Beispiel #1
0
        private UInt32 GetMenuStringsAddress(int line)
        {
            // code from 0x0044E500
            uint  ecx       = MemoryManager.ReadUInt(MemoryManager.ReadUInt(MemoryManager.ReadUInt(MemoryManager.ReadUInt(0x004c4918) + 0x4dc8) + 0x354) + 0x4d00);
            short offset    = MemoryManager.ReadShort((UInt32)(ecx + line * 2));
            int   filestart = MemoryManager.ReadInt(MemoryManager.ReadUInt(MemoryManager.ReadUInt(MemoryManager.ReadUInt(0x004c4918) + 0x4dc8) + 0x354) + 0x4cfc);

            return((UInt32)(filestart + offset * 2));
        }
Beispiel #2
0
        /// <summary>
        /// Uses a Power-up from the driver. This does not trigger the PowerUpUsed event.
        /// </summary>
        /// <param name="brick">The Brick type to use.</param>
        /// <param name="whiteBricks">Amount of White bricks to use.</param>
        public void UsePowerUp(Brick brick, int whiteBricks)
        {
            if (driverIndex >= 0 && driverIndex <= 5 && brick != Brick.White && brick != Brick.None)
            {
                UInt32 function = 0;

                switch (brick)
                {
                case Brick.Red:
                    // Red Power-up
                    function = gameClient.POWERUP_RED_ADDRESS;
                    break;

                case Brick.Blue:
                    // Blue Power-up
                    function = gameClient.POWERUP_RED_ADDRESS;
                    break;

                case Brick.Green:
                    // Green Power-up
                    function = gameClient.POWERUP_GREEN_ADDRESS;
                    break;

                case Brick.Yellow:
                    // Yellow Power-up
                    function = gameClient.POWERUP_YELLOW_ADDRESS;
                    break;

                default:
                    return;
                }

                uint ecx = MemoryManager.ReadUInt(baseAddress + 0x8);
                uint ebx = 0;
                uint edx = 0;

                switch (driverIndex)
                {
                case 0:                         // Local player
                    ebx = ecx - 0x498;
                    edx = ecx - 0x444;
                    break;

                case 1:                         // Opponent 1
                    edx = 0xD1;
                    break;

                case 2:                         // Opponent 2
                    edx = 0xA4;
                    break;

                case 3:                         // Opponent 3
                    edx = 0xBA;
                    break;

                case 4:                         // Opponent 4
                    edx = 0x49;
                    break;

                case 5:                         // Opponent 5
                    edx = 0x8D;
                    break;

                default:
                    return;
                }

                List <byte> codeToInject = new List <byte>();

                codeToInject.Add(0xBB);
                codeToInject.AddRange(BitConverter.GetBytes(ebx));                                                                   // mov ebx,neededEBX
                codeToInject.Add(0xB9);
                codeToInject.AddRange(BitConverter.GetBytes(ecx));                                                                   // mov ecx,neededECX
                codeToInject.Add(0xBA);
                codeToInject.AddRange(BitConverter.GetBytes(edx));                                                                   // mov edx,neededEDX
                codeToInject.Add(0x6A);
                codeToInject.Add((byte)whiteBricks);                                                                                 // push whitebricks
                codeToInject.Add(0x68);
                codeToInject.AddRange(BitConverter.GetBytes(baseAddress));                                                           // push raceraddress
                codeToInject.Add(0xE8);
                codeToInject.AddRange(BitConverter.GetBytes((int)(-(MemoryManager.NewMemory + codeToInject.Count + 4) + function))); // call function
                codeToInject.Add(0xC3);                                                                                              // ret

                // Write code to the assigned memory and execute it
                MemoryManager.WriteBytes(MemoryManager.NewMemory, codeToInject.ToArray());
                MemoryManager.CreateThread(MemoryManager.NewMemory);
            }
        }