Jump to content

How to show a hidden partition? - (Moved)


Recommended Posts

  • Moderators

Moved to the appropriate forum.

Moderation Team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

You will need  to add\build in the ms scripting package "WinPE-Scripting.cab" to your winpe to make it work

"WinPE-PowerShell_en-us.cab" and more,  Here are all or more packages that you can add in starting from a clean boot.wim @line 1 using the ADK

Dism /Mount-Image /ImageFile:"C:\WinPE_amd64_PS\media\sources\boot.wim" /Index:1 /MountDir:"C:\WinPE_amd64_PS\mount"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-WMI.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-WMI_en-us.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-NetFX.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-NetFX_en-us.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-Scripting.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-Scripting_en-us.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-PowerShell.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-PowerShell_en-us.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-StorageWMI.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-StorageWMI_en-us.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-DismCmdlets.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-DismCmdlets_en-us.cab"
Dism /Unmount-Image /MountDir:C:\WinPE_amd64_PS\mount /Commit

Many years ago i have started using this for doin' the disk queries for my winpe boot project

#include <Array.au3>

_GetDriveInfos()

Func _GetDriveInfos()
    $var = DriveGetDrive("FIXED")
    Local $aDiskDrive = 0
    Dim $specifs[$var[0]][8]
    For $i = 1 To $var[0]
        Dim $Services = ObjGet('winmgmts:\\.\root\cimv2')
        Dim $DiskDrives = $Services.ExecQuery("Select Caption, DeviceID From Win32_DiskDrive")
        For $DiskDrive In $DiskDrives
            Dim $DiskPartitions = $Services.ExecQuery("Associators of {Win32_DiskDrive.DeviceID='" & $DiskDrive.DeviceID & "'} Where AssocClass = Win32_DiskDriveToDiskPartition")
            For $DiskPartition In $DiskPartitions
                Dim $LogicalDisks = $Services.ExecQuery("Associators of {Win32_DiskPartition.DeviceID='" & $DiskPartition.DeviceID & "'} Where AssocClass = Win32_LogicalDiskToPartition")
                For $LogicalDisk In $LogicalDisks
                    If $LogicalDisk.DeviceID = $var[$i] Then
                        $specifs[$i - 1][0] = StringUpper($var[$i])
                        $specifs[$i - 1][1] = $DiskDrive.Caption
                        $specifs[$i - 1][2] = Round(DriveSpaceTotal($var[$i]) / 1000)
                        $specifs[$i - 1][3] = Round(DriveSpaceFree($var[$i]) / 1000)
                        $specifs[$i - 1][4] = StringFormat('%.2f', $LogicalDisk.Size / (1024 ^ 3)) & ' GB'
                        $specifs[$i - 1][5] = $DiskPartition.DeviceID
                        $specifs[$i - 1][6] = $LogicalDisk.VolumeName
                        $specifs[$i - 1][7] = $DiskPartition.Type
                    EndIf
                Next
            Next
        Next
    Next
    _ArrayDisplay($specifs, '$specifs')
EndFunc   ;==>_GetDriveInfos

Good luck!

Deye

Edited by Deye
Link to comment
Share on other sites

11 hours ago, Deye said:

You will need  to add\build in the ms scripting package "WinPE-Scripting.cab" to your winpe to make it work

"WinPE-PowerShell_en-us.cab" and more,  Here are all or more packages that you can add in starting from a clean boot.wim @line 1 using the ADK

Dism /Mount-Image /ImageFile:"C:\WinPE_amd64_PS\media\sources\boot.wim" /Index:1 /MountDir:"C:\WinPE_amd64_PS\mount"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-WMI.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-WMI_en-us.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-NetFX.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-NetFX_en-us.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-Scripting.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-Scripting_en-us.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-PowerShell.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-PowerShell_en-us.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-StorageWMI.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-StorageWMI_en-us.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-DismCmdlets.cab"
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-DismCmdlets_en-us.cab"
Dism /Unmount-Image /MountDir:C:\WinPE_amd64_PS\mount /Commit

Many years ago i have started using this for doin' the disk queries for my winpe boot project

#include <Array.au3>

_GetDriveInfos()

Func _GetDriveInfos()
    $var = DriveGetDrive("FIXED")
    Local $aDiskDrive = 0
    Dim $specifs[$var[0]][8]
    For $i = 1 To $var[0]
        Dim $Services = ObjGet('winmgmts:\\.\root\cimv2')
        Dim $DiskDrives = $Services.ExecQuery("Select Caption, DeviceID From Win32_DiskDrive")
        For $DiskDrive In $DiskDrives
            Dim $DiskPartitions = $Services.ExecQuery("Associators of {Win32_DiskDrive.DeviceID='" & $DiskDrive.DeviceID & "'} Where AssocClass = Win32_DiskDriveToDiskPartition")
            For $DiskPartition In $DiskPartitions
                Dim $LogicalDisks = $Services.ExecQuery("Associators of {Win32_DiskPartition.DeviceID='" & $DiskPartition.DeviceID & "'} Where AssocClass = Win32_LogicalDiskToPartition")
                For $LogicalDisk In $LogicalDisks
                    If $LogicalDisk.DeviceID = $var[$i] Then
                        $specifs[$i - 1][0] = StringUpper($var[$i])
                        $specifs[$i - 1][1] = $DiskDrive.Caption
                        $specifs[$i - 1][2] = Round(DriveSpaceTotal($var[$i]) / 1000)
                        $specifs[$i - 1][3] = Round(DriveSpaceFree($var[$i]) / 1000)
                        $specifs[$i - 1][4] = StringFormat('%.2f', $LogicalDisk.Size / (1024 ^ 3)) & ' GB'
                        $specifs[$i - 1][5] = $DiskPartition.DeviceID
                        $specifs[$i - 1][6] = $LogicalDisk.VolumeName
                        $specifs[$i - 1][7] = $DiskPartition.Type
                    EndIf
                Next
            Next
        Next
    Next
    _ArrayDisplay($specifs, '$specifs')
EndFunc   ;==>_GetDriveInfos

Good luck!

Deye

Thank you! I've saved it in my disk lol. But it still depends on so many modules. And it cannot detect hidden partitions.

Edited by BlueSkyMemory
Link to comment
Share on other sites

On 4/9/2020 at 2:51 PM, RTFC said:

Maybe try this?

I've found your code is so powerful! By the way, could you please help extract the part that determines whether it is an active partition? Thanks a lot! (To ensure which partitions can be booted)

Edited by BlueSkyMemory
Link to comment
Share on other sites

Thanks.:) To make a partition bootable (NB: only one (1) partition can be bootable per physical drive, so you always need to edit two flags, not one), look for, and edit boolean IsPrimary (any non-zero value = True; usually 0x01 or 0x80); it's the first byte of each partition table entry in the MBR. In the UDF, see var $partition_active in Func _ReadPartitionEntry for more info.

WARNING: any changes you make to these low-level descriptors is entirely your own responsibility. Please ensure you back up your entire physical drive (not just the files on it), before you start tampering with it. In this particular case, editing a single byte can result in your system no longer booting at all, and no easy way of fixing it. Only proceed if that scenario does not concern you at all.

Link to comment
Share on other sites

3 hours ago, RTFC said:

Thanks.:) To make a partition bootable (NB: only one (1) partition can be bootable per physical drive, so you always need to edit two flags, not one), look for, and edit boolean IsPrimary (any non-zero value = True; usually 0x01 or 0x80); it's the first byte of each partition table entry in the MBR. In the UDF, see var $partition_active in Func _ReadPartitionEntry for more info.

WARNING: any changes you make to these low-level descriptors is entirely your own responsibility. Please ensure you back up your entire physical drive (not just the files on it), before you start tampering with it. In this particular case, editing a single byte can result in your system no longer booting at all, and no easy way of fixing it. Only proceed if that scenario does not concern you at all.

I've got it! And do you know how to show a hidden partition? I mean, to give a letter to it.

Link to comment
Share on other sites

Assigning drive letters has got nothing to do with physical drives; you need to look into SetVolumeMountpoint for that.

To hide/show logical volumes, see the remarks section of the UDF:

- hide/unhide logical volumes (simply set/reset bit4 of a volume's Partition_Type in its (E)MBR partition entry)

 

Edited by RTFC
Link to comment
Share on other sites

1 hour ago, RTFC said:

Assigning drive letters has got nothing to do with physical drives; you need to look into SetVolumeMountpoint for that.

To hide/show logical volumes, see the remarks section of the UDF:

- hide/unhide logical volumes (simply set/reset bit4 of a volume's Partition_Type in its (E)MBR partition entry)

 

OK, I've got these APIs. Now I can use FindFirstVolume and FindNextVolume to get all GUIDs, and then assign letter to them. But when I try to use Find First/Next VolumeMountPoint  to find out its letter, I failed (actually it can only get the mountpoint I set to, not the drive letter.)

Link to comment
Share on other sites

  • Developers

@BlueSkyMemory, The comment I made in your other thread was also meant for you! 

Do NOT quote each and every post you reply to, as that information is already there, so just reply with your answer unless there is a real need to quote something!

Jos  

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

OK. Now the problem is solved. Thanks to everyone! This is my code below, hoping to help others--

Func _GetVolumeMountPoint($sGUID)
    $tPathName = DllStructCreate("char[2048]")
    $aResult = DllCall("Kernel32.dll", 'bool', 'GetVolumePathNamesForVolumeNameA', 'str', $sGUID, 'str', $tPathName, 'dword', DllStructGetSize($tPathName), 'dword', DllStructGetPtr($tPathName))
;~  _ArrayDisplay($aResult)
    Return $aResult[2]
EndFunc

 

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

×
×
  • Create New...