Storm: MD5, SCrc, Storm IOFileUnit and template instances

MD5Init/Transform/Update/Final (0x779340-0x779AE0), SCrcBuffer/SCrcCompute
(0x779BA0, table 0xADE9A8), the Storm::IOFileUnit family (0x779C30-0x77A530,
Win32/Win64) and TSExportTableSyncReuse's deleting destructor, plus new
template instances in the stpl.h OFFSET lists (from the Storm, Tempest,
Os, SoundInterface and Frame work).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Saty
2026-09-27 03:04:03 +02:00
co-authored by Claude Opus 5.5
parent cb9f7f4ac7
commit 425ae44fe3
7 changed files with 1177 additions and 13 deletions
+7
View File
@@ -8,6 +8,10 @@
#define STORM_MAX_STR 0x7FFFFFFF
#define SCRC_INITIALIZE 0x1
#define SCRC_PROCESS 0x2
#define SCRC_FINALIZE 0x4
#define STORM_ERROR_SUCCESS 0
#define STORM_ERROR_FILE_NOT_FOUND 2
#define STORM_ERROR_NOT_ENOUGH_MEMORY 8
@@ -124,6 +128,9 @@ int32_t STORMAPI SCmdProcessCommandLine(int32_t (STORMAPI* extracallback)(const
int32_t STORMAPI SCmdRegisterArgList(const _ARGLIST* listptr, uint32_t numargs);
int32_t STORMAPI SCmdRegisterArgument(uint32_t flags, uint32_t id, const char* name, void* variableptr, uint32_t variablebytes, uint32_t setvalue, uint32_t setmask, int32_t (STORMAPI* callback)(_CMDPARAMS*, const char*));
uint32_t SCrcBuffer(const void* buffer, uint32_t length, uint32_t* crc, uint32_t flags);
uint32_t STORMAPI SCrcCompute(const void* buffer, uint32_t length, uint32_t* crc, uint32_t flags);
int32_t STORMAPI SCompDestroy();
void STORMAPI SErrCatchUnhandledExceptions();
+21 -13
View File
@@ -254,6 +254,7 @@ class TSExportTableSyncReuse : public TSExportTableSimpleReuse<T, THandle> {
public:
/* 0040 */ TSync m_sync;
~TSExportTableSyncReuse();
void Delete(THandle handle);
void DeleteUnlock(T* ptr, TLockedHandle lockedhandle);
int32_t IsForWriting(TLockedHandle lockedhandle);
@@ -377,7 +378,7 @@ void TSList<T, TGetLink>::ChangeLinkOffset(ptrdiff_t linkoffset) {
}
// VERIFY: ab66a452 manual
// OFFSET: [0x0047C470, 0x0047E7C0, 0x0047E830, 0x0047E8A0, 0x00485970, 0x00489A60, 0x0049A610, 0x004B73E0, 0x004B7460, 0x004BA230, 0x004BA2A0, 0x004BCEF0, 0x004C9650, 0x004CA310, 0x004CDA60, 0x004DA510, 0x004F92A0, 0x00502270, 0x00503060, 0x00527B00, 0x00528690, 0x0052F090, 0x0053EEB0, 0x0055FD20, 0x005AE0C0, 0x005B2170, 0x005B2260, 0x005B4CF0, 0x005BE660, 0x005BE6D0, 0x005BE740, 0x005F3DB0, 0x00606480, 0x00615FF0, 0x00617210, 0x00633470, 0x00670070, 0x00687FD0, 0x006BC100, 0x006BDDC0, 0x006BDE40, 0x006BF210, 0x006E4B80, 0x006EBF90, 0x006F2B70, 0x006F2BE0, 0x006FAF40, 0x0074F550, 0x0074F640, 0x00771C20, 0x00772EF0, 0x00788B20, 0x007FBC20, 0x00804D90, 0x00804E00, 0x00807650, 0x0081A530, 0x0083D2D0, 0x008489F0, 0x00848A60, 0x008C8550, 0x008C8640, 0x0095B8E0]
// OFFSET: [0x0047C470, 0x0047E7C0, 0x0047E830, 0x0047E8A0, 0x00485970, 0x00489A60, 0x0049A610, 0x004B73E0, 0x004B7460, 0x004BA230, 0x004BA2A0, 0x004BCEF0, 0x004C9650, 0x004CA310, 0x004CDA60, 0x004DA510, 0x004F92A0, 0x00502270, 0x00503060, 0x00527B00, 0x00528690, 0x0052F090, 0x0053EEB0, 0x0055FD20, 0x005AE0C0, 0x005B2170, 0x005B2260, 0x005B4CF0, 0x005BE660, 0x005BE6D0, 0x005BE740, 0x005F3DB0, 0x00606480, 0x00615FF0, 0x00617210, 0x00633470, 0x00670070, 0x00687FD0, 0x006BC100, 0x006BDDC0, 0x006BDE40, 0x006BF210, 0x006E4B80, 0x006EBF90, 0x006F2B70, 0x006F2BE0, 0x006FAF40, 0x0074F550, 0x0074F640, 0x00771C20, 0x00772EF0, 0x00788B20, 0x007FBC20, 0x00804D90, 0x00804E00, 0x00807650, 0x0081A530, 0x0083D2D0, 0x008489F0, 0x00848A60, 0x0086E850, 0x008C8550, 0x008C8640, 0x0095B8E0]
template <class T, class TGetLink>
void TSList<T, TGetLink>::Clear() {
T* node;
@@ -584,7 +585,8 @@ T* TSLinkedNode<T>::RawNext() {
return this->m_link.RawNext();
}
// INLINED
// VERIFY: d9cd8150 manual
// OFFSET: 0x0075B560
template <class T>
void TSSwap(T& a, T& b) {
T temp = a;
@@ -647,7 +649,7 @@ TSFixedArray<T>::TSFixedArray(const TSFixedArray<T>& source) {
}
// VERIFY: 0f3f0aeb manual
// OFFSET: [0x0047C630, 0x0047C6C0, 0x00490BE0, 0x004967E0, 0x004B74F0, 0x004BAFD0, 0x004BC2F0, 0x004BC380, 0x004BE2D0, 0x004C0260, 0x004C9520, 0x004CA720, 0x004CC6F0, 0x004CC780, 0x004CDDD0, 0x004CF070, 0x004D3130, 0x004D33C0, 0x004D4E10, 0x004F31F0, 0x005032A0, 0x00503330, 0x005033C0, 0x00503450, 0x005053E0, 0x00527BF0, 0x00527C80, 0x00527E70, 0x0052F100, 0x0053F160, 0x00548B70, 0x00558C50, 0x00558CE0, 0x0055F560, 0x0055F5F0, 0x0055F680, 0x0055F710, 0x0055F7A0, 0x00566700, 0x00575F60, 0x005920F0, 0x005B4DE0, 0x005B4E70, 0x005BE830, 0x005BE8C0, 0x005C7290, 0x005C7320, 0x005D24E0, 0x005F03B0, 0x005F3E20, 0x005F5AD0, 0x005F5B60, 0x005F5BF0, 0x005FCB80, 0x00617AA0, 0x00617B30, 0x00617BC0, 0x0066E830, 0x0066E8C0, 0x0066E950, 0x0066E9E0, 0x0066EA70, 0x0066EB00, 0x0066EB90, 0x0066EC20, 0x0066ECB0, 0x0066ED40, 0x0066EDD0, 0x0066EE60, 0x0066EEF0, 0x0066EF80, 0x0066F010, 0x0066F0A0, 0x0066F130, 0x0066F1C0, 0x0066F250, 0x0066F2E0, 0x0066F370, 0x0066F400, 0x0066F490, 0x0066F520, 0x0066F5B0, 0x0066F640, 0x0066F6D0, 0x0066F760, 0x0066F7F0, 0x0066F880, 0x006881A0, 0x006BBE30, 0x006BEE90, 0x006C2650, 0x006C2AC0, 0x006C2B50, 0x006C8380, 0x006E4EB0, 0x006E4F40, 0x006F2C50, 0x006F2CE0, 0x006F2D70, 0x006F2E00, 0x006F2E90, 0x006F2F20, 0x006F2FB0, 0x00709AA0, 0x00709B30, 0x0072FFC0, 0x007675F0, 0x007685D0, 0x00776AD0, 0x007B04D0, 0x007B5DF0, 0x007C0B40, 0x007C0BD0, 0x007DD360, 0x007DD3F0, 0x007E01C0, 0x007F2A20, 0x007F4ED0, 0x00804EF0, 0x00804F80, 0x008109F0, 0x00810A80, 0x00810B10, 0x00812BC0, 0x00812C50, 0x00814910, 0x0081A620, 0x00848800, 0x0084B570, 0x00876550, 0x00877760, 0x0087B0F0]
// OFFSET: [0x0047C630, 0x0047C6C0, 0x00490BE0, 0x004967E0, 0x004B74F0, 0x004BAFD0, 0x004BC2F0, 0x004BC380, 0x004BE2D0, 0x004C0260, 0x004C9520, 0x004CA720, 0x004CC6F0, 0x004CC780, 0x004CDDD0, 0x004CF070, 0x004D0A70, 0x004D3130, 0x004D33C0, 0x004D4E10, 0x004F31F0, 0x00502360, 0x005032A0, 0x00503330, 0x005033C0, 0x00503450, 0x005053E0, 0x00527BF0, 0x00527C80, 0x00527E70, 0x0052F100, 0x0053F160, 0x00548B70, 0x00558C50, 0x00558CE0, 0x0055F560, 0x0055F5F0, 0x0055F680, 0x0055F710, 0x0055F7A0, 0x00566700, 0x00575F60, 0x005920F0, 0x005B4DE0, 0x005B4E70, 0x005BE830, 0x005BE8C0, 0x005C7290, 0x005C7320, 0x005D24E0, 0x005F03B0, 0x005F3E20, 0x005F5AD0, 0x005F5B60, 0x005F5BF0, 0x005FCB80, 0x00617AA0, 0x00617B30, 0x00617BC0, 0x0066E830, 0x0066E8C0, 0x0066E950, 0x0066E9E0, 0x0066EA70, 0x0066EB00, 0x0066EB90, 0x0066EC20, 0x0066ECB0, 0x0066ED40, 0x0066EDD0, 0x0066EE60, 0x0066EEF0, 0x0066EF80, 0x0066F010, 0x0066F0A0, 0x0066F130, 0x0066F1C0, 0x0066F250, 0x0066F2E0, 0x0066F370, 0x0066F400, 0x0066F490, 0x0066F520, 0x0066F5B0, 0x0066F640, 0x0066F6D0, 0x0066F760, 0x0066F7F0, 0x0066F880, 0x006881A0, 0x006BBE30, 0x006BEE90, 0x006C2650, 0x006C2AC0, 0x006C2B50, 0x006C8380, 0x006E4EB0, 0x006E4F40, 0x006F2C50, 0x006F2CE0, 0x006F2D70, 0x006F2E00, 0x006F2E90, 0x006F2F20, 0x006F2FB0, 0x00709AA0, 0x00709B30, 0x0072FFC0, 0x007675F0, 0x007685D0, 0x00776AD0, 0x007B04D0, 0x007B5DF0, 0x007C0B40, 0x007C0BD0, 0x007DD360, 0x007DD3F0, 0x007E01C0, 0x007F2A20, 0x007F4ED0, 0x00804EF0, 0x00804F80, 0x008109F0, 0x00810A80, 0x00810B10, 0x00812BC0, 0x00812C50, 0x00814910, 0x0081A620, 0x00848800, 0x0084B570, 0x00876550, 0x00877760, 0x0087B0F0, 0x0097BB80]
template <class T>
TSFixedArray<T>::~TSFixedArray() {
for (uint32_t i = 0; i < this->m_count; i++) {
@@ -687,7 +689,7 @@ void TSFixedArray<T>::ReallocAndClearData(uint32_t count) {
}
// VERIFY: e2efd710 manual
// OFFSET: [0x00403760, 0x004037F0, 0x00408340, 0x004083F0, 0x00408490, 0x00408D80, 0x004644C0, 0x004657D0, 0x00466910, 0x0047CCC0, 0x0047D9F0, 0x0047DA80, 0x00480EE0, 0x00490A80, 0x00493A40, 0x00493AD0, 0x00496680, 0x00497970, 0x00497A00, 0x004B7580, 0x004B9990, 0x004B9A20, 0x004BB060, 0x004BBDA0, 0x004BBF00, 0x004BC060, 0x004BE170, 0x004BEBB0, 0x004C00B0, 0x004C46C0, 0x004C4750, 0x004CA380, 0x004CB930, 0x004CB9C0, 0x004CC360, 0x004CC4C0, 0x004CDB20, 0x004CEA00, 0x004CEAA0, 0x004CEF00, 0x004D0910, 0x004D2D90, 0x004D34A0, 0x004D4FF0, 0x004D85A0, 0x004DE520, 0x004E0EC0, 0x004E25C0, 0x004E6660, 0x004F2FB0, 0x004FCFC0, 0x004FD050, 0x004FD150, 0x004FFCE0, 0x005014A0, 0x005023E0, 0x00502540, 0x005026A0, 0x00502800, 0x005034E0, 0x00514100, 0x005141A0, 0x0051A2E0, 0x00525720, 0x00525880, 0x00527D10, 0x0052EF00, 0x0053B790, 0x0053B820, 0x0053EFA0, 0x005436A0, 0x00548640, 0x005489C0, 0x0054EC50, 0x0054ECF0, 0x00553220, 0x005532C0, 0x00553350, 0x005533E0, 0x00558710, 0x00558870, 0x0055EAD0, 0x0055EC30, 0x0055ED90, 0x0055EEF0, 0x0055F050, 0x00564CE0, 0x00566790, 0x005685D0, 0x0056BAD0, 0x0056BD40, 0x0056D780, 0x0056D810, 0x00575DC0, 0x00577410, 0x0057C120, 0x0057C1B0, 0x0057E360, 0x0057E400, 0x0058E030, 0x0058F8F0, 0x005907A0, 0x00590870, 0x00590920, 0x005909C0, 0x00590A60, 0x00591F70, 0x00593FC0, 0x00594050, 0x00599030, 0x0059B150, 0x0059B1F0, 0x005A2AF0, 0x005A46F0, 0x005B49B0, 0x005B4B10, 0x005B8C80, 0x005BDF60, 0x005BE0C0, 0x005C58D0, 0x005C5960, 0x005C6C60, 0x005C6DC0, 0x005C9080, 0x005CA3D0, 0x005CD240, 0x005CD2D0, 0x005CEB50, 0x005CFFB0, 0x005D0080, 0x005D0110, 0x005D2360, 0x005D3260, 0x005DA3F0, 0x005DA480, 0x005DA510, 0x005E6E40, 0x005E7940, 0x005ED620, 0x005EEB80, 0x005F0240, 0x005F1420, 0x005F39B0, 0x005F4E30, 0x005F5020, 0x005F5180, 0x005F52E0, 0x005FC9C0, 0x005FEF70, 0x0060A1C0, 0x0060A260, 0x006152E0, 0x006169A0, 0x00616C20, 0x00617280, 0x006173E0, 0x00617540, 0x0061BD20, 0x0061BDB0, 0x00634790, 0x00634820, 0x00669EB0, 0x0066CD10, 0x0066CE70, 0x0066CFD0, 0x0066D130, 0x0066D290, 0x0066D3F0, 0x0066D550, 0x0066D6B0, 0x0066D810, 0x0066D970, 0x0066DAD0, 0x0066DC30, 0x0066DD90, 0x0066DEF0, 0x0066E050, 0x00681800, 0x006822B0, 0x00683760, 0x00683810, 0x006838B0, 0x00683960, 0x00688040, 0x00689F90, 0x006A54A0, 0x006A9440, 0x006B1EF0, 0x006BA590, 0x006BBBE0, 0x006C26E0, 0x006C2840, 0x006C4210, 0x006C4E20, 0x006C5EE0, 0x006C5F80, 0x006C6020, 0x006C8220, 0x006C9DF0, 0x006CF4A0, 0x006CF540, 0x006CF5E0, 0x006E4BF0, 0x006E4D50, 0x006F2120, 0x006F2280, 0x006F23E0, 0x006F2540, 0x006F26A0, 0x006F2800, 0x006F2960, 0x006FECD0, 0x00709580, 0x007096E0, 0x00716260, 0x00716300, 0x007163B0, 0x0072FE60, 0x00746400, 0x00747C10, 0x00747CA0, 0x007583D0, 0x00767490, 0x00768460, 0x00769D80, 0x0076D060, 0x007760A0, 0x00776950, 0x00786B90, 0x00790250, 0x007902E0, 0x00790370, 0x007917D0, 0x00791870, 0x0079B370, 0x0079BA30, 0x0079D510, 0x0079F650, 0x007A01C0, 0x007B0370, 0x007B0D60, 0x007B0DF0, 0x007B0E80, 0x007B4F10, 0x007BA120, 0x007BDFE0, 0x007BE140, 0x007C30B0, 0x007CC020, 0x007CCBE0, 0x007CCC80, 0x007CDEC0, 0x007DBB10, 0x007DBBC0, 0x007DD0A0, 0x007DD200, 0x007E0050, 0x007E6600, 0x007E7FF0, 0x007EBEA0, 0x007ECFF0, 0x007F1F80, 0x007F3BF0, 0x007F3D70, 0x007F4CF0, 0x007F78F0, 0x007F79C0, 0x007F8E30, 0x007F9F80, 0x007FA020, 0x007FA0B0, 0x00804830, 0x00804990, 0x00810370, 0x00810500, 0x00810660, 0x008107C0, 0x008128D0, 0x00812A30, 0x00814800, 0x008196A0, 0x0081A2F0, 0x0081CDC0, 0x00824660, 0x00824700, 0x0084B140, 0x0084B2A0, 0x008555E0, 0x0086D0E0, 0x0086E8E0, 0x008704B0, 0x00876370, 0x00878E90, 0x00878F30, 0x0087AEB0, 0x00887490, 0x008A17D0, 0x008A1860, 0x008A18F0, 0x00959260, 0x0095E2C0, 0x00967E50, 0x00967EF0, 0x009690F0, 0x00969540, 0x0097BBE0, 0x0097F650, 0x00980EE0, 0x009A80F0, 0x009A8D50, 0x009A8DF0]
// OFFSET: [0x00403760, 0x004037F0, 0x00408340, 0x004083F0, 0x00408490, 0x00408D80, 0x004644C0, 0x004657D0, 0x00466910, 0x0047CCC0, 0x0047D9F0, 0x0047DA80, 0x00480EE0, 0x00490A80, 0x00493A40, 0x00493AD0, 0x00496680, 0x00497970, 0x00497A00, 0x004B7580, 0x004B9990, 0x004B9A20, 0x004BB060, 0x004BBDA0, 0x004BBF00, 0x004BC060, 0x004BE170, 0x004BEBB0, 0x004C00B0, 0x004C46C0, 0x004C4750, 0x004CA380, 0x004CB930, 0x004CB9C0, 0x004CC360, 0x004CC4C0, 0x004CDB20, 0x004CEA00, 0x004CEAA0, 0x004CEF00, 0x004D0910, 0x004D2D90, 0x004D34A0, 0x004D4FF0, 0x004D85A0, 0x004DE520, 0x004E0EC0, 0x004E25C0, 0x004E6660, 0x004F2FB0, 0x004FCFC0, 0x004FD050, 0x004FD150, 0x004FFCE0, 0x005014A0, 0x005023E0, 0x00502540, 0x005026A0, 0x00502800, 0x005034E0, 0x00514100, 0x005141A0, 0x0051A2E0, 0x00525720, 0x00525880, 0x00527D10, 0x0052EF00, 0x0053B790, 0x0053B820, 0x0053EFA0, 0x005436A0, 0x00548640, 0x005489C0, 0x0054EC50, 0x0054ECF0, 0x00553220, 0x005532C0, 0x00553350, 0x005533E0, 0x00558710, 0x00558870, 0x0055EAD0, 0x0055EC30, 0x0055ED90, 0x0055EEF0, 0x0055F050, 0x00564CE0, 0x00566790, 0x005685D0, 0x0056BAD0, 0x0056BD40, 0x0056D780, 0x0056D810, 0x00575DC0, 0x00577410, 0x0057C120, 0x0057C1B0, 0x0057E360, 0x0057E400, 0x0058E030, 0x0058F8F0, 0x005907A0, 0x00590870, 0x00590920, 0x005909C0, 0x00590A60, 0x00591F70, 0x00592180, 0x00592290, 0x00593FC0, 0x00594050, 0x00599030, 0x0059B150, 0x0059B1F0, 0x005A2AF0, 0x005A46F0, 0x005B49B0, 0x005B4B10, 0x005B8C80, 0x005BDF60, 0x005BE0C0, 0x005C58D0, 0x005C5960, 0x005C6C60, 0x005C6DC0, 0x005C9080, 0x005CA3D0, 0x005CD240, 0x005CD2D0, 0x005CEB50, 0x005CFFB0, 0x005D0080, 0x005D0110, 0x005D2360, 0x005D3260, 0x005DA3F0, 0x005DA480, 0x005DA510, 0x005E6E40, 0x005E7940, 0x005ED620, 0x005EEB80, 0x005F0240, 0x005F0440, 0x005F1420, 0x005F39B0, 0x005F4E30, 0x005F5020, 0x005F5180, 0x005F52E0, 0x005FC9C0, 0x005FEF70, 0x0060A1C0, 0x0060A260, 0x006152E0, 0x006169A0, 0x00616C20, 0x00617280, 0x006173E0, 0x00617540, 0x0061BD20, 0x0061BDB0, 0x00634790, 0x00634820, 0x00669EB0, 0x0066CD10, 0x0066CE70, 0x0066CFD0, 0x0066D130, 0x0066D290, 0x0066D3F0, 0x0066D550, 0x0066D6B0, 0x0066D810, 0x0066D970, 0x0066DAD0, 0x0066DC30, 0x0066DD90, 0x0066DEF0, 0x0066E050, 0x00681800, 0x006822B0, 0x00683760, 0x00683810, 0x006838B0, 0x00683960, 0x00688040, 0x00689F90, 0x006A54A0, 0x006A9440, 0x006B1EF0, 0x006BA590, 0x006BBBE0, 0x006C26E0, 0x006C2840, 0x006C4210, 0x006C4E20, 0x006C5EE0, 0x006C5F80, 0x006C6020, 0x006C8220, 0x006C9DF0, 0x006CF4A0, 0x006CF540, 0x006CF5E0, 0x006E4BF0, 0x006E4D50, 0x006F2120, 0x006F2280, 0x006F23E0, 0x006F2540, 0x006F26A0, 0x006F2800, 0x006F2960, 0x006FECD0, 0x00709580, 0x007096E0, 0x00716260, 0x00716300, 0x007163B0, 0x0072FE60, 0x00746400, 0x00747C10, 0x00747CA0, 0x007583D0, 0x00767490, 0x00768460, 0x00769D80, 0x0076D060, 0x007760A0, 0x00776950, 0x00786B90, 0x00790250, 0x007902E0, 0x00790370, 0x007917D0, 0x00791870, 0x0079B370, 0x0079BA30, 0x0079D510, 0x0079F650, 0x007A01C0, 0x007B0370, 0x007B0D60, 0x007B0DF0, 0x007B0E80, 0x007B4F10, 0x007BA120, 0x007BDFE0, 0x007BE140, 0x007C30B0, 0x007CC020, 0x007CCBE0, 0x007CCC80, 0x007CDEC0, 0x007DBB10, 0x007DBBC0, 0x007DD0A0, 0x007DD200, 0x007E0050, 0x007E6600, 0x007E7FF0, 0x007EBEA0, 0x007ECFF0, 0x007F1F80, 0x007F3BF0, 0x007F3D70, 0x007F4CF0, 0x007F78F0, 0x007F79C0, 0x007F8E30, 0x007F9F80, 0x007FA020, 0x007FA0B0, 0x00804830, 0x00804990, 0x00810370, 0x00810500, 0x00810660, 0x008107C0, 0x008128D0, 0x00812A30, 0x00814800, 0x008196A0, 0x0081A2F0, 0x0081CDC0, 0x00824660, 0x00824700, 0x00848890, 0x0084B140, 0x0084B2A0, 0x008555E0, 0x0086D0E0, 0x0086E8E0, 0x008704B0, 0x00876370, 0x00878E90, 0x00878F30, 0x0087AEB0, 0x00887490, 0x008A17D0, 0x008A1860, 0x008A18F0, 0x00959260, 0x0095E2C0, 0x00967E50, 0x00967EF0, 0x009690F0, 0x00969540, 0x00978EC0, 0x0097BBE0, 0x0097F650, 0x00980EE0, 0x009A80F0, 0x009A8D50, 0x009A8DF0]
template <class T>
void TSFixedArray<T>::ReallocData(uint32_t count) {
T* olddata = this->m_data;
@@ -729,7 +731,7 @@ void TSFixedArray<T>::Set(uint32_t count, const T* data) {
}
// VERIFY: 30433c72 manual
// OFFSET: [0x00464B30, 0x00465AC0, 0x004670D0, 0x004957B0, 0x004F5840, 0x00599820, 0x006171B0, 0x0061F9C0, 0x006C0270, 0x006CA0B0, 0x0079E080, 0x007F1220, 0x007F1EA0, 0x007F1F20, 0x009AAF10]
// OFFSET: [0x00464B30, 0x00465AC0, 0x004670D0, 0x004957B0, 0x004D0B00, 0x004F5840, 0x00599820, 0x006171B0, 0x0061F9C0, 0x006C0270, 0x006CA0B0, 0x0079E080, 0x007F1220, 0x007F1EA0, 0x007F1F20, 0x009AAF10]
template <class T>
void TSFixedArray<T>::SetCount(uint32_t count) {
if (count != this->m_count) {
@@ -764,7 +766,7 @@ TSGrowableArray<T>::TSGrowableArray() {
}
// VERIFY: d0bba67f manual
// OFFSET: [0x0057FCB0, 0x0057FD50, 0x0057FEA0, 0x0061F7F0, 0x006BADD0, 0x006C6550, 0x006C6760, 0x0071C780, 0x0071C830, 0x00723410, 0x00758630, 0x00791EB0, 0x00791F80, 0x007920A0, 0x007940F0, 0x007A3DB0, 0x007A8E90, 0x007CD140, 0x007CD3F0]
// OFFSET: [0x004BBE20, 0x0057FCB0, 0x0057FD50, 0x0057FEA0, 0x0061F7F0, 0x006BADD0, 0x006C6550, 0x006C6760, 0x0071C780, 0x0071C830, 0x00723410, 0x00758630, 0x00791EB0, 0x00791F80, 0x007920A0, 0x007940F0, 0x007A3DB0, 0x007A8E90, 0x007CD140, 0x007CD3F0]
template <class T>
uint32_t TSGrowableArray<T>::Add(uint32_t count, const T* data) {
uint32_t newcount = this->m_count + count;
@@ -929,7 +931,7 @@ void TSGrowableArray<T>::Reserve(uint32_t count, int32_t round) {
}
// VERIFY: aa735f18 auto
// OFFSET: [0x00409280, 0x0040AFE0, 0x00481030, 0x004845F0, 0x004920B0, 0x004949C0, 0x004969C0, 0x004B8610, 0x004BB540, 0x004BC4A0, 0x004BC5B0, 0x004BE360, 0x004C05B0, 0x004C4B80, 0x004CABE0, 0x004CC810, 0x004CC920, 0x004CDE60, 0x004CEC60, 0x004CF320, 0x004D6640, 0x004D99F0, 0x004E1BD0, 0x004F3280, 0x00500EC0, 0x00500F10, 0x005031B0, 0x005054F0, 0x00505600, 0x00505710, 0x00505820, 0x00506210, 0x00522220, 0x00528700, 0x00528810, 0x00529BC0, 0x0052F1F0, 0x0053F440, 0x005462C0, 0x00548C00, 0x00556DC0, 0x005595E0, 0x005596F0, 0x0055FDB0, 0x0055FEC0, 0x0055FFD0, 0x005600E0, 0x005601F0, 0x00565490, 0x00567830, 0x0056BC00, 0x005714D0, 0x00575FF0, 0x0057F5D0, 0x0057F6E0, 0x0057FDD0, 0x0057FF20, 0x0058EC40, 0x00591760, 0x00591910, 0x005923A0, 0x0059DF60, 0x005B5310, 0x005B5420, 0x005BF870, 0x005BF980, 0x005C8310, 0x005C8420, 0x005CC510, 0x005CF530, 0x005D2570, 0x005D5A60, 0x005DCA90, 0x005EFFD0, 0x005F0570, 0x005F3ED0, 0x005F5C80, 0x005F5D90, 0x005F5EA0, 0x005FCC60, 0x00603930, 0x006156C0, 0x00616CA0, 0x00616D70, 0x00617CE0, 0x00617DF0, 0x00617F00, 0x006700E0, 0x00671CB0, 0x00671DC0, 0x00671ED0, 0x00671FE0, 0x006720F0, 0x00672200, 0x00672310, 0x00672420, 0x00672530, 0x00672640, 0x00672750, 0x00672860, 0x00672970, 0x00672A80, 0x00672B90, 0x00682790, 0x00682A40, 0x00685180, 0x00685E40, 0x00688450, 0x0068A0F0, 0x006BC250, 0x006C2E60, 0x006C2F70, 0x006C49B0, 0x006C59D0, 0x006C65E0, 0x006C6800, 0x006C6A20, 0x006C8410, 0x006DECC0, 0x006E6920, 0x006E6A30, 0x006F31A0, 0x006F32B0, 0x006F33C0, 0x006F34D0, 0x006F35E0, 0x006F36F0, 0x006F3800, 0x00700CF0, 0x00709BC0, 0x00709CD0, 0x00723170, 0x007233C0, 0x00734800, 0x00767AB0, 0x00768B00, 0x0076D260, 0x00776CF0, 0x00788930, 0x00791F30, 0x00792010, 0x00792130, 0x00793FD0, 0x00794190, 0x0079F980, 0x007A02F0, 0x007B06F0, 0x007B25B0, 0x007B2710, 0x007BA250, 0x007BE2A0, 0x007BE3B0, 0x007CD250, 0x007CD470, 0x007DD480, 0x007DD590, 0x007E02E0, 0x007E6EF0, 0x007F2AB0, 0x007F4A70, 0x007F4F60, 0x007FB220, 0x008076C0, 0x008077D0, 0x00810BA0, 0x00810CB0, 0x00810DC0, 0x00812D40, 0x00812E50, 0x008149E0, 0x0081AB60, 0x0082DAC0, 0x0082DBC0, 0x0084B600, 0x0084B710, 0x0086EED0, 0x008765E0, 0x008798B0, 0x0087BB70, 0x00968390, 0x00969800, 0x00969B80, 0x0097D600, 0x0097DF90, 0x00980810]
// OFFSET: [0x00409280, 0x0040AFE0, 0x00481030, 0x004845F0, 0x004920B0, 0x004949C0, 0x004969C0, 0x004B8610, 0x004BB540, 0x004BC4A0, 0x004BC5B0, 0x004BE360, 0x004C05B0, 0x004C4B80, 0x004C4C80, 0x004CABE0, 0x004CC810, 0x004CC920, 0x004CDE60, 0x004CEC60, 0x004CF320, 0x004D6640, 0x004D99F0, 0x004E1BD0, 0x004F3280, 0x00500EC0, 0x00500F10, 0x005031B0, 0x005054F0, 0x00505600, 0x00505710, 0x00505820, 0x00506210, 0x00522220, 0x00528700, 0x00528810, 0x00529BC0, 0x0052F1F0, 0x0053F440, 0x005462C0, 0x00548C00, 0x00556DC0, 0x005595E0, 0x005596F0, 0x0055FDB0, 0x0055FEC0, 0x0055FFD0, 0x005600E0, 0x005601F0, 0x00565490, 0x00567830, 0x0056BC00, 0x005714D0, 0x00575FF0, 0x0057F5D0, 0x0057F6E0, 0x0057FDD0, 0x0057FF20, 0x0058EC40, 0x00591760, 0x00591910, 0x005923A0, 0x0059DF60, 0x005B5310, 0x005B5420, 0x005BF870, 0x005BF980, 0x005C8310, 0x005C8420, 0x005CC510, 0x005CF530, 0x005D2570, 0x005D5A60, 0x005DCA90, 0x005EFFD0, 0x005F0570, 0x005F0680, 0x005F3ED0, 0x005F5C80, 0x005F5D90, 0x005F5EA0, 0x005FCC60, 0x00603930, 0x006156C0, 0x00616CA0, 0x00616D70, 0x00617CE0, 0x00617DF0, 0x00617F00, 0x006700E0, 0x00671CB0, 0x00671DC0, 0x00671ED0, 0x00671FE0, 0x006720F0, 0x00672200, 0x00672310, 0x00672420, 0x00672530, 0x00672640, 0x00672750, 0x00672860, 0x00672970, 0x00672A80, 0x00672B90, 0x00682790, 0x00682A40, 0x00685180, 0x00685E40, 0x00688450, 0x0068A0F0, 0x006BC250, 0x006C2E60, 0x006C2F70, 0x006C49B0, 0x006C59D0, 0x006C65E0, 0x006C6800, 0x006C6A20, 0x006C8410, 0x006DECC0, 0x006E6920, 0x006E6A30, 0x006F31A0, 0x006F32B0, 0x006F33C0, 0x006F34D0, 0x006F35E0, 0x006F36F0, 0x006F3800, 0x00700CF0, 0x00709BC0, 0x00709CD0, 0x00723170, 0x007233C0, 0x00734800, 0x00767AB0, 0x00768B00, 0x0076D260, 0x00776CF0, 0x00788930, 0x00791F30, 0x00792010, 0x00792130, 0x00793FD0, 0x00794190, 0x0079F980, 0x007A02F0, 0x007B06F0, 0x007B25B0, 0x007B2710, 0x007BA250, 0x007BE2A0, 0x007BE3B0, 0x007CD250, 0x007CD470, 0x007DD480, 0x007DD590, 0x007E02E0, 0x007E6EF0, 0x007F2AB0, 0x007F4A70, 0x007F4F60, 0x007FB220, 0x008076C0, 0x008077D0, 0x00810BA0, 0x00810CB0, 0x00810DC0, 0x00812D40, 0x00812E50, 0x008149E0, 0x0081AB60, 0x0082DAC0, 0x0082DBC0, 0x0084B600, 0x0084B710, 0x0086EED0, 0x008765E0, 0x008798B0, 0x0087BB70, 0x00968390, 0x00969800, 0x00969B80, 0x0097D600, 0x0097DF90, 0x00980810]
template <class T>
void TSGrowableArray<T>::SetCount(uint32_t count) {
if (count > this->m_count) {
@@ -957,7 +959,7 @@ void TSGrowableArray<T>::SetCount(uint32_t count) {
}
// VERIFY: 8457e24c auto
// OFFSET: 0x0047C560
// OFFSET: [0x0047C560, 0x005C6800]
template <class T, class TKey>
TSHashObject<T, TKey>::~TSHashObject() {
}
@@ -978,7 +980,7 @@ T* TSHashTable<T, TKey>::InternalNew(TSExplicitList<T>* listptr, size_t extrabyt
}
// VERIFY: 4a402d4d manual
// OFFSET: [0x0047C870, 0x0047CA60, 0x004921C0, 0x00496AD0, 0x004B84E0, 0x004BB410, 0x004BC6C0, 0x004BC930, 0x004BE5C0, 0x004C0890, 0x004CAE00, 0x004CCBB0, 0x004CCDA0, 0x004CE3C0, 0x004CF590, 0x004D6040, 0x004F34D0, 0x00506110, 0x00506430, 0x00506630, 0x00506830, 0x00529750, 0x00529850, 0x00529A60, 0x0052F400, 0x0053F770, 0x00549040, 0x0055A270, 0x0055A480, 0x00560700, 0x005608A0, 0x00560AB0, 0x00560CB0, 0x00560EA0, 0x00567700, 0x00576330, 0x00592E00, 0x005B64F0, 0x005B6690, 0x005C1690, 0x005C1880, 0x005C8820, 0x005D27C0, 0x005F0850, 0x005F40E0, 0x005F5FB0, 0x005F6240, 0x005F6400, 0x005FCE70, 0x00618450, 0x00618680, 0x006188A0, 0x00672CA0, 0x00672E50, 0x00672F50, 0x00673100, 0x00673200, 0x006733B0, 0x006734B0, 0x00673660, 0x00673760, 0x00673910, 0x00673A10, 0x00673BD0, 0x00673CD0, 0x00673E70, 0x00673F70, 0x00674110, 0x00674210, 0x006743C0, 0x006744C0, 0x00674670, 0x00674770, 0x00674910, 0x00674A10, 0x00674BB0, 0x00674CB0, 0x00674E50, 0x00674F50, 0x006750F0, 0x006751F0, 0x006753B0, 0x00688560, 0x006BC390, 0x006BF030, 0x006C2D30, 0x006C3180, 0x006C8620, 0x006E66C0, 0x006E67C0, 0x006F3AD0, 0x006F3C70, 0x006F3EC0, 0x006F40C0, 0x006F4310, 0x006F44D0, 0x006F4690, 0x00709F60, 0x0070A150, 0x00734910, 0x00767BC0, 0x00768D00, 0x00776E00, 0x007B0860, 0x007B71F0, 0x007C0E60, 0x007C0F60, 0x007DD840, 0x007DDA30, 0x007E04E0, 0x007F2CC0, 0x007F5400, 0x0080A430, 0x0080A620, 0x008110B0, 0x008112A0, 0x008114A0, 0x008132F0, 0x008134E0, 0x0081AFD0, 0x0084A1B0, 0x0084B910, 0x008767E0, 0x00877910, 0x0087C0A0]
// OFFSET: [0x0047C870, 0x0047CA60, 0x004921C0, 0x00496AD0, 0x004B84E0, 0x004BB410, 0x004BB510, 0x004BC6C0, 0x004BC930, 0x004BCA30, 0x004BCA60, 0x004BE5C0, 0x004BE6C0, 0x004C0890, 0x004C0990, 0x004C95B0, 0x004C97F0, 0x004CAE00, 0x004CAF00, 0x004CCBB0, 0x004CCDA0, 0x004CCEA0, 0x004CCED0, 0x004CE3C0, 0x004CE4C0, 0x004CF590, 0x004CF690, 0x004D6040, 0x004F34D0, 0x00506110, 0x00506430, 0x00506630, 0x00506830, 0x00529750, 0x00529850, 0x00529A60, 0x0052F400, 0x0053F770, 0x00549040, 0x0055A270, 0x0055A480, 0x00560700, 0x005608A0, 0x00560AB0, 0x00560CB0, 0x00560EA0, 0x00567700, 0x00576330, 0x00592E00, 0x005B64F0, 0x005B6690, 0x005C1690, 0x005C1880, 0x005C8820, 0x005D27C0, 0x005F0850, 0x005F40E0, 0x005F5FB0, 0x005F6240, 0x005F6400, 0x005FCE70, 0x00618450, 0x00618680, 0x006188A0, 0x00672CA0, 0x00672E50, 0x00672F50, 0x00673100, 0x00673200, 0x006733B0, 0x006734B0, 0x00673660, 0x00673760, 0x00673910, 0x00673A10, 0x00673BD0, 0x00673CD0, 0x00673E70, 0x00673F70, 0x00674110, 0x00674210, 0x006743C0, 0x006744C0, 0x00674670, 0x00674770, 0x00674910, 0x00674A10, 0x00674BB0, 0x00674CB0, 0x00674E50, 0x00674F50, 0x006750F0, 0x006751F0, 0x006753B0, 0x00688560, 0x006BC390, 0x006BF030, 0x006C2D30, 0x006C3180, 0x006C8620, 0x006E66C0, 0x006E67C0, 0x006F3AD0, 0x006F3C70, 0x006F3EC0, 0x006F40C0, 0x006F4310, 0x006F44D0, 0x006F4690, 0x00709F60, 0x0070A150, 0x00734910, 0x00767BC0, 0x00768D00, 0x00776E00, 0x007B0860, 0x007B71F0, 0x007C0E60, 0x007C0F60, 0x007DD840, 0x007DDA30, 0x007E04E0, 0x007F2CC0, 0x007F5400, 0x0080A430, 0x0080A620, 0x008110B0, 0x008112A0, 0x008114A0, 0x008132F0, 0x008134E0, 0x0081AFD0, 0x0084A1B0, 0x0084B910, 0x008767E0, 0x00877910, 0x0087C0A0]
template <class T, class TKey>
TSHashTable<T, TKey>::~TSHashTable() {
this->InternalClear(1);
@@ -1210,7 +1212,7 @@ T* TSHashTable<T, TKey>::New(const char* str, size_t extrabytes, uint32_t flags)
}
// VERIFY: cb777ac9 manual
// OFFSET: [0x004B6D90, 0x004BB1E0, 0x006BBD40, 0x006C2A50, 0x006F6020, 0x007B0690, 0x007BDD80, 0x007BDDF0]
// OFFSET: [0x004B6D90, 0x004BB1E0, 0x00505480, 0x006BBD40, 0x006C2A50, 0x006F6020, 0x007B0690, 0x007BDD80, 0x007BDDF0, 0x00810970]
template <class T, class TKey>
T* TSHashTable<T, TKey>::Ptr(uint32_t hashval, const TKey& key) {
if (this->m_slotmask == 0xFFFFFFFF) {
@@ -1229,7 +1231,7 @@ T* TSHashTable<T, TKey>::Ptr(uint32_t hashval, const TKey& key) {
}
// VERIFY: fca99b11 manual
// OFFSET: [0x004BE0E0, 0x0053F3B0, 0x0055F4D0, 0x00687870, 0x006C8100, 0x007E0250]
// OFFSET: [0x004BC410, 0x004BE0E0, 0x0053F3B0, 0x0055F4D0, 0x00617C50, 0x00687870, 0x006C8100, 0x007E0250]
template <class T, class TKey>
T* TSHashTable<T, TKey>::Ptr(const char* str) {
if (this->m_slotmask == 0xFFFFFFFF) {
@@ -1249,7 +1251,7 @@ T* TSHashTable<T, TKey>::Ptr(const char* str) {
}
// VERIFY: b253b260 manual
// OFFSET: [0x00565030, 0x00685230]
// OFFSET: [0x004D4790, 0x00565030, 0x00685230]
template <class T, class TKey>
void TSHashTable<T, TKey>::Unlink(T* ptr) {
if (ptr->m_linktoslot.IsLinked()) {
@@ -1266,7 +1268,7 @@ TSHashTableReuse<T, TKey>::TSHashTableReuse() {
}
// VERIFY: dcbf18cd manual
// OFFSET: [0x004B8F10, 0x004BB710, 0x004C0D30, 0x006BC830, 0x007772F0]
// OFFSET: [0x004B8F10, 0x004B8F70, 0x004BB710, 0x004BB770, 0x004C0D30, 0x004C0D90, 0x006BC830, 0x007772F0]
template <class T, class TKey>
TSHashTableReuse<T, TKey>::~TSHashTableReuse() {
this->Destructor();
@@ -1360,6 +1362,12 @@ T* TSExportTableSimpleReuse<T, THandle>::Ptr(THandle handle) {
return TSHashTable<T, HASHKEY_NONE>::Ptr(static_cast<uint32_t>(reinterpret_cast<uintptr_t>(handle)), this->m_key);
}
// VERIFY: 252836f7 auto
// OFFSET: 0x00777900
template <class T, class THandle, class TLockedHandle, class TSync>
TSExportTableSyncReuse<T, THandle, TLockedHandle, TSync>::~TSExportTableSyncReuse() {
}
// VERIFY: 21249c03 manual
// OFFSET: 0x007778A0
template <class T, class THandle, class TLockedHandle, class TSync>
@@ -0,0 +1,85 @@
#ifndef ENGINE_SOURCE_STORM_SOURCE_IOUNIT_IOFILEUNIT_H
#define ENGINE_SOURCE_STORM_SOURCE_IOUNIT_IOFILEUNIT_H
#include <cstddef>
#include <cstdint>
namespace Storm {
class IORefcount {
public:
void Release();
};
struct IOFileParam {
/* 0000 */ const char* m_name;
/* 0004 */ uint32_t m_access;
/* 0008 */ uint32_t m_share;
/* 000C */ uint32_t m_creation;
/* 0010 */ uint32_t m_flags;
};
class IOUnit {
public:
/* 0004 */ IORefcount* m_refcount;
/* 0008 */ int32_t m_count;
IOUnit();
virtual ~IOUnit();
virtual bool Read(void* buffer, int64_t offset, uint32_t count, uint32_t* bytesRead) = 0;
virtual bool Write(const void* buffer, int64_t offset, uint32_t count) = 0;
virtual bool Flush() = 0;
virtual bool GetFileSize(int64_t* size) = 0;
virtual bool SetFileSize(int64_t size) = 0;
virtual void* Win32Handle() = 0;
void Release();
};
class IOWin32FileUnit : public IOUnit {
public:
static IOWin32FileUnit* Open(const IOFileParam* param);
/* 000C */ void* m_handle;
/* 0010 */ int64_t m_position;
IOWin32FileUnit(void* handle);
virtual ~IOWin32FileUnit();
virtual bool Read(void* buffer, int64_t offset, uint32_t count, uint32_t* bytesRead);
virtual bool Write(const void* buffer, int64_t offset, uint32_t count);
virtual bool Flush();
virtual bool GetFileSize(int64_t* size);
virtual bool SetFileSize(int64_t size);
virtual void* Win32Handle();
bool Seek(int64_t offset);
};
class IOUnbufferedFileUnit : public IOUnit {
public:
static IOUnbufferedFileUnit* Open(const IOFileParam* param);
/* 000C */ IOUnit* m_unit;
/* 0010 */ int64_t m_size;
/* 0018 */ void* m_buffer;
/* 001C */ uint32_t m_alignMask;
/* 0020 */ char m_path[260];
IOUnbufferedFileUnit(void* handle, const IOFileParam* param);
virtual ~IOUnbufferedFileUnit();
virtual bool Read(void* buffer, int64_t offset, uint32_t count, uint32_t* bytesRead);
virtual bool Write(const void* buffer, int64_t offset, uint32_t count);
virtual bool Flush();
virtual bool GetFileSize(int64_t* size);
virtual bool SetFileSize(int64_t size);
virtual void* Win32Handle();
};
class IOFileUnit {
public:
static IOUnit* Create(const IOFileParam& param, IOUnit* next);
};
}
#endif
+192
View File
@@ -2,6 +2,38 @@
#include <cstring>
#include "MD5.h"
#define S11 7
#define S12 12
#define S13 17
#define S14 22
#define S21 5
#define S22 9
#define S23 14
#define S24 20
#define S31 4
#define S32 11
#define S33 16
#define S34 23
#define S41 6
#define S42 10
#define S43 15
#define S44 21
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
#define FF(a, b, c, d, x, s, ac) { (a) += F((b), (c), (d)) + (x) + (uint32_t)(ac); (a) = ROTATE_LEFT((a), (s)); (a) += (b); }
#define GG(a, b, c, d, x, s, ac) { (a) += G((b), (c), (d)) + (x) + (uint32_t)(ac); (a) = ROTATE_LEFT((a), (s)); (a) += (b); }
#define HH(a, b, c, d, x, s, ac) { (a) += H((b), (c), (d)) + (x) + (uint32_t)(ac); (a) = ROTATE_LEFT((a), (s)); (a) += (b); }
#define II(a, b, c, d, x, s, ac) { (a) += I((b), (c), (d)) + (x) + (uint32_t)(ac); (a) = ROTATE_LEFT((a), (s)); (a) += (b); }
// STATIC: 0x00ADE968
static uint8_t PADDING[64] = { 0x80 };
// VERIFY: 6581b87a manual
// OFFSET: 0x007709F0
uint8_t* MD5::ToArray(uint8_t* array) const {
@@ -45,3 +77,163 @@ const MD5& MD5::operator=(const char* str) {
MD5::MD5(char* str) {
*this = str;
}
// INLINED
static void Decode(uint32_t* output, const uint8_t* input, uint32_t len) {
for (uint32_t i = 0, j = 0; j < len; i++, j += 4) {
output[i] = static_cast<uint32_t>(input[j]) | (static_cast<uint32_t>(input[j + 1]) << 8) | (static_cast<uint32_t>(input[j + 2]) << 16) | (static_cast<uint32_t>(input[j + 3]) << 24);
}
}
// INLINED
static void Encode(uint8_t* output, const uint32_t* input, uint32_t len) {
for (uint32_t i = 0, j = 0; j < len; i++, j += 4) {
output[j] = static_cast<uint8_t>(input[i] & 0xFF);
output[j + 1] = static_cast<uint8_t>((input[i] >> 8) & 0xFF);
output[j + 2] = static_cast<uint8_t>((input[i] >> 16) & 0xFF);
output[j + 3] = static_cast<uint8_t>((input[i] >> 24) & 0xFF);
}
}
// VERIFY: fb13b4ee auto
// OFFSET: 0x00779340
void MD5Init(MD5_CTX* context) {
context->count[0] = context->count[1] = 0;
context->state[0] = 0x67452301;
context->state[1] = 0xEFCDAB89;
context->state[2] = 0x98BADCFE;
context->state[3] = 0x10325476;
}
// VERIFY: d05abf4a manual
// OFFSET: 0x00779370
static void MD5Transform(uint32_t state[4], const uint8_t block[64]) {
uint32_t a = state[0];
uint32_t b = state[1];
uint32_t c = state[2];
uint32_t d = state[3];
uint32_t x[16];
Decode(x, block, 64);
FF(a, b, c, d, x[0], S11, 0xD76AA478);
FF(d, a, b, c, x[1], S12, 0xE8C7B756);
FF(c, d, a, b, x[2], S13, 0x242070DB);
FF(b, c, d, a, x[3], S14, 0xC1BDCEEE);
FF(a, b, c, d, x[4], S11, 0xF57C0FAF);
FF(d, a, b, c, x[5], S12, 0x4787C62A);
FF(c, d, a, b, x[6], S13, 0xA8304613);
FF(b, c, d, a, x[7], S14, 0xFD469501);
FF(a, b, c, d, x[8], S11, 0x698098D8);
FF(d, a, b, c, x[9], S12, 0x8B44F7AF);
FF(c, d, a, b, x[10], S13, 0xFFFF5BB1);
FF(b, c, d, a, x[11], S14, 0x895CD7BE);
FF(a, b, c, d, x[12], S11, 0x6B901122);
FF(d, a, b, c, x[13], S12, 0xFD987193);
FF(c, d, a, b, x[14], S13, 0xA679438E);
FF(b, c, d, a, x[15], S14, 0x49B40821);
GG(a, b, c, d, x[1], S21, 0xF61E2562);
GG(d, a, b, c, x[6], S22, 0xC040B340);
GG(c, d, a, b, x[11], S23, 0x265E5A51);
GG(b, c, d, a, x[0], S24, 0xE9B6C7AA);
GG(a, b, c, d, x[5], S21, 0xD62F105D);
GG(d, a, b, c, x[10], S22, 0x02441453);
GG(c, d, a, b, x[15], S23, 0xD8A1E681);
GG(b, c, d, a, x[4], S24, 0xE7D3FBC8);
GG(a, b, c, d, x[9], S21, 0x21E1CDE6);
GG(d, a, b, c, x[14], S22, 0xC33707D6);
GG(c, d, a, b, x[3], S23, 0xF4D50D87);
GG(b, c, d, a, x[8], S24, 0x455A14ED);
GG(a, b, c, d, x[13], S21, 0xA9E3E905);
GG(d, a, b, c, x[2], S22, 0xFCEFA3F8);
GG(c, d, a, b, x[7], S23, 0x676F02D9);
GG(b, c, d, a, x[12], S24, 0x8D2A4C8A);
HH(a, b, c, d, x[5], S31, 0xFFFA3942);
HH(d, a, b, c, x[8], S32, 0x8771F681);
HH(c, d, a, b, x[11], S33, 0x6D9D6122);
HH(b, c, d, a, x[14], S34, 0xFDE5380C);
HH(a, b, c, d, x[1], S31, 0xA4BEEA44);
HH(d, a, b, c, x[4], S32, 0x4BDECFA9);
HH(c, d, a, b, x[7], S33, 0xF6BB4B60);
HH(b, c, d, a, x[10], S34, 0xBEBFBC70);
HH(a, b, c, d, x[13], S31, 0x289B7EC6);
HH(d, a, b, c, x[0], S32, 0xEAA127FA);
HH(c, d, a, b, x[3], S33, 0xD4EF3085);
HH(b, c, d, a, x[6], S34, 0x04881D05);
HH(a, b, c, d, x[9], S31, 0xD9D4D039);
HH(d, a, b, c, x[12], S32, 0xE6DB99E5);
HH(c, d, a, b, x[15], S33, 0x1FA27CF8);
HH(b, c, d, a, x[2], S34, 0xC4AC5665);
II(a, b, c, d, x[0], S41, 0xF4292244);
II(d, a, b, c, x[7], S42, 0x432AFF97);
II(c, d, a, b, x[14], S43, 0xAB9423A7);
II(b, c, d, a, x[5], S44, 0xFC93A039);
II(a, b, c, d, x[12], S41, 0x655B59C3);
II(d, a, b, c, x[3], S42, 0x8F0CCC92);
II(c, d, a, b, x[10], S43, 0xFFEFF47D);
II(b, c, d, a, x[1], S44, 0x85845DD1);
II(a, b, c, d, x[8], S41, 0x6FA87E4F);
II(d, a, b, c, x[15], S42, 0xFE2CE6E0);
II(c, d, a, b, x[6], S43, 0xA3014314);
II(b, c, d, a, x[13], S44, 0x4E0811A1);
II(a, b, c, d, x[4], S41, 0xF7537E82);
II(d, a, b, c, x[11], S42, 0xBD3AF235);
II(c, d, a, b, x[2], S43, 0x2AD7D2BB);
II(b, c, d, a, x[9], S44, 0xEB86D391);
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
memset(x, 0, sizeof(x));
}
// VERIFY: 2d3acce0 auto
// OFFSET: 0x00779A30
void MD5Update(MD5_CTX* context, const uint8_t* input, uint32_t inputLen) {
uint32_t index = (context->count[0] >> 3) & 0x3F;
if ((context->count[0] += inputLen << 3) < (inputLen << 3)) {
context->count[1]++;
}
context->count[1] += inputLen >> 29;
uint32_t partLen = 64 - index;
uint32_t i;
if (inputLen >= partLen) {
memcpy(&context->buffer[index], input, partLen);
MD5Transform(context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64) {
MD5Transform(context->state, &input[i]);
}
index = 0;
} else {
i = 0;
}
memcpy(&context->buffer[index], &input[i], inputLen - i);
}
// VERIFY: 9952e256 manual
// OFFSET: 0x00779AE0
void MD5Final(uint8_t digest[16], MD5_CTX* context) {
uint8_t bits[8];
Encode(bits, context->count, 8);
uint32_t index = (context->count[0] >> 3) & 0x3F;
uint32_t padLen = index < 56 ? 56 - index : 120 - index;
MD5Update(context, PADDING, padLen);
MD5Update(context, bits, 8);
Encode(digest, context->state, 16);
memset(context, 0, sizeof(*context));
}
+78
View File
@@ -0,0 +1,78 @@
#include <cstddef>
#include <cstdint>
#include "Engine/Source/Storm/H/storm.h"
// STATIC: 0x00ADE9A8
static const uint32_t s_crcTable[256] = {
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D,
};
// VERIFY: d50433f4 manual
// OFFSET: 0x00779BA0
uint32_t SCrcBuffer(const void* buffer, uint32_t length, uint32_t* crc, uint32_t flags) {
uint32_t result = 0;
if (crc) {
result = *crc;
}
if (flags & SCRC_INITIALIZE) {
result = 0xFFFFFFFF;
}
if (flags & SCRC_PROCESS) {
const uint8_t* data = static_cast<const uint8_t*>(buffer);
for (uint32_t i = length; i; i--) {
result = s_crcTable[(result ^ *data) & 0xFF] ^ (result >> 8);
data++;
}
}
if (flags & SCRC_FINALIZE) {
result = ~result;
}
if (crc) {
*crc = result;
}
return result;
}
// VERIFY: 49bd5746 auto
// OFFSET: 0x00779C10
uint32_t STORMAPI SCrcCompute(const void* buffer, uint32_t length, uint32_t* crc, uint32_t flags) {
return SCrcBuffer(buffer, length, crc, flags);
}
@@ -0,0 +1,408 @@
#if defined(WOWDECOMP_ARCH_32)
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <windows.h>
#include "Engine/Source/Storm/Source/IOUnit/IOFileUnit.h"
#include "Engine/Source/Storm/H/storm.h"
#include "Engine/Source/Storm/Source/SOption.h"
namespace Storm {
// VERIFY: 691f0e24 auto
// OFFSET: 0x00779C30
static HANDLE OpenFileHandle(const IOFileParam* param) {
HANDLE handle;
if (g_opt.unicodeenabled) {
WCHAR widename[MAX_PATH];
SUniConvertUTF8to16(reinterpret_cast<uint16_t*>(widename), MAX_PATH, param->m_name, STORM_MAX_STR, nullptr, nullptr);
handle = CreateFileW(widename, param->m_access, param->m_share, nullptr, param->m_creation, param->m_flags, nullptr);
} else {
handle = CreateFileA(param->m_name, param->m_access, param->m_share, nullptr, param->m_creation, param->m_flags, nullptr);
}
return handle != INVALID_HANDLE_VALUE ? handle : nullptr;
}
// VERIFY: 1969c849 auto
// OFFSET: 0x00779F50
static uint32_t OsPathGetRootChars(const char* path) {
uint32_t length = SStrLen(path);
if (length < 2) {
return 0;
}
if (path[1] == ':') {
return path[2] == '\\' ? 3 : 2;
}
if (path[0] != '\\' || path[1] != '\\') {
return 0;
}
const char* current = path + 2;
for (int32_t i = 0; i < 2; i++) {
if (current) {
current = SStrChr(current, '\\') + 1;
}
}
return current ? static_cast<uint32_t>(current - path) : length;
}
// INLINED
IOUnit::IOUnit() {
this->m_refcount = nullptr;
this->m_count = 1;
}
// INLINED
void IOUnit::Release() {
IORefcount* refcount = this->m_refcount;
if (--this->m_count == 0) {
delete this;
}
if (refcount) {
refcount->Release();
}
}
// INLINED
IOWin32FileUnit::IOWin32FileUnit(void* handle) {
this->m_handle = handle;
this->m_position = -1;
this->Seek(0);
}
// VERIFY: 71d9830f manual
// OFFSET: 0x00779CD0
bool IOWin32FileUnit::Seek(int64_t offset) {
if (this->m_position != offset) {
LONG high = static_cast<LONG>(offset >> 32);
if (SetFilePointer(this->m_handle, static_cast<LONG>(offset), &high, FILE_BEGIN) == INVALID_SET_FILE_POINTER) {
this->m_position = -1;
return false;
}
this->m_position = offset;
}
return true;
}
// VERIFY: 072ade62 manual
// OFFSET: 0x00779D30
bool IOWin32FileUnit::Read(void* buffer, int64_t offset, uint32_t count, uint32_t* bytesRead) {
uint32_t minimum = 1;
uint32_t localRead;
if (!bytesRead) {
minimum = count;
bytesRead = &localRead;
}
*bytesRead = 0;
for (int32_t tries = 0; tries < 3; tries++) {
if (!this->Seek(offset)) {
return false;
}
BOOL result = ReadFile(this->m_handle, buffer, count, reinterpret_cast<LPDWORD>(bytesRead), nullptr);
this->m_position = offset + *bytesRead;
if (result) {
return *bytesRead >= minimum;
}
this->m_position = -1;
Sleep(10);
}
return false;
}
// VERIFY: b8232079 auto
// OFFSET: 0x00779E20
bool IOWin32FileUnit::Write(const void* buffer, int64_t offset, uint32_t count) {
DWORD written = 0;
if (!this->Seek(offset)) {
return false;
}
if (WriteFile(this->m_handle, buffer, count, &written, nullptr) && written == count) {
this->m_position = offset + written;
return true;
}
this->m_position = -1;
return false;
}
// VERIFY: 258aaf32 manual
// OFFSET: 0x00779E90
bool IOWin32FileUnit::Flush() {
return FlushFileBuffers(this->m_handle) != 0;
}
// VERIFY: da06c8e1 auto
// OFFSET: 0x00779EB0
bool IOWin32FileUnit::GetFileSize(int64_t* size) {
DWORD high;
DWORD low = ::GetFileSize(this->m_handle, &high);
if (low == INVALID_FILE_SIZE && GetLastError()) {
*size = 0;
return false;
}
*size = (static_cast<int64_t>(high) << 32) | low;
return true;
}
// VERIFY: a1be587a auto
// OFFSET: 0x00779F10
bool IOWin32FileUnit::SetFileSize(int64_t size) {
if (!this->Seek(size)) {
return false;
}
return SetEndOfFile(this->m_handle) != 0;
}
// VERIFY: 58328fc2 auto
// OFFSET: 0x008C32F0
void* IOWin32FileUnit::Win32Handle() {
return this->m_handle;
}
// VERIFY: 14b234bb manual
// OFFSET: 0x00779FB0
bool IOUnbufferedFileUnit::Read(void* buffer, int64_t offset, uint32_t count, uint32_t* bytesRead) {
if (!(this->m_alignMask & reinterpret_cast<uintptr_t>(buffer)) && !(this->m_alignMask & count)) {
return this->m_unit->Read(buffer, offset, count, bytesRead);
}
if (!this->m_buffer) {
return false;
}
uint32_t total = 0;
bool result = true;
while (count) {
uint32_t chunk = count >= 0x100000 ? 0x100000 : count;
uint32_t size = chunk;
if (chunk & this->m_alignMask) {
size = (this->m_alignMask + chunk) & ~this->m_alignMask;
}
uint32_t read;
result = this->m_unit->Read(this->m_buffer, offset, size, &read);
if (!result) {
break;
}
read = size < chunk ? size : chunk;
memcpy(buffer, this->m_buffer, read);
buffer = static_cast<uint8_t*>(buffer) + read;
offset += read;
count -= read;
total += read;
if (read < chunk) {
break;
}
}
if (!bytesRead) {
return count == 0;
}
*bytesRead = total;
return result;
}
// VERIFY: 4f575842 manual
// OFFSET: 0x0077A0C0
bool IOUnbufferedFileUnit::Write(const void* buffer, int64_t offset, uint32_t count) {
if (!(this->m_alignMask & reinterpret_cast<uintptr_t>(buffer)) && !(this->m_alignMask & count)) {
return this->m_unit->Write(buffer, offset, count);
}
if (!this->m_buffer) {
return false;
}
bool result = true;
while (count) {
uint32_t chunk = count >= 0x100000 ? 0x100000 : count;
memcpy(this->m_buffer, buffer, chunk);
buffer = static_cast<const uint8_t*>(buffer) + chunk;
uint32_t size = chunk;
if (chunk & this->m_alignMask) {
size = (this->m_alignMask + chunk) & ~this->m_alignMask;
}
result = this->m_unit->Write(this->m_buffer, offset, size);
if (!result) {
break;
}
offset += chunk;
count -= chunk;
}
if (offset > this->m_size) {
this->m_size = offset;
}
return result;
}
// VERIFY: be82d77d auto
// OFFSET: 0x0077A190
bool IOUnbufferedFileUnit::Flush() {
return this->m_unit->Flush();
}
// VERIFY: 37e4f9d3 auto
// OFFSET: 0x0077A1A0
bool IOUnbufferedFileUnit::SetFileSize(int64_t size) {
this->m_size = size;
return this->m_unit->SetFileSize((size + this->m_alignMask) & ~this->m_alignMask);
}
// VERIFY: 710d0107 auto
// OFFSET: 0x0077A1E0
bool IOUnbufferedFileUnit::GetFileSize(int64_t* size) {
*size = this->m_size;
return true;
}
// VERIFY: eb064776 manual
// OFFSET: 0x0077A200
IOUnit::~IOUnit() {
}
// VERIFY: 95180380 manual
// OFFSET: 0x0077A230
IOWin32FileUnit::~IOWin32FileUnit() {
CloseHandle(this->m_handle);
this->m_handle = nullptr;
}
// VERIFY: 2e94c18b manual
// OFFSET: 0x0077A270
IOUnbufferedFileUnit::IOUnbufferedFileUnit(void* handle, const IOFileParam* param) {
this->m_unit = new IOWin32FileUnit(handle);
this->m_size = 0;
this->m_unit->GetFileSize(&this->m_size);
SStrCopy(this->m_path, param->m_name, sizeof(this->m_path));
this->m_buffer = VirtualAlloc(nullptr, 0x100000, MEM_COMMIT, PAGE_READWRITE);
char rootPath[MAX_PATH];
SStrCopy(rootPath, this->m_path, OsPathGetRootChars(this->m_path) + 1);
DWORD sectorsPerCluster;
DWORD bytesPerSector;
DWORD freeClusters;
DWORD totalClusters;
if (!GetDiskFreeSpaceA(rootPath, &sectorsPerCluster, &bytesPerSector, &freeClusters, &totalClusters) || ((bytesPerSector - 1) & bytesPerSector)) {
this->m_alignMask = 0xFFFF;
} else {
this->m_alignMask = bytesPerSector - 1;
}
}
// VERIFY: 550631c8 manual
// OFFSET: 0x0077A380
void* IOUnbufferedFileUnit::Win32Handle() {
return this->m_unit->Win32Handle();
}
// VERIFY: 80291fbf manual
// OFFSET: 0x0077A390
IOUnbufferedFileUnit* IOUnbufferedFileUnit::Open(const IOFileParam* param) {
HANDLE handle = OpenFileHandle(param);
if (!handle) {
return nullptr;
}
return new IOUnbufferedFileUnit(handle, param);
}
// VERIFY: b4b1ab6f manual
// OFFSET: 0x0077A3E0
IOWin32FileUnit* IOWin32FileUnit::Open(const IOFileParam* param) {
HANDLE handle = OpenFileHandle(param);
if (!handle) {
return nullptr;
}
return new IOWin32FileUnit(handle);
}
// VERIFY: 1519e975 auto
// OFFSET: 0x0077A450
IOUnit* IOFileUnit::Create(const IOFileParam& param, IOUnit* next) {
if (next) {
return nullptr;
}
if (param.m_flags & FILE_FLAG_NO_BUFFERING) {
return IOUnbufferedFileUnit::Open(&param);
}
return IOWin32FileUnit::Open(&param);
}
// VERIFY: 3f8b0bf0 manual
// OFFSET: [0x0077A480, 0x0077A530]
IOUnbufferedFileUnit::~IOUnbufferedFileUnit() {
VirtualFree(this->m_buffer, 0, MEM_RELEASE);
if (this->m_unit) {
delete this->m_unit;
}
IOFileParam param;
param.m_name = this->m_path;
param.m_access = GENERIC_WRITE;
param.m_share = FILE_SHARE_READ;
param.m_creation = OPEN_EXISTING;
param.m_flags = FILE_ATTRIBUTE_NORMAL;
IOUnit* unit = IOWin32FileUnit::Open(&param);
if (unit) {
unit->SetFileSize(this->m_size);
unit->Release();
}
}
}
#endif
@@ -0,0 +1,386 @@
#if defined(WOWDECOMP_ARCH_64)
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <windows.h>
#include "Engine/Source/Storm/Source/IOUnit/IOFileUnit.h"
#include "Engine/Source/Storm/H/storm.h"
#include "Engine/Source/Storm/Source/SOption.h"
namespace Storm {
// OFFSET: 0x00779C30
static HANDLE OpenFileHandle(const IOFileParam* param) {
HANDLE handle;
if (g_opt.unicodeenabled) {
WCHAR widename[MAX_PATH];
SUniConvertUTF8to16(reinterpret_cast<uint16_t*>(widename), MAX_PATH, param->m_name, STORM_MAX_STR, nullptr, nullptr);
handle = CreateFileW(widename, param->m_access, param->m_share, nullptr, param->m_creation, param->m_flags, nullptr);
} else {
handle = CreateFileA(param->m_name, param->m_access, param->m_share, nullptr, param->m_creation, param->m_flags, nullptr);
}
return handle != INVALID_HANDLE_VALUE ? handle : nullptr;
}
// OFFSET: 0x00779F50
static uint32_t OsPathGetRootChars(const char* path) {
uint32_t length = SStrLen(path);
if (length < 2) {
return 0;
}
if (path[1] == ':') {
return path[2] == '\\' ? 3 : 2;
}
if (path[0] != '\\' || path[1] != '\\') {
return 0;
}
const char* current = path + 2;
for (int32_t i = 0; i < 2; i++) {
if (current) {
current = SStrChr(current, '\\') + 1;
}
}
return current ? static_cast<uint32_t>(current - path) : length;
}
// INLINED
IOUnit::IOUnit() {
this->m_refcount = nullptr;
this->m_count = 1;
}
// INLINED
void IOUnit::Release() {
IORefcount* refcount = this->m_refcount;
if (--this->m_count == 0) {
delete this;
}
if (refcount) {
refcount->Release();
}
}
// INLINED
IOWin32FileUnit::IOWin32FileUnit(void* handle) {
this->m_handle = handle;
this->m_position = -1;
this->Seek(0);
}
// OFFSET: 0x00779CD0
bool IOWin32FileUnit::Seek(int64_t offset) {
if (this->m_position != offset) {
LONG high = static_cast<LONG>(offset >> 32);
if (SetFilePointer(this->m_handle, static_cast<LONG>(offset), &high, FILE_BEGIN) == INVALID_SET_FILE_POINTER) {
this->m_position = -1;
return false;
}
this->m_position = offset;
}
return true;
}
// OFFSET: 0x00779D30
bool IOWin32FileUnit::Read(void* buffer, int64_t offset, uint32_t count, uint32_t* bytesRead) {
uint32_t minimum = 1;
uint32_t localRead;
if (!bytesRead) {
minimum = count;
bytesRead = &localRead;
}
*bytesRead = 0;
for (int32_t tries = 0; tries < 3; tries++) {
if (!this->Seek(offset)) {
return false;
}
BOOL result = ReadFile(this->m_handle, buffer, count, reinterpret_cast<LPDWORD>(bytesRead), nullptr);
this->m_position = offset + *bytesRead;
if (result) {
return *bytesRead >= minimum;
}
this->m_position = -1;
Sleep(10);
}
return false;
}
// OFFSET: 0x00779E20
bool IOWin32FileUnit::Write(const void* buffer, int64_t offset, uint32_t count) {
DWORD written = 0;
if (!this->Seek(offset)) {
return false;
}
if (WriteFile(this->m_handle, buffer, count, &written, nullptr) && written == count) {
this->m_position = offset + written;
return true;
}
this->m_position = -1;
return false;
}
// OFFSET: 0x00779E90
bool IOWin32FileUnit::Flush() {
return FlushFileBuffers(this->m_handle) != 0;
}
// OFFSET: 0x00779EB0
bool IOWin32FileUnit::GetFileSize(int64_t* size) {
DWORD high;
DWORD low = ::GetFileSize(this->m_handle, &high);
if (low == INVALID_FILE_SIZE && GetLastError()) {
*size = 0;
return false;
}
*size = (static_cast<int64_t>(high) << 32) | low;
return true;
}
// OFFSET: 0x00779F10
bool IOWin32FileUnit::SetFileSize(int64_t size) {
if (!this->Seek(size)) {
return false;
}
return SetEndOfFile(this->m_handle) != 0;
}
// OFFSET: 0x008C32F0
void* IOWin32FileUnit::Win32Handle() {
return this->m_handle;
}
// OFFSET: 0x00779FB0
bool IOUnbufferedFileUnit::Read(void* buffer, int64_t offset, uint32_t count, uint32_t* bytesRead) {
if (!(this->m_alignMask & reinterpret_cast<uintptr_t>(buffer)) && !(this->m_alignMask & count)) {
return this->m_unit->Read(buffer, offset, count, bytesRead);
}
if (!this->m_buffer) {
return false;
}
uint32_t total = 0;
bool result = true;
while (count) {
uint32_t chunk = count >= 0x100000 ? 0x100000 : count;
uint32_t size = chunk;
if (chunk & this->m_alignMask) {
size = (this->m_alignMask + chunk) & ~this->m_alignMask;
}
uint32_t read;
result = this->m_unit->Read(this->m_buffer, offset, size, &read);
if (!result) {
break;
}
read = size < chunk ? size : chunk;
memcpy(buffer, this->m_buffer, read);
buffer = static_cast<uint8_t*>(buffer) + read;
offset += read;
count -= read;
total += read;
if (read < chunk) {
break;
}
}
if (!bytesRead) {
return count == 0;
}
*bytesRead = total;
return result;
}
// OFFSET: 0x0077A0C0
bool IOUnbufferedFileUnit::Write(const void* buffer, int64_t offset, uint32_t count) {
if (!(this->m_alignMask & reinterpret_cast<uintptr_t>(buffer)) && !(this->m_alignMask & count)) {
return this->m_unit->Write(buffer, offset, count);
}
if (!this->m_buffer) {
return false;
}
bool result = true;
while (count) {
uint32_t chunk = count >= 0x100000 ? 0x100000 : count;
memcpy(this->m_buffer, buffer, chunk);
buffer = static_cast<const uint8_t*>(buffer) + chunk;
uint32_t size = chunk;
if (chunk & this->m_alignMask) {
size = (this->m_alignMask + chunk) & ~this->m_alignMask;
}
result = this->m_unit->Write(this->m_buffer, offset, size);
if (!result) {
break;
}
offset += chunk;
count -= chunk;
}
if (offset > this->m_size) {
this->m_size = offset;
}
return result;
}
// OFFSET: 0x0077A190
bool IOUnbufferedFileUnit::Flush() {
return this->m_unit->Flush();
}
// OFFSET: 0x0077A1A0
bool IOUnbufferedFileUnit::SetFileSize(int64_t size) {
this->m_size = size;
return this->m_unit->SetFileSize((size + this->m_alignMask) & ~this->m_alignMask);
}
// OFFSET: 0x0077A1E0
bool IOUnbufferedFileUnit::GetFileSize(int64_t* size) {
*size = this->m_size;
return true;
}
// OFFSET: 0x0077A200
IOUnit::~IOUnit() {
}
// OFFSET: 0x0077A230
IOWin32FileUnit::~IOWin32FileUnit() {
CloseHandle(this->m_handle);
this->m_handle = nullptr;
}
// OFFSET: 0x0077A270
IOUnbufferedFileUnit::IOUnbufferedFileUnit(void* handle, const IOFileParam* param) {
this->m_unit = new IOWin32FileUnit(handle);
this->m_size = 0;
this->m_unit->GetFileSize(&this->m_size);
SStrCopy(this->m_path, param->m_name, sizeof(this->m_path));
this->m_buffer = VirtualAlloc(nullptr, 0x100000, MEM_COMMIT, PAGE_READWRITE);
char rootPath[MAX_PATH];
SStrCopy(rootPath, this->m_path, OsPathGetRootChars(this->m_path) + 1);
DWORD sectorsPerCluster;
DWORD bytesPerSector;
DWORD freeClusters;
DWORD totalClusters;
if (!GetDiskFreeSpaceA(rootPath, &sectorsPerCluster, &bytesPerSector, &freeClusters, &totalClusters) || ((bytesPerSector - 1) & bytesPerSector)) {
this->m_alignMask = 0xFFFF;
} else {
this->m_alignMask = bytesPerSector - 1;
}
}
// OFFSET: 0x0077A380
void* IOUnbufferedFileUnit::Win32Handle() {
return this->m_unit->Win32Handle();
}
// OFFSET: 0x0077A390
IOUnbufferedFileUnit* IOUnbufferedFileUnit::Open(const IOFileParam* param) {
HANDLE handle = OpenFileHandle(param);
if (!handle) {
return nullptr;
}
return new IOUnbufferedFileUnit(handle, param);
}
// OFFSET: 0x0077A3E0
IOWin32FileUnit* IOWin32FileUnit::Open(const IOFileParam* param) {
HANDLE handle = OpenFileHandle(param);
if (!handle) {
return nullptr;
}
return new IOWin32FileUnit(handle);
}
// OFFSET: 0x0077A450
IOUnit* IOFileUnit::Create(const IOFileParam& param, IOUnit* next) {
if (next) {
return nullptr;
}
if (param.m_flags & FILE_FLAG_NO_BUFFERING) {
return IOUnbufferedFileUnit::Open(&param);
}
return IOWin32FileUnit::Open(&param);
}
// OFFSET: [0x0077A480, 0x0077A530]
IOUnbufferedFileUnit::~IOUnbufferedFileUnit() {
VirtualFree(this->m_buffer, 0, MEM_RELEASE);
if (this->m_unit) {
delete this->m_unit;
}
IOFileParam param;
param.m_name = this->m_path;
param.m_access = GENERIC_WRITE;
param.m_share = FILE_SHARE_READ;
param.m_creation = OPEN_EXISTING;
param.m_flags = FILE_ATTRIBUTE_NORMAL;
IOUnit* unit = IOWin32FileUnit::Open(&param);
if (unit) {
unit->SetFileSize(this->m_size);
unit->Release();
}
}
}
#endif