mirror of
https://github.com/reactos/reactos.git
synced 2025-07-27 15:22:23 +00:00
[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
This commit is contained in:
parent
6097ae49f8
commit
ce4ac4fb98
10 changed files with 34 additions and 28 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -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])
|
||||||
|
|
|
@ -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;
|
||||||
|
|
6
reactos/ntoskrnl/cache/section/sptab.c
vendored
6
reactos/ntoskrnl/cache/section/sptab.c
vendored
|
@ -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",
|
||||||
|
@ -215,7 +215,7 @@ _MmSetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
|
||||||
ASSERT(!Entry || IS_SWAP_FROM_SSE(Entry));
|
ASSERT(!Entry || IS_SWAP_FROM_SSE(Entry));
|
||||||
MmDeleteSectionAssociation(PFN_FROM_SSE(OldEntry));
|
MmDeleteSectionAssociation(PFN_FROM_SSE(OldEntry));
|
||||||
} else if (IS_SWAP_FROM_SSE(Entry)) {
|
} 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);
|
SWAPENTRY_FROM_SSE(OldEntry) == MM_WAIT_ENTRY);
|
||||||
if (OldEntry && SWAPENTRY_FROM_SSE(OldEntry) != MM_WAIT_ENTRY)
|
if (OldEntry && SWAPENTRY_FROM_SSE(OldEntry) != MM_WAIT_ENTRY)
|
||||||
MmDeleteSectionAssociation(PFN_FROM_SSE(OldEntry));
|
MmDeleteSectionAssociation(PFN_FROM_SSE(OldEntry));
|
||||||
|
@ -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
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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++;
|
||||||
}
|
}
|
||||||
|
@ -409,7 +414,7 @@ FsRtlDoesNameContainWildCards(IN PUNICODE_STRING Name)
|
||||||
*
|
*
|
||||||
* @param Expression
|
* @param Expression
|
||||||
* The string in which we've to find Name. It can contain wildcards.
|
* 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
|
* @param Name
|
||||||
* The string to find. It cannot contain wildcards
|
* The string to find. It cannot contain wildcards
|
||||||
|
@ -419,7 +424,7 @@ FsRtlDoesNameContainWildCards(IN PUNICODE_STRING Name)
|
||||||
*
|
*
|
||||||
* @param UpcaseTable
|
* @param UpcaseTable
|
||||||
* If not NULL, and if IgnoreCase is set to TRUE, it will be used to
|
* 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
|
* @return TRUE if Name is in Expression, FALSE otherwise
|
||||||
*
|
*
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1049,7 +1049,7 @@ MiMapViewInSystemSpace(IN PVOID Section,
|
||||||
MiDereferenceControlArea(ControlArea);
|
MiDereferenceControlArea(ControlArea);
|
||||||
return STATUS_NO_MEMORY;
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* What's the underlying session? */
|
/* What's the underlying session? */
|
||||||
if (Session == &MmSession)
|
if (Session == &MmSession)
|
||||||
{
|
{
|
||||||
|
@ -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;
|
||||||
|
|
|
@ -1385,7 +1385,7 @@ MiFreeInitializationCode(IN PVOID InitStart,
|
||||||
|
|
||||||
/* Compute the number of pages we expect to free */
|
/* Compute the number of pages we expect to free */
|
||||||
PagesFreed = (PFN_NUMBER)(MiAddressToPte(InitEnd) - PointerPte + 1);
|
PagesFreed = (PFN_NUMBER)(MiAddressToPte(InitEnd) - PointerPte + 1);
|
||||||
|
|
||||||
/* Try to actually free them */
|
/* Try to actually free them */
|
||||||
PagesFreed = MiDeleteSystemPageableVm(PointerPte,
|
PagesFreed = MiDeleteSystemPageableVm(PointerPte,
|
||||||
PagesFreed,
|
PagesFreed,
|
||||||
|
@ -1406,7 +1406,7 @@ MiFindInitializationCode(OUT PVOID *StartVa,
|
||||||
PIMAGE_NT_HEADERS NtHeader;
|
PIMAGE_NT_HEADERS NtHeader;
|
||||||
PIMAGE_SECTION_HEADER Section, LastSection;
|
PIMAGE_SECTION_HEADER Section, LastSection;
|
||||||
BOOLEAN InitFound;
|
BOOLEAN InitFound;
|
||||||
|
|
||||||
/* So we don't free our own code yet */
|
/* So we don't free our own code yet */
|
||||||
InitCode = (ULONG_PTR)&MiFindInitializationCode;
|
InitCode = (ULONG_PTR)&MiFindInitializationCode;
|
||||||
|
|
||||||
|
@ -1423,7 +1423,7 @@ MiFindInitializationCode(OUT PVOID *StartVa,
|
||||||
/* Get the loader entry and its DLL base */
|
/* Get the loader entry and its DLL base */
|
||||||
LdrEntry = CONTAINING_RECORD(NextEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
|
LdrEntry = CONTAINING_RECORD(NextEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
|
||||||
DllBase = (ULONG_PTR)LdrEntry->DllBase;
|
DllBase = (ULONG_PTR)LdrEntry->DllBase;
|
||||||
|
|
||||||
/* Get the NT header */
|
/* Get the NT header */
|
||||||
NtHeader = RtlImageNtHeader((PVOID)DllBase);
|
NtHeader = RtlImageNtHeader((PVOID)DllBase);
|
||||||
if (!NtHeader)
|
if (!NtHeader)
|
||||||
|
@ -1454,13 +1454,13 @@ MiFindInitializationCode(OUT PVOID *StartVa,
|
||||||
{
|
{
|
||||||
/* Pick the biggest size -- either raw or virtual */
|
/* Pick the biggest size -- either raw or virtual */
|
||||||
Size = max(Section->SizeOfRawData, Section->Misc.VirtualSize);
|
Size = max(Section->SizeOfRawData, Section->Misc.VirtualSize);
|
||||||
|
|
||||||
/* Read the section alignment */
|
/* Read the section alignment */
|
||||||
Alignment = NtHeader->OptionalHeader.SectionAlignment;
|
Alignment = NtHeader->OptionalHeader.SectionAlignment;
|
||||||
|
|
||||||
/* Align the start and end addresses appropriately */
|
/* Align the start and end addresses appropriately */
|
||||||
InitStart = DllBase + Section->VirtualAddress;
|
InitStart = DllBase + Section->VirtualAddress;
|
||||||
InitEnd = ((Alignment + InitStart + Size - 2) & 0xFFFFF000) - 1;
|
InitEnd = ((Alignment + InitStart + Size - 2) & 0xFFFFF000) - 1;
|
||||||
InitStart = (InitStart + (PAGE_SIZE - 1)) & 0xFFFFF000;
|
InitStart = (InitStart + (PAGE_SIZE - 1)) & 0xFFFFF000;
|
||||||
|
|
||||||
/* Have we reached the last section? */
|
/* Have we reached the last section? */
|
||||||
|
@ -1532,12 +1532,12 @@ MiFindInitializationCode(OUT PVOID *StartVa,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move to the next section */
|
/* Move to the next section */
|
||||||
SectionCount--;
|
SectionCount--;
|
||||||
Section++;
|
Section++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move to the next module */
|
/* Move to the next module */
|
||||||
NextEntry = NextEntry->Flink;
|
NextEntry = NextEntry->Flink;
|
||||||
}
|
}
|
||||||
|
@ -1546,7 +1546,7 @@ MiFindInitializationCode(OUT PVOID *StartVa,
|
||||||
KeLeaveCriticalRegion();
|
KeLeaveCriticalRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note: This function assumes that all discardable sections are at the end of
|
* 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
|
* the PE file. It searches backwards until it finds the non-discardable section
|
||||||
*/
|
*/
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue