Skip to content
⌘ NSIS Forum Archive

Plugin-DLL keeps Crashing

4 posts

sepp2012#

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
!addplugindir "."
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 = *stacktop\Next ; Decrease Stack
  MessageRequester("testprocedure", *stacktop\text)
EndProcedure 
T.Slappy#
What about dlltest::testprocedure /NOUNLOAD "This is an DLL MessageBox with NSI-parameter" ??
sepp2012#
Originally Posted by T.Slappy View Post
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 View Post
Try ProcedureCDLL
Yes, that's it 👍
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).