C++/MFC
SHGetKnownFolderPath 함수 사용시에 바이러스로 인식되는 현상
Hwoarang757
2022. 10. 26. 23:55
Self Extractor 배포 프로젝트에 %appdata% Path를 구하기 위하여
아래와 같이 ShlObj_core.h 의 SHGetKnownFolderPath 함수 사용시에 , 백신에서는 해당 프로세스를
바이러스로 감지 하였습니다 -_-;;
wchar_t *wszPath;
if (SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, NULL, &wszPath) != S_OK) {
std::cout << "디렉터리 정보 얻기 실패" << std::endl;
}
std::wstring wstrPath(wszPath);
std::string strPath(wstrPath.begin(), wstrPath.end());
strPath += "\\AgentTest\\AgentTest.exe";
std::cout << strPath << std::endl;
fileapi.h 의 GetTempPath 함수 사용시에는 바이러스로 감지 하지 않았습니다.
GetTempPath의 경우 , 사용자계정\Local\Temp 이므로 , Roaming으로 접근하기 위하여
rfind 함수로 시작 위치를 찾아 Roaming 문자열을 결합 하였습니다.
std::string strAgentPath = GetAppDataTempPath();
// \LOCAL\TEMP\ 를 변경
std::transform(strAgentPath.begin(), strAgentPath.end(), strAgentPath.begin(), ::tolower);
strAgentPath = strAgentPath.substr(0, strAgentPath.rfind("\\local\\temp\\"));
strAgentPath = strAgentPath + "\\Roaming\\AgentTest\\AgentTest.exe";
std::string GetAppDataTempPath() {
TCHAR szTempPath[MAX_PATH];
GetTempPath(MAX_PATH, szTempPath);
return szTempPath;
}