mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Move 'PrintLastError()' to utility.cpp
This commit is contained in:
parent
b1d3a01a71
commit
03e700bac1
@ -11,6 +11,7 @@ DWORD64 FindPatternSIMD(const char* szModule, const unsigned char* szPattern, co
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Utility
|
// Utility
|
||||||
void DbgPrint(LPCSTR sFormat, ...);
|
void DbgPrint(LPCSTR sFormat, ...);
|
||||||
|
void PrintLastError(void);
|
||||||
void HexDump(const char* szHeader, int nFunc, const void* pData, int nSize);
|
void HexDump(const char* szHeader, int nFunc, const void* pData, int nSize);
|
||||||
std::string Base64Encode(const std::string& in);
|
std::string Base64Encode(const std::string& in);
|
||||||
std::string Base64Decode(const std::string& in);
|
std::string Base64Decode(const std::string& in);
|
||||||
|
@ -133,6 +133,22 @@ void DbgPrint(LPCSTR sFormat, ...)
|
|||||||
OutputDebugString(sBuffer);
|
OutputDebugString(sBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// For printing the last error to the console if any.
|
||||||
|
void PrintLastError(void)
|
||||||
|
{
|
||||||
|
DWORD errorMessageID = ::GetLastError();
|
||||||
|
if (errorMessageID != NULL)
|
||||||
|
{
|
||||||
|
LPSTR messageBuffer = nullptr;
|
||||||
|
size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
|
NULL, errorMessageID, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&messageBuffer, 0, NULL);
|
||||||
|
|
||||||
|
spdlog::error("{}\n", messageBuffer);
|
||||||
|
LocalFree(messageBuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// For dumping data from a buffer to a file on the disk
|
// For dumping data from a buffer to a file on the disk
|
||||||
void HexDump(const char* szHeader, int nFunc, const void* pData, int nSize)
|
void HexDump(const char* szHeader, int nFunc, const void* pData, int nSize)
|
||||||
|
@ -184,6 +184,7 @@
|
|||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="public\utility.cpp" />
|
||||||
<ClCompile Include="sdklauncher\sdklauncher.cpp" />
|
<ClCompile Include="sdklauncher\sdklauncher.cpp" />
|
||||||
<ClCompile Include="thirdparty\detours\src\creatwth.cpp">
|
<ClCompile Include="thirdparty\detours\src\creatwth.cpp">
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
|
||||||
@ -211,6 +212,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="core\stdafx.h" />
|
<ClInclude Include="core\stdafx.h" />
|
||||||
|
<ClInclude Include="public\include\utility.h" />
|
||||||
<ClInclude Include="sdklauncher\sdklauncher.h" />
|
<ClInclude Include="sdklauncher\sdklauncher.h" />
|
||||||
<ClInclude Include="sdklauncher\sdklauncher_res.h" />
|
<ClInclude Include="sdklauncher\sdklauncher_res.h" />
|
||||||
<ClInclude Include="thirdparty\detours\include\detours.h" />
|
<ClInclude Include="thirdparty\detours\include\detours.h" />
|
||||||
|
@ -39,6 +39,9 @@
|
|||||||
<ClCompile Include="thirdparty\detours\src\creatwth.cpp">
|
<ClCompile Include="thirdparty\detours\src\creatwth.cpp">
|
||||||
<Filter>Detours Files</Filter>
|
<Filter>Detours Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="public\utility.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="resource\sdklauncher.rc">
|
<ResourceCompile Include="resource\sdklauncher.rc">
|
||||||
@ -64,6 +67,9 @@
|
|||||||
<ClInclude Include="thirdparty\detours\include\detours.h">
|
<ClInclude Include="thirdparty\detours\include\detours.h">
|
||||||
<Filter>Detours Files\include</Filter>
|
<Filter>Detours Files\include</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="public\include\utility.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Image Include="resource\ico\sdklauncher_rel.ico">
|
<Image Include="resource\ico\sdklauncher_rel.ico">
|
||||||
|
@ -2,24 +2,7 @@
|
|||||||
#include "sdklauncher.h"
|
#include "sdklauncher.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Print the error message to the console if any.
|
// Purpose switch case:
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void PrintLastError()
|
|
||||||
{
|
|
||||||
DWORD errorMessageID = ::GetLastError();
|
|
||||||
if (errorMessageID != NULL)
|
|
||||||
{
|
|
||||||
LPSTR messageBuffer = nullptr;
|
|
||||||
size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
||||||
NULL, errorMessageID, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&messageBuffer, 0, NULL);
|
|
||||||
|
|
||||||
spdlog::error("{}\n", messageBuffer);
|
|
||||||
LocalFree(messageBuffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose case switch:
|
|
||||||
// * Launch the game in user specified mode and state.
|
// * Launch the game in user specified mode and state.
|
||||||
// * Load specified command line arguments from a file on the disk.
|
// * Load specified command line arguments from a file on the disk.
|
||||||
// * Format the file paths for the game exe and specified hook dll.
|
// * Format the file paths for the game exe and specified hook dll.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user