9 #define POOL_NX_OPTIN 1 48 #if defined(ALLOC_PRAGMA) 49 #pragma alloc_text(INIT, DriverEntry) 50 #pragma alloc_text(PAGE, DriverpDriverUnload) 51 #pragma alloc_text(INIT, DriverpIsSuppoetedOS) 65 _Use_decl_annotations_ NTSTATUS
DriverEntry(PDRIVER_OBJECT driver_object,
66 PUNICODE_STRING registry_path) {
67 UNREFERENCED_PARAMETER(registry_path);
70 static const wchar_t kLogFilePath[] = L
"\\SystemRoot\\HyperPlatform.log";
71 static const auto kLogLevel =
75 auto status = STATUS_UNSUCCESSFUL;
80 ExInitializeDriverRuntime(DrvRtPoolNxOptIn);
83 bool need_reinitialization =
false;
85 if (status == STATUS_REINITIALIZATION_NEEDED) {
86 need_reinitialization =
true;
87 }
else if (!NT_SUCCESS(status)) {
94 return STATUS_CANCELLED;
99 if (!NT_SUCCESS(status)) {
106 if (!NT_SUCCESS(status)) {
114 if (!NT_SUCCESS(status)) {
123 if (!NT_SUCCESS(status)) {
133 if (!NT_SUCCESS(status)) {
144 if (!NT_SUCCESS(status)) {
155 if (need_reinitialization) {
165 PDRIVER_OBJECT driver_object) {
166 UNREFERENCED_PARAMETER(driver_object);
184 RTL_OSVERSIONINFOW os_version = {};
185 auto status = RtlGetVersion(&os_version);
186 if (!NT_SUCCESS(status)) {
189 if (os_version.dwMajorVersion != 6 && os_version.dwMajorVersion != 10) {
194 reinterpret_cast<ULONG_PTR>(MmSystemRangeStart) != 0x80000000) {
NTSTATUS LogInitialization(ULONG flag, const wchar_t *log_file_path)
#define HYPERPLATFORM_LOG_INFO(format,...)
Declares interfaces to global object functions.
NTSTATUS VmInitialization()
Virtualizes all processors.
void LogTermination()
Terminates the log system. Should be called from a DriverUnload routine.
bool DriverpIsSuppoetedOS()
NTSTATUS PowerCallbackInitialization()
void VmTermination()
De-virtualize all processors.
constexpr bool IsX64()
Checks if a system is x64.
#define HYPERPLATFORM_COMMON_DBG_BREAK()
Sets a break point that works only when a debugger is present.
static const auto kLogOptDisableFunctionName
For LogInitialization(). Do not log a current function name.
void PowerCallbackTermination()
NTSTATUS HotplugCallbackInitialization()
Declares interfaces to driver functions.
Declares interfaces to power functions.
void UtilTermination()
Frees all resources allocated for the sake of the Util functions.
DRIVER_INITIALIZE DriverEntry
void HotplugCallbackTermination()
NTSTATUS GlobalObjectInitialization()
Calls all constructors and register all destructor.
constexpr bool IsReleaseBuild()
Checks if the project is compiled as Release.
static DRIVER_UNLOAD DriverpDriverUnload
Declares interfaces to utility functions.
Declares interfaces to hot-plug functions.
void GlobalObjectTermination()
Calls all destructors.
Declares and implements common things across the project.
Declares interfaces to VMM initialization functions.
void LogRegisterReinitialization(PDRIVER_OBJECT driver_object)
NTSTATUS UtilInitialization(PDRIVER_OBJECT driver_object)
Declares interfaces to logging functions.
static const auto kLogPutLevelInfo
For LogInitialization(). Enables ERROR, WARN and INFO levels of logs.
static const auto kLogPutLevelDebug
For LogInitialization(). Enables all levels of logs.