Пример #1
0
        private void RefreshList()
        {
            try
            {
                Process[] wowProcesses = Process.GetProcessesByName("Wow");

                dataGridView1.Rows.Clear();
                Memory.SetDebugPrivileges();
                foreach (Process proc in wowProcesses)
                {
                    if ((proc != null) & (!proc.HasExited))
                    {
                        IntPtr procHwnd = MemoryApi.OpenProcess((int)Memory.Mode.READ, 1, (uint)proc.Id);

                        int    pid    = proc.Id;
                        string hexPid = proc.Id.ToString("X2");
                        string login  = ReadUTF8String(procHwnd, (UIntPtr)Offsets.Client.Other.StaticLoginString);

                        //В мире
                        string inWorld = ReadProcessMemory(procHwnd, (UIntPtr)Offsets.Client.StaticInWorld, 1u)[0] == 1 ? "Да" : "Нет";

                        //Присоединен?
                        UIntPtr connectionPointer = ReadPointer(procHwnd, (UIntPtr)Offsets.Client.StaticClientConnection);
                        string  connected         = ReadProcessMemory(procHwnd, connectionPointer + Offsets.Client.HasConnectedOffset, 1u)[0] == 5 ? "Да" : "Нет";

                        MemoryApi.CloseHandle(procHwnd); //Обязательно закрываем

                        //Добавляем
                        dataGridView1.Rows.Add(pid, hexPid, login, inWorld, connected);
                    }
                }
            }
            catch (Exception ex) { Tools.MsgBox.Exception(ex, "Ошибка обновления списка с процессами"); }
        }
Пример #2
0
        private byte[] ReadProcessMemory(IntPtr Hwnd, UIntPtr MemoryAddress, uint bytesToRead)
        {
            byte[] array = new byte[bytesToRead];
            IntPtr intPtr;

            MemoryApi.ReadProcessMemory(Hwnd, MemoryAddress, array, bytesToRead, out intPtr);
            return(array);
        }
Пример #3
0
        public override IntPtr GetDataPointer()
        {
            if (MemoryApi.Read(ReturnAddress, out IntPtr pString))
            {
                return(pString);
            }

            return(IntPtr.Zero);
        }
Пример #4
0
        public void commitSingleRoom(UInt16 value, int layer, int x, int y, Map map)
        {
            int finalIndex = y + x * 200;

            finalIndex += map.verticalHeights.Take <int>(map.currentRoomY).Sum();
            finalIndex += map.currentRoomX * 4000;
            map.roomLayerArray[layer][finalIndex] = value;
            IntPtr targetAddress = IntPtr.Add(upperLeftRoomArray[layer], finalIndex * 2);

            MemoryApi.WriteMemoryPtrUShort(gameProcess, targetAddress, value);
        }
Пример #5
0
        public UInt16[] getMapInfoLayer(int targetLayerIndex)
        {
            UInt16[] mapValues = new UInt16[450];
            int      bytesRead;

            if (gameProcess != null)
            {
                mapValues = MemoryApi.ReadMemoryPtrRange(gameProcess, upperLeftMapArray[targetLayerIndex], 2, 450, out bytesRead);
            }

            return(mapValues);
        }
Пример #6
0
        protected override bool PrepareAsm(out IEnumerable <string> assembly)
        {
            byte[] luaJumpBytes = Encoding.ASCII.GetBytes("JumpOrAscendStart();AscendStop()");

            uint memoryNeeded = (uint)(4 + 40 + luaJumpBytes.Length + 1);

            if (MemoryApi.AllocateMemory(memoryNeeded, out IntPtr memory))
            {
                ExecuteAddress = memory;
                CommandAddress = ExecuteAddress + 4;
                DataAddress    = CommandAddress + 40;

                MemoryApi.WriteBytes(CommandAddress, luaJumpBytes);

                IntPtr distancePointer = DataAddress;
                IntPtr startPointer    = IntPtr.Add(distancePointer, 0x4);
                IntPtr endPointer      = IntPtr.Add(startPointer, 0xC);
                IntPtr resultPointer   = IntPtr.Add(endPointer, 0xC);

                assembly = new List <string>()
                {
                    "X:",
                    $"TEST DWORD [{ExecuteAddress}], 1",
                    "JE @out",
                    "PUSH 0",
                    "PUSH 0x120171",
                    $"PUSH {distancePointer}",
                    $"PUSH {resultPointer}",
                    $"PUSH {endPointer}",
                    $"PUSH {startPointer}",
                    $"CALL {OffsetList.FunctionTraceline}",
                    "ADD ESP, 0x18",
                    "TEST AL, 1",
                    "JE @out",
                    "PUSH 0",
                    $"PUSH {CommandAddress}",
                    $"PUSH {CommandAddress}",
                    $"CALL {OffsetList.FunctionLuaDoString}",
                    "ADD ESP, 0xC",
                    $"MOV DWORD [{ExecuteAddress}], 0",
                    "@out:",
                    "RET"
                };

                return(true);
            }

            assembly = Array.Empty <string>();
            return(false);
        }
Пример #7
0
        public void AddCustomerToApiTest()
        {
            // Arrange
            MemoryApi memoryApi = new MemoryApi();
//            IEnumerable<Customer> customers = await memoryApi.getCustomers();

            int customerCount = memoryApi.getCustomers().Result.ToList().Count;

            // Act
            memoryApi.addCustomer(new Customer {
                Id = 0, FirstName = "Ofek", LastName = "Agmon"
            }).Wait();

            // Assert
            Assert.AreEqual(customerCount + 1, memoryApi.getCustomers().Result.ToList().Count);
        }
Пример #8
0
        /// <summary>
        /// Save currently selected map layer to memory and map array.  Write related cache if writeCache = true.
        /// </summary>
        /// <param name="layer"></param>
        /// <param name="map"></param>
        /// <param name="writeCache"></param>
        public void commitFullMapLayer(int layer, Map map, bool writeCache)
        {
            MemoryApi.WriteMemoryPtrUShort(gameProcess, upperLeftMapArray[layer], map.mapInfoArray[layer]);

            if (writeCache)
            {
                if (layer == 0)
                {
                    MemoryApi.WriteMemoryPtrUShort(gameProcess, upperLeftMapCacheStyleArray[areaID], map.mapInfoArray[layer]);
                }
                else if (layer == 1)
                {
                    MemoryApi.WriteMemoryPtrUShort(gameProcess, upperLeftMapCacheColorArray[areaID], map.mapInfoArray[layer]);
                }
            }
        }
Пример #9
0
        public void commitSingleMap(UInt16 value, int layer, int index)
        {
            IntPtr targetAddress = IntPtr.Add(upperLeftMapArray[layer], index * 2);

            MemoryApi.WriteMemoryPtrUShort(gameProcess, targetAddress, value);
            if (layer == 0)
            {
                IntPtr targetCacheAddress = IntPtr.Add(upperLeftMapCacheStyleArray[areaID], index * 2);
                MemoryApi.WriteMemoryPtrUShort(gameProcess, targetCacheAddress, value);
            }
            else if (layer == 1)
            {
                IntPtr targetCacheAddress = IntPtr.Add(upperLeftMapCacheColorArray[areaID], index * 2);
                MemoryApi.WriteMemoryPtrUShort(gameProcess, targetCacheAddress, value);
            }
        }
Пример #10
0
        private int matchVersion()
        {
            int bytesRead;

            byte[] BUNNY_EX   = new byte[] { 66, 85, 78, 78, 89, 32, 69, 88 };
            byte[] cocoa_byte = new byte[] { 241, 3, 0, 0 };
            for (int i = 0; i < bexAddress.Length; i++)
            {
                byte[] byteArray = MemoryApi.ReadMemoryPtr(gameProcess, bexAddress[i], 8, out bytesRead);

                if (byteArray.SequenceEqual(BUNNY_EX))
                {
                    byteArray = MemoryApi.ReadMemoryPtr(gameProcess, cocoaAddress[i], 4, out bytesRead);
                    if (byteArray.SequenceEqual(cocoa_byte))
                    {
                        return(i);
                    }
                }
            }
            return(-1);
        }
Пример #11
0
        /// <summary>
        /// Empty the Clipboard and Restore to system clipboard data contained in a collection of ClipData objects
        /// </summary>
        /// <param name="clipData">The collection of ClipData containing data stored from clipboard</param>
        /// <returns></returns>
        public static bool SetClipboard(ReadOnlyCollection <ClipboardData> clipData)
        {
            //Open clipboard to allow its manipultaion
            if (!ClipboardApi.OpenClipboard(IntPtr.Zero))
            {
                return(false);
            }

            //Clear the clipboard
            EmptyClipboard();

            //Get an Enumerator to iterate into each ClipData contained into the collection
            IEnumerator <ClipboardData> cData = clipData.GetEnumerator();

            while (cData.MoveNext())
            {
                ClipboardData cd = cData.Current;

                //Get the pointer for inserting the buffer data into the clipboard
                IntPtr alloc = MemoryApi.GlobalAlloc(MemoryApi.GMEM_MOVEABLE | MemoryApi.GMEM_DDESHARE, cd.Size);
                IntPtr gLock = MemoryApi.GlobalLock(alloc);

                //Clopy the buffer of the ClipData into the clipboard
                if ((int)cd.Size > 0)
                {
                    Marshal.Copy(cd.Buffer, 0, gLock, cd.Buffer.GetLength(0));
                }
                else
                {
                }
                //Release pointers
                MemoryApi.GlobalUnlock(alloc);
                ClipboardApi.SetClipboardData(cd.Format, alloc);
            }
            ;
            //Close the clipboard to realese unused resources
            ClipboardApi.CloseClipboard();
            return(true);
        }
Пример #12
0
        protected override bool PrepareAsm(out IEnumerable <string> assembly)
        {
            byte[] luaBytes    = Encoding.ASCII.GetBytes(Lua);
            byte[] luaVarBytes = Encoding.ASCII.GetBytes(VarName);

            uint memoryNeeded = (uint)(4 + luaBytes.Length + 1 + luaVarBytes.Length + 1);

            if (MemoryApi.AllocateMemory(memoryNeeded, out IntPtr memory))
            {
                ReturnAddress  = memory;
                CommandAddress = ReturnAddress + 4;
                VarAddress     = CommandAddress + luaBytes.Length + 1;

                MemoryApi.WriteBytes(CommandAddress, luaBytes);
                MemoryApi.WriteBytes(VarAddress, luaVarBytes);

                assembly = new List <string>()
                {
                    "X:",
                    "PUSH 0",
                    $"PUSH {CommandAddress}",
                    $"PUSH {CommandAddress}",
                    $"CALL {OffsetList.FunctionLuaDoString}",
                    "ADD ESP, 0xC",
                    $"CALL {OffsetList.FunctionGetActivePlayerObject}",
                    "MOV ECX, EAX",
                    "PUSH -1",
                    $"PUSH {VarAddress}",
                    $"CALL {OffsetList.FunctionGetLocalizedText}",
                    $"MOV DWORD [{ReturnAddress}], EAX",
                    $"RET"
                };

                return(true);
            }

            assembly = Array.Empty <string>();
            return(false);
        }
Пример #13
0
        /// <summary>
        /// Convert to a DataClip collection all data present in the clipboard
        /// </summary>
        /// <returns></returns>
        public static ReadOnlyCollection <ClipboardData> GetClipboard()
        {
            //Init a list of ClipData, which will contain each Clipboard Data
            List <ClipboardData> clipData = new List <ClipboardData>();

            //Open Clipboard to allow us to read from it
            if (!ClipboardApi.OpenClipboard(IntPtr.Zero))
            {
                return(new ReadOnlyCollection <ClipboardData>(clipData));
            }

            //Loop for each clipboard data type
            uint format = 0;

            while ((format = ClipboardApi.EnumClipboardFormats(format)) != 0)
            {
                //Check if clipboard data type is recognized, and get its name
                string formatName = "0";
                if (format > 14)
                {
                    StringBuilder res = new StringBuilder();
                    if (ClipboardApi.GetClipboardFormatName(format, res, 100) > 0)
                    {
                        formatName = res.ToString();
                    }
                }
                //Get the pointer for the current Clipboard Data
                IntPtr pos = ClipboardApi.GetClipboardData(format);
                //Goto next if it's unreachable
                if (pos == IntPtr.Zero)
                {
                    continue;
                }
                //Get the clipboard buffer data properties
                UIntPtr lenght = MemoryApi.GlobalSize(pos);
                IntPtr  gLock  = MemoryApi.GlobalLock(pos);
                byte[]  buffer;
                if ((int)lenght > 0)
                {
                    //Init a buffer which will contain the clipboard data
                    buffer = new byte[(int)lenght];
                    int l = Convert.ToInt32(lenght.ToString());
                    //Copy data from clipboard to our byte[] buffer
                    Marshal.Copy(gLock, buffer, 0, l);
                }
                else
                {
                    buffer = new byte[0];
                }
                //Create a ClipData object that represtens current clipboard data
                var cd = new ClipboardData(format, formatName, buffer);
                cd.FormatName = formatName;
                //Add current Clipboard Data to the list


                clipData.Add(cd);
            }
            //Close the clipboard and realese unused resources
            ClipboardApi.CloseClipboard();
            //Returns the list of Clipboard Datas as a ReadOnlyCollection of ClipData
            return(new ReadOnlyCollection <ClipboardData>(clipData));
        }
Пример #14
0
        private void fillAddresses()
        {
            baseAddress = gameProcess.MainModule.BaseAddress;

            //scan decimal byte array 66 85 78 78 89 32 69 88
            bexAddress = new IntPtr[] { IntPtr.Add(baseAddress, 0x12E29F0), //1.85
                                        IntPtr.Add(baseAddress, 0x12DE9B0), //1.80
                                        IntPtr.Add(baseAddress, 0xA441C8),  //1.75
                                        IntPtr.Add(baseAddress, 0xA45208),  //1.75lm
                                        IntPtr.Add(baseAddress, 0xA421C8),  //1.71
                                        IntPtr.Add(baseAddress, 0xA3B140),  //1.70
                                        IntPtr.Add(baseAddress, 0xA176E0)   //1.65
            };

            //scan decimal byte array 241 3 0 0
            cocoaAddress = new IntPtr[] { IntPtr.Add(baseAddress, 0x272517), //1.85
                                          IntPtr.Add(baseAddress, 0x271509), //1.80
                                          IntPtr.Add(baseAddress, 0x29DCD2), //1.75
                                          IntPtr.Add(baseAddress, 0x29ED92), //1.75lm
                                          IntPtr.Add(baseAddress, 0x29D112), //1.71
                                          IntPtr.Add(baseAddress, 0x29B512), //1.70
                                          IntPtr.Add(baseAddress, 0x27c658)  //1.65
            };

            version = matchVersion();
            if (version == -1)
            {
                return;
            }
            //Scan 51118828, 4 byte in woodlands, take first value and subtract 0x970
            Sprite1Address = new IntPtr[] { IntPtr.Add(baseAddress, 0xAC61A0), //1.80e
                                            IntPtr.Add(baseAddress, 0xAC2168), //1.80
                                            IntPtr.Add(baseAddress, 0xE47290), //1.75
                                            IntPtr.Add(baseAddress, 0xE48310), //1.75lm
                                            IntPtr.Add(baseAddress, 0xE45290), //1.71
                                            IntPtr.Add(baseAddress, 0xE3D1F0), //1.70
                                            IntPtr.Add(baseAddress, 0xE197C0)  //1.65
            };

            //Scan 5, 2 byte in town, compare for left exit and subtract 0x138
            StyleAddress = new IntPtr[] { IntPtr.Add(baseAddress, 0xA63C90), //1.80e
                                          IntPtr.Add(baseAddress, 0xA5FC58), //1.80
                                          IntPtr.Add(baseAddress, 0xDE4D80), //1.75
                                          IntPtr.Add(baseAddress, 0xDE5E00), //1.75lm
                                          IntPtr.Add(baseAddress, 0xDE2D80), //1.71
                                          IntPtr.Add(baseAddress, 0xDDACE0), //1.70
                                          IntPtr.Add(baseAddress, 0xDB72B0)  //1.65
            };

            CacheColorAddress = new IntPtr[] { IntPtr.Add(baseAddress, 0x12CCEA0), //1.80e
                                               IntPtr.Add(baseAddress, 0x12C8E60), //1.80
                                               IntPtr.Add(baseAddress, 0xA5C260),  //1.75
                                               IntPtr.Add(baseAddress, 0xA5D290),  //1.75lm
                                               IntPtr.Add(baseAddress, 0xA5A260),  //1.71
                                               IntPtr.Add(baseAddress, 0xA531D0),  //1.70
                                               IntPtr.Add(baseAddress, 0xA2F6F0)   //1.65
            };

            CacheStyleAddress = new IntPtr[] { IntPtr.Add(baseAddress, 0x12C9660), //1.80e
                                               IntPtr.Add(baseAddress, 0x12C5620), //1.80
                                               IntPtr.Add(baseAddress, 0xA58A20),  //1.75
                                               IntPtr.Add(baseAddress, 0xA59A50),  //1.75lm
                                               IntPtr.Add(baseAddress, 0xA56A20),  //1.71
                                               IntPtr.Add(baseAddress, 0xA4F990),  //1.70
                                               IntPtr.Add(baseAddress, 0xA2BEB0)   //1.65
            };

            mapIDAddress = new IntPtr[] { IntPtr.Add(baseAddress, 0x138528C), //1.80e
                                          IntPtr.Add(baseAddress, 0x138024C), //1.80
                                          IntPtr.Add(baseAddress, 0xAB8074),  //1.75
                                          IntPtr.Add(baseAddress, 0xAB90E4),  //1.75lm
                                          IntPtr.Add(baseAddress, 0xAB6074),  //1.71
                                          IntPtr.Add(baseAddress, 0xAAEFD4),  //1.70
                                          IntPtr.Add(baseAddress, 0xA8B4CC)   //1.65
            };

            upperLeftRoomArray = new IntPtr[] { IntPtr.Subtract(Sprite1Address[version], 0xC3F90), //collision
                                                IntPtr.Subtract(Sprite1Address[version], 0x93250), //entities
                                                IntPtr.Subtract(Sprite1Address[version], 0x61A84), //items
                                                IntPtr.Subtract(Sprite1Address[version], 0x30D40), //sprite 2
                                                IntPtr.Add(Sprite1Address[version], 0),            //sprite 1
                                                IntPtr.Add(Sprite1Address[version], 0x30D40),      //sprite 3
                                                IntPtr.Add(Sprite1Address[version], 0x61A80),      //sprite 4
                                                IntPtr.Add(Sprite1Address[version], 0x927C0),      //sprite 5
                                                IntPtr.Add(Sprite1Address[version], 0xC3500),      //sprite 6
                                                IntPtr.Add(Sprite1Address[version], 0xF4240),      //sprite 7
            };

            upperLeftMapArray = new IntPtr[] { IntPtr.Add(StyleAddress[version], 0),     //Style
                                               IntPtr.Add(StyleAddress[version], 0x384), //Color
                                               IntPtr.Add(StyleAddress[version], 0x708), //Background
            };

            upperLeftMapCacheColorArray = new IntPtr[] { IntPtr.Add(CacheColorAddress[version], 0),      //area0
                                                         IntPtr.Add(CacheColorAddress[version], 0x384),  //area1
                                                         IntPtr.Add(CacheColorAddress[version], 0x708),  //area2
                                                         IntPtr.Add(CacheColorAddress[version], 0xA8C),  //area3
                                                         IntPtr.Add(CacheColorAddress[version], 0xE10),  //area4
                                                         IntPtr.Add(CacheColorAddress[version], 0x1194), //area5
                                                         IntPtr.Add(CacheColorAddress[version], 0x1518), //area6
                                                         IntPtr.Add(CacheColorAddress[version], 0x189C), //area7
                                                         IntPtr.Add(CacheColorAddress[version], 0x1C20), //area8
                                                         IntPtr.Add(CacheColorAddress[version], 0x1FA4), //area9
                                                         IntPtr.Add(CacheColorAddress[version], 0x2328), //area10
                                                         IntPtr.Add(CacheColorAddress[version], 0x26AC)  //area11
            };
            upperLeftMapCacheStyleArray = new IntPtr[] { IntPtr.Add(CacheStyleAddress[version], 0),      //area0
                                                         IntPtr.Add(CacheStyleAddress[version], 0x384),  //area1
                                                         IntPtr.Add(CacheStyleAddress[version], 0x708),  //area2
                                                         IntPtr.Add(CacheStyleAddress[version], 0xA8C),  //area3
                                                         IntPtr.Add(CacheStyleAddress[version], 0xE10),  //area4
                                                         IntPtr.Add(CacheStyleAddress[version], 0x1194), //area5
                                                         IntPtr.Add(CacheStyleAddress[version], 0x1518), //area6
                                                         IntPtr.Add(CacheStyleAddress[version], 0x189C), //area7
                                                         IntPtr.Add(CacheStyleAddress[version], 0x1C20), //area8
                                                         IntPtr.Add(CacheStyleAddress[version], 0x1FA4), //area9
                                                         IntPtr.Add(CacheStyleAddress[version], 0x2328), //area10
                                                         IntPtr.Add(CacheStyleAddress[version], 0x26AC)  //area11
            };
            int bytesRead;

            areaID = MemoryApi.ReadMemoryPtrUShort(gameProcess, mapIDAddress[version], out bytesRead);
        }
Пример #15
0
 public void commitFullRoomLayer(int layer, Map map)
 {
     MemoryApi.WriteMemoryPtrUShort(gameProcess, upperLeftRoomArray[layer], map.roomLayerArray[layer]);
 }
Пример #16
0
        public void commitSingleRoom(UInt16 value, int layer, int index)
        {
            IntPtr targetAddress = IntPtr.Add(upperLeftRoomArray[layer], index * 2);

            MemoryApi.WriteMemoryPtrUShort(gameProcess, targetAddress, value);
        }