I am using WinCE PB 5.0 (Eval Edition) with Samsung Arm 2410

I've included the USB Bluetooth support into my Platform using the catalog
(drag and drop).

When I plug a Bluetooth USB device into my target, I am hitting a DebugCheck
in EnterCriticalSection because the critical section is not initialized.

VOID WINAPI EnterCriticalSection(LPCRITICAL_SECTION lpcs) {
#ifdef DOCHECKCS
CheckTakeCritSec(lpcs);
#elif defined (COREDLL) && !defined (SHIP_BUILD)
if (!vpcs->hCrit || (0xcccccccc == (DWORD) vpcs->hCrit)) {
RETAILMSG (1, (L"!ERROR: Calling EnterCriticalSection on a CS
(%8.8lx) that is not initialized!\r\n", lpcs));
DEBUGCHK (0);
}


Here is stack trace of problem. Run gets to USBDeviceAttach.

PUBLIC\COMMON\OAK\....\USB\usbdrv.cpp:Function - USBDeviceAttach

#if defined (DEBUG) || defined (_DEBUG) || defined (RETAILLOG)
gpsynchUsbDevice->Lock();
DebugInit();
gpsynchUsbDevice->Unlock();
#endif

IFDBG(DebugOut (DEBUG_HCI_INIT, L"[USB] BTUSB: USBDeviceAttach 0x%08x
%s\n", hDevice, szUniqueDriverId));

The DebugOut function is:
PRIVATE\WINCEOS\COMM\BLUETOOTH\SYS\btdebug.cxx:Function - DebugOut:
void DebugOut (unsigned int cMask, WCHAR *lpszFormat, ...) {

#if defined (DEBUG)
if (gulZoneMask != dpCurSettings.ulZoneMask) {
EnterCriticalSection (&gcs_debug);

At this point gcs_debug is not inialized since DebugInitialize (the function
that calls InitializeCriticalSection (&gcs_debug);) from that file
(btdebug.cxx) is never called.

The DebugInit call (in USBDeviceAttach) is from
PUBLIC\COMMON\OAK\INC\bt_tdbg.h:
inline void DebugInit()
{
gdwRefCount++;
if (!ghInstBTD)
{
ghInstBTD = LoadLibrary(L"btd.dll");
if (ghInstBTD)
{
pfnDebugOut = (DEBUGOUT )GetProcAddress(ghInstBTD, L"DebugOut");
pfnDumpBuff = (DUMPBUFF )GetProcAddress(ghInstBTD, L"DumpBuff");
}
}
}

This macro does not link in DebugInitialize. How is DebugInitialize (from
btdebug.cxx) to be called?