2007年6月13日 星期三

[轉載] AP Launch Flow in WinCE

首先你要瞭解到 task bar 是那個 process, 通常是 explorer.exe
然後你要知道它是怎麼被 launched, it is launched with following registry by kernel


[HKEY_LOCAL_MACHINE\init]
"Launch50"="explorer.exe"
"Depend50"=hex:14,00, 1e,00

LaunchXX 是代表 launch sequence,
DependXX 則是帶表當 LaunchYY 還沒 ready 前不會被 Launch
由此可知 explorer 的 Seq is 50 and it depends on Lanch20 (0x14) and Launch30 (0x1e)

Code Snippet
[HKEY_LOCAL_MACHINE\init]
"Launch20"="device.exe"
"Launch30"="gwes.exe"
"Depend30"=hex:14,00

也就是 device.exe (20/0x14) and gwes.exe (30/0x1e)
那再來就是 kernel 怎麼知道被 depend 的 process ready or not, it was deected by SignalStarted API.
基本上就是被 launch 的 App 要再適當時後 invoke SignalStarted to notify kernel it has been started and initilized.

所以可以這樣做
Assume your boot up checking apps is YourApp.exe
那可以加上以下的 registry

Code Snippet
[HKEY_LOCAL_MACHINE\init]
"Launch49"="YourApp.exe"
"Depend49"=hex:14,00, 1e,00 ; depend on devmgr and GWES as well.
"Depend50"=hex:14,00, 1e,00, 31, 00 ; and make the explorer depends on us.

這樣一來你的 App 會先被 loaded, 然後 do whatever you want, 之後假如要放行再 invoke SignalStarted, 不然就把 system shutdown if you want.
BTW, SignalStarted 會需要一個 parameter, sequence number for the apps.
假如是 Launch49 那你的 Seq number 就是 49, 當然 hard coded 不是一個好的辦法, 事實上 每個 LaunchXX 的 App 被 launched 的時後 kernel 都會把 Seq number 以 command parameter 的方式 pass 進去
也就是會由 WinMain 的 lpCmdLine 傳進來
關於 SignalStarted 的實例可以參考 $(_WINCEROOT)\public\shell\OAK\HPC\EXPLORER\MAIN\explorer.cpp or $(_WINCEROOT)\public\common\SDK\SAMPLES\CELOG\FLUSH\CELOGFLUSH\flush.c

http://forums.microsoft.com/MSDN-CHT/ShowPost.aspx?PostID=1720833&SiteID=14

沒有留言: