private static Action <BlobBuilder, PESectionLocation> CreateNativeResourceSectionSerializer(IModule module) { // Win32 resources are supplied to the compiler in one of two forms, .RES (the output of the resource compiler), // or .OBJ (the output of running cvtres.exe on a .RES file). A .RES file is parsed and processed into // a set of objects implementing IWin32Resources. These are then ordered and the final image form is constructed // and written to the resource section. Resources in .OBJ form are already very close to their final output // form. Rather than reading them and parsing them into a set of objects similar to those produced by // processing a .RES file, we process them like the native linker would, copy the relevant sections from // the .OBJ into our output and apply some fixups. var nativeResourcesOpt = module.Win32Resources; var nativeResourceSectionOpt = module.Win32ResourceSection; if (!IteratorHelper.EnumerableIsEmpty(nativeResourcesOpt) || nativeResourceSectionOpt != null) { return((sectionBuilder, location) => { if (nativeResourceSectionOpt != null) { NativeResourceWriter.SerializeWin32Resources(sectionBuilder, nativeResourceSectionOpt, location.RelativeVirtualAddress); } else { NativeResourceWriter.SerializeWin32Resources(sectionBuilder, nativeResourcesOpt, location.RelativeVirtualAddress); } }); } return(null); }
protected override void Serialize(BlobBuilder builder, SectionLocation location) { NativeResourceWriter.SerializeWin32Resources( builder, _resources, location.RelativeVirtualAddress ); }