58 ULONG IndexDevice = 0;
75 DPRINT(
"NtOpenKey() failed with status 0x%08lx\n",
Status);
79 pDeviceInformation =
RtlAllocateHeap(RtlGetProcessHeap(), 0, DeviceInfoLength);
80 if (!pDeviceInformation)
82 DPRINT(
"RtlAllocateHeap() failed\n");
87 pValueInformation =
RtlAllocateHeap(RtlGetProcessHeap(), 0, ValueInfoLength);
88 if (!pValueInformation)
90 DPRINT(
"RtlAllocateHeap() failed\n");
107 RtlFreeHeap(RtlGetProcessHeap(), 0, pDeviceInformation);
109 pDeviceInformation =
RtlAllocateHeap(RtlGetProcessHeap(), 0, DeviceInfoLength);
110 if (!pDeviceInformation)
112 DPRINT(
"RtlAllocateHeap() failed\n");
125 DPRINT(
"NtEnumerateKey() failed with status 0x%08lx\n",
Status);
143 DPRINT(
"NtOpenKey() failed with status 0x%08lx\n",
Status);
156 RtlFreeHeap(RtlGetProcessHeap(), 0, pValueInformation);
158 pValueInformation =
RtlAllocateHeap(RtlGetProcessHeap(), 0, ValueInfoLength);
159 if (!pValueInformation)
161 DPRINT(
"RtlAllocateHeap() failed\n");
174 DPRINT(
"NtQueryValueKey() failed with status 0x%08lx\n",
Status);
179 DPRINT(
"Wrong registry type: got 0x%lx, expected 0x%lx\n", pValueInformation->
Type,
REG_SZ);
189 DPRINT(
"Found ACPI BIOS\n");
200 if (pDeviceInformation)
201 RtlFreeHeap(RtlGetProcessHeap(), 0, pDeviceInformation);
202 if (pValueInformation)
203 RtlFreeHeap(RtlGetProcessHeap(), 0, pValueInformation);
225 DPRINT(
"GetComputerIdentifier() called\n");
231 DPRINT(
"RtlAllocateHeap() failed\n");
237 L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor");
279 ComputerIdentifier =
L"X64 MP";
281 ComputerIdentifier =
L"X64 UP";
289 ComputerIdentifier =
L"ACPI UP";
294 ComputerIdentifier =
L"ACPI MP";
302 ComputerIdentifier =
L"PC UP";
307 ComputerIdentifier =
L"PC MP";
315 SizeNeeded = (
wcslen(ComputerIdentifier) + 1) *
sizeof(
WCHAR);
316 if (SizeNeeded > IdentifierLength)
368 DPRINT(
"INF_GetDataField() failed\n");
374 DPRINT(
"INF_GetDataField() failed\n");
391 DPRINT(
"ProcessEntry() failed\n");
394 else if (RetVal == 1)
421 ValueSize = (
wcslen(KeyValue) + 1) *
sizeof(
WCHAR);
424 sizeof(*GenEntry) + IdSize + ValueSize);
425 if (GenEntry ==
NULL)
428 DPRINT1(
"RtlAllocateHeap() failed\n");
454 WCHAR ComputerIdentifier[128];
455 WCHAR ComputerKey[32];
456 ULONG Count1, Count2;
461 ComputerIdentifier[0] = 0;
464 DPRINT(
"Computer identifier: '%S'\n", ComputerIdentifier);
480 DPRINT(
"INF_GetDataField() failed\n");
484 DPRINT(
"KeyValue: %S\n", KeyValue);
485 FoundId = !!
wcsstr(ComputerIdentifier, KeyValue);
494 DPRINT(
"INF_GetDataField() failed\n");
511 L"Computer.NT" INF_ARCH,
515 if ((Count1 == -1) && (Count2 == -1))
557 HANDLE ControllerInstanceKey;
559 ULONG ControllerInstance;
565 DPRINT(
"GetDisplayIdentifier() called\n");
569 L"\\Registry\\Machine\\HARDWARE\\Description\\System\\MultifunctionAdapter");
619 ControllerInstance = 0;
652 if (ValueInfo ==
NULL)
654 DPRINT(
"RtlAllocateHeap() failed\n");
655 NtClose(ControllerInstanceKey);
682 NtClose(ControllerInstanceKey);
689 NtClose(ControllerInstanceKey);
691 ControllerInstance++;
715 WCHAR DisplayIdentifier[128];
716 WCHAR DisplayKey[32];
721 DisplayIdentifier[0] = 0;
724 DPRINT(
"Display identifier: '%S'\n", DisplayIdentifier);
740 DPRINT(
"INF_GetDataField() failed\n");
744 DPRINT(
"KeyValue: %S\n", KeyValue);
745 FoundId = !!
wcsstr(DisplayIdentifier, KeyValue);
754 DPRINT(
"INF_GetDataField() failed\n");
792 static WCHAR SectionName[128];
794 DPRINT(
"ProcessComputerFiles(%S) called\n", ComputerType);
797 L"Files.%s", ComputerType);
798 *AdditionalSectionName = SectionName;
821 DPRINT(
"ProcessDisplayRegistry(%S) called\n", DisplayType);
825 DPRINT1(
"SpInfFindFirstLine() failed\n");
832 DPRINT1(
"INF_GetDataField() failed\n");
840 L"System\\CurrentControlSet\\Services\\%s",
866 DPRINT1(
"RtlWriteRegistryValue() failed (Status %lx)\n",
Status);
874 DPRINT1(
"INF_GetDataField() failed\n");
879 L"System\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\%s\\Device0",
881 DPRINT(
"RegPath: '%S'\n", RegPath);
895 L"System\\CurrentControlSet\\Services\\%s\\Device0",
910 L"DefaultSettings.XResolution",
916 DPRINT1(
"RtlWriteRegistryValue() failed (Status %lx)\n",
Status);
923 DPRINT1(
"INF_GetDataField() failed\n");
930 L"DefaultSettings.YResolution",
936 DPRINT1(
"RtlWriteRegistryValue() failed (Status %lx)\n",
Status);
943 DPRINT1(
"INF_GetDataField() failed\n");
950 L"DefaultSettings.BitsPerPel",
956 DPRINT1(
"RtlWriteRegistryValue() failed (Status %lx)\n",
Status);
963 DPRINT(
"ProcessDisplayRegistry() done\n");
978 DPRINT(
"LanguageId: %S\n", LanguageId);
982 L".DEFAULT\\Control Panel\\International");
1015 if (
wcslen(LanguageId) >= 4)
1020 L"SYSTEM\\CurrentControlSet\\Control\\NLS\\Language");
1121 SIZE_T IdSize, ValueSize;
1130 ValueSize = (
wcslen(KeyValue) + 1) *
sizeof(
WCHAR);
1133 sizeof(*GenEntry) + IdSize + ValueSize);
1134 if (GenEntry ==
NULL)
1137 DPRINT1(
"RtlAllocateHeap() failed\n");
1152 LangEntryParam->
uIndex++;
1169 LangEntryParam.
uIndex = 0;
1190 &LangEntryParam) == -1)
1197 if (LangEntryParam.
uIndex == 1)
1251 }
while (LayoutsList[uIndex].
LangID != 0);
1257 DPRINT1(
"No keyboard layouts have been found\n");
1284 if (LayoutsList[0].LayoutID == LayoutId)
1288 for (uIndex = 1; LayoutsList[uIndex].
LangID != 0; ++uIndex)
1290 if (LayoutsList[uIndex].LayoutID == LayoutId)
1296 NewLayoutsList[uIndex].
LangID = LayoutsList[uIndex].
LangID;
1300 NewLayoutsList[uIndex].
LangID = 0;
1301 NewLayoutsList[uIndex].
LayoutID = 0;
1302 NewLayoutsList[uOldPos].
LangID = LayoutsList[0].
LangID;
1304 NewLayoutsList[0].
LangID = LayoutsList[uOldPos].
LangID;
1312ProcessKeyboardLayoutFiles(
1337 L".DEFAULT\\Control Panel\\International\\Geo");
1378 WCHAR ValueBuffer[] =
L"?:\\pagefile.sys 0 0\0";
1391 ValueBuffer[0] =
Drive;
1397 (
PVOID)&ValueBuffer,
1398 sizeof(ValueBuffer));
static WCHAR ServiceName[]
HANDLE GetRootKeyByPredefKey(IN HANDLE KeyHandle, OUT PCWSTR *RootKeyMountPoint OPTIONAL)
PGENERIC_LIST CreateKeyboardDriverList(IN HINF InfFile)
PGENERIC_LIST CreateComputerTypeList(IN HINF InfFile)
struct _LANG_ENTRY_PARAM * PLANG_ENTRY_PARAM
ULONG GetDefaultLanguageIndex(VOID)
BOOLEAN SetDefaultPagefile(_In_ WCHAR Drive)
static BOOLEAN GetComputerIdentifier(OUT PWSTR Identifier, IN ULONG IdentifierLength)
PGENERIC_LIST CreateDisplayDriverList(IN HINF InfFile)
BOOLEAN AddComputerTypeEntries(_In_ HINF InfFile, PGENERIC_LIST List, _In_ PWSTR SectionName)
static LONG AddEntriesFromInfSection(IN OUT PGENERIC_LIST List, IN HINF InfFile, IN PCWSTR SectionName, IN PINFCONTEXT pContext, IN PPROCESS_ENTRY_ROUTINE ProcessEntry, IN PVOID Parameter OPTIONAL)
UCHAR(NTAPI * PPROCESS_ENTRY_ROUTINE)(IN PCWSTR KeyName, IN PCWSTR KeyValue, OUT PVOID *UserData, OUT PBOOLEAN Current, IN PVOID Parameter OPTIONAL)
BOOLEAN ProcessKeyboardLayoutRegistry(_In_ PCWSTR pszLayoutId, _In_ PCWSTR LanguageId)
static BOOLEAN GetDisplayIdentifier(OUT PWSTR Identifier, IN ULONG IdentifierLength)
BOOLEAN ProcessComputerFiles(_In_ HINF InfFile, _In_ PCWSTR ComputerType, _Out_ PWSTR *AdditionalSectionName)
static BOOLEAN IsAcpiComputer(VOID)
static UCHAR NTAPI DefaultProcessEntry(IN PCWSTR KeyName, IN PCWSTR KeyValue, OUT PVOID *UserData, OUT PBOOLEAN Current, IN PVOID Parameter OPTIONAL)
static UCHAR NTAPI ProcessLangEntry(IN PCWSTR KeyName, IN PCWSTR KeyValue, OUT PVOID *UserData, OUT PBOOLEAN Current, IN PVOID Parameter OPTIONAL)
PGENERIC_LIST CreateKeyboardLayoutList(IN HINF InfFile, IN PCWSTR LanguageId, OUT PWSTR DefaultKBLayout)
BOOLEAN ProcessDisplayRegistry(_In_ HINF InfFile, _In_ PCWSTR DisplayType)
PGENERIC_LIST CreateLanguageList(IN HINF InfFile, OUT PWSTR DefaultLanguage)
struct _LANG_ENTRY_PARAM LANG_ENTRY_PARAM
BOOLEAN SetGeoID(_In_ GEOID GeoId)
BOOLEAN ProcessLocaleRegistry(_In_ PCWSTR LanguageId)
static ULONG DefaultLanguageIndex
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG _In_ ULONG _Out_ PULONG ReturnedLength
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define NT_SUCCESS(StatCode)
static void cleanup(void)
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define OBJ_CASE_INSENSITIVE
NTSYSAPI NTSTATUS WINAPI RtlWriteRegistryValue(ULONG, PCWSTR, PCWSTR, ULONG, PVOID, ULONG)
pSpInfFindNextLine SpInfFindNextLine
pSpInfFindFirstLine SpInfFindFirstLine
FORCEINLINE VOID INF_FreeData(IN PCWSTR InfData)
BOOLEAN AddKbLayoutsToRegistry(_In_ const MUI_LAYOUTS *MuiLayouts)
const MUI_LAYOUTS * MUIGetLayoutsList(IN PCWSTR LanguageId)
BOOLEAN IsLanguageAvailable(IN PCWSTR LanguageId)
BOOLEAN INF_GetDataField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PCWSTR *Data)
BOOLEAN INF_GetData(IN PINFCONTEXT Context, OUT PCWSTR *Key, OUT PCWSTR *Data)
PGENERIC_LIST CreateGenericList(VOID)
PGENERIC_LIST_ENTRY GetFirstListEntry(IN PGENERIC_LIST List)
BOOLEAN AppendGenericListEntry(IN OUT PGENERIC_LIST List, IN PVOID Data, IN BOOLEAN Current)
VOID DestroyGenericList(IN OUT PGENERIC_LIST List, IN BOOLEAN FreeData)
ULONG GetNumberOfListEntries(IN PGENERIC_LIST List)
PVOID GetListEntryData(IN PGENERIC_LIST_ENTRY Entry)
#define InitializeObjectAttributes(p, n, a, r, s)
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
NTSYSAPI NTSTATUS NTAPI NtSetValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN ULONG TitleIndex OPTIONAL, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
@ KeyValuePartialInformation
struct _KEY_BASIC_INFORMATION KEY_BASIC_INFORMATION
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
NTSYSAPI NTSTATUS NTAPI NtQueryValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, IN PULONG ResultLength)
struct _KEY_FULL_INFORMATION KEY_FULL_INFORMATION
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
NTSYSAPI NTSTATUS NTAPI NtEnumerateKey(IN HANDLE KeyHandle, IN ULONG Index, IN KEY_INFORMATION_CLASS KeyInformationClass, IN PVOID KeyInformation, IN ULONG Length, IN PULONG ResultLength)
#define KEY_ENUMERATE_SUB_KEYS
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
struct _KEY_FULL_INFORMATION * PKEY_FULL_INFORMATION
#define RTL_REGISTRY_HANDLE
NTSTATUS NTAPI NtQueryKey(IN HANDLE KeyHandle, IN KEY_INFORMATION_CLASS KeyInformationClass, OUT PVOID KeyInformation, IN ULONG Length, OUT PULONG ResultLength)
#define STATUS_NO_MORE_ENTRIES
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
NTSTRSAFEAPI RtlStringCchCopyW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
static UNICODE_STRING IdentifierU
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define STATUS_BUFFER_TOO_SMALL
#define STATUS_BUFFER_OVERFLOW
PULONG MinorVersion OPTIONAL
#define RTL_CONSTANT_STRING(s)
#define RtlCopyMemory(Destination, Source, Length)
#define STATUS_OBJECT_NAME_NOT_FOUND
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
_In_ HFONT _Out_ PUINT Height
static WCHAR DefaultLanguage[20]
static WCHAR DefaultKBLayout[20]
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
_Must_inspect_result_ _In_ WDFCMRESLIST List
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
#define HKEY_LOCAL_MACHINE
_Inout_opt_ PVOID Parameter