Powered By Blogger
Wednesday, June 3, 2009

Enabling agressive scanning for Wifi

To enable aggressive scanning for wifi network (preferred or non-preferred ones) in Wireless Zero Configuration in Windows CE, use this registry setting:

[HKEY_LOCAL_MACHINE\Comm\WiFi]
ScanInterval: dword:5
This will set WZC to scan for network every 5 seconds. By default, it is set to 60 seconds. Try tuning this value as per your requirement.

Thursday, April 23, 2009

Creating Cab Files

I found a really cool utility for creating CAB files for a windows ce device - Quick Cab.
Check it out.

http://forum.xda-developers.com/showthread.php?t=400221

Wednesday, April 15, 2009

War of the worlds

Guys check out the heated arguement in this post :)

http://blogs.msdn.com/mikehall/archive/2005/01/13/352470.aspx

Wednesday, April 8, 2009

Keyboard Hooking in Windows CE 6.0

If you want to monitor system wide keyboard events from an application, then we need to use keyboard hooking using the SetWindowsHookEx & UnhookWindowsHookEx functions. Since we need a system wide hook, we need to place the callback functions in a DLL.




typedef struct {
DWORD vkCode;
DWORD scanCode;
DWORD flags;
DWORD time;
ULONG_PTR dwExtraInfo;
} KBDLLHOOKSTRUCT, *PKBDLLHOOKSTRUCT;
.....

VOID InitHook ()
{
.....
SetWindowsHookEx(WH_KEYBOARD_LL,hookproc,hinstance,NULL);
.....
}
....
HOOKDLL_API LRESULT CALLBACK hookproc(int ncode,WPARAM wparam,LPARAM lparam)
{
UINT uMsg = 0;
if(ncode>=0)
{
if((lparam & 0x80000000) == 0x00000000)//Check whether key was pressed(not released).
{
switch((((KBDLLHOOKSTRUCT*)lparam)->vkCode))
{
case VK_F1:
RETAILMSG(1,(TEXT("TRAPPED, F1\r\n")));
uMsg = WM_USER+755;
break;

case VK_F2:
RETAILMSG(1,(TEXT("TRAPPED, F2\r\n")));
uMsg = WM_USER+756;
break;

case VK_F3:
RETAILMSG(1,(TEXT("TRAPPED, F3\r\n")));
uMsg = WM_USER+757;
break;

case VK_F4:
RETAILMSG(1,(TEXT("TRAPPED, F4\r\n")));
uMsg = WM_USER+758;
break;
}

}
}
return ( CallNextHookEx(hook,ncode,wparam,lparam) );//pass control to next hook in the hook chain.
}


But in Wince 6.0, these APIs have been removed, but is still present in coredll. Hence, they can be accessed using LoadLibrary and GetProcAddress functions.


N.B: Special Thanks Prathamesh S Kulkarni on his article on keyboard hooking in code project.

Hi :)
First of all sorry guys, for the leave of absence, I have been busy lately.

In one of the tasks assigned for me, I had to bring the system back in to ON mode from idle, when any bluetooth activity happens. Activity in the sense, authentication request or a file transfer start etc.

File transfer or any other requests (except for pin request), can be tackled my monitoring the bluetooth stack events. But an authentication request cannot be obtained using the same. The the authentication ui for bluetooth is located in

WINCE600\PUBLIC\COMMON\OAK\DRIVERS\BLUETOOTH\SAMPLE\BTSVC

Its a service (BTSVC), and can modified directly or cloned By AuthenticationDlgProc and the corresponding dialog in the resource file, we can easily modify the behaviour during a bluetooth authentication request. Or a new application can be provided with the same functionality, do doing so , this service must be removed first as only one type of authentication ui will be allowed at a time.

Wednesday, February 25, 2009

Monitoring for bluetooth events

Here is a sample code for monitoring incoming connection and authentication requests on a microsoft bluetooth stack:



DWORD BTActivityMonitor ( LPVOID lpParam )
{
MSGQUEUEOPTIONS mqOptions;
memset (&mqOptions, 0, sizeof(mqOptions));

mqOptions.dwFlags = 0;
mqOptions.dwSize = sizeof(mqOptions);
mqOptions.dwMaxMessages = 10;
mqOptions.cbMaxMessage = sizeof(BTEVENT);
mqOptions.bReadAccess = TRUE;

// Create message queue to receive BT events on
HANDLE hMsgQ = CreateMsgQueue(NULL, &mqOptions);
if (! hMsgQ) {
wprintf(L"Error creating message queue.\r\n");
goto exit_bt;
}

// Listen for all Bluetooth notifi cations
HANDLE hBTNotif = RequestBluetoothNotifications(
BTE_CLASS_CONNECTIONS | BTE_CLASS_DEVICE | BTE_CLASS_PAIRING,
hMsgQ);
if (! hBTNotif) {
wprintf(L"Error in call to RequestBluetoothNotifications.\r\n");
goto exit_bt;
}

wprintf(L"Waiting for Bluetooth notifications...\r\n");

while (FALSE == bStop) {
DWORD dwWait = WaitForSingleObject (hMsgQ, INFINITE);
if (WAIT_OBJECT_0 == dwWait) {
//
// We have got a Bluetooth event!
//

BTEVENT btEvent;
DWORD dwFlags = 0;
DWORD dwBytesRead = 0;

BOOL fRet = ReadMsgQueue (hMsgQ, &btEvent, sizeof(BTEVENT), &dwBytesRead, 10, &dwFlags);
if (! fRet) {
wprintf(L"Error - Failed to read message from queue!\r\n");
goto exit_bt;
} else {
wprintf(L"----------------------------------------\r\n");
wprintf(L"Got event with id=%d.\r\n", btEvent.dwEventId);
}
} else {
wprintf(L"Error - Unexpected return value from WaitForSingleObject!\r\n");
goto exit_bt;
}

}


exit_bt:
// Stop listening for Bluetooth notifications
if (hBTNotif && (! StopBluetoothNotifications(hBTNotif))) {
wprintf(L"Warning! StopBluetoothNotifications returned FALSE.\r\n");
}

if (hMsgQ) {
CloseMsgQueue(hMsgQ);
}

return 0;
}

Tuesday, January 6, 2009

Cloning Public Code

Here is a nice article by Bruce Eitman for cloning public code

https://geekswithblogs.net/BruceEitman/archive/2008/07/02/platform-builder-clone-public-code.aspx