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
programs/wineconsole/Makefile
programs/winedbg/Makefile
programs/winefile/Makefile
programs/winemenubuilder/Makefile
programs/winemine/Makefile
programs/winepath/Makefile
programs/winevdm/Makefile
......
......@@ -58,13 +58,6 @@ SUBDIRS = tests
@MAKE_DLL_RULES@
install::
$(MKINSTALLDIRS) $(bindir)
$(INSTALL_SCRIPT) $(TOPSRCDIR)/tools/wineshelllink $(bindir)/wineshelllink
uninstall::
$(RM) $(bindir)/wineshelllink
# Special rules for 16-bit resource files
version16.res: version16.rc
......
......@@ -9,6 +9,7 @@
* access in a IStream to.
*
* Copyright 1999 Juergen Schmied
* Copyright 2003 Mike McCormack for Codeweavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -73,10 +74,7 @@ static ICOM_VTABLE(IStream) stvt =
typedef struct
{ ICOM_VTABLE(IStream) *lpvtst;
DWORD ref;
LPBYTE pImage;
HANDLE hMapping;
DWORD dwLength;
DWORD dwPos;
HANDLE handle;
} ISHFileStream;
/**************************************************************************
......@@ -84,40 +82,42 @@ typedef struct
*
* similar to CreateStreamOnHGlobal
*/
HRESULT CreateStreamOnFile (LPCSTR pszFilename, IStream ** ppstm)
HRESULT CreateStreamOnFile (LPCWSTR pszFilename, DWORD grfMode, IStream ** ppstm)
{
ISHFileStream* fstr;
OFSTRUCT ofs;
HFILE hFile = OpenFile( pszFilename, &ofs, OF_READ );
HRESULT ret = E_FAIL;
HANDLE handle;
DWORD access = GENERIC_READ, creat;
fstr = (ISHFileStream*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ISHFileStream));
fstr->lpvtst=&stvt;
fstr->ref = 1;
fstr->dwLength = GetFileSize ((HANDLE)hFile, NULL);
if( grfMode & STGM_TRANSACTED )
return E_INVALIDARG;
if (!(fstr->hMapping = CreateFileMappingA((HANDLE)hFile,NULL,PAGE_READONLY|SEC_COMMIT,0,0,NULL)))
{
WARN("failed to create filemap.\n");
goto end_2;
}
if( grfMode & STGM_WRITE )
access |= GENERIC_WRITE;
if( grfMode & STGM_READWRITE )
access = GENERIC_WRITE | GENERIC_READ;
if (!(fstr->pImage = MapViewOfFile(fstr->hMapping,FILE_MAP_READ,0,0,0)))
{
WARN("failed to mmap filemap.\n");
goto end_3;
}
if( grfMode & STGM_CREATE )
creat = CREATE_ALWAYS;
else
creat = OPEN_EXISTING;
TRACE("Opening %s\n", debugstr_w(pszFilename) );
ret = S_OK;
goto end_1;
handle = CreateFileW( pszFilename, access, 0, NULL, creat, 0, NULL );
if( handle == INVALID_HANDLE_VALUE )
return E_FAIL;
end_3: CloseHandle(fstr->hMapping);
end_2: HeapFree(GetProcessHeap(), 0, fstr);
fstr = NULL;
fstr = (ISHFileStream*)HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,sizeof(ISHFileStream));
if( !fstr )
return E_FAIL;
fstr->lpvtst=&stvt;
fstr->ref = 1;
fstr->handle = handle;
end_1: _lclose(hFile);
(*ppstm) = (IStream*)fstr;
return ret;
return S_OK;
}
/**************************************************************************
......@@ -169,13 +169,10 @@ static ULONG WINAPI IStream_fnRelease(IStream *iface)
TRACE("(%p)->()\n",This);
if (!--(This->ref))
{ TRACE(" destroying SHFileStream (%p)\n",This);
UnmapViewOfFile(This->pImage);
CloseHandle(This->hMapping);
HeapFree(GetProcessHeap(),0,This);
return 0;
{
TRACE(" destroying SHFileStream (%p)\n",This);
CloseHandle(This->handle);
HeapFree(GetProcessHeap(),0,This);
}
return This->ref;
}
......@@ -184,52 +181,64 @@ static HRESULT WINAPI IStream_fnRead (IStream * iface, void* pv, ULONG cb, ULONG
{
ICOM_THIS(ISHFileStream, iface);
DWORD dwBytesToRead, dwBytesLeft;
TRACE("(%p)->(%p,0x%08lx,%p)\n",This, pv, cb, pcbRead);
if ( !pv )
return STG_E_INVALIDPOINTER;
dwBytesLeft = This->dwLength - This->dwPos;
if ( 0 >= dwBytesLeft ) /* end of buffer */
return S_FALSE;
dwBytesToRead = ( cb > dwBytesLeft) ? dwBytesLeft : cb;
return STG_E_INVALIDPOINTER;
memmove ( pv, (This->pImage) + (This->dwPos), dwBytesToRead);
This->dwPos += dwBytesToRead; /* adjust pointer */
if (pcbRead)
*pcbRead = dwBytesToRead;
if ( ! ReadFile( This->handle, pv, cb, pcbRead, NULL ) )
return E_FAIL;
return S_OK;
}
static HRESULT WINAPI IStream_fnWrite (IStream * iface, const void* pv, ULONG cb, ULONG* pcbWritten)
{
ICOM_THIS(ISHFileStream, iface);
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)
{
DWORD pos, newposlo, newposhi;
ICOM_THIS(ISHFileStream, iface);
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)
{
ICOM_THIS(ISHFileStream, iface);
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)
{
......
......@@ -101,14 +101,12 @@ LPENUMIDLIST IEnumIDList_Constructor(LPCSTR,DWORD,DWORD);
LPEXTRACTICONA IExtractIconA_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 */
HRESULT WINAPI SHELL32_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID * ppv);
HRESULT WINAPI SHELL32_DllCanUnloadNow(void);
/* FIXME: move away */
#define ResultFromShort(i) MAKE_SCODE(SEVERITY_SUCCESS, 0, (USHORT)(i))
/* menu merging */
#define MM_ADDSEPARATOR 0x00000001L
......
......@@ -49,7 +49,8 @@ typedef enum
*/
typedef enum
{ SLGP_SHORTPATH = 0x0001,
SLGP_UNCPRIORITY = 0x0002
SLGP_UNCPRIORITY = 0x0002,
SLGP_RAWPATH = 0x0004
} SLGP_FLAGS;
/*****************************************************************************
* IShellLink interface
......
......@@ -28,6 +28,7 @@ SUBDIRS = \
wineconsole \
winedbg \
winefile \
winemenubuilder \
winemine \
winepath \
winevdm \
......@@ -54,6 +55,7 @@ INSTALLSUBDIRS = \
wineconsole \
winedbg \
winefile \
winemenubuilder \
winemine \
winepath \
winevdm \
......@@ -84,6 +86,7 @@ SYMLINKS = \
wcmd.exe \
wineconsole.exe \
winedbg.exe \
winemenubuilder.exe \
winevdm.exe \
winhelp.exe
......@@ -142,6 +145,9 @@ wineconsole.exe$(DLLEXT): wineconsole/wineconsole.exe$(DLLEXT)
winedbg.exe$(DLLEXT): 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)
$(RM) $@ && $(LN_S) winevdm/winevdm.exe$(DLLEXT) $@
......@@ -151,6 +157,7 @@ winhelp.exe$(DLLEXT): winhelp/winhelp.exe$(DLLEXT)
wcmd/wcmd.exe$(DLLEXT): wcmd
wineconsole/wineconsole.exe$(DLLEXT): wineconsole
winedbg/winedbg.exe$(DLLEXT): winedbg
winemenubuilder/winemenubuilder.exe$(DLLEXT): winemenubuilder
winevdm/winevdm.exe$(DLLEXT): winevdm
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