Advertisement
expired6978

CameraHook

Jan 11th, 2013
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. #include "Hooks_Camera.h"
  2. #include "GameCamera.h"
  3. #include "PapyrusEvents.h"
  4. #include "SafeWrite.h"
  5. #include <queue>
  6.  
  7. static const UInt32 kInstallCameraHook_Base = 0x00653097;
  8. static const UInt32 kInstallCameraHook_Entry_retn = kInstallCameraHook_Base + 0x05;
  9. /*
  10.  
  11. .text:00653094                 mov     ecx, [esi+20h]
  12. .text:00653097                 mov     eax, ecx
  13. .text:00653099                 neg     eax
  14. .text:0065309B                 pop     edi
  15. .text:0065309C                 sbb     eax, eax
  16. .text:0065309E                 pop     esi
  17. .text:0065309F                 pop     ebx
  18.  
  19. edi - old state
  20. ecx - new state
  21.  
  22. */
  23.  
  24. void __stdcall InstallCameraHook(TESCameraState * oldState, TESCameraState * newState)
  25. {
  26.     SKSECameraEvent evn(oldState, newState);
  27.     g_cameraEventDispatcher.SendEvent(&evn);
  28. }
  29.  
  30. __declspec(naked) void InstallHookCamera_Entry(void)
  31. {
  32.     __asm
  33.     {
  34.         pushad
  35.         push    ecx
  36.         push    edi
  37.         call    InstallCameraHook
  38.         popad
  39.  
  40.         // overwritten code
  41.         mov     eax, ecx
  42.         neg     eax
  43.         pop     edi
  44.  
  45.         jmp     [kInstallCameraHook_Entry_retn]
  46.     }
  47. }
  48.  
  49.  
  50. void Hooks_Camera_Commit(void)
  51. {
  52.     WriteRelJump(kInstallCameraHook_Base, (UInt32)InstallHookCamera_Entry);
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement