VOID CheckAndAddIrdaPort( _In_ PINILOCALMON pIniLocalMon ) { PLCMINIPORT pIniPort = NULL; LcmEnterSplSem(); for ( pIniPort = pIniLocalMon->pIniPort ; pIniPort && !IS_IRDA_PORT(pIniPort->pName) ; pIniPort = pIniPort->pNext ) ; LcmLeaveSplSem(); if ( pIniPort || !IsIRDAInstalled() ) return; // // Add the port to the list and write to registry // LcmCreatePortEntry(pIniLocalMon, szIRDA); }
__user_driver PLCMINIPORT LcmCreatePortEntry( __inout PINILOCALMON pIniLocalMon, __in PWSTR pPortName ) { DWORD cb = 0; PLCMINIPORT pIniPort = NULL; PLCMINIPORT pPort = NULL; size_t cchPortName = wcslen (pPortName) + 1; if (!pPortName || wcslen(pPortName) > 247) { SetLastError(ERROR_INVALID_NAME); return NULL; } cb = (DWORD) (sizeof(LCMINIPORT) + cchPortName * sizeof (WCHAR)); pIniPort = (PLCMINIPORT)AllocSplMem(cb); if( pIniPort ) { ZeroMemory(pIniPort, cb); pIniPort->pName = (LPWSTR)(pIniPort+1); (VOID) StringCchCopy (pIniPort->pName, cchPortName, pPortName); pIniPort->cb = cb; pIniPort->cRef = 0; pIniPort->pNext = 0; pIniPort->pIniLocalMon = pIniLocalMon; pIniPort->signature = IPO_SIGNATURE; pIniPort->hFile = INVALID_HANDLE_VALUE; LcmEnterSplSem(); pPort = pIniLocalMon->pIniPort; if (pPort) { while (pPort->pNext) pPort = pPort->pNext; pPort->pNext = pIniPort; } else pIniLocalMon->pIniPort = pIniPort; LcmLeaveSplSem(); } return pIniPort; }