/// <summary> /// Call a manually mapped PE by its EntryPoint. /// </summary> /// <author>Ruben Boonen (@FuzzySec)</author> /// <param name="peInfo">Module meta data struct (PE.PE_META_DATA).</param> /// <param name="moduleMemoryBase">Base address of the module in memory.</param> /// <returns>void</returns> public static void CallMappedPEModule(Data.PE.PE_META_DATA peInfo, IntPtr moduleMemoryBase) { var hRemoteThread = IntPtr.Zero; var lpStartAddress = peInfo.Is32Bit ? (IntPtr)((ulong)moduleMemoryBase + peInfo.OptHeader32.AddressOfEntryPoint) : (IntPtr)((ulong)moduleMemoryBase + peInfo.OptHeader64.AddressOfEntryPoint); Native.NtCreateThreadEx( ref hRemoteThread, Data.Win32.WinNT.ACCESS_MASK.STANDARD_RIGHTS_ALL, IntPtr.Zero, (IntPtr)(-1), lpStartAddress, IntPtr.Zero, false, 0, 0, 0, IntPtr.Zero ); }
/// <summary> /// Call a manually mapped PE by its EntryPoint. /// </summary> /// <author>Ruben Boonen (@FuzzySec)</author> /// <param name="PEINFO">Module meta data struct (PE.PE_META_DATA).</param> /// <param name="ModuleMemoryBase">Base address of the module in memory.</param> /// <returns>void</returns> public static void CallMappedPEModule(Data.PE.PE_META_DATA PEINFO, IntPtr ModuleMemoryBase) { // Call module by EntryPoint (eg Mimikatz.exe) IntPtr hRemoteThread = IntPtr.Zero; IntPtr lpStartAddress = PEINFO.Is32Bit ? (IntPtr)((UInt64)ModuleMemoryBase + PEINFO.OptHeader32.AddressOfEntryPoint) : (IntPtr)((UInt64)ModuleMemoryBase + PEINFO.OptHeader64.AddressOfEntryPoint); Native.NtCreateThreadEx( ref hRemoteThread, Data.Win32.WinNT.ACCESS_MASK.STANDARD_RIGHTS_ALL, IntPtr.Zero, (IntPtr)(-1), lpStartAddress, IntPtr.Zero, false, 0, 0, 0, IntPtr.Zero ); }