2013年6月14日 星期五

Disable WinCE5.0 Fatal Error Dialog

參考Windows CE Base Team Blog Replacing a COREDLL component in CE 6.0

1. 建立取代原fatal error的library.

Type: Library Name: showerr

Code:

 extern "C" BOOL ShowErrThrd(DWORD dwExcpCode, DWORD dwExcpAddr)
{
    // TODO: Place code here.

   RETAILMSG(1, (TEXT("***A PROCESS CRASHED***\r\n")));

   MessageBox(NULL, L"Program Error", L"MsgBox", MB_OK);

   return 0;
}

 使用新的ShowErrThrd替代舊的ShowErrThrd function

2. 建立測試程式, 驗證是否成功disable fatal error dialog.

Code:

int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
    // TODO: Place code here.
   RETAILMSG(1, (TEXT("CRASHER!\r\n")));

   /* crash here by writting 0 to NULL */
   *((unsigned long *)NULL) = 0;

   return 0;
}

3. Replace showerr.lib.

原WinCE5.0 project增加下列的動作:

Platform|Settings…|Custom Build Actions|Pre-Sysgen|

New Custom Build action輸入
%_PROJECTROOT%\..\..\mytest_showerr\presysgen.cmd

presysgen.cmd內容為:

@echo off

pushd %_PROJECTROOT%
md oak
pushd %_PROJECTROOT%\oak
md lib
pushd %_PROJECTROOT%\oak\lib
md %_TGTCPU%
pushd %_PROJECTROOT%\oak\lib\%_TGTCPU%
md %WINCEDEBUG%
pushd %_PROJECTROOT%\..\..\showerr
build -c
pushd obj\%_TGTCPU%\%WINCEDEBUG%
copy *.* %_PROJECTROOT%\oak\lib\%_TGTCPU%\%WINCEDEBUG%\*.*
popd

4. 重新Sysgen WinCE5.0 project, 成功改變原fatal error function到自己的function.

沒有留言:

張貼留言