[Question] "Beginning" Lua programming menu

Shout-Out

User Tag List

Results 1 to 4 of 4
  1. #1
    Krillere's Avatar Contributor
    Reputation
    112
    Join Date
    Nov 2007
    Posts
    668
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Question] "Beginning" Lua programming

    Hello, I've just started in the ME business. I tried making some code after looking at all the great documentation.

    I've tried this code:

    Code:
    BlackMagic WoW = new BlackMagic();
    WoW.OpenProcessAndThread(SProcess.GetProcessFromWindowTitle("World of Warcraft"));
    
    uint CodeCave = WoW.AllocateMemory();
    
    WoW.Asm.Clear();
    
    WoW.Asm.AddLine("var_18= dword ptr -18h");
    WoW.Asm.AddLine("var_4= dword ptr -4");
    WoW.Asm.AddLine("arg_0= dword ptr  8");
    
    WoW.Asm.AddLine("push    ebp");
    WoW.Asm.AddLine("mov     ebp, esp");
    WoW.Asm.AddLine("push    ecx");
    WoW.Asm.AddLine("push    ebx");
    WoW.Asm.AddLine("push    esi");
    WoW.Asm.AddLine("mov     esi, [ebp+arg_0]");
    WoW.Asm.AddLine("push    edi");
    WoW.Asm.AddLine("push    1");
    WoW.Asm.AddLine("push    esi");
    WoW.Asm.AddLine("call    sub_827110");
    WoW.Asm.AddLine("add     esp, 8");
    WoW.Asm.AddLine("test    eax, eax");
    WoW.Asm.AddLine("jz      loc_4A6752");
    
    WoW.Asm.InjectAndExecute(CodeCave);
    WoW.FreeMemory(CodeCave);
    That ASM code is the code for DoEmote(), it fails at
    Code:
    WoW.Asm.InjectAndExecute(CodeCave);
    After that code failed, I began looking at the pseudo code, the pseudo code for DoEmote is this;

    Code:
    int __cdecl sub_4A6610(int a1)
    {
      char *v1; // eax@3
      char *v2; // esi@3
      int v4; // esi@6
      int v5; // edi@7
      int v6; // ebx@10
      int v7; // eax@15
      int v8; // ecx@15
      int v9; // edi@15
      int v10; // esi@15
      int v11; // edx@18
      int v12; // eax@19
      int v13; // edx@19
      int v14; // ST18_4@21
      char *v15; // [sp+14h] [bp-4h]@2
    
      if ( sub_827110(a1, 1) )
      {
        v15 = (char *)sub_827290(a1, 1, 0);
        if ( !sub_7019D0(v15, "DANCE", 0x7FFFFFFFu) )
        {
          v1 = (char *)sub_827290(a1, 2, 0);
          v2 = v1;
          if ( v1 )
          {
            if ( (unsigned __int8)sub_50DAC0(v1) )
            {
              sub_50D9F0(v2);
              return 0;
            }
          }
        }
        v4 = dword_A75074;
        if ( dword_A75074 )
        {
          v5 = 76 * dword_A75074;
          while ( 1 )
          {
            --v4;
            v5 -= 76;
            if ( v4 < 0 || v4 >= dword_A75074 )
              v6 = 0;
            else
              v6 = v5 + dword_A75088;
            if ( !sub_7019D0(v15, *(char **)(v6 + 4), 0x7FFFFFFFu) )
              break;
            if ( !v4 )
              return 0;
          }
          v10 = dword_B695C8;
          v9 = dword_B695CC;
          v7 = sub_827290(a1, 2, 0);
          if ( v7 )
          {
            LOBYTE(v8) = *(_BYTE *)v7;
            if ( *(_BYTE *)v7 )
            {
              if ( (_BYTE)v8 != 37 )
              {
                v10 = sub_4C4DC0(v7, 16, 0, 0, 3.402823466385289e38, 0);
                v9 = v11;
              }
            }
          }
          v12 = sub_47A5C0(v8);
          if ( sub_47BBC0(v12, v13, 16) )
          {
            sub_671C90(v6, v10, v9);
            return 0;
          }
        }
      }
      else
      {
        sub_828430(a1, "Usage: DoEmote(\"emote\"[, \"target\"])", v14);
      }
      return 0;
    }
    But I don't know how to call DoEmote using the pseudo-code, any pointer on how to do that would be nice! But, the main question still is; How do I make the ASM stuff work? :-)

    ( I did read the rules, and I don't think that this is breaking it, if it is just delete it.. )

    [Question] &quot;Beginning&quot; Lua programming
  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)
    WoW.Asm.AddLine("var_18= dword ptr -18h");
    WoW.Asm.AddLine("var_4= dword ptr -4");
    WoW.Asm.AddLine("arg_0= dword ptr 8");
    This is not only wrong; this wrong-wrong.

    Just use lua_dostring/Framescript::Execute or whatever.
    Your attempt is wrong from the beginning to the end.
    Hey, it compiles! Ship it!

  3. #3
    Krillere's Avatar Contributor
    Reputation
    112
    Join Date
    Nov 2007
    Posts
    668
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I tried a new approach, I used IDA to find the CastSpellById function, this was the ASM Code I found:

    Code:
    push    ebp
    mov     ebp, esp
    sub     esp, 2E8h
    push    esi
    mov     esi, [ebp+arg_0]
    push    1
    push    esi
    call    sub_8270D0
    add     esp, 8
    test    eax, eax
    jnz     short loc_4D7101
    Then, I tried doing it with BlackMagic ( changing a few things though! )

    Code:
                BlackMagic WoW = new BlackMagic();
                WoW.OpenProcessAndThread(SProcess.GetProcessFromWindowTitle("World of Warcraft"));
    
                uint CodeCave = WoW.AllocateMemory();
                WoW.Asm.Clear();
                const uint CastSpellById = 0x004D70D0;
    
    WoW.Asm.AddLine("push    ebp");
    WoW.Asm.AddLine("mov     ebp, esp");
    WoW.Asm.AddLine("sub     esp, 2E8h");
    WoW.Asm.AddLine("push    esi");
    WoW.Asm.AddLine("mov     esi, [ebp+arg_0]");
    WoW.Asm.AddLine("push    1");
    WoW.Asm.AddLine("push    esi");
    WoW.Asm.AddLine("call    sub_8270D0");
    WoW.Asm.AddLine("add     esp, 8");
    WoW.Asm.AddLine("test    eax, eax");
    WoW.Asm.AddLine("jnz     short {0}", CastSpellById);
    WoW.Asm.AddLine("retn");
    
    WoW.Asm.InjectAndExecute(CodeCave);
    WoW.FreeMemory(CodeCave);
    But now I'm unsure. I'm trying to figure out what the
    Code:
    [ebp+arg_0]
    and the
    Code:
    sub_8270D0
    is, if anyone could help me with this I would be gratefull. I changed the
    Code:
    loc_4D7101
    to the address, don't ask me why, but it seemed right. Atleast I tried this time, this may be the wrong approach, but I really want to learn this. Thanks in advance, Krillere.

    Edit: Sorry for doubleposting, didn't notice.

  4. #4
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you don't have a basic understanding of ASM, you shouldn't be messing with it.

    Closing this thread until you do at least a little bit of research.

    Hint: Copy/pasting from IDA isn't correct.

Similar Threads

  1. Lua Programming
    By SectorSeven in forum Suggestions
    Replies: 14
    Last Post: 06-23-2008, 03:18 AM
  2. Some questions about databases and Lua script
    By Whisperfrost in forum World of Warcraft Emulator Servers
    Replies: 6
    Last Post: 06-18-2008, 08:11 AM
  3. [Question]Problem with enabling lua
    By Corosive720 in forum World of Warcraft Emulator Servers
    Replies: 5
    Last Post: 01-23-2008, 12:01 PM
All times are GMT -5. The time now is 02:37 AM. 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