Commit 88090b47 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Remove code that starts wineshelllink, instead create a windows

compatible shortcut (*.lnk) file. After creating that file, start a link processor (winemenubuilder) on it, which reads it back then calls wineshelllink. Rework CreateStreamFromFile to create an IStream object that is writeable.
parent fa9af1d0
...@@ -1525,6 +1525,7 @@ programs/winecfg/Makefile ...@@ -1525,6 +1525,7 @@ programs/winecfg/Makefile
programs/wineconsole/Makefile programs/wineconsole/Makefile
programs/winedbg/Makefile programs/winedbg/Makefile
programs/winefile/Makefile programs/winefile/Makefile
programs/winemenubuilder/Makefile
programs/winemine/Makefile programs/winemine/Makefile
programs/winepath/Makefile programs/winepath/Makefile
programs/winevdm/Makefile programs/winevdm/Makefile
......
...@@ -58,13 +58,6 @@ SUBDIRS = tests ...@@ -58,13 +58,6 @@ SUBDIRS = tests
@MAKE_DLL_RULES@ @MAKE_DLL_RULES@
install::
$(MKINSTALLDIRS) $(bindir)
$(INSTALL_SCRIPT) $(TOPSRCDIR)/tools/wineshelllink $(bindir)/wineshelllink
uninstall::
$(RM) $(bindir)/wineshelllink
# Special rules for 16-bit resource files # Special rules for 16-bit resource files
version16.res: version16.rc version16.res: version16.rc
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
* access in a IStream to. * access in a IStream to.
* *
* Copyright 1999 Juergen Schmied * Copyright 1999 Juergen Schmied
* Copyright 2003 Mike McCormack for Codeweavers
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
...@@ -73,10 +74,7 @@ static ICOM_VTABLE(IStream) stvt = ...@@ -73,10 +74,7 @@ static ICOM_VTABLE(IStream) stvt =
typedef struct typedef struct
{ ICOM_VTABLE(IStream) *lpvtst; { ICOM_VTABLE(IStream) *lpvtst;
DWORD ref; DWORD ref;
LPBYTE pImage; HANDLE handle;
HANDLE hMapping;
DWORD dwLength;
DWORD dwPos;
} ISHFileStream; } ISHFileStream;
/************************************************************************** /**************************************************************************
...@@ -84,40 +82,42 @@ typedef struct ...@@ -84,40 +82,42 @@ typedef struct
* *
* similar to CreateStreamOnHGlobal * similar to CreateStreamOnHGlobal
*/ */
HRESULT CreateStreamOnFile (LPCSTR pszFilename, IStream ** ppstm) HRESULT CreateStreamOnFile (LPCWSTR pszFilename, DWORD grfMode, IStream ** ppstm)
{ {
ISHFileStream* fstr; ISHFileStream* fstr;
OFSTRUCT ofs; HANDLE handle;
HFILE hFile = OpenFile( pszFilename, &ofs, OF_READ ); DWORD access = GENERIC_READ, creat;
HRESULT ret = E_FAIL;
fstr = (ISHFileStream*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ISHFileStream)); if( grfMode & STGM_TRANSACTED )
fstr->lpvtst=&stvt; return E_INVALIDARG;
fstr->ref = 1;
fstr->dwLength = GetFileSize ((HANDLE)hFile, NULL);
if (!(fstr->hMapping = CreateFileMappingA((HANDLE)hFile,NULL,PAGE_READONLY|SEC_COMMIT,0,0,NULL))) if( grfMode & STGM_WRITE )
{ access |= GENERIC_WRITE;
WARN("failed to create filemap.\n"); if( grfMode & STGM_READWRITE )
goto end_2; access = GENERIC_WRITE | GENERIC_READ;
}
if (!(fstr->pImage = MapViewOfFile(fstr->hMapping,FILE_MAP_READ,0,0,0))) if( grfMode & STGM_CREATE )
{ creat = CREATE_ALWAYS;
WARN("failed to mmap filemap.\n"); else
goto end_3; creat = OPEN_EXISTING;
}
TRACE("Opening %s\n", debugstr_w(pszFilename) );
ret = S_OK; handle = CreateFileW( pszFilename, access, 0, NULL, creat, 0, NULL );
goto end_1; if( handle == INVALID_HANDLE_VALUE )
return E_FAIL;
end_3: CloseHandle(fstr->hMapping); fstr = (ISHFileStream*)HeapAlloc(GetProcessHeap(),
end_2: HeapFree(GetProcessHeap(), 0, fstr); HEAP_ZERO_MEMORY,sizeof(ISHFileStream));
fstr = NULL; if( !fstr )
return E_FAIL;
fstr->lpvtst=&stvt;
fstr->ref = 1;
fstr->handle = handle;
end_1: _lclose(hFile);
(*ppstm) = (IStream*)fstr; (*ppstm) = (IStream*)fstr;
return ret;
return S_OK;
} }
/************************************************************************** /**************************************************************************
...@@ -169,13 +169,10 @@ static ULONG WINAPI IStream_fnRelease(IStream *iface) ...@@ -169,13 +169,10 @@ static ULONG WINAPI IStream_fnRelease(IStream *iface)
TRACE("(%p)->()\n",This); TRACE("(%p)->()\n",This);
if (!--(This->ref)) if (!--(This->ref))
{ TRACE(" destroying SHFileStream (%p)\n",This); {
TRACE(" destroying SHFileStream (%p)\n",This);
UnmapViewOfFile(This->pImage); CloseHandle(This->handle);
CloseHandle(This->hMapping); HeapFree(GetProcessHeap(),0,This);
HeapFree(GetProcessHeap(),0,This);
return 0;
} }
return This->ref; return This->ref;
} }
...@@ -184,52 +181,64 @@ static HRESULT WINAPI IStream_fnRead (IStream * iface, void* pv, ULONG cb, ULONG ...@@ -184,52 +181,64 @@ static HRESULT WINAPI IStream_fnRead (IStream * iface, void* pv, ULONG cb, ULONG
{ {
ICOM_THIS(ISHFileStream, iface); ICOM_THIS(ISHFileStream, iface);
DWORD dwBytesToRead, dwBytesLeft;
TRACE("(%p)->(%p,0x%08lx,%p)\n",This, pv, cb, pcbRead); TRACE("(%p)->(%p,0x%08lx,%p)\n",This, pv, cb, pcbRead);
if ( !pv ) if ( !pv )
return STG_E_INVALIDPOINTER; return STG_E_INVALIDPOINTER;
dwBytesLeft = This->dwLength - This->dwPos;
if ( 0 >= dwBytesLeft ) /* end of buffer */
return S_FALSE;
dwBytesToRead = ( cb > dwBytesLeft) ? dwBytesLeft : cb;
memmove ( pv, (This->pImage) + (This->dwPos), dwBytesToRead); if ( ! ReadFile( This->handle, pv, cb, pcbRead, NULL ) )
return E_FAIL;
This->dwPos += dwBytesToRead; /* adjust pointer */
if (pcbRead)
*pcbRead = dwBytesToRead;
return S_OK; return S_OK;
} }
static HRESULT WINAPI IStream_fnWrite (IStream * iface, const void* pv, ULONG cb, ULONG* pcbWritten) static HRESULT WINAPI IStream_fnWrite (IStream * iface, const void* pv, ULONG cb, ULONG* pcbWritten)
{ {
ICOM_THIS(ISHFileStream, iface); ICOM_THIS(ISHFileStream, iface);
TRACE("(%p)\n",This); TRACE("(%p)\n",This);
return E_NOTIMPL; if( !pv )
return STG_E_INVALIDPOINTER;
if( ! WriteFile( This->handle, pv, cb, pcbWritten, NULL ) )
return E_FAIL;
return S_OK;
} }
static HRESULT WINAPI IStream_fnSeek (IStream * iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition) static HRESULT WINAPI IStream_fnSeek (IStream * iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
{ {
DWORD pos, newposlo, newposhi;
ICOM_THIS(ISHFileStream, iface); ICOM_THIS(ISHFileStream, iface);
TRACE("(%p)\n",This); TRACE("(%p)\n",This);
return E_NOTIMPL; pos = dlibMove.QuadPart; /* FIXME: truncates */
newposhi = 0;
newposlo = SetFilePointer( This->handle, pos, &newposhi, dwOrigin );
if( newposlo == INVALID_SET_FILE_POINTER )
return E_FAIL;
plibNewPosition->QuadPart = newposlo | ( (LONGLONG)newposhi<<32);
return S_OK;
} }
static HRESULT WINAPI IStream_fnSetSize (IStream * iface, ULARGE_INTEGER libNewSize) static HRESULT WINAPI IStream_fnSetSize (IStream * iface, ULARGE_INTEGER libNewSize)
{ {
ICOM_THIS(ISHFileStream, iface); ICOM_THIS(ISHFileStream, iface);
TRACE("(%p)\n",This); TRACE("(%p)\n",This);
return E_NOTIMPL; if( ! SetFilePointer( This->handle, libNewSize.QuadPart, NULL, FILE_BEGIN ) )
return E_FAIL;
if( ! SetEndOfFile( This->handle ) )
return E_FAIL;
return S_OK;
} }
static HRESULT WINAPI IStream_fnCopyTo (IStream * iface, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten) static HRESULT WINAPI IStream_fnCopyTo (IStream * iface, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten)
{ {
......
...@@ -101,14 +101,12 @@ LPENUMIDLIST IEnumIDList_Constructor(LPCSTR,DWORD,DWORD); ...@@ -101,14 +101,12 @@ LPENUMIDLIST IEnumIDList_Constructor(LPCSTR,DWORD,DWORD);
LPEXTRACTICONA IExtractIconA_Constructor(LPITEMIDLIST); LPEXTRACTICONA IExtractIconA_Constructor(LPITEMIDLIST);
LPEXTRACTICONW IExtractIconW_Constructor(LPITEMIDLIST); LPEXTRACTICONW IExtractIconW_Constructor(LPITEMIDLIST);
HRESULT CreateStreamOnFile (LPCSTR pszFilename, IStream ** ppstm); HRESULT CreateStreamOnFile (LPCWSTR pszFilename, DWORD grfMode, IStream ** ppstm);
/* FIXME: rename the functions when the shell32.dll has it's own exports namespace */ /* FIXME: rename the functions when the shell32.dll has it's own exports namespace */
HRESULT WINAPI SHELL32_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID * ppv); HRESULT WINAPI SHELL32_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID * ppv);
HRESULT WINAPI SHELL32_DllCanUnloadNow(void); HRESULT WINAPI SHELL32_DllCanUnloadNow(void);
/* FIXME: move away */
#define ResultFromShort(i) MAKE_SCODE(SEVERITY_SUCCESS, 0, (USHORT)(i))
/* menu merging */ /* menu merging */
#define MM_ADDSEPARATOR 0x00000001L #define MM_ADDSEPARATOR 0x00000001L
......
...@@ -49,7 +49,8 @@ typedef enum ...@@ -49,7 +49,8 @@ typedef enum
*/ */
typedef enum typedef enum
{ SLGP_SHORTPATH = 0x0001, { SLGP_SHORTPATH = 0x0001,
SLGP_UNCPRIORITY = 0x0002 SLGP_UNCPRIORITY = 0x0002,
SLGP_RAWPATH = 0x0004
} SLGP_FLAGS; } SLGP_FLAGS;
/***************************************************************************** /*****************************************************************************
* IShellLink interface * IShellLink interface
......
...@@ -28,6 +28,7 @@ SUBDIRS = \ ...@@ -28,6 +28,7 @@ SUBDIRS = \
wineconsole \ wineconsole \
winedbg \ winedbg \
winefile \ winefile \
winemenubuilder \
winemine \ winemine \
winepath \ winepath \
winevdm \ winevdm \
...@@ -54,6 +55,7 @@ INSTALLSUBDIRS = \ ...@@ -54,6 +55,7 @@ INSTALLSUBDIRS = \
wineconsole \ wineconsole \
winedbg \ winedbg \
winefile \ winefile \
winemenubuilder \
winemine \ winemine \
winepath \ winepath \
winevdm \ winevdm \
...@@ -84,6 +86,7 @@ SYMLINKS = \ ...@@ -84,6 +86,7 @@ SYMLINKS = \
wcmd.exe \ wcmd.exe \
wineconsole.exe \ wineconsole.exe \
winedbg.exe \ winedbg.exe \
winemenubuilder.exe \
winevdm.exe \ winevdm.exe \
winhelp.exe winhelp.exe
...@@ -142,6 +145,9 @@ wineconsole.exe$(DLLEXT): wineconsole/wineconsole.exe$(DLLEXT) ...@@ -142,6 +145,9 @@ wineconsole.exe$(DLLEXT): wineconsole/wineconsole.exe$(DLLEXT)
winedbg.exe$(DLLEXT): winedbg/winedbg.exe$(DLLEXT) winedbg.exe$(DLLEXT): winedbg/winedbg.exe$(DLLEXT)
$(RM) $@ && $(LN_S) winedbg/winedbg.exe$(DLLEXT) $@ $(RM) $@ && $(LN_S) winedbg/winedbg.exe$(DLLEXT) $@
winemenubuilder.exe$(DLLEXT): winemenubuilder/winemenubuilder.exe$(DLLEXT)
$(RM) $@ && $(LN_S) winemenubuilder/winemenubuilder.exe$(DLLEXT) $@
winevdm.exe$(DLLEXT): winevdm/winevdm.exe$(DLLEXT) winevdm.exe$(DLLEXT): winevdm/winevdm.exe$(DLLEXT)
$(RM) $@ && $(LN_S) winevdm/winevdm.exe$(DLLEXT) $@ $(RM) $@ && $(LN_S) winevdm/winevdm.exe$(DLLEXT) $@
...@@ -151,6 +157,7 @@ winhelp.exe$(DLLEXT): winhelp/winhelp.exe$(DLLEXT) ...@@ -151,6 +157,7 @@ winhelp.exe$(DLLEXT): winhelp/winhelp.exe$(DLLEXT)
wcmd/wcmd.exe$(DLLEXT): wcmd wcmd/wcmd.exe$(DLLEXT): wcmd
wineconsole/wineconsole.exe$(DLLEXT): wineconsole wineconsole/wineconsole.exe$(DLLEXT): wineconsole
winedbg/winedbg.exe$(DLLEXT): winedbg winedbg/winedbg.exe$(DLLEXT): winedbg
winemenubuilder/winemenubuilder.exe$(DLLEXT): winemenubuilder
winevdm/winevdm.exe$(DLLEXT): winevdm winevdm/winevdm.exe$(DLLEXT): winevdm
winhelp/winhelp.exe$(DLLEXT): winhelp winhelp/winhelp.exe$(DLLEXT): winhelp
......
Makefile
winemenubuilder.exe.dbg.c
winemenubuilder.exe.spec.c
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = winemenubuilder.exe
APPMODE = gui
IMPORTS = shell32 ole32 user32 advapi32 kernel32
EXTRALIBS = $(LIBUUID)
C_SRCS = \
winemenubuilder.c
@MAKE_PROG_RULES@
install::
$(MKINSTALLDIRS) $(bindir)
$(INSTALL_SCRIPT) $(TOPSRCDIR)/tools/wineshelllink $(bindir)/wineshelllink
uninstall::
$(RM) $(bindir)/wineshelllink
### Dependencies:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment