mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-27 17:34:22 +01:00
Merge pull request #5920 from bunnei/am-ldn-fix
Fix LDN Initialization return code & resulting AM overflow
This commit is contained in:
commit
b0a3915351
@ -400,6 +400,7 @@ add_library(core STATIC
|
|||||||
hle/service/hid/controllers/xpad.h
|
hle/service/hid/controllers/xpad.h
|
||||||
hle/service/lbl/lbl.cpp
|
hle/service/lbl/lbl.cpp
|
||||||
hle/service/lbl/lbl.h
|
hle/service/lbl/lbl.h
|
||||||
|
hle/service/ldn/errors.h
|
||||||
hle/service/ldn/ldn.cpp
|
hle/service/ldn/ldn.cpp
|
||||||
hle/service/ldn/ldn.h
|
hle/service/ldn/ldn.h
|
||||||
hle/service/ldr/ldr.cpp
|
hle/service/ldr/ldr.cpp
|
||||||
|
@ -1047,20 +1047,21 @@ void IStorageAccessor::Write(Kernel::HLERequestContext& ctx) {
|
|||||||
|
|
||||||
const u64 offset{rp.Pop<u64>()};
|
const u64 offset{rp.Pop<u64>()};
|
||||||
const std::vector<u8> data{ctx.ReadBuffer()};
|
const std::vector<u8> data{ctx.ReadBuffer()};
|
||||||
|
const std::size_t size{std::min(data.size(), backing.GetSize() - offset)};
|
||||||
|
|
||||||
LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, data.size());
|
LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, size);
|
||||||
|
|
||||||
if (data.size() > backing.GetSize() - offset) {
|
if (offset > backing.GetSize()) {
|
||||||
LOG_ERROR(Service_AM,
|
LOG_ERROR(Service_AM,
|
||||||
"offset is out of bounds, backing_buffer_sz={}, data_size={}, offset={}",
|
"offset is out of bounds, backing_buffer_sz={}, data_size={}, offset={}",
|
||||||
backing.GetSize(), data.size(), offset);
|
backing.GetSize(), size, offset);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(ERR_SIZE_OUT_OF_BOUNDS);
|
rb.Push(ERR_SIZE_OUT_OF_BOUNDS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::memcpy(backing.GetData().data() + offset, data.data(), data.size());
|
std::memcpy(backing.GetData().data() + offset, data.data(), size);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
@ -1070,11 +1071,11 @@ void IStorageAccessor::Read(Kernel::HLERequestContext& ctx) {
|
|||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
|
|
||||||
const u64 offset{rp.Pop<u64>()};
|
const u64 offset{rp.Pop<u64>()};
|
||||||
const std::size_t size{ctx.GetWriteBufferSize()};
|
const std::size_t size{std::min(ctx.GetWriteBufferSize(), backing.GetSize() - offset)};
|
||||||
|
|
||||||
LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, size);
|
LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, size);
|
||||||
|
|
||||||
if (size > backing.GetSize() - offset) {
|
if (offset > backing.GetSize()) {
|
||||||
LOG_ERROR(Service_AM, "offset is out of bounds, backing_buffer_sz={}, size={}, offset={}",
|
LOG_ERROR(Service_AM, "offset is out of bounds, backing_buffer_sz={}, size={}, offset={}",
|
||||||
backing.GetSize(), size, offset);
|
backing.GetSize(), size, offset);
|
||||||
|
|
||||||
|
13
src/core/hle/service/ldn/errors.h
Normal file
13
src/core/hle/service/ldn/errors.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// Copyright 2021 yuzu emulator team
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/hle/result.h"
|
||||||
|
|
||||||
|
namespace Service::LDN {
|
||||||
|
|
||||||
|
constexpr ResultCode ERROR_DISABLED{ErrorModule::LDN, 22};
|
||||||
|
|
||||||
|
} // namespace Service::LDN
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "core/hle/ipc_helpers.h"
|
#include "core/hle/ipc_helpers.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
|
#include "core/hle/service/ldn/errors.h"
|
||||||
#include "core/hle/service/ldn/ldn.h"
|
#include "core/hle/service/ldn/ldn.h"
|
||||||
#include "core/hle/service/sm/sm.h"
|
#include "core/hle/service/sm/sm.h"
|
||||||
|
|
||||||
@ -103,7 +104,7 @@ public:
|
|||||||
: ServiceFramework{system_, "IUserLocalCommunicationService"} {
|
: ServiceFramework{system_, "IUserLocalCommunicationService"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, nullptr, "GetState"},
|
{0, &IUserLocalCommunicationService::GetState, "GetState"},
|
||||||
{1, nullptr, "GetNetworkInfo"},
|
{1, nullptr, "GetNetworkInfo"},
|
||||||
{2, nullptr, "GetIpv4Address"},
|
{2, nullptr, "GetIpv4Address"},
|
||||||
{3, nullptr, "GetDisconnectReason"},
|
{3, nullptr, "GetDisconnectReason"},
|
||||||
@ -138,13 +139,38 @@ public:
|
|||||||
RegisterHandlers(functions);
|
RegisterHandlers(functions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize2(Kernel::HLERequestContext& ctx) {
|
void GetState(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||||
// Result success seem make this services start network and continue.
|
|
||||||
// If we just pass result error then it will stop and maybe try again and again.
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(RESULT_UNKNOWN);
|
// Indicate a network error, as we do not actually emulate LDN
|
||||||
|
rb.Push(static_cast<u32>(State::Error));
|
||||||
|
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Initialize2(Kernel::HLERequestContext& ctx) {
|
||||||
|
LOG_DEBUG(Service_LDN, "called");
|
||||||
|
|
||||||
|
is_initialized = true;
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum class State {
|
||||||
|
None,
|
||||||
|
Initialized,
|
||||||
|
AccessPointOpened,
|
||||||
|
AccessPointCreated,
|
||||||
|
StationOpened,
|
||||||
|
StationConnected,
|
||||||
|
Error,
|
||||||
|
};
|
||||||
|
|
||||||
|
bool is_initialized{};
|
||||||
};
|
};
|
||||||
|
|
||||||
class LDNS final : public ServiceFramework<LDNS> {
|
class LDNS final : public ServiceFramework<LDNS> {
|
||||||
|
Loading…
Reference in New Issue
Block a user