[Solved] InvalidPtr Lua menu

User Tag List

Results 1 to 1 of 1
  1. #1
    weber7655's Avatar Member
    Reputation
    6
    Join Date
    Sep 2009
    Posts
    18
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Solved] InvalidPtr Lua

    EDIT: I actually solved my own problem - of course, after days of trying this to no avail, I solved it immediately after posting. Typical. The below code should work, I'll leave it up in case anybody can use it as a learning tool

    As much as I hate to open another question thread after just having done so a few days ago, I've spent a considerable amount of time on this and searched extensively but haven't found what I'm doing wrong. I'm using Apoc's Lua Wrapper (http://www.mmowned.com/forums/world-...ected-clr.html) from an injected endScene hook and now have DoString working.

    I may be completely off, but from what I understand, in order to get return values, we must register our own Lua function. When registering new Lua, the InvalidPtr function checks to see whether the pointer to our new function is within WoW's .text space. Since the pointer to our new function is outside this space, we find an unused space in the .text section and write a JMP to our new Lua pointer. We then try to pass this JMP location to WoW's Registering function.

    When I do this, it's still crashing WoW as I call WoW's register function. I've debugged in OllyDbg and it appears that my JMP command is correctly pointing to the new Lua function.


    Code:
    // LuaRegisterCommand = WoWBase + 0x3AB990
    
    // Pass the pointer to my new Lua function as the argument
    public static IntPtr WriteLuaCallback(IntPtr callbackPtr)
            {
    // Set codeCaveLocation (where my JMP is written) to a location which
    // is unused, overwriting only the 0xCC 0xCC 0xCC... used for alignment
                IntPtr codeCaveLocation = (IntPtr)Helper.WoWBase + 0x3E5C32;
    
    // Write 0xE9, the opcode for a relative jump
                Helper.Magic.Write<byte>(codeCaveLocation, 0xE9);
    
    // Write the relative location of my new Lua pointer to the JMP instruction
                Helper.Magic.Write<int>(codeCaveLocation + 1, (int)callbackPtr - (int)codeCaveLocation - 5);
    
    // Return the location of my code cave (JMP instruction) to be used as I
    // call WoW's RegisterCommand - RegisterCommand(commandName, codeCaveLocation)
                return codeCaveLocation;
            }
    Any help would be greatly appreciated.


    A couple of the main references I've used (not limited to of course)
    http://www.mmowned.com/forums/world-...-callback.html
    http://www.mmowned.com/forums/world-..._register.html
    Last edited by weber7655; 06-09-2011 at 08:07 PM.

    [Solved] InvalidPtr Lua

Similar Threads

  1. [Lua Script] (Solved) Lua suicide doesnt work.. would like some help.
    By DaynNight in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 02-03-2012, 03:40 PM
  2. [Lua] Newbie Lua scripting question (SOLVED)
    By Maybepie in forum WoW EMU Questions & Requests
    Replies: 10
    Last Post: 04-16-2010, 07:21 AM
  3. Solve this for rep!
    By Gelormino in forum Community Chat
    Replies: 21
    Last Post: 09-22-2007, 01:14 PM
  4. if you solve this i will reward you
    By Ark in forum Gaming Chat
    Replies: 39
    Last Post: 08-08-2007, 12:56 PM
All times are GMT -5. The time now is 01:04 AM. 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