MCPcopy Create free account
hub / github.com/bytecode77/r77-rootkit / CreateEntry

Method CreateEntry

TestConsole/Helper/ConfigSystem.cs:128–182  ·  view source on GitHub ↗

Creates an entry in the configuration system. The name of the config directory. The name of the config entry. The value of the entry.

(string directoryName, string entryName, object value)

Source from the content-addressed store, hash-verified

126 /// <param name="entryName">The name of the config entry.</param>
127 /// <param name="value">The value of the entry.</param>
128 public static void CreateEntry(string directoryName, string entryName, object value)
129 {
130 if (!EnsureConfigSystem())
131 {
132 return;
133 }
134
135 using RegistryKey? configKey = GetConfigSystemKey();
136 using RegistryKey? key = configKey?.CreateSubKey(directoryName);
137
138 if (key != null)
139 {
140 switch (Directories[directoryName])
141 {
142 case RegistryValueKind.String:
143 if (value?.ToString() is string stringValue && !stringValue.IsNullOrWhiteSpace())
144 {
145 key.SetStringValue(entryName, stringValue);
146
147 Log.Information(
148 new LogTextItem("Created config system entry"),
149 new LogFileItem($"{directoryName}/{entryName}"),
150 new LogTextItem("="),
151 new LogFileItem($"{stringValue}")
152 );
153 }
154 return;
155 case RegistryValueKind.DWord:
156 if (value?.ToString().ToInt32OrNull() is int intValue)
157 {
158 key.SetInt32Value(entryName, intValue);
159
160 Log.Information(
161 new LogTextItem("Created config system entry"),
162 new LogFileItem($"{directoryName}/{entryName}"),
163 new LogTextItem("="),
164 new LogFileItem($"{intValue}")
165 );
166 }
167 else
168 {
169 Log.Error(
170 new LogTextItem("Failed to create config system entry."),
171 new LogDetailsItem("Value must be an integer.")
172 );
173 }
174 return;
175 }
176 }
177
178 Log.Error(
179 new LogTextItem("Failed to create config system entry"),
180 new LogFileItem($"{directoryName}/{entryName}")
181 );
182 }
183 /// <summary>
184 /// Deletes an entry from the configuration system.
185 /// </summary>

Callers 2

Calls 2

InformationMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected