Integrating latest 47acbe8

This commit is contained in:
alexpete
2021-03-25 13:57:57 -07:00
parent 448c549698
commit 75dc720198
10312 changed files with 2711566 additions and 671451 deletions
@@ -21,7 +21,6 @@
#include <IConsole.h>
#include <ITextModeConsole.h>
#include <INetwork.h>
-3
View File
@@ -51,8 +51,6 @@ ly_add_target(
Legacy::CrySystem.DLMalloc.C
PRIVATE
3rdParty::expat
3rdParty::LibTomCrypt
3rdParty::LibTomMath
3rdParty::lz4
3rdParty::md5
3rdParty::tiff
@@ -64,7 +62,6 @@ ly_add_target(
AZ::AzFramework
RUNTIME_DEPENDENCIES
Legacy::Cry3DEngine
Legacy::CryNetwork
)
ly_add_source_properties(
+6
View File
@@ -29,6 +29,12 @@ void CCmdLine::PushCommand(const string& sCommand, const string& sParameter)
{
type = eCLAT_Pre;
++szCommand;
// Handle cmd line parameters that use -- properly
if (szCommand[0] == '-')
{
++szCommand;
}
}
else if (sCommand[0] == '+')
{
-44
View File
@@ -1,44 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "CrySystem_precompiled.h"
#include "CryTomcrypt.h"
//////////////////////////////////////////////////////////////////////////
#ifdef INCLUDE_LIBTOMCRYPT
prng_state g_yarrow_prng_state;
// Main public RSA key used for verifying Cry Pak comments
rsa_key g_rsa_key_public_for_sign;
void* LTC_CALL tomcrypt_Malloc(size_t size)
{
return CryModuleMalloc(size);
}
void* LTC_CALL tomcrypt_Realloc(void* ptr, size_t size)
{
return CryModuleRealloc(ptr, size);
}
void* LTC_CALL tomcrypt_Calloc(size_t num, size_t size)
{
return CryModuleCalloc(num, size);
}
void LTC_CALL tomcrypt_Free(void* ptr)
{
CryModuleFree(ptr);
}
#endif // INCLUDE_LIBTOMCRYPT
-47
View File
@@ -1,47 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include "ProjectDefines.h"
#ifdef INCLUDE_LIBTOMCRYPT
#include "CryMemoryManager.h"
#define USE_LTM
#define LTM_DESC
#define LTC_EXPORT
#define LTC_NO_PROTOTYPES
#if defined(AZ_COMPILER_MSVC)
#define LTC_CALL __cdecl
#else
#define LTC_CALL
#endif
LTC_EXPORT void* LTC_CALL tomcrypt_Malloc(size_t size);
LTC_EXPORT void* LTC_CALL tomcrypt_Realloc(void* ptr, size_t size);
LTC_EXPORT void* LTC_CALL tomcrypt_Calloc(size_t num, size_t size);
LTC_EXPORT void LTC_CALL tomcrypt_Free(void* ptr);
#define XMALLOC tomcrypt_Malloc
#define XREALLOC tomcrypt_Realloc
#define XCALLOC tomcrypt_Calloc
#define XFREE tomcrypt_Free
#include <tomcrypt.h>
#undef byte // tomcrypt defines a byte macro which conflicts with out byte data type
#define STREAM_CIPHER_NAME "twofish"
extern prng_state g_yarrow_prng_state;
extern rsa_key g_rsa_key_public_for_sign;
#endif //INCLUDE_LIBTOMCRYPT
@@ -1,57 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "CrySystem_precompiled.h"
#include <Cryptography/Crypto.h>
#include <Cryptography/StreamCipher.h>
//-----------------------------------------------------------------------------
void Crypto::EncryptBuffer(uint8* pOutput, const uint8* pInput, uint32 bufferLength, const uint8* pKey, uint32 keyLength)
{
if (pKey && (keyLength > 0))
{
StreamCipherState cipher;
m_streamCipher.Init(cipher, pKey, keyLength);
if (pInput && pOutput && (bufferLength > 0))
{
m_streamCipher.Encrypt(cipher, pInput, bufferLength, pOutput);
}
}
}
//-----------------------------------------------------------------------------
void Crypto::DecryptBuffer(uint8* pOutput, const uint8* pInput, uint32 bufferLength, const uint8* pKey, uint32 keyLength)
{
if (pKey && (keyLength > 0))
{
StreamCipherState cipher;
m_streamCipher.Init(cipher, pKey, keyLength);
if (pInput && pOutput && (bufferLength > 0))
{
m_streamCipher.Decrypt(cipher, pInput, bufferLength, pOutput);
}
}
}
//-----------------------------------------------------------------------------
IRijndael* Crypto::GetRijndael()
{
return &m_rijndael;
}
//-----------------------------------------------------------------------------
IStreamCipher* Crypto::GetStreamCipher()
{
return &m_streamCipher;
}
@@ -1,43 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef CRYINCLUDE_CRYSYSTEM_CRYPTO_H
#define CRYINCLUDE_CRYSYSTEM_CRYPTO_H
#pragma once
#include <ICrypto.h>
#include <Cryptography/rijndael.h>
#include <Cryptography/StreamCipher.h>
#include <Cryptography/Whirlpool.h>
class Crypto
: public ICrypto
{
public:
// Exposed block encryption
void EncryptBuffer(uint8* pOutput, const uint8* pInput, uint32 bufferLength, const uint8* pKey, uint32 keyLength) override;
void DecryptBuffer(uint8* pOutput, const uint8* pInput, uint32 bufferLength, const uint8* pKey, uint32 keyLength) override;
// Crypto implementations
IRijndael* GetRijndael() override;
IStreamCipher* GetStreamCipher() override;
void InitWhirlpoolHash(uint8* hash);
void InitWhirlpoolHash(uint8* hash, const string& str);
void InitWhirlpoolHash(uint8* hash, const uint8* input, size_t length);
protected:
Rijndael m_rijndael;
CStreamCipher m_streamCipher;
};
#endif // CRYINCLUDE_CRYSYSTEM_CRYPTO_H
@@ -1,84 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "CrySystem_precompiled.h"
#include "StreamCipher.h"
StreamCipherState CStreamCipher::BeginCipher(const uint8* pKey, uint32 keyLength)
{
StreamCipherState cipher;
Init(cipher, pKey, keyLength);
return cipher;
}
void CStreamCipher::Init(StreamCipherState& state, const uint8* key, int keyLen)
{
int i, j;
for (i = 0; i < 256; i++)
{
state.m_S[i] = i;
}
if (key)
{
for (i = j = 0; i < 256; i++)
{
uint8 temp;
j = (j + key[i % keyLen] + state.m_S[i]) & 255;
temp = state.m_S[i];
state.m_S[i] = state.m_S[j];
state.m_S[j] = temp;
}
}
state.m_I = state.m_J = 0;
for (i = 0; i < 1024; i++)
{
GetNext(state);
}
memcpy(state.m_StartS, state.m_S, sizeof(state.m_StartS));
state.m_StartI = state.m_I;
state.m_StartJ = state.m_J;
}
uint8 CStreamCipher::GetNext(StreamCipherState& state)
{
uint8 tmp;
state.m_I = (state.m_I + 1) & 0xff;
state.m_J = (state.m_J + state.m_S[state.m_I]) & 0xff;
tmp = state.m_S[state.m_J];
state.m_S[state.m_J] = state.m_S[state.m_I];
state.m_S[state.m_I] = tmp;
return state.m_S[(state.m_S[state.m_I] + state.m_S[state.m_J]) & 0xff];
}
void CStreamCipher::ProcessBuffer(StreamCipherState& state, const uint8* input, int inputLen, uint8* output, bool resetKey)
{
if (resetKey)
{
memcpy(state.m_S, state.m_StartS, sizeof(state.m_S));
state.m_I = state.m_StartI;
state.m_J = state.m_StartJ;
}
for (int i = 0; i < inputLen; i++)
{
output[i] = input[i] ^ GetNext(state);
}
}
@@ -1,38 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
/****************************************************
A simple stream cipher based on RC4
****************************************************/
#ifndef CRYINCLUDE_CRYPTOGRAPHY_STREAMCIPHER_H
#define CRYINCLUDE_CRYPTOGRAPHY_STREAMCIPHER_H
#pragma once
#include <ICrypto.h>
class CStreamCipher
: public IStreamCipher
{
public:
StreamCipherState BeginCipher(const uint8* pKey, uint32 keyLength);
void Init(StreamCipherState& state, const uint8* key, int keyLen);
void Encrypt(StreamCipherState& state, const uint8* input, int inputLen, uint8* output) { ProcessBuffer(state, input, inputLen, output, true); }
void Decrypt(StreamCipherState& state, const uint8* input, int inputLen, uint8* output) { ProcessBuffer(state, input, inputLen, output, true); }
void EncryptStream(StreamCipherState& state, const uint8* input, int inputLen, uint8* output) { ProcessBuffer(state, input, inputLen, output, false); }
void DecryptStream(StreamCipherState& state, const uint8* input, int inputLen, uint8* output) { ProcessBuffer(state, input, inputLen, output, false); }
private:
uint8 GetNext(StreamCipherState& state);
void ProcessBuffer(StreamCipherState& state, const uint8* input, int inputLen, uint8* output, bool resetKey);
};
#endif // CRYINCLUDE_CRYPTOGRAPHY_STREAMCIPHER_H
File diff suppressed because it is too large Load Diff
@@ -1,18 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef CRYINCLUDE_CRYPTOGRAPHY_WHIRLPOOL_H
#define CRYINCLUDE_CRYPTOGRAPHY_WHIRLPOOL_H
#pragma once
bool WhirlpoolHash_Test();
#endif // CRYINCLUDE_CRYPTOGRAPHY_WHIRLPOOL_H
File diff suppressed because it is too large Load Diff
@@ -1,133 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef CRYINCLUDE_CRYPTOGRAPHY_RIJNDAEL_H
#define CRYINCLUDE_CRYPTOGRAPHY_RIJNDAEL_H
#pragma once
#include <ICrypto.h>
//
// File : rijndael.h
// Creation date : Sun Nov 5 2000 03:21:05 CEST
// Author : Szymon Stefanek (stefanek@tin.it)
//
// Another implementation of the Rijndael cipher.
// This is intended to be an easily usable library file.
// This code is public domain.
// Based on the Vincent Rijmen and K.U.Leuven implementation 2.4.
//
//
// Original Copyright notice:
//
// rijndael-alg-fst.c v2.4 April '2000
// rijndael-alg-fst.h
// rijndael-api-fst.c
// rijndael-api-fst.h
//
// Optimised ANSI C code
//
// authors: v1.0: Antoon Bosselaers
// v2.0: Vincent Rijmen, K.U.Leuven
// v2.3: Paulo Barreto
// v2.4: Vincent Rijmen, K.U.Leuven
//
// This code is placed in the public domain.
//
//
// This implementation works on 128 , 192 , 256 bit keys
// and on 128 bit blocks
//
//
// Example of usage:
//
// // Input data
// unsigned char key[32]; // The key
// initializeYour256BitKey(); // Obviously initialized with sth
// const unsigned char * plainText = getYourPlainText(); // Your plain text
// int plainTextLen = strlen(plainText); // Plain text length
//
// // Encrypting
// Rijndael rin;
// unsigned char output[plainTextLen + 16];
//
// rin.init(Rijndael::CBC,Rijndael::Encrypt,key,Rijndael::Key32Bytes);
// // It is a good idea to check the error code
// int len = rin.padEncrypt(plainText,len,output);
// if(len >= 0)useYourEncryptedText();
// else encryptError(len);
//
// // Decrypting: we can reuse the same object
// unsigned char output2[len];
// rin.init(Rijndael::CBC,Rijndael::Decrypt,key,Rijndael::Key32Bytes));
// len = rin.padDecrypt(output,len,output2);
// if(len >= 0)useYourDecryptedText();
// else decryptError(len);
//
class Rijndael
: public IRijndael
{
public:
//////////////////////////////////////////////////////////////////////////////////////////
// API
//////////////////////////////////////////////////////////////////////////////////////////
// init(): Initializes the crypt session
// Returns RIJNDAEL_SUCCESS or an error code
// mode : Rijndael::ECB, Rijndael::CBC or Rijndael::CFB1
// You have to use the same mode for encrypting and decrypting
// dir : Rijndael::Encrypt or Rijndael::Decrypt
// A cipher instance works only in one direction
// (Well , it could be easily modified to work in both
// directions with a single init() call, but it looks
// useless to me...anyway , it is a matter of generating
// two expanded keys)
// key : array of unsigned octets , it can be 16 , 24 or 32 bytes long
// this CAN be binary data (it is not expected to be null terminated)
// keyLen : Rijndael::Key16Bytes , Rijndael::Key24Bytes or Rijndael::Key32Bytes
// initVector: initialization vector, you will usually use 0 here
int init(RijndaelState& state, RijndaelMode mode, RijndaelDirection dir, const uint8* key, RijndaelKeyLength keyLen, uint8* initVector = 0);
// Encrypts the input array (can be binary data)
// The input array length must be a multiple of 16 bytes, the remaining part
// is DISCARDED.
// so it actually encrypts inputLen / 128 blocks of input and puts it in outBuffer
// Input len is in BITS!
// outBuffer must be at least inputLen / 8 bytes long.
// Returns the encrypted buffer length in BITS or an error code < 0 in case of error
int blockEncrypt(RijndaelState& state, const uint8* input, int inputLen, uint8* outBuffer);
// Encrypts the input array (can be binary data)
// The input array can be any length , it is automatically padded on a 16 byte boundary.
// Input len is in BYTES!
// outBuffer must be at least (inputLen + 16) bytes long
// Returns the encrypted buffer length in BYTES or an error code < 0 in case of error
int padEncrypt(RijndaelState& state, const uint8* input, int inputOctets, uint8* outBuffer);
// Decrypts the input vector
// Input len is in BITS!
// outBuffer must be at least inputLen / 8 bytes long
// Returns the decrypted buffer length in BITS and an error code < 0 in case of error
int blockDecrypt(RijndaelState& state, const uint8* input, int inputLen, uint8* outBuffer);
// Decrypts the input vector
// Input len is in BYTES!
// outBuffer must be at least inputLen bytes long
// Returns the decrypted buffer length in BYTES and an error code < 0 in case of error
int padDecrypt(RijndaelState& state, const uint8* input, int inputOctets, uint8* outBuffer);
protected:
void keySched(RijndaelState & state, uint8 key[_MAX_KEY_COLUMNS][4]);
void keyEncToDec(RijndaelState& state);
void encrypt(RijndaelState & state, const uint8 a[16], uint8 b[16]);
void decrypt(RijndaelState & state, const uint8 a[16], uint8 b[16]);
};
#endif // CRYINCLUDE_CRYPTOGRAPHY_RIJNDAEL_H
-9
View File
@@ -13,17 +13,10 @@
// Description : Console implementation for iOS, reports back to the main interface
#ifndef CRYINCLUDE_CRYSYSTEM_IOSCONSOLE_H
#define CRYINCLUDE_CRYSYSTEM_IOSCONSOLE_H
#pragma once
#include <IConsole.h>
#include <ITextModeConsole.h>
#include <INetwork.h>
class CIOSConsole
: public ISystemUserCallback
@@ -59,5 +52,3 @@ public:
virtual void PutText(int x, int y, const char* msg);
virtual void EndDraw();
};
#endif // CRYINCLUDE_CRYSYSTEM_IOSCONSOLE_H
@@ -279,8 +279,11 @@ static void LoadMap(IConsoleCmdArgs* args)
{
if (gEnv->pSystem && gEnv->pSystem->GetILevelSystem() && !gEnv->IsEditor())
{
gEnv->pSystem->GetILevelSystem()->UnLoadLevel();
gEnv->pSystem->GetILevelSystem()->LoadLevel(args->GetArg(1));
if (args->GetArgCount() > 1)
{
gEnv->pSystem->GetILevelSystem()->UnLoadLevel();
gEnv->pSystem->GetILevelSystem()->LoadLevel(args->GetArg(1));
}
}
}
@@ -788,13 +791,16 @@ ILevel* CLevelSystem::LoadLevelInternal(const char* _levelName)
pSpamDelay->Set(0.0f);
}
bool is3DEngineLoaded = gEnv->IsEditor() ? gEnv->p3DEngine->InitLevelForEditor(pLevelInfo->GetPath(), pLevelInfo->GetDefaultGameType()->name)
: gEnv->p3DEngine->LoadLevel(pLevelInfo->GetPath(), pLevelInfo->GetDefaultGameType()->name);
if (!is3DEngineLoaded)
if (gEnv->p3DEngine)
{
OnLoadingError(pLevelInfo, "3DEngine failed to handle loading the level");
bool is3DEngineLoaded = gEnv->IsEditor() ? gEnv->p3DEngine->InitLevelForEditor(pLevelInfo->GetPath(), pLevelInfo->GetDefaultGameType()->name)
: gEnv->p3DEngine->LoadLevel(pLevelInfo->GetPath(), pLevelInfo->GetDefaultGameType()->name);
if (!is3DEngineLoaded)
{
OnLoadingError(pLevelInfo, "3DEngine failed to handle loading the level");
return 0;
return 0;
}
}
// Parse level specific config data.
@@ -867,7 +873,10 @@ ILevel* CLevelSystem::LoadLevelInternal(const char* _levelName)
//////////////////////////////////////////////////////////////////////////
// Notify 3D engine that loading finished
//////////////////////////////////////////////////////////////////////////
gEnv->p3DEngine->PostLoadLevel();
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->PostLoadLevel();
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
-1
View File
@@ -21,7 +21,6 @@
#include <IConsole.h>
#include <ISystem.h>
#include <IStreamEngine.h>
#include <INetwork.h> // EvenBalance - M. Quinn
#include "System.h"
#include "CryPath.h" // PathUtil::ReplaceExtension()
#include <Pak/CryPakUtils.h>
@@ -17,7 +17,5 @@
set(LY_BUILD_DEPENDENCIES
PRIVATE
3rdParty::LibTomCrypt
3rdParty::LibTomMath
m
)
@@ -60,7 +60,7 @@ AZRequestReadStream* AZRequestReadStream::Allocate(const EStreamTaskType tSource
//REMARK: if params->pBuffer is NOT NULL, then retReq->m_buffer
//should become params->pBuffer, this is called stream-in-place.
//The only reason we are not doing this here is because
//platforms like Xenia support stream-in-place to WRITE ONLY buffers.
//some platforms support stream-in-place to WRITE ONLY buffers.
//Because there are no guarantees that low level streaming and decompression apis
//would treat the output buffer as WRITE ONLY, we still allocate the buffer and memcpy
//to params->pBuffer upon the completion callback being called.
@@ -351,8 +351,8 @@ void AZRequestReadStream::OnRequestComplete(AZ::IO::SizeType numBytesRead, [[may
m_isError = false;
if (m_params.pBuffer)
{
//In some systems like Xenia, streaming-in-place is supported. The caveat
//is that in Xenia's case, the destination buffer is write-only. This is why
//In some systems, streaming-in-place is supported. The caveat
//is that in some cases, the destination buffer is write-only. This is why
//a final memcpy must be done here until support is added to AZ::IO::Streamer API
//to decompress/load data into write-only buffers. SEE: LY-98089
AZ_Assert(m_params.pBuffer != m_buffer, "Streaming-In-Place requires destination and source buffers to be different");
@@ -22,11 +22,6 @@
#include <CryPath.h>
#include <AzFramework/Archive/Archive.h>
#ifdef SUPPORT_RSA_AND_STREAMCIPHER_PAK_ENCRYPTION
#include "../ZipEncrypt.h"
#endif
extern CMTSafeHeap* g_pPakHeap;
#if defined(STREAMENGINE_ENABLE_STATS)
@@ -146,12 +141,8 @@ uint32 CAsyncIOFileRequest::ConfigureRead(AZ::IO::CCachedFileData* pFileData)
m_crc32FromHeader = pFileEntry->desc.lCRC32;
}
m_bEncryptedBuffer = false;
m_nPageReadCurrent = 0;
// FIXME later - see FIXME in DecryptBlockEntry if changing how m_bStreamInPlace is inited
m_bStreamInPlace = !m_bCompressedBuffer || ((!m_pExternalMemoryBuffer || !m_bWriteOnlyExternal) && (m_nFileSize > m_nFileSizeCompressed));
m_bReadBegun = 1;
@@ -267,17 +258,6 @@ uint32 CAsyncIOFileRequest::AllocateOutput([[maybe_unused]] AZ::IO::CCachedFileD
m_pDecompQueue = new SStreamJobQueue;
}
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
if (m_bEncryptedBuffer)
{
m_pDecryptQueue = new SStreamJobQueue;
#ifdef SUPPORT_RSA_AND_STREAMCIPHER_PAK_ENCRYPTION
m_pDecryptionCTR = new symmetric_CTR;
#endif
}
#endif //STREAMENGINE_SUPPORT_DECRYPT
// Doesn't need to be atomic, as there's no concurrency yet.
int nMemoryBufferUsers = 0;
if (nReadAllocSize > 0)
@@ -288,10 +268,6 @@ uint32 CAsyncIOFileRequest::AllocateOutput([[maybe_unused]] AZ::IO::CCachedFileD
{
++nMemoryBufferUsers;
}
if (m_bEncryptedBuffer)
{
++nMemoryBufferUsers;
}
m_nMemoryBufferUsers = nMemoryBufferUsers;
m_bOutputAllocated = 1;
@@ -321,21 +297,11 @@ void CAsyncIOFileRequest::Cancel()
{
CryOptionalAutoLock<CryCriticalSection> readLock(m_externalBufferLockRead, m_pExternalMemoryBuffer != NULL);
CryOptionalAutoLock<CryCriticalSection> decompLock(m_externalBufferLockDecompress, m_pExternalMemoryBuffer != NULL);
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
CryOptionalAutoLock<CryCriticalSection> decryptLock(m_externalBufferLockDecrypt, m_pExternalMemoryBuffer != NULL);
#endif //STREAMENGINE_SUPPORT_DECRYPT
Failed(ERROR_USER_ABORT);
}
}
void CAsyncIOFileRequest::SyncWithDecrypt()
{
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
m_decryptJobExecutor.reset(); // destructor waits on job completion
#endif //STREAMENGINE_SUPPORT_DECRYPT
}
void CAsyncIOFileRequest::SyncWithDecompress()
{
m_decompJobExecutor.reset(); // destructor waits on job completion
@@ -358,14 +324,6 @@ bool CAsyncIOFileRequest::TryCancel()
m_externalBufferLockRead.Unlock();
return false;
}
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
if (!m_externalBufferLockDecrypt.TryLock())
{
m_externalBufferLockDecompress.Unlock();
m_externalBufferLockRead.Unlock();
return false;
}
#endif //STREAMENGINE_SUPPORT_DECRYPT
bExt = true;
}
@@ -373,9 +331,6 @@ bool CAsyncIOFileRequest::TryCancel()
if (bExt)
{
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
m_externalBufferLockDecrypt.Unlock();
#endif
m_externalBufferLockDecompress.Unlock();
m_externalBufferLockRead.Unlock();
}
@@ -409,25 +364,6 @@ void CAsyncIOFileRequest::FreeBuffer()
m_pDecompQueue = NULL;
}
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
if (m_pDecryptQueue)
{
m_pDecryptQueue->Flush(tms);
delete m_pDecryptQueue;
m_pDecryptQueue = NULL;
}
#ifdef SUPPORT_RSA_AND_STREAMCIPHER_PAK_ENCRYPTION
if (m_pDecryptionCTR)
{
ZipEncrypt::FinishStreamCipher(m_pDecryptionCTR);
delete m_pDecryptionCTR;
m_pDecryptionCTR = NULL;
}
#endif
#endif //STREAMENGINE_SUPPORT_DECRYPT
if (m_pMemoryBuffer)
{
CStreamEngine* pStreamEngine = GetStreamEngine();
@@ -474,9 +410,6 @@ void CAsyncIOFileRequest::Flush()
void CAsyncIOFileRequest::Reset()
{
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
m_decryptJobExecutor.reset(); // destructor waits on job completion
#endif
m_decompJobExecutor.reset(); // destructor waits on job completion
#ifndef _RELEASE
@@ -490,10 +423,6 @@ void CAsyncIOFileRequest::Reset()
m_strFileName.resize(0);
m_pakFile.resize(0);
#ifdef SUPPORT_RSA_AND_STREAMCIPHER_PAK_ENCRYPTION
m_decryptionCTRInitialisedAgainst = m_pakFile;
#endif
// Reset POD members of the structure
memset(&m_nSortKey, 0, ((char*)(this + 1) - (char*)&m_nSortKey));
}
@@ -696,7 +625,6 @@ uint32 CAsyncIOFileRequest::ReadFileInPages(CStreamingIOThread* pIOThread, CCryF
uint32 nPageReadLen = (m_nPageReadEnd - m_nPageReadStart);
bool const bCompressed = m_bCompressedBuffer;
bool const bEncrypted = m_bEncryptedBuffer;
bool const bInPlace = m_bStreamInPlace;
bool const bIgnoreOutOfTmp = IgnoreOutofTmpMem();
@@ -811,14 +739,7 @@ uint32 CAsyncIOFileRequest::ReadFileInPages(CStreamingIOThread* pIOThread, CCryF
bool bLastBlock = (m_nPageReadCurrent + nPageSize) == nPageReadLen;
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
if (bEncrypted)
{
PushDecryptPage(pStreamEngine->GetJobEngineState(), pReadTarget, pTemporaryPageHdr, nPageSize, bLastBlock);
}
else
#endif //STREAMENGINE_SUPPORT_DECRYPT
if (bCompressed) //Spawn the decompression jobs here only if the file isn't encrypted. Encryption and Decompression are strictly linear, the decryption jobs will spawn decompression jobs as they complete.
if (bCompressed)
{
PushDecompressPage(pStreamEngine->GetJobEngineState(), pReadTarget, pTemporaryPageHdr, nPageSize, bLastBlock);
}
@@ -38,10 +38,6 @@ class CMTSafeHeap;
class CAsyncIOFileRequest_TransferPtr;
struct SStreamEngineTempMemStats;
#ifdef SUPPORT_RSA_AND_STREAMCIPHER_PAK_ENCRYPTION //Could check for INCLUDE_LIBTOMCRYPT here, but only decryption is implemented here, not signing
#include "CryTomcrypt.h"
#endif
#if !defined(USE_EDGE_ZLIB)
// Prevent compilation conflicts - zconf.h (included by zlib.h) defines WINDOWS and WIN32 - those
// definitions conflict with CryEngine's definitions.
@@ -209,16 +205,8 @@ public:
static void JobStart_Decompress(CAsyncIOFileRequest_TransferPtr& pSelf, const SStreamJobEngineState& engineState, int nSlot);
void DecompressBlockEntry(SStreamJobEngineState engineState, int nJob);
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
uint32 PushDecryptPage(const SStreamJobEngineState& engineState, void* pSrc, SStreamPageHdr* pSrcHdr, uint32 nBytes, bool bLast);
uint32 PushDecryptBlock(const SStreamJobEngineState& engineState, void* pSrc, SStreamPageHdr* pSrcHdr, uint32 nOffs, uint32 nBytes, bool bLast);
static void JobStart_Decrypt(CAsyncIOFileRequest_TransferPtr& pSelf, const SStreamJobEngineState& engineState, int nSlot);
void DecryptBlockEntry(SStreamJobEngineState engineState, int nJob);
#endif //STREAMENGINE_SUPPORT_DECRYPT
void Cancel();
bool TryCancel();
void SyncWithDecrypt();
void SyncWithDecompress();
void ComputeSortKey(uint64 nCurrentKeyInProgress);
void SetPriority(EStreamTaskPriority estp);
@@ -237,7 +225,6 @@ private:
private:
static void JobFinalize_Decompress(CAsyncIOFileRequest_TransferPtr& pSelf, const SStreamJobEngineState& engineState);
static void JobFinalize_Decrypt(CAsyncIOFileRequest_TransferPtr& pSelf, const SStreamJobEngineState& engineState);
static void JobFinalize_Transfer(CAsyncIOFileRequest_TransferPtr& pSelf, const SStreamJobEngineState& engineState);
private:
@@ -264,23 +251,13 @@ public:
// Cancel() must acquire both
CryCriticalSection m_externalBufferLockRead;
CryCriticalSection m_externalBufferLockDecompress;
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
CryCriticalSection m_externalBufferLockDecrypt;
#endif //STREAMENGINE_SUPPORT_DECRYPT
CryStringLocal m_strFileName;
string m_pakFile;
#ifdef SUPPORT_RSA_AND_STREAMCIPHER_PAK_ENCRYPTION
string m_decryptionCTRInitialisedAgainst;
#endif //SUPPORT_RSA_AND_STREAMCIPHER_PAK_ENCRYPTION
// If request come from stream, it will be not 0.
IReadStreamPtr m_pReadStream;
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
AZStd::unique_ptr<AZ::LegacyJobExecutor> m_decryptJobExecutor;
#endif //STREAMENGINE_SUPPORT_DECRYPT
AZStd::unique_ptr<AZ::LegacyJobExecutor> m_decompJobExecutor;
// Only POD data should exist beyond this point - will be memsetted to 0 on Reset !
@@ -311,7 +288,6 @@ public:
uint32 m_nReadMemoryBufferSize;
uint32 m_bCompressedBuffer : 1;
uint32 m_bEncryptedBuffer : 1;
uint32 m_bStatsUpdated : 1;
uint32 m_bStreamInPlace : 1;
uint32 m_bWriteOnlyExternal : 1;
@@ -338,7 +314,6 @@ public:
uint32 m_nPageReadEnd;
volatile uint32 m_nBytesDecompressed;
volatile uint32 m_nBytesDecrypted;
uint32 m_crc32FromHeader;
@@ -347,19 +322,12 @@ public:
z_stream_s* m_pZlibStream;
AZ::IO::ZipDir::UncompressLookahead* m_pLookahead;
SStreamJobQueue* m_pDecompQueue;
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
SStreamJobQueue* m_pDecryptQueue;
#endif //STREAMENGINE_SUPPORT_DECRYPT
#ifdef SUPPORT_RSA_AND_STREAMCIPHER_PAK_ENCRYPTION
symmetric_CTR* m_pDecryptionCTR;
#endif //SUPPORT_RSA_AND_STREAMCIPHER_PAK_ENCRYPTION
#ifdef STREAMENGINE_ENABLE_STATS
// Time that read operation took.
CTimeValue m_readTime;
CTimeValue m_unzipTime;
CTimeValue m_verifyTime;
CTimeValue m_decryptTime;
CTimeValue m_startTime;
CTimeValue m_completionTime;
@@ -395,15 +363,11 @@ struct SStreamEngineDecompressStats
{
uint64 m_nTotalBytesUnziped;
uint64 m_nTempBytesUnziped;
uint64 m_nTotalBytesDecrypted;
uint64 m_nTempBytesDecrypted;
uint64 m_nTotalBytesVerified;
uint64 m_nTempBytesVerified;
CTimeValue m_totalUnzipTime;
CTimeValue m_tempUnzipTime;
CTimeValue m_totalDecryptTime;
CTimeValue m_tempDecryptTime;
CTimeValue m_totalVerifyTime;
CTimeValue m_tempVerifyTime;
};
@@ -17,11 +17,6 @@
#include <CryPath.h>
#include "StreamAsyncFileRequest.h"
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
#include "ZipEncrypt.h"
#include "StreamEngine.h"
#endif //STREAMENGINE_SUPPORT_DECRYPT
#include "MTSafeAllocator.h"
namespace AZ::IO::ZipDir::ZipDirStructuresInternal
@@ -73,32 +68,6 @@ public:
}
}
};
class NotifyListenerDecrypt
: NotifyListener
{
public:
NotifyListenerDecrypt(IStreamEngineListener* pL, CAsyncIOFileRequest* pReq)
: NotifyListener(pL, pReq)
{
if (m_pL)
{
m_pL->OnStreamBeginDecrypt(m_pReq);
m_bInProgress = true;
}
}
~NotifyListenerDecrypt()
{
End();
}
void End()
{
if (m_bInProgress)
{
m_pL->OnStreamEndDecrypt(m_pReq);
m_bInProgress = false;
}
}
};
#endif
#if defined(STREAMENGINE_ENABLE_STATS)
@@ -294,153 +263,6 @@ void CAsyncIOFileRequest::DecompressBlockEntry(SStreamJobEngineState engineState
#endif
}
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
//////////////////////////////////////////////////////////////////////////
void CAsyncIOFileRequest::DecryptBlockEntry(SStreamJobEngineState engineState, int nJob)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::System);
STREAM_DECOMPRESS_TRACE("[StreamDecrypt],DecryptBlockEntry,0x%x,%s,0x%p,%i\n", CryGetCurrentThreadId(), m_strFileName.c_str(), this, nJob);
SStreamJobQueue::Job& job = m_pDecryptQueue->m_jobs[nJob];
void* const pSrc = job.pSrc;
SStreamPageHdr* const pSrcHdr = job.pSrcHdr;
const uint32 nOffs = job.nOffs;
const uint32 nBytes = job.nBytes;
const bool bLast = job.bLast;
const bool bFailed = HasFailed();
const bool bCompressed = m_bCompressedBuffer;
CAsyncIOFileRequest_TransferPtr pSelf(this);
bool decryptOK = false;
if (!bFailed)
{
#if defined(STREAMENGINE_ENABLE_TIMING)
LARGE_INTEGER liStart;
QueryPerformanceCounter(&liStart);
#endif
//printf("Inflate: %s Avail in: %d, Avail Out: %d, Next In: 0x%p, Next Out: 0x%p\n", m_strFileName.c_str(), m_pZlibStream->avail_in, m_pZlibStream->avail_out, m_pZlibStream->next_in, m_pZlibStream->next_out);
#ifdef STREAMENGINE_ENABLE_LISTENER
NotifyListenerDecrypt decryptListener(gEnv->pSystem->GetStreamEngine()->GetListener(), this);
#endif
unsigned long nBytesDecrypted = m_nBytesDecrypted;
uint8_t* pData = (uint8_t*)pSrc + nOffs;
//if (reinterpret_cast<UINT_PTR>(m_pExternalMemoryBuffer) < 0xc0000000 || reinterpret_cast<UINT_PTR>(m_pExternalMemoryBuffer) >= 0xd0000000)
{
CryOptionalAutoLock<CryCriticalSection> decryptLock(m_externalBufferLockDecrypt, m_pExternalMemoryBuffer != NULL);
if (0)
{
//Intentionally empty
}
#ifdef SUPPORT_RSA_AND_STREAMCIPHER_PAK_ENCRYPTION
else if (m_pDecryptionCTR)
{
STREAM_DECOMPRESS_TRACE ("[StreamDecrypt],ZipEncrypt::DecryptBufferWithStreamCipher,0x%x,%s,0x%p,%i,0x%p,%i,%i\n",
CryGetCurrentThreadId(),
m_strFileName.c_str(),
pData,
m_nFileSize - nBytesDecrypted,
(uint8_t*)pSrc + nOffs,
nBytes,
nBytesDecrypted);
decryptOK = ZipEncrypt::DecryptBufferWithStreamCipher(
pData, //In
pData, //Out - same = decrypt in place
nBytes,
m_pDecryptionCTR);
nBytesDecrypted += decryptOK ? nBytes : 0;
}
#endif
else
{
//Should never get here, this should have been checked in the prep functions
CryFatalError("Invalid encryption technique in streaming engine");
}
}
m_nBytesDecrypted = nBytesDecrypted;
//inform listen, so aysnc callback does not overlap
#ifdef STREAMENGINE_ENABLE_LISTENER
decryptListener.End();
#endif
if (decryptOK)
{
#if defined(STREAMENGINE_ENABLE_TIMING)
LARGE_INTEGER liEnd, liFreq;
QueryPerformanceCounter(&liEnd);
QueryPerformanceFrequency(&liFreq);
m_decryptTime += CTimeValue((int64)((liEnd.QuadPart - liStart.QuadPart) * CTimeValue::TIMEVALUE_PRECISION / liFreq.QuadPart));
#endif
}
else
{
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_ERROR_DBGBRK, "Decrypt Error: %s\n", m_strFileName.c_str());
Failed(ERROR_DECRYPTION_FAIL);
}
}
// FIXME later - if we end up here with a uncompressed request, that is not in-place, this won't copy
// to the output. Not currently an issue given how ConfigureRead sets up m_bStreamInPlace, but may be in
// future.
if (!decryptOK || !bCompressed) // Inverse of push condition below
{
if (pSrcHdr)
{
if (CryInterlockedDecrement(&pSrcHdr->nRefs) == 0)
{
engineState.pTempMem->TempFree(engineState.pHeap, pSrc, pSrcHdr->nSize);
}
}
}
int nPopSlot = m_pDecryptQueue->Pop();
// job is no longer valid
if (decryptOK && bCompressed)
{
PushDecompressBlock(engineState, pSrc, pSrcHdr, nOffs, nBytes, bLast);
if (pSrcHdr)
{
if (CryInterlockedDecrement(&pSrcHdr->nRefs) == 0)
{
engineState.pTempMem->TempFree(engineState.pHeap, pSrc, pSrcHdr->nSize);
}
}
}
if (HasFailed() || bLast)
{
JobFinalize_Decrypt(pSelf, engineState);
}
else if (nPopSlot >= 0)
{
// Chain start the next job, we're responsible for it.
STREAM_DECOMPRESS_TRACE("[StreamDecrypt],Chaining,0x%x,%s,0x%p,%i\n", CryGetCurrentThreadId(), m_strFileName.c_str(), this, nPopSlot);
JobStart_Decrypt(pSelf, engineState, nPopSlot);
}
#if defined(STREAMENGINE_ENABLE_STATS)
CryInterlockedDecrement(&engineState.pStats->nCurrentDecryptCount);
#endif
}
#endif //STREAMENGINE_SUPPORT_DECRYPT
//////////////////////////////////////////////////////////////////////////
uint32 CAsyncIOFileRequest::PushDecompressPage(const SStreamJobEngineState& engineState, void* pSrc, SStreamPageHdr* pSrcHdr, uint32 nBytes, bool bLast)
@@ -502,71 +324,10 @@ void CAsyncIOFileRequest::JobStart_Decompress(CAsyncIOFileRequest_TransferPtr& p
}); // Legacy JobManager priority: eStreamPriority
}
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
uint32 CAsyncIOFileRequest::PushDecryptPage(const SStreamJobEngineState& engineState, void* pSrc, SStreamPageHdr* pSrcHdr, uint32 nBytes, bool bLast)
{
uint32 nError = 0;
for (uint32 nBlockPos = 0; !nError && (nBlockPos < nBytes); nBlockPos += STREAMING_BLOCK_SIZE)
{
bool bLastBlock = (nBlockPos + STREAMING_BLOCK_SIZE) >= nBytes;
uint32 nBlockSize = min(nBytes - nBlockPos, (uint32)STREAMING_BLOCK_SIZE);
nError = PushDecryptBlock(engineState, pSrc, pSrcHdr, nBlockPos, nBlockSize, bLast && bLastBlock);
}
return nError;
}
uint32 CAsyncIOFileRequest::PushDecryptBlock(const SStreamJobEngineState& engineState, void* pSrc, SStreamPageHdr* pSrcHdr, uint32 nOffs, uint32 nBytes, bool bLast)
{
uint32 nError = m_nError;
if (!nError)
{
if (pSrcHdr)
{
CryInterlockedIncrement(&pSrcHdr->nRefs);
}
int nPushJob = m_pDecryptQueue->Push(pSrc, pSrcHdr, nOffs, nBytes, bLast);
if (nPushJob >= 0)
{
STREAM_DECOMPRESS_TRACE("[StreamDecrypt],PushDecryptBlock,0x%x,%s,0x%p,%i\n", CryGetCurrentThreadId(), m_strFileName.c_str(), this, nPushJob);
AddRef();
CAsyncIOFileRequest_TransferPtr pSelf(this);
JobStart_Decrypt(pSelf, engineState, nPushJob);
}
}
return nError;
}
void CAsyncIOFileRequest::JobStart_Decrypt(CAsyncIOFileRequest_TransferPtr& pSelf, const SStreamJobEngineState& engineState, int nJob)
{
STREAM_DECOMPRESS_TRACE("[StreamDecrypt],QueueDecryptBlockAppend,0x%x,%s,0x%p,%i\n", CryGetCurrentThreadId(), pSelf->m_strFileName.c_str(), &pSelf, nJob);
#if defined(STREAMENGINE_ENABLE_STATS)
CryInterlockedIncrement(&engineState.pStats->nCurrentDecryptCount);
#endif
CAsyncIOFileRequest* request = pSelf.Relinquish();
if (!request->m_decryptJobExecutor)
{
request->m_decryptJobExecutor = AZStd::make_unique<AZ::LegacyJobExecutor>();
}
request->m_decryptJobExecutor->StartJob([request, engineState, nJob]()
{
request->DecryptBlockEntry(engineState, nJob);
}); // Legacy JobManager priority: eStreamPriority
}
#endif //STREAMENGINE_SUPPORT_DECRYPT
//////////////////////////////////////////////////////////////////////////
void CAsyncIOFileRequest::JobFinalize_Read(CAsyncIOFileRequest_TransferPtr& pSelf, const SStreamJobEngineState& engineState)
{
if ((!pSelf->m_bCompressedBuffer && !pSelf->m_bEncryptedBuffer) || pSelf->HasFailed())
if (!pSelf->m_bCompressedBuffer || pSelf->HasFailed())
{
JobFinalize_Transfer(pSelf, engineState);
}
@@ -608,39 +369,6 @@ void CAsyncIOFileRequest::JobFinalize_Decompress(CAsyncIOFileRequest_TransferPtr
JobFinalize_Transfer(pSelf, engineState);
}
void CAsyncIOFileRequest::JobFinalize_Decrypt(CAsyncIOFileRequest_TransferPtr& pSelf, const SStreamJobEngineState& engineState)
{
STREAM_DECOMPRESS_TRACE("[StreamDecompress],FinalizeDecompress,0x%x,%s,0x%p,0x%p,0x%p,0x%p\n", CryGetCurrentThreadId(), pSelf->m_strFileName.c_str(), &pSelf, &engineState, engineState.pStats, engineState.pDecompressStats);
CAsyncIOFileRequest* pReq = &*pSelf;
const bool bCompressed = pReq->m_bCompressedBuffer;
const bool bFailed = pReq->HasFailed();
if (!bCompressed && !bFailed)
{
pReq->JobFinalize_Validate(engineState);
}
pReq->JobFinalize_Buffer(engineState);
#if defined(STREAMENGINE_ENABLE_STATS) && defined(STREAMENGINE_ENABLE_TIMING)
if (pReq->m_decryptTime.GetValue() != 0)
{
engineState.pDecompressStats->m_nTotalBytesDecrypted += pReq->m_nFileSize;
engineState.pDecompressStats->m_totalDecryptTime += pReq->m_decryptTime;
engineState.pDecompressStats->m_nTempBytesDecrypted += pReq->m_nFileSize;
engineState.pDecompressStats->m_tempDecryptTime += pReq->m_decryptTime;
}
#endif
if (!bCompressed || pReq->HasFailed())
{
JobFinalize_Transfer(pSelf, engineState);
}
}
void CAsyncIOFileRequest::JobFinalize_Buffer(const SStreamJobEngineState& engineState)
{
if (CryInterlockedDecrement(&m_nMemoryBufferUsers) == 0)
@@ -58,7 +58,6 @@ CStreamEngine::CStreamEngine()
m_Statistics.nPendingReadBytes = 0;
m_Statistics.nCurrentAsyncCount = 0;
m_Statistics.nCurrentDecryptCount = 0;
m_Statistics.nCurrentDecompressCount = 0;
m_Statistics.nCurrentFinishedCount = 0;
@@ -548,13 +547,10 @@ void CStreamEngine::Update()
{
// Repeat every second.
m_nUnzipBandwidth = m_decompressStats.m_tempUnzipTime.GetValue() == 0 ? 0 : (uint32)(m_decompressStats.m_nTempBytesUnziped / m_decompressStats.m_tempUnzipTime.GetSeconds());
m_nDecryptBandwidth = m_decompressStats.m_tempDecryptTime.GetValue() == 0 ? 0 : (uint32)(m_decompressStats.m_nTempBytesDecrypted / m_decompressStats.m_tempDecryptTime.GetSeconds());
m_nVerifyBandwidth = m_decompressStats.m_tempVerifyTime.GetValue() == 0 ? 0 : (uint32)(m_decompressStats.m_nTempBytesVerified / m_decompressStats.m_tempVerifyTime.GetSeconds());
m_decompressStats.m_tempUnzipTime.SetValue(0);
m_decompressStats.m_nTempBytesUnziped = 0;
m_decompressStats.m_tempDecryptTime.SetValue(0);
m_decompressStats.m_nTempBytesDecrypted = 0;
m_decompressStats.m_tempVerifyTime.SetValue(0);
m_decompressStats.m_nTempBytesVerified = 0;
@@ -564,20 +560,14 @@ void CStreamEngine::Update()
{
m_nUnzipBandwidthAverage = (uint32)(m_decompressStats.m_nTotalBytesUnziped / m_decompressStats.m_totalUnzipTime.GetSeconds());
}
if (m_decompressStats.m_totalDecryptTime.GetValue() != 0)
{
m_nDecryptBandwidthAverage = (uint32)(m_decompressStats.m_nTotalBytesDecrypted / m_decompressStats.m_totalDecryptTime.GetSeconds());
}
if (m_decompressStats.m_totalVerifyTime.GetValue() != 0)
{
m_nVerifyBandwidthAverage = (uint32)(m_decompressStats.m_nTotalBytesVerified / m_decompressStats.m_totalVerifyTime.GetSeconds());
}
m_Statistics.nDecompressBandwidth = m_nUnzipBandwidth;
m_Statistics.nDecryptBandwidth = m_nDecryptBandwidth;
m_Statistics.nVerifyBandwidth = m_nVerifyBandwidth;
m_Statistics.nDecompressBandwidthAverage = m_nUnzipBandwidthAverage;
m_Statistics.nDecryptBandwidthAverage = m_nDecryptBandwidthAverage;
m_Statistics.nVerifyBandwidthAverage = m_nVerifyBandwidthAverage;
CTimeValue currentTime = gEnv->pTimer->GetAsyncTime();
@@ -1388,14 +1378,14 @@ void CStreamEngine::DrawStatistics()
const char* sMediaType = m_bStreamDataOnHDD ? "HDD" : "DVD";
const char* sStatus = (m_bStreamingStatsPaused) ? "Paused" : "";
DrawText(tx, ty += ystep, clText, "Streaming IO: %.2f|%.2fMB/s, ACT: %3dmsec, Unzip: %.2fMB/s, Decrypt: %.2fMB/s, Verify: %.2fMB/s, Jobs:%5d (%4d) %s %s",
DrawText(tx, ty += ystep, clText, "Streaming IO: %.2f|%.2fMB/s, ACT: %3dmsec, Unzip: %.2fMB/s, Verify: %.2fMB/s, Jobs:%5d (%4d) %s %s",
(float)stats.nTotalCurrentReadBandwidth / (1024 * 1024), (float)stats.nTotalSessionReadBandwidth / (1024 * 1024),
(uint32)stats.fAverageCompletionTime, (float)stats.nDecompressBandwidth / (1024 * 1024), (float)stats.nDecryptBandwidth / (1024 * 1024), (float)stats.nVerifyBandwidth / (1024 * 1024),
(uint32)stats.fAverageCompletionTime, (float)stats.nDecompressBandwidth / (1024 * 1024), (float)stats.nVerifyBandwidth / (1024 * 1024),
(uint32)stats.nTotalStreamingRequestCount, (uint32)(stats.nTotalRequestCount - stats.nTotalStreamingRequestCount),
sMediaType, sStatus);
DrawText(tx, ty += ystep, clText, "\t Request: Active:%2d (%2.1fMB) Live:%2d Decrypt:%2d Decompress:%2d Async:%2d Finished:%2d Temp Pool Max:%2.1fMB", openStats.nOpenRequestCount,
(float)stats.nPendingReadBytes / (1024 * 1024), CAsyncIOFileRequest::s_nLiveRequests, stats.nCurrentDecryptCount, stats.nCurrentDecompressCount, stats.nCurrentAsyncCount, stats.nCurrentFinishedCount,
DrawText(tx, ty += ystep, clText, "\t Request: Active:%2d (%2.1fMB) Live:%2d Decompress:%2d Async:%2d Finished:%2d Temp Pool Max:%2.1fMB", openStats.nOpenRequestCount,
(float)stats.nPendingReadBytes / (1024 * 1024), CAsyncIOFileRequest::s_nLiveRequests, stats.nCurrentDecompressCount, stats.nCurrentAsyncCount, stats.nCurrentFinishedCount,
(float)stats.nMaxTempMemory / (1024 * 1024));
ty += ystep;
@@ -1577,10 +1567,8 @@ void CStreamEngine::ClearStatistics()
m_PerExtensionInfo.clear();
m_Statistics.nDecompressBandwidth = 0;
m_Statistics.nDecryptBandwidth = 0;
m_Statistics.nVerifyBandwidth = 0;
m_Statistics.nDecompressBandwidthAverage = 0;
m_Statistics.nDecryptBandwidthAverage = 0;
m_Statistics.nVerifyBandwidthAverage = 0;
m_Statistics.nTotalBytesRead = 0;
@@ -213,11 +213,9 @@ private:
TExtensionInfoMap m_PerExtensionInfo;
//////////////////////////////////////////////////////////////////////////
// Used to calculate unzip/decrypt/verify bandwidth for statistics.
// Used to calculate unzip/verify bandwidth for statistics.
uint32 m_nUnzipBandwidth;
uint32 m_nUnzipBandwidthAverage;
uint32 m_nDecryptBandwidth;
uint32 m_nDecryptBandwidthAverage;
uint32 m_nVerifyBandwidth;
uint32 m_nVerifyBandwidthAverage;
CTimeValue m_nLastBandwidthUpdateTime;
@@ -343,7 +343,6 @@ void CStreamingIOThread::Run()
break;
default:
pFileRequest->SyncWithDecrypt();
pFileRequest->SyncWithDecompress();
pFileRequest->Failed(nError);
@@ -433,7 +433,6 @@ void CReadStream::FreeTemporaryMemory()
if (m_pFileRequest)
{
m_pFileRequest->SyncWithDecompress();
m_pFileRequest->SyncWithDecrypt();
m_pFileRequest->FreeBuffer();
}
m_pBuffer = 0;
+11 -30
View File
@@ -21,13 +21,14 @@
#include <AzCore/IO/IStreamer.h>
#include <AzCore/IO/SystemFile.h>
#include "CryLibrary.h"
#include "ICrypto.h"
#include <CryPath.h>
#include <CrySystemBus.h>
#include <AzFramework/API/ApplicationAPI.h>
#include <AzFramework/API/ApplicationAPI_Platform.h>
#include <AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h>
#include <AzCore/Debug/Trace.h>
#include <AzCore/Debug/IEventLogger.h>
#include <AzCore/Interface/Interface.h>
#include <AzFramework/Logging/MissingAssetLogger.h>
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
#include <AzFramework/API/AtomActiveInterface.h>
@@ -120,7 +121,6 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
#endif
#include <INetwork.h>
#include <I3DEngine.h>
#include <IRenderer.h>
#include <IMovieSystem.h>
@@ -180,8 +180,6 @@ WATERMARKDATA(_m);
#include <AzFramework/Asset/AssetSystemBus.h>
#include <AzFramework/Input/Buses/Requests/InputSystemRequestBus.h>
#include <ICrypto.h>
#ifdef WIN32
#include <AzFramework/Input/Buses/Notifications/RawInputNotificationBus_Platform.h>
@@ -396,7 +394,6 @@ CSystem::CSystem(SharedEnvironmentInstance* pSharedEnvironment)
m_pILZ4Decompressor = NULL;
m_pIZStdDecompressor = nullptr;
m_pLocalizationManager = NULL;
m_crypto = nullptr;
m_sys_physics_CPU = 0;
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION SYSTEM_CPP_SECTION_2
@@ -721,7 +718,6 @@ void CSystem::ShutDown()
SAFE_DELETE(m_env.pServiceNetwork);
SAFE_RELEASE(m_env.pLyShine);
SAFE_RELEASE(m_env.pCryFont);
SAFE_RELEASE(m_env.pNetwork);
SAFE_RELEASE(m_env.p3DEngine); // depends on EntitySystem
if (m_env.pConsole)
{
@@ -786,8 +782,6 @@ void CSystem::ShutDown()
SAFE_DELETE(m_pDefaultValidator);
m_pValidator = nullptr;
SAFE_DELETE(m_crypto);
SAFE_DELETE(m_env.pOverloadSceneManager);
SAFE_DELETE(m_pLocalizationManager);
@@ -853,10 +847,14 @@ void CSystem::Quit()
GetIRenderer()->RestoreGamma();
}
SAFE_RELEASE(m_env.pNetwork);
gEnv->pLog->FlushAndClose();
// Latest possible place to flush any pending messages to disk before the forceful termination.
if (auto logger = AZ::Interface<AZ::Debug::IEventLogger>::Get(); logger)
{
logger->Flush();
}
/*
* TODO: This call to _exit, _Exit, TerminateProcess etc. needs to
* eventually be removed. This causes an extremely early exit before we
@@ -1340,7 +1338,7 @@ bool CSystem::UpdatePreTickBus(int updateFlags, int nPauseMode)
gEnv->pLocalMemoryUsage->OnUpdate();
}
if (!gEnv->IsEditor())
if (!gEnv->IsEditor() && gEnv->pRenderer)
{
// If the dimensions of the render target change,
// or are different from the camera defaults,
@@ -1550,21 +1548,12 @@ bool CSystem::UpdatePreTickBus(int updateFlags, int nPauseMode)
m_pServerThrottle->Update();
}
//////////////////////////////////////////////////////////////////////
// initial network update
if (m_env.pNetwork)
{
FRAME_PROFILER("INetwork::SyncWithGame", gEnv->pSystem, PROFILE_SYSTEM);
m_env.pNetwork->SyncWithGame(eNGS_FrameStart);
}
//////////////////////////////////////////////////////////////////////////
if (m_env.pRenderer->GetIStereoRenderer()->IsRenderingToHMD())
{
EBUS_EVENT(AZ::VR::HMDDeviceRequestBus, UpdateInternalState);
}
//////////////////////////////////////////////////////////////////////
//update console system
if (m_env.pConsole)
@@ -1722,7 +1711,7 @@ bool CSystem::UpdatePostTickBus(int updateFlags, int nPauseMode)
//////////////////////////////////////////////////////////////////////
//update process (3D engine)
if (!(updateFlags & ESYSUPDATE_EDITOR) && !m_bNoUpdate)
if (!(updateFlags & ESYSUPDATE_EDITOR) && !m_bNoUpdate && m_env.p3DEngine)
{
FRAME_PROFILER("SysUpdate:Update3DEngine", this, PROFILE_SYSTEM);
@@ -1770,14 +1759,6 @@ bool CSystem::UpdatePostTickBus(int updateFlags, int nPauseMode)
m_bNeedDoWorkDuringOcclusionChecks = true;
}
//////////////////////////////////////////////////////////////////////
// final network update
if (m_env.pNetwork)
{
FRAME_PROFILER("SysUpdate - Network::SyncWithGame", this, PROFILE_SYSTEM);
m_env.pNetwork->SyncWithGame(eNGS_FrameEnd);
}
//Now update frame statistics
CTimeValue cur_time = gEnv->pTimer->GetAsyncTime();
@@ -1814,7 +1795,7 @@ bool CSystem::UpdatePostTickBus(int updateFlags, int nPauseMode)
}
// If it's in editing mode (in editor) the render is done in RenderViewport so we skip rendering here.
if (!gEnv->IsEditing())
if (!gEnv->IsEditing() && gEnv->pRenderer && gEnv->p3DEngine)
{
if (GetIViewSystem())
{
-12
View File
@@ -258,10 +258,6 @@ struct SSystemCVars
int sys_vtune;
float sys_update_profile_time;
int sys_limit_phys_thread_count;
int sys_usePlatformSavingAPI;
#ifndef _RELEASE
int sys_usePlatformSavingAPIEncryption;
#endif
int sys_MaxFPS;
float sys_maxTimeStepForMovieSystem;
int sys_force_installtohdd_mode;
@@ -476,7 +472,6 @@ public:
IRenderer* GetIRenderer(){ return m_env.pRenderer; }
ITimer* GetITimer(){ return m_env.pTimer; }
INetwork* GetINetwork(){ return m_env.pNetwork; }
AZ::IO::IArchive* GetIPak() { return m_env.pCryPak; };
IConsole* GetIConsole() { return m_env.pConsole; };
IRemoteConsole* GetIRemoteConsole();
@@ -506,7 +501,6 @@ public:
ILZ4Decompressor* GetLZ4Decompressor() { return m_pILZ4Decompressor; }
IZStdDecompressor* GetZStdDecompressor() { return m_pIZStdDecompressor; }
WIN_HWND GetHWND(){ return m_hWnd; }
ICrypto* GetCrypto() { return m_crypto; }
//////////////////////////////////////////////////////////////////////////
// retrieves the perlin noise singleton instance
CPNoise3* GetNoiseGen();
@@ -687,9 +681,6 @@ private:
//! @name Initialization routines
//@{
bool InitNetwork(const SSystemInitParams& startupParams);
bool InitConsole();
bool InitRenderer(WIN_HINSTANCE hinst, WIN_HWND hwnd, const SSystemInitParams& initParams);
@@ -904,9 +895,6 @@ private: // ------------------------------------------------------
//! System access to zstd decompressor
IZStdDecompressor* m_pIZStdDecompressor;
//! System for cryptography
ICrypto* m_crypto;
// XML Utils interface.
class CXmlUtils* m_pXMLUtils;
+34 -93
View File
@@ -87,7 +87,6 @@
#endif //WIN32
#include <INetwork.h>
#include <I3DEngine.h>
#include <IRenderer.h>
#include <AzCore/IO/FileIO.h>
@@ -134,7 +133,6 @@
#include "RemoteCommand.h"
#include "LevelSystem/LevelSystem.h"
#include "ViewSystem/ViewSystem.h"
#include <Cryptography/Crypto.h>
#include <CrySystemBus.h>
#include <AzCore/Jobs/JobFunction.h>
#include <AzCore/Jobs/JobManagerBus.h>
@@ -247,27 +245,24 @@ CUNIXConsole* pUnixConsole;
#define CRYENGINE_DEFAULT_LOCALIZATION_LANG "en-US"
#define LOCALIZATION_TRANSLATIONS_LIST_FILE_NAME "Libs/Localization/localization.xml"
#define LOAD_LEGACY_RENDERER_FOR_EDITOR true // If you set this to false you must for now also set 'ed_useAtomNativeViewport' to true (see /Code/Sandbox/Editor/ViewManager.cpp)
#define LOAD_LEGACY_RENDERER_FOR_LAUNCHER true
//////////////////////////////////////////////////////////////////////////
// Where possible, these are defaults used to initialize cvars
// System.cfg can then be used to override them
// This includes the Game DLL, although it is loaded elsewhere
#define DLL_NETWORK "CryNetwork"
#define DLL_ONLINE "CryOnline"
#define DLL_MOVIE "CryMovie"
#define DLL_FONT "CryFont"
#define DLL_3DENGINE "Cry3DEngine"
#define DLL_RENDERER_DX9 "CryRenderD3D9"
#define DLL_RENDERER_DX11 "CryRenderD3D11"
#define DLL_RENDERER_DX12 "CryRenderD3D12"
#define DLL_RENDERER_METAL "CryRenderMetal"
#define DLL_RENDERER_GL "CryRenderGL"
#define DLL_RENDERER_NULL "CryRenderNULL"
#define DLL_GAME "GameDLL"
#define DLL_UNITTESTS "CryUnitTests"
#define DLL_SHINE "LyShine"
#define DLL_LMBRAWS "LmbrAWS"
#define DLL_FONT "CryFont"
#define DLL_3DENGINE "Cry3DEngine"
#define DLL_RENDERER_DX9 "CryRenderD3D9"
#define DLL_RENDERER_DX11 "CryRenderD3D11"
#define DLL_RENDERER_DX12 "CryRenderD3D12"
#define DLL_RENDERER_METAL "CryRenderMetal"
#define DLL_RENDERER_GL "CryRenderGL"
#define DLL_RENDERER_NULL "CryRenderNULL"
#define DLL_SHINE "LyShine"
//////////////////////////////////////////////////////////////////////////
#if defined(WIN32) || defined(LINUX) || defined(APPLE)
@@ -547,10 +542,6 @@ static void GetSpecConfigFileToLoad(ICVar* pVar, AZStd::string& cfgFile, ESystem
case CONFIG_IOS:
cfgFile = "ios";
break;
#if defined(AZ_PLATFORM_XENIA) || defined(TOOLS_SUPPORT_XENIA)
#define AZ_RESTRICTED_SECTION SYSTEMINIT_CPP_SECTION_3
#include AZ_RESTRICTED_FILE_EXPLICIT(SystemInit_cpp, xenia)
#endif
#if defined(AZ_PLATFORM_JASPER) || defined(TOOLS_SUPPORT_JASPER)
#define AZ_RESTRICTED_SECTION SYSTEMINIT_CPP_SECTION_3
#include AZ_RESTRICTED_FILE_EXPLICIT(SystemInit_cpp, jasper)
@@ -736,10 +727,6 @@ static void LoadDetectedSpec(ICVar* pVar)
#endif
break;
}
#if defined(AZ_PLATFORM_XENIA) || defined(TOOLS_SUPPORT_XENIA)
#define AZ_RESTRICTED_SECTION SYSTEMINIT_CPP_SECTION_5
#include AZ_RESTRICTED_FILE_EXPLICIT(SystemInit_cpp, xenia)
#endif
#if defined(AZ_PLATFORM_JASPER) || defined(TOOLS_SUPPORT_JASPER)
#define AZ_RESTRICTED_SECTION SYSTEMINIT_CPP_SECTION_5
#include AZ_RESTRICTED_FILE_EXPLICIT(SystemInit_cpp, jasper)
@@ -1368,25 +1355,6 @@ bool CSystem::OpenRenderLibrary(int type, const SSystemInitParams& initParams)
return true;
}
/////////////////////////////////////////////////////////////////////////////////
bool CSystem::InitNetwork(const SSystemInitParams& initParams)
{
LOADING_TIME_PROFILE_SECTION(GetISystem());
if (!InitializeEngineModule(DLL_NETWORK, "EngineModule_CryNetwork", initParams))
{
return false;
}
if (!m_env.pNetwork)
{
AZ_Assert(false, "Network System did not initialize correctly; it was not found in the system environment.");
return false;
}
return true;
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
bool CSystem::InitConsole()
@@ -1990,9 +1958,13 @@ bool CSystem::InitShine([[maybe_unused]] const SSystemInitParams& initParams)
{
LOADING_TIME_PROFILE_SECTION(GetISystem());
// Initialize UI system if one exists
EBUS_EVENT(UiSystemBus, InitializeSystem);
if (!m_env.pLyShine)
{
AZ_Error(AZ_TRACE_SYSTEM_WINDOW, false, "LYShine System did not initialize correctly. Please check that the LyShine gem is enabled for this project in ProjectConfigurator.");
return false;
}
return true;
}
@@ -3029,7 +3001,10 @@ AZ_POP_DISABLE_WARNING
//////////////////////////////////////////////////////////////////////////
// RENDERER
//////////////////////////////////////////////////////////////////////////
if (!startupParams.bSkipRenderer)
const bool loadLegacyRenderer = gEnv->IsEditor() ?
LOAD_LEGACY_RENDERER_FOR_EDITOR :
LOAD_LEGACY_RENDERER_FOR_LAUNCHER;
if (loadLegacyRenderer && !startupParams.bSkipRenderer)
{
AZ_Assert(CryMemory::IsHeapValid(), "CryMemory must be valid before initializing renderer.");
AZ_Printf(AZ_TRACE_SYSTEM_WINDOW, "Renderer initialization");
@@ -3048,23 +3023,21 @@ AZ_POP_DISABLE_WARNING
LoadConfiguration("mgpu.cfg");
}
}
}
InlineInitializationProcessing("CSystem::Init InitRenderer");
InlineInitializationProcessing("CSystem::Init InitRenderer");
if (m_env.pCryFont)
{
m_env.pCryFont->SetRendererProperties(m_env.pRenderer);
}
AZ_Assert(m_env.pRenderer || startupParams.bSkipRenderer, "The renderer did not initialize correctly.");
}
#if !defined(AZ_RELEASE_BUILD) && defined(AZ_PLATFORM_ANDROID)
m_thermalInfoHandler = AZStd::make_unique<ThermalInfoAndroidHandler>();
#endif
if (m_env.pCryFont)
{
m_env.pCryFont->SetRendererProperties(m_env.pRenderer);
}
InlineInitializationProcessing("CSystem::Init m_pResourceManager->UnloadFastLoadPaks");
AZ_Assert(m_env.pRenderer || startupParams.bSkipRenderer, "The renderer did not initialize correctly.");
if (g_cvars.sys_rendersplashscreen && !startupParams.bEditor && !startupParams.bShaderCacheGen)
{
if (m_env.pRenderer)
@@ -3283,7 +3256,7 @@ AZ_POP_DISABLE_WARNING
//////////////////////////////////////////////////////////////////////////
// Init 3d engine
//////////////////////////////////////////////////////////////////////////
if (!startupParams.bSkipRenderer && !startupParams.bShaderCacheGen)
if (loadLegacyRenderer && !startupParams.bSkipRenderer && !startupParams.bShaderCacheGen)
{
AZ_Printf(AZ_TRACE_SYSTEM_WINDOW, "Initializing 3D Engine");
INDENT_LOG_DURING_SCOPE();
@@ -3298,28 +3271,10 @@ AZ_POP_DISABLE_WARNING
{
m_env.pRenderer->TryFlush();
}
InlineInitializationProcessing("CSystem::Init Init3DEngine");
}
InlineInitializationProcessing("CSystem::Init Init3DEngine");
m_crypto = new Crypto();
//////////////////////////////////////////////////////////////////////////
// NETWORK
//////////////////////////////////////////////////////////////////////////
if (!startupParams.bSkipNetwork && !startupParams.bPreview && !startupParams.bShaderCacheGen)
{
AZ_Printf(AZ_TRACE_SYSTEM_WINDOW, "Network initialization");
INDENT_LOG_DURING_SCOPE();
InitNetwork(startupParams);
if (gEnv->IsDedicated())
{
m_pServerThrottle.reset(new CServerThrottle(this, m_pCpu->GetCPUCount()));
}
}
InlineInitializationProcessing("CSystem::Init InitNetwork");
//////////////////////////////////////////////////////////////////////////
// SERVICE NETWORK
//////////////////////////////////////////////////////////////////////////
@@ -3336,7 +3291,6 @@ AZ_POP_DISABLE_WARNING
m_env.pRemoteCommandManager = new CRemoteCommandManager();
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
@@ -4915,19 +4869,6 @@ void CSystem::CreateSystemVars()
#include AZ_RESTRICTED_FILE(SystemInit_cpp)
#endif
#if defined(WIN32)
static const int default_sys_usePlatformSavingAPI = 0;
static const int default_sys_usePlatformSavingAPIDefault = 0;
#else
static const int default_sys_usePlatformSavingAPI = 1;
static const int default_sys_usePlatformSavingAPIDefault = 1;
#endif
REGISTER_CVAR2("sys_usePlatformSavingAPI", &g_cvars.sys_usePlatformSavingAPI, default_sys_usePlatformSavingAPI, VF_CHEAT, "Use the platform APIs for saving and loading (complies with TRCs, but allocates lots of memory)");
#ifndef _RELEASE
REGISTER_CVAR2("sys_usePlatformSavingAPIEncryption", &g_cvars.sys_usePlatformSavingAPIEncryption, default_sys_usePlatformSavingAPIDefault, VF_CHEAT, "Use encryption cipher when using the platform APIs for saving and loading");
#endif
// adding CVAR to toggle assert verbosity level
const int defaultAssertValue = 1;
REGISTER_CVAR2_CB("sys_asserts", &g_cvars.sys_asserts, defaultAssertValue, VF_CHEAT,
-27
View File
@@ -15,7 +15,6 @@
#include "System.h"
#include <time.h>
#include <INetwork.h>
#include <I3DEngine.h>
#include <IRenderer.h>
#include <IMovieSystem.h>
@@ -91,11 +90,7 @@ static AZStd::vector<AZStd::string> GetModuleNames()
moduleNames.push_back("Cry3DEngine" MODULE_EXTENSION);
moduleNames.push_back("CryFont" MODULE_EXTENSION);
moduleNames.push_back("CryNetwork" MODULE_EXTENSION);
moduleNames.push_back("CryPhysics" MODULE_EXTENSION);
moduleNames.push_back("CrySystem" MODULE_EXTENSION);
// K01
moduleNames.push_back("CryOnline" MODULE_EXTENSION);
if (gEnv && gEnv->pConsole)
{
@@ -135,14 +130,7 @@ const char g_szGroupCore[] = "CryEngine";
const char* g_szModuleGroups[][2] = {
{"Editor.exe", g_szGroupCore},
{"CrySystem.dll", g_szGroupCore},
{"CryNetwork.dll", g_szGroupCore},
{"CryPhysics.dll", g_szGroupCore},
{"CryFont.dll", g_szGroupCore},
{"Cry3DEngine.dll", g_szGroupCore},
{"CryRenderD3D9.dll", g_szGroupCore},
{"CryRenderD3D10.dll", g_szGroupCore},
{"CryRenderOGL.dll", g_szGroupCore},
{"CryRenderNULL.dll", g_szGroupCore}
};
//////////////////////////////////////////////////////////////////////////
@@ -382,21 +370,6 @@ void CSystem::CollectMemStats (ICrySizer* pSizer, MemStatsPurposeEnum nPurpose,
}
}
if (m_env.pNetwork)
{
SIZER_COMPONENT_NAME(pSizer, "Network");
{
SIZER_COMPONENT_NAME (pSizer, "$Allocations waste");
const SmallModuleInfo* info = FindModuleInfo(stats, "CryNetwork.dll");
if (info)
{
pSizer->AddObject(info, info->memInfo.allocated - info->memInfo.requested);
}
}
m_env.pNetwork->GetMemoryStatistics(pSizer);
}
{
SIZER_COMPONENT_NAME(pSizer, "UserData");
if (m_pUserCallback)
-4
View File
@@ -22,10 +22,6 @@
#if defined(USE_UNIXCONSOLE)
#if defined(_MSC_VER)
__pragma(comment(lib, "pdcurses.lib"))
#endif // _MSC_VER
#if !defined(WIN32)
#include <sys/types.h>
#include <sys/select.h>
-1
View File
@@ -19,7 +19,6 @@
#include <IConsole.h>
#include <ITextModeConsole.h>
#include <INetwork.h>
#if defined(USE_DEDICATED_SERVER_CONSOLE)
+1 -1
View File
@@ -105,7 +105,7 @@ void CView::Update(float frameTime, bool isActive)
// Modify FOV based on the HMD device configuration
bool hmdActive = false;
bool isRenderingToHMD = gEnv->pRenderer->GetIStereoRenderer()->IsRenderingToHMD();
bool isRenderingToHMD = gEnv->pRenderer ? gEnv->pRenderer->GetIStereoRenderer()->IsRenderingToHMD() : false;
if (isRenderingToHMD)
{
const AZ::VR::HMDDeviceInfo* deviceInfo = nullptr;
@@ -21,7 +21,6 @@
#include <IConsole.h>
#include <ITextModeConsole.h>
#include <INetwork.h>
#if defined(USE_WINDOWSCONSOLE)
-3
View File
@@ -25,7 +25,6 @@
#include <ITimer.h>
#include <IRenderer.h>
#include <INetwork.h> // EvenBalance - M.Quinn
#include <ISystem.h>
#include <ILog.h>
#include <IProcess.h>
@@ -332,7 +331,6 @@ CXConsole::CXConsole()
m_pSysDeactivateConsole = 0;
m_pFont = NULL;
m_pRenderer = NULL;
m_pNetwork = NULL; // EvenBalance - M. Quinn
m_pImage = NULL;
m_nCursorPos = 0;
m_nScrollPos = 0;
@@ -490,7 +488,6 @@ void CXConsole::Init(ISystem* pSystem)
m_pFont = pSystem->GetICryFont()->GetFont("default");
}
m_pRenderer = pSystem->GetIRenderer();
m_pNetwork = gEnv->pNetwork; // EvenBalance - M. Quinn
m_pTimer = pSystem->GetITimer();
AzFramework::InputChannelEventListener::Connect();
-1
View File
@@ -420,7 +420,6 @@ private: // ----------------------------------------------------------
IFFont* m_pFont;
IRenderer* m_pRenderer;
ITimer* m_pTimer;
INetwork* m_pNetwork; // EvenBalance - M. Quinn
ICVar* m_pSysDeactivateConsole;
-377
View File
@@ -1,377 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "CrySystem_precompiled.h"
#include "System.h"
#include "ZipEncrypt.h"
#include "smartptr.h"
#include "CryZlib.h"
#ifdef INCLUDE_LIBTOMCRYPT
#define mp_count_bits(a) ltc_mp.count_bits(a)
#define mp_unsigned_bin_size(a) ltc_mp.unsigned_size(a)
void ZipEncrypt::Init(const uint8* pKeyData, uint32 keyLen)
{
LOADING_TIME_PROFILE_SECTION;
ltc_mp = ltm_desc;
register_hash (&sha1_desc);
register_hash (&sha256_desc);
register_cipher (&twofish_desc);
int prng_idx = register_prng(&yarrow_desc) != -1;
assert(prng_idx != -1);
rng_make_prng(128, find_prng("yarrow"), &g_yarrow_prng_state, NULL);
int importReturn = rsa_import(pKeyData, (unsigned long)keyLen, &g_rsa_key_public_for_sign);
if (CRYPT_OK != importReturn)
{
#if !defined(_RELEASE)
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_ERROR, "RSA Public Key failed to initialize. Returned %d", importReturn);
#endif //_RELEASE
}
}
bool ZipEncrypt::StartStreamCipher(unsigned char key[16], unsigned char IV[16], symmetric_CTR* pCTR, const unsigned int offset)
{
int err;
int cipher_idx = find_cipher(STREAM_CIPHER_NAME);
if (cipher_idx < 0)
{
return false;
}
err = ctr_start(cipher_idx, IV, key, 16, 0, CTR_COUNTER_LITTLE_ENDIAN, pCTR);
if (err != CRYPT_OK)
{
//printf("ctr_start error: %s\n",error_to_string(errno));
return false;
}
// Seek forward into the stream cipher by offset bytes
unsigned int offset_blocks = offset / pCTR->blocklen;
unsigned int offset_remaining = offset - (offset_blocks * pCTR->blocklen);
if (offset_blocks > 0)
{
SwapEndian((uint32*)(&pCTR->ctr[0]), 4);
*((uint32*)(&pCTR->ctr[0])) += offset_blocks;
SwapEndian((uint32*)(&pCTR->ctr[0]), 4);
ctr_setiv(pCTR->ctr, pCTR->ctrlen, pCTR);
}
// Seek into the last block to initialize the padding
unsigned int bytesConsumed = 0;
while (bytesConsumed < offset_remaining)
{
const static unsigned int bufSize = 1024;
unsigned char buffer[bufSize] = {0};
unsigned int bytesToConsume = min(bufSize, offset_remaining - bytesConsumed);
ctr_decrypt(buffer, buffer, bytesToConsume, pCTR);
bytesConsumed += bytesToConsume;
}
return true;
}
void ZipEncrypt::FinishStreamCipher(symmetric_CTR* pCTR)
{
ctr_done(pCTR);
}
bool ZipEncrypt::DecryptBufferWithStreamCipher(unsigned char* inBuffer, unsigned char* outBuffer, size_t bufferSize, symmetric_CTR* pCTR)
{
int err;
err = ctr_decrypt(inBuffer, outBuffer, bufferSize, pCTR);
if (err != CRYPT_OK)
{
//printf("ctr_encrypt error: %s\n", error_to_string(errno));
return false;
}
return true;
}
bool ZipEncrypt::DecryptBufferWithStreamCipher(unsigned char* inBuffer, size_t bufferSize, unsigned char key[16], unsigned char IV[16])
{
LOADING_TIME_PROFILE_SECTION
symmetric_CTR ctr;
if (!StartStreamCipher(key, IV, &ctr))
{
return false;
}
if (!DecryptBufferWithStreamCipher(inBuffer, inBuffer, bufferSize, &ctr))
{
return false;
}
ctr_done(&ctr);
return true;
}
int ZipEncrypt::GetEncryptionKeyIndex(const AZ::IO::ZipDir::FileEntry* pFileEntry)
{
return (~(pFileEntry->desc.lCRC32 >> 2)) & 0xF;
}
void ZipEncrypt::GetEncryptionInitialVector(const AZ::IO::ZipDir::FileEntry* pFileEntry, unsigned char IV[16])
{
uint32 intIV[4]; //16 byte
intIV[0] = pFileEntry->desc.lSizeUncompressed ^ (pFileEntry->desc.lSizeCompressed << 12);
intIV[1] = (!pFileEntry->desc.lSizeCompressed);
intIV[2] = pFileEntry->desc.lCRC32 ^ (pFileEntry->desc.lSizeCompressed << 12);
intIV[3] = !pFileEntry->desc.lSizeUncompressed ^ pFileEntry->desc.lSizeCompressed;
memcpy(IV, intIV, sizeof(intIV));
}
//////////////////////////////////////////////////////////////////////////
bool ZipEncrypt::RSA_VerifyData(void* inBuffer, int sizeIn, unsigned char* signedHash, int signedHashSize, rsa_key& publicKey)
{
// verify hash
int sha256 = find_hash ("sha256");
if (sha256 == -1)
{
#if !defined(_RELEASE)
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_ERROR_DBGBRK, "Hash program for RSA_VerifyData could not be found. LibTomCrypt has failed to start.");
#endif
return false;
}
int hashSize = 32; // 32 bytes for SHA 256
unsigned char hash_digest[1024]; // 32 bytes should be enough
hash_state md;
hash_descriptor[sha256].init(&md);
hash_descriptor[sha256].process(&md, (unsigned char*)inBuffer, sizeIn);
hash_descriptor[sha256].done(&md, hash_digest); // 32 bytes
assert(hash_descriptor[sha256].hashsize == hashSize);
int prng_idx = find_prng("yarrow");
assert(prng_idx != -1);
// Verify generated hash with RSA public key
int statOut = 0;
int res = rsa_verify_hash(signedHash, signedHashSize, hash_digest, hashSize, sha256, 0, &statOut, &publicKey);
if (res != CRYPT_OK || statOut != 1)
{
return false;
}
return true;
}
bool ZipEncrypt::RSA_VerifyData(const unsigned char** inBuffers, unsigned int* sizesIn, const int numBuffers, unsigned char* signedHash, int signedHashSize, rsa_key& publicKey)
{
// verify hash from multiple buffers
int sha256 = find_hash ("sha256");
if (sha256 == -1)
{
#if !defined(_RELEASE)
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_ERROR_DBGBRK, "Hash program for RSA_VerifyData could not be found. LibTomCrypt has failed to start.");
#endif
return false;
}
int hashSize = 32; // 32 bytes for SHA 256
unsigned char hash_digest[1024]; // 32 bytes should be enough
hash_state md;
hash_descriptor[sha256].init(&md);
for (int i = 0; i < numBuffers; i++)
{
hash_descriptor[sha256].process(&md, inBuffers[i], sizesIn[i]);
}
hash_descriptor[sha256].done(&md, hash_digest); // 32 bytes
assert(hash_descriptor[sha256].hashsize == hashSize);
int prng_idx = find_prng("yarrow");
assert(prng_idx != -1);
// Verify generated hash with RSA public key
int statOut = 0;
int res = rsa_verify_hash(signedHash, signedHashSize, hash_digest, hashSize, sha256, 0, &statOut, &publicKey);
if (res != CRYPT_OK || statOut != 1)
{
return false;
}
return true;
}
//////////////////////////////////////////////////////////////////////////
int ZipEncrypt::custom_rsa_encrypt_key_ex(const unsigned char* in, unsigned long inlen,
unsigned char* out, unsigned long* outlen,
const unsigned char* lparam, unsigned long lparamlen,
prng_state* prng, int prng_idx, int hash_idx, int padding, rsa_key* key)
{
unsigned long modulus_bitlen, modulus_bytelen, x;
int err;
LTC_ARGCHK(in != NULL);
LTC_ARGCHK(out != NULL);
LTC_ARGCHK(outlen != NULL);
LTC_ARGCHK(key != NULL);
/* valid padding? */
if ((padding != LTC_LTC_PKCS_1_V1_5) &&
(padding != LTC_LTC_PKCS_1_OAEP))
{
return CRYPT_PK_INVALID_PADDING;
}
/* valid prng? */
if ((err = prng_is_valid(prng_idx)) != CRYPT_OK)
{
return err;
}
if (padding == LTC_LTC_PKCS_1_OAEP)
{
/* valid hash? */
if ((err = hash_is_valid(hash_idx)) != CRYPT_OK)
{
return err;
}
}
/* get modulus len in bits */
modulus_bitlen = mp_count_bits((key->N));
/* outlen must be at least the size of the modulus */
modulus_bytelen = mp_unsigned_bin_size((key->N));
if (modulus_bytelen > *outlen)
{
*outlen = modulus_bytelen;
return CRYPT_BUFFER_OVERFLOW;
}
if (padding == LTC_LTC_PKCS_1_OAEP)
{
/* OAEP pad the key */
x = *outlen;
if ((err = pkcs_1_oaep_encode(in, inlen, lparam,
lparamlen, modulus_bitlen, prng, prng_idx, hash_idx,
out, &x)) != CRYPT_OK)
{
return err;
}
}
else
{
/* LTC_PKCS #1 v1.5 pad the key */
x = *outlen;
if ((err = pkcs_1_v1_5_encode(in, inlen, LTC_LTC_PKCS_1_EME,
modulus_bitlen, prng, prng_idx,
out, &x)) != CRYPT_OK)
{
return err;
}
}
/* rsa exptmod the OAEP or LTC_PKCS #1 v1.5 pad */
return ltc_mp.rsa_me(out, x, out, outlen, PK_PRIVATE, key);
}
//////////////////////////////////////////////////////////////////////////
int ZipEncrypt::custom_rsa_decrypt_key_ex(const unsigned char* in, unsigned long inlen,
unsigned char* out, unsigned long* outlen,
const unsigned char* lparam, unsigned long lparamlen,
int hash_idx, int padding,
int* stat, rsa_key* key)
{
unsigned long modulus_bitlen, modulus_bytelen, x;
int err;
unsigned char* tmp;
LTC_ARGCHK(out != NULL);
LTC_ARGCHK(outlen != NULL);
LTC_ARGCHK(key != NULL);
LTC_ARGCHK(stat != NULL);
/* default to invalid */
*stat = 0;
/* valid padding? */
if ((padding != LTC_LTC_PKCS_1_V1_5) &&
(padding != LTC_LTC_PKCS_1_OAEP))
{
return CRYPT_PK_INVALID_PADDING;
}
if (padding == LTC_LTC_PKCS_1_OAEP)
{
/* valid hash ? */
if ((err = hash_is_valid(hash_idx)) != CRYPT_OK)
{
return err;
}
}
/* get modulus len in bits */
modulus_bitlen = mp_count_bits((key->N));
/* outlen must be at least the size of the modulus */
modulus_bytelen = mp_unsigned_bin_size((key->N));
if (modulus_bytelen != inlen)
{
return CRYPT_INVALID_PACKET;
}
/* allocate ram */
tmp = (unsigned char*)XMALLOC(inlen);
if (tmp == NULL)
{
return CRYPT_MEM;
}
/* rsa decode the packet */
x = inlen;
if ((err = ltc_mp.rsa_me(in, inlen, tmp, &x, PK_PUBLIC, key)) != CRYPT_OK)
{
XFREE(tmp);
return err;
}
if (padding == LTC_LTC_PKCS_1_OAEP)
{
/* now OAEP decode the packet */
err = pkcs_1_oaep_decode(tmp, x, lparam, lparamlen, modulus_bitlen, hash_idx,
out, outlen, stat);
}
else
{
/* now LTC_PKCS #1 v1.5 depad the packet */
err = pkcs_1_v1_5_decode(tmp, x, LTC_LTC_PKCS_1_EME, modulus_bitlen, out, outlen, stat);
}
XFREE(tmp);
return err;
}
#endif //INCLUDE_LIBTOMCRYPT
//////////////////////////////////////////////////////////////////////////
-50
View File
@@ -1,50 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#pragma once
#include <AzFramework/Archive/ZipFileFormat.h>
#include <AzFramework/Archive/ZipDirStructures.h>
#include "CryTomcrypt.h"
namespace ZipEncrypt
{
#ifdef INCLUDE_LIBTOMCRYPT
void Init(const uint8* pKeyData, uint32 keyLen);
bool StartStreamCipher(unsigned char key[16], unsigned char IV[16], symmetric_CTR * pCTR, const unsigned int offset = 0);
void FinishStreamCipher(symmetric_CTR* pCTR);
bool DecryptBufferWithStreamCipher(unsigned char* inBuffer, unsigned char* outBuffer, size_t bufferSize, symmetric_CTR* pCTR);
bool DecryptBufferWithStreamCipher(unsigned char* inBuffer, size_t bufferSize, unsigned char key[16], unsigned char IV[16]);
int GetEncryptionKeyIndex(const AZ::IO::ZipDir::FileEntry* pFileEntry);
void GetEncryptionInitialVector(const AZ::IO::ZipDir::FileEntry * pFileEntry, unsigned char IV[16]);
bool RSA_VerifyData(void* inBuffer, int sizeIn, unsigned char* signedHash, int signedHashSize, rsa_key& publicKey);
bool RSA_VerifyData(const unsigned char** inBuffers, unsigned int* sizesIn, const int numBuffers, unsigned char* signedHash, int signedHashSize, rsa_key& publicKey);
int custom_rsa_encrypt_key_ex(const unsigned char* in, unsigned long inlen,
unsigned char* out, unsigned long* outlen,
const unsigned char* lparam, unsigned long lparamlen,
prng_state* prng, int prng_idx, int hash_idx, int padding, rsa_key* key);
int custom_rsa_decrypt_key_ex(const unsigned char* in, unsigned long inlen,
unsigned char* out, unsigned long* outlen,
const unsigned char* lparam, unsigned long lparamlen,
int hash_idx, int padding,
int* stat, rsa_key* key);
#endif //INCLUDE_LIBTOMCRYPT
}
@@ -20,7 +20,6 @@ set(FILES
ConsoleHelpGen.cpp
CryAsyncMemcpy.cpp
CrySizerStats.cpp
CryTomcrypt.cpp
DebugCallStack.cpp
GeneralMemoryHeap.cpp
HandlerBase.cpp
@@ -74,7 +73,6 @@ set(FILES
ConsoleBatchFile.h
ConsoleHelpGen.h
CrySizerStats.h
CryTomcrypt.h
CryWaterMark.h
DebugCallStack.h
GeneralMemoryHeap.h
@@ -121,8 +119,6 @@ set(FILES
XML/XmlUtils.h
XML/ReadXMLSink.cpp
XML/WriteXMLSource.cpp
ZipEncrypt.h
ZipEncrypt.cpp
ZipFile.h
ZipFileFormat_info.h
LoadingProfiler.cpp
@@ -162,14 +158,6 @@ set(FILES
Statistics/LocalMemoryUsage.cpp
ZLibCompressor.cpp
ZLibCompressor.h
Cryptography/Crypto.cpp
Cryptography/Crypto.h
Cryptography/rijndael.cpp
Cryptography/StreamCipher.cpp
Cryptography/Whirlpool.cpp
Cryptography/rijndael.h
Cryptography/StreamCipher.h
Cryptography/Whirlpool.h
SoftCode/SoftCodeMgr.cpp
SoftCode/SoftCodeMgr.h
OverloadSceneManager/OverloadSceneManager.cpp