Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
hook.hpp
Go to the documentation of this file.
1#pragma once
2#include <Windows.h>
3#include "def.h"
4#include <detours/detours.h>
5
12NTSTATUS NTAPI Hooked_NtWriteVirtualMemory(
13 HANDLE ProcessHandle,
14 PVOID BaseAddress,
15 PVOID Buffer,
16 SIZE_T NumberOfBytesToWrite,
17 PSIZE_T NumberOfBytesWritten
18);
19
24NTSTATUS NTAPI Hooked_NtModifyBootEntry(PBOOT_ENTRY BootEntry);
25
39 HANDLE SectionHandle,
40 HANDLE ProcessHandle,
41 PVOID* BaseAddress,
42 PLARGE_INTEGER SectionOffset,
43 PSIZE_T ViewSize,
44 ULONG AllocationType,
45 ULONG PageProtection,
46 PMEM_EXTENDED_PARAMETER ExtendedParameters,
47 ULONG ExtendedParameterCount
48);
49
51NTSTATUS NTAPI Hooked_NtMapViewOfSection(
52 HANDLE SectionHandle,
53 HANDLE ProcessHandle,
54 PVOID* BaseAddress,
55 ULONG_PTR ZeroBits,
56 SIZE_T CommitSize,
57 PLARGE_INTEGER SectionOffset,
58 PSIZE_T ViewSize,
59 PANO_SECTION_INHERIT InheritDisposition,
60 ULONG AllocationType,
61 ULONG Win32Protect
62);
63
65NTSTATUS NTAPI Hooked_NtUnmapViewOfSection(
66 HANDLE ProcessHandle,
67 PVOID BaseAddress
68);
69
72 HANDLE ProcessHandle,
73 PVOID BaseAddress,
74 ULONG Flags
75);
76
79 HANDLE ProcessHandle,
80 PVOID* BaseAddress,
81 PSIZE_T RegionSize,
82 ULONG NewProtection,
83 PULONG OldProtection
84);
85
88 HANDLE ProcessHandle,
89 PVOID* BaseAddress,
90 ULONG_PTR ZeroBits,
91 PSIZE_T RegionSize,
92 ULONG AllocationType,
93 ULONG Protection
94);
95
98 HANDLE ProcessHandle,
99 PVOID* BaseAddress,
100 PSIZE_T RegionSize,
101 ULONG AllocationType,
102 ULONG PageProtection,
103 PMEM_EXTENDED_PARAMETER ExtendedParameters,
104 ULONG ExtendedParameterCount
105);
106
108NTSTATUS NTAPI Hooked_NtReadVirtualMemory(
109 HANDLE ProcessHandle,
110 PVOID BaseAddress,
111 PVOID Buffer,
112 SIZE_T NumberOfBytesToRead,
113 PSIZE_T NumberOfBytesRead
114);
115
117NTSTATUS NTAPI Hooked_NtCreateThreadEx(
118 PHANDLE ThreadHandle,
119 ACCESS_MASK DesiredAccess,
120 POBJECT_ATTRIBUTES ObjectAttributes,
121 HANDLE ProcessHandle,
122 PVOID StartRoutine,
123 PVOID Argument,
124 ULONG CreateFlags,
125 SIZE_T ZeroBits,
126 SIZE_T StackSize,
127 SIZE_T MaximumStackSize,
128 PVOID AttributeList
129);
130
132NTSTATUS NTAPI Hooked_NtQueueApcThread(
133 HANDLE ThreadHandle,
134 PPANO_APC_ROUTINE ApcRoutine,
135 PVOID ApcArgument1,
136 PVOID ApcArgument2,
137 PVOID ApcArgument3
138);
139
142NTSTATUS NTAPI Hooked_NtQueueApcThreadEx2(
143 HANDLE ThreadHandle,
144 HANDLE ReserveHandle,
145 ULONG ApcFlags,
146 PPANO_APC_ROUTINE ApcRoutine,
147 PVOID ApcArgument1,
148 PVOID ApcArgument2,
149 PVOID ApcArgument3
150);
151
153NTSTATUS NTAPI Hooked_NtSetInformationProcess(
154 HANDLE ProcessHandle,
155 PROCESSINFOCLASS ProcessInformationClass,
156 PVOID ProcessInformation,
157 ULONG ProcessInformationLength
158);
159
161VOID PlaceHooks();
162
164VOID UnHook();
165
enum _PANO_SECTION_INHERIT PANO_SECTION_INHERIT
How a mapped view is shared with child processes. Only defined in kernel-mode headers.
struct _BOOT_ENTRY * PBOOT_ENTRY
VOID(NTAPI * PPANO_APC_ROUTINE)(_In_opt_ PVOID ApcArgument1, _In_opt_ PVOID ApcArgument2, _In_opt_ PVOID ApcArgument3)
The routine an APC queued with NtQueueApcThread runs. Not in the SDK headers.
Definition def.h:143
VOID UnHook()
The UnHook function removes the hooks from the NTDLL functions.
Definition hook.cpp:1052
NTSTATUS NTAPI Hooked_NtWriteVirtualMemory(HANDLE ProcessHandle, PVOID BaseAddress, PVOID Buffer, SIZE_T NumberOfBytesToWrite, PSIZE_T NumberOfBytesWritten)
The Hooked_NtWriteVirtualMemory function is a function that hooks the NtWriteVirtualMemory function.
Definition hook.cpp:339
NTSTATUS NTAPI Hooked_NtSetInformationProcess(HANDLE ProcessHandle, PROCESSINFOCLASS ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength)
Hooks NtSetInformationProcess, which sets information about a process.
Definition hook.cpp:783
NTSTATUS NTAPI Hooked_NtUnmapViewOfSectionEx(HANDLE ProcessHandle, PVOID BaseAddress, ULONG Flags)
Hooks NtUnmapViewOfSectionEx, which unmaps a view of a section from a process.
Definition hook.cpp:537
NTSTATUS NTAPI Hooked_NtReadVirtualMemory(HANDLE ProcessHandle, PVOID BaseAddress, PVOID Buffer, SIZE_T NumberOfBytesToRead, PSIZE_T NumberOfBytesRead)
Hooks NtReadVirtualMemory, which reads memory from a process.
Definition hook.cpp:638
NTSTATUS NTAPI Hooked_NtUnmapViewOfSection(HANDLE ProcessHandle, PVOID BaseAddress)
Hooks NtUnmapViewOfSection, which unmaps a view of a section from a process.
Definition hook.cpp:508
NTSTATUS NTAPI Hooked_NtCreateThreadEx(PHANDLE ThreadHandle, ACCESS_MASK DesiredAccess, POBJECT_ATTRIBUTES ObjectAttributes, HANDLE ProcessHandle, PVOID StartRoutine, PVOID Argument, ULONG CreateFlags, SIZE_T ZeroBits, SIZE_T StackSize, SIZE_T MaximumStackSize, PVOID AttributeList)
Hooks NtCreateThreadEx, which creates a thread in a process.
Definition hook.cpp:675
NTSTATUS NTAPI Hooked_NtAllocateVirtualMemoryEx(HANDLE ProcessHandle, PVOID *BaseAddress, PSIZE_T RegionSize, ULONG AllocationType, ULONG PageProtection, PMEM_EXTENDED_PARAMETER ExtendedParameters, ULONG ExtendedParameterCount)
Hooks NtAllocateVirtualMemoryEx, which reserves and/or commits memory in a process.
Definition hook.cpp:605
NTSTATUS NTAPI Hooked_NtQueueApcThreadEx2(HANDLE ThreadHandle, HANDLE ReserveHandle, ULONG ApcFlags, PPANO_APC_ROUTINE ApcRoutine, PVOID ApcArgument1, PVOID ApcArgument2, PVOID ApcArgument3)
Hooks NtQueueApcThreadEx2, which queues a user-mode APC to a thread, optionally as a special user APC...
Definition hook.cpp:747
NTSTATUS NTAPI Hooked_NtModifyBootEntry(PBOOT_ENTRY BootEntry)
The Hooked_NtModifyBootEntry function is a function that hooks the NtModifyBootEntry function.
NTSTATUS NTAPI Hooked_NtAllocateVirtualMemory(HANDLE ProcessHandle, PVOID *BaseAddress, ULONG_PTR ZeroBits, PSIZE_T RegionSize, ULONG AllocationType, ULONG Protection)
Hooks NtAllocateVirtualMemory, which reserves and/or commits memory in a process.
Definition hook.cpp:570
VOID PlaceHooks()
The PlaceHooks function places the hooks on the NTDLL functions.
Definition hook.cpp:1019
NTSTATUS NTAPI Hooked_NtMapViewOfSectionEx(HANDLE SectionHandle, HANDLE ProcessHandle, PVOID *BaseAddress, PLARGE_INTEGER SectionOffset, PSIZE_T ViewSize, ULONG AllocationType, ULONG PageProtection, PMEM_EXTENDED_PARAMETER ExtendedParameters, ULONG ExtendedParameterCount)
The Hooked_NtMapViewOfSectionEx function is a function that hooks the NtMapViewOfSectionEx function.
NTSTATUS NTAPI Hooked_NtMapViewOfSection(HANDLE SectionHandle, HANDLE ProcessHandle, PVOID *BaseAddress, ULONG_PTR ZeroBits, SIZE_T CommitSize, PLARGE_INTEGER SectionOffset, PSIZE_T ViewSize, PANO_SECTION_INHERIT InheritDisposition, ULONG AllocationType, ULONG Win32Protect)
Hooks NtMapViewOfSection, which maps a view of a section into a process.
Definition hook.cpp:429
NTSTATUS NTAPI Hooked_NtQueueApcThread(HANDLE ThreadHandle, PPANO_APC_ROUTINE ApcRoutine, PVOID ApcArgument1, PVOID ApcArgument2, PVOID ApcArgument3)
Hooks NtQueueApcThread, which queues a user-mode APC to a thread.
Definition hook.cpp:714
NTSTATUS NTAPI Hooked_NtProtectVirtualMemory(HANDLE ProcessHandle, PVOID *BaseAddress, PSIZE_T RegionSize, ULONG NewProtection, PULONG OldProtection)
Hooks NtProtectVirtualMemory, which changes the protection of memory in a process.
Definition hook.cpp:393