public Expression VisitStackArgumentStorage(StackArgumentStorage stack) { if (ensureVariables) { return(frame.EnsureStackVariable( stack.StackOffset - (site.StackDepthOnEntry + sigCallee.ReturnAddressOnStack), stack.DataType)); } else { return(arch.CreateStackAccess(frame, stack.StackOffset, stack.DataType)); } }
public Expression VisitStackArgumentStorage(StackArgumentStorage stack) { if (ensureVariables) { return(binder.EnsureStackVariable( stack.StackOffset - site.StackDepthOnEntry, stack.DataType)); } else { return(arch.CreateStackAccess( binder, stack.StackOffset - site.SizeOfReturnAddressOnStack, stack.DataType)); } }
private string?ReadVarargsFormat(Address addrInstr, Expression callee, FunctionType sig) { var formatIndex = sig.Parameters !.Length - 1; if (formatIndex < 0) { throw new ApplicationException("Expected variadic function to take at least one parameter."); } var formatParam = sig.Parameters[formatIndex]; // $TODO: Issue #471: what about non-x86 architectures, like Sparc or PowerPC, // there can be varargs functions where the first N parameters are // passed in registers and the remaining are passed on the stack. if (formatParam.Storage is StackStorage stackStorage) { var stackAccess = arch.CreateStackAccess( frame, stackStorage.StackOffset, stackStorage.DataType); if (GetValue(stackAccess) is Constant c && c.IsValid) { var str = ReadCString(c); if (str != null) { return(str); } } } else { var reg = GetValue(formatParam) as Address; if (reg != null) { var str = ReadCString(reg); if (str != null) { return(str); } } } WarnUnableToDetermineFormatString(addrInstr, callee); return(null); }
private string ReadVarargsFormat(FunctionType sig) { var formatIndex = sig.Parameters.Length - 2; if (formatIndex < 0) { throw new ApplicationException( string.Format("Varargs: should be at least 2 parameters")); } var formatParam = sig.Parameters[formatIndex]; // $TODO: Issue #471: what about non-x86 architectures, like Sparc or PowerPC, // there can be varargs functions where the first N parameters are // passed in registers and the remaining are passed on the stack. var stackStorage = formatParam.Storage as StackStorage; if (stackStorage == null) { var reg = GetValue(formatParam) as Address; if (reg != null) { return(ReadCString(reg)); } throw new NotSupportedException( string.Format( "The {0} parameter of {1} wasn't a stack access.", formatParam.Name, sig.Name)); } var stackAccess = arch.CreateStackAccess( frame, stackStorage.StackOffset, stackStorage.DataType); var c = GetValue(stackAccess) as Constant; if (c == null || !c.IsValid) { throw new ApplicationException( string.Format("Varargs: invalid format constant")); } return(ReadCString(c)); }
private string ReadVarargsFormat(Address addrInstr, Expression callee, FunctionType sig) { var formatIndex = sig.Parameters.Length - 2; if (formatIndex < 0) { throw new ApplicationException( string.Format("Varargs: should be at least 2 parameters")); } var formatParam = sig.Parameters[formatIndex]; // $TODO: Issue #471: what about non-x86 architectures, like Sparc or PowerPC, // there can be varargs functions where the first N parameters are // passed in registers and the remaining are passed on the stack. var stackStorage = formatParam.Storage as StackStorage; if (stackStorage == null) { var reg = GetValue(formatParam) as Address; if (reg != null) { return(ReadCString(reg)); } WarnUnableToDetermineFormatString(addrInstr, callee); return(null); } var stackAccess = arch.CreateStackAccess( frame, stackStorage.StackOffset, stackStorage.DataType); var c = GetValue(stackAccess) as Constant; if (c == null || !c.IsValid) { WarnUnableToDetermineFormatString(addrInstr, callee); return(null); } return(ReadCString(c)); }