Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2017
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. #include <psp2/kernel/modulemgr.h>
  2. #include <psp2/sysmodule.h>
  3. #include <psp2/screenshot.h>
  4. #include <taihen.h>
  5.  
  6. static tai_hook_ref_t load_hook;
  7. static tai_hook_ref_t unload_hook;
  8. static tai_hook_ref_t ss_overlay_hook;
  9. static SceUID ss_overlay_uid;
  10.  
  11. // hook to never watermark screenshots
  12. int hook_ss_overlay(const char *filepath, int offsetX, int offsetY) {
  13. int ret;
  14. ret = TAI_CONTINUE(int, ss_overlay_hook, NULL, offsetX, offsetY); // so others get a chance to hook
  15. return ret;
  16. }
  17. // hook load module
  18. int hook_sysmodule_load(uint16_t id) {
  19. int ret;
  20. ret = TAI_CONTINUE(int, load_hook, id);
  21. if (ret >= 0) { // load successful
  22. switch (id) {
  23. case SCE_SYSMODULE_SCREEN_SHOT:
  24. ss_overlay_uid =
  25. taiHookFunctionExport(&ss_overlay_hook, // Output a reference
  26. "SceScreenShot", // Name of module being hooked
  27. 0xF26FC97D, // NID specifying SceScreenShot
  28. 0x7061665B, // NID specifying sceScreenShotSetOverlayImage
  29. hook_ss_overlay); // Name of the hook function // Name of the hook function
  30. break;
  31. // you can consider other loaded modules too here ...
  32.  
  33. }
  34. }
  35. return ret;
  36. }
  37. // hook unload module
  38. int hook_sysmodule_unload(uint16_t id) {
  39. int ret;
  40. ret = TAI_CONTINUE(int, unload_hook, id);
  41. if (ret >= 0) { // unload successful
  42. switch (id) {
  43. case SCE_SYSMODULE_SCREEN_SHOT:
  44. if (ss_overlay_uid >= 0) {
  45. taiHookRelease(ss_overlay_uid, ss_overlay_hook);
  46. ss_overlay_uid = -1;
  47. }
  48. break;
  49. // you can consider other loaded modules too here ...
  50.  
  51.  
  52. }
  53. }
  54. return ret;
  55. }
  56. // our own plugin entry
  57. int module_start(SceSize argc, const void *args) {
  58. ss_overlay_uid = -1;
  59. taiHookFunctionImport(&load_hook, // Output a reference
  60. TAI_MAIN_MODULE, // Name of module being hooked
  61. 0x03FCF19D, // NID specifying SceSysmodule
  62. 0x79A0160A, // NID specifying sceSysmoduleLoadModule
  63. hook_sysmodule_load); // Name of the hook function
  64. taiHookFunctionImport(&unload_hook, // Output a reference
  65. TAI_MAIN_MODULE, // Name of module being hooked
  66. 0x03FCF19D, // NID specifying SceSysmodule
  67. 0x31D87805, // NID specifying sceSysmoduleUnloadModule
  68. hook_sysmodule_unload); // Name of the hook function
  69. return SCE_KERNEL_START_SUCCESS;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement