Problems / Questions about Storport.sys driver

We are trying to just write a basic driver that does nothing that we can load into storport.sys correctly.

When we call StorportInitialize() we should see storport calling our FindAdapter() function but this does not happen. The SCM reports the driver is loaded successfully yet Storport does not call FindAdapter(). Any ideas. See code below.

#include “ntddk.h”
#include “storport.h”

typedef struct _DEVICE_EXTENSION
{
ULONG data;
} DEVICE_EXTENSION, *PDEVICE_EXTENSION;

typedef struct _SRB_EXTENSION
{
ULONG data;
} SRB_EXTENSION, *PSRB_EXTENSION;

NTSTATUS DriverEntry( PDRIVER_OBJECT driverObj , PUNICODE_STRING regPath )
{
VIRTUAL_HW_INITIALIZATION_DATA virtdata;
ULONG i;

virtdata.HwInitialize = vInitialize

virtdata.HwInitialize = vInitialize
virtdata.HwFindAdapter = vFindAdapter

virtdata.AdapterInterfaceType = Internal

status = StorportInitialize( driverObj, regPath, (PHW_INITIALIZATION_DATA) &virtdata, NULL );

}

You are not correctly initializing the structure. Here is what needs
to be done…

//
// Set up information for StorPortInitialize.
//
RtlZeroMemory(&OsrHwInitData,
sizeof(VIRTUAL_HW_INITIALIZATION_DATA));
OsrHwInitData.HwInitializationDataSize =
sizeof(VIRTUAL_HW_INITIALIZATION_DATA);

//
// Set up our entry points (callbacks).
//
OsrHwInitData.HwInitialize = OsrHwInitialize; //
Required.
OsrHwInitData.HwStartIo = OsrHwStartIo; //
Required.
OsrHwInitData.HwFindAdapter = OsrHwFindAdapter; //
Required.
OsrHwInitData.HwResetBus = OsrHwResetBus; //
Required.
OsrHwInitData.HwAdapterControl = OsrHwAdapterControl; //
Required.
OsrHwInitData.HwFreeAdapterResources = OsrHwFreeAdapterResources;
OsrHwInitData.HwProcessServiceRequest = OsrHwProcessServiceRequest;
OsrHwInitData.HwCompleteServiceIrp =
OsrHwCompleteServiceRequest;

OsrHwInitData.AdapterInterfaceType = Internal;

OsrHwInitData.MultipleRequestPerLu = TRUE;
OsrHwInitData.PortVersionFlags = 0;

OsrHwInitData.DeviceExtensionSize =
sizeof(HW_DEVICE_EXTENSION);
OsrHwInitData.SpecificLuExtensionSize = sizeof(HW_LU_EXTENSION);
OsrHwInitData.SrbExtensionSize = sizeof(HW_SRB_EXTENSION) +
OsrUserGetSrbExtensionSize();

status = StorPortInitialize(DriverObject,
RegistryPath,

(PHW_INITIALIZATION_DATA)&OsrHwInitData,
NULL);

if (STATUS_SUCCESS!=status) { // Port driver
said not OK?
OsrTracePrint(TRACE_LEVEL_ERROR,OSRVMINIPT_DEBUG_FUNCTRACE,
(“DriverEntry failure in call to
StorPortInitialize. status:0x%x\n”,status));
ExFreePool(OsrRegistryPath.Buffer);
ASSERT(FALSE);
return status;
}

–Mark Cariddi
OSR, Open Systems Resources, Inc.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@EMPIRE.ECLIPSE.NCSC.MIL
Sent: Wednesday, October 28, 2009 10:46 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Problems / Questions about Storport.sys driver

We are trying to just write a basic driver that does nothing that we can
load into storport.sys correctly.

When we call StorportInitialize() we should see storport calling our
FindAdapter() function but this does not happen. The SCM reports the
driver is loaded successfully yet Storport does not call FindAdapter().
Any ideas. See code below.

#include “ntddk.h”
#include “storport.h”

typedef struct _DEVICE_EXTENSION
{
ULONG data;
} DEVICE_EXTENSION, *PDEVICE_EXTENSION;

typedef struct _SRB_EXTENSION
{
ULONG data;
} SRB_EXTENSION, *PSRB_EXTENSION;

NTSTATUS DriverEntry( PDRIVER_OBJECT driverObj , PUNICODE_STRING regPath
)
{
VIRTUAL_HW_INITIALIZATION_DATA virtdata;
ULONG i;

virtdata.HwInitialize = vInitialize

virtdata.HwInitialize = vInitialize
virtdata.HwFindAdapter = vFindAdapter

virtdata.AdapterInterfaceType = Internal

status = StorportInitialize( driverObj, regPath,
(PHW_INITIALIZATION_DATA) &virtdata, NULL );

}


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Sorry, i was trying to post but i guess the forum didnt let me finish. Seems I can not go back and edit a post which i created…

Anywho would love thougths and ideas on why FindAdapter is not getting called as the DDK indicates that it should be getting called.

THanks

I actually have the exact code you posted except that I have sizeof(DEVICE_EXTENSION) not size of (HW_DEVICE_EXTENSION) but since you declare the struct I assume you just gave it a different name.

I should note that in my code i also declared InitTracing() and CleanupTracing() and storport is calling InitTracing()

How did you install it? Do you have real hardware?

-scott


Scott Noone
Consulting Associate
OSR Open Systems Resources, Inc.
http://www.osronline.com

wrote in message news:xxxxx@ntdev…
>I should note that in my code i also declared InitTracing() and
>CleanupTracing() and storport is calling InitTracing()
>

#include “ntddk.h”
#include “storport.h”

typedef struct _DEVICE_EXTENSION
{
ULONG data;
} DEVICE_EXTENSION, *PDEVICE_EXTENSION;

typedef struct _SRB_EXTENSION
{
ULONG data;
} SRB_EXTENSION, *PSRB_EXTENSION;

ULONG vFindAdapter( IN PVOID DeviceExtension, IN PVOID HwContext, IN PVOID BusInformation, IN PVOID LowerDevice, IN PCHAR ArgumentString, IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo, OUT PBOOLEAN Again );

NTSTATUS DriverEntry( PDRIVER_OBJECT driverObj , PUNICODE_STRING regPath )
{
VIRTUAL_HW_INITIALIZATION_DATA virtdata;
ULONG i;

RtlZeroMemory(&virtdata, sizeof(VIRTUAL_HW_INITIALIZATION_DATA));

virtdata.HwInitializationDataSize = sizeof(VIRTUAL_HW_INITIALIZATION_DATA);

virtdata.HwInitialize = vHwInitialize;
virtdata.HwStartIo = vHwStartIo;
virtdata.HwFindAdapter = vHwFindAdapter;
virtdata.HwResetBus = vHwResetBus;
virtdata.HwAdapterControl = vHwAdapterControl;
virtdata.HwFreeAdapterResources = vHwFreeAdapterResources;
virtdata.HwProcessServiceRequest = vHwProcessServiceRequest;
virtdata.HwCompleteServiceIrp = vHwCompleteServiceRequest;

virtdata.AdapterInterfaceType = Internal;
virtdata.MultipleRequestPerLu = TRUE;
virtdata.PortVersionFlags = 0;

virtdata.DeviceExtensionSize = sizeof(DEVICE_EXTENSION);
virtdata.SpecificLuExtensionSize = sizeof(LU_EXTENSION);
virtdata.SrbExtensionSize = sizeof(SRB_EXTENSION);

status = StorPortInitialize(driverObj, regPath, (PHW_INITIALIZATION_DATA)&OsrHwInitData, NULL);

if (STATUS_SUCCESS ==status) {
//loaded correctly.
//When debugging my code status does equal SUCCESS yet FindAdapter() not called?
}

retrun STATUS_SUCCESS
}

I load it by the (service control manager). No real hardware.

If you do not have real hw yet, have you created a root pnp device? You cannot use the osr driver loader or net start or the scm to load the driver and have it start running

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

-----Original Message-----
From: xxxxx@EMPIRE.ECLIPSE.NCSC.MIL
Sent: Wednesday, October 28, 2009 7:47 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Problems / Questions about Storport.sys driver

We are trying to just write a basic driver that does nothing that we can load into storport.sys correctly.

When we call StorportInitialize() we should see storport calling our FindAdapter() function but this does not happen. The SCM reports the driver is loaded successfully yet Storport does not call FindAdapter(). Any ideas. See code below.

#include “ntddk.h”
#include “storport.h”

typedef struct _DEVICE_EXTENSION
{
ULONG data;
} DEVICE_EXTENSION, *PDEVICE_EXTENSION;

typedef struct _SRB_EXTENSION
{
ULONG data;
} SRB_EXTENSION, *PSRB_EXTENSION;

NTSTATUS DriverEntry( PDRIVER_OBJECT driverObj , PUNICODE_STRING regPath )
{
VIRTUAL_HW_INITIALIZATION_DATA virtdata;
ULONG i;

virtdata.HwInitialize = vInitialize

virtdata.HwInitialize = vInitialize
virtdata.HwFindAdapter = vFindAdapter

virtdata.AdapterInterfaceType = Internal

status = StorportInitialize( driverObj, regPath, (PHW_INITIALIZATION_DATA) &virtdata, NULL );

}


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

YOu cannot do it that way. YOu need to have an inf file to make are
root enumerated device…

–Mark Cariddi
OSR, Open Systems Resources, Inc…

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@EMPIRE.ECLIPSE.NCSC.MIL
Sent: Wednesday, October 28, 2009 11:17 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Problems / Questions about Storport.sys driver

I load it by the (service control manager). No real hardware.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Not the right way. Look at the toaster bus driver sample on how to use devcon to create a root enumerated device and and inf for it. Note that you do not need to write your own bus driver, just learn the inf syntax and how to invoke devcon

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

-----Original Message-----
From: xxxxx@EMPIRE.ECLIPSE.NCSC.MIL
Sent: Wednesday, October 28, 2009 8:20 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Problems / Questions about Storport.sys driver

I load it by the (service control manager). No real hardware.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

The next NtInsider article on Virtual Miniports will document this…

–Mark

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mark Cariddi
Sent: Wednesday, October 28, 2009 11:21 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Problems / Questions about Storport.sys driver

YOu cannot do it that way. YOu need to have an inf file to make are
root enumerated device…

–Mark Cariddi
OSR, Open Systems Resources, Inc…

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@EMPIRE.ECLIPSE.NCSC.MIL
Sent: Wednesday, October 28, 2009 11:17 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Problems / Questions about Storport.sys driver

I load it by the (service control manager). No real hardware.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer