From 9d5138bef18f8d199665b1c0cd2b96a7a4fec944 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sat, 20 Feb 2021 17:23:57 +0000 Subject: [PATCH] Support Ioctl3 without the inline output buffer This is used by Project Diva for GET_VA_REGIONS --- .../cpp/skyline/services/nvdrv/INvDrvServices.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/cpp/skyline/services/nvdrv/INvDrvServices.cpp b/app/src/main/cpp/skyline/services/nvdrv/INvDrvServices.cpp index 94f02cd7..0ad93b7d 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/INvDrvServices.cpp +++ b/app/src/main/cpp/skyline/services/nvdrv/INvDrvServices.cpp @@ -125,10 +125,14 @@ namespace skyline::service::nvdrv { // Strip the permissions from the command leaving only the ID cmd &= 0xFFFF; - if (request.inputBuf.empty() || request.outputBuf.size() < 2) + if (request.inputBuf.empty() || request.outputBuf.empty()) { throw exception("Inadequate amount of buffers for IOCTL3: I - {}, O - {}", request.inputBuf.size(), request.outputBuf.size()); - else if (request.inputBuf[0].data() != request.outputBuf[0].data()) - throw exception("IOCTL3 Input Buffer (0x{:X}) != Output Buffer (0x{:X}) [Output Buffer #2: 0x{:X}]", request.inputBuf[0].data(), request.outputBuf[0].data(), request.outputBuf[1].data()); + } else if (request.inputBuf[0].data() != request.outputBuf[0].data()) { + if (request.outputBuf.size() >= 2) + throw exception("IOCTL3 Input Buffer (0x{:X}) != Output Buffer (0x{:X}) [Output Buffer #2: 0x{:X}]", request.inputBuf[0].data(), request.outputBuf[0].data(), request.outputBuf[1].data()); + else + throw exception("IOCTL3 Input Buffer (0x{:X}) != Output Buffer (0x{:X})", request.inputBuf[0].data(), request.outputBuf[0].data()); + } span buffer{}; if (request.inputBuf[0].size() >= request.outputBuf[0].size()) @@ -136,7 +140,8 @@ namespace skyline::service::nvdrv { else buffer = request.outputBuf[0]; - response.Push(device->HandleIoctl(cmd, device::IoctlType::Ioctl3, buffer, request.outputBuf[1])); + + response.Push(device->HandleIoctl(cmd, device::IoctlType::Ioctl3, buffer, request.outputBuf.size() >= 2 ? request.outputBuf[1] : span())); return {}; }