rendered paste body#include <stdio.h>
#include <string.h>
class FistDetour
{
private:
unsigned long counter;
unsigned long numOfBytes;
void *funcPtr;
unsigned char *code;
public:
FistDetour(void *funcPtr, unsigned long bytes = 0)
{
this->funcPtr = funcPtr;
this->numOfBytes = bytes;
this->code = new unsigned char;
}
~FistDetour()
{
delete code;
}
unsigned char getInstructionAt(unsigned long offset)
{
memcpy((void *)code, (void *)((unsigned long)this->funcPtr + offset), 1);
return *(this->code);
}
};
int myFunc()
{
return 0;
}
int main()
{
FistDetour *detours = new FistDetour((void *)myFunc);
int counter = 0;
unsigned char code;
while(counter < 15)
{
code = detours->getInstructionAt(counter);
printf("myFunc(0x%X) + %d \t\t 0x%X\n", myFunc, counter, code);
counter++;
if(0xC3 == code)
break;
}
delete detours;
}