ReactOS  0.4.14-dev-1332-g6db3d88
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 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 WINAPIV 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

◆ CHILD_DDE_TIMEOUT

#define CHILD_DDE_TIMEOUT   2500

Definition at line 146 of file shlexec.c.

◆ DDE_DEFAULT_APP_VARIANTS

#define DDE_DEFAULT_APP_VARIANTS   3

Definition at line 2479 of file shlexec.c.

◆ okChildInt

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

Definition at line 460 of file shlexec.c.

◆ okChildIntBroken

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

Definition at line 469 of file shlexec.c.

◆ okChildPath

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

Definition at line 451 of file shlexec.c.

◆ okChildString

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

Definition at line 383 of file shlexec.c.

◆ okChildStringBroken

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

Definition at line 384 of file shlexec.c.

◆ okShell

#define okShell   okShell_(__FILE__, __LINE__)

Definition at line 362 of file shlexec.c.

◆ okShell_

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

Definition at line 361 of file shlexec.c.

◆ shell_execute

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

Definition at line 569 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 674 of file shlexec.c.

◆ todo_wait

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

Definition at line 492 of file shlexec.c.

◆ URL_SUCCESS

#define URL_SUCCESS   0x1

Definition at line 1746 of file shlexec.c.

◆ USE_BSLASH

#define USE_BSLASH   0x4

Definition at line 1748 of file shlexec.c.

◆ USE_COLON

#define USE_COLON   0x2

Definition at line 1747 of file shlexec.c.

Function Documentation

◆ childTimeout()

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

Definition at line 201 of file shlexec.c.

202 {
203  trace("childTimeout called\n");
204 
205  PostQuitMessage(0);
206 }
#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 2780 of file shlexec.c.

2781 {
2782  char filename[MAX_PATH];
2783  const char* const * testfile;
2784 
2785  /* Delete the test files */
2786  testfile=testfiles;
2787  while (*testfile)
2788  {
2789  sprintf(filename, *testfile, tmpdir);
2790  /* Make sure we can delete the files ('test file.noassoc' is read-only now) */
2793  testfile++;
2794  }
2797 
2798  /* Delete the test association */
2799  delete_test_association(".shlexec");
2800  delete_test_association(".sha");
2801  delete_test_class("shlproto");
2802 
2804 
2805  CoUninitialize();
2806 }
#define CloseHandle
Definition: compat.h:406
static void delete_test_class(const char *classname)
Definition: shlexec.c:800
static HANDLE hEvent
Definition: shlexec.c:189
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:52
#define MAX_PATH
Definition: compat.h:26
static void delete_test_association(const char *extension)
Definition: shlexec.c:805
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
static const char * testfiles[]
Definition: shlexec.c:1005
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714
static char child_file[MAX_PATH]
Definition: shlexec.c:53

Referenced by START_TEST().

◆ create_test_association()

static BOOL create_test_association ( const char extension)
static

Definition at line 712 of file shlexec.c.

713 {
714  HKEY hkey;
715  char class[MAX_PATH];
716  LONG rc;
717 
718  sprintf(class, "shlexec%s", extension);
719  rc=RegCreateKeyExA(HKEY_CLASSES_ROOT, extension, 0, NULL, 0, KEY_SET_VALUE,
720  NULL, &hkey, NULL);
721  ok(rc == ERROR_SUCCESS || rc == ERROR_ACCESS_DENIED,
722  "could not create association %s (rc=%d)\n", class, rc);
723  if (rc != ERROR_SUCCESS)
724  return FALSE;
725 
726  rc=RegSetValueExA(hkey, NULL, 0, REG_SZ, (LPBYTE) class, strlen(class)+1);
727  ok(rc==ERROR_SUCCESS, "RegSetValueEx '%s' failed, expected ERROR_SUCCESS, got %d\n", class, rc);
728  CloseHandle(hkey);
729 
730  return create_test_class(class, FALSE);
731 }
#define CloseHandle
Definition: compat.h:406
#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:684
#define sprintf(buf, format,...)
Definition: sprintf.c:55
unsigned char * LPBYTE
Definition: typedefs.h:53
#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 684 of file shlexec.c.

685 {
686  HKEY hkey, hkey_shell;
687  LONG rc;
688 
689  rc = RegCreateKeyExA(HKEY_CLASSES_ROOT, class, 0, NULL, 0,
691  &hkey, NULL);
692  ok(rc == ERROR_SUCCESS || rc == ERROR_ACCESS_DENIED,
693  "could not create class %s (rc=%d)\n", class, rc);
694  if (rc != ERROR_SUCCESS)
695  return FALSE;
696 
697  if (protocol)
698  {
699  rc = RegSetValueExA(hkey, "URL Protocol", 0, REG_SZ, (LPBYTE)"", 1);
700  ok(rc == ERROR_SUCCESS, "RegSetValueEx '%s' failed, expected ERROR_SUCCESS, got %d\n", class, rc);
701  }
702 
703  rc = RegCreateKeyExA(hkey, "shell", 0, NULL, 0,
704  KEY_CREATE_SUB_KEY, NULL, &hkey_shell, NULL);
705  ok(rc == ERROR_SUCCESS, "RegCreateKeyEx 'shell' failed, expected ERROR_SUCCESS, got %d\n", rc);
706 
707  CloseHandle(hkey);
708  CloseHandle(hkey_shell);
709  return TRUE;
710 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
unsigned char * LPBYTE
Definition: typedefs.h:53
#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 915 of file shlexec.c.

917 {
918  create_test_verb_dde(classname, verb, rawcmd, cmdtail, NULL, NULL,
919  NULL, NULL);
921 }
WCHAR classname[128]
Definition: startup.c:15
smooth NULL
Definition: ftsmooth.c:416
static void reset_association_description(void)
Definition: shlexec.c:365
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:814

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 814 of file shlexec.c.

818 {
819  HKEY hkey_shell, hkey_verb, hkey_cmd;
820  char shell[MAX_PATH];
821  char* cmd;
822  LONG rc;
823 
824  strcpy(assoc_desc, " Assoc ");
825  strcat_param(assoc_desc, "class", classname);
826  strcat_param(assoc_desc, "verb", verb);
827  sprintf(shell, "%d", rawcmd);
828  strcat_param(assoc_desc, "rawcmd", shell);
829  strcat_param(assoc_desc, "cmdtail", cmdtail);
830  strcat_param(assoc_desc, "ddeexec", ddeexec);
831  strcat_param(assoc_desc, "app", application);
832  strcat_param(assoc_desc, "topic", topic);
833  strcat_param(assoc_desc, "ifexec", ifexec);
834 
835  sprintf(shell, "%s\\shell", classname);
837  KEY_CREATE_SUB_KEY, &hkey_shell);
838  ok(rc == ERROR_SUCCESS, "%s key creation failed with %d\n", shell, rc);
839 
840  rc=RegCreateKeyExA(hkey_shell, verb, 0, NULL, 0, KEY_CREATE_SUB_KEY,
841  NULL, &hkey_verb, NULL);
842  ok(rc == ERROR_SUCCESS, "%s verb key creation failed with %d\n", verb, rc);
843 
844  rc=RegCreateKeyExA(hkey_verb, "command", 0, NULL, 0, KEY_SET_VALUE,
845  NULL, &hkey_cmd, NULL);
846  ok(rc == ERROR_SUCCESS, "\'command\' key creation failed with %d\n", rc);
847 
848  if (rawcmd)
849  {
850  rc=RegSetValueExA(hkey_cmd, NULL, 0, REG_SZ, (LPBYTE)cmdtail, strlen(cmdtail)+1);
851  }
852  else
853  {
854  cmd = heap_alloc(strlen(argv0) + 10 + strlen(child_file) + 2 + strlen(cmdtail) + 1);
855  sprintf(cmd,"%s shlexec \"%s\" %s", argv0, child_file, cmdtail);
856  rc=RegSetValueExA(hkey_cmd, NULL, 0, REG_SZ, (LPBYTE)cmd, strlen(cmd)+1);
857  ok(rc == ERROR_SUCCESS, "setting command failed with %d\n", rc);
858  heap_free(cmd);
859  }
860 
861  if (ddeexec)
862  {
863  HKEY hkey_ddeexec, hkey_application, hkey_topic, hkey_ifexec;
864 
865  rc=RegCreateKeyExA(hkey_verb, "ddeexec", 0, NULL, 0, KEY_SET_VALUE |
866  KEY_CREATE_SUB_KEY, NULL, &hkey_ddeexec, NULL);
867  ok(rc == ERROR_SUCCESS, "\'ddeexec\' key creation failed with %d\n", rc);
868  rc=RegSetValueExA(hkey_ddeexec, NULL, 0, REG_SZ, (LPBYTE)ddeexec,
869  strlen(ddeexec)+1);
870  ok(rc == ERROR_SUCCESS, "set value failed with %d\n", rc);
871 
872  if (application)
873  {
874  rc=RegCreateKeyExA(hkey_ddeexec, "application", 0, NULL, 0, KEY_SET_VALUE,
875  NULL, &hkey_application, NULL);
876  ok(rc == ERROR_SUCCESS, "\'application\' key creation failed with %d\n", rc);
877 
878  rc=RegSetValueExA(hkey_application, NULL, 0, REG_SZ, (LPBYTE)application,
879  strlen(application)+1);
880  ok(rc == ERROR_SUCCESS, "set value failed with %d\n", rc);
881  CloseHandle(hkey_application);
882  }
883  if (topic)
884  {
885  rc=RegCreateKeyExA(hkey_ddeexec, "topic", 0, NULL, 0, KEY_SET_VALUE,
886  NULL, &hkey_topic, NULL);
887  ok(rc == ERROR_SUCCESS, "\'topic\' key creation failed with %d\n", rc);
888  rc=RegSetValueExA(hkey_topic, NULL, 0, REG_SZ, (LPBYTE)topic,
889  strlen(topic)+1);
890  ok(rc == ERROR_SUCCESS, "set value failed with %d\n", rc);
891  CloseHandle(hkey_topic);
892  }
893  if (ifexec)
894  {
895  rc=RegCreateKeyExA(hkey_ddeexec, "ifexec", 0, NULL, 0, KEY_SET_VALUE,
896  NULL, &hkey_ifexec, NULL);
897  ok(rc == ERROR_SUCCESS, "\'ifexec\' key creation failed with %d\n", rc);
898  rc=RegSetValueExA(hkey_ifexec, NULL, 0, REG_SZ, (LPBYTE)ifexec,
899  strlen(ifexec)+1);
900  ok(rc == ERROR_SUCCESS, "set value failed with %d\n", rc);
901  CloseHandle(hkey_ifexec);
902  }
903  CloseHandle(hkey_ddeexec);
904  }
905 
906  CloseHandle(hkey_shell);
907  CloseHandle(hkey_verb);
908  CloseHandle(hkey_cmd);
909 }
#define CloseHandle
Definition: compat.h:406
#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:53
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:478
#define MAX_PATH
Definition: compat.h:26
static char argv0[MAX_PATH]
Definition: shlexec.c:49
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:44
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:364
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:53

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 153 of file shlexec.c.

156 {
157  DWORD size = 0;
158 
159  if (winetest_debug > 2)
160  trace("dde_cb: %04x, %04x, %p, %p, %p, %p, %08lx, %08lx\n",
161  uType, uFmt, hConv, hsz1, hsz2, hData, dwData1, dwData2);
162 
163  switch (uType)
164  {
165  case XTYP_CONNECT:
166  if (!DdeCmpStringHandles(hsz1, hszTopic))
167  {
169  ok(size < MAX_PATH, "got size %d\n", size);
170  assert(size < MAX_PATH);
171  return (HDDEDATA)TRUE;
172  }
173  return (HDDEDATA)FALSE;
174 
175  case XTYP_EXECUTE:
176  size = DdeGetData(hData, (LPBYTE)ddeExec, MAX_PATH, 0);
177  ok(size < MAX_PATH, "got size %d\n", size);
178  assert(size < MAX_PATH);
179  DdeFreeDataHandle(hData);
181  PostQuitMessage(0);
182  return (HDDEDATA)DDE_FACK;
183 
184  default:
185  return NULL;
186  }
187 }
#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:149
BOOL WINAPI DdeFreeDataHandle(HDDEDATA)
Definition: ddemisc.c:1461
int winetest_debug
unsigned char * LPBYTE
Definition: typedefs.h:53
DWORD WINAPI DdeQueryStringA(DWORD, HSZ, LPSTR, DWORD, INT)
Definition: ddemisc.c:501
smooth NULL
Definition: ftsmooth.c:416
static DWORD ddeInst
Definition: shlexec.c:147
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:150
#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:148
#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:149

Referenced by doChild(), and test_dde_default_app().

◆ ddeThread()

static DWORD CALLBACK ddeThread ( LPVOID  arg)
static

Definition at line 2538 of file shlexec.c.

2539 {
2541  assert(info && info->filename);
2542  PostThreadMessageA(info->threadIdParent,
2543  WM_QUIT,
2545  0);
2546  ExitThread(0);
2547 }
#define SEE_MASK_FLAG_DDEWAIT
Definition: shellapi.h:34
#define shell_execute_ex(mask, verb, filename, parameters, directory, class)
Definition: shlexec.c:674
#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:10
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 87 of file shlexec.c.

88 {
89  if (c >= '0' && c <= '9') return c - '0';
90  if (c >= 'a' && c <= 'f') return c - 'a' + 10;
91  assert(c >= 'A' && c <= 'F');
92  return c - 'A' + 10;
93 }
#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 95 of file shlexec.c.

96 {
97  static char decoded[1024];
98  char* ptr;
99  size_t len,i;
100 
101  len = strlen(str) / 2;
102  if (!len--) return NULL;
103  if (len >= sizeof(decoded))
104  {
105  fprintf(stderr, "string is too long!\n");
106  assert(0);
107  }
108  ptr = decoded;
109  for (i = 0; i < len; i++)
110  ptr[i] = (decode_char(str[2 * i]) << 4) | decode_char(str[2 * i + 1]);
111  ptr[len] = '\0';
112  return ptr;
113 }
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:87

Referenced by getChildString().

◆ delete_test_association()

static void delete_test_association ( const char extension)
static

Definition at line 805 of file shlexec.c.

806 {
807  char classname[MAX_PATH];
808 
809  sprintf(classname, "shlexec%s", extension);
812 }
static void delete_test_class(const char *classname)
Definition: shlexec.c:800
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:734
#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 800 of file shlexec.c.

801 {
803 }
WCHAR classname[128]
Definition: startup.c:15
static LSTATUS myRegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey)
Definition: shlexec.c:734
#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 208 of file shlexec.c.

209 {
210  char *filename, buffer[MAX_PATH];
211  HANDLE hFile, map;
212  int i;
213  UINT_PTR timer;
214 
215  filename=argv[2];
218  return;
219 
220  /* Arguments */
221  childPrintf(hFile, "[Child]\r\n");
222  if (winetest_debug > 2)
223  {
224  trace("cmdlineA='%s'\n", GetCommandLineA());
225  trace("argcA=%d\n", argc);
226  }
227  childPrintf(hFile, "cmdlineA=%s\r\n", encodeA(GetCommandLineA()));
228  childPrintf(hFile, "argcA=%d\r\n", argc);
229  for (i = 0; i < argc; i++)
230  {
231  if (winetest_debug > 2)
232  trace("argvA%d='%s'\n", i, argv[i]);
233  childPrintf(hFile, "argvA%d=%s\r\n", i, encodeA(argv[i]));
234  }
236  childPrintf(hFile, "longPath=%s\r\n", encodeA(buffer));
237 
238  /* Check environment variable inheritance */
239  *buffer = '\0';
240  SetLastError(0);
241  GetEnvironmentVariableA("ShlexecVar", buffer, sizeof(buffer));
242  childPrintf(hFile, "ShlexecVarLE=%d\r\n", GetLastError());
243  childPrintf(hFile, "ShlexecVar=%s\r\n", encodeA(buffer));
244 
245  map = OpenFileMappingA(FILE_MAP_READ, FALSE, "winetest_shlexec_dde_map");
246  if (map != NULL)
247  {
248  HANDLE dde_ready;
249  char *shared_block = MapViewOfFile(map, FILE_MAP_READ, 0, 0, 4096);
250  CloseHandle(map);
251  if (shared_block[0] != '\0' || shared_block[1] != '\0')
252  {
253  HDDEDATA hdde;
254  HSZ hszApplication;
255  MSG msg;
256  UINT rc;
257 
259  ddeInst = 0;
262  ok(rc == DMLERR_NO_ERROR, "DdeInitializeA() returned %d\n", rc);
263  hszApplication = DdeCreateStringHandleA(ddeInst, shared_block, CP_WINANSI);
264  ok(hszApplication != NULL, "DdeCreateStringHandleA(%s) = NULL\n", shared_block);
265  shared_block += strlen(shared_block) + 1;
267  ok(hszTopic != NULL, "DdeCreateStringHandleA(%s) = NULL\n", shared_block);
268  hdde = DdeNameService(ddeInst, hszApplication, 0, DNS_REGISTER | DNS_FILTEROFF);
269  ok(hdde != NULL, "DdeNameService() failed le=%u\n", GetLastError());
270 
272 
273  dde_ready = OpenEventA(EVENT_MODIFY_STATE, FALSE, "winetest_shlexec_dde_ready");
274  SetEvent(dde_ready);
275  CloseHandle(dde_ready);
276 
277  while (GetMessageA(&msg, NULL, 0, 0))
278  {
279  if (winetest_debug > 2)
280  trace("msg %d lParam=%ld wParam=%lu\n", msg.message, msg.lParam, msg.wParam);
282  }
283 
284  Sleep(500);
285  KillTimer(NULL, timer);
286  hdde = DdeNameService(ddeInst, hszApplication, 0, DNS_UNREGISTER);
287  ok(hdde != NULL, "DdeNameService() failed le=%u\n", GetLastError());
288  ok(DdeFreeStringHandle(ddeInst, hszTopic), "DdeFreeStringHandle(topic)\n");
289  ok(DdeFreeStringHandle(ddeInst, hszApplication), "DdeFreeStringHandle(application)\n");
290  ok(DdeUninitialize(ddeInst), "DdeUninitialize() failed\n");
291  }
292  else
293  {
294  dde_ready = OpenEventA(EVENT_MODIFY_STATE, FALSE, "winetest_shlexec_dde_ready");
295  SetEvent(dde_ready);
296  CloseHandle(dde_ready);
297  }
298 
299  UnmapViewOfFile(shared_block);
300 
301  childPrintf(hFile, "ddeExec=%s\r\n", encodeA(ddeExec));
302  }
303 
304  childPrintf(hFile, "Failures=%d\r\n", winetest_get_failures());
306 
308  SetEvent(hEvent);
310 }
#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:406
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:410
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:399
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:189
#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:539
#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:201
#define FILE_MAP_READ
Definition: compat.h:435
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
static DWORD ddeInst
Definition: shlexec.c:147
#define DNS_FILTEROFF
Definition: ddeml.h:155
#define trace
Definition: atltest.h:70
#define GetEnvironmentVariableA(x, y, z)
Definition: compat.h:419
static void init_event(const char *child_file)
Definition: shlexec.c:190
BOOL WINAPI DdeFreeStringHandle(DWORD, HSZ)
Definition: ddemisc.c:631
static BOOL post_quit_on_execute
Definition: shlexec.c:150
#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:153
#define SetLastError(x)
Definition: compat.h:417
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:812
_In_ HANDLE hFile
Definition: mswsock.h:90
static HSZ hszTopic
Definition: shlexec.c:148
#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:67
#define EVENT_MODIFY_STATE
Definition: winbase.h:163
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:407
#define CHILD_DDE_TIMEOUT
Definition: shlexec.c:146
#define UnmapViewOfFile
Definition: compat.h:411
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:149

Referenced by START_TEST().

◆ dump_child_()

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

Definition at line 312 of file shlexec.c.

313 {
314  if (winetest_debug > 1)
315  {
316  char key[18];
317  char* str;
318  int i, c;
319 
320  str=getChildString("Child", "cmdlineA");
321  trace_(file, line)("cmdlineA='%s'\n", str);
322  c=GetPrivateProfileIntA("Child", "argcA", -1, child_file);
323  trace_(file, line)("argcA=%d\n",c);
324  for (i=0;i<c;i++)
325  {
326  sprintf(key, "argvA%d", i);
327  str=getChildString("Child", key);
328  trace_(file, line)("%s='%s'\n", key, str);
329  }
330 
331  c=GetPrivateProfileIntA("Child", "ShlexecVarLE", -1, child_file);
332  trace_(file, line)("ShlexecVarLE=%d\n", c);
333  str=getChildString("Child", "ShlexecVar");
334  trace_(file, line)("ShlexecVar='%s'\n", str);
335 
336  c=GetPrivateProfileIntA("Child", "Failures", -1, child_file);
337  trace_(file, line)("Failures=%d\n", c);
338  }
339 }
#define trace_(file, line,...)
Definition: kmt_test.h:221
static char * getChildString(const char *sect, const char *key)
Definition: shlexec.c:127
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:41
Definition: fci.c:126
static char child_file[MAX_PATH]
Definition: shlexec.c:53

Referenced by shell_execute_(), and shell_execute_ex_().

◆ encodeA()

static const char* encodeA ( const char str)
static

Definition at line 67 of file shlexec.c.

68 {
69  static char encoded[2*1024+1];
70  char* ptr;
71  size_t len,i;
72 
73  if (!str) return "";
74  len = strlen(str) + 1;
75  if (len >= sizeof(encoded)/2)
76  {
77  fprintf(stderr, "string is too long!\n");
78  assert(0);
79  }
80  ptr = encoded;
81  for (i = 0; i < len; i++)
82  sprintf(&ptr[i * 2], "%02x", (unsigned char)str[i]);
83  ptr[2 * len] = '\0';
84  return ptr;
85 }
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 930 of file shlexec.c.

931 {
932  char tmplongpath[MAX_PATH];
933  const char* p;
934  DWORD sp = 0, lp = 0;
935  DWORD tmplen;
936  WIN32_FIND_DATAA wfd;
937  HANDLE goit;
938 
939  if (!shortpath || !shortpath[0])
940  return 0;
941 
942  if (shortpath[1] == ':')
943  {
944  tmplongpath[0] = shortpath[0];
945  tmplongpath[1] = ':';
946  lp = sp = 2;
947  }
948 
949  while (shortpath[sp])
950  {
951  /* check for path delimiters and reproduce them */
952  if (shortpath[sp] == '\\' || shortpath[sp] == '/')
953  {
954  if (!lp || tmplongpath[lp-1] != '\\')
955  {
956  /* strip double "\\" */
957  tmplongpath[lp++] = '\\';
958  }
959  tmplongpath[lp] = 0; /* terminate string */
960  sp++;
961  continue;
962  }
963 
964  p = shortpath + sp;
965  if (sp == 0 && p[0] == '.' && (p[1] == '/' || p[1] == '\\'))
966  {
967  tmplongpath[lp++] = *p++;
968  tmplongpath[lp++] = *p++;
969  }
970  for (; *p && *p != '/' && *p != '\\'; p++);
971  tmplen = p - (shortpath + sp);
972  lstrcpynA(tmplongpath + lp, shortpath + sp, tmplen + 1);
973  /* Check if the file exists and use the existing file name */
974  goit = FindFirstFileA(tmplongpath, &wfd);
975  if (goit == INVALID_HANDLE_VALUE)
976  return 0;
977  FindClose(goit);
978  strcpy(tmplongpath + lp, wfd.cFileName);
979  lp += strlen(tmplongpath + lp);
980  sp += tmplen;
981  }
982  tmplen = strlen(shortpath) - 1;
983  if ((shortpath[tmplen] == '/' || shortpath[tmplen] == '\\') &&
984  (tmplongpath[lp - 1] != '/' && tmplongpath[lp - 1] != '\\'))
985  tmplongpath[lp++] = shortpath[tmplen];
986  tmplongpath[lp] = 0;
987 
988  tmplen = strlen(tmplongpath) + 1;
989  if (tmplen <= longlen)
990  {
991  strcpy(longpath, tmplongpath);
992  tmplen--; /* length without 0 */
993  }
994 
995  return tmplen;
996 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define lstrcpynA
Definition: compat.h:416
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 127 of file shlexec.c.

128 {
129  char buf[1024];
130  char* ret;
131 
132  GetPrivateProfileStringA(sect, key, "-", buf, sizeof(buf), child_file);
133  if (buf[0] == '\0' || (buf[0] == '-' && buf[1] == '\0')) return NULL;
134  assert(!(strlen(buf) & 1));
135  ret = decodeA(buf);
136  return ret;
137 }
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:95
#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:41
static char child_file[MAX_PATH]
Definition: shlexec.c:53

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 2321 of file shlexec.c.

2322 {
2323  char *base;
2324  PIMAGE_NT_HEADERS nt_headers;
2325  DWORD import_directory_rva;
2326  PIMAGE_IMPORT_DESCRIPTOR import_descriptor;
2327  int hook_count = 0;
2328 
2329  base = (char *) GetModuleHandleA("shell32.dll");
2330  nt_headers = (PIMAGE_NT_HEADERS)(base + ((PIMAGE_DOS_HEADER) base)->e_lfanew);
2331  import_directory_rva = nt_headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
2332 
2333  /* Search for the correct imported module by walking the import descriptors */
2334  import_descriptor = (PIMAGE_IMPORT_DESCRIPTOR)(base + import_directory_rva);
2335  while (U(*import_descriptor).OriginalFirstThunk != 0)
2336  {
2337  char *import_module_name;
2338 
2339  import_module_name = base + import_descriptor->Name;
2340  if (lstrcmpiA(import_module_name, "user32.dll") == 0 ||
2341  lstrcmpiA(import_module_name, "user32") == 0)
2342  {
2343  PIMAGE_THUNK_DATA int_entry;
2344  PIMAGE_THUNK_DATA iat_entry;
2345 
2346  /* The import name table and import address table are two parallel
2347  * arrays. We need the import name table to find the imported
2348  * routine and the import address table to patch the address, so
2349  * walk them side by side */
2350  int_entry = (PIMAGE_THUNK_DATA)(base + U(*import_descriptor).OriginalFirstThunk);
2351  iat_entry = (PIMAGE_THUNK_DATA)(base + import_descriptor->FirstThunk);
2352  while (int_entry->u1.Ordinal != 0)
2353  {
2354  if (! IMAGE_SNAP_BY_ORDINAL(int_entry->u1.Ordinal))
2355  {
2356  PIMAGE_IMPORT_BY_NAME import_by_name;
2357  import_by_name = (PIMAGE_IMPORT_BY_NAME)(base + int_entry->u1.AddressOfData);
2358  if (lstrcmpA((char *) import_by_name->Name, "WaitForInputIdle") == 0)
2359  {
2360  /* Found the correct routine in the correct imported module. Patch it. */
2361  DWORD old_prot;
2362  VirtualProtect(&iat_entry->u1.Function, sizeof(ULONG_PTR), PAGE_READWRITE, &old_prot);
2363  iat_entry->u1.Function = (ULONG_PTR) new_func;
2364  VirtualProtect(&iat_entry->u1.Function, sizeof(ULONG_PTR), old_prot, &old_prot);
2365  if (winetest_debug > 1)
2366  trace("Hooked %s.WaitForInputIdle\n", import_module_name);
2367  hook_count++;
2368  break;
2369  }
2370  }
2371  int_entry++;
2372  iat_entry++;
2373  }
2374  break;
2375  }
2376 
2377  import_descriptor++;
2378  }
2379  ok(hook_count, "Could not hook WaitForInputIdle()\n");
2380 }
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:45
union _IMAGE_THUNK_DATA32::@2079 u1
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
int winetest_debug
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
uint32_t ULONG_PTR
Definition: typedefs.h:64
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
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#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
PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS
Definition: ntddk_ex.h:187

Referenced by test_dde().

◆ hooked_WaitForInputIdle()

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

Definition at line 2303 of file shlexec.c.

2304 {
2306  if (winetest_debug > 1)
2307  trace("WaitForInputIdle() waiting for dde event timeout=min(%u,5s)\n", timeout);
2308  timeout = timeout < 5000 ? timeout : 5000;
2310 }
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:2302
static HANDLE dde_ready_event
Definition: shlexec.c:57

Referenced by test_dde().

◆ init_event()

static void init_event ( const char child_file)
static

Definition at line 190 of file shlexec.c.

191 {
192  char* event_name;
193  event_name=strrchr(child_file, '\\')+1;
194  hEvent=CreateEventA(NULL, FALSE, FALSE, event_name);
195 }
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
static HANDLE hEvent
Definition: shlexec.c:189
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:53

Referenced by doChild(), and init_test().

◆ init_test()

static void init_test ( void  )
static

Definition at line 2649 of file shlexec.c.

2650 {
2651  HMODULE hdll;
2652  HRESULT (WINAPI *pDllGetVersion)(DLLVERSIONINFO*);
2653  char filename[MAX_PATH];
2654  WCHAR lnkfile[MAX_PATH];
2655  char params[1024];
2656  const char* const * testfile;
2657  lnk_desc_t desc;
2658  DWORD rc;
2659  HRESULT r;
2660 
2661  hdll=GetModuleHandleA("shell32.dll");
2662  pDllGetVersion=(void*)GetProcAddress(hdll, "DllGetVersion");
2663  if (pDllGetVersion)
2664  {
2665  dllver.cbSize=sizeof(dllver);
2666  pDllGetVersion(&dllver);
2667  trace("major=%d minor=%d build=%d platform=%d\n",
2670  }
2671  else
2672  {
2673  memset(&dllver, 0, sizeof(dllver));
2674  }
2675 
2676  r = CoInitialize(NULL);
2677  ok(r == S_OK, "CoInitialize failed (0x%08x)\n", r);
2678  if (FAILED(r))
2679  exit(1);
2680 
2681  rc=GetModuleFileNameA(NULL, argv0, sizeof(argv0));
2682  ok(rc != 0 && rc < sizeof(argv0), "got %d\n", rc);
2684  {
2685  strcat(argv0, ".so");
2687  "unable to find argv0!\n");
2688  }
2689 
2690  /* Older versions (win 2k) fail tests if there is a space in
2691  the path. */
2692  if (dllver.dwMajorVersion <= 5)
2693  strcpy(filename, "c:\\");
2694  else
2695  GetTempPathA(sizeof(filename), filename);
2696  GetTempFileNameA(filename, "wt", 0, tmpdir);
2697  GetLongPathNameA(tmpdir, tmpdir, sizeof(tmpdir));
2698  DeleteFileA( tmpdir );
2699  rc = CreateDirectoryA( tmpdir, NULL );
2700  ok( rc, "failed to create %s err %u\n", tmpdir, GetLastError() );
2701  /* Set %TMPDIR% for the tests */
2702  SetEnvironmentVariableA("TMPDIR", tmpdir);
2703 
2704  rc = GetTempFileNameA(tmpdir, "wt", 0, child_file);
2705  ok(rc != 0, "got %d\n", rc);
2707 
2708  /* Set up the test files */
2709  testfile=testfiles;
2710  while (*testfile)
2711  {
2712  HANDLE hfile;
2713 
2714  sprintf(filename, *testfile, tmpdir);
2717  if (hfile==INVALID_HANDLE_VALUE)
2718  {
2719  trace("unable to create '%s': err=%u\n", filename, GetLastError());
2720  assert(0);
2721  }
2722  CloseHandle(hfile);
2723  testfile++;
2724  }
2725 
2726  /* Setup the test shortcuts */
2727  sprintf(filename, "%s\\test_shortcut_shlexec.lnk", tmpdir);
2728  MultiByteToWideChar(CP_ACP, 0, filename, -1, lnkfile, ARRAY_SIZE(lnkfile));
2729  desc.description=NULL;
2730  desc.workdir=NULL;
2731  sprintf(filename, "%s\\test file.shlexec", tmpdir);
2732  desc.path=filename;
2733  desc.pidl=NULL;
2734  desc.arguments="ignored";
2735  desc.showcmd=0;
2736  desc.icon=NULL;
2737  desc.icon_id=0;
2738  desc.hotkey=0;
2739  create_lnk(lnkfile, &desc, 0);
2740 
2741  sprintf(filename, "%s\\test_shortcut_exe.lnk", tmpdir);
2742  MultiByteToWideChar(CP_ACP, 0, filename, -1, lnkfile, ARRAY_SIZE(lnkfile));
2743  desc.description=NULL;
2744  desc.workdir=NULL;
2745  desc.path=argv0;
2746  desc.pidl=NULL;
2747  sprintf(params, "shlexec \"%s\" Lnk", child_file);
2748  desc.arguments=params;
2749  desc.showcmd=0;
2750  desc.icon=NULL;
2751  desc.icon_id=0;
2752  desc.hotkey=0;
2753  create_lnk(lnkfile, &desc, 0);
2754 
2755  /* Create a basic association suitable for most tests */
2756  if (!create_test_association(".shlexec"))
2757  {
2759  skip("Unable to create association for '.shlexec'\n");
2760  return;
2761  }
2762  create_test_verb("shlexec.shlexec", "Open", 0, "Open \"%1\"");
2763  create_test_verb("shlexec.shlexec", "NoQuotes", 0, "NoQuotes %1");
2764  create_test_verb("shlexec.shlexec", "LowerL", 0, "LowerL %l");
2765  create_test_verb("shlexec.shlexec", "QuotedLowerL", 0, "QuotedLowerL \"%l\"");
2766  create_test_verb("shlexec.shlexec", "UpperL", 0, "UpperL %L");
2767  create_test_verb("shlexec.shlexec", "QuotedUpperL", 0, "QuotedUpperL \"%L\"");
2768 
2769  create_test_association(".sha");
2770  create_test_verb("shlexec.sha", "averb", 0, "AVerb \"%1\"");
2771 
2772  create_test_class("shlproto", TRUE);
2773  create_test_verb("shlproto", "open", 0, "URL \"%1\"");
2774  create_test_verb("shlproto", "averb", 0, "AVerb \"%1\"");
2775 
2776  /* Set an environment variable to see if it is inherited */
2777  SetEnvironmentVariableA("ShlexecVar", "Present");
2778 }
#define HRESULT
Definition: msvc.h:7
DWORD dwMinorVersion
Definition: shlwapi.h:1956
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
static BOOL create_test_class(const char *class, BOOL protocol)
Definition: shlexec.c:684
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define CP_ACP
Definition: compat.h:99
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
#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:539
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:915
static DLLVERSIONINFO dllver
Definition: shlexec.c:54
GLenum const GLfloat * params
Definition: glext.h:5645
DWORD dwBuildNumber
Definition: shlwapi.h:1957
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:786
static const WCHAR desc[]
Definition: protectdata.c:36
#define GENERIC_WRITE
Definition: nt_native.h:90
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:52
#define trace
Definition: atltest.h:70
static void init_event(const char *child_file)
Definition: shlexec.c:190
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
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:6
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:812
static char argv0[MAX_PATH]
Definition: shlexec.c:49
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:1005
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:1964
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define GetProcAddress(x, y)
Definition: compat.h:418
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:407
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:712
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:55
static char child_file[MAX_PATH]
Definition: shlexec.c:53

Referenced by START_TEST().

◆ myRegDeleteTreeA()

static LSTATUS myRegDeleteTreeA ( HKEY  hKey,
LPCSTR  lpszSubKey 
)
static

Definition at line 734 of file shlexec.c.

735 {
736  LONG ret;
737  DWORD dwMaxSubkeyLen, dwMaxValueLen;
738  DWORD dwMaxLen, dwSize;
739  CHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
740  HKEY hSubKey = hKey;
741 
742  if(lpszSubKey)
743  {
744  ret = RegOpenKeyExA(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
745  if (ret) return ret;
746  }
747 
748  /* Get highest length for keys, values */
749  ret = RegQueryInfoKeyA(hSubKey, NULL, NULL, NULL, NULL,
750  &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
751  if (ret) goto cleanup;
752 
753  dwMaxSubkeyLen++;
754  dwMaxValueLen++;
755  dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
756  if (dwMaxLen > ARRAY_SIZE(szNameBuf))
757  {
758  /* Name too big: alloc a buffer for it */
759  if (!(lpszName = heap_alloc(dwMaxLen*sizeof(CHAR))))
760  {
762  goto cleanup;
763  }
764  }
765 
766 
767  /* Recursively delete all the subkeys */
768  while (TRUE)
769  {
770  dwSize = dwMaxLen;
771  if (RegEnumKeyExA(hSubKey, 0, lpszName, &dwSize, NULL,
772  NULL, NULL, NULL)) break;
773 
774  ret = myRegDeleteTreeA(hSubKey, lpszName);
775  if (ret) goto cleanup;
776  }
777 
778  if (lpszSubKey)
779  ret = RegDeleteKeyA(hKey, lpszSubKey);
780  else
781  while (TRUE)
782  {
783  dwSize = dwMaxLen;
784  if (RegEnumValueA(hKey, 0, lpszName, &dwSize,
785  NULL, NULL, NULL, NULL)) break;
786 
787  ret = RegDeleteValueA(hKey, lpszName);
788  if (ret) goto cleanup;
789  }
790 
791 cleanup:
792  /* Free buffer if allocated */
793  if (lpszName != szNameBuf)
794  heap_free(lpszName);
795  if(lpszSubKey)
796  RegCloseKey(hSubKey);
797  return ret;
798 }
#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:734
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 453 of file shlexec.c.

454 {
455  INT result;
458  "%s expected %d, but got %d\n", key, expected, result);
459 }
int32_t INT
Definition: typedefs.h:57
Definition: parser.c:48
HKEY key
Definition: reg.c:42
#define okShell_(file, line)
Definition: shlexec.c:361
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:41
Definition: fci.c:126
static char child_file[MAX_PATH]
Definition: shlexec.c:53

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 462 of file shlexec.c.

463 {
464  INT result;
467  "%s expected %d, but got %d\n", key, expected, result);
468 }
int32_t INT
Definition: typedefs.h:57
Definition: parser.c:48
HKEY key
Definition: reg.c:42
#define broken(x)
Definition: _sntprintf.h:21
#define okShell_(file, line)
Definition: shlexec.c:361
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:41
Definition: fci.c:126
static char child_file[MAX_PATH]
Definition: shlexec.c:53

◆ okChildPath_()

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

Definition at line 423 of file shlexec.c.

424 {
425  char* result;
426  int equal, shortequal;
427  result=getChildString("Child", key);
428  if (!result)
429  {
430  okShell_(file,line)(FALSE, "%s expected '%s', but key not found or empty\n", key, expected);
431  return;
432  }
433  shortequal = FALSE;
434  equal = (StrCmpPath(result, expected) == 0);
435  if (!equal)
436  {
437  char altpath[MAX_PATH];
438  DWORD rc = GetLongPathNameA(expected, altpath, sizeof(altpath));
439  if (0 < rc && rc < sizeof(altpath))
440  equal = (StrCmpPath(result, altpath) == 0);
441  if (!equal)
442  {
443  rc = GetShortPathNameA(expected, altpath, sizeof(altpath));
444  if (0 < rc && rc < sizeof(altpath))
445  shortequal = (StrCmpPath(result, altpath) == 0);
446  }
447  }
448  okShell_(file,line)(equal || broken(shortequal) /* XP SP1 */,
449  "%s expected '%s', got '%s'\n", key, expected, result);
450 }
static char * getChildString(const char *sect, const char *key)
Definition: shlexec.c:127
#define equal(x, y)
Definition: reader.cc:56
static int StrCmpPath(const char *s1, const char *s2)
Definition: shlexec.c:386
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:361
GLuint64EXT * result
Definition: glext.h:11304
BOOL expected
Definition: store.c:2063
Definition: path.c:41
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 370 of file shlexec.c.

371 {
372  char* result;
373  result=getChildString("Child", key);
374  if (!result)
375  {
376  okShell_(file, line)(FALSE, "%s expected '%s', but key not found or empty\n", key, expected);
377  return;
378  }
380  broken(lstrcmpiA(result, bad) == 0),
381  "%s expected '%s', got '%s'\n", key, expected, result);
382 }
static char * getChildString(const char *sect, const char *key)
Definition: shlexec.c:127
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:361
GLuint64EXT * result
Definition: glext.h:11304
BOOL expected
Definition: store.c:2063
Definition: path.c:41
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 365 of file shlexec.c.

366 {
367  *assoc_desc = '\0';
368 }
static char assoc_desc[2048]
Definition: shlexec.c:364

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 496 of file shlexec.c.

497 {
498  INT_PTR rc, rcEmpty = 0;
499 
500  if(!verb)
501  rcEmpty = shell_execute_(file, line, "", filename, parameters, directory);
502 
503  strcpy(shell_call, "ShellExecute(");
504  strcat_param(shell_call, "verb", verb);
505  strcat_param(shell_call, "file", filename);
506  strcat_param(shell_call, "params", parameters);
508  strcat(shell_call, ")");
510  if (winetest_debug > 1)
511  trace_(file, line)("Called %s\n", shell_call);
512 
514  SetLastError(0xcafebabe);
515 
516  /* FIXME: We cannot use ShellExecuteEx() here because if there is no
517  * association it displays the 'Open With' dialog and I could not find
518  * a flag to prevent this.
519  */
520  rc=(INT_PTR)ShellExecuteA(NULL, verb, filename, parameters, directory, SW_HIDE);
521 
522  if (rc > 32)
523  {
524  int wait_rc;
525  wait_rc=WaitForSingleObject(hEvent, 5000);
526  if (wait_rc == WAIT_TIMEOUT)
527  {
528  HWND wnd = FindWindowA("#32770", "Windows");
529  if (!wnd)
530  wnd = FindWindowA("Shell_Flyout", "");
531  if (wnd != NULL)
532  {
533  SendMessageA(wnd, WM_CLOSE, 0, 0);
534  win_skip("Skipping shellexecute of file with unassociated extension\n");
536  rc = SE_ERR_NOASSOC;
537  }
538  }
540  okShell_(file, line)(wait_rc==WAIT_OBJECT_0 || rc <= 32,
541  "WaitForSingleObject returned %d\n", wait_rc);
542  }
543  /* The child process may have changed the result file, so let profile
544  * functions know about it
545  */
548  {
549  int c;
551  c = GetPrivateProfileIntA("Child", "Failures", -1, child_file);
552  if (c > 0)
554  okChildInt_(file, line, "ShlexecVarLE", 0);
555  okChildString_(file, line, "ShlexecVar", "Present", "Present");
556  }
557 
558  if(!verb)
559  {
560  if (rc != rcEmpty && rcEmpty == SE_ERR_NOASSOC) /* NT4 */
561  bad_shellexecute = 1;
562  okShell_(file, line)(rc == rcEmpty ||
563  broken(rc != rcEmpty && rcEmpty == SE_ERR_NOASSOC) /* NT4 */,
564  "Got different return value with empty string: %lu %lu\n", rc, rcEmpty);
565  }
566 
567  return rc;
568 }
HINSTANCE WINAPI ShellExecuteA(HWND hWnd, LPCSTR lpVerb, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, INT iShowCmd)
Definition: shlexec.cpp:2171
static char shell_call[2048]
Definition: shlexec.c:348
#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:63
static HANDLE hEvent
Definition: shlexec.c:189
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:370
smooth NULL
Definition: ftsmooth.c:416
static void strcat_param(char *str, const char *name, const char *param)
Definition: shlexec.c:478
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
Definition: parser.c:48
#define todo_wine_if(is_todo)
Definition: test.h:163
#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:417
#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:453
static int bad_shellexecute
Definition: shlexec.c:494
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:56
#define okShell_(file, line)
Definition: shlexec.c:361
#define SE_ERR_NOASSOC
Definition: shellapi.h:132
static int _todo_wait
Definition: shlexec.c:491
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:496
#define win_skip
Definition: test.h:149
static char assoc_desc[2048]
Definition: shlexec.c:364
static void dump_child_(const char *file, int line)
Definition: shlexec.c:312
Definition: fci.c:126
static char child_file[MAX_PATH]
Definition: shlexec.c:53

◆ 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 572 of file shlexec.c.

576 {
577  char smask[11];
578  SHELLEXECUTEINFOA sei;
579  BOOL success;
580  INT_PTR rc;
581 
582  /* Add some flags so we can wait for the child process */
584 
585  strcpy(shell_call, "ShellExecuteEx(");
586  sprintf(smask, "0x%x", mask);
587  strcat_param(shell_call, "mask", smask);
588  strcat_param(shell_call, "verb", verb);
589  strcat_param(shell_call, "file", filename);
590  strcat_param(shell_call, "params", parameters);
592  strcat_param(shell_call, "class", class);
593  strcat(shell_call, ")");
595  if (winetest_debug > 1)
596  trace_(file, line)("Called %s\n", shell_call);
597 
598  sei.cbSize=sizeof(sei);
599  sei.fMask=mask;
600  sei.hwnd=NULL;
601  sei.lpVerb=verb;
602  sei.lpFile=filename;
603  sei.lpParameters=parameters;
605  sei.nShow=SW_SHOWNORMAL;
606  sei.hInstApp=NULL; /* Out */
607  sei.lpIDList=NULL;
608  sei.lpClass=class;
609  sei.hkeyClass=NULL;
610  sei.dwHotKey=0;
611  U(sei).hIcon=NULL;
612  sei.hProcess=(HANDLE)0xdeadbeef; /* Out */
613 
615  SetLastError(0xcafebabe);
616  success=ShellExecuteExA(&sei);
617  rc=(INT_PTR)sei.hInstApp;
618  okShell_(file, line)((success && rc > 32) || (!success && rc <= 32),
619  "rc=%d and hInstApp=%ld is not allowed\n",
620  success, rc);
621 
622  if (rc > 32)
623  {
624  DWORD wait_rc, rc;
625  if (sei.hProcess!=NULL)
626  {
627  wait_rc=WaitForSingleObject(sei.hProcess, 5000);
628  okShell_(file, line)(wait_rc==WAIT_OBJECT_0,
629  "WaitForSingleObject(hProcess) returned %d\n",
630  wait_rc);
631  wait_rc = GetExitCodeProcess(sei.hProcess, &rc);
632  okShell_(file, line)(wait_rc, "GetExitCodeProcess() failed le=%u\n", GetLastError());
634  okShell_(file, line)(rc == 0, "child returned %u\n", rc);
635  CloseHandle(sei.hProcess);
636  }
637  wait_rc=WaitForSingleObject(hEvent, 5000);
639  okShell_(file, line)(wait_rc==WAIT_OBJECT_0,
640  "WaitForSingleObject returned %d\n", wait_rc);
641  }
642  else
643  okShell_(file, line)(sei.hProcess==NULL,
644  "returned a process handle %p\n", sei.hProcess);
645 
646  /* The child process may have changed the result file, so let profile
647  * functions know about it
648  */
651  {
652  int c;
654  c = GetPrivateProfileIntA("Child", "Failures", -1, child_file);
655  if (c > 0)
657  /* When NOZONECHECKS is specified the environment variables are not
658  * inherited if the process does not have elevated privileges.
659  */
661  {
662  okChildInt_(file, line, "ShlexecVarLE", 203);
663  okChildString_(file, line, "ShlexecVar", "", "");
664  }
665  else
666  {
667  okChildInt_(file, line, "ShlexecVarLE", 0);
668  okChildString_(file, line, "ShlexecVar", "Present", "Present");
669  }
670  }
671 
672  return rc;
673 }
static char shell_call[2048]
Definition: shlexec.c:348
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExA(LPSHELLEXECUTEINFOA sei)
Definition: shlexec.cpp:2205
#define trace_(file, line,...)
Definition: kmt_test.h:221
#define CloseHandle
Definition: compat.h:406
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:45
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
int32_t INT_PTR
Definition: typedefs.h:63
static HANDLE hEvent
Definition: shlexec.c:189
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:370
smooth NULL
Definition: ftsmooth.c:416
static void strcat_param(char *str, const char *name, const char *param)
Definition: shlexec.c:478
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
Definition: parser.c:48
#define todo_wine_if(is_todo)
Definition: test.h:163
#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:72
#define success(from, fromstr, to, tostr)
#define SetLastError(x)
Definition: compat.h:417
#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:453
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:361
static int _todo_wait
Definition: shlexec.c:491
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:364
static void dump_child_(const char *file, int line)
Definition: shlexec.c:312
static BOOL skip_shlexec_tests
Definition: shlexec.c:55
Definition: fci.c:126
static char child_file[MAX_PATH]
Definition: shlexec.c:53

◆ START_TEST()

START_TEST ( shlexec  )

Definition at line 2861 of file shlexec.c.

2862 {
2863 
2865  if (myARGC >= 3)
2866  {
2867  doChild(myARGC, myARGV);
2868  /* Skip the tests/failures trace for child processes */
2870  }
2871 
2872  init_test();
2873 
2875  test_argify();
2877  test_filename();
2878  test_fileurls();
2879  test_urls();
2881  test_lnks();
2882  test_exes();
2883  test_dde();
2885  test_directory();
2886 
2887  cleanup_test();
2888 }
LONG winetest_get_failures(void)
static void test_argify(void)
Definition: shlexec.c:1545
static void test_fileurls(void)
Definition: shlexec.c:1786
static void doChild(int argc, char **argv)
Definition: shlexec.c:208
static void test_exes(void)
Definition: shlexec.c:2204
static void test_lpFile_parsed(void)
Definition: shlexec.c:1092
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1487
static void cleanup_test(void)
Definition: shlexec.c:2780
static void test_find_executable(void)
Definition: shlexec.c:1963
static void test_dde_default_app(void)
Definition: shlexec.c:2549
static void test_directory(void)
Definition: shlexec.c:2808
static void test_filename(void)
Definition: shlexec.c:1603
static int myARGC
Definition: shlexec.c:50
static void test_lnks(void)
Definition: shlexec.c:2110
static void init_test(void)
Definition: shlexec.c:2649
int winetest_get_mainargs(char ***pargv)
static char ** myARGV
Definition: shlexec.c:51
static void test_urls(void)
Definition: shlexec.c:1869
static void test_dde(void)
Definition: shlexec.c:2382
static void test_commandline2argv(void)
Definition: shlexec.c:1359

◆ strcat_param()

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

Definition at line 478 of file shlexec.c.

479 {
480  if (param)
481  {
482  if (str[strlen(str)-1] == '"')
483  strcat(str, ", ");
484  strcat(str, name);
485  strcat(str, "=\"");
486  strcat(str, param);
487  strcat(str, "\"");
488  }
489 }
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:38

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 386 of file shlexec.c.

387 {
388  if (!s1 && !s2) return 0;
389  if (!s2) return 1;
390  if (!s1) return -1;
391  while (*s1)
392  {
393  if (!*s2)
394  {
395  if (*s1=='.')
396  s1++;
397  return (*s1-*s2);
398  }
399  if ((*s1=='/' || *s1=='\\') && (*s2=='/' || *s2=='\\'))
400  {
401  while (*s1=='/' || *s1=='\\')
402  s1++;
403  while (*s2=='/' || *s2=='\\')
404  s2++;
405  }
406  else if (toupper(*s1)==toupper(*s2))
407  {
408  s1++;
409  s2++;
410  }
411  else
412  {
413  return (*s1-*s2);
414  }
415  }
416  if (*s2=='.')
417  s2++;
418  if (*s2)
419  return -1;
420  return 0;
421 }
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 1545 of file shlexec.c.

1546 {
1547  char fileA[MAX_PATH], params[2*MAX_PATH+12];
1548  INT_PTR rc;
1549  const argify_tests_t* test;
1550  const char *bad;
1551  const char* cmd;
1552 
1553  /* Test with a long parameter */
1554  for (rc = 0; rc < MAX_PATH; rc++)
1555  fileA[rc] = 'a' + rc % 26;
1556  fileA[MAX_PATH-1] = '\0';
1557  sprintf(params, "shlexec \"%s\" %s", child_file, fileA);
1558 
1559  /* We need NOZONECHECKS on Win2003 to block a dialog */
1561  okShell(rc > 32, "failed: rc=%lu\n", rc);
1562  okChildInt("argcA", 4);
1563  okChildPath("argvA3", fileA);
1564 
1565  if (skip_shlexec_tests)
1566  {
1567  skip("No argify tests due to lack of .shlexec association\n");
1568  return;
1569  }
1570 
1571  create_test_verb("shlexec.shlexec", "Params232S", 0, "Params232S %2 %3 \"%2\" \"%*\"");
1572  create_test_verb("shlexec.shlexec", "Params23456", 0, "Params23456 \"%2\" \"%3\" \"%4\" \"%5\" \"%6\"");
1573  create_test_verb("shlexec.shlexec", "Params23456789", 0, "Params23456789 \"%2\" \"%3\" \"%4\" \"%5\" \"%6\" \"%7\" \"%8\" \"%9\"");
1574  create_test_verb("shlexec.shlexec", "Params2345Etc", 0, "Params2345Etc ~2=\"%~2\" ~3=\"%~3\" ~4=\"%~4\" ~5=%~5");
1575  create_test_verb("shlexec.shlexec", "Params9Etc", 0, "Params9Etc ~9=\"%~9\"");
1576  create_test_verb("shlexec.shlexec", "Params20", 0, "Params20 \"%20\"");
1577  create_test_verb("shlexec.shlexec", "ParamsBad", 0, "ParamsBad \"%% %- %~ %~0 %~1 %~a %~* %a %b %c %TMPDIR%\"");
1578 
1579  sprintf(fileA, "%s\\test file.shlexec", tmpdir);
1580 
1581  test = argify_tests;
1582  while (test->params)
1583  {
1584  bad = test->broken ? test->broken : test->cmd;
1585 
1586  rc = shell_execute_ex(SEE_MASK_DOENVSUBST, test->verb, fileA, test->params, NULL, NULL);
1587  okShell(rc > 32, "failed: rc=%lu\n", rc);
1588 
1589  cmd = getChildString("Child", "cmdlineA");
1590  /* Our commands are such that the verb immediately precedes the
1591  * part we are interested in.
1592  */
1593  if (cmd) cmd = strstr(cmd, test->verb);
1594  if (cmd) cmd += strlen(test->verb);
1595  if (!cmd) cmd = "(null)";
1596  todo_wine_if(test->todo)
1597  okShell(!strcmp(cmd, test->cmd) || broken(!strcmp(cmd, bad)),
1598  "expected '%s', got '%s'\n", cmd, test->cmd);
1599  test++;
1600  }
1601 }
static char * getChildString(const char *sect, const char *key)
Definition: shlexec.c:127
#define shell_execute_ex(mask, verb, filename, parameters, directory, class)
Definition: shlexec.c:674
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:460
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:63
static const argify_tests_t argify_tests[]
Definition: shlexec.c:1420
#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:915
GLenum const GLfloat * params
Definition: glext.h:5645
smooth NULL
Definition: ftsmooth.c:416
#define todo_wine_if(is_todo)
Definition: test.h:163
#define SEE_MASK_NOZONECHECKS
Definition: shellapi.h:54
static char tmpdir[MAX_PATH]
Definition: shlexec.c:52
#define MAX_PATH
Definition: compat.h:26
#define SEE_MASK_DOENVSUBST
Definition: shellapi.h:35
static char argv0[MAX_PATH]
Definition: shlexec.c:49
GLdouble s
Definition: gl.h:2039
#define okShell
Definition: shlexec.c:362
#define broken(x)
Definition: _sntprintf.h:21
#define skip(...)
Definition: atltest.h:64
#define okChildPath(key, expected)
Definition: shlexec.c:451
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:55
static char child_file[MAX_PATH]
Definition: shlexec.c:53

Referenced by START_TEST().

◆ test_commandline2argv()

static void test_commandline2argv ( void  )
static

Definition at line 1359 of file shlexec.c.

1360 {
1361  static const WCHAR exeW[] = {'e','x','e',0};
1362  const cmdline_tests_t* test;
1363  WCHAR strW[MAX_PATH];
1364  LPWSTR *args;
1365  int numargs;
1366  DWORD le;
1367 
1368  test = cmdline_tests;
1369  while (test->cmd)
1370  {
1371  if (!test_one_cmdline(test))
1372  return;
1373  test++;
1374  }
1375 
1376  SetLastError(0xdeadbeef);
1377  args = CommandLineToArgvW(exeW, NULL);
1378  le = GetLastError();
1379  ok(args == NULL && le == ERROR_INVALID_PARAMETER, "expected NULL with ERROR_INVALID_PARAMETER got %p with %u\n", args, le);
1380 
1381  SetLastError(0xdeadbeef);
1383  le = GetLastError();
1384  ok(args == NULL && le == ERROR_INVALID_PARAMETER, "expected NULL with ERROR_INVALID_PARAMETER got %p with %u\n", args, le);
1385 
1386  *strW = 0;
1387  args = CommandLineToArgvW(strW, &numargs);
1388  ok(numargs == 1 || broken(numargs > 1), "expected 1 args, got %d\n", numargs);
1389  ok(!args || (!args[numargs] || broken(args[numargs] != NULL) /* before Vista */),
1390  "expected NULL-terminated list of commandline arguments\n");
1391  if (numargs == 1)
1392  {
1394  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));
1395  }
1396  if (args) LocalFree(args);
1397 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
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:1318
WCHAR strW[12]
Definition: clipboard.c:2029
LPWSTR *WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int *numargs)
Definition: shell32_main.c:79
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const cmdline_tests_t cmdline_tests[]
Definition: shlexec.c:1157
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
#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 2382 of file shlexec.c.

2383 {
2384  char filename[MAX_PATH], defApplication[MAX_PATH];
2385  const dde_tests_t* test;
2386  char params[1024];
2387  INT_PTR rc;
2388  HANDLE map;
2389  char *shared_block;
2390  DWORD ddeflags;
2391 
2393 
2394  sprintf(filename, "%s\\test file.sde", tmpdir);
2395 
2396  /* Default service is application name minus path and extension */
2397  strcpy(defApplication, strrchr(argv0, '\\')+1);
2398  *strchr(defApplication, '.') = 0;
2399 
2401  4096, "winetest_shlexec_dde_map");
2402  shared_block = MapViewOfFile(map, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 4096);
2403 
2405  test = dde_tests;
2406  while (test->command)
2407  {
2408  if (!create_test_association(".sde"))
2409  {
2410  skip("Unable to create association for '.sde'\n");
2411  return;
2412  }
2413  create_test_verb_dde("shlexec.sde", "Open", 0, test->command, test->ddeexec,
2414  test->application, test->topic, test->ifexec);
2415 
2416  if (test->application != NULL || test->topic != NULL)
2417  {
2418  strcpy(shared_block, test->application ? test->application : defApplication);
2419  strcpy(shared_block + strlen(shared_block) + 1, test->topic ? test->topic : SZDDESYS_TOPIC);
2420  }
2421  else
2422  {
2423  shared_block[0] = '\0';
2424  shared_block[1] = '\0';
2425  }
2426  ddeExec[0] = 0;
2427 
2429  dde_ready_event = CreateEventA(NULL, TRUE, FALSE, "winetest_shlexec_dde_ready");
2430  rc = shell_execute_ex(ddeflags, NULL, filename, NULL, NULL, NULL);
2432  if (!(ddeflags & SEE_MASK_WAITFORINPUTIDLE) && rc == SE_ERR_DDEFAIL &&
2434  strcmp(winetest_platform, "windows") == 0)
2435  {
2436  /* Windows 10 does not call WaitForInputIdle() for DDE which creates
2437  * a race condition as the DDE server may not have time to start up.
2438  * When that happens the test fails with the above results and we
2439  * compensate by forcing the WaitForInputIdle() call.
2440  */
2441  trace("Adding SEE_MASK_WAITFORINPUTIDLE for Windows 10\n");
2442  ddeflags |= SEE_MASK_WAITFORINPUTIDLE;
2443  delete_test_association(".sde");
2445  continue;
2446  }
2447  okShell(32 < rc, "failed: rc=%lu err=%u\n", rc, GetLastError());
2448  if (test->ddeexec)
2450  broken(waitforinputidle_count == 0) /* Win10 race */,
2451  "WaitForInputIdle() was called %u times\n",
2453  else
2454  okShell(waitforinputidle_count == 0, "WaitForInputIdle() was called %u times for a non-DDE case\n", waitforinputidle_count);
2455 
2456  if (32 < rc)
2457  {
2458  if (test->broken)
2459  okChildIntBroken("argcA", test->expectedArgs + 3);
2460  else
2461  okChildInt("argcA", test->expectedArgs + 3);
2462 
2463  if (test->expectedArgs == 1) okChildPath("argvA3", filename);
2464 
2465  sprintf(params, test->expectedDdeExec, filename);
2466  okChildPath("ddeExec", params);
2467  }
2469 
2470  delete_test_association(".sde");
2471  test++;
2472  }
2473 
2474  UnmapViewOfFile(shared_block);
2475  CloseHandle(map);
2477 }
#define SEE_MASK_FLAG_DDEWAIT
Definition: shellapi.h:34
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
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:674
#define MapViewOfFile
Definition: compat.h:410
#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:2303
#define okChildIntBroken(key, expected)
Definition: shlexec.c:469
#define okChildInt(key, expected)
Definition: shlexec.c:460
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
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:63
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:435
#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:52
#define trace
Definition: atltest.h:70
static dde_tests_t dde_tests[]
Definition: shlexec.c:2274
static void reset_association_description(void)
Definition: shlexec.c:365
#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:805
#define SZDDESYS_TOPIC
Definition: ddeml.h:47
static int waitforinputidle_count
Definition: shlexec.c:2302
static char argv0[MAX_PATH]
Definition: shlexec.c:49
#define okShell
Definition: shlexec.c:362
#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:814
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define skip(...)
Definition: atltest.h:64
#define okChildPath(key, expected)
Definition: shlexec.c:451
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:2321
#define CHILD_DDE_TIMEOUT
Definition: shlexec.c:146
static HANDLE dde_ready_event
Definition: shlexec.c:57
#define UnmapViewOfFile
Definition: compat.h:411
static BOOL create_test_association(const char *extension)
Definition: shlexec.c:712
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:149

Referenced by START_TEST().

◆ test_dde_default_app()

static void test_dde_default_app ( void  )
static

Definition at line 2549 of file shlexec.c.

2550 {
2551  char filename[MAX_PATH];
2552  HSZ hszApplication;
2555  char params[1024];
2556  DWORD threadId;
2557  MSG msg;
2558  INT_PTR rc;
2559  int which = 0;
2560  HDDEDATA ret;
2561  BOOL b;
2562 
2564  ddeInst = 0;
2567  ok(rc == DMLERR_NO_ERROR, "got %lx\n", rc);
2568 
2569  sprintf(filename, "%s\\test file.sde", tmpdir);
2570 
2571  /* It is strictly not necessary to register an application name here, but wine's
2572  * DdeNameService implementation complains if 0 is passed instead of
2573  * hszApplication with DNS_FILTEROFF */
2574  hszApplication = DdeCreateStringHandleA(ddeInst, "shlexec", CP_WINANSI);
2576  ok(hszApplication && hszTopic, "got %p and %p\n", hszApplication, hszTopic);
2577  ret = DdeNameService(ddeInst, hszApplication, 0, DNS_REGISTER | DNS_FILTEROFF);
2578  ok(ret != 0, "got %p\n", ret);
2579 
2581  while (test->command)
2582  {
2583  HANDLE thread;
2584 
2585  if (!create_test_association(".sde"))
2586  {
2587  skip("Unable to create association for '.sde'\n");
2588  return;
2589  }
2590  sprintf(params, test->command, tmpdir);
2591  create_test_verb_dde("shlexec.sde", "Open", 1, params, "[test]", NULL,
2592  "shlexec", NULL);
2593  ddeApplication[0] = 0;
2594 
2595  /* No application will be run as we will respond to the first DDE event,
2596  * so don't wait for it */
2597  SetEvent(hEvent);
2598 
2599  thread = CreateThread(NULL, 0, ddeThread, &info, 0, &threadId);
2600  ok(thread != NULL, "got %p\n", thread);
2601  while (GetMessageA(&msg, NULL, 0, 0)) DispatchMessageA(&msg);
2602  rc = msg.wParam > 32 ? 33 : msg.wParam;
2603 
2604  /* The first two tests determine which set of results to expect.
2605  * First check the platform as only the first set of results is
2606  * acceptable for Wine.
2607  */
2608  if (strcmp(winetest_platform, "wine"))
2609  {
2610  if (test == dde_default_app_tests)
2611  {
2612  if (strcmp(ddeApplication, test->expectedDdeApplication[0]))
2613  which = 2;
2614  }
2615  else if (test == dde_default_app_tests + 1)
2616  {
2617  if (which == 0 && rc == test->rc[1])
2618  which = 1;
2619  trace("DDE result variant %d\n", which);
2620  }
2621  }
2622 
2623  todo_wine_if(test->todo & 0x1)
2624  okShell(rc==test->rc[which], "failed: rc=%lu err=%u\n",
2625  rc, GetLastError());
2626  if (rc == 33)
2627  {
2628  todo_wine_if(test->todo & 0x2)
2629  ok(!strcmp(ddeApplication, test->expectedDdeApplication[which]),
2630  "Expected application '%s', got '%s'\n",
2631  test->expectedDdeApplication[which], ddeApplication);
2632  }
2634 
2635  delete_test_association(".sde");
2636  test++;
2637  }
2638 
2639  ret = DdeNameService(ddeInst, hszApplication, 0, DNS_UNREGISTER);
2640  ok(ret != 0, "got %p\n", ret);
2642  ok(b, "got %d\n", b);
2643  b = DdeFreeStringHandle(ddeInst, hszApplication);
2644  ok(b, "got %d\n", b);
2646  ok(b, "got %d\n", b);
2647 }
#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:149
int32_t INT_PTR
Definition: typedefs.h:63
static HANDLE hEvent
Definition: shlexec.c:189
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:147
#define todo_wine_if(is_todo)
Definition: test.h:163
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define DNS_FILTEROFF
Definition: ddeml.h:155
static DWORD CALLBACK ddeThread(LPVOID arg)
Definition: shlexec.c:2538
static char tmpdir[MAX_PATH]
Definition: shlexec.c:52
#define trace
Definition: atltest.h:70
BOOL WINAPI DdeFreeStringHandle(DWORD, HSZ)
Definition: ddemisc.c:631
static void reset_association_description(void)
Definition: shlexec.c:365
static BOOL post_quit_on_execute
Definition: shlexec.c:150
#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:153
unsigned long DWORD
Definition: ntddk_ex.h:95
static void delete_test_association(const char *extension)
Definition: shlexec.c:805
static HANDLE thread
Definition: service.c:33
int ret
#define okShell
Definition: shlexec.c:362
static HSZ hszTopic
Definition: shlexec.c:148
#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:814
#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:2488
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static BOOL create_test_association(const char *extension)
Definition: shlexec.c:712
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 2808 of file shlexec.c.

2809 {
2810  char path[MAX_PATH], curdir[MAX_PATH];
2811  char params[1024], dirpath[1024];
2812  INT_PTR rc;
2813 
2814  sprintf(path, "%s\\test2.exe", tmpdir);
2816 
2817  sprintf(params, "shlexec \"%s\" Exec", child_file);
2818 
2819  /* Test with the current directory */
2820  GetCurrentDirectoryA(sizeof(curdir), curdir);
2823  NULL, "test2.exe", params, NULL, NULL);
2824  okShell(rc > 32, "returned %lu\n", rc);
2825  okChildInt("argcA", 4);
2826  okChildString("argvA3", "Exec");
2827  okChildPath("longPath", path);
2828  SetCurrentDirectoryA(curdir);
2829 
2831  NULL, "test2.exe", params, NULL, NULL);
2832  okShell(rc == SE_ERR_FNF, "returned %lu\n", rc);
2833 
2834  /* Explicitly specify the directory to use */
2836  NULL, "test2.exe", params, tmpdir, NULL);
2837  okShell(rc > 32, "returned %lu\n", rc);
2838  okChildInt("argcA", 4);
2839  okChildString("argvA3", "Exec");
2840  okChildPath("longPath", path);
2841 
2842  /* Specify it through an environment variable */
2844  NULL, "test2.exe", params, "%TMPDIR%", NULL);
2845  todo_wine okShell(rc == SE_ERR_FNF, "returned %lu\n", rc);
2846 
2848  NULL, "test2.exe", params, "%TMPDIR%", NULL);
2849  okShell(rc > 32, "returned %lu\n", rc);
2850  okChildInt("argcA", 4);
2851  okChildString("argvA3", "Exec");
2852  okChildPath("longPath", path);
2853 
2854  /* Not a colon-separated directory list */
2855  sprintf(dirpath, "%s:%s", curdir, tmpdir);
2857  NULL, "test2.exe", params, dirpath, NULL);
2858  okShell(rc == SE_ERR_FNF, "returned %lu\n", rc);
2859 }
#define shell_execute_ex(mask, verb, filename, parameters, directory, class)
Definition: shlexec.c:674
#define okChildInt(key, expected)
Definition: shlexec.c:460
BOOL WINAPI CopyFileA(IN LPCSTR lpExistingFileName, IN LPCSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:404
int32_t INT_PTR
Definition: typedefs.h:63
#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:383
#define SEE_MASK_NOZONECHECKS
Definition: shellapi.h:54
static char tmpdir[MAX_PATH]
Definition: shlexec.c:52
#define MAX_PATH
Definition: compat.h:26
#define SEE_MASK_DOENVSUBST
Definition: shellapi.h:35
#define todo_wine
Definition: test.h:162
BOOL WINAPI SetCurrentDirectoryA(IN LPCSTR lpPathName)
Definition: path.c:2205
static char argv0[MAX_PATH]
Definition: shlexec.c:49
#define okShell
Definition: shlexec.c:362
#define SE_ERR_FNF
Definition: shellapi.h:122
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
#define okChildPath(key, expected)
Definition: shlexec.c:451
static char child_file[MAX_PATH]
Definition: shlexec.c:53

Referenced by START_TEST().

◆ test_exes()

static void test_exes ( void  )
static

Definition at line 2204 of file shlexec.c.

2205 {
2206  char filename[MAX_PATH];
2207  char params[1024];
2208  INT_PTR rc;
2209 
2210  sprintf(params, "shlexec \"%s\" Exec", child_file);
2211 
2212  /* We need NOZONECHECKS on Win2003 to block a dialog */
2214  NULL, NULL);
2215  okShell(rc > 32, "returned %lu\n", rc);
2216  okChildInt("argcA", 4);
2217  okChildString("argvA3", "Exec");
2218 
2219  if (! skip_noassoc_tests)
2220  {
2221  sprintf(filename, "%s\\test file.noassoc", tmpdir);
2222  if (CopyFileA(argv0, filename, FALSE))
2223  {
2225  todo_wine {
2226  okShell(rc==SE_ERR_NOASSOC, "returned %lu\n", rc);
2227  }
2228  }
2229  }
2230  else
2231  {
2232  win_skip("Skipping shellexecute of file with unassociated extension\n");
2233  }
2234 
2235  /* test combining executable and parameters */
2236  sprintf(filename, "%s shlexec \"%s\" Exec", argv0, child_file);
2237  rc = shell_execute(NULL, filename, NULL, NULL);
2238  okShell(rc == SE_ERR_FNF, "returned %lu\n", rc);
2239 
2240  sprintf(filename, "\"%s\" shlexec \"%s\" Exec", argv0, child_file);
2241  rc = shell_execute(NULL, filename, NULL, NULL);
2242  okShell(rc == SE_ERR_FNF, "returned %lu\n", rc);
2243 
2244  /* A verb, even if invalid, overrides the normal handling of executables */
2246  "notaverb", argv0, NULL, NULL, NULL);
2247  todo_wine okShell(rc == SE_ERR_NOASSOC, "returned %lu\n", rc);
2248 
2249  if (!skip_shlexec_tests)
2250  {
2251  /* A class overrides the normal handling of executables too */
2252  /* FIXME SEE_MASK_FLAG_NO_UI is only needed due to Wine's bug */
2254  NULL, argv0, NULL, NULL, ".shlexec");
2255  todo_wine okShell(rc > 32, "returned %lu\n", rc);
2256  okChildInt("argcA", 5);
2257  todo_wine okChildString("argvA3", "Open");
2258  todo_wine okChildPath("argvA4", argv0);
2259  }
2260 }
#define shell_execute_ex(mask, verb, filename, parameters, directory, class)
Definition: shlexec.c:674
#define okChildInt(key, expected)
Definition: shlexec.c:460
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:569
int32_t INT_PTR
Definition: typedefs.h:63
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:383
#define SEE_MASK_NOZONECHECKS
Definition: shellapi.h:54
#define SEE_MASK_CLASSNAME
Definition: shellapi.h:25
static char tmpdir[MAX_PATH]
Definition: shlexec.c:52
#define MAX_PATH
Definition: compat.h:26
#define todo_wine
Definition: test.h:162
static char argv0[MAX_PATH]
Definition: shlexec.c:49
#define okShell
Definition: shlexec.c:362
#define SE_ERR_FNF
Definition: shellapi.h:122
#define todo_wait
Definition: shlexec.c:492
#define okChildPath(key, expected)
Definition: shlexec.c:451
static BOOL skip_noassoc_tests
Definition: shlexec.c:56
#define SE_ERR_NOASSOC
Definition: shellapi.h:132
#define win_skip
Definition: test.h:149
static BOOL skip_shlexec_tests
Definition: shlexec.c:55
static char child_file[MAX_PATH]
Definition: shlexec.c:53

Referenced by START_TEST().

◆ test_filename()

static void test_filename ( void  )
static

Definition at line 1603 of file shlexec.c.

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

Referenced by START_TEST().

◆ test_fileurls()

static void test_fileurls ( void  )
static

Definition at line 1786 of file shlexec.c.

1787 {
1788  char filename[MAX_PATH], fileurl[MAX_PATH], longtmpdir[MAX_PATH];
1789  char command[MAX_PATH];
1790  const fileurl_tests_t* test;
1791  char *s;
1792  INT_PTR rc;
1793 
1794  if (skip_shlexec_tests)
1795  {
1796  skip("No file URL tests due to lack of .shlexec association\n");
1797  return;
1798  }
1799 
1801  "file:///nosuchfile.shlexec", NULL, NULL, NULL);
1802  if (rc > 32)
1803  {
1804  win_skip("shell32 is too old (likely < 4.72). Skipping the file URL tests\n");
1805  return;
1806  }
1807 
1808  get_long_path_name(tmpdir, longtmpdir, ARRAY_SIZE(longtmpdir));
1809  SetEnvironmentVariableA("urlprefix", "file:///");
1810 
1812  while (test->basename)
1813  {
1814  /* Build the file URL */
1815  sprintf(filename, test->basename, longtmpdir);
1816  strcpy(fileurl, test->urlprefix);
1817  strcat(fileurl, filename);
1818  s = fileurl + strlen(test->urlprefix);
1819  while (*s)
1820  {
1821  if (!(test->flags & USE_COLON) && *s == ':')
1822  *s = '|';
1823  else if (!(test->flags & USE_BSLASH) && *s == '\\')
1824  *s = '/';
1825  s++;
1826  }
1827 
1828  /* Test it first with FindExecutable() */
1829  rc = (INT_PTR)FindExecutableA(fileurl, NULL, command);
1830  ok(rc == SE_ERR_FNF, "FindExecutable(%s) failed: bad rc=%lu\n", fileurl, rc);
1831 
1832  /* Then ShellExecute() */
1833  if ((test->todo & 0x10) == 0)
1834  rc = shell_execute(NULL, fileurl, NULL, NULL);
1835  else todo_wait
1836  rc = shell_execute(NULL, fileurl, NULL, NULL);
1837  if (bad_shellexecute)
1838  {
1839  win_skip("shell32 is too old (likely 4.72). Skipping the file URL tests\n");
1840  break;
1841  }
1842  if (test->flags & URL_SUCCESS)
1843  {
1844  todo_wine_if(test->todo & 0x1)
1845  okShell(rc > 32, "failed: bad rc=%lu\n", rc);
1846  }
1847  else
1848  {
1849  todo_wine_if(test->todo & 0x1)
1850  okShell(rc == SE_ERR_FNF || rc == SE_ERR_PNF ||
1851  broken(rc == SE_ERR_ACCESSDENIED) /* win2000 */,
1852  "failed: bad rc=%lu\n", rc);
1853  }
1854  if (rc == 33)
1855  {
1856  todo_wine_if(test->todo & 0x2)
1857  okChildInt("argcA", 5);
1858  todo_wine_if(test->todo & 0x4)
1859  okChildString("argvA3", "Open");
1860  todo_wine_if(test->todo & 0x8)
1861  okChildPath("argvA4", filename);
1862  }
1863  test++;
1864  }
1865 
1866  SetEnvironmentVariableA("urlprefix", NULL);
1867 }
#define USE_COLON
Definition: shlexec.c:1747
#define shell_execute_ex(mask, verb, filename, parameters, directory, class)
Definition: shlexec.c:674
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:1750
#define okChildInt(key, expected)
Definition: shlexec.c:460
_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:569
int32_t INT_PTR
Definition: typedefs.h:63
const char * filename
Definition: ioapi.h:135
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define URL_SUCCESS
Definition: shlexec.c:1746
smooth NULL
Definition: ftsmooth.c:416
#define SEE_MASK_FLAG_NO_UI
Definition: shellapi.h:36
#define okChildString(key, expected)
Definition: shlexec.c:383
#define todo_wine_if(is_todo)
Definition: test.h:163
static char tmpdir[MAX_PATH]
Definition: shlexec.c:52
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:1748
static DWORD get_long_path_name(const char *shortpath, char *longpath, DWORD longlen)
Definition: shlexec.c:930
HINSTANCE WINAPI FindExecutableA(LPCSTR lpFile, LPCSTR lpDirectory, LPSTR lpResult)
Definition: shlexec.cpp:1223
GLdouble s
Definition: gl.h:2039
#define okShell
Definition: shlexec.c:362
#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:492
#define okChildPath(key, expected)
Definition: shlexec.c:451
static int bad_shellexecute
Definition: shlexec.c:494
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define win_skip
Definition: test.h:149
static BOOL skip_shlexec_tests
Definition: shlexec.c:55

Referenced by START_TEST().

◆ test_find_executable()

static void test_find_executable ( void  )
static

Definition at line 1963 of file shlexec.c.

1964 {
1965  char notepad_path[MAX_PATH];
1966  char filename[MAX_PATH];
1967  char command[MAX_PATH];
1968  const filename_tests_t* test;
1969  INT_PTR rc;
1970 
1971  if (!create_test_association(".sfe"))
1972  {
1973  skip("Unable to create association for '.sfe'\n");
1974  return;
1975  }
1976  create_test_verb("shlexec.sfe", "Open", 1, "%1");
1977 
1978  /* Don't test FindExecutable(..., NULL), it always crashes */
1979 
1980  strcpy(command, "your word");
1981  if (0) /* Can crash on Vista! */
1982  {
1984  ok(rc == SE_ERR_FNF || rc > 32 /* nt4 */, "FindExecutable(NULL) returned %ld\n", rc);
1985  ok(strcmp(command, "your word") != 0, "FindExecutable(NULL) returned command=[%s]\n", command);
1986  }
1987 
1988  GetSystemDirectoryA( notepad_path, MAX_PATH );
1989  strcat( notepad_path, "\\notepad.exe" );
1990 
1991  /* Search for something that should be in the system-wide search path (no default directory) */
1992  strcpy(command, "your word");
1993  rc=(INT_PTR)FindExecutableA("notepad.exe", NULL, command);
1994  ok(rc > 32, "FindExecutable(%s) returned %ld\n", "notepad.exe", rc);
1995  ok(strcasecmp(command, notepad_path) == 0, "FindExecutable(%s) returned command=[%s]\n", "notepad.exe", command);
1996 
1997  /* Search for something that should be in the system-wide search path (with default directory) */
1998  strcpy(command, "your word");
1999  rc=(INT_PTR)FindExecutableA("notepad.exe", tmpdir, command);
2000  ok(rc > 32, "FindExecutable(%s) returned %ld\n", "notepad.exe", rc);
2001  ok(strcasecmp(command, notepad_path) == 0, "FindExecutable(%s) returned command=[%s]\n", "notepad.exe", command);
2002 
2003  strcpy(command, "your word");
2005  ok(rc == SE_ERR_NOASSOC /* >= win2000 */ || rc > 32 /* win98, nt4 */, "FindExecutable(NULL) returned %ld\n", rc);
2006  ok(strcmp(command, "your word") != 0, "FindExecutable(NULL) returned command=[%s]\n", command);
2007 
2008  sprintf(filename, "%s\\test file.sfe", tmpdir);
2010  ok(rc > 32, "FindExecutable(%s) returned %ld\n", filename, rc);
2011  /* Depending on the platform, command could be '%1' or 'test file.sfe' */
2012 
2013  rc=(INT_PTR)FindExecutableA("test file.sfe", tmpdir, command);
2014  ok(rc > 32, "FindExecutable(%s) returned %ld\n", filename, rc);
2015 
2016  rc=(INT_PTR)FindExecutableA("test file.sfe", NULL, command);
2017  ok(rc == SE_ERR_FNF, "FindExecutable(%s) returned %ld\n", filename, rc);
2018 
2019  delete_test_association(".sfe");
2020 
2021  if (!create_test_association(".shl"))
2022  {
2023  skip("Unable to create association for '.shl'\n");
2024  return;
2025  }
2026  create_test_verb("shlexec.shl", "Open", 0, "Open");
2027 
2028  sprintf(filename, "%s\\test file.shl", tmpdir);
2030  ok(rc == SE_ERR_FNF /* NT4 */ || rc > 32, "FindExecutable(%s) returned %ld\n", filename, rc);
2031 
2032  sprintf(filename, "%s\\test file.shlfoo", tmpdir);
2034 
2035  delete_test_association(".shl");
2036 
2037  if (rc > 32)
2038  {
2039  /* On Windows XP and 2003 FindExecutable() is completely broken.
2040  * Probably what it does is convert the filename to 8.3 format,
2041  * which as a side effect converts the '.shlfoo' extension to '.shl',
2042  * and then tries to find an association for '.shl'. This means it
2043  * will normally fail on most extensions with more than 3 characters,
2044  * like '.mpeg', etc.
2045  * Also it means we cannot do any other test.
2046  */
2047  win_skip("FindExecutable() is broken -> not running 4+ character extension tests\n");
2048  return;
2049  }
2050 
2051  if (skip_shlexec_tests)
2052  {
2053  skip("No FindExecutable/filename tests due to lack of .shlexec association\n");
2054  return;
2055  }
2056 
2058  while (test->basename)
2059  {
2060  sprintf(filename, test->basename, tmpdir);
2061  if (strchr(filename, '/'))
2062  {
2063  char* c;
2064  c=filename;
2065  while (*c)
2066  {
2067  if (*c=='\\')
2068  *c='/';
2069  c++;
2070  }
2071  }
2072  /* Win98 does not '\0'-terminate command! */
2073  memset(command, '\0', sizeof(command));
2075  if (rc > 32)
2076  rc=33;
2077  todo_wine_if(test->todo & 0x10)
2078  ok(rc==test->rc, "FindExecutable(%s) failed: rc=%ld\n", filename, rc);
2079  if (rc > 32)
2080  {
2081  BOOL equal;
2082  equal=strcmp(command, argv0) == 0 ||
2083  /* NT4 returns an extra 0x8 character! */
2084  (strlen(command) == strlen(argv0)+1 && strncmp(command, argv0, strlen(argv0)) == 0);
2085  todo_wine_if(test->todo & 0x20)
2086  ok(equal, "FindExecutable(%s) returned command='%s' instead of '%s'\n",
2087  filename, command, argv0);
2088  }
2089  test++;
2090  }
2091 }
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:63
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:915
unsigned int BOOL
Definition: ntddk_ex.h:94
static filename_tests_t filename_tests[]
Definition: shlexec.c:1039
smooth NULL
Definition: ftsmooth.c:416
#define todo_wine_if(is_todo)
Definition: test.h:163
static char tmpdir[MAX_PATH]
Definition: shlexec.c:52
#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:805
HINSTANCE WINAPI FindExecutableA(LPCSTR lpFile, LPCSTR lpDirectory, LPSTR lpResult)
Definition: shlexec.cpp:1223
static char argv0[MAX_PATH]
Definition: shlexec.c:49
#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:712
#define win_skip
Definition: test.h:149
static BOOL skip_shlexec_tests
Definition: shlexec.c:55

Referenced by START_TEST().

◆ test_lnks()

static void test_lnks ( void  )
static

Definition at line 2110 of file shlexec.c.

2111 {
2112  char filename[MAX_PATH];
2113  char params[MAX_PATH];
2114  const filename_tests_t* test;
2115  INT_PTR rc;
2116 
2117  if (skip_shlexec_tests)
2118  skip("No FindExecutable/filename tests due to lack of .shlexec association\n");
2119  else
2120  {
2121  /* Should open through our association */
2122  sprintf(filename, "%s\\test_shortcut_shlexec.lnk", tmpdir);
2124  okShell(rc > 32, "failed: rc=%lu err=%u\n", rc, GetLastError());
2125  okChildInt("argcA", 5);
2126  okChildString("argvA3", "Open");
2127  sprintf(params, "%s\\test file.shlexec", tmpdir);
2129  okChildPath("argvA4", filename);
2130 
2131  rc=shell_execute_ex(SEE_MASK_NOZONECHECKS|SEE_MASK_DOENVSUBST, NULL, "%TMPDIR%\\test_shortcut_shlexec.lnk", NULL, NULL, NULL);
2132  okShell(rc > 32, "failed: rc=%lu err=%u\n", rc, GetLastError());
2133  okChildInt("argcA", 5);
2134  okChildString("argvA3", "Open");
2135  sprintf(params, "%s\\test file.shlexec", tmpdir);
2137  okChildPath("argvA4", filename);
2138  }
2139 
2140  /* Should just run our executable */
2141  sprintf(filename, "%s\\test_shortcut_exe.lnk", tmpdir);
2143  okShell(rc > 32, "failed: rc=%lu err=%u\n", rc, GetLastError());
2144  okChildInt("argcA", 4);
2145  okChildString("argvA3", "Lnk");
2146 
2147  if (!skip_shlexec_tests)
2148  {
2149  /* An explicit class overrides lnk's ContextMenuHandler */
2151  okShell(rc > 32, "failed: rc=%lu err=%u\n", rc, GetLastError());
2152  okChildInt("argcA", 5);
2153  okChildString("argvA3", "Open");
2154  okChildPath("argvA4", filename);
2155  }
2156 
2157  if (dllver.dwMajorVersion>=6)
2158  {
2159  char* c;
2160  /* Recent versions of shell32.dll accept '/'s in shortcut paths.
2161  * Older versions don't or are quite buggy in this regard.
2162  */
2163  sprintf(filename, "%s\\test_shortcut_exe.lnk", tmpdir);
2164  c=filename;
2165  while (*c)
2166  {
2167  if (*c=='\\')
2168  *c='/';
2169  c++;
2170  }
2172  okShell(rc > 32, "failed: rc=%lu err=%u\n", rc, GetLastError());
2173  okChildInt("argcA", 4);
2174  okChildString("argvA3", "Lnk");
2175  }
2176 
2177  sprintf(filename, "%s\\test_shortcut_exe.lnk", tmpdir);
2178  test=lnk_tests;
2179  while (test->basename)
2180  {
2181  params[0]='\"';
2182  sprintf(params+1, test->basename, tmpdir);
2183  strcat(params,"\"");
2185  NULL, NULL);
2186  if (rc > 32)
2187  rc=33;
2188  todo_wine_if(test->todo & 0x1)
2189  okShell(rc==test->rc, "failed: rc=%lu err=%u\n", rc, GetLastError());
2190  if (rc==0)
2191  {
2192  todo_wine_if(test->todo & 0x2)
2193  okChildInt("argcA", 5);
2194  todo_wine_if(test->todo & 0x4)
2195  okChildString("argvA3", "Lnk");
2196  sprintf(params, test->basename, tmpdir);
2197  okChildPath("argvA4", params);
2198  }
2199  test++;
2200  }
2201 }
#define shell_execute_ex(mask, verb, filename, parameters, directory, class)
Definition: shlexec.c:674
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
#define okChildInt(key, expected)
Definition: shlexec.c:460
_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:63
const char * filename
Definition: ioapi.h:135
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static DLLVERSIONINFO dllver
Definition: shlexec.c:54
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:383
#define todo_wine_if(is_todo)
Definition: test.h:163
#define SEE_MASK_NOZONECHECKS
Definition: shellapi.h:54
#define SEE_MASK_CLASSNAME
Definition: shellapi.h:25
static char tmpdir[MAX_PATH]
Definition: shlexec.c:52
#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:930
#define okShell
Definition: shlexec.c:362
_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:451
#define c
Definition: ke_i.h:80
static filename_tests_t lnk_tests[]
Definition: shlexec.c:2094
static BOOL skip_shlexec_tests
Definition: shlexec.c:55

Referenced by START_TEST().

◆ test_lpFile_parsed()

static void test_lpFile_parsed ( void  )
static

Definition at line 1092 of file shlexec.c.

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