aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLadislav <Zezula>2013-07-24 23:28:59 +0200
committerLadislav <Zezula>2013-07-24 23:28:59 +0200
commita3fba332ce93a3453441b2b8e6f43c0793602bb5 (patch)
tree4084297a682160e3f22501199c7d4a86a2bc10a8
parent43033709ea78369d0fe86d1a014e0743ce8bd33b (diff)
+ Lower Windows permissions are now needed for opening MPQ for read-only
-rw-r--r--src/FileStream.cpp8
-rw-r--r--test/Test.cpp2
2 files changed, 5 insertions, 5 deletions
diff --git a/src/FileStream.cpp b/src/FileStream.cpp
index 4310924..90bd176 100644
--- a/src/FileStream.cpp
+++ b/src/FileStream.cpp
@@ -465,13 +465,13 @@ static bool BaseFile_Open(
#ifdef PLATFORM_WINDOWS
{
ULARGE_INTEGER FileSize;
- DWORD dwDesiredAccess = (dwStreamFlags & STREAM_FLAG_READ_ONLY) ? GENERIC_READ : GENERIC_ALL;
+ DWORD dwWriteAccess = (dwStreamFlags & STREAM_FLAG_READ_ONLY) ? 0 : GENERIC_ALL;
DWORD dwWriteShare = (dwStreamFlags & STREAM_FLAG_WRITE_SHARE) ? FILE_SHARE_WRITE : 0;
// Open the file
pStream->Base.File.hFile = CreateFile(szFileName,
- dwDesiredAccess,
- dwWriteShare | FILE_SHARE_READ,
+ FILE_READ_DATA | dwWriteAccess,
+ FILE_SHARE_READ | dwWriteShare,
NULL,
OPEN_EXISTING,
0,
@@ -610,7 +610,7 @@ static bool BaseMap_Open(
bool bResult = false;
// Open the file for read access
- hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
+ hFile = CreateFile(szFileName, FILE_READ_DATA, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if(hFile != NULL)
{
// Retrieve file size. Don't allow mapping file of a zero size.
diff --git a/test/Test.cpp b/test/Test.cpp
index 20b225f..c3960db 100644
--- a/test/Test.cpp
+++ b/test/Test.cpp
@@ -1148,7 +1148,7 @@ static int TestArchiveOpenAndClose(const TCHAR * szMpqName)
if(nError == ERROR_SUCCESS)
{
_tprintf(_T("Opening archive %s ...\n"), szMpqName);
- if(!SFileOpenArchive(szMpqName, 0, STREAM_PROVIDER_PARTIAL | BASE_PROVIDER_FILE, &hMpq))
+ if(!SFileOpenArchive(szMpqName, 0, STREAM_FLAG_READ_ONLY | BASE_PROVIDER_MAP, &hMpq))
nError = GetLastError();
ha = (TMPQArchive *)hMpq;
}