Skip to content

Commit 245b40d

Browse files
committed
Fix vs2019 SAL checks
1 parent 3e68101 commit 245b40d

File tree

14 files changed

+54
-23
lines changed

14 files changed

+54
-23
lines changed

ProcessHacker/cmdmode.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,9 @@ static BOOLEAN PhpGetDllBaseRemoteCallback(
357357
PGET_DLL_BASE_REMOTE_CONTEXT context = Context;
358358
PH_STRINGREF baseDllName;
359359

360+
if (!context)
361+
return TRUE;
362+
360363
PhUnicodeStringToStringRef(&Module->BaseDllName, &baseDllName);
361364

362365
if (PhEqualStringRef(&baseDllName, &context->BaseDllName, TRUE))

ProcessHacker/dbgcon.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ static BOOLEAN NTAPI PhpLoadCurrentProcessSymbolsCallback(
144144
_In_opt_ PVOID Context
145145
)
146146
{
147+
if (!Context)
148+
return TRUE;
149+
147150
PhLoadModuleSymbolProvider((PPH_SYMBOL_PROVIDER)Context, Module->FileName->Buffer,
148151
(ULONG64)Module->BaseAddress, Module->Size);
149152

@@ -433,11 +436,14 @@ static NTSTATUS PhpLeakEnumerationRoutine(
433436
symbol = PhGetSymbolFromAddress(DebugConsoleSymbolProvider, (ULONG64)StackTrace[i], NULL, NULL, NULL, NULL);
434437

435438
if (symbol)
439+
{
436440
wprintf(L"\t%s\n", symbol->Buffer);
441+
PhDereferenceObject(symbol);
442+
}
437443
else
444+
{
438445
wprintf(L"\t?\n");
439-
440-
PhDereferenceObject(symbol);
446+
}
441447
}
442448

443449
NumberOfLeaksShown++;

ProcessHacker/hndllist.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,11 @@ BOOLEAN NTAPI PhpHandleTreeNewCallback(
458458
_In_opt_ PVOID Context
459459
)
460460
{
461-
PPH_HANDLE_LIST_CONTEXT context;
461+
PPH_HANDLE_LIST_CONTEXT context = Context;
462462
PPH_HANDLE_NODE node;
463463

464-
context = Context;
464+
if (!context)
465+
return FALSE;
465466

466467
if (PhCmForwardMessage(hwnd, Message, Parameter1, Parameter2, &context->Cm))
467468
return TRUE;
@@ -472,6 +473,9 @@ BOOLEAN NTAPI PhpHandleTreeNewCallback(
472473
{
473474
PPH_TREENEW_GET_CHILDREN getChildren = Parameter1;
474475

476+
if (!getChildren)
477+
break;
478+
475479
if (!getChildren->Node)
476480
{
477481
static PVOID sortFunctions[] =
@@ -520,6 +524,9 @@ BOOLEAN NTAPI PhpHandleTreeNewCallback(
520524
{
521525
PPH_TREENEW_IS_LEAF isLeaf = Parameter1;
522526

527+
if (!isLeaf)
528+
break;
529+
523530
isLeaf->IsLeaf = TRUE;
524531
}
525532
return TRUE;
@@ -528,6 +535,9 @@ BOOLEAN NTAPI PhpHandleTreeNewCallback(
528535
PPH_TREENEW_GET_CELL_TEXT getCellText = Parameter1;
529536
PPH_HANDLE_ITEM handleItem;
530537

538+
if (!getCellText)
539+
break;
540+
531541
node = (PPH_HANDLE_NODE)getCellText->Node;
532542
handleItem = node->HandleItem;
533543

@@ -620,6 +630,9 @@ BOOLEAN NTAPI PhpHandleTreeNewCallback(
620630
PPH_TREENEW_GET_NODE_COLOR getNodeColor = Parameter1;
621631
PPH_HANDLE_ITEM handleItem;
622632

633+
if (!getNodeColor)
634+
break;
635+
623636
node = (PPH_HANDLE_NODE)getNodeColor->Node;
624637
handleItem = node->HandleItem;
625638

@@ -644,6 +657,9 @@ BOOLEAN NTAPI PhpHandleTreeNewCallback(
644657
{
645658
PPH_TREENEW_KEY_EVENT keyEvent = Parameter1;
646659

660+
if (!keyEvent)
661+
break;
662+
647663
switch (keyEvent->VirtualKey)
648664
{
649665
case 'C':

ProcessHacker/hndlstat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ INT_PTR CALLBACK PhpHandleStatisticsDlgProc(
191191
unknownType = NULL;
192192

193193
if (!entry->Name)
194-
unknownType = PhFormatString(L"(unknown: %lu)", i);
194+
unknownType = PhFormatString(L"(unknown: %lu)", (ULONG)i);
195195

196196
countString = PhFormatUInt64(entry->Count, TRUE);
197197

ProcessHacker/memsrch.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -645,16 +645,15 @@ INT_PTR CALLBACK PhpMemoryStringDlgProc(
645645
return FALSE;
646646
}
647647

648-
static BOOL NTAPI PhpMemoryStringResultCallback(
648+
static VOID NTAPI PhpMemoryStringResultCallback(
649649
_In_ _Assume_refs_(1) PPH_MEMORY_RESULT Result,
650650
_In_opt_ PVOID Context
651651
)
652652
{
653653
PMEMORY_STRING_CONTEXT context = Context;
654654

655-
PhAddItemList(context->Results, Result);
656-
657-
return TRUE;
655+
if (context)
656+
PhAddItemList(context->Results, Result);
658657
}
659658

660659
NTSTATUS PhpMemoryStringThreadStart(

phlib/basesup.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ PVOID PhReAllocateSafe(
538538
*/
539539
_Check_return_
540540
_Ret_maybenull_
541+
_Success_(return != NULL)
541542
PVOID PhAllocatePage(
542543
_In_ SIZE_T Size,
543544
_Out_opt_ PSIZE_T NewSize

phlib/emenu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ PPH_EMENU_ITEM PhFindEMenuItemEx(
174174
_In_ ULONG Flags,
175175
_In_opt_ PWSTR Text,
176176
_In_opt_ ULONG Id,
177-
_Inout_opt_ PPH_EMENU_ITEM *FoundParent,
178-
_Inout_opt_ PULONG FoundIndex
177+
_Out_opt_ PPH_EMENU_ITEM *FoundParent,
178+
_Out_opt_ PULONG FoundIndex
179179
)
180180
{
181181
PH_STRINGREF searchText;

phlib/guisup.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ INT PhFindListViewItemByParam(
169169
return ListView_FindItem(ListViewHandle, StartIndex, &findInfo);
170170
}
171171

172+
_Success_(return)
172173
BOOLEAN PhGetListViewItemImageIndex(
173174
_In_ HWND ListViewHandle,
174175
_In_ INT Index,
@@ -189,6 +190,7 @@ BOOLEAN PhGetListViewItemImageIndex(
189190
return TRUE;
190191
}
191192

193+
_Success_(return)
192194
BOOLEAN PhGetListViewItemParam(
193195
_In_ HWND ListViewHandle,
194196
_In_ INT Index,
@@ -873,6 +875,7 @@ HICON PhGetFileShellIcon(
873875

874876
iconFlag = LargeIcon ? SHGFI_LARGEICON : SHGFI_SMALLICON;
875877
icon = NULL;
878+
memset(&fileInfo, 0, sizeof(SHFILEINFO));
876879

877880
if (FileName && SHGetFileInfo(
878881
FileName,
@@ -887,6 +890,8 @@ HICON PhGetFileShellIcon(
887890

888891
if (!icon && DefaultExtension)
889892
{
893+
memset(&fileInfo, 0, sizeof(SHFILEINFO));
894+
890895
if (SHGetFileInfo(
891896
DefaultExtension,
892897
FILE_ATTRIBUTE_NORMAL,

phlib/include/emenu.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ PPH_EMENU_ITEM PhFindEMenuItemEx(
7777
_In_ ULONG Flags,
7878
_In_opt_ PWSTR Text,
7979
_In_opt_ ULONG Id,
80-
_Inout_opt_ PPH_EMENU_ITEM *FoundParent,
81-
_Inout_opt_ PULONG FoundIndex
80+
_Out_opt_ PPH_EMENU_ITEM *FoundParent,
81+
_Out_opt_ PULONG FoundIndex
8282
);
8383

8484
PHLIBAPI

phlib/include/guisup.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ PhFindListViewItemByParam(
188188
_In_opt_ PVOID Param
189189
);
190190

191+
_Success_(return)
191192
PHLIBAPI
192193
BOOLEAN
193194
NTAPI
@@ -197,6 +198,7 @@ PhGetListViewItemImageIndex(
197198
_Out_ PINT ImageIndex
198199
);
199200

201+
_Success_(return)
200202
PHLIBAPI
201203
BOOLEAN
202204
NTAPI

phlib/include/lsasup.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ PhGetLookupPolicyHandle(
2121
VOID
2222
);
2323

24+
_Success_(return)
2425
PHLIBAPI
2526
BOOLEAN
2627
NTAPI
@@ -29,6 +30,7 @@ PhLookupPrivilegeName(
2930
_Out_ PPH_STRING *PrivilegeName
3031
);
3132

33+
_Success_(return)
3234
PHLIBAPI
3335
BOOLEAN
3436
NTAPI
@@ -37,6 +39,7 @@ PhLookupPrivilegeDisplayName(
3739
_Out_ PPH_STRING *PrivilegeDisplayName
3840
);
3941

42+
_Success_(return)
4043
PHLIBAPI
4144
BOOLEAN
4245
NTAPI

phlib/include/phbasesup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ PhReAllocateSafe(
165165

166166
_Check_return_
167167
_Ret_maybenull_
168+
_Success_(return != NULL)
168169
PHLIBAPI
169170
PVOID
170171
NTAPI

phlib/lsasup.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ LSA_HANDLE PhGetLookupPolicyHandle(
110110
* \param PrivilegeName A variable which receives a pointer to a string containing the privilege
111111
* name. You must free the string using PhDereferenceObject() when you no longer need it.
112112
*/
113+
_Success_(return)
113114
BOOLEAN PhLookupPrivilegeName(
114115
_In_ PLUID PrivilegeValue,
115116
_Out_ PPH_STRING *PrivilegeName
@@ -141,6 +142,7 @@ BOOLEAN PhLookupPrivilegeName(
141142
* privilege's display name. You must free the string using PhDereferenceObject() when you no longer
142143
* need it.
143144
*/
145+
_Success_(return)
144146
BOOLEAN PhLookupPrivilegeDisplayName(
145147
_In_ PPH_STRINGREF PrivilegeName,
146148
_Out_ PPH_STRING *PrivilegeDisplayName
@@ -176,6 +178,7 @@ BOOLEAN PhLookupPrivilegeDisplayName(
176178
* \param PrivilegeName The name of a privilege.
177179
* \param PrivilegeValue A variable which receives the LUID of the privilege.
178180
*/
181+
_Success_(return)
179182
BOOLEAN PhLookupPrivilegeValue(
180183
_In_ PPH_STRINGREF PrivilegeName,
181184
_Out_ PLUID PrivilegeValue

phlib/ref.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -705,20 +705,12 @@ VOID PhDrainAutoPool(
705705
_In_ PPH_AUTO_POOL AutoPool
706706
)
707707
{
708-
ULONG i;
709-
710-
for (i = 0; i < AutoPool->StaticCount; i++)
711-
PhDereferenceObject(AutoPool->StaticObjects[i]);
712-
708+
PhDereferenceObjects(AutoPool->StaticObjects, AutoPool->StaticCount);
713709
AutoPool->StaticCount = 0;
714710

715711
if (AutoPool->DynamicObjects)
716712
{
717-
for (i = 0; i < AutoPool->DynamicCount; i++)
718-
{
719-
PhDereferenceObject(AutoPool->DynamicObjects[i]);
720-
}
721-
713+
PhDereferenceObjects(AutoPool->DynamicObjects, AutoPool->DynamicCount);
722714
AutoPool->DynamicCount = 0;
723715

724716
if (AutoPool->DynamicAllocated > PH_AUTO_POOL_DYNAMIC_BIG_SIZE)

0 commit comments

Comments
 (0)