Can i make function in some other lenguage (i means C) and then HexEdit it into my prog made in MASM. Can i just simply Paste this piece of code.

For example i make in MASM function that is doing nothing but acept the same amount and type of variables like my func made in C fill it with NOP it will be easy to find when Hex-ing.
Posted on 2003-06-28 16:08:51 by AceEmbler
You must remember that variable names just points to data segment (which is loaded into the memory). Thus you need to be sure that the variables's memeory is correct.

Anyway it is better to link it into your masm created exe then use your hands and hexeditor.
Posted on 2003-06-28 23:37:31 by roticv
Also, if any of the Hex copied code contains any calls to the Windows API they will be screwed up because they will point to an incorrect import address entry.

Static or dynamic link the function.
Posted on 2003-06-29 00:12:18 by Mecurius

Anyway it is better to link it into your masm created exe then use your hands and hexeditor.

how can i do this ??
Posted on 2003-06-29 02:35:28 by AceEmbler
Why not just link your C obj file to your masm file, that way you can make calls to the proc directly from your asm program. Just have to create a proto for it. Or make it a LIB or a dll.

I think you use RadASM so this is how you would do it :

copy the obj file to your project folder.

Right click in the project window

select "add existing"/"Object file"

That's it.
Posted on 2003-06-29 02:41:27 by donkey
so i just have to name this func the same as in C and link it ?? thats all ???
Posted on 2003-06-29 03:28:10 by AceEmbler
Yah, you have to create a PROTO though. I have never tried this (I only use assembler) so I'm not sure what the pitfalls are. I know that the linker will decorate the name for you :


becomes :

Posted on 2003-06-29 03:34:46 by donkey
so when i do it that way i can use windos api inside C proc ??
Posted on 2003-06-29 03:39:44 by AceEmbler
I would need an object file made with C or at least a C compiler and some knowledge of C to answer that. None of which I have, like I said I've never tried it and I only program in assembler (can't even do VB). So someone else has to take over from here :)
Posted on 2003-06-29 03:45:03 by donkey
If you want to call a VC function from a MASM program, you need to do something like this:

// Be aware that some standard C functions (especially the stdio functions) require startup
// code which is included if you define a C main or WinMain function.

// The API doesn't require the startup code (which is why you can call them
// from ASM.)

// If you don't want to use the extended (nonstandard) VC keyword __stdcall,
// then you must call the C function from ASM using the CDECL or C calling
// convention.

// Add the following #include line if you want to call API from C
// This will include the definitions of most (but not all) API functions
#include <windows.h>

// function returning nothing
extern "C" __stdcall void fproc1()

// function returning int
extern "C" __stdcall int fproc2()
return 1; // return value in EAX

// function returning pointer
extern "C" __stdcall int *fproc3()
static int staticInt;
int *pInt = &staticInt;
return pInt; // return value in EAX
Posted on 2003-07-01 14:40:39 by tenkey