not the best way but a works way at all
Code:
#include <stdio.h>
#include <windows.h>
void TestFunction(){
__asm{
nop
nop
nop
nop
push 1
call exit
nop
nop
nop
nop
};
}
/*
push tmpptr
push ffs
call printf
*/
void FuncToBytes(void*function,DWORD byte_start,DWORD byte_end){
char *ff_s = "Hacking Into The Function Location : 0x%x\n";
char *ffs = "ESI First 4 Bytes Location : 0x%x\n";
char *ff_s_ = "ESI Last 4 Bytes Location : 0x%x\n";
char *Bytez = "OpCodes 0x%x In Addr 0x%x\n";
DWORD *start_addr;
DWORD *end_addr;
__asm{
mov esi, function
push esi
push ff_s
call printf
jmp de
jmp_inc:inc esi
jmp de
de:
mov ebx, [esi]
cmp ebx, byte_start
jne jmp_inc
push esi
push ffs
call printf
mov start_addr, esi
jmp next_
next_: add esi, 4
xor ebx, ebx
jmp s_scan
jmp_: inc esi
jmp s_scan
s_scan: mov ebx, [esi]
cmp ebx, byte_end
jne jmp_
mov end_addr, esi
//sub end_addr, 4
push esi
push ff_s_
call printf
xor esi, esi
};
printf("\n");
for(DWORD i=(unsigned long)start_addr; i<(unsigned long)end_addr;i++){
//Bytez
__asm{
mov esi, i
mov ebx, [esi]
push esi
push ebx
push Bytez
call printf
}
}
__asm{
call exit
}
}
int main(){
//first nops //last nops
FuncToBytes(TestFunction,0x90909090,0x90909090);
return 0;
}