Get root key from name (LOCAL_MACHINE vs. LOCAL_USER).
(rootKeyName string)
| 269 | |
| 270 | // Get root key from name (LOCAL_MACHINE vs. LOCAL_USER). |
| 271 | func 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. |
| 295 | func hardenKey(rootKey registry.Key, path string, valueName string, hardenedValue uint32) error { |
no outgoing calls
no test coverage detected