ReactOS 0.4.17-dev-573-g8315b8c
drivepage.c File Reference
#include "reactos.h"
#include <shlwapi.h>
#include <math.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.

Classes

struct  _PARTITEM
 Data structure stored for each partition item in the TreeList. (None for disks items.) More...
 
struct  _PARTCREATE_CTX
 Dialog context structure used by PartitionDlgProc() and FormatDlgProc(Worker)(). More...
 

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)
 

Typedefs

typedef struct _PARTITEM PARTITEM
 Data structure stored for each partition item in the TreeList. (None for disks items.)
 
typedef struct _PARTITEMPPARTITEM
 
typedef struct _PARTCREATE_CTX PARTCREATE_CTX
 Dialog context structure used by PartitionDlgProc() and FormatDlgProc(Worker)().
 
typedef struct _PARTCREATE_CTXPPARTCREATE_CTX
 

Functions

static BOOL DoSanitizeText (_Inout_ PWSTR pszSanitized)
 Sanitize a given string in-place, by removing any invalid character found in it.
 
static BOOL DoSanitizeClipboard (_In_ HWND hWnd)
 Sanitize in-place any text found in the clipboard.
 
static VOID ShowErrorTip (_In_ HWND hEdit)
 
static LRESULT CALLBACK InstallDirEditProc (_In_ HWND hWnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
 Subclass edit window procedure to filter allowed characters for the ReactOS installation directory.
 
static INT_PTR CALLBACK MoreOptDlgProc (_In_ HWND hDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
static INT_PTR CALLBACK FormatDlgProcWorker (_In_ PPARTCREATE_CTX PartCreateCtx, _In_ HWND hDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
static INT_PTR CALLBACK FormatDlgProc (_In_ HWND hDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
static INT_PTR CALLBACK PartitionDlgProc (_In_ HWND hDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ 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)
 
HTLITEM TreeListAddItem (_In_ HWND hTreeList, _In_opt_ HTLITEM hParent, _In_opt_ HTLITEM hInsertAfter, _In_ LPCWSTR lpText, _In_ INT iImage, _In_ INT iSelectedImage, _In_ LPARAM lParam)
 
LPARAM TreeListGetItemData (_In_ HWND hTreeList, _In_ HTLITEM hItem)
 
static PPARTITEM GetItemPartition (_In_ HWND hTreeList, _In_ HTLITEM hItem)
 
static PPARTITEM GetSelectedPartition (_In_ HWND hTreeList, _Out_opt_ HTLITEM *phItem)
 
PVOL_CREATE_INFO FindVolCreateInTreeByVolume (_In_ HWND hTreeList, _In_ PVOLENTRY Volume)
 
VOID GetPartitionTypeString (IN PPARTENTRY PartEntry, OUT PSTR strBuffer, IN ULONG cchBuffer)
 
static VOID PrettifySize1 (_Inout_ PULONGLONG Size, _Out_ PCWSTR *Unit)
 
static VOID PrettifySize2 (_Inout_ PULONGLONG Size, _Out_ PCWSTR *Unit)
 
static HTLITEM PrintPartitionData (_In_ HWND hWndList, _In_ HTLITEM htiParent, _In_opt_ HTLITEM hInsertAfter, _In_ PPARTENTRY PartEntry)
 
static VOID DeleteTreeItem (_In_ HWND hWndList, _In_ TLITEMW *ptlItem)
 Called on response to the TVN_DELETEITEM notification sent by the TreeList.
 
static VOID PrintDiskData (_In_ HWND hWndList, _In_opt_ HTLITEM hInsertAfter, _In_ PDISKENTRY DiskEntry)
 
static VOID InitPartitionList (_In_ HINSTANCE hInstance, _In_ HWND hWndList)
 
static VOID DrawPartitionList (_In_ HWND hWndList, _In_ PPARTLIST List)
 
static VOID CleanupPartitionList (_In_ HWND hWndList)
 
static BOOLEAN DoCreatePartition (_In_ HWND hList, _In_ PPARTLIST List, _Inout_ HTLITEM *phItem, _Inout_opt_ PPARTITEM *pPartItem, _In_opt_ ULONGLONG SizeBytes, _In_opt_ ULONG_PTR PartitionInfo)
 Create a partition in the selected disk region in the partition list, and update the partition list UI.
 
static BOOLEAN DoDeletePartition (_In_ HWND hList, _In_ PPARTLIST List, _Inout_ HTLITEM *phItem, _In_ PPARTITEM PartItem)
 Delete the selected partition in the partition list, and update the partition list UI.
 
static BOOLEAN SelectInstallPartition (_In_ PSETUPDATA pSetupData, _In_ HWND hwndDlg)
 
INT_PTR CALLBACK DriveDlgProc (_In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ 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 26 of file drivepage.c.

◆ IDS_LIST_COLUMN_LAST

#define IDS_LIST_COLUMN_LAST   IDS_PARTITION_STATUS

Definition at line 27 of file drivepage.c.

◆ MAX_LIST_COLUMNS

#define MAX_LIST_COLUMNS   (IDS_LIST_COLUMN_LAST - IDS_LIST_COLUMN_FIRST + 1)

Definition at line 29 of file drivepage.c.

◆ NDEBUG

#define NDEBUG

Definition at line 21 of file drivepage.c.

Typedef Documentation

◆ PARTCREATE_CTX

Dialog context structure used by PartitionDlgProc() and FormatDlgProc(Worker)().

◆ PARTITEM

Data structure stored for each partition item in the TreeList. (None for disks items.)

◆ PPARTCREATE_CTX

◆ PPARTITEM

Function Documentation

◆ CleanupPartitionList()

static VOID CleanupPartitionList ( _In_ HWND  hWndList)
static

Definition at line 1344 of file drivepage.c.

1346{
1347 HIMAGELIST hSmall;
1348
1349 /* Cleanup all the items. Their cached data will be automatically deleted
1350 * on response to the TVN_DELETEITEM notification sent by the TreeList
1351 * by DeleteTreeItem() */
1353
1354 /* And cleanup the imagelist */
1357 ImageList_Destroy(hSmall);
1358}
static HWND hWndList[5+1]
Definition: SetParent.c:10
#define NULL
Definition: types.h:112
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:941
#define TVSIL_NORMAL
Definition: commctrl.h:3448
#define TreeList_DeleteAllItems(h)
Definition: treelist.h:363
#define TreeList_GetImageList(h, i)
Definition: treelist.h:397
#define TreeList_SetImageList(h, l, i)
Definition: treelist.h:407

Referenced by DriveDlgProc().

◆ 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 699 of file drivepage.c.

706{
707 UINT i;
708 TLCOLUMN tlC;
709 WCHAR szText[50];
710
711 /* Create the columns */
712 tlC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
713 tlC.pszText = szText;
714
715 /* Load the column labels from the resource file */
716 for (i = 0; i < nNumOfColumns; i++)
717 {
718 tlC.iSubItem = i;
719 tlC.cx = pColsWidth[i];
720 tlC.fmt = pColsAlign[i];
721
722 LoadStringW(hInstance, pIDs[i], szText, ARRAYSIZE(szText));
723
724 if (TreeList_InsertColumn(hWndTreeList, i, &tlC) == -1)
725 return FALSE;
726 }
727
728 return TRUE;
729}
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: sysinfo.c:13
short WCHAR
Definition: pedump.c:58
#define LVCF_WIDTH
Definition: commctrl.h:2592
#define LVCF_FMT
Definition: commctrl.h:2591
#define LVCF_SUBITEM
Definition: commctrl.h:2594
#define LVCF_TEXT
Definition: commctrl.h:2593
#define LoadStringW
Definition: utils.h:64
#define TreeList_InsertColumn(h, i, p)
Definition: treelist.h:368
#define TLCOLUMN
Definition: treelist.h:465

Referenced by InitPartitionList().

◆ DeleteTreeItem()

static VOID DeleteTreeItem ( _In_ HWND  hWndList,
_In_ TLITEMW ptlItem 
)
static

Called on response to the TVN_DELETEITEM notification sent by the TreeList.

Definition at line 1112 of file drivepage.c.

1115{
1116 PPARTITEM PartItem;
1117
1118 /* Code below is equivalent to: PartItem = GetItemPartition(hWndList, ptlItem->hItem);
1119 * except that we already have the data structure in ptlItem->lParam, so there is
1120 * no need to call extra helpers as GetItemPartition() does. */
1121 HTLITEM hParentItem = TreeList_GetParent(hWndList, ptlItem->hItem);
1122 /* May or may not be a PPARTITEM: this is a PPARTITEM only when hParentItem != NULL */
1123 PartItem = (PPARTITEM)ptlItem->lParam;
1124 if (!hParentItem || !PartItem)
1125 return;
1126
1127 if (PartItem->VolCreate)
1128 LocalFree(PartItem->VolCreate);
1129 LocalFree(PartItem);
1130}
struct _PARTITEM * PPARTITEM
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
if(dx< 0)
Definition: linetemp.h:194
Data structure stored for each partition item in the TreeList. (None for disks items....
Definition: drivepage.c:357
PVOL_CREATE_INFO VolCreate
Definition: drivepage.c:360
#define HTLITEM
Definition: treelist.h:466
#define TreeList_GetParent(h, i)
Definition: treelist.h:442

Referenced by DriveDlgProc().

◆ DoCreatePartition()

static BOOLEAN DoCreatePartition ( _In_ HWND  hList,
_In_ PPARTLIST  List,
_Inout_ HTLITEM phItem,
_Inout_opt_ PPARTITEM pPartItem,
_In_opt_ ULONGLONG  SizeBytes,
_In_opt_ ULONG_PTR  PartitionInfo 
)
static

Create a partition in the selected disk region in the partition list, and update the partition list UI.

Definition at line 1367 of file drivepage.c.

1374{
1375 PPARTITEM PartItem;
1376 PPARTENTRY PartEntry;
1377 HTLITEM hParentItem;
1378 HTLITEM hInsertAfter;
1379 PPARTENTRY NextPart;
1381
1382 PartItem = (pPartItem ? *pPartItem : GetItemPartition(hList, *phItem));
1383 if (!PartItem)
1384 {
1385 /* We must have a disk region... */
1386 ASSERT(FALSE);
1387 return FALSE;
1388 }
1389 PartEntry = PartItem->PartEntry;
1390#if 0
1391 if (PartEntry->IsPartitioned)
1392 {
1393 /* Don't create a partition when one already exists */
1394 ASSERT(FALSE);
1395 return FALSE;
1396 }
1397 ASSERT(!PartEntry->Volume);
1398#endif
1399
1401 PartEntry,
1402 SizeBytes,
1404 if (!Success)
1405 return Success;
1406
1407 /* Retrieve the parent item (disk or MBR extended partition) */
1408 hParentItem = TreeList_GetParent(hList, *phItem);
1409 hInsertAfter = TreeList_GetPrevSibling(hList, *phItem);
1410 if (!hInsertAfter)
1411 hInsertAfter = TVI_FIRST;
1412
1413 /*
1414 * The current entry has been recreated and maybe split
1415 * in two: new partition and remaining unused space.
1416 * Thus, recreate the current entry.
1417 *
1418 * NOTE: Since we create a partition we don't care
1419 * about its previous PartItem, so it can be deleted.
1420 */
1421 {
1422 /* Cache out the original item's volume create info */
1423 PVOL_CREATE_INFO VolCreate = PartItem->VolCreate;
1424 PartItem->VolCreate = NULL;
1425
1426 /* Remove the current item */
1427 TreeList_DeleteItem(hList, *phItem);
1428
1429 /* Recreate the entry */
1430 *phItem = PrintPartitionData(hList, hParentItem, hInsertAfter, PartEntry);
1431
1432 /* Retrieve the new PartItem and restore the volume create
1433 * information associated to the newly-created partition */
1434 PartItem = GetItemPartition(hList, *phItem);
1435 ASSERT(PartItem);
1436
1437 /* Update the volume associated to the create information */
1438 if (VolCreate)
1439 VolCreate->Volume = PartItem->Volume;
1440
1441 /* Restore the volume create information */
1442 PartItem->VolCreate = VolCreate;
1443
1444 if (pPartItem)
1445 *pPartItem = PartItem;
1446 }
1447
1448 /* Add also the following unused space, if any */
1449 // NextPart = GetAdjDiskRegion(NULL, PartEntry, ENUM_REGION_NEXT);
1450 NextPart = GetAdjUnpartitionedEntry(PartEntry, TRUE);
1451 if (NextPart /*&& !NextPart->IsPartitioned*/)
1452 PrintPartitionData(hList, hParentItem, *phItem, NextPart);
1453
1454 /* Give the focus on and select the created partition */
1455 // TreeList_SetFocusItem(hList, 1, 1);
1456 TreeList_SelectItem(hList, *phItem);
1457
1458 return TRUE;
1459}
unsigned char BOOLEAN
Definition: actypes.h:127
static PPARTITEM GetItemPartition(_In_ HWND hTreeList, _In_ HTLITEM hItem)
Definition: drivepage.c:778
static HTLITEM PrintPartitionData(_In_ HWND hWndList, _In_ HTLITEM htiParent, _In_opt_ HTLITEM hInsertAfter, _In_ PPARTENTRY PartEntry)
Definition: drivepage.c:939
@ Success
Definition: eventcreate.c:712
HWND hList
Definition: livecd.c:10
#define ASSERT(a)
Definition: mode.c:44
#define TVI_FIRST
Definition: commctrl.h:3374
PPARTENTRY NTAPI GetAdjUnpartitionedEntry(_In_ PPARTENTRY PartEntry, _In_ BOOLEAN Direction)
Retrieves, if any, the unpartitioned disk region that is adjacent (next or previous) to the specified...
Definition: partlist.c:2856
BOOLEAN NTAPI CreatePartition(_In_ PPARTLIST List, _Inout_ PPARTENTRY PartEntry, _In_opt_ ULONGLONG SizeBytes, _In_opt_ ULONG_PTR PartitionInfo)
Definition: partlist.c:2975
BOOLEAN IsPartitioned
Definition: partlist.h:82
PVOLENTRY Volume
Definition: partlist.h:95
PPARTENTRY PartEntry
Definition: drivepage.c:358
PVOLENTRY Volume
Definition: drivepage.c:359
Data structure stored when a partition/volume needs to be formatted.
Definition: reactos.h:187
PVOLENTRY Volume
Definition: reactos.h:188
#define TreeList_GetPrevSibling(h, i)
Definition: treelist.h:444
#define TreeList_DeleteItem(h, i)
Definition: treelist.h:364
#define TreeList_SelectItem(h, i)
Definition: treelist.h:436
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
_In_ ULONG _In_ struct _SET_PARTITION_INFORMATION_EX * PartitionInfo
Definition: iofuncs.h:2105

Referenced by DriveDlgProc(), and SelectInstallPartition().

◆ DoDeletePartition()

static BOOLEAN DoDeletePartition ( _In_ HWND  hList,
_In_ PPARTLIST  List,
_Inout_ HTLITEM phItem,
_In_ PPARTITEM  PartItem 
)
static

Delete the selected partition in the partition list, and update the partition list UI.

Definition at line 1467 of file drivepage.c.

1472{
1473 PPARTENTRY PartEntry = PartItem->PartEntry;
1474 PPARTENTRY PrevPart, NextPart;
1475 BOOLEAN PrevIsPartitioned, NextIsPartitioned;
1477
1478 HTLITEM hParentItem;
1479 HTLITEM hInsertAfter;
1480 HTLITEM hAdjItem;
1481 PPARTITEM AdjPartItem;
1482
1483#if 0
1484 if (!PartEntry->IsPartitioned)
1485 {
1486 /* Don't delete an unpartitioned disk region */
1487 ASSERT(FALSE);
1488 return FALSE;
1489 }
1490#endif
1491
1492 /*
1493 * Determine the nature of the previous and next disk regions,
1494 * in order to know what to do on the corresponding tree items
1495 * after the selected partition has been deleted.
1496 *
1497 * NOTE: Don't reference these pointers after DeletePartition(),
1498 * since these disk regions might have been coalesced/reallocated.
1499 * However we can check whether they were NULL or not.
1500 */
1501 // PrevPart = GetAdjDiskRegion(NULL, PartEntry, ENUM_REGION_PREV);
1502 // NextPart = GetAdjDiskRegion(NULL, PartEntry, ENUM_REGION_NEXT);
1503 PrevPart = GetAdjUnpartitionedEntry(PartEntry, FALSE);
1504 NextPart = GetAdjUnpartitionedEntry(PartEntry, TRUE);
1505
1506 PrevIsPartitioned = (PrevPart && PrevPart->IsPartitioned);
1507 NextIsPartitioned = (NextPart && NextPart->IsPartitioned);
1508
1509 ASSERT(PartEntry->IsPartitioned); // The current partition must be partitioned.
1511 PartEntry,
1512 &PartEntry);
1513 if (!Success)
1514 return Success;
1515
1516 /* Retrieve the parent item (disk or MBR extended partition) */
1517 hParentItem = TreeList_GetParent(hList, *phItem);
1518
1519 /* If previous sibling isn't partitioned, remove it */
1520 if (PrevPart && !PrevIsPartitioned)
1521 {
1522 hAdjItem = TreeList_GetPrevSibling(hList, *phItem);
1523 ASSERT(hAdjItem); // TODO: Investigate
1524 if (hAdjItem)
1525 {
1526 AdjPartItem = GetItemPartition(hList, hAdjItem);
1527 ASSERT(AdjPartItem && (AdjPartItem->PartEntry == PrevPart));
1528 AdjPartItem = NULL;
1529 TreeList_DeleteItem(hList, hAdjItem);
1530 }
1531 }
1532 /* If next sibling isn't partitioned, remove it */
1533 if (NextPart && !NextIsPartitioned)
1534 {
1535 hAdjItem = TreeList_GetNextSibling(hList, *phItem);
1536 ASSERT(hAdjItem); // TODO: Investigate
1537 if (hAdjItem)
1538 {
1539 AdjPartItem = GetItemPartition(hList, hAdjItem);
1540 ASSERT(AdjPartItem && (AdjPartItem->PartEntry == NextPart));
1541 AdjPartItem = NULL;
1542 TreeList_DeleteItem(hList, hAdjItem);
1543 }
1544 }
1545
1546 /* We are going to insert the updated entry after
1547 * either, the original previous sibling (if it is
1548 * partitioned), or the second-previous sibling
1549 * (if the first one was already removed, see above) */
1550 hInsertAfter = TreeList_GetPrevSibling(hList, *phItem);
1551 if (!hInsertAfter)
1552 hInsertAfter = TVI_FIRST;
1553
1554 /* Remove the current item */
1555 TreeList_DeleteItem(hList, *phItem);
1556
1557 /* Add back the "new" unpartitioned space */
1558 *phItem = PrintPartitionData(hList, hParentItem, hInsertAfter, PartEntry);
1559
1560 /* Give the focus on and select the unpartitioned space */
1561 // TreeList_SetFocusItem(hList, 1, 1);
1562 TreeList_SelectItem(hList, *phItem);
1563
1564 return TRUE;
1565}
BOOLEAN NTAPI DeletePartition(_In_ PPARTLIST List, _In_ PPARTENTRY PartEntry, _Out_opt_ PPARTENTRY *FreeRegion)
Definition: partlist.c:3075
#define TreeList_GetNextSibling(h, i)
Definition: treelist.h:443

Referenced by DriveDlgProc().

◆ DoSanitizeClipboard()

static BOOL DoSanitizeClipboard ( _In_ HWND  hWnd)
static

Sanitize in-place any text found in the clipboard.

Definition at line 71 of file drivepage.c.

73{
74 HGLOBAL hData;
75 LPWSTR pszText, pszSanitized;
76 BOOL bSanitized;
77
78 /* Protect read-only edit control from modification */
80 return FALSE;
81
82 if (!OpenClipboard(hWnd))
83 return FALSE;
84
86 pszText = GlobalLock(hData);
87 if (!pszText)
88 {
90 return FALSE;
91 }
92
93 pszSanitized = _wcsdup(pszText);
94 GlobalUnlock(hData);
95 bSanitized = (pszSanitized && DoSanitizeText(pszSanitized));
96 if (bSanitized)
97 {
98 /* Update clipboard text */
99 SIZE_T cbData = (wcslen(pszSanitized) + 1) * sizeof(WCHAR);
101 pszText = GlobalLock(hData);
102 if (pszText)
103 {
104 CopyMemory(pszText, pszSanitized, cbData);
105 GlobalUnlock(hData);
107 }
108 }
109 free(pszSanitized);
110
112 return bSanitized;
113}
HWND hWnd
Definition: settings.c:17
#define CF_UNICODETEXT
Definition: constants.h:408
#define free
Definition: debug_ros.c:5
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
_ACRTIMP wchar_t *__cdecl _wcsdup(const wchar_t *) __WINE_DEALLOC(free) __WINE_MALLOC
Definition: wcs.c:86
static BOOL DoSanitizeText(_Inout_ PWSTR pszSanitized)
Sanitize a given string in-place, by removing any invalid character found in it.
Definition: drivepage.c:42
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
static ERESOURCE GlobalLock
Definition: sys_arch.c:8
#define CopyMemory
Definition: minwinbase.h:29
#define ES_READONLY
Definition: pedump.c:675
_In_opt_ _In_opt_ _In_ _In_ DWORD cbData
Definition: shlwapi.h:761
uint16_t * LPWSTR
Definition: typedefs.h:56
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define GMEM_MOVEABLE
Definition: winbase.h:318
#define GMEM_SHARE
Definition: winbase.h:329
#define GetWindowLongPtrW
Definition: winuser.h:4983
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
HANDLE WINAPI GetClipboardData(_In_ UINT)
#define GWL_STYLE
Definition: winuser.h:863

Referenced by InstallDirEditProc().

◆ DoSanitizeText()

static BOOL DoSanitizeText ( _Inout_ PWSTR  pszSanitized)
static

Sanitize a given string in-place, by removing any invalid character found in it.

Definition at line 42 of file drivepage.c.

44{
45 PWCHAR pch1, pch2;
46 BOOL bSanitized = FALSE;
47
48 for (pch1 = pch2 = pszSanitized; *pch1; ++pch1)
49 {
50 /* Skip any invalid character found */
52 {
53 bSanitized = TRUE;
54 continue;
55 }
56
57 /* Copy over the valid ones */
58 *pch2 = *pch1;
59 ++pch2;
60 }
61 *pch2 = 0;
62
63 return bSanitized;
64}
#define IS_VALID_INSTALL_PATH_CHAR(c)
Defines the class of characters valid for the installation directory.
Definition: setuplib.h:206
uint16_t * PWCHAR
Definition: typedefs.h:56

Referenced by DoSanitizeClipboard().

◆ DrawPartitionList()

static VOID DrawPartitionList ( _In_ HWND  hWndList,
_In_ PPARTLIST  List 
)
static

Definition at line 1319 of file drivepage.c.

1322{
1324
1325 /* Clear the list first */
1327
1328 /* Insert all the detected disks and partitions */
1329 for (Entry = List->DiskListHead.Flink;
1330 Entry != &List->DiskListHead;
1331 Entry = Entry->Flink)
1332 {
1333 /* Print disk entry */
1334 PDISKENTRY DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
1335 PrintDiskData(hWndList, NULL, DiskEntry);
1336 }
1337
1338 /* Select the first item */
1339 // TreeList_SetFocusItem(hWndList, 1, 1);
1341}
static VOID PrintDiskData(_In_ HWND hWndList, _In_opt_ HTLITEM hInsertAfter, _In_ PDISKENTRY DiskEntry)
Definition: drivepage.c:1134
Entry
Definition: section.c:5216
Definition: typedefs.h:120
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by DriveDlgProc(), and SelectPartitionPage().

◆ DriveDlgProc()

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

Definition at line 1684 of file drivepage.c.

1689{
1690 PSETUPDATA pSetupData;
1691 HWND hList;
1692
1693 /* Retrieve pointer to the global setup data */
1694 pSetupData = (PSETUPDATA)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
1695
1696 switch (uMsg)
1697 {
1698 case WM_INITDIALOG:
1699 {
1700 /* Save pointer to the global setup data */
1701 pSetupData = (PSETUPDATA)((LPPROPSHEETPAGEW)lParam)->lParam;
1702 SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)pSetupData);
1703
1704 /* Initially hide and disable all partitioning buttons */
1705 ShowDlgItem(hwndDlg, IDC_INITDISK, SW_HIDE);
1706 EnableDlgItem(hwndDlg, IDC_INITDISK, FALSE);
1713
1714 /* Initialize the partitions list */
1715 hList = GetDlgItem(hwndDlg, IDC_PARTITION);
1717 InitPartitionList(pSetupData->hInstance, hList);
1719 break;
1720 }
1721
1722 case WM_DESTROY:
1723 {
1724 hList = GetDlgItem(hwndDlg, IDC_PARTITION);
1728 return TRUE;
1729 }
1730
1731 case WM_COMMAND:
1732 {
1733 if (HIWORD(wParam) == BN_CLICKED) switch (LOWORD(wParam))
1734 {
1735 case IDC_PARTMOREOPTS:
1736 {
1737 DialogBoxParamW(pSetupData->hInstance,
1739 hwndDlg,
1741 (LPARAM)pSetupData);
1742 return TRUE;
1743 }
1744
1745 case IDC_INITDISK:
1746 {
1747 // TODO: Implement disk partitioning initialization
1748 return TRUE;
1749 }
1750
1751 case IDC_PARTCREATE:
1752 {
1753 HTLITEM hItem;
1754 PPARTITEM PartItem;
1755 PPARTENTRY PartEntry;
1756 ULONGLONG PartSize;
1757 ULONGLONG MaxPartSize;
1758 ULONG MaxSizeMB;
1759 INT_PTR ret;
1760 PARTCREATE_CTX PartCreateCtx = {0};
1761
1762 hList = GetDlgItem(hwndDlg, IDC_PARTITION);
1763 PartItem = GetSelectedPartition(hList, &hItem);
1764 if (!PartItem)
1765 {
1766 /* If the button was clicked, an empty disk
1767 * region should have been selected first */
1768 ASSERT(FALSE);
1769 break;
1770 }
1771 PartEntry = PartItem->PartEntry;
1772 if (PartEntry->IsPartitioned)
1773 {
1774 /* Don't create a partition when one already exists */
1775 ASSERT(FALSE);
1776 break;
1777 }
1778 ASSERT(!PartEntry->Volume);
1779
1780 /* Get the partition info stored in the TreeList */
1781 PartCreateCtx.PartItem = PartItem;
1782
1783 /* Retrieve the maximum size in MB (rounded up) the partition can have */
1784 MaxPartSize = GetPartEntrySizeInBytes(PartEntry);
1785 MaxSizeMB = (ULONG)RoundingDivide(MaxPartSize, MB);
1786 PartCreateCtx.MaxSizeMB = MaxSizeMB;
1787
1788 /* Don't force formatting by default */
1789 PartCreateCtx.ForceFormat = FALSE;
1790
1791 /* Show the partitioning dialog */
1792 ret = DialogBoxParamW(pSetupData->hInstance,
1794 hwndDlg,
1796 (LPARAM)&PartCreateCtx);
1797 if (ret != IDOK)
1798 break;
1799
1800 /*
1801 * If the input size, given in MB, specifies the maximum partition
1802 * size, it may slightly under- or over-estimate the latter due to
1803 * rounding error. In this case, use all of the unpartitioned space.
1804 * Otherwise, directly convert the size to bytes.
1805 */
1806 PartSize = PartCreateCtx.PartSizeMB;
1807 if (PartSize == MaxSizeMB)
1808 PartSize = MaxPartSize;
1809 else // if (PartSize < MaxSizeMB)
1810 PartSize *= MB;
1811
1812 ASSERT(PartSize <= MaxPartSize);
1813
1814 if (!DoCreatePartition(hList, pSetupData->PartitionList,
1815 &hItem, &PartItem,
1816 PartSize,
1817 !PartCreateCtx.MBRExtPart
1818 ? 0 : PARTITION_EXTENDED))
1819 {
1820 DisplayError(GetParent(hwndDlg),
1823 }
1824 break;
1825 }
1826
1827 case IDC_PARTFORMAT:
1828 {
1829 PPARTITEM PartItem;
1830 PPARTENTRY PartEntry;
1831 INT_PTR ret;
1832 PARTCREATE_CTX PartCreateCtx = {0};
1833
1834 hList = GetDlgItem(hwndDlg, IDC_PARTITION);
1835 PartItem = GetSelectedPartition(hList, NULL);
1836 if (!PartItem)
1837 {
1838 /* If the button was clicked, an empty disk
1839 * region should have been selected first */
1840 ASSERT(FALSE);
1841 break;
1842 }
1843 PartEntry = PartItem->PartEntry;
1844 if (!PartEntry->Volume)
1845 {
1846 /* Don't format an unformattable partition */
1847 ASSERT(FALSE);
1848 break;
1849 }
1850
1851 /* Show the formatting dialog */
1852 PartCreateCtx.PartItem = PartItem;
1853 ret = DialogBoxParamW(pSetupData->hInstance,
1855 hwndDlg,
1857 (LPARAM)&PartCreateCtx);
1859 break;
1860 }
1861
1862 case IDC_PARTDELETE:
1863 {
1864 HTLITEM hItem;
1865 PPARTITEM PartItem;
1866 PPARTENTRY PartEntry;
1867 UINT uIDWarnMsg;
1868
1869 hList = GetDlgItem(hwndDlg, IDC_PARTITION);
1870 PartItem = GetSelectedPartition(hList, &hItem);
1871 if (!PartItem)
1872 {
1873 /* If the button was clicked, a partition
1874 * should have been selected first */
1875 ASSERT(FALSE);
1876 break;
1877 }
1878 PartEntry = PartItem->PartEntry;
1879 if (!PartEntry->IsPartitioned)
1880 {
1881 /* Don't delete an unpartitioned disk region */
1882 ASSERT(FALSE);
1883 break;
1884 }
1885
1886 /* Choose the correct warning message to display:
1887 * MBR-extended (container) vs. standard partition */
1888 if (PartEntry == PartEntry->DiskEntry->ExtendedPartition)
1890 else
1891 uIDWarnMsg = IDS_WARN_DELETE_PARTITION;
1892
1893 /* If the user really wants to delete the partition... */
1894 if (DisplayMessage(GetParent(hwndDlg),
1897 MAKEINTRESOURCEW(uIDWarnMsg)) == IDYES)
1898 {
1899 /* ... make it so! */
1900 if (!DoDeletePartition(hList, pSetupData->PartitionList,
1901 &hItem, PartItem))
1902 {
1904 L"Could not delete the selected partition.");
1905 }
1906 }
1907 break;
1908 }
1909 }
1910 break;
1911 }
1912
1913 case WM_NOTIFY:
1914 {
1915 LPNMHDR lpnm = (LPNMHDR)lParam;
1916
1917 if (lpnm->idFrom == IDC_PARTITION) switch (lpnm->code)
1918 {
1919 case NM_RETURN:
1920 {
1921 /* If the currently selected item is a partition (and so, if
1922 * the wizard "Next" button is enabled), pressing "Next" will
1923 * attempt to select an install partition and go to the next
1924 * page if successful. */
1925 HWND hWndParent = GetParent(hwndDlg);
1928 break;
1929 }
1930
1931 case TVN_KEYDOWN:
1932 {
1933 if (((LPTV_KEYDOWN_EX)lParam)->wVKey == VK_DELETE)
1934 {
1935 /* Send the delete command only if IDC_PARTDELETE is
1936 * enabled (i.e. the selected item IS a partition) */
1939 }
1940 break;
1941 }
1942 }
1943
1944 // On Vista+ we can use TVN_ITEMCHANGED instead, with NMTVITEMCHANGE* pointer
1945 if (lpnm->idFrom == IDC_PARTITION && lpnm->code == TVN_SELCHANGED)
1946 {
1948
1949 /* Check whether the item has been (de)selected */
1950#if 0 // When using NMTVITEMCHANGE
1951 if (!(pnmv->uChanged & TVIF_STATE) ||
1952 !((pnmv->uStateOld ^ pnmv->uStateNew) & TVIS_SELECTED))
1953 { break; }
1954#endif
1955 if (!((pnmv->itemOld.mask | pnmv->itemNew.mask) & TVIF_STATE) ||
1956 !((pnmv->itemOld.state ^ pnmv->itemNew.state) & TVIS_SELECTED))
1957 {
1958 break;
1959 }
1960
1961 if (pnmv->itemNew.state & TVIS_SELECTED)
1962 {
1963 HTLITEM hParentItem = TreeList_GetParent(lpnm->hwndFrom, pnmv->itemNew.hItem);
1964 /* May or may not be a PPARTENTRY: this is a PPARTENTRY only when hParentItem != NULL */
1965
1966 if (!hParentItem)
1967 {
1968 /* Hard disk */
1969 PDISKENTRY DiskEntry = (PDISKENTRY)pnmv->itemNew.lParam;
1970 ASSERT(DiskEntry);
1971
1972 /* Show the "Initialize" disk button and hide and disable the others */
1973 ShowDlgItem(hwndDlg, IDC_INITDISK, SW_SHOW);
1974
1975#if 0 // FIXME: Init disk not implemented yet!
1976 EnableDlgItem(hwndDlg, IDC_INITDISK,
1977 DiskEntry->DiskStyle == PARTITION_STYLE_RAW);
1978#else
1979 EnableDlgItem(hwndDlg, IDC_INITDISK, FALSE);
1980#endif
1981
1984
1987
1990
1991 /* Disable the "Next" button */
1992 goto DisableWizNext;
1993 }
1994 else
1995 {
1996 /* Partition or unpartitioned space */
1997 PPARTITEM PartItem = (PPARTITEM)pnmv->itemNew.lParam;
1998 PPARTENTRY PartEntry;
1999 BOOL CanBePartitioned;
2000 ASSERT(PartItem);
2001 PartEntry = PartItem->PartEntry;
2002 ASSERT(PartEntry);
2003
2004 /* Hide and disable the "Initialize" disk button */
2005 ShowDlgItem(hwndDlg, IDC_INITDISK, SW_HIDE);
2006 EnableDlgItem(hwndDlg, IDC_INITDISK, FALSE);
2007
2008 /* Check whether the selected disk region is not partitioned, and
2009 * can be partitioned according to the disk's partitioning scheme */
2010 CanBePartitioned = (!PartEntry->IsPartitioned &&
2011 (PartitionCreateChecks(PartEntry, 0ULL, 0) == NOT_AN_ERROR));
2012
2013 if (!PartEntry->IsPartitioned)
2014 {
2015 /* Show the "Create" partition button, but enable it
2016 * only if the selected disk region can be partitioned */
2018 EnableDlgItem(hwndDlg, IDC_PARTCREATE, CanBePartitioned);
2019
2020 /* Hide and disable the "Format" button */
2023 }
2024 else
2025 {
2026 /* Hide and disable the "Create" partition button */
2029
2030 /* Show the "Format" button, but enable it only
2031 * if a formattable volume is present */
2033 EnableDlgItem(hwndDlg, IDC_PARTFORMAT, !!PartEntry->Volume);
2034 }
2035
2036 /* Show the "Delete" partition button, but enable it
2037 * only if the disk region is partitioned */
2039 EnableDlgItem(hwndDlg, IDC_PARTDELETE, PartEntry->IsPartitioned);
2040
2041 /*
2042 * Enable the "Next" button if:
2043 *
2044 * 1. the selected disk region is partitioned:
2045 * it can either have a volume attached (and be either
2046 * formatted or ready to be formatted),
2047 * or it's not yet formatted (the installer will prompt
2048 * for formatting parameters).
2049 *
2050 * 2. Or, the selected disk region is not partitioned, but
2051 * can be partitioned according to the disk's partitioning
2052 * scheme (the installer will auto-partition the region
2053 * and prompt for formatting parameters).
2054 *
2055 * In all other cases, the "Next" button is disabled.
2056 */
2057
2058 // TODO: In the future: first test needs to be augmented with:
2059 // (... && PartEntry->Volume->IsSimpleVolume)
2060 if ((PartEntry->IsPartitioned && PartEntry->Volume) || CanBePartitioned)
2061 {
2062 // ASSERT(PartEntry != PartEntry->DiskEntry->ExtendedPartition);
2065 }
2066 else
2067 {
2068 goto DisableWizNext;
2069 }
2070 }
2071 }
2072 else
2073 {
2074DisableWizNext:
2075 /* Keep the "Next" button disabled. It will be enabled
2076 * only when the user selects a valid partition. */
2078 }
2079
2080 break;
2081 }
2082
2083 if (lpnm->idFrom == IDC_PARTITION && lpnm->code == TVN_DELETEITEM)
2084 {
2085 /* Deleting an item from the partition list */
2087 DeleteTreeItem(lpnm->hwndFrom, (TLITEMW*)&pnmv->itemOld);
2088 break;
2089 }
2090
2091 switch (lpnm->code)
2092 {
2093 case PSN_SETACTIVE:
2094 {
2095 /* Keep the "Next" button disabled. It will be enabled
2096 * only when the user selects a valid partition. */
2098 break;
2099 }
2100
2102 {
2103 /* Reselect the currently selected item, so as to refresh the UI buttons */
2104 HTLITEM hItem;
2105 hList = GetDlgItem(hwndDlg, IDC_PARTITION);
2107 if (hItem)
2108 {
2109 /* Don't use TreeList_SelectItem() directly. Instead,
2110 * deselect first the item before reselecting it, so as to
2111 * invalidate its cached state and have the TVN_SELCHANGED
2112 * notification sent. */
2113 TreeList_SetItemState(hList, hItem, 0, TVIS_SELECTED);
2114 TreeList_SetItemState(hList, hItem, TVIS_SELECTED, TVIS_SELECTED);
2115 }
2116
2117 /* Focus on the partition list */
2119 return TRUE;
2120 }
2121
2122 case PSN_QUERYCANCEL:
2123 {
2124 if (DisplayMessage(GetParent(hwndDlg),
2128 {
2129 /* Go to the Abort page */
2131 }
2132
2133 /* Do not close the wizard too soon */
2135 return TRUE;
2136 }
2137
2138 case PSN_WIZNEXT:
2139 {
2140 /* Select the install partition and if success, go to the next page */
2141 if (SelectInstallPartition(pSetupData, hwndDlg))
2142 break;
2143 /* Failed, stay on the page */
2144 SetWindowLongPtrW(hwndDlg, DWLP_MSGRESULT, -1);
2145 return TRUE;
2146 }
2147
2148 default:
2149 break;
2150 }
2151 break;
2152 }
2153
2154 default:
2155 break;
2156 }
2157
2158 return FALSE;
2159}
UI_CONTEXT UiContext
Definition: reactos.c:38
INT __cdecl DisplayMessage(_In_opt_ HWND hWnd, _In_ UINT uType, _In_opt_ PCWSTR pszTitle, _In_opt_ PCWSTR pszFormatMessage,...)
Definition: reactos.c:245
#define ShowDlgItem(hDlg, nID, nCmdShow)
Definition: reactos.h:34
#define ID_WIZNEXT
Definition: reactos.h:47
struct _SETUPDATA * PSETUPDATA
#define IDS_WARN_DELETE_PARTITION
Definition: resource.h:179
#define IDC_INITDISK
Definition: resource.h:51
#define IDD_ABORTPAGE
Definition: resource.h:78
#define IDC_PARTMOREOPTS
Definition: resource.h:56
#define IDS_ERROR_CREATE_PARTITION_TITLE
Definition: resource.h:175
#define IDC_PARTDELETE
Definition: resource.h:54
#define IDS_WARN_DELETE_PARTITION_TITLE
Definition: resource.h:178
#define IDS_ERROR_CREATE_PARTITION
Definition: resource.h:176
#define IDC_PARTITION
Definition: resource.h:50
#define IDD_FORMAT
Definition: resource.h:93
#define IDD_ADVINSTOPTS
Definition: resource.h:80
#define IDC_PARTFORMAT
Definition: resource.h:53
#define IDC_PARTCREATE
Definition: resource.h:52
#define IDS_ABORTSETUP2
Definition: resource.h:111
#define IDS_ABORTSETUP
Definition: resource.h:110
#define IDD_PARTITION
Definition: resource.h:84
#define IDS_WARN_DELETE_MBR_EXTENDED_PARTITION
Definition: resource.h:180
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static VOID InitPartitionList(_In_ HINSTANCE hInstance, _In_ HWND hWndList)
Definition: drivepage.c:1282
static BOOLEAN DoDeletePartition(_In_ HWND hList, _In_ PPARTLIST List, _Inout_ HTLITEM *phItem, _In_ PPARTITEM PartItem)
Delete the selected partition in the partition list, and update the partition list UI.
Definition: drivepage.c:1467
static BOOLEAN SelectInstallPartition(_In_ PSETUPDATA pSetupData, _In_ HWND hwndDlg)
Definition: drivepage.c:1569
static INT_PTR CALLBACK PartitionDlgProc(_In_ HWND hDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: drivepage.c:598
static BOOLEAN DoCreatePartition(_In_ HWND hList, _In_ PPARTLIST List, _Inout_ HTLITEM *phItem, _Inout_opt_ PPARTITEM *pPartItem, _In_opt_ ULONGLONG SizeBytes, _In_opt_ ULONG_PTR PartitionInfo)
Create a partition in the selected disk region in the partition list, and update the partition list U...
Definition: drivepage.c:1367
static PPARTITEM GetSelectedPartition(_In_ HWND hTreeList, _Out_opt_ HTLITEM *phItem)
Definition: drivepage.c:796
static INT_PTR CALLBACK FormatDlgProc(_In_ HWND hDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: drivepage.c:553
static VOID DrawPartitionList(_In_ HWND hWndList, _In_ PPARTLIST List)
Definition: drivepage.c:1319
static INT_PTR CALLBACK MoreOptDlgProc(_In_ HWND hDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: drivepage.c:214
static VOID CleanupPartitionList(_In_ HWND hWndList)
Definition: drivepage.c:1344
static VOID DeleteTreeItem(_In_ HWND hWndList, _In_ TLITEMW *ptlItem)
Called on response to the TVN_DELETEITEM notification sent by the TreeList.
Definition: drivepage.c:1112
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
@ NOT_AN_ERROR
Definition: errorcode.h:17
#define EnableDlgItem(hDlg, nID, bEnable)
Definition: eventvwr.h:55
#define GetPartEntrySizeInBytes(PartEntry)
Definition: partlist.h:255
struct _DISKENTRY * PDISKENTRY
VOID DisplayError(DWORD dwError)
Definition: logoff.c:33
LONG_PTR LPARAM
Definition: minwindef.h:175
#define ULL(a, b)
Definition: format_msg.c:27
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define DBG_UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:330
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:321
#define PARTITION_EXTENDED
Definition: part_mbr.h:55
#define LOWORD(l)
Definition: pedump.c:82
#define PropSheet_PressButton(d, i)
Definition: prsht.h:348
#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 PSBTN_NEXT
Definition: prsht.h:147
#define PropSheet_SetWizButtons(d, f)
Definition: prsht.h:357
#define PSN_QUERYINITIALFOCUS
Definition: prsht.h:126
#define PropSheet_SetCurSelByID(d, i)
Definition: prsht.h:354
#define PSN_SETACTIVE
Definition: prsht.h:115
#define TVN_DELETEITEM
Definition: commctrl.h:3747
#define TVN_SELCHANGED
Definition: commctrl.h:3740
#define TVN_KEYDOWN
Definition: commctrl.h:3718
#define LPNMTREEVIEW
Definition: commctrl.h:3648
#define TVIS_SELECTED
Definition: commctrl.h:3285
#define NM_RETURN
Definition: commctrl.h:132
#define TVIF_STATE
Definition: commctrl.h:3274
#define WM_NOTIFY
Definition: richedit.h:61
ERROR_NUMBER NTAPI PartitionCreateChecks(_In_ PPARTENTRY PartEntry, _In_opt_ ULONGLONG SizeBytes, _In_opt_ ULONG_PTR PartitionInfo)
Definition: partlist.c:2946
ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
Definition: partlist.c:97
#define MB
Definition: setuplib.h:75
PARTITION_STYLE DiskStyle
Definition: partlist.h:139
Dialog context structure used by PartitionDlgProc() and FormatDlgProc(Worker)().
Definition: drivepage.c:368
BOOLEAN MBRExtPart
Definition: drivepage.c:372
PPARTITEM PartItem
Definition: drivepage.c:369
BOOLEAN ForceFormat
Definition: drivepage.c:373
ULONG PartSizeMB
Definition: drivepage.c:371
UCHAR PartitionType
Definition: partlist.h:73
struct _DISKENTRY * DiskEntry
Definition: partlist.h:66
HINSTANCE hInstance
Definition: reactos.h:127
PPARTLIST PartitionList
Definition: reactos.h:160
HWND hPartList
Definition: reactos.h:70
UINT_PTR idFrom
Definition: winuser.h:3266
UINT code
Definition: winuser.h:3267
HWND hwndFrom
Definition: winuser.h:3265
#define GWLP_USERDATA
Definition: treelist.c:63
#define TLITEMW
Definition: treelist.h:478
HTREEITEM hItem
Definition: treelist.h:37
#define TreeList_GetSelection(h)
Definition: treelist.h:450
int32_t INT_PTR
Definition: typedefs.h:64
uint64_t ULONGLONG
Definition: typedefs.h:67
uint32_t ULONG
Definition: typedefs.h:59
#define HIWORD(l)
Definition: typedefs.h:247
#define MAKEWPARAM(l, h)
Definition: winuser.h:4117
#define SW_HIDE
Definition: winuser.h:779
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_COMMAND
Definition: winuser.h:1768
#define WM_INITDIALOG
Definition: winuser.h:1767
#define MB_YESNO
Definition: winuser.h:828
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:841
#define MB_ICONERROR
Definition: winuser.h:798
struct tagNMHDR * LPNMHDR
#define MB_OK
Definition: winuser.h:801
BOOL WINAPI IsWindowEnabled(_In_ HWND)
#define MB_ICONWARNING
Definition: winuser.h:797
HWND WINAPI GetParent(_In_ HWND)
#define MB_ICONQUESTION
Definition: winuser.h:800
#define DWLP_MSGRESULT
Definition: winuser.h:881
#define MB_DEFBUTTON2
Definition: winuser.h:810
#define BN_CLICKED
Definition: winuser.h:1954
#define SW_SHOW
Definition: winuser.h:786
#define VK_DELETE
Definition: winuser.h:2269
#define WM_DESTROY
Definition: winuser.h:1637
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define IDYES
Definition: winuser.h:846
#define SetWindowLongPtrW
Definition: winuser.h:5512
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

◆ FindVolCreateInTreeByVolume()

PVOL_CREATE_INFO FindVolCreateInTreeByVolume ( _In_ HWND  hTreeList,
_In_ PVOLENTRY  Volume 
)

Definition at line 815 of file drivepage.c.

818{
820
821 /* Enumerate every cached data in the TreeList, and for each, check
822 * whether its corresponding PPARTENTRY is the one we are looking for */
823 // for (hItem = TVI_ROOT; hItem; hItem = TreeList_GetNextItem(...)) { }
824 hItem = TVI_ROOT;
825 while ((hItem = TreeList_GetNextItem(hTreeList, hItem, TVGN_NEXTITEM)))
826 {
827 PPARTITEM PartItem = GetItemPartition(hTreeList, hItem);
828 if (!PartItem || !PartItem->VolCreate /* || !PartItem->Volume */)
829 continue;
830
831 if (PartItem->Volume == Volume)
832 {
833 /* Found it, return the associated volume-create structure */
834 return PartItem->VolCreate;
835 }
836 }
837
838 /* Nothing was found */
839 return NULL;
840}
UNICODE_STRING Volume
Definition: fltkernel.h:1172
#define TVI_ROOT
Definition: commctrl.h:3373
#define TreeList_GetNextItem(h, i, c)
Definition: treelist.h:440
#define TVGN_NEXTITEM
Definition: treelist.h:166

Referenced by FsVolCallback().

◆ FormatDlgProc()

static INT_PTR CALLBACK FormatDlgProc ( _In_ HWND  hDlg,
_In_ UINT  uMsg,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)
static

Definition at line 553 of file drivepage.c.

558{
559 PPARTCREATE_CTX PartCreateCtx;
560
561 /* Retrieve dialog context pointer */
562 PartCreateCtx = (PPARTCREATE_CTX)GetWindowLongPtrW(hDlg, GWLP_USERDATA);
563
564 switch (uMsg)
565 {
566 case WM_INITDIALOG:
567 {
568 /* Save dialog context pointer */
569 PartCreateCtx = (PPARTCREATE_CTX)lParam;
570 SetWindowLongPtrW(hDlg, GWLP_USERDATA, (LONG_PTR)PartCreateCtx);
571
572 /* We actually want to format, so set the flag */
573 PartCreateCtx->ForceFormat = TRUE;
574 break;
575 }
576
577 case WM_COMMAND:
578 {
579 if (HIWORD(wParam) == BN_CLICKED) switch (LOWORD(wParam))
580 {
581 case IDOK:
582 /* Retrieve the formatting options */
583 FormatDlgProcWorker(PartCreateCtx, hDlg, uMsg, wParam, lParam);
585 case IDCANCEL:
586 EndDialog(hDlg, LOWORD(wParam));
587 return TRUE;
588 }
589 break;
590 }
591 }
592
593 return FormatDlgProcWorker(PartCreateCtx, hDlg, uMsg, wParam, lParam);
594}
static INT_PTR CALLBACK FormatDlgProcWorker(_In_ PPARTCREATE_CTX PartCreateCtx, _In_ HWND hDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: drivepage.c:378
struct _PARTCREATE_CTX * PPARTCREATE_CTX
#define __fallthrough
Definition: sal_old.h:314
#define IDCANCEL
Definition: winuser.h:842
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by DriveDlgProc(), and SelectInstallPartition().

◆ FormatDlgProcWorker()

static INT_PTR CALLBACK FormatDlgProcWorker ( _In_ PPARTCREATE_CTX  PartCreateCtx,
_In_ HWND  hDlg,
_In_ UINT  uMsg,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)
static

Definition at line 378 of file drivepage.c.

384{
385 switch (uMsg)
386 {
387 case WM_INITDIALOG:
388 {
389 ULONG Index = 0;
390 INT iItem;
392 PCWSTR DefaultFs;
394 PVOL_CREATE_INFO VolCreate;
395
396 /* List the well-known file systems. We use the same strings
397 * for the displayed FS names and their actual ones. */
399 {
401 if (iItem != CB_ERR && iItem != CB_ERRSPACE)
403 }
404
405 /* Add the 'Do not format' entry if needed */
406 if (!PartCreateCtx->ForceFormat)
407 {
408 WCHAR szText[50];
409
411 iItem = SendDlgItemMessageW(hDlg, IDC_FSTYPE, CB_INSERTSTRING, 0, (LPARAM)szText);
412 if (iItem != CB_ERR && iItem != CB_ERRSPACE)
414 }
415
416 // FIXME: Read from SetupData.FsType; select the "FAT" FS instead.
417 DefaultFs = L"FAT";
418
419 /* Retrieve the selected volume and create information */
420 ASSERT(PartCreateCtx->PartItem->Volume == PartCreateCtx->PartItem->PartEntry->Volume);
421 Volume = PartCreateCtx->PartItem->PartEntry->Volume;
422 VolCreate = PartCreateCtx->PartItem->VolCreate;
423
424 /* Select the existing file system in the list if any,
425 * otherwise use the "DefaultFs" */
426 if (VolCreate && *VolCreate->FileSystemName)
427 FileSystem = VolCreate->FileSystemName;
428 else if (Volume && *Volume->Info.FileSystem)
429 FileSystem = Volume->Info.FileSystem;
430 else
431 FileSystem = DefaultFs;
432
434 if (iItem == CB_ERR)
435 iItem = 0;
437
438 /* Check the quick-format option by default as it speeds up formatting */
439 if (!VolCreate || VolCreate->QuickFormat)
441 else
443
444 return TRUE;
445 }
446
447 case WM_COMMAND:
448 {
449 //
450 // NOTE:
451 // - CBN_SELCHANGE sent everytime a combobox list item is selected,
452 // *even if* the list is opened.
453 // - CBN_SELENDOK sent only when user finished to select an item
454 // by clicking on it (if the list is opened), or selection changed
455 // (when the list is closed but selection is done with arrow keys).
456 //
457 if ((HIWORD(wParam) == CBN_SELCHANGE /*|| HIWORD(wParam) == CBN_SELENDOK*/) &&
459 {
460 // HWND hWndList = GetDlgItem(hDlg, IDC_FSTYPE);
462 INT iItem;
463
464 /* Retrieve the selected file system. Use the
465 * item data instead of the displayed string. */
466 iItem = SendDlgItemMessageW(hDlg, IDC_FSTYPE, CB_GETCURSEL, 0, 0);
467 if (iItem == CB_ERR)
468 iItem = 0; // Default entry
470 if (FileSystem == (PCWSTR)CB_ERR)
471 FileSystem = NULL; // Default data
472
473 /* Enable or disable formatting options,
474 * depending on whether we need to format */
476 return TRUE;
477 }
478
479 if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDOK)
480 {
481 PPARTITEM PartItem = PartCreateCtx->PartItem;
482 PVOL_CREATE_INFO VolCreate;
484 INT iItem;
485
486 /*
487 * Retrieve the formatting options
488 */
489
490 /* Retrieve the selected file system. Use the
491 * item data instead of the displayed string. */
492 iItem = SendDlgItemMessageW(hDlg, IDC_FSTYPE, CB_GETCURSEL, 0, 0);
493 if (iItem == CB_ERR)
494 iItem = 0; // Default entry
496 if (FileSystem == (PCWSTR)CB_ERR)
497 FileSystem = NULL; // Default data
498
499 VolCreate = PartItem->VolCreate;
500
501 /* Check if we need to format */
502 if (!FileSystem || !*FileSystem)
503 {
504 /* We don't format. If there is an existing
505 * volume-create structure, free it. */
506 if (VolCreate)
507 LocalFree(VolCreate);
508 PartItem->VolCreate = NULL;
509
510 /* And return */
511 return TRUE;
512 }
513
514 /* We will format: allocate and initialize
515 * a volume-create structure if needed */
516 if (!VolCreate)
517 VolCreate = LocalAlloc(LPTR, sizeof(*VolCreate));
518 if (!VolCreate)
519 {
520 DPRINT1("Failed to allocate volume-create structure\n");
521 return TRUE;
522 }
523
524 /* Cached input information that will be set to
525 * the FORMAT_VOLUME_INFO structure given to the
526 * 'FSVOLNOTIFY_STARTFORMAT' step */
527 // TODO: Think about which values could be defaulted...
529 _countof(VolCreate->FileSystemName),
530 FileSystem);
531 VolCreate->MediaFlag = FMIFS_HARDDISK;
532 VolCreate->Label = NULL;
533 VolCreate->QuickFormat =
535 VolCreate->ClusterSize = 0;
536
537 /* Set the volume associated to the new create information */
538 VolCreate->Volume = PartItem->Volume;
539
540 /* Associate the new, or update the volume create information */
541 PartItem->VolCreate = VolCreate;
542 return TRUE;
543 }
544 break;
545 }
546 }
547
548 return FALSE;
549}
#define DPRINT1
Definition: precomp.h:8
SETUPDATA SetupData
Definition: reactos.c:24
#define IDC_FSTYPE
Definition: resource.h:90
#define IDC_CHECK_QUICKFMT
Definition: resource.h:91
#define IDS_VOLUME_NOFORMAT
Definition: resource.h:118
PWCHAR FileSystem
Definition: format.c:71
@ FMIFS_HARDDISK
Definition: fmifs.h:66
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
#define LPTR
Definition: minwinbase.h:93
UINT_PTR WPARAM
Definition: minwindef.h:174
BOOLEAN NTAPI GetRegisteredFileSystems(IN ULONG Index, OUT PCWSTR *FileSystemName)
Definition: fsutil.c:183
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
ULONG ClusterSize
Definition: reactos.h:199
BOOLEAN QuickFormat
Definition: reactos.h:198
WCHAR FileSystemName[MAX_PATH+1]
Definition: reactos.h:195
FMIFS_MEDIA_FLAG MediaFlag
Definition: reactos.h:196
PCWSTR Label
Definition: reactos.h:197
const uint16_t * PCWSTR
Definition: typedefs.h:57
int32_t INT
Definition: typedefs.h:58
_In_ WDFCOLLECTION _In_ ULONG Index
#define CB_SETITEMDATA
Definition: winuser.h:1995
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define BST_UNCHECKED
Definition: winuser.h:199
#define CB_ERRSPACE
Definition: winuser.h:2472
#define CB_ERR
Definition: winuser.h:2471
#define CB_SETCURSEL
Definition: winuser.h:1990
#define CB_FINDSTRINGEXACT
Definition: winuser.h:1969
#define CBN_SELCHANGE
Definition: winuser.h:2008
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
#define CB_GETITEMDATA
Definition: winuser.h:1979
#define CB_INSERTSTRING
Definition: winuser.h:1986
#define CB_GETCURSEL
Definition: winuser.h:1972
#define BST_CHECKED
Definition: winuser.h:197

Referenced by FormatDlgProc(), and PartitionDlgProc().

◆ GetItemPartition()

static PPARTITEM GetItemPartition ( _In_ HWND  hTreeList,
_In_ HTLITEM  hItem 
)
static

Definition at line 778 of file drivepage.c.

781{
782 HTLITEM hParentItem;
783 PPARTITEM PartItem;
784
785 hParentItem = TreeList_GetParent(hTreeList, hItem);
786 /* May or may not be a PPARTITEM: this is a PPARTITEM only when hParentItem != NULL */
787 PartItem = (PPARTITEM)TreeListGetItemData(hTreeList, hItem);
788 if (!hParentItem || !PartItem)
789 return NULL;
790
791 return PartItem;
792}
LPARAM TreeListGetItemData(_In_ HWND hTreeList, _In_ HTLITEM hItem)
Definition: drivepage.c:762

Referenced by DoCreatePartition(), DoDeletePartition(), FindVolCreateInTreeByVolume(), and GetSelectedPartition().

◆ GetPartitionTypeString()

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

Definition at line 844 of file drivepage.c.

848{
849 if (PartEntry->PartitionType == PARTITION_ENTRY_UNUSED)
850 {
851 StringCchCopyA(strBuffer, cchBuffer,
852 "Unused" /* MUIGetString(STRING_FORMATUNUSED) */);
853 }
854 // else if (PartEntry == PartEntry->DiskEntry->ExtendedPartition)
855 else if (IsContainerPartition(PartEntry->PartitionType))
856 {
857 StringCchCopyA(strBuffer, cchBuffer,
858 "Extended Partition" /* MUIGetString(STRING_EXTENDED_PARTITION) */);
859 }
860 else
861 {
862 /* Do the table lookup */
863 PCSTR Description = LookupPartitionTypeString(PartEntry->DiskEntry->DiskStyle,
864 &PartEntry->PartitionType);
865 if (Description)
866 {
868 return;
869 }
870
871 /* We are here because the partition type is unknown */
872 if (cchBuffer > 0) *strBuffer = '\0';
873 }
874
875 if ((cchBuffer > 0) && (*strBuffer == '\0'))
876 {
877 StringCchPrintfA(strBuffer, cchBuffer,
878 // MUIGetString(STRING_PARTTYPE),
879 "Type 0x%02x",
880 PartEntry->PartitionType);
881 }
882}
PCSTR NTAPI LookupPartitionTypeString(_In_ PARTITION_STYLE PartitionStyle, _In_ PVOID PartitionType)
Definition: partinfo.c:804
static DWORD cchBuffer
Definition: fusion.c:85
_Must_inspect_result_ _In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ LPGUID _In_opt_ HANDLE _In_opt_ ULONG _In_opt_ ULONG _In_opt_ ULONG _In_opt_ PLARGE_INTEGER _In_opt_ PUNICODE_STRING Description
Definition: nttmapi.h:425
#define PARTITION_ENTRY_UNUSED
Definition: part_mbr.h:50
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
const char * PCSTR
Definition: typedefs.h:52

Referenced by PrintPartitionData().

◆ GetSelectedPartition()

static PPARTITEM GetSelectedPartition ( _In_ HWND  hTreeList,
_Out_opt_ HTLITEM phItem 
)
static

Definition at line 796 of file drivepage.c.

799{
801 PPARTITEM PartItem;
802
803 hItem = TreeList_GetSelection(hTreeList);
804 if (!hItem)
805 return NULL;
806
807 PartItem = GetItemPartition(hTreeList, hItem);
808 if (PartItem && phItem)
809 *phItem = hItem;
810
811 return PartItem;
812}

Referenced by DriveDlgProc(), and SelectInstallPartition().

◆ InitPartitionList()

static VOID InitPartitionList ( _In_ HINSTANCE  hInstance,
_In_ HWND  hWndList 
)
static

Definition at line 1282 of file drivepage.c.

1285{
1286 const DWORD dwStyle = TVS_HASBUTTONS | /*TVS_HASLINES | TVS_LINESATROOT |*/ TVS_SHOWSELALWAYS | TVS_FULLROWSELECT;
1287 const DWORD dwExStyle = TVS_EX_FULLROWMARK /* | TVS_EX_FULLROWITEMS*/;
1288 HIMAGELIST hSmall;
1289
1290 /* Set the TreeList styles and fixup the item selection color */
1292 // TreeList_SetStyleEx(hWndList, dwStyle, dwStyle);
1295
1296 /* Initialize its columns */
1298 hWndList,
1299 column_ids,
1303
1304 /* Create the ImageList */
1307 ILC_COLOR32 | ILC_MASK, // ILC_COLOR24
1308 1, 1);
1309
1310 /* Add event type icons to the ImageList */
1313
1314 /* Assign the ImageList to the List View */
1316}
#define IDI_PARTITION
Definition: resource.h:21
#define IDI_DISKDRIVE
Definition: resource.h:20
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:814
static const INT column_widths[MAX_LIST_COLUMNS]
Definition: drivepage.c:31
#define MAX_LIST_COLUMNS
Definition: drivepage.c:29
static const INT column_alignment[MAX_LIST_COLUMNS]
Definition: drivepage.c:32
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:699
static const UINT column_ids[MAX_LIST_COLUMNS]
Definition: drivepage.c:30
unsigned long DWORD
Definition: ntddk_ex.h:95
#define TVS_SHOWSELALWAYS
Definition: commctrl.h:3257
#define ILC_COLOR32
Definition: commctrl.h:358
#define TVS_FULLROWSELECT
Definition: commctrl.h:3264
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define TVS_HASBUTTONS
Definition: commctrl.h:3252
#define ILC_MASK
Definition: commctrl.h:351
#define TVC_MARK
Definition: treelist.h:145
#define TreeList_SetColor(h, i, c)
Definition: treelist.h:379
#define TreeList_SetExtendedStyle(h, d)
Definition: treelist.h:376
#define TreeList_SetStyle(h, d)
Definition: treelist.h:430
#define TVS_EX_FULLROWMARK
Definition: treelist.h:272
#define TreeList_GetStyle(h)
Definition: treelist.h:429
DWORD WINAPI GetSysColor(_In_ int)
#define COLOR_HIGHLIGHT
Definition: winuser.h:937
#define SM_CYSMICON
Definition: winuser.h:1024
#define SM_CXSMICON
Definition: winuser.h:1023
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2444
int WINAPI GetSystemMetrics(_In_ int)

Referenced by DriveDlgProc().

◆ InstallDirEditProc()

static LRESULT CALLBACK InstallDirEditProc ( _In_ HWND  hWnd,
_In_ UINT  uMsg,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)
static

Subclass edit window procedure to filter allowed characters for the ReactOS installation directory.

Definition at line 151 of file drivepage.c.

156{
158
159 switch (uMsg)
160 {
161 case WM_UNICHAR:
162 if (wParam == UNICODE_NOCHAR)
163 return TRUE;
165
166 case WM_IME_CHAR:
167 case WM_CHAR:
168 {
169 WCHAR wch = (WCHAR)wParam;
170
171 /* Let the EDIT control deal with Control characters.
172 * It won't emit them as raw data in the text. */
173 if (wParam < ' ')
174 break;
175
176 /* Ignore Ctrl-Backspace */
177 if (wParam == '\x7F')
178 return 0;
179
180 /* Protect read-only edit control from modification */
182 break;
183
184 if (uMsg == WM_IME_CHAR)
185 {
186 if (!IsWindowUnicode(hWnd) && HIBYTE(wch) != 0)
187 {
188 CHAR data[] = {HIBYTE(wch), LOBYTE(wch)};
189 MultiByteToWideChar(CP_ACP, 0, data, 2, &wch, 1);
190 }
191 }
192
193 /* Show an error and ignore input character if it's invalid */
195 {
197 return 0;
198 }
199 break;
200 }
201
202 case WM_PASTE:
203 /* Verify the text being pasted; if it was sanitized, show an error */
206 break;
207 }
208
209 return CallWindowProcW(orgEditProc, hWnd, uMsg, wParam, lParam);
210}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
static VOID ShowErrorTip(_In_ HWND hEdit)
Definition: drivepage.c:116
static BOOL DoSanitizeClipboard(_In_ HWND hWnd)
Sanitize in-place any text found in the clipboard.
Definition: drivepage.c:71
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HIBYTE(W)
Definition: jmemdos.c:486
char CHAR
Definition: pedump.c:57
#define WM_UNICHAR
Definition: richedit.h:67
#define WM_PASTE
Definition: winuser.h:1891
BOOL WINAPI IsWindowUnicode(_In_ HWND)
#define WM_IME_CHAR
Definition: winuser.h:1862
#define WM_CHAR
Definition: winuser.h:1745
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:3014
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by MoreOptDlgProc().

◆ MoreOptDlgProc()

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

Definition at line 214 of file drivepage.c.

219{
220 PSETUPDATA pSetupData;
221
222 /* Retrieve pointer to the global setup data */
223 pSetupData = (PSETUPDATA)GetWindowLongPtrW(hDlg, GWLP_USERDATA);
224
225 switch (uMsg)
226 {
227 case WM_INITDIALOG:
228 {
229 HWND hEdit;
230 WNDPROC orgEditProc;
231 BOOL bIsBIOS;
232 UINT uID;
233 INT iItem, iCurrent = CB_ERR, iDefault = 0;
234 WCHAR szText[50];
235
236 /* Save pointer to the global setup data */
237 pSetupData = (PSETUPDATA)lParam;
238 SetWindowLongPtrW(hDlg, GWLP_USERDATA, (LONG_PTR)pSetupData);
239
240 /* Subclass the install-dir edit control */
241 hEdit = GetDlgItem(hDlg, IDC_PATH);
245
246 /* Set the current installation directory */
248
249
250 /* Initialize the list of available bootloader locations */
251 bIsBIOS = ((pSetupData->USetupData.ArchType == ARCH_PcAT) ||
252 (pSetupData->USetupData.ArchType == ARCH_NEC98x86));
254 {
255 if ( ( bIsBIOS && (uID == IDS_BOOTLOADER_SYSTEM)) ||
256 (!bIsBIOS && (uID == IDS_BOOTLOADER_MBRVBR || uID == IDS_BOOTLOADER_VBRONLY)) )
257 {
258 continue; // Skip this choice.
259 }
260
261 LoadStringW(pSetupData->hInstance, uID, szText, ARRAYSIZE(szText));
262 iItem = SendDlgItemMessageW(hDlg, IDC_INSTFREELDR, CB_ADDSTRING, 0, (LPARAM)szText);
263 if (iItem != CB_ERR && iItem != CB_ERRSPACE)
264 {
265 UINT uBldrLoc = uID - IDS_BOOTLOADER_NOINST
266 - (bIsBIOS && (uID >= IDS_BOOTLOADER_SYSTEM) ? 1 : 0);
267 SendDlgItemMessageW(hDlg, IDC_INSTFREELDR, CB_SETITEMDATA, iItem, uBldrLoc);
268
269 /* Find the index of the current and default locations */
270 if (uBldrLoc == pSetupData->USetupData.BootLoaderLocation)
271 iCurrent = iItem;
273 iDefault = iItem;
274 }
275 }
276 /* Select the current location or fall back to the default one */
277 if (iCurrent == CB_ERR)
278 iCurrent = iDefault;
280
281 return TRUE;
282 }
283
284 case WM_DESTROY:
285 {
286 /* Unsubclass the edit control */
287 HWND hEdit = GetDlgItem(hDlg, IDC_PATH);
289 if (orgEditProc) SetWindowLongPtrW(hEdit, GWLP_WNDPROC, (LONG_PTR)orgEditProc);
290 break;
291 }
292
293 case WM_COMMAND:
294 {
295 if (HIWORD(wParam) == BN_CLICKED) switch (LOWORD(wParam))
296 {
297 case IDOK:
298 {
299 HWND hEdit;
300 BOOL bIsValid;
301 WCHAR InstallDir[MAX_PATH];
302 INT iItem;
303 UINT uBldrLoc = CB_ERR;
304
305 /*
306 * Retrieve the installation path and verify its validity.
307 * Check for the validity of the installation directory and
308 * pop up an error if this is not the case.
309 */
310 hEdit = GetDlgItem(hDlg, IDC_PATH);
311 bIsValid = (GetWindowTextLengthW(hEdit) < _countof(InstallDir)); // && IsValidInstallDirectory(InstallDir);
312 GetWindowTextW(hEdit, InstallDir, _countof(InstallDir));
313 bIsValid = bIsValid && IsValidInstallDirectory(InstallDir);
314
315 if (!bIsValid)
316 {
317 // ERROR_DIRECTORY_NAME
318 DisplayError(hDlg,
321 break; // Go back to the dialog.
322 }
323
326 InstallDir);
327
328 /* Retrieve the bootloader location */
330 if (iItem != CB_ERR)
331 uBldrLoc = SendDlgItemMessageW(hDlg, IDC_INSTFREELDR, CB_GETITEMDATA, iItem, 0);
332 if (uBldrLoc == CB_ERR) // Default location: System partition / MBR & VBR
334 uBldrLoc = min(max(uBldrLoc, 0), 3);
335 pSetupData->USetupData.BootLoaderLocation = uBldrLoc;
336
338 }
339 case IDCANCEL:
340 EndDialog(hDlg, LOWORD(wParam));
341 return TRUE;
342 }
343 break;
344 }
345 }
346
347 return FALSE;
348}
#define IDS_BOOTLOADER_MBRVBR
Definition: resource.h:133
#define IDS_BOOTLOADER_SYSTEM
Definition: resource.h:132
#define IDS_BOOTLOADER_VBRONLY
Definition: resource.h:134
#define IDC_PATH
Definition: resource.h:81
#define IDC_INSTFREELDR
Definition: resource.h:82
#define IDS_ERROR_DIRECTORY_NAME_TITLE
Definition: resource.h:171
#define IDS_ERROR_DIRECTORY_NAME
Definition: resource.h:172
#define IDS_BOOTLOADER_NOINST
Definition: resource.h:130
#define MAX_PATH
Definition: compat.h:34
static LRESULT CALLBACK InstallDirEditProc(_In_ HWND hWnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
Subclass edit window procedure to filter allowed characters for the ReactOS installation directory.
Definition: drivepage.c:151
#define min(a, b)
Definition: monoChain.cc:55
_In_ UINT uID
Definition: shlwapi.h:156
BOOLEAN NTAPI IsValidInstallDirectory(_In_ PCWSTR InstallDir)
Verify whether the given directory is suitable for ReactOS installation. Each path component must be ...
Definition: setuplib.c:781
@ ARCH_NEC98x86
Definition: setuplib.h:55
@ ARCH_PcAT
Definition: setuplib.h:54
static HWND hEdit
Definition: autocomplete.c:34
USETUP_DATA USetupData
Definition: reactos.h:156
WCHAR InstallationDirectory[MAX_PATH]
Definition: setuplib.h:157
LONG BootLoaderLocation
Definition: setuplib.h:132
ARCHITECTURE_TYPE ArchType
Definition: setuplib.h:145
#define max(a, b)
Definition: svc.c:63
#define GWLP_WNDPROC
Definition: treelist.c:66
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1382
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define CB_ADDSTRING
Definition: winuser.h:1965
int WINAPI GetWindowTextLengthW(_In_ HWND)

Referenced by DriveDlgProc().

◆ PartitionDlgProc()

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

Definition at line 598 of file drivepage.c.

603{
604 PPARTCREATE_CTX PartCreateCtx;
605
606 /* Retrieve dialog context pointer */
607 PartCreateCtx = (PPARTCREATE_CTX)GetWindowLongPtrW(hDlg, GWLP_USERDATA);
608
609 switch (uMsg)
610 {
611 case WM_INITDIALOG:
612 {
613 PPARTENTRY PartEntry;
614 PDISKENTRY DiskEntry;
615 ULONG MaxSizeMB;
616
617 /* Save dialog context pointer */
618 PartCreateCtx = (PPARTCREATE_CTX)lParam;
619 SetWindowLongPtrW(hDlg, GWLP_USERDATA, (LONG_PTR)PartCreateCtx);
620
621 /* Retrieve the selected partition */
622 PartEntry = PartCreateCtx->PartItem->PartEntry;
623 DiskEntry = PartEntry->DiskEntry;
624
625 /* Set the spinner to the maximum size in MB the partition can have */
626 MaxSizeMB = PartCreateCtx->MaxSizeMB;
629
630 /* Default to regular partition (non-extended on MBR disks) */
632
633 /* Also, disable and hide IDC_CHECK_MBREXTPART
634 * if space is logical or the disk is not MBR */
635 if ((DiskEntry->DiskStyle == PARTITION_STYLE_MBR) &&
636 !PartEntry->LogicalPartition)
637 {
640 }
641 else
642 {
645 }
646 break;
647 }
648
649 case WM_COMMAND:
650 {
651 if (HIWORD(wParam) == BN_CLICKED) switch (LOWORD(wParam))
652 {
654 {
655 /* Check for MBR-extended (container) partition */
656 // BST_UNCHECKED or BST_INDETERMINATE => FALSE
658 {
659 /* It is, disable formatting options */
663 }
664 else
665 {
666 /* It is not, re-enable formatting options */
670 }
671 return TRUE;
672 }
673
674 case IDOK:
675 {
676 /* Collect all the information and return it
677 * to the caller for creating the partition */
679 PartCreateCtx->PartSizeMB = min(max(PartCreateCtx->PartSizeMB, 1), PartCreateCtx->MaxSizeMB);
681
682 /* Retrieve the formatting options */
683 FormatDlgProcWorker(PartCreateCtx, hDlg, uMsg, wParam, lParam);
685 }
686 case IDCANCEL:
687 EndDialog(hDlg, LOWORD(wParam));
688 return TRUE;
689 }
690 break;
691 }
692 }
693
694 return FormatDlgProcWorker(PartCreateCtx, hDlg, uMsg, wParam, lParam);
695}
#define IDC_CHECK_MBREXTPART
Definition: resource.h:88
#define IDC_FS_STATIC
Definition: resource.h:89
#define IDC_UPDOWN_PARTSIZE
Definition: resource.h:86
@ PARTITION_STYLE_MBR
Definition: imports.h:201
#define UDM_SETRANGE32
Definition: commctrl.h:2156
#define UDM_GETPOS32
Definition: commctrl.h:2161
#define UDM_SETPOS32
Definition: commctrl.h:2160
BOOLEAN LogicalPartition
Definition: partlist.h:79

Referenced by DriveDlgProc().

◆ PrettifySize1()

static VOID PrettifySize1 ( _Inout_ PULONGLONG  Size,
_Out_ PCWSTR Unit 
)
static

Definition at line 886 of file drivepage.c.

889{
890 ULONGLONG DiskSize = *Size;
891
892 if (DiskSize >= 10 * GB) /* 10 GB */
893 {
894 DiskSize = RoundingDivide(DiskSize, GB);
895 *Unit = L"GB"; // MUIGetString(STRING_GB);
896 }
897 else
898 {
899 DiskSize = RoundingDivide(DiskSize, MB);
900 if (DiskSize == 0)
901 DiskSize = 1;
902 *Unit = L"MB"; // MUIGetString(STRING_MB);
903 }
904
905 *Size = DiskSize;
906}
Unit
Definition: gdiplusenums.h:26
#define GB
Definition: setuplib.h:76
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539

Referenced by PrintDiskData().

◆ PrettifySize2()

static VOID PrettifySize2 ( _Inout_ PULONGLONG  Size,
_Out_ PCWSTR Unit 
)
static

Definition at line 909 of file drivepage.c.

912{
913 ULONGLONG PartSize = *Size;
914
915#if 0
916 if (PartSize >= 10 * GB) /* 10 GB */
917 {
918 PartSize = RoundingDivide(PartSize, GB);
919 *Unit = L"GB"; // MUIGetString(STRING_GB);
920 }
921 else
922#endif
923 if (PartSize >= 10 * MB) /* 10 MB */
924 {
925 PartSize = RoundingDivide(PartSize, MB);
926 *Unit = L"MB"; // MUIGetString(STRING_MB);
927 }
928 else
929 {
930 PartSize = RoundingDivide(PartSize, KB);
931 *Unit = L"KB"; // MUIGetString(STRING_KB);
932 }
933
934 *Size = PartSize;
935}
#define KB
Definition: setuplib.h:74

Referenced by PrintPartitionData().

◆ PrintDiskData()

static VOID PrintDiskData ( _In_ HWND  hWndList,
_In_opt_ HTLITEM  hInsertAfter,
_In_ PDISKENTRY  DiskEntry 
)
static

Definition at line 1134 of file drivepage.c.

1138{
1139 BOOL Success;
1140 HANDLE hDevice;
1141 PCHAR DiskName = NULL;
1142 ULONG Length = 0;
1143 PLIST_ENTRY PrimaryEntry;
1144 ULONGLONG DiskSize;
1145 HTLITEM htiDisk;
1146 WCHAR LineBuffer[128];
1147 UCHAR outBuf[512];
1148
1149 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
1150 // L"\\Device\\Harddisk%lu\\Partition%lu",
1151 L"\\\\.\\PhysicalDrive%lu",
1152 DiskEntry->DiskNumber);
1153
1154 hDevice = CreateFileW(
1155 LineBuffer, // device interface name
1156 GENERIC_READ /*| GENERIC_WRITE*/, // dwDesiredAccess
1157 FILE_SHARE_READ | FILE_SHARE_WRITE, // dwShareMode
1158 NULL, // lpSecurityAttributes
1159 OPEN_EXISTING, // dwCreationDistribution
1160 0, // dwFlagsAndAttributes
1161 NULL // hTemplateFile
1162 );
1163 if (hDevice != INVALID_HANDLE_VALUE)
1164 {
1166
1167 Query.PropertyId = StorageDeviceProperty;
1168 Query.QueryType = PropertyStandardQuery;
1169
1170 Success = DeviceIoControl(hDevice,
1172 &Query,
1173 sizeof(Query),
1174 &outBuf,
1175 sizeof(outBuf),
1176 &Length,
1177 NULL);
1178 if (Success)
1179 {
1181 if (devDesc->ProductIdOffset)
1182 {
1183 DiskName = (PCHAR)&outBuf[devDesc->ProductIdOffset];
1184 Length -= devDesc->ProductIdOffset;
1185 DiskName[min(Length, strlen(DiskName))] = 0;
1186 // ( i = devDesc->ProductIdOffset; p[i] != 0 && i < Length; i++ )
1187 }
1188 }
1189
1190 CloseHandle(hDevice);
1191 }
1192
1193 if (DiskName && *DiskName)
1194 {
1195 if (DiskEntry->DriverName.Length > 0)
1196 {
1197 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
1198 // MUIGetString(STRING_HDDINFO_1),
1199 L"Harddisk %lu (%S) (Port=%hu, Bus=%hu, Id=%hu) on %wZ",
1200 DiskEntry->DiskNumber,
1201 DiskName,
1202 DiskEntry->Port,
1203 DiskEntry->Bus,
1204 DiskEntry->Id,
1205 &DiskEntry->DriverName);
1206 }
1207 else
1208 {
1209 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
1210 // MUIGetString(STRING_HDDINFO_2),
1211 L"Harddisk %lu (%S) (Port=%hu, Bus=%hu, Id=%hu)",
1212 DiskEntry->DiskNumber,
1213 DiskName,
1214 DiskEntry->Port,
1215 DiskEntry->Bus,
1216 DiskEntry->Id);
1217 }
1218 }
1219 else
1220 {
1221 if (DiskEntry->DriverName.Length > 0)
1222 {
1223 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
1224 // MUIGetString(STRING_HDDINFO_1),
1225 L"Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %wZ",
1226 DiskEntry->DiskNumber,
1227 DiskEntry->Port,
1228 DiskEntry->Bus,
1229 DiskEntry->Id,
1230 &DiskEntry->DriverName);
1231 }
1232 else
1233 {
1234 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
1235 // MUIGetString(STRING_HDDINFO_2),
1236 L"Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu)",
1237 DiskEntry->DiskNumber,
1238 DiskEntry->Port,
1239 DiskEntry->Bus,
1240 DiskEntry->Id);
1241 }
1242 }
1243
1244 htiDisk = TreeListAddItem(hWndList, NULL, hInsertAfter,
1245 LineBuffer, 0, 0,
1246 (LPARAM)DiskEntry);
1247
1248 /* Disk type: MBR, GPT or RAW (Uninitialized) */
1249 TreeList_SetItemText(hWndList, htiDisk, 1,
1250 DiskEntry->DiskStyle == PARTITION_STYLE_MBR ? L"MBR" :
1251 DiskEntry->DiskStyle == PARTITION_STYLE_GPT ? L"GPT" :
1252 L"RAW");
1253
1254 /* Format the disk size */
1255 DiskSize = GetDiskSizeInBytes(DiskEntry);
1256 if (!StrFormatByteSizeW(DiskSize, LineBuffer, ARRAYSIZE(LineBuffer)))
1257 {
1258 /* We failed for whatever reason, do the hardcoded way */
1259 PCWSTR Unit;
1260 PrettifySize1(&DiskSize, &Unit);
1261 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
1262 L"%6I64u %s",
1263 DiskSize, Unit);
1264 }
1265 TreeList_SetItemText(hWndList, htiDisk, 2, LineBuffer);
1266
1267 /* Print partition lines */
1268 for (PrimaryEntry = DiskEntry->PrimaryPartListHead.Flink;
1269 PrimaryEntry != &DiskEntry->PrimaryPartListHead;
1270 PrimaryEntry = PrimaryEntry->Flink)
1271 {
1272 /* If this is an extended partition, recursively print the logical partitions */
1273 PPARTENTRY PartEntry = CONTAINING_RECORD(PrimaryEntry, PARTENTRY, ListEntry);
1274 PrintPartitionData(hWndList, htiDisk, NULL, PartEntry);
1275 }
1276
1277 /* Expand the disk node */
1279}
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 INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_SHARE_READ
Definition: compat.h:136
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:854
static VOID PrettifySize1(_Inout_ PULONGLONG Size, _Out_ PCWSTR *Unit)
Definition: drivepage.c:886
HTLITEM TreeListAddItem(_In_ HWND hTreeList, _In_opt_ HTLITEM hParent, _In_opt_ HTLITEM hInsertAfter, _In_ LPCWSTR lpText, _In_ INT iImage, _In_ INT iSelectedImage, _In_ LPARAM lParam)
Definition: drivepage.c:733
#define GetDiskSizeInBytes(DiskEntry)
Definition: partlist.h:258
#define PCHAR
Definition: match.c:90
@ PARTITION_STYLE_GPT
Definition: imports.h:202
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define TVE_EXPAND
Definition: commctrl.h:3428
#define IOCTL_STORAGE_QUERY_PROPERTY
Definition: ntddstor.h:178
@ StorageDeviceProperty
Definition: ntddstor.h:512
@ PropertyStandardQuery
Definition: ntddstor.h:505
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define TreeList_Expand(h, i, c)
Definition: treelist.h:365
#define TreeList_SetItemText(hwndLV, hItem_, iSubItem_, pszText_)
Definition: treelist.h:484
unsigned char UCHAR
Definition: typedefs.h:53
char * PCHAR
Definition: typedefs.h:51
struct _STORAGE_DEVICE_DESCRIPTOR * PSTORAGE_DEVICE_DESCRIPTOR

Referenced by DrawPartitionList().

◆ PrintPartitionData()

static HTLITEM PrintPartitionData ( _In_ HWND  hWndList,
_In_ HTLITEM  htiParent,
_In_opt_ HTLITEM  hInsertAfter,
_In_ PPARTENTRY  PartEntry 
)
static

Definition at line 939 of file drivepage.c.

944{
945 PDISKENTRY DiskEntry = PartEntry->DiskEntry;
946 PVOLINFO VolInfo = (PartEntry->Volume ? &PartEntry->Volume->Info : NULL);
947 PPARTITEM PartItem;
948 ULONGLONG PartSize;
949 HTLITEM htiPart;
950 CHAR PartTypeString[32];
951 PCHAR PartType = PartTypeString;
952 WCHAR LineBuffer[128];
953
954 /* Volume name */
955 if (PartEntry->IsPartitioned == FALSE)
956 {
957 /* Unpartitioned space: Just display the description */
958 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
959 // MUIGetString(STRING_UNPSPACE)
960 L"Unpartitioned space");
961 }
962 else
963//
964// NOTE: This could be done with the next case.
965//
966 if ((DiskEntry->DiskStyle == PARTITION_STYLE_MBR) &&
967 IsContainerPartition(PartEntry->PartitionType))
968 {
969 /* Extended partition container: Just display the partition's type */
970 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
971 // MUIGetString(STRING_EXTENDED_PARTITION)
972 L"Extended Partition");
973 }
974 else
975 {
976 /* Drive letter and partition number */
977 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
978 // MUIGetString(STRING_HDDINFOUNK5),
979 L"%s (%c%c)",
980 (VolInfo && *VolInfo->VolumeLabel) ? VolInfo->VolumeLabel : L"Partition",
981 !(VolInfo && VolInfo->DriveLetter) ? L'-' : VolInfo->DriveLetter,
982 !(VolInfo && VolInfo->DriveLetter) ? L'-' : L':');
983 }
984
985 /* Allocate and initialize a partition-info structure */
986 PartItem = LocalAlloc(LPTR, sizeof(*PartItem));
987 if (!PartItem)
988 {
989 DPRINT1("Failed to allocate partition-info structure\n");
990 // return NULL;
991 // We'll store a NULL pointer?!
992 }
993
994 PartItem->PartEntry = PartEntry;
995 PartItem->Volume = PartEntry->Volume;
996
997 htiPart = TreeListAddItem(hWndList, htiParent, hInsertAfter,
998 LineBuffer, 1, 1,
999 (LPARAM)PartItem);
1000
1001 *LineBuffer = 0;
1002 if (PartEntry->IsPartitioned)
1003 {
1004 PartTypeString[0] = '\0';
1005
1006 /*
1007 * If the volume's file system is recognized, display the volume label
1008 * (if any) and the file system name. Otherwise, display the partition
1009 * type if it's not a new partition.
1010 */
1011 if (VolInfo && *VolInfo->FileSystem &&
1012 _wcsicmp(VolInfo->FileSystem, L"RAW") != 0)
1013 {
1014 // TODO: Group this part together with the similar one
1015 // from below once the strings are in the same encoding...
1016 if (PartEntry->New)
1017 {
1018 StringCchPrintfA(PartTypeString,
1019 ARRAYSIZE(PartTypeString),
1020 "New (%S)",
1021 VolInfo->FileSystem);
1022 }
1023 else
1024 {
1025 StringCchPrintfA(PartTypeString,
1026 ARRAYSIZE(PartTypeString),
1027 "%S",
1028 VolInfo->FileSystem);
1029 }
1030 PartType = PartTypeString;
1031 }
1032 else
1033 /* Determine partition type */
1034 if (PartEntry->New)
1035 {
1036 /* Use this description if the partition is new and not planned for formatting */
1037 PartType = "New (Unformatted)"; // MUIGetString(STRING_UNFORMATTED);
1038 }
1039 else
1040 {
1041 /* If the partition is not new but its file system is not recognized
1042 * (or is not formatted), use the partition type description. */
1043 GetPartitionTypeString(PartEntry,
1044 PartTypeString,
1045 ARRAYSIZE(PartTypeString));
1046 PartType = PartTypeString;
1047 }
1048#if 0
1049 if (!PartType || !*PartType)
1050 {
1052 }
1053#endif
1054
1055 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
1056 L"%S",
1057 PartType);
1058 }
1059 TreeList_SetItemText(hWndList, htiPart, 1, LineBuffer);
1060
1061 /* Format the partition size */
1062 PartSize = GetPartEntrySizeInBytes(PartEntry);
1063 if (!StrFormatByteSizeW(PartSize, LineBuffer, ARRAYSIZE(LineBuffer)))
1064 {
1065 /* We failed for whatever reason, do the hardcoded way */
1066 PCWSTR Unit;
1067 PrettifySize2(&PartSize, &Unit);
1068 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
1069 L"%6I64u %s",
1070 PartSize, Unit);
1071 }
1072 TreeList_SetItemText(hWndList, htiPart, 2, LineBuffer);
1073
1074 /* Volume status */
1075 *LineBuffer = 0;
1076 if (PartEntry->IsPartitioned)
1077 {
1078 StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
1079 // MUIGetString(STRING_HDDINFOUNK5),
1080 PartEntry->BootIndicator ? L"Active" : L"");
1081 }
1082 TreeList_SetItemText(hWndList, htiPart, 3, LineBuffer);
1083
1084
1085 /* If this is the single extended partition of an MBR disk,
1086 * recursively display its logical partitions */
1087 if (PartEntry == DiskEntry->ExtendedPartition)
1088 {
1089 PLIST_ENTRY LogicalEntry;
1090
1091 for (LogicalEntry = DiskEntry->LogicalPartListHead.Flink;
1092 LogicalEntry != &DiskEntry->LogicalPartListHead;
1093 LogicalEntry = LogicalEntry->Flink)
1094 {
1095 PPARTENTRY LogicalPartEntry = CONTAINING_RECORD(LogicalEntry, PARTENTRY, ListEntry);
1096 PrintPartitionData(hWndList, htiPart, NULL, LogicalPartEntry);
1097 }
1098
1099 /* Expand the extended partition node */
1101 }
1102
1103 return htiPart;
1104}
PartType
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:164
VOID GetPartitionTypeString(IN PPARTENTRY PartEntry, OUT PSTR strBuffer, IN ULONG cchBuffer)
Definition: drivepage.c:844
static VOID PrettifySize2(_Inout_ PULONGLONG Size, _Out_ PCWSTR *Unit)
Definition: drivepage.c:909
PPARTENTRY ExtendedPartition
Definition: partlist.h:153
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:150
WCHAR FileSystem[MAX_PATH+1]
Definition: volutil.h:22
WCHAR DriveLetter
Definition: volutil.h:20
WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH/sizeof(WCHAR)+1]
Volume label, NUL-terminated.
Definition: volutil.h:21
PCSTR MUIGetString(ULONG Number)
Definition: mui.c:251
#define STRING_FORMATUNKNOWN
Definition: mui.h:183

Referenced by DoCreatePartition(), DoDeletePartition(), PrintDiskData(), and PrintPartitionData().

◆ SelectInstallPartition()

static BOOLEAN SelectInstallPartition ( _In_ PSETUPDATA  pSetupData,
_In_ HWND  hwndDlg 
)
static

Definition at line 1569 of file drivepage.c.

1572{
1573 HWND hList;
1574 HTLITEM hItem;
1575 PPARTITEM PartItem;
1576 PPARTENTRY PartEntry;
1577
1578 hList = GetDlgItem(hwndDlg, IDC_PARTITION);
1579 PartItem = GetSelectedPartition(hList, &hItem);
1580 if (!PartItem)
1581 return FALSE; // Fail
1582 PartEntry = PartItem->PartEntry;
1583 ASSERT(PartEntry);
1584
1585 /*
1586 * Check whether the user wants to install ReactOS on a disk that
1587 * is not recognized by the computer's firmware and if so, display
1588 * a warning since such disks may not be bootable.
1589 */
1590 if (PartEntry->DiskEntry->MediaType == FixedMedia &&
1591 !PartEntry->DiskEntry->BiosFound)
1592 {
1593 INT nRet;
1594
1595 nRet = DisplayMessage(hwndDlg,
1597 L"Warning",
1598 L"The disk you have selected for installing ReactOS\n"
1599 L"is not visible by the firmware of your computer,\n"
1600 L"and so may not be bootable.\n"
1601 L"\nClick on OK to continue anyway."
1602 L"\nClick on CANCEL to go back to the partitions list.");
1603 if (nRet != IDOK)
1604 return FALSE; // Fail
1605 }
1606
1607 /* If this is an empty region, auto-create the partition if conditions are OK */
1608 if (!PartEntry->IsPartitioned)
1609 {
1610 ULONG Error;
1611
1612 Error = PartitionCreateChecks(PartEntry, 0ULL, 0);
1613 if (Error != NOT_AN_ERROR)
1614 {
1615 // MUIDisplayError(Error, Ir, POPUP_WAIT_ANY_KEY);
1617 L"Could not create a partition on the selected disk region.");
1618 return FALSE; // Fail
1619 }
1620
1621 /* Automatically create the partition on the whole empty space;
1622 * it will be formatted later with default parameters */
1623 if (!DoCreatePartition(hList, pSetupData->PartitionList,
1624 &hItem, &PartItem,
1625 0ULL, 0))
1626 {
1627 DisplayError(GetParent(hwndDlg),
1630 return FALSE; // Fail
1631 }
1632 /* Update PartEntry */
1633 PartEntry = PartItem->PartEntry;
1634 }
1635
1636 ASSERT(PartEntry->IsPartitioned);
1637 // ASSERT(PartEntry != PartEntry->DiskEntry->ExtendedPartition);
1639 ASSERT(PartEntry->Volume);
1640
1641#if 0 // TODO: Implement!
1642 if (!IsPartitionLargeEnough(PartEntry))
1643 {
1646 return FALSE; // Fail
1647 }
1648#endif
1649
1650 /* Force formatting only if the partition doesn't have a volume (may or may not be formatted) */
1651 if (PartEntry->Volume &&
1652 ((PartEntry->Volume->FormatState == Formatted) ||
1653 (PartItem->VolCreate && *PartItem->VolCreate->FileSystemName)))
1654 {
1655 /*NOTHING*/;
1656 }
1657 else /* Request formatting of the selected region if it's not already formatted */
1658 {
1659 INT_PTR ret;
1660 PARTCREATE_CTX PartCreateCtx = {0};
1661
1662 /* Show the formatting dialog */
1663 PartCreateCtx.PartItem = PartItem;
1664 ret = DialogBoxParamW(pSetupData->hInstance,
1666 hwndDlg,
1668 (LPARAM)&PartCreateCtx);
1669
1670 /* If the user refuses to format the partition, fail */
1671 if (ret != IDOK)
1672 return FALSE;
1673
1674 /* The partition will be formatted */
1675 }
1676
1677 /* The install partition has been found */
1678 InstallPartition = PartEntry;
1679 return TRUE;
1680}
PPARTENTRY InstallPartition
Definition: reactos.c:28
BOOL Error
Definition: chkdsk.c:66
@ ERROR_INSUFFICIENT_PARTITION_SIZE
Definition: errorcode.h:57
@ Formatted
Definition: partlist.h:37
@ FixedMedia
Definition: ntdddisk.h:383
ULONG RequiredPartitionDiskSpace
Definition: setuplib.h:156
FORMATSTATE FormatState
Definition: partlist.h:48
VOID __cdecl MUIDisplayError(IN ULONG ErrorNum, OUT PINPUT_RECORD Ir, IN ULONG WaitEvent,...)
Definition: mui.c:237
static USETUP_DATA USetupData
Definition: usetup.c:44
#define POPUP_WAIT_ANY_KEY
Definition: usetup.h:123
#define MB_OKCANCEL
Definition: winuser.h:815

Referenced by DriveDlgProc().

◆ ShowErrorTip()

static VOID ShowErrorTip ( _In_ HWND  hEdit)
static

Definition at line 116 of file drivepage.c.

118{
119 EDITBALLOONTIP balloon;
120 WCHAR szTitle[512];
121 WCHAR szText[512];
122
123 /* Load the resources */
126
127 /* Show a warning balloon */
128 balloon.cbStruct = sizeof(balloon);
129 balloon.pszTitle = szTitle;
130 balloon.pszText = szText;
131#if (_WIN32_WINNT < _WIN32_WINNT_VISTA)
132 balloon.ttiIcon = TTI_ERROR;
133#else
134 balloon.ttiIcon = TTI_ERROR_LARGE;
135#endif
136
138 Edit_ShowBalloonTip(hEdit, &balloon);
139
140 // NOTE: There is no need to hide it when other keys are pressed;
141 // the EDIT control will deal with that itself.
142}
#define IDS_ERROR_INVALID_INSTALLDIR_CHAR
Definition: resource.h:168
#define IDS_ERROR_INVALID_INSTALLDIR_CHAR_TITLE
Definition: resource.h:167
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
#define Edit_ShowBalloonTip(hwnd, peditballoontip)
Definition: commctrl.h:4708
#define TTI_ERROR
Definition: commctrl.h:1782
BOOL WINAPI MessageBeep(_In_ UINT uType)

Referenced by InstallDirEditProc().

◆ TreeListAddItem()

HTLITEM TreeListAddItem ( _In_ HWND  hTreeList,
_In_opt_ HTLITEM  hParent,
_In_opt_ HTLITEM  hInsertAfter,
_In_ LPCWSTR  lpText,
_In_ INT  iImage,
_In_ INT  iSelectedImage,
_In_ LPARAM  lParam 
)

Definition at line 733 of file drivepage.c.

741{
742 TLINSERTSTRUCTW Insert;
743
744 ZeroMemory(&Insert, sizeof(Insert));
745
746 Insert.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
747 Insert.hParent = hParent;
748 Insert.hInsertAfter = (hInsertAfter ? hInsertAfter : TVI_LAST);
749 Insert.item.pszText = (LPWSTR)lpText;
750 Insert.item.iImage = iImage;
751 Insert.item.iSelectedImage = iSelectedImage;
752 Insert.item.lParam = lParam;
753
754 // Insert.item.mask |= TVIF_STATE;
755 // Insert.item.stateMask = TVIS_OVERLAYMASK;
756 // Insert.item.state = INDEXTOOVERLAYMASK(1);
757
758 return TreeList_InsertItem(hTreeList, &Insert);
759}
#define ZeroMemory
Definition: minwinbase.h:31
#define TVI_LAST
Definition: commctrl.h:3375
#define TVIF_TEXT
Definition: commctrl.h:3271
#define TVIF_IMAGE
Definition: commctrl.h:3272
#define TVIF_PARAM
Definition: commctrl.h:3273
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3276
#define TreeList_InsertItem(h, p)
Definition: treelist.h:403
#define TLINSERTSTRUCTW
Definition: treelist.h:471

Referenced by PrintDiskData(), and PrintPartitionData().

◆ TreeListGetItemData()

LPARAM TreeListGetItemData ( _In_ HWND  hTreeList,
_In_ HTLITEM  hItem 
)

Definition at line 762 of file drivepage.c.

765{
766 TLITEMW tlItem;
767
768 tlItem.mask = TVIF_PARAM;
769 tlItem.hItem = hItem;
770
771 TreeList_GetItem(hTreeList, &tlItem);
772
773 return tlItem.lParam;
774}
#define TreeList_GetItem(h, p)
Definition: treelist.h:394

Referenced by GetItemPartition().

Variable Documentation

◆ column_alignment

Definition at line 32 of file drivepage.c.

Referenced by InitPartitionList().

◆ column_ids

◆ column_widths

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

Definition at line 31 of file drivepage.c.

Referenced by InitPartitionList().