move GetLastErrorString and FreeLastErrorString to loader source file

This commit is contained in:
RadWolfie 2020-03-30 03:55:46 -05:00
parent 04840af6d3
commit 7bfd1c795b
3 changed files with 27 additions and 32 deletions

View File

@ -56,31 +56,3 @@ bool VerifyWow64()
return (bIsWow64 != FALSE);
}
LPTSTR GetLastErrorString()
{
DWORD err = GetLastError();
// Translate ErrorCode to String.
LPTSTR Error = nullptr;
if (::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
err,
0,
(LPTSTR)&Error,
0,
NULL) == 0) {
// Failed in translating.
}
return Error;
}
void FreeLastErrorString(LPTSTR Error)
{
if (Error) {
::LocalFree(Error);
Error = nullptr;
}
}

View File

@ -113,7 +113,3 @@ extern bool IsOptionalAddressRange(const int index);
extern int AddressRangeGetSystemFlags(const int index);
extern bool VerifyWow64();
extern LPTSTR GetLastErrorString();
extern void FreeLastErrorString(LPTSTR Error);
extern void OutputMessage(const char* msg);

View File

@ -104,6 +104,33 @@ void OutputMessage(const char* msg)
}
}
LPTSTR GetLastErrorString()
{
DWORD err = GetLastError();
// Translate ErrorCode to String.
LPTSTR Error = nullptr;
if (::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
err,
0,
(LPTSTR)&Error,
0,
NULL) == 0) {
// Failed in translating.
}
return Error;
}
void FreeLastErrorString(LPTSTR Error)
{
if (Error) {
::LocalFree(Error);
Error = nullptr;
}
}
#define EMULATION_DLL "cxbxr-emu.dll"
DWORD CALLBACK rawMain()