WhiteMagic and Endscene menu

User Tag List

Results 1 to 1 of 1
  1. #1
    shadowKD's Avatar Member
    Reputation
    1
    Join Date
    Jul 2017
    Posts
    24
    Thanks G/R
    7/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    WhiteMagic and Endscene

    Hello everyone, I decided to deal with the CleanCore project code (cata), but I was stopped by the exception
    System.TypeInitializationException
    what could be the problem?

    Exception climbs in all the red lines!

    Code:
    using System;
    using System.Windows.Forms;
    using WhiteMagic.Internals;
    
    
    namespace cleanCore.D3D
    {
    
        public static class Pulse
        {
            private static Direct3DAPI.Direct3D9EndScene _endSceneDelegate;
            private static Detour _endSceneHook;
    
            private static readonly object _frameLock = new object();
            public static IntPtr EndScenePointer = IntPtr.Zero;
            public static IntPtr ResetPointer = IntPtr.Zero;
            public static IntPtr ResetExPointer = IntPtr.Zero;
    
            public static event EventHandler OnFrame;
    
            private static int EndSceneHook(IntPtr device)
            {
                lock (_frameLock)
                {
                    if (OnFrame != null)
                        OnFrame(null, new EventArgs());
                }
    
                return (int)_endSceneHook.CallOriginal(device);
            }
    
            public static void Initialize()
            {
                var window = new Form();
                IntPtr direct3D = Direct3DAPI.Direct3DCreate9(Direct3DAPI.SDKVersion);
                if (direct3D == IntPtr.Zero)
                    throw new Exception("Direct3DCreate9 failed (SDK Version: " + Direct3DAPI.SDKVersion + ")");
                var pp = new Direct3DAPI.PresentParameters { Windowed = true, SwapEffect = 1, BackBufferFormat = 0 };
                var createDevice = Helper.Magic.RegisterDelegate<Direct3DAPI.Direct3D9CreateDevice>(Helper.Magic.GetObjectVtableFunction(direct3D, 16));
                IntPtr device;
                if (createDevice(direct3D, 0, 1, window.Handle, 0x20, ref pp, out device) < 0)
                    throw new Exception("Failed to create device");
                EndScenePointer = Helper.Magic.GetObjectVtableFunction(device, Direct3DAPI.EndSceneOffset);
                ResetPointer = Helper.Magic.GetObjectVtableFunction(device, Direct3DAPI.ResetOffset);
                ResetExPointer = Helper.Magic.GetObjectVtableFunction(device, Direct3DAPI.ResetExOffset);
    
                var deviceRelease = Helper.Magic.RegisterDelegate<Direct3DAPI.D3DRelease>(Helper.Magic.GetObjectVtableFunction(device, 2));
                var release = Helper.Magic.RegisterDelegate<Direct3DAPI.D3DRelease>(Helper.Magic.GetObjectVtableFunction(direct3D, 2));
                deviceRelease(device);
                release(direct3D);
                window.Dispose();
                // TODO: replace this with a VTable hook
                _endSceneDelegate = Helper.Magic.RegisterDelegate<Direct3DAPI.Direct3D9EndScene>(EndScenePointer);
                _endSceneHook = Helper.Magic.Detours.CreateAndApply(_endSceneDelegate,
                                                                    new Direct3DAPI.Direct3D9EndScene(EndSceneHook),
                                                                    "EndScene");
            }
        }
    
    }

    WhiteMagic and Endscene

Similar Threads

  1. Understanding Detours and EndScene Hooking
    By berlinermauer in forum WoW Memory Editing
    Replies: 7
    Last Post: 10-04-2012, 02:08 PM
  2. C# DLL Injection and Hooking Endscene with WhiteMagic
    By rlane187 in forum WoW Memory Editing
    Replies: 6
    Last Post: 01-26-2012, 01:27 PM
  3. Replies: 11
    Last Post: 01-06-2011, 02:59 PM
  4. Easyhook and whitemagic problems & FSM design question
    By !@^^@! in forum WoW Memory Editing
    Replies: 9
    Last Post: 02-16-2010, 06:51 AM
  5. CEGui and EndScene
    By hypnodok in forum WoW Memory Editing
    Replies: 3
    Last Post: 01-08-2009, 04:51 PM
All times are GMT -5. The time now is 11:31 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search