本文整理汇总了C++中MemoryAllocator类的典型用法代码示例。如果您正苦于以下问题:C++ MemoryAllocator类的具体用法?C++ MemoryAllocator怎么用?C++ MemoryAllocator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MemoryAllocator类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cellJpgDecOpen
int cellJpgDecOpen(u32 mainHandle, mem32_t subHandle, u32 src_addr, mem_struct_ptr_t<CellJpgDecOpnInfo> openInfo)
{
//u32 srcSelect = Memory.Read32(src_addr);
u32 fileName = Memory.Read32(src_addr+4);
//u32 fileOffset = Memory.Read32(src_addr+8);
//u32 fileSize = Memory.Read32(src_addr+12);
//u32 streamPtr = Memory.Read32(src_addr+16);
//u32 streamSize = Memory.Read32(src_addr+20);
//u32 spuThreadEnable = Memory.Read32(src_addr+24);
CellJpgDecSubHandle *current_subHandle = new CellJpgDecSubHandle;
// Get file descriptor
MemoryAllocator<be_t<u32>> fd;
int ret = cellFsOpen(fileName, 0, fd, NULL, 0);
current_subHandle->fd = fd->ToLE();
if(ret != CELL_OK) return CELL_JPGDEC_ERROR_OPEN_FILE;
// Get size of file
MemoryAllocator<CellFsStat> sb; // Alloc a CellFsStat struct
ret = cellFsFstat(current_subHandle->fd, sb);
if(ret != CELL_OK) return ret;
current_subHandle->fileSize = sb->st_size; // Get CellFsStat.st_size
// From now, every u32 subHandle argument is a pointer to a CellPngDecSubHandle struct.
subHandle = cellJpgDec.GetNewId(current_subHandle);
return CELL_OK;
}
示例2: cellJpgDecOpen
int cellJpgDecOpen(u32 mainHandle, mem32_t subHandle, mem_ptr_t<CellJpgDecSrc> src, mem_ptr_t<CellJpgDecOpnInfo> openInfo)
{
cellJpgDec.Warning("cellJpgDecOpen(mainHandle=0x%x, subHandle=0x%x, src_addr=0x%x, openInfo=0x%x)",
mainHandle, subHandle.GetAddr(), src.GetAddr(), openInfo);
if (!subHandle.IsGood() || !src.IsGood() || !openInfo.IsGood())
return CELL_JPGDEC_ERROR_ARG;
CellJpgDecSubHandle *current_subHandle = new CellJpgDecSubHandle;
// Get file descriptor
MemoryAllocator<be_t<u32>> fd;
int ret = cellFsOpen(src->fileName, 0, fd, NULL, 0);
current_subHandle->fd = fd->ToLE();
if(ret != CELL_OK) return CELL_JPGDEC_ERROR_OPEN_FILE;
// Get size of file
MemoryAllocator<CellFsStat> sb; // Alloc a CellFsStat struct
ret = cellFsFstat(current_subHandle->fd, sb.GetAddr());
if(ret != CELL_OK) return ret;
current_subHandle->fileSize = sb->st_size; // Get CellFsStat.st_size
// From now, every u32 subHandle argument is a pointer to a CellPngDecSubHandle struct.
subHandle = cellJpgDec.GetNewId(current_subHandle);
return CELL_OK;
}
示例3: cellFontInit
int cellFontInit(mem_ptr_t<CellFontConfig> config)
{
cellFont.Log("cellFontInit(config=0x%x)", config.GetAddr());
MemoryAllocator<u64> revisionFlags = 0;
cellFontGetRevisionFlags(revisionFlags.GetAddr());
return cellFontInitializeWithRevision(revisionFlags, config.GetAddr());
}
示例4: cellGifDecOpen
int cellGifDecOpen(u32 mainHandle, mem32_t subHandle, const mem_ptr_t<CellGifDecSrc> src, mem_ptr_t<CellGifDecOpnInfo> openInfo)
{
if (!subHandle.IsGood() || !src.IsGood())
return CELL_GIFDEC_ERROR_ARG;
/*
vfsStream* stream;
switch(src->srcSelect)
{
case CELL_GIFDEC_FILE:
stream = Emu.GetVFS().Open(src->fileName.GetString(), vfsRead);
stream->Seek(src->fileOffset);
src->fileSize;
break;
case CELL_GIFDEC_BUFFER:
if(src->streamSize < 5)
return CELL_GIFDEC_ERROR_ARG;
stream = new vfsStreamMemory(src->streamPtr.GetAddr(), src->streamSize);
break;
default:
return CELL_GIFDEC_ERROR_ARG;
}
if(!stream->IsOpened())
{
return CELL_GIFDEC_ERROR_OPEN_FILE;
}
*/
CellGifDecSubHandle *current_subHandle = new CellGifDecSubHandle;
// Get file descriptor
MemoryAllocator<be_t<u32>> fd;
int ret = cellFsOpen(src->fileName, 0, fd, 0, 0);
current_subHandle->fd = fd->ToLE();
if(ret != CELL_OK) return CELL_GIFDEC_ERROR_OPEN_FILE;
// Get size of file
MemoryAllocator<CellFsStat> sb; // Alloc a CellFsStat struct
ret = cellFsFstat(current_subHandle->fd, sb.GetAddr());
if(ret != CELL_OK) return ret;
current_subHandle->fileSize = sb->st_size; // Get CellFsStat.st_size
// From now, every u32 subHandle argument is a pointer to a CellPngDecSubHandle struct.
subHandle = cellGifDec->GetNewId(current_subHandle);
return CELL_OK;
}
示例5: cellSaveDataAutoSave2
int cellSaveDataAutoSave2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr)
{
cellSysutil->Warning("cellSaveDataAutoSave2(version=%d, dirName_addr=0x%x, errDialog=%d, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=%d, userdata_addr=0x%x)",
version, dirName_addr, errDialog, setBuf.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr);
MemoryAllocator<CellSaveDataCBResult> result;
MemoryAllocator<CellSaveDataStatGet> statGet;
MemoryAllocator<CellSaveDataStatSet> statSet;
std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user
vfsDir dir(saveBaseDir);
if (!dir.IsOpened())
return CELL_SAVEDATA_ERROR_INTERNAL;
std::string dirName = Memory.ReadString(dirName_addr);
std::vector<SaveDataEntry> saveEntries;
for (const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read())
{
if (entry->flags & DirEntry_TypeDir && entry->name == dirName) {
addSaveDataEntry(saveEntries, saveBaseDir+dirName);
}
}
// The target entry does not exist
if (saveEntries.size() == 0) {
SaveDataEntry entry;
entry.dirName = dirName;
entry.sizeKB = 0;
entry.isNew = true;
saveEntries.push_back(entry);
}
getSaveDataStat(saveEntries[0], statGet.GetAddr()); // There should be only one element in this list
result->userdata_addr = userdata_addr;
funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr());
Memory.Free(statGet->fileList.GetAddr());
if (result->result < 0) {
LOG_ERROR(HLE, "cellSaveDataAutoSave2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
/*if (statSet->setParam.GetAddr())
// TODO: Write PARAM.SFO file
*/
// Enter the loop where the save files are read/created/deleted.
s32 ret = modifySaveDataFiles(funcFile, result.GetAddr(), saveBaseDir + (char*)statGet->dir.dirName);
return CELL_SAVEDATA_RET_OK;
}
示例6: cellPngDecOpen
int cellPngDecOpen(u32 mainHandle, mem32_t subHandle, mem_ptr_t<CellPngDecSrc> src, u32 openInfo)
{
cellPngDec.Warning("cellPngDecOpen(mainHandle=0x%x, subHandle=0x%x, src_addr=0x%x, openInfo=0x%x)",
mainHandle, subHandle.GetAddr(), src.GetAddr(), openInfo);
if (!subHandle.IsGood() || !src.IsGood())
return CELL_PNGDEC_ERROR_ARG;
CellPngDecSubHandle *current_subHandle = new CellPngDecSubHandle;
current_subHandle->fd = NULL;
current_subHandle->src = *src;
switch(src->srcSelect.ToBE())
{
case const_se_t<u32, CELL_PNGDEC_BUFFER>::value:
current_subHandle->fileSize = src->streamSize.ToLE();
break;
case const_se_t<u32, CELL_PNGDEC_FILE>::value:
// Get file descriptor
MemoryAllocator<be_t<u32>> fd;
int ret = cellFsOpen(src->fileName_addr, 0, fd.GetAddr(), NULL, 0);
current_subHandle->fd = fd->ToLE();
if(ret != CELL_OK) return CELL_PNGDEC_ERROR_OPEN_FILE;
// Get size of file
MemoryAllocator<CellFsStat> sb; // Alloc a CellFsStat struct
ret = cellFsFstat(current_subHandle->fd, sb.GetAddr());
if(ret != CELL_OK) return ret;
current_subHandle->fileSize = sb->st_size; // Get CellFsStat.st_size
break;
}
// From now, every u32 subHandle argument is a pointer to a CellPngDecSubHandle struct.
subHandle = cellPngDec.GetNewId(current_subHandle);
return CELL_OK;
}
示例7: cellSaveDataFixedLoad2
int cellSaveDataFixedLoad2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataFixedCallback> funcFixed, mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr)
{
cellSysutil->Warning("cellSaveDataFixedLoad2(version=%d, setList_addr=0x%x, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=%d, userdata_addr=0x%x)",
version, setList.GetAddr(), setBuf.GetAddr(), funcFixed.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr);
MemoryAllocator<CellSaveDataCBResult> result;
MemoryAllocator<CellSaveDataListGet> listGet;
MemoryAllocator<CellSaveDataFixedSet> fixedSet;
MemoryAllocator<CellSaveDataStatGet> statGet;
MemoryAllocator<CellSaveDataStatSet> statSet;
std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user
vfsDir dir(saveBaseDir);
if (!dir.IsOpened())
return CELL_SAVEDATA_ERROR_INTERNAL;
std::string dirNamePrefix = Memory.ReadString(setList->dirNamePrefix_addr);
std::vector<SaveDataEntry> saveEntries;
for (const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read())
{
if (entry->flags & DirEntry_TypeDir && entry->name.substr(0, dirNamePrefix.size()) == dirNamePrefix)
{
// Count the amount of matches and the amount of listed directories
listGet->dirListNum++;
if (listGet->dirListNum > setBuf->dirListMax)
continue;
listGet->dirNum++;
std::string saveDir = saveBaseDir + entry->name;
addSaveDataEntry(saveEntries, saveDir);
}
}
// Sort the entries and fill the listGet->dirList array
std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder));
listGet->dirList.SetAddr(setBuf->buf_addr);
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.GetAddr());
for (u32 i = 0; i<saveEntries.size(); i++) {
memcpy(dirList[i].dirName, saveEntries[i].dirName.c_str(), CELL_SAVEDATA_DIRNAME_SIZE);
memcpy(dirList[i].listParam, saveEntries[i].listParam.c_str(), CELL_SAVEDATA_SYSP_LPARAM_SIZE);
}
funcFixed(result.GetAddr(), listGet.GetAddr(), fixedSet.GetAddr());
if (result->result < 0) {
LOG_ERROR(HLE, "cellSaveDataFixedLoad2: CellSaveDataFixedCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
setSaveDataFixed(saveEntries, fixedSet.GetAddr());
getSaveDataStat(saveEntries[0], statGet.GetAddr()); // There should be only one element in this list
// TODO: Display the Yes|No dialog here
result->userdata_addr = userdata_addr;
funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr());
Memory.Free(statGet->fileList.GetAddr());
if (result->result < 0) {
LOG_ERROR(HLE, "cellSaveDataFixedLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
/*if (statSet->setParam.GetAddr())
// TODO: Write PARAM.SFO file
*/
// Enter the loop where the save files are read/created/deleted.
s32 ret = modifySaveDataFiles(funcFile, result.GetAddr(), saveBaseDir + (char*)statGet->dir.dirName);
return ret;
}
示例8: modifySaveDataFiles
s32 modifySaveDataFiles(mem_func_ptr_t<CellSaveDataFileCallback>& funcFile, mem_ptr_t<CellSaveDataCBResult> result, const std::string& saveDataDir)
{
MemoryAllocator<CellSaveDataFileGet> fileGet;
MemoryAllocator<CellSaveDataFileSet> fileSet;
if (!Emu.GetVFS().ExistsDir(saveDataDir))
Emu.GetVFS().CreateDir(saveDataDir);
fileGet->excSize = 0;
while (true)
{
funcFile(result.GetAddr(), fileGet.GetAddr(), fileSet.GetAddr());
if (result->result < 0) {
LOG_ERROR(HLE, "modifySaveDataFiles: CellSaveDataFileCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
if (result->result == CELL_SAVEDATA_CBRESULT_OK_LAST) {
break;
}
std::string filepath = saveDataDir + '/';
vfsStream* file = NULL;
void* buf = Memory.VirtualToRealAddr(fileSet->fileBuf_addr);
switch ((u32)fileSet->fileType)
{
case CELL_SAVEDATA_FILETYPE_SECUREFILE: filepath += (char*)Memory.VirtualToRealAddr(fileSet->fileName_addr); break;
case CELL_SAVEDATA_FILETYPE_NORMALFILE: filepath += (char*)Memory.VirtualToRealAddr(fileSet->fileName_addr); break;
case CELL_SAVEDATA_FILETYPE_CONTENT_ICON0: filepath += "ICON0.PNG"; break;
case CELL_SAVEDATA_FILETYPE_CONTENT_ICON1: filepath += "ICON1.PAM"; break;
case CELL_SAVEDATA_FILETYPE_CONTENT_PIC1: filepath += "PIC1.PNG"; break;
case CELL_SAVEDATA_FILETYPE_CONTENT_SND0: filepath += "SND0.AT3"; break;
default:
LOG_ERROR(HLE, "modifySaveDataFiles: Unknown fileType! Aborting...");
return CELL_SAVEDATA_ERROR_PARAM;
}
switch ((u32)fileSet->fileOperation)
{
case CELL_SAVEDATA_FILEOP_READ:
file = Emu.GetVFS().OpenFile(filepath, vfsRead);
fileGet->excSize = file->Read(buf, std::min(fileSet->fileSize, fileSet->fileBufSize)); // TODO: This may fail for big files because of the dest pointer.
break;
case CELL_SAVEDATA_FILEOP_WRITE:
Emu.GetVFS().CreateFile(filepath);
file = Emu.GetVFS().OpenFile(filepath, vfsWrite);
fileGet->excSize = file->Write(buf, std::min(fileSet->fileSize, fileSet->fileBufSize)); // TODO: This may fail for big files because of the dest pointer.
break;
case CELL_SAVEDATA_FILEOP_DELETE:
Emu.GetVFS().RemoveFile(filepath);
fileGet->excSize = 0;
break;
case CELL_SAVEDATA_FILEOP_WRITE_NOTRUNC:
LOG_WARNING(HLE, "modifySaveDataFiles: File operation CELL_SAVEDATA_FILEOP_WRITE_NOTRUNC not yet implemented");
break;
default:
LOG_ERROR(HLE, "modifySaveDataFiles: Unknown fileOperation! Aborting...");
return CELL_SAVEDATA_ERROR_PARAM;
}
if (file && file->IsOpened())
file->Close();
}
return CELL_SAVEDATA_RET_OK;
}
示例9: cellHddGameCheck
int cellHddGameCheck(u32 version, u32 dirName_addr, u32 errDialog, mem_func_ptr_t<CellHddGameStatCallback> funcStat, u32 container)
{
cellSysutil->Warning("cellHddGameCheck(version=%d, dirName_addr=0x%xx, errDialog=%d, funcStat_addr=0x%x, container=%d)",
version, dirName_addr, errDialog, funcStat, container);
std::string dirName = Memory.ReadString(dirName_addr);
if (dirName.size() != 9)
return CELL_HDDGAME_ERROR_PARAM;
MemoryAllocator<CellHddGameSystemFileParam> param;
MemoryAllocator<CellHddGameCBResult> result;
MemoryAllocator<CellHddGameStatGet> get;
MemoryAllocator<CellHddGameStatSet> set;
get->hddFreeSizeKB = 40 * 1024 * 1024; // 40 GB, TODO: Use the free space of the computer's HDD where RPCS3 is being run.
get->isNewData = CELL_HDDGAME_ISNEWDATA_EXIST;
get->sysSizeKB = 0; // TODO
get->st_atime__ = 0; // TODO
get->st_ctime__ = 0; // TODO
get->st_mtime__ = 0; // TODO
get->sizeKB = CELL_HDDGAME_SIZEKB_NOTCALC;
memcpy(get->contentInfoPath, ("/dev_hdd0/game/"+dirName).c_str(), CELL_HDDGAME_PATH_MAX);
memcpy(get->hddGamePath, ("/dev_hdd0/game/"+dirName+"/USRDIR").c_str(), CELL_HDDGAME_PATH_MAX);
if (!Emu.GetVFS().ExistsDir(("/dev_hdd0/game/"+dirName).c_str()))
{
get->isNewData = CELL_HDDGAME_ISNEWDATA_NODIR;
}
else
{
// TODO: Is cellHddGameCheck really responsible for writing the information in get->getParam ? (If not, delete this else)
vfsFile f(("/dev_hdd0/game/"+dirName+"/PARAM.SFO").c_str());
PSFLoader psf(f);
if (!psf.Load(false)) {
return CELL_HDDGAME_ERROR_BROKEN;
}
get->getParam.parentalLevel = psf.GetInteger("PARENTAL_LEVEL");
get->getParam.attribute = psf.GetInteger("ATTRIBUTE");
get->getParam.resolution = psf.GetInteger("RESOLUTION");
get->getParam.soundFormat = psf.GetInteger("SOUND_FORMAT");
std::string title = psf.GetString("TITLE");
memcpy(get->getParam.title, title.c_str(), std::min<size_t>(CELL_HDDGAME_SYSP_TITLE_SIZE,title.length()+1));
std::string app_ver = psf.GetString("APP_VER");
memcpy(get->getParam.dataVersion, app_ver.c_str(), std::min<size_t>(CELL_HDDGAME_SYSP_VERSION_SIZE,app_ver.length()+1));
memcpy(get->getParam.titleId, dirName.c_str(), std::min<size_t>(CELL_HDDGAME_SYSP_TITLEID_SIZE,dirName.length()+1));
for (u32 i=0; i<CELL_HDDGAME_SYSP_LANGUAGE_NUM; i++) {
char key [16];
sprintf(key, "TITLE_%02d", i);
title = psf.GetString(key);
memcpy(get->getParam.titleLang[i], title.c_str(), std::min<size_t>(CELL_HDDGAME_SYSP_TITLE_SIZE, title.length() + 1));
}
}
// TODO ?
funcStat(result.GetAddr(), get.GetAddr(), set.GetAddr());
if (result->result != CELL_HDDGAME_CBRESULT_OK &&
result->result != CELL_HDDGAME_CBRESULT_OK_CANCEL)
return CELL_HDDGAME_ERROR_CBRESULT;
// TODO ?
return CELL_OK;
}
示例10: cellHddGameCheck
int cellHddGameCheck(u32 version, u32 dirName_addr, u32 errDialog, mem_func_ptr_t<CellHddGameStatCallback> funcStat, u32 container)
{
cellSysutil.Warning("cellHddGameCheck(version=%d, dirName_addr=0x%xx, errDialog=%d, funcStat_addr=0x%x, container=%d)",
version, dirName_addr, errDialog, funcStat, container);
if (!Memory.IsGoodAddr(dirName_addr) || !funcStat.IsGood())
return CELL_HDDGAME_ERROR_PARAM;
std::string dirName = Memory.ReadString(dirName_addr).ToStdString();
if (dirName.size() != 9)
return CELL_HDDGAME_ERROR_PARAM;
MemoryAllocator<CellHddGameSystemFileParam> param;
MemoryAllocator<CellHddGameCBResult> result;
MemoryAllocator<CellHddGameStatGet> get;
MemoryAllocator<CellHddGameStatSet> set;
get->hddFreeSizeKB = 40000000; // 40 GB, TODO: Use the free space of the computer's HDD where RPCS3 is being run.
get->isNewData = CELL_HDDGAME_ISNEWDATA_EXIST;
get->sysSizeKB = 0; // TODO
get->st_atime__ = 0; // TODO
get->st_ctime__ = 0; // TODO
get->st_mtime__ = 0; // TODO
get->sizeKB = CELL_HDDGAME_SIZEKB_NOTCALC;
memcpy(get->contentInfoPath, ("/dev_hdd0/game/"+dirName).c_str(), CELL_HDDGAME_PATH_MAX);
memcpy(get->hddGamePath, ("/dev_hdd0/game/"+dirName+"/USRDIR").c_str(), CELL_HDDGAME_PATH_MAX);
if (!Emu.GetVFS().ExistsDir(("/dev_hdd0/game/"+dirName).c_str()))
{
get->isNewData = CELL_HDDGAME_ISNEWDATA_NODIR;
}
else
{
// TODO: Is cellHddGameCheck really responsible for writing the information in get->getParam ? (If not, delete this else)
vfsFile f(("/dev_hdd0/game/"+dirName+"/PARAM.SFO").c_str());
PSFLoader psf(f);
if (!psf.Load(false)) {
return CELL_HDDGAME_ERROR_BROKEN;
}
get->getParam.parentalLevel = psf.m_info.parental_lvl;
get->getParam.attribute = psf.m_info.attr;
get->getParam.resolution = psf.m_info.resolution;
get->getParam.soundFormat = psf.m_info.sound_format;
memcpy(get->getParam.title, psf.m_info.name.mb_str(), CELL_HDDGAME_SYSP_TITLE_SIZE);
memcpy(get->getParam.dataVersion, psf.m_info.app_ver.mb_str(), CELL_HDDGAME_SYSP_VERSION_SIZE);
memcpy(get->getParam.titleId, dirName.c_str(), CELL_HDDGAME_SYSP_TITLEID_SIZE);
for (u32 i=0; i<CELL_HDDGAME_SYSP_LANGUAGE_NUM; i++) {
memcpy(get->getParam.titleLang[i], psf.m_info.name.mb_str(), CELL_HDDGAME_SYSP_TITLE_SIZE); // TODO: Get real titleLang name
}
}
// TODO ?
funcStat(result.GetAddr(), get.GetAddr(), set.GetAddr());
if (result->result != CELL_HDDGAME_CBRESULT_OK &&
result->result != CELL_HDDGAME_CBRESULT_OK_CANCEL)
return CELL_HDDGAME_ERROR_CBRESULT;
// TODO ?
return CELL_OK;
}
示例11: cellSaveDataListLoad2
int cellSaveDataListLoad2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataListCallback> funcList, mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr)
{
cellSysutil.Warning("cellSaveDataListLoad2(version=%d, setList_addr=0x%x, setBuf_addr=0x%x, funcList_addr=0x%x, funcStat_addr=0x%x, funcFile_addr=0x%x, container=%d, userdata_addr=0x%x)",
version, setList.GetAddr(), setBuf.GetAddr(), funcList.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr);
if (!setList.IsGood() || !setBuf.IsGood() || !funcList.IsGood() || !funcStat.IsGood() || !funcFile.IsGood())
return CELL_SAVEDATA_ERROR_PARAM;
MemoryAllocator<CellSaveDataCBResult> result;
MemoryAllocator<CellSaveDataListGet> listGet;
MemoryAllocator<CellSaveDataListSet> listSet;
MemoryAllocator<CellSaveDataStatGet> statGet;
MemoryAllocator<CellSaveDataStatSet> statSet;
std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user
vfsDir dir(saveBaseDir);
if(!dir.IsOpened())
return CELL_SAVEDATA_ERROR_INTERNAL;
std::string dirNamePrefix = Memory.ReadString(setList->dirNamePrefix_addr);
std::vector<SaveDataEntry> saveEntries;
for(const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read())
{
if (entry->flags & DirEntry_TypeDir && entry->name.substr(0,dirNamePrefix.size()) == dirNamePrefix)
{
// Count the amount of matches and the amount of listed directories
listGet->dirListNum++;
if (listGet->dirListNum > setBuf->dirListMax)
continue;
listGet->dirNum++;
std::string saveDir = saveBaseDir + entry->name;
addSaveDataEntry(saveEntries, saveDir);
}
}
// Sort the entries and fill the listGet->dirList array
std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder));
listGet->dirList.SetAddr(setBuf->buf_addr);
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.GetAddr());
for (u32 i=0; i<saveEntries.size(); i++) {
memcpy(dirList[i].dirName, saveEntries[i].dirName.c_str(), CELL_SAVEDATA_DIRNAME_SIZE);
memcpy(dirList[i].listParam, saveEntries[i].listParam.c_str(), CELL_SAVEDATA_SYSP_LPARAM_SIZE);
}
funcList(result.GetAddr(), listGet.GetAddr(), listSet.GetAddr());
if (result->result < 0) {
ConLog.Error("cellSaveDataListLoad2: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
if (!listSet->fixedList.IsGood())
return CELL_SAVEDATA_ERROR_PARAM;
setSaveDataList(saveEntries, (u32)listSet->fixedList.GetAddr(), listSet->fixedListNum);
if (listSet->newData.IsGood())
addNewSaveDataEntry(saveEntries, (u32)listSet->newData.GetAddr());
if (saveEntries.size() == 0) {
ConLog.Warning("cellSaveDataListLoad2: No save entries found!"); // TODO: Find a better way to handle this error
return CELL_SAVEDATA_RET_OK;
}
u32 focusIndex = focusSaveDataEntry(saveEntries, listSet->focusPosition);
// TODO: Display the dialog here
u32 selectedIndex = focusIndex; // TODO: Until the dialog is implemented, select always the focused entry
getSaveDataStat(saveEntries[selectedIndex], statGet.GetAddr());
result->userdata_addr = userdata_addr;
funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr());
Memory.Free(statGet->fileList.GetAddr());
if (result->result < 0) {
ConLog.Error("cellSaveDataListLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
/*if (statSet->setParam.IsGood())
// TODO: Write PARAM.SFO file
*/
// Enter the loop where the save files are read/created/deleted.
s32 ret = modifySaveDataFiles(funcFile, result.GetAddr(), saveBaseDir + (char*)statGet->dir.dirName);
// TODO: There are other returns in this function that doesn't free the memory. Fix it (without using goto's, please).
for (auto& entry : saveEntries) {
delete[] entry.iconBuf;
entry.iconBuf = nullptr;
}
return ret;
}
示例12: cellSaveDataFixedLoad2
int cellSaveDataFixedLoad2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataFixedCallback> funcFixed, mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr)
{
cellSysutil.Warning("cellSaveDataFixedLoad2(version=%d, setList_addr=0x%x, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=%d, userdata_addr=0x%x)",
version, setList.GetAddr(), setBuf.GetAddr(), funcFixed.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr);
if (!setList.IsGood() || !setBuf.IsGood() || !funcFixed.IsGood() || !funcStat.IsGood() || !funcFile.IsGood())
return CELL_SAVEDATA_ERROR_PARAM;
MemoryAllocator<CellSaveDataCBResult> result;
MemoryAllocator<CellSaveDataListGet> listGet;
MemoryAllocator<CellSaveDataFixedSet> fixedSet;
MemoryAllocator<CellSaveDataStatGet> statGet;
MemoryAllocator<CellSaveDataStatSet> statSet;
MemoryAllocator<CellSaveDataFileGet> fileGet;
MemoryAllocator<CellSaveDataFileSet> fileSet;
std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user
vfsDir dir(saveBaseDir);
if (!dir.IsOpened())
return CELL_SAVEDATA_ERROR_INTERNAL;
std::string dirNamePrefix = Memory.ReadString(setList->dirNamePrefix_addr);
std::vector<SaveDataEntry> saveEntries;
for (const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read())
{
if (entry->flags & DirEntry_TypeDir && entry->name.substr(0, dirNamePrefix.size()) == dirNamePrefix)
{
// Count the amount of matches and the amount of listed directories
listGet->dirListNum++;
if (listGet->dirListNum > setBuf->dirListMax)
continue;
listGet->dirNum++;
std::string saveDir = saveBaseDir + entry->name;
addSaveDataEntry(saveEntries, saveDir);
}
}
// Sort the entries and fill the listGet->dirList array
std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder));
listGet->dirList.SetAddr(setBuf->buf_addr);
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.GetAddr());
for (u32 i = 0; i<saveEntries.size(); i++) {
memcpy(dirList[i].dirName, saveEntries[i].dirName.c_str(), CELL_SAVEDATA_DIRNAME_SIZE);
memcpy(dirList[i].listParam, saveEntries[i].listParam.c_str(), CELL_SAVEDATA_SYSP_LPARAM_SIZE);
}
funcFixed(result.GetAddr(), listGet.GetAddr(), fixedSet.GetAddr());
if (result->result < 0) {
ConLog.Error("cellSaveDataFixedLoad2: CellSaveDataFixedCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
setSaveDataFixed(saveEntries, fixedSet.GetAddr());
getSaveDataStat(saveEntries[0], statGet.GetAddr()); // There should be only one element in this list
// TODO: Display the Yes|No dialog here
result->userdata_addr = userdata_addr;
funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr());
Memory.Free(statGet->fileList.GetAddr());
if (result->result < 0) {
ConLog.Error("cellSaveDataFixedLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
/*if (statSet->setParam.IsGood())
// TODO: Write PARAM.SFO file
*/
fileGet->excSize = 0;
while (true)
{
funcFile(result.GetAddr(), fileGet.GetAddr(), fileSet.GetAddr());
if (result->result < 0) {
ConLog.Error("cellSaveDataFixedLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
if (result->result == CELL_SAVEDATA_CBRESULT_OK_LAST)
break;
switch (fileSet->fileOperation)
{
case CELL_SAVEDATA_FILEOP_READ:
fileGet->excSize = readSaveDataFile(fileSet.GetAddr(), saveBaseDir + (char*)statGet->dir.dirName);
break;
case CELL_SAVEDATA_FILEOP_WRITE:
fileGet->excSize = writeSaveDataFile(fileSet.GetAddr(), saveBaseDir + (char*)statGet->dir.dirName);
break;
case CELL_SAVEDATA_FILEOP_DELETE:
case CELL_SAVEDATA_FILEOP_WRITE_NOTRUNC:
ConLog.Warning("cellSaveDataFixedLoad2: TODO: fileSet->fileOperation not yet implemented");
break;
}
}
// TODO: There are other returns in this function that doesn't free the memory. Fix it (without using goto's, please).
for (auto& entry : saveEntries) {
delete[] entry.iconBuf;
entry.iconBuf = nullptr;
}
return CELL_SAVEDATA_RET_OK;
//.........这里部分代码省略.........
示例13: Free
int32_t Free (void *p)
{
return Heap.Delete(p);
}
示例14:
void *Alloc (uint32_t size)
{
return Heap.New(size);
}