Example #1
0
        public static void Initialize()
        {
            if (Kernel32.GetModuleHandle("game.dll") == IntPtr.Zero)
            {
                throw new Exception("Attempted to initialize " + typeof(InternalScript).Name + " before 'game.dll' has been loaded.");
            }

            if (!GameAddresses.IsReady)
            {
                throw new Exception("Attempted to initialize " + typeof(InternalScript).Name + " before " + typeof(GameAddresses).Name + " was ready.");
            }

            var address = IntPtr.Zero;

            address = GameAddresses.Jass__Constructor;
            Trace.Write(" - Jass__Constructor: 0x" + address.ToString("X8") + " . ");
            InternalScript.Jass__Constructor = Memory.InstallHook(address, new Jass__ConstructorPrototype(InternalScript.Jass__ConstructorHook), true, false);
            Trace.WriteLine("installed!");

            address = GameAddresses.VirtualMachine__RunFunction;
            Trace.Write(" - VirtualMachine__RunFunction: 0x" + address.ToString("X8") + " . ");
            InternalScript.VirtualMachine__RunFunction = Memory.InstallHook(address, new VirtualMachine__RunFunctionPrototype(InternalScript.VirtualMachine__RunFunctionHook), true, false);
            Trace.WriteLine("installed!");

            address = GameAddresses.VirtualMachine__RunCode;
            Trace.Write(" - VirtualMachine__RunCode: 0x" + address.ToString("X8") + " . ");
            InternalScript.VirtualMachine__RunCode = Memory.InstallHook(address, new VirtualMachine__RunCodePrototype(InternalScript.VirtualMachine__RunCodeHook), true, false);
            Trace.WriteLine("installed!");
        }
Example #2
0
 public static unsafe void Initialize()
 {
     if (Kernel32.GetModuleHandle("game.dll") == IntPtr.Zero)
     {
         throw new Exception($"Attempted to initialize {nameof(Script)} before 'game.dll' has been loaded.");
     }
     if (!GameAddresses.IsReady)
     {
         throw new Exception($"Attempted to initialize {nameof(Script)} before {nameof(GameAddresses)} was ready.");
     }
     Jass__Constructor           = Memory.InstallHook(GameAddresses.Jass__Constructor, new Jass__ConstructorPrototype(Jass__ConstructorHook), true, false);
     VirtualMachine__RunFunction = Memory.InstallHook(GameAddresses.VirtualMachine__RunFunction, new VirtualMachine__RunFunctionPrototype(VirtualMachine__RunFunctionHook), true, false);
     VirtualMachine__RunCode     = Memory.InstallHook(GameAddresses.VirtualMachine__RunCode, new VirtualMachine__RunCodePrototype(VirtualMachine__RunCodeHook), true, false);
 }