Lua Do String menu

User Tag List

Results 1 to 13 of 13
  1. #1
    kingdeking's Avatar Member
    Reputation
    4
    Join Date
    Oct 2008
    Posts
    50
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lua Do String

    Hello,

    I am trying to find this function in WoW but its hard, can you help me a bit? I used Lua Func in game, set breakpoint and looked up where it was called from. Now i have one function that is called all the time and calls different Lua functions, it takes 3 parameters, one is the lua state ptr.

    Lua Do String
  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)
    How i'm doing it:

    Code:
    public void LuaDoString(string command)
            {
                int nSize = command.Length + 0x100;
                uint codeCave = process.AllocateMemory(nSize);
                uint moduleBase = (uint)process.MainModule.BaseAddress;
    
                process.WriteASCIIString(codeCave, command);
    
                process.Asm.Clear();
    
                String[] asm = new String[] 
                {
                    "mov eax, " + codeCave,
                    "push 0",
                    "push eax",
                  
                    "push eax",
                    "mov eax, " + (moduleBase + Offsets.Endscene.Lua_DoStringAddress),
                    
                    "call eax",
                    "add esp, 0xC",
                    "retn",    
                };
    
                vLib.InjectAndExecute(asm);
                process.FreeMemory(codeCave);
            }

  3. #3
    kingdeking's Avatar Member
    Reputation
    4
    Join Date
    Oct 2008
    Posts
    50
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ye ye, just wondering how to get the return value :/

  4. #4
    Empted's Avatar Contributor
    Reputation
    83
    Join Date
    Aug 2011
    Posts
    117
    Thanks G/R
    0/5
    Trade Feedback
    2 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,
    Code:
                wow.WriteASCIIString(varName, variable);
                wow.Asm.AddLine("mov ecx, {0}", player.BaseAddress);
                wow.Asm.AddLine("push {0}", -1);
                wow.Asm.AddLine("push {0}", varName);
                wow.Asm.AddLine("call {0}", (uint)wow.MainModule.BaseAddress + (uint)Offsets.eWowFunctions.FrameScript__GetLocalizedText);
                wow.Asm.AddLine("mov dword [{0}], eax", returnValue);
    Simply try putting return value into variable with some name, like myVariable=SomeFunction(). Then you create string with that variable name you need to get value from (ASCII encoded) and call FrameScript__GetLocalizedText with 3 params you can see above. It returns you a pointer to a string with UTF encoding that you can simply read and get your return value.
    Offset for FrameScript__GetLocalizedText is 0x43C230+(wow main module adress).
    Btw reading UTF string can be done something like this:
    Code:
                    byte[] bytes = wow.ReadBytes(wow.ReadUInt(returnValue), 0x50);
                    string decodedBytes = Encoding.UTF8.GetString(bytes);
                    sResult = decodedBytes.Split('\0')[0];
    Last edited by Empted; 08-16-2012 at 11:59 AM.

  5. #5
    migtron's Avatar Corporal
    Reputation
    18
    Join Date
    Jun 2010
    Posts
    22
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Assuming you mean FrameScript::ExecuteBuffer by "Lua_DoString", that function uses cdecl calling conventions and as such returns the result in EAX. But are you sure you actually need its return value? I don't know for sure what it returns in 4.3.4 and after a quick glance at the code I would wildly guess... the Lua stack size maybe? Or some error code? Doesn't seem like anything useful at least.

  6. #6
    kingdeking's Avatar Member
    Reputation
    4
    Join Date
    Oct 2008
    Posts
    50
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay guys, thanks for all the help but I managed to reverse it myself. My assumption in the first post was correct luckily. The return value can be found in different places of the lua_state object.

    Most integer values go to

    mov eax, [Lua_State_PTR+C];
    mov ret, [eax]

  7. #7
    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)
    Originally Posted by kingdeking View Post
    Ye ye, just wondering how to get the return value :/
    Then you need GetLocalizedText, and not DoString

  8. #8
    kingdeking's Avatar Member
    Reputation
    4
    Join Date
    Oct 2008
    Posts
    50
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    btw, different question, how do you determine if a battleground is over?

  9. #9
    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)
    UPDATE_BATTLEFIELD_STATUS event

    or BATTLEFIELDS_SHOW maybe

  10. #10
    kingdeking's Avatar Member
    Reputation
    4
    Join Date
    Oct 2008
    Posts
    50
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay. So these are fields somewhere in WoW I can read right? So I should get a pointer to these when reversig RegisterEvent() Api right?

  11. #11
    Empted's Avatar Contributor
    Reputation
    83
    Join Date
    Aug 2011
    Posts
    117
    Thanks G/R
    0/5
    Trade Feedback
    2 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can probably hook those events in Lua and modify some of your variables once event hits. And check that variable using GetLocalizedText.

  12. #12
    kingdeking's Avatar Member
    Reputation
    4
    Join Date
    Oct 2008
    Posts
    50
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. But what is GetLocalizedText doing? :confused: What is it good for?

  13. #13
    Empted's Avatar Contributor
    Reputation
    83
    Join Date
    Aug 2011
    Posts
    117
    Thanks G/R
    0/5
    Trade Feedback
    2 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Look my post above. It get's value from variable by name. And because of lua being dynamically typed language it will always get string value.
    Btw calling GetLocalizedText to check variable can be bad for perfomance, so i guess it's better first to find adress of variable and just memory read.
    Last edited by Empted; 08-16-2012 at 06:52 PM.

Similar Threads

  1. [ArcEmu] MySQL/Lua from string choosing
    By kerovi in forum WoW EMU Questions & Requests
    Replies: 0
    Last Post: 01-11-2011, 01:24 PM
  2. Lua Do String
    By qjlex in forum WoW Memory Editing
    Replies: 40
    Last Post: 10-10-2009, 08:16 PM
  3. Lua do most of the strings?
    By luciferc in forum WoW Memory Editing
    Replies: 23
    Last Post: 07-11-2009, 04:45 AM
  4. New LUA Scripts
    By 777devil777 in forum World of Warcraft Emulator Servers
    Replies: 8
    Last Post: 11-26-2007, 05:58 PM
  5. LUA Refrences
    By 777devil777 in forum World of Warcraft Emulator Servers
    Replies: 1
    Last Post: 11-22-2007, 08:09 PM
All times are GMT -5. The time now is 03:15 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