flat assembler
Message board for the users of flat assembler.

Index > Windows > Help with a C callable dll

Author
Thread Post new topic Reply to topic
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 06 Dec 2006, 18:57
I have a dll written in assembly and trying to make it c-callable, It works correctly except I don't think the stack is geting cleaned up properly. Does anyone know what I'm doing wrong? Or is it a macro problem? The test code is below, The executable is c code, and the dll is assembly. It uses my own custom includes, but the example is very small and should convert to standard fasm include format very easy. The code is below.


Last edited by madmatt on 06 Dec 2006, 21:11; edited 2 times in total
Post 06 Dec 2006, 18:57
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 06 Dec 2006, 19:23
Your C program is assuming that your DLL proc is stdcall. Make your DLL stdcall too or try to fix your C environment. IMHO it's better to use stdcall in the DLL
Post 06 Dec 2006, 19:23
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 06 Dec 2006, 21:04
Hey thanks! Very Happy Changed "proc c ...." to "proc stdcall ..." and everything works. Cool

[EDIT] Corrected version in the first post. [END EDIT]
Post 06 Dec 2006, 21:04
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 07 Dec 2006, 01:40
Note that stdcall is the default so you can pass from "proc c ...." to "proc ...." if you want.
Post 07 Dec 2006, 01:40
View user's profile Send private message Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost 08 Dec 2006, 11:35
There is nothing wrong with having stdcall but if it's purely for C, C/cdecl is the default type for C functions and if you're compiler is assuming the functions are stdcall you have default calling convention set to stdcall. Anyways you should probably declare procedures with "type convention name( ... )" if it's in a Windows environment, even if they are cdecl.

_________________
redghost.ca
Post 08 Dec 2006, 11:35
View user's profile Send private message AIM Address MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.