mirror of
https://github.com/momo5502/hypervisor.git
synced 2025-04-19 13:42:55 +00:00
Fix formatting
This commit is contained in:
parent
4ec4055e4b
commit
c58f6c9742
@ -49,13 +49,13 @@ namespace vmx
|
|||||||
if (mtrr_data[i].enabled != FALSE)
|
if (mtrr_data[i].enabled != FALSE)
|
||||||
{
|
{
|
||||||
mtrr_data[i].physical_address_min = mtrr_base.page_frame_number *
|
mtrr_data[i].physical_address_min = mtrr_base.page_frame_number *
|
||||||
MTRR_PAGE_SIZE;
|
MTRR_PAGE_SIZE;
|
||||||
|
|
||||||
unsigned long bit{};
|
unsigned long bit{};
|
||||||
_BitScanForward64(&bit, mtrr_mask.page_frame_number * MTRR_PAGE_SIZE);
|
_BitScanForward64(&bit, mtrr_mask.page_frame_number * MTRR_PAGE_SIZE);
|
||||||
mtrr_data[i].physical_address_max = mtrr_data[i].
|
mtrr_data[i].physical_address_max = mtrr_data[i].
|
||||||
physical_address_min +
|
physical_address_min +
|
||||||
(1ULL << bit) - 1;
|
(1ULL << bit) - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,7 +198,7 @@ namespace vmx
|
|||||||
this->epml4[0].write_access = 1;
|
this->epml4[0].write_access = 1;
|
||||||
this->epml4[0].execute_access = 1;
|
this->epml4[0].execute_access = 1;
|
||||||
this->epml4[0].page_frame_number = memory::get_physical_address(&this->epdpt) /
|
this->epml4[0].page_frame_number = memory::get_physical_address(&this->epdpt) /
|
||||||
PAGE_SIZE;
|
PAGE_SIZE;
|
||||||
|
|
||||||
// --------------------------
|
// --------------------------
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ namespace vmx
|
|||||||
{
|
{
|
||||||
this->epde[i][j].page_frame_number = (i * 512) + j;
|
this->epde[i][j].page_frame_number = (i * 512) + j;
|
||||||
this->epde[i][j].memory_type = mtrr_adjust_effective_memory_type(
|
this->epde[i][j].memory_type = mtrr_adjust_effective_memory_type(
|
||||||
mtrr_data, this->epde[i][j].page_frame_number * 2_mb, MEMORY_TYPE_WRITE_BACK);
|
mtrr_data, this->epde[i][j].page_frame_number * 2_mb, MEMORY_TYPE_WRITE_BACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -366,7 +366,7 @@ namespace vmx
|
|||||||
if (translation_hint)
|
if (translation_hint)
|
||||||
{
|
{
|
||||||
physical_address = translation_hint->physical_base_address + ADDRMASK_EPT_PML1_OFFSET(
|
physical_address = translation_hint->physical_base_address + ADDRMASK_EPT_PML1_OFFSET(
|
||||||
reinterpret_cast<uint64_t>(destination));
|
reinterpret_cast<uint64_t>(destination));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -50,6 +50,6 @@ namespace utils
|
|||||||
finally(F&& f) noexcept
|
finally(F&& f) noexcept
|
||||||
{
|
{
|
||||||
return final_action<typename std::remove_cv<typename std::remove_reference<F>::type>::type>(
|
return final_action<typename std::remove_cv<typename std::remove_reference<F>::type>::type>(
|
||||||
std::forward<F>(f));
|
std::forward<F>(f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,8 @@ namespace
|
|||||||
});
|
});
|
||||||
|
|
||||||
memcpy(buffer.get(), request.source_data, request.source_data_size);
|
memcpy(buffer.get(), request.source_data, request.source_data_size);
|
||||||
translation_hints = generate_translation_hints(request.process_id, request.target_address, request.source_data_size);
|
translation_hints = generate_translation_hints(request.process_id, request.target_address,
|
||||||
|
request.source_data_size);
|
||||||
|
|
||||||
if (!translation_hints)
|
if (!translation_hints)
|
||||||
{
|
{
|
||||||
@ -153,7 +154,7 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
_Function_class_(DRIVER_DISPATCH) NTSTATUS io_ctl_handler(
|
_Function_class_(DRIVER_DISPATCH) NTSTATUS io_ctl_handler(
|
||||||
PDEVICE_OBJECT /*device_object*/, const PIRP irp)
|
PDEVICE_OBJECT /*device_object*/, const PIRP irp)
|
||||||
{
|
{
|
||||||
PAGED_CODE()
|
PAGED_CODE()
|
||||||
|
|
||||||
|
@ -13,9 +13,9 @@ _IRQL_requires_min_(PASSIVE_LEVEL)
|
|||||||
_IRQL_requires_same_
|
_IRQL_requires_same_
|
||||||
VOID
|
VOID
|
||||||
KeGenericCallDpc(
|
KeGenericCallDpc(
|
||||||
_In_ PKDEFERRED_ROUTINE Routine,
|
_In_ PKDEFERRED_ROUTINE Routine,
|
||||||
_In_opt_ PVOID Context
|
_In_opt_ PVOID Context
|
||||||
);
|
);
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
||||||
@ -24,8 +24,8 @@ _IRQL_requires_(DISPATCH_LEVEL)
|
|||||||
_IRQL_requires_same_
|
_IRQL_requires_same_
|
||||||
VOID
|
VOID
|
||||||
KeSignalCallDpcDone(
|
KeSignalCallDpcDone(
|
||||||
_In_ PVOID SystemArgument1
|
_In_ PVOID SystemArgument1
|
||||||
);
|
);
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
||||||
@ -34,8 +34,8 @@ _IRQL_requires_(DISPATCH_LEVEL)
|
|||||||
_IRQL_requires_same_
|
_IRQL_requires_same_
|
||||||
LOGICAL
|
LOGICAL
|
||||||
KeSignalCallDpcSynchronize(
|
KeSignalCallDpcSynchronize(
|
||||||
_In_ PVOID SystemArgument2
|
_In_ PVOID SystemArgument2
|
||||||
);
|
);
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
||||||
@ -45,13 +45,13 @@ _IRQL_requires_max_(DISPATCH_LEVEL)
|
|||||||
NTKERNELAPI
|
NTKERNELAPI
|
||||||
_When_(return != NULL, _Post_writable_byte_size_ (NumberOfBytes)) PVOID
|
_When_(return != NULL, _Post_writable_byte_size_ (NumberOfBytes)) PVOID
|
||||||
MmAllocateContiguousNodeMemory(
|
MmAllocateContiguousNodeMemory(
|
||||||
_In_ SIZE_T NumberOfBytes,
|
_In_ SIZE_T NumberOfBytes,
|
||||||
_In_ PHYSICAL_ADDRESS LowestAcceptableAddress,
|
_In_ PHYSICAL_ADDRESS LowestAcceptableAddress,
|
||||||
_In_ PHYSICAL_ADDRESS HighestAcceptableAddress,
|
_In_ PHYSICAL_ADDRESS HighestAcceptableAddress,
|
||||||
_In_opt_ PHYSICAL_ADDRESS BoundaryAddressMultiple,
|
_In_opt_ PHYSICAL_ADDRESS BoundaryAddressMultiple,
|
||||||
_In_ ULONG Protect,
|
_In_ ULONG Protect,
|
||||||
_In_ NODE_REQUIREMENT PreferredNode
|
_In_ NODE_REQUIREMENT PreferredNode
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
@ -60,8 +60,8 @@ NTSYSAPI
|
|||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
RtlCaptureContext(
|
RtlCaptureContext(
|
||||||
_Out_ PCONTEXT ContextRecord
|
_Out_ PCONTEXT ContextRecord
|
||||||
);
|
);
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
||||||
@ -79,34 +79,34 @@ typedef struct _KAPC_STATE
|
|||||||
NTKERNELAPI
|
NTKERNELAPI
|
||||||
VOID
|
VOID
|
||||||
KeStackAttachProcess(
|
KeStackAttachProcess(
|
||||||
__inout PEPROCESS PROCESS,
|
__inout PEPROCESS PROCESS,
|
||||||
__out PRKAPC_STATE ApcState
|
__out PRKAPC_STATE ApcState
|
||||||
);
|
);
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
||||||
NTKERNELAPI
|
NTKERNELAPI
|
||||||
VOID
|
VOID
|
||||||
KeUnstackDetachProcess(
|
KeUnstackDetachProcess(
|
||||||
__in PRKAPC_STATE ApcState
|
__in PRKAPC_STATE ApcState
|
||||||
);
|
);
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
||||||
NTKERNELAPI
|
NTKERNELAPI
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
PsLookupProcessByProcessId(
|
PsLookupProcessByProcessId(
|
||||||
IN HANDLE ProcessId,
|
IN HANDLE ProcessId,
|
||||||
OUT PEPROCESS* Process
|
OUT PEPROCESS* Process
|
||||||
);
|
);
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
||||||
NTKERNELAPI
|
NTKERNELAPI
|
||||||
PVOID
|
PVOID
|
||||||
PsGetProcessSectionBaseAddress(
|
PsGetProcessSectionBaseAddress(
|
||||||
__in PEPROCESS Process
|
__in PEPROCESS Process
|
||||||
);
|
);
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
||||||
@ -114,16 +114,16 @@ NTKERNELAPI
|
|||||||
PPEB
|
PPEB
|
||||||
NTAPI
|
NTAPI
|
||||||
PsGetProcessPeb(
|
PsGetProcessPeb(
|
||||||
IN PEPROCESS Process
|
IN PEPROCESS Process
|
||||||
);
|
);
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
||||||
NTKERNELAPI
|
NTKERNELAPI
|
||||||
PCSTR
|
PCSTR
|
||||||
PsGetProcessImageFileName(
|
PsGetProcessImageFileName(
|
||||||
__in PEPROCESS Process
|
__in PEPROCESS Process
|
||||||
);
|
);
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
||||||
@ -131,18 +131,18 @@ __kernel_entry NTSYSCALLAPI
|
|||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
NtCreateFile(
|
NtCreateFile(
|
||||||
_Out_ PHANDLE FileHandle,
|
_Out_ PHANDLE FileHandle,
|
||||||
_In_ ACCESS_MASK DesiredAccess,
|
_In_ ACCESS_MASK DesiredAccess,
|
||||||
_In_ POBJECT_ATTRIBUTES ObjectAttributes,
|
_In_ POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
_Out_ PIO_STATUS_BLOCK IoStatusBlock,
|
_Out_ PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
_In_opt_ PLARGE_INTEGER AllocationSize,
|
_In_opt_ PLARGE_INTEGER AllocationSize,
|
||||||
_In_ ULONG FileAttributes,
|
_In_ ULONG FileAttributes,
|
||||||
_In_ ULONG ShareAccess,
|
_In_ ULONG ShareAccess,
|
||||||
_In_ ULONG CreateDisposition,
|
_In_ ULONG CreateDisposition,
|
||||||
_In_ ULONG CreateOptions,
|
_In_ ULONG CreateOptions,
|
||||||
_In_reads_bytes_opt_(EaLength) PVOID EaBuffer,
|
_In_reads_bytes_opt_(EaLength) PVOID EaBuffer,
|
||||||
_In_ ULONG EaLength
|
_In_ ULONG EaLength
|
||||||
);
|
);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ namespace process
|
|||||||
this->own_ = obj.own_;
|
this->own_ = obj.own_;
|
||||||
this->handle_ = obj.handle_;
|
this->handle_ = obj.handle_;
|
||||||
|
|
||||||
if(this->own_ && this->handle_)
|
if (this->own_ && this->handle_)
|
||||||
{
|
{
|
||||||
ObReferenceObject(this->handle_);
|
ObReferenceObject(this->handle_);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ sleep_callback::sleep_callback(callback_function&& callback)
|
|||||||
PCALLBACK_OBJECT callback_object{};
|
PCALLBACK_OBJECT callback_object{};
|
||||||
UNICODE_STRING callback_name = RTL_CONSTANT_STRING(L"\\Callback\\PowerState");
|
UNICODE_STRING callback_name = RTL_CONSTANT_STRING(L"\\Callback\\PowerState");
|
||||||
OBJECT_ATTRIBUTES object_attributes = RTL_CONSTANT_OBJECT_ATTRIBUTES(
|
OBJECT_ATTRIBUTES object_attributes = RTL_CONSTANT_OBJECT_ATTRIBUTES(
|
||||||
&callback_name, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE);
|
&callback_name, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE);
|
||||||
|
|
||||||
const auto _ = utils::finally([&callback_object]()
|
const auto _ = utils::finally([&callback_object]()
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ namespace std
|
|||||||
// TEMPLATE FUNCTION forward
|
// TEMPLATE FUNCTION forward
|
||||||
template <class _Ty>
|
template <class _Ty>
|
||||||
constexpr _Ty&& forward(
|
constexpr _Ty&& forward(
|
||||||
typename remove_reference<_Ty>::type& _Arg)
|
typename remove_reference<_Ty>::type& _Arg)
|
||||||
{
|
{
|
||||||
// forward an lvalue as either an lvalue or an rvalue
|
// forward an lvalue as either an lvalue or an rvalue
|
||||||
return (static_cast<_Ty&&>(_Arg));
|
return (static_cast<_Ty&&>(_Arg));
|
||||||
@ -46,7 +46,7 @@ namespace std
|
|||||||
|
|
||||||
template <class _Ty>
|
template <class _Ty>
|
||||||
constexpr _Ty&& forward(
|
constexpr _Ty&& forward(
|
||||||
typename remove_reference<_Ty>::type&& _Arg)
|
typename remove_reference<_Ty>::type&& _Arg)
|
||||||
{
|
{
|
||||||
// forward an rvalue as an rvalue
|
// forward an rvalue as an rvalue
|
||||||
return (static_cast<_Ty&&>(_Arg));
|
return (static_cast<_Ty&&>(_Arg));
|
||||||
@ -134,12 +134,21 @@ namespace std
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template <class T>
|
||||||
struct remove_extent { typedef T type; };
|
struct remove_extent
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
template<class T>
|
template <class T>
|
||||||
struct remove_extent<T[]> { typedef T type; };
|
struct remove_extent<T[]>
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
template<class T, std::size_t N>
|
template <class T, std::size_t N>
|
||||||
struct remove_extent<T[N]> { typedef T type; };
|
struct remove_extent<T[N]>
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ bool driver_device::send(const DWORD ioctl_code, const data& input, data& output
|
|||||||
static_cast<DWORD>(output.size()),
|
static_cast<DWORD>(output.size()),
|
||||||
&size_returned,
|
&size_returned,
|
||||||
nullptr
|
nullptr
|
||||||
) != FALSE;
|
) != FALSE;
|
||||||
|
|
||||||
if (success && size_returned < output.size())
|
if (success && size_returned < output.size())
|
||||||
{
|
{
|
||||||
|
@ -52,7 +52,7 @@ std::vector<uint8_t> load_resource(const int id)
|
|||||||
auto* const handle = LoadResource(nullptr, res);
|
auto* const handle = LoadResource(nullptr, res);
|
||||||
if (!handle) return {};
|
if (!handle) return {};
|
||||||
|
|
||||||
const auto* data_ptr =static_cast<uint8_t*>(LockResource(handle));
|
const auto* data_ptr = static_cast<uint8_t*>(LockResource(handle));
|
||||||
const auto data_size = SizeofResource(nullptr, res);
|
const auto data_size = SizeofResource(nullptr, res);
|
||||||
|
|
||||||
std::vector<uint8_t> data{};
|
std::vector<uint8_t> data{};
|
||||||
@ -78,7 +78,7 @@ void unsafe_main(const int /*argc*/, char* /*argv*/[])
|
|||||||
{
|
{
|
||||||
const auto driver_file = extract_driver();
|
const auto driver_file = extract_driver();
|
||||||
|
|
||||||
driver driver{ driver_file, "MomoLul"};
|
driver driver{driver_file, "MomoLul"};
|
||||||
const driver_device driver_device{R"(\\.\HelloDev)"};
|
const driver_device driver_device{R"(\\.\HelloDev)"};
|
||||||
|
|
||||||
std::string pid_str{};
|
std::string pid_str{};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user