-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathExample.cpp
43 lines (32 loc) · 1.12 KB
/
Example.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "ThreadIn.h"
#include <iostream>
DWORD WINAPI threadStartFunction(LPVOID lpParam) {
using namespace std;
while (true) {
cout << "Hello world!" << endl;
this_thread::sleep_for(1s);
}
}
DWORD WINAPI threadStartFunction2(LPVOID lpParam) {
using namespace std;
while (true) {
cout << "Hello world!" << endl;
this_thread::sleep_for(1s);
}
}
void threadStartFunction2Detour(__int64 a1, __int64 a2, __int64 a3, ...) {
using namespace std;
cout << "From detour, a1: " << a1 << endl;
cout << "From detour, a2: " << a2 << endl;
cout << "From detour, a3: " << a3 << endl;
}
int main() {
using namespace std;
CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)threadStartFunction, (HMODULE) nullptr, 0, nullptr);
// CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)threadStartFunction2, (HMODULE) nullptr, 0, nullptr);
// Freeze threadStartFunction
ii::ThreadIn(reinterpret_cast<__int64>(&threadStartFunction));
// Hook threadStartFunction2 to threadStartFunction2Detour
// ii::ThreadIn(reinterpret_cast<__int64>(&threadStartFunction2), reinterpret_cast<__int64>(&threadStartFunction2Detour));
return getchar();
}