Fix some SAL warnings
This commit is contained in:
@@ -999,7 +999,7 @@ static PPH_STRING PhpaGetSendMessageReceiver(
|
||||
return PhaFormatString(L"Window 0x%Ix (%s): %s \"%s\"", windowHandle, clientIdName->Buffer, windowClass, PhGetStringOrEmpty(windowText));
|
||||
}
|
||||
|
||||
static PPH_STRING PhpaGetAlpcInformation(
|
||||
PPH_STRING PhpaGetAlpcInformation(
|
||||
_In_ HANDLE ThreadId
|
||||
)
|
||||
{
|
||||
|
||||
@@ -726,7 +726,10 @@ VOID PhpFindObjectAddResultEntries(
|
||||
PhPrintPointer(objectNode->ObjectString, searchResult->Object);
|
||||
}
|
||||
|
||||
PhDereferenceObject(processItem);
|
||||
if (processItem)
|
||||
{
|
||||
PhDereferenceObject(processItem);
|
||||
}
|
||||
}
|
||||
|
||||
Context->SearchResultsAddIndex = i;
|
||||
|
||||
+11
-7
@@ -273,7 +273,7 @@ BOOLEAN PhpInitializeNetApi(VOID)
|
||||
NetApiBufferFree_I = PhGetDllBaseProcedureAddress(netapiModuleHandle, "NetApiBufferFree", 0);
|
||||
}
|
||||
|
||||
if (!NetUserEnum_I && !NetApiBufferFree_I)
|
||||
if (netapiModuleHandle && !NetUserEnum_I && !NetApiBufferFree_I)
|
||||
{
|
||||
FreeLibrary(netapiModuleHandle);
|
||||
netapiModuleHandle = NULL;
|
||||
@@ -414,7 +414,8 @@ VOID PhpFreeProgramsComboBox(
|
||||
{
|
||||
ULONG total;
|
||||
|
||||
total = ComboBox_GetCount(ComboBoxHandle);
|
||||
if ((total = ComboBox_GetCount(ComboBoxHandle)) == CB_ERR)
|
||||
return;
|
||||
|
||||
for (ULONG i = 0; i < total; i++)
|
||||
{
|
||||
@@ -428,7 +429,8 @@ static VOID PhpFreeAccountsComboBox(
|
||||
{
|
||||
ULONG total;
|
||||
|
||||
total = ComboBox_GetCount(ComboBoxHandle);
|
||||
if ((total = ComboBox_GetCount(ComboBoxHandle)) == CB_ERR)
|
||||
return;
|
||||
|
||||
for (ULONG i = 0; i < total; i++)
|
||||
{
|
||||
@@ -573,7 +575,8 @@ static VOID PhpFreeSessionsComboBox(
|
||||
ULONG total;
|
||||
ULONG i;
|
||||
|
||||
total = ComboBox_GetCount(ComboBoxHandle);
|
||||
if ((total = ComboBox_GetCount(ComboBoxHandle)) == CB_ERR)
|
||||
return;
|
||||
|
||||
for (i = 0; i < total; i++)
|
||||
{
|
||||
@@ -701,7 +704,8 @@ static VOID PhpFreeDesktopsComboBox(
|
||||
ULONG total;
|
||||
ULONG i;
|
||||
|
||||
total = ComboBox_GetCount(ComboBoxHandle);
|
||||
if ((total = ComboBox_GetCount(ComboBoxHandle)) == CB_ERR)
|
||||
return;
|
||||
|
||||
for (i = 0; i < total; i++)
|
||||
{
|
||||
@@ -1512,8 +1516,8 @@ NTSTATUS PhExecuteRunAsCommand3(
|
||||
|
||||
static VOID PhpSplitUserName(
|
||||
_In_ PWSTR UserName,
|
||||
_Out_ PPH_STRING *DomainPart,
|
||||
_Out_ PPH_STRING *UserPart
|
||||
_Out_opt_ PPH_STRING *DomainPart,
|
||||
_Out_opt_ PPH_STRING *UserPart
|
||||
)
|
||||
{
|
||||
PH_STRINGREF userName;
|
||||
|
||||
+9
-9
@@ -4733,7 +4733,7 @@ VOID PhpResizeHashtable(
|
||||
|
||||
for (i = 0; i < Hashtable->NextEntry; i++)
|
||||
{
|
||||
if (entry->HashCode != -1)
|
||||
if (entry->HashCode != ULONG_MAX)
|
||||
{
|
||||
ULONG index = PhpIndexFromHash(Hashtable, entry->HashCode);
|
||||
|
||||
@@ -4764,7 +4764,7 @@ FORCEINLINE PVOID PhpAddEntryHashtable(
|
||||
{
|
||||
ULONG i;
|
||||
|
||||
for (i = Hashtable->Buckets[index]; i != -1; i = entry->Next)
|
||||
for (i = Hashtable->Buckets[index]; i != ULONG_MAX; i = entry->Next)
|
||||
{
|
||||
entry = PH_HASHTABLE_GET_ENTRY(Hashtable, i);
|
||||
|
||||
@@ -4779,7 +4779,7 @@ FORCEINLINE PVOID PhpAddEntryHashtable(
|
||||
}
|
||||
|
||||
// Use a free entry if possible.
|
||||
if (Hashtable->FreeEntry != -1)
|
||||
if (Hashtable->FreeEntry != ULONG_MAX)
|
||||
{
|
||||
freeEntry = Hashtable->FreeEntry;
|
||||
entry = PH_HASHTABLE_GET_ENTRY(Hashtable, freeEntry);
|
||||
@@ -4909,7 +4909,7 @@ BOOLEAN PhEnumHashtable(
|
||||
|
||||
(*EnumerationKey)++;
|
||||
|
||||
if (entry->HashCode != -1)
|
||||
if (entry->HashCode != ULONG_MAX)
|
||||
{
|
||||
*Entry = &entry->Body;
|
||||
return TRUE;
|
||||
@@ -4944,7 +4944,7 @@ PVOID PhFindEntryHashtable(
|
||||
hashCode = PhpValidateHash(Hashtable->HashFunction(Entry));
|
||||
index = PhpIndexFromHash(Hashtable, hashCode);
|
||||
|
||||
for (i = Hashtable->Buckets[index]; i != -1; i = entry->Next)
|
||||
for (i = Hashtable->Buckets[index]; i != ULONG_MAX; i = entry->Next)
|
||||
{
|
||||
entry = PH_HASHTABLE_GET_ENTRY(Hashtable, i);
|
||||
|
||||
@@ -4981,16 +4981,16 @@ BOOLEAN PhRemoveEntryHashtable(
|
||||
|
||||
hashCode = PhpValidateHash(Hashtable->HashFunction(Entry));
|
||||
index = PhpIndexFromHash(Hashtable, hashCode);
|
||||
previousIndex = -1;
|
||||
previousIndex = ULONG_MAX;
|
||||
|
||||
for (i = Hashtable->Buckets[index]; i != -1; i = entry->Next)
|
||||
for (i = Hashtable->Buckets[index]; i != ULONG_MAX; i = entry->Next)
|
||||
{
|
||||
entry = PH_HASHTABLE_GET_ENTRY(Hashtable, i);
|
||||
|
||||
if (entry->HashCode == hashCode && Hashtable->EqualFunction(&entry->Body, Entry))
|
||||
{
|
||||
// Unlink the entry from the bucket.
|
||||
if (previousIndex == -1)
|
||||
if (previousIndex == ULONG_MAX)
|
||||
{
|
||||
Hashtable->Buckets[index] = entry->Next;
|
||||
}
|
||||
@@ -4999,7 +4999,7 @@ BOOLEAN PhRemoveEntryHashtable(
|
||||
PH_HASHTABLE_GET_ENTRY(Hashtable, previousIndex)->Next = entry->Next;
|
||||
}
|
||||
|
||||
entry->HashCode = -1; // indicates the entry is not being used
|
||||
entry->HashCode = ULONG_MAX; // indicates the entry is not being used
|
||||
entry->Next = Hashtable->FreeEntry;
|
||||
Hashtable->FreeEntry = i;
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ typedef struct
|
||||
// ISecurityInformation
|
||||
|
||||
ISecurityInformation *PhSecurityInformation_Create(
|
||||
_In_ HWND WindowHandle,
|
||||
_In_opt_ HWND WindowHandle,
|
||||
_In_ PWSTR ObjectName,
|
||||
_In_ PWSTR ObjectType,
|
||||
_In_ PPH_OPEN_OBJECT OpenObject,
|
||||
|
||||
+7
-7
@@ -1519,7 +1519,7 @@ PPH_STRING PhFormatSize(
|
||||
// PhFormat handles this better than the old method.
|
||||
|
||||
format.Type = SizeFormatType | FormatUseRadix;
|
||||
format.Radix = (UCHAR)(MaxSizeUnit != -1 ? MaxSizeUnit : PhMaxSizeUnit);
|
||||
format.Radix = (UCHAR)(MaxSizeUnit != ULONG_MAX ? MaxSizeUnit : PhMaxSizeUnit);
|
||||
format.u.Size = Size;
|
||||
|
||||
return PhFormat(&format, 1, 0);
|
||||
@@ -2078,12 +2078,12 @@ NTSTATUS PhGetFullPathEx(
|
||||
if (filePart)
|
||||
{
|
||||
// The path points to a file.
|
||||
*IndexOfFileName = (ULONG)(filePart - fullPath->Buffer);
|
||||
*IndexOfFileName = PtrToUlong(PTR_SUB_OFFSET(filePart, fullPath->Buffer));
|
||||
}
|
||||
else
|
||||
{
|
||||
// The path points to a directory.
|
||||
*IndexOfFileName = -1;
|
||||
*IndexOfFileName = ULONG_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5167,7 +5167,7 @@ PPH_STRING PhCreateCacheFile(
|
||||
PPH_STRING cacheDirectory;
|
||||
PPH_STRING cacheFilePath;
|
||||
PPH_STRING cacheFullFilePath = NULL;
|
||||
ULONG indexOfFileName = -1;
|
||||
ULONG indexOfFileName = ULONG_MAX;
|
||||
WCHAR alphastring[16] = L"";
|
||||
|
||||
cacheDirectory = PhExpandEnvironmentStrings(&cacheDirectorySr);
|
||||
@@ -5186,7 +5186,7 @@ PPH_STRING PhCreateCacheFile(
|
||||
{
|
||||
PPH_STRING directoryPath;
|
||||
|
||||
if (indexOfFileName != -1 && (directoryPath = PhSubstring(cacheFullFilePath, 0, indexOfFileName)))
|
||||
if (indexOfFileName != ULONG_MAX && (directoryPath = PhSubstring(cacheFullFilePath, 0, indexOfFileName)))
|
||||
{
|
||||
PhCreateDirectory(directoryPath);
|
||||
PhDereferenceObject(directoryPath);
|
||||
@@ -5205,7 +5205,7 @@ VOID PhDeleteCacheFile(
|
||||
{
|
||||
PPH_STRING cacheDirectory;
|
||||
PPH_STRING cacheFullFilePath;
|
||||
ULONG indexOfFileName = -1;
|
||||
ULONG indexOfFileName = ULONG_MAX;
|
||||
|
||||
if (RtlDoesFileExists_U(PhGetString(FileName)))
|
||||
{
|
||||
@@ -5214,7 +5214,7 @@ VOID PhDeleteCacheFile(
|
||||
|
||||
if (cacheFullFilePath = PhGetFullPath(PhGetString(FileName), &indexOfFileName))
|
||||
{
|
||||
if (indexOfFileName != -1 && (cacheDirectory = PhSubstring(cacheFullFilePath, 0, indexOfFileName)))
|
||||
if (indexOfFileName != ULONG_MAX && (cacheDirectory = PhSubstring(cacheFullFilePath, 0, indexOfFileName)))
|
||||
{
|
||||
PhDeleteDirectory(cacheDirectory);
|
||||
PhDereferenceObject(cacheDirectory);
|
||||
|
||||
Reference in New Issue
Block a user