ReactOS 0.4.15-dev-7928-g68a8619
drivepage.c File Reference
#include "reactos.h"
#include <shlwapi.h>
#include <ntddstor.h>
#include <ntddscsi.h>
#include "resource.h"
#include <debug.h>
Include dependency graph for drivepage.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define IDS_LIST_COLUMN_FIRST   IDS_PARTITION_NAME
 
#define IDS_LIST_COLUMN_LAST   IDS_PARTITION_STATUS
 
#define MAX_LIST_COLUMNS   (IDS_LIST_COLUMN_LAST - IDS_LIST_COLUMN_FIRST + 1)
 

Functions

static INT_PTR CALLBACK MoreOptDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static INT_PTR CALLBACK PartitionDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
BOOL CreateTreeListColumns (IN HINSTANCE hInstance, IN HWND hWndTreeList, IN const UINT *pIDs, IN const INT *pColsWidth, IN const INT *pColsAlign, IN UINT nNumOfColumns)
 
VOID DisplayStuffUsingWin32Setup (HWND hwndDlg)
 
HTLITEM TreeListAddItem (IN HWND hTreeList, IN HTLITEM hParent, IN LPWSTR lpText, IN INT iImage, IN INT iSelectedImage, IN LPARAM lParam)
 
VOID GetPartitionTypeString (IN PPARTENTRY PartEntry, OUT PSTR strBuffer, IN ULONG cchBuffer)
 
static HTLITEM PrintPartitionData (IN HWND hWndList, IN PPARTLIST List, IN HTLITEM htiParent, IN PDISKENTRY DiskEntry, IN PPARTENTRY PartEntry)
 
static VOID PrintDiskData (IN HWND hWndList, IN PPARTLIST List, IN PDISKENTRY DiskEntry)
 
VOID DrawPartitionList (IN HWND hWndList, IN PPARTLIST List)
 
INT_PTR CALLBACK DriveDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

static const UINT column_ids [MAX_LIST_COLUMNS] = {IDS_LIST_COLUMN_FIRST, IDS_LIST_COLUMN_FIRST + 1, IDS_LIST_COLUMN_FIRST + 2, IDS_LIST_COLUMN_FIRST + 3}
 
static const INT column_widths [MAX_LIST_COLUMNS] = {200, 90, 60, 60}
 
static const INT column_alignment [MAX_LIST_COLUMNS] = {LVCFMT_LEFT, LVCFMT_LEFT, LVCFMT_RIGHT, LVCFMT_RIGHT}
 

Macro Definition Documentation

◆ IDS_LIST_COLUMN_FIRST

#define IDS_LIST_COLUMN_FIRST   IDS_PARTITION_NAME

Definition at line 41 of file drivepage.c.

◆ IDS_LIST_COLUMN_LAST

#define IDS_LIST_COLUMN_LAST   IDS_PARTITION_STATUS

Definition at line 42 of file drivepage.c.

◆ MAX_LIST_COLUMNS

#define MAX_LIST_COLUMNS   (IDS_LIST_COLUMN_LAST - IDS_LIST_COLUMN_FIRST + 1)

Definition at line 44 of file drivepage.c.

◆ NDEBUG

#define NDEBUG

Definition at line 36 of file drivepage.c.

Function Documentation

◆ CreateTreeListColumns()

BOOL CreateTreeListColumns ( IN HINSTANCE  hInstance,
IN HWND  hWndTreeList,
IN const UINT pIDs,
IN const INT pColsWidth,
IN const INT pColsAlign,
IN UINT  nNumOfColumns 
)

Definition at line 127 of file drivepage.c.

134{
135 UINT i;
136 TLCOLUMN tlC;
137 WCHAR szText[50];
138
139 /* Create the columns */
140 tlC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
141 tlC.pszText = szText;
142
143 /* Load the column labels from the resource file */
144 for (i = 0; i < nNumOfColumns; i++)
145 {
146 tlC.iSubItem = i;
147 tlC.cx = pColsWidth[i];
148 tlC.fmt = pColsAlign[i];
149
150 LoadStringW(hInstance, pIDs[i], szText, ARRAYSIZE(szText));
151
152 if (TreeList_InsertColumn(hWndTreeList, i, &tlC) == -1)
153 return FALSE;
154 }
155
156 return TRUE;
157}
HINSTANCE hInstance
Definition: charmap.c:19
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50
#define LVCF_WIDTH
Definition: commctrl.h:2587
#define LVCF_FMT
Definition: commctrl.h:2586
#define LVCF_SUBITEM
Definition: commctrl.h:2589
#define LVCF_TEXT
Definition: commctrl.h:2588
#define TreeList_InsertColumn(h, i, p)
Definition: treelist.h:368
#define TLCOLUMN
Definition: treelist.h:459
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by DriveDlgProc().

◆ DisplayStuffUsingWin32Setup()

VOID DisplayStuffUsingWin32Setup ( HWND  hwndDlg)

Definition at line 161 of file drivepage.c.

162{
163 HDEVINFO h;
164 HWND hList;
165 SP_DEVINFO_DATA DevInfoData;
166 DWORD i;
167
168 h = SetupDiGetClassDevs(&GUID_DEVCLASS_DISKDRIVE, NULL, NULL, DIGCF_PRESENT);
169 if (h == INVALID_HANDLE_VALUE)
170 return;
171
172 hList = GetDlgItem(hwndDlg, IDC_PARTITION);
173 DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
174 for (i=0; SetupDiEnumDeviceInfo(h, i, &DevInfoData); i++)
175 {
176 DWORD DataT;
178 DWORD buffersize = 0;
179
181 &DevInfoData,
183 &DataT,
184 (PBYTE)buffer,
185 buffersize,
186 &buffersize))
187 {
189 {
190 if (buffer) LocalFree(buffer);
191 buffer = LocalAlloc(LPTR, buffersize * 2);
192 }
193 else
194 {
195 return;
196 }
197 }
198 if (buffer)
199 {
202 }
203 }
205}
#define IDC_PARTITION
Definition: resource.h:38
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define NULL
Definition: types.h:112
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
BOOL WINAPI SetupDiEnumDeviceInfo(HDEVINFO devinfo, DWORD index, PSP_DEVINFO_DATA info)
Definition: devinst.c:1787
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2893
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint buffer
Definition: glext.h:5915
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
HWND hList
Definition: livecd.c:10
BYTE * PBYTE
Definition: pedump.c:66
#define SPDRP_DEVICEDESC
Definition: setupapi.h:507
#define SetupDiGetDeviceRegistryProperty
Definition: setupapi.h:2603
#define SetupDiGetClassDevs
Definition: setupapi.h:2593
#define DIGCF_PRESENT
Definition: setupapi.h:171
struct _SP_DEVINFO_DATA SP_DEVINFO_DATA
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define LPTR
Definition: winbase.h:381
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define LB_ADDSTRING
Definition: winuser.h:2031
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
CHAR * LPTSTR
Definition: xmlstorage.h:192

◆ DrawPartitionList()

VOID DrawPartitionList ( IN HWND  hWndList,
IN PPARTLIST  List 
)

Definition at line 591 of file drivepage.c.

594{
596 PDISKENTRY DiskEntry;
597
598 for (Entry = List->DiskListHead.Flink;
599 Entry != &List->DiskListHead;
600 Entry = Entry->Flink)
601 {
602 DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
603
604 /* Print disk entry */
605 PrintDiskData(hWndList, List, DiskEntry);
606 }
607}
static HWND hWndList[5+1]
Definition: SetParent.c:10
static VOID PrintDiskData(IN HWND hWndList, IN PPARTLIST List, IN PDISKENTRY DiskEntry)
Definition: drivepage.c:408
base of all file and directory entries
Definition: entries.h:83
Definition: typedefs.h:120
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550

Referenced by DriveDlgProc(), and SelectPartitionPage().

◆ DriveDlgProc()

INT_PTR CALLBACK DriveDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 613 of file drivepage.c.

618{
619 PSETUPDATA pSetupData;
620 HWND hList;
621 HIMAGELIST hSmall;
622
623 /* Retrieve pointer to the global setup data */
624 pSetupData = (PSETUPDATA)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
625
626 switch (uMsg)
627 {
628 case WM_INITDIALOG:
629 {
630 /* Save pointer to the global setup data */
631 pSetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
632 SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (DWORD_PTR)pSetupData);
633
634 /*
635 * Keep the "Next" button disabled. It will be enabled only
636 * when the user selects a valid partition.
637 */
639
640 hList = GetDlgItem(hwndDlg, IDC_PARTITION);
641
643 // TreeList_SetExtendedStyleEx(hList, TVS_EX_FULLROWITEMS, TVS_EX_FULLROWITEMS);
644
646 hList,
651
652 /* Create the ImageList */
655 ILC_COLOR32 | ILC_MASK, // ILC_COLOR24
656 1, 1);
657
658 /* Add event type icons to the ImageList */
661
662 /* Assign the ImageList to the List View */
664
665 // DisplayStuffUsingWin32Setup(hwndDlg);
667 break;
668 }
669
670 case WM_DESTROY:
671 {
672 hList = GetDlgItem(hwndDlg, IDC_PARTITION);
675 ImageList_Destroy(hSmall);
676 return TRUE;
677 }
678
679 case WM_COMMAND:
680 {
681 switch (LOWORD(wParam))
682 {
683 case IDC_PARTMOREOPTS:
684 DialogBoxParamW(pSetupData->hInstance,
686 hwndDlg,
688 (LPARAM)pSetupData);
689 break;
690
691 case IDC_PARTCREATE:
692 DialogBoxW(pSetupData->hInstance,
694 hwndDlg,
696 break;
697
698 case IDC_PARTDELETE:
699 break;
700 }
701 break;
702 }
703
704 case WM_NOTIFY:
705 {
706 LPNMHDR lpnm = (LPNMHDR)lParam;
707
708 // On Vista+ we can use TVN_ITEMCHANGED instead, with NMTVITEMCHANGE* pointer
709 if (lpnm->idFrom == IDC_PARTITION && lpnm->code == TVN_SELCHANGED)
710 {
712
713 // if (pnmv->uChanged & TVIF_STATE) /* The state has changed */
714 if (pnmv->itemNew.mask & TVIF_STATE)
715 {
716 /* The item has been (de)selected */
717 // if (pnmv->uNewState & TVIS_SELECTED)
718 if (pnmv->itemNew.state & TVIS_SELECTED)
719 {
720 HTLITEM hParentItem = TreeList_GetParent(lpnm->hwndFrom, pnmv->itemNew.hItem);
721 /* May or may not be a PPARTENTRY: this is a PPARTENTRY only when hParentItem != NULL */
722 PPARTENTRY PartEntry = (PPARTENTRY)pnmv->itemNew.lParam;
723
724 if (!hParentItem || !PartEntry)
725 {
728 goto DisableWizNext;
729 }
730 else // if (hParentItem && PartEntry)
731 {
732 EnableWindow(GetDlgItem(hwndDlg, IDC_PARTCREATE), !PartEntry->IsPartitioned);
734
735 if (PartEntry->IsPartitioned &&
736 !IsContainerPartition(PartEntry->PartitionType) /* alternatively: PartEntry->PartitionNumber != 0 */ &&
737 // !PartEntry->New &&
738 (PartEntry->FormatState == Preformatted /* || PartEntry->FormatState == Formatted */))
739 {
741 }
742 else
743 {
744 goto DisableWizNext;
745 }
746 }
747 }
748 else
749 {
750DisableWizNext:
751 /*
752 * Keep the "Next" button disabled. It will be enabled only
753 * when the user selects a valid partition.
754 */
756 }
757 }
758
759 break;
760 }
761
762 switch (lpnm->code)
763 {
764#if 0
765 case PSN_SETACTIVE:
766 {
767 /*
768 * Keep the "Next" button disabled. It will be enabled only
769 * when the user selects a valid partition.
770 */
772 break;
773 }
774#endif
775
777 {
778 /* Give the focus on and select the first item */
779 hList = GetDlgItem(hwndDlg, IDC_PARTITION);
780 // TreeList_SetFocusItem(hList, 1, 1);
783 return TRUE;
784 }
785
786 case PSN_QUERYCANCEL:
787 {
788 if (MessageBoxW(GetParent(hwndDlg),
789 pSetupData->szAbortMessage,
790 pSetupData->szAbortTitle,
792 {
793 /* Go to the Terminate page */
795 }
796
797 /* Do not close the wizard too soon */
799 return TRUE;
800 }
801
802 case PSN_WIZNEXT: /* Set the selected data */
803 {
805
806 /****/
807 // FIXME: This is my test disk encoding!
808 DISKENTRY DiskEntry;
809 PARTENTRY PartEntry;
810 DiskEntry.DiskNumber = 0;
811 DiskEntry.HwDiskNumber = 0;
812 DiskEntry.HwFixedDiskNumber = 0;
813 PartEntry.DiskEntry = &DiskEntry;
814 PartEntry.PartitionNumber = 1; // 4;
815 /****/
816
818 NULL, // pSetupData->USetupData.InstallationDirectory,
819 &PartEntry);
820
821 if (!NT_SUCCESS(Status))
822 {
823 DPRINT1("InitDestinationPaths() failed with status 0x%08lx\n", Status);
824 }
825
826 break;
827 }
828
829 default:
830 break;
831 }
832 }
833 break;
834
835 default:
836 break;
837 }
838
839 return FALSE;
840}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
struct _SETUPDATA * PSETUPDATA
#define IDD_RESTARTPAGE
Definition: resource.h:59
#define IDI_PARTITION
Definition: resource.h:12
#define IDC_PARTMOREOPTS
Definition: resource.h:62
#define IDC_PARTDELETE
Definition: resource.h:40
#define IDI_DISKDRIVE
Definition: resource.h:11
#define IDC_PARTCREATE
Definition: resource.h:39
#define IDD_PARTITION
Definition: resource.h:70
#define IDD_BOOTOPTIONS
Definition: resource.h:64
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:928
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
static const INT column_widths[MAX_LIST_COLUMNS]
Definition: drivepage.c:46
#define MAX_LIST_COLUMNS
Definition: drivepage.c:44
static const INT column_alignment[MAX_LIST_COLUMNS]
Definition: drivepage.c:47
VOID DrawPartitionList(IN HWND hWndList, IN PPARTLIST List)
Definition: drivepage.c:591
static INT_PTR CALLBACK MoreOptDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: drivepage.c:52
BOOL CreateTreeListColumns(IN HINSTANCE hInstance, IN HWND hWndTreeList, IN const UINT *pIDs, IN const INT *pColsWidth, IN const INT *pColsAlign, IN UINT nNumOfColumns)
Definition: drivepage.c:127
static const UINT column_ids[MAX_LIST_COLUMNS]
Definition: drivepage.c:45
static INT_PTR CALLBACK PartitionDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: drivepage.c:99
Status
Definition: gdiplustypes.h:25
struct _PARTENTRY * PPARTENTRY
@ Preformatted
Definition: partlist.h:37
if(dx< 0)
Definition: linetemp.h:194
#define PSN_QUERYINITIALFOCUS
Definition: settings.cpp:98
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:316
#define LOWORD(l)
Definition: pedump.c:82
#define PSN_QUERYCANCEL
Definition: prsht.h:123
#define PSN_WIZNEXT
Definition: prsht.h:121
#define PSWIZB_NEXT
Definition: prsht.h:154
#define PSWIZB_BACK
Definition: prsht.h:153
#define PropSheet_SetWizButtons(d, f)
Definition: prsht.h:357
#define LPPROPSHEETPAGE
Definition: prsht.h:390
#define PropSheet_SetCurSelByID(d, i)
Definition: prsht.h:354
#define PSN_SETACTIVE
Definition: prsht.h:115
#define TVN_SELCHANGED
Definition: commctrl.h:3735
#define TVSIL_NORMAL
Definition: commctrl.h:3443
#define LPNMTREEVIEW
Definition: commctrl.h:3643
#define ILC_COLOR32
Definition: commctrl.h:358
#define TVIS_SELECTED
Definition: commctrl.h:3280
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define ILC_MASK
Definition: commctrl.h:351
#define TVIF_STATE
Definition: commctrl.h:3269
#define WM_NOTIFY
Definition: richedit.h:61
NTSTATUS InitDestinationPaths(IN OUT PUSETUP_DATA pSetupData, IN PCWSTR InstallationDir, IN PPARTENTRY PartEntry)
Definition: setuplib.c:627
ULONG HwDiskNumber
Definition: partlist.h:102
ULONG DiskNumber
Definition: partlist.h:108
ULONG HwFixedDiskNumber
Definition: partlist.h:103
BOOLEAN IsPartitioned
Definition: partlist.h:66
UCHAR PartitionType
Definition: partlist.h:53
struct _DISKENTRY * DiskEntry
Definition: partlist.h:46
FORMATSTATE FormatState
Definition: partlist.h:61
ULONG PartitionNumber
Definition: partlist.h:55
USETUP_DATA USetupData
Definition: reactos.h:128
HINSTANCE hInstance
Definition: reactos.h:114
TCHAR szAbortMessage[512]
Definition: reactos.h:123
PPARTLIST PartitionList
Definition: reactos.h:132
TCHAR szAbortTitle[64]
Definition: reactos.h:124
UINT_PTR idFrom
Definition: winuser.h:3158
UINT code
Definition: winuser.h:3159
HWND hwndFrom
Definition: winuser.h:3157
#define SetWindowLongPtr
Definition: treelist.c:70
#define GWLP_USERDATA
Definition: treelist.c:63
#define TreeList_SetExtendedStyleEx(h, d, m)
Definition: treelist.h:377
#define HTLITEM
Definition: treelist.h:460
#define TreeList_GetImageList(h, i)
Definition: treelist.h:397
#define TreeList_GetParent(h, i)
Definition: treelist.h:436
#define TVS_EX_FULLROWMARK
Definition: treelist.h:272
#define TreeList_SelectItem(h, i)
Definition: treelist.h:430
#define TreeList_SetImageList(h, l, i)
Definition: treelist.h:407
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define GetWindowLongPtrW
Definition: winuser.h:4829
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4399
#define WM_COMMAND
Definition: winuser.h:1740
#define SM_CYSMICON
Definition: winuser.h:1013
#define WM_INITDIALOG
Definition: winuser.h:1739
#define MB_YESNO
Definition: winuser.h:817
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define SM_CXSMICON
Definition: winuser.h:1012
struct tagNMHDR * LPNMHDR
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HWND WINAPI GetParent(_In_ HWND)
#define MB_ICONQUESTION
Definition: winuser.h:789
#define DWLP_MSGRESULT
Definition: winuser.h:870
#define WM_DESTROY
Definition: winuser.h:1609
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define IDYES
Definition: winuser.h:835
#define SetWindowLongPtrW
Definition: winuser.h:5346
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2075
int WINAPI GetSystemMetrics(_In_ int)
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by _tWinMain().

◆ GetPartitionTypeString()

VOID GetPartitionTypeString ( IN PPARTENTRY  PartEntry,
OUT PSTR  strBuffer,
IN ULONG  cchBuffer 
)

Definition at line 237 of file drivepage.c.

241{
242 if (PartEntry->PartitionType == PARTITION_ENTRY_UNUSED)
243 {
244 StringCchCopyA(strBuffer, cchBuffer,
245 "Unused" /* MUIGetString(STRING_FORMATUNUSED) */);
246 }
247 else if (IsContainerPartition(PartEntry->PartitionType))
248 {
249 StringCchCopyA(strBuffer, cchBuffer,
250 "Extended Partition" /* MUIGetString(STRING_EXTENDED_PARTITION) */);
251 }
252 else
253 {
254 UINT i;
255
256 /* Do the table lookup */
257 if (PartEntry->DiskEntry->DiskStyle == PARTITION_STYLE_MBR)
258 {
259 for (i = 0; i < ARRAYSIZE(MbrPartitionTypes); ++i)
260 {
261 if (PartEntry->PartitionType == MbrPartitionTypes[i].Type)
262 {
263 StringCchCopyA(strBuffer, cchBuffer,
265 return;
266 }
267 }
268 }
269#if 0 // TODO: GPT support!
270 else if (PartEntry->DiskEntry->DiskStyle == PARTITION_STYLE_GPT)
271 {
272 for (i = 0; i < ARRAYSIZE(GptPartitionTypes); ++i)
273 {
274 if (IsEqualPartitionType(PartEntry->PartitionType,
276 {
277 StringCchCopyA(strBuffer, cchBuffer,
279 return;
280 }
281 }
282 }
283#endif
284
285 /* We are here because the partition type is unknown */
286 if (cchBuffer > 0) *strBuffer = '\0';
287 }
288
289 if ((cchBuffer > 0) && (*strBuffer == '\0'))
290 {
291 StringCchPrintfA(strBuffer, cchBuffer,
292 // MUIGetString(STRING_PARTTYPE),
293 "Type 0x%02x",
294 PartEntry->PartitionType);
295 }
296}
const GPT_PARTITION_TYPE GptPartitionTypes[NUM_GPT_PARTITION_TYPES]
Definition: partinfo.c:271
const MBR_PARTITION_TYPE MbrPartitionTypes[NUM_MBR_PARTITION_TYPES]
Definition: partinfo.c:46
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
static const WCHAR Description[]
Definition: oid.c:1266
static DWORD cchBuffer
Definition: fusion.c:85
@ PARTITION_STYLE_GPT
Definition: imports.h:202
@ PARTITION_STYLE_MBR
Definition: imports.h:201
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
STRSAFEAPI StringCchPrintfA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszFormat,...)
Definition: strsafe.h:520

Referenced by PrintPartitionData().

◆ MoreOptDlgProc()

static INT_PTR CALLBACK MoreOptDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 52 of file drivepage.c.

56{
57 PSETUPDATA pSetupData;
58
59 /* Retrieve pointer to the global setup data */
60 pSetupData = (PSETUPDATA)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
61
62 switch (uMsg)
63 {
64 case WM_INITDIALOG:
65 {
66 /* Save pointer to the global setup data */
67 pSetupData = (PSETUPDATA)lParam;
68 SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (DWORD_PTR)pSetupData);
69
73 break;
74 }
75
76 case WM_COMMAND:
77 switch (LOWORD(wParam))
78 {
79 case IDOK:
80 {
84 EndDialog(hwndDlg, IDOK);
85 return TRUE;
86 }
87
88 case IDCANCEL:
89 EndDialog(hwndDlg, IDCANCEL);
90 return TRUE;
91 }
92 break;
93 }
94
95 return FALSE;
96}
#define IDC_PATH
Definition: resource.h:65
#define IDC_INSTFREELDR
Definition: resource.h:66
WCHAR InstallationDirectory[MAX_PATH]
Definition: setuplib.h:137
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define IDCANCEL
Definition: winuser.h:831
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define IDOK
Definition: winuser.h:830
#define BST_CHECKED
Definition: winuser.h:197
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by DriveDlgProc().

◆ PartitionDlgProc()

static INT_PTR CALLBACK PartitionDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 99 of file drivepage.c.

103{
104 switch (uMsg)
105 {
106 case WM_INITDIALOG:
107 break;
108
109 case WM_COMMAND:
110 {
111 switch (LOWORD(wParam))
112 {
113 case IDOK:
114 EndDialog(hwndDlg, IDOK);
115 return TRUE;
116 case IDCANCEL:
117 EndDialog(hwndDlg, IDCANCEL);
118 return TRUE;
119 }
120 }
121 }
122 return FALSE;
123}

Referenced by DriveDlgProc().

◆ PrintDiskData()

static VOID PrintDiskData ( IN HWND  hWndList,
IN PPARTLIST  List,
IN PDISKENTRY  DiskEntry 
)
static

Definition at line 408 of file drivepage.c.

412{
414 HANDLE hDevice;
415 PCHAR DiskName = NULL;
416 ULONG Length = 0;
417 PPARTENTRY PrimaryPartEntry, LogicalPartEntry;
418 PLIST_ENTRY PrimaryEntry, LogicalEntry;
419 ULARGE_INTEGER DiskSize;
420 HTLITEM htiDisk, htiPart;
421 WCHAR LineBuffer[128];
422 UCHAR outBuf[512];
423
424 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
425 // L"\\Device\\Harddisk%lu\\Partition%lu",
426 L"\\\\.\\PhysicalDrive%lu",
427 DiskEntry->DiskNumber);
428
429 hDevice = CreateFileW(
430 LineBuffer, // device interface name
431 GENERIC_READ /*| GENERIC_WRITE*/, // dwDesiredAccess
432 FILE_SHARE_READ | FILE_SHARE_WRITE, // dwShareMode
433 NULL, // lpSecurityAttributes
434 OPEN_EXISTING, // dwCreationDistribution
435 0, // dwFlagsAndAttributes
436 NULL // hTemplateFile
437 );
438 if (hDevice != INVALID_HANDLE_VALUE)
439 {
441
442 Query.PropertyId = StorageDeviceProperty;
443 Query.QueryType = PropertyStandardQuery;
444
445 Success = DeviceIoControl(hDevice,
447 &Query,
448 sizeof(Query),
449 &outBuf,
450 sizeof(outBuf),
451 &Length,
452 NULL);
453 if (Success)
454 {
456 if (devDesc->ProductIdOffset)
457 {
458 DiskName = (PCHAR)&outBuf[devDesc->ProductIdOffset];
459 Length -= devDesc->ProductIdOffset;
460 DiskName[min(Length, strlen(DiskName))] = 0;
461 // ( i = devDesc->ProductIdOffset; p[i] != 0 && i < Length; i++ )
462 }
463 }
464
465 CloseHandle(hDevice);
466 }
467
468 if (DiskName && *DiskName)
469 {
470 if (DiskEntry->DriverName.Length > 0)
471 {
472 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
473 // MUIGetString(STRING_HDDINFO_1),
474 L"Harddisk %lu (%S) (Port=%hu, Bus=%hu, Id=%hu) on %wZ",
475 DiskEntry->DiskNumber,
476 DiskName,
477 DiskEntry->Port,
478 DiskEntry->Bus,
479 DiskEntry->Id,
480 &DiskEntry->DriverName);
481 }
482 else
483 {
484 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
485 // MUIGetString(STRING_HDDINFO_2),
486 L"Harddisk %lu (%S) (Port=%hu, Bus=%hu, Id=%hu)",
487 DiskEntry->DiskNumber,
488 DiskName,
489 DiskEntry->Port,
490 DiskEntry->Bus,
491 DiskEntry->Id);
492 }
493 }
494 else
495 {
496 if (DiskEntry->DriverName.Length > 0)
497 {
498 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
499 // MUIGetString(STRING_HDDINFO_1),
500 L"Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %wZ",
501 DiskEntry->DiskNumber,
502 DiskEntry->Port,
503 DiskEntry->Bus,
504 DiskEntry->Id,
505 &DiskEntry->DriverName);
506 }
507 else
508 {
509 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
510 // MUIGetString(STRING_HDDINFO_2),
511 L"Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu)",
512 DiskEntry->DiskNumber,
513 DiskEntry->Port,
514 DiskEntry->Bus,
515 DiskEntry->Id);
516 }
517 }
518
519 htiDisk = TreeListAddItem(hWndList, NULL, LineBuffer,
520 0, 0,
521 (LPARAM)DiskEntry);
522
523 /* Disk type: MBR, GPT or RAW (Uninitialized) */
524 TreeList_SetItemText(hWndList, htiDisk, 1,
525 DiskEntry->DiskStyle == PARTITION_STYLE_MBR ? L"MBR" :
526 DiskEntry->DiskStyle == PARTITION_STYLE_GPT ? L"GPT" :
527 L"RAW");
528
529 /* Format the disk size in KBs, MBs, etc... */
530 DiskSize.QuadPart = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
531 if (StrFormatByteSizeW(DiskSize.QuadPart, LineBuffer, ARRAYSIZE(LineBuffer)) == NULL)
532 {
533 /* We failed for whatever reason, do the hardcoded way */
534 PWCHAR Unit;
535
536 if (DiskSize.QuadPart >= 10 * GB) /* 10 GB */
537 {
538 DiskSize.QuadPart = RoundingDivide(DiskSize.QuadPart, GB);
539 // Unit = MUIGetString(STRING_GB);
540 Unit = L"GB";
541 }
542 else
543 {
544 DiskSize.QuadPart = RoundingDivide(DiskSize.QuadPart, MB);
545 if (DiskSize.QuadPart == 0)
546 DiskSize.QuadPart = 1;
547 // Unit = MUIGetString(STRING_MB);
548 Unit = L"MB";
549 }
550
551 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
552 L"%6lu %s",
553 DiskSize.u.LowPart,
554 Unit);
555 }
556 TreeList_SetItemText(hWndList, htiDisk, 2, LineBuffer);
557
558
559 /* Print partition lines */
560 for (PrimaryEntry = DiskEntry->PrimaryPartListHead.Flink;
561 PrimaryEntry != &DiskEntry->PrimaryPartListHead;
562 PrimaryEntry = PrimaryEntry->Flink)
563 {
564 PrimaryPartEntry = CONTAINING_RECORD(PrimaryEntry, PARTENTRY, ListEntry);
565
566 htiPart = PrintPartitionData(hWndList, List, htiDisk,
567 DiskEntry, PrimaryPartEntry);
568
569 if (IsContainerPartition(PrimaryPartEntry->PartitionType))
570 {
571 for (LogicalEntry = DiskEntry->LogicalPartListHead.Flink;
572 LogicalEntry != &DiskEntry->LogicalPartListHead;
573 LogicalEntry = LogicalEntry->Flink)
574 {
575 LogicalPartEntry = CONTAINING_RECORD(LogicalEntry, PARTENTRY, ListEntry);
576
578 DiskEntry, LogicalPartEntry);
579 }
580
581 /* Expand the extended partition node */
583 }
584 }
585
586 /* Expand the disk node */
588}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
BOOL Query(LPCTSTR *ServiceArgs, DWORD ArgCount, BOOL bExtended)
Definition: query.c:292
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_SHARE_READ
Definition: compat.h:136
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2388
HTLITEM TreeListAddItem(IN HWND hTreeList, IN HTLITEM hParent, IN LPWSTR lpText, IN INT iImage, IN INT iSelectedImage, IN LPARAM lParam)
Definition: drivepage.c:209
static HTLITEM PrintPartitionData(IN HWND hWndList, IN PPARTLIST List, IN HTLITEM htiParent, IN PDISKENTRY DiskEntry, IN PPARTENTRY PartEntry)
Definition: drivepage.c:300
@ Success
Definition: eventcreate.c:712
unsigned int BOOL
Definition: ntddk_ex.h:94
Unit
Definition: gdiplusenums.h:26
#define PCHAR
Definition: match.c:90
#define min(a, b)
Definition: monoChain.cc:55
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define IOCTL_STORAGE_QUERY_PROPERTY
Definition: ntddstor.h:178
* PSTORAGE_DEVICE_DESCRIPTOR
Definition: ntddstor.h:576
@ StorageDeviceProperty
Definition: ntddstor.h:512
@ PropertyStandardQuery
Definition: ntddstor.h:505
#define L(x)
Definition: ntvdm.h:50
#define TVE_EXPAND
Definition: commctrl.h:3423
ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
Definition: partlist.c:95
#define GB
Definition: setuplib.h:57
#define MB
Definition: setuplib.h:56
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
struct _ULARGE_INTEGER::@4140 u
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define TreeList_Expand(h, i, c)
Definition: treelist.h:365
#define TreeList_SetItemText(hwndLV, hItem_, iSubItem_, pszText_)
Definition: treelist.h:467
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by DrawPartitionList().

◆ PrintPartitionData()

static HTLITEM PrintPartitionData ( IN HWND  hWndList,
IN PPARTLIST  List,
IN HTLITEM  htiParent,
IN PDISKENTRY  DiskEntry,
IN PPARTENTRY  PartEntry 
)
static

Definition at line 300 of file drivepage.c.

306{
307 LARGE_INTEGER PartSize;
308 HTLITEM htiPart;
309 CHAR PartTypeString[32];
310 PCHAR PartType = PartTypeString;
311 WCHAR LineBuffer[128];
312
313 /* Volume name */
314 if (PartEntry->IsPartitioned == FALSE)
315 {
316 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
317 // MUIGetString(STRING_UNPSPACE),
318 L"Unpartitioned space");
319 }
320 else
321 {
322 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
323 // MUIGetString(STRING_HDDINFOUNK5),
324 L"%s (%c%c)",
325 *PartEntry->VolumeLabel ? PartEntry->VolumeLabel : L"Partition",
326 (PartEntry->DriveLetter == 0) ? L'-' : PartEntry->DriveLetter,
327 (PartEntry->DriveLetter == 0) ? L'-' : L':');
328 }
329
330 htiPart = TreeListAddItem(hWndList, htiParent, LineBuffer,
331 1, 1,
332 (LPARAM)PartEntry);
333
334 /* Determine partition type */
335 *LineBuffer = 0;
336 if (PartEntry->IsPartitioned)
337 {
338 PartTypeString[0] = '\0';
339 if (PartEntry->New == TRUE)
340 {
341 PartType = "New (Unformatted)"; // MUIGetString(STRING_UNFORMATTED);
342 }
343 else if (PartEntry->IsPartitioned == TRUE)
344 {
345 GetPartitionTypeString(PartEntry,
346 PartTypeString,
347 ARRAYSIZE(PartTypeString));
348 PartType = PartTypeString;
349 }
350
351 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
352 L"%S",
353 PartType);
354 }
355 TreeList_SetItemText(hWndList, htiPart, 1, LineBuffer);
356
357 /* Format the disk size in KBs, MBs, etc... */
358 PartSize.QuadPart = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
359 if (StrFormatByteSizeW(PartSize.QuadPart, LineBuffer, ARRAYSIZE(LineBuffer)) == NULL)
360 {
361 /* We failed for whatever reason, do the hardcoded way */
362 PWCHAR Unit;
363
364#if 0
365 if (PartSize.QuadPart >= 10 * GB) /* 10 GB */
366 {
367 PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, GB);
368 // Unit = MUIGetString(STRING_GB);
369 Unit = L"GB";
370 }
371 else
372#endif
373 if (PartSize.QuadPart >= 10 * MB) /* 10 MB */
374 {
375 PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, MB);
376 // Unit = MUIGetString(STRING_MB);
377 Unit = L"MB";
378 }
379 else
380 {
381 PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, KB);
382 // Unit = MUIGetString(STRING_KB);
383 Unit = L"KB";
384 }
385
386 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
387 L"%6lu %s",
388 PartSize.u.LowPart,
389 Unit);
390 }
391 TreeList_SetItemText(hWndList, htiPart, 2, LineBuffer);
392
393 /* Volume status */
394 *LineBuffer = 0;
395 if (PartEntry->IsPartitioned)
396 {
397 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
398 // MUIGetString(STRING_HDDINFOUNK5),
399 PartEntry->BootIndicator ? L"Active" : L"");
400 }
401 TreeList_SetItemText(hWndList, htiPart, 3, LineBuffer);
402
403 return htiPart;
404}
PartType
VOID GetPartitionTypeString(IN PPARTENTRY PartEntry, OUT PSTR strBuffer, IN ULONG cchBuffer)
Definition: drivepage.c:237
#define KB
Definition: setuplib.h:55
LONGLONG QuadPart
Definition: typedefs.h:114
struct _LARGE_INTEGER::@2295 u
char CHAR
Definition: xmlstorage.h:175

Referenced by PrintDiskData().

◆ TreeListAddItem()

HTLITEM TreeListAddItem ( IN HWND  hTreeList,
IN HTLITEM  hParent,
IN LPWSTR  lpText,
IN INT  iImage,
IN INT  iSelectedImage,
IN LPARAM  lParam 
)

Definition at line 209 of file drivepage.c.

215{
216 TL_INSERTSTRUCTW Insert;
217
218 ZeroMemory(&Insert, sizeof(Insert));
219
220 Insert.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
221 Insert.hInsertAfter = TVI_LAST;
222 Insert.hParent = hParent;
223 Insert.item.pszText = lpText;
224 Insert.item.iImage = iImage;
225 Insert.item.iSelectedImage = iSelectedImage;
226 Insert.item.lParam = lParam;
227
228 // Insert.item.mask |= TVIF_STATE;
229 // Insert.item.stateMask = TVIS_OVERLAYMASK;
230 // Insert.item.state = INDEXTOOVERLAYMASK(1);
231
232 return TreeList_InsertItem(hTreeList, &Insert);
233}
#define TVI_LAST
Definition: commctrl.h:3370
#define TVIF_TEXT
Definition: commctrl.h:3266
#define TVIF_IMAGE
Definition: commctrl.h:3267
#define TVIF_PARAM
Definition: commctrl.h:3268
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3271
#define TreeList_InsertItem(h, p)
Definition: treelist.h:403
#define TL_INSERTSTRUCTW
Definition: treelist.h:462
#define ZeroMemory
Definition: winbase.h:1712

Referenced by PrintDiskData(), and PrintPartitionData().

Variable Documentation

◆ column_alignment

Definition at line 47 of file drivepage.c.

Referenced by DriveDlgProc().

◆ column_ids

Definition at line 45 of file drivepage.c.

Referenced by DriveDlgProc().

◆ column_widths

const INT column_widths[MAX_LIST_COLUMNS] = {200, 90, 60, 60}
static

Definition at line 46 of file drivepage.c.

Referenced by DriveDlgProc().