Writeable code sections got you down? Fear no more!

Virtual Memory changes included in Windows Mobile 6.1 can relocate read-only code sections out of Slot 0 and into a higher address range. This change was taken to relieve pressure from our coveted, read-write Slot 0. This change will be transparent to most developers since code sections are by default, read-only and do not assume code sections will be adjacent.

 

However, if you are intentionally including the “W” (write) attribute on a code section and your DLL is greater than 64kb, then you may be affected. Luckily, dumpbin.exe already knows to display a warning:

 

C:\WM612\release>dumpbin myDll.dll

 

60000020 flags

         Code

  Execute Read

DUMPBIN : warning LNK4078: multiple '.text' sections found with different attributes (E0000020)

SECTION HEADER #2

E0000020 flags

         Code

         Execute Read Write

There is nothing programmatically wrong with the above and most modules will work without modification. However, if you are seeing some strange results in recent versions of Windows Mobile, you may want to try and restrict your module to Slot 0 by adding the following registry key:

[HKEY_LOCAL_MACHINE\System\Loader\LoadModuleLow]

    "MyDll.dll"=dword:1 << change DLL name to match

 

Please note that using the above key will force your entire module into Slot 0 and prevent other modules from loading in that slot. The above registry setting should be used with caution and only for modules with a writeable code section.

Comments