ExAcquireResourceExclusiveLite and recurse

Can be ExAcquireResourceExclusiveLite called two (or more) times
from one thread before resource is released with
ExReleaseResourceForThreadLite?

Petr Balas (petr at petrbalas dot cz)

> Can be ExAcquireResourceExclusiveLite called two (or more) times

from one thread before resource is released with
ExReleaseResourceForThreadLite?

AFAIK yes - and you will need to release it twice too.

Max

Hi

> Can be ExAcquireResourceExclusiveLite called two (or more) times
> from one thread before resource is released with
> ExReleaseResourceForThreadLite?

AFAIK yes - and you will need to release it twice too.

O.K. it’s exactly what I need.

BTW:

  1. IOCTL call
  2. acquire mutex via KeWaitForMutexObject
  3. return from IOCTL
  4. BSOD

Anybody know why?

Petr

Petr Balas (petr at petrbalas dot cz)

> BTW:

  1. IOCTL call
  2. acquire mutex via KeWaitForMutexObject
  3. return from IOCTL
  4. BSOD

Anybody know why?

You must release mutex before returning to user mode. Use mutants if you
do not want this behaviour.

Max

Hi

> BTW:
> 1) IOCTL call
> 2) acquire mutex via KeWaitForMutexObject
> 3) return from IOCTL
> 4) BSOD
>
> Anybody know why?

You must release mutex before returning to user mode. Use mutants if you
do not want this behaviour.

How to create mutant from kernel mode?
Can mutants be acquired recursivelly?

Petr

> How to create mutant from kernel mode?

There is an undocumented NtCreateMutant call, but it’s better to use
CreateMutex from user mode.

Can mutants be acquired recursivelly?

Yes. This is what called “mutex” in user-mode Win32.

Max

Hi

> How to create mutant from kernel mode?

There is an undocumented NtCreateMutant call, but it’s better to use
CreateMutex from user mode.

Hmmmm.

> Can mutants be acquired recursivelly?

Yes. This is what called “mutex” in user-mode Win32.

O.K.

But at this moment I prefer to stay with resources:

Create:
ExInitializeResourceLite(&SerializeAccessResource);

Delete:
ExDeleteResourceLite(&SerializeAccessResource);

Acquire:
SerializeAccessOwningThread = ExGetCurrentResourceThread();
ExAcquireResourceExclusiveLite(&SerializeAccessResource, TRUE);

Release:
ExReleaseResourceForThreadLite(&SerializeAccessResource,
SerializeAccessOwningThread);

Petr

Petr Balas (petr at petrbalas dot cz)