ReactOS  0.4.14-dev-614-gbfd8a84
CShellLink.cpp File Reference
#include "precomp.h"
#include <appmgmt.h>
#include "pshpack1.h"
#include "poppack.h"
Include dependency graph for CShellLink.cpp:

Go to the source code of this file.

Classes

struct  LOCATION_INFO
 
struct  LOCAL_VOLUME_INFO
 
struct  volume_info
 

Macros

#define ICON_LINK_WINDOWS_COMPAT
 
#define SHLINK_LOCAL   0
 
#define SHLINK_REMOTE   1
 
#define LNK_EXT_INDEX   4
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
static HRESULT ShellLink_UpdatePath (LPCWSTR sPathRel, LPCWSTR path, LPCWSTR sWorkDir, LPWSTR *psPath)
 
static LPWSTR __inline HEAP_strdupAtoW (HANDLE heap, DWORD flags, LPCSTR str)
 
static LPWSTR __inline strdupW (LPCWSTR src)
 
static HRESULT Stream_LoadString (IStream *stm, BOOL unicode, LPWSTR *pstr)
 
static BOOL ShellLink_GetVolumeInfo (LPCWSTR path, CShellLink::volume_info *volume)
 
static HRESULT Stream_ReadChunk (IStream *stm, LPVOID *data)
 
static BOOL Stream_LoadVolume (LOCAL_VOLUME_INFO *vol, CShellLink::volume_info *volume)
 
static LPWSTR Stream_LoadPath (LPCSTR p, DWORD maxlen)
 
static HRESULT Stream_LoadLocation (IStream *stm, CShellLink::volume_info *volume, LPWSTR *path)
 
static HRESULT Stream_WriteString (IStream *stm, LPCWSTR str)
 
static HRESULT Stream_WriteLocationInfo (IStream *stm, LPCWSTR path, CShellLink::volume_info *volume)
 
static BOOL SHELL_ExistsFileW (LPCWSTR path)
 
static LPWSTR shelllink_get_msi_component_path (LPWSTR component)
 
static HRESULT SHELL_PidlGetIconLocationW (PCIDLIST_ABSOLUTE pidl, UINT uFlags, PWSTR pszIconFile, UINT cchMax, int *piIndex, UINT *pwFlags)
 
static LPWSTR GetAdvertisedArg (LPCWSTR str)
 
static BOOL HACKISH_PathResolve (IN OUT PWSTR pszPath, IN PZPCWSTR dirs OPTIONAL, IN UINT fFlags)
 
INT_PTR CALLBACK ExtendedShortcutProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
EXTERN_C HRESULT WINAPI SHOpenFolderAndSelectItems (LPITEMIDLIST pidlFolder, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD dwFlags)
 
LPWSTR SH_GetTargetTypeByPath (LPCWSTR lpcwFullPath)
 
HRESULT WINAPI IShellLink_ConstructFromPath (WCHAR *path, REFIID riid, LPVOID *ppv)
 
HRESULT WINAPI IShellLink_ConstructFromFile (IShellFolder *psf, LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv)
 

Macro Definition Documentation

◆ ICON_LINK_WINDOWS_COMPAT

#define ICON_LINK_WINDOWS_COMPAT

Definition at line 152 of file CShellLink.cpp.

◆ LNK_EXT_INDEX

#define LNK_EXT_INDEX   4

◆ SHLINK_LOCAL

#define SHLINK_LOCAL   0

Definition at line 154 of file CShellLink.cpp.

◆ SHLINK_REMOTE

#define SHLINK_REMOTE   1

Definition at line 155 of file CShellLink.cpp.

Function Documentation

◆ ExtendedShortcutProc()

INT_PTR CALLBACK ExtendedShortcutProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 2734 of file CShellLink.cpp.

2736 {
2737  switch(uMsg)
2738  {
2739  case WM_INITDIALOG:
2740  if (lParam)
2741  {
2742  HWND hDlgCtrl = GetDlgItem(hwndDlg, IDC_SHORTEX_RUN_DIFFERENT);
2743  SendMessage(hDlgCtrl, BM_SETCHECK, BST_CHECKED, 0);
2744  }
2745  return TRUE;
2746  case WM_COMMAND:
2747  {
2748  HWND hDlgCtrl = GetDlgItem(hwndDlg, IDC_SHORTEX_RUN_DIFFERENT);
2749  if (LOWORD(wParam) == IDOK)
2750  {
2751  if (SendMessage(hDlgCtrl, BM_GETCHECK, 0, 0) == BST_CHECKED)
2752  EndDialog(hwndDlg, 1);
2753  else
2754  EndDialog(hwndDlg, 0);
2755  }
2756  else if (LOWORD(wParam) == IDCANCEL)
2757  {
2758  EndDialog(hwndDlg, -1);
2759  }
2761  {
2762  if (SendMessage(hDlgCtrl, BM_GETCHECK, 0, 0) == BST_CHECKED)
2763  SendMessage(hDlgCtrl, BM_SETCHECK, BST_UNCHECKED, 0);
2764  else
2765  SendMessage(hDlgCtrl, BM_SETCHECK, BST_CHECKED, 0);
2766  }
2767  }
2768  }
2769  return FALSE;
2770 }
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define IDC_SHORTEX_RUN_DIFFERENT
Definition: shresdef.h:418
#define BM_GETCHECK
Definition: winuser.h:1900
#define BM_SETCHECK
Definition: winuser.h:1903
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1722
#define BST_UNCHECKED
Definition: winuser.h:199
#define BST_CHECKED
Definition: winuser.h:197
#define SendMessage
Definition: winuser.h:5818
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by CShellLink::OnCommand().

◆ GetAdvertisedArg()

static LPWSTR GetAdvertisedArg ( LPCWSTR  str)
static

Definition at line 2001 of file CShellLink.cpp.

2002 {
2003  if (!str)
2004  return NULL;
2005 
2006  LPCWSTR p = wcschr(str, L':');
2007  if (!p)
2008  return NULL;
2009 
2010  DWORD len = p - str;
2011  LPWSTR ret = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * (len + 1));
2012  if (!ret)
2013  return ret;
2014 
2015  memcpy(ret, str, sizeof(WCHAR)*len);
2016  ret[len] = 0;
2017  return ret;
2018 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CShellLink::SetAdvertiseInfo().

◆ HACKISH_PathResolve()

static BOOL HACKISH_PathResolve ( IN OUT PWSTR  pszPath,
IN PZPCWSTR dirs  OPTIONAL,
IN UINT  fFlags 
)
static

Definition at line 2175 of file CShellLink.cpp.

2179 {
2180  // FIXME: This is unimplemented!!!
2181 #if 0
2182  return PathResolve(pszPath, dirs, fFlags);
2183 #else
2184  BOOL Success = FALSE;
2185  USHORT i;
2186  LPWSTR fname = NULL;
2188 
2189  /* First, search for a valid existing path */
2190 
2191  // NOTE: See also: SHELL_FindExecutable()
2192 
2193  /*
2194  * List of extensions searched for, by PathResolve with the flag
2195  * PRF_TRYPROGRAMEXTENSIONS == PRF_EXECUTABLE | PRF_VERIFYEXISTS set,
2196  * according to MSDN: https://msdn.microsoft.com/en-us/library/windows/desktop/bb776478(v=vs.85).aspx
2197  */
2198  static PCWSTR Extensions[] = {L".pif", L".com", L".bat", L".cmd", L".lnk", L".exe", NULL};
2199  #define LNK_EXT_INDEX 4 // ".lnk" has index 4 in the array above
2200 
2201  /*
2202  * Start at the beginning of the list if PRF_EXECUTABLE is set, otherwise
2203  * just use the last element 'NULL' (no extension checking).
2204  */
2205  i = ((fFlags & PRF_EXECUTABLE) ? 0 : _countof(Extensions) - 1);
2206  for (; i < _countof(Extensions); ++i)
2207  {
2208  /* Ignore shell links ".lnk" if needed */
2209  if ((fFlags & PRF_DONTFINDLNK) && (i == LNK_EXT_INDEX))
2210  continue;
2211 
2212  Success = (SearchPathW(NULL, pszPath, Extensions[i],
2213  _countof(szPath), szPath, NULL) != 0);
2214  if (!Success)
2215  {
2216  ERR("SearchPathW(pszPath = '%S') failed. Error code: %lu\n", pszPath, GetLastError());
2217  }
2218  else
2219  {
2220  ERR("SearchPathW(pszPath = '%S', szPath = '%S') succeeded\n", pszPath, szPath);
2221  break;
2222  }
2223  }
2224 
2225  if (!Success)
2226  {
2227  ERR("SearchPathW(pszPath = '%S') failed. Error code: %lu\n", pszPath, GetLastError());
2228 
2229  /* We failed, try with PathFindOnPath, as explained by MSDN */
2230  // Success = PathFindOnPathW(pszPath, dirs);
2231  StringCchCopyW(szPath, _countof(szPath), pszPath);
2232  Success = PathFindOnPathW(szPath, dirs);
2233  if (!Success)
2234  {
2235  ERR("PathFindOnPathW(pszPath = '%S') failed\n", pszPath);
2236 
2237  /* We failed again, fall back to building a possible non-existing path */
2238  if (!GetFullPathNameW(pszPath, _countof(szPath), szPath, &fname))
2239  {
2240  ERR("GetFullPathNameW(pszPath = '%S') failed. Error code: %lu\n", pszPath, GetLastError());
2241  return FALSE;
2242  }
2243 
2245  if (!Success)
2246  ERR("PathFileExistsW(szPath = '%S') failed. Error code: %lu\n", szPath, GetLastError());
2247 
2248  /******************************************************/
2249  /* Question: Why this line is needed only for files?? */
2250  if (fname && (_wcsicmp(pszPath, fname) == 0))
2251  *szPath = L'\0';
2252  /******************************************************/
2253  }
2254  else
2255  {
2256  ERR("PathFindOnPathW(pszPath = '%S' ==> '%S') succeeded\n", pszPath, szPath);
2257  }
2258  }
2259 
2260  /* Copy back the results to the caller */
2261  StringCchCopyW(pszPath, MAX_PATH, szPath);
2262 
2263  /*
2264  * Since the called functions always checked whether the file path existed,
2265  * we do not need to redo a final check: we can use instead the cached
2266  * result in 'Success'.
2267  */
2268  return ((fFlags & PRF_VERIFYEXISTS) ? Success : TRUE);
2269 #endif
2270 }
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define TRUE
Definition: types.h:120
#define PRF_DONTFINDLNK
Definition: PathResolve.cpp:33
#define _countof(array)
Definition: fontsub.cpp:30
#define PRF_VERIFYEXISTS
Definition: PathResolve.cpp:29
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1105
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 BOOL
Definition: ntddk_ex.h:94
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1756
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
static const WCHAR L[]
Definition: oid.c:1250
DWORD WINAPI SearchPathW(IN LPCWSTR lpPath OPTIONAL, IN LPCWSTR lpFileName, IN LPCWSTR lpExtension OPTIONAL, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart OPTIONAL)
Definition: path.c:1297
#define ERR(fmt,...)
Definition: debug.h:109
unsigned short USHORT
Definition: pedump.c:61
LPCWSTR szPath
Definition: env.c:35
#define PRF_EXECUTABLE
Definition: PathResolve.cpp:30
WCHAR * LPWSTR
Definition: xmlstorage.h:184
BOOL WINAPI PathFindOnPathW(LPWSTR lpszFile, LPCWSTR *lppszOtherDirs)
Definition: path.c:1382
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by CShellLink::SetTargetFromPIDLOrPath().

◆ HEAP_strdupAtoW()

static LPWSTR __inline HEAP_strdupAtoW ( HANDLE  heap,
DWORD  flags,
LPCSTR  str 
)
static

Definition at line 194 of file CShellLink.cpp.

195 {
196  INT len;
197  LPWSTR p;
198 
199  assert(str);
200 
201  len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
202  p = (LPWSTR)HeapAlloc(heap, flags, len * sizeof(WCHAR));
203  if (!p)
204  return p;
205  MultiByteToWideChar(CP_ACP, 0, str, -1, p, len);
206  return p;
207 }
#define CP_ACP
Definition: compat.h:99
#define assert(x)
Definition: debug.h:53
int32_t INT
Definition: typedefs.h:56
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
#define MultiByteToWideChar
Definition: compat.h:100
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CShellLink::Extract(), CShellLink::SetArguments(), CShellLink::SetDescription(), CShellLink::SetIconLocation(), CShellLink::SetPath(), CShellLink::SetRelativePath(), and CShellLink::SetWorkingDirectory().

◆ IShellLink_ConstructFromFile()

HRESULT WINAPI IShellLink_ConstructFromFile ( IShellFolder psf,
LPCITEMIDLIST  pidl,
REFIID  riid,
LPVOID ppv 
)

Definition at line 3185 of file CShellLink.cpp.

3186 {
3187  WCHAR path[MAX_PATH];
3188  if (!ILGetDisplayNameExW(psf, pidl, path, 0))
3189  return E_FAIL;
3190 
3192 }
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define E_FAIL
Definition: ddrawi.h:102
BOOL ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type)
Definition: pidl.c:91
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26

◆ IShellLink_ConstructFromPath()

HRESULT WINAPI IShellLink_ConstructFromPath ( WCHAR path,
REFIID  riid,
LPVOID ppv 
)

Definition at line 3171 of file CShellLink.cpp.

3172 {
3174  HRESULT hr = CShellLink::_CreatorClass::CreateInstance(NULL, IID_PPV_ARG(IPersistFile, &ppf));
3175  if (FAILED(hr))
3176  return hr;
3177 
3178  hr = ppf->Load(path, 0);
3179  if (FAILED(hr))
3180  return hr;
3181 
3182  return ppf->QueryInterface(riid, ppv);
3183 }
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define IID_PPV_ARG(Itype, ppType)
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77

Referenced by CFSDropTarget::_DoDrop(), IShellLink_ConstructFromFile(), and SHAddToRecentDocs().

◆ SH_GetTargetTypeByPath()

LPWSTR SH_GetTargetTypeByPath ( LPCWSTR  lpcwFullPath)

Definition at line 2784 of file CShellLink.cpp.

2785 {
2786  LPCWSTR pwszExt;
2787  static WCHAR wszBuf[MAX_PATH];
2788 
2789  /* Get file information */
2790  SHFILEINFOW fi;
2791  if (!SHGetFileInfoW(lpcwFullPath, 0, &fi, sizeof(fi), SHGFI_TYPENAME | SHGFI_USEFILEATTRIBUTES))
2792  {
2793  ERR("SHGetFileInfoW failed for %ls (%lu)\n", lpcwFullPath, GetLastError());
2794  fi.szTypeName[0] = L'\0';
2795  fi.hIcon = NULL;
2796  }
2797 
2798  pwszExt = PathFindExtensionW(lpcwFullPath);
2799  if (pwszExt[0])
2800  {
2801  if (!fi.szTypeName[0])
2802  {
2803  /* The file type is unknown, so default to string "FileExtension File" */
2804  size_t cchRemaining = 0;
2805  LPWSTR pwszEnd = NULL;
2806 
2807  StringCchPrintfExW(wszBuf, _countof(wszBuf), &pwszEnd, &cchRemaining, 0, L"%s ", pwszExt + 1);
2808  }
2809  else
2810  {
2811  /* Update file type */
2812  StringCbPrintfW(wszBuf, sizeof(wszBuf), L"%s (%s)", fi.szTypeName, pwszExt);
2813  }
2814  }
2815 
2816  return wszBuf;
2817 }
#define SHGFI_TYPENAME
Definition: shellapi.h:165
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define _countof(array)
Definition: fontsub.cpp:30
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
WCHAR szTypeName[80]
Definition: shellapi.h:374
STRSAFEAPI StringCchPrintfExW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:585
smooth NULL
Definition: ftsmooth.c:416
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:442
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:410
#define MAX_PATH
Definition: compat.h:26
#define SHGFI_USEFILEATTRIBUTES
Definition: shellapi.h:179
static const WCHAR L[]
Definition: oid.c:1250
HICON hIcon
Definition: shellapi.h:370
#define ERR(fmt,...)
Definition: debug.h:109
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CShellLink::OnInitDialog().

◆ SHELL_ExistsFileW()

static BOOL SHELL_ExistsFileW ( LPCWSTR  path)
static

Definition at line 989 of file CShellLink.cpp.

990 {
992  return FALSE;
993 
994  return TRUE;
995 }
#define TRUE
Definition: types.h:120
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23

Referenced by ShellLink_UpdatePath().

◆ SHELL_PidlGetIconLocationW()

static HRESULT SHELL_PidlGetIconLocationW ( PCIDLIST_ABSOLUTE  pidl,
UINT  uFlags,
PWSTR  pszIconFile,
UINT  cchMax,
int piIndex,
UINT pwFlags 
)
static

Definition at line 1679 of file CShellLink.cpp.

1681 {
1682  LPCITEMIDLIST pidlLast;
1684 
1685  HRESULT hr = SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psf), &pidlLast);
1686  if (FAILED_UNEXPECTEDLY(hr))
1687  return hr;
1688 
1690  hr = psf->GetUIObjectOf(0, 1, &pidlLast, IID_NULL_PPV_ARG(IExtractIconW, &pei));
1691  if (FAILED_UNEXPECTEDLY(hr))
1692  return hr;
1693 
1694  hr = pei->GetIconLocation(uFlags, pszIconFile, cchMax, piIndex, pwFlags);
1695  if (FAILED_UNEXPECTEDLY(hr))
1696  return hr;
1697 
1698  return S_OK;
1699 }
HRESULT hr
Definition: shlfolder.c:183
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
UINT uFlags
Definition: api.c:59
#define IID_PPV_ARG(Itype, ppType)
#define IID_NULL_PPV_ARG(Itype, ppType)
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
UINT cchMax
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1323

Referenced by CShellLink::GetIconLocation().

◆ shelllink_get_msi_component_path()

static LPWSTR shelllink_get_msi_component_path ( LPWSTR  component)
static

Definition at line 1357 of file CShellLink.cpp.

1358 {
1359  DWORD Result, sz = 0;
1360 
1361  Result = CommandLineFromMsiDescriptor(component, NULL, &sz);
1362  if (Result != ERROR_SUCCESS)
1363  return NULL;
1364 
1365  sz++;
1366  LPWSTR path = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, sz * sizeof(WCHAR));
1367  Result = CommandLineFromMsiDescriptor(component, path, &sz);
1368  if (Result != ERROR_SUCCESS)
1369  {
1370  HeapFree(GetProcessHeap(), 0, path);
1371  path = NULL;
1372  }
1373 
1374  TRACE("returning %s\n", debugstr_w(path));
1375 
1376  return path;
1377 }
#define ERROR_SUCCESS
Definition: deptool.c:10
GLsizei const GLchar ** path
Definition: glext.h:7234
DWORD WINAPI CommandLineFromMsiDescriptor(WCHAR *szDescriptor, WCHAR *szCommandLine, DWORD *pcchCommandLine)
Definition: msi.c:22
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
_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:426
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by CShellLink::Resolve().

◆ ShellLink_GetVolumeInfo()

static BOOL ShellLink_GetVolumeInfo ( LPCWSTR  path,
CShellLink::volume_info volume 
)
static

Definition at line 462 of file CShellLink.cpp.

463 {
464  WCHAR drive[4] = { path[0], ':', '\\', 0 };
465 
466  volume->type = GetDriveTypeW(drive);
467  BOOL bRet = GetVolumeInformationW(drive, volume->label, _countof(volume->label), &volume->serial, NULL, NULL, NULL, 0);
468  TRACE("ret = %d type %d serial %08x name %s\n", bRet,
469  volume->type, volume->serial, debugstr_w(volume->label));
470  return bRet;
471 }
#define _countof(array)
Definition: fontsub.cpp:30
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
BOOL WINAPI GetVolumeInformationW(IN LPCWSTR lpRootPathName, IN LPWSTR lpVolumeNameBuffer, IN DWORD nVolumeNameSize, OUT LPDWORD lpVolumeSerialNumber OPTIONAL, OUT LPDWORD lpMaximumComponentLength OPTIONAL, OUT LPDWORD lpFileSystemFlags OPTIONAL, OUT LPWSTR lpFileSystemNameBuffer OPTIONAL, IN DWORD nFileSystemNameSize)
Definition: volume.c:226

Referenced by CShellLink::SetTargetFromPIDLOrPath().

◆ ShellLink_UpdatePath()

static HRESULT ShellLink_UpdatePath ( LPCWSTR  sPathRel,
LPCWSTR  path,
LPCWSTR  sWorkDir,
LPWSTR psPath 
)
static

Definition at line 1001 of file CShellLink.cpp.

1002 {
1003  if (!path || !psPath)
1004  return E_INVALIDARG;
1005 
1006  if (!*psPath && sPathRel)
1007  {
1008  WCHAR buffer[2*MAX_PATH], abs_path[2*MAX_PATH];
1009  LPWSTR final = NULL;
1010 
1011  /* first try if [directory of link file] + [relative path] finds an existing file */
1012 
1013  GetFullPathNameW(path, MAX_PATH * 2, buffer, &final);
1014  if (!final)
1015  final = buffer;
1016  wcscpy(final, sPathRel);
1017 
1018  *abs_path = '\0';
1019 
1021  {
1022  if (!GetFullPathNameW(buffer, MAX_PATH, abs_path, &final))
1023  wcscpy(abs_path, buffer);
1024  }
1025  else
1026  {
1027  /* try if [working directory] + [relative path] finds an existing file */
1028  if (sWorkDir)
1029  {
1030  wcscpy(buffer, sWorkDir);
1031  wcscpy(PathAddBackslashW(buffer), sPathRel);
1032 
1034  if (!GetFullPathNameW(buffer, MAX_PATH, abs_path, &final))
1035  wcscpy(abs_path, buffer);
1036  }
1037  }
1038 
1039  /* FIXME: This is even not enough - not all shell links can be resolved using this algorithm. */
1040  if (!*abs_path)
1041  wcscpy(abs_path, sPathRel);
1042 
1043  *psPath = strdupW(abs_path);
1044  if (!*psPath)
1045  return E_OUTOFMEMORY;
1046  }
1047 
1048  return S_OK;
1049 }
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1105
GLuint buffer
Definition: glext.h:5915
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
LPWSTR WINAPI PathAddBackslashW(LPWSTR lpszPath)
Definition: path.c:289
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define S_OK
Definition: intsafe.h:59
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CShellLink::Load(), and CShellLink::SetRelativePath().

◆ SHOpenFolderAndSelectItems()

EXTERN_C HRESULT WINAPI SHOpenFolderAndSelectItems ( LPITEMIDLIST  pidlFolder,
UINT  cidl,
PCUITEMID_CHILD_ARRAY  apidl,
DWORD  dwFlags 
)

Definition at line 389 of file shlfolder.cpp.

393 {
394  ERR("SHOpenFolderAndSelectItems() is hackplemented\n");
395  PCIDLIST_ABSOLUTE pidlItem;
396  if (cidl)
397  {
398  /* Firefox sends a full pidl here dispite the fact it is a PCUITEMID_CHILD_ARRAY -_- */
399  if (ILGetNext(apidl[0]) != NULL)
400  {
401  pidlItem = apidl[0];
402  }
403  else
404  {
405  pidlItem = ILCombine(pidlFolder, apidl[0]);
406  }
407  }
408  else
409  {
410  pidlItem = pidlFolder;
411  }
412 
413  CComPtr<IShellFolder> psfDesktop;
414 
415  HRESULT hr = SHGetDesktopFolder(&psfDesktop);
416  if (FAILED_UNEXPECTEDLY(hr))
417  return hr;
418 
419  STRRET strret;
420  hr = psfDesktop->GetDisplayNameOf(pidlItem, SHGDN_FORPARSING, &strret);
421  if (FAILED_UNEXPECTEDLY(hr))
422  return hr;
423 
424  WCHAR wszBuf[MAX_PATH];
425  hr = StrRetToBufW(&strret, pidlItem, wszBuf, _countof(wszBuf));
426  if (FAILED_UNEXPECTEDLY(hr))
427  return hr;
428 
429  WCHAR wszParams[MAX_PATH];
430  wcscpy(wszParams, L"/select,");
431  wcscat(wszParams, wszBuf);
432 
433  SHELLEXECUTEINFOW sei;
434  memset(&sei, 0, sizeof sei);
435  sei.cbSize = sizeof sei;
437  sei.lpFile = L"explorer.exe";
438  sei.lpParameters = wszParams;
439 
440  if (ShellExecuteExW(&sei))
441  return S_OK;
442  else
443  return E_FAIL;
444 }
HRESULT hr
Definition: shlfolder.c:183
#define SEE_MASK_WAITFORINPUTIDLE
Definition: shellapi.h:56
#define _countof(array)
Definition: fontsub.cpp:30
HRESULT WINAPI StrRetToBufW(LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
Definition: string.c:1522
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:699
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
Definition: pidl.c:851
#define E_FAIL
Definition: ddrawi.h:102
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2235
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define MAX_PATH
Definition: compat.h:26
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
LPCWSTR lpParameters
Definition: shellapi.h:331
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define memset(x, y, z)
Definition: compat.h:39

Referenced by CShellLink::OnCommand().

◆ strdupW()

static LPWSTR __inline strdupW ( LPCWSTR  src)
static

Definition at line 209 of file CShellLink.cpp.

210 {
211  LPWSTR dest;
212  if (!src) return NULL;
213  dest = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, (wcslen(src) + 1) * sizeof(WCHAR));
214  if (dest)
215  wcscpy(dest, src);
216  return dest;
217 }
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
GLenum src
Definition: glext.h:6340
static char * dest
Definition: rtl.c:135
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by CShellLink::DoOpen(), CShellLink::GetIconLocation(), CShellLink::Load(), CShellLink::OnNotify(), CShellLink::Resolve(), CShellLink::Save(), CShellLink::SetArguments(), CShellLink::SetDescription(), CShellLink::SetIconLocation(), CShellLink::SetPath(), CShellLink::SetRelativePath(), CShellLink::SetTargetFromPIDLOrPath(), CShellLink::SetWorkingDirectory(), and ShellLink_UpdatePath().

◆ Stream_LoadLocation()

static HRESULT Stream_LoadLocation ( IStream stm,
CShellLink::volume_info volume,
LPWSTR path 
)
static

Definition at line 543 of file CShellLink.cpp.

545 {
546  char *p = NULL;
547  HRESULT hr = Stream_ReadChunk(stm, (LPVOID*) &p);
548  if (FAILED(hr))
549  return hr;
550 
551  LOCATION_INFO *loc = reinterpret_cast<LOCATION_INFO *>(p);
552  if (loc->dwTotalSize < sizeof(LOCATION_INFO))
553  {
554  HeapFree(GetProcessHeap(), 0, p);
555  return E_FAIL;
556  }
557 
558  /* if there's valid local volume information, load it */
559  if (loc->dwVolTableOfs &&
560  ((loc->dwVolTableOfs + sizeof(LOCAL_VOLUME_INFO)) <= loc->dwTotalSize))
561  {
563 
566  }
567 
568  /* if there's a local path, load it */
569  DWORD n = loc->dwLocalPathOfs;
570  if (n && n < loc->dwTotalSize)
571  *path = Stream_LoadPath(&p[n], loc->dwTotalSize - n);
572 
573  TRACE("type %d serial %08x name %s path %s\n", volume->type,
574  volume->serial, debugstr_w(volume->label), debugstr_w(*path));
575 
576  HeapFree(GetProcessHeap(), 0, p);
577  return S_OK;
578 }
HRESULT hr
Definition: shlfolder.c:183
GLdouble n
Definition: glext.h:7729
#define E_FAIL
Definition: ddrawi.h:102
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
DWORD dwLocalPathOfs
Definition: CShellLink.cpp:167
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
#define S_OK
Definition: intsafe.h:59
DWORD dwVolTableOfs
Definition: CShellLink.cpp:166
GLfloat GLfloat p
Definition: glext.h:8902
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by CShellLink::Load().

◆ Stream_LoadPath()

static LPWSTR Stream_LoadPath ( LPCSTR  p,
DWORD  maxlen 
)
static

Definition at line 526 of file CShellLink.cpp.

527 {
528  UINT len = 0;
529 
530  while (len < maxlen && p[len])
531  len++;
532 
533  UINT wlen = MultiByteToWideChar(CP_ACP, 0, p, len, NULL, 0);
534  LPWSTR path = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, (wlen + 1) * sizeof(WCHAR));
535  if (!path)
536  return NULL;
537  MultiByteToWideChar(CP_ACP, 0, p, len, path, wlen);
538  path[wlen] = 0;
539 
540  return path;
541 }
GLsizei const GLchar ** path
Definition: glext.h:7234
#define CP_ACP
Definition: compat.h:99
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLsizei len
Definition: glext.h:6722
unsigned int UINT
Definition: ndis.h:50
#define MultiByteToWideChar
Definition: compat.h:100
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by Stream_LoadLocation().

◆ Stream_LoadString()

static HRESULT Stream_LoadString ( IStream stm,
BOOL  unicode,
LPWSTR pstr 
)
static

Definition at line 405 of file CShellLink.cpp.

406 {
407  TRACE("%p\n", stm);
408 
409  USHORT len;
410  DWORD count = 0;
411  HRESULT hr = stm->Read(&len, sizeof(len), &count);
412  if (FAILED(hr) || count != sizeof(len))
413  return E_FAIL;
414 
415  if (unicode)
416  len *= sizeof(WCHAR);
417 
418  TRACE("reading %d\n", len);
419  LPSTR temp = (LPSTR)HeapAlloc(GetProcessHeap(), 0, len + sizeof(WCHAR));
420  if (!temp)
421  return E_OUTOFMEMORY;
422  count = 0;
423  hr = stm->Read(temp, len, &count);
424  if (FAILED(hr) || count != len)
425  {
427  return E_FAIL;
428  }
429 
430  TRACE("read %s\n", debugstr_an(temp, len));
431 
432  /* convert to unicode if necessary */
433  LPWSTR str;
434  if (!unicode)
435  {
437  str = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, (count + 1) * sizeof(WCHAR));
438  if (!str)
439  {
441  return E_OUTOFMEMORY;
442  }
445  }
446  else
447  {
448  count /= sizeof(WCHAR);
449  str = (LPWSTR)temp;
450  }
451  str[count] = 0;
452 
453  *pstr = str;
454 
455  return S_OK;
456 }
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:99
GLuint GLuint GLsizei count
Definition: gl.h:1545
char * LPSTR
Definition: xmlstorage.h:182
#define E_FAIL
Definition: ddrawi.h:102
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:47
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59
unsigned short USHORT
Definition: pedump.c:61
static calc_node_t temp
Definition: rpn_ieee.c:38
#define MultiByteToWideChar
Definition: compat.h:100
WCHAR * LPWSTR
Definition: xmlstorage.h:184
HRESULT Read([out, size_is(cb), length_is(*pcbRead)] void *pv, [in] ULONG cb, [out] ULONG *pcbRead)
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by CShellLink::Load().

◆ Stream_LoadVolume()

static BOOL Stream_LoadVolume ( LOCAL_VOLUME_INFO vol,
CShellLink::volume_info volume 
)
static

Definition at line 508 of file CShellLink.cpp.

509 {
510  volume->serial = vol->dwVolSerial;
511  volume->type = vol->dwType;
512 
513  if (!vol->dwVolLabelOfs)
514  return FALSE;
515  if (vol->dwSize <= vol->dwVolLabelOfs)
516  return FALSE;
517  INT len = vol->dwSize - vol->dwVolLabelOfs;
518 
519  LPSTR label = (LPSTR)vol;
520  label += vol->dwVolLabelOfs;
521  MultiByteToWideChar(CP_ACP, 0, label, len, volume->label, _countof(volume->label));
522 
523  return TRUE;
524 }
#define TRUE
Definition: types.h:120
#define CP_ACP
Definition: compat.h:99
#define _countof(array)
Definition: fontsub.cpp:30
char * LPSTR
Definition: xmlstorage.h:182
int32_t INT
Definition: typedefs.h:56
GLenum GLsizei len
Definition: glext.h:6722
uint8_t label[11]
Definition: fsck.fat.h:65
#define MultiByteToWideChar
Definition: compat.h:100

Referenced by Stream_LoadLocation().

◆ Stream_ReadChunk()

static HRESULT Stream_ReadChunk ( IStream stm,
LPVOID data 
)
static

Definition at line 473 of file CShellLink.cpp.

474 {
475  struct sized_chunk
476  {
477  DWORD size;
478  unsigned char data[1];
479  } *chunk;
480 
481  TRACE("%p\n", stm);
482 
483  DWORD size;
484  ULONG count;
485  HRESULT hr = stm->Read(&size, sizeof(size), &count);
486  if (FAILED(hr) || count != sizeof(size))
487  return E_FAIL;
488 
489  chunk = static_cast<sized_chunk *>(HeapAlloc(GetProcessHeap(), 0, size));
490  if (!chunk)
491  return E_OUTOFMEMORY;
492 
493  chunk->size = size;
494  hr = stm->Read(chunk->data, size - sizeof(size), &count);
495  if (FAILED(hr) || count != (size - sizeof(size)))
496  {
498  return E_FAIL;
499  }
500 
501  TRACE("Read %d bytes\n", chunk->size);
502 
503  *data = chunk;
504 
505  return S_OK;
506 }
uint16_t size
Definition: btrfs_drv.h:556
HRESULT hr
Definition: shlfolder.c:183
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define E_FAIL
Definition: ddrawi.h:102
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define S_OK
Definition: intsafe.h:59
unsigned int ULONG
Definition: retypes.h:1
HRESULT Read([out, size_is(cb), length_is(*pcbRead)] void *pv, [in] ULONG cb, [out] ULONG *pcbRead)
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by Stream_LoadLocation().

◆ Stream_WriteLocationInfo()

static HRESULT Stream_WriteLocationInfo ( IStream stm,
LPCWSTR  path,
CShellLink::volume_info volume 
)
static

Definition at line 801 of file CShellLink.cpp.

803 {
804  LOCAL_VOLUME_INFO *vol;
805  LOCATION_INFO *loc;
806 
807  TRACE("%p %s %p\n", stm, debugstr_w(path), volume);
808 
809  /* figure out the size of everything */
810  DWORD label_size = WideCharToMultiByte(CP_ACP, 0, volume->label, -1,
811  NULL, 0, NULL, NULL);
812  DWORD path_size = WideCharToMultiByte(CP_ACP, 0, path, -1,
813  NULL, 0, NULL, NULL);
814  DWORD volume_info_size = sizeof(*vol) + label_size;
815  DWORD final_path_size = 1;
816  DWORD total_size = sizeof(*loc) + volume_info_size + path_size + final_path_size;
817 
818  /* create pointers to everything */
819  loc = static_cast<LOCATION_INFO *>(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, total_size));
820  vol = (LOCAL_VOLUME_INFO*) &loc[1];
821  LPSTR szLabel = (LPSTR) &vol[1];
822  LPSTR szPath = &szLabel[label_size];
823  LPSTR szFinalPath = &szPath[path_size];
824 
825  /* fill in the location information header */
826  loc->dwTotalSize = total_size;
827  loc->dwHeaderSize = sizeof(*loc);
828  loc->dwFlags = 1;
829  loc->dwVolTableOfs = sizeof(*loc);
830  loc->dwLocalPathOfs = sizeof(*loc) + volume_info_size;
831  loc->dwNetworkVolTableOfs = 0;
832  loc->dwFinalPathOfs = sizeof(*loc) + volume_info_size + path_size;
833 
834  /* fill in the volume information */
835  vol->dwSize = volume_info_size;
836  vol->dwType = volume->type;
837  vol->dwVolSerial = volume->serial;
838  vol->dwVolLabelOfs = sizeof(*vol);
839 
840  /* copy in the strings */
841  WideCharToMultiByte(CP_ACP, 0, volume->label, -1,
842  szLabel, label_size, NULL, NULL);
844  szPath, path_size, NULL, NULL);
845  *szFinalPath = 0;
846 
847  ULONG count = 0;
848  HRESULT hr = stm->Write(loc, total_size, &count);
849  HeapFree(GetProcessHeap(), 0, loc);
850 
851  return hr;
852 }
DWORD dwHeaderSize
Definition: CShellLink.cpp:164
#define WideCharToMultiByte
Definition: compat.h:101
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:99
GLuint GLuint GLsizei count
Definition: gl.h:1545
DWORD dwNetworkVolTableOfs
Definition: CShellLink.cpp:168
char * LPSTR
Definition: xmlstorage.h:182
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
DWORD dwLocalPathOfs
Definition: CShellLink.cpp:167
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
DWORD dwFinalPathOfs
Definition: CShellLink.cpp:169
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwVolTableOfs
Definition: CShellLink.cpp:166
LPCWSTR szPath
Definition: env.c:35
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
unsigned int ULONG
Definition: retypes.h:1
HRESULT Write([in, size_is(cb)] const void *pv, [in] ULONG cb, [out] ULONG *pcbWritten)
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by CShellLink::Save().

◆ Stream_WriteString()

static HRESULT Stream_WriteString ( IStream stm,
LPCWSTR  str 
)
static

Definition at line 774 of file CShellLink.cpp.

775 {
776  USHORT len = wcslen(str) + 1; // FIXME: Possible overflows?
777  DWORD count;
778 
779  HRESULT hr = stm->Write(&len, sizeof(len), &count);
780  if (FAILED(hr))
781  return hr;
782 
783  len *= sizeof(WCHAR);
784 
785  hr = stm->Write(str, len, &count);
786  if (FAILED(hr))
787  return hr;
788 
789  return S_OK;
790 }
HRESULT hr
Definition: shlfolder.c:183
GLuint GLuint GLsizei count
Definition: gl.h:1545
const WCHAR * str
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59
unsigned short USHORT
Definition: pedump.c:61
HRESULT Write([in, size_is(cb)] const void *pv, [in] ULONG cb, [out] ULONG *pcbWritten)
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by CShellLink::Save().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )