Current News
Archived News
Search News
Discussion Forum


Old Forum
Install Programs More Downloads...
Troubleshooting
Source Code
Format Specs.
Misc. Information
Non-SF Stuff
Links




ShadowFlare [Sat, 22 Aug 2009 07:51:17 +0000 (01:51 -0600)]
- No longer attempts to write a larger header than this library supports if the archive says it is larger.
- Various additional optimizations are now enabled in the Visual C++ 2008 DLL project.

SFmpqapi.cpp
SFmpqapi.vcproj

index 55f9fb8..c9a7322 100644 (file)
@@ -2036,7 +2036,7 @@ BOOL SFMPQAPI WINAPI MpqAddFileToArchiveEx(MPQHANDLE hMPQ, LPCSTR lpSourceFileNa
        mpqOpenArc->lpBlockTable[BlockIndex].dwFlags = dwFlags|MAFA_EXISTS;
        DWORD dwFileOffset = mpqOpenArc->lpBlockTable[BlockIndex].dwFileOffset;
        SetFilePointer(mpqOpenArc->hFile,mpqOpenArc->dwMPQStart,0,FILE_BEGIN);
-       WriteFile(mpqOpenArc->hFile,&mpqOpenArc->MpqHeader,mpqOpenArc->MpqHeader.dwHeaderSize,&tsz,0);
+       WriteFile(mpqOpenArc->hFile,&mpqOpenArc->MpqHeader,sizeof(MPQHEADER),&tsz,0);
        if (dwFlags & MAFA_ENCRYPT) {
                DWORD dwCryptKey;
                if (dwFlags&MAFA_ENCRYPT) dwCryptKey = HashString(lpDestFileName,HASH_KEY);
@@ -2381,7 +2381,7 @@ BOOL SFMPQAPI WINAPI MpqAddFileFromBufferEx(MPQHANDLE hMPQ, LPVOID lpBuffer, DWO
        mpqOpenArc->lpBlockTable[BlockIndex].dwFlags = dwFlags|MAFA_EXISTS;
        DWORD dwFileOffset = mpqOpenArc->lpBlockTable[BlockIndex].dwFileOffset;
        SetFilePointer(mpqOpenArc->hFile,mpqOpenArc->dwMPQStart,0,FILE_BEGIN);
-       WriteFile(mpqOpenArc->hFile,&mpqOpenArc->MpqHeader,mpqOpenArc->MpqHeader.dwHeaderSize,&tsz,0);
+       WriteFile(mpqOpenArc->hFile,&mpqOpenArc->MpqHeader,sizeof(MPQHEADER),&tsz,0);
        if (dwFlags & MAFA_ENCRYPT) {
                DWORD dwCryptKey;
                if (dwFlags&MAFA_ENCRYPT) dwCryptKey = HashString(lpFileName,HASH_KEY);
@@ -2675,7 +2675,7 @@ BOOL SFMPQAPI WINAPI MpqCompactArchive(MPQHANDLE hMPQ)
                }
                if (i==10000) return FALSE;
        }
-       DWORD dwLastOffset = mpqOpenArc->MpqHeader.dwHeaderSize,tsz;
+       DWORD dwLastOffset = sizeof(MPQHEADER),tsz;
        char *buffer = (char *)SFAlloc(65536);
        if (buffer==0) {
                CloseHandle(hFile);
@@ -3020,8 +3020,9 @@ BOOL SFMPQAPI WINAPI MpqCompactArchive(MPQHANDLE hMPQ)
        SetFilePointer(mpqOpenArc->hFile,mpqOpenArc->dwMPQStart+dwLastOffset,0,FILE_BEGIN);
        SetEndOfFile(mpqOpenArc->hFile);
        SetFilePointer(mpqOpenArc->hFile,mpqOpenArc->dwMPQStart,0,FILE_BEGIN);
+       mpqOpenArc->MpqHeader.dwHeaderSize = sizeof(MPQHEADER);
        WriteFile(mpqOpenArc->hFile,&mpqOpenArc->MpqHeader,sizeof(MPQHEADER),&tsz,0);
-       dwLastOffset = mpqOpenArc->MpqHeader.dwHeaderSize;
+       dwLastOffset = sizeof(MPQHEADER);
        ReadSize = 65536;
        for (i=dwLastOffset;i<mpqOpenArc->MpqHeader.dwHashTableOffset;i+=65536) {
                SetFilePointer(mpqOpenArc->hFile,mpqOpenArc->dwMPQStart+i,0,FILE_BEGIN);
index f2a42f8..aedff70 100644 (file)
@@ -4,6 +4,7 @@
        Version="9.00"
        Name="SFmpqapi"
        ProjectGUID="{D677FDD7-F14A-403F-8D59-C75D1825260C}"
+       RootNamespace="SFmpqapi"
        TargetFrameworkVersion="0"
        >
        <Platforms>
@@ -23,6 +24,7 @@
                        UseOfMFC="0"
                        ATLMinimizesCRunTimeLibraryUsage="false"
                        CharacterSet="2"
+                       WholeProgramOptimization="1"
                        >
                        <Tool
                                Name="VCPreBuildEventTool"
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="2"
-                               InlineFunctionExpansion="1"
+                               InlineFunctionExpansion="0"
+                               FavorSizeOrSpeed="1"
                                PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SFMPQAPI_EXPORTS;ZLIB_DLL;BETA"
                                StringPooling="true"
                                RuntimeLibrary="0"
-                               EnableFunctionLevelLinking="true"
+                               EnableFunctionLevelLinking="false"
                                PrecompiledHeaderFile=".\Release/SFmpqapi.pch"
                                AssemblerListingLocation=".\Release/"
                                ObjectFile=".\Release/"
@@ -78,7 +81,7 @@
                                SuppressStartupBanner="true"
                                ModuleDefinitionFile=".\SFmpqapi.def"
                                ProgramDatabaseFile=".\Release/SFmpq.pdb"
-                               RandomizedBaseAddress="1"
+                               RandomizedBaseAddress="0"
                                DataExecutionPrevention="0"
                                ImportLibrary=".\Release/SFmpq.lib"
                                TargetMachine="1"
                        UseOfMFC="0"
                        ATLMinimizesCRunTimeLibraryUsage="false"
                        CharacterSet="2"
+                       WholeProgramOptimization="1"
                        >
                        <Tool
                                Name="VCPreBuildEventTool"
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="2"
-                               InlineFunctionExpansion="1"
+                               InlineFunctionExpansion="0"
+                               FavorSizeOrSpeed="1"
                                PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SFMPQAPI_EXPORTS;ZLIB_DLL"
                                StringPooling="true"
                                RuntimeLibrary="0"
-                               EnableFunctionLevelLinking="true"
+                               EnableFunctionLevelLinking="false"
                                PrecompiledHeaderFile=".\Release/SFmpqapi.pch"
                                AssemblerListingLocation=".\Release/"
                                ObjectFile=".\Release/"
                                SuppressStartupBanner="true"
                                ModuleDefinitionFile=".\SFmpqapi.def"
                                ProgramDatabaseFile=".\Release/SFmpq.pdb"
-                               RandomizedBaseAddress="1"
+                               RandomizedBaseAddress="0"
                                DataExecutionPrevention="0"
                                ImportLibrary=".\Release/SFmpq.lib"
                                TargetMachine="1"