Create a LUA function in 3.3.5a 12340 menu

User Tag List

Results 1 to 12 of 12
  1. #1
    Blackplayer27's Avatar Active Member
    Reputation
    32
    Join Date
    Sep 2010
    Posts
    27
    Thanks G/R
    3/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Create a LUA function in 3.3.5a 12340

    Hello, i try to create a new lua function in 3.3.5a but i dont found the offset for the lua_state, can you pls help me ?

    source
    PHP Code:
    #include <windows.h>

    extern "C" {
    #include "lua/src/lua.h"
    #include "lua/src/lualib.h"
    #include "lua/src/lauxlib.h"
    }

    int lua_Test (lua_State *L) {
        
    MessageBox(NULL"Call Function""Testing"MB_OK MB_ICONEXCLAMATION);
        
    int numberOfArgs lua_gettop(L);
        
    lua_Number n 42;
        
    lua_pushnumber(Ln);
        return 
    1;
    }

    void registerLua () {
        
    MessageBox(NULL"Load registerLua""Testing"MB_OK MB_ICONEXCLAMATION);

        
    // 0x00803b70  == lua_pushcclosure; Credits: berserk85
        // 0x00804070  == lua_setfield; Credits: berserk85
        // 0x00D3F78C == lua_State

        
    lua_State *state = (lua_State*)(*(void **)0x00D3F78C); //< OFFSET need !!!

        
    unsigned char pCodeCave = (unsigned char *)0x005E7367// replace before use

        
    DWORD old;
        
    VirtualProtect((LPVOID)pCodeCave5PAGE_EXECUTE_READWRITE, &old);
        *(
    byte *)pCodeCave 0xe9;
        *(
    int *)(pCodeCave 1) = (int)lua_Test - (int)pCodeCave 5;
        
    VirtualProtect((LPVOID)pCodeCave5oldNULL);

        
    lua_pushcclosure(state, (lua_CFunction)(pCodeCave), 0);
        
    lua_setfield(state, -10002"test");
    }

    BOOL WINAPI DllMain (HINSTANCE hDLLDWORD reasonLPVOID reserved) {
        
    MessageBox(NULL"START""Testing"MB_OK MB_ICONEXCLAMATION);
        if (
    reason == DLL_PROCESS_ATTACH) {        
            
    // patch TLS to be able to access data from WoW's main thread
            
    _asm {
                
    mov eaxdword ptr fs:[0x2c
                
    mov eaxdword ptr ds:[eax]
                
    add eax// current TLS
                
    mov ebxdword ptr ds:[0x012705b0]
                
    mov ebxdword ptr ds:[eax 0x00002d94// WoW's main thread TLS
                
    mov [eax], ebx // Perform patch
            
    }
            
    registerLua();
        }
        return 
    TRUE;

    //Orginal from http://www.ownedcore.com/forums/worl..._register.html

    current lua_state (0x00D3F78C) from http://www.ownedcore.com/forums/worl...ml#post1917706
    Last edited by Blackplayer27; 03-04-2014 at 12:41 PM.

    Create a LUA function in 3.3.5a 12340
  2. #2
    Jadd's Avatar 🐸 Premium Seller
    Reputation
    1511
    Join Date
    May 2008
    Posts
    2,432
    Thanks G/R
    81/333
    Trade Feedback
    1 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    lua_statement?

  3. #3
    Blackplayer27's Avatar Active Member
    Reputation
    32
    Join Date
    Sep 2010
    Posts
    27
    Thanks G/R
    3/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Jadd View Post
    lua_statement?
    Sorry i mean lua_state.

  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)
    your offset is correct, the lua_state is at 0x00D3F78C
    but you really should add the wow module base to that address ASLR!
    Last edited by xalcon; 03-04-2014 at 04:04 PM. Reason: soooo many typos :<
    "Threads should always commit suicide - they should never be murdered" - DirectX SDK

  5. #5
    JuJuBoSc's Avatar Banned for scamming CoreCoins Purchaser
    Reputation
    1019
    Join Date
    May 2007
    Posts
    922
    Thanks G/R
    1/3
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's 3.3.5 so he don't care about ASLR I guess

  6. #6
    Blackplayer27's Avatar Active Member
    Reputation
    32
    Join Date
    Sep 2010
    Posts
    27
    Thanks G/R
    3/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  7. #7
    Jadd's Avatar 🐸 Premium Seller
    Reputation
    1511
    Join Date
    May 2008
    Posts
    2,432
    Thanks G/R
    81/333
    Trade Feedback
    1 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I notice you are using a different version of Lua as WoW. They use 5.1, you are using 5.2+. This could cause some issues for you, so first and foremost I'd suggest trying your application using the older 5.1 library.

  8. #8
    Blackplayer27's Avatar Active Member
    Reputation
    32
    Join Date
    Sep 2010
    Posts
    27
    Thanks G/R
    3/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok i try it thx

  9. #9
    Blackplayer27's Avatar Active Member
    Reputation
    32
    Join Date
    Sep 2010
    Posts
    27
    Thanks G/R
    3/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok i change nun the lua version to 5.1 but now i become a error on a other point :/
    imgur: the simple image sharer
    imgur: the simple image sharer
    imgur: the simple image sharer

    have anyone a other method to register lua functions ?

  10. #10
    Wildbreath's Avatar Contributor
    Reputation
    162
    Join Date
    Feb 2012
    Posts
    121
    Thanks G/R
    2/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    public delegate void LuaRegisterFunction(string name, uint callback);

  11. #11
    Blackplayer27's Avatar Active Member
    Reputation
    32
    Join Date
    Sep 2010
    Posts
    27
    Thanks G/R
    3/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Wildbreath View Post
    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    public delegate void LuaRegisterFunction(string name, uint callback);
    Can you give me a example how i can use this ? Im not really a pro in memory editing. But i try to learn it

  12. #12
    Wildbreath's Avatar Contributor
    Reputation
    162
    Join Date
    Feb 2012
    Posts
    121
    Thanks G/R
    2/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    delegate a function using LuaRegisterFunction offset, patch InvalidPtrCheck or create trampoline to your function and invoke delegate (c#), dont know how to do in c++
    or search a wizardry (monk healing spheres program in the forum memory editing section) and research it.

Similar Threads

  1. LUA Function Thread
    By steveo123 in forum WoW EMU Questions & Requests
    Replies: 3
    Last Post: 10-13-2008, 08:54 AM
  2. [Guide] How to use local LUA function!
    By Dartignan in forum WoW EMU Guides & Tutorials
    Replies: 0
    Last Post: 08-05-2008, 09:28 PM
  3. Replies: 22
    Last Post: 05-29-2008, 03:52 PM
  4. [Question] Lua functions
    By Lich King in forum World of Warcraft Emulator Servers
    Replies: 5
    Last Post: 04-10-2008, 07:39 PM
  5. [Guide] Creating a LUA bossfight!
    By Gastricpenguin in forum WoW EMU Guides & Tutorials
    Replies: 54
    Last Post: 03-01-2008, 09:55 PM
All times are GMT -5. The time now is 02:10 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