Re: IOCTL_DISK_GET_PARTITION_INFO_EX Fails on Dynamic Disks with (1) Incorrect function.

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Joe Richards [MVP] (humorexpress_at_hotmail.com)
Date: 08/07/04


Date: Sat, 07 Aug 2004 17:58:29 -0400

n/m I think I worked it out. Issue would appear to be that a volume that sits on
a dynamic disk could span multiple dynamic disks. Calling a function to get the
info under one of those disks wouldn't make sense.

--
Joe Richards Microsoft MVP Windows Server Directory Services
www.joeware.net
Joe Richards [MVP] wrote:
> I am trying to use the IOCTL_DISK_GET_PARTITION_INFO_EX control code and 
> anytime I hit a volume that is Dynamic is kicks out with an Error of 1, 
> Incorrect Function.
> 
> Below is a small snippet of how the handle is opened and the way I am 
> using IOCTL_DISK_GET_PARTITION_INFO_EX. Note that it works great on 
> volumes that are located on Basic Disks....
> 
> Disk0 has C: and is basic
> Disk1 has E: J: K: L: and is dynamic
> Disk2 has F: G: H: I: and is basic
> 
> 
> DEBUG: Gather Part Info for c:
> DEBUG: Opening \\.\c:
> DEBUG: Get Partition Info
> DEBUG: Partition Number: 1
> DEBUG: Partition Style : 0
> 
> DEBUG: Gather Part Info for e:
> DEBUG: Opening \\.\e:
> DEBUG: Get Partition Info
> ERROR (IOCTL_DISK_GET_PARTITION_INFO_EX): (1) Incorrect function.
> DEBUG: Partition Number: -1
> DEBUG: Partition Style : -1
> 
> DEBUG: Gather Part Info for f:
> DEBUG: Opening \\.\f:
> DEBUG: Get Partition Info
> DEBUG: Partition Number: 1
> DEBUG: Partition Style : 0
> 
> DEBUG: Gather Part Info for g:
> DEBUG: Opening \\.\g:
> DEBUG: Get Partition Info
> DEBUG: Partition Number: 2
> DEBUG: Partition Style : 0
> 
> DEBUG: Gather Part Info for h:
> DEBUG: Opening \\.\h:
> DEBUG: Get Partition Info
> DEBUG: Partition Number: 3
> DEBUG: Partition Style : 0
> 
> DEBUG: Gather Part Info for i:
> DEBUG: Opening \\.\i:
> DEBUG: Get Partition Info
> DEBUG: Partition Number: 4
> DEBUG: Partition Style : 0
> 
> DEBUG: Gather Part Info for j:
> DEBUG: Opening \\.\j:
> DEBUG: Get Partition Info
> ERROR (IOCTL_DISK_GET_PARTITION_INFO_EX): (1) Incorrect function.
> DEBUG: Partition Number: -1
> DEBUG: Partition Style : -1
> 
> DEBUG: Gather Part Info for k:
> DEBUG: Opening \\.\k:
> DEBUG: Get Partition Info
> ERROR (IOCTL_DISK_GET_PARTITION_INFO_EX): (1) Incorrect function.
> DEBUG: Partition Number: -1
> DEBUG: Partition Style : -1
> 
> DEBUG: Gather Part Info for l:
> DEBUG: Opening \\.\l:
> DEBUG: Get Partition Info
> ERROR (IOCTL_DISK_GET_PARTITION_INFO_EX): (1) Incorrect function.
> DEBUG: Partition Number: -1
> DEBUG: Partition Style : -1
> 
> 
> 
> 
> 
> 
> HANDLE OpenHandle(string v)
>  {
>   v="\\\\.\\"+v;
>   if (bDebug) cout << "DEBUG: Opening " << v << endl;
>   HANDLE h = CreateFile(v.c_str(),GENERIC_READ,
>                       FILE_SHARE_READ | FILE_SHARE_WRITE,
>                                  NULL, OPEN_EXISTING, 0, NULL);
>   if (h == INVALID_HANDLE_VALUE)
>    {
>     DisplayErrorMsg("ERROR (CreateFile): ");
>     return 0;
>    }
>   return h;
>  }
> 
> 
> bool GetPartInfo(HANDLE h)
>  {
>   DWORD dwSize=0;
>   PARTITION_INFORMATION_EX pie;
> 
>   ZeroMemory(&pie,sizeof(pie));
> 
>   if (!DeviceIoControl(h,IOCTL_DISK_GET_PARTITION_INFO_EX,NULL,0,&pie,
>                                                 sizeof(pie), &dwSize,NULL))
>    { // This fails with err=1 if Dynamic...
>     DWORD dwErr=GetLastError();
>     DisplayErrorMsg("ERROR (IOCTL_DISK_GET_PARTITION_INFO_EX): ");
>     return false;
>    }
> 
>   //
>   // Do something with partition info...
>   //
> 
>   return true;
>  }
> 
> 
> 
> 
> -- 
> Joe Richards Microsoft MVP Windows Server Directory Services
> www.joeware.net


Relevant Pages

  • Re: How can i install and boot to MS-DOS
    ... Come back with my MS-DOS problem,i followed ur way,boot to MS-DOS ... if we can use it on the NTFS active partition. ... these debug commands to create the Bootsect.dos file: ... toggle the active partition again and boot to the Windows XP ...
    (microsoft.public.windowsxp.setup_deployment)
  • Re: old DOS partitions
    ... You can NUKE the partition table on the harddrive, ... There are two ways to use the following Debug script: ... This script completely clears the partition table on your hard disk, ... preparing the hard disk for repartitioning using the MS-DOS Fdisk ...
    (alt.os.linux.suse)
  • Re: How can i install and boot to MS-DOS
    ... seemed the command "debug" is not being in MS-DOS then it say bad ... If i mark DOS partition active then setup windows after then i will be ... able to do this thing(choose boot to win or to dos) but in that,the ...
    (microsoft.public.windowsxp.setup_deployment)
  • Re: How can i install and boot to MS-DOS
    ... Toggle the active partition and boot to your MS-DOS installation and run these debug commands to create the Bootsect.dos file: ... toggle the active partition again and boot to the Windows XP installation. ...
    (microsoft.public.windowsxp.setup_deployment)
  • newwin is null or not an object error
    ... When opening certain sites. ... an error message stating the following. ... A Runtime Error has occured. ... Do you wish to debug? ...
    (microsoft.public.windows.inetexplorer.ie6.browser)