Coldboot (Reboot) in C# under WinCE 2.2 and Apalis T30

How can I do a coldboot (reboot) in C# with my Apalis module?

With WinCE 2.0 I could call the function KernelIoControl(…); but this doesn’t work anymore in verson 2.2

Dear @TriUrs

The only difference between V2.0 and V2.2 is a more stringent parameter verification.

  • Can you please send us the detailed code how you call the KernelIoControl() function
  • Please verify that the coldboot works when you trigger it from the built-in UpdateTool

Regards, Andy

I use the following code for a coldboot:

private static extern bool KernelIoControl(Int32 dwIoControlCode, IntPtr lpInBuf, 
Int32 nInBufSize, byte[] lpOutBuf, Int32 nOutBufSize, ref Int32 lpBytesReturned);

private int CTL_CODE(int DeviceType, int Func, int Method, int Access)
	return (DeviceType << 16) | (Access << 14) | (Func << 2) | Method;

public void ColdBoot()
	const int FILE_DEVICE_HAL = 0x101;
	const int METHOD_BUFFERED = 0;
	const int FILE_ANY_ACCESS = 0;
	int bytesReturned = 0;


	byte[] outbuff = new byte[0];
	KernelIoControl(IOCTL_HAL_REBOOT, IntPtr.Zero, 4, outbuff, nOutBufSize: 0, lpBytesReturned: ref bytesReturned);

This worked under WinCE 2.0. And I think I do the same as you suggest for other modules here:

Coldboot works with built-in UpdateTool (which I use right now always).

Dear @TriUrs
There’s a number of issues in your code:

  1. you provide a outbuff of size 1 byte ( byte[] outbuff = new byte[0];), but state it is 0 bytes in length ( nOutBufSize: 0 ). In reality this will not generate a problem. The parameter is ignored anyway. You can simplify your code by removing outbuff at all.
  2. Also the lpBytesReturned can be ignored (just to simplify the code)
  3. You provide no input buffer ( lpInBuf: IntPtr.Zero), but state it is 4 bytes in length ( nOutBufSize: 4 ). This one is causing the problem.

There’s two options to solve it. Please refer also to the developer page article:

The following two code snippets should be fine in c#

    System.UInt32 zero = 0;

    // Cold Boot
    KernelIoControl(IOCTL_HAL_REBOOT, ref zero, 4,, 0,;

    // Warm Boot
    KernelIoControl(IOCTL_HAL_REBOOT,, 0,, 0,; 

Regards, Andy

With your help it worked. Thank you.