Skip to content

Commit

Permalink
Clean
Browse files Browse the repository at this point in the history
  • Loading branch information
G_Moris committed Dec 26, 2024
1 parent 11852cb commit a2543bd
Showing 1 changed file with 52 additions and 1 deletion.
53 changes: 52 additions & 1 deletion Client/core/DXHook/CProxyDirect3D9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,54 @@
#include "StdInc.h"
#include <dwmapi.h>
#include <resource.h>
#include <tlhelp32.h>

static HWND FindWindowByProcessName(const char* processName)
{
HWND hwnd = NULL;
DWORD pid = 0;

// Íàéòè ïðîöåññ ïî èìåíè
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSnapshot != INVALID_HANDLE_VALUE)
{
PROCESSENTRY32 pe;
pe.dwSize = sizeof(pe);

if (Process32First(hSnapshot, &pe))
{
do
{
if (strcmp(pe.szExeFile, processName) == 0)
{
pid = pe.th32ProcessID;
break;
}
} while (Process32Next(hSnapshot, &pe));
}
CloseHandle(hSnapshot);
}

if (pid == 0)
return NULL;

// Íàéòè îêíî ïî PID
EnumWindows(
[](HWND hwnd, LPARAM lParam) -> BOOL
{
DWORD windowPid;
GetWindowThreadProcessId(hwnd, &windowPid);
if (windowPid == (DWORD)lParam)
{
*((HWND*)lParam) = hwnd;
return FALSE;
}
return TRUE;
},
(LPARAM)&pid);

return hwnd;
}

extern HINSTANCE g_hModule;

Expand Down Expand Up @@ -176,13 +224,16 @@ HRESULT CProxyDirect3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND
DwmSetWindowAttribute(hFocusWindow, DWMWA_USE_IMMERSIVE_DARK_MODE, &darkTitleBar, sizeof(darkTitleBar));

// Update icon
if (const HICON icon = LoadIconA(g_hModule, MAKEINTRESOURCE(IDI_ICON1)))
if (HICON icon = LoadIconA(g_hModule, MAKEINTRESOURCE(IDI_ICON1)))
{
const auto paramIcon = reinterpret_cast<LPARAM>(icon);
for (const WPARAM size : {ICON_SMALL, ICON_BIG})
{
SendMessage(hFocusWindow, WM_SETICON, size, paramIcon);
}

// Clean
DestroyIcon(icon);
}

// Redraw, we avoid possible problems with the fact that it won't replace the icon somewhere
Expand Down

0 comments on commit a2543bd

Please sign in to comment.