mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Added LogLevel setting
This commit is contained in:
parent
32301efd5c
commit
87c2af5049
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 16
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 16.0.29001.49
|
VisualStudioVersion = 17.2.32516.85
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DDrawCompat", "DDrawCompat\DDrawCompat.vcxproj", "{1146187A-17DE-4350-B9D1-9F9EAA934908}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DDrawCompat", "DDrawCompat\DDrawCompat.vcxproj", "{1146187A-17DE-4350-B9D1-9F9EAA934908}"
|
||||||
EndProject
|
EndProject
|
||||||
@ -9,15 +9,12 @@ Global
|
|||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|x86 = Debug|x86
|
Debug|x86 = Debug|x86
|
||||||
Release|x86 = Release|x86
|
Release|x86 = Release|x86
|
||||||
ReleaseWithDebugLogs|x86 = ReleaseWithDebugLogs|x86
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{1146187A-17DE-4350-B9D1-9F9EAA934908}.Debug|x86.ActiveCfg = Debug|Win32
|
{1146187A-17DE-4350-B9D1-9F9EAA934908}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
{1146187A-17DE-4350-B9D1-9F9EAA934908}.Debug|x86.Build.0 = Debug|Win32
|
{1146187A-17DE-4350-B9D1-9F9EAA934908}.Debug|x86.Build.0 = Debug|Win32
|
||||||
{1146187A-17DE-4350-B9D1-9F9EAA934908}.Release|x86.ActiveCfg = Release|Win32
|
{1146187A-17DE-4350-B9D1-9F9EAA934908}.Release|x86.ActiveCfg = Release|Win32
|
||||||
{1146187A-17DE-4350-B9D1-9F9EAA934908}.Release|x86.Build.0 = Release|Win32
|
{1146187A-17DE-4350-B9D1-9F9EAA934908}.Release|x86.Build.0 = Release|Win32
|
||||||
{1146187A-17DE-4350-B9D1-9F9EAA934908}.ReleaseWithDebugLogs|x86.ActiveCfg = ReleaseWithDebugLogs|Win32
|
|
||||||
{1146187A-17DE-4350-B9D1-9F9EAA934908}.ReleaseWithDebugLogs|x86.Build.0 = ReleaseWithDebugLogs|Win32
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -131,9 +131,7 @@ namespace
|
|||||||
BYTE* targetFunc = static_cast<BYTE*>(origFuncPtr);
|
BYTE* targetFunc = static_cast<BYTE*>(origFuncPtr);
|
||||||
|
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
#ifdef DEBUGLOGS
|
|
||||||
oss << Compat::funcPtrToStr(targetFunc) << ' ';
|
oss << Compat::funcPtrToStr(targetFunc) << ' ';
|
||||||
#endif
|
|
||||||
|
|
||||||
char origFuncPtrStr[20] = {};
|
char origFuncPtrStr[20] = {};
|
||||||
if (!funcName)
|
if (!funcName)
|
||||||
@ -170,16 +168,15 @@ namespace
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef DEBUGLOGS
|
|
||||||
Compat::LogStream(oss) << Compat::hexDump(prevTargetFunc, instructionSize) << " -> "
|
Compat::LogStream(oss) << Compat::hexDump(prevTargetFunc, instructionSize) << " -> "
|
||||||
<< Compat::funcPtrToStr(targetFunc) << ' ';
|
<< Compat::funcPtrToStr(targetFunc) << ' ';
|
||||||
#endif
|
|
||||||
prevTargetFunc = targetFunc;
|
prevTargetFunc = targetFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Compat::getModuleHandleFromAddress(targetFunc) == Dll::g_currentModule)
|
if (Compat::getModuleHandleFromAddress(targetFunc) == Dll::g_currentModule)
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: Target function is already hooked: " << funcName;
|
LOG_INFO << "ERROR: Target function is already hooked: " << funcName;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +238,7 @@ namespace
|
|||||||
auto dbgEng = LoadLibraryW((Compat::getSystemPath() / "dbgeng.dll").c_str());
|
auto dbgEng = LoadLibraryW((Compat::getSystemPath() / "dbgeng.dll").c_str());
|
||||||
if (!dbgEng)
|
if (!dbgEng)
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: DbgEng: failed to load library";
|
LOG_INFO << "ERROR: DbgEng: failed to load library";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +247,7 @@ namespace
|
|||||||
auto debugCreate = reinterpret_cast<decltype(&DebugCreate)>(Compat::getProcAddress(dbgEng, "DebugCreate"));
|
auto debugCreate = reinterpret_cast<decltype(&DebugCreate)>(Compat::getProcAddress(dbgEng, "DebugCreate"));
|
||||||
if (!debugCreate)
|
if (!debugCreate)
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: DbgEng: DebugCreate not found";
|
LOG_INFO << "ERROR: DbgEng: DebugCreate not found";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,14 +257,14 @@ namespace
|
|||||||
FAILED(result = g_debugClient->QueryInterface(IID_IDebugSymbols, reinterpret_cast<void**>(&g_debugSymbols))) ||
|
FAILED(result = g_debugClient->QueryInterface(IID_IDebugSymbols, reinterpret_cast<void**>(&g_debugSymbols))) ||
|
||||||
FAILED(result = g_debugClient->QueryInterface(IID_IDebugDataSpaces4, reinterpret_cast<void**>(&g_debugDataSpaces))))
|
FAILED(result = g_debugClient->QueryInterface(IID_IDebugDataSpaces4, reinterpret_cast<void**>(&g_debugDataSpaces))))
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: DbgEng: object creation failed: " << Compat::hex(result);
|
LOG_INFO << "ERROR: DbgEng: object creation failed: " << Compat::hex(result);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = g_debugClient->OpenDumpFileWide(Compat::getModulePath(Dll::g_currentModule).c_str(), 0);
|
result = g_debugClient->OpenDumpFileWide(Compat::getModulePath(Dll::g_currentModule).c_str(), 0);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: DbgEng: OpenDumpFile failed: " << Compat::hex(result);
|
LOG_INFO << "ERROR: DbgEng: OpenDumpFile failed: " << Compat::hex(result);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +272,7 @@ namespace
|
|||||||
result = g_debugControl->WaitForEvent(0, INFINITE);
|
result = g_debugControl->WaitForEvent(0, INFINITE);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: DbgEng: WaitForEvent failed: " << Compat::hex(result);
|
LOG_INFO << "ERROR: DbgEng: WaitForEvent failed: " << Compat::hex(result);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +280,7 @@ namespace
|
|||||||
result = g_debugSymbols->GetModuleParameters(1, 0, 0, &dmp);
|
result = g_debugSymbols->GetModuleParameters(1, 0, 0, &dmp);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: DbgEng: GetModuleParameters failed: " << Compat::hex(result);
|
LOG_INFO << "ERROR: DbgEng: GetModuleParameters failed: " << Compat::hex(result);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,7 +288,7 @@ namespace
|
|||||||
result = g_debugDataSpaces->GetValidRegionVirtual(dmp.Base, dmp.Size, &g_debugBase, &size);
|
result = g_debugDataSpaces->GetValidRegionVirtual(dmp.Base, dmp.Size, &g_debugBase, &size);
|
||||||
if (FAILED(result) || 0 == g_debugBase)
|
if (FAILED(result) || 0 == g_debugBase)
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: DbgEng: GetValidRegionVirtual failed: " << Compat::hex(result);
|
LOG_INFO << "ERROR: DbgEng: GetValidRegionVirtual failed: " << Compat::hex(result);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
|
#include <regex>
|
||||||
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <Common/Log.h>
|
#include <Common/Log.h>
|
||||||
#include <Common/Path.h>
|
#include <Common/Path.h>
|
||||||
|
#include <Common/ScopedCriticalSection.h>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
Compat::CriticalSection g_logCs;
|
Compat::CriticalSection g_logCs;
|
||||||
|
std::ofstream g_logFile;
|
||||||
|
static std::ostringstream g_initialLogStream;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Compat
|
namespace Compat
|
||||||
@ -23,33 +29,60 @@ namespace Compat
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::Log() : m_lock(g_logCs)
|
Log::Log(bool isEnabled) : m_isEnabled(isEnabled)
|
||||||
{
|
{
|
||||||
|
if (!m_isEnabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EnterCriticalSection(&g_logCs);
|
||||||
SYSTEMTIME st = {};
|
SYSTEMTIME st = {};
|
||||||
GetLocalTime(&st);
|
GetLocalTime(&st);
|
||||||
|
|
||||||
char header[20];
|
char header[20];
|
||||||
#ifdef DEBUGLOGS
|
if (s_logLevel >= Config::Settings::LogLevel::DEBUG)
|
||||||
sprintf_s(header, "%04hx %02hu:%02hu:%02hu.%03hu ",
|
{
|
||||||
GetCurrentThreadId(), st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
|
sprintf_s(header, "%04hx %02hu:%02hu:%02hu.%03hu ",
|
||||||
#else
|
GetCurrentThreadId(), st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
|
||||||
sprintf_s(header, "%02hu:%02hu:%02hu.%03hu ", st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
|
}
|
||||||
#endif
|
else
|
||||||
s_logFile << header;
|
{
|
||||||
|
sprintf_s(header, "%02hu:%02hu:%02hu.%03hu ",
|
||||||
|
st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
|
||||||
|
}
|
||||||
|
*s_logStream << header;
|
||||||
|
|
||||||
if (0 != s_indent)
|
if (0 != s_indent)
|
||||||
{
|
{
|
||||||
std::fill_n(std::ostreambuf_iterator<char>(s_logFile), s_indent, ' ');
|
std::fill_n(std::ostreambuf_iterator<char>(*s_logStream), s_indent, ' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log::Log(unsigned logLevel) : Log(logLevel <= s_logLevel)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Log::~Log()
|
Log::~Log()
|
||||||
{
|
{
|
||||||
s_logFile << std::endl;
|
if (m_isEnabled)
|
||||||
|
{
|
||||||
|
*s_logStream << std::endl;
|
||||||
|
LeaveCriticalSection(&g_logCs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log::initLogging(std::filesystem::path processPath)
|
void Log::initLogging(std::filesystem::path processPath, unsigned logLevel)
|
||||||
{
|
{
|
||||||
|
s_logLevel = logLevel;
|
||||||
|
s_logStream = &g_logFile;
|
||||||
|
|
||||||
|
if (Config::Settings::LogLevel::NONE == logLevel)
|
||||||
|
{
|
||||||
|
g_initialLogStream = {};
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (Compat::isEqual(processPath.extension(), ".exe"))
|
if (Compat::isEqual(processPath.extension(), ".exe"))
|
||||||
{
|
{
|
||||||
processPath.replace_extension();
|
processPath.replace_extension();
|
||||||
@ -65,16 +98,46 @@ namespace Compat
|
|||||||
}
|
}
|
||||||
logFilePath += ".log";
|
logFilePath += ".log";
|
||||||
|
|
||||||
s_logFile.open(logFilePath, std::ios_base::out, SH_DENYWR);
|
g_logFile.open(logFilePath, std::ios_base::out, SH_DENYWR);
|
||||||
if (!s_logFile.fail())
|
if (!g_logFile.fail())
|
||||||
{
|
{
|
||||||
|
std::string initialLogs(g_initialLogStream.str());
|
||||||
|
if (logLevel < Config::Settings::LogLevel::DEBUG)
|
||||||
|
{
|
||||||
|
initialLogs = std::regex_replace(initialLogs, std::regex("^....."), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
g_logFile.write(initialLogs.c_str(), initialLogs.size());
|
||||||
|
g_initialLogStream = {};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s_logLevel = Config::Settings::LogLevel::NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
LogFuncBase::~LogFuncBase()
|
||||||
|
{
|
||||||
|
if (m_isEnabled)
|
||||||
|
{
|
||||||
|
Log::s_isLeaveLog = true;
|
||||||
|
Log::s_indent -= 2;
|
||||||
|
Log log(Config::Settings::LogLevel::DEBUG);
|
||||||
|
log << "< ";
|
||||||
|
logCall(log);
|
||||||
|
|
||||||
|
if (m_logResult)
|
||||||
|
{
|
||||||
|
log << " = ";
|
||||||
|
m_logResult(log);
|
||||||
|
}
|
||||||
|
Log::s_isLeaveLog = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_local DWORD Log::s_indent = 0;
|
thread_local DWORD Log::s_indent = 0;
|
||||||
|
|
||||||
bool Log::s_isLeaveLog = false;
|
bool Log::s_isLeaveLog = false;
|
||||||
std::ofstream Log::s_logFile;
|
unsigned Log::s_logLevel = Config::Settings::LogLevel::INITIAL;
|
||||||
|
std::ostream* Log::s_logStream = &g_initialLogStream;
|
||||||
}
|
}
|
||||||
|
@ -10,28 +10,22 @@
|
|||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
#include <Common/ScopedCriticalSection.h>
|
#include <Config/Settings/LogLevel.h>
|
||||||
#include <DDraw/Log.h>
|
#include <DDraw/Log.h>
|
||||||
#include <Win32/Log.h>
|
#include <Win32/Log.h>
|
||||||
|
|
||||||
#ifdef DEBUGLOGS
|
#define LOG_INFO Compat::Log(Config::Settings::LogLevel::INFO)
|
||||||
#define LOG_DEBUG Compat::Log()
|
#define LOG_DEBUG Compat::Log(Config::Settings::LogLevel::DEBUG)
|
||||||
#define LOG_FUNC(...) Compat::LogFunc logFunc(__VA_ARGS__)
|
#define LOG_FUNC(...) Compat::LogFunc logFunc(__VA_ARGS__)
|
||||||
#define LOG_FUNC_CUSTOM(funcPtr, ...) Compat::LogFunc<funcPtr> logFunc(__VA_ARGS__)
|
#define LOG_FUNC_CUSTOM(funcPtr, ...) Compat::LogFunc<funcPtr> logFunc(__VA_ARGS__)
|
||||||
#define LOG_RESULT(...) logFunc.setResult(__VA_ARGS__)
|
#define LOG_RESULT(...) logFunc.setResult(__VA_ARGS__)
|
||||||
#else
|
|
||||||
#define LOG_DEBUG if constexpr (false) Compat::Log()
|
|
||||||
#define LOG_FUNC(...)
|
|
||||||
#define LOG_FUNC_CUSTOM(funcPtr, ...)
|
|
||||||
#define LOG_RESULT(...) __VA_ARGS__
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LOG_ONCE(msg) \
|
#define LOG_ONCE(msg) \
|
||||||
{ \
|
{ \
|
||||||
static bool isAlreadyLogged = false; \
|
static bool isAlreadyLogged = false; \
|
||||||
if (!isAlreadyLogged) \
|
if (!isAlreadyLogged) \
|
||||||
{ \
|
{ \
|
||||||
Compat::Log() << msg; \
|
LOG_INFO << msg; \
|
||||||
isAlreadyLogged = true; \
|
isAlreadyLogged = true; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
@ -245,28 +239,34 @@ namespace Compat
|
|||||||
class Log
|
class Log
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Log();
|
Log(bool isEnabled);
|
||||||
|
Log(unsigned logLevel);
|
||||||
~Log();
|
~Log();
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
Log& operator<<(const T& t)
|
Log& operator<<(const T& t)
|
||||||
{
|
{
|
||||||
LogStream(s_logFile) << t;
|
if (m_isEnabled)
|
||||||
|
{
|
||||||
|
LogStream(*s_logStream) << t;
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initLogging(std::filesystem::path processPath);
|
static unsigned getLogLevel() { return s_logLevel; }
|
||||||
|
static void initLogging(std::filesystem::path processPath, unsigned logLevel);
|
||||||
static bool isLeaveLog() { return s_isLeaveLog; }
|
static bool isLeaveLog() { return s_isLeaveLog; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class LogFuncBase;
|
friend class LogFuncBase;
|
||||||
|
|
||||||
ScopedCriticalSection m_lock;
|
bool m_isEnabled;
|
||||||
|
|
||||||
static thread_local DWORD s_indent;
|
static thread_local DWORD s_indent;
|
||||||
|
|
||||||
static bool s_isLeaveLog;
|
static bool s_isLeaveLog;
|
||||||
static std::ofstream s_logFile;
|
static unsigned s_logLevel;
|
||||||
|
static std::ostream* s_logStream;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <auto funcPtr, int paramIndex, typename = decltype(funcPtr)>
|
template <auto funcPtr, int paramIndex, typename = decltype(funcPtr)>
|
||||||
@ -315,7 +315,10 @@ namespace Compat
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
T setResult(T result)
|
T setResult(T result)
|
||||||
{
|
{
|
||||||
m_logResult = [=](Log& log) { log << std::hex << result << std::dec; };
|
if (m_isEnabled)
|
||||||
|
{
|
||||||
|
m_logResult = [=](Log& log) { log << std::hex << result << std::dec; };
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,29 +327,19 @@ namespace Compat
|
|||||||
LogFuncBase(const char* funcName, std::function<void(Log&)> logParams)
|
LogFuncBase(const char* funcName, std::function<void(Log&)> logParams)
|
||||||
: m_funcName(funcName)
|
: m_funcName(funcName)
|
||||||
, m_logParams(logParams)
|
, m_logParams(logParams)
|
||||||
|
, m_isEnabled(Log::s_logLevel >= Config::Settings::LogLevel::DEBUG)
|
||||||
{
|
{
|
||||||
Log log;
|
if (m_isEnabled)
|
||||||
log << "> ";
|
|
||||||
logCall(log);
|
|
||||||
Log::s_indent += 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
~LogFuncBase()
|
|
||||||
{
|
|
||||||
Log::s_isLeaveLog = true;
|
|
||||||
Log::s_indent -= 2;
|
|
||||||
Log log;
|
|
||||||
log << "< ";
|
|
||||||
logCall(log);
|
|
||||||
|
|
||||||
if (m_logResult)
|
|
||||||
{
|
{
|
||||||
log << " = ";
|
Log log(Config::Settings::LogLevel::DEBUG);
|
||||||
m_logResult(log);
|
log << "> ";
|
||||||
|
logCall(log);
|
||||||
|
Log::s_indent += 2;
|
||||||
}
|
}
|
||||||
Log::s_isLeaveLog = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~LogFuncBase();
|
||||||
|
|
||||||
template <typename Param>
|
template <typename Param>
|
||||||
auto packParam(Param&& param)
|
auto packParam(Param&& param)
|
||||||
{
|
{
|
||||||
@ -377,6 +370,7 @@ namespace Compat
|
|||||||
const char* m_funcName;
|
const char* m_funcName;
|
||||||
std::function<void(Log&)> m_logParams;
|
std::function<void(Log&)> m_logParams;
|
||||||
std::function<void(Log&)> m_logResult;
|
std::function<void(Log&)> m_logResult;
|
||||||
|
bool m_isEnabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <auto funcPtr = nullptr>
|
template <auto funcPtr = nullptr>
|
||||||
|
@ -17,12 +17,10 @@ template <auto memberPtr, typename Vtable>
|
|||||||
constexpr auto getCompatFunc(Vtable*)
|
constexpr auto getCompatFunc(Vtable*)
|
||||||
{
|
{
|
||||||
auto func = getCompatVtable<Vtable>().*memberPtr;
|
auto func = getCompatVtable<Vtable>().*memberPtr;
|
||||||
#ifdef DEBUGLOGS
|
|
||||||
if (!func)
|
if (!func)
|
||||||
{
|
{
|
||||||
func = &callOrigFunc<memberPtr>;
|
func = &callOrigFunc<memberPtr>;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return func;
|
return func;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,18 +50,21 @@ public:
|
|||||||
template <auto memberPtr>
|
template <auto memberPtr>
|
||||||
void visit([[maybe_unused]] const char* funcName)
|
void visit([[maybe_unused]] const char* funcName)
|
||||||
{
|
{
|
||||||
if constexpr (getCompatFunc<memberPtr, Vtable>())
|
if constexpr (!(getCompatVtable<Vtable>().*memberPtr))
|
||||||
{
|
{
|
||||||
if (m_vtable.*memberPtr)
|
if (Compat::Log::getLogLevel() < Config::Settings::LogLevel::DEBUG)
|
||||||
{
|
{
|
||||||
#ifdef DEBUGLOGS
|
return;
|
||||||
s_funcName<memberPtr> = s_vtableTypeName + "::" + funcName;
|
|
||||||
Compat::Log() << "Hooking function: " << s_funcName<memberPtr>
|
|
||||||
<< " (" << Compat::funcPtrToStr(m_vtable.*memberPtr) << ')';
|
|
||||||
#endif
|
|
||||||
m_vtable.*memberPtr = &hookFunc<memberPtr>;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_vtable.*memberPtr)
|
||||||
|
{
|
||||||
|
s_funcName<memberPtr> = s_vtableTypeName + "::" + funcName;
|
||||||
|
LOG_DEBUG << "Hooking function: " << s_funcName<memberPtr>
|
||||||
|
<< " (" << Compat::funcPtrToStr(m_vtable.*memberPtr) << ')';
|
||||||
|
m_vtable.*memberPtr = &hookFunc<memberPtr>;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -101,11 +102,9 @@ private:
|
|||||||
static std::string s_vtableTypeName;
|
static std::string s_vtableTypeName;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef DEBUGLOGS
|
|
||||||
template <typename Vtable, typename Lock>
|
template <typename Vtable, typename Lock>
|
||||||
template <auto memberPtr>
|
template <auto memberPtr>
|
||||||
std::string VtableHookVisitor<Vtable, Lock>::s_funcName;
|
std::string VtableHookVisitor<Vtable, Lock>::s_funcName;
|
||||||
|
|
||||||
template <typename Vtable, typename Lock>
|
template <typename Vtable, typename Lock>
|
||||||
std::string VtableHookVisitor<Vtable, Lock>::s_vtableTypeName(getVtableTypeName());
|
std::string VtableHookVisitor<Vtable, Lock>::s_vtableTypeName(getVtableTypeName());
|
||||||
#endif
|
|
||||||
|
@ -14,6 +14,7 @@ namespace Config
|
|||||||
Settings::DisplayResolution displayResolution;
|
Settings::DisplayResolution displayResolution;
|
||||||
Settings::ForceD3D9On12 forceD3D9On12;
|
Settings::ForceD3D9On12 forceD3D9On12;
|
||||||
Settings::FullscreenMode fullscreenMode;
|
Settings::FullscreenMode fullscreenMode;
|
||||||
|
Settings::LogLevel logLevel;
|
||||||
Settings::RemoveBorders removeBorders;
|
Settings::RemoveBorders removeBorders;
|
||||||
Settings::RenderColorDepth renderColorDepth;
|
Settings::RenderColorDepth renderColorDepth;
|
||||||
Settings::ResolutionScale resolutionScale;
|
Settings::ResolutionScale resolutionScale;
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <Config/Settings/DisplayResolution.h>
|
#include <Config/Settings/DisplayResolution.h>
|
||||||
#include <Config/Settings/ForceD3D9On12.h>
|
#include <Config/Settings/ForceD3D9On12.h>
|
||||||
#include <Config/Settings/FullscreenMode.h>
|
#include <Config/Settings/FullscreenMode.h>
|
||||||
|
#include <Config/Settings/LogLevel.h>
|
||||||
#include <Config/Settings/RemoveBorders.h>
|
#include <Config/Settings/RemoveBorders.h>
|
||||||
#include <Config/Settings/RenderColorDepth.h>
|
#include <Config/Settings/RenderColorDepth.h>
|
||||||
#include <Config/Settings/ResolutionScale.h>
|
#include <Config/Settings/ResolutionScale.h>
|
||||||
@ -38,6 +39,7 @@ namespace Config
|
|||||||
extern Settings::DisplayResolution displayResolution;
|
extern Settings::DisplayResolution displayResolution;
|
||||||
extern Settings::ForceD3D9On12 forceD3D9On12;
|
extern Settings::ForceD3D9On12 forceD3D9On12;
|
||||||
extern Settings::FullscreenMode fullscreenMode;
|
extern Settings::FullscreenMode fullscreenMode;
|
||||||
|
extern Settings::LogLevel logLevel;
|
||||||
extern Settings::RemoveBorders removeBorders;
|
extern Settings::RemoveBorders removeBorders;
|
||||||
extern Settings::RenderColorDepth renderColorDepth;
|
extern Settings::RenderColorDepth renderColorDepth;
|
||||||
extern Settings::ResolutionScale resolutionScale;
|
extern Settings::ResolutionScale resolutionScale;
|
||||||
|
@ -19,11 +19,11 @@ namespace
|
|||||||
|
|
||||||
void loadConfigFile(const std::string& source, const std::filesystem::path& path)
|
void loadConfigFile(const std::string& source, const std::filesystem::path& path)
|
||||||
{
|
{
|
||||||
Compat::Log() << "Loading " << source << " config file: " << path.u8string();
|
LOG_INFO << "Loading " << source << " config file: " << path.u8string();
|
||||||
std::ifstream f(path);
|
std::ifstream f(path);
|
||||||
if (!f.is_open())
|
if (!f.is_open())
|
||||||
{
|
{
|
||||||
Compat::Log() << " File not found, skipping";
|
LOG_INFO << " File not found, skipping";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ namespace
|
|||||||
}
|
}
|
||||||
catch (const Config::ParsingError& error)
|
catch (const Config::ParsingError& error)
|
||||||
{
|
{
|
||||||
Compat::Log() << " Line #" << lineNumber << ": " << error.what();
|
LOG_INFO << " Line #" << lineNumber << ": " << error.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,14 +120,14 @@ namespace Config
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Compat::Log() << "Final configuration:";
|
LOG_INFO << "Final configuration:";
|
||||||
for (const auto& setting : getSettings())
|
for (const auto& setting : getSettings())
|
||||||
{
|
{
|
||||||
std::string name(setting.second.getName());
|
std::string name(setting.second.getName());
|
||||||
name.insert(name.end(), maxNameLength - name.length(), ' ');
|
name.insert(name.end(), maxNameLength - name.length(), ' ');
|
||||||
std::string source(setting.second.getSource());
|
std::string source(setting.second.getSource());
|
||||||
source.insert(source.end(), maxSourceLength - source.length(), ' ');
|
source.insert(source.end(), maxSourceLength - source.length(), ' ');
|
||||||
Compat::Log() << " [" << source << "] " << name << " = " << setting.second.getValueStr();
|
LOG_INFO << " [" << source << "] " << name << " = " << setting.second.getValueStr();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
29
DDrawCompat/Config/Settings/LogLevel.h
Normal file
29
DDrawCompat/Config/Settings/LogLevel.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Config/MappedSetting.h>
|
||||||
|
|
||||||
|
namespace Config
|
||||||
|
{
|
||||||
|
namespace Settings
|
||||||
|
{
|
||||||
|
class LogLevel : public MappedSetting<UINT>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const UINT NONE = 0;
|
||||||
|
static const UINT INFO = 1;
|
||||||
|
static const UINT DEBUG = 2;
|
||||||
|
static const UINT INITIAL = MAXUINT;
|
||||||
|
|
||||||
|
LogLevel::LogLevel()
|
||||||
|
: MappedSetting("LogLevel",
|
||||||
|
#ifdef _DEBUG
|
||||||
|
"debug",
|
||||||
|
#else
|
||||||
|
"info",
|
||||||
|
#endif
|
||||||
|
{ {"none", NONE}, {"info", INFO}, {"debug", DEBUG} })
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -23,9 +23,9 @@ namespace
|
|||||||
|
|
||||||
if (result.empty())
|
if (result.empty())
|
||||||
{
|
{
|
||||||
return "\"\"";
|
return "none";
|
||||||
}
|
}
|
||||||
return '"' + result.substr(2) + '"';
|
return result.substr(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,8 +55,8 @@ namespace D3dDdi
|
|||||||
info.formatOps = getFormatOps();
|
info.formatOps = getFormatOps();
|
||||||
info.supportedZBufferBitDepths = getSupportedZBufferBitDepths(info.formatOps);
|
info.supportedZBufferBitDepths = getSupportedZBufferBitDepths(info.formatOps);
|
||||||
|
|
||||||
Compat::Log() << "Supported z-buffer bit depths: " << bitDepthsToString(info.supportedZBufferBitDepths);
|
LOG_INFO << "Supported z-buffer bit depths: " << bitDepthsToString(info.supportedZBufferBitDepths);
|
||||||
Compat::Log() << "Supported MSAA modes: " << getSupportedMsaaModes(info.formatOps);
|
LOG_INFO << "Supported MSAA modes: " << getSupportedMsaaModes(info.formatOps);
|
||||||
LOG_DEBUG << "Supported resource formats:";
|
LOG_DEBUG << "Supported resource formats:";
|
||||||
for (const auto& formatOp : info.formatOps)
|
for (const auto& formatOp : info.formatOps)
|
||||||
{
|
{
|
||||||
|
@ -79,7 +79,7 @@ namespace
|
|||||||
static std::set<HMODULE> hookedModules;
|
static std::set<HMODULE> hookedModules;
|
||||||
if (hookedModules.find(hModule) == hookedModules.end())
|
if (hookedModules.find(hModule) == hookedModules.end())
|
||||||
{
|
{
|
||||||
Compat::Log() << "Hooking user mode display driver: " << Compat::funcPtrToStr(g_origOpenAdapter);
|
LOG_INFO << "Hooking user mode display driver: " << Compat::funcPtrToStr(g_origOpenAdapter);
|
||||||
Dll::pinModule(hModule);
|
Dll::pinModule(hModule);
|
||||||
hookedModules.insert(hModule);
|
hookedModules.insert(hModule);
|
||||||
}
|
}
|
||||||
|
@ -599,9 +599,7 @@ namespace D3dDdi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUGLOGS
|
|
||||||
LOG_RESULT(m_lockResource.get());
|
LOG_RESULT(m_lockResource.get());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Resource::disableClamp()
|
void Resource::disableClamp()
|
||||||
|
@ -32,7 +32,7 @@ namespace
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: Failed to create a DirectDraw clipper for hooking: " << result;
|
LOG_INFO << "ERROR: Failed to create a DirectDraw clipper for hooking: " << result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ namespace
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: Failed to create a DirectDraw palette for hooking: " << result;
|
LOG_INFO << "ERROR: Failed to create a DirectDraw palette for hooking: " << result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ namespace
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: Failed to create a DirectDraw surface for hooking: " << result;
|
LOG_INFO << "ERROR: Failed to create a DirectDraw surface for hooking: " << result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ namespace DDraw
|
|||||||
|
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: Failed to create the real primary surface: " << Compat::hex(result);
|
LOG_INFO << "ERROR: Failed to create the real primary surface: " << Compat::hex(result);
|
||||||
g_monitorRect = {};
|
g_monitorRect = {};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ namespace DDraw
|
|||||||
result = Surface::create(dd, desc, surface, std::move(privateData));
|
result = Surface::create(dd, desc, surface, std::move(privateData));
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: Failed to create the compat primary surface: " << Compat::hex(result);
|
LOG_INFO << "ERROR: Failed to create the compat primary surface: " << Compat::hex(result);
|
||||||
g_monitorRect = {};
|
g_monitorRect = {};
|
||||||
RealPrimarySurface::release();
|
RealPrimarySurface::release();
|
||||||
return result;
|
return result;
|
||||||
|
@ -5,10 +5,6 @@
|
|||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="ReleaseWithDebugLogs|Win32">
|
|
||||||
<Configuration>ReleaseWithDebugLogs</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
<Configuration>Release</Configuration>
|
<Configuration>Release</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
@ -36,13 +32,6 @@
|
|||||||
<CharacterSet>NotSet</CharacterSet>
|
<CharacterSet>NotSet</CharacterSet>
|
||||||
<SpectreMitigation>false</SpectreMitigation>
|
<SpectreMitigation>false</SpectreMitigation>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithDebugLogs|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
|
||||||
<CharacterSet>NotSet</CharacterSet>
|
|
||||||
<SpectreMitigation>false</SpectreMitigation>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
@ -54,9 +43,6 @@
|
|||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithDebugLogs|Win32'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<TargetName>ddraw</TargetName>
|
<TargetName>ddraw</TargetName>
|
||||||
@ -72,22 +58,14 @@
|
|||||||
<IntDir>$(SolutionDir)Build\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)Build\$(Configuration)\</IntDir>
|
||||||
<MultiProcFXC>true</MultiProcFXC>
|
<MultiProcFXC>true</MultiProcFXC>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithDebugLogs|Win32'">
|
|
||||||
<TargetName>ddraw</TargetName>
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<GenerateManifest>false</GenerateManifest>
|
|
||||||
<IntDir>$(SolutionDir)Build\$(Configuration)\</IntDir>
|
|
||||||
<MultiProcFXC>true</MultiProcFXC>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
<PrecompiledHeader>
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<PreprocessorDefinitions>DEBUGLOGS;WIN32_LEAN_AND_MEAN;CINTERFACE;_NO_DDRAWINT_NO_COM;PSAPI_VERSION=1;WIN32;_DEBUG;_WINDOWS;_USRDLL;DDRAWCOMPAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;CINTERFACE;_NO_DDRAWINT_NO_COM;PSAPI_VERSION=1;WIN32;_DEBUG;_WINDOWS;_USRDLL;DDRAWCOMPAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
|
||||||
<ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
|
<ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
@ -111,9 +89,9 @@
|
|||||||
<VariableName>g_ps%(Filename)</VariableName>
|
<VariableName>g_ps%(Filename)</VariableName>
|
||||||
</FxCompile>
|
</FxCompile>
|
||||||
<FxCompile>
|
<FxCompile>
|
||||||
|
<HeaderFileOutput>$(IntDir)%(RelativeDir)%(Filename).h</HeaderFileOutput>
|
||||||
<ObjectFileOutput />
|
<ObjectFileOutput />
|
||||||
<ShaderModel>2.0</ShaderModel>
|
<ShaderModel>2.0</ShaderModel>
|
||||||
<HeaderFileOutput>$(IntDir)%(RelativeDir)%(Filename).h</HeaderFileOutput>
|
|
||||||
<ShaderType>Pixel</ShaderType>
|
<ShaderType>Pixel</ShaderType>
|
||||||
<DisableOptimizations>false</DisableOptimizations>
|
<DisableOptimizations>false</DisableOptimizations>
|
||||||
</FxCompile>
|
</FxCompile>
|
||||||
@ -127,6 +105,7 @@
|
|||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
|
<ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir);$(IntDir)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir);$(IntDir)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@ -148,49 +127,11 @@
|
|||||||
</FxCompile>
|
</FxCompile>
|
||||||
<FxCompile>
|
<FxCompile>
|
||||||
<HeaderFileOutput>$(IntDir)%(RelativeDir)%(Filename).h</HeaderFileOutput>
|
<HeaderFileOutput>$(IntDir)%(RelativeDir)%(Filename).h</HeaderFileOutput>
|
||||||
</FxCompile>
|
|
||||||
<FxCompile>
|
|
||||||
<ObjectFileOutput />
|
<ObjectFileOutput />
|
||||||
<ShaderModel>2.0</ShaderModel>
|
<ShaderModel>2.0</ShaderModel>
|
||||||
<ShaderType>Pixel</ShaderType>
|
<ShaderType>Pixel</ShaderType>
|
||||||
</FxCompile>
|
</FxCompile>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithDebugLogs|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>DEBUGLOGS;WIN32_LEAN_AND_MEAN;CINTERFACE;_NO_DDRAWINT_NO_COM;PSAPI_VERSION=1;WIN32;NDEBUG;_WINDOWS;_USRDLL;DDRAWCOMPAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
<ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
|
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir);$(IntDir)</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies>dwmapi.lib;dxguid.lib;imm32.lib;msimg32.lib;oleacc.lib;uxtheme.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
|
|
||||||
</Link>
|
|
||||||
<PreBuildEvent>
|
|
||||||
<Command>powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Unrestricted -File genversion.ps1 "$(IntDir)version.h"</Command>
|
|
||||||
<Message>Generating version information</Message>
|
|
||||||
</PreBuildEvent>
|
|
||||||
<ResourceCompile>
|
|
||||||
<AdditionalIncludeDirectories>$(IntDir)</AdditionalIncludeDirectories>
|
|
||||||
<PreprocessorDefinitions>SPECIALBUILD=\"$(Configuration)\"</PreprocessorDefinitions>
|
|
||||||
</ResourceCompile>
|
|
||||||
<FxCompile>
|
|
||||||
<VariableName>g_ps%(Filename)</VariableName>
|
|
||||||
</FxCompile>
|
|
||||||
<FxCompile>
|
|
||||||
<ObjectFileOutput />
|
|
||||||
<ShaderModel>2.0</ShaderModel>
|
|
||||||
<HeaderFileOutput>$(IntDir)%(RelativeDir)%(Filename).h</HeaderFileOutput>
|
|
||||||
<ShaderType>Pixel</ShaderType>
|
|
||||||
</FxCompile>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Common\BitSet.h" />
|
<ClInclude Include="Common\BitSet.h" />
|
||||||
<ClInclude Include="Common\Comparison.h" />
|
<ClInclude Include="Common\Comparison.h" />
|
||||||
@ -229,6 +170,7 @@
|
|||||||
<ClInclude Include="Config\Settings\DisplayResolution.h" />
|
<ClInclude Include="Config\Settings\DisplayResolution.h" />
|
||||||
<ClInclude Include="Config\Settings\ForceD3D9On12.h" />
|
<ClInclude Include="Config\Settings\ForceD3D9On12.h" />
|
||||||
<ClInclude Include="Config\Settings\FullscreenMode.h" />
|
<ClInclude Include="Config\Settings\FullscreenMode.h" />
|
||||||
|
<ClInclude Include="Config\Settings\LogLevel.h" />
|
||||||
<ClInclude Include="Config\Settings\RemoveBorders.h" />
|
<ClInclude Include="Config\Settings\RemoveBorders.h" />
|
||||||
<ClInclude Include="Config\Settings\RenderColorDepth.h" />
|
<ClInclude Include="Config\Settings\RenderColorDepth.h" />
|
||||||
<ClInclude Include="Config\Settings\ResolutionScale.h" />
|
<ClInclude Include="Config\Settings\ResolutionScale.h" />
|
||||||
@ -471,11 +413,9 @@
|
|||||||
<FxCompile Include="Shaders\TextureSampler.hlsl" />
|
<FxCompile Include="Shaders\TextureSampler.hlsl" />
|
||||||
<FxCompile Include="Shaders\VertexFixup.hlsl">
|
<FxCompile Include="Shaders\VertexFixup.hlsl">
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ReleaseWithDebugLogs|Win32'">Vertex</ShaderType>
|
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
|
||||||
<VariableName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">g_vs%(Filename)</VariableName>
|
<VariableName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">g_vs%(Filename)</VariableName>
|
||||||
<VariableName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">g_vs%(Filename)</VariableName>
|
<VariableName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">g_vs%(Filename)</VariableName>
|
||||||
<VariableName Condition="'$(Configuration)|$(Platform)'=='ReleaseWithDebugLogs|Win32'">g_vs%(Filename)</VariableName>
|
|
||||||
</FxCompile>
|
</FxCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -484,4 +424,4 @@
|
|||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -564,6 +564,9 @@
|
|||||||
<ClInclude Include="Config\Settings\BltFilter.h">
|
<ClInclude Include="Config\Settings\BltFilter.h">
|
||||||
<Filter>Header Files\Config\Settings</Filter>
|
<Filter>Header Files\Config\Settings</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Config\Settings\LogLevel.h">
|
||||||
|
<Filter>Header Files\Config\Settings</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Gdi\Gdi.cpp">
|
<ClCompile Include="Gdi\Gdi.cpp">
|
||||||
|
@ -34,7 +34,7 @@ namespace
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: Failed to create a Direct3D object for hooking: " << Compat::hex(result);
|
LOG_INFO << "ERROR: Failed to create a Direct3D object for hooking: " << Compat::hex(result);
|
||||||
}
|
}
|
||||||
return d3d;
|
return d3d;
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ namespace
|
|||||||
HRESULT result = dd->CreateSurface(&dd, &desc, &renderTarget.getRef(), nullptr);
|
HRESULT result = dd->CreateSurface(&dd, &desc, &renderTarget.getRef(), nullptr);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: Failed to create a render target for hooking: " << Compat::hex(result);
|
LOG_INFO << "ERROR: Failed to create a render target for hooking: " << Compat::hex(result);
|
||||||
}
|
}
|
||||||
return renderTarget;
|
return renderTarget;
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ namespace
|
|||||||
&d3d, IID_IDirect3DRGBDevice, &renderTarget, &d3dDevice.getRef(), nullptr);
|
&d3d, IID_IDirect3DRGBDevice, &renderTarget, &d3dDevice.getRef(), nullptr);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: Failed to create a Direct3D device for hooking: " << Compat::hex(result);
|
LOG_INFO << "ERROR: Failed to create a Direct3D device for hooking: " << Compat::hex(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ namespace
|
|||||||
HRESULT result = dev->CreateExecuteBuffer(&dev, &desc, &buffer.getRef(), nullptr);
|
HRESULT result = dev->CreateExecuteBuffer(&dev, &desc, &buffer.getRef(), nullptr);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: Failed to create an execute buffer for hooking: " << Compat::hex(result);
|
LOG_INFO << "ERROR: Failed to create an execute buffer for hooking: " << Compat::hex(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ namespace
|
|||||||
HRESULT result = d3d->CreateLight(&d3d, &light.getRef(), nullptr);
|
HRESULT result = d3d->CreateLight(&d3d, &light.getRef(), nullptr);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: Failed to create a light for hooking: " << Compat::hex(result);
|
LOG_INFO << "ERROR: Failed to create a light for hooking: " << Compat::hex(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ namespace
|
|||||||
HRESULT result = d3d->CreateMaterial(&d3d, &material.getRef(), nullptr);
|
HRESULT result = d3d->CreateMaterial(&d3d, &material.getRef(), nullptr);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: Failed to create a material for hooking: " << Compat::hex(result);
|
LOG_INFO << "ERROR: Failed to create a material for hooking: " << Compat::hex(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ namespace
|
|||||||
HRESULT result = dd->CreateSurface(&dd, &desc, &texture.getRef(), nullptr);
|
HRESULT result = dd->CreateSurface(&dd, &desc, &texture.getRef(), nullptr);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: Failed to create a texture for hooking: " << Compat::hex(result);
|
LOG_INFO << "ERROR: Failed to create a texture for hooking: " << Compat::hex(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ namespace
|
|||||||
HRESULT result = d3d->CreateVertexBuffer(&d3d, &desc, &vertexBuffer.getRef(), 0, nullptr);
|
HRESULT result = d3d->CreateVertexBuffer(&d3d, &desc, &vertexBuffer.getRef(), 0, nullptr);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: Failed to create a vertex buffer for hooking: " << Compat::hex(result);
|
LOG_INFO << "ERROR: Failed to create a vertex buffer for hooking: " << Compat::hex(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
Direct3d::Direct3dVertexBuffer::hookVtable(*vertexBuffer.get()->lpVtbl);
|
Direct3d::Direct3dVertexBuffer::hookVtable(*vertexBuffer.get()->lpVtbl);
|
||||||
@ -211,7 +211,7 @@ namespace
|
|||||||
HRESULT result = d3d->CreateViewport(&d3d, &viewport.getRef(), nullptr);
|
HRESULT result = d3d->CreateViewport(&d3d, &viewport.getRef(), nullptr);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: Failed to create a Direct3D viewport for hooking: " << Compat::hex(result);
|
LOG_INFO << "ERROR: Failed to create a Direct3D viewport for hooking: " << Compat::hex(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,11 +70,11 @@ namespace
|
|||||||
static bool isAlreadyInstalled = false;
|
static bool isAlreadyInstalled = false;
|
||||||
if (!isAlreadyInstalled)
|
if (!isAlreadyInstalled)
|
||||||
{
|
{
|
||||||
Compat::Log() << "Installing display mode hooks";
|
LOG_INFO << "Installing display mode hooks";
|
||||||
Win32::DisplayMode::installHooks();
|
Win32::DisplayMode::installHooks();
|
||||||
Compat::Log() << "Installing registry hooks";
|
LOG_INFO << "Installing registry hooks";
|
||||||
Win32::Registry::installHooks();
|
Win32::Registry::installHooks();
|
||||||
Compat::Log() << "Installing Direct3D driver hooks";
|
LOG_INFO << "Installing Direct3D driver hooks";
|
||||||
D3dDdi::installHooks();
|
D3dDdi::installHooks();
|
||||||
Gdi::VirtualScreen::init();
|
Gdi::VirtualScreen::init();
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ namespace
|
|||||||
HRESULT result = CALL_ORIG_PROC(DirectDrawCreate)(nullptr, &dd.getRef(), nullptr);
|
HRESULT result = CALL_ORIG_PROC(DirectDrawCreate)(nullptr, &dd.getRef(), nullptr);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: Failed to create a DirectDraw object for hooking: " << Compat::hex(result);
|
LOG_INFO << "ERROR: Failed to create a DirectDraw object for hooking: " << Compat::hex(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ namespace
|
|||||||
nullptr, reinterpret_cast<void**>(&dd7.getRef()), IID_IDirectDraw7, nullptr);
|
nullptr, reinterpret_cast<void**>(&dd7.getRef()), IID_IDirectDraw7, nullptr);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: Failed to create a DirectDraw object for hooking: " << Compat::hex(result);
|
LOG_INFO << "ERROR: Failed to create a DirectDraw object for hooking: " << Compat::hex(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,19 +104,19 @@ namespace
|
|||||||
}
|
}
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: Failed to set the cooperative level for hooking: " << Compat::hex(result);
|
LOG_INFO << "ERROR: Failed to set the cooperative level for hooking: " << Compat::hex(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Compat::Log() << "Installing DirectDraw hooks";
|
LOG_INFO << "Installing DirectDraw hooks";
|
||||||
DDraw::installHooks(dd7);
|
DDraw::installHooks(dd7);
|
||||||
Compat::Log() << "Installing Direct3D hooks";
|
LOG_INFO << "Installing Direct3D hooks";
|
||||||
Direct3d::installHooks(dd, dd7);
|
Direct3d::installHooks(dd, dd7);
|
||||||
Compat::Log() << "Installing GDI hooks";
|
LOG_INFO << "Installing GDI hooks";
|
||||||
Gdi::installHooks();
|
Gdi::installHooks();
|
||||||
Compat::closeDbgEng();
|
Compat::closeDbgEng();
|
||||||
Gdi::GuiThread::start();
|
Gdi::GuiThread::start();
|
||||||
Compat::Log() << "Finished installing hooks";
|
LOG_INFO << "Finished installing hooks";
|
||||||
isAlreadyInstalled = true;
|
isAlreadyInstalled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,7 +143,7 @@ namespace
|
|||||||
|
|
||||||
void printEnvironmentVariable(const char* var)
|
void printEnvironmentVariable(const char* var)
|
||||||
{
|
{
|
||||||
Compat::Log() << "Environment variable " << var << " = \"" << Dll::getEnvVar(var) << '"';
|
LOG_INFO << "Environment variable " << var << " = \"" << Dll::getEnvVar(var) << '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDpiAwareness()
|
void setDpiAwareness()
|
||||||
@ -189,26 +189,26 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto processPath(Compat::getModulePath(nullptr));
|
auto processPath(Compat::getModulePath(nullptr));
|
||||||
Compat::Log::initLogging(processPath);
|
LOG_INFO << "Process path: " << processPath.u8string();
|
||||||
Compat::Log() << "Process path: " << processPath.u8string();
|
|
||||||
|
|
||||||
auto currentDllPath(Compat::getModulePath(hinstDLL));
|
auto currentDllPath(Compat::getModulePath(hinstDLL));
|
||||||
Compat::Log() << "Loading DDrawCompat " << (lpvReserved ? "statically" : "dynamically") << " from " << currentDllPath.u8string();
|
LOG_INFO << "Loading DDrawCompat " << (lpvReserved ? "statically" : "dynamically") << " from " << currentDllPath.u8string();
|
||||||
printEnvironmentVariable("__COMPAT_LAYER");
|
printEnvironmentVariable("__COMPAT_LAYER");
|
||||||
|
|
||||||
Config::Parser::loadAllConfigFiles(processPath);
|
Config::Parser::loadAllConfigFiles(processPath);
|
||||||
|
Compat::Log::initLogging(processPath, Config::logLevel.get());
|
||||||
|
|
||||||
auto systemPath(Compat::getSystemPath());
|
auto systemPath(Compat::getSystemPath());
|
||||||
if (Compat::isEqual(currentDllPath.parent_path(), systemPath))
|
if (Compat::isEqual(currentDllPath.parent_path(), systemPath))
|
||||||
{
|
{
|
||||||
Compat::Log() << "DDrawCompat cannot be installed in the Windows system directory";
|
LOG_INFO << "DDrawCompat cannot be installed in the Windows system directory";
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dll::g_origDDrawModule = LoadLibraryW((systemPath / "ddraw.dll").c_str());
|
Dll::g_origDDrawModule = LoadLibraryW((systemPath / "ddraw.dll").c_str());
|
||||||
if (!Dll::g_origDDrawModule)
|
if (!Dll::g_origDDrawModule)
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: Failed to load system ddraw.dll from " << systemPath.u8string();
|
LOG_INFO << "ERROR: Failed to load system ddraw.dll from " << systemPath.u8string();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,11 +247,11 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|||||||
CALL_ORIG_PROC(SetAppCompatData)(disableMaxWindowedMode, 0);
|
CALL_ORIG_PROC(SetAppCompatData)(disableMaxWindowedMode, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Compat::Log() << "DDrawCompat loaded successfully";
|
LOG_INFO << "DDrawCompat loaded successfully";
|
||||||
}
|
}
|
||||||
else if (fdwReason == DLL_PROCESS_DETACH)
|
else if (fdwReason == DLL_PROCESS_DETACH)
|
||||||
{
|
{
|
||||||
Compat::Log() << "DDrawCompat detached successfully";
|
LOG_INFO << "DDrawCompat detached successfully";
|
||||||
}
|
}
|
||||||
else if (fdwReason == DLL_THREAD_DETACH)
|
else if (fdwReason == DLL_THREAD_DETACH)
|
||||||
{
|
{
|
||||||
|
@ -323,20 +323,14 @@ namespace
|
|||||||
template <auto origFunc>
|
template <auto origFunc>
|
||||||
void hookGdiDcFunction(const char* moduleName, const char* funcName)
|
void hookGdiDcFunction(const char* moduleName, const char* funcName)
|
||||||
{
|
{
|
||||||
#ifdef DEBUGLOGS
|
|
||||||
g_funcName<origFunc> = funcName;
|
g_funcName<origFunc> = funcName;
|
||||||
#endif
|
|
||||||
|
|
||||||
Compat::hookFunction<origFunc>(moduleName, funcName, &compatGdiDcFunc<origFunc>);
|
Compat::hookFunction<origFunc>(moduleName, funcName, &compatGdiDcFunc<origFunc>);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <auto origFunc>
|
template <auto origFunc>
|
||||||
void hookGdiTextDcFunction(const char* moduleName, const char* funcName)
|
void hookGdiTextDcFunction(const char* moduleName, const char* funcName)
|
||||||
{
|
{
|
||||||
#ifdef DEBUGLOGS
|
|
||||||
g_funcName<origFunc> = funcName;
|
g_funcName<origFunc> = funcName;
|
||||||
#endif
|
|
||||||
|
|
||||||
Compat::hookFunction<origFunc>(moduleName, funcName, &compatGdiTextDcFunc<origFunc>);
|
Compat::hookFunction<origFunc>(moduleName, funcName, &compatGdiTextDcFunc<origFunc>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ namespace
|
|||||||
"DDrawCompatMessageWindow", nullptr, 0, 0, 0, 0, 0, HWND_MESSAGE, nullptr, nullptr, nullptr);
|
"DDrawCompatMessageWindow", nullptr, 0, 0, 0, 0, 0, HWND_MESSAGE, nullptr, nullptr, nullptr);
|
||||||
if (!g_messageWindow)
|
if (!g_messageWindow)
|
||||||
{
|
{
|
||||||
Compat::Log() << "ERROR: Failed to create a message-only window";
|
LOG_INFO << "ERROR: Failed to create a message-only window";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,10 +51,7 @@ namespace
|
|||||||
template <auto origFunc>
|
template <auto origFunc>
|
||||||
void hookIconFunc(const char* moduleName, const char* funcName)
|
void hookIconFunc(const char* moduleName, const char* funcName)
|
||||||
{
|
{
|
||||||
#ifdef DEBUGLOGS
|
|
||||||
g_funcName<origFunc> = funcName;
|
g_funcName<origFunc> = funcName;
|
||||||
#endif
|
|
||||||
|
|
||||||
Compat::hookFunction<origFunc>(moduleName, funcName, &iconFunc<origFunc>);
|
Compat::hookFunction<origFunc>(moduleName, funcName, &iconFunc<origFunc>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,7 +378,7 @@ namespace
|
|||||||
HMODULE module = Compat::getModuleHandleFromAddress(wndProc);
|
HMODULE module = Compat::getModuleHandleFromAddress(wndProc);
|
||||||
if (module != GetModuleHandle("ntdll") && module != GetModuleHandle("user32"))
|
if (module != GetModuleHandle("ntdll") && module != GetModuleHandle("user32"))
|
||||||
{
|
{
|
||||||
Compat::Log() << "Failed to hook a user32 window procedure: " << className;
|
LOG_INFO << "Failed to hook a user32 window procedure: " << className;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ namespace Win32
|
|||||||
|
|
||||||
if (0 == cpuAffinity || !CALL_ORIG_FUNC(SetProcessAffinityMask)(GetCurrentProcess(), cpuAffinity))
|
if (0 == cpuAffinity || !CALL_ORIG_FUNC(SetProcessAffinityMask)(GetCurrentProcess(), cpuAffinity))
|
||||||
{
|
{
|
||||||
Compat::Log() << (0 == cpuAffinity ? "Invalid" : "Failed to set") << " CPU affinity, falling back to default";
|
LOG_INFO << (0 == cpuAffinity ? "Invalid" : "Failed to set") << " CPU affinity, falling back to default";
|
||||||
Config::cpuAffinity.reset();
|
Config::cpuAffinity.reset();
|
||||||
CALL_ORIG_FUNC(SetProcessAffinityMask)(GetCurrentProcess(), Config::cpuAffinity.get());
|
CALL_ORIG_FUNC(SetProcessAffinityMask)(GetCurrentProcess(), Config::cpuAffinity.get());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user