jmpews / Dobby

a lightweight, multi-platform, multi-architecture hook framework.
Apache License 2.0
3.89k stars 796 forks source link

DobbyDestroy always assert faild #198

Closed LinzerLee closed 1 year ago

LinzerLee commented 1 year ago

Environment: macOS 12.6 (x64)

I am using the lastest commit.

I call DobbyHook function,but it always assert faild。 In InterceptRouting::GenerateRelocatedCode method

// save original prologue
memcpy((void *)entry_->origin_insns, (void *)origin_->addr, origin_->size);

It looks like forgot about the origin_insn_size field for assignment,this will cause the call to DobbyDestroy to fail, because the assertion of DobbyCodePatch function fails。

Suggested Modification:

// save original prologue
memcpy((void *)entry_->origin_insns, (void *)origin_->addr, origin_->size);
entry_->origin_insn_size = origin_->size;
jmpews commented 1 year ago

fixed