Jim was good enoug to point out a problem with an error string algo in the MASM32 library that I have never had documented and don't remember who wrote it so i have written a new one that is a bit simpler as a primitive that just returns the offset of the last error string so it can be displayed as either console or normal GUI data while testing GetLastError return values.
LATER : Macro and procedure.
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
LastError$ MACRO
IFNDEF @@_e_r_r_o_r_@@
.data?
@@_e_r_r_o_r_@@ db 512 dup (?)
.code
ENDIF
push edi
invoke GetLastError
mov edi,eax
invoke FormatMessage,FORMAT_MESSAGE_FROM_SYSTEM,
NULL,edi,0,ADDR @@_e_r_r_o_r_@@,512,NULL
pop edi
EXITM <OFFSET @@_e_r_r_o_r_@@>
ENDM
GetLastErrorString PROTO
.code
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
call main
exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
main proc
LOCAL wc :WNDCLASSEX
fclose NULL ; close an invalid empty file handle
fn MessageBox,0,LastError$(), \
"System Error String", \
MB_OK
invoke SendMessage,0,0,0,0 ; invalid window handle
fn MessageBox,0,LastError$(), \
"System Error String", \
MB_OK
invoke RegisterClassEx,ADDR wc ; empty WNDCLASSEX structure
fn MessageBox,0,rv(GetLastErrorString), \
"System Error String", \
MB_OK
ret
main endp
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
GetLastErrorString proc
IFNDEF @@_e_r_r_o_r_@@
.data?
@@_e_r_r_o_r_@@ db 512 dup (?)
.code
ENDIF
push edi
invoke GetLastError
mov edi,eax
invoke FormatMessage,FORMAT_MESSAGE_FROM_SYSTEM,
NULL,edi,0,ADDR @@_e_r_r_o_r_@@,512,NULL
pop edi
mov eax, OFFSET @@_e_r_r_o_r_@@
ret
GetLastErrorString endp
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start