0

I wanna to use NPAPI plugin in my app and i created a functions, provides by a browser to plugin. Load library, initialization and start, all goes well, until it comes to a function NPP_New. This function makes crash, because NPP pointer (tried instead to specify 0 - the function returns an error code 2 "Invalid Instance" and not crash). I think there is a problem in memory access.Found several ways of memory sharing, but I do not know exactly what is appropriate in this case.

// ...
char szMimeType[] = "application/x-some-plugin";
NPP_t npp; npp.pdata = 0; npp.ndata = &npp;
UINT result = NPP_New(szMimeType, &npp, NP_FULL, 0, 0, 0, NULL);
// ...
Georg Fritzsche
  • 97,545
  • 26
  • 194
  • 236
Alex Shul
  • 500
  • 7
  • 22
  • What type of crash do you get? The npp usage as posted shouldn't crash anything - are you sure it's not another problem like accessing incorrectly setup function pointer tables or your app crashing in NPN functions called from NPP_New? – Georg Fritzsche Jan 13 '14 at 07:45
  • The docs for `NPP_New` say "`NPP_New` creates a new instance of a plug-in. It is called after `NP_Initialize`". I don't see your call to `NP_Initialize` – woolstar Jan 13 '14 at 07:53
  • My actions: `LoadLibrary()` -> returns valid handle; `GetProcAddress()` for "NP_GetEntryPoints" and "NP_Initialize" -> returns valid pointers; `NP_GetEntryPoints()` -> returns `NPERR_NO_ERROR`; `NP_Initialize()` -> returns `NPERR_NO_ERROR`; `NPP_New()` -> crashes `Unhandled exception "0x77e615de" in "MyApp.exe": 0xC0000005: Access violation.` If call `NPP_New(szMimeType, 0, NP_FULL, 0, 0, 0, NULL)` -> retruns `NPERR_INVALID_INSTANCE_ERROR` and not crashes; – Alex Shul Jan 13 '14 at 14:12

1 Answers1

0

@Georg Fritzsche, you were right! The problem was in pointers to NPN_ functions. Variable NPNetscapeFuncs pNpnFuncs create and fill as a local in one of my functions and thus destroyed on completion of the function. When I did pNpnFuncs global variable - everything was fine work.

Alex Shul
  • 500
  • 7
  • 22