首页 > WinDriver > WD-独占设备和非独占设备的区别
2012七月22

WD-独占设备和非独占设备的区别

NTSTATUS 
  IoCreateDevice(
    IN PDRIVER_OBJECT  DriverObject,
    IN ULONG  DeviceExtensionSize,
    IN PUNICODE_STRING  DeviceName  OPTIONAL,
    IN DEVICE_TYPE  DeviceType,
    IN ULONG  DeviceCharacteristics,
    IN BOOLEAN  Exclusive,// TRUE为独占模式
    OUT PDEVICE_OBJECT  *DeviceObject
    );

test代码使用

	HANDLE hDevice = CreateFileA("\\.\DDKTest",//打开的是一个独占的驱动设备.
								GENERIC_READ,
								0,
								NULL,
								OPEN_EXISTING,
								FILE_ATTRIBUTE_NORMAL,
								NULL);
 
	if (INVALID_HANDLE_VALUE == hDevice)
	{
		printf("err:%dn",GetLastError());
	}
 
	// 未closehandle;
	system("pause");

加上closehandle,多次运行exe正常

意味着,独占模式时,每次只能有一个程序打开,如果它不close,其他的就不能访问.

文章作者:hgy413
本文地址:https://hgy413.com/99.html
版权所有 © 转载时必须以链接形式注明作者和原始出处!

9 Responses to “WD-独占设备和非独占设备的区别”

  1. #1 minecraft 回复 | 引用 Post:2018-10-03 21:02

    Good post. I’m dealing with some of these issues as well..

  2. #2 minecraft 回复 | 引用 Post:2018-10-06 23:16

    Very nice post. I just stumbled upon your blog and wished to say that I have truly enjoyed surfing around your blog posts.

    In any case I will be subscribing to your feed and I hope you write
    again soon!

  3. Great work! That is the kind of information that should be shared
    around the internet. Disgrace on Google for no longer positioning
    this put up upper! Come on over and discuss with my
    site . Thank you =)

  4. Simply wish to say your article is as surprising. The clearness on your submit is simply great and i can think you are knowledgeable
    on this subject. Fine with your permission let me to clutch your feed to keep up
    to date with approaching post. Thanks a million and
    please continue the gratifying work.

  5. Descargar facebook
    Wonderful site you have here but I was curious if you knew of any discussion boards that
    cover the same topics talked about here? I’d really
    like to be a part of community where I can get feedback from other experienced people that share the
    same interest. If you have any recommendations, please
    let me know. Thank you! Descargar facebook

  6. #6 descargar facebook 回复 | 引用 Post:2018-11-02 00:23

    Oh my goodness! Impressive article dude! Thanks, However I am encountering problems
    with your RSS. I don’t understand the reason why I am unable
    to join it. Is there anyone else getting the same RSS problems?
    Anyone that knows the answer can you kindly respond?

    Thanks!!

  7. #7 quest bars cheap 回复 | 引用 Post:2018-11-03 08:15

    Excellent beat ! I wish to apprentice while you amend your web site,
    how can i subscribe for a blog website? The account helped me a acceptable deal.
    I had been tiny bit acquainted of this your broadcast offered bright
    clear idea

  8. I for all time emailed this web site post page to all my contacts, for the reason that if like to read it next my friends will too.

  9. Awesome article.

发表评论