Has anyone used RemoteWipe in Windows Mobile?

P

PJ on Development

I just got my Treo and noting the lack of a software reset (the need
to use the stylus on the reset button really annoys me), I decided to
build my own.

The Reset and Suspend part of my little program works like a charm and
then I decided to improve a little more and add a Hard Reset feature,
which would restore the device to its factory settings.

Searching high and low on the net I found two possible ways. The first
one involved calling SetCleanRebootFlag() and then reset the device.

---- Begin Code Snippet ----
[DllImport("coredll.dll", SetLastError=true)]
public static extern void SetCleanRebootFlag();

[DllImport("coredll.dll", SetLastError=true)]
private static extern int SetSystemPowerState(IntPtr psState,
PowerStateFlags flags, uint Options);

[DllImport("coredll.dll", SetLastError=true)]
private static extern bool KernelIoControl(int dwIoControlCode, IntPtr
inBuf, int inBufSize, IntPtr outBuf, int outBufSize, ref int
bytesReturned);

public static void SoftReset()
{
if (SetSystemPowerState(IntPtr.Zero, PowerStateFlags.Reset,
0x1000) != 0)
{
int bytesReturned = 0;
if (!KernelIoControl(0x101003c, IntPtr.Zero, 0, IntPtr.Zero,
0, ref bytesReturned))
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}
}
}

public static void HardReset()
{
SetCleanRebootFlag();
SoftReset();
}
---- End Code Snippet ----


The other involved using the ConfigurationManager to process a XML
that would perform a "RemoteWipe".

---- Begin Code Snippet ----
public static void HardReset()
{
XmlDocument doc = new XmlDocument();
doc.LoadXml("<wap-provisioningdoc><characteristic
type='RemoteWipe'><parm name='doWipe' value='1'/></characteristic></
wap-provisioningdoc>");
ConfigurationManager.ProcessConfiguration(doc, true);
}
---- End Code Snippet ----


The first method didn't work because after Windows Mobile 5 it ignores
the CleanBootFlag; the second method worked... too much.

It corrupted the microSD on the device to the point that it needed to
be reformatted in order to be recognized again.

Does anyone had any experience with that?
 
S

Sasha K.

I just got my Treo and noting the lack of a software reset (the need
to use the stylus on the reset button really annoys me), I decided to
build my own.

The Reset and Suspend part of my little program works like a charm and
then I decided to improve a little more and add a Hard Reset feature,
which would restore the device to its factory settings.

Searching high and low on the net I found two possible ways. The first
one involved calling SetCleanRebootFlag() and then reset the device.

---- Begin Code Snippet ----
[DllImport("coredll.dll", SetLastError=true)]
public static extern void SetCleanRebootFlag();

[DllImport("coredll.dll", SetLastError=true)]
private static extern int SetSystemPowerState(IntPtr psState,
PowerStateFlags flags, uint Options);

[DllImport("coredll.dll", SetLastError=true)]
private static extern bool KernelIoControl(int dwIoControlCode, IntPtr
inBuf, int inBufSize, IntPtr outBuf, int outBufSize, ref int
bytesReturned);

public static void SoftReset()
{
    if (SetSystemPowerState(IntPtr.Zero, PowerStateFlags.Reset,
0x1000) != 0)
    {
        int bytesReturned = 0;
        if (!KernelIoControl(0x101003c, IntPtr.Zero, 0, IntPtr.Zero,
0, ref bytesReturned))
        {
            throw new Win32Exception(Marshal.GetLastWin32Error());
        }
    }

}

public static void HardReset()
{
    SetCleanRebootFlag();
    SoftReset();}

---- End Code Snippet ----

The other involved using the ConfigurationManager to process a XML
that would perform a "RemoteWipe".

---- Begin Code Snippet ----
public static void HardReset()
{
    XmlDocument doc = new XmlDocument();
    doc.LoadXml("<wap-provisioningdoc><characteristic
type='RemoteWipe'><parm name='doWipe' value='1'/></characteristic></
wap-provisioningdoc>");
    ConfigurationManager.ProcessConfiguration(doc, true);}

---- End Code Snippet ----

The first method didn't work because after Windows Mobile 5 it ignores
the CleanBootFlag; the second method worked... too much.

It corrupted the microSD on the device to the point that it needed to
be reformatted in order to be recognized again.

Does anyone had any experience with that?

I've never had a remote wipe operation *corrupt* my storage card, but
as part of said operation, the device is supposed to wipe it as well
as its internal memory. That's a key difference between a hard reset
and remote wipe. I could see some kind of corruption happening if your
card had encryption turned on, I suppose...

As for doing a proper hard reset, there's no reliable way to do it in
code as of WM5. Please see the following blog entry and its comments:
http://blogs.msdn.com/ce_base/archive/2006/02/09/How_OEMs_implement_Clean_Boot_on_WM5.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top