public DebugEventResponse OnChildProcessCreated(int threadID,
				IProcessDebuggerService child, out IDebugEventListener childListener)
			{
				var childProcess = new ProcessDebugger(child);
				childListener = childProcess.eventListener;
				throw new NotImplementedException();
			}
Beispiel #2
0
        public override bool HandleException(ref CONTEXT ctx, ProcessDebugger pd)
        {
            ctx.Eax  = 0xFF;    // light density
            ctx.Eip += 0xEB;    // skip code

            return(true);
        }
Beispiel #3
0
        // .text:00536238 F3 0F 11 0D EC+                movss   dword_1B134EC, xmm1
        public override bool HandleException(ref CONTEXT ctx, ProcessDebugger pd)
        {
            ctx.Eip += 8;

            WriteVals(1000, 1000, pd);
            return true;
        }
Beispiel #4
0
        public override bool HandleException(ref CONTEXT ctx, ProcessDebugger pd)
        {
            ctx.Al  &= 0;
            ctx.Eip += 4;

            return(true);
        }
Beispiel #5
0
        public override bool HandleException(ref CONTEXT ctx, ProcessDebugger pd)
        {
            ctx.Esi  = Game.GetViewingUnit();
            ctx.Eip += 6;

            return(true);
        }
Beispiel #6
0
 private void processesComboBox_SelectionChangeCommitted(object sender, EventArgs e)
 {
     ResetButtonText(false);
     if (pd != null)
     {
         pd.StopDebugging();
         pd.Join();
         pd = null;
     }
 }
Beispiel #7
0
 public void CanStartDebugOnNewProcess()
 {
     using (var dbg = new ProcessDebugger())
     {
         dbg.Start(SimpleCrackMe);
         var debugEvent = dbg.Wait.NextEvent();
         Assert.Equal(DebugEventType.CreateProcessEvent, debugEvent.EventType);
         debugEvent = dbg.Continue.Until(DebugEventType.ExitProcessEvent);
         Assert.Equal(DebugEventType.ExitProcessEvent, debugEvent.EventType);
     }
 }
Beispiel #8
0
 public void CanDebugProcessToEndAndGetExitCode()
 {
     using (var dbg = new ProcessDebugger())
     {
         dbg.Start(SimpleCrackMe);
         var returnCode = dbg.Continue.ToEnd();
         Assert.NotNull(dbg.ExitCode);
         Assert.Equal(0, dbg.ExitCode.Value);
         Assert.Equal(returnCode, dbg.ExitCode.Value);
     }
 }
Beispiel #9
0
        private void DetachHacks()
        {
            timer.Stop();

            if (pd != null)
            {
                pd.StopDebugging();
                pd.Join();
                pd = null;
            }
        }
Beispiel #10
0
 public static void ShouldNotCrashIfDetachAtBreakpoint()
 {
     using (var dbg = new ProcessDebugger())
     {
         dbg.Start(SimpleCrackMe);
         dbg.Wait.NextEvent();
         Breakpoint breakPoint = dbg.Breakpoints.AtEntryPoint();
         dbg.BreakingThread.Continue.UntilBreakpoint(breakPoint);
         dbg.BreakingThread.Continue.Run();
     }
 }
Beispiel #11
0
 public void CanCrack()
 {
     using (var dbg = new ProcessDebugger())
     {
         PatchJNZ(dbg);
         dbg.Patches.ModifyImage(dbg.Debuggee.MainModule, "SimpleCrackMe-Patched.exe");
         Assert.Equal(1, dbg.Continue.ToEnd());   //Resolved !!!!
         var result = StartAndGetReturnCode("SimpleCrackMe-Patched.exe");
         Assert.Equal(1, result);                 //Patched !!!!
     }
 }
Beispiel #12
0
        private void DetachHacks()
        {
            timer.Stop();

            if (pd != null)
            {
                pd.StopDebugging();
                pd.Join();
                pd = null;
            }
        }
Beispiel #13
0
 public static void CanStepIn()
 {
     using (var dbg = new ProcessDebugger())
     {
         dbg.Start(SimpleCrackMe);
         Breakpoint breakPoint = dbg.Breakpoints.AtEntryPoint();
         dbg.BreakingThread.Continue.UntilBreakpoint(breakPoint);
         dbg.BreakingThread.StepByStep = true;
         AssertIsSingleStep(dbg.Wait.NextEvent());
         AssertIsSingleStep(dbg.Wait.NextEvent());
     }
 }
Beispiel #14
0
        public bool Install()
        {
            if (!Exists())
            {
                return(false);
            }

            try
            {
                pd = new ProcessDebugger(process.Id);
                pd.Run();

                var now = DateTime.Now;
                while (!pd.WaitForComeUp(50) && now.MSecToNow() < 1000)
                {
                }

                foreach (ProcessThread pT in process.Threads)
                {
                    if (pd.GetThreadStartAddress(pT.Id) == pd.GetAddress(D2Pointers.Game.mainThread))
                    {
                        mainThreadId = pT.Id;
                        break;
                    }
                }

                ApplySettings();
            }
            catch
            {
                return(false);
            }

            CheckInGame(true);

            overlay      = new OverlayWindow();
            overlay.game = this;
            overlay.PostCreate();
            overlay.InGameStateChanged(InGame);

            AutoTeleport = new AutoTeleHandler(this);
            Pickit       = new Pickit(this);
            PlayerInfo   = new PlayerInfo(this);
            MapHandler   = new MapHandler(this);

            syncTimer.Start();
            gameCheckTimer.Start();
            selectedUnitTimer.Start();

            return(true);
        }
Beispiel #15
0
        public bool Detach()
        {
            if (overlay != null)
            {
                overlay.Close();
                overlay.Dispose();
                overlay = null;
            }

            syncTimer.Stop();
            gameCheckTimer.Stop();
            selectedUnitTimer.Stop();

            if (Pickit != null)
            {
                Pickit.Stop();
                Pickit = null;
            }

            if (MapHandler != null)
            {
                MapHandler.Reset();
                MapHandler = null;
            }

            if (AutoTeleport != null)
            {
                AutoTeleport.Terminate();
                AutoTeleport = null;
            }

            PlayerInfo = null;

            if (Installed)
            {
                try
                {
                    pd.StopDebugging();
                    pd.Join();
                    pd = null;
                }
                catch
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #16
0
        public override bool HandleException(ref CONTEXT ctx, ProcessDebugger pd)
        {
            var viewingUnit = Game.GetViewingUnit();

            //var val = pd.ReadUInt(ctx.Edi);
            //if (val != 1)
            ctx.Edi = viewingUnit;

            //ctx.Ecx = pd.ReadUInt(ctx.Edi + 0x60);
            //ctx.Eip += 3;

            ctx.Eip += 7;

            return(true);
        }
Beispiel #17
0
        public void CanGetRVAFromPdbPublicServerOrExport()
        {
            using (var dbg = new ProcessDebugger())
            {
                dbg.Start(SimpleCrackMe);

                var symbol = dbg.SymbolManager.FromName("kernel32.dll", "_GetStdHandle@4");
                Assert.NotNull(symbol);
                Assert.Equal(SymbolType.Pdb, symbol.Type);

                symbol = dbg.SymbolManager.FromName("kernel32.dll", "GetStdHandle");
                Assert.NotNull(symbol);
                Assert.Equal(SymbolType.Export, symbol.Type);
            }
        }
Beispiel #18
0
        public void Start()
        {
            try
            {
                pd = new ProcessDebugger(process.Id);
                var breakpoints = new List <HardwareBreakPoint>();
                var data        = BuildDatas.ContainsKey(build) ? BuildDatas[build] : null;

                if (data != null)
                {
                    breakpoints.Add(new CascBreakpoint1(data.CascOffs1));
                    breakpoints.Add(new CascBreakpoint2(data.CascOffs2));
                }
                else
                {
                    throw new Exception("No offset data for build " + build);
                }

                pd.Run();

                var time = DateTime.Now;

                PrettyLogger.WriteLine(ConsoleColor.Yellow, "Attaching to {0}...", process.GetVersionInfo());
                PrettyLogger.WriteLine(ConsoleColor.Yellow, "Waiting 5 sec to come up...");
                while (!pd.WaitForComeUp(50) && time.MSecToNow() < 5000)
                {
                }

                if (!pd.IsDebugging)
                {
                    throw new Exception("Failed to start logger");
                }

                PrettyLogger.WriteLine(ConsoleColor.Yellow, "Installing breakpoints...");
                foreach (var bp in breakpoints)
                {
                    pd.AddBreakPoint(bp);
                }

                PrettyLogger.WriteLine(ConsoleColor.Magenta, "Successfully attached to {0} PID: {1}.",
                                       process.GetVersionInfo(), process.Id);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Beispiel #19
0
        private Patch PatchJNZ(ProcessDebugger dbg)
        {
            dbg.Start(SimpleCrackMe);
            RVA mainRVA = dbg.SymbolManager.FromName("SimpleCrackMe.exe", "main").RVA; //new RVA(0x113D0);
            RVA jnzRVA  = new RVA(0x113F2);                                            // mainRVA + 0x22;

            dbg.Wait.NextEvent();
            Breakpoint breakPoint = dbg.Breakpoints.At("SimpleCrackMe.exe", mainRVA);

            dbg.BreakingThread.Continue.UntilBreakpoint(breakPoint);
            var disasm   = dbg.BreakingThread.Continue.UntilInstruction("JNZ");
            var expected = dbg.AddressOfModule("SimpleCrackMe.exe") + jnzRVA;
            var actual   = dbg.BreakingThread.CurrentInstruction;

            Assert.Equal(expected, actual);
            return(dbg.BreakingThread.WriteInstruction("NOP", true));
        }
Beispiel #20
0
 public static void CanBreakAtEntryThenSkipBreakpointNextStepIn()
 {
     using (var dbg = new ProcessDebugger())
     {
         dbg.Start(SimpleCrackMe);
         Breakpoint breakPoint = dbg.Breakpoints.AtEntryPoint();
         var        evt        = dbg.BreakingThread.Continue.UntilBreakpoint(breakPoint);
         Assert.NotNull(evt);
         Assert.True(evt.Details.IsFirstChance);
         Assert.True(evt.Details.Exception.Reason == ExceptionReason.ExceptionBreakpoint);
         Assert.Equal(dbg.Debuggee.MainModule.EntryPointAddress, breakPoint.Address.ToIntPtr());
         Assert.Equal(breakPoint.Address.ToIntPtr(), dbg.BreakingThread.ThreadContext.EIP);
         Assert.Equal(dbg.Debuggee.MainModule.EntryPointAddress, evt.Details.Exception.Address);
         var nextEvent = dbg.BreakingThread.Wait.NextEvent();                 //Does not throw a trap
         Assert.NotEqual(DebugEventType.ExceptionEvent, nextEvent.EventType);
     }
 }
Beispiel #21
0
 public static void BreakpointDoesNotCancelStepIn()
 {
     using (var dbg = new ProcessDebugger())
     {
         dbg.Start(SimpleCrackMe);
         dbg.Wait.NextEvent();
         dbg.BreakingThread.StepByStep = true;
         Breakpoint breakPoint = dbg.Breakpoints.AtEntryPoint();
         dbg.Continue.UntilBreakpoint(breakPoint);
         var address = dbg.BreakingThread.CurrentInstruction;
         Assert.Equal(breakPoint.Address, address);
         AssertIsSingleStep(dbg.Wait.NextEvent());
         AssertIsSingleStep(dbg.Wait.NextEvent());
         dbg.BreakingThread.StepByStep = false;
         dbg.BreakingThread.GoTo(address);
         AssertIsBreakpoint(dbg.BreakingThread.Wait.NextEvent());
         AssertIsNotSingleStep(dbg.BreakingThread.Wait.NextEvent());
     }
 }
Beispiel #22
0
        public void CanPatchAndUnpatch()
        {
            using (var dbg = new ProcessDebugger())
            {
                PatchJNZ(dbg);
                Assert.Equal(1, dbg.Continue.ToEnd());
            }

            using (var dbg = new ProcessDebugger())
            {
                PatchJNZ(dbg).Undo();
                Assert.Equal(0, dbg.Continue.ToEnd());
            }
            using (var dbg = new ProcessDebugger())
            {
                var patch = PatchJNZ(dbg);
                patch.Undo();
                patch.Redo();
                Assert.Equal(1, dbg.Continue.ToEnd());
            }
        }
Beispiel #23
0
        public override bool HandleException(ref CONTEXT ctx, ProcessDebugger pd)
        {
            ctx.Al   = pd.ReadByte(ctx.Ebp + 0x12A);
            ctx.Eip += 6;

            var pString = ctx.Edi;
            var pItem   = ctx.Ebx;
            var str     = pd.ReadUTF16String(pString);
            //"ÿc";
            //str = "ÿc1" + str;

            var item     = pd.Read <UnitAny>(pItem);
            var itemData = pd.Read <ItemData>(item.pItemData);

            var changed = false;

            var appendix = "";

            if (Game.Settings.ItemNameHack.ShowItemCode.IsEnabled())
            {
                var pTxt = Game.GetItemText(item.dwTxtFileNo);
                var txt  = pd.Read <ItemTxt>(pTxt);
                appendix += "(" + txt.GetCode() + ")";
            }

            if (Game.Settings.ItemNameHack.ShowEth.IsEnabled() && (itemData.dwFlags & 0x400000) != 0)
            {
                appendix += "{E}";
            }

            var runeNumber = item.RuneNumber();

            if (runeNumber > 0 && Game.Settings.ItemNameHack.ShowRuneNumber.IsEnabled())
            {
                appendix += "(" + runeNumber + ")";
            }

            if (Game.Settings.ItemNameHack.ShowSockets.IsEnabled())
            {
                var cnt = Game.GetItemSockets(pItem, item.dwUnitId);

                if (cnt > 0 && cnt != uint.MaxValue)
                {
                    appendix += "(" + cnt + ")";
                }
            }

            if (Game.Settings.ItemNameHack.ShowItemLevel.IsEnabled() && itemData.dwItemLevel > 1)
            {
                appendix += "(L" + itemData.dwItemLevel + ")";
            }

            if (Game.Settings.ItemNameHack.ShowItemPrice.IsEnabled())
            {
                var price = Game.GetItemPrice(pItem, item.dwUnitId);

                if (price > 0 && price != uint.MaxValue)
                {
                    appendix += "($" + price + ")";
                }
            }

            if (Game.Settings.ItemNameHack.ChangeItemColor.IsEnabled())
            {
                var itemInfo = ItemStorage.GetInfo(item.dwTxtFileNo);
                if (itemInfo != null)
                {
                    var sock          = Game.GetItemSockets(pItem, item.dwUnitId);
                    var configEntries = Game.ItemProcessingSettings.GetMatches(itemInfo, sock,
                                                                               (itemData.dwFlags & 0x400000) != 0, (ItemQuality)itemData.dwQuality).Where(it => it.Color != D2Color.Default);
                    if (configEntries.Count() != 0)
                    {
                        var entry = configEntries.First();
                        str     = "ÿc" + entry.Color.GetCode() + str;
                        changed = true;
                    }
                }
            }

            if (appendix != "")
            {
                str    += " " + appendix;
                changed = true;
            }

            if (changed)
            {
                pd.WriteUTF16String(pString, str);
            }

            return(true);
        }
Beispiel #24
0
        private void startStopButton_Click(object sender, EventArgs e)
        {
            if (pd != null)
            {
                try
                {
                    DetachHacks();
                    ResetButtonText(false);
                }
                catch (Exception ex)
                {
                    ShowError(ex.Message);
                }
                return;
            }

            var procInfo = processesComboBox.SelectedItem as ProcessInfo;
            if (procInfo == null)
            {
                ShowError("Select a process!");
                return;
            }

            try
            {
                if (Process.GetProcessById(procInfo.Id) == null)
                {
                    ShowError(string.Format("Can't find process '{0}'!", procInfo.DisplayName));
                    return;
                }
            }
            catch (Exception ex)
            {
                ShowError(string.Format("Error: {0}", ex.Message));
                return;
            }

            try
            {
                pd = new ProcessDebugger(procInfo.Id);
                using (var md5 = MD5.Create())
                {
                    var hash = md5.ComputeHash(File.ReadAllBytes(pd.Process.MainModule.FileName));
                    Debug.WriteLine(pd.Process.MainModule.FileVersionInfo);
                    Debug.WriteLine(string.Format("MD5: {0}", string.Join(", ", hash.Select(it => string.Format("0x{0:X2}", it)).ToArray())));
                    if (!hash.SequenceEqual(MainForm.hash))
                        throw new Exception("Hash does not match. Probably newer version of WoT executable.");
                }
                pd.Run();
                var now = DateTime.Now;
                while (!pd.WaitForComeUp(50) && now.MSecToNow() < 1000)
                { }
                ToggleHacks();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
                return;
            }

            ResetButtonText(true);
        }
Beispiel #25
0
 private void processesComboBox_SelectionChangeCommitted(object sender, EventArgs e)
 {
     ResetButtonText(false);
     if (pd != null)
     {
         pd.StopDebugging();
         pd.Join();
         pd = null;
     }
 }
Beispiel #26
0
        private void startStopButton_Click(object sender, EventArgs e)
        {
            if (pd != null)
            {
                try
                {
                    DetachHacks();
                    ResetButtonText(false);
                }
                catch (Exception ex)
                {
                    ShowError(ex.Message);
                }
                return;
            }

            var procInfo = processesComboBox.SelectedItem as ProcessInfo;

            if (procInfo == null)
            {
                ShowError("Select a process!");
                return;
            }

            try
            {
                if (Process.GetProcessById(procInfo.Id) == null)
                {
                    ShowError(string.Format("Can't find process '{0}'!", procInfo.DisplayName));
                    return;
                }
            }
            catch (Exception ex)
            {
                ShowError(string.Format("Error: {0}", ex.Message));
                return;
            }

            try
            {
                pd = new ProcessDebugger(procInfo.Id);
                using (var md5 = MD5.Create())
                {
                    var hash = md5.ComputeHash(File.ReadAllBytes(pd.Process.MainModule.FileName));
                    Debug.WriteLine(pd.Process.MainModule.FileVersionInfo);
                    Debug.WriteLine(string.Format("MD5: {0}", string.Join(", ", hash.Select(it => string.Format("0x{0:X2}", it)).ToArray())));
                    if (!hash.SequenceEqual(MainForm.hash))
                    {
                        throw new Exception("Hash does not match. Probably newer version of WoT executable.");
                    }
                }
                pd.Run();
                var now = DateTime.Now;
                while (!pd.WaitForComeUp(50) && now.MSecToNow() < 1000)
                {
                }
                ToggleHacks();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
                return;
            }

            ResetButtonText(true);
        }
			internal MemoryStream(ProcessDebugger debugger)
			{
				Contract.Requires(debugger != null);
				this.debugger = debugger;
			}
        public override bool HandleException(ref CONTEXT ctx, ProcessDebugger pd)
        {
            bool skip = false;

            var pPacket = ctx.Edi;
            var len     = ctx.Edx;

            var packet = pd.ReadBytes(pPacket, (int)len);

            //MessageBox.Show(packet.ToString());

            switch ((GameServerPacket)packet[0])
            {
            case GameServerPacket.RemoveGroundUnit:
            {
                if (!Game.Settings.ReceivePacketHack.ItemTracker.EnablePickit.IsEnabled())
                {
                    break;
                }

                Game.ItemGoneHandler(packet);
                break;
            }

            case GameServerPacket.GameObjectModeChange:
            {
                if (!Game.Settings.ReceivePacketHack.NoTownPortalAnim.IsEnabled())
                {
                    break;
                }

                // no portal anim #1
                var pUnit = Game.FindUnit(BitConverter.ToUInt32(packet, 2), (UnitType)packet[1]);
                if (pUnit != 0)
                {
                    var unit = pd.Read <UnitAny>(pUnit);
                    if (unit.dwTxtFileNo == 0x3B)
                    {
                        skip = true;
                    }
                }

                break;
            }

            case GameServerPacket.PlayerReassign:
            {
                if (!Game.Settings.ReceivePacketHack.BlockFlash.IsEnabled() &&
                    !Game.Settings.ReceivePacketHack.FastTele.IsEnabled() &&
                    !Game.Settings.ReceivePacketHack.ItemTracker.EnablePickit.IsEnabled())
                {
                    break;
                }

                var unitType = (UnitType)packet[1];
                if (unitType != UnitType.Player)
                {
                    break;
                }

                var pPlayer = Game.GetPlayerUnit();
                if (pPlayer == 0)
                {
                    break;
                }

                var unit = pd.Read <UnitAny>(pPlayer);
                if (BitConverter.ToUInt32(packet, 2) == unit.dwUnitId)
                {
                    if (Game.Settings.ReceivePacketHack.ItemTracker.EnablePickit.IsEnabled())
                    {
                        Game.CurrentX = BitConverter.ToUInt16(packet, 6);
                        Game.CurrentY = BitConverter.ToUInt16(packet, 8);
                        Task.Factory.StartNew(() => Game.OnRelocaton());
                    }

                    // no flash
                    if (Game.Settings.ReceivePacketHack.BlockFlash.IsEnabled())
                    {
                        pd.WriteByte(pPacket + 10, 0);
                    }

                    // fast teleport
                    if (Game.Settings.ReceivePacketHack.FastTele.IsEnabled() && !allowableModes.Contains((PlayerMode)unit.dwMode))
                    {
                        unit.dwFrameRemain = 0;
                        pd.Write <UnitAny>(pPlayer, unit);
                    }
                }
                break;
            }

            case GameServerPacket.Unknown18:
            case GameServerPacket.PlayerLifeManaChange:
            {
                if (!Game.Settings.Chicken.Enabled || Game.chickening)
                {
                    break;
                }

                var life = BitConverter.ToUInt16(packet, 1);
                var mana = BitConverter.ToUInt16(packet, 3);
                Task.Factory.StartNew(() => Game.TryChicken(life, mana, false));
                break;
            }

            case GameServerPacket.GameObjectAssignment:
            {
                if ((UnitType)packet[1] == UnitType.Object && BitConverter.ToUInt16(packet, 6) == 0x3B)
                {
                    // no portal anim #2
                    if (Game.Settings.ReceivePacketHack.NoTownPortalAnim.IsEnabled())
                    {
                        pd.WriteByte(pPacket + 12, 2);
                    }

                    UnitAny unit;
                    if (Game.backToTown && Game.GetPlayerUnit(out unit))
                    {
                        if (!Game.IsInTown())
                        {
                            var path = pd.Read <Path>(unit.pPath);
                            if (Misc.Distance(path.xPos, path.yPos, BitConverter.ToUInt16(packet, 8), BitConverter.ToUInt16(packet, 10)) < 10)
                            {
                                Task.Factory.StartNew(() => Game.Interact(BitConverter.ToUInt32(packet, 2), UnitType.Object));
                            }
                        }
                        Game.backToTown = false;
                    }
                }
                break;
            }

            case GameServerPacket.PlayerInfomation:      // event message
            {
                var type         = packet[1];
                var infoType     = packet[2];
                var relationType = packet[7];
                if (type == 0x7 && infoType == 8 && relationType == 3)
                {
                    if (!Game.Settings.Chicken.ChickenOnHostility.IsEnabled() || Game.chickening)
                    {
                        break;
                    }

                    Task.Factory.StartNew(() => Game.TryChicken(0, 0, true));
                }
                break;
            }

            case GameServerPacket.WorldItemAction:
            case GameServerPacket.OwnedItemAction:
            {
                skip = !Game.ItemActionHandler(packet);
                break;
            }

            case GameServerPacket.DelayedState:
            {
                // skip delay between entering portals
                if (Game.Settings.ReceivePacketHack.NoTownPortalAnim.IsEnabled() && packet[6] == 102)
                {
                    skip = true;
                }
                break;
            }

            case GameServerPacket.TriggerSound:
            {
                if (Game.Settings.ReceivePacketHack.ItemTracker.EnablePickit.IsEnabled())
                {
                    if (packet[1] == 0 && packet[6] == 0x17)
                    {
                        Game.Pickit.Disable(PickitDisableReason.InventoryFull);
                    }
                }
                break;
            }

            case GameServerPacket.AttributeByte:
            case GameServerPacket.AttributeWord:
            case GameServerPacket.AttributeDWord:
            {
                var  attr = (StatType)packet[1];
                uint val  = 0;
                switch ((GameServerPacket)packet[0])
                {
                case GameServerPacket.AttributeByte:
                    val = (uint)packet[2];
                    break;

                case GameServerPacket.AttributeWord:
                    val = BitConverter.ToUInt16(packet, 2);
                    break;

                case GameServerPacket.AttributeDWord:
                    val = (uint)((packet[5] << 16) | (packet[4] << 8) | packet[3]);
                    break;
                }

                Game.PlayerInfo.SetStat(attr, val);
                break;
            }

            case GameServerPacket.StateNotification:
            {
                /*var uid = BitConverter.ToUInt32(packet, 1);
                 * var attr = (StatType)packet[5];
                 * var value = BitConverter.ToUInt32(packet, 6);
                 *
                 * UnitAny player;
                 * if (!Game.GetPlayerUnit(out player))
                 *  break;
                 *
                 * if (player.dwUnitId != uid)
                 *  break;
                 *
                 * Game.PlayerInfo.SetStat(attr, value);*/
                break;
            }
            }

            if (!skip)
            {
                ctx.Ecx  = ctx.Edi;
                ctx.Eip += 2;
            }
            else
            {
                ctx.Esp += 4;
                ctx.Eip += 7;
                ctx.Eax  = 0;
            }

            return(true);
        }
Beispiel #29
0
		private static Instruction Decode(InstructionDecoder decoder, ProcessDebugger debugger, ForeignPtr ptr)
		{
			var reader = new BinaryReader(debugger.OpenMemory(ptr));
			while (decoder.Feed(reader.ReadByte())) { }
			return decoder.GetInstruction();
		}
Beispiel #30
0
 // .text:00534BCE 8A 45 FF                       mov     al, [ebp+var_1
 public override bool HandleException(ref CONTEXT ctx, ProcessDebugger pd)
 {
     ctx.Eip += 3;
     ctx.Al = 1;
     return true;
 }
			// Called on worker thread
			internal Thread(ProcessDebugger process, int id)
			{
				Contract.Requires(process != null);
				this.process = process;
				this.id = id;
			}
Beispiel #32
0
        public override bool HandleException(ref CONTEXT ctx, ProcessDebugger pd)
        {
            // Esi - pUnit
            var hide = false;

            var pUnit = ctx.Esi;

            if (pUnit == 0)
            {
                hide = true;
            }
            else if (Game.Settings.Infravision.HideCorpses.IsEnabled() || Game.Settings.Infravision.HideDying.IsEnabled() || Game.Settings.Infravision.HideItems.IsEnabled())
            {
                var unit = pd.Read <UnitAny>(pUnit);
                switch ((UnitType)unit.dwType)
                {
                case UnitType.Monster:
                {
                    if (Game.Settings.Infravision.HideCorpses.IsEnabled() &&
                        unit.dwMode == (uint)NpcMode.Dead ||
                        Game.Settings.Infravision.HideDying.IsEnabled() &&
                        unit.dwMode == (uint)NpcMode.Death)
                    {
                        hide = true;
                    }
                    break;
                }

                case UnitType.Item:
                {
                    if (!Game.Settings.Infravision.HideItems.IsEnabled())
                    {
                        break;
                    }

                    var itemInfo = ItemStorage.GetInfo(unit.dwTxtFileNo);
                    if (itemInfo != null)
                    {
                        var itemData = pd.Read <ItemData>(unit.pItemData);
                        var pTxt     = Game.GetItemText(unit.dwTxtFileNo);
                        var txt      = pd.Read <ItemTxt>(pTxt);

                        var sock          = Game.GetItemSockets(pUnit, unit.dwUnitId);
                        var configEntries = Game.ItemProcessingSettings.GetMatches(itemInfo, sock,
                                                                                   (itemData.dwFlags & 0x400000) != 0, (ItemQuality)itemData.dwQuality).Where(it => it.Hide);
                        if (configEntries.Count() != 0)
                        {
                            hide = true;
                        }
                    }
                    break;
                }
                }
            }

            ctx.Eax = hide ? 1u : 0u;

            ctx.Eip += 0x77;

            return(true);
        }
			public EventListener(ProcessDebugger owner)
			{
				this.owner = owner;
			}