How to Soft Reset Windows Mobile without using KernelIOControl API

I’ve just writted this snippet of code! :-)

Please compile with Microsoft Embedded Visual C++ 4.0 SP4 and run!


//
// TheResetter.cpp : Softreset your Windows Mobile PDA without KernelIOControl
//

#include "stdafx.h"
#include "tlhelp32.h"
#include "Winuser.h"


//
// The soft reset routine without using KernelIOControl
//
void SoftResetPDA ()
{
HANDLE hProcessSnap = NULL;
PROCESSENTRY32 pe32 = {0};

// Get running processes
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

// Something wrong... exiting
if (hProcessSnap == INVALID_HANDLE_VALUE)
return;

// Let's feed up the structure
pe32.dwSize = sizeof(PROCESSENTRY32);

// Asks for the first running process
if (Process32First(hProcessSnap, &pe32))
{

do
{
// Is it Shell32.exe?
if (_wcsicmp(pe32.szExeFile, _T("SHELL32.EXE")) == 0)
{
// Yeah! Open it and kill it ^_^
HANDLE hProcess;
hProcess = OpenProcess (PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID);
TerminateProcess(hProcess, 0);
}
}
while (Process32Next(hProcessSnap, &pe32));
}

// Lets close the snapshot
CloseHandle (hProcessSnap);
}

//
// The main entry point
//
// It just asks us for a confirm :-)
//
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{

if (MessageBox (NULL, L"Want to reset?" , L"Eduard'SoftReset", MB_YESNO) == IDYES)
{
SoftResetPDA();
}

return 0;
}

Related Posts with Thumbnails

Popularity: 2%

Share this Post:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

No Responses to “How to Soft Reset Windows Mobile without using KernelIOControl API”

Leave a Reply:

Name (required):
Mail (will not be published) (required):
Website:
Comment (required):
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Indirizzo per il Trackback