Remove Win32 byte pointers from DLC pack blobs

This commit is contained in:
notmatthewbeshay 2026-03-10 00:19:34 +11:00
parent 66538b67f2
commit 61808e925a
3 changed files with 13 additions and 11 deletions

View file

@ -363,7 +363,7 @@ bool DLCManager::readDLCDataFile(DWORD &dwFilesProcessed, const std::string &pat
} }
DWORD bytesRead,dwFileSize = GetFileSize(file,NULL); DWORD bytesRead,dwFileSize = GetFileSize(file,NULL);
PBYTE pbData = (PBYTE) new BYTE[dwFileSize]; uint8_t *pbData = new uint8_t[dwFileSize];
BOOL bSuccess = ReadFile(file,pbData,dwFileSize,&bytesRead,NULL); BOOL bSuccess = ReadFile(file,pbData,dwFileSize,&bytesRead,NULL);
if(bSuccess==FALSE) if(bSuccess==FALSE)
{ {
@ -385,7 +385,7 @@ bool DLCManager::readDLCDataFile(DWORD &dwFilesProcessed, const std::string &pat
return processDLCDataFile(dwFilesProcessed, pbData, bytesRead, pack); return processDLCDataFile(dwFilesProcessed, pbData, bytesRead, pack);
} }
bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD dwLength, DLCPack *pack) bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, uint8_t *pbData, DWORD dwLength, DLCPack *pack)
{ {
std::unordered_map<int, DLCManager::EDLCParameterType> parameterMapping; std::unordered_map<int, DLCManager::EDLCParameterType> parameterMapping;
unsigned int uiCurrentByte=0; unsigned int uiCurrentByte=0;
@ -439,7 +439,7 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD
dwTemp+=DLC_DETAIL_ADV(pFile->dwWchCount); dwTemp+=DLC_DETAIL_ADV(pFile->dwWchCount);
pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[dwTemp]; pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[dwTemp];
} }
PBYTE pbTemp=((PBYTE )pFile);//+ sizeof(C4JStorage::DLC_FILE_DETAILS)*ulFileCount; uint8_t *pbTemp = reinterpret_cast<uint8_t *>(pFile);//+ sizeof(C4JStorage::DLC_FILE_DETAILS)*ulFileCount;
pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte]; pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte];
for(unsigned int i=0;i<uiFileCount;i++) for(unsigned int i=0;i<uiFileCount;i++)
@ -566,7 +566,7 @@ DWORD DLCManager::retrievePackIDFromDLCDataFile(const std::string &path, DLCPack
} }
DWORD bytesRead,dwFileSize = GetFileSize(file,NULL); DWORD bytesRead,dwFileSize = GetFileSize(file,NULL);
PBYTE pbData = (PBYTE) new BYTE[dwFileSize]; uint8_t *pbData = new uint8_t[dwFileSize];
BOOL bSuccess = ReadFile(file,pbData,dwFileSize,&bytesRead,NULL); BOOL bSuccess = ReadFile(file,pbData,dwFileSize,&bytesRead,NULL);
if(bSuccess==FALSE) if(bSuccess==FALSE)
{ {
@ -590,7 +590,7 @@ DWORD DLCManager::retrievePackIDFromDLCDataFile(const std::string &path, DLCPack
return packId; return packId;
} }
DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) DWORD DLCManager::retrievePackID(uint8_t *pbData, DWORD dwLength, DLCPack *pack)
{ {
DWORD packId=0; DWORD packId=0;
bool bPackIDSet=false; bool bPackIDSet=false;
@ -643,7 +643,7 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack)
dwTemp+=DLC_DETAIL_ADV(pFile->dwWchCount); dwTemp+=DLC_DETAIL_ADV(pFile->dwWchCount);
pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[dwTemp]; pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[dwTemp];
} }
PBYTE pbTemp=((PBYTE )pFile); uint8_t *pbTemp = reinterpret_cast<uint8_t *>(pFile);
pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte]; pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte];
for(unsigned int i=0;i<uiFileCount;i++) for(unsigned int i=0;i<uiFileCount;i++)
@ -688,4 +688,4 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack)
parameterMapping.clear(); parameterMapping.clear();
return packId; return packId;
} }

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
//using namespace std; //using namespace std;
#include <cstdint>
#include <vector> #include <vector>
class DLCPack; class DLCPack;
class DLCSkinFile; class DLCSkinFile;
@ -93,7 +94,7 @@ public:
DWORD retrievePackIDFromDLCDataFile(const std::string &path, DLCPack *pack); DWORD retrievePackIDFromDLCDataFile(const std::string &path, DLCPack *pack);
private: private:
bool processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD dwLength, DLCPack *pack); bool processDLCDataFile(DWORD &dwFilesProcessed, uint8_t *pbData, DWORD dwLength, DLCPack *pack);
DWORD retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack); DWORD retrievePackID(uint8_t *pbData, DWORD dwLength, DLCPack *pack);
}; };

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
//using namespace std; //using namespace std;
#include <cstdint>
#include "DLCManager.h" #include "DLCManager.h"
class DLCFile; class DLCFile;
@ -28,7 +29,7 @@ private:
DWORD m_packId; DWORD m_packId;
DWORD m_packVersion; DWORD m_packVersion;
PBYTE m_data; // This pointer is for all the data used for this pack, so deleting it invalidates ALL of it's children. uint8_t *m_data; // This pointer is for all the data used for this pack, so deleting it invalidates ALL of it's children.
public: public:
DLCPack(const std::wstring &name,DWORD dwLicenseMask); DLCPack(const std::wstring &name,DWORD dwLicenseMask);
@ -39,7 +40,7 @@ public:
std::wstring getFullDataPath() { return m_dataPath; } std::wstring getFullDataPath() { return m_dataPath; }
void SetDataPointer(PBYTE pbData) { m_data = pbData; } void SetDataPointer(uint8_t *pbData) { m_data = pbData; }
bool IsCorrupt() { return m_isCorrupt; } bool IsCorrupt() { return m_isCorrupt; }
void SetIsCorrupt(bool val) { m_isCorrupt = val; } void SetIsCorrupt(bool val) { m_isCorrupt = val; }