From 2c2132b9316bccb2471e3c0df3fb8c08645502b1 Mon Sep 17 00:00:00 2001 From: marcoigorr Date: Fri, 26 Aug 2022 16:31:33 +0200 Subject: [PATCH] Created window class, various changes --- ExOverlay.vcxproj | 2 ++ ExOverlay.vcxproj.filters | 9 ++++++ d3d.cpp | 6 ++-- main.cpp | 60 ++++++--------------------------------- wnd.cpp | 57 +++++++++++++++++++++++++++++++++++++ wnd.h | 13 +++++++++ 6 files changed, 91 insertions(+), 56 deletions(-) create mode 100644 wnd.cpp create mode 100644 wnd.h diff --git a/ExOverlay.vcxproj b/ExOverlay.vcxproj index 144902e..1b4a505 100644 --- a/ExOverlay.vcxproj +++ b/ExOverlay.vcxproj @@ -148,6 +148,7 @@ + @@ -166,6 +167,7 @@ + diff --git a/ExOverlay.vcxproj.filters b/ExOverlay.vcxproj.filters index 01d1672..93b84d1 100644 --- a/ExOverlay.vcxproj.filters +++ b/ExOverlay.vcxproj.filters @@ -40,6 +40,9 @@ {6213f21f-4f99-455b-9a45-67fcb4b6e946} + + {0d3dc74f-24db-40fd-a459-8370baecc965} + @@ -87,6 +90,9 @@ Hack\proc + + Window + @@ -137,5 +143,8 @@ Hack\proc + + Window + \ No newline at end of file diff --git a/d3d.cpp b/d3d.cpp index 6a60cdb..ac2170a 100644 --- a/d3d.cpp +++ b/d3d.cpp @@ -49,10 +49,8 @@ void Direct3D9::renderFrame() d3ddev->BeginScene(); // 3D rendering on the back buffer here... - if (option->bMenu) - { - D3D9->drawText((char*)"ULTRAKILL Process found!", 100, option->SCREEN_HEIGHT - 100, 255, 255, 255, 255); - } + + D3D9->drawText((char*)"ULTRAKILL Process found!", 100, option->SCREEN_HEIGHT - 100, 255, 255, 255, 255); // End d3d scene d3ddev->EndScene(); diff --git a/main.cpp b/main.cpp index 414e934..09e8ae0 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,6 @@ #include "framework.h" +#include "wnd.h" // window class #include "d3d.h" #include "dearImGui.h" @@ -14,7 +15,6 @@ // Forward declare message handler from imgui_impl_win32.cpp extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam)) @@ -55,59 +55,15 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine option->exit = true; } - // Window Title - WCHAR overlayTitle[50] = L"ExOverlay"; - // Handle for the window - HWND hWnd; - // Struct that holds info for the window class - WNDCLASSEX wc; - - // Clearing window class for use - ZeroMemory(&wc, sizeof(wc)); - - // Filling needed information - wc.cbSize = sizeof(wc); - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = 0; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = CreateSolidBrush(RGB(0,0,0)); - wc.lpszMenuName = overlayTitle; - wc.lpszClassName = overlayTitle; - wc.hIconSm = 0; - - // Register window class - RegisterClassExW(&wc); - - // Create the window and use the result as the handle - hWnd = CreateWindowEx( - WS_EX_LAYERED, - overlayTitle, // name of the window class - overlayTitle, // title of the window - WS_POPUP | WS_EX_TOPMOST, // window style - 0, // x-position of the window - 0, // y-position of the window - option->SCREEN_WIDTH, // width of the window - option->SCREEN_HEIGHT, // height of the window - NULL, // we have no parent window, NULL - NULL, // we aren't using menus, NULL - hInstance, // application handle - NULL); // used with multiple windows, NULL - - if (!hWnd) - return FALSE; - - // Set the opacity and transparency color key - SetLayeredWindowAttributes(hWnd, RGB(0, 0, 0), 0, LWA_COLORKEY); - - // Display window - ShowWindow(hWnd, nCmdShow); + // Windows fullscreen transparent window creation + if (!window->createWnd(hInstance)) + option->exit = true; + + // Display created window + ShowWindow(window->hWnd, nCmdShow); // Set up and initialize Direct3D and ImGui - D3D9->initD3D(hWnd); + D3D9->initD3D(window->hWnd); MSG msg; diff --git a/wnd.cpp b/wnd.cpp new file mode 100644 index 0000000..80af583 --- /dev/null +++ b/wnd.cpp @@ -0,0 +1,57 @@ +#include "framework.h" +#include "wnd.h" + +#include "Option.h" + +#define wc window->wc + + +// forward declaration of WndProc in main.cpp +extern LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); +bool Window::createWnd(HINSTANCE hInstance) +{ + // Clearing window class for use + ZeroMemory(&wc, sizeof(wc)); + + // Filling needed information + wc.cbSize = sizeof(wc); + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = WndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInstance; + wc.hIcon = 0; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = CreateSolidBrush(RGB(0, 0, 0)); + wc.lpszMenuName = overlayTitle; + wc.lpszClassName = overlayTitle; + wc.hIconSm = 0; + + // Register window class + RegisterClassExW(&wc); + + // Create the window and use the result as the handle + window->hWnd = CreateWindowEx( + WS_EX_LAYERED, + window->overlayTitle, // name of the window class + window->overlayTitle, // title of the window + WS_POPUP | WS_EX_TOPMOST, // window style + 0, // x-position of the window + 0, // y-position of the window + option->SCREEN_WIDTH, // width of the window + option->SCREEN_HEIGHT, // height of the window + NULL, // we have no parent window, NULL + NULL, // we aren't using menus, NULL + hInstance, // application handle + NULL); // used with multiple windows, NULL + + if (!window->hWnd) + return FALSE; + + // Set the opacity and transparency color key + SetLayeredWindowAttributes(window->hWnd, RGB(0, 0, 0), 0, LWA_COLORKEY); + + return TRUE; +} + +Window* window = new Window(); \ No newline at end of file diff --git a/wnd.h b/wnd.h new file mode 100644 index 0000000..8228094 --- /dev/null +++ b/wnd.h @@ -0,0 +1,13 @@ +#pragma once + +class Window +{ +public: + WCHAR overlayTitle[50] = L"ExOverlay"; // Window Title + HWND hWnd; // Handle for the window + WNDCLASSEX wc; // Struct that holds info for the window class + + bool createWnd(HINSTANCE hInstance); +}; + +extern Window* window;