Conversation
Refactor CreateVirtualFunction to include caching and hashing.
|
This can be also possible on the C++ side, now the vf will not leak. // destructor
- ValveFunction::~ValveFunction() {}
+ ValveFunction::~ValveFunction() {
+ if (m_precallback) {
+ globals::callbackManager.ReleaseCallback(m_precallback);
+ m_precallback = nullptr;
+ }
+ if (m_postcallback) {
+ globals::callbackManager.ReleaseCallback(m_postcallback);
+ m_postcallback = nullptr;
+ }
+ }
// cache
auto it = std::find_if(m_managed_ptrs.begin(), m_managed_ptrs.end(), [&](ValveFunction* vf) {
return vf && vf->m_ulAddr == function_addr &&
vf->m_eCallingConvention == CONV_THISCALL &&
vf->m_Args == args &&
vf->m_eReturnType == return_type &&
vf->m_offset == vtable_offset;
});
if (it != m_managed_ptrs.end())
{
return *it;
} |
|
I think this is a useful feature, but I believe it would be better implemented on the native side rather than on the C# side |
great suggestion |
Yes, this was implemented as a trial, and there may be better implementations. |
|
This should be fixed by PR #1121 as it's done on the native layer now, but thank you for prompting the discussion |
Refactor CreateVirtualFunction to include caching and hashing.