Skip to content

Commit 973b962

Browse files
committed
Improve handling of wide characters contd
1 parent edfc404 commit 973b962

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

OptiScaler/hooks/LibraryLoad_Hooks.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ HMODULE LibraryLoadHooks::LoadLibraryCheckW(std::wstring libName, LPCWSTR lpLibF
4040
LOG_TRACE("{}", libNameA);
4141

4242
// C:\\Path\\like\\this.dll
43-
auto normalizedPath = std::filesystem::path(libName).lexically_normal().string();
43+
auto normalizedPath = std::filesystem::path(libName).lexically_normal().wstring();
4444

4545
// If Opti is not loading as nvngx.dll
4646
if (!State::Instance().isWorkingAsNvngx)
@@ -99,14 +99,14 @@ HMODULE LibraryLoadHooks::LoadLibraryCheckW(std::wstring libName, LPCWSTR lpLibF
9999
{
100100
auto loadedBin = NtdllProxy::LoadLibraryExW_Ldr(lpLibFullPath, NULL, 0);
101101

102-
if (loadedBin && normalizedPath.contains("\\versions\\"))
102+
if (loadedBin && normalizedPath.contains(L"\\versions\\"))
103103
{
104-
if (normalizedPath.contains("\\dlss\\"))
104+
if (normalizedPath.contains(L"\\dlss\\"))
105105
{
106106
State::Instance().NGX_OTA_Dlss = wstring_to_string(lpLibFullPath);
107107
}
108108

109-
if (normalizedPath.contains("\\dlssd\\"))
109+
if (normalizedPath.contains(L"\\dlssd\\"))
110110
{
111111
State::Instance().NGX_OTA_Dlssd = wstring_to_string(lpLibFullPath);
112112
}
@@ -173,7 +173,7 @@ HMODULE LibraryLoadHooks::LoadLibraryCheckW(std::wstring libName, LPCWSTR lpLibF
173173
// Try to catch something like this:
174174
// C:\ProgramData/NVIDIA/NGX/models/sl_dlss_0/versions/133120/files/190_E658703.dll
175175
if (CheckDllNameW(&libName, &slDlssNamesW) ||
176-
(normalizedPath.contains("\\versions\\") && normalizedPath.contains("\\sl_dlss_0")))
176+
(normalizedPath.contains(L"\\versions\\") && normalizedPath.contains(L"\\sl_dlss_0")))
177177
{
178178
auto dlssModule = NtdllProxy::LoadLibraryExW_Ldr(lpLibFullPath, NULL, 0);
179179

@@ -191,7 +191,7 @@ HMODULE LibraryLoadHooks::LoadLibraryCheckW(std::wstring libName, LPCWSTR lpLibF
191191

192192
// sl.dlss_g.dll
193193
if (CheckDllNameW(&libName, &slDlssgNamesW) ||
194-
(normalizedPath.contains("\\versions\\") && normalizedPath.contains("\\sl_dlss_g_")))
194+
(normalizedPath.contains(L"\\versions\\") && normalizedPath.contains(L"\\sl_dlss_g_")))
195195
{
196196
auto dlssgModule = NtdllProxy::LoadLibraryExW_Ldr(lpLibFullPath, NULL, 0);
197197

@@ -209,7 +209,7 @@ HMODULE LibraryLoadHooks::LoadLibraryCheckW(std::wstring libName, LPCWSTR lpLibF
209209

210210
// sl.reflex.dll
211211
if (CheckDllNameW(&libName, &slReflexNamesW) ||
212-
(normalizedPath.contains("\\versions\\") && normalizedPath.contains("\\sl_reflex_")))
212+
(normalizedPath.contains(L"\\versions\\") && normalizedPath.contains(L"\\sl_reflex_")))
213213
{
214214
auto reflexModule = NtdllProxy::LoadLibraryExW_Ldr(lpLibFullPath, NULL, 0);
215215

@@ -227,7 +227,7 @@ HMODULE LibraryLoadHooks::LoadLibraryCheckW(std::wstring libName, LPCWSTR lpLibF
227227

228228
// sl.pcl.dll
229229
if (CheckDllNameW(&libName, &slPclNamesW) ||
230-
(normalizedPath.contains("\\versions\\") && normalizedPath.contains("\\sl_pcl_")))
230+
(normalizedPath.contains(L"\\versions\\") && normalizedPath.contains(L"\\sl_pcl_")))
231231
{
232232
auto pclModule = NtdllProxy::LoadLibraryExW_Ldr(lpLibFullPath, NULL, 0);
233233

@@ -245,7 +245,7 @@ HMODULE LibraryLoadHooks::LoadLibraryCheckW(std::wstring libName, LPCWSTR lpLibF
245245

246246
// sl.common.dll
247247
if (CheckDllNameW(&libName, &slCommonNamesW) ||
248-
(normalizedPath.contains("\\versions\\") && normalizedPath.contains("\\sl_common_")))
248+
(normalizedPath.contains(L"\\versions\\") && normalizedPath.contains(L"\\sl_common_")))
249249
{
250250
auto commonModule = NtdllProxy::LoadLibraryExW_Ldr(lpLibFullPath, NULL, 0);
251251

0 commit comments

Comments
 (0)