rpcsx/rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp
Arkaran99 3caff5a107 Change ModuleManager::init function.
First step to help refactor Module management.
Add every module in the static ModuleInfo list. Module without id are assigned
to 0xffff.
The init function is called after constructor and take a pointer to Module
as an input.
This pointer is used to set the Module's global pointer in its file.
2014-09-13 22:00:17 +02:00

87 lines
2.2 KiB
C++

#include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/FS/VFS.h"
#include "Emu/FS/vfsFileBase.h"
#include "cellUserInfo.h"
Module *cellUserInfo = nullptr;
int cellUserInfoGetStat(u32 id, vm::ptr<CellUserInfoUserStat> stat)
{
cellUserInfo->Warning("cellUserInfoGetStat(id=%d, stat_addr=0x%x)", id, stat.addr());
if (id > CELL_USERINFO_USER_MAX)
return CELL_USERINFO_ERROR_NOUSER;
char path [256];
sprintf(path, "/dev_hdd0/home/%08d", id);
if (!Emu.GetVFS().ExistsDir(path))
return CELL_USERINFO_ERROR_NOUSER;
sprintf(path, "/dev_hdd0/home/%08d/localusername", id);
vfsStream* stream = Emu.GetVFS().OpenFile(path, vfsRead);
if (!stream || !(stream->IsOpened()))
return CELL_USERINFO_ERROR_INTERNAL;
char name [CELL_USERINFO_USERNAME_SIZE];
memset(name, 0, CELL_USERINFO_USERNAME_SIZE);
stream->Read(name, CELL_USERINFO_USERNAME_SIZE);
stream->Close();
delete stream;
stat->id = id;
memcpy(stat->name, name, CELL_USERINFO_USERNAME_SIZE);
return CELL_OK;
}
int cellUserInfoSelectUser_ListType()
{
UNIMPLEMENTED_FUNC(cellUserInfo);
return CELL_OK;
}
int cellUserInfoSelectUser_SetList()
{
UNIMPLEMENTED_FUNC(cellUserInfo);
return CELL_OK;
}
int cellUserInfoEnableOverlay()
{
UNIMPLEMENTED_FUNC(cellUserInfo);
return CELL_OK;
}
int cellUserInfoGetList(vm::ptr<be_t<u32>> listNum, vm::ptr<CellUserInfoUserList> listBuf, vm::ptr<be_t<u32>> currentUserId)
{
cellUserInfo->Warning("cellUserInfoGetList(listNum_addr=0x%x, listBuf_addr=0x%x, currentUserId_addr=0x%x)",
listNum.addr(), listBuf.addr(), currentUserId.addr());
// If only listNum is NULL, an error will be returned
if (listBuf && !listNum)
return CELL_USERINFO_ERROR_PARAM;
if (listNum)
*listNum = 1;
if (listBuf)
listBuf->userId[0] = 1;
if (currentUserId)
*currentUserId = 1;
return CELL_OK;
}
void cellUserInfo_init(Module *pxThis)
{
cellUserInfo = pxThis;
cellUserInfo->AddFunc(0x2b761140, cellUserInfoGetStat);
cellUserInfo->AddFunc(0x3097cc1c, cellUserInfoSelectUser_ListType);
cellUserInfo->AddFunc(0x55123a25, cellUserInfoSelectUser_SetList);
cellUserInfo->AddFunc(0xb3516536, cellUserInfoEnableOverlay);
cellUserInfo->AddFunc(0xc55e338b, cellUserInfoGetList);
}