#pragma once
#include "IAsmHelper.h"
namespace blackbone
{
///
/// 32 bit assembler helper
///
class AsmHelper32 : public IAsmHelper
{
public:
BLACKBONE_API AsmHelper32( );
BLACKBONE_API ~AsmHelper32( void );
///
/// Generate function prologue code
///
/// Unused
virtual void GenPrologue( bool switchMode = false );
///
/// Generate function epilogue code
///
/// Unused
/// Stack change value
virtual void GenEpilogue( bool switchMode = false, int retSize = -1 );
///
/// Generate function call
///
/// Function pointer
/// Function arguments
/// Calling convention
virtual void GenCall( const AsmFunctionPtr& pFN, const std::vector& args, eCalligConvention cc = cc_stdcall );
///
/// Save eax value and terminate current thread
///
/// NtTerminateThread address
/// Memory where eax value will be saved
virtual void ExitThreadWithStatus( uint64_t pExitThread, uint64_t resultPtr );
///
/// Save return value and signal thread return event
///
/// NtSetEvent address
/// Result value memory location
/// Event memory location
/// Error code memory location
/// Return type
virtual void SaveRetValAndSignalEvent(
uint64_t pSetEvent,
uint64_t ResultPtr,
uint64_t EventPtr,
uint64_t errPtr,
eReturnType rtype = rt_int32
);
///
/// Does nothing under x86
///
/// Unused
virtual void EnableX64CallStack( bool ) { }
private:
AsmHelper32( const AsmHelper32& ) = delete;
AsmHelper32& operator = (const AsmHelper32&) = delete;
///
/// Push function argument
///
/// Argument.
/// Push type(register or stack)
void PushArg( const AsmVariant& arg, eArgType regidx = at_stack );
///
/// Push argument into function
///
/// Argument
/// Argument location
template
void PushArgp( _Type arg, eArgType index );
};
}