- 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
This commit is contained in:
Timo Kreuzer 2012-10-07 21:36:50 +00:00
parent 6097ae49f8
commit ce4ac4fb98
10 changed files with 34 additions and 28 deletions

View file

@ -38,7 +38,7 @@ RtlAreAnyAccessesGranted(IN ACCESS_MASK GrantedAccess,
PAGED_CODE_RTL(); PAGED_CODE_RTL();
/* Return if there's any leftover bits after granting all of them */ /* Return if there's any leftover bits after granting all of them */
return (GrantedAccess & DesiredAccess); return ((GrantedAccess & DesiredAccess) != 0);
} }
/* /*

View file

@ -222,7 +222,7 @@ RtlEqualPrefixSid(IN PSID Sid1_,
if (!Sid1->SubAuthorityCount) return TRUE; if (!Sid1->SubAuthorityCount) return TRUE;
/* Now compare all the subauthority values BUT the last one */ /* 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? */ /* Does any mismatch? */
if (Sid1->SubAuthority[i] != Sid2->SubAuthority[i]) if (Sid1->SubAuthority[i] != Sid2->SubAuthority[i])

View file

@ -194,7 +194,7 @@ _ui64tow_s( unsigned __int64 value, wchar_t *str,
*--pos = 'a' + digit - 10; *--pos = 'a' + digit - 10;
} while (value != 0); } while (value != 0);
if(buffer-pos+65 > size) { if((size_t)(buffer-pos+65) > size) {
MSVCRT_INVALID_PMT("str[size] is too small"); MSVCRT_INVALID_PMT("str[size] is too small");
#ifndef _LIBCNT_ #ifndef _LIBCNT_
*_errno() = EINVAL; *_errno() = EINVAL;

View file

@ -196,7 +196,7 @@ _MmSetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
ASSERT(MiSectionPageTableGet(&Segment->PageTable, Offset)); ASSERT(MiSectionPageTableGet(&Segment->PageTable, Offset));
PageTable->Segment = Segment; 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]; OldEntry = PageTable->PageEntries[PageIndex];
DPRINT("MiSetPageEntrySectionSegment(%p,%08x%08x,%x=>%x)\n", DPRINT("MiSetPageEntrySectionSegment(%p,%08x%08x,%x=>%x)\n",
@ -247,7 +247,7 @@ _MmGetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
ENTRIES_PER_ELEMENT * PAGE_SIZE); ENTRIES_PER_ELEMENT * PAGE_SIZE);
PageTable = MiSectionPageTableGet(&Segment->PageTable, &FileOffset); PageTable = MiSectionPageTableGet(&Segment->PageTable, &FileOffset);
if (!PageTable) return 0; 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]; Result = PageTable->PageEntries[PageIndex];
#if 0 #if 0
DPRINTC DPRINTC

View file

@ -280,7 +280,7 @@ NtQuerySystemEnvironmentValue(IN PUNICODE_STRING VariableName,
RtlInitAnsiString(&AValue, AnsiValueBuffer); RtlInitAnsiString(&AValue, AnsiValueBuffer);
/* Initialize a UNICODE string from the callers buffer */ /* Initialize a UNICODE string from the callers buffer */
RtlInitEmptyUnicodeString(&WValue, ValueBuffer, ValueBufferLength); RtlInitEmptyUnicodeString(&WValue, ValueBuffer, (USHORT)ValueBufferLength);
/* Convert the result to UNICODE */ /* Convert the result to UNICODE */
Status = RtlAnsiStringToUnicodeString(&WValue, &AValue, FALSE); Status = RtlAnsiStringToUnicodeString(&WValue, &AValue, FALSE);

View file

@ -27,6 +27,7 @@ FsRtlIsNameInExpressionPrivate(IN PUNICODE_STRING Expression,
PUSHORT BackTracking = NULL; PUSHORT BackTracking = NULL;
UNICODE_STRING IntExpression; UNICODE_STRING IntExpression;
USHORT ExpressionPosition = 0, NamePosition = 0, MatchingChars; USHORT ExpressionPosition = 0, NamePosition = 0, MatchingChars;
WCHAR CompareChar;
PAGED_CODE(); PAGED_CODE();
/* Check if we were given strings at all */ /* 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 */ /* 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++; NamePosition++;
ExpressionPosition++; ExpressionPosition++;
@ -118,7 +122,8 @@ FsRtlIsNameInExpressionPrivate(IN PUNICODE_STRING Expression,
else if (Expression->Buffer[ExpressionPosition] == L'*') else if (Expression->Buffer[ExpressionPosition] == L'*')
{ {
/* Skip contigous stars */ /* 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++; ExpressionPosition++;
} }

View file

@ -43,7 +43,7 @@ KSPIN_LOCK ExpTaggedPoolLock;
ULONG PoolHitTag; ULONG PoolHitTag;
BOOLEAN ExStopBadTags; BOOLEAN ExStopBadTags;
KSPIN_LOCK ExpLargePoolTableLock; KSPIN_LOCK ExpLargePoolTableLock;
LONG ExpPoolBigEntriesInUse; ULONG ExpPoolBigEntriesInUse;
ULONG ExpPoolFlags; ULONG ExpPoolFlags;
ULONG ExPoolFailures; ULONG ExPoolFailures;
@ -1246,10 +1246,10 @@ ExpAddTagForBigPages(IN PVOID Va,
// keep losing the race or that we are not finding a free entry anymore, // keep losing the race or that we are not finding a free entry anymore,
// which implies a massive number of concurrent big pool allocations. // which implies a massive number of concurrent big pool allocations.
// //
InterlockedIncrement(&ExpPoolBigEntriesInUse); InterlockedIncrementUL(&ExpPoolBigEntriesInUse);
if ((i >= 16) && (ExpPoolBigEntriesInUse > (TableSize / 4))) 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); ExpPoolBigEntriesInUse);
} }
@ -1348,7 +1348,7 @@ ExpFindAndRemoveTagBigPages(IN PVOID Va,
// the lock and return the tag that was located // the lock and return the tag that was located
// //
InterlockedIncrement((PLONG)&Entry->Va); InterlockedIncrement((PLONG)&Entry->Va);
InterlockedDecrement(&ExpPoolBigEntriesInUse); InterlockedDecrementUL(&ExpPoolBigEntriesInUse);
KeReleaseSpinLock(&ExpLargePoolTableLock, OldIrql); KeReleaseSpinLock(&ExpLargePoolTableLock, OldIrql);
return PoolTag; return PoolTag;
} }

View file

@ -2472,7 +2472,7 @@ MmCreateArm3Section(OUT PVOID *SectionObject,
ASSERT(ControlArea->u.Flags.WasPurged == FALSE); ASSERT(ControlArea->u.Flags.WasPurged == FALSE);
/* Make sure the segment and the section are the same size, or the section is smaller */ /* 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 */ /* Return the object and the creation status */
*SectionObject = (PVOID)NewSection; *SectionObject = (PVOID)NewSection;

View file

@ -2960,7 +2960,8 @@ LoaderScan:
0); 0);
if (!NT_SUCCESS(Status)) 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; goto Quickie;
} }

View file

@ -1744,7 +1744,7 @@ MiQueryMemoryBasicInformation(IN HANDLE ProcessHandle,
return Status; return Status;
} }
ULONG BOOLEAN
NTAPI NTAPI
MiIsEntireRangeCommitted(IN ULONG_PTR StartingAddress, MiIsEntireRangeCommitted(IN ULONG_PTR StartingAddress,
IN ULONG_PTR EndingAddress, IN ULONG_PTR EndingAddress,