Issue with porting WinXP driver to Win 7

Joined
Apr 13, 2012
Messages
1
Reaction score
0
Details of the issue with Porting WinXP (plug & play camera driver) to Win 7 issue:

1. The driver was a working and tested driver for WinXP.

2. The driver is recompiled for Win7 using Windows driver kit (WinDDK 7600.16385.1) and a .sys file is generated, when we tried to load it
It fails loading and blue screen error appears.

3. Loading of the driver in Win 7 takes more time than in WinXP.
4. The size of the .sys file generated when compiled for WinXP is 12 MB where as when compiled for Win 7 it is 100k.
5. While loading the driver in Win 7 PC multiple IRP message is received “IRP_MN_QUERY_DEVICE_RELATIONS”, “IRP_MN_QUERY_CAPABILITIES”
For a long time before blue screen appears Where in the same is not observed for WinXP.

The .inf file for the driver is attached for your reference.

The entry point for the driver architecture is as :

NTSTATUS
DriverEntry(
__in PDRIVER_OBJECT DriverObject,
__in PUNICODE_STRING RegistryPath
)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PDEVICE_OBJECT deviceObject = NULL;
/* Initialize the driver object with this driver's entry points*/
DriverObject->DriverExtension->AddDevice = CMOSAddDevice;
DriverObject->MajorFunction[IRP_MJ_CREATE] = CMOSCreateDevice;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = CMOSCloseDevice;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = CMOSDeviceControl;
DriverObject->DriverUnload = CMOSUnloadDriver;
DriverObject->MajorFunction[IRP_MJ_PNP] = CMOSDispatchPnp;
DriverObject->MajorFunction[IRP_MJ_POWER] = CMOSDispatchPower;
DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = CMOSDispatchSystemControl;
return ntStatus;
}

Blue screen appears as it tries to add the device “CMOSAddDevice”.

NTSTATUS
CMOSAddDevice
(
IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT DeviceObject
)
{
NTSTATUS status = STATUS_SUCCESS;
UNICODE_STRING ntUnicodeString; // NT Device Name "\Device\CMOS"
UNICODE_STRING ntWin32NameString; // Win32 Name "\DosDevices\CMOS_EVAL"
PDEVICE_OBJECT fdo; //Functional Device Object
UNICODE_STRING symbolicLinkName;
PCMOS_DEVICE_INFO deviceInfo=0;
ULONG deviceInfoSize;
ANSI_STRING ansi_string;
STRING DestinationString[100];
PAGED_CODE();
CMOS_DBGP(("+CMOSAddDevice \n"));

deviceInfoSize = sizeof(CMOS_DEVICE_INFO);
/*! Convert String to Unicodec string*/
RtlInitUnicodeString( &ntUnicodeString, NT_DEVICE_NAME );
/*! Create Device Object */
status = IoCreateDevice(
DriverObject, // Our Driver Object
deviceInfoSize, // We don't use a device extension
&ntUnicodeString, // Device name "\Device\SIOCTL"
FILE_DEVICE_UNKNOWN, // Device type
FILE_DEVICE_SECURE_OPEN, // Device characteristics
FALSE, // Not an exclusive device
&fdo); // Returned ptr to Device Object

if ( !NT_SUCCESS( status ) )
{
CMOS_DBGP(("Couldn't create the device object\n"));
return status;
}
CMOS_DBGP(("FDO:: 0x%x\n",fdo));
/*! Store into Driver global structure */
deviceInfo = (PCMOS_DEVICE_INFO)fdo->DeviceExtension;
RtlZeroMemory(deviceInfo,deviceInfoSize);
/*!Initialize Device object to Device Info*/
deviceInfo->Fdo= fdo;
/*!Initialize Physical Device to Device Info*/
deviceInfo->Pdo = DeviceObject;
/*!Initialize a Unicode String containing the Win32 name for our device.*/
RtlInitUnicodeString( &deviceInfo->symbolicLinkName, DOS_DEVICE_NAME );
/*! Create a symbolic link between our device name and the Win32 name */
status = IoCreateSymbolicLink(
&deviceInfo->symbolicLinkName, &ntUnicodeString );

if ( !NT_SUCCESS( status ) )
{
/* Delete everything that this routine has allocated. */
CMOS_DBGP(("Couldn't create symbolic link\n"));
IoDeleteDevice( DeviceObject );
return status;
}
CMOS_DBGP(("symbolic link Created successfully\n"));

/*! Attach our driver to the device stack */
deviceInfo->NextLowerDriver =
IoAttachDeviceToDeviceStack
(
fdo,
DeviceObject
);
if(NULL == deviceInfo->NextLowerDriver)
{
CMOS_DBGP(("----symbolic link not created----\n"));
CMOSAddDeviceExit(deviceInfo);
return STATUS_NO_SUCH_DEVICE;
}
CMOS_DBGP(("IoAttachDeviceToDeviceStack success\n"));
/*! Initialize Remove Lock */
IoInitializeRemoveLock
(
&deviceInfo->RemoveLock ,
'0ADS',
1, // MaxLockedMinutes
0 // HighWatermark, this parameter is
);
/*! Set FDO Flags */
fdo->Flags |= DO_POWER_PAGABLE;
deviceInfo->Fdo= fdo;
fdo->Flags &= ~DO_DEVICE_INITIALIZING;

CMOS_DBGP(("-CMOSAddDevice \n"));
return status;

}


Regards,
Misbah
 

Attachments

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top