Browse Source

Fix paths and move GetSecureEncryptionKey so things compile again

Michael Hansen 13 years ago
parent
commit
041b1985e4
  1. 4
      Sources/Plasma/Apps/plClient/plClient.cpp
  2. 2
      Sources/Plasma/Apps/plClient/winmain.cpp
  3. 2
      Sources/Plasma/Apps/plFileEncrypt/main.cpp
  4. 16
      Sources/Plasma/Apps/plFileSecure/main.cpp
  5. 4
      Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp
  6. 2
      Sources/Plasma/Apps/plPythonPack/main.cpp
  7. 2
      Sources/Plasma/Apps/plUruLauncher/Pch.h
  8. 1
      Sources/Plasma/CoreLib/CMakeLists.txt
  9. 62
      Sources/Plasma/CoreLib/plFileUtils.cpp
  10. 9
      Sources/Plasma/CoreLib/plFileUtils.h
  11. 2
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp
  12. 2
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp
  13. 2
      Sources/Plasma/FeatureLib/pfCrashHandler/plCrashSrv.cpp
  14. 2
      Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp
  15. 2
      Sources/Plasma/FeatureLib/pfPython/plPythonPack.cpp
  16. 2
      Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.cpp
  17. 2
      Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.cpp
  18. 4
      Sources/Plasma/PubUtilLib/plAgeDescription/plAgeManifest.cpp
  19. 2
      Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp
  20. 2
      Sources/Plasma/PubUtilLib/plAudio/plWin32StreamingSound.cpp
  21. 4
      Sources/Plasma/PubUtilLib/plAudioCore/plAudioFileReader.cpp
  22. 4
      Sources/Plasma/PubUtilLib/plAudioCore/plSoundBuffer.cpp
  23. 61
      Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp
  24. 9
      Sources/Plasma/PubUtilLib/plFile/plSecureStream.h
  25. 2
      Sources/Plasma/PubUtilLib/plFile/plStreamSource.cpp
  26. 2
      Sources/Plasma/PubUtilLib/plGImage/plFontCache.cpp
  27. 2
      Sources/Plasma/PubUtilLib/plGImage/plWinFontCache.cpp
  28. 2
      Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp
  29. 2
      Sources/Plasma/PubUtilLib/plNetClientRecorder/plNetClientRecorder.cpp
  30. 2
      Sources/Plasma/PubUtilLib/plResMgr/plLocalization.cpp
  31. 2
      Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp
  32. 4
      Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp
  33. 2
      Sources/Plasma/PubUtilLib/plSDL/plSDLParser.cpp
  34. 2
      Sources/Plasma/PubUtilLib/plStatGather/plAutoProfile.cpp
  35. 2
      Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp
  36. 4
      Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp
  37. 2
      Sources/Tools/MaxComponent/plAudioComponents.cpp
  38. 2
      Sources/Tools/MaxComponent/plGUIComponents.cpp
  39. 4
      Sources/Tools/MaxComponent/plMiscComponents.cpp
  40. 2
      Sources/Tools/MaxComponent/plResponderLink.cpp
  41. 2
      Sources/Tools/MaxConvert/hsMaterialConverter.cpp
  42. 2
      Sources/Tools/MaxExport/SimpleExport.cpp
  43. 2
      Sources/Tools/MaxExport/plExportDlg.cpp
  44. 2
      Sources/Tools/MaxMain/main.cpp
  45. 2
      Sources/Tools/MaxMain/plAgeDescInterface.cpp
  46. 2
      Sources/Tools/MaxMain/plPythonMgr.cpp
  47. 2
      Sources/Tools/plResBrowser/plResBrowserWndProc.cpp

4
Sources/Plasma/Apps/plClient/plClient.cpp

@ -57,7 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsTimer.h" #include "hsTimer.h"
#include "plPipeline/hsG3DDeviceSelector.h" #include "plPipeline/hsG3DDeviceSelector.h"
#include "plFile/plEncryptedStream.h" #include "plFile/plEncryptedStream.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plInputCore/plInputManager.h" #include "plInputCore/plInputManager.h"
#include "plInputCore/plInputInterfaceMgr.h" #include "plInputCore/plInputInterfaceMgr.h"
#include "plInputCore/plInputDevice.h" #include "plInputCore/plInputDevice.h"
@ -83,7 +83,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pfConsole/pfConsoleDirSrc.h" #include "pfConsole/pfConsoleDirSrc.h"
#include "plScene/plPageTreeMgr.h" #include "plScene/plPageTreeMgr.h"
#include "plScene/plVisMgr.h" #include "plScene/plVisMgr.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "pfKI/pfKI.h" #include "pfKI/pfKI.h"

2
Sources/Plasma/Apps/plClient/winmain.cpp

@ -71,7 +71,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "pnProduct/pnProduct.h" #include "pnProduct/pnProduct.h"
#include "plNetGameLib/plNetGameLib.h" #include "plNetGameLib/plNetGameLib.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plPhysX/plSimulationMgr.h" #include "plPhysX/plSimulationMgr.h"

2
Sources/Plasma/Apps/plFileEncrypt/main.cpp

@ -39,7 +39,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021 Mead, WA 99021
*==LICENSE==*/ *==LICENSE==*/
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plFile/plEncryptedStream.h" #include "plFile/plEncryptedStream.h"
#include "pnProduct/pnProduct.h" #include "pnProduct/pnProduct.h"

16
Sources/Plasma/Apps/plFileSecure/main.cpp

@ -39,8 +39,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021 Mead, WA 99021
*==LICENSE==*/ *==LICENSE==*/
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plFile/plSecureStream.h" #include "plFile/plSecureStream.h"
#include "pnProduct/pnProduct.h" #include "pnProduct/pnProduct.h"
@ -61,15 +61,15 @@ void print_help() {
printf("\tplFileSecure (<directory> <ext>)|[/generate /default]\n"); printf("\tplFileSecure (<directory> <ext>)|[/generate /default]\n");
printf("\n"); printf("\n");
printf("<directory> <ext> : The directory and extension of files to secure. Cannot\n"); printf("<directory> <ext> : The directory and extension of files to secure. Cannot\n");
printf(" be used with /generate. Uses the %s file in\n", plFileUtils::kKeyFilename); printf(" be used with /generate. Uses the %s file in\n", plSecureStream::kKeyFilename);
printf(" the current directory (or default key if no file exists)\n"); printf(" the current directory (or default key if no file exists)\n");
printf("/generate : Generates a random key and writes it to a %s\n", plFileUtils::kKeyFilename); printf("/generate : Generates a random key and writes it to a %s\n", plSecureStream::kKeyFilename);
printf(" file in the current directory. Cannot be used with\n"); printf(" file in the current directory. Cannot be used with\n");
printf(" <directory> <ext>\n"); printf(" <directory> <ext>\n");
printf("/default : If used with /generate, creates a %s file\n", plFileUtils::kKeyFilename); printf("/default : If used with /generate, creates a %s file\n", plSecureStream::kKeyFilename);
printf(" with the default key. If used with <directory> <ext>, it\n"); printf(" with the default key. If used with <directory> <ext>, it\n");
printf(" secures with the default key instead of the\n"); printf(" secures with the default key instead of the\n");
printf(" %s file's key\n", plFileUtils::kKeyFilename); printf(" %s file's key\n", plSecureStream::kKeyFilename);
printf("\n"); printf("\n");
} }
@ -103,7 +103,7 @@ void GenerateKey(bool useDefault)
} }
hsUNIXStream out; hsUNIXStream out;
out.Open(plFileUtils::kKeyFilename, "wb"); out.Open(plSecureStream::kKeyFilename, "wb");
out.Write(sizeof(uint32_t) * arrsize(key), (void*)key); out.Write(sizeof(uint32_t) * arrsize(key), (void*)key);
out.Close(); out.Close();
} }
@ -204,7 +204,7 @@ int main(int argc, char *argv[])
else else
{ {
uint32_t key[4]; uint32_t key[4];
plFileUtils::GetSecureEncryptionKey(plFileUtils::kKeyFilename, key, arrsize(key)); plSecureStream::GetSecureEncryptionKey(plSecureStream::kKeyFilename, key, arrsize(key));
SecureFiles(directory, ext, key); SecureFiles(directory, ext, key);
} }
return 0; return 0;

4
Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp

@ -41,8 +41,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "hsTimer.h" #include "hsTimer.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plResMgr/plResManager.h" #include "plResMgr/plResManager.h"
#include "plResMgr/plResMgrSettings.h" #include "plResMgr/plResMgrSettings.h"

2
Sources/Plasma/Apps/plPythonPack/main.cpp

@ -42,7 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "PythonInterface.h" #include "PythonInterface.h"
#include "hsStream.h" #include "hsStream.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include <vector> #include <vector>
#include <string> #include <string>

2
Sources/Plasma/Apps/plUruLauncher/Pch.h

@ -62,7 +62,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnNetCli/pnNetCli.h" #include "pnNetCli/pnNetCli.h"
#include "plNetGameLib/plNetGameLib.h" #include "plNetGameLib/plNetGameLib.h"
#include "pnEncryption/plChecksum.h" #include "pnEncryption/plChecksum.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plCompression/plZlibStream.h" #include "plCompression/plZlibStream.h"
#include "plClientPatcher/UruPlayer.h" #include "plClientPatcher/UruPlayer.h"

1
Sources/Plasma/CoreLib/CMakeLists.txt

@ -1,3 +1,4 @@
include_directories(../PubUtilLib/plUnifiedTime) # EVIL: For plFileUtils.cpp
add_definitions(-D_LIB) add_definitions(-D_LIB)
if(NOT WCHAR_BYTES) if(NOT WCHAR_BYTES)

62
Sources/Plasma/CoreLib/plFileUtils.cpp

@ -57,9 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsStringTokenizer.h" #include "hsStringTokenizer.h"
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime.h"
#include "plSecureStream.h" // for the default key
#include <time.h> #include <time.h>
#include <sys/types.h> #include <sys/types.h>
@ -503,61 +501,3 @@ uint32_t plFileUtils::GetFileSize( const wchar_t *path )
return len; return len;
} }
//// GetSecureEncryptionKey //////////////////////////////////////////////////
bool plFileUtils::GetSecureEncryptionKey(const char* filename, uint32_t* key, unsigned length)
{
wchar_t* wFilename = hsStringToWString(filename);
bool ret = GetSecureEncryptionKey(wFilename, key, length);
delete [] wFilename;
return ret;
}
bool plFileUtils::GetSecureEncryptionKey(const wchar_t* filename, uint32_t* key, unsigned length)
{
// looks for an encryption key file in the same directory, and reads it
std::wstring sFilename = filename;
// grab parent directory
size_t loc = sFilename.rfind(L"\\");
if (loc == std::wstring::npos)
loc = sFilename.rfind(L"/");
std::wstring sDir;
if (loc != std::wstring::npos)
sDir = sFilename.substr(0, loc);
else // no directory
sDir = L"./";
if ((sDir[sDir.length()-1] != L'/') && (sDir[sDir.length()-1] != L'\\'))
sDir += L'/'; // add the slash, if it doesn't has one
// now add the key filename
std::wstring keyFile = sDir + kWKeyFilename;
if (FileExists(keyFile.c_str()))
{
// file exists, read from it
hsUNIXStream file;
file.Open(keyFile.c_str(), L"rb");
unsigned bytesToRead = length * sizeof(uint32_t);
uint8_t* buffer = (uint8_t*)malloc(bytesToRead);
unsigned bytesRead = file.Read(bytesToRead, buffer);
file.Close();
unsigned memSize = min(bytesToRead, bytesRead);
memcpy(key, buffer, memSize);
free(buffer);
return true;
}
// file doesn't exist, use default key
unsigned memSize = min(length, arrsize(plSecureStream::kDefaultKey));
memSize *= sizeof(uint32_t);
memcpy(key, plSecureStream::kDefaultKey, memSize);
return false;
}

9
Sources/Plasma/CoreLib/plFileUtils.h

@ -56,9 +56,6 @@ class plUnifiedTime;
namespace plFileUtils namespace plFileUtils
{ {
static const char kKeyFilename[] = "encryption.key";
static const wchar_t kWKeyFilename[] = L"encryption.key";
// Creates the directory specified. Returns false if unsuccessful or directory already exists // Creates the directory specified. Returns false if unsuccessful or directory already exists
bool CreateDir( const char *path ); bool CreateDir( const char *path );
bool CreateDir( const wchar_t *path ); bool CreateDir( const wchar_t *path );
@ -113,12 +110,6 @@ namespace plFileUtils
// Concatenates fileName onto path, making sure to add a slash if necessary // Concatenates fileName onto path, making sure to add a slash if necessary
void ConcatFileName(char* path, const char* fileName); void ConcatFileName(char* path, const char* fileName);
void ConcatFileName(wchar_t* path, const wchar_t* fileName); void ConcatFileName(wchar_t* path, const wchar_t* fileName);
// searches the parent directory of filename for the encryption key file, and reads it
// into the key passed in. Returns false if the key file didn't exist (and sets key to
// the default key)
bool GetSecureEncryptionKey(const char* filename, uint32_t* key, unsigned length);
bool GetSecureEncryptionKey(const wchar_t* filename, uint32_t* key, unsigned length);
}; };

2
Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp

@ -155,7 +155,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime/plUnifiedTime.h"
//end for agedefn test //end for agedefn test
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "pnSceneObject/plAudioInterface.h" #include "pnSceneObject/plAudioInterface.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"

2
Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp

@ -84,7 +84,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime/plUnifiedTime.h"
//end for agedefn test //end for agedefn test
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"

2
Sources/Plasma/FeatureLib/pfCrashHandler/plCrashSrv.cpp

@ -42,7 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plCrashSrv.h" #include "plCrashSrv.h"
#include "plCrash_Private.h" #include "plCrash_Private.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "pnProduct/pnProduct.h" #include "pnProduct/pnProduct.h"
#ifdef HS_BUILD_FOR_WIN32 #ifdef HS_BUILD_FOR_WIN32

2
Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp

@ -50,7 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plResMgr/plLocalization.h" #include "plResMgr/plLocalization.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plFile/plEncryptedStream.h" #include "plFile/plEncryptedStream.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"

2
Sources/Plasma/FeatureLib/pfPython/plPythonPack.cpp

@ -54,7 +54,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plPythonPack.h" #include "plPythonPack.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plFile/plSecureStream.h" #include "plFile/plSecureStream.h"
#include "plFile/plStreamSource.h" #include "plFile/plStreamSource.h"

2
Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.cpp

@ -46,7 +46,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plgDispatch.h" #include "plgDispatch.h"
#include "plCompression/plZlibStream.h" #include "plCompression/plZlibStream.h"
#include "pnEncryption/plChecksum.h" #include "pnEncryption/plChecksum.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plFile/plSecureStream.h" #include "plFile/plSecureStream.h"
#include "plFile/plStreamSource.h" #include "plFile/plStreamSource.h"
#include "plMessage/plNetCommMsgs.h" #include "plMessage/plNetCommMsgs.h"

2
Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.cpp

@ -44,7 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAgeDescription.h" #include "plAgeDescription.h"
#include "hsStlUtils.h" #include "hsStlUtils.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plFile/plInitFileReader.h" #include "plFile/plInitFileReader.h"
#include "plFile/plEncryptedStream.h" #include "plFile/plEncryptedStream.h"
#include "hsStringTokenizer.h" #include "hsStringTokenizer.h"

4
Sources/Plasma/PubUtilLib/plAgeDescription/plAgeManifest.cpp

@ -51,8 +51,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAgeManifest.h" #include "plAgeManifest.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plFile/plInitFileReader.h" #include "plFile/plInitFileReader.h"
#include "hsStringTokenizer.h" #include "hsStringTokenizer.h"

2
Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp

@ -46,7 +46,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAgeLoader/plAgeLoader.h" #include "plAgeLoader/plAgeLoader.h"
#include "plCompression/plZlibStream.h" #include "plCompression/plZlibStream.h"
#include "pnEncryption/plChecksum.h" #include "pnEncryption/plChecksum.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plMessage/plResPatcherMsg.h" #include "plMessage/plResPatcherMsg.h"
#include "pnNetBase/pnNbError.h" #include "pnNetBase/pnNbError.h"
#include "plNetGameLib/plNetGameLib.h" #include "plNetGameLib/plNetGameLib.h"

2
Sources/Plasma/PubUtilLib/plAudio/plWin32StreamingSound.cpp

@ -44,7 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsGeometry3.h" #include "hsGeometry3.h"
#include "plgDispatch.h" #include "plgDispatch.h"
#include "plProfile.h" #include "plProfile.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plWin32Sound.h" #include "plWin32Sound.h"
#include "plWin32StreamingSound.h" #include "plWin32StreamingSound.h"

4
Sources/Plasma/PubUtilLib/plAudioCore/plAudioFileReader.cpp

@ -55,8 +55,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAudioCore.h" #include "plAudioCore.h"
//#include "hsTimer.h" //#include "hsTimer.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime/plUnifiedTime.h"
#include "plBufferedFileReader.h" #include "plBufferedFileReader.h"
#include "plCachedFileReader.h" #include "plCachedFileReader.h"

4
Sources/Plasma/PubUtilLib/plAudioCore/plSoundBuffer.cpp

@ -49,8 +49,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plgDispatch.h" #include "plgDispatch.h"
#include "hsResMgr.h" #include "hsResMgr.h"
#include "pnMessage/plRefMsg.h" #include "pnMessage/plRefMsg.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime/plUnifiedTime.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "hsTimer.h" #include "hsTimer.h"

61
Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp

@ -62,6 +62,9 @@ static const int kFileStartOffset = kMagicStringLen + sizeof(uint32_t);
static const int kMaxBufferedFileSize = 10*1024; static const int kMaxBufferedFileSize = 10*1024;
const char plSecureStream::kKeyFilename[] = "encryption.key";
const wchar_t plSecureStream::kWKeyFilename[] = L"encryption.key";
plSecureStream::plSecureStream(bool deleteOnExit, uint32_t* key) : plSecureStream::plSecureStream(bool deleteOnExit, uint32_t* key) :
fRef(INVALID_HANDLE_VALUE), fRef(INVALID_HANDLE_VALUE),
fActualFileSize(0), fActualFileSize(0),
@ -757,3 +760,61 @@ hsStream* plSecureStream::OpenSecureFileWrite(const wchar_t* fileName, uint32_t*
s->Open(fileName, L"wb"); s->Open(fileName, L"wb");
return s; return s;
} }
//// GetSecureEncryptionKey //////////////////////////////////////////////////
bool plSecureStream::GetSecureEncryptionKey(const char* filename, uint32_t* key, unsigned length)
{
wchar_t* wFilename = hsStringToWString(filename);
bool ret = GetSecureEncryptionKey(wFilename, key, length);
delete [] wFilename;
return ret;
}
bool plSecureStream::GetSecureEncryptionKey(const wchar_t* filename, uint32_t* key, unsigned length)
{
// looks for an encryption key file in the same directory, and reads it
std::wstring sFilename = filename;
// grab parent directory
size_t loc = sFilename.rfind(L"\\");
if (loc == std::wstring::npos)
loc = sFilename.rfind(L"/");
std::wstring sDir;
if (loc != std::wstring::npos)
sDir = sFilename.substr(0, loc);
else // no directory
sDir = L"./";
if ((sDir[sDir.length()-1] != L'/') && (sDir[sDir.length()-1] != L'\\'))
sDir += L'/'; // add the slash, if it doesn't has one
// now add the key filename
std::wstring keyFile = sDir + kWKeyFilename;
if (plFileUtils::FileExists(keyFile.c_str()))
{
// file exists, read from it
hsUNIXStream file;
file.Open(keyFile.c_str(), L"rb");
unsigned bytesToRead = length * sizeof(uint32_t);
uint8_t* buffer = (uint8_t*)malloc(bytesToRead);
unsigned bytesRead = file.Read(bytesToRead, buffer);
file.Close();
unsigned memSize = min(bytesToRead, bytesRead);
memcpy(key, buffer, memSize);
free(buffer);
return true;
}
// file doesn't exist, use default key
unsigned memSize = min(length, arrsize(plSecureStream::kDefaultKey));
memSize *= sizeof(uint32_t);
memcpy(key, plSecureStream::kDefaultKey, memSize);
return false;
}

9
Sources/Plasma/PubUtilLib/plFile/plSecureStream.h

@ -131,6 +131,15 @@ public:
static hsStream* OpenSecureFileWrite(const wchar_t* fileName, uint32_t* key = nil); static hsStream* OpenSecureFileWrite(const wchar_t* fileName, uint32_t* key = nil);
static const uint32_t kDefaultKey[4]; // our default encryption key static const uint32_t kDefaultKey[4]; // our default encryption key
// searches the parent directory of filename for the encryption key file, and reads it
// into the key passed in. Returns false if the key file didn't exist (and sets key to
// the default key)
static bool GetSecureEncryptionKey(const char* filename, uint32_t* key, unsigned length);
static bool GetSecureEncryptionKey(const wchar_t* filename, uint32_t* key, unsigned length);
static const char kKeyFilename[];
static const wchar_t kWKeyFilename[];
}; };
#endif // plSecureStream_h_inc #endif // plSecureStream_h_inc

2
Sources/Plasma/PubUtilLib/plFile/plStreamSource.cpp

@ -128,7 +128,7 @@ hsStream* plStreamSource::GetFile(std::wstring filename)
if (plSecureStream::IsSecureFile(sFilename.c_str())) if (plSecureStream::IsSecureFile(sFilename.c_str()))
{ {
uint32_t encryptionKey[4]; uint32_t encryptionKey[4];
if (!plFileUtils::GetSecureEncryptionKey(sFilename.c_str(), encryptionKey, 4)) if (!plSecureStream::GetSecureEncryptionKey(sFilename.c_str(), encryptionKey, 4))
{ {
FATAL("Hey camper... You need an NTD key file!"); FATAL("Hey camper... You need an NTD key file!");
return nil; return nil;

2
Sources/Plasma/PubUtilLib/plGImage/plFontCache.cpp

@ -57,7 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plFont.h" #include "plFont.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "pnMessage/plRefMsg.h" #include "pnMessage/plRefMsg.h"
#include "hsResMgr.h" #include "hsResMgr.h"

2
Sources/Plasma/PubUtilLib/plGImage/plWinFontCache.cpp

@ -63,7 +63,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plWinFontCache.h" #include "plWinFontCache.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plGImage/plDynSurfaceWriter.h" #include "plGImage/plDynSurfaceWriter.h"
#if HS_BUILD_FOR_WIN32 #if HS_BUILD_FOR_WIN32

2
Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp

@ -63,7 +63,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plNetMessage/plNetMessage.h" #include "plNetMessage/plNetMessage.h"
#include "plAvatar/plAvatarMgr.h" #include "plAvatar/plAvatarMgr.h"
#include "plAvatar/plArmatureMod.h" #include "plAvatar/plArmatureMod.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
/***************************************************************************** /*****************************************************************************

2
Sources/Plasma/PubUtilLib/plNetClientRecorder/plNetClientRecorder.cpp

@ -56,7 +56,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plMessage/plAgeLoadedMsg.h" #include "plMessage/plAgeLoadedMsg.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
plNetClientRecorder::plNetClientRecorder(TimeWrapper* timeWrapper) : plNetClientRecorder::plNetClientRecorder(TimeWrapper* timeWrapper) :
fTimeWrapper(timeWrapper) fTimeWrapper(timeWrapper)

2
Sources/Plasma/PubUtilLib/plResMgr/plLocalization.cpp

@ -41,7 +41,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "HeadSpin.h" #include "HeadSpin.h"
#include "plLocalization.h" #include "plLocalization.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
plLocalization::Language plLocalization::fLanguage = plLocalization::kEnglish; plLocalization::Language plLocalization::fLanguage = plLocalization::kEnglish;

2
Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp

@ -46,7 +46,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnKeyedObject/plKeyImp.h" #include "pnKeyedObject/plKeyImp.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "pnFactory/plFactory.h" #include "pnFactory/plFactory.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "hsStlUtils.h" #include "hsStlUtils.h"
#include "plVersion.h" #include "plVersion.h"

4
Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp

@ -60,8 +60,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnMessage/plObjRefMsg.h" #include "pnMessage/plObjRefMsg.h"
#include "plMessage/plAgeLoadedMsg.h" #include "plMessage/plAgeLoadedMsg.h"
#include "pnMessage/plClientMsg.h" #include "pnMessage/plClientMsg.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "pnFactory/plCreator.h" #include "pnFactory/plCreator.h"
#include "pnNetCommon/plSynchedObject.h" #include "pnNetCommon/plSynchedObject.h"
#include "pnNetCommon/plNetApp.h" #include "pnNetCommon/plNetApp.h"

2
Sources/Plasma/PubUtilLib/plSDL/plSDLParser.cpp

@ -42,7 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h" #include "hsStlUtils.h"
#include "plSDL.h" #include "plSDL.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plFile/plStreamSource.h" #include "plFile/plStreamSource.h"
#include "pnNetCommon/pnNetCommon.h" #include "pnNetCommon/pnNetCommon.h"
#include "pnNetCommon/plNetApp.h" #include "pnNetCommon/plNetApp.h"

2
Sources/Plasma/PubUtilLib/plStatGather/plAutoProfile.cpp

@ -57,7 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnMessage/plClientMsg.h" #include "pnMessage/plClientMsg.h"
#include "plAgeLoader/plAgeLoader.h" #include "plAgeLoader/plAgeLoader.h"
#include "plProfileManagerFull.h" #include "plProfileManagerFull.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plPipeline/plDebugText.h" #include "plPipeline/plDebugText.h"
#include "pnMessage/plTimeMsg.h" #include "pnMessage/plTimeMsg.h"

2
Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp

@ -50,7 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsStream.h" #include "hsStream.h"
#include "pnUtils/pnUtils.h" #include "pnUtils/pnUtils.h"
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime/plUnifiedTime.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
plProfileManagerFull::plProfileManagerFull() : plProfileManagerFull::plProfileManagerFull() :
fVars(plProfileManager::Instance().fVars), fVars(plProfileManager::Instance().fVars),

4
Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp

@ -61,10 +61,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsTemplates.h" #include "hsTemplates.h"
#include "hsTimer.h" #include "hsTimer.h"
#include "hsStlUtils.h" #include "hsStlUtils.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plStatusLog.h" #include "plStatusLog.h"
#include "hsStlUtils.h" #include "hsStlUtils.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime/plUnifiedTime.h"
#include "pnProduct/pnProduct.h" #include "pnProduct/pnProduct.h"

2
Sources/Tools/MaxComponent/plAudioComponents.cpp

@ -92,7 +92,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAudio/plWin32StreamingSound.h" #include "plAudio/plWin32StreamingSound.h"
#include "plAudio/plWin32GroupedSound.h" #include "plAudio/plWin32GroupedSound.h"
#include "plAudioCore/plSoundBuffer.h" #include "plAudioCore/plSoundBuffer.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
// Valdez Asset Manager Related // Valdez Asset Manager Related
#ifdef MAXASS_AVAILABLE #ifdef MAXASS_AVAILABLE

2
Sources/Tools/MaxComponent/plGUIComponents.cpp

@ -115,7 +115,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAgeDescription/plAgeDescription.h" #include "plAgeDescription/plAgeDescription.h"
#include "MaxMain/plMaxCFGFile.h" #include "MaxMain/plMaxCFGFile.h"
#include "MaxMain/plAgeDescInterface.h" #include "MaxMain/plAgeDescInterface.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "MaxConvert/plConvert.h" #include "MaxConvert/plConvert.h"
#include "MaxPlasmaMtls/Layers/plDynamicTextLayer.h" #include "MaxPlasmaMtls/Layers/plDynamicTextLayer.h"
#include "MaxPlasmaMtls/Layers/plLayerTexBitmapPB.h" #include "MaxPlasmaMtls/Layers/plLayerTexBitmapPB.h"

4
Sources/Tools/MaxComponent/plMiscComponents.cpp

@ -70,7 +70,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plInterp/plController.h" #include "plInterp/plController.h"
#include "MaxMain/plMaxNode.h" #include "MaxMain/plMaxNode.h"
#include "pnKeyedObject/plKey.h" #include "pnKeyedObject/plKey.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
// Follow mod // Follow mod
#include "plInterp/plAnimPath.h" #include "plInterp/plAnimPath.h"
@ -95,7 +95,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAgeDescription/plAgeDescription.h" #include "plAgeDescription/plAgeDescription.h"
#include "MaxMain/plMaxCFGFile.h" #include "MaxMain/plMaxCFGFile.h"
#include "MaxMain/plAgeDescInterface.h" #include "MaxMain/plAgeDescInterface.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plResMgr/plPageInfo.h" #include "plResMgr/plPageInfo.h"
#include "plDrawable/plGeometrySpan.h" #include "plDrawable/plGeometrySpan.h"

2
Sources/Tools/MaxComponent/plResponderLink.cpp

@ -49,7 +49,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plMiscComponents.h" #include "plMiscComponents.h"
// Needed for the dialog // Needed for the dialog
#include "MaxMain/plMaxCFGFile.h" #include "MaxMain/plMaxCFGFile.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plAgeDescription/plAgeDescription.h" #include "plAgeDescription/plAgeDescription.h"
// Needed to create the message // Needed to create the message

2
Sources/Tools/MaxConvert/hsMaterialConverter.cpp

@ -62,7 +62,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plSurface/hsGMaterial.h" #include "plSurface/hsGMaterial.h"
#include "pnSceneObject/plSceneObject.h" #include "pnSceneObject/plSceneObject.h"
#include "UserPropMgr.h" #include "UserPropMgr.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "hsConverterUtils.h" #include "hsConverterUtils.h"
#include "hsControlConverter.h" #include "hsControlConverter.h"

2
Sources/Tools/MaxExport/SimpleExport.cpp

@ -79,7 +79,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plExportDlg.h" #include "plExportDlg.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plAvatar/plAvatarMgr.h" #include "plAvatar/plAvatarMgr.h"

2
Sources/Tools/MaxExport/plExportDlg.cpp

@ -325,7 +325,7 @@ void plExportDlgImp::IExportCurrentFile(const char* exportPath)
GetCOREInterface()->ExportToFile(exportPath); GetCOREInterface()->ExportToFile(exportPath);
} }
#include "plFile/hsFiles.h" #include "hsFiles.h"
void plExportDlgImp::IDoExport() void plExportDlgImp::IDoExport()
{ {

2
Sources/Tools/MaxMain/main.cpp

@ -138,7 +138,7 @@ __declspec(dllexport) ULONG LibVersion()
#include "plSDL/plSDL.h" #include "plSDL/plSDL.h"
#include "plMaxCFGFile.h" #include "plMaxCFGFile.h"
#include <direct.h> #include <direct.h>
#include "plFile/hsFiles.h" #include "hsFiles.h"
// //
// DLLMAIN // DLLMAIN

2
Sources/Tools/MaxMain/plAgeDescInterface.cpp

@ -43,7 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAgeDescInterface.h" #include "plAgeDescInterface.h"
#include "max.h" #include "max.h"
#include "resource.h" #include "resource.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plAgeDescription/plAgeDescription.h" #include "plAgeDescription/plAgeDescription.h"
#include "plMaxCFGFile.h" #include "plMaxCFGFile.h"
#include "hsStream.h" #include "hsStream.h"

2
Sources/Tools/MaxMain/plPythonMgr.cpp

@ -45,7 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "MaxComponent/plAutoUIBlock.h" #include "MaxComponent/plAutoUIBlock.h"
//#include "Python.h" //#include "Python.h"
#include "plMaxCFGFile.h" #include "plMaxCFGFile.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plgDispatch.h" #include "plgDispatch.h"
#include "pfPython/cyPythonInterface.h" #include "pfPython/cyPythonInterface.h"

2
Sources/Tools/plResBrowser/plResBrowserWndProc.cpp

@ -50,7 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plResMgr/plResManager.h" #include "plResMgr/plResManager.h"
#include "plResMgr/plResMgrSettings.h" #include "plResMgr/plResMgrSettings.h"
#include "plWinRegistryTools.h" #include "plWinRegistryTools.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#define IDC_REGTREEVIEW 1000 #define IDC_REGTREEVIEW 1000

Loading…
Cancel
Save