-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPeeved.cpp
More file actions
664 lines (548 loc) · 28.2 KB
/
Copy pathPeeved.cpp
File metadata and controls
664 lines (548 loc) · 28.2 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
#include "stdafx.h"
#include <stdio.h>
#include <windows.h>
#include <iostream>
#include <fstream>
#include <python.h>
using namespace std;
#include "detours.h"
#define THISEXPORTS
#if defined(THISEXPORTS)
#define KEYDLL3_API __declspec(dllexport)
#else
#define KEYDLL3_API __declspec(dllimport)
#endif
#pragma data_seg(".HOOKDATA")//Shared data among all instances.
HHOOK hook = NULL;
HINSTANCE hinsta = NULL;
#pragma data_seg()
//linker directive
#pragma comment(linker, "/SECTION:.HOOKDATA,RWS")
//This function installs the Keyboard hook:
KEYDLL3_API void installhook();
//This function removes the previously installed hook.
KEYDLL3_API void removehook();
//hook procedure:
KEYDLL3_API LRESULT CALLBACK hookproc( int ncode,
WPARAM wparam,
LPARAM lparam);
bool running = false;
bool adamloaded = false;
bool fileloaded =false;
HINSTANCE hinstance = NULL;
HANDLE threadhandle = NULL;
DWORD WINAPI threadfunc(LPVOID junk);
static LONG nExtends = 0;
static LONG nInterns = 0;
static ofstream myfile;
static char *(*TruePy_GetPath)() = NULL;
static int ( * TruePyRun_AnyFile)( FILE *fp, const char *filename) = NULL;
static int ( * TruePyRun_AnyFileFlags)( FILE *fp, const char *filename, void *flags) = NULL;
static int ( * TruePyRun_AnyFileEx)( FILE *fp, const char *filename, int closeit) = NULL;
static int ( * TruePyRun_AnyFileExFlags)( FILE *fp, const char *filename, int closeit, void *flags) = NULL;
static int ( * TruePyRun_SimpleString)( const char *command) = NULL;
static int ( * TruePyRun_SimpleStringFlags)( const char *command, void *flags) = NULL;
static int ( * TruePyRun_SimpleFile)( FILE *fp, const char *filename) = NULL;
static int ( * TruePyRun_SimpleFileFlags)( FILE *fp, const char *filename, void *flags) = NULL;
static int ( * TruePyRun_SimpleFileEx)( FILE *fp, const char *filename, int closeit) = NULL;
static int ( * TruePyRun_SimpleFileExFlags)( FILE *fp, const char *filename, int closeit, void *flags) = NULL;
static int ( * TruePyRun_InteractiveOne)( FILE *fp, const char *filename) = NULL;
static int ( * TruePyRun_InteractiveOneFlags)( FILE *fp, const char *filename, void *flags) = NULL;
static int ( * TruePyRun_InteractiveLoop)( FILE *fp, const char *filename) = NULL;
static int ( * TruePyRun_InteractiveLoopFlags)( FILE *fp, const char *filename, void *flags) = NULL;
static void* ( * TruePyParser_SimpleParseString)( const char *str, int start) = NULL;
static void* ( * TruePyParser_SimpleParseStringFlags)( const char *str, int start, int flags) = NULL;
static void* ( * TruePyParser_SimpleParseStringFlagsFilename)( const char *str, const char *filename, int start, int flags) = NULL;
static void* ( * TruePyParser_SimpleParseFile)( FILE *fp, const char *filename, int start) = NULL;
static void* ( * TruePyParser_SimpleParseFileFlags)( FILE *fp, const char *filename, int start, int flags) = NULL;
static void* ( * TruePyRun_String)( const char *str, int start, void *globals, void *locals) = NULL;
static void* ( * TruePyRun_StringFlags)( const char *str, int start, void *globals, void *locals, void *flags) = NULL;
static void* ( * TruePyRun_File)( FILE *fp, const char *filename, int start, void *globals, void *locals) = NULL;
static void* ( * TruePyRun_FileEx)( FILE *fp, const char *filename, int start, void *globals, void *locals, int closeit) = NULL;
static void* ( * TruePyRun_FileFlags)( FILE *fp, const char *filename, int start, void *globals, void *locals, void *flags) = NULL;
static void* ( * TruePyRun_FileExFlags)( FILE *fp, const char *filename, int start, void *globals, void *locals, int closeit, void *flags) = NULL;
static void* ( * TruePy_CompileString)( const char *str, const char *filename, int start) = NULL;
static void* ( * TruePy_CompileStringFlags)( const char *str, const char *filename, int start, void *flags) = NULL;
static void* (*TruePyImport_ImportModule)( const char *name) = NULL;
static void* (*TruePyImport_ImportModuleEx)( char *name, void *globals, void *locals, void *fromlist) = NULL;
static void * (*TruePyString_FromString)( char *name) = NULL;
static PyObject * (*TruePyImport_AddModule)(char* name) = NULL;
static PyObject* (*TruePyModule_GetDict)( PyObject *module) = NULL;
static PyObject* (*TruePyDict_GetItemString)( PyObject *p, const char *key) = NULL;
static int (*TruePyDict_Check)( PyObject *p)=NULL;
static PyObject* (*TruePyDict_Keys)( PyObject *p) = NULL;
static PyObject* (*TruePyList_GetItem)( PyObject *list, Py_ssize_t index) = NULL;
static Py_ssize_t (*TruePyList_Size)( PyObject *list) = NULL;
static char* (*TruePyString_AsString)( PyObject *string) = NULL;
static int (*TruePyModule_AddObject)( PyObject *module, const char *name, PyObject *value) = NULL;
static PyObject* (*TruePyObject_CallObject)( PyObject *callable_object, PyObject *args) = NULL;
static int ( * TrueWinMain)(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow) = NULL;
KEYDLL3_API void installhook()
{
hook = NULL;
hook = SetWindowsHookEx( WH_KEYBOARD,
hookproc,
hinsta,
NULL);
if(hook==NULL)
MessageBox( NULL,
L"Unable to install hook",
L"Error!",
MB_OK);
}
KEYDLL3_API void removehook()
{
UnhookWindowsHookEx(hook);
}
KEYDLL3_API LRESULT CALLBACK hookproc( int ncode,
WPARAM wparam,
LPARAM lparam)
{
if(wparam == VK_DIVIDE)
{
UnhookWindowsHookEx(hook);
}
/*
else if(wparam == VK_DIVIDE && adamloaded ==false)
{
adamloaded = true;
MessageBox(0,L"adamadam.py", L"",MB_OK);
FILE *fp2 =fopen("C:\\adamadam.py","r");
TruePyRun_SimpleFile(fp2,"C:\\adamadam.py");
Sleep(1000);
}*/
else if(wparam == VK_MULTIPLY && fileloaded == false)
{
fileloaded = true;
//MessageBox(0,L"file.py", L"",MB_OK);
FILE *fp2;
fp2 =fopen("C:\\file.py","r");
TruePyRun_SimpleFile(fp2,"C:\\file.py");
Sleep(1000);
}
//pass control to next hook.
return ( CallNextHookEx(hook,ncode,wparam,lparam) );
}
// Every detour DLL needs at least one export for use by setdll.exe or
// withdll.exe. The export is never called, just referenced to force load.
VOID NullExport()
{
}
//
static int CALLCOUNT = 0;
CRITICAL_SECTION cs;
static PyObject* myTruePyObject_CallObject(PyObject *callable_object, PyObject *args)
{
return TruePyObject_CallObject(callable_object, args);
}
// static int myTruePyModule_AddObject( PyObject *module, const char *name, PyObject *value)
// {
//
// return TruePyModule_AddObject(module, name,value);
// }
//
// static void * myTruePyString_FromString( char *name)
// {
// return TruePyString_FromString(name);
// }
// static void* myTruePyImport_ImportModule( const char *name)
// {
// return TruePyImport_ImportModule(name);
// }
// static void* myTruePyImport_ImportModuleEx( char *name, void *globals, void *locals, void *fromlist)
// {
//
// return TruePyImport_ImportModuleEx(name,globals,locals,fromlist);
// }
//
// static int myTruePyRun_AnyFile( FILE *fp, const char *filename)
// {
// return TruePyRun_AnyFile(fp,filename);
// }
// static int myTruePyRun_AnyFileFlags( FILE *fp, const char *filename, void *flags)
// {
// return TruePyRun_AnyFileFlags( fp, filename, flags);
// }
// static int myTruePyRun_AnyFileEx( FILE *fp, const char *filename, int closeit)
// {
// return TruePyRun_AnyFileEx(fp,filename, closeit);
// }
// static int myTruePyRun_AnyFileExFlags( FILE *fp, const char *filename, int closeit, void *flags)
// {
// return TruePyRun_AnyFileExFlags(fp, filename, closeit, flags);
// }
// static int myTruePyRun_SimpleString( const char *command)
// {
// return TruePyRun_SimpleString( command);
// }
// static int myTruePyRun_SimpleStringFlags( const char *command, void *flags)
// {
// return TruePyRun_SimpleStringFlags( command, flags);
// }
//
// static int myTruePyRun_SimpleFileFlags( FILE *fp, const char *filename, void *flags)
// {
// return TruePyRun_SimpleFileFlags( fp, filename, flags);
// }
// static int myTruePyRun_SimpleFileEx( FILE *fp, const char *filename, int closeit)
// {
// return TruePyRun_SimpleFileEx( fp, filename, closeit);
// }
// static int myTruePyRun_SimpleFileExFlags( FILE *fp, const char *filename, int closeit, void *flags)
// {
// return TruePyRun_SimpleFileExFlags( fp, filename, closeit, flags);
// }
// static int myTruePyRun_InteractiveOne( FILE *fp, const char *filename)
// {
// return TruePyRun_InteractiveOne(fp, filename);
// }
// static int myTruePyRun_InteractiveOneFlags( FILE *fp, const char *filename, void *flags)
// {
// return TruePyRun_InteractiveOneFlags(fp, filename, flags);
// }
// static int myTruePyRun_InteractiveLoop( FILE *fp, const char *filename)
// {
// return TruePyRun_InteractiveLoop(fp, filename);
// }
// static int myTruePyRun_InteractiveLoopFlags( FILE *fp, const char *filename, void *flags)
// {
// return TruePyRun_InteractiveLoopFlags( fp, filename, flags);
// }
// static void* myTruePyParser_SimpleParseString( const char *str, int start)
// {
// return TruePyParser_SimpleParseString(str, start);
// }
// static void* myTruePyParser_SimpleParseStringFlags( const char *str, int start, int flags)
// {
// return TruePyParser_SimpleParseStringFlags(str, start, flags);
// }
// static void* myTruePyParser_SimpleParseStringFlagsFilename( const char *str, const char *filename, int start, int flags)
// {
// return TruePyParser_SimpleParseStringFlagsFilename(str, filename, start, flags);
// }
// static void* myTruePyParser_SimpleParseFile( FILE *fp, const char *filename, int start)
// {
// return TruePyParser_SimpleParseFile(fp, filename, start);
// }
// static void* myTruePyParser_SimpleParseFileFlags( FILE *fp, const char *filename, int start, int flags)
// {
// return TruePyParser_SimpleParseFileFlags(fp, filename, start, flags);
// }
// static void* myTruePyRun_String( const char *str, int start, void *globals, void *locals)
// {
// return TruePyRun_String(str, start, globals, locals);
// }
// static void* myTruePyRun_StringFlags( const char *str, int start, void *globals, void *locals, void *flags)
// {
// void* bla = TruePyRun_StringFlags( str, start, globals, locals, flags);
// return bla;
// }
// static void* myTruePyRun_File( FILE *fp, const char *filename, int start, void *globals, void *locals)
// {
// return TruePyRun_File( fp, filename, start, globals, locals);
// }
// static void* myTruePyRun_FileEx( FILE *fp, const char *filename, int start, void *globals, void *locals, int closeit)
// {
// return TruePyRun_FileEx( fp, filename, start, globals, locals, closeit);
// }
// static void* myTruePyRun_FileFlags( FILE *fp, const char *filename, int start, void *globals, void *locals, void *flags)
// {
// return TruePyRun_FileFlags( fp, filename, start, globals, locals, flags);
// }
// static void* myTruePyRun_FileExFlags( FILE *fp, const char *filename, int start, void *globals, void *locals, int closeit, void *flags)
// {
// return TruePyRun_FileExFlags( fp, filename, start, globals, locals, closeit, flags);
// }
// static void* myTruePy_CompileString( const char *str, const char *filename, int start)
// {
// return TruePy_CompileString( str, filename, start);
// }
// static void* myTruePy_CompileStringFlags( const char *str, const char *filename, int start, void *flags)
// {
// char* asdf = TruePy_GetPath();
// myfile << asdf<<endl;
// return TruePy_CompileStringFlags( str, filename, start, flags);
// }
//
// static PyObject* myTruePyImport_AddModule( char *str)
// {
// return TruePyImport_AddModule( str);
// }
static int ExtendWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// We couldn't call LoadLibrary in DllMain, so our functions here.
LONG error;
//MessageBox(0, L"Im a hooker...",L"...", MB_OK);
// We separate out the functions in the export table (Target)
TruePyRun_AnyFile =(int ( *)( FILE *fp, const char *filename))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyRun_AnyFile");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// error = DetourAttach(&(PVOID&)TruePyRun_AnyFile, myTruePyRun_AnyFile);
// if(error == ERROR_INVALID_HANDLE )
// {
// MessageBox(0, L"ERROR_INVALID_HANDLE", L"", MB_OK);
// }
// error = DetourTransactionCommit();
// if(error != NO_ERROR)
// {
// MessageBox(0, L"TruePyRun_AnyFile failed", L"", MB_OK);
// }
TruePyRun_AnyFileFlags =(int ( *)(FILE *fp, const char *filename, void *flags))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyRun_AnyFileFlags");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyRun_AnyFileFlags, myTruePyRun_AnyFileFlags);
// error = DetourTransactionCommit();
// if(error != NO_ERROR)
// {
// MessageBox(0, L"TruePyRun_AnyFileFlags failed", L"", MB_OK);
// }
TruePyRun_AnyFileEx =(int ( *)(FILE *fp, const char *filename, int closeit))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyRun_AnyFileEx");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyRun_AnyFileEx, myTruePyRun_AnyFileEx);
// error = DetourTransactionCommit();
// if(error != NO_ERROR)
// {
// MessageBox(0, L"TruePyRun_AnyFileEx failed", L"", MB_OK);
// }
TruePyRun_AnyFileExFlags =(int ( *)(FILE *fp, const char *filename, int closeit, void *flags))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyRun_AnyFileExFlags");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyRun_AnyFileExFlags, myTruePyRun_AnyFileExFlags);
// error = DetourTransactionCommit();
// if(error != NO_ERROR)
// {
// MessageBox(0, L"TruePyRun_AnyFileExFlags failed", L"", MB_OK);
// }
TruePyRun_SimpleString =(int ( *)(const char *command))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyRun_SimpleString");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyRun_SimpleString, myTruePyRun_SimpleString);
// error = DetourTransactionCommit();
// if(error != NO_ERROR)
// {
// MessageBox(0, L"TruePyRun_SimpleString failed", L"", MB_OK);
// }
TruePyRun_SimpleStringFlags =(int ( *)(const char *command, void *flags))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyRun_SimpleStringFlags");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyRun_SimpleStringFlags, myTruePyRun_SimpleStringFlags);
// error = DetourTransactionCommit();
// if(error != NO_ERROR)
// {
// MessageBox(0, L"TruePyRun_SimpleStringFlags failed", L"", MB_OK);
// }
TruePyRun_SimpleFile =(int ( *)(FILE *fp, const char *filename))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyRun_SimpleFile");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyRun_SimpleFile, myTruePyRun_SimpleFile);
// error = DetourTransactionCommit();
// if(error != NO_ERROR)
// {
// MessageBox(0, L"TruePyRun_SimpleFile failed", L"", MB_OK);
// }
TruePyRun_SimpleFileFlags =(int ( *)(FILE *fp, const char *filename, void *flags))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyRun_SimpleFileFlags");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyRun_SimpleFileFlags, myTruePyRun_SimpleFileFlags);
// error = DetourTransactionCommit();
TruePyRun_SimpleFileEx =(int ( *)(FILE *fp, const char *filename, int closeit))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyRun_SimpleFileEx");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyRun_SimpleFileEx, myTruePyRun_SimpleFileEx);
// error = DetourTransactionCommit();
TruePyRun_SimpleFileExFlags =(int ( *)(FILE *fp, const char *filename, int closeit, void *flags))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyRun_SimpleFileExFlags");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyRun_SimpleFileExFlags, myTruePyRun_SimpleFileExFlags);
// error = DetourTransactionCommit();
TruePyRun_InteractiveOne =(int ( *)( FILE *fp, const char *filename))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyRun_InteractiveOne");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyRun_InteractiveOne, myTruePyRun_InteractiveOne);
// error = DetourTransactionCommit();
TruePyRun_InteractiveOneFlags =(int ( *)( FILE *fp, const char *filename, void *flags))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyRun_InteractiveOneFlags");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyRun_InteractiveOneFlags, myTruePyRun_InteractiveOneFlags);
// error = DetourTransactionCommit();
TruePyRun_InteractiveLoop =(int ( *)( FILE *fp, const char *filename))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyRun_InteractiveLoop");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyRun_InteractiveLoop, myTruePyRun_InteractiveLoop);
// error = DetourTransactionCommit();
TruePyRun_InteractiveLoopFlags =(int ( *)(FILE *fp, const char *filename, void *flags))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyRun_InteractiveLoopFlags");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyRun_InteractiveLoopFlags, myTruePyRun_InteractiveLoopFlags);
// error = DetourTransactionCommit();
TruePyParser_SimpleParseString =(void* ( *)(const char *str, int start))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyParser_SimpleParseString");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyParser_SimpleParseString, myTruePyParser_SimpleParseString);
// error = DetourTransactionCommit();
TruePyParser_SimpleParseStringFlags =(void* ( *)( const char *str, int start, int flags))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyParser_SimpleParseStringFlags");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyParser_SimpleParseStringFlags, myTruePyParser_SimpleParseStringFlags);
// error = DetourTransactionCommit();
TruePyParser_SimpleParseStringFlagsFilename =(void* ( *)( const char *str, const char *filename, int start, int flags))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyParser_SimpleParseStringFlagsFilename");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyParser_SimpleParseStringFlagsFilename, myTruePyParser_SimpleParseStringFlagsFilename);
// error = DetourTransactionCommit();
TruePyParser_SimpleParseFile =(void* ( *)(FILE *fp, const char *filename, int start))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyParser_SimpleParseFile");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyParser_SimpleParseFile, myTruePyParser_SimpleParseFile);
// error = DetourTransactionCommit();
TruePyParser_SimpleParseFileFlags =(void* ( *)( FILE *fp, const char *filename, int start, int flags))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyParser_SimpleParseFileFlags");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyParser_SimpleParseFileFlags, myTruePyParser_SimpleParseFileFlags);
// error = DetourTransactionCommit();
TruePyRun_String =(void* ( *)( const char *str, int start, void *globals, void *locals))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyRun_String");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyRun_String, myTruePyRun_String);
// error = DetourTransactionCommit();
TruePyRun_StringFlags =(void* ( *)( const char *str, int start, void *globals, void *locals, void *flags))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyRun_StringFlags");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyRun_StringFlags, myTruePyRun_StringFlags);
// error = DetourTransactionCommit();
TruePyRun_File =(void* ( *)( FILE *fp, const char *filename, int start, void *globals, void *locals))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyParser_SimpleParseFile");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyRun_File, myTruePyRun_File);
// error = DetourTransactionCommit();
TruePyRun_FileEx =(void* ( *)( FILE *fp, const char *filename, int start, void *globals, void *locals, int closeit))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyRun_FileEx");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyRun_FileEx, myTruePyRun_FileEx);
// error = DetourTransactionCommit();
TruePyRun_FileFlags =(void* ( *)( FILE *fp, const char *filename, int start, void *globals, void *locals, void *flags))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyRun_FileFlags");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyRun_FileFlags, myTruePyRun_FileFlags);
// error = DetourTransactionCommit();
TruePyRun_FileExFlags =(void* ( *)( FILE *fp, const char *filename, int start, void *globals, void *locals, int closeit, void *flags))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyRun_FileExFlags");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyRun_FileExFlags, myTruePyRun_FileExFlags);
// error = DetourTransactionCommit();
TruePy_CompileString =(void* ( *)( const char *str, const char *filename, int start))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "Py_CompileString");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePy_CompileString, myTruePy_CompileString);
// error = DetourTransactionCommit();
TruePy_CompileStringFlags =(void* ( *)( const char *str, const char *filename, int start, void *flags))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "Py_CompileStringFlags");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePy_CompileStringFlags, myTruePy_CompileStringFlags);
// error = DetourTransactionCommit();
TruePyImport_ImportModule =(void* ( *)( const char *name))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyImport_ImportModule");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyImport_ImportModule, myTruePyImport_ImportModule);
// error = DetourTransactionCommit();
TruePyImport_ImportModuleEx =(void* ( *)( char *name, void *globals, void *locals, void *fromlist))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyImport_ImportModuleEx");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyImport_ImportModuleEx, myTruePyImport_ImportModuleEx);
// error = DetourTransactionCommit();
TruePyString_FromString =(void* ( *)( char *name))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyString_FromString");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyString_FromString, myTruePyString_FromString);
// error = DetourTransactionCommit();
TruePyImport_AddModule =(PyObject* ( *)( char *name))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyImport_AddModule");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyImport_AddModule, myTruePyImport_AddModule);
// error = DetourTransactionCommit();
TruePyModule_AddObject =(int ( *)( PyObject *module, const char *name, PyObject *value))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyModule_AddObject");
// DetourTransactionBegin();
// DetourUpdateThread(GetCurrentThread());
// DetourAttach(&(PVOID&)TruePyModule_AddObject, myTruePyModule_AddObject);
// error = DetourTransactionCommit();
TruePyObject_CallObject =(PyObject* ( *)( PyObject *callable_object, PyObject *args))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyObject_CallObject");
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)TruePyObject_CallObject, myTruePyObject_CallObject);
error = DetourTransactionCommit();
TruePy_GetPath =(char* ( *)( ))DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "Py_GetPath");
TruePyModule_GetDict=( PyObject* (*) (PyObject *module)) DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyModule_GetDict");
TruePyDict_Check=( int (*) (PyObject *dict)) DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyDict_Check");
TruePyDict_Keys=( PyObject* (*) (PyObject *dict)) DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyDict_Keys");
TruePyDict_GetItemString=( PyObject* (*) (PyObject *dict, const char*key)) DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyDict_GetItemString");
TruePyList_GetItem=( PyObject* (*) (PyObject *list, Py_ssize_t index)) DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyList_GetItem");
TruePyList_Size=( Py_ssize_t (*) (PyObject *list)) DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyList_Size");
TruePyString_AsString=( char* (*) (PyObject *string)) DetourFindFunction("C:\\Program Files\\CCP\\EVE\\bin\\python25.dll", "PyString_AsString");
installhook();
return TrueWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
}
BOOL DllMain(HINSTANCE hinst, DWORD dwReason, LPVOID reserved)
{
LONG error;
(void)hinst;
(void)reserved;
if (dwReason == DLL_PROCESS_ATTACH) {
hinsta = hinst;
DetourRestoreAfterWith();
myfile.open ("evelog.log");
myfile << "[LOG]Starting dll" <<endl<<endl;
LPDWORD bla= new DWORD;
threadhandle = CreateThread(NULL, 0, threadfunc, NULL, 0, bla);
if(threadhandle==NULL)
{
MessageBox( NULL,
L"Unable to start thread",
L"Error!",
MB_OK);
myfile << "Thread not !started" << endl;
}
else
{
myfile << "Thread started" << endl;
}
InitializeCriticalSection(&cs);
// NB: DllMain can't call LoadLibrary, so we hook the app entry point.
TrueWinMain = (int ( *)(HINSTANCE, HINSTANCE, LPSTR, int))
DetourGetEntryPoint(NULL);
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)TrueWinMain, ExtendWinMain);
error = DetourTransactionCommit();
if(error != NO_ERROR)
{
myfile << "[LOG]###############################################################" <<endl;
myfile << "[LOG] Could not hook python25.dll!" <<endl;
myfile << "[LOG]###############################################################" <<endl;
myfile.close();
}
}
else if (dwReason == DLL_PROCESS_DETACH) {
myfile << "[LOG]###############################################################" <<endl;
myfile << "[LOG] Closing dll!" <<endl;
myfile << "[LOG]###############################################################" <<endl;
TerminateThread(threadhandle,1);
DeleteCriticalSection(&cs);
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
// Detach the entry point.
DetourDetach(&(PVOID&)TrueWinMain, ExtendWinMain);
error = DetourTransactionCommit();
}
return TRUE;
}
DWORD WINAPI threadfunc(LPVOID junk)
{
return 1;
}