flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Tomasz Grysztar 06 May 2006, 12:28
This works just as expected:
Code: format PE GUI 4.0 entry start include 'win32a.inc' section '.data' data readable writeable ErrTitle db 'Error',0 LErrStrBuff dd ? FileName db 'c:\nothing',0 section '.code' code readable executable start: invoke CreateFile,FileName,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,0,0 call ShowError invoke ExitProcess,0 ShowError: pushad invoke GetLastError invoke FormatMessage,\ FORMAT_MESSAGE_FROM_SYSTEM+\ FORMAT_MESSAGE_ALLOCATE_BUFFER,\ NULL,\ eax,\ LANG_NEUTRAL,\ LErrStrBuff,\ 0,\ NULL invoke MessageBox,HWND_DESKTOP,[LErrStrBuff],ErrTitle,MB_ICONERROR+MB_OK popad ret section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',user32,'USER32.DLL' include 'apia\kernel32.inc' include 'apia\user32.inc' |
|||
![]() |
|
moriman 06 May 2006, 13:22
Strange indeed¿ Yes, I tried this and get the correct error message.
In the attached routine the ShowError sub is only called from 2 places and the program skips the 2nd call because of the first error (RegOpenKey). When I close all programs and run test.exe from the Start->Run button (Win98), the first time it runs it produces the The parameter is incorrect error and starts the app (as it should). If I close the MessageBox and the app and then do the same again, it produces a The operation completed successfully error. LOL. When I change your code above from Code: invoke CreateFile,FileName,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,0,0 to Code: invoke RegOpenKey, HKEY_CURRENT_USER, RegKey, RegHnd I get the expected error string. ![]()
|
|||||||||||
![]() |
|
Tomasz Grysztar 06 May 2006, 13:43
It seems that RegOpenKey doesn't do SetLastError on failure, it just returns the error code in EAX. Checked it with OllyDbg.
|
|||
![]() |
|
moriman 06 May 2006, 14:26
Many thanks Tomasz, when I removed the invoke GetLastError, everything works as expected
![]() |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.