ReactOS 0.4.17-dev-684-ga6524ef
ShellExecuteEx.cpp File Reference
#include "shelltest.h"
#include "closewnd.h"
#include <pstypes.h>
#include <psfuncs.h>
#include <stdlib.h>
#include <stdio.h>
#include <strsafe.h>
#include <versionhelpers.h>
#include <shellutils.h>
#include "shell32_apitest_sub.h"
Include dependency graph for ShellExecuteEx.cpp:

Go to the source code of this file.

Classes

struct  TEST_ENTRY
 

Macros

#define REG_APPPATHS   L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\"
 

Typedefs

typedef enum TEST_RESULT TEST_RESULT
 
typedef struct TEST_ENTRY TEST_ENTRY
 
typedef struct TEST_ENTRYPTEST_ENTRY
 

Enumerations

enum  TEST_RESULT { TEST_FAILED , TEST_SUCCESS_NO_PROCESS , TEST_SUCCESS_WITH_PROCESS }
 

Functions

static void RunTest (LPTHREAD_START_ROUTINE TestFunc, UINT TimeOut=1000 *30)
 
template<class T >
static TReset (T &sei, UINT flags=SEE_MASK_FLAG_NO_UI)
 
static void TEST_DoTestEntry (INT line, TEST_RESULT result, LPCWSTR lpFile, LPCWSTR cmdline=NULL)
 
static void TEST_DoTestEntries (void)
 
static LPWSTR getCommandLineFromProcess (HANDLE hProcess)
 
static TEST_RESULT TEST_DoTestEntryStruct (const TEST_ENTRY *pEntry)
 
static BOOL enableTokenPrivilege (LPCWSTR pszPrivilege)
 
static BOOL TEST_Start (void)
 
static void TEST_End (void)
 
static void test_properties ()
 
static void test_sei_lpIDList ()
 
static BOOL CreateAppPath (LPCWSTR pszName, LPCWSTR pszValue)
 
static VOID DeleteAppPath (LPCWSTR pszName)
 
static void TEST_AppPath (void)
 
static void test_DoInvalidDir (void)
 
static DWORD CALLBACK Test_InvokeIdList (LPVOID)
 
 START_TEST (ShellExecuteEx)
 

Variables

static WCHAR s_win_dir [MAX_PATH]
 
static WCHAR s_sys_dir [MAX_PATH]
 
static WCHAR s_win_notepad [MAX_PATH]
 
static WCHAR s_sys_notepad [MAX_PATH]
 
static WCHAR s_win_test_exe [MAX_PATH]
 
static WCHAR s_sys_test_exe [MAX_PATH]
 
static WCHAR s_win_bat_file [MAX_PATH]
 
static WCHAR s_sys_bat_file [MAX_PATH]
 
static WCHAR s_win_txt_file [MAX_PATH]
 
static WCHAR s_sys_txt_file [MAX_PATH]
 
static WCHAR s_win_notepad_cmdline [MAX_PATH]
 
static WCHAR s_sys_notepad_cmdline [MAX_PATH]
 
static WCHAR s_win_test_exe_cmdline [MAX_PATH]
 
static WCHAR s_sys_test_exe_cmdline [MAX_PATH]
 
static BOOL s_bWow64
 
static WINDOW_LIST s_List1
 
static WINDOW_LIST s_List2
 

Macro Definition Documentation

◆ REG_APPPATHS

#define REG_APPPATHS   L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\"

Definition at line 57 of file ShellExecuteEx.cpp.

Typedef Documentation

◆ PTEST_ENTRY

◆ TEST_ENTRY

◆ TEST_RESULT

Enumeration Type Documentation

◆ TEST_RESULT

Enumerator
TEST_FAILED 
TEST_SUCCESS_NO_PROCESS 
TEST_SUCCESS_WITH_PROCESS 

Definition at line 59 of file ShellExecuteEx.cpp.

60{
TEST_RESULT
@ TEST_FAILED
@ TEST_SUCCESS_NO_PROCESS
@ TEST_SUCCESS_WITH_PROCESS

Function Documentation

◆ CreateAppPath()

static BOOL CreateAppPath ( LPCWSTR  pszName,
LPCWSTR  pszValue 
)
static

Definition at line 460 of file ShellExecuteEx.cpp.

461{
462 WCHAR szSubKey[MAX_PATH];
463 StringCchPrintfW(szSubKey, _countof(szSubKey), L"%s\\%s", REG_APPPATHS, pszName);
464
466 HKEY hKey;
468 &hKey, NULL);
469 if (error != ERROR_SUCCESS)
470 trace("Could not create test key (%lu)\n", error);
471
472 DWORD cbValue = (lstrlenW(pszValue) + 1) * sizeof(WCHAR);
474 if (error != ERROR_SUCCESS)
475 trace("Could not set value of the test key (%lu)\n", error);
476
478
479 return error == ERROR_SUCCESS;
480}
#define REG_APPPATHS
#define trace
Definition: atltest.h:70
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define NULL
Definition: types.h:112
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
#define MAX_PATH
Definition: compat.h:34
#define lstrlenW
Definition: compat.h:750
#define L(x)
Definition: resources.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
#define REG_SZ
Definition: layer.c:22
#define error(str)
Definition: mkdosfs.c:1605
#define KEY_WRITE
Definition: nt_native.h:1034
short WCHAR
Definition: pedump.c:58
_In_opt_ LPCSTR _In_opt_ LPCSTR pszValue
Definition: shlwapi.h:783
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by TEST_AppPath().

◆ DeleteAppPath()

static VOID DeleteAppPath ( LPCWSTR  pszName)
static

Definition at line 483 of file ShellExecuteEx.cpp.

484{
485 WCHAR szSubKey[MAX_PATH];
486 StringCchPrintfW(szSubKey, _countof(szSubKey), L"%s\\%s", REG_APPPATHS, pszName);
487
489 if (error != ERROR_SUCCESS)
490 trace("Could not remove the test key (%lu)\n", error);
491}
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239

Referenced by TEST_AppPath().

◆ enableTokenPrivilege()

static BOOL enableTokenPrivilege ( LPCWSTR  pszPrivilege)
static

Definition at line 243 of file ShellExecuteEx.cpp.

244{
245 HANDLE hToken;
247 return FALSE;
248
249 TOKEN_PRIVILEGES tkp = { 0 };
250 if (!LookupPrivilegeValueW(NULL, pszPrivilege, &tkp.Privileges[0].Luid))
251 return FALSE;
252
253 tkp.PrivilegeCount = 1;
255 return AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, NULL);
256}
#define FALSE
Definition: types.h:117
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:374
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
#define GetCurrentProcess()
Definition: compat.h:759
$ULONG PrivilegeCount
Definition: setypes.h:1035
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
Definition: setypes.h:1036
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:942
#define TOKEN_QUERY
Definition: setypes.h:940
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63

Referenced by TEST_Start().

◆ getCommandLineFromProcess()

static LPWSTR getCommandLineFromProcess ( HANDLE  hProcess)
static

Definition at line 133 of file ShellExecuteEx.cpp.

134{
135 PEB peb;
139 BOOL ret;
140
143
144 ret = ReadProcessMemory(hProcess, info.PebBaseAddress, &peb, sizeof(peb), NULL);
145 if (!ret)
146 trace("ReadProcessMemory failed (%ld)\n", GetLastError());
147
149 if (!ret)
150 trace("ReadProcessMemory failed (%ld)\n", GetLastError());
151
152 LPWSTR cmdline = Params.CommandLine.Buffer;
153 if (!cmdline)
154 trace("!cmdline\n");
155
156 SIZE_T cbCmdLine = Params.CommandLine.Length;
157 if (!cbCmdLine)
158 trace("!cbCmdLine\n");
159
160 LPWSTR pszBuffer = (LPWSTR)calloc(cbCmdLine + sizeof(WCHAR), 1);
161 if (!pszBuffer)
162 trace("!pszBuffer\n");
163
164 ret = ReadProcessMemory(hProcess, cmdline, pszBuffer, cbCmdLine, NULL);
165 if (!ret)
166 trace("ReadProcessMemory failed (%ld)\n", GetLastError());
167
168 pszBuffer[cbCmdLine / sizeof(WCHAR)] = UNICODE_NULL;
169
170 return pszBuffer; // needs free()
171}
#define ok_ntstatus(status, expected)
Definition: atltest.h:135
LONG NTSTATUS
Definition: precomp.h:26
@ ProcessBasicInformation
Definition: cicbase.cpp:63
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:758
return ret
Definition: mutex.c:147
unsigned int BOOL
Definition: ntddk_ex.h:94
Status
Definition: gdiplustypes.h:24
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
#define UNICODE_NULL
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_writes_bytes_to_opt_(ProcessInformationLength, *ReturnLength) PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:211
#define calloc
Definition: rosglue.h:14
#define STATUS_SUCCESS
Definition: shellext.h:65
TCHAR * cmdline
Definition: stretchblt.cpp:32
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
Definition: btrfs_drv.h:1913
uint16_t * LPWSTR
Definition: typedefs.h:56
ULONG_PTR SIZE_T
Definition: typedefs.h:80
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:308
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by TEST_DoTestEntryStruct().

◆ Reset()

template<class T >
static T & Reset ( T sei,
UINT  flags = SEE_MASK_FLAG_NO_UI 
)
static

Definition at line 32 of file ShellExecuteEx.cpp.

33{
34 ZeroMemory(&sei, sizeof(T));
35 sei.cbSize = sizeof(T);
36 sei.fMask = flags;
37 sei.nShow = SW_SHOW;
38 return sei;
39}
GLbitfield flags
Definition: glext.h:7161
#define ZeroMemory
Definition: minwinbase.h:31
#define T(num)
Definition: thunks.c:311
#define SW_SHOW
Definition: winuser.h:786

Referenced by $if(), DECLARE_INTERFACE_(), MMixerSetWaveResetState(), and Test_InvokeIdList().

◆ RunTest()

static void RunTest ( LPTHREAD_START_ROUTINE  TestFunc,
UINT  TimeOut = 1000 * 30 
)
static

Definition at line 20 of file ShellExecuteEx.cpp.

21{
22 // These tests have a tendency to hang, kill it if it takes too long
24 if (hThread)
25 {
29 }
30}
#define CloseHandle
Definition: compat.h:739
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
BOOL WINAPI TerminateThread(IN HANDLE hThread, IN DWORD dwExitCode)
Definition: thread.c:587
int TestFunc(int,...)
HANDLE hThread
Definition: wizard.c:28
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define WAIT_OBJECT_0
Definition: winbase.h:383
#define ERROR_OPERATION_ABORTED
Definition: winerror.h:899

◆ START_TEST()

START_TEST ( ShellExecuteEx  )

Definition at line 568 of file ShellExecuteEx.cpp.

569{
571
572 // FIXME: These tests are broken (silent skip for now)
573 if (!lstrcmpiW(L"", L""))
574 return;
575
576#ifdef _WIN64
577 skip("Win64 is not supported yet\n");
578 return;
579#endif
580
581 if (!TEST_Start())
582 return;
583
584 TEST_AppPath();
589
590 TEST_End();
591}
static KSTART_ROUTINE RunTest
Definition: NpfsConnect.c:238
static void test_sei_lpIDList()
static BOOL TEST_Start(void)
static DWORD CALLBACK Test_InvokeIdList(LPVOID)
static void test_properties()
static void TEST_AppPath(void)
static void test_DoInvalidDir(void)
static void TEST_DoTestEntries(void)
static void TEST_End(void)
#define skip(...)
Definition: atltest.h:64
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4171

◆ TEST_AppPath()

static void TEST_AppPath ( void  )
static

Definition at line 493 of file ShellExecuteEx.cpp.

494{
495 if (CreateAppPath(L"app_path_test.bat", s_win_test_exe))
496 {
497 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_WITH_PROCESS, L"app_path_test.bat");
498 TEST_DoTestEntry(__LINE__, TEST_FAILED, L"app_path_test.bat.exe");
499 DeleteAppPath(L"app_path_test.bat");
500 }
501
502 if (CreateAppPath(L"app_path_test.bat.exe", s_sys_test_exe))
503 {
504 TEST_DoTestEntry(__LINE__, TEST_FAILED, L"app_path_test.bat");
505 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_WITH_PROCESS, L"app_path_test.bat.exe");
506 DeleteAppPath(L"app_path_test.bat.exe");
507 }
508}
static WCHAR s_win_test_exe[MAX_PATH]
static void TEST_DoTestEntry(INT line, TEST_RESULT result, LPCWSTR lpFile, LPCWSTR cmdline=NULL)
static WCHAR s_sys_test_exe[MAX_PATH]
static BOOL CreateAppPath(LPCWSTR pszName, LPCWSTR pszValue)
static VOID DeleteAppPath(LPCWSTR pszName)

Referenced by START_TEST().

◆ test_DoInvalidDir()

static void test_DoInvalidDir ( void  )
static

Definition at line 510 of file ShellExecuteEx.cpp.

511{
512 WCHAR szSubProgram[MAX_PATH];
513 if (!FindSubProgram(szSubProgram, _countof(szSubProgram)))
514 {
515 skip("shell32_apitest_sub.exe not found\n");
516 return;
517 }
518
519 DWORD dwExitCode;
521 sei.lpFile = szSubProgram;
522 sei.lpParameters = L"TEST";
523 sei.nShow = SW_SHOWNORMAL;
524
525 // Test invalid path on sei.lpDirectory
526 WCHAR szInvalidPath[MAX_PATH] = L"M:\\This is an invalid path\n";
527 sei.lpDirectory = szInvalidPath;
529 WaitForSingleObject(sei.hProcess, 20 * 1000);
530 GetExitCodeProcess(sei.hProcess, &dwExitCode);
531 ok_long(dwExitCode, 0);
533}
#define ok_long(expression, result)
Definition: atltest.h:133
#define ok_int(expression, result)
Definition: atltest.h:134
#define TRUE
Definition: types.h:120
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
Definition: proc.c:1165
static BOOL FindSubProgram(LPWSTR pszSubProgram, DWORD cchSubProgram)
#define SEE_MASK_NOCLOSEPROCESS
Definition: shellapi.h:33
#define SEE_MASK_FLAG_NO_UI
Definition: shellapi.h:38
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2732
LPCWSTR lpDirectory
Definition: shellapi.h:340
LPCWSTR lpParameters
Definition: shellapi.h:339
#define SW_SHOWNORMAL
Definition: winuser.h:781

Referenced by START_TEST().

◆ TEST_DoTestEntries()

static void TEST_DoTestEntries ( void  )
static

Definition at line 77 of file ShellExecuteEx.cpp.

78{
81 TEST_DoTestEntry(__LINE__, TEST_FAILED, L"This is an invalid path.");
94 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_WITH_PROCESS, L"\"test program.exe\"", s_sys_test_exe_cmdline);
97 TEST_DoTestEntry(__LINE__, TEST_FAILED, L"shell:ThisIsAnInvalidName");
98 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"); // My Computer
99 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"); // My Computer (with shell:)
100
102 {
103 WCHAR szCurDir[MAX_PATH];
104 GetCurrentDirectoryW(_countof(szCurDir), szCurDir);
106 TEST_DoTestEntry(__LINE__, TEST_FAILED, L"::{21EC2020-3AEA-1069-A2DD-08002B30309D}"); // Control Panel (without path)
107 SetCurrentDirectoryW(szCurDir);
108 }
109
110 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}"); // Control Panel (with path)
111 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}"); // Control Panel (with path and shell:)
112 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:AppData");
113 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Common Desktop");
114 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Common Programs");
115 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Common Start Menu");
116 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Common StartUp");
117 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:ControlPanelFolder");
118 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Desktop");
119 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Favorites");
120 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Fonts");
121 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Local AppData");
122 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:My Pictures");
123 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Personal");
124 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Programs");
125 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Recent");
126 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:RecycleBinFolder");
127 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:SendTo");
128 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Start Menu");
129 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:StartUp");
130}
static WCHAR s_win_dir[MAX_PATH]
static WCHAR s_sys_bat_file[MAX_PATH]
static WCHAR s_sys_test_exe_cmdline[MAX_PATH]
static WCHAR s_win_txt_file[MAX_PATH]
static WCHAR s_sys_notepad_cmdline[MAX_PATH]
static WCHAR s_win_test_exe_cmdline[MAX_PATH]
static WCHAR s_win_bat_file[MAX_PATH]
static WCHAR s_win_notepad[MAX_PATH]
static WCHAR s_win_notepad_cmdline[MAX_PATH]
static WCHAR s_sys_txt_file[MAX_PATH]
static WCHAR s_sys_dir[MAX_PATH]
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:756
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2168
VERSIONHELPERAPI IsWindowsVistaOrGreater()

Referenced by START_TEST().

◆ TEST_DoTestEntry()

static void TEST_DoTestEntry ( INT  line,
TEST_RESULT  result,
LPCWSTR  lpFile,
LPCWSTR  cmdline = NULL 
)
static

Definition at line 222 of file ShellExecuteEx.cpp.

223{
224 WINDOW_LIST existingwindows;
225 GetWindowList(&existingwindows);
226 HWND hWndForeground = GetForegroundWindow();
227
228 TEST_ENTRY entry = { line, result, lpFile, cmdline };
230
232 {
233 // Wait a bit for Explorer to open its window
234 for (UINT i = 0; i < 2000 && hWndForeground == GetForegroundWindow(); i += 250)
235 Sleep(250);
236 }
237
238 CloseNewWindows(&existingwindows);
239 FreeWindowList(&existingwindows);
240}
static TEST_RESULT TEST_DoTestEntryStruct(const TEST_ENTRY *pEntry)
static VOID FreeWindowList(PWINDOW_LIST pList)
Definition: closewnd.h:20
static VOID CloseNewWindows(PWINDOW_LIST pExisting, PWINDOW_LIST pNew)
Definition: closewnd.h:78
static VOID GetWindowList(PWINDOW_LIST pList)
Definition: closewnd.h:42
GLuint64EXT * result
Definition: glext.h:11304
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: sysinfo.c:13
uint32_t entry
Definition: isohybrid.c:63
Definition: cmd.c:13
Definition: parser.c:49
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:726
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392

Referenced by TEST_AppPath(), and TEST_DoTestEntries().

◆ TEST_DoTestEntryStruct()

static TEST_RESULT TEST_DoTestEntryStruct ( const TEST_ENTRY pEntry)
static

Definition at line 173 of file ShellExecuteEx.cpp.

174{
175 SHELLEXECUTEINFOW info = { sizeof(info) };
178 info.hwnd = NULL;
179 info.lpVerb = NULL;
180 info.lpFile = pEntry->lpFile;
181 info.nShow = SW_SHOWNORMAL;
182
184
186 if (ret && info.hProcess)
188 else if (ret && !info.hProcess)
190 else
192
193 ok(pEntry->result == result,
194 "Line %d: result: %d vs %d\n", pEntry->line, pEntry->result, result);
195
197 WaitForInputIdle(info.hProcess, 2000);
198
199 if (pEntry->result == TEST_SUCCESS_WITH_PROCESS && pEntry->cmdline && !s_bWow64)
200 {
202 if (!cmdline)
203 {
204 skip("!cmdline\n");
205 }
206 else
207 {
208 ok(lstrcmpiW(pEntry->cmdline, cmdline) == 0,
209 "Line %d: cmdline: '%ls' vs '%ls'\n", pEntry->line,
210 pEntry->cmdline, cmdline);
211 }
212
213 TerminateProcess(info.hProcess, 0xDEADFACE);
214 free(cmdline);
215 }
216
217 CloseHandle(info.hProcess);
218 return result;
219}
static BOOL s_bWow64
static LPWSTR getCommandLineFromProcess(HANDLE hProcess)
#define ok(value,...)
Definition: atltest.h:57
#define free
Definition: debug_ros.c:5
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1375
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#define SEE_MASK_NOASYNC
Definition: shellapi.h:35
#define SEE_MASK_WAITFORINPUTIDLE
Definition: shellapi.h:52
DWORD WINAPI WaitForInputIdle(_In_ HANDLE, _In_ DWORD)

Referenced by TEST_DoTestEntry().

◆ TEST_End()

static void TEST_End ( void  )
static

Definition at line 354 of file ShellExecuteEx.cpp.

355{
362
363 // Execution can be asynchronous; you have to wait for it to finish.
364 INT nCount = GetWindowCount();
365 for (INT i = 0; i < 100; ++i)
366 {
367 INT nOldCount = nCount;
368 Sleep(3000);
369 nCount = GetWindowCount();
370 if (nOldCount == nCount)
371 break;
372 }
373 Sleep(3000);
374
375 // Close newly-opened window(s)
380}
static WINDOW_LIST s_List2
static WINDOW_LIST s_List1
static INT GetWindowCount(VOID)
Definition: closewnd.h:135
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
int32_t INT
Definition: typedefs.h:58

Referenced by START_TEST().

◆ Test_InvokeIdList()

static DWORD CALLBACK Test_InvokeIdList ( LPVOID  )
static

Definition at line 535 of file ShellExecuteEx.cpp.

536{
537 CCoInit ComInit;
538 UINT err, ret;
539 WCHAR Path[MAX_PATH * 2];
540 CComHeapPtr<ITEMIDLIST> pidl;
542
545 PathAppendW(Path, L"cmd.exe");
546 sei.lpParameters = L"/C exit 0";
547 sei.lpIDList = LPITEMIDLIST((pidl.Attach(ILCreateFromPathW(Path)), pidl));
548 if (!pidl)
549 {
550 skip("No exe to test\n");
551 return 0;
552 }
553
554 sei.lpVerb = NULL;
555 ok(ShellExecuteExW(&sei), "Failed with error %lu\n", GetLastError());
556
557 sei.lpVerb = L"open";
558 ok(ShellExecuteExW(&sei), "Failed with error %lu\n", GetLastError());
559
560 sei.lpVerb = L"Shell32_Test_DoesNotExist";
561 ret = ShellExecuteExW(&sei), err = GetLastError();
562 ok(!ret, "Expected failure\n");
564
565 return 0;
566}
PRTL_UNICODE_STRING_BUFFER Path
static T & Reset(T &sei, UINT flags=SEE_MASK_FLAG_NO_UI)
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2232
#define PathAppendW
Definition: pathcch.h:310
LPITEMIDLIST WINAPI ILCreateFromPathW(LPCWSTR path)
Definition: pidl.c:1108
#define err(...)
#define SEE_MASK_INVOKEIDLIST
Definition: shellapi.h:28
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define ERROR_NO_ASSOCIATION
Definition: winerror.h:1001
#define SW_HIDE
Definition: winuser.h:779

Referenced by START_TEST().

◆ test_properties()

static void test_properties ( void  )
static

Definition at line 382 of file ShellExecuteEx.cpp.

383{
384 HRESULT hrCoInit = CoInitialize(NULL);
385
386 WCHAR Buffer[MAX_PATH * 4];
388
389 SHELLEXECUTEINFOW info = { sizeof(info) };
391 info.lpVerb = L"properties";
392 info.lpFile = Buffer;
393 info.nShow = SW_SHOW;
394
395 BOOL bRet = ShellExecuteExW(&info);
396 ok(bRet, "Failed! (GetLastError(): %d)\n", (int)GetLastError());
397 ok_ptr(info.hInstApp, (HINSTANCE)42);
398
400 if (Extension)
401 {
402 // The inclusion of this depends on the file display settings!
404 }
405
406 // Now retry it with the extension cut off
407 bRet = ShellExecuteExW(&info);
408 ok(bRet, "Failed! (GetLastError(): %d)\n", (int)GetLastError());
409 ok_ptr(info.hInstApp, (HINSTANCE)42);
410
411 // Now retry it with complete garabage
412 info.lpFile = L"complete garbage, cannot run this!";
413 bRet = ShellExecuteExW(&info);
414 ok_int(bRet, 0);
415 ok_ptr(info.hInstApp, (HINSTANCE)2);
416
417 if (SUCCEEDED(hrCoInit))
419}
#define ok_ptr(expression, result)
Definition: atltest.h:108
Definition: bufpool.h:45
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
LPWSTR WINAPI PathFindExtensionW(const WCHAR *path)
Definition: path.c:1250
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:531
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
#define SUCCEEDED(hr)
Definition: intsafe.h:50

Referenced by START_TEST().

◆ test_sei_lpIDList()

static void test_sei_lpIDList ( )
static

Definition at line 421 of file ShellExecuteEx.cpp.

422{
423 // Note: SEE_MASK_FLAG_NO_UI prevents the test from blocking with a MessageBox
425
426 /* This tests ShellExecuteEx with lpIDList for explorer C:\ */
430 if (!pidl)
431 {
432 skip("Unable to initialize test\n");
433 return;
434 }
435
436 SHELLEXECUTEINFOW ShellExecInfo = { sizeof(ShellExecInfo) };
437 ShellExecInfo.nShow = SW_SHOWNORMAL;
439 ShellExecInfo.lpIDList = pidl;
440 BOOL ret = ShellExecuteExW(&ShellExecInfo);
441 ok_int(ret, TRUE);
442 ILFree(pidl);
443
444 /* This tests ShellExecuteEx with lpIDList going through IContextMenu */
445 CCoInit ComInit;
447 if (!pidl)
448 {
449 skip("Unable to initialize test\n");
450 return;
451 }
453 ShellExecInfo.lpIDList = pidl;
454 ret = ShellExecuteExW(&ShellExecInfo);
455 ok_int(ret, TRUE);
456 ILFree(pidl);
457}
BOOL WINAPI PathStripToRootW(WCHAR *path)
Definition: path.c:1171
LPITEMIDLIST WINAPI SHCloneSpecialIDList(HWND hwndOwner, int nFolder, BOOL fCreate)
Definition: pidl.c:446
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1051
#define SEE_MASK_IDLIST
Definition: shellapi.h:27
#define SEE_MASK_FLAG_DDEWAIT
Definition: shellapi.h:36
#define CSIDL_PROFILE
Definition: shlobj.h:2230

Referenced by START_TEST().

◆ TEST_Start()

static BOOL TEST_Start ( void  )
static

Definition at line 260 of file ShellExecuteEx.cpp.

261{
262 // Check Wow64
263 s_bWow64 = FALSE;
265 if (s_bWow64)
266 skip("Wow64: Command Line check is skipped\n");
267
268 // getCommandLineFromProcess needs this
270
271 // s_win_dir
273
274 // s_sys_dir
276
277 // s_win_notepad
279 PathAppendW(s_win_notepad, L"notepad.exe");
280
281 // s_sys_notepad
283 PathAppendW(s_sys_notepad, L"notepad.exe");
284
285 // s_win_test_exe
287 PathAppendW(s_win_test_exe, L"test program.exe");
289 if (!ret)
290 {
291 skip("Please retry with admin rights\n");
292 return FALSE;
293 }
294
295 // s_sys_test_exe
297 PathAppendW(s_sys_test_exe, L"test program.exe");
299
300 // s_win_bat_file
302 PathAppendW(s_win_bat_file, L"test program.bat");
303 FILE *fp = _wfopen(s_win_bat_file, L"wb");
304 fprintf(fp, "exit /b 3");
305 fclose(fp);
307
308 // s_sys_bat_file
310 PathAppendW(s_sys_bat_file, L"test program.bat");
311 fp = _wfopen(s_sys_bat_file, L"wb");
312 fprintf(fp, "exit /b 4");
313 fclose(fp);
315
316 // s_win_txt_file
318 PathAppendW(s_win_txt_file, L"test_file.txt");
319 fp = _wfopen(s_win_txt_file, L"wb");
320 fclose(fp);
322
323 // s_sys_txt_file
325 PathAppendW(s_sys_txt_file, L"test_file.txt");
326 fp = _wfopen(s_sys_txt_file, L"wb");
327 fclose(fp);
329
330 // Check .txt settings
333 if (lstrcmpiW(PathFindFileNameW(szPath), L"notepad.exe") != 0)
334 {
335 skip("Please associate .txt with notepad.exe before tests\n");
336 return FALSE;
337 }
338
339 // command lines
341 L"\"%s\" ", s_win_notepad);
343 L"\"%s\" ", s_sys_notepad);
345 L"\"%s\" ", s_win_test_exe);
347 L"\"%s\" ", s_sys_test_exe);
348
350
351 return TRUE;
352}
static BOOL enableTokenPrivilege(LPCWSTR pszPrivilege)
static WCHAR s_sys_notepad[MAX_PATH]
#define IsWow64Process
Definition: compat.h:760
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:367
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2271
WCHAR *WINAPI PathFindFileNameW(const WCHAR *path)
Definition: path.c:1677
BOOL WINAPI PathFileExistsW(const WCHAR *path)
Definition: path.c:2583
int CDECL fclose(FILE *file)
Definition: file.c:3757
int WINAPIV fprintf(FILE *file, const char *format,...)
Definition: file.c:5549
FILE *CDECL _wfopen(const wchar_t *path, const wchar_t *mode)
Definition: file.c:4335
LPCWSTR szPath
Definition: env.c:37
HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory, LPWSTR lpResult)
Definition: shlexec.cpp:1581
#define SE_DEBUG_NAME
Definition: winnt_old.h:428

Referenced by START_TEST().

Variable Documentation

◆ s_bWow64

BOOL s_bWow64
static

Definition at line 55 of file ShellExecuteEx.cpp.

Referenced by TEST_DoTestEntryStruct(), and TEST_Start().

◆ s_List1

WINDOW_LIST s_List1
static

Definition at line 258 of file ShellExecuteEx.cpp.

Referenced by TEST_End(), and TEST_Start().

◆ s_List2

WINDOW_LIST s_List2
static

Definition at line 258 of file ShellExecuteEx.cpp.

Referenced by TEST_End().

◆ s_sys_bat_file

WCHAR s_sys_bat_file[MAX_PATH]
static

Definition at line 48 of file ShellExecuteEx.cpp.

Referenced by TEST_DoTestEntries(), TEST_End(), and TEST_Start().

◆ s_sys_dir

WCHAR s_sys_dir[MAX_PATH]
static

Definition at line 42 of file ShellExecuteEx.cpp.

Referenced by TEST_DoTestEntries(), and TEST_Start().

◆ s_sys_notepad

WCHAR s_sys_notepad[MAX_PATH]
static

Definition at line 44 of file ShellExecuteEx.cpp.

Referenced by TEST_Start().

◆ s_sys_notepad_cmdline

WCHAR s_sys_notepad_cmdline[MAX_PATH]
static

Definition at line 52 of file ShellExecuteEx.cpp.

Referenced by TEST_DoTestEntries(), and TEST_Start().

◆ s_sys_test_exe

WCHAR s_sys_test_exe[MAX_PATH]
static

Definition at line 46 of file ShellExecuteEx.cpp.

Referenced by TEST_AppPath(), TEST_DoTestEntries(), TEST_End(), and TEST_Start().

◆ s_sys_test_exe_cmdline

WCHAR s_sys_test_exe_cmdline[MAX_PATH]
static

Definition at line 54 of file ShellExecuteEx.cpp.

Referenced by TEST_DoTestEntries(), and TEST_Start().

◆ s_sys_txt_file

WCHAR s_sys_txt_file[MAX_PATH]
static

Definition at line 50 of file ShellExecuteEx.cpp.

Referenced by TEST_DoTestEntries(), TEST_End(), and TEST_Start().

◆ s_win_bat_file

WCHAR s_win_bat_file[MAX_PATH]
static

Definition at line 47 of file ShellExecuteEx.cpp.

Referenced by TEST_DoTestEntries(), TEST_End(), and TEST_Start().

◆ s_win_dir

WCHAR s_win_dir[MAX_PATH]
static

Definition at line 41 of file ShellExecuteEx.cpp.

Referenced by TEST_DoTestEntries(), and TEST_Start().

◆ s_win_notepad

WCHAR s_win_notepad[MAX_PATH]
static

Definition at line 43 of file ShellExecuteEx.cpp.

Referenced by TEST_DoTestEntries(), and TEST_Start().

◆ s_win_notepad_cmdline

WCHAR s_win_notepad_cmdline[MAX_PATH]
static

Definition at line 51 of file ShellExecuteEx.cpp.

Referenced by TEST_DoTestEntries(), and TEST_Start().

◆ s_win_test_exe

WCHAR s_win_test_exe[MAX_PATH]
static

Definition at line 45 of file ShellExecuteEx.cpp.

Referenced by TEST_AppPath(), TEST_DoTestEntries(), TEST_End(), and TEST_Start().

◆ s_win_test_exe_cmdline

WCHAR s_win_test_exe_cmdline[MAX_PATH]
static

Definition at line 53 of file ShellExecuteEx.cpp.

Referenced by TEST_DoTestEntries(), and TEST_Start().

◆ s_win_txt_file

WCHAR s_win_txt_file[MAX_PATH]
static

Definition at line 49 of file ShellExecuteEx.cpp.

Referenced by TEST_DoTestEntries(), TEST_End(), and TEST_Start().