diff --git a/Il2CppInspector.Common/FileFormatReaders/FormatLayouts/MachO.cs b/Il2CppInspector.Common/FileFormatReaders/FormatLayouts/MachO.cs index f177024..8df3d8c 100644 --- a/Il2CppInspector.Common/FileFormatReaders/FormatLayouts/MachO.cs +++ b/Il2CppInspector.Common/FileFormatReaders/FormatLayouts/MachO.cs @@ -1,5 +1,5 @@ /* - Copyright 2017-2019 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com + Copyright 2017-2020 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com All rights reserved. */ @@ -24,7 +24,9 @@ namespace Il2CppInspector LC_SYMTAB = 0x2, LC_DYSYMTAB = 0xb, LC_SEGMENT_64 = 0x19, + LC_ENCRYPTION_INFO = 0x21, LC_FUNCTION_STARTS = 0x26, + LC_ENCRYPTION_INFO_64 = 0x2C, CPU_TYPE_X86 = 7, CPU_TYPE_X86_64 = 0x01000000 + CPU_TYPE_X86, @@ -96,6 +98,14 @@ namespace Il2CppInspector public uint StrSize; } + internal class MachOEncryptionInfo + { + // MachOLoadCommand + public uint CryptOffset; + public uint CryptSize; + public uint CryptID; + } + internal class MachO_nlist where TWord : struct { public uint n_strx; diff --git a/Il2CppInspector.Common/FileFormatReaders/MachOReader.cs b/Il2CppInspector.Common/FileFormatReaders/MachOReader.cs index 7142424..6b3a85f 100644 --- a/Il2CppInspector.Common/FileFormatReaders/MachOReader.cs +++ b/Il2CppInspector.Common/FileFormatReaders/MachOReader.cs @@ -1,5 +1,5 @@ /* - Copyright 2017-2019 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com + Copyright 2017-2020 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com All rights reserved. */ @@ -39,6 +39,7 @@ namespace Il2CppInspector protected override bool checkMagicBE(MachO magic) => magic == MachO.MH_CIGAM_64; protected override MachO lc_Segment => MachO.LC_SEGMENT_64; + public override uint MapVATR(ulong uiAddr) { var section = sections.First(x => uiAddr >= x.Address && uiAddr <= x.Address + x.Size); return (uint) (uiAddr - (section.Address - section.ImageOffset)); @@ -126,6 +127,15 @@ namespace Il2CppInspector case MachO.LC_DYSYMTAB: // TODO: Implement Mach-O dynamic symbol table break; + + // Encryption check + // If cryptid == 1, this binary is encrypted with FairPlay DRM + case MachO.LC_ENCRYPTION_INFO: + case MachO.LC_ENCRYPTION_INFO_64: + var encryptionInfo = ReadObject(); + if (encryptionInfo.CryptID != 0) + throw new NotImplementedException("This Mach-O executable is encrypted with FairPlay DRM and cannot be processed. Please provide a decrypted version of the executable."); + break; } // There might be other data after the load command so always use the specified total size to step forwards