Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Proof-of-concept support of thiscall
Browse files Browse the repository at this point in the history
  • Loading branch information
yegord committed Jun 9, 2015
1 parent e9705fa commit 50bffeb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/nc/arch/x86/CallingConventions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ Cdecl32CallingConvention::Cdecl32CallingConvention(const X86Architecture *archit
setFirstArgumentOffset(architecture->bitness());
setArgumentAlignment(architecture->bitness());

addArgumentGroup(std::vector<core::ir::MemoryLocation>(1, X86Registers::ecx()->memoryLocation()));
addArgumentGroup(std::vector<core::ir::MemoryLocation>());

addReturnValueLocation(X86Registers::eax()->memoryLocation());
addReturnValueLocation(X86Registers::st0()->memoryLocation());

Expand Down Expand Up @@ -146,6 +149,9 @@ Stdcall32CallingConvention::Stdcall32CallingConvention(const X86Architecture *ar
setArgumentAlignment(architecture->bitness());
setCalleeCleanup(true);

addArgumentGroup(std::vector<core::ir::MemoryLocation>(1, X86Registers::ecx()->memoryLocation()));
addArgumentGroup(std::vector<core::ir::MemoryLocation>());

addReturnValueLocation(X86Registers::ax()->memoryLocation());
addReturnValueLocation(X86Registers::st0()->memoryLocation());

Expand Down
2 changes: 2 additions & 0 deletions src/nc/arch/x86/CallingConventions.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class Microsoft64CallingConvention: public core::ir::calling::Convention {

/**
* 32-bit cdecl calling convention.
* Tweaked to allow passing one argument via ecx (like in thiscall).
*/
class Cdecl32CallingConvention: public core::ir::calling::Convention {
public:
Expand All @@ -79,6 +80,7 @@ class Cdecl16CallingConvention: public core::ir::calling::Convention {

/**
* 32-bit stdcall calling convention.
* Tweaked to allow passing one argument via ecx (like in thiscall).
*/
class Stdcall32CallingConvention: public core::ir::calling::Convention {
public:
Expand Down

0 comments on commit 50bffeb

Please sign in to comment.