Skip to content

Commit 8168b44

Browse files
committed
Improve macro usage
1 parent 35fda0b commit 8168b44

File tree

17 files changed

+41
-39
lines changed

17 files changed

+41
-39
lines changed

ProcessHacker/about.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ VOID PhShowAboutDialog(
161161
ShowWindow(PhAboutWindowHandle, SW_SHOW);
162162
}
163163

164-
if (IsIconic(PhAboutWindowHandle))
164+
if (IsMinimized(PhAboutWindowHandle))
165165
ShowWindow(PhAboutWindowHandle, SW_RESTORE);
166166
else
167167
SetForegroundWindow(PhAboutWindowHandle);

ProcessHacker/appsup.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ VOID PhCopyListViewInfoTip(
941941
Tip->Buffer,
942942
copyLength * 2
943943
);
944-
GetInfoTip->pszText[copyIndex + copyLength] = 0;
944+
GetInfoTip->pszText[copyIndex + copyLength] = UNICODE_NULL;
945945
}
946946

947947
VOID PhCopyListView(
@@ -1969,11 +1969,11 @@ BOOLEAN PhpSelectFavoriteInRegedit(
19691969
for (i = 3; i < count; i++)
19701970
{
19711971
MENUITEMINFO info = { sizeof(MENUITEMINFO) };
1972-
WCHAR buffer[32];
1972+
WCHAR buffer[MAX_PATH];
19731973

19741974
info.fMask = MIIM_ID | MIIM_STRING;
19751975
info.dwTypeData = buffer;
1976-
info.cch = sizeof(buffer) / sizeof(WCHAR);
1976+
info.cch = RTL_NUMBER_OF(buffer);
19771977
GetMenuItemInfo(favoritesMenu, i, TRUE, &info);
19781978

19791979
if (info.cch == FavoriteName->Length / sizeof(WCHAR))
@@ -2007,7 +2007,7 @@ BOOLEAN PhpSelectFavoriteInRegedit(
20072007
PostMessage(RegeditWindow, WM_MENUSELECT, MAKEWPARAM(0, 0xffff), 0);
20082008

20092009
// Bring regedit to the top.
2010-
if (IsIconic(RegeditWindow))
2010+
if (IsMinimized(RegeditWindow))
20112011
{
20122012
ShowWindow(RegeditWindow, SW_RESTORE);
20132013
SetForegroundWindow(RegeditWindow);

ProcessHacker/dbgcon.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ VOID PhShowDebugConsole(
9090
// Set a handler so we can catch Ctrl+C and Ctrl+Break.
9191
SetConsoleCtrlHandler(ConsoleHandlerRoutine, TRUE);
9292

93-
freopen("CONOUT$", "w", stdout);
94-
freopen("CONOUT$", "w", stderr);
95-
freopen("CONIN$", "r", stdin);
93+
_wfreopen(L"CONOUT$", L"w", stdout);
94+
_wfreopen(L"CONOUT$", L"w", stderr);
95+
_wfreopen(L"CONIN$", L"r", stdin);
96+
9697
DebugConsoleThreadHandle = PhCreateThread(0, PhpDebugConsoleThreadStart, NULL);
9798
}
9899
else
@@ -102,7 +103,7 @@ VOID PhShowDebugConsole(
102103
consoleWindow = GetConsoleWindow();
103104

104105
// Console window already exists, so bring it to the top.
105-
if (IsIconic(consoleWindow))
106+
if (IsMinimized(consoleWindow))
106107
ShowWindow(consoleWindow, SW_RESTORE);
107108
else
108109
BringWindowToTop(consoleWindow);
@@ -115,9 +116,9 @@ VOID PhCloseDebugConsole(
115116
VOID
116117
)
117118
{
118-
freopen("NUL", "w", stdout);
119-
freopen("NUL", "w", stderr);
120-
freopen("NUL", "r", stdin);
119+
_wfreopen(L"NUL", L"w", stdout);
120+
_wfreopen(L"NUL", L"w", stderr);
121+
_wfreopen(L"NUL", L"r", stdin);
121122

122123
FreeConsole();
123124
}
@@ -599,7 +600,7 @@ static VOID PhpTestRwLock(
599600
Context->ReleaseShared(Context->Parameter);
600601

601602
// Null test
602-
603+
PhInitializeStopwatch(&stopwatch);
603604
PhStartStopwatch(&stopwatch);
604605

605606
for (i = 0; i < 2000000; i++)
@@ -626,6 +627,7 @@ static VOID PhpTestRwLock(
626627
}
627628

628629
PhWaitForBarrier(&RwStartBarrier, FALSE);
630+
PhInitializeStopwatch(&stopwatch);
629631
PhStartStopwatch(&stopwatch);
630632
NtWaitForMultipleObjects(RW_PROCESSORS, threadHandles, WaitAll, FALSE, NULL);
631633
PhStopStopwatch(&stopwatch);
@@ -742,7 +744,7 @@ NTSTATUS PhpDebugConsoleThreadStart(
742744
inputLength = (ULONG)PhCountStringZ(line);
743745

744746
if (inputLength != 0)
745-
line[inputLength - 1] = 0;
747+
line[inputLength - 1] = UNICODE_NULL;
746748

747749
context = NULL;
748750
command = wcstok_s(line, delims, &context);

ProcessHacker/hndllist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ BOOLEAN NTAPI PhpHandleTreeNewCallback(
596596
node->FileShareAccessText[0] = '-';
597597
node->FileShareAccessText[1] = '-';
598598
node->FileShareAccessText[2] = '-';
599-
node->FileShareAccessText[3] = 0;
599+
node->FileShareAccessText[3] = UNICODE_NULL;
600600

601601
if (handleItem->FileFlags & PH_HANDLE_FILE_SHARED_READ)
602602
node->FileShareAccessText[0] = 'R';

ProcessHacker/logwnd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ VOID PhShowLogDialog(
5858
ShowWindow(PhLogWindowHandle, SW_SHOW);
5959
}
6060

61-
if (IsIconic(PhLogWindowHandle))
61+
if (IsMinimized(PhLogWindowHandle))
6262
ShowWindow(PhLogWindowHandle, SW_RESTORE);
6363
else
6464
SetForegroundWindow(PhLogWindowHandle);

ProcessHacker/mainwnd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,7 @@ VOID PhMwpOnSize(
17121712
VOID
17131713
)
17141714
{
1715-
if (!IsIconic(PhMainWndHandle))
1715+
if (!IsMinimized(PhMainWndHandle))
17161716
{
17171717
HDWP deferHandle;
17181718

@@ -1956,7 +1956,7 @@ ULONG_PTR PhMwpOnUserMessage(
19561956
ShowWindow(PhMainWndHandle, SW_SHOW);
19571957
}
19581958

1959-
if (IsIconic(PhMainWndHandle))
1959+
if (IsMinimized(PhMainWndHandle))
19601960
{
19611961
ShowWindow(PhMainWndHandle, SW_RESTORE);
19621962
}
@@ -2351,7 +2351,7 @@ VOID PhMwpActivateWindow(
23512351
_In_ BOOLEAN Toggle
23522352
)
23532353
{
2354-
if (IsIconic(PhMainWndHandle))
2354+
if (IsMinimized(PhMainWndHandle))
23552355
{
23562356
ShowWindow(PhMainWndHandle, SW_RESTORE);
23572357
SetForegroundWindow(PhMainWndHandle);

ProcessHacker/memedit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ VOID PhShowMemoryEditorDialog(
133133
{
134134
context = CONTAINING_RECORD(links, MEMORY_EDITOR_CONTEXT, Links);
135135

136-
if (IsIconic(context->WindowHandle))
136+
if (IsMinimized(context->WindowHandle))
137137
ShowWindow(context->WindowHandle, SW_RESTORE);
138138
else
139139
SetForegroundWindow(context->WindowHandle);

ProcessHacker/memlists.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ VOID PhShowMemoryListsDialog(
6262

6363
if (!IsWindowVisible(PhMemoryListsWindowHandle))
6464
ShowWindow(PhMemoryListsWindowHandle, SW_SHOW);
65-
else if (IsIconic(PhMemoryListsWindowHandle))
65+
else if (IsMinimized(PhMemoryListsWindowHandle))
6666
ShowWindow(PhMemoryListsWindowHandle, SW_RESTORE);
6767
else
6868
SetForegroundWindow(PhMemoryListsWindowHandle);

ProcessHacker/memprv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ VOID PhGetMemoryProtectionString(
4646

4747
if (!Protection)
4848
{
49-
String[0] = 0;
49+
String[0] = UNICODE_NULL;
5050
return;
5151
}
5252

ProcessHacker/options.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ VOID PhShowOptionsDialog(
174174
ShowWindow(PhOptionsWindowHandle, SW_SHOW);
175175
}
176176

177-
if (IsIconic(PhOptionsWindowHandle))
177+
if (IsMinimized(PhOptionsWindowHandle))
178178
ShowWindow(PhOptionsWindowHandle, SW_RESTORE);
179179
else
180180
SetForegroundWindow(PhOptionsWindowHandle);

ProcessHacker/procprp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ LRESULT CALLBACK PhpPropSheetWndProc(
273273
break;
274274
case WM_SIZE:
275275
{
276-
if (!IsIconic(hwnd))
276+
if (!IsMinimized(hwnd))
277277
{
278278
PhLayoutManagerLayout(&propSheetContext->LayoutManager);
279279
}

ProcessHacker/syssccpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ VOID PhSipGetCpuBrandString(
840840
);
841841

842842
PhZeroExtendToUtf16Buffer(brandString, 48, BrandString);
843-
BrandString[48] = 0;
843+
BrandString[48] = UNICODE_NULL;
844844
}
845845

846846
BOOLEAN PhSipGetCpuFrequencyFromDistribution(

phlib/extlv.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -721,8 +721,8 @@ static INT PhpDefaultCompareListViewItems(
721721
_In_ ULONG Column
722722
)
723723
{
724-
WCHAR xText[261];
725-
WCHAR yText[261];
724+
WCHAR xText[MAX_PATH + 1];
725+
WCHAR yText[MAX_PATH + 1];
726726
LVITEM item;
727727

728728
// Get the X item text.
@@ -731,18 +731,18 @@ static INT PhpDefaultCompareListViewItems(
731731
item.iItem = X;
732732
item.iSubItem = Column;
733733
item.pszText = xText;
734-
item.cchTextMax = 260;
734+
item.cchTextMax = MAX_PATH;
735735

736-
xText[0] = 0;
736+
xText[0] = UNICODE_NULL;
737737
CallWindowProc(Context->OldWndProc, Context->Handle, LVM_GETITEM, 0, (LPARAM)&item);
738738

739739
// Get the Y item text.
740740

741741
item.iItem = Y;
742742
item.pszText = yText;
743-
item.cchTextMax = 260;
743+
item.cchTextMax = MAX_PATH;
744744

745-
yText[0] = 0;
745+
yText[0] = UNICODE_NULL;
746746
CallWindowProc(Context->OldWndProc, Context->Handle, LVM_GETITEM, 0, (LPARAM)&item);
747747

748748
// Compare them.

phlib/maplib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,14 +294,14 @@ NTSTATUS PhpGetMappedArchiveMemberFromHeader(
294294
{
295295
// Longnames member. Set the name to "/".
296296
Member->NameBuffer[0] = '/';
297-
Member->NameBuffer[1] = 0;
297+
Member->NameBuffer[1] = ANSI_NULL;
298298

299299
Member->Type = LongnamesArchiveMemberType;
300300
}
301301
else
302302
{
303303
// Linker member. Set the name to "".
304-
Member->NameBuffer[0] = 0;
304+
Member->NameBuffer[0] = ANSI_NULL;
305305

306306
Member->Type = LinkerArchiveMemberType;
307307
}

phlib/symprv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ NTSTATUS PhpLookupDynamicFunctionTable(
967967
}
968968
else
969969
{
970-
OutOfProcessCallbackDllBuffer[0] = 0;
970+
OutOfProcessCallbackDllBuffer[0] = UNICODE_NULL;
971971

972972
if (OutOfProcessCallbackDllString)
973973
{

phlib/theme.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ VOID PhReInitializeWindowTheme(
242242
WCHAR windowClassName[MAX_PATH];
243243

244244
if (!GetClassName(currentWindow, windowClassName, RTL_NUMBER_OF(windowClassName)))
245-
windowClassName[0] = 0;
245+
windowClassName[0] = UNICODE_NULL;
246246

247247
//dprintf("PhReInitializeWindowTheme: %S\r\n", windowClassName);
248248

@@ -352,7 +352,7 @@ BOOLEAN CALLBACK PhpThemeWindowEnumChildWindows(
352352
return TRUE;
353353

354354
if (!GetClassName(WindowHandle, windowClassName, RTL_NUMBER_OF(windowClassName)))
355-
windowClassName[0] = 0;
355+
windowClassName[0] = UNICODE_NULL;
356356

357357
//dprintf("PhpThemeWindowEnumChildWindows: %S\r\n", windowClassName);
358358

@@ -506,7 +506,7 @@ BOOLEAN CALLBACK PhpReInitializeThemeWindowEnumChildWindows(
506506
);
507507

508508
if (!GetClassName(WindowHandle, windowClassName, RTL_NUMBER_OF(windowClassName)))
509-
windowClassName[0] = 0;
509+
windowClassName[0] = UNICODE_NULL;
510510

511511
//dprintf("PhpReInitializeThemeWindowEnumChildWindows: %S\r\n", windowClassName);
512512

@@ -1442,7 +1442,7 @@ LRESULT CALLBACK PhpThemeWindowSubclassProc(
14421442
WCHAR className[MAX_PATH];
14431443

14441444
if (!GetClassName(customDraw->hdr.hwndFrom, className, RTL_NUMBER_OF(className)))
1445-
className[0] = 0;
1445+
className[0] = UNICODE_NULL;
14461446

14471447
//dprintf("NM_CUSTOMDRAW: %S\r\n", className);
14481448

tools/peview/prpsh.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ LRESULT CALLBACK PvpPropSheetWndProc(
252252
break;
253253
case WM_SIZE:
254254
{
255-
if (!IsIconic(hWnd))
255+
if (!IsMinimized(hWnd))
256256
{
257257
PhLayoutManagerLayout(&propSheetContext->LayoutManager);
258258
}

0 commit comments

Comments
 (0)