Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all!
I am a new guy for driver development. I had written a drive to implement a virtual disk through file. The DriverEntry routine is as below:
C++
NTSTATUS DriverEntry(PDRIVER_OBJECT drvObject, PUNICODE_STRING usRegPath)
{
	PKEY_VALUE_PARTIAL_INFORMATION startKeyValue;
	ULONG version;
	int i;
 
	Dump("DriverEntry " DRIVER_NAME " " DRIVER_VERSION "\n");
 
	memset(&OsVersion, 0, sizeof(RTL_OSVERSIONINFOW));
	OsVersion.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOW);
	RtlGetVersion(&OsVersion);
	//Dump("RtlGetVersion:%d,%d\r\n", OsVersion.dwMajorVersion, OsVersion.dwMinorVersion);
	// Load dump filter if the main driver is already loaded
	if (NT_SUCCESS (FDDeviceIoControl (NT_ROOT_PREFIX, FD_IOCTL_GET_DRIVER_VERSION, NULL, 0, &version, sizeof (version))))
		return DumpFilterEntry ((PFILTER_EXTENSION) drvObject, (PFILTER_INITIALIZATION_DATA) usRegPath);
 
	FDDriverObject = drvObject;
	memset(VirtualVolumeDeviceObjects, 0, sizeof(VirtualVolumeDeviceObjects));
 
	if(NT_SUCCESS(FDReadRegistryKey(usRegPath, L"Start", &startKeyValue)))
	{
		if(startKeyValue->Type == REG_DWORD && *((uint32 *)startKeyValue->Data) == SERVICE_BOOT_START)
		{
			LoadBootArguments();
		}
		FDfree(startKeyValue);
	}
	else
	{
		Dump("Read registry key value failure!\n");
	}
 
	VolumeClassFilterRegistered = IsVolumeClassFilterRegistered();
	ReportBOOL("VolumeClassFilterRegistered", VolumeClassFilterRegistered);
 
	for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; ++i)
	{
		FDDriverObject->MajorFunction[i] = FDDispatchQueueIRP;
	}
	FDDriverObject->DriverExtension->AddDevice = FileDiskAddDevice;
 
	drvObject->DriverUnload = UnloadDriver;
 
	return FDCreateRootDeviceObject(FDDriverObject);
}

In the code above, I had register a AddDevice routine named FileDiskAddDevice. Through the message output by DebugPrint, I look my driver can be loaded successfully by system. Next, I want to make IO manager call my AddDevice routine. But I don't know how to do it. My driver is just for a virtual device. No real device fits it. So I can't add device by unplug and plug again. I hope someone can be kind to tell me what I should do. Thank you! Smile | :)

Be regards!
Posted

1 solution

Please do not post the same question in multiple forums.
 
Share this answer
 
Comments
[no name] 11-Jan-15 9:32am    
Why not? Sorry I don't see any reason why not to do it. But if there is a good argument...please explain.
Thank you, Bruno
Richard MacCutchan 12-Jan-15 3:47am    
Because it means that the same question will be worked by different people who cannot see each others responses. It duplicates work and takes time from questioners who follow the rules. If you don't understand the protocols of CodeProject then perhaps you should spend some more time reading the FAQs.
[no name] 12-Jan-15 3:56am    
Thank you for the reply. So you mean not in different Forums in CP....I thought you mean in different Forum globally (StackOverFlow, CP, ....)
Richard MacCutchan 12-Jan-15 4:23am    
How would I know if the question has been posted outside of CodeProject?
whiteclouds 11-Jan-15 20:47pm    
Sorry to see this blame. But I am just post question in message board and here. This isn't be acceptable, is it?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900