flat assembler
Message board for the users of flat assembler.

Index > Windows > wether to use invoke or cinvoke for dll functions

Author
Thread Post new topic Reply to topic
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 24 May 2012, 17:35
Maybe this question have been answered already but could not find relevant information with search function in adaquate time. Shocked

How do I know wether to use invoke or cinvoke macro to call a DLL function ?
I think the MS DLL's are all compatible with the invoke macro but what about custom DLL's not designed by MS ? How can I obtain the calling procedure if not provided in documents ?

Concrete case is for this API
http://www.ftdichip.com/Support/Documents/ProgramGuides/D2XX_Programmer%27s_Guide%28FT_000071%29.pdf

But would be good to know in general for future / other provided API's.

Thanks for help. Very Happy
Post 24 May 2012, 17:35
View user's profile Send private message Send e-mail Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 24 May 2012, 18:30
By looking at FTD2XX.H in example 1 I'd say they are stdcall and therefore you must use invoke. The reason I think they are stdcall is because they are marked WINAPI (which is defined as __stdcall).
Post 24 May 2012, 18:30
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20302
Location: In your JS exploiting you and your system
revolution 24 May 2012, 20:46
Yes, you use invoke. This is from my code:
Code:
       invoke  FT_SetBaudRate,[comm_handle],FT_BAUD_115200    
Post 24 May 2012, 20:46
View user's profile Send private message Visit poster's website Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 24 May 2012, 21:50
Thanks for information.

But is there a general rule what macro to use under which circumstances (if documentation is not provided or not with that detail) ?
Post 24 May 2012, 21:50
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20302
Location: In your JS exploiting you and your system
revolution 24 May 2012, 22:23
shutdownall wrote:
But is there a general rule what macro to use under which circumstances ...
Yes.

cinvoke for ccall
invoke for stdcall
shutdownall wrote:
... (if documentation is not provided or not with that detail) ?
Use a debugger and check the return type.

ret = ccall
ret imm = stdcall
Post 24 May 2012, 22:23
View user's profile Send private message Visit poster's website 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.