ILSpy
ILSpy copied to clipboard
Support for WebCIL
Specification see https://github.com/dotnet/runtime/blob/main/docs/design/mono/webcil.md (basically a "firewall-evading" repackaging of Windows DLLs)
I started a discussion on how others could read that format without rolling their own implementation https://github.com/dotnet/runtime/discussions/86587 (Transport feed NuGet might be a solution sometime https://github.com/dotnet/runtime/issues/86597)
Code in question: https://github.com/dotnet/runtime/tree/main/src/libraries/Microsoft.NET.WebAssembly.Webcil/src/Webcil (WasmModuleReader is of interest)
BlazorWebCilPublishDemo.zip publish output see bin\Release\net8.0\browser-wasm\publish\wwwroot_framework
From https://devblogs.microsoft.com/dotnet/asp-net-core-updates-in-dotnet-8-preview-5/
"In .NET 8 Preview 5 we’ve improved the Webcil format by adding a standard WebAssembly wrapper. This means that Webcil files are now just WebAssembly files that have the standard .wasm extension.
Webcil is now the default packaging format when you publish a Blazor WebAssembly app. If you wish to disable the use of Webcil, you may do so by setting <WasmEnableWebcil>false</WasmEnableWebcil> in your project file."
WebCIL project moved to https://github.com/dotnet/runtime/tree/main/src/tasks/Microsoft.NET.WebAssembly.Webcil
@christophwille
Did you try to use the WebcilReader
-class from that Microsoft.NET.WebAssembly.Webcil project to read a .wasm file en extract the PE bytes?
I want to create a MetadataReference based on the PE bytes like:
MetadataReference.CreateFromImage(bytes);
At the moment, this is only a tracking issue, no PoC or other code exists.
@christophwille
FYI
I got some reverse decoding working, I can get the original PE dll bytes, however I'm missing the PE header:
So that's a blocker I think, or I still need to find a way to extract this (but I don't think its present)
Do you know a way to generate a valid PE header ?
I have to read up on WebCil again but I think I saw that no header was one of the features.
I want to create a MetadataReference based on the PE bytes like:\n\nMetadataReference.CreateFromImage(bytes);
@StefH How is your question related to ILSpy or WebCIL support in ILSpy? We don't use Roslyn's MetadataReference in ILSpy at all.
I think for most of the features in ILSpy just reading the ECMA-335 portion of the file should be sufficient, but I haven't looked into it in depth.
If you need Roslyn support for WebCIL I'd suggest asking in their repository directly. Thank you very much!
@siegfriedpammer Thanks for your reply. I'll investigate some more and report any other questions or issues to the Roslyn repository.
In case anyone is interested:
I create a project which can create a valid MetadataReference based on the Webcil WASM wrapped file : https://github.com/StefH/ProtoBufJsonConverter/tree/main/src-webcil
@StefH thanks for posting your research results, unfortunately this does not help in our case, because we need to read the WebCIL image as-is without generating a PE file.