Posted by: Sue Loh (with help from Andrew Rogers)

I’ve seen this question fly by a few times, so I’m blogging it.  “Now that Windows Mobile 5 is persistent store based, how are OEMs supposed to implement a clean boot?”  The idea is to reset the registry, databases and all files to produce a “clean” device, as if it came straight out of the factory.

What happens is that when the file system driver manager (FSDMGR) mounts the drivers for the persistent store, it will call an OAL IOCTL to determine whether the partition needs to be formatted.  So OEMs must tell FSDMGR to call the IOCTL, and they must implement the IOCTL.  In more detail, OEMs should do the following:

  1. Implement IOCTL_HAL_QUERY_FORMAT_PARTITION (this might mean the OALIoCtlHalQueryFormatPartition function in %_WINCEROOT%\platform\*\src\kernel\oal\ioctl.c).  FSDMGR will call this IOCTL whenever it mounts a block driver that has the “CheckForFormat” registry value set.
  2. Implement a trigger to set the value passed by OALIoCtlHalQueryFormatPartition().  For example, some devices will clear the persistent store whenever the user presses a particular key-combination during boot.  How this key-combination is chosen and implemented is up to the OEM, I believe.
  3. Add “CheckForFormat” to the storage profile in the registry.

Older mechanisms like IOCTL_HAL_GET_HIVE_CLEAN_FLAG should not be used with Windows Mobile 5.  You don’t want to get into situations where the registry is cleaned but the rest of persistent storage is not.