flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
LocoDelAssembly 12 Jun 2007, 01:09
The MS COFF format lacks of import section, you have to use the keyword "extrn" instead.
Here the example that comes with fasm package Code: ; example of making Win32 COFF object file format MS COFF extrn '__imp__MessageBoxA@16' as MessageBox:dword section '.text' code readable executable public _demo _demo: push 0 push _caption push _message push 0 call [MessageBox] ret section '.data' data readable writeable _caption db 'Win32 assembly',0 _message db 'Coffee time!',0 |
|||
![]() |
|
Fungos Bauux 12 Jun 2007, 03:02
Ok. Now i have this:
asm.asm (code taken from samples) Code: include 'win32a.inc' format MS COFF public Test as '_Test' extrn '__imp__LoadLibraryA@4' as LoadLibrary:dword extrn '__imp__GetProcAddress@8' as GetProcAddress:dword extrn '__imp__MessageBoxA@16' as MessageBox:dword section '.text' executable proc Test c num1, num2 local loc1 dd ? local loc2 dd ? mov eax, [num1] add eax, [num2] rcr eax, 1 ret endp test.cpp: Code: unsigned int Test(unsigned int, unsigned int); int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { ... RunTest(); ... } void RunTest() { int i = Test(1, 1); } Compilation with dev-cpp/g++: Code: windres.exe -i test_private.rc --input-format=rc -o test_private.res -O coff g++.exe -D__DEBUG__ main.o test_private.res -o "test.exe" -L"lib" -mwindows asm.obj -g3 -march=i686 main.o(.text+0x16): In function `Z7RunTestv': C:/Dev/main.cpp:27: undefined reference to `Test(unsigned int, unsigned int)' collect2: ld returned 1 exit status It looks like something is wrong on linking asm.o object with my cpp project. Anybody has some dev-cpp/g++ sample working? |
|||
![]() |
|
vid 12 Jun 2007, 03:22
you should enclose declaration of "Test" in "extern C" block.
Something like this: (not sure about how is "__stdcall" used in gcc) Code: extern "C" { unsigned __stdcall int Test(unsigned int, unsigned int); } |
|||
![]() |
|
Fungos Bauux 03 Jul 2007, 00:01
This is what I'm doing: C++ <-> Fasm MS COFF .obj <-> external .DLL program.
But when Im compiling the C++, the linker says it cannot find dll exports. The C++ and DLL doesn't communicate directly. What I need to do to get this working? |
|||
![]() |
|
vid 03 Jul 2007, 00:08
Post complete command line and error message from compiler.
Maybe you have to create .lib file for the DLL? |
|||
![]() |
|
Fungos Bauux 03 Jul 2007, 00:30
Code: g++.exe main.o -o "test.exe" -mwindows fasm.obj fasm.obj(.text+0x12): undefined reference to `GFXDllCreateObject@12' collect2: ld returned 1 exit status. I'm using Dev-C++. The DLL that I'm trying to use came with an application and I haven't any lib and even .h to use it. |
|||
![]() |
|
vid 03 Jul 2007, 00:40
There are some tools that can spit out LIB from DLL file. I am pretty sure you can find them somewhere in MASM32, but i don't recall how it is called. Someone else may help.
meanwhile, you could browse MSDN about "__declspec(dllimport)", and about Module Definiton (.DEF) files |
|||
![]() |
|
Fungos Bauux 03 Jul 2007, 02:33
thanks. worked. dlltool from devcpp does the job.
|
|||
![]() |
|
hologram 06 Jul 2007, 16:53
How ? Im using devcpp and need to use a dll without any headers and libs
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.