Questions tagged [stdcall]

Anything related to the `stdcall` calling convention, i.e. one of the common subroutine calling conventions used on systems with x86 architecture.

Anything related to the stdcall calling convention, i.e. one of the common subroutine calling conventions used on systems with x86 architecture.

See Wikipedia on:

150 questions
7
votes
2 answers

Why did Microsoft define WINAPI, CALLBACK, and APIENTRY to all refer to __stdcall?

This is a curiosity question for anybody who has worked for, known somebody who's worked for, or otherwise had any sort of affiliation with the Microsoft team responsible for defining these macros. I understand what __stdcall is and I know why it's…
Aaron
  • 181
  • 1
  • 12
6
votes
1 answer

Why does first parameter in x86 assembly starts from offset 8?

I'm trying to develop understanding of Assembly language. I understand that when function creates stack frame, it pushes current EBP, than copies stack pointer value to the EBP. First (and only) function parameter is accessed by EBP + 8. But why 8?…
Inline
  • 2,566
  • 1
  • 16
  • 32
6
votes
2 answers

64-bit C++ passing functions with "different" calling conventions as parameters gives ambiguous error

My goal is to easily extract a prototype of an arbitrary function with both the __cdecl and __stdcall calling conventions. It works fine in 32-bit. The only thing that's changing is the calling convention in my template function…
Goodies
  • 4,439
  • 3
  • 31
  • 57
6
votes
1 answer

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…
David
  • 63
  • 1
  • 3
6
votes
1 answer

Plainly and simply, why do we use _stdcall?

I've come across calling conventions whilst studying states for game making with C++. In a previous question someone stated that MSDN doesn't explain _stdcall very well - I agree. What are the primary purposes for calling conventions like _stdcall?…
Dezachu
  • 153
  • 1
  • 2
  • 10
5
votes
1 answer

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…
Len Holgate
  • 21,282
  • 4
  • 45
  • 92
5
votes
1 answer

Calling Convention with a shared library for android

I created some plugin files in C++ for my Unity3d app. So far the app was just a simple protype, so I tested only on my desktop with libraries compiled as DLL for Windows. Today I recompiled those files as .so(Shared Object) for Android(both arm and…
Jenix
  • 2,996
  • 2
  • 29
  • 58
5
votes
1 answer

What are the sign extension rules for calling Windows API functions (stdcall)? This is needed to call WInAPI from Go, which is strict about int types

Oops, there was one thing I forgot when I made this answer, and it's something that I'm both not quite sure on myself and that I can't seem to find information for on MSDN and Google and the Stack Overflow search. There are a number of places in the…
andlabs
  • 11,290
  • 1
  • 31
  • 52
5
votes
3 answers

Calling a function that can be either cdecl or stdcall

I need to write code that calls an external function that can be either stdcall call or cdecl in a 32bit windows application. My code, the caller, can't know in advance which of these its going to be. Right now, if I try to call a cdecl function…
shoosh
  • 76,898
  • 55
  • 205
  • 325
4
votes
2 answers

What is the correct callback signature for a function called using ctypes in python?

I have to define a callback function in Python, one that will be called from a DLL. BOOL setCallback (LONG nPort, void ( _stdcall *pFileRefDone) (DWORD nPort, DWORD nUser), DWORD nUser); I tried this code, that seems to work in Python 2.5 but with…
sorin
  • 161,544
  • 178
  • 535
  • 806
4
votes
2 answers

Stack cleanup not working (__stdcall MASM function)

there's something weird going on here. Visual Studio is letting me know the ESP value was not properly saved but I cannot see any mistakes in the code (32-bit, windows, __stdcall) MASM code: .MODE FLAT, STDCALL ... memcpy PROC dest : DWORD,…
Carol Victor
  • 331
  • 1
  • 7
4
votes
1 answer

Calling functions from Rust DLL with Excel VBA

I'm trying to create a Rust DLL and call those functions from 64bit Excel (Windows 10 and Office 365). Currently my lib.rs looks like this: #[no_mangle] pub extern "stdcall" fn square(x: f64) -> f64 { {x * x} } I'm compiling with command: rustc…
A. Soikkeli
  • 134
  • 2
  • 7
4
votes
1 answer

Pinvoke native method with pascal callingconvention

I have an old c++ librrary and all of methods exports with pascal calling convention, As i know c# marshaller does not support pascal calling convention, Can i use stdcall on c# side and pass parameters in reverse order?
4
votes
4 answers

Why isn't PInvoke crashing in case of violated calling convention (in .NET 3.5)?

My solution has an unmanaged C++ DLL, which exports a function, and a managed application that PInvokes this function. I've just converted the solution from .NET 3.5 to .NET 4.0 and got this PInvokeStackImbalance "A call to PInvoke function [...]…
Alex Che
  • 6,659
  • 4
  • 44
  • 53
4
votes
2 answers

GCC exports decorated function name only from dll

I have a dll, it exports a function... extern "C" int __stdcall MP_GetFactory( gmpi::IMpUnknown** returnInterface ) { } I compile this with Code::Blocks GCC compiler (V3.4.5). Problem: resulting dll exports decorated function…
Jeff McClintock
  • 1,242
  • 10
  • 27
1
2
3
9 10