It is currently Thu Nov 21, 2019 4:48 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 41 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: PureBasic Interface to ImDisk
PostPosted: Sat Jan 10, 2015 9:37 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1593
-----------------------------------------------------------------------------------

Download PureBasic Interface to ImDisk from My PureBasic Stuff

-----------------------------------------------------------------------------------

Tricks 'n' Tips
PureBasic Interface to OpenCV
PureBasic Interface to WinDivert
PureBasic Interface to WinRAR
PureBasic Interface to 7-Zip
PureBasic Interface to ImDisk
Windows Services & Other Stuff
Invading Space Aliens
Death Star vs Asteroids
GIF Toolkit
LSB File Embedding
Spider Web Drawing
Deform Image: MLS
Video Snipping Tool
Stitch Images: SIFT
Image Waves: LUT
YouTube Player & Downloader
MP4 Player & Downloader
Barcode Generator
Embed JS into PureBasic
Geolocation: Google Maps
Book & Viewer & Magnify
Video for Windows: VfW
Alternate Console
Network Share Management

-----------------------------------------------------------------------------------

TESTED ( PureBasic 5.24 - 5.62 )
- Windows 7, Windows 8, Windows 10

ImDisk Virtual Disk Driver API
- Windows NT, 2000, XP, Vista, 7, 8, 8.1 or Windows Server 2003, 2008, 2012

INCLUDED
- 16 examples, 2 service files, 6 includes

- ImDisk v2.0.10.64: http://www.ltr-data.se/opencode.html/#ImDisk
-- imdisk.cpl / imdisk.lib / imdisk.sys
-- imdisk.h, imdisk.c, imdisk_cpl.cpp, imdisk_sys.cpp, drvio.c, gpl.txt, readme.txt

- Microsoft Windows SDK
-- imapi2fs.h, imapi2sample.cpp

-----------------------------------------------------------------------------------

EXAMPLES
- CreateDevice1.pb
-- creates a RAM Disk linked to the first available drive letter
- RemoveDevice1.pb
-- removes the link between the drive and RAM Disk
- CreateDevice2.pb
-- creates an image file linked to the first available drive letter
- RemoveDevice2.pb
-- removes the link between the drive and image file
- MountDevice.pb
-- mounts an image file to virtual memory or relinks an image file
- CreateMountPoint1.pb
-- creates a MountPoint between a folder location and the first available drive letter
- RemoveMountPoint1.pb
-- removes the link between the two locations
- CreateMountPoint2.pb
-- creates a MountPoint between a folder location and a newly created folder
- RemoveMountPoint2.pb
-- removes the link between the two locations
- AdjustImageFileSize.pb
-- adjusts an image file size
- ExtendDevice.pb
-- extends the size of an image file
- SaveImageFile.pb
-- saves a device to an image file
- SaveImageFileInteractive.pb
-- saves a device to an image file interactively
- QueryDevice.pb
-- displays information about devices
- GetFormattedGeometry.pb
-- displays information about disk drives with a valid boot record signature
- CreateMountableImage.pb
-- creates a mountable image file from either a device or folder location

NOTES
- Compiler Options--Compile/Run--Current directory: binaries\
- Request Administrator mode for Windows Vista and above: checked
-- CreateDriverService.pb: required to create the virtual device driver service
-- DeleteDriverService.pb: required to delete the virtual device driver service (may also need a reboot)
-- CreateDevice1.pb: required by the format-drive window prompt, and the HideDrive registry option
-- RemoveDevice1.pb: required by the HideDrive registry option
-- CreateDevice2.pb: required by the format-drive window prompt, and the HideDrive registry option
-- RemoveDevice2.pb: required by the HideDrive registry option
-- MountDevice.pb: required by the HideDrive registry option
-- ExtendDevice.pb: required by the device driver
-- SaveImageFile.pb: required by the DeviceIoControl function
-- SaveImageFileInteractive.pb: required by the DeviceIoControl function
-- GetFormattedGeometry.pb: required to access the BPB (BIOS Parameter Block)

-----------------------------------------------------------------------------------

Before using the ImDisk Interface for the first time run the file: CreateDriverService.pb (folder: /setservice/).
- after a reboot any virtual drives are removed, but the formatted image files remain intact and can be reused
- if a virtual drive is created or modified in memory, an image file must be saved to be available after reboot

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Fri Oct 11, 2019 1:08 am, edited 138 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic Interface to ImDisk
PostPosted: Sat Jan 10, 2015 11:14 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 3693
Location: Italy
Cool stuff, not something I can try right now but wanted to say thanks for sharing it.

_________________
[ My little PureBasic review ]


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic Interface to ImDisk
PostPosted: Sun Jan 11, 2015 2:06 am 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 22, 2004 4:12 pm
Posts: 2447
Location: Norway
Might be cool for creating an encrypted cloud storage app. :D

_________________
I like logic, hence I dislike humans but love computers.


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic Interface to ImDisk
PostPosted: Sun Jan 11, 2015 3:41 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1593
Hi luis, Joakim Christiansen,

You're welcome, and thank you for commenting.

-----------------------------------------------------------------

Updated:
- added Constants, Structures, and Functions
- added folder: references
-- includes license and readme files from ImDisk

Made some minor improvements to the Service-Create/Delete scripts.

NB*: The new Functions and Structures have not been tested.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic Interface to ImDisk
PostPosted: Sun Jan 11, 2015 3:42 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3458
Hi
You did it as I expected :)
Did not test it yet but I expect again that it will be a very good stuff

Thanks JHPJHP

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic Interface to ImDisk
PostPosted: Sun Jan 11, 2015 5:54 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1593
Hi RASHAD,

Thank you for the vote of confidence, I hope it meets your expectations. :mrgreen:

---------------------------------------------------

The entire list of available Functions have now been included, but I can't guarantee they've been correctly declared until I apply them to an example.

I've also added a couple new Procedures that include the option to hide the virtual drive.
- this is a rudimentary attempt to conceal the drive and is not very reliable

Some of the default options have been changed, most notably when removing the virtual device the folder and image file are not deleted.

NB*: It's worth noting that the device-driver service (imdisk.sys) is only needed for "Device" examples.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Mon Jan 12, 2015 5:52 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic Interface to ImDisk
PostPosted: Sun Jan 11, 2015 1:38 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Apr 12, 2013 1:55 pm
Posts: 1058
Location: just outside of Ferguson
That was some awesome detective and analytical work JHPJHP.
To help future sleuths I'm adding the word ramdisk to this thread. ;)

Because there are some who would try to run ricardo's program multiple times to attempt to recover the deleted video from the hard drive, this seems to be a better solution.
And don't forget to erase the RAM after use, although that wouldn't stop a determined hacker. ;)

_________________
Keep it BASIC.


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic Interface to ImDisk
PostPosted: Sun Jan 11, 2015 11:55 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1593
Hi heartbone,

Thanks for the kudos.

------------------------------------------------------

Applied various updates to the package, but moving forward is slow due to a lack of API examples.
- added: References, Constants, Structures, and Macros

------------------------------------------------------

Updated the package with additional Constants and Structures, fixing various Function declarations.
- replaced the imdisk.lib file with a newer version (x86 / x64)
- updated the references with newer versions
- removed the i64 binaries
- added an additional test script (x86 / x64)

------------------------------------------------------

Updated:
- added 1 example
-- ExtendDevice.pb: extends the size of an image file

NB*: Various other improvements have been made to multiple examples.

------------------------------------------------------

Updated:
- CreateDevice.pb: added a simple GUI interface

If the created device is less then 32 MB then the format of the drive will be FAT otherwise it's NTFS.
- FAT file systems cannot be extended using ExtendDevice.pb, but the image file size will be increased


NB*: Update also includes some general improvements to the examples.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Mon Jan 19, 2015 5:10 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic Interface to ImDisk
PostPosted: Mon Jan 19, 2015 3:45 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1593
Updated:
- fixed an inconsistency where the QUAD data type was required
- small update/patch to the example: ExtendDevice.pb
- removed the test scripts (didn't offer anything new)
- split the example: CreateMountPoint.pb
-- CreateMountPoint1.pb and CreateMountPoint2.pb
- split the example: RemoveMountPoint.pb
-- RemoveMountPoint1.pb and RemoveMountPoint2.pb

--------------------------------------------------------------

After some additional testing I noticed an issue with the DISK_GEOMETRY Structure and the LARGE_INTEGER datatype in the example: QueryDevice.pb. Even though the Structure matched the documentation I had to create an additional Structure: DISK_GEOMETRY_QUERY, modified to work with both 32bit and 64bit versions of PureBasic.

--------------------------------------------------------------

Updated
- added 5 examples
-- AdjustImageFileSize.pb: adjusts an image file size
-- SaveImageFile.pb: saves a device to an image file
-- SaveImageFileInteractive.pb: saves a device to an image file interactively
-- QueryDevice.pb: displays information about devices
-- GetFormattedGeometry.pb: displays information about disk drives with a valid boot record signature

AdjustImageFileSize.pb: This function is used to resize an image file to match the formatted size of the device and cannot be made larger. If the adjusted image file size is smaller then the format size, the next time it is "relinked" using the example: CreateDevice.pb the Windows Format tool will open.

SaveImageFileInteractive.pb: If the image file is saved using the built-in option: New MBR, when it is "linked" using the example: CreateDevice.pb the Windows Format tool will open.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Sat Jan 24, 2015 9:44 am, edited 3 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic Interface to ImDisk
PostPosted: Mon Jan 19, 2015 5:26 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1593
Updated:
- added 2 examples
-- CreateDevice1.pb: creates a RAM Disk linked to the first available drive letter
-- RemoveDevice1.pb: removes the link between the drive and RAM Disk
- renamed 2 examples
-- CreateDevice.pb to CreateDevice2.pb
-- RemoveDevice.pb to RemoveDevice2.pb

I used the CrystalDiskMark tool to benchmark the speed of the RAM disk, receiving similar results to those in the following link.
- https://www.raymond.cc/blog/12-ram-disk-software-benchmarked-for-fastest-read-and-write-speed/
- these are the parameters I used to compare speed between my C:\ drive and a newly created RAM disk: 5 | 50 MB.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Tue Jan 20, 2015 4:41 am, edited 10 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic Interface to ImDisk
PostPosted: Mon Jan 19, 2015 5:43 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Apr 12, 2013 1:55 pm
Posts: 1058
Location: just outside of Ferguson
Thanks for putting this package together JHPJHP and making it better explained how to interface with it.
It is something that I am saving for probable future use,
and hope that I get to develop an application that will benefit greatly from using it.

As much as the hated Vista thrashes its C: drive, I've long wondered why the OS doesn't do more in RAM.
It sure would speed things along.
Using this really makes sense for any computationally intense work that relies on multiple file I/O, to save on wear and tear.

And thanks for the link.
It led me to this: Make Firefox Faster By Putting Profile and SQLite Database in RAMDisk something that I will try very soon.
If it makes a significant difference, I'm going to identify other areas to implement its use.
It's not the same as running the OS from a SSD, but it is cheaper, and possibly safer.

_________________
Keep it BASIC.


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic Interface to ImDisk
PostPosted: Tue Jan 20, 2015 2:58 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1593
Hi heartbone,

You're welcome, I hope it can be of some use.

My own tests showed a speed increase from 80 MB/s ( C:\ ) to over 5000 MB/s ( RAM disk ).
- benchmark tool (5 | 50 MB): CrystalDiskMark

--------------------------------------------

Updated:
- added the FlushFileBuffers function where appropriate.

Another option would have been to use the CreateFile function instead of the OpenFile function:
Code:
CreateFile_(*lpFileName, #GENERIC_READ | #GENERIC_WRITE, #FILE_SHARE_READ | #FILE_SHARE_WRITE, #Null, #OPEN_EXISTING, #FILE_FLAG_NO_BUFFERING, #Null)

I've set the max drive size (before extending) to 4GB, but if you have the RAM and would like to increase this:
- LARGE_INTEGER Structure handles QUAD type values, not to be confused with: LARGE_INTEGER union or ULARGE_INTEGER union
Code:
DriveSize.LARGE_INTEGER
DriveSize\highpart = 1
DriveSize\lowpart = 1024 * 1024 * 1024
highpart.q = DriveSize\highpart * Pow(2, 32)
lowpart.q = DriveSize\lowpart * 4
Debug highpart
Debug lowpart

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Top
 Profile  
Reply with quote  
 Post subject: PureBasic Interface to ImDisk
PostPosted: Fri Jan 23, 2015 6:04 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1593
Updated:
- added 1 include
-- datasections.pbi
- added Constants, 1 Structure, Functions (Interfaces)
- added 2 reference files
-- imapi2fs.h, imapi2sample.cpp
- added 1 example
-- CreateMountableImage.pb: creates a mountable image file from either a device or folder location

The device examples have been updated to handle multiple links, a max size of 4 GB (ImDisk has no limit), including various other improvements.

CreateMountableImage.pb: I worked on this example for awhile, but kept hitting a wall when it came to declaring the various interfaces. Using the Microsoft site which lists the Functions alphabetically, I didn't realize my mistake until I found this post by bingo: http://www.purebasic.fr/english/viewtopic.php?t=29757.

NB*: A mountable image file cannot be created from a drive-root, or a circular reference.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic Interface to ImDisk
PostPosted: Wed Jan 28, 2015 4:27 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1593
Updated:
- CreateDevice2.pb: added a second button to mount an existing image file
-- an ISO video file, or a file created with the example: CreateMountableImage.pb can also be mounted
-- forcing ISO files to be mounted as a CD and IMG files to be mounted as a hard drive
- removed instances of the Function: ImDiskSetAPIFlags previously used to automatically force dismounting a drive and suppressing messages
-- RemoveDevice1.pb and RemoveDevice2.pb
--- if a drive lock cannot be established a messagebox will prompt with a "force dismount" option

NB*: Fixed a few issues in a couple examples, nothing worth documenting.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic Interface to ImDisk
PostPosted: Wed Jan 28, 2015 7:36 pm 
Offline
User
User

Joined: Wed Aug 06, 2008 8:21 am
Posts: 72
Thx! :mrgreen:

_________________
PureBASIC v5.41 LTS , Windows v8.1 x64
Forget UNICODE - Keep it BASIC !


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 41 posts ]  Go to page 1, 2, 3  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye