I assemble the following:
to a win32 obj file:Code:global _printhello ;exports SECTION .text _printhello: mov ah, 09h mov edx, string ;32-bit register usage is necessary for win32 obj file int 21h int 20h SECTION .data string db 'Hello world!$'
C:\>nasmw -f win32 phile.asm
This produces a .obj file phile.obj
Because borland c++ 5.5 doesn't want to link this .obj file I use the COFF2OMF import library conversion tool.
C:\>coff2omf phile.obj crap.obj
Then I atttempt to use the exported function _printhello in a C program:
I compile it and link it together with phile.obj .Code:#include <stdio.h> void printhello(); int main() { printhello(); return 0; }
Upon execution an invalid page fault exception occurs and it crashes...
Also, when I try to debug it with ollydbg it gives some warning that it might be a self-modifying file or something.
Can anybody help me?


Reply With Quote
Bookmarks