BOOL CFDriverDemoController::InstallService(LPCTSTR pszDriverFilePath, LPCTSTR pszServiceName) { BOOL bRet = TRUE; if (NULL == m_hSCManager) { FTLASSERT(NULL == m_hDriverDemoService); API_VERIFY((m_hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) != NULL); if (m_hSCManager) { API_VERIFY_EXCEPT1((m_hDriverDemoService = ::CreateService( m_hSCManager, pszServiceName, TEXT("FDriver Demo Service"), SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER, //SERVICE_FILE_SYSTEM_DRIVER SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, pszDriverFilePath, NULL, NULL, NULL, NULL, NULL )) != NULL, ERROR_SERVICE_EXISTS); if (!m_hDriverDemoService) { m_hDriverDemoService = ::OpenService(m_hSCManager, pszServiceName, SERVICE_ALL_ACCESS); API_ASSERT(m_hDriverDemoService != NULL); } if (m_hDriverDemoService) { API_VERIFY(::StartService(m_hDriverDemoService, 0, NULL)); } else { //Create Or Open Service Fail, DWORD dwLastError = GetLastError(); API_VERIFY(CloseServiceHandle(m_hDriverDemoService)); m_hDriverDemoService = NULL; SetLastError(dwLastError); bRet = FALSE; } } } FTLTRACE(TEXT("InstallService, DriverPath=%s, m_hSCManager=0x%x\n"), pszDriverFilePath, m_hSCManager); return bRet; }
/* * Summary: Turns on a specific LED color depending on the status input. * Parameters: u32 LED status denoting which LED to turn on. * OFF = off, MINORITY = red, MAJORITY = green, PROCESSING = blue * Return: None. */ void setStatus(u32 STATUS) { if ((STATUS != OFF) && // if input is not "no LED" (STATUS != MINORITY) && // or "red LED" (STATUS != MAJORITY) && // or "green LED" (STATUS != PROCESSING)) // or "blue LED" { logNormal("setStatus: Invalid input %d\n", STATUS); // blinkcode! API_ASSERT((OFF == STATUS) || (MINORITY == STATUS) || (MAJORITY == STATUS) || (PROCESSING == STATUS), E_API_EQUAL); } for (u8 i = 0; i < 3; ++i) ledOff(LED_PIN[i]); // turn off the LEDs if (STATUS == OFF) // and if the status to display is "off" return; // keep the LEDs off ledOn(LED_PIN[STATUS]); // otherwise, turn on the appropriate LED return; }