ReactOS 0.4.16-dev-1506-g117cd33
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 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)
 
 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 36 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 38 of file ShellExecuteEx.cpp.

39{
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 439 of file ShellExecuteEx.cpp.

440{
441 WCHAR szSubKey[MAX_PATH];
442 StringCchPrintfW(szSubKey, _countof(szSubKey), L"%s\\%s", REG_APPPATHS, pszName);
443
445 HKEY hKey;
447 &hKey, NULL);
448 if (error != ERROR_SUCCESS)
449 trace("Could not create test key (%lu)\n", error);
450
451 DWORD cbValue = (lstrlenW(pszValue) + 1) * sizeof(WCHAR);
452 error = RegSetValueExW(hKey, NULL, 0, REG_SZ, (LPBYTE)pszValue, cbValue);
453 if (error != ERROR_SUCCESS)
454 trace("Could not set value of the test key (%lu)\n", error);
455
457
458 return error == ERROR_SUCCESS;
459}
#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:1031
#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
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by TEST_AppPath().

◆ DeleteAppPath()

static VOID DeleteAppPath ( LPCWSTR  pszName)
static

Definition at line 462 of file ShellExecuteEx.cpp.

463{
464 WCHAR szSubKey[MAX_PATH];
465 StringCchPrintfW(szSubKey, _countof(szSubKey), L"%s\\%s", REG_APPPATHS, pszName);
466
468 if (error != ERROR_SUCCESS)
469 trace("Could not remove the test key (%lu)\n", error);
470}
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 222 of file ShellExecuteEx.cpp.

223{
224 HANDLE hToken;
226 return FALSE;
227
228 TOKEN_PRIVILEGES tkp = { 0 };
229 if (!LookupPrivilegeValueW(NULL, pszPrivilege, &tkp.Privileges[0].Luid))
230 return FALSE;
231
232 tkp.PrivilegeCount = 1;
234 return AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, NULL);
235}
#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 112 of file ShellExecuteEx.cpp.

113{
114 PEB peb;
118 BOOL ret;
119
122
123 ret = ReadProcessMemory(hProcess, info.PebBaseAddress, &peb, sizeof(peb), NULL);
124 if (!ret)
125 trace("ReadProcessMemory failed (%ld)\n", GetLastError());
126
128 if (!ret)
129 trace("ReadProcessMemory failed (%ld)\n", GetLastError());
130
131 LPWSTR cmdline = Params.CommandLine.Buffer;
132 if (!cmdline)
133 trace("!cmdline\n");
134
135 SIZE_T cbCmdLine = Params.CommandLine.Length;
136 if (!cbCmdLine)
137 trace("!cbCmdLine\n");
138
139 LPWSTR pszBuffer = (LPWSTR)calloc(cbCmdLine + sizeof(WCHAR), 1);
140 if (!pszBuffer)
141 trace("!pszBuffer\n");
142
143 ret = ReadProcessMemory(hProcess, cmdline, pszBuffer, cbCmdLine, NULL);
144 if (!ret)
145 trace("ReadProcessMemory failed (%ld)\n", GetLastError());
146
147 pszBuffer[cbCmdLine / sizeof(WCHAR)] = UNICODE_NULL;
148
149 return pszBuffer; // needs free()
150}
#define ok_ntstatus(status, expected)
Definition: atltest.h:135
LONG NTSTATUS
Definition: precomp.h:26
@ ProcessBasicInformation
Definition: cicbase.cpp:44
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:758
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
Status
Definition: gdiplustypes.h:25
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
#define UNICODE_NULL
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:59
#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
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
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by TEST_DoTestEntryStruct().

◆ START_TEST()

START_TEST ( ShellExecuteEx  )

Definition at line 514 of file ShellExecuteEx.cpp.

515{
516#ifdef _WIN64
517 skip("Win64 is not supported yet\n");
518 return;
519#endif
520
521 if (!TEST_Start())
522 return;
523
524 TEST_AppPath();
529
530 TEST_End();
531}
static void test_sei_lpIDList()
static BOOL TEST_Start(void)
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

◆ TEST_AppPath()

static void TEST_AppPath ( void  )
static

Definition at line 472 of file ShellExecuteEx.cpp.

473{
474 if (CreateAppPath(L"app_path_test.bat", s_win_test_exe))
475 {
476 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_WITH_PROCESS, L"app_path_test.bat");
477 TEST_DoTestEntry(__LINE__, TEST_FAILED, L"app_path_test.bat.exe");
478 DeleteAppPath(L"app_path_test.bat");
479 }
480
481 if (CreateAppPath(L"app_path_test.bat.exe", s_sys_test_exe))
482 {
483 TEST_DoTestEntry(__LINE__, TEST_FAILED, L"app_path_test.bat");
484 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_WITH_PROCESS, L"app_path_test.bat.exe");
485 DeleteAppPath(L"app_path_test.bat.exe");
486 }
487}
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 489 of file ShellExecuteEx.cpp.

490{
491 WCHAR szSubProgram[MAX_PATH];
492 if (!FindSubProgram(szSubProgram, _countof(szSubProgram)))
493 {
494 skip("shell32_apitest_sub.exe not found\n");
495 return;
496 }
497
498 DWORD dwExitCode;
500 sei.lpFile = szSubProgram;
501 sei.lpParameters = L"TEST";
502 sei.nShow = SW_SHOWNORMAL;
503
504 // Test invalid path on sei.lpDirectory
505 WCHAR szInvalidPath[MAX_PATH] = L"M:\\This is an invalid path\n";
506 sei.lpDirectory = szInvalidPath;
508 WaitForSingleObject(sei.hProcess, 20 * 1000);
509 GetExitCodeProcess(sei.hProcess, &dwExitCode);
510 ok_long(dwExitCode, 0);
512}
#define ok_long(expression, result)
Definition: atltest.h:133
#define ok_int(expression, result)
Definition: atltest.h:134
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:739
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
Definition: proc.c:1168
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:2552
LPCWSTR lpDirectory
Definition: shellapi.h:340
LPCWSTR lpParameters
Definition: shellapi.h:339
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define SW_SHOWNORMAL
Definition: winuser.h:781

Referenced by START_TEST().

◆ TEST_DoTestEntries()

static void TEST_DoTestEntries ( void  )
static

Definition at line 56 of file ShellExecuteEx.cpp.

57{
60 TEST_DoTestEntry(__LINE__, TEST_FAILED, L"This is an invalid path.");
73 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_WITH_PROCESS, L"\"test program.exe\"", s_sys_test_exe_cmdline);
76 TEST_DoTestEntry(__LINE__, TEST_FAILED, L"shell:ThisIsAnInvalidName");
77 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"); // My Computer
78 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"); // My Computer (with shell:)
79
81 {
82 WCHAR szCurDir[MAX_PATH];
83 GetCurrentDirectoryW(_countof(szCurDir), szCurDir);
85 TEST_DoTestEntry(__LINE__, TEST_FAILED, L"::{21EC2020-3AEA-1069-A2DD-08002B30309D}"); // Control Panel (without path)
86 SetCurrentDirectoryW(szCurDir);
87 }
88
89 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}"); // Control Panel (with path)
90 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:)
91 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:AppData");
92 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Common Desktop");
93 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Common Programs");
94 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Common Start Menu");
95 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Common StartUp");
96 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:ControlPanelFolder");
97 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Desktop");
98 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Favorites");
99 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Fonts");
100 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Local AppData");
101 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:My Pictures");
102 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Personal");
103 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Programs");
104 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Recent");
105 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:RecycleBinFolder");
106 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:SendTo");
107 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:Start Menu");
108 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_NO_PROCESS, L"shell:StartUp");
109}
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:2249
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 201 of file ShellExecuteEx.cpp.

202{
203 WINDOW_LIST existingwindows;
204 GetWindowList(&existingwindows);
205 HWND hWndForeground = GetForegroundWindow();
206
207 TEST_ENTRY entry = { line, result, lpFile, cmdline };
209
211 {
212 // Wait a bit for Explorer to open its window
213 for (UINT i = 0; i < 2000 && hWndForeground == GetForegroundWindow(); i += 250)
214 Sleep(250);
215 }
216
217 CloseNewWindows(&existingwindows);
218 FreeWindowList(&existingwindows);
219}
static TEST_RESULT TEST_DoTestEntryStruct(const TEST_ENTRY *pEntry)
static VOID FreeWindowList(PWINDOW_LIST pList)
Definition: closewnd.h:32
static VOID CloseNewWindows(PWINDOW_LIST pExisting, PWINDOW_LIST pNew)
Definition: closewnd.h:101
static VOID GetWindowList(PWINDOW_LIST pList)
Definition: closewnd.h:54
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
uint32_t entry
Definition: isohybrid.c:63
unsigned int UINT
Definition: ndis.h:50
Definition: cmd.c:13
Definition: parser.c:49
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
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 152 of file ShellExecuteEx.cpp.

153{
154 SHELLEXECUTEINFOW info = { sizeof(info) };
157 info.hwnd = NULL;
158 info.lpVerb = NULL;
159 info.lpFile = pEntry->lpFile;
160 info.nShow = SW_SHOWNORMAL;
161
163
165 if (ret && info.hProcess)
167 else if (ret && !info.hProcess)
169 else
171
172 ok(pEntry->result == result,
173 "Line %d: result: %d vs %d\n", pEntry->line, pEntry->result, result);
174
176 WaitForInputIdle(info.hProcess, 2000);
177
178 if (pEntry->result == TEST_SUCCESS_WITH_PROCESS && pEntry->cmdline && !s_bWow64)
179 {
181 if (!cmdline)
182 {
183 skip("!cmdline\n");
184 }
185 else
186 {
187 ok(lstrcmpiW(pEntry->cmdline, cmdline) == 0,
188 "Line %d: cmdline: '%ls' vs '%ls'\n", pEntry->line,
189 pEntry->cmdline, cmdline);
190 }
191
192 TerminateProcess(info.hProcess, 0xDEADFACE);
193 free(cmdline);
194 }
195
196 CloseHandle(info.hProcess);
197 return result;
198}
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:1532
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4265
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 333 of file ShellExecuteEx.cpp.

334{
341
342 // Execution can be asynchronous; you have to wait for it to finish.
343 INT nCount = GetWindowCount();
344 for (INT i = 0; i < 100; ++i)
345 {
346 INT nOldCount = nCount;
347 Sleep(3000);
348 nCount = GetWindowCount();
349 if (nOldCount == nCount)
350 break;
351 }
352 Sleep(3000);
353
354 // Close newly-opened window(s)
359}
static WINDOW_LIST s_List2
static WINDOW_LIST s_List1
static INT GetWindowCount(VOID)
Definition: closewnd.h:174
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
int32_t INT
Definition: typedefs.h:58

Referenced by START_TEST().

◆ test_properties()

static void test_properties ( void  )
static

Definition at line 361 of file ShellExecuteEx.cpp.

362{
363 HRESULT hrCoInit = CoInitialize(NULL);
364
365 WCHAR Buffer[MAX_PATH * 4];
367
368 SHELLEXECUTEINFOW info = { sizeof(info) };
370 info.lpVerb = L"properties";
371 info.lpFile = Buffer;
372 info.nShow = SW_SHOW;
373
374 BOOL bRet = ShellExecuteExW(&info);
375 ok(bRet, "Failed! (GetLastError(): %d)\n", (int)GetLastError());
376 ok_ptr(info.hInstApp, (HINSTANCE)42);
377
379 if (Extension)
380 {
381 // The inclusion of this depends on the file display settings!
383 }
384
385 // Now retry it with the extension cut off
386 bRet = ShellExecuteExW(&info);
387 ok(bRet, "Failed! (GetLastError(): %d)\n", (int)GetLastError());
388 ok_ptr(info.hInstApp, (HINSTANCE)42);
389
390 // Now retry it with complete garabage
391 info.lpFile = L"complete garbage, cannot run this!";
392 bRet = ShellExecuteExW(&info);
393 ok_int(bRet, 0);
394 ok_ptr(info.hInstApp, (HINSTANCE)2);
395
396 if (SUCCEEDED(hrCoInit))
398}
#define ok_ptr(expression, result)
Definition: atltest.h:108
Definition: bufpool.h:45
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
LPWSTR WINAPI PathFindExtensionW(const WCHAR *path)
Definition: path.c:1274
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define SEE_MASK_INVOKEIDLIST
Definition: shellapi.h:28
#define SW_SHOW
Definition: winuser.h:786

Referenced by START_TEST().

◆ test_sei_lpIDList()

static void test_sei_lpIDList ( )
static

Definition at line 400 of file ShellExecuteEx.cpp.

401{
402 // Note: SEE_MASK_FLAG_NO_UI prevents the test from blocking with a MessageBox
404
405 /* This tests ShellExecuteEx with lpIDList for explorer C:\ */
409 if (!pidl)
410 {
411 skip("Unable to initialize test\n");
412 return;
413 }
414
415 SHELLEXECUTEINFOW ShellExecInfo = { sizeof(ShellExecInfo) };
416 ShellExecInfo.nShow = SW_SHOWNORMAL;
418 ShellExecInfo.lpIDList = pidl;
419 BOOL ret = ShellExecuteExW(&ShellExecInfo);
420 ok_int(ret, TRUE);
421 ILFree(pidl);
422
423 /* This tests ShellExecuteEx with lpIDList going through IContextMenu */
424 CCoInit ComInit;
426 if (!pidl)
427 {
428 skip("Unable to initialize test\n");
429 return;
430 }
432 ShellExecInfo.lpIDList = pidl;
433 ret = ShellExecuteExW(&ShellExecInfo);
434 ok_int(ret, TRUE);
435 ILFree(pidl);
436}
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
BOOL WINAPI PathStripToRootW(WCHAR *path)
Definition: path.c:1195
LPITEMIDLIST WINAPI SHCloneSpecialIDList(HWND hwndOwner, int nFolder, BOOL fCreate)
Definition: pidl.c:446
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1045
LPITEMIDLIST WINAPI ILCreateFromPathW(LPCWSTR path)
Definition: pidl.c:1102
#define SEE_MASK_IDLIST
Definition: shellapi.h:27
#define SEE_MASK_FLAG_DDEWAIT
Definition: shellapi.h:36
#define CSIDL_PROFILE
Definition: shlobj.h:2218
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
COM Initialisation.
Definition: shellclasses.h:179

Referenced by START_TEST().

◆ TEST_Start()

static BOOL TEST_Start ( void  )
static

Definition at line 239 of file ShellExecuteEx.cpp.

240{
241 // Check Wow64
242 s_bWow64 = FALSE;
244 if (s_bWow64)
245 skip("Wow64: Command Line check is skipped\n");
246
247 // getCommandLineFromProcess needs this
249
250 // s_win_dir
252
253 // s_sys_dir
255
256 // s_win_notepad
258 PathAppendW(s_win_notepad, L"notepad.exe");
259
260 // s_sys_notepad
262 PathAppendW(s_sys_notepad, L"notepad.exe");
263
264 // s_win_test_exe
266 PathAppendW(s_win_test_exe, L"test program.exe");
268 if (!ret)
269 {
270 skip("Please retry with admin rights\n");
271 return FALSE;
272 }
273
274 // s_sys_test_exe
276 PathAppendW(s_sys_test_exe, L"test program.exe");
278
279 // s_win_bat_file
281 PathAppendW(s_win_bat_file, L"test program.bat");
282 FILE *fp = _wfopen(s_win_bat_file, L"wb");
283 fprintf(fp, "exit /b 3");
284 fclose(fp);
286
287 // s_sys_bat_file
289 PathAppendW(s_sys_bat_file, L"test program.bat");
290 fp = _wfopen(s_sys_bat_file, L"wb");
291 fprintf(fp, "exit /b 4");
292 fclose(fp);
294
295 // s_win_txt_file
297 PathAppendW(s_win_txt_file, L"test_file.txt");
298 fp = _wfopen(s_win_txt_file, L"wb");
299 fclose(fp);
301
302 // s_sys_txt_file
304 PathAppendW(s_sys_txt_file, L"test_file.txt");
305 fp = _wfopen(s_sys_txt_file, L"wb");
306 fclose(fp);
308
309 // Check .txt settings
312 if (lstrcmpiW(PathFindFileNameW(szPath), L"notepad.exe") != 0)
313 {
314 skip("Please associate .txt with notepad.exe before tests\n");
315 return FALSE;
316 }
317
318 // command lines
320 L"\"%s\" ", s_win_notepad);
322 L"\"%s\" ", s_sys_notepad);
324 L"\"%s\" ", s_win_test_exe);
326 L"\"%s\" ", s_sys_test_exe);
327
329
330 return TRUE;
331}
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:439
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
WCHAR *WINAPI PathFindFileNameW(const WCHAR *path)
Definition: path.c:1701
BOOL WINAPI PathFileExistsW(const WCHAR *path)
Definition: path.c:2607
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
LPCWSTR szPath
Definition: env.c:37
#define PathAppendW
Definition: pathcch.h:310
HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory, LPWSTR lpResult)
Definition: shlexec.cpp:1410
#define SE_DEBUG_NAME
Definition: winnt_old.h:416

Referenced by START_TEST().

Variable Documentation

◆ s_bWow64

BOOL s_bWow64
static

Definition at line 34 of file ShellExecuteEx.cpp.

Referenced by TEST_DoTestEntryStruct(), and TEST_Start().

◆ s_List1

WINDOW_LIST s_List1
static

Definition at line 237 of file ShellExecuteEx.cpp.

Referenced by TEST_End(), and TEST_Start().

◆ s_List2

WINDOW_LIST s_List2
static

Definition at line 237 of file ShellExecuteEx.cpp.

Referenced by TEST_End().

◆ s_sys_bat_file

WCHAR s_sys_bat_file[MAX_PATH]
static

Definition at line 27 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 21 of file ShellExecuteEx.cpp.

Referenced by TEST_DoTestEntries(), and TEST_Start().

◆ s_sys_notepad

WCHAR s_sys_notepad[MAX_PATH]
static

Definition at line 23 of file ShellExecuteEx.cpp.

Referenced by TEST_Start().

◆ s_sys_notepad_cmdline

WCHAR s_sys_notepad_cmdline[MAX_PATH]
static

Definition at line 31 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 25 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 33 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 29 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 26 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 20 of file ShellExecuteEx.cpp.

Referenced by TEST_DoTestEntries(), and TEST_Start().

◆ s_win_notepad

WCHAR s_win_notepad[MAX_PATH]
static

Definition at line 22 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 30 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 24 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 32 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 28 of file ShellExecuteEx.cpp.

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