digitalmars.D.bugs - Bug using dynamicaly loaded function ?
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 ?
Oct 31 2008
Sorry, I found my error, I made this : alias extern(C) BOOL function(HWND, DWORD) REGISTERSHELLHOOKPROC; It looks like it's working (the generated code is the right code).
Oct 31 2008