I've seen some programs return the text for the WSA error codes such as:

"err_number: blah blah".

This is more handy then writing your own error messages for logfiles but I'm not sure how to do it. I think it has to do with LoadString api but I'm not sure.

// CyberHeg
Posted on 2003-07-30 03:09:13 by CyberHeg
Here is a macro for FASM:

macro lasterr {
stdcall [GlobalAlloc],GMEM_MOVEABLE+GMEM_ZEROINIT,1000h
push eax
push eax
stdcall [GlobalLock],eax
push eax
call [WSAGetLastError]
stdcall [FormatMessage],FORMAT_MESSAGE_FROM_SYSTEM,0,eax,0,[esp+08h],1000h,0
pop eax
stdcall [MessageBox],0,eax,0,MB_OK+MB_ICONASTERISK+MB_APPLMODAL
call [GlobalUnlock]
call [GlobalFree]
Posted on 2003-08-13 12:45:26 by masnick[CCCP]