示例#1
0
        /// <summary>
        /// Target a GUID by calling WoW's clientGameUITarget function
        /// </summary>
        /// <param name="guid">guid to target</param>
        public static void TargetGUID(ulong guid, [CallerMemberName] string functionName = "")
        {
            AmeisenLogger.Instance.Log(LogLevel.DEBUG, $"TargetGUID: {guid}", "AmeisenCore", functionName);
            //BlackMagic.WriteUInt64(Offsets.localTargetGuid, guid);

            byte[]   guidBytes = BitConverter.GetBytes(Convert.ToUInt64(guid));
            string[] asm       = new string[]
            {
                $"PUSH {BitConverter.ToUInt32(guidBytes, 4)}",
                $"PUSH {BitConverter.ToUInt32(guidBytes, 0)}",
                $"CALL {Offsets.clientGameUITarget}",
                "ADD ESP, 0x8",
                "RETN"
            };

            // add our hook-job to process it
            HookJob hookJob = new HookJob(asm, false);

            AmeisenHook.AddHookJob(ref hookJob);

            // wait for the hook-job to return to us
            while (!hookJob.IsFinished)
            {
                Thread.Sleep(1);
            }
        }
示例#2
0
        /// <summary>
        /// Execute the given LUA command inside WoW's MainThread
        /// </summary>
        /// <param name="command">lua command to run</param>
        public static void LuaDoString(string command)
        {
            AmeisenLogger.Instance.Log(LogLevel.VERBOSE, $"Doing string: Command [{command}]", "AmeisenCore");
            uint argCC = BlackMagic.AllocateMemory(Encoding.UTF8.GetBytes(command).Length + 1);

            BlackMagic.WriteBytes(argCC, Encoding.UTF8.GetBytes(command));

            string[] asm = new string[]
            {
                $"MOV EAX, {(argCC)}",
                "PUSH 0",
                "PUSH EAX",
                "PUSH EAX",
                $"CALL {(Offsets.luaDoString)}",
                "ADD ESP, 0xC",
                "RETN",
            };

            HookJob hookJob = new HookJob(asm, false);

            AmeisenHook.AddHookJob(ref hookJob);

            while (!hookJob.IsFinished)
            {
                Thread.Sleep(1);
            }

            AmeisenLogger.Instance.Log(LogLevel.VERBOSE, $"Command returned: Command [{command}]", "AmeisenCore");
            BlackMagic.FreeMemory(argCC);
        }
示例#3
0
        /// <summary>
        /// Execute the given LUA command inside WoW's MainThread
        /// </summary>
        /// <param name="command">lua command to run</param>
        public static void LuaDoString(string command)
        {
            AmeisenLogger.Instance.Log(LogLevel.VERBOSE, $"Doing string: Command [{command}]", "AmeisenCore");
            // reserve memory for our command and write its bytes to the memory
            uint argCC = BlackMagic.AllocateMemory(Encoding.UTF8.GetBytes(command).Length + 1);

            BlackMagic.WriteBytes(argCC, Encoding.UTF8.GetBytes(command));

            string[] asm = new string[]
            {
                $"MOV EAX, {(argCC)}",
                "PUSH 0",
                "PUSH EAX",
                "PUSH EAX",
                $"CALL {(Offsets.luaDoString)}",
                "ADD ESP, 0xC",
                "RETN",
            };

            // add our hook job to be executed on hook
            HookJob hookJob = new HookJob(asm, false);

            AmeisenHook.AddHookJob(ref hookJob);

            // wait for our hook to return
            while (!hookJob.IsFinished)
            {
                Thread.Sleep(1);
            }

            AmeisenLogger.Instance.Log(LogLevel.VERBOSE, $"Command returned: Command [{command}]", "AmeisenCore");
            BlackMagic.FreeMemory(argCC); // free our codecaves memory
        }
示例#4
0
        /// <summary>
        /// Get Localized Text for command aka. read a lua variable
        /// </summary>
        /// <param name="command">lua command to run</param>
        /// <param name="variable">variable to read</param>
        /// <returns>
        /// Localized text for the executed functions
        /// return value, variable content or whatever
        /// you want to read.
        /// </returns>
        public static string GetLocalizedText(string command, string variable)
        {
            if (command.Length > 0 && variable.Length > 0)
            {
                // allocate memory for our command
                uint argCCCommand = BlackMagic.AllocateMemory(Encoding.UTF8.GetBytes(command).Length + 1);
                BlackMagic.WriteBytes(argCCCommand, Encoding.UTF8.GetBytes(command));

                string[] asmDoString = new string[]
                {
                    $"MOV EAX, {(argCCCommand) }",
                    "PUSH 0",
                    "PUSH EAX",
                    "PUSH EAX",
                    $"CALL {(Offsets.luaDoString)}",
                    "ADD ESP, 0xC",
                    "RETN",
                };

                // allocate memory for our variable
                uint argCC = BlackMagic.AllocateMemory(Encoding.UTF8.GetBytes(variable).Length + 1);
                BlackMagic.WriteBytes(argCC, Encoding.UTF8.GetBytes(variable));

                string[] asmLocalText = new string[]
                {
                    $"CALL {(Offsets.clientObjectManagerGetActivePlayerObject)}",
                    "MOV ECX, EAX",
                    "PUSH -1",
                    $"PUSH {(argCC)}",
                    $"CALL {(Offsets.luaGetLocalizedText)}",
                    "RETN",
                };

                HookJob       hookJobLocaltext = new HookJob(asmLocalText, true);
                ReturnHookJob hookJobDoString  = new ReturnHookJob(asmDoString, false, hookJobLocaltext);

                // add our hook-job to be executed
                AmeisenHook.AddHookJob(ref hookJobDoString);

                // wait for our hook-job to return
                while (!hookJobDoString.IsFinished)
                {
                    Thread.Sleep(1);
                }

                // parse the result bytes to a readable string
                string result = Encoding.UTF8.GetString((byte[])hookJobDoString.ReturnValue);
                AmeisenLogger.Instance.Log(LogLevel.VERBOSE, "DoString(" + command + "); => " + variable + " = " + result, "AmeisenCore");

                // free our memory
                BlackMagic.FreeMemory(argCCCommand);
                BlackMagic.FreeMemory(argCC);
                return(result);
            }
            return("");
        }
示例#5
0
        /// <summary>
        /// Get Localized Text for command
        /// </summary>
        /// <param name="command">lua command to run</param>
        /// <param name="variable">variable to read</param>
        /// <returns>localized text for the executed functions return value</returns>
        public static string GetLocalizedText(string command, string variable)
        {
            if (command.Length > 0 && variable.Length > 0)
            {
                uint argCCCommand = BlackMagic.AllocateMemory(Encoding.UTF8.GetBytes(command).Length + 1);
                BlackMagic.WriteBytes(argCCCommand, Encoding.UTF8.GetBytes(command));

                string[] asmDoString = new string[]
                {
                    $"MOV EAX, {(argCCCommand) }",
                    "PUSH 0",
                    "PUSH EAX",
                    "PUSH EAX",
                    $"CALL {(Offsets.luaDoString)}",
                    "ADD ESP, 0xC",
                    "RETN",
                };

                uint argCC = BlackMagic.AllocateMemory(Encoding.UTF8.GetBytes(variable).Length + 1);
                BlackMagic.WriteBytes(argCC, Encoding.UTF8.GetBytes(variable));

                uint playerBase = BlackMagic.ReadUInt(Offsets.playerBase);
                playerBase = BlackMagic.ReadUInt(playerBase + 0x34);
                playerBase = BlackMagic.ReadUInt(playerBase + 0x24);

                string[] asmLocalText = new string[]
                {
                    $"CALL {(Offsets.clientObjectManagerGetActivePlayerObject)}",
                    "MOV ECX, EAX",
                    "PUSH -1",
                    $"PUSH {(argCC)}",
                    $"CALL {(Offsets.luaGetLocalizedText)}",
                    "RETN",
                };

                HookJob       hookJobLocaltext = new HookJob(asmLocalText, true);
                ReturnHookJob hookJobDoString  = new ReturnHookJob(asmDoString, false, hookJobLocaltext);

                AmeisenHook.AddHookJob(ref hookJobDoString);

                while (!hookJobDoString.IsFinished || !hookJobDoString.IsFinished)
                {
                    Thread.Sleep(5);
                }

                string result = Encoding.UTF8.GetString((byte[])hookJobDoString.ReturnValue);

                AmeisenLogger.Instance.Log(LogLevel.VERBOSE, "DoString(" + command + "); => " + variable + " = " + result, "AmeisenCore");

                BlackMagic.FreeMemory(argCCCommand);
                BlackMagic.FreeMemory(argCC);
                return(result);
            }
            return("");
        }
示例#6
0
        /// <summary>
        /// Target a GUID
        /// </summary>
        /// <param name="guid">guid to target</param>
        public static void TargetGUID(ulong guid)
        {
            AmeisenLogger.Instance.Log(LogLevel.DEBUG, $"TargetGUID: {guid}", "AmeisenCore");
            //BlackMagic.WriteUInt64(Offsets.localTargetGUID, guid);

            byte[]   guidBytes = BitConverter.GetBytes(guid);
            string[] asm       = new string[]
            {
                $"PUSH {BitConverter.ToUInt32(guidBytes, 4)}",
                $"PUSH {BitConverter.ToUInt32(guidBytes, 0)}",
                $"CALL {Offsets.clientGameUITarget}",
                "ADD ESP, 0x8",
                "RETN"
            };

            HookJob hookJob = new HookJob(asm, false);

            AmeisenHook.AddHookJob(ref hookJob);

            while (!hookJob.IsFinished)
            {
                Thread.Sleep(1);
            }
        }
示例#7
0
 public void AddHookJob(ref HookJob hookJob)
 {
     hookJobs.Enqueue(hookJob);
 }
示例#8
0
 /// <summary>
 /// Build a job to execute on the endscene hook
 /// </summary>
 /// <param name="asm">ASM to execute</param>
 /// <param name="readReturnBytes">read the return bytes</param>
 /// <param name="chainedJob">
 /// Job to execute after running the main Job, for example GetLocalizedText stuff
 /// </param>
 public ReturnHookJob(string[] asm, bool readReturnBytes, HookJob chainedJob) : base(asm, readReturnBytes)
 {
     ChainedJob = chainedJob;
 }