mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[mingw] fixed MinGW32 compilation
This commit is contained in:
parent
4dfb38430f
commit
3d1131faaf
3 changed files with 29 additions and 7 deletions
2
Makefile
2
Makefile
|
@ -3,7 +3,7 @@ TARGETNAME=rufus
|
||||||
CC = gcc
|
CC = gcc
|
||||||
RC = windres
|
RC = windres
|
||||||
STRIP = strip
|
STRIP = strip
|
||||||
CFLAGS = -std=gnu99 -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration -Wno-pointer-sign -Wshadow -O2 -Wl,--subsystem,windows
|
CFLAGS = -std=gnu99 -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration -Wno-pointer-sign -Wshadow -O2 -Wl,--subsystem,windows -DWINVER=0x501 -D_WIN32_IE=0x501
|
||||||
LIBS = -lsetupapi -lole32
|
LIBS = -lsetupapi -lole32
|
||||||
|
|
||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
|
|
12
rufus.c
12
rufus.c
|
@ -24,11 +24,11 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <setupapi.h>
|
#include <setupapi.h>
|
||||||
#include <winioctl.h>
|
#include <winioctl.h>
|
||||||
// TODO: MinGW32 requires <ddk/ntddscsi.h>
|
|
||||||
#include <ntddscsi.h>
|
|
||||||
// http://doc.sch130.nsc.ru/www.sysinternals.com/ntw2k/source/fmifs.shtml
|
// http://doc.sch130.nsc.ru/www.sysinternals.com/ntw2k/source/fmifs.shtml
|
||||||
// http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/fmifs/
|
// http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/fmifs/
|
||||||
//#include <fmifs.h>
|
//#include <fmifs.h>
|
||||||
|
@ -110,7 +110,7 @@ static BOOL GetDriveHandle(DWORD num, HANDLE* hDrive, char* DriveLetter)
|
||||||
{
|
{
|
||||||
BOOL r;
|
BOOL r;
|
||||||
DWORD size;
|
DWORD size;
|
||||||
STORAGE_DEVICE_NUMBER sdn = {0};
|
STORAGE_DEVICE_NUMBER_REDEF device_number = {0};
|
||||||
static char drives[26*4]; /* "D:\", "E:\", etc. */
|
static char drives[26*4]; /* "D:\", "E:\", etc. */
|
||||||
char *drive = drives;
|
char *drive = drives;
|
||||||
char drive_name[] = "\\\\.\\#:";
|
char drive_name[] = "\\\\.\\#:";
|
||||||
|
@ -138,13 +138,13 @@ static BOOL GetDriveHandle(DWORD num, HANDLE* hDrive, char* DriveLetter)
|
||||||
}
|
}
|
||||||
|
|
||||||
r = DeviceIoControl(*hDrive, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL,
|
r = DeviceIoControl(*hDrive, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL,
|
||||||
0, &sdn, sizeof(sdn), &size, NULL);
|
0, &device_number, sizeof(device_number), &size, NULL);
|
||||||
if ((!r) || (size <= 0)) {
|
if ((!r) || (size <= 0)) {
|
||||||
uprintf("IOCTL_STORAGE_GET_DEVICE_NUMBER failed: %s\n", WindowsErrorString(0));
|
uprintf("IOCTL_STORAGE_GET_DEVICE_NUMBER failed: %s\n", WindowsErrorString(0));
|
||||||
safe_closehandle(*hDrive);
|
safe_closehandle(*hDrive);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (sdn.DeviceNumber == num)
|
if (device_number.DeviceNumber == num)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ static BOOL GetUSBDevices(void)
|
||||||
SP_DEVINFO_DATA dev_info_data;
|
SP_DEVINFO_DATA dev_info_data;
|
||||||
SP_DEVICE_INTERFACE_DATA devint_data;
|
SP_DEVICE_INTERFACE_DATA devint_data;
|
||||||
PSP_DEVICE_INTERFACE_DETAIL_DATA_A devint_detail_data;
|
PSP_DEVICE_INTERFACE_DETAIL_DATA_A devint_detail_data;
|
||||||
STORAGE_DEVICE_NUMBER device_number;
|
STORAGE_DEVICE_NUMBER_REDEF device_number;
|
||||||
DWORD size, i, j, datatype;
|
DWORD size, i, j, datatype;
|
||||||
HANDLE hDrive;
|
HANDLE hDrive;
|
||||||
char drive_letter;
|
char drive_letter;
|
||||||
|
|
22
rufus.h
22
rufus.h
|
@ -52,6 +52,28 @@
|
||||||
const GUID GUID_DEVINTERFACE_DISK = { 0x53f56307L, 0xb6bf, 0x11d0, {0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b} };
|
const GUID GUID_DEVINTERFACE_DISK = { 0x53f56307L, 0xb6bf, 0x11d0, {0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b} };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
DWORD DeviceType;
|
||||||
|
ULONG DeviceNumber;
|
||||||
|
ULONG PartitionNumber;
|
||||||
|
} STORAGE_DEVICE_NUMBER_REDEF;
|
||||||
|
|
||||||
|
typedef struct _SCSI_PASS_THROUGH {
|
||||||
|
USHORT Length;
|
||||||
|
UCHAR ScsiStatus;
|
||||||
|
UCHAR PathId;
|
||||||
|
UCHAR TargetId;
|
||||||
|
UCHAR Lun;
|
||||||
|
UCHAR CdbLength;
|
||||||
|
UCHAR SenseInfoLength;
|
||||||
|
UCHAR DataIn;
|
||||||
|
ULONG DataTransferLength;
|
||||||
|
ULONG TimeOutValue;
|
||||||
|
ULONG_PTR DataBufferOffset;
|
||||||
|
ULONG SenseInfoOffset;
|
||||||
|
UCHAR Cdb[16];
|
||||||
|
} SCSI_PASS_THROUGH,*PSCSI_PASS_THROUGH;
|
||||||
|
|
||||||
typedef struct _SCSI_PASS_THROUGH_WITH_BUFFERS {
|
typedef struct _SCSI_PASS_THROUGH_WITH_BUFFERS {
|
||||||
SCSI_PASS_THROUGH Spt;
|
SCSI_PASS_THROUGH Spt;
|
||||||
ULONG Filler;
|
ULONG Filler;
|
||||||
|
|
Loading…
Reference in a new issue