ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

VOID NTAPI INIT_FUNCTION CmGetSystemControlValues ( IN PVOID  SystemHiveData,
IN PCM_SYSTEM_CONTROL_VECTOR  ControlVector 
)

Definition at line 104 of file cmcontrl.c.

Referenced by ExpInitializeExecutive().

{
    PHHIVE SystemHive = (PHHIVE)&CmControlHive;
    NTSTATUS Status;
    HCELL_INDEX RootCell, BaseCell, KeyCell, ValueCell;
    ULONG Length, DataSize;
    PCM_KEY_NODE Node;
    PCM_KEY_VALUE ValueData;
    UNICODE_STRING KeyName;
    BOOLEAN Auto, IsSmallKey;
    PVOID Buffer;

    /* LUDDDIIIICRROOOUUSSSS KI^H^H HACKKKK */
    if (!SystemHiveData) return;

    /* Initialize the Hive View List and the security cache */
    RtlZeroMemory(SystemHive, sizeof(*SystemHive));
    CmpInitHiveViewList((PCMHIVE)SystemHive);
    CmpInitSecurityCache((PCMHIVE)SystemHive);

    /* Initialize the Hive */
    Status = HvInitialize(SystemHive,
                          HINIT_FLAT,
                          HIVE_VOLATILE,
                          HFILE_TYPE_PRIMARY,
                          SystemHiveData,
                          NULL,
                          NULL,
                          NULL,
                          NULL,
                          NULL,
                          NULL,
                          1,
                          NULL);
    if (!NT_SUCCESS(Status)) KeBugCheckEx(BAD_SYSTEM_CONFIG_INFO, 1, 1, 0, 0);

    /* Sanity check, flat hives don't have release routines */
    ASSERT(SystemHive->ReleaseCellRoutine == NULL);

    /* Set the Root Cell */
    RootCell = ((PHBASE_BLOCK)SystemHiveData)->RootCell;

    /* Find the current control set */
    RtlInitUnicodeString(&KeyName, L"current");
    BaseCell = CmpFindControlSet(SystemHive, RootCell, &KeyName, &Auto);
    if (BaseCell == HCELL_NIL) KeBugCheckEx(BAD_SYSTEM_CONFIG_INFO, 1, 2, 0, 0);

    /*  Find the control subkey */
    RtlInitUnicodeString(&KeyName, L"control");
    Node = (PCM_KEY_NODE)HvGetCell(SystemHive, BaseCell);
    BaseCell = CmpFindSubKeyByName(SystemHive, Node, &KeyName);
    if (BaseCell == HCELL_NIL) KeBugCheckEx(BAD_SYSTEM_CONFIG_INFO,1 , 3, 0, 0);

    /* Loop each key */
    while (ControlVector->KeyPath)
    {
        /*  Assume failure */
        Length = -1;

        /* Get the cell for this key */
        KeyCell = CmpWalkPath(SystemHive, BaseCell, ControlVector->KeyPath);
        if (KeyCell != HCELL_NIL)
        {
            /* Now get the cell for the value */
            RtlInitUnicodeString(&KeyName, ControlVector->ValueName);
            Node = (PCM_KEY_NODE)HvGetCell(SystemHive, KeyCell);
            ValueCell = CmpFindValueByName(SystemHive, Node, &KeyName);
            if (ValueCell != HCELL_NIL)
            {
                /* Check if there's any data */
                if (!ControlVector->BufferLength)
                {
                    /* No, the buffer will only be large enough for a ULONG */
                    DataSize = sizeof(ULONG);
                }
                else
                {
                    /* Yes, save the data size */
                    DataSize = *ControlVector->BufferLength;
                }

                /* Get the actual data */
                ValueData = (PCM_KEY_VALUE)HvGetCell(SystemHive, ValueCell);

                /* Check if this is a small key */
                IsSmallKey = CmpIsKeyValueSmall(&Length, ValueData->DataLength);

                /* If the length is bigger then our buffer, normalize it */
                if (DataSize < Length) Length = DataSize;

                /* Make sure we have some data */
                if (Length > 0)
                {
                    /* Check if this was a small key */
                    if (IsSmallKey)
                    {
                        /* The buffer is directly safe to read */
                        Buffer = (PVOID)(&(ValueData->Data));
                    }
                    else
                    {
                        /* Use the longer path */
                        Buffer = (PVOID)HvGetCell(SystemHive, ValueData->Data);
                    }

                    /* Sanity check if this is a small key */
                    ASSERT((IsSmallKey ?
                           (Length <= CM_KEY_VALUE_SMALL) : TRUE));

                    /* Copy the data in the buffer */
                    RtlCopyMemory(ControlVector->Buffer, Buffer, Length);
                }

                /* Check if we should return the data type */
                if (ControlVector->Type)
                {
                    /* Return the type that we read */
                    *ControlVector->Type = ValueData->Type;
                }
            }
        }

        /* Return the size that we read */
        if (ControlVector->BufferLength) *ControlVector->BufferLength = Length;

        /* Go to the next entry */
        ControlVector++;
    }

    /* Check if the ID is in the registry */
    if (CmDefaultLanguageIdType == REG_SZ)
    {
        /* Read it */
        PsDefaultSystemLocaleId =
            (LCID)CmpConvertLangId(CmDefaultLanguageId,
                                   CmDefaultLanguageIdLength);
    }
    else
    {
        /* Use EN_US by default */
        PsDefaultSystemLocaleId = 0x409;
    }

    /* Check if the ID Is in the registry */
    if (CmInstallUILanguageIdType == REG_SZ)
    {
        /* Read it */
        PsInstallUILanguageId =  CmpConvertLangId(CmInstallUILanguageId,
                                                  CmInstallUILanguageIdLength);
    }
    else
    {
        /* Otherwise, use the default */
        PsInstallUILanguageId = LANGIDFROMLCID(PsDefaultSystemLocaleId);
    }

    /* Set the defaults for the Thread UI */
    PsDefaultThreadLocaleId = PsDefaultSystemLocaleId;
    PsDefaultUILanguageId = PsInstallUILanguageId;
}

Generated on Sun May 27 2012 06:06:31 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.