Пример #1
0
        public void UsePower(uint actorPtr, uint acdPtr, D3PowerInfo power)
        {
            uint flagAddress = GetAddress("UsePower_Flag");

            d3.WriteObject(GetAddress("UsePower_PowerInfo"), power, typeof(D3PowerInfo));
            d3.WriteUInt(GetAddress("UsePower_ActorPtr"), actorPtr);
            d3.WriteUInt(GetAddress("UsePower_AcdPtr"), acdPtr);
            d3.WriteInt(flagAddress, 1);

            while (d3.ReadInt(flagAddress) == 1)
            {
                Thread.Sleep(1);
            }
        }
Пример #2
0
        public byte[] InjectAndExecute(string[] asm)
        {
            while (InjectionUsed)
            {
                Thread.Sleep(5);
            }
            InjectionUsed = true;

            // Hook Wow:
            Hooking();

            byte[] tempsByte = new byte[0];

            // reset return value pointer
            Memory.WriteInt(retnInjectionAsm, 0);

            if (Memory.IsProcessOpen && threadHooked)
            {
                // Write the asm stuff
                Memory.Asm.Clear();
                foreach (string tempLineAsm in asm)
                {
                    Memory.Asm.AddLine(tempLineAsm);
                }

                // Allocation Memory
                uint injectionAsm_Codecave = Memory.AllocateMemory(Memory.Asm.Assemble().Length);



                // Inject
                Memory.Asm.Inject(injectionAsm_Codecave);
                Memory.WriteInt(addresseInjection, (int)injectionAsm_Codecave);
                while (Memory.ReadInt(addresseInjection) > 0)
                {
                    Thread.Sleep(5); Console.WriteLine("Wait..");
                }                                                                                               // Wait to launch code



                byte        Buf       = new Byte();
                List <byte> retnByte  = new List <byte>();
                uint        dwAddress = Memory.ReadUInt(retnInjectionAsm);
                Buf = Memory.ReadByte(dwAddress);
                while (Buf != 0)
                {
                    retnByte.Add(Buf);
                    dwAddress = dwAddress + 1;
                    Buf       = Memory.ReadByte(dwAddress);
                }
                tempsByte = retnByte.ToArray();


                // Free memory allocated
                Memory.FreeMemory(injectionAsm_Codecave);
            }
            InjectionUsed = false;
            // return
            return(tempsByte);
        }
Пример #3
0
 public static bool IsInGame(int processId)
 {
     try
     {
         // init memory
         var memory = new BlackMagic(processId);
         //
         System.Diagnostics.Process processById = System.Diagnostics.Process.GetProcessById(processId);
         uint baseModule = 0;
         foreach (ProcessModule v in from ProcessModule v in memory.Modules
                  where String.Equals(v.ModuleName, (processById.ProcessName + ".exe"), StringComparison.CurrentCultureIgnoreCase)
                  select v)
         {
             baseModule = (uint)v.BaseAddress;
         }
         return((memory.ReadInt(baseModule + (uint)Addresses.GameInfo.isLoading) == 0) && (memory.ReadByte(baseModule + (uint)Addresses.GameInfo.gameState) > 0));
     }
     catch (Exception e)
     {
         Logging.WriteError("IsInGame(int processId): " + e);
     }
     return(false);
 }
Пример #4
0
        public static Structs.PatternList FindPatternList(Structs.PatternList patternList)
        {
            Structs.PatternList newPatternList = new Structs.PatternList();
            newPatternList.processName = patternList.processName;
            uint baseModule = 0;

            BlackMagic memread = new BlackMagic();

            if (memread.OpenProcessAndThread(SProcess.GetProcessFromProcessName(patternList.processName)))
            {
                try
                {
                    // Dump module
                    ProcessModuleCollection modules = Process.GetProcessById(memread.ProcessId).Modules;
                    foreach (ProcessModule o in modules)
                    {
                        Structs.ModuleList m = new Structs.ModuleList();
                        m.Name           = o.ModuleName;
                        m.baseAddressDec = (int)o.BaseAddress;
                        m.baseAddressHex = (o.BaseAddress).ToString("X");
                        patternList.Modules.Add(m);

                        // Check module base if exist.
                        if (patternList.baseModuleName != "")
                        {
                            if (patternList.baseModuleName.ToLower() == o.ModuleName.ToLower())
                            {
                                baseModule = (uint)o.BaseAddress;
                            }
                        }
                    }
                }
                catch { }

                foreach (Structs.Pattern p in patternList.Patterns)
                {
                    try
                    {
                        uint dwCodeLoc = memread.FindPattern(p.pattern, p.mask);
                        uint offset    = memread.ReadUInt((uint)((int)dwCodeLoc + p.offsetLocation));
                        if (offset > 0)
                        {
                            offset    = offset - baseModule;
                            dwCodeLoc = dwCodeLoc - baseModule;
                        }


                        if (offset > 0)
                        {
                            // Dump offset
                            p.offset          = offset.ToString("X");
                            p.offsetDec       = offset;
                            p.offsetUsedAtDec = (uint)((int)dwCodeLoc + p.offsetLocation);
                            p.offsetUsedAt    = ((int)dwCodeLoc + p.offsetLocation).ToString("X");
                            try
                            {
                                switch (p.type)
                                {
                                case "int64":
                                    p.value = Convert.ToString(memread.ReadUInt64(p.offsetDec));
                                    break;

                                case "int":
                                    p.value = Convert.ToString(memread.ReadInt(p.offsetDec));
                                    break;

                                case "float":
                                    p.value = Convert.ToString(memread.ReadFloat(p.offsetDec));
                                    break;

                                case "string":
                                    p.value = Convert.ToString(memread.ReadASCIIString(p.offsetDec, 30));
                                    break;
                                }
                            }
                            catch { p.value = "No Found"; }
                        }
                        else
                        {
                            p.offset = "No Found";
                        }
                    }
                    catch
                    { p.offset = "No Found"; }
                    newPatternList.Patterns.Add(p);
                }
                memread.Close();
            }
            else
            {
                MessageBox.Show("Process no found.");
            }
            return(patternList);
        }
Пример #5
0
        public byte[] InjectAndExecute(string[] asm)
        {
            while (ExecutingCode)
            {
                System.Threading.Thread.Sleep(5);
            }

            ExecutingCode = true;

            HookApplication();

            byte[] tempsByte = new byte[0];

            // reset return value pointer
            process.WriteInt(returnAddress, 0);

            if (process.IsProcessOpen && mainThreadHooked)
            {
                // Write the asm stuff
                process.Asm.Clear();
                foreach (string tempLineAsm in asm)
                {
                    process.Asm.AddLine(tempLineAsm);
                }

                // Allocation Memory
                int  codeSize = process.Asm.Assemble().Length;
                uint injectionAsm_Codecave = process.AllocateMemory(codeSize);


                try
                {
                    // Inject
                    process.Asm.Inject(injectionAsm_Codecave);
                    process.WriteInt(injectionAddress, (int)injectionAsm_Codecave);

                    // Wait to launch code
                    while (process.ReadInt(injectionAddress) > 0)
                    {
                        System.Threading.Thread.Sleep(5);
                    }

                    byte        Buf       = new Byte();
                    List <byte> retnByte  = new List <byte>();
                    uint        dwAddress = process.ReadUInt(returnAddress);
                    Buf = process.ReadByte(dwAddress);
                    while (Buf != 0)
                    {
                        retnByte.Add(Buf);
                        dwAddress = dwAddress + 1;
                        Buf       = process.ReadByte(dwAddress);
                    }
                    tempsByte = retnByte.ToArray();
                }
                catch { }

                // Free memory allocated
                process.FreeMemory(injectionAsm_Codecave);
            }

            DisposeOfHook();

            ExecutingCode = false;

            return(tempsByte);
        }
Пример #6
0
 /// <summary>
 /// Check if the player's world is loaded
 /// </summary>
 /// <returns>true if yes, false if no</returns>
 public static bool CheckWorldLoaded()
 {
     return(BlackMagic.ReadInt(Offsets.worldLoaded) == 1);
 }
Пример #7
0
 /// <summary>
 /// Get our active ZoneID
 /// </summary>
 /// <returns>zoneid that wer'e currently in</returns>
 public static int GetZoneID()
 {
     return(BlackMagic.ReadInt(Offsets.zoneID));
 }
Пример #8
0
 /// <summary>
 /// Get our current MapID
 /// </summary>
 /// <returns>mapid</returns>
 public static int GetMapID()
 {
     return(BlackMagic.ReadInt(Offsets.mapID));
 }
Пример #9
0
 public int ReadInt(uint dwAddress)
 {
     return(D3.ReadInt(dwAddress, false, buffer));
 }
Пример #10
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (Utils.IsUserAdministrator())
            {
                Utils.SYSTEM_INFO sys_info = new Utils.SYSTEM_INFO();
                Utils.GetSystemInfo(out sys_info);

                IntPtr proc_min_address   = sys_info.minimumApplicationAddress;
                IntPtr proc_max_address   = sys_info.maximumApplicationAddress;
                long   proc_min_address_l = (long)proc_min_address;
                long   proc_max_address_l = (long)proc_max_address;
                logDebug(String.Format("Min {0} Max {1}", proc_min_address_l, proc_max_address_l));


                BlackMagic bm = new BlackMagic();
                if (bm.OpenProcessAndThread(SProcess.GetProcessFromProcessName(windowName[0])))
                {
                    logDebug("Found");
                    Utils.MEMORY_BASIC_INFORMATION mem_basic_info = new Utils.MEMORY_BASIC_INFORMATION();

                    while (proc_min_address_l < proc_max_address_l)
                    {
                        // 28 = sizeof(MEMORY_BASIC_INFORMATION)
                        Utils.VirtualQueryEx(bm.ProcessHandle, proc_min_address, out mem_basic_info, 28);

                        //logDebug(mem_basic_info.ToString());
                        // if this memory chunk is accessible
                        if ((mem_basic_info.Protect == Utils.PAGE_READWRITE || mem_basic_info.Protect == Utils.PAGE_READONLY) && mem_basic_info.State == Utils.MEM_COMMIT)
                        {
                            //logDebug(String.Format("Addr={0:X8} Size={1}", mem_basic_info.BaseAddress, mem_basic_info.RegionSize));
                            byte[] buffer = new byte[mem_basic_info.RegionSize];

                            // read everything in the buffer above
                            buffer = bm.ReadBytes((uint)mem_basic_info.BaseAddress, mem_basic_info.RegionSize);
                            //Utils.ReadProcessMemory((int)bm.ProcessHandle, mem_basic_info.BaseAddress, buffer, mem_basic_info.RegionSize, ref bytesRead);

                            MemoryStream ms = new MemoryStream(buffer);
                            BinaryReader br = new BinaryReader(ms);
                            while (ms.Position != ms.Length)
                            {
                                int data = br.ReadInt32();
                                if ((data == 18248) || (data == 18622))
                                {
                                    int readData = bm.ReadInt((uint)(mem_basic_info.BaseAddress + ms.Position - 4));
                                    logDebug(String.Format("Found Addr={0:X8} Size={1}", mem_basic_info.BaseAddress + ms.Position - 4, readData));
                                }
                            }

                            // then output this in the file
                            //for (int i = 0; i < mem_basic_info.RegionSize; i++)
                            //    sw.WriteLine("0x{0} : {1}", (mem_basic_info.BaseAddress + i).ToString("X"), (char)buffer[i]);
                        }

                        // move to the next memory chunk
                        proc_min_address_l += mem_basic_info.RegionSize;
                        proc_min_address    = new IntPtr(proc_min_address_l);
                    }

                    bm.Close();
                    logDebug("Done");
                }
            }
            else
            {
                logDebug("Need admin user");
            }
        }