Jump to content











Photo
- - - - -

Retrieving device/drive information


  • Please log in to reply
100 replies to this topic

#1 Zharif

Zharif

    Frequent Member

  • .script developer
  • 152 posts
  • Location:Germany
  •  
    Germany

Posted 07 May 2015 - 04:01 PM

In regard to this thread I decided to write my own commandline tool to gather some drive information. This tool is written in VB6 and follows the "mountvol" - style in main. I did not try to reinvent a wheel but to cover more info and functions in one commandline tool. It uses pure API calls and is bound on their features and restrictions.
I will certainly name the used API calls and functions in particular if somebody is interested (don't want to open a VB-Thread).
It has been fully tested on my Win8.1 OS and partially on WinXP and WinVista. My time for coding was -and is still limited, although started several month before.

This post is intended to discuss if it's a senseless tool or if you think it has some kind of worth (am I in the right forum here?).
If deemed to be useful, what should be changed/deleted/added to improve it?
Which kind of information is not available? Some (error-) messages?

 

 

Here is a "short" description of zDInfo:

zDInfo without parameters:
An extended set of drive and partition information is displayed.

No elevation of the command prompt is needed.

 

zDInfo /ELEVATE [<any set of arguments below>]
Must be the first switch.
Opens a console in admin mode running zSDInfo.exe (COMSPEC /k).
All commands listed below can be passed with the /ELEVATE prefix to
grant elevated rights .

 

Stand-alone switches:
Any of these must be the first switch. Others will be ignored.

 

/VM:[{<DrvLetter>|<NTFS-DirectoryFolder>}] [<Guid>]
Associates a volume with a directory on another volume or a drive letter.
A Mountpoint may be a drive letter or a fully qualified directory on
another volume. Non-existing path structures will be created. To associate
a volume with a directory that has any files or subdirectories in it is
treated as an error. If a mountpoint contains a path to a mounted folder,
a ""Dir not empty"" error will be displayed, even if the directory is empty.
Elevated rights are required.

/VU:[{<Guid>|<DrvLetter>|<NTFS-DirectoryFolder>}]
Deletes a drive letter or a mounted NTFS-directory folder.
If a GUID is used, ALL associations will be deleted.
If input is a remote drive ""Net Use <Input> /d /y"" is called.
Elevated rights are required.

/L:[{<Guid>|<DrvLetter>}] [<VolumeLabel>]
Sets a volume label by passing a GUID or a drive letter.
By passing a GUID, writing to unmounted volumes is supported.
To write a VolumeLabel that contains spaces, doublequotes must be added.
An empty value or two consecutive doublequotes blanks the volume label.
Elevated rights may be required.
 

Optional filter switches that may be combined in a useful manner:

 

/DL:[{1|2}] = DiskGetDriveLayoutEx Filter:
  if omitted show all detected Drvs and Parts.
  1  show DiskGetDriveLayoutEx entries only (including CD/DVDRoms)
  2  show unknown Devs/Parts only (retrieve drive/partition entries
      of GUIDs or mapped DrvLetters not detected by DiskGetDriveLayoutEx)
      A ""ud""-prefix followed by a count number is assigned for unknown devices
 
/DF:[{1|2}] = DriveOrPartition Filter:
  if omitted show Drvs and PartEntries.
  1  show Drvs only
  2  show Parts only
 

/PF:[{1|2}] = Partition Filter:
  if omitted show only PartEntries with PartNr > 0.
  1  show all PartEntries with non-empty sizes (this option shows extended
      partition info or partition entries invisible to mountmgr)
  2  show all PartEntries (full DiskGetDriveLayoutEx)
 
/MF:[{1|2}] = Mount Filter:
  if omitted show mounted and unmounted PartEntries.
  1  show mounted PartEntries only
  2  show unmounted PartEntries only

 

/TF:[{2|3|4|5|6}] = DriveType Filter:
  if omitted show all DrvTypes.
  2  show Removable Drvs only
  3  show Fixed Drvs only
  4  show Remote (network) Drvs only
  5  show CD/DVD-Rom Drvs only
  6  show Ramdisk Drvs only

/SF:[{B|K|M|G|T}] = SizeUnit Filter:
  if omitted attempt to detect size units automatically.
  B  sizes as Bytes
  K  sizes as Kilobytes
  M  sizes as Megabytes
  G  sizes as Gigabytes
  T  sizes as Terabytes
 
/FF:[{1|2|3}] = VolumeFilesystemFlags Filter:
  if omitted don't show FilesystemFlags.
  1  show all FilesystemFlags
  2  show Flags tagged as True for each partition
  3  show Flags tagged as False for each partition
 

NOTES:
-  Command line input is case-insensitive.
-  Any input containing spaces must be surrounded by doublequotes.
-  Drive letters can be passed without a disk designator and/or a backslash.
-  Directory pathes must be fully qualified - no relative pathes are allowed.
-  Errorlevels are supported. If no error occurs exitcode is 0.
   On errors the exitcode is a two- or three digit number, where the first digit always
   returns the procedure number. The remaining numbers return the corresponding
   VB/API-Error.
-  Output entry, DrvBusType: WinVista reports SATA drives as ATA. Win7 reports
   SATA drives in PATA mode as ATA.
 

Some Examples:

Any of these commands can be prefixed with /ELEVATE

zdInfo /L:C "Lbl Space"                              Label of drive letter C:\ becomes Lbl Space
zdInfo /L:D ""                                              Blank label of drive letter D:\
zDInfo /VM:Z <GUID>                               Associate a volume GUID with drive letter Z:\
zDInfo /VM:D:\tmp\MountZ <GUID>       Associate a volume GUID with directory D:\tmp\MountZ
zDInfo /VM:"D:\tmp\Mount Z" <GUID>   Associate a volume GUID with directory D:\tmp\Mount Z
zDInfo /VU:D                                              Unmount drive letter D:\

 

zDInfo /FF:3                                         Default listing (Drvs and Parts); additionally show all VolumeFilesystemFlags

zDInfo /TF:3                                         Default listing (Drvs and Parts) but show fixed Drvs only

zDInfo /TF:3 /DF:2                               Show partition entries of fixed Drvs

zDInfo /TF:3 /DF:2 /PF:2                      Show ALL partition entries of fixed Drvs
zDInfo /TF:3 /DF:2 /PF:2 /MF:1            Show ALL partition entries of fixed Drvs if mounted

 

 

Here's a list of needed/used API's and supported output values:

Spoiler

 

 

- Latest version here (extract zDInfo.exe from zip archive) -

Attached Files


  • Nuno Brito likes this

#2 erwan.l

erwan.l

    Gold Member

  • Developer
  • 1985 posts
  • Location:Nantes - France
  •  
    France

Posted 07 May 2015 - 04:32 PM

Hi Zharif,

 

Thanks for sharing.

 

I cannot open your zip file.

Although I could not open it, make sure you distribute the vb runtime with it (msvbvm60.dll and vb6.dll).

As vb6 is quite rare these days, not everyone will have these dll's in their systems.

 

For the dev guys outhere, you may want to tell which API you are using.

 

Regards,

Erwan



#3 Zharif

Zharif

    Frequent Member

  • .script developer
  • 152 posts
  • Location:Germany
  •  
    Germany

Posted 07 May 2015 - 05:00 PM

Thanks for response erwan.l.

 

I can't reproduce your problem. I just downloaded the file, removed the zip extension, opened a command prompt, typed in zdinfo.exe and everything is as it should to be.

 

Ok, here's the list of used API's:

For any API, if a unicode version exist,

a unicode system-check decides if the A- or W version is used.

 

Edit: updated list in the first post


SOME LINKS:
  http://blogs.msdn.co.../16/408947.aspx
  http://blogs.msdn.co.../04/414806.aspx



#4 erwan.l

erwan.l

    Gold Member

  • Developer
  • 1985 posts
  • Location:Nantes - France
  •  
    France

Posted 07 May 2015 - 05:43 PM

If you mean the zip file is actually an exe file to which you appended a zip file extension, it may explain my problem.

I would advise to actually put the exe in a zip file.

 

edit : re reading your post i missed the "Rename zDInfo.exe.zip to zDInfo.exe" the first time...



#5 Zharif

Zharif

    Frequent Member

  • .script developer
  • 152 posts
  • Location:Germany
  •  
    Germany

Posted 07 May 2015 - 05:46 PM

Your're welcome.

I'm simply pleased that somebody is willing to test this utility.



#6 erwan.l

erwan.l

    Gold Member

  • Developer
  • 1985 posts
  • Location:Nantes - France
  •  
    France

Posted 07 May 2015 - 07:05 PM

Works fine on my win 8.1 64 bits.

 

you could add the drivelayout (partition style, partition count, disk id).



#7 Zharif

Zharif

    Frequent Member

  • .script developer
  • 152 posts
  • Location:Germany
  •  
    Germany

Posted 07 May 2015 - 07:18 PM

Thanks for the time you spend.

I must confess not to know what you exactly mean with "partition style".

Regarding your remaining suggestions the "partition count" (DevicePartitionNr.) and the disk id is already implemented.

Or did I mistake your suggestions?

Maybe you could provide an example syntax?



#8 Zharif

Zharif

    Frequent Member

  • .script developer
  • 152 posts
  • Location:Germany
  •  
    Germany

Posted 07 May 2015 - 07:56 PM

New version. Fixed wrong syntax for the /ELEVATE switch.

Download link updated.



#9 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 08 May 2015 - 07:15 PM

It seems like nice.  :thumbsup:

 

A couple (preliminary) notes, if I may.

 

IMHO the default should be the /MP switch and if one really wants to have less information (similar to MOUNTVOL) then he should use a new  /MV switch

 

The output can be potentially be bettered (to the scope of easier parsing it from batch, as it is parsing it is made needlessly complex).

This:

 

*********** [MAXTOR STM3320820AS ATA Device] \\.\PHYSICALDRIVE0
DevPath: \Device\HarddiskVolume1
VolGuid: \\?\Volume{83092730-6bfc-11df-b90c-806d6172696f}\
PartInfo: \\.\Device\Harddisk0\Partition1
VolMP: C:\

*********** [MAXTOR STM3320820AS ATA Device] \\.\PHYSICALDRIVE1
DevPath: \Device\HarddiskVolume2
VolGuid: \\?\Volume{b0b284c4-8a33-11dd-8781-806d6172696f}\
PartInfo: \\.\Device\Harddisk1\Partition1
VolMP: D:\

 

 

Could become (say):

 

Devname:[MAXTOR STM3320820AS ATA Device] 

PhysDisk:\\.\PHYSICALDRIVE0
DevPath:\Device\HarddiskVolume1
VolGuid:\\?\Volume{83092730-6bfc-11df-b90c-806d6172696f}\
PartInfo:\\.\Device\Harddisk0\Partition1
VolMP:C:\

DevName:[MAXTOR STM3320820AS ATA Device] 

PhysDisk:\\.\PHYSICALDRIVE1
DevPath:\Device\HarddiskVolume2
VolGuid:\\?\Volume{b0b284c4-8a33-11dd-8781-806d6172696f}\
PartInfo:\\.\Device\Harddisk1\Partition1
VolMP:D:\

 

This way there is a "same" separator on each line (the colon :, but an equal = sign would do nicely as well ) and each line has the same format ObjectName:Data or ObjectName=Data, this latter would have the advantage of being easier to use for variable assignments.

 

Adding to the output (possibly only when a further - say - /GD switch is added) a "simple, logical" identification *like* the ones grub4dos uses), i.e.

Devname[hd0,0]:[MAXTOR STM3320820AS ATA Device] 

PhysDisk[hd0,0]:\\.\PHYSICALDRIVE0
DevPath[hd0,0]:\Device\HarddiskVolume1
VolGuid[hd0,0]:\\?\Volume{83092730-6bfc-11df-b90c-806d6172696f}\
PartInfo[hd0,0]:\\.\Device\Harddisk0\Partition1
VolMP[hd0,0]:C:\

 

 

Devname[cd0] [ASUS DRW-2014S1T ATAPI Device]
DevPath[cd0]: \Device\CdRom0
VolGuid[cd0]: \\?\Volume{80cf88c2-8a34-11dd-813c-806d6172696f}\
PartInfo[cd0]: \\.\Device\CDRom0
VolMP[cd0]: I:\

 

or - still say - hd0_0-Devname, hd0_0-PhysDisk, etc. would further simplify batch parsing/variable assigning.

 

The /V option is confusing, any switch should never have different meaning, if you want to keep /V for "Version", than change "Verbose" to (say) /VV (as in Very Verbose, and BTW all "additional arguments" would be two letters ones).

 

Though it has no consequences in practice, the SAME output when using two different switches, namely GUID|MP is not advised, choose (say) /MP and that's it.

 

:duff:

Wonko



#10 Zharif

Zharif

    Frequent Member

  • .script developer
  • 152 posts
  • Location:Germany
  •  
    Germany

Posted 09 May 2015 - 04:14 AM

Thanks for reply Wonko, as always - much appreciated.

BTW, I like your opening statement: "It seems like nice."

Everything you suggested IS possible.

 

But at first:

 

IThough it has no consequences in practice, the SAME output when using two different switches, namely GUID|MP is not advised, choose (say) /MP and that's it.

 

Indeed, it has consequences in practice.

Choosing /GUID enumerates all local GUID's found on the system.

Feature:     Output will display any mounted AND unmounted, formatted partition or volume.

Drawback: If a network drive is mounted with a drive letter (e.g. NAS share, network printer) for which no GUID

                   exist (cause it's not local) it will not be displayed.

 

Choosing /MP enumerates all drive letters found on the system.

Feature: Output will display any formatted partition or volume AND network drives that have a drive letter assigned

Drawback: Any unmounted partition will not be displayed.

 

It may be discussed which output is better.

In assumption that somebody need info about physical devices in main, the GUID switch seems to be more convenient for me.?

Personally, I think it's good to have both switches for crosschecking existance of ALL devices found.

 

About your remaining suggestions:

Very good ideas, especially about grub4dos (from which I don't know anything). Will implement this switch in the next version.

Just to clarify (I think I know the answer - but just to go sure):

[hd0,0] = harddisk 1, partition 1

[hd0,1] = harddisk 1, partition 2

[hd1,0] = harddisk 2, partition 1

.. as known from unix based OS'es?

 

About /V and /VV - I've overseen this - thanks very much. This will be changed in the next version.

 

About the output in main - you're right, for scripting guys like us it will be more simple to prepend a Find/Findstr command to get formatted output if the asterixes are missing and the PhysicalDriveNr gets it's own line.

 

But please remember some drawbacks then:

I added the asterixes and left out model-strings because if somebody (like me) has more than one HDD, and each of it has more than one partition, the model-string is only displayed once for each HDD. The asterixes visualise, that we're talking about the same HDD. If I follow your suggestion, for any partition found on one HDD, the model-string and PhysicalDriveNr. is displayed that makes the output harder to read.??

 

Hope my english was good enough to follow me.

 

Please have a look at these examples:

Current output for my hardware configuration

- external USB3.0 drive plugged in, 4 partitions; 2 primary, 1 container with 2 partitions, 3 mounted

- a mounted network share from my NAS (drive letter Z:\)

 

Command zDInfo /MP

 

 

*********** [Samsung SSD 840 EVO 250GB SATA Device]  \\.\PHYSICALDRIVE0
DevPath:    \Device\HarddiskVolume1
VolGuid:    \\?\Volume{fdf59bef-f233-11e3-824f-806e6f6e6963}\
PartInfo:   \\.\Device\Harddisk0\Partition1
VolMP:      C:\

*********** [ST4000DM000-1F2168 SATA Device]  \\.\PHYSICALDRIVE1
DevPath:    \Device\HarddiskVolume2
VolGuid:    \\?\Volume{b8321c52-3f49-43ae-59a2-459f4c50ae21}\
PartInfo:   \\.\Device\Harddisk1\Partition1
VolMP:      D:\

DevPath:    \Device\HarddiskVolume3
VolGuid:    \\?\Volume{4caf39e4-9431-43a9-816c-4ff4b86fbf02}\
PartInfo:   \\.\Device\Harddisk1\Partition2
VolMP:      E:\

*********** [ST3000DM001-9YN166 SATA Device]  \\.\PHYSICALDRIVE2
DevPath:    \Device\HarddiskVolume4
VolGuid:    \\?\Volume{5d88bcf4-6604-4397-971b-e7e1a9ea35e3}\
PartInfo:   \\.\Device\Harddisk2\Partition1
VolMP:      F:\

DevPath:    \Device\HarddiskVolume5
VolGuid:    \\?\Volume{da5d59bd-3539-4c31-89e3-365773211e1e}\
PartInfo:   \\.\Device\Harddisk2\Partition2
VolMP:      G:\

*********** [HL-DT-ST DVD-ROM GDRH20N SATA Device]
DevPath:    \Device\CdRom1
VolGuid:    \\?\Volume{fdf59bf5-f233-11e3-824f-806e6f6e6963}\
PartInfo:   \\.\Device\CDRom1
VolMP:      H:\

*********** [HL-DT-ST BD-RE  BH10LS38 SATA Device]
DevPath:    \Device\CdRom0
VolGuid:    \\?\Volume{fdf59bf6-f233-11e3-824f-806e6f6e6963}\
PartInfo:   \\.\Device\CDRom0
VolMP:      I:\

*********** [Generic- Compact Flash USB Device]  \\.\PHYSICALDRIVE3
DevPath:    \Device\HarddiskVolume6
VolGuid:    \\?\Volume{fdf59c08-f233-11e3-824f-806e6f6e6963}\
PartInfo:   \\.\Device\Harddisk3\Partition1
VolMP:      J:\

*********** [Generic- SM/xD-Picture USB Device]  \\.\PHYSICALDRIVE4
DevPath:    \Device\HarddiskVolume7
VolGuid:    \\?\Volume{fdf59c09-f233-11e3-824f-806e6f6e6963}\
PartInfo:   \\.\Device\Harddisk4\Partition1
VolMP:      K:\

*********** [Generic- SD/MMC USB Device]  \\.\PHYSICALDRIVE5
DevPath:    \Device\HarddiskVolume8
VolGuid:    \\?\Volume{fdf59c0b-f233-11e3-824f-806e6f6e6963}\
PartInfo:   \\.\Device\Harddisk5\Partition1
VolMP:      L:\

*********** [Generic- MS/MS-Pro USB Device]  \\.\PHYSICALDRIVE6
DevPath:    \Device\HarddiskVolume9
VolGuid:    \\?\Volume{fdf59c0d-f233-11e3-824f-806e6f6e6963}\
PartInfo:   \\.\Device\Harddisk6\Partition1
VolMP:      M:\

*********** [ST1000LM 024 HN-M101MBB USB Device]  \\.\PHYSICALDRIVE7
DevPath:    \Device\HarddiskVolume10
VolGuid:    \\?\Volume{63bf099e-3be7-11e4-82d3-f46d046659f7}\
PartInfo:   \\.\Device\Harddisk7\Partition1
VolMP:      N:\

DevPath:    \Device\HarddiskVolume11
VolGuid:    \\?\Volume{53002ca7-95f8-11e4-8381-f46d046659f7}\
PartInfo:   \\.\Device\Harddisk7\Partition3
VolMP:      O:\

DevPath:    \Device\HarddiskVolume13
VolGuid:    \\?\Volume{b8d5f49e-982e-11e4-8389-f46d046659f7}\
PartInfo:   \\.\Device\Harddisk7\Partition2
VolMP:      Q:\

*********** [Unknown Device]
DevPath:    \Device\LanmanRedirector\;Z:0000000000022711\Zphere\MSc
VolGuid:
PartInfo:
VolMP:      Z:\

 

 

 

and now zDInfo /GUID:

 

 

*********** [Samsung SSD 840 EVO 250GB SATA Device]  \\.\PHYSICALDRIVE0
DevPath:    \Device\HarddiskVolume1
VolGuid:    \\?\Volume{fdf59bef-f233-11e3-824f-806e6f6e6963}\
PartInfo:   \\.\Device\Harddisk0\Partition1
VolMP:      C:\

*********** [ST4000DM000-1F2168 SATA Device]  \\.\PHYSICALDRIVE1
DevPath:    \Device\HarddiskVolume2
VolGuid:    \\?\Volume{b8321c52-3f49-43ae-59a2-459f4c50ae21}\
PartInfo:   \\.\Device\Harddisk1\Partition1
VolMP:      D:\

DevPath:    \Device\HarddiskVolume3
VolGuid:    \\?\Volume{4caf39e4-9431-43a9-816c-4ff4b86fbf02}\
PartInfo:   \\.\Device\Harddisk1\Partition2
VolMP:      E:\

*********** [ST3000DM001-9YN166 SATA Device]  \\.\PHYSICALDRIVE2
DevPath:    \Device\HarddiskVolume4
VolGuid:    \\?\Volume{5d88bcf4-6604-4397-971b-e7e1a9ea35e3}\
PartInfo:   \\.\Device\Harddisk2\Partition1
VolMP:      F:\

DevPath:    \Device\HarddiskVolume5
VolGuid:    \\?\Volume{da5d59bd-3539-4c31-89e3-365773211e1e}\
PartInfo:   \\.\Device\Harddisk2\Partition2
VolMP:      G:\

*********** [ST1000LM 024 HN-M101MBB USB Device]  \\.\PHYSICALDRIVE7
DevPath:    \Device\HarddiskVolume10
VolGuid:    \\?\Volume{63bf099e-3be7-11e4-82d3-f46d046659f7}\
PartInfo:   \\.\Device\Harddisk7\Partition1
VolMP:      N:\

DevPath:    \Device\HarddiskVolume11
VolGuid:    \\?\Volume{53002ca7-95f8-11e4-8381-f46d046659f7}\
PartInfo:   \\.\Device\Harddisk7\Partition3
VolMP:      O:\

DevPath:    \Device\HarddiskVolume12
VolGuid:    \\?\Volume{0e76b9c9-97c7-11e4-8387-f46d046659f7}\
PartInfo:   \\.\Device\Harddisk7\Partition4
VolMP:      *** Not mounted ***

DevPath:    \Device\HarddiskVolume13
VolGuid:    \\?\Volume{b8d5f49e-982e-11e4-8389-f46d046659f7}\
PartInfo:   \\.\Device\Harddisk7\Partition2
VolMP:      Q:\

*********** [Generic- Compact Flash USB Device]  \\.\PHYSICALDRIVE3
DevPath:    \Device\HarddiskVolume6
VolGuid:    \\?\Volume{fdf59c08-f233-11e3-824f-806e6f6e6963}\
PartInfo:   \\.\Device\Harddisk3\Partition1
VolMP:      J:\

*********** [Generic- SM/xD-Picture USB Device]  \\.\PHYSICALDRIVE4
DevPath:    \Device\HarddiskVolume7
VolGuid:    \\?\Volume{fdf59c09-f233-11e3-824f-806e6f6e6963}\
PartInfo:   \\.\Device\Harddisk4\Partition1
VolMP:      K:\

*********** [Generic- SD/MMC USB Device]  \\.\PHYSICALDRIVE5
DevPath:    \Device\HarddiskVolume8
VolGuid:    \\?\Volume{fdf59c0b-f233-11e3-824f-806e6f6e6963}\
PartInfo:   \\.\Device\Harddisk5\Partition1
VolMP:      L:\

*********** [Generic- MS/MS-Pro USB Device]  \\.\PHYSICALDRIVE6
DevPath:    \Device\HarddiskVolume9
VolGuid:    \\?\Volume{fdf59c0d-f233-11e3-824f-806e6f6e6963}\
PartInfo:   \\.\Device\Harddisk6\Partition1
VolMP:      M:\

*********** [HL-DT-ST BD-RE  BH10LS38 SATA Device]
DevPath:    \Device\CdRom0
VolGuid:    \\?\Volume{fdf59bf6-f233-11e3-824f-806e6f6e6963}\
PartInfo:   \\.\Device\CDRom0
VolMP:      I:\

*********** [HL-DT-ST DVD-ROM GDRH20N SATA Device]
DevPath:    \Device\CdRom1
VolGuid:    \\?\Volume{fdf59bf5-f233-11e3-824f-806e6f6e6963}\
PartInfo:   \\.\Device\CDRom1
VolMP:      H:\

 

 

 

Will await your final responses before starting work.

 

 

 



#11 Zharif

Zharif

    Frequent Member

  • .script developer
  • 152 posts
  • Location:Germany
  •  
    Germany

Posted 09 May 2015 - 11:27 AM

Wonko,

I would really like to add the Grub4Dos-thing but I've to translate the API-Output internally.

Please tell me: Are these information correct?

http://diddy.boot-la...iles/syntax.htm

 

This site tells that primary partitions are numbered from 0-3.

But what does Grub4Dos do/output on GPT disks that allow more than 4 primary partitions?

Is access of grub4dos limited to floppy, fixed, cd/dvd-rom and virtual drives?

 

Or do you have something better to read for me?



#12 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 09 May 2015 - 12:37 PM

Yep, the info in the grub4dos guide is correct.

Please consider how the "traditional" way that grub4dos uses is that:
Disks are numbered starting from 0.
Partitions/volumes are numbered as well starting from 0, but more specifically the 4 primary slots in the partition table in the MBR are numbered as 0,1,2,3 so that 4,5,6, etc. are logical volumes in the order they are found in the EMBR chain.
With GPT (where all partitions are primary) the partitions/volumes are enumerated still starting from 0, in the order they appear in the GPT partition table.
grub4dos has a number of other possible devices, but they won't be relevant, the (pd) (rd) and similar devices make no sense once the Windows has been booted.

GRUB2 has introduced a change, keeping disks numbered starting from 0 but numbering partitions starting from 1 (BTW similar to what actually NT does).
Both conventions would be fine, most probably the latter is easier/simpler as the translation should be direct, as an example:
\\.\Device\Harddisk0\Partition1= [hd0,1] in GRUB2 notation whilst this would be [hd0,0] in grub4dos notation
\\.\Device\Harddisk3\Partition1 = [hd3,1] in GRUB2 notation whilst this would be [hd3,0] in grub4dos notation
\\.\Device\Harddisk7\Partition2= [hd7,2] in GRUB2 notation whilst this would be [hd7,1] in grub4dos notation

Substantially the convention adopted does not really matter, as the scope (the one I suggested) is that when you have the tool output the Object name comprising a unique reference it is easier to parse it and to assign variables from batch, it doesn't need to represent an existing convention as long as it doesn't produce "duplicates".
As an example, if the ouput of the tool is:

Devname[hd0,0]=[MAXTOR STM3320820AS ATA Device]
PhysDisk[hd0,0]=\\.\PHYSICALDRIVE0
DevPath[hd0,0]=\Device\HarddiskVolume1
VolGuid[hd0,0]=\\?\Volume{83092730-6bfc-11df-b90c-806d6172696f}\
PartInfo[hd0,0]=\\.\Device\Harddisk0\Partition1
VolMP[hd0,0]=C:\

Devname[cd0]=[ASUS DRW-2014S1T ATAPI Device]
DevPath[cd0]= \Device\CdRom0
VolGuid[cd0]=\\?\Volume{80cf88c2-8a34-11dd-813c-806d6172696f}\
PartInfo[cd0]= \\.\Device\CDRom0
VolMP[cd0]= I:\


FOR /F "tokens=* delims=" %%? IN ('zdinfo /MP') DO SET %%?
would load the whole output as an indexed set of variables.


About GUID/MT I am still not sure to understand the differences and the utility of the two switches. :unsure:
The two quotes you posted, once reordered and compared show only two differences:
in the /GUID there is:
 

DevPath: \Device\HarddiskVolume12
VolGuid: \\?\Volume{0e76b9c9-97c7-11e4-8387-f46d046659f7}\
PartInfo: \\.\Device\Harddisk7\Partition4
VolMP: *** Not mounted ***

which is not in the /MT and in the /MT there is:

*********** [Unknown Device]
DevPath: \Device\LanmanRedirector\;Z:0000000000022711\Zphere\MSc
VolGuid:
PartInfo:
VolMP: Z:\

that is not in the /GUID.

What gives? :dubbio:

The net result (to me and until I understand the subtleties that I am now still failing to grasp :ph34r:) is that NEITHER switches provide a FULL listing of ALL devices, so, to be thorough in the enumeration of devices one needs to run the tool twice, once with /MP and one with the /GUID and remove duplicates, then I would request an /ALL switch that combines the effect of both /MP and /GUID and use this latter one only.

About the asterisks, let's say that I want to know that drive letter C:\ belongs to \\.\PhysicalDrive0, with the "asterisks output" I need to find the corresponding "Partinfo" object, than transform its contents from \\.\Device\Harddisk0\Partition1 to \\.\PHYSICALDRIVE0, when your tool already provides this string exactly as needed (but in its current form is not easily parsable). If you want to use the asterisks it's fine to me if you use them just for "DevName" (and you add as "last askerisk" the = delim) but the "PhysDisk" is IMHO useful "repeated" on each entry for a same hard disk.

:duff:
Wonko

#13 Zharif

Zharif

    Frequent Member

  • .script developer
  • 152 posts
  • Location:Germany
  •  
    Germany

Posted 09 May 2015 - 02:43 PM

I now fully understand your suggestion about the output style.

You want to load everything into environmental variables (variable names must be certainly unique) with the corresponding value. The unique part of the variable names is the partition numbering-suffix.

 

I will do that with the GRUB2 notation first.

Therefore another question: HardDisk prefix="hd", CD/DVD-Rom prefix="cd".

What about card-reading devices? Are they prefixed with "hd" too?

 

I just tested your suggestion to devide variable name and value by a colon or an equal sign only.

The output then becomes really ugly.

What about this one here?

 

DevName    =[Samsung SSD 840 EVO 250GB SATA Device]
PhysDisk      =\\.\PHYSICALDRIVE0
DevPath       =\Device\HarddiskVolume1
VolGuid        =\\?\Volume{fdf59bef-f233-11e3-824f-806e6f6e6963}\
PartInfo        =\\.\Device\Harddisk0\Partition1
VolMP          =C:\

DevName    =[ST4000DM000-1F2168 SATA Device]
PhysDisk      =\\.\PHYSICALDRIVE1
DevPath       =\Device\HarddiskVolume2
VolGuid        =\\?\Volume{b8321c52-3f49-43ae-59a2-459f4c50ae21}\
PartInfo        =\\.\Device\Harddisk1\Partition1
VolMP          =D:\

Possible loop (after unique variable names are established):

for /f "tokens=1* delims= " %%a in ('zdinfo /mp') do set %%a%%b

 

About /GUID and /MP:

Yes, you got the point exactly.

Getting the full list of devices is not possible with one switch only (at the moment).

Certainly it is, but this requires much more coding and I tried to avoid this (at least to keep this proggy as small as possible). My assumption was, that a user is either interested in getting all guids or in all drive letters (each result may differ slightly from the other).

But you may be right. An /ALL switch might be better, or no switches at all but to show "ALL" by default.

If you think that this is the best solution - I will try this.

 

 

 

About the asterisks, let's say that I want to know that drive letter C:\ belongs to \\.\PhysicalDrive0, with the "asterisks output" I need to find the corresponding "Partinfo" object, than transform its contents from \\.\Device\Harddisk0\Partition1 to \\.\PHYSICALDRIVE0, when your tool already provides this string exactly as needed (but in its current form is not easily parsable). If you want to use the asterisks it's fine to me if you use them just for "DevName" (and you add as "last askerisk" the = delim) but the "PhysDisk" is IMHO useful "repeated" on each entry for a same hard disk.

 

Okay,I will play with this.



#14 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 09 May 2015 - 03:39 PM

I am not much a fun of "space padding", but your proposal would do fine, maybe one could "invent" a set of 8 char tags, like:
 
Dev_Name
PhysDisk
Dev_Path
Vol_Guid
PartInfo
Vol_MntP

Which in a command prompt output would make it "nicely aligned".

About the /ALL command it was just a way to have "everything", since one can use the /T: switch to filter them by device Type.

Now what I personally would do is to remove the /M switch which is seemingly an exact duplicate of what Mountvol does and re-use it (the /M switch I mean) to filter all Mounted devices and add a /U switch to list all devices that are not mounted to a drive letter.

The /Lbl switch (which is interesting :thumbsup: as - unlike LABEL - allows to assign the label to a GUID, i.e. also to a not "mounted" to a drive letter volume) could be simplified to /L renaming the current /L to /I (since after all it gives Info), but it all depends on the "final idea", personally I would prefer a good, nice tool that ONLY reports info and a separate tool (let's call it GUIDLBL.EXE as an example) that actually can change *anything* on the system, this way the actual ZDINFO provides INFO ;) ONLY and it becomes perfectly safe in the hands of everyone (no risk of making any change if a "wrong" switch is issued) and maybe - but this will need to be verified - there wouldn't even be the need to elevate at all. :unsure:

 

Card readers to all effects are \\.\PhysicalDrive(s) this is the output of zdinfo /MP /T:2 on my machine:

 

zdinfo /MP /T:2

*********** [Generic USB SD Reader USB Device] \\.\PHYSICALDRIVE2
DevPath: \Device\Harddisk2\DP(1)0-0+8
VolGuid: \\?\Volume{dcb7316e-341c-11e3-b06c-001fc6bb76ce}\
PartInfo: \\.\Device\Harddisk2\Partition1
VolMP: E:\

*********** [Generic USB CF Reader USB Device] \\.\PHYSICALDRIVE3
DevPath: \Device\Harddisk3\DP(1)0-0+9
VolGuid: \\?\Volume{dcb7316f-341c-11e3-b06c-001fc6bb76ce}\
PartInfo: \\.\Device\Harddisk3\Partition1
VolMP: G:\

*********** [Generic USB SM Reader USB Device] \\.\PHYSICALDRIVE4
DevPath: \Device\Harddisk4\DP(1)0-0+a
VolGuid: \\?\Volume{dcb73170-341c-11e3-b06c-001fc6bb76ce}\
PartInfo: \\.\Device\Harddisk4\Partition1
VolMP: H:\

*********** [Generic USB MS Reader USB Device] \\.\PHYSICALDRIVE5
DevPath: \Device\Harddisk5\DP(1)0-0+b
VolGuid: \\?\Volume{dcb73171-341c-11e3-b06c-001fc6bb76ce}\
PartInfo: \\.\Device\Harddisk5\Partition1
VolMP: J:\

 

(with all slots empty) which shows one of the possible issues with the "translation" :(, as in grub4dos or GRUB2 notation there would be no partitions on those, so it would be a matter of deciding how to deal with the issue, which would affect all "Removable" drives that are not partitioned (i.e. including possibly "standard" USB sticks) :dubbio: AFAIK/AFAICR *any* device that has DP(n) in DevPath is "Removable". 

 

:duff:

Wonko



#15 Zharif

Zharif

    Frequent Member

  • .script developer
  • 152 posts
  • Location:Germany
  •  
    Germany

Posted 09 May 2015 - 04:43 PM

Card readers to all effects are \\.\PhysicalDrive(s) this is the output of zdinfo /MP /T:2 on my machine:

...(with all slots empty) which shows one of the possible issues with the "translation" :(, as in grub4dos or GRUB2 notation there would be no partitions on those, so it would be a matter of deciding how to deal with the issue, which would affect all "Removable" drives that are not partitioned (i.e. including possibly "standard" USB sticks) :dubbio: AFAIK/AFAICR *any* device that has DP(n) in DevPath is "Removable".

 

Thanks for clarification. Your output is very interesting.

 

Example: DevPath: \Device\Harddisk4\DP(1)0-0+a

                PartInfo: \\.\Device\Harddisk4\Partition1

As I see the last chars are hex numbers (0-0+a = 00A = A = 10).

As from your previous posts I assume that it is not okay to replace "Harddisk4\DP(1)0-0+a" with "HarddiskVolume10"

 

But I don't get your point here.

Till your second last post I assumed to "translate" the "PartInfo"-String to get the Grub* notation.

Harddisk4\Partition1 becomes "[hd4_1]" or "[hd4,1]"?

Please excuse, I can't follow at the moment.

 

So far, I do have some ideas to capture your remaining suggestions.

Will start work (excluding the GRUB2/Gub4Dos translation till I'm very sure to know what I'm doing here).



#16 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 10 May 2015 - 11:07 AM

Well, the grub/grub4dos/grub2 are "logical" and linear.

 

Let's say you have this device (fake for the moment that you have a "special" machine where grub has actually access to this card dreader):

 

*********** [Generic USB SD Reader USB Device] \\.\PHYSICALDRIVE2
DevPath: \Device\Harddisk2\DP(1)0-0+8
VolGuid: \\?\Volume{dcb7316e-341c-11e3-b06c-001fc6bb76ce}\
PartInfo: \\.\Device\Harddisk2\Partition1
VolMP: E:\

 

 

The WHOLE device will be (hd2).

In WIndows NT that will be \\.\PhysicalDrive2.

Till now everything is fine and dandy.

 

The "grub" family (correctly BTW) does NOT care whether the device is "fixed" or "removable", it checks the first sector of the device.

If it is all 00's the device "remains" (hd2).

If it is a bootsector (i.e. the first sector has a BPB) the device ALSO "remains" (hd2) AND the volume in it (since the first sector has a BPB the device is formatted as "superfloppy") will be ALSO (hd2).

If it is a MBR (i.e. the first sector contains a partition table) the whole device is still (hd2) but the first volume in it (to be more accurate the (primary) partition which extents are written to entry #0 in the partition table) will be (hd2,0), the (primary) partition which extents are written to entry #1 will be (hd2,1) etc., in grub2 the slots are numbered respectively #1 and #2 and the result will be (hd2,1) and (hd2,2).

 

In windows NT there are some differences.

If the device is "fixed" the OS will expect a MBR and will behave normally, the device remains \\.\PhysicalDrive2, the first primary partition will be HardDisk2\Partition1, the second HardDisk2\Parition2 etc.

If the device is "removable" AND first sector is a MBR,  the whole device remains \\.\PhysicalDrive2  BUT the OS will allow ONLY the first partition (more accurately the partition which extents are in first slot) to be accessible/mountable/etc., and that partition will be HardDIsk2\Partition1, till now still everuthing is fine.

 

If the device is "removable" AND first sector is a bootsector, the whole device remains \\.\PhysicalDrive2 AND the volume will be as well HardDisk2\Partition1.

 

These stupid card readers go even a step ahead and provide a Hardiskn\Partition1 device even when there is NO media in them (just like a CD/DVD drives are mapped to a drive letter even when empty).

 

In grub4dos the first sector of this device will be:

(hd2)

and the:

(hd2,0) will throw an error because there is NO partition in this device.

 

In windows NT the first sector will be at the same time:

\\.\PhysicalDrive2

and
HardDisk2\Partition1

and

\\.\E:

 

If you prefer, when faced with unpartitioned removable media, Windows NT "fakes" a partition table, see the attached screenshot, the SAME sector of a "super-floppy" device) is accessed in three different ways:

  1. as PhysicalDrive (right)
  2. as volume through it's drive letter (right)
  3. as partition (faked)

:duff:

Wonko

 

See also here:

http://reboot.pro/to...-line-possible/

 

Output on the same device:

 

zdinfo /MP /T:2

*********** [Multi Flash Reader USB Device] \\.\PHYSICALDRIVE2
DevPath: \Device\Harddisk2\DP(1)0-0+1b
VolGuid: \\?\Volume{d58328b0-ecc5-11e4-b09c-001fc6bb76ce}\
PartInfo: \\.\Device\Harddisk2\Partition1
VolMP: E:\

 

C:\VSS>dosdev
C: = \Device\HarddiskVolume1 [Fixed]
D: = \Device\HarddiskVolume2 [Fixed]
E: = \Device\Harddisk2\DP(1)0-0+1b [Removable]
F: = \Device\CdRom1 [CDRom]
I: = \Device\CdRom0 [CDRom]

 

(removed drive letter E: from disk manager)

showdrive

 

 

C:\VSS>dosdev
C: = \Device\HarddiskVolume1 [Fixed]
D: = \Device\HarddiskVolume2 [Fixed]
E: = \Device\Harddisk2\Partition1 [Removable]
F: = \Device\CdRom1 [CDRom]
I: = \Device\CdRom0 [CDRom]

 

(removed drive letter E: from disk manager)

 

mountstorPE

 

C:\VSS>dosdev
C: = \Device\HarddiskVolume1 [Fixed]
D: = \Device\HarddiskVolume2 [Fixed]
E: = \Device\Harddisk2\Partition1 [Removable]
F: = \Device\CdRom1 [CDRom]
G: = \Device\Harddisk2\DP(1)0-0+1b [Removable]
I: = \Device\CdRom0 [CDRom]

 

Of course E: and G: are exactly the same thing, dealing with the NT mount manager and connected things is far from "easy", now from Explorer I see G: (but not E:) in disk manager I have no drive letter, if I assign to it E: I can access it through explorer as BOTH E: and G: and zdinfo:

zdinfo /MP /T:2

*********** [Multi Flash Reader USB Device] \\.\PHYSICALDRIVE2
DevPath: \Device\Harddisk2\Partition1
VolGuid: \\?\Volume{d58328b0-ecc5-11e4-b09c-001fc6bb76ce}\
PartInfo: \\.\Device\Harddisk2\Partition1
VolMP: E:\

DevPath: \Device\Harddisk2\DP(1)0-0+1b
VolGuid: \\?\Volume{d58328b0-ecc5-11e4-b09c-001fc6bb76ce}\
PartInfo: \\.\Device\Harddisk2\Partition1
VolMP: G:\

 

but mountvol sees NOT G:, only E:. 

Crazy stuff. ;)

Attached Files



#17 Zharif

Zharif

    Frequent Member

  • .script developer
  • 152 posts
  • Location:Germany
  •  
    Germany

Posted 10 May 2015 - 04:51 PM

Wonko,

please let me try to summarise:
Objective is that the Grub family throws an device error for the (hd2,n) partition if there's no formatted partition in this device (e.g. no media present).

This goes for any device because its first sector is checked. Consequently, no drive letter will be mapped (is available).
[hd2] can be accessed...
[hd2,n] is prompted with an error


NT-Systems instead treat card readers (our example) as physical drive and as removable.
In this case and independent from the first sector attribute a partition number is provided,
although no formatted partition (or no media) may present. Consequently, a drive letter is assigned.
[\\.\PhysicalDrive2] can be accessed...
[\\.\Device\HardDisk2\Partition1] can also be accessed, but implicates an existing formatted
partition/media, which may not be present.

Using the VolumeFilesystem Info should help to decide which translation ([hd2] or [hd2,n]) should be used.
If no filesystem is detected output is [\\.\PhysicalDrive2] = [hd2].
If there is a filesystem, the PartitionNr can be prepended  =  [hd2,PartNr].
Is this an accurate way? Or am I on the wrong track?
 



#18 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 10 May 2015 - 06:05 PM

Using the VolumeFilesystem Info should help to decide which translation ([hd2] or [hd2,n]) should be used.
If no filesystem is detected output is [\\.\PhysicalDrive2] = [hd2].
If there is a filesystem, the PartitionNr can be prepended  =  [hd2,PartNr].
Is this an accurate way? Or am I on the wrong track?
 

Almost. :)

 

The issue here is that (since your tool is aimed to be used on Windows NT systems that do behave "strangely") I find it perfectly legitimate :thumbsup: to use the [hd2,n] for the actual volume, no matter if there is media (or a MBR or a filesystem).

 

BUT to go on with the given example, right now your tool provides the same output:

 

*********** [Multi Flash Reader USB Device] \\.\PHYSICALDRIVE2
DevPath: \Device\Harddisk2\Partition1
VolGuid: \\?\Volume{d58328b0-ecc5-11e4-b09c-001fc6bb76ce}\
PartInfo: \\.\Device\Harddisk2\Partition1
VolMP: E:\

 

In THREE cases:

1) there is NO media in the card reader

2) there is media formatted as super-floppy \\.\PhysicalDrive2,  \\.\Device\Harddisk2\Partition1 and \Device\Harddisk2\DP(1)0-0+1b and \\?\Volume{d58328b0-ecc5-11e4-b09c-001fc6bb76ce}\ ALL point to the same thing as WHOLE=Partition=Volume 

3) there is media partitioned and formatted as hard disk \\.\PhysicalDrive2 will be the whole thing (starting at LBA 0), while \\.\Device\Harddisk2\Partition1 and \Device\Harddisk2\DP(1)0-0+1b and \\?\Volume{d58328b0-ecc5-11e4-b09c-001fc6bb76ce}\ will point to the Partition=Volume

 

Since the idea of your tool is (or I believe it to be) that of providing more (or more accurate) info then other available tools, I was thinking if there was a way to differentiate the three cases, particularly, excluded the first case, which is irrelevant as any command on the empty device will return an error, there is no way through your tool to know if the media in the card reader (but the same would happen I believe for a "common" USB stick, as there will be cases #2 and #3) is partitioned or not.

 

The practical consequence is IMHO that someone may accidentally write a MBR to the \\PhysicalDrive2 thinking to be writing it to a partitioned device but ultimately overwriting the volume bootsector.

 

Maybe you could add an Object, let's call it:

MediaTyp

with three possible values (say):

MediaTyp=NoMedia

MediaTyp=Sfloppy

MediaTyp=HD_like

 

That may help in using the info gathered by the tool.

I have no idea how to "probe" for presence of the media, though :unsure:

And to add to the uncertainty :ph34r: what would happen if the media is completely blank (i.e. not partitioned and not formatted) and if it has just a magic bytes 55AA, but it has no BPB nor partition table?

A "HD_like" device would be considered "initialized when just the 55AA as last two bytes are present, i.e. LBA0 with 510 00's followed by 55AA, but maybe also some non-bootable filesystems (I am thinking of EXT2/3/4) would "look the same". :dubbio:

 

I know I am posting more problems than solutions, sorry. :(

 

:duff:

Wonko



#19 Zharif

Zharif

    Frequent Member

  • .script developer
  • 152 posts
  • Location:Germany
  •  
    Germany

Posted 10 May 2015 - 07:03 PM


I know I am posting more problems than solutions, sorry.

LOL, I expected this "problems" since the very first moment you appeared in this thread.

(Edit: Do not misinterpret me. Any of your posts is most appreciated for me -  reconsidering my thoughts and actions)

But I'm able to follow you now.

 

 

The issue here is that (since your tool is aimed to be used on Windows NT systems that do behave "strangely") I find it perfectly legitimate :thumbsup: to use the [hd2,n] for the actual volume, no matter if there is media (or a MBR or a filesystem).

Sounds good but I still must think about this (and do some research).

 

 


 

Maybe you could add an Object, let's call it:

MediaTyp

with three possible values (say):

MediaTyp=NoMedia

MediaTyp=Sfloppy

MediaTyp=HD_like

Yes, I've been thinking of something similar before.

I'm very sure I've seen an API function somewhere that may do this.

 

BTW,

new version here:

- removed /GUID or /MP switch -the list will show all devices by default

- added /M and /U switch to filter the list by mounted/unmounted devices additionally

- Variable names re-aligned in a way I could live with :-)

- renamed verbose switch from /V  to /VV

- renamed /L to /I

- renamed /LBL to /L

- renamed /M to /VM

- renamed /U to /VU

- help updated

 

 



#20 cdob

cdob

    Gold Member

  • Expert
  • 1342 posts

Posted 10 May 2015 - 07:56 PM

Awesome zDInfo work so far, thanks.

I wonder about grub4dos [hd?,?] notation:
zDInfo.exe is a windows program. Grub4dos is a boot manager.
The BIOS can change Disk numbers at boot.
The Windows numbers refers to current boot, but can be shiftet at next boot.
Does [hd?,?] notation helps or confuse the end user?

#21 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 11 May 2015 - 10:10 AM

Does [hd?,?] notation helps or confuse the end user?

Most probably it confuses him/her, but the idea is not to use "grub4dos notation", is to use optionally (i.e. when a given switch is added) one similar to it (with partitions starting from 1 like the GRUB2 and windows NT notation) to the only scope of having the output of the utility easily indexed.

As an example we could have:

[hdd_0,1] <- this could mean hard disk like device

and

[rdd_1,1] <- this could mean removable disk device

[cdd_0] <-this could mean CD like device

 

To parse (example) this output of current version of zdinfo, in order to quickly "couple" (say) drive letter with partition or device:

 

DevModel =[MAXTOR STM3320820AS ATA Device]
PhysDisk =\\.\PHYSICALDRIVE0
DevPath =\Device\HarddiskVolume1
VolGuid =\\?\Volume{83092730-6bfc-11df-b90c-806d6172696f}\
PartInfo =\\.\Device\Harddisk0\Partition1
DrvType =Fixed
VolMP =C:\

DevModel =[MAXTOR STM3320820AS ATA Device]
PhysDisk =\\.\PHYSICALDRIVE1
DevPath =\Device\HarddiskVolume2
VolGuid =\\?\Volume{b0b284c4-8a33-11dd-8781-806d6172696f}\
PartInfo =\\.\Device\Harddisk1\Partition1
DrvType =Fixed
VolMP =D:\

DevModel =[ASUS DRW-2014S1T ATAPI Device]
PhysDisk =
DevPath =\Device\CdRom0
VolGuid =\\?\Volume{80cf88c2-8a34-11dd-813c-806d6172696f}\
PartInfo =\\.\Device\CDRom0
DrvType =CD/DVD-ROM
VolMP =I:\

DevModel =[KernSafe DVD-RAM MOUNTER SCSI Device]
PhysDisk =
DevPath =\Device\CdRom1
VolGuid =\\?\Volume{c930f56b-520e-11e4-b08b-001fc6bb76ce}\
PartInfo =\\.\Device\CDRom1
DrvType =CD/DVD-ROM
VolMP =F:\

 

 

One would need *something like* this batch:







@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
FOR /F "tokens=1,* delims== " %%A in (2hds2cds.txt) DO (
SET %%A=%%B
IF %%A==VolMP CALL :do_!DrvType!
)
GOTO :EOF

:do_Fixed
CLS
ECHO Fixed
FOR /F "tokens=4,6 delims=k\n " %%B IN ("%PartInfo%") DO SET hdd=%%B&SET part=%%C
FOR %%D IN (DevModel PhysDisk DevPath VolGUID PartInfo DrvType VolMP) DO SET %%D_hdd!hdd!_part!part!=!%%D!
SET |FIND "hdd!hdd!_part!part!"
PAUSE
GOTO :EOF

:do_CD/DVD-ROM
CLS
ECHO CD/DVD-ROM
FOR /F "tokens=2 delims=m " %%B IN ("%PartInfo%") DO SET cdd=%%B
FOR %%D IN (DevModel PhysDisk DevPath VolGUID PartInfo DrvType VolMP) DO SET %%D_cdd!cdd!=!%%D!
SET |FIND "_cdd!cdd!"
PAUSE
GOTO :EOF

:duff:

Wonko

 

P.S.: till now - with all due respect for Zharif and for his nice tool of course :) - I do not see all that many enhancements (in terms of added info) to the output of my (shameless plug) ddlistw.cmd, exception made for the "DevModel" info:

ddlistw
Drives by drive letter:
c: 0,1 FIX \Volume{83092730-6bfc-11df-b90c-806d6172696f} \HarddiskVolume1
d: 1,1 FIX \Volume{b0b284c4-8a33-11dd-8781-806d6172696f} \HarddiskVolume2
f: x,x CDR \Volume{c930f56b-520e-11e4-b08b-001fc6bb76ce} \CdRom1
i: x,x CDR \Volume{80cf88c2-8a34-11dd-813c-806d6172696f} \CdRom0
Premere un tasto per continuare . . .

Drives by connection:
c: 0,1 FIX \Volume{83092730-6bfc-11df-b90c-806d6172696f} \HarddiskVolume1
d: 1,1 FIX \Volume{b0b284c4-8a33-11dd-8781-806d6172696f} \HarddiskVolume2
i: x,x CDR \Volume{80cf88c2-8a34-11dd-813c-806d6172696f} \CdRom0
f: x,x CDR \Volume{c930f56b-520e-11e4-b08b-001fc6bb76ce} \CdRom1
Premere un tasto per continuare . . . 

Though getting the same kind of output with zdinfo :thumbsup: is definitely easier:

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
FOR /F "tokens=1,* delims== " %%A in ('zdinfo.exe') DO (
SET %%A=%%B
IF %%A==VolMP CALL :do_!DrvType!
)
GOTO :EOF

:do_Fixed
FOR /F "tokens=4,6 delims=k\n " %%B IN ("%PartInfo%") DO SET hdd=%%B&SET part=%%C
ECHO %VolMP:\=% %hdd%,%part% %VolGUID:\\?=% %DevPath%
GOTO :EOF

:do_CD/DVD-ROM
FOR /F "tokens=2 delims=m " %%B IN ("%PartInfo%") DO SET cdd=%%B
ECHO %VolMP:\=% %CDD%,x %VolGUID:\\?=% %DevPath%
GOTO :EOF

:do_Removable
ECHO Not yet implemented
GOTO :EOF


#22 Zharif

Zharif

    Frequent Member

  • .script developer
  • 152 posts
  • Location:Germany
  •  
    Germany

Posted 12 May 2015 - 03:31 PM

zDInfo updated.

 

This version now shows some drive geometric info too.

These are:

- the DevDiskSize (should work on even unformatted devices),

- the DevMediaType (floppy related enumerations/Drive not ready/ fixed disk other than floppy/removable)

- Cylinders

- TracksPerCylinder

-  SectorsPerTrack

-  BytesPerSector

The last four will only appear by using the /SD-Switch.

 

- display-style of volume disk space removed.

- added new switch: "/S:[{0-5}] " let's the user choose, if sizes should either be displayed as Byte/KB/MB/GB/TB.

 

- added a /TEST-Switch (experimental), especially for Wonko.

This switch tries to mimic the Grub* notation to create unique variable names.

If proved to be okay, it will become the default display style.

 

- help updated

 

 

 

Since the idea of your tool is (or I believe it to be) that of providing more (or more accurate) info then other available tools, I was thinking if there was a way to differentiate the three cases, particularly, excluded the first case, which is irrelevant as any command on the empty device will return an error, there is no way through your tool to know if the media in the card reader (but the same would happen I believe for a "common" USB stick, as there will be cases #2 and #3) is partitioned or not.

 

The practical consequence is IMHO that someone may accidentally write a MBR to the \\PhysicalDrive2 thinking to be writing it to a partitioned device but ultimately overwriting the volume bootsector.

 

Maybe you could add an Object, let's call it:

MediaTyp

with three possible values (say):

MediaTyp=NoMedia

MediaTyp=Sfloppy

MediaTyp=HD_like

 

That may help in using the info gathered by the tool.

 

 

What do you think, does added information help to not accidently overwriting something?

 

Please Wonko (and certainly others too), have a look at it.

Suggestions/critics of any kind are welcome.



#23 erwan.l

erwan.l

    Gold Member

  • Developer
  • 1985 posts
  • Location:Nantes - France
  •  
    France

Posted 12 May 2015 - 04:55 PM

Which api do you do you use for disk size?

 

zdinfo reports :

DevModel       =[KINGSTON SVP100S296G SATA Device]
DevSizeTotal   =96021918720 Bytes (i.e 187542810)
 
clonedisk reports :
Size: 96029466624 bytes
TotalSectors: 187557552
 
I believe you are using disk geometry right?
Beware that this may not be accurate (either the value or the wording in zdinfo).


#24 erwan.l

erwan.l

    Gold Member

  • Developer
  • 1985 posts
  • Location:Nantes - France
  •  
    France

Posted 12 May 2015 - 04:56 PM

zdinfo seems confused by imdisk devices.

 

DevModel       =[Unknown Device]
DevSizeTotal   =-1 Bytes
DevMediaType   =Unknown Format
DevPhysDisk    =
DevPath        =\Device\ImDisk0
DevPartInfo    =
VolGuid        =
VolDrvType     =Fixed
VolMP          =R:\
 
whereas using getdiskfreespace api, I get
 
->GetDiskFreeSpace
Sectors per cluster: 8
Bytes per sector: 512
ClusterSize: 4096
Total clusters: 262143 (1023 MB)
Free Clusters: 200135 (781 MB) / Used Clusters: 62008 (242 MB)
 


#25 Zharif

Zharif

    Frequent Member

  • .script developer
  • 152 posts
  • Location:Germany
  •  
    Germany

Posted 12 May 2015 - 05:11 PM

Indeed, for the DiskSize I use the IOCTL_DISK_GET_DRIVE_GEOMETRY control code for DeviceIOControl.

 

Structure:

 Private Type DISK_GEOMETRY
    Cylinders         As LARGE_INTEGER
    'Cylinders         As Currency  'LARGE_INTEGER (8 bytes)
    MediaType         As Long
    TracksPerCylinder As Long
    SectorsPerTrack   As Long
    BytesPerSector    As Long
  End Type

 

whereas Cylinders refer to the LARGE_INTEGER structure

Private Type LARGE_INTEGER
    lowpart As Long
    highpart As Long
End Type
 

The Volume Disk spaces are retrieved by the GetDiskFreeSpaceEx-API that also uses the LARGE_INTEGER structure to get sizes in byte.

 

I cross-checked all results on my systems - the exactly showed the same sizes as in the disk management console. That's all I could do so far. Maybe I should try to use currency declarations.? Will have a look at that - thanks for input.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users