ReactOS  0.4.14-dev-41-g31d7680
shlexec.c File Reference
#include <stdio.h>
#include <assert.h>
#include "wtypes.h"
#include "winbase.h"
#include "windef.h"
#include "shellapi.h"
#include "shlwapi.h"
#include "ddeml.h"
#include "wine/heap.h"
#include "wine/test.h"
#include "shell32_test.h"
Include dependency graph for shlexec.c:

Go to the source code of this file.

Classes

struct  filename_tests_t
 
struct  cmdline_tests_t
 
struct  argify_tests_t
 
struct  fileurl_tests_t
 
struct  dde_tests_t
 
struct  dde_default_app_tests_t
 
struct  dde_thread_info_t
 

Macros

#define NTDDI_WINXPSP1   0x05010100
 
#define NTDDI_VERSION   NTDDI_WINXPSP1
 
#define _WIN32_WINNT   0x0501
 
#define CHILD_DDE_TIMEOUT   2500
 
#define okShell_(file, line)   (winetest_set_location(file, line), 0) ? (void)0 : _okShell
 
#define okShell   okShell_(__FILE__, __LINE__)
 
#define okChildString(key, expected)   okChildString_(__FILE__, __LINE__, (key), (expected), (expected))
 
#define okChildStringBroken(key, expected, broken)   okChildString_(__FILE__, __LINE__, (key), (expected), (broken))
 
#define okChildPath(key, expected)   okChildPath_(__FILE__, __LINE__, (key), (expected))
 
#define okChildInt(key, expected)   okChildInt_(__FILE__, __LINE__, (key), (expected))
 
#define okChildIntBroken(key, expected)   okChildIntBroken_(__FILE__, __LINE__, (key), (expected))
 
#define todo_wait   for (_todo_wait = 1; _todo_wait; _todo_wait = 0)
 
#define shell_execute(verb, filename, parameters, directory)   shell_execute_(__FILE__, __LINE__, verb, filename, parameters, directory)
 
#define shell_execute_ex(mask, verb, filename, parameters, directory, class)   shell_execute_ex_(__FILE__, __LINE__, mask, verb, filename, parameters, directory, class)
 
#define URL_SUCCESS   0x1
 
#define USE_COLON   0x2
 
#define USE_BSLASH   0x4
 
#define DDE_DEFAULT_APP_VARIANTS   3
 

Functions

static const charencodeA (const char *str)
 
static unsigned decode_char (char c)
 
static chardecodeA (const char *str)
 
static void WINETEST_PRINTF_ATTR (2, 3)
 
static chargetChildString (const char *sect, const char *key)
 
static HDDEDATA CALLBACK ddeCb (UINT uType, UINT uFmt, HCONV hConv, HSZ hsz1, HSZ hsz2, HDDEDATA hData, ULONG_PTR dwData1, ULONG_PTR dwData2)
 
static void init_event (const char *child_file)
 
static void CALLBACK childTimeout (HWND wnd, UINT msg, UINT_PTR timer, DWORD time)
 
static void doChild (int argc, char **argv)
 
static void dump_child_ (const char *file, int line)
 
static void reset_association_description (void)
 
static void okChildString_ (const char *file, int line, const char *key, const char *expected, const char *bad)
 
static int StrCmpPath (const char *s1, const char *s2)
 
static void okChildPath_ (const char *file, int line, const char *key, const char *expected)
 
static void okChildInt_ (const char *file, int line, const char *key, int expected)
 
static void okChildIntBroken_ (const char *file, int line, const char *key, int expected)
 
static void strcat_param (char *str, const char *name, const char *param)
 
static INT_PTR shell_execute_ (const char *file, int line, LPCSTR verb, LPCSTR filename, LPCSTR parameters, LPCSTR directory)
 
static INT_PTR shell_execute_ex_ (const char *file, int line, DWORD mask, LPCSTR verb, LPCSTR filename, LPCSTR parameters, LPCSTR directory, LPCSTR class)
 
static BOOL create_test_class (const char *class, BOOL protocol)
 
static BOOL create_test_association (const char *extension)
 
static LSTATUS myRegDeleteTreeA (HKEY hKey, LPCSTR lpszSubKey)
 
static void delete_test_class (const char *classname)
 
static void delete_test_association (const char *extension)
 
static void create_test_verb_dde (const char *classname, const char *verb, int rawcmd, const char *cmdtail, const char *ddeexec, const char *application, const char *topic, const char *ifexec)
 
static void create_test_verb (const char *classname, const char *verb, int rawcmd, const char *cmdtail)
 
static DWORD get_long_path_name (const char *shortpath, char *longpath, DWORD longlen)
 
static void test_lpFile_parsed (void)
 
static BOOL test_one_cmdline (const cmdline_tests_t *test)
 
static void test_commandline2argv (void)
 
static void test_argify (void)
 
static void test_filename (void)
 
static void test_fileurls (void)
 
static void test_urls (void)
 
static void test_find_executable (void)
 
static void test_lnks (void)
 
static void test_exes (void)
 
static DWORD WINAPI hooked_WaitForInputIdle (HANDLE process, DWORD timeout)
 
static void hook_WaitForInputIdle (DWORD(WINAPI *new_func)(HANDLE, DWORD))
 
static void test_dde (void)
 
static DWORD CALLBACK ddeThread (LPVOID arg)
 
static void test_dde_default_app (void)
 
static void init_test (void)
 
static void cleanup_test (void)
 
static void test_directory (void)
 
 START_TEST (shlexec)
 

Variables

static char argv0 [MAX_PATH]
 
static int myARGC
 
static char ** myARGV
 
static char tmpdir [MAX_PATH]
 
static char child_file [MAX_PATH]
 
static DLLVERSIONINFO dllver
 
static BOOL skip_shlexec_tests = FALSE
 
static BOOL skip_noassoc_tests = FALSE
 
static HANDLE dde_ready_event
 
static DWORD ddeInst
 
static HSZ hszTopic
 
static char ddeExec [MAX_PATH]
 
static char ddeApplication [MAX_PATH]
 
static BOOL post_quit_on_execute
 
static HANDLE hEvent
 
static char shell_call [2048]
 
static char assoc_desc [2048]
 
static int _todo_wait = 0
 
static int bad_shellexecute = 0
 
static const chartestfiles []
 
static filename_tests_t filename_tests []
 
static filename_tests_t noquotes_tests []
 
static const cmdline_tests_t cmdline_tests []
 
static const argify_tests_t argify_tests []
 
static fileurl_tests_t fileurl_tests []
 
static filename_tests_t lnk_tests []
 
static dde_tests_t dde_tests []
 
static int waitforinputidle_count
 
static dde_default_app_tests_t dde_default_app_tests []
 

Macro Definition Documentation

◆ _WIN32_WINNT

#define _WIN32_WINNT   0x0501

Definition at line 37 of file shlexec.c.

◆ CHILD_DDE_TIMEOUT

#define CHILD_DDE_TIMEOUT   2500

Definition at line 153 of file shlexec.c.

◆ DDE_DEFAULT_APP_VARIANTS

#define DDE_DEFAULT_APP_VARIANTS   3

Definition at line 2486 of file shlexec.c.

◆ NTDDI_VERSION

#define NTDDI_VERSION   NTDDI_WINXPSP1

Definition at line 36 of file shlexec.c.

◆ NTDDI_WINXPSP1

#define NTDDI_WINXPSP1   0x05010100

Definition at line 35 of file shlexec.c.

◆ okChildInt

#define okChildInt (   key,
  expected 
)    okChildInt_(__FILE__, __LINE__, (key), (expected))

Definition at line 467 of file shlexec.c.

◆ okChildIntBroken

#define okChildIntBroken (   key,
  expected 
)    okChildIntBroken_(__FILE__, __LINE__, (key), (expected))

Definition at line 476 of file shlexec.c.

◆ okChildPath

#define okChildPath (   key,
  expected 
)    okChildPath_(__FILE__, __LINE__, (key), (expected))

Definition at line 458 of file shlexec.c.

◆ okChildString

#define okChildString (   key,
  expected 
)    okChildString_(__FILE__, __LINE__, (key), (expected), (expected))

Definition at line 390 of file shlexec.c.

◆ okChildStringBroken

#define okChildStringBroken (   key,
  expected,
  broken 
)    okChildString_(__FILE__, __LINE__, (key), (expected), (broken))

Definition at line 391 of file shlexec.c.

◆ okShell

#define okShell   okShell_(__FILE__, __LINE__)

Definition at line 369 of file shlexec.c.

◆ okShell_

#define okShell_ (   file,
  line 
)    (winetest_set_location(file, line), 0) ? (void)0 : _okShell

Definition at line 368 of file shlexec.c.

◆ shell_execute

#define shell_execute (   verb,
  filename,
  parameters,
  directory 
)    shell_execute_(__FILE__, __LINE__, verb, filename, parameters, directory)

Definition at line 576 of file shlexec.c.

◆ shell_execute_ex

#define shell_execute_ex (   mask,
  verb,
  filename,
  parameters,
  directory,
  class 
)    shell_execute_ex_(__FILE__, __LINE__, mask, verb, filename, parameters, directory, class)

Definition at line 681 of file shlexec.c.

◆ todo_wait

#define todo_wait   for (_todo_wait = 1; _todo_wait; _todo_wait = 0)

Definition at line 499 of file shlexec.c.

◆ URL_SUCCESS

#define URL_SUCCESS   0x1

Definition at line 1753 of file shlexec.c.

◆ USE_BSLASH

#define USE_BSLASH   0x4

Definition at line 1755 of file shlexec.c.

◆ USE_COLON

#define USE_COLON   0x2

Definition at line 1754 of file shlexec.c.

Function Documentation

◆ childTimeout()

static void CALLBACK childTimeout ( HWND  wnd,
UINT  msg,
UINT_PTR  timer,
DWORD  time 
)
static

Definition at line 208 of file shlexec.c.

209 {
210  trace("childTimeout called\n");
211 
212  PostQuitMessage(0);
213 }
#define trace
Definition: atltest.h:70
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)

Referenced by doChild().

◆ cleanup_test()

static void cleanup_test ( void  )
static

Definition at line 2787 of file shlexec.c.

2788 {
2789  char filename[MAX_PATH];
2790  const char* const * testfile;
2791 
2792  /* Delete the test files */
2793  testfile=testfiles;
2794  while (*testfile)
2795  {
2796  sprintf(filename, *testfile, tmpdir);
2797  /* Make sure we can delete the files ('test file.noassoc' is read-only now) */
2800  testfile++;
2801  }
2804 
2805  /* Delete the test association */
2806  delete_test_association(".shlexec");
2807  delete_test_association(".sha");
2808  delete_test_class("shlproto");
2809 
2811 
2812  CoUninitialize();
2813 }
#define CloseHandle
Definition: compat.h:398
static void delete_test_class(const char *classname)
Definition: shlexec.c:807
static HANDLE hEvent
Definition: shlexec.c:196
const char * filename
Definition: ioapi.h:135
#define sprintf(buf, format,...)
Definition: sprintf.c:55
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:926
static char tmpdir[MAX_PATH]
Definition: shlexec.c:59
#define MAX_PATH
Definition: compat.h:26
static void delete_test_association(const char *extension)
Definition: shlexec.c:812
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
static const char * testfiles[]
Definition: shlexec.c:1012
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714
static char child_file[MAX_PATH]
Definition: shlexec.c:60

Referenced by START_TEST().

◆ create_test_association()

static BOOL create_test_association ( const char extension)
static

Definition at line 719 of file shlexec.c.

720 {
721  HKEY hkey;
722  char class[MAX_PATH];
723  LONG rc;
724 
725  sprintf(class, "shlexec%s", extension);
726  rc=RegCreateKeyExA(HKEY_CLASSES_ROOT, extension, 0, NULL, 0, KEY_SET_VALUE,
727  NULL, &hkey, NULL);
728  ok(rc == ERROR_SUCCESS || rc == ERROR_ACCESS_DENIED,
729  "could not create association %s (rc=%d)\n", class, rc);
730  if (rc != ERROR_SUCCESS)
731  return FALSE;
732 
733  rc=RegSetValueExA(hkey, NULL, 0, REG_SZ, (LPBYTE) class, strlen(class)+1);
734  ok(rc==ERROR_SUCCESS, "RegSetValueEx '%s' failed, expected ERROR_SUCCESS, got %d\n", class, rc);
735  CloseHandle(hkey);
736 
737  return create_test_class(class, FALSE);
738 }
#define CloseHandle
Definition: compat.h:398
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static BOOL create_test_class(const char *class, BOOL protocol)
Definition: shlexec.c:691
#define sprintf(buf, format,...)
Definition: sprintf.c:55
unsigned char * LPBYTE
Definition: typedefs.h:52
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
#define MAX_PATH
Definition: compat.h:26
#define ok(value,...)
Definition: atltest.h:57
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4812
LONG WINAPI RegCreateKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD Reserved, _In_ LPSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_ LPDWORD lpdwDisposition)
Definition: reg.c:1029
#define REG_SZ
Definition: layer.c:22

Referenced by init_test(), test_dde(), test_dde_default_app(), and test_find_executable().

◆ create_test_class()

static BOOL create_test_class ( const char class,
BOOL  protocol 
)
static

Definition at line 691 of file shlexec.c.

692 {
693  HKEY hkey, hkey_shell;
694  LONG rc;
695 
696  rc = RegCreateKeyExA(HKEY_CLASSES_ROOT, class, 0, NULL, 0,
698  &hkey, NULL);
699  ok(rc == ERROR_SUCCESS || rc == ERROR_ACCESS_DENIED,
700  "could not create class %s (rc=%d)\n", class, rc);
701  if (rc != ERROR_SUCCESS)
702  return FALSE;
703 
704  if (protocol)
705  {
706  rc = RegSetValueExA(hkey, "URL Protocol", 0, REG_SZ, (LPBYTE)"", 1);
707  ok(rc == ERROR_SUCCESS, "RegSetValueEx '%s' failed, expected ERROR_SUCCESS, got %d\n", class, rc);
708  }
709 
710  rc = RegCreateKeyExA(hkey, "shell", 0, NULL, 0,
711  KEY_CREATE_SUB_KEY, NULL, &hkey_shell, NULL);
712  ok(rc == ERROR_SUCCESS, "RegCreateKeyEx 'shell' failed, expected ERROR_SUCCESS, got %d\n", rc);
713 
714  CloseHandle(hkey);
715  CloseHandle(hkey_shell);
716  return TRUE;
717 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
unsigned char * LPBYTE
Definition: typedefs.h:52
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: atltest.h:57
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4812
LONG WINAPI RegCreateKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD Reserved, _In_ LPSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_ LPDWORD lpdwDisposition)
Definition: reg.c:1029
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
#define REG_SZ
Definition: layer.c:22

Referenced by create_test_association(), init_test(), and test_urls().

◆ create_test_verb()

static void create_test_verb ( const char classname,
const char verb,
int  rawcmd,
const char cmdtail 
)
static

Definition at line 922 of file shlexec.c.

924 {
925  create_test_verb_dde(classname, verb, rawcmd, cmdtail, NULL, NULL,
926  NULL, NULL);
928 }
WCHAR classname[128]
Definition: startup.c:15
smooth NULL
Definition: ftsmooth.c:416
static void reset_association_description(void)
Definition: shlexec.c:372
static void create_test_verb_dde(const char *classname, const char *verb, int rawcmd, const char *cmdtail, const char *ddeexec, const char *application, const char *topic, const char *ifexec)
Definition: shlexec.c:821

Referenced by init_test(), test_argify(), test_find_executable(), and test_urls().

◆ create_test_verb_dde()

static void create_test_verb_dde ( const char classname,
const char verb,
int  rawcmd,
const char cmdtail,
const char ddeexec,
const char application,
const char topic,
const char ifexec 
)
static

Definition at line 821 of file shlexec.c.

825 {
826  HKEY hkey_shell, hkey_verb, hkey_cmd;
827  char shell[MAX_PATH];
828  char* cmd;
829  LONG rc;
830 
831  strcpy(assoc_desc, " Assoc ");
832  strcat_param(assoc_desc, "class", classname);
833  strcat_param(assoc_desc, "verb", verb);
834  sprintf(shell, "%d", rawcmd);
835  strcat_param(assoc_desc, "rawcmd", shell);
836  strcat_param(assoc_desc, "cmdtail", cmdtail);
837  strcat_param(assoc_desc, "ddeexec", ddeexec);
838  strcat_param(assoc_desc, "app", application);
839  strcat_param(assoc_desc, "topic", topic);
840  strcat_param(assoc_desc, "ifexec", ifexec);
841 
842  sprintf(shell, "%s\\shell", classname);
844  KEY_CREATE_SUB_KEY, &hkey_shell);
845  ok(rc == ERROR_SUCCESS, "%s key creation failed with %d\n", shell, rc);
846 
847  rc=RegCreateKeyExA(hkey_shell, verb, 0, NULL, 0, KEY_CREATE_SUB_KEY,
848  NULL, &hkey_verb, NULL);
849  ok(rc == ERROR_SUCCESS, "%s verb key creation failed with %d\n", verb, rc);
850 
851  rc=RegCreateKeyExA(hkey_verb, "command", 0, NULL, 0, KEY_SET_VALUE,
852  NULL, &hkey_cmd, NULL);
853  ok(rc == ERROR_SUCCESS, "\'command\' key creation failed with %d\n", rc);
854 
855  if (rawcmd)
856  {
857  rc=RegSetValueExA(hkey_cmd, NULL, 0, REG_SZ, (LPBYTE)cmdtail, strlen(cmdtail)+1);
858  }
859  else
860  {
861  cmd = heap_alloc(strlen(argv0) + 10 + strlen(child_file) + 2 + strlen(cmdtail) + 1);
862  sprintf(cmd,"%s shlexec \"%s\" %s", argv0, child_file, cmdtail);
863  rc=RegSetValueExA(hkey_cmd, NULL, 0, REG_SZ, (LPBYTE)cmd, strlen(cmd)+1);
864  ok(rc == ERROR_SUCCESS, "setting command failed with %d\n", rc);
865  heap_free(cmd);
866  }
867 
868  if (ddeexec)
869  {
870  HKEY hkey_ddeexec, hkey_application, hkey_topic, hkey_ifexec;
871 
872  rc=RegCreateKeyExA(hkey_verb, "ddeexec", 0, NULL, 0, KEY_SET_VALUE |
873  KEY_CREATE_SUB_KEY, NULL, &hkey_ddeexec, NULL);
874  ok(rc == ERROR_SUCCESS, "\'ddeexec\' key creation failed with %d\n", rc);
875  rc=RegSetValueExA(hkey_ddeexec, NULL, 0, REG_SZ, (LPBYTE)ddeexec,
876  strlen(ddeexec)+1);
877  ok(rc == ERROR_SUCCESS, "set value failed with %d\n", rc);
878 
879  if (application)
880  {
881  rc=RegCreateKeyExA(hkey_ddeexec, "application", 0, NULL, 0, KEY_SET_VALUE,
882  NULL, &hkey_application, NULL);
883  ok(rc == ERROR_SUCCESS, "\'application\' key creation failed with %d\n", rc);
884 
885  rc=RegSetValueExA(hkey_application, NULL, 0, REG_SZ, (LPBYTE)application,
886  strlen(application)+1);
887  ok(rc == ERROR_SUCCESS, "set value failed with %d\n", rc);
888  CloseHandle(hkey_application);
889  }
890  if (topic)
891  {
892  rc=RegCreateKeyExA(hkey_ddeexec, "topic", 0, NULL, 0, KEY_SET_VALUE,
893  NULL, &hkey_topic, NULL);
894  ok(rc == ERROR_SUCCESS, "\'topic\' key creation failed with %d\n", rc);
895  rc=RegSetValueExA(hkey_topic, NULL, 0, REG_SZ, (LPBYTE)topic,
896  strlen(topic)+1);
897  ok(rc == ERROR_SUCCESS, "set value failed with %d\n", rc);
898  CloseHandle(hkey_topic);
899  }
900  if (ifexec)
901  {
902  rc=RegCreateKeyExA(hkey_ddeexec, "ifexec", 0, NULL, 0, KEY_SET_VALUE,
903  NULL, &hkey_ifexec, NULL);
904  ok(rc == ERROR_SUCCESS, "\'ifexec\' key creation failed with %d\n", rc);
905  rc=RegSetValueExA(hkey_ifexec, NULL, 0, REG_SZ, (LPBYTE)ifexec,
906  strlen(ifexec)+1);
907  ok(rc == ERROR_SUCCESS, "set value failed with %d\n", rc);
908  CloseHandle(hkey_ifexec);
909  }
910  CloseHandle(hkey_ddeexec);
911  }
912 
913  CloseHandle(hkey_shell);
914  CloseHandle(hkey_verb);
915  CloseHandle(hkey_cmd);
916 }
#define CloseHandle
Definition: compat.h:398
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
Definition: ftp_var.h:139
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3331
char * cmd
Definition: vfdcmd.c:85
WCHAR classname[128]
Definition: startup.c:15
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define sprintf(buf, format,...)
Definition: sprintf.c:55
unsigned char * LPBYTE
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
static void strcat_param(char *str, const char *name, const char *param)
Definition: shlexec.c:485
#define MAX_PATH
Definition: compat.h:26
static char argv0[MAX_PATH]
Definition: shlexec.c:56
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
#define ok(value,...)
Definition: atltest.h:57
static const char topic[]
Definition: propsys.c:43
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4812
LONG WINAPI RegCreateKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD Reserved, _In_ LPSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_ LPDWORD lpdwDisposition)
Definition: reg.c:1029
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
static char assoc_desc[2048]
Definition: shlexec.c:371
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
#define REG_SZ
Definition: layer.c:22
static char child_file[MAX_PATH]
Definition: shlexec.c:60

Referenced by create_test_verb(), test_dde(), and test_dde_default_app().

◆ ddeCb()

static HDDEDATA CALLBACK ddeCb ( UINT  uType,
UINT  uFmt,
HCONV  hConv,
HSZ  hsz1,
HSZ  hsz2,
HDDEDATA  hData,
ULONG_PTR  dwData1,
ULONG_PTR  dwData2 
)
static

Definition at line 160 of file shlexec.c.

163 {
164  DWORD size = 0;
165 
166  if (winetest_debug > 2)
167  trace("dde_cb: %04x, %04x, %p, %p, %p, %p, %08lx, %08lx\n",
168  uType, uFmt, hConv, hsz1, hsz2, hData, dwData1, dwData2);
169 
170  switch (uType)
171  {
172  case XTYP_CONNECT:
173  if (!DdeCmpStringHandles(hsz1, hszTopic))
174  {
176  ok(size < MAX_PATH, "got size %d\n", size);
177  assert(size < MAX_PATH);
178  return (HDDEDATA)TRUE;
179  }
180  return (HDDEDATA)FALSE;
181 
182  case XTYP_EXECUTE:
183  size = DdeGetData(hData, (LPBYTE)ddeExec, MAX_PATH, 0);
184  ok(size < MAX_PATH, "got size %d\n", size);
185  assert(size < MAX_PATH);
186  DdeFreeDataHandle(hData);
188  PostQuitMessage(0);
189  return (HDDEDATA)DDE_FACK;
190 
191  default:
192  return NULL;
193  }
194 }
#define TRUE
Definition: types.h:120
#define XTYP_EXECUTE
Definition: ddeml.h:185
#define assert(x)
Definition: debug.h:53
static char ddeApplication[MAX_PATH]
Definition: shlexec.c:156
BOOL WINAPI DdeFreeDataHandle(HDDEDATA)
Definition: ddemisc.c:1461
int winetest_debug
unsigned char * LPBYTE
Definition: typedefs.h:52
DWORD WINAPI DdeQueryStringA(DWORD, HSZ, LPSTR, DWORD, INT)
Definition: ddemisc.c:501
smooth NULL
Definition: ftsmooth.c:416
static DWORD ddeInst
Definition: shlexec.c:154
INT WINAPI DdeCmpStringHandles(HSZ, HSZ)
Definition: ddemisc.c:685
#define XTYP_CONNECT
Definition: ddeml.h:186
GLsizeiptr size
Definition: glext.h:5919
#define trace
Definition: atltest.h:70
static BOOL post_quit_on_execute
Definition: shlexec.c:157
#define MAX_PATH
Definition: compat.h:26
#define DDE_FACK
Definition: ddeml.h:216
unsigned long DWORD
Definition: ntddk_ex.h:95
static HSZ hszTopic
Definition: shlexec.c:155
#define CP_WINANSI
Definition: ddeml.h:32
#define ok(value,...)
Definition: atltest.h:57
DWORD WINAPI DdeGetData(HDDEDATA, LPBYTE, DWORD, DWORD)
Definition: ddemisc.c:1379
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
static char ddeExec[MAX_PATH]
Definition: shlexec.c:156

Referenced by doChild(), and test_dde_default_app().

◆ ddeThread()

static DWORD CALLBACK ddeThread ( LPVOID  arg)
static

Definition at line 2545 of file shlexec.c.

2546 {
2548  assert(info && info->filename);
2549  PostThreadMessageA(info->threadIdParent,
2550  WM_QUIT,
2552  0);
2553  ExitThread(0);
2554 }
#define SEE_MASK_FLAG_DDEWAIT
Definition: shellapi.h:34
#define shell_execute_ex(mask, verb, filename, parameters, directory, class)
Definition: shlexec.c:681
#define WM_QUIT
Definition: winuser.h:1605
BOOL WINAPI PostThreadMessageA(_In_ DWORD, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define assert(x)
Definition: debug.h:53
void * arg
Definition: msvc.h:12
smooth NULL
Definition: ftsmooth.c:416
#define SEE_MASK_FLAG_NO_UI
Definition: shellapi.h:36
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:364

Referenced by test_dde_default_app().

◆ decode_char()

static unsigned decode_char ( char  c)
static

Definition at line 94 of file shlexec.c.

95 {
96  if (c >= '0' && c <= '9') return c - '0';
97  if (c >= 'a' && c <= 'f') return c - 'a' + 10;
98  assert(c >= 'A' && c <= 'F');
99  return c - 'A' + 10;
100 }
#define assert(x)
Definition: debug.h:53
const GLubyte * c
Definition: glext.h:8905

Referenced by decodeA().

◆ decodeA()

static char* decodeA ( const char str)
static

Definition at line 102 of file shlexec.c.

103 {
104  static char decoded[1024];
105  char* ptr;
106  size_t len,i;
107 
108  len = strlen(str) / 2;
109  if (!len--) return NULL;
110  if (len >= sizeof(decoded))
111  {
112  fprintf(stderr, "string is too long!\n");
113  assert(0);
114  }
115  ptr = decoded;
116  for (i = 0; i < len; i++)
117  ptr[i] = (decode_char(str[2 * i]) << 4) | decode_char(str[2 * i + 1]);
118  ptr[len] = '\0';
119  return ptr;
120 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define assert(x)
Definition: debug.h:53
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
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
GLenum GLsizei len
Definition: glext.h:6722
FILE * stderr
static unsigned decode_char(char c)
Definition: shlexec.c:94

Referenced by getChildString().

◆ delete_test_association()

static void delete_test_association ( const char extension)
static

Definition at line 812 of file shlexec.c.

813 {
814  char classname[MAX_PATH];
815 
816  sprintf(classname, "shlexec%s", extension);
819 }
static void delete_test_class(const char *classname)
Definition: shlexec.c:807
WCHAR classname[128]
Definition: startup.c:15
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static LSTATUS myRegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey)
Definition: shlexec.c:741
#define MAX_PATH
Definition: compat.h:26
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10

Referenced by cleanup_test(), test_dde(), test_dde_default_app(), and test_find_executable().

◆ delete_test_class()

static void delete_test_class ( const char classname)
static

Definition at line 807 of file shlexec.c.

808 {
810 }
WCHAR classname[128]
Definition: startup.c:15
static LSTATUS myRegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey)
Definition: shlexec.c:741
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10

Referenced by cleanup_test(), delete_test_association(), and test_urls().

◆ doChild()

static void doChild ( int  argc,
char **  argv 
)
static

Definition at line 215 of file shlexec.c.

216 {
217  char *filename, buffer[MAX_PATH];
218  HANDLE hFile, map;
219  int i;
220  UINT_PTR timer;
221 
222  filename=argv[2];
225  return;
226 
227  /* Arguments */
228  childPrintf(hFile, "[Child]\r\n");
229  if (winetest_debug > 2)
230  {
231  trace("cmdlineA='%s'\n", GetCommandLineA());
232  trace("argcA=%d\n", argc);
233  }
234  childPrintf(hFile, "cmdlineA=%s\r\n", encodeA(GetCommandLineA()));
235  childPrintf(hFile, "argcA=%d\r\n", argc);
236  for (i = 0; i < argc; i++)
237  {
238  if (winetest_debug > 2)
239  trace("argvA%d='%s'\n", i, argv[i]);
240  childPrintf(hFile, "argvA%d=%s\r\n", i, encodeA(argv[i]));
241  }
243  childPrintf(hFile, "longPath=%s\r\n", encodeA(buffer));
244 
245  /* Check environment variable inheritance */
246  *buffer = '\0';
247  SetLastError(0);
248  GetEnvironmentVariableA("ShlexecVar", buffer, sizeof(buffer));
249  childPrintf(hFile, "ShlexecVarLE=%d\r\n", GetLastError());
250  childPrintf(hFile, "ShlexecVar=%s\r\n", encodeA(buffer));
251 
252  map = OpenFileMappingA(FILE_MAP_READ, FALSE, "winetest_shlexec_dde_map");
253  if (map != NULL)
254  {
255  HANDLE dde_ready;
256  char *shared_block = MapViewOfFile(map, FILE_MAP_READ, 0, 0, 4096);
257  CloseHandle(map);
258  if (shared_block[0] != '\0' || shared_block[1] != '\0')
259  {
260  HDDEDATA hdde;
261  HSZ hszApplication;
262  MSG msg;
263  UINT rc;
264 
266  ddeInst = 0;
269  ok(rc == DMLERR_NO_ERROR, "DdeInitializeA() returned %d\n", rc);
270  hszApplication = DdeCreateStringHandleA(ddeInst, shared_block, CP_WINANSI);
271  ok(hszApplication != NULL, "DdeCreateStringHandleA(%s) = NULL\n", shared_block);
272  shared_block += strlen(shared_block) + 1;
274  ok(hszTopic != NULL, "DdeCreateStringHandleA(%s) = NULL\n", shared_block);
275  hdde = DdeNameService(ddeInst, hszApplication, 0, DNS_REGISTER | DNS_FILTEROFF);
276  ok(hdde != NULL, "DdeNameService() failed le=%u\n", GetLastError());
277 
279 
280  dde_ready = OpenEventA(EVENT_MODIFY_STATE, FALSE, "winetest_shlexec_dde_ready");
281  SetEvent(dde_ready);
282  CloseHandle(dde_ready);
283 
284  while (GetMessageA(&msg, NULL, 0, 0))
285  {
286  if (winetest_debug > 2)
287  trace("msg %d lParam=%ld wParam=%lu\n", msg.message, msg.lParam, msg.wParam);
289  }
290 
291  Sleep(500);
292  KillTimer(NULL, timer);
293  hdde = DdeNameService(ddeInst, hszApplication, 0, DNS_UNREGISTER);
294  ok(hdde != NULL, "DdeNameService() failed le=%u\n", GetLastError());
295  ok(DdeFreeStringHandle(ddeInst, hszTopic), "DdeFreeStringHandle(topic)\n");
296  ok(DdeFreeStringHandle(ddeInst, hszApplication), "DdeFreeStringHandle(application)\n");
297  ok(DdeUninitialize(ddeInst), "DdeUninitialize() failed\n");
298  }
299  else
300  {
301  dde_ready = OpenEventA(EVENT_MODIFY_STATE, FALSE, "winetest_shlexec_dde_ready");
302  SetEvent(dde_ready);
303  CloseHandle(dde_ready);
304  }
305 
306  UnmapViewOfFile(shared_block);
307 
308  childPrintf(hFile, "ddeExec=%s\r\n", encodeA(ddeExec));
309  }
310 
311  childPrintf(hFile, "Failures=%d\r\n", winetest_get_failures());
313 
315  SetEvent(hEvent);
317 }
#define DNS_UNREGISTER
Definition: ddeml.h:153
static int argc
Definition: ServiceArgs.c:12
LONG winetest_get_failures(void)
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#define CBF_FAIL_ADVISES
Definition: ddeml.h:105
#define MapViewOfFile
Definition: compat.h:402
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL WINAPI GetMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
#define CBF_FAIL_POKES
Definition: ddeml.h:107
static HANDLE hEvent
Definition: shlexec.c:196
#define argv
Definition: mplay32.c:18
const char * filename
Definition: ioapi.h:135
int winetest_debug
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:548
#define DNS_REGISTER
Definition: ddeml.h:152
#define CBF_FAIL_REQUESTS
Definition: ddeml.h:108
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
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventA(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCSTR lpName)
Definition: synch.c:669
#define GENERIC_WRITE
Definition: nt_native.h:90
#define DMLERR_NO_ERROR
Definition: ddeml.h:242
BOOL WINAPI DdeUninitialize(DWORD)
Definition: ddemisc.c:1112
smooth NULL
Definition: ftsmooth.c:416
static void CALLBACK childTimeout(HWND wnd, UINT msg, UINT_PTR timer, DWORD time)
Definition: shlexec.c:208
#define FILE_MAP_READ
Definition: compat.h:427
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
static DWORD ddeInst
Definition: shlexec.c:154
#define DNS_FILTEROFF
Definition: ddeml.h:155
#define trace
Definition: atltest.h:70
#define GetEnvironmentVariableA(x, y, z)
Definition: compat.h:411
static void init_event(const char *child_file)
Definition: shlexec.c:197
BOOL WINAPI DdeFreeStringHandle(DWORD, HSZ)
Definition: ddemisc.c:631
static BOOL post_quit_on_execute
Definition: shlexec.c:157
#define MAX_PATH
Definition: compat.h:26
static HDDEDATA CALLBACK ddeCb(UINT uType, UINT uFmt, HCONV hConv, HSZ hsz1, HSZ hsz2, HDDEDATA hData, ULONG_PTR dwData1, ULONG_PTR dwData2)
Definition: shlexec.c:160
#define SetLastError(x)
Definition: compat.h:409
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
Definition: _map.h:44
LPSTR WINAPI GetCommandLineA(VOID)
Definition: proc.c:2003
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
_In_ HANDLE hFile
Definition: mswsock.h:90
static HSZ hszTopic
Definition: shlexec.c:155
#define CREATE_ALWAYS
Definition: disk.h:72
#define CP_WINANSI
Definition: ddeml.h:32
HANDLE NTAPI OpenFileMappingA(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCSTR lpName)
Definition: filemap.c:284
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
HDDEDATA WINAPI DdeNameService(DWORD, HSZ, HSZ, UINT)
Definition: ddeserver.c:154
#define msg(x)
Definition: auth_time.c:54
#define CBF_SKIP_ALLNOTIFICATIONS
Definition: ddeml.h:115
HSZ WINAPI DdeCreateStringHandleA(DWORD, LPCSTR, INT)
Definition: ddemisc.c:577
static const char * encodeA(const char *str)
Definition: shlexec.c:74
#define EVENT_MODIFY_STATE
Definition: winbase.h:163
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
#define CHILD_DDE_TIMEOUT
Definition: shlexec.c:153
#define UnmapViewOfFile
Definition: compat.h:403
UINT WINAPI DdeInitializeA(LPDWORD, PFNCALLBACK, DWORD, DWORD)
Definition: ddemisc.c:1075
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 GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum map
Definition: glfuncs.h:262
static char ddeExec[MAX_PATH]
Definition: shlexec.c:156

Referenced by START_TEST().

◆ dump_child_()

static void dump_child_ ( const char file,
int  line 
)
static

Definition at line 319 of file shlexec.c.

320 {
321  if (winetest_debug > 1)
322  {
323  char key[18];
324  char* str;
325  int i, c;
326 
327  str=getChildString("Child", "cmdlineA");
328  trace_(file, line)("cmdlineA='%s'\n", str);
329  c=GetPrivateProfileIntA("Child", "argcA", -1, child_file);
330  trace_(file, line)("argcA=%d\n",c);
331  for (i=0;i<c;i++)
332  {
333  sprintf(key, "argvA%d", i);
334  str=getChildString("Child", key);
335  trace_(file, line)("%s='%s'\n", key, str);
336  }
337 
338  c=GetPrivateProfileIntA("Child", "ShlexecVarLE", -1, child_file);
339  trace_(file, line)("ShlexecVarLE=%d\n", c);
340  str=getChildString("Child", "ShlexecVar");
341  trace_(file, line)("ShlexecVar='%s'\n", str);
342 
343  c=GetPrivateProfileIntA("Child", "Failures", -1, child_file);
344  trace_(file, line)("Failures=%d\n", c);
345  }
346 }
#define trace_(file, line,...)
Definition: kmt_test.h:221
static char * getChildString(const char *sect, const char *key)
Definition: shlexec.c:134
int winetest_debug
#define sprintf(buf, format,...)
Definition: sprintf.c:55
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
const WCHAR * str
Definition: parser.c:48
const GLubyte * c
Definition: glext.h:8905
HKEY key
Definition: reg.c:42
#define c
Definition: ke_i.h:80
UINT WINAPI GetPrivateProfileIntA(LPCSTR section, LPCSTR entry, INT def_val, LPCSTR filename)
Definition: profile.c:1326
Definition: path.c:42
Definition: fci.c:126
static char child_file[MAX_PATH]
Definition: shlexec.c:60

Referenced by shell_execute_(), and shell_execute_ex_().

◆ encodeA()

static const char* encodeA ( const char str)
static

Definition at line 74 of file shlexec.c.

75 {
76  static char encoded[2*1024+1];
77  char* ptr;
78  size_t len,i;
79 
80  if (!str) return "";
81  len = strlen(str) + 1;
82  if (len >= sizeof(encoded)/2)
83  {
84  fprintf(stderr, "string is too long!\n");
85  assert(0);
86  }
87  ptr = encoded;
88  for (i = 0; i < len; i++)
89  sprintf(&ptr[i * 2], "%02x", (unsigned char)str[i]);
90  ptr[2 * len] = '\0';
91  return ptr;
92 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define assert(x)
Definition: debug.h:53
#define sprintf(buf, format,...)
Definition: sprintf.c:55
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
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str
GLenum GLsizei len
Definition: glext.h:6722
FILE * stderr

Referenced by doChild().

◆ get_long_path_name()

static DWORD get_long_path_name ( const char shortpath,
char longpath,
DWORD  longlen 
)
static

Definition at line 937 of file shlexec.c.

938 {
939  char tmplongpath[MAX_PATH];
940  const char* p;
941  DWORD sp = 0, lp = 0;
942  DWORD tmplen;
943  WIN32_FIND_DATAA wfd;
944  HANDLE goit;
945 
946  if (!shortpath || !shortpath[0])
947  return 0;
948 
949  if (shortpath[1] == ':')
950  {
951  tmplongpath[0] = shortpath[0];
952  tmplongpath[1] = ':';
953  lp = sp = 2;
954  }
955 
956  while (shortpath[sp])
957  {
958  /* check for path delimiters and reproduce them */
959  if (shortpath[sp] == '\\' || shortpath[sp] == '/')
960  {
961  if (!lp || tmplongpath[lp-1] != '\\')
962  {
963  /* strip double "\\" */
964  tmplongpath[lp++] = '\\';
965  }
966  tmplongpath[lp] = 0; /* terminate string */
967  sp++;
968  continue;
969  }
970 
971  p = shortpath + sp;
972  if (sp == 0 && p[0] == '.' && (p[1] == '/' || p[1] == '\\'))
973  {
974  tmplongpath[lp++] = *p++;
975  tmplongpath[lp++] = *p++;
976  }
977  for (; *p && *p != '/' && *p != '\\'; p++);
978  tmplen = p - (shortpath + sp);
979  lstrcpynA(tmplongpath + lp, shortpath + sp, tmplen + 1);
980  /* Check if the file exists and use the existing file name */
981  goit = FindFirstFileA(tmplongpath, &wfd);
982  if (goit == INVALID_HANDLE_VALUE)
983  return 0;
984  FindClose(goit);
985  strcpy(tmplongpath + lp, wfd.cFileName);
986  lp += strlen(tmplongpath + lp);
987  sp += tmplen;
988  }
989  tmplen = strlen(shortpath) - 1;
990  if ((shortpath[tmplen] == '/' || shortpath[tmplen] == '\\') &&
991  (tmplongpath[lp - 1] != '/' && tmplongpath[lp - 1] != '\\'))
992  tmplongpath[lp++] = shortpath[tmplen];
993  tmplongpath[lp] = 0;
994 
995  tmplen = strlen(tmplongpath) + 1;
996  if (tmplen <= longlen)
997  {
998  strcpy(longpath, tmplongpath);
999  tmplen--; /* length without 0 */
1000  }
1001 
1002  return tmplen;
1003 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define lstrcpynA
Definition: compat.h:408
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
static const WCHAR sp[]
Definition: suminfo.c:288
static char shortpath[MAX_PATH]
Definition: batch.c:32
GLfloat GLfloat p
Definition: glext.h:8902
HANDLE WINAPI FindFirstFileA(IN LPCSTR lpFileName, OUT LPWIN32_FIND_DATAA lpFindFileData)
Definition: find.c:263
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by test_fileurls(), and test_lnks().

◆ getChildString()

static char* getChildString ( const char sect,
const char key 
)
static

Definition at line 134 of file shlexec.c.

135 {
136  char buf[1024];
137  char* ret;
138 
139  GetPrivateProfileStringA(sect, key, "-", buf, sizeof(buf), child_file);
140  if (buf[0] == '\0' || (buf[0] == '-' && buf[1] == '\0')) return NULL;
141  assert(!(strlen(buf) & 1));
142  ret = decodeA(buf);
143  return ret;
144 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static char * decodeA(const char *str)
Definition: shlexec.c:102
#define assert(x)
Definition: debug.h:53
INT WINAPI GetPrivateProfileStringA(LPCSTR section, LPCSTR entry, LPCSTR def_val, LPSTR buffer, UINT len, LPCSTR filename)
Definition: profile.c:1204
smooth NULL
Definition: ftsmooth.c:416
int ret
Definition: path.c:42
static char child_file[MAX_PATH]
Definition: shlexec.c:60

Referenced by dump_child_(), okChildPath_(), okChildString_(), and test_argify().

◆ hook_WaitForInputIdle()

static void hook_WaitForInputIdle ( DWORD(WINAPI *new_func)(HANDLE, DWORD )
static

Definition at line 2328 of file shlexec.c.

2329 {
2330  char *base;
2331  PIMAGE_NT_HEADERS nt_headers;
2332  DWORD import_directory_rva;
2333  PIMAGE_IMPORT_DESCRIPTOR import_descriptor;
2334  int hook_count = 0;
2335 
2336  base = (char *) GetModuleHandleA("shell32.dll");
2337  nt_headers = (PIMAGE_NT_HEADERS)(base + ((PIMAGE_DOS_HEADER) base)->e_lfanew);
2338  import_directory_rva = nt_headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
2339 
2340  /* Search for the correct imported module by walking the import descriptors */
2341  import_descriptor = (PIMAGE_IMPORT_DESCRIPTOR)(base + import_directory_rva);
2342  while (U(*import_descriptor).OriginalFirstThunk != 0)
2343  {
2344  char *import_module_name;
2345 
2346  import_module_name = base + import_descriptor->Name;
2347  if (lstrcmpiA(import_module_name, "user32.dll") == 0 ||
2348  lstrcmpiA(import_module_name, "user32") == 0)
2349  {
2350  PIMAGE_THUNK_DATA int_entry;
2351  PIMAGE_THUNK_DATA iat_entry;
2352 
2353  /* The import name table and import address table are two parallel
2354  * arrays. We need the import name table to find the imported
2355  * routine and the import address table to patch the address, so
2356  * walk them side by side */
2357  int_entry = (PIMAGE_THUNK_DATA)(base + U(*import_descriptor).OriginalFirstThunk);
2358  iat_entry = (PIMAGE_THUNK_DATA)(base + import_descriptor->FirstThunk);
2359  while (int_entry->u1.Ordinal != 0)
2360  {
2361  if (! IMAGE_SNAP_BY_ORDINAL(int_entry->u1.Ordinal))
2362  {
2363  PIMAGE_IMPORT_BY_NAME import_by_name;
2364  import_by_name = (PIMAGE_IMPORT_BY_NAME)(base + int_entry->u1.AddressOfData);
2365  if (lstrcmpA((char *) import_by_name->Name, "WaitForInputIdle") == 0)
2366  {
2367  /* Found the correct routine in the correct imported module. Patch it. */
2368  DWORD old_prot;
2369  VirtualProtect(&iat_entry->u1.Function, sizeof(ULONG_PTR), PAGE_READWRITE, &old_prot);
2370  iat_entry->u1.Function = (ULONG_PTR) new_func;
2371  VirtualProtect(&iat_entry->u1.Function, sizeof(ULONG_PTR), old_prot, &old_prot);
2372  if (winetest_debug > 1)
2373  trace("Hooked %s.WaitForInputIdle\n", import_module_name);
2374  hook_count++;
2375  break;
2376  }
2377  }
2378  int_entry++;
2379  iat_entry++;
2380  }
2381  break;
2382  }
2383 
2384  import_descriptor++;
2385  }
2386  ok(hook_count, "Could not hook WaitForInputIdle()\n");
2387 }
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntddk_ex.h:178
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
#define U(x)
Definition: wordpad.c:44
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
struct _IMAGE_IMPORT_DESCRIPTOR * PIMAGE_IMPORT_DESCRIPTOR
struct _IMAGE_IMPORT_BY_NAME * PIMAGE_IMPORT_BY_NAME
PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS
Definition: ntddk_ex.h:187
int winetest_debug
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
uint32_t ULONG_PTR
Definition: typedefs.h:63
DWORD e_lfanew
Definition: crypt.c:1156
GLuint base
Definition: 3dtext.c:35
#define trace
Definition: atltest.h:70
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL NTAPI VirtualProtect(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flNewProtect, OUT PDWORD lpflOldProtect)
Definition: virtmem.c:144
union _IMAGE_THUNK_DATA32::@2055 u1
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
#define IMAGE_SNAP_BY_ORDINAL(Ordinal)
Definition: ntimage.h:567
#define ok(value,...)
Definition: atltest.h:57
#define IMAGE_DIRECTORY_ENTRY_IMPORT
Definition: pedump.c:260
#define ULONG_PTR
Definition: config.h:101
PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA
Definition: ntimage.h:566
#define PAGE_READWRITE
Definition: nt_native.h:1304

Referenced by test_dde().

◆ hooked_WaitForInputIdle()

static DWORD WINAPI hooked_WaitForInputIdle ( HANDLE  process,
DWORD  timeout 
)
static

Definition at line 2310 of file shlexec.c.

2311 {
2313  if (winetest_debug > 1)
2314  trace("WaitForInputIdle() waiting for dde event timeout=min(%u,5s)\n", timeout);
2315  timeout = timeout < 5000 ? timeout : 5000;
2317 }
Definition: dhcpd.h:245
int winetest_debug
GLbitfield GLuint64 timeout
Definition: glext.h:7164
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define trace
Definition: atltest.h:70
static int waitforinputidle_count
Definition: shlexec.c:2309
static HANDLE dde_ready_event
Definition: shlexec.c:64

Referenced by test_dde().

◆ init_event()

static void init_event ( const char child_file)
static

Definition at line 197 of file shlexec.c.

198 {
199  char* event_name;
200  event_name=strrchr(child_file, '\\')+1;
201  hEvent=CreateEventA(NULL, FALSE, FALSE, event_name);
202 }
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
static HANDLE hEvent
Definition: shlexec.c:196
smooth NULL
Definition: ftsmooth.c:416
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:637
static char child_file[MAX_PATH]
Definition: shlexec.c:60

Referenced by doChild(), and init_test().

◆ init_test()

static void init_test ( void  )
static

Definition at line 2656 of file shlexec.c.

2657 {
2658  HMODULE hdll;
2659  HRESULT (WINAPI *pDllGetVersion)(DLLVERSIONINFO*);
2660  char filename[MAX_PATH];
2661  WCHAR lnkfile[MAX_PATH];
2662  char params[1024];
2663  const char* const * testfile;
2664  lnk_desc_t desc;
2665  DWORD rc;
2666  HRESULT r;
2667 
2668  hdll=GetModuleHandleA("shell32.dll");
2669  pDllGetVersion=(void*)GetProcAddress(hdll, "DllGetVersion");
2670  if (pDllGetVersion)
2671  {
2672  dllver.cbSize=sizeof(dllver);
2673  pDllGetVersion(&dllver);
2674  trace("major=%d minor=%d build=%d platform=%d\n",
2677  }
2678  else
2679  {
2680  memset(&dllver, 0, sizeof(dllver));
2681  }
2682 
2683  r = CoInitialize(NULL);
2684  ok(r == S_OK, "CoInitialize failed (0x%08x)\n", r);
2685  if (FAILED(r))
2686  exit(1);
2687 
2688  rc=GetModuleFileNameA(NULL, argv0, sizeof(argv0));
2689  ok(rc != 0 && rc < sizeof(argv0), "got %d\n", rc);
2691  {
2692  strcat(argv0, ".so");
2694  "unable to find argv0!\n");
2695  }
2696 
2697  /* Older versions (win 2k) fail tests if there is a space in
2698  the path. */
2699  if (dllver.dwMajorVersion <= 5)
2700  strcpy(filename, "c:\\");
2701  else
2702  GetTempPathA(sizeof(filename), filename);
2703  GetTempFileNameA(filename, "wt", 0, tmpdir);
2704  GetLongPathNameA(tmpdir, tmpdir, sizeof(tmpdir));
2705  DeleteFileA( tmpdir );
2706  rc = CreateDirectoryA( tmpdir, NULL );
2707  ok( rc, "failed to create %s err %u\n", tmpdir, GetLastError() );
2708  /* Set %TMPDIR% for the tests */
2709  SetEnvironmentVariableA("TMPDIR", tmpdir);
2710 
2711  rc = GetTempFileNameA(tmpdir, "wt", 0, child_file);
2712  ok(rc != 0, "got %d\n", rc);
2714 
2715  /* Set up the test files */
2716  testfile=testfiles;
2717  while (*testfile)
2718  {
2719  HANDLE hfile;
2720 
2721  sprintf(filename, *testfile, tmpdir);
2724  if (hfile==INVALID_HANDLE_VALUE)
2725  {
2726  trace("unable to create '%s': err=%u\n", filename, GetLastError());
2727  assert(0);
2728  }
2729  CloseHandle(hfile);
2730  testfile++;
2731  }
2732 
2733  /* Setup the test shortcuts */
2734  sprintf(filename, "%s\\test_shortcut_shlexec.lnk", tmpdir);
2735  MultiByteToWideChar(CP_ACP, 0, filename, -1, lnkfile, ARRAY_SIZE(lnkfile));
2736  desc.description=NULL;
2737  desc.workdir=NULL;
2738  sprintf(filename, "%s\\test file.shlexec", tmpdir);
2739  desc.path=filename;
2740  desc.pidl=NULL;
2741  desc.arguments="ignored";
2742  desc.showcmd=0;
2743  desc.icon=NULL;
2744  desc.icon_id=0;
2745  desc.hotkey=0;
2746  create_lnk(lnkfile, &desc, 0);
2747 
2748  sprintf(filename, "%s\\test_shortcut_exe.lnk", tmpdir);
2749  MultiByteToWideChar(CP_ACP, 0, filename, -1, lnkfile, ARRAY_SIZE(lnkfile));
2750  desc.description=NULL;
2751  desc.workdir=NULL;
2752  desc.path=argv0;
2753  desc.pidl=NULL;
2754  sprintf(params, "shlexec \"%s\" Lnk", child_file);
2755  desc.arguments=params;
2756  desc.showcmd=0;
2757  desc.icon=NULL;
2758  desc.icon_id=0;
2759  desc.hotkey=0;
2760  create_lnk(lnkfile, &desc, 0);
2761 
2762  /* Create a basic association suitable for most tests */
2763  if (!create_test_association(".shlexec"))
2764  {
2766  skip("Unable to create association for '.shlexec'\n");
2767  return;
2768  }
2769  create_test_verb("shlexec.shlexec", "Open", 0, "Open \"%1\"");
2770  create_test_verb("shlexec.shlexec", "NoQuotes", 0, "NoQuotes %1");
2771  create_test_verb("shlexec.shlexec", "LowerL", 0, "LowerL %l");
2772  create_test_verb("shlexec.shlexec", "QuotedLowerL", 0, "QuotedLowerL \"%l\"");
2773  create_test_verb("shlexec.shlexec", "UpperL", 0, "UpperL %L");
2774  create_test_verb("shlexec.shlexec", "QuotedUpperL", 0, "QuotedUpperL \"%L\"");
2775 
2776  create_test_association(".sha");
2777  create_test_verb("shlexec.sha", "averb", 0, "AVerb \"%1\"");
2778 
2779  create_test_class("shlproto", TRUE);
2780  create_test_verb("shlproto", "open", 0, "URL \"%1\"");
2781  create_test_verb("shlproto", "averb", 0, "AVerb \"%1\"");
2782 
2783  /* Set an environment variable to see if it is inherited */
2784  SetEnvironmentVariableA("ShlexecVar", "Present");
2785 }
#define HRESULT
Definition: msvc.h:9
DWORD dwMinorVersion
Definition: shlwapi.h:1956
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
static BOOL create_test_class(const char *class, BOOL protocol)
Definition: shlexec.c:691
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define CP_ACP
Definition: compat.h:99
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define assert(x)
Definition: debug.h:53
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
const char * filename
Definition: ioapi.h:135
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:548
DWORD WINAPI GetLongPathNameA(IN LPCSTR lpszShortPath, OUT LPSTR lpszLongPath, IN DWORD cchBuffer)
Definition: path.c:1670
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static void create_test_verb(const char *classname, const char *verb, int rawcmd, const char *cmdtail)
Definition: shlexec.c:922
static DLLVERSIONINFO dllver
Definition: shlexec.c:61
GLenum const GLfloat * params
Definition: glext.h:5645
DWORD dwBuildNumber
Definition: shlwapi.h:1957
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:786
#define GENERIC_WRITE
Definition: nt_native.h:90
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
DWORD dwMajorVersion
Definition: shlwapi.h:1955
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
static char tmpdir[MAX_PATH]
Definition: shlexec.c:59
#define trace
Definition: atltest.h:70
static void init_event(const char *child_file)
Definition: shlexec.c:197
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableA(IN LPCSTR lpName, IN LPCSTR lpValue)
Definition: environ.c:218
#define MAX_PATH
Definition: compat.h:26
#define WINAPI
Definition: msvc.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
static char argv0[MAX_PATH]
Definition: shlexec.c:56
DWORD dwPlatformID
Definition: shlwapi.h:1958
#define S_OK
Definition: intsafe.h:59
#define CREATE_ALWAYS
Definition: disk.h:72
static const char * testfiles[]
Definition: shlexec.c:1012
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2053
#define create_lnk(a, b, c)
Definition: shell32_test.h:37
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
static PVOID hdll
Definition: shimdbg.c:126
#define MultiByteToWideChar
Definition: compat.h:100
#define skip(...)
Definition: atltest.h:64
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1897
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define GetProcAddress(x, y)
Definition: compat.h:410
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
void exit(int exitcode)
Definition: _exit.c:33
#define memset(x, y, z)
Definition: compat.h:39
static BOOL create_test_association(const char *extension)
Definition: shlexec.c:719
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
static BOOL skip_shlexec_tests
Definition: shlexec.c:62
static char child_file[MAX_PATH]
Definition: shlexec.c:60

Referenced by START_TEST().

◆ myRegDeleteTreeA()

static LSTATUS myRegDeleteTreeA ( HKEY  hKey,
LPCSTR  lpszSubKey 
)
static

Definition at line 741 of file shlexec.c.

742 {
743  LONG ret;
744  DWORD dwMaxSubkeyLen, dwMaxValueLen;
745  DWORD dwMaxLen, dwSize;
746  CHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
747  HKEY hSubKey = hKey;
748 
749  if(lpszSubKey)
750  {
751  ret = RegOpenKeyExA(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
752  if (ret) return ret;
753  }
754 
755  /* Get highest length for keys, values */
756  ret = RegQueryInfoKeyA(hSubKey, NULL, NULL, NULL, NULL,
757  &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
758  if (ret) goto cleanup;
759 
760  dwMaxSubkeyLen++;
761  dwMaxValueLen++;
762  dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
763  if (dwMaxLen > ARRAY_SIZE(szNameBuf))
764  {
765  /* Name too big: alloc a buffer for it */
766  if (!(lpszName = heap_alloc(dwMaxLen*sizeof(CHAR))))
767  {
769  goto cleanup;
770  }
771  }
772 
773 
774  /* Recursively delete all the subkeys */
775  while (TRUE)
776  {
777  dwSize = dwMaxLen;
778  if (RegEnumKeyExA(hSubKey, 0, lpszName, &dwSize, NULL,
779  NULL, NULL, NULL)) break;
780 
781  ret = myRegDeleteTreeA(hSubKey, lpszName);
782  if (ret) goto cleanup;
783  }
784 
785  if (lpszSubKey)
786  ret = RegDeleteKeyA(hKey, lpszSubKey);
787  else
788  while (TRUE)
789  {
790  dwSize = dwMaxLen;
791  if (RegEnumValueA(hKey, 0, lpszName, &dwSize,
792  NULL, NULL, NULL, NULL)) break;
793 
794  ret = RegDeleteValueA(hKey, lpszName);
795  if (ret) goto cleanup;
796  }
797 
798 cleanup:
799  /* Free buffer if allocated */
800  if (lpszName != szNameBuf)
801  heap_free(lpszName);
802  if(lpszSubKey)
803  RegCloseKey(hSubKey);
804  return ret;
805 }
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
#define KEY_READ
Definition: nt_native.h:1023
LONG WINAPI RegQueryInfoKeyA(HKEY hKey, LPSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3607
char CHAR
Definition: xmlstorage.h:175
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3331
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
static LSTATUS myRegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey)
Definition: shlexec.c:741
LONG WINAPI RegEnumValueA(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpdwReserved, _Out_opt_ LPDWORD lpdwType, _Out_opt_ LPBYTE lpData, _Inout_opt_ LPDWORD lpcbData)
Definition: reg.c:2691
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
Definition: reg.c:1222
#define ARRAY_SIZE(a)
Definition: main.h:24
LONG WINAPI RegDeleteValueA(HKEY hKey, LPCSTR lpValueName)
Definition: reg.c:2319
char * cleanup(char *str)
Definition: wpickclick.c:99
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
LONG WINAPI RegEnumKeyExA(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2442
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by delete_test_association(), and delete_test_class().

◆ okChildInt_()

static void okChildInt_ ( const char file,
int  line,
const char key,
int  expected 
)
static

Definition at line 460 of file shlexec.c.

461 {
462  INT result;
465  "%s expected %d, but got %d\n", key, expected, result);
466 }
int32_t INT
Definition: typedefs.h:56
Definition: parser.c:48
HKEY key
Definition: reg.c:42
#define okShell_(file, line)
Definition: shlexec.c:368
UINT WINAPI GetPrivateProfileIntA(LPCSTR section, LPCSTR entry, INT def_val, LPCSTR filename)
Definition: profile.c:1326
GLuint64EXT * result
Definition: glext.h:11304
BOOL expected
Definition: store.c:2063
Definition: path.c:42
Definition: fci.c:126
static char child_file[MAX_PATH]
Definition: shlexec.c:60

Referenced by shell_execute_(), and shell_execute_ex_().

◆ okChildIntBroken_()

static void okChildIntBroken_ ( const char file,
int  line,
const char key,
int  expected 
)
static

Definition at line 469 of file shlexec.c.

470 {
471  INT result;
474  "%s expected %d, but got %d\n", key, expected, result);
475 }
int32_t INT
Definition: typedefs.h:56
Definition: parser.c:48
HKEY key
Definition: reg.c:42
#define broken(x)
Definition: _sntprintf.h:21
#define okShell_(file, line)
Definition: shlexec.c:368
UINT WINAPI GetPrivateProfileIntA(LPCSTR section, LPCSTR entry, INT def_val, LPCSTR filename)
Definition: profile.c:1326
GLuint64EXT * result
Definition: glext.h:11304
BOOL expected
Definition: store.c:2063
Definition: path.c:42
Definition: fci.c:126
static char child_file[MAX_PATH]
Definition: shlexec.c:60

◆ okChildPath_()

static void okChildPath_ ( const char file,
int  line,
const char key,
const char expected 
)
static

Definition at line 430 of file shlexec.c.

431 {
432  char* result;
433  int equal, shortequal;
434  result=getChildString("Child", key);
435  if (!result)
436  {
437  okShell_(file,line)(FALSE, "%s expected '%s', but key not found or empty\n", key, expected);
438  return;
439  }
440  shortequal = FALSE;
441  equal = (StrCmpPath(result, expected) == 0);
442  if (!equal)
443  {
444  char altpath[MAX_PATH];
445  DWORD rc = GetLongPathNameA(expected, altpath, sizeof(altpath));
446  if (0 < rc && rc < sizeof(altpath))
447  equal = (StrCmpPath(result, altpath) == 0);
448  if (!equal)
449  {
450  rc = GetShortPathNameA(expected, altpath, sizeof(altpath));
451  if (0 < rc && rc < sizeof(altpath))
452  shortequal = (StrCmpPath(result, altpath) == 0);
453  }
454  }
455  okShell_(file,line)(equal || broken(shortequal) /* XP SP1 */,
456  "%s expected '%s', got '%s'\n", key, expected, result);
457 }
static char * getChildString(const char *sect, const char *key)
Definition: shlexec.c:134
#define equal(x, y)
Definition: reader.cc:56
static int StrCmpPath(const char *s1, const char *s2)
Definition: shlexec.c:393
DWORD WINAPI GetLongPathNameA(IN LPCSTR lpszShortPath, OUT LPSTR lpszLongPath, IN DWORD cchBuffer)
Definition: path.c:1670
Definition: parser.c:48
DWORD WINAPI GetShortPathNameA(IN LPCSTR lpszLongPath, OUT LPSTR lpszShortPath, IN DWORD cchBuffer)
Definition: path.c:1751
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY key
Definition: reg.c:42
#define broken(x)
Definition: _sntprintf.h:21
#define okShell_(file, line)
Definition: shlexec.c:368
GLuint64EXT * result
Definition: glext.h:11304
BOOL expected
Definition: store.c:2063
Definition: path.c:42
Definition: fci.c:126

◆ okChildString_()

static void okChildString_ ( const char file,
int  line,
const char key,
const char expected,
const char bad 
)
static

Definition at line 377 of file shlexec.c.

378 {
379  char* result;
380  result=getChildString("Child", key);
381  if (!result)
382  {
383  okShell_(file, line)(FALSE, "%s expected '%s', but key not found or empty\n", key, expected);
384  return;
385  }
387  broken(lstrcmpiA(result, bad) == 0),
388  "%s expected '%s', got '%s'\n", key, expected, result);
389 }
static char * getChildString(const char *sect, const char *key)
Definition: shlexec.c:134
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
Definition: parser.c:48
HKEY key
Definition: reg.c:42
#define broken(x)
Definition: _sntprintf.h:21
#define okShell_(file, line)
Definition: shlexec.c:368
GLuint64EXT * result
Definition: glext.h:11304
BOOL expected
Definition: store.c:2063
Definition: path.c:42
Definition: fci.c:126

Referenced by shell_execute_(), and shell_execute_ex_().

◆ reset_association_description()

static void reset_association_description ( void  )
static

Definition at line 372 of file shlexec.c.

373 {
374  *assoc_desc = '\0';
375 }
static char assoc_desc[2048]
Definition: shlexec.c:371

Referenced by create_test_verb(), test_dde(), and test_dde_default_app().

◆ shell_execute_()

static INT_PTR shell_execute_ ( const char file,
int  line,
LPCSTR  verb,
LPCSTR  filename,
LPCSTR  parameters,
LPCSTR  directory 
)
static

Definition at line 503 of file shlexec.c.

504 {
505  INT_PTR rc, rcEmpty = 0;
506 
507  if(!verb)
508  rcEmpty = shell_execute_(file, line, "", filename, parameters, directory);
509 
510  strcpy(shell_call, "ShellExecute(");
511  strcat_param(shell_call, "verb", verb);
512  strcat_param(shell_call, "file", filename);
513  strcat_param(shell_call, "params", parameters);
515  strcat(shell_call, ")");
517  if (winetest_debug > 1)
518  trace_(file, line)("Called %s\n", shell_call);
519 
521  SetLastError(0xcafebabe);
522 
523  /* FIXME: We cannot use ShellExecuteEx() here because if there is no
524  * association it displays the 'Open With' dialog and I could not find
525  * a flag to prevent this.
526  */
527  rc=(INT_PTR)ShellExecuteA(NULL, verb, filename, parameters, directory, SW_HIDE);
528 
529  if (rc > 32)
530  {
531  int wait_rc;
532  wait_rc=WaitForSingleObject(hEvent, 5000);
533  if (wait_rc == WAIT_TIMEOUT)
534  {
535  HWND wnd = FindWindowA("#32770", "Windows");
536  if (!wnd)
537  wnd = FindWindowA("Shell_Flyout", "");
538  if (wnd != NULL)
539  {
540  SendMessageA(wnd, WM_CLOSE, 0, 0);
541  win_skip("Skipping shellexecute of file with unassociated extension\n");
543  rc = SE_ERR_NOASSOC;
544  }
545  }
547  okShell_(file, line)(wait_rc==WAIT_OBJECT_0 || rc <= 32,
548  "WaitForSingleObject returned %d\n", wait_rc);
549  }
550  /* The child process may have changed the result file, so let profile
551  * functions know about it
552  */
555  {
556  int c;
558  c = GetPrivateProfileIntA("Child", "Failures", -1, child_file);
559  if (c > 0)
561  okChildInt_(file, line, "ShlexecVarLE", 0);
562  okChildString_(file, line, "ShlexecVar", "Present", "Present");
563  }
564 
565  if(!verb)
566  {
567  if (rc != rcEmpty && rcEmpty == SE_ERR_NOASSOC) /* NT4 */
568  bad_shellexecute = 1;
569  okShell_(file, line)(rc == rcEmpty ||
570  broken(rc != rcEmpty && rcEmpty == SE_ERR_NOASSOC) /* NT4 */,
571  "Got different return value with empty string: %lu %lu\n", rc, rcEmpty);
572  }
573 
574  return rc;
575 }
HINSTANCE WINAPI ShellExecuteA(HWND hWnd, LPCSTR lpVerb, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, INT iShowCmd)
Definition: shlexec.cpp:2113
static char shell_call[2048]
Definition: shlexec.c:355
#define trace_(file, line,...)
Definition: kmt_test.h:221
#define TRUE
Definition: types.h:120
void winetest_add_failures(LONG new_failures)
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
#define SW_HIDE
Definition: winuser.h:762
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
int32_t INT_PTR
Definition: typedefs.h:62
static HANDLE hEvent
Definition: shlexec.c:196
const char * filename
Definition: ioapi.h:135
int winetest_debug
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:786
static void okChildString_(const char *file, int line, const char *key, const char *expected, const char *bad)
Definition: shlexec.c:377
smooth NULL
Definition: ftsmooth.c:416
static void strcat_param(char *str, const char *name, const char *param)
Definition: shlexec.c:485
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
Definition: parser.c:48
#define todo_wine_if(is_todo)
Definition: test.h:155
#define WAIT_OBJECT_0
Definition: winbase.h:387
#define WM_CLOSE
Definition: winuser.h:1603
const GLubyte * c
Definition: glext.h:8905
#define SetLastError(x)
Definition: compat.h:409
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define broken(x)
Definition: _sntprintf.h:21
HWND WINAPI FindWindowA(_In_opt_ LPCSTR, _In_opt_ LPCSTR)
static void okChildInt_(const char *file, int line, const char *key, int expected)
Definition: shlexec.c:460
static int bad_shellexecute
Definition: shlexec.c:501
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define c
Definition: ke_i.h:80
static BOOL skip_noassoc_tests
Definition: shlexec.c:63
#define okShell_(file, line)
Definition: shlexec.c:368
#define SE_ERR_NOASSOC
Definition: shellapi.h:132
static int _todo_wait
Definition: shlexec.c:498
BOOL WINAPI DECLSPEC_HOTPATCH WritePrivateProfileStringA(LPCSTR section, LPCSTR entry, LPCSTR string, LPCSTR filename)
Definition: profile.c:1484
UINT WINAPI GetPrivateProfileIntA(LPCSTR section, LPCSTR entry, INT def_val, LPCSTR filename)
Definition: profile.c:1326
static INT_PTR shell_execute_(const char *file, int line, LPCSTR verb, LPCSTR filename, LPCSTR parameters, LPCSTR directory)
Definition: shlexec.c:503
#define win_skip
Definition: test.h:141
static char assoc_desc[2048]
Definition: shlexec.c:371
static void dump_child_(const char *file, int line)
Definition: shlexec.c:319
Definition: fci.c:126
static char child_file[MAX_PATH]
Definition: shlexec.c:60

◆ shell_execute_ex_()

static INT_PTR shell_execute_ex_ ( const char file,
int  line,
DWORD  mask,
LPCSTR  verb,
LPCSTR  filename,
LPCSTR  parameters,
LPCSTR  directory,
LPCSTR  class 
)
static

Definition at line 579 of file shlexec.c.

583 {
584  char smask[11];
585  SHELLEXECUTEINFOA sei;
586  BOOL success;
587  INT_PTR rc;
588 
589  /* Add some flags so we can wait for the child process */
591 
592  strcpy(shell_call, "ShellExecuteEx(");
593  sprintf(smask, "0x%x", mask);
594  strcat_param(shell_call, "mask", smask);
595  strcat_param(shell_call, "verb", verb);
596  strcat_param(shell_call, "file", filename);
597  strcat_param(shell_call, "params", parameters);
599  strcat_param(shell_call, "class", class);
600  strcat(shell_call, ")");
602  if (winetest_debug > 1)
603  trace_(file, line)("Called %s\n", shell_call);
604 
605  sei.cbSize=sizeof(sei);
606  sei.fMask=mask;
607  sei.hwnd=NULL;
608  sei.lpVerb=verb;
609  sei.lpFile=filename;
610  sei.lpParameters=parameters;
612  sei.nShow=SW_SHOWNORMAL;
613  sei.hInstApp=NULL; /* Out */
614  sei.lpIDList=NULL;
615  sei.lpClass=class;
616  sei.hkeyClass=NULL;
617  sei.dwHotKey=0;
618  U(sei).hIcon=NULL;
619  sei.hProcess=(HANDLE)0xdeadbeef; /* Out */
620 
622  SetLastError(0xcafebabe);
623  success=ShellExecuteExA(&sei);
624  rc=(INT_PTR)sei.hInstApp;
625  okShell_(file, line)((success && rc > 32) || (!success && rc <= 32),
626  "rc=%d and hInstApp=%ld is not allowed\n",
627  success, rc);
628 
629  if (rc > 32)
630  {
631  DWORD wait_rc, rc;
632  if (sei.hProcess!=NULL)
633  {
634  wait_rc=WaitForSingleObject(sei.hProcess, 5000);
635  okShell_(file, line)(wait_rc==WAIT_OBJECT_0,
636  "WaitForSingleObject(hProcess) returned %d\n",
637  wait_rc);
638  wait_rc = GetExitCodeProcess(sei.hProcess, &rc);
639  okShell_(file, line)(wait_rc, "GetExitCodeProcess() failed le=%u\n", GetLastError());
641  okShell_(file, line)(rc == 0, "child returned %u\n", rc);
642  CloseHandle(sei.hProcess);
643  }
644  wait_rc=WaitForSingleObject(hEvent, 5000);
646  okShell_(file, line)(wait_rc==WAIT_OBJECT_0,
647  "WaitForSingleObject returned %d\n", wait_rc);
648  }
649  else
650  okShell_(file, line)(sei.hProcess==NULL,
651  "returned a process handle %p\n", sei.hProcess);
652 
653  /* The child process may have changed the result file, so let profile
654  * functions know about it
655  */
658  {
659  int c;
661  c = GetPrivateProfileIntA("Child", "Failures", -1, child_file);
662  if (c > 0)
664  /* When NOZONECHECKS is specified the environment variables are not
665  * inherited if the process does not have elevated privileges.
666  */
668  {
669  okChildInt_(file, line, "ShlexecVarLE", 203);
670  okChildString_(file, line, "ShlexecVar", "", "");
671  }
672  else
673  {
674  okChildInt_(file, line, "ShlexecVarLE", 0);
675  okChildString_(file, line, "ShlexecVar", "Present", "Present");
676  }
677  }
678 
679  return rc;
680 }
static char shell_call[2048]
Definition: shlexec.c:355
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExA(LPSHELLEXECUTEINFOA sei)
Definition: shlexec.cpp:2147
#define trace_(file, line,...)
Definition: kmt_test.h:221
#define CloseHandle
Definition: compat.h:398
void winetest_add_failures(LONG new_failures)
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
#define SEE_MASK_NOCLOSEPROCESS
Definition: shellapi.h:31
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
Definition: proc.c:1168
#define SEE_MASK_NO_CONSOLE
Definition: shellapi.h:38
#define U(x)
Definition: wordpad.c:44
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
int32_t INT_PTR
Definition: typedefs.h:62
static HANDLE hEvent
Definition: shlexec.c:196
const char * filename
Definition: ioapi.h:135
int winetest_debug
#define sprintf(buf, format,...)
Definition: sprintf.c:55
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
GLenum GLint GLuint mask
Definition: glext.h:6028
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:786
HINSTANCE hInstApp
Definition: shellapi.h:317
static void okChildString_(const char *file, int line, const char *key, const char *expected, const char *bad)
Definition: shlexec.c:377
smooth NULL
Definition: ftsmooth.c:416
static void strcat_param(char *str, const char *name, const char *param)
Definition: shlexec.c:485
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
Definition: parser.c:48
#define todo_wine_if(is_todo)
Definition: test.h:155
#define SEE_MASK_NOZONECHECKS
Definition: shellapi.h:54
#define WAIT_OBJECT_0
Definition: winbase.h:387
LPCSTR lpParameters
Definition: shellapi.h:314
const GLubyte * c
Definition: glext.h:8905
unsigned long DWORD
Definition: ntddk_ex.h:95
PVOID HANDLE
Definition: typedefs.h:71
#define success(from, fromstr, to, tostr)
#define SetLastError(x)
Definition: compat.h:409
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
LPCSTR lpDirectory
Definition: shellapi.h:315
#define SW_SHOWNORMAL
Definition: winuser.h:764
static void okChildInt_(const char *file, int line, const char *key, int expected)
Definition: shlexec.c:460
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define c
Definition: ke_i.h:80
#define okShell_(file, line)
Definition: shlexec.c:368
static int _todo_wait
Definition: shlexec.c:498
BOOL WINAPI DECLSPEC_HOTPATCH WritePrivateProfileStringA(LPCSTR section, LPCSTR entry, LPCSTR string, LPCSTR filename)
Definition: profile.c:1484
UINT WINAPI GetPrivateProfileIntA(LPCSTR section, LPCSTR entry, INT def_val, LPCSTR filename)
Definition: profile.c:1326
static char assoc_desc[2048]
Definition: shlexec.c:371
static void dump_child_(const char *file, int line)
Definition: shlexec.c:319
static BOOL skip_shlexec_tests
Definition: shlexec.c:62
Definition: fci.c:126
static char child_file[MAX_PATH]
Definition: shlexec.c:60

◆ START_TEST()

START_TEST ( shlexec  )

Definition at line 2868 of file shlexec.c.

2869 {
2870 
2872  if (myARGC >= 3)
2873  {
2874  doChild(myARGC, myARGV);
2875  /* Skip the tests/failures trace for child processes */
2877  }
2878 
2879  init_test();
2880 
2882  test_argify();
2884  test_filename();
2885  test_fileurls();
2886  test_urls();
2888  test_lnks();
2889  test_exes();
2890  test_dde();
2892  test_directory();
2893 
2894  cleanup_test();
2895 }
LONG winetest_get_failures(void)
static void test_argify(void)
Definition: shlexec.c:1552
static void test_fileurls(void)
Definition: shlexec.c:1793
static void doChild(int argc, char **argv)
Definition: shlexec.c:215
static void test_exes(void)
Definition: shlexec.c:2211
static void test_lpFile_parsed(void)
Definition: shlexec.c:1099
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1487
static void cleanup_test(void)
Definition: shlexec.c:2787
static void test_find_executable(void)
Definition: shlexec.c:1970
static void test_dde_default_app(void)
Definition: shlexec.c:2556
static void test_directory(void)
Definition: shlexec.c:2815
static void test_filename(void)
Definition: shlexec.c:1610
static int myARGC
Definition: shlexec.c:57
static void test_lnks(void)
Definition: shlexec.c:2117
static void init_test(void)
Definition: shlexec.c:2656
int winetest_get_mainargs(char ***pargv)
static char ** myARGV
Definition: shlexec.c:58
static void test_urls(void)
Definition: shlexec.c:1876
static void test_dde(void)
Definition: shlexec.c:2389
static void test_commandline2argv(void)
Definition: shlexec.c:1366

◆ strcat_param()

static void strcat_param ( char str,
const char name,
const char param 
)
static

Definition at line 485 of file shlexec.c.

486 {
487  if (param)
488  {
489  if (str[strlen(str)-1] == '"')
490  strcat(str, ", ");
491  strcat(str, name);
492  strcat(str, "=\"");
493  strcat(str, param);
494  strcat(str, "\"");
495  }
496 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
const WCHAR * str
GLfloat param
Definition: glext.h:5796
Definition: name.c:36

Referenced by create_test_verb_dde(), shell_execute_(), and shell_execute_ex_().

◆ StrCmpPath()

static int StrCmpPath ( const char s1,
const char s2 
)
static

Definition at line 393 of file shlexec.c.

394 {
395  if (!s1 && !s2) return 0;
396  if (!s2) return 1;
397  if (!s1) return -1;
398  while (*s1)
399  {
400  if (!*s2)
401  {
402  if (*s1=='.')
403  s1++;
404  return (*s1-*s2);
405  }
406  if ((*s1=='/' || *s1=='\\') && (*s2=='/' || *s2=='\\'))
407  {
408  while (*s1=='/' || *s1=='\\')
409  s1++;
410  while (*s2=='/' || *s2=='\\')
411  s2++;
412  }
413  else if (toupper(*s1)==toupper(*s2))
414  {
415  s1++;
416  s2++;
417  }
418  else
419  {
420  return (*s1-*s2);
421  }
422  }
423  if (*s2=='.')
424  s2++;
425  if (*s2)
426  return -1;
427  return 0;
428 }
struct S2 s2
int toupper(int c)
Definition: utclib.c:881
struct S1 s1

Referenced by okChildPath_().

◆ test_argify()

static void test_argify ( void  )
static

Definition at line 1552 of file shlexec.c.

1553 {
1554  char fileA[MAX_PATH], params[2*MAX_PATH+12];
1555  INT_PTR rc;
1556  const argify_tests_t* test;
1557  const char *bad;
1558  const char* cmd;
1559 
1560  /* Test with a long parameter */
1561  for (rc = 0; rc < MAX_PATH; rc++)
1562  fileA[rc] = 'a' + rc % 26;
1563  fileA[MAX_PATH-1] = '\0';
1564  sprintf(params, "shlexec \"%s\" %s", child_file, fileA);
1565 
1566  /* We need NOZONECHECKS on Win2003 to block a dialog */
1568  okShell(rc > 32, "failed: rc=%lu\n", rc);
1569  okChildInt("argcA", 4);
1570  okChildPath("argvA3", fileA);
1571 
1572  if (skip_shlexec_tests)
1573  {
1574  skip("No argify tests due to lack of .shlexec association\n");
1575  return;
1576  }
1577 
1578  create_test_verb("shlexec.shlexec", "Params232S", 0, "Params232S %2 %3 \"%2\" \"%*\"");
1579  create_test_verb("shlexec.shlexec", "Params23456", 0, "Params23456 \"%2\" \"%3\" \"%4\" \"%5\" \"%6\"");
1580  create_test_verb("shlexec.shlexec", "Params23456789", 0, "Params23456789 \"%2\" \"%3\" \"%4\" \"%5\" \"%6\" \"%7\" \"%8\" \"%9\"");
1581  create_test_verb("shlexec.shlexec", "Params2345Etc", 0, "Params2345Etc ~2=\"%~2\" ~3=\"%~3\" ~4=\"%~4\" ~5=%~5");
1582  create_test_verb("shlexec.shlexec", "Params9Etc", 0, "Params9Etc ~9=\"%~9\"");
1583  create_test_verb("shlexec.shlexec", "Params20", 0, "Params20 \"%20\"");
1584  create_test_verb("shlexec.shlexec", "ParamsBad", 0, "ParamsBad \"%% %- %~ %~0 %~1 %~a %~* %a %b %c %TMPDIR%\"");
1585 
1586  sprintf(fileA, "%s\\test file.shlexec", tmpdir);
1587 
1588  test = argify_tests;
1589  while (test->params)
1590  {
1591  bad = test->broken ? test->broken : test->cmd;
1592 
1593  rc = shell_execute_ex(SEE_MASK_DOENVSUBST, test->verb, fileA, test->params, NULL, NULL);
1594  okShell(rc > 32, "failed: rc=%lu\n", rc);
1595 
1596  cmd = getChildString("Child", "cmdlineA");
1597  /* Our commands are such that the verb immediately precedes the
1598  * part we are interested in.
1599  */
1600  if (cmd) cmd = strstr(cmd, test->verb);
1601  if (cmd) cmd += strlen(test->verb);
1602  if (!cmd) cmd = "(null)";
1603  todo_wine_if(test->todo)
1604  okShell(!strcmp(cmd, test->cmd) || broken(!strcmp(cmd, bad)),
1605  "expected '%s', got '%s'\n", cmd, test->cmd);
1606  test++;
1607  }
1608 }
static char * getChildString(const char *sect, const char *key)
Definition: shlexec.c:134
#define shell_execute_ex(mask, verb, filename, parameters, directory, class)
Definition: shlexec.c:681
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
Definition: ftp_var.h:139
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
#define okChildInt(key, expected)
Definition: shlexec.c:467
GLdouble n
Definition: glext.h:7729
char * cmd
Definition: vfdcmd.c:85
#define test
Definition: rosglue.h:37
int32_t INT_PTR
Definition: typedefs.h:62
static const argify_tests_t argify_tests[]
Definition: shlexec.c:1427
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static void create_test_verb(const char *classname, const char *verb, int rawcmd, const char *cmdtail)
Definition: shlexec.c:922
GLenum const GLfloat * params
Definition: glext.h:5645
smooth NULL
Definition: ftsmooth.c:416
#define todo_wine_if(is_todo)
Definition: test.h:155
#define SEE_MASK_NOZONECHECKS
Definition: shellapi.h:54
static char tmpdir[MAX_PATH]
Definition: shlexec.c:59
#define MAX_PATH
Definition: compat.h:26
#define SEE_MASK_DOENVSUBST
Definition: shellapi.h:35
static char argv0[MAX_PATH]
Definition: shlexec.c:56
GLdouble s
Definition: gl.h:2039
#define okShell
Definition: shlexec.c:369
#define broken(x)
Definition: _sntprintf.h:21
#define skip(...)
Definition: atltest.h:64
#define okChildPath(key, expected)
Definition: shlexec.c:458
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
BOOL expected
Definition: store.c:2063
static BOOL skip_shlexec_tests
Definition: shlexec.c:62
static char child_file[MAX_PATH]
Definition: shlexec.c:60

Referenced by START_TEST().

◆ test_commandline2argv()

static void test_commandline2argv ( void  )
static

Definition at line 1366 of file shlexec.c.

1367 {
1368  static const WCHAR exeW[] = {'e','x','e',0};
1369  const cmdline_tests_t* test;
1370  WCHAR strW[MAX_PATH];
1371  LPWSTR *args;
1372  int numargs;
1373  DWORD le;
1374 
1375  test = cmdline_tests;
1376  while (test->cmd)
1377  {
1378  if (!test_one_cmdline(test))
1379  return;
1380  test++;
1381  }
1382 
1383  SetLastError(0xdeadbeef);
1384  args = CommandLineToArgvW(exeW, NULL);
1385  le = GetLastError();
1386  ok(args == NULL && le == ERROR_INVALID_PARAMETER, "expected NULL with ERROR_INVALID_PARAMETER got %p with %u\n", args, le);
1387 
1388  SetLastError(0xdeadbeef);
1390  le = GetLastError();
1391  ok(args == NULL && le == ERROR_INVALID_PARAMETER, "expected NULL with ERROR_INVALID_PARAMETER got %p with %u\n", args, le);
1392 
1393  *strW = 0;
1394  args = CommandLineToArgvW(strW, &numargs);
1395  ok(numargs == 1 || broken(numargs > 1), "expected 1 args, got %d\n", numargs);
1396  ok(!args || (!args[numargs] || broken(args[numargs] != NULL) /* before Vista */),
1397  "expected NULL-terminated list of commandline arguments\n");
1398  if (numargs == 1)
1399  {
1401  ok(!lstrcmpW(args[0], strW), "wrong path to the current executable: %s instead of %s\n", wine_dbgstr_w(args[0]), wine_dbgstr_w(strW));
1402  }
1403  if (args) LocalFree(args);
1404 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:609
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define test
Definition: rosglue.h:37
Definition: match.c:390
static BOOL test_one_cmdline(const cmdline_tests_t *test)
Definition: shlexec.c:1325
WCHAR strW[12]
Definition: clipboard.c:2029
LPWSTR *WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int *numargs)
Definition: shell32_main.c:76
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const cmdline_tests_t cmdline_tests[]
Definition: shlexec.c:1164
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define broken(x)
Definition: _sntprintf.h:21
#define ARRAY_SIZE(a)
Definition: main.h:24
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define ok(value,...)
Definition: atltest.h:57
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define args
Definition: format.c:66

Referenced by START_TEST().

◆ test_dde()

static void test_dde ( void  )
static

Definition at line 2389 of file shlexec.c.

2390 {
2391  char filename[MAX_PATH], defApplication[MAX_PATH];
2392  const dde_tests_t* test;
2393  char params[1024];
2394  INT_PTR rc;
2395  HANDLE map;
2396  char *shared_block;
2397  DWORD ddeflags;
2398 
2400 
2401  sprintf(filename, "%s\\test file.sde", tmpdir);
2402 
2403  /* Default service is application name minus path and extension */
2404  strcpy(defApplication, strrchr(argv0, '\\')+1);
2405  *strchr(defApplication, '.') = 0;
2406 
2408  4096, "winetest_shlexec_dde_map");
2409  shared_block = MapViewOfFile(map, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 4096);
2410 
2412  test = dde_tests;
2413  while (test->command)
2414  {
2415  if (!create_test_association(".sde"))
2416  {
2417  skip("Unable to create association for '.sde'\n");
2418  return;
2419  }
2420  create_test_verb_dde("shlexec.sde", "Open", 0, test->command, test->ddeexec,
2421  test->application, test->topic, test->ifexec);
2422 
2423  if (test->application != NULL || test->topic != NULL)
2424  {
2425  strcpy(shared_block, test->application ? test->application : defApplication);
2426  strcpy(shared_block + strlen(shared_block) + 1, test->topic ? test->topic : SZDDESYS_TOPIC);
2427  }
2428  else
2429  {
2430  shared_block[0] = '\0';
2431  shared_block[1] = '\0';
2432  }
2433  ddeExec[0] = 0;
2434 
2436  dde_ready_event = CreateEventA(NULL, TRUE, FALSE, "winetest_shlexec_dde_ready");
2437  rc = shell_execute_ex(ddeflags, NULL, filename, NULL, NULL, NULL);
2439  if (!(ddeflags & SEE_MASK_WAITFORINPUTIDLE) && rc == SE_ERR_DDEFAIL &&
2441  strcmp(winetest_platform, "windows") == 0)
2442  {
2443  /* Windows 10 does not call WaitForInputIdle() for DDE which creates
2444  * a race condition as the DDE server may not have time to start up.
2445  * When that happens the test fails with the above results and we
2446  * compensate by forcing the WaitForInputIdle() call.
2447  */
2448  trace("Adding SEE_MASK_WAITFORINPUTIDLE for Windows 10\n");
2449  ddeflags |= SEE_MASK_WAITFORINPUTIDLE;
2450  delete_test_association(".sde");
2452  continue;
2453  }
2454  okShell(32 < rc, "failed: rc=%lu err=%u\n", rc, GetLastError());
2455  if (test->ddeexec)
2457  broken(waitforinputidle_count == 0) /* Win10 race */,
2458  "WaitForInputIdle() was called %u times\n",
2460  else
2461  okShell(waitforinputidle_count == 0, "WaitForInputIdle() was called %u times for a non-DDE case\n", waitforinputidle_count);
2462 
2463  if (32 < rc)
2464  {
2465  if (test->broken)
2466  okChildIntBroken("argcA", test->expectedArgs + 3);
2467  else
2468  okChildInt("argcA", test->expectedArgs + 3);
2469 
2470  if (test->expectedArgs == 1) okChildPath("argvA3", filename);
2471 
2472  sprintf(params, test->expectedDdeExec, filename);
2473  okChildPath("ddeExec", params);
2474  }
2476 
2477  delete_test_association(".sde");
2478  test++;
2479  }
2480 
2481  UnmapViewOfFile(shared_block);
2482  CloseHandle(map);
2484 }
#define SEE_MASK_FLAG_DDEWAIT
Definition: shellapi.h:34
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#define shell_execute_ex(mask, verb, filename, parameters, directory, class)
Definition: shlexec.c:681
#define MapViewOfFile
Definition: compat.h:402
#define SEE_MASK_WAITFORINPUTIDLE
Definition: shellapi.h:56
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static DWORD WINAPI hooked_WaitForInputIdle(HANDLE process, DWORD timeout)
Definition: shlexec.c:2310
#define okChildIntBroken(key, expected)
Definition: shlexec.c:476
#define okChildInt(key, expected)
Definition: shlexec.c:467
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define test
Definition: rosglue.h:37
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
int32_t INT_PTR
Definition: typedefs.h:62
const char * filename
Definition: ioapi.h:135
#define sprintf(buf, format,...)
Definition: sprintf.c:55
GLenum const GLfloat * params
Definition: glext.h:5645
smooth NULL
Definition: ftsmooth.c:416
#define SEE_MASK_FLAG_NO_UI
Definition: shellapi.h:36
const char * winetest_platform
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:637
#define FILE_MAP_READ
Definition: compat.h:427
#define SE_ERR_DDEFAIL
Definition: shellapi.h:130
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static char tmpdir[MAX_PATH]
Definition: shlexec.c:59
#define trace
Definition: atltest.h:70
static dde_tests_t dde_tests[]
Definition: shlexec.c:2281
static void reset_association_description(void)
Definition: shlexec.c:372
#define FILE_MAP_WRITE
Definition: winbase.h:154
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: _map.h:44
static void delete_test_association(const char *extension)
Definition: shlexec.c:812
#define SZDDESYS_TOPIC
Definition: ddeml.h:47
static int waitforinputidle_count
Definition: shlexec.c:2309
static char argv0[MAX_PATH]
Definition: shlexec.c:56
#define okShell
Definition: shlexec.c:369
#define broken(x)
Definition: _sntprintf.h:21
static void create_test_verb_dde(const char *classname, const char *verb, int rawcmd, const char *cmdtail, const char *ddeexec, const char *application, const char *topic, const char *ifexec)
Definition: shlexec.c:821
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define skip(...)
Definition: atltest.h:64
#define okChildPath(key, expected)
Definition: shlexec.c:458
DWORD WINAPI WaitForInputIdle(_In_ HANDLE, _In_ DWORD)
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static void hook_WaitForInputIdle(DWORD(WINAPI *new_func)(HANDLE, DWORD))
Definition: shlexec.c:2328
#define CHILD_DDE_TIMEOUT
Definition: shlexec.c:153
static HANDLE dde_ready_event
Definition: shlexec.c:64
#define UnmapViewOfFile
Definition: compat.h:403
static BOOL create_test_association(const char *extension)
Definition: shlexec.c:719
HANDLE NTAPI CreateFileMappingA(IN HANDLE hFile, IN LPSECURITY_ATTRIBUTES lpFileMappingAttributes, IN DWORD flProtect, IN DWORD dwMaximumSizeHigh, IN DWORD dwMaximumSizeLow, IN LPCSTR lpName)
Definition: filemap.c:23
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 GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum map
Definition: glfuncs.h:262
#define PAGE_READWRITE
Definition: nt_native.h:1304
static char ddeExec[MAX_PATH]
Definition: shlexec.c:156

Referenced by START_TEST().

◆ test_dde_default_app()

static void test_dde_default_app ( void  )
static

Definition at line 2556 of file shlexec.c.

2557 {
2558  char filename[MAX_PATH];
2559  HSZ hszApplication;
2562  char params[1024];
2563  DWORD threadId;
2564  MSG msg;
2565  INT_PTR rc;
2566  int which = 0;
2567  HDDEDATA ret;
2568  BOOL b;
2569 
2571  ddeInst = 0;
2574  ok(rc == DMLERR_NO_ERROR, "got %lx\n", rc);
2575 
2576  sprintf(filename, "%s\\test file.sde", tmpdir);
2577 
2578  /* It is strictly not necessary to register an application name here, but wine's
2579  * DdeNameService implementation complains if 0 is passed instead of
2580  * hszApplication with DNS_FILTEROFF */
2581  hszApplication = DdeCreateStringHandleA(ddeInst, "shlexec", CP_WINANSI);
2583  ok(hszApplication && hszTopic, "got %p and %p\n", hszApplication, hszTopic);
2584  ret = DdeNameService(ddeInst, hszApplication, 0, DNS_REGISTER | DNS_FILTEROFF);
2585  ok(ret != 0, "got %p\n", ret);
2586 
2588  while (test->command)
2589  {
2590  HANDLE thread;
2591 
2592  if (!create_test_association(".sde"))
2593  {
2594  skip("Unable to create association for '.sde'\n");
2595  return;
2596  }
2597  sprintf(params, test->command, tmpdir);
2598  create_test_verb_dde("shlexec.sde", "Open", 1, params, "[test]", NULL,
2599  "shlexec", NULL);
2600  ddeApplication[0] = 0;
2601 
2602  /* No application will be run as we will respond to the first DDE event,
2603  * so don't wait for it */
2604  SetEvent(hEvent);
2605 
2606  thread = CreateThread(NULL, 0, ddeThread, &info, 0, &threadId);
2607  ok(thread != NULL, "got %p\n", thread);
2608  while (GetMessageA(&msg, NULL, 0, 0)) DispatchMessageA(&msg);
2609  rc = msg.wParam > 32 ? 33 : msg.wParam;
2610 
2611  /* The first two tests determine which set of results to expect.
2612  * First check the platform as only the first set of results is
2613  * acceptable for Wine.
2614  */
2615  if (strcmp(winetest_platform, "wine"))
2616  {
2617  if (test == dde_default_app_tests)
2618  {
2619  if (strcmp(ddeApplication, test->expectedDdeApplication[0]))
2620  which = 2;
2621  }
2622  else if (test == dde_default_app_tests + 1)
2623  {
2624  if (which == 0 && rc == test->rc[1])
2625  which = 1;
2626  trace("DDE result variant %d\n", which);
2627  }
2628  }
2629 
2630  todo_wine_if(test->todo & 0x1)
2631  okShell(rc==test->rc[which], "failed: rc=%lu err=%u\n",
2632  rc, GetLastError());
2633  if (rc == 33)
2634  {
2635  todo_wine_if(test->todo & 0x2)
2636  ok(!strcmp(ddeApplication, test->expectedDdeApplication[which]),
2637  "Expected application '%s', got '%s'\n",
2638  test->expectedDdeApplication[which], ddeApplication);
2639  }
2641 
2642  delete_test_association(".sde");
2643  test++;
2644  }
2645 
2646  ret = DdeNameService(ddeInst, hszApplication, 0, DNS_UNREGISTER);
2647  ok(ret != 0, "got %p\n", ret);
2649  ok(b, "got %d\n", b);
2650  b = DdeFreeStringHandle(ddeInst, hszApplication);
2651  ok(b, "got %d\n", b);
2653  ok(b, "got %d\n", b);
2654 }
#define DNS_UNREGISTER
Definition: ddeml.h:153
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define CBF_FAIL_ADVISES
Definition: ddeml.h:105
static GLenum which
Definition: wgl_font.c:159
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
BOOL WINAPI GetMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define CBF_FAIL_POKES
Definition: ddeml.h:107
#define test
Definition: rosglue.h:37
static char ddeApplication[MAX_PATH]
Definition: shlexec.c:156
int32_t INT_PTR
Definition: typedefs.h:62
static HANDLE hEvent
Definition: shlexec.c:196
const char * filename
Definition: ioapi.h:135
#define DNS_REGISTER
Definition: ddeml.h:152
#define CBF_FAIL_REQUESTS
Definition: ddeml.h:108
#define sprintf(buf, format,...)
Definition: sprintf.c:55
GLenum const GLfloat * params
Definition: glext.h:5645
unsigned int BOOL
Definition: ntddk_ex.h:94
#define DMLERR_NO_ERROR
Definition: ddeml.h:242
BOOL WINAPI DdeUninitialize(DWORD)
Definition: ddemisc.c:1112
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:136
smooth NULL
Definition: ftsmooth.c:416
const char * winetest_platform
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:458
#define b
Definition: ke_i.h:79
static DWORD ddeInst
Definition: shlexec.c:154
#define todo_wine_if(is_todo)
Definition: test.h:155
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define DNS_FILTEROFF
Definition: ddeml.h:155
static DWORD CALLBACK ddeThread(LPVOID arg)
Definition: shlexec.c:2545
static char tmpdir[MAX_PATH]
Definition: shlexec.c:59
#define trace
Definition: atltest.h:70
BOOL WINAPI DdeFreeStringHandle(DWORD, HSZ)
Definition: ddemisc.c:631
static void reset_association_description(void)
Definition: shlexec.c:372
static BOOL post_quit_on_execute
Definition: shlexec.c:157
#define MAX_PATH
Definition: compat.h:26
static HDDEDATA CALLBACK ddeCb(UINT uType, UINT uFmt, HCONV hConv, HSZ hsz1, HSZ hsz2, HDDEDATA hData, ULONG_PTR dwData1, ULONG_PTR dwData2)
Definition: shlexec.c:160
unsigned long DWORD
Definition: ntddk_ex.h:95
static void delete_test_association(const char *extension)
Definition: shlexec.c:812
static HANDLE thread
Definition: service.c:33
int ret
#define okShell
Definition: shlexec.c:369
static HSZ hszTopic
Definition: shlexec.c:155
#define CP_WINANSI
Definition: ddeml.h:32
#define ok(value,...)
Definition: atltest.h:57
HDDEDATA WINAPI DdeNameService(DWORD, HSZ, HSZ, UINT)
Definition: ddeserver.c:154
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3706
static void create_test_verb_dde(const char *classname, const char *verb, int rawcmd, const char *cmdtail, const char *ddeexec, const char *application, const char *topic, const char *ifexec)
Definition: shlexec.c:821
#define skip(...)
Definition: atltest.h:64
#define msg(x)
Definition: auth_time.c:54
#define CBF_SKIP_ALLNOTIFICATIONS
Definition: ddeml.h:115
HSZ WINAPI DdeCreateStringHandleA(DWORD, LPCSTR, INT)
Definition: ddemisc.c:577
static dde_default_app_tests_t dde_default_app_tests[]
Definition: shlexec.c:2495
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static BOOL create_test_association(const char *extension)
Definition: shlexec.c:719
UINT WINAPI DdeInitializeA(LPDWORD, PFNCALLBACK, DWORD, DWORD)
Definition: ddemisc.c:1075

Referenced by START_TEST().

◆ test_directory()

static void test_directory ( void  )
static

Definition at line 2815 of file shlexec.c.

2816 {
2817  char path[MAX_PATH], curdir[MAX_PATH];
2818  char params[1024], dirpath[1024];
2819  INT_PTR rc;
2820 
2821  sprintf(path, "%s\\test2.exe", tmpdir);
2823 
2824  sprintf(params, "shlexec \"%s\" Exec", child_file);
2825 
2826  /* Test with the current directory */
2827  GetCurrentDirectoryA(sizeof(curdir), curdir);
2830  NULL, "test2.exe", params, NULL, NULL);
2831  okShell(rc > 32, "returned %lu\n", rc);
2832  okChildInt("argcA", 4);
2833  okChildString("argvA3", "Exec");
2834  todo_wine okChildPath("longPath", path);
2835  SetCurrentDirectoryA(curdir);
2836 
2838  NULL, "test2.exe", params, NULL, NULL);
2839  okShell(rc == SE_ERR_FNF, "returned %lu\n", rc);
2840 
2841  /* Explicitly specify the directory to use */
2843  NULL, "test2.exe", params, tmpdir, NULL);
2844  okShell(rc > 32, "returned %lu\n", rc);
2845  okChildInt("argcA", 4);
2846  okChildString("argvA3", "Exec");
2847  todo_wine okChildPath("longPath", path);
2848 
2849  /* Specify it through an environment variable */
2851  NULL, "test2.exe", params, "%TMPDIR%", NULL);
2852  todo_wine okShell(rc == SE_ERR_FNF, "returned %lu\n", rc);
2853 
2855  NULL, "test2.exe", params, "%TMPDIR%", NULL);
2856  okShell(rc > 32, "returned %lu\n", rc);
2857  okChildInt("argcA", 4);
2858  okChildString("argvA3", "Exec");
2859  todo_wine okChildPath("longPath", path);
2860 
2861  /* Not a colon-separated directory list */
2862  sprintf(dirpath, "%s:%s", curdir, tmpdir);
2864  NULL, "test2.exe", params, dirpath, NULL);
2865  okShell(rc == SE_ERR_FNF, "returned %lu\n", rc);
2866 }
#define shell_execute_ex(mask, verb, filename, parameters, directory, class)
Definition: shlexec.c:681
#define okChildInt(key, expected)
Definition: shlexec.c:467
BOOL WINAPI CopyFileA(IN LPCSTR lpExistingFileName, IN LPCSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:404
int32_t INT_PTR
Definition: typedefs.h:62
#define sprintf(buf, format,...)
Definition: sprintf.c:55
GLenum const GLfloat * params
Definition: glext.h:5645
smooth NULL
Definition: ftsmooth.c:416
#define SEE_MASK_FLAG_NO_UI
Definition: shellapi.h:36
#define okChildString(key, expected)
Definition: shlexec.c:390
#define SEE_MASK_NOZONECHECKS
Definition: shellapi.h:54
static char tmpdir[MAX_PATH]
Definition: shlexec.c:59
#define MAX_PATH
Definition: compat.h:26
#define SEE_MASK_DOENVSUBST
Definition: shellapi.h:35
#define todo_wine
Definition: test.h:154
BOOL WINAPI SetCurrentDirectoryA(IN LPCSTR lpPathName)
Definition: path.c:2205
static char argv0[MAX_PATH]
Definition: shlexec.c:56
#define okShell
Definition: shlexec.c:369
#define SE_ERR_FNF
Definition: shellapi.h:122
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
Definition: services.c:325
#define okChildPath(key, expected)
Definition: shlexec.c:458
static char child_file[MAX_PATH]
Definition: shlexec.c:60

Referenced by START_TEST().

◆ test_exes()

static void test_exes ( void  )
static

Definition at line 2211 of file shlexec.c.

2212 {
2213  char filename[MAX_PATH];
2214  char params[1024];
2215  INT_PTR rc;
2216 
2217  sprintf(params, "shlexec \"%s\" Exec", child_file);
2218 
2219  /* We need NOZONECHECKS on Win2003 to block a dialog */
2221  NULL, NULL);
2222  okShell(rc > 32, "returned %lu\n", rc);
2223  okChildInt("argcA", 4);
2224  okChildString("argvA3", "Exec");
2225 
2226  if (! skip_noassoc_tests)
2227  {
2228  sprintf(filename, "%s\\test file.noassoc", tmpdir);
2229  if (CopyFileA(argv0, filename, FALSE))
2230  {
2232  todo_wine {
2233  okShell(rc==SE_ERR_NOASSOC, "returned %lu\n", rc);
2234  }
2235  }
2236  }
2237  else
2238  {
2239  win_skip("Skipping shellexecute of file with unassociated extension\n");
2240  }
2241 
2242  /* test combining executable and parameters */
2243  sprintf(filename, "%s shlexec \"%s\" Exec", argv0, child_file);
2244  rc = shell_execute(NULL, filename, NULL, NULL);
2245  okShell(rc == SE_ERR_FNF, "returned %lu\n", rc);
2246 
2247  sprintf(filename, "\"%s\" shlexec \"%s\" Exec", argv0, child_file);
2248  rc = shell_execute(NULL, filename, NULL, NULL);
2249  okShell(rc == SE_ERR_FNF, "returned %lu\n", rc);
2250 
2251  /* A verb, even if invalid, overrides the normal handling of executables */
2253  "notaverb", argv0, NULL, NULL, NULL);
2254  todo_wine okShell(rc == SE_ERR_NOASSOC, "returned %lu\n", rc);
2255 
2256  if (!skip_shlexec_tests)
2257  {
2258  /* A class overrides the normal handling of executables too */
2259  /* FIXME SEE_MASK_FLAG_NO_UI is only needed due to Wine's bug */
2261  NULL, argv0, NULL, NULL, ".shlexec");
2262  todo_wine okShell(rc > 32, "returned %lu\n", rc);
2263  okChildInt("argcA", 5);
2264  todo_wine okChildString("argvA3", "Open");
2265  todo_wine okChildPath("argvA4", argv0);
2266  }
2267 }
#define shell_execute_ex(mask, verb, filename, parameters, directory, class)
Definition: shlexec.c:681
#define okChildInt(key, expected)
Definition: shlexec.c:467
BOOL WINAPI CopyFileA(IN LPCSTR lpExistingFileName, IN LPCSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:404
#define shell_execute(verb, filename, parameters, directory)
Definition: shlexec.c:576
int32_t INT_PTR
Definition: typedefs.h:62
const char * filename
Definition: ioapi.h:135
#define sprintf(buf, format,...)
Definition: sprintf.c:55
GLenum const GLfloat * params
Definition: glext.h:5645
smooth NULL
Definition: ftsmooth.c:416
#define SEE_MASK_FLAG_NO_UI
Definition: shellapi.h:36
#define okChildString(key, expected)
Definition: shlexec.c:390
#define SEE_MASK_NOZONECHECKS
Definition: shellapi.h:54
#define SEE_MASK_CLASSNAME
Definition: shellapi.h:25
static char tmpdir[MAX_PATH]
Definition: shlexec.c:59
#define MAX_PATH
Definition: compat.h:26
#define todo_wine
Definition: test.h:154
static char argv0[MAX_PATH]
Definition: shlexec.c:56
#define okShell
Definition: shlexec.c:369
#define SE_ERR_FNF
Definition: shellapi.h:122
#define todo_wait
Definition: shlexec.c:499
#define okChildPath(key, expected)
Definition: shlexec.c:458
static BOOL skip_noassoc_tests
Definition: shlexec.c:63
#define SE_ERR_NOASSOC
Definition: shellapi.h:132
#define win_skip
Definition: test.h:141
static BOOL skip_shlexec_tests
Definition: shlexec.c:62
static char child_file[MAX_PATH]
Definition: shlexec.c:60

Referenced by START_TEST().

◆ test_filename()

static void test_filename ( void  )
static

Definition at line 1610 of file shlexec.c.

1611 {
1612  char filename[MAX_PATH];
1613  const filename_tests_t* test;
1614  char* c;
1615  INT_PTR rc;
1616 
1617  if (skip_shlexec_tests)
1618  {
1619  skip("No ShellExecute/filename tests due to lack of .shlexec association\n");
1620  return;
1621  }
1622 
1624  while (test->basename)
1625  {
1626  BOOL quotedfile = FALSE;
1627 
1628  if (skip_noassoc_tests && test->rc == SE_ERR_NOASSOC)
1629  {
1630  win_skip("Skipping shellexecute of file with unassociated extension\n");
1631  test++;
1632  continue;
1633  }
1634 
1635  sprintf(filename, test->basename, tmpdir);
1636  if (strchr(filename, '/'))
1637  {
1638  c=filename;
1639  while (*c)
1640  {
1641  if (*c=='\\')
1642  *c='/';
1643  c++;
1644  }
1645  }
1646  if ((test->todo & 0x40)==0)
1647  {
1648  rc=shell_execute(test->verb, filename, NULL, NULL);
1649  }
1650  else
1651  {
1652  char quoted[MAX_PATH + 2];
1653 
1654  quotedfile = TRUE;
1655  sprintf(quoted, "\"%s\"", filename);
1656  rc=shell_execute(test->verb, quoted, NULL, NULL);
1657  }
1658  if (rc > 32)
1659  rc=33;
1660  okShell(rc==test->rc ||
1661  broken(quotedfile && rc == SE_ERR_FNF), /* NT4 */
1662  "failed: rc=%ld err=%u\n", rc, GetLastError());
1663  if (rc == 33)
1664  {
1665  const char* verb;
1666  todo_wine_if(test->todo & 0x2)
1667  okChildInt("argcA", 5);
1668  verb=(test->verb ? test->verb : "Open");
1669  todo_wine_if(test->todo & 0x4)
1670  okChildString("argvA3", verb);
1671  todo_wine_if(test->todo & 0x8)
1672  okChildPath("argvA4", filename);
1673  }
1674  test++;
1675  }
1676 
1678  while (test->basename)
1679  {
1680  sprintf(filename, test->basename, tmpdir);
1681  rc=shell_execute(test->verb, filename, NULL, NULL);
1682  if (rc > 32)
1683  rc=33;
1684  todo_wine_if(test->todo & 0x1)
1685  okShell(rc==test->rc, "failed: rc=%ld err=%u\n", rc, GetLastError());
1686  if (rc==0)
1687  {
1688  int count;
1689  const char* verb;
1690  char* str;
1691 
1692  verb=(test->verb ? test->verb : "Open");
1693  todo_wine_if(test->todo & 0x4)
1694  okChildString("argvA3", verb);
1695 
1696  count=4;
1697  str=filename;
1698  while (1)
1699  {
1700  char attrib[18];
1701  char* space;
1702  space=strchr(str, ' ');
1703  if (space)
1704  *space='\0';
1705  sprintf(attrib, "argvA%d", count);
1706  todo_wine_if(test->todo & 0x8)
1707  okChildPath(attrib, str);
1708  count++;
1709  if (!space)
1710  break;
1711  str=space+1;
1712  }
1713  todo_wine_if(test->todo & 0x2)
1714  okChildInt("argcA", count);
1715  }
1716  test++;
1717  }
1718 
1719  if (dllver.dwMajorVersion != 0)
1720  {
1721  /* The more recent versions of shell32.dll accept quoted filenames
1722  * while older ones (e.g. 4.00) don't. Still we want to test this
1723  * because IE 6 depends on the new behavior.
1724  * One day we may need to check the exact version of the dll but for
1725  * now making sure DllGetVersion() is present is sufficient.
1726  */
1727  sprintf(filename, "\"%s\\test file.shlexec\"", tmpdir);
1729  okShell(rc > 32, "failed: rc=%ld err=%u\n", rc, GetLastError());
1730  okChildInt("argcA", 5);
1731  okChildString("argvA3", "Open");
1732  sprintf(filename, "%s\\test file.shlexec", tmpdir);
1733  okChildPath("argvA4", filename);
1734  }
1735 
1736  sprintf(filename, "\"%s\\test file.sha\"", tmpdir);
1738  todo_wine okShell(rc > 32, "failed: rc=%ld err=%u\n", rc, GetLastError());
1739  okChildInt("argcA", 5);
1740  todo_wine okChildString("argvA3", "averb");
1741  sprintf(filename, "%s\\test file.sha", tmpdir);
1742  todo_wine okChildPath("argvA4", filename);
1743 }
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define okChildInt(key, expected)
Definition: shlexec.c:467
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define test
Definition: rosglue.h:37
#define shell_execute(verb, filename, parameters, directory)
Definition: shlexec.c:576
int32_t INT_PTR
Definition: typedefs.h:62
const char * filename
Definition: ioapi.h:135
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static DLLVERSIONINFO dllver
Definition: shlexec.c:61
unsigned int BOOL
Definition: ntddk_ex.h:94
static filename_tests_t noquotes_tests[]
Definition: shlexec.c:1089
static filename_tests_t filename_tests[]
Definition: shlexec.c:1046
const WCHAR * str
DWORD dwMajorVersion
Definition: shlwapi.h:1955
smooth NULL
Definition: ftsmooth.c:416
#define okChildString(key, expected)
Definition: shlexec.c:390
#define todo_wine_if(is_todo)
Definition: test.h:155
static char tmpdir[MAX_PATH]
Definition: shlexec.c:59
#define MAX_PATH
Definition: compat.h:26
const GLubyte * c
Definition: glext.h:8905
#define todo_wine
Definition: test.h:154
#define okShell
Definition: shlexec.c:369
#define broken(x)
Definition: _sntprintf.h:21
#define SE_ERR_FNF
Definition: shellapi.h:122
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3706
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define skip(...)
Definition: atltest.h:64
#define okChildPath(key, expected)
Definition: shlexec.c:458
#define c
Definition: ke_i.h:80
static BOOL skip_noassoc_tests
Definition: shlexec.c:63
#define SE_ERR_NOASSOC
Definition: shellapi.h:132
#define win_skip
Definition: test.h:141
static BOOL skip_shlexec_tests
Definition: shlexec.c:62

Referenced by START_TEST().

◆ test_fileurls()

static void test_fileurls ( void  )
static

Definition at line 1793 of file shlexec.c.

1794 {
1795  char filename[MAX_PATH], fileurl[MAX_PATH], longtmpdir[MAX_PATH];
1796  char command[MAX_PATH];
1797  const fileurl_tests_t* test;
1798  char *s;
1799  INT_PTR rc;
1800 
1801  if (skip_shlexec_tests)
1802  {
1803  skip("No file URL tests due to lack of .shlexec association\n");
1804  return;
1805  }
1806 
1808  "file:///nosuchfile.shlexec", NULL, NULL, NULL);
1809  if (rc > 32)
1810  {
1811  win_skip("shell32 is too old (likely < 4.72). Skipping the file URL tests\n");
1812  return;
1813  }
1814 
1815  get_long_path_name(tmpdir, longtmpdir, ARRAY_SIZE(longtmpdir));
1816  SetEnvironmentVariableA("urlprefix", "file:///");
1817 
1819  while (test->basename)
1820  {
1821  /* Build the file URL */
1822  sprintf(filename, test->basename, longtmpdir);
1823  strcpy(fileurl, test->urlprefix);
1824  strcat(fileurl, filename);
1825  s = fileurl + strlen(test->urlprefix);
1826  while (*s)
1827  {
1828  if (!(test->flags & USE_COLON) && *s == ':')
1829  *s = '|';
1830  else if (!(test->flags & USE_BSLASH) && *s == '\\')
1831  *s = '/';
1832  s++;
1833  }
1834 
1835  /* Test it first with FindExecutable() */
1836  rc = (INT_PTR)FindExecutableA(fileurl, NULL, command);
1837  ok(rc == SE_ERR_FNF, "FindExecutable(%s) failed: bad rc=%lu\n", fileurl, rc);
1838 
1839  /* Then ShellExecute() */
1840  if ((test->todo & 0x10) == 0)
1841  rc = shell_execute(NULL, fileurl, NULL, NULL);
1842  else todo_wait
1843  rc = shell_execute(NULL, fileurl, NULL, NULL);
1844  if (bad_shellexecute)
1845  {
1846  win_skip("shell32 is too old (likely 4.72). Skipping the file URL tests\n");
1847  break;
1848  }
1849  if (test->flags & URL_SUCCESS)
1850  {
1851  todo_wine_if(test->todo & 0x1)
1852  okShell(rc > 32, "failed: bad rc=%lu\n", rc);
1853  }
1854  else
1855  {
1856  todo_wine_if(test->todo & 0x1)
1857  okShell(rc == SE_ERR_FNF || rc == SE_ERR_PNF ||
1858  broken(rc == SE_ERR_ACCESSDENIED) /* win2000 */,
1859  "failed: bad rc=%lu\n", rc);
1860  }
1861  if (rc == 33)
1862  {
1863  todo_wine_if(test->todo & 0x2)
1864  okChildInt("argcA", 5);
1865  todo_wine_if(test->todo & 0x4)
1866  okChildString("argvA3", "Open");
1867  todo_wine_if(test->todo & 0x8)
1868  okChildPath("argvA4", filename);
1869  }
1870  test++;
1871  }
1872 
1873  SetEnvironmentVariableA("urlprefix", NULL);
1874 }
#define USE_COLON
Definition: shlexec.c:1754
#define shell_execute_ex(mask, verb, filename, parameters, directory, class)
Definition: shlexec.c:681
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static fileurl_tests_t fileurl_tests[]
Definition: shlexec.c:1757
#define okChildInt(key, expected)
Definition: shlexec.c:467
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
#define SE_ERR_ACCESSDENIED
Definition: shellapi.h:124
#define test
Definition: rosglue.h:37
#define shell_execute(verb, filename, parameters, directory)
Definition: shlexec.c:576
int32_t INT_PTR
Definition: typedefs.h:62
const char * filename
Definition: ioapi.h:135
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define URL_SUCCESS
Definition: shlexec.c:1753
smooth NULL
Definition: ftsmooth.c:416
#define SEE_MASK_FLAG_NO_UI
Definition: shellapi.h:36
#define okChildString(key, expected)
Definition: shlexec.c:390
#define todo_wine_if(is_todo)
Definition: test.h:155
static char tmpdir[MAX_PATH]
Definition: shlexec.c:59
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableA(IN LPCSTR lpName, IN LPCSTR lpValue)
Definition: environ.c:218
#define MAX_PATH
Definition: compat.h:26
#define USE_BSLASH
Definition: shlexec.c:1755
static DWORD get_long_path_name(const char *shortpath, char *longpath, DWORD longlen)
Definition: shlexec.c:937
HINSTANCE WINAPI FindExecutableA(LPCSTR lpFile, LPCSTR lpDirectory, LPSTR lpResult)
Definition: shlexec.cpp:1169
GLdouble s
Definition: gl.h:2039
#define okShell
Definition: shlexec.c:369
#define broken(x)
Definition: _sntprintf.h:21
#define SE_ERR_PNF
Definition: shellapi.h:123
#define SE_ERR_FNF
Definition: shellapi.h:122
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3706
#define skip(...)
Definition: atltest.h:64
#define todo_wait
Definition: shlexec.c:499
#define okChildPath(key, expected)
Definition: shlexec.c:458
static int bad_shellexecute
Definition: shlexec.c:501
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define win_skip
Definition: test.h:141
static BOOL skip_shlexec_tests
Definition: shlexec.c:62

Referenced by START_TEST().

◆ test_find_executable()

static void test_find_executable ( void  )
static

Definition at line 1970 of file shlexec.c.

1971 {
1972  char notepad_path[MAX_PATH];
1973  char filename[MAX_PATH];
1974  char command[MAX_PATH];
1975  const filename_tests_t* test;
1976  INT_PTR rc;
1977 
1978  if (!create_test_association(".sfe"))
1979  {
1980  skip("Unable to create association for '.sfe'\n");
1981  return;
1982  }
1983  create_test_verb("shlexec.sfe", "Open", 1, "%1");
1984 
1985  /* Don't test FindExecutable(..., NULL), it always crashes */
1986 
1987  strcpy(command, "your word");
1988  if (0) /* Can crash on Vista! */
1989  {
1991  ok(rc == SE_ERR_FNF || rc > 32 /* nt4 */, "FindExecutable(NULL) returned %ld\n", rc);
1992  ok(strcmp(command, "your word") != 0, "FindExecutable(NULL) returned command=[%s]\n", command);
1993  }
1994 
1995  GetSystemDirectoryA( notepad_path, MAX_PATH );
1996  strcat( notepad_path, "\\notepad.exe" );
1997 
1998  /* Search for something that should be in the system-wide search path (no default directory) */
1999  strcpy(command, "your word");
2000  rc=(INT_PTR)FindExecutableA("notepad.exe", NULL, command);
2001  ok(rc > 32, "FindExecutable(%s) returned %ld\n", "notepad.exe", rc);
2002  ok(strcasecmp(command, notepad_path) == 0, "FindExecutable(%s) returned command=[%s]\n", "notepad.exe", command);
2003 
2004  /* Search for something that should be in the system-wide search path (with default directory) */
2005  strcpy(command, "your word");
2006  rc=(INT_PTR)FindExecutableA("notepad.exe", tmpdir, command);
2007  ok(rc > 32, "FindExecutable(%s) returned %ld\n", "notepad.exe", rc);
2008  ok(strcasecmp(command, notepad_path) == 0, "FindExecutable(%s) returned command=[%s]\n", "notepad.exe", command);
2009 
2010  strcpy(command, "your word");
2012  ok(rc == SE_ERR_NOASSOC /* >= win2000 */ || rc > 32 /* win98, nt4 */, "FindExecutable(NULL) returned %ld\n", rc);
2013  ok(strcmp(command, "your word") != 0, "FindExecutable(NULL) returned command=[%s]\n", command);
2014 
2015  sprintf(filename, "%s\\test file.sfe", tmpdir);
2017  ok(rc > 32, "FindExecutable(%s) returned %ld\n", filename, rc);
2018  /* Depending on the platform, command could be '%1' or 'test file.sfe' */
2019 
2020  rc=(INT_PTR)FindExecutableA("test file.sfe", tmpdir, command);
2021  ok(rc > 32, "FindExecutable(%s) returned %ld\n", filename, rc);
2022 
2023  rc=(INT_PTR)FindExecutableA("test file.sfe", NULL, command);
2024  ok(rc == SE_ERR_FNF, "FindExecutable(%s) returned %ld\n", filename, rc);
2025 
2026  delete_test_association(".sfe");
2027 
2028  if (!create_test_association(".shl"))
2029  {
2030  skip("Unable to create association for '.shl'\n");
2031  return;
2032  }
2033  create_test_verb("shlexec.shl", "Open", 0, "Open");
2034 
2035  sprintf(filename, "%s\\test file.shl", tmpdir);
2037  ok(rc == SE_ERR_FNF /* NT4 */ || rc > 32, "FindExecutable(%s) returned %ld\n", filename, rc);
2038 
2039  sprintf(filename, "%s\\test file.shlfoo", tmpdir);
2041 
2042  delete_test_association(".shl");
2043 
2044  if (rc > 32)
2045  {
2046  /* On Windows XP and 2003 FindExecutable() is completely broken.
2047  * Probably what it does is convert the filename to 8.3 format,
2048  * which as a side effect converts the '.shlfoo' extension to '.shl',
2049  * and then tries to find an association for '.shl'. This means it
2050  * will normally fail on most extensions with more than 3 characters,
2051  * like '.mpeg', etc.
2052  * Also it means we cannot do any other test.
2053  */
2054  win_skip("FindExecutable() is broken -> not running 4+ character extension tests\n");
2055  return;
2056  }
2057 
2058  if (skip_shlexec_tests)
2059  {
2060  skip("No FindExecutable/filename tests due to lack of .shlexec association\n");
2061  return;
2062  }
2063 
2065  while (test->basename)
2066  {
2067  sprintf(filename, test->basename, tmpdir);
2068  if (strchr(filename, '/'))
2069  {
2070  char* c;
2071  c=filename;
2072  while (*c)
2073  {
2074  if (*c=='\\')
2075  *c='/';
2076  c++;
2077  }
2078  }
2079  /* Win98 does not '\0'-terminate command! */
2080  memset(command, '\0', sizeof(command));
2082  if (rc > 32)
2083  rc=33;
2084  todo_wine_if(test->todo & 0x10)
2085  ok(rc==test->rc, "FindExecutable(%s) failed: rc=%ld\n", filename, rc);
2086  if (rc > 32)
2087  {
2088  BOOL equal;
2089  equal=strcmp(command, argv0) == 0 ||
2090  /* NT4 returns an extra 0x8 character! */
2091  (strlen(command) == strlen(argv0)+1 && strncmp(command, argv0, strlen(argv0)) == 0);
2092  todo_wine_if(test->todo & 0x20)
2093  ok(equal, "FindExecutable(%s) returned command='%s' instead of '%s'\n",
2094  filename, command, argv0);
2095  }
2096  test++;
2097  }
2098 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
#define strcasecmp
Definition: fake.h:9
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define equal(x, y)
Definition: reader.cc:56
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2282
#define test
Definition: rosglue.h:37
int32_t INT_PTR
Definition: typedefs.h:62
const char * filename
Definition: ioapi.h:135
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static void create_test_verb(const char *classname, const char *verb, int rawcmd, const char *cmdtail)
Definition: shlexec.c:922
unsigned int BOOL
Definition: ntddk_ex.h:94
static filename_tests_t filename_tests[]
Definition: shlexec.c:1046
smooth NULL
Definition: ftsmooth.c:416
#define todo_wine_if(is_todo)
Definition: test.h:155
static char tmpdir[MAX_PATH]
Definition: shlexec.c:59
#define MAX_PATH
Definition: compat.h:26
const GLubyte * c
Definition: glext.h:8905
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
static void delete_test_association(const char *extension)
Definition: shlexec.c:812
HINSTANCE WINAPI FindExecutableA(LPCSTR lpFile, LPCSTR lpDirectory, LPSTR lpResult)
Definition: shlexec.cpp:1169
static char argv0[MAX_PATH]
Definition: shlexec.c:56
#define SE_ERR_FNF
Definition: shellapi.h:122
#define ok(value,...)
Definition: atltest.h:57
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define skip(...)
Definition: atltest.h:64
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define c
Definition: ke_i.h:80
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define SE_ERR_NOASSOC
Definition: shellapi.h:132
#define memset(x, y, z)
Definition: compat.h:39
static BOOL create_test_association(const char *extension)
Definition: shlexec.c:719
#define win_skip
Definition: test.h:141
static BOOL skip_shlexec_tests
Definition: shlexec.c:62

Referenced by START_TEST().

◆ test_lnks()

static void test_lnks ( void  )
static

Definition at line 2117 of file shlexec.c.

2118 {
2119  char filename[MAX_PATH];
2120  char params[MAX_PATH];
2121  const filename_tests_t* test;
2122  INT_PTR rc;
2123 
2124  if (skip_shlexec_tests)
2125  skip("No FindExecutable/filename tests due to lack of .shlexec association\n");
2126  else
2127  {
2128  /* Should open through our association */
2129  sprintf(filename, "%s\\test_shortcut_shlexec.lnk", tmpdir);
2131  okShell(rc > 32, "failed: rc=%lu err=%u\n", rc, GetLastError());
2132  okChildInt("argcA", 5);
2133  okChildString("argvA3", "Open");
2134  sprintf(params, "%s\\test file.shlexec", tmpdir);
2136  okChildPath("argvA4", filename);
2137 
2138  rc=shell_execute_ex(SEE_MASK_NOZONECHECKS|SEE_MASK_DOENVSUBST, NULL, "%TMPDIR%\\test_shortcut_shlexec.lnk", NULL, NULL, NULL);
2139  okShell(rc > 32, "failed: rc=%lu err=%u\n", rc, GetLastError());
2140  okChildInt("argcA", 5);
2141  okChildString("argvA3", "Open");
2142  sprintf(params, "%s\\test file.shlexec", tmpdir);
2144  okChildPath("argvA4", filename);
2145  }
2146 
2147  /* Should just run our executable */
2148  sprintf(filename, "%s\\test_shortcut_exe.lnk", tmpdir);
2150  okShell(rc > 32, "failed: rc=%lu err=%u\n", rc, GetLastError());
2151  okChildInt("argcA", 4);
2152  okChildString("argvA3", "Lnk");
2153 
2154  if (!skip_shlexec_tests)
2155  {
2156  /* An explicit class overrides lnk's ContextMenuHandler */
2158  okShell(rc > 32, "failed: rc=%lu err=%u\n", rc, GetLastError());
2159  okChildInt("argcA", 5);
2160  okChildString("argvA3", "Open");
2161  okChildPath("argvA4", filename);
2162  }
2163 
2164  if (dllver.dwMajorVersion>=6)
2165  {
2166  char* c;
2167  /* Recent versions of shell32.dll accept '/'s in shortcut paths.
2168  * Older versions don't or are quite buggy in this regard.
2169  */
2170  sprintf(filename, "%s\\test_shortcut_exe.lnk", tmpdir);
2171  c=filename;
2172  while (*c)
2173  {
2174  if (*c=='\\')
2175  *c='/';
2176  c++;
2177  }
2179  okShell(rc > 32, "failed: rc=%lu err=%u\n", rc, GetLastError());
2180  okChildInt("argcA", 4);
2181  okChildString("argvA3", "Lnk");
2182  }
2183 
2184  sprintf(filename, "%s\\test_shortcut_exe.lnk", tmpdir);
2185  test=lnk_tests;
2186  while (test->basename)
2187  {
2188  params[0]='\"';
2189  sprintf(params+1, test->basename, tmpdir);
2190  strcat(params,"\"");
2192  NULL, NULL);
2193  if (rc > 32)
2194  rc=33;
2195  todo_wine_if(test->todo & 0x1)
2196  okShell(rc==test->rc, "failed: rc=%lu err=%u\n", rc, GetLastError());
2197  if (rc==0)
2198  {
2199  todo_wine_if(test->todo & 0x2)
2200  okChildInt("argcA", 5);
2201  todo_wine_if(test->todo & 0x4)
2202  okChildString("argvA3", "Lnk");
2203  sprintf(params, test->basename, tmpdir);
2204  okChildPath("argvA4", params);
2205  }
2206  test++;
2207  }
2208 }
#define shell_execute_ex(mask, verb, filename, parameters, directory, class)
Definition: shlexec.c:681
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
#define okChildInt(key, expected)
Definition: shlexec.c:467
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define test
Definition: rosglue.h:37
int32_t INT_PTR
Definition: typedefs.h:62
const char * filename
Definition: ioapi.h:135
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static DLLVERSIONINFO dllver
Definition: shlexec.c:61
GLenum const GLfloat * params
Definition: glext.h:5645
DWORD dwMajorVersion
Definition: shlwapi.h:1955
smooth NULL
Definition: ftsmooth.c:416
#define okChildString(key, expected)
Definition: shlexec.c:390
#define todo_wine_if(is_todo)
Definition: test.h:155
#define SEE_MASK_NOZONECHECKS
Definition: shellapi.h:54
#define SEE_MASK_CLASSNAME
Definition: shellapi.h:25
static char tmpdir[MAX_PATH]
Definition: shlexec.c:59
#define MAX_PATH
Definition: compat.h:26
#define SEE_MASK_DOENVSUBST
Definition: shellapi.h:35
const GLubyte * c
Definition: glext.h:8905
static DWORD get_long_path_name(const char *shortpath, char *longpath, DWORD longlen)
Definition: shlexec.c:937
#define okShell
Definition: shlexec.c:369
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3706
#define skip(...)
Definition: atltest.h:64
#define okChildPath(key, expected)
Definition: shlexec.c:458
#define c
Definition: ke_i.h:80
static filename_tests_t lnk_tests[]
Definition: shlexec.c:2101
static BOOL skip_shlexec_tests
Definition: shlexec.c:62

Referenced by START_TEST().

◆ test_lpFile_parsed()

static void test_lpFile_parsed ( void  )
static

Definition at line 1099 of file shlexec.c.

1100 {
1101  char fileA[MAX_PATH];
1102  INT_PTR rc;
1103 
1104  if (skip_shlexec_tests)
1105  {
1106  skip("No filename parsing tests due to lack of .shlexec association\n");
1107  return;
1108  }
1109 
1110  /* existing "drawback_file.noassoc" prevents finding "drawback_file.noassoc foo.shlexec" on wine */
1111  sprintf(fileA, "%s\\drawback_file.noassoc foo.shlexec", tmpdir);
1112  rc=shell_execute(NULL, fileA, NULL, NULL);
1113  okShell(rc > 32, "failed: rc=%lu\n", rc);
1114 
1115  /* if quoted, existing "drawback_file.noassoc" not prevents finding "drawback_file.noassoc foo.shlexec" on wine */
1116  sprintf(fileA, "\"%s\\drawback_file.noassoc foo.shlexec\"", tmpdir);
1117  rc=shell_execute(NULL, fileA, NULL, NULL);
1118  okShell(rc > 32 || broken(rc == SE_ERR_FNF) /* Win95/NT4 */,
1119  "failed: rc=%lu\n", rc);
1120 
1121  /* error should be SE_ERR_FNF, not SE_ERR_NOASSOC */
1122  sprintf(fileA, "\"%s\\drawback_file.noassoc\" foo.shlexec", tmpdir);
1123  rc=shell_execute(NULL, fileA, NULL, NULL);
1124  okShell(rc == SE_ERR_FNF, "returned %lu\n", rc);
1125 
1126  /* ""command"" not works on wine (and real win9x and w2k) */
1127  sprintf(fileA,