svnno****@sourc*****
svnno****@sourc*****
2015年 11月 14日 (土) 17:41:37 JST
Revision: 6130 http://sourceforge.jp/projects/ttssh2/scm/svn/commits/6130 Author: yutakapon Date: 2015-11-14 17:41:36 +0900 (Sat, 14 Nov 2015) Log Message: ----------- チケット #35205 設定フォルダ:改善項目 Virtual Storeの判別処理を分離した。 内部処理変更なので、外見えには変化なし。 Ticket Links: ------------ http://sourceforge.jp/projects/ttssh2/tracker/detail/35205 Modified Paths: -------------- trunk/teraterm/common/tttypes.h trunk/teraterm/teraterm/vtwin.cpp -------------- next part -------------- Modified: trunk/teraterm/common/tttypes.h =================================================================== --- trunk/teraterm/common/tttypes.h 2015-11-14 07:55:18 UTC (rev 6129) +++ trunk/teraterm/common/tttypes.h 2015-11-14 08:41:36 UTC (rev 6130) @@ -1000,6 +1000,7 @@ BOOL TelLineMode; _locale_t locale; + BOOL VirtualStoreEnabled; } TComVar; typedef TComVar far *PComVar; Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2015-11-14 07:55:18 UTC (rev 6129) +++ trunk/teraterm/teraterm/vtwin.cpp 2015-11-14 08:41:36 UTC (rev 6130) @@ -549,6 +549,85 @@ } +// Virtual Store\x82\xAA\x97L\x8C\xF8\x82ł\xA0\x82邩\x82ǂ\xA4\x82\xA9\x82ʂ\xB7\x82\xE9\x81B +// +// [Windows 95-XP] +// return FALSE (always) +// +// [Windows Vista-10] +// return TRUE: Virtual Store Enabled +// FALSE: Virtual Store Disabled or Unknown +// +BOOL GetVirtualStoreEnvironment(void) +{ + BOOL ret = FALSE; + int flag = 0; + OSVERSIONINFO osvi; + HANDLE hToken; + DWORD dwLength; + TOKEN_ELEVATION tokenElevation; + LONG lRet; + HKEY hKey; + TCHAR lpData[256]; + DWORD dwDataSize; + DWORD dwType; + BYTE bValue; + + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&osvi); + // Windows Vista\x88ȑO\x82͖\xB3\x8E\x8B\x82\xB7\x82\xE9\x81B + if (!(osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion >= 6)) + goto error; + + // UAC\x82\xAA\x97L\x8C\xF8\x82\xA9\x82ǂ\xA4\x82\xA9\x81B + // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\x82\xCCEnableLUA(DWORD\x92l)\x82\xAA0\x82\xA9\x82ǂ\xA4\x82\xA9\x82Ŕ\xBB\x92f\x82ł\xAB\x82܂\xB7(0\x82\xCDUAC\x96\xB3\x8C\xF8\x81A1\x82\xCDUAC\x97L\x8C\xF8)\x81B + flag = 0; + lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, + TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"), + NULL, KEY_QUERY_VALUE, &hKey + ); + if (lRet == ERROR_SUCCESS) { + dwDataSize = sizeof(lpData) / sizeof(lpData[0]); + lRet = RegQueryValueEx( + hKey, + TEXT("EnableLUA"), + 0, + &dwType, + (LPBYTE)lpData, + &dwDataSize); + if (lRet == ERROR_SUCCESS) { + bValue = ((LPBYTE)lpData)[0]; + if (bValue == 1) + // UAC\x82\xAA\x97L\x8C\xF8\x82̏ꍇ\x81AVirtual Store\x82\xAA\x93\xAD\x82\xAD\x81B + flag = 1; + } + RegCloseKey(hKey); + } + if (flag == 0) + goto error; + + // UAC\x82\xAA\x97L\x8C\xF8\x8E\x9E\x81A\x83v\x83\x8D\x83Z\x83X\x82\xAA\x8AǗ\x9D\x8EҌ\xA0\x8C\xC0\x82ɏ\xB8\x8Ai\x82\xB5\x82Ă\xA2\x82邩\x81B + flag = 0; + if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_ADJUST_DEFAULT, &hToken)) { + if (GetTokenInformation(hToken, (TOKEN_INFORMATION_CLASS)TokenElevation, &tokenElevation, sizeof(TOKEN_ELEVATION), &dwLength)) { + // (0\x82͏\xB8\x8Ai\x82\xB5\x82Ă\xA2\x82Ȃ\xA2\x81A\x94\xF10\x82͏\xB8\x8Ai\x82\xB5\x82Ă\xA2\x82\xE9)\x81B + if (tokenElevation.TokenIsElevated == 0) { + // \x8AǗ\x9D\x8EҌ\xA0\x8C\xC0\x82\xF0\x8E\x9D\x82\xC1\x82Ă\xA2\x82Ȃ\xAF\x82\xEA\x82AVirtual Store\x82\xAA\x93\xAD\x82\xAD\x81B + flag = 1; + } + } + CloseHandle(hToken); + } + if (flag == 0) + goto error; + + ret = TRUE; + return (ret); + +error: + return (ret); +} + CVTWindow::CVTWindow() { WNDCLASS wc; @@ -795,6 +874,10 @@ } ShowWindow(CmdShow); ChangeCaret(); + + // Tera Term\x82̋N\x93\xAE\x8E\x9E\x81AVirtual Store\x82\xAA\x93\xAD\x82\xAD\x82\xA9\x82ǂ\xA4\x82\xA9\x82\xF0\x8Ao\x82\xA6\x82Ă\xA8\x82\xAD\x81B + // (2015.11.14 yutaka) + cv.VirtualStoreEnabled = GetVirtualStoreEnvironment(); } ///////////////////////////////////////////////////////////////////////////// @@ -4767,13 +4850,6 @@ // static BOOL convertVirtualStore(char *path, char *filename, char *vstore_path, int vstore_pathlen) { -#if _MSC_VER == 1400 // VSC2005(VC8.0) - typedef struct _TOKEN_ELEVATION { - DWORD TokenIsElevated; - } TOKEN_ELEVATION, *PTOKEN_ELEVATION; - int TokenElevation = 20; -#endif - BOOL ret = FALSE; int flag = 0; char *s, **p; @@ -4787,67 +4863,12 @@ char shFullPath[1024] = ""; LPITEMIDLIST pidl; int CSIDL; - OSVERSIONINFO osvi; - HANDLE hToken; - DWORD dwLength; - TOKEN_ELEVATION tokenElevation; - LONG lRet; - HKEY hKey; - TCHAR lpData[256]; - DWORD dwDataSize; - DWORD dwType; - BYTE bValue; OutputDebugPrintf("[%s][%s]\n", path, filename); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&osvi); - // Windows Vista\x88ȑO\x82͖\xB3\x8E\x8B\x82\xB7\x82\xE9\x81B - if (!(osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion >= 6)) + if (cv.VirtualStoreEnabled == FALSE) goto error; - // UAC\x82\xAA\x97L\x8C\xF8\x82\xA9\x82ǂ\xA4\x82\xA9\x81B - // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\x82\xCCEnableLUA(DWORD\x92l)\x82\xAA0\x82\xA9\x82ǂ\xA4\x82\xA9\x82Ŕ\xBB\x92f\x82ł\xAB\x82܂\xB7(0\x82\xCDUAC\x96\xB3\x8C\xF8\x81A1\x82\xCDUAC\x97L\x8C\xF8)\x81B - flag = 0; - lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"), - NULL, KEY_QUERY_VALUE, &hKey - ); - if (lRet == ERROR_SUCCESS) { - dwDataSize = sizeof(lpData) / sizeof(lpData[0]); - lRet = RegQueryValueEx( - hKey, - TEXT("EnableLUA"), - 0, - &dwType, - (LPBYTE)lpData, - &dwDataSize); - if (lRet == ERROR_SUCCESS) { - bValue = ((LPBYTE)lpData)[0]; - if (bValue == 1) - // UAC\x82\xAA\x97L\x8C\xF8\x82̏ꍇ\x81AVirtual Store\x82\xAA\x93\xAD\x82\xAD\x81B - flag = 1; - } - RegCloseKey(hKey); - } - if (flag == 0) - goto error; - - // UAC\x82\xAA\x97L\x8C\xF8\x8E\x9E\x81A\x83v\x83\x8D\x83Z\x83X\x82\xAA\x8AǗ\x9D\x8EҌ\xA0\x8C\xC0\x82ɏ\xB8\x8Ai\x82\xB5\x82Ă\xA2\x82邩\x81B - flag = 0; - if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_ADJUST_DEFAULT, &hToken)) { - if (GetTokenInformation(hToken, (TOKEN_INFORMATION_CLASS)TokenElevation, &tokenElevation, sizeof(TOKEN_ELEVATION), &dwLength)) { - // (0\x82͏\xB8\x8Ai\x82\xB5\x82Ă\xA2\x82Ȃ\xA2\x81A\x94\xF10\x82͏\xB8\x8Ai\x82\xB5\x82Ă\xA2\x82\xE9)\x81B - if (tokenElevation.TokenIsElevated == 0) { - // \x8AǗ\x9D\x8EҌ\xA0\x8C\xC0\x82\xF0\x8E\x9D\x82\xC1\x82Ă\xA2\x82Ȃ\xAF\x82\xEA\x82AVirtual Store\x82\xAA\x93\xAD\x82\xAD\x81B - flag = 1; - } - } - CloseHandle(hToken); - } - if (flag == 0) - goto error; - // Virtual Store\x91ΏۂƂȂ\xE9\x83t\x83H\x83\x8B\x83_\x82\xA9\x81B p = virstore_env; while (*p) {