7static const std::vector<HookTestCase> g_Cases = {
11 "RWX view mapped into remote process",
15 {
"NtMapViewOfSection: 4096-byte view mapped into a remote process at * (protection 0x40, executable)" },
18 "RX view mapped into remote process",
22 {
"NtMapViewOfSection: 4096-byte view mapped into a remote process at * (protection 0x20, executable)" },
26 "RW view of an RWX section mapped into remote process",
30 {
"NtMapViewOfSection: 4096-byte view mapped into a remote process at * (protection 0x4, not executable)" },
33 "RW view mapped into remote process",
37 {
"NtMapViewOfSection: 4096-byte view mapped into a remote process at * (protection 0x4, not executable)" },
41 "Image mapped into remote process",
45 {
"NtMapViewOfSection: *-byte image mapped into a remote process at * (protection 0x2, executable)" },
48 "RWX view mapped into current process is not reported",
55 "RWX view mapped through a real handle to self is not reported",
57 HANDLE self = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
64 "Image mapped into current process is not reported",
72 "Failed map into remote process is not reported",
79 "Map through a remote handle without PROCESS_VM_OPERATION is not reported",
81 HANDLE remote = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, GetProcessId(context.RemoteProcess()));
91 "Ex: RWX view mapped into remote process",
95 {
"NtMapViewOfSectionEx: 4096-byte view mapped into a remote process at * (protection 0x40, executable)" },
98 "Ex: image mapped into remote process",
102 {
"NtMapViewOfSectionEx: *-byte image mapped into a remote process at * (protection 0x2, executable)" },
105 "Ex: RWX view mapped into current process is not reported",
112 "Ex: failed map into remote process is not reported",
120int main(
int argc,
char** argv) {
121 return RunHookTests(argc, argv,
"NtMapViewOfSection", g_Cases);
int main()
Loads the hook DLL for this architecture from bin/<config>, one directory above the tests folder this...
Resources shared by the cases of one test run, created in the child process. The remote processes are...
int RunHookTests(int argc, char **argv, const char *apiName, const std::vector< HookTestCase > &cases)
Runs the cases and prints a PASS/FAIL line for each. Call from main.
PVOID MapView(HANDLE section, HANDLE process, ULONG protection)
Maps a view of a section through NtMapViewOfSection. Returns NULL if the call fails.
HANDLE CreateImageSection()
Creates an image section from System32.
PVOID MapViewEx(HANDLE section, HANDLE process, ULONG protection)
Maps a view of a section through NtMapViewOfSectionEx. Returns NULL if the call fails.
HANDLE CreatePageSection(DWORD protection)
Creates a one-page, pagefile-backed section with the given maximum protection.