@@ -991,23 +991,6 @@ SString SharedUtil::GetSystemErrorMessage(uint uiError, bool bRemoveNewlines, bo
991
991
return strResult;
992
992
}
993
993
994
- #ifdef ExpandEnvironmentStringsForUser
995
- //
996
- // eg "%HOMEDRIVE%" -> "C:"
997
- //
998
- SString SharedUtil::ExpandEnvString (const SString& strInput)
999
- {
1000
- HANDLE hProcessToken;
1001
- if (!OpenProcessToken (GetCurrentProcess (), TOKEN_IMPERSONATE | TOKEN_QUERY | TOKEN_DUPLICATE, &hProcessToken))
1002
- return strInput;
1003
-
1004
- const static int iBufferSize = 32000 ;
1005
- char envBuf[iBufferSize + 2 ];
1006
- ExpandEnvironmentStringsForUser (hProcessToken, strInput, envBuf, iBufferSize);
1007
- return envBuf;
1008
- }
1009
- #endif
1010
-
1011
994
// /////////////////////////////////////////////////////////////
1012
995
//
1013
996
// MyShellExecute
@@ -1258,6 +1241,7 @@ static LONG SafeNtQueryInformationThread(HANDLE ThreadHandle, INT ThreadInformat
1258
1241
struct FunctionLookup
1259
1242
{
1260
1243
FunctionPointer function;
1244
+ HMODULE module ;
1261
1245
bool once;
1262
1246
};
1263
1247
@@ -1267,11 +1251,11 @@ static LONG SafeNtQueryInformationThread(HANDLE ThreadHandle, INT ThreadInformat
1267
1251
{
1268
1252
lookup.once = true ;
1269
1253
1270
- HMODULE ntdll = LoadLibraryA (" ntdll.dll" );
1254
+ lookup. module = LoadLibraryA (" ntdll.dll" );
1271
1255
1272
- if (ntdll )
1273
- lookup.function = static_cast <FunctionPointer>(static_cast <void *>(GetProcAddress (ntdll , " NtQueryInformationThread" )));
1274
- else
1256
+ if (lookup. module )
1257
+ lookup.function = static_cast <FunctionPointer>(static_cast <void *>(GetProcAddress (lookup. module , " NtQueryInformationThread" )));
1258
+ else
1275
1259
return 0xC0000135L ; // STATUS_DLL_NOT_FOUND
1276
1260
}
1277
1261
@@ -1876,17 +1860,27 @@ namespace SharedUtil
1876
1860
// Dynamically load GetCurrentProcessorNumber, as it does not exist on XP
1877
1861
using GetCurrentProcessorNumber_t = DWORD (WINAPI*)();
1878
1862
1879
- static auto FnGetCurrentProcessorNumber = ([]() -> GetCurrentProcessorNumber_t {
1880
- HMODULE kernel32 = LoadLibraryA (" kernel32" );
1863
+ struct ProcessorNumberLookup
1864
+ {
1865
+ GetCurrentProcessorNumber_t function;
1866
+ HMODULE module ;
1867
+ bool once;
1868
+ };
1869
+
1870
+ static ProcessorNumberLookup lookup = {};
1871
+
1881
1872
1882
- if (kernel32)
1883
- return static_cast <GetCurrentProcessorNumber_t>(static_cast <void *>(GetProcAddress (kernel32, " GetCurrentProcessorNumber" )));
1873
+ if (!lookup.once )
1874
+ {
1875
+ lookup.once = true ;
1876
+ lookup.module = LoadLibraryA (" kernel32" );
1884
1877
1885
- return nullptr ;
1886
- })();
1878
+ if (lookup.module )
1879
+ lookup.function = static_cast <GetCurrentProcessorNumber_t>(static_cast <void *>(GetProcAddress (lookup.module , " GetCurrentProcessorNumber" )));
1880
+ }
1887
1881
1888
- if (FnGetCurrentProcessorNumber )
1889
- return FnGetCurrentProcessorNumber ();
1882
+ if (lookup. function )
1883
+ return lookup. function ();
1890
1884
1891
1885
return _GetCurrentProcessorNumberXP ();
1892
1886
#elif defined(__APPLE__) && defined(__aarch64__)
@@ -2091,7 +2085,7 @@ namespace SharedUtil
2091
2085
if (iter == m_StartLastMap.end ())
2092
2086
return ;
2093
2087
2094
- // If last of found range is after query last, then range is not obscured
2088
+ // If last of found range is after or at query last, then range is not obscured
2095
2089
if (iter->second > uiLast)
2096
2090
return ;
2097
2091
@@ -2105,6 +2099,15 @@ namespace SharedUtil
2105
2099
IterType iter = m_StartLastMap.lower_bound (uiPoint);
2106
2100
// iter is on or after point - So it can't overlap the point
2107
2101
2102
+ if (iter != m_StartLastMap.end ())
2103
+ {
2104
+ // If last of found range is after or at query point, then range is overlapping
2105
+ if (iter->first <= uiPoint && iter->second >= uiPoint)
2106
+ {
2107
+ result = iter;
2108
+ return true ;
2109
+ }
2110
+ }
2108
2111
if (iter != m_StartLastMap.begin ())
2109
2112
{
2110
2113
iter--;
0 commit comments