Bug using dynamicaly loaded function ?
Vermi
moi at vermi.fr
Fri Oct 31 04:21:10 PDT 2008
Hi,
I'm having trouble with a very simple code, I don't know if it's a bug of the compiler or if I do something wrong.
Here is the peace of code :
---------------------------
alias BOOL function(HWND, DWORD) REGISTERSHELLHOOKPROC;
// Get function at ordinal 181
REGISTERSHELLHOOKPROC _registerShellHook = cast(REGISTERSHELLHOOKPROC)GetProcAddress(GetModuleHandleA("SHELL32.DLL"), cast(char*)0x000000B5);
if ( _registerShellHook != null )
{
_registerShellHook(null, 1);
_registerShellHook(this._handle, 3);
}
---------------------------
It compile sucessfully, but I have an "Access Violation" at runtime. After looking at the generated assembler code I found that the call is not compiled the right way.
_registerShellHook(null, 1); is compiled as :
push 0 <--- Should be afteur the "push 1"
mov eax, 1 <--- should be push 1
call esi <--- right adress
it's the same problem for the second call. What have I done wrong ?
More information about the Digitalmars-d-bugs
mailing list