Skip to content

Instantly share code, notes, and snippets.

@DJm00n
Created May 29, 2022 18:10
Show Gist options
  • Save DJm00n/2ff4604f13d294a6fbd5113a89676e4a to your computer and use it in GitHub Desktop.
Save DJm00n/2ff4604f13d294a6fbd5113a89676e4a to your computer and use it in GitHub Desktop.
GetDefaultLayout() from input.dll
/* WARNING: Could not reconcile some variable overlaps */
void GetDefaultLayout(LPCWSTR param_1,wchar_t *param_2,uint *param_3)
{
LSTATUS LVar1;
uint uVar2;
ulonglong uVar3;
undefined **ppuVar4;
undefined **hKey;
HKEY hKey_00;
HKEY pHVar5;
bool bVar6;
DWORD local_388;
DWORD local_384;
DWORD local_380 [2];
wchar_t *local_378;
undefined **local_370;
undefined **local_368;
undefined **local_360;
HKEY local_358;
wchar_t local_348 [40];
short local_2f8 [40];
undefined2 local_2a8 [40];
WCHAR local_258 [264];
ulonglong local_48;
/* 0x1bef0 113 GetDefaultLayout */
local_48 = __security_cookie ^ (ulonglong)&stack0xfffffffffffffc48;
hKey = (undefined **)0x0;
local_378 = param_2;
if (param_3 == (uint *)0x0) goto LAB_18001c314;
if (param_2 == (wchar_t *)0x0) {
*param_3 = 0x54;
goto LAB_18001c314;
}
local_358 = (HKEY)0x0;
local_370 = &`vftable';
local_368 = (undefined **)0x0;
local_360 = &`vftable';
if (param_1 == (LPCWSTR)0x0) {
pHVar5 = (HKEY)0xffffffff80000001;
LAB_18001bfb2:
hKey_00 = local_358;
uVar3 = ?Open@CInputDllRegKey@@QEAAJPEAUHKEY__@@PEBGK@Z
((longlong)&local_370,pHVar5,L"Keyboard Layout\\Preload",0x20019);
hKey = local_368;
bVar6 = false;
if ((int)uVar3 == 0) {
local_384 = 0x50;
local_388 = 0;
LVar1 = RegQueryValueExW((HKEY)local_368,L"1",(LPDWORD)0x0,&local_388,(LPBYTE)local_348,
&local_384);
*(undefined2 *)((longlong)local_348 + (ulonglong)(~-(uint)(LVar1 != 0) & 0x4e)) = 0;
if (LVar1 == 0) {
uVar3 = ?TransNum@Externals@@YAKPEBGPEAPEBG@Z(local_348);
uVar2 = (uint)uVar3;
uVar3 = ?Open@CInputDllRegKey@@QEAAJPEAUHKEY__@@PEBGK@Z
((longlong)&local_370,pHVar5,L"Keyboard Layout\\Substitutes",0x20019);
hKey = local_368;
if ((int)uVar3 == 0) {
local_388 = 0x50;
local_384 = 0;
LVar1 = RegQueryValueExW((HKEY)local_368,local_348,(LPDWORD)0x0,&local_384,
(LPBYTE)local_2f8,&local_388);
*(undefined2 *)((longlong)local_2f8 + (ulonglong)(~-(uint)(LVar1 != 0) & 0x4e)) = 0;
if (LVar1 == 0) {
uVar3 = ?TransNum@Externals@@YAKPEBGPEAPEBG@Z(local_2f8);
uVar2 = (uint)uVar3;
}
}
local_384 = wcstoul(local_348,(wchar_t **)0x0,0x10);
if ((uVar2 & 0xf0000000) != 0xe0000000) {
?CLSIDToStringW@@YAHAEBU_GUID@@PEAG@Z((longlong)&GUID_TFCAT_TIP_KEYBOARD,local_2a8);
memset(local_258,0,0x208);
?StringCchPrintfW@@YAJPEAG_KPEBGZZ
(local_258,0x104,L"%s\\0x0000%04x\\%s",L"Software\\Microsoft\\CTF\\Assemblies");
uVar3 = ?Open@CInputDllRegKey@@QEAAJPEAUHKEY__@@PEBGK@Z
((longlong)&local_370,pHVar5,local_258,0x20019);
hKey = local_368;
if ((int)uVar3 == 0) {
local_388 = 0x50;
local_380[0] = 0;
LVar1 = RegQueryValueExW((HKEY)local_368,L"Default",(LPDWORD)0x0,local_380,
(LPBYTE)local_348,&local_388);
*(undefined2 *)((longlong)local_348 + (ulonglong)(~-(uint)(LVar1 != 0) & 0x4e)) = 0;
if (LVar1 == 0) {
local_380[0] = 0x50;
local_388 = 0;
LVar1 = RegQueryValueExW((HKEY)hKey,L"Profile",(LPDWORD)0x0,&local_388,
(LPBYTE)local_2f8,local_380);
*(undefined2 *)((longlong)local_2f8 + (ulonglong)(~-(uint)(LVar1 != 0) & 0x4e)) = 0;
if ((((LVar1 == 0) && (local_348[0] == L'{')) &&
(uVar3 = ?StringToCLSID@@YAHPEBGPEAU_GUID@@@Z
((longlong)local_348,(int *)&local_360), (int)uVar3 != 0)) &&
(((local_2f8[0] == 0x7b &&
(uVar3 = ?StringToCLSID@@YAHPEBGPEAU_GUID@@@Z
((longlong)local_2f8,(int *)&local_370), (int)uVar3 != 0))&&
((local_360 != (undefined **)0x0 || (local_358 != (HKEY)0x0)))))) {
ppuVar4 = local_370;
if (local_370 == (undefined **)0x0) {
ppuVar4 = local_368;
}
bVar6 = ppuVar4 != (undefined **)0x0;
}
}
}
}
if (bVar6) {
?StringCchPrintfW@@YAJPEAG_KPEBGZZ
(local_378,(ulonglong)*param_3,L"%04x:%s%s",(ulonglong)(ushort)local_384);
uVar2 = 0x54;
}
else {
?StringCchPrintfW@@YAJPEAG_KPEBGZZ
(local_378,(ulonglong)*param_3,L"%04x:%08x",(ulonglong)(ushort)local_384);
uVar2 = 0xe;
}
*param_3 = uVar2;
}
}
}
else {
uVar3 = ?Open@CInputDllRegKey@@QEAAJPEAUHKEY__@@PEBGK@Z
((longlong)&local_360,(HKEY)0xffffffff80000003,param_1,0x20019);
hKey_00 = local_358;
pHVar5 = local_358;
if ((int)uVar3 == 0) goto LAB_18001bfb2;
}
if (hKey_00 != (HKEY)0x0) {
RegCloseKey(hKey_00);
}
if (hKey != (undefined **)0x0) {
RegCloseKey((HKEY)hKey);
}
LAB_18001c314:
__security_check_cookie(local_48 ^ (ulonglong)&stack0xfffffffffffffc48);
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment