[WoW] [3.0.9] [Info] LUA Callbacks menu

User Tag List

Page 2 of 4 FirstFirst 1234 LastLast
Results 16 to 30 of 47
  1. #16
    Nesox's Avatar ★ Elder ★
    Reputation
    1280
    Join Date
    Mar 2007
    Posts
    1,238
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cant get it to work perfectley. GetTop seems to allways return 0 somehow. Maybe it's my Lua_DoString that doesnt work properley or is it impossible to use Lua_DoString and then pop the values?
    Here's the class im using.


    Code:
    public class Lua
        {
    
            private BlackMagic wow { get; set; }
            private uint State;
    
            public Lua(BlackMagic _BlackMagic)
            {
                this.wow = _BlackMagic;
                State = GetState();
            }
    
    
            private enum Offsets : uint
            {
                GetLuaState = 0x0077D0F0, 
                lua_gettop = 0x007ADAD0,
                lua_tostring = 0x007ADFE0,
             }
    
            public uint GetState()
            {
                uint codeCave = wow.AllocateMemory(0x1048);
    
                wow.Asm.Clear();
                wow.Asm.AddLine("call {0}", (uint)Offsets.GetLuaState);
                wow.Asm.AddLine("retn");
    
                uint result = wow.Asm.InjectAndExecute(codeCave);
                wow.FreeMemory(codeCave);
                return result;
            }
    
            public int GetTop()
            {
                uint codeCave = wow.AllocateMemory(0x1048);
                wow.Asm.Clear();
                wow.Asm.AddLine("push {0}", State);
                wow.Asm.AddLine("call {0}", (uint)Offsets.lua_gettop);
                wow.Asm.AddLine("add esp, 0x4");
                wow.Asm.AddLine("retn");
    
                uint result = wow.Asm.InjectAndExecute(codeCave);
                wow.FreeMemory(codeCave);
                return (int)result;
            }
    
            public override string ToString()
            {
                return ToString(GetTop(), 64);
            }
    
            public string ToString(int index, int length)
            {
                uint codeCave = wow.AllocateMemory(0x2048);
    
                wow.Asm.Clear();
                wow.Asm.AddLine("push 0");
                wow.Asm.AddLine("push {0}", index);
                wow.Asm.AddLine("push {0}", State);
                wow.Asm.AddLine("call {0}", (uint)Offsets.lua_tostring);
                wow.Asm.AddLine("add esp, 0xC");
                wow.Asm.AddLine("retn");
    
                uint result = wow.Asm.InjectAndExecute(codeCave);
                wow.FreeMemory(codeCave);
    
                try
                {
                    return wow.ReadASCIIString(result, length);
                }
                catch (Exception e)
                {
                    return "";
                }
            }
    
            public void Lua_DoString(string pszString)
            {
                ObjectManager __ObjectManager = new ObjectManager(this.wow);
                ObjectManager.WoWObjectManager _ObjectManager = __ObjectManager.GetWowObjectManager();
    
                wow.Asm.Clear();
                uint pScript = wow.AllocateMemory(pszString.Length + 1);
                wow.WriteASCIIString(pScript, pszString);
    
                wow.Asm.AddLine("mov EDX, [{0}]", _ObjectManager.g_clientConnection);   //Start UpdateCurMgr
                wow.Asm.AddLine("mov EDX, [EDX+{0}]", _ObjectManager.Offset);
                wow.Asm.AddLine("FS mov EAX, [0x2C]");
                wow.Asm.AddLine("mov EAX, [EAX]");
                wow.Asm.AddLine("add EAX, 8");
                wow.Asm.AddLine("mov [EAX], EDX"); // End UpdateCurMgr
    
                wow.Asm.AddLine("mov ecx, [{0}]", State );//0x00FC54EC);
                wow.Asm.AddLine("push ecx");
                wow.Asm.AddLine("mov eax, {0}", pScript);
                wow.Asm.AddLine("push eax");
                wow.Asm.AddLine("mov edx, {0}", pScript);
                wow.Asm.AddLine("push edx");
    
                wow.Asm.AddLine("call {0}", WowDecompile.FindOffset(this.wow, WowDecompile.Offsets.Lua_DoString));
                wow.Asm.AddLine("add esp, 0xC");
                wow.Asm.AddLine("retn");
    
                uint codeCave = wow.AllocateMemory(0x2048);
                wow.Asm.InjectAndExecuteEx(this.wow.ProcessHandle, codeCave);
            }
    
          }
    And here is how i use it.
    Code:
                    BlackMagic wow = new BlackMagic(p.Id);
                    Lua _Lua = new Lua(wow);
    
                    _Lua.Lua_DoString("status, mapName, instanceID, lowestlevel, highestlevel, teamSize, registeredMatch = GetBattlefieldStatus(1);");
    
                    for (int i = 0; i < _Lua.GetTop(); i++)
                    {
                           if(i != 0)
                                 Console.WriteLine(_Lua.ToString(i, 64));
    
                           else
                                 Console.WriteLine("GetTop:{0}", _Lua.GetTop());
                    }
    Any suggestions?

    [WoW] [3.0.9] [Info] LUA Callbacks
  2. #17
    jjaa's Avatar Contributor
    Reputation
    245
    Join Date
    Dec 2006
    Posts
    562
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Nesox View Post
    Cant get it to work perfectley. GetTop seems to allways return 0 somehow. Maybe it's my Lua_DoString that doesnt work properley or is it impossible to use Lua_DoString and then pop the values?
    Here's the class im using.


    ....

    [/code]Any suggestions?

    lua_DoString will not put anything on the lua stack, thats why you register your own lua function and pass the lua you want to execute as a pram to your lua function.

    Code:
    typedef int ( __cdecl * Lua_CFunction )( struct lua_State *L);
    FUNCTION_AT_ADDRESS(void __cdecl lua_RegisterFunction( char * szName, Lua_CFunction pFunc ), 0x0077D290);
    
    int __cdecl lua_ISXWoWPrint (struct lua_State *L) 
    {
    
      
    int n = LuaGetTop(L);  /* number of arguments */
      for (int i=1; i<=n; i++) 
      {
            const char *out=lua_tostring(L,i,NULL);
            if (out && out[0])
                printf("%s",out);
      }
      return 0;
    
    
    }
    //007CB790 must be patched to stop the invalid function pointer crap
    
    int __cdecl CMD_tester(int argc, char *argv[])
    {
        lua_RegisterFunction("ISXWoWPrint",lua_ISXWoWPrint);
        MyDoString("ISXWoWPrint(luafunc())","ISXWoWPrint(luafunc())");
    }
    I haven't tested it yet because the servers are down but it should work...i hope

  3. #18
    Nesox's Avatar ★ Elder ★
    Reputation
    1280
    Join Date
    Mar 2007
    Posts
    1,238
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah ok thank you ill try to figure out how to do that later ^^
    Edit: it's gonna take a while
    Last edited by Nesox; 03-17-2009 at 08:27 AM.

  4. #19
    jagged software's Avatar Member
    Reputation
    -4
    Join Date
    Feb 2009
    Posts
    36
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cypher great work. I'd hump your leg but it seems inappropriate.
    Thanks for this and your other posts today.

    Nesox, Re: Porting to C#.
    You should have a custom library in both languages. The more tools in your toolbox the better.

  5. #20
    Nesox's Avatar ★ Elder ★
    Reputation
    1280
    Join Date
    Mar 2007
    Posts
    1,238
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by jagged software View Post
    Nesox, Re: Porting to C#.
    You should have a custom library in both languages. The more tools in your toolbox the better.
    My C++ skills arent really fresh gonna start learning it more serious in a while when i got some more time

  6. #21
    jagged software's Avatar Member
    Reputation
    -4
    Join Date
    Feb 2009
    Posts
    36
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it's the best way to go IMO. but whatever gets the job done. if you have any questions when learning, feel free to send me a PM.

  7. #22
    SKU's Avatar Contributor
    Reputation
    306
    Join Date
    May 2007
    Posts
    565
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by jjaa View Post
    [COLOR=Cyan]lua_DoString will not put anything on the lua stack, thats why you register your own lua function and pass the lua you want to execute as a pram to your lua function.
    Ah good to know, not that I was trying to get the value off the stack for 3 hours. Gonna look into it, although my brain refuses to convert C++ to sense.

    Until then, my 'loldetour' of the print() function has to be enough. :/


  8. #23
    ostapus's Avatar Active Member
    Reputation
    60
    Join Date
    Nov 2008
    Posts
    180
    Thanks G/R
    3/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice,

    thanks for isxwow source Cypher. I was wondering for a long time how facing been implemented in isxwow. I wish someone had more fresh sources where -lineofsight parameter (for target command) is implemented.

  9. #24
    ostapus's Avatar Active Member
    Reputation
    60
    Join Date
    Nov 2008
    Posts
    180
    Thanks G/R
    3/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by jjaa View Post
    lua_DoString will not put anything on the lua stack, thats why you register your own lua function and pass the lua you want to execute as a pram to your lua function.
    Hmm, in theory - after lua_dostring you should be able to pull results (if there any) from the stack... lua_dostring is actually macros as
    lua_load(....) with following lua_pcall

    where lua_load compiles and puts bytecode in the stack and lua_pcall calling that compiled chunk of code.. so if that chunk - puts anything in the stack - it should be popable. once again - in theory

  10. #25
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by ostapus View Post
    Nice,

    thanks for isxwow source Cypher. I was wondering for a long time how facing been implemented in isxwow. I wish someone had more fresh sources where -lineofsight parameter (for target command) is implemented.

    1.9.x (the version I just posted) was the last version with a source release.

  11. #26
    argh44z's Avatar Member
    Reputation
    19
    Join Date
    Nov 2007
    Posts
    93
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for that file Cypher, I had found a copy a while back and then lost it again while switching computers. Maytricksmath was a p. cool dude.

  12. #27
    ggg898's Avatar Member
    Reputation
    10
    Join Date
    Jan 2009
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there anything one have to do in order to "prepare" for a DoString call? I have a wrapper much like the one in this post, but when it gets called, the state pointer param is pointing to something else than a lua state. (at least something which Lua_getTop doesnt return the correct values for).

    If i call GetState in my regged fucntion first, it works ok. (or at least in 99% of the cases, it does return wrong number of parameters once in a while compared to what it should when looking at wow api wiki). This really gives me the feel that some sync or threading problem is occuring.

    I call DoString with the last paramter set to null, and in the context of wows rendering thread, this is the only place any of my lua calls occurs, so I cant really understand where the threading probs occur....

    Do wows other threads call Lua so i have to suspend them even when executing in the rendering thread?

    What state does a Lua_doString with null third parameter use? Anyone knows? Or have i missunderstood something real bad?

    Many thanks to all users on this site

  13. #28
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Third param is just zero, you don't need to pass it anything.

    If you're in the render thread you don't need to worry about thread synchronization because all of WoWs thread-local stuff happens in that thread, so obviously it can't change anything while your code is being executed.

    You don't need to call GetState, you're probably calling GetTop wrong.

  14. #29
    slcavos's Avatar Member
    Reputation
    1
    Join Date
    Jan 2008
    Posts
    7
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not to resurrect a dead thread, but this is the closest, most recent match to what I am doing. I am currently trying to get simple DoString support in C# using BlackMagic, and have hit a brick wall.

    When I invoke the function, it doesn't crash the client, it doesn't throw an exception, but nothing happens. No response whatsoever. Same story with CastSpellById, incidentally. I have double checked the function offsets in IDA to verify the parameters and everything looks ok there. I have all the required DLLs in the executable folder. I have read every LUA thread I could find, and aside from constantly being reminded that I should be using C++ for this, I can't find anything that I might be doing wrong.

    Here's what I am using:
    Code:
            public static void Lua_DoString(string command)
            {
               // command is something like "DoEmote(\"dance\")"
    
                wow.SuspendThread();
    
                uint codecave = wow.AllocateMemory();
                uint stringcave = wow.AllocateMemory(command.Length + 1);
                WriteString(stringcave, command, true);
    
                wow.Asm.Clear();
                wow.Asm.AddLine("fs mov eax, [0x2C]");
                wow.Asm.AddLine("mov eax, [eax]");
                wow.Asm.AddLine("add eax, 8");
                wow.Asm.AddLine("mov dword [eax], {0}", s_curMgr);
    
                wow.Asm.AddLine("push {0}", 0);
                wow.Asm.AddLine("mov eax, {0}", stringcave);
                wow.Asm.AddLine("push eax");
                wow.Asm.AddLine("push eax");
                wow.Asm.AddLine("call {0}", 0x0049AE30);
                wow.Asm.AddLine("add esp, 0xC");
                wow.Asm.AddLine("retn");
    
                wow.Asm.InjectAndExecute(codecave);
                wow.FreeMemory(codecave);
                wow.FreeMemory(stringcave);
                wow.ResumeThread();
            }
    This seems like it should be quite simple and I can't help the nagging feeling that I am missing something obvious. I don't really care about getting return values at this point, just basic commands. If anyone could give my function a looksie, I would really appreciate it.

  15. #30
    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)
    Here's mine...

    Code:
     
    public bool lua_DoString(BlackMagic bm, string command)
    {
    space = bm.AllocateMemory(0x2048);
    bm.WriteASCIIString(space + 0x1024, command);
    g_clientCon = bm.ReadUInt(0x1132F60);
    s_curMgr = bm.ReadUInt(g_clientCon + 0x2C24);
    bm.Asm.Clear();
    bm.Asm.AddLine("FS mov eax, [0x2C]");
    bm.Asm.AddLine("mov eax, [eax]");
    bm.Asm.AddLine("add eax, 0x10");
    bm.Asm.AddLine("mov dword [eax], {0}", s_curMgr);
    bm.Asm.AddLine("mov ecx, 0");
    bm.Asm.AddLine("mov eax, " + (space + 0x1024));
    bm.Asm.AddLine("push ecx");
    bm.Asm.AddLine("push eax");
    bm.Asm.AddLine("push eax");
    bm.Asm.AddLine("mov eax, " + luaDoString);
    bm.Asm.AddLine("call eax");
    bm.Asm.AddLine("add esp, 0xC");
    bm.Asm.AddLine("retn");
    bm.SuspendThread();
    bm.Asm.InjectAndExecute(space);
    bm.ResumeThread();
    bm.FreeMemory(space);
    return true;
    }

Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. Replies: 10
    Last Post: 02-13-2011, 01:21 AM
  2. WoW May 2008 Banwave Info
    By iamyour41 in forum World of Warcraft General
    Replies: 15
    Last Post: 05-22-2008, 12:50 AM
  3. [Release]WoW Fansite Tools and Info
    By xsyx in forum World of Warcraft Emulator Servers
    Replies: 3
    Last Post: 05-10-2008, 07:19 PM
All times are GMT -5. The time now is 09:06 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