flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
Vasilev Vjacheslav 16 Sep 2005, 16:00
coff.template.asm
Code: format ms coff public start include '%fasminc%\win32a.inc' include 'main.imp' ID_DLGMAIN = 10 MAX_PATH = 260 ERROR_ALREADY_EXISTS = 183 section '.idata' data readable writeable szMutex db "template",0 section '.udata' readable writeable hInstance dd ? hMutex dd ? section '.code' code readable executable start: invoke CreateMutex,NULL,TRUE,szMutex mov [hMutex],eax invoke GetLastError cmp al,ERROR_ALREADY_EXISTS jz exit_prog invoke GetModuleHandle,NULL or eax,eax jz exit_prog mov [hInstance],eax invoke DialogBoxParam,eax,ID_DLGMAIN,NULL,DialogProc,NULL exit_prog: invoke ReleaseMutex,[hMutex] invoke ExitProcess,NULL proc DialogProc, hWnd,wMsg,wParam,lParam push ebx esi edi movzx eax,word [wMsg] cmp ax,WM_COMMAND jz .wmcommand cmp ax,WM_CLOSE jz .wmclose cmp ax,WM_INITDIALOG jnz .not_processed .wminit: jmp .processed .wmcommand: ;cmp [wParam],BN_CLICKED shl 16 + 100 ;jnz .processed jmp .processed .wmclose: invoke EndDialog,[hWnd],NULL .processed: xor eax,eax inc eax jmp .finish .not_processed: xor eax,eax .finish: pop edi esi ebx ret endp ; eof build.bat Code: @echo off set prgname=coff.template gorc.exe /r %prgname%.rc scan.exe %prgname%.asm -g golink -entry start %prgname%.obj kernel32.dll user32.dll %prgname%.res echo _ pause scan.exe is a program by Vortex, you can get it here and gorc and golink can be downloaded from www.GoDevTool.com, also you can use ms linker _________________ [not enough memory] |
|||
![]() |
|
Vasilev Vjacheslav 16 Sep 2005, 16:05
also you can found coff examples in vortex package
|
|||
![]() |
|
Richter 16 Sep 2005, 16:59
Why have i to change the example?
I should be possible to link it like it is or not? |
|||
![]() |
|
Eoin 16 Sep 2005, 17:27
The example only implement a function, demo, which displays a MesssageBox. In order to make and executable you need to link it with an obj file which conatins everyting else needed for an exe. In this case the additional OBJ file(s) will at least need to contain a '__mainCRTStartup' label to be used as an entry point to the app. I think mainCRTStartup has something to do with the C runtime.
You also need to link it with the appropiate LIB file which conatins the necessary info about '__imp__MessageBoxA@16'. |
|||
![]() |
|
Vortex 17 Sep 2005, 07:22
Richter,
Here is the solution : Code: set fasminc=\fasmw\include \fasm\fasm MSCoff.asm \masm32\bin\polink /SUBSYSTEM:WINDOWS /ENTRY:demo MSCoff.obj kernel32.lib user32.lib You don't have to modify the source code, create a batch file containing the statements above and you will get an executable of 1536 bytes. If you would like to get my import library package : http://vortex.masmcode.com/files/MSCOFFlibs1.zip Attached is the demo example with the final executable MSCoff.exe , plus the necessary import libraries kernel32.lib and user32.lib
_________________ Code it... That's all... |
|||||||||||
![]() |
|
Richter 17 Sep 2005, 08:17
thank you for you solution for idiots
![]() That is what i needed ![]() |
|||
![]() |
|
zolkefli 10 May 2006, 15:32
where can I get polink.exe. Its free right?
|
|||
![]() |
|
okasvi 10 May 2006, 15:47
zolkefli wrote: where can I get polink.exe. Its free right? it comes along PellesC http://www.smorgasbordet.com/pellesc/ _________________ When We Ride On Our Enemies support reverse smileys |: |
|||
![]() |
|
zolkefli 11 May 2006, 15:26
The documentation on extrn is quite simple. I can understand this statement
extrn '__imp__MessageBoxA@16' as MessageBox:dword What is this for '__imp__' in front of function name What is @16 for? and the :dword size is refer to what. The size of function return? Thanks |
|||
![]() |
|
zubi 11 May 2006, 16:16
What is in front and at the end of the function is the 'decoration' that compilers add to the function name. @16 is the total number of bytes that is expected by that function as parameters. In MessageBoxA case, it is 16 since it expects 4 dword sized parameters. dword at the end is the size of the data. You can use extrn to refer to any label, not necessarily a function. I think it is used for type checking.
What I can't understand is that it was supposed to be decorated as "_MessageBoxA@16". Which software is it that uses such names starting with "__imp_"? |
|||
![]() |
|
zolkefli 13 May 2006, 21:37
thanks zubi
The 'decoration' is still confusing me.. Another thing... Can we create object file from DLL or LIB file? |
|||
![]() |
|
zubi 14 May 2006, 14:53
You can 'extract' .obj files from Lib files as Libs are made of obj files anyway. A librarian should be able to add or remove object files to and from a lib. I don't know about dlls. I don't think you can extract object modules back from dlls as the symbols are already resolved, but I don't know about the issue completely.
|
|||
![]() |
|
f0dder 14 May 2006, 18:28
There's a "dll2lib" tool available, but it's commercial, clunky, and fails on a lot of DLLs.
|
|||
![]() |
|
Vasilev Vjacheslav 14 May 2006, 18:29
also dll file can be converted to lib with dll2lib program (not free) and i think from lib to object
|
|||
![]() |
|
zolkefli 17 May 2006, 11:03
thanks guys. I already try. You can also use polib.exe comes along PellesC to convert from DLL to LIB
zubi, What is librarian. where can I get it.TQ again |
|||
![]() |
|
zubi 17 May 2006, 13:31
Librarian is a software to create and manipulate libraries. Polib.exe is a librarian, you have already discovered it
![]() |
|||
![]() |
|
zolkefli 17 May 2006, 16:35
Quote:
Ooooo ![]() I try several way to get .lib to .obj but cannot. don't know how actually to doit on polib.exe |
|||
![]() |
|
flaith 17 May 2006, 16:37
@Richter
if you already have installed gcc (like devc++), you just have to link that way : Code: ld -e _demo mscoff.obj libkernel32.a libuser32.a libmsvcrt.a -o mscoff.exe -s You just have to copy the 3 libs in the same dir of the object file. Besides, the meaning of the @16 for messagebox@16 represent the number of parameter : here it's 4 parameters (4 * 4 bytes) ![]() _________________ Je suis sur de 'rien', mais je ne suis pas sur du 'tout'. |
|||
![]() |
|
zolkefli 17 May 2006, 21:26
Actually what are the different between OBJ and LIB
|
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.