Archive: Plugin-DLL keeps Crashing


Plugin-DLL keeps Crashing
  Hello all,

I am trying to write a DLL with PureBasic :-)
I can call the DLL-function and I can even pass a parameter, but when the DLL-function ends the exe is crashing everytime with the error-code 0xc0000005. Does anyone have an idea?

Thanks,
Sepp

dlltest.nsi


"."


>Name "DLL-Test"
>OutFile "dlltest.exe"
>RequestExecutionLevel user
SilentInstall silent

Section
MessageBox MB_OK "This is an internal MessageBox"
dlltest::testprocedure "This is an DLL MessageBox with NSI-parameter"
MessageBox MB_OK "This is the last Message"
>SectionEnd
>
dlltest.pb

Structure TCHAR

char
.i
EndStructure

Structure stack_t
*Next.stack_t
text.s{1024}
>EndStructure

ProcedureDLL testprocedure(hwndParent.i, string_size.i, *variables.TCHAR, *stacktop_pointer, *extra)
*stacktop.stack_t = PeekI(*stacktop_pointer)
*stacktop_pointer = *stacktopNext ; Decrease Stack
MessageRequester("testprocedure", *stacktoptext)
>EndProcedure
>

Try ProcedureCDLL


What about dlltest::testprocedure /NOUNLOAD "This is an DLL MessageBox with NSI-parameter" ??


Originally posted by T.Slappy
What about dlltest::testprocedure /NOUNLOAD "This is an DLL MessageBox with NSI-parameter" ??
I tried that, but it is still crashing.
Also /NOUNLOAD was deprecated in NSIS 2.42 (but still works).

Originally posted by Anders
Try ProcedureCDLL
Yes, that's it :up:
Thank you very very much! I tried it for several hours, but did not got it.

I researched a little bit more, for all who are interested: NSIS-DLL's must use the cdecl calling convention (Windows-default is stdcall) whereas the calling function cleans the stack (at stdcall the callee cleans the stack).