MCPcopy
hub / github.com/hardentools/hardentools / getRootKeyFromName

Function getRootKeyFromName

registry_utils.go:271–292  ·  view source on GitHub ↗

Get root key from name (LOCAL_MACHINE vs. LOCAL_USER).

(rootKeyName string)

Source from the content-addressed store, hash-verified

269
270// Get root key from name (LOCAL_MACHINE vs. LOCAL_USER).
271func getRootKeyFromName(rootKeyName string) (rootKey registry.Key, err error) {
272 switch rootKeyName {
273 case "CLASSES_ROOT":
274 rootKey = registry.CLASSES_ROOT
275 case "CURRENT_USER":
276 rootKey = registry.CURRENT_USER
277 case "LOCAL_MACHINE":
278 rootKey = registry.LOCAL_MACHINE
279 case "USERS":
280 rootKey = registry.USERS
281 case "CURRENT_CONFIG":
282 rootKey = registry.CURRENT_CONFIG
283 case "PERFORMANCE_DATA":
284 rootKey = registry.PERFORMANCE_DATA
285 default:
286 // Invalid rootKeyName?
287 Info.Println("Invalid rootKeyName provided to restore registry function")
288 err = errors.New("Invalid rootKeyName provided to restore registry function")
289 return registry.CURRENT_USER, err
290 }
291 return rootKey, nil
292}
293
294// Harden Dword value including saving the original state.
295func hardenKey(rootKey registry.Key, path string, valueName string, hardenedValue uint32) error {

Callers 1

restoreSavedRegistryKeysFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected