[1/2] shell32: Check IsWow64Process() before calling Wow64 functions.

Nikolay Sivov bunglehead at gmail.com
Wed Apr 20 19:28:40 CDT 2016


On 21.04.2016 3:12, Olivier F. R. Dierick wrote:
> See bug 36838 for comments and discussion.
> 
> Supersedes patch submission 121402.
> 
> Better version of the patch. Call IsWow64Process() only once on dll
> initialization and setup a global variable.
> 
>>From e7b7317755faff75b960f9143b2195344113a9a4 Mon Sep 17 00:00:00 2001
> From: "Olivier F. R. Dierick" <o.dierick at piezo-forte.be>
> Date: Wed, 20 Apr 2016 06:45:38 +0200
> Subject: shell32: Check IsWow64Process() before calling Wow64 functions.
> 
> Signed-off-by: Olivier F. R. Dierick <o.dierick at piezo-forte.be>
> ---
>  dlls/shell32/shell32_main.c  |    3 +++
>  dlls/shell32/shell32_main.h  |    1 +
>  dlls/shell32/shfldr_unixfs.c |    6 ++++--
>  3 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/dlls/shell32/shell32_main.c b/dlls/shell32/shell32_main.c
> index 74deecd..98e7fbf 100644
> --- a/dlls/shell32/shell32_main.c
> +++ b/dlls/shell32/shell32_main.c
> @@ -1255,6 +1255,7 @@ HRESULT WINAPI DllGetVersion (DLLVERSIONINFO
> *pdvi)
>   *
>   */
>  HINSTANCE    shell32_hInstance = 0;
> +BOOL         is_wow64 = FALSE;
>  
>  
>  /*************************************************************************
> @@ -1277,6 +1278,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD
> fdwReason, LPVOID fImpLoad)
>          GetModuleFileNameW(hinstDLL, swShell32Name, MAX_PATH);
>          swShell32Name[MAX_PATH - 1] = '\0';
>  
> +        if (!IsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64
> = FALSE;
> +
>          InitChangeNotifications();
>          break;
>  
> diff --git a/dlls/shell32/shell32_main.h b/dlls/shell32/shell32_main.h
> index 492f79f..7a4d9b2 100644
> --- a/dlls/shell32/shell32_main.h
> +++ b/dlls/shell32/shell32_main.h
> @@ -42,6 +42,7 @@
>  */
>  extern HMODULE	huser32 DECLSPEC_HIDDEN;
>  extern HINSTANCE shell32_hInstance DECLSPEC_HIDDEN;
> +extern BOOL is_wow64 DECLSPEC_HIDDEN;
>  
>  /* Iconcache */
>  #define INVALID_INDEX -1
> diff --git a/dlls/shell32/shfldr_unixfs.c b/dlls/shell32/shfldr_unixfs.c
> index be1ba81..d9b1320 100644
> --- a/dlls/shell32/shfldr_unixfs.c
> +++ b/dlls/shell32/shfldr_unixfs.c
> @@ -414,7 +414,8 @@ static BOOL UNIXFS_get_unix_path(LPCWSTR pszDosPath,
> char *pszCanonicalPath)
>      dospath_end = dospath + lstrlenW(dospath);
>      /* search for the most valid UNIX path possible, then append
> missing
>       * path parts */
> -    Wow64DisableWow64FsRedirection(&redir);
> +    if(is_wow64)
> +        Wow64DisableWow64FsRedirection(&redir);
>      while(!(pszUnixPath = wine_get_unix_file_name(dospath))){
>          if(has_failed){
>              *dospath_end = '/';
> @@ -428,7 +429,8 @@ static BOOL UNIXFS_get_unix_path(LPCWSTR pszDosPath,
> char *pszCanonicalPath)
>          }
>          *dospath_end = '\0';
>      }
> -    Wow64RevertWow64FsRedirection(redir);
> +    if(is_wow64)
> +        Wow64RevertWow64FsRedirection(redir);
>      if(dospath_end < dospath)
>          return FALSE;
>      strcat(szPath, pszUnixPath + cDriveSymlinkLen);
> 

Like I said in bug comment, doing this is depending on a side effect.
SHFileOperation() could do anything internally, if you want to have
consistent ERROR_SUCCESS last error (even though it's kind of wrong to
check it, since it returns error code already), why not force it in
SHFileOperation() directly? Changing internal path is wrong in my opinion.



More information about the wine-devel mailing list