flat assembler
Message board for the users of flat assembler.
Index
> Windows > [solved]FormatMessage |
Author |
|
revolution 27 Jul 2020, 22:47
I presume this question is for the Windows API so I have moved this to the Windows forum.
|
|||
27 Jul 2020, 22:47 |
|
revolution 28 Jul 2020, 01:58
So show your code please. We can't help you with no code.
|
|||
28 Jul 2020, 01:58 |
|
bitRAKE 22 Aug 2020, 02:12
Code: format PE64 CONSOLE 6.2 include 'win64wxp.inc' .code Quilt: invoke GetStdHandle,STD_OUTPUT_HANDLE mov [hCon],rax invoke GetLastError invoke FormatMessage,FORMAT_MESSAGE_ALLOCATE_BUFFER\ \ ; always use these two together or FORMAT_MESSAGE_FROM_SYSTEM\ or FORMAT_MESSAGE_IGNORE_INSERTS,\ 0,rax,0,ADDR lpBuffer,0,0 invoke WriteConsole,[hCon],[lpBuffer],eax,0,0 invoke LocalFree,[lpBuffer] invoke ExitProcess,eax .data hCon rq 1 lpBuffer rq 1 .end Quilt _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
22 Aug 2020, 02:12 |
|
Overclick 24 Aug 2020, 12:13
Ah it was pointer... I had to read clearly, thanks bro.
|
||||||||||
24 Aug 2020, 12:13 |
|
Overclick 24 Aug 2020, 12:21
Quote:
It some mistake? Working fine as usual single one: Code: invoke FormatMessage,FORMAT_MESSAGE_FROM_SYSTEM\ +0xFF,0,r15d,0,ERROR_fun_buffer,512,0 Or you mean that keys(flags)? Any way I don't need the pointer. |
|||
24 Aug 2020, 12:21 |
|
bitRAKE 25 Aug 2020, 05:45
Yeah, the flags - possible security hole when FORMAT_MESSAGE_FROM_SYSTEM not accompanied by FORMAT_MESSAGE_IGNORE_INSERTS. I haven't looked into it specifically, but I'll trust MS that there is a system message that uses inserts.
_________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
25 Aug 2020, 05:45 |
|
Overclick 25 Aug 2020, 13:08
You talking about FORMAT_MESSAGE_IGNORE_INSERTS? You probably right I will use it just in case.
|
|||
25 Aug 2020, 13:08 |
|
bitRAKE 12 Sep 2020, 02:18
Code: format PE64 CONSOLE 6.2 at $7FFF_FFFE_0000 include 'win64wxp.inc' struct MSGBOXPARAMSW cbSize dd ?,? hwndOwner dq ? hInstance dq ? lpszText dq ? lpszCaption dq ? dwStyle dd ?,? lpszIcon dq ? dwContextHelpId dd ?,? lpfnMsgBoxCallback dq ? dwLanguageId dd ?,? ends ; MSGBOXPARAMSW struct HELPINFO cbSize dd ? iContextType dd ? iCtrlId dd ?,? hItemHandle dq ? dwContextId dd ?,? MousePos POINT ends ; HELPINFO .code help_info: virtual at RCX .hi HELPINFO end virtual cmp [.hi.dwContextId],55555 jnz @F enter 32,0 ; don't loop back here and [mbp__GetLastError.dwStyle],not MB_HELP lea rcx,[mbp__GetLastError] call [MessageBoxIndirectW] leave @@: retn Quilt: invoke GetStdHandle,STD_OUTPUT_HANDLE mov [hCon],rax invoke GetLastError mov [last_error],rax invoke FormatMessage,FORMAT_MESSAGE_ALLOCATE_BUFFER\ \ ; always use these two together or FORMAT_MESSAGE_FROM_SYSTEM\ or FORMAT_MESSAGE_IGNORE_INSERTS,0,[last_error],0,ADDR lpBuffer,0,0 invoke WriteConsole,[hCon],[lpBuffer],eax,0,0 push [lpBuffer] pop [mbp__GetLastError.lpszText] invoke MessageBoxIndirectW,ADDR mbp__GetLastError ; display error invoke LocalFree,[lpBuffer] invoke ExitProcess,eax .data _title TCHAR "My GetLastError",0 align 8 last_error rq 1 hCon rq 1 lpBuffer rq 1 mbp__GetLastError MSGBOXPARAMSW\ cbSize:80,\ hwndOwner:0,\ hInstance:0,\; zero to use system icon (LoadIcon) value lpszCaption:_title,\ dwStyle:MB_OK or MB_USERICON or MB_HELP or MB_TASKMODAL,\ lpszIcon:32518,\ dwContextHelpId:55555,\ lpfnMsgBoxCallback:help_info .end Quilt _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
12 Sep 2020, 02:18 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.