am: Implement CreateTransferMemoryStorage
Creates an AM::IStorage object with the contents of the transfer memory located at the handle provided.
This commit is contained in:
parent
c70529c1ec
commit
76d515327b
|
@ -704,6 +704,31 @@ void ILibraryAppletCreator::CreateStorage(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_AM, "called, size={}", size);
|
LOG_DEBUG(Service_AM, "called, size={}", size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ILibraryAppletCreator::CreateTransferMemoryStorage(Kernel::HLERequestContext& ctx) {
|
||||||
|
IPC::RequestParser rp{ctx};
|
||||||
|
|
||||||
|
rp.SetCurrentOffset(3);
|
||||||
|
const auto handle{rp.Pop<Kernel::Handle>()};
|
||||||
|
|
||||||
|
const auto shared_mem =
|
||||||
|
Core::System::GetInstance().CurrentProcess()->GetHandleTable().Get<Kernel::SharedMemory>(
|
||||||
|
handle);
|
||||||
|
|
||||||
|
if (shared_mem == nullptr) {
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(ResultCode(-1));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<u8> memory(shared_mem->size);
|
||||||
|
std::memcpy(memory.data(), shared_mem->backing_block->data() + shared_mem->backing_block_offset,
|
||||||
|
memory.size());
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
rb.PushIpcInterface(std::make_shared<IStorage>(std::move(memory)));
|
||||||
|
}
|
||||||
|
|
||||||
IApplicationFunctions::IApplicationFunctions() : ServiceFramework("IApplicationFunctions") {
|
IApplicationFunctions::IApplicationFunctions() : ServiceFramework("IApplicationFunctions") {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
|
|
|
@ -163,6 +163,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void CreateLibraryApplet(Kernel::HLERequestContext& ctx);
|
void CreateLibraryApplet(Kernel::HLERequestContext& ctx);
|
||||||
void CreateStorage(Kernel::HLERequestContext& ctx);
|
void CreateStorage(Kernel::HLERequestContext& ctx);
|
||||||
|
void CreateTransferMemoryStorage(Kernel::HLERequestContext& ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
class IApplicationFunctions final : public ServiceFramework<IApplicationFunctions> {
|
class IApplicationFunctions final : public ServiceFramework<IApplicationFunctions> {
|
||||||
|
|
Loading…
Reference in a new issue