1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[ui] improve partition scheme default selection

* Also rename our variable to PartitionStyle/ps for clarity
This commit is contained in:
Pete Batard 2018-03-26 18:58:22 +01:00
parent 61f46f7cdc
commit 1dbbe69a4b
7 changed files with 46 additions and 33 deletions

View file

@ -757,7 +757,7 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys
#endif #endif
switch (DriveLayout->PartitionStyle) { switch (DriveLayout->PartitionStyle) {
case PARTITION_STYLE_MBR: case PARTITION_STYLE_MBR:
SelectedDrive.PartitionType = PARTITION_STYLE_MBR; SelectedDrive.PartitionStyle = PARTITION_STYLE_MBR;
for (i=0; i<DriveLayout->PartitionCount; i++) { for (i=0; i<DriveLayout->PartitionCount; i++) {
if (DriveLayout->PartitionEntry[i].Mbr.PartitionType != PARTITION_ENTRY_UNUSED) { if (DriveLayout->PartitionEntry[i].Mbr.PartitionType != PARTITION_ENTRY_UNUSED) {
SelectedDrive.nPartitions++; SelectedDrive.nPartitions++;
@ -804,7 +804,7 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys
} }
break; break;
case PARTITION_STYLE_GPT: case PARTITION_STYLE_GPT:
SelectedDrive.PartitionType = PARTITION_STYLE_GPT; SelectedDrive.PartitionStyle = PARTITION_STYLE_GPT;
suprintf("Partition type: GPT, NB Partitions: %d", DriveLayout->PartitionCount); suprintf("Partition type: GPT, NB Partitions: %d", DriveLayout->PartitionCount);
suprintf("Disk GUID: %s", GuidToString(&DriveLayout->Gpt.DiskId)); suprintf("Disk GUID: %s", GuidToString(&DriveLayout->Gpt.DiskId));
suprintf("Max parts: %d, Start Offset: %" PRIi64 ", Usable = %" PRIi64 " bytes", suprintf("Max parts: %d, Start Offset: %" PRIi64 ", Usable = %" PRIi64 " bytes",
@ -833,7 +833,7 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys
} }
break; break;
default: default:
SelectedDrive.PartitionType = PARTITION_STYLE_MBR; SelectedDrive.PartitionStyle = PARTITION_STYLE_MBR;
suprintf("Partition type: RAW"); suprintf("Partition type: RAW");
break; break;
} }

View file

@ -63,7 +63,7 @@ typedef struct {
DWORD SectorSize; DWORD SectorSize;
DWORD FirstDataSector; DWORD FirstDataSector;
MEDIA_TYPE MediaType; MEDIA_TYPE MediaType;
int PartitionType; int PartitionStyle;
int nPartitions; // number of partitions we actually care about int nPartitions; // number of partitions we actually care about
int FSType; int FSType;
char proposed_label[16]; char proposed_label[16];

View file

@ -1662,7 +1662,7 @@ DWORD WINAPI FormatThread(void* param)
if (large_drive) if (large_drive)
uprintf("Notice: Large drive detected (may produce short writes)"); uprintf("Notice: Large drive detected (may produce short writes)");
// Find out if we need to add any extra partitions // Find out if we need to add any extra partitions
if ((windows_to_go) && (tt == TT_UEFI) && (pt == PARTITION_STYLE_GPT)) if ((windows_to_go) && (tt == TT_UEFI) && (ps == PARTITION_STYLE_GPT))
// According to Microsoft, every GPT disk (we RUN Windows from) must have an MSR due to not having hidden sectors // According to Microsoft, every GPT disk (we RUN Windows from) must have an MSR due to not having hidden sectors
// http://msdn.microsoft.com/en-us/library/windows/hardware/dn640535.aspx#gpt_faq_what_disk_require_msr // http://msdn.microsoft.com/en-us/library/windows/hardware/dn640535.aspx#gpt_faq_what_disk_require_msr
extra_partitions = XP_MSR | XP_EFI; extra_partitions = XP_MSR | XP_EFI;
@ -1848,7 +1848,7 @@ DWORD WINAPI FormatThread(void* param)
UpdateProgress(OP_ZERO_MBR, -1.0f); UpdateProgress(OP_ZERO_MBR, -1.0f);
CHECK_FOR_USER_CANCEL; CHECK_FOR_USER_CANCEL;
if (!CreatePartition(hPhysicalDrive, pt, fs, (pt==PARTITION_STYLE_MBR) && (tt==TT_UEFI), extra_partitions)) { if (!CreatePartition(hPhysicalDrive, ps, fs, (ps==PARTITION_STYLE_MBR) && (tt==TT_UEFI), extra_partitions)) {
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_PARTITION_FAILURE; FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_PARTITION_FAILURE;
goto out; goto out;
} }
@ -1882,7 +1882,7 @@ DWORD WINAPI FormatThread(void* param)
} }
// Thanks to Microsoft, we must fix the MBR AFTER the drive has been formatted // Thanks to Microsoft, we must fix the MBR AFTER the drive has been formatted
if (pt == PARTITION_STYLE_MBR) { if (ps == PARTITION_STYLE_MBR) {
PrintInfoDebug(0, MSG_228); // "Writing master boot record..." PrintInfoDebug(0, MSG_228); // "Writing master boot record..."
if ((!WriteMBR(hPhysicalDrive)) || (!WriteSBR(hPhysicalDrive))) { if ((!WriteMBR(hPhysicalDrive)) || (!WriteSBR(hPhysicalDrive))) {
if (!IS_ERROR(FormatStatus)) if (!IS_ERROR(FormatStatus))

View file

@ -101,7 +101,7 @@ BUTTON_IMAGELIST bi_iso = { 0 }, bi_up = { 0 }, bi_down = { 0 }, bi_save = { 0 }
char szFolderPath[MAX_PATH], app_dir[MAX_PATH], system_dir[MAX_PATH], temp_dir[MAX_PATH], sysnative_dir[MAX_PATH]; char szFolderPath[MAX_PATH], app_dir[MAX_PATH], system_dir[MAX_PATH], temp_dir[MAX_PATH], sysnative_dir[MAX_PATH];
char *image_path = NULL, *short_image_path; char *image_path = NULL, *short_image_path;
float fScale = 1.0f; float fScale = 1.0f;
int default_fs, fs, bt, pt, tt; int default_fs, fs, bt, ps, tt;
int cbw, ddw, ddbh = 0, bh = 0; // (empty) check box width, (empty) drop down width, button height (for and without dropdown match) int cbw, ddw, ddbh = 0, bh = 0; // (empty) check box width, (empty) drop down width, button height (for and without dropdown match)
uint32_t dur_mins, dur_secs; uint32_t dur_mins, dur_secs;
loc_cmd* selected_locale = NULL; loc_cmd* selected_locale = NULL;
@ -310,6 +310,8 @@ static void SetPartitionSchemeAndTargetSystem(BOOL only_target)
} }
if (!only_target) { if (!only_target) {
// Try to reselect the current drive's partition scheme
int preferred_ps = SelectedDrive.PartitionStyle;
if (allowed_partition_scheme[PARTITION_STYLE_MBR]) if (allowed_partition_scheme[PARTITION_STYLE_MBR])
IGNORE_RETVAL(ComboBox_SetItemData(hPartitionScheme, IGNORE_RETVAL(ComboBox_SetItemData(hPartitionScheme,
ComboBox_AddStringU(hPartitionScheme, "MBR"), PARTITION_STYLE_MBR)); ComboBox_AddStringU(hPartitionScheme, "MBR"), PARTITION_STYLE_MBR));
@ -319,20 +321,31 @@ static void SetPartitionSchemeAndTargetSystem(BOOL only_target)
if (allowed_partition_scheme[PARTITION_STYLE_SFD]) if (allowed_partition_scheme[PARTITION_STYLE_SFD])
IGNORE_RETVAL(ComboBox_SetItemData(hPartitionScheme, IGNORE_RETVAL(ComboBox_SetItemData(hPartitionScheme,
ComboBox_AddStringU(hPartitionScheme, sfd_name), PARTITION_STYLE_SFD)); ComboBox_AddStringU(hPartitionScheme, sfd_name), PARTITION_STYLE_SFD));
SetComboEntry(hPartitionScheme, PARTITION_STYLE_GPT); // Override the partition scheme according to the current
pt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); if (bt == BT_NON_BOOTABLE)
preferred_ps = PARTITION_STYLE_MBR;
else if (bt == BT_UEFI_NTFS)
preferred_ps = PARTITION_STYLE_GPT;
else if ((bt == BT_IMAGE) && (image_path != NULL) && (img_report.is_iso)) {
if (HAS_WINDOWS(img_report) && img_report.has_efi)
preferred_ps = allow_dual_uefi_bios? PARTITION_STYLE_MBR : PARTITION_STYLE_GPT;
if (img_report.is_bootable_img)
preferred_ps = PARTITION_STYLE_MBR;
}
SetComboEntry(hPartitionScheme, preferred_ps);
ps = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme));
} }
has_uefi_csm = FALSE; has_uefi_csm = FALSE;
if (allowed_target_system[0] && (pt != PARTITION_STYLE_GPT)) { if (allowed_target_system[0] && (ps != PARTITION_STYLE_GPT)) {
IGNORE_RETVAL(ComboBox_SetItemData(hTargetSystem, IGNORE_RETVAL(ComboBox_SetItemData(hTargetSystem,
ComboBox_AddStringU(hTargetSystem, lmprintf(MSG_031)), TT_BIOS)); ComboBox_AddStringU(hTargetSystem, lmprintf(MSG_031)), TT_BIOS));
has_uefi_csm = TRUE; has_uefi_csm = TRUE;
} }
if (allowed_target_system[1] && !((pt == PARTITION_STYLE_MBR) && IS_BIOS_BOOTABLE(img_report) && IS_EFI_BOOTABLE(img_report)) ) if (allowed_target_system[1] && !((ps == PARTITION_STYLE_MBR) && IS_BIOS_BOOTABLE(img_report) && IS_EFI_BOOTABLE(img_report)) )
IGNORE_RETVAL(ComboBox_SetItemData(hTargetSystem, IGNORE_RETVAL(ComboBox_SetItemData(hTargetSystem,
ComboBox_AddStringU(hTargetSystem, lmprintf(MSG_032)), TT_UEFI)); ComboBox_AddStringU(hTargetSystem, lmprintf(MSG_032)), TT_UEFI));
if (allowed_target_system[2] && ((pt != PARTITION_STYLE_GPT) || (bt == BT_NON_BOOTABLE))) if (allowed_target_system[2] && ((ps != PARTITION_STYLE_GPT) || (bt == BT_NON_BOOTABLE)))
IGNORE_RETVAL(ComboBox_SetItemData(hTargetSystem, IGNORE_RETVAL(ComboBox_SetItemData(hTargetSystem,
ComboBox_AddStringU(hTargetSystem, lmprintf(MSG_033)), TT_BIOS)); ComboBox_AddStringU(hTargetSystem, lmprintf(MSG_033)), TT_BIOS));
IGNORE_RETVAL(ComboBox_SetCurSel(hTargetSystem, 0)); IGNORE_RETVAL(ComboBox_SetCurSel(hTargetSystem, 0));
@ -633,7 +646,7 @@ static void EnableMBRBootOptions(BOOL enable, BOOL remove_checkboxes)
BOOL actual_enable_fix = enable; BOOL actual_enable_fix = enable;
static UINT uXPartChecked = BST_UNCHECKED; static UINT uXPartChecked = BST_UNCHECKED;
if ((pt != PARTITION_STYLE_MBR) || (tt != TT_BIOS) || ((bt == BT_IMAGE) && !IS_BIOS_BOOTABLE(img_report))) { if ((ps != PARTITION_STYLE_MBR) || (tt != TT_BIOS) || ((bt == BT_IMAGE) && !IS_BIOS_BOOTABLE(img_report))) {
// These options cannot apply if we aren't using MBR+BIOS, or are using an image that isn't BIOS bootable // These options cannot apply if we aren't using MBR+BIOS, or are using an image that isn't BIOS bootable
actual_enable_mbr = FALSE; actual_enable_mbr = FALSE;
actual_enable_fix = FALSE; actual_enable_fix = FALSE;
@ -1430,7 +1443,7 @@ static BOOL BootCheck(void)
return FALSE; return FALSE;
} }
if (SelectedDrive.MediaType != FixedMedia) { if (SelectedDrive.MediaType != FixedMedia) {
if ((tt == TT_UEFI) && (pt == PARTITION_STYLE_GPT) && (nWindowsBuildNumber < 15000)) { if ((tt == TT_UEFI) && (ps == PARTITION_STYLE_GPT) && (nWindowsBuildNumber < 15000)) {
// Up to Windows 10 Creators Update, we were screwed, since we need access to 2 partitions at the same time. // Up to Windows 10 Creators Update, we were screwed, since we need access to 2 partitions at the same time.
// Thankfully, the newer Windows allow mounting multiple partitions on the same REMOVABLE drive. // Thankfully, the newer Windows allow mounting multiple partitions on the same REMOVABLE drive.
MessageBoxExU(hMainDialog, lmprintf(MSG_198), lmprintf(MSG_190), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); MessageBoxExU(hMainDialog, lmprintf(MSG_198), lmprintf(MSG_190), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid);
@ -1737,13 +1750,13 @@ static INT_PTR CALLBACK ProgressCallback(HWND hCtrl, UINT message, WPARAM wParam
{ {
HDC hDC; HDC hDC;
RECT rect; RECT rect;
PAINTSTRUCT ps; PAINTSTRUCT paint_struct;
wchar_t winfo[128] = L"Copying ISO files..."; wchar_t winfo[128] = L"Copying ISO files...";
switch (message) { switch (message) {
case WM_PAINT: case WM_PAINT:
hDC = BeginPaint(hCtrl, &ps); hDC = BeginPaint(hCtrl, &paint_struct);
CallWindowProc(progress_original_proc, hCtrl, message, (WPARAM)hDC, lParam); CallWindowProc(progress_original_proc, hCtrl, message, (WPARAM)hDC, lParam);
GetWindowTextW(hProgress, winfo, ARRAYSIZE(winfo)); GetWindowTextW(hProgress, winfo, ARRAYSIZE(winfo));
SetBkMode(hDC, TRANSPARENT); SetBkMode(hDC, TRANSPARENT);
@ -1754,7 +1767,7 @@ static INT_PTR CALLBACK ProgressCallback(HWND hCtrl, UINT message, WPARAM wParam
ExtTextOutW(hDC, rect.right / 2, rect.bottom / 2 + (int)(4.0f * fScale), ExtTextOutW(hDC, rect.right / 2, rect.bottom / 2 + (int)(4.0f * fScale),
ETO_CLIPPED | ETO_NUMERICSLOCAL | (right_to_left_mode ? ETO_RTLREADING : 0), ETO_CLIPPED | ETO_NUMERICSLOCAL | (right_to_left_mode ? ETO_RTLREADING : 0),
&rect, winfo, (int)wcslen(winfo), NULL); &rect, winfo, (int)wcslen(winfo), NULL);
EndPaint(hCtrl, &ps); EndPaint(hCtrl, &paint_struct);
return (INT_PTR)TRUE; return (INT_PTR)TRUE;
} }
@ -2785,7 +2798,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
RECT rc, DialogRect, DesktopRect; RECT rc, DialogRect, DesktopRect;
LONG progress_style; LONG progress_style;
HDC hDC; HDC hDC;
PAINTSTRUCT ps; PAINTSTRUCT paint_struct;
int nDeviceIndex, i, nWidth, nHeight, nb_devices, selected_language, offset; int nDeviceIndex, i, nWidth, nHeight, nb_devices, selected_language, offset;
char tmp[128]; char tmp[128];
wchar_t* wbuffer = NULL; wchar_t* wbuffer = NULL;
@ -2954,7 +2967,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
case IDC_PARTITION_TYPE: case IDC_PARTITION_TYPE:
if (HIWORD(wParam) != CBN_SELCHANGE) if (HIWORD(wParam) != CBN_SELCHANGE)
break; break;
pt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); ps = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme));
SetPartitionSchemeAndTargetSystem(TRUE); SetPartitionSchemeAndTargetSystem(TRUE);
SetFileSystemAndClusterSize(NULL); SetFileSystemAndClusterSize(NULL);
EnableMBRBootOptions(TRUE, FALSE); EnableMBRBootOptions(TRUE, FALSE);
@ -3002,7 +3015,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
SetProposedLabel(ComboBox_GetCurSel(hDeviceList)); SetProposedLabel(ComboBox_GetCurSel(hDeviceList));
EnableControls(TRUE); EnableControls(TRUE);
tt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); tt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme));
pt = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem)); ps = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem));
return (INT_PTR)TRUE; return (INT_PTR)TRUE;
case IDC_SELECT: case IDC_SELECT:
if (iso_provided) { if (iso_provided) {
@ -3051,7 +3064,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
// Just in case // Just in case
bt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); bt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType));
tt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); tt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme));
pt = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem)); ps = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem));
fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
write_as_image = FALSE; write_as_image = FALSE;
// Disable all controls except Cancel // Disable all controls except Cancel
@ -3310,9 +3323,9 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
break; break;
case WM_PAINT: case WM_PAINT:
hDC = BeginPaint(hDlg, &ps); hDC = BeginPaint(hDlg, &paint_struct);
OnPaint(hDC); OnPaint(hDC);
EndPaint(hDlg, &ps); EndPaint(hDlg, &paint_struct);
break; break;
case WM_CTLCOLORSTATIC: case WM_CTLCOLORSTATIC:

View file

@ -399,7 +399,7 @@ extern int64_t iso_blocking_status;
extern uint16_t rufus_version[3], embedded_sl_version[2]; extern uint16_t rufus_version[3], embedded_sl_version[2];
extern int nWindowsVersion; extern int nWindowsVersion;
extern int nWindowsBuildNumber; extern int nWindowsBuildNumber;
extern int fs, bt, pt, tt; extern int fs, bt, ps, tt;
extern char WindowsVersionStr[128]; extern char WindowsVersionStr[128];
extern size_t ubuffer_pos; extern size_t ubuffer_pos;
extern char ubuffer[UBUFFER_SIZE]; extern char ubuffer[UBUFFER_SIZE];

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326 IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 3.0.1223" CAPTION "Rufus 3.0.1224"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0 FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -371,8 +371,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,18,1223,0 FILEVERSION 2,18,1224,0
PRODUCTVERSION 2,18,1223,0 PRODUCTVERSION 2,18,1224,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -389,13 +389,13 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "2.18.1223" VALUE "FileVersion", "2.18.1224"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe" VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "2.18.1223" VALUE "ProductVersion", "2.18.1224"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View file

@ -457,7 +457,7 @@ static PSID GetSID(void) {
*/ */
BOOL FileIO(BOOL save, char* path, char** buffer, DWORD* size) BOOL FileIO(BOOL save, char* path, char** buffer, DWORD* size)
{ {
SECURITY_ATTRIBUTES s_attr, *ps = NULL; SECURITY_ATTRIBUTES s_attr, *sa = NULL;
SECURITY_DESCRIPTOR s_desc; SECURITY_DESCRIPTOR s_desc;
PSID sid = NULL; PSID sid = NULL;
HANDLE handle; HANDLE handle;
@ -472,7 +472,7 @@ BOOL FileIO(BOOL save, char* path, char** buffer, DWORD* size)
s_attr.nLength = sizeof(SECURITY_ATTRIBUTES); s_attr.nLength = sizeof(SECURITY_ATTRIBUTES);
s_attr.bInheritHandle = FALSE; s_attr.bInheritHandle = FALSE;
s_attr.lpSecurityDescriptor = &s_desc; s_attr.lpSecurityDescriptor = &s_desc;
ps = &s_attr; sa = &s_attr;
} else { } else {
uprintf("Could not set security descriptor: %s\n", WindowsErrorString()); uprintf("Could not set security descriptor: %s\n", WindowsErrorString());
} }
@ -481,7 +481,7 @@ BOOL FileIO(BOOL save, char* path, char** buffer, DWORD* size)
*buffer = NULL; *buffer = NULL;
} }
handle = CreateFileU(path, save?GENERIC_WRITE:GENERIC_READ, FILE_SHARE_READ, handle = CreateFileU(path, save?GENERIC_WRITE:GENERIC_READ, FILE_SHARE_READ,
ps, save?CREATE_ALWAYS:OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); sa, save?CREATE_ALWAYS:OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (handle == INVALID_HANDLE_VALUE) { if (handle == INVALID_HANDLE_VALUE) {
uprintf("Could not %s file '%s'\n", save?"create":"open", path); uprintf("Could not %s file '%s'\n", save?"create":"open", path);