Yes, it is wrong way. Even if you’re able to implement it somewhat (not sharing critical sections, that’s crazy), who prevents somebody else to open the device directly and ignore your synchronization?
The driver should synchronize access to the device. The simplest way is to make the device exclusive so only one app can open it. The more complex way is to allow apps to open the device concurrently but allow them to get exclusive access for some time. Using IOCTLs like “lock” and “unlock” and once one app has the device locked, requests from other apps are queued or returned with an error. Also, you can implement some automatic locking logic to protect your sequences if driver has a way how to identify them. Beware, in both cases you have to handle app crash/close handle and automatically unlock. This is an advantage of exclusive access; OS handles everything for you.
Michal
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-512293-
xxxxx@lists.osr.com] On Behalf Of xxxxx@clibb.de
Sent: Monday, September 03, 2012 7:59 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Critical Section between applications?
(first longer message seems to got lost…)
Hello,
i have a USB device, which driver is based on OSR USB FX2.
I have a DLL which contains Enter / LeaveCriticalSection
to secure my USB Read / Write Sequences.
This works ok. Even when i access the DLL with multiple threads.
Now i access my DLL from two applications.
(i see two DLL_PROCESS_ATTACH).
Can i still use Enter / LeaveCriticalSection to synchronize accesses
between the the applications?
I think i must use shared memory to have the variable for the CriticalSection
in both memory areas?
Or is this the wrong way? Must it e.g. be done completely in driver?
(e.g. by taking the request, but not calling CompletionRoutine)?
Can you give me a hint?
Many thanks!
Best regards,
Martin
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
NOTE: The information in this message is intended for the personal and confidential use of the designated recipient(s) named above. To the extent the recipient(s) is/are bound by a non-disclosure agreement, or other agreement that contains an obligation of confidentiality, with AuthenTec, then this message and/or any attachments shall be considered confidential information and subject to the confidentiality terms of that agreement. If the reader of this message is not the intended recipient named above, you are notified that you have received this document in error, and any review, dissemination, distribution or copying of this message is strictly prohibited. If you have received this document in error, please delete the original message and notify the sender immediately.
Thank You!
AuthenTec, Inc. http://www.authentec.com/