DXGL r335 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r334‎ | r335 | r336 >
Date:22:58, 24 February 2013
Author:admin
Status:new
Tags:
Comment:
Kill DWM8And16BitMitigation in HKEY_CURRENT_USER.
Clean up registry key handle in DWM8And16BitMitigation killer.
Modified paths:
  • /cfgmgr/cfgmgr.cpp (modified) (history)

Diff [purge]

Index: cfgmgr/cfgmgr.cpp
@@ -359,7 +359,52 @@
360360 else MessageBox(NULL,_T("Registry value could not be deleted. Your program may crash as a result."),_T("Error"),MB_OK|MB_ICONWARNING);
361361 }
362362 }
 363+ RegCloseKey(hKey);
363364 }
 365+ if(is64) error = RegOpenKeyEx(HKEY_CURRENT_USER,_T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"),0,KEY_READ|KEY_WOW64_64KEY,&hKey);
 366+ else error = RegOpenKeyEx(HKEY_CURRENT_USER,_T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"),0,KEY_READ,&hKey);
 367+ if(error == ERROR_SUCCESS)
 368+ {
 369+ GetModuleFileName(NULL,filename,MAX_PATH);
 370+ TCHAR buffer[1024];
 371+ ZeroMemory(buffer,1024*sizeof(TCHAR));
 372+ DWORD sizeout = 1024*sizeof(TCHAR);
 373+ if(RegQueryValueEx(hKey,filename,NULL,NULL,(LPBYTE)buffer,&sizeout) == ERROR_SUCCESS)
 374+ {
 375+ if(_tcsstr(buffer,_T("DWM8And16BitMitigation")))
 376+ {
 377+ MessageBox(NULL,_T("DXGL has detected an incompatible AppCompat flag for the program you are currently running. To continue, the registry value must be deleted.\nIf you see a UAC prompt, you must click Yes."),
 378+ _T("AppCompat error"),MB_OK|MB_ICONHAND);
 379+ error = RegDeleteValue(hKey,filename);
 380+ if(error == ERROR_ACCESS_DENIED)
 381+ {
 382+ tstring command;
 383+ if(is64) command.assign(_T("DELETE \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /reg:64 /f /v \""));
 384+ else command.assign(_T("DELETE \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /f /v \""));
 385+ command.append(filename);
 386+ command.append(_T("\""));
 387+ SHELLEXECUTEINFO info;
 388+ ZeroMemory(&info,sizeof(SHELLEXECUTEINFO));
 389+ info.cbSize = sizeof(SHELLEXECUTEINFO);
 390+ info.lpVerb = _T("runas");
 391+ info.lpFile = _T("reg.exe");
 392+ info.lpParameters = command.c_str();
 393+ info.nShow = SW_SHOWNORMAL;
 394+ info.fMask = SEE_MASK_NOCLOSEPROCESS;
 395+ ShellExecuteEx(&info);
 396+ WaitForSingleObject(info.hProcess,INFINITE);
 397+ GetExitCodeProcess(info.hProcess,(LPDWORD)&error);
 398+ }
 399+ if(!error)
 400+ {
 401+ MessageBox(NULL,_T("Registry value successfully deleted. Please restart the program."),_T("Success"),MB_OK|MB_ICONINFORMATION);
 402+ exit(0);
 403+ }
 404+ else MessageBox(NULL,_T("Registry value could not be deleted. Your program may crash as a result."),_T("Error"),MB_OK|MB_ICONWARNING);
 405+ }
 406+ }
 407+ RegCloseKey(hKey);
 408+ }
364409 }
365410 void GetGlobalConfig(DXGLCFG *cfg)
366411 {