From acf7d072b051eda2cf111f49c40354b03b80b477 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Thu, 12 Jan 2012 02:52:40 +0000 Subject: [PATCH] [sl] syslinux support (EXPERIMENTAL) * MS platforms only (*BREAKS* MinGW) --- configure | 18 +- configure.ac | 13 +- ms-config.h | 3 + res/syslinux/ldlinux.bss | Bin 0 -> 512 bytes res/syslinux/ldlinux.sys | Bin 0 -> 31205 bytes rufus_2010.sln | 20 ++ src/.msvc/rufus_2010.vcxproj | 15 +- src/.msvc/rufus_2010.vcxproj.filters | 3 + src/.msvc/rufus_sources | 7 +- src/dos.c | 11 +- src/dos.h | 2 +- src/format.c | 58 ++-- src/ms-sys/.msvc/ms-sys_sources | 8 +- src/resource.h | 2 + src/rufus.c | 28 +- src/rufus.h | 8 +- src/rufus.rc | 28 +- src/syslinux.c | 212 ++++++++++++ src/syslinux/inttypes.h | 301 ++++++++++++++++++ src/syslinux/libfat/.msvc/libfat.vcxproj | 172 ++++++++++ .../libfat/.msvc/libfat.vcxproj.filters | 41 +++ src/syslinux/libfat/.msvc/libfat_sources | 18 ++ src/syslinux/libfat/cache.c | 65 ++++ src/syslinux/libfat/fat.h | 108 +++++++ src/syslinux/libfat/fatchain.c | 134 ++++++++ src/syslinux/libfat/libfat.h | 85 +++++ src/syslinux/libfat/libfatint.h | 55 ++++ src/syslinux/libfat/open.c | 117 +++++++ src/syslinux/libfat/searchdir.c | 64 ++++ src/syslinux/libfat/ulint.h | 112 +++++++ .../libinstaller/.msvc/libinstaller.vcxproj | 170 ++++++++++ .../.msvc/libinstaller.vcxproj.filters | 35 ++ .../libinstaller/.msvc/libinstaller_sources | 17 + src/syslinux/libinstaller/advconst.h | 45 +++ src/syslinux/libinstaller/fat.c | 126 ++++++++ src/syslinux/libinstaller/setadv.c | 166 ++++++++++ src/syslinux/libinstaller/setadv.h | 16 + src/syslinux/libinstaller/syslinux.h | 55 ++++ src/syslinux/libinstaller/syslxint.h | 261 +++++++++++++++ src/syslinux/libinstaller/syslxmod.c | 201 ++++++++++++ src/syslinux/sltypes.h | 26 ++ src/syslinux/stdint.h | 262 +++++++++++++++ wdk_build.cmd | 32 +- 43 files changed, 3063 insertions(+), 57 deletions(-) create mode 100644 res/syslinux/ldlinux.bss create mode 100644 res/syslinux/ldlinux.sys create mode 100644 src/syslinux.c create mode 100644 src/syslinux/inttypes.h create mode 100644 src/syslinux/libfat/.msvc/libfat.vcxproj create mode 100644 src/syslinux/libfat/.msvc/libfat.vcxproj.filters create mode 100644 src/syslinux/libfat/.msvc/libfat_sources create mode 100644 src/syslinux/libfat/cache.c create mode 100644 src/syslinux/libfat/fat.h create mode 100644 src/syslinux/libfat/fatchain.c create mode 100644 src/syslinux/libfat/libfat.h create mode 100644 src/syslinux/libfat/libfatint.h create mode 100644 src/syslinux/libfat/open.c create mode 100644 src/syslinux/libfat/searchdir.c create mode 100644 src/syslinux/libfat/ulint.h create mode 100644 src/syslinux/libinstaller/.msvc/libinstaller.vcxproj create mode 100644 src/syslinux/libinstaller/.msvc/libinstaller.vcxproj.filters create mode 100644 src/syslinux/libinstaller/.msvc/libinstaller_sources create mode 100644 src/syslinux/libinstaller/advconst.h create mode 100644 src/syslinux/libinstaller/fat.c create mode 100644 src/syslinux/libinstaller/setadv.c create mode 100644 src/syslinux/libinstaller/setadv.h create mode 100644 src/syslinux/libinstaller/syslinux.h create mode 100644 src/syslinux/libinstaller/syslxint.h create mode 100644 src/syslinux/libinstaller/syslxmod.c create mode 100644 src/syslinux/sltypes.h create mode 100644 src/syslinux/stdint.h diff --git a/configure b/configure index a71f2149..e0deb9e4 100644 --- a/configure +++ b/configure @@ -652,6 +652,7 @@ ac_user_opts=' enable_option_checking enable_silent_rules with_freedos +with_syslinux enable_debug ' ac_precious_vars='build_alias @@ -1286,6 +1287,7 @@ Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-freedos embed FreeDOS support (default=yes) + --with-syslinux embed SysLinux support (default=yes) Some influential environment variables: CC C compiler command @@ -3475,10 +3477,24 @@ else fi if test "x$with_freedos" != "xno" ; then - AM_RCFLAGS="-DWITH_FREEDOS" + AM_RCFLAGS="${AM_RCFLAGS} -DWITH_FREEDOS" EXESUFFIX="f" fi + +# Check whether --with-syslinux was given. +if test "${with_syslinux+set}" = set; then : + withval=$with_syslinux; +else + with_freedos=yes +fi + +if test "x$with_syslinux" != "xno" ; then + AM_RCFLAGS="${AM_RCFLAGS} -DWITH_SYSLINUX" + EXESUFFIX="f" +fi + + # Debug symbols # Check whether --enable-debug was given. if test "${enable_debug+set}" = set; then : diff --git a/configure.ac b/configure.ac index 810b51c2..a432b82d 100644 --- a/configure.ac +++ b/configure.ac @@ -43,10 +43,21 @@ AC_ARG_WITH([freedos], [], [with_freedos=yes]) if test "x$with_freedos" != "xno" ; then - AM_RCFLAGS="-DWITH_FREEDOS" + AM_RCFLAGS="${AM_RCFLAGS} -DWITH_FREEDOS" EXESUFFIX="f" fi +AC_ARG_WITH([syslinux], + [AS_HELP_STRING([--with-syslinux], + [embed SysLinux support (default=yes)])], + [], + [with_freedos=yes]) +if test "x$with_syslinux" != "xno" ; then + AM_RCFLAGS="${AM_RCFLAGS} -DWITH_SYSLINUX" + EXESUFFIX="f" +fi + + # Debug symbols AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug], [keep debug symbols for gdb (default=yes)]), [debug_enabled=$enableval], diff --git a/ms-config.h b/ms-config.h index e0006a10..d10be7a8 100644 --- a/ms-config.h +++ b/ms-config.h @@ -3,3 +3,6 @@ /* Embed FreeDOS files and allow FreeDOS support */ #define WITH_FREEDOS + +/* SysLinux support, for ISO -> bootable USB */ +//#define WITH_SYSLINUX diff --git a/res/syslinux/ldlinux.bss b/res/syslinux/ldlinux.bss new file mode 100644 index 0000000000000000000000000000000000000000..884c5a8e5cebb8ea1558f89479e7684b05194637 GIT binary patch literal 512 zcmaDIF(EiI*vHc^G=hP;;MX6+lYJNWlvM|@h0BHY9o(q4zoPo{(!QI!D;W5@eJJaWsrCodyH66Y`0)XJG@av@R&{f@~D-OP6Vf@tm%fHO9@z*By zV(o9PTk1zuL|Ab_~JA}kwD|`&{d^e-wraCupVP`t7S;r z@qXXhduhAQ{d)UvH$%eu0g`r7HEG|! z8J=uEmG=F6n(cpP28MF+15el-IUaT#?YOpsk?Dm#P$STgM<)%x^+a*>~&30Cp{jgJheu+YAQBi&oFBfLa N{$tu?Ct)7C3IJIpyg>i} literal 0 HcmV?d00001 diff --git a/res/syslinux/ldlinux.sys b/res/syslinux/ldlinux.sys new file mode 100644 index 0000000000000000000000000000000000000000..cee0f82ffadde50dacf85f68532a10d6fe309470 GIT binary patch literal 31205 zcmeFZc|cRg_BcNG<|erb2?>jcN+rRF;)2Ag1ql>n5fm`&AhK1sqN37}0Im%Uwp^~E zeN|h#y^7dApW0X2QWh5$qoB67h+S;$YpGg$-RLoGo!7n%_o z?LcO>7K2~L)n!|^9jA`rj}p77_bKeu)e(yJnrWsKtv__!s5XbkZbv4v<7Rb_=npfZ z7oi|_1(r%#7yVkzxT?(Y*Je=+K{06rG${Ke%%@OrB?G<)8qH+`;1iEaaFwW8= z<-W{=IwI(g#VN*BW2OSSsRrmtKv;SR6S?cV>QhKr{~Z-?x>f%zrS4MH{DtiJrkec` z*}ET71(ZNku$A)gD%#2=r?Z_1kUeTwA}WQ_i&8V!Dd`(jLGzNSUcT({hrU#ywMc33 z&ZV$n%F>Sl9w|NuciD!Gs&AWYRH2P3&~~wV9#Vx@yLh^ib9pT3sep2k_cr(qpS+E_ zKcqeP;(6-+eJac$KuGbT?jakG0zMDJa?m=zW zVeL6~v#&wG3RU(#Y)Eu4ILG8}3BR0z6g5`N5`H}eQ@mIMiSOXa&aGI-y^q;Sb&u%X zU<4SN-7a_;Ma{|!UfeyZ;jI(jFCE(;fYF7 zwF7kEw!#dODbKsQ5Obe;9}JxNm_B({P@s1S!RxXt;yC#JCcd?jH27mDAy0r--4` z%nqWz9btD5=4-F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ln index c7d864ed..127f43f9 100644 --- a/rufus_2010.sln +++ b/rufus_2010.sln @@ -8,6 +8,10 @@ Project("{11411DA5-63FE-49DC-8D5C-CA379B95FF3C}") = "rufus", "src\.msvc\rufus_20 EndProject Project("{11411DA5-63FE-49DC-8D5C-CA379B95FF3C}") = "ms-sys", "src\ms-sys\.msvc\ms-sys.vcxproj", "{2B1D078D-8EB4-4398-9CA4-23457265A7F6}" EndProject +Project("{11411DA5-63FE-49DC-8D5C-CA379B95FF3C}") = "syslinux-libfat", "src\syslinux\libfat\.msvc\libfat.vcxproj", "{8390DCE0-859D-4F57-AD9C-AAEAC4D77EEF}" +EndProject +Project("{11411DA5-63FE-49DC-8D5C-CA379B95FF3C}") = "syslinux-libinstaller", "src\syslinux\libinstaller\.msvc\libinstaller.vcxproj", "{266502AC-CD74-4581-B707-938A7D05AD7A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -32,6 +36,22 @@ Global {2B1D078D-8EB4-4398-9CA4-23457265A7F6}.Release|Win32.Build.0 = Release|Win32 {2B1D078D-8EB4-4398-9CA4-23457265A7F6}.Release|x64.ActiveCfg = Release|x64 {2B1D078D-8EB4-4398-9CA4-23457265A7F6}.Release|x64.Build.0 = Release|x64 + {8390DCE0-859D-4F57-AD9C-AAEAC4D77EEF}.Debug|Win32.ActiveCfg = Debug|Win32 + {8390DCE0-859D-4F57-AD9C-AAEAC4D77EEF}.Debug|Win32.Build.0 = Debug|Win32 + {8390DCE0-859D-4F57-AD9C-AAEAC4D77EEF}.Debug|x64.ActiveCfg = Debug|x64 + {8390DCE0-859D-4F57-AD9C-AAEAC4D77EEF}.Debug|x64.Build.0 = Debug|x64 + {8390DCE0-859D-4F57-AD9C-AAEAC4D77EEF}.Release|Win32.ActiveCfg = Release|Win32 + {8390DCE0-859D-4F57-AD9C-AAEAC4D77EEF}.Release|Win32.Build.0 = Release|Win32 + {8390DCE0-859D-4F57-AD9C-AAEAC4D77EEF}.Release|x64.ActiveCfg = Release|x64 + {8390DCE0-859D-4F57-AD9C-AAEAC4D77EEF}.Release|x64.Build.0 = Release|x64 + {266502AC-CD74-4581-B707-938A7D05AD7A}.Debug|Win32.ActiveCfg = Debug|Win32 + {266502AC-CD74-4581-B707-938A7D05AD7A}.Debug|Win32.Build.0 = Debug|Win32 + {266502AC-CD74-4581-B707-938A7D05AD7A}.Debug|x64.ActiveCfg = Debug|x64 + {266502AC-CD74-4581-B707-938A7D05AD7A}.Debug|x64.Build.0 = Debug|x64 + {266502AC-CD74-4581-B707-938A7D05AD7A}.Release|Win32.ActiveCfg = Release|Win32 + {266502AC-CD74-4581-B707-938A7D05AD7A}.Release|Win32.Build.0 = Release|Win32 + {266502AC-CD74-4581-B707-938A7D05AD7A}.Release|x64.ActiveCfg = Release|x64 + {266502AC-CD74-4581-B707-938A7D05AD7A}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/.msvc/rufus_2010.vcxproj b/src/.msvc/rufus_2010.vcxproj index 52511ae7..91c14209 100644 --- a/src/.msvc/rufus_2010.vcxproj +++ b/src/.msvc/rufus_2010.vcxproj @@ -80,7 +80,7 @@ _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;%(PreprocessorDefinitions) MultiThreadedDebug Level3 - ..\ms-sys\inc;%(AdditionalIncludeDirectories) + ..\ms-sys\inc;..\syslinux;..\syslinux\libinstaller;..\syslinux\libfat;%(AdditionalIncludeDirectories) setupapi.lib;comctl32.lib;%(AdditionalDependencies) @@ -99,7 +99,7 @@ X64 - ..\ms-sys\inc;%(AdditionalIncludeDirectories) + ..\ms-sys\inc;..\syslinux;..\syslinux\libinstaller;..\syslinux\libfat;%(AdditionalIncludeDirectories) _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;%(PreprocessorDefinitions) MultiThreadedDebug Level3 @@ -122,7 +122,7 @@ _CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;%(PreprocessorDefinitions) MultiThreaded Level3 - ..\ms-sys\inc;%(AdditionalIncludeDirectories) + ..\ms-sys\inc;..\syslinux;..\syslinux\libinstaller;..\syslinux\libfat;%(AdditionalIncludeDirectories) setupapi.lib;comctl32.lib;%(AdditionalDependencies) @@ -144,7 +144,7 @@ _CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;%(PreprocessorDefinitions) MultiThreaded Level3 - ..\ms-sys\inc;%(AdditionalIncludeDirectories) + ..\ms-sys\inc;..\syslinux;..\syslinux\libinstaller;..\syslinux\libfat;%(AdditionalIncludeDirectories) setupapi.lib;comctl32.lib;%(AdditionalDependencies) @@ -166,6 +166,7 @@ + @@ -191,6 +192,12 @@ {2b1d078d-8eb4-4398-9ca4-23457265a7f6} + + {8390dce0-859d-4f57-ad9c-aaeac4d77eef} + + + {266502ac-cd74-4581-b707-938a7d05ad7a} + diff --git a/src/.msvc/rufus_2010.vcxproj.filters b/src/.msvc/rufus_2010.vcxproj.filters index 1a36bfe0..181eab37 100644 --- a/src/.msvc/rufus_2010.vcxproj.filters +++ b/src/.msvc/rufus_2010.vcxproj.filters @@ -39,6 +39,9 @@ Source Files + + Source Files + diff --git a/src/.msvc/rufus_sources b/src/.msvc/rufus_sources index 85a9fb40..a94ae3fa 100644 --- a/src/.msvc/rufus_sources +++ b/src/.msvc/rufus_sources @@ -3,7 +3,7 @@ TARGETTYPE=PROGRAM UMTYPE=windows UMENTRY=winmain -INCLUDES=$(DDK_INC_PATH);.\ms-sys\inc +INCLUDES=$(DDK_INC_PATH);.\ms-sys\inc;.\syslinux;.\syslinux\libfat;.\syslinux\libinstaller C_DEFINES = $(C_DEFINES) /DDDKBUILD /DUNICODE /D_UNICODE /DISOLATION_AWARE_ENABLED !IFNDEF MSC_WARNING_LEVEL @@ -18,7 +18,9 @@ TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \ $(SDK_LIB_PATH)\version.lib \ $(SDK_LIB_PATH)\uuid.lib \ $(SDK_LIB_PATH)\shell32.lib \ - .\ms-sys\ms-sys.lib + .\ms-sys\ms-sys.lib \ + .\syslinux\libfat\libfat.lib \ + .\syslinux\libinstaller\libinstaller.lib # http://jpassing.com/2008/02/01/how-to-use-manifests-with-buildexe/ SXS_APPLICATION_MANIFEST=..\common_controls_and_elevation.manifest @@ -31,4 +33,5 @@ SOURCES=rufus.c \ dos_locale.c \ badblocks.c \ drive.c \ + syslinux.c \ rufus.rc diff --git a/src/dos.c b/src/dos.c index 653ee47a..8ed04c76 100644 --- a/src/dos.c +++ b/src/dos.c @@ -25,6 +25,7 @@ #endif #include +#include #include #include @@ -428,9 +429,13 @@ BOOL ExtractFreeDOS(const char* path) return SetDOSLocale(path, TRUE); } -BOOL ExtractDOS(const char* path, int dos_type) +BOOL ExtractDOS(const char* path) { - if (dos_type == DT_WINME) + switch(ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType))) { + case DT_WINME: return ExtractMSDOS(path); - return ExtractFreeDOS(path); + case DT_FREEDOS: + return ExtractFreeDOS(path); + } + return FALSE; } diff --git a/src/dos.h b/src/dos.h index b47180ba..d439dd08 100644 --- a/src/dos.h +++ b/src/dos.h @@ -105,7 +105,7 @@ typedef struct _LONG_FILE_NAME_ENTRY { } LONG_FILE_NAME_ENTRY, *PLONG_FILE_NAME_ENTRY; // sizeof = 0x020 -#pragma pack() +#pragma pack(pop) #define FAT_LFN_NAME_LENGTH \ (RTL_FIELD_SIZE(LONG_FILE_NAME_ENTRY, NameA) \ diff --git a/src/format.c b/src/format.c index 1e6eea1d..a53b03f4 100644 --- a/src/format.c +++ b/src/format.c @@ -308,7 +308,11 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive) fake_fd._ptr = (char*)hPhysicalDrive; fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector; - r = write_95b_mbr(&fake_fd); + if (ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType)) == DT_SYSLINUX) { + r = write_syslinux_mbr(&fake_fd); + } else { + r = write_95b_mbr(&fake_fd); + } out: safe_free(buf); @@ -494,26 +498,38 @@ void __cdecl FormatThread(void* param) UpdateProgress(OP_FIX_MBR, -1.0f); if (IsChecked(IDC_DOS)) { - // We still have a lock, which we need to modify the volume boot record - // => no need to reacquire the lock... - hLogicalVolume = GetDriveHandle(num, drive_name, TRUE, FALSE); - if (hLogicalVolume == INVALID_HANDLE_VALUE) { - uprintf("Could not re-mount volume for partition boot record access\n"); - FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OPEN_FAILED; - goto out; - } - PrintStatus(0, "Writing partition boot record...\n"); - if (!WritePBR(hLogicalVolume, ComboBox_GetCurSel(hDOSType) == DT_FREEDOS)) { - // Errorcode has already been set - goto out; - } - // ...but we must have relinquished that lock to write the MS-DOS files - safe_unlockclose(hLogicalVolume); - UpdateProgress(OP_DOS, -1.0f); - PrintStatus(0, "Copying DOS files...\n"); - if (!ExtractDOS(drive_name, ComboBox_GetCurSel(hDOSType))) { - FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANNOT_COPY; - goto out; + switch (ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType))) { + case DT_FREEDOS: + case DT_WINME: + // We still have a lock, which we need to modify the volume boot record + // => no need to reacquire the lock... + hLogicalVolume = GetDriveHandle(num, drive_name, TRUE, FALSE); + if (hLogicalVolume == INVALID_HANDLE_VALUE) { + uprintf("Could not re-mount volume for partition boot record access\n"); + FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OPEN_FAILED; + goto out; + } + PrintStatus(0, "Writing partition boot record...\n"); + if (!WritePBR(hLogicalVolume, ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType)) == DT_FREEDOS)) { + // Errorcode has already been set + goto out; + } + // ...but we must have relinquished that lock to write the MS-DOS files + safe_unlockclose(hLogicalVolume); + UpdateProgress(OP_DOS, -1.0f); + PrintStatus(0, "Copying DOS files...\n"); + if (!ExtractDOS(drive_name)) { + FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANNOT_COPY; + goto out; + } + break; + // SysLinux requires patching of the PBR after the files have been extracted + case DT_SYSLINUX: + if (!InstallSysLinux(num, drive_name)) { + FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANNOT_COPY; + goto out; + } + break; } } diff --git a/src/ms-sys/.msvc/ms-sys_sources b/src/ms-sys/.msvc/ms-sys_sources index 6da50d64..6f140e4d 100644 --- a/src/ms-sys/.msvc/ms-sys_sources +++ b/src/ms-sys/.msvc/ms-sys_sources @@ -10,13 +10,7 @@ MSC_WARNING_LEVEL=/W3 USE_MSVCRT=1 TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \ - $(SDK_LIB_PATH)\user32.lib \ - $(SDK_LIB_PATH)\setupapi.lib \ - $(SDK_LIB_PATH)\ole32.lib \ - $(SDK_LIB_PATH)\version.lib \ - $(SDK_LIB_PATH)\uuid.lib \ - $(SDK_LIB_PATH)\shell32.lib \ - ms-sys.lib + $(SDK_LIB_PATH)\user32.lib SOURCES=file.c \ br.c \ diff --git a/src/resource.h b/src/resource.h index 7bf5aa43..37614ea5 100644 --- a/src/resource.h +++ b/src/resource.h @@ -35,6 +35,8 @@ #define IDR_FD_EGA16_CPX 324 #define IDR_FD_EGA17_CPX 325 #define IDR_FD_EGA18_CPX 326 +#define IDR_SL_LDLINUX_BSS 400 +#define IDR_SL_LDLINUX_SYS 401 #define IDC_DEVICE 1001 #define IDC_FILESYSTEM 1002 #define IDC_START 1003 diff --git a/src/rufus.c b/src/rufus.c index abf43a33..1b228a0f 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -56,7 +56,7 @@ char szFolderPath[MAX_PATH]; float fScale = 1.0f; int default_fs; HWND hDeviceList, hCapacity, hFileSystem, hClusterSize, hLabel, hDOSType, hNBPasses; -BOOL bWithFreeDOS; +BOOL bWithFreeDOS, bWithSysLinux; static HWND hDeviceTooltip = NULL, hFSTooltip = NULL, hProgress = NULL; static StrArray DriveID, DriveLabel; @@ -621,7 +621,18 @@ static void InitProgress(void) } if (IsChecked(IDC_DOS)) { // 1 extra slot for PBR writing - nb_slots[OP_DOS] = ((ComboBox_GetCurSel(hDOSType) == DT_FREEDOS)?5:3)+1; + // TODO: switch + switch (ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType))) { + case DT_WINME: + nb_slots[OP_DOS] = 3+1; + break; + case DT_FREEDOS: + nb_slots[OP_DOS] = 5+1; + break; + default: + nb_slots[OP_DOS] = 2+1; + break; + } } nb_slots[OP_PARTITION] = 1; nb_slots[OP_FIX_MBR] = 1; @@ -932,10 +943,13 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA IGNORE_RETVAL(ComboBox_AddStringU(hNBPasses, "4 Passes")); IGNORE_RETVAL(ComboBox_SetCurSel(hNBPasses, 1)); // Fill up the DOS type dropdown - IGNORE_RETVAL(ComboBox_AddStringU(hDOSType, "FreeDOS")); - IGNORE_RETVAL(ComboBox_AddStringU(hDOSType, "WinMe")); + IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "WinMe"), DT_WINME)); + if (bWithFreeDOS) + IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "FreeDOS"), DT_FREEDOS)); + if (bWithSysLinux) + IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "SysLinux"), DT_SYSLINUX)); IGNORE_RETVAL(ComboBox_SetCurSel(hDOSType, bWithFreeDOS?DT_FREEDOS:DT_WINME)); - if (bWithFreeDOS) { + if (bWithFreeDOS || bWithSysLinux) { SetDlgItemTextA(hDlg, IDC_DOS, "Create a DOS bootable disk:"); ShowWindow(hDOSType, SW_SHOW); } @@ -1126,6 +1140,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine bWithFreeDOS = (FindResource(hMainInstance, MAKEINTRESOURCE(IDR_FD_COMMAND_COM), RT_RCDATA) != NULL) && (FindResource(hMainInstance, MAKEINTRESOURCE(IDR_FD_KERNEL_SYS), RT_RCDATA) != NULL); uprintf("FreeDOS resources are %sembedded with this app\n", bWithFreeDOS?"":"NOT "); + // Find out if the SysLinux resources are embedded in the app + bWithSysLinux = (FindResource(hMainInstance, MAKEINTRESOURCE(IDR_SL_LDLINUX_SYS), RT_RCDATA) != NULL) && + (FindResource(hMainInstance, MAKEINTRESOURCE(IDR_SL_LDLINUX_BSS), RT_RCDATA) != NULL); + uprintf("SysLinux resources are %sembedded with this app\n", bWithSysLinux?"":"NOT "); // Create the main Window if ( (hDlg = CreateDialogA(hInstance, MAKEINTRESOURCEA(IDD_DIALOG), NULL, MainCallback)) == NULL ) { diff --git a/src/rufus.h b/src/rufus.h index 21bc832a..2cc89872 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -117,8 +117,9 @@ enum { }; enum dos_type { - DT_FREEDOS = 0, - DT_WINME, + DT_WINME = 0, + DT_FREEDOS, + DT_SYSLINUX, DT_MAX }; @@ -163,7 +164,8 @@ extern HWND CreateTooltip(HWND hControl, const char* message, int duration); extern void DestroyTooltip(HWND hWnd); extern void DestroyAllTooltips(void); extern BOOL Notification(int type, char* title, char* format, ...); -extern BOOL ExtractDOS(const char* path, int dos_type); +extern BOOL ExtractDOS(const char* path); +extern BOOL InstallSysLinux(DWORD num, const char* drive_name); extern void __cdecl FormatThread(void* param); extern BOOL CreatePartition(HANDLE hDrive); extern HANDLE GetDriveHandle(DWORD DriveIndex, char* DriveLetter, BOOL bWriteAccess, BOOL bLockDrive); diff --git a/src/rufus.rc b/src/rufus.rc index 8e2cacfa..eb15f16f 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -7,8 +7,10 @@ // // Generated from the TEXTINCLUDE 2 resource. // -#include "../ms-config.h" #include +#ifndef __GNUC__ +#include "../ms-config.h" +#endif #ifndef IDC_STATIC #define IDC_STATIC -1 #endif @@ -31,7 +33,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 206, 278 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW -CAPTION "Rufus v1.0.7.115" +CAPTION "Rufus v1.0.7.116" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,94,236,50,14 @@ -67,7 +69,7 @@ BEGIN DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP CONTROL "http://rufus.akeo.ie",IDC_ABOUT_RUFUS_URL, "SysLink",WS_TABSTOP,46,47,114,9 - LTEXT "Version 1.0.7 (Build 115)",IDC_STATIC,46,19,78,8 + LTEXT "Version 1.0.7 (Build 116)",IDC_STATIC,46,19,78,8 PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8 @@ -111,8 +113,10 @@ END 2 TEXTINCLUDE BEGIN - "#include ""../ms-config.h""\r\n" "#include \r\n" + "#ifndef __GNUC__\r\n" + "#include ""../ms-config.h""\r\n" + "#endif\r\n" "#ifndef IDC_STATIC\r\n" "#define IDC_STATIC -1\r\n" "#endif\r\n" @@ -152,6 +156,10 @@ BEGIN "IDR_FD_EGA17_CPX RCDATA ""../res/freedos/ega17.cpx""\r\n" "IDR_FD_EGA18_CPX RCDATA ""../res/freedos/ega18.cpx""\r\n" "#endif\r\n" + "#if defined(WITH_SYSLINUX)\r\n" + "IDR_SL_LDLINUX_BSS RCDATA ""../res/syslinux/ldlinux.bss""\r\n" + "IDR_SL_LDLINUX_SYS RCDATA ""../res/syslinux/ldlinux.sys""\r\n" + "#endif\r\n" "\r\n" "// Must reference a manifest for visual styles and elevation\r\n" "// Oh, and it must happen at the end, or MinGW will ignore it!\r\n" @@ -198,8 +206,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,7,115 - PRODUCTVERSION 1,0,7,115 + FILEVERSION 1,0,7,116 + PRODUCTVERSION 1,0,7,116 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -216,13 +224,13 @@ BEGIN BEGIN VALUE "CompanyName", "akeo.ie" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "1.0.7.115" + VALUE "FileVersion", "1.0.7.116" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "1.0.7.115" + VALUE "ProductVersion", "1.0.7.116" END END BLOCK "VarFileInfo" @@ -281,6 +289,10 @@ IDR_FD_EGA16_CPX RCDATA "../res/freedos/ega16.cpx" IDR_FD_EGA17_CPX RCDATA "../res/freedos/ega17.cpx" IDR_FD_EGA18_CPX RCDATA "../res/freedos/ega18.cpx" #endif +#if defined(WITH_SYSLINUX) +IDR_SL_LDLINUX_BSS RCDATA "../res/syslinux/ldlinux.bss" +IDR_SL_LDLINUX_SYS RCDATA "../res/syslinux/ldlinux.sys" +#endif // Must reference a manifest for visual styles and elevation // Oh, and it must happen at the end, or MinGW will ignore it! diff --git a/src/syslinux.c b/src/syslinux.c new file mode 100644 index 00000000..14ddb980 --- /dev/null +++ b/src/syslinux.c @@ -0,0 +1,212 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2003 Lars Munch Christensen - All Rights Reserved + * Copyright 1998-2008 H. Peter Anvin - All Rights Reserved + * Copyright 2011 Pete Batard + * + * Based on the Linux installer program for SYSLINUX by H. Peter Anvin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 53 Temple Place Ste 330, + * Boston MA 02111-1307, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* Memory leaks detection - define _CRTDBG_MAP_ALLOC as preprocessor macro */ +#ifdef _CRTDBG_MAP_ALLOC +#include +#include +#endif + +#include +#include +#include +#include + +#include "rufus.h" +#include "resource.h" + +#include "syslinux.h" +#include "libfat.h" +#include "setadv.h" + +unsigned char* syslinux_ldlinux; +unsigned int syslinux_ldlinux_len; +unsigned char* syslinux_bootsect; +unsigned int syslinux_bootsect_len; + +/* + * Wrapper for ReadFile suitable for libfat + */ +int libfat_readfile(intptr_t pp, void *buf, size_t secsize, + libfat_sector_t sector) +{ + uint64_t offset = (uint64_t) sector * secsize; + LONG loword = (LONG) offset; + LONG hiword = (LONG) (offset >> 32); + LONG hiwordx = hiword; + DWORD bytes_read; + + if (SetFilePointer((HANDLE) pp, loword, &hiwordx, FILE_BEGIN) != loword || + hiword != hiwordx || + !ReadFile((HANDLE) pp, buf, (DWORD)secsize, &bytes_read, NULL) || + bytes_read != secsize) { + uprintf("Cannot read sector %u\n", sector); + // TODO -1? + return 0; + } + + return (int)secsize; +} + +// TODO: set format errors +BOOL InstallSysLinux(DWORD num, const char* drive_name) +{ + HANDLE f_handle = INVALID_HANDLE_VALUE; + HANDLE d_handle = INVALID_HANDLE_VALUE; + DWORD bytes_read; + DWORD bytes_written; + BOOL r = FALSE; + HGLOBAL res_handle; + HRSRC res; + + static unsigned char sectbuf[SECTOR_SIZE]; + static char ldlinux_name[] = "?:\\ldlinux.sys"; + struct libfat_filesystem *fs; + libfat_sector_t s, *secp; + libfat_sector_t *sectors; + int ldlinux_sectors; + uint32_t ldlinux_cluster; + int nsectors; + + ldlinux_name[0] = drive_name[0]; + + /* Initialize the ADV -- this should be smarter */ + syslinux_reset_adv(syslinux_adv); + + /* Access ldlinux.sys resource */ + res = FindResource(hMainInstance, MAKEINTRESOURCE(IDR_SL_LDLINUX_SYS), RT_RCDATA); + if (res == NULL) { + uprintf("Unable to locate ldlinux.sys resource: %s\n", WindowsErrorString()); + goto out; + } + res_handle = LoadResource(NULL, res); + if (res_handle == NULL) { + uprintf("Unable to load ldlinux.sys resource: %s\n", WindowsErrorString()); + goto out; + } + syslinux_ldlinux = (unsigned char*)LockResource(res_handle); + syslinux_ldlinux_len = SizeofResource(NULL, res); + + /* Access ldlinux.bss resource */ + res = FindResource(hMainInstance, MAKEINTRESOURCE(IDR_SL_LDLINUX_BSS), RT_RCDATA); + if (res == NULL) { + uprintf("Unable to locate ldlinux.bss resource: %s\n", WindowsErrorString()); + goto out; + } + res_handle = LoadResource(NULL, res); + if (res_handle == NULL) { + uprintf("Unable to load ldlinux.bss resource: %s\n", WindowsErrorString()); + goto out; + } + syslinux_bootsect = (unsigned char*)LockResource(res_handle); + syslinux_bootsect_len = SizeofResource(NULL, res); + + /* Create ldlinux.sys file */ + f_handle = CreateFileA(ldlinux_name, GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, CREATE_ALWAYS, + FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM | + FILE_ATTRIBUTE_HIDDEN, NULL); + + if (f_handle == INVALID_HANDLE_VALUE) { + uprintf("Unable to create ldlinux.sys\n"); + goto out; + } + + /* Write ldlinux.sys file */ + if (!WriteFile(f_handle, syslinux_ldlinux, syslinux_ldlinux_len, + &bytes_written, NULL) || + bytes_written != syslinux_ldlinux_len) { + uprintf("Could not write ldlinux.sys\n"); + goto out; + } + if (!WriteFile(f_handle, syslinux_adv, 2 * ADV_SIZE, + &bytes_written, NULL) || + bytes_written != 2 * ADV_SIZE) { + uprintf("Could not write ADV to ldlinux.sys\n"); + goto out; + } + + /* Now flush the media */ + if (!FlushFileBuffers(f_handle)) { + uprintf("FlushFileBuffers failed\n"); + goto out; + } + + /* Reopen the volume (we already have a lock) */ + d_handle = GetDriveHandle(num, (char*)drive_name, TRUE, FALSE); + if (d_handle == INVALID_HANDLE_VALUE) { + uprintf("Could open volume for syslinux operation\n"); + FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OPEN_FAILED; + goto out; + } + + /* Map the file (is there a better way to do this?) */ + ldlinux_sectors = (syslinux_ldlinux_len + 2 * ADV_SIZE + SECTOR_SIZE - 1) >> SECTOR_SHIFT; + sectors = (libfat_sector_t*) calloc(ldlinux_sectors, sizeof *sectors); + fs = libfat_open(libfat_readfile, (intptr_t) d_handle); + ldlinux_cluster = libfat_searchdir(fs, 0, "LDLINUX SYS", NULL); + secp = sectors; + nsectors = 0; + s = libfat_clustertosector(fs, ldlinux_cluster); + while (s && nsectors < ldlinux_sectors) { + *secp++ = s; + nsectors++; + s = libfat_nextsector(fs, s); + } + libfat_close(fs); + + /* Patch ldlinux.sys and the boot sector */ + syslinux_patch(sectors, nsectors, 0, 0, NULL, NULL); + + /* Rewrite the file */ + if (SetFilePointer(f_handle, 0, NULL, FILE_BEGIN) != 0 || + !WriteFile(f_handle, syslinux_ldlinux, syslinux_ldlinux_len, + &bytes_written, NULL) + || bytes_written != syslinux_ldlinux_len) { + uprintf("Could not write ldlinux.sys: %s\n", WindowsErrorString()); + goto out; + } + + /* Close file */ + safe_closehandle(f_handle); + + /* Make the syslinux boot sector */ + if (SetFilePointer(d_handle, 0, NULL, FILE_BEGIN) != 0 || + !ReadFile(d_handle, sectbuf, SECTOR_SIZE, + &bytes_read, NULL) + || bytes_read != SECTOR_SIZE) { + uprintf("Could not read boot record: %s\n", WindowsErrorString()); + goto out; + } + + syslinux_make_bootsect(sectbuf); + + if (SetFilePointer(d_handle, 0, NULL, FILE_BEGIN) != 0 || + !WriteFile(d_handle, sectbuf, SECTOR_SIZE, + &bytes_written, NULL) + || bytes_written != SECTOR_SIZE) { + uprintf("Could not write boot record: %s\n", WindowsErrorString()); + goto out; + } + + r = TRUE; + +out: + safe_closehandle(d_handle); + safe_closehandle(f_handle); + return r; +} diff --git a/src/syslinux/inttypes.h b/src/syslinux/inttypes.h new file mode 100644 index 00000000..892b5bc6 --- /dev/null +++ b/src/syslinux/inttypes.h @@ -0,0 +1,301 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file was original part of the w64 mingw-runtime package. + */ + +/* + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * Modified for libusb/MSVC: Pete Batard + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAIMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Date: 2010-04-02 + */ + +#ifndef _MSC_VER +#error This header should only be used with Microsoft compilers +#endif + +/* 7.8 Format conversion of integer types */ + +#ifndef _INTTYPES_H_ +#define _INTTYPES_H_ + +#include +/* SysLinux types addon */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + intmax_t quot; + intmax_t rem; + } imaxdiv_t; + + +#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) + +/* 7.8.1 Macros for format specifiers + * + * MS runtime does not yet understand C9x standard "ll" + * length specifier. It appears to treat "ll" as "l". + * The non-standard I64 length specifier causes warning in GCC, + * but understood by MS runtime functions. + */ + +/* fprintf macros for signed types */ +#define PRId8 "d" +#define PRId16 "d" +#define PRId32 "d" +#define PRId64 "I64d" + +#define PRIdLEAST8 "d" +#define PRIdLEAST16 "d" +#define PRIdLEAST32 "d" +#define PRIdLEAST64 "I64d" + +#define PRIdFAST8 "d" +#define PRIdFAST16 "d" +#define PRIdFAST32 "d" +#define PRIdFAST64 "I64d" + +#define PRIdMAX "I64d" + +#define PRIi8 "i" +#define PRIi16 "i" +#define PRIi32 "i" +#define PRIi64 "I64i" + +#define PRIiLEAST8 "i" +#define PRIiLEAST16 "i" +#define PRIiLEAST32 "i" +#define PRIiLEAST64 "I64i" + +#define PRIiFAST8 "i" +#define PRIiFAST16 "i" +#define PRIiFAST32 "i" +#define PRIiFAST64 "I64i" + +#define PRIiMAX "I64i" + +#define PRIo8 "o" +#define PRIo16 "o" +#define PRIo32 "o" +#define PRIo64 "I64o" + +#define PRIoLEAST8 "o" +#define PRIoLEAST16 "o" +#define PRIoLEAST32 "o" +#define PRIoLEAST64 "I64o" + +#define PRIoFAST8 "o" +#define PRIoFAST16 "o" +#define PRIoFAST32 "o" +#define PRIoFAST64 "I64o" + +#define PRIoMAX "I64o" + +/* fprintf macros for unsigned types */ +#define PRIu8 "u" +#define PRIu16 "u" +#define PRIu32 "u" +#define PRIu64 "I64u" + + +#define PRIuLEAST8 "u" +#define PRIuLEAST16 "u" +#define PRIuLEAST32 "u" +#define PRIuLEAST64 "I64u" + +#define PRIuFAST8 "u" +#define PRIuFAST16 "u" +#define PRIuFAST32 "u" +#define PRIuFAST64 "I64u" + +#define PRIuMAX "I64u" + +#define PRIx8 "x" +#define PRIx16 "x" +#define PRIx32 "x" +#define PRIx64 "I64x" + +#define PRIxLEAST8 "x" +#define PRIxLEAST16 "x" +#define PRIxLEAST32 "x" +#define PRIxLEAST64 "I64x" + +#define PRIxFAST8 "x" +#define PRIxFAST16 "x" +#define PRIxFAST32 "x" +#define PRIxFAST64 "I64x" + +#define PRIxMAX "I64x" + +#define PRIX8 "X" +#define PRIX16 "X" +#define PRIX32 "X" +#define PRIX64 "I64X" + +#define PRIXLEAST8 "X" +#define PRIXLEAST16 "X" +#define PRIXLEAST32 "X" +#define PRIXLEAST64 "I64X" + +#define PRIXFAST8 "X" +#define PRIXFAST16 "X" +#define PRIXFAST32 "X" +#define PRIXFAST64 "I64X" + +#define PRIXMAX "I64X" + +/* + * fscanf macros for signed int types + * NOTE: if 32-bit int is used for int_fast8_t and int_fast16_t + * (see stdint.h, 7.18.1.3), FAST8 and FAST16 should have + * no length identifiers + */ + +#define SCNd16 "hd" +#define SCNd32 "d" +#define SCNd64 "I64d" + +#define SCNdLEAST16 "hd" +#define SCNdLEAST32 "d" +#define SCNdLEAST64 "I64d" + +#define SCNdFAST16 "hd" +#define SCNdFAST32 "d" +#define SCNdFAST64 "I64d" + +#define SCNdMAX "I64d" + +#define SCNi16 "hi" +#define SCNi32 "i" +#define SCNi64 "I64i" + +#define SCNiLEAST16 "hi" +#define SCNiLEAST32 "i" +#define SCNiLEAST64 "I64i" + +#define SCNiFAST16 "hi" +#define SCNiFAST32 "i" +#define SCNiFAST64 "I64i" + +#define SCNiMAX "I64i" + +#define SCNo16 "ho" +#define SCNo32 "o" +#define SCNo64 "I64o" + +#define SCNoLEAST16 "ho" +#define SCNoLEAST32 "o" +#define SCNoLEAST64 "I64o" + +#define SCNoFAST16 "ho" +#define SCNoFAST32 "o" +#define SCNoFAST64 "I64o" + +#define SCNoMAX "I64o" + +#define SCNx16 "hx" +#define SCNx32 "x" +#define SCNx64 "I64x" + +#define SCNxLEAST16 "hx" +#define SCNxLEAST32 "x" +#define SCNxLEAST64 "I64x" + +#define SCNxFAST16 "hx" +#define SCNxFAST32 "x" +#define SCNxFAST64 "I64x" + +#define SCNxMAX "I64x" + +/* fscanf macros for unsigned int types */ + +#define SCNu16 "hu" +#define SCNu32 "u" +#define SCNu64 "I64u" + +#define SCNuLEAST16 "hu" +#define SCNuLEAST32 "u" +#define SCNuLEAST64 "I64u" + +#define SCNuFAST16 "hu" +#define SCNuFAST32 "u" +#define SCNuFAST64 "I64u" + +#define SCNuMAX "I64u" + +#ifdef _WIN64 +#define PRIdPTR "I64d" +#define PRIiPTR "I64i" +#define PRIoPTR "I64o" +#define PRIuPTR "I64u" +#define PRIxPTR "I64x" +#define PRIXPTR "I64X" +#define SCNdPTR "I64d" +#define SCNiPTR "I64i" +#define SCNoPTR "I64o" +#define SCNxPTR "I64x" +#define SCNuPTR "I64u" +#else +#define PRIdPTR "d" +#define PRIiPTR "i" +#define PRIoPTR "o" +#define PRIuPTR "u" +#define PRIxPTR "x" +#define PRIXPTR "X" +#define SCNdPTR "d" +#define SCNiPTR "i" +#define SCNoPTR "o" +#define SCNxPTR "x" + #define SCNuPTR "u" +#endif + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +/* + * no length modifier for char types prior to C9x + * MS runtime scanf appears to treat "hh" as "h" + */ + +/* signed char */ +#define SCNd8 "hhd" +#define SCNdLEAST8 "hhd" +#define SCNdFAST8 "hhd" + +#define SCNi8 "hhi" +#define SCNiLEAST8 "hhi" +#define SCNiFAST8 "hhi" + +#define SCNo8 "hho" +#define SCNoLEAST8 "hho" +#define SCNoFAST8 "hho" + +#define SCNx8 "hhx" +#define SCNxLEAST8 "hhx" +#define SCNxFAST8 "hhx" + +/* unsigned char */ +#define SCNu8 "hhu" +#define SCNuLEAST8 "hhu" +#define SCNuFAST8 "hhu" +#endif /* __STDC_VERSION__ >= 199901 */ + +#endif /* !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) */ + + +#ifdef __cplusplus +} +#endif + +#endif /* ndef _INTTYPES_H */ diff --git a/src/syslinux/libfat/.msvc/libfat.vcxproj b/src/syslinux/libfat/.msvc/libfat.vcxproj new file mode 100644 index 00000000..7262a131 --- /dev/null +++ b/src/syslinux/libfat/.msvc/libfat.vcxproj @@ -0,0 +1,172 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + + + + {8390DCE0-859D-4F57-AD9C-AAEAC4D77EEF} + Win32Proj + libfat + syslinux-libfat + + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + true + Unicode + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + true + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)x86_32\$(Configuration)\ + $(SolutionDir)x86_32\$(Configuration)\$(ProjectName)\ + $(SolutionDir)x86_32\$(Configuration)\ + $(SolutionDir)x86_32\$(Configuration)\$(ProjectName)\ + $(SolutionDir)x86_64\$(Configuration)\ + $(SolutionDir)x86_64\$(Configuration)\$(ProjectName)\ + $(SolutionDir)x86_64\$(Configuration)\ + $(SolutionDir)x86_64\$(Configuration)\$(ProjectName)\ + false + false + false + false + + + + + + Level3 + Disabled + _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) + ..;..\..;%(AdditionalIncludeDirectories) + MultiThreadedDebug + ProgramDatabase + + + Windows + true + + + MachineX86 + + + + + Level3 + + + MaxSpeed + true + _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) + ..;..\..;%(AdditionalIncludeDirectories) + MultiThreaded + ProgramDatabase + + + MachineX86 + + + + + + + Level3 + Disabled + _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) + ..;..\..;%(AdditionalIncludeDirectories) + MultiThreadedDebug + ProgramDatabase + + + Windows + true + + + MachineX64 + + + + + Level3 + + + MaxSpeed + true + _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) + ..;..\..;%(AdditionalIncludeDirectories) + MultiThreaded + ProgramDatabase + + + Windows + true + true + true + + + MachineX64 + + + + + + \ No newline at end of file diff --git a/src/syslinux/libfat/.msvc/libfat.vcxproj.filters b/src/syslinux/libfat/.msvc/libfat.vcxproj.filters new file mode 100644 index 00000000..f89ce1a4 --- /dev/null +++ b/src/syslinux/libfat/.msvc/libfat.vcxproj.filters @@ -0,0 +1,41 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/src/syslinux/libfat/.msvc/libfat_sources b/src/syslinux/libfat/.msvc/libfat_sources new file mode 100644 index 00000000..858bf26f --- /dev/null +++ b/src/syslinux/libfat/.msvc/libfat_sources @@ -0,0 +1,18 @@ +TARGETNAME=libfat +TARGETTYPE=LIBRARY + +INCLUDES=$(DDK_INC_PATH);.. +C_DEFINES=$(C_DEFINES) /DDDKBUILD /DUNICODE /D_UNICODE /DISOLATION_AWARE_ENABLED + +!IFNDEF MSC_WARNING_LEVEL +MSC_WARNING_LEVEL=/W3 +!ENDIF +USE_MSVCRT=1 + +TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \ + $(SDK_LIB_PATH)\user32.lib + +SOURCES=cache.c \ + fatchain.c \ + open.c \ + searchdir.c \ No newline at end of file diff --git a/src/syslinux/libfat/cache.c b/src/syslinux/libfat/cache.c new file mode 100644 index 00000000..85b7eadf --- /dev/null +++ b/src/syslinux/libfat/cache.c @@ -0,0 +1,65 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2004-2008 H. Peter Anvin - All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 53 Temple Place Ste 330, + * Boston MA 02111-1307, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * cache.c + * + * Simple sector cache + */ + +#include +#include "libfatint.h" + +void *libfat_get_sector(struct libfat_filesystem *fs, libfat_sector_t n) +{ + struct libfat_sector *ls; + + for (ls = fs->sectors; ls; ls = ls->next) { + if (ls->n == n) + return ls->data; /* Found in cache */ + } + + /* Not found in cache */ + ls = malloc(sizeof(struct libfat_sector)); + if (!ls) { + libfat_flush(fs); + ls = malloc(sizeof(struct libfat_sector)); + + if (!ls) + return NULL; /* Can't allocate memory */ + } + + if (fs->read(fs->readptr, ls->data, LIBFAT_SECTOR_SIZE, n) + != LIBFAT_SECTOR_SIZE) { + free(ls); + return NULL; /* I/O error */ + } + + ls->n = n; + ls->next = fs->sectors; + fs->sectors = ls; + + return ls->data; +} + +void libfat_flush(struct libfat_filesystem *fs) +{ + struct libfat_sector *ls, *lsnext; + + lsnext = fs->sectors; + fs->sectors = NULL; + + for (ls = lsnext; ls; ls = lsnext) { + lsnext = ls->next; + free(ls); + } +} diff --git a/src/syslinux/libfat/fat.h b/src/syslinux/libfat/fat.h new file mode 100644 index 00000000..b4e32f76 --- /dev/null +++ b/src/syslinux/libfat/fat.h @@ -0,0 +1,108 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2001-2008 H. Peter Anvin - All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 53 Temple Place Ste 330, + * Boston MA 02111-1307, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * fat.h + * + * Basic data structures for a FAT filesystem + */ + +#ifndef FAT_H +#define FAT_H + +#include "ulint.h" + +/* The poor excuse FAT has for a superblock -- in the boot sector */ +struct fat_bootsect { + le8_t bsJump[3]; /* Jump to code */ + char bsOemName[8]; /* Formatting program */ + le16_t bsBytesPerSec; /* Bytes/sector */ + le8_t bsSecPerClust; /* Sectors/cluster */ + le16_t bsResSectors; /* Reserved sectors */ + le8_t bsFATs; /* Number of FATs */ + le16_t bsRootDirEnts; /* Number of entries/root directory */ + le16_t bsSectors; /* Number of sectors [1] */ + le8_t bsMedia; /* Magic media type byte */ + le16_t bsFATsecs; /* Sectors/FAT */ + le16_t bsSecPerTrack; /* Sectors/track */ + le16_t bsHeads; /* Number of heads */ + le32_t bsHiddenSecs; /* Number of hidden sectors */ + le32_t bsHugeSectors; /* Number of sectors [2] */ + union { + /* FAT12/16 */ + struct { + le8_t bsDriveNumber; /* Drive number */ + le8_t bsReserved1; /* Reserved */ + le8_t bsBootSignature; /* 0x29 */ + le32_t bsVolumeID; /* Volume serial number */ + char bsVolumeLabel[11]; /* Volume name */ + char bsFileSysType[8]; /* File system type */ + + le8_t bsCode[448]; /* Boot sector code */ + } fat16; + + /* FAT32 */ + struct { + le32_t bpb_fatsz32; /* Sectors/FAT */ + le16_t bpb_extflags; /* Extended flags */ + le16_t bpb_fsver; /* Filesystem version */ + le32_t bpb_rootclus; /* Root directory cluster */ + le16_t bpb_fsinfo; /* FSINFO sector number */ + le16_t bpb_bkbootsec; /* Backup boot sector (superblock) */ + char bpb_reserved[12]; + + /* Same shit, different offset! */ + le8_t bsDriveNumber; /* Drive number */ + le8_t bsReserved1; /* Reserved */ + le8_t bsBootSignature; /* 0x29 */ + le32_t bsVolumeID; /* Volume serial number */ + char bsVolumeLabel[11]; /* Volume name */ + char bsFileSysType[8]; /* File system type */ + + le8_t bsCode[420]; /* Boot sector code */ + } fat32; + } u; + + le16_t bsSignature; /* 0xAA55 */ +}; + +#define BS_BOOTSIGNATURE 0x29 +#define BS_SIGNATURE 0xAA55 + +/* A FAT filesystem directory entry */ + +struct fat_dirent { + le8_t name[11]; /* Mangled filename */ + le8_t attribute; /* File type/attribute */ + le8_t caseflags; /* VFAT: case for basis and extension */ + le8_t ctime_ms; /* ms of creation time */ + le32_t ctime; /* Creation time */ + le16_t atime; /* Date portion (high 16 bits) of atime */ + le16_t clusthi; /* FAT32: high 16 bits of cluster */ + le32_t mtime; /* Modification time */ + le16_t clustlo; /* First cluster pointer */ + le32_t size; /* File size (bytes) */ +}; + +/* A VFAT filesystem continuation entry */ +struct fat_vfat_slot { + le8_t id; /* Sequence number for slot */ + le16_t name0[5]; /* 5 characters */ + le8_t attribute; /* Attribute byte */ + le8_t reserved; /* Reserved, MBZ */ + le8_t alias_csum; /* Short name checksum */ + le16_t name5[6]; /* 6 characters */ + le16_t firstclust; /* MBZ */ + le16_t name11[2]; /* 2 characters */ +}; + +#endif /* FAT_H */ diff --git a/src/syslinux/libfat/fatchain.c b/src/syslinux/libfat/fatchain.c new file mode 100644 index 00000000..16d2111a --- /dev/null +++ b/src/syslinux/libfat/fatchain.c @@ -0,0 +1,134 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2004-2008 H. Peter Anvin - All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 53 Temple Place Ste 330, + * Boston MA 02111-1307, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * fatchain.c + * + * Follow a FAT chain + */ + +#include "libfatint.h" +#include "ulint.h" + +/* + * Convert a cluster number (or 0 for the root directory) to a + * sector number. Return -1 on failure. + */ +libfat_sector_t libfat_clustertosector(const struct libfat_filesystem *fs, + int32_t cluster) +{ + if (cluster == 0) + cluster = fs->rootcluster; + + if (cluster == 0) + return fs->rootdir; + else if (cluster < 2 || cluster >= fs->endcluster) + return -1; + else + return fs->data + ((libfat_sector_t) (cluster - 2) << fs->clustshift); +} + +/* + * Get the next sector of either the root directory or a FAT chain. + * Returns 0 on end of file and -1 on error. + */ + +libfat_sector_t libfat_nextsector(struct libfat_filesystem * fs, + libfat_sector_t s) +{ + int32_t cluster, nextcluster; + uint32_t fatoffset; + libfat_sector_t fatsect; + uint8_t *fsdata; + uint32_t clustmask = fs->clustsize - 1; + libfat_sector_t rs; + + if (s < fs->data) { + if (s < fs->rootdir) + return -1; + + /* Root directory */ + s++; + return (s < fs->data) ? s : 0; + } + + rs = s - fs->data; + + if (~rs & clustmask) + return s + 1; /* Next sector in cluster */ + + cluster = (int32_t) (2 + (rs >> fs->clustshift)); + + if (cluster >= fs->endcluster) + return -1; + + switch (fs->fat_type) { + case FAT12: + /* Get first byte */ + fatoffset = cluster + (cluster >> 1); + fatsect = fs->fat + (fatoffset >> LIBFAT_SECTOR_SHIFT); + fsdata = libfat_get_sector(fs, fatsect); + if (!fsdata) + return -1; + nextcluster = fsdata[fatoffset & LIBFAT_SECTOR_MASK]; + + /* Get second byte */ + fatoffset++; + fatsect = fs->fat + (fatoffset >> LIBFAT_SECTOR_SHIFT); + fsdata = libfat_get_sector(fs, fatsect); + if (!fsdata) + return -1; + nextcluster |= fsdata[fatoffset & LIBFAT_SECTOR_MASK] << 8; + + /* Extract the FAT entry */ + if (cluster & 1) + nextcluster >>= 4; + else + nextcluster &= 0x0FFF; + + if (nextcluster >= 0x0FF8) + return 0; + break; + + case FAT16: + fatoffset = cluster << 1; + fatsect = fs->fat + (fatoffset >> LIBFAT_SECTOR_SHIFT); + fsdata = libfat_get_sector(fs, fatsect); + if (!fsdata) + return -1; + nextcluster = + read16((le16_t *) & fsdata[fatoffset & LIBFAT_SECTOR_MASK]); + + if (nextcluster >= 0x0FFF8) + return 0; + break; + + case FAT28: + fatoffset = cluster << 2; + fatsect = fs->fat + (fatoffset >> LIBFAT_SECTOR_SHIFT); + fsdata = libfat_get_sector(fs, fatsect); + if (!fsdata) + return -1; + nextcluster = + read32((le32_t *) & fsdata[fatoffset & LIBFAT_SECTOR_MASK]); + nextcluster &= 0x0FFFFFFF; + + if (nextcluster >= 0x0FFFFFF8) + return 0; + break; + + default: + return -1; /* WTF? */ + } + + return libfat_clustertosector(fs, nextcluster); +} diff --git a/src/syslinux/libfat/libfat.h b/src/syslinux/libfat/libfat.h new file mode 100644 index 00000000..a0179d7c --- /dev/null +++ b/src/syslinux/libfat/libfat.h @@ -0,0 +1,85 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2004-2008 H. Peter Anvin - All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 53 Temple Place Ste 330, + * Boston MA 02111-1307, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * libfat.h + * + * Headers for the libfat library + */ + +#ifndef LIBFAT_H +#define LIBFAT_H + +#include +#include + +#define LIBFAT_SECTOR_SHIFT 9 +#define LIBFAT_SECTOR_SIZE 512 +#define LIBFAT_SECTOR_MASK 511 + +typedef uint64_t libfat_sector_t; +struct libfat_filesystem; + +struct libfat_direntry { + libfat_sector_t sector; + int offset; + unsigned char entry[32]; +}; + +/* + * Open the filesystem. The readfunc is the function to read + * sectors, in the format: + * int readfunc(intptr_t readptr, void *buf, size_t secsize, + * libfat_sector_t secno) + * + * ... where readptr is a private argument. + * + * A return value of != secsize is treated as error. + */ +struct libfat_filesystem + *libfat_open(int (*readfunc) (intptr_t, void *, size_t, libfat_sector_t), + intptr_t readptr); + +void libfat_close(struct libfat_filesystem *); + +/* + * Convert a cluster number (or 0 for the root directory) to a + * sector number. Return -1 on failure. + */ +libfat_sector_t libfat_clustertosector(const struct libfat_filesystem *fs, + int32_t cluster); + +/* + * Get the next sector of either the root directory or a FAT chain. + * Returns 0 on end of file and -1 on error. + */ +libfat_sector_t libfat_nextsector(struct libfat_filesystem *fs, + libfat_sector_t s); + +/* + * Flush all cached sectors for this filesystem. + */ +void libfat_flush(struct libfat_filesystem *fs); + +/* + * Get a pointer to a specific sector. + */ +void *libfat_get_sector(struct libfat_filesystem *fs, libfat_sector_t n); + +/* + * Search a FAT directory for a particular pre-mangled filename. + * Copies the directory entry into direntry and returns 0 if found. + */ +int32_t libfat_searchdir(struct libfat_filesystem *fs, int32_t dirclust, + const void *name, struct libfat_direntry *direntry); + +#endif /* LIBFAT_H */ diff --git a/src/syslinux/libfat/libfatint.h b/src/syslinux/libfat/libfatint.h new file mode 100644 index 00000000..adfad00b --- /dev/null +++ b/src/syslinux/libfat/libfatint.h @@ -0,0 +1,55 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2004-2008 H. Peter Anvin - All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 53 Temple Place Ste 330, + * Boston MA 02111-1307, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * libfatint.h + * + * Internals for the libfat filesystem + */ + +#ifndef LIBFATINT_H +#define LIBFATINT_H + +#include "libfat.h" +#include "fat.h" + +struct libfat_sector { + libfat_sector_t n; /* Sector number */ + struct libfat_sector *next; /* Next in list */ + char data[LIBFAT_SECTOR_SIZE]; +}; + +enum fat_type { + FAT12, + FAT16, + FAT28 +}; + +struct libfat_filesystem { + int (*read) (intptr_t, void *, size_t, libfat_sector_t); + intptr_t readptr; + + enum fat_type fat_type; + unsigned int clustsize; + int clustshift; + int32_t endcluster; /* Highest legal cluster number + 1 */ + int32_t rootcluster; /* Root directory cluster */ + + libfat_sector_t fat; /* Start of FAT */ + libfat_sector_t rootdir; /* Start of root directory */ + libfat_sector_t data; /* Start of data area */ + libfat_sector_t end; /* End of filesystem */ + + struct libfat_sector *sectors; +}; + +#endif /* LIBFATINT_H */ diff --git a/src/syslinux/libfat/open.c b/src/syslinux/libfat/open.c new file mode 100644 index 00000000..43c4b085 --- /dev/null +++ b/src/syslinux/libfat/open.c @@ -0,0 +1,117 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2004-2008 H. Peter Anvin - All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 53 Temple Place Ste 330, + * Boston MA 02111-1307, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * open.c + * + * Open a FAT filesystem and compute some initial values; return NULL + * on failure. + */ + +#include +#include "libfatint.h" +#include "ulint.h" + +struct libfat_filesystem * +libfat_open(int (*readfunc) (intptr_t, void *, size_t, libfat_sector_t), + intptr_t readptr) +{ + struct libfat_filesystem *fs = NULL; + struct fat_bootsect *bs; + int i; + uint32_t sectors, fatsize, minfatsize, rootdirsize; + uint32_t nclusters; + + fs = malloc(sizeof(struct libfat_filesystem)); + if (!fs) + goto barf; + + fs->sectors = NULL; + fs->read = readfunc; + fs->readptr = readptr; + + bs = libfat_get_sector(fs, 0); + if (!bs) + goto barf; + + if (read16(&bs->bsBytesPerSec) != LIBFAT_SECTOR_SIZE) + goto barf; + + for (i = 0; i <= 8; i++) { + if ((uint8_t) (1 << i) == read8(&bs->bsSecPerClust)) + break; + } + if (i > 8) + goto barf; + fs->clustsize = 1 << i; /* Treat 0 as 2^8 = 64K */ + fs->clustshift = i; + + sectors = read16(&bs->bsSectors); + if (!sectors) + sectors = read32(&bs->bsHugeSectors); + + fs->end = sectors; + + fs->fat = read16(&bs->bsResSectors); + fatsize = read16(&bs->bsFATsecs); + if (!fatsize) + fatsize = read32(&bs->u.fat32.bpb_fatsz32); + + fs->rootdir = fs->fat + fatsize * read8(&bs->bsFATs); + + rootdirsize = ((read16(&bs->bsRootDirEnts) << 5) + LIBFAT_SECTOR_MASK) + >> LIBFAT_SECTOR_SHIFT; + fs->data = fs->rootdir + rootdirsize; + + /* Sanity checking */ + if (fs->data >= fs->end) + goto barf; + + /* Figure out how many clusters */ + nclusters = (uint32_t) ((fs->end - fs->data) >> fs->clustshift); + fs->endcluster = nclusters + 2; + + if (nclusters <= 0xff4) { + fs->fat_type = FAT12; + minfatsize = fs->endcluster + (fs->endcluster >> 1); + } else if (nclusters <= 0xfff4) { + fs->fat_type = FAT16; + minfatsize = fs->endcluster << 1; + } else if (nclusters <= 0xffffff4) { + fs->fat_type = FAT28; + minfatsize = fs->endcluster << 2; + } else + goto barf; /* Impossibly many clusters */ + + minfatsize = (minfatsize + LIBFAT_SECTOR_SIZE - 1) >> LIBFAT_SECTOR_SHIFT; + + if (minfatsize > fatsize) + goto barf; /* The FATs don't fit */ + + if (fs->fat_type == FAT28) + fs->rootcluster = read32(&bs->u.fat32.bpb_rootclus); + else + fs->rootcluster = 0; + + return fs; /* All good */ + +barf: + if (fs) + free(fs); + return NULL; +} + +void libfat_close(struct libfat_filesystem *fs) +{ + libfat_flush(fs); + free(fs); +} diff --git a/src/syslinux/libfat/searchdir.c b/src/syslinux/libfat/searchdir.c new file mode 100644 index 00000000..4964120b --- /dev/null +++ b/src/syslinux/libfat/searchdir.c @@ -0,0 +1,64 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2004-2008 H. Peter Anvin - All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 53 Temple Place Ste 330, + * Boston MA 02111-1307, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * searchdir.c + * + * Search a FAT directory for a particular pre-mangled filename. + * Copies the directory entry into direntry and returns the starting cluster + * if found; returns -2 on not found, -1 on error, 0 on empty file. + */ + +#include +#include "libfatint.h" + +int32_t libfat_searchdir(struct libfat_filesystem *fs, int32_t dirclust, + const void *name, struct libfat_direntry *direntry) +{ + struct fat_dirent *dep; + int nent; + libfat_sector_t s = libfat_clustertosector(fs, dirclust); + + while (1) { + if (s == 0) + return -2; /* Not found */ + else if (s == (libfat_sector_t) - 1) + return -1; /* Error */ + + dep = libfat_get_sector(fs, s); + if (!dep) + return -1; /* Read error */ + + for (nent = 0; nent < LIBFAT_SECTOR_SIZE; + nent += sizeof(struct fat_dirent)) { + if (!memcmp(dep->name, name, 11)) { + if (direntry) { + memcpy(direntry->entry, dep, sizeof(*dep)); + direntry->sector = s; + direntry->offset = nent; + } + if (read32(&dep->size) == 0) + return 0; /* An empty file has no clusters */ + else + return read16(&dep->clustlo) + + (read16(&dep->clusthi) << 16); + } + + if (dep->name[0] == 0) + return -2; /* Hit high water mark */ + + dep++; + } + + s = libfat_nextsector(fs, s); + } +} diff --git a/src/syslinux/libfat/ulint.h b/src/syslinux/libfat/ulint.h new file mode 100644 index 00000000..c2fadb72 --- /dev/null +++ b/src/syslinux/libfat/ulint.h @@ -0,0 +1,112 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2001-2008 H. Peter Anvin - All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139, + * USA; either version 2 of the License, or (at your option) any later + * version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * ulint.h + * + * Basic operations on unaligned, littleendian integers + */ + +#ifndef ULINT_H +#define ULINT_H + +#include + +/* These are unaligned, littleendian integer types */ + +typedef uint8_t le8_t; /* 8-bit byte */ +typedef uint8_t le16_t[2]; /* 16-bit word */ +typedef uint8_t le32_t[4]; /* 32-bit dword */ + +/* Read/write these quantities */ + +static inline unsigned char read8(le8_t * _p) +{ + return *_p; +} + +static inline void write8(le8_t * _p, uint8_t _v) +{ + *_p = _v; +} + +#if defined(__i386__) || defined(__x86_64__) + +/* Littleendian architectures which support unaligned memory accesses */ + +static inline unsigned short read16(le16_t * _p) +{ + return *((const uint16_t *)_p); +} + +static inline void write16(le16_t * _p, unsigned short _v) +{ + *((uint16_t *) _p) = _v; +} + +static inline unsigned int read32(le32_t * _p) +{ + return *((const uint32_t *)_p); +} + +static inline void write32(le32_t * _p, uint32_t _v) +{ + *((uint32_t *) _p) = _v; +} + +#else + +/* Generic, mostly portable versions */ + +static inline unsigned short read16(le16_t * _pp) +{ + uint8_t *_p = *_pp; + uint16_t _v; + + _v = _p[0]; + _v |= _p[1] << 8; + return _v; +} + +static inline void write16(le16_t * _pp, uint16_t _v) +{ + uint8_t *_p = *_pp; + + _p[0] = _v & 0xFF; + _p[1] = (_v >> 8) & 0xFF; +} + +static inline unsigned int read32(le32_t * _pp) +{ + uint8_t *_p = *_pp; + uint32_t _v; + + _v = _p[0]; + _v |= _p[1] << 8; + _v |= _p[2] << 16; + _v |= _p[3] << 24; + return _v; +} + +static inline void write32(le32_t * _pp, uint32_t _v) +{ + uint8_t *_p = *_pp; + + _p[0] = _v & 0xFF; + _p[1] = (_v >> 8) & 0xFF; + _p[2] = (_v >> 16) & 0xFF; + _p[3] = (_v >> 24) & 0xFF; +} + +#endif + +#endif /* ULINT_H */ diff --git a/src/syslinux/libinstaller/.msvc/libinstaller.vcxproj b/src/syslinux/libinstaller/.msvc/libinstaller.vcxproj new file mode 100644 index 00000000..4a32c72c --- /dev/null +++ b/src/syslinux/libinstaller/.msvc/libinstaller.vcxproj @@ -0,0 +1,170 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + + {266502AC-CD74-4581-B707-938A7D05AD7A} + Win32Proj + libinstaller + syslinux-libinstaller + + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + true + Unicode + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + true + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)x86_32\$(Configuration)\ + $(SolutionDir)x86_32\$(Configuration)\$(ProjectName)\ + $(SolutionDir)x86_32\$(Configuration)\ + $(SolutionDir)x86_32\$(Configuration)\$(ProjectName)\ + $(SolutionDir)x86_64\$(Configuration)\ + $(SolutionDir)x86_64\$(Configuration)\$(ProjectName)\ + $(SolutionDir)x86_64\$(Configuration)\ + $(SolutionDir)x86_64\$(Configuration)\$(ProjectName)\ + false + false + false + false + + + + + + Level3 + Disabled + _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) + ..;..\..;%(AdditionalIncludeDirectories) + MultiThreadedDebug + ProgramDatabase + + + Windows + true + + + MachineX86 + + + + + Level3 + + + MaxSpeed + true + _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) + ..;..\..;%(AdditionalIncludeDirectories) + MultiThreaded + ProgramDatabase + + + MachineX86 + + + + + + + Level3 + Disabled + _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) + ..;..\..;%(AdditionalIncludeDirectories) + MultiThreadedDebug + ProgramDatabase + + + Windows + true + + + MachineX64 + + + + + Level3 + + + MaxSpeed + true + _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) + ..;..\..;%(AdditionalIncludeDirectories) + MultiThreaded + ProgramDatabase + + + Windows + true + true + true + + + MachineX64 + + + + + + \ No newline at end of file diff --git a/src/syslinux/libinstaller/.msvc/libinstaller.vcxproj.filters b/src/syslinux/libinstaller/.msvc/libinstaller.vcxproj.filters new file mode 100644 index 00000000..82f38a3c --- /dev/null +++ b/src/syslinux/libinstaller/.msvc/libinstaller.vcxproj.filters @@ -0,0 +1,35 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/src/syslinux/libinstaller/.msvc/libinstaller_sources b/src/syslinux/libinstaller/.msvc/libinstaller_sources new file mode 100644 index 00000000..0096225d --- /dev/null +++ b/src/syslinux/libinstaller/.msvc/libinstaller_sources @@ -0,0 +1,17 @@ +TARGETNAME=libinstaller +TARGETTYPE=LIBRARY + +INCLUDES=$(DDK_INC_PATH);.. +C_DEFINES=$(C_DEFINES) /DDDKBUILD /DUNICODE /D_UNICODE /DISOLATION_AWARE_ENABLED + +!IFNDEF MSC_WARNING_LEVEL +MSC_WARNING_LEVEL=/W3 +!ENDIF +USE_MSVCRT=1 + +TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \ + $(SDK_LIB_PATH)\user32.lib + +SOURCES=fat.c \ + setadv.c \ + syslxmod.c \ No newline at end of file diff --git a/src/syslinux/libinstaller/advconst.h b/src/syslinux/libinstaller/advconst.h new file mode 100644 index 00000000..b7c775fd --- /dev/null +++ b/src/syslinux/libinstaller/advconst.h @@ -0,0 +1,45 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved + * Copyright 2009 Intel Corporation; author: H. Peter Anvin + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- */ + +/* + * syslinux/advconst.h + * + * ADV defined constants + * + * Defined in a separate file so it can be used by non-COM32 code. + * Some of these constants are also defined in adv.inc, they better match... + */ + +#ifndef _SYSLINUX_ADVCONST_H +#define _SYSLINUX_ADVCONST_H + +#define ADV_END 0 +#define ADV_BOOTONCE 1 +#define ADV_MENUSAVE 2 + +#endif /* _SYSLINUX_ADVCONST_H */ diff --git a/src/syslinux/libinstaller/fat.c b/src/syslinux/libinstaller/fat.c new file mode 100644 index 00000000..9cde00c2 --- /dev/null +++ b/src/syslinux/libinstaller/fat.c @@ -0,0 +1,126 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 1998-2008 H. Peter Anvin - All Rights Reserved + * Copyright 2009-2010 Intel Corporation; author H. Peter Anvin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 53 Temple Place Ste 330, + * Boston MA 02111-1307, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * fat.c - Initial sanity check for FAT-based installers + */ + +#define _XOPEN_SOURCE 500 /* Required on glibc 2.x */ +#define _BSD_SOURCE +#include +#include +#include +#include +#include + +#include "syslinux.h" +#include "syslxint.h" + +void syslinux_make_bootsect(void *bs) +{ + struct boot_sector *bootsect = bs; + const struct boot_sector *sbs = + (const struct boot_sector *)boot_sector; + + memcpy(&bootsect->bsHead, &sbs->bsHead, bsHeadLen); + memcpy(&bootsect->bsCode, &sbs->bsCode, bsCodeLen); +} + +/* + * Check to see that what we got was indeed an MS-DOS boot sector/superblock; + * Return NULL if OK and otherwise an error message; + */ +const char *syslinux_check_bootsect(const void *bs) +{ + int sectorsize; + long long sectors, fatsectors, dsectors; + long long clusters; + int rootdirents, clustersize; + const struct boot_sector *sectbuf = bs; + + /* Must be 0xF0 or 0xF8..0xFF */ + if (get_8(§buf->bsMedia) != 0xF0 && get_8(§buf->bsMedia) < 0xF8) + return "invalid media signature (not a FAT filesystem?)"; + + sectorsize = get_16(§buf->bsBytesPerSec); + if (sectorsize == SECTOR_SIZE) + ; /* ok */ + else if (sectorsize >= 512 && sectorsize <= 4096 && + (sectorsize & (sectorsize - 1)) == 0) + return "unsupported sectors size"; + else + return "impossible sector size"; + + clustersize = get_8(§buf->bsSecPerClust); + if (clustersize == 0 || (clustersize & (clustersize - 1))) + return "impossible cluster size"; + + sectors = get_16(§buf->bsSectors); + sectors = sectors ? sectors : get_32(§buf->bsHugeSectors); + + dsectors = sectors - get_16(§buf->bsResSectors); + + fatsectors = get_16(§buf->bsFATsecs); + fatsectors = fatsectors ? fatsectors : get_32(§buf->bs32.FATSz32); + fatsectors *= get_8(§buf->bsFATs); + dsectors -= fatsectors; + + rootdirents = get_16(§buf->bsRootDirEnts); + dsectors -= (rootdirents + sectorsize / 32 - 1) / sectorsize; + + if (dsectors < 0) + return "negative number of data sectors"; + + if (fatsectors == 0) + return "zero FAT sectors"; + + clusters = dsectors / clustersize; + + if (clusters < 0xFFF5) { + /* FAT12 or FAT16 */ + + if (!get_16(§buf->bsFATsecs)) + return "zero FAT sectors (FAT12/16)"; + + if (get_8(§buf->bs16.BootSignature) == 0x29) { + if (!memcmp(§buf->bs16.FileSysType, "FAT12 ", 8)) { + if (clusters >= 0xFF5) + return "more than 4084 clusters but claims FAT12"; + } else if (!memcmp(§buf->bs16.FileSysType, "FAT16 ", 8)) { + if (clusters < 0xFF5) + return "less than 4084 clusters but claims FAT16"; + } else if (!memcmp(§buf->bs16.FileSysType, "FAT32 ", 8)) { + return "less than 65525 clusters but claims FAT32"; + } else if (memcmp(§buf->bs16.FileSysType, "FAT ", 8)) { + static char fserr[] = + "filesystem type \"????????\" not supported"; + memcpy(fserr + 17, §buf->bs16.FileSysType, 8); + return fserr; + } + } + } else if (clusters < 0x0FFFFFF5) { + /* + * FAT32... + * + * Moving the FileSysType and BootSignature was a lovely stroke + * of M$ idiocy... + */ + if (get_8(§buf->bs32.BootSignature) != 0x29 || + memcmp(§buf->bs32.FileSysType, "FAT32 ", 8)) + return "missing FAT32 signature"; + } else { + return "impossibly large number of clusters"; + } + + return NULL; +} diff --git a/src/syslinux/libinstaller/setadv.c b/src/syslinux/libinstaller/setadv.c new file mode 100644 index 00000000..a2cf2ac1 --- /dev/null +++ b/src/syslinux/libinstaller/setadv.c @@ -0,0 +1,166 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved + * Copyright 2010 Intel Corporation; author: H. Peter Anvin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 53 Temple Place Ste 330, + * Boston MA 02111-1307, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * setadv.c + * + * (Over)write a data item in the auxilliary data vector. To + * delete an item, set its length to zero. + * + * Return 0 on success, -1 on error, and set errno. + * + */ +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include "syslxint.h" + +unsigned char syslinux_adv[2 * ADV_SIZE]; + +#define ADV_MAGIC1 0x5a2d2fa5 /* Head signature */ +#define ADV_MAGIC2 0xa3041767 /* Total checksum */ +#define ADV_MAGIC3 0xdd28bf64 /* Tail signature */ + +static void cleanup_adv(unsigned char *advbuf) +{ + int i; + uint32_t csum; + + /* Make sure both copies agree, and update the checksum */ + set_32((uint32_t *) advbuf, ADV_MAGIC1); + + csum = ADV_MAGIC2; + for (i = 8; i < ADV_SIZE - 4; i += 4) + csum -= get_32((uint32_t *) (advbuf + i)); + + set_32((uint32_t *) (advbuf + 4), csum); + set_32((uint32_t *) (advbuf + ADV_SIZE - 4), ADV_MAGIC3); + + memcpy(advbuf + ADV_SIZE, advbuf, ADV_SIZE); +} + +int syslinux_setadv(int tag, size_t size, const void *data) +{ + uint8_t *p; + size_t left; + uint8_t advtmp[ADV_SIZE]; + + if ((unsigned)tag - 1 > 254) { + errno = EINVAL; + return -1; /* Impossible tag value */ + } + + if (size > 255) { + errno = ENOSPC; /* Max 255 bytes for a data item */ + return -1; + } + + left = ADV_LEN; + p = advtmp; + memcpy(p, syslinux_adv + 2 * 4, left); /* Make working copy */ + + while (left >= 2) { + uint8_t ptag = p[0]; + size_t plen = p[1] + 2; + + if (ptag == ADV_END) + break; + + if (ptag == tag) { + /* Found our tag. Delete it. */ + + if (plen >= left) { + /* Entire remainder is our tag */ + break; + } + memmove(p, p + plen, left - plen); + } else { + /* Not our tag */ + if (plen > left) + break; /* Corrupt tag (overrun) - overwrite it */ + + left -= plen; + p += plen; + } + } + + /* Now (p, left) reflects the position to write in and how much space + we have for our data. */ + + if (size) { + if (left < size + 2) { + errno = ENOSPC; /* Not enough space for data */ + return -1; + } + + *p++ = (uint8_t) tag; + *p++ = (uint8_t) size; + memcpy(p, data, size); + p += size; + left -= size + 2; + } + + memset(p, 0, left); + + /* If we got here, everything went OK, commit the write */ + memcpy(syslinux_adv + 2 * 4, advtmp, ADV_LEN); + cleanup_adv(syslinux_adv); + + return 0; +} + +void syslinux_reset_adv(unsigned char *advbuf) +{ + /* Create an all-zero ADV */ + memset(advbuf + 2 * 4, 0, ADV_LEN); + cleanup_adv(advbuf); +} + +static int adv_consistent(const unsigned char *p) +{ + int i; + uint32_t csum; + + if (get_32((uint32_t *) p) != ADV_MAGIC1 || + get_32((uint32_t *) (p + ADV_SIZE - 4)) != ADV_MAGIC3) + return 0; + + csum = 0; + for (i = 4; i < ADV_SIZE - 4; i += 4) + csum += get_32((uint32_t *) (p + i)); + + return csum == ADV_MAGIC2; +} + +/* + * Verify that an in-memory ADV is consistent, making the copies consistent. + * If neither copy is OK, return -1 and call syslinux_reset_adv(). + */ +int syslinux_validate_adv(unsigned char *advbuf) +{ + if (adv_consistent(advbuf + 0 * ADV_SIZE)) { + memcpy(advbuf + ADV_SIZE, advbuf, ADV_SIZE); + return 0; + } else if (adv_consistent(advbuf + 1 * ADV_SIZE)) { + memcpy(advbuf, advbuf + ADV_SIZE, ADV_SIZE); + return 0; + } else { + syslinux_reset_adv(advbuf); + return -1; + } +} diff --git a/src/syslinux/libinstaller/setadv.h b/src/syslinux/libinstaller/setadv.h new file mode 100644 index 00000000..32bdfec1 --- /dev/null +++ b/src/syslinux/libinstaller/setadv.h @@ -0,0 +1,16 @@ +#ifndef _H_SET_ADV_ +#define _H_SET_ADV_ + +/* ADV information */ +#define ADV_SIZE 512 /* Total size */ +#define ADV_LEN (ADV_SIZE-3*4) /* Usable data size */ + +extern unsigned char syslinux_adv[2 * ADV_SIZE]; + +int syslinux_setadv(int tag, size_t size, const void *data); +void syslinux_reset_adv(unsigned char *advbuf); +int syslinux_validate_adv(unsigned char *advbuf); +int read_adv(const char *path, const char *cfg); +int write_adv(const char *path, const char *cfg); + +#endif diff --git a/src/syslinux/libinstaller/syslinux.h b/src/syslinux/libinstaller/syslinux.h new file mode 100644 index 00000000..39564ea7 --- /dev/null +++ b/src/syslinux/libinstaller/syslinux.h @@ -0,0 +1,55 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 1998-2008 H. Peter Anvin - All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 53 Temple Place Ste 330, + * Boston MA 02111-1307, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +#ifndef SYSLINUX_H +#define SYSLINUX_H + +#include +#include +#include "advconst.h" +#include "setadv.h" + +/* The standard boot sector and ldlinux image */ +extern unsigned char* syslinux_bootsect; +extern unsigned int syslinux_bootsect_len; +extern const int syslinux_bootsect_mtime; + +extern unsigned char* syslinux_ldlinux; +extern unsigned int syslinux_ldlinux_len; +extern const int syslinux_ldlinux_mtime; + +#define boot_sector syslinux_bootsect +#define boot_sector_len syslinux_bootsect_len +#define boot_image syslinux_ldlinux +#define boot_image_len syslinux_ldlinux_len + +extern unsigned char syslinux_mbr[]; +extern const unsigned int syslinux_mbr_len; +extern const int syslinux_mbr_mtime; + +/* Sector size assumptions... */ +#define SECTOR_SHIFT 9 +#define SECTOR_SIZE (1 << SECTOR_SHIFT) + +/* This takes a boot sector and merges in the syslinux fields */ +void syslinux_make_bootsect(void *); + +/* Check to see that what we got was indeed an MS-DOS boot sector/superblock */ +const char *syslinux_check_bootsect(const void *bs); + +/* This patches the boot sector and ldlinux.sys based on a sector map */ +typedef uint64_t sector_t; +int syslinux_patch(const sector_t *sectors, int nsectors, + int stupid, int raid_mode, + const char *subdir, const char *subvol); + +#endif diff --git a/src/syslinux/libinstaller/syslxint.h b/src/syslinux/libinstaller/syslxint.h new file mode 100644 index 00000000..749c74be --- /dev/null +++ b/src/syslinux/libinstaller/syslxint.h @@ -0,0 +1,261 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved + * Copyright 2009-2011 Intel Corporation; author: H. Peter Anvin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 53 Temple Place Ste 330, + * Boston MA 02111-1307, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +#ifndef SYSLXINT_H +#define SYSLXINT_H + +#include "syslinux.h" + +#if defined(__386__) || defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64) +# define X86_MEM 1 /* Littleendian and unaligned safe */ +#else +# define X86_MEM 0 +#endif + +/* + * Access functions for littleendian numbers, possibly misaligned. + */ +static inline uint8_t get_8(const uint8_t * p) +{ + return *p; +} + +static inline uint16_t get_16(const uint16_t * p) +{ +#if X86_MEM + /* Littleendian and unaligned-capable */ + return *p; +#else + const uint8_t *pp = (const uint8_t *)p; + return pp[0] + ((uint16_t)pp[1] << 8); +#endif +} + +static inline uint32_t get_32(const uint32_t * p) +{ +#if X86_MEM + /* Littleendian and unaligned-capable */ + return *p; +#else + const uint16_t *pp = (const uint16_t *)p; + return get_16(pp[0]) + (uint32_t)get_16(pp[1]); +#endif +} + +static inline uint64_t get_64(const uint64_t * p) +{ +#if X86_MEM + /* Littleendian and unaligned-capable */ + return *p; +#else + const uint32_t *pp = (const uint32_t *)p; + return get_32(pp[0]) + (uint64_t)get_32(pp[1]); +#endif +} + +static inline void set_8(uint8_t *p, uint8_t v) +{ + *p = v; +} + +static inline void set_16(uint16_t *p, uint16_t v) +{ +#if X86_MEM + /* Littleendian and unaligned-capable */ + *p = v; +#else + uint8_t *pp = (uint8_t *) p; + pp[0] = (v & 0xff); + pp[1] = ((v >> 8) & 0xff); +#endif +} + +static inline void set_32(uint32_t *p, uint32_t v) +{ +#if X86_MEM + /* Littleendian and unaligned-capable */ + *p = v; +#else + uint8_t *pp = (uint8_t *) p; + pp[0] = (v & 0xff); + pp[1] = ((v >> 8) & 0xff); + pp[2] = ((v >> 16) & 0xff); + pp[3] = ((v >> 24) & 0xff); +#endif +} + +static inline void set_64(uint64_t *p, uint64_t v) +{ +#if X86_MEM + /* Littleendian and unaligned-capable */ + *p = v; +#else + uint32_t *pp = (uint32_t *) p; + set_32(pp[0], v); + set_32(pp[1], v >> 32); +#endif +} + +/* + * Special handling for the MS-DOS derivative: syslinux_ldlinux + * is a "far" object... + */ +#ifdef __MSDOS__ + +static inline __attribute__ ((const)) +uint16_t ds(void) +{ + uint16_t v; + asm("movw %%ds,%0":"=rm"(v)); + return v; +} + +static inline void *set_fs(const void *p) +{ + uint16_t seg; + + seg = ds() + ((size_t) p >> 4); + asm volatile ("movw %0,%%fs"::"rm" (seg)); + return (void *)((size_t) p & 0xf); +} + +uint8_t get_8_sl(const uint8_t * p); +uint16_t get_16_sl(const uint16_t * p); +uint32_t get_32_sl(const uint32_t * p); +uint64_t get_64_sl(const uint64_t * p); +void set_8_sl(uint8_t * p, uint8_t v); +void set_16_sl(uint16_t * p, uint16_t v); +void set_32_sl(uint32_t * p, uint32_t v); +void set_64_sl(uint64_t * p, uint64_t v); +void memcpy_to_sl(void *dst, const void *src, size_t len); +void memcpy_from_sl(void *dst, const void *src, size_t len); + +#else + +/* Sane system ... */ +#define get_8_sl(x) get_8(x) +#define get_16_sl(x) get_16(x) +#define get_32_sl(x) get_32(x) +#define get_64_sl(x) get_64(x) +#define set_8_sl(x,y) set_8(x,y) +#define set_16_sl(x,y) set_16(x,y) +#define set_32_sl(x,y) set_32(x,y) +#define set_64_sl(x,y) set_64(x,y) +#define memcpy_to_sl(d,s,l) memcpy(d,s,l) +#define memcpy_from_sl(d,s,l) memcpy(d,s,l) + +#endif + +#define LDLINUX_MAGIC 0x3eb202fe +#define BS_MAGIC_VER (0x1b << 9) + +/* Patch area for disk-based installers */ +struct patch_area { + uint32_t magic; /* LDLINUX_MAGIC */ + uint32_t instance; /* Per-version value */ + uint16_t data_sectors; + uint16_t adv_sectors; + uint32_t dwords; + uint32_t checksum; + uint16_t maxtransfer; + uint16_t epaoffset; /* Pointer to the extended patch area */ +}; + +struct ext_patch_area { + uint16_t advptroffset; /* ADV pointers */ + uint16_t diroffset; /* Current directory field */ + uint16_t dirlen; /* Length of current directory field */ + uint16_t subvoloffset; /* Subvolume field */ + uint16_t subvollen; /* Length of subvolume field */ + uint16_t secptroffset; /* Sector extent pointers */ + uint16_t secptrcnt; /* Number of sector extent pointers */ + + uint16_t sect1ptr0; /* Boot sector offset of sector 1 ptr LSW */ + uint16_t sect1ptr1; /* Boot sector offset of sector 1 ptr MSW */ + uint16_t raidpatch; /* Boot sector RAID mode patch pointer */ +}; + +/* Sector extent */ +#pragma pack(push, 1) +struct syslinux_extent { + uint64_t lba; + uint16_t len; +}; + +/* FAT bootsector format, also used by other disk-based derivatives */ +struct boot_sector { + uint8_t bsJump[3]; + char bsOemName[8]; + uint16_t bsBytesPerSec; + uint8_t bsSecPerClust; + uint16_t bsResSectors; + uint8_t bsFATs; + uint16_t bsRootDirEnts; + uint16_t bsSectors; + uint8_t bsMedia; + uint16_t bsFATsecs; + uint16_t bsSecPerTrack; + uint16_t bsHeads; + uint32_t bsHiddenSecs; + uint32_t bsHugeSectors; + + union { + struct { + uint8_t DriveNumber; + uint8_t Reserved1; + uint8_t BootSignature; + uint32_t VolumeID; + char VolumeLabel[11]; + char FileSysType[8]; + uint8_t Code[442]; + } bs16; + struct { + uint32_t FATSz32; + uint16_t ExtFlags; + uint16_t FSVer; + uint32_t RootClus; + uint16_t FSInfo; + uint16_t BkBootSec; + uint8_t Reserved0[12]; + uint8_t DriveNumber; + uint8_t Reserved1; + uint8_t BootSignature; + uint32_t VolumeID; + char VolumeLabel[11]; + char FileSysType[8]; + uint8_t Code[414]; + } bs32; + }; + + uint32_t bsMagic; + uint16_t bsForwardPtr; + uint16_t bsSignature; +}; +#pragma pack(pop) + +#define bsHead bsJump +#define bsHeadLen offsetof(struct boot_sector, bsBytesPerSec) +#define bsCode bs32.Code /* The common safe choice */ +#define bsCodeLen (offsetof(struct boot_sector, bsSignature) - \ + offsetof(struct boot_sector, bsCode)) + +static inline int fat_check_sb_fields(const struct boot_sector *sb) +{ + return sb->bsResSectors && sb->bsFATs && + (!memcmp(sb->bs16.FileSysType, "FAT12 ", 8) || + !memcmp(sb->bs16.FileSysType, "FAT16 ", 8) || + !memcmp(sb->bs16.FileSysType, "FAT ", 8) || + !memcmp(sb->bs32.FileSysType, "FAT32 ", 8)); +} + +#endif /* SYSLXINT_H */ diff --git a/src/syslinux/libinstaller/syslxmod.c b/src/syslinux/libinstaller/syslxmod.c new file mode 100644 index 00000000..035fa97c --- /dev/null +++ b/src/syslinux/libinstaller/syslxmod.c @@ -0,0 +1,201 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 1998-2008 H. Peter Anvin - All Rights Reserved + * Copyright 2009-2010 Intel Corporation; author H. Peter Anvin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 53 Temple Place Ste 330, + * Boston MA 02111-1307, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * syslxmod.c - Code to provide a SYSLINUX code set to an installer. + */ + +#define _XOPEN_SOURCE 500 /* Required on glibc 2.x */ +#define _BSD_SOURCE +#include +#include +#include +#include +#include + +#include "syslinux.h" +#include "syslxint.h" + + +/* + * Generate sector extents + */ +static void generate_extents(struct syslinux_extent *ex, int nptrs, + const sector_t *sectp, int nsect) +{ + uint32_t addr = 0x8000; /* ldlinux.sys starts loading here */ + uint32_t base; + sector_t sect, lba; + unsigned int len; + + base = addr; + len = 0; + lba = 0; + + memset(ex, 0, nptrs * sizeof *ex); + + while (nsect) { + sect = *sectp++; + + if (len) { + uint32_t xbytes = (len + 1) * SECTOR_SIZE; + + if (sect == lba + len && xbytes < 65536 && + ((addr ^ (base + xbytes - 1)) & 0xffff0000) == 0) { + /* We can add to the current extent */ + len++; + goto next; + } + + set_64_sl(&ex->lba, lba); + set_16_sl(&ex->len, (uint16_t) len); + ex++; + } + + base = addr; + lba = sect; + len = 1; + + next: + addr += SECTOR_SIZE; + nsect--; + } + + if (len) { + set_64_sl(&ex->lba, lba); + set_16_sl(&ex->len, (uint16_t) len); + ex++; + } +} + +/* + * Form a pointer based on a 16-bit patcharea/epa field + */ +static inline void *ptr(void *img, uint16_t *offset_p) +{ + return (char *)img + get_16_sl(offset_p); +} + +/* + * This patches the boot sector and the beginning of ldlinux.sys + * based on an ldlinux.sys sector map passed in. Typically this is + * handled by writing ldlinux.sys, mapping it, and then overwrite it + * with the patched version. If this isn't safe to do because of + * an OS which does block reallocation, then overwrite it with + * direct access since the location is known. + * + * Returns the number of modified bytes in ldlinux.sys if successful, + * otherwise -1. + */ +#define NADV 2 + +int syslinux_patch(const sector_t *sectp, int nsectors, + int stupid, int raid_mode, + const char *subdir, const char *subvol) +{ + struct patch_area *patcharea; + struct ext_patch_area *epa; + struct syslinux_extent *ex; + uint32_t *wp; + int nsect = ((boot_image_len + SECTOR_SIZE - 1) >> SECTOR_SHIFT) + 2; + uint32_t csum; + int i, dw, nptrs; + struct boot_sector *sbs = (struct boot_sector *)boot_sector; + uint64_t *advptrs; + + if (nsectors < nsect) + return -1; /* The actual file is too small for content */ + + /* Search for LDLINUX_MAGIC to find the patch area */ + for (wp = (uint32_t *)boot_image; get_32_sl(wp) != LDLINUX_MAGIC; + wp++) + ; + patcharea = (struct patch_area *)wp; + epa = ptr(boot_image, &patcharea->epaoffset); + + /* First sector need pointer in boot sector */ + set_32(ptr(sbs, &epa->sect1ptr0), (uint32_t) sectp[0]); + set_32(ptr(sbs, &epa->sect1ptr1), (uint32_t) (sectp[0] >> 32)); + sectp++; + + /* Handle RAID mode */ + if (raid_mode) { + /* Patch in INT 18h = CD 18 */ + set_16(ptr(sbs, &epa->raidpatch), 0x18CD); + } + + /* Set up the totals */ + dw = boot_image_len >> 2; /* COMPLETE dwords, excluding ADV */ + set_16_sl(&patcharea->data_sectors, nsect - 2); /* Not including ADVs */ + set_16_sl(&patcharea->adv_sectors, 2); /* ADVs need 2 sectors */ + set_32_sl(&patcharea->dwords, dw); + + /* Handle Stupid mode */ + if (stupid) { + /* Access only one sector at a time */ + set_16_sl(&patcharea->maxtransfer, 1); + } + + /* Set the sector extents */ + ex = ptr(boot_image, &epa->secptroffset); + nptrs = get_16_sl(&epa->secptrcnt); + + if (nsect > nptrs) { + /* Not necessarily an error in this case, but a general problem */ + fprintf(stderr, "Insufficient extent space, build error!\n"); + exit(1); + } + + /* -1 for the pointer in the boot sector, -2 for the two ADVs */ + generate_extents(ex, nptrs, sectp, nsect-1-2); + + /* ADV pointers */ + advptrs = ptr(boot_image, &epa->advptroffset); + set_64_sl(&advptrs[0], sectp[nsect-1-2]); + set_64_sl(&advptrs[1], sectp[nsect-1-1]); + + /* Poke in the base directory path */ + if (subdir) { + int sublen = (int) (strlen(subdir) + 1); + if (get_16_sl(&epa->dirlen) < sublen) { + fprintf(stderr, "Subdirectory path too long... aborting install!\n"); + exit(1); + } + memcpy_to_sl(ptr(boot_image, &epa->diroffset), subdir, sublen); + } + + /* Poke in the subvolume information */ + if (subvol) { + int sublen = (int) (strlen(subvol) + 1); + if (get_16_sl(&epa->subvollen) < sublen) { + fprintf(stderr, "Subvol name too long... aborting install!\n"); + exit(1); + } + memcpy_to_sl(ptr(boot_image, &epa->subvoloffset), subvol, sublen); + } + + /* Now produce a checksum */ + set_32_sl(&patcharea->checksum, 0); + + csum = LDLINUX_MAGIC; + for (i = 0, wp = (uint32_t *)boot_image; i < dw; i++, wp++) + csum -= get_32_sl(wp); /* Negative checksum */ + + set_32_sl(&patcharea->checksum, csum); + + /* + * Assume all bytes modified. This can be optimized at the expense + * of keeping track of what the highest modified address ever was. + */ + return dw << 2; +} diff --git a/src/syslinux/sltypes.h b/src/syslinux/sltypes.h new file mode 100644 index 00000000..ed9a829f --- /dev/null +++ b/src/syslinux/sltypes.h @@ -0,0 +1,26 @@ +#ifndef _MSC_VER +#error This header should only be used with Microsoft compilers +#endif + +/* The addons below are not part of inttypes but required for syslinux */ + +#ifndef _SLTYPES_H_ +#define _SLTYPES_H_ + +/* On MS environments, the inline keyword is available in C++ only */ +#ifndef inline +#define inline __inline +#endif + +/* ssize_t is also not available (copy/paste from MinGW) */ +#ifndef _SSIZE_T_DEFINED +#define _SSIZE_T_DEFINED +#undef ssize_t +#ifdef _WIN64 + typedef __int64 ssize_t; +#else + typedef int ssize_t; +#endif /* _WIN64 */ +#endif /* _SSIZE_T_DEFINED */ + +#endif \ No newline at end of file diff --git a/src/syslinux/stdint.h b/src/syslinux/stdint.h new file mode 100644 index 00000000..7e0746f8 --- /dev/null +++ b/src/syslinux/stdint.h @@ -0,0 +1,262 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file was originally part of the w64 mingw-runtime package. + */ + +/* ISO C9x 7.18 Integer types + * Based on ISO/IEC SC22/WG14 9899 Committee draft (SC22 N2794) + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * Contributor: Danny Smith + * Modified for libusb/MSVC: Pete Batard + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAIMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Date: 2010-04-02 + */ + +#ifndef _MSC_VER +#error This header should only be used with Microsoft compilers +#endif + +#ifndef _STDINT_H +#define _STDINT_H + +#ifndef _INTPTR_T_DEFINED +#define _INTPTR_T_DEFINED +#ifndef __intptr_t_defined +#define __intptr_t_defined +#undef intptr_t +#ifdef _WIN64 + typedef __int64 intptr_t; +#else + typedef int intptr_t; +#endif /* _WIN64 */ +#endif /* __intptr_t_defined */ +#endif /* _INTPTR_T_DEFINED */ + +#ifndef _UINTPTR_T_DEFINED +#define _UINTPTR_T_DEFINED +#ifndef __uintptr_t_defined +#define __uintptr_t_defined +#undef uintptr_t +#ifdef _WIN64 + typedef unsigned __int64 uintptr_t; +#else + typedef unsigned int uintptr_t; +#endif /* _WIN64 */ +#endif /* __uintptr_t_defined */ +#endif /* _UINTPTR_T_DEFINED */ + +#ifndef _PTRDIFF_T_DEFINED +#define _PTRDIFF_T_DEFINED +#ifndef _PTRDIFF_T_ +#define _PTRDIFF_T_ +#undef ptrdiff_t +#ifdef _WIN64 + typedef __int64 ptrdiff_t; +#else + typedef int ptrdiff_t; +#endif /* _WIN64 */ +#endif /* _PTRDIFF_T_ */ +#endif /* _PTRDIFF_T_DEFINED */ + +#ifndef _WCHAR_T_DEFINED +#define _WCHAR_T_DEFINED +#ifndef __cplusplus + typedef unsigned short wchar_t; +#endif /* C++ */ +#endif /* _WCHAR_T_DEFINED */ + +#ifndef _WCTYPE_T_DEFINED +#define _WCTYPE_T_DEFINED +#ifndef _WINT_T +#define _WINT_T + typedef unsigned short wint_t; + typedef unsigned short wctype_t; +#endif /* _WINT_T */ +#endif /* _WCTYPE_T_DEFINED */ + +/* 7.18.1.1 Exact-width integer types */ +typedef __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; + +/* 7.18.1.2 Minimum-width integer types */ +typedef signed char int_least8_t; +typedef unsigned char uint_least8_t; +typedef short int_least16_t; +typedef unsigned short uint_least16_t; +typedef int int_least32_t; +typedef unsigned uint_least32_t; +typedef __int64 int_least64_t; +typedef unsigned __int64 uint_least64_t; + +/* 7.18.1.3 Fastest minimum-width integer types + * Not actually guaranteed to be fastest for all purposes + * Here we use the exact-width types for 8 and 16-bit ints. + */ +typedef __int8 int_fast8_t; +typedef unsigned __int8 uint_fast8_t; +typedef __int16 int_fast16_t; +typedef unsigned __int16 uint_fast16_t; +typedef __int32 int_fast32_t; +typedef unsigned __int32 uint_fast32_t; +typedef __int64 int_fast64_t; +typedef unsigned __int64 uint_fast64_t; + +/* 7.18.1.5 Greatest-width integer types */ +typedef __int64 intmax_t; +typedef unsigned __int64 uintmax_t; + +/* 7.18.2 Limits of specified-width integer types */ +#if !defined ( __cplusplus) || defined (__STDC_LIMIT_MACROS) + +/* 7.18.2.1 Limits of exact-width integer types */ +#define INT8_MIN (-128) +#define INT16_MIN (-32768) +#define INT32_MIN (-2147483647 - 1) +#define INT64_MIN (-9223372036854775807LL - 1) + +#define INT8_MAX 127 +#define INT16_MAX 32767 +#define INT32_MAX 2147483647 +#define INT64_MAX 9223372036854775807LL + +#define UINT8_MAX 255 +#define UINT16_MAX 65535 +#define UINT32_MAX 0xffffffffU /* 4294967295U */ +#define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */ + +/* 7.18.2.2 Limits of minimum-width integer types */ +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST64_MIN INT64_MIN + +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MAX INT64_MAX + +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +/* 7.18.2.3 Limits of fastest minimum-width integer types */ +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST64_MIN INT64_MIN + +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MAX INT16_MAX +#define INT_FAST32_MAX INT32_MAX +#define INT_FAST64_MAX INT64_MAX + +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX UINT16_MAX +#define UINT_FAST32_MAX UINT32_MAX +#define UINT_FAST64_MAX UINT64_MAX + +/* 7.18.2.4 Limits of integer types capable of holding + object pointers */ +#ifdef _WIN64 +#define INTPTR_MIN INT64_MIN +#define INTPTR_MAX INT64_MAX +#define UINTPTR_MAX UINT64_MAX +#else +#define INTPTR_MIN INT32_MIN +#define INTPTR_MAX INT32_MAX +#define UINTPTR_MAX UINT32_MAX +#endif + +/* 7.18.2.5 Limits of greatest-width integer types */ +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX + +/* 7.18.3 Limits of other integer types */ +#ifdef _WIN64 +#define PTRDIFF_MIN INT64_MIN +#define PTRDIFF_MAX INT64_MAX +#else +#define PTRDIFF_MIN INT32_MIN +#define PTRDIFF_MAX INT32_MAX +#endif + +#define SIG_ATOMIC_MIN INT32_MIN +#define SIG_ATOMIC_MAX INT32_MAX + +#ifndef SIZE_MAX +#ifdef _WIN64 +#define SIZE_MAX UINT64_MAX +#else +#define SIZE_MAX UINT32_MAX +#endif +#endif + +#ifndef WCHAR_MIN /* also in wchar.h */ +#define WCHAR_MIN 0U +#define WCHAR_MAX 0xffffU +#endif + +/* + * wint_t is unsigned short for compatibility with MS runtime + */ +#define WINT_MIN 0U +#define WINT_MAX 0xffffU + +#endif /* !defined ( __cplusplus) || defined __STDC_LIMIT_MACROS */ + + +/* 7.18.4 Macros for integer constants */ +#if !defined ( __cplusplus) || defined (__STDC_CONSTANT_MACROS) + +/* 7.18.4.1 Macros for minimum-width integer constants + + Accoding to Douglas Gwyn : + "This spec was changed in ISO/IEC 9899:1999 TC1; in ISO/IEC + 9899:1999 as initially published, the expansion was required + to be an integer constant of precisely matching type, which + is impossible to accomplish for the shorter types on most + platforms, because C99 provides no standard way to designate + an integer constant with width less than that of type int. + TC1 changed this to require just an integer constant + *expression* with *promoted* type." + + The trick used here is from Clive D W Feather. +*/ + +#define INT8_C(val) (INT_LEAST8_MAX-INT_LEAST8_MAX+(val)) +#define INT16_C(val) (INT_LEAST16_MAX-INT_LEAST16_MAX+(val)) +#define INT32_C(val) (INT_LEAST32_MAX-INT_LEAST32_MAX+(val)) +/* The 'trick' doesn't work in C89 for long long because, without + suffix, (val) will be evaluated as int, not intmax_t */ +#define INT64_C(val) val##i64 + +#define UINT8_C(val) (val) +#define UINT16_C(val) (val) +#define UINT32_C(val) (val##i32) +#define UINT64_C(val) val##ui64 + +/* 7.18.4.2 Macros for greatest-width integer constants */ +#define INTMAX_C(val) val##i64 +#define UINTMAX_C(val) val##ui64 + +#endif /* !defined ( __cplusplus) || defined __STDC_CONSTANT_MACROS */ + +#endif diff --git a/wdk_build.cmd b/wdk_build.cmd index d83732c8..ba1fc0fc 100644 --- a/wdk_build.cmd +++ b/wdk_build.cmd @@ -25,8 +25,38 @@ copy obj%BUILD_ALT_DIR%\%ARCH_DIR%\ms-sys.lib . >NUL 2>&1 if EXIST Makefile.hide ren Makefile.hide Makefile if EXIST sources del sources >NUL 2>&1 +::# SysLinux libfat Library +cd ..\syslinux\libfat +if EXIST Makefile ren Makefile Makefile.hide + +copy .msvc\libfat_sources sources >NUL 2>&1 + +@echo on +%BUILD_CMD% +@echo off +if errorlevel 1 goto builderror +copy obj%BUILD_ALT_DIR%\%ARCH_DIR%\libfat.lib . >NUL 2>&1 + +if EXIST Makefile.hide ren Makefile.hide Makefile +if EXIST sources del sources >NUL 2>&1 + +::# SysLinux libinstaller Library +cd ..\libinstaller +if EXIST Makefile ren Makefile Makefile.hide + +copy .msvc\libinstaller_sources sources >NUL 2>&1 + +@echo on +%BUILD_CMD% +@echo off +if errorlevel 1 goto builderror +copy obj%BUILD_ALT_DIR%\%ARCH_DIR%\libinstaller.lib . >NUL 2>&1 + +if EXIST Makefile.hide ren Makefile.hide Makefile +if EXIST sources del sources >NUL 2>&1 + ::# Rufus Application -cd .. +cd ..\.. if EXIST Makefile ren Makefile Makefile.hide copy .msvc\rufus_sources sources >NUL 2>&1