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
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29001.49
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.2.32516.85
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DDrawCompat", "DDrawCompat\DDrawCompat.vcxproj", "{1146187A-17DE-4350-B9D1-9F9EAA934908}"
|
||||
EndProject
|
||||
@ -9,15 +9,12 @@ Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x86 = Release|x86
|
||||
ReleaseWithDebugLogs|x86 = ReleaseWithDebugLogs|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{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}.Release|x86.ActiveCfg = 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
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -131,9 +131,7 @@ namespace
|
||||
BYTE* targetFunc = static_cast<BYTE*>(origFuncPtr);
|
||||
|
||||
std::ostringstream oss;
|
||||
#ifdef DEBUGLOGS
|
||||
oss << Compat::funcPtrToStr(targetFunc) << ' ';
|
||||
#endif
|
||||
|
||||
char origFuncPtrStr[20] = {};
|
||||
if (!funcName)
|
||||
@ -170,16 +168,15 @@ namespace
|
||||
{
|
||||
break;
|
||||
}
|
||||
#ifdef DEBUGLOGS
|
||||
|
||||
Compat::LogStream(oss) << Compat::hexDump(prevTargetFunc, instructionSize) << " -> "
|
||||
<< Compat::funcPtrToStr(targetFunc) << ' ';
|
||||
#endif
|
||||
prevTargetFunc = targetFunc;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -241,7 +238,7 @@ namespace
|
||||
auto dbgEng = LoadLibraryW((Compat::getSystemPath() / "dbgeng.dll").c_str());
|
||||
if (!dbgEng)
|
||||
{
|
||||
Compat::Log() << "ERROR: DbgEng: failed to load library";
|
||||
LOG_INFO << "ERROR: DbgEng: failed to load library";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -250,7 +247,7 @@ namespace
|
||||
auto debugCreate = reinterpret_cast<decltype(&DebugCreate)>(Compat::getProcAddress(dbgEng, "DebugCreate"));
|
||||
if (!debugCreate)
|
||||
{
|
||||
Compat::Log() << "ERROR: DbgEng: DebugCreate not found";
|
||||
LOG_INFO << "ERROR: DbgEng: DebugCreate not found";
|
||||
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_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;
|
||||
}
|
||||
|
||||
result = g_debugClient->OpenDumpFileWide(Compat::getModulePath(Dll::g_currentModule).c_str(), 0);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Compat::Log() << "ERROR: DbgEng: OpenDumpFile failed: " << Compat::hex(result);
|
||||
LOG_INFO << "ERROR: DbgEng: OpenDumpFile failed: " << Compat::hex(result);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -275,7 +272,7 @@ namespace
|
||||
result = g_debugControl->WaitForEvent(0, INFINITE);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Compat::Log() << "ERROR: DbgEng: WaitForEvent failed: " << Compat::hex(result);
|
||||
LOG_INFO << "ERROR: DbgEng: WaitForEvent failed: " << Compat::hex(result);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -283,7 +280,7 @@ namespace
|
||||
result = g_debugSymbols->GetModuleParameters(1, 0, 0, &dmp);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Compat::Log() << "ERROR: DbgEng: GetModuleParameters failed: " << Compat::hex(result);
|
||||
LOG_INFO << "ERROR: DbgEng: GetModuleParameters failed: " << Compat::hex(result);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -291,7 +288,7 @@ namespace
|
||||
result = g_debugDataSpaces->GetValidRegionVirtual(dmp.Base, dmp.Size, &g_debugBase, &size);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,17 @@
|
||||
#include <regex>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <Common/Log.h>
|
||||
#include <Common/Path.h>
|
||||
#include <Common/ScopedCriticalSection.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
Compat::CriticalSection g_logCs;
|
||||
std::ofstream g_logFile;
|
||||
static std::ostringstream g_initialLogStream;
|
||||
|
||||
}
|
||||
|
||||
namespace Compat
|
||||
@ -23,33 +29,60 @@ namespace Compat
|
||||
return os;
|
||||
}
|
||||
|
||||
Log::Log() : m_lock(g_logCs)
|
||||
Log::Log(bool isEnabled) : m_isEnabled(isEnabled)
|
||||
{
|
||||
if (!m_isEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EnterCriticalSection(&g_logCs);
|
||||
SYSTEMTIME st = {};
|
||||
GetLocalTime(&st);
|
||||
|
||||
char header[20];
|
||||
#ifdef DEBUGLOGS
|
||||
sprintf_s(header, "%04hx %02hu:%02hu:%02hu.%03hu ",
|
||||
GetCurrentThreadId(), st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
|
||||
#else
|
||||
sprintf_s(header, "%02hu:%02hu:%02hu.%03hu ", st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
|
||||
#endif
|
||||
s_logFile << header;
|
||||
if (s_logLevel >= Config::Settings::LogLevel::DEBUG)
|
||||
{
|
||||
sprintf_s(header, "%04hx %02hu:%02hu:%02hu.%03hu ",
|
||||
GetCurrentThreadId(), st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf_s(header, "%02hu:%02hu:%02hu.%03hu ",
|
||||
st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
|
||||
}
|
||||
*s_logStream << header;
|
||||
|
||||
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()
|
||||
{
|
||||
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"))
|
||||
{
|
||||
processPath.replace_extension();
|
||||
@ -65,16 +98,46 @@ namespace Compat
|
||||
}
|
||||
logFilePath += ".log";
|
||||
|
||||
s_logFile.open(logFilePath, std::ios_base::out, SH_DENYWR);
|
||||
if (!s_logFile.fail())
|
||||
g_logFile.open(logFilePath, std::ios_base::out, SH_DENYWR);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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 <Common/ScopedCriticalSection.h>
|
||||
#include <Config/Settings/LogLevel.h>
|
||||
#include <DDraw/Log.h>
|
||||
#include <Win32/Log.h>
|
||||
|
||||
#ifdef DEBUGLOGS
|
||||
#define LOG_DEBUG Compat::Log()
|
||||
#define LOG_INFO Compat::Log(Config::Settings::LogLevel::INFO)
|
||||
#define LOG_DEBUG Compat::Log(Config::Settings::LogLevel::DEBUG)
|
||||
#define LOG_FUNC(...) Compat::LogFunc logFunc(__VA_ARGS__)
|
||||
#define LOG_FUNC_CUSTOM(funcPtr, ...) Compat::LogFunc<funcPtr> logFunc(__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) \
|
||||
{ \
|
||||
static bool isAlreadyLogged = false; \
|
||||
if (!isAlreadyLogged) \
|
||||
{ \
|
||||
Compat::Log() << msg; \
|
||||
LOG_INFO << msg; \
|
||||
isAlreadyLogged = true; \
|
||||
} \
|
||||
}
|
||||
@ -245,28 +239,34 @@ namespace Compat
|
||||
class Log
|
||||
{
|
||||
public:
|
||||
Log();
|
||||
Log(bool isEnabled);
|
||||
Log(unsigned logLevel);
|
||||
~Log();
|
||||
|
||||
template <typename T>
|
||||
Log& operator<<(const T& t)
|
||||
{
|
||||
LogStream(s_logFile) << t;
|
||||
if (m_isEnabled)
|
||||
{
|
||||
LogStream(*s_logStream) << t;
|
||||
}
|
||||
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; }
|
||||
|
||||
private:
|
||||
friend class LogFuncBase;
|
||||
|
||||
ScopedCriticalSection m_lock;
|
||||
bool m_isEnabled;
|
||||
|
||||
static thread_local DWORD s_indent;
|
||||
|
||||
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)>
|
||||
@ -315,7 +315,10 @@ namespace Compat
|
||||
template <typename T>
|
||||
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;
|
||||
}
|
||||
|
||||
@ -324,29 +327,19 @@ namespace Compat
|
||||
LogFuncBase(const char* funcName, std::function<void(Log&)> logParams)
|
||||
: m_funcName(funcName)
|
||||
, m_logParams(logParams)
|
||||
, m_isEnabled(Log::s_logLevel >= Config::Settings::LogLevel::DEBUG)
|
||||
{
|
||||
Log log;
|
||||
log << "> ";
|
||||
logCall(log);
|
||||
Log::s_indent += 2;
|
||||
}
|
||||
|
||||
~LogFuncBase()
|
||||
{
|
||||
Log::s_isLeaveLog = true;
|
||||
Log::s_indent -= 2;
|
||||
Log log;
|
||||
log << "< ";
|
||||
logCall(log);
|
||||
|
||||
if (m_logResult)
|
||||
if (m_isEnabled)
|
||||
{
|
||||
log << " = ";
|
||||
m_logResult(log);
|
||||
Log log(Config::Settings::LogLevel::DEBUG);
|
||||
log << "> ";
|
||||
logCall(log);
|
||||
Log::s_indent += 2;
|
||||
}
|
||||
Log::s_isLeaveLog = false;
|
||||
}
|
||||
|
||||
~LogFuncBase();
|
||||
|
||||
template <typename Param>
|
||||
auto packParam(Param&& param)
|
||||
{
|
||||
@ -377,6 +370,7 @@ namespace Compat
|
||||
const char* m_funcName;
|
||||
std::function<void(Log&)> m_logParams;
|
||||
std::function<void(Log&)> m_logResult;
|
||||
bool m_isEnabled;
|
||||
};
|
||||
|
||||
template <auto funcPtr = nullptr>
|
||||
|
@ -17,12 +17,10 @@ template <auto memberPtr, typename Vtable>
|
||||
constexpr auto getCompatFunc(Vtable*)
|
||||
{
|
||||
auto func = getCompatVtable<Vtable>().*memberPtr;
|
||||
#ifdef DEBUGLOGS
|
||||
if (!func)
|
||||
{
|
||||
func = &callOrigFunc<memberPtr>;
|
||||
}
|
||||
#endif
|
||||
return func;
|
||||
}
|
||||
|
||||
@ -52,18 +50,21 @@ public:
|
||||
template <auto memberPtr>
|
||||
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
|
||||
s_funcName<memberPtr> = s_vtableTypeName + "::" + funcName;
|
||||
Compat::Log() << "Hooking function: " << s_funcName<memberPtr>
|
||||
<< " (" << Compat::funcPtrToStr(m_vtable.*memberPtr) << ')';
|
||||
#endif
|
||||
m_vtable.*memberPtr = &hookFunc<memberPtr>;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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:
|
||||
@ -101,11 +102,9 @@ private:
|
||||
static std::string s_vtableTypeName;
|
||||
};
|
||||
|
||||
#ifdef DEBUGLOGS
|
||||
template <typename Vtable, typename Lock>
|
||||
template <auto memberPtr>
|
||||
std::string VtableHookVisitor<Vtable, Lock>::s_funcName;
|
||||
|
||||
template <typename Vtable, typename Lock>
|
||||
std::string VtableHookVisitor<Vtable, Lock>::s_vtableTypeName(getVtableTypeName());
|
||||
#endif
|
||||
|
@ -14,6 +14,7 @@ namespace Config
|
||||
Settings::DisplayResolution displayResolution;
|
||||
Settings::ForceD3D9On12 forceD3D9On12;
|
||||
Settings::FullscreenMode fullscreenMode;
|
||||
Settings::LogLevel logLevel;
|
||||
Settings::RemoveBorders removeBorders;
|
||||
Settings::RenderColorDepth renderColorDepth;
|
||||
Settings::ResolutionScale resolutionScale;
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <Config/Settings/DisplayResolution.h>
|
||||
#include <Config/Settings/ForceD3D9On12.h>
|
||||
#include <Config/Settings/FullscreenMode.h>
|
||||
#include <Config/Settings/LogLevel.h>
|
||||
#include <Config/Settings/RemoveBorders.h>
|
||||
#include <Config/Settings/RenderColorDepth.h>
|
||||
#include <Config/Settings/ResolutionScale.h>
|
||||
@ -38,6 +39,7 @@ namespace Config
|
||||
extern Settings::DisplayResolution displayResolution;
|
||||
extern Settings::ForceD3D9On12 forceD3D9On12;
|
||||
extern Settings::FullscreenMode fullscreenMode;
|
||||
extern Settings::LogLevel logLevel;
|
||||
extern Settings::RemoveBorders removeBorders;
|
||||
extern Settings::RenderColorDepth renderColorDepth;
|
||||
extern Settings::ResolutionScale resolutionScale;
|
||||
|
@ -19,11 +19,11 @@ namespace
|
||||
|
||||
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);
|
||||
if (!f.is_open())
|
||||
{
|
||||
Compat::Log() << " File not found, skipping";
|
||||
LOG_INFO << " File not found, skipping";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ namespace
|
||||
}
|
||||
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())
|
||||
{
|
||||
std::string name(setting.second.getName());
|
||||
name.insert(name.end(), maxNameLength - name.length(), ' ');
|
||||
std::string source(setting.second.getSource());
|
||||
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())
|
||||
{
|
||||
return "\"\"";
|
||||
return "none";
|
||||
}
|
||||
return '"' + result.substr(2) + '"';
|
||||
return result.substr(2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,8 +55,8 @@ namespace D3dDdi
|
||||
info.formatOps = getFormatOps();
|
||||
info.supportedZBufferBitDepths = getSupportedZBufferBitDepths(info.formatOps);
|
||||
|
||||
Compat::Log() << "Supported z-buffer bit depths: " << bitDepthsToString(info.supportedZBufferBitDepths);
|
||||
Compat::Log() << "Supported MSAA modes: " << getSupportedMsaaModes(info.formatOps);
|
||||
LOG_INFO << "Supported z-buffer bit depths: " << bitDepthsToString(info.supportedZBufferBitDepths);
|
||||
LOG_INFO << "Supported MSAA modes: " << getSupportedMsaaModes(info.formatOps);
|
||||
LOG_DEBUG << "Supported resource formats:";
|
||||
for (const auto& formatOp : info.formatOps)
|
||||
{
|
||||
|
@ -79,7 +79,7 @@ namespace
|
||||
static std::set<HMODULE> hookedModules;
|
||||
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);
|
||||
hookedModules.insert(hModule);
|
||||
}
|
||||
|
@ -599,9 +599,7 @@ namespace D3dDdi
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUGLOGS
|
||||
LOG_RESULT(m_lockResource.get());
|
||||
#endif
|
||||
}
|
||||
|
||||
void Resource::disableClamp()
|
||||
|
@ -32,7 +32,7 @@ namespace
|
||||
}
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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))
|
||||
{
|
||||
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 = {};
|
||||
return result;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ namespace DDraw
|
||||
result = Surface::create(dd, desc, surface, std::move(privateData));
|
||||
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 = {};
|
||||
RealPrimarySurface::release();
|
||||
return result;
|
||||
|
@ -5,10 +5,6 @@
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="ReleaseWithDebugLogs|Win32">
|
||||
<Configuration>ReleaseWithDebugLogs</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
@ -36,13 +32,6 @@
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
<SpectreMitigation>false</SpectreMitigation>
|
||||
</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" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
@ -54,9 +43,6 @@
|
||||
<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" />
|
||||
</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 Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<TargetName>ddraw</TargetName>
|
||||
@ -72,22 +58,14 @@
|
||||
<IntDir>$(SolutionDir)Build\$(Configuration)\</IntDir>
|
||||
<MultiProcFXC>true</MultiProcFXC>
|
||||
</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'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<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>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
@ -111,9 +89,9 @@
|
||||
<VariableName>g_ps%(Filename)</VariableName>
|
||||
</FxCompile>
|
||||
<FxCompile>
|
||||
<HeaderFileOutput>$(IntDir)%(RelativeDir)%(Filename).h</HeaderFileOutput>
|
||||
<ObjectFileOutput />
|
||||
<ShaderModel>2.0</ShaderModel>
|
||||
<HeaderFileOutput>$(IntDir)%(RelativeDir)%(Filename).h</HeaderFileOutput>
|
||||
<ShaderType>Pixel</ShaderType>
|
||||
<DisableOptimizations>false</DisableOptimizations>
|
||||
</FxCompile>
|
||||
@ -127,6 +105,7 @@
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);$(IntDir)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
@ -148,49 +127,11 @@
|
||||
</FxCompile>
|
||||
<FxCompile>
|
||||
<HeaderFileOutput>$(IntDir)%(RelativeDir)%(Filename).h</HeaderFileOutput>
|
||||
</FxCompile>
|
||||
<FxCompile>
|
||||
<ObjectFileOutput />
|
||||
<ShaderModel>2.0</ShaderModel>
|
||||
<ShaderType>Pixel</ShaderType>
|
||||
</FxCompile>
|
||||
</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>
|
||||
<ClInclude Include="Common\BitSet.h" />
|
||||
<ClInclude Include="Common\Comparison.h" />
|
||||
@ -229,6 +170,7 @@
|
||||
<ClInclude Include="Config\Settings\DisplayResolution.h" />
|
||||
<ClInclude Include="Config\Settings\ForceD3D9On12.h" />
|
||||
<ClInclude Include="Config\Settings\FullscreenMode.h" />
|
||||
<ClInclude Include="Config\Settings\LogLevel.h" />
|
||||
<ClInclude Include="Config\Settings\RemoveBorders.h" />
|
||||
<ClInclude Include="Config\Settings\RenderColorDepth.h" />
|
||||
<ClInclude Include="Config\Settings\ResolutionScale.h" />
|
||||
@ -471,11 +413,9 @@
|
||||
<FxCompile Include="Shaders\TextureSampler.hlsl" />
|
||||
<FxCompile Include="Shaders\VertexFixup.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ReleaseWithDebugLogs|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)'=='Release|Win32'">g_vs%(Filename)</VariableName>
|
||||
<VariableName Condition="'$(Configuration)|$(Platform)'=='ReleaseWithDebugLogs|Win32'">g_vs%(Filename)</VariableName>
|
||||
</FxCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -484,4 +424,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
@ -564,6 +564,9 @@
|
||||
<ClInclude Include="Config\Settings\BltFilter.h">
|
||||
<Filter>Header Files\Config\Settings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Config\Settings\LogLevel.h">
|
||||
<Filter>Header Files\Config\Settings</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Gdi\Gdi.cpp">
|
||||
|
@ -34,7 +34,7 @@ namespace
|
||||
}
|
||||
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;
|
||||
}
|
||||
@ -58,7 +58,7 @@ namespace
|
||||
HRESULT result = dd->CreateSurface(&dd, &desc, &renderTarget.getRef(), nullptr);
|
||||
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;
|
||||
}
|
||||
@ -103,7 +103,7 @@ namespace
|
||||
&d3d, IID_IDirect3DRGBDevice, &renderTarget, &d3dDevice.getRef(), nullptr);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ namespace
|
||||
HRESULT result = dev->CreateExecuteBuffer(&dev, &desc, &buffer.getRef(), nullptr);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ namespace
|
||||
HRESULT result = d3d->CreateLight(&d3d, &light.getRef(), nullptr);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ namespace
|
||||
HRESULT result = d3d->CreateMaterial(&d3d, &material.getRef(), nullptr);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ namespace
|
||||
HRESULT result = dd->CreateSurface(&dd, &desc, &texture.getRef(), nullptr);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -199,7 +199,7 @@ namespace
|
||||
HRESULT result = d3d->CreateVertexBuffer(&d3d, &desc, &vertexBuffer.getRef(), 0, nullptr);
|
||||
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);
|
||||
@ -211,7 +211,7 @@ namespace
|
||||
HRESULT result = d3d->CreateViewport(&d3d, &viewport.getRef(), nullptr);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -70,11 +70,11 @@ namespace
|
||||
static bool isAlreadyInstalled = false;
|
||||
if (!isAlreadyInstalled)
|
||||
{
|
||||
Compat::Log() << "Installing display mode hooks";
|
||||
LOG_INFO << "Installing display mode hooks";
|
||||
Win32::DisplayMode::installHooks();
|
||||
Compat::Log() << "Installing registry hooks";
|
||||
LOG_INFO << "Installing registry hooks";
|
||||
Win32::Registry::installHooks();
|
||||
Compat::Log() << "Installing Direct3D driver hooks";
|
||||
LOG_INFO << "Installing Direct3D driver hooks";
|
||||
D3dDdi::installHooks();
|
||||
Gdi::VirtualScreen::init();
|
||||
|
||||
@ -82,7 +82,7 @@ namespace
|
||||
HRESULT result = CALL_ORIG_PROC(DirectDrawCreate)(nullptr, &dd.getRef(), nullptr);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ namespace
|
||||
nullptr, reinterpret_cast<void**>(&dd7.getRef()), IID_IDirectDraw7, nullptr);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -104,19 +104,19 @@ namespace
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
Compat::Log() << "Installing DirectDraw hooks";
|
||||
LOG_INFO << "Installing DirectDraw hooks";
|
||||
DDraw::installHooks(dd7);
|
||||
Compat::Log() << "Installing Direct3D hooks";
|
||||
LOG_INFO << "Installing Direct3D hooks";
|
||||
Direct3d::installHooks(dd, dd7);
|
||||
Compat::Log() << "Installing GDI hooks";
|
||||
LOG_INFO << "Installing GDI hooks";
|
||||
Gdi::installHooks();
|
||||
Compat::closeDbgEng();
|
||||
Gdi::GuiThread::start();
|
||||
Compat::Log() << "Finished installing hooks";
|
||||
LOG_INFO << "Finished installing hooks";
|
||||
isAlreadyInstalled = true;
|
||||
}
|
||||
}
|
||||
@ -143,7 +143,7 @@ namespace
|
||||
|
||||
void printEnvironmentVariable(const char* var)
|
||||
{
|
||||
Compat::Log() << "Environment variable " << var << " = \"" << Dll::getEnvVar(var) << '"';
|
||||
LOG_INFO << "Environment variable " << var << " = \"" << Dll::getEnvVar(var) << '"';
|
||||
}
|
||||
|
||||
void setDpiAwareness()
|
||||
@ -189,26 +189,26 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
}
|
||||
|
||||
auto processPath(Compat::getModulePath(nullptr));
|
||||
Compat::Log::initLogging(processPath);
|
||||
Compat::Log() << "Process path: " << processPath.u8string();
|
||||
LOG_INFO << "Process path: " << processPath.u8string();
|
||||
|
||||
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");
|
||||
|
||||
Config::Parser::loadAllConfigFiles(processPath);
|
||||
Compat::Log::initLogging(processPath, Config::logLevel.get());
|
||||
|
||||
auto systemPath(Compat::getSystemPath());
|
||||
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;
|
||||
}
|
||||
|
||||
Dll::g_origDDrawModule = LoadLibraryW((systemPath / "ddraw.dll").c_str());
|
||||
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;
|
||||
}
|
||||
|
||||
@ -247,11 +247,11 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
CALL_ORIG_PROC(SetAppCompatData)(disableMaxWindowedMode, 0);
|
||||
}
|
||||
|
||||
Compat::Log() << "DDrawCompat loaded successfully";
|
||||
LOG_INFO << "DDrawCompat loaded successfully";
|
||||
}
|
||||
else if (fdwReason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
Compat::Log() << "DDrawCompat detached successfully";
|
||||
LOG_INFO << "DDrawCompat detached successfully";
|
||||
}
|
||||
else if (fdwReason == DLL_THREAD_DETACH)
|
||||
{
|
||||
|
@ -323,20 +323,14 @@ namespace
|
||||
template <auto origFunc>
|
||||
void hookGdiDcFunction(const char* moduleName, const char* funcName)
|
||||
{
|
||||
#ifdef DEBUGLOGS
|
||||
g_funcName<origFunc> = funcName;
|
||||
#endif
|
||||
|
||||
Compat::hookFunction<origFunc>(moduleName, funcName, &compatGdiDcFunc<origFunc>);
|
||||
}
|
||||
|
||||
template <auto origFunc>
|
||||
void hookGdiTextDcFunction(const char* moduleName, const char* funcName)
|
||||
{
|
||||
#ifdef DEBUGLOGS
|
||||
g_funcName<origFunc> = funcName;
|
||||
#endif
|
||||
|
||||
Compat::hookFunction<origFunc>(moduleName, funcName, &compatGdiTextDcFunc<origFunc>);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ namespace
|
||||
"DDrawCompatMessageWindow", nullptr, 0, 0, 0, 0, 0, HWND_MESSAGE, nullptr, nullptr, nullptr);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -51,10 +51,7 @@ namespace
|
||||
template <auto origFunc>
|
||||
void hookIconFunc(const char* moduleName, const char* funcName)
|
||||
{
|
||||
#ifdef DEBUGLOGS
|
||||
g_funcName<origFunc> = funcName;
|
||||
#endif
|
||||
|
||||
Compat::hookFunction<origFunc>(moduleName, funcName, &iconFunc<origFunc>);
|
||||
}
|
||||
|
||||
|
@ -378,7 +378,7 @@ namespace
|
||||
HMODULE module = Compat::getModuleHandleFromAddress(wndProc);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ namespace Win32
|
||||
|
||||
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();
|
||||
CALL_ORIG_FUNC(SetProcessAffinityMask)(GetCurrentProcess(), Config::cpuAffinity.get());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user