addDevice problem

Hello all,
I am a beginner in WDM driver developer. I want to ask, i create a simple DriverEntry.?The function is only DriverUnload. When i test with instDrv and DbgView, it works fine. But when i add another function?AddDevice, there is a problem. When i test and try to start, the driver start and directly execute the DriverUnload. Anyone know this problem?
?
Thanks

How are you starting the device?

mm

AddDevice is for Plug and Play Drivers. To correctly develop a PnP
driver you must have the IRP_MJ_POWER and IRP_MJ_PNP handlers, as well
as generating an INF file to get the driver installed (for the device it
will support, or for a software only PnP Driver). Check the WDK or
osronline for a software only PNP driver…

–Mark Cariddi

OSR, Open Systems REsources, Inc.

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of sahrizal sofian
Sent: Wednesday, August 12, 2009 10:13 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] addDevice problem

Hello all,

I am a beginner in WDM driver developer. I want to ask, i create a
simple DriverEntry. The function is only DriverUnload. When i test with
instDrv and DbgView, it works fine. But when i add another function
AddDevice, there is a problem. When i test and try to start, the driver
start and directly execute the DriverUnload. Anyone know this problem?

Thanks

— 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

This are the AddDevice Function. Thanks
?
?
NTSTATUS AddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
{
NTSTATUS status = STATUS_SUCCESS;
PDEVICE_OBJECT fDO=NULL;
PFDO_DATA devExt;

PAGED_CODE();
DbgPrint(“AddDevice with Physical Address %p : Start \n”,PhysicalDeviceObject);
//Create a device object.
status=IoCreateDevice( DriverObject,
sizeof(FDO_DATA),
NULL,
FILE_DEVICE_UNKNOWN,
FILE_DEVICE_SECURE_OPEN,
FALSE,
&fDO);
//Check create device and directly return the status if create device fail
if (!NT_SUCCESS(status))
{
return status;
}
DbgPrint(“AddDevice: create device success \n”);

//Casting the pointer
devExt=(PFDO_DATA)fDO->DeviceExtension;
//Assign variable Self and PhyDevObj of DevExt to FDO and PhysicalDeviceObject
devExt->Self = fDO;
devExt->PhyDevObj = PhysicalDeviceObject;
//Attach the device object into the lower object, and it should be checked
//whether this attachment success or not. If not then the device object should
//be deleted so it will not be in the memory
devExt->LowDevObj = IoAttachDeviceToDeviceStack(fDO,devExt->PhyDevObj);
if (devExt->LowDevObj == NULL){
IoDeleteDevice(fDO);
return STATUS_NO_SUCH_DEVICE;
}
//Assign flag of FDO to DO_BUFFERED_IO and DO_POWER_PAGEABLE
fDO->Flags |= DO_BUFFERED_IO | DO_POWER_PAGABLE;

//Reset flag in device object to do initializing
fDO->Flags &= ~DO_DEVICE_INITIALIZING;

return STATUS_SUCCESS;
}

— On Wed, 8/12/09, xxxxx@evitechnology.com wrote:

From: xxxxx@evitechnology.com
Subject: RE:[ntdev] addDevice problem
To: “Windows System Software Devs Interest List”
Date: Wednesday, August 12, 2009, 10:16 AM

How are you starting the device??

mm


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 might want to take a look at one of the wdk samples and use it as a starting point for learning/experimentation.

‘Toaster’ is the catch all wdm sample.

Good luck,

mm

Thanks. Actually i also try to adapt from toaster example. But, how we test our major function? Because, we can not use the instDrv. Should we build own windows API. Is there any good reference to create this?

— On Wed, 8/12/09, xxxxx@evitechnology.com wrote:

From: xxxxx@evitechnology.com
Subject: RE:[ntdev] addDevice problem
To: “Windows System Software Devs Interest List”
Date: Wednesday, August 12, 2009, 10:26 AM

You might want to take a look at one of the wdk samples and use it as a starting point for learning/experimentation.

‘Toaster’ is the catch all wdm sample.

Good luck,

mm


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

toaster comes with a complete family including bus driver, function
driver,inf files to install different variations of drivers and applications
to communicate with those drivers. if you install the toaster bus driver
u’ll be able to test your (toaster ) function driver’s major function
routines.

-rtshiva

On Wed, Aug 12, 2009 at 8:01 PM, sahrizal sofian
wrote:

> Thanks. Actually i also try to adapt from toaster example. But, how we
> test our major function? Because, we can not use the instDrv. Should we
> build own windows API. Is there any good reference to create this?
>
> — On Wed, 8/12/09, xxxxx@evitechnology.com > > wrote:
>
>
> From: xxxxx@evitechnology.com
> Subject: RE:[ntdev] addDevice problem
> To: “Windows System Software Devs Interest List”
> Date: Wednesday, August 12, 2009, 10:26 AM
>
>
> You might want to take a look at one of the wdk samples and use it as a
> starting point for learning/experimentation.
>
> ‘Toaster’ is the catch all wdm sample.
>
>
> Good luck,
>
> mm
>
> —
> 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

use toaster…

remove all instances of the IRPs you dont need to support…

start the driver …using a INF…

create an application which accceses the drivers starting from createfile then doing read file …write file…DIO…etc…and see the effect on toaster witha debugger…

you also need to create a sym link along wit with ur dev obj to access the driver…

good luck…