|
@@ -133,24 +133,28 @@ typedef struct _RawSMBIOSData
|
|
|
|
|
|
void ResourceWatcherFSM::GetAutoStartFile(std::string& userDirPath, std::vector<std::string>& userDirFiles, std::string& pubDirPath, std::vector<std::string>& pubDirFiles)
|
|
|
{
|
|
|
- CSimpleStringA startMenuPublicPath(STARTUP_DIR_FULL_PATH);
|
|
|
- auto arr = fileutil_get_sub_files(startMenuPublicPath);
|
|
|
- pubDirPath = startMenuPublicPath.GetData();
|
|
|
- if (arr != NULL) {
|
|
|
- for (int i = 0; i < arr->nelts; ++i) {
|
|
|
- char* file = ARRAY_IDX(arr, i, char*);
|
|
|
- char* filename = strrchr(file, '\\');
|
|
|
- if (filename != NULL) { filename += 1; }
|
|
|
- else { filename = file; }
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("filename:%s", filename);
|
|
|
- pubDirFiles.push_back(std::string(filename));
|
|
|
+ CSimpleStringA startMenuPublicPath(true);
|
|
|
+ GetCommStartupDirectory(startMenuPublicPath);
|
|
|
+ if (!startMenuPublicPath.IsNullOrEmpty()) {
|
|
|
+ auto arr = fileutil_get_sub_files(startMenuPublicPath);
|
|
|
+ pubDirPath = startMenuPublicPath.GetData();
|
|
|
+ if (arr != NULL) {
|
|
|
+ for (int i = 0; i < arr->nelts; ++i) {
|
|
|
+ char* file = ARRAY_IDX(arr, i, char*);
|
|
|
+ char* filename = strrchr(file, '\\');
|
|
|
+ if (filename != NULL) { filename += 1; }
|
|
|
+ else { filename = file; }
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("filename:%s", filename);
|
|
|
+ pubDirFiles.push_back(std::string(filename));
|
|
|
+ }
|
|
|
+ toolkit_array_free2(arr);
|
|
|
}
|
|
|
- toolkit_array_free2(arr);
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
CSimpleStringA startMenuFullPath(true);
|
|
|
GetUserStartupDirectory(startMenuFullPath);
|
|
|
if (!startMenuFullPath.IsNullOrEmpty()) {
|
|
|
- arr = fileutil_get_sub_files(startMenuFullPath);
|
|
|
+ auto arr = fileutil_get_sub_files(startMenuFullPath);
|
|
|
userDirPath = startMenuFullPath.GetData();
|
|
|
if (arr != NULL) {
|
|
|
for (int i = 0; i < arr->nelts; ++i) {
|
|
@@ -399,13 +403,9 @@ void ResourceWatcherFSM::TriggerAtStatusChanged(bool bMStatus)
|
|
|
RecoverDDEClipboardEnable();
|
|
|
}
|
|
|
GetEntityBase()->GetFunction()->PostThreadPoolTask(new DetectSoftwareInstallStatusTask(this));
|
|
|
- GetEntityBase()->GetFunction()->PostThreadPoolTask(new UploadMonitorInfoTask(this));
|
|
|
- AlarmSystemBasicInfo();
|
|
|
-#else
|
|
|
- AlarmSystemBasicInfo();
|
|
|
#endif //RVC_OS_LINUX
|
|
|
+ AlarmSystemBasicInfo();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1526,7 +1526,7 @@ ErrorCodeEnum ResourceWatcherFSM::CreateLinkFile(const CSimpleStringA& szStartAp
|
|
|
{
|
|
|
hr = pShellLink->SetIconLocation(szIconPath, 0);
|
|
|
if (!SUCCEEDED(hr)) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("SetIconLocation failed: %d", hr);
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("SetIconLocation failed: %u", hr);
|
|
|
}
|
|
|
}
|
|
|
IPersistFile* pPersistFile;
|
|
@@ -1539,25 +1539,25 @@ ErrorCodeEnum ResourceWatcherFSM::CreateLinkFile(const CSimpleStringA& szStartAp
|
|
|
result = Error_Succeed;
|
|
|
}
|
|
|
else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Save failed: %d", hr);
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Save failed: %u", hr);
|
|
|
}
|
|
|
pPersistFile->Release();
|
|
|
}
|
|
|
else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("QueryInterface failed: %d", hr);
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("QueryInterface failed: %u", hr);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("SetWorkingDirectory failed: %d", hr);
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("SetWorkingDirectory failed: %u", hr);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("SetPath failed: %d", hr);
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("SetPath failed: %u", hr);
|
|
|
}
|
|
|
pShellLink->Release();
|
|
|
}
|
|
|
else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CoCreateInstance failed: %d", hr);
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CoCreateInstance failed: %u", hr);
|
|
|
}
|
|
|
CoUninitialize();
|
|
|
}
|
|
@@ -1743,15 +1743,6 @@ void ResourceWatcherFSM::DetectAutoStartupCover()
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
- case 5: //设置使用EXE注册表自启动(涵盖所有类型)
|
|
|
- if (nStartupType == 1 || nStartupType == 0 || nStartupType == 3 || nStartupType == 4 || nStartupType == 5) {
|
|
|
- rc = ChangeAutoStartupWithExe();
|
|
|
- if (rc == Error_Succeed && (nStartupType == 3 || nStartupType == 4 || nStartupType == 5)) {
|
|
|
- toDeleteAutoStartFile = true;
|
|
|
- //这里不做清理,因为以前也没有问题
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
case 3: //不设置开机自启动
|
|
|
if (nStartupType == 1 || nStartupType == 2) {
|
|
|
rc = ChangeAutoStartupWithExe(false, true);
|
|
@@ -1766,10 +1757,19 @@ void ResourceWatcherFSM::DetectAutoStartupCover()
|
|
|
rc = ChangeAutoStartupWithExe(true);
|
|
|
}
|
|
|
break;
|
|
|
+ case 5: //设置使用EXE注册表自启动(涵盖所有类型)
|
|
|
+ if (nStartupType == 1 || nStartupType == 0 || nStartupType == 3 || nStartupType == 4 || nStartupType == 5) {
|
|
|
+ rc = ChangeAutoStartupWithExe();
|
|
|
+ if (rc == Error_Succeed && (nStartupType == 3 || nStartupType == 4 || nStartupType == 5)) {
|
|
|
+ toDeleteAutoStartFile = true;
|
|
|
+ //这里不做清理,因为以前也没有问题
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
case 6: //设置为开机后开始菜单自启动(涵盖所有类型)
|
|
|
{
|
|
|
CSimpleStringA exePath(true);
|
|
|
- if (nStartupType == 1 || nStartupType == 2 || nStartupType == 3 || nStartupType == 5) {
|
|
|
+ if (nStartupType == 1 || nStartupType == 2 || nStartupType == 3 || nStartupType == 5 || nStartupType == 0) {
|
|
|
CSimpleStringA strNoUse(true);
|
|
|
if (!m_skipDesktopDetect && !IsDesktopIconExist(strNoUse)) {
|
|
|
LogWarn(Severity_Low, Error_InvalidState, LOG_WARN_CREATE_EXELINK_FROMAUTOSTART_ABORT,
|
|
@@ -1781,7 +1781,7 @@ void ResourceWatcherFSM::DetectAutoStartupCover()
|
|
|
//TODO: 如果出现修改注册表成功但是设置自启动图标失败的情况 [Gifur@202492]
|
|
|
rc = ChangeAutoStartupWithExe(false, true);
|
|
|
}
|
|
|
- else if (nStartupType == 3 || nStartupType == 5) {
|
|
|
+ else if (nStartupType == 3 || nStartupType == 5 || nStartupType == 0) {
|
|
|
rc = Error_Succeed;
|
|
|
}
|
|
|
if (rc == Error_Succeed) {
|
|
@@ -1794,7 +1794,7 @@ void ResourceWatcherFSM::DetectAutoStartupCover()
|
|
|
LogWarn(Severity_Low, Error_Debug, LOG_WARN_CREATE_EXELINK_FROMAUTOSTART_SUCC,
|
|
|
CSimpleStringA::Format("Create autostart lnk succ, old start type: %d", nStartupType));
|
|
|
if ((nStartupType == 3 || nStartupType == 5)) { toDeleteAutoStartFile = true; }
|
|
|
- DeleteDuplicateAutoStartFile(true);
|
|
|
+ if(nStartupType != 0) DeleteDuplicateAutoStartFile(true);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1804,7 +1804,7 @@ void ResourceWatcherFSM::DetectAutoStartupCover()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- break;
|
|
|
+ break;
|
|
|
case 7: //设置为开机后开始菜单自启动(针对仅有桌面开机自启动的)
|
|
|
{
|
|
|
CSimpleStringA exePath(true);
|
|
@@ -2293,17 +2293,22 @@ void ResourceWatcherFSM::DetectVersionHasChangedAndWarn()
|
|
|
|
|
|
void ResourceWatcherFSM::DetectDestopFileAndWarn(bool bClear, CSimpleStringA& strFileSaveList)
|
|
|
{
|
|
|
- if (!m_strLoginedUserName.IsNullOrEmpty()) {
|
|
|
- CSimpleStringA filelist(true);
|
|
|
- int dirCount(0), fileCount(0);
|
|
|
- CSimpleStringA desktopFullPath = CSimpleStringA::Format("C:\\Users\\%s\\Desktop", m_strLoginedUserName.GetData());
|
|
|
- CSimpleStringA desktopPublicPath("C:\\Users\\Public\\Desktop");
|
|
|
- CAutoArray<CSimpleStringA> desktopPaths;
|
|
|
- desktopPaths.Init(2);
|
|
|
- desktopPaths[0] = desktopFullPath;
|
|
|
- desktopPaths[1] = desktopPublicPath;
|
|
|
- for (int k = 0; k < desktopPaths.GetCount(); ++k) {
|
|
|
- CSimpleStringA& curPath = desktopPaths[k];
|
|
|
+ CSimpleStringA filelist(true);
|
|
|
+ int dirCount(0), fileCount(0);
|
|
|
+ CSimpleStringA desktopFullPath(true);
|
|
|
+ CSimpleStringA desktopPublicPath(true);
|
|
|
+ GetUserDesktopDirectory(desktopFullPath);
|
|
|
+ GetCommDesktopDirectory(desktopPublicPath);
|
|
|
+ if (desktopFullPath.IsNullOrEmpty() || desktopPublicPath.IsNullOrEmpty()) {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("get desktop directory path failed: pub:%d,user:%d", desktopPublicPath.GetLength(), desktopFullPath.GetLength());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ CAutoArray<CSimpleStringA> desktopPaths;
|
|
|
+ desktopPaths.Init(2);
|
|
|
+ desktopPaths[0] = desktopFullPath;
|
|
|
+ desktopPaths[1] = desktopPublicPath;
|
|
|
+ for (int k = 0; k < desktopPaths.GetCount(); ++k) {
|
|
|
+ CSimpleStringA& curPath = desktopPaths[k];
|
|
|
auto arr = fileutil_get_sub_files(curPath);
|
|
|
if (arr != NULL) {
|
|
|
for (int i = 0; i < arr->nelts; ++i) {
|
|
@@ -2311,8 +2316,8 @@ void ResourceWatcherFSM::DetectDestopFileAndWarn(bool bClear, CSimpleStringA& st
|
|
|
char* filename = strrchr(file, '\\');
|
|
|
if (filename != NULL) { filename += 1; }
|
|
|
else { filename = file; }
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("filename:%s", filename);
|
|
|
- bool toRecord = true;
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("filename:%s", filename);
|
|
|
+ bool toRecord = true;
|
|
|
if (bClear) {
|
|
|
std::string strLowFileName = SP::Utility::ToLower(std::string(filename));
|
|
|
if (strFileSaveList.IsNullOrEmpty() || strFileSaveList.IndexOf(strLowFileName.c_str()) == -1) {
|
|
@@ -2326,13 +2331,13 @@ void ResourceWatcherFSM::DetectDestopFileAndWarn(bool bClear, CSimpleStringA& st
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("skip to delete: %s", filename);
|
|
|
}
|
|
|
}
|
|
|
- if (toRecord) {
|
|
|
+ if (toRecord) {
|
|
|
fileCount++;
|
|
|
if (!filelist.IsNullOrEmpty()) {
|
|
|
filelist += "|";
|
|
|
}
|
|
|
filelist += filename;
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
if (arr->nelts > 0) {
|
|
|
filelist += ";";
|
|
@@ -2347,8 +2352,8 @@ void ResourceWatcherFSM::DetectDestopFileAndWarn(bool bClear, CSimpleStringA& st
|
|
|
char* dirname = strrchr(dir, '\\');
|
|
|
if (dirname != NULL) { dirname += 1; }
|
|
|
else { dirname = dir; }
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("dir name:%s", dirname);
|
|
|
- bool toRecord = true;
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("dir name:%s", dirname);
|
|
|
+ bool toRecord = true;
|
|
|
if (bClear) {
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("remove desktop dir:%s", dirname);
|
|
|
RemoveDirRecursiveA(dir);
|
|
@@ -2356,23 +2361,23 @@ void ResourceWatcherFSM::DetectDestopFileAndWarn(bool bClear, CSimpleStringA& st
|
|
|
toRecord = false;
|
|
|
}
|
|
|
}
|
|
|
- if (toRecord) {
|
|
|
- dirCount++;
|
|
|
+ if (toRecord) {
|
|
|
+ dirCount++;
|
|
|
if (!filelist.IsNullOrEmpty() && i != 0) {
|
|
|
filelist += "|";
|
|
|
}
|
|
|
filelist += dirname;
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
if (arr->nelts > 0) {
|
|
|
filelist += ";";
|
|
|
}
|
|
|
toolkit_array_free2(arr);
|
|
|
}
|
|
|
- }
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_INFO_DESKTOP_FILESTATUS
|
|
|
- ,CSimpleStringA::Format("{\"subject\":\"desktop_file\",\"clear_flag\":\"%d\",\"username\":\"%s\",\"file_count\":%d,\"dir_count\":%d,\"content\":\"%s\"}"
|
|
|
- , bClear ? 1 : 0, m_strLoginedUserName.GetData(), fileCount, dirCount, filelist.GetLength() < 950 ? filelist.GetData() : (filelist.SubString(0, 950) + "....").GetData()));
|
|
|
+ }
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_INFO_DESKTOP_FILESTATUS
|
|
|
+ , CSimpleStringA::Format("{\"subject\":\"desktop_file\",\"clear_flag\":\"%d\",\"desktop\":\"%s\",\"file_count\":%d,\"dir_count\":%d,\"content\":\"%s\"}"
|
|
|
+ , bClear ? 1 : 0, desktopFullPath.GetData(), fileCount, dirCount, filelist.GetLength() < 950 ? filelist.GetData() : (filelist.SubString(0, 950) + "....").GetData()));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2585,6 +2590,67 @@ void ResourceWatcherFSM::DetectAutoStartFileAndWarn()
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("to delete duplicate auto start file.");
|
|
|
DeleteDuplicateAutoStartFile();
|
|
|
}
|
|
|
+ //////////////////////////////////////////////////////////////////////////
|
|
|
+
|
|
|
+ struct fileStruc {
|
|
|
+ std::string username;
|
|
|
+ std::vector<std::string> filenames;
|
|
|
+ //JSONCONVERT2OBJECT_MEMEBER_REGISTER(username, filenames)
|
|
|
+ };
|
|
|
+
|
|
|
+ struct fileVec
|
|
|
+ {
|
|
|
+ std::vector<fileStruc> startupfiles;
|
|
|
+ //JSONCONVERT2OBJECT_MEMEBER_REGISTER(startupfiles)
|
|
|
+ } curStartupFileInfo, keyStartFileInfo;
|
|
|
+
|
|
|
+ CSimpleStringA desktopParentPath = "C:\\Users";
|
|
|
+ auto arr = fileutil_get_sub_dirs(desktopParentPath);
|
|
|
+ if (arr != NULL) {
|
|
|
+ for (int i = 0; i < arr->nelts; ++i) {
|
|
|
+ char* dir = ARRAY_IDX(arr, i, char*);
|
|
|
+ char* dirname = strrchr(dir, '\\');
|
|
|
+ if (dirname != NULL) { dirname += 1; }
|
|
|
+ else { dirname = dir; }
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("dir name:%s", dirname);
|
|
|
+ fileStruc curset;
|
|
|
+ fileStruc keyset;
|
|
|
+ curset.username = keyset.username = dirname;
|
|
|
+ ToListCurrentUserStartupFile(dir, curset.filenames, keyset.filenames);
|
|
|
+ curStartupFileInfo.startupfiles.push_back(curset);
|
|
|
+ keyStartFileInfo.startupfiles.push_back(keyset);
|
|
|
+ }
|
|
|
+ toolkit_array_free2(arr);
|
|
|
+ }
|
|
|
+ std::string curset_str(""), keyset_str("");
|
|
|
+ for (auto it = curStartupFileInfo.startupfiles.begin(); it != curStartupFileInfo.startupfiles.end(); ++it) {
|
|
|
+ if (!curset_str.empty()) curset_str += ";";
|
|
|
+ curset_str += it->username;
|
|
|
+ curset_str += ":";
|
|
|
+ std::string content("");
|
|
|
+ for (auto ik = it->filenames.begin(); ik != it->filenames.end(); ik++) {
|
|
|
+ if (!content.empty()) content += "|";
|
|
|
+ content += ik->c_str();
|
|
|
+ }
|
|
|
+ curset_str += content;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (auto it = keyStartFileInfo.startupfiles.begin(); it != keyStartFileInfo.startupfiles.end(); ++it) {
|
|
|
+ if (!keyset_str.empty()) keyset_str += ";";
|
|
|
+ keyset_str += it->username;
|
|
|
+ keyset_str += ":";
|
|
|
+ std::string content("");
|
|
|
+ for (auto ik = it->filenames.begin(); ik != it->filenames.end(); ik++) {
|
|
|
+ if (!content.empty()) content += "|";
|
|
|
+ content += ik->c_str();
|
|
|
+ }
|
|
|
+ keyset_str += content;
|
|
|
+ }
|
|
|
+
|
|
|
+ //Object2Json(curset_str, curStartupFileInfo);
|
|
|
+ //Object2Json(keyset_str, keyStartFileInfo);
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_RESOURCEWATCHER_DEBUG_STARTUPFILES, curset_str.c_str());
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_RESOURCEWATCHER_DEBUG_KEY_STARTUPFILES, keyset_str.c_str());
|
|
|
}
|
|
|
|
|
|
ErrorCodeEnum ResourceWatcherFSM::DetectVTMInstalledBySetup(BOOL& fYes)
|
|
@@ -4116,6 +4182,7 @@ void ResourceWatcherFSM::InitUserInfo()
|
|
|
if (m_bFirstRunAfterBoot) {
|
|
|
LPITEMIDLIST lp;
|
|
|
CHAR lstr[MAX_PATH] = "";
|
|
|
+ //CSIDL_COMMON_STARTUP: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
|
|
|
HRESULT hr = SHGetSpecialFolderLocation(0, CSIDL_COMMON_STARTUP, &lp);
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
memset(lstr, 0, strlen(lstr));
|
|
@@ -4123,6 +4190,14 @@ void ResourceWatcherFSM::InitUserInfo()
|
|
|
CSimpleStringA s = lstr;
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CSIDL_COMMON_STARTUP: %s", s.GetData());
|
|
|
}
|
|
|
+ hr = SHGetSpecialFolderLocation(0, CSIDL_STARTUP, &lp);
|
|
|
+ if (SUCCEEDED(hr)) {
|
|
|
+ memset(lstr, 0, strlen(lstr));
|
|
|
+ SHGetPathFromIDListA(lp, lstr);
|
|
|
+ CSimpleStringA s = lstr;
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CSIDL_STARTUP: %s", s.GetData());
|
|
|
+ }
|
|
|
+ //CSIDL_COMMON_DESKTOPDIRECTORY: C:\Users\Public\Desktop
|
|
|
hr = SHGetSpecialFolderLocation(0, CSIDL_COMMON_DESKTOPDIRECTORY, &lp);
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
memset(lstr, 0, strlen(lstr));
|
|
@@ -4130,7 +4205,7 @@ void ResourceWatcherFSM::InitUserInfo()
|
|
|
CSimpleStringA s = lstr;
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CSIDL_COMMON_DESKTOPDIRECTORY: %s", s.GetData());
|
|
|
}
|
|
|
-
|
|
|
+ //CSIDL_DESKTOP: C:\Users\szzt\Desktop
|
|
|
hr = SHGetSpecialFolderLocation(0, CSIDL_DESKTOP, &lp);
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
memset(lstr, 0, strlen(lstr));
|
|
@@ -4138,7 +4213,7 @@ void ResourceWatcherFSM::InitUserInfo()
|
|
|
CSimpleStringA s = lstr;
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CSIDL_DESKTOP: %s", s.GetData());
|
|
|
}
|
|
|
-
|
|
|
+ //CSIDL_DESKTOPDIRECTORY: C:\Users\szzt\Desktop
|
|
|
hr = SHGetSpecialFolderLocation(0, CSIDL_DESKTOPDIRECTORY, &lp);
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
memset(lstr, 0, strlen(lstr));
|
|
@@ -4146,19 +4221,6 @@ void ResourceWatcherFSM::InitUserInfo()
|
|
|
CSimpleStringA s = lstr;
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CSIDL_DESKTOPDIRECTORY: %s", s.GetData());
|
|
|
}
|
|
|
-
|
|
|
- CSimpleStringA desktopParentPath = "C:\\Users";
|
|
|
- auto arr = fileutil_get_sub_dirs(desktopParentPath);
|
|
|
- if (arr != NULL) {
|
|
|
- for (int i = 0; i < arr->nelts; ++i) {
|
|
|
- char* dir = ARRAY_IDX(arr, i, char*);
|
|
|
- char* dirname = strrchr(dir, '\\');
|
|
|
- if (dirname != NULL) { dirname += 1; }
|
|
|
- else { dirname = dir; }
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("dir name:%s", dirname);
|
|
|
- }
|
|
|
- toolkit_array_free2(arr);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
const DWORD INFO_BUFFER_SIZE = 128;
|
|
@@ -4193,19 +4255,82 @@ void ResourceWatcherFSM::InitUserInfo()
|
|
|
,m_strCurrentUserName.GetData(), m_strLoginedUserName.GetData(), diff_flag));
|
|
|
}
|
|
|
|
|
|
-void ResourceWatcherFSM::GetUserDesktopDirectory(CSimpleStringA& outDir)
|
|
|
+void ResourceWatcherFSM::ToListCurrentUserStartupFile(const std::string& userDirPath, std::vector<std::string>& files, std::vector<std::string>& keyfiles)
|
|
|
{
|
|
|
- outDir.Clear();
|
|
|
- if (!m_strLoginedUserName.IsNullOrEmpty()) {
|
|
|
- CSimpleStringA desktopFullPath = CSimpleStringA::Format("C:\\Users\\%s\\Desktop", m_strLoginedUserName.GetData());
|
|
|
- outDir = desktopFullPath;
|
|
|
+ std::string fulPath(userDirPath);
|
|
|
+ fulPath += "\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup";
|
|
|
+ files.clear();
|
|
|
+ keyfiles.clear();
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("startup path:%s", fulPath.c_str());
|
|
|
+ if (ExistsDirA(fulPath.c_str())) {
|
|
|
+ auto arr = fileutil_get_sub_files(fulPath.c_str());
|
|
|
+ if (arr != NULL) {
|
|
|
+ for (int i = 0; i < arr->nelts; ++i) {
|
|
|
+ char* file = ARRAY_IDX(arr, i, char*);
|
|
|
+ char* filename = strrchr(file, '\\');
|
|
|
+ if (filename != NULL) { filename += 1; }
|
|
|
+ else { filename = file; }
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("filename:%s", filename);
|
|
|
+ files.push_back(std::string(filename));
|
|
|
+ }
|
|
|
+ toolkit_array_free2(arr);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (auto kt = keyUserlist.cbegin(); kt != keyUserlist.cend(); ++kt) {
|
|
|
+ std::string sub_file(fulPath);
|
|
|
+ sub_file += "\\";
|
|
|
+ sub_file += kt->c_str();
|
|
|
+ if (ExistsFileA(sub_file.c_str())) {
|
|
|
+ keyfiles.push_back(*kt);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void ResourceWatcherFSM::GetCommDesktopDirectory(CSimpleStringA& outDir)
|
|
|
+{
|
|
|
+ outDir.Clear();
|
|
|
+ LPITEMIDLIST lp;
|
|
|
+ CHAR lstr[MAX_PATH] = "";
|
|
|
+ HRESULT hr = SHGetSpecialFolderLocation(0, CSIDL_COMMON_DESKTOPDIRECTORY, &lp);
|
|
|
+ if (SUCCEEDED(hr)) {
|
|
|
+ memset(lstr, 0, strlen(lstr));
|
|
|
+ SHGetPathFromIDListA(lp, lstr);
|
|
|
+ outDir = lstr;
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CSIDL_COMMON_DESKTOPDIRECTORY: %s", outDir.GetData());
|
|
|
}
|
|
|
else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("LoginedUserName is empty.");
|
|
|
+ DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("SHGetSpecialFolderLocation for CSIDL_COMMON_DESKTOPDIRECTORY failed:%u", hr);
|
|
|
+ outDir = "C:\\Users\\Public\\Desktop";
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+void ResourceWatcherFSM::GetUserDesktopDirectory(CSimpleStringA& outDir)
|
|
|
+{
|
|
|
+ outDir.Clear();
|
|
|
+ LPITEMIDLIST lp;
|
|
|
+ CHAR lstr[MAX_PATH] = "";
|
|
|
+ HRESULT hr = SHGetSpecialFolderLocation(0, CSIDL_DESKTOP, &lp);
|
|
|
+ if (SUCCEEDED(hr)) {
|
|
|
+ memset(lstr, 0, strlen(lstr));
|
|
|
+ SHGetPathFromIDListA(lp, lstr);
|
|
|
+ outDir = lstr;
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CSIDL_DESKTOP: %s", outDir.GetData());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("SHGetSpecialFolderLocation for CSIDL_DESKTOP failed:%u", hr);
|
|
|
+ if (!m_strLoginedUserName.IsNullOrEmpty()) {
|
|
|
+ CSimpleStringA desktopFullPath = CSimpleStringA::Format("C:\\Users\\%s\\Desktop", m_strLoginedUserName.GetData());
|
|
|
+ outDir = desktopFullPath;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("LoginedUserName is empty.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
bool ResourceWatcherFSM::IsDesktopIconExist(CSimpleStringA& strPath)
|
|
|
{
|
|
|
CSimpleStringA s(true);
|
|
@@ -4218,26 +4343,46 @@ bool ResourceWatcherFSM::IsDesktopIconExist(CSimpleStringA& strPath)
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+void ResourceWatcherFSM::GetCommStartupDirectory(CSimpleStringA& outDir)
|
|
|
+{
|
|
|
+ outDir.Clear();
|
|
|
+ LPITEMIDLIST lp;
|
|
|
+ CHAR lstr[MAX_PATH] = "";
|
|
|
+ HRESULT hr = SHGetSpecialFolderLocation(0, CSIDL_COMMON_STARTUP, &lp);
|
|
|
+ if (SUCCEEDED(hr)) {
|
|
|
+ memset(lstr, 0, strlen(lstr));
|
|
|
+ SHGetPathFromIDListA(lp, lstr);
|
|
|
+ outDir = lstr;
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CSIDL_COMMON_STARTUP: %s", outDir.GetData());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("SHGetSpecialFolderLocation for CSIDL_COMMON_STARTUP failed:%u", hr);
|
|
|
+ outDir = STARTUP_DIR_FULL_PATH;
|
|
|
+ }
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
void ResourceWatcherFSM::GetUserStartupDirectory(CSimpleStringA& outDir)
|
|
|
{
|
|
|
outDir.Clear();
|
|
|
- //LPITEMIDLIST lp;
|
|
|
- //HRESULT hr = SHGetSpecialFolderLocation(0, CSIDL_COMMON_STARTUP, &lp);
|
|
|
- //if (SUCCEEDED(hr)) {
|
|
|
- // CHAR lstr[MAX_PATH];
|
|
|
- // memset(lstr, 0, strlen(lstr));
|
|
|
- // SHGetPathFromIDListA(lp, lstr);
|
|
|
- // CSimpleStringA desktopFullPath = lstr;
|
|
|
- // DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CSIDL_COMMON_STARTUP: %s", desktopFullPath.GetData());
|
|
|
- // outDir = desktopFullPath;
|
|
|
- //}
|
|
|
-
|
|
|
- if (!m_strLoginedUserName.IsNullOrEmpty()) {
|
|
|
- CSimpleStringA startMenuFullPath = CSimpleStringA::Format("C:\\Users\\%s\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup", m_strLoginedUserName.GetData());
|
|
|
- outDir = startMenuFullPath;
|
|
|
+ LPITEMIDLIST lp;
|
|
|
+ CHAR lstr[MAX_PATH] = "";
|
|
|
+ HRESULT hr = SHGetSpecialFolderLocation(0, CSIDL_STARTUP, &lp);
|
|
|
+ if (SUCCEEDED(hr)) {
|
|
|
+ memset(lstr, 0, strlen(lstr));
|
|
|
+ SHGetPathFromIDListA(lp, lstr);
|
|
|
+ outDir = lstr;
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CSIDL_STARTUP: %s", outDir.GetData());
|
|
|
}
|
|
|
else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("LoginedUserName is empty.");
|
|
|
+ DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("SHGetSpecialFolderLocation for CSIDL_STARTUP failed:%u", hr);
|
|
|
+ if (!m_strLoginedUserName.IsNullOrEmpty()) {
|
|
|
+ CSimpleStringA startMenuFullPath = CSimpleStringA::Format("C:\\Users\\%s\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup", m_strLoginedUserName.GetData());
|
|
|
+ outDir = startMenuFullPath;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("LoginedUserName is empty.");
|
|
|
+ }
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
@@ -4521,65 +4666,6 @@ BOOL ResourceWatcherFSM::DetectIsFirstRunAtBoot()
|
|
|
}
|
|
|
|
|
|
#ifdef RVC_OS_LINUX
|
|
|
-void ResourceWatcherFSM::UploadMonitorSettings()
|
|
|
-{
|
|
|
- CSmartPointer<IConfigInfo> spCtSettingConfig;
|
|
|
- GetEntityBase()->GetFunction()->OpenConfig(Config_CenterSetting, spCtSettingConfig);
|
|
|
- int nSwitchOff(0);
|
|
|
- spCtSettingConfig->ReadConfigValueInt(GetEntityBase()->GetEntityName(), "MonitorListenOFF", nSwitchOff);
|
|
|
- if (!!nSwitchOff) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Cancel monitor change listen!");
|
|
|
- if (m_bFirstRunAfterBoot) {
|
|
|
- CSimpleStringA value(true);
|
|
|
- bool res = GetMonitorInfo(value);
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_INFO_MONITOR_SETTINGS, value);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
-
|
|
|
- int nInterval(10000);
|
|
|
- int nValue(0);
|
|
|
- spCtSettingConfig->ReadConfigValueInt(GetEntityBase()->GetEntityName(), "MonitorListenInterval", nValue);
|
|
|
- if (nValue >= 10000) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Update monitor listen interval from %d to %d", nInterval, nValue);
|
|
|
- nInterval = nValue;
|
|
|
- }
|
|
|
-
|
|
|
- CSimpleStringA strLastMonitor(true);
|
|
|
- bool readFromCfgFalg(true);
|
|
|
- CSmartPointer<IConfigInfo> spRunConfig;
|
|
|
- GetEntityBase()->GetFunction()->OpenConfig(Config_Run, spRunConfig);
|
|
|
- spRunConfig->ReadConfigValue("MonitorAttribute", "LastInfo", strLastMonitor);
|
|
|
-
|
|
|
- do
|
|
|
- {
|
|
|
- CSimpleStringA value(true);
|
|
|
- bool res = GetMonitorInfo(value);
|
|
|
- if (!value.IsNullOrEmpty() && (strLastMonitor.IsNullOrEmpty() || (strLastMonitor.Compare(value) != 0))) {
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_INFO_MONITOR_SETTINGS, value);
|
|
|
- CSmartPointer<IConfigInfo> spRunConfig;
|
|
|
- GetEntityBase()->GetFunction()->OpenConfig(Config_Run, spRunConfig);
|
|
|
- spRunConfig->WriteConfigValue("MonitorAttribute", "LastInfo", value);
|
|
|
- strLastMonitor = value;
|
|
|
- if (readFromCfgFalg) {
|
|
|
- readFromCfgFalg = false;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- else if (readFromCfgFalg && !strLastMonitor.IsNullOrEmpty() && strLastMonitor.Compare(value) == 0)
|
|
|
- {
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_INFO_MONITOR_SETTINGS, value);
|
|
|
- readFromCfgFalg = false;
|
|
|
- }
|
|
|
-
|
|
|
- Sleep(nInterval);
|
|
|
-
|
|
|
- } while (true);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
void ResourceWatcherFSM::DetectSoftwareInstallStatus()
|
|
|
{
|
|
|
CSmartPointer<IConfigInfo> spCtSettingConfig;
|