Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. /*
  2. * Copyright (c) 2015, Simone Margaritelli <evilsocket at gmail dot com>
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * * Redistributions of source code must retain the above copyright notice,
  9. * this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * * Neither the name of ARM Inject nor the names of its contributors may be used
  14. * to endorse or promote products derived from this software without
  15. * specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  18. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  21. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  22. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  23. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  24. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  25. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  26. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  27. * POSSIBILITY OF SUCH DAMAGE.
  28. */
  29. #include "hook.h"
  30. //#include "hooks/io.h"
  31.  
  32. //Create typedef for function pointer that we want to hook
  33. typedef unsigned long (* fDoJumpingStuff)( unsigned long, unsigned long );
  34.  
  35. //Create function pointer
  36. fDoJumpingStuff fpOriginalFunction = NULL;
  37.  
  38. //Create function for our hook
  39. unsigned long Hook_DoJumpingStuff( unsigned long ulClass, unsigned long ulCPad )
  40. {
  41. //Call original function and store return stuff in our var
  42. if( fpOriginalFunction != NULL)
  43. {
  44. unsigned long ulReturnVal = fpOriginalFunction( ulClass, ulCPad );
  45.  
  46. //Print message thats its working !
  47. HOOKLOG("%s", "You jumped!");
  48.  
  49. //Return original return stuff
  50. return ulReturnVal;
  51. }
  52.  
  53. return 0;
  54. }
  55.  
  56. void __attribute__ ((constructor)) libhook_main()
  57. {
  58. ld_modules_t modules = libhook_get_modules();
  59.  
  60. HOOKLOG( "LIBRARY LOADED FROM PID %d.", getpid() );
  61.  
  62. for( ld_modules_t::const_iterator i = modules.begin(), e = modules.end(); i != e; ++i) {
  63.  
  64. if( i->name.find( "libGTALcs.so" ) != std::string::npos ) {
  65.  
  66. HOOKLOG( "Library Found ! what we need kurwa fix %s.", i->name.c_str() );
  67. fpOriginalFunction = (fDoJumpingStuff)libhook_addhook( i->name.c_str(), "_ZN10CPlayerPed14DoJumpingStuffEP4CPad", (uintptr_t)&Hook_DoJumpingStuff );
  68.  
  69. }
  70. }
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement