开发者

Probing Dlls through Reflection in ASP .Net

I have been trying to find more information on the technique of dll and exe discovery by way of writing programs using ASP .Net and reflection(?). I haven't been able to find anything.

I know there are dissassemblers but I am not interested in running other tools and disassembling code per say, I am more interested in understanding how to write a program that takes an unknown file or executable and determines the properties and methods within that are public.

I am just starting on my search for this and was wondering of any good resources to jumpstart the learning开发者_如何学JAVA process.


I am more interested in understanding how to write a program that takes an unknown file or executable and determines the properties and methods within that are public.

Reflection is a good way to do that. Here are a few tips if you don't want a full code explanation.

  1. You could use the Assembly.ReflectionOnlyLoad to load an existing assembly. This will only work for .NET assemblies. The difference between Load and ReflectionOnlyLoad is that Load loads an assembly that allows you to use it, like executing a method on a type in that assembly. ReflectionOnlyLoad is useful when you only want to look at what is in the assembly without executing any code. The other advantage of ReflectionOnlyLoad is that it doesn't care what platform the assembly was compiled for.

  2. Once you have the assembly, you can use a method like GetExportedTypes to get a list of all of the public types. If you want to get the public and non-public, you can use just GetTypes().

  3. So now we have our assembly loaded, and a list of all of the types. The Type class has several members for working with that type. GetMethods and GetProperties come to mind.

You can refer to this MSDN article for a more general overview of Reflection.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜