ReactOS 0.4.15-dev-8219-ge8b88cf
PathResolve.cpp File Reference
#include "shelltest.h"
#include <stdio.h>
#include <assert.h>
Include dependency graph for PathResolve.cpp:

Go to the source code of this file.

Classes

struct  tagTEST_ENTRY
 

Macros

#define PRF_VERIFYEXISTS   0x01
 
#define PRF_EXECUTABLE   0x02
 
#define PRF_TRYPROGRAMEXTENSIONS   (PRF_EXECUTABLE | PRF_VERIFYEXISTS)
 
#define PRF_FIRSTDIRDEF   0x04
 
#define PRF_DONTFINDLNK   0x08
 
#define PRF_REQUIREABSOLUTE   0x10
 
#define FLAGS0   0
 
#define FLAGS1   PRF_VERIFYEXISTS
 
#define FLAGS2   PRF_EXECUTABLE
 
#define FLAGS3   PRF_TRYPROGRAMEXTENSIONS
 
#define FLAGS4   (PRF_FIRSTDIRDEF | PRF_VERIFYEXISTS)
 
#define FLAGS5   (PRF_FIRSTDIRDEF | PRF_EXECUTABLE)
 
#define FLAGS6   (PRF_FIRSTDIRDEF | PRF_TRYPROGRAMEXTENSIONS)
 
#define FLAGS7   (PRF_REQUIREABSOLUTE | PRF_VERIFYEXISTS)
 
#define FLAGS8   (PRF_REQUIREABSOLUTE | PRF_EXECUTABLE)
 
#define FLAGS9   (PRF_REQUIREABSOLUTE | PRF_TRYPROGRAMEXTENSIONS)
 
#define FLAGS10   (PRF_REQUIREABSOLUTE | PRF_FIRSTDIRDEF | PRF_VERIFYEXISTS)
 
#define FLAGS11   (PRF_REQUIREABSOLUTE | PRF_FIRSTDIRDEF | PRF_EXECUTABLE)
 
#define FLAGS12   (PRF_REQUIREABSOLUTE | PRF_FIRSTDIRDEF | PRF_TRYPROGRAMEXTENSIONS)
 
#define FLAGS13   0xFFFFFFFF
 
#define EF_FULLPATH   0x01
 
#define EF_TESTDATA   0x02
 
#define EF_TYPE_MASK   0x0F
 
#define EF_NAME_ONLY   0x10
 
#define EF_APP_PATH   0x20
 
#define RET_IGNORE   0x00BEF00D
 
#define ERR_NO_CHANGE   0xBEEF /* Error Code 48879 */
 
#define ERR_DEAD   0xDEAD /* Error Code 57005 */
 
#define ERR_IGNORE   0x7F7F7F7F /* Ignore Error Code */
 
#define RAISED   9999 /* exception raised */
 

Typedefs

typedef int(WINAPIPATHRESOLVE) (LPWSTR, LPWSTR *, UINT)
 
typedef BOOL(WINAPIISLFNDRIVEW) (LPCWSTR)
 
typedef struct tagTEST_ENTRY TEST_ENTRY
 
typedef struct tagTEST_ENTRYPTEST_ENTRY
 

Functions

static BOOL CreateShortcut (LPCWSTR pszLnkFileName, LPCWSTR pszTargetPathName)
 
static BOOL CreateRegAppPath (INT SectionNumber, INT LineNumber, const WCHAR *Name, const WCHAR *Value)
 
static BOOL DeleteRegAppPath (INT SectionNumber, INT LineNumber, const WCHAR *Name)
 
static void DoEntry (INT SectionNumber, INT LineNumber, const TEST_ENTRY *pEntry)
 
static void TestMain_PathResolve (void)
 
 START_TEST (PathResolve)
 

Variables

static HINSTANCE s_hShell32 = NULL
 
static PATHRESOLVE s_pPathResolve = NULL
 
static ISLFNDRIVEW s_pIsLFNDriveW = NULL
 
static WCHAR s_TestDir [MAX_PATH]
 
static WCHAR s_TestDirWithBackslash [MAX_PATH]
 
static WCHAR s_ShortcutLongName [MAX_PATH]
 
static WCHAR s_LinkTarget [MAX_PATH]
 
static WCHAR s_LinkTargetWithBackslash [MAX_PATH]
 
static WCHAR s_LinkTargetDoubleBackslash [MAX_PATH]
 
static LPWSTR s_Dirs [2] = { s_TestDir, NULL }
 
static LPWSTR s_DirsWithBackslash [2] = { s_TestDirWithBackslash, NULL }
 
static const TEST_ENTRY s_LFNEntries []
 

Macro Definition Documentation

◆ EF_APP_PATH

#define EF_APP_PATH   0x20

Definition at line 82 of file PathResolve.cpp.

◆ EF_FULLPATH

#define EF_FULLPATH   0x01

Definition at line 78 of file PathResolve.cpp.

◆ EF_NAME_ONLY

#define EF_NAME_ONLY   0x10

Definition at line 81 of file PathResolve.cpp.

◆ EF_TESTDATA

#define EF_TESTDATA   0x02

Definition at line 79 of file PathResolve.cpp.

◆ EF_TYPE_MASK

#define EF_TYPE_MASK   0x0F

Definition at line 80 of file PathResolve.cpp.

◆ ERR_DEAD

#define ERR_DEAD   0xDEAD /* Error Code 57005 */

Definition at line 88 of file PathResolve.cpp.

◆ ERR_IGNORE

#define ERR_IGNORE   0x7F7F7F7F /* Ignore Error Code */

Definition at line 89 of file PathResolve.cpp.

◆ ERR_NO_CHANGE

#define ERR_NO_CHANGE   0xBEEF /* Error Code 48879 */

Definition at line 87 of file PathResolve.cpp.

◆ FLAGS0

#define FLAGS0   0

Definition at line 49 of file PathResolve.cpp.

◆ FLAGS1

#define FLAGS1   PRF_VERIFYEXISTS

Definition at line 50 of file PathResolve.cpp.

◆ FLAGS10

Definition at line 59 of file PathResolve.cpp.

◆ FLAGS11

Definition at line 60 of file PathResolve.cpp.

◆ FLAGS12

Definition at line 61 of file PathResolve.cpp.

◆ FLAGS13

#define FLAGS13   0xFFFFFFFF

Definition at line 62 of file PathResolve.cpp.

◆ FLAGS2

#define FLAGS2   PRF_EXECUTABLE

Definition at line 51 of file PathResolve.cpp.

◆ FLAGS3

Definition at line 52 of file PathResolve.cpp.

◆ FLAGS4

Definition at line 53 of file PathResolve.cpp.

◆ FLAGS5

Definition at line 54 of file PathResolve.cpp.

◆ FLAGS6

Definition at line 55 of file PathResolve.cpp.

◆ FLAGS7

Definition at line 56 of file PathResolve.cpp.

◆ FLAGS8

Definition at line 57 of file PathResolve.cpp.

◆ FLAGS9

Definition at line 58 of file PathResolve.cpp.

◆ PRF_DONTFINDLNK

#define PRF_DONTFINDLNK   0x08

Definition at line 42 of file PathResolve.cpp.

◆ PRF_EXECUTABLE

#define PRF_EXECUTABLE   0x02

Definition at line 39 of file PathResolve.cpp.

◆ PRF_FIRSTDIRDEF

#define PRF_FIRSTDIRDEF   0x04

Definition at line 41 of file PathResolve.cpp.

◆ PRF_REQUIREABSOLUTE

#define PRF_REQUIREABSOLUTE   0x10

Definition at line 45 of file PathResolve.cpp.

◆ PRF_TRYPROGRAMEXTENSIONS

#define PRF_TRYPROGRAMEXTENSIONS   (PRF_EXECUTABLE | PRF_VERIFYEXISTS)

Definition at line 40 of file PathResolve.cpp.

◆ PRF_VERIFYEXISTS

#define PRF_VERIFYEXISTS   0x01

Definition at line 38 of file PathResolve.cpp.

◆ RAISED

#define RAISED   9999 /* exception raised */

Definition at line 90 of file PathResolve.cpp.

◆ RET_IGNORE

#define RET_IGNORE   0x00BEF00D

Definition at line 84 of file PathResolve.cpp.

Typedef Documentation

◆ ISLFNDRIVEW

typedef BOOL(WINAPI * ISLFNDRIVEW) (LPCWSTR)

Definition at line 22 of file PathResolve.cpp.

◆ PATHRESOLVE

typedef int(WINAPI * PATHRESOLVE) (LPWSTR, LPWSTR *, UINT)

Definition at line 19 of file PathResolve.cpp.

◆ PTEST_ENTRY

◆ TEST_ENTRY

Function Documentation

◆ CreateRegAppPath()

static BOOL CreateRegAppPath ( INT  SectionNumber,
INT  LineNumber,
const WCHAR Name,
const WCHAR Value 
)
static

Definition at line 609 of file PathResolve.cpp.

610{
611 HKEY RegistryKey;
612 LONG Result;
613 WCHAR Buffer[1024];
615
616 wcscpy(Buffer, L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\");
619 0, KEY_WRITE, NULL, &RegistryKey, &Disposition);
620 if (Result != ERROR_SUCCESS)
621 {
622 trace("Section %d, Line %d: Could not create test key. Status: %lu\n",
623 SectionNumber, LineNumber, Result);
624 return FALSE;
625 }
626 Result = RegSetValueW(RegistryKey, NULL, REG_SZ, Value, 0);
627 if (Result != ERROR_SUCCESS)
628 {
629 trace("Section %d, Line %d: Could not set value of the test key. Status: %lu\n",
630 SectionNumber, LineNumber, Result);
631 RegCloseKey(RegistryKey);
632 return FALSE;
633 }
634 RegCloseKey(RegistryKey);
635 return TRUE;
636}
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 LineNumber
Definition: acpixf.h:1220
#define trace
Definition: atltest.h:70
#define RegCloseKey(hKey)
Definition: registry.h:49
Definition: bufpool.h:45
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegSetValueW(HKEY hKeyOriginal, LPCWSTR lpSubKey, DWORD dwType, LPCWSTR lpData, DWORD cbData)
Definition: reg.c:5000
unsigned long DWORD
Definition: ntddk_ex.h:95
#define REG_SZ
Definition: layer.c:22
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:56
#define KEY_WRITE
Definition: nt_native.h:1031
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by DoEntry().

◆ CreateShortcut()

static BOOL CreateShortcut ( LPCWSTR  pszLnkFileName,
LPCWSTR  pszTargetPathName 
)
static

Definition at line 578 of file PathResolve.cpp.

580{
581 IPersistFile *ppf;
582 IShellLinkW* psl;
584
586 if (SUCCEEDED(hres))
587 {
588 hres = CoCreateInstance(CLSID_ShellLink, NULL,
589 CLSCTX_INPROC_SERVER, IID_IShellLinkW, (LPVOID*)&psl);
590 if (SUCCEEDED(hres))
591 {
592 psl->SetPath(pszTargetPathName);
594 if (SUCCEEDED(hres))
595 {
596 hres = ppf->Save(pszLnkFileName, TRUE);
597 ppf->Release();
598 }
599 psl->Release();
600 }
602 }
604
605 return SUCCEEDED(hres);
606}
#define SetLastError(x)
Definition: compat.h:752
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
HRESULT SetPath([in] LPCWSTR pszFile)
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
ULONG Release()
nsrefcnt Release()
#define SUCCEEDED(hr)
Definition: intsafe.h:50
HRESULT hres
Definition: protocol.c:465
const GUID IID_IPersistFile

Referenced by START_TEST().

◆ DeleteRegAppPath()

static BOOL DeleteRegAppPath ( INT  SectionNumber,
INT  LineNumber,
const WCHAR Name 
)
static

Definition at line 639 of file PathResolve.cpp.

640{
641 LONG Result;
642 WCHAR Buffer[1024];
643 wcscpy(Buffer, L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\");
646 if (Result != ERROR_SUCCESS)
647 {
648 trace("Section %d, Line %d: Could not remove the test key. Status: %lu\n",
649 SectionNumber, LineNumber, Result);
650 return FALSE;
651 }
652 return TRUE;
653}
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239

Referenced by DoEntry().

◆ DoEntry()

static void DoEntry ( INT  SectionNumber,
INT  LineNumber,
const TEST_ENTRY pEntry 
)
static

Definition at line 655 of file PathResolve.cpp.

656{
657 WCHAR Path[MAX_PATH], PathExpected[MAX_PATH];
658 INT Ret;
659 DWORD Error;
660
661 ZeroMemory(Path, sizeof(Path));
662 ZeroMemory(PathExpected, sizeof(PathExpected));
663
664 if (pEntry->NameBefore == NULL)
665 {
666 assert(pEntry->NameExpected == NULL);
667 }
668
669 switch (pEntry->EF_ & EF_TYPE_MASK)
670 {
671 case EF_FULLPATH:
672 if (pEntry->NameBefore)
673 {
674 lstrcpyW(Path, pEntry->NameBefore);
675 }
676 if (pEntry->NameExpected)
677 {
678 lstrcpyW(PathExpected, pEntry->NameExpected);
679 }
680 break;
681
682 case EF_TESTDATA:
683 if (pEntry->EF_ & EF_NAME_ONLY)
684 {
685 lstrcpyW(Path, pEntry->NameBefore);
686 }
687 else
688 {
690 lstrcatW(Path, L"\\");
691 lstrcatW(Path, pEntry->NameBefore);
692 }
693
694 if (pEntry->NameExpected)
695 {
696 lstrcpyW(PathExpected, s_TestDir);
697 lstrcatW(PathExpected, L"\\");
698 lstrcatW(PathExpected, pEntry->NameExpected);
699 }
700 break;
701
702 default:
703 assert(0);
704 break;
705 }
706
707 if (pEntry->EF_ & EF_APP_PATH)
708 {
709 if (!CreateRegAppPath(SectionNumber, LineNumber, pEntry->NameBefore, PathExpected))
710 {
711 skip("Section %d, Line %d: CreateRegAppPath failure\n", SectionNumber, LineNumber);
712 return;
713 }
714 }
715
717 {
719 if (pEntry->NameBefore)
720 {
721 Ret = (*s_pPathResolve)(Path, pEntry->Dirs, pEntry->Flags);
722 }
723 else
724 {
725 Ret = (*s_pPathResolve)(NULL, pEntry->Dirs, pEntry->Flags);
726 }
728 }
730 {
731 Ret = RAISED;
732 Error = ERR_DEAD;
733 }
734 _SEH2_END;
735
736 if (pEntry->EF_ & EF_APP_PATH)
737 {
738 ok(DeleteRegAppPath(SectionNumber, LineNumber, pEntry->NameBefore),
739 "Section %d, Line %d: DeleteRegAppPath failed\n", SectionNumber, LineNumber);
740 }
741
742 if (pEntry->Ret != RET_IGNORE)
743 {
744 ok(Ret == pEntry->Ret, "Section %d, Line %d: Ret expected %d, was %d.\n",
745 SectionNumber, LineNumber, pEntry->Ret, Ret);
746 }
747
748 if (pEntry->Error != ERR_IGNORE)
749 {
750 ok(Error == pEntry->Error, "Section %d, Line %d: last error expected %ld, was %ld.\n",
751 SectionNumber, LineNumber, pEntry->Error, Error);
752 }
753
754 if (pEntry->NameExpected && !(pEntry->EF_ & EF_APP_PATH))
755 {
756 char expected[MAX_PATH];
757 char path[MAX_PATH];
758
761
762 ok(lstrcmpW(Path, PathExpected) == 0, "Section %d, Line %d: Path expected %s, was %s.\n",
763 SectionNumber, LineNumber, expected, path);
764 }
765}
#define EF_FULLPATH
Definition: PathResolve.cpp:78
#define ERR_NO_CHANGE
Definition: PathResolve.cpp:87
#define EF_NAME_ONLY
Definition: PathResolve.cpp:81
static BOOL DeleteRegAppPath(INT SectionNumber, INT LineNumber, const WCHAR *Name)
#define EF_TYPE_MASK
Definition: PathResolve.cpp:80
#define ERR_DEAD
Definition: PathResolve.cpp:88
#define ERR_IGNORE
Definition: PathResolve.cpp:89
#define RET_IGNORE
Definition: PathResolve.cpp:84
#define RAISED
Definition: PathResolve.cpp:90
#define EF_APP_PATH
Definition: PathResolve.cpp:82
static WCHAR s_TestDir[MAX_PATH]
Definition: PathResolve.cpp:27
static BOOL CreateRegAppPath(INT SectionNumber, INT LineNumber, const WCHAR *Name, const WCHAR *Value)
#define EF_TESTDATA
Definition: PathResolve.cpp:79
PRTL_UNICODE_STRING_BUFFER Path
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
BOOL Error
Definition: chkdsk.c:66
#define lstrcpynA
Definition: compat.h:751
#define MAX_PATH
Definition: compat.h:34
#define lstrcpyW
Definition: compat.h:749
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4242
#define assert(x)
Definition: debug.h:53
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define wine_dbgstr_w
Definition: kernel32.h:34
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
BOOL expected
Definition: store.c:2063
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _countof(array)
Definition: sndvol32.h:70
int32_t INT
Definition: typedefs.h:58
#define ZeroMemory
Definition: winbase.h:1712
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by TestMain_PathResolve().

◆ START_TEST()

START_TEST ( PathResolve  )

Definition at line 831 of file PathResolve.cpp.

832{
833 LPWSTR pch;
834 WCHAR szRoot[MAX_PATH];
835
836 /* Get this program's path */
838
839 /* Add '\testdir' to the path */
840 pch = wcsrchr(s_TestDir, L'\\');
841 if (pch == NULL)
842 {
843 skip("GetModuleFileName and/or wcsrchr are insane.\n");
844 return;
845 }
846 lstrcpyW(pch, L"\\testdir");
847
848 /* Create the testdir directory */
851 {
852 skip("testdir is not found.\n");
853 return;
854 }
855
856 /* Build s_TestDirWithBackslash path */
859
860 /* Build s_LinkTarget path */
862 lstrcatW(s_LinkTarget, L"\\");
863 lstrcatW(s_LinkTarget, L"2PRONG.txt");
864
865 /* Create the file */
867 ok(GetFileAttributesW(s_LinkTarget) != INVALID_FILE_ATTRIBUTES, "s_LinkTarget not found\n");
868
869 /* Build s_LinkTargetWithBackslash path */
874
875 /* Build s_LinkTargetDoubleBackslash path */
879
880 /* Build s_ShortcutLongName path */
883 lstrcatW(s_ShortcutLongName, L"CmdLineUtils.lnk"); /* in Long File Name */
884
885 /* Create s_ShortcutLongName shortcut file */
887 "CreateShortcut(%s, %s) failed.\n",
889
890 /* Load shell32.dll */
891 s_hShell32 = LoadLibraryA("shell32");
892 if (s_hShell32 == NULL)
893 {
894 skip("Unable to load shell32.\n");
895 goto Cleanup;
896 }
897
898 /* Get PathResolve procedure */
900 if (s_pPathResolve == NULL)
901 {
902 skip("Unable to get PathResolve address.\n");
903 goto Cleanup;
904 }
905
906 /* Get IsLFNDriveW procedure */
908 if (s_pIsLFNDriveW == NULL)
909 {
910 skip("Unable to get IsLFNDriveW address.\n");
911 goto Cleanup;
912 }
913
914 /* Is LFN supported? */
915 lstrcpyW(szRoot, s_TestDir);
916 PathStripToRootW(szRoot);
917 if (!s_pIsLFNDriveW(szRoot))
918 {
919 skip("LFN is not supported in this drive %s.\n", wine_dbgstr_w(szRoot));
920 goto Cleanup;
921 }
922
923 /* Do tests */
925
926 /* Clean up */
927Cleanup:
932}
static WCHAR s_LinkTarget[MAX_PATH]
Definition: PathResolve.cpp:30
static void TestMain_PathResolve(void)
static WCHAR s_LinkTargetWithBackslash[MAX_PATH]
Definition: PathResolve.cpp:31
static ISLFNDRIVEW s_pIsLFNDriveW
Definition: PathResolve.cpp:26
static WCHAR s_LinkTargetDoubleBackslash[MAX_PATH]
Definition: PathResolve.cpp:32
BOOL(WINAPI * ISLFNDRIVEW)(LPCWSTR)
Definition: PathResolve.cpp:22
int(WINAPI * PATHRESOLVE)(LPWSTR, LPWSTR *, UINT)
Definition: PathResolve.cpp:19
static BOOL CreateShortcut(LPCWSTR pszLnkFileName, LPCWSTR pszTargetPathName)
static PATHRESOLVE s_pPathResolve
Definition: PathResolve.cpp:25
static WCHAR s_TestDirWithBackslash[MAX_PATH]
Definition: PathResolve.cpp:28
static WCHAR s_ShortcutLongName[MAX_PATH]
Definition: PathResolve.cpp:29
static HINSTANCE s_hShell32
Definition: PathResolve.cpp:24
#define wcsrchr
Definition: compat.h:16
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
BOOL WINAPI PathStripToRootW(LPWSTR lpszPath)
Definition: path.c:733
static const WCHAR Cleanup[]
Definition: register.c:80
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
#define pch(ap)
Definition: match.c:418
int32_t INT_PTR
Definition: typedefs.h:64
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
const char * LPCSTR
Definition: xmlstorage.h:183
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ TestMain_PathResolve()

static void TestMain_PathResolve ( void  )
static

Definition at line 767 of file PathResolve.cpp.

768{
769 UINT i, cEntries;
770 const TEST_ENTRY *pEntries;
771 WCHAR Saved[128], *pPathExtSaved;
772
773 pEntries = s_LFNEntries;
775
776 /* save PATHEXT */
777 if (GetEnvironmentVariableW(L"PATHEXT", Saved, _countof(Saved)))
778 pPathExtSaved = Saved;
779 else
780 pPathExtSaved = NULL;
781
782 /* Section 1 */
783 for (i = 0; i < cEntries; ++i)
784 {
785 DoEntry(1, pEntries[i].LineNumber, &pEntries[i]);
786 }
787
788 /* Section 2: reset PATHEXT */
789 if (SetEnvironmentVariableW(L"PATHEXT", NULL))
790 {
791 for (i = 0; i < cEntries; ++i)
792 {
793 DoEntry(2, pEntries[i].LineNumber, &pEntries[i]);
794 }
795 }
796 else
797 {
798 skip("SetEnvironmentVariableW failed\n");
799 }
800
801 /* Section 3: set PATHEXT to ".COM;.EXE;.BAT" */
802 if (SetEnvironmentVariableW(L"PATHEXT", L".COM;.EXE;.BAT"))
803 {
804 for (i = 0; i < cEntries; ++i)
805 {
806 DoEntry(3, pEntries[i].LineNumber, &pEntries[i]);
807 }
808 }
809 else
810 {
811 skip("SetEnvironmentVariableW failed\n");
812 }
813
814 /* Section 4: set PATHEXT to ".TXT" */
815 if (SetEnvironmentVariableW(L"PATHEXT", L".TXT"))
816 {
817 for (i = 0; i < cEntries; ++i)
818 {
819 DoEntry(4, pEntries[i].LineNumber, &pEntries[i]);
820 }
821 }
822 else
823 {
824 skip("SetEnvironmentVariableW failed\n");
825 }
826
827 /* restore PATHEXT */
828 SetEnvironmentVariableW(L"PATHEXT", pPathExtSaved);
829}
static const TEST_ENTRY s_LFNEntries[]
Definition: PathResolve.cpp:93
static void DoEntry(INT SectionNumber, INT LineNumber, const TEST_ENTRY *pEntry)
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:755
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableW(IN LPCWSTR lpName, IN LPCWSTR lpValue)
Definition: environ.c:259
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
unsigned int UINT
Definition: ndis.h:50
Definition: cmd.c:13
_In_ UINT _In_ UINT cEntries
Definition: wingdi.h:3621

Referenced by START_TEST().

Variable Documentation

◆ s_Dirs

LPWSTR s_Dirs[2] = { s_TestDir, NULL }
static

Definition at line 33 of file PathResolve.cpp.

◆ s_DirsWithBackslash

LPWSTR s_DirsWithBackslash[2] = { s_TestDirWithBackslash, NULL }
static

Definition at line 34 of file PathResolve.cpp.

◆ s_hShell32

HINSTANCE s_hShell32 = NULL
static

Definition at line 24 of file PathResolve.cpp.

Referenced by START_TEST().

◆ s_LFNEntries

const TEST_ENTRY s_LFNEntries[]
static

Definition at line 93 of file PathResolve.cpp.

Referenced by TestMain_PathResolve().

◆ s_LinkTarget

WCHAR s_LinkTarget[MAX_PATH]
static

Definition at line 30 of file PathResolve.cpp.

Referenced by START_TEST().

◆ s_LinkTargetDoubleBackslash

WCHAR s_LinkTargetDoubleBackslash[MAX_PATH]
static

Definition at line 32 of file PathResolve.cpp.

Referenced by START_TEST().

◆ s_LinkTargetWithBackslash

WCHAR s_LinkTargetWithBackslash[MAX_PATH]
static

Definition at line 31 of file PathResolve.cpp.

Referenced by START_TEST().

◆ s_pIsLFNDriveW

ISLFNDRIVEW s_pIsLFNDriveW = NULL
static

Definition at line 26 of file PathResolve.cpp.

Referenced by START_TEST().

◆ s_pPathResolve

PATHRESOLVE s_pPathResolve = NULL
static

Definition at line 25 of file PathResolve.cpp.

Referenced by START_TEST().

◆ s_ShortcutLongName

WCHAR s_ShortcutLongName[MAX_PATH]
static

Definition at line 29 of file PathResolve.cpp.

Referenced by START_TEST().

◆ s_TestDir

WCHAR s_TestDir[MAX_PATH]
static

Definition at line 27 of file PathResolve.cpp.

Referenced by DoEntry(), and START_TEST().

◆ s_TestDirWithBackslash

WCHAR s_TestDirWithBackslash[MAX_PATH]
static

Definition at line 28 of file PathResolve.cpp.

Referenced by START_TEST().