#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"
Go to the source code of this file.
◆ REG_APPPATHS
| #define REG_APPPATHS L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\" |
◆ PTEST_ENTRY
◆ TEST_ENTRY
◆ TEST_RESULT
◆ TEST_RESULT
| Enumerator |
|---|
| TEST_FAILED | |
| TEST_SUCCESS_NO_PROCESS | |
| TEST_SUCCESS_WITH_PROCESS | |
Definition at line 59 of file ShellExecuteEx.cpp.
60{
@ TEST_SUCCESS_NO_PROCESS
@ TEST_SUCCESS_WITH_PROCESS
◆ CreateAppPath()
Definition at line 460 of file ShellExecuteEx.cpp.
461{
464
470 trace(
"Could not create test key (%lu)\n",
error);
471
475 trace(
"Could not set value of the test key (%lu)\n",
error);
476
478
480}
#define RegCloseKey(hKey)
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
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)
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
_In_opt_ LPCSTR _In_opt_ LPCSTR pszValue
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
#define HKEY_LOCAL_MACHINE
Referenced by TEST_AppPath().
◆ DeleteAppPath()
◆ enableTokenPrivilege()
| static BOOL enableTokenPrivilege |
( |
LPCWSTR |
pszPrivilege | ) |
|
|
static |
Definition at line 243 of file ShellExecuteEx.cpp.
244{
248
252
256}
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
#define GetCurrentProcess()
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
#define TOKEN_ADJUST_PRIVILEGES
#define SE_PRIVILEGE_ENABLED
Referenced by TEST_Start().
◆ getCommandLineFromProcess()
Definition at line 133 of file ShellExecuteEx.cpp.
134{
140
143
147
151
155
157 if (!cbCmdLine)
158 trace(
"!cbCmdLine\n");
159
161 if (!pszBuffer)
162 trace(
"!pszBuffer\n");
163
167
169
170 return pszBuffer;
171}
#define ok_ntstatus(status, expected)
@ ProcessBasicInformation
#define ReadProcessMemory(a, b, c, d, e)
_In_ BOOL _In_ HANDLE hProcess
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)
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
DWORD WINAPI GetLastError(void)
Referenced by TEST_DoTestEntryStruct().
◆ Reset()
◆ RunTest()
Definition at line 20 of file ShellExecuteEx.cpp.
21{
22
25 {
29 }
30}
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)
BOOL WINAPI TerminateThread(IN HANDLE hThread, IN DWORD dwExitCode)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
#define ERROR_OPERATION_ABORTED
◆ START_TEST()
Definition at line 568 of file ShellExecuteEx.cpp.
569{
571
572
574 return;
575
576#ifdef _WIN64
577 skip(
"Win64 is not supported yet\n");
578 return;
579#endif
580
582 return;
583
589
591}
static KSTART_ROUTINE RunTest
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)
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
◆ TEST_AppPath()
Definition at line 493 of file ShellExecuteEx.cpp.
494{
496 {
500 }
501
503 {
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()
Definition at line 510 of file ShellExecuteEx.cpp.
511{
514 {
515 skip(
"shell32_apitest_sub.exe not found\n");
516 return;
517 }
518
521 sei.
lpFile = szSubProgram;
524
525
533}
#define ok_long(expression, result)
#define ok_int(expression, result)
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
static BOOL FindSubProgram(LPWSTR pszSubProgram, DWORD cchSubProgram)
#define SEE_MASK_NOCLOSEPROCESS
#define SEE_MASK_FLAG_NO_UI
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Referenced by START_TEST().
◆ TEST_DoTestEntries()
Definition at line 77 of file ShellExecuteEx.cpp.
78{
100
102 {
108 }
109
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)
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
VERSIONHELPERAPI IsWindowsVistaOrGreater()
Referenced by START_TEST().
◆ TEST_DoTestEntry()
Definition at line 222 of file ShellExecuteEx.cpp.
223{
227
230
232 {
233
236 }
237
240}
static TEST_RESULT TEST_DoTestEntryStruct(const TEST_ENTRY *pEntry)
static VOID FreeWindowList(PWINDOW_LIST pList)
static VOID CloseNewWindows(PWINDOW_LIST pExisting, PWINDOW_LIST pNew)
static VOID GetWindowList(PWINDOW_LIST pList)
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
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
HWND WINAPI GetForegroundWindow(void)
Referenced by TEST_AppPath(), and TEST_DoTestEntries().
◆ TEST_DoTestEntryStruct()
Definition at line 173 of file ShellExecuteEx.cpp.
174{
182
184
188 else if (
ret && !
info.hProcess)
190 else
192
195
198
200 {
203 {
205 }
206 else
207 {
209 "Line %d: cmdline: '%ls' vs '%ls'\n",
pEntry->line,
211 }
212
215 }
216
219}
static LPWSTR getCommandLineFromProcess(HANDLE hProcess)
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
#define SEE_MASK_WAITFORINPUTIDLE
DWORD WINAPI WaitForInputIdle(_In_ HANDLE, _In_ DWORD)
Referenced by TEST_DoTestEntry().
◆ TEST_End()
Definition at line 354 of file ShellExecuteEx.cpp.
355{
362
363
365 for (
INT i = 0;
i < 100; ++
i)
366 {
367 INT nOldCount = nCount;
370 if (nOldCount == nCount)
371 break;
372 }
374
375
380}
static WINDOW_LIST s_List2
static WINDOW_LIST s_List1
static INT GetWindowCount(VOID)
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Referenced by START_TEST().
◆ Test_InvokeIdList()
Definition at line 535 of file ShellExecuteEx.cpp.
536{
537 CCoInit ComInit;
540 CComHeapPtr<ITEMIDLIST> pidl;
542
548 if (!pidl)
549 {
550 skip(
"No exe to test\n");
551 return 0;
552 }
553
556
559
560 sei.
lpVerb =
L"Shell32_Test_DoesNotExist";
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
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
LPITEMIDLIST WINAPI ILCreateFromPathW(LPCWSTR path)
#define SEE_MASK_INVOKEIDLIST
ITEMIDLIST UNALIGNED * LPITEMIDLIST
#define ERROR_NO_ASSOCIATION
Referenced by START_TEST().
◆ test_properties()
Definition at line 382 of file ShellExecuteEx.cpp.
383{
385
388
391 info.lpVerb =
L"properties";
394
398
401 {
402
404 }
405
406
410
411
412 info.lpFile =
L"complete garbage, cannot run this!";
416
419}
#define ok_ptr(expression, result)
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
LPWSTR WINAPI PathFindExtensionW(const WCHAR *path)
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
_Inout_opt_ PUNICODE_STRING Extension
Referenced by START_TEST().
◆ test_sei_lpIDList()
| static void test_sei_lpIDList |
( |
| ) |
|
|
static |
Definition at line 421 of file ShellExecuteEx.cpp.
422{
423
425
426
430 if (!pidl)
431 {
432 skip(
"Unable to initialize test\n");
433 return;
434 }
435
443
444
445 CCoInit ComInit;
447 if (!pidl)
448 {
449 skip(
"Unable to initialize test\n");
450 return;
451 }
457}
BOOL WINAPI PathStripToRootW(WCHAR *path)
LPITEMIDLIST WINAPI SHCloneSpecialIDList(HWND hwndOwner, int nFolder, BOOL fCreate)
void WINAPI ILFree(LPITEMIDLIST pidl)
#define SEE_MASK_FLAG_DDEWAIT
Referenced by START_TEST().
◆ TEST_Start()
Definition at line 260 of file ShellExecuteEx.cpp.
261{
262
266 skip(
"Wow64: Command Line check is skipped\n");
267
268
270
271
273
274
276
277
280
281
284
285
290 {
291 skip(
"Please retry with admin rights\n");
293 }
294
295
299
300
307
308
315
316
322
323
329
330
334 {
335 skip(
"Please associate .txt with notepad.exe before tests\n");
337 }
338
339
348
350
352}
static BOOL enableTokenPrivilege(LPCWSTR pszPrivilege)
static WCHAR s_sys_notepad[MAX_PATH]
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
WCHAR *WINAPI PathFindFileNameW(const WCHAR *path)
BOOL WINAPI PathFileExistsW(const WCHAR *path)
int CDECL fclose(FILE *file)
int WINAPIV fprintf(FILE *file, const char *format,...)
FILE *CDECL _wfopen(const wchar_t *path, const wchar_t *mode)
HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory, LPWSTR lpResult)
Referenced by START_TEST().
◆ s_bWow64
◆ s_List1
◆ s_List2
◆ s_sys_bat_file
◆ s_sys_dir
◆ s_sys_notepad
◆ s_sys_notepad_cmdline
◆ s_sys_test_exe
◆ s_sys_test_exe_cmdline
◆ s_sys_txt_file
◆ s_win_bat_file
◆ s_win_dir
◆ s_win_notepad
◆ s_win_notepad_cmdline
◆ s_win_test_exe
◆ s_win_test_exe_cmdline
◆ s_win_txt_file