Passing string pointer as parameter crashes WoW menu

User Tag List

Results 1 to 8 of 8
  1. #1
    Burningmace's Avatar Member
    Reputation
    1
    Join Date
    Feb 2010
    Posts
    16
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Passing string pointer as parameter crashes WoW

    I've been working on some code that calls a method in WoW and returns its return value. Whilst this is fine for a single uint parameter, I'm struggling with passing strings.

    So far my code allocates memory for a string, writes it to memory, then calls the method at the address with the address of the string as a parameter.

    Here's what I have:
    Code:
            private uint Call(uint address, string Param)
            {
                Param += '\0';
                // round length to nearest 4096
                int sl = RoundPageSize(Param.Length);
                // create some memory to store the string
                uint sptr = wow.AllocateMemory(sl);
                // write the string to memory
                SMemory.WriteUnicodeString((IntPtr)wow.ProcessId, sptr, Param);
                // execute at the address (I'm testing with 0x005A4FE0)
                uint retn = wow.Execute(address, sptr);
                System.Threading.Thread.Sleep(5);
                wow.FreeMemory(sptr);
                return retn;
            }
    This crashes WoW, stating that an access violation occured reading memory address 0x00000044.

    What am I doing wrong?

    Passing string pointer as parameter crashes WoW
  2. #2
    flo8464's Avatar Active Member
    Reputation
    30
    Join Date
    Apr 2009
    Posts
    434
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, at first, you can't call non-__stdcall functions by using CreateRemoteThread.
    Then, ever tried to leave the string in memory? 5ms is pretty short, maybe the game still stores references to your string. Ohh, and calling functions in a remote thread can cause many problems, like race conditions and access to the TLS etc

    Call it manually by injecting some ASM.
    Hey, it compiles! Ship it!

  3. #3
    Burningmace's Avatar Member
    Reputation
    1
    Join Date
    Feb 2010
    Posts
    16
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried some ASM and still got the same issue...

    Code:
    // called with 0x005A4FE0, "target"
    private uint Call(WarcraftOffsets address, string Param)
            {
                Param += '\0';
                int sl = RoundPageSize(Param.Length);
                uint sptr = wow.AllocateMemory(sl);
                SMemory.WriteUnicodeString((IntPtr)wow.ProcessId, sptr, Param);
                wow.Asm.Clear();
                wow.Asm.AddLine("push 0x" + sptr.ToString("X"));
                wow.Asm.AddLine("call 0x" + address.ToString("X"));
                wow.Asm.AddLine("pop ebp");
                wow.Asm.AddLine("retn");
                uint mptr = wow.AllocateMemory(wow.Asm.GetMemorySize());
                uint retn = wow.Asm.InjectAndExecute(mptr); // CRASH
                System.Threading.Thread.Sleep(1000);
                wow.FreeMemory(mptr);
                wow.FreeMemory(sptr);
                return retn;
            }

  4. #4
    Robske's Avatar Contributor
    Reputation
    305
    Join Date
    May 2007
    Posts
    1,062
    Thanks G/R
    3/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Meh, as I expected. You are trying to call a lua function. You have to manage the lua stack yourself.

    int __cdecl lua_UnitHealth(LuaState* p)
    "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding
    "I cried a little earlier when I had to poop" - Sku

  5. #5
    Burningmace's Avatar Member
    Reputation
    1
    Join Date
    Feb 2010
    Posts
    16
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Aaah, that explains a lot. I've just read the guide by jbrauman on the object manager and the WoW 3.3.0 info dump threads and it seems there should be a much simpler way to access the information than injecting ASM to call LUA functions.

    From what I can understand, there's a static pointer to the PlayerBase and then a bunch of offsets to the important values. The info thread has an enum called PlayerFields with a pile of interesting looking offsets in. What I can't find is the actual PlayerBase pointer... I searched but it's basically full of questions without answers - telling people either to find it themselves (without giving them an idea how) or telling them it's in the info thread (I can't find it!). A little help?

  6. #6
    Robske's Avatar Contributor
    Reputation
    305
    Join Date
    May 2007
    Posts
    1,062
    Thanks G/R
    3/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Burningmace View Post
    Aaah, that explains a lot. I've just read the guide by jbrauman on the object manager and the WoW 3.3.0 info dump threads and it seems there should be a much simpler way to access the information than injecting ASM to call LUA functions.

    From what I can understand, there's a static pointer to the PlayerBase and then a bunch of offsets to the important values. The info thread has an enum called PlayerFields with a pile of interesting looking offsets in. What I can't find is the actual PlayerBase pointer... I searched but it's basically full of questions without answers - telling people either to find it themselves (without giving them an idea how) or telling them it's in the info thread (I can't find it!). A little help?
    Iterate the objectmanager and compare with the GUID of the localplayer or use the static pointer to the localplayer base...

    And open your eyes while searching:


    Just updated my addresses and I tought I'd share the new player pointer so here it is:
    Player Pointer: 0x00CF8C50
    Base: Didn't change, (((Ptr)+34)+24)
    "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding
    "I cried a little earlier when I had to poop" - Sku

  7. #7
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Burningmace View Post
    [code]
    private uint Call(uint address, string Param)
    {
    Param += '\0';
    // round length to nearest 4096
    int sl = RoundPageSize(Param.Length);
    // create some memory to store the string
    uint sptr = wow.AllocateMemory(sl);
    // write the string to memory
    SMemory.WriteUnicodeString((IntPtr)wow.ProcessId, sptr, Param);
    Among other things, String.Length != buffer size if you're using Unicode. Use ANSI or correctly calculate the byte length of the Unicode string.
    Don't believe everything you think.

  8. #8
    Burningmace's Avatar Member
    Reputation
    1
    Join Date
    Feb 2010
    Posts
    16
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    amamonk - I spotted this error a minute ago and corrected it, though since the original string was only 6 characters it shouldn't have caused problems in this case.

    Robske - You're a legend! +1 rep for you, I think. I can't believe I missed that one, my brain must have fallen asleep. I think the fact that it was such a short reply in the thread meant that my eyes just slid over it without processing it. When I searched the thread itself I used "playerbase" as a term, so that's why it didn't get flagged. Just goes to show that you shouldn't try to find stuff like this so early in the morning!

    I did actually read up on iterating through the object manager, but for some reason I kept getting 0x00000000 returned from my pointers. Maybe I messed up somewhere or chose the wrong pointer... who knows? Anyway, I'll give that player base pointer a go. Thanks again!
    Last edited by Burningmace; 02-12-2010 at 04:07 PM.

Similar Threads

  1. Patches crash WoW
    By dev1462 in forum WoW ME Tools & Guides
    Replies: 2
    Last Post: 04-19-2008, 10:19 AM
  2. Map editing crashes WoW on Vista, why!
    By dev1462 in forum WoW ME Questions and Requests
    Replies: 0
    Last Post: 04-13-2008, 12:23 PM
  3. [Hunter] Disconect/Crash WoW
    By jonoboo in forum World of Warcraft Exploits
    Replies: 2
    Last Post: 12-28-2007, 04:45 PM
  4. Quests crashing wow
    By Le Froid in forum World of Warcraft Emulator Servers
    Replies: 7
    Last Post: 11-27-2007, 10:46 PM
  5. [Question] MEfix crashing wow still? Help please
    By ravner298 in forum WoW ME Questions and Requests
    Replies: 4
    Last Post: 10-11-2007, 04:58 PM
All times are GMT -5. The time now is 06:26 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