Harden Dword value including saving the original state.
(rootKey registry.Key, path string, valueName string, hardenedValue uint32)
| 293 | |
| 294 | // Harden Dword value including saving the original state. |
| 295 | func hardenKey(rootKey registry.Key, path string, valueName string, hardenedValue uint32) error { |
| 296 | rootKeyName, _ := getRootKeyName(rootKey) |
| 297 | key, _, err := registry.CreateKey(rootKey, path, registry.WRITE) |
| 298 | if err != nil { |
| 299 | return fmt.Errorf("Couldn't create / open registry key for write access: %s\\%s", |
| 300 | rootKeyName, path) |
| 301 | } |
| 302 | defer key.Close() |
| 303 | |
| 304 | // Save current state. |
| 305 | err = saveOriginalRegistryDWORD(rootKey, path, valueName) |
| 306 | if err != nil { |
| 307 | return err |
| 308 | } |
| 309 | // Harden. |
| 310 | err = key.SetDWordValue(valueName, hardenedValue) |
| 311 | if err != nil { |
| 312 | return fmt.Errorf("Couldn't set registry value: %s \\ %s \\ %s", |
| 313 | rootKeyName, path, valueName) |
| 314 | } |
| 315 | |
| 316 | return nil |
| 317 | } |
| 318 | |
| 319 | // Harden SZ (String) value including saving the original state. |
| 320 | func hardenKeySZ(rootKey registry.Key, path string, valueName string, hardenedValue string) error { |
no test coverage detected