mirror of
https://github.com/PabloMK7/citra.git
synced 2024-11-20 06:24:17 +00:00
Merge pull request #3469 from wwylele/frd-new-framework
Service/FRD: convert to ServiceFramework
This commit is contained in:
commit
5dc8ac80dd
8 changed files with 313 additions and 305 deletions
|
@ -45,18 +45,6 @@ public:
|
|||
memset(cmdbuf + index, 0, size_in_words * sizeof(u32));
|
||||
index += size_in_words;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieves the address of a static buffer, used when a buffer is needed for output
|
||||
* @param buffer_id The index of the static buffer
|
||||
* @param data_size If non-null, will store the size of the buffer
|
||||
*/
|
||||
VAddr PeekStaticBuffer(u8 buffer_id, size_t* data_size = nullptr) const {
|
||||
u32* static_buffer = cmdbuf + Kernel::kStaticBuffersOffset / sizeof(u32) + buffer_id * 2;
|
||||
if (data_size)
|
||||
*data_size = StaticBufferDescInfo{static_buffer[0]}.size;
|
||||
return static_buffer[1];
|
||||
}
|
||||
};
|
||||
|
||||
class RequestBuilder : public RequestHelperBase {
|
||||
|
@ -122,7 +110,6 @@ public:
|
|||
template <typename... O>
|
||||
void PushMoveObjects(Kernel::SharedPtr<O>... pointers);
|
||||
|
||||
[[deprecated]] void PushStaticBuffer(VAddr buffer_vaddr, size_t size, u8 buffer_id);
|
||||
void PushStaticBuffer(const std::vector<u8>& buffer, u8 buffer_id);
|
||||
|
||||
/// Pushes an HLE MappedBuffer interface back to unmapped the buffer.
|
||||
|
@ -204,11 +191,6 @@ inline void RequestBuilder::PushMoveObjects(Kernel::SharedPtr<O>... pointers) {
|
|||
PushMoveHLEHandles(context->AddOutgoingHandle(std::move(pointers))...);
|
||||
}
|
||||
|
||||
inline void RequestBuilder::PushStaticBuffer(VAddr buffer_vaddr, size_t size, u8 buffer_id) {
|
||||
Push(StaticBufferDesc(size, buffer_id));
|
||||
Push(buffer_vaddr);
|
||||
}
|
||||
|
||||
inline void RequestBuilder::PushStaticBuffer(const std::vector<u8>& buffer, u8 buffer_id) {
|
||||
ASSERT_MSG(buffer_id < MAX_STATIC_BUFFERS, "Invalid static buffer id");
|
||||
|
||||
|
@ -309,18 +291,6 @@ public:
|
|||
|
||||
u32 PopPID();
|
||||
|
||||
/**
|
||||
* @brief Pops the static buffer vaddr
|
||||
* @return The virtual address of the buffer
|
||||
* @param[out] data_size If non-null, the pointed value will be set to the size of the data
|
||||
*
|
||||
* In real services, static buffers must be set up before any IPC request using those is sent.
|
||||
* It is the duty of the process (usually services) to allocate and set up the receiving static
|
||||
* buffer information. Our HLE services do not need to set up the buffers beforehand.
|
||||
* Please note that the setup uses virtual addresses.
|
||||
*/
|
||||
[[deprecated]] VAddr PopStaticBuffer(size_t* data_size);
|
||||
|
||||
/**
|
||||
* @brief Pops a static buffer from the IPC request buffer.
|
||||
* @return The buffer that was copied from the IPC request originator.
|
||||
|
@ -467,14 +437,6 @@ inline u32 RequestParser::PopPID() {
|
|||
return Pop<u32>();
|
||||
}
|
||||
|
||||
inline VAddr RequestParser::PopStaticBuffer(size_t* data_size) {
|
||||
const u32 sbuffer_descriptor = Pop<u32>();
|
||||
StaticBufferDescInfo bufferInfo{sbuffer_descriptor};
|
||||
if (data_size != nullptr)
|
||||
*data_size = bufferInfo.size;
|
||||
return Pop<VAddr>();
|
||||
}
|
||||
|
||||
inline const std::vector<u8>& RequestParser::PopStaticBuffer() {
|
||||
const u32 sbuffer_descriptor = Pop<u32>();
|
||||
// Pop the address from the incoming request buffer
|
||||
|
|
|
@ -2,173 +2,160 @@
|
|||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/string_util.h"
|
||||
#include "core/hle/ipc.h"
|
||||
#include "core/hle/ipc_helpers.h"
|
||||
#include "core/hle/result.h"
|
||||
#include "core/hle/service/frd/frd.h"
|
||||
#include "core/hle/service/frd/frd_a.h"
|
||||
#include "core/hle/service/frd/frd_u.h"
|
||||
#include "core/hle/service/service.h"
|
||||
#include "core/memory.h"
|
||||
|
||||
namespace Service {
|
||||
namespace FRD {
|
||||
|
||||
static FriendKey my_friend_key = {0, 0, 0ull};
|
||||
static MyPresence my_presence = {};
|
||||
Module::Interface::Interface(std::shared_ptr<Module> frd, const char* name, u32 max_session)
|
||||
: ServiceFramework(name, max_session), frd(std::move(frd)) {}
|
||||
|
||||
void GetMyPresence(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
Module::Interface::~Interface() = default;
|
||||
|
||||
u32 shifted_out_size = cmd_buff[64];
|
||||
u32 my_presence_addr = cmd_buff[65];
|
||||
void Module::Interface::GetMyPresence(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp(ctx, 0x08, 0, 0);
|
||||
|
||||
ASSERT(shifted_out_size == ((sizeof(MyPresence) << 14) | 2));
|
||||
std::vector<u8> buffer(sizeof(MyPresence));
|
||||
std::memcpy(buffer.data(), &frd->my_presence, buffer.size());
|
||||
|
||||
Memory::WriteBlock(my_presence_addr, &my_presence, sizeof(MyPresence));
|
||||
|
||||
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushStaticBuffer(buffer, 0);
|
||||
|
||||
LOG_WARNING(Service_FRD, "(STUBBED) called");
|
||||
}
|
||||
|
||||
void GetFriendKeyList(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
void Module::Interface::GetFriendKeyList(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp(ctx, 0x11, 2, 0);
|
||||
u32 unknown = rp.Pop<u32>();
|
||||
u32 frd_count = rp.Pop<u32>();
|
||||
|
||||
u32 unknown = cmd_buff[1];
|
||||
u32 frd_count = cmd_buff[2];
|
||||
u32 frd_key_addr = cmd_buff[65];
|
||||
std::vector<u8> buffer(sizeof(FriendKey) * frd_count, 0);
|
||||
|
||||
FriendKey zero_key = {};
|
||||
for (u32 i = 0; i < frd_count; ++i) {
|
||||
Memory::WriteBlock(frd_key_addr + i * sizeof(FriendKey), &zero_key, sizeof(FriendKey));
|
||||
}
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.Push<u32>(0); // 0 friends
|
||||
rb.PushStaticBuffer(buffer, 0);
|
||||
|
||||
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
|
||||
cmd_buff[2] = 0; // 0 friends
|
||||
LOG_WARNING(Service_FRD, "(STUBBED) called, unknown=%d, frd_count=%d, frd_key_addr=0x%08X",
|
||||
unknown, frd_count, frd_key_addr);
|
||||
LOG_WARNING(Service_FRD, "(STUBBED) called, unknown=%u, frd_count=%u", unknown, frd_count);
|
||||
}
|
||||
|
||||
void GetFriendProfile(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
void Module::Interface::GetFriendProfile(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp(ctx, 0x15, 1, 2);
|
||||
u32 count = rp.Pop<u32>();
|
||||
std::vector<u8> frd_keys = rp.PopStaticBuffer();
|
||||
ASSERT(frd_keys.size() == count * sizeof(FriendKey));
|
||||
|
||||
u32 count = cmd_buff[1];
|
||||
u32 frd_key_addr = cmd_buff[3];
|
||||
u32 profiles_addr = cmd_buff[65];
|
||||
std::vector<u8> buffer(sizeof(Profile) * count, 0);
|
||||
|
||||
Profile zero_profile = {};
|
||||
for (u32 i = 0; i < count; ++i) {
|
||||
Memory::WriteBlock(profiles_addr + i * sizeof(Profile), &zero_profile, sizeof(Profile));
|
||||
}
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushStaticBuffer(buffer, 0);
|
||||
|
||||
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
|
||||
LOG_WARNING(Service_FRD,
|
||||
"(STUBBED) called, count=%d, frd_key_addr=0x%08X, profiles_addr=0x%08X", count,
|
||||
frd_key_addr, profiles_addr);
|
||||
LOG_WARNING(Service_FRD, "(STUBBED) called, count=%u", count);
|
||||
}
|
||||
|
||||
void GetFriendAttributeFlags(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
void Module::Interface::GetFriendAttributeFlags(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp(ctx, 0x17, 1, 2);
|
||||
u32 count = rp.Pop<u32>();
|
||||
std::vector<u8> frd_keys = rp.PopStaticBuffer();
|
||||
ASSERT(frd_keys.size() == count * sizeof(FriendKey));
|
||||
|
||||
u32 count = cmd_buff[1];
|
||||
u32 frd_key_addr = cmd_buff[3];
|
||||
u32 attr_flags_addr = cmd_buff[65];
|
||||
// TODO:(mailwl) figure out AttributeFlag size and zero all buffer. Assume 1 byte
|
||||
std::vector<u8> buffer(1 * count, 0);
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushStaticBuffer(buffer, 0);
|
||||
|
||||
for (u32 i = 0; i < count; ++i) {
|
||||
// TODO:(mailwl) figure out AttributeFlag size and zero all buffer. Assume 1 byte
|
||||
Memory::Write8(attr_flags_addr + i, 0);
|
||||
}
|
||||
|
||||
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
|
||||
LOG_WARNING(Service_FRD,
|
||||
"(STUBBED) called, count=%d, frd_key_addr=0x%08X, attr_flags_addr=0x%08X", count,
|
||||
frd_key_addr, attr_flags_addr);
|
||||
LOG_WARNING(Service_FRD, "(STUBBED) called, count=%u", count);
|
||||
}
|
||||
|
||||
void GetMyFriendKey(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
void Module::Interface::GetMyFriendKey(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp(ctx, 0x5, 0, 0);
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushRaw(frd->my_friend_key);
|
||||
|
||||
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
|
||||
std::memcpy(&cmd_buff[2], &my_friend_key, sizeof(FriendKey));
|
||||
LOG_WARNING(Service_FRD, "(STUBBED) called");
|
||||
}
|
||||
|
||||
void GetMyScreenName(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
void Module::Interface::GetMyScreenName(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp(ctx, 0x9, 0, 0);
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(7, 0);
|
||||
|
||||
struct ScreenName {
|
||||
std::array<char16_t, 12> name;
|
||||
};
|
||||
|
||||
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
|
||||
// TODO: (mailwl) get the name from config
|
||||
Common::UTF8ToUTF16("Citra").copy(reinterpret_cast<char16_t*>(&cmd_buff[2]), 11);
|
||||
ScreenName screen_name{u"Citra"};
|
||||
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushRaw(screen_name);
|
||||
|
||||
LOG_WARNING(Service_FRD, "(STUBBED) called");
|
||||
}
|
||||
|
||||
void UnscrambleLocalFriendCode(Service::Interface* self) {
|
||||
void Module::Interface::UnscrambleLocalFriendCode(Kernel::HLERequestContext& ctx) {
|
||||
const size_t scrambled_friend_code_size = 12;
|
||||
const size_t friend_code_size = 8;
|
||||
|
||||
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1C, 1, 2);
|
||||
IPC::RequestParser rp(ctx, 0x1C, 1, 2);
|
||||
const u32 friend_code_count = rp.Pop<u32>();
|
||||
size_t in_buffer_size;
|
||||
const VAddr scrambled_friend_codes = rp.PopStaticBuffer(&in_buffer_size);
|
||||
ASSERT_MSG(in_buffer_size == (friend_code_count * scrambled_friend_code_size),
|
||||
std::vector<u8> scrambled_friend_codes = rp.PopStaticBuffer();
|
||||
ASSERT_MSG(scrambled_friend_codes.size() == (friend_code_count * scrambled_friend_code_size),
|
||||
"Wrong input buffer size");
|
||||
|
||||
size_t out_buffer_size;
|
||||
VAddr unscrambled_friend_codes = rp.PeekStaticBuffer(0, &out_buffer_size);
|
||||
ASSERT_MSG(out_buffer_size == (friend_code_count * friend_code_size),
|
||||
"Wrong output buffer size");
|
||||
|
||||
for (u32 current = 0; current < friend_code_count; ++current) {
|
||||
// TODO(B3N30): Unscramble the codes and compare them against the friend list
|
||||
// Only write 0 if the code isn't in friend list, otherwise write the
|
||||
// unscrambled one
|
||||
//
|
||||
// Code for unscrambling (should be compared to HW):
|
||||
// std::array<u16, 6> scambled_friend_code;
|
||||
// Memory::ReadBlock(scrambled_friend_codes+(current*scrambled_friend_code_size),
|
||||
// scambled_friend_code.data(), scrambled_friend_code_size); std::array<u16, 4>
|
||||
// unscrambled_friend_code; unscrambled_friend_code[0] = scambled_friend_code[0] ^
|
||||
// scambled_friend_code[5]; unscrambled_friend_code[1] = scambled_friend_code[1] ^
|
||||
// scambled_friend_code[5]; unscrambled_friend_code[2] = scambled_friend_code[2] ^
|
||||
// scambled_friend_code[5]; unscrambled_friend_code[3] = scambled_friend_code[3] ^
|
||||
// scambled_friend_code[5];
|
||||
|
||||
u64 result = 0ull;
|
||||
Memory::WriteBlock(unscrambled_friend_codes + (current * sizeof(result)), &result,
|
||||
sizeof(result));
|
||||
}
|
||||
std::vector<u8> unscrambled_friend_codes(friend_code_count * friend_code_size, 0);
|
||||
// TODO(B3N30): Unscramble the codes and compare them against the friend list
|
||||
// Only write 0 if the code isn't in friend list, otherwise write the
|
||||
// unscrambled one
|
||||
//
|
||||
// Code for unscrambling (should be compared to HW):
|
||||
// std::array<u16, 6> scambled_friend_code;
|
||||
// Memory::ReadBlock(scrambled_friend_codes+(current*scrambled_friend_code_size),
|
||||
// scambled_friend_code.data(), scrambled_friend_code_size); std::array<u16, 4>
|
||||
// unscrambled_friend_code; unscrambled_friend_code[0] = scambled_friend_code[0] ^
|
||||
// scambled_friend_code[5]; unscrambled_friend_code[1] = scambled_friend_code[1] ^
|
||||
// scambled_friend_code[5]; unscrambled_friend_code[2] = scambled_friend_code[2] ^
|
||||
// scambled_friend_code[5]; unscrambled_friend_code[3] = scambled_friend_code[3] ^
|
||||
// scambled_friend_code[5];
|
||||
|
||||
LOG_WARNING(Service_FRD, "(STUBBED) called");
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushStaticBuffer(unscrambled_friend_codes, out_buffer_size, 0);
|
||||
rb.PushStaticBuffer(unscrambled_friend_codes, 0);
|
||||
}
|
||||
|
||||
void SetClientSdkVersion(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
void Module::Interface::SetClientSdkVersion(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp(ctx, 0x32, 1, 2);
|
||||
u32 version = rp.Pop<u32>();
|
||||
rp.PopPID();
|
||||
|
||||
const u32 version = cmd_buff[1];
|
||||
|
||||
self->SetVersion(version);
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
|
||||
LOG_WARNING(Service_FRD, "(STUBBED) called, version: 0x%08X", version);
|
||||
|
||||
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
|
||||
}
|
||||
|
||||
void Init() {
|
||||
using namespace Kernel;
|
||||
Module::Module() = default;
|
||||
Module::~Module() = default;
|
||||
|
||||
AddService(new FRD_A_Interface);
|
||||
AddService(new FRD_U_Interface);
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
||||
auto frd = std::make_shared<Module>();
|
||||
std::make_shared<FRD_U>(frd)->InstallAsService(service_manager);
|
||||
std::make_shared<FRD_A>(frd)->InstallAsService(service_manager);
|
||||
}
|
||||
|
||||
void Shutdown() {}
|
||||
|
||||
} // namespace FRD
|
||||
|
||||
} // namespace Service
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Service {
|
||||
|
||||
|
@ -30,98 +32,114 @@ struct Profile {
|
|||
u32 unknown;
|
||||
};
|
||||
|
||||
/**
|
||||
* FRD::GetMyPresence service function
|
||||
* Inputs:
|
||||
* 64 : sizeof (MyPresence) << 14 | 2
|
||||
* 65 : Address of MyPresence structure
|
||||
* Outputs:
|
||||
* 1 : Result of function, 0 on success, otherwise error code
|
||||
*/
|
||||
void GetMyPresence(Service::Interface* self);
|
||||
class Module final {
|
||||
public:
|
||||
Module();
|
||||
~Module();
|
||||
|
||||
/**
|
||||
* FRD::GetFriendKeyList service function
|
||||
* Inputs:
|
||||
* 1 : Unknown
|
||||
* 2 : Max friends count
|
||||
* 65 : Address of FriendKey List
|
||||
* Outputs:
|
||||
* 1 : Result of function, 0 on success, otherwise error code
|
||||
* 2 : FriendKey count filled
|
||||
*/
|
||||
void GetFriendKeyList(Service::Interface* self);
|
||||
class Interface : public ServiceFramework<Interface> {
|
||||
public:
|
||||
Interface(std::shared_ptr<Module> frd, const char* name, u32 max_session);
|
||||
~Interface();
|
||||
|
||||
/**
|
||||
* FRD::GetFriendProfile service function
|
||||
* Inputs:
|
||||
* 1 : Friends count
|
||||
* 2 : Friends count << 18 | 2
|
||||
* 3 : Address of FriendKey List
|
||||
* 64 : (count * sizeof (Profile)) << 10 | 2
|
||||
* 65 : Address of Profiles List
|
||||
* Outputs:
|
||||
* 1 : Result of function, 0 on success, otherwise error code
|
||||
*/
|
||||
void GetFriendProfile(Service::Interface* self);
|
||||
protected:
|
||||
/**
|
||||
* FRD::GetMyPresence service function
|
||||
* Inputs:
|
||||
* 64 : sizeof (MyPresence) << 14 | 2
|
||||
* 65 : Address of MyPresence structure
|
||||
* Outputs:
|
||||
* 1 : Result of function, 0 on success, otherwise error code
|
||||
*/
|
||||
void GetMyPresence(Kernel::HLERequestContext& ctx);
|
||||
|
||||
/**
|
||||
* FRD::GetFriendAttributeFlags service function
|
||||
* Inputs:
|
||||
* 1 : Friends count
|
||||
* 2 : Friends count << 18 | 2
|
||||
* 3 : Address of FriendKey List
|
||||
* 65 : Address of AttributeFlags
|
||||
* Outputs:
|
||||
* 1 : Result of function, 0 on success, otherwise error code
|
||||
*/
|
||||
void GetFriendAttributeFlags(Service::Interface* self);
|
||||
/**
|
||||
* FRD::GetFriendKeyList service function
|
||||
* Inputs:
|
||||
* 1 : Unknown
|
||||
* 2 : Max friends count
|
||||
* 65 : Address of FriendKey List
|
||||
* Outputs:
|
||||
* 1 : Result of function, 0 on success, otherwise error code
|
||||
* 2 : FriendKey count filled
|
||||
*/
|
||||
void GetFriendKeyList(Kernel::HLERequestContext& ctx);
|
||||
|
||||
/**
|
||||
* FRD::GetMyFriendKey service function
|
||||
* Inputs:
|
||||
* none
|
||||
* Outputs:
|
||||
* 1 : Result of function, 0 on success, otherwise error code
|
||||
* 2-5 : FriendKey
|
||||
*/
|
||||
void GetMyFriendKey(Service::Interface* self);
|
||||
/**
|
||||
* FRD::GetFriendProfile service function
|
||||
* Inputs:
|
||||
* 1 : Friends count
|
||||
* 2 : Friends count << 18 | 2
|
||||
* 3 : Address of FriendKey List
|
||||
* 64 : (count * sizeof (Profile)) << 10 | 2
|
||||
* 65 : Address of Profiles List
|
||||
* Outputs:
|
||||
* 1 : Result of function, 0 on success, otherwise error code
|
||||
*/
|
||||
void GetFriendProfile(Kernel::HLERequestContext& ctx);
|
||||
|
||||
/**
|
||||
* FRD::GetMyScreenName service function
|
||||
* Outputs:
|
||||
* 1 : Result of function, 0 on success, otherwise error code
|
||||
* 2 : UTF16 encoded name (max 11 symbols)
|
||||
*/
|
||||
void GetMyScreenName(Service::Interface* self);
|
||||
/**
|
||||
* FRD::GetFriendAttributeFlags service function
|
||||
* Inputs:
|
||||
* 1 : Friends count
|
||||
* 2 : Friends count << 18 | 2
|
||||
* 3 : Address of FriendKey List
|
||||
* 65 : Address of AttributeFlags
|
||||
* Outputs:
|
||||
* 1 : Result of function, 0 on success, otherwise error code
|
||||
*/
|
||||
void GetFriendAttributeFlags(Kernel::HLERequestContext& ctx);
|
||||
|
||||
/**
|
||||
* FRD::UnscrambleLocalFriendCode service function
|
||||
* Inputs:
|
||||
* 1 : Friend code count
|
||||
* 2 : ((count * 12) << 14) | 0x402
|
||||
* 3 : Pointer to encoded friend codes. Each is 12 bytes large
|
||||
* 64 : ((count * 8) << 14) | 2
|
||||
* 65 : Pointer to write decoded local friend codes to. Each is 8 bytes large.
|
||||
* Outputs:
|
||||
* 1 : Result of function, 0 on success, otherwise error code
|
||||
*/
|
||||
void UnscrambleLocalFriendCode(Service::Interface* self);
|
||||
/**
|
||||
* FRD::GetMyFriendKey service function
|
||||
* Inputs:
|
||||
* none
|
||||
* Outputs:
|
||||
* 1 : Result of function, 0 on success, otherwise error code
|
||||
* 2-5 : FriendKey
|
||||
*/
|
||||
void GetMyFriendKey(Kernel::HLERequestContext& ctx);
|
||||
|
||||
/**
|
||||
* FRD::SetClientSdkVersion service function
|
||||
* Inputs:
|
||||
* 1 : Used SDK Version
|
||||
* Outputs:
|
||||
* 1 : Result of function, 0 on success, otherwise error code
|
||||
*/
|
||||
void SetClientSdkVersion(Service::Interface* self);
|
||||
/**
|
||||
* FRD::GetMyScreenName service function
|
||||
* Outputs:
|
||||
* 1 : Result of function, 0 on success, otherwise error code
|
||||
* 2 : UTF16 encoded name (max 11 symbols)
|
||||
*/
|
||||
void GetMyScreenName(Kernel::HLERequestContext& ctx);
|
||||
|
||||
/// Initialize FRD service(s)
|
||||
void Init();
|
||||
/**
|
||||
* FRD::UnscrambleLocalFriendCode service function
|
||||
* Inputs:
|
||||
* 1 : Friend code count
|
||||
* 2 : ((count * 12) << 14) | 0x402
|
||||
* 3 : Pointer to encoded friend codes. Each is 12 bytes large
|
||||
* 64 : ((count * 8) << 14) | 2
|
||||
* 65 : Pointer to write decoded local friend codes to. Each is 8 bytes large.
|
||||
* Outputs:
|
||||
* 1 : Result of function, 0 on success, otherwise error code
|
||||
*/
|
||||
void UnscrambleLocalFriendCode(Kernel::HLERequestContext& ctx);
|
||||
|
||||
/// Shutdown FRD service(s)
|
||||
void Shutdown();
|
||||
/**
|
||||
* FRD::SetClientSdkVersion service function
|
||||
* Inputs:
|
||||
* 1 : Used SDK Version
|
||||
* Outputs:
|
||||
* 1 : Result of function, 0 on success, otherwise error code
|
||||
*/
|
||||
void SetClientSdkVersion(Kernel::HLERequestContext& ctx);
|
||||
|
||||
private:
|
||||
std::shared_ptr<Module> frd;
|
||||
};
|
||||
|
||||
private:
|
||||
FriendKey my_friend_key = {0, 0, 0ull};
|
||||
MyPresence my_presence = {};
|
||||
};
|
||||
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager);
|
||||
|
||||
} // namespace FRD
|
||||
} // namespace Service
|
||||
|
|
|
@ -7,11 +7,63 @@
|
|||
namespace Service {
|
||||
namespace FRD {
|
||||
|
||||
// Empty arrays are illegal -- commented out until an entry is added.
|
||||
// const Interface::FunctionInfo FunctionTable[] = { };
|
||||
|
||||
FRD_A_Interface::FRD_A_Interface() {
|
||||
// Register(FunctionTable);
|
||||
FRD_A::FRD_A(std::shared_ptr<Module> frd) : Module::Interface(std::move(frd), "frd:a", 8) {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0x00010000, nullptr, "HasLoggedIn"},
|
||||
{0x00020000, nullptr, "IsOnline"},
|
||||
{0x00030000, nullptr, "Login"},
|
||||
{0x00040000, nullptr, "Logout"},
|
||||
{0x00050000, &FRD_A::GetMyFriendKey, "GetMyFriendKey"},
|
||||
{0x00060000, nullptr, "GetMyPreference"},
|
||||
{0x00070000, nullptr, "GetMyProfile"},
|
||||
{0x00080000, &FRD_A::GetMyPresence, "GetMyPresence"},
|
||||
{0x00090000, &FRD_A::GetMyScreenName, "GetMyScreenName"},
|
||||
{0x000A0000, nullptr, "GetMyMii"},
|
||||
{0x000B0000, nullptr, "GetMyLocalAccountId"},
|
||||
{0x000C0000, nullptr, "GetMyPlayingGame"},
|
||||
{0x000D0000, nullptr, "GetMyFavoriteGame"},
|
||||
{0x000E0000, nullptr, "GetMyNcPrincipalId"},
|
||||
{0x000F0000, nullptr, "GetMyComment"},
|
||||
{0x00100040, nullptr, "GetMyPassword"},
|
||||
{0x00110080, &FRD_A::GetFriendKeyList, "GetFriendKeyList"},
|
||||
{0x00120042, nullptr, "GetFriendPresence"},
|
||||
{0x00130142, nullptr, "GetFriendScreenName"},
|
||||
{0x00140044, nullptr, "GetFriendMii"},
|
||||
{0x00150042, &FRD_A::GetFriendProfile, "GetFriendProfile"},
|
||||
{0x00160042, nullptr, "GetFriendRelationship"},
|
||||
{0x00170042, &FRD_A::GetFriendAttributeFlags, "GetFriendAttributeFlags"},
|
||||
{0x00180044, nullptr, "GetFriendPlayingGame"},
|
||||
{0x00190042, nullptr, "GetFriendFavoriteGame"},
|
||||
{0x001A00C4, nullptr, "GetFriendInfo"},
|
||||
{0x001B0080, nullptr, "IsIncludedInFriendList"},
|
||||
{0x001C0042, &FRD_A::UnscrambleLocalFriendCode, "UnscrambleLocalFriendCode"},
|
||||
{0x001D0002, nullptr, "UpdateGameModeDescription"},
|
||||
{0x001E02C2, nullptr, "UpdateGameMode"},
|
||||
{0x001F0042, nullptr, "SendInvitation"},
|
||||
{0x00200002, nullptr, "AttachToEventNotification"},
|
||||
{0x00210040, nullptr, "SetNotificationMask"},
|
||||
{0x00220040, nullptr, "GetEventNotification"},
|
||||
{0x00230000, nullptr, "GetLastResponseResult"},
|
||||
{0x00240040, nullptr, "PrincipalIdToFriendCode"},
|
||||
{0x00250080, nullptr, "FriendCodeToPrincipalId"},
|
||||
{0x00260080, nullptr, "IsValidFriendCode"},
|
||||
{0x00270040, nullptr, "ResultToErrorCode"},
|
||||
{0x00280244, nullptr, "RequestGameAuthentication"},
|
||||
{0x00290000, nullptr, "GetGameAuthenticationData"},
|
||||
{0x002A0204, nullptr, "RequestServiceLocator"},
|
||||
{0x002B0000, nullptr, "GetServiceLocatorData"},
|
||||
{0x002C0002, nullptr, "DetectNatProperties"},
|
||||
{0x002D0000, nullptr, "GetNatProperties"},
|
||||
{0x002E0000, nullptr, "GetServerTimeInterval"},
|
||||
{0x002F0040, nullptr, "AllowHalfAwake"},
|
||||
{0x00300000, nullptr, "GetServerTypes"},
|
||||
{0x00310082, nullptr, "GetFriendComment"},
|
||||
{0x00320042, &FRD_A::SetClientSdkVersion, "SetClientSdkVersion"},
|
||||
{0x00330000, nullptr, "GetMyApproachContext"},
|
||||
{0x00340046, nullptr, "AddFriendWithApproach"},
|
||||
{0x00350082, nullptr, "DecryptApproachContext"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
} // namespace FRD
|
||||
|
|
|
@ -4,18 +4,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/service.h"
|
||||
#include "core/hle/service/frd/frd.h"
|
||||
|
||||
namespace Service {
|
||||
namespace FRD {
|
||||
|
||||
class FRD_A_Interface : public Service::Interface {
|
||||
class FRD_A final : public Module::Interface {
|
||||
public:
|
||||
FRD_A_Interface();
|
||||
|
||||
std::string GetPortName() const override {
|
||||
return "frd:a";
|
||||
}
|
||||
explicit FRD_A(std::shared_ptr<Module> frd);
|
||||
};
|
||||
|
||||
} // namespace FRD
|
||||
|
|
|
@ -2,70 +2,68 @@
|
|||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "core/hle/service/frd/frd.h"
|
||||
#include "core/hle/service/frd/frd_u.h"
|
||||
|
||||
namespace Service {
|
||||
namespace FRD {
|
||||
|
||||
const Interface::FunctionInfo FunctionTable[] = {
|
||||
{0x00010000, nullptr, "HasLoggedIn"},
|
||||
{0x00020000, nullptr, "IsOnline"},
|
||||
{0x00030000, nullptr, "Login"},
|
||||
{0x00040000, nullptr, "Logout"},
|
||||
{0x00050000, GetMyFriendKey, "GetMyFriendKey"},
|
||||
{0x00060000, nullptr, "GetMyPreference"},
|
||||
{0x00070000, nullptr, "GetMyProfile"},
|
||||
{0x00080000, GetMyPresence, "GetMyPresence"},
|
||||
{0x00090000, GetMyScreenName, "GetMyScreenName"},
|
||||
{0x000A0000, nullptr, "GetMyMii"},
|
||||
{0x000B0000, nullptr, "GetMyLocalAccountId"},
|
||||
{0x000C0000, nullptr, "GetMyPlayingGame"},
|
||||
{0x000D0000, nullptr, "GetMyFavoriteGame"},
|
||||
{0x000E0000, nullptr, "GetMyNcPrincipalId"},
|
||||
{0x000F0000, nullptr, "GetMyComment"},
|
||||
{0x00100040, nullptr, "GetMyPassword"},
|
||||
{0x00110080, GetFriendKeyList, "GetFriendKeyList"},
|
||||
{0x00120042, nullptr, "GetFriendPresence"},
|
||||
{0x00130142, nullptr, "GetFriendScreenName"},
|
||||
{0x00140044, nullptr, "GetFriendMii"},
|
||||
{0x00150042, GetFriendProfile, "GetFriendProfile"},
|
||||
{0x00160042, nullptr, "GetFriendRelationship"},
|
||||
{0x00170042, GetFriendAttributeFlags, "GetFriendAttributeFlags"},
|
||||
{0x00180044, nullptr, "GetFriendPlayingGame"},
|
||||
{0x00190042, nullptr, "GetFriendFavoriteGame"},
|
||||
{0x001A00C4, nullptr, "GetFriendInfo"},
|
||||
{0x001B0080, nullptr, "IsIncludedInFriendList"},
|
||||
{0x001C0042, UnscrambleLocalFriendCode, "UnscrambleLocalFriendCode"},
|
||||
{0x001D0002, nullptr, "UpdateGameModeDescription"},
|
||||
{0x001E02C2, nullptr, "UpdateGameMode"},
|
||||
{0x001F0042, nullptr, "SendInvitation"},
|
||||
{0x00200002, nullptr, "AttachToEventNotification"},
|
||||
{0x00210040, nullptr, "SetNotificationMask"},
|
||||
{0x00220040, nullptr, "GetEventNotification"},
|
||||
{0x00230000, nullptr, "GetLastResponseResult"},
|
||||
{0x00240040, nullptr, "PrincipalIdToFriendCode"},
|
||||
{0x00250080, nullptr, "FriendCodeToPrincipalId"},
|
||||
{0x00260080, nullptr, "IsValidFriendCode"},
|
||||
{0x00270040, nullptr, "ResultToErrorCode"},
|
||||
{0x00280244, nullptr, "RequestGameAuthentication"},
|
||||
{0x00290000, nullptr, "GetGameAuthenticationData"},
|
||||
{0x002A0204, nullptr, "RequestServiceLocator"},
|
||||
{0x002B0000, nullptr, "GetServiceLocatorData"},
|
||||
{0x002C0002, nullptr, "DetectNatProperties"},
|
||||
{0x002D0000, nullptr, "GetNatProperties"},
|
||||
{0x002E0000, nullptr, "GetServerTimeInterval"},
|
||||
{0x002F0040, nullptr, "AllowHalfAwake"},
|
||||
{0x00300000, nullptr, "GetServerTypes"},
|
||||
{0x00310082, nullptr, "GetFriendComment"},
|
||||
{0x00320042, SetClientSdkVersion, "SetClientSdkVersion"},
|
||||
{0x00330000, nullptr, "GetMyApproachContext"},
|
||||
{0x00340046, nullptr, "AddFriendWithApproach"},
|
||||
{0x00350082, nullptr, "DecryptApproachContext"},
|
||||
};
|
||||
|
||||
FRD_U_Interface::FRD_U_Interface() {
|
||||
Register(FunctionTable);
|
||||
FRD_U::FRD_U(std::shared_ptr<Module> frd) : Module::Interface(std::move(frd), "frd:u", 8) {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0x00010000, nullptr, "HasLoggedIn"},
|
||||
{0x00020000, nullptr, "IsOnline"},
|
||||
{0x00030000, nullptr, "Login"},
|
||||
{0x00040000, nullptr, "Logout"},
|
||||
{0x00050000, &FRD_U::GetMyFriendKey, "GetMyFriendKey"},
|
||||
{0x00060000, nullptr, "GetMyPreference"},
|
||||
{0x00070000, nullptr, "GetMyProfile"},
|
||||
{0x00080000, &FRD_U::GetMyPresence, "GetMyPresence"},
|
||||
{0x00090000, &FRD_U::GetMyScreenName, "GetMyScreenName"},
|
||||
{0x000A0000, nullptr, "GetMyMii"},
|
||||
{0x000B0000, nullptr, "GetMyLocalAccountId"},
|
||||
{0x000C0000, nullptr, "GetMyPlayingGame"},
|
||||
{0x000D0000, nullptr, "GetMyFavoriteGame"},
|
||||
{0x000E0000, nullptr, "GetMyNcPrincipalId"},
|
||||
{0x000F0000, nullptr, "GetMyComment"},
|
||||
{0x00100040, nullptr, "GetMyPassword"},
|
||||
{0x00110080, &FRD_U::GetFriendKeyList, "GetFriendKeyList"},
|
||||
{0x00120042, nullptr, "GetFriendPresence"},
|
||||
{0x00130142, nullptr, "GetFriendScreenName"},
|
||||
{0x00140044, nullptr, "GetFriendMii"},
|
||||
{0x00150042, &FRD_U::GetFriendProfile, "GetFriendProfile"},
|
||||
{0x00160042, nullptr, "GetFriendRelationship"},
|
||||
{0x00170042, &FRD_U::GetFriendAttributeFlags, "GetFriendAttributeFlags"},
|
||||
{0x00180044, nullptr, "GetFriendPlayingGame"},
|
||||
{0x00190042, nullptr, "GetFriendFavoriteGame"},
|
||||
{0x001A00C4, nullptr, "GetFriendInfo"},
|
||||
{0x001B0080, nullptr, "IsIncludedInFriendList"},
|
||||
{0x001C0042, &FRD_U::UnscrambleLocalFriendCode, "UnscrambleLocalFriendCode"},
|
||||
{0x001D0002, nullptr, "UpdateGameModeDescription"},
|
||||
{0x001E02C2, nullptr, "UpdateGameMode"},
|
||||
{0x001F0042, nullptr, "SendInvitation"},
|
||||
{0x00200002, nullptr, "AttachToEventNotification"},
|
||||
{0x00210040, nullptr, "SetNotificationMask"},
|
||||
{0x00220040, nullptr, "GetEventNotification"},
|
||||
{0x00230000, nullptr, "GetLastResponseResult"},
|
||||
{0x00240040, nullptr, "PrincipalIdToFriendCode"},
|
||||
{0x00250080, nullptr, "FriendCodeToPrincipalId"},
|
||||
{0x00260080, nullptr, "IsValidFriendCode"},
|
||||
{0x00270040, nullptr, "ResultToErrorCode"},
|
||||
{0x00280244, nullptr, "RequestGameAuthentication"},
|
||||
{0x00290000, nullptr, "GetGameAuthenticationData"},
|
||||
{0x002A0204, nullptr, "RequestServiceLocator"},
|
||||
{0x002B0000, nullptr, "GetServiceLocatorData"},
|
||||
{0x002C0002, nullptr, "DetectNatProperties"},
|
||||
{0x002D0000, nullptr, "GetNatProperties"},
|
||||
{0x002E0000, nullptr, "GetServerTimeInterval"},
|
||||
{0x002F0040, nullptr, "AllowHalfAwake"},
|
||||
{0x00300000, nullptr, "GetServerTypes"},
|
||||
{0x00310082, nullptr, "GetFriendComment"},
|
||||
{0x00320042, &FRD_U::SetClientSdkVersion, "SetClientSdkVersion"},
|
||||
{0x00330000, nullptr, "GetMyApproachContext"},
|
||||
{0x00340046, nullptr, "AddFriendWithApproach"},
|
||||
{0x00350082, nullptr, "DecryptApproachContext"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
} // namespace FRD
|
||||
|
|
|
@ -4,18 +4,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/service.h"
|
||||
#include "core/hle/service/frd/frd.h"
|
||||
|
||||
namespace Service {
|
||||
namespace FRD {
|
||||
|
||||
class FRD_U_Interface : public Service::Interface {
|
||||
class FRD_U final : public Module::Interface {
|
||||
public:
|
||||
FRD_U_Interface();
|
||||
|
||||
std::string GetPortName() const override {
|
||||
return "frd:u";
|
||||
}
|
||||
explicit FRD_U(std::shared_ptr<Module> frd);
|
||||
};
|
||||
|
||||
} // namespace FRD
|
||||
|
|
|
@ -244,7 +244,7 @@ void Init() {
|
|||
CECD::Init();
|
||||
CFG::Init();
|
||||
DLP::Init();
|
||||
FRD::Init();
|
||||
FRD::InstallInterfaces(*SM::g_service_manager);
|
||||
GSP::InstallInterfaces(*SM::g_service_manager);
|
||||
HID::InstallInterfaces(*SM::g_service_manager);
|
||||
IR::InstallInterfaces(*SM::g_service_manager);
|
||||
|
@ -274,7 +274,6 @@ void Shutdown() {
|
|||
NFC::Shutdown();
|
||||
NEWS::Shutdown();
|
||||
NDM::Shutdown();
|
||||
FRD::Shutdown();
|
||||
DLP::Shutdown();
|
||||
CFG::Shutdown();
|
||||
CECD::Shutdown();
|
||||
|
|
Loading…
Reference in a new issue