Skip to content

Commit 3783846

Browse files
unkn0wNameunkn0wName
authored andcommitted
fix: 修复细节bug
1 parent eab528b commit 3783846

13 files changed

Lines changed: 331 additions & 332 deletions

Lite_version/testRoot/jni/kernel_root_kit/include/rootkit_err_def.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ enum class KRootErr : ssize_t {
44
ERR_NONE = 0,
55
ERR_PARAM = -1000,
66
ERR_NO_ROOT,
7-
ERR_WAIT_FORK_CHILD,
87
ERR_READ_CHILD_ERRCODE,
98
ERR_READ_CHILD_STRING,
109
ERR_READ_CHILD_INT,
Binary file not shown.

Lite_version/testRoot/jni/kernel_root_kit/src/jni/rootkit_command.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,19 @@ KRootErr run_root_cmd_with_cb(const char* str_root_key, const char* cmd, void (*
6464
} while(0);
6565
write_errcode_from_child(finfo, err);
6666
write_string_from_child(finfo, result);
67+
finfo.close_all();
6768
_exit(0);
6869
return {};
6970
}
70-
if(!is_fork_child_process_work_finished(finfo)) {
71-
err = KRootErr::ERR_WAIT_FORK_CHILD;
71+
72+
if(!read_errcode_from_child(finfo, err)) {
73+
err = KRootErr::ERR_READ_CHILD_ERRCODE;
74+
} else if(!read_string_from_child(finfo, result)) {
75+
err = KRootErr::ERR_READ_CHILD_STRING;
7276
} else {
73-
if(!read_errcode_from_child(finfo, err)) {
74-
err = KRootErr::ERR_READ_CHILD_ERRCODE;
75-
} else if(!read_string_from_child(finfo, result)) {
76-
err = KRootErr::ERR_READ_CHILD_STRING;
77-
} else {
78-
cb(result.c_str());
79-
}
77+
cb(result.c_str());
8078
}
79+
int status = 0; waitpid(finfo.child_pid, &status, 0);
8180
return err;
8281
}
8382
}

Lite_version/testRoot/jni/kernel_root_kit/src/jni/rootkit_exec_process.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,15 @@ namespace kernel_root {
5656
if (fork_pipe_child_process(finfo)) {
5757
KRootErr err = unsafe_root_exec_process(str_root_key, file_path);
5858
write_errcode_from_child(finfo, err);
59+
finfo.close_all();
5960
_exit(0);
6061
return KRootErr::ERR_NONE;
6162
}
6263
KRootErr err = KRootErr::ERR_NONE;
63-
if (!is_fork_child_process_work_finished(finfo)) {
64-
err = KRootErr::ERR_WAIT_FORK_CHILD;
65-
} else if (!read_errcode_from_child(finfo, err)) {
66-
if(err == KRootErr::ERR_READ_EOF) {
67-
return KRootErr::ERR_NONE;
68-
}
64+
if (!read_errcode_from_child(finfo, err)) {
65+
if(err == KRootErr::ERR_READ_EOF) err = KRootErr::ERR_NONE;
6966
}
67+
int status = 0; waitpid(finfo.child_pid, &status, 0);
7068
return err;
7169
}
7270

0 commit comments

Comments
 (0)