[Kernel] Make KeEnter/LeaveCriticalRegion only affect the caller thread

Adds a new X_KTHREAD::apc_disable_count field at 0xB0 into X_KTHREAD based on where 360 kernel seems to store it, and made CriticalRegion funcs act on that, instead of locking things between all threads, and changes DeliverAPCs to check that field before running the APCs.

XThread::LockApc/UnlockApc were also updated too as those previously called into EnterCrit/LeaveCrit to work, but AFAIK the code that uses LockApc/UnlockApc does have an actual need for locking between threads, so changed them to work on XThread::global_critical_region_ directly instead.
This commit is contained in:
emoose
2021-05-24 04:01:35 +01:00
committed by Rick Gibbed
parent 0d3ef65dcd
commit 052ce3d389
3 changed files with 19 additions and 12 deletions

View File

@@ -960,14 +960,14 @@ void KeReleaseSpinLockFromRaisedIrql(lpdword_t lock_ptr) {
DECLARE_XBOXKRNL_EXPORT2(KeReleaseSpinLockFromRaisedIrql, kThreading,
kImplemented, kHighFrequency);
void KeEnterCriticalRegion() { XThread::EnterCriticalRegion(); }
void KeEnterCriticalRegion() {
XThread::GetCurrentThread()->EnterCriticalRegion();
}
DECLARE_XBOXKRNL_EXPORT2(KeEnterCriticalRegion, kThreading, kImplemented,
kHighFrequency);
void KeLeaveCriticalRegion() {
XThread::LeaveCriticalRegion();
XThread::GetCurrentThread()->CheckApcs();
XThread::GetCurrentThread()->LeaveCriticalRegion();
}
DECLARE_XBOXKRNL_EXPORT2(KeLeaveCriticalRegion, kThreading, kImplemented,
kHighFrequency);