ReactOS 0.4.16-dev-2332-g4cba65d
git.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "objbase.h"
#include "ole2.h"
#include "winerror.h"
#include "compobj_private.h"
#include "wine/list.h"
#include "wine/debug.h"
Include dependency graph for git.c:

Go to the source code of this file.

Classes

struct  StdGITEntry
 
struct  StdGlobalInterfaceTableImpl
 

Macros

#define COBJMACROS
 

Typedefs

typedef struct StdGITEntry StdGITEntry
 
typedef struct StdGlobalInterfaceTableImpl StdGlobalInterfaceTableImpl
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ole)
 
static StdGlobalInterfaceTableImplimpl_from_IGlobalInterfaceTable (IGlobalInterfaceTable *iface)
 
static StdGITEntryStdGlobalInterfaceTable_FindEntry (StdGlobalInterfaceTableImpl *This, DWORD cookie)
 
static HRESULT WINAPI StdGlobalInterfaceTable_QueryInterface (IGlobalInterfaceTable *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI StdGlobalInterfaceTable_AddRef (IGlobalInterfaceTable *iface)
 
static ULONG WINAPI StdGlobalInterfaceTable_Release (IGlobalInterfaceTable *iface)
 
static HRESULT WINAPI StdGlobalInterfaceTable_RegisterInterfaceInGlobal (IGlobalInterfaceTable *iface, IUnknown *pUnk, REFIID riid, DWORD *pdwCookie)
 
static HRESULT WINAPI StdGlobalInterfaceTable_RevokeInterfaceFromGlobal (IGlobalInterfaceTable *iface, DWORD dwCookie)
 
static HRESULT WINAPI StdGlobalInterfaceTable_GetInterfaceFromGlobal (IGlobalInterfaceTable *iface, DWORD dwCookie, REFIID riid, void **ppv)
 
HRESULT WINAPI GlobalInterfaceTable_CreateInstance (IClassFactory *iface, IUnknown *outer, REFIID riid, void **obj)
 
void release_std_git (void)
 

Variables

static IGlobalInterfaceTablestd_git
 
static CRITICAL_SECTION git_section = { &critsect_debug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG critsect_debug
 
static const IGlobalInterfaceTableVtbl StdGlobalInterfaceTableImpl_Vtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 29 of file git.c.

Typedef Documentation

◆ StdGITEntry

◆ StdGlobalInterfaceTableImpl

Function Documentation

◆ GlobalInterfaceTable_CreateInstance()

HRESULT WINAPI GlobalInterfaceTable_CreateInstance ( IClassFactory iface,
IUnknown outer,
REFIID  riid,
void **  obj 
)

Definition at line 303 of file git.c.

304{
306
307 if (!std_git)
308 {
309 git = malloc(sizeof(*git));
310 if (!git) return E_OUTOFMEMORY;
311
313 list_init(&git->list);
314 git->nextCookie = 0xf100; /* that's where windows starts, so that's where we start */
315
317 {
318 free(git);
319 }
320 else
321 TRACE("Created the GIT %p\n", git);
322 }
323
324 return IGlobalInterfaceTable_QueryInterface(std_git, riid, obj);
325}
static void list_init(struct list_entry *head)
Definition: list.h:51
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
static IGlobalInterfaceTable * std_git
Definition: git.c:72
static const IGlobalInterfaceTableVtbl StdGlobalInterfaceTableImpl_Vtbl
Definition: git.c:293
REFIID riid
Definition: atlbase.h:39
#define InterlockedCompareExchangePointer
Definition: interlocked.h:144
#define TRACE(s)
Definition: solgame.cpp:4
struct list list
Definition: git.c:67
IGlobalInterfaceTable IGlobalInterfaceTable_iface
Definition: git.c:65

◆ impl_from_IGlobalInterfaceTable()

static StdGlobalInterfaceTableImpl * impl_from_IGlobalInterfaceTable ( IGlobalInterfaceTable iface)
inlinestatic

Definition at line 84 of file git.c.

85{
86 return CONTAINING_RECORD(iface, StdGlobalInterfaceTableImpl, IGlobalInterfaceTable_iface);
87}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by release_std_git(), StdGlobalInterfaceTable_GetInterfaceFromGlobal(), StdGlobalInterfaceTable_RegisterInterfaceInGlobal(), and StdGlobalInterfaceTable_RevokeInterfaceFromGlobal().

◆ release_std_git()

void release_std_git ( void  )

Definition at line 327 of file git.c.

328{
330 StdGITEntry *entry, *entry2;
331
332 if (!std_git) return;
333
336 {
337 list_remove(&entry->entry);
338
340 IStream_Release(entry->stream);
341 free(entry);
342 }
343
344 free(git);
345}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
HRESULT WINAPI CoReleaseMarshalData(IStream *stream)
Definition: marshal.c:673
static StdGlobalInterfaceTableImpl * impl_from_IGlobalInterfaceTable(IGlobalInterfaceTable *iface)
Definition: git.c:84
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204

Referenced by DllMain().

◆ StdGlobalInterfaceTable_AddRef()

static ULONG WINAPI StdGlobalInterfaceTable_AddRef ( IGlobalInterfaceTable iface)
static

Definition at line 140 of file git.c.

141{
142 return 1;
143}

◆ StdGlobalInterfaceTable_FindEntry()

static StdGITEntry * StdGlobalInterfaceTable_FindEntry ( StdGlobalInterfaceTableImpl This,
DWORD  cookie 
)
static

Definition at line 93 of file git.c.

95{
97
98 TRACE("%p, %#lx.\n", This, cookie);
99
101 if (e->cookie == cookie)
102 return e;
103 }
104
105 TRACE("Entry not found\n");
106 return NULL;
107}
#define e
Definition: ke_i.h:82
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
Definition: cookie.c:34

Referenced by StdGlobalInterfaceTable_GetInterfaceFromGlobal(), and StdGlobalInterfaceTable_RevokeInterfaceFromGlobal().

◆ StdGlobalInterfaceTable_GetInterfaceFromGlobal()

static HRESULT WINAPI StdGlobalInterfaceTable_GetInterfaceFromGlobal ( IGlobalInterfaceTable iface,
DWORD  dwCookie,
REFIID  riid,
void **  ppv 
)
static

Definition at line 249 of file git.c.

252{
257
258 TRACE("%#lx, %s, %p.\n", dwCookie, debugstr_guid(riid), ppv);
259
261
263 if (entry == NULL) {
264 WARN("Entry for cookie %#lx not found\n", dwCookie);
266 return E_INVALIDARG;
267 }
268
269 TRACE("entry=%p\n", entry);
270
271 hres = IStream_Clone(entry->stream, &stream);
272
274
275 if (hres != S_OK) {
276 WARN("Failed to clone stream with error %#lx.\n", hres);
277 return hres;
278 }
279
280 /* unmarshal the interface */
282 IStream_Release(stream);
283
284 if (hres != S_OK) {
285 WARN("Failed to unmarshal stream\n");
286 return hres;
287 }
288
289 TRACE("ppv=%p\n", *ppv);
290 return S_OK;
291}
#define WARN(fmt,...)
Definition: precomp.h:61
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT WINAPI CoUnmarshalInterface(IStream *stream, REFIID riid, void **ppv)
Definition: marshal.c:793
static StdGITEntry * StdGlobalInterfaceTable_FindEntry(StdGlobalInterfaceTableImpl *This, DWORD cookie)
Definition: git.c:93
static CRITICAL_SECTION git_section
Definition: git.c:74
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define debugstr_guid
Definition: kernel32.h:35
HRESULT hres
Definition: protocol.c:465
Definition: parse.h:23
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

◆ StdGlobalInterfaceTable_QueryInterface()

static HRESULT WINAPI StdGlobalInterfaceTable_QueryInterface ( IGlobalInterfaceTable iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 114 of file git.c.

116{
117 /* Make sure silly coders can't crash us */
118 if (ppvObject == 0) return E_INVALIDARG;
119
120 *ppvObject = 0; /* assume we don't have the interface */
121
122 /* Do we implement that interface? */
124 IsEqualIID(&IID_IGlobalInterfaceTable, riid))
125 {
126 *ppvObject = iface;
127 }
128 else
129 {
130 FIXME("(%s), not supported.\n", debugstr_guid(riid));
131 return E_NOINTERFACE;
132 }
133
134 /* Now inc the refcount */
135 IGlobalInterfaceTable_AddRef(iface);
136 return S_OK;
137}
#define FIXME(fmt,...)
Definition: precomp.h:53
const GUID IID_IUnknown
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ StdGlobalInterfaceTable_RegisterInterfaceInGlobal()

static HRESULT WINAPI StdGlobalInterfaceTable_RegisterInterfaceInGlobal ( IGlobalInterfaceTable iface,
IUnknown pUnk,
REFIID  riid,
DWORD pdwCookie 
)
static

Definition at line 156 of file git.c.

159{
165
166 TRACE("iface=%p, pUnk=%p, riid=%s, pdwCookie=0x%p\n", iface, pUnk, debugstr_guid(riid), pdwCookie);
167
168 if (pUnk == NULL) return E_INVALIDARG;
169
170 /* marshal the interface */
171 TRACE("About to marshal the interface\n");
172
174 if (hres != S_OK) return hres;
175 hres = CoMarshalInterface(stream, riid, pUnk, MSHCTX_INPROC, NULL, MSHLFLAGS_TABLESTRONG);
176 if (hres != S_OK)
177 {
178 IStream_Release(stream);
179 return hres;
180 }
181
182 zero.QuadPart = 0;
183 IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL);
184
185 entry = malloc(sizeof(*entry));
186 if (!entry)
187 {
189 IStream_Release(stream);
190 return E_OUTOFMEMORY;
191 }
192
194
195 entry->iid = *riid;
196 entry->stream = stream;
197 entry->cookie = This->nextCookie;
198 This->nextCookie++; /* inc the cookie count */
199
200 /* insert the new entry at the end of the list */
201 list_add_tail(&This->list, &entry->entry);
202
203 /* and return the cookie */
204 *pdwCookie = entry->cookie;
205
207
208 TRACE("Cookie is %#lx\n", entry->cookie);
209 return S_OK;
210}
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
#define TRUE
Definition: types.h:120
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL delete_on_release, IStream **stream)
HRESULT WINAPI CoMarshalInterface(IStream *stream, REFIID riid, IUnknown *unk, DWORD dest_context, void *pvDestContext, DWORD mshlFlags)
Definition: marshal.c:483
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
int zero
Definition: sehframes.cpp:29

◆ StdGlobalInterfaceTable_Release()

static ULONG WINAPI StdGlobalInterfaceTable_Release ( IGlobalInterfaceTable iface)
static

Definition at line 146 of file git.c.

147{
148 return 1;
149}

◆ StdGlobalInterfaceTable_RevokeInterfaceFromGlobal()

static HRESULT WINAPI StdGlobalInterfaceTable_RevokeInterfaceFromGlobal ( IGlobalInterfaceTable iface,
DWORD  dwCookie 
)
static

Definition at line 213 of file git.c.

215{
218 HRESULT hr;
219
220 TRACE("%p, %#lx.\n", iface, dwCookie);
221
223
225 if (entry == NULL) {
226 TRACE("Entry not found\n");
228 return E_INVALIDARG; /* not found */
229 }
230
231 list_remove(&entry->entry);
232
234
235 /* Free the stream */
236 hr = CoReleaseMarshalData(entry->stream);
237 if (hr != S_OK)
238 {
239 WARN("Failed to release marshal data, hr = %#lx\n", hr);
240 return hr;
241 }
242 IStream_Release(entry->stream);
243
244 free(entry);
245 return S_OK;
246}
HRESULT hr
Definition: shlfolder.c:183

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( ole  )

Variable Documentation

◆ critsect_debug

CRITICAL_SECTION_DEBUG critsect_debug
static
Initial value:
=
{
0, 0, &git_section,
0, 0, { (DWORD_PTR)(__FILE__ ": global interface table") }
}
static CRITICAL_SECTION_DEBUG critsect_debug
Definition: git.c:75
#define DWORD_PTR
Definition: treelist.c:76

Definition at line 75 of file git.c.

◆ git_section

◆ std_git

IGlobalInterfaceTable* std_git
static

Definition at line 72 of file git.c.

Referenced by GlobalInterfaceTable_CreateInstance(), and release_std_git().

◆ StdGlobalInterfaceTableImpl_Vtbl

const IGlobalInterfaceTableVtbl StdGlobalInterfaceTableImpl_Vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI StdGlobalInterfaceTable_RevokeInterfaceFromGlobal(IGlobalInterfaceTable *iface, DWORD dwCookie)
Definition: git.c:213
static HRESULT WINAPI StdGlobalInterfaceTable_QueryInterface(IGlobalInterfaceTable *iface, REFIID riid, void **ppvObject)
Definition: git.c:114
static HRESULT WINAPI StdGlobalInterfaceTable_RegisterInterfaceInGlobal(IGlobalInterfaceTable *iface, IUnknown *pUnk, REFIID riid, DWORD *pdwCookie)
Definition: git.c:156
static ULONG WINAPI StdGlobalInterfaceTable_Release(IGlobalInterfaceTable *iface)
Definition: git.c:146
static ULONG WINAPI StdGlobalInterfaceTable_AddRef(IGlobalInterfaceTable *iface)
Definition: git.c:140
static HRESULT WINAPI StdGlobalInterfaceTable_GetInterfaceFromGlobal(IGlobalInterfaceTable *iface, DWORD dwCookie, REFIID riid, void **ppv)
Definition: git.c:249

Definition at line 293 of file git.c.

Referenced by GlobalInterfaceTable_CreateInstance().