I'm using IDA to disassemble exe's; eventually, I'll want to insert extra asm code and then rebuild and run, but for now I just want to rebuild and run the IDA-generated listing. The scheme is: exe -> IDA-generated asm -> masm32-generated new exe with the same functionality as the original exe. This involves making only those modifications to the IDA asm listing that are necessary so that the resulting asm file will assemble under masm32, and then link. I'm able to assemble OK. Problem: if the file calls functions in msvcrt.dll, say (standard C functions, not C++), then the linker can't find them because it's looking for the decorated names. How can I tell the compiler not to decorate the names in msvcrt.inc? Things like include extern "C" c:\masm32\include\msvcrt.inc don't work. The masm32 ml.exe doesn't recognize this syntax, but I'm sure there must be an easy way to do this. Iczelion's tutorials don't help here, because he never includes straight C libraries and problems of name decoration don't arise in the examples. Thanks for any help, Alan PS. I know msvcrt.inc isn't even in the masm32 include library. I generated it myself using IDA to disassemble msvcrt.dll, using some tools I wrote to convert the file to an inc file.
Posted on 2000-12-11 19:34:00 by A Mason
You need to also make a library (.lib) file for the C library. Icz has kindly posted a method for this (it's not eazy, but do-able)
Posted on 2000-12-11 21:36:00 by TTom
Thanks TTom. I already did this, using msvcrt.lib from the VC98\lib directory rather than making my own lib file. Is the library that Iczelion's method creates different from the Microsoft one? In C++, if you want to make an entire header file extern C, all you have to do is write extern "C" {} and the compiler won;'t decorate the names in the header file. I'm shocked that there doesn't seem to be an analogous command in the assembler that would work with the inc files. Have checked the help in Programmer's Workbench for masm6.11 and have gotten nowhere. I'm probably missing something obvious. In any case, it would be very nice to construct a lib file from a raw dll. I can get an inc file from a dll fairly easily by using IDA to disassemble the dll (IDA gives a lot of useful prototype info, though it sometimes makes mistakes). Could also use dumpPE here (strip out the publics and use the decorated names to deduce the prototypes -- this won't work for straight C though, since there's no decoration in this case). I also have some obj and lib file analyzer tools (coff, OMF) based on some code by Matt Pietrek. It would be very useful to have a detailed discussion of these issues by Iczelion and others on his Web page.
Posted on 2000-12-12 01:02:00 by A Mason
well, if you only want to add functionalities to the program, you can always use my generic asm patcher (for masm) that you can find on http://www.effervescence.com
Posted on 2000-12-12 13:23:00 by roy