[misc] update to VS2015 and fix VS code analysis issues

* Also update Bled to latest, as well as build scripts
* Note: Considering that Visual Studio 2015 is both freely and legally
  available for anyone who wants to use it to compile Rufus, starting
  with this commit, I will NOT be supporting any other version of Visual
  Studio but 2015.
This commit is contained in:
Pete Batard 2015-08-10 23:19:57 +01:00
parent b854f70bae
commit 5004374277
37 changed files with 199 additions and 141 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@ -81,27 +81,27 @@
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">

View file

@ -174,10 +174,10 @@ int is_zero_mbr(FILE *fp)
static int write_bootmark(FILE *fp)
{
unsigned char aucRef[] = {0x55, 0xAA};
int pos = 0x1FE;
uint32_t pos = 0x1FE;
FAKE_FD* fd = (FAKE_FD*)fp;
/* We use fp->_bufsiz as our sector size indicator */
for (pos = 0x1FE; pos < fp->_bufsiz; pos += 0x200) {
for (pos = 0x1FE; pos < fd->_sector_size; pos += 0x200) {
if (!write_data(fp, pos, aucRef, sizeof(aucRef)))
return 0;
}

View file

@ -89,19 +89,20 @@ int64_t read_sectors(HANDLE hDrive, uint64_t SectorSize,
}
/*
* The following calls use a bastardized fp on Windows that contains:
* fp->_ptr: a Windows handle
* fp->_bufsiz: the sector size
* fp->_cnt: a file offset
* The following calls use a hijacked fp on Windows that contains:
* fp->_handle: a Windows handle
* fp->_sector_size: the sector size
* fp->_offset: a file offset
*/
int contains_data(FILE *fp, uint64_t Position,
const void *pData, uint64_t Len)
{
unsigned char aucBuf[MAX_DATA_LEN];
HANDLE hDrive = (HANDLE)fp->_ptr;
uint64_t SectorSize = (uint64_t)fp->_bufsiz;
FAKE_FD* fd = (FAKE_FD*)fp;
HANDLE hDrive = (HANDLE)fd->_handle;
uint64_t SectorSize = (uint64_t)fd->_sector_size;
uint64_t StartSector, EndSector, NumSectors;
Position += (uint64_t)fp->_cnt;
Position += fd->_offset;
StartSector = Position/SectorSize;
EndSector = (Position+Len+SectorSize-1)/SectorSize;
@ -133,10 +134,11 @@ int write_data(FILE *fp, uint64_t Position,
const void *pData, uint64_t Len)
{
unsigned char aucBuf[MAX_DATA_LEN];
HANDLE hDrive = (HANDLE)fp->_ptr;
uint64_t SectorSize = (uint64_t)fp->_bufsiz;
FAKE_FD* fd = (FAKE_FD*)fp;
HANDLE hDrive = (HANDLE)fd->_handle;
uint64_t SectorSize = (uint64_t)fd->_sector_size;
uint64_t StartSector, EndSector, NumSectors;
Position += (uint64_t)fp->_cnt;
Position += fd->_offset;
StartSector = Position/SectorSize;
EndSector = (Position+Len+SectorSize-1)/SectorSize;

View file

@ -6,6 +6,13 @@
/* Max valid value of uiLen for contains_data */
#define MAX_DATA_LEN 32768
/* We hijack the FILE structure for our own needs */
typedef struct {
void *_handle;
uint64_t _offset;
uint32_t _sector_size;
} FAKE_FD;
/* Checks if a file contains a data pattern of length Len at position
Position. The file pointer will change when calling this function! */
int contains_data(FILE *fp, uint64_t Position,