2017-03-25 15:25:24 +01:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
#include "Emu/Cell/PPUModule.h"
|
2020-03-26 21:10:24 +01:00
|
|
|
#include "cellSysutil.h"
|
2024-01-05 03:56:31 +01:00
|
|
|
#include "sceNp.h"
|
|
|
|
|
#include "Emu/IdManager.h"
|
2017-03-25 15:25:24 +01:00
|
|
|
|
2018-08-25 14:39:00 +02:00
|
|
|
LOG_CHANNEL(cellSysutilNpEula);
|
2017-03-25 15:25:24 +01:00
|
|
|
|
2024-01-05 03:56:31 +01:00
|
|
|
enum SceNpEulaStatus
|
2017-03-25 15:25:24 +01:00
|
|
|
{
|
2025-04-05 21:50:45 +02:00
|
|
|
SCE_NP_EULA_UNKNOWN = 0,
|
|
|
|
|
SCE_NP_EULA_ACCEPTED = 1,
|
2024-01-05 03:56:31 +01:00
|
|
|
SCE_NP_EULA_ALREADY_ACCEPTED = 2,
|
2025-04-05 21:50:45 +02:00
|
|
|
SCE_NP_EULA_REJECTED = 3,
|
|
|
|
|
SCE_NP_EULA_ABORTED = 4,
|
|
|
|
|
SCE_NP_EULA_ERROR = 5,
|
2020-03-26 21:10:24 +01:00
|
|
|
};
|
|
|
|
|
|
2024-01-05 03:56:31 +01:00
|
|
|
using SceNpEulaVersion = u32;
|
|
|
|
|
using SceNpEulaCheckEulaStatusCallback = void(SceNpEulaStatus status, u32 errorCode, SceNpEulaVersion version, vm::ptr<void> arg);
|
|
|
|
|
|
|
|
|
|
struct sceNpEulaCallbacksRegistered
|
2020-03-26 21:10:24 +01:00
|
|
|
{
|
2024-01-05 03:56:31 +01:00
|
|
|
atomic_t<SceNpEulaStatus> status = SCE_NP_EULA_UNKNOWN;
|
|
|
|
|
atomic_t<bool> sceNpEulaCheckEulaStatus_callback_registered = false;
|
|
|
|
|
atomic_t<bool> sceNpEulaShowCurrentEula_callback_registered = false;
|
2020-03-26 21:10:24 +01:00
|
|
|
};
|
|
|
|
|
|
2024-01-05 03:56:31 +01:00
|
|
|
error_code sceNpEulaCheckEulaStatus(vm::cptr<SceNpCommunicationId> communicationId, u32 arg2, u64 arg3, vm::ptr<SceNpEulaCheckEulaStatusCallback> cbFunc, vm::ptr<void> cbFuncArg)
|
2020-03-26 21:10:24 +01:00
|
|
|
{
|
2024-01-05 03:56:31 +01:00
|
|
|
cellSysutilNpEula.warning("sceNpEulaCheckEulaStatus(communicationId=*0x%x, arg2=0x%x, arg3=0x%x, cbFunc=*0x%x, cbFuncArg=*0x%x)", communicationId, arg2, arg3, cbFunc, cbFuncArg);
|
|
|
|
|
|
|
|
|
|
if (!communicationId || !cbFunc)
|
2020-03-26 21:10:24 +01:00
|
|
|
{
|
2024-01-05 03:56:31 +01:00
|
|
|
return SCE_NP_EULA_ERROR_INVALID_ARGUMENT;
|
|
|
|
|
}
|
2020-03-26 21:10:24 +01:00
|
|
|
|
2024-01-05 03:56:31 +01:00
|
|
|
auto& cb_infos = g_fxo->get<sceNpEulaCallbacksRegistered>();
|
2020-03-26 21:10:24 +01:00
|
|
|
|
2024-01-05 03:56:31 +01:00
|
|
|
if (cb_infos.sceNpEulaCheckEulaStatus_callback_registered || cb_infos.sceNpEulaShowCurrentEula_callback_registered)
|
|
|
|
|
{
|
|
|
|
|
return SCE_NP_EULA_ERROR_ALREADY_INITIALIZED;
|
|
|
|
|
}
|
2020-03-26 21:10:24 +01:00
|
|
|
|
2024-01-05 03:56:31 +01:00
|
|
|
cb_infos.sceNpEulaCheckEulaStatus_callback_registered = true;
|
|
|
|
|
cb_infos.status = SCE_NP_EULA_ALREADY_ACCEPTED;
|
|
|
|
|
|
|
|
|
|
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
|
2025-04-05 21:50:45 +02:00
|
|
|
{
|
|
|
|
|
auto& cb_infos = g_fxo->get<sceNpEulaCallbacksRegistered>();
|
|
|
|
|
cbFunc(cb_ppu, cb_infos.status, CELL_OK, 1, cbFuncArg);
|
|
|
|
|
cb_infos.sceNpEulaCheckEulaStatus_callback_registered = false;
|
|
|
|
|
return 0;
|
|
|
|
|
});
|
2020-03-26 21:10:24 +01:00
|
|
|
|
2017-03-25 15:25:24 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-26 21:10:24 +01:00
|
|
|
error_code sceNpEulaAbort()
|
2017-03-25 15:25:24 +01:00
|
|
|
{
|
2024-01-05 03:56:31 +01:00
|
|
|
cellSysutilNpEula.warning("sceNpEulaAbort()");
|
|
|
|
|
|
|
|
|
|
auto& cb_infos = g_fxo->get<sceNpEulaCallbacksRegistered>();
|
|
|
|
|
|
|
|
|
|
if (!cb_infos.sceNpEulaCheckEulaStatus_callback_registered && !cb_infos.sceNpEulaShowCurrentEula_callback_registered)
|
|
|
|
|
{
|
|
|
|
|
return SCE_NP_EULA_ERROR_NOT_INITIALIZED;
|
|
|
|
|
}
|
2020-03-26 21:10:24 +01:00
|
|
|
|
2024-01-05 03:56:31 +01:00
|
|
|
// It would forcefully abort the dialog/process of getting the eula but since we don't show the dialog, just alter the status returned
|
|
|
|
|
cb_infos.status = SCE_NP_EULA_ABORTED;
|
2020-03-26 21:10:24 +01:00
|
|
|
|
2017-03-25 15:25:24 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-26 21:10:24 +01:00
|
|
|
// Seen on: Resistance 3, Uncharted 2
|
2024-01-05 03:56:31 +01:00
|
|
|
error_code sceNpEulaShowCurrentEula(vm::cptr<SceNpCommunicationId> communicationId, u64 arg2, vm::ptr<CellSysutilCallback> cbFunc, vm::ptr<void> cbFuncArg)
|
2017-03-25 15:25:24 +01:00
|
|
|
{
|
2024-01-05 03:56:31 +01:00
|
|
|
cellSysutilNpEula.todo("sceNpEulaShowCurrentEula(communicationId=*0x%x, arg2=0x%x, cbFunc=*0x%x, cbFuncArg=*0x%x)", communicationId, arg2, cbFunc, cbFuncArg);
|
2020-03-26 21:10:24 +01:00
|
|
|
|
2024-01-05 03:56:31 +01:00
|
|
|
if (!communicationId || !cbFunc)
|
|
|
|
|
{
|
|
|
|
|
return SCE_NP_EULA_ERROR_INVALID_ARGUMENT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto& cb_infos = g_fxo->get<sceNpEulaCallbacksRegistered>();
|
|
|
|
|
|
|
|
|
|
if (cb_infos.sceNpEulaCheckEulaStatus_callback_registered || cb_infos.sceNpEulaShowCurrentEula_callback_registered)
|
|
|
|
|
{
|
|
|
|
|
return SCE_NP_EULA_ERROR_ALREADY_INITIALIZED;
|
|
|
|
|
}
|
2020-03-26 21:10:24 +01:00
|
|
|
|
2024-01-05 03:56:31 +01:00
|
|
|
// Call callback (Unknown parameters)
|
2020-03-26 21:10:24 +01:00
|
|
|
|
2017-03-25 15:25:24 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DECLARE(ppu_module_manager::cellSysutilNpEula)("cellSysutilNpEula", []()
|
2025-04-05 21:50:45 +02:00
|
|
|
{
|
|
|
|
|
REG_FUNC(cellSysutilNpEula, sceNpEulaCheckEulaStatus);
|
|
|
|
|
REG_FUNC(cellSysutilNpEula, sceNpEulaAbort);
|
|
|
|
|
REG_FUNC(cellSysutilNpEula, sceNpEulaShowCurrentEula);
|
|
|
|
|
});
|