[C#] ProcessModule / dllbase zu int?! - PE Header

02/14/2014 23:20 onahoe#1
#old
02/15/2014 02:29 davydavekk#2
Your variable 'dllBaseAdressIWant ' contains the module, but not its base address.


PHP Code:
IntPtr processHandle OpenProcess(0x1F0FFFfalseSystem.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)dllBaseAdressIWantlollol.Lengthref bytesWritten); 
Also, why don't you put 'using System.Diagnostics' ? Your code would be much easier to read.