Skip to content

Commit

Permalink
[MsvcDiver] Also search parent type for invoked method
Browse files Browse the repository at this point in the history
  • Loading branch information
theXappy committed Nov 2, 2024
1 parent 9bdcb0e commit 36ff9c9
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/ScubaDiver/MsvcDiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -862,8 +862,29 @@ protected override string MakeInvokeResponse(ScubaDiverMessage arg)
Rtti.TypeInfo typeInfo = modulesAndTypes[module].Single();

List<UndecoratedFunction> typeFuncs = _exportsMaster.GetExportedTypeFunctions(module, typeInfo.Name).ToList();
UndecoratedFunction targetMethod = typeFuncs.Single(m => m.DecoratedName == method.DecoratedName);
Logger.Debug($"[MsvcDiver] FOUND the target function: {targetMethod}");
UndecoratedFunction targetMethod = typeFuncs.SingleOrDefault(m => m.DecoratedName == method.DecoratedName);
if (targetMethod != null)
{
Logger.Debug($"[MsvcDiver] FOUND the target function: {targetMethod}");
}
else
{
// Extend search to other types (this method might be inherited and hence found under another type's name.
// Turning `namespace::class::func` to `namespace::class`
string methodFullName = method.UndecoratedFullName;
string parentType = methodFullName.Substring(0, methodFullName.IndexOf(method.Name));

typeFuncs = _exportsMaster.GetExportedTypeFunctions(module, parentType).ToList();
targetMethod = typeFuncs.SingleOrDefault(m => m.DecoratedName == method.DecoratedName);
if (targetMethod != null)
{
Logger.Debug($"[MsvcDiver] FOUND the target function in PARENT type: {targetMethod}");
}
else
{
return QuickError($"Could not find method {targetMethod} in either {typeInfo.Name} nor {parentType}");
}
}

//
// Turn target method into an invoke-able delegate
Expand Down

0 comments on commit 36ff9c9

Please sign in to comment.