版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Delphi编写的虚拟磁盘开发源码分析 一、虚拟光驱驱动(C语言编写)1、Vcd文件夹、DeviceThread.h/设备的处理线程VOIDDeviceThread (IN PVOID Con text);、DeviceThread.c#in clude #in clude #in clude #in clude #i nclude #in clude #i nclude #in clude #in clude /NTSTATUSVCDOpe nFile (OBJECT_ATTRIBUTESFILE END OF FILE INFORMATIONFILE_BASIC_INFORMATIONFI
2、LE_STANDARD_INFORMATIONFILE_ALIGNMENT_INFORMATIONIN PDEVICE_OBJECTIN PIRP)PDEVICE_EXTENSIONPCHARUCHARUNICODE_STRINGNTSTATUSDeviceObject,Irpdevice_exte nsion;file name;afile_ nameMAX_PATH = 0 ufile_ name;status;object_attributes;file_eof;file_basic;file_sta ndard;file_alig nment;DbgPri nt(VCDOpe nFil
3、en);device_exte nsio n = (PDEVICE_EXTENSION) DeviceObject-DeviceExte nsio n;file name = (PCHAR)lrp-Associatedlrp.SystemBuffer;RtlCopyMemory(device_exte nsion- oldfile_ name,file name,MAX_PATH);if (file name0 = )if (file name1 = )/ serversharepathXXX.iso -?UNCserversharepathXXX.isostrcpy(afile_ name,
4、 ?UNC);strcat(afile_ name, file name);else/ DeviceHarddisk0Partiti on 1pathXXX.iso不变strcpy(afile_ name, file name);else/ c:pathXXX.iso -?c:pathXXX.isostrcpy(afile_ name, ?);strcat(afile_ name, file name);device_exte nsion-file_iname.Le ngth = (USHORT)strle n(afile_ name);device_exte nsion-file_ name
5、.MaximumLe ngth = device_exte nsion-file_ name.Le ngth;device_exte nsion-file_ name.Buffer=ExAllocatePool(N on PagedPool,device_exte nsion-file_ name.Le ngth);RtlCopyMemory(device_exte nsion-file _n ame.Buffer, afile_ name,device_exte nsion-file_ name.Le ngth );status = RtlA nsiStri ngTo Uni codeStr
6、i ng( &ufile_ name,&device_exte nsion-file_ name, TRUE);if (!NT_SUCCESS(status) ExFreePool(device_exte nsi on-file _n ame.Buffer); lrp-loStatus.Status = status;lrp-loStatus .In formati on = 0;return status;In itializeObjectAttributes(&object_attributes,&ufile_ name,OBJ_CASE_INSENSITIVE,NULL,NULL);st
7、atus = ZwCreateFile(&device_exte nsion-file_ha ndle,GENERIC_READ,&object_attributes,& lrp-loStatus,NULL,FILE_ATTRIBUTE_NORMAL,FILE_SHARE_READ,FILE_OPEN,FILE_NON_DIRECTORY_FILE | FILE_RANDOM_ACCESS |FILE_NO_INTERMEDIATE_BUFFERING |FILE_SYNCHRONOUS_IO_NONALERT,NULL,0);if (status = STATUS_OBJECT_NAME_N
8、OT_FOUND | status = STATUS_NO_SUCH_FILE)/如果长度是0ExFreePool(device_exte nsi on-file_ name.Buffer);RtlFree Uni codeStri ng(&ufile_ name);Irp-IoStatus.Status = STATUS_NO_SUCH_FILE;Irp-IoStatus .In formati on = 0;DbgPrint(” 文件不存在!n);return STATUS_NO_SUCH_FILE;else if (!NT_SUCCESS(status)ExFreePool(device
9、_exte nsi on-file _n ame.Buffer);RtlFree Uni codeStri ng(&ufile_iname);DbgPrint(”打开文件失败!n);return status;RtIFree Un icodeStri ng(&u file _n ame);/获取虚拟光盘文件基础信息status = ZwQueryl nformatio nFile(device_exte nsion-file_ha ndle,& lrp-loStatus,&file_basic,sizeof(FILE_BASIC_INFORMATION),FileBasic In format
10、i on);if (!NT_SUCCESS(status)ExFreePool(device_exte nsi on-file _n ame.Buffer);ZwClose(device_exte nsio n-file_ha ndle);DbgPri nt(1获取文件信息失败!n);return status;status = ZwQueryI nformatio nFile(device_exte nsion-file_ha ndle,& lrp-loStatus,&file_sta ndard,sizeof(FILE_STANDARD_INFORMATION),FileSta ndard
11、 In formatio n);if (!NT_SUCCESS(status)ExFreePool(device_exte nsi on-file _n ame.Buffer);ZwClose(device_exte nsio n-file_ha ndle);DbgPrint(2获取文件信息失败!n);return status;device_exte nsion-file_size.QuadPart = file_sta ndard.E ndOfFile.QuadPart;DbgPrint(文件长度%d!n,device_extension-file_size.QuadPart);statu
12、s = ZwQueryl nformatio nFile(device_exte nsion-file_ha ndle,& lrp-loStatus,&file_alig nment,sizeof(FILE_ALIGNMENT_INFORMATION),FileAlig nmen tl nformati on);if (!NT_SUCCESS(status)ExFreePool(device_exte nsi on-file _n ame.Buffer);ZwClose(device_exte nsio n-file_ha ndle);DbgPrint(3获取文件信息失败!n); return
13、 status;DeviceObject-Alig nmen tRequireme nt = file_alig nmen t.Alig nmen tRequireme nt;/只读DeviceObject-Characteristics |= FILE_READ_ONLY_DEVICE;/媒体在光驱device_exte nsi on-media_in_device = TRUE;lrp-loStatus.Status = STATUS_SUCCESS;lrp-loStatus .In formatio n = 0;return STATUS_SUCCESS;NTSTATUSVCDClose
14、File(IN PDEVICE_OBJECT DeviceObject,IN PIRPIrp)PDEVICE_EXTENSION device_exte nsio n;DbgPri nt(VCDCloseFilen ”);ASSERT(DeviceObject != NULL);ASSERT(Irp != NULL);device_exte nsio n = (PDEVICE_EXTENSION) DeviceObject-DeviceExte nsio n;ExFreePool(device_exte nsi on-file _n ame.Buffer);ZwClose(device_ext
15、e nsion-file_ha ndle);device_exte nsion-media_in_device = FALSE;Irp-IoStatus.Status = STATUS_SUCCESS;lrp-loStatus .In formatio n = 0;return STATUS_SUCCESS;/VOIDDeviceThread (IN PVOID Con text)PDEVICE_OBJECT device_object;PDEVICE_EXTENSION device_exte nsi on;PLIST_ENTRYrequest;PIRPirp;PIO_STACK_LOCAT
16、ION io_stack;PUCHARsystem_buffer;PUCHARbuffer;DbgPri nt(DeviceThreadn);device_object = (PDEVICE_OBJECT) Con text;device_exte nsio n = (PDEVICE_EXTENSION) device_object-DeviceExte nsio n;必须如此才能保证对文件读写正常.否则核模式优先级别高的话写/把线程自身优先级设置较低文件会失败KeSetPriorityThread(KeGetCurre ntThread(), LOW_REALTIME_PRIORITY);f
17、or (;)/等待事件被触发KeWaitForSi ngleObject(&device_exte nsion- k_eve nt,Executive,KernelMode,FALSE,NULL);DbgPrint(KeWaitForSingleObject被触发 n);/如果线程结束标志被设置了,就结束自身if (device_exte nsion-termi nate_thread)PsTermi nateSystemThread(STATUS_SUCCESS);/解锁while (request = ExIn terlockedRemoveHeadList(&device_exte ns
18、ion-list_head,&device_exte nsion-list_lock)irp = CONTAINING_RECORD(request, IRP, Tail.Overla y.L istE ntry);io_stack = IoGetCurre ntlrpStackLocati on (irp);DbgPri nt(io_stack-MajorFu nctio n=%un,io_stack-MajorFu nctio n);switch (io_stack-MajorF un ctio n)/读case IRP_MJ_READ:system_buffer = (PUCHAR) M
19、mGetSystemAddressForMdlSafe(irp-MdlAddress, NormalPagePriority);if (system_buffer = NULL)irp-loStatus.Status = STATUS_INSUFFICIENT_RESOURCES;irp-IoStatus .In formatio n = 0;break;buffer = (PUCHAR) ExAllocatePool(PagedPool, io_stack-Parameters.Read.Le ngth);if (buffer = NULL)irp-loStatus.Status = STA
20、TUS_INSUFFICIENT_RESOURCES;irp-IoStatus .In formatio n = 0;break;ZwReadFile(device_exte nsion-file_ha ndle,NULL,NULL,NULL,&i rp-IoStatus,buffer,io_stack-Parameters.Read.Le ngth,& o_stack-Parameters.Read.ByteOffset,NULL);RtlCopyMemory(system_buffer, buffer, io_stack-Parameters.Read.Le ngth);ExFreePoo
21、l(buffer);break;/写,直接返回写保护case IRP_MJ_WRITE:irp-loStatus.Status = STATUS_MEDIA_WRITE_PROTECTED;break;/设备控制case IRP_MJ_DEVICE_CONTROL:switch (io_stack-Parameters.DeviceloC on trol.IoC on trolCode)/我们定义的打开文件case IOCTL_VCD_OPEN_FILE:SeImpers on ateClie nt(device_exte nsion-security_clie nt_con text, NU
22、LL);irp-loStatus.Status = VCDOpe nF ile(device_object, irp);DbgPri nt(VCDOpe nFile=%un ,irp-loStatus.Status);PsRevertToSelf();DbgPri nt(PsRevertToSelfn);break;/我们定义的关闭文件case IOCTL_VCD_CLOSE_FILE:irp-loStatus.Status = VCDCloseFile(device_object, irp);break;default:irp-loStatus.Status = STATUS_DRIVER_
23、INTERNAL_ERROR;break;default:irp-loStatus.Status = STATUS_DRIVER_INTERNAL_ERROR;loCompleteRequest(irp,(CCHAR) (NT_SUCCESS(irp-loStatus.Status) ?IO_DISK_INCREMENT IO_NO_INCREMENT);、VCD.h#ifndef _VCD_#defi ne _VCD_ #ifndef T#ifdef _NTDDK_#defi ne _T(x)L # x#else#defi ne _T(x)x#en dif#en dif#ifndef _T
24、#defi ne _T(x) #en dif_T(x)#defi ne DEVICE_BASE_NAME#defi ne DEVICE_DIR_NAME#defi ne DEVICE_FULL_NAME_T(VCD)_T(Device)DEVICE_BASE_NAMEDEVICE_DIR_NAME DEVICE_BASE_NAME#defi ne DEVICE_VCD0 x8000II打开文件#defi neIOCTL_VCD_OPEN_FILEFILE_READ_ACCESS | FILE_WRITE_ACCESS)II关闭文件#defi neIOCTL_VCD_CLOSE_FILEFILE
25、_READ_ACCESS | FILE_WRITE_ACCESS)II查询设备信息CTL_CODE(DEVICE_VCD, 0 x800,CTL_CODE(DEVICE_VCD, 0 x801,METHOD_BUFFERED,METHOD_BUFFERED,METHOD_BUFFERED,#defi ne IOCTL_VCD_QUERY_DEVICE CTL_CODE(DEVICE_VCD,0 x802,FILE_READ_ACCESS)#defi ne MAX_PATH260#defi ne DWORD un sig ned long#defi ne WORD un sig ned shor
26、t#defi ne BOOL un sig ned long#defi ne BYTE un sig ned charI*II虚拟光驱文件信息typedef struct _VCD_FILE_INFORMATION LARGE_INTEGER FileSize;II 文件大小UCHARFileNameMAX_PATH;II 文件名 VCD_FILE_INFORMATION, *PVCD_FILE_INFORMATION;*III设备的信息typedef struct _VCD_DEVICE_INFORMATION VCD设备ULONGMagic;II标示,符和这个标示就认为是ULONGVers
27、ion;II版本ULONGIn dex;II设备序号BOOLMedia In;II设备中是否有媒体UCHARFileNameMAX_PATH;II文件名UCHARDescaptio nMAX_PATH;II设备描述VCD_DEVICE_INFORMATION, *PVCD_DEVICE_INFORMATION;#defi ne DEVICE_MAGICOxAAFFFFAA#defi ne DEVICE_VERSIONOxOOOOOOOlII创建多少个 CDROM设备,我定为4个.#defi ne DEVICE_COUNT0 x4II驱动对象扩展信息typedef struct _DEVICE_
28、EXTENSION ULONGBOOLEANHANDLEUCHARANSI_STRINGLARGE_INTEGERPSECURITY CLIENT CONTEXTLIST_ENTRY KSPIN LOCKKEVENTPVOIDBOOLEANin dex; media_in_device;file_ha ndle;oldfile_ nameMAX_PATH; file_ name; file_size;security_clie nt_con text;list_head;list_lock;k_eve nt; thread_po in ter;termi nate_thread;II设备的ID
29、II设备里是否有媒体II文件句柄II传进来的原始文件名II文件名II文件大小II客户端安全上下文II线程ListII线程锁II事件句柄II线程对象指针II线程是否已经终止 DEVICE_EXTENSION, *PDEVICE_EXTENSION;II目录设备 Device的句柄 extern HANDLE device_root_ha ndle;#defi ne SECTOR_SIZE512#defi ne TOC_DATA_TRACK0 x04II入口NTSTATUSDriverE ntry(IN PDRIVER_OBJECT DriverObject,IN PUNICODE_STRING
30、RegistryPath );IIII创建CDROM设备NTSTATUSIoCreateCDROMDevice(IN PDRIVER_OBJECT DriverObject,IN ULONGNumber);NTSTATUSIrpCreateClose (IN PDEVICE_OBJECT DeviceObject,IN PIRPIrp);VOIDIrpUn load (IN PDRIVER_OBJECT DriverObject);NTSTATUSlrpReadWrite(IN PDEVICE_OBJECT DeviceObject,IN PIRPIrp);NTSTATUSIrpDeviceC
31、 on trol(IN PDEVICE_OBJECT DeviceObject,IN PIRPIrp);#en dif、VCD.c#in clude #in clude #in clude #in clude #in clude #i nclude #i nclude #in clude #in clude #i nclude HANDLE device_root_ha ndle;NTSTATUSDriverEntry (IN PDRIVER_OBJECT DriverObject,IN PUNICODE_STRING RegistryPathNTSTATUSinti;UNICODE_STRI
32、NGOBJECT_ATTRIBUTESstatus = STATUS_SUCCESS;object_attributes;device_dir_ name;DbgPri nt(lrpU nl oadn);/创建设备目录 DeviceRtlI ni tU nicodeStri ng(&device_dir_name, DEVICE_DIR_NAME);In itializeObjectAttributes(&object_attributes,&device_dir_ name,OBJ_PERMANENT,NULL,NULL);status = ZwCreateDirectoryObject(&
33、device_root_ha ndle,/全部能力DIRECTORY_ALL_ACCESS,&object_attributes);if (!NT_SUCCESS(status)DbgPri nt(ZwCreateDirectoryObject Failedn);return status;/创建临时对象ZwMakeTemporaryObject(device_root_ha ndle);for (i=0;iMajorFu nctio nIRP_MJ_CREATEDriverObject-MajorFu nctio nIRP_MJ_CLOSE=IrpCreateClose;DriverObje
34、ct-MajorFu nctio nIRP_MJ_READDriverObject-MajorFu nctio nIRP_MJ_WRITE=IrpReadWrite;DriverObject-MajorFu nctio nIRP_MJ_DEVICE_CONTROL = IrpDeviceC on trol;DriverObject-Driver Un load = IrpUn load;return STATUS_SUCCESS; /创建CDROM设备,每个设备都会有一个处理线程NTSTATUSloCreateCDROMDevice(IN PDRIVER_OBJECT DriverObject
35、,IN ULONGNumber)NTSTATUSWCHARUNICODE_STRINGANSI_STRINGPDEVICE_OBJECTstatus = STATUS_SUCCESS;device_ name_buferMAXIMUM_FILENAME_LENGTH = 0;device_ name;adevice_ name;device_object;PDEVICE_EXTENSIONdevice_exte nsi on;HANDLEthread_ha ndle;swpri ntf(device_ name_buffer,DEVICE_FULL_NAME L% u,Number);RtlI
36、 nit Un icodeStri ng(&device_ name, device _n ame_buffer);Rtl Un icodeStri ngToA nsiStri ng(&adevice_ name, & device _n ame, TRUE);DbgPri nt(adevice_ name:%sn, adevice_ name.Bufer);RtlFreeA nsiStri ng(&adevice _n ame);status = IoCreateDevice(DriverObject, sizeof(DEVICE_EXTENSION), &device_ name, FIL
37、E_DEVICE_CD_ROM,0,FALSE,&device_object);if (!NT_SUCCESS(status)DbgPri nt(loCreateDevice Failed!n ”);return status;device_object-Flags |= DO_DIRECT_IO;device_exte nsion = (PDEVICE_EXTENSION) device_object-DeviceExte nsio n;device_exte nsion-in dex = Number;device_exte nsi on-media_in_device = FALSE;d
38、evice_object-Characteristics |= FILE_READ_ONLY_DEVICE; /CDROM 只能是只读的/初始化线程ListIn itializeListHead(&device_exte nsio n-list_head);/初始化自旋锁Keln itializeSpi nLock(&device_exte nsi on-list_lock);/初始化事件KeI nitializeEve nt(&device_exte nsion-k_event,Synchroni zatio nEvent,FALSE);device_exte nsi on-termi na
39、te_thread = FALSE;/创建系统线程status = PsCreateSystemThread(&thread_ha ndle,(ACCESS_MASK) 0L,NULL,NULL,NULL,DeviceThread,device_object);if (!NT_SUCCESS(status)IoDeleteDevice(device_object);DbgPri nt(PsCreateSystemThread Failed!n);return status;status = ObRefere nceObjectByHa ndle(thread_ha ndle,THREAD_AL
40、L_ACCESS,NULL,KernelMode,&device_exte nsion-thread_po in ter, NULL);if (!NT_SUCCESS(status)ZwClose(thread_ha ndle);device_exte nsi on-termi nate_thread = TRUE;KeSetEve nt(&device_exte nsion- k_eve nt,(KPRIORITY) 0,FALSE);loDeleteDevice(device_object);DbgPrint(ObReferenceObjectByHandle Failed!n); ret
41、urn status;ZwClose(thread_ha ndle);return STATUS_SUCCESS;ntifs.h#defi ne TOKEN_SOURCE_LENGTH 8typedef en um _TOKEN_TYPE Toke nPrimary = 1,Toke nl mpers on ati on TOKEN_TYPE;typedef struct _TOKEN_SOURCE CCHAR SourceNameTOKEN_SOURCE_LENGTH;LUIDSourceIde ntifier; TOKEN_SOURCE, *PTOKEN_SOURCE;typedef st
42、ruct _TOKEN_CONTROL LUIDToke nld;LUIDAuthe nticati onld;LUIDModifiedld;TOKEN_SOURCE Toke nSource; TOKEN_CONTROL, *PTOKEN_CONTROL;typedef struct _SECURITY_CLIENT_CONTEXT SECURITY_QUALITY_OF_SERVICE SecurityQos;PACCESS_TOKENClie ntToke n;BOOLEANDirectlyAccessClie ntToke n;BOOLEANDirectAccessEffectiveO
43、 nly;BOOLEANServerIsRemote;TOKEN_CONTROLClie ntToke nCon trol; SECURITY_CLIENT_CONTEXT, *PSECURITY_CLIENT_CONTEXT; TOC o 1-5 h z #defi ne PsDerefere ncelmpers on atio nToke n(T)if (ARGUMENT_PRESENT(T) (ObDereferenceObject(T); else ; #defi ne PsDerefere ncePrimaryToke n(T) (ObDerefere nceObject(T)NTK
44、ERNELAPIVOIDPsRevertToSelf (VOID);NTKERNELAPINTSTATUSSeCreateClie ntSecurity (IN PETHREADThread,IN PSECURITY_QUALITY_OF_SERVICE QualityOfService,IN BOOLEANRemoteClie nt,#defi ne SeDeleteClie ntSecurity(C)OUT PSECURITY_CLIENT_CONTEXT Clie ntCo ntext );if (SeToke nType(C)-Clie ntToke n) = Toke nPrimar
45、y) PsDerefere ncePrimaryToke n( (C)-Clie ntToke n ); else PsDerefere ncelmpers on ati on Toke n( (C)-Clie ntToke n ); NTKERNELAPIVOIDSelmpers on ateClie nt (IN PSECURITY_CLIENT_CONTEXT Clie ntC on text,IN PETHREADServerThread OPTIONAL);NTKERNELAPITOKEN_TYPESeTokenType (IN PACCESS_TOKEN Toke n);Irp.c
46、#in clude #in clude #in clude #in clude #in clude #i nclude #i nclude #in clude #in clude #i nclude /PDEVICE_OBJECTCDROMDeleteDevice (IN PDEVICE_OBJECT DeviceObject )PDEVICE_EXTENSION device_exte nsio n; PDEVICE_OBJECTn ext_device_object;DbgPri nt(CDROMDeleteDevicen);ASSERT(DeviceObject != NULL);dev
47、ice_exte nsio n = (PDEVICE_EXTENSION) DeviceObject-DeviceExte nsio n;device_exte nsi on-termi nate_thread = TRUE;KeSetEve nt(&device_exte nsion- k_eve nt,(KPRIORITY) 0,FALSE);KeWaitForSi ngleObject(device_exte nsion-thread_po in ter,Executive,KernelMode,FALSE,NULL);ObDerefere nceObject(device_exte n
48、sio n-thread_poi nter);if (device_exte nsion-security_clie nt_con text != NULL)SeDeleteClie ntSecurity(device_exte nsio n-security_clie nt_con text); ExFreePool(device_exte nsion-security_clie nt_con text);n ext_device_object = DeviceObject-NextDevice;IoDeleteDevice(DeviceObject);return n ext_device
49、_object;/VOIDIrpUn load (IN PDRIVER_OBJECT DriverObject)PDEVICE_OBJECT device_object;DbgPri nt(IrpU nl oadn);device_object = DriverObject-DeviceObject;while (device_object)device_object = CDROMDeleteDevice(device_object);ZwClose(device_root_ha ndle);NTSTATUSIrpCreateClose (IN PDEVICE_OBJECT DeviceOb
50、ject,IN PIRPIrp)DbgPri nt(lrpCreateClosen); lrp-loStatus.Status = STATUS_SUCCESS; lrp-loStatus.l nformation = FILE_OPENED;IoCompleteRequest(Irp, IO_NO_INCREMENT);return STATUS_SUCCESS;NTSTATUSIrpReadWrite (IN PDEVICE_OBJECT DeviceObject,IN PIRPIrp)PDEVICE_EXTENSION device_exte nsio n;PIO_STACK_LOCAT
51、ION io_stack;DbgPri nt(lrpReadWriten);device_exte nsio n = (PDEVICE_EXTENSION) DeviceObject-DeviceExte nsio n;/如果没有媒体在光驱中就结束if (!device_exte nsion-media_in_device)Irp-IoStatus.Status = STATUS_NO_MEDIA_IN_DEVICE;Irp-IoStatus .In formati on = 0;IoCompleteRequest(Irp, IO_NO_INCREMENT);return STATUS_NO_
52、MEDIA_IN_DEVICE;io_stack = loGetCurre ntlrpStackLocati on (Irp);/如果长度=0if (io_stack-Parameters.Read.Le ngth = 0)Irp-IoStatus.Status = STATUS_SUCCESS;Irp-IoStatus .In formati on = 0;loCompleteRequest(lrp, IO_NO_INCREMENT);return STATUS_SUCCESS;loMarklrpPe ndi ng(lrp);ExIn terlockedl nsertTailList(&de
53、vice_exte nsion-list_head,& lrp-Tail.Overlay.ListE ntry,&device_exte nsion-list_lock);/触发事件KeSetEve nt(&device_exte nsion- k_eve nt,(KPRIORITY) 0,FALSE);return STATUS_PENDING;NTSTATUSIrpDeviceC on trol (IN PDEVICE_OBJECT DeviceObject,IN PIRPIrp)PDEVICE_EXTENSION device_exte nsio n;PIO_STACK_LOCATION
54、 io_stack;NTSTATUSstatus;DbgPri nt(IrpDeviceC on troln);device_exte nsio n = (PDEVICE_EXTENSION) DeviceObject-DeviceExte nsio n;io_stack = loGetCurre ntlrpStackLocati on (Irp);/如果没有媒体,并且不是打开文件或者查询设备信息的请求就不处理if (!device_exte nsi on-media_in_device) &(io_stack-Parameters.DeviceIoC on trol.IoC on trolC
55、ode !=IOCTL_VCD_OPEN_FILE )&(io_stack-Parameters.DeviceIoCo ntrol.loC on trolCode !=IOCTL_VCD_QUERY_DEVICE)Irp-IoStatus.Status = STATUS_NO_MEDIA_IN_DEVICE;lrp-loStatus .In formati on = 0;loCompleteRequest(lrp, IO_NO_INCREMENT);return STATUS_NO_MEDIA_IN_DEVICE;/处理请求switch (io_stack-Parameters.Devicel
56、oC ontrol.loCon trolCode)/打开case IOCTL_VCD_OPEN_FILE:SECURITY_QUALITY_OF_SERVICE security_quality_of_service;DbgPri nt(IOCTL_VCD_OPEN_FILEn);/如果有媒体if (device_exte nsi on-media_in_device)status = STATUS_INVALID_DEVICE_REQUEST;Irp-IoStatus .In formatio n = 0;DbgPrint(里面有光盘!n); break;/如果参数不够长if (io_sta
57、ck-Parameters.DeviceIoC on trol.l nputBufferLe ngth IoStatus .In formatio n = 0;DbgPrint(缓冲区不够长!n); break;/客户端安全的上下文if (device_exte nsion-security_clie nt_con text != NULL)DbgPrint(去掉客户端安全上下文!n);SeDeleteClie ntSecurity(device_exte nsio n-security_clie nt_con text);elseDbgPrint(创建客户端安全上下文 !n);device_
58、exte nsion-security_clie nt_con text =ExAllocatePool(No nPagedPool, sizeof(SECURITY_CLIENT_CONTEXT);RtlZeroMemory(&security_quality_of_service, sizeof(SECURITY_QUALITY_OF_SERVICE);security_quality_of_service 丄en gth = sizeof(SECURITY_QUALITY_OF_SERVICE); security_quality_of_service .Im pers on ati o
59、n Level = SecurityImpers on ati on; security_quality_of_service.C on textTracki ngMode = SECURITY_STATIC_TRACKING; security_quality_of_service.EffectiveO nly = FALSE;SeCreateClie ntSecurity(PsGetCurre ntThread(),&security_quality_of_service,FALSE,device_exte nsion-security_clie nt_con text);loMarklr
60、pPe ndi ng(Irp);ExI nterlockedI nsertTailList(&device_exte nsion-list_head,&Irp-Tail.Overlay.ListE ntry,&device_exte nsion-list_lock);KeSetEve nt(&device_exte nsion-k_event,(KPRIORITY) 0,FALSE);status = STATUS_PENDING;break;/如果是关闭文件case IOCTL_VCD_CLOSE_FILE:DbgPri nt(IOCTL_VCD_CLOSE_FILEn ”);IoMarkI
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年度美容美发行业品牌推广与广告投放合同4篇
- 2025版五金制品研发、生产与销售合作协议2篇
- 2025年度铝合金门窗维修保养服务合同模板4篇
- 2025年度高速公路路基采石供应合同3篇
- 2025年行政法律文书数字化处理及输出合同3篇
- 精准农业2025年度粮食储备风险管理与保险合同3篇
- 二零二五红酒年份酒定制销售及品牌合作合同范本3篇
- 二零二五版门窗行业环保材料采购合同8篇
- 2025年度铝窗产品研发与创新激励合同4篇
- 2025年度道路施工劳务分包合同4篇
- 2024-2025学年人教版数学六年级上册 期末综合试卷(含答案)
- 收养能力评分表
- 山东省桓台第一中学2024-2025学年高一上学期期中考试物理试卷(拓展部)(无答案)
- 中华人民共和国保守国家秘密法实施条例培训课件
- 管道坡口技术培训
- 2024年全国统一高考英语试卷(新课标Ⅰ卷)含答案
- 2024年认证行业法律法规及认证基础知识 CCAA年度确认 试题与答案
- 皮肤储存新技术及临床应用
- 外研版七年级英语上册《阅读理解》专项练习题(含答案)
- 2024年辽宁石化职业技术学院单招职业适应性测试题库必考题
- 上海市复旦大学附中2024届高考冲刺模拟数学试题含解析
评论
0/150
提交评论