yongshi123

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

So the Today screen is just not what you want to use for a kiosk or custom shell. What is a developer to do?

Well the first step is to break VS2005. This is a complete hack! Use this at your own risk and know that this is not bullet proof. This is not supported by Microsoft. I have used this to help my customers who have needed to have a custom Shell but for a variety of reasons they could not use CE but instead resorted to Windows Mobile.

The pattern for building a kiosk or single purpose device is

  1. Build a program using Compact Framework or native using C++.
    • The program should keep the screen covered at all times
    • It should also intercept all hardware keys to make sure that no program or menu is displayed that you did not intend.
    • Harden the application using exception handling and secure code best practices.
    • Throughly test the application and even consider inviting a security firm to crack the device.
  2. It should be launched by putting a link in the \Windows\Startup directory
  3. To prevent unwanted programs from running you should
    • Running in trusted mode by signing all programs that are allowed to run with a certificate and not allowing users to be prompted for permission to run an application. This acts as a white list of programs that are authorized to run.
    • The certificate should be added to the certificate stores
    • You should revoke all unneeded certificates for example the Mobile to Mobile (M2M) Root Certificates.
    • Blacklist programs that are included in the ROM like Bubble for example.
  4. You can make a smaller attack surface however make sure you leave yourself a way into the device. To further trim down the attack surface of the device you might
    • Prevent Auto Run using security policy 2. This should not matter as Trusted Mode does apply to the program and it should be signed with your certificate. However it acts as an extra precaution.
    • Prevent the Run dialog command using the NoRunDlg registry value. This should not matter since the Clock is covered. However it acts as an extra precaution to be on the safe side.
    • Prevent someone from running applications off removable media using NoExternalExes registry value. While this should not really matter since it only affects File Explorer it is just an extra precaution to be on the safe side.
    • You could even turn off RAPI using security policy 4097.
  5. Create a Today Plugin to cover the "Today screen". This is just to make it harder on booting the device to gain access while your kiosk application loads. In addition, it acts as safety net if your kiosk application crashes.

Writing A Shell

Step one is to write the shell you want to use. You can use managed or unmanaged code. For the purposes of this I am going to stick with managed code (Hey, it is a blog entry after all). Formwithstartbar

So if I just create a Professional Windows Mobile 6 Device application with a simple form, there is just one problem. OK, one huge problem the "Start Bar" at the top is still visible! And a user can get to the "Start Menu"!

So is there a way to cover up the "Start Bar" and it turns out there is a way. A couple of ways one simple and the other not so simple.

So for the simple method just set the following properties:

  • Set FormBorderStyle to None
  • Set WindowState to Maximized
  • Set ControlBox to False
  • Set MinimizeBox to False

KioskformYou will now have a form that covers the whole screen. This will absolutely work if your application has only a few forms. The issue becomes how do I handle having my own tool bar at the top. This is harder.

It requires you to do some p/invoking. To get the declarations check out http://www.pinvoke.net.

You need two methods FindWindowW and SetWindowPos. FindWindowW will be used to find the Start Bar. SetWindowPos will be used to hide the Start Bar and when needed to show the Start Bar.

        public void HideStartBar()
        {
            IntPtr handle;

            try
            {
                // Find the handle to the Start Bar
                handle = FindWindowW("HHTaskBar", null);

                // If the handle is found then hide the start bar
                if (handle != IntPtr.Zero)
                {
                    // Hide the start bar
                    SetWindowPos(handle, 0, 0, 0, 0, 0, SWP_HIDEWINDOW);
                }
            }
            catch
            {
                MessageBox.Show("Could not hide Start Bar.");
            }
        }

        public void ShowStartBar()
        {
            IntPtr handle;

            try
            {
                // Find the handle to the Start Bar
                handle = FindWindowW("HHTaskBar", null);

                // If the handle is found then show the start bar
                if (handle != IntPtr.Zero)
                {
                    // Show the start bar
                    SetWindowPos(handle, 0, 0, 0, 240, 26, SWP_SHOWWINDOW);
                }
            }
            catch
            {
                MessageBox.Show("Could not show Start Bar.");
            }
        }

In the constructor of your own tool bar but the HideStartBar. In addition you will need to move the tool bar since by default the form is position just below the start bar at 0, 26.

        public void MyStartBar_Load()
        {
            Location = new Point(0, 0);
        }

So now you can create your own kiosk mode. Just please know that this is not supported by Microsoft and a total hack. If your kiosk application crashes you device can be compromised.

posted on 2009-05-06 14:45  yongshi123  阅读(361)  评论(0编辑  收藏  举报