clean up and standardize types across the codebase, unify atomic operations, improve UTF-8 handling throughout the system, remove obsolete input and named queue interfaces, redesign process preparation and creation, tighten IPC and service boundaries, improve error handling and reliability, minor documentation cleanup, fix doom surfaces, fix panic in ini parsing.
This commit is contained in:
1 parent
899225f551
commit
c0ad63c27f
226 files changed
+6562
-4147
No files matched your search
@@ -2,13 +2,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ntlite/atomic.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <intrin.h>
|
||||
#include <ntlite/ddk/irql.h>
|
||||
|
||||
// Legacy spinlock storage used by current driver-visible objects.
|
||||
typedef struct SPINLOCK {
|
||||
volatile long Locked;
|
||||
volatile int32_t Locked;
|
||||
} SPINLOCK;
|
||||
|
||||
#define SPINLOCK_INIT { 0 }
|
||||
@@ -43,7 +45,7 @@ static __forceinline uintptr_t KeAcquireSpinlock(SPINLOCK* sl) {
|
||||
if (oldIrql < DISPATCH_LEVEL)
|
||||
KeRaiseIrql(DISPATCH_LEVEL);
|
||||
|
||||
while (_InterlockedCompareExchange(&sl->Locked, 1, 0) != 0)
|
||||
while (NtlAtomicCompareExchange32(&sl->Locked, 1, 0) != 0)
|
||||
_mm_pause();
|
||||
|
||||
return KiPackSpinlockCookie(flags, oldIrql);
|
||||
@@ -54,7 +56,7 @@ static __forceinline void KeReleaseSpinlock(SPINLOCK* sl, uintptr_t cookie) {
|
||||
uintptr_t flags = KiSpinlockCookieFlags(cookie);
|
||||
KIRQL oldIrql = KiSpinlockCookieIrql(cookie);
|
||||
|
||||
_InterlockedExchange(&sl->Locked, 0);
|
||||
NtlAtomicExchange32(&sl->Locked, 0);
|
||||
|
||||
// Restore the caller's hardware interrupt state before dropping to an
|
||||
// IRQL that can dispatch APCs. PASSIVE_LEVEL with IF still clear is not a
|
||||
@@ -64,23 +66,23 @@ static __forceinline void KeReleaseSpinlock(SPINLOCK* sl, uintptr_t cookie) {
|
||||
}
|
||||
|
||||
// Attempts to acquire a spinlock without blocking.
|
||||
static __forceinline int KeTryAcquireSpinlock(SPINLOCK* sl, uintptr_t* outCookie) {
|
||||
static __forceinline bool KeTryAcquireSpinlock(SPINLOCK* sl, uintptr_t* outCookie) {
|
||||
uintptr_t flags = KeDisableInterrupts();
|
||||
|
||||
KIRQL oldIrql = KeGetCurrentIrql();
|
||||
if (oldIrql < DISPATCH_LEVEL)
|
||||
KeRaiseIrql(DISPATCH_LEVEL);
|
||||
|
||||
if (_InterlockedCompareExchange(&sl->Locked, 1, 0) == 0) {
|
||||
if (NtlAtomicCompareExchange32(&sl->Locked, 1, 0) == 0) {
|
||||
*outCookie = KiPackSpinlockCookie(flags, oldIrql);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Keep the failed-acquire unwind consistent with normal release: restore
|
||||
// IF before a PASSIVE transition can dispatch pending APCs.
|
||||
KeRestoreInterrupts(flags);
|
||||
KeLowerIrql(oldIrql);
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Acquires a spinlock for DPC-level code.
|
||||
|
||||
Reference in new issue
Block a user