paavohtl Claude Opus 4.6 commited on
Commit
055dbb3
·
1 Parent(s): ab93fba

feat: add Registry cleanup hooks (DeleteKeyRecursive, CleanAll)

Browse files

DeleteKeyRecursive delegates to openwa-lib's recursive registry helper.
CleanAll deletes all 4 WA registry subsections and clears NetSettings INI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

crates/openwa-wormkit/src/replacements/config.rs CHANGED
@@ -4,8 +4,13 @@
4
  //! - Theme__GetFileSize (0x44BA80): theme file size query
5
  //! - Theme__Load (0x44BB20): theme file read
6
  //! - Theme__Save (0x44BBC0): theme file write
 
 
7
 
8
  use openwa_types::address::va;
 
 
 
9
 
10
  const THEME_PATH: &str = "data\\current.thm";
11
 
@@ -62,6 +67,63 @@ fn show_error_message(msg: &str) {
62
  }
63
  }
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  // ============================================================
66
  // Hook installation
67
  // ============================================================
@@ -85,6 +147,18 @@ pub fn install() -> Result<(), String> {
85
  va::THEME_SAVE,
86
  hook_theme_save as *const (),
87
  )?;
 
 
 
 
 
 
 
 
 
 
 
 
88
  }
89
 
90
  Ok(())
 
4
  //! - Theme__GetFileSize (0x44BA80): theme file size query
5
  //! - Theme__Load (0x44BB20): theme file read
6
  //! - Theme__Save (0x44BBC0): theme file write
7
+ //! - Registry__DeleteKeyRecursive (0x4E4D10): recursive registry deletion
8
+ //! - Registry__CleanAll (0x4C90D0): full registry cleanup
9
 
10
  use openwa_types::address::va;
11
+ use crate::log_line;
12
+ #[allow(unused_imports)]
13
+ use openwa_lib::rebase::rb;
14
 
15
  const THEME_PATH: &str = "data\\current.thm";
16
 
 
67
  }
68
  }
69
 
70
+ // ============================================================
71
+ // Registry__DeleteKeyRecursive replacement (0x4E4D10)
72
+ // ============================================================
73
+
74
+ /// Rust replacement for Registry__DeleteKeyRecursive.
75
+ /// stdcall(hkey: HKEY, subkey: *const u8) -> i32
76
+ unsafe extern "stdcall" fn hook_delete_key_recursive(hkey: u32, subkey: u32) -> i32 {
77
+ use windows_sys::Win32::System::Registry::HKEY;
78
+
79
+ let c_subkey = std::ffi::CStr::from_ptr(subkey as *const i8);
80
+ let subkey_str = c_subkey.to_string_lossy();
81
+
82
+ let _ = log_line(&format!("[Config] DeleteKeyRecursive: {subkey_str}"));
83
+
84
+ let result = openwa_lib::wa::registry::delete_key_recursive(
85
+ hkey as usize as HKEY,
86
+ &subkey_str,
87
+ );
88
+
89
+ let _ = log_line(&format!("[Config] DeleteKeyRecursive result: {result}"));
90
+ result as i32
91
+ }
92
+
93
+ // ============================================================
94
+ // Registry__CleanAll replacement (0x4C90D0)
95
+ // ============================================================
96
+
97
+ /// Rust replacement for Registry__CleanAll.
98
+ /// stdcall(struct_ptr: u32)
99
+ unsafe extern "stdcall" fn hook_registry_clean_all(struct_ptr: u32) {
100
+ use windows_sys::Win32::System::Registry::HKEY_CURRENT_USER;
101
+
102
+ let _ = log_line("[Config] CleanAll: deleting registry sections");
103
+
104
+ let sections = [
105
+ "Software\\Team17SoftwareLTD\\WormsArmageddon\\Data",
106
+ "Software\\Team17SoftwareLTD\\WormsArmageddon\\Options",
107
+ "Software\\Team17SoftwareLTD\\WormsArmageddon\\ExportVideo",
108
+ "Software\\Team17SoftwareLTD\\WormsArmageddon\\VSyncAssist",
109
+ ];
110
+
111
+ for section in &sections {
112
+ openwa_lib::wa::registry::delete_key_recursive(HKEY_CURRENT_USER, section);
113
+ }
114
+
115
+ // Clear the NetSettings INI section
116
+ extern "system" {
117
+ fn WriteProfileSectionA(app_name: *const u8, string: *const u8) -> i32;
118
+ }
119
+ WriteProfileSectionA(b"NetSettings\0".as_ptr(), b"\0".as_ptr());
120
+
121
+ // Set struct_ptr + 0xE0 = 0
122
+ *((struct_ptr + 0xE0) as *mut u8) = 0;
123
+
124
+ let _ = log_line("[Config] CleanAll completed");
125
+ }
126
+
127
  // ============================================================
128
  // Hook installation
129
  // ============================================================
 
147
  va::THEME_SAVE,
148
  hook_theme_save as *const (),
149
  )?;
150
+
151
+ let _ = crate::hook::install(
152
+ "Registry__DeleteKeyRecursive",
153
+ va::REGISTRY_DELETE_KEY_RECURSIVE,
154
+ hook_delete_key_recursive as *const (),
155
+ )?;
156
+
157
+ let _ = crate::hook::install(
158
+ "Registry__CleanAll",
159
+ va::REGISTRY_CLEAN_ALL,
160
+ hook_registry_clean_all as *const (),
161
+ )?;
162
  }
163
 
164
  Ok(())