Estoy intentando hacer una pequeña aplicación que hace uso de la API VirtualProtect es la siguiente:
using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace VirtualProtectTest
{
class Program
{
[DllImport("kernel32.dll")]
public static extern bool VirtualProtectEx( IntPtr hProcess, uint dwAddress, int nSize, uint flNewProtect, out uint lpflOldProtect);
static void Main(string[] args)
{
Process p = Process.Start("app.exe");
Thread.Sleep(1000);
if (VirtualProtectEx(p.Handle, (uint)p.MainModule.BaseAddress, 4096, 0x100, out uint a))
{
Console.WriteLine("Success!");
}
else
{
Console.WriteLine("Fail!");
p.Kill();
}
Console.ReadKey();
}
}
}
Pero siempre me devuelve los mismos errores:
; expected (CS1002) - C:\Users\android\Documents\SharpDevelop Projects\Consol\Consol\Program.cs:25,97
Invalid expression term ')' (CS1525) - C:\Users\android\Documents\SharpDevelop Projects\Consol\Consol\Program.cs:25,96
; expected (CS1002) - C:\Users\android\Documents\SharpDevelop Projects\Consol\Consol\Program.cs:25,96
Invalid expression term ')' (CS1525) - C:\Users\android\Documents\SharpDevelop Projects\Consol\Consol\Program.cs:25,95
; expected (CS1002) - C:\Users\android\Documents\SharpDevelop Projects\Consol\Consol\Program.cs:25,95
Invalid expression term 'int' (CS1525) - C:\Users\android\Documents\SharpDevelop Projects\Consol\Consol\Program.cs:25,94
; expected (CS1002) - C:\Users\android\Documents\SharpDevelop Projects\Consol\Consol\Program.cs:30,13
Invalid expression term 'else' (CS1525) - C:\Users\android\Documents\SharpDevelop Projects\Consol\Consol\Program.cs:30,9