2017-04-13 18:30:25 +02:00
|
|
|
#include "stdafx.h"
|
2018-09-29 00:12:00 +02:00
|
|
|
#include "sys_ss.h"
|
|
|
|
|
|
2017-04-13 18:30:25 +02:00
|
|
|
#include "Emu/Cell/PPUThread.h"
|
|
|
|
|
|
|
|
|
|
|
2017-09-25 17:52:34 +02:00
|
|
|
#ifdef _WIN32
|
|
|
|
|
#include <Windows.h>
|
|
|
|
|
#include <wincrypt.h>
|
|
|
|
|
|
|
|
|
|
const HCRYPTPROV s_crypto_provider = []() -> HCRYPTPROV
|
|
|
|
|
{
|
|
|
|
|
HCRYPTPROV result;
|
|
|
|
|
|
2017-11-01 23:18:11 +01:00
|
|
|
if (!CryptAcquireContextW(&result, nullptr, nullptr, PROV_RSA_FULL, 0) && !CryptAcquireContextW(&result, nullptr, nullptr, PROV_RSA_FULL, CRYPT_NEWKEYSET))
|
2017-09-25 17:52:34 +02:00
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::atexit([]()
|
|
|
|
|
{
|
|
|
|
|
if (s_crypto_provider)
|
|
|
|
|
{
|
|
|
|
|
CryptReleaseContext(s_crypto_provider, 0);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}();
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-02-09 15:49:37 +01:00
|
|
|
|
2017-04-13 18:30:25 +02:00
|
|
|
|
2018-08-25 14:39:00 +02:00
|
|
|
LOG_CHANNEL(sys_ss);
|
2017-04-13 18:30:25 +02:00
|
|
|
|
2017-09-25 17:52:34 +02:00
|
|
|
error_code sys_ss_random_number_generator(u32 arg1, vm::ptr<void> buf, u64 size)
|
|
|
|
|
{
|
|
|
|
|
sys_ss.warning("sys_ss_random_number_generator(arg1=%u, buf=*0x%x, size=0x%x)", arg1, buf, size);
|
|
|
|
|
|
|
|
|
|
if (arg1 != 2)
|
|
|
|
|
{
|
|
|
|
|
return 0x80010509;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (size > 0x10000000)
|
|
|
|
|
{
|
|
|
|
|
return 0x80010501;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
if (!s_crypto_provider || !CryptGenRandom(s_crypto_provider, size, (BYTE*)buf.get_ptr()))
|
|
|
|
|
{
|
|
|
|
|
return CELL_EABORT;
|
|
|
|
|
}
|
|
|
|
|
#else
|
2017-10-04 07:03:24 +02:00
|
|
|
fs::file rnd{"/dev/urandom"};
|
2017-09-25 17:52:34 +02:00
|
|
|
|
|
|
|
|
if (!rnd || rnd.read(buf.get_ptr(), size) != size)
|
|
|
|
|
{
|
|
|
|
|
return CELL_EABORT;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-09 15:49:37 +01:00
|
|
|
s32 sys_ss_get_console_id(vm::ptr<u8> buf)
|
2017-04-13 18:30:25 +02:00
|
|
|
{
|
|
|
|
|
sys_ss.todo("sys_ss_get_console_id(buf=*0x%x)", buf);
|
|
|
|
|
|
|
|
|
|
// TODO: Return some actual IDPS?
|
|
|
|
|
*buf = 0;
|
|
|
|
|
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-09 15:49:37 +01:00
|
|
|
s32 sys_ss_get_open_psid(vm::ptr<CellSsOpenPSID> psid)
|
2017-04-13 18:30:25 +02:00
|
|
|
{
|
|
|
|
|
sys_ss.warning("sys_ss_get_open_psid(psid=*0x%x)", psid);
|
|
|
|
|
|
|
|
|
|
psid->high = 0;
|
|
|
|
|
psid->low = 0;
|
|
|
|
|
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|