# Monday, 23 April 2012
IKDASM - IL Disassembler Example for IKVM.Reflection

A while ago I wrote an IL disassembler to test IKVM.Reflection. Both as a correctness test and also to test if the API surface exposes enough of the underlying information.

I thought it would make a good IKVM.Reflection example (although the code won't win any awards, it's a bit of a hack). One nice feature is that it tries really hard to emit the same output file as the .NET ildasm to make comparison easier. There's even a command line option to match a specific ildasm version (2.0, 4.0 or 4.5) and its quirks.

The binaries are available in ikdasm-v0.1-binaries.zip and the Visual Studio 2010 solution in ikdasm-v0.1.zip.

Note that in its current form the ildasm compatibility mode only works on Windows, because it needs to P/Invoke _gcvt in msvcrt.dll to make sure the floating point numbers match the ildasm output.

Monday, 23 April 2012 16:54:40 (W. Europe Daylight Time, UTC+02:00)  #    Comments [0]
# Thursday, 19 April 2012
New Development Snapshot

At Lang.NEXT I met someone who was interested in using IKVM.Reflection and after he started porting his code, he ran into some missing functionality in IKVM.Reflection, so I've made some improvements there.

I've also fixed the remaining known issues with access stubs and "unloadable" (missing types) custom modifiers.

Changes:

  • Fix for recently introduced bug (with access stub rewrite). Bug #3512589.
  • Changed build process to fall back to the NAnt task, if we can't find the resource compiler.
  • Made WinForms message loop thread creation lazy to hopefully allow more applications to run without message loop thread. This is a (partial) workaround for bug #3515033.
  • Changed ikvmc to read input files after processing all the options (to make -nowarn: and -warnaserror: options that follow the file names work for warnings produced during input file reading).
  • Added support for type 2 access stubs for constructors.
  • Bug fix. When an unloadable type is used in a method signature that overrides a method (or implements an interface method), the custom modifier must be the same as the base class or an override stub must be generated.
  • Added partial implementation of ThreadMXBean.
  • IKVM.Reflection: Bug fix. When writing an assembly that has a .netmodule, the TypeDefId field in the ExportedType in the manifest module should contain a TypeDef token instead of an index.
  • IKVM.Reflection: Bug fix. When exporting a nested type (via AssemblyBuilder.__AddTypeForwarder()), we should also set the namespace (in practice it is unlikely for a nested type to have a namespace, but is is possible).
  • IKVM.Reflection: Corrected a couple of method parameter names in Assembly.
  • IKVM.Reflection: Added Assembly.GetType(string,bool,bool) method.
  • IKVM.Reflection: Added support for case-insensitive type and member lookup.
  • IKVM.Reflection: Implemented case insensitive lookup in Type.GetInterface().
  • IKVM.Reflection: Moved GetEvents(), GetFields(), GetConstructors(), GetNestedTypes() and GetProperties() to a common implementation that fixes a number of bugs.
  • IKVM.Reflection: Fixed GetMethods() to properly filter out base class methods that have been overridden.
  • IKVM.Reflection: Moved member lookup by name to a common implementation that fixes a number of bugs and adds IgnoreCase support.
  • IKVM.Reflection: Added MemberInfo.ReflectedType.
  • IKVM.Reflection: Added Binder support for method and property lookup.
  • IKVM.Reflection: Bug fix. ParameterBuilder.Position should return the 1-based position passed in to DefineParameter, not the 0-based ParameterInfo.Position.
  • IKVM.Reflection: Changed Type.__ContainsMissingType to return true for generic type parameters that have constraints that return true for __ContainsMissingType.
  • IKVM.Reflection: Bug fix. It should be possible to import a function pointer type into a ModuleBuilder.
  • IKVM.Reflection: Implemented Assembly.ToString().
  • IKVM.Reflection: Added [Flags] attribute to ResourceLocation enum.
  • IKVM.Reflection: Added support for reading/querying manifest resources that are forwarded to another assembly.
  • IKVM.Reflection: Bug fix. Module.GetManifestResourceStream() should return null (instead of throwing FileNotFoundException) for non-existing resource names.

Binaries available here: ikvmbin-7.1.4491.zip

Thursday, 19 April 2012 09:26:43 (W. Europe Daylight Time, UTC+02:00)  #    Comments [0]
# Thursday, 12 April 2012
MS12-025

This patch Tuesday Microsoft released MS12-025 that fixes approximately a zillion vulnerabilities in System.Drawing.dll.

Here's what they fixed (multiple instances of each issue):

  • Added security demands to unsafe methods.
  • Wrap handles in SafeHandle instead of using IntPtr.
  • Use checked to guard against integer overflow when calculating how many bytes to AllocHGlobal.

It's a little embarassing to have so many vulnerabilities in this old code. Luckily, silently running .NET code in the browser is becoming a thing of the past.

Thursday, 12 April 2012 12:33:30 (W. Europe Daylight Time, UTC+02:00)  #    Comments [0]
# Friday, 06 April 2012
Lang.NEXT

I'm back home after a really great Lang.NEXT conference.

The video of my talk is available on Channel 9. The slides are here.

Friday, 06 April 2012 22:24:37 (W. Europe Daylight Time, UTC+02:00)  #    Comments [0]