I succeeded in compiling and installing the Microsoft RAM disk example driver (VS2013 with WDK 8.1 - also using the WDK 8.1 driver examples).
The readme tells that after installation you can use the RAM drive from an admin prompt. Probably the same problem as being asked here: https://superuser.com/questions/344577/how-to-access-ramdisk-drive-from-non-admin-user-account-on-windows-xp
With the answer given in this thread, I added this code to the RamDiskEvtDeviceAdd function:
status = WdfDeviceInitAssignSDDLString(DeviceInit,
&SDDL_DEVOBJ_SYS_ALL_ADM_RWX_WORLD_RWX_RES_RWX);
if (!NT_SUCCESS(status)) {
return status;
}
This should add RWX rights for admin, world and reserved accounts.
Now a regular user can access the drive and copy files to the ram drive. It also is visible and accessible in the explorer (Windows 7). But I still cannot delete files (not even as administrator). The first prompt tells you that administrator privileges are required to delete files. If you confirm this prompt, a second prompt appears: "You require permissions from Everyone to make changes to this file.".
When looking at the properties of the disk drive, there is no security tab that lets you examine or grant any rights. So I think some kind of security descriptor is missing.
I already tried to peek into other RAM drive implementations, but they are probably written with different driver models (non WDF), which seem to work quite differently in this aspect.
I also tried to get more information studying the MSDN pages regarding WDF, but was unable find something useful.
Some people might ask: why don't you use a working RAM drive solution? But the actual problem is to create a disk driver, that can be configured to create IO errors on demand. Similar to this solution for Linux: http://www.scylladb.com/2016/02/16/fault-injection-filesystem-software-testing/
So I thought using a simple RAM disk driver might be good start. Any comments how to fix the delete access right problems are welcome.