24 static char szCompanyName[128];
25 static char szAppName[128];
26 static char szAppVersion[128];
43 static char tmp_string_data[1024];
47 static bool userSIDValid =
false;
53 if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken) ==
FALSE)
55 mprintf((
"Failed to get process token! Error Code: %d", GetLastError()));
61 GetTokenInformation(hToken, TokenUser, NULL, 0, &dwBufferSize);
63 PTOKEN_USER ptkUser = (PTOKEN_USER)
new byte[dwBufferSize];
65 if (GetTokenInformation(hToken, TokenUser, ptkUser, dwBufferSize, &dwBufferSize))
70 if (IsValidSid(ptkUser->User.Sid) ==
FALSE)
72 mprintf((
"Invalid SID structure detected!"));
78 LPTSTR sidName = NULL;
79 if (ConvertSidToStringSid(ptkUser->User.Sid, &sidName) == 0)
81 mprintf((
"Failed to convert SID structure to string! Error Code: %d", GetLastError()));
87 outStr.assign(sidName);
90 delete[](byte*) ptkUser;
102 if (!IsWow64Process(GetCurrentProcess(), &bIsWow64))
104 mprintf((
"Failed to determine if we run under Wow64, registry configuration may fail!"));
108 return bIsWow64 ==
TRUE;
114 if (!Cmdline_alternate_registry_path) {
117 sprintf(out_keyname,
"Software\\%s\\%s\\%s", szCompanyName, szAppName, section);
120 sprintf(out_keyname,
"Software\\%s\\%s", szCompanyName, szAppName);
122 return HKEY_LOCAL_MACHINE;
132 sprintf(out_keyname,
"%s_Classes\\VirtualStore\\Machine\\Software\\Wow6432Node\\%s\\%s\\%s", userSID.c_str(), szCompanyName, szAppName, section);
135 sprintf(out_keyname,
"%s_Classes\\VirtualStore\\Machine\\Software\\Wow6432Node\\%s\\%s", userSID.c_str(), szCompanyName, szAppName);
141 sprintf(out_keyname,
"%s_Classes\\VirtualStore\\Machine\\Software\\%s\\%s\\%s", userSID.c_str(), szCompanyName, szAppName, section);
144 sprintf(out_keyname,
"%s_Classes\\VirtualStore\\Machine\\Software\\%s\\%s", userSID.c_str(), szCompanyName, szAppName);
154 sprintf(out_keyname,
"Software\\%s\\%s\\%s", szCompanyName, szAppName, section);
157 sprintf(out_keyname,
"Software\\%s\\%s", szCompanyName, szAppName);
160 return HKEY_LOCAL_MACHINE;
164 sprintf(out_keyname,
"Software\\%s\\%s\\%s", szCompanyName, szAppName, section);
167 sprintf(out_keyname,
"Software\\%s\\%s", szCompanyName, szAppName);
170 return HKEY_LOCAL_MACHINE;
187 lResult = RegOpenKeyEx(useHKey,
193 if (lResult != ERROR_SUCCESS) {
201 lResult = RegQueryValueEx(hKey,
208 if (lResult != ERROR_SUCCESS) {
234 lResult = RegCreateKeyEx(useHKey,
238 REG_OPTION_NON_VOLATILE,
244 if (lResult != ERROR_SUCCESS) {
252 lResult = RegSetValueEx(hKey,
259 if (lResult != ERROR_SUCCESS) {
282 lResult = RegCreateKeyEx(useHKey,
286 REG_OPTION_NON_VOLATILE,
292 if (lResult != ERROR_SUCCESS) {
300 lResult = RegSetValueEx(hKey,
304 (CONST BYTE *)&value,
307 if (lResult != ERROR_SUCCESS) {
335 lResult = RegOpenKeyEx(useHKey,
341 if (lResult != ERROR_SUCCESS) {
350 lResult = RegQueryValueEx(hKey,
354 (
ubyte *)&tmp_string_data,
357 if (lResult != ERROR_SUCCESS) {
361 default_value = tmp_string_data;
367 return default_value;
381 return default_value;
386 lResult = RegOpenKeyEx(useHKey,
392 if (lResult != ERROR_SUCCESS) {
401 lResult = RegQueryValueEx(hKey,
408 if (lResult != ERROR_SUCCESS) {
412 default_value = tmp_val;
418 return default_value;
446 OSVERSIONINFO versionInfo;
447 versionInfo.dwOSVersionInfoSize =
sizeof(OSVERSIONINFO);
448 GetVersionEx(&versionInfo);
451 if (versionInfo.dwMajorVersion >= 6)
uint os_config_read_uint(const char *section, const char *name, uint default_value)
GLsizei const GLfloat * value
void os_init_registry_stuff(const char *company, const char *app, const char *version)
const char * os_config_read_string(const char *section, const char *name, const char *default_value)
std::basic_string< char, std::char_traits< char >, std::allocator< char > > SCP_string
void os_config_write_uint(const char *section, const char *name, uint value)
bool get_user_sid(SCP_string &outStr)
const char * Osreg_app_name
void os_config_write_string(const char *section, const char *name, const char *value)
bool registry_has_value(const char *section, const char *name)
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
HKEY get_registry_keyname(char *out_keyname, const char *section)
GLuint const GLchar * name
const char * Osreg_company_name
const char * Osreg_class_name
const char * Osreg_pref_dir