Understanding FrameScript_GetTop menu

Shout-Out

User Tag List

Results 1 to 10 of 10
  1. #1
    Neverhaven's Avatar Member
    Reputation
    12
    Join Date
    Sep 2009
    Posts
    25
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Understanding FrameScript_GetTop

    I'm trying to use FrameScript_GetTop to get values returned from functions, as an alternative to FrameScript__GetLocalizedText, to see if it's faster, however it doesn't seem to work properly. Here's how it use it:
    Code:
    ...
        Lua.Print("Interface.FrameScript__GetTop() = " + Interface.FrameScript_GetTop());
        Lua.DoString("print('test'); return 'test';");
        Lua.Print("Interface.FrameScript__GetTop() = " + Interface.FrameScript_GetTop());
    ...
    And here's what it prints:
    Code:
    Interface.FrameScript__GetTop() = 0
    Interface.FrameScript__GetTop() = 0
    However, according to the lua manual, it should print this
    Code:
    Interface.FrameScript__GetTop() = 0
    Interface.FrameScript__GetTop() = 1
    Anyone able to help me out, or point in a direction so i can figure out what's wrong?
    Last edited by Neverhaven; 09-17-2010 at 02:06 PM.

    Understanding FrameScript_GetTop
  2. #2
    Cheatz0's Avatar Member
    Reputation
    14
    Join Date
    May 2009
    Posts
    36
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As far as i know, DoString does not push any values on the stack. Therefore, GetTop() will return 0 in both cases.

  3. #3
    eLaps's Avatar Active Member
    Reputation
    34
    Join Date
    Sep 2007
    Posts
    123
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to register a lua callback to get returned values from lua functions.

  4. #4
    ramey's Avatar Member
    Reputation
    45
    Join Date
    Jan 2008
    Posts
    320
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by eLaps View Post
    You need to register a lua callback to get returned values from lua functions.
    Need would be wrong term to use. You don't need to, but you can.

  5. #5
    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)
    The lua fuction called "DoString" is not the lua one. Its common name around here is FrameScript_Execute. Basically if you reverse the function you will see a call to lua_pcall with nresults set to 0.

    EDIT: Btw is should add that if you want to find all the lua functions. Just download the Lua 5.1 binary. Disassemble it, IDA recognizes all the function names because of the debug info. Then just use the patchdiff plug-in to do a comparison.
    Last edited by jjaa; 09-18-2010 at 09:01 PM.

  6. #6
    Neverhaven's Avatar Member
    Reputation
    12
    Join Date
    Sep 2009
    Posts
    25
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by jjaa View Post
    The lua fuction called "DoString" is not the lua one. Its common name around here is FrameScript_Execute. Basically if you reverse the function you will see a call to lua_pcall with nresults set to 0.

    EDIT: Btw is should add that if you want to find all the lua functions. Just download the Lua 5.1 binary. Disassemble it, IDA recognizes all the function names because of the debug info. Then just use the patchdiff plug-in to do a comparison.
    Yea, i kinda figured that after taking a look at the FrameScript_Execute in IDA. That explains why the arguments doesn't match those of luaL_dostring. So, is using the native luaL_dostring just as safe as FrameScript_Execute? I don't mean in terms of getting caught/detected, but in terms of not crashing and so.

  7. #7
    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 Neverhaven View Post
    Yea, i kinda figured that after taking a look at the FrameScript_Execute in IDA. That explains why the arguments doesn't match those of luaL_dostring. So, is using the native luaL_dostring just as safe as FrameScript_Execute? I don't mean in terms of getting caught/detected, but in terms of not crashing and so.

    looking at the include files, luaL_dostring is just a macro. The wow devs just made there own version. Hence FrameScript_Execute.

    #define luaL_dostring(L, s) \

    (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
    Last edited by jjaa; 09-19-2010 at 12:30 AM.

  8. #8
    Neverhaven's Avatar Member
    Reputation
    12
    Join Date
    Sep 2009
    Posts
    25
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This might sound like an akward solution, but do you think it'd work if i change the FrameScript_Execute function temporarily, so that i change the two calls to FrameScript_PCall, so that instead of passing 0 nresults, i pass -1 nresults? Or should i just do the luaL_loadstring || lua_pcall? Btw, i tried the patchdiff plugin, very nice plugin, but it didn't find luaL_loadstring in wow. Which file should i load first? Also, i found binaries for lua 5.1.4 and not 5.1.0 if that's a problem.

  9. #9
    saagarp's Avatar Private
    Reputation
    1
    Join Date
    Aug 2010
    Posts
    4
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As jjaa stated, there is no function named luaL_dostring. It's a preprocessor macro, and no symbol is created for it at compile-time. See source here. If this doesn't make sense, I don't know where to point you. Sorry.

    When luaL_dostring is referenced, it is automatically split into a call to LoadString and a call to pcall.

    Your options, as stated in numerous other places on the forum, are:
    1) write and register a custom LUA wrapper to take the arguments and then parse them. Continue calling FrameScript_Execute.
    2) manually call loadstring, pcall, parse elements off the LUA stack, and restore the stack to the previous state.

    Personally I choose option 2, and found that the LUA reference page was fantastic for information. Especially this. Once you grasp how the stack functions, pulling the elements off is very simple using lua_gettop/lua_type/lua_to[whatever].

    EDIT: wanted to add in response to your question:
    > but do you think it'd work if i change the FrameScript_Execute function temporarily, so that i change the two calls to FrameScript_PCall, so that instead of passing 0 nresults, i pass -1 nresults?

    I'm sure that, SOMEHOW, you could make it work. You'd end up having to demangle the stack in your own routine afterwards anyways, and FrameScript_Execute isn't really that complicated of a function to reverse. I think IDA reversed it to approximately 10 lines of code. Run Hex-Rays over it, get the function addresses you need, and call pcall yourself.
    Last edited by saagarp; 09-20-2010 at 12:21 PM.

  10. #10
    MaiN's Avatar Elite User
    Reputation
    335
    Join Date
    Sep 2006
    Posts
    1,047
    Thanks G/R
    0/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Changing FrameScript::Execute is not a good idea. It is used internally by WoW in some places.
    [16:15:41] Cypher: caus the CPU is a dick
    [16:16:07] kynox: CPU is mad
    [16:16:15] Cypher: CPU is all like
    [16:16:16] Cypher: whatever, i do what i want

Similar Threads

  1. Auctioneer and Bottomscanner: understanding and using
    By devilish_hunter in forum World of Warcraft Guides
    Replies: 22
    Last Post: 11-12-2011, 03:16 PM
  2. Understanding Outdoor Instances
    By TheDipper in forum World of Warcraft General
    Replies: 6
    Last Post: 10-20-2007, 02:56 AM
  3. understanding
    By friendofdar in forum World of Warcraft Emulator Servers
    Replies: 1
    Last Post: 09-07-2007, 08:05 PM
  4. I just don't understand...
    By Tory in forum Gaming Chat
    Replies: 6
    Last Post: 09-23-2006, 12:49 AM
  5. Understand Opposing Faction Chat (Adanvced)
    By Matt in forum World of Warcraft Exploits
    Replies: 11
    Last Post: 08-09-2006, 02:47 AM
All times are GMT -5. The time now is 06:11 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