ITSS: fix the ITS moniker implementation

Mike McCormack mike at codeweavers.com
Wed Aug 25 01:32:07 CDT 2004


With this fix, I can open chm files using HH.EXE and builtin ITSS.DLL

Mike


ChangeLog:
* fix the ITS moniker implementation
-------------- next part --------------
? dlls/itss/itsstor.h
Index: dlls/itss/chm_lib.c
===================================================================
RCS file: /home/wine/wine/dlls/itss/chm_lib.c,v
retrieving revision 1.1
diff -u -r1.1 chm_lib.c
--- dlls/itss/chm_lib.c	24 Aug 2004 21:00:15 -0000	1.1
+++ dlls/itss/chm_lib.c	25 Aug 2004 05:02:16 -0000
@@ -626,7 +626,7 @@
     /* open file */
     if ((newHandle->fd=CreateFileW(filename,
                                    GENERIC_READ,
-                                   0,
+                                   FILE_SHARE_READ,
                                    NULL,
                                    OPEN_EXISTING,
                                    FILE_ATTRIBUTE_NORMAL,
Index: dlls/itss/itss.c
===================================================================
RCS file: /home/wine/wine/dlls/itss/itss.c,v
retrieving revision 1.1
diff -u -r1.1 itss.c
--- dlls/itss/itss.c	24 Aug 2004 21:00:15 -0000	1.1
+++ dlls/itss/itss.c	25 Aug 2004 05:02:16 -0000
@@ -39,6 +39,8 @@
 #include "wine/unicode.h"
 #include "wine/debug.h"
 
+#include "itsstor.h"
+
 WINE_DEFAULT_DEBUG_CHANNEL(itss);
 
 #include "initguid.h"
@@ -48,8 +50,6 @@
 DEFINE_GUID(IID_IITStorage, 0x88cc31de, 0x27ab, 0x11d0, 0x9d, 0xf9, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xec);
 
 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj);
-extern HRESULT ITS_IParseDisplayName_create(IUnknown *pUnkOuter, LPVOID *ppObj);
-extern HRESULT ITSS_StgOpenStorage( const WCHAR*, IStorage*, DWORD, SNB, DWORD, IStorage** );
 
 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
 {
Index: dlls/itss/moniker.c
===================================================================
RCS file: /home/wine/wine/dlls/itss/moniker.c,v
retrieving revision 1.1
diff -u -r1.1 moniker.c
--- dlls/itss/moniker.c	24 Aug 2004 21:00:15 -0000	1.1
+++ dlls/itss/moniker.c	25 Aug 2004 05:02:16 -0000
@@ -38,6 +38,8 @@
 #include "wine/unicode.h"
 #include "wine/debug.h"
 
+#include "itsstor.h"
+
 WINE_DEFAULT_DEBUG_CHANNEL(itss);
 
 /*****************************************************************************/
@@ -153,8 +155,30 @@
     REFIID riid,
     void** ppvObj)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    ICOM_THIS(ITS_IMonikerImpl,iface);
+    DWORD grfMode = STGM_SIMPLE | STGM_READ | STGM_SHARE_EXCLUSIVE;
+    HRESULT r;
+    IStorage *stg = NULL;
+
+    TRACE("%p %p %p %s %p\n", This,
+           pbc, pmkToLeft, debugstr_guid(riid), ppvObj);
+
+    r = ITSS_StgOpenStorage( This->szFile, NULL, grfMode, 0, 0, &stg );
+    if( r == S_OK )
+    {
+        TRACE("Opened storage %s\n", debugstr_w( This->szFile ) );
+        if (IsEqualGUID(riid, &IID_IStream))
+            r = IStorage_OpenStream( stg, This->szHtml,
+                       NULL, grfMode, 0, (IStream**)ppvObj );
+        else if (IsEqualGUID(riid, &IID_IStorage))
+            r = IStorage_OpenStorage( stg, This->szHtml,
+                       NULL, grfMode, NULL, 0, (IStorage**)ppvObj );
+        else
+            r = STG_E_ACCESSDENIED;
+        IStorage_Release( stg );
+    }
+
+    return r;
 }
 
 static HRESULT WINAPI ITS_IMonikerImpl_Reduce(
Index: dlls/itss/storage.c
===================================================================
RCS file: /home/wine/wine/dlls/itss/storage.c,v
retrieving revision 1.1
diff -u -r1.1 storage.c
--- dlls/itss/storage.c	24 Aug 2004 21:00:15 -0000	1.1
+++ dlls/itss/storage.c	25 Aug 2004 05:02:16 -0000
@@ -36,12 +36,15 @@
 
 #include "itss.h"
 #include "chm_lib.h"
+#include "itsstor.h"
 
 #include "wine/unicode.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(itss);
 
+#include "initguid.h"
+
 /************************************************************************/
 
 typedef struct _ITSS_IStorageImpl
@@ -330,8 +333,16 @@
     len = strlenW( This->dir ) + strlenW( pwcsName ) + 1;
     path = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
     strcpyW( path, This->dir );
+    if( pwcsName[0] == '/' )
+    {
+        WCHAR *p = &path[strlenW( path ) - 1];
+        while( ( path <= p ) && ( *p = '/' ) )
+            *p-- = 0;
+    }
     strcatW( path, pwcsName );
 
+    TRACE("Resolving %s\n", debugstr_w(path));
+
     r = chm_resolve_object(This->chmfile, path, &ui);
     HeapFree( GetProcessHeap(), 0, path );
 
@@ -368,7 +379,10 @@
     DWORD reserved,
     IStorage** ppstg)
 {
-    FIXME("\n");
+    ICOM_THIS(ITSS_IStorageImpl,iface);
+
+    FIXME("%p %s %p %lu %p %lu %p\n", This, debugstr_w(pwcsName),
+          pstgPriority, grfMode, snbExclude, reserved, ppstg);
     return E_NOTIMPL;
 }
 
@@ -749,8 +763,21 @@
         STATSTG* pstatstg,
         DWORD grfStatFlag)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    ICOM_THIS(IStream_Impl,iface);
+
+    TRACE("%p %p %ld\n", This, pstatstg, grfStatFlag);
+
+    memset( pstatstg, 0, sizeof *pstatstg );
+    if( !( grfStatFlag & STATFLAG_NONAME ) )
+    {
+        FIXME("copy the name\n");
+    }
+    pstatstg->type = STGTY_STREAM;
+    pstatstg->cbSize.QuadPart = This->ui.length;
+    pstatstg->grfMode = STGM_READ;
+    memcpy( &pstatstg->clsid, &CLSID_ITStorage, sizeof (CLSID) );
+
+    return S_OK;
 }
 
 static HRESULT WINAPI ITSS_IStream_Clone(
--- /dev/null	1994-07-18 08:46:18.000000000 +0900
+++ dlls/itss/itsstor.h	2004-08-25 15:23:24.000000000 +0900
@@ -0,0 +1,38 @@
+/*
+ *    ITSS Storage implementation
+ *
+ * Copyright 2004 Mike McCormack
+ *
+ *  see http://bonedaddy.net/pabs3/hhm/#chmspec
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __WINE_ITS_STORAGE_PRIVATE__
+#define __WINE_ITS_STORAGE_PRIVATE__
+
+extern HRESULT ITSS_StgOpenStorage( 
+    const WCHAR* pwcsName,
+    IStorage* pstgPriority,
+    DWORD grfMode,
+    SNB snbExclude,
+    DWORD reserved,
+    IStorage** ppstgOpen);
+
+extern HRESULT ITS_IParseDisplayName_create(
+    IUnknown *pUnkOuter,
+    LPVOID *ppObj);
+
+#endif /* __WINE_ITS_STORAGE_PRIVATE__ */


More information about the wine-patches mailing list