Page 1 of 1

Mounting a Virtual Disk

Posted: Wed Apr 27, 2005 12:19 pm
by ShDancer
Well i was looking for some kind of virtual disk when i found Virtul Bin.
Its very nice but i found another thing that i think it can be very usefull.
I was wondering if some one is interested in porting this to Purebasic?

Heres the link's
http://www.acc.umu.se/~bosse/
or if you whant to download
http://www.acc.umu.se/~bosse/filedisk.zip

then just run this to make a small empty file on your hard disk.

Code: Select all

Procedure makeSparse(Filename.s, FileSize.l)
  Protected FileHandle.l
  Protected ReturnValue.l
  FileHandle = CreateFile(#PB_Any, Filename)
  If ( FileHandle <> 0 )
    FileSeek(FileSize - 1)
    WriteByte(0)
    CloseFile(FileHandle)
  Else
    ReturnValue = -1
  EndIf
  ProcedureReturn ReturnValue
EndProcedure

makeSparse("C:\Test.txt", 30*1024*1024) ; 30 Mbytes
After that just install the downloaded software reboot your computer and mount the File Disk.

This will add a new disk (virtual) to your windows expolorer.

The only problem is that i can only test on NTFS, i don't have any FAT Operating System to test it on.

Posted: Thu May 05, 2005 3:28 pm
by ShDancer
Did Anyone saw or tried this???

Posted: Thu May 05, 2005 4:15 pm
by Max.
Looks very interesting. Gonna check it out the next days.

Posted: Thu May 05, 2005 8:12 pm
by ShDancer
Thanks, as i said i would like to port this do purebasic, i think its very usefull.

You can make something like a secure and protected disk using password and encryptation.

Or just use it to store files something like VBin ( Not a Replacement ), its easy to import/export Files.

It has several uses.

But i need help on this, my knoledge of C or C++ is almost none.

Posted: Thu May 05, 2005 9:39 pm
by Paul
Hi ShDancer,

I haven't tried the virtual disk thing but I did notice that your little procedure is not the correct way to create a sparce file.

Example, use this command to call your procedure:

Code: Select all

makeSparse("test1.txt", 100*1024*1024)
Then check the properties of the created file...
Size: 100 MB (104,857,600 bytes)
Size on Disk: 100 MB (104,857,600 bytes)


Now try this procedure:

Code: Select all

#FSCTL_SET_SPARSE=$900C4

Procedure MKSparce(FileName.s,FileSize)
  hFile=CreateFile_(FileName,#GENERIC_READ|#GENERIC_WRITE,#FILE_SHARE_READ|#FILE_SHARE_WRITE,0,#CREATE_NEW,#FILE_FLAG_NO_BUFFERING,0)
  If FileHandle<>#INVALID_HANDLE_VALUE
    If DeviceIoControl_(hFile,#FSCTL_SET_SPARSE,0,0,0,0,@Bytes,0)
      If SetFilePointer_(hFile,FileSize,0,#FILE_BEGIN)
        SetEndOfFile_(hFile)
        Result=1
      EndIf
    EndIf
    CloseHandle_(hFile)
  EndIf
  ProcedureReturn Result
EndProcedure
And use this command to call the new procedure:

Code: Select all

MKSparse("test2.txt", 100*1024*1024)
Check the file size of the new file...
Size: 100 MB (104,857,600 bytes)
Size on Disk: 16 KB (16,384 bytes) <--- 16KB !!!


A true sparce file makes the OS think it is 100MB total but actually takes up only 16kb on the hard drive. Much more efficient if there is only a small amount of data stored in it when it's being used as a virtual disk. :)

Posted: Mon May 23, 2005 8:17 pm
by ShDancer
Thanks in advance for the reply Paul.

Did anyone try it?
Just 10 min and one reboot. (Well more or less :) )

Until today i was involved in a project in my company
and didn't had time for pb, so now i'm free to continue
this little utility.

Can someone help me porting this to pb?
I don't understand much of C or C++ Language.

I think it could be usefull, for the comunity.

Thanks once more.

Posted: Tue May 24, 2005 11:39 am
by jqn
Hi,
I've ported to PB and re-designed filedisk (only C) into this little example:

http://purebasic.myftp.org/?filename=fi ... TCData.zip

Regards,
JOAQUIN

Posted: Tue May 24, 2005 4:39 pm
by Worm
The zip file seems to be corrupt. Could you repost?

Posted: Tue May 24, 2005 4:58 pm
by jqn
The zip file is correct, but I've changed the case in URL. Sorry.

Try this:

http://purebasic.myftp.org/?filename=fi ... TCdata.zip

JOAQUIN

Posted: Tue May 24, 2005 5:49 pm
by Worm
Thanks, seems to work for me now.

Posted: Tue Jun 07, 2005 5:19 pm
by Intrigued
Wow, thanks for sharing! I am going to go through and try this out over the next few days.

Have you two (or anyone else for that matter) gotten around to encrypting the data in the virtual drive? How about hiding the virtual drive (or can you do that with this code, I'll have to read through the file)?

Thanks for sharing!

*thumbs up*

Posted: Tue Jun 07, 2005 5:36 pm
by jqn
Hi,
About encryption, see:

http://www.scherrer.cc/crypt/

I've NOT TESTED it.

JOAQUIN

Posted: Tue Jun 07, 2005 6:39 pm
by Intrigued
jqn wrote:Hi,
About encryption, see:

http://www.scherrer.cc/crypt/

I've NOT TESTED it.

JOAQUIN
Thanks for the link. I see that Win9x/ME is not supported. Here's what I would need:

Win98SE/ME/2000/XP

and...

I would prefer the use of 448-bit Blowfish. The product I have out now uses 448-bit Blowfish for encryption and thus my marketing compaign can be on the same level, when I tout comments like "448-bit Blowfish encryption used! Stronger than the standard SSL connection!", or something to that effect.

I do appreciate the quick post though and offer!

Re: Mounting a Virtual Disk

Posted: Mon Aug 05, 2019 5:16 am
by dagcrack
Sorry to revive this old thread but I was wondering if someone still had a copy of TCdata.zip since the URL is down. Seemed to be hosted by jqn's home ftp server through a freeddns account which has been down/inactive for a while.

In case nobody has it, are there any alternative solutions for Windows currently?

The original mentioned code in http://www.acc.umu.se/~bosse/ can be found (latest version) here: http://www.acc.umu.se/~bosse/filedisk/filedisk-21.zip

Thanks in advance.