Exemplo n.º 1
0
        public override void Initialize()
        {
            Form   form       = new Form();
            IntPtr iDirect3D9 = Direct3DCreate9(32u);

            if (iDirect3D9 == IntPtr.Zero)
            {
                throw new Exception("Failed to create D3D.");
            }
            D3D9.D3DPRESENT_PARAMETERS d3dPresentParams = new D3D9.D3DPRESENT_PARAMETERS
            {
                Windowed         = true,
                SwapEffect       = 1u,
                BackBufferFormat = 0u
            };

            var createDevice = (D3D9.D3DCreateDevice)Marshal.GetDelegateForFunctionPointer(Marshal.ReadIntPtr(Marshal.ReadIntPtr(iDirect3D9), D3D9Vtable.Reset_Index * 4), typeof(D3D9.D3DCreateDevice));

            IntPtr device;

            if (createDevice(iDirect3D9, 0u, 1u, form.Handle, 32u, ref d3dPresentParams, out device) < 0)
            {
                throw new Exception("Failed to create device.");
            }

            this.EndScenePointer = Marshal.ReadIntPtr(Marshal.ReadIntPtr(device), D3D9Vtable.EndScene_Index * 4);

            var deviceRelease = (D3D9.D3DRelease)Marshal.GetDelegateForFunctionPointer(Marshal.ReadIntPtr(Marshal.ReadIntPtr(device), D3D9Vtable.Release_Index * 4), typeof(D3D9.D3DRelease));
            var d3dRelease    = (D3D9.D3DRelease)Marshal.GetDelegateForFunctionPointer(Marshal.ReadIntPtr(Marshal.ReadIntPtr(iDirect3D9), D3D9Vtable.Release_Index * 4), typeof(D3D9.D3DRelease));

            deviceRelease(device);
            d3dRelease(iDirect3D9);
            form.Dispose();

            this.endSceneDelegate = (D3D9.D3DEndscene)Marshal.GetDelegateForFunctionPointer(this.EndScenePointer, typeof(D3D9.D3DEndscene));

            LOLSmiteModel.Memory.GetMagic.Detours.CreateAndApply(endSceneDelegate, new D3D9.D3DEndscene(this.EndsceneDetour), "endscene");
        }
Exemplo n.º 2
0
		public override void Initialize()
		{
			
			Form form = new Form();
			IntPtr iDirect3D9 = Direct3DCreate9(32u);
			if (iDirect3D9 == IntPtr.Zero)
			{
				throw new Exception("Failed to create D3D.");
			}
			D3D9.D3DPRESENT_PARAMETERS d3dPresentParams = new D3D9.D3DPRESENT_PARAMETERS
			{
				Windowed = true,
				SwapEffect = 1u,
				BackBufferFormat = 0u
			};
			
			var createDevice = (D3D9.D3DCreateDevice) Marshal.GetDelegateForFunctionPointer ( Marshal.ReadIntPtr(Marshal.ReadIntPtr(iDirect3D9), D3D9Vtable.Reset_Index*4), typeof(D3D9.D3DCreateDevice) );
			
			IntPtr device;
			if (createDevice(iDirect3D9, 0u, 1u, form.Handle, 32u, ref d3dPresentParams, out device) < 0)
			{
				throw new Exception("Failed to create device.");
			}
			
			this.EndScenePointer = Marshal.ReadIntPtr(Marshal.ReadIntPtr(device), D3D9Vtable.EndScene_Index*4);
			
			var deviceRelease = (D3D9.D3DRelease)Marshal.GetDelegateForFunctionPointer(Marshal.ReadIntPtr(Marshal.ReadIntPtr(device), D3D9Vtable.Release_Index*4), typeof(D3D9.D3DRelease));
			var d3dRelease = (D3D9.D3DRelease)Marshal.GetDelegateForFunctionPointer(Marshal.ReadIntPtr(Marshal.ReadIntPtr(iDirect3D9), D3D9Vtable.Release_Index*4), typeof(D3D9.D3DRelease));
			
			deviceRelease(device);
			d3dRelease(iDirect3D9);
			form.Dispose();
			
			this.endSceneDelegate = (D3D9.D3DEndscene)Marshal.GetDelegateForFunctionPointer(this.EndScenePointer, typeof(D3D9.D3DEndscene));
			
			LOLSmiteModel.Memory.GetMagic.Detours.CreateAndApply(endSceneDelegate,new D3D9.D3DEndscene(this.EndsceneDetour),"endscene");
		}