stdcall

What is __stdcall?

I'm leaning some win32 programming, and the WinMain prototype looks like: int WINAPI WinMain ( HINSTANCE instance, HINSTANCE prev_instance, PSTR cmd_line, int cmd_show ) I was confused as to what this WINAPI identifier was for and found: #define WINAPI __stdcall What does this do? I'm confused by this having something at all ...

Thought experiment with __stdcall and corrupted stack (C++)

My mind was wandering today on the topic of function pointers, and I came up with the following scenario in my head: __stdcall int function (int) { return 0; } int main() { (*(int(*)(char*,char*))function)("thought", "experiment"); return 0; } AFAIK this code would corrupt the stack, so what types of issues could I be loo...

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

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...

Create a C# DLL That Can Be Imported in a Delphi App Using stdcall - Possible?

I have a program that I need to create a DLL for, hopefully in C#. The program is written in Delphi and I have an interface file to code to. The interface uses the stdcall calling convention. Is it possible to create a C# DLL that conforms to the interface and can be used in the Delphi application? Is there some sample code that demo...

syntax error: _stdcall -- Help? Please?

Hello, I am trying to use this code to define the APIs that are needed to communicate with a card reader. Below is the header file (complete). [AtUsbHid.h] It is throwing several errors, but I figure if the syntax issue is solved, the rest will fall into place. Please help me out. I made sure that __export was replaced with __declsp...

Creating an MSVC import library from a DLL that uses stdcall

I have a dll that exports extern "C" __declspec(dllexport) int __stdcall Foo( void ); A dump of the dll shows ****************************************************************************** Section: Exports File Offset: 00001400 (5120) Flags: 00000000 Time Stamp: 00000000 Major Version: ...

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

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. ...

How do I compile boost using __cdecl calling convention?

I have a project compiled using __cdecl calling convention (msvc2010) and I compiled boost using the same compiler using the default settings. The project linked with boost but I at runtime I got an assert message like this: File: ...\boost\boost\program_options\detail\parsers.hpp Line: 79 Run-Time Check Failure #0 - The value of ESP w...

Is there STDCALL in Linux?

hello, I'm trying to port a Windows app to Linux. This appplication marks some functions with the __stdcall attribute. However, i was told by a friend that stdcall is used only on windows and has no meaning in linux (but DOES exist in Windows GCC). I tried to search Google about that, and got some results state that there IS stdacll in L...

Mixed calling conventions make compilation errors

Hi, I have a library (C++) which has some API functions. One of them is declared as __cdecl, but gets a function poiner from __stdcall. Something like: typedef int (__stdcall *Func)(unsigned char* buffer); //... int ApiFunc(Func funcPtr); //This is __cdecl since it is an 'extern "C"' library and the calling convention is not specified...

Calling functions meant for threads normally

I have a function with the prototype DWORD WINAPI blah(LPVOID arg); Which was meant to be used with CreateThread for a threaded app. I call it with CreateThread with no problem. But then somewhere else in the code, I call it normally, just by blah(NULL). When it gets to this part, it crashes. Is this because the WINAPI part makes it ...

Why did Microsoft choose stdcall as their API convention?

Is there a good reason? Are their internal functions (not exported) also stdcall convention? ...

Can stdcall have a variable arguments?

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 eithe...