mirror of
https://github.com/Cxbx-Reloaded/subhook.git
synced 2024-12-02 08:08:32 +00:00
Make Install(src, dst, flags) remove existing hook
This commit is contained in:
parent
873e7cd795
commit
2fe65f1de9
19
subhook.h
19
subhook.h
@ -186,8 +186,13 @@ class Hook {
|
||||
bool Install(void *src,
|
||||
void *dst,
|
||||
HookFlags flags = HookNoFlags) {
|
||||
if (hook_ != nullptr) {
|
||||
subhook_remove(hook_);
|
||||
subhook_free(hook_);
|
||||
}
|
||||
hook_ = subhook_new(src, dst, (subhook_flags_t)flags);
|
||||
if (hook_ == nullptr) {
|
||||
hook_ = subhook_new(src, dst, (subhook_flags_t)flags);
|
||||
return false;
|
||||
}
|
||||
return Install();
|
||||
}
|
||||
@ -211,8 +216,8 @@ class Hook {
|
||||
class ScopedHookRemove {
|
||||
public:
|
||||
ScopedHookRemove(Hook *hook)
|
||||
: hook_(hook)
|
||||
, removed_(hook_->Remove())
|
||||
: hook_(hook),
|
||||
removed_(hook_->Remove())
|
||||
{
|
||||
}
|
||||
|
||||
@ -234,8 +239,8 @@ class ScopedHookRemove {
|
||||
class ScopedHookInstall {
|
||||
public:
|
||||
ScopedHookInstall(Hook *hook)
|
||||
: hook_(hook)
|
||||
, installed_(hook_->Install())
|
||||
: hook_(hook),
|
||||
installed_(hook_->Install())
|
||||
{
|
||||
}
|
||||
|
||||
@ -243,8 +248,8 @@ class ScopedHookInstall {
|
||||
void *src,
|
||||
void *dst,
|
||||
HookFlags flags = HookNoFlags)
|
||||
: hook_(hook)
|
||||
, installed_(hook_->Install(src, dst, flags))
|
||||
: hook_(hook),
|
||||
installed_(hook_->Install(src, dst, flags))
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user