mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-12-16 04:09:39 +00:00
Check buffer out and size in HID_USBv5/USB_VEN GetVersion Ioctl
This commit is contained in:
parent
2e22a3cf42
commit
f665eaad5f
@ -204,6 +204,22 @@ std::optional<IPCReply> USBV5ResourceManager::HandleDeviceIOCtl(const IOCtlReque
|
|||||||
return handler(*device);
|
return handler(*device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IPCReply USBV5ResourceManager::GetUSBVersion(const IOCtlRequest& request) const
|
||||||
|
{
|
||||||
|
static constexpr u32 VERSION = 0x50001;
|
||||||
|
|
||||||
|
if (request.buffer_in != 0 || request.buffer_in_size != 0 || request.buffer_out == 0 ||
|
||||||
|
request.buffer_out_size != 0x20)
|
||||||
|
{
|
||||||
|
return IPCReply(IPC_EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& system = GetSystem();
|
||||||
|
auto& memory = system.GetMemory();
|
||||||
|
memory.Write_U32(VERSION, request.buffer_out);
|
||||||
|
return IPCReply(IPC_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
void USBV5ResourceManager::OnDeviceChange(const ChangeEvent event,
|
void USBV5ResourceManager::OnDeviceChange(const ChangeEvent event,
|
||||||
std::shared_ptr<USB::Device> device)
|
std::shared_ptr<USB::Device> device)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -83,6 +83,7 @@ protected:
|
|||||||
|
|
||||||
using Handler = std::function<std::optional<IPCReply>(USBV5Device&)>;
|
using Handler = std::function<std::optional<IPCReply>(USBV5Device&)>;
|
||||||
std::optional<IPCReply> HandleDeviceIOCtl(const IOCtlRequest& request, Handler handler);
|
std::optional<IPCReply> HandleDeviceIOCtl(const IOCtlRequest& request, Handler handler);
|
||||||
|
IPCReply GetUSBVersion(const IOCtlRequest& request) const;
|
||||||
|
|
||||||
void OnDeviceChange(ChangeEvent event, std::shared_ptr<USB::Device> device) override;
|
void OnDeviceChange(ChangeEvent event, std::shared_ptr<USB::Device> device) override;
|
||||||
void OnDeviceChangeEnd() override;
|
void OnDeviceChangeEnd() override;
|
||||||
|
|||||||
@ -16,21 +16,15 @@
|
|||||||
|
|
||||||
namespace IOS::HLE
|
namespace IOS::HLE
|
||||||
{
|
{
|
||||||
constexpr u32 USBV5_VERSION = 0x50001;
|
|
||||||
|
|
||||||
USB_HIDv5::~USB_HIDv5() = default;
|
USB_HIDv5::~USB_HIDv5() = default;
|
||||||
|
|
||||||
std::optional<IPCReply> USB_HIDv5::IOCtl(const IOCtlRequest& request)
|
std::optional<IPCReply> USB_HIDv5::IOCtl(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
auto& system = GetSystem();
|
|
||||||
auto& memory = system.GetMemory();
|
|
||||||
|
|
||||||
request.Log(GetDeviceName(), Common::Log::LogType::IOS_USB);
|
request.Log(GetDeviceName(), Common::Log::LogType::IOS_USB);
|
||||||
switch (request.request)
|
switch (request.request)
|
||||||
{
|
{
|
||||||
case USB::IOCTL_USBV5_GETVERSION:
|
case USB::IOCTL_USBV5_GETVERSION:
|
||||||
memory.Write_U32(USBV5_VERSION, request.buffer_out);
|
return GetUSBVersion(request);
|
||||||
return IPCReply(IPC_SUCCESS);
|
|
||||||
case USB::IOCTL_USBV5_GETDEVICECHANGE:
|
case USB::IOCTL_USBV5_GETDEVICECHANGE:
|
||||||
return GetDeviceChange(request);
|
return GetDeviceChange(request);
|
||||||
case USB::IOCTL_USBV5_SHUTDOWN:
|
case USB::IOCTL_USBV5_SHUTDOWN:
|
||||||
|
|||||||
@ -16,21 +16,15 @@
|
|||||||
|
|
||||||
namespace IOS::HLE
|
namespace IOS::HLE
|
||||||
{
|
{
|
||||||
constexpr u32 USBV5_VERSION = 0x50001;
|
|
||||||
|
|
||||||
USB_VEN::~USB_VEN() = default;
|
USB_VEN::~USB_VEN() = default;
|
||||||
|
|
||||||
std::optional<IPCReply> USB_VEN::IOCtl(const IOCtlRequest& request)
|
std::optional<IPCReply> USB_VEN::IOCtl(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
auto& system = GetSystem();
|
|
||||||
auto& memory = system.GetMemory();
|
|
||||||
|
|
||||||
request.Log(GetDeviceName(), Common::Log::LogType::IOS_USB);
|
request.Log(GetDeviceName(), Common::Log::LogType::IOS_USB);
|
||||||
switch (request.request)
|
switch (request.request)
|
||||||
{
|
{
|
||||||
case USB::IOCTL_USBV5_GETVERSION:
|
case USB::IOCTL_USBV5_GETVERSION:
|
||||||
memory.Write_U32(USBV5_VERSION, request.buffer_out);
|
return GetUSBVersion(request);
|
||||||
return IPCReply(IPC_SUCCESS);
|
|
||||||
case USB::IOCTL_USBV5_GETDEVICECHANGE:
|
case USB::IOCTL_USBV5_GETDEVICECHANGE:
|
||||||
return GetDeviceChange(request);
|
return GetDeviceChange(request);
|
||||||
case USB::IOCTL_USBV5_SHUTDOWN:
|
case USB::IOCTL_USBV5_SHUTDOWN:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user