From ce4ac4fb981c76022e31d91fd70a51bb67ff85c4 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 7 Oct 2012 21:36:50 +0000 Subject: [PATCH] [RTL] - Fix a bug in RtlAreAnyAccessesGranted - Fix an MSVC warning in RtlEqualPrefixSid [CRT] - Fix an MSVC warning in _ui64tow_s [NTOSKRNL] - DPRINT the filename when MmLoadSystemImage fails - Fix a few MSVC warnings svn path=/trunk/; revision=57518 --- reactos/lib/rtl/access.c | 2 +- reactos/lib/rtl/sid.c | 2 +- reactos/lib/sdk/crt/string/itow.c | 2 +- reactos/ntoskrnl/cache/section/sptab.c | 6 +++--- reactos/ntoskrnl/ex/sysinfo.c | 2 +- reactos/ntoskrnl/fsrtl/name.c | 15 ++++++++++----- reactos/ntoskrnl/mm/ARM3/expool.c | 8 ++++---- reactos/ntoskrnl/mm/ARM3/section.c | 4 ++-- reactos/ntoskrnl/mm/ARM3/sysldr.c | 19 ++++++++++--------- reactos/ntoskrnl/mm/ARM3/virtual.c | 2 +- 10 files changed, 34 insertions(+), 28 deletions(-) diff --git a/reactos/lib/rtl/access.c b/reactos/lib/rtl/access.c index acc0afa9212..8a808ecb9bf 100644 --- a/reactos/lib/rtl/access.c +++ b/reactos/lib/rtl/access.c @@ -38,7 +38,7 @@ RtlAreAnyAccessesGranted(IN ACCESS_MASK GrantedAccess, PAGED_CODE_RTL(); /* Return if there's any leftover bits after granting all of them */ - return (GrantedAccess & DesiredAccess); + return ((GrantedAccess & DesiredAccess) != 0); } /* diff --git a/reactos/lib/rtl/sid.c b/reactos/lib/rtl/sid.c index 39ddb9be2f5..8a6d5db6ba5 100644 --- a/reactos/lib/rtl/sid.c +++ b/reactos/lib/rtl/sid.c @@ -222,7 +222,7 @@ RtlEqualPrefixSid(IN PSID Sid1_, if (!Sid1->SubAuthorityCount) return TRUE; /* Now compare all the subauthority values BUT the last one */ - for (i = 0; i < (Sid1->SubAuthorityCount - 1); i++) + for (i = 0; (i + 1) < Sid1->SubAuthorityCount; i++) { /* Does any mismatch? */ if (Sid1->SubAuthority[i] != Sid2->SubAuthority[i]) diff --git a/reactos/lib/sdk/crt/string/itow.c b/reactos/lib/sdk/crt/string/itow.c index 19c9947dca3..c18b679665a 100644 --- a/reactos/lib/sdk/crt/string/itow.c +++ b/reactos/lib/sdk/crt/string/itow.c @@ -194,7 +194,7 @@ _ui64tow_s( unsigned __int64 value, wchar_t *str, *--pos = 'a' + digit - 10; } while (value != 0); - if(buffer-pos+65 > size) { + if((size_t)(buffer-pos+65) > size) { MSVCRT_INVALID_PMT("str[size] is too small"); #ifndef _LIBCNT_ *_errno() = EINVAL; diff --git a/reactos/ntoskrnl/cache/section/sptab.c b/reactos/ntoskrnl/cache/section/sptab.c index 4bdc8b75ff3..66ac8f277b2 100644 --- a/reactos/ntoskrnl/cache/section/sptab.c +++ b/reactos/ntoskrnl/cache/section/sptab.c @@ -196,7 +196,7 @@ _MmSetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment, ASSERT(MiSectionPageTableGet(&Segment->PageTable, Offset)); PageTable->Segment = Segment; - PageIndex = (Offset->QuadPart - PageTable->FileOffset.QuadPart) / PAGE_SIZE; + PageIndex = (ULONG_PTR)((Offset->QuadPart - PageTable->FileOffset.QuadPart) / PAGE_SIZE); OldEntry = PageTable->PageEntries[PageIndex]; DPRINT("MiSetPageEntrySectionSegment(%p,%08x%08x,%x=>%x)\n", @@ -215,7 +215,7 @@ _MmSetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment, ASSERT(!Entry || IS_SWAP_FROM_SSE(Entry)); MmDeleteSectionAssociation(PFN_FROM_SSE(OldEntry)); } else if (IS_SWAP_FROM_SSE(Entry)) { - ASSERT(!IS_SWAP_FROM_SSE(OldEntry) || + ASSERT(!IS_SWAP_FROM_SSE(OldEntry) || SWAPENTRY_FROM_SSE(OldEntry) == MM_WAIT_ENTRY); if (OldEntry && SWAPENTRY_FROM_SSE(OldEntry) != MM_WAIT_ENTRY) MmDeleteSectionAssociation(PFN_FROM_SSE(OldEntry)); @@ -247,7 +247,7 @@ _MmGetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment, ENTRIES_PER_ELEMENT * PAGE_SIZE); PageTable = MiSectionPageTableGet(&Segment->PageTable, &FileOffset); if (!PageTable) return 0; - PageIndex = (Offset->QuadPart - PageTable->FileOffset.QuadPart) / PAGE_SIZE; + PageIndex = (ULONG_PTR)((Offset->QuadPart - PageTable->FileOffset.QuadPart) / PAGE_SIZE); Result = PageTable->PageEntries[PageIndex]; #if 0 DPRINTC diff --git a/reactos/ntoskrnl/ex/sysinfo.c b/reactos/ntoskrnl/ex/sysinfo.c index 6b2b658258a..6fb5e257d4b 100644 --- a/reactos/ntoskrnl/ex/sysinfo.c +++ b/reactos/ntoskrnl/ex/sysinfo.c @@ -280,7 +280,7 @@ NtQuerySystemEnvironmentValue(IN PUNICODE_STRING VariableName, RtlInitAnsiString(&AValue, AnsiValueBuffer); /* Initialize a UNICODE string from the callers buffer */ - RtlInitEmptyUnicodeString(&WValue, ValueBuffer, ValueBufferLength); + RtlInitEmptyUnicodeString(&WValue, ValueBuffer, (USHORT)ValueBufferLength); /* Convert the result to UNICODE */ Status = RtlAnsiStringToUnicodeString(&WValue, &AValue, FALSE); diff --git a/reactos/ntoskrnl/fsrtl/name.c b/reactos/ntoskrnl/fsrtl/name.c index 45db5f1c387..f36b227f790 100644 --- a/reactos/ntoskrnl/fsrtl/name.c +++ b/reactos/ntoskrnl/fsrtl/name.c @@ -27,6 +27,7 @@ FsRtlIsNameInExpressionPrivate(IN PUNICODE_STRING Expression, PUSHORT BackTracking = NULL; UNICODE_STRING IntExpression; USHORT ExpressionPosition = 0, NamePosition = 0, MatchingChars; + WCHAR CompareChar; PAGED_CODE(); /* Check if we were given strings at all */ @@ -99,10 +100,13 @@ FsRtlIsNameInExpressionPrivate(IN PUNICODE_STRING Expression, } } - while (NamePosition < Name->Length / sizeof(WCHAR) && ExpressionPosition < Expression->Length / sizeof(WCHAR)) + while ((NamePosition < Name->Length / sizeof(WCHAR)) && + (ExpressionPosition < Expression->Length / sizeof(WCHAR))) { /* Basic check to test if chars are equal */ - if (Expression->Buffer[ExpressionPosition] == (IgnoreCase ? UpcaseTable[Name->Buffer[NamePosition]] : Name->Buffer[NamePosition])) + CompareChar = IgnoreCase ? UpcaseTable[Name->Buffer[NamePosition]] : + Name->Buffer[NamePosition]; + if (Expression->Buffer[ExpressionPosition] == CompareChar) { NamePosition++; ExpressionPosition++; @@ -118,7 +122,8 @@ FsRtlIsNameInExpressionPrivate(IN PUNICODE_STRING Expression, else if (Expression->Buffer[ExpressionPosition] == L'*') { /* Skip contigous stars */ - while (ExpressionPosition + 1 < Expression->Length / sizeof(WCHAR) && Expression->Buffer[ExpressionPosition + 1] == L'*') + while ((ExpressionPosition + 1 < (USHORT)(Expression->Length / sizeof(WCHAR))) && + (Expression->Buffer[ExpressionPosition + 1] == L'*')) { ExpressionPosition++; } @@ -409,7 +414,7 @@ FsRtlDoesNameContainWildCards(IN PUNICODE_STRING Name) * * @param Expression * The string in which we've to find Name. It can contain wildcards. - * If IgnoreCase is set to TRUE, this string MUST BE uppercase. + * If IgnoreCase is set to TRUE, this string MUST BE uppercase. * * @param Name * The string to find. It cannot contain wildcards @@ -419,7 +424,7 @@ FsRtlDoesNameContainWildCards(IN PUNICODE_STRING Name) * * @param UpcaseTable * If not NULL, and if IgnoreCase is set to TRUE, it will be used to - * upcase the both strings + * upcase the both strings * * @return TRUE if Name is in Expression, FALSE otherwise * diff --git a/reactos/ntoskrnl/mm/ARM3/expool.c b/reactos/ntoskrnl/mm/ARM3/expool.c index a5f081843e3..1f978f1e745 100644 --- a/reactos/ntoskrnl/mm/ARM3/expool.c +++ b/reactos/ntoskrnl/mm/ARM3/expool.c @@ -43,7 +43,7 @@ KSPIN_LOCK ExpTaggedPoolLock; ULONG PoolHitTag; BOOLEAN ExStopBadTags; KSPIN_LOCK ExpLargePoolTableLock; -LONG ExpPoolBigEntriesInUse; +ULONG ExpPoolBigEntriesInUse; ULONG ExpPoolFlags; ULONG ExPoolFailures; @@ -1246,10 +1246,10 @@ ExpAddTagForBigPages(IN PVOID Va, // keep losing the race or that we are not finding a free entry anymore, // which implies a massive number of concurrent big pool allocations. // - InterlockedIncrement(&ExpPoolBigEntriesInUse); + InterlockedIncrementUL(&ExpPoolBigEntriesInUse); if ((i >= 16) && (ExpPoolBigEntriesInUse > (TableSize / 4))) { - DPRINT1("Should attempt expansion since we now have %d entries\n", + DPRINT1("Should attempt expansion since we now have %lu entries\n", ExpPoolBigEntriesInUse); } @@ -1348,7 +1348,7 @@ ExpFindAndRemoveTagBigPages(IN PVOID Va, // the lock and return the tag that was located // InterlockedIncrement((PLONG)&Entry->Va); - InterlockedDecrement(&ExpPoolBigEntriesInUse); + InterlockedDecrementUL(&ExpPoolBigEntriesInUse); KeReleaseSpinLock(&ExpLargePoolTableLock, OldIrql); return PoolTag; } diff --git a/reactos/ntoskrnl/mm/ARM3/section.c b/reactos/ntoskrnl/mm/ARM3/section.c index befa6bae1df..5c10f2c4ce0 100644 --- a/reactos/ntoskrnl/mm/ARM3/section.c +++ b/reactos/ntoskrnl/mm/ARM3/section.c @@ -1049,7 +1049,7 @@ MiMapViewInSystemSpace(IN PVOID Section, MiDereferenceControlArea(ControlArea); return STATUS_NO_MEMORY; } - + /* What's the underlying session? */ if (Session == &MmSession) { @@ -2472,7 +2472,7 @@ MmCreateArm3Section(OUT PVOID *SectionObject, ASSERT(ControlArea->u.Flags.WasPurged == FALSE); /* Make sure the segment and the section are the same size, or the section is smaller */ - ASSERT(NewSection->SizeOfSection.QuadPart <= NewSection->Segment->SizeOfSegment); + ASSERT((ULONG64)NewSection->SizeOfSection.QuadPart <= NewSection->Segment->SizeOfSegment); /* Return the object and the creation status */ *SectionObject = (PVOID)NewSection; diff --git a/reactos/ntoskrnl/mm/ARM3/sysldr.c b/reactos/ntoskrnl/mm/ARM3/sysldr.c index 3f42163b590..59e37c1a80a 100644 --- a/reactos/ntoskrnl/mm/ARM3/sysldr.c +++ b/reactos/ntoskrnl/mm/ARM3/sysldr.c @@ -1385,7 +1385,7 @@ MiFreeInitializationCode(IN PVOID InitStart, /* Compute the number of pages we expect to free */ PagesFreed = (PFN_NUMBER)(MiAddressToPte(InitEnd) - PointerPte + 1); - + /* Try to actually free them */ PagesFreed = MiDeleteSystemPageableVm(PointerPte, PagesFreed, @@ -1406,7 +1406,7 @@ MiFindInitializationCode(OUT PVOID *StartVa, PIMAGE_NT_HEADERS NtHeader; PIMAGE_SECTION_HEADER Section, LastSection; BOOLEAN InitFound; - + /* So we don't free our own code yet */ InitCode = (ULONG_PTR)&MiFindInitializationCode; @@ -1423,7 +1423,7 @@ MiFindInitializationCode(OUT PVOID *StartVa, /* Get the loader entry and its DLL base */ LdrEntry = CONTAINING_RECORD(NextEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); DllBase = (ULONG_PTR)LdrEntry->DllBase; - + /* Get the NT header */ NtHeader = RtlImageNtHeader((PVOID)DllBase); if (!NtHeader) @@ -1454,13 +1454,13 @@ MiFindInitializationCode(OUT PVOID *StartVa, { /* Pick the biggest size -- either raw or virtual */ Size = max(Section->SizeOfRawData, Section->Misc.VirtualSize); - + /* Read the section alignment */ Alignment = NtHeader->OptionalHeader.SectionAlignment; /* Align the start and end addresses appropriately */ InitStart = DllBase + Section->VirtualAddress; - InitEnd = ((Alignment + InitStart + Size - 2) & 0xFFFFF000) - 1; + InitEnd = ((Alignment + InitStart + Size - 2) & 0xFFFFF000) - 1; InitStart = (InitStart + (PAGE_SIZE - 1)) & 0xFFFFF000; /* Have we reached the last section? */ @@ -1532,12 +1532,12 @@ MiFindInitializationCode(OUT PVOID *StartVa, } } } - + /* Move to the next section */ SectionCount--; Section++; } - + /* Move to the next module */ NextEntry = NextEntry->Flink; } @@ -1546,7 +1546,7 @@ MiFindInitializationCode(OUT PVOID *StartVa, KeLeaveCriticalRegion(); } -/* +/* * Note: This function assumes that all discardable sections are at the end of * the PE file. It searches backwards until it finds the non-discardable section */ @@ -2960,7 +2960,8 @@ LoaderScan: 0); if (!NT_SUCCESS(Status)) { - DPRINT1("ZwOpenFile failed with status 0x%x\n", Status); + DPRINT1("ZwOpenFile failed for '%wZ' with status 0x%x\n", + FileName, Status); goto Quickie; } diff --git a/reactos/ntoskrnl/mm/ARM3/virtual.c b/reactos/ntoskrnl/mm/ARM3/virtual.c index 3e248ad4ba9..65f2701e173 100644 --- a/reactos/ntoskrnl/mm/ARM3/virtual.c +++ b/reactos/ntoskrnl/mm/ARM3/virtual.c @@ -1744,7 +1744,7 @@ MiQueryMemoryBasicInformation(IN HANDLE ProcessHandle, return Status; } -ULONG +BOOLEAN NTAPI MiIsEntireRangeCommitted(IN ULONG_PTR StartingAddress, IN ULONG_PTR EndingAddress,