Skip to main content
May 22, 2017
Answered

Reader-enabled plugin unloading when an external library is used

  • May 22, 2017
  • 2 replies
  • 1785 views

Hello,

I am developing a plugin for Adobe Reader which has to interact with an external web service.

To interact with this web service, I'd like to use the C++ REST SDK​, hence I have to include its library in my plugin.

As soon as I add a source file using any C++ REST SDK object in my plugin, it will compile, load in Adobe Reader and unload as soon as it starts.

If I just include the library in the source file, it runs normally. I tested my source file in another project and it works well.

The only clue I get about this unloading is the following lines in the output of Adobe Reader (debugged in Visual Studio):

'AcroRd32.exe' (Win32): Loaded 'C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\plug_ins\MyPlugin.api'. Symbols loaded.

'AcroRd32.exe' (Win32): Unloaded 'C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\plug_ins\MyPlugin.api'

Exception thrown at 0x7795A9F2 in AcroRd32.exe: Microsoft C++ exception: _ASExceptionInfo at memory location 0x005FD664.

My plugin is successfully signed for Adobe Reader (I have a RIKLA key), it's based on the BasicPlugin sample, and I checked that the C++ Rest SDK is correctly included in the MyPlugin.api file.

I also haven't found any information about such an "AsExceptionInfo" anywhere.

Do you have any idea about how I could solve this problem?

Thanks in advance for you answers.

This topic has been closed for replies.
Correct answer lrosenth

Alright.

Well, when a library is included but not called, I can use the debugger and go through my code. As soon as I call any function of a library, all my breakpoints become useless (Visual Studio says that "The breakpoint will not currently be hit. No symbol have been loaded for this document.").

I tried putting a breakpoint in the PIHandshake and/or PluginInit methods, and none of them are reached. I guess that my plugin fails before it even runs then, right? If so, how can I get more details about my Exception?


You’ve been saying library – which to me implies a STATICALLY linked library. But are you instead referring to a DLL? If so, then I suspect your problem, as TSN says, is that you aren’t putting the DLL in the right place to be properly loaded!

2 replies

Legend
May 26, 2017

You need to follow the rules of DLL searching. A plug-in is a DLL, and loading a DLL does not update the DLL search order. So a DLL in the plug_ins folder is not found. A DLL in the Acrobat EXE folder might be found, but it would be absolutely wrong to modify Acrobat's EXE folder in this way. So you either need to install it in the standard system folders, or load it yourself with LoadLibrary etc.

lrosenth
Adobe Employee
Adobe Employee
May 22, 2017

Does the plugin work in Acrobat?

Do you have Sandboxing or Protected Mode enabled in Reader?

May 22, 2017

I haven't and cannot test the plugin in Acrobat.

Both of those modes are disabled.

lrosenth
Adobe Employee
Adobe Employee
May 22, 2017

Why can you not test the plugin in Acrobat? All plugin development – even/especially for Reader – should be done in Acrobat.

Without knowing what the 3rd party library does, and what your code is doing, it’s really impossible us to know why the crash. Offhand, I would first start by checking all your error handling, especially making sure you aren’t mixing exception models (aka try/catch vs. DURING/HANDLER). Next I would use your source debugger to walk through the code and see where the problem occurs and if you can get more info about the crash.