void DoAtlCustomTraitsList() { // Declare the array, with our data type and traits class CAtlList < MyData, MyTraits > MyList; // Create some variables of our data type MyData add_item, search_item; // Add some elements to the list. add_item.ID = 1; _stprintf_s(add_item.name, _T("Rumpelstiltskin")); _stprintf_s(add_item.address, _T("One Grimm Way")); MyList.AddHead(add_item); add_item.ID = 2; _stprintf_s(add_item.name, _T("Rapunzel")); _stprintf_s(add_item.address, _T("One Grimm Way")); MyList.AddHead(add_item); add_item.ID = 3; _stprintf_s(add_item.name, _T("Cinderella")); _stprintf_s(add_item.address, _T("Two Grimm Way")); MyList.AddHead(add_item); // Create an element which will be used // to search the list for a match. search_item.ID = 2; _stprintf_s(search_item.name, _T("Don't care")); _stprintf_s(search_item.address, _T("Don't care")); // Perform a comparison by searching for a match // between any element in the list, and our // search item. This operation will use the // (overridden) comparison operator and will // find a match when the IDs are the same. POSITION i; i = MyList.Find(search_item); if (i != NULL) _tprintf_s(_T("Item found!\n")); else _tprintf_s(_T("Item not found.\n")); }
HRESULT CHdmvClipInfo::ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtDuration, CAtlList<PlaylistItem>& Playlist) { CPath Path(strPlaylistFile); rtDuration = 0; // Get BDMV folder Path.RemoveFileSpec(); Path.RemoveFileSpec(); m_hFile = CreateFile(strPlaylistFile, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY | FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (m_hFile != INVALID_HANDLE_VALUE) { BYTE Buff[100]; bool bDuplicate = false; ReadBuffer(Buff, 4); if (memcmp(Buff, "MPLS", 4)) { return CloseFile(VFW_E_INVALID_FILE_FORMAT); } ReadBuffer(Buff, 4); if ((memcmp(Buff, "0200", 4) != 0) && (memcmp(Buff, "0100", 4) != 0)) { return CloseFile(VFW_E_INVALID_FILE_FORMAT); } LARGE_INTEGER Pos; DWORD dwTemp; unsigned short nPlaylistItems; Pos.QuadPart = ReadDword(); // PlayList_start_address ReadDword(); // PlayListMark_start_address // PlayList() SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN); ReadDword(); // length ReadShort(); // reserved_for_future_use nPlaylistItems = ReadShort(); // number_of_PlayItems ReadShort(); // number_of_SubPaths Pos.QuadPart += 10; for (size_t i = 0; i < nPlaylistItems; i++) { PlaylistItem Item; SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN); Pos.QuadPart += ReadShort() + 2; ReadBuffer(Buff, 5); Item.m_strFileName.Format(_T("%s\\STREAM\\%c%c%c%c%c.M2TS"), Path, Buff[0], Buff[1], Buff[2], Buff[3], Buff[4]); ReadBuffer(Buff, 4); if (memcmp(Buff, "M2TS", 4)) { return CloseFile(VFW_E_INVALID_FILE_FORMAT); } ReadBuffer(Buff, 3); dwTemp = ReadDword(); Item.m_rtIn = 20000i64 * dwTemp / 90; // Carefull : 32->33 bits! dwTemp = ReadDword(); Item.m_rtOut = 20000i64 * dwTemp / 90; // Carefull : 32->33 bits! rtDuration += (Item.m_rtOut - Item.m_rtIn); if (Playlist.Find(Item) != NULL) { bDuplicate = true; } Playlist.AddTail(Item); //TRACE(_T("File : %s, Duration : %s, Total duration : %s\n"), strTemp, ReftimeToString (rtOut - rtIn), ReftimeToString (rtDuration)); } CloseFile(S_OK); return bDuplicate ? S_FALSE : S_OK; } return AmHresultFromWin32(GetLastError()); }
void CWebServer::OnRequest(CWebClientSocket* pClient, CStringA& hdr, CStringA& body) { CPath p(pClient->m_path); CStringA ext = p.GetExtension().MakeLower(); CStringA mime; if (ext.IsEmpty()) { mime = "text/html"; } else { m_mimes.Lookup(ext, mime); } hdr = "HTTP/1.0 200 OK\r\n"; bool fHandled = false, fCGI = false; if (!fHandled && m_webroot.IsDirectory()) { CStringA tmphdr; fHandled = fCGI = CallCGI(pClient, tmphdr, body, mime); if (fHandled) { tmphdr.Replace("\r\n", "\n"); CAtlList<CStringA> hdrlines; ExplodeMin(tmphdr, hdrlines, '\n'); POSITION pos = hdrlines.GetHeadPosition(); while (pos) { POSITION cur = pos; CAtlList<CStringA> sl; CStringA key = Explode(hdrlines.GetNext(pos), sl, ':', 2); if (sl.GetCount() < 2) { continue; } key.Trim().MakeLower(); if (key == "content-type") { mime = sl.GetTail().Trim(); hdrlines.RemoveAt(cur); } else if (key == "content-length") { hdrlines.RemoveAt(cur); } } tmphdr = Implode(hdrlines, '\n'); tmphdr.Replace("\n", "\r\n"); hdr += tmphdr + "\r\n"; } } RequestHandler rh = NULL; if (!fHandled && m_internalpages.Lookup(pClient->m_path, rh) && (pClient->*rh)(hdr, body, mime)) { if (mime.IsEmpty()) { mime = "text/html"; } CString redir; if (pClient->m_get.Lookup(_T("redir"), redir) || pClient->m_post.Lookup(_T("redir"), redir)) { if (redir.IsEmpty()) { redir = '/'; } hdr = "HTTP/1.0 302 Found\r\n" "Location: " + CStringA(redir) + "\r\n"; return; } fHandled = true; } if (!fHandled && m_webroot.IsDirectory()) { fHandled = LoadPage(0, body, pClient->m_path); } UINT resid; CStringA res; if (!fHandled && m_downloads.Lookup(pClient->m_path, resid) && (LoadResource(resid, res, _T("FILE")) || LoadResource(resid, res, _T("PNG")))) { if (mime.IsEmpty()) { mime = "application/octet-stream"; } memcpy(body.GetBufferSetLength(res.GetLength()), res.GetBuffer(), res.GetLength()); fHandled = true; } if (!fHandled) { hdr = mime == "text/html" ? "HTTP/1.0 301 Moved Permanently\r\n" "Location: /404.html\r\n" : "HTTP/1.0 404 Not Found\r\n"; return; } if ((mime == "text/html" || mime == "text/javascript") && !fCGI) { if (mime == "text/html") { hdr += "Expires: Thu, 19 Nov 1981 08:52:00 GMT\r\n" "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\n" "Pragma: no-cache\r\n"; CStringA debug; if (AfxGetAppSettings().fWebServerPrintDebugInfo) { debug += "<br><hr>\r\n"; debug += "<div id=\"debug\">"; CString key, value; POSITION pos; pos = pClient->m_hdrlines.GetStartPosition(); while (pos) { pClient->m_hdrlines.GetNextAssoc(pos, key, value); debug += "HEADER[" + key + "] = " + value + "\r\n"; } debug += "cmd: " + pClient->m_cmd + "\r\n"; debug += "path: " + pClient->m_path + "\r\n"; debug += "ver: " + pClient->m_ver + "\r\n"; pos = pClient->m_get.GetStartPosition(); while (pos) { pClient->m_get.GetNextAssoc(pos, key, value); debug += "GET[" + key + "] = " + value + "\r\n"; } pos = pClient->m_post.GetStartPosition(); while (pos) { pClient->m_post.GetNextAssoc(pos, key, value); debug += "POST[" + key + "] = " + value + "\r\n"; } pos = pClient->m_cookie.GetStartPosition(); while (pos) { pClient->m_cookie.GetNextAssoc(pos, key, value); debug += "COOKIE[" + key + "] = " + value + "\r\n"; } pos = pClient->m_request.GetStartPosition(); while (pos) { pClient->m_request.GetNextAssoc(pos, key, value); debug += "REQUEST[" + key + "] = " + value + "\r\n"; } debug += "</div>"; } body.Replace("[debug]", debug); } body.Replace("[browserpath]", "/browser.html"); body.Replace("[commandpath]", "/command.html"); body.Replace("[controlspath]", "/controls.html"); body.Replace("[indexpath]", "/index.html"); body.Replace("[path]", CStringA(pClient->m_path)); body.Replace("[setposcommand]", CMD_SETPOS); body.Replace("[setvolumecommand]", CMD_SETVOLUME); body.Replace("[wmcname]", "wm_command"); // TODO: add more general tags to replace } // gzip if (AfxGetAppSettings().fWebServerUseCompression && hdr.Find("Content-Encoding:") < 0) do { CString accept_encoding; pClient->m_hdrlines.Lookup(_T("accept-encoding"), accept_encoding); accept_encoding.MakeLower(); CAtlList<CString> sl; ExplodeMin(accept_encoding, sl, ','); if (!sl.Find(_T("gzip"))) { break; } CHAR path[_MAX_PATH], fn[_MAX_PATH]; if (!GetTempPathA(_MAX_PATH, path) || !GetTempFileNameA(path, "mpc_gz", 0, fn)) { break; } gzFile gf = gzopen(fn, "wb9"); if (!gf || gzwrite(gf, (LPVOID)(LPCSTR)body, body.GetLength()) != body.GetLength()) { if (gf) { gzclose(gf); } DeleteFileA(fn); break; } gzclose(gf); FILE* f = NULL; if (fopen_s(&f, fn, "rb")) { DeleteFileA(fn); break; } fseek(f, 0, 2); CHAR* s = body.GetBufferSetLength(ftell(f)); fseek(f, 0, 0); int len = (int)fread(s, 1, body.GetLength(), f); ASSERT(len == body.GetLength()); #ifndef _DEBUG UNREFERENCED_PARAMETER(len); #endif fclose(f); DeleteFileA(fn); hdr += "Content-Encoding: gzip\r\n"; } while (0); CStringA content; content.Format( "Content-Type: %s\r\n" "Content-Length: %d\r\n", mime, body.GetLength()); hdr += content; }
void CWebServer::OnRequest(CWebClientSocket* pClient, CStringA& hdr, CStringA& body) { CPath p(AToT(pClient->m_path)); CStringA ext = p.GetExtension().MakeLower(); CStringA mime; if (ext.IsEmpty()) { mime = "text/html"; } else { m_mimes.Lookup(ext, mime); } hdr = "HTTP/1.0 200 OK\r\n"; bool fHandled = false, fCGI = false; if (!fHandled && m_webroot.IsDirectory()) { CStringA tmphdr; fHandled = fCGI = CallCGI(pClient, tmphdr, body, mime); if (fHandled) { tmphdr.Replace("\r\n", "\n"); CAtlList<CStringA> hdrlines; ExplodeMin(tmphdr, hdrlines, '\n'); POSITION pos = hdrlines.GetHeadPosition(); while (pos) { POSITION cur = pos; CAtlList<CStringA> sl; CStringA key = Explode(hdrlines.GetNext(pos), sl, ':', 2); if (sl.GetCount() < 2) { continue; } key.Trim().MakeLower(); if (key == "content-type") { mime = sl.GetTail().Trim(); hdrlines.RemoveAt(cur); } else if (key == "content-length") { hdrlines.RemoveAt(cur); } } tmphdr = Implode(hdrlines, "\r\n"); hdr += tmphdr + "\r\n"; } } RequestHandler rh = NULL; if (!fHandled && m_internalpages.Lookup(pClient->m_path, rh) && (pClient->*rh)(hdr, body, mime)) { if (mime.IsEmpty()) { mime = "text/html"; } CString redir; if (pClient->m_get.Lookup("redir", redir) || pClient->m_post.Lookup("redir", redir)) { if (redir.IsEmpty()) { redir = '/'; } hdr = "HTTP/1.0 302 Found\r\n" "Location: " + CStringA(redir) + "\r\n"; return; } fHandled = true; } if (!fHandled && m_webroot.IsDirectory()) { fHandled = LoadPage(0, body, UTF8To16(pClient->m_path)); } UINT resid; if (!fHandled && m_downloads.Lookup(pClient->m_path, resid) && (LoadResource(resid, body, _T("FILE")) || LoadResource(resid, body, _T("PNG")))) { if (mime.IsEmpty()) { mime = "application/octet-stream"; } fHandled = true; } if (!fHandled) { hdr = mime == "text/html" ? "HTTP/1.0 301 Moved Permanently\r\n" "Location: /404.html\r\n" : "HTTP/1.0 404 Not Found\r\n"; return; } if ((mime == "text/html" || mime == "text/javascript") && !fCGI) { if (mime == "text/html") { hdr += "Expires: Thu, 19 Nov 1981 08:52:00 GMT\r\n" "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\n" "Pragma: no-cache\r\n"; CStringA debug; if (AfxGetAppSettings().fWebServerPrintDebugInfo) { debug += "<br><hr>\r\n"; debug += "<div id=\"debug\">"; CStringA key; POSITION pos; { CStringA value; pos = pClient->m_hdrlines.GetStartPosition(); while (pos) { pClient->m_hdrlines.GetNextAssoc(pos, key, value); debug += "HEADER[" + key + "] = " + value + "\r\n"; } } debug += "cmd: " + pClient->m_cmd + "\r\n"; debug += "path: " + pClient->m_path + "\r\n"; debug += "ver: " + pClient->m_ver + "\r\n"; { CString value; pos = pClient->m_get.GetStartPosition(); while (pos) { pClient->m_get.GetNextAssoc(pos, key, value); debug += "GET[" + HtmlSpecialChars(key) + "] = " + HtmlSpecialChars(UTF8(value)) + "\r\n"; } pos = pClient->m_post.GetStartPosition(); while (pos) { pClient->m_post.GetNextAssoc(pos, key, value); debug += "POST[" + HtmlSpecialChars(key) + "] = " + HtmlSpecialChars(UTF8(value)) + "\r\n"; } pos = pClient->m_cookie.GetStartPosition(); while (pos) { pClient->m_cookie.GetNextAssoc(pos, key, value); debug += "COOKIE[" + HtmlSpecialChars(key) + "] = " + HtmlSpecialChars(UTF8(value)) + "\r\n"; } pos = pClient->m_request.GetStartPosition(); while (pos) { pClient->m_request.GetNextAssoc(pos, key, value); debug += "REQUEST[" + HtmlSpecialChars(key) + "] = " + HtmlSpecialChars(UTF8(value)) + "\r\n"; } } debug += "</div>"; } body.Replace("[debug]", debug); } body.Replace("[browserpath]", "/browser.html"); body.Replace("[commandpath]", "/command.html"); body.Replace("[controlspath]", "/controls.html"); body.Replace("[indexpath]", "/index.html"); body.Replace("[path]", pClient->m_path); body.Replace("[setposcommand]", CMD_SETPOS); body.Replace("[setvolumecommand]", CMD_SETVOLUME); body.Replace("[wmcname]", "wm_command"); // TODO: add more general tags to replace } // gzip if (AfxGetAppSettings().fWebServerUseCompression && !body.IsEmpty() && hdr.Find("Content-Encoding:") < 0 && ext != ".png" && ext != ".jpeg" && ext != ".gif") do { CStringA accept_encoding; pClient->m_hdrlines.Lookup("accept-encoding", accept_encoding); accept_encoding.MakeLower(); CAtlList<CStringA> sl; ExplodeMin(accept_encoding, sl, ','); if (!sl.Find("gzip")) { break; } // Allocate deflate state z_stream strm; strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; int ret = deflateInit2(&strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 15 + 16, 8, Z_DEFAULT_STRATEGY); if (ret != Z_OK) { ASSERT(0); break; } int gzippedBuffLen = body.GetLength(); BYTE* gzippedBuff = DEBUG_NEW BYTE[gzippedBuffLen]; // Compress strm.avail_in = body.GetLength(); strm.next_in = (Bytef*)(LPCSTR)body; strm.avail_out = gzippedBuffLen; strm.next_out = gzippedBuff; ret = deflate(&strm, Z_FINISH); if (ret != Z_STREAM_END || strm.avail_in != 0) { ASSERT(0); deflateEnd(&strm); delete [] gzippedBuff; break; } gzippedBuffLen -= strm.avail_out; memcpy(body.GetBufferSetLength(gzippedBuffLen), gzippedBuff, gzippedBuffLen); // Clean up deflateEnd(&strm); delete [] gzippedBuff; hdr += "Content-Encoding: gzip\r\n"; } while (0); CStringA content; content.Format( "Content-Type: %s\r\n" "Content-Length: %d\r\n", mime, body.GetLength()); hdr += content; }
static BOOL ValidateItem(int index, BOOL bNewState, BOOL bDisplayErrors) { ServiceItem* pSvcItem = NULL; LVITEM truc = {}; truc.mask = LVIF_PARAM; truc.iItem = index; ListView_GetItem(hServicesListCtrl, &truc); // The lParam member must be valid. pSvcItem = reinterpret_cast<ServiceItem*>(truc.lParam); if (!pSvcItem) return FALSE; // // Allow modifications only if the service is not a required service for the system, // or allow only the activation of a disabled required service. // BOOL bOldState = !!(ListView_GetCheckState(hServicesListCtrl, truc.iItem /* == index */) % 2); if ( !pSvcItem->m_bIsRequired || (pSvcItem->m_bIsRequired && !pSvcItem->m_bIsEnabled && bOldState == FALSE && bNewState == TRUE) ) { if (bOldState == bNewState) return FALSE; ListView_SetCheckState(hServicesListCtrl, index, bNewState); if (pSvcItem->m_bIsEnabled) // Enabled service. { if (bNewState == FALSE) // To be deactivated. { userModificationsList.AddTail(pSvcItem->m_lpszSvcName); } else if (bNewState == TRUE) // To be reactivated { POSITION it = userModificationsList.Find(pSvcItem->m_lpszSvcName); if (it) { userModificationsList.RemoveAt(it); } else { OutputDebugString(_T("(1) \"WTF: What The Fukhurmajalmahamadahaldeliya ?!\" (The Dictator, Sacha Baron Cohen)\n")); } } } else // Disabled service. { if (bNewState == TRUE) // To be activated. { userModificationsList.AddTail(pSvcItem->m_lpszSvcName); } else if (bNewState == FALSE) // To be redeactivated { POSITION it = userModificationsList.Find(pSvcItem->m_lpszSvcName); if (it) { userModificationsList.RemoveAt(it); } else { OutputDebugString(_T("(2) \"WTF: What The Fukhurmajalmahamadahaldeliya ?!\" (The Dictator, Sacha Baron Cohen)\n")); } } } return TRUE; } else { if (bDisplayErrors) { DialogBoxW(hInst, MAKEINTRESOURCEW(IDD_REQUIRED_SERVICES_DISABLING_DIALOG), hServicesPage /* hMainWnd */, RequiredServicesDisablingDialogWndProc); } return FALSE; } }
static void AddService(SC_HANDLE hSCManager, LPENUM_SERVICE_STATUS_PROCESS Service, BOOL bHideOSVendorServices) { // // Retrieve a handle to the service. // SC_HANDLE hService = OpenServiceW(hSCManager, Service->lpServiceName, SERVICE_QUERY_CONFIG); if (hService == NULL) return; DWORD dwBytesNeeded = 0; QueryServiceConfigW(hService, NULL, 0, &dwBytesNeeded); // if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) LPQUERY_SERVICE_CONFIG lpServiceConfig = (LPQUERY_SERVICE_CONFIG)MemAlloc(0, dwBytesNeeded); if (!lpServiceConfig) { CloseServiceHandle(hService); return; } QueryServiceConfigW(hService, lpServiceConfig, dwBytesNeeded, &dwBytesNeeded); // // Get the service's vendor... // LPWSTR lpszVendor = NULL; { // Isolate only the executable path, without any arguments. // TODO: Correct at the level of CmdLineToArgv the potential bug when lpszFilename == NULL. #if 0 // Disabled until CmdLineToArgv is included unsigned int argc = 0; LPWSTR* argv = NULL; CmdLineToArgv(lpServiceConfig->lpBinaryPathName, &argc, &argv, L" \t"); if (argc >= 1 && argv[0]) lpszVendor = GetExecutableVendor(argv[0]); #else // Hackish solution taken from the original srvpage.c. // Will be removed after CmdLineToArgv is introduced. WCHAR FileName[MAX_PATH]; memset(&FileName, 0, sizeof(FileName)); if (wcscspn(lpServiceConfig->lpBinaryPathName, L"\"")) { wcsncpy(FileName, lpServiceConfig->lpBinaryPathName, wcscspn(lpServiceConfig->lpBinaryPathName, L" ") ); } else { wcscpy(FileName, lpServiceConfig->lpBinaryPathName); } lpszVendor = GetExecutableVendor(FileName); #endif if (!lpszVendor) lpszVendor = LoadResourceString(hInst, IDS_UNKNOWN); #if 0 MemFree(argv); #endif } // ...and display or not the Microsoft / ReactOS services. BOOL bContinue = TRUE; if (bHideOSVendorServices) { if (FindSubStrI(lpszVendor, bIsWindows ? IDS_MICROSOFT : IDS_REACTOS)) bContinue = FALSE; } if (bContinue) { BOOL bIsServiceEnabled = (lpServiceConfig->dwStartType != SERVICE_DISABLED); BOOL bAddServiceToList = FALSE; BOOL bIsModifiedService = FALSE; RegistryDisabledServiceItemParams params = {}; // // Try to look into the user modifications list... // POSITION it = userModificationsList.Find(Service->lpServiceName); if (it) { bAddServiceToList = TRUE; bIsModifiedService = TRUE; } // // ...if not found, try to find if the disabled service is in the registry. // if (!bAddServiceToList) { if (!bIsServiceEnabled) { QUERY_REGISTRY_KEYS_TABLE KeysQueryTable[2] = {}; KeysQueryTable[0].QueryRoutine = GetRegistryKeyedDisabledServicesQueryRoutine; KeysQueryTable[0].EntryContext = ¶ms; RegQueryRegistryKeys(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services", KeysQueryTable, Service->lpServiceName); bAddServiceToList = params.bIsPresent; if (bIsWindows && bIsPreVistaOSVersion && !bAddServiceToList) { QUERY_REGISTRY_VALUES_TABLE ValuesQueryTable[2] = {}; ValuesQueryTable[0].QueryRoutine = GetRegistryValuedDisabledServicesQueryRoutine; ValuesQueryTable[0].EntryContext = ¶ms; RegQueryRegistryValues(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services", ValuesQueryTable, Service->lpServiceName); bAddServiceToList = params.bIsPresent; } } else { bAddServiceToList = TRUE; } } if (bAddServiceToList) { // // Check if service is required by the system. // BOOL bIsRequired = FALSE; dwBytesNeeded = 0; QueryServiceConfig2(hService, SERVICE_CONFIG_FAILURE_ACTIONS, NULL, 0, &dwBytesNeeded); // if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) LPSERVICE_FAILURE_ACTIONS lpServiceFailureActions = (LPSERVICE_FAILURE_ACTIONS)MemAlloc(0, dwBytesNeeded); if (!lpServiceFailureActions) { MemFree(lpszVendor); MemFree(lpServiceConfig); CloseServiceHandle(hService); return; } QueryServiceConfig2(hService, SERVICE_CONFIG_FAILURE_ACTIONS, (LPBYTE)lpServiceFailureActions, dwBytesNeeded, &dwBytesNeeded); // In Microsoft's MSConfig, things are done just like that!! (extracted string values from msconfig.exe) if ( ( wcsicmp(Service->lpServiceName, L"rpcss" ) == 0 || wcsicmp(Service->lpServiceName, L"rpclocator") == 0 || wcsicmp(Service->lpServiceName, L"dcomlaunch") == 0 ) || ( lpServiceFailureActions && (lpServiceFailureActions->cActions >= 1) && (lpServiceFailureActions->lpsaActions[0].Type == SC_ACTION_REBOOT) ) ) // We add also this test, which corresponds to real life. { bIsRequired = TRUE; } MemFree(lpServiceFailureActions); // // Add the service into the list. // LVITEM item = {}; item.mask = LVIF_TEXT | LVIF_PARAM; item.pszText = Service->lpDisplayName; item.lParam = reinterpret_cast<LPARAM>(new ServiceItem(Service->lpServiceName, bIsServiceEnabled, bIsRequired)); item.iItem = ListView_InsertItem(hServicesListCtrl, &item); if (bIsRequired) { LPWSTR lpszYes = LoadResourceString(hInst, IDS_YES); ListView_SetItemText(hServicesListCtrl, item.iItem, 1, lpszYes); MemFree(lpszYes); } ListView_SetItemText(hServicesListCtrl, item.iItem, 2, lpszVendor); LPWSTR lpszStatus = LoadResourceString(hInst, ((Service->ServiceStatusProcess.dwCurrentState == SERVICE_STOPPED) ? IDS_SERVICES_STATUS_STOPPED : IDS_SERVICES_STATUS_RUNNING)); ListView_SetItemText(hServicesListCtrl, item.iItem, 3, lpszStatus); MemFree(lpszStatus); if (!bIsServiceEnabled) { LPWSTR lpszUnknown = LoadResourceString(hInst, IDS_UNKNOWN); LPWSTR lpszDisableDate = FormatDateTime(¶ms.time); ListView_SetItemText(hServicesListCtrl, item.iItem, 4, (lpszDisableDate ? lpszDisableDate : lpszUnknown)); FreeDateTime(lpszDisableDate); MemFree(lpszUnknown); } ListView_SetCheckState(hServicesListCtrl, item.iItem, (!bIsModifiedService ? bIsServiceEnabled : !bIsServiceEnabled)); } } MemFree(lpszVendor); MemFree(lpServiceConfig); CloseServiceHandle(hService); return; }