Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
d49521ba
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
1 年多 前同步成功
通知
37
Star
125
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Musl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
d49521ba
编写于
9月 14, 2022
作者:
Z
zhangcui
提交者:
Gitee
9月 14, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化全局变量
Signed-off-by:
N
zhangcui
<
zhangcui11@huawei.com
>
上级
8086f6b7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
17 deletion
+16
-17
porting/linux/user/src/hook/musl_preinit.c
porting/linux/user/src/hook/musl_preinit.c
+16
-17
未找到文件。
porting/linux/user/src/hook/musl_preinit.c
浏览文件 @
d49521ba
...
...
@@ -44,24 +44,22 @@ static struct MallocDispatchType __ohos_malloc_hook_init_dispatch = {
.
munmap
=
MuslMalloc
(
munmap
),
};
#define MAX_SYM_NAME_SIZE 1000
#define MAX_PROC_NAME_SIZE 1024
static
char
*
__malloc_hook_shared_lib
=
"libnative_hook.z.so"
;
static
char
*
__malloc_hook_function_prefix
=
"ohos_malloc_hook"
;
volatile
atomic_llong
ohos_malloc_hook_shared_library
;
void
*
function_of_shared_lib
[
LAST_FUNCTION
];
static
enum
EnumHookMode
__hook_mode
=
STEP_HOOK_MODE
;
static
char
__hook_process_path
[
PATH_MAX
+
1
]
=
{
0
};
static
char
__progname
[
PATH_MAX
+
1
]
=
{
0
};
static
char
__param_value
[
OHOS_PARAM_MAX_SIZE
+
1
]
=
{
0
};
static
char
*
get_native_hook_param
()
static
void
get_native_hook_param
(
char
*
buf
,
unsigned
int
buf_len
)
{
#ifdef OHOS_ENABLE_PARAMETER
const
char
*
key
=
MUSL_HOOK_PARAM_NAME
;
unsigned
int
len
=
OHOS_PARAM_MAX_SIZE
;
(
void
)
SystemReadParam
(
key
,
__param_value
,
&
len
);
return
__param_value
;
unsigned
int
len
=
buf_len
;
(
void
)
SystemReadParam
(
key
,
buf
,
&
len
);
#else
return
NULL
;
return
;
#endif
}
...
...
@@ -70,16 +68,15 @@ static int parse_hook_variable(enum EnumHookMode* mode, char* path, int size)
if
(
!
mode
||
!
path
||
size
<=
0
)
{
return
-
1
;
}
bool
flag
=
__set_hook_flag
(
false
);
char
*
hook_param_value
=
get_native_hook_param
();
if
(
hook_param_value
==
NULL
||
hook_param_value
[
0
]
==
'\0'
)
{
char
hook_param_value
[
OHOS_PARAM_MAX_SIZE
+
1
]
=
{
0
};
unsigned
int
len
=
OHOS_PARAM_MAX_SIZE
;
get_native_hook_param
(
hook_param_value
,
len
);
if
(
hook_param_value
[
0
]
==
'\0'
)
{
*
mode
=
STEP_HOOK_MODE
;
path
[
0
]
=
'\0'
;
}
else
{
char
*
ptr
=
hook_param_value
;
char
*
mode_str
=
hook_param_value
;
while
(
*
ptr
&&
*
ptr
!=
':'
)
{
++
ptr
;
}
...
...
@@ -89,11 +86,11 @@ static int parse_hook_variable(enum EnumHookMode* mode, char* path, int size)
++
ptr
;
}
if
(
strcmp
(
mode_str
,
"startup"
)
==
0
)
{
if
(
strcmp
(
hook_param_value
,
"startup"
)
==
0
)
{
*
mode
=
STARTUP_HOOK_MODE
;
}
else
if
(
strcmp
(
mode_str
,
"direct"
)
==
0
)
{
}
else
if
(
strcmp
(
hook_param_value
,
"direct"
)
==
0
)
{
*
mode
=
DIRECT_HOOK_MODE
;
}
else
if
(
strcmp
(
mode_str
,
"step"
)
==
0
)
{
}
else
if
(
strcmp
(
hook_param_value
,
"step"
)
==
0
)
{
*
mode
=
STEP_HOOK_MODE
;
}
else
{
*
mode
=
STEP_HOOK_MODE
;
...
...
@@ -427,8 +424,10 @@ __attribute__((constructor(1))) static void __musl_initialize()
{
atomic_store_explicit
(
&
__hook_enable_hook_flag
,
(
volatile
bool
)
false
,
memory_order_seq_cst
);
__set_default_malloc
();
parse_hook_variable
(
&
__hook_mode
,
__hook_process_path
,
sizeof
(
__hook_process_path
));
char
__hook_process_path
[
MAX_PROC_NAME_SIZE
+
1
]
=
{
0
};
parse_hook_variable
(
&
__hook_mode
,
__hook_process_path
,
sizeof
(
__hook_process_path
)
-
1
);
if
(
__hook_mode
==
STARTUP_HOOK_MODE
)
{
char
__progname
[
MAX_PROC_NAME_SIZE
+
1
]
=
{
0
};
if
(
get_proc_name
(
getpid
(),
__progname
,
sizeof
(
__progname
)
-
1
))
{
const
char
*
pos
=
strrchr
(
__progname
,
'/'
);
const
char
*
file_name
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录