[3.3.5a 12340] Having all Lua events dispatched to my C# code & questions menu

User Tag List

Results 1 to 4 of 4
  1. #1
    Bitsize's Avatar Private
    Reputation
    1
    Join Date
    Oct 2012
    Posts
    3
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [3.3.5a 12340] Having all Lua events dispatched to my C# code & questions

    Hello. I'm trying to have all events dispatched to my C# code. I've been trying to figure out how to add an event listener to the Lua environment then get back the array of event descriptors from each event that's dispatched. I'm using BlackRain and BlackMagic for the injection.

    Code:
    local executiveFrame = CreateFrame("Frame", "CSharp_ExecutiveFrame");
    	executiveFrame:SetScript("OnEvent", CSharp_OnEvent); //How do I specify this in my C# code?
    	executiveFrame:RegisterEvent("VARIABLES_LOADED");
    	executiveFrame:RegisterEvent("PLAYER_LOGIN");
    	executiveFrame:RegisterEvent("PLAYER_ENTERING_WORLD");
    I've looked at this wonderful code by Apoc: http://www.ownedcore.com/forums/worl...ected-clr.html (C# Lua Wrapper (No ASM, Requires injected CLR))

    The only problem is that I'm not familiar with the standards here as I'm brand new to this scene. I don't know what the OnyxInputHandler method/function (which term is used here?) does exactly. I'm pretty darn sure it just compiles all the arguments into a List.

    Does LuaDoString take Lua code as the first parameter and execute it similar to Perl's eval? If I'm wrong how does that work?

    For these three methods what is the significance of the Onyx text? Can I change that?

    Code:
    public static void DoString(string lua)
                {
                    DoStringHandler(lua, "Onyx.lua", 0);
                }
     
                public static string[] GetReturnValues(string lua)
                {
                    DoString(string.Format("OnyxInput({0})", lua));
                    return LuaValues.ToArray();
                }
     
                public static T GetReturnVal<T>(string lua, uint retVal)
                {
                    DoString(string.Format("OnyxInput({0})", lua));
                    object tmp;
                    if (typeof(T) == typeof(bool))
                    {
                        tmp = LuaValues[(int)retVal] == "1";
                    }
                    else
                    {
                        tmp = (T)Convert.ChangeType(LuaValues[(int)retVal], typeof(T));
                    }
                    return (T)tmp;
                }
    Is the EndScene hook just when the client is finished rendering that frame?

    Is it possible to run my code from the process without overwriting valuable memory? Something about a codecave?

    What is this InvalidPtrCheck about? What do I need to know about it?
    Last edited by Bitsize; 01-26-2013 at 01:27 AM. Reason: Added one more question.

    [3.3.5a 12340] Having all Lua events dispatched to my C# code &amp; questions
  2. #2
    ament's Avatar Member
    Reputation
    7
    Join Date
    Mar 2009
    Posts
    19
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OnyxInputHandler is registered to lua function OnyxInput and to get return values all code is executed as OnyxInput(lua) since wow's framescript_execute calls to lua_pcall discards all return values.
    I just insert a jump to my function to avoid the InvalidPtrCheck.

    Code:
    IntPtr RunkEventPtr = Marshal.GetFunctionPointerForDelegate(RunkEvent);
                    fasm.Clear();
                    fasm.Add("jmp {0}", RunkEventPtr);
                    fasm.Inject(0x0040104B);
    
                    FrameScript_RegisterFunction("RunkEvent", (IntPtr)0x0040104B);
    
                    Lua.DoString("local frame = CreateFrame('Frame'); frame:RegisterAllEvents(); frame:SetScript('OnEvent', RunkEvent);");

  3. #3
    Bitsize's Avatar Private
    Reputation
    1
    Join Date
    Oct 2012
    Posts
    3
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by ament View Post
    OnyxInputHandler is registered to lua function OnyxInput and to get return values all code is executed as OnyxInput(lua) since wow's framescript_execute calls to lua_pcall discards all return values.
    I just insert a jump to my function to avoid the InvalidPtrCheck.

    Code:
    IntPtr RunkEventPtr = Marshal.GetFunctionPointerForDelegate(RunkEvent);
                    fasm.Clear();
                    fasm.Add("jmp {0}", RunkEventPtr);
                    fasm.Inject(0x0040104B);
    
                    FrameScript_RegisterFunction("RunkEvent", (IntPtr)0x0040104B);
    
                    Lua.DoString("local frame = CreateFrame('Frame'); frame:RegisterAllEvents(); frame:SetScript('OnEvent', RunkEvent);");
    Is that OOP or in?

    Can anyone answer the other questions?

  4. #4
    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)
    Hook FrameScript_SignalEvent. This is the function that dispatches events.

Similar Threads

  1. What To Do once you have all scammed infos of the account!!
    By Premium-mmo in forum WoW Scam Prevention
    Replies: 49
    Last Post: 07-04-2008, 09:09 AM
  2. [Release] Portal Lua Event
    By Spartansp in forum World of Warcraft Emulator Servers
    Replies: 28
    Last Post: 02-04-2008, 09:46 AM
  3. Where have all the hacks gone?
    By Shinyshoes in forum WoW EMU Exploits & Bugs
    Replies: 2
    Last Post: 01-26-2008, 02:57 PM
  4. Antrix/ascent ID search 4.0. Updated to have ALL GO and NPC IDs for ascent.
    By Equ1N0X in forum World of Warcraft Emulator Servers
    Replies: 3
    Last Post: 11-02-2007, 07:28 PM
  5. [Question] Have all AreaTriggers been tested?
    By dreamhacker in forum WoW ME Questions and Requests
    Replies: 4
    Last Post: 10-28-2007, 02:45 AM
All times are GMT -5. The time now is 03:31 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