Signed-off-by: Derek Lesho dereklesho52@Gmail.com --- dlls/ntoskrnl.exe/ntoskrnl.c | 16 ++++++++++++++-- dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 2 +- dlls/ntoskrnl.exe/ntoskrnl_private.h | 1 + include/ddk/ntddk.h | 1 + 4 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index 0ab150ea65..6bcd19c78f 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -2484,6 +2484,8 @@ static void *create_thread_object( HANDLE handle ) if (!NtQueryInformationThread( handle, ThreadBasicInformation, &info, sizeof(info), NULL )) thread->id = info.ClientId;
+ thread->critical_region_count = 0; + return thread; }
@@ -3382,7 +3384,8 @@ NTSTATUS WINAPI IoCsqInitialize(PIO_CSQ csq, PIO_CSQ_INSERT_IRP insert_irp, PIO_ */ void WINAPI KeEnterCriticalRegion(void) { - FIXME(": stub\n"); + TRACE(": semi-stub\n"); + KeGetCurrentThread()->critical_region_count++; }
/*********************************************************************** @@ -3390,7 +3393,8 @@ void WINAPI KeEnterCriticalRegion(void) */ void WINAPI KeLeaveCriticalRegion(void) { - FIXME(": stub\n"); + TRACE(": semi-stub\n"); + KeGetCurrentThread()->critical_region_count--; }
/*********************************************************************** @@ -4322,3 +4326,11 @@ ULONG WINAPI ExSetTimerResolution(ULONG time, BOOLEAN set_resolution) FIXME("stub: %u %d\n", time, set_resolution); return KeQueryTimeIncrement(); } + +/********************************************************************* + * KeAreApcsDisabled (NTOSKRNL.@) + */ +BOOLEAN WINAPI KeAreApcsDisabled(void) +{ + return !!KeGetCurrentThread()->critical_region_count; +} diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec index f965ff55ec..e485a04da1 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec +++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec @@ -521,7 +521,7 @@ @ stdcall KeAcquireSpinLockAtDpcLevel(ptr) @ stdcall -arch=arm,arm64,x86_64 KeAcquireSpinLockRaiseToDpc(ptr) @ stub KeAddSystemServiceTable -@ stub KeAreApcsDisabled +@ stdcall KeAreApcsDisabled() @ stub KeAttachProcess @ stub KeBugCheck @ stub KeBugCheckEx diff --git a/dlls/ntoskrnl.exe/ntoskrnl_private.h b/dlls/ntoskrnl.exe/ntoskrnl_private.h index f5a76284cb..19c287c151 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl_private.h +++ b/dlls/ntoskrnl.exe/ntoskrnl_private.h @@ -32,6 +32,7 @@ struct _KTHREAD { DISPATCHER_HEADER header; CLIENT_ID id; + unsigned int critical_region_count; };
void *alloc_kernel_object( POBJECT_TYPE type, HANDLE handle, SIZE_T size, LONG ref ) DECLSPEC_HIDDEN; diff --git a/include/ddk/ntddk.h b/include/ddk/ntddk.h index 719ba67c6a..f09f879032 100644 --- a/include/ddk/ntddk.h +++ b/include/ddk/ntddk.h @@ -213,6 +213,7 @@ NTSTATUS WINAPI IoQueryDeviceDescription(PINTERFACE_TYPE,PULONG,PCONFIGURATION_ PCONFIGURATION_TYPE,PULONG,PIO_QUERY_DEVICE_ROUTINE,PVOID); void WINAPI IoRegisterDriverReinitialization(PDRIVER_OBJECT,PDRIVER_REINITIALIZE,PVOID); NTSTATUS WINAPI IoRegisterShutdownNotification(PDEVICE_OBJECT); +BOOLEAN WINAPI KeAreApcsDisabled(void); NTSTATUS WINAPI KeExpandKernelStackAndCallout(PEXPAND_STACK_CALLOUT,void*,SIZE_T); void WINAPI KeSetTargetProcessorDpc(PRKDPC,CCHAR); BOOLEAN WINAPI MmIsAddressValid(void *);