Пример #1
0
NTSTATUS GetRegistryConfigData(PUNICODE_STRING RegistryPath)
{
    InsertTemporaryRegData(RegistryPath); //---------------------------------------------------------------------------------------DELETE

    NTSTATUS status = QueryRegistryValue(RegistryPath, L"Data", ConfigDataQueryRoutine);

    return status;
}
void DoRegistryFile(CStringA resToken)
{
	int nBrace = -1;
	int nBraceCnt = 1;
	for (int i = 2; i < resToken.GetLength(); i++)
	{
		if (resToken.GetAt(i) == '[')
			nBraceCnt++;
		else if (resToken.GetAt(i) == ']')
		{
			nBraceCnt--;
			if (nBraceCnt == 0)
			{
				nBrace = i;
				break;
			}
		}
	}

	if (nBrace == -1)
		return;

	USES_CONVERSION;

	CStringA strRegPath = resToken.Mid(2, nBrace - 2);

	std::vector<CStringA> vecOutRegPaths;
	EnumRegistry(strRegPath, vecOutRegPaths);

	int cnt = vecOutRegPaths.size();
	for (int i = 0; i < cnt; i++)
	{
		CStringA strFilePath;
		if (QueryRegistryValue(vecOutRegPaths.at(i), strFilePath))
		{
			CHAR expName[MAX_PATH + 1];
			ExpandEnvironmentStringsA(strFilePath, expName, MAX_PATH);
			strFilePath = expName;

			if (strFilePath.Find('\\') != -1)
				DoFilePathName(strFilePath);
			else
				DoOnlyFileName(strFilePath);
		}
	}
}
void DoRegistryPath(CStringA resToken)
{	
	int nBrace = -1;
	int nBraceCnt = 1;
	for (int i = 2; i < resToken.GetLength(); i++)
	{
		if (resToken.GetAt(i) == '{')
			nBraceCnt++;
		else if (resToken.GetAt(i) == '}')
		{
			nBraceCnt--;
			if (nBraceCnt == 0)
			{
				nBrace = i;
				break;
			}
		}
	}

	if (nBrace == -1)
		return;

	USES_CONVERSION;

	bool bIsPath = true;
	CStringA strRegPath = resToken.Mid(2, nBrace - 2);
	int nLength = strRegPath.GetLength();
	if (nLength > 2 && strRegPath.Mid(nLength - 2).MakeLower() == "|p")
	{
		bIsPath = true;
		strRegPath = strRegPath.Mid(0, nLength - 2);
	}
	else if (nLength > 2 && strRegPath.Mid(nLength - 2).MakeLower() == "|f")
	{
		bIsPath = false;
		strRegPath = strRegPath.Mid(0, nLength - 2);
	}

	std::vector<CStringA> vecOutRegPaths;
	EnumRegistry(strRegPath, vecOutRegPaths);

	int cnt = vecOutRegPaths.size();
	for (int i = 0; i < cnt; i++)
	{
		CStringA strFilePath;
		if (QueryRegistryValue(vecOutRegPaths.at(i), strFilePath))
		{
			if (!bIsPath)
			{
				strFilePath.Replace('/', '\\');
				int nEndSlash = strFilePath.ReverseFind('\\');
				if (nEndSlash == -1)
					continue;

				strFilePath = strFilePath.Mid(0, nEndSlash);
			}

			strFilePath += resToken.Mid(nBrace + 1);			
			DoFilePathName(strFilePath);
		}
	}
}