summaryrefslogtreecommitdiff
path: root/src/core/hle/applets
diff options
context:
space:
mode:
authorGravatar MerryMage2016-04-16 11:18:49 +0100
committerGravatar Subv2016-05-21 11:14:12 -0500
commitfddd243b17edb0fe03ef1a85c2abdf95353a534d (patch)
treec3e6a15cc40b4516fcf0f0a485261777f7d01f8e /src/core/hle/applets
parentKernel/Thread: Remove use of Memory::GetPointer (diff)
downloadyuzu-fddd243b17edb0fe03ef1a85c2abdf95353a534d.tar.gz
yuzu-fddd243b17edb0fe03ef1a85c2abdf95353a534d.tar.xz
yuzu-fddd243b17edb0fe03ef1a85c2abdf95353a534d.zip
APT: Remove use of Memory::GetPointer
Diffstat (limited to 'src/core/hle/applets')
-rw-r--r--src/core/hle/applets/mii_selector.cpp21
-rw-r--r--src/core/hle/applets/mii_selector.h4
-rw-r--r--src/core/hle/applets/swkbd.cpp15
3 files changed, 21 insertions, 19 deletions
diff --git a/src/core/hle/applets/mii_selector.cpp b/src/core/hle/applets/mii_selector.cpp
index bf39eca22..77f01d208 100644
--- a/src/core/hle/applets/mii_selector.cpp
+++ b/src/core/hle/applets/mii_selector.cpp
@@ -32,9 +32,9 @@ ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& p
32 // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared memory. 32 // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared memory.
33 // Create the SharedMemory that will hold the framebuffer data 33 // Create the SharedMemory that will hold the framebuffer data
34 Service::APT::CaptureBufferInfo capture_info; 34 Service::APT::CaptureBufferInfo capture_info;
35 ASSERT(sizeof(capture_info) == parameter.buffer_size); 35 ASSERT(sizeof(capture_info) == parameter.buffer.size());
36 36
37 memcpy(&capture_info, parameter.data, sizeof(capture_info)); 37 memcpy(&capture_info, parameter.buffer.data(), sizeof(capture_info));
38 38
39 using Kernel::MemoryPermission; 39 using Kernel::MemoryPermission;
40 // Allocate a heap block of the required size for this applet. 40 // Allocate a heap block of the required size for this applet.
@@ -47,8 +47,7 @@ ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& p
47 // Send the response message with the newly created SharedMemory 47 // Send the response message with the newly created SharedMemory
48 Service::APT::MessageParameter result; 48 Service::APT::MessageParameter result;
49 result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished); 49 result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished);
50 result.data = nullptr; 50 result.buffer.clear();
51 result.buffer_size = 0;
52 result.destination_id = static_cast<u32>(Service::APT::AppletId::Application); 51 result.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
53 result.sender_id = static_cast<u32>(id); 52 result.sender_id = static_cast<u32>(id);
54 result.object = framebuffer_memory; 53 result.object = framebuffer_memory;
@@ -63,15 +62,17 @@ ResultCode MiiSelector::StartImpl(const Service::APT::AppletStartupParameter& pa
63 // TODO(Subv): Set the expected fields in the response buffer before resending it to the application. 62 // TODO(Subv): Set the expected fields in the response buffer before resending it to the application.
64 // TODO(Subv): Reverse the parameter format for the Mii Selector 63 // TODO(Subv): Reverse the parameter format for the Mii Selector
65 64
66 if(parameter.buffer_size >= sizeof(u32)) { 65 memcpy(&config, parameter.buffer.data(), parameter.buffer.size());
67 // TODO: defaults return no error, but garbage in other unknown fields 66
68 memset(parameter.data, 0, sizeof(u32)); 67 // TODO(Subv): Find more about this structure, result code 0 is enough to let most games continue.
69 } 68 MiiResult result;
69 memset(&result, 0, sizeof(result));
70 result.result_code = 0;
70 71
71 // Let the application know that we're closing 72 // Let the application know that we're closing
72 Service::APT::MessageParameter message; 73 Service::APT::MessageParameter message;
73 message.buffer_size = parameter.buffer_size; 74 message.buffer.resize(sizeof(MiiResult));
74 message.data = parameter.data; 75 std::memcpy(message.buffer.data(), &result, message.buffer.size());
75 message.signal = static_cast<u32>(Service::APT::SignalType::LibAppClosed); 76 message.signal = static_cast<u32>(Service::APT::SignalType::LibAppClosed);
76 message.destination_id = static_cast<u32>(Service::APT::AppletId::Application); 77 message.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
77 message.sender_id = static_cast<u32>(id); 78 message.sender_id = static_cast<u32>(id);
diff --git a/src/core/hle/applets/mii_selector.h b/src/core/hle/applets/mii_selector.h
index be6b04642..24e8e721d 100644
--- a/src/core/hle/applets/mii_selector.h
+++ b/src/core/hle/applets/mii_selector.h
@@ -24,7 +24,7 @@ struct MiiConfig {
24 u8 unk_004; 24 u8 unk_004;
25 INSERT_PADDING_BYTES(3); 25 INSERT_PADDING_BYTES(3);
26 u16 unk_008; 26 u16 unk_008;
27 INSERT_PADDING_BYTES(0x8C - 0xA); 27 INSERT_PADDING_BYTES(0x82);
28 u8 unk_08C; 28 u8 unk_08C;
29 INSERT_PADDING_BYTES(3); 29 INSERT_PADDING_BYTES(3);
30 u16 unk_090; 30 u16 unk_090;
@@ -75,6 +75,8 @@ public:
75 75
76 /// Whether this applet is currently running instead of the host application or not. 76 /// Whether this applet is currently running instead of the host application or not.
77 bool started; 77 bool started;
78
79 MiiConfig config;
78}; 80};
79 81
80} 82}
diff --git a/src/core/hle/applets/swkbd.cpp b/src/core/hle/applets/swkbd.cpp
index 3ad950692..d87bf3d57 100644
--- a/src/core/hle/applets/swkbd.cpp
+++ b/src/core/hle/applets/swkbd.cpp
@@ -35,9 +35,9 @@ ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter con
35 // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared memory. 35 // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared memory.
36 // Create the SharedMemory that will hold the framebuffer data 36 // Create the SharedMemory that will hold the framebuffer data
37 Service::APT::CaptureBufferInfo capture_info; 37 Service::APT::CaptureBufferInfo capture_info;
38 ASSERT(sizeof(capture_info) == parameter.buffer_size); 38 ASSERT(sizeof(capture_info) == parameter.buffer.size());
39 39
40 memcpy(&capture_info, parameter.data, sizeof(capture_info)); 40 memcpy(&capture_info, parameter.buffer.data(), sizeof(capture_info));
41 41
42 using Kernel::MemoryPermission; 42 using Kernel::MemoryPermission;
43 // Allocate a heap block of the required size for this applet. 43 // Allocate a heap block of the required size for this applet.
@@ -50,8 +50,7 @@ ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter con
50 // Send the response message with the newly created SharedMemory 50 // Send the response message with the newly created SharedMemory
51 Service::APT::MessageParameter result; 51 Service::APT::MessageParameter result;
52 result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished); 52 result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished);
53 result.data = nullptr; 53 result.buffer.clear();
54 result.buffer_size = 0;
55 result.destination_id = static_cast<u32>(Service::APT::AppletId::Application); 54 result.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
56 result.sender_id = static_cast<u32>(id); 55 result.sender_id = static_cast<u32>(id);
57 result.object = framebuffer_memory; 56 result.object = framebuffer_memory;
@@ -61,9 +60,9 @@ ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter con
61} 60}
62 61
63ResultCode SoftwareKeyboard::StartImpl(Service::APT::AppletStartupParameter const& parameter) { 62ResultCode SoftwareKeyboard::StartImpl(Service::APT::AppletStartupParameter const& parameter) {
64 ASSERT_MSG(parameter.buffer_size == sizeof(config), "The size of the parameter (SoftwareKeyboardConfig) is wrong"); 63 ASSERT_MSG(parameter.buffer.size() == sizeof(config), "The size of the parameter (SoftwareKeyboardConfig) is wrong");
65 64
66 memcpy(&config, parameter.data, parameter.buffer_size); 65 memcpy(&config, parameter.buffer.data(), parameter.buffer.size());
67 text_memory = boost::static_pointer_cast<Kernel::SharedMemory, Kernel::Object>(parameter.object); 66 text_memory = boost::static_pointer_cast<Kernel::SharedMemory, Kernel::Object>(parameter.object);
68 67
69 // TODO(Subv): Verify if this is the correct behavior 68 // TODO(Subv): Verify if this is the correct behavior
@@ -107,8 +106,8 @@ void SoftwareKeyboard::DrawScreenKeyboard() {
107void SoftwareKeyboard::Finalize() { 106void SoftwareKeyboard::Finalize() {
108 // Let the application know that we're closing 107 // Let the application know that we're closing
109 Service::APT::MessageParameter message; 108 Service::APT::MessageParameter message;
110 message.buffer_size = sizeof(SoftwareKeyboardConfig); 109 message.buffer.resize(sizeof(SoftwareKeyboardConfig));
111 message.data = reinterpret_cast<u8*>(&config); 110 std::memcpy(message.buffer.data(), &config, message.buffer.size());
112 message.signal = static_cast<u32>(Service::APT::SignalType::LibAppClosed); 111 message.signal = static_cast<u32>(Service::APT::SignalType::LibAppClosed);
113 message.destination_id = static_cast<u32>(Service::APT::AppletId::Application); 112 message.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
114 message.sender_id = static_cast<u32>(id); 113 message.sender_id = static_cast<u32>(id);