Stratosphere: Fix smhax.

This commit is contained in:
Michael Scire 2018-04-22 01:13:36 -06:00
parent c8ef305880
commit 809090e40d
3 changed files with 18 additions and 8 deletions

View File

@ -53,11 +53,11 @@ int main(int argc, char **argv)
WaitableManager *server_manager = new WaitableManager(U64_MAX); WaitableManager *server_manager = new WaitableManager(U64_MAX);
/* Create sm:, (and thus allow things to register to it). */ /* Create sm:, (and thus allow things to register to it). */
server_manager->add_waitable(new ManagedPortServer<UserService>("sm:", 0x40)); server_manager->add_waitable(new ManagedPortServer<UserService>("dbg:", 0x40));
/* Create sm:m manually. */ /* Create sm:m manually. */
Handle smm_h; Handle smm_h;
if (R_FAILED(Registration::RegisterServiceForSelf(smEncodeName("sm:m"), 1, false, &smm_h))) { if (R_FAILED(Registration::RegisterServiceForSelf(smEncodeName("dbg:m"), 1, false, &smm_h))) {
/* TODO: Panic. */ /* TODO: Panic. */
} }

View File

@ -27,21 +27,32 @@ Result UserService::dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id,
std::tuple<Result> UserService::initialize(PidDescriptor pid) { std::tuple<Result> UserService::initialize(PidDescriptor pid) {
this->pid = pid.pid; this->pid = pid.pid;
this->has_initialized = true;
return std::make_tuple(0); return std::make_tuple(0);
} }
std::tuple<Result, MovedHandle> UserService::get_service(u64 service) { std::tuple<Result, MovedHandle> UserService::get_service(u64 service) {
Handle session_h = 0; Handle session_h = 0;
Result rc = Registration::GetServiceForPid(this->pid, service, &session_h); Result rc = 0x415;
if (this->has_initialized) {
rc = Registration::GetServiceForPid(this->pid, service, &session_h);
}
return std::make_tuple(rc, MovedHandle{session_h}); return std::make_tuple(rc, MovedHandle{session_h});
} }
std::tuple<Result, MovedHandle> UserService::register_service(u64 service, u8 is_light, u32 max_sessions) { std::tuple<Result, MovedHandle> UserService::register_service(u64 service, u8 is_light, u32 max_sessions) {
Handle service_h = 0; Handle service_h = 0;
Result rc = Registration::RegisterServiceForPid(this->pid, service, max_sessions, is_light != 0, &service_h); Result rc = 0x415;
if (this->has_initialized) {
rc = Registration::RegisterServiceForPid(this->pid, service, max_sessions, is_light != 0, &service_h);
}
return std::make_tuple(rc, MovedHandle{service_h}); return std::make_tuple(rc, MovedHandle{service_h});
} }
std::tuple<Result> UserService::unregister_service(u64 service) { std::tuple<Result> UserService::unregister_service(u64 service) {
return std::make_tuple(Registration::UnregisterServiceForPid(this->pid, service)); Result rc = 0x415;
if (this->has_initialized) {
rc = Registration::UnregisterServiceForPid(this->pid, service);
}
return std::make_tuple(rc);
} }

View File

@ -11,12 +11,11 @@ enum UserServiceCmd {
class UserService : IServiceObject { class UserService : IServiceObject {
u64 pid; u64 pid;
bool has_initialized;
public: public:
Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size);
UserService() { UserService() : pid(U64_MAX), has_initialized(false) { }
this->pid = U64_MAX;
}
private: private:
/* Actual commands. */ /* Actual commands. */