Created
March 21, 2017 02:44
-
-
Save rweichler/7b134d8b8c9e44e13017acb751d82f52 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jit.off() | |
local USE_C = true -- change this | |
PATH = '/var/root/test' | |
package.path = PATH..'/?.lua;'.. | |
PATH..'/?/init.lua;'.. | |
package.path | |
package.cpath = PATH..'/?.so;'.. | |
package.cpath | |
objc = require 'objc' | |
ffi = require 'ffi' | |
C = ffi.C | |
ffi.cdef[[ | |
void MSHookMessageEx(Class class, SEL message, void *hook, void *orig); | |
]] | |
if USE_C then | |
function LMFAO(scrollView) -- this is called from the c lib | |
scrol(scrollView) | |
end | |
require 'hook' -- c lib that calls MSHookMessageEx | |
else | |
local orig = ffi.new('void (*[1])(id, SEL, id)') | |
-- this is the function that corrupts the memory somehow | |
local hook = function(self, _cmd, scrollView) | |
orig[0](self, _cmd, scrollView) | |
scrol(scrollView) | |
end | |
_G.CB = ffi.cast('void (*)(id, SEL, id)', hook) | |
C.MSHookMessageEx(objc.SBRootFolderView, objc.SEL('scrollViewDidScroll:'), _G.CB, orig) | |
end | |
require 'cylinder' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment