Skip to content

GetStringFromRegistry can fail to read from the correct registry location depending on process admin privileges #1059

@xezon

Description

@xezon

GetStringFromRegistry can fail to read from the correct location depending on process admin privileges. This is reproducible with the HTTP Proxy setting in the Options Menu. When using the game once as Admin, then the game will write a Proxy key into HKEY_LOCAL_MACHINE. Then when using the game without Admin privileges, the game will write a Proxy key into HKEY_CURRENT_USER. But when reading, it will be able to read from HKEY_LOCAL_MACHINE first. This is a bug.

bool GetStringFromRegistry(std::string path, std::string key, std::string& val)
{
#if RTS_GENERALS
	std::string fullPath = "SOFTWARE\\Electronic Arts\\EA Games\\Generals";
#elif RTS_ZEROHOUR
	std::string fullPath = "SOFTWARE\\Electronic Arts\\EA Games\\Command and Conquer Generals Zero Hour";
#endif

	fullPath.append(path);

// PROBLEMATICO

	if (getStringFromRegistry(HKEY_LOCAL_MACHINE, fullPath.c_str(), key.c_str(), val))
	{
		return true;
	}

	return getStringFromRegistry(HKEY_CURRENT_USER, fullPath.c_str(), key.c_str(), val);
}
bool SetStringInRegistry( std::string path, std::string key, std::string val)
{
#if RTS_GENERALS
	std::string fullPath = "SOFTWARE\\Electronic Arts\\EA Games\\Generals";
#elif RTS_ZEROHOUR
	std::string fullPath = "SOFTWARE\\Electronic Arts\\EA Games\\Command and Conquer Generals Zero Hour";
#endif
	fullPath.append(path);

	if (setStringInRegistry( HKEY_LOCAL_MACHINE, fullPath, key, val))
		return true;

	return setStringInRegistry( HKEY_CURRENT_USER, fullPath, key, val );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething is not working right, typically is user facingMinorSeverity: Minor < Major < Critical < Blocker

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions