Skip to content
⌘ NSIS Forum Archive

plugin make installer crash

5 posts

ginglese#

plugin make installer crash

Hi all,

i'm facing a problem.

i have a nsis plugin i made, each time i use the function from this plugin, installer crash when installer exit from this plugin function.

i have a section for license check:

Section -license
push $R1

!insertmacro LICENSECHECK SIMU
pop $R1

MessageBox MB_ICONSTOP|MB_OK "license return $R1"
SectionEnd
macro is :
!macro LICENSECHECK _TYPE

; set install for all users
SetShellVarContext all
SetOverwrite try

push $R1
;install VC (9) 2008 MSVCRT dll
!insertmacro ALL_INSTALLVCREDIST
pop $R1

SetOutPath $TEMP

File "${SRC_COMMON_DIR}\Bin\<dependencies>1.dll"
...
File "${SRC_COMMON_DIR}\Bin\<dependencies>N.dll"

SetOutPath "$TEMP\Data\Lang"
File /r "${SRC_COMMON_DIR}\Data\Lang\*"

SetOutPath $TEMP

; backup current R2 value
push $R2

; push on the stask, product code id (this is poped in the plugin)
push ${PRODUCT_SHORT_VERSION}
push ${${_TYPE}_LICENSE_ID}
push ${STRING_VALIDATOR}
LicenseValidatorPlugin::validateLicense
; get license result
pop $R2

--> this message box is not display and installer crash
MessageBox MB_ICONSTOP|MB_OK "license return "

; if module cannot be loaded return 1
StrCmp $R2 ${STRING_VALIDATOR} 0 lbl_LICENSECHECK_endFct
StrCpy $R2 1

lbl_LICENSECHECK_endFct:

; delete
Delete "$TEMP\<dependencies>N.dll"

RMDIR /r "$TEMP\Data\Lang"

;restore
Exch $R2

!macroend
Do you have any clue how can i find what is the problem ?
I have displayed a messagebox at the end of my plugin function and it's displayed, but not the nsis messagebox after the plugin function, installer crash instead.

Thank you for your help.

Guillaume
Anders#
cdecl vs stdcall forced in a .def file?

It is basically impossible for us to tell when you don't post your plugin source and compiler switches used.

I would suggest that you run it in a debugger and make sure the stack is correct after you exit the plugin function...
ginglese#
Hi Anders,

Thank you for your answer.

I used this plugin in previous version of my program installer and it was working.
i have a new version and I updated installer script too.

My plugin is build with VC9, what is "cdecl vs stdcall forced in a .def file?" ?


how can i run nsis plugin in a debugger ?

BR,

Guillaume
Anders#
Here is a simple example:
#include <Windows.h>
#include <tchar.h>
EXTERN_C __declspec(dllexport) void STDMETHODVCALLTYPE Hello(HWND hwndNSIS, UINT cchNSIS, LPTSTR Vars)
{
MessageBox(hwndNSIS,Vars,_T("Register $0 is:"),0);
}

EXTERN_C BOOL STDMETHODCALLTYPE _DllMainCRTStartup(HINSTANCE hInst, DWORD dwReason, LPVOID pCtx)
{
return TRUE;
}
cl /O1 /Zl /LD temp.c /link user32.lib
SectionStrCpy $0 "Hello World"
temp::Hello
SectionEnd
To debug run the installer in the Visual Studio debugger or WinDbg...
ginglese#
Hi Anders,

Didn't found a way to debug my code ... i run the installer from visual but no debug info....

Anyway, I found my problem ! i removed all code from plugin and added part by part until i experience the crash.

Problem came from the some object destructor called automatically at the end but dependant on some static object already destroyed...
To solve the problem i dynamicatlly allocated my object and delete them before the static objects.

Thanks for your help.

Guillaume