IDA Scripts menu

User Tag List

Thread: IDA Scripts

Results 1 to 9 of 9
  1. #1
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1354
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    IDA Scripts

    Here's a (very sucky) IDA script to rename all the Lua callbacks:
    Code:
    from idaapi import *
    from idc import *
    
    # RegisterLuaCallback = 0x005C0920 (eso.live.1.0.0.941004)
    
    def RenameFunc(callback, name):
      if MakeNameEx(callback, name, SN_NOCHECK | SN_NOWARN) is False:
        print "Failed to rename callback. Attempting to append suffix."
        renamed = False
        for i in range(1, 10):
          name2 = str(name) + "_" + str(i)
          if MakeNameEx(callback, name2, SN_NOCHECK | SN_NOWARN) is True:
            renamed = True
            break
        if renamed is not True:
          raise Exception, "Failed to rename callback"
    
    ea = ScreenEA()
    
    func = get_func(ea)
    
    if func is None:
      raise Exception, "Invalid function for RegisterLuaCallback"
    
    funcea = func.startEA
    print "RegisterLuaCallback is function %s at 0x%x" % (GetFunctionName(funcea), funcea)
    
    for ref in CodeRefsTo(funcea, 1):
      print "RegisterLuaCallback called from %s (0x%x)" % (GetFunctionName(ref), ref)
      namestr = GetString(Dword(ref - 7 + 1))
      print "Callback name is %s" % (namestr)
      callback = Dword(ref - 0xC + 1)
      print "Callback function is %s (0x%x)" % (GetFunctionName(callback), callback)
      newfuncname = "Lua_" + str(namestr)
      print "Renaming callback %s (0x%x) as %s" % (GetFunctionName(callback), callback, newfuncname)
      RenameFunc(callback, newfuncname)
    
    print "Finished"
    I'm lazy so you'll have to set the cursor to the RegisterLuaCallback function yourself, it won't find it for you (although I've put the offset in a comment so you don't have to).

    And here's one to rename the metatables:
    Code:
    from idaapi import *
    from idc import *
    
    # RegisterLuaMetatable = 0x005BDA10 (eso.live.1.0.0.941004)
    
    def RenameFunc(callback, name):
      if MakeNameEx(callback, name, SN_NOCHECK | SN_NOWARN) is False:
        print "Failed to rename callback. Attempting to append suffix."
        renamed = False
        for i in range(1, 10):
          name2 = str(name) + "_" + str(i)
          if MakeNameEx(callback, name2, SN_NOCHECK | SN_NOWARN) is True:
            renamed = True
            break
        if renamed is not True:
          raise Exception, "Failed to rename callback"
    
    ea = ScreenEA()
    
    func = get_func(ea)
    
    if func is None:
      raise Exception, "Invalid function for RegisterLuaMetatable"
    
    funcea = func.startEA
    print "RegisterLuaMetatable is function %s at 0x%x" % (GetFunctionName(funcea), funcea)
    
    for ref in CodeRefsTo(funcea, 1):
      print "RegisterLuaMetatable called from %s (0x%x)" % (GetFunctionName(ref), ref)
      namestr = GetString(Dword(ref - 5 + 1))
      print "Metatable name is %s" % (namestr)
      callback = Dword(ref - 0xF + 1)
      print "Metatable function is %s (0x%x)" % (GetFunctionName(callback), callback)
      newfuncname = "Lua_" + str(namestr)
      print "Renaming callback %s (0x%x) as %s" % (GetFunctionName(callback), callback, newfuncname)
      RenameFunc(callback, newfuncname)
      metatable = Dword(ref - 0xA + 1)
      print "Metatable is 0x%x" % (metatable)
      i = 0
      while Dword(metatable + i * 4) != 0:
        callbacknamestr = GetString(Dword(metatable + i * 4))
        callbackptr = Dword(metatable + i * 4 + 4)
        MakeUnkn(callbackptr, DOUNK_SIMPLE)
        MakeFunction(callbackptr)
        print "Callback function is %s (0x%x)" % (GetFunctionName(callbackptr), callbackptr)
        callbacknamestrnew = "Lua_" + str(namestr) + "_" + str(callbacknamestr)
        print "Renaming callback %s (0x%x) as %s" % (GetFunctionName(callbackptr), callbackptr, callbacknamestrnew)
        RenameFunc(callbackptr, callbacknamestrnew)
        i = i + 2
    
    print "Finished"
    Again, you'll have to set the cursor yourself, but I've put the offset in the script.
    Last edited by Ket; 03-25-2014 at 09:02 AM.

    These ads disappear when you log in.

  2. #2
    viperbot's Avatar Contributor
    Reputation
    104
    Join Date
    Jan 2012
    Posts
    599
    Thanks G/R
    2/54
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    *nevermind*
    Last edited by viperbot; 03-28-2014 at 01:14 PM.
    ]

  3. #3
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1354
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah I had tagged that as RegisterLuaEvent but apparently it's used for the enums also. Thanks!

    Found the func to actually run Lua code? I was going to hunt for that tomorrow but I won't say no if you want to save me some time.
    Last edited by Cypher; 03-29-2014 at 06:48 AM.

  4. #4
    viperbot's Avatar Contributor
    Reputation
    104
    Join Date
    Jan 2012
    Posts
    599
    Thanks G/R
    2/54
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, but there is a ExecuteChatCommand lua function might call it eventually. (I believe, since as in wow, you can do /script luacode).
    Last edited by viperbot; 03-22-2014 at 03:37 PM.
    ]

  5. #5
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1354
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by viperbot View Post
    No, but there is a ExecuteChatCommand lua function might call it eventually. (I believe, since as in wow, you can do /script luacode).
    Yeah, I saw that one but I didn't see a 'script' chat command callback... I'm only looking statically though, so I may have missed it, but there's also no "RunScript" Lua callback like there is in WoW.

    EDIT: There's definitely a /played callback and that's not in the strings. I thought I saw others but maybe I was wrong. So yeah, that's actually probably a good place to start, thanks for the tip. Just wish I could actually log into the world, it would make everything so much easier to be able to actually debug things.
    Last edited by Cypher; 03-22-2014 at 10:29 PM.

  6. #6
    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)
    Originally Posted by Cypher View Post
    Found the func to actually run Lua code? I was going to hunt for that tomorrow but I won't say no if you want to save me some time.
    For eso.live.1.0.0.941004 :

    Code:
    009BE020 char __thiscall ZoLuaVM::DoString(int this, const char *apBuffer, unsigned int aBufferSize, char aIsTrusted, const char *apIdentifier)

  7. #7
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1354
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by JuJuBoSc View Post
    For eso.live.1.0.0.941004 :

    Code:
    009BE020 char __thiscall ZoLuaVM::DoString(int this, const char *apBuffer, unsigned int aBufferSize, char aIsTrusted, const char *apIdentifier)
    Thanks JuJu, you're awesome!

  8. #8
    viperbot's Avatar Contributor
    Reputation
    104
    Join Date
    Jan 2012
    Posts
    599
    Thanks G/R
    2/54
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @JuJuBoSc, if you dont mind giving a quick lesson. How do you find something like that? Hook a known lua funtion and work backwards?
    ]

  9. #9
    Sirmabus's Avatar Sergeant
    Reputation
    34
    Join Date
    Jun 2008
    Posts
    69
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I made my own similar IDA Pro Python scripts to gather and name the Lua register methods and constants
    (TESO API ref here: ESOUI API)

    For the register methods it names them with the register name/label with a "_lua" suffix, and saves out a sorted list to "eso_lua_methods.csv".
    For the constants ("global constants", "events", etc., as seen in the API docs) are saved to sorted list "eso_lua_constants.csv".
    From here one could easily make these output to some sort of a header file et al.
    TESO_Lua_Parser_Scripts.zipIDA Scripts-tesoluascriptsexample1-jpgIDA Scripts-luamethodscsvexample-jpgIDA Scripts-luaconstantscsvexample-jpg
    Last edited by Sirmabus; 04-04-2014 at 02:13 AM.

Similar Threads

  1. IDA script / plugin
    By violentmagician in forum WoW Memory Editing
    Replies: 5
    Last Post: 09-19-2012, 06:19 PM
  2. [4.2.2+][mac] IDA Scripts - Dump Descriptors + label DBCs
    By Tanaris4 in forum WoW Memory Editing
    Replies: 5
    Last Post: 09-28-2011, 12:55 AM
  3. [IDA Script][Mac][4.1] Marking LUA functions
    By Tanaris4 in forum WoW Memory Editing
    Replies: 2
    Last Post: 04-23-2011, 12:37 AM
  4. IDA Scripts
    By kynox in forum WoW Memory Editing
    Replies: 20
    Last Post: 08-13-2009, 10:51 AM
  5. [IDA Script] Label Packet Handlers
    By kynox in forum WoW Memory Editing
    Replies: 5
    Last Post: 07-26-2009, 08:08 AM
All times are GMT -5. The time now is 06:41 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2021 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2021 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search