News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Macros for calling c/c++ functions

Started by fallenhobbit, January 07, 2005, 08:50:58 AM

Previous topic - Next topic

fallenhobbit

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]

hutch--

 :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
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Vortex

Hi fallenhobbit,

Welcome to the forum, nice work :U

You have another choice to declare C functions:
printf PROTO C :VARARG

Jibz

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]

Vortex

There is an easy method to create an import library for msvcrt.dll

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