Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <stdint.h>
- #include <string.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <errno.h>
- #include <sys/ioccom.h>
- #include <kernel.h>
- #include "stdafx.h"
- #include "mira_substitute.h"
- // We need to provide an export to force the expected stub library to be generated
- __declspec (dllexport) void dummy()
- {
- }
- Substitute substitute;
- struct substitute_hook* sceSysmoduleLoadModule_ref;
- struct substitute_hook* sceScreenShotDisableNotification_ref;
- struct substitute_hook* sceScreenShotEnableNotification_ref;
- struct substitute_hook* sceScreenShotIsDisabled_ref;
- struct substitute_hook* sceScreenShotIsVshScreenCaptureDisabled_ref;
- struct substitute_hook* sceScreenShotSetOverlayImage_ref;
- struct substitute_hook* sceScreenShotSetOverlayImageWithOrigin_ref;
- struct substitute_hook* sceVideoRecordingSetInfo_ref;
- // Don't do anything to silence notifications
- int32_t sceScreenShotDisableNotification_hook()
- {
- SUBSTITUTE_WAIT(sceScreenShotDisableNotification_ref)
- printf("sceScreenShotDisableNotification was called but not executed\n");
- return 0;
- }
- // Don't do anything to silence notifications
- int32_t sceScreenShotEnableNotification_hook()
- {
- SUBSTITUTE_WAIT(sceScreenShotEnableNotification_ref)
- printf("sceScreenShotEnableNotification was called but not executed\n");
- return 0;
- }
- // Always return false, so sceScreenShotEnable()/sceScreenShotDisable() effectively do nothing
- int32_t sceScreenShotIsDisabled_hook()
- {
- SUBSTITUTE_WAIT(sceScreenShotIsDisabled_ref)
- printf("sceScreenShotIsDisabled was called but not executed\n");
- return 0;
- }
- // Always return false, to enable screenshots on the PS4's menu
- int32_t sceScreenShotIsVshScreenCaptureDisabled_hook()
- {
- SUBSTITUTE_WAIT(sceScreenShotIsVshScreenCaptureDisabled_ref)
- printf("sceScreenShotIsVshScreenCaptureDisabled was called but not executed\n");
- return 0;
- }
- // Don't add overlay
- int32_t sceScreenShotSetOverlayImage_hook(const char*filePath, int32_t offsetX, int32_t offsetY)
- {
- SUBSTITUTE_WAIT(sceScreenShotSetOverlayImage_ref)
- printf("sceScreenShotSetOverlayImage was called but not executed\n");
- return 0;
- }
- // Don't add overlay
- int32_t sceScreenShotSetOverlayImageWithOrigin_hook(const char *filePath, int32_t marginX, int32_t marginY, int8_t origin)
- {
- SUBSTITUTE_WAIT(sceScreenShotSetOverlayImageWithOrigin_ref)
- printf("sceScreenShotSetOverlayImageWithOrigin was called but not executed\n");
- return 0;
- }
- // Video capture settings
- int32_t sceVideoRecordingSetInfo_hook(int32_t info, const void *pInfo, size_t infoLen)
- {
- // Make all permission level changes to zero
- if (info == 0xA007)
- {
- uint32_t level = 0;
- return SUBSTITUTE_CONTINUE(int, sceVideoRecordingSetInfo_ref, (int32_t), info, (const void *), &level, (size_t), sizeof(level)); // return sceVideoRecordingSetInfo(info, &level, sizeof(level));
- }
- // Clear guards rather than create them
- if (info == 0xA008)
- {
- return SUBSTITUTE_CONTINUE(int, sceVideoRecordingSetInfo_ref, (int32_t), info, (const void *), nullptr, (size_t), 0); // return sceVideoRecordingSetInfo(info, nullptr, 0);
- }
- // Make copyright info empty
- if (info == 0x0A01)
- {
- char copyright = 0;
- return SUBSTITUTE_CONTINUE(int, sceVideoRecordingSetInfo_ref, (int32_t), info, (const void *), ©right, (size_t), sizeof(copyright)); // return sceVideoRecordingSetInfo(info, ©right, sizeof(copyright));
- }
- // Use real function
- return SUBSTITUTE_CONTINUE(int, sceVideoRecordingSetInfo_ref, (int32_t), info, (const void *), &pInfo, (size_t), infoLen); // return sceVideoRecordingSetInfo(info, &pInfo, infoLen);
- }
- int sceSysmoduleLoadModule_hook(uint16_t id)
- {
- // Wait during sceSysmoduleLoadModule_ref is fully initialized
- SUBSTITUTE_WAIT(sceSysmoduleLoadModule_ref)
- // Execute sysmodule anyway
- int ret = SUBSTITUTE_CONTINUE(int, sceSysmoduleLoadModule_ref, (uint16_t), id);
- // If id is SCE_SYSMODULE_SCREEN_SHOT
- if (id == 0x009C)
- {
- printf("SCE_SYSMODULE_SCREEN_SHOT detected. Hooking ...\n");
- sceScreenShotDisableNotification_ref = substitute.Hook(SUBSTITUTE_MAIN_MODULE, "sceScreenShotDisableNotification", (void*)sceScreenShotDisableNotification_hook, SUBSTITUTE_IAT_NAME);
- if (!sceScreenShotDisableNotification_ref)
- {
- printf("[ScreenshotEnabler] (sceScreenShotDisableNotification) Unable to hook (%p) !\n", sceScreenShotDisableNotification_ref);
- return 0;
- } else {
- printf("[ScreenshotEnabler] (sceScreenShotDisableNotification) Hook enable !\n");
- }
- sceScreenShotEnableNotification_ref = substitute.Hook(SUBSTITUTE_MAIN_MODULE, "sceScreenShotEnableNotification", (void*)sceScreenShotEnableNotification_hook, SUBSTITUTE_IAT_NAME);
- if (!sceScreenShotEnableNotification_ref)
- {
- printf("[ScreenshotEnabler] (sceScreenShotEnableNotification) Unable to hook (%p) !\n", sceScreenShotEnableNotification_ref);
- return 0;
- } else {
- printf("[ScreenshotEnabler] (sceScreenShotEnableNotification) Hook enable !\n");
- }
- sceScreenShotIsDisabled_ref = substitute.Hook(SUBSTITUTE_MAIN_MODULE, "sceScreenShotIsDisabled", (void*)sceScreenShotIsDisabled_hook, SUBSTITUTE_IAT_NAME);
- if (!sceScreenShotIsDisabled_ref)
- {
- printf("[ScreenshotEnabler] (sceScreenShotIsDisabled) Unable to hook (%p) !\n", sceScreenShotIsDisabled_ref);
- return 0;
- } else {
- printf("[ScreenshotEnabler] (sceScreenShotIsDisabled) Hook enable !\n");
- }
- sceScreenShotIsVshScreenCaptureDisabled_ref = substitute.Hook(SUBSTITUTE_MAIN_MODULE, "sceScreenShotIsVshScreenCaptureDisabled", (void*)sceScreenShotIsVshScreenCaptureDisabled_hook, SUBSTITUTE_IAT_NAME);
- if (!sceScreenShotIsVshScreenCaptureDisabled_ref)
- {
- printf("[ScreenshotEnabler] (sceScreenShotIsVshScreenCaptureDisabled) Unable to hook (%p) !\n", sceScreenShotIsVshScreenCaptureDisabled_ref);
- return 0;
- } else {
- printf("[ScreenshotEnabler] (sceScreenShotIsVshScreenCaptureDisabled) Hook enable !\n");
- }
- sceScreenShotSetOverlayImage_ref = substitute.Hook(SUBSTITUTE_MAIN_MODULE, "sceScreenShotSetOverlayImage", (void*)sceScreenShotSetOverlayImage_hook, SUBSTITUTE_IAT_NAME);
- if (!sceScreenShotSetOverlayImage_ref)
- {
- printf("[ScreenshotEnabler] (sceScreenShotSetOverlayImage) Unable to hook (%p) !\n", sceScreenShotSetOverlayImage_ref);
- return 0;
- } else {
- printf("[ScreenshotEnabler] (sceScreenShotSetOverlayImage) Hook enable !\n");
- }
- sceScreenShotSetOverlayImageWithOrigin_ref = substitute.Hook(SUBSTITUTE_MAIN_MODULE, "sceScreenShotSetOverlayImageWithOrigin", (void*)sceScreenShotSetOverlayImageWithOrigin_hook, SUBSTITUTE_IAT_NAME);
- if (!sceScreenShotSetOverlayImageWithOrigin_ref)
- {
- printf("[ScreenshotEnabler] (sceScreenShotSetOverlayImageWithOrigin) Unable to hook (%p) !\n", sceScreenShotSetOverlayImageWithOrigin_ref);
- return 0;
- } else {
- printf("[ScreenshotEnabler] (sceScreenShotSetOverlayImageWithOrigin) Hook enable !\n");
- }
- }
- // If id is SCE_SYSMODULE_VIDEO_RECORDING
- if (id == 0x0085)
- {
- printf("SCE_SYSMODULE_VIDEO_RECORDING detected. Hooking ...\n");
- sceVideoRecordingSetInfo_ref = substitute.Hook(SUBSTITUTE_MAIN_MODULE, "sceVideoRecordingSetInfo", (void*)sceVideoRecordingSetInfo_hook, SUBSTITUTE_IAT_NAME);
- if (!sceVideoRecordingSetInfo_ref)
- {
- printf("[ScreenshotEnabler] (sceVideoRecordingSetInfo) Unable to hook (%p) !\n", sceVideoRecordingSetInfo_ref);
- return 0;
- } else {
- printf("[ScreenshotEnabler] (sceVideoRecordingSetInfo) Hook enable !\n");
- }
- }
- return ret;
- }
- int main()
- {
- printf("[ScreenshotEnabler] Main called !\n");
- sceSysmoduleLoadModule_ref = substitute.Hook(SUBSTITUTE_MAIN_MODULE, "sceSysmoduleLoadModule", (void*)sceSysmoduleLoadModule_hook, SUBSTITUTE_IAT_NAME);
- if (!sceSysmoduleLoadModule_ref)
- {
- printf("[ScreenshotEnabler] (sceSysmoduleLoadModule) Unable to hook (%p) !\n", sceSysmoduleLoadModule_ref);
- return 0;
- } else {
- printf("[ScreenshotEnabler] (sceSysmoduleLoadModule) Hook enable !\n");
- }
- return 0;
- }
- int fini()
- {
- if (sceSysmoduleLoadModule_ref)
- substitute.Unhook(sceSysmoduleLoadModule_ref);
- if (sceScreenShotDisableNotification_ref)
- substitute.Unhook(sceScreenShotDisableNotification_ref);
- if (sceScreenShotEnableNotification_ref)
- substitute.Unhook(sceScreenShotEnableNotification_ref);
- if (sceScreenShotIsDisabled_ref)
- substitute.Unhook(sceScreenShotIsDisabled_ref);
- if (sceScreenShotIsVshScreenCaptureDisabled_ref)
- substitute.Unhook(sceScreenShotIsVshScreenCaptureDisabled_ref);
- if (sceScreenShotSetOverlayImage_ref)
- substitute.Unhook(sceScreenShotSetOverlayImage_ref);
- if (sceScreenShotSetOverlayImageWithOrigin_ref)
- substitute.Unhook(sceScreenShotSetOverlayImageWithOrigin_ref);
- if (sceVideoRecordingSetInfo_ref)
- substitute.Unhook(sceVideoRecordingSetInfo_ref);
- return 0;
- }
- extern "C"
- {
- int module_start(size_t args, const void *argp)
- {
- return main();
- }
- int module_stop(size_t args, const void *argp)
- {
- return fini();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement