asm/asm.h
changeset 0 4c53fd0b014e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/asm/asm.h	Fri Feb 20 15:24:04 2009 +1300
     1.3 @@ -0,0 +1,40 @@
     1.4 +#ifndef __ASM_H__
     1.5 +#define __ASM_H__
     1.6 +
     1.7 +#define OP_JMP				0xE9
     1.8 +#define OP_JMP_SIZE			5
     1.9 +
    1.10 +#define OP_NOP				0x90
    1.11 +#define OP_NOP_SIZE			1
    1.12 +
    1.13 +#define OP_PREFIX			0xFF
    1.14 +#define OP_JMP_SEG			0x25
    1.15 +
    1.16 +#define OP_JMP_BYTE			0xEB
    1.17 +#define OP_JMP_BYTE_SIZE	2
    1.18 +
    1.19 +#ifdef __cplusplus
    1.20 +extern "C" {
    1.21 +#endif
    1.22 +
    1.23 +void check_thunks(unsigned char *dest, unsigned char *pc);
    1.24 +
    1.25 +//if dest is NULL, returns minimum number of bytes needed to be copied
    1.26 +//if dest is not NULL, it will copy the bytes to dest as well as fix CALLs and JMPs
    1.27 +//http://www.devmaster.net/forums/showthread.php?t=2311
    1.28 +int copy_bytes(unsigned char *func, unsigned char* dest, int required_len);
    1.29 +
    1.30 +//insert a specific JMP instruction at the given location
    1.31 +void inject_jmp(void* src, void* dest);
    1.32 +
    1.33 +//fill a given block with NOPs
    1.34 +void fill_nop(void* src, unsigned int len);
    1.35 +
    1.36 +//evaluate a JMP at the target
    1.37 +void* eval_jump(void* src);
    1.38 +
    1.39 +#ifdef __cplusplus
    1.40 +}
    1.41 +#endif
    1.42 +
    1.43 +#endif //__ASM_H__