diff --git a/src/WINNT/afsd/NTMakefile b/src/WINNT/afsd/NTMakefile index bdce860725..9aab931446 100644 --- a/src/WINNT/afsd/NTMakefile +++ b/src/WINNT/afsd/NTMakefile @@ -412,7 +412,7 @@ $(EXEDIR)\symlink.exe: $(SLOBJS) $(OUT)\symlink.res $(EXELIBS) $(EXEPREP) # afsshare.exe -$(EXEDIR)\afsshare.exe: $(OUT)\afsshare.obj $(OUT)\afsshare.res +$(EXEDIR)\afsshare.exe: $(OUT)\afsshare.obj $(OUT)\afsshare.res $(EXELIBS) $(EXECONLINK) $(_VC_MANIFEST_EMBED_EXE) $(EXEPREP) diff --git a/src/WINNT/afsd/afskfw.c b/src/WINNT/afsd/afskfw.c index 69bd459673..352f48086c 100644 --- a/src/WINNT/afsd/afskfw.c +++ b/src/WINNT/afsd/afskfw.c @@ -497,6 +497,34 @@ KFW_cleanup(void) FreeLibrary(hKrb5); } +typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); +static int IsWow64() +{ + static int init = TRUE; + static int bIsWow64 = FALSE; + + if (init) { + HMODULE hModule; + LPFN_ISWOW64PROCESS fnIsWow64Process = NULL; + + hModule = GetModuleHandle(TEXT("kernel32")); + if (hModule) { + fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(hModule, "IsWow64Process"); + + if (NULL != fnIsWow64Process) + { + if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64)) + { + // on error, assume FALSE. + // in other words, do nothing. + } + } + FreeLibrary(hModule); + } + init = FALSE; + } + return bIsWow64; +} int KFW_accept_dotted_usernames(void) @@ -506,7 +534,7 @@ KFW_accept_dotted_usernames(void) DWORD value = 1; code = RegOpenKeyEx(HKEY_CURRENT_USER, AFSREG_USER_OPENAFS_SUBKEY, - 0, KEY_QUERY_VALUE, &parmKey); + 0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &parmKey); if (code == ERROR_SUCCESS) { len = sizeof(value); code = RegQueryValueEx(parmKey, "AcceptDottedPrincipalNames", NULL, NULL, @@ -515,7 +543,7 @@ KFW_accept_dotted_usernames(void) } if (code != ERROR_SUCCESS) { code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_OPENAFS_SUBKEY, - 0, KEY_QUERY_VALUE, &parmKey); + 0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &parmKey); if (code == ERROR_SUCCESS) { len = sizeof(value); code = RegQueryValueEx(parmKey, "AcceptDottedPrincipalNames", NULL, NULL, @@ -535,7 +563,7 @@ KFW_use_krb524(void) DWORD use524 = 0; code = RegOpenKeyEx(HKEY_CURRENT_USER, AFSREG_USER_OPENAFS_SUBKEY, - 0, KEY_QUERY_VALUE, &parmKey); + 0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &parmKey); if (code == ERROR_SUCCESS) { len = sizeof(use524); code = RegQueryValueEx(parmKey, "Use524", NULL, NULL, @@ -544,7 +572,7 @@ KFW_use_krb524(void) } if (code != ERROR_SUCCESS) { code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_OPENAFS_SUBKEY, - 0, KEY_QUERY_VALUE, &parmKey); + 0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &parmKey); if (code == ERROR_SUCCESS) { len = sizeof(use524); code = RegQueryValueEx(parmKey, "Use524", NULL, NULL, @@ -563,7 +591,7 @@ KFW_is_available(void) DWORD enableKFW = 1; code = RegOpenKeyEx(HKEY_CURRENT_USER, AFSREG_USER_OPENAFS_SUBKEY, - 0, KEY_QUERY_VALUE, &parmKey); + 0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &parmKey); if (code == ERROR_SUCCESS) { len = sizeof(enableKFW); code = RegQueryValueEx(parmKey, "EnableKFW", NULL, NULL, @@ -573,7 +601,7 @@ KFW_is_available(void) if (code != ERROR_SUCCESS) { code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_OPENAFS_SUBKEY, - 0, KEY_QUERY_VALUE, &parmKey); + 0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &parmKey); if (code == ERROR_SUCCESS) { len = sizeof(enableKFW); code = RegQueryValueEx(parmKey, "EnableKFW", NULL, NULL, diff --git a/src/WINNT/afsd/afsshare.c b/src/WINNT/afsd/afsshare.c index 3e6dd27280..6b3adcd8d8 100644 --- a/src/WINNT/afsd/afsshare.c +++ b/src/WINNT/afsd/afsshare.c @@ -32,7 +32,7 @@ main(int argc, char **argv) { 0, NULL, REG_OPTION_NON_VOLATILE, - KEY_READ|KEY_WRITE, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_READ|KEY_WRITE, NULL, &hkSubmounts, NULL) == ERROR_SUCCESS) @@ -50,7 +50,7 @@ main(int argc, char **argv) { 0, NULL, REG_OPTION_NON_VOLATILE, - KEY_READ, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_READ, NULL, &hkParameters, NULL) == ERROR_SUCCESS) diff --git a/src/WINNT/afsd/cm.h b/src/WINNT/afsd/cm.h index a1776da1f0..4273392355 100644 --- a/src/WINNT/afsd/cm.h +++ b/src/WINNT/afsd/cm.h @@ -89,6 +89,7 @@ #define CM_ERROR_INEXACT_MATCH (CM_ERROR_BASE+54) #define CM_ERROR_BPLUS_NOMATCH (CM_ERROR_BASE+55) #define CM_ERROR_EAS_NOT_SUPPORTED (CM_ERROR_BASE+56) +#define CM_ERROR_RANGE_NOT_LOCKED (CM_ERROR_BASE+57) /* Used by cm_FollowMountPoint and cm_GetVolumeByName */ #define RWVOL 0 diff --git a/src/WINNT/afsd/fs.c b/src/WINNT/afsd/fs.c index 87896d88f1..e7c987d7c0 100644 --- a/src/WINNT/afsd/fs.c +++ b/src/WINNT/afsd/fs.c @@ -702,7 +702,7 @@ static DWORD IsFreelance(void) DWORD enabled = 0; code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY, - 0, KEY_QUERY_VALUE, &parmKey); + 0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &parmKey); if (code == ERROR_SUCCESS) { dummyLen = sizeof(cm_freelanceEnabled); code = RegQueryValueEx(parmKey, "FreelanceClient", NULL, NULL, @@ -721,7 +721,7 @@ static const char * NetbiosName(void) DWORD enabled = 0; code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY, - 0, KEY_QUERY_VALUE, &parmKey); + 0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &parmKey); if (code == ERROR_SUCCESS) { dummyLen = sizeof(buffer); code = RegQueryValueEx(parmKey, "NetbiosName", NULL, NULL, @@ -4036,7 +4036,7 @@ CSCPolicyCmd(struct cmd_syndesc *asp, void *arock) 0, "AFS", REG_OPTION_NON_VOLATILE, - KEY_WRITE, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_WRITE, NULL, &hkCSCPolicy, NULL ); @@ -4084,7 +4084,7 @@ CSCPolicyCmd(struct cmd_syndesc *asp, void *arock) 0, "AFS", REG_OPTION_NON_VOLATILE, - KEY_READ|KEY_QUERY_VALUE, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_READ|KEY_QUERY_VALUE, NULL, &hkCSCPolicy, NULL ); diff --git a/src/WINNT/afsd/fs_utils.c b/src/WINNT/afsd/fs_utils.c index cc19bf198d..884fc8e0e6 100644 --- a/src/WINNT/afsd/fs_utils.c +++ b/src/WINNT/afsd/fs_utils.c @@ -197,7 +197,8 @@ void fs_utils_InitMountRoot() char *pmount=mountRoot; DWORD len=sizeof(mountRoot)-1; printf("int mountroot \n"); - if ((RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY, 0, KEY_QUERY_VALUE, &parmKey)!= ERROR_SUCCESS) + if ((RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY, 0, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &parmKey)!= ERROR_SUCCESS) || (RegQueryValueEx(parmKey, "Mountroot", NULL, NULL,(LPBYTE)(mountRoot), &len)!= ERROR_SUCCESS) || (len==sizeof(mountRoot)-1) ) @@ -215,4 +216,3 @@ void fs_utils_InitMountRoot() strcpy(cm_back_slash_mount_root+1,pmount); cm_back_slash_mount_root[0]='\\'; } - diff --git a/src/WINNT/afsd/smb.c b/src/WINNT/afsd/smb.c index ca9f514976..32b77270e6 100644 --- a/src/WINNT/afsd/smb.c +++ b/src/WINNT/afsd/smb.c @@ -2639,7 +2639,11 @@ void smb_MapNTError(long code, unsigned long *NTStatusp) } else if (code == CM_ERROR_BAD_LEVEL) { NTStatus = 0xC0000148L; /* Invalid Level */ - } else { + } + else if (code == CM_ERROR_RANGE_NOT_LOCKED) { + NTStatus = 0xC000007EL; /* Range Not Locked */ + } + else { NTStatus = 0xC0982001L; /* SMB non-specific error */ } diff --git a/src/WINNT/afsd/symlink.c b/src/WINNT/afsd/symlink.c index 9917e959ad..72da4c0674 100644 --- a/src/WINNT/afsd/symlink.c +++ b/src/WINNT/afsd/symlink.c @@ -101,7 +101,7 @@ static const char * NetbiosName(void) DWORD enabled = 0; code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY, - 0, KEY_QUERY_VALUE, &parmKey); + 0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &parmKey); if (code == ERROR_SUCCESS) { dummyLen = sizeof(buffer); code = RegQueryValueEx(parmKey, "NetbiosName", NULL, NULL, diff --git a/src/WINNT/afsreg/afsreg.c b/src/WINNT/afsreg/afsreg.c index 24a9ae0859..b503ad342d 100644 --- a/src/WINNT/afsreg/afsreg.c +++ b/src/WINNT/afsreg/afsreg.c @@ -29,6 +29,35 @@ static long CopyValues(HKEY srcKey, HKEY dupKey); static long CopySubkeys(const char *srcName, HKEY srcKey, const char *dupName, HKEY dupKey); +typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); +int IsWow64(void) +{ + static int init = TRUE; + static int bIsWow64 = FALSE; + + if (init) { + HMODULE hModule; + LPFN_ISWOW64PROCESS fnIsWow64Process = NULL; + + hModule = GetModuleHandle(TEXT("kernel32")); + if (hModule) { + fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(hModule, "IsWow64Process"); + + if (NULL != fnIsWow64Process) + { + if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64)) + { + // on error, assume FALSE. + // in other words, do nothing. + } + } + FreeLibrary(hModule); + } + init = FALSE; + } + return bIsWow64; +} + /* ----------------------- exported functions ----------------------- */ @@ -86,9 +115,9 @@ RegOpenKeyAlt(HKEY key, /* [in] open key from which to start */ if (create) { status = RegCreateKeyEx(key, subKeyName, (DWORD)0, "AFS", REG_OPTION_NON_VOLATILE, - mode, NULL, resultKeyP, &keyDisp); + (IsWow64()?KEY_WOW64_64KEY:0)|mode, NULL, resultKeyP, &keyDisp); } else { - status = RegOpenKeyEx(key, subKeyName, (DWORD)0, mode, resultKeyP); + status = RegOpenKeyEx(key, subKeyName, (DWORD)0, (IsWow64()?KEY_WOW64_64KEY:0)|mode, resultKeyP); } if (resultKeyDispP) { @@ -240,7 +269,7 @@ RegDeleteKeyAlt(HKEY key, /* determine if delete failed due to subkeys */ HKEY subKey; - status = RegOpenKeyEx(key, subKeyName, 0, KEY_ALL_ACCESS, &subKey); + status = RegOpenKeyEx(key, subKeyName, 0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_ALL_ACCESS, &subKey); if (status == ERROR_SUCCESS) { char *keyEnum; diff --git a/src/WINNT/afsreg/afsreg.h b/src/WINNT/afsreg/afsreg.h index e0bafae6a0..a5c61e3c71 100644 --- a/src/WINNT/afsreg/afsreg.h +++ b/src/WINNT/afsreg/afsreg.h @@ -234,6 +234,9 @@ extern long RegDupKeyAlt(const char *sourceKey, const char *targetKey); +extern int +IsWow64(void); + #ifdef __cplusplus }; #endif diff --git a/src/WINNT/client_creds/NTMakefile b/src/WINNT/client_creds/NTMakefile index 3721279ea9..caef2be7b8 100644 --- a/src/WINNT/client_creds/NTMakefile +++ b/src/WINNT/client_creds/NTMakefile @@ -66,6 +66,7 @@ EXELIBS = \ $(DESTDIR)\lib\afsdes.lib \ $(DESTDIR)\lib\afsauthent.lib \ $(DESTDIR)\lib\libafsconf.lib \ + $(DESTDIR)\lib\afs\afsreg.lib \ $(DESTDIR)\lib\afskfw.lib ############################################################################ diff --git a/src/WINNT/client_creds/advtab.cpp b/src/WINNT/client_creds/advtab.cpp index b3d6712b1d..ce77373c2d 100644 --- a/src/WINNT/client_creds/advtab.cpp +++ b/src/WINNT/client_creds/advtab.cpp @@ -298,7 +298,8 @@ void Advanced_OnStartup (HWND hDlg) g.fStartup = IsDlgButtonChecked (hDlg, IDC_STARTUP); HKEY hk; - if (RegCreateKey (HKEY_LOCAL_MACHINE, TEXT(AFSREG_CLT_SVC_PARAM_SUBKEY), &hk) == 0) + if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, TEXT(AFSREG_CLT_SVC_PARAM_SUBKEY), 0, NULL, 0, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_WRITE, NULL, &hk, NULL) == 0) { DWORD dwSize = sizeof(g.fStartup); DWORD dwType = REG_DWORD; diff --git a/src/WINNT/client_creds/creds.cpp b/src/WINNT/client_creds/creds.cpp index 27210563f2..3cec15c650 100644 --- a/src/WINNT/client_creds/creds.cpp +++ b/src/WINNT/client_creds/creds.cpp @@ -158,7 +158,8 @@ void GetGatewayName (LPTSTR pszGateway) { *pszGateway = TEXT('\0'); HKEY hk; - if (RegOpenKey (HKEY_LOCAL_MACHINE, TEXT(AFSREG_CLT_SVC_PARAM_SUBKEY), &hk) == 0) + if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, TEXT(AFSREG_CLT_SVC_PARAM_SUBKEY), 0, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &hk) == 0) { DWORD dwSize = MAX_PATH; DWORD dwType = REG_SZ; @@ -240,7 +241,8 @@ BOOL IsServiceConfigured (void) { rc = TRUE; } - else if (RegOpenKey (HKEY_LOCAL_MACHINE, TEXT(AFSREG_CLT_SVC_PARAM_SUBKEY), &hk) == 0) + else if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, TEXT(AFSREG_CLT_SVC_PARAM_SUBKEY), 0, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &hk) == 0) { TCHAR szCell[ MAX_PATH ]; DWORD dwSize = sizeof(szCell); @@ -454,7 +456,8 @@ int GetDefaultCell (LPTSTR pszCell) int rc; HKEY hk; - if (RegOpenKey (HKEY_CURRENT_USER, TEXT(AFSREG_USER_OPENAFS_SUBKEY), &hk) == 0) + if (RegOpenKeyEx (HKEY_CURRENT_USER, TEXT(AFSREG_USER_OPENAFS_SUBKEY), 0, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &hk) == 0) { DWORD dwSize = sizeof(szCellA); DWORD dwType = REG_SZ; diff --git a/src/WINNT/client_creds/main.cpp b/src/WINNT/client_creds/main.cpp index 0cdd114845..c7bda7c14e 100644 --- a/src/WINNT/client_creds/main.cpp +++ b/src/WINNT/client_creds/main.cpp @@ -181,7 +181,8 @@ BOOL InitApp (LPSTR pszCmdLineA) if (fInstall) { HKEY hk; - if (RegCreateKey (HKEY_CURRENT_USER, AFSREG_USER_OPENAFS_SUBKEY, &hk) == 0) + if (RegCreateKeyEx (HKEY_CURRENT_USER, AFSREG_USER_OPENAFS_SUBKEY, 0, NULL, 0, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_WRITE, NULL, &hk, NULL) == 0) { DWORD dwSize = sizeof(g.fStartup); DWORD dwType = REG_DWORD; @@ -216,14 +217,16 @@ BOOL InitApp (LPSTR pszCmdLineA) return FALSE; HKEY hk; - if (RegOpenKey (HKEY_CURRENT_USER, AFSREG_USER_OPENAFS_SUBKEY, &hk) == 0) + if (RegOpenKeyEx (HKEY_CURRENT_USER, AFSREG_USER_OPENAFS_SUBKEY, 0, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &hk) == 0) { DWORD dwSize = sizeof(g.fStartup); DWORD dwType = REG_DWORD; RegQueryValueEx (hk, TEXT("ShowTrayIcon"), NULL, &dwType, (PBYTE)&g.fStartup, &dwSize); RegCloseKey (hk); } - else if (RegOpenKey (HKEY_LOCAL_MACHINE, AFSREG_CLT_OPENAFS_SUBKEY, &hk) == 0) + else if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, AFSREG_CLT_OPENAFS_SUBKEY, 0, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &hk) == 0) { DWORD dwSize = sizeof(g.fStartup); DWORD dwType = REG_DWORD; @@ -402,7 +405,8 @@ BOOL IsServerInstalled (void) BOOL fInstalled = FALSE; HKEY hk; - if (RegOpenKey (HKEY_LOCAL_MACHINE, AFSREG_SVR_SVC_SUBKEY, &hk) == 0) + if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, AFSREG_SVR_SVC_SUBKEY, 0, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &hk) == 0) { fInstalled = TRUE; RegCloseKey (hk); diff --git a/src/WINNT/client_creds/misc.cpp b/src/WINNT/client_creds/misc.cpp index e759b31cc3..7a449eeaa7 100644 --- a/src/WINNT/client_creds/misc.cpp +++ b/src/WINNT/client_creds/misc.cpp @@ -60,7 +60,8 @@ void LoadRemind (size_t iCreds) g.aCreds[ iCreds ].fRemind = TRUE; HKEY hk; - if (RegOpenKey (HKEY_CURRENT_USER, AFSREG_USER_OPENAFS_SUBKEY "\\Reminders", &hk) == 0) + if (RegOpenKeyEx (HKEY_CURRENT_USER, AFSREG_USER_OPENAFS_SUBKEY "\\Reminders", 0, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &hk) == 0) { DWORD dwValue = 1; DWORD dwSize = sizeof(dwValue); @@ -75,7 +76,8 @@ void LoadRemind (size_t iCreds) void SaveRemind (size_t iCreds) { HKEY hk; - if (RegCreateKey (HKEY_CURRENT_USER, AFSREG_USER_OPENAFS_SUBKEY "\\Reminders", &hk) == 0) + if (RegCreateKeyEx (HKEY_CURRENT_USER, AFSREG_USER_OPENAFS_SUBKEY "\\Reminders", 0, NULL, 0, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_WRITE, NULL, &hk, NULL) == 0) { DWORD dwValue = g.aCreds[ iCreds ].fRemind; RegSetValueEx (hk, g.aCreds[ iCreds ].szCell, NULL, REG_DWORD, (PBYTE)&dwValue, sizeof(DWORD)); @@ -131,4 +133,3 @@ HWND GetTabChild (HWND hTab) return NULL; } - diff --git a/src/WINNT/client_creds/settings.cpp b/src/WINNT/client_creds/settings.cpp index bab9cb2ea7..95bde308da 100644 --- a/src/WINNT/client_creds/settings.cpp +++ b/src/WINNT/client_creds/settings.cpp @@ -18,6 +18,7 @@ extern "C" { #include #include #include +#include "afscreds.h" #include "settings.h" @@ -91,7 +92,8 @@ BOOL StoreSettings (HKEY hkParent, void EraseSettings (HKEY hkParent, LPCTSTR pszBase, LPCTSTR pszValue) { HKEY hk; - if (RegOpenKey (hkParent, pszBase, &hk) == 0) + if (RegOpenKeyEx (hkParent, pszBase, 0, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_SET_VALUE, &hk) == 0) { RegDeleteValue (hk, pszValue); RegCloseKey (hk); @@ -108,7 +110,8 @@ BOOL GetBinaryRegValue (HKEY hk, BOOL rc = FALSE; HKEY hkFinal; - if (RegOpenKey (hk, pszBase, &hkFinal) == ERROR_SUCCESS) + if (RegOpenKeyEx (hk, pszBase, 0, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &hkFinal) == ERROR_SUCCESS) { DWORD dwType; DWORD dwSize = (DWORD)cbData; @@ -130,7 +133,8 @@ size_t GetRegValueSize (HKEY hk, size_t cb = 0; HKEY hkFinal; - if (RegOpenKey (hk, pszBase, &hkFinal) == ERROR_SUCCESS) + if (RegOpenKeyEx (hk, pszBase, 0, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &hkFinal) == ERROR_SUCCESS) { DWORD dwType; DWORD dwSize = 0; @@ -156,7 +160,8 @@ BOOL SetBinaryRegValue (HKEY hk, BOOL rc = FALSE; HKEY hkFinal; - if (RegCreateKey (hk, pszBase, &hkFinal) == ERROR_SUCCESS) + if (RegCreateKeyEx (hk, pszBase, 0, NULL, 0, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_WRITE, NULL, &hkFinal, NULL) == ERROR_SUCCESS) { DWORD dwSize = (DWORD)cbData; @@ -176,7 +181,8 @@ BOOL SetBinaryRegValue (HKEY hk, BOOL RegDeltreeKey (HKEY hk, LPTSTR pszKey) { HKEY hkSub; - if (RegOpenKey (hk, pszKey, &hkSub) == 0) + if (RegOpenKeyEx (hk, pszKey, 0, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_WRITE, &hkSub) == 0) { TCHAR szFound[ MAX_PATH ]; while (RegEnumKey (hkSub, 0, szFound, MAX_PATH) == 0) diff --git a/src/WINNT/client_creds/shortcut.cpp b/src/WINNT/client_creds/shortcut.cpp index 2f6f117a2d..7853968d02 100644 --- a/src/WINNT/client_creds/shortcut.cpp +++ b/src/WINNT/client_creds/shortcut.cpp @@ -117,7 +117,7 @@ void Shortcut_FixStartup (LPCTSTR pszLinkName, BOOL fAutoStart) TCHAR szParams[ 64 ] = TEXT(AFSCREDS_SHORTCUT_OPTIONS); code = RegOpenKeyEx(HKEY_CURRENT_USER, AFSREG_USER_OPENAFS_SUBKEY, - 0, KEY_QUERY_VALUE, &hk); + 0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &hk); if (code == ERROR_SUCCESS) { len = sizeof(szParams); type = REG_SZ; @@ -127,7 +127,7 @@ void Shortcut_FixStartup (LPCTSTR pszLinkName, BOOL fAutoStart) } if (code != ERROR_SUCCESS) { code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_OPENAFS_SUBKEY, - 0, KEY_QUERY_VALUE, &hk); + 0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &hk); if (code == ERROR_SUCCESS) { len = sizeof(szParams); type = REG_SZ; diff --git a/src/WINNT/client_creds/window.cpp b/src/WINNT/client_creds/window.cpp index 3cdda06014..84a07e5c36 100644 --- a/src/WINNT/client_creds/window.cpp +++ b/src/WINNT/client_creds/window.cpp @@ -263,7 +263,8 @@ void Main_OnInitDialog (HWND hDlg) GetString (szUser, IDS_UNKNOWN); HKEY hk; - if (RegOpenKey (HKEY_LOCAL_MACHINE, AFSREG_CLT_SW_VERSION_SUBKEY, &hk) == 0) + if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, AFSREG_CLT_SW_VERSION_SUBKEY, 0, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &hk) == 0) { DWORD dwSize = sizeof(szVersion); DWORD dwType = REG_SZ; @@ -463,14 +464,16 @@ void Main_OnCheckTerminate (void) { HKEY hk; - if (RegOpenKey (HKEY_CURRENT_USER, AFSREG_USER_OPENAFS_SUBKEY, &hk) == 0) + if (RegOpenKeyEx (HKEY_CURRENT_USER, AFSREG_USER_OPENAFS_SUBKEY, 0, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &hk) == 0) { DWORD dwSize = sizeof(g.fStartup); DWORD dwType = REG_DWORD; RegQueryValueEx (hk, TEXT("ShowTrayIcon"), NULL, &dwType, (PBYTE)&g.fStartup, &dwSize); RegCloseKey (hk); } - else if (RegOpenKey (HKEY_LOCAL_MACHINE, AFSREG_CLT_OPENAFS_SUBKEY, &hk) == 0) + else if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, AFSREG_CLT_OPENAFS_SUBKEY, 0, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &hk) == 0) { DWORD dwSize = sizeof(g.fStartup); DWORD dwType = REG_DWORD; @@ -803,7 +806,8 @@ void Terminate_OnOK (HWND hDlg) g.fStartup = IsDlgButtonChecked (hDlg, IDC_STARTUP); HKEY hk; - if (RegCreateKey (HKEY_CURRENT_USER, AFSREG_USER_OPENAFS_SUBKEY, &hk) == 0) + if (RegCreateKeyEx (HKEY_CURRENT_USER, AFSREG_USER_OPENAFS_SUBKEY, 0, NULL, 0, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_WRITE, NULL, &hk, NULL) == 0) { DWORD dwSize = sizeof(g.fStartup); DWORD dwType = REG_DWORD; diff --git a/src/WINNT/client_exp/NTMakefile b/src/WINNT/client_exp/NTMakefile index 0ad2f6c80a..05ed805f5c 100644 --- a/src/WINNT/client_exp/NTMakefile +++ b/src/WINNT/client_exp/NTMakefile @@ -60,6 +60,7 @@ DLLLIBS =\ $(DESTDIR)\lib\afsauthent.lib \ $(DESTDIR)\lib\libafsconf.lib \ $(DESTDIR)\lib\libosi.lib \ + $(DESTDIR)\lib\afs\afsreg.lib \ $(DESTDIR)\lib\afs\TaLocale.lib \ $(DESTDIR)\lib\afs\afsutil.lib diff --git a/src/WINNT/client_exp/afs_shl_ext.cpp b/src/WINNT/client_exp/afs_shl_ext.cpp index 79baf68444..a9edeb910e 100644 --- a/src/WINNT/client_exp/afs_shl_ext.cpp +++ b/src/WINNT/client_exp/afs_shl_ext.cpp @@ -20,8 +20,10 @@ extern "C" { #include #include "help.h" #include "shell_ext.h" -#include "winreg.h" - +#include +extern "C" { +#include "WINNT\afsreg.h" +} #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE @@ -303,7 +305,7 @@ LRESULT DoValueDelete(HKEY hKey,PTCHAR pszSubKey,PTCHAR szValue=NULL) lResult = RegOpenKeyEx( hKey, pszSubKey, 0, - KEY_ALL_ACCESS, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_ALL_ACCESS, &thKey); if(NOERROR == lResult) { @@ -347,3 +349,4 @@ STDAPI DllUnregisterServer(void) return S_OK; } + diff --git a/src/WINNT/client_exp/gui2fs.cpp b/src/WINNT/client_exp/gui2fs.cpp index 3bfc1b81a5..704d4ece6e 100644 --- a/src/WINNT/client_exp/gui2fs.cpp +++ b/src/WINNT/client_exp/gui2fs.cpp @@ -1057,7 +1057,7 @@ const char * NetbiosName(void) DWORD enabled = 0; code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY, - 0, KEY_QUERY_VALUE, &parmKey); + 0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &parmKey); if (code == ERROR_SUCCESS) { dummyLen = sizeof(buffer); code = RegQueryValueEx(parmKey, "NetbiosName", NULL, NULL, @@ -2181,4 +2181,3 @@ BOOL ListSymlink(CStringArray& files) return !error; } - diff --git a/src/WINNT/client_exp/shell_ext.cpp b/src/WINNT/client_exp/shell_ext.cpp index fa89b6366a..d9231381fb 100644 --- a/src/WINNT/client_exp/shell_ext.cpp +++ b/src/WINNT/client_exp/shell_ext.cpp @@ -79,7 +79,7 @@ CShellExt::CShellExt() m_bIsOverlayEnabled=FALSE; if (FAILED(hr)) m_pAlloc = NULL; - RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY,0, KEY_QUERY_VALUE, &NPKey); + RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY,0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &NPKey); LSPsize=sizeof(ShellOption); code=RegQueryValueEx(NPKey, "ShellOption", NULL, &LSPtype, (LPBYTE)&ShellOption, &LSPsize); diff --git a/src/WINNT/client_exp/submounts_dlg.cpp b/src/WINNT/client_exp/submounts_dlg.cpp index f39a5bf642..35a0ee8d7a 100644 --- a/src/WINNT/client_exp/submounts_dlg.cpp +++ b/src/WINNT/client_exp/submounts_dlg.cpp @@ -53,7 +53,7 @@ static CSubmountInfo *ReadSubmtInfo(const CString& strShareName) 0, "AFS", REG_OPTION_NON_VOLATILE, - KEY_READ, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_READ, NULL, &hkSubmounts, NULL ); @@ -174,7 +174,7 @@ BOOL CSubmountsDlg::FillSubmtList() 0, "AFS", REG_OPTION_NON_VOLATILE, - KEY_READ|KEY_WRITE|KEY_QUERY_VALUE, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_READ|KEY_WRITE|KEY_QUERY_VALUE, NULL, &hkSubmounts, NULL ); @@ -256,7 +256,7 @@ static BOOL AddSubmt(CSubmountInfo *pInfo) 0, "AFS", REG_OPTION_NON_VOLATILE, - KEY_WRITE, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_WRITE, NULL, &hkSubmounts, NULL ); @@ -278,7 +278,7 @@ static BOOL DeleteSubmt(CSubmountInfo *pInfo) 0, "AFS", REG_OPTION_NON_VOLATILE, - KEY_WRITE, + (IsWow64()?KEY_WOW64_64KEY:0)|KEY_WRITE, NULL, &hkSubmounts, NULL );