inital commit. currently all winapi

This commit is contained in:
2016-04-03 17:04:20 +02:00
commit 3b681758f4
76 changed files with 13747 additions and 0 deletions

79
main.c Normal file
View File

@@ -0,0 +1,79 @@
#include <stdio.h>
#include <Windows.h>
#include "misc.h"
#include "hook.h"
#if 0
Check whether trampoline works correctly
start:
je lbl1
jmp lbl1
lbl1:
---
hook() == LOOPS_INTO_OVERWRITTEN_CODE
start:
mov eax, 3
l:
dec eax
test eax, eax
je l
#endif
static int test(int a, int b);
static void normal(int a, int b, int c, int d, int e);
static void normal2(int a, int b, int c, int d, int e);
typedef void(*FUNCTYPE)(int a, int b, int c, int d, int e);
static void hooked(int a, int b, int c, int d, int e);
static FUNCTYPE original;
int main(int argc, char** argv)
{
int r = 0;
if((r = hook(normal2, 0, hooked, &original)) < 0)
{
printf("CAn't hook: %d\n", r);
return 1;
}
printf("---\nDisass. trampoline/original\n");
disassemble_func(original, 10);
original(3, 1, 1, 1, 1);
//original(5, 1, 1, 1, 1);
VirtualFree(original, 0, MEM_RELEASE);
(void)getc(stdin);
}
static int test(int a, int b)
{
if(a == 0)
return 5;
else if(a == 1)
return b;
return a;
}
static void normal(int a, int b, int c, int d, int e)
{
printf("Result: %d\n", a*b*c*d*e);
}
static void normal2(int a, int b, int c, int d, int e)
{
if(a == 3)
return;
printf("Result: %d\n", a*b*c*d*e);
}
static void hooked(int a, int b, int c, int d, int e)
{
original(1, b, c, d, e);
}