Jérôme Gardou
4c5351bf55
[NTOS/MM]
...
- Fix PFNs tracing
- Add private pages to the process working set
2020-10-20 15:20:59 +02:00
Jérôme Gardou
5abc016401
[NTOS/MM] Initialize process Working set and start implementing adding entries to it
2020-10-20 15:20:59 +02:00
Thomas Faber
6b3f309a08
[NTOS] Consistently use MUTANT_INCREMENT.
...
Spotted by Hermès.
2020-10-16 16:09:54 +02:00
Thomas Faber
ba9bf73d48
[NTOS:MM] Acquire PsLoadedModuleResource when walking PsLoadedModuleList. CORE-16449
2020-10-15 14:49:20 +02:00
Thomas Faber
a30edc324e
[NTOS:MM] Acquire MmSystemLoadLock in MiFindInitializationCode. CORE-16449
...
We might otherwise free the INIT section for an image that's in the
process of being loaded by Mm.
2020-10-15 14:49:11 +02:00
Thomas Faber
ef1c726621
[NTOS:MM] Print debugging information in case CORE-16449 happens.
2020-10-08 08:59:46 +02:00
Thomas Faber
e57a59a60a
[NTOS:MM] Fail on SizeOfRawData overflow. CORE-17284
...
Fixes the corresponding tests in ntdll_apitest:NtMapViewOfSection.
Also add a TODO for the remaining test failures.
2020-10-03 13:20:25 +02:00
Thomas Faber
b957af4b6b
[NTOS:MM] VirtualSize overrides SizeOfRawData when mapping PE files. CORE-17284
...
This fixes the related failures in ntdll_apitest:NtMapViewOfSection
as well as loading of OrgPlayer's DragDrop.ocx.
2020-10-03 13:13:35 +02:00
Timo Kreuzer
3d17a7590d
[NTOS:MM] Fix paged pool initialization on x64
2020-10-01 11:24:42 +02:00
Victor Perevertkin
d01518da7c
[XDK] Add definitions required for newer storage class drivers (cdrom)
...
That introduced some warnings in the current code which were corrected as well
CORE-17129
2020-09-24 22:30:52 +03:00
Timo Kreuzer
896d090ee6
[NTOS:MM] Call MiSessionAddProcess() from MmCreateProcess() like on x86
2020-09-20 23:08:17 +02:00
Timo Kreuzer
bebcda0b0b
[NTOS:MM] In the x64 version of MmCreateProcessAddressSpace() zero out all page table PFNs
2020-09-20 23:08:17 +02:00
Serge Gautherie
a72b78558d
[NTOS:MM] MiGetPageTableForProcess(): #if out unreachable code
...
No impact.
Detected by Cppcheck: unreachableCode.
Addendum to ddaf47dec3
(r34976).
2020-06-25 21:59:02 +02:00
Serge Gautherie
ceccaae311
[NTOS:MM] MmDeleteProcessAddressSpace(): Move 'Address' to where it belongs ( #2865 )
...
No impact.
Detected by Cppcheck: unusedVariable.
Addendum to 2dade10d54
.
2020-06-01 12:10:11 +03:00
Serge Gautherie
b20f815126
[NTOSKRNL] Place INIT_FUNCTION before the return type ( #2823 )
...
(but after 'static' or SAL 2 annotation.)
Follow-up to 71fefa32
, which mentions that it's actually required by the compiler in some circumstances.
2020-05-23 15:56:10 +02:00
Hervé Poussineau
033102fdb1
[NTOS] Add a #define __ROS_ROSSYM__ when using rossym
...
Use it where needed.
2020-04-09 23:00:57 +02:00
Vadim Galyant
3c585d0e38
[NTOS:MM] Since the _MMPTE_SUBSECTION structure for x86 (without PAE) uses the SubsectionAddressLow truncated by the least significant three bits, the _CONTROL_AREA, _LARGE_CONTROL_AREA, _SUBSECTION, _MSUBSECTION structures must be 8-byte aligned.
...
Corresponding checks in MmArmInitSystem() have been removed.
2020-04-06 11:16:34 +02:00
Thomas Faber
5032a40d33
[NTOS:MM] In MmArmInitSystem, perform self-tests after per-arch initialization.
...
Mm(Non)PagedPoolStart won't be initialized otherwise, making the tests
pretty pointless.
2020-04-06 11:16:34 +02:00
Thomas Faber
74a2c6ba42
[NTOS:MM] Initialize MmSubsectionBase on x86 builds. CORE-16731
...
Spotted by Vadim Galyant.
2020-04-06 11:16:34 +02:00
Thomas Faber
25a5aee86f
[NTOS:MM] Get rid of unnecessary MmZeroingPageThreadActive.
2020-04-06 11:13:55 +02:00
Thomas Faber
5280deecfa
[NTOS:MM] Fix MmZeroingPageThreadActive race condition.
...
If a thread calls MiInsertPageInFreeList after the zero page thread has
woken up from its wait but before it acquired the PFN lock,
MmZeroingPageEvent might get set again even though there is no additional
work to be done.
By setting MmZeroingPageThreadActive together with the event, the variable
correctly indicates for future callers that the zero thread will process
newly added free pages.
This partially reverts r72990.
2020-04-06 11:13:55 +02:00
Vadim Galyant
ac843d7b82
[NTOS:MM] Make the definitions and macros for x86 more human-readable. ( #2487 )
...
- Move also PDE_MAPPED_VA definition from common miarm.h to ..arch/mm.h.
- Add assert "PAE not yet implemented".
2020-04-04 14:26:15 +02:00
Vadim Galyant
b78cb36d91
[NTOS:MM] Using the macro MiIsPteOnPdeBoundary(). ( #2496 )
...
The SYSTEM_PD_SIZE constant should not be used to determine the page boundary for page tables. It is better to use the portable MiIsPteOnPdeBoundary() macro for this.
2020-04-02 12:15:33 +02:00
Thomas Faber
6831468ccf
[NTOS:MM] Assert PFN lock ownership in MiInsertPageInFreeList.
...
AMD64 initialization previously only raised the IRQL.
It now acquires the lock where needed, as i386 does.
2020-03-02 20:50:54 +01:00
Thomas Faber
754e175d12
[NTOS:MM] Use MI_ZERO_PTES as the number of usable zeroing PTEs, not the total allocated. CORE-11856
...
We'll now have 32 usable zeroing PTEs instead of 31.
MP kernels will (some day) zero up to 32 pages at a time.
2020-02-22 12:33:54 +01:00
Thomas Faber
feb7275bc8
[NTOS:MM] Use POOL_BILLED_PROCESS_INVALID constant.
2020-02-08 13:00:32 +01:00
Serge Gautherie
2c6747aff0
[NTOS:MM] Stop using PD_COUNT, PDE_COUNT and PTE_COUNT ( #2294 )
...
Directly use PPE_PER_PAGE, PDE_PER_PAGE, PTE_PER_PAGE constants from hardware-specific MM headers instead
2020-02-05 23:48:26 +01:00
Timo Kreuzer
7523a7b138
[NTOS:KE] Rename some locking functions to reflect the IRQL level changes
...
* KiAcquireApcLock -> KiAcquireApcLockRaiseToSynch
* KiAcquireApcLockAtDpcLevel -> KiAcquireApcLockAtSynchLevel
* KiReleaseApcLockFromDpcLevel -> KiReleaseApcLockFromSynchLevel
* KiAcquireApcLockAtApcLevel -> KiAcquireApcLockRaiseToDpc
* KiAcquireProcessLock -> KiAcquireProcessLockRaiseToSynch
* KiReleaseProcessLockFromDpcLevel -> KiReleaseProcessLockFromSynchLevel
* KiAcquireDispatcherLockAtDpcLevel -> KiAcquireDispatcherLockAtSynchLevel
* KiReleaseDispatcherLockFromDpcLevel -> KiReleaseDispatcherLockFromSynchLevel
* Add some ASSERTs
2019-12-31 15:30:27 +01:00
Timo Kreuzer
21647e2c4e
[NTOS] Revert pool debugging code
...
Revert "[NTOS] On DBG builds, fill pool allocations with 0xCD and freed pool with 0xDD"
This reverts commit 24f240be8a
.
Revert "[NTOS] Add compile time option to trace callers of pool allocations"
This reverts commit 8b20755040
.
Revert "WIP"
This reverts commit 8cfd5c601f
.
2019-11-25 19:32:06 +01:00
Timo Kreuzer
8cfd5c601f
WIP
2019-11-24 18:26:19 +01:00
Timo Kreuzer
8b20755040
[NTOS] Add compile time option to trace callers of pool allocations
2019-11-24 18:26:19 +01:00
Timo Kreuzer
24f240be8a
[NTOS] On DBG builds, fill pool allocations with 0xCD and freed pool with 0xDD
...
This matches what the MSVC runtime does with heap allocations on debug builds.
2019-11-24 18:26:19 +01:00
Hermès Bélusca-Maïto
ea6d427d10
[I8042PRT] Remove dead commented-out code; Allow sending ROS-specific commands to the kernel debugger since KD64 also support them.
...
[NTOS:MM] Remove an extra ')' in a DbgPrint() string.
2019-11-17 23:21:55 +01:00
Hermès Bélusca-Maïto
7e941247bd
[MM:AMD64] Remove the _WINKD_ around MmDebugPte since it's now used by both kd64 (windbg) and KDBG through the usage of mmdbg.c
2019-11-03 23:46:54 +01:00
Hermès Bélusca-Maïto
f5e86c0fd3
[NTOS] Just go ahead and allow printing all the printable ASCII characters in ExpTagAllowPrint().
...
As documented in https://docs.microsoft.com/fr-fr/windows-hardware/drivers/ddi/wdm/nf-wdm-exallocatepoolwithtag
pool tag "characters" must be a value in the range 0x20 (space) to 0x7E (tilde),
which happen indeed to be the range of printable (non-extended) ASCII characters.
(The display problem was originally caught while attempting to display
the pool tag 0x3a306847 corresponding to 'Gh0:', a win32ss GDIOBJ pool tag
encoded with macro GDIOBJ_POOL_TAG().)
2019-11-01 19:09:29 +01:00
Stanislav Motylkov
9bf672d4f1
[NTOS:MM] Add debug print to MiAllocateContiguousMemory in out-of-memory case
2019-10-27 06:32:50 +01:00
Timo Kreuzer
56da95671c
[NTOS] Fix a bug in the PE loader, which caused images to be loaded up to MmHighestUserAddress, thus overwriting the shared user page.
...
This is now fixed by using MM_HIGHEST_VAD_ADDRESS as the margin instead.
Should fix CORE-11717
2019-10-26 21:38:13 +02:00
Pierre Schweitzer
3b78ca210e
[NTOSKRNL] Simplify buffer definition in MiQueryMemorySectionName().
...
Also take into account the UNICODE_STRING structure while computing whole size
This is based on Thomas' patch.
CORE-12043
2019-09-29 14:16:44 +02:00
Timo Kreuzer
41250d1028
[NTOS:MM] Fix MmspCompareSegments
...
On x64 the previous implementation would only compare the upper 32 bits and ignore the lower 32 bits.
2019-09-01 14:15:07 +02:00
Serge Gautherie
66bf74d228
[NTOSKRNL] Move DPRINT1("Thread wants too much stack\n") around
...
To KiUserModeCallout() from MmGrowKernelStackEx().
As suggested by Thomas Faber:
"MmGrowKernelStackEx really shouldn't be DPRINT'ing."
CORE-14494
2019-08-15 18:18:59 +02:00
Timo Kreuzer
de679e8f33
[NTOS:MM] MmSizeOfSystemCacheInPages is ULONG_PTR, not ULONG
...
Fixes failed assertion on x64.
2019-08-15 18:04:57 +02:00
Timo Kreuzer
7611cc2b12
[REACTOS] Fix SIZE_T related warnings
2019-08-15 14:20:00 +02:00
Hermès Bélusca-Maïto
3625238ecb
[NTOS:MM] Add a MmChangeKernelResourceSectionProtection() helper. ( #1649 )
...
This allows setting the memory protection of the kernel's resource
section as will. MmMakeKernelResourceSectionWritable() is re-implemented
around this helper.
2019-07-14 22:23:49 +02:00
Serge Gautherie
ccf8bff3ec
[NTOS:MM] Fix MmGetFileNameForAddress() callers. ( #1723 )
...
MmGetFileNameForAddress() calls RtlCreateUnicodeString().
This also fixes a leak in MiQueryMemorySectionName().
2019-07-14 00:32:23 +02:00
Serge Gautherie
6ba611f39e
[NTOS:MM] Fix MmSizeOfSystemCacheInPages value on AMD64
...
And add 'ASSERT(MmSystemCacheEnd == ...);'.
Addendum to d56a249089
.
CORE-14259
2019-07-06 09:55:38 +02:00
Hermès Bélusca-Maïto
05616105a5
[NTOS:MM] Fix MiLocateKernelSections() and MmMakeKernelResourceSectionWritable().
...
- MiLocateKernelSections(): Fix the calculation of MiKernelResourceEndPte,
MmPoolCodeEnd and MmPteCodeEnd.
- MmMakeKernelResourceSectionWritable(): Fix PTE looping upper limit;
use MI_MAKE_HARDWARE_PTE_KERNEL to build the updated read-write PTE.
2019-06-26 00:57:53 +02:00
Hermès Bélusca-Maïto
f694d12f0c
[NTOS:KE/MM] Some bug-fixes in the bugcheck code.
...
- Introduce the MmMakeKernelResourceSectionWritable() helper for
making the kernel resource memory section writable, and use it
in KeGetBugMessageText(). Indeed, this latter function patches
in place the bugcheck resource message to trim any trailing
newlines before displaying the message on screen.
See also https://github.com/osresearch/uxen/blob/83bad53/dm/introspection-win7.c#L286
that mentions it too.
This fixes bugcheck text display (e.g. the MANUALLY_INITIATED_CRASH one)
when using (at least) MSVC-built ReactOS, avoiding a Page-Fault
exception during the bugcheck.
- Cover KeGetBugMessageText() in SEH since we are accessing kernel
resources that could also be corrupted in bugcheck scenarii, and we
don't want to further bugcheck.
- Fix newline trimming loop.
- KiDoBugCheckCallbacks():
* Wrap the bugcheck CallbackRoutine call in SEH.
* Add a FIXME concerning the need of further memory validation of CurrentRecord.
- Add a FIXME concerning the need to run the bugcheck-reason callbacks
with the KbCallbackReserved1 reason, in KeBugCheckWithTf().
Mentioned in http://blog.ptsecurity.com/2012/06/customizing-blue-screen-of-death.html
2019-06-25 21:01:49 +02:00
Serge Gautherie
cf27695269
[NTOS:MM] PeFmtCreateSection(): Improve AMD64 image failure case
...
Addendum to 98638cc2df
.
CORE-15981
2019-06-04 18:22:19 +02:00
Mark Jansen
98638cc2df
[NTOS/MM] Recognize AMD64 image in PeFmtCreateSection failure case
2019-05-15 19:39:56 +02:00
Thomas Faber
f3a280f52b
[NTOS] Use correct buffer size when calling MiResolveImageReferences. CORE-15882
2019-05-05 10:39:11 +02:00