- Fix coding style in some places.

svn path=/trunk/; revision=32524
This commit is contained in:
Aleksey Bragin 2008-02-28 14:05:47 +00:00
parent 01211c8fa1
commit a7fe55dbe5

View file

@ -160,6 +160,8 @@ Mmi386ReleaseMmInfo(PEPROCESS Process)
{ {
PUSHORT LdtDescriptor; PUSHORT LdtDescriptor;
ULONG LdtBase; ULONG LdtBase;
PULONG Pde;
PULONG PageDir;
ULONG i, j; ULONG i, j;
DPRINT("Mmi386ReleaseMmInfo(Process %x)\n",Process); DPRINT("Mmi386ReleaseMmInfo(Process %x)\n",Process);
@ -176,9 +178,6 @@ Mmi386ReleaseMmInfo(PEPROCESS Process)
ExFreePool((PVOID) LdtBase); ExFreePool((PVOID) LdtBase);
} }
PULONG Pde;
PULONG PageDir;
PageDir = MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase.u.LowPart)); PageDir = MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase.u.LowPart));
for (i = 0; i < ADDR_TO_PDE_OFFSET(MmSystemRangeStart); i++) for (i = 0; i < ADDR_TO_PDE_OFFSET(MmSystemRangeStart); i++)
{ {
@ -250,6 +249,7 @@ MmCreateProcessAddressSpace(IN ULONG MinWs,
NTSTATUS Status; NTSTATUS Status;
ULONG i, j; ULONG i, j;
PFN_TYPE Pfn[2]; PFN_TYPE Pfn[2];
PULONG PageDirectory;
DPRINT("MmCopyMmInfo(Src %x, Dest %x)\n", MinWs, Process); DPRINT("MmCopyMmInfo(Src %x, Dest %x)\n", MinWs, Process);
@ -267,7 +267,6 @@ MmCreateProcessAddressSpace(IN ULONG MinWs,
} }
} }
PULONG PageDirectory;
PageDirectory = MmCreateHyperspaceMapping(Pfn[0]); PageDirectory = MmCreateHyperspaceMapping(Pfn[0]);
memcpy(PageDirectory + ADDR_TO_PDE_OFFSET(MmSystemRangeStart), memcpy(PageDirectory + ADDR_TO_PDE_OFFSET(MmSystemRangeStart),
@ -317,6 +316,7 @@ MmFreePageTable(PEPROCESS Process, PVOID Address)
PEPROCESS CurrentProcess = PsGetCurrentProcess(); PEPROCESS CurrentProcess = PsGetCurrentProcess();
ULONG i; ULONG i;
PFN_TYPE Pfn; PFN_TYPE Pfn;
PULONG PageTable;
DPRINT("ProcessId %d, Address %x\n", Process->UniqueProcessId, Address); DPRINT("ProcessId %d, Address %x\n", Process->UniqueProcessId, Address);
if (Process != NULL && Process != CurrentProcess) if (Process != NULL && Process != CurrentProcess)
@ -324,7 +324,6 @@ MmFreePageTable(PEPROCESS Process, PVOID Address)
KeAttachProcess(&Process->Pcb); KeAttachProcess(&Process->Pcb);
} }
PULONG PageTable;
PageTable = (PULONG)PAGE_ROUND_DOWN((PVOID)ADDR_TO_PTE(Address)); PageTable = (PULONG)PAGE_ROUND_DOWN((PVOID)ADDR_TO_PTE(Address));
for (i = 0; i < 1024; i++) for (i = 0; i < 1024; i++)
{ {
@ -564,11 +563,11 @@ MmDeleteVirtualMapping(PEPROCESS Process, PVOID Address, BOOLEAN FreePage,
{ {
BOOLEAN WasValid = FALSE; BOOLEAN WasValid = FALSE;
PFN_TYPE Pfn; PFN_TYPE Pfn;
ULONG Pte;
PULONG Pt;
DPRINT("MmDeleteVirtualMapping(%x, %x, %d, %x, %x)\n", DPRINT("MmDeleteVirtualMapping(%x, %x, %d, %x, %x)\n",
Process, Address, FreePage, WasDirty, Page); Process, Address, FreePage, WasDirty, Page);
ULONG Pte;
PULONG Pt;
Pt = MmGetPageTableForProcess(Process, Address, FALSE); Pt = MmGetPageTableForProcess(Process, Address, FALSE);
@ -718,84 +717,85 @@ BOOLEAN
NTAPI NTAPI
MmIsAccessedAndResetAccessPage(PEPROCESS Process, PVOID Address) MmIsAccessedAndResetAccessPage(PEPROCESS Process, PVOID Address)
{ {
if (Address < MmSystemRangeStart && Process == NULL) PULONG Pt;
{ ULONG Pte;
DPRINT1("MmIsAccessedAndResetAccessPage is called for user space without a process.\n");
KEBUGCHECK(0);
}
PULONG Pt; if (Address < MmSystemRangeStart && Process == NULL)
ULONG Pte; {
DPRINT1("MmIsAccessedAndResetAccessPage is called for user space without a process.\n");
KEBUGCHECK(0);
}
Pt = MmGetPageTableForProcess(Process, Address, FALSE); Pt = MmGetPageTableForProcess(Process, Address, FALSE);
if (Pt == NULL) if (Pt == NULL)
{ {
KEBUGCHECK(0); KEBUGCHECK(0);
} }
do do
{ {
Pte = *Pt; Pte = *Pt;
} while (Pte != InterlockedCompareExchangeUL(Pt, Pte & ~PA_ACCESSED, Pte)); } while (Pte != InterlockedCompareExchangeUL(Pt, Pte & ~PA_ACCESSED, Pte));
if (Pte & PA_ACCESSED) if (Pte & PA_ACCESSED)
{ {
MiFlushTlb(Pt, Address); MiFlushTlb(Pt, Address);
return TRUE; return TRUE;
} }
else else
{ {
MmUnmapPageTable(Pt); MmUnmapPageTable(Pt);
return FALSE; return FALSE;
} }
} }
VOID VOID
NTAPI NTAPI
MmSetCleanPage(PEPROCESS Process, PVOID Address) MmSetCleanPage(PEPROCESS Process, PVOID Address)
{ {
if (Address < MmSystemRangeStart && Process == NULL) PULONG Pt;
{ ULONG Pte;
DPRINT1("MmSetCleanPage is called for user space without a process.\n");
KEBUGCHECK(0);
}
PULONG Pt; if (Address < MmSystemRangeStart && Process == NULL)
ULONG Pte; {
DPRINT1("MmSetCleanPage is called for user space without a process.\n");
KEBUGCHECK(0);
}
Pt = MmGetPageTableForProcess(Process, Address, FALSE); Pt = MmGetPageTableForProcess(Process, Address, FALSE);
if (Pt == NULL) if (Pt == NULL)
{ {
KEBUGCHECK(0); KEBUGCHECK(0);
} }
do do
{ {
Pte = *Pt; Pte = *Pt;
} while (Pte != InterlockedCompareExchangeUL(Pt, Pte & ~PA_DIRTY, Pte)); } while (Pte != InterlockedCompareExchangeUL(Pt, Pte & ~PA_DIRTY, Pte));
if (Pte & PA_DIRTY) if (Pte & PA_DIRTY)
{ {
MiFlushTlb(Pt, Address); MiFlushTlb(Pt, Address);
} }
else else
{ {
MmUnmapPageTable(Pt); MmUnmapPageTable(Pt);
} }
} }
VOID VOID
NTAPI NTAPI
MmSetDirtyPage(PEPROCESS Process, PVOID Address) MmSetDirtyPage(PEPROCESS Process, PVOID Address)
{ {
PULONG Pt;
ULONG Pte;
if (Address < MmSystemRangeStart && Process == NULL) if (Address < MmSystemRangeStart && Process == NULL)
{ {
DPRINT1("MmSetDirtyPage is called for user space without a process.\n"); DPRINT1("MmSetDirtyPage is called for user space without a process.\n");
KEBUGCHECK(0); KEBUGCHECK(0);
} }
PULONG Pt;
ULONG Pte;
Pt = MmGetPageTableForProcess(Process, Address, FALSE); Pt = MmGetPageTableForProcess(Process, Address, FALSE);
if (Pt == NULL) if (Pt == NULL)
@ -871,6 +871,8 @@ MmCreateVirtualMappingForKernel(PVOID Address,
ULONG i; ULONG i;
PVOID Addr; PVOID Addr;
ULONG PdeOffset, oldPdeOffset; ULONG PdeOffset, oldPdeOffset;
PULONG Pt;
ULONG Pte;
BOOLEAN NoExecute = FALSE; BOOLEAN NoExecute = FALSE;
DPRINT("MmCreateVirtualMappingForKernel(%x, %x, %x, %d)\n", DPRINT("MmCreateVirtualMappingForKernel(%x, %x, %x, %d)\n",
@ -895,9 +897,6 @@ MmCreateVirtualMappingForKernel(PVOID Address,
Addr = Address; Addr = Address;
PULONG Pt;
ULONG Pte;
oldPdeOffset = ADDR_TO_PDE_OFFSET(Addr); oldPdeOffset = ADDR_TO_PDE_OFFSET(Addr);
Pt = MmGetPageTableForProcess(NULL, Addr, TRUE); Pt = MmGetPageTableForProcess(NULL, Addr, TRUE);
if (Pt == NULL) if (Pt == NULL)
@ -948,6 +947,9 @@ MmCreatePageFileMapping(PEPROCESS Process,
PVOID Address, PVOID Address,
SWAPENTRY SwapEntry) SWAPENTRY SwapEntry)
{ {
PULONG Pt;
ULONG Pte;
if (Process == NULL && Address < MmSystemRangeStart) if (Process == NULL && Address < MmSystemRangeStart)
{ {
DPRINT1("No process\n"); DPRINT1("No process\n");
@ -963,9 +965,6 @@ MmCreatePageFileMapping(PEPROCESS Process,
KEBUGCHECK(0); KEBUGCHECK(0);
} }
PULONG Pt;
ULONG Pte;
Pt = MmGetPageTableForProcess(Process, Address, TRUE); Pt = MmGetPageTableForProcess(Process, Address, TRUE);
if (Pt == NULL) if (Pt == NULL)
{ {
@ -1013,6 +1012,8 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process,
PVOID Addr; PVOID Addr;
ULONG i; ULONG i;
ULONG oldPdeOffset, PdeOffset; ULONG oldPdeOffset, PdeOffset;
PULONG Pt = NULL;
ULONG Pte;
BOOLEAN NoExecute = FALSE; BOOLEAN NoExecute = FALSE;
DPRINT("MmCreateVirtualMappingUnsafe(%x, %x, %x, %x (%x), %d)\n", DPRINT("MmCreateVirtualMappingUnsafe(%x, %x, %x, %x (%x), %d)\n",
@ -1068,9 +1069,6 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process,
} }
Addr = Address; Addr = Address;
PULONG Pt = NULL;
ULONG Pte;
oldPdeOffset = ADDR_TO_PDE_OFFSET(Addr) + 1; oldPdeOffset = ADDR_TO_PDE_OFFSET(Addr) + 1;
for (i = 0; i < PageCount; i++, Addr = (PVOID)((ULONG_PTR)Addr + PAGE_SIZE)) for (i = 0; i < PageCount; i++, Addr = (PVOID)((ULONG_PTR)Addr + PAGE_SIZE))
{ {
@ -1208,6 +1206,7 @@ MmSetPageProtect(PEPROCESS Process, PVOID Address, ULONG flProtect)
{ {
ULONG Attributes = 0; ULONG Attributes = 0;
BOOLEAN NoExecute = FALSE; BOOLEAN NoExecute = FALSE;
PULONG Pt;
DPRINT("MmSetPageProtect(Process %x Address %x flProtect %x)\n", DPRINT("MmSetPageProtect(Process %x Address %x flProtect %x)\n",
Process, Address, flProtect); Process, Address, flProtect);
@ -1230,7 +1229,6 @@ MmSetPageProtect(PEPROCESS Process, PVOID Address, ULONG flProtect)
{ {
Attributes |= PA_USER; Attributes |= PA_USER;
} }
PULONG Pt;
Pt = MmGetPageTableForProcess(Process, Address, FALSE); Pt = MmGetPageTableForProcess(Process, Address, FALSE);
if (Pt == NULL) if (Pt == NULL)
@ -1251,9 +1249,9 @@ MmGetPhysicalAddress(PVOID vaddr)
*/ */
{ {
PHYSICAL_ADDRESS p; PHYSICAL_ADDRESS p;
ULONG Pte;
DPRINT("MmGetPhysicalAddress(vaddr %x)\n", vaddr); DPRINT("MmGetPhysicalAddress(vaddr %x)\n", vaddr);
ULONG Pte;
Pte = MmGetPageEntryForProcess(NULL, vaddr); Pte = MmGetPageEntryForProcess(NULL, vaddr);
if (Pte != 0 && Pte & PA_PRESENT) if (Pte != 0 && Pte & PA_PRESENT)
{ {
@ -1338,9 +1336,10 @@ NTAPI
MmChangeHyperspaceMapping(PVOID Address, PFN_TYPE NewPage) MmChangeHyperspaceMapping(PVOID Address, PFN_TYPE NewPage)
{ {
PFN_TYPE Pfn; PFN_TYPE Pfn;
ULONG Entry;
ASSERT (IS_HYPERSPACE(Address)); ASSERT (IS_HYPERSPACE(Address));
ULONG Entry;
Entry = InterlockedExchange((PLONG)ADDR_TO_PTE(Address), PFN_TO_PTE(NewPage) | PA_PRESENT | PA_READWRITE); Entry = InterlockedExchange((PLONG)ADDR_TO_PTE(Address), PFN_TO_PTE(NewPage) | PA_PRESENT | PA_READWRITE);
Pfn = PTE_TO_PFN(Entry); Pfn = PTE_TO_PFN(Entry);
@ -1353,9 +1352,10 @@ NTAPI
MmDeleteHyperspaceMapping(PVOID Address) MmDeleteHyperspaceMapping(PVOID Address)
{ {
PFN_TYPE Pfn; PFN_TYPE Pfn;
ULONG Entry;
ASSERT (IS_HYPERSPACE(Address)); ASSERT (IS_HYPERSPACE(Address));
ULONG Entry;
Entry = InterlockedExchange((PLONG)ADDR_TO_PTE(Address), 0); Entry = InterlockedExchange((PLONG)ADDR_TO_PTE(Address), 0);
Pfn = PTE_TO_PFN(Entry); Pfn = PTE_TO_PFN(Entry);
@ -1368,13 +1368,13 @@ NTAPI
MmUpdatePageDir(PEPROCESS Process, PVOID Address, ULONG Size) MmUpdatePageDir(PEPROCESS Process, PVOID Address, ULONG Size)
{ {
ULONG StartOffset, EndOffset, Offset; ULONG StartOffset, EndOffset, Offset;
PULONG Pde;
if (Address < MmSystemRangeStart) if (Address < MmSystemRangeStart)
{ {
KEBUGCHECK(0); KEBUGCHECK(0);
} }
PULONG Pde;
StartOffset = ADDR_TO_PDE_OFFSET(Address); StartOffset = ADDR_TO_PDE_OFFSET(Address);
EndOffset = ADDR_TO_PDE_OFFSET((PVOID)((ULONG_PTR)Address + Size)); EndOffset = ADDR_TO_PDE_OFFSET((PVOID)((ULONG_PTR)Address + Size));
@ -1405,10 +1405,10 @@ NTAPI
MmInitGlobalKernelPageDirectory(VOID) MmInitGlobalKernelPageDirectory(VOID)
{ {
ULONG i; ULONG i;
PULONG CurrentPageDirectory = (PULONG)PAGEDIRECTORY_MAP;
DPRINT("MmInitGlobalKernelPageDirectory()\n"); DPRINT("MmInitGlobalKernelPageDirectory()\n");
PULONG CurrentPageDirectory = (PULONG)PAGEDIRECTORY_MAP;
for (i = ADDR_TO_PDE_OFFSET(MmSystemRangeStart); i < 1024; i++) for (i = ADDR_TO_PDE_OFFSET(MmSystemRangeStart); i < 1024; i++)
{ {
if (i != ADDR_TO_PDE_OFFSET(PAGETABLE_MAP) && if (i != ADDR_TO_PDE_OFFSET(PAGETABLE_MAP) &&