Created
February 25, 2019 19:44
-
-
Save ViugiNick/583a55a73a515891f545e57653127def to your computer and use it in GitHub Desktop.
This file contains 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
macro_rules! cfunc_mid_2_3_1( | |
() => ( | |
fn check_method_entry<T: CopyAddress>( | |
env_me_cref : usize, | |
me: *const rb_method_entry_struct, | |
source: &T) -> Result<*const rb_method_entry_struct, MemoryCopyError> { | |
unsafe { | |
let tmp = env_me_cref as *const RBasic; | |
if tmp as usize != 0x00 { | |
//let imemo : RBasic = copy_struct(env_me_cref, source)?; | |
let tmp1 = copy_address_raw(env_me_cref, std::mem::size_of::<rb_method_definition_struct>(), source)?; | |
let imemo : *const RBasic = tmp1.as_ptr() as *const RBasic; | |
let imemo_val : RBasic = std::ptr::read(imemo); | |
let ttype = (imemo_val.flags >> 12) & 0x07; | |
if ttype == 6 { | |
return Ok(imemo as *const rb_method_entry_struct); | |
} | |
else { | |
if ttype == 2 { | |
//me = check_method_entry(imemo as usize, me, source)?; | |
return Ok(check_method_entry(imemo as usize, me, source)?); | |
//Ok(me); | |
} | |
} | |
} | |
} | |
return Ok(me); | |
} | |
use libc::Dl_info; | |
use libc::dladdr; | |
fn cfunc_mid<T: CopyAddress>(cfp: &rb_control_frame_t, symbols: &symbols, source: &T) -> Result<StackFrame, MemoryCopyError> { | |
let mut me : *const rb_method_entry_struct = ptr::null_mut(); | |
unsafe { | |
let mut ep = cfp.ep; | |
let frame_flag : usize = copy_struct(ep.offset(0) as usize, source)?; | |
if frame_flag & 0xffff0001 == 0x55550001 { | |
let mut env_specval : usize = copy_struct(ep.offset(-1) as usize, source)?; | |
let mut env_me_cref : usize = copy_struct(ep.offset(-2) as usize, source)?; | |
while env_specval & 0x02 != 0 { | |
me = check_method_entry(env_me_cref, me, source)?; | |
if !me.is_null() { | |
break; | |
} | |
ep = ep.offset(0) as *mut usize; | |
env_specval = ep.offset(-1) as usize; | |
env_me_cref = ep.offset(-2) as usize; | |
} | |
if me.is_null() { | |
me = check_method_entry(env_me_cref, me, source)?; | |
} | |
if me as usize == 0 { | |
return Ok(StackFrame::unknown_c_function()); | |
} | |
//TODO | |
} | |
} | |
return Ok(StackFrame::unknown_c_function()) | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment