Your variable 'dllBaseAdressIWant ' contains the module, but not its base address.
PHP Code:
IntPtr processHandle = OpenProcess(0x1F0FFF, false, System.Diagnostics.Process.GetProcessesByName(targetProc)[0].Id);
System.Diagnostics.ProcessModuleCollection modules = System.Diagnostics.Process.GetProcessesByName(targetProc)[0].Modules;
IntPtr dllBaseAdressIWant = IntPtr.Zero; // changed a bit here
foreach (System.Diagnostics.ProcessModule i in modules)
{
if (i.ModuleName == "fuck.dll")
{
dllBaseAdressIWant = i.BaseAddress; // now dllBaseAdressIWant is the base address of the module :)
}
}
int bytesWritten = 0;
byte[] lol = new byte[1] {0x4E};
WriteProcessMemory((int)processHandle, (int)dllBaseAdressIWant, lol, lol.Length, ref bytesWritten);
Also, why don't you put 'using System.Diagnostics' ? Your code would be much easier to read.