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
2
votes
1 answer

Understanding the concept of STDCALL vs CDECL with EBP and ESP cleanup

I believe I understand the difference between STDCALL and CDECL but I'm wondering if I can find some clarification within this code. I understand that in STDCALL the CALLEE is responsible for cleaning up the stack, and I understand that in CDECL the…
2
votes
1 answer

__stdcall typedef g++ problem

This code compiles (as I would expect): typedef void __stdcall (*Func)(); struct A { static void __stdcall f() { } }; int main() { Func p = A::f; } But this one: struct A { typedef void __stdcall (*Func)(); static void __stdcall…
jhh
  • 155
  • 1
  • 6
2
votes
1 answer

Calling LONGLONG RtlLargeIntegerDivide(LONGLONG, LONGLONG, LONGLONG*) in NASM (stdcall)

I'm trying to call the following function: long long RtlLargeIntegerDivide(long long dividend, long long divisor, long long* pRemainder) in assembly code (NASM). It uses the stdcall calling convention, and it returns the quotient. These are the…
user541686
  • 205,094
  • 128
  • 528
  • 886
2
votes
1 answer

ASM Function Call & Ret - What does ret 0xC do?

What does ret do? Why is ret 0xC needed here? What if it was just ret and not ret 0xC or how about 0x4? mov eax,[esp+10] // param3 mov ecx,[esp+0C] // param2 mov edx,[esp+08] // param1 push eax push ecx push edx mov ecx,esi call File.exe+333330…
2
votes
2 answers

Mixed calling conventions make compilation errors

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…
Allen L
  • 127
  • 1
  • 11
2
votes
1 answer

DllExport not creating an entry point

I am trying to create a C# unmanaged DLL using Robert Giesecke's "UnmanagedExports" nuget package, but it doesn't seem to be creating any entry points. Full code here: using System.IO; using System.Runtime.InteropServices; using…
nevada_scout
  • 971
  • 3
  • 16
  • 37
2
votes
1 answer

How does this asm for a stdcall function clean args from the stack?

I have simple code. StdCall is __stdcall and CdeclCall is __cdecl. #include int __stdcall StdCall(int a,int b) { return a + b; } int __cdecl CdeclCall(int a,int b) { return a + b; } int main(int argc, char **argv) { …
Pranit Kothari
  • 9,721
  • 10
  • 61
  • 137
2
votes
3 answers

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

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 =…
codeLover
  • 3,720
  • 10
  • 65
  • 121
2
votes
3 answers

Windows function names followed by @ number symbol?

I'm programming for Windows in assembly in NASM, and i found this in the code: extern _ExitProcess@4 ;Rest of code... ; ... call _ExitProcess@4 What does the @4 mean in the declaration and call of a winapi library function?
Smax Smaxović
  • 550
  • 2
  • 7
  • 17
2
votes
2 answers

how to use assembly to get the result of a __stdcall function that returns float

I have an assembly routine that calls, in a generic way, a function known to use the stdcall convention and return a float. This function is being used by a marshalling framework to expose stdcall functions to a scripting language. Background Here's…
0xbe5077ed
  • 4,565
  • 6
  • 35
  • 77
2
votes
1 answer

GNU inline asm: which registers get clobbered by __stdcall?

If I am using the call instruction, via GNU's inline assembler in C++ code, to call a function I know uses the __stdcall convention, do I have to list any registers as clobbered? I'm not finding great guidance on the internet, but it looks like…
0xbe5077ed
  • 4,565
  • 6
  • 35
  • 77
2
votes
1 answer

QtConcurrent::run() doesn't accept __stdcall/WINAPI function

I was trying to execute a DLL function that has __stdcall calling convention using QtConcurrent::run(), but I am getting compile errors. I've reduced the problem to this example code: __stdcall void dllFunc() { qDebug() << "test"; } void test()…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
2
votes
1 answer

assigning functions to std::function with same signature, but different calling convention fails

the following compiles and runs just fine with mingw 4.7.2 and -m64 flag. but with -m32 or with any mingw 32bit release it fails to compile. is it a bug or am i missing a compiler flag? #include #include using…
user1283078
  • 2,006
  • 17
  • 17
2
votes
1 answer

COM Server: ESP not saved across a function call when calling interface method

I'm in the process of implementing a COM server in an EXE file. To be precise, I'm adding a COM interface to an existing application. with the ultimate goal of automating the application. The first component and an interface (with a single method so…
Dabbler
  • 9,733
  • 5
  • 41
  • 64
2
votes
1 answer

Fastcall in 64 bit

I've been reading up on the differences in 32bit calling conventions. The fastcall vs. stdcall ordeal that is. From what I read there was great confusion with the two conventions, and 64 bit was standardized to avoid this confusion. I have to ask,…
Hawken
  • 2,059
  • 19
  • 34