First step to make it possible to call COM interfaces from C++ code in

Winelib.
oldstable
François Gouget 1998-12-18 16:00:03 +00:00 committed by Alexandre Julliard
parent 374a0a8fe2
commit d604eb12ff
6 changed files with 864 additions and 272 deletions

View File

@ -20,19 +20,19 @@ type win16
# as 16->32 relays. They use the cdecl calling convention.
# IStorage
500 cdecl IStorage16_QueryInterface(ptr ptr ptr) IStorage16_QueryInterface
501 cdecl IStorage16_AddRef(ptr) IStorage16_AddRef
502 cdecl IStorage16_Release(ptr) IStorage16_Release
#503 cdecl IStorage16_CreateStream(ptr str long long long ptr) IStorage16_CreateStream
500 cdecl IStorage16_QueryInterface(ptr ptr ptr) IStorage16_fnQueryInterface
501 cdecl IStorage16_AddRef(ptr) IStorage16_fnAddRef
502 cdecl IStorage16_Release(ptr) IStorage16_fnRelease
#503 cdecl IStorage16_CreateStream(ptr str long long long ptr) IStorage16_fnCreateStream
503 stub IStorage16_CreateStream
504 cdecl IStorage16_OpenStream(ptr str ptr long long ptr) IStorage16_OpenStream
#505 cdecl IStorage16_CreateStorage(ptr str long long long ptr) IStorage16_CreateStorage
504 cdecl IStorage16_OpenStream(ptr str ptr long long ptr) IStorage16_fnOpenStream
#505 cdecl IStorage16_CreateStorage(ptr str long long long ptr) IStorage16_fnCreateStorage
505 stub IStorage16_CreateStorage
506 cdecl IStorage16_OpenStorage(ptr str ptr long ptr long ptr) IStorage16_OpenStorage
507 cdecl IStorage16_CopyTo(ptr long ptr ptr ptr) IStorage16_CopyTo
506 cdecl IStorage16_OpenStorage(ptr str ptr long ptr long ptr) IStorage16_fnOpenStorage
507 cdecl IStorage16_CopyTo(ptr long ptr ptr ptr) IStorage16_fnCopyTo
508 stub IStorage16_MoveElementTo
509 cdecl IStorage16_Commit(ptr long) IStorage16_Commit
509 cdecl IStorage16_Commit(ptr long) IStorage16_fnCommit
510 stub IStorage16_Revert
511 stub IStorage16_EnumElements
512 stub IStorage16_DestroyElement
@ -40,16 +40,16 @@ type win16
514 stub IStorage16_SetElementTimes
515 stub IStorage16_SetClass
516 stub IStorage16_SetStateBits
517 cdecl IStorage16_Stat(ptr ptr long) IStorage16_Stat
517 cdecl IStorage16_Stat(ptr ptr long) IStorage16_fnStat
# IStream
518 cdecl IStream16_QueryInterface(ptr ptr ptr) IStream16_QueryInterface
519 cdecl IStream16_AddRef(ptr) IStream16_AddRef
520 cdecl IStream16_Release(ptr) IStream16_Release
521 cdecl IStream16_Read(ptr ptr long ptr) IStream16_Read
#522 cdecl IStream16_Write(ptr ptr long ptr) IStream16_Write
518 cdecl IStream16_QueryInterface(ptr ptr ptr) IStream16_fnQueryInterface
519 cdecl IStream16_AddRef(ptr) IStream16_fnAddRef
520 cdecl IStream16_Release(ptr) IStream16_fnRelease
521 cdecl IStream16_Read(ptr ptr long ptr) IStream16_fnRead
#522 cdecl IStream16_Write(ptr ptr long ptr) IStream16_fnWrite
522 stub IStream16_Write
523 cdecl IStream16_Seek(ptr long long long ptr) IStream16_Seek
523 cdecl IStream16_Seek(ptr long long long ptr) IStream16_fnSeek
524 stub IStream16_SetSize
525 stub IStream16_CopyTo
526 stub IStream16_Commit

View File

@ -25,19 +25,7 @@ DEFINE_OLEGUID(IID_IRootStorage,0x12,0,0);
DEFINE_OLEGUID(IID_IMessageFilter,0x16,0,0);
DEFINE_OLEGUID(IID_IStdMarshalInfo,0x18,0,0);
#define THIS LPUNKNOWN this
typedef struct IUnknown *LPUNKNOWN,IUnknown;
typedef struct {
STDMETHOD(QueryInterface) (THIS_ REFIID riid,LPVOID FAR* ppvObj) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
} *LPUNKNOWN_VTABLE,IUnknown_VTable;
struct IUnknown {
LPUNKNOWN_VTABLE lpvtbl;
DWORD ref;
};
#undef THIS
#include "objbase.h"
#define THIS LPCLASSFACTORY this
typedef struct IClassFactory *LPCLASSFACTORY,IClassFactory;

465
include/objbase.h 100644
View File

@ -0,0 +1,465 @@
#ifndef __WINE_OBJBASE_H
#define __WINE_OBJBASE_H
/*
* The goal of the following set of definitions is to provide a way to use the same
* header file definitions to provide both a C interface and a C++ object oriented
* interface to COM interfaces. The type of interface is selected automatically
* depending on the language but it is always possible to get the C interface in C++
* by defining CINTERFACE.
*
* It is based on the following assumptions:
* - all COM interfaces derive from IUnknown, this should not be a problem.
* - the header file only defines the interface, the actual fields are defined
* separately in the C file implementing the interface.
* - no COM method returns void. This seems to be the case but otherwise we could support this
* case by having one more set of macros.
*
* The natural approach to this problem would be to make sure we get a C++ class and
* virtual methods in C++ and a structure with a table of pointer to functions in C.
* Unfortunately the layout of the virtual table is compiler specific, the layout of
* g++ virtual tables is not the same as that of an egcs virtual table which is not the
* same as that generated by Visual C+. There are workarounds to make the virtual tables
* compatible via padding but unfortunately the one which is imposed to the WINE emulator
* by the Windows binaries, i.e. the Visual C++ one, is the most compact of all.
*
* So the solution I finally adopted does not use virtual tables. Instead I use inline
* non virtual methods that dereference the method pointer themselves and perform the call.
*
* Let's take Direct3D as an example:
*
* #define ICOM_INTERFACE IDirect3D
* ICOM_BEGIN(IDirect3D,IUnknown)
* ICOM_METHOD1(HRESULT,Initialize, REFIID,);
* ICOM_METHOD2(HRESULT,EnumDevices, LPD3DENUMDEVICESCALLBACK,, LPVOID,);
* ICOM_METHOD2(HRESULT,CreateLight, LPDIRECT3DLIGHT*,, IUnknown*,);
* ICOM_METHOD2(HRESULT,CreateMaterial,LPDIRECT3DMATERIAL*,, IUnknown*,);
* ICOM_METHOD2(HRESULT,CreateViewport,LPDIRECT3DVIEWPORT*,, IUnknown*,);
* ICOM_METHOD2(HRESULT,FindDevice, LPD3DFINDDEVICESEARCH,, LPD3DFINDDEVICERESULT,);
* ICOM_END(IDirect3D)
* #undef ICOM_INTERFACE
*
* #if !defined(__cplusplus) || defined(CINTERFACE)
* // *** IUnknown methods *** //
* #define IDirect3D_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b)
* #define IDirect3D_AddRef(p) ICOM_ICALL (IUnknown,AddRef,p)
* #define IDirect3D_Release(p) ICOM_ICALL (IUnknown,Release,p)
* // *** IDirect3D methods *** //
* #define IDirect3D_Initialize(p,a) ICOM_CALL1(Initialize,p,a)
* #define IDirect3D_EnumDevices(p,a,b) ICOM_CALL2(EnumDevice,p,a,b)
* #define IDirect3D_CreateLight(p,a,b) ICOM_CALL2(CreateLight,p,a,b)
* #define IDirect3D_CreateMaterial(p,a,b) ICOM_CALL2(CreateMaterial,p,a,b)
* #define IDirect3D_CreateViewport(p,a,b) ICOM_CALL2(CreateViewport,p,a,b)
* #define IDirect3D_FindDevice(p,a,b) ICOM_CALL2(FindDevice,p,a,b)
* #endif
*
* Comments:
* - The ICOM_INTERFACE is used in the ICOM_METHOD macros for the 'this' pointer and to cast
* pointers. Defining this macro here saves us the trouble of having to repeat the interface
* name everywhere. Note haowever that because of the way macros work a macro like ICOM_METHOD1
* cannot use 'ICOM_INTERFACE##_VTABLE' because this would give 'ICOM_INTERFACE_VTABLE' and not
* 'IDirect3D_VTABLE'.
* - ICOM_BEGIN and ICOM_END are responsible for generating whatever structure is appropriate for
* representing the interface in the current language. In C this is a couple of structs in C++
* it's a class. The first parameter is the interface name and the second one is the interface
* we inherit from. The reason why you have to repeat the interface name is because that's the
* only way these macro can successfully output "IDirect3D_VTABLE'. Trying to use ICOM_INTERFACE
* would, as in ICOM_METHOD, only yield 'ICOM_INTERFACE_VTABLE'.
* - With the way ICOM_BEGIN works you don't have to repeat the definitions of the methods of the
* parent interface. They are automatically inherited both in C and in C++.
* - In C++ the ICOM_METHOD macros generate a function prototype and a call to a function pointer
* method. This means using once 't1 p1, t2 p2, ...' and once 'p1, p2' without the types. The
* only way I found to handle this is to have one ICOM_METHOD macro per number of parameters and
* to have it take only the type information (with const if necessary) as parameters.
* The 'undef ICOM_INTERFACE' is here to remind you that using ICOM_INTERFACE in the following
* macros will not work. This time it's because the ICOM_CALL macro expansion is done only once
* the 'IDirect3D_Xxx' macro is expanded. And by that time ICOM_INTERFACE will be long gone
* anyway.
* - You may have noticed the double commas after each parameter type. This allows you to put the
* name of that parameter which I think is good for documentation. It is not required and since
* I did not know what to put there for this example (I could only find doc about IDirect3D2),
* I left them blank.
* - Finally the set of 'IDirect3D_Xxx' macros is a standard set of macros defined to ease access
* to the interface methods in C. Unfortunately I don't see any way to avoid having to duplicate
* the inherited method definitions there. We must use ICOM_ICALL to invoke inherited methods,
* because in C we have to cast the virtual table pointer, and we should use the ICOM_CALL
* method in the other cases. This time I could have used a trick to use only one macro whatever
* the number of parameters but I prefered to have it work the same way as above.
* - You probably have noticed that we don't define the fields we need to actually implement this
* interface: reference count, pointer to other resources and miscellaneous fields. That's
* because it's not needed, and the user will anyway only manipulate pointers to this structure
* so he does not need to know its real size. Of course on the implementation side we have the
* real definition of the interface structure and they should match what the macros yield in
* each language (or conversely).
*
*
* In C this gives:
* typedef struct IDirect3D_VTABLE IDirect3D_VTABLE;
* struct IDirect3D {
* IDirect3D_VTABLE* lpvtbl;
* };
* struct IDirect3D_VTABLE {
* IUnknown_VTABLE bvt;
* HRESULT (*fnInitialize)(IDirect3D* me, REFIID a);
* HRESULT (*fnEnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b);
* HRESULT (*fnCreateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b);
* HRESULT (*fnCreateMaterial)(IDirect3D* me, LPDIRECT3DMATERIAL* a, IUnknown* b);
* HRESULT (*fnCreateViewport)(IDirect3D* me, LPDIRECT3DVIEWPORT* a, IUnknown* b);
* HRESULT (*fnFindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b);
* };
*
* #if !defined(__cplusplus) || defined(CINTERFACE)
* // *** IUnknown methods *** //
* #define IDirect3D_QueryInterface(p,a,b) ((IUnknown_VTABLE*)(p)->lpvtbl)->fnQueryInterface((IUnknown*)p,a,b)
* #define IDirect3D_AddRef(p) ((IUnknown_VTABLE*)(p)->lpvtbl)->fnAddRef((IUnknown*)p)
* #define IDirect3D_Release(p) ((IUnknown_VTABLE*)(p)->lpvtbl)->fnRelease((IUnknown*)p)
* // *** IDirect3D methods *** //
* #define IDirect3D_Initialize(p,a) (p)->lpvtbl->fnInitialize(p,a)
* #define IDirect3D_EnumDevices(p,a,b) (p)->lpvtbl->fnEnumDevice(p,a,b)
* #define IDirect3D_CreateLight(p,a,b) (p)->lpvtbl->fnCreateLight(p,a,b)
* #define IDirect3D_CreateMaterial(p,a,b) (p)->lpvtbl->fnCreateMaterial(p,a,b)
* #define IDirect3D_CreateViewport(p,a,b) (p)->lpvtbl->fnCreateViewport(p,a,b)
* #define IDirect3D_FindDevice(p,a,b) (p)->lpvtbl->fnFindDevice(p,a,b)
* #endif
*
* Comments:
* - IDirect3D only contains a pointer to the IDirect3D virtual/jump table. This is the only thing
* the user needs to know to use the interface. Of course the structure we will define to
* implement this interface will have more fields but the first one will match this pointer.
* - The code generated by ICOM_BEGIN goes up to the bvt field in the IDirect3D virtual table.
* This bvt field is what saves us from having to duplicate the inherited method definitions.
* It's a shame that C (gcc) will not allow unnamed structs. If this was possible we could
* seamlessly inherit and use the parent's interface function pointers.
* - What follows is just a bunch of function pointer definitions generated by the ICOM_METHOD
* macros. The implementation will fill this jump table with appropriate values in a static
* variable and initialize the lpvtbl field to point to this variable.
* - The IDirect3D_Xxx macros then just derefence the lpvtbl pointer and use the function pointer
* corresponding to the macro name. This emulates the behavior of a virtual table and should be
* about as fast. In the case of inherited methods we have some additional casting to do to
* because the inherited methods are defined in the bvt field or maybe further imbricated. Since
* the effect of the bvt field is that we inherit the parent virtual table fields this cast is
* relatively inocuous. A similar cast must be performed on the interface pointer before the
* invoked method will accept it. Despite all these casts there is little chance that you call a
* method on the wrong type of interface because the function names still have to match. But this
* is the only thing that will make the compilation fail.
*
*
* And in C++ (with gcc's g++):
*
* typedef struct IDirect3D: public IUnknown {
* private: HRESULT (*fnInitialize)(IDirect3D* me, REFIID a);
* public: inline HRESULT Initialize(REFIID a) { return ((IDirect3D*)t.lpvtbl)->fnInitialize(this,a); };
* private: HRESULT (*fnEnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b);
* public: inline HRESULT EnumDevices(LPD3DENUMDEVICESCALLBACK a, LPVOID b)
* { return ((IDirect3D*)t.lpvtbl)->fnEnumDevices(this,a,b); };
* private: HRESULT (*fnCreateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b);
* public: inline HRESULT CreateLight(LPDIRECT3DLIGHT* a, IUnknown* b)
* { return ((IDirect3D*)t.lpvtbl)->fnCreateLight(this,a,b); };
* private: HRESULT (*fnCreateMaterial)(IDirect3D* me, LPDIRECT3DMATERIAL* a, IUnknown* b);
* public: inline HRESULT CreateMaterial(LPDIRECT3DMATERIAL* a, IUnknown* b)
* { return ((IDirect3D*)t.lpvtbl)->fnCreateMaterial(this,a,b); };
* private: HRESULT (*fnCreateViewport)(IDirect3D* me, LPDIRECT3DVIEWPORT* a, IUnknown* b);
* public: inline HRESULT CreateViewport(LPDIRECT3DVIEWPORT* a, IUnknown* b)
* { return ((IDirect3D*)t.lpvtbl)->fnCreateViewport(this,a,b); };
* private: HRESULT (*fnFindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b);
* public: inline HRESULT FindDevice(LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b)
* { return ((IDirect3D*)t.lpvtbl)->fnFindDevice(this,a,b); };
* };
*
* Comments:
* - In C++ IDirect3D does double duty as both the virtual/jump table and as the interface
* definition. The reason for this is to avoid having to duplicate the mehod definitions: once
* to have the function pointers in the jump table and once to have the methods in the interface
* class. Here one macro can generate both. This means though that the first pointer, t.lpvtbl
* defined in IUnknown, must be interpreted as the jump table pointer if we interpret the
* structure as the the interface class, and as the function pointer to the QueryInterface
* method, t.fnQueryInterface, if we interpret the structure as the jump table. Fortunately this
* gymnastic is entirely taken care of in the header of IUnknown.
* - Of course in C++ we use inheritance so that we don't have to duplicate the method definitions.
* - Since IDirect3D does double duty, each ICOM_METHOD macro defines both a function pointer and
* a non-vritual inline method which dereferences it and calls it. This way this method behaves
* just like a virtual method but does not create a true C++ virtual table which would break the
* structure layout. If you look at the implementation of these methods you'll notice that they
* would not work for void functions. We have to return something and fortunately this seems to
* be what all the COM methods do (otherwise we would need another set of macros).
* - Note how the ICOM_METHOD generates both function prototypes mixing types and formal parameter
* names and the method invocation using only the formal parameter name. This is the reason why
* we need different macros to handle different numbers of parameters.
* - Finally there is no IDirect3D_Xxx macro. These are not needed in C++ unless the CINTERFACE
* macro is defined in which case we would not be here.
*
*
* Implementing a COM interface.
*
* This continues the above example.I assume the implementation is in C but it would probably
* be similar in C++.
*
* typedef struct _IDirect3D {
* void* lpvtbl;
* // ...
*
* } _IDirect3D;
*
* static ICOM_VTABLE(IDirect3D) d3dvt;
*
* // implement the IDirect3D methods here
*
* int IDirect3D_fnQueryInterface(LPUNKNOWN me)
* {
* ICOM_THIS(IDirect3D,me);
* // ...
* }
*
* // ...
*
* static ICOM_VTABLE(IDirect3D) d3dvt = {
* {
* IDirect3D_fnQueryInterface,
* IUnknown_fnAdd,
* IUnknown_fnAdd2
* },
* IDirect3D_fnInitialize,
* IDirect3D_fnSetWidth
* };
*
* Comments:
* - We first define what the interface really contains. This is th e_IDirect3D structure. The
* first field must of course be the virtual table pointer. Everything else is free.
* - Then we predeclare our static virtual table variable, we will need its address in some
* methods to initialize the virtual table pointer of the returned interface objects.
* - Then we implement the interface methods. To match what has been declared in the header file
* they must take a pointer to a IDirect3D structure so we must cast it to an _IDirect3D so that
* we can manipulate the fields. This is performed by the ICOM_THIS macro.
* - Finally we initialize the virtual table. The inherited methods must be in curly brackets to
* match the parent interface's virtual table definition.
*/
#define ICOM_VTABLE(iface) iface##_VTABLE
#if defined(__cplusplus) && !defined(CINTERFACE)
/* C++ interface */
#define ICOM_BEGIN(iface,ibase) \
typedef struct iface: public ibase {
#define ICOM_METHOD(ret,xfn) \
private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me); \
public: inline ret (CALLBACK xfn)(void) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this); };
#define ICOM_METHOD1(ret,xfn,ta,na) \
private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a); \
public: inline ret (CALLBACK xfn)(ta a) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a); };
#define ICOM_METHOD2(ret,xfn,ta,na,tb,nb) \
private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b); \
public: inline ret (CALLBACK xfn)(ta a,tb b) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b); };
#define ICOM_METHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c); \
public: inline ret (CALLBACK xfn)(ta a,tb b,tc c) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c); };
#define ICOM_METHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d); \
public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d); };
#define ICOM_METHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e); \
public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e); };
#define ICOM_METHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f); \
public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f); };
#define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); \
public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g); };
#define ICOM_CMETHOD(ret,xfn) \
private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me); \
public: inline ret (CALLBACK xfn)(void) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this); };
#define ICOM_CMETHOD1(ret,xfn,ta,na) \
private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a); \
public: inline ret (CALLBACK xfn)(ta a) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a); };
#define ICOM_CMETHOD2(ret,xfn,ta,na,tb,nb) \
private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b); \
public: inline ret (CALLBACK xfn)(ta a,tb b) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b); };
#define ICOM_CMETHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c); \
public: inline ret (CALLBACK xfn)(ta a,tb b,tc c) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c); };
#define ICOM_CMETHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d); \
public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d); };
#define ICOM_CMETHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e); \
public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e); };
#define ICOM_CMETHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f); \
public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f); };
#define ICOM_CMETHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); \
public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g); };
#define ICOM_END(iface) \
};
#define ICOM_ICALL(ibase, xfn, p) this_is_a_syntax_error
#define ICOM_ICALL1(ibase, xfn, p,a) this_is_a_syntax_error
#define ICOM_ICALL2(ibase, xfn, p,a,b) this_is_a_syntax_error
#define ICOM_ICALL3(ibase, xfn, p,a,b,c) this_is_a_syntax_error
#define ICOM_ICALL4(ibase, xfn, p,a,b,c,d) this_is_a_syntax_error
#define ICOM_ICALL5(ibase, xfn, p,a,b,c,d,e) this_is_a_syntax_error
#define ICOM_ICALL6(ibase, xfn, p,a,b,c,d,e,f) this_is_a_syntax_error
#define ICOM_ICALL7(ibase, xfn, p,a,b,c,d,e,f,g) this_is_a_syntax_error
#define ICOM_CALL(xfn, p) this_is_a_syntax_error
#define ICOM_CALL1(xfn, p,a) this_is_a_syntax_error
#define ICOM_CALL2(xfn, p,a,b) this_is_a_syntax_error
#define ICOM_CALL3(xfn, p,a,b,c) this_is_a_syntax_error
#define ICOM_CALL4(xfn, p,a,b,c,d) this_is_a_syntax_error
#define ICOM_CALL5(xfn, p,a,b,c,d,e) this_is_a_syntax_error
#define ICOM_CALL6(xfn, p,a,b,c,d,e,f) this_is_a_syntax_error
#define ICOM_CALL7(xfn, p,a,b,c,d,e,f,g) this_is_a_syntax_error
#else
/* C interface */
#define ICOM_BEGIN(iface,ibase) \
typedef struct ICOM_VTABLE(iface) ICOM_VTABLE(iface); \
struct iface { \
const ICOM_VTABLE(iface)* lpvtbl; \
}; \
struct ICOM_VTABLE(iface) { \
ICOM_VTABLE(ibase) bvt;
#define ICOM_METHOD(ret, xfn) \
ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me);
#define ICOM_METHOD1(ret,xfn,ta,na) \
ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a);
#define ICOM_METHOD2(ret,xfn,ta,na,tb,nb) \
ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b);
#define ICOM_METHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c);
#define ICOM_METHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
#define ICOM_METHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
#define ICOM_METHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
#define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
#define ICOM_CMETHOD(ret, xfn) \
ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me);
#define ICOM_CMETHOD1(ret,xfn,ta,na) \
ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a);
#define ICOM_CMETHOD2(ret,xfn,ta,na,tb,nb) \
ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b);
#define ICOM_CMETHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c);
#define ICOM_CMETHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
#define ICOM_CMETHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
#define ICOM_CMETHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
#define ICOM_CMETHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
#define ICOM_END(iface) \
};
#define ICOM_ICALL(ibase, xfn, p) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p)
#define ICOM_ICALL1(ibase, xfn, p,a) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a)
#define ICOM_ICALL2(ibase, xfn, p,a,b) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b)
#define ICOM_ICALL3(ibase, xfn, p,a,b,c) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c)
#define ICOM_ICALL4(ibase, xfn, p,a,b,c,d) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c,d)
#define ICOM_ICALL5(ibase, xfn, p,a,b,c,d,e) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c,d,e)
#define ICOM_ICALL6(ibase, xfn, p,a,b,c,d,e,f) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c,d,e,f)
#define ICOM_ICALL7(ibase, xfn, p,a,b,c,d,e,f,g) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c,d,e,f,g)
#define ICOM_CALL(xfn, p) (p)->lpvtbl->fn##xfn(p)
#define ICOM_CALL1(xfn, p,a) (p)->lpvtbl->fn##xfn(p,a)
#define ICOM_CALL2(xfn, p,a,b) (p)->lpvtbl->fn##xfn(p,a,b)
#define ICOM_CALL3(xfn, p,a,b,c) (p)->lpvtbl->fn##xfn(p,a,b,c)
#define ICOM_CALL4(xfn, p,a,b,c,d) (p)->lpvtbl->fn##xfn(p,a,b,c,d)
#define ICOM_CALL5(xfn, p,a,b,c,d,e) (p)->lpvtbl->fn##xfn(p,a,b,c,d,e)
#define ICOM_CALL6(xfn, p,a,b,c,d,e,f) (p)->lpvtbl->fn##xfn(p,a,b,c,d,e,f)
#define ICOM_CALL7(xfn, p,a,b,c,d,e,f,g) (p)->lpvtbl->fn##xfn(p,a,b,c,d,e,f,g)
#define ICOM_THIS(iface,me) struct _##iface* this=(struct _##iface*)me
#define ICOM_CTHIS(iface,me) const _##iface* this=(const _##iface*)me
#endif
typedef struct IUnknown IUnknown ,*LPUNKNOWN;
/*****************************************************************************
* IUnknown interface
*/
#define ICOM_INTERFACE IUnknown
#if defined(__cplusplus) && !defined(CINTERFACE)
struct IUnknown {
union {
const void* lpvtbl;
HRESULT (CALLBACK *fnQueryInterface)(IUnknown* me, REFIID riid, LPVOID* ppvObj);
} t;
inline int QueryInterface(REFIID a, LPVOID* b) { return ((IUnknown*)t.lpvtbl)->t.fnQueryInterface(this,a,b); }
#else
typedef struct ICOM_VTABLE(IUnknown) ICOM_VTABLE(IUnknown);
struct IUnknown {
ICOM_VTABLE(IUnknown)* lpvtbl;
};
struct ICOM_VTABLE(IUnknown) {
ICOM_METHOD2(HRESULT,QueryInterface,REFIID,riid, LPVOID*,ppvObj)
#endif
ICOM_METHOD (ULONG,AddRef)
ICOM_METHOD (ULONG,Release)
#ifdef __WRC__
}; /* FIXME: WRC does not support function macros and it is ICOM_END that is supposed to close the class */
#else
ICOM_END(IUnknown)
#endif
#undef ICOM_INTERFACE
#if !defined(__cplusplus) || defined(CINTERFACE)
/*** IUnknown methods ***/
#define IUnknown_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
#define IUnknown_AddRef(p) ICOM_CALL (AddRef,p)
#define IUnknown_Release(p) ICOM_CALL (Release,p)
#endif
#endif /* __WINE_OBJBASE_H */

View File

@ -1,14 +1,10 @@
#ifndef _WINE_STORAGE_H
#define _WINE_STORAGE_H
#ifndef __WINE_STORAGE_H
#define __WINE_STORAGE_H
#include "objbase.h"
/* Does this look like a cellar to you? */
#define STDMETHOD(xfn) HRESULT (CALLBACK *fn##xfn)
#define STDMETHOD_(ret,xfn) ret (CALLBACK *fn##xfn)
#define PURE
#define FAR
#define THIS_ THIS,
struct storage_header {
BYTE magic[8]; /* 00: magic */
BYTE unknown1[36]; /* 08: unknown */
@ -82,131 +78,176 @@ typedef struct {
#define STGM_CONVERT 0x00020000
#define STGM_FAILIFTHERE 0x00000000
#define THIS LPSTORAGE16 this
typedef struct IStorage16_VTable {
/* IUnknown methods */
STDMETHOD(QueryInterface) (THIS_ REFIID riid,LPVOID FAR* ppvObj);
STDMETHOD_(ULONG,AddRef) (THIS);
STDMETHOD_(ULONG,Release) (THIS);
/* IStorage methods */
STDMETHOD(CreateStream)(THIS_ LPCOLESTR16 pwcsName, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStream16 **ppstm);
STDMETHOD(OpenStream)(THIS_ LPCOLESTR16 pwcsName, void *reserved1, DWORD grfMode, DWORD reserved2, IStream16 **ppstm);
STDMETHOD(CreateStorage)(THIS_ LPCOLESTR16 pwcsName, DWORD grfMode, DWORD dwStgFmt, DWORD reserved2, IStorage16 **ppstg);
STDMETHOD(OpenStorage)(THIS_ LPCOLESTR16 pwcsName,IStorage16 *pstgPriority, DWORD grfMode, SNB16 SNB16Exclude, DWORD reserved, IStorage16 **ppstg);
STDMETHOD(CopyTo)(THIS_ DWORD ciidExclude, const IID *rgiidExclude, SNB16 SNB16Exclude, IStorage16 *pstgDest);
STDMETHOD(MoveElementTo)(THIS_ LPCOLESTR16 pwcsName, IStorage16 *pstgDest, LPCOLESTR16 pwcsNewName, DWORD grfFlags);
STDMETHOD(Commit)(THIS_ DWORD grfCommitFlags);
STDMETHOD(Revert)(THIS);
STDMETHOD(EnumElements)(THIS_ DWORD reserved1,void *reserved2, DWORD reserved3, IEnumSTATSTG **ppenum);
STDMETHOD(DestroyElement)(THIS_ LPCOLESTR16 pwcsName);
STDMETHOD(RenameElement)(THIS_ LPCOLESTR16 pwcsOldName, LPCOLESTR16 pwcsNewName);
STDMETHOD(SetElementTimes)(THIS_ LPCOLESTR16 pwcsName, const FILETIME *pctime, const FILETIME *patime, const FILETIME *pmtime);
STDMETHOD(SetClass)(THIS_ REFCLSID clsid);
STDMETHOD(SetStateBits)(THIS_ DWORD grfStateBits, DWORD grfMask);
STDMETHOD(Stat)(THIS_ STATSTG *pstatstg, DWORD grfStatFlag);
} IStorage16_VTable,*LPSTORAGE16_VTABLE;
struct IStorage16 {
LPSTORAGE16_VTABLE lpvtbl;
DWORD ref;
SEGPTR thisptr; /* pointer to this struct as segmented */
struct storage_pps_entry stde;
int ppsent;
HFILE32 hf;
};
#undef THIS
#define THIS LPSTORAGE32 this
typedef struct IStorage32_VTable {
/* IUnknown methods */
STDMETHOD(QueryInterface) (THIS_ REFIID riid,LPVOID FAR* ppvObj);
STDMETHOD_(ULONG,AddRef) (THIS);
STDMETHOD_(ULONG,Release) (THIS);
/* IStorage methods */
STDMETHOD(CreateStream)(THIS_ LPCOLESTR32 pwcsName, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStream32 **ppstm);
STDMETHOD(OpenStream)(THIS_ LPCOLESTR32 pwcsName, void *reserved1, DWORD grfMode, DWORD reserved2, IStream32 **ppstm);
STDMETHOD(CreateStorage)(THIS_ LPCOLESTR32 pwcsName, DWORD grfMode, DWORD dwStgFmt, DWORD reserved2, IStorage32 **ppstg);
STDMETHOD(OpenStorage)(THIS_ LPCOLESTR32 pwcsName,IStorage32 *pstgPriority, DWORD grfMode, SNB32 SNB16Exclude, DWORD reserved, IStorage32 **ppstg);
STDMETHOD(CopyTo)(THIS_ DWORD ciidExclude, const IID *rgiidExclude, SNB32 SNB16Exclude, IStorage32 *pstgDest);
STDMETHOD(MoveElementTo)(THIS_ LPCOLESTR32 pwcsName, IStorage32 *pstgDest, LPCOLESTR32 pwcsNewName, DWORD grfFlags);
STDMETHOD(Commit)(THIS_ DWORD grfCommitFlags);
STDMETHOD(Revert)(THIS);
STDMETHOD(EnumElements)(THIS_ DWORD reserved1,void *reserved2, DWORD reserved3, IEnumSTATSTG **ppenum);
STDMETHOD(DestroyElement)(THIS_ LPCOLESTR32 pwcsName);
STDMETHOD(RenameElement)(THIS_ LPCOLESTR32 pwcsOldName, LPCOLESTR32 pwcsNewName);
STDMETHOD(SetElementTimes)(THIS_ LPCOLESTR32 pwcsName, const FILETIME *pctime, const FILETIME *patime, const FILETIME *pmtime);
STDMETHOD(SetClass)(THIS_ REFCLSID clsid);
STDMETHOD(SetStateBits)(THIS_ DWORD grfStateBits, DWORD grfMask);
STDMETHOD(Stat)(THIS_ STATSTG *pstatstg, DWORD grfStatFlag);
} IStorage32_VTable,*LPSTORAGE32_VTABLE;
/*****************************************************************************
* IStorage16 interface
*/
#define ICOM_INTERFACE IStorage16
ICOM_BEGIN(IStorage16,IUnknown)
ICOM_METHOD5(HRESULT,CreateStream, LPCOLESTR16,pwcsName, DWORD,grfMode, DWORD,reserved1, DWORD,reserved2, IStream16**,ppstm);
ICOM_METHOD5(HRESULT,OpenStream, LPCOLESTR16,pwcsName, void*,reserved1, DWORD,grfMode, DWORD,reserved2, IStream16**,ppstm);
ICOM_METHOD5(HRESULT,CreateStorage, LPCOLESTR16,pwcsName, DWORD,grfMode, DWORD,dwStgFmt, DWORD,reserved2, IStorage16**,ppstg);
ICOM_METHOD6(HRESULT,OpenStorage, LPCOLESTR16,pwcsName, IStorage16*,pstgPriority, DWORD,grfMode, SNB16,snb16Exclude, DWORD,reserved, IStorage16**,ppstg);
ICOM_METHOD4(HRESULT,CopyTo, DWORD,ciidExclude, const IID*,rgiidExclude, SNB16,snb16Exclude, IStorage16*,pstgDest);
ICOM_METHOD4(HRESULT,MoveElementTo, LPCOLESTR16,pwcsName, IStorage16*,pstgDest, LPCOLESTR16,pwcsNewName, DWORD,grfFlags);
ICOM_METHOD1(HRESULT,Commit, DWORD,grfCommitFlags);
ICOM_METHOD (HRESULT,Revert);
ICOM_METHOD4(HRESULT,EnumElements, DWORD,reserved1, void*,reserved2, DWORD,reserved3, IEnumSTATSTG**,ppenum);
ICOM_METHOD1(HRESULT,DestroyElement, LPCOLESTR16,pwcsName);
ICOM_METHOD2(HRESULT,RenameElement, LPCOLESTR16,pwcsOldName, LPCOLESTR16,pwcsNewName);
ICOM_METHOD4(HRESULT,SetElementTimes,LPCOLESTR16,pwcsName, const FILETIME*,pctime, const FILETIME*,patime, const FILETIME*,pmtime);
ICOM_METHOD1(HRESULT,SetClass, REFCLSID,clsid);
ICOM_METHOD2(HRESULT,SetStateBits, DWORD,grfStateBits, DWORD,grfMask);
ICOM_METHOD2(HRESULT,Stat, STATSTG*,pstatstg, DWORD,grfStatFlag);
ICOM_END(IStorage16)
#undef ICOM_INTERFACE
#if !defined(__cplusplus) || defined(CINTERFACE)
/*** IUnknown methods ***/
#define IStorage16_QueryInterface(p,a,b) ICOM_ICALL2(QueryInterface,p,a,b)
#define IStorage16_AddRef(p) ICOM_ICALL (AddRef,p)
#define IStorage16_Release(p) ICOM_ICALL (Release,p)
/*** IStorage16 methods ***/
#define IStorage16_CreateStream(p,a,b,c,d,e) ICOM_CALL5(CreateStream,p,a,b,c,d,e)
#define IStorage16_OpenStream(p,a,b,c,d,e) ICOM_CALL5(OpenStream,p,a,b,c,d,e)
#define IStorage16_CreateStorage(p,a,b,c,d,e) ICOM_CALL5(CreateStorage,p,a,b,c,d,e)
#define IStorage16_OpenStorage(p,a,b,c,d,e,f) ICOM_CALL6(OpenStorage,p,a,b,c,d,e,f)
#define IStorage16_CopyTo(p,a,b,c,d) ICOM_CALL4(CopyTo,p,a,b,c,d)
#define IStorage16_MoveElementTo(p,a,b,c,d) ICOM_CALL4(MoveElementTo,p,a,b,c,d)
#define IStorage16_Commit(p,a) ICOM_CALL1(Commit,p,a)
#define IStorage16_Revert(p) ICOM_CALL (Revert,p)
#define IStorage16_EnumElements(p,a,b,c,d) ICOM_CALL4(EnumElements,p,a,b,c,d)
#define IStorage16_DestroyElement(p,a) ICOM_CALL1(DestroyElement,p,a)
#define IStorage16_RenameElement(p,a,b) ICOM_CALL2(RenameElement,p,a,b)
#define IStorage16_SetElementTimes(p,a,b,c,d) ICOM_CALL4(SetElementTimes,p,a,b,c,d)
#define IStorage16_SetClass(p,a) ICOM_CALL1(SetClass,p,a)
#define IStorage16_SetStateBits(p,a,b) ICOM_CALL2(SetStateBits,p,a,b)
#define IStorage16_Stat(p,a,b) ICOM_CALL2(Stat,p,a,b)
#endif
/*****************************************************************************
* IStorage32 interface
*/
#define ICOM_INTERFACE IStorage32
ICOM_BEGIN(IStorage32,IUnknown)
ICOM_METHOD5(HRESULT,CreateStream, LPCOLESTR32,pwcsName, DWORD,grfMode, DWORD,reserved1, DWORD,reserved2, IStream32**,ppstm);
ICOM_METHOD5(HRESULT,OpenStream, LPCOLESTR32,pwcsName, void*,reserved1, DWORD,grfMode, DWORD,reserved2, IStream32**,ppstm);
ICOM_METHOD5(HRESULT,CreateStorage, LPCOLESTR32,pwcsName, DWORD,grfMode, DWORD,dwStgFmt, DWORD,reserved2, IStorage32**,ppstg);
ICOM_METHOD6(HRESULT,OpenStorage, LPCOLESTR32,pwcsName, IStorage32*,pstgPriority, DWORD,grfMode, SNB32,snb16Exclude, DWORD,reserved, IStorage32**,ppstg);
ICOM_METHOD4(HRESULT,CopyTo, DWORD,ciidExclude, const IID*,rgiidExclude, SNB32,snb16Exclude, IStorage32*,pstgDest);
ICOM_METHOD4(HRESULT,MoveElementTo, LPCOLESTR32,pwcsName, IStorage32*,pstgDest, LPCOLESTR32,pwcsNewName, DWORD,grfFlags);
ICOM_METHOD1(HRESULT,Commit, DWORD,grfCommitFlags);
ICOM_METHOD (HRESULT,Revert);
ICOM_METHOD4(HRESULT,EnumElements, DWORD,reserved1, void*,reserved2, DWORD,reserved3, IEnumSTATSTG**,ppenum);
ICOM_METHOD1(HRESULT,DestroyElement, LPCOLESTR32,pwcsName);
ICOM_METHOD2(HRESULT,RenameElement, LPCOLESTR32,pwcsOldName, LPCOLESTR32,pwcsNewName);
ICOM_METHOD4(HRESULT,SetElementTimes,LPCOLESTR32,pwcsName, const FILETIME*,pctime, const FILETIME*,patime, const FILETIME*,pmtime);
ICOM_METHOD1(HRESULT,SetClass, REFCLSID,clsid);
ICOM_METHOD2(HRESULT,SetStateBits, DWORD,grfStateBits, DWORD,grfMask);
ICOM_METHOD2(HRESULT,Stat, STATSTG*,pstatstg, DWORD,grfStatFlag);
ICOM_END(IStorage32)
#undef ICOM_INTERFACE
#if !defined(__cplusplus) || defined(CINTERFACE)
/*** IUnknown methods ***/
#define IStorage32_QueryInterface(p,a,b) ICOM_ICALL2(QueryInterface,p,a,b)
#define IStorage32_AddRef(p) ICOM_ICALL (AddRef,p)
#define IStorage32_Release(p) ICOM_ICALL (Release,p)
/*** IStorage32 methods ***/
#define IStorage32_CreateStream(p,a,b,c,d,e) ICOM_CALL5(CreateStream,p,a,b,c,d,e)
#define IStorage32_OpenStream(p,a,b,c,d,e) ICOM_CALL5(OpenStream,p,a,b,c,d,e)
#define IStorage32_CreateStorage(p,a,b,c,d,e) ICOM_CALL5(CreateStorage,p,a,b,c,d,e)
#define IStorage32_OpenStorage(p,a,b,c,d,e,f) ICOM_CALL6(OpenStorage,p,a,b,c,d,e,f)
#define IStorage32_CopyTo(p,a,b,c,d) ICOM_CALL4(CopyTo,p,a,b,c,d)
#define IStorage32_MoveElementTo(p,a,b,c,d) ICOM_CALL4(MoveElementTo,p,a,b,c,d)
#define IStorage32_Commit(p,a) ICOM_CALL1(Commit,p,a)
#define IStorage32_Revert(p) ICOM_CALL (Revert,p)
#define IStorage32_EnumElements(p,a,b,c,d) ICOM_CALL4(EnumElements,p,a,b,c,d)
#define IStorage32_DestroyElement(p,a) ICOM_CALL1(DestroyElement,p,a)
#define IStorage32_RenameElement(p,a,b) ICOM_CALL2(RenameElement,p,a,b)
#define IStorage32_SetElementTimes(p,a,b,c,d) ICOM_CALL4(SetElementTimes,p,a,b,c,d)
#define IStorage32_SetClass(p,a) ICOM_CALL1(SetClass,p,a)
#define IStorage32_SetStateBits(p,a,b) ICOM_CALL2(SetStateBits,p,a,b)
#define IStorage32_Stat(p,a,b) ICOM_CALL2(Stat,p,a,b)
#endif
/*****************************************************************************
* IStream16 interface
*/
#define ICOM_INTERFACE IStream16
ICOM_BEGIN(IStream16,IUnknown)
ICOM_METHOD3(HRESULT,Read, void*,pv, ULONG,cb, ULONG*,pcbRead);
ICOM_METHOD3(HRESULT,Write, const void*,pv, ULONG,cb, ULONG*,pcbWritten);
ICOM_METHOD3(HRESULT,Seek, LARGE_INTEGER,dlibMove, DWORD,dwOrigin, ULARGE_INTEGER*,plibNewPosition);
ICOM_METHOD1(HRESULT,SetSize, ULARGE_INTEGER,libNewSize);
ICOM_METHOD4(HRESULT,CopyTo, IStream16*,pstm, ULARGE_INTEGER,cb, ULARGE_INTEGER*,pcbRead, ULARGE_INTEGER*,pcbWritten);
ICOM_METHOD1(HRESULT,Commit, DWORD,grfCommitFlags);
ICOM_METHOD (HRESULT,Revert);
ICOM_METHOD3(HRESULT,LockRegion, ULARGE_INTEGER,libOffset, ULARGE_INTEGER,cb, DWORD,dwLockType);
ICOM_METHOD3(HRESULT,UnlockRegion,ULARGE_INTEGER,libOffset, ULARGE_INTEGER,cb, DWORD,dwLockType);
ICOM_METHOD2(HRESULT,Stat, STATSTG*,pstatstg, DWORD,grfStatFlag);
ICOM_METHOD1(HRESULT,Clone, IStream16**,ppstm);
ICOM_END(IStream16)
#undef ICOM_INTERFACE
#if !defined(__cplusplus) || defined(CINTERFACE)
/*** IUnknown methods ***/
#define IStream16_QueryInterface(p,a,b) ICOM_ICALL2(QueryInterface,p,a,b)
#define IStream16_AddRef(p) ICOM_ICALL (AddRef,p)
#define IStream16_Release(p) ICOM_ICALL (Release,p)
/*** IStream16 methods ***/
#define IStream16_Read(p,a,b,c) ICOM_CALL3(Read,p,a,b,c)
#define IStream16_Write(p,a,b,c) ICOM_CALL3(Write,p,a,b,c)
#define IStream16_Seek(p) ICOM_CALL3(Seek,p)
#define IStream16_SetSize(p,a,b) ICOM_CALL1(SetSize,p,a,b)
#define IStream16_CopyTo(pa,b,c,d) ICOM_CALL4(CopyTo,pa,b,c,d)
#define IStream16_Commit(p,a) ICOM_CALL1(Commit,p,a)
#define IStream16_Revert(p) ICOM_CALL (Revert,p)
#define IStream16_LockRegion(pa,b,c) ICOM_CALL3(LockRegion,pa,b,c)
#define IStream16_UnlockRegion(p,a,b,c) ICOM_CALL3(UnlockRegion,p,a,b,c)
#define IStream16_Stat(p,a,b) ICOM_CALL2(Stat,p,a,b)
#define IStream16_Clone(p,a) ICOM_CALL1(Clone,p,a)
#endif
/*****************************************************************************
* IStream32 interface
*/
#define ICOM_INTERFACE IStream32
ICOM_BEGIN(IStream32,IUnknown)
ICOM_METHOD3(HRESULT,Read, void*,pv, ULONG,cb, ULONG*,pcbRead);
ICOM_METHOD3(HRESULT,Write, const void*,pv, ULONG,cb, ULONG*,pcbWritten);
ICOM_METHOD3(HRESULT,Seek, LARGE_INTEGER,dlibMove, DWORD,dwOrigin, ULARGE_INTEGER*,plibNewPosition);
ICOM_METHOD1(HRESULT,SetSize, ULARGE_INTEGER,libNewSize);
ICOM_METHOD4(HRESULT,CopyTo, IStream32*,pstm, ULARGE_INTEGER,cb, ULARGE_INTEGER*,pcbRead, ULARGE_INTEGER*,pcbWritten);
ICOM_METHOD1(HRESULT,Commit, DWORD,grfCommitFlags);
ICOM_METHOD (HRESULT,Revert);
ICOM_METHOD3(HRESULT,LockRegion, ULARGE_INTEGER,libOffset, ULARGE_INTEGER,cb, DWORD,dwLockType);
ICOM_METHOD3(HRESULT,UnlockRegion,ULARGE_INTEGER,libOffset, ULARGE_INTEGER,cb, DWORD,dwLockType);
ICOM_METHOD2(HRESULT,Stat, STATSTG*,pstatstg, DWORD,grfStatFlag);
ICOM_METHOD1(HRESULT,Clone, IStream32**,ppstm);
ICOM_END(IStream32)
#undef ICOM_INTERFACE
#if !defined(__cplusplus) || defined(CINTERFACE)
/*** IUnknown methods ***/
#define IStream32_QueryInterface(p,a,b) ICOM_ICALL2(QueryInterface,p,a,b)
#define IStream32_AddRef(p) ICOM_ICALL (AddRef,p)
#define IStream32_Release(p) ICOM_ICALL (Release,p)
/*** IStream32 methods ***/
#define IStream32_Read(p,a,b,c) ICOM_CALL3(Read,p,a,b,c)
#define IStream32_Write(p,a,b,c) ICOM_CALL3(Write,p,a,b,c)
#define IStream32_Seek(p) ICOM_CALL3(Seek,p)
#define IStream32_SetSize(p,a,b) ICOM_CALL1(SetSize,p,a,b)
#define IStream32_CopyTo(pa,b,c,d) ICOM_CALL4(CopyTo,pa,b,c,d)
#define IStream32_Commit(p,a) ICOM_CALL1(Commit,p,a)
#define IStream32_Revert(p) ICOM_CALL (Revert,p)
#define IStream32_LockRegion(pa,b,c) ICOM_CALL3(LockRegion,pa,b,c)
#define IStream32_UnlockRegion(p,a,b,c) ICOM_CALL3(UnlockRegion,p,a,b,c)
#define IStream32_Stat(p,a,b) ICOM_CALL2(Stat,p,a,b)
#define IStream32_Clone(p,a) ICOM_CALL1(Clone,p,a)
#endif
struct IStorage32 {
LPSTORAGE32_VTABLE lpvtbl;
DWORD ref;
struct storage_pps_entry stde;
int ppsent;
HFILE32 hf;
};
#undef THIS
#define THIS LPSTREAM16 this
typedef struct IStream16_VTable {
STDMETHOD(QueryInterface)(THIS_ REFIID riid, void * *ppvObject);
STDMETHOD_(ULONG,AddRef)(THIS);
STDMETHOD_(ULONG,Release)(THIS);
STDMETHOD(Read)(THIS_ void *pv, ULONG cb, ULONG *pcbRead);
STDMETHOD(Write)(THIS_ const void *pv,ULONG cb,ULONG *pcbWritten);
STDMETHOD(Seek)(THIS_ LARGE_INTEGER dlibMove,DWORD dwOrigin,ULARGE_INTEGER *plibNewPosition);
STDMETHOD(SetSize)(THIS_ ULARGE_INTEGER libNewSize);
STDMETHOD(CopyTo)(THIS_ IStream16 *pstm,ULARGE_INTEGER cb,ULARGE_INTEGER *pcbRead,ULARGE_INTEGER *pcbWritten);
STDMETHOD(Commit)(THIS_ DWORD grfCommitFlags);
STDMETHOD(Revert)(THIS);
STDMETHOD(LockRegion)(THIS_ ULARGE_INTEGER libOffset, ULARGE_INTEGER cb,DWORD dwLockType);
STDMETHOD(UnlockRegion)(THIS_ ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
STDMETHOD(Stat)(THIS_ STATSTG *pstatstg, DWORD grfStatFlag);
STDMETHOD(Clone)(THIS_ IStream16 **ppstm);
} IStream16_VTable,*LPSTREAM16_VTABLE;
struct IStream16 {
LPSTREAM16_VTABLE lpvtbl;
DWORD ref;
SEGPTR thisptr; /* pointer to this struct as segmented */
struct storage_pps_entry stde;
int ppsent;
HFILE32 hf;
ULARGE_INTEGER offset;
};
#undef THIS
#define THIS LPSTREAM32 this
typedef struct IStream32_VTable {
STDMETHOD(QueryInterface)(THIS_ REFIID riid, void * *ppvObject);
STDMETHOD_(ULONG,AddRef)(THIS);
STDMETHOD_(ULONG,Release)(THIS);
STDMETHOD(Read)(THIS_ void *pv, ULONG cb, ULONG *pcbRead);
STDMETHOD(Write)(THIS_ const void *pv,ULONG cb,ULONG *pcbWritten);
STDMETHOD(Seek)(THIS_ LARGE_INTEGER dlibMove,DWORD dwOrigin,ULARGE_INTEGER *plibNewPosition);
STDMETHOD(SetSize)(THIS_ ULARGE_INTEGER libNewSize);
STDMETHOD(CopyTo)(THIS_ IStream32 *pstm,ULARGE_INTEGER cb,ULARGE_INTEGER *pcbRead,ULARGE_INTEGER *pcbWritten);
STDMETHOD(Commit)(THIS_ DWORD grfCommitFlags);
STDMETHOD(Revert)(THIS);
STDMETHOD(LockRegion)(THIS_ ULARGE_INTEGER libOffset, ULARGE_INTEGER cb,DWORD dwLockType);
STDMETHOD(UnlockRegion)(THIS_ ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
STDMETHOD(Stat)(THIS_ STATSTG *pstatstg, DWORD grfStatFlag);
STDMETHOD(Clone)(THIS_ IStream32 **ppstm);
} IStream32_VTable,*LPSTREAM32_VTABLE;
struct IStream32 {
LPSTREAM32_VTABLE lpvtbl;
DWORD ref;
struct storage_pps_entry stde;
int ppsent;
HFILE32 hf;
ULARGE_INTEGER offset;
};
#undef THIS
#undef STDMETHOD
#undef STDMETHOD_
#undef PURE
#undef FAR
#undef THIS_
#endif

View File

@ -20,14 +20,19 @@
#include "module.h"
#include "debug.h"
/*
* IUnknown
*/
/* --- IUnknown implementation */
typedef struct _IUnknown {
/* IUnknown fields */
ICOM_VTABLE(IUnknown)* lpvtbl;
DWORD ref;
} _IUnknown;
/******************************************************************************
* IUnknown_AddRef [VTABLE:IUNKNOWN.1]
*/
static ULONG WINAPI IUnknown_AddRef(LPUNKNOWN this) {
static ULONG WINAPI IUnknown_fnAddRef(LPUNKNOWN iface) {
ICOM_THIS(IUnknown,iface);
TRACE(relay,"(%p)->AddRef()\n",this);
return ++(this->ref);
}
@ -35,7 +40,8 @@ static ULONG WINAPI IUnknown_AddRef(LPUNKNOWN this) {
/******************************************************************************
* IUnknown_Release [VTABLE:IUNKNOWN.2]
*/
static ULONG WINAPI IUnknown_Release(LPUNKNOWN this) {
static ULONG WINAPI IUnknown_fnRelease(LPUNKNOWN iface) {
ICOM_THIS(IUnknown,iface);
TRACE(relay,"(%p)->Release()\n",this);
if (!--(this->ref)) {
HeapFree(GetProcessHeap(),0,this);
@ -47,7 +53,8 @@ static ULONG WINAPI IUnknown_Release(LPUNKNOWN this) {
/******************************************************************************
* IUnknown_QueryInterface [VTABLE:IUNKNOWN.0]
*/
static HRESULT WINAPI IUnknown_QueryInterface(LPUNKNOWN this,REFIID refiid,LPVOID *obj) {
static HRESULT WINAPI IUnknown_fnQueryInterface(LPUNKNOWN iface,REFIID refiid,LPVOID *obj) {
ICOM_THIS(IUnknown,iface);
char xrefiid[50];
WINE_StringFromCLSID((LPCLSID)refiid,xrefiid);
@ -60,10 +67,10 @@ static HRESULT WINAPI IUnknown_QueryInterface(LPUNKNOWN this,REFIID refiid,LPVOI
return OLE_E_ENUM_NOMORE;
}
static IUnknown_VTable uvt = {
IUnknown_QueryInterface,
IUnknown_AddRef,
IUnknown_Release
static ICOM_VTABLE(IUnknown) uvt = {
IUnknown_fnQueryInterface,
IUnknown_fnAddRef,
IUnknown_fnRelease
};
/******************************************************************************
@ -71,12 +78,12 @@ static IUnknown_VTable uvt = {
*/
LPUNKNOWN
IUnknown_Constructor() {
LPUNKNOWN unk;
_IUnknown* unk;
unk = (LPUNKNOWN)HeapAlloc(GetProcessHeap(),0,sizeof(IUnknown));
unk = (_IUnknown*)HeapAlloc(GetProcessHeap(),0,sizeof(IUnknown));
unk->lpvtbl = &uvt;
unk->ref = 1;
return unk;
return (LPUNKNOWN)unk;
}
/*

View File

@ -33,12 +33,12 @@ static const BYTE STORAGE_oldmagic[8]={0xd0,0xcf,0x11,0xe0,0x0e,0x11,0xfc,0x0d};
#define SMALLBLOCKS_PER_BIGBLOCK (BIGSIZE/SMALLSIZE)
#define READ_HEADER assert(STORAGE_get_big_block(hf,-1,(LPBYTE)&sth));assert(!memcmp(STORAGE_magic,sth.magic,sizeof(STORAGE_magic)));
static IStorage16_VTable stvt16;
static IStorage16_VTable *segstvt16 = NULL;
static IStorage32_VTable stvt32;
static IStream16_VTable strvt16;
static IStream16_VTable *segstrvt16 = NULL;
static IStream32_VTable strvt32;
static ICOM_VTABLE(IStorage16) stvt16;
static ICOM_VTABLE(IStorage16) *segstvt16 = NULL;
static ICOM_VTABLE(IStorage32) stvt32;
static ICOM_VTABLE(IStream16) strvt16;
static ICOM_VTABLE(IStream16) *segstrvt16 = NULL;
static ICOM_VTABLE(IStream32) strvt32;
/*ULONG WINAPI IStorage16_AddRef(LPSTORAGE16 this);*/
static void _create_istorage16(LPSTORAGE16 *stg);
@ -46,6 +46,7 @@ static void _create_istream16(LPSTREAM16 *str);
#define IMPLEMENTED 1
/******************************************************************************
* STORAGE_get_big_block [Internal]
*
@ -420,7 +421,7 @@ STORAGE_set_big_chain(HFILE32 hf,int blocknr,INT32 type) {
}
/******************************************************************************
* STORAGE_set_small_chain [INTERNAL]
* STORAGE_set_small_chain [Internal]
*/
static BOOL32
STORAGE_set_small_chain(HFILE32 hf,int blocknr,INT32 type) {
@ -632,14 +633,28 @@ STORAGE_get_free_pps_entry(HFILE32 hf) {
return curblock*4;
}
/* --- IStream16 implementation */
typedef struct _IStream16 {
/* IUnknown fields */
ICOM_VTABLE(IStream16)* lpvtbl;
DWORD ref;
/* IStream16 fields */
SEGPTR thisptr; /* pointer to this struct as segmented */
struct storage_pps_entry stde;
int ppsent;
HFILE32 hf;
ULARGE_INTEGER offset;
} _IStream16;
/******************************************************************************
* IStream16_QueryInterface [STORAGE.518]
*/
HRESULT WINAPI IStream16_QueryInterface(
LPSTREAM16 this,REFIID refiid,LPVOID *obj
HRESULT WINAPI IStream16_fnQueryInterface(
LPUNKNOWN iface,REFIID refiid,LPVOID *obj
) {
ICOM_THIS(IStream16,iface);
char xrefiid[50];
WINE_StringFromCLSID((LPCLSID)refiid,xrefiid);
TRACE(relay,"(%p)->(%s,%p)\n",this,xrefiid,obj);
if (!memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown))) {
@ -653,14 +668,16 @@ HRESULT WINAPI IStream16_QueryInterface(
/******************************************************************************
* IStream16_AddRef [STORAGE.519]
*/
ULONG WINAPI IStream16_AddRef(LPSTREAM16 this) {
ULONG WINAPI IStream16_fnAddRef(LPUNKNOWN iface) {
ICOM_THIS(IStream16,iface);
return ++(this->ref);
}
/******************************************************************************
* IStream16_Release [STORAGE.520]
*/
ULONG WINAPI IStream16_Release(LPSTREAM16 this) {
ULONG WINAPI IStream16_fnRelease(LPUNKNOWN iface) {
ICOM_THIS(IStream16,iface);
FlushFileBuffers(this->hf);
this->ref--;
if (!this->ref) {
@ -677,9 +694,10 @@ ULONG WINAPI IStream16_Release(LPSTREAM16 this) {
* FIXME
* Does not handle 64 bits
*/
HRESULT WINAPI IStream16_Seek(
LPSTREAM16 this,LARGE_INTEGER offset,DWORD whence,ULARGE_INTEGER *newpos
HRESULT WINAPI IStream16_fnSeek(
LPSTREAM16 iface,LARGE_INTEGER offset,DWORD whence,ULARGE_INTEGER *newpos
) {
ICOM_THIS(IStream16,iface);
TRACE(relay,"(%p)->([%ld.%ld],%ld,%p)\n",this,offset.HighPart,offset.LowPart,whence,newpos);
switch (whence) {
@ -720,9 +738,10 @@ HRESULT WINAPI IStream16_Seek(
/******************************************************************************
* IStream16_Read [STORAGE.521]
*/
HRESULT WINAPI IStream16_Read(
LPSTREAM16 this,void *pv,ULONG cb,ULONG *pcbRead
HRESULT WINAPI IStream16_fnRead(
LPSTREAM16 iface,void *pv,ULONG cb,ULONG *pcbRead
) {
ICOM_THIS(IStream16,iface);
BYTE block[BIGSIZE];
ULONG *bytesread=pcbRead,xxread;
int blocknr;
@ -780,9 +799,10 @@ HRESULT WINAPI IStream16_Read(
/******************************************************************************
* IStream16_Write [STORAGE.522]
*/
HRESULT WINAPI IStream16_Write(
LPSTREAM16 this,const void *pv,ULONG cb,ULONG *pcbWrite
HRESULT WINAPI IStream16_fnWrite(
LPSTREAM16 iface,const void *pv,ULONG cb,ULONG *pcbWrite
) {
ICOM_THIS(IStream16,iface);
BYTE block[BIGSIZE];
ULONG *byteswritten=pcbWrite,xxwritten;
int oldsize,newsize,i,curoffset=0,lastblocknr,blocknr,cc;
@ -1042,15 +1062,18 @@ HRESULT WINAPI IStream16_Write(
* _create_istream16 [Internal]
*/
static void _create_istream16(LPSTREAM16 *str) {
LPSTREAM16 lpst;
_IStream16* lpst;
if (!strvt16.fnQueryInterface) {
if (!strvt16.bvt.fnQueryInterface) {
HMODULE16 wp = GetModuleHandle16("STORAGE");
if (wp>=32) {
#define VTENT(x) strvt16.fn##x = (void*)WIN32_GetProcAddress16(wp,"IStream16_"#x);
/* FIXME: what is this WIN32_GetProcAddress16. Should the name be IStream16_QueryInterface of IStream16_fnQueryInterface */
#define VTENT(xfn) strvt16.bvt.fn##xfn = (void*)WIN32_GetProcAddress16(wp,"IStream16_"#xfn);
VTENT(QueryInterface)
VTENT(AddRef)
VTENT(Release)
#undef VTENT
#define VTENT(xfn) strvt16.fn##xfn = (void*)WIN32_GetProcAddress16(wp,"IStream16_"#xfn);
VTENT(Read)
VTENT(Write)
VTENT(Seek)
@ -1063,14 +1086,16 @@ static void _create_istream16(LPSTREAM16 *str) {
VTENT(Stat)
VTENT(Clone)
#undef VTENT
segstrvt16 = SEGPTR_NEW(IStream16_VTable);
segstrvt16 = SEGPTR_NEW(ICOM_VTABLE(IStream16));
memcpy(segstrvt16,&strvt16,sizeof(strvt16));
segstrvt16 = (LPSTREAM16_VTABLE)SEGPTR_GET(segstrvt16);
segstrvt16 = (ICOM_VTABLE(IStream16)*)SEGPTR_GET(segstrvt16);
} else {
#define VTENT(x) strvt16.fn##x = IStream16_##x;
#define VTENT(xfn) strvt16.bvt.fn##xfn = IStream16_fn##xfn;
VTENT(QueryInterface)
VTENT(AddRef)
VTENT(Release)
#undef VTENT
#define VTENT(xfn) strvt16.fn##xfn = IStream16_fn##xfn;
VTENT(Read)
VTENT(Write)
VTENT(Seek)
@ -1088,19 +1113,34 @@ static void _create_istream16(LPSTREAM16 *str) {
segstrvt16 = &strvt16;
}
}
lpst = SEGPTR_NEW(IStream16);
lpst = SEGPTR_NEW(_IStream16);
lpst->lpvtbl = segstrvt16;
lpst->ref = 1;
lpst->thisptr = SEGPTR_GET(lpst);
*str = (void*)lpst->thisptr;
}
/* --- IStream32 implementation */
typedef struct _IStream32 {
/* IUnknown fields */
ICOM_VTABLE(IStream32)* lpvtbl;
DWORD ref;
/* IStream32 fields */
struct storage_pps_entry stde;
int ppsent;
HFILE32 hf;
ULARGE_INTEGER offset;
} _IStream32;
/*****************************************************************************
* IStream32_QueryInterface [VTABLE]
*/
HRESULT WINAPI IStream32_QueryInterface(
LPSTREAM32 this,REFIID refiid,LPVOID *obj
HRESULT WINAPI IStream32_fnQueryInterface(
LPUNKNOWN iface,REFIID refiid,LPVOID *obj
) {
ICOM_THIS(IStream32,iface);
char xrefiid[50];
WINE_StringFromCLSID((LPCLSID)refiid,xrefiid);
@ -1116,14 +1156,16 @@ HRESULT WINAPI IStream32_QueryInterface(
/******************************************************************************
* IStream32_AddRef [VTABLE]
*/
ULONG WINAPI IStream32_AddRef(LPSTREAM32 this) {
ULONG WINAPI IStream32_fnAddRef(LPUNKNOWN iface) {
ICOM_THIS(IStream32,iface);
return ++(this->ref);
}
/******************************************************************************
* IStream32_Release [VTABLE]
*/
ULONG WINAPI IStream32_Release(LPSTREAM32 this) {
ULONG WINAPI IStream32_fnRelease(LPUNKNOWN iface) {
ICOM_THIS(IStream32,iface);
FlushFileBuffers(this->hf);
this->ref--;
if (!this->ref) {
@ -1134,10 +1176,12 @@ ULONG WINAPI IStream32_Release(LPSTREAM32 this) {
return this->ref;
}
static IStream32_VTable strvt32 = {
IStream32_QueryInterface,
IStream32_AddRef,
IStream32_Release,
static ICOM_VTABLE(IStream32) strvt32 = {
{
IStream32_fnQueryInterface,
IStream32_fnAddRef,
IStream32_fnRelease
},
(void*)4,
(void*)5,
(void*)6,
@ -1149,12 +1193,26 @@ static IStream32_VTable strvt32 = {
};
/* --- IStorage16 implementation */
typedef struct _IStorage16 {
/* IUnknown fields */
ICOM_VTABLE(IStorage16)* lpvtbl;
DWORD ref;
/* IStorage16 fields */
SEGPTR thisptr; /* pointer to this struct as segmented */
struct storage_pps_entry stde;
int ppsent;
HFILE32 hf;
} _IStorage16;
/******************************************************************************
* IStorage16_QueryInterface [STORAGE.500]
*/
HRESULT WINAPI IStorage16_QueryInterface(
LPSTORAGE16 this,REFIID refiid,LPVOID *obj
HRESULT WINAPI IStorage16_fnQueryInterface(
LPUNKNOWN iface,REFIID refiid,LPVOID *obj
) {
ICOM_THIS(IStorage16,iface);
char xrefiid[50];
WINE_StringFromCLSID((LPCLSID)refiid,xrefiid);
@ -1170,14 +1228,16 @@ HRESULT WINAPI IStorage16_QueryInterface(
/******************************************************************************
* IStorage16_AddRef [STORAGE.501]
*/
ULONG WINAPI IStorage16_AddRef(LPSTORAGE16 this) {
ULONG WINAPI IStorage16_fnAddRef(LPUNKNOWN iface) {
ICOM_THIS(IStorage16,iface);
return ++(this->ref);
}
/******************************************************************************
* IStorage16_Release [STORAGE.502]
*/
ULONG WINAPI IStorage16_Release(LPSTORAGE16 this) {
ULONG WINAPI IStorage16_fnRelease(LPUNKNOWN iface) {
ICOM_THIS(IStorage16,iface);
this->ref--;
if (this->ref)
return this->ref;
@ -1188,9 +1248,10 @@ ULONG WINAPI IStorage16_Release(LPSTORAGE16 this) {
/******************************************************************************
* IStorage16_Stat [STORAGE.517]
*/
HRESULT WINAPI IStorage16_Stat(
LPSTORAGE16 this,STATSTG *pstatstg, DWORD grfStatFlag
HRESULT WINAPI IStorage16_fnStat(
LPSTORAGE16 iface,STATSTG *pstatstg, DWORD grfStatFlag
) {
ICOM_THIS(IStorage16,iface);
TRACE(ole,"(%p)->(%p,0x%08lx)\n",
this,pstatstg,grfStatFlag
);
@ -1211,9 +1272,10 @@ HRESULT WINAPI IStorage16_Stat(
/******************************************************************************
* IStorage16_Commit [STORAGE.509]
*/
HRESULT WINAPI IStorage16_Commit(
LPSTORAGE16 this,DWORD commitflags
HRESULT WINAPI IStorage16_fnCommit(
LPSTORAGE16 iface,DWORD commitflags
) {
ICOM_THIS(IStorage16,iface);
FIXME(ole,"(%p)->(0x%08lx),STUB!\n",
this,commitflags
);
@ -1223,7 +1285,8 @@ HRESULT WINAPI IStorage16_Commit(
/******************************************************************************
* IStorage16_CopyTo [STORAGE.507]
*/
HRESULT WINAPI IStorage16_CopyTo(LPSTORAGE16 this,DWORD ciidExclude,const IID *rgiidExclude,SNB16 SNB16Exclude,IStorage16 *pstgDest) {
HRESULT WINAPI IStorage16_fnCopyTo(LPSTORAGE16 iface,DWORD ciidExclude,const IID *rgiidExclude,SNB16 SNB16Exclude,IStorage16 *pstgDest) {
ICOM_THIS(IStorage16,iface);
char xguid[50];
if (rgiidExclude)
@ -1240,10 +1303,11 @@ HRESULT WINAPI IStorage16_CopyTo(LPSTORAGE16 this,DWORD ciidExclude,const IID *r
/******************************************************************************
* IStorage16_CreateStorage [STORAGE.505]
*/
HRESULT WINAPI IStorage16_CreateStorage(
LPSTORAGE16 this,LPCOLESTR16 pwcsName,DWORD grfMode,DWORD dwStgFormat,DWORD reserved2, IStorage16 **ppstg
HRESULT WINAPI IStorage16_fnCreateStorage(
LPSTORAGE16 iface,LPCOLESTR16 pwcsName,DWORD grfMode,DWORD dwStgFormat,DWORD reserved2, IStorage16 **ppstg
) {
LPSTORAGE16 lpstg;
ICOM_THIS(IStorage16,iface);
_IStorage16* lpstg;
int ppsent,x;
struct storage_pps_entry stde;
struct storage_header sth;
@ -1257,7 +1321,7 @@ HRESULT WINAPI IStorage16_CreateStorage(
if (grfMode & STGM_TRANSACTED)
FIXME(ole,"We do not support transacted Compound Storage. Using direct mode.\n");
_create_istorage16(ppstg);
lpstg = (LPSTORAGE16)PTR_SEG_TO_LIN(*ppstg);
lpstg = (_IStorage16*)PTR_SEG_TO_LIN(*ppstg);
lpstg->hf = this->hf;
ppsent=STORAGE_get_free_pps_entry(lpstg->hf);
@ -1299,10 +1363,11 @@ HRESULT WINAPI IStorage16_CreateStorage(
/******************************************************************************
* IStorage16_CreateStream [STORAGE.503]
*/
HRESULT WINAPI IStorage16_CreateStream(
LPSTORAGE16 this,LPCOLESTR16 pwcsName,DWORD grfMode,DWORD reserved1,DWORD reserved2, IStream16 **ppstm
HRESULT WINAPI IStorage16_fnCreateStream(
LPSTORAGE16 iface,LPCOLESTR16 pwcsName,DWORD grfMode,DWORD reserved1,DWORD reserved2, IStream16 **ppstm
) {
LPSTREAM16 lpstr;
ICOM_THIS(IStorage16,iface);
_IStream16* lpstr;
int ppsent,x;
struct storage_pps_entry stde;
@ -1312,7 +1377,7 @@ HRESULT WINAPI IStorage16_CreateStream(
if (grfMode & STGM_TRANSACTED)
FIXME(ole,"We do not support transacted Compound Storage. Using direct mode.\n");
_create_istream16(ppstm);
lpstr = (LPSTREAM16)PTR_SEG_TO_LIN(*ppstm);
lpstr = (_IStream16*)PTR_SEG_TO_LIN(*ppstm);
lpstr->hf = FILE_Dup(this->hf);
lpstr->offset.LowPart = 0;
lpstr->offset.HighPart = 0;
@ -1350,10 +1415,11 @@ HRESULT WINAPI IStorage16_CreateStream(
/******************************************************************************
* IStorage16_OpenStorage [STORAGE.506]
*/
HRESULT WINAPI IStorage16_OpenStorage(
LPSTORAGE16 this,LPCOLESTR16 pwcsName, IStorage16 *pstgPrio, DWORD grfMode, SNB16 snbExclude, DWORD reserved, IStorage16 **ppstg
HRESULT WINAPI IStorage16_fnOpenStorage(
LPSTORAGE16 iface,LPCOLESTR16 pwcsName, IStorage16 *pstgPrio, DWORD grfMode, SNB16 snbExclude, DWORD reserved, IStorage16 **ppstg
) {
LPSTREAM16 lpstg;
ICOM_THIS(IStorage16,iface);
_IStream16* lpstg;
WCHAR name[33];
int newpps;
@ -1363,17 +1429,17 @@ HRESULT WINAPI IStorage16_OpenStorage(
if (grfMode & STGM_TRANSACTED)
FIXME(ole,"We do not support transacted Compound Storage. Using direct mode.\n");
_create_istorage16(ppstg);
lpstg = (LPSTREAM16)PTR_SEG_TO_LIN(*ppstg);
lpstg = (_IStream16*)PTR_SEG_TO_LIN(*ppstg);
lpstg->hf = FILE_Dup(this->hf);
lstrcpyAtoW(name,pwcsName);
newpps = STORAGE_look_for_named_pps(lpstg->hf,this->stde.pps_dir,name);
if (newpps==-1) {
IStream16_Release(lpstg);
IStream16_fnRelease((IUnknown*)lpstg);
return E_FAIL;
}
if (1!=STORAGE_get_pps_entry(lpstg->hf,newpps,&(lpstg->stde))) {
IStream16_Release(lpstg);
IStream16_fnRelease((IUnknown*)lpstg);
return E_FAIL;
}
lpstg->ppsent = newpps;
@ -1383,10 +1449,11 @@ HRESULT WINAPI IStorage16_OpenStorage(
/******************************************************************************
* IStorage16_OpenStream [STORAGE.504]
*/
HRESULT WINAPI IStorage16_OpenStream(
LPSTORAGE16 this,LPCOLESTR16 pwcsName, void *reserved1, DWORD grfMode, DWORD reserved2, IStream16 **ppstm
HRESULT WINAPI IStorage16_fnOpenStream(
LPSTORAGE16 iface,LPCOLESTR16 pwcsName, void *reserved1, DWORD grfMode, DWORD reserved2, IStream16 **ppstm
) {
LPSTREAM16 lpstr;
ICOM_THIS(IStorage16,iface);
_IStream16* lpstr;
WCHAR name[33];
int newpps;
@ -1396,17 +1463,17 @@ HRESULT WINAPI IStorage16_OpenStream(
if (grfMode & STGM_TRANSACTED)
FIXME(ole,"We do not support transacted Compound Storage. Using direct mode.\n");
_create_istream16(ppstm);
lpstr = (LPSTREAM16)PTR_SEG_TO_LIN(*ppstm);
lpstr = (_IStream16*)PTR_SEG_TO_LIN(*ppstm);
lpstr->hf = FILE_Dup(this->hf);
lstrcpyAtoW(name,pwcsName);
newpps = STORAGE_look_for_named_pps(lpstr->hf,this->stde.pps_dir,name);
if (newpps==-1) {
IStream16_Release(lpstr);
IStream16_fnRelease((IUnknown*)lpstr);
return E_FAIL;
}
if (1!=STORAGE_get_pps_entry(lpstr->hf,newpps,&(lpstr->stde))) {
IStream16_Release(lpstr);
IStream16_fnRelease((IUnknown*)lpstr);
return E_FAIL;
}
lpstr->offset.LowPart = 0;
@ -1419,15 +1486,17 @@ HRESULT WINAPI IStorage16_OpenStream(
* _create_istorage16 [INTERNAL]
*/
static void _create_istorage16(LPSTORAGE16 *stg) {
LPSTORAGE16 lpst;
_IStorage16* lpst;
if (!stvt16.fnQueryInterface) {
if (!stvt16.bvt.fnQueryInterface) {
HMODULE16 wp = GetModuleHandle16("STORAGE");
if (wp>=32) {
#define VTENT(x) stvt16.fn##x = (void*)WIN32_GetProcAddress16(wp,"IStorage16_"#x);
#define VTENT(xfn) stvt16.bvt.fn##xfn = (void*)WIN32_GetProcAddress16(wp,"IStorage16_"#xfn);
VTENT(QueryInterface)
VTENT(AddRef)
VTENT(Release)
#undef VTENT
#define VTENT(xfn) stvt16.fn##xfn = (void*)WIN32_GetProcAddress16(wp,"IStorage16_"#xfn);
VTENT(CreateStream)
VTENT(OpenStream)
VTENT(CreateStorage)
@ -1444,14 +1513,16 @@ static void _create_istorage16(LPSTORAGE16 *stg) {
VTENT(SetStateBits)
VTENT(Stat)
#undef VTENT
segstvt16 = SEGPTR_NEW(IStorage16_VTable);
segstvt16 = SEGPTR_NEW(ICOM_VTABLE(IStorage16));
memcpy(segstvt16,&stvt16,sizeof(stvt16));
segstvt16 = (LPSTORAGE16_VTABLE)SEGPTR_GET(segstvt16);
segstvt16 = (ICOM_VTABLE(IStorage16)*)SEGPTR_GET(segstvt16);
} else {
#define VTENT(x) stvt16.fn##x = IStorage16_##x;
#define VTENT(xfn) stvt16.bvt.fn##xfn = IStorage16_fn##xfn;
VTENT(QueryInterface)
VTENT(AddRef)
VTENT(Release)
#undef VTENT
#define VTENT(xfn) stvt16.fn##xfn = IStorage16_fn##xfn;
VTENT(CreateStream)
VTENT(OpenStream)
VTENT(CreateStorage)
@ -1473,19 +1544,33 @@ static void _create_istorage16(LPSTORAGE16 *stg) {
segstvt16 = &stvt16;
}
}
lpst = SEGPTR_NEW(IStorage16);
lpst = SEGPTR_NEW(_IStorage16);
lpst->lpvtbl = segstvt16;
lpst->ref = 1;
lpst->thisptr = SEGPTR_GET(lpst);
*stg = (void*)lpst->thisptr;
}
/* --- IStorage32 implementation */
typedef struct _IStorage32 {
/* IUnknown fields */
ICOM_VTABLE(IStorage32)* lpvtbl;
DWORD ref;
/* IStorage32 fields */
struct storage_pps_entry stde;
int ppsent;
HFILE32 hf;
} _IStorage32;
/******************************************************************************
* IStorage32_QueryInterface [VTABLE]
*/
HRESULT WINAPI IStorage32_QueryInterface(
LPSTORAGE32 this,REFIID refiid,LPVOID *obj
HRESULT WINAPI IStorage32_fnQueryInterface(
LPUNKNOWN iface,REFIID refiid,LPVOID *obj
) {
ICOM_THIS(IStorage32,iface);
char xrefiid[50];
WINE_StringFromCLSID((LPCLSID)refiid,xrefiid);
@ -1501,14 +1586,16 @@ HRESULT WINAPI IStorage32_QueryInterface(
/******************************************************************************
* IStorage32_AddRef [VTABLE]
*/
ULONG WINAPI IStorage32_AddRef(LPSTORAGE32 this) {
ULONG WINAPI IStorage32_fnAddRef(LPUNKNOWN iface) {
ICOM_THIS(IStorage32,iface);
return ++(this->ref);
}
/******************************************************************************
* IStorage32_Release [VTABLE]
*/
ULONG WINAPI IStorage32_Release(LPSTORAGE32 this) {
ULONG WINAPI IStorage32_fnRelease(LPUNKNOWN iface) {
ICOM_THIS(IStorage32,iface);
this->ref--;
if (this->ref)
return this->ref;
@ -1519,15 +1606,16 @@ ULONG WINAPI IStorage32_Release(LPSTORAGE32 this) {
/******************************************************************************
* IStorage32_CreateStream [VTABLE]
*/
HRESULT WINAPI IStorage32_CreateStream(
LPSTORAGE32 this,LPCOLESTR32 pwcsName,DWORD grfMode,DWORD reserved1,DWORD reserved2, IStream32 **ppstm
HRESULT WINAPI IStorage32_fnCreateStream(
LPSTORAGE32 iface,LPCOLESTR32 pwcsName,DWORD grfMode,DWORD reserved1,DWORD reserved2, IStream32 **ppstm
) {
ICOM_THIS(IStorage32,iface);
TRACE(ole,"(%p)->(%p,0x%08lx,0x%08lx,0x%08lx,%p)\n",
this,pwcsName,grfMode,reserved1,reserved2,ppstm
);
*ppstm = (IStream32*)HeapAlloc(GetProcessHeap(),0,sizeof(IStream32));
(*ppstm)->lpvtbl= &strvt32;
(*ppstm)->ref = 1;
((_IStream32*)(*ppstm))->lpvtbl= &strvt32;
((_IStream32*)(*ppstm))->ref = 1;
return OLE_OK;
}
@ -1535,24 +1623,27 @@ HRESULT WINAPI IStorage32_CreateStream(
/******************************************************************************
* IStorage32_OpenStream [VTABLE]
*/
HRESULT WINAPI IStorage32_OpenStream(
LPSTORAGE32 this,LPCOLESTR32 pwcsName, void *reserved1, DWORD grfMode, DWORD reserved2, IStream32 **ppstm
HRESULT WINAPI IStorage32_fnOpenStream(
LPSTORAGE32 iface,LPCOLESTR32 pwcsName, void *reserved1, DWORD grfMode, DWORD reserved2, IStream32 **ppstm
) {
ICOM_THIS(IStorage32,iface);
TRACE(ole,"(%p)->(%p,%p,0x%08lx,0x%08lx,%p)\n",
this,pwcsName,reserved1,grfMode,reserved2,ppstm
);
*ppstm = (IStream32*)HeapAlloc(GetProcessHeap(),0,sizeof(IStream32));
(*ppstm)->lpvtbl= &strvt32;
(*ppstm)->ref = 1;
((_IStream32*)(*ppstm))->lpvtbl= &strvt32;
((_IStream32*)(*ppstm))->ref = 1;
return OLE_OK;
}
static IStorage32_VTable stvt32 = {
IStorage32_QueryInterface,
IStorage32_AddRef,
IStorage32_Release,
IStorage32_CreateStream,
IStorage32_OpenStream,
static ICOM_VTABLE(IStorage32) stvt32 = {
{
IStorage32_fnQueryInterface,
IStorage32_fnAddRef,
IStorage32_fnRelease
},
IStorage32_fnCreateStream,
IStorage32_fnOpenStream,
(void*)6,
(void*)7,
(void*)8,
@ -1577,7 +1668,7 @@ OLESTATUS WINAPI StgCreateDocFile16(
) {
HFILE32 hf;
int i,ret;
LPSTORAGE16 lpstg;
_IStorage16* lpstg;
struct storage_pps_entry stde;
TRACE(ole,"(%s,0x%08lx,0x%08lx,%p)\n",
@ -1589,7 +1680,7 @@ OLESTATUS WINAPI StgCreateDocFile16(
WARN(ole,"couldn't open file for storage:%ld\n",GetLastError());
return E_FAIL;
}
lpstg = (LPSTORAGE16)PTR_SEG_TO_LIN(*ppstgOpen);
lpstg = (_IStorage16*)PTR_SEG_TO_LIN(*ppstgOpen);
lpstg->hf = hf;
/* FIXME: check for existance before overwriting? */
if (!STORAGE_init_storage(hf)) {
@ -1607,7 +1698,7 @@ OLESTATUS WINAPI StgCreateDocFile16(
i++;
}
if (ret!=1) {
IStorage16_Release(lpstg); /* will remove it */
IStorage16_fnRelease((IUnknown*)lpstg); /* will remove it */
return E_FAIL;
}
return OLE_OK;
@ -1623,8 +1714,8 @@ OLESTATUS WINAPI StgCreateDocFile32(
pwcsName,grfMode,reserved,ppstgOpen
);
*ppstgOpen = (IStorage32*)HeapAlloc(GetProcessHeap(),0,sizeof(IStorage32));
(*ppstgOpen)->ref = 1;
(*ppstgOpen)->lpvtbl = &stvt32;
((_IStorage32*)(*ppstgOpen))->ref = 1;
((_IStorage32*)(*ppstgOpen))->lpvtbl = &stvt32;
return OLE_OK;
}
@ -1688,7 +1779,7 @@ OLESTATUS WINAPI StgOpenStorage16(
) {
HFILE32 hf;
int ret,i;
LPSTORAGE16 lpstg;
_IStorage16* lpstg;
struct storage_pps_entry stde;
TRACE(ole,"(%s,%p,0x%08lx,%p,%ld,%p)\n",
@ -1700,7 +1791,7 @@ OLESTATUS WINAPI StgOpenStorage16(
WARN(ole,"Couldn't open file for storage\n");
return E_FAIL;
}
lpstg = (LPSTORAGE16)PTR_SEG_TO_LIN(*ppstgOpen);
lpstg = (_IStorage16*)PTR_SEG_TO_LIN(*ppstgOpen);
lpstg->hf = hf;
i=0;ret=0;
@ -1713,7 +1804,7 @@ OLESTATUS WINAPI StgOpenStorage16(
i++;
}
if (ret!=1) {
IStorage16_Release(lpstg); /* will remove it */
IStorage16_fnRelease((IUnknown*)lpstg); /* will remove it */
return E_FAIL;
}
return OLE_OK;
@ -1731,8 +1822,8 @@ OLESTATUS WINAPI StgOpenStorage32(
pwcsName,pstgPriority,grfMode,snbExclude,reserved,
ppstgOpen);
*ppstgOpen = (IStorage32*)HeapAlloc(GetProcessHeap(),0,sizeof(IStorage32));
(*ppstgOpen)->ref = 1;
(*ppstgOpen)->lpvtbl = &stvt32;
((_IStorage32*)(*ppstgOpen))->ref = 1;
((_IStorage32*)(*ppstgOpen))->lpvtbl = &stvt32;
return OLE_OK;
}