Skip to content

Commit

Permalink
Created window class, various changes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoigorr committed Aug 26, 2022
1 parent a94ba7f commit 2c2132b
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 56 deletions.
2 changes: 2 additions & 0 deletions ExOverlay.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
<ClCompile Include="offsets.cpp" />
<ClCompile Include="Option.cpp" />
<ClCompile Include="proc.cpp" />
<ClCompile Include="wnd.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="addresses.h" />
Expand All @@ -166,6 +167,7 @@
<ClInclude Include="offsets.h" />
<ClInclude Include="Option.h" />
<ClInclude Include="proc.h" />
<ClInclude Include="wnd.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
9 changes: 9 additions & 0 deletions ExOverlay.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
<Filter Include="Hack\proc">
<UniqueIdentifier>{6213f21f-4f99-455b-9a45-67fcb4b6e946}</UniqueIdentifier>
</Filter>
<Filter Include="Window">
<UniqueIdentifier>{0d3dc74f-24db-40fd-a459-8370baecc965}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
Expand Down Expand Up @@ -87,6 +90,9 @@
<ClCompile Include="proc.cpp">
<Filter>Hack\proc</Filter>
</ClCompile>
<ClCompile Include="wnd.cpp">
<Filter>Window</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
Expand Down Expand Up @@ -137,5 +143,8 @@
<ClInclude Include="proc.h">
<Filter>Hack\proc</Filter>
</ClInclude>
<ClInclude Include="wnd.h">
<Filter>Window</Filter>
</ClInclude>
</ItemGroup>
</Project>
6 changes: 2 additions & 4 deletions d3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
60 changes: 8 additions & 52 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

#include "framework.h"
#include "wnd.h" // window class
#include "d3d.h"
#include "dearImGui.h"

Expand All @@ -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))
Expand Down Expand Up @@ -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;

Expand Down
57 changes: 57 additions & 0 deletions wnd.cpp
Original file line number Diff line number Diff line change
@@ -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();
13 changes: 13 additions & 0 deletions wnd.h
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 2c2132b

Please sign in to comment.