Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTFSD
Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


I don't understand ExAcquireResourceExclusiveLite

Frank_FriemelFrank_Friemel Member Posts: 308
Hello,

I have a simple question about "ExAcquireResourceExclusiveLite".
I have the following code (that of course makes no sense and is for testing
only):

//------------------------------

BOOLEAN b;

b = ExAcquireResourceExclusiveLite( &Resource, FALSE );
b = ExAcquireResourceExclusiveLite( &Resource, FALSE );
.
.
.
if (b) ExReleaseResourceLite(&Resource);
.
.
.

//------------------------------

Two calls of "ExAcquireResourceExclusiveLite" and both return always
"TRUE"!!! Shouldn't the second call return "FALSE" ???

Besides: When I try to use "ExTryToAcquireResourceExclusiveLite" the Linker
can't find it!!!

Thanks in advance!
Frank Friemel

Comments

  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    1.ExTryToAcquireResourceExclusiveLite doesn't exist - NTIFS.H contains
    prototype of non-exising routine.
    But ExAcquireResourceExclusiveLite(..., FALSE) does requested
    functionality.

    2. Resources can be acquired recursively. But for every acquire there must
    be corresponding release.
    If the resource is already acquired exclusively for some thread - every
    next acquire shared/exclsuive
    will be done successfully withou waiting - and exclusive access will be
    granted.

    WARNING:
    Trying to acquire resource exclusive (Wait=TRUE) in context of some
    thread where corresponding resource
    ia already acquired shared is programmer's error.

    Paul

    > -----P?vodn? zpr?va-----
    > Od: Frank Friemel [SMTP:[email protected]]
    > Odesl?no: 27. dubna 2000 12:43
    > Komu: File Systems Developers
    > P?edm?t: [ntfsd] I don't understand ExAcquireResourceExclusiveLite
    >
    > Hello,
    >
    > I have a simple question about "ExAcquireResourceExclusiveLite".
    > I have the following code (that of course makes no sense and is for
    > testing
    > only):
    >
    > //------------------------------
    >
    > BOOLEAN b;
    >
    > b = ExAcquireResourceExclusiveLite( &Resource, FALSE );
    > b = ExAcquireResourceExclusiveLite( &Resource, FALSE );
    > .
    > .
    > .
    > if (b) ExReleaseResourceLite(&Resource);
    > .
    > .
    > .
    >
    > //------------------------------
    >
    > Two calls of "ExAcquireResourceExclusiveLite" and both return always
    > "TRUE"!!! Shouldn't the second call return "FALSE" ???
    >
    > Besides: When I try to use "ExTryToAcquireResourceExclusiveLite" the
    > Linker
    > can't find it!!!
    >
    > Thanks in advance!
    > Frank Friemel
    >
    > ---
    > You are currently subscribed to ntfsd as: [email protected]
    > To unsubscribe send a blank email to $subst('Email.Unsub')
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    From what I understand of ERESOURCE is that it has the concept of "owning
    thread". That means that a resources is acquired (or owned) by a thread. If
    a thread has acquired a ERESOURCE exclusively, and tries to acquire it again
    (exclusive OR shared), it will still have exclusive access.

    On the other hand, if *another* thread tries to acquire the resource, it
    will be failed, or put to wait state (depending on Wait parameter).

    In your code it looks like the same thread is trying to acquire the resource
    again, and hence succeeds.

    If you note, that is where ExReleaseResourceForThreadLite() comes from, and
    not just ExReleaseResource().

    Also, you must release them as many times as you acquired them.

    Hope that helps.
    Shweta.

    Hello,

    I have a simple question about "ExAcquireResourceExclusiveLite".
    I have the following code (that of course makes no sense and is for testing
    only):

    file://------------------------------

    BOOLEAN b;

    b = ExAcquireResourceExclusiveLite( &Resource, FALSE );
    b = ExAcquireResourceExclusiveLite( &Resource, FALSE );
    .
    .
    .
    if (b) ExReleaseResourceLite(&Resource);
    .
    .
    .

    file://------------------------------

    Two calls of "ExAcquireResourceExclusiveLite" and both return always
    "TRUE"!!! Shouldn't the second call return "FALSE" ???

    Besides: When I try to use "ExTryToAcquireResourceExclusiveLite" the Linker
    can't find it!!!

    Thanks in advance!
    Frank Friemel

    ---
    You are currently subscribed to ntfsd as: [email protected]
    To unsubscribe send a blank email to $subst('Email.Unsub')

    ______________________________________________
    FREE Personalized Email at Mail.com
    Sign up at http://www.mail.com/?sr=signup
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Writing WDF Drivers 7 Dec 2020 LIVE ONLINE
Internals & Software Drivers 25 Jan 2021 LIVE ONLINE
Developing Minifilters 8 March 2021 LIVE ONLINE