|
@@ -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) {
|
|
@@ -1526,7 +1530,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 +1543,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();
|
|
|
}
|
|
@@ -2293,17 +2297,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 +2320,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 +2335,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 +2356,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 +2365,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 +2594,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 +4186,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 +4194,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 +4209,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 +4217,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 +4225,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 +4259,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 +4347,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;
|
|
|
}
|
|
@@ -4579,7 +4728,6 @@ void ResourceWatcherFSM::UploadMonitorSettings()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
void ResourceWatcherFSM::DetectSoftwareInstallStatus()
|
|
|
{
|
|
|
CSmartPointer<IConfigInfo> spCtSettingConfig;
|