IApplicationFunctions.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. using LibHac;
  2. using LibHac.Account;
  3. using LibHac.Common;
  4. using LibHac.Fs;
  5. using LibHac.Ns;
  6. using Ryujinx.Common;
  7. using Ryujinx.Common.Logging;
  8. using Ryujinx.HLE.HOS.Ipc;
  9. using Ryujinx.HLE.HOS.Kernel.Common;
  10. using Ryujinx.HLE.HOS.Kernel.Memory;
  11. using Ryujinx.HLE.HOS.Kernel.Threading;
  12. using Ryujinx.HLE.HOS.Services.Am.AppletAE.Storage;
  13. using Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.ApplicationProxy.Types;
  14. using Ryujinx.HLE.HOS.Services.Sdb.Pdm.QueryService;
  15. using Ryujinx.HLE.HOS.SystemState;
  16. using System;
  17. using System.Numerics;
  18. using static LibHac.Fs.ApplicationSaveDataManagement;
  19. using AccountUid = Ryujinx.HLE.HOS.Services.Account.Acc.UserId;
  20. using ApplicationId = LibHac.Ncm.ApplicationId;
  21. namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.ApplicationProxy
  22. {
  23. class IApplicationFunctions : IpcService
  24. {
  25. private ulong _defaultSaveDataSize = 200000000;
  26. private ulong _defaultJournalSaveDataSize = 200000000;
  27. private KEvent _gpuErrorDetectedSystemEvent;
  28. private KEvent _friendInvitationStorageChannelEvent;
  29. private KEvent _notificationStorageChannelEvent;
  30. private KEvent _healthWarningDisappearedSystemEvent;
  31. private int _gpuErrorDetectedSystemEventHandle;
  32. private int _friendInvitationStorageChannelEventHandle;
  33. private int _notificationStorageChannelEventHandle;
  34. private int _healthWarningDisappearedSystemEventHandle;
  35. public IApplicationFunctions(Horizon system)
  36. {
  37. // TODO: Find where they are signaled.
  38. _gpuErrorDetectedSystemEvent = new KEvent(system.KernelContext);
  39. _friendInvitationStorageChannelEvent = new KEvent(system.KernelContext);
  40. _notificationStorageChannelEvent = new KEvent(system.KernelContext);
  41. _healthWarningDisappearedSystemEvent = new KEvent(system.KernelContext);
  42. }
  43. [CommandHipc(1)]
  44. // PopLaunchParameter(LaunchParameterKind kind) -> object<nn::am::service::IStorage>
  45. public ResultCode PopLaunchParameter(ServiceCtx context)
  46. {
  47. LaunchParameterKind kind = (LaunchParameterKind)context.RequestData.ReadUInt32();
  48. byte[] storageData;
  49. switch (kind)
  50. {
  51. case LaunchParameterKind.UserChannel:
  52. storageData = context.Device.UserChannelPersistence.Pop();
  53. break;
  54. case LaunchParameterKind.PreselectedUser:
  55. // Only the first 0x18 bytes of the Data seems to be actually used.
  56. storageData = StorageHelper.MakeLaunchParams(context.Device.System.AccountManager.LastOpenedUser);
  57. break;
  58. case LaunchParameterKind.Unknown:
  59. throw new NotImplementedException("Unknown LaunchParameterKind.");
  60. default:
  61. return ResultCode.ObjectInvalid;
  62. }
  63. if (storageData == null)
  64. {
  65. return ResultCode.NotAvailable;
  66. }
  67. MakeObject(context, new AppletAE.IStorage(storageData));
  68. return ResultCode.Success;
  69. }
  70. [CommandHipc(20)]
  71. // EnsureSaveData(nn::account::Uid) -> u64
  72. public ResultCode EnsureSaveData(ServiceCtx context)
  73. {
  74. Uid userId = context.RequestData.ReadStruct<AccountUid>().ToLibHacUid();
  75. ApplicationId applicationId = new ApplicationId(context.Process.TitleId);
  76. BlitStruct<ApplicationControlProperty> controlHolder = context.Device.Application.ControlData;
  77. ref ApplicationControlProperty control = ref controlHolder.Value;
  78. if (LibHac.Utilities.IsEmpty(controlHolder.ByteSpan))
  79. {
  80. // If the current application doesn't have a loaded control property, create a dummy one
  81. // and set the savedata sizes so a user savedata will be created.
  82. control = ref new BlitStruct<ApplicationControlProperty>(1).Value;
  83. // The set sizes don't actually matter as long as they're non-zero because we use directory savedata.
  84. control.UserAccountSaveDataSize = 0x4000;
  85. control.UserAccountSaveDataJournalSize = 0x4000;
  86. Logger.Warning?.Print(LogClass.ServiceAm,
  87. "No control file was found for this game. Using a dummy one instead. This may cause inaccuracies in some games.");
  88. }
  89. Result result = EnsureApplicationSaveData(context.Device.FileSystem.FsClient, out long requiredSize, applicationId, ref control, ref userId);
  90. context.ResponseData.Write(requiredSize);
  91. return (ResultCode)result.Value;
  92. }
  93. [CommandHipc(21)]
  94. // GetDesiredLanguage() -> nn::settings::LanguageCode
  95. public ResultCode GetDesiredLanguage(ServiceCtx context)
  96. {
  97. // This seems to be calling ns:am GetApplicationDesiredLanguage followed by ConvertApplicationLanguageToLanguageCode
  98. // Calls are from a IReadOnlyApplicationControlDataInterface object
  99. // ConvertApplicationLanguageToLanguageCode compares language code strings and returns the index
  100. // TODO: When above calls are implemented, switch to using ns:am
  101. long desiredLanguageCode = context.Device.System.State.DesiredLanguageCode;
  102. int supportedLanguages = (int)context.Device.Application.ControlData.Value.SupportedLanguages;
  103. int firstSupported = BitOperations.TrailingZeroCount(supportedLanguages);
  104. if (firstSupported > (int)SystemState.TitleLanguage.Chinese)
  105. {
  106. Logger.Warning?.Print(LogClass.ServiceAm, "Application has zero supported languages");
  107. context.ResponseData.Write(desiredLanguageCode);
  108. return ResultCode.Success;
  109. }
  110. // If desired language is not supported by application, use first supported language from TitleLanguage.
  111. // TODO: In the future, a GUI could enable user-specified search priority
  112. if (((1 << (int)context.Device.System.State.DesiredTitleLanguage) & supportedLanguages) == 0)
  113. {
  114. SystemLanguage newLanguage = Enum.Parse<SystemLanguage>(Enum.GetName(typeof(SystemState.TitleLanguage), firstSupported));
  115. desiredLanguageCode = SystemStateMgr.GetLanguageCode((int)newLanguage);
  116. Logger.Info?.Print(LogClass.ServiceAm, $"Application doesn't support configured language. Using {newLanguage}");
  117. }
  118. context.ResponseData.Write(desiredLanguageCode);
  119. return ResultCode.Success;
  120. }
  121. [CommandHipc(22)]
  122. // SetTerminateResult(u32)
  123. public ResultCode SetTerminateResult(ServiceCtx context)
  124. {
  125. Result result = new Result(context.RequestData.ReadUInt32());
  126. Logger.Info?.Print(LogClass.ServiceAm, $"Result = 0x{result.Value:x8} ({result.ToStringWithName()}).");
  127. return ResultCode.Success;
  128. }
  129. [CommandHipc(23)]
  130. // GetDisplayVersion() -> nn::oe::DisplayVersion
  131. public ResultCode GetDisplayVersion(ServiceCtx context)
  132. {
  133. // This should work as DisplayVersion U8Span always gives a 0x10 size byte array.
  134. // If an NACP isn't found, the buffer will be all '\0' which seems to be the correct implementation.
  135. context.ResponseData.Write(context.Device.Application.ControlData.Value.DisplayVersion);
  136. return ResultCode.Success;
  137. }
  138. [CommandHipc(25)] // 3.0.0+
  139. // ExtendSaveData(u8 save_data_type, nn::account::Uid, u64 save_size, u64 journal_size) -> u64 result_code
  140. public ResultCode ExtendSaveData(ServiceCtx context)
  141. {
  142. SaveDataType saveDataType = (SaveDataType)context.RequestData.ReadUInt64();
  143. Uid userId = context.RequestData.ReadStruct<AccountUid>().ToLibHacUid();
  144. ulong saveDataSize = context.RequestData.ReadUInt64();
  145. ulong journalSize = context.RequestData.ReadUInt64();
  146. // NOTE: Service calls nn::fs::ExtendApplicationSaveData.
  147. // Since LibHac currently doesn't support this method, we can stub it for now.
  148. _defaultSaveDataSize = saveDataSize;
  149. _defaultJournalSaveDataSize = journalSize;
  150. context.ResponseData.Write((uint)ResultCode.Success);
  151. Logger.Stub?.PrintStub(LogClass.ServiceAm, new { saveDataType, userId, saveDataSize, journalSize });
  152. return ResultCode.Success;
  153. }
  154. [CommandHipc(26)] // 3.0.0+
  155. // GetSaveDataSize(u8 save_data_type, nn::account::Uid) -> (u64 save_size, u64 journal_size)
  156. public ResultCode GetSaveDataSize(ServiceCtx context)
  157. {
  158. SaveDataType saveDataType = (SaveDataType)context.RequestData.ReadUInt64();
  159. Uid userId = context.RequestData.ReadStruct<AccountUid>().ToLibHacUid();
  160. // NOTE: Service calls nn::fs::FindSaveDataWithFilter with SaveDataType = 1 hardcoded.
  161. // Then it calls nn::fs::GetSaveDataAvailableSize and nn::fs::GetSaveDataJournalSize to get the sizes.
  162. // Since LibHac currently doesn't support the 2 last methods, we can hardcode the values to 200mb.
  163. context.ResponseData.Write(_defaultSaveDataSize);
  164. context.ResponseData.Write(_defaultJournalSaveDataSize);
  165. Logger.Stub?.PrintStub(LogClass.ServiceAm, new { saveDataType, userId });
  166. return ResultCode.Success;
  167. }
  168. [CommandHipc(30)]
  169. // BeginBlockingHomeButtonShortAndLongPressed()
  170. public ResultCode BeginBlockingHomeButtonShortAndLongPressed(ServiceCtx context)
  171. {
  172. // NOTE: This set two internal fields at offsets 0x89 and 0x8B to value 1 then it signals an internal event.
  173. Logger.Stub?.PrintStub(LogClass.ServiceAm);
  174. return ResultCode.Success;
  175. }
  176. [CommandHipc(31)]
  177. // EndBlockingHomeButtonShortAndLongPressed()
  178. public ResultCode EndBlockingHomeButtonShortAndLongPressed(ServiceCtx context)
  179. {
  180. // NOTE: This set two internal fields at offsets 0x89 and 0x8B to value 0 then it signals an internal event.
  181. Logger.Stub?.PrintStub(LogClass.ServiceAm);
  182. return ResultCode.Success;
  183. }
  184. [CommandHipc(32)] // 2.0.0+
  185. // BeginBlockingHomeButton(u64 nano_second)
  186. public ResultCode BeginBlockingHomeButton(ServiceCtx context)
  187. {
  188. ulong nanoSeconds = context.RequestData.ReadUInt64();
  189. // NOTE: This set two internal fields at offsets 0x89 to value 1 and 0x90 to value of "nanoSeconds" then it signals an internal event.
  190. Logger.Stub?.PrintStub(LogClass.ServiceAm, new { nanoSeconds });
  191. return ResultCode.Success;
  192. }
  193. [CommandHipc(33)] // 2.0.0+
  194. // EndBlockingHomeButton()
  195. public ResultCode EndBlockingHomeButton(ServiceCtx context)
  196. {
  197. // NOTE: This set two internal fields at offsets 0x89 and 0x90 to value 0 then it signals an internal event.
  198. Logger.Stub?.PrintStub(LogClass.ServiceAm);
  199. return ResultCode.Success;
  200. }
  201. [CommandHipc(40)]
  202. // NotifyRunning() -> b8
  203. public ResultCode NotifyRunning(ServiceCtx context)
  204. {
  205. context.ResponseData.Write(true);
  206. return ResultCode.Success;
  207. }
  208. [CommandHipc(50)] // 2.0.0+
  209. // GetPseudoDeviceId() -> nn::util::Uuid
  210. public ResultCode GetPseudoDeviceId(ServiceCtx context)
  211. {
  212. context.ResponseData.Write(0L);
  213. context.ResponseData.Write(0L);
  214. Logger.Stub?.PrintStub(LogClass.ServiceAm);
  215. return ResultCode.Success;
  216. }
  217. [CommandHipc(66)] // 3.0.0+
  218. // InitializeGamePlayRecording(u64, handle<copy>)
  219. public ResultCode InitializeGamePlayRecording(ServiceCtx context)
  220. {
  221. Logger.Stub?.PrintStub(LogClass.ServiceAm);
  222. return ResultCode.Success;
  223. }
  224. [CommandHipc(67)] // 3.0.0+
  225. // SetGamePlayRecordingState(u32)
  226. public ResultCode SetGamePlayRecordingState(ServiceCtx context)
  227. {
  228. int state = context.RequestData.ReadInt32();
  229. Logger.Stub?.PrintStub(LogClass.ServiceAm, new { state });
  230. return ResultCode.Success;
  231. }
  232. [CommandHipc(90)] // 4.0.0+
  233. // EnableApplicationCrashReport(u8)
  234. public ResultCode EnableApplicationCrashReport(ServiceCtx context)
  235. {
  236. bool applicationCrashReportEnabled = context.RequestData.ReadBoolean();
  237. Logger.Stub?.PrintStub(LogClass.ServiceAm, new { applicationCrashReportEnabled });
  238. return ResultCode.Success;
  239. }
  240. [CommandHipc(100)] // 5.0.0+
  241. // InitializeApplicationCopyrightFrameBuffer(s32 width, s32 height, handle<copy, transfer_memory> transfer_memory, u64 transfer_memory_size)
  242. public ResultCode InitializeApplicationCopyrightFrameBuffer(ServiceCtx context)
  243. {
  244. int width = context.RequestData.ReadInt32();
  245. int height = context.RequestData.ReadInt32();
  246. ulong transferMemorySize = context.RequestData.ReadUInt64();
  247. int transferMemoryHandle = context.Request.HandleDesc.ToCopy[0];
  248. ulong transferMemoryAddress = context.Process.HandleTable.GetObject<KTransferMemory>(transferMemoryHandle).Address;
  249. ResultCode resultCode = ResultCode.InvalidParameters;
  250. if (((transferMemorySize & 0x3FFFF) == 0) && width <= 1280 && height <= 720)
  251. {
  252. resultCode = InitializeApplicationCopyrightFrameBufferImpl(transferMemoryAddress, transferMemorySize, width, height);
  253. }
  254. if (transferMemoryHandle != 0)
  255. {
  256. context.Device.System.KernelContext.Syscall.CloseHandle(transferMemoryHandle);
  257. }
  258. return resultCode;
  259. }
  260. private ResultCode InitializeApplicationCopyrightFrameBufferImpl(ulong transferMemoryAddress, ulong transferMemorySize, int width, int height)
  261. {
  262. if ((transferMemorySize & 0x3FFFF) != 0)
  263. {
  264. return ResultCode.InvalidParameters;
  265. }
  266. ResultCode resultCode;
  267. // if (_copyrightBuffer == null)
  268. {
  269. // TODO: Initialize buffer and object.
  270. Logger.Stub?.PrintStub(LogClass.ServiceAm, new { transferMemoryAddress, transferMemorySize, width, height });
  271. resultCode = ResultCode.Success;
  272. }
  273. return resultCode;
  274. }
  275. [CommandHipc(101)] // 5.0.0+
  276. // SetApplicationCopyrightImage(buffer<bytes, 0x45> frame_buffer, s32 x, s32 y, s32 width, s32 height, s32 window_origin_mode)
  277. public ResultCode SetApplicationCopyrightImage(ServiceCtx context)
  278. {
  279. ulong frameBufferPos = context.Request.SendBuff[0].Position;
  280. ulong frameBufferSize = context.Request.SendBuff[0].Size;
  281. int x = context.RequestData.ReadInt32();
  282. int y = context.RequestData.ReadInt32();
  283. int width = context.RequestData.ReadInt32();
  284. int height = context.RequestData.ReadInt32();
  285. uint windowOriginMode = context.RequestData.ReadUInt32();
  286. ResultCode resultCode = ResultCode.InvalidParameters;
  287. if (((y | x) >= 0) && width >= 1 && height >= 1)
  288. {
  289. ResultCode result = SetApplicationCopyrightImageImpl(x, y, width, height, frameBufferPos, frameBufferSize, windowOriginMode);
  290. if (result != ResultCode.Success)
  291. {
  292. resultCode = result;
  293. }
  294. else
  295. {
  296. resultCode = ResultCode.Success;
  297. }
  298. }
  299. Logger.Stub?.PrintStub(LogClass.ServiceAm, new { frameBufferPos, frameBufferSize, x, y, width, height, windowOriginMode });
  300. return resultCode;
  301. }
  302. private ResultCode SetApplicationCopyrightImageImpl(int x, int y, int width, int height, ulong frameBufferPos, ulong frameBufferSize, uint windowOriginMode)
  303. {
  304. /*
  305. if (_copyrightBuffer == null)
  306. {
  307. return ResultCode.NullCopyrightObject;
  308. }
  309. */
  310. Logger.Stub?.PrintStub(LogClass.ServiceAm, new { x, y, width, height, frameBufferPos, frameBufferSize, windowOriginMode });
  311. return ResultCode.Success;
  312. }
  313. [CommandHipc(102)] // 5.0.0+
  314. // SetApplicationCopyrightVisibility(bool visible)
  315. public ResultCode SetApplicationCopyrightVisibility(ServiceCtx context)
  316. {
  317. bool visible = context.RequestData.ReadBoolean();
  318. Logger.Stub?.PrintStub(LogClass.ServiceAm, new { visible });
  319. // NOTE: It sets an internal field and return ResultCode.Success in all case.
  320. return ResultCode.Success;
  321. }
  322. [CommandHipc(110)] // 5.0.0+
  323. // QueryApplicationPlayStatistics(buffer<bytes, 5> title_id_list) -> (buffer<bytes, 6> entries, s32 entries_count)
  324. public ResultCode QueryApplicationPlayStatistics(ServiceCtx context)
  325. {
  326. // TODO: Call pdm:qry cmd 13 when IPC call between services will be implemented.
  327. return (ResultCode)QueryPlayStatisticsManager.GetPlayStatistics(context);
  328. }
  329. [CommandHipc(111)] // 6.0.0+
  330. // QueryApplicationPlayStatisticsByUid(nn::account::Uid, buffer<bytes, 5> title_id_list) -> (buffer<bytes, 6> entries, s32 entries_count)
  331. public ResultCode QueryApplicationPlayStatisticsByUid(ServiceCtx context)
  332. {
  333. // TODO: Call pdm:qry cmd 16 when IPC call between services will be implemented.
  334. return (ResultCode)QueryPlayStatisticsManager.GetPlayStatistics(context, true);
  335. }
  336. [CommandHipc(120)] // 5.0.0+
  337. // ExecuteProgram(ProgramSpecifyKind kind, u64 value)
  338. public ResultCode ExecuteProgram(ServiceCtx context)
  339. {
  340. ProgramSpecifyKind kind = (ProgramSpecifyKind)context.RequestData.ReadUInt32();
  341. // padding
  342. context.RequestData.ReadUInt32();
  343. ulong value = context.RequestData.ReadUInt64();
  344. Logger.Stub?.PrintStub(LogClass.ServiceAm, new { kind, value });
  345. context.Device.UiHandler.ExecuteProgram(context.Device, kind, value);
  346. return ResultCode.Success;
  347. }
  348. [CommandHipc(121)] // 5.0.0+
  349. // ClearUserChannel()
  350. public ResultCode ClearUserChannel(ServiceCtx context)
  351. {
  352. context.Device.UserChannelPersistence.Clear();
  353. return ResultCode.Success;
  354. }
  355. [CommandHipc(122)] // 5.0.0+
  356. // UnpopToUserChannel(object<nn::am::service::IStorage> input_storage)
  357. public ResultCode UnpopToUserChannel(ServiceCtx context)
  358. {
  359. AppletAE.IStorage data = GetObject<AppletAE.IStorage>(context, 0);
  360. context.Device.UserChannelPersistence.Push(data.Data);
  361. return ResultCode.Success;
  362. }
  363. [CommandHipc(123)] // 5.0.0+
  364. // GetPreviousProgramIndex() -> s32 program_index
  365. public ResultCode GetPreviousProgramIndex(ServiceCtx context)
  366. {
  367. int previousProgramIndex = context.Device.UserChannelPersistence.PreviousIndex;
  368. context.ResponseData.Write(previousProgramIndex);
  369. Logger.Stub?.PrintStub(LogClass.ServiceAm, new { previousProgramIndex });
  370. return ResultCode.Success;
  371. }
  372. [CommandHipc(130)] // 8.0.0+
  373. // GetGpuErrorDetectedSystemEvent() -> handle<copy>
  374. public ResultCode GetGpuErrorDetectedSystemEvent(ServiceCtx context)
  375. {
  376. if (_gpuErrorDetectedSystemEventHandle == 0)
  377. {
  378. if (context.Process.HandleTable.GenerateHandle(_gpuErrorDetectedSystemEvent.ReadableEvent, out _gpuErrorDetectedSystemEventHandle) != KernelResult.Success)
  379. {
  380. throw new InvalidOperationException("Out of handles!");
  381. }
  382. }
  383. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_gpuErrorDetectedSystemEventHandle);
  384. // NOTE: This is used by "sdk" NSO during applet-application initialization.
  385. // A seperate thread is setup where event-waiting is handled.
  386. // When the Event is signaled, official sw will assert.
  387. return ResultCode.Success;
  388. }
  389. [CommandHipc(140)] // 9.0.0+
  390. // GetFriendInvitationStorageChannelEvent() -> handle<copy>
  391. public ResultCode GetFriendInvitationStorageChannelEvent(ServiceCtx context)
  392. {
  393. if (_friendInvitationStorageChannelEventHandle == 0)
  394. {
  395. if (context.Process.HandleTable.GenerateHandle(_friendInvitationStorageChannelEvent.ReadableEvent, out _friendInvitationStorageChannelEventHandle) != KernelResult.Success)
  396. {
  397. throw new InvalidOperationException("Out of handles!");
  398. }
  399. }
  400. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_friendInvitationStorageChannelEventHandle);
  401. return ResultCode.Success;
  402. }
  403. [CommandHipc(141)] // 9.0.0+
  404. // TryPopFromFriendInvitationStorageChannel() -> object<nn::am::service::IStorage>
  405. public ResultCode TryPopFromFriendInvitationStorageChannel(ServiceCtx context)
  406. {
  407. // NOTE: IStorage are pushed in the channel with IApplicationAccessor PushToFriendInvitationStorageChannel
  408. // If _friendInvitationStorageChannelEvent is signaled, the event is cleared.
  409. // If an IStorage is available, returns it with ResultCode.Success.
  410. // If not, just returns ResultCode.NotAvailable. Since we don't support friend feature for now, it's fine to do the same.
  411. Logger.Stub?.PrintStub(LogClass.ServiceAm);
  412. return ResultCode.NotAvailable;
  413. }
  414. [CommandHipc(150)] // 9.0.0+
  415. // GetNotificationStorageChannelEvent() -> handle<copy>
  416. public ResultCode GetNotificationStorageChannelEvent(ServiceCtx context)
  417. {
  418. if (_notificationStorageChannelEventHandle == 0)
  419. {
  420. if (context.Process.HandleTable.GenerateHandle(_notificationStorageChannelEvent.ReadableEvent, out _notificationStorageChannelEventHandle) != KernelResult.Success)
  421. {
  422. throw new InvalidOperationException("Out of handles!");
  423. }
  424. }
  425. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_notificationStorageChannelEventHandle);
  426. return ResultCode.Success;
  427. }
  428. [CommandHipc(160)] // 9.0.0+
  429. // GetHealthWarningDisappearedSystemEvent() -> handle<copy>
  430. public ResultCode GetHealthWarningDisappearedSystemEvent(ServiceCtx context)
  431. {
  432. if (_healthWarningDisappearedSystemEventHandle == 0)
  433. {
  434. if (context.Process.HandleTable.GenerateHandle(_healthWarningDisappearedSystemEvent.ReadableEvent, out _healthWarningDisappearedSystemEventHandle) != KernelResult.Success)
  435. {
  436. throw new InvalidOperationException("Out of handles!");
  437. }
  438. }
  439. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_healthWarningDisappearedSystemEventHandle);
  440. return ResultCode.Success;
  441. }
  442. }
  443. }