int my_ldi(t_info *t, t_prog *p) { int i; int s; if (p->param[0] && p->param[1] && p->param[2] && p->param[2] < REG_NUMBER) { s = 0; if (TYPE_PARAM1 == P_DIR) s += p->param[0]; else if (TYPE_PARAM1 == P_IND) s += get_ind_value(t, p, 0, IDX_MOD); else s += get_reg_value(t, p, 0); if (TYPE_PARAM2 == P_DIR) s += p->param[1]; else s += get_reg_value(t, p, 1); i = -1; PC = get_index(PC, s, IDX_MOD); while (++i && i < REG_SIZE) p->reg[p->param[2] * REG_SIZE + i] = t->vm[PC + i]; t->carry = 0 - t->carry + 1; return (0); } return (1); }
int my_ldi(t_info *t, t_prog *p) { int i; int s; if (PARAM1 && PARAM2 && PARAM3 && PARAM3 < REG_NUMBER) { s = 0; if (TYPE_PARAM1 == P_DIR) s += PARAM1; else if (TYPE_PARAM1 == P_IND) s += get_ind_value(t, p, 0, IDX_MOD); else s += get_reg_value(p, 0); if (TYPE_PARAM2 == P_DIR) s += PARAM2; else s += get_reg_value(p, 1); i = -1; PC = get_index(PC, s, IDX_MOD); while (++i && i < REG_SIZE) p->reg[PARAM3 * REG_SIZE + i] = t->vm[PC + i]; t->carry = 0 - t->carry + 1; return (0); } return (1); }
static void set_registry_variables(WCHAR **env, HKEY hkey, DWORD type, BOOL set_path) { static const WCHAR SystemRootW[] = {'S','y','s','t','e','m','R','o','o','t',0}; static const WCHAR SystemDriveW[] = {'S','y','s','t','e','m','D','r','i','v','e',0}; static const WCHAR PATHW[] = {'P','A','T','H'}; UNICODE_STRING us_name, us_value; WCHAR name[1024], value[1024]; DWORD ret, index, size; for (index = 0; ; index++) { size = sizeof(name)/sizeof(WCHAR); ret = RegEnumValueW(hkey, index, name, &size, NULL, NULL, NULL, NULL); if (ret != ERROR_SUCCESS) break; if (!memicmpW(name, SystemRootW, sizeof(SystemRootW)/sizeof(WCHAR))) continue; if (!memicmpW(name, SystemDriveW, sizeof(SystemDriveW)/sizeof(WCHAR))) continue; RtlInitUnicodeString(&us_name, name); us_value.Buffer = value; us_value.MaximumLength = sizeof(value); if (!memicmpW(name, PATHW, sizeof(PATHW)/sizeof(WCHAR)) && !RtlQueryEnvironmentVariable_U(*env, &us_name, &us_value)) { if (!set_path) continue; size = strlenW(value)+1; if (!get_reg_value(*env, hkey, name, value+size, sizeof(value)-size*sizeof(WCHAR))) continue; value[size] = ';'; RtlInitUnicodeString(&us_value, value); RtlSetEnvironmentVariable(env, &us_name, &us_value); continue; } if (!get_reg_value(*env, hkey, name, value, sizeof(value))) continue; if(!value[0]) continue; RtlInitUnicodeString(&us_value, value); RtlSetEnvironmentVariable(env, &us_name, &us_value); } }
int my_aff(t_info *t, t_prog *p) { if (t != NULL && p->param[0] < REG_SIZE) { my_putchar(get_reg_value(p, 0) % 256); return (0); } return (1); }
//Search for a value first in 64bit regs then in 32bit regs std::string find_reg_value(HKEY hKey, std::string key_name, LPCTSTR lpValueName, std::string defaultValue) { auto res = get_reg_value(hKey, key_name, lpValueName, defaultValue); if (res == "") res = regGetValue32(hKey, key_name, lpValueName, defaultValue); return res; }
/** * INI ファイルを保存するディレクトリ(このモジュールが配置されているディレクトリ)を取得する。 * * この関数は成功するとディレクトリをポインタで返す。 * 呼び出し元は戻り値が NULL ではないなら、ポインタを適切に開放しなければならない。 * * @return ディレクトリパス */ static char *getMacroDir(void) { char *work; char *temp; DWORD type; if ((temp = (char *)get_reg_value(hideinstloc, &type)) == NULL) { // 秀丸がインストールされていないなら、秀丸メールディレクトリがホーム work = (char *)get_reg_value(turukamedir, &type); } else { // 秀丸がインストールされているならマクロパスを調べる if ((work = (char *)get_reg_value(macropath, &type)) == NULL) { // マクロパスが存在しなければ秀丸の InstallLocation がホーム size_t size = strlen(temp) + 1; work = (char *)malloc(size); strcpy_s(work, size, temp); } } if (temp != NULL) { free(temp); } return work; }
/** * DLL のメインエントリポイント。 * 設定ファイルから内容の読み出しを行っている。 */ BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { hInst = (HINSTANCE)hModule; switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: { // 設定ファイルから内容を読み出す char *work = getMacroDir(); std::string iniFilePath = work; #ifdef _DEBUG std::string logFilePath = work; logFilePath += "\\HidemaruMailSearch.log"; fopen_s(&logFile, logFilePath.c_str(), "w"); #endif free(work); iniFilePath += "\\HidemaruMailSearch.ini"; iniFile = new IniFile(iniFilePath.c_str()); for (int i = 0; i < MAX_HISTORY; i++) { std::string key = "history"; char num[3] = {0}; _itoa_s(i, num, 10); key += num; char *temp = iniFile->read("History", key.c_str()); if (temp != NULL) { if (strlen(temp) != 0) { std::string value = temp; history.push_back(value); } free(temp); } } work = iniFile->read("Config", "radio"); if (strcmp(work, "1") == 0) { selectedRadioButton = IDC_RADIO1; } else if (strcmp(work, "2") == 0) { selectedRadioButton = IDC_RADIO2; } else if (strcmp(work, "3") == 0) { selectedRadioButton = IDC_RADIO3; } else if (strcmp(work, "4") == 0) { selectedRadioButton = IDC_RADIO4; } else { selectedRadioButton = IDC_RADIO1; } if (work != NULL) { free(work); } work = iniFile->read("Config", "check"); if (strcmp(work, "TRUE") == 0) { selectedCheckBox = TRUE; } else { selectedCheckBox = FALSE; } if (work != NULL) { free(work); } // TKInfo.dll の初期化とエクスポート関数の取得 char *hidemaruMailDir = (char *)get_reg_value(HIDEMARU_MAIL_DIR_KEY, NULL); std::string tkInfo = hidemaruMailDir; free(hidemaruMailDir); tkInfo += "TKInfo.dll"; hInstDLL = LoadLibrary(tkInfo.c_str()); GET_FUNC(HidemaruMailVersion); GET_FUNC(StartDoGrep); GET_FUNC(SetFindPack); GET_FUNC(CurrentAccount); GET_FUNC(CurrentFolder); GET_FUNC(YenEncode); GET_FUNC(ExecAtMain); GET_FUNC(SetQuietMode); GET_FUNC(IsHidemaruMail); GET_FUNC(IsHidemaruMailMain); GET_FUNC(IsHidemaruMailGrep); GET_FUNC(MainWnd); GET_FUNC(PushFindPack); break; } case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: if (iniFile != NULL) { delete iniFile; } #ifdef _DEBUG fclose(logFile); #endif break; } return TRUE; }
/** * マクロから呼び出されるエントリポイント。 * @param [in] text 検索文字列 * @return 戻り値に意味はない */ EXPORT int search(const char *text) { if (!IsHidemaruMail()) { #ifndef _DEBUG MessageBox(NULL, "このマクロは秀丸からは起動できません。", NULL, MB_OK); return 0; #endif } HWND hwnd = reinterpret_cast<HWND>(MainWnd()); if (hwnd == NULL) { MessageBox(NULL, "秀丸メール本体が起動してなければなりません。", NULL, MB_OK); return 0; } if (strlen(text) != 0) { std::string oneLine = text; size_t pos; if ((pos = oneLine.find("\r\n")) != std::string.npos) { oneLine[pos] = '\0'; } if (oneLine.find(' ') != std::string.npos) { selectedText = "\""; selectedText += YenEncode(oneLine.c_str()); selectedText += "\""; } else { selectedText = YenEncode(oneLine.c_str()); } } // SetQuietMode を使用すると、検索結果ウィンドウが手前に来ない // SetQuietMode(1); int rc = (int)DialogBox(hInst, (LPCTSTR)IDD_HIDEMARUMAILSEARCH_DIALOG, hwnd, (DLGPROC)DialogProc); // SetQuietMode(0); if (rc == IDOK) { const char *account = NULL; const char *folder = NULL; switch (selectedRadioButton) { case IDC_RADIO1: case IDC_RADIO2: account = (const char *)ExecAtMain("CurrentAccount"); if (IsHidemaruMailMain() || IsHidemaruMailGrep()) { folder = CurrentFolder(); } else { folder = (const char *)ExecAtMain("CurrentFolder"); } break; case IDC_RADIO3: account = (const char *)ExecAtMain("CurrentAccount"); if (selectedCheckBox) { folder = ""; } else { folder = "受信+送信済み+ユーザー"; } break; case IDC_RADIO4: account = ""; if (selectedCheckBox) { folder = ""; } else { folder = "受信+送信済み+ユーザー"; } break; } #ifdef _DEBUG switch (selectedRadioButton) { case IDC_RADIO1: case IDC_RADIO2: case IDC_RADIO3: if (account == NULL || strlen(account) == 0) { MessageBox(NULL, "秀丸メールにアカウントが見つかりませんでした。\nこのエラーが頻発するようなら作者に連絡してください。", "HidemaruMailSearch", MB_OK); } break; } #endif std::string inputText = history[0].c_str(); std::string query; trim(inputText); // お気に入りの保存と読み込み if (inputText.find("fav:") == 0) { size_t pos = inputText.find(' '); if (pos != std::string::npos) { size_t len = strlen("fav:"); if (pos != len) { std::string favname = inputText.substr(len, pos - len); std::string favval = inputText.substr(pos + 1); if (favval == "\"\"") { iniFile->write("Favorite", favname.c_str(), NULL); return 0; } else { iniFile->write("Favorite", favname.c_str(), favval.c_str()); return 0; } } } else { char *favval = iniFile->read("Favorite", inputText.substr(strlen("fav:")).c_str()); if (favval != NULL) { inputText = favval; free(favval); } } } if (inputText.compare("help:") == 0) { if (helpCmd == "") { char *temp; char *work = NULL; DWORD type; if ((temp = (char *)get_reg_value(hideinstloc, &type)) == NULL) { // 秀丸がインストールされていないなら、メモ帳 helpCmd = "notepad.exe "; work = (char *)get_reg_value(turukamedir, &type); helpCmd += "\""; helpCmd += work; helpCmd += "\\HidemaruMailSearch.txt\""; } else { helpCmd = "\""; helpCmd += temp; helpCmd += "\\Hidemaru.exe\" \""; helpCmd += "/j"; helpCmd += HELPFILE_LINE; helpCmd += " "; if ((work = (char *)get_reg_value(macropath, &type)) == NULL) { // マクロパスが存在しなければ秀丸の InstallLocation がホーム helpCmd += temp; } else { helpCmd += work; } helpCmd += "\\HidemaruMailSearch.txt\""; } if (temp != NULL) { free(temp); } if (work != NULL) { free(work); } } PROCESS_INFORMATION pi; STARTUPINFO si; memset(&si, 0, sizeof(STARTUPINFO)); si.cb = sizeof(STARTUPINFO); CreateProcess(NULL, (LPSTR)helpCmd.c_str(), NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi); return 0; } else if (inputText.find("debug:") == 0) { query = inputText.substr(strlen("debug:")); } else { std::string flag; trim(inputText); while (inputText.size() != 0) { int tagKind = findTag(inputText); if (tagKind == TARGET_SMALLHEADERBODY && inputText.find(colon_targets[TARGET_SMALLHEADERBODY]) != 0) { inputText = colon_targets[TARGET_SMALLHEADERBODY] + inputText; } rc = makeQuery(tagKind, inputText, query, flag); trim(inputText); } if (flag.size() != 0) { if (query.size() != 0) { query += ","; } query += flag; } // サブフォルダを検索対称にするかどうか if (selectedRadioButton == IDC_RADIO2) { query += ",subfolder=1"; } else { query += ",subfolder=0"; } // 常にハイライト query += ",hilight=1"; } #ifdef _DEBUG println("■アカウント"); println(account); println("■フォルダ"); println(folder); println("■検索式"); println(query); println("■入力"); println(history[0]); #endif if (IsHidemaruMailMain() || IsHidemaruMailGrep()) { SetFindPack(query.c_str()); StartDoGrep(account, folder); PushFindPack(); } else { ExecAtMain("SetFindPack", query.c_str()); ExecAtMain("StartDoGrep", account, folder); ExecAtMain("PushFindPack"); } } return 0; }
BOOL WINAPI CreateEnvironmentBlock( LPVOID* lpEnvironment, HANDLE hToken, BOOL bInherit ) { static const WCHAR env_keyW[] = {'S','y','s','t','e','m','\\', 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\', 'C','o','n','t','r','o','l','\\', 'S','e','s','s','i','o','n',' ','M','a','n','a','g','e','r','\\', 'E','n','v','i','r','o','n','m','e','n','t',0}; static const WCHAR profile_keyW[] = {'S','o','f','t','w','a','r','e','\\', 'M','i','c','r','o','s','o','f','t','\\', 'W','i','n','d','o','w','s',' ','N','T','\\', 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', 'P','r','o','f','i','l','e','L','i','s','t',0}; static const WCHAR envW[] = {'E','n','v','i','r','o','n','m','e','n','t',0}; static const WCHAR volatile_envW[] = {'V','o','l','a','t','i','l','e',' ','E','n','v','i','r','o','n','m','e','n','t',0}; static const WCHAR ProfilesDirectoryW[] = {'P','r','o','f','i','l','e','s','D','i','r','e','c','t','o','r','y',0}; static const WCHAR SystemRootW[] = {'S','y','s','t','e','m','R','o','o','t',0}; static const WCHAR SystemDriveW[] = {'S','y','s','t','e','m','D','r','i','v','e',0}; static const WCHAR AllUsersProfileW[] = {'A','l','l','U','s','e','r','s','P','r','o','f','i','l','e',0}; static const WCHAR ALLUSERSPROFILEW[] = {'A','L','L','U','S','E','R','S','P','R','O','F','I','L','E',0}; static const WCHAR USERNAMEW[] = {'U','S','E','R','N','A','M','E',0}; static const WCHAR USERPROFILEW[] = {'U','S','E','R','P','R','O','F','I','L','E',0}; static const WCHAR DefaultW[] = {'D','e','f','a','u','l','t',0}; static const WCHAR COMPUTERNAMEW[] = {'C','O','M','P','U','T','E','R','N','A','M','E',0}; WCHAR *env, buf[UNICODE_STRING_MAX_CHARS], profiles_dir[MAX_PATH]; UNICODE_STRING us_name, us_val; DWORD len; HKEY hkey, hsubkey; TRACE("%p %p %d\n", lpEnvironment, hToken, bInherit ); if (!lpEnvironment) return FALSE; if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, env_keyW, 0, KEY_READ, &hkey) != ERROR_SUCCESS) return FALSE; if (RtlCreateEnvironment(bInherit, &env) != STATUS_SUCCESS) { RegCloseKey(hkey); return FALSE; } if (!GetEnvironmentVariableW(SystemRootW, buf, UNICODE_STRING_MAX_CHARS)) { if (!get_reg_value(env, hkey, SystemRootW, buf, UNICODE_STRING_MAX_CHARS)) { buf[0] = 0; WARN("SystemRoot variable not set\n"); } } RtlInitUnicodeString(&us_name, SystemRootW); RtlInitUnicodeString(&us_val, buf); RtlSetEnvironmentVariable(&env, &us_name, &us_val); if (!GetEnvironmentVariableW(SystemDriveW, buf, UNICODE_STRING_MAX_CHARS)) { if (!get_reg_value(env, hkey, SystemRootW, buf, UNICODE_STRING_MAX_CHARS)) { buf[0] = 0; WARN("SystemDrive variable not set\n"); } } RtlInitUnicodeString(&us_name, SystemDriveW); RtlInitUnicodeString(&us_val, buf); RtlSetEnvironmentVariable(&env, &us_name, &us_val); set_registry_variables(&env, hkey, REG_SZ, !bInherit); set_registry_variables(&env, hkey, REG_EXPAND_SZ, !bInherit); if (RegOpenKeyExW(hkey, envW, 0, KEY_READ, &hsubkey) == ERROR_SUCCESS) { set_registry_variables(&env, hsubkey, REG_SZ, !bInherit); set_registry_variables(&env, hsubkey, REG_EXPAND_SZ, !bInherit); RegCloseKey(hsubkey); } if (RegOpenKeyExW(hkey, volatile_envW, 0, KEY_READ, &hsubkey) == ERROR_SUCCESS) { set_registry_variables(&env, hsubkey, REG_SZ, !bInherit); set_registry_variables(&env, hsubkey, REG_EXPAND_SZ, !bInherit); RegCloseKey(hsubkey); } RegCloseKey(hkey); if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, profile_keyW, 0, KEY_READ, &hkey) == ERROR_SUCCESS) { if (get_reg_value(env, hkey, ProfilesDirectoryW, profiles_dir, MAX_PATH-sizeof(WCHAR))) { len = strlenW(profiles_dir); if (profiles_dir[len-1] != '\\') { profiles_dir[len++] = '\\'; profiles_dir[len] = '\0'; } memcpy(buf, profiles_dir, len*sizeof(WCHAR)); if (get_reg_value(env, hkey, AllUsersProfileW, buf+len, UNICODE_STRING_MAX_CHARS-len)) { RtlInitUnicodeString(&us_name, ALLUSERSPROFILEW); RtlInitUnicodeString(&us_val, buf); RtlSetEnvironmentVariable(&env, &us_name, &us_val); } } else { profiles_dir[0] = 0; } RegCloseKey(hkey); } len = sizeof(buf)/sizeof(WCHAR); if (GetComputerNameW(buf, &len)) { RtlInitUnicodeString(&us_name, COMPUTERNAMEW); RtlInitUnicodeString(&us_val, buf); RtlSetEnvironmentVariable(&env, &us_name, &us_val); } set_wow64_environment(&env); if (!hToken) { if (profiles_dir[0]) { len = strlenW(profiles_dir); if (len*sizeof(WCHAR)+sizeof(DefaultW) < sizeof(buf)) { memcpy(buf, profiles_dir, len*sizeof(WCHAR)); memcpy(buf+len, DefaultW, sizeof(DefaultW)); RtlInitUnicodeString(&us_name, USERPROFILEW); RtlInitUnicodeString(&us_val, buf); RtlSetEnvironmentVariable(&env, &us_name, &us_val); } } buf[0] = '.'; memcpy(buf+1, DefaultW, sizeof(DefaultW)); } else { TOKEN_USER *token_user = NULL; SID_NAME_USE use; WCHAR *sidW; DWORD size, tmp=0; if (GetTokenInformation(hToken, TokenUser, NULL, 0, &len) || GetLastError()!=ERROR_INSUFFICIENT_BUFFER || !(token_user = HeapAlloc(GetProcessHeap(), 0, len)) || !GetTokenInformation(hToken, TokenUser, token_user, len, &len) || !ConvertSidToStringSidW(token_user->User.Sid, &sidW)) { HeapFree(GetProcessHeap(), 0, token_user); RtlDestroyEnvironment(env); return FALSE; } len = strlenW(profiles_dir); memcpy(buf, profiles_dir, len*sizeof(WCHAR)); size = UNICODE_STRING_MAX_CHARS-len; if (LookupAccountSidW(NULL, token_user->User.Sid, buf+len, &size, NULL, &tmp, &use)) { RtlInitUnicodeString(&us_name, USERNAMEW); RtlInitUnicodeString(&us_val, buf+len); RtlSetEnvironmentVariable(&env, &us_name, &us_val); if (len) { RtlInitUnicodeString(&us_name, USERPROFILEW); RtlInitUnicodeString(&us_val, buf); RtlSetEnvironmentVariable(&env, &us_name, &us_val); } } HeapFree(GetProcessHeap(), 0, token_user); strcpyW(buf, sidW); LocalFree(sidW); } if (RegOpenKeyExW(HKEY_USERS, buf, 0, KEY_READ, &hkey) == ERROR_SUCCESS) { if (RegOpenKeyExW(hkey, envW, 0, KEY_READ, &hsubkey) == ERROR_SUCCESS) { set_registry_variables(&env, hsubkey, REG_SZ, !bInherit); set_registry_variables(&env, hsubkey, REG_EXPAND_SZ, !bInherit); RegCloseKey(hsubkey); } if (RegOpenKeyExW(hkey, volatile_envW, 0, KEY_READ, &hsubkey) == ERROR_SUCCESS) { set_registry_variables(&env, hsubkey, REG_SZ, !bInherit); set_registry_variables(&env, hsubkey, REG_EXPAND_SZ, !bInherit); RegCloseKey(hsubkey); } RegCloseKey(hkey); } *lpEnvironment = env; return TRUE; }
static void set_wow64_environment(WCHAR **env) { static const WCHAR versionW[] = {'S','o','f','t','w','a','r','e','\\', 'M','i','c','r','o','s','o','f','t','\\', 'W','i','n','d','o','w','s','\\', 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0}; static const WCHAR progdirW[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r',0}; static const WCHAR progdir86W[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r',' ','(','x','8','6',')',0}; static const WCHAR progfilesW[] = {'P','r','o','g','r','a','m','F','i','l','e','s',0}; static const WCHAR progw6432W[] = {'P','r','o','g','r','a','m','W','6','4','3','2',0}; static const WCHAR commondirW[] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r',0}; static const WCHAR commondir86W[] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r',' ','(','x','8','6',')',0}; static const WCHAR commonfilesW[] = {'C','o','m','m','o','n','P','r','o','g','r','a','m','F','i','l','e','s',0}; static const WCHAR commonw6432W[] = {'C','o','m','m','o','n','P','r','o','g','r','a','m','W','6','4','3','2',0}; UNICODE_STRING nameW, valueW; WCHAR buf[64]; HKEY hkey; BOOL is_win64 = (sizeof(void *) > sizeof(int)); BOOL is_wow64; IsWow64Process( GetCurrentProcess(), &is_wow64 ); if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, versionW, 0, KEY_READ|KEY_WOW64_64KEY, &hkey)) return; /* set the ProgramFiles variables */ if (get_reg_value(*env, hkey, progdirW, buf, sizeof(buf))) { if (is_win64 || is_wow64) { RtlInitUnicodeString(&nameW, progw6432W); RtlInitUnicodeString(&valueW, buf); RtlSetEnvironmentVariable(env, &nameW, &valueW); } if (is_win64 || !is_wow64) { RtlInitUnicodeString(&nameW, progfilesW); RtlInitUnicodeString(&valueW, buf); RtlSetEnvironmentVariable(env, &nameW, &valueW); } } if (is_wow64 && get_reg_value(*env, hkey, progdir86W, buf, sizeof(buf))) { RtlInitUnicodeString(&nameW, progfilesW); RtlInitUnicodeString(&valueW, buf); RtlSetEnvironmentVariable(env, &nameW, &valueW); } /* set the CommonProgramFiles variables */ if (get_reg_value(*env, hkey, commondirW, buf, sizeof(buf))) { if (is_win64 || is_wow64) { RtlInitUnicodeString(&nameW, commonw6432W); RtlInitUnicodeString(&valueW, buf); RtlSetEnvironmentVariable(env, &nameW, &valueW); } if (is_win64 || !is_wow64) { RtlInitUnicodeString(&nameW, commonfilesW); RtlInitUnicodeString(&valueW, buf); RtlSetEnvironmentVariable(env, &nameW, &valueW); } } if (is_wow64 && get_reg_value(*env, hkey, commondir86W, buf, sizeof(buf))) { RtlInitUnicodeString(&nameW, commonfilesW); RtlInitUnicodeString(&valueW, buf); RtlSetEnvironmentVariable(env, &nameW, &valueW); } RegCloseKey(hkey); }