Skip to content

Commit

Permalink
Fix registry permission set
Browse files Browse the repository at this point in the history
  • Loading branch information
nomi-san committed Aug 10, 2023
1 parent 3770692 commit 6e3d4fe
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions loader/Main/IFEO.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Security.AccessControl;
using Microsoft.Win32;

namespace PenguLoader.Main
Expand All @@ -25,10 +26,22 @@ public static bool SetDebugger(string target, string debugger)
{
if (key == null) return false;

using (var image = key.CreateSubKey(target))
using (var image = key.CreateSubKey(target, RegistryKeyPermissionCheck.ReadWriteSubTree))
{
if (image == null) return false;

try
{
var user = Environment.UserDomainName + "\\" + Environment.UserName;
RegistryAccessRule rule = new RegistryAccessRule(user, RegistryRights.FullControl, AccessControlType.Allow);
RegistrySecurity security = new RegistrySecurity();
security.AddAccessRule(rule);
image.SetAccessControl(security);
}
catch
{
}

image.SetValue(VALUE_NAME, debugger, RegistryValueKind.String);
return true;
}
Expand All @@ -49,6 +62,9 @@ public static void RemoveDebugger(string target)
}
}

private static RegistryKey OpenIFEOKey(bool writable = false) => Registry.LocalMachine.OpenSubKey(IFEO_PATH, writable);
static RegistryKey OpenIFEOKey(bool writable = false)
{
return Registry.LocalMachine.OpenSubKey(IFEO_PATH, writable);
}
}
}

0 comments on commit 6e3d4fe

Please sign in to comment.