public static void Initialize() { var endScenePointer = IntPtr.Zero; var resetPointer = IntPtr.Zero; using (var d3d = new SlimDX.Direct3D9.Direct3D()) { using ( var tmpDevice = new Device(d3d, 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.HardwareVertexProcessing, new PresentParameters { BackBufferWidth = 1, BackBufferHeight = 1 })) { endScenePointer = Manager.Memory.GetObjectVtableFunction(tmpDevice.ComPointer, VMT_ENDSCENE); resetPointer = Manager.Memory.GetObjectVtableFunction(tmpDevice.ComPointer, VMT_RESET); } } _endSceneDelegate = Manager.Memory.RegisterDelegate <Direct3D9EndScene>(endScenePointer); _endSceneHook = Manager.Memory.Detours.CreateAndApply(_endSceneDelegate, new Direct3D9EndScene(EndSceneHook), "D9EndScene"); _resetDelegate = Manager.Memory.RegisterDelegate <Direct3D9Reset>(resetPointer); _resetHook = Manager.Memory.Detours.CreateAndApply(_resetDelegate, new Direct3D9Reset(ResetHook), "D9Reset"); // NEEDED FOR DRAWING IN RENDERBACKGROUND //_renderBackgroundDelegate = Manager.Memory.RegisterDelegate<Direct3D39RenderBackground>((IntPtr)Pointers.Drawing.RenderBackground); //_renderBackgroundHook = Manager.Memory.Detours.CreateAndApply(_renderBackgroundDelegate, new Direct3D39RenderBackground(PrepareRenderState), "RenderBackground"); Log.WriteLine("EndScene detoured at 0x{0:X}", endScenePointer); }
public static void Initialize() { var endScenePointer = IntPtr.Zero; var resetPointer = IntPtr.Zero; using (var d3d = new SlimDX.Direct3D9.Direct3D()) { using ( var tmpDevice = new Device(d3d, 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.HardwareVertexProcessing, new PresentParameters { BackBufferWidth = 1, BackBufferHeight = 1 })) { endScenePointer = Manager.Memory.GetObjectVtableFunction(tmpDevice.ComPointer, VMT_ENDSCENE); resetPointer = Manager.Memory.GetObjectVtableFunction(tmpDevice.ComPointer, VMT_RESET); } } _endSceneDelegate = Manager.Memory.RegisterDelegate<Direct3D9EndScene>(endScenePointer); _endSceneHook = Manager.Memory.Detours.CreateAndApply(_endSceneDelegate, new Direct3D9EndScene(EndSceneHook), "D9EndScene"); //_resetDelegate = Manager.Memory.RegisterDelegate<Direct3D9Reset>(resetPointer); //_resetHook = Manager.Memory.Detours.CreateAndApply(_resetDelegate, new Direct3D9Reset(ResetHook), "D9Reset"); Log.WriteLine("Direct3D9x:"); Log.WriteLine("\tEndScene: 0x{0:X}", endScenePointer); Log.WriteLine("\tReset: 0x{0:X}", resetPointer); }
public override void Initialize() { using (var d3d = new Direct3D()) { using (var tmpDevice = new Device(d3d, 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.HardwareVertexProcessing, new PresentParameters { BackBufferWidth = 1, BackBufferHeight = 1 })) { EndScenePointer = GeneralHelper.Memory.GetVFTableEntry(tmpDevice.ComPointer, VMT_ENDSCENE); ResetPointer = GeneralHelper.Memory.GetVFTableEntry(tmpDevice.ComPointer, VMT_RESET); } } _endSceneDelegate = GeneralHelper.Memory.CreateFunction <Direct3D9EndScene>(EndScenePointer); _endSceneHook = GeneralHelper.Memory.Detours.CreateAndApply(_endSceneDelegate, new Direct3D9EndScene(Callback), "D9EndScene"); /* _resetDelegate = GeneralHelper.Memory.CreateFunction<Direct3D9Reset>(ResetPointer); * _resetHook = GeneralHelper.Memory.Detours.CreateAndApply(_resetDelegate, * new Direct3D9Reset(ResetHook), "D9Reset"); * */ //We really need RESET hook to, so we dont crash wow when hiding the window... return; }
private DirectX() { Console.WriteLine("DirectX applied"); _endSceneDelegate = Memory.Reader.RegisterDelegate <Direct3D9EndScene>(GetEndScene.Instance.ToPointer()); _endSceneHook = Memory.Reader.Detours.CreateAndApply( _endSceneDelegate, new Direct3D9EndScene(EndSceneHook), "D9EndScene"); }
public override void Initialize() { using (var d3d = new Direct3D()) { using (var tmpDevice = new Device(d3d, 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.HardwareVertexProcessing, new PresentParameters() { BackBufferWidth = 1, BackBufferHeight = 1 })) { EndScenePointer = Pulse.Magic.GetObjectVtableFunction(tmpDevice.ComPointer, VMT_ENDSCENE); ResetPointer = Pulse.Magic.GetObjectVtableFunction(tmpDevice.ComPointer, VMT_RESET); } } _endSceneDelegate = Pulse.Magic.RegisterDelegate<Direct3D9EndScene>(EndScenePointer); _endSceneHook = Pulse.Magic.Detours.CreateAndApply(_endSceneDelegate, new Direct3D9EndScene(Callback), "D9EndScene"); }
/// <summary> /// Applying the EndScene detour /// </summary> internal static void Init() { if (Applied) { return; } _endSceneDelegate = Memory.Reader.RegisterDelegate <Direct3D9EndScene>(GetEndScene.ToPointer()); _endSceneHook = Memory.Reader.Detours.CreateAndApply( _endSceneDelegate, new Direct3D9EndScene(EndSceneHook), "D9EndScene"); Applied = true; }
private DirectX() { Console.WriteLine("DirectX applied"); var vTable = GetEndScene.Instance.ToVTablePointer(); _endSceneOriginal = Memory.Reader.RegisterDelegate <Direct3D9EndScene>(vTable.ReadAs <IntPtr>()); _endSceneDetour = new Direct3D9EndScene(EndSceneHook); var addrToDetour = Marshal.GetFunctionPointerForDelegate(_endSceneDetour); _mtId = Process.GetCurrentProcess().Threads[0].Id; var directXvTableHook = new Hack(vTable, BitConverter.GetBytes((int)addrToDetour), "DirectXVTableHook"); HookWardenMemScan.AddHack(directXvTableHook); directXvTableHook.Apply(); }
public override void Initialize() { // Create a new 'window' var window = new Form(); // Grabbed from d3d9.h const uint D3D_SDK_VERSION = 32; // Create the IDirect3D* object. IntPtr direct3D = Direct3DCreate9(D3D_SDK_VERSION); // Make sure it's valid. (Should always be valid....) if (direct3D == IntPtr.Zero) throw new Exception("Failed to create D3D."); // Setup some present params... var d3dpp = new D3DPRESENT_PARAMETERS { Windowed = true, SwapEffect = 1, BackBufferFormat = 0 }; IntPtr device; // CreateDevice is a vfunc of IDirect3D. Hence; why this entire thing only works in process! (Unless you // know of some way to hook funcs from out of process...) // It's the 16th vfunc btw. // Check d3d9.h var createDevice = Pulse.Magic.RegisterDelegate<IDirect3D9_CreateDevice>(Pulse.Magic.GetObjectVtableFunction(direct3D, 16)); // Pass it some vals. You can check d3d9.h for what these actually are.... if (createDevice(direct3D, 0, 1, window.Handle, 0x20, ref d3dpp, out device) < 0) throw new Exception("Failed to create device."); EndScenePointer = Pulse.Magic.GetObjectVtableFunction(device, VMT_ENDSCENE); ResetPointer = Pulse.Magic.GetObjectVtableFunction(device, VMT_RESET); // We now have a valid pointer to the device. We can release the shit we don't need now. :) // Again, the Release() funcs are virtual. Part of the IUnknown interface for COM. // They're the 3rd vfunc. (2nd index) var deviceRelease = Pulse.Magic.RegisterDelegate<D3DVirtVoid>(Pulse.Magic.GetObjectVtableFunction(device, 2)); var d3dRelease = Pulse.Magic.RegisterDelegate<D3DVirtVoid>(Pulse.Magic.GetObjectVtableFunction(direct3D, 2)); // And finally, release the device and d3d object. deviceRelease(device); d3dRelease(direct3D); // Destroy the window... window.Dispose(); // Hook endscene _endSceneDelegate = Pulse.Magic.RegisterDelegate<Direct3D9EndScene>(EndScenePointer); _endSceneHook = Pulse.Magic.Detours.CreateAndApply(_endSceneDelegate, new Direct3D9EndScene(Callback), "D9EndScene"); }