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:
maksw committed 2026-10-12 18:17:43 +02:00
1 parent 899225f551
commit c0ad63c27f
226 files changed
+6562 -4147

No files matched your search

+9 -9
View File
@@ -1,5 +1,6 @@
// Object manager. This file owns reference-counted kernel objects and their terminal lifetime transitions.
#include <ntlite/atomic.h>
#include <stdbool.h>
#include <string.h>
#include <intrin.h>
@@ -26,7 +27,6 @@ static uint32_t KiObjectPoolTag(OBJECT_TYPE type) {
case ObjectTypeUsbPipe: return MM_POOL_TAG('u', 's', 'b', 'p');
case ObjectTypeFileMapping: return MM_POOL_TAG('m', 'a', 'p', 'f');
case ObjectTypeSurface: return MM_POOL_TAG('s', 'u', 'r', 'f');
case ObjectTypeInputQueue: return MM_POOL_TAG('i', 'n', 'p', 'q');
case ObjectTypeImageSection: return MM_POOL_TAG('i', 'm', 's', 'e');
case ObjectTypeTimer: return MM_POOL_TAG('t', 'm', 'r', ' ');
case ObjectTypeDisplayClock: return MM_POOL_TAG('d', 'c', 'l', 'k');
@@ -73,16 +73,16 @@ __declspec(dllexport) bool ObTryReferenceObject(OBJECT* object) {
return false;
while (true) {
if (_InterlockedCompareExchange(&object->LifetimeState, 0, 0) != ObjectAlive)
if (NtlAtomicLoad32(&object->LifetimeState) != ObjectAlive)
return false;
if ((_InterlockedCompareExchange(&object->Flags, 0, 0) & OBJECT_FLAG_INSERTED) == 0)
if ((NtlAtomicLoadU32(&object->Flags) & OBJECT_FLAG_INSERTED) == 0)
return false;
long refs = _InterlockedCompareExchange(&object->RefCount, 0, 0);
int32_t refs = NtlAtomicLoad32(&object->RefCount);
if (refs <= 0 || refs == 0x7fffffffL)
return false;
if (_InterlockedCompareExchange(&object->RefCount, refs + 1, refs) == refs)
if (NtlAtomicCompareExchange32(&object->RefCount, refs + 1, refs) == refs)
return true;
}
}
@@ -108,7 +108,7 @@ __declspec(dllexport) void ObDereferenceObject(OBJECT* object) {
if (!object)
return;
long refs = _InterlockedDecrement(&object->RefCount);
int32_t refs = NtlAtomicDecrement32(&object->RefCount);
if (refs > 0)
return;
if (refs < 0) {
@@ -121,7 +121,7 @@ __declspec(dllexport) void ObDereferenceObject(OBJECT* object) {
(unsigned)object->Flags);
}
if (_InterlockedCompareExchange(&object->LifetimeState, ObjectDying, ObjectAlive) != ObjectAlive) {
if (NtlAtomicCompareExchange32(&object->LifetimeState, ObjectDying, ObjectAlive) != ObjectAlive) {
KePanic(KE_PANIC_CODE_GENERIC,
"object: duplicate terminal transition object=0x%016llX type=%u state=%ld flags=0x%08x\n",
(uint64_t)(uintptr_t)object,
@@ -130,10 +130,10 @@ __declspec(dllexport) void ObDereferenceObject(OBJECT* object) {
(unsigned)object->Flags);
}
_InterlockedExchange(&object->Flags, OBJECT_FLAG_UNLINKED);
NtlAtomicExchangeU32(&object->Flags, OBJECT_FLAG_UNLINKED);
if (object->Destroy)
object->Destroy(object);
_InterlockedExchange(&object->LifetimeState, ObjectDead);
NtlAtomicExchange32(&object->LifetimeState, ObjectDead);
MmFreePool(object);
}