Skip to content
This repository has been archived by the owner on Dec 28, 2024. It is now read-only.

Commit

Permalink
GetThreadUILanguage and SetThreadUILanguage
Browse files Browse the repository at this point in the history
  • Loading branch information
katahiromz committed Jan 15, 2022
1 parent b276e48 commit daa94d6
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ vista2xp-*
Testing
.ninja*
*.ninja
RosBE-Logs
33 changes: 33 additions & 0 deletions dlls/v2xker32/v2xker32.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ static FN_SleepConditionVariableSRW s_pSleepConditionVariableSRW;
static FN_WakeConditionVariable s_pWakeConditionVariable;
static FN_WakeAllConditionVariable s_pWakeAllConditionVariable;

typedef LANGID (WINAPI *FN_GetThreadUILanguage)(VOID);
typedef LANGID (WINAPI *FN_SetThreadUILanguage)(LANGID);

static FN_GetThreadUILanguage s_pGetThreadUILanguage;
static FN_SetThreadUILanguage s_pSetThreadUILanguage;

BOOL WINAPI
IsWow64ProcessForXP(HANDLE hProcess, PBOOL Wow64Process)
{
Expand All @@ -81,6 +87,31 @@ IsWow64ProcessForXP(HANDLE hProcess, PBOOL Wow64Process)
return FALSE;
}

BOOL IsWindowsVistaOrLater(VOID)
{
OSVERSIONINFOW osver = { sizeof(osver) };
return (GetVersionExW(&osver) && osver.dwMajorVersion >= 6);
}

LANGID GetThreadUILanguageForXP()
{
if (IsWindowsVistaOrLater() && s_pGetThreadUILanguage)
return (*s_pGetThreadUILanguage)();

return LANGIDFROMLCID(GetThreadLocale());
}

LANGID SetThreadUILanguageForXP(LANGID LangID)
{
if (IsWindowsVistaOrLater() && s_pSetThreadUILanguage)
return (*s_pSetThreadUILanguage)(LangID);

if (SetThreadLocale(MAKELCID(LangID, SORT_DEFAULT)))
return LangID;

return 0;
}

ULONGLONG WINAPI GetTickCount64ForXP(void)
{
LARGE_INTEGER count;
Expand Down Expand Up @@ -527,6 +558,8 @@ DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
s_pSleepConditionVariableSRW = (FN_SleepConditionVariableSRW)GetProcAddress(s_hKernel32, "SleepConditionVariableSRW");
s_pWakeConditionVariable = (FN_WakeConditionVariable)GetProcAddress(s_hKernel32, "WakeConditionVariable");
s_pWakeAllConditionVariable = (FN_WakeAllConditionVariable)GetProcAddress(s_hKernel32, "WakeAllConditionVariable");
s_pGetThreadUILanguage = (FN_GetThreadUILanguage)GetProcAddress(s_hKernel32, "GetThreadUILanguage");
s_pSetThreadUILanguage = (FN_SetThreadUILanguage)GetProcAddress(s_hKernel32, "SetThreadUILanguage");
break;
case DLL_PROCESS_DETACH:
break;
Expand Down
2 changes: 2 additions & 0 deletions dlls/v2xker32/v2xker32.def
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ EXPORTS
SleepConditionVariableSRW = SleepConditionVariableSRWForXP
WakeConditionVariable = WakeConditionVariableForXP
WakeAllConditionVariable = WakeAllConditionVariableForXP
GetThreadUILanguage = GetThreadUILanguageForXP
SetThreadUILanguage = SetThreadUILanguageForXP

; kernel32 --> advapi32
CreateProcessAsUserA = advapi32.CreateProcessAsUserA
Expand Down
2 changes: 2 additions & 0 deletions supported.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ kernel32.SleepConditionVariableCS
kernel32.SleepConditionVariableSRW
kernel32.WakeConditionVariable
kernel32.WakeAllConditionVariable
kernel32.GetThreadUILanguage
kernel32.SetThreadUILanguage
comctl32.TaskDialog
comctl32.TaskDialogIndirect
user32.ChangeWindowMessageFilter
Expand Down
4 changes: 3 additions & 1 deletion vista2xp/JustDoIt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ bool do_kernel32(codereverse::ExeImage& image, size_t i, char *name)
lstrcmpA(symbol.pszName, "SleepConditionVariableCS") == 0 ||
lstrcmpA(symbol.pszName, "SleepConditionVariableSRW") == 0 ||
lstrcmpA(symbol.pszName, "WakeConditionVariable") == 0 ||
lstrcmpA(symbol.pszName, "WakeAllConditionVariable") == 0)
lstrcmpA(symbol.pszName, "WakeAllConditionVariable") == 0 ||
lstrcmpA(symbol.pszName, "GetThreadUILanguage") == 0 ||
lstrcmpA(symbol.pszName, "SetThreadUILanguage") == 0)
{
if (lstrcmpiA(name, "kernel32") == 0)
StringCbCopyA(const_cast<char *>(name), sizeof("v2xker32"), "v2xker32");
Expand Down

0 comments on commit daa94d6

Please sign in to comment.