How to Use lua_tostring menu

User Tag List

Results 1 to 8 of 8
  1. #1
    demonguy's Avatar Member
    Reputation
    2
    Join Date
    Feb 2012
    Posts
    111
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to Use lua_tostring

    Here is my code

    Code:
    DWORD *Add = (DWORD *)((ModuleBase) + t_luaState);
    lua_State *State = (lua_State *)*Add;
    s_luapushcclosure(State,(lua_CFunction)os_execute,0);
    s_lua_setfield(State,LUA_GLOBALSINDEX,"OSexecute");
    the define of struct lua_State is in lua.h (version 5.1.4)
    And the i get "Add" by tracing "lua_newstate" and it's 0xABEF10 of 4.3.4(rebased)


    Code:
    int os_execute (lua_State *L) {
      MessageBox(NULL,"1","2",0);
      LUATOSTRING s_lua_tostring = (LUATOSTRING)((ModuleBase) + t_lua_tostring);
      MessageBox(NULL,"1",s_lua_tostring(L,-1),0);
      return 0;
    }
    i have modified "FrameScript::InvalidPtrChec" , So it won't work

    it works fine when i run the macro in WOW as "/run print("OSexecute")"
    but when i run "/run OSexecute("123")", after the first MessageBox, WOW crashes... who knows why?
    Last edited by demonguy; 04-28-2012 at 10:36 PM.

    How to Use lua_tostring
  2. #2
    l0l1dk's Avatar Elite User

    Reputation
    499
    Join Date
    Sep 2010
    Posts
    342
    Thanks G/R
    1/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You shouldn't need to cast os_execute to a lua_CFunction when calling s_luapushcclosure; it should already be one. Make sure that os_execute's calling convention is __cdecl. If it isn't __cdecl it will cause the stack will be misaligned after it is called, causing a crash. If that isn't the problem then you should be able to figure out what's causing it by looking at the crash log.

  3. #3
    demonguy's Avatar Member
    Reputation
    2
    Join Date
    Feb 2012
    Posts
    111
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My default calling convention is __cdecl so the problem won't be it ....

    And there is my crash info , I don't know how to debug a injected DLL ... So i don't know how to get information from the crash info ~~~


    Someone says that WOW's lua_State is different from standard lua struct lua_State..... is that true??

    How to Use lua_tostring-1-jpg

  4. #4
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1. Use c++ style casts
    2. Use a consisten naming scheme
    3. http://www.ownedcore.com/forums/worl...ml#post2181478 (Warden confusion?)
    4. Lua 5.1 Reference Manual , so lua_tostring is just a macro around lua_tolstring which has an additional parameter. This means you **** up you stack when calling it with less parameters.

  5. #5
    namreeb's Avatar Legendary

    Reputation
    668
    Join Date
    Sep 2008
    Posts
    1,029
    Thanks G/R
    8/222
    Trade Feedback
    0 (0%)
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by demonguy View Post
    Someone says that WOW's lua_State is different from standard lua struct lua_State..... is that true??
    Yes. Or at least it used to be.

  6. #6
    demonguy's Avatar Member
    Reputation
    2
    Join Date
    Feb 2012
    Posts
    111
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Bananenbrot View Post
    1. Use c++ style casts
    2. Use a consisten naming scheme
    3. http://www.ownedcore.com/forums/worl...ml#post2181478 (Warden confusion?)
    4. Lua 5.1 Reference Manual , so lua_tostring is just a macro around lua_tolstring which has an additional parameter. This means you **** up you stack when calling it with less parameters.

    Thanks..... I solved it ....
    i misused "luaV_tostring" found in IDA as "lua_tostring"....... So it totally a wrong function .....

    But i have another question.... When i includes all lua standard source code , and try to call standard c function by passing WOW's lua_State,,, it always failed. Why?
    Last edited by demonguy; 04-30-2012 at 02:01 AM.

  7. #7
    migtron's Avatar Corporal
    Reputation
    18
    Join Date
    Jun 2010
    Posts
    22
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by demonguy View Post
    But i have another question.... When i includes all lua standard source code , and try to call standard c function by passing WOW's lua_State,,, it always failed. Why?
    That's because Blizzard is not using stock Lua, but a highly modified version (e.g. to implement the concept of "code taint" to prevent addons from botting). So if you call the "official" Lua functions with Blizzard's lua_State, you are providing them with a different data structure than they expect, leading to errors and/or crashed.

  8. #8
    demonguy's Avatar Member
    Reputation
    2
    Join Date
    Feb 2012
    Posts
    111
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by migtron View Post
    That's because Blizzard is not using stock Lua, but a highly modified version (e.g. to implement the concept of "code taint" to prevent addons from botting). So if you call the "official" Lua functions with Blizzard's lua_State, you are providing them with a different data structure than they expect, leading to errors and/or crashed.
    Oh i see.... Thanks

Similar Threads

  1. GUIDE: HOW TO USE TORRENTS (Look inside)
    By Hounro in forum Community Chat
    Replies: 14
    Last Post: 01-22-2007, 09:04 PM
  2. How to use fish bot?
    By Pixo in forum World of Warcraft Guides
    Replies: 0
    Last Post: 01-04-2007, 07:01 PM
  3. Hunter Pets how to use them to gank lowbies
    By Demonicmaster in forum World of Warcraft Exploits
    Replies: 4
    Last Post: 12-21-2006, 04:35 PM
  4. How To: use .rar files.
    By raamoz in forum World of Warcraft Guides
    Replies: 3
    Last Post: 11-06-2006, 02:51 PM
All times are GMT -5. The time now is 10:15 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