[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:
@@ -113,7 +113,9 @@ struct X_KTHREAD {
|
||||
uint8_t unk_8B; // 0x8B
|
||||
uint8_t unk_8C[0x10]; // 0x8C
|
||||
xe::be<uint32_t> unk_9C; // 0x9C
|
||||
uint8_t unk_A0[0x1C]; // 0xA0
|
||||
uint8_t unk_A0[0x10]; // 0xA0
|
||||
int32_t apc_disable_count; // 0xB0
|
||||
uint8_t unk_B4[0x8]; // 0xB4
|
||||
uint8_t suspend_count; // 0xBC
|
||||
uint8_t unk_BD; // 0xBD
|
||||
uint8_t unk_BE; // 0xBE
|
||||
@@ -192,8 +194,8 @@ class XThread : public XObject, public cpu::Thread {
|
||||
|
||||
virtual void Reenter(uint32_t address);
|
||||
|
||||
static void EnterCriticalRegion();
|
||||
static void LeaveCriticalRegion();
|
||||
void EnterCriticalRegion();
|
||||
void LeaveCriticalRegion();
|
||||
uint32_t RaiseIrql(uint32_t new_irql);
|
||||
void LowerIrql(uint32_t new_irql);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user