[Help] HowTo use LUA func menu

User Tag List

Results 1 to 8 of 8
  1. #1
    jojom's Avatar Member
    Reputation
    1
    Join Date
    Aug 2012
    Posts
    3
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Help] HowTo use LUA func

    Hello,
    first, I apologize in advance for my very bad english, but I come here because I can see that this site seems very active so sorry if you have trouble to understand me :confused:
    I am currently doing a cheat for the version 3.3.5a 12340 (tphack, flyhack, speedhack, realmlist changer, walk on water, ...). I know coding in c/c++ and I'm able to write / read simple things in memory but I need some help in using LUA functions.

    For some reasons, i need to use the "/reload" command into the chat. So i searched some lua func and i found :
    lua_SendChatMessage with the offset : 0050D170 // for 3.3.5a 12340

    So I launched my OllyDbg and I researched this offset :

    [Help] HowTo use LUA func-sans-titre-jpg

    And after... I don't realy understand, i know simple assembler instructions but i don't know where to start :confused:

    So if you could help me to understand and interact in c++ (in preference, but i can understand autoit and c#) with this function it would be great

    [Help] HowTo use LUA func
  2. #2
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's not the function you want. Use FrameScript_Execute. There is a lot of information in this section about it. Just make sure you run it from the main thread.

  3. #3
    jojom's Avatar Member
    Reputation
    1
    Join Date
    Aug 2012
    Posts
    3
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right, after several searches I noticed that "FrameScript_execute" was also called "Lua_DoString", so i found Lua_DoString = 0x00819210, // 3.3.5a 12340 .

    As you said lanman92, there is a lot of information about "Lua_DoString", I found source code in c# here for exemple (Lua Do String) or here (they are very similar ).

    But I have some difficulties to translate c# to c++, so if someone could help me to understand it, it would be very nice

    and is it forced to use blackmagic dll?

    thank you

  4. #4
    J0llyGr33n's Avatar Corporal
    Reputation
    1
    Join Date
    Sep 2011
    Posts
    20
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Vandra View Post
    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);
            }
    seems to be pretty straight forward.

  5. #5
    Viano's Avatar Active Member
    Reputation
    37
    Join Date
    May 2008
    Posts
    172
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes but why doing this? Inject. Hook. Win.
    Viano

  6. #6
    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)
    Originally Posted by J0llyGr33n View Post
    seems to be pretty straight forward.
    This will cause crashes i guess and not that rare you think. And seems like you don't update thread's TLS.
    Just make a simple detour. So you pause process, modify memory page properties for writing, not just executing and reading, write jmp to your codecave at the start of some frequently called function (some d3d func or even WoW's like RenderWorld to start with) and in that codecave you simply call anything you want and then restore original 5 bytes of the function then jmp back. This is probably the most explicit and close to your code way of calling function in main thread, though not the best.
    Last edited by Empted; 09-05-2012 at 02:08 PM.

  7. #7
    jojom's Avatar Member
    Reputation
    1
    Join Date
    Aug 2012
    Posts
    3
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by J0llyGr33n View Post
    seems to be pretty straight forward.
    yes in c# but not in c++ :/

  8. #8
    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)
    Originally Posted by jojom View Post
    yes in c# but not in c++ :/
    It's easier in C++ than in C#, because C++ is a nativly compiled language and C# not.
    The code snippet is horrible, it has a tendency to leak memory (C# people seem to leak more resources than people using a language without garbage collector ...) and it won't work as lua function have to be called inside WoW's main thread context, but Black Magic will create a new thread to execute the code. Even if that chat functions are an exeption and do not rely on thread-specific data, you'll encounter threading problems like race conditions.

    Just inject a DLL and hook some function only called by the main thread (Prefer Endscene oder GlxSwapBuffers, depending on which 3d-API you use to run WoW, as it ensures that you have a consistent state) ad do your stuff there.

    The only alternative to code injection is adjusting the main threads context (Didn't use Windows for over 3 years, but it should be SetThreadContext/GetThreadContext) which is VERY hackish.
    Last edited by flo8464; 09-10-2012 at 05:53 AM.
    Hey, it compiles! Ship it!

Similar Threads

  1. NoAddiction, using LUAs need help!
    By ShasVa in forum WoW Bots Questions & Requests
    Replies: 0
    Last Post: 05-08-2011, 04:24 AM
  2. [Help] New to LUA, Need help with script.
    By nickelo in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 03-14-2008, 11:23 PM
  3. Help with this LUA script
    By jordash in forum World of Warcraft Emulator Servers
    Replies: 7
    Last Post: 03-08-2008, 04:19 PM
  4. [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
  5. Howto use Firefox to quickly search any site.
    By Mizzypoo in forum Community Chat
    Replies: 0
    Last Post: 01-09-2008, 02:08 PM
All times are GMT -5. The time now is 01:52 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