From a4a3de2ad363b1bceb28f106e2cc6d811b3370b5 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Mon, 12 Jan 2026 15:19:16 -0700 Subject: Add handling of structure returns and parameters in Windows x86/x64 calling conventions --- arch/x86/arch_x86.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'arch') diff --git a/arch/x86/arch_x86.cpp b/arch/x86/arch_x86.cpp index aeeed4e7..83a476bf 100644 --- a/arch/x86/arch_x86.cpp +++ b/arch/x86/arch_x86.cpp @@ -3827,6 +3827,23 @@ public: } return result; } + + bool IsReturnTypeRegisterCompatible(BinaryView*, Type* type) override + { + if (!type) + return false; + if (type->IsFloat()) + return true; + if (type->GetWidth() == 0 || type->GetWidth() == 1 || type->GetWidth() == 2 || type->GetWidth() == 4 + || type->GetWidth() == 8) + return true; + return false; + } + + std::optional GetReturnedIndirectReturnValuePointer() override + { + return Variable::Register(XED_REG_EAX); + } }; @@ -4060,6 +4077,36 @@ public: { return true; } + + bool IsReturnTypeRegisterCompatible(BinaryView*, Type* type) override + { + if (!type) + return false; + if (type->IsFloat()) + return true; + return type->GetWidth() == 0 || type->GetWidth() == 1 || type->GetWidth() == 2 || type->GetWidth() == 4 + || type->GetWidth() == 8; + } + + std::optional GetReturnedIndirectReturnValuePointer() override + { + return Variable::Register(XED_REG_RAX); + } + + bool IsArgumentTypeRegisterCompatible(BinaryView*, Type* type) override + { + if (!type) + return false; + if (type->IsFloat()) + return true; + return type->GetWidth() == 0 || type->GetWidth() == 1 || type->GetWidth() == 2 || type->GetWidth() == 4 + || type->GetWidth() == 8; + } + + bool IsNonRegisterArgumentIndirect(BinaryView*, Type*) override + { + return true; + } }; -- cgit v1.3.1