stdcall

Inconsistent results calling DLL from JNA/C versus Pascal

断了今生、忘了曾经 提交于 2019-12-11 20:44:53
问题 I have a c++ dll library with header files provided, without implementation. And I implement JNA call for this library functions. And I have the problem with only 1 function (other, even similar works fine). This is declaration from .h file: int CALLINGCONV SMIMESignML( const char* pin, unsigned long slot, const char* szOutputFilePath, const char* szFrom, const char* szTo, const char* szSubject, const char* szOtherHeaders, const char* szBody, const char* szAttachments, unsigned long dwFlags,

mingw32 g++ and stdcall @suffix

时光怂恿深爱的人放手 提交于 2019-12-11 12:37:06
问题 I declared some C++ functions prototyped as follows: extern "C" void __stdcall function(); I also have some third-party dll with exported function() - no name decorations at all. I'm unable to build my exe or dll due to undefined reference to function@... , because of MinGW's stdcall @-suffix. How can I obtain object file without @... just plain function names? 回答1: It sounds like you're trying to use MinGW to compile a program that uses external C functions from a third-party dll. There's a

Very strange segfault calling WinUsb_GetOverlappedResult

倾然丶 夕夏残阳落幕 提交于 2019-12-08 08:17:42
问题 I have this code: void GetResult(WINUSB_INTERFACE_HANDLE InterfaceHandle, LPOVERLAPPED lpOverlapped) { DWORD numBytes = 0; WinUsb_GetOverlappedResult( InterfaceHandle, lpOverlapped, &numBytes, TRUE ); return; uint8_t stack[64]; } WinUsb_GetOverlappedResult is a __stdcall function declared as follows: WINBOOL WINAPI WinUsb_GetOverlappedResult (WINUSB_INTERFACE_HANDLE InterfaceHandle, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, WINBOOL bWait); Compiling in debug mode with GCC

Why did Microsoft choose stdcall as their API convention?

Deadly 提交于 2019-12-07 05:00:44
问题 Is there a good reason? Are their internal functions (not exported) also stdcall convention? 回答1: It was an adaptation to the pascal calling convention for 32-bit code. Pascal was the calling convention for 16-bit operating systems like OS/2 and Windows 3. Why pascal was chosen is a bit of a guess, even I was a small pup back then, but it is slightly more efficient. Which mattered back when 640 KB was all you had to work with. Most Win32 functions aren't true stdcall as it also prescribes how

In C++, do variadic functions (those with … at the end of the parameter list) necessarily follow the __cdecl calling convention?

寵の児 提交于 2019-12-07 00:22:58
问题 I know that __stdcall functions can't have ellipses, but I want to be sure there are no platforms that support the stdarg.h functions for calling conventions other than __cdecl or __stdcall. 回答1: The calling convention has to be one where the caller clears the arguments from the stack (because the callee doesn't know what will be passed). That doesn't necessarily correspond to what Microsoft calls "__cdecl" though. Just for example, on a SPARC, it'll normally pass the arguments in registers,

Why need to use “WINAPI*” for the Syntax for declaring function pointers for functions in a DLL

会有一股神秘感。 提交于 2019-12-06 11:37:43
I have a C++ console application & a DLL. In the C++ application I see the following snippet :: typedef DWORD (WINAPI* functABC)(unsigned long*); functABC functABC111; HMODULE handleDLL = LOadLibrary("a.DLL"); functABC111 = (functABC)GetProcAddress(handleDLL,"function_1"); At a high level I understand that we are getting the function pointer to the function in a.DLL "function_1()". But want to understand the 1st 2 lines in the above snippet :: typedef DWORD (WINAPI* functABC)(unsigned long*); functABC functABC111; 2 questions :: 1) Is the name "functABC" just a random function pointer name? 2)

Can stdcall have a variable arguments?

落花浮王杯 提交于 2019-12-06 08:20:55
问题 As far as I know, only the caller-clean-stack convention can use variable arguments. By the way, the WinApi StringCchPrintfW is declared like this.(I removed the SAL) __inline HRESULT __stdcall StringCchPrintfW( STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat, ... ); Can stdcall have a variable arguments either? 回答1: No. The stdcall calling convention has the callee clean the stack. Since the callee is cleaning the stack there is no way for it to know at compile time how

Writing naked functions with custom prolog and epilog code in Visual Studio

£可爱£侵袭症+ 提交于 2019-12-06 05:15:04
问题 I'm writing some plugin code in a dll that is called by a host over which I have no control. The host assumes that the plugins are exported as __stdcall functions. The host is told the name of the function and the details of the arguments that it expects and dynamically crufts up a call to it via LoadLibrary, GetProcAddress and manually pushing the arguments onto the stack. Usually plugin dlls expose a constant interface. My plugin exposes an interface that is configured at dll load time. To

How to make stdcall from Go

旧街凉风 提交于 2019-12-06 00:06:25
I have a pointer to a COM interface and would like to take the function pointers from its virtual table and make method calls. To do this I need to make stdcall method calls. In Go how do I make a call with convention stdcall or make a call with convention stdcall in cgo? See "godoc syscall Proc" for instructions on how to call stdcall functions on windows. Be warned that *Proc.Call does allocate / deallocate memory, so, if you care about efficiency, you should use correspondent syscall.Syscall/syscall.Syscall6/syscall.Syscall9/... function instead. Alex 来源: https://stackoverflow.com/questions

Why did Microsoft choose stdcall as their API convention?

孤人 提交于 2019-12-05 10:00:56
Is there a good reason? Are their internal functions (not exported) also stdcall convention? It was an adaptation to the pascal calling convention for 32-bit code. Pascal was the calling convention for 16-bit operating systems like OS/2 and Windows 3. Why pascal was chosen is a bit of a guess, even I was a small pup back then, but it is slightly more efficient. Which mattered back when 640 KB was all you had to work with. Most Win32 functions aren't true stdcall as it also prescribes how the exported function is decorated before presented to the linker. Like void Mumble(int arg) becomes