ReactOS 0.4.15-dev-8434-g155a7c7
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 "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 void 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 35 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 37 of file ShellExecuteEx.cpp.

38{
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 394 of file ShellExecuteEx.cpp.

395{
396 WCHAR szSubKey[MAX_PATH];
397 StringCchPrintfW(szSubKey, _countof(szSubKey), L"%s\\%s", REG_APPPATHS, pszName);
398
400 HKEY hKey;
402 &hKey, NULL);
403 if (error != ERROR_SUCCESS)
404 trace("Could not create test key (%lu)\n", error);
405
406 DWORD cbValue = (lstrlenW(pszValue) + 1) * sizeof(WCHAR);
407 error = RegSetValueExW(hKey, NULL, 0, REG_SZ, (LPBYTE)pszValue, cbValue);
408 if (error != ERROR_SUCCESS)
409 trace("Could not set value of the test key (%lu)\n", error);
410
412
413 return error == ERROR_SUCCESS;
414}
#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
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 L(x)
Definition: ntvdm.h:50
#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 417 of file ShellExecuteEx.cpp.

418{
419 WCHAR szSubKey[MAX_PATH];
420 StringCchPrintfW(szSubKey, _countof(szSubKey), L"%s\\%s", REG_APPPATHS, pszName);
421
423 if (error != ERROR_SUCCESS)
424 trace("Could not remove the test key (%lu)\n", error);
425}
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 203 of file ShellExecuteEx.cpp.

204{
205 HANDLE hToken;
207 return FALSE;
208
209 TOKEN_PRIVILEGES tkp = { 0 };
210 if (!LookupPrivilegeValueW(NULL, pszPrivilege, &tkp.Privileges[0].Luid))
211 return FALSE;
212
213 tkp.PrivilegeCount = 1;
215 return AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, NULL);
216}
#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:1023
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
Definition: setypes.h:1024
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:930
#define TOKEN_QUERY
Definition: setypes.h:928
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63

Referenced by TEST_Start().

◆ getCommandLineFromProcess()

static LPWSTR getCommandLineFromProcess ( HANDLE  hProcess)
static

Definition at line 111 of file ShellExecuteEx.cpp.

112{
113 PEB peb;
117 BOOL ret;
118
121
122 ret = ReadProcessMemory(hProcess, info.PebBaseAddress, &peb, sizeof(peb), NULL);
123 if (!ret)
124 trace("ReadProcessMemory failed (%ld)\n", GetLastError());
125
127 if (!ret)
128 trace("ReadProcessMemory failed (%ld)\n", GetLastError());
129
130 LPWSTR cmdline = Params.CommandLine.Buffer;
131 if (!cmdline)
132 trace("!cmdline\n");
133
134 SIZE_T cbCmdLine = Params.CommandLine.Length;
135 if (!cbCmdLine)
136 trace("!cbCmdLine\n");
137
138 LPWSTR pszBuffer = (LPWSTR)calloc(cbCmdLine + sizeof(WCHAR), 1);
139 if (!pszBuffer)
140 trace("!pszBuffer\n");
141
142 ret = ReadProcessMemory(hProcess, cmdline, pszBuffer, cbCmdLine, NULL);
143 if (!ret)
144 trace("ReadProcessMemory failed (%ld)\n", GetLastError());
145
146 pszBuffer[cbCmdLine / sizeof(WCHAR)] = UNICODE_NULL;
147
148 return pszBuffer; // needs free()
149}
#define ok_ntstatus(status, expected)
Definition: atltest.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:758
unsigned int BOOL
Definition: ntddk_ex.h:94
Status
Definition: gdiplustypes.h:25
@ ProcessBasicInformation
Definition: winternl.h:394
_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
int ret
_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 469 of file ShellExecuteEx.cpp.

470{
471#ifdef _WIN64
472 skip("Win64 is not supported yet\n");
473 return;
474#endif
475
476 if (!TEST_Start())
477 return;
478
479 TEST_AppPath();
484
485 TEST_End();
486}
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 427 of file ShellExecuteEx.cpp.

428{
429 if (CreateAppPath(L"app_path_test.bat", s_win_test_exe))
430 {
431 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_WITH_PROCESS, L"app_path_test.bat");
432 TEST_DoTestEntry(__LINE__, TEST_FAILED, L"app_path_test.bat.exe");
433 DeleteAppPath(L"app_path_test.bat");
434 }
435
436 if (CreateAppPath(L"app_path_test.bat.exe", s_sys_test_exe))
437 {
438 TEST_DoTestEntry(__LINE__, TEST_FAILED, L"app_path_test.bat");
439 TEST_DoTestEntry(__LINE__, TEST_SUCCESS_WITH_PROCESS, L"app_path_test.bat.exe");
440 DeleteAppPath(L"app_path_test.bat.exe");
441 }
442}
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 444 of file ShellExecuteEx.cpp.

445{
446 WCHAR szSubProgram[MAX_PATH];
447 if (!FindSubProgram(szSubProgram, _countof(szSubProgram)))
448 {
449 skip("shell32_apitest_sub.exe not found\n");
450 return;
451 }
452
453 DWORD dwExitCode;
455 sei.lpFile = szSubProgram;
456 sei.lpParameters = L"TEST";
457 sei.nShow = SW_SHOWNORMAL;
458
459 // Test invalid path on sei.lpDirectory
460 WCHAR szInvalidPath[MAX_PATH] = L"M:\\This is an invalid path\n";
461 sei.lpDirectory = szInvalidPath;
463 WaitForSingleObject(sei.hProcess, 20 * 1000);
464 GetExitCodeProcess(sei.hProcess, &dwExitCode);
465 ok_long(dwExitCode, 0);
467}
#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:31
#define SEE_MASK_FLAG_NO_UI
Definition: shellapi.h:36
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2455
LPCWSTR lpDirectory
Definition: shellapi.h:334
LPCWSTR lpParameters
Definition: shellapi.h:333
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define SW_SHOWNORMAL
Definition: winuser.h:770

Referenced by START_TEST().

◆ TEST_DoTestEntries()

static void TEST_DoTestEntries ( void  )
static

Definition at line 55 of file ShellExecuteEx.cpp.

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

197{
198 TEST_ENTRY entry = { line, result, lpFile, cmdline };
200}
static void TEST_DoTestEntryStruct(const TEST_ENTRY *pEntry)
GLuint64EXT * result
Definition: glext.h:11304
uint32_t entry
Definition: isohybrid.c:63
Definition: cmd.c:13
Definition: parser.c:49

Referenced by TEST_AppPath(), and TEST_DoTestEntries().

◆ TEST_DoTestEntryStruct()

static void TEST_DoTestEntryStruct ( const TEST_ENTRY pEntry)
static

Definition at line 151 of file ShellExecuteEx.cpp.

152{
153 SHELLEXECUTEINFOW info = { sizeof(info) };
156 info.hwnd = NULL;
157 info.lpVerb = NULL;
158 info.lpFile = pEntry->lpFile;
159 info.nShow = SW_SHOWNORMAL;
160
162
164 if (ret && info.hProcess)
166 else if (ret && !info.hProcess)
168 else
170
171 ok(pEntry->result == result,
172 "Line %d: result: %d vs %d\n", pEntry->line, pEntry->result, result);
173
174 if (pEntry->result == TEST_SUCCESS_WITH_PROCESS && pEntry->cmdline && !s_bWow64)
175 {
177 if (!cmdline)
178 {
179 skip("!cmdline\n");
180 }
181 else
182 {
183 ok(lstrcmpiW(pEntry->cmdline, cmdline) == 0,
184 "Line %d: cmdline: '%ls' vs '%ls'\n", pEntry->line,
185 pEntry->cmdline, cmdline);
186 }
187
188 TerminateProcess(info.hProcess, 0xDEADFACE);
189 free(cmdline);
190 }
191
192 CloseHandle(info.hProcess);
193}
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:4261
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#define SEE_MASK_NOASYNC
Definition: shellapi.h:33
#define SEE_MASK_WAITFORINPUTIDLE
Definition: shellapi.h:58

Referenced by TEST_DoTestEntry().

◆ TEST_End()

static void TEST_End ( void  )
static

Definition at line 314 of file ShellExecuteEx.cpp.

315{
316 Sleep(500);
321
328}
static WINDOW_LIST s_List2
static WINDOW_LIST s_List1
void CloseNewWindows(PWINDOW_LIST List1, PWINDOW_LIST List2)
Definition: closewnd.cpp:66
void GetWindowList(PWINDOW_LIST pList)
Definition: closewnd.cpp:33
void FreeWindowList(PWINDOW_LIST pList)
Definition: closewnd.cpp:11
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790

Referenced by START_TEST().

◆ test_properties()

static void test_properties ( void  )
static

Definition at line 330 of file ShellExecuteEx.cpp.

331{
332 HRESULT hrCoInit = CoInitialize(NULL);
333
334 WCHAR Buffer[MAX_PATH * 4];
336
337 SHELLEXECUTEINFOW info = { sizeof(info) };
339 info.lpVerb = L"properties";
340 info.lpFile = Buffer;
341 info.nShow = SW_SHOW;
342
343 BOOL bRet = ShellExecuteExW(&info);
344 ok(bRet, "Failed! (GetLastError(): %d)\n", (int)GetLastError());
345 ok_ptr(info.hInstApp, (HINSTANCE)42);
346
348 if (Extension)
349 {
350 // The inclusion of this depends on the file display settings!
352 }
353
354 // Now retry it with the extension cut off
355 bRet = ShellExecuteExW(&info);
356 ok(bRet, "Failed! (GetLastError(): %d)\n", (int)GetLastError());
357 ok_ptr(info.hInstApp, (HINSTANCE)42);
358
359 // Now retry it with complete garabage
360 info.lpFile = L"complete garbage, cannot run this!";
361 bRet = ShellExecuteExW(&info);
362 ok_int(bRet, 0);
363 ok_ptr(info.hInstApp, (HINSTANCE)2);
364
365 if (SUCCEEDED(hrCoInit))
367}
#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
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
_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:775

Referenced by START_TEST().

◆ test_sei_lpIDList()

static void test_sei_lpIDList ( )
static

Definition at line 369 of file ShellExecuteEx.cpp.

370{
372 {
373 skip("Vista+\n");
374 return;
375 }
376
377 /* This tests ShellExecuteEx with lpIDList for explorer C:\ */
378
379 /* ITEMIDLIST for CLSID of 'My Computer' followed by PIDL for 'C:\' */
380 BYTE lpitemidlist[30] = { 0x14, 0, 0x1f, 0, 0xe0, 0x4f, 0xd0, 0x20, 0xea,
381 0x3a, 0x69, 0x10, 0xa2, 0xd8, 0x08, 0, 0x2b, 0x30, 0x30, 0x9d, // My Computer
382 0x8, 0, 0x23, 0x43, 0x3a, 0x5c, 0x5c, 0, 0, 0,}; // C:\\ + NUL-NUL ending
383
384 SHELLEXECUTEINFOW ShellExecInfo = { sizeof(ShellExecInfo) };
385 ShellExecInfo.fMask = SEE_MASK_IDLIST;
386 ShellExecInfo.hwnd = NULL;
387 ShellExecInfo.nShow = SW_SHOWNORMAL;
388 ShellExecInfo.lpIDList = lpitemidlist;
389 BOOL ret = ShellExecuteExW(&ShellExecInfo);
390 ok_int(ret, TRUE);
391}
#define SEE_MASK_IDLIST
Definition: shellapi.h:27
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ TEST_Start()

static BOOL TEST_Start ( void  )
static

Definition at line 220 of file ShellExecuteEx.cpp.

221{
222 // Check Wow64
223 s_bWow64 = FALSE;
225 if (s_bWow64)
226 skip("Wow64: Command Line check is skipped\n");
227
228 // getCommandLineFromProcess needs this
230
231 // s_win_dir
233
234 // s_sys_dir
236
237 // s_win_notepad
239 PathAppendW(s_win_notepad, L"notepad.exe");
240
241 // s_sys_notepad
243 PathAppendW(s_sys_notepad, L"notepad.exe");
244
245 // s_win_test_exe
247 PathAppendW(s_win_test_exe, L"test program.exe");
249 if (!ret)
250 {
251 skip("Please retry with admin rights\n");
252 return FALSE;
253 }
254
255 // s_sys_test_exe
257 PathAppendW(s_sys_test_exe, L"test program.exe");
259
260 // s_win_bat_file
262 PathAppendW(s_win_bat_file, L"test program.bat");
263 FILE *fp = _wfopen(s_win_bat_file, L"wb");
264 fprintf(fp, "exit /b 3");
265 fclose(fp);
267
268 // s_sys_bat_file
270 PathAppendW(s_sys_bat_file, L"test program.bat");
271 fp = _wfopen(s_sys_bat_file, L"wb");
272 fprintf(fp, "exit /b 4");
273 fclose(fp);
275
276 // s_win_txt_file
278 PathAppendW(s_win_txt_file, L"test_file.txt");
279 fp = _wfopen(s_win_txt_file, L"wb");
280 fclose(fp);
282
283 // s_sys_txt_file
285 PathAppendW(s_sys_txt_file, L"test_file.txt");
286 fp = _wfopen(s_sys_txt_file, L"wb");
287 fclose(fp);
289
290 // Check .txt settings
293 if (lstrcmpiW(PathFindFileNameW(szPath), L"notepad.exe") != 0)
294 {
295 skip("Please associate .txt with notepad.exe before tests\n");
296 return FALSE;
297 }
298
299 // command lines
301 L"\"%s\" ", s_win_notepad);
303 L"\"%s\" ", s_sys_notepad);
305 L"\"%s\" ", s_win_test_exe);
307 L"\"%s\" ", s_sys_test_exe);
308
310
311 return TRUE;
312}
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 GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:394
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1777
_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:309
HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory, LPWSTR lpResult)
Definition: shlexec.cpp:1270
#define SE_DEBUG_NAME
Definition: winnt_old.h:385

Referenced by START_TEST().

Variable Documentation

◆ s_bWow64

BOOL s_bWow64
static

Definition at line 33 of file ShellExecuteEx.cpp.

Referenced by TEST_DoTestEntryStruct(), and TEST_Start().

◆ s_List1

WINDOW_LIST s_List1
static

Definition at line 218 of file ShellExecuteEx.cpp.

Referenced by TEST_End(), and TEST_Start().

◆ s_List2

WINDOW_LIST s_List2
static

Definition at line 218 of file ShellExecuteEx.cpp.

Referenced by TEST_End().

◆ s_sys_bat_file

WCHAR s_sys_bat_file[MAX_PATH]
static

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

Referenced by TEST_DoTestEntries(), and TEST_Start().

◆ s_sys_notepad

WCHAR s_sys_notepad[MAX_PATH]
static

Definition at line 22 of file ShellExecuteEx.cpp.

Referenced by TEST_Start().

◆ s_sys_notepad_cmdline

WCHAR s_sys_notepad_cmdline[MAX_PATH]
static

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

Referenced by TEST_DoTestEntries(), and TEST_Start().

◆ s_win_notepad

WCHAR s_win_notepad[MAX_PATH]
static

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

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