S3C2410下WinCE6.0的启动过程详解(11)

Code
DWORD WINAPI
RunApps(
    LPVOID param
    )
{
    HMODULE hFilesys;
    DEBUGMSG (ZONE_ENTRY, (L"RunApps started\r\n"));

    CELOG_LaunchingFilesys();

    hFilesys = (HMODULE) NKLoadLibraryEx (L"filesys.dll", MAKELONG (LOAD_LIBRARY_IN_KERNEL, LLIB_NO_PAGING), NULL);

    if (hFilesys) {
        FARPROC pfnMain = GetProcAddressA (hFilesys, (LPCSTR) 2);   // WinMain of filesys
        HANDLE hFSReady, hTh;

        DEBUGCHK (pfnMain);

        hFSReady = NKCreateEvent (NULL, TRUE, FALSE, TEXT("SYSTEM/FSReady"));
        hTh = CreateKernelThread ((LPTHREAD_START_ROUTINE)pfnMain, hFilesys, THREAD_RT_PRIORITY_NORMAL, 0);

        DEBUGCHK (hTh && hFSReady);
        HNDLCloseHandle (g_pprcNK, hTh);

        // If pSignalStarted is NULL, we don't have filesys (tinykern). Don't bother waiting for it.
        if (pSignalStarted) {
            NKWaitForSingleObject (hFSReady, INFINITE);

            DEBUGCHK (SystemAPISets[SH_FILESYS_APIS]);

            // Initialize MUI-Resource loader (requires registry)
            InitMUILanguages();

            // Read system settings from registry
            InitSystemSettings ();

            // signal filesys that we're done
            (* pSignalStarted) (0);
        }
        HNDLCloseHandle (g_pprcNK, hFSReady);
   
    } else {
        RETAILMSG (1, (L"Filesys doesn't exist, no app started\r\n"));
    }

    // instead of exiting, we're make this thread cleaning dirty pages in the background.
    CleanPagesInTheBackground ();

    // should've never returned
    DEBUGCHK (0);
    NKExitThread (0);

    return 0;
}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/392d14ee7c46bd4a232f80e3976d6e8b.html