Skip to content

Commit c14c8ca

Browse files
committed
Remove unused resources (patch by tetyys) (1/2)
1 parent 2cb7b9a commit c14c8ca

File tree

5 files changed

+30
-31
lines changed

5 files changed

+30
-31
lines changed

ProcessHacker/include/mainwnd.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef PH_MAINWND_H
22
#define PH_MAINWND_H
33

4-
#define PH_MAINWND_CLASSNAME L"ProcessHacker" // phapppub
5-
64
PHAPPAPI extern HWND PhMainWndHandle; // phapppub
75
extern BOOLEAN PhMainWndExiting;
86

ProcessHacker/include/mainwndp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ LRESULT CALLBACK PhMwpWndProc(
3333

3434
// Initialization
3535

36-
BOOLEAN PhMwpInitializeWindowClass(
36+
RTL_ATOM PhMwpInitializeWindowClass(
3737
VOID
3838
);
3939

ProcessHacker/mainwnd.c

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Main window
44
*
55
* Copyright (C) 2009-2016 wj32
6+
* Copyright (C) 2017 dmex
67
*
78
* This file is part of Process Hacker.
89
*
@@ -99,6 +100,7 @@ BOOLEAN PhMainWndInitialization(
99100
_In_ INT ShowCommand
100101
)
101102
{
103+
RTL_ATOM windowAtom;
102104
PH_STRING_BUILDER stringBuilder;
103105
PH_RECTANGLE windowRectangle;
104106

@@ -118,7 +120,7 @@ BOOLEAN PhMainWndInitialization(
118120

119121
PhMwpInitializeProviders();
120122

121-
if (!PhMwpInitializeWindowClass())
123+
if ((windowAtom = PhMwpInitializeWindowClass()) == INVALID_ATOM)
122124
return FALSE;
123125

124126
windowRectangle.Position = PhGetIntegerPairSetting(L"MainWindowPosition");
@@ -127,23 +129,27 @@ BOOLEAN PhMainWndInitialization(
127129
// Create the window title.
128130

129131
PhInitializeStringBuilder(&stringBuilder, 100);
130-
PhAppendStringBuilder2(&stringBuilder, L"Process Hacker");
131132

132-
if (PhCurrentUserName)
133+
if (PhGetIntegerSetting(L"EnableWindowText"))
133134
{
134-
PhAppendStringBuilder2(&stringBuilder, L" [");
135-
PhAppendStringBuilder(&stringBuilder, &PhCurrentUserName->sr);
136-
PhAppendCharStringBuilder(&stringBuilder, ']');
137-
if (KphIsConnected()) PhAppendCharStringBuilder(&stringBuilder, '+');
138-
}
135+
PhAppendStringBuilder2(&stringBuilder, L"Process Hacker");
136+
137+
if (PhCurrentUserName)
138+
{
139+
PhAppendStringBuilder2(&stringBuilder, L" [");
140+
PhAppendStringBuilder(&stringBuilder, &PhCurrentUserName->sr);
141+
PhAppendCharStringBuilder(&stringBuilder, ']');
142+
if (KphIsConnected()) PhAppendCharStringBuilder(&stringBuilder, '+');
143+
}
139144

140-
if (WINDOWS_HAS_UAC && PhGetOwnTokenAttributes().ElevationType == TokenElevationTypeFull)
141-
PhAppendStringBuilder2(&stringBuilder, L" (Administrator)");
145+
if (WINDOWS_HAS_UAC && PhGetOwnTokenAttributes().ElevationType == TokenElevationTypeFull)
146+
PhAppendStringBuilder2(&stringBuilder, L" (Administrator)");
147+
}
142148

143149
// Create the window.
144150

145151
PhMainWndHandle = CreateWindow(
146-
PH_MAINWND_CLASSNAME,
152+
MAKEINTATOM(windowAtom),
147153
stringBuilder.String->Buffer,
148154
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
149155
windowRectangle.Left,
@@ -329,30 +335,28 @@ LRESULT CALLBACK PhMwpWndProc(
329335
return DefWindowProc(hWnd, uMsg, wParam, lParam);
330336
}
331337

332-
BOOLEAN PhMwpInitializeWindowClass(
338+
RTL_ATOM PhMwpInitializeWindowClass(
333339
VOID
334340
)
335341
{
336342
WNDCLASSEX wcex;
337-
343+
PPH_STRING className;
344+
338345
memset(&wcex, 0, sizeof(WNDCLASSEX));
339346
wcex.cbSize = sizeof(WNDCLASSEX);
340347
wcex.style = 0;
341348
wcex.lpfnWndProc = PhMwpWndProc;
342349
wcex.cbClsExtra = 0;
343350
wcex.cbWndExtra = 0;
344351
wcex.hInstance = PhInstanceHandle;
345-
wcex.hIcon = PH_LOAD_SHARED_ICON_LARGE(PhLibImageBase, MAKEINTRESOURCE(IDI_PROCESSHACKER));
346-
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
347-
//wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
352+
className = PhaGetStringSetting(L"MainWindowClassName");
353+
wcex.lpszClassName = PhGetStringOrDefault(className, L"MainWindowClassName");
348354
wcex.lpszMenuName = MAKEINTRESOURCE(IDR_MAINWND);
349-
wcex.lpszClassName = PH_MAINWND_CLASSNAME;
355+
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
356+
wcex.hIcon = PH_LOAD_SHARED_ICON_LARGE(PhLibImageBase, MAKEINTRESOURCE(IDI_PROCESSHACKER));
350357
wcex.hIconSm = PH_LOAD_SHARED_ICON_SMALL(PhLibImageBase, MAKEINTRESOURCE(IDI_PROCESSHACKER));
351358

352-
if (!RegisterClassEx(&wcex))
353-
return FALSE;
354-
355-
return TRUE;
359+
return RegisterClassEx(&wcex);
356360
}
357361

358362
VOID PhMwpInitializeProviders(
@@ -425,7 +429,7 @@ VOID PhMwpInitializeControls(
425429
3,
426430
3,
427431
PhMainWndHandle,
428-
(HMENU)ID_MAINWND_PROCESSTL,
432+
NULL,
429433
PhLibImageBase,
430434
NULL
431435
);
@@ -440,7 +444,7 @@ VOID PhMwpInitializeControls(
440444
3,
441445
3,
442446
PhMainWndHandle,
443-
(HMENU)ID_MAINWND_SERVICETL,
447+
NULL,
444448
PhLibImageBase,
445449
NULL
446450
);
@@ -455,7 +459,7 @@ VOID PhMwpInitializeControls(
455459
3,
456460
3,
457461
PhMainWndHandle,
458-
(HMENU)ID_MAINWND_NETWORKTL,
462+
NULL,
459463
PhLibImageBase,
460464
NULL
461465
);

ProcessHacker/resource.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,6 @@
534534
#define IDC_HANDLESEARCH 1385
535535
#define IDC_SEARCH 1387
536536
#define IDC_FILTEROPTIONS 1389
537-
#define ID_MAINWND_PROCESSTL 2001
538-
#define ID_MAINWND_SERVICETL 2002
539-
#define ID_MAINWND_NETWORKTL 2003
540-
#define ID_MAINWND_PROCESSLV 2004
541537
#define ID_HACKER_EXIT 40001
542538
#define ID_PROCESS_PROPERTIES 40006
543539
#define ID_PROCESS_TERMINATE 40007

ProcessHacker/settings.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ VOID PhAddDefaultSettings(
8181
PhpAddIntegerPairSetting(L"LogWindowPosition", L"300,300");
8282
PhpAddScalableIntegerPairSetting(L"LogWindowSize", L"@96|450,500");
8383
PhpAddIntegerSetting(L"MainWindowAlwaysOnTop", L"0");
84+
PhpAddStringSetting(L"MainWindowClassName", L"MainWindowClassName");
8485
PhpAddIntegerSetting(L"MainWindowOpacity", L"0"); // means 100%
8586
PhpAddIntegerPairSetting(L"MainWindowPosition", L"100,100");
8687
PhpAddScalableIntegerPairSetting(L"MainWindowSize", L"@96|800,600");

0 commit comments

Comments
 (0)