Jump to content











Photo
- - - - -

LockVolume


  • Please log in to reply
17 replies to this topic

#1 joakim

joakim

    Silver Member

  • Team Reboot
  • 912 posts
  • Location:Bergen
  •  
    Norway

Posted 26 July 2011 - 01:00 PM

This is a specilaized application that will lock and unlock a volume for you. Since Vista, new security mechanisms was added to Windows that prevented raw disk access as was before nt6.x; http://msdn.microsof...y/ff551353.aspx . I posted an ugly workaround for it about 2 years ago; http://communities.v.../docs/DOC-10455

Later user TheK made the first good solution using the win api in his LockDismount tool; http://reboot.pro/12413/

LockVolume is more or less the same as his, except it is written AutoIt and source is attached. However, some differences are present;

1. My tool is per volume, whereas his is per disk.
2. Mine can optionally dismount if necessary, whereas his will dismount (not 100 % sure though)

Anyways, the only purpose was to provide some source for AutoIt coders to reuse. If there's bugs, the source is provided for you to fix.. :whistling: There will likely never be an updated version as this was just a side-effect of something else I'm doing.

Posted Image

Some explanation of the GUI:
Usually clicking on just "Lock It" and "Unlock It" should be enough. But sometimes you may want to dismount the volume as well. If so, then click on "Safe Dismount", after volume is locked. But if something is preventing the volume from being locked, then you must force dismount it by clicking on "Force Dismount" (no need to lock it afterwords then). Remounting the volume after a forcefully dismount, is done by clicking on "Force Remount". The activated buttons should be activated when it makes sense to use them, and if not show an error message. Either way, if anything goes wrong, just close the application, and all locks will be unocked. Just beware that a forced dismount may cause issues if something serious was going on on the file system for that volume.

Download; http://www.mediafire.../LockVolume.zip
  • Nuno Brito likes this

#2 Nuno Brito

Nuno Brito

    Platinum Member

  • Team Reboot
  • 10447 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 27 July 2011 - 01:11 PM

Thank you for sharing.

Will be mentioned at this week's newsletter!

:cheers:

#3 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13649 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 27 July 2011 - 03:09 PM

Sometimes they return! :confused1:

joakim is probably too modest :cheers: (not everywhere but in spots :confused1:) to mention how the original idea/finding was his own:
http://reboot.pro/8200/page__st__19
http://reboot.pro/8200/page__st__24
on which TheK based his nice app (and erwan.l implemented it in clonedisk) :frusty:

VERY well done! :cheers:

:worship:
Wonko

#4 joakim

joakim

    Silver Member

  • Team Reboot
  • 912 posts
  • Location:Bergen
  •  
    Norway

Posted 27 July 2011 - 03:49 PM

joakim is probably too modest :cheers: (not everywhere but in spots :confused1:) to mention how the original idea/finding was his own:
http://reboot.pro/8200/page__st__19
http://reboot.pro/8200/page__st__24

Sorry for not mentioning that thread as well. The whole point with this thread is not to claim an idea to be mine. It is to provide AutoIt source code. Please search first post for the word purpose.

#5 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13649 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 27 July 2011 - 04:47 PM

Sorry for not mentioning that thread as well. The whole point with this thread is not to claim an idea to be mine. It is to provide AutoIt source code. Please search first post for the word purpose.


No prob whatever :confused1:, the purpose of your post what that one, the purpose of my post was to give you some more credits (that you fully deserve) than the ones you attributed yourself.

If you prefer, in my perverted mind :confused1:, I think you were very clever at the time (and still seemingly are) and somehow this opinion of mine had to be expressed.

Of course you are perfectly free to object to this public positive endorsement about your contributions. :cheers:

:frusty:
Wonko

#6 amalux

amalux

    Platinum Member

  • Tutorial Writer
  • 2813 posts
  •  
    United States

Posted 28 July 2011 - 12:25 AM

This looks great, thanks :frusty:

:cheers:

#7 cornflake

cornflake

    Newbie

  • Members
  • 11 posts
  •  
    United States

Posted 02 August 2011 - 12:23 AM

joakim are the DeviceIoControl calls you are now using just as reliable as the method you posted to the VMWare community two years ago? Also, I've got to say it's pretty annoying that VMWare has so little information on that problem. When I first encountered it years ago it took a lot of time to figure out the solution (in my case take the disk offline). Do you happen to know why they haven't addressed this issue in their Workstation product?

I notice you are using DISMOUNT_VOLUME and msdn says about that:

The operating system does not detect unmounted volumes. If an attempt is made to access an unmounted volume, the operating system then tries to mount the volume. For example, a call to GetLogicalDrives triggers the operating system to mount unmounted volumes.


What I am curious about is if I dismount a volume and start a virtual machine using that volume, will the host operating system attempt to mount the volume in any case? Is that possible given that it's in use by VMWare workstation?

#8 joakim

joakim

    Silver Member

  • Team Reboot
  • 912 posts
  • Location:Bergen
  •  
    Norway

Posted 02 August 2011 - 06:13 AM

According to the documentation at msdn, the locks will be released if the calling process that made the lock (or dismount) is closed. That means if you use LockVolume or LockDismount and launch a vm from physical disk, you are at a risk that something may go wrong. For instance if the program (LockVolume or LockDismount ) is accidentally closed, your host will immediately try to mount the unlocked volume, and you may end up with a corrupted FS. Therefore it would be safer to use these programs if we could prevent them from accidentally being closed (at this point LockDismount is 1 step safer because it can be run hidden (if in cmdline mode). Maybe TheK can correct me if I'm wrong about LockDismount..

However, the host system can attempt (but not succeed) at mounting a dismounted volume as long as it's locked.

So if you are using the whole \\.\PhysicalDriveN for your vm, I would recommend taking the disk offline (because it's way harder to accidentally putting the disk online again).

Why VMware still haven't figured this out, is still a mistery to me, but I guess they have their reasons. It should be fairly simple for them to implement these api's in their main executable in workstation/player.:cheers:

#9 paraglider

paraglider

    Gold Member

  • .script developer
  • 1716 posts
  • Location:NC,USA
  •  
    United States

Posted 02 August 2011 - 11:53 AM

Certainly is a bad idea to share a physical drive mounted in a VM with the host OS. I tried that once and finished up with a corrupted drive that had to be reformatted.

#10 joakim

joakim

    Silver Member

  • Team Reboot
  • 912 posts
  • Location:Bergen
  •  
    Norway

Posted 02 August 2011 - 12:27 PM

Certainly is a bad idea to share a physical drive mounted in a VM with the host OS. I tried that once and finished up with a corrupted drive that had to be reformatted.


He he, I messed it up when creating the ugly workaround 2 years ago, where I clicked Yes when asked to initialize new disk.. Which resulted in a new overwritten partition table. However, I was lucky enough to be able to recreate the original one, but learned my lesson.

#11 razz

razz
  • Members
  • 3 posts
  •  
    European Union

Posted 25 October 2014 - 10:15 PM

Thank you joakim! A very useful tool!

Some people (me :) ) are removing drive letters from volumes before start virtual machine.
Could you please add support working with such volumes without drive letters ("\\.\PhysicalDrive1\Volume2" instead of "F:" for example)?!

Edited by razz, 25 October 2014 - 10:18 PM.


#12 joakim

joakim

    Silver Member

  • Team Reboot
  • 912 posts
  • Location:Bergen
  •  
    Norway

Posted 26 October 2014 - 09:11 PM

Hi

 

I doubt that there will be any updates to this old tool, unfortunately. Maybe you can find a workaround to not remove the driveletter before lock/dismounting it. Out of curiosity, what virtualization method are you using with raw disk access?



#13 razz

razz
  • Members
  • 3 posts
  •  
    European Union

Posted 03 November 2014 - 03:03 AM

joakim, on 26 Oct 2014 - 11:11 PM, said:
what virtualization method are you using with raw disk access?

I just needed write access to a physical partition for a VirtualBox VM in W7 host system.

Thank you joakim for the source code! I took it and couple lessons of AutoIt, so now I have my modification of your tool. Now it can lock partitions without mount points and delete/restore volume letters. I post it here soon.

Edited by razz, 03 November 2014 - 03:10 AM.


#14 joakim

joakim

    Silver Member

  • Team Reboot
  • 912 posts
  • Location:Bergen
  •  
    Norway

Posted 03 November 2014 - 03:23 PM

That sounds great! You are welcome.



#15 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13649 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 07 November 2014 - 11:13 AM

... so now I have my modification of your tool. Now it can lock partitions without mount points and delete/restore volume letters. I post it here soon.

 

...and are you planning to keep it all for yourself or maybe you are willing to share the modified code/tool? :unsure:

 

:duff:

Wonko



#16 razz

razz
  • Members
  • 3 posts
  •  
    European Union

Posted 07 November 2014 - 02:20 PM

Just now got how to fix a small stupid bug. Here you go :)
LockDismountRemove 0.04

#17 joakim

joakim

    Silver Member

  • Team Reboot
  • 912 posts
  • Location:Bergen
  •  
    Norway

Posted 07 November 2014 - 04:38 PM

Nice. Thanks for sharing.



#18 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13649 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 07 November 2014 - 07:07 PM

Very good, thanks.  :)

 

I am re-posting it as attachment so that hopefully it doesn't get lost (for inactivity or whatever makes mediafire links invalid after some time).

 

:duff:

Wonko

Attached Files






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users