ReactOS  0.4.15-dev-4572-gde972e2
settings.c File Reference
#include "precomp.h"
#include "genlist.h"
#include "infsupp.h"
#include "mui.h"
#include "registry.h"
#include "settings.h"
#include <debug.h>
Include dependency graph for settings.c:

Go to the source code of this file.

Classes

struct  _LANG_ENTRY_PARAM
 

Macros

#define NDEBUG
 

Typedefs

typedef UCHAR(NTAPIPPROCESS_ENTRY_ROUTINE) (IN PCWSTR KeyName, IN PCWSTR KeyValue, OUT PVOID *UserData, OUT PBOOLEAN Current, IN PVOID Parameter OPTIONAL)
 
typedef struct _LANG_ENTRY_PARAM LANG_ENTRY_PARAM
 
typedef struct _LANG_ENTRY_PARAMPLANG_ENTRY_PARAM
 

Functions

static BOOLEAN IsAcpiComputer (VOID)
 
static BOOLEAN GetComputerIdentifier (OUT PWSTR Identifier, IN ULONG IdentifierLength)
 
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)
 
static UCHAR NTAPI DefaultProcessEntry (IN PCWSTR KeyName, IN PCWSTR KeyValue, OUT PVOID *UserData, OUT PBOOLEAN Current, IN PVOID Parameter OPTIONAL)
 
BOOLEAN AddComputerTypeEntries (_In_ HINF InfFile, PGENERIC_LIST List, _In_ PWSTR SectionName)
 
PGENERIC_LIST CreateComputerTypeList (IN HINF InfFile)
 
static BOOLEAN GetDisplayIdentifier (OUT PWSTR Identifier, IN ULONG IdentifierLength)
 
PGENERIC_LIST CreateDisplayDriverList (IN HINF InfFile)
 
BOOLEAN ProcessComputerFiles (IN HINF InfFile, IN PGENERIC_LIST List, OUT PWSTR *AdditionalSectionName)
 
BOOLEAN ProcessDisplayRegistry (IN HINF InfFile, IN PGENERIC_LIST List)
 
BOOLEAN ProcessLocaleRegistry (IN PGENERIC_LIST List)
 
PGENERIC_LIST CreateKeyboardDriverList (IN HINF InfFile)
 
ULONG GetDefaultLanguageIndex (VOID)
 
static UCHAR NTAPI ProcessLangEntry (IN PCWSTR KeyName, IN PCWSTR KeyValue, OUT PVOID *UserData, OUT PBOOLEAN Current, IN PVOID Parameter OPTIONAL)
 
PGENERIC_LIST CreateLanguageList (IN HINF InfFile, OUT PWSTR DefaultLanguage)
 
PGENERIC_LIST CreateKeyboardLayoutList (IN HINF InfFile, IN PCWSTR LanguageId, OUT PWSTR DefaultKBLayout)
 
BOOLEAN ProcessKeyboardLayoutRegistry (IN PGENERIC_LIST List, IN PCWSTR LanguageId)
 
BOOLEAN SetGeoID (IN PCWSTR Id)
 
BOOLEAN SetDefaultPagefile (IN WCHAR Drive)
 

Variables

static ULONG DefaultLanguageIndex = 0
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 36 of file settings.c.

Typedef Documentation

◆ LANG_ENTRY_PARAM

◆ PLANG_ENTRY_PARAM

◆ PPROCESS_ENTRY_ROUTINE

typedef UCHAR(NTAPI * PPROCESS_ENTRY_ROUTINE) (IN PCWSTR KeyName, IN PCWSTR KeyValue, OUT PVOID *UserData, OUT PBOOLEAN Current, IN PVOID Parameter OPTIONAL)

Definition at line 328 of file settings.c.

Function Documentation

◆ AddComputerTypeEntries()

BOOLEAN AddComputerTypeEntries ( _In_ HINF  InfFile,
PGENERIC_LIST  List,
_In_ PWSTR  SectionName 
)

Definition at line 442 of file settings.c.

446 {
448  PCWSTR KeyName;
449  PCWSTR KeyValue;
450  WCHAR ComputerIdentifier[128];
451  WCHAR ComputerKey[32];
452  ULONG Count1, Count2;
453 
454  /* Get the computer identification */
455  if (!GetComputerIdentifier(ComputerIdentifier, 128))
456  {
457  ComputerIdentifier[0] = 0;
458  }
459 
460  DPRINT("Computer identifier: '%S'\n", ComputerIdentifier);
461 
462  /* Search for matching device identifier */
463  if (!SpInfFindFirstLine(InfFile, SectionName, NULL, &Context))
464  {
465  /* FIXME: error message */
466  return FALSE;
467  }
468 
469  do
470  {
471  BOOLEAN FoundId;
472 
473  if (!INF_GetDataField(&Context, 1, &KeyValue))
474  {
475  /* FIXME: Handle error! */
476  DPRINT("INF_GetDataField() failed\n");
477  return FALSE;
478  }
479 
480  DPRINT("KeyValue: %S\n", KeyValue);
481  FoundId = !!wcsstr(ComputerIdentifier, KeyValue);
482  INF_FreeData(KeyValue);
483 
484  if (!FoundId)
485  continue;
486 
487  if (!INF_GetDataField(&Context, 0, &KeyName))
488  {
489  /* FIXME: Handle error! */
490  DPRINT("INF_GetDataField() failed\n");
491  return FALSE;
492  }
493 
494  DPRINT("Computer key: %S\n", KeyName);
495  RtlStringCchCopyW(ComputerKey, ARRAYSIZE(ComputerKey), KeyName);
497  } while (SpInfFindNextLine(&Context, &Context));
498 
500  InfFile,
501  L"Computer",
502  &Context,
504  ComputerKey);
506  InfFile,
507  L"Computer.NT" INF_ARCH,
508  &Context,
510  ComputerKey);
511  if ((Count1 == -1) && (Count2 == -1))
512  {
513  return FALSE;
514  }
515 
516  return TRUE;
517 }
const uint16_t * PCWSTR
Definition: typedefs.h:57
static UCHAR NTAPI DefaultProcessEntry(IN PCWSTR KeyName, IN PCWSTR KeyValue, OUT PVOID *UserData, OUT PBOOLEAN Current, IN PVOID Parameter OPTIONAL)
Definition: settings.c:404
#define TRUE
Definition: types.h:120
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
pSpInfFindFirstLine SpInfFindFirstLine
Definition: infsupp.c:87
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
BOOLEAN INF_GetDataField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PCWSTR *Data)
Definition: infsupp.c:42
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
__wchar_t WCHAR
Definition: xmlstorage.h:180
FORCEINLINE VOID INF_FreeData(IN PCWSTR InfData)
Definition: infsupp.h:157
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)
Definition: settings.c:336
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
static BOOLEAN GetComputerIdentifier(OUT PWSTR Identifier, IN ULONG IdentifierLength)
Definition: settings.c:213
NTSTRSAFEAPI RtlStringCchCopyW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:127
pSpInfFindNextLine SpInfFindNextLine
Definition: infsupp.c:88
#define NULL
Definition: types.h:112
struct tagContext Context
Definition: acpixf.h:1034
unsigned int ULONG
Definition: retypes.h:1
#define DPRINT
Definition: sndvol32.h:71

Referenced by CreateComputerTypeList().

◆ AddEntriesFromInfSection()

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 
)
static

Definition at line 336 of file settings.c.

343 {
344  LONG TotalCount = 0;
345  PCWSTR KeyName;
346  PCWSTR KeyValue;
347  PVOID UserData;
348  BOOLEAN Current;
349  UCHAR RetVal;
350 
351  if (!SpInfFindFirstLine(InfFile, SectionName, NULL, pContext))
352  return -1;
353 
354  do
355  {
356  /*
357  * NOTE: Do not use INF_GetData() as it expects INF entries of exactly
358  * two fields ("key = value"); however we expect to be able to deal with
359  * entries having more than two fields, the only requirement being that
360  * the second field (field number 1) contains the field description.
361  */
362  if (!INF_GetDataField(pContext, 0, &KeyName))
363  {
364  DPRINT("INF_GetDataField() failed\n");
365  return -1;
366  }
367 
368  if (!INF_GetDataField(pContext, 1, &KeyValue))
369  {
370  DPRINT("INF_GetDataField() failed\n");
372  return -1;
373  }
374 
375  UserData = NULL;
376  Current = FALSE;
377  RetVal = ProcessEntry(KeyName,
378  KeyValue,
379  &UserData,
380  &Current,
381  Parameter);
383  INF_FreeData(KeyValue);
384 
385  if (RetVal == 0)
386  {
387  DPRINT("ProcessEntry() failed\n");
388  return -1;
389  }
390  else if (RetVal == 1)
391  {
393  ++TotalCount;
394  }
395  // else if (RetVal == 2), skip the entry.
396 
397  } while (SpInfFindNextLine(pContext, pContext));
398 
399  return TotalCount;
400 }
const uint16_t * PCWSTR
Definition: typedefs.h:57
pSpInfFindFirstLine SpInfFindFirstLine
Definition: infsupp.c:87
_In_ PVOID Parameter
Definition: ldrtypes.h:241
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
unsigned char BOOLEAN
BOOLEAN INF_GetDataField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PCWSTR *Data)
Definition: infsupp.c:42
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
struct tagUserData UserData
FORCEINLINE VOID INF_FreeData(IN PCWSTR InfData)
Definition: infsupp.h:157
BOOLEAN AppendGenericListEntry(IN OUT PGENERIC_LIST List, IN PVOID Data, IN BOOLEAN Current)
Definition: genlist.c:62
unsigned char UCHAR
Definition: xmlstorage.h:181
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
pSpInfFindNextLine SpInfFindNextLine
Definition: infsupp.c:88
#define NULL
Definition: types.h:112
#define DPRINT
Definition: sndvol32.h:71

Referenced by AddComputerTypeEntries(), CreateDisplayDriverList(), CreateKeyboardDriverList(), CreateKeyboardLayoutList(), and CreateLanguageList().

◆ CreateComputerTypeList()

PGENERIC_LIST CreateComputerTypeList ( IN HINF  InfFile)

Definition at line 520 of file settings.c.

522 {
525 
527  if (List == NULL)
528  return NULL;
529 
530  Success = AddComputerTypeEntries(InfFile, List, L"Map.Computer");
531  Success |= AddComputerTypeEntries(InfFile, List, L"Map.Computer.NT" INF_ARCH);
532  if (!Success)
533  {
535  return NULL;
536  }
537 
538  return List;
539 }
VOID DestroyGenericList(IN OUT PGENERIC_LIST List, IN BOOLEAN FreeData)
Definition: genlist.c:36
#define TRUE
Definition: types.h:120
#define L(x)
Definition: ntvdm.h:50
BOOLEAN AddComputerTypeEntries(_In_ HINF InfFile, PGENERIC_LIST List, _In_ PWSTR SectionName)
Definition: settings.c:442
unsigned char BOOLEAN
PGENERIC_LIST CreateGenericList(VOID)
Definition: genlist.c:20
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define NULL
Definition: types.h:112

Referenced by DeviceSettingsPage(), LoadSetupData(), and SetupStartPage().

◆ CreateDisplayDriverList()

PGENERIC_LIST CreateDisplayDriverList ( IN HINF  InfFile)

Definition at line 704 of file settings.c.

706 {
709  PCWSTR KeyName;
710  PCWSTR KeyValue;
711  WCHAR DisplayIdentifier[128];
712  WCHAR DisplayKey[32];
713 
714  /* Get the display identification */
715  if (!GetDisplayIdentifier(DisplayIdentifier, 128))
716  {
717  DisplayIdentifier[0] = 0;
718  }
719 
720  DPRINT("Display identifier: '%S'\n", DisplayIdentifier);
721 
722  /* Search for matching device identifier */
723  if (!SpInfFindFirstLine(InfFile, L"Map.Display", NULL, &Context))
724  {
725  /* FIXME: error message */
726  return NULL;
727  }
728 
729  do
730  {
731  BOOLEAN FoundId;
732 
733  if (!INF_GetDataField(&Context, 1, &KeyValue))
734  {
735  /* FIXME: Handle error! */
736  DPRINT("INF_GetDataField() failed\n");
737  return NULL;
738  }
739 
740  DPRINT("KeyValue: %S\n", KeyValue);
741  FoundId = !!wcsstr(DisplayIdentifier, KeyValue);
742  INF_FreeData(KeyValue);
743 
744  if (!FoundId)
745  continue;
746 
747  if (!INF_GetDataField(&Context, 0, &KeyName))
748  {
749  /* FIXME: Handle error! */
750  DPRINT("INF_GetDataField() failed\n");
751  return NULL;
752  }
753 
754  DPRINT("Display key: %S\n", KeyName);
755  RtlStringCchCopyW(DisplayKey, ARRAYSIZE(DisplayKey), KeyName);
757  } while (SpInfFindNextLine(&Context, &Context));
758 
760  if (List == NULL)
761  return NULL;
762 
764  InfFile,
765  L"Display",
766  &Context,
768  DisplayKey) == -1)
769  {
771  return NULL;
772  }
773 
774 #if 0
775  AppendGenericListEntry(List, L"Other display driver", NULL, TRUE);
776 #endif
777 
778  return List;
779 }
const uint16_t * PCWSTR
Definition: typedefs.h:57
static UCHAR NTAPI DefaultProcessEntry(IN PCWSTR KeyName, IN PCWSTR KeyValue, OUT PVOID *UserData, OUT PBOOLEAN Current, IN PVOID Parameter OPTIONAL)
Definition: settings.c:404
VOID DestroyGenericList(IN OUT PGENERIC_LIST List, IN BOOLEAN FreeData)
Definition: genlist.c:36
#define TRUE
Definition: types.h:120
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
pSpInfFindFirstLine SpInfFindFirstLine
Definition: infsupp.c:87
#define L(x)
Definition: ntvdm.h:50
unsigned char BOOLEAN
BOOLEAN INF_GetDataField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PCWSTR *Data)
Definition: infsupp.c:42
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
PGENERIC_LIST CreateGenericList(VOID)
Definition: genlist.c:20
static BOOLEAN GetDisplayIdentifier(OUT PWSTR Identifier, IN ULONG IdentifierLength)
Definition: settings.c:543
__wchar_t WCHAR
Definition: xmlstorage.h:180
FORCEINLINE VOID INF_FreeData(IN PCWSTR InfData)
Definition: infsupp.h:157
BOOLEAN AppendGenericListEntry(IN OUT PGENERIC_LIST List, IN PVOID Data, IN BOOLEAN Current)
Definition: genlist.c:62
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)
Definition: settings.c:336
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
NTSTRSAFEAPI RtlStringCchCopyW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:127
pSpInfFindNextLine SpInfFindNextLine
Definition: infsupp.c:88
#define NULL
Definition: types.h:112
struct tagContext Context
Definition: acpixf.h:1034
#define DPRINT
Definition: sndvol32.h:71

Referenced by DeviceSettingsPage(), LoadSetupData(), and SetupStartPage().

◆ CreateKeyboardDriverList()

PGENERIC_LIST CreateKeyboardDriverList ( IN HINF  InfFile)

Definition at line 1089 of file settings.c.

1091 {
1094 
1095  List = CreateGenericList();
1096  if (List == NULL)
1097  return NULL;
1098 
1100  InfFile,
1101  L"Keyboard",
1102  &Context,
1104  NULL) == -1)
1105  {
1107  return NULL;
1108  }
1109 
1110  return List;
1111 }
static UCHAR NTAPI DefaultProcessEntry(IN PCWSTR KeyName, IN PCWSTR KeyValue, OUT PVOID *UserData, OUT PBOOLEAN Current, IN PVOID Parameter OPTIONAL)
Definition: settings.c:404
VOID DestroyGenericList(IN OUT PGENERIC_LIST List, IN BOOLEAN FreeData)
Definition: genlist.c:36
#define TRUE
Definition: types.h:120
#define L(x)
Definition: ntvdm.h:50
PGENERIC_LIST CreateGenericList(VOID)
Definition: genlist.c:20
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)
Definition: settings.c:336
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define NULL
Definition: types.h:112
struct tagContext Context
Definition: acpixf.h:1034

Referenced by DeviceSettingsPage(), LoadSetupData(), and SetupStartPage().

◆ CreateKeyboardLayoutList()

PGENERIC_LIST CreateKeyboardLayoutList ( IN HINF  InfFile,
IN PCWSTR  LanguageId,
OUT PWSTR  DefaultKBLayout 
)

Definition at line 1226 of file settings.c.

1230 {
1233  PCWSTR KeyValue;
1234  const MUI_LAYOUTS* LayoutsList;
1235  ULONG uIndex = 0;
1236 
1237  /* Get default layout id */
1238  if (!SpInfFindFirstLine(InfFile, L"NLS", L"DefaultLayout", &Context))
1239  return NULL;
1240 
1241  if (!INF_GetData(&Context, NULL, &KeyValue))
1242  return NULL;
1243 
1244  wcscpy(DefaultKBLayout, KeyValue);
1245 
1246  List = CreateGenericList();
1247  if (List == NULL)
1248  return NULL;
1249 
1250  LayoutsList = MUIGetLayoutsList(LanguageId);
1251 
1252  do
1253  {
1254  // NOTE: See https://svn.reactos.org/svn/reactos?view=revision&revision=68354
1256  InfFile,
1257  L"KeyboardLayout",
1258  &Context,
1260  DefaultKBLayout) == -1)
1261  {
1263  return NULL;
1264  }
1265 
1266  uIndex++;
1267 
1268  } while (LayoutsList[uIndex].LangID != NULL);
1269 
1270  /* Check whether some keyboard layouts have been found */
1271  /* FIXME: Handle this case */
1272  if (GetNumberOfListEntries(List) == 0)
1273  {
1274  DPRINT1("No keyboard layouts have been found\n");
1276  return NULL;
1277  }
1278 
1279  return List;
1280 }
const uint16_t * PCWSTR
Definition: typedefs.h:57
ULONG GetNumberOfListEntries(IN PGENERIC_LIST List)
Definition: genlist.c:140
static UCHAR NTAPI DefaultProcessEntry(IN PCWSTR KeyName, IN PCWSTR KeyValue, OUT PVOID *UserData, OUT PBOOLEAN Current, IN PVOID Parameter OPTIONAL)
Definition: settings.c:404
VOID DestroyGenericList(IN OUT PGENERIC_LIST List, IN BOOLEAN FreeData)
Definition: genlist.c:36
#define TRUE
Definition: types.h:120
pSpInfFindFirstLine SpInfFindFirstLine
Definition: infsupp.c:87
#define L(x)
Definition: ntvdm.h:50
const MUI_LAYOUTS * MUIGetLayoutsList(IN PCWSTR LanguageId)
Definition: mui.c:112
PGENERIC_LIST CreateGenericList(VOID)
Definition: genlist.c:20
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
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)
Definition: settings.c:336
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
BOOLEAN INF_GetData(IN PINFCONTEXT Context, OUT PCWSTR *Key, OUT PCWSTR *Data)
Definition: infsupp.c:90
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
struct tagContext Context
Definition: acpixf.h:1034
unsigned int ULONG
Definition: retypes.h:1
Definition: mui.h:9
_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
Definition: wdfusb.h:1075
static WCHAR DefaultKBLayout[20]
Definition: usetup.c:68

Referenced by DeviceSettingsPage(), LoadSetupData(), SetupStartPage(), and UpdateKBLayout().

◆ CreateLanguageList()

PGENERIC_LIST CreateLanguageList ( IN HINF  InfFile,
OUT PWSTR  DefaultLanguage 
)

Definition at line 1176 of file settings.c.

1179 {
1182  PCWSTR KeyValue;
1183 
1184  LANG_ENTRY_PARAM LangEntryParam;
1185 
1186  LangEntryParam.uIndex = 0;
1187  LangEntryParam.DefaultLanguage = DefaultLanguage;
1188 
1189  /* Get default language id */
1190  if (!SpInfFindFirstLine(InfFile, L"NLS", L"DefaultLanguage", &Context))
1191  return NULL;
1192 
1193  if (!INF_GetData(&Context, NULL, &KeyValue))
1194  return NULL;
1195 
1196  wcscpy(DefaultLanguage, KeyValue);
1197 
1198  List = CreateGenericList();
1199  if (List == NULL)
1200  return NULL;
1201 
1203  InfFile,
1204  L"Language",
1205  &Context,
1207  &LangEntryParam) == -1)
1208  {
1210  return NULL;
1211  }
1212 
1213  /* Only one language available, make it the default one */
1214  if (LangEntryParam.uIndex == 1)
1215  {
1219  }
1220 
1221  return List;
1222 }
const uint16_t * PCWSTR
Definition: typedefs.h:57
Definition: settings.c:1120
PGENERIC_LIST_ENTRY GetFirstListEntry(IN PGENERIC_LIST List)
Definition: genlist.c:104
VOID DestroyGenericList(IN OUT PGENERIC_LIST List, IN BOOLEAN FreeData)
Definition: genlist.c:36
#define TRUE
Definition: types.h:120
pSpInfFindFirstLine SpInfFindFirstLine
Definition: infsupp.c:87
DWORD Id
ULONG uIndex
Definition: settings.c:1122
#define L(x)
Definition: ntvdm.h:50
PVOID GetListEntryData(IN PGENERIC_LIST_ENTRY Entry)
Definition: genlist.c:126
static UCHAR NTAPI ProcessLangEntry(IN PCWSTR KeyName, IN PCWSTR KeyValue, OUT PVOID *UserData, OUT PBOOLEAN Current, IN PVOID Parameter OPTIONAL)
Definition: settings.c:1128
static ULONG DefaultLanguageIndex
Definition: settings.c:41
PGENERIC_LIST CreateGenericList(VOID)
Definition: genlist.c:20
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
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)
Definition: settings.c:336
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
BOOLEAN INF_GetData(IN PINFCONTEXT Context, OUT PCWSTR *Key, OUT PCWSTR *Data)
Definition: infsupp.c:90
#define NULL
Definition: types.h:112
static WCHAR DefaultLanguage[20]
Definition: usetup.c:67
struct tagContext Context
Definition: acpixf.h:1034
PWCHAR DefaultLanguage
Definition: settings.c:1123

Referenced by LanguagePage(), LoadSetupData(), and SetupStartPage().

◆ DefaultProcessEntry()

static UCHAR NTAPI DefaultProcessEntry ( IN PCWSTR  KeyName,
IN PCWSTR  KeyValue,
OUT PVOID UserData,
OUT PBOOLEAN  Current,
IN PVOID Parameter  OPTIONAL 
)
static

Definition at line 404 of file settings.c.

410 {
411  PWSTR CompareKey = (PWSTR)Parameter;
412 
413  PGENENTRY GenEntry;
414  SIZE_T IdSize, ValueSize;
415 
416  IdSize = (wcslen(KeyName) + 1) * sizeof(WCHAR);
417  ValueSize = (wcslen(KeyValue) + 1) * sizeof(WCHAR);
418 
419  GenEntry = RtlAllocateHeap(ProcessHeap, 0,
420  sizeof(*GenEntry) + IdSize + ValueSize);
421  if (GenEntry == NULL)
422  {
423  /* Failure, stop enumeration */
424  DPRINT1("RtlAllocateHeap() failed\n");
425  return 0;
426  }
427 
428  GenEntry->Id = (PCWSTR)((ULONG_PTR)GenEntry + sizeof(*GenEntry));
429  GenEntry->Value = (PCWSTR)((ULONG_PTR)GenEntry + sizeof(*GenEntry) + IdSize);
430  RtlStringCbCopyW((PWSTR)GenEntry->Id, IdSize, KeyName);
431  RtlStringCbCopyW((PWSTR)GenEntry->Value, ValueSize, KeyValue);
432 
433  *UserData = GenEntry;
434  *Current = (CompareKey ? !_wcsicmp(KeyName, CompareKey) : FALSE);
435 
436  /* Add the entry */
437  return 1;
438 }
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
const uint16_t * PCWSTR
Definition: typedefs.h:57
uint16_t * PWSTR
Definition: typedefs.h:56
PCWSTR Value
Definition: settings.h:33
_In_ PVOID Parameter
Definition: ldrtypes.h:241
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define FALSE
Definition: types.h:117
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
__wchar_t WCHAR
Definition: xmlstorage.h:180
HANDLE ProcessHeap
Definition: servman.c:15
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define NULL
Definition: types.h:112
PCWSTR Id
Definition: settings.h:32
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define DPRINT1
Definition: precomp.h:8
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by AddComputerTypeEntries(), CreateDisplayDriverList(), CreateKeyboardDriverList(), and CreateKeyboardLayoutList().

◆ GetComputerIdentifier()

static BOOLEAN GetComputerIdentifier ( OUT PWSTR  Identifier,
IN ULONG  IdentifierLength 
)
static

Definition at line 213 of file settings.c.

216 {
219  LPCWSTR ComputerIdentifier;
220  HANDLE ProcessorsKey;
221  PKEY_FULL_INFORMATION pFullInfo;
222  ULONG Size, SizeNeeded;
224 
225  DPRINT("GetComputerIdentifier() called\n");
226 
227  Size = sizeof(KEY_FULL_INFORMATION);
228  pFullInfo = (PKEY_FULL_INFORMATION)RtlAllocateHeap(RtlGetProcessHeap(), 0, Size);
229  if (!pFullInfo)
230  {
231  DPRINT("RtlAllocateHeap() failed\n");
232  return FALSE;
233  }
234 
235  /* Open the processors key */
237  L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor");
239  &KeyName,
241  NULL,
242  NULL);
243 
244  Status = NtOpenKey(&ProcessorsKey,
247  if (!NT_SUCCESS(Status))
248  {
249  DPRINT("NtOpenKey() failed (Status 0x%lx)\n", Status);
250  RtlFreeHeap(RtlGetProcessHeap(), 0, pFullInfo);
251  return FALSE;
252  }
253 
254  /* Get number of subkeys */
255  Status = NtQueryKey(ProcessorsKey,
257  pFullInfo,
258  Size,
259  &Size);
260  NtClose(ProcessorsKey);
262  {
263  DPRINT("NtQueryKey() failed (Status 0x%lx)\n", Status);
264  RtlFreeHeap(RtlGetProcessHeap(), 0, pFullInfo);
265  return FALSE;
266  }
267 
268  /* Find computer identifier */
269  if (pFullInfo->SubKeys == 0)
270  {
271  /* Something strange happened. No processor detected */
272  RtlFreeHeap(RtlGetProcessHeap(), 0, pFullInfo);
273  return FALSE;
274  }
275 
276 #ifdef _M_AMD64
277  /* On x64 we are l33t and use the MP config by default */
278  ComputerIdentifier = L"X64 MP";
279 #else
280  if (IsAcpiComputer())
281  {
282  if (pFullInfo->SubKeys == 1)
283  {
284  /* Computer is mono-CPU */
285  ComputerIdentifier = L"ACPI UP";
286  }
287  else
288  {
289  /* Computer is multi-CPUs */
290  ComputerIdentifier = L"ACPI MP";
291  }
292  }
293  else
294  {
295  if (pFullInfo->SubKeys == 1)
296  {
297  /* Computer is mono-CPU */
298  ComputerIdentifier = L"PC UP";
299  }
300  else
301  {
302  /* Computer is multi-CPUs */
303  ComputerIdentifier = L"PC MP";
304  }
305  }
306 #endif
307 
308  RtlFreeHeap(RtlGetProcessHeap(), 0, pFullInfo);
309 
310  /* Copy computer identifier to return buffer */
311  SizeNeeded = (wcslen(ComputerIdentifier) + 1) * sizeof(WCHAR);
312  if (SizeNeeded > IdentifierLength)
313  return FALSE;
314 
315  RtlCopyMemory(Identifier, ComputerIdentifier, SizeNeeded);
316 
317  return TRUE;
318 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
NTSTATUS NTAPI NtQueryKey(IN HANDLE KeyHandle, IN KEY_INFORMATION_CLASS KeyInformationClass, OUT PVOID KeyInformation, IN ULONG Length, OUT PULONG ResultLength)
Definition: ntapi.c:632
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
static BOOLEAN IsAcpiComputer(VOID)
Definition: settings.c:47
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _KEY_FULL_INFORMATION KEY_FULL_INFORMATION
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3401
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
struct _KEY_FULL_INFORMATION * PKEY_FULL_INFORMATION
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define DPRINT
Definition: sndvol32.h:71

Referenced by AddComputerTypeEntries().

◆ GetDefaultLanguageIndex()

ULONG GetDefaultLanguageIndex ( VOID  )

Definition at line 1115 of file settings.c.

1116 {
1117  return DefaultLanguageIndex;
1118 }
static ULONG DefaultLanguageIndex
Definition: settings.c:41

Referenced by LanguagePage().

◆ GetDisplayIdentifier()

static BOOLEAN GetDisplayIdentifier ( OUT PWSTR  Identifier,
IN ULONG  IdentifierLength 
)
static

Definition at line 543 of file settings.c.

546 {
549  WCHAR Buffer[32];
550  HANDLE BusKey;
551  HANDLE BusInstanceKey;
552  HANDLE ControllerKey;
553  HANDLE ControllerInstanceKey;
554  ULONG BusInstance;
555  ULONG ControllerInstance;
560 
561  DPRINT("GetDisplayIdentifier() called\n");
562 
563  /* Open the bus key */
565  L"\\Registry\\Machine\\HARDWARE\\Description\\System\\MultifunctionAdapter");
567  &KeyName,
569  NULL,
570  NULL);
571 
572  Status = NtOpenKey(&BusKey,
575  if (!NT_SUCCESS(Status))
576  {
577  DPRINT("NtOpenKey() failed (Status %lx)\n", Status);
578  return FALSE;
579  }
580 
581  BusInstance = 0;
582  while (TRUE)
583  {
584  RtlStringCchPrintfW(Buffer, ARRAYSIZE(Buffer), L"%lu", BusInstance);
587  &KeyName,
589  BusKey,
590  NULL);
591 
592  Status = NtOpenKey(&BusInstanceKey,
595  if (!NT_SUCCESS(Status))
596  {
597  DPRINT("NtOpenKey() failed (Status %lx)\n", Status);
598  NtClose(BusKey);
599  return FALSE;
600  }
601 
602  /* Open the controller type key */
603  RtlInitUnicodeString(&KeyName, L"DisplayController");
605  &KeyName,
607  BusInstanceKey,
608  NULL);
609 
610  Status = NtOpenKey(&ControllerKey,
613  if (NT_SUCCESS(Status))
614  {
615  ControllerInstance = 0;
616 
617  while (TRUE)
618  {
619  /* Open the pointer controller instance key */
620  RtlStringCchPrintfW(Buffer, ARRAYSIZE(Buffer), L"%lu", ControllerInstance);
623  &KeyName,
625  ControllerKey,
626  NULL);
627 
628  Status = NtOpenKey(&ControllerInstanceKey,
631  if (!NT_SUCCESS(Status))
632  {
633  DPRINT("NtOpenKey() failed (Status %lx)\n", Status);
634  NtClose(ControllerKey);
635  NtClose(BusInstanceKey);
636  NtClose(BusKey);
637  return FALSE;
638  }
639 
640  /* Get controller identifier */
641  RtlInitUnicodeString(&KeyName, L"Identifier");
642 
644  256 * sizeof(WCHAR);
645  ValueInfo = (KEY_VALUE_PARTIAL_INFORMATION*) RtlAllocateHeap(RtlGetProcessHeap(),
646  0,
647  BufferLength);
648  if (ValueInfo == NULL)
649  {
650  DPRINT("RtlAllocateHeap() failed\n");
651  NtClose(ControllerInstanceKey);
652  NtClose(ControllerKey);
653  NtClose(BusInstanceKey);
654  NtClose(BusKey);
655  return FALSE;
656  }
657 
658  Status = NtQueryValueKey(ControllerInstanceKey,
659  &KeyName,
661  ValueInfo,
662  BufferLength,
663  &ReturnedLength);
664  if (NT_SUCCESS(Status))
665  {
666  DPRINT("Identifier: %S\n", (PWSTR)ValueInfo->Data);
667 
668  BufferLength = min(ValueInfo->DataLength / sizeof(WCHAR), IdentifierLength);
669  RtlCopyMemory(Identifier,
670  ValueInfo->Data,
671  BufferLength * sizeof(WCHAR));
672  Identifier[BufferLength] = 0;
673 
674  RtlFreeHeap(RtlGetProcessHeap(),
675  0,
676  ValueInfo);
677 
678  NtClose(ControllerInstanceKey);
679  NtClose(ControllerKey);
680  NtClose(BusInstanceKey);
681  NtClose(BusKey);
682  return TRUE;
683  }
684 
685  NtClose(ControllerInstanceKey);
686 
687  ControllerInstance++;
688  }
689 
690  NtClose(ControllerKey);
691  }
692 
693  NtClose(BusInstanceKey);
694 
695  BusInstance++;
696  }
697 
698  NtClose(BusKey);
699 
700  return FALSE;
701 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1110
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
Definition: bufpool.h:45
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
Status
Definition: gdiplustypes.h:24
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)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3401
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG _In_ ULONG _Out_ PULONG ReturnedLength
Definition: batclass.h:187
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define DPRINT
Definition: sndvol32.h:71
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019

Referenced by CreateDisplayDriverList().

◆ IsAcpiComputer()

static BOOLEAN IsAcpiComputer ( VOID  )
static

Definition at line 47 of file settings.c.

48 {
49  UNICODE_STRING MultiKeyPathU = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System\\MultifunctionAdapter");
50  UNICODE_STRING IdentifierU = RTL_CONSTANT_STRING(L"Identifier");
51  UNICODE_STRING AcpiBiosIdentifier = RTL_CONSTANT_STRING(L"ACPI BIOS");
53  PKEY_BASIC_INFORMATION pDeviceInformation = NULL;
54  ULONG DeviceInfoLength = sizeof(KEY_BASIC_INFORMATION) + 50 * sizeof(WCHAR);
55  PKEY_VALUE_PARTIAL_INFORMATION pValueInformation = NULL;
56  ULONG ValueInfoLength = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 50 * sizeof(WCHAR);
58  ULONG IndexDevice = 0;
60  HANDLE hDevicesKey = NULL;
61  HANDLE hDeviceKey = NULL;
63  BOOLEAN ret = FALSE;
64 
66  &MultiKeyPathU,
68  NULL,
69  NULL);
70  Status = NtOpenKey(&hDevicesKey,
73  if (!NT_SUCCESS(Status))
74  {
75  DPRINT("NtOpenKey() failed with status 0x%08lx\n", Status);
76  goto cleanup;
77  }
78 
79  pDeviceInformation = RtlAllocateHeap(RtlGetProcessHeap(), 0, DeviceInfoLength);
80  if (!pDeviceInformation)
81  {
82  DPRINT("RtlAllocateHeap() failed\n");
84  goto cleanup;
85  }
86 
87  pValueInformation = RtlAllocateHeap(RtlGetProcessHeap(), 0, ValueInfoLength);
88  if (!pValueInformation)
89  {
90  DPRINT("RtlAllocateHeap() failed\n");
92  goto cleanup;
93  }
94 
95  while (TRUE)
96  {
97  Status = NtEnumerateKey(hDevicesKey,
98  IndexDevice,
100  pDeviceInformation,
101  DeviceInfoLength,
102  &RequiredSize);
104  break;
106  {
107  RtlFreeHeap(RtlGetProcessHeap(), 0, pDeviceInformation);
108  DeviceInfoLength = RequiredSize;
109  pDeviceInformation = RtlAllocateHeap(RtlGetProcessHeap(), 0, DeviceInfoLength);
110  if (!pDeviceInformation)
111  {
112  DPRINT("RtlAllocateHeap() failed\n");
114  goto cleanup;
115  }
116  Status = NtEnumerateKey(hDevicesKey,
117  IndexDevice,
119  pDeviceInformation,
120  DeviceInfoLength,
121  &RequiredSize);
122  }
123  if (!NT_SUCCESS(Status))
124  {
125  DPRINT("NtEnumerateKey() failed with status 0x%08lx\n", Status);
126  goto cleanup;
127  }
128  IndexDevice++;
129 
130  /* Open device key */
131  DeviceName.Length = DeviceName.MaximumLength = pDeviceInformation->NameLength;
132  DeviceName.Buffer = pDeviceInformation->Name;
134  &DeviceName,
136  hDevicesKey,
137  NULL);
138  Status = NtOpenKey(&hDeviceKey,
141  if (!NT_SUCCESS(Status))
142  {
143  DPRINT("NtOpenKey() failed with status 0x%08lx\n", Status);
144  goto cleanup;
145  }
146 
147  /* Read identifier */
148  Status = NtQueryValueKey(hDeviceKey,
149  &IdentifierU,
151  pValueInformation,
152  ValueInfoLength,
153  &RequiredSize);
155  {
156  RtlFreeHeap(RtlGetProcessHeap(), 0, pValueInformation);
157  ValueInfoLength = RequiredSize;
158  pValueInformation = RtlAllocateHeap(RtlGetProcessHeap(), 0, ValueInfoLength);
159  if (!pValueInformation)
160  {
161  DPRINT("RtlAllocateHeap() failed\n");
163  goto cleanup;
164  }
165  Status = NtQueryValueKey(hDeviceKey,
166  &IdentifierU,
168  pValueInformation,
169  ValueInfoLength,
170  &RequiredSize);
171  }
172  if (!NT_SUCCESS(Status))
173  {
174  DPRINT("NtQueryValueKey() failed with status 0x%08lx\n", Status);
175  goto nextdevice;
176  }
177  else if (pValueInformation->Type != REG_SZ)
178  {
179  DPRINT("Wrong registry type: got 0x%lx, expected 0x%lx\n", pValueInformation->Type, REG_SZ);
180  goto nextdevice;
181  }
182 
183  ValueName.Length = ValueName.MaximumLength = pValueInformation->DataLength;
184  ValueName.Buffer = (PWCHAR)pValueInformation->Data;
185  if (ValueName.Length >= sizeof(WCHAR) && ValueName.Buffer[ValueName.Length / sizeof(WCHAR) - 1] == UNICODE_NULL)
186  ValueName.Length -= sizeof(WCHAR);
187  if (RtlEqualUnicodeString(&ValueName, &AcpiBiosIdentifier, FALSE))
188  {
189  DPRINT("Found ACPI BIOS\n");
190  ret = TRUE;
191  goto cleanup;
192  }
193 
194 nextdevice:
195  NtClose(hDeviceKey);
196  hDeviceKey = NULL;
197  }
198 
199 cleanup:
200  if (pDeviceInformation)
201  RtlFreeHeap(RtlGetProcessHeap(), 0, pDeviceInformation);
202  if (pValueInformation)
203  RtlFreeHeap(RtlGetProcessHeap(), 0, pValueInformation);
204  if (hDevicesKey)
205  NtClose(hDevicesKey);
206  if (hDeviceKey)
207  NtClose(hDeviceKey);
208  return ret;
209 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:205
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
struct _KEY_BASIC_INFORMATION KEY_BASIC_INFORMATION
uint16_t * PWCHAR
Definition: typedefs.h:56
if(dx==0 &&dy==0)
Definition: linetemp.h:174
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 STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define L(x)
Definition: ntvdm.h:50
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3272
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
unsigned char BOOLEAN
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
Status
Definition: gdiplustypes.h:24
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)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3401
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:240
int ret
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
unsigned int ULONG
Definition: retypes.h:1
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
char * cleanup(char *str)
Definition: wpickclick.c:99
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431
#define DPRINT
Definition: sndvol32.h:71
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define REG_SZ
Definition: layer.c:22

Referenced by GetComputerIdentifier().

◆ ProcessComputerFiles()

BOOLEAN ProcessComputerFiles ( IN HINF  InfFile,
IN PGENERIC_LIST  List,
OUT PWSTR AdditionalSectionName 
)

Definition at line 783 of file settings.c.

787 {
789  static WCHAR SectionName[128];
790 
791  DPRINT("ProcessComputerFiles() called\n");
792 
794  if (Entry == NULL)
795  return FALSE;
796 
797  RtlStringCchPrintfW(SectionName, ARRAYSIZE(SectionName),
798  L"Files.%s", ((PGENENTRY)GetListEntryData(Entry))->Id);
799  *AdditionalSectionName = SectionName;
800 
801  return TRUE;
802 }
Definition: genlist.h:10
struct _Entry Entry
Definition: kefuncs.h:629
#define TRUE
Definition: types.h:120
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1110
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
DWORD Id
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
PVOID GetListEntryData(IN PGENERIC_LIST_ENTRY Entry)
Definition: genlist.c:126
__wchar_t WCHAR
Definition: xmlstorage.h:180
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define NULL
Definition: types.h:112
#define DPRINT
Definition: sndvol32.h:71
base of all file and directory entries
Definition: entries.h:82
PGENERIC_LIST_ENTRY GetCurrentListEntry(IN PGENERIC_LIST List)
Definition: genlist.c:97

Referenced by PrepareCopyInfFile().

◆ ProcessDisplayRegistry()

BOOLEAN ProcessDisplayRegistry ( IN HINF  InfFile,
IN PGENERIC_LIST  List 
)

Definition at line 805 of file settings.c.

808 {
812  PCWSTR Buffer;
814  ULONG StartValue;
815  ULONG Width, Height, Bpp;
819  WCHAR RegPath[255];
820 
821  DPRINT("ProcessDisplayRegistry() called\n");
822 
824  if (Entry == NULL)
825  return FALSE;
826 
827  if (!SpInfFindFirstLine(InfFile, L"Display",
829  &Context))
830  {
831  DPRINT1("SpInfFindFirstLine() failed\n");
832  return FALSE;
833  }
834 
835  /* Enable the correct driver */
837  {
838  DPRINT1("INF_GetDataField() failed\n");
839  return FALSE;
840  }
841 
842  ASSERT(wcslen(ServiceName) < 10);
843  DPRINT("Service name: '%S'\n", ServiceName);
844 
845  RtlStringCchPrintfW(RegPath, ARRAYSIZE(RegPath),
846  L"System\\CurrentControlSet\\Services\\%s",
847  ServiceName);
848  RtlInitUnicodeString(&KeyName, RegPath);
850  &KeyName,
853  NULL);
857  if (!NT_SUCCESS(Status))
858  {
859  DPRINT1("NtOpenKey() failed (Status %lx)\n", Status);
860  return FALSE;
861  }
862 
863  StartValue = 1;
865  L"Start",
866  REG_DWORD,
867  &StartValue,
868  sizeof(StartValue));
870  if (!NT_SUCCESS(Status))
871  {
872  DPRINT1("RtlWriteRegistryValue() failed (Status %lx)\n", Status);
873  return FALSE;
874  }
875 
876  /* Set the resolution */
877 
878  if (!INF_GetDataField(&Context, 4, &Buffer))
879  {
880  DPRINT1("INF_GetDataField() failed\n");
881  return FALSE;
882  }
883 
884  RtlStringCchPrintfW(RegPath, ARRAYSIZE(RegPath),
885  L"System\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\%s\\Device0",
886  ServiceName);
887  DPRINT("RegPath: '%S'\n", RegPath);
888  RtlInitUnicodeString(&KeyName, RegPath);
890  &KeyName,
893  NULL);
898  {
899  /* Try without Hardware Profile part */
900  RtlStringCchPrintfW(RegPath, ARRAYSIZE(RegPath),
901  L"System\\CurrentControlSet\\Services\\%s\\Device0",
902  ServiceName);
903  RtlInitUnicodeString(&KeyName, RegPath);
907  }
908  if (!NT_SUCCESS(Status))
909  {
910  DPRINT1("NtOpenKey() failed (Status %lx)\n", Status);
911  return FALSE;
912  }
913 
914  Width = wcstoul(Buffer, NULL, 10);
916  L"DefaultSettings.XResolution",
917  REG_DWORD,
918  &Width,
919  sizeof(Width));
920  if (!NT_SUCCESS(Status))
921  {
922  DPRINT1("RtlWriteRegistryValue() failed (Status %lx)\n", Status);
924  return FALSE;
925  }
926 
927  if (!INF_GetDataField(&Context, 5, &Buffer))
928  {
929  DPRINT1("INF_GetDataField() failed\n");
931  return FALSE;
932  }
933 
934  Height = wcstoul(Buffer, 0, 0);
936  L"DefaultSettings.YResolution",
937  REG_DWORD,
938  &Height,
939  sizeof(Height));
940  if (!NT_SUCCESS(Status))
941  {
942  DPRINT1("RtlWriteRegistryValue() failed (Status %lx)\n", Status);
944  return FALSE;
945  }
946 
947  if (!INF_GetDataField(&Context, 6, &Buffer))
948  {
949  DPRINT1("INF_GetDataField() failed\n");
951  return FALSE;
952  }
953 
954  Bpp = wcstoul(Buffer, 0, 0);
956  L"DefaultSettings.BitsPerPel",
957  REG_DWORD,
958  &Bpp,
959  sizeof(Bpp));
960  if (!NT_SUCCESS(Status))
961  {
962  DPRINT1("RtlWriteRegistryValue() failed (Status %lx)\n", Status);
964  return FALSE;
965  }
966 
968 
969  DPRINT("ProcessDisplayRegistry() done\n");
970 
971  return TRUE;
972 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
const uint16_t * PCWSTR
Definition: typedefs.h:57
Definition: genlist.h:10
struct _Entry Entry
Definition: kefuncs.h:629
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define TRUE
Definition: types.h:120
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:124
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1110
LONG NTSTATUS
Definition: precomp.h:26
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
pSpInfFindFirstLine SpInfFindFirstLine
Definition: infsupp.c:87
_In_ HFONT _Out_ PUINT Height
Definition: font.h:124
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
DWORD Id
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
NTSYSAPI NTSTATUS WINAPI RtlWriteRegistryValue(ULONG, PCWSTR, PCWSTR, ULONG, PVOID, ULONG)
PVOID GetListEntryData(IN PGENERIC_LIST_ENTRY Entry)
Definition: genlist.c:126
BOOLEAN INF_GetDataField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PCWSTR *Data)
Definition: infsupp.c:42
Definition: bufpool.h:45
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
Status
Definition: gdiplustypes.h:24
LPTSTR ServiceName
Definition: ServiceMain.c:15
#define ASSERT(a)
Definition: mode.c:44
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3401
#define RTL_REGISTRY_HANDLE
Definition: nt_native.h:168
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
HANDLE GetRootKeyByPredefKey(IN HANDLE KeyHandle, OUT PCWSTR *RootKeyMountPoint OPTIONAL)
Definition: registry.c:90
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define DPRINT1
Definition: precomp.h:8
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
struct tagContext Context
Definition: acpixf.h:1034
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define DPRINT
Definition: sndvol32.h:71
#define REG_DWORD
Definition: sdbapi.c:596
base of all file and directory entries
Definition: entries.h:82
PGENERIC_LIST_ENTRY GetCurrentListEntry(IN PGENERIC_LIST List)
Definition: genlist.c:97
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by UpdateRegistry().

◆ ProcessKeyboardLayoutRegistry()

BOOLEAN ProcessKeyboardLayoutRegistry ( IN PGENERIC_LIST  List,
IN PCWSTR  LanguageId 
)

Definition at line 1284 of file settings.c.

1287 {
1289  PCWSTR LayoutId;
1290  const MUI_LAYOUTS* LayoutsList;
1291  MUI_LAYOUTS NewLayoutsList[20];
1292  ULONG uIndex;
1293  ULONG uOldPos = 0;
1294 
1296  if (Entry == NULL)
1297  return FALSE;
1298 
1299  LayoutId = ((PGENENTRY)GetListEntryData(Entry))->Id;
1300  if (LayoutId == NULL)
1301  return FALSE;
1302 
1303  LayoutsList = MUIGetLayoutsList(LanguageId);
1304 
1305  if (_wcsicmp(LayoutsList[0].LayoutID, LayoutId) == 0)
1306  return TRUE;
1307 
1308  for (uIndex = 1; LayoutsList[uIndex].LangID != NULL; uIndex++)
1309  {
1310  if (_wcsicmp(LayoutsList[uIndex].LayoutID, LayoutId) == 0)
1311  {
1312  uOldPos = uIndex;
1313  continue;
1314  }
1315 
1316  NewLayoutsList[uIndex].LangID = LayoutsList[uIndex].LangID;
1317  NewLayoutsList[uIndex].LayoutID = LayoutsList[uIndex].LayoutID;
1318  }
1319 
1320  NewLayoutsList[uIndex].LangID = NULL;
1321  NewLayoutsList[uIndex].LayoutID = NULL;
1322  NewLayoutsList[uOldPos].LangID = LayoutsList[0].LangID;
1323  NewLayoutsList[uOldPos].LayoutID = LayoutsList[0].LayoutID;
1324  NewLayoutsList[0].LangID = LayoutsList[uOldPos].LangID;
1325  NewLayoutsList[0].LayoutID = LayoutsList[uOldPos].LayoutID;
1326 
1327  return AddKbLayoutsToRegistry(NewLayoutsList);
1328 }
const uint16_t * PCWSTR
Definition: typedefs.h:57
Definition: genlist.h:10
struct _Entry Entry
Definition: kefuncs.h:629
#define TRUE
Definition: types.h:120
PCWSTR LangID
Definition: mui.h:11
DWORD Id
#define FALSE
Definition: types.h:117
PVOID GetListEntryData(IN PGENERIC_LIST_ENTRY Entry)
Definition: genlist.c:126
const MUI_LAYOUTS * MUIGetLayoutsList(IN PCWSTR LanguageId)
Definition: mui.c:112
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define NULL
Definition: types.h:112
struct _GENENTRY * PGENENTRY
BOOLEAN AddKbLayoutsToRegistry(IN const MUI_LAYOUTS *MuiLayouts)
Definition: mui.c:208
unsigned int ULONG
Definition: retypes.h:1
PCWSTR LayoutID
Definition: mui.h:12
Definition: mui.h:9
base of all file and directory entries
Definition: entries.h:82
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
PGENERIC_LIST_ENTRY GetCurrentListEntry(IN PGENERIC_LIST List)
Definition: genlist.c:97

Referenced by UpdateRegistry().

◆ ProcessLangEntry()

static UCHAR NTAPI ProcessLangEntry ( IN PCWSTR  KeyName,
IN PCWSTR  KeyValue,
OUT PVOID UserData,
OUT PBOOLEAN  Current,
IN PVOID Parameter  OPTIONAL 
)
static

Definition at line 1128 of file settings.c.

1134 {
1135  PLANG_ENTRY_PARAM LangEntryParam = (PLANG_ENTRY_PARAM)Parameter;
1136 
1137  PGENENTRY GenEntry;
1138  SIZE_T IdSize, ValueSize;
1139 
1141  {
1142  /* The specified language is unavailable, skip the entry */
1143  return 2;
1144  }
1145 
1146  IdSize = (wcslen(KeyName) + 1) * sizeof(WCHAR);
1147  ValueSize = (wcslen(KeyValue) + 1) * sizeof(WCHAR);
1148 
1149  GenEntry = RtlAllocateHeap(ProcessHeap, 0,
1150  sizeof(*GenEntry) + IdSize + ValueSize);
1151  if (GenEntry == NULL)
1152  {
1153  /* Failure, stop enumeration */
1154  DPRINT1("RtlAllocateHeap() failed\n");
1155  return 0;
1156  }
1157 
1158  GenEntry->Id = (PCWSTR)((ULONG_PTR)GenEntry + sizeof(*GenEntry));
1159  GenEntry->Value = (PCWSTR)((ULONG_PTR)GenEntry + sizeof(*GenEntry) + IdSize);
1160  RtlStringCbCopyW((PWSTR)GenEntry->Id, IdSize, KeyName);
1161  RtlStringCbCopyW((PWSTR)GenEntry->Value, ValueSize, KeyValue);
1162 
1163  *UserData = GenEntry;
1164  *Current = FALSE;
1165 
1166  if (!_wcsicmp(KeyName, LangEntryParam->DefaultLanguage))
1167  DefaultLanguageIndex = LangEntryParam->uIndex;
1168 
1169  LangEntryParam->uIndex++;
1170 
1171  /* Add the entry */
1172  return 1;
1173 }
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
const uint16_t * PCWSTR
Definition: typedefs.h:57
Definition: settings.c:1120
uint16_t * PWSTR
Definition: typedefs.h:56
PCWSTR Value
Definition: settings.h:33
_In_ PVOID Parameter
Definition: ldrtypes.h:241
uint32_t ULONG_PTR
Definition: typedefs.h:65
ULONG uIndex
Definition: settings.c:1122
#define FALSE
Definition: types.h:117
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
static ULONG DefaultLanguageIndex
Definition: settings.c:41
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
__wchar_t WCHAR
Definition: xmlstorage.h:180
HANDLE ProcessHeap
Definition: servman.c:15
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define NULL
Definition: types.h:112
BOOLEAN IsLanguageAvailable(IN PCWSTR LanguageId)
Definition: mui.c:70
PCWSTR Id
Definition: settings.h:32
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define DPRINT1
Definition: precomp.h:8
PWCHAR DefaultLanguage
Definition: settings.c:1123
struct _LANG_ENTRY_PARAM * PLANG_ENTRY_PARAM
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by CreateLanguageList().

◆ ProcessLocaleRegistry()

BOOLEAN ProcessLocaleRegistry ( IN PGENERIC_LIST  List)

Definition at line 975 of file settings.c.

977 {
979  PCWSTR LanguageId;
983 
986 
988  if (Entry == NULL)
989  return FALSE;
990 
991  LanguageId = ((PGENENTRY)GetListEntryData(Entry))->Id;
992  if (LanguageId == NULL)
993  return FALSE;
994 
995  DPRINT("LanguageId: %S\n", LanguageId);
996 
997  /* Open the default users locale key */
999  L".DEFAULT\\Control Panel\\International");
1000 
1002  &KeyName,
1005  NULL);
1006 
1008  KEY_SET_VALUE,
1009  &ObjectAttributes);
1010  if (!NT_SUCCESS(Status))
1011  {
1012  DPRINT1("NtOpenKey() failed (Status %lx)\n", Status);
1013  return FALSE;
1014  }
1015 
1016  /* Set default user locale */
1017  RtlInitUnicodeString(&ValueName, L"Locale");
1019  &ValueName,
1020  0,
1021  REG_SZ,
1022  (PVOID)LanguageId,
1023  (wcslen(LanguageId) + 1) * sizeof(WCHAR));
1024  NtClose(KeyHandle);
1025  if (!NT_SUCCESS(Status))
1026  {
1027  DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
1028  return FALSE;
1029  }
1030 
1031  /* Skip first 4 zeroes */
1032  if (wcslen(LanguageId) >= 4)
1033  LanguageId += 4;
1034 
1035  /* Open the NLS language key */
1037  L"SYSTEM\\CurrentControlSet\\Control\\NLS\\Language");
1038 
1040  &KeyName,
1043  NULL);
1044 
1046  KEY_SET_VALUE,
1047  &ObjectAttributes);
1048  if (!NT_SUCCESS(Status))
1049  {
1050  DPRINT1("NtOpenKey() failed (Status %lx)\n", Status);
1051  return FALSE;
1052  }
1053 
1054  /* Set default language */
1055  RtlInitUnicodeString(&ValueName, L"Default");
1057  &ValueName,
1058  0,
1059  REG_SZ,
1060  (PVOID)LanguageId,
1061  (wcslen(LanguageId) + 1) * sizeof(WCHAR));
1062  if (!NT_SUCCESS(Status))
1063  {
1064  DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
1065  NtClose(KeyHandle);
1066  return FALSE;
1067  }
1068 
1069  /* Set install language */
1070  RtlInitUnicodeString(&ValueName, L"InstallLanguage");
1072  &ValueName,
1073  0,
1074  REG_SZ,
1075  (PVOID)LanguageId,
1076  (wcslen(LanguageId) + 1) * sizeof(WCHAR));
1077  NtClose(KeyHandle);
1078  if (!NT_SUCCESS(Status))
1079  {
1080  DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
1081  return FALSE;
1082  }
1083 
1084  return TRUE;
1085 }
#define HKEY_USERS
Definition: winreg.h:13
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
const uint16_t * PCWSTR
Definition: typedefs.h:57
Definition: genlist.h:10
struct _Entry Entry
Definition: kefuncs.h:629
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
DWORD Id
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
PVOID GetListEntryData(IN PGENERIC_LIST_ENTRY Entry)
Definition: genlist.c:126
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3401
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:240
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
HANDLE GetRootKeyByPredefKey(IN HANDLE KeyHandle, OUT PCWSTR *RootKeyMountPoint OPTIONAL)
Definition: registry.c:90
#define NULL
Definition: types.h:112
NTSYSAPI NTSTATUS NTAPI NtSetValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN ULONG TitleIndex OPTIONAL, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
Definition: ntapi.c:859
struct _GENENTRY * PGENENTRY
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define DPRINT1
Definition: precomp.h:8
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define DPRINT
Definition: sndvol32.h:71
base of all file and directory entries
Definition: entries.h:82
PGENERIC_LIST_ENTRY GetCurrentListEntry(IN PGENERIC_LIST List)
Definition: genlist.c:97
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

Referenced by UpdateRegistry().

◆ SetDefaultPagefile()

BOOLEAN SetDefaultPagefile ( IN WCHAR  Drive)

Definition at line 1383 of file settings.c.

1385 {
1386  NTSTATUS Status;
1387  HANDLE KeyHandle;
1389  UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management");
1391  WCHAR ValueBuffer[] = L"?:\\pagefile.sys 0 0\0";
1392 
1394  &KeyName,
1397  NULL);
1400  &ObjectAttributes);
1401  if (!NT_SUCCESS(Status))
1402  return FALSE;
1403 
1404  ValueBuffer[0] = Drive;
1405 
1407  &ValueName,
1408  0,
1409  REG_MULTI_SZ,
1410  (PVOID)&ValueBuffer,
1411  sizeof(ValueBuffer));
1412 
1413  NtClose(KeyHandle);
1414  return TRUE;
1415 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
#define REG_MULTI_SZ
Definition: nt_native.h:1501
PWCHAR Drive
Definition: chkdsk.c:73
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3401
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:240
HANDLE GetRootKeyByPredefKey(IN HANDLE KeyHandle, OUT PCWSTR *RootKeyMountPoint OPTIONAL)
Definition: registry.c:90
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define NULL
Definition: types.h:112
NTSYSAPI NTSTATUS NTAPI NtSetValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN ULONG TitleIndex OPTIONAL, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
Definition: ntapi.c:859
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by UpdateRegistry().

◆ SetGeoID()

BOOLEAN SetGeoID ( IN PCWSTR  Id)

Definition at line 1340 of file settings.c.

1342 {
1343  NTSTATUS Status;
1346  HANDLE KeyHandle;
1347 
1349  L".DEFAULT\\Control Panel\\International\\Geo");
1351  &Name,
1354  NULL);
1356  KEY_SET_VALUE,
1357  &ObjectAttributes);
1358  if (!NT_SUCCESS(Status))
1359  {
1360  DPRINT1("NtOpenKey() failed (Status %lx)\n", Status);
1361  return FALSE;
1362  }
1363 
1364  RtlInitUnicodeString(&Name, L"Nation");
1366  &Name,
1367  0,
1368  REG_SZ,
1369  (PVOID)Id,
1370  (wcslen(Id) + 1) * sizeof(WCHAR));
1371  NtClose(KeyHandle);
1372  if (!NT_SUCCESS(Status))
1373  {
1374  DPRINT1("NtSetValueKey() failed (Status = %lx)\n", Status);
1375  return FALSE;
1376  }
1377 
1378  return TRUE;
1379 }
#define HKEY_USERS
Definition: winreg.h:13
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
DWORD Id
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
struct NameRec_ * Name
Definition: cdprocs.h:459
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3401
HANDLE GetRootKeyByPredefKey(IN HANDLE KeyHandle, OUT PCWSTR *RootKeyMountPoint OPTIONAL)
Definition: registry.c:90
#define NULL
Definition: types.h:112
NTSYSAPI NTSTATUS NTAPI NtSetValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN ULONG TitleIndex OPTIONAL, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
Definition: ntapi.c:859
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define DPRINT1
Definition: precomp.h:8
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define REG_SZ
Definition: layer.c:22

Referenced by UpdateRegistry().

Variable Documentation

◆ DefaultLanguageIndex

ULONG DefaultLanguageIndex = 0
static

Definition at line 41 of file settings.c.

Referenced by CreateLanguageList(), GetDefaultLanguageIndex(), and ProcessLangEntry().