[Mono-list] msil/cil editting library

Andrew Huntwork ash@huntwork.net
Thu, 24 Oct 2002 16:58:05 -0700

we're currently working on a java bytecode obfuscator/watermarker 
(www.cs.arizona.edu/sandmark/), and we'd like to obfuscate/watermark 
cil/msil assemblies as well.  we're just starting to investigate this, 
so i could easily imagine that I have some terminology wrong already.

we currently use BCEL (bcel.sf.net) to edit java bytecode.  bcel 
provides apis to view and change almost all attributes of classes and 
methods, including the instruction lists of methods.

we'd like to use and possibly develop or help to develop a similar 
library for msil, and it appears that the mono project contains large 
pieces of such a library in easily usable form already (file parsing, 
metadata parsing, method representation, control flow graph 
representation, etc).  I haven't run across any code that would allow me 
to dump a modified MonoMethod back into a MonoImage or a MonoImage back 
into an assembly.  Does such code exist?  I have found code that 
interprets the instructions and arguments in a byte array, but having 
some kind of higher level view of instructions and arguments is 
sometimes helpful.  Does mono contain such an abstraction?

Does anyone have any advice on developing such a library?  Is anyone 
aware of existing libraries that do this kind of thing?

Thanks very much for your help.