flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
LocoDelAssembly 15 Aug 2006, 06:37
http://board.flatassembler.net/topic.php?t=5658 <- The same problem but the solution does not rely on .ends though
|
|||
![]() |
|
vid 15 Aug 2006, 07:09
sorry, when using "win32[a/w]xp.inc", you just can't add imports youself.
|
|||
![]() |
|
Xanfa 15 Aug 2006, 13:31
Oh I've look at .end macro once or twice (not remember) and what it does (in my memory) is import DLLs that come with Fasm package. Now I can't write here what step to do this, but this a suggestion to modify this macro more useful: Using match directive to modify the .end macro so it have its arguments, such as:
.end 'MyDll1.dll',function1,function2,'Dll2.dll',function1,function2... and what to do is add these library and its function to library and import macro (modify the win32a/wx.inc)... and if you type: .end it will generate the orginal .end macro as it is... I'll try make this modify, and if perfect, i'll post it ! |
|||
![]() |
|
daluca 16 Aug 2006, 06:15
greetings:
i've encounter a solution for what i wanted: first this is the code for an example dll from which we want to use the functions: Code: format PE GUI 4.0 DLL include 'win32ax.inc' section '.code' code readable executable proc DllEntryPoint hinstDLL,fdwReason,lpvReserved invoke MessageBox,0,content,title,MB_OK mov eax,TRUE ret endp ReturnString: ;this function has no parameters ;and return in edi a pointer to a ;string contained in the data section ;of this dll mov edi,string ret ShowBox: ;this function has no parameters (in the stack i mean) ;expects in esi a pointer to a string in the program ;that calls this DLL and shows it in a messagebox invoke MessageBox,0,esi,title2,MB_OK ret Exit: ;this just calls the ExitProcess function invoke ExitProcess,0 ;------------------------------------- .end DllEntryPoint ;the beloved macro ;------------------------------------- section 'data' data readable writeable title db 'Hello from DLL',0 title2 db 'the below string is in the exe file',0 content db 'DLL loaded successfully',0 string db 'this string is in the dll data section',0 ;------------------------------------- section '.edata' export data readable export 'CUSTOM.DLL',\ ReturnString,'ReturnString',\ ShowBox,'ShowBox',\ Exit,'Exit' ;-------------------------------------- section '.reloc' fixups data discardable then i create a file CUSTOM.INC with: Code: import custom,\ ReturnString,'ReturnString',\ ShowBox,'ShowBox',\ Exit,'Exit' and copy it to the include\apia folder then i modifie the win32ax.inc adding the commented parts: Code: macro import lib,[functions] { common macro import_#lib \{ import lib,functions \} } include 'apia/kernel32.inc' include 'apia/user32.inc' include 'apia/gdi32.inc' include 'apia/advapi32.inc' include 'apia/comctl32.inc' include 'apia/comdlg32.inc' include 'apia/shell32.inc' include 'apia/wsock32.inc' include 'apia/CUSTOM.inc' ;<---added purge import macro .data { section '.data' data readable writeable } macro .code { section '.text' code readable executable } macro .end label { entry label section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL',\ gdi32,'GDI32.DLL',\ advapi32,'ADVAPI32.DLL',\ comctl32,'COMCTL32.DLL',\ comdlg32,'COMDLG32.DLL',\ shell32,'SHELL32.DLL',\ wsock32,'WSOCK32.DLL',\ custom,'CUSTOM.DLL' ;<---added import_kernel32 import_user32 import_gdi32 import_advapi32 import_comctl32 import_comdlg32 import_shell32 import_wsock32 import_custom ;<---added } and now i can assemble the program below that uses this functions: Code: format pe gui include 'win32ax.inc' section 'code' code readable executable start: invoke ReturnString ;returns in edi a pointer to ;string contained in the data ;section of the dll invoke MessageBox,0,edi,title,MB_OK mov esi,msg invoke ShowBox invoke Exit ;------------------------------------- section 'data' data readable writeable title db 'the below string comes from the dll',0 msg db 'hello from exe data section',0 ;------------------------------------- .end start i have only encountered one problem: when i assembled the dll, the win32ax.inc file was not modified so everything was ok, then i modifie the win32ax.inc file and assemble the program that uses the dll and again everything works, but if i assemble the dll again with the win32ax.inc modified it gives a error:symbol already defined well, what do you think? vid: do you think is safe to use this method? or maybe can lead up to any other error apart from the "error: symbol already defined" error. thanks to all. |
|||
![]() |
|
Xanfa 16 Aug 2006, 12:56
ReturnString, ShowBox and Exit already defined in the custom.inc file (modified), so U can't use it in your DLL when U assemble it again. Try rename the label in your DLL file, the problem may be fix. Example:
export 'CUSTOM.DLL',\ ReturnStringxx,'ReturnString',\ ShowBoxxx,'ShowBox',\ Exitxx,'Exit' |
|||
![]() |
|
daluca 17 Aug 2006, 04:35
so I get it:
the labels in the dll code and export section should not be equal to those in the import file only the quoted strings, and the labels in the sources that use this functions should match the labels in the import file. and in this way everything works. thanks. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.