public ParseFunctionDeclaration ( string fnDecl ) : |
||
fnDecl | string | |
Résultat |
public void Usb_ParseFunctionDeclaration() { Given_Procedure(0x1000); var usb = new UserSignatureBuilder(program); var sProc = usb.ParseFunctionDeclaration("int foo(char *)", proc.Frame); Assert.AreEqual( "fn(arg(prim(SignedInt,4)),(arg(ptr(prim(Character,1))))", sProc.Signature.ToString()); }
public void Usb_ParseFunctionDeclaration_PlatfromTypes() { var platformTypes = new Dictionary<string, DataType>() { { "BYTE", PrimitiveType.Create(PrimitiveType.Byte.Domain, 1) }, }; mockFactory.Given_PlatformTypes(platformTypes); Given_Procedure(0x1000); var usb = new UserSignatureBuilder(program); var sProc = usb.ParseFunctionDeclaration("BYTE foo(BYTE a, BYTE b)", proc.Frame); Assert.AreEqual( "fn(arg(BYTE),(arg(a,BYTE)arg(b,BYTE))", sProc.Signature.ToString()); }
public void Usb_ParseFunctionDeclaration_PlatfromTypes() { program.EnvironmentMetadata.Types.Add( "BYTE", PrimitiveType.Create(PrimitiveType.Byte.Domain, 1)); Given_Procedure(0x1000); var usb = new UserSignatureBuilder(program); var sProc = usb.ParseFunctionDeclaration("BYTE foo(BYTE a, BYTE b)"); Assert.AreEqual( "fn(arg(BYTE),(arg(a,BYTE),arg(b,BYTE))", sProc.Signature.ToString()); }
public void Usb_ParseFunctionDeclaration_UserDefinedTypes() { var platformTypes = new Dictionary<string, DataType>() { { "BYTE", PrimitiveType.Create(PrimitiveType.Byte.Domain, 1) }, }; var userDefinedTypes1 = new Dictionary<string, DataType>() { { "USRDEF1", PrimitiveType.Create( PrimitiveType.Int16.Domain, 2 ) }, }; var userDefinedTypes2 = new Dictionary<string, DataType>() { { "USRDEF2", PrimitiveType.Create( PrimitiveType.Int16.Domain, 2 ) }, }; mockFactory.Given_PlatformTypes(platformTypes); Given_Procedure(0x1000); var usb = new UserSignatureBuilder(program); //should accept user defined type USRDEF1 mockFactory.Given_UserDefinedMetafile("mod1", userDefinedTypes1, null, null); var sProc = usb.ParseFunctionDeclaration("BYTE foo(USRDEF1 a, BYTE b)", proc.Frame); Assert.AreEqual( "fn(arg(BYTE),(arg(a,USRDEF1)arg(b,BYTE))", sProc.Signature.ToString()); //should not accept undefined type USRDEF2 sProc = usb.ParseFunctionDeclaration("BYTE foo(USRDEF1 a, USRDEF2 b)", proc.Frame); Assert.AreEqual(null, sProc); //define USRDEF2 so parser should accept it mockFactory.Given_UserDefinedMetafile("mod2", userDefinedTypes2, null, null); sProc = usb.ParseFunctionDeclaration("BYTE foo(USRDEF1 a, USRDEF2 b)", proc.Frame); Assert.AreEqual( "fn(arg(BYTE),(arg(a,USRDEF1)arg(b,USRDEF2))", sProc.Signature.ToString()); }
public void Usb_ParseFunctionDeclaration_UserDefinedTypes() { program.EnvironmentMetadata.Types.Add( "BYTE", PrimitiveType.Create(PrimitiveType.Byte.Domain, 1)); Given_Procedure(0x1000); var usb = new UserSignatureBuilder(program); //should accept user defined type USRDEF1 program.EnvironmentMetadata.Types.Add( "USRDEF1", PrimitiveType.Create(PrimitiveType.Int16.Domain, 2)); var sProc = usb.ParseFunctionDeclaration("BYTE foo(USRDEF1 a, BYTE b)"); Assert.AreEqual( "fn(arg(BYTE),(arg(a,USRDEF1),arg(b,BYTE))", sProc.Signature.ToString()); //should not accept undefined type USRDEF2 sProc = usb.ParseFunctionDeclaration("BYTE foo(USRDEF1 a, USRDEF2 b)"); Assert.AreEqual(null, sProc); //define USRDEF2 so parser should accept it program.EnvironmentMetadata.Types.Add( "USRDEF2", PrimitiveType.Create(PrimitiveType.Int16.Domain, 2)); sProc = usb.ParseFunctionDeclaration("BYTE foo(USRDEF1 a, USRDEF2 b)"); Assert.AreEqual( "fn(arg(BYTE),(arg(a,USRDEF1),arg(b,USRDEF2))", sProc.Signature.ToString()); }
private bool TryGetNoDecompiledParsedProcedure(Address addr, out Procedure_v1 parsedProc) { Procedure_v1 sProc; if (!TryGetNoDecompiledProcedure(addr, out sProc)) { parsedProc = null; return false; } if (noDecompiledProcs.TryGetValue(addr, out parsedProc)) return true; parsedProc = new Procedure_v1() { Name = sProc.Name, }; noDecompiledProcs[addr] = parsedProc; if (string.IsNullOrEmpty(sProc.CSignature)) { Warn(addr, "The user-defined procedure at address {0} did not have a signature.", addr); return true; } var usb = new UserSignatureBuilder(program); var procDecl = usb.ParseFunctionDeclaration(sProc.CSignature); if (procDecl == null) { Warn(addr, "The user-defined procedure signature at address {0} could not be parsed.", addr); return true; } parsedProc.Signature = procDecl.Signature; return true; }
private bool TryParseSignature(string txtSignature, out ProcedureBase_v1 sProc) { sProc = null; if (program == null || program.Platform == null) { return false; } // Attempt to parse the signature. var usb = new UserSignatureBuilder(program); sProc = usb.ParseFunctionDeclaration(txtSignature); return sProc != null; }
protected void Signature_TextChanged(object sender, EventArgs e) { // Attempt to parse the signature. var CSignature = dlg.Signature.Text.Trim(); ProcedureBase_v1 sProc = null; bool isValid; if (!string.IsNullOrEmpty(CSignature)) { var usb = new UserSignatureBuilder(program); sProc = usb.ParseFunctionDeclaration(CSignature); isValid = (sProc != null); } else { CSignature = null; isValid = true; } EnableControls(isValid); if (isValid) { if (sProc != null) dlg.ProcedureName.Text = sProc.Name; EnableProcedureName(); } }
private bool TryGetNoDecompiledProcedure(Address addr, out ExternalProcedure ep) { Procedure_v1 sProc; if (!program.User.Procedures.TryGetValue(addr, out sProc) || sProc.Decompile) { ep = null; return false; } FunctionType sig = null; if (!string.IsNullOrEmpty(sProc.CSignature)) { var usb = new UserSignatureBuilder(program); var procDecl = usb.ParseFunctionDeclaration(sProc.CSignature); if (procDecl != null) { var ser = program.CreateProcedureSerializer(); sig = ser.Deserialize( procDecl.Signature, program.Architecture.CreateFrame()); } } else { Warn(addr, "The user-defined procedure at address {0} did not have a signature.", addr); } ep = new ExternalProcedure(sProc.Name, sig); return true; }