[2.4.3] Lua do_string with CreateRemoteThread menu

User Tag List

Results 1 to 14 of 14
  1. #1
    =manzarek='s Avatar Member
    Reputation
    3
    Join Date
    Feb 2010
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [2.4.3] Lua do_string with CreateRemoteThread

    Hi,
    Here is my code
    public void InjectAndExecute(String[] asm)
    {
    //write asm
    Memory.Asm.Clear();
    foreach (string tempLineAsm in asm)
    {
    Memory.Asm.AddLine(tempLineAsm);
    }
    //allocate
    uint injected_code = Memory.AllocateMemory(Memory.Asm.Assemble().Length, Magic.MemoryAllocType.MEM_COMMIT, Magic.MemoryProtectType.PAGE_EXECUTE_READWRITE);
    ///inject
    Memory.Asm.Inject(injected_code);
    //Execute
    IntPtr th = Memory.CreateRemoteThread(injected_code, 0);
    SThread.WaitForSingleObject(th);
    //free memory
    Memory.FreeMemory(injected_code);
    SThread.TerminateThread(th, 0);
    }

    public void Lua_Dostring(String command)
    {
    //allocate for command
    uint DoStringArg_Codecave = Memory.AllocateMemory(Encoding.UTF8.GetBytes(command).Length + 1);
    //write command
    Memory.WriteBytes(DoStringArg_Codecave, Encoding.UTF8.GetBytes(command));
    String[] asm = new String[]
    {
    "mov eax, " + DoStringArg_Codecave,
    "push 0",
    "push eax",
    "push eax",
    "mov eax, " + (uint)Offsets.Fonctions.Lua_Dostring, // Lua_DoString
    "call eax",
    "add esp, 0xC",
    "retn",
    };
    InjectAndExecute(asm);
    Memory.FreeMemory(DoStringArg_Codecave);
    }
    I try to call Lua_Dostring creating a remoteThread but nothing happend when im executing it, i try to make my char dance (DoEmote(\"dance\")).

    The injection seems to work:
    [2.4.3] Lua do_string with CreateRemoteThread-bb59c26667d5b52af3fafa882d64a7e0-png

    But nothing happend on the execution

    Can someone help me with this please?

    Thank you
    Last edited by =manzarek=; 09-15-2013 at 07:17 AM.

    [2.4.3] Lua do_string with CreateRemoteThread
  2. #2
    Valediction's Avatar Active Member
    Reputation
    37
    Join Date
    Jul 2012
    Posts
    48
    Thanks G/R
    8/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Prototype is:

    int Lua_dostring(lua_state *state, const char *command);

    Also check the calling convention. I find it's fastcall in 1.12, although I think they (thankfully) dropped that in later releases of WoW, don't know about TBC, you seem to be using cdecl (check if that's correct).

    If you're instead trying to call FrameScript__Execute, signature changes a bit. Don't have time for more now will check this later.

  3. #3
    =manzarek='s Avatar Member
    Reputation
    3
    Join Date
    Feb 2010
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your reply
    Im using 0x00706C80 -> Lua_Dostring posted from cypher in the dump thread
    Prototype is:
    int __cdecl sub_706C80(int a1, int a2, int a3) according to ida.
    The calling convention is cdecl

    Since i try to call the function in a new thread maybe i need to replace TLS address

    somethink like:
    push dword [fs:2Ch]
    mov [fs:2Ch], dword TLSAddress
    "mov eax, " + DoStringArg_Codecave,
    "push 0",
    "push eax",
    "push eax",
    "mov eax, " + (uint)Offsets.Fonctions.Lua_Dostring, // Lua_DoString
    "call eax",
    "add esp, 0xC",
    pop dword [fs:2Ch]
    "retn",

    if so how do i find the TLSAddress
    I find this here http://www.ownedcore.com/forums/worl...journal-2.html (WoW Modification Journal)

  4. #4
    xalcon's Avatar Contributor ふたなり
    Authenticator enabled
    Reputation
    198
    Join Date
    Oct 2008
    Posts
    291
    Thanks G/R
    20/58
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    you need to call FrameScript_Execute (aka Lua_DoString) from the MainThread, using your own thread will not work. (I've hooked DirectX EndScene for this)
    "Threads should always commit suicide - they should never be murdered" - DirectX SDK

  5. #5
    Valediction's Avatar Active Member
    Reputation
    37
    Join Date
    Jul 2012
    Posts
    48
    Thanks G/R
    8/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that shouldn't be needed. I have successfully called dostring from a non-main thread and worked (but of course you have to do it from Mt if you want any reliability).

  6. #6
    xalcon's Avatar Contributor ふたなり
    Authenticator enabled
    Reputation
    198
    Join Date
    Oct 2008
    Posts
    291
    Thanks G/R
    20/58
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    well, thats true for unprotected functions.
    Anyway, have you added the process baseaddress to Offsets.Fonctions.Lua_Dostring? I don't know what OS you are using, but ASLR might be the "problem" here.

    Code:
    var baseAddress = wowProcess.MainModule.BaseAddress;
    var funcpointer = baseAddress + FrameScript_Execute_Offset;
    // call funcpointer
    "Threads should always commit suicide - they should never be murdered" - DirectX SDK

  7. #7
    culino2's Avatar Elite User
    Reputation
    336
    Join Date
    Feb 2013
    Posts
    181
    Thanks G/R
    139/72
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by xalcon View Post
    well, thats true for unprotected functions.
    Anyway, have you added the process baseaddress to Offsets.Fonctions.Lua_Dostring? I don't know what OS you are using, but ASLR might be the "problem" here.

    Code:
    var baseAddress = wowProcess.MainModule.BaseAddress;
    var funcpointer = baseAddress + FrameScript_Execute_Offset;
    // call funcpointer
    ASLR isn't enabled in Classic/BC/Wotlk.

  8. #8
    =manzarek='s Avatar Member
    Reputation
    3
    Join Date
    Feb 2010
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah there is no ASLR

  9. #9
    xalcon's Avatar Contributor ふたなり
    Authenticator enabled
    Reputation
    198
    Join Date
    Oct 2008
    Posts
    291
    Thanks G/R
    20/58
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Well, I'm out then :P
    Maybe some offset problems or something related to CreateRemoteThread? Does your client crash when you set the function pointer to 0/Is you code even called?
    I'm not using asm to call wow functions (I'm injected - I can use delegates :3), but your asm code looks okay to me. (even when you push eax twice xP but I guess you are just lazy)
    "Threads should always commit suicide - they should never be murdered" - DirectX SDK

  10. #10
    Valediction's Avatar Active Member
    Reputation
    37
    Join Date
    Jul 2012
    Posts
    48
    Thanks G/R
    8/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I suggest you give mmBBQ a try to check if you have the signature and addresses right. If it works that way then you're probably doing something wrong injecting or calling the function. mmBBQ makes it very easy to try these kinds of thinks, google it up, it uses LUA.

  11. #11
    =manzarek='s Avatar Member
    Reputation
    3
    Join Date
    Feb 2010
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok so i writted the string in memory (doemote...) and write the addresse down( it was 0xFAF0000).
    Then i used asmcall.cdecl(0x00706C80, 0xFAF0000, 0xFAF0000, 0) in mmBBQ
    And...
    It worked, my char started dancing
    So i dont know what is wrong with my injection but i know for sure that the lua_dostring addresse is correct and that my first write is also correct.
    The problem is from the asm code then,
    I checked with cheat engine debugger my injected code is executed.
    I have no idea
    Last edited by =manzarek=; 09-16-2013 at 03:17 PM.

  12. #12
    =manzarek='s Avatar Member
    Reputation
    3
    Join Date
    Feb 2010
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well i used EndScene Hook and now it work
    Credit to Apoc for http://www.ownedcore.com/forums/worl...1-offsets.html (C# code that automatically gets Endscene (DirectX9) and Present (DirectX 11) offsets)

    But if someone have the answer for my problem i will be happy

    Thank you for your replies

  13. #13
    Achilees's Avatar Member
    Reputation
    14
    Join Date
    Sep 2013
    Posts
    20
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am trying to get this to work with 1.12.1 following is the code
    Code:
      public static void InjectAndExecute(String[] asm)
            {
                //write asm
                Memory.Asm.Clear();
                foreach (string tempLineAsm in asm)
                {
                    Memory.Asm.AddLine(tempLineAsm);
                }
                //allocate
                uint injected_code = Memory.AllocateMemory(Memory.Asm.Assemble().Length, Magic.MemoryAllocType.MEM_COMMIT, Magic.MemoryProtectType.PAGE_EXECUTE_READWRITE);
                ///inject
                Memory.Asm.Inject(injected_code);
                //Execute
                IntPtr th = Memory.CreateRemoteThread(injected_code, 0);
                SThread.WaitForSingleObject(th);
                //free memory
                Memory.FreeMemory(injected_code);
                SThread.TerminateThread(th, 0);
            }
    
     public static void Lua_Dostring(String command)
            {
                //allocate for command
                uint DoStringArg_Codecave = Memory.AllocateMemory(Encoding.UTF8.GetBytes(command).Length + 1);
                //write command
                Memory.WriteBytes(DoStringArg_Codecave, Encoding.UTF8.GetBytes(command));
                String[] asm = new String[] 
                {
                "mov eax, " + DoStringArg_Codecave,
                "push 0",
                "push eax",
                "push eax",
                "mov eax, " + (uint)0x006F57F0, // Lua_DoString
                "call eax",
                "add esp, 0xC",
                "retn", 
                };
                InjectAndExecute(asm);
                Memory.FreeMemory(DoStringArg_Codecave);
            }
    Code:
       public static IntPtr CreateRemoteThread(uint lpStartAddress, uint dwCreationFlags)
            {
                uint outlp;
    
                return CreateRemoteThread(WoW.Handle, IntPtr.Zero, 0,(IntPtr)lpStartAddress, IntPtr.Zero, dwCreationFlags, out outlp);
            }
    I am assuming my CreateRemoteThread has issues or i am not sure how you hooked EndScene

  14. #14
    Achilees's Avatar Member
    Reputation
    14
    Join Date
    Sep 2013
    Posts
    20
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I made that pretty apparent with my code paste, anyway thanks for the hint, trying to learn this shit i mean stuff..

Similar Threads

  1. [LUA] Problem with my lua
    By Corosive720 in forum WoW EMU Questions & Requests
    Replies: 1
    Last Post: 09-27-2008, 02:06 PM
  2. [Lua] Problem with my lua code
    By ariax1 in forum WoW EMU Questions & Requests
    Replies: 7
    Last Post: 09-26-2008, 02:45 AM
  3. [Lua] - Problem With Teleporter
    By shadowslayer133 in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 09-16-2008, 04:02 PM
  4. [Help Plzzzz] LUA Problem with KJ Script
    By Arthas117 in forum WoW EMU Questions & Requests
    Replies: 3
    Last Post: 08-16-2008, 05:25 PM
  5. [Help] i need Lua help with this script...
    By Ellenor in forum World of Warcraft Emulator Servers
    Replies: 25
    Last Post: 03-03-2008, 03:45 PM
All times are GMT -5. The time now is 08:34 AM. 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