private void btnFixReg_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtChangeKey.Text))
{
MessageBox.Show("Please enter a key!", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
if (txtChangeKey.Text.Length < 44 || txtChangeKey.Text.Length > 44)
{
MessageBox.Show("Invalid key format entered!", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
if (txtChangeKey.Tex*****ntains(" "))
{
MessageBox.Show("Your entered key contains spaces!", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
string enteredkey = txtChangeKey.Text;
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Bohemia Interactive Studio\ArmA 2 OA", true);
if (key == null)
{
MessageBox.Show("ArmA 2 Operation Arrowhead is not installed!", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
RegistryKey key7 = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Bohemia Interactive Studio\ArmA 2 OA", true);
RegistrySecurity userSecurity = new RegistrySecurity();
RegistryAccessRule userRule = new RegistryAccessRule("Everyone", RegistryRights.FullControl, AccessControlType.Allow);
userSecurity.AddAccessRule(userRule);
byte[] buffer2 = new byte[15];
string[] strArray2 = enteredkey.Split(new char[] { '-' });
int upperBound = strArray2.GetUpperBound(0);
byte[] buffer3 = new byte[upperBound + 1];
int num3 = upperBound;
for (int i = 0; i <= num3; i++)
{
buffer3[i] = Convert.ToByte(strArray2[i], 0x10);
}
buffer2 = buffer3;
key.SetValue("KEY", buffer2);
RegistryKey key2 = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Bohemia Interactive Studio\ArmA 2 OA", true);
byte[] objectValue = (byte[])RuntimeHelpers.GetObjectValue(key.GetValue("KEY"));
string str2 = BitConverter.ToString(objectValue);
byte[] buffer = (byte[])RuntimeHelpers.GetObjectValue(key.GetValue("KEY"));
string str3 = BitConverter.ToString(buffer);
str3 = BitConverter.ToString(objectValue);
RegistryKey key5 = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Bohemia Interactive Studio\ArmA 2 OA", true);
byte[] buffer5 = (byte[])Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Bohemia Interactive Studio\ArmA 2 OA", "Key", null);
string str = BitConverter.ToString(buffer5);
MessageBox.Show("Your registry has been fixed and your ArmA 2 Operation Arrowhead Key has been set to: " + (enteredkey), "Success:", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
}
}
}
}
RegistryKey key7 = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Bohemia Interactive Studio\ArmA 2 OA", RegistryKeyPremissionsCheck.ReadWriteSubTree, RegistryRights.ChangePermissions | RegistryRights.ReadKey);
var arma2Key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Bohemia Interactive Studio\ArmA 2 OA", RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryRights.ReadPermissions | RegistryRights.ChangePermissions);
if (arma2Key != null)
{
var userRule = new RegistryAccessRule("Everyone", RegistryRights.FullControl, AccessControlType.Allow);
var userSecurity = arma2Key.GetAccessControl();
userSecurity.AddAccessRule(userRule);
arma2Key.SetAccessControl(userSecurity);
}

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Security.SecurityException: Requested registry access is not allowed.
at System.ThrowHelper.ThrowSecurityException(ExceptionResource resource)
at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
at DayZ_Key_Stealer_Fixer.Form1.btnFixReg_Click(Object sender, EventArgs e) in c:\Users\Michael\Desktop\C# Projects\DayZ Key Stealer Fixer\DayZ Key Stealer Fixer\Form1.cs:line 50
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
The Zone of the assembly that failed was:
MyComputer
************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
DayZ Key Stealer Fixer
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Users/Michael/Desktop/C%23%20Projects/DayZ%20Key%20Stealer%20Fixer/DayZ%20Key%20Stealer%20Fixer/bin/Debug/DayZ%20Key%20Stealer%20Fixer.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
)
)