欢迎来到天天文库
浏览记录
ID:40088088
大小:245.02 KB
页数:43页
时间:2019-07-20
《delphi编写的虚拟磁盘开发源码分析》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、Delphi编写的虚拟磁盘开发源码分析一、虚拟光驱驱动(C语言编写)1、Vcd文件夹(1)、DeviceThread.h//设备的处理线程VOIDDeviceThread(INPVOIDContext);(2)、DeviceThread.c#include#include#include#include#include#include#include#include2、iceThread.h>#include//////////////////////////////////////////////////////////////////////////NTSTATUSVCDOpenFile(INPDEVICE_OBJECTDeviceObject,INPIRPIrp){PDEVICE_EXTENSIONdevice_extension;PCHARfilename;UCHARafile_name[MAX_PATH]={0};UNICODE_STRINGufile3、_name;NTSTATUSstatus;OBJECT_ATTRIBUTESobject_attributes;FILE_END_OF_FILE_INFORMATIONfile_eof;FILE_BASIC_INFORMATIONfile_basic;FILE_STANDARD_INFORMATIONfile_standard;FILE_ALIGNMENT_INFORMATIONfile_alignment;DbgPrint("VCDOpenFile");device_extension=(PDEVICE_4、EXTENSION)DeviceObject->DeviceExtension;43filename=(PCHAR)Irp->AssociatedIrp.SystemBuffer;RtlCopyMemory(device_extension->oldfile_name,filename,MAX_PATH);if(filename[0]=='\'){if(filename[1]=='\')//\serversharepathXXX.iso->??UNC\serversharepathXXX5、.iso{strcpy(afile_name,"\??\UNC");strcat(afile_name,filename);}else//DeviceHarddisk0Partition1pathXXX.iso不变{strcpy(afile_name,filename);}}else//c:pathXXX.iso->??c:pathXXX.iso{strcpy(afile_name,"\??\");strcat(afile_name,filename);}device_extens6、ion->file_name.Length=(USHORT)strlen(afile_name);device_extension->file_name.MaximumLength=device_extension->file_name.Length;device_extension->file_name.Buffer=ExAllocatePool(NonPagedPool,device_extension->file_name.Length);RtlCopyMemory(device_extension->f7、ile_name.Buffer,afile_name,device_extension->file_name.Length);status=RtlAnsiStringToUnicodeString(&ufile_name,&device_extension->file_name,TRUE);if(!NT_SUCCESS(status))43{ExFreePool(device_extension->file_name.Buffer);Irp->IoStatus.Status=status;Irp->IoStat8、us.Information=0;returnstatus;}InitializeObjectAttributes(&object_attributes,&ufile_name,OBJ_CASE_INSENSITIVE,NULL,NULL);status=ZwCreateFile(&device_extension->file_handle,GENERIC_READ,&object_a
2、iceThread.h>#include//////////////////////////////////////////////////////////////////////////NTSTATUSVCDOpenFile(INPDEVICE_OBJECTDeviceObject,INPIRPIrp){PDEVICE_EXTENSIONdevice_extension;PCHARfilename;UCHARafile_name[MAX_PATH]={0};UNICODE_STRINGufile
3、_name;NTSTATUSstatus;OBJECT_ATTRIBUTESobject_attributes;FILE_END_OF_FILE_INFORMATIONfile_eof;FILE_BASIC_INFORMATIONfile_basic;FILE_STANDARD_INFORMATIONfile_standard;FILE_ALIGNMENT_INFORMATIONfile_alignment;DbgPrint("VCDOpenFile");device_extension=(PDEVICE_
4、EXTENSION)DeviceObject->DeviceExtension;43filename=(PCHAR)Irp->AssociatedIrp.SystemBuffer;RtlCopyMemory(device_extension->oldfile_name,filename,MAX_PATH);if(filename[0]=='\'){if(filename[1]=='\')//\serversharepathXXX.iso->??UNC\serversharepathXXX
5、.iso{strcpy(afile_name,"\??\UNC");strcat(afile_name,filename);}else//DeviceHarddisk0Partition1pathXXX.iso不变{strcpy(afile_name,filename);}}else//c:pathXXX.iso->??c:pathXXX.iso{strcpy(afile_name,"\??\");strcat(afile_name,filename);}device_extens
6、ion->file_name.Length=(USHORT)strlen(afile_name);device_extension->file_name.MaximumLength=device_extension->file_name.Length;device_extension->file_name.Buffer=ExAllocatePool(NonPagedPool,device_extension->file_name.Length);RtlCopyMemory(device_extension->f
7、ile_name.Buffer,afile_name,device_extension->file_name.Length);status=RtlAnsiStringToUnicodeString(&ufile_name,&device_extension->file_name,TRUE);if(!NT_SUCCESS(status))43{ExFreePool(device_extension->file_name.Buffer);Irp->IoStatus.Status=status;Irp->IoStat
8、us.Information=0;returnstatus;}InitializeObjectAttributes(&object_attributes,&ufile_name,OBJ_CASE_INSENSITIVE,NULL,NULL);status=ZwCreateFile(&device_extension->file_handle,GENERIC_READ,&object_a
此文档下载收益归作者所有