windows fixes

This commit is contained in:
Mathias Panzenböck 2013-01-05 01:32:21 +01:00
parent b281f3ac46
commit fb21805099
2 changed files with 11 additions and 5 deletions

View File

@ -32,14 +32,14 @@ BIN=$(BUILDDIR)/$(APPNAME)
ifeq ($(TARGET),win32)
PLATFORM=windows
CC=i686-pc-mingw32-gcc
CFLAGS=$(COMMON_CFLAGS) -m32
CFLAGS=$(COMMON_CFLAGS) -m32 -DWINVER=0x500
LIBS=-lws2_32 -liberty
APPNAME=audioextract.exe
else
ifeq ($(TARGET),win64)
PLATFORM=windows
CC=x86_64-w64-mingw32-gcc
CFLAGS=$(COMMON_CFLAGS) -m64
CFLAGS=$(COMMON_CFLAGS) -m64 -DWINVER=0x500
LIBS=-lws2_32 -liberty
APPNAME=audioextract64.exe
endif

View File

@ -56,8 +56,7 @@ int extract(const struct extract_options *options, size_t *numfilesptr)
goto error;
}
filesize.LowPart = GetFileSize(hFile, (LPDWORD)&(filesize.HighPart));
if (filesize.LowPart == INVALID_FILE_SIZE)
if (!GetFileSizeEx(hFile, &filesize))
{
PrintError(options->filepath);
goto error;
@ -68,6 +67,13 @@ int extract(const struct extract_options *options, size_t *numfilesptr)
printf("%s: Skipping empty file.\n", options->filepath);
goto cleanup;
}
else if (filesize.QuadPart < 0)
{
fprintf(stderr, "%s: File has negative size (%"PRIi64")?\n",
options->filepath,
filesize.QuadPart);
goto error;
}
else if ((uint64_t)filesize.QuadPart <= options->offset)
{
printf("%s: Skipping file because offset is bigger than file.\n",
@ -93,7 +99,7 @@ int extract(const struct extract_options *options, size_t *numfilesptr)
goto error;
}
if (do_extract(filedata, filesize.QuadPart, options, numfilesptr))
if (do_extract(filedata, length, options, numfilesptr))
{
goto cleanup;
}