Jump to content

WinAPIVhd UDF (WinAPIEx UDF Extension)


Yashied
 Share

Recommended Posts

Hi Yashied, nicely done.
 
somehow your examples missing #include <WinAPIVhd.au3>, if running from scite.
But's fine from explorer.
 
You could add support for vhdx, if @OSBuild >= 9200.
Edited by JFX
Link to comment
Share on other sites

  • 1 month later...

Thank you very much for this great UDF!

I tired it and created a virtual disk

Open: OK
Attach: OK
GUID: {XXXXXXXXXXXXXXXXXXXXXXXXX}
Size: 128 МБ
VHD (.PHYSICALDRIVE1) has been successfully opened and ready for use!

What I can't understand, when I am trying to access it from windows explorer it says : Can't access file because it is busy

How can I make it accessable?

Great thanx in advance!
 

Link to comment
Share on other sites

  • 2 weeks later...

Thanks Yashield !

I was working on virtdisk.dll when i fall on your great work.

But something puzzles me, i'm on Win7 and my virtdisk.dll have only 12 functions :

 

AttachVirtualDisk
CompactVirtualDisk
CreateVirtualDisk
DetachVirtualDisk
ExpandVirtualDisk
GetStorageDependencyInformation
GetVirtualDiskInformation
GetVirtualDiskOperationProgress
GetVirtualDiskPhysicalPath
MergeVirtualDisk
OpenVirtualDisk
SetVirtualDiskInformation
 
instead of the 20 of your UDF  :huh2:

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

@topten

I think the reason may be some kind of third-party programs such as antivirus or something like that. Always works fine for me.

@wakillon

Look more carefully at the functions. Some functions (_WinAPI_Create*VirtualDiskParameters*()) is auxiliary and not included in the dll.

Link to comment
Share on other sites

@wakillon

Look more carefully at the functions. Some functions (_WinAPI_Create*VirtualDiskParameters*()) is auxiliary and not included in the dll.

 

AddVirtualDiskParent
BreakMirrorVirtualDisk
DeleteVirtualDiskMetadata
EnumerateVirtualDiskMetadata
GetVirtualDiskMetadata
MirrorVirtualDisk
ResizeVirtualDisk
SetVirtualDiskMetadata
 
This 8 functions names are not auxiliary and are not displayed in "Dll Export Viewer" for my virtdisk.dll.
 
Is there different versions of this dll ?
 
Edit1 : Same result with "DllExportFinder"
 
Edit2 : As i'm under windows 7 family premium, may be it's different on Windows 7 Enterprise and Windows 7 Ultimate.
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

AddVirtualDiskParent

BreakMirrorVirtualDisk

DeleteVirtualDiskMetadata

EnumerateVirtualDiskMetadata

GetVirtualDiskMetadata

MirrorVirtualDisk

ResizeVirtualDisk

SetVirtualDiskMetadata

 

This 8 functions names are not auxiliary and are not displayed in "Dll Export Viewer" for my virtdisk.dll.

These functions require Windows 8 or later.

https://msdn.microsoft.com/en-us/library/windows/desktop/dd323699(v=vs.85).aspx

Link to comment
Share on other sites

  • 1 year later...

Hi,

i try to play with this udf.

The initialize step should format the virtual drive but it doesn't on my computer (win 7 pro).

I tried to change partition type with $PARTITION_FAT_32 but same result.

I saw some GPT[x] name but ...

The result of initialize is ok but windows ask for formatting, if i accept, windows show an error : he can't format

What must i change to obtain a formated drive by script?

If i open and close one vhd of mine, it's ok.

 

 

 

Edited by kaz
Link to comment
Share on other sites

after asking google and looking in detail the initialize function i i found something interesting.

Then offset must of one partition is most commun 64 KB (with  sector size 512-byte sectors ) or a multiple of.

So, i modified the line :

DllStructSetData($tPIEX, 'StartingOffset', 0) 

by

DllStructSetData($tPIEX, 'StartingOffset', 64 * 2 *  DllStructGetData($tDG, 'BytesPerSector'))

and the line :

DllStructSetData($tVI, 'StartingOffset', 0)

by

DllStructSetData($tVI, 'StartingOffset', DllStructGetData($tPIEX, 'StartingOffset'))

The script create a valide partition now. When it mounted the first time, windows ask for formatting. No error obtain now.

i didn't find solution to avoid this external step.

 

Edited by kaz
Link to comment
Share on other sites

  • 2 years later...
  • Moderators

@juniq did you happen to notice this thread is more than 4 years old? Perhaps what worked in 2015 doesn't work the same in 2019. If you would like to actually contribute to the thread, rather than a blanket "fix your errors", why don't you point out spots where you are running into issue and what you would do to fix it? ;)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • 3 years later...

Dear all, I know that this thread is several years old but maybe JFX or others have a suggestion for what I'm looking for.

To reply to juniq or to others who might want to test this nice UDF: to make it work you just need to add to the scripts the missing Iif function.

Func __Iif($fTest, $vTrueVal, $vFalseVal)
    Return $fTest ? $vTrueVal : $vFalseVal
EndFunc   ;==>__Iif

Once the UDF finds the function it works with latest AutoIt release. Then the only extra fix needed it the one Kaz pointed out in his previous comment.

Concerning my issue, I'm trying to get the VHD source path once an OS booted from a VHD via bootmgr. Unfortunately Diskpart is not reliable and I have a batch script which is slow and more a mock-up than a real script. If you're interested you can read the details in this post of reboot.pro.

Besides DiskPart method I've been looking for a Windows API to do that without success. I don't know where to look for. Yesterday I just found that UsbDriveInfo.exe from Uwe Sieber has this information when you click on the FileBackedVirtual Bus volumes (see attached picture). I tried to find anything related to "Container" information in WinAPIs but without success.

Has anybody here any clue on how to be able to use AutoIt instead of the slow (and unreliable) DiskPart to retreive the original VHD path of a booted virtual volume ?

Thanks for any suggestion you might give me,

V.

Edit: BTW if you're on an x64 OS and you run the 32bit version of UsbDriveInfo the "Container" field will not appear.

 

FileBackedVirtual Volumes Info.png

Edited by Virgus
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...