欢迎来到天天文库
浏览记录
ID:53787626
大小:172.00 KB
页数:44页
时间:2020-04-07
《delphi编写的虚拟磁盘开发源码分析.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、.Delphi编写的虚拟磁盘开发源码分析一、虚拟光驱驱动(C语言编写)1、Vcd文件夹(1)、DeviceThread.h//设备的处理线程VOIDDeviceThread(INPVOIDContext);(2)、DeviceThread.c#include#include#include#include#include#include#include#include2、hread.h>#include//////////////////////////////////////////////////////////////////////////NTSTATUSVCDOpenFile(INPDEVICE_OBJECTDeviceObject,INPIRPIrp){PDEVICE_EXTENSIONdevice_extension;PCHARfilename;UCHARafile_name[MAX_PATH]={0};UNICODE_STRINGufile_name;NTS3、TATUSstatus;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_EXTENSION)Devi4、ceObject->DeviceExtension;..filename=(PCHAR)Irp->AssociatedIrp.SystemBuffer;RtlCopyMemory(device_extension->oldfile_name,filename,MAX_PATH);if(filename[0]=='\'){if(filename[1]=='\')//\serversharepathXXX.iso->??UNC\serversharepathXXX.iso{strcpy(afile_n5、ame,"\??\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_extension->file_name.Length=(U6、SHORT)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->file_name.Buffer,afile_name,de7、vice_extension->file_name.Length);status=RtlAnsiStringToUnicodeString(&ufile_name,&device_extension->file_name,TRUE);if(!NT_SUCCESS(status))..{ExFreePool(device_extension->file_name.Buffer);Irp->IoStatus.Status=status;Irp->IoStatus.Information=0;returnstatus;}Ini8、tializeObjectAttributes(&object_attributes,&ufile_name,OBJ_CASE_INSENSITIVE,NULL,NULL);status=ZwCreateFile(&device_extension->file_handle,GENERIC_READ,&object_
2、hread.h>#include//////////////////////////////////////////////////////////////////////////NTSTATUSVCDOpenFile(INPDEVICE_OBJECTDeviceObject,INPIRPIrp){PDEVICE_EXTENSIONdevice_extension;PCHARfilename;UCHARafile_name[MAX_PATH]={0};UNICODE_STRINGufile_name;NTS
3、TATUSstatus;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_EXTENSION)Devi
4、ceObject->DeviceExtension;..filename=(PCHAR)Irp->AssociatedIrp.SystemBuffer;RtlCopyMemory(device_extension->oldfile_name,filename,MAX_PATH);if(filename[0]=='\'){if(filename[1]=='\')//\serversharepathXXX.iso->??UNC\serversharepathXXX.iso{strcpy(afile_n
5、ame,"\??\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_extension->file_name.Length=(U
6、SHORT)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->file_name.Buffer,afile_name,de
7、vice_extension->file_name.Length);status=RtlAnsiStringToUnicodeString(&ufile_name,&device_extension->file_name,TRUE);if(!NT_SUCCESS(status))..{ExFreePool(device_extension->file_name.Buffer);Irp->IoStatus.Status=status;Irp->IoStatus.Information=0;returnstatus;}Ini
8、tializeObjectAttributes(&object_attributes,&ufile_name,OBJ_CASE_INSENSITIVE,NULL,NULL);status=ZwCreateFile(&device_extension->file_handle,GENERIC_READ,&object_
此文档下载收益归作者所有