diff --git a/src/driver/irp.cpp b/src/driver/irp.cpp index e0cc27b..66911f0 100644 --- a/src/driver/irp.cpp +++ b/src/driver/irp.cpp @@ -44,24 +44,21 @@ namespace debug_log("Pid: %d | Address: %p\n", request->process_id, request->target_address); - auto current_proc = process::get_current_process(); - if (current_proc) - { - debug_log("Current: %p\n", current_proc.get_id()); - } - - //debug_log("Current: %lld\n",PsGetCurrentProcessId()); - - /*const auto process_handle = process::find_process_by_id(request->process_id); - if(process_handle && process_handle.is_alive()) + const auto process_handle = process::find_process_by_id(request->process_id); + if (!process_handle || !process_handle.is_alive()) { debug_log("Bad process\n"); return; } - process::scoped_process_attacher attacher{process_handle}; + const auto name = process_handle.get_image_filename(); + if (name) + { + debug_log("Attaching to %s\n", name); + } - debug_log("Original: %s\n", request->target_address);*/ + //process::scoped_process_attacher attacher{process_handle}; + //debug_log("Original: %s\n", request->target_address); } _Function_class_(DRIVER_DISPATCH) NTSTATUS io_ctl_handler( diff --git a/src/driver/process.cpp b/src/driver/process.cpp index ba375fd..13d2e27 100644 --- a/src/driver/process.cpp +++ b/src/driver/process.cpp @@ -58,14 +58,14 @@ namespace process return KeWaitForSingleObject(this->handle_, Executive, KernelMode, FALSE, &zero_time) != STATUS_WAIT_0; } - HANDLE process_handle::get_id() const + uint32_t process_handle::get_id() const { if(!this->handle_) { return 0; } - PsGetProcessId(this->handle_); + return uint32_t(uint64_t(PsGetProcessId(this->handle_))); } const char* process_handle::get_image_filename() const diff --git a/src/driver/process.hpp b/src/driver/process.hpp index 3aa750c..296c47f 100644 --- a/src/driver/process.hpp +++ b/src/driver/process.hpp @@ -19,7 +19,7 @@ namespace process operator PEPROCESS() const; bool is_alive() const; - HANDLE get_id() const; + uint32_t get_id() const; const char* get_image_filename() const; diff --git a/src/runner/main.cpp b/src/runner/main.cpp index 5710099..e2ea57a 100644 --- a/src/runner/main.cpp +++ b/src/runner/main.cpp @@ -46,6 +46,8 @@ std::filesystem::path get_current_path() void unsafe_main(const int /*argc*/, char* /*argv*/[]) { + printf("Pid: %lu\n", GetCurrentProcessId()); + driver driver{get_current_path() / "driver.sys", "MomoLul"}; driver_device driver_device{"\\\\.\\HelloDev"};