Exemple #1
0
        public void Apply(ExeFS exefs, List <Tuple <string, uint> > symbols)
        {
            long patchAddr = Address.GetAddress(exefs, symbols);

            byte[] buffer = new byte[0];

            switch (PatchType)
            {
            case PatchTypeEnum.ptr:
                buffer = BitConverter.GetBytes(((MemAddress)Data).GetAddress(exefs, symbols));
                break;

            case PatchTypeEnum.bl:
                long blHookAddr = ((MemAddress)Data).GetAddress(exefs, symbols);
                buffer = ArmUtils.Armv8Encode_bl((uint)(blHookAddr - patchAddr));
                break;

            case PatchTypeEnum.b:
                long bHookAddr = ((MemAddress)Data).GetAddress(exefs, symbols);
                buffer = ArmUtils.Armv8Encode_b((uint)(bHookAddr - patchAddr));
                break;

            case PatchTypeEnum.data:
                buffer = (byte[])Data;
                break;

            default:
                throw new Exception($"Invalid Patch Type : {PatchType}");
            }

            exefs.WriteExeFs(patchAddr, buffer);
        }