Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes and cleanup in windows injection #1811

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/libinjector/win/win_injector.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,11 +774,13 @@ void injector_terminate_on_win(drakvuf_t drakvuf,
uint32_t injection_tid,
vmi_pid_t pid)
{
injector_t injector = (injector_t)g_try_malloc0(sizeof(struct injector));
if ( !injector )
return;

PRINT_DEBUG("Target PID %u to terminate %u\n", injection_pid, pid);
drakvuf_interrupt(drakvuf, 0); // clean

injector_t injector = (injector_t)g_try_malloc0(sizeof(struct injector));

injector->method = INJECT_METHOD_TERMINATEPROC;
injector->drakvuf = drakvuf;
injector->target_pid = injection_pid;
Expand All @@ -805,11 +807,13 @@ void injector_exitthread_on_win(drakvuf_t drakvuf,
vmi_pid_t injection_pid,
uint32_t injection_tid)
{
injector_t injector = (injector_t)g_try_malloc0(sizeof(struct injector));
if ( !injector )
return;

PRINT_DEBUG("Target PID %u to terminate TID %u\n", injection_pid, injection_tid);
drakvuf_interrupt(drakvuf, 0); // clean

injector_t injector = (injector_t)g_try_malloc0(sizeof(struct injector));

injector->method = INJECT_METHOD_EXITTHREAD;
injector->drakvuf = drakvuf;
injector->target_pid = injection_pid;
Expand Down
5 changes: 3 additions & 2 deletions src/libinjector/win/win_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,15 @@ addr_t get_function_va(drakvuf_t drakvuf, addr_t eprocess_base, char const* lib,
void free_memtraps(injector_t injector)
{
GSList* loop = injector->memtraps;
injector->memtraps = NULL;

while (loop)
{
drakvuf_remove_trap(injector->drakvuf, loop->data, (drakvuf_trap_free_t)free);
loop = loop->next;
}
g_slist_free(loop);

g_slist_free(injector->memtraps);
injector->memtraps = NULL;
}

void free_injector(injector_t injector)
Expand Down