Пример #1
0
        private void populateRegistrykey(caCommandMessages.RegKey respKey, RegistryKey sysKey)
        {
            // First, populate the values for this key
            populateRegKeyValues(respKey, sysKey);

            // Second, recursively populate sub-keys for this key
            String[] subKeyNames = sysKey.GetSubKeyNames();

            if (subKeyNames.Length > 0)
            {
                RegKey[] childKeys = new RegKey[subKeyNames.Length];

                for (int i = 0; i < subKeyNames.Length; i++)
                {
                    RegistryKey subKey = sysKey.OpenSubKey(subKeyNames[i], false);

                    // Allocate a new RegKey to hold the subkey
                    childKeys[i] = new RegKey();

                    // Populate the subkey
                    populateRegistrykey(childKeys[i], subKey);
                }

                respKey.subKeys = childKeys;
            }
        }
Пример #2
0
        private void populateRegKeyValues(caCommandMessages.RegKey respKey, RegistryKey sysKey)
        {
            String[] valNames = sysKey.GetValueNames();

            if (valNames.Length > 0)
            {
                RegValue[] values = new RegValue[valNames.Length];

                for (int i = 0; i < valNames.Length; i++)
                {
                    RegistryValueKind valKind = sysKey.GetValueKind(valNames[i]);

                    RegValue val = null;

                    switch (valKind)
                    {
                    case RegistryValueKind.String:
                        val = new RegStringValue(valNames[i], (String)sysKey.GetValue(valNames[i]));
                        break;

                    case RegistryValueKind.Binary:
                        val = new RegBinaryValue(valNames[i], (byte[])sysKey.GetValue(valNames[i]));
                        break;

                    case RegistryValueKind.DWord:
                        val = new RegDWORDValue(valNames[i], (int)sysKey.GetValue(valNames[i]));
                        break;

                    case RegistryValueKind.ExpandString:
                        val = new RegExpandStringValue(valNames[i],
                                                       (String)sysKey.GetValue(valNames[i], null, RegistryValueOptions.DoNotExpandEnvironmentNames),
                                                       (String)sysKey.GetValue(valNames[i]));
                        break;

                    case RegistryValueKind.MultiString:
                        val = new RegMultiStringValue(valNames[i], (String[])sysKey.GetValue(valNames[i]));
                        break;

                    case RegistryValueKind.QWord:
                        val = new RegQWORDValue(valNames[i], (long)sysKey.GetValue(valNames[i]));
                        break;

                    case RegistryValueKind.Unknown:
                        val = null;     // Can't handle Unknown Type
                        break;

                    case RegistryValueKind.None:
                        val = null;     // Can't handle None Type
                        break;
                    }
                    // Save the value
                    values[i] = (RegValue)val;
                }

                respKey.values = values;
            }
        }
 public GetRegistryKeyResponseMessage(ulong ulReqID) : base(ulReqID)
 {
     requestType = "GetRegistryKeyResponseMessage";
     regKey      = new RegKey();
 }