Skip to content

Commit

Permalink
Moved log query out of logging function
Browse files Browse the repository at this point in the history
- Removed log query inside of logging function to prevent unnecessary function calls. This will mean you NEED to restart adapter in order for logs to enable however this is done in favour of performance

- Support for live changing moved to companion app only due to above reasons
  • Loading branch information
bud3699 committed Oct 27, 2024
1 parent 978d62a commit 39ecdb0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Virtual Display Driver (HDR)/MttVDD/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ UINT numVirtualDisplays;
wstring gpuname;
wstring confpath = L"C:\\VirtualDisplayDriver";
bool logsEnabled = false;
bool debugLogs;
bool debugLogs = false;
bool HDRPlus = false;
bool SDR10 = false;
bool customEdid = false;
Expand Down Expand Up @@ -268,8 +268,6 @@ void SendToPipe(const std::string& logMessage) {

void vddlog(const char* type, const char* message) {
FILE* logFile;
logsEnabled = EnabledQuery(L"LoggingEnabled");
debugLogs = EnabledQuery(L"DebugLoggingEnabled");
wstring logsDir = confpath + L"\\Logs";

auto now = chrono::system_clock::now();
Expand Down Expand Up @@ -621,22 +619,26 @@ void HandleClient(HANDLE hPipe) {
wchar_t* param = buffer + 10;
if (wcsncmp(param, L"true", 4) == 0) {
UpdateXmlToggleSetting(true, L"debuglogging");
debugLogs = true;
vddlog("i", "Pipe debugging enabled");
vddlog("d", "Debug Logs Enabled");
}
else if (wcsncmp(param, L"false", 5) == 0) {
UpdateXmlToggleSetting(false, L"debuglogging");
debugLogs = false;
vddlog("i", "Debugging disabled");
}
}
else if (wcsncmp(buffer, L"LOGGING", 7) == 0) {
wchar_t* param = buffer + 8;
if (wcsncmp(param, L"true", 4) == 0) {
UpdateXmlToggleSetting(true, L"logging");
logsEnabled = true;
vddlog("i", "Logging Enabled");
}
else if (wcsncmp(param, L"false", 5) == 0) {
UpdateXmlToggleSetting(false, L"logging");
logsEnabled = false;
vddlog("i", "Logging disabled");
}
}
Expand Down Expand Up @@ -838,15 +840,15 @@ bool initpath() {
if (lResult != ERROR_SUCCESS) {
ostringstream oss;
oss << "Failed to open registry key for path. Error code: " << lResult;
vddlog("w", oss.str().c_str()); // These are okay to call though since they're only called if the reg doesnt exist
//vddlog("w", oss.str().c_str()); // These are okay to call though since they're only called if the reg doesnt exist
return false;
}

lResult = RegQueryValueExW(hKey, L"VDDPATH", NULL, NULL, (LPBYTE)szPath, &dwBufferSize);
if (lResult != ERROR_SUCCESS) {
ostringstream oss;
oss << "Failed to open registry key for path. Error code: " << lResult;
vddlog("w", oss.str().c_str());
//vddlog("w", oss.str().c_str()); Prevent these from being called since no longer checks before logging, only on startup whether it should
RegCloseKey(hKey);
return false;
}
Expand Down Expand Up @@ -888,6 +890,7 @@ extern "C" NTSTATUS DriverEntry(
Config.EvtDriverUnload = EvtDriverUnload;
initpath();
logsEnabled = EnabledQuery(L"LoggingEnabled");
debugLogs = EnabledQuery(L"DebugLoggingEnabled");
HDRPlus = EnabledQuery(L"HDRPlusEnabled");
SDR10 = EnabledQuery(L"SDR10Enabled");
HDRCOLOUR = HDRPlus ? IDDCX_BITS_PER_COMPONENT_12 : IDDCX_BITS_PER_COMPONENT_10;
Expand Down

0 comments on commit 39ecdb0

Please sign in to comment.