pine: add vle replies

This commit is contained in:
Gauvain 'GovanifY' Roussel-Tarbouriech 2021-05-31 15:37:32 +02:00 committed by refractionpcsx2
parent f68122a380
commit 2e6af75f1d
1 changed files with 45 additions and 28 deletions

View File

@ -380,6 +380,8 @@ PINEServer::IPCBuffer PINEServer::ParseCommand(char* buf, char* ret_buffer, u32
} }
case MsgVersion: case MsgVersion:
{ {
if (!m_vm->HasActiveMachine())
goto error;
char version[256] = {}; char version[256] = {};
if (GIT_TAGGED_COMMIT) // Nightly builds if (GIT_TAGGED_COMMIT) // Nightly builds
{ {
@ -391,11 +393,14 @@ PINEServer::IPCBuffer PINEServer::ParseCommand(char* buf, char* ret_buffer, u32
{ {
sprintf(version, "PCSX2 %u.%u.%u-%lld", PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo, SVN_REV); sprintf(version, "PCSX2 %u.%u.%u-%lld", PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo, SVN_REV);
} }
version[255] = 0x00; const u32 size = strlen(version) + 1;
if (!SafetyChecks(buf_cnt, 0, ret_cnt, 256, buf_size)) version[size] = 0x00;
if (!SafetyChecks(buf_cnt, 0, ret_cnt, size + 4, buf_size))
goto error; goto error;
memcpy(&ret_buffer[ret_cnt], version, 256); ToArray(ret_buffer, size, ret_cnt);
ret_cnt += 256; ret_cnt += 4;
memcpy(&ret_buffer[ret_cnt], version, size);
ret_cnt += size;
break; break;
} }
case MsgSaveState: case MsgSaveState:
@ -422,52 +427,64 @@ PINEServer::IPCBuffer PINEServer::ParseCommand(char* buf, char* ret_buffer, u32
{ {
if (!m_vm->HasActiveMachine()) if (!m_vm->HasActiveMachine())
goto error; goto error;
if (!SafetyChecks(buf_cnt, 0, ret_cnt, 256, buf_size)) char title[GameInfo::gameName.size() + 1] = {};
goto error;
char title[256] = {};
sprintf(title, "%s", GameInfo::gameName.ToUTF8().data()); sprintf(title, "%s", GameInfo::gameName.ToUTF8().data());
title[255] = 0x00; const u32 size = strlen(title) + 1;
memcpy(&ret_buffer[ret_cnt], title, 256); title[size] = 0x00;
ret_cnt += 256; if (!SafetyChecks(buf_cnt, 0, ret_cnt, size + 4, buf_size))
goto error;
ToArray(ret_buffer, size, ret_cnt);
ret_cnt += 4;
memcpy(&ret_buffer[ret_cnt], title, size);
ret_cnt += size;
break; break;
} }
case MsgID: case MsgID:
{ {
if (!m_vm->HasActiveMachine()) if (!m_vm->HasActiveMachine())
goto error; goto error;
if (!SafetyChecks(buf_cnt, 0, ret_cnt, 256, buf_size)) char title[GameInfo::gameName.size() + 1] = {};
sprintf(title, "%s", GameInfo::gameSerial.ToUTF8().data());
const u32 size = strlen(title) + 1;
title[size] = 0x00;
if (!SafetyChecks(buf_cnt, 0, ret_cnt, size + 4, buf_size))
goto error; goto error;
char id[256] = {}; ToArray(ret_buffer, size, ret_cnt);
sprintf(id, "%s", GameInfo::gameSerial.ToUTF8().data()); ret_cnt += 4;
id[255] = 0x00; memcpy(&ret_buffer[ret_cnt], title, size);
memcpy(&ret_buffer[ret_cnt], id, 256); ret_cnt += size;
ret_cnt += 256;
break; break;
} }
case MsgUUID: case MsgUUID:
{ {
if (!m_vm->HasActiveMachine()) if (!m_vm->HasActiveMachine())
goto error; goto error;
if (!SafetyChecks(buf_cnt, 0, ret_cnt, 256, buf_size)) char title[GameInfo::gameName.size() + 1] = {};
sprintf(title, "%s", GameInfo::gameCRC.ToUTF8().data());
const u32 size = strlen(title) + 1;
title[size] = 0x00;
if (!SafetyChecks(buf_cnt, 0, ret_cnt, size + 4, buf_size))
goto error; goto error;
char uuid[256] = {}; ToArray(ret_buffer, size, ret_cnt);
sprintf(uuid, "%s", GameInfo::gameCRC.ToUTF8().data()); ret_cnt += 4;
uuid[255] = 0x00; memcpy(&ret_buffer[ret_cnt], title, size);
memcpy(&ret_buffer[ret_cnt], uuid, 256); ret_cnt += size;
ret_cnt += 256;
break; break;
} }
case MsgGameVersion: case MsgGameVersion:
{ {
if (!m_vm->HasActiveMachine()) if (!m_vm->HasActiveMachine())
goto error; goto error;
if (!SafetyChecks(buf_cnt, 0, ret_cnt, 256, buf_size)) char title[GameInfo::gameName.size() + 1] = {};
sprintf(title, "%s", GameInfo::gameVersion.ToUTF8().data());
const u32 size = strlen(title) + 1;
title[size] = 0x00;
if (!SafetyChecks(buf_cnt, 0, ret_cnt, size + 4, buf_size))
goto error; goto error;
char version[256] = {}; ToArray(ret_buffer, size, ret_cnt);
sprintf(version, "%s", GameInfo::gameVersion.ToUTF8().data()); ret_cnt += 4;
version[255] = 0x00; memcpy(&ret_buffer[ret_cnt], title, size);
memcpy(&ret_buffer[ret_cnt], version, 256); ret_cnt += size;
ret_cnt += 256;
break; break;
} }
case MsgStatus: case MsgStatus: