From c0bc9e446fc594ea1383103ffdffcc36b9664c61 Mon Sep 17 00:00:00 2001 From: barrybingo Date: Fri, 22 Mar 2019 22:38:59 +0000 Subject: [PATCH] Don't crash if ran on unsupported windows --- pplib/kerneloffsets.h | 12 +++++++----- pplib/pplib.cpp | 4 +++- testpplib/main.cpp | 6 ++++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/pplib/kerneloffsets.h b/pplib/kerneloffsets.h index e46b72d..02d6bec 100644 --- a/pplib/kerneloffsets.h +++ b/pplib/kerneloffsets.h @@ -31,7 +31,7 @@ public: static uint64_t objecttable; static uint64_t vadroot; - static void init() + static bool init() { windows_version win_ver = get_windows_version(); @@ -40,16 +40,18 @@ public: { case WINDOWS7: init_win7(); - break; + return true; case WINDOWS8: init_win8(); - break; + return true; case WINDOWS81: init_win81(); - break; + return true; case WINDOWS10: init_win10(); - break; + return true; + default: + return false; } } diff --git a/pplib/pplib.cpp b/pplib/pplib.cpp index 88ddbf1..7040c51 100644 --- a/pplib/pplib.cpp +++ b/pplib/pplib.cpp @@ -6,9 +6,11 @@ using namespace native::structs; bool elevate_ppl() { + if (!kernel_offsets::init()) return false; + if (!init_exploit()) return false; - kernel_offsets::init(); + execute_in_kernel([](MmGetSystemRoutineAddress_t _MmGetSystemRoutineAddress) { diff --git a/testpplib/main.cpp b/testpplib/main.cpp index c6d0a8c..dd270b4 100644 --- a/testpplib/main.cpp +++ b/testpplib/main.cpp @@ -3,7 +3,9 @@ int main() { - elevate_ppl(); - MessageBoxA(NULL, "Use ProcessHacker to check PPL status", "Paused", NULL); + if (elevate_ppl()) + MessageBoxA(NULL, "Use ProcessHacker to check PPL status", "Paused", NULL); + else + MessageBoxA(NULL, "Something went wrong - probably unsuported windows version", "Error", MB_ICONERROR); return 0; }