Saturday 30 January 2010

PSL Example for beginners

There are many articles about PSLs (Protected Server Libraries) and all you CE developers use the PSL mechanisms without racking your brain. Usually there's no need to care about. But some years ago when I started CEing (CE 3.0!) I faced this mechanism the first time while debugging into Win32 API.
Later, in a settop box project, we had to speed up very frequent API calls into a driver. I remembered the PSLs and with that we could speed up the application as required.

There are really good articles about PSLs and what's behind

(WinCE - Using Protected Server Libraries (PSL)) but there is no really basic example that you simply run to see how it works.

You're interested? Load the psl example directory from (Skydrive, unpack it into your BSP (or emulator) src directory and build. After that run it and check the debug output - or single-step the calls.


At the end of this blog you find the debug output you should see when running psl_client.exe on a CE6.0 emulator.

Oh, I forgot to mention a fancy set of functions that allow loading the PSL driver by application (no need to add the driver to the BuiltIn registry path).

And Here two helpful links providing some other PSL related information:
Changes in CE 6.0 (e.g. Error Handling in case of an exception)

Cheers,
Jürgen

Trade offs with PSLs moved into kernel with CE 6.0



20148 PID:3ea000a TID:3eb000a Created device subkey .\MPS0, dll psl_driver = 1
20148 PID:400002 TID:3eb000a DEVICE!RegReadActivationValues RegQueryValueEx(Drivers\Dynamic\MPS0\BusPrefix) returned 2
20211 PID:400002 TID:3eb000a RELFSD: Opening file psl_driver.dll from desktop
20259 PID:400002 TID:3eb000a OSAXST1: >>> Loading Module 'psl_driver.dll' (0x95E2A51C) at address 0xD0DF0000-0xD0DF6000 in Process 'NK.EXE' (0x8335FAA0) PB Debugger Loaded symbols for 'C:\WINCE600\OSDESIGNS\ARMEMU\ARMEMU\RELDIR\DEVICEEMULATOR_ARMV4I_DEBUG\PSL_DRIVER.DLL'
20622 PID:400002 TID:3eb000a PslTest driver : DLL Process Attach.
20627 PID:400002 TID:3eb000a PslTest driver : +MPS_Init
20629 PID:400002 TID:3eb000a ++PslTestRegister()
20629 PID:400002 TID:3eb000a PslTest driver : -MPS_Init
20629 PID:3ea000a TID:3eb000a Activated device MPS0 = d0d4c470
20629 PID:3ea000a TID:3eb000a Client: PslTestOpen()
20629 PID:3ea000a TID:3eb000a PSL successfully opened
20629 PID:400002 TID:3eb000a PslTestFoo('Client calling PSL') called
20629 PID:3ea000a TID:3eb000a PslTestFoo("Client calling PSL") returned 18
20629 PID:400002 TID:3eb000a PslTestBar('abcdefghijklmnopqrstuvwxyz{|}~?????????????????????????? ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃ', 200) called
20629 PID:3ea000a TID:3eb000a PslTestBar("abcdefghijklmnopqrstuvwxyz{|}~?????????????????????????? ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃ") returned 42
20629 PID:3ea000a TID:3eb000a Client: PslTestClose()
20629 PID:400002 TID:3eb000a PslTest driver : +MPS_Deinit
20629 PID:400002 TID:3eb000a !!!Kernel mode PSL 'PTST' de-registered!!!
20629 PID:400002 TID:3eb000a PslTest driver : -MPS_Deinit
20629 PID:400002 TID:3eb000a OSAXST1: <<< Unloading Module 'psl_driver.dll' (0x95E2A51C) at address 0xD0DF0000-0xD0DF6000 in Process 'NK.EXE' (0x8335FAA0)
PB Debugger Unloaded symbols for 'C:\WINCE600\OSDESIGNS\ARMEMU\ARMEMU\RELDIR\DEVICEEMULATOR_ARMV4I_DEBUG\PSL_DRIVER.DLL'
20631 PID:400002 TID:3eb000a PslTest driver : DLL Process Detach.
20632 PID:1b50002 TID:11f0002 [NOTIFY] HandleSystemEvent 7 /ADD MPS0:
22120 PID:1b50002 TID:11f0002 [NOTIFY] HandleSystemEvent 7 /REMOVE MPS0:
22255 PID:3ea000a TID:3eb000a Deactivated device d0d4c470 = 1
22255 PID:3ea000a TID:3eb000a Deleted device subkey .\MPS0 = 0
22255 PID:3ea000a TID:3eb000a OSAXST1: <<< Unloading Module 'coredll.dll' (0x97FF96CC) at address 0x40010000-0x40121000 in Process 'psl_client.exe' (0x95D2FAF8)
22268 PID:3ea000a TID:3eb000a OSAXST1: <<< Unloading Module 'psl_client.exe' (0x95D2FAF8) at address 0x00010000-0x00015000 in Process 'psl_client.exe' (0x95D2FAF8)



No comments: