Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions El/DataSignatures/dataSignatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,11 @@ bool DataSignatures::VerifySignature(const DSHash &hash, const DSSignature &sign
}
}
break;
case 3:
RSADecrypt((unsigned char *)calculatedHash.Data(),
(const unsigned char *)signature._content3.Data(), signature._content3.Size(),
keyData, keySize);
break;
}
Temp<char> revHash; revHash.Realloc(hash._content.Size());
for (int i=0, siz=hash._content.Size()-1; i<=siz; i++)
Expand Down Expand Up @@ -458,6 +463,9 @@ bool DataSignatures::VerifySignature(const DSHash &hash, const DSSignature &sign
}
}
break;
case 3:
ok = CryptVerifySignature(handle, (BYTE *)signature._content3.Data(), signature._content3.Size(), key, NULL, 0) == TRUE;
break;
}
}

Expand Down
34 changes: 31 additions & 3 deletions El/ParamFile/paramFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5938,7 +5938,12 @@ ParamFile::ErrorCode ParamFile::ParseBinEx(const char *name, IParamClassSource *
SerializeBinStream f(&in);

SerializeBin(f, source, context);
if (f.GetError() != SerializeBinStream::EOK) return f.GetError();
if (f.GetError() != SerializeBinStream::EOK)
{
RptF("Config binary load failed: file=%s error=%d offset=%d version=%d",
name, (int)f.GetError(), f.TellG(), f.GetVersion());
return f.GetError();
}

SetFile(this);
//SetSource(new ParamClassOwnerNoUnload("",name));
Expand All @@ -5947,6 +5952,9 @@ ParamFile::ErrorCode ParamFile::ParseBinEx(const char *name, IParamClassSource *

// load variables
LoadVariables(f, parentVariables, globalVariables);
if (f.GetError() != SerializeBinStream::EOK)
RptF("Config variable load failed: file=%s error=%d offset=%d version=%d",
name, (int)f.GetError(), f.TellG(), f.GetVersion());

#if DIAG_OPEN
if (_entries.Size() > 0)
Expand All @@ -5968,7 +5976,13 @@ ParamFile::ErrorCode ParamFile::ParseBinEx(QIStream &in, IParamClassSource *sour
SerializeBinStream f(&in);

SerializeBin(f, source, context);
if (f.GetError() != SerializeBinStream::EOK) return f.GetError();
if (f.GetError() != SerializeBinStream::EOK)
{
RString sourceName = source ? source->GetOwnerDebugName() : RString("<unknown stream>");
RptF("Config binary stream load failed: source=%s error=%d offset=%d version=%d",
(const char *)sourceName, (int)f.GetError(), f.TellG(), f.GetVersion());
return f.GetError();
}

SetFile(this);
//SetSource(new ParamClassOwnerNoUnload("",name));
Expand All @@ -5977,6 +5991,12 @@ ParamFile::ErrorCode ParamFile::ParseBinEx(QIStream &in, IParamClassSource *sour

// load variables
LoadVariables(f, parentVariables, globalVariables);
if (f.GetError() != SerializeBinStream::EOK)
{
RString sourceName = source ? source->GetOwnerDebugName() : RString("<unknown stream>");
RptF("Config variable stream load failed: source=%s error=%d offset=%d version=%d",
(const char *)sourceName, (int)f.GetError(), f.TellG(), f.GetVersion());
}

#if DIAG_OPEN
if (_entries.Size() > 0)
Expand Down Expand Up @@ -6020,14 +6040,22 @@ ParamFile::ErrorCode ParamFile::ParseBinEx(QFBank &bank, const char *name, IEval
//context._fullLoad = false;

SerializeBin(f, source, context);
if (f.GetError() != SerializeBinStream::EOK) return f.GetError();
if (f.GetError() != SerializeBinStream::EOK)
{
RptF("Config bank load failed: file=%s error=%d offset=%d version=%d",
name, (int)f.GetError(), f.TellG(), f.GetVersion());
return f.GetError();
}

SetFile(this);
//SetSource(new ParamClassOwnerFilename("",name));

//Assert(CheckIntegrity());

LoadVariables(f, parentVariables, globalVariables);
if (f.GetError() != SerializeBinStream::EOK)
RptF("Config bank variable load failed: file=%s error=%d offset=%d version=%d",
name, (int)f.GetError(), f.TellG(), f.GetVersion());

#if DIAG_OPEN
if (_entries.Size() > 0)
Expand Down
125 changes: 125 additions & 0 deletions El/QStream/qbStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,65 @@ struct AddNonDataFile
return false;
}
};

// DayZ signature version 3 hashes selected script/config payloads, together
// with the normalized file list and PBO prefix. Binary assets are deliberately
// excluded by the DayZ v3 policy.
struct DayZV3File
{
unsigned long startOffset;
unsigned long length;
RString name;
DayZV3File() : startOffset(0), length(0) {}
DayZV3File(unsigned long offset, unsigned long len, RString fileName)
: startOffset(offset), length(len), name(fileName) {}
ClassIsMovable(DayZV3File);
};

struct AddDayZV3File
{
AutoArray<DayZV3File> &_files;
AddDayZV3File(AutoArray<DayZV3File> &files) : _files(files) {}
bool operator ()(const FileInfoO &info, const FileBankType *container)
{
if (info.length > 0)
{
const char *ext = GetFileExt(info.name);
if (ext && *ext == '.' &&
(!stricmp(ext+1,"bikb") || !stricmp(ext+1,"c") || !stricmp(ext+1,"ext") ||
!stricmp(ext+1,"hpp") || !stricmp(ext+1,"cfg") || !stricmp(ext+1,"h") ||
!stricmp(ext+1,"inc")))
_files.Add(DayZV3File(info.startOffset, info.length, info.name));
}
return false;
}
};

struct AddDayZV3Name
{
AutoArray<RString> &_names;
AddDayZV3Name(AutoArray<RString> &names) : _names(names) {}
bool operator ()(const FileInfoO &info, const FileBankType *container)
{
if (info.length > 0)
{
RString name = info.name;
name.Lower();
_names.Add(name);
}
return false;
}
};

static int CmpDayZV3Files(const DayZV3File *a, const DayZV3File *b)
{
return a->startOffset < b->startOffset ? -1 : (a->startOffset > b->startOffset ? 1 : 0);
}

static int CmpDayZV3Names(const RString *a, const RString *b)
{
return strcmp(*a, *b);
}
//@} NonDataFileHash calculation

#define MT_SAFE 0
Expand Down Expand Up @@ -609,6 +668,72 @@ class QFBank: public RefCount
//break; //unreachable code
}
}
return false;
case 3:
{
// BISign v3 selects the DayZ script/config file hash (hash3).
AutoArray<DayZV3File> files;
_files.ForEachF(AddDayZV3File(files));
QSort(files.Data(), files.Size(), CmpDayZV3Files);

HashCalculator fileCalculator;
if (files.Size() > 0)
{
QIStreamDataSource in;
in.AttachSource(_fileAccess);
for (int i = 0; i < files.Size(); i++)
{
in.seekg(files[i].startOffset);
int remaining = files[i].length;
char buffer[16*1024];
while (remaining > 0)
{
int chunk = remaining > (int)sizeof(buffer) ? (int)sizeof(buffer) : remaining;
size_t read = in.read(buffer, chunk);
if (read == 0 || in.fail()) return false;
fileCalculator.Add(buffer, read);
remaining -= (int)read;
}
}
}
else
{
// DayZ v3 uses the reversed sentinel when no files match its allowlist.
fileCalculator.Add("gnihton", 7);
}
AutoArray<char> fileHash;
if (!fileCalculator.GetResult(fileHash)) return false;

AutoArray<RString> names;
_files.ForEachF(AddDayZV3Name(names));
QSort(names.Data(), names.Size(), CmpDayZV3Names);
HashCalculator nameCalculator;
const char *previous = NULL;
for (int i = 0; i < names.Size(); i++)
{
if (!previous || strcmp(previous, names[i]) != 0)
{
nameCalculator.Add(names[i].Data(), names[i].GetLength());
previous = names[i];
}
}
AutoArray<char> nameHash;
if (!nameCalculator.GetResult(nameHash)) return false;

HashCalculator finalCalculator;
finalCalculator.Add(fileHash.Data(), fileHash.Size());
finalCalculator.Add(nameHash.Data(), nameHash.Size());
if (GetPrefix().GetLength() > 0)
{
finalCalculator.Add(GetPrefix().Data(), GetPrefix().GetLength());
if (GetPrefix()[GetPrefix().GetLength()-1] != '\\')
finalCalculator.Add("\\", 1);
}
AutoArray<char> finalHash;
if (!finalCalculator.GetResult(finalHash)) return false;
hash.Realloc(finalHash.Data(), finalHash.Size());
return true;
}
}
return false;
}
Expand Down
11 changes: 8 additions & 3 deletions Enfusion/src/Physics/enf_physicsbulletmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,13 +731,18 @@ bool BulletManager::LoadMaterials(const char* name)
GameDataNamespace globals(NULL, RString(), false); // TODO: parsing namespace if access to globals needed

ParamFile matFile;
matFile.ParseBinOrTxt(name, NULL, NULL, &globals);
const bool physicsMaterialsInVfs = QFBankQueryFunctions::FileExists(name);
const bool physicsMaterialsOnDisk = QIFileFunctions::FileExists(name);
const bool physicsMaterialsParsed = matFile.ParseBinOrTxt(name, NULL, NULL, &globals);
RptF("PhysicsMaterialsDiagnostic file=%s vfs=%d disk=%d parsed=%d entries=%d",
cc_cast(name), physicsMaterialsInVfs, physicsMaterialsOnDisk,
physicsMaterialsParsed, matFile.GetEntryCount());

BulletPhysicsMaterial* mat = new BulletPhysicsMaterial(name);

if (matFile.GetEntryCount()==0)
if (!physicsMaterialsParsed || matFile.GetEntryCount()==0)
{
RptF("Cannot load material file %s",cc_cast(name));
RptF("Physics material file is present but invalid: %s",cc_cast(name));
return 0;
}
else
Expand Down
1 change: 1 addition & 0 deletions cfg/Bin/cfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2779,6 +2779,7 @@ class CfgVehicles
emptyGloves = "";
emptyBack = "";
emptyShoulder = "";
emptyShoulder2 = ""; // optional second large-weapon slot
emptyMelee = "";
emptyMask = "";
};
Expand Down
Loading
Loading