flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
sleepsleep 20 May 2013, 14:27
maybe invoke MessageBox,NULL, [dwError], _title ,MB_OK
|
|||
![]() |
|
DerTobi 20 May 2013, 15:40
Yes you are right, i need [thishere], but it does not work.
|
|||
![]() |
|
sleepsleep 20 May 2013, 17:17
Code: ; Entry point start: invoke SetLastError,3 invoke GetLastError invoke FormatMessage,FORMAT_MESSAGE_ALLOCATE_BUFFER+FORMAT_MESSAGE_FROM_SYSTEM,NULL,eax,0, dwError,0,NULL invoke MessageBox,NULL, [dwError], _title ,MB_OK above works, i tested a few error number, but not every number works, kinda weird because 500 supposed got error code string, ERROR_USER_PROFILE_LOAD 500 (0x1F4) User profile cannot be loaded. |
|||
![]() |
|
sleepsleep 20 May 2013, 17:37
i added a few things for diagnose,
Code: invoke FormatMessage,FORMAT_MESSAGE_ALLOCATE_BUFFER+FORMAT_MESSAGE_FROM_SYSTEM+FORMAT_MESSAGE_IGNORE_INSERTS,NULL,eax,0, dwError,0,NULL cmp eax,0 jne @f invoke GetLastError cinvoke wsprintf,b1,<'%lu',0>,eax @@: invoke MessageBox,NULL, [dwError], b1 ,MB_OK and i got error code 317, translated to ERROR_MR_MID_NOT_FOUND 317 (0x13D) The system cannot find message text for message number 0x%1 in the message file for %2. |
|||
![]() |
|
DerTobi 20 May 2013, 19:00
Ah i used an unvalid errorcode, thx you Sleep.
But i can´t compile your second code. b1 and @f are unkowed! |
|||
![]() |
|
sleepsleep 21 May 2013, 02:20
b1 rb 0xff
@f is a Jump to next @@: @b is a jump to previous @@: Enjoy, But i still wonder why 500 doesnt work, and how the way they store message, inside each dll or one dll, Because google said, under compiler, they are in winerror.h something, |
|||
![]() |
|
DerTobi 21 May 2013, 22:27
Ah thx again Sleep, i enjoy it.
|
|||
![]() |
|
Force 21 May 2013, 23:46
Maybe you can try this code
Code: format PE GUI 4.0 include 'D:\FASM\INCLUDE\WIN32AX.INC' entry start Section '.data' data readable writeable hWnd dd ? buf dd ? _title db "Test",0 section '.code' code readable executable ; Entry point start: mov ebx,500 invoke SetLastError, ebx invoke GetLastError mov [hWnd],eax lea eax,[buf] invoke FormatMessage,FORMAT_MESSAGE_ALLOCATE_BUFFER+FORMAT_MESSAGE_FROM_SYSTEM,0,ebx,0,eax,0,0 invoke MessageBox,[hWnd],[buf],_title,MB_ICONERROR+MB_OK invoke ExitProcess,0 section ".idata" import data readable writable library kernel32, 'kernel32.dll', user32, 'USER32.DLL' include "d:\fasm\include\api\kernel32.inc" include "d:\fasm\include\api\user32.inc" |
|||
![]() |
|
sleepsleep 22 May 2013, 09:11
@Force,
i dont quite get it, the return value from GetLastError in EAX is 500, why you want to use that value for MessageBox? and lea eax,[buf] doesnt seems right, because buf is ? unknown value. |
|||
![]() |
|
Force 22 May 2013, 10:28
|
|||
![]() |
|
sleepsleep 22 May 2013, 10:47
i assume that is different because it was inside a proc,
|
|||
![]() |
|
Force 22 May 2013, 11:29
Yes it is confusing a bit
then simpliest way ... Code: format PE GUI 4.0 include 'fasm\include\win32ax.inc' entry start Section '.data' data readable writeable buffer db MAX_PATH dup(?) title db "FORCE",0 section '.code' code readable executable start: invoke SetLastError,500 invoke GetLastError mov edi,eax invoke FormatMessage,FORMAT_MESSAGE_FROM_SYSTEM,\ NULL,edi,0,buffer,512,NULL invoke MessageBox,NULL,buffer,title,MB_ICONERROR invoke ExitProcess,0 section ".idata" import data readable writable library kernel32, 'kernel32.dll', user32, 'USER32.DLL' include "\fasm\include\api\kernel32.inc" include "\fasm\include\api\user32.inc" |
|||
![]() |
|
randomdude 22 May 2013, 14:35
for what do you need to call GetLastError/SetLastError?
and if you are using FORMAT_MESSAGE_ALLOCATE_BUFFER: Quote: The caller should use the LocalFree function to free the buffer when it is no longer needed. this is what i use Code: proc ShowLastError locals syserroraddr dd ? tempstring rb 100h endl push ebx edi esi invoke GetLastError mov ebx,eax test ebx,ebx jz .end lea edi,dword[tempstring] cinvoke wsprintf,edi,lpfmt,errorstring,ebx lea esi,dword[syserroraddr] invoke FormatMessage,FORMAT_MESSAGE_ALLOCATE_BUFFER+FORMAT_MESSAGE_FROM_SYSTEM,0,ebx,LANG_NEUTRAL,esi,0,0 invoke MessageBox,0,dword[esi],edi,MB_ICONERROR+MB_OK invoke LocalFree,dword[esi] mov eax,ebx .end: pop esi edi ebx ret endp errorstring db 'ERROR :',0 lpfmt db '%s %#x',0 |
|||
![]() |
|
DerTobi 24 May 2013, 20:02
@Sleep
500 was just for testing and not important. @Force yes i found this example too, so i tried to import it without the use of a dll and your code doesnt work too, but thx you for your participation. @random Your solution i do realy like , thx. I need it to debug win api´s. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.