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");
793 static WCHAR SectionName[128];
795 DPRINT(
"ProcessComputerFiles() called\n");
803 *AdditionalSectionName = SectionName;
825 DPRINT(
"ProcessDisplayRegistry() called\n");
835 DPRINT1(
"SpInfFindFirstLine() failed\n");
842 DPRINT1(
"INF_GetDataField() failed\n");
850 L"System\\CurrentControlSet\\Services\\%s",
876 DPRINT1(
"RtlWriteRegistryValue() failed (Status %lx)\n",
Status);
884 DPRINT1(
"INF_GetDataField() failed\n");
889 L"System\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\%s\\Device0",
891 DPRINT(
"RegPath: '%S'\n", RegPath);
905 L"System\\CurrentControlSet\\Services\\%s\\Device0",
920 L"DefaultSettings.XResolution",
926 DPRINT1(
"RtlWriteRegistryValue() failed (Status %lx)\n",
Status);
933 DPRINT1(
"INF_GetDataField() failed\n");
940 L"DefaultSettings.YResolution",
946 DPRINT1(
"RtlWriteRegistryValue() failed (Status %lx)\n",
Status);
953 DPRINT1(
"INF_GetDataField() failed\n");
960 L"DefaultSettings.BitsPerPel",
966 DPRINT1(
"RtlWriteRegistryValue() failed (Status %lx)\n",
Status);
973 DPRINT(
"ProcessDisplayRegistry() done\n");
996 if (LanguageId ==
NULL)
999 DPRINT(
"LanguageId: %S\n", LanguageId);
1003 L".DEFAULT\\Control Panel\\International");
1036 if (
wcslen(LanguageId) >= 4)
1041 L"SYSTEM\\CurrentControlSet\\Control\\NLS\\Language");
1142 SIZE_T IdSize, ValueSize;
1151 ValueSize = (
wcslen(KeyValue) + 1) *
sizeof(
WCHAR);
1154 sizeof(*GenEntry) + IdSize + ValueSize);
1155 if (GenEntry ==
NULL)
1158 DPRINT1(
"RtlAllocateHeap() failed\n");
1173 LangEntryParam->
uIndex++;
1190 LangEntryParam.
uIndex = 0;
1211 &LangEntryParam) == -1)
1218 if (LangEntryParam.
uIndex == 1)
1272 }
while (LayoutsList[uIndex].
LangID !=
NULL);
1278 DPRINT1(
"No keyboard layouts have been found\n");
1304 if (LayoutId ==
NULL)
1309 if (
_wcsicmp(LayoutsList[0].LayoutID, LayoutId) == 0)
1312 for (uIndex = 1; LayoutsList[uIndex].
LangID !=
NULL; uIndex++)
1314 if (
_wcsicmp(LayoutsList[uIndex].LayoutID, LayoutId) == 0)
1320 NewLayoutsList[uIndex].
LangID = LayoutsList[uIndex].
LangID;
1326 NewLayoutsList[uOldPos].
LangID = LayoutsList[0].
LangID;
1328 NewLayoutsList[0].
LangID = LayoutsList[uOldPos].
LangID;
1353 L".DEFAULT\\Control Panel\\International\\Geo");
1395 WCHAR ValueBuffer[] =
L"?:\\pagefile.sys 0 0\0";
1408 ValueBuffer[0] =
Drive;
1414 (
PVOID)&ValueBuffer,
1415 sizeof(ValueBuffer));
static WCHAR ServiceName[]
HANDLE GetRootKeyByPredefKey(IN HANDLE KeyHandle, OUT PCWSTR *RootKeyMountPoint OPTIONAL)
PGENERIC_LIST CreateKeyboardDriverList(IN HINF InfFile)
BOOLEAN ProcessKeyboardLayoutRegistry(IN PGENERIC_LIST List, IN PCWSTR LanguageId)
PGENERIC_LIST CreateComputerTypeList(IN HINF InfFile)
struct _LANG_ENTRY_PARAM * PLANG_ENTRY_PARAM
ULONG GetDefaultLanguageIndex(VOID)
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)
static BOOLEAN GetDisplayIdentifier(OUT PWSTR Identifier, IN ULONG IdentifierLength)
BOOLEAN SetGeoID(IN PCWSTR Id)
static BOOLEAN IsAcpiComputer(VOID)
BOOLEAN ProcessComputerFiles(IN HINF InfFile, IN PGENERIC_LIST List, OUT PWSTR *AdditionalSectionName)
BOOLEAN ProcessDisplayRegistry(IN HINF InfFile, IN PGENERIC_LIST List)
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 ProcessLocaleRegistry(IN PGENERIC_LIST List)
PGENERIC_LIST CreateLanguageList(IN HINF InfFile, OUT PWSTR DefaultLanguage)
BOOLEAN SetDefaultPagefile(IN WCHAR Drive)
struct _LANG_ENTRY_PARAM LANG_ENTRY_PARAM
static ULONG DefaultLanguageIndex
BOOLEAN ProcessKeyboardLayoutFiles(IN PGENERIC_LIST List)
struct _GENENTRY * PGENENTRY
_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)
const MUI_LAYOUTS * MUIGetLayoutsList(IN PCWSTR LanguageId)
BOOLEAN IsLanguageAvailable(IN PCWSTR LanguageId)
BOOLEAN AddKbLayoutsToRegistry(IN const MUI_LAYOUTS *MuiLayouts)
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)
PGENERIC_LIST_ENTRY GetCurrentListEntry(IN PGENERIC_LIST List)
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
base of all file and directory entries
#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_ 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