From: Derek Lesho Subject: Re: [PATCH 1/5] ntoskrnl.exe: Implement KeAreApcsDisabled using critical region functions. Message-Id: Date: Wed, 24 Apr 2019 10:41:09 -0400 In-Reply-To: <20190424223202.7ca4722d031cc2dd08d1e302@baikal.ru> References: <20190424142509.528-1-dereklesho52@Gmail.com> <20190424223202.7ca4722d031cc2dd08d1e302@baikal.ru> I thought about that, but since the only documented way to access it is from the current thread. On Wed, Apr 24, 2019 at 10:32 AM Dmitry Timoshkov wrote: > Derek Lesho wrote: > > > void WINAPI KeEnterCriticalRegion(void) > > { > > - FIXME(": stub\n"); > > + TRACE(": semi-stub\n"); > > + KeGetCurrentThread()->critical_region_count++; > > } > ... > > void WINAPI KeLeaveCriticalRegion(void) > > { > > - FIXME(": stub\n"); > > + TRACE(": semi-stub\n"); > > + KeGetCurrentThread()->critical_region_count--; > > } > ... > > +BOOLEAN WINAPI KeAreApcsDisabled(void) > > +{ > > + return !!KeGetCurrentThread()->critical_region_count; > > +} > > Shouldn't these APIs use interlocked operations? > > -- > Dmitry. >
I thought about that, but since the only documented way to access it is from the current thread.

On Wed, Apr 24, 2019 at 10:32 AM Dmitry Timoshkov <dmitry@baikal.ru> wrote:
Derek Lesho <dereklesho52@gmail.com> wrote:

>  void WINAPI KeEnterCriticalRegion(void)
>  {
> -    FIXME(": stub\n");
> +    TRACE(": semi-stub\n");
> +    KeGetCurrentThread()->critical_region_count++;
>  }
...
>  void WINAPI KeLeaveCriticalRegion(void)
>  {
> -    FIXME(": stub\n");
> +    TRACE(": semi-stub\n");
> +    KeGetCurrentThread()->critical_region_count--;
>  }
...
> +BOOLEAN WINAPI KeAreApcsDisabled(void)
> +{
> +    return !!KeGetCurrentThread()->critical_region_count;
> +}

Shouldn't these APIs use interlocked operations?

--
Dmitry.