[SHELL32][SDK] Implement RealShellExecute(,Ex)(A,W) (#5849)
authorKatayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
Mon, 18 Mar 2024 23:58:07 +0000 (08:58 +0900)
committerGitHub <noreply@github.com>
Mon, 18 Mar 2024 23:58:07 +0000 (08:58 +0900)
Implementing missing features...
JIRA issue: CORE-19278
- Modify shell32.spec.
- Implement RealShellExecuteA, RealShellExecuteW, RealShellExecuteExA,
  and RealShellExecuteExW functions.
- Add the prototypes to <undocshell.h>.
- Modify SEE_MASK_... constants.

dll/win32/shell32/shell32.spec
dll/win32/shell32/shlexec.cpp
dll/win32/shell32/stubs.cpp
sdk/include/psdk/shellapi.h
sdk/include/reactos/undocshell.h

index eb8685f..e3f096b 100644 (file)
 262 stdcall PrintersGetCommand_RunDLL(ptr ptr wstr long)
 263 stdcall PrintersGetCommand_RunDLLA(ptr ptr str long)
 264 stdcall PrintersGetCommand_RunDLLW(ptr ptr wstr long)
-265 stdcall RealShellExecuteA(ptr str str str str str str str long ptr)
-266 stdcall RealShellExecuteExA(ptr str str str str str str str long ptr long)
-267 stdcall RealShellExecuteExW(ptr str str str str str str str long ptr long)
-268 stdcall RealShellExecuteW(ptr wstr wstr wstr wstr wstr wstr wstr long ptr)
+265 stdcall RealShellExecuteA(ptr str str str str ptr str ptr long ptr)
+266 stdcall RealShellExecuteExA(ptr str str str str ptr str ptr long ptr long)
+267 stdcall RealShellExecuteExW(ptr wstr wstr wstr wstr ptr wstr ptr long ptr long)
+268 stdcall RealShellExecuteW(ptr wstr wstr wstr wstr ptr wstr ptr long ptr)
 269 stdcall RegenerateUserEnvironment(ptr long)
 270 stdcall SHAddToRecentDocs(long ptr)
 271 stdcall SHAppBarMessage(long ptr)
index ce8113a..3d74c66 100644 (file)
@@ -2650,3 +2650,197 @@ HRESULT WINAPI ShellExecCmdLine(
 
     return HRESULT_FROM_WIN32(dwError);
 }
+
+/*************************************************************************
+ *                RealShellExecuteExA (SHELL32.266)
+ */
+EXTERN_C
+HINSTANCE WINAPI
+RealShellExecuteExA(
+    _In_opt_ HWND hwnd,
+    _In_opt_ LPCSTR lpOperation,
+    _In_opt_ LPCSTR lpFile,
+    _In_opt_ LPCSTR lpParameters,
+    _In_opt_ LPCSTR lpDirectory,
+    _In_opt_ LPSTR lpReturn,
+    _In_opt_ LPCSTR lpTitle,
+    _In_opt_ LPVOID lpReserved,
+    _In_ INT nCmdShow,
+    _Out_opt_ PHANDLE lphProcess,
+    _In_ DWORD dwFlags)
+{
+    SHELLEXECUTEINFOA ExecInfo;
+
+    TRACE("(%p, %s, %s, %s, %s, %p, %s, %p, %u, %p, %lu)\n",
+          hwnd, debugstr_a(lpOperation), debugstr_a(lpFile), debugstr_a(lpParameters),
+          debugstr_a(lpDirectory), lpReserved, debugstr_a(lpTitle),
+          lpReserved, nCmdShow, lphProcess, dwFlags);
+
+    ZeroMemory(&ExecInfo, sizeof(ExecInfo));
+    ExecInfo.cbSize = sizeof(ExecInfo);
+    ExecInfo.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_UNKNOWN_0x1000;
+    ExecInfo.hwnd = hwnd;
+    ExecInfo.lpVerb = lpOperation;
+    ExecInfo.lpFile = lpFile;
+    ExecInfo.lpParameters = lpParameters;
+    ExecInfo.lpDirectory = lpDirectory;
+    ExecInfo.nShow = (WORD)nCmdShow;
+
+    if (lpReserved)
+    {
+        ExecInfo.fMask |= SEE_MASK_USE_RESERVED;
+        ExecInfo.hInstApp = (HINSTANCE)lpReserved;
+    }
+
+    if (lpTitle)
+    {
+        ExecInfo.fMask |= SEE_MASK_HASTITLE;
+        ExecInfo.lpClass = lpTitle;
+    }
+
+    if (dwFlags & 1)
+        ExecInfo.fMask |= SEE_MASK_FLAG_SEPVDM;
+
+    if (dwFlags & 2)
+        ExecInfo.fMask |= SEE_MASK_NO_CONSOLE;
+
+    if (lphProcess == NULL)
+    {
+        ShellExecuteExA(&ExecInfo);
+    }
+    else
+    {
+        ExecInfo.fMask |= SEE_MASK_NOCLOSEPROCESS;
+        ShellExecuteExA(&ExecInfo);
+        *lphProcess = ExecInfo.hProcess;
+    }
+
+    return ExecInfo.hInstApp;
+}
+
+/*************************************************************************
+ *                RealShellExecuteExW (SHELL32.267)
+ */
+EXTERN_C
+HINSTANCE WINAPI
+RealShellExecuteExW(
+    _In_opt_ HWND hwnd,
+    _In_opt_ LPCWSTR lpOperation,
+    _In_opt_ LPCWSTR lpFile,
+    _In_opt_ LPCWSTR lpParameters,
+    _In_opt_ LPCWSTR lpDirectory,
+    _In_opt_ LPWSTR lpReturn,
+    _In_opt_ LPCWSTR lpTitle,
+    _In_opt_ LPVOID lpReserved,
+    _In_ INT nCmdShow,
+    _Out_opt_ PHANDLE lphProcess,
+    _In_ DWORD dwFlags)
+{
+    SHELLEXECUTEINFOW ExecInfo;
+
+    TRACE("(%p, %s, %s, %s, %s, %p, %s, %p, %u, %p, %lu)\n",
+          hwnd, debugstr_w(lpOperation), debugstr_w(lpFile), debugstr_w(lpParameters),
+          debugstr_w(lpDirectory), lpReserved, debugstr_w(lpTitle),
+          lpReserved, nCmdShow, lphProcess, dwFlags);
+
+    ZeroMemory(&ExecInfo, sizeof(ExecInfo));
+    ExecInfo.cbSize = sizeof(ExecInfo);
+    ExecInfo.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_UNKNOWN_0x1000;
+    ExecInfo.hwnd = hwnd;
+    ExecInfo.lpVerb = lpOperation;
+    ExecInfo.lpFile = lpFile;
+    ExecInfo.lpParameters = lpParameters;
+    ExecInfo.lpDirectory = lpDirectory;
+    ExecInfo.nShow = (WORD)nCmdShow;
+
+    if (lpReserved)
+    {
+        ExecInfo.fMask |= SEE_MASK_USE_RESERVED;
+        ExecInfo.hInstApp = (HINSTANCE)lpReserved;
+    }
+
+    if (lpTitle)
+    {
+        ExecInfo.fMask |= SEE_MASK_HASTITLE;
+        ExecInfo.lpClass = lpTitle;
+    }
+
+    if (dwFlags & 1)
+        ExecInfo.fMask |= SEE_MASK_FLAG_SEPVDM;
+
+    if (dwFlags & 2)
+        ExecInfo.fMask |= SEE_MASK_NO_CONSOLE;
+
+    if (lphProcess == NULL)
+    {
+        ShellExecuteExW(&ExecInfo);
+    }
+    else
+    {
+        ExecInfo.fMask |= SEE_MASK_NOCLOSEPROCESS;
+        ShellExecuteExW(&ExecInfo);
+        *lphProcess = ExecInfo.hProcess;
+    }
+
+    return ExecInfo.hInstApp;
+}
+
+/*************************************************************************
+ *                RealShellExecuteA (SHELL32.265)
+ */
+EXTERN_C
+HINSTANCE WINAPI
+RealShellExecuteA(
+    _In_opt_ HWND hwnd,
+    _In_opt_ LPCSTR lpOperation,
+    _In_opt_ LPCSTR lpFile,
+    _In_opt_ LPCSTR lpParameters,
+    _In_opt_ LPCSTR lpDirectory,
+    _In_opt_ LPSTR lpReturn,
+    _In_opt_ LPCSTR lpTitle,
+    _In_opt_ LPVOID lpReserved,
+    _In_ INT nCmdShow,
+    _Out_opt_ PHANDLE lphProcess)
+{
+    return RealShellExecuteExA(hwnd,
+                               lpOperation,
+                               lpFile,
+                               lpParameters,
+                               lpDirectory,
+                               lpReturn,
+                               lpTitle,
+                               lpReserved,
+                               nCmdShow,
+                               lphProcess,
+                               0);
+}
+
+/*************************************************************************
+ *                RealShellExecuteW (SHELL32.268)
+ */
+EXTERN_C
+HINSTANCE WINAPI
+RealShellExecuteW(
+    _In_opt_ HWND hwnd,
+    _In_opt_ LPCWSTR lpOperation,
+    _In_opt_ LPCWSTR lpFile,
+    _In_opt_ LPCWSTR lpParameters,
+    _In_opt_ LPCWSTR lpDirectory,
+    _In_opt_ LPWSTR lpReturn,
+    _In_opt_ LPCWSTR lpTitle,
+    _In_opt_ LPVOID lpReserved,
+    _In_ INT nCmdShow,
+    _Out_opt_ PHANDLE lphProcess)
+{
+    return RealShellExecuteExW(hwnd,
+                               lpOperation,
+                               lpFile,
+                               lpParameters,
+                               lpDirectory,
+                               lpReturn,
+                               lpTitle,
+                               lpReserved,
+                               nCmdShow,
+                               lphProcess,
+                               0);
+}
index 118e1c1..c66355e 100644 (file)
@@ -492,106 +492,6 @@ SHCreateProcessAsUserW(PSHCREATEPROCESSINFOW pscpi)
     return FALSE;
 }
 
-/*
- * Unimplemented
- */
-EXTERN_C HINSTANCE
-WINAPI
-RealShellExecuteExA(HWND hwnd,
-                    LPCSTR lpOperation,
-                    LPCSTR lpFile,
-                    LPCSTR lpParameters,
-                    LPCSTR lpDirectory,
-                    LPSTR lpReturn,
-                    LPCSTR lpTitle,
-                    LPSTR lpReserved,
-                    WORD nShowCmd,
-                    HANDLE *lpProcess,
-                    DWORD dwFlags)
-{
-    FIXME("RealShellExecuteExA() stub\n");
-    return NULL;
-}
-
-/*
- * Unimplemented
- */
-EXTERN_C HINSTANCE
-WINAPI
-RealShellExecuteExW(HWND hwnd,
-                    LPCWSTR lpOperation,
-                    LPCWSTR lpFile,
-                    LPCWSTR lpParameters,
-                    LPCWSTR lpDirectory,
-                    LPWSTR lpReturn,
-                    LPCWSTR lpTitle,
-                    LPWSTR lpReserved,
-                    WORD nShowCmd,
-                    HANDLE *lpProcess,
-                    DWORD dwFlags)
-{
-    FIXME("RealShellExecuteExW() stub\n");
-    return NULL;
-}
-
-/*
- * Implemented
- */
-EXTERN_C HINSTANCE
-WINAPI
-RealShellExecuteA(HWND hwnd,
-                  LPCSTR lpOperation,
-                  LPCSTR lpFile,
-                  LPCSTR lpParameters,
-                  LPCSTR lpDirectory,
-                  LPSTR lpReturn,
-                  LPCSTR lpTitle,
-                  LPSTR lpReserved,
-                  WORD nShowCmd,
-                  HANDLE *lpProcess)
-{
-    return RealShellExecuteExA(hwnd,
-                               lpOperation,
-                               lpFile,
-                               lpParameters,
-                               lpDirectory,
-                               lpReturn,
-                               lpTitle,
-                               lpReserved,
-                               nShowCmd,
-                               lpProcess,
-                               0);
-}
-
-/*
- * Implemented
- */
-EXTERN_C HINSTANCE
-WINAPI
-RealShellExecuteW(HWND hwnd,
-                  LPCWSTR lpOperation,
-                  LPCWSTR lpFile,
-                  LPCWSTR lpParameters,
-                  LPCWSTR lpDirectory,
-                  LPWSTR lpReturn,
-                  LPCWSTR lpTitle,
-                  LPWSTR lpReserved,
-                  WORD nShowCmd,
-                  HANDLE *lpProcess)
-{
-    return RealShellExecuteExW(hwnd,
-                               lpOperation,
-                               lpFile,
-                               lpParameters,
-                               lpDirectory,
-                               lpReturn,
-                               lpTitle,
-                               lpReserved,
-                               nShowCmd,
-                               lpProcess,
-                               0);
-}
-
 /*
  * Unimplemented
  */
index 77e3fc5..b153a18 100644 (file)
@@ -37,7 +37,7 @@ extern "C" {
 #define SEE_MASK_UNICODE       0x00004000
 #define SEE_MASK_NO_CONSOLE    0x00008000
 /*
- * NOTE: The following three flags are undocumented and are not present in the
+ * NOTE: The following 5 flags are undocumented and are not present in the
  * official Windows SDK. However they are used in shobjidl.idl to define some
  * CMIC_MASK_* flags, these ones being mentioned in the MSDN documentation of
  * the CMINVOKECOMMANDINFOEX structure.
@@ -45,9 +45,11 @@ extern "C" {
  * course their values may differ from the real ones, however I have no way
  * of discovering them. If somebody else can verify them, it would be great.
  */
-#define SEE_MASK_HASLINKNAME   0x00010000
-#define SEE_MASK_HASTITLE      0x00020000
-#define SEE_MASK_FLAG_SEPVDM   0x00040000
+#define SEE_MASK_UNKNOWN_0x1000 0x00001000 /* FIXME: Name */
+#define SEE_MASK_HASLINKNAME    0x00010000
+#define SEE_MASK_FLAG_SEPVDM    0x00020000
+#define SEE_MASK_USE_RESERVED   0x00040000
+#define SEE_MASK_HASTITLE       0x00080000
 /* END NOTE */
 #define SEE_MASK_ASYNCOK       0x00100000
 #define SEE_MASK_HMONITOR      0x00200000
@@ -55,6 +57,7 @@ extern "C" {
 #define SEE_MASK_NOQUERYCLASSSTORE     0x01000000
 #define SEE_MASK_WAITFORINPUTIDLE      0x02000000
 #define SEE_MASK_FLAG_LOG_USAGE        0x04000000
+#define SEE_MASK_FLAG_HINST_IS_SITE 0x08000000
 
 #define ABM_NEW        0
 #define ABM_REMOVE     1
index 8f18060..2c79315 100644 (file)
@@ -23,7 +23,6 @@
 extern "C" {
 #endif /* defined(__cplusplus) */
 
-
 #if (NTDDI_VERSION < NTDDI_LONGHORN)
 #define DBIMF_NOGRIPPER         0x0800
 #define DBIMF_ALWAYSGRIPPER     0x1000
@@ -615,6 +614,60 @@ HRESULT WINAPI ShellExecCmdLine(
     LPVOID pUnused,
     DWORD dwSeclFlags);
 
+HINSTANCE WINAPI
+RealShellExecuteA(
+    _In_opt_ HWND hwnd,
+    _In_opt_ LPCSTR lpOperation,
+    _In_opt_ LPCSTR lpFile,
+    _In_opt_ LPCSTR lpParameters,
+    _In_opt_ LPCSTR lpDirectory,
+    _In_opt_ LPSTR lpReturn,
+    _In_opt_ LPCSTR lpTitle,
+    _In_opt_ LPVOID lpReserved,
+    _In_ INT nCmdShow,
+    _Out_opt_ PHANDLE lphProcess);
+
+HINSTANCE WINAPI
+RealShellExecuteW(
+    _In_opt_ HWND hwnd,
+    _In_opt_ LPCWSTR lpOperation,
+    _In_opt_ LPCWSTR lpFile,
+    _In_opt_ LPCWSTR lpParameters,
+    _In_opt_ LPCWSTR lpDirectory,
+    _In_opt_ LPWSTR lpReturn,
+    _In_opt_ LPCWSTR lpTitle,
+    _In_opt_ LPVOID lpReserved,
+    _In_ INT nCmdShow,
+    _Out_opt_ PHANDLE lphProcess);
+
+HINSTANCE WINAPI
+RealShellExecuteExA(
+    _In_opt_ HWND hwnd,
+    _In_opt_ LPCSTR lpOperation,
+    _In_opt_ LPCSTR lpFile,
+    _In_opt_ LPCSTR lpParameters,
+    _In_opt_ LPCSTR lpDirectory,
+    _In_opt_ LPSTR lpReturn,
+    _In_opt_ LPCSTR lpTitle,
+    _In_opt_ LPVOID lpReserved,
+    _In_ INT nCmdShow,
+    _Out_opt_ PHANDLE lphProcess,
+    _In_ DWORD dwFlags);
+
+HINSTANCE WINAPI
+RealShellExecuteExW(
+    _In_opt_ HWND hwnd,
+    _In_opt_ LPCWSTR lpOperation,
+    _In_opt_ LPCWSTR lpFile,
+    _In_opt_ LPCWSTR lpParameters,
+    _In_opt_ LPCWSTR lpDirectory,
+    _In_opt_ LPWSTR lpReturn,
+    _In_opt_ LPCWSTR lpTitle,
+    _In_opt_ LPVOID lpReserved,
+    _In_ INT nCmdShow,
+    _Out_opt_ PHANDLE lphProcess,
+    _In_ DWORD dwFlags);
+
 /* RegisterShellHook types */
 #define RSH_DEREGISTER        0
 #define RSH_REGISTER          1
@@ -800,7 +853,7 @@ DWORD WINAPI WinList_Init(void);
 
 IStream* WINAPI SHGetViewStream(LPCITEMIDLIST, DWORD, LPCTSTR, LPCTSTR, LPCTSTR);
 
-EXTERN_C HRESULT WINAPI SHCreateSessionKey(REGSAM samDesired, PHKEY phKey);
+HRESULT WINAPI SHCreateSessionKey(REGSAM samDesired, PHKEY phKey);
 
 LONG WINAPI SHRegQueryValueExA(
     HKEY hkey,
@@ -822,7 +875,6 @@ LONG WINAPI SHRegQueryValueExW(
     #define SHRegQueryValueEx SHRegQueryValueExA
 #endif
 
-EXTERN_C
 HRESULT WINAPI
 CopyStreamUI(
     _In_ IStream *pSrc,