![]() |
Lucciefr
Lua code caving, injection and exploration framework
|
Windows error messages. More...
#include "strutils.h"
Macros | |
#define | ERRMSG_LANGID MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT) |
The ERRMSG_LANGID is taken from MS examples, you could also just use 0 (or SUBLANG_NEUTRAL, which leads to the same result) | |
Functions | |
char * | ErrorMessage (DWORD code, bool strip, const UINT codepage) |
Get error message string for a given error code. More... | |
char * | win_error (DWORD code, const UINT codepage, bool decorate) |
Format error message. More... | |
Windows error messages.
char* ErrorMessage | ( | DWORD | code, |
bool | strip, | ||
const UINT | codepage | ||
) |
Get error message string for a given error code.
This is a wrapper for the Windows FormatMessage
function. It will return a malloced copy of the string, optionally converted to a specific codepage. Make sure you call free()
on the result later!
If you don't need/want a specific conversion, pass codepage == 0
(CP_ACP). If strip
is set, the function will remove the trailing CRLF from the message.
In case of errors, the function returns NULL
.
char* win_error | ( | DWORD | code, |
const UINT | codepage, | ||
bool | decorate | ||
) |
Format error message.
This function uses ErrorMessage to retrieve the Windows error message with a given (codepage) conversion. If you set decorate
, the message will be reformatted to also include the error code - otherwise you get the 'plain' message string.
Make sure you call free()
on the result later!