»áÔ±£º ÃÜÂ룺 ¡¡Ãâ·Ñ×¢²á | Íü¼ÇÃÜÂë | »áÔ±µÇ¼ ÍøÒ³¹¦ÄÜ£º ¼ÓÈëÊÕ²Ø ÉèΪÊ×Ò³ ÍøÕ¾ËÑË÷  
 °²È«¼¼Êõ¼¼ÊõÎĵµ
  ¡¤ °²È«ÅäÖÆ
  ¡¤ ¹¤¾ß½éÉÜ
  ¡¤ ºÚ¿Í½Ìѧ
  ¡¤ ·À»ðǽ
  ¡¤ Â©¶´·ÖÎö
  ¡¤ ÆƽâרÌâ
  ¡¤ ºÚ¿Í±à³Ì
  ¡¤ ÈëÇÖ¼ì²â
 °²È«¼¼ÊõÂÛ̳
  ¡¤ °²È«ÅäÖÆ
  ¡¤ ¹¤¾ß½éÉÜ
  ¡¤ ·À»ðǽ
  ¡¤ ºÚ¿ÍÈëÇÖ
  ¡¤ Â©¶´¼ì²â
  ¡¤ Æƽⷽ·¨
  ¡¤ É±¶¾×¨Çø
 °²È«¼¼Êõ¹¤¾ßÏÂÔØ
  ¡¤ É¨Ã蹤¾ß
  ¡¤ ¹¥»÷³ÌÐò
  ¡¤ ºóÃÅľÂí
  ¡¤ ¾Ü¾ø·þÎñ
  ¡¤ ¿ÚÁîÆƽâ
  ¡¤ ´úÀí³ÌÐò
  ¡¤ ·À»ðǽ
  ¡¤ ¼ÓÃܽâÃÜ
  ¡¤ ÈëÇÖ¼ì²â
  ¡¤ ¹¥·ÀÑÝʾ
°²È«·ÀÏß > °²È«ÅäÖÆ
Windows 2000Çý¶¯³ÌÐòµÄÉè¼Æ
·¢±íÈÕÆÚ£º2003-07-03 00:00:00×÷ÕߣºÌ ³ö´¦£º  

---- ±¾ÎĽéÉÜÁËWindows 2000 WDMÇý¶¯³ÌÐò½á¹¹¼°Æä±àдµÄ×¢ÒâÊÂÏ×îºó¸ø³öÁËÒ»¸ö¼òµ¥µÄWDMÇý¶¯³ÌÐò¼°¿Í»§¶Ë³ÌÐòµÄÔ´Âë(Zip,24KB)£¬Ï£ÍûÄܶԴó¼ÒÓÐËù°ïÖú¡£

---- 1. ¼ò½é£º

---- Windows 2000Ô­ÃûWindows NT 5.0ÊǼÌWindows NT 4.0µÄÐÂÒ»´ú²Ù×÷ϵͳ£¬Ëü²»µ«¼Ì³ÐÁËWindows NT 4.0µÄÖÖÖÖÓŵ㣬¶øÇÒÔÚ¼¼ÊõÉÏÓÖÓÐÁËÐí¶àµÄÍ»ÆÆ£¬ÆäÖÐÒ»Ïî¾ÍÊǶÔÇý¶¯³ÌÐò½á¹¹µÄ±ä»¯£¬¼´ÒýÈëÁËȫеÄWDM (Win32 Driver Model)µÄÇý¶¯³ÌÐò¹¹¼Ü¡£ËµÊÇм¼Êõ£¬ÆäʵÔçÔÚ1997ÄêMicrosoft¾ÍÌá³öÁ˸ÃÏî¼¼Êõ²¢ÔÚWindows 98Öеõ½Á˳ä·ÖµÄÓ¦Ó㬻»¾ä»°Ëµ£¬Windows 98Ò²Ö§³ÖWDM¡£ÕâÑùWDM¾Í³ÉΪÁËÒ»¸ö¿çƽ̨µÄÇý¶¯³ÌÐòÄ£ÐÍ£¬²»½öÈç´ËWDMÇý¶¯³ÌÐò»¹¿ÉÒÔÔÚ²»ÐÞ¸ÄÔ´´úÂëµÄÇé¿öϾ­¹ýÖØбàÒëºóÔÚ·ÇIntelƽ̨ÉÏÔËÐУ¬¿ÉÒÔ²»¿äÕŵĽ²WDMËãµÃÉÏÊÇ21ÊÀ¼ÍµÄÇý¶¯³ÌÐò¹¹¼Ü¡£

---- 2£®WDMµÄ¹¤×÷Ô­Àí£º

---- WDMÊÇÔÚNT 4.0Çý¶¯³ÌÐò½á¹¹ÉÏ·¢Õ¹ÆðÀ´µÄ£¬ËùÒÔËüÓëNT 4.0µÄÇý¶¯³ÌÐò¼«ÎªÏàËÆ£¬µ«ÊÇËüÈ´ÓÐÁ˱¾ÖÊÉϵÄÌá¸ß£¬±ÈÈçËüÖ§³ÖUSB¡¢IEEE 1394¡¢ACPIµÈȫеÄÓ²¼þ±ê×¼¡£ËäÈ»Windows 98ÓëWindows 2000¶¼Ö§³ÖWDM£¬¿ÉÊDz¢²»Òâζ×ÅWindows 98ϵÄVxD¿ÉÒÔÔÚWindows 2000ÏÂÔËÐУ¬¶øNTϵÄVDDÈ´¿ÉÒÔÔÚWindows 98ÏÂÔËÐС£²»¹ýÔ­ÏÈ×¼±¸ÔÚÁ½¸öƽ̨ÉÏͬʱÔËÐÐÐèÒª±àдÁ½¸ö½ØÈ»²»Í¬µÄÇý¶¯³ÌÐò£¬¶øÏÖÔÚÖ»ÐèÒª±àдһ¸öWDMÇý¶¯³ÌÐò¾Í¿ÉÒÔÁË¡£Í¬NT 4.0Çý¶¯³ÌÐòÒ»Ñù£¬WDMÇý¶¯³ÌÐòÒ²ÊÇ·Ö²ãµÄ£¬¼´²»Í¬²ãÉϵÄÇý¶¯³ÌÐòÓÐ×Ų»Í¬µÄÓÅÏÈȨ£¬¶øWindows 9xϵÄVxDÔòûÓд˽ṹ¡£ÁíÍ⣬WDM»¹ÒýÈëÁ˹¦ÄÜÉ豸¶ÔÏóFDO£¨functional device object£©ÓëÎïÀíÉ豸¶ÔÏóPDO£¨physical device object£©Á½¸öиÅÄîÀ´ÃèÊöÓ²¼þ£¬Ò»¸öPDO´ú±íÒ»¸öÕæʵӲ¼þ£¬ÔÚÇý¶¯³ÌÐò¿´À´ÔòÊÇÒ»¸öFDO£¬¼ûͼ1¡£ÁíÍâÖµµÃ×¢ÒâµÄÊÇ£¬Ò»¸öÓ²¼þÖ»ÔÊÐíÓÐÒ»¸öPDO£¬µ«È´¿ÉÒÔÓµÓжà¸öFDO£¬¶øÔÚÇý¶¯³ÌÐòÖÐÎÒÃDz»ÊÇÖ±½Ó²Ù×÷Ó²¼þ¶øÊDzÙ×÷ÏàÓ¦µÄPDOÓëFDO¡£ÔÚRing-3ÓëRing-0ͨѶ·½Ã棬²Ù×÷ϵͳΪÿһ¸öÓû§ÇëÇó´ò°ü³ÉÒ»¸öIRP£¨IO Request Packet£©½á¹¹£¬½«Æä·¢ËÍÖÁÇý¶¯³ÌÐò²¢Í¨¹ýʶ±ðIRPÖеÄPDOÀ´Ê¶±ðÊÇ·¢Ë͸øÄÄÒ»¸öÉ豸µÄ¡£ÁíÍ⣬ÔÚÇý¶¯³ÌÐòµÄ¼ÓÔØ·½ÃæWDM¼È²»¿¿Çý¶¯³ÌÐòÃû³ÆÒ²²»¿¿Ò»¸ö¾ßÓÐijÖÖÌØÊâÒâÒåµÄID£¬¶øÊÇÒÀ¿¿Ò»¸ö128λµÄGUIDÀ´Ê¶±ðÇý¶¯³ÌÐò£¨WindowsÏÂÐí¶à¶«Î÷¶¼ÊÇ¿¿´Ë½øÐÐʶ±ðµÄ£©¡£

---- 3£®¾ßÌåʵÏÖ£º

---- ͬÐí¶àÓ¦ÓóÌÐòÒ»Ñù£¬WDMÇý¶¯³ÌÐòÊÇPE¸ñʽµÄ£¬µ«ÊÇËüȴûÓÐWinMain»òmainÕâÑùµÄÈë¿Ú£¬È¡¶ø´úÖ®µÄÊÇDriverEntry£º

NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject,  

  //²»Í¬ÓÚÇ°ÃæµÄPDO

           

IN PUNICODE_STRING RegistryPath)

{

DriverObject- >DriverExtension- >AddDevice =

AddDevice;  // DriverExtension

Öдæ·Å×ÅÇý¶¯³ÌÐòÀ©Õ¹ÐÅÏ¢£¬°üÀ¨É豸ËùÐèÒªµÄÓ²¼þ×ÊÔ´µÈ¡£

DriverObject- >MajorFunction[IRP_MJ_CREATE]

= RequestCreate;

DriverObject- >MajorFunction[IRP_MJ_CLOSE]

= RequestClose;

DriverObject- >MajorFunction[IRP_MJ_DEVICE_CONTROL]

= RequestControl;

DriverObject- >MajorFunction[IRP_MJ_PNP]

= RequestPnp;

  return STATUS_SUCCESS;

}

---- ÔÚDriverEntryÇý¶¯³ÌÐòÒªÏò²Ù×÷ϵͳµÇ¼Ç²¢×¢²áһЩÏûÏ¢´¦ÀíÆ÷£¬¶øÇÒ»¹ÒªÖ¸Ã÷ÊÇ·ñ¶ÔÇý¶¯³ÌÐòÊäÈëÊä³öµÄÊý¾Ý½øÐлº³å£¬ÁíÍ⻹ҪÎÒÃÇÌṩһ¸öAddDeviceÀý³ÌÀ´°ÑÇý¶¯³ÌÐòÌí¼Óµ½Çý¶¯³ÌÐò¶ÑÕ»ÖС£ÆäÖУ¬IRP_MJ_XXXXXΪÇý¶¯³ÌÐòËùÊÕµ½µÄϵͳÏûÏ¢£¬RequestXXXXXΪÏàÓ¦µÄÏûÏ¢´¦Àíº¯Êý¡£ÔÚ¿Í»§¶Ë³ÌÐòÖУ¬ÎÒÃÇÒ»°ãÒª²ÉÓÃDeviceIoControlͨ¹ý×Ô¶¨ÒåµÄ¿ØÖÆÂëÓëÇý¶¯³ÌÐòͨÐÅ£¨ÔÚVxDÖдó¶àÒ²²ÉÓÃÕâÖÖ·½Ê½£©¡£¿´¿´Çý¶¯³ÌÐòËùÊÕµ½µÄϵͳÏûÏ¢£¬ÎÒÃDz»ÄÑ·¢ÏÖµ±Óû§µ÷ÓÃDeviceIoControlʱ²Ù×÷ϵͳ¾Í»áÏòÇý¶¯³ÌÐò·¢³öÒ»ÌõIRP_MJ_DEVICE_CONTROLÏûÏ¢£¬ÒÔ´¥·¢RequestControlÏûÏ¢´¦Àíº¯Êý¡£

NTSTATUS RequestControl(IN PDEVICE_OBJECT

DeviceObject, IN PIRP Irp)

{

  PIO_STACK_LOCATION IrpStack;

  ULONG ControlCode;

  ULONG InputLength,OutputLength;

  NTSTATUS status;

IrpStack=IoGetCurrentIrpStackLocation(Irp);  

//»ñÈ¡µ±Ç°IRPËùÔÚµÄI/O¶ÑÕ»

ControlCode=IrpStack- >Parameters.DeviceIoControl.

IoControlCode;    //È¡µÃ¿ØÖÆÂë

InputLength=IrpStack- >Parameters.DeviceIoControl.

InputBufferLength; //È¡ÊäÈ뻺³åÇø´óС

OutputLength=IrpStack- >Parameters.DeviceIoControl.

OutputBufferLength;//È¡Êä³ö»º³åÇø´óС

switch(ControlCode)

  {

case HELLOWDM_IOCTL_HELLO:  DbgPrint

("Hello from WDM.\n");//Ïòµ÷ÊÔÆ÷Êä³ö×Ö·û´®

  status=STATUS_SUCCESS;     //Ö÷µ»ØÖµ  

        break;

default:    status=STATUS_INVALID_DEVICE_REQUEST;

      //ÊäÈëµÄ¿ØÖÆÂë²»Ö§³Ö

  }

  return CompleteRequest(Irp, status, 0);

//µ÷ÓÃCompleteRequest֪ͨ²Ù×÷ϵͳÍê³ÉIRP²Ù×÷

}

---- ÔÚ¿Í»§¶Ë·½Ã棬Ïȵ÷ÓÃSetupapi.dllÖÐµÄ SetupDiGetClassDevs²¢ÓÃÉÏÃæÌáµ½µÄ128λ GUID½¨Á¢Ring-0ÓëRing-3½Ó¿Ú£º

---- HDEVINFO info=SetupDiGetClassDevs ((LPGUID)&GUID_HELLOWDM,NULL, //GUID_HELLOWDM ÊÇ128λGUID NULL,DIGCF_PRESENT|DIGCF_INTERFACEDEVICE); È»ºóʹÓÃSetupDiEnumDeviceInterfaces ¶ÔËù»ñµÃµÄ½Ó¿Ú½øÐÐö¾ÙÒÔ»ñµÃ½Ó¿ÚÊý¾Ý£¬½Ó×ÅÁ¬ÐøÁ½´Îµ÷ÓÃSetupDiGetDeviceInterfaceDetail »ñµÃ½Ó¿ÚÏêϸÐÅÏ¢£¬ÆäÖаüÀ¨µ÷ÓÃCreateFil eËùÐèµÄÒ»¸öÐÍΪ\\.\0000000000000004# {3d93c5c0-0085-11d1-821e-0080c88327ab} µÄ×Ö·û´®£¬×îºóµ÷Ó÷½·¨ºÍVxDµÄµ÷ÓôóÌåÏàͬÕâÀï¾Í²»×¸ÊöÁË¡£²»¹ýÓÉÓÚʹÓÃÁË Setupapi.dllÖеÄAPIËùÒÔ»¹ÐèҪʹÓà SetupDiDestroyDeviceInfoListÀ´ÊÍ·ÅËùÉêÇëµÄ×ÊÔ´¡£

---- 4£®¼¸µã˵Ã÷£º

---- ÓÉÓÚWDMÊÇ¿çƽ̨ºÍ¿ç²Ù×÷ϵͳµÄµÄÇý¶¯³ÌÐòÄ£ÐÍ£¬ËùÒÔÔÚ±àдʱһ¶¨²»ÒªÊ¹Óûã±à¡£ÁíÍ⣬ÔÚ±àдʱ»¹Ó¦×¢Òâ¶ÔIRP_MJ_PNPÏûÏ¢µÄÏìÓ¦ÒÔ¼°ÆäËûϵͳÏûÏ¢µÄ´«µÝ£¬ÕâÀïµÄ´«µÝÊÇÏòÆäËüÔÚÇý¶¯³ÌÐò¶ÑÕ»ÖеÄÇý¶¯³ÌÐò¶ø²»ÊÇÏò¿Í»§¶Ë³ÌÐò£¬ÏêϸµÄÐÅÏ¢Çë²Î¿¼±¾ÎÄËùÌṩµÄÀý³Ì¡£×îºó£¬ÓÉÓÚ±ÊÕßд´ËÎÄÕÂʱWindows 2000ÉÐδÕýʽ·¢²¼£¬Ò»Çеıàд¹¤×÷¶¼ÊÇÔÚWindows 98ÉÏÓÃ98DDKÓëVC6.0Íê³ÉµÄ,²¢ÇÒÓÃNumega SoftIce 4.0µ÷ÊÔͨ¹ý¡£

¡¾·µ»Ø¶¥²¿¡¿ ¡¾´òÓ¡±¾Ò³¡¿ ¡¾¹Ø±Õ´°¿Ú¡¿

¹ØÓÚÎÒÃÇ / ¸øÎÒÁôÑÔ / °æȨ¾Ù±¨ / Òâ¼û½¨Òé / ÍøÕ¾±à³ÌQQȺ   
Copyright ©2003- 2024 Lihuasoft.net webmaster(at)lihuasoft.net ¼ÓÔØʱ¼ä 0.00182