MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / ParseCommand

Method ParseCommand

pcsx2/PINE.cpp:511–757  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

509}
510
511PINEServer::IPCBuffer PINEServer::ParseCommand(std::span<u8> buf, std::vector<u8>& ret_buffer, u32 buf_size)
512{
513 u32 ret_cnt = 5;
514 u32 buf_cnt = 0;
515
516 while (buf_cnt < buf_size)
517 {
518 if (!SafetyChecks(buf_cnt, 1, ret_cnt, 0, buf_size)) [[unlikely]]
519 return IPCBuffer{5, MakeFailIPC(ret_buffer)};
520 buf_cnt++;
521 // example IPC messages: MsgRead/Write
522 // refer to the client doc for more info on the format
523 // IPC Message event (1 byte)
524 // | Memory address (4 byte)
525 // | | argument (VLE)
526 // | | |
527 // format: XX YY YY YY YY ZZ ZZ ZZ ZZ
528 // reply code: 00 = OK, FF = NOT OK
529 // | return value (VLE)
530 // | |
531 // reply: XX ZZ ZZ ZZ ZZ
532 switch ((IPCCommand)buf[buf_cnt - 1])
533 {
534 case MsgRead8:
535 {
536 if (!VMManager::HasValidVM())
537 goto error;
538 if (!SafetyChecks(buf_cnt, 4, ret_cnt, 1, buf_size)) [[unlikely]]
539 goto error;
540 const u32 a = FromSpan<u32>(buf, buf_cnt);
541 const u8 res = vtlb_ramRead<mem8_t>(a);
542 ToResultVector(ret_buffer, res, ret_cnt);
543 ret_cnt += 1;
544 buf_cnt += 4;
545 break;
546 }
547 case MsgRead16:
548 {
549 if (!VMManager::HasValidVM())
550 goto error;
551 if (!SafetyChecks(buf_cnt, 4, ret_cnt, 2, buf_size)) [[unlikely]]
552 goto error;
553 const u32 a = FromSpan<u32>(buf, buf_cnt);
554 const u16 res = vtlb_ramRead<mem16_t>(a);
555 ToResultVector(ret_buffer, res, ret_cnt);
556 ret_cnt += 2;
557 buf_cnt += 4;
558 break;
559 }
560 case MsgRead32:
561 {
562 if (!VMManager::HasValidVM())
563 goto error;
564 if (!SafetyChecks(buf_cnt, 4, ret_cnt, 4, buf_size)) [[unlikely]]
565 goto error;
566 const u32 a = FromSpan<u32>(buf, buf_cnt);
567 const u32 res = vtlb_ramRead<mem32_t>(a);
568 ToResultVector(ret_buffer, res, ret_cnt);

Callers

nothing calls this directly

Calls 8

SafetyChecksFunction · 0.85
ToResultVectorFunction · 0.85
GetDescriptionMethod · 0.80
formatFunction · 0.50
sizeMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected