|Syntactic Confectionery Delight|
Re: Win32::API and 'short' argumentsby BrowserUk (Pope)
|on May 10, 2006 at 01:19 UTC||Need Help??|
Example: This DLL
Built with this.DEF file
And this command line
Can be successfully accessed using this perl/win32::API code:
However, if you omit the .DEF file above, then the exported entrypoint will be mangled and look like this:
instead of like this (when built with the def file):
And you would have to change the import and invokation to look like this (Note the use of the mangled name and the disabling of strict):
Alternatively, if the module was built using compiler options that mean that WINAPI translates to _cdecl (the standard C calling convention):
Then although if you build it without a def file and inspect the dll it looks the same as when built with _stdcall and a .def file:
When you try to call it with Win32::API
You will get a segfault because of the mis-match in the calling conventions.
It is not always possible to tell which calling convention was used to build the DLL by simple inspection.
You say you have the .def file; it may be possible to determine from that. You also say that you don't get segfaults when you are calling the code, which is a pretty strong indication that it was built using _stdcall, which is generally the MS compiler default.
If the DLL was built with non-MS tools, things can be more complicated still.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.