MCPcopy Create free account
hub / github.com/PenguLoader/PenguLoader / IFEO

Class IFEO

loader/Main/IFEO.cs:8–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6namespace PenguLoader.Main
7{
8 internal static class IFEO
9 {
10 private static string IFEO_PATH => @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options";
11 private static string VALUE_NAME => "Debugger";
12
13 public static string GetDebugger(string target)
14 {
15 using (var key = Registry.LocalMachine.OpenSubKey(IFEO_PATH))
16 {
17 if (key == null)
18 return string.Empty;
19
20 using (var image = key.OpenSubKey(target))
21 {
22 if (image == null)
23 return string.Empty;
24
25 return image.GetValue(VALUE_NAME) as string;
26 }
27 }
28 }
29
30 public static void SetDebugger(string t, string d)
31 {
32 d = d.Replace("\"", "\\\"");
33 Invoke($"reg add \"HKLM\\{IFEO_PATH}\\{t}\" /v \"{VALUE_NAME}\" /t REG_SZ /d \"{d}\" /f");
34 }
35
36 public static void RemoveDebugger(string t)
37 {
38 Invoke($"reg delete \"HKLM\\{IFEO_PATH}\\{t}\" /f");
39 }
40
41 public static void Invoke(string args)
42 {
43 using (var process = new Process
44 {
45 StartInfo = new ProcessStartInfo
46 {
47 FileName = "cmd.exe",
48 Arguments = $"/C {args}",
49 RedirectStandardOutput = true,
50 RedirectStandardError = true,
51 UseShellExecute = false,
52 CreateNoWindow = true
53 }
54 })
55 {
56 process.Start();
57 process.WaitForExit();
58 var error = process.StandardError.ReadToEnd();
59
60 if (process.ExitCode != 0 || !string.IsNullOrEmpty(error))
61 {
62 throw new InvalidOperationException(error);
63 }
64 }
65 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected