aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--StormLib.xcodeproj/project.pbxproj102
-rw-r--r--src/SBaseFileTable.cpp11
-rw-r--r--src/SFilePatchArchives.cpp138
-rw-r--r--src/StormLib.h1
-rw-r--r--stormlib_dll/StormLib.def3
-rw-r--r--test/StormTest.cpp43
7 files changed, 214 insertions, 88 deletions
diff --git a/.gitignore b/.gitignore
index 5ebd21a..3d764df 100644
--- a/.gitignore
+++ b/.gitignore
@@ -62,6 +62,8 @@ local.properties
*.vspscc
.builds
*.dotCover
+*.o
+*.dylib
## TODO: If you have NuGet Package Restore enabled, uncomment this
#packages/
@@ -161,3 +163,5 @@ pip-log.txt
# Mac crap
.DS_Store
+**/project.xcworkspace
+**/xcuserdata
diff --git a/StormLib.xcodeproj/project.pbxproj b/StormLib.xcodeproj/project.pbxproj
index 2cf44e7..cc77a68 100644
--- a/StormLib.xcodeproj/project.pbxproj
+++ b/StormLib.xcodeproj/project.pbxproj
@@ -487,6 +487,40 @@
22EC6045154B28A000679228 /* FileStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 22EC6043154B28A000679228 /* FileStream.h */; };
22F5A9C51193DFBA00F8B121 /* SFileVerify.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 22F5A9C41193DFBA00F8B121 /* SFileVerify.cpp */; };
22F5A9C61193DFBA00F8B121 /* SFileVerify.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 22F5A9C41193DFBA00F8B121 /* SFileVerify.cpp */; };
+ E60816D61B707A9000B283F7 /* rsa_sign_hash.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816D51B707A9000B283F7 /* rsa_sign_hash.c */; };
+ E60816D71B707A9B00B283F7 /* rsa_sign_hash.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816D51B707A9000B283F7 /* rsa_sign_hash.c */; };
+ E60816D91B707B1800B283F7 /* pkcs_1_pss_encode.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816D81B707B1800B283F7 /* pkcs_1_pss_encode.c */; };
+ E60816DA1B707B1800B283F7 /* pkcs_1_pss_encode.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816D81B707B1800B283F7 /* pkcs_1_pss_encode.c */; };
+ E60816DC1B707B2700B283F7 /* pkcs_1_v1_5_encode.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816DB1B707B2700B283F7 /* pkcs_1_v1_5_encode.c */; };
+ E60816DD1B707B2700B283F7 /* pkcs_1_v1_5_encode.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816DB1B707B2700B283F7 /* pkcs_1_v1_5_encode.c */; };
+ E60816DF1B707B5700B283F7 /* der_encode_sequence_ex.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816DE1B707B5700B283F7 /* der_encode_sequence_ex.c */; };
+ E60816E01B707B5700B283F7 /* der_encode_sequence_ex.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816DE1B707B5700B283F7 /* der_encode_sequence_ex.c */; };
+ E60816EE1B707B7200B283F7 /* der_encode_bit_string.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816E11B707B7200B283F7 /* der_encode_bit_string.c */; };
+ E60816EF1B707B7200B283F7 /* der_encode_bit_string.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816E11B707B7200B283F7 /* der_encode_bit_string.c */; };
+ E60816F01B707B7200B283F7 /* der_encode_boolean.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816E21B707B7200B283F7 /* der_encode_boolean.c */; };
+ E60816F11B707B7200B283F7 /* der_encode_boolean.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816E21B707B7200B283F7 /* der_encode_boolean.c */; };
+ E60816F21B707B7200B283F7 /* der_encode_ia5_string.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816E31B707B7200B283F7 /* der_encode_ia5_string.c */; };
+ E60816F31B707B7200B283F7 /* der_encode_ia5_string.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816E31B707B7200B283F7 /* der_encode_ia5_string.c */; };
+ E60816F41B707B7200B283F7 /* der_encode_integer.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816E41B707B7200B283F7 /* der_encode_integer.c */; };
+ E60816F51B707B7200B283F7 /* der_encode_integer.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816E41B707B7200B283F7 /* der_encode_integer.c */; };
+ E60816F61B707B7200B283F7 /* der_encode_object_identifier.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816E51B707B7200B283F7 /* der_encode_object_identifier.c */; };
+ E60816F71B707B7200B283F7 /* der_encode_object_identifier.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816E51B707B7200B283F7 /* der_encode_object_identifier.c */; };
+ E60816F81B707B7200B283F7 /* der_encode_octet_string.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816E61B707B7200B283F7 /* der_encode_octet_string.c */; };
+ E60816F91B707B7200B283F7 /* der_encode_octet_string.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816E61B707B7200B283F7 /* der_encode_octet_string.c */; };
+ E60816FA1B707B7200B283F7 /* der_encode_printable_string.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816E71B707B7200B283F7 /* der_encode_printable_string.c */; };
+ E60816FB1B707B7200B283F7 /* der_encode_printable_string.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816E71B707B7200B283F7 /* der_encode_printable_string.c */; };
+ E60816FC1B707B7200B283F7 /* der_encode_sequence_multi.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816E81B707B7200B283F7 /* der_encode_sequence_multi.c */; };
+ E60816FD1B707B7200B283F7 /* der_encode_sequence_multi.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816E81B707B7200B283F7 /* der_encode_sequence_multi.c */; };
+ E60816FE1B707B7200B283F7 /* der_encode_set.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816E91B707B7200B283F7 /* der_encode_set.c */; };
+ E60816FF1B707B7200B283F7 /* der_encode_set.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816E91B707B7200B283F7 /* der_encode_set.c */; };
+ E60817001B707B7200B283F7 /* der_encode_setof.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816EA1B707B7200B283F7 /* der_encode_setof.c */; };
+ E60817011B707B7200B283F7 /* der_encode_setof.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816EA1B707B7200B283F7 /* der_encode_setof.c */; };
+ E60817021B707B7200B283F7 /* der_encode_short_integer.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816EB1B707B7200B283F7 /* der_encode_short_integer.c */; };
+ E60817031B707B7200B283F7 /* der_encode_short_integer.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816EB1B707B7200B283F7 /* der_encode_short_integer.c */; };
+ E60817041B707B7200B283F7 /* der_encode_utctime.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816EC1B707B7200B283F7 /* der_encode_utctime.c */; };
+ E60817051B707B7200B283F7 /* der_encode_utctime.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816EC1B707B7200B283F7 /* der_encode_utctime.c */; };
+ E60817061B707B7200B283F7 /* der_encode_utf8_string.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816ED1B707B7200B283F7 /* der_encode_utf8_string.c */; };
+ E60817071B707B7200B283F7 /* der_encode_utf8_string.c in Sources */ = {isa = PBXBuildFile; fileRef = E60816ED1B707B7200B283F7 /* der_encode_utf8_string.c */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -745,6 +779,23 @@
32ED00B40D03542A00AB0B4E /* SFileListFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SFileListFile.cpp; path = src/SFileListFile.cpp; sourceTree = "<group>"; };
32ED00B60D03542A00AB0B4E /* StormLib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StormLib.h; path = src/StormLib.h; sourceTree = "<group>"; };
32ED00B70D03542A00AB0B4E /* StormPort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StormPort.h; path = src/StormPort.h; sourceTree = "<group>"; };
+ E60816D51B707A9000B283F7 /* rsa_sign_hash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rsa_sign_hash.c; sourceTree = "<group>"; };
+ E60816D81B707B1800B283F7 /* pkcs_1_pss_encode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pkcs_1_pss_encode.c; sourceTree = "<group>"; };
+ E60816DB1B707B2700B283F7 /* pkcs_1_v1_5_encode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pkcs_1_v1_5_encode.c; sourceTree = "<group>"; };
+ E60816DE1B707B5700B283F7 /* der_encode_sequence_ex.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_encode_sequence_ex.c; sourceTree = "<group>"; };
+ E60816E11B707B7200B283F7 /* der_encode_bit_string.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_encode_bit_string.c; sourceTree = "<group>"; };
+ E60816E21B707B7200B283F7 /* der_encode_boolean.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_encode_boolean.c; sourceTree = "<group>"; };
+ E60816E31B707B7200B283F7 /* der_encode_ia5_string.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_encode_ia5_string.c; sourceTree = "<group>"; };
+ E60816E41B707B7200B283F7 /* der_encode_integer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_encode_integer.c; sourceTree = "<group>"; };
+ E60816E51B707B7200B283F7 /* der_encode_object_identifier.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_encode_object_identifier.c; sourceTree = "<group>"; };
+ E60816E61B707B7200B283F7 /* der_encode_octet_string.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_encode_octet_string.c; sourceTree = "<group>"; };
+ E60816E71B707B7200B283F7 /* der_encode_printable_string.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_encode_printable_string.c; sourceTree = "<group>"; };
+ E60816E81B707B7200B283F7 /* der_encode_sequence_multi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_encode_sequence_multi.c; sourceTree = "<group>"; };
+ E60816E91B707B7200B283F7 /* der_encode_set.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_encode_set.c; sourceTree = "<group>"; };
+ E60816EA1B707B7200B283F7 /* der_encode_setof.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_encode_setof.c; sourceTree = "<group>"; };
+ E60816EB1B707B7200B283F7 /* der_encode_short_integer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_encode_short_integer.c; sourceTree = "<group>"; };
+ E60816EC1B707B7200B283F7 /* der_encode_utctime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_encode_utctime.c; sourceTree = "<group>"; };
+ E60816ED1B707B7200B283F7 /* der_encode_utf8_string.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_encode_utf8_string.c; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -1092,6 +1143,20 @@
22C9184F11933FCF0083AC69 /* asn1 */ = {
isa = PBXGroup;
children = (
+ E60816E11B707B7200B283F7 /* der_encode_bit_string.c */,
+ E60816E21B707B7200B283F7 /* der_encode_boolean.c */,
+ E60816E31B707B7200B283F7 /* der_encode_ia5_string.c */,
+ E60816E41B707B7200B283F7 /* der_encode_integer.c */,
+ E60816E51B707B7200B283F7 /* der_encode_object_identifier.c */,
+ E60816E61B707B7200B283F7 /* der_encode_octet_string.c */,
+ E60816E71B707B7200B283F7 /* der_encode_printable_string.c */,
+ E60816E81B707B7200B283F7 /* der_encode_sequence_multi.c */,
+ E60816E91B707B7200B283F7 /* der_encode_set.c */,
+ E60816EA1B707B7200B283F7 /* der_encode_setof.c */,
+ E60816EB1B707B7200B283F7 /* der_encode_short_integer.c */,
+ E60816EC1B707B7200B283F7 /* der_encode_utctime.c */,
+ E60816ED1B707B7200B283F7 /* der_encode_utf8_string.c */,
+ E60816DE1B707B5700B283F7 /* der_encode_sequence_ex.c */,
22C9185011933FCF0083AC69 /* der_decode_bit_string.c */,
22C9185111933FCF0083AC69 /* der_decode_boolean.c */,
22C9185211933FCF0083AC69 /* der_decode_choice.c */,
@@ -1138,6 +1203,8 @@
22C9187111933FCF0083AC69 /* pkcs1 */ = {
isa = PBXGroup;
children = (
+ E60816DB1B707B2700B283F7 /* pkcs_1_v1_5_encode.c */,
+ E60816D81B707B1800B283F7 /* pkcs_1_pss_encode.c */,
22C9187211933FCF0083AC69 /* pkcs_1_mgf1.c */,
22C9187311933FCF0083AC69 /* pkcs_1_oaep_decode.c */,
22C9187411933FCF0083AC69 /* pkcs_1_pss_decode.c */,
@@ -1149,6 +1216,7 @@
22C9187611933FCF0083AC69 /* rsa */ = {
isa = PBXGroup;
children = (
+ E60816D51B707A9000B283F7 /* rsa_sign_hash.c */,
22C9187711933FCF0083AC69 /* rsa_exptmod.c */,
22C9187811933FCF0083AC69 /* rsa_free.c */,
22C9187911933FCF0083AC69 /* rsa_import.c */,
@@ -1403,6 +1471,7 @@
225530EB1056BC8700FA646A /* SFileCompactArchive.cpp in Sources */,
225530EC1056BC8700FA646A /* SFileCreateArchive.cpp in Sources */,
225530ED1056BC8700FA646A /* SFileExtractFile.cpp in Sources */,
+ E60816F81B707B7200B283F7 /* der_encode_octet_string.c in Sources */,
225530EE1056BC8700FA646A /* SFileFindFile.cpp in Sources */,
225530EF1056BC8700FA646A /* SFileOpenArchive.cpp in Sources */,
226C7CAD1857DEEB00AB689C /* SFileGetFileInfo.cpp in Sources */,
@@ -1448,6 +1517,7 @@
22C918A811933FCF0083AC69 /* der_decode_short_integer.c in Sources */,
22C918A911933FCF0083AC69 /* der_decode_utctime.c in Sources */,
22C918AA11933FCF0083AC69 /* der_decode_utf8_string.c in Sources */,
+ E60816F01B707B7200B283F7 /* der_encode_boolean.c in Sources */,
22C918AB11933FCF0083AC69 /* der_length_bit_string.c in Sources */,
22C918AC11933FCF0083AC69 /* der_length_boolean.c in Sources */,
22C918AD11933FCF0083AC69 /* der_length_ia5_string.c in Sources */,
@@ -1478,7 +1548,9 @@
22C918C611933FCF0083AC69 /* rsa_verify_simple.c in Sources */,
22C9198A1193400A0083AC69 /* bn_fast_mp_invmod.c in Sources */,
22C9198B1193400A0083AC69 /* bn_fast_mp_montgomery_reduce.c in Sources */,
+ E60816F61B707B7200B283F7 /* der_encode_object_identifier.c in Sources */,
22C9198C1193400A0083AC69 /* bn_fast_s_mp_mul_digs.c in Sources */,
+ E60816FA1B707B7200B283F7 /* der_encode_printable_string.c in Sources */,
22C9198D1193400A0083AC69 /* bn_fast_s_mp_mul_high_digs.c in Sources */,
22C9198E1193400A0083AC69 /* bn_fast_s_mp_sqr.c in Sources */,
22C9198F1193400A0083AC69 /* bn_mp_2expt.c in Sources */,
@@ -1496,6 +1568,8 @@
22C9199B1193400A0083AC69 /* bn_mp_cnt_lsb.c in Sources */,
22C9199C1193400A0083AC69 /* bn_mp_copy.c in Sources */,
22C9199D1193400A0083AC69 /* bn_mp_count_bits.c in Sources */,
+ E60816F41B707B7200B283F7 /* der_encode_integer.c in Sources */,
+ E60817061B707B7200B283F7 /* der_encode_utf8_string.c in Sources */,
22C9199E1193400A0083AC69 /* bn_mp_div_2.c in Sources */,
22C9199F1193400A0083AC69 /* bn_mp_div_2d.c in Sources */,
22C919A01193400A0083AC69 /* bn_mp_div_3.c in Sources */,
@@ -1520,6 +1594,7 @@
22C919B31193400A0083AC69 /* bn_mp_init_set.c in Sources */,
22C919B41193400A0083AC69 /* bn_mp_init_size.c in Sources */,
22C919B51193400A0083AC69 /* bn_mp_init.c in Sources */,
+ E60816D91B707B1800B283F7 /* pkcs_1_pss_encode.c in Sources */,
22C919B61193400A0083AC69 /* bn_mp_invmod_slow.c in Sources */,
22C919B71193400A0083AC69 /* bn_mp_invmod.c in Sources */,
22C919B81193400A0083AC69 /* bn_mp_is_square.c in Sources */,
@@ -1533,11 +1608,15 @@
22C919C01193400A0083AC69 /* bn_mp_mod.c in Sources */,
22C919C11193400A0083AC69 /* bn_mp_montgomery_calc_normalization.c in Sources */,
22C919C21193400A0083AC69 /* bn_mp_montgomery_reduce.c in Sources */,
+ E60817021B707B7200B283F7 /* der_encode_short_integer.c in Sources */,
22C919C31193400A0083AC69 /* bn_mp_montgomery_setup.c in Sources */,
+ E60816DC1B707B2700B283F7 /* pkcs_1_v1_5_encode.c in Sources */,
22C919C41193400A0083AC69 /* bn_mp_mul_2.c in Sources */,
+ E60816FC1B707B7200B283F7 /* der_encode_sequence_multi.c in Sources */,
22C919C51193400A0083AC69 /* bn_mp_mul_2d.c in Sources */,
22C919C61193400A0083AC69 /* bn_mp_mul_d.c in Sources */,
22C919C71193400A0083AC69 /* bn_mp_mul.c in Sources */,
+ E60816EE1B707B7200B283F7 /* der_encode_bit_string.c in Sources */,
22C919C81193400A0083AC69 /* bn_mp_mulmod.c in Sources */,
22C919C91193400A0083AC69 /* bn_mp_n_root.c in Sources */,
22C919CA1193400A0083AC69 /* bn_mp_neg.c in Sources */,
@@ -1545,6 +1624,7 @@
22C919CC1193400A0083AC69 /* bn_mp_prime_fermat.c in Sources */,
22C919CD1193400A0083AC69 /* bn_mp_prime_is_divisible.c in Sources */,
22C919CE1193400A0083AC69 /* bn_mp_prime_is_prime.c in Sources */,
+ E60816D61B707A9000B283F7 /* rsa_sign_hash.c in Sources */,
22C919CF1193400A0083AC69 /* bn_mp_prime_miller_rabin.c in Sources */,
22C919D01193400A0083AC69 /* bn_mp_prime_next_prime.c in Sources */,
22C919D11193400A0083AC69 /* bn_mp_prime_rabin_miller_trials.c in Sources */,
@@ -1558,8 +1638,11 @@
22C919D91193400A0083AC69 /* bn_mp_reduce_2k_l.c in Sources */,
22C919DA1193400A0083AC69 /* bn_mp_reduce_2k_setup_l.c in Sources */,
22C919DB1193400A0083AC69 /* bn_mp_reduce_2k_setup.c in Sources */,
+ E60816FE1B707B7200B283F7 /* der_encode_set.c in Sources */,
+ E60817001B707B7200B283F7 /* der_encode_setof.c in Sources */,
22C919DC1193400A0083AC69 /* bn_mp_reduce_2k.c in Sources */,
22C919DD1193400A0083AC69 /* bn_mp_reduce_is_2k_l.c in Sources */,
+ E60817041B707B7200B283F7 /* der_encode_utctime.c in Sources */,
22C919DE1193400A0083AC69 /* bn_mp_reduce_is_2k.c in Sources */,
22C919DF1193400A0083AC69 /* bn_mp_reduce_setup.c in Sources */,
22C919E01193400A0083AC69 /* bn_mp_reduce.c in Sources */,
@@ -1583,6 +1666,8 @@
22C919F21193400A0083AC69 /* bn_mp_toradix_n.c in Sources */,
22C919F31193400A0083AC69 /* bn_mp_toradix.c in Sources */,
22C919F41193400A0083AC69 /* bn_mp_unsigned_bin_size.c in Sources */,
+ E60816F21B707B7200B283F7 /* der_encode_ia5_string.c in Sources */,
+ E60816DF1B707B5700B283F7 /* der_encode_sequence_ex.c in Sources */,
22C919F51193400A0083AC69 /* bn_mp_xor.c in Sources */,
22C919F61193400A0083AC69 /* bn_mp_zero.c in Sources */,
22C919F71193400A0083AC69 /* bn_prime_tab.c in Sources */,
@@ -1617,6 +1702,7 @@
225FACAE0E53BAB400DA2CAE /* SFileCompactArchive.cpp in Sources */,
225FACAF0E53BAB400DA2CAE /* SFileCreateArchive.cpp in Sources */,
225FACB00E53BAB400DA2CAE /* SFileExtractFile.cpp in Sources */,
+ E60816F91B707B7200B283F7 /* der_encode_octet_string.c in Sources */,
225FACB10E53BAB400DA2CAE /* SFileFindFile.cpp in Sources */,
225FACB20E53BAB400DA2CAE /* SFileOpenArchive.cpp in Sources */,
226C7CAE1857DEEB00AB689C /* SFileGetFileInfo.cpp in Sources */,
@@ -1662,6 +1748,7 @@
22C918F211933FCF0083AC69 /* der_decode_short_integer.c in Sources */,
22C918F311933FCF0083AC69 /* der_decode_utctime.c in Sources */,
22C918F411933FCF0083AC69 /* der_decode_utf8_string.c in Sources */,
+ E60816F11B707B7200B283F7 /* der_encode_boolean.c in Sources */,
22C918F511933FCF0083AC69 /* der_length_bit_string.c in Sources */,
22C918F611933FCF0083AC69 /* der_length_boolean.c in Sources */,
22C918F711933FCF0083AC69 /* der_length_ia5_string.c in Sources */,
@@ -1692,7 +1779,9 @@
22C9191011933FCF0083AC69 /* rsa_verify_simple.c in Sources */,
22C91A031193400A0083AC69 /* bn_fast_mp_invmod.c in Sources */,
22C91A041193400A0083AC69 /* bn_fast_mp_montgomery_reduce.c in Sources */,
+ E60816F71B707B7200B283F7 /* der_encode_object_identifier.c in Sources */,
22C91A051193400A0083AC69 /* bn_fast_s_mp_mul_digs.c in Sources */,
+ E60816FB1B707B7200B283F7 /* der_encode_printable_string.c in Sources */,
22C91A061193400A0083AC69 /* bn_fast_s_mp_mul_high_digs.c in Sources */,
22C91A071193400A0083AC69 /* bn_fast_s_mp_sqr.c in Sources */,
22C91A081193400A0083AC69 /* bn_mp_2expt.c in Sources */,
@@ -1710,6 +1799,8 @@
22C91A141193400A0083AC69 /* bn_mp_cnt_lsb.c in Sources */,
22C91A151193400A0083AC69 /* bn_mp_copy.c in Sources */,
22C91A161193400A0083AC69 /* bn_mp_count_bits.c in Sources */,
+ E60816F51B707B7200B283F7 /* der_encode_integer.c in Sources */,
+ E60817071B707B7200B283F7 /* der_encode_utf8_string.c in Sources */,
22C91A171193400A0083AC69 /* bn_mp_div_2.c in Sources */,
22C91A181193400A0083AC69 /* bn_mp_div_2d.c in Sources */,
22C91A191193400A0083AC69 /* bn_mp_div_3.c in Sources */,
@@ -1734,6 +1825,7 @@
22C91A2C1193400A0083AC69 /* bn_mp_init_set.c in Sources */,
22C91A2D1193400A0083AC69 /* bn_mp_init_size.c in Sources */,
22C91A2E1193400A0083AC69 /* bn_mp_init.c in Sources */,
+ E60816DA1B707B1800B283F7 /* pkcs_1_pss_encode.c in Sources */,
22C91A2F1193400A0083AC69 /* bn_mp_invmod_slow.c in Sources */,
22C91A301193400A0083AC69 /* bn_mp_invmod.c in Sources */,
22C91A311193400A0083AC69 /* bn_mp_is_square.c in Sources */,
@@ -1747,11 +1839,15 @@
22C91A391193400A0083AC69 /* bn_mp_mod.c in Sources */,
22C91A3A1193400A0083AC69 /* bn_mp_montgomery_calc_normalization.c in Sources */,
22C91A3B1193400A0083AC69 /* bn_mp_montgomery_reduce.c in Sources */,
+ E60817031B707B7200B283F7 /* der_encode_short_integer.c in Sources */,
22C91A3C1193400A0083AC69 /* bn_mp_montgomery_setup.c in Sources */,
+ E60816DD1B707B2700B283F7 /* pkcs_1_v1_5_encode.c in Sources */,
22C91A3D1193400A0083AC69 /* bn_mp_mul_2.c in Sources */,
+ E60816FD1B707B7200B283F7 /* der_encode_sequence_multi.c in Sources */,
22C91A3E1193400A0083AC69 /* bn_mp_mul_2d.c in Sources */,
22C91A3F1193400A0083AC69 /* bn_mp_mul_d.c in Sources */,
22C91A401193400A0083AC69 /* bn_mp_mul.c in Sources */,
+ E60816EF1B707B7200B283F7 /* der_encode_bit_string.c in Sources */,
22C91A411193400A0083AC69 /* bn_mp_mulmod.c in Sources */,
22C91A421193400A0083AC69 /* bn_mp_n_root.c in Sources */,
22C91A431193400A0083AC69 /* bn_mp_neg.c in Sources */,
@@ -1759,6 +1855,7 @@
22C91A451193400A0083AC69 /* bn_mp_prime_fermat.c in Sources */,
22C91A461193400A0083AC69 /* bn_mp_prime_is_divisible.c in Sources */,
22C91A471193400A0083AC69 /* bn_mp_prime_is_prime.c in Sources */,
+ E60816D71B707A9B00B283F7 /* rsa_sign_hash.c in Sources */,
22C91A481193400A0083AC69 /* bn_mp_prime_miller_rabin.c in Sources */,
22C91A491193400A0083AC69 /* bn_mp_prime_next_prime.c in Sources */,
22C91A4A1193400A0083AC69 /* bn_mp_prime_rabin_miller_trials.c in Sources */,
@@ -1772,8 +1869,11 @@
22C91A521193400A0083AC69 /* bn_mp_reduce_2k_l.c in Sources */,
22C91A531193400A0083AC69 /* bn_mp_reduce_2k_setup_l.c in Sources */,
22C91A541193400A0083AC69 /* bn_mp_reduce_2k_setup.c in Sources */,
+ E60816FF1B707B7200B283F7 /* der_encode_set.c in Sources */,
+ E60817011B707B7200B283F7 /* der_encode_setof.c in Sources */,
22C91A551193400A0083AC69 /* bn_mp_reduce_2k.c in Sources */,
22C91A561193400A0083AC69 /* bn_mp_reduce_is_2k_l.c in Sources */,
+ E60817051B707B7200B283F7 /* der_encode_utctime.c in Sources */,
22C91A571193400A0083AC69 /* bn_mp_reduce_is_2k.c in Sources */,
22C91A581193400A0083AC69 /* bn_mp_reduce_setup.c in Sources */,
22C91A591193400A0083AC69 /* bn_mp_reduce.c in Sources */,
@@ -1797,6 +1897,8 @@
22C91A6B1193400A0083AC69 /* bn_mp_toradix_n.c in Sources */,
22C91A6C1193400A0083AC69 /* bn_mp_toradix.c in Sources */,
22C91A6D1193400A0083AC69 /* bn_mp_unsigned_bin_size.c in Sources */,
+ E60816F31B707B7200B283F7 /* der_encode_ia5_string.c in Sources */,
+ E60816E01B707B5700B283F7 /* der_encode_sequence_ex.c in Sources */,
22C91A6E1193400A0083AC69 /* bn_mp_xor.c in Sources */,
22C91A6F1193400A0083AC69 /* bn_mp_zero.c in Sources */,
22C91A701193400A0083AC69 /* bn_prime_tab.c in Sources */,
diff --git a/src/SBaseFileTable.cpp b/src/SBaseFileTable.cpp
index b293574..ed0748d 100644
--- a/src/SBaseFileTable.cpp
+++ b/src/SBaseFileTable.cpp
@@ -374,10 +374,13 @@ int ConvertMpqHeaderToFormat4(
//
Label_ArchiveVersion1:
- if(pHeader->dwHashTablePos <= pHeader->dwHeaderSize || (pHeader->dwHashTablePos & 0x80000000))
- ha->dwFlags |= MPQ_FLAG_MALFORMED;
- if(pHeader->dwBlockTablePos <= pHeader->dwHeaderSize || (pHeader->dwBlockTablePos & 0x80000000))
- ha->dwFlags |= MPQ_FLAG_MALFORMED;
+ if(pHeader->dwBlockTableSize > 1) // Prevent empty MPQs being marked as malformed
+ {
+ if(pHeader->dwHashTablePos <= pHeader->dwHeaderSize || (pHeader->dwHashTablePos & 0x80000000))
+ ha->dwFlags |= MPQ_FLAG_MALFORMED;
+ if(pHeader->dwBlockTablePos <= pHeader->dwHeaderSize || (pHeader->dwBlockTablePos & 0x80000000))
+ ha->dwFlags |= MPQ_FLAG_MALFORMED;
+ }
// Only low byte of sector size is really used
if(pHeader->wSectorSize & 0xFF00)
diff --git a/src/SFilePatchArchives.cpp b/src/SFilePatchArchives.cpp
index 7c6515e..d01aaf2 100644
--- a/src/SFilePatchArchives.cpp
+++ b/src/SFilePatchArchives.cpp
@@ -437,24 +437,37 @@ static bool CreatePatchPrefix(TMPQArchive * ha, const char * szFileName, size_t
static bool IsMatchingPatchFile(
TMPQArchive * ha,
const char * szFileName,
- LPBYTE pbFileMd5)
+ LPBYTE pbBaseFileMd5)
{
MPQ_PATCH_HEADER PatchHeader = {0};
HANDLE hFile = NULL;
DWORD dwTransferred = 0;
+ DWORD dwFlags = 0;
bool bResult = false;
// Open the file and load the patch header
if(SFileOpenFileEx((HANDLE)ha, szFileName, SFILE_OPEN_BASE_FILE, &hFile))
{
- // Load the patch header
- SFileReadFile(hFile, &PatchHeader, sizeof(MPQ_PATCH_HEADER), &dwTransferred, NULL);
- BSWAP_ARRAY32_UNSIGNED(pPatchHeader, sizeof(DWORD) * 6);
-
- // If the file contains an incremental patch,
- // compare the "MD5 before patching" with the base file MD5
- if(dwTransferred == sizeof(MPQ_PATCH_HEADER) && PatchHeader.dwSignature == PATCH_SIGNATURE_HEADER)
- bResult = (!memcmp(PatchHeader.md5_before_patch, pbFileMd5, MD5_DIGEST_SIZE));
+ // Retrieve the flags. We need to know whether the file is a patch or not
+ SFileGetFileInfo(hFile, SFileInfoFlags, &dwFlags, sizeof(DWORD), &dwTransferred);
+ if(dwFlags & MPQ_FILE_PATCH_FILE)
+ {
+ // Load the patch header
+ SFileReadFile(hFile, &PatchHeader, sizeof(MPQ_PATCH_HEADER), &dwTransferred, NULL);
+ BSWAP_ARRAY32_UNSIGNED(pPatchHeader, sizeof(DWORD) * 6);
+
+ // If the file contains an incremental patch,
+ // compare the "MD5 before patching" with the base file MD5
+ if(dwTransferred == sizeof(MPQ_PATCH_HEADER) && PatchHeader.dwSignature == PATCH_SIGNATURE_HEADER)
+ bResult = (!memcmp(PatchHeader.md5_before_patch, pbBaseFileMd5, MD5_DIGEST_SIZE));
+ }
+ else
+ {
+ // TODO: How to match it if it's not an incremental patch?
+ // Example: StarCraft II\Updates\enGB\s2-update-enGB-23258.MPQ:
+ // Mods\Core.SC2Mod\enGB.SC2Assets\StreamingBuckets.txt"
+ bResult = false;
+ }
// Close the file
SFileCloseFile(hFile);
@@ -499,33 +512,6 @@ static const char * FindArchiveLanguage(TMPQArchive * ha, PLOCALIZED_MPQ_INFO pM
return NULL;
}
-static TFileEntry * FindBaseLstFile(TMPQArchive * ha)
-{
- TFileEntry * pFileEntry;
- const char * szLanguage;
- char szFileName[0x40];
-
- // Prepare the file name tenplate
- memcpy(szFileName, "####-md5.lst", 13);
-
- // Try all languages
- for(szLanguage = LanguageList; szLanguage[0] != 0; szLanguage++)
- {
- // Copy the language name
- szFileName[0] = szLanguage[0];
- szFileName[1] = szLanguage[1];
- szFileName[2] = szLanguage[2];
- szFileName[3] = szLanguage[3];
-
- // Check whether this file exists
- pFileEntry = GetFileEntryLocale(ha, szFileName, 0);
- if(pFileEntry != NULL)
- return pFileEntry;
- }
-
- return NULL;
-}
-
static bool FindPatchPrefix_WoW_13164_13623(TMPQArchive * haBase, TMPQArchive * haPatch)
{
const char * szPatchPrefix;
@@ -565,12 +551,11 @@ static bool FindPatchPrefix_WoW_13164_13623(TMPQArchive * haBase, TMPQArchive *
// We need to match the file by its MD5
//
-
-static bool FindPatchPrefix_SC2(TMPQArchive * haBase, TMPQArchive * haPatch)
+// Note: pBaseEntry is the file entry of the base version of "StreamingBuckets.txt"
+static bool FindPatchPrefix_SC2(TMPQArchive * haBase, TMPQArchive * haPatch, TFileEntry * pBaseEntry)
{
TMPQNamePrefix * pPatchPrefix;
- TFileEntry * pBaseEntry;
- char * szLstFileName;
+ char * szPatchFileName;
char * szPlainName;
size_t cchWorkBuffer = 0x400;
bool bResult = false;
@@ -583,17 +568,9 @@ static bool FindPatchPrefix_SC2(TMPQArchive * haBase, TMPQArchive * haPatch)
TFileEntry * pFileEntry;
// Allocate working buffer for merging LST file
- szLstFileName = STORM_ALLOC(char, cchWorkBuffer);
- if(szLstFileName != NULL)
+ szPatchFileName = STORM_ALLOC(char, cchWorkBuffer);
+ if(szPatchFileName != NULL)
{
- // Find a *-md5.lst file in the base archive
- pBaseEntry = FindBaseLstFile(haBase);
- if(pBaseEntry == NULL)
- {
- STORM_FREE(szLstFileName);
- return false;
- }
-
// Parse the entire file table
for(pFileEntry = haPatch->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++)
{
@@ -601,21 +578,21 @@ static bool FindPatchPrefix_SC2(TMPQArchive * haBase, TMPQArchive * haPatch)
if(IsPatchMetadataFile(pFileEntry))
{
// Construct the name of the MD5 file
- strcpy(szLstFileName, pFileEntry->szFileName);
- szPlainName = (char *)GetPlainFileName(szLstFileName);
+ strcpy(szPatchFileName, pFileEntry->szFileName);
+ szPlainName = (char *)GetPlainFileName(szPatchFileName);
strcpy(szPlainName, pBaseEntry->szFileName);
// Check for matching MD5 file
- if(IsMatchingPatchFile(haPatch, szLstFileName, pBaseEntry->md5))
+ if(IsMatchingPatchFile(haPatch, szPatchFileName, pBaseEntry->md5))
{
- bResult = CreatePatchPrefix(haPatch, szLstFileName, (size_t)(szPlainName - szLstFileName));
+ bResult = CreatePatchPrefix(haPatch, szPatchFileName, (size_t)(szPlainName - szPatchFileName));
break;
}
}
}
// Delete the merge buffer
- STORM_FREE(szLstFileName);
+ STORM_FREE(szPatchFileName);
}
}
@@ -637,6 +614,8 @@ static bool FindPatchPrefix_SC2(TMPQArchive * haBase, TMPQArchive * haPatch)
static bool FindPatchPrefix(TMPQArchive * haBase, TMPQArchive * haPatch, const char * szPatchPathPrefix)
{
+ TFileEntry * pFileEntry;
+
// If the patch prefix was explicitly entered, we use that one
if(szPatchPathPrefix != NULL)
return CreatePatchPrefix(haPatch, szPatchPathPrefix, 0);
@@ -649,8 +628,9 @@ static bool FindPatchPrefix(TMPQArchive * haBase, TMPQArchive * haPatch, const c
// Updates for Starcraft II
// Match: LocalizedData\GameHotkeys.txt <==> Campaigns\Liberty.SC2Campaign\enGB.SC2Data\LocalizedData\GameHotkeys.txt
// All Starcraft II base archives seem to have the file "StreamingBuckets.txt" present
- if(GetFileEntryLocale(haBase, "StreamingBuckets.txt", 0))
- return FindPatchPrefix_SC2(haBase, haPatch);
+ pFileEntry = GetFileEntryLocale(haBase, "StreamingBuckets.txt", 0);
+ if(pFileEntry != NULL)
+ return FindPatchPrefix_SC2(haBase, haPatch, pFileEntry);
// Diablo III patch MPQs don't use patch prefix
// Hearthstone MPQs don't use patch prefix
@@ -896,29 +876,37 @@ bool WINAPI SFileOpenPatchArchive(
// Open the archive like it is normal archive
if(nError == ERROR_SUCCESS)
{
- if(!SFileOpenArchive(szPatchMpqName, 0, MPQ_OPEN_READ_ONLY | MPQ_OPEN_PATCH, &hPatchMpq))
- return false;
- haPatch = (TMPQArchive *)hPatchMpq;
-
- // We need to remember the proper patch prefix to match names of patched files
- FindPatchPrefix(ha, (TMPQArchive *)hPatchMpq, szPatchPathPrefix);
-
- // Now add the patch archive to the list of patches to the original MPQ
- while(ha != NULL)
+ if(SFileOpenArchive(szPatchMpqName, 0, MPQ_OPEN_READ_ONLY | MPQ_OPEN_PATCH, &hPatchMpq))
{
- if(ha->haPatch == NULL)
+ // Cast the archive handle to structure pointer
+ haPatch = (TMPQArchive *)hPatchMpq;
+
+ // We need to remember the proper patch prefix to match names of patched files
+ if(FindPatchPrefix(ha, (TMPQArchive *)hPatchMpq, szPatchPathPrefix))
{
- haPatch->haBase = ha;
- ha->haPatch = haPatch;
- return true;
+ // Now add the patch archive to the list of patches to the original MPQ
+ while(ha != NULL)
+ {
+ if(ha->haPatch == NULL)
+ {
+ haPatch->haBase = ha;
+ ha->haPatch = haPatch;
+ return true;
+ }
+
+ // Move to the next archive
+ ha = ha->haPatch;
+ }
}
- // Move to the next archive
- ha = ha->haPatch;
+ // Close the archive
+ SFileCloseArchive(hPatchMpq);
+ nError = ERROR_CANT_FIND_PATCH_PREFIX;
+ }
+ else
+ {
+ nError = GetLastError();
}
-
- // Should never happen
- nError = ERROR_CAN_NOT_COMPLETE;
}
SetLastError(nError);
diff --git a/src/StormLib.h b/src/StormLib.h
index b6cb0c9..fb32b8b 100644
--- a/src/StormLib.h
+++ b/src/StormLib.h
@@ -149,6 +149,7 @@ extern "C" {
#define ERROR_MARKED_FOR_DELETE 10005 // The file was marked as "deleted" in the MPQ
#define ERROR_FILE_INCOMPLETE 10006 // The required file part is missing
#define ERROR_UNKNOWN_FILE_NAMES 10007 // A name of at least one file is unknown
+#define ERROR_CANT_FIND_PATCH_PREFIX 10008 // StormLib was unable to find patch prefix for the patches
// Values for SFileCreateArchive
#define HASH_TABLE_SIZE_MIN 0x00000004 // Verified: If there is 1 file, hash table size is 4
diff --git a/stormlib_dll/StormLib.def b/stormlib_dll/StormLib.def
index a85f942..4b48b13 100644
--- a/stormlib_dll/StormLib.def
+++ b/stormlib_dll/StormLib.def
@@ -73,3 +73,6 @@ EXPORTS
SCompExplode
SCompCompress
SCompDecompress
+
+ GetLastError=Kernel32.GetLastError
+ SetLastError=Kernel32.SetLastError
diff --git a/test/StormTest.cpp b/test/StormTest.cpp
index 51654a0..685e7de 100644
--- a/test/StormTest.cpp
+++ b/test/StormTest.cpp
@@ -203,7 +203,7 @@ static const char * PatchList_SC2_34644_Maps[] =
static const char * PatchList_SC2_32283_enGB[] =
{
- "MPQ_2013_v4_enGB.SC2Data",
+ "MPQ_2013_v4_Mods#Core.SC2Mod#enGB.SC2Assets",
"s2-update-enGB-23258.MPQ",
"s2-update-enGB-24540.MPQ",
"s2-update-enGB-26147.MPQ",
@@ -213,6 +213,18 @@ static const char * PatchList_SC2_32283_enGB[] =
NULL
};
+static const char * PatchList_SC2_36281_enGB[] =
+{
+ "MPQ_2013_v4_Mods#Liberty.SC2Mod#enGB.SC2Data",
+ "s2-update-enGB-23258.MPQ",
+ "s2-update-enGB-24540.MPQ",
+ "s2-update-enGB-26147.MPQ",
+ "s2-update-enGB-28522.MPQ",
+ "s2-update-enGB-30384.MPQ",
+ "s2-update-enGB-32281.MPQ",
+ NULL
+};
+
static const char * PatchList_HS_6898_enGB[] =
{
"MPQ_2014_v4_base-Win.MPQ",
@@ -1924,10 +1936,15 @@ static int OpenPatchedArchive(TLogHelper * pLogger, HANDLE * phMpq, const char *
}
}
- // Store the archive handle or close the archive
- if(phMpq == NULL)
+ // If anything failed, close the MPQ handle
+ if(nError != ERROR_SUCCESS)
+ {
SFileCloseArchive(hMpq);
- else
+ hMpq = NULL;
+ }
+
+ // Give the archive handle to the caller
+ if(phMpq != NULL)
*phMpq = hMpq;
return nError;
}
@@ -2494,7 +2511,7 @@ static int TestOpenArchive_Corrupt(const char * szPlainName)
// Opens a patched MPQ archive
-static int TestOpenArchive_Patched(const char * PatchList[], const char * szPatchedFile, int nExpectedPatchCount)
+static int TestOpenArchive_Patched(const char * PatchList[], const char * szPatchedFile, int nExpectedPatchCount, bool bExpectedToFail = false)
{
TLogHelper Logger("OpenPatchedMpqTest", PatchList[0]);
HANDLE hMpq;
@@ -2530,6 +2547,9 @@ static int TestOpenArchive_Patched(const char * PatchList[], const char * szPatc
SFileCloseArchive(hMpq);
}
+ // Clear the error if patch prefix was not found
+ if(nError == ERROR_CANT_FIND_PATCH_PREFIX && bExpectedToFail)
+ nError = ERROR_SUCCESS;
return nError;
}
@@ -3181,6 +3201,7 @@ static int TestCreateArchive_Deprotect(const char * szPlainName)
return nError;
}
*/
+
static int TestCreateArchive_EmptyMpq(const char * szPlainName, DWORD dwCreateFlags)
{
TLogHelper Logger("CreateEmptyMpq", szPlainName);
@@ -4087,7 +4108,7 @@ int main(int argc, char * argv[])
// Search all testing archives and verify their SHA1 hash
// if(nError == ERROR_SUCCESS)
// nError = FindFiles(ForEachFile_VerifyFileChecksum, szMpqSubDir);
-
+/*
// Test sparse compression
if(nError == ERROR_SUCCESS)
nError = TestSparseCompression();
@@ -4282,10 +4303,14 @@ int main(int argc, char * argv[])
// Open a patched archive with new format of BSDIFF patch
if(nError == ERROR_SUCCESS)
nError = TestOpenArchive_Patched(PatchList_SC2_34644_Maps, "Maps\\Campaign\\THorner03.SC2Map\\BankList.xml", 3);
-
+*/
// Open a patched archive
if(nError == ERROR_SUCCESS)
- nError = TestOpenArchive_Patched(PatchList_SC2_32283_enGB, "LocalizedData\\GameHotkeys.txt", 6);
+ nError = TestOpenArchive_Patched(PatchList_SC2_32283_enGB, "LocalizedData\\GameHotkeys.txt", 0, true);
+/*
+ // Open a patched archive where the "StreamingBuckets.txt" is not a patch file
+ if(nError == ERROR_SUCCESS)
+ nError = TestOpenArchive_Patched(PatchList_SC2_36281_enGB, "LocalizedData\\GameHotkeys.txt", 6);
// Open a patched archive
if(nError == ERROR_SUCCESS)
@@ -4430,7 +4455,7 @@ int main(int argc, char * argv[])
// Test replacing a file with zero size file
if(nError == ERROR_SUCCESS)
nError = TestModifyArchive_ReplaceFile("MPQ_2014_v4_Base.StormReplay", "AddFile-replay.message.events");
-
+*/
#ifdef _MSC_VER
_CrtDumpMemoryLeaks();
#endif // _MSC_VER