Problems with the hook during loading screen menu

User Tag List

Results 1 to 8 of 8
  1. #1
    Xzord's Avatar Member
    Reputation
    1
    Join Date
    Jan 2015
    Posts
    2
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems with the hook during loading screen

    Hello everyone!

    I use Hook from this forum for wow 3.3.5 12340
    Hook:
    Code:
    public struct Direct3D
        {
            public static uint Direct3D9__Device = 0xC5DF88;
            public static uint Direct3D9__Device__OffsetA = 0x397C;
            public static uint Direct3D9__Device__OffsetB = 0xA8;
        }
        public class HookManager
        {
            private BlackMagic process;
    
            private bool mainThreadHooked;
            private bool ExecutingCode;
    
            private uint codeCave;
            private uint injectionAddress;
            private uint returnAddress;
    
            public HookManager(BlackMagic process)
            {
                this.process = process;
    
                this.mainThreadHooked = false;
                this.ExecutingCode = false;
    
                this.codeCave = 0;
                this.injectionAddress = 0;
                this.returnAddress = 0;
            }
    
            private void HookApplication()
            {
                if (!process.IsProcessOpen)
                    throw new Exception("Process is not open");
    
                //uint baseAddress = (uint)process.MainModule.BaseAddress;
                uint pDevice = process.ReadUInt(/*baseAddress + */Direct3D.Direct3D9__Device);
                uint pEnd = process.ReadUInt(pDevice + Direct3D.Direct3D9__Device__OffsetA);
                uint pScene = process.ReadUInt(pEnd);
                uint pEndScene = process.ReadUInt(pScene + Direct3D.Direct3D9__Device__OffsetB);
    
                if (process.ReadUInt(pEndScene) == 0xE9 && (codeCave == 0 || injectionAddress == 0))
                {
                    DisposeOfHook();
                }
                if (process.ReadUInt(pEndScene) != 0xE9)
                {
                    try
                    {
                        mainThreadHooked = false;
    
                        codeCave = process.AllocateMemory(2048);
                        injectionAddress = process.AllocateMemory(0x4);
    
                        process.WriteInt(injectionAddress, 0);
    
                        returnAddress = process.AllocateMemory(0x4);
                        process.WriteInt(returnAddress, 0);
    
                        process.Asm.Clear();
    
                        process.Asm.AddLine("mov edi, edi");
                        process.Asm.AddLine("push ebp");
                        process.Asm.AddLine("mov ebp, esp");
    
                        process.Asm.AddLine("pushfd");
                        process.Asm.AddLine("pushad");
    
                        //Test for waiting code?
                        process.Asm.AddLine("mov eax, [" + injectionAddress + "]");
                        process.Asm.AddLine("test eax, ebx");
                        process.Asm.AddLine("je @out");
    
                        //Execute waiting code
                        process.Asm.AddLine("mov eax, [" + injectionAddress + "]");
                        process.Asm.AddLine("call eax");
    
                        //Copy pointer to return value
                        process.Asm.AddLine("mov [" + returnAddress + "], eax");
    
                        process.Asm.AddLine("mov edx, " + injectionAddress);
                        process.Asm.AddLine("mov ecx, 0");
                        process.Asm.AddLine("mov [edx], ecx");
    
                        //Close Function
                        process.Asm.AddLine("@out:");
    
                        //Inject Code
                        uint sizeAsm = (uint)(process.Asm.Assemble().Length);
    
                        process.Asm.Inject(codeCave);
    
                        int sizeJumpBack = 5;
    
                        // create jump back stub
                        process.Asm.Clear();
                        process.Asm.AddLine("jmp " + (pEndScene + sizeJumpBack));
                        process.Asm.Inject(codeCave + sizeAsm);// + (uint)sizeJumpBack);
    
                        // create hook jump
                        process.Asm.Clear(); // $jmpto
                        process.Asm.AddLine("jmp " + (codeCave));
                        process.Asm.Inject(pEndScene);
    
                    }
                    catch
                    {
                        mainThreadHooked = false; return;
                    }
                    mainThreadHooked = true;
                }
    
            }
            private void DisposeOfHook()
            {
                if (!process.IsProcessOpen)
                    throw new Exception("Process is not open");
    
                //uint baseAddress = (uint)process.MainModule.BaseAddress;
                uint pDevice = process.ReadUInt(/*baseAddress + */Direct3D.Direct3D9__Device);
                uint pEnd = process.ReadUInt(pDevice + Direct3D.Direct3D9__Device__OffsetA);
                uint pScene = process.ReadUInt(pEnd);
                uint pEndScene = process.ReadUInt(pScene + Direct3D.Direct3D9__Device__OffsetB);
    
                try
                {
                    if (process.ReadByte(pEndScene) == 0xE9) // check if wow is already hooked and dispose Hook
                    {
                        // Restore origine endscene:
                        process.Asm.Clear();
                        process.Asm.AddLine("mov edi, edi");
                        process.Asm.AddLine("push ebp");
                        process.Asm.AddLine("mov ebp, esp");
                        process.Asm.Inject(pEndScene);
                    }
    
                    // free memory:
                    process.FreeMemory(codeCave);
                    process.FreeMemory(injectionAddress);
                    process.FreeMemory(returnAddress);
                }
                catch
                {
                }
            }
    
            public byte[] InjectAndExecute(string[] asm)
            {
                while (ExecutingCode)
                {
                    System.Threading.Thread.Sleep(5);
                }
    
                ExecutingCode = true;
    
                HookApplication();
    
                byte[] tempsByte = new byte[0];
    
                // reset return value pointer
                process.WriteInt(returnAddress, 0);
    
                if (process.IsProcessOpen && mainThreadHooked)
                {
                    // Write the asm stuff
                    process.Asm.Clear();
                    foreach (string tempLineAsm in asm)
                    {
                        process.Asm.AddLine(tempLineAsm);
                    }
    
                    // Allocation Memory
                    int codeSize = process.Asm.Assemble().Length;
                    uint injectionAsm_Codecave = process.AllocateMemory(codeSize);
    
    
                    try
                    {
                        // Inject
                        process.Asm.Inject(injectionAsm_Codecave);
                        process.WriteInt(injectionAddress, (int)injectionAsm_Codecave);
    
                        // Wait to launch code
                        while (process.ReadInt(injectionAddress) > 0)
                        {
                            System.Threading.Thread.Sleep(5);
                        }
    
                        byte Buf = new Byte();
                        List<byte> retnByte = new List<byte>();
                        uint dwAddress = process.ReadUInt(returnAddress);
                        Buf = process.ReadByte(dwAddress);
                        while (Buf != 0)
                        {
                            retnByte.Add(Buf);
                            dwAddress = dwAddress + 1;
                            Buf = process.ReadByte(dwAddress);
                        }
                        tempsByte = retnByte.ToArray();
                    }
                    catch { }
    
                    // Free memory allocated 
                    process.FreeMemory(injectionAsm_Codecave);
                }
    
                DisposeOfHook();
    
                ExecutingCode = false;
    
                return tempsByte;
            }
        }
    FunctionManager:
    Code:
    public class FunctionManager
        {
            BlackMagic process;
            HookManager aHook;
            uint FrameScript__Execute = 0x00819210;
            //uint moduleBase { get { return (uint)process.MainModule.BaseAddress; } }
    
            public FunctionManager(BlackMagic process)
            {
                this.process = process;
                this.aHook = new HookManager(process);
            }
    
            public void LuaDoString(string command)
            {
                int nSize = command.Length + 0x100;
                uint codeCave = process.AllocateMemory(nSize);
    
                process.WriteASCIIString(codeCave, command);
                process.Asm.Clear();
    
                String[] asm = new String[] 
                {
                    "mov eax, " + codeCave,
                    "push 0",
                    "push eax",
                  
                    "push eax",
                    "mov eax, " + (/*moduleBase + */FrameScript__Execute),
                    
                    "call eax",
                    "add esp, 0xC",
                    "retn",    
                };
    
                aHook.InjectAndExecute(asm);
                process.FreeMemory(codeCave);
            }
    
            public string GetLocalizedText(string command)
            {
                uint ClntObjMgrGetActivePlayerObj = 0x004038F0;
                uint FrameScript__GetLocalizedText = 0x007225E0;
    
                int nSize = command.Length + 0x100;
                uint codeCave = process.AllocateMemory(nSize);
                process.WriteASCIIString(codeCave, command);
    
                String[] asm = new String[] 
                    {
                    "call " + ClntObjMgrGetActivePlayerObj,
                    "mov ecx, eax",
                    "push -1",
                    "mov edx, " + codeCave + "",
                    "push edx",
                    "call " + FrameScript__GetLocalizedText,
                    "retn",
                    };
    
                string sResult = Encoding.ASCII.GetString(aHook.InjectAndExecute(asm));
                process.FreeMemory(codeCave);
    
                return sResult;
            }
        }
    And I have wow crash without wow errors, when I use this, during loading screen (for example: BG queue pop and I accepted that):
    Code:
    functionManager.LuaDoString(string.Format("spell, _, _, _, startTime, _, _, _, _ = UnitCastingInfo(\"target\"); if (spell) then Time = startTime / 1000 - GetTime() else Time = 0 end;"));
    
                    string Time = functionManager.GetLocalizedText("Time"); //Line 276
    Please, help to correct it. Program error in attachments.
    Attached Thumbnails Attached Thumbnails Problems with the hook during loading screen-error-jpg  

    Problems with the hook during loading screen
  2. #2
    Vandra's Avatar Contributor
    Reputation
    288
    Join Date
    Mar 2008
    Posts
    471
    Thanks G/R
    26/26
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Windows version ?
    "If it compiles, it works."

  3. #3
    JuJuBoSc's Avatar Banned for scamming CoreCoins Purchaser
    Reputation
    1019
    Join Date
    May 2007
    Posts
    922
    Thanks G/R
    1/3
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Because GetLocalizedText use the player object, and the ClntObjMgrGetActivePlayerObj return null while in loading screen.

  4. #4
    Xzord's Avatar Member
    Reputation
    1
    Join Date
    Jan 2015
    Posts
    2
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Win XP. Thx and how to fix that? I tried to read ClntObjMgrGetActivePlayerObj adress when was loading screen. All time the same value.

  5. #5
    Wildbreath's Avatar Contributor
    Reputation
    162
    Join Date
    Feb 2012
    Posts
    121
    Thanks G/R
    2/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hook EnterWorld (last function in C_GameUI_Initialize function), or check byte by offset in first cmp with 0 in EnterWorld function, it should be equal 1

  6. #6
    JuJuBoSc's Avatar Banned for scamming CoreCoins Purchaser
    Reputation
    1019
    Join Date
    May 2007
    Posts
    922
    Thanks G/R
    1/3
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Xzord View Post
    Win XP. Thx and how to fix that? I tried to read ClntObjMgrGetActivePlayerObj adress when was loading screen. All time the same value.
    It's an function, so there is no point reading it.

  7. #7
    MaiN's Avatar Elite User
    Reputation
    335
    Join Date
    Sep 2006
    Posts
    1,047
    Thanks G/R
    0/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by JuJuBoSc View Post
    It's an function, so there is no point reading it.
    What if you are trying to emulate the function?
    [16:15:41] Cypher: caus the CPU is a dick
    [16:16:07] kynox: CPU is mad
    [16:16:15] Cypher: CPU is all like
    [16:16:16] Cypher: whatever, i do what i want

  8. #8
    JuJuBoSc's Avatar Banned for scamming CoreCoins Purchaser
    Reputation
    1019
    Join Date
    May 2007
    Posts
    922
    Thanks G/R
    1/3
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    imo he don't even think about doing that

Similar Threads

  1. [Question] Problems with the new WoW update.
    By Aradroth in forum WoW ME Questions and Requests
    Replies: 6
    Last Post: 01-23-2008, 09:40 PM
  2. [Question] Having problems with the fix(23)
    By Jo_Vo in forum WoW ME Questions and Requests
    Replies: 0
    Last Post: 11-26-2007, 08:06 AM
  3. problem with the website
    By aznboy in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 11-09-2007, 11:05 PM
  4. Problem with the vote thing
    By Cyrex in forum Community Chat
    Replies: 0
    Last Post: 03-01-2007, 11:59 PM
All times are GMT -5. The time now is 04:38 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search