inline_item_t
*
init_item(address_t
*
target_fun, address_t
*
hook_fun, list_node_t
*
param_list,address_t ret_value)
{
inline_item_t
*
p_item
=
0
;
address_t temp
=
0
;
p_item
=
(inline_item_t
*
)malloc( sizeof(inline_item_t) );
p_item
-
>shell_code_len
=
(int8_t
*
)&asm_shellcode_end
-
(int8_t
*
)&asm_shellcode_begin;
p_item
-
>shell_code
=
(int8_t
*
)malloc( p_item
-
>shell_code_len);
/
/
分配shellcode空间
p_item
-
>old_fun
=
target_fun;
/
/
保存原始函数地址
p_item
-
>new_fun
=
hook_fun;
/
/
存储hook函数地址
p_item
-
>back_code_len
=
12
;
/
/
备份
12
字节指令
p_item
-
>back_code
=
malloc(p_item
-
>back_code_len);
p_item
-
>reg
=
malloc(
0x10
*
sizeof(address_t));
/
/
分配备份寄存器的空间
p_item
-
>stack
=
malloc(
0x10
*
sizeof(address_t));
/
/
分配备份栈的空间
p_item
-
>param_list
=
0
;
p_item
-
>ret_value
=
0
;
if
( param_list !
=
0
){
p_item
-
>param_list
=
param_list;
/
/
初始化要修改的参数列表
}
if
( ret_value!
=
0
){
p_item
-
>ret_value
=
(address_t
*
)malloc( sizeof(address_t) );
/
/
初始化要修改的返回值
ret_value
=
10
;
memcpy( p_item
-
>ret_value, &ret_value, sizeof(address_t));
}
return
p_item;
}