|
8 | 8 | import os |
9 | 9 | import re |
10 | 10 | import subprocess |
11 | | -from ctypes import byref, sizeof |
| 11 | +from ctypes import byref, sizeof, c_void_p |
12 | 12 | from random import randint |
13 | 13 | from uuid import uuid4 |
14 | 14 | from winreg import ( |
@@ -257,8 +257,28 @@ def add_persistent_route(self, gateway: str): |
257 | 257 | self.run_as_system(["C:\\Windows\\System32\\ROUTE.exe", "-p", "change", "0.0.0.0", "mask", "0.0.0.0", gateway]) |
258 | 258 |
|
259 | 259 | def launch_background_processes(self): |
260 | | - notepad_path = os.path.join(os.environ["SystemRoot"], "System32", "notepad.exe") |
261 | | - self._launch_background_process(notepad_path) |
| 260 | + try: |
| 261 | + total_processes = int(self.options.get("background_processes", 1)) |
| 262 | + except (TypeError, ValueError): |
| 263 | + total_processes = 1 |
| 264 | + total_processes = max(0, min(total_processes, 10)) |
| 265 | + |
| 266 | + if total_processes > 0: |
| 267 | + if sizeof(c_void_p) == 4: |
| 268 | + system32 = os.path.join(os.environ["SystemRoot"], "Sysnative") |
| 269 | + else: |
| 270 | + system32 = os.path.join(os.environ["SystemRoot"], "System32") |
| 271 | + notepad_path = os.path.join(system32, "notepad.exe") |
| 272 | + calc_path = os.path.join(system32, "calc.exe") |
| 273 | + process_pool = [notepad_path, calc_path] |
| 274 | + |
| 275 | + # Always launch notepad first. |
| 276 | + self._launch_background_process(notepad_path) |
| 277 | + |
| 278 | + for _ in range(total_processes - 1): |
| 279 | + selected_process = process_pool[randint(0, len(process_pool) - 1)] |
| 280 | + self._launch_background_process(selected_process) |
| 281 | + # self.log_notepad_process_tree() |
262 | 282 |
|
263 | 283 | def _launch_background_process(self, process_path): |
264 | 284 | try: |
@@ -324,30 +344,11 @@ def log_notepad_process_tree(self): |
324 | 344 | log.error("Failed to collect notepad process info: %s", e.output) |
325 | 345 |
|
326 | 346 | def start(self): |
327 | | - try: |
328 | | - total_processes = int(self.options.get("background_processes", 1)) |
329 | | - except (TypeError, ValueError): |
330 | | - total_processes = 1 |
331 | | - total_processes = max(0, min(total_processes, 10)) |
332 | | - |
333 | | - if total_processes > 0: |
334 | | - system32 = os.path.join(os.environ["SystemRoot"], "System32") |
335 | | - notepad_path = os.path.join(system32, "notepad.exe") |
336 | | - calc_path = os.path.join(system32, "calc.exe") |
337 | | - process_pool = [notepad_path, calc_path] |
338 | | - |
339 | | - # Always launch notepad first. |
340 | | - self._launch_background_process(notepad_path) |
341 | | - |
342 | | - for _ in range(total_processes - 1): |
343 | | - selected_process = process_pool[randint(0, len(process_pool) - 1)] |
344 | | - self._launch_background_process(selected_process) |
345 | | - # self.log_notepad_process_tree() |
346 | | - |
347 | 347 | if self.config.windows_static_route: |
348 | 348 | log.info("Config for route is: %s", str(self.config.windows_static_route)) |
349 | 349 | self.add_persistent_route(self.config.windows_static_route_gateway) |
350 | 350 |
|
| 351 | + self.launch_background_processes() |
351 | 352 | self.change_productid() |
352 | 353 | self.set_office_mrus() |
353 | 354 | self.ramnit() |
|
0 commit comments