Recent

Author Topic: Create a temporary RAM drive with Drive letter for app time only ?  (Read 903 times)

jamie

  • Hero Member
  • *****
  • Posts: 6077
I would like to be able to create a temporary RAM drive with an Assigned letter within the app and only exclusive use for the app.

 I know I can create a RAM drive in windows but what I want is to create an exclusive use of a RAM drive just for my app if for example the media the app is on is READ only.
   
  I have an app that can create default setup files if one isn't found but the app also deals with a series of images that are processed digitally and thus these images are stashed away for later retrieval while the app is operating.

 I have a case where I want to send out software that can operate from a flash or CD drive for intermediate use, Trials or simply they just don't want to fully install it and the app needs a file stream to interact with while it's active to give them full capabilities while active.

 This RAM drive will be removed/Delete when App exits so all items in it will of course go away.

Is there any code out there that can create a Temp RAM drive exclusive to the app?

I wanted to add that I am well aware of user files being creating in user space on the HD if the device is plugged into the USB/CD etc., but in my case, I can't do that if they decide not to allow any writing to disk unless they decide to install it.

« Last Edit: December 04, 2022, 03:18:54 am by jamie »
The only true wisdom is knowing you know nothing

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: Create a temporary RAM drive with Drive letter for app time only ?
« Reply #1 on: December 04, 2022, 07:24:28 pm »
I would like to be able to create a temporary RAM drive with an Assigned letter within the app and only exclusive use for the app.

Windows doesn't have process only drive letters or volumes. The most you can do is create it without drive letter (thus it won't be visible inside Windows Explorer) and access it using it's volume name: \\?\Volume{VOLUME-GUID}\<path on volume>. Please note that anyone knowing the volume GUID can still access the volume using that path.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2006
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Create a temporary RAM drive with Drive letter for app time only ?
« Reply #2 on: December 04, 2022, 07:51:10 pm »
I still do not really understand everything but on Windows you can use the Structured Storage ability when I somehow understood you correct.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

440bx

  • Hero Member
  • *****
  • Posts: 3921
Re: Create a temporary RAM drive with Drive letter for app time only ?
« Reply #3 on: December 04, 2022, 08:09:14 pm »
I know I can create a RAM drive in windows but what I want is to create an exclusive use of a RAM drive just for my app if for example the media the app is on is READ only.
If I needed something like that, I'd simply redirect the drive related API calls (CreateFile, GetLogicalDrives, SetFilepointer, etc) to a block of memory I allocated myself.  Emulating a drive isn't difficult and should not require much code if the emulation is targeting a specific program instead of being general.

HTH.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Wallaby

  • Jr. Member
  • **
  • Posts: 78
Re: Create a temporary RAM drive with Drive letter for app time only ?
« Reply #4 on: December 05, 2022, 07:13:48 am »
As someone who has written a RAM disk driver for Windows, I'd say: don't do that.

It's tens of thousands of lines of complex kernel-level code written in C. I don't think it's even possible in FPC.

Use a structured storage or a database file (like SQLite) or a ZIP archive (if the data are read-only) to store your application data.

loaded

  • Hero Member
  • *****
  • Posts: 824
Re: Create a temporary RAM drive with Drive letter for app time only ?
« Reply #5 on: December 05, 2022, 09:06:44 am »
It's tens of thousands of lines of complex kernel-level code written in C. I don't think it's even possible in FPC.

I remember back in the old "DOS Black Screen 6.22" times this was done with a few simple codes. It just required a reboot.
Maybe things are easier now.
Actually, it would be great to have Lazarus setup and working with such an option.
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

Bogen85

  • Hero Member
  • *****
  • Posts: 595
Re: Create a temporary RAM drive with Drive letter for app time only ?
« Reply #6 on: December 05, 2022, 01:25:04 pm »
I've not looked into these on windows.

https://winfsp.dev/ Windows File System Proxy
http://dokan-dev.github.io/ User Mode File System

Not sure if modules have been written for those to achieve something like what is being desired here.
« Last Edit: December 05, 2022, 10:40:22 pm by Bogen85 »

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: Create a temporary RAM drive with Drive letter for app time only ?
« Reply #7 on: December 05, 2022, 10:36:11 pm »
It's tens of thousands of lines of complex kernel-level code written in C. I don't think it's even possible in FPC.

Of course it's possible in FPC. But it isn't trivial to do.

 

TinyPortal © 2005-2018