I want to call the ANSI method "Popup" defined like a standard rundll32 callable entry proc.
extern "C" void CALLBACK Popup(HWND, HINSTANCE, LPSTR commandLine, int) {
}
The code below loads the dll successfully and can call the proc. However something in the proc does something with the MSVCRT and this generates the "Abnormal Program Termination" message box.
---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Runtime Error!
Program: ...\Test.exe
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
---------------------------
OK
---------------------------
Is there something I have to call inside my asm code to initialize the msvcrt? I have checked the WINE port rundll32.c file and could not see any unusual going on there in regards to MSVCRT initialization.
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\shlwapi.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\shlwapi.lib
.data
dllName db "test",0
funcName db "Popup",0
moduleName db 256 dup (0)
.data?
instance HINSTANCE ?
commandLine LPSTR ?
popupFunc dd ?
.code
start:
invoke GetModuleFileNameA, NULL, addr moduleName, 256
invoke PathStripPathA, addr moduleName
;invoke MessageBoxA,NULL, addr moduleName, NULL, MB_OK
invoke lstrlenA, addr moduleName
mov ebx,eax
invoke GetCommandLineA
add ebx, eax
mov commandLine, ebx
;invoke MessageBoxA,NULL, commandLine, NULL, MB_OK
invoke LoadLibrary, addr dllName
.if eax != NULL
mov instance,eax
invoke GetProcAddress, instance, addr funcName
.if eax != NULL
mov popupFunc, eax
push SW_SHOWDEFAULT
push commandLine
push instance
push 0 ; hwnd
call [popupFunc] ; Crashes in msvcrt
.endif
.else
;invoke MessageBox,NULL,addr dllName, NULL, MB_ICONERROR
.endif
invoke ExitProcess,0
end start
Any ideas?