LUA's, and ToStrings, and Bears? Oh My! menu

User Tag List

Results 1 to 14 of 14
  1. #1
    Harland's Avatar Member
    Reputation
    8
    Join Date
    Oct 2007
    Posts
    50
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    LUA's, and ToStrings, and Bears? Oh My!

    Harro,

    So I was working on my LUA wrapper last night and have hit a bump. Despite to extensive resources found via search, I am still having issues returning results with ToString.

    I am executing all my Lua in WoW's main thread via an EndScene hook, so scope isn't the issue. It appears that I have not understood the concept of FrameScript_Execute [0x007F25C0] entirely, I believe a majority of people label this as DoString....

    Anyways in dodgy pseudocode if I were to call in WoW's main thread:
    Anyways lets assume I were to call the luaCommand UnitGUID("unit") where unit is some unit in my vicinity. Below is some dodgy psuedocode I would call the following. Please assume all the functions have been hooked appropriately with the offsets mentioned below. Also assume function typedefs have been correctly declared as Bobbysings WoWX Base.
    Code:
    //Offsets
    //GetState            = 0x7F1160;
    //GetTop              = 0x826D80;
    //ToString            = 0x827290;
    //FrameScript_Execute = 0x007F25C0;
    
    FrameScript_Execute(luaCommand, 0, GetState());
    int n = GetTop(GetState());
    ToString(GetState(), n, 0);
    What I would like to know is, should ToString() return a char * to the result returned by UnitGUID("unit")? Or is UnitGUID("unit") not pushing the GUID string to the luaStack?

    Now I have seen Apoc post that he simply calls DoString -> GetTop -> ToLString. I must be missing something though.

    One thing I notice is GetTop() always returns 0 for me (even after calling DoString numerous times), indicating the stack size has not increased at all.

    I really do not want to use GetLocalizedText, Cypher has given many good reasons as to why. Although my Bot is not public or commercial (I only share it with close friends), I still do not wish to use the GetLocalizedText method.

    ISXWoW's method of grabbing values elludes me right now, is it entirely necessary to register your own Lua Function in order to return results?

    I'm open to any suggestions to get the DoString -> GetTop -> ToLString method working.

    LUA's, and ToStrings, and Bears? Oh My!
  2. #2
    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)
    I register a callback to do all my calls through.

    Pass 0 for the lua_State param, so when it hits your callback you have a 'fresh' stack to work with.

  3. #3
    Harland's Avatar Member
    Reputation
    8
    Join Date
    Oct 2007
    Posts
    50
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah okay well that makes sense I'll go that route.

  4. #4
    Xarg0's Avatar Member
    Reputation
    61
    Join Date
    Jan 2008
    Posts
    389
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're going to register your own lua callback you'll have to do something about the isFunctionPtrInRange function, otherwise wow will crash when it tries to execute your lua function.
    It's rather easy to trick the function, you coud for example just write a jmp to your lua callback into a codecave in wow and register it as your lua function, there are also serveral other ways to work around the functionptr check and I'd strongly suggest you to not patch the function, some parts are occupied by the warden, atleast they were occupied a year ago.
    I hacked 127.0.0.1

  5. #5
    Azzie2k8's Avatar Member
    Reputation
    11
    Join Date
    Apr 2009
    Posts
    190
    Thanks G/R
    0/0
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    since apoc was so nice and linked me there here is something really useful

    http://www.mmowned.com/forums/wow-me...ected-clr.html

    as Xarg0 said you will need to patch the InvalidPointerFunction which is easy allthough robske told me how to do so (thanks )

  6. #6
    audible83's Avatar Member
    Reputation
    4
    Join Date
    Jun 2008
    Posts
    48
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Programming in Lua : contents

    It has alot of info when you dont know how lua works...

  7. #7
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A better solution is loadbuffer/pcall, but that takes a bit more RE'ing than just calling FramescriptExcecute.
    Don't believe everything you think.

  8. #8
    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)
    Don't patch the pointer check function, that's just stupid.

    Just create a code cave somewhere in the .text section to jump to your func, and register your code cave's address instead.

  9. #9
    Harland's Avatar Member
    Reputation
    8
    Join Date
    Oct 2007
    Posts
    50
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for all the suggestions, most I have come across already during my browsing on the forum. I've finally got some moments to code now, so I'll see how I go.

  10. #10
    Harland's Avatar Member
    Reputation
    8
    Join Date
    Oct 2007
    Posts
    50
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Grrrr Shynd's Black Magic has spoiled me rotten....his BlackMagic Fasm wrapper made code caving easy. I have a problem, i'm trying to WriteProcessMemory to my codecave to jump to my lua function. Does anyone have some suggestions on how to convert an __asm block to bytes so that I may redirect flow to my lua function.

    Perhaps some better terms to type into Google would be much appreciated :P

    Edit: Forgot to mention i'm writing this in C++.
    Last edited by Harland; 02-18-2010 at 04:58 AM.

  11. #11
    kynox's Avatar Member
    Reputation
    830
    Join Date
    Dec 2006
    Posts
    888
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Harland View Post
    Grrrr Shynd's Black Magic has spoiled me rotten....his BlackMagic Fasm wrapper made code caving easy. I have a problem, i'm trying to WriteProcessMemory to my codecave to jump to my lua function. Does anyone have some suggestions on how to convert an __asm block to bytes so that I may redirect flow to my lua function.

    Perhaps some better terms to type into Google would be much appreciated :P

    Edit: Forgot to mention i'm writing this in C++.
    asmjit - Project Hosting on Google Code

  12. #12
    Harland's Avatar Member
    Reputation
    8
    Join Date
    Oct 2007
    Posts
    50
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers Kynox, I'm so happy I could kiss your sister right now. It's ashame Cypher gave her herpes though.

  13. #13
    kynox's Avatar Member
    Reputation
    830
    Join Date
    Dec 2006
    Posts
    888
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Harland View Post
    Cheers Kynox, I'm so happy I could kiss your sister right now. It's ashame Cypher gave her herpes though.
    Hilarious. Really.

  14. #14
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Harland View Post
    Cheers Kynox, I'm so happy I could kiss your sister right now. It's ashame Cypher gave her herpes though.
    Kynox's mum told me she was clean. She lied.

Similar Threads

  1. LUA Portal and Patch 2.4.3
    By edcbabe in forum World of Warcraft Emulator Servers
    Replies: 4
    Last Post: 07-29-2008, 09:33 PM
  2. Replies: 1
    Last Post: 03-23-2008, 11:34 PM
  3. [Ascent MOD] Reload LUA scripts and Script_bin!
    By Le Froid in forum World of Warcraft Emulator Servers
    Replies: 5
    Last Post: 01-03-2008, 10:29 PM
  4. Tauren cat -> thekal and bear -> worgen
    By ampax in forum WoW ME Questions and Requests
    Replies: 3
    Last Post: 07-08-2007, 07:11 PM
  5. Tauren cat -> thekal and bear -> worgen
    By ampax in forum WoW ME Questions and Requests
    Replies: 0
    Last Post: 06-16-2007, 12:24 AM
All times are GMT -5. The time now is 02:23 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