[Mono-dev] My findings about PocketPC/Compact Framework apps.
Corwin Light-Williams
mess at thethirdman.org
Mon Dec 12 19:18:30 EST 2005
Alright, even more interestingly, DotGNU Portable.NET's cscc also
compiles apps that work just fine on PocketPC, and the obvious
difference is, once again, the order of the pieces in the header. Is
there anybody who can help me modify gmcs to have a different header?
I really would like to use gmcs, but I can't if it doesn't generate
valid PEFiles. :)
Thanks!
Corwin
On Dec 6, 2005, at 2:35 PM, Corwin Light-Williams wrote:
> I've perused the lists and bugzilla, and this topic comes up every
> now and then- sorry to rehash it.
>
> I want to target .NET Compact Framework 2.0 on Windows Mobile 5,
> using mono as my compiler. If you simply compile an app using mcs/
> gmcs on the command line, it doesn't work. Fine, I maybe expected
> that. So I decompiled it using Microsoft's ildasm- the output was
> fine. I then recompiled it using Microsoft's ilasm, and it worked!
> I deduced (as others have) that it must be in the PEFile part of
> the app.
>
> So I compiled a version of Mono's ilasm, using GMCS and the 2.0
> gac, and lo and behold, I can do the same thing I did with
> Microsoft's tools- disassemble and reassemble, and generate an app
> that runs on PocketPC. Except ilasm doesn't seem to link DLLs
> properly, or maybe my patched build was wrong- I could make an app
> that linked against system libraries work, but not an app that
> links against the .NETCF's System.Windows.Forms.dll. Damn.
>
> So a little poking around reveals that gmcs and ilasm use two
> different PEFile writers- ilasm uses PEAPI.PEFile, whereas gmcs
> uses the C stuff, natively referenced through
> System.Reflection.Emit. Aha!
>
> I then made 4 different EXE files, from the same source.
>
> - One compiled using gmcs.
> - One compiled using csc.
> - One compiled using Microsoft ILASM to compile a decompiled EXE.
> - One compiled using Mono ILASM to compile a decompiled EXE.
>
> They all are slightly different- a byte here and there. But guess
> what gmcs had different that the latter three had all in common?
> Here's GMCS's text section:
>
> IAT
> CLI Header
> -> ImportTables
> -> EntryPoint
> Bytecodes
> Strings, Guid, Blob, etc
> metadata
> strongname
>
> Here's what the other three have:
>
> IAT
> CLI Header
> Bytecodes
> Strings, Guid, Blob, etc
> metadata
> strongname
> -> ImportTables
> -> EntryPoint
>
> So I patched reflection.c to place the ImportTables a little later,
> which still (to my surprise) generated an app that ran on Windows.
> When I took it to the PocketPC, sure enough, it ran without
> complaint or crash, although sadly it did nothing.
>
> I feel like I'm close here, and I'm wondering if anyone has any
> comments or help.
>
> Thanks for reading a long message!
>
> Corwin
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
More information about the Mono-devel-list
mailing list