public void ProcSer_Deserialize_thiscall_function() { var ssig = new SerializedSignature { Convention = "__thiscall", Arguments = new Argument_v1[] { new Argument_v1 { Name = "self", Type = new PointerType_v1 { DataType = PrimitiveType_v1.Int32(), PointerSize = 4 } }, new Argument_v1 { Name = "arg1", Type = new PointerType_v1 { DataType = PrimitiveType_v1.Int32(), PointerSize = 4 } }, } }; Given_ProcedureSerializer("__thiscall"); mr.ReplayAll(); var sig = ser.Deserialize(ssig, arch.CreateFrame()); var sExp = @"void foo(Register (ptr32 int32) self, Stack (ptr32 int32) arg1) // stackDelta: 8; fpuStackDelta: 0; fpuMaxParam: -1 "; Assert.AreEqual(sExp, sig.ToString("foo", FunctionType.EmitFlags.AllDetails)); }
public List <ImageSymbol> GetAllSymbols() { return(new List <ImageSymbol> { ImageSymbol.Procedure( arch.Object, Address.Ptr64(0x12340000), "MyFunction", signature: new SerializedSignature { Arguments = new Argument_v1[] { new Argument_v1("arg1", PrimitiveType_v1.Int32(), new StackVariable_v1(), false), new Argument_v1("arg2", new PointerType_v1(PrimitiveType_v1.Char8()) { PointerSize = 4 }, new StackVariable_v1(), false), }, ReturnValue = new Argument_v1 { Type = PrimitiveType_v1.Int32() } }) }); }
public void Tlldr_LoadGlobalByOrdinal() { var typelib = new TypeLibrary(); platform = new Mock <IPlatform>(); platform.Setup(p => p.DefaultCallingConvention).Returns("__cdecl"); platform.Setup(p => p.Architecture).Returns(new FakeArchitecture(new ServiceContainer())); var tlldr = new TypeLibraryDeserializer(platform.Object, true, typelib); tlldr.Load(new SerializedLibrary { ModuleName = "stdlib", Globals = new List <GlobalVariable_v1> { new GlobalVariable_v1 { Name = "errno", Ordinal = 42, Type = PrimitiveType_v1.Int32(), } } }); var stdlib = typelib.Modules["stdlib"]; var globalByName = stdlib.GlobalsByName["errno"]; var globalByOrdinal = stdlib.GlobalsByOrdinal[42]; Assert.AreSame(globalByName, globalByOrdinal); }
public void MacTi_PtrChain() { var decls = new List <Declaration> { new TypeDeclaration("GrafPort", new Record { Fields = new List <Field> { new Field(new List <string> { "test" }, new Primitive(PrimitiveType_v1.Int32())) } }), new TypeDeclaration("DialogPtr", new TypeReference("WindowPtr")), new TypeDeclaration("GrafPtr", new Pointer(new TypeReference("GrafPort"))), new TypeDeclaration("WindowPtr", new TypeReference("GrafPtr")) }; Given_TypeImporter(); typeimporter.LoadTypes(decls); Assert.AreEqual(32, typelib.Types["GrafPtr"].BitSize); Assert.AreEqual(32, typelib.Types["WindowPtr"].BitSize); Assert.AreEqual(32, typelib.Types["DialogPtr"].BitSize); }
public SerializedType VisitRangeType(RangeType rangeType) { var low = rangeType.Low.Accept(ceval).ToInt64(); var hi = rangeType.High.Accept(ceval).ToInt64(); var delta = hi - low + 1; if (delta < 0) { throw new NotImplementedException("Range overflow."); } if (delta < 256) { return(low < 0 ? PrimitiveType_v1.SChar8() : PrimitiveType_v1.UChar8()); } if (delta < 65536) { return(low <= 0 ? PrimitiveType_v1.Int16() : PrimitiveType_v1.UInt16()); } if (delta < (1L << 32)) { return(low <= 0 ? PrimitiveType_v1.Int32() : PrimitiveType_v1.UInt32()); } return(PrimitiveType_v1.Int64()); }
public void Ici_load_do_with_16bit_load() { var ici = new InlineCodeInterpreter(constants); var ssig = new SerializedSignature { Arguments = new[] { new Argument_v1 { Name = "d", Type = new ReferenceType_v1 { Referent = PrimitiveType_v1.Int32(), Size = 4, } }, }, }; var svc = ici.BuildSystemCallFromMachineCode( "GetTime", ssig, Opcodes(0x205F, 0x2038, 0x020c, 0xa9c6)); Assert.AreEqual("A9C6", svc.SyscallInfo.Vector); var reg = (Register_v1)svc.Signature.Arguments[0].Kind; Assert.AreEqual("a0", reg.Name); }
public void X86_64Psig_MixedIntsFloats() { var pser = Given_ProcedureSerializer(); var ssig = new SerializedSignature { ReturnValue = new Argument_v1 { Type = PrimitiveType_v1.Int32() }, Arguments = new Argument_v1[] { new Argument_v1 { Type = PrimitiveType_v1.Int32(), Name = "a" }, new Argument_v1 { Type = PrimitiveType_v1.Real64(), Name = "b" }, new Argument_v1 { Type = PointerType_v1.Create(PrimitiveType_v1.Char8(), 8), Name = "c" }, new Argument_v1 { Type = PrimitiveType_v1.Real64(), Name = "d" }, new Argument_v1 { Type = PrimitiveType_v1.Real32(), Name = "e" }, } }; var sig = pser.Deserialize(ssig, frame); Assert.AreEqual("rax", sig.ReturnValue.Storage.ToString()); ExpectArgs(sig, "rcx", "xmm1", "r8", "xmm3", "Stack +0008"); }
public void SvArm32Ps_Load_IntArgs() { var ssig = new SerializedSignature { Arguments = new Argument_v1[] { new Argument_v1 { Name = "dc", Type = PrimitiveType_v1.Int16(), }, new Argument_v1 { Name = "b1", Type = PrimitiveType_v1.SChar8(), }, new Argument_v1 { Name = "w2", Type = PrimitiveType_v1.Int32(), }, new Argument_v1 { Name = "h3", Type = PrimitiveType_v1.Int16(), }, new Argument_v1 { Name = "b4", Type = PrimitiveType_v1.UChar8(), }, new Argument_v1 { Name = "w5", Type = PrimitiveType_v1.Int32(), }, new Argument_v1 { Name = "foo", Type = PrimitiveType_v1.Int32() } } }; Given_ProcedureSerializer(); mr.ReplayAll(); var sig = ser.Deserialize(ssig, arch.CreateFrame()); var args = sig.Parameters; Assert.AreEqual("r0", args[0].Storage.ToString()); Assert.AreEqual("r1", args[1].Storage.ToString()); Assert.AreEqual("r2", args[2].Storage.ToString()); Assert.AreEqual("r3", args[3].Storage.ToString()); Assert.AreEqual("Stack +0000", args[4].Storage.ToString()); Assert.AreEqual("Stack +0004", args[5].Storage.ToString()); Assert.AreEqual("Stack +0008", args[6].Storage.ToString()); }
public void SvArm32Ps_mmap() { var ssig = new SerializedSignature { ReturnValue = new Argument_v1 { Type = new PointerType_v1 { PointerSize = 4, DataType = new VoidType_v1(), } }, Arguments = new Argument_v1[] { new Argument_v1 { Name = "addr", Type = new PointerType_v1 { PointerSize = 4, DataType = new VoidType_v1(), } }, new Argument_v1 { Name = "length", Type = PrimitiveType_v1.UInt32(), }, new Argument_v1 { Name = "prot", Type = PrimitiveType_v1.Int32(), }, new Argument_v1 { Name = "flags", Type = PrimitiveType_v1.Int32(), }, new Argument_v1 { Name = "fd", Type = PrimitiveType_v1.Int32(), }, new Argument_v1 { Name = "offset", Type = PrimitiveType_v1.Int32(), } } }; Given_ProcedureSerializer(); mr.ReplayAll(); var sig = ser.Deserialize(ssig, arch.CreateFrame()); var args = sig.Parameters; }
private SerializedType Type() { switch (str[i++]) { case 'b': return(PrimitiveType_v1.Bool()); case 'c': return(PrimitiveType_v1.Char8()); case 'h': return(PrimitiveType_v1.UChar8()); case 's': return(PrimitiveType_v1.Int16()); case 'r': return(PrimitiveType_v1.UInt16()); case 'i': return(PrimitiveType_v1.Int32()); case 'j': return(PrimitiveType_v1.UInt32()); case 'l': return(PrimitiveType_v1.Int64()); case 'm': return(PrimitiveType_v1.UInt64()); case 'w': return(PrimitiveType_v1.WChar16()); case 'f': return(PrimitiveType_v1.Real32()); case 'd': return(PrimitiveType_v1.Real64()); case 'P': return(new PointerType_v1 { DataType = Type(), PointerSize = ptrSize }); case 'R': return(new ReferenceType_v1 { Referent = Type(), Size = ptrSize }); default: --i; if (char.IsDigit(str[i])) { return(new TypeReference_v1 { TypeName = SimpleName(), }); } throw new NotImplementedException(string.Format("Unknown GCC type code '{0}'.", str[i])); } }
public void SvX86Ps_DeserializeFpuArgument() { var ssig = new SerializedSignature { Convention = "stdapi", ReturnValue = RegArg(PrimitiveType_v1.Int32(), "eax"), Arguments = new Argument_v1[] { StackArg(PrimitiveType_v1.Real64(), "rArg04") } }; Given_ProcedureSerializer(); mr.ReplayAll(); var sig = ser.Deserialize(ssig, arch.CreateFrame()); Assert.AreEqual("Register int32 test(Stack real64 rArg04)", sig.ToString("test")); }
public void Ici_Load_Word_Constant_To_Register() { var ici = new InlineCodeInterpreter(constants); var ssig = new SerializedSignature { Arguments = new [] { new Argument_v1 { Name = "typecode", Type = PrimitiveType_v1.Int32(), }, new Argument_v1 { Name = "dataPtr", Type = new PrimitiveType_v1 { Domain = Domain.Pointer, ByteSize = 4 }, }, new Argument_v1 { Name = "result", Type = new ReferenceType_v1 { Referent = new TypeReference_v1 { TypeName = "AEDesc" } } } }, ReturnValue = new Argument_v1 { Type = PrimitiveType_v1.Int16() } }; var svc = ici.BuildSystemCallFromMachineCode( "AECreateDesc", ssig, Opcodes(0x303C, 0x0825, 0xA816)); Assert.AreEqual("A816", svc.SyscallInfo.Vector); Assert.AreEqual("d0", svc.SyscallInfo.RegisterValues[0].Register); Assert.AreEqual("0825", svc.SyscallInfo.RegisterValues[0].Value); }
public void SvArm32Ps_Load_cdecl() { var ssig = new SerializedSignature { Arguments = new Argument_v1[] { new Argument_v1 { Name = "foo", Type = PrimitiveType_v1.Int32(), } } }; Given_ProcedureSerializer(); mr.ReplayAll(); var sig = ser.Deserialize(ssig, arch.CreateFrame()); Assert.AreEqual(0, sig.StackDelta); }
public void Ici_PascalService() { var ici = new InlineCodeInterpreter(constants); var ssig = new SerializedSignature { Arguments = new[] { new Argument_v1 { Name = "arg1", Type = PrimitiveType_v1.Int32() }, new Argument_v1 { Name = "arg2", Type = PrimitiveType_v1.Int16() }, } }; var svc = ici.BuildSystemCallFromMachineCode("fooSvc", ssig, new List <Exp> { Exp(0xAAAA) }); Assert.AreEqual((ushort)0xAAAA, svc.Ordinal); Assert.AreEqual("fooSvc", svc.Name); Assert.AreEqual("fn(pascal,void,(arg(arg1,prim(SignedInt,4)),arg(arg2,prim(SignedInt,2))))", svc.Signature.ToString()); }
public void Ici_swap() { var ici = new InlineCodeInterpreter(constants); var ssig = new SerializedSignature { Arguments = new[] { new Argument_v1 { Name = "d", Type = new ReferenceType_v1 { Referent = PrimitiveType_v1.Int32(), Size = 4, } }, }, }; var svc = ici.BuildSystemCallFromMachineCode( "xx", ssig, Opcodes(0x4840, 0xa9c6)); Assert.AreEqual("A9C6", svc.SyscallInfo.Vector); }
public void ProcSer_Deserialize_thiscall_method() { var ssig = new SerializedSignature { Convention = "__thiscall", EnclosingType = new TypeReference_v1 { TypeName = "bob" }, Arguments = new Argument_v1[] { new Argument_v1 { Name = "arg0", Type = new PointerType_v1 { DataType = PrimitiveType_v1.Int32(), PointerSize = 4 } }, new Argument_v1 { Name = "arg1", Type = new PointerType_v1 { DataType = PrimitiveType_v1.Int32(), PointerSize = 4 } }, } }; Given_ProcedureSerializer("__thiscall"); var sig = ser.Deserialize(ssig, arch.CreateFrame()); var sExp = @"void foo(Register (ptr32 bob) this, Stack (ptr32 int32) arg0, Stack (ptr32 int32) arg1) // stackDelta: 12; fpuStackDelta: 0; fpuMaxParam: -1 "; Assert.AreEqual(sExp, sig.ToString("foo", FunctionType.EmitFlags.AllDetails)); }
public void Tlldr_LoadGlobalByOrdinal() { var typelib = new TypeLibrary(); var tlldr = new TypeLibraryDeserializer(platform, true, typelib); tlldr.Load(new SerializedLibrary { ModuleName = "stdlib", Globals = new List <GlobalVariable_v1> { new GlobalVariable_v1 { Name = "errno", Ordinal = 42, Type = PrimitiveType_v1.Int32(), } } }); var stdlib = typelib.Modules["stdlib"]; var globalByName = stdlib.GlobalsByName["errno"]; var globalByOrdinal = stdlib.GlobalsByOrdinal[42]; Assert.AreSame(globalByName, globalByOrdinal); }
private SerializedType Type() { var qual = CvQualifier(); switch (str[i++]) { case 'v': return(new VoidType_v1()); case 'b': return(Qualify(PrimitiveType_v1.Bool(), qual)); case 'c': return(Qualify(PrimitiveType_v1.Char8(), qual)); case 'h': return(Qualify(PrimitiveType_v1.UChar8(), qual)); case 's': return(Qualify(PrimitiveType_v1.Int16(), qual)); case 't': return(Qualify(PrimitiveType_v1.UInt16(), qual)); case 'i': return(Qualify(PrimitiveType_v1.Int32(), qual)); case 'j': return(Qualify(PrimitiveType_v1.UInt32(), qual)); case 'l': return(Qualify(PrimitiveType_v1.Int64(), qual)); case 'm': return(Qualify(PrimitiveType_v1.UInt64(), qual)); case 'w': return(Qualify(PrimitiveType_v1.WChar16(), qual)); case 'f': return(Qualify(PrimitiveType_v1.Real32(), qual)); case 'd': return(Qualify(PrimitiveType_v1.Real64(), qual)); case 'F': --i; return(FunctionType()); case 'N': --i; return(CreateTypeReference(NestedName())); case 'P': var ptr = new PointerType_v1 { DataType = Type(), PointerSize = ptrSize }; AddSubstitution(ptr); return(Qualify(ptr, qual)); case 'R': qual = CvQualifier(); var r = new ReferenceType_v1 { Referent = Type(), Size = ptrSize }; return(Qualify(r, qual)); case 'S': switch (str[i++]) { case 't': return(Qualify(new TypeReference_v1 { Scope = new[] { "std" }, TypeName = Type().ToString(), }, qual)); case 's': return(Qualify(new TypeReference_v1 { Scope = new[] { "std" }, TypeName = "string" }, qual)); default: int iStart = --i; while (str[i] != '_') { ++i; } ++i; var sub = str.Substring(iStart, i - iStart); Debug.Print(sub); return(Qualify((SerializedType)substitutions[sub], qual)); } throw new NotImplementedException(); default: --i; if (char.IsDigit(str[i])) { var tref = new TypeReference_v1 { TypeName = UnqualifiedName() }; AddSubstitution(tref); return(Qualify(tref, qual)); } throw new NotImplementedException(string.Format("Unknown GCC type code '{0}' ({1}).", str[i], str.Substring(i))); } }
private SerializedType Type() { switch (str[i++]) { case 'b': return(PrimitiveType_v1.Bool()); case 'c': return(PrimitiveType_v1.Char8()); case 'h': return(PrimitiveType_v1.UChar8()); case 's': return(PrimitiveType_v1.Int16()); case 'r': return(PrimitiveType_v1.UInt16()); case 'i': return(PrimitiveType_v1.Int32()); case 'j': return(PrimitiveType_v1.UInt32()); case 'l': return(PrimitiveType_v1.Int64()); case 'm': return(PrimitiveType_v1.UInt64()); case 'w': return(PrimitiveType_v1.WChar16()); case 'f': return(PrimitiveType_v1.Real32()); case 'd': return(PrimitiveType_v1.Real64()); case 'P': return(new PointerType_v1 { DataType = Type(), PointerSize = ptrSize }); case 'R': //$TODO: Reko doesn't have a concept of 'const' or 'volatile'. // Needs to be implemented for completeness, but should not affect // quality of decompilation. var qual = CvQualifier(); return(new ReferenceType_v1 { Referent = Type(), Size = ptrSize }); case 'S': switch (str[i++]) { case 't': return(new TypeReference_v1 { Scope = new[] { "std" }, TypeName = Type().ToString(), }); case 's': return(new TypeReference_v1 { Scope = new[] { "std" }, TypeName = "string" }); } throw new NotImplementedException(); default: --i; if (char.IsDigit(str[i])) { return(new TypeReference_v1 { TypeName = UnqualifiedName(), }); } throw new NotImplementedException(string.Format("Unknown GCC type code '{0}'.", str[i])); } }
public SerializedType VisitSetType(SetType setType) { //$TODO: Reko doesn't support bitset semantics natively yet. //$For now, return the wordsize of the MacOS. return(PrimitiveType_v1.Int32()); }
static TypeBuilder() { reservedTypes = new Dictionary <int, SerializedType> { // Type indices 0-511 are reserved.Types 0-255 (high byte = 0) have meaning according // to the decoding of the following bits: // // xxxx xxxx x xx xxx xx // xxxx xxxx i md typ sz // // The format of Type Index(and Reserved Types) is illustrated in the next // four tables. // // Table 1.2, Format of i // i Action // ----------- // 0 Special type, not interpreted as follows // (see "Special Types" below) // 1 Low 7 bits are interpreted as follows: // Table 1.3, Format of md // md Mode // ------- // 00 Direct // 01 Near Pointer // 10 Far pointer // 11 Huge pointer // Table 1.4, Format of typ // typ Basic type // --------------- // 000 Signed // 001 Unsigned // 010 Real // 011 Complex // 100 Boolean // 101 ASCII // 110 Currency // 111 Reserved // Table 1.5 Format of sz // sz Size (Real) (Complex) (Currency) // --------------------------------------------- // 00 8-bit 4-byte 8-byte Reserved // 01 16-bit 8-byte 16-byte 8-byte // 10 32-bit 10-byte 20-byte Reserved // 11 Reserved // Tables 1.6 and 1.7 list the predefined primitive types of the symbolic // debugging OMF. // Table 1.6 Special Types (8th bit = 0) // Name Value Description // ---------------------------- // T_NOTYPE 0 Uncharacterized type(no type) // T_ABS 1 Absolute symbol // Table 1.7 Primitive Type Listing(8th bit = 1) // Name Value Description // -------------------------------- // T_CHAR 80H 8-bit signed // T_SHORT 8lH 16-bit signed // T_LONG 82H 32-bit signed // T_UCHAR 84H 8-bit unsigned // T_USHORT 85H 16-bit unsigned // T_ULONG 86H 32-bit unsigned // T_REAL2 88H 32-bit real // T_REAL64 89H 64-bit real // T_REAL80 8AH(10) 80-bit real // T_CPLX64 8CH(12) 64-bit complex // T_CPLX128 8DH(13) 128-bit complex // T_CPLX160 8EH(14) 160-bit complex { 0x80, PrimitiveType_v1.Char8() }, { 0x81, PrimitiveType_v1.Int16() }, { 0x82, PrimitiveType_v1.Int32() }, { 0x84, new PrimitiveType_v1(Domain.UnsignedInt, 1) }, { 0x85, PrimitiveType_v1.UInt16() }, { 0x86, PrimitiveType_v1.UInt32() }, { 0x88, PrimitiveType_v1.Real32() }, { 0x89, PrimitiveType_v1.Real64() }, { 0x8A, PrimitiveType_v1.Real80() }, // T_BOOL08 90H(16) 8-bit Boolean // T_BOOL16 91H(17) 16-bit Boolean // T_BOOL32 9H(18) 32-bit Boolean // T_ ASCII 94H(20) 8-bit character // T_ASCII16 95H(21) 16-bit characters // T_ASCII32 96H(22) 32-bit characters // T_BSTRING 97H(23) Basic string type { 0x90, PrimitiveType_v1.Bool() }, { 0x91, PrimitiveType_v1.Bool(2) }, { 0x92, PrimitiveType_v1.Bool(4) }, // T_PCHAR A0H(32) Near pointer to 8-bit signed // T_PSHORT A1H(33) Near pointer to 16-bit signed // T_PLONG A2H(34) Near pointer to 32-bit signed // T_PUCHAR A4H(36) Near pointer to 8-bit unsigned // T_PUSHORT A5H(37) Near pointer to 16-bit unsigned // T_PULONG A6H(38) Near pointer to 32-bit unsigned // T_PREAL32 A8H(40) Near pointer to 32-bit real // T_PREAL64 A9H(41) Near pointer to 64-bit real // T_PREAL80 AAH(42) Near pointer to 80-bit real // T_PCPLX64 ACH(44) Near pointer to 64-bit complex // T_PCPLX128 ADH(45) Near pointer to 128-bit complex // T_ PCPLX160 AEH(46) Near pointer to 160-bit complex { 0xA0, NearPtr(PrimitiveType_v1.Char8()) }, { 0xA1, NearPtr(PrimitiveType_v1.Int16()) }, { 0xA2, NearPtr(PrimitiveType_v1.Int32()) }, { 0xA4, NearPtr(new PrimitiveType_v1 { Domain = Domain.UnsignedInt, ByteSize = 1 }) }, { 0xA5, NearPtr(PrimitiveType_v1.UInt16()) }, { 0xA6, NearPtr(PrimitiveType_v1.UInt32()) }, { 0xA8, NearPtr(PrimitiveType_v1.Real32()) }, { 0xA9, NearPtr(PrimitiveType_v1.Real64()) }, { 0xAA, NearPtr(PrimitiveType_v1.Real80()) }, // T_PBOOL08 B0H(48) Near pointer to 8-bit Boolean // T_PBOOL16 B1H(49) Near pointer to 16-bit Boolean // T_PBOOL32 B2H(50) Near pointer to 32-bit Boolean // T_PASCII B4H(52) Near pointer to 8-bit character // T_PASCII16 B5H(53) Near pointer to 16-bit character // T_PASC1132 B6H(54) Near pointer to 32-bit character // T_PBSTRING B7H(55) Near pointer to Basic string { 0xB0, NearPtr(PrimitiveType_v1.Bool()) }, { 0xB1, NearPtr(PrimitiveType_v1.Bool(2)) }, { 0xB2, NearPtr(PrimitiveType_v1.Bool(4)) }, // T_PFCHAR C0H(64) Far pointer to 8-bit signed // T_PFSHORT C1H(65) Far pointer to 16-bit signed // T_PFLONG C2H(66) Far pointer to 32-bit signed // T_PFUCHAR C4H(68) Far pointer to 8-bit unsigned // T_PFUSHORT C5H(69) Far pointer to 16-bit unsigned // T_PFULONG C6H(70) Far pointer to 32-bit unsigned // T_PFREAL32 C8H(72) Far pointer to 32-bit real // T_PFREAL64 C9H(73) Far pointer to 64-bit real // T_PFREAL80 CAH(74) Far pointer to 80-bit real // T_PFCPLX64 CCH(76) Far pointer to 64-bit complex // T_PFCPLX128 CDH(77) Far pointer to 128-bit complex // T_PFCPLX160 CEH(78) Far pointer to 160-bit complex { 0xC0, FarPtr(PrimitiveType_v1.Char8()) }, { 0xC1, FarPtr(PrimitiveType_v1.Int16()) }, { 0xC2, FarPtr(PrimitiveType_v1.Int32()) }, { 0xC4, FarPtr(new PrimitiveType_v1 { Domain = Domain.UnsignedInt, ByteSize = 1 }) }, { 0xC5, FarPtr(PrimitiveType_v1.UInt16()) }, { 0xC6, FarPtr(PrimitiveType_v1.UInt32()) }, { 0xC8, FarPtr(PrimitiveType_v1.Real32()) }, { 0xC9, FarPtr(PrimitiveType_v1.Real64()) }, { 0xCA, FarPtr(PrimitiveType_v1.Real80()) }, // T_PFBOOL08 D0H(80) Far pointer to 8-bit Boolean // T_PFBOOL16 D1H(81) Far pointer to 16-bit Boolean // T_PFBOO132 D2H(82) Far pointer to 32-bit Boolean // T_PFASCII D4H(84) Far pointer to 8-bit character // T_PFASCII16 D5H(85) Far pointer to 16-bit character // T_PFASCII32 D6H(86) Far pointer to 32-bit character // T_PFBSTRING D7H(87) Far pointer to Basic string { 0xD0, NearPtr(PrimitiveType_v1.Bool()) }, { 0xD1, NearPtr(PrimitiveType_v1.Bool(2)) }, { 0xD2, NearPtr(PrimitiveType_v1.Bool(4)) }, // T_PHCHAR E0H(96) Huge pointer to 8-bit signed // T_PHSHORT E1H(97) Huge pointer to 16-bit signed // T_PHLONG E2H(98) Huge pointer to 32-bit signed // T_PHUCHAR E4H(100) Huge pointer to 8-bit unsigned // T_PHUSHORT E5H(101) Huge pointer to 16-bit unsigned // T_PHULONG E6H(102) Huge pointer to 32-bit unsigned // T_PHREAL32 E8H(104) Huge pointer to 32-bit real // T_PHREAL64 E9H(105) Huge pointer to 64-bit real // T_PHREAL80 EAH(106) Huge pointer to 80-bit real // T_PHCPLX64 ECH(108) Huge pointer to 64-bit complex // T_PHCPLX128 EDH(109) Huge pointer to 128-bit complex // T_PHCPLX160 EEH(110) Huge pointer to 160-bit complex // T_PHBOOL08 F0H(112) Huge pointer to 8-bit Boolean // T_PHBOOL16 F1H(113) Huge pointer to 16-bit Boolean // T_PHBOOL32 F2H(114) Huge pointer to 32-bit Boolean // T_PHASCII F4H(116) Huge pointer to 8-bit character // T_PHASC1116 F5H(117) Huge pointer to 16-bit character // T_PHASC1132 F6H(118) Huge pointer to 32-bit character // T_PHBSTRING F7H(119) Huge pointer to Basic string }; }
private bool LoadParameter(SerializedSignature ssig, List <Argument_v1> args) { if (PeekAndDiscard(TokenType.NUMBER)) { return(true); } Token tok = Peek(); if (tok.Type != TokenType.ID) { return(false); } Get(); SerializedType type = null; switch (tok.Value) { case "word": case "s_word": type = new PrimitiveType_v1(PrimitiveType.Word16.Domain, 2); break; case "long": type = new PrimitiveType_v1(PrimitiveType.Word32.Domain, 4); break; //$TODO: need SegmentedPointerType case "segptr": case "segstr": type = new PrimitiveType_v1(Domain.SegPointer, 4); break; case "ptr": type = new PrimitiveType_v1(Domain.Pointer, 4); break; case "str": type = PointerType_v1.Create(PrimitiveType_v1.Char8(), 4); break; case "wstr": type = PointerType_v1.Create(PrimitiveType_v1.WChar16(), 4); break; case "uint16": type = PrimitiveType_v1.UInt16(); break; case "uint32": type = PrimitiveType_v1.UInt32(); break; case "uint64": type = PrimitiveType_v1.UInt64(); break; case "int16": type = PrimitiveType_v1.Int16(); break; case "int32": type = PrimitiveType_v1.Int32(); break; case "int64": type = PrimitiveType_v1.Int64(); break; default: throw new Exception("Unknown: " + tok.Value); } args.Add(new Argument_v1 { Type = type }); return(true); }
private SerializedType Type() { switch (str[i++]) { case 'v': return(new VoidType_v1()); case 'b': return(PrimitiveType_v1.Bool()); case 'c': return(PrimitiveType_v1.Char8()); case 'h': return(PrimitiveType_v1.UChar8()); case 's': return(PrimitiveType_v1.Int16()); case 't': return(PrimitiveType_v1.UInt16()); case 'i': return(PrimitiveType_v1.Int32()); case 'j': return(PrimitiveType_v1.UInt32()); case 'l': return(PrimitiveType_v1.Int64()); case 'm': return(PrimitiveType_v1.UInt64()); case 'w': return(PrimitiveType_v1.WChar16()); case 'f': return(PrimitiveType_v1.Real32()); case 'd': return(PrimitiveType_v1.Real64()); case 'F': --i; return(FunctionType()); case 'N': --i; return(CreateTypeReference(NestedName())); case 'P': var ptr = new PointerType_v1 { DataType = Type(), PointerSize = ptrSize }; AddSubstitution(ptr); return(ptr); case 'R': //$TODO: Reko doesn't have a concept of 'const' or 'volatile'. // Needs to be implemented for completeness, but should not affect // quality of decompilation. var qual = CvQualifier(); return(new ReferenceType_v1 { Referent = Type(), Size = ptrSize }); case 'S': switch (str[i++]) { case 't': return(new TypeReference_v1 { Scope = new[] { "std" }, TypeName = Type().ToString(), }); case 's': return(new TypeReference_v1 { Scope = new[] { "std" }, TypeName = "string" }); default: int iStart = --i; while (str[i] != '_') { ++i; } ++i; var sub = str.Substring(iStart, i - iStart); Debug.Print(sub); return((SerializedType)substitutions[sub]); } throw new NotImplementedException(); default: --i; if (char.IsDigit(str[i])) { var tref = new TypeReference_v1 { TypeName = UnqualifiedName() }; AddSubstitution(tref); return(tref); } throw new NotImplementedException(string.Format("Unknown GCC type code '{0}' ({1}).", str[i], str.Substring(i))); } }