drifter01620@184: #ifndef __ASM_H__ drifter01620@184: #define __ASM_H__ drifter01620@184: drifter01620@184: #define OP_JMP 0xE9 drifter01620@184: #define OP_JMP_SIZE 5 drifter01620@184: drifter01620@184: #define OP_NOP 0x90 drifter01620@184: #define OP_NOP_SIZE 1 drifter01620@184: drifter01620@184: #define OP_PREFIX 0xFF drifter01620@184: #define OP_JMP_SEG 0x25 drifter01620@184: drifter01620@184: #define OP_JMP_BYTE 0xEB drifter01620@184: #define OP_JMP_BYTE_SIZE 2 drifter01620@184: drifter01620@184: #ifdef __cplusplus drifter01620@184: extern "C" { drifter01620@184: #endif drifter01620@184: drifter01620@184: void check_thunks(unsigned char *dest, unsigned char *pc); drifter01620@184: drifter01620@184: //if dest is NULL, returns minimum number of bytes needed to be copied drifter01620@184: //if dest is not NULL, it will copy the bytes to dest as well as fix CALLs and JMPs drifter01620@184: //http://www.devmaster.net/forums/showthread.php?t=2311 drifter01620@184: int copy_bytes(unsigned char *func, unsigned char* dest, int required_len); drifter01620@184: drifter01620@184: //insert a specific JMP instruction at the given location drifter01620@184: void inject_jmp(void* src, void* dest); drifter01620@184: drifter01620@184: //fill a given block with NOPs drifter01620@184: void fill_nop(void* src, unsigned int len); drifter01620@184: drifter01620@184: //evaluate a JMP at the target drifter01620@184: void* eval_jump(void* src); drifter01620@184: drifter01620@184: #ifdef __cplusplus drifter01620@184: } drifter01620@184: #endif drifter01620@184: drifter01620@184: #endif //__ASM_H__