Exetools  

Go Back   Exetools > General > General Discussion

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 10-24-2007, 19:30
just4urim
 
Posts: n/a
Cool A drive letter is related to which physical disk?!

Hi all ,

I'm really interested if there's a way to find out that a specific drive letter is related to which physical disk? ( in XP and 98 ) . however in XP I found an IOCTL code ( IOCTL_DISK_GET_DRIVE_LETTERS ) , but it has not been even defined in windows! and i can't to compile my application!

Any idea? Is there any way ? ( for example from kernel mode ).

Tnx,
Just4uriM
Reply With Quote
  #2  
Old 10-24-2007, 22:08
evlncrn8 evlncrn8 is offline
VIP
 
Join Date: Sep 2005
Posts: 179
Rept. Given: 36
Rept. Rcvd 54 Times in 24 Posts
Thanks Given: 49
Thanks Rcvd at 117 Times in 69 Posts
evlncrn8 Reputation: 54
mountmgr.....
Reply With Quote
  #3  
Old 10-25-2007, 01:12
JuneMouse
 
Posts: n/a
you dont need r0 to get all these information

simply start wmic in cmd.exe

and get all the information you need

Code:
wmic:root\cli>path Win32_DiskPartition get Deviceid
DeviceID
Disk #0, Partition #0
Disk #0, Partition #1
Disk #0, Partition #2
Disk #2, Partition #0

wmic:root\cli>path Win32_logicaldisk get Deviceid
DeviceID
A:
C:
D:
E:
G:

wmic:root\cli>path Win32_diskdrive get Deviceid
DeviceID
\\.\PHYSICALDRIVE0
\\.\PHYSICALDRIVE2

wmic:root\cli>
try this command for an amazing amount of information about your diskdrives inside wmic
Code:
path Win32_DiskPartition assoc
or you can code a few lines in the latest leet language c#

or script oldstyle

Code:
ComputerName = "."
Set wmiServices  = GetObject ( _
    "winmgmts:{impersonationLevel=Impersonate}!//" _
    & ComputerName)
' Get physical disk drive
Set wmiDiskDrives =  wmiServices.ExecQuery ( _
    "SELECT Caption, DeviceID FROM Win32_DiskDrive")

For Each wmiDiskDrive In wmiDiskDrives
    WScript.Echo "Disk drive Caption: " _
        & wmiDiskDrive.Caption _ 
        & VbNewLine & "DeviceID: " _
        & " (" & wmiDiskDrive.DeviceID & ")"

    'Use the disk drive device id to
    ' find associated partition
    query = "ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" _
        & wmiDiskDrive.DeviceID & "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition"    
    Set wmiDiskPartitions = wmiServices.ExecQuery(query)

    For Each wmiDiskPartition In wmiDiskPartitions
        'Use partition device id to find logical disk
        Set wmiLogicalDisks = wmiServices.ExecQuery _
            ("ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" _
             & wmiDiskPartition.DeviceID & "'} WHERE AssocClass = Win32_LogicalDiskToPartition") 

        For Each wmiLogicalDisk In wmiLogicalDisks
            WScript.Echo "Drive letter associated" _
                & " with disk drive = " _ 
                & wmiDiskDrive.Caption _
                & wmiDiskDrive.DeviceID _
                & VbNewLine & " Partition = " _
                & wmiDiskPartition.DeviceID _
                & VbNewLine & " is " _
                & wmiLogicalDisk.DeviceID
        Next      
    Next
Next

output as follows for above script

wmic:/>cscript foo.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

Disk drive Caption: ************
DeviceID:  (\\.\PHYSICALDRIVE0)
Drive letter associated with disk drive = ***********\\.\PHYSICALDRIVE0
 Partition = Disk #0, Partition #0
 is C:
Drive letter associated with disk drive = **********\\.\PHYSICALDRIVE0
 Partition = Disk #0, Partition #1
 is E:
Drive letter associated with disk drive = **********\\.\PHYSICALDRIVE0
 Partition = Disk #0, Partition #2
 is D:
Disk drive Caption: *********** USB Device
DeviceID:  (\\.\PHYSICALDRIVE2)
Drive letter associated with disk drive = *********** USB Device\\.\PHYSI
CALDRIVE2
 Partition = Disk #2, Partition #0
 is G:

wmic:/>
above script is from ms
http://msdn2.microsoft.com/en-us/library/aa394592.aspx

Quote:
...detect which drive letter is associated with a logical disk partition? Start with the Win32_DiskDrive class and query for instances of Win32_DiskPartition using the DeviceID property and the Win32_DiskDriveToDiskPartition association class. Now you have a collection of the partitions on the physical drive.
Query for the Win32_LogicalDisk that represents the partition using the Win32_DiskPartition.DeviceID property and Win32_LogicalDiskToPartition association class.
Get the drive letter from the Win32_LogicalDisk.DeviceID.

Last edited by JuneMouse; 10-25-2007 at 01:19.
Reply With Quote
  #4  
Old 11-05-2007, 15:16
just4urim
 
Posts: n/a
Thanks for your guidance,
Quote:
Originally Posted by JuneMouse
you dont need r0 to get all these information

simply start wmic in cmd.exe

and ...
actually i did it in other way and as writing a Client Mount Manager was a bit vague! , I prefered to explore for some thing else . I used a smart IOCTL IOCTL_VOLUME_LOGICAL_TO_PHYSICAL to find the related physical hard disk number for a logical drive . May be it would help you in some way!

Regards,
Just4UriM
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating boot WinPE ISO from USB drive with min. disk space+factory reset prtn. info chants General Discussion 2 02-29-2020 21:49
About cracking related IRC channels Hero General Discussion 1 07-11-2005 04:32


All times are GMT +8. The time now is 12:36.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( 1998 - 2024 )