From: Derek Lesho Subject: Re: [PATCH 1/5] ntoskrnl.exe: Implement KeAreApcsDisabled using critical region functions. Message-Id: Date: Wed, 24 Apr 2019 10:45:56 -0400 In-Reply-To: References: <20190424142509.528-1-dereklesho52@Gmail.com> <20190424223202.7ca4722d031cc2dd08d1e302@baikal.ru> *but since the only documented way to access it is from the current thread, I thought it was unnecessary. On Wed, Apr 24, 2019 at 10:41 AM Derek Lesho wrote: > 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. >> >
*but since the only documented way to access it is from the current thread, I thought it was unnecessary.

On Wed, Apr 24, 2019 at 10:41 AM Derek Lesho <dereklesho52@gmail.com> wrote:
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.