mirror of
https://github.com/shadps4-emu/ext-cryptopp.git
synced 2024-11-23 09:59:42 +00:00
Improve OutputDebugString messages (Issue 314)
This commit is contained in:
parent
e3c4ccb0fc
commit
1dd0b07a1e
15
fipstest.cpp
15
fipstest.cpp
@ -42,6 +42,7 @@ extern "C" {void __cdecl _CRT_DEBUGGER_HOOK(int); }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
#if CRYPTOPP_MSC_VERSION
|
||||
@ -330,11 +331,19 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule
|
||||
#endif
|
||||
}
|
||||
|
||||
if (h != g_BaseAddressOfMAC)
|
||||
if (h == g_BaseAddressOfMAC)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "Crypto++ DLL loaded at base address 0x" << std::hex << h << ".\n";
|
||||
#ifdef CRYPTOPP_WIN32_AVAILABLE
|
||||
OutputDebugString(oss.str().c_str());
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "Crypto++ DLL integrity check may fail. Expected module base address is 0x";
|
||||
oss << std::hex << g_BaseAddressOfMAC << ", but module loaded at 0x" << h << "\n";
|
||||
oss << std::hex << g_BaseAddressOfMAC << ", but module loaded at 0x" << h << ".\n";
|
||||
#ifdef CRYPTOPP_WIN32_AVAILABLE
|
||||
OutputDebugString(oss.str().c_str());
|
||||
#endif
|
||||
@ -456,7 +465,7 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule
|
||||
#ifdef CRYPTOPP_WIN32_AVAILABLE
|
||||
std::string hexMac;
|
||||
HexEncoder(new StringSink(hexMac)).PutMessageEnd(actualMac, actualMac.size());
|
||||
OutputDebugString((("Crypto++ DLL integrity check failed. Actual MAC is: " + hexMac) + "\n").c_str());
|
||||
OutputDebugString((("Crypto++ DLL integrity check failed. Actual MAC is: " + hexMac) + ".\n").c_str());
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
8
test.cpp
8
test.cpp
@ -288,14 +288,14 @@ int CRYPTOPP_API main(int argc, char *argv[])
|
||||
f.PutMessageEnd(buf.begin(), buf.size());
|
||||
|
||||
// Encode MAC
|
||||
string hexEncoded;
|
||||
string hexMac;
|
||||
HexEncoder encoder;
|
||||
encoder.Put(mac, sizeof(mac)), encoder.MessageEnd();
|
||||
hexEncoded.resize(static_cast<size_t>(encoder.MaxRetrievable()));
|
||||
encoder.Get(reinterpret_cast<byte*>(&hexEncoded[0]), hexEncoded.size());
|
||||
hexMac.resize(static_cast<size_t>(encoder.MaxRetrievable()));
|
||||
encoder.Get(reinterpret_cast<byte*>(&hexMac[0]), hexMac.size());
|
||||
|
||||
// Report MAC and location
|
||||
std::cout << "Placing MAC " << hexEncoded << " in " << fname << " at file offset " << macPos;
|
||||
std::cout << "Placing MAC " << hexMac << " in " << fname << " at file offset " << macPos;
|
||||
std::cout << " (0x" << std::hex << macPos << std::dec << ").\n";
|
||||
|
||||
// place MAC
|
||||
|
Loading…
Reference in New Issue
Block a user