Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace WiimoteVision
- {
- public class Injected : EasyHook.IEntryPoint
- {
- private EasyHook.LocalHook Direct3DCreate9Hook;
- private MyDirect3D9.IDirect3D9 IDirect3D9;
- public Injected(EasyHook.RemoteHooking.IContext Context)
- {
- }
- public unsafe void Run(EasyHook.RemoteHooking.IContext Context)
- {
- // Install the DirectX hook.
- try
- {
- Direct3DCreate9Hook = EasyHook.LocalHook.Create(
- EasyHook.LocalHook.GetProcAddress("D3D9.DLL", "Direct3DCreate9"),
- new Direct3DCreate9Delegate(MyDirect3DCreate9),
- this);
- Direct3DCreate9Hook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });
- }
- catch (Exception Exception)
- {
- return;
- }
- EasyHook.RemoteHooking.WakeUpProcess();
- while (true)
- {
- System.Threading.Thread.Sleep(500);
- }
- }
- // This is the wrapping that let's us give Win32 a delegate instead of a function pointer.
- [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.Winapi, SetLastError = true)]
- private unsafe delegate Win32.D3D9.IDirect3D9* Direct3DCreate9Delegate(ushort SdkVersion);
- // This is our fake version of Direct3DCreate9. We call the real one but this let's us grab the IDirect3D pointer.
- private static unsafe Win32.D3D9.IDirect3D9* MyDirect3DCreate9(ushort SdkVersion)
- {
- // Since this function is static we need to get a reference to "this".
- Injected This = (Injected)EasyHook.HookRuntimeInfo.Callback;
- // Create one of our custom IDirect3D9 objects (which insantiates a real one and passes most calls through to it).
- This.IDirect3D9 = new MyDirect3D9.IDirect3D9(SdkVersion);
- // Return the IDirect3D9 pointer.
- return This.IDirect3D9.NativeIDirect3D9;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment