The MASM Forum Archive 2004 to 2012

General Forums => The Laboratory => Topic started by: fallenhobbit on January 07, 2005, 08:50:58 AM

Title: Macros for calling c/c++ functions
Post by: fallenhobbit on January 07, 2005, 08:50:58 AM
I recently posted a few things on having problems calling c/c++ runtime functions because the c/c++ runtimes use the _cdecl calling convention. This is the culmination of my research thus far. Its a series of macros that let you easily call most of the exported functions in the VC++ msvcrt.dll runtime. Feel free to flame me...Im kinda new to assembly (about a year coding in it)....cheers

[attachment deleted by admin]
Title: Re: Macros for calling c/c++ functions
Post by: hutch-- on January 07, 2005, 10:07:22 AM
 :bg

Never fear, we SHOOT people who flame others in here.  :naughty:

Compliments on te work you have posted as well, it looks well done.  :U
Title: Re: Macros for calling c/c++ functions
Post by: Vortex on January 07, 2005, 10:50:27 AM
Hi fallenhobbit,

Welcome to the forum, nice work :U

You have another choice to declare C functions:
printf PROTO C :VARARG
Title: Re: Macros for calling c/c++ functions
Post by: Jibz on January 07, 2005, 11:12:50 AM
Yes, I was about to suggest the same thing. I guess it's because of the choice to make everything stdcall in MASM32 instead of adding the proper calling conventions to the prototype includes that many people do not consider this.

Here is a version that shows it works with invoke .. I didn't add printf so there's still a bit of work to do ;).

[attachment deleted by admin]
Title: Re: Macros for calling c/c++ functions
Post by: Vortex on January 07, 2005, 06:06:10 PM
There is an easy method to create an import library for msvcrt.dll

polib /out:msvcrt.lib \windows\system32\msvcrt.dll