c# - How do I invoke .getmethodinfo? -
i have started read how open source encryption program works.
the problem is, i'm stuck here on these 2 lines of code can't understand @ all, have looked @ msdn doesn't me @ understand these 2 lines do.
methodinfo run = assembly.load(injres).gettype("resource.reflect").getmethod("run"); bool inj = (bool)run.invoke(null, new object[] { assembly.getexecutingassembly().location, "", payloadres, false });
i'm trying figure out way accomplish same thing, there way invoke .getmethod?
this basic "reflection" in .net.
basically happens here is:
- loads .net assembly indicated
injres
- inside assembly, type definition
resource.reflect
(whichclass
) - inside
resource.reflect
type,run
method , save variablerun
- invoke (in other works, "execute")
run()
function onnull
instance (which meansrun()
static
method) parameters(assembly.getexecutingassembly().location, "", payloadres, false)
more simply, these lines translate "regular old c#" looks like:
bool inj = resource.reflect.run(assembly.getexecutingassembly().location, "", payloadres, false);
but original author couldn't have written simple 1 line above because either:
- the assembly wasn't referenced @ build-time, compiler doesn't know
resouce
namespace have thrown compile error - or
resouce.reflect
class orrun
method isn'tpublic
couldn't have been called normally. reflection can bypass limitation.
Comments
Post a Comment