Return a stub service in the event that a service interface is not implemented, instead of reporting to the caller that GetServiceHandle itself is unimplemented (which games seem to dislike).

This commit is contained in:
Kevin Hartman 2015-02-17 01:10:11 -08:00
parent a78b8b1bc4
commit b4700444a2
3 changed files with 11 additions and 1 deletions

View File

@ -57,6 +57,8 @@ namespace Service {
std::unordered_map<std::string, Kernel::SharedPtr<Interface>> g_kernel_named_ports; std::unordered_map<std::string, Kernel::SharedPtr<Interface>> g_kernel_named_ports;
std::unordered_map<std::string, Kernel::SharedPtr<Interface>> g_srv_services; std::unordered_map<std::string, Kernel::SharedPtr<Interface>> g_srv_services;
Interface g_stub_service;
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// Module interface // Module interface

View File

@ -119,5 +119,7 @@ void Shutdown();
extern std::unordered_map<std::string, Kernel::SharedPtr<Interface>> g_kernel_named_ports; extern std::unordered_map<std::string, Kernel::SharedPtr<Interface>> g_kernel_named_ports;
/// Map of services registered with the "srv:" service, retrieved using GetServiceHandle. /// Map of services registered with the "srv:" service, retrieved using GetServiceHandle.
extern std::unordered_map<std::string, Kernel::SharedPtr<Interface>> g_srv_services; extern std::unordered_map<std::string, Kernel::SharedPtr<Interface>> g_srv_services;
/// Returned to callers when the requested service is not yet implemented
extern Interface g_stub_service;
} // namespace } // namespace

View File

@ -42,8 +42,14 @@ static void GetServiceHandle(Service::Interface* self) {
LOG_TRACE(Service_SRV, "called port=%s, handle=0x%08X", port_name.c_str(), cmd_buff[3]); LOG_TRACE(Service_SRV, "called port=%s, handle=0x%08X", port_name.c_str(), cmd_buff[3]);
} else { } else {
LOG_ERROR(Service_SRV, "(UNIMPLEMENTED) called port=%s", port_name.c_str()); LOG_ERROR(Service_SRV, "(UNIMPLEMENTED) called port=%s", port_name.c_str());
res = UnimplementedFunction(ErrorModule::SRV);
// Note: developers should add the corresponding service interface implementation when this is hit
UNIMPLEMENTED();
// Return the stubbed (empty) service so that applications can continue
cmd_buff[3] = Kernel::g_handle_table.Create(&Service::g_stub_service).MoveFrom();
} }
cmd_buff[1] = res.raw; cmd_buff[1] = res.raw;
} }