IoBuildSynchronousFsdRequest + STATUS_ACCESS_DENIED with RAMDISK

Hi I am trying to write a block of data (1MB) from my driver to the softpedia ramdisk but
getting Status as STATUS_ACCESS_DENIED.
$B!!(B
Status = IoCallDriver(DeviceObject, Irp);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(
&Event,
Executive,
KernelMode,
FALSE,
NULL
);
Status = IoStatus.Status;
}
What could be wrong? Any help would be really great.

thanks,

regards…kiran

kiran k wrote:

Hi I am trying to write a block of data (1MB) from my driver to the
softpedia ramdisk but

getting Status as STATUS_ACCESS_DENIED.

 

Status = IoCallDriver(DeviceObject, Irp);

if (Status == STATUS_PENDING)

{

KeWaitForSingleObject(

&Event,

Executive,

KernelMode,

FALSE,

NULL

);

Status = IoStatus.Status;

}

What could be wrong?

A hundred things could be wrong. You haven’t shown us a single useful
thing here. What kind of driver is this? Where did you get the
DeviceObject? How did you build the IRP?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hi Tim,

I am building the IRP using …

Irp = IoBuildSynchronousFsdRequest(
IRP_MJ_WRITE,
DeviceObject,
Buffer,
Length,
Offset,
&Event,
&IoStatus
);

It’s an upper disk filter driver.I am trying to write to s softpedia ramdisk device.i created a 500 mb of this ramdisk.

The call is always returning with status STATUS_ACCESS_DENIED.

I checked the ramdisk attributes and it is not in readonly mode.

VOLUME - Manipulate volume attributes.
DISK - Manipulate disk attributes.

DISKPART> attribute disk
Current Read-only State : No
Read-only : No
Boot Disk : No
Pagefile Disk : No
Hibernation File Disk : No
Crashdump Disk : No
Clustered Disk : No

thanks for your help.

Thanks,

regards…kiran

Date: Mon, 8 Sep 2014 10:02:47 -0700
From: xxxxx@probo.com
To: xxxxx@lists.osr.com
Subject: Re: [ntdev] IoBuildSynchronousFsdRequest + STATUS_ACCESS_DENIED with RAMDISK

kiran k wrote:

Hi I am trying to write a block of data (1MB) from my driver to the softpedia ramdisk but
getting Status as STATUS_ACCESS_DENIED.
$B!!(B
Status = IoCallDriver(DeviceObject, Irp);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(
&Event,
Executive,
KernelMode,
FALSE,
NULL
);
Status = IoStatus.Status;
}What could be wrong?

A hundred things could be wrong. You haven’t shown us a single useful thing here. What kind of driver is this? Where did you get the DeviceObject? How did you build the IRP?

Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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

kiran,

I am not so much into storage, RAMDISKs and so on, but MS forbids writes to volumes starting with Windows Vista (except from MBR/VBR areas). Not sure which driver enforces the policy but it may be the case.

kiran k wrote:

I am building the IRP using …

Irp = IoBuildSynchronousFsdRequest(
IRP_MJ_WRITE,
DeviceObject,
Buffer,
Length,
Offset,
&Event,
&IoStatus
);

It’s an upper disk filter driver.I am trying to write to s softpedia
ramdisk device. i created a 500 mb of this ramdisk.
The call is always returning with status STATUS_ACCESS_DENIED.

You still didn’t tell us where you got the device object. Have you
opened a file on the RAMDISK? Are you putting a FILE_OBJECT into the IRP?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

The driver is an upper filter for disk devices.

  1. I have the RAMDISK hardware ID…L"SPVD\Disk"

  2. When this is mounted I do get called in AddDevice and here I do query the device hardware ID and once find it that it matches with the above then…

  3. Create a filter device object with IoCreateDevice()

  4. call IoAttachDeviceToDeviceStack.

  5. do ~DO_DEVICE_INITIALIZING.

Hope this information is okay.I am using this device object in the call to IoBuildSynchronousFsdRequest().

Date: Tue, 9 Sep 2014 09:47:28 -0700
From: xxxxx@probo.com
To: xxxxx@lists.osr.com
Subject: Re: [ntdev] IoBuildSynchronousFsdRequest + STATUS_ACCESS_DENIED with RAMDISK

kiran k wrote:

I am building the IRP using …

Irp = IoBuildSynchronousFsdRequest(
IRP_MJ_WRITE,
DeviceObject,
Buffer,
Length,
Offset,
&Event,
&IoStatus
);

It’s an upper disk filter driver.I am trying to write to s softpedia ramdisk device. i created a 500 mb of this ramdisk.
The call is always returning with status STATUS_ACCESS_DENIED.

You still didn’t tell us where you got the device object. Have you opened a file on the RAMDISK? Are you putting a FILE_OBJECT into the IRP?

Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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

Why are you writing your filter using WDM?

That’s a very bad decision…

Also, it is *very* unlikely that you want to be calling IoBuildSynchronousFsdRequest from a disk filter driver… unless you’re calling it from a work item (and even then it’s a bad idea)… because it builds IRPs that are associated with whatever thread happens to be scheduled as “current thread” at the time you call the function, and you almost certainly cannot predict what this thread is (again, unless it’s a work item).

And you STILL haven’t told us where you’re getting the device object you use to call this function. OK, you said “AddDevice” – that’s WHERE you obtained it. Which parameter, specifically, did you get the Device Object pointer from in AddDevice? The Device Object RETURNED from IoAttachDeviceToDeviceStack or the Device Object passed into AddDevice or something else?

C’mon Mr. Kumar… a bit of engineering discipline on your part would help us help you.

And please… stop with your WDM filter and re-write your filter using WDF. You’d probably be done by now.

Peter
OSR
@OSRDrivers

Thanks Peter for the reply.

The device object pointer is from IoAttachDeviceToDeviceStack().

I have the PhysicalDeviceObject once I get into Adddevice.I do IoGetDeviceProperty() and get the hardware ID.

Next I create the filter device object with IoCreateDevice() and then …

deviceExtension->LowerDeviceObject =
IoAttachDeviceToDeviceStack(filterDeviceObject, PhysicalDeviceObject);

thanks.

Date: Wed, 10 Sep 2014 08:22:59 -0400
From: xxxxx@osr.com
To: xxxxx@lists.osr.com
Subject: RE:[ntdev] IoBuildSynchronousFsdRequest + STATUS_ACCESS_DENIED with RAMDISK

Why are you writing your filter using WDM?

That’s a very bad decision…

Also, it is *very* unlikely that you want to be calling IoBuildSynchronousFsdRequest from a disk filter driver… unless you’re calling it from a work item (and even then it’s a bad idea)… because it builds IRPs that are associated with whatever thread happens to be scheduled as “current thread” at the time you call the function, and you almost certainly cannot predict what this thread is (again, unless it’s a work item).

And you STILL haven’t told us where you’re getting the device object you use to call this function. OK, you said “AddDevice” – that’s WHERE you obtained it. Which parameter, specifically, did you get the Device Object pointer from in AddDevice? The Device Object RETURNED from IoAttachDeviceToDeviceStack or the Device Object passed into AddDevice or something else?

C’mon Mr. Kumar… a bit of engineering discipline on your part would help us help you.

And please… stop with your WDM filter and re-write your filter using WDF. You’d probably be done by now.

Peter
OSR
@OSRDrivers


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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’re going to ignore the rest of what I told you, aren’t you.

Sigh…

Peter
OSR
@OSRDrivers

This piece of code that I am trying to talk to RAMDISK is part of existing huge code base.

I have noted your inputs about WDF but rewriting it would be a little complex for me at this

time.

I have a separate thread where in I am calling the function to write data to RAMDSIK by creating IRP with IoBuildSynchronousFsdRequest().

Will check into your comments and work on that.

Thanks for the help Peter.

Date: Wed, 10 Sep 2014 13:48:05 -0400
From: xxxxx@osr.com
To: xxxxx@lists.osr.com
Subject: RE:[ntdev] IoBuildSynchronousFsdRequest + STATUS_ACCESS_DENIED with RAMDISK

You’re going to ignore the rest of what I told you, aren’t you.

Sigh…

Peter
OSR
@OSRDrivers


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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