| 26 | } |
| 27 | |
| 28 | Result srvInit(void) |
| 29 | { |
| 30 | Result rc = 0; |
| 31 | |
| 32 | if (AtomicPostIncrement(&srvRefCount)) return 0; |
| 33 | |
| 34 | if(GET_VERSION_MINOR(osGetKernelVersion()) < 39 && *srvPmGetSessionHandle() != 0) |
| 35 | rc = svcDuplicateHandle(&srvHandle, *srvPmGetSessionHandle()); // Prior to system version 7.0 srv:pm was a superset of srv: |
| 36 | else |
| 37 | rc = svcConnectToPort(&srvHandle, "srv:"); |
| 38 | |
| 39 | if (R_SUCCEEDED(rc)) |
| 40 | rc = srvRegisterClient(); |
| 41 | else |
| 42 | // Prior to system version 11.0, the kernel filled the resulting handle with junk in case of failure |
| 43 | srvHandle = 0; |
| 44 | |
| 45 | if (R_FAILED(rc)) srvExit(); |
| 46 | return rc; |
| 47 | } |
| 48 | |
| 49 | void srvExit(void) |
| 50 | { |
no test coverage detected