TCHAR ClassGuidString[MAX_GUID_STRING_LEN];
GUID ClassGuid;
ULONG ulLength;
- LPTSTR DeviceID;
+ LPTSTR DeviceID = NULL;
INT ClassImage = 24;
CONFIGRET cr;
BOOL fCreated;
STARTUPINFO si;
SECURITY_ATTRIBUTES sa;
- HANDLE hInRead;
- HANDLE hOutWrite;
- HANDLE hErrWrite;
+ HANDLE hInRead = INVALID_HANDLE_VALUE;
+ HANDLE hOutWrite = INVALID_HANDLE_VALUE;
+ HANDLE hErrWrite = INVALID_HANDLE_VALUE;
// Create pipes
// initialize security attributes for handle inheritance (for WinNT)
sa.lpSecurityDescriptor = NULL;
// create STDIN pipe
- if( !CreatePipe( &hInRead, phInWrite, &sa, 0 ))
+ if( !CreatePipe( &hInRead, phInWrite, &sa, 0 )) {
+ hInRead = INVALID_HANDLE_VALUE;
goto error;
+ }
// create STDOUT pipe
- if( !CreatePipe( phOutRead, &hOutWrite, &sa, 0 ))
+ if( !CreatePipe( phOutRead, &hOutWrite, &sa, 0 )) {
+ hOutWrite = INVALID_HANDLE_VALUE;
goto error;
+ }
// create STDERR pipe
- if( !CreatePipe( phErrRead, &hErrWrite, &sa, 0 ))
+ if( !CreatePipe( phErrRead, &hErrWrite, &sa, 0 )) {
+ hErrWrite = INVALID_HANDLE_VALUE;
goto error;
+ }
// process startup information
memset( &si, 0, sizeof( si ));
return TRUE;
error:
- CloseHandle( hInRead );
- CloseHandle( hOutWrite );
- CloseHandle( hErrWrite );
+ if (hInRead != INVALID_HANDLE_VALUE) CloseHandle( hInRead );
+ if (hOutWrite != INVALID_HANDLE_VALUE) CloseHandle( hOutWrite );
+ if (hErrWrite != INVALID_HANDLE_VALUE) CloseHandle( hErrWrite );
CloseHandle( ppi->hProcess );
CloseHandle( ppi->hThread );
ULONG_PTR CharsRead = _tcslen(Buffer);
while (Len + CharsRead >= AllocLen)
{
+ LPTSTR OldContents = Contents;
Contents = cmd_realloc(Contents, (AllocLen *= 2) * sizeof(TCHAR));
if (!Contents)
+ {
+ cmd_free(OldContents);
return NULL;
+ }
}
_tcscpy(&Contents[Len], Buffer);
Len += CharsRead;
dwBuffer = GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE);
if (dwBuffer == 0)
{
- ConOutResPrintf(STRING_VOL_HELP2, _T("PATH"));
+ cmd_free(pszBuffer);
+ ConOutResPrintf(STRING_VOL_HELP2, _T("PATH"));
return 0;
}
else if (dwBuffer > ENV_BUFFER_SIZE)
{
pszBuffer = (LPTSTR)cmd_realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
- GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE);
+ GetEnvironmentVariable (_T("PATH"), pszBuffer, dwBuffer);
}
ConOutPrintf (_T("PATH=%s\n"), pszBuffer);
{
if (size > MAX_PATH)
{
+ LPTSTR Oldcomspec = comspec;
comspec = cmd_realloc(comspec,size * sizeof(TCHAR) );
if (comspec==NULL)
{
+ cmd_free(Oldcomspec);
return 1;
}
size = GetEnvironmentVariable (_T("COMSPEC"), comspec, size);
set(CMAKE_${lang}_COMPILER_LINKER_OPTION_FLAG_EXECUTABLE "/link")
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS 1)
- set(CMAKE_${lang}_LINK_EXECUTABLE "${_CMAKE_VS_LINK_EXE}<CMAKE_${lang}_COMPILER> ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} <FLAGS> /Fe<TARGET> <OBJECTS> /link /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
+ set(CMAKE_${lang}_LINK_EXECUTABLE
+ "${_CMAKE_VS_LINK_EXE}<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
set(CMAKE_${lang}_FLAGS_INIT "")
set(CMAKE_${lang}_FLAGS_DEBUG_INIT "")
-
-add_definitions(-D__WINESRC__)
-
remove_definitions(-D_WIN32_WINNT=0x502)
add_definitions(-D_WIN32_WINNT=0x600)
+add_definitions(-D__WINESRC__)
include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine)
-
spec2def(dmusic.dll dmusic.spec)
-add_library(dmusic SHARED
+list(APPEND SOURCE
buffer.c
clock.c
collection.c
dmusic.c
dmusic_main.c
download.c
- downloadedinstrument.c
instrument.c
port.c
- regsvr.c
version.rc
${CMAKE_CURRENT_BINARY_DIR}/dmusic.def)
+add_library(dmusic SHARED ${SOURCE})
set_module_type(dmusic win32dll UNICODE)
-
-target_link_libraries(dmusic
- dxguid
- uuid
- wine)
-
-add_importlibs(dmusic
- msvcrt
- user32
- advapi32
- ole32
- dsound
- kernel32
- ntdll)
-
+target_link_libraries(dmusic dxguid uuid wine)
+add_importlibs(dmusic ole32 advapi32 winmm msvcrt kernel32 ntdll)
add_dependencies(dmusic psdk)
add_pch(dmusic dmusic_private.h)
add_cd_file(TARGET dmusic DESTINATION reactos/system32 FOR all)
-/* IDirectMusicBuffer Implementation
+/*
+ * IDirectMusicBuffer Implementation
*
* Copyright (C) 2003-2004 Rok Mandeljc
+ * Copyright (C) 2012 Christian Costa
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*/
#include "dmusic_private.h"
+//#include "initguid.h"
+#include "dmksctrl.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+static inline IDirectMusicBufferImpl *impl_from_IDirectMusicBuffer(IDirectMusicBuffer *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectMusicBufferImpl, IDirectMusicBuffer_iface);
+}
+
/* IDirectMusicBufferImpl IUnknown part: */
-static HRESULT WINAPI IDirectMusicBufferImpl_QueryInterface (LPDIRECTMUSICBUFFER iface, REFIID riid, LPVOID *ppobj) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- TRACE("(%p, (%s, %p)\n",This,debugstr_dmguid(riid),ppobj);
- if (IsEqualIID (riid, &IID_IUnknown)
- || IsEqualIID (riid, &IID_IDirectMusicBuffer)) {
- IUnknown_AddRef(iface);
- *ppobj = This;
- return S_OK;
- }
- WARN("(%p, (%s, %p): not found\n",This,debugstr_dmguid(riid),ppobj);
- return E_NOINTERFACE;
+static HRESULT WINAPI IDirectMusicBufferImpl_QueryInterface(LPDIRECTMUSICBUFFER iface, REFIID riid, LPVOID *ret_iface)
+{
+ TRACE("(%p)->(%s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
+
+ if (IsEqualIID(riid, &IID_IUnknown) ||
+ IsEqualIID(riid, &IID_IDirectMusicBuffer))
+ {
+ IDirectMusicBuffer_AddRef(iface);
+ *ret_iface = iface;
+ return S_OK;
+ }
+
+ *ret_iface = NULL;
+
+ WARN("(%p)->(%s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
+
+ return E_NOINTERFACE;
}
-static ULONG WINAPI IDirectMusicBufferImpl_AddRef (LPDIRECTMUSICBUFFER iface) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- ULONG refCount = InterlockedIncrement(&This->ref);
+static ULONG WINAPI IDirectMusicBufferImpl_AddRef(LPDIRECTMUSICBUFFER iface)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+ ULONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
+ TRACE("(%p)->(): new ref = %u\n", iface, ref);
- DMUSIC_LockModule();
+ DMUSIC_LockModule();
- return refCount;
+ return ref;
}
-static ULONG WINAPI IDirectMusicBufferImpl_Release (LPDIRECTMUSICBUFFER iface) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- ULONG refCount = InterlockedDecrement(&This->ref);
+static ULONG WINAPI IDirectMusicBufferImpl_Release(LPDIRECTMUSICBUFFER iface)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+ ULONG ref = InterlockedDecrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
+ TRACE("(%p)->(): new ref = %u\n", iface, ref);
- if (!refCount) {
- HeapFree(GetProcessHeap(), 0, This);
- }
+ if (!ref) {
+ HeapFree(GetProcessHeap(), 0, This->data);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
- DMUSIC_UnlockModule();
-
- return refCount;
+ DMUSIC_UnlockModule();
+
+ return ref;
}
/* IDirectMusicBufferImpl IDirectMusicBuffer part: */
-static HRESULT WINAPI IDirectMusicBufferImpl_Flush (LPDIRECTMUSICBUFFER iface) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p): stub\n", This);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_Flush(LPDIRECTMUSICBUFFER iface)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ TRACE("(%p)->()\n", iface);
+
+ This->write_pos = 0;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_TotalTime (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prtTime) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, %p): stub\n", This, prtTime);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_TotalTime(LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prtTime)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ FIXME("(%p, %p): stub\n", This, prtTime);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_PackStructured (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD dwChannelMessage) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, 0x%s, %d, %d): stub\n", This, wine_dbgstr_longlong(rt), dwChannelGroup, dwChannelMessage);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_PackStructured(LPDIRECTMUSICBUFFER iface, REFERENCE_TIME ref_time, DWORD channel_group, DWORD channel_message)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+ DWORD new_write_pos = This->write_pos + sizeof(DMUS_EVENTHEADER) + sizeof(DWORD);
+ DMUS_EVENTHEADER header;
+
+ TRACE("(%p)->(0x%s, %u, 0x%x)\n", iface, wine_dbgstr_longlong(ref_time), channel_group, channel_message);
+
+ if (new_write_pos > This->size)
+ return DMUS_E_BUFFER_FULL;
+
+ /* Channel_message 0xZZYYXX (3 bytes) is a midi message where XX = status byte, YY = byte 1 and ZZ = byte 2 */
+
+ if (!(channel_message & 0x80))
+ {
+ /* Status byte MSB is always set */
+ return DMUS_E_INVALID_EVENT;
+ }
+
+ if (!This->write_pos)
+ This->start_time = ref_time;
+
+ header.cbEvent = 3; /* Midi message takes 4 bytes space but only 3 are relevant */
+ header.dwChannelGroup = channel_group;
+ header.rtDelta = ref_time - This->start_time;
+ header.dwFlags = DMUS_EVENT_STRUCTURED;
+
+ memcpy(This->data + This->write_pos, &header, sizeof(header));
+ *(DWORD*)(This->data + This->write_pos + sizeof(header)) = channel_message;
+ This->write_pos = new_write_pos;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_PackUnstructured (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD cb, LPBYTE lpb) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, 0x%s, %d, %d, %p): stub\n", This, wine_dbgstr_longlong(rt), dwChannelGroup, cb, lpb);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_PackUnstructured(LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD cb, LPBYTE lpb)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ FIXME("(%p, 0x%s, %d, %d, %p): stub\n", This, wine_dbgstr_longlong(rt), dwChannelGroup, cb, lpb);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_ResetReadPtr (LPDIRECTMUSICBUFFER iface) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p): stub\n", This);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_ResetReadPtr(LPDIRECTMUSICBUFFER iface)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ FIXME("(%p): stub\n", This);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_GetNextEvent (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prt, LPDWORD pdwChannelGroup, LPDWORD pdwLength, LPBYTE* ppData) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, %p, %p, %p, %p): stub\n", This, prt, pdwChannelGroup, pdwLength, ppData);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_GetNextEvent(LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prt, LPDWORD pdwChannelGroup, LPDWORD pdwLength, LPBYTE* ppData)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ FIXME("(%p, %p, %p, %p, %p): stub\n", This, prt, pdwChannelGroup, pdwLength, ppData);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_GetRawBufferPtr (LPDIRECTMUSICBUFFER iface, LPBYTE* ppData) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, %p): stub\n", This, ppData);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_GetRawBufferPtr(LPDIRECTMUSICBUFFER iface, LPBYTE* data)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ TRACE("(%p)->(%p)\n", iface, data);
+
+ if (!data)
+ return E_POINTER;
+
+ *data = This->data;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_GetStartTime (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prt) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, %p): stub\n", This, prt);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_GetStartTime(LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME ref_time)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ TRACE("(%p)->(%p)\n", iface, ref_time);
+
+ if (!ref_time)
+ return E_POINTER;
+ if (!This->write_pos)
+ return DMUS_E_BUFFER_EMPTY;
+
+ *ref_time = This->start_time;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_GetUsedBytes (LPDIRECTMUSICBUFFER iface, LPDWORD pcb) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, %p): stub\n", This, pcb);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_GetUsedBytes(LPDIRECTMUSICBUFFER iface, LPDWORD used_bytes)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ TRACE("(%p)->(%p)\n", iface, used_bytes);
+
+ if (!used_bytes)
+ return E_POINTER;
+
+ *used_bytes = This->write_pos;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_GetMaxBytes (LPDIRECTMUSICBUFFER iface, LPDWORD pcb) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, %p): stub\n", This, pcb);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_GetMaxBytes(LPDIRECTMUSICBUFFER iface, LPDWORD max_bytes)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ TRACE("(%p)->(%p)\n", iface, max_bytes);
+
+ if (!max_bytes)
+ return E_POINTER;
+
+ *max_bytes = This->size;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_GetBufferFormat (LPDIRECTMUSICBUFFER iface, LPGUID pGuidFormat) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, %p): stub\n", This, pGuidFormat);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_GetBufferFormat(LPDIRECTMUSICBUFFER iface, LPGUID format)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ TRACE("(%p)->(%p)\n", iface, format);
+
+ if (!format)
+ return E_POINTER;
+
+ *format = This->format;
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_SetStartTime (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, 0x%s): stub\n", This, wine_dbgstr_longlong(rt));
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_SetStartTime(LPDIRECTMUSICBUFFER iface, REFERENCE_TIME ref_time)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ TRACE("(%p)->(0x%s)\n", This, wine_dbgstr_longlong(ref_time));
+
+ This->start_time = ref_time;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_SetUsedBytes (LPDIRECTMUSICBUFFER iface, DWORD cb) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, %d): stub\n", This, cb);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_SetUsedBytes(LPDIRECTMUSICBUFFER iface, DWORD used_bytes)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ TRACE("(%p)->(%u)\n", iface, used_bytes);
+
+ if (used_bytes > This->size)
+ return DMUS_E_BUFFER_FULL;
+
+ This->write_pos = used_bytes;
+
+ return S_OK;
}
static const IDirectMusicBufferVtbl DirectMusicBuffer_Vtbl = {
IDirectMusicBufferImpl_SetUsedBytes
};
-/* for ClassFactory */
-HRESULT WINAPI DMUSIC_CreateDirectMusicBufferImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
- IDirectMusicBufferImpl* dmbuff;
-
- dmbuff = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBufferImpl));
- if (NULL == dmbuff) {
- *ppobj = NULL;
- return E_OUTOFMEMORY;
- }
- dmbuff->lpVtbl = &DirectMusicBuffer_Vtbl;
- dmbuff->ref = 0; /* will be inited by QueryInterface */
-
- return IDirectMusicBufferImpl_QueryInterface ((LPDIRECTMUSICBUFFER)dmbuff, lpcGUID, ppobj);
+HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_iface)
+{
+ IDirectMusicBufferImpl* dmbuffer;
+ HRESULT hr;
+
+ TRACE("(%p, %p)\n", desc, ret_iface);
+
+ *ret_iface = NULL;
+
+ dmbuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBufferImpl));
+ if (!dmbuffer)
+ return E_OUTOFMEMORY;
+
+ dmbuffer->IDirectMusicBuffer_iface.lpVtbl = &DirectMusicBuffer_Vtbl;
+ dmbuffer->ref = 0; /* Will be inited by QueryInterface */
+
+ if (IsEqualGUID(&desc->guidBufferFormat, &GUID_NULL))
+ dmbuffer->format = KSDATAFORMAT_SUBTYPE_MIDI;
+ else
+ dmbuffer->format = desc->guidBufferFormat;
+ dmbuffer->size = (desc->cbBuffer + 3) & ~3; /* Buffer size must be multiple of 4 bytes */
+
+ dmbuffer->data = HeapAlloc(GetProcessHeap(), 0, dmbuffer->size);
+ if (!dmbuffer->data) {
+ HeapFree(GetProcessHeap(), 0, dmbuffer);
+ return E_OUTOFMEMORY;
+ }
+
+ hr = IDirectMusicBufferImpl_QueryInterface((LPDIRECTMUSICBUFFER)dmbuffer, &IID_IDirectMusicBuffer, ret_iface);
+ if (FAILED(hr))
+ {
+ HeapFree(GetProcessHeap(), 0, dmbuffer->data);
+ HeapFree(GetProcessHeap(), 0, dmbuffer);
+ }
+
+ return hr;
}
-/* IReferenceClock Implementation
+/*
+ * IReferenceClock Implementation
*
* Copyright (C) 2003-2004 Rok Mandeljc
*
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+static inline IReferenceClockImpl *impl_from_IReferenceClock(IReferenceClock *iface)
+{
+ return CONTAINING_RECORD(iface, IReferenceClockImpl, IReferenceClock_iface);
+}
+
/* IReferenceClockImpl IUnknown part: */
-static HRESULT WINAPI IReferenceClockImpl_QueryInterface (IReferenceClock *iface, REFIID riid, LPVOID *ppobj) {
- IReferenceClockImpl *This = (IReferenceClockImpl *)iface;
+static HRESULT WINAPI IReferenceClockImpl_QueryInterface(IReferenceClock *iface, REFIID riid, LPVOID *ppobj)
+{
+ IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
if (IsEqualIID (riid, &IID_IUnknown) ||
return E_NOINTERFACE;
}
-static ULONG WINAPI IReferenceClockImpl_AddRef (IReferenceClock *iface) {
- IReferenceClockImpl *This = (IReferenceClockImpl *)iface;
- ULONG refCount = InterlockedIncrement(&This->ref);
+static ULONG WINAPI IReferenceClockImpl_AddRef(IReferenceClock *iface)
+{
+ IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
+ ULONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
+ TRACE("(%p)->(): new ref = %u\n", This, ref);
- DMUSIC_LockModule();
+ DMUSIC_LockModule();
- return refCount;
+ return ref;
}
-static ULONG WINAPI IReferenceClockImpl_Release (IReferenceClock *iface) {
- IReferenceClockImpl *This = (IReferenceClockImpl *)iface;
- ULONG refCount = InterlockedDecrement(&This->ref);
+static ULONG WINAPI IReferenceClockImpl_Release(IReferenceClock *iface)
+{
+ IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
+ ULONG ref = InterlockedDecrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
+ TRACE("(%p)->(): new ref = %u\n", This, ref);
- if (!refCount) {
- HeapFree(GetProcessHeap(), 0, This);
- }
+ if (!ref)
+ HeapFree(GetProcessHeap(), 0, This);
- DMUSIC_UnlockModule();
+ DMUSIC_UnlockModule();
- return refCount;
+ return ref;
}
/* IReferenceClockImpl IReferenceClock part: */
-static HRESULT WINAPI IReferenceClockImpl_GetTime (IReferenceClock *iface, REFERENCE_TIME* pTime) {
- IReferenceClockImpl *This = (IReferenceClockImpl *)iface;
- TRACE("(%p, %p)\n", This, pTime);
- *pTime = This->rtTime;
- return S_OK;
+static HRESULT WINAPI IReferenceClockImpl_GetTime(IReferenceClock *iface, REFERENCE_TIME* pTime)
+{
+ IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
+
+ TRACE("(%p)->(%p)\n", This, pTime);
+
+ *pTime = This->rtTime;
+
+ return S_OK;
}
-static HRESULT WINAPI IReferenceClockImpl_AdviseTime (IReferenceClock *iface, REFERENCE_TIME baseTime, REFERENCE_TIME streamTime, HANDLE hEvent, DWORD* pdwAdviseCookie) {
- IReferenceClockImpl *This = (IReferenceClockImpl *)iface;
- FIXME("(%p, 0x%s, 0x%s, %p, %p): stub\n", This, wine_dbgstr_longlong(baseTime), wine_dbgstr_longlong(streamTime), hEvent, pdwAdviseCookie);
- return S_OK;
+static HRESULT WINAPI IReferenceClockImpl_AdviseTime(IReferenceClock *iface, REFERENCE_TIME baseTime, REFERENCE_TIME streamTime, HANDLE hEvent, DWORD* pdwAdviseCookie)
+{
+ IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
+
+ FIXME("(%p)->(0x%s, 0x%s, %p, %p): stub\n", This, wine_dbgstr_longlong(baseTime), wine_dbgstr_longlong(streamTime), hEvent, pdwAdviseCookie);
+
+ return S_OK;
}
-static HRESULT WINAPI IReferenceClockImpl_AdvisePeriodic (IReferenceClock *iface, REFERENCE_TIME startTime, REFERENCE_TIME periodTime, HANDLE hSemaphore, DWORD* pdwAdviseCookie) {
- IReferenceClockImpl *This = (IReferenceClockImpl *)iface;
- FIXME("(%p, 0x%s, 0x%s, %p, %p): stub\n", This, wine_dbgstr_longlong(startTime), wine_dbgstr_longlong(periodTime), hSemaphore, pdwAdviseCookie);
- return S_OK;
+static HRESULT WINAPI IReferenceClockImpl_AdvisePeriodic(IReferenceClock *iface, REFERENCE_TIME startTime, REFERENCE_TIME periodTime, HANDLE hSemaphore, DWORD* pdwAdviseCookie)
+{
+ IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
+
+ FIXME("(%p)->(0x%s, 0x%s, %p, %p): stub\n", This, wine_dbgstr_longlong(startTime), wine_dbgstr_longlong(periodTime), hSemaphore, pdwAdviseCookie);
+
+ return S_OK;
}
-static HRESULT WINAPI IReferenceClockImpl_Unadvise (IReferenceClock *iface, DWORD dwAdviseCookie) {
- IReferenceClockImpl *This = (IReferenceClockImpl *)iface;
- FIXME("(%p, %d): stub\n", This, dwAdviseCookie);
- return S_OK;
+static HRESULT WINAPI IReferenceClockImpl_Unadvise(IReferenceClock *iface, DWORD dwAdviseCookie)
+{
+ IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
+
+ FIXME("(%p)->(%d): stub\n", This, dwAdviseCookie);
+
+ return S_OK;
}
static const IReferenceClockVtbl ReferenceClock_Vtbl = {
};
/* for ClassFactory */
-HRESULT WINAPI DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
- IReferenceClockImpl* clock;
+HRESULT DMUSIC_CreateReferenceClockImpl(LPCGUID riid, LPVOID* ret_iface, LPUNKNOWN unkouter)
+{
+ IReferenceClockImpl* clock;
- clock = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IReferenceClockImpl));
- if (NULL == clock) {
- *ppobj = NULL;
- return E_OUTOFMEMORY;
- }
- clock->lpVtbl = &ReferenceClock_Vtbl;
- clock->ref = 0; /* will be inited by QueryInterface */
- clock->rtTime = 0;
- clock->pClockInfo.dwSize = sizeof (DMUS_CLOCKINFO);
-
- return IReferenceClockImpl_QueryInterface ((IReferenceClock *)clock, lpcGUID, ppobj);
+ TRACE("(%p,%p,%p)\n", riid, ret_iface, unkouter);
+
+ clock = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IReferenceClockImpl));
+ if (!clock) {
+ *ret_iface = NULL;
+ return E_OUTOFMEMORY;
+ }
+
+ clock->IReferenceClock_iface.lpVtbl = &ReferenceClock_Vtbl;
+ clock->ref = 0; /* Will be inited by QueryInterface */
+ clock->rtTime = 0;
+ clock->pClockInfo.dwSize = sizeof (DMUS_CLOCKINFO);
+
+ return IReferenceClockImpl_QueryInterface((IReferenceClock*)clock, riid, ret_iface);
}
-/* IDirectMusicCollection Implementation
+/*
+ * IDirectMusicCollection Implementation
*
* Copyright (C) 2003-2004 Rok Mandeljc
*
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
WINE_DECLARE_DEBUG_CHANNEL(dmfile);
-static ULONG WINAPI IDirectMusicCollectionImpl_IUnknown_AddRef (LPUNKNOWN iface);
-static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_AddRef (LPDIRECTMUSICCOLLECTION iface);
-static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface);
-static ULONG WINAPI IDirectMusicCollectionImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface);
+static inline IDirectMusicCollectionImpl *impl_from_IDirectMusicCollection(IDirectMusicCollection *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectMusicCollectionImpl, IDirectMusicCollection_iface);
+}
+
+static inline IDirectMusicCollectionImpl *impl_from_IDirectMusicObject(IDirectMusicObject *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectMusicCollectionImpl, IDirectMusicObject_iface);
+}
+
+static inline IDirectMusicCollectionImpl *impl_from_IPersistStream(IPersistStream *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectMusicCollectionImpl, IPersistStream_iface);
+}
/*****************************************************************************
* IDirectMusicCollectionImpl implementation
*/
/* IDirectMusicCollectionImpl IUnknown part: */
-static HRESULT WINAPI IDirectMusicCollectionImpl_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, UnknownVtbl, iface);
- TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
-
- if (IsEqualIID (riid, &IID_IUnknown)) {
- *ppobj = &This->UnknownVtbl;
- IDirectMusicCollectionImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
- return S_OK;
- } else if (IsEqualIID (riid, &IID_IDirectMusicCollection)) {
- *ppobj = &This->CollectionVtbl;
- IDirectMusicCollectionImpl_IDirectMusicCollection_AddRef ((LPDIRECTMUSICCOLLECTION)&This->CollectionVtbl);
- return S_OK;
- } else if (IsEqualIID (riid, &IID_IDirectMusicObject)) {
- *ppobj = &This->ObjectVtbl;
- IDirectMusicCollectionImpl_IDirectMusicObject_AddRef ((LPDIRECTMUSICOBJECT)&This->ObjectVtbl);
- return S_OK;
- } else if (IsEqualIID (riid, &IID_IPersistStream)) {
- *ppobj = &This->PersistStreamVtbl;
- IDirectMusicCollectionImpl_IPersistStream_AddRef ((LPPERSISTSTREAM)&This->PersistStreamVtbl);
- return S_OK;
- }
-
- WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
- return E_NOINTERFACE;
+static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_QueryInterface(LPDIRECTMUSICCOLLECTION iface, REFIID riid, LPVOID *ret_iface)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicCollection(iface);
+
+ TRACE("(%p/%p)->(%s, %p)\n", iface, This, debugstr_dmguid(riid), ret_iface);
+
+ if (IsEqualIID(riid, &IID_IUnknown) ||
+ IsEqualIID(riid, &IID_IDirectMusicCollection))
+ {
+ *ret_iface = iface;
+ IDirectMusicCollection_AddRef(iface);
+ return S_OK;
+ }
+ else if (IsEqualIID(riid, &IID_IDirectMusicObject))
+ {
+ *ret_iface = &This->IDirectMusicObject_iface;
+ IDirectMusicCollection_AddRef(iface);
+ return S_OK;
+ }
+ else if (IsEqualIID(riid, &IID_IPersistStream))
+ {
+ *ret_iface = &This->IPersistStream_iface;
+ IDirectMusicCollection_AddRef(iface);
+ return S_OK;
+ }
+
+ *ret_iface = NULL;
+
+ WARN("(%p/%p)->(%s, %p): not found\n", iface, This, debugstr_dmguid(riid), ret_iface);
+
+ return E_NOINTERFACE;
}
-static ULONG WINAPI IDirectMusicCollectionImpl_IUnknown_AddRef (LPUNKNOWN iface) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, UnknownVtbl, iface);
- ULONG refCount = InterlockedIncrement(&This->ref);
+static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_AddRef(LPDIRECTMUSICCOLLECTION iface)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicCollection(iface);
+ ULONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
+ TRACE("(%p/%p)->(): new ref = %u\n", iface, This, ref);
- DMUSIC_LockModule();
+ DMUSIC_LockModule();
- return refCount;
+ return ref;
}
-static ULONG WINAPI IDirectMusicCollectionImpl_IUnknown_Release (LPUNKNOWN iface) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, UnknownVtbl, iface);
- ULONG refCount = InterlockedDecrement(&This->ref);
-
- TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
-
- if (!refCount) {
- HeapFree(GetProcessHeap(), 0, This);
- }
-
- DMUSIC_UnlockModule();
+static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_Release(LPDIRECTMUSICCOLLECTION iface)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicCollection(iface);
+ ULONG ref = InterlockedDecrement(&This->ref);
- return refCount;
-}
+ TRACE("(%p/%p)->(): new ref = %u\n", iface, This, ref);
-static const IUnknownVtbl DirectMusicCollection_Unknown_Vtbl = {
- IDirectMusicCollectionImpl_IUnknown_QueryInterface,
- IDirectMusicCollectionImpl_IUnknown_AddRef,
- IDirectMusicCollectionImpl_IUnknown_Release
-};
+ if (!ref)
+ HeapFree(GetProcessHeap(), 0, This);
-/* IDirectMusicCollectionImpl IDirectMusicCollection part: */
-static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_QueryInterface (LPDIRECTMUSICCOLLECTION iface, REFIID riid, LPVOID *ppobj) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, CollectionVtbl, iface);
- return IDirectMusicCollectionImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
-}
+ DMUSIC_UnlockModule();
-static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_AddRef (LPDIRECTMUSICCOLLECTION iface) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, CollectionVtbl, iface);
- return IDirectMusicCollectionImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
+ return ref;
}
-static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_Release (LPDIRECTMUSICCOLLECTION iface) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, CollectionVtbl, iface);
- return IDirectMusicCollectionImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
+/* IDirectMusicCollection Interface follows: */
+static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_GetInstrument(LPDIRECTMUSICCOLLECTION iface, DWORD patch, IDirectMusicInstrument** instrument)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicCollection(iface);
+ DMUS_PRIVATE_INSTRUMENTENTRY *inst_entry;
+ struct list *list_entry;
+ DWORD inst_patch;
+
+ TRACE("(%p/%p)->(%u, %p)\n", iface, This, patch, instrument);
+
+ LIST_FOR_EACH(list_entry, &This->Instruments) {
+ inst_entry = LIST_ENTRY(list_entry, DMUS_PRIVATE_INSTRUMENTENTRY, entry);
+ IDirectMusicInstrument_GetPatch(inst_entry->pInstrument, &inst_patch);
+ if (patch == inst_patch) {
+ *instrument = inst_entry->pInstrument;
+ IDirectMusicInstrument_AddRef(inst_entry->pInstrument);
+ IDirectMusicInstrumentImpl_CustomLoad(inst_entry->pInstrument, This->pStm);
+ TRACE(": returning instrument %p\n", *instrument);
+ return S_OK;
+ }
+ }
+
+ TRACE(": instrument not found\n");
+
+ return DMUS_E_INVALIDPATCH;
}
-/* IDirectMusicCollection Interface follow: */
-static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_GetInstrument (LPDIRECTMUSICCOLLECTION iface, DWORD dwPatch, IDirectMusicInstrument** ppInstrument) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, CollectionVtbl, iface);
- DMUS_PRIVATE_INSTRUMENTENTRY *tmpEntry;
- struct list *listEntry;
- DWORD dwInstPatch;
-
- TRACE("(%p, %d, %p)\n", This, dwPatch, ppInstrument);
-
- LIST_FOR_EACH (listEntry, &This->Instruments) {
- tmpEntry = LIST_ENTRY(listEntry, DMUS_PRIVATE_INSTRUMENTENTRY, entry);
- IDirectMusicInstrument_GetPatch (tmpEntry->pInstrument, &dwInstPatch);
- if (dwPatch == dwInstPatch) {
- *ppInstrument = tmpEntry->pInstrument;
- IDirectMusicInstrument_AddRef (tmpEntry->pInstrument);
- IDirectMusicInstrumentImpl_Custom_Load (tmpEntry->pInstrument, This->pStm); /* load instrument before returning it */
- TRACE(": returning instrument %p\n", *ppInstrument);
- return S_OK;
- }
-
- }
- TRACE(": instrument not found\n");
-
- return DMUS_E_INVALIDPATCH;
-}
-
-static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_EnumInstrument (LPDIRECTMUSICCOLLECTION iface, DWORD dwIndex, DWORD* pdwPatch, LPWSTR pwszName, DWORD dwNameLen) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, CollectionVtbl, iface);
- unsigned int r = 0;
- DMUS_PRIVATE_INSTRUMENTENTRY *tmpEntry;
- struct list *listEntry;
- DWORD dwLen;
-
- TRACE("(%p, %d, %p, %p, %d)\n", This, dwIndex, pdwPatch, pwszName, dwNameLen);
- LIST_FOR_EACH (listEntry, &This->Instruments) {
- tmpEntry = LIST_ENTRY(listEntry, DMUS_PRIVATE_INSTRUMENTENTRY, entry);
- if (r == dwIndex) {
- ICOM_NAME_MULTI (IDirectMusicInstrumentImpl, InstrumentVtbl, tmpEntry->pInstrument, pInstrument);
- IDirectMusicInstrument_GetPatch (tmpEntry->pInstrument, pdwPatch);
- if (pwszName) {
- dwLen = min(strlenW(pInstrument->wszName),dwNameLen-1);
- memcpy (pwszName, pInstrument->wszName, dwLen * sizeof(WCHAR));
- pwszName[dwLen] = '\0';
- }
- return S_OK;
- }
- r++;
- }
-
- return S_FALSE;
+static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_EnumInstrument(LPDIRECTMUSICCOLLECTION iface, DWORD index, DWORD* patch, LPWSTR name, DWORD name_length)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicCollection(iface);
+ DWORD i = 0;
+ DMUS_PRIVATE_INSTRUMENTENTRY *inst_entry;
+ struct list *list_entry;
+ DWORD length;
+
+ TRACE("(%p/%p)->(%d, %p, %p, %d)\n", iface, This, index, patch, name, name_length);
+
+ LIST_FOR_EACH(list_entry, &This->Instruments) {
+ inst_entry = LIST_ENTRY(list_entry, DMUS_PRIVATE_INSTRUMENTENTRY, entry);
+ if (i == index) {
+ IDirectMusicInstrumentImpl *instrument = impl_from_IDirectMusicInstrument(inst_entry->pInstrument);
+ IDirectMusicInstrument_GetPatch(inst_entry->pInstrument, patch);
+ if (name) {
+ length = min(strlenW(instrument->wszName), name_length - 1);
+ memcpy(name, instrument->wszName, length * sizeof(WCHAR));
+ name[length] = '\0';
+ }
+ return S_OK;
+ }
+ i++;
+ }
+
+ return S_FALSE;
}
static const IDirectMusicCollectionVtbl DirectMusicCollection_Collection_Vtbl = {
};
/* IDirectMusicCollectionImpl IDirectMusicObject part: */
-static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, ObjectVtbl, iface);
- return IDirectMusicCollectionImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
+static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_QueryInterface(LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ret_iface)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicObject(iface);
+ return IDirectMusicCollection_QueryInterface(&This->IDirectMusicCollection_iface, riid, ret_iface);
}
-static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, ObjectVtbl, iface);
- return IDirectMusicCollectionImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
+static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_AddRef(LPDIRECTMUSICOBJECT iface)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicObject(iface);
+ return IDirectMusicCollection_AddRef(&This->IDirectMusicCollection_iface);
}
-static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, ObjectVtbl, iface);
- return IDirectMusicCollectionImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
+static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_Release(LPDIRECTMUSICOBJECT iface)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicObject(iface);
+ return IDirectMusicCollection_Release(&This->IDirectMusicCollection_iface);
}
-static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, ObjectVtbl, iface);
- TRACE("(%p, %p)\n", This, pDesc);
- /* I think we shouldn't return pointer here since then values can be changed; it'd be a mess */
- memcpy (pDesc, This->pDesc, This->pDesc->dwSize);
- return S_OK;
+static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_GetDescriptor(LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicObject(iface);
+
+ TRACE("(%p/%p)->(%p)\n", iface, This, pDesc);
+
+ /* I think we shouldn't return pointer here since then values can be changed; it'd be a mess */
+ memcpy (pDesc, This->pDesc, This->pDesc->dwSize);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, ObjectVtbl, iface);
- TRACE("(%p, %p): setting descriptor:\n%s\n", This, pDesc, debugstr_DMUS_OBJECTDESC (pDesc));
+static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_SetDescriptor(LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicObject(iface);
+
+ TRACE("(%p, %p)\n", iface, pDesc);
+
+ if (!pDesc)
+ return E_POINTER;
+
+ if (TRACE_ON(dmusic))
+ {
+ TRACE("Setting descriptor:\n");
+ dump_DMUS_OBJECTDESC(pDesc);
+ }
/* According to MSDN, we should copy only given values, not whole struct */
if (pDesc->dwValidData & DMUS_OBJ_OBJECT)
return S_OK;
}
-static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, ObjectVtbl, iface);
- DMUS_PRIVATE_CHUNK Chunk;
- DWORD StreamSize, StreamCount, ListSize[1], ListCount[1];
- LARGE_INTEGER liMove; /* used when skipping chunks */
-
- TRACE("(%p, %p, %p)\n", This, pStream, pDesc);
-
- /* FIXME: should this be determined from stream? */
- pDesc->dwValidData |= DMUS_OBJ_CLASS;
- pDesc->guidClass = CLSID_DirectMusicCollection;
-
- IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_RIFF: {
- IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
- TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
- StreamSize = Chunk.dwSize - sizeof(FOURCC);
- StreamCount = 0;
- if (Chunk.fccID == mmioFOURCC('D','L','S',' ')) {
- TRACE_(dmfile)(": collection form\n");
- do {
- IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_DLID: {
- TRACE_(dmfile)(": GUID chunk\n");
- pDesc->dwValidData |= DMUS_OBJ_OBJECT;
- IStream_Read (pStream, &pDesc->guidObject, Chunk.dwSize, NULL);
- break;
- }
- case DMUS_FOURCC_VERSION_CHUNK: {
- TRACE_(dmfile)(": version chunk\n");
- pDesc->dwValidData |= DMUS_OBJ_VERSION;
- IStream_Read (pStream, &pDesc->vVersion, Chunk.dwSize, NULL);
- break;
- }
- case DMUS_FOURCC_CATEGORY_CHUNK: {
- TRACE_(dmfile)(": category chunk\n");
- pDesc->dwValidData |= DMUS_OBJ_CATEGORY;
- IStream_Read (pStream, pDesc->wszCategory, Chunk.dwSize, NULL);
- break;
- }
- case FOURCC_LIST: {
- IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
- TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
- ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
- ListCount[0] = 0;
- switch (Chunk.fccID) {
- /* pure INFO list, such can be found in dls collections */
- case mmioFOURCC('I','N','F','O'): {
- TRACE_(dmfile)(": INFO list\n");
- do {
- IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case mmioFOURCC('I','N','A','M'):{
- CHAR szName[DMUS_MAX_NAME];
- TRACE_(dmfile)(": name chunk\n");
- pDesc->dwValidData |= DMUS_OBJ_NAME;
- IStream_Read (pStream, szName, Chunk.dwSize, NULL);
- MultiByteToWideChar (CP_ACP, 0, szName, -1, pDesc->wszName, DMUS_MAX_NAME);
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- liMove.QuadPart = 1;
- IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
- }
- break;
- }
- case mmioFOURCC('I','A','R','T'): {
- TRACE_(dmfile)(": artist chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- case mmioFOURCC('I','C','O','P'): {
- TRACE_(dmfile)(": copyright chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- case mmioFOURCC('I','S','B','J'): {
- TRACE_(dmfile)(": subject chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- case mmioFOURCC('I','C','M','T'): {
- TRACE_(dmfile)(": comment chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
- } while (ListCount[0] < ListSize[0]);
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown (skipping)\n");
- liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
- IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
- } while (StreamCount < StreamSize);
- } else {
- TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
- liMove.QuadPart = StreamSize;
- IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
- return E_FAIL;
- }
-
- TRACE_(dmfile)(": reading finished\n");
- break;
- }
- default: {
- TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
- return DMUS_E_INVALIDFILE;
- }
- }
-
- TRACE(": returning descriptor:\n%s\n", debugstr_DMUS_OBJECTDESC (pDesc));
-
- return S_OK;
+static HRESULT read_from_stream(IStream *stream, void *data, ULONG size)
+{
+ ULONG read;
+ HRESULT hr;
+
+ hr = IStream_Read(stream, data, size, &read);
+ if (FAILED(hr)) {
+ TRACE("IStream_Read failed: %08x\n", hr);
+ return hr;
+ }
+ if (read < size) {
+ TRACE("Didn't read full chunk: %u < %u\n", read, size);
+ return E_FAIL;
+ }
+
+ return S_OK;
+}
+
+static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_ParseDescriptor(LPDIRECTMUSICOBJECT iface, LPSTREAM stream, LPDMUS_OBJECTDESC desc)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicObject(iface);
+ DMUS_PRIVATE_CHUNK chunk;
+ DWORD StreamSize, StreamCount, ListSize[1], ListCount[1];
+ LARGE_INTEGER liMove; /* used when skipping chunks */
+ HRESULT hr;
+
+ TRACE("(%p)->(%p, %p)\n", This, stream, desc);
+
+ /* FIXME: should this be determined from stream? */
+ desc->dwValidData |= DMUS_OBJ_CLASS;
+ desc->guidClass = CLSID_DirectMusicCollection;
+
+ hr = read_from_stream(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD));
+ if (FAILED(hr))
+ return hr;
+ TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+
+ if (chunk.fccID != FOURCC_RIFF) {
+ TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
+ return DMUS_E_INVALIDFILE;
+ }
+
+ hr = read_from_stream(stream, &chunk.fccID, sizeof(FOURCC));
+ if (FAILED(hr))
+ return hr;
+ TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(chunk.fccID));
+ StreamSize = chunk.dwSize - sizeof(FOURCC);
+
+ if (chunk.fccID != mmioFOURCC('D','L','S',' ')) {
+ TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
+ liMove.QuadPart = StreamSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
+ return E_FAIL;
+ }
+
+ StreamCount = 0;
+ TRACE_(dmfile)(": collection form\n");
+
+ do {
+ hr = read_from_stream(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD));
+ if (FAILED(hr))
+ return hr;
+ StreamCount += sizeof(FOURCC) + sizeof(DWORD) + chunk.dwSize;
+ TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+ switch (chunk.fccID) {
+ case FOURCC_DLID:
+ TRACE_(dmfile)(": GUID chunk\n");
+ desc->dwValidData |= DMUS_OBJ_OBJECT;
+ hr = read_from_stream(stream, &desc->guidObject, chunk.dwSize);
+ if (FAILED(hr))
+ return hr;
+ break;
+
+ case DMUS_FOURCC_VERSION_CHUNK:
+ TRACE_(dmfile)(": version chunk\n");
+ desc->dwValidData |= DMUS_OBJ_VERSION;
+ hr = read_from_stream(stream, &desc->vVersion, chunk.dwSize);
+ if (FAILED(hr))
+ return hr;
+ break;
+
+ case DMUS_FOURCC_CATEGORY_CHUNK:
+ TRACE_(dmfile)(": category chunk\n");
+ desc->dwValidData |= DMUS_OBJ_CATEGORY;
+ hr = read_from_stream(stream, desc->wszCategory, chunk.dwSize);
+ if (FAILED(hr))
+ return hr;
+ break;
+
+ case FOURCC_LIST:
+ hr = read_from_stream(stream, &chunk.fccID, sizeof(FOURCC));
+ if (FAILED(hr))
+ return hr;
+ TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunk.fccID));
+ ListSize[0] = chunk.dwSize - sizeof(FOURCC);
+ ListCount[0] = 0;
+ switch (chunk.fccID) {
+ /* pure INFO list, such can be found in dls collections */
+ case mmioFOURCC('I','N','F','O'):
+ TRACE_(dmfile)(": INFO list\n");
+ do {
+ hr = read_from_stream(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD));
+ if (FAILED(hr))
+ return hr;
+ ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunk.dwSize;
+ TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+ switch (chunk.fccID) {
+ case mmioFOURCC('I','N','A','M'): {
+ CHAR szName[DMUS_MAX_NAME];
+ TRACE_(dmfile)(": name chunk\n");
+ desc->dwValidData |= DMUS_OBJ_NAME;
+ hr = read_from_stream(stream, szName, chunk.dwSize);
+ if (FAILED(hr))
+ return hr;
+ MultiByteToWideChar (CP_ACP, 0, szName, -1, desc->wszName, DMUS_MAX_NAME);
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ liMove.QuadPart = 1;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ }
+ break;
+ }
+
+ case mmioFOURCC('I','A','R','T'):
+ TRACE_(dmfile)(": artist chunk (ignored)\n");
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ chunk.dwSize++;
+ }
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+
+ case mmioFOURCC('I','C','O','P'):
+ TRACE_(dmfile)(": copyright chunk (ignored)\n");
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ chunk.dwSize++;
+ }
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+
+ case mmioFOURCC('I','S','B','J'):
+ TRACE_(dmfile)(": subject chunk (ignored)\n");
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ chunk.dwSize++;
+ }
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+
+ case mmioFOURCC('I','C','M','T'):
+ TRACE_(dmfile)(": comment chunk (ignored)\n");
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ chunk.dwSize++;
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+
+ default:
+ TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0] ++;
+ chunk.dwSize++;
+ }
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
+ } while (ListCount[0] < ListSize[0]);
+ break;
+
+ default:
+ TRACE_(dmfile)(": unknown (skipping)\n");
+ liMove.QuadPart = chunk.dwSize - sizeof(FOURCC);
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ break;
+
+ default:
+ TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
+ } while (StreamCount < StreamSize);
+
+ TRACE_(dmfile)(": reading finished\n");
+
+ if (TRACE_ON(dmusic)) {
+ TRACE("Returning descriptor:\n");
+ dump_DMUS_OBJECTDESC(desc);
+ }
+
+ return S_OK;
}
static const IDirectMusicObjectVtbl DirectMusicCollection_Object_Vtbl = {
};
/* IDirectMusicCollectionImpl IPersistStream part: */
-static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, PersistStreamVtbl, iface);
- return IDirectMusicCollectionImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
+static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_QueryInterface(LPPERSISTSTREAM iface, REFIID riid, LPVOID *ret_iface)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IPersistStream(iface);
+ return IDirectMusicCollection_QueryInterface(&This->IDirectMusicCollection_iface, riid, ret_iface);
}
-static ULONG WINAPI IDirectMusicCollectionImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, PersistStreamVtbl, iface);
- return IDirectMusicCollectionImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
+static ULONG WINAPI IDirectMusicCollectionImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IPersistStream(iface);
+ return IDirectMusicCollection_AddRef(&This->IDirectMusicCollection_iface);
}
-static ULONG WINAPI IDirectMusicCollectionImpl_IPersistStream_Release (LPPERSISTSTREAM iface) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, PersistStreamVtbl, iface);
- return IDirectMusicCollectionImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
+static ULONG WINAPI IDirectMusicCollectionImpl_IPersistStream_Release (LPPERSISTSTREAM iface)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IPersistStream(iface);
+ return IDirectMusicCollection_Release(&This->IDirectMusicCollection_iface);
}
-static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
- return E_NOTIMPL;
+static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_GetClassID(LPPERSISTSTREAM iface, CLSID* pClassID)
+{
+ return E_NOTIMPL;
}
-static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
- return E_NOTIMPL;
+static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_IsDirty(LPPERSISTSTREAM iface)
+{
+ return E_NOTIMPL;
}
-static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, PersistStreamVtbl, iface);
-
- DMUS_PRIVATE_CHUNK Chunk;
- DWORD StreamSize, StreamCount, ListSize[3], ListCount[3];
- LARGE_INTEGER liMove; /* used when skipping chunks */
- ULARGE_INTEGER dlibCollectionPosition, dlibInstrumentPosition, dlibWavePoolPosition;
-
- IStream_AddRef (pStm); /* add count for later references */
- liMove.QuadPart = 0;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, &dlibCollectionPosition); /* store offset, in case it'll be needed later */
- This->liCollectionPosition.QuadPart = dlibCollectionPosition.QuadPart;
- This->pStm = pStm;
-
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_RIFF: {
- IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
- TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
- StreamSize = Chunk.dwSize - sizeof(FOURCC);
- StreamCount = 0;
- switch (Chunk.fccID) {
- case FOURCC_DLS: {
- TRACE_(dmfile)(": collection form\n");
- do {
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_COLH: {
- TRACE_(dmfile)(": collection header chunk\n");
- This->pHeader = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize);
- IStream_Read (pStm, This->pHeader, Chunk.dwSize, NULL);
- break;
- }
- case FOURCC_DLID: {
- TRACE_(dmfile)(": DLID (GUID) chunk\n");
- This->pDesc->dwValidData |= DMUS_OBJ_OBJECT;
- IStream_Read (pStm, &This->pDesc->guidObject, Chunk.dwSize, NULL);
- break;
- }
- case FOURCC_VERS: {
- TRACE_(dmfile)(": version chunk\n");
- This->pDesc->dwValidData |= DMUS_OBJ_VERSION;
- IStream_Read (pStm, &This->pDesc->vVersion, Chunk.dwSize, NULL);
- break;
- }
- case FOURCC_PTBL: {
- TRACE_(dmfile)(": pool table chunk\n");
- This->pPoolTable = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(POOLTABLE));
- IStream_Read (pStm, This->pPoolTable, sizeof(POOLTABLE), NULL);
- Chunk.dwSize -= sizeof(POOLTABLE);
- This->pPoolCues = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, This->pPoolTable->cCues*sizeof(POOLCUE));
- IStream_Read (pStm, This->pPoolCues, Chunk.dwSize, NULL);
- break;
- }
- case FOURCC_LIST: {
- IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
- TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
- ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
- ListCount[0] = 0;
- switch (Chunk.fccID) {
- case mmioFOURCC('I','N','F','O'): {
- TRACE_(dmfile)(": INFO list\n");
- do {
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case mmioFOURCC('I','N','A','M'): {
- CHAR szName[DMUS_MAX_NAME];
- TRACE_(dmfile)(": name chunk\n");
- This->pDesc->dwValidData |= DMUS_OBJ_NAME;
- IStream_Read (pStm, szName, Chunk.dwSize, NULL);
- MultiByteToWideChar (CP_ACP, 0, szName, -1, This->pDesc->wszName, DMUS_MAX_NAME);
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- liMove.QuadPart = 1;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- }
- break;
- }
- case mmioFOURCC('I','A','R','T'): {
- TRACE_(dmfile)(": artist chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- case mmioFOURCC('I','C','O','P'): {
- TRACE_(dmfile)(": copyright chunk\n");
- This->szCopyright = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize);
- IStream_Read (pStm, This->szCopyright, Chunk.dwSize, NULL);
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- liMove.QuadPart = 1;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- }
- break;
- }
- case mmioFOURCC('I','S','B','J'): {
- TRACE_(dmfile)(": subject chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- case mmioFOURCC('I','C','M','T'): {
- TRACE_(dmfile)(": comment chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
- } while (ListCount[0] < ListSize[0]);
- break;
- }
- case FOURCC_WVPL: {
- TRACE_(dmfile)(": wave pool list (mark & skip)\n");
- liMove.QuadPart = 0;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, &dlibWavePoolPosition); /* store position */
- This->liWavePoolTablePosition.QuadPart = dlibWavePoolPosition.QuadPart;
- liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- case FOURCC_LINS: {
- TRACE_(dmfile)(": instruments list\n");
- do {
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_LIST: {
- IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
- TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
- ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
- ListCount[1] = 0;
- switch (Chunk.fccID) {
- case FOURCC_INS: {
- LPDMUS_PRIVATE_INSTRUMENTENTRY pNewInstrument = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_INSTRUMENTENTRY));
- TRACE_(dmfile)(": instrument list\n");
- DMUSIC_CreateDirectMusicInstrumentImpl (&IID_IDirectMusicInstrument, (LPVOID*)&pNewInstrument->pInstrument, NULL); /* only way to create this one... even M$ does it discretely */
- {
- ICOM_NAME_MULTI (IDirectMusicInstrumentImpl, InstrumentVtbl, pNewInstrument->pInstrument, pInstrument);
- liMove.QuadPart = 0;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, &dlibInstrumentPosition);
- pInstrument->liInstrumentPosition.QuadPart = dlibInstrumentPosition.QuadPart - (2*sizeof(FOURCC) + sizeof(DWORD)); /* store offset, it'll be needed later */
-
- do {
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_INSH: {
- TRACE_(dmfile)(": instrument header chunk\n");
- pInstrument->pHeader = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize);
- IStream_Read (pStm, pInstrument->pHeader, Chunk.dwSize, NULL);
- break;
- }
- case FOURCC_DLID: {
- TRACE_(dmfile)(": DLID (GUID) chunk\n");
- pInstrument->pInstrumentID = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize);
- IStream_Read (pStm, pInstrument->pInstrumentID, Chunk.dwSize, NULL);
- break;
- }
- case FOURCC_LIST: {
- IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
- TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
- ListSize[2] = Chunk.dwSize - sizeof(FOURCC);
- ListCount[2] = 0;
- switch (Chunk.fccID) {
- default: {
- TRACE_(dmfile)(": unknown (skipping)\n");
- liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": ListCount[1] = %d < ListSize[1] = %d\n", ListCount[1], ListSize[1]);
- } while (ListCount[1] < ListSize[1]);
- /* DEBUG: dumps whole instrument object tree: */
- if (TRACE_ON(dmusic)) {
- TRACE("*** IDirectMusicInstrument (%p) ***\n", pInstrument);
- if (pInstrument->pInstrumentID)
- TRACE(" - GUID = %s\n", debugstr_dmguid(pInstrument->pInstrumentID));
-
- TRACE(" - Instrument header:\n");
- TRACE(" - cRegions: %d\n", pInstrument->pHeader->cRegions);
- TRACE(" - Locale:\n");
- TRACE(" - ulBank: %d\n", pInstrument->pHeader->Locale.ulBank);
- TRACE(" - ulInstrument: %d\n", pInstrument->pHeader->Locale.ulInstrument);
- TRACE(" => dwPatch: %d\n", MIDILOCALE2Patch(&pInstrument->pHeader->Locale));
- }
- list_add_tail (&This->Instruments, &pNewInstrument->entry);
- }
- break;
- }
- }
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
- } while (ListCount[0] < ListSize[0]);
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown (skipping)\n");
- liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": StreamCount = %d < StreamSize = %d\n", StreamCount, StreamSize);
- } while (StreamCount < StreamSize);
- break;
- }
- default: {
- TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
- liMove.QuadPart = StreamSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
- return E_FAIL;
- }
- }
- TRACE_(dmfile)(": reading finished\n");
- break;
- }
- default: {
- TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
- return E_FAIL;
- }
- }
-
- /* DEBUG: dumps whole collection object tree: */
- if (TRACE_ON(dmusic)) {
- int r = 0;
- DMUS_PRIVATE_INSTRUMENTENTRY *tmpEntry;
- struct list *listEntry;
-
- TRACE("*** IDirectMusicCollection (%p) ***\n", This->CollectionVtbl);
- if (This->pDesc->dwValidData & DMUS_OBJ_OBJECT)
- TRACE(" - GUID = %s\n", debugstr_dmguid(&This->pDesc->guidObject));
- if (This->pDesc->dwValidData & DMUS_OBJ_VERSION)
- TRACE(" - Version = %i,%i,%i,%i\n", (This->pDesc->vVersion.dwVersionMS >> 8) & 0x0000FFFF, This->pDesc->vVersion.dwVersionMS & 0x0000FFFF,
- (This->pDesc->vVersion.dwVersionLS >> 8) & 0x0000FFFF, This->pDesc->vVersion.dwVersionLS & 0x0000FFFF);
- if (This->pDesc->dwValidData & DMUS_OBJ_NAME)
- TRACE(" - Name = %s\n", debugstr_w(This->pDesc->wszName));
-
- TRACE(" - Collection header:\n");
- TRACE(" - cInstruments: %d\n", This->pHeader->cInstruments);
- TRACE(" - Instruments:\n");
-
- LIST_FOR_EACH (listEntry, &This->Instruments) {
- tmpEntry = LIST_ENTRY( listEntry, DMUS_PRIVATE_INSTRUMENTENTRY, entry );
- TRACE(" - Instrument[%i]: %p\n", r, tmpEntry->pInstrument);
- r++;
- }
- }
-
- return S_OK;
+static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Load(LPPERSISTSTREAM iface, IStream* stream)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IPersistStream(iface);
+ DMUS_PRIVATE_CHUNK chunk;
+ DWORD StreamSize, StreamCount, ListSize[2], ListCount[2];
+ LARGE_INTEGER liMove; /* used when skipping chunks */
+ ULARGE_INTEGER dlibCollectionPosition, dlibInstrumentPosition, dlibWavePoolPosition;
+
+ IStream_AddRef(stream); /* add count for later references */
+ liMove.QuadPart = 0;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, &dlibCollectionPosition); /* store offset, in case it'll be needed later */
+ This->liCollectionPosition.QuadPart = dlibCollectionPosition.QuadPart;
+ This->pStm = stream;
+
+ IStream_Read(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD), NULL);
+ TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+
+ if (chunk.fccID != FOURCC_RIFF) {
+ TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
+ return E_FAIL;
+ }
+
+ IStream_Read(stream, &chunk.fccID, sizeof(FOURCC), NULL);
+ TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(chunk.fccID));
+ StreamSize = chunk.dwSize - sizeof(FOURCC);
+ StreamCount = 0;
+
+ if (chunk.fccID != FOURCC_DLS) {
+ TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
+ liMove.QuadPart = StreamSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
+ return E_FAIL;
+ }
+
+ TRACE_(dmfile)(": collection form\n");
+ do {
+ IStream_Read(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD), NULL);
+ StreamCount += sizeof(FOURCC) + sizeof(DWORD) + chunk.dwSize;
+ TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+ switch (chunk.fccID) {
+ case FOURCC_COLH: {
+ TRACE_(dmfile)(": collection header chunk\n");
+ This->pHeader = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, chunk.dwSize);
+ IStream_Read(stream, This->pHeader, chunk.dwSize, NULL);
+ break;
+ }
+ case FOURCC_DLID: {
+ TRACE_(dmfile)(": DLID (GUID) chunk\n");
+ This->pDesc->dwValidData |= DMUS_OBJ_OBJECT;
+ IStream_Read(stream, &This->pDesc->guidObject, chunk.dwSize, NULL);
+ break;
+ }
+ case FOURCC_VERS: {
+ TRACE_(dmfile)(": version chunk\n");
+ This->pDesc->dwValidData |= DMUS_OBJ_VERSION;
+ IStream_Read(stream, &This->pDesc->vVersion, chunk.dwSize, NULL);
+ break;
+ }
+ case FOURCC_PTBL: {
+ TRACE_(dmfile)(": pool table chunk\n");
+ This->pPoolTable = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(POOLTABLE));
+ IStream_Read(stream, This->pPoolTable, sizeof(POOLTABLE), NULL);
+ chunk.dwSize -= sizeof(POOLTABLE);
+ This->pPoolCues = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->pPoolTable->cCues * sizeof(POOLCUE));
+ IStream_Read(stream, This->pPoolCues, chunk.dwSize, NULL);
+ break;
+ }
+ case FOURCC_LIST: {
+ IStream_Read(stream, &chunk.fccID, sizeof(FOURCC), NULL);
+ TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunk.fccID));
+ ListSize[0] = chunk.dwSize - sizeof(FOURCC);
+ ListCount[0] = 0;
+ switch (chunk.fccID) {
+ case mmioFOURCC('I','N','F','O'): {
+ TRACE_(dmfile)(": INFO list\n");
+ do {
+ IStream_Read(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD), NULL);
+ ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunk.dwSize;
+ TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+ switch (chunk.fccID) {
+ case mmioFOURCC('I','N','A','M'): {
+ CHAR szName[DMUS_MAX_NAME];
+ TRACE_(dmfile)(": name chunk\n");
+ This->pDesc->dwValidData |= DMUS_OBJ_NAME;
+ IStream_Read(stream, szName, chunk.dwSize, NULL);
+ MultiByteToWideChar(CP_ACP, 0, szName, -1, This->pDesc->wszName, DMUS_MAX_NAME);
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ liMove.QuadPart = 1;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ }
+ break;
+ }
+ case mmioFOURCC('I','A','R','T'): {
+ TRACE_(dmfile)(": artist chunk (ignored)\n");
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ chunk.dwSize++;
+ }
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ case mmioFOURCC('I','C','O','P'): {
+ TRACE_(dmfile)(": copyright chunk\n");
+ This->szCopyright = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, chunk.dwSize);
+ IStream_Read(stream, This->szCopyright, chunk.dwSize, NULL);
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ liMove.QuadPart = 1;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ }
+ break;
+ }
+ case mmioFOURCC('I','S','B','J'): {
+ TRACE_(dmfile)(": subject chunk (ignored)\n");
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ chunk.dwSize++;
+ }
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ case mmioFOURCC('I','C','M','T'): {
+ TRACE_(dmfile)(": comment chunk (ignored)\n");
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ chunk.dwSize++;
+ }
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ default: {
+ TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ chunk.dwSize++;
+ }
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ }
+ TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
+ } while (ListCount[0] < ListSize[0]);
+ break;
+ }
+ case FOURCC_WVPL: {
+ TRACE_(dmfile)(": wave pool list (mark & skip)\n");
+ liMove.QuadPart = 0;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, &dlibWavePoolPosition); /* store position */
+ This->liWavePoolTablePosition.QuadPart = dlibWavePoolPosition.QuadPart;
+ liMove.QuadPart = chunk.dwSize - sizeof(FOURCC);
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ case FOURCC_LINS: {
+ TRACE_(dmfile)(": instruments list\n");
+ do {
+ IStream_Read(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD), NULL);
+ ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunk.dwSize;
+ TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+ switch (chunk.fccID) {
+ case FOURCC_LIST: {
+ IStream_Read(stream, &chunk.fccID, sizeof(FOURCC), NULL);
+ TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunk.fccID));
+ ListSize[1] = chunk.dwSize - sizeof(FOURCC);
+ ListCount[1] = 0;
+ switch (chunk.fccID) {
+ case FOURCC_INS: {
+ LPDMUS_PRIVATE_INSTRUMENTENTRY new_instrument = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_INSTRUMENTENTRY));
+ TRACE_(dmfile)(": instrument list\n");
+ /* Only way to create this one... even M$ does it discretely */
+ DMUSIC_CreateDirectMusicInstrumentImpl(&IID_IDirectMusicInstrument, (void**)&new_instrument->pInstrument, NULL);
+ {
+ IDirectMusicInstrumentImpl *instrument = impl_from_IDirectMusicInstrument(new_instrument->pInstrument);
+ /* Store offset and length, they will be needed when loading the instrument */
+ liMove.QuadPart = 0;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, &dlibInstrumentPosition);
+ instrument->liInstrumentPosition.QuadPart = dlibInstrumentPosition.QuadPart;
+ instrument->length = ListSize[1];
+ do {
+ IStream_Read(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD), NULL);
+ ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + chunk.dwSize;
+ TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+ switch (chunk.fccID) {
+ case FOURCC_INSH: {
+ TRACE_(dmfile)(": instrument header chunk\n");
+ IStream_Read(stream, &instrument->header, chunk.dwSize, NULL);
+ break;
+ }
+ case FOURCC_DLID: {
+ TRACE_(dmfile)(": DLID (GUID) chunk\n");
+ IStream_Read(stream, &instrument->id, chunk.dwSize, NULL);
+ break;
+ }
+ case FOURCC_LIST: {
+ IStream_Read(stream, &chunk.fccID, sizeof(FOURCC), NULL);
+ TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunk.fccID));
+ switch (chunk.fccID) {
+ default: {
+ TRACE_(dmfile)(": unknown (skipping)\n");
+ liMove.QuadPart = chunk.dwSize - sizeof(FOURCC);
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ }
+ break;
+ }
+ default: {
+ TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ }
+ TRACE_(dmfile)(": ListCount[1] = %d < ListSize[1] = %d\n", ListCount[1], ListSize[1]);
+ } while (ListCount[1] < ListSize[1]);
+ /* DEBUG: dumps whole instrument object tree: */
+ if (TRACE_ON(dmusic)) {
+ TRACE("*** IDirectMusicInstrument (%p) ***\n", instrument);
+ if (!IsEqualGUID(&instrument->id, &GUID_NULL))
+ TRACE(" - GUID = %s\n", debugstr_dmguid(&instrument->id));
+ TRACE(" - Instrument header:\n");
+ TRACE(" - cRegions: %d\n", instrument->header.cRegions);
+ TRACE(" - Locale:\n");
+ TRACE(" - ulBank: %d\n", instrument->header.Locale.ulBank);
+ TRACE(" - ulInstrument: %d\n", instrument->header.Locale.ulInstrument);
+ TRACE(" => dwPatch: %d\n", MIDILOCALE2Patch(&instrument->header.Locale));
+ }
+ list_add_tail(&This->Instruments, &new_instrument->entry);
+ }
+ break;
+ }
+ }
+ break;
+ }
+ default: {
+ TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ }
+ TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
+ } while (ListCount[0] < ListSize[0]);
+ break;
+ }
+ default: {
+ TRACE_(dmfile)(": unknown (skipping)\n");
+ liMove.QuadPart = chunk.dwSize - sizeof(FOURCC);
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ }
+ break;
+ }
+ default: {
+ TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ }
+ TRACE_(dmfile)(": StreamCount = %d < StreamSize = %d\n", StreamCount, StreamSize);
+ } while (StreamCount < StreamSize);
+
+ TRACE_(dmfile)(": reading finished\n");
+
+
+ /* DEBUG: dumps whole collection object tree: */
+ if (TRACE_ON(dmusic)) {
+ int r = 0;
+ DMUS_PRIVATE_INSTRUMENTENTRY *tmpEntry;
+ struct list *listEntry;
+
+ TRACE("*** IDirectMusicCollection (%p) ***\n", &This->IDirectMusicCollection_iface);
+ if (This->pDesc->dwValidData & DMUS_OBJ_OBJECT)
+ TRACE(" - GUID = %s\n", debugstr_dmguid(&This->pDesc->guidObject));
+ if (This->pDesc->dwValidData & DMUS_OBJ_VERSION)
+ TRACE(" - Version = %i,%i,%i,%i\n", (This->pDesc->vVersion.dwVersionMS >> 8) & 0x0000FFFF, This->pDesc->vVersion.dwVersionMS & 0x0000FFFF,
+ (This->pDesc->vVersion.dwVersionLS >> 8) & 0x0000FFFF, This->pDesc->vVersion.dwVersionLS & 0x0000FFFF);
+ if (This->pDesc->dwValidData & DMUS_OBJ_NAME)
+ TRACE(" - Name = %s\n", debugstr_w(This->pDesc->wszName));
+
+ TRACE(" - Collection header:\n");
+ TRACE(" - cInstruments: %d\n", This->pHeader->cInstruments);
+ TRACE(" - Instruments:\n");
+
+ LIST_FOR_EACH(listEntry, &This->Instruments) {
+ tmpEntry = LIST_ENTRY( listEntry, DMUS_PRIVATE_INSTRUMENTENTRY, entry );
+ TRACE(" - Instrument[%i]: %p\n", r, tmpEntry->pInstrument);
+ r++;
+ }
+ }
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
- return E_NOTIMPL;
+static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Save(LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty)
+{
+ return E_NOTIMPL;
}
-static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
- return E_NOTIMPL;
+static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_GetSizeMax(LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize)
+{
+ return E_NOTIMPL;
}
static const IPersistStreamVtbl DirectMusicCollection_PersistStream_Vtbl = {
/* for ClassFactory */
-HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
+HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl(LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter)
+{
IDirectMusicCollectionImpl* obj;
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicCollectionImpl));
*ppobj = NULL;
return E_OUTOFMEMORY;
}
- obj->UnknownVtbl = &DirectMusicCollection_Unknown_Vtbl;
- obj->CollectionVtbl = &DirectMusicCollection_Collection_Vtbl;
- obj->ObjectVtbl = &DirectMusicCollection_Object_Vtbl;
- obj->PersistStreamVtbl = &DirectMusicCollection_PersistStream_Vtbl;
+ obj->IDirectMusicCollection_iface.lpVtbl = &DirectMusicCollection_Collection_Vtbl;
+ obj->IDirectMusicObject_iface.lpVtbl = &DirectMusicCollection_Object_Vtbl;
+ obj->IPersistStream_iface.lpVtbl = &DirectMusicCollection_PersistStream_Vtbl;
obj->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
DM_STRUCT_INIT(obj->pDesc);
obj->pDesc->dwValidData |= DMUS_OBJ_CLASS;
obj->ref = 0; /* will be inited by QueryInterface */
list_init (&obj->Instruments);
- return IDirectMusicCollectionImpl_IUnknown_QueryInterface ((LPUNKNOWN)&obj->UnknownVtbl, lpcGUID, ppobj);
+ return IDirectMusicCollection_QueryInterface(&obj->IDirectMusicCollection_iface, lpcGUID, ppobj);
}
-/* IDirectMusic8 Implementation
+/*
+ * IDirectMusic8 Implementation
*
* Copyright (C) 2003-2004 Rok Mandeljc
+ * Copyright (C) 2012 Christian Costa
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+
+//#include <stdio.h>
+
#include "dmusic_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+static inline IDirectMusic8Impl *impl_from_IDirectMusic8(IDirectMusic8 *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectMusic8Impl, IDirectMusic8_iface);
+}
+
/* IDirectMusic8Impl IUnknown part: */
-static HRESULT WINAPI IDirectMusic8Impl_QueryInterface (LPDIRECTMUSIC8 iface, REFIID riid, LPVOID *ppobj) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
-
- if (IsEqualIID (riid, &IID_IUnknown) ||
- IsEqualIID (riid, &IID_IDirectMusic) ||
- IsEqualIID (riid, &IID_IDirectMusic2) ||
- IsEqualIID (riid, &IID_IDirectMusic8)) {
- IUnknown_AddRef(iface);
- *ppobj = This;
- return S_OK;
- }
-
- WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
- return E_NOINTERFACE;
+static HRESULT WINAPI IDirectMusic8Impl_QueryInterface(LPDIRECTMUSIC8 iface, REFIID riid, LPVOID *ret_iface)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
+
+ TRACE("(%p)->(%s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
+
+ if (IsEqualIID (riid, &IID_IUnknown) ||
+ IsEqualIID (riid, &IID_IDirectMusic) ||
+ IsEqualIID (riid, &IID_IDirectMusic2) ||
+ IsEqualIID (riid, &IID_IDirectMusic8))
+ {
+ IDirectMusic8_AddRef(iface);
+ *ret_iface = iface;
+ return S_OK;
+ }
+
+ *ret_iface = NULL;
+
+ WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);
+
+ return E_NOINTERFACE;
}
-static ULONG WINAPI IDirectMusic8Impl_AddRef (LPDIRECTMUSIC8 iface) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- ULONG refCount = InterlockedIncrement(&This->ref);
+static ULONG WINAPI IDirectMusic8Impl_AddRef(LPDIRECTMUSIC8 iface)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
+ ULONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
+ TRACE("(%p)->(): new ref = %u\n", This, ref);
- DMUSIC_LockModule();
+ DMUSIC_LockModule();
- return refCount;
+ return ref;
}
-static ULONG WINAPI IDirectMusic8Impl_Release (LPDIRECTMUSIC8 iface) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- ULONG refCount = InterlockedDecrement(&This->ref);
+static ULONG WINAPI IDirectMusic8Impl_Release(LPDIRECTMUSIC8 iface)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
+ ULONG ref = InterlockedDecrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
+ TRACE("(%p)->(): new ref = %u\n", This, ref);
- if (!refCount) {
- HeapFree(GetProcessHeap(), 0, This);
- }
+ if (!ref) {
+ HeapFree(GetProcessHeap(), 0, This->system_ports);
+ HeapFree(GetProcessHeap(), 0, This->ppPorts);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
- DMUSIC_UnlockModule();
-
- return refCount;
+ DMUSIC_UnlockModule();
+
+ return ref;
}
/* IDirectMusic8Impl IDirectMusic part: */
-static HRESULT WINAPI IDirectMusic8Impl_EnumPort(LPDIRECTMUSIC8 iface, DWORD dwIndex, LPDMUS_PORTCAPS pPortCaps) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- TRACE("(%p, %d, %p)\n", This, dwIndex, pPortCaps);
- if (NULL == pPortCaps) { return E_POINTER; }
- /* i guess the first port shown is always software synthesizer */
- if (dwIndex == 0)
- {
- IDirectMusicSynth8* synth;
- TRACE("enumerating 'Microsoft Software Synthesizer' port\n");
- CoCreateInstance (&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynth8, (void**)&synth);
- IDirectMusicSynth8_GetPortCaps (synth, pPortCaps);
- IDirectMusicSynth8_Release (synth);
- return S_OK;
- }
-
-/* it seems that the rest of devices are obtained thru dmusic32.EnumLegacyDevices...*sigh*...which is undocumented*/
-#if 0
- int numMIDI = midiOutGetNumDevs();
- int numWAVE = waveOutGetNumDevs();
- int i;
- /* then return digital sound ports */
- for (i = 1; i <= numWAVE; i++)
- {
- TRACE("enumerating 'digital sound' ports\n");
- if (i == dwIndex)
- {
- DirectSoundEnumerateA(register_waveport, pPortCaps);
- return S_OK;
- }
- }
- /* finally, list all *real* MIDI ports*/
- for (i = numWAVE + 1; i <= numWAVE + numMIDI; i++)
- {
- TRACE("enumerating 'real MIDI' ports\n");
- if (i == dwIndex)
- FIXME("Found MIDI port, but *real* MIDI ports not supported yet\n");
- }
-#endif
- return S_FALSE;
+static HRESULT WINAPI IDirectMusic8Impl_EnumPort(LPDIRECTMUSIC8 iface, DWORD index, LPDMUS_PORTCAPS port_caps)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
+
+ TRACE("(%p, %d, %p)\n", This, index, port_caps);
+
+ if (!port_caps)
+ return E_POINTER;
+
+ if (index >= This->nb_system_ports)
+ return S_FALSE;
+
+ *port_caps = This->system_ports[index].caps;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusic8Impl_CreateMusicBuffer (LPDIRECTMUSIC8 iface, LPDMUS_BUFFERDESC pBufferDesc, LPDIRECTMUSICBUFFER** ppBuffer, LPUNKNOWN pUnkOuter) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
+static HRESULT WINAPI IDirectMusic8Impl_CreateMusicBuffer(LPDIRECTMUSIC8 iface, LPDMUS_BUFFERDESC buffer_desc, LPDIRECTMUSICBUFFER* buffer, LPUNKNOWN unkouter)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
- TRACE("(%p, %p, %p, %p)\n", This, pBufferDesc, ppBuffer, pUnkOuter);
+ TRACE("(%p)->(%p, %p, %p)\n", This, buffer_desc, buffer, unkouter);
- if (pUnkOuter)
- return CLASS_E_NOAGGREGATION;
+ if (unkouter)
+ return CLASS_E_NOAGGREGATION;
- if (!pBufferDesc || !ppBuffer)
- return E_POINTER;
+ if (!buffer_desc || !buffer)
+ return E_POINTER;
- return DMUSIC_CreateDirectMusicBufferImpl(&IID_IDirectMusicBuffer, (LPVOID)ppBuffer, NULL);
+ return DMUSIC_CreateDirectMusicBufferImpl(buffer_desc, (LPVOID)buffer);
}
-static HRESULT WINAPI IDirectMusic8Impl_CreatePort (LPDIRECTMUSIC8 iface, REFCLSID rclsidPort, LPDMUS_PORTPARAMS pPortParams, LPDIRECTMUSICPORT* ppPort, LPUNKNOWN pUnkOuter) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- int i/*, j*/;
- DMUS_PORTCAPS PortCaps;
- IDirectMusicPort* pNewPort = NULL;
- HRESULT hr = E_FAIL;
-
- TRACE("(%p, %s, %p, %p, %p)\n", This, debugstr_dmguid(rclsidPort), pPortParams, ppPort, pUnkOuter);
- ZeroMemory(&PortCaps, sizeof(DMUS_PORTCAPS));
- PortCaps.dwSize = sizeof(DMUS_PORTCAPS);
-
- for (i = 0; S_FALSE != IDirectMusic8Impl_EnumPort(iface, i, &PortCaps); i++) {
- if (IsEqualCLSID (rclsidPort, &PortCaps.guidPort)) {
- hr = DMUSIC_CreateDirectMusicPortImpl(&IID_IDirectMusicPort, (LPVOID*) &pNewPort, (LPUNKNOWN) This, pPortParams, &PortCaps);
- if (FAILED(hr)) {
- *ppPort = NULL;
- return hr;
- }
- This->nrofports++;
- if (!This->ppPorts) This->ppPorts = HeapAlloc(GetProcessHeap(), 0, sizeof(LPDIRECTMUSICPORT) * This->nrofports);
- else This->ppPorts = HeapReAlloc(GetProcessHeap(), 0, This->ppPorts, sizeof(LPDIRECTMUSICPORT) * This->nrofports);
- This->ppPorts[This->nrofports - 1] = pNewPort;
- *ppPort = pNewPort;
- return S_OK;
- }
- }
- /* FIXME: place correct error here */
- return E_NOINTERFACE;
+static HRESULT WINAPI IDirectMusic8Impl_CreatePort(LPDIRECTMUSIC8 iface, REFCLSID rclsid_port, LPDMUS_PORTPARAMS port_params, LPDIRECTMUSICPORT* port, LPUNKNOWN unkouter)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
+ int i;
+ DMUS_PORTCAPS port_caps;
+ IDirectMusicPort* new_port = NULL;
+ HRESULT hr;
+ GUID default_port;
+ const GUID *request_port = rclsid_port;
+
+ TRACE("(%p)->(%s, %p, %p, %p)\n", This, debugstr_dmguid(rclsid_port), port_params, port, unkouter);
+
+ if (!rclsid_port)
+ return E_POINTER;
+ if (!port_params)
+ return E_INVALIDARG;
+ if (!port)
+ return E_POINTER;
+ if (unkouter)
+ return CLASS_E_NOAGGREGATION;
+
+ if (TRACE_ON(dmusic))
+ dump_DMUS_PORTPARAMS(port_params);
+
+ ZeroMemory(&port_caps, sizeof(DMUS_PORTCAPS));
+ port_caps.dwSize = sizeof(DMUS_PORTCAPS);
+
+ if (IsEqualGUID(request_port, &GUID_NULL)) {
+ hr = IDirectMusic8_GetDefaultPort(iface, &default_port);
+ if(FAILED(hr))
+ return hr;
+ request_port = &default_port;
+ }
+
+ for (i = 0; S_FALSE != IDirectMusic8Impl_EnumPort(iface, i, &port_caps); i++) {
+ if (IsEqualCLSID(request_port, &port_caps.guidPort)) {
+ hr = This->system_ports[i].create(&IID_IDirectMusicPort, (LPVOID*)&new_port, (LPUNKNOWN)This, port_params, &port_caps, This->system_ports[i].device);
+ if (FAILED(hr)) {
+ *port = NULL;
+ return hr;
+ }
+ This->nrofports++;
+ if (!This->ppPorts)
+ This->ppPorts = HeapAlloc(GetProcessHeap(), 0, sizeof(LPDIRECTMUSICPORT) * This->nrofports);
+ else
+ This->ppPorts = HeapReAlloc(GetProcessHeap(), 0, This->ppPorts, sizeof(LPDIRECTMUSICPORT) * This->nrofports);
+ This->ppPorts[This->nrofports - 1] = new_port;
+ *port = new_port;
+ return S_OK;
+ }
+ }
+
+ return E_NOINTERFACE;
}
-static HRESULT WINAPI IDirectMusic8Impl_EnumMasterClock (LPDIRECTMUSIC8 iface, DWORD dwIndex, LPDMUS_CLOCKINFO lpClockInfo) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- FIXME("(%p, %d, %p): stub\n", This, dwIndex, lpClockInfo);
- return S_FALSE;
+static HRESULT WINAPI IDirectMusic8Impl_EnumMasterClock(LPDIRECTMUSIC8 iface, DWORD index, LPDMUS_CLOCKINFO clock_info)
+{
+ TRACE("(%p)->(%d, %p)\n", iface, index, clock_info);
+
+ if (!clock_info)
+ return E_POINTER;
+
+ if (index > 1)
+ return S_FALSE;
+
+ if (!index)
+ {
+ static const GUID guid_system_clock = { 0x58d58419, 0x71b4, 0x11d1, { 0xa7, 0x4c, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12 } };
+ static const WCHAR name_system_clock[] = { 'S','y','s','t','e','m',' ','C','l','o','c','k',0 };
+
+ clock_info->ctType = 0;
+ clock_info->guidClock = guid_system_clock;
+ strcpyW(clock_info->wszDescription, name_system_clock);
+ }
+ else
+ {
+ static const GUID guid_dsound_clock = { 0x58d58420, 0x71b4, 0x11d1, { 0xa7, 0x4c, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12 } };
+ static const WCHAR name_dsound_clock[] = { 'D','i','r','e','c','t','S','o','u','n','d',' ','C','l','o','c','k',0 };
+
+ clock_info->ctType = 0;
+ clock_info->guidClock = guid_dsound_clock;
+ strcpyW(clock_info->wszDescription, name_dsound_clock);
+ }
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusic8Impl_GetMasterClock (LPDIRECTMUSIC8 iface, LPGUID pguidClock, IReferenceClock** ppReferenceClock) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
+static HRESULT WINAPI IDirectMusic8Impl_GetMasterClock(LPDIRECTMUSIC8 iface, LPGUID guid_clock, IReferenceClock** reference_clock)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
- TRACE("(%p, %p, %p)\n", This, pguidClock, ppReferenceClock);
- if (pguidClock)
- *pguidClock = This->pMasterClock->pClockInfo.guidClock;
- if(ppReferenceClock)
- *ppReferenceClock = (IReferenceClock *)This->pMasterClock;
+ TRACE("(%p)->(%p, %p)\n", This, guid_clock, reference_clock);
- return S_OK;
+ if (guid_clock)
+ *guid_clock = This->pMasterClock->pClockInfo.guidClock;
+ if (reference_clock)
+ *reference_clock = (IReferenceClock*)This->pMasterClock;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusic8Impl_SetMasterClock (LPDIRECTMUSIC8 iface, REFGUID rguidClock) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidClock));
- return S_OK;
+static HRESULT WINAPI IDirectMusic8Impl_SetMasterClock(LPDIRECTMUSIC8 iface, REFGUID rguidClock)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
+
+ FIXME("(%p)->(%s): stub\n", This, debugstr_dmguid(rguidClock));
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusic8Impl_Activate (LPDIRECTMUSIC8 iface, BOOL fEnable) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- int i;
-
- FIXME("(%p, %d): stub\n", This, fEnable);
- for (i = 0; i < This->nrofports; i++) {
- IDirectMusicPortImpl_Activate(This->ppPorts[i], fEnable);
- }
-
- return S_OK;
+static HRESULT WINAPI IDirectMusic8Impl_Activate(LPDIRECTMUSIC8 iface, BOOL enable)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
+ int i;
+ HRESULT hr;
+
+ TRACE("(%p)->(%u)\n", This, enable);
+
+ for (i = 0; i < This->nrofports; i++)
+ {
+ hr = IDirectMusicPort_Activate(This->ppPorts[i], enable);
+ if (FAILED(hr))
+ return hr;
+ }
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusic8Impl_GetDefaultPort (LPDIRECTMUSIC8 iface, LPGUID pguidPort) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- HKEY hkGUID;
- DWORD returnTypeGUID, sizeOfReturnBuffer = 50;
- char returnBuffer[51];
- GUID defaultPortGUID;
- WCHAR buff[51];
-
- TRACE("(%p, %p)\n", This, pguidPort);
- if ((RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\DirectMusic\\Defaults" , 0, KEY_READ, &hkGUID) != ERROR_SUCCESS) ||
- (RegQueryValueExA(hkGUID, "DefaultOutputPort", NULL, &returnTypeGUID, (LPBYTE)returnBuffer, &sizeOfReturnBuffer) != ERROR_SUCCESS))
- {
- WARN(": registry entry missing\n" );
- *pguidPort = CLSID_DirectMusicSynth;
- return S_OK;
- }
- /* FIXME: Check return types to ensure we're interpreting data right */
- MultiByteToWideChar(CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff) / sizeof(WCHAR));
- CLSIDFromString(buff, &defaultPortGUID);
- *pguidPort = defaultPortGUID;
-
- return S_OK;
+static HRESULT WINAPI IDirectMusic8Impl_GetDefaultPort(LPDIRECTMUSIC8 iface, LPGUID guid_port)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
+ HKEY hkGUID;
+ DWORD returnTypeGUID, sizeOfReturnBuffer = 50;
+ char returnBuffer[51];
+ GUID defaultPortGUID;
+ WCHAR buff[51];
+
+ TRACE("(%p)->(%p)\n", This, guid_port);
+
+ if ((RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\DirectMusic\\Defaults" , 0, KEY_READ, &hkGUID) != ERROR_SUCCESS) ||
+ (RegQueryValueExA(hkGUID, "DefaultOutputPort", NULL, &returnTypeGUID, (LPBYTE)returnBuffer, &sizeOfReturnBuffer) != ERROR_SUCCESS))
+ {
+ WARN(": registry entry missing\n" );
+ *guid_port = CLSID_DirectMusicSynth;
+ return S_OK;
+ }
+ /* FIXME: Check return types to ensure we're interpreting data right */
+ MultiByteToWideChar(CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff) / sizeof(WCHAR));
+ CLSIDFromString(buff, &defaultPortGUID);
+ *guid_port = defaultPortGUID;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusic8Impl_SetDirectSound (LPDIRECTMUSIC8 iface, LPDIRECTSOUND pDirectSound, HWND hWnd) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- FIXME("(%p, %p, %p): stub\n", This, pDirectSound, hWnd);
- return S_OK;
+static HRESULT WINAPI IDirectMusic8Impl_SetDirectSound(LPDIRECTMUSIC8 iface, LPDIRECTSOUND dsound, HWND wnd)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
+
+ FIXME("(%p)->(%p, %p): stub\n", This, dsound, wnd);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusic8Impl_SetExternalMasterClock (LPDIRECTMUSIC8 iface, IReferenceClock* pClock) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- FIXME("(%p, %p): stub\n", This, pClock);
- return S_OK;
+static HRESULT WINAPI IDirectMusic8Impl_SetExternalMasterClock(LPDIRECTMUSIC8 iface, IReferenceClock* clock)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
+
+ FIXME("(%p)->(%p): stub\n", This, clock);
+
+ return S_OK;
}
static const IDirectMusic8Vtbl DirectMusic8_Vtbl = {
- IDirectMusic8Impl_QueryInterface,
- IDirectMusic8Impl_AddRef,
- IDirectMusic8Impl_Release,
- IDirectMusic8Impl_EnumPort,
- IDirectMusic8Impl_CreateMusicBuffer,
- IDirectMusic8Impl_CreatePort,
- IDirectMusic8Impl_EnumMasterClock,
- IDirectMusic8Impl_GetMasterClock,
- IDirectMusic8Impl_SetMasterClock,
- IDirectMusic8Impl_Activate,
- IDirectMusic8Impl_GetDefaultPort,
- IDirectMusic8Impl_SetDirectSound,
- IDirectMusic8Impl_SetExternalMasterClock
+ IDirectMusic8Impl_QueryInterface,
+ IDirectMusic8Impl_AddRef,
+ IDirectMusic8Impl_Release,
+ IDirectMusic8Impl_EnumPort,
+ IDirectMusic8Impl_CreateMusicBuffer,
+ IDirectMusic8Impl_CreatePort,
+ IDirectMusic8Impl_EnumMasterClock,
+ IDirectMusic8Impl_GetMasterClock,
+ IDirectMusic8Impl_SetMasterClock,
+ IDirectMusic8Impl_Activate,
+ IDirectMusic8Impl_GetDefaultPort,
+ IDirectMusic8Impl_SetDirectSound,
+ IDirectMusic8Impl_SetExternalMasterClock
};
-/* for ClassFactory */
-HRESULT WINAPI DMUSIC_CreateDirectMusicImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
- IDirectMusic8Impl *dmusic;
-
- TRACE("(%p,%p,%p)\n",lpcGUID, ppobj, pUnkOuter);
-
- dmusic = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusic8Impl));
- if (NULL == dmusic) {
- *ppobj = NULL;
- return E_OUTOFMEMORY;
- }
- dmusic->lpVtbl = &DirectMusic8_Vtbl;
- dmusic->ref = 0; /* will be inited with QueryInterface */
- dmusic->pMasterClock = NULL;
- dmusic->ppPorts = NULL;
- dmusic->nrofports = 0;
- DMUSIC_CreateReferenceClockImpl (&IID_IReferenceClock, (LPVOID*)&dmusic->pMasterClock, NULL);
-
- return IDirectMusic8Impl_QueryInterface ((LPDIRECTMUSIC8)dmusic, lpcGUID, ppobj);
+static void create_system_ports_list(IDirectMusic8Impl* object)
+{
+ port_info * port;
+ const WCHAR emulated[] = {' ','[','E','m','u','l','a','t','e','d',']',0};
+ ULONG nb_ports;
+ ULONG nb_midi_out;
+ ULONG nb_midi_in;
+ MIDIOUTCAPSW caps_out;
+ MIDIINCAPSW caps_in;
+ IDirectMusicSynth8* synth;
+ HRESULT hr;
+ ULONG i;
+
+ TRACE("(%p)\n", object);
+
+ /* NOTE:
+ - it seems some native versions get the rest of devices through dmusic32.EnumLegacyDevices...*sigh*...which is undocumented
+ - should we enum wave devices ? Native does not seem to
+ */
+
+ nb_midi_out = midiOutGetNumDevs();
+ nb_midi_in = midiInGetNumDevs();
+ nb_ports = 1 /* midi mapper */ + nb_midi_out + nb_midi_in + 1 /* synth port */;
+
+ port = object->system_ports = HeapAlloc(GetProcessHeap(), 0, nb_ports * sizeof(port_info));
+ if (!object->system_ports)
+ return;
+
+ /* Fill common port caps for all winmm ports */
+ for (i = 0; i < (nb_ports - 1 /* synth port*/); i++)
+ {
+ object->system_ports[i].caps.dwSize = sizeof(DMUS_PORTCAPS);
+ object->system_ports[i].caps.dwType = DMUS_PORT_WINMM_DRIVER;
+ object->system_ports[i].caps.dwMemorySize = 0;
+ object->system_ports[i].caps.dwMaxChannelGroups = 1;
+ object->system_ports[i].caps.dwMaxVoices = 0;
+ object->system_ports[i].caps.dwMaxAudioChannels = 0;
+ object->system_ports[i].caps.dwEffectFlags = DMUS_EFFECT_NONE;
+ /* Fake port GUID */
+ object->system_ports[i].caps.guidPort = IID_IUnknown;
+ object->system_ports[i].caps.guidPort.Data1 = i + 1;
+ }
+
+ /* Fill midi mapper port info */
+ port->device = MIDI_MAPPER;
+ port->create = DMUSIC_CreateMidiOutPortImpl;
+ midiOutGetDevCapsW(MIDI_MAPPER, &caps_out, sizeof(caps_out));
+ strcpyW(port->caps.wszDescription, caps_out.szPname);
+ strcatW(port->caps.wszDescription, emulated);
+ port->caps.dwFlags = DMUS_PC_SHAREABLE;
+ port->caps.dwClass = DMUS_PC_OUTPUTCLASS;
+ port++;
+
+ /* Fill midi out port info */
+ for (i = 0; i < nb_midi_out; i++)
+ {
+ port->device = i;
+ port->create = DMUSIC_CreateMidiOutPortImpl;
+ midiOutGetDevCapsW(i, &caps_out, sizeof(caps_out));
+ strcpyW(port->caps.wszDescription, caps_out.szPname);
+ strcatW(port->caps.wszDescription, emulated);
+ port->caps.dwFlags = DMUS_PC_SHAREABLE | DMUS_PC_EXTERNAL;
+ port->caps.dwClass = DMUS_PC_OUTPUTCLASS;
+ port++;
+ }
+
+ /* Fill midi in port info */
+ for (i = 0; i < nb_midi_in; i++)
+ {
+ port->device = i;
+ port->create = DMUSIC_CreateMidiInPortImpl;
+ midiInGetDevCapsW(i, &caps_in, sizeof(caps_in));
+ strcpyW(port->caps.wszDescription, caps_in.szPname);
+ strcatW(port->caps.wszDescription, emulated);
+ port->caps.dwFlags = DMUS_PC_EXTERNAL;
+ port->caps.dwClass = DMUS_PC_INPUTCLASS;
+ port++;
+ }
+
+ /* Fill synth port info */
+ port->create = DMUSIC_CreateSynthPortImpl;
+ hr = CoCreateInstance(&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynth8, (void**)&synth);
+ if (SUCCEEDED(hr))
+ {
+ port->caps.dwSize = sizeof(port->caps);
+ hr = IDirectMusicSynth8_GetPortCaps(synth, &port->caps);
+ IDirectMusicSynth8_Release(synth);
+ }
+ if (FAILED(hr))
+ nb_ports--;
+
+ object->nb_system_ports = nb_ports;
+}
+
+/* For ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicImpl(LPCGUID riid, LPVOID* ret_iface, LPUNKNOWN unkouter)
+{
+ IDirectMusic8Impl *dmusic;
+ HRESULT ret;
+
+ TRACE("(%p,%p,%p)\n", riid, ret_iface, unkouter);
+
+ *ret_iface = NULL;
+
+ dmusic = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusic8Impl));
+ if (!dmusic)
+ return E_OUTOFMEMORY;
+
+ dmusic->IDirectMusic8_iface.lpVtbl = &DirectMusic8_Vtbl;
+ dmusic->ref = 0; /* Will be inited by QueryInterface */
+ dmusic->pMasterClock = NULL;
+ dmusic->ppPorts = NULL;
+ dmusic->nrofports = 0;
+ ret = DMUSIC_CreateReferenceClockImpl(&IID_IReferenceClock, (LPVOID*)&dmusic->pMasterClock, NULL);
+ if (FAILED(ret)) {
+ HeapFree(GetProcessHeap(), 0, dmusic);
+ return ret;
+ }
+
+ ret = IDirectMusic8Impl_QueryInterface(&dmusic->IDirectMusic8_iface, riid, ret_iface);
+ if (FAILED(ret)) {
+ IReferenceClock_Release(&dmusic->pMasterClock->IReferenceClock_iface);
+ HeapFree(GetProcessHeap(), 0, dmusic);
+ return ret;
+ }
+
+ create_system_ports_list(dmusic);
+
+ return S_OK;
}
--- /dev/null
+/*
+ * COM Classes for dmusic
+ *
+ * Copyright 2010 Alexandre Julliard
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+[
+ threading(both),
+ progid("Microsoft.DirectMusic.1"),
+ vi_progid("Microsoft.DirectMusic"),
+ uuid(636b9f10-0c7d-11d1-95b2-0020afdc7421)
+]
+coclass DirectMusic { interface IDirectMusic; }
+
+[
+ threading(both),
+ progid("Microsoft.DirectMusicCollection.1"),
+ vi_progid("Microsoft.DirectMusicCollection"),
+ uuid(480ff4b0-28b2-11d1-bef7-00c04fbf8fef)
+]
+coclass DirectMusicCollection { interface IDirectMusicCollection; }
--- /dev/null
+HKCR
+{
+ NoRemove Interface
+ {
+ }
+ NoRemove CLSID
+ {
+ '{636B9F10-0C7D-11D1-95B2-0020AFDC7421}' = s 'DirectMusic'
+ {
+ InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
+ ProgId = s 'Microsoft.DirectMusic.1'
+ VersionIndependentProgId = s 'Microsoft.DirectMusic'
+ }
+ '{480FF4B0-28B2-11D1-BEF7-00C04FBF8FEF}' = s 'DirectMusicCollection'
+ {
+ InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
+ ProgId = s 'Microsoft.DirectMusicCollection.1'
+ VersionIndependentProgId = s 'Microsoft.DirectMusicCollection'
+ }
+ }
+ 'Microsoft.DirectMusic.1' = s 'DirectMusic'
+ {
+ CLSID = s '{636B9F10-0C7D-11D1-95B2-0020AFDC7421}'
+ }
+ 'Microsoft.DirectMusic' = s 'DirectMusic'
+ {
+ CLSID = s '{636B9F10-0C7D-11D1-95B2-0020AFDC7421}'
+ CurVer = s 'Microsoft.DirectMusic.1'
+ }
+ 'Microsoft.DirectMusicCollection.1' = s 'DirectMusicCollection'
+ {
+ CLSID = s '{480FF4B0-28B2-11D1-BEF7-00C04FBF8FEF}'
+ }
+ 'Microsoft.DirectMusicCollection' = s 'DirectMusicCollection'
+ {
+ CLSID = s '{480FF4B0-28B2-11D1-BEF7-00C04FBF8FEF}'
+ CurVer = s 'Microsoft.DirectMusicCollection.1'
+ }
+}
#include <stdio.h>
#include "dmusic_private.h"
+#include "rpcproxy.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+static HINSTANCE instance;
LONG DMUSIC_refCount = 0;
typedef struct {
- const IClassFactoryVtbl *lpVtbl;
+ IClassFactory IClassFactory_iface;
+ HRESULT (WINAPI *fnCreateInstance)(REFIID riid, void **ppv, IUnknown *pUnkOuter);
} IClassFactoryImpl;
/******************************************************************
- * DirectMusic ClassFactory
+ * IClassFactory implementation
*/
-static HRESULT WINAPI DirectMusicCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
- FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
-
- if (ppobj == NULL) return E_POINTER;
-
- return E_NOINTERFACE;
+static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
+{
+ return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
}
-static ULONG WINAPI DirectMusicCF_AddRef(LPCLASSFACTORY iface) {
- DMUSIC_LockModule();
-
- return 2; /* non-heap based object */
+static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
+{
+ if (ppv == NULL)
+ return E_POINTER;
+
+ if (IsEqualGUID(&IID_IUnknown, riid))
+ TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
+ else if (IsEqualGUID(&IID_IClassFactory, riid))
+ TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
+ else {
+ FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
+ *ppv = NULL;
+ return E_NOINTERFACE;
+ }
+
+ *ppv = iface;
+ IUnknown_AddRef((IUnknown*)*ppv);
+ return S_OK;
}
-static ULONG WINAPI DirectMusicCF_Release(LPCLASSFACTORY iface) {
- DMUSIC_UnlockModule();
-
- return 1; /* non-heap based object */
-}
+static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
+{
+ DMUSIC_LockModule();
-static HRESULT WINAPI DirectMusicCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
- TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
- return DMUSIC_CreateDirectMusicImpl (riid, ppobj, pOuter);
+ return 2; /* non-heap based object */
}
-static HRESULT WINAPI DirectMusicCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
- TRACE("(%d)\n", dolock);
-
- if (dolock)
- DMUSIC_LockModule();
- else
- DMUSIC_UnlockModule();
-
- return S_OK;
-}
-
-static const IClassFactoryVtbl DirectMusicCF_Vtbl = {
- DirectMusicCF_QueryInterface,
- DirectMusicCF_AddRef,
- DirectMusicCF_Release,
- DirectMusicCF_CreateInstance,
- DirectMusicCF_LockServer
-};
-
-static IClassFactoryImpl DirectMusic_CF = {&DirectMusicCF_Vtbl};
-
-/******************************************************************
- * DirectMusicCollection ClassFactory
- */
-static HRESULT WINAPI CollectionCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
- FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
+static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
+{
+ DMUSIC_UnlockModule();
- if (ppobj == NULL) return E_POINTER;
-
- return E_NOINTERFACE;
+ return 1; /* non-heap based object */
}
-static ULONG WINAPI CollectionCF_AddRef(LPCLASSFACTORY iface) {
- DMUSIC_LockModule();
-
- return 2; /* non-heap based object */
-}
+static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
+ REFIID riid, void **ppv)
+{
+ IClassFactoryImpl *This = impl_from_IClassFactory(iface);
-static ULONG WINAPI CollectionCF_Release(LPCLASSFACTORY iface) {
- DMUSIC_UnlockModule();
+ TRACE ("(%p, %s, %p)\n", pUnkOuter, debugstr_dmguid(riid), ppv);
- return 1; /* non-heap based object */
+ return This->fnCreateInstance(riid, ppv, pUnkOuter);
}
-static HRESULT WINAPI CollectionCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
- TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
- return DMUSIC_CreateDirectMusicCollectionImpl (riid, ppobj, pOuter);
-}
+static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
+{
+ TRACE("(%d)\n", dolock);
-static HRESULT WINAPI CollectionCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
- TRACE("(%d)\n", dolock);
+ if (dolock)
+ DMUSIC_LockModule();
+ else
+ DMUSIC_UnlockModule();
- if (dolock)
- DMUSIC_LockModule();
- else
- DMUSIC_UnlockModule();
-
- return S_OK;
+ return S_OK;
}
-static const IClassFactoryVtbl CollectionCF_Vtbl = {
- CollectionCF_QueryInterface,
- CollectionCF_AddRef,
- CollectionCF_Release,
- CollectionCF_CreateInstance,
- CollectionCF_LockServer
+static const IClassFactoryVtbl classfactory_vtbl = {
+ ClassFactory_QueryInterface,
+ ClassFactory_AddRef,
+ ClassFactory_Release,
+ ClassFactory_CreateInstance,
+ ClassFactory_LockServer
};
-static IClassFactoryImpl Collection_CF = {&CollectionCF_Vtbl};
+static IClassFactoryImpl DirectMusic_CF = {{&classfactory_vtbl}, DMUSIC_CreateDirectMusicImpl};
+static IClassFactoryImpl Collection_CF = {{&classfactory_vtbl},
+ DMUSIC_CreateDirectMusicCollectionImpl};
/******************************************************************
* DllMain
*/
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
if (fdwReason == DLL_PROCESS_ATTACH) {
+ instance = hinstDLL;
DisableThreadLibraryCalls(hinstDLL);
/* FIXME: Initialisation */
} else if (fdwReason == DLL_PROCESS_DETACH) {
return CLASS_E_CLASSNOTAVAILABLE;
}
+/***********************************************************************
+ * DllRegisterServer (DMUSIC.@)
+ */
+HRESULT WINAPI DllRegisterServer(void)
+{
+ return __wine_register_resources( instance );
+}
+
+/***********************************************************************
+ * DllUnregisterServer (DMUSIC.@)
+ */
+HRESULT WINAPI DllUnregisterServer(void)
+{
+ return __wine_unregister_resources( instance );
+}
/******************************************************************
* Helper functions
*
*/
/* dwPatch from MIDILOCALE */
-DWORD MIDILOCALE2Patch (LPMIDILOCALE pLocale) {
+DWORD MIDILOCALE2Patch (const MIDILOCALE *pLocale) {
DWORD dwPatch = 0;
if (!pLocale) return 0;
dwPatch |= (pLocale->ulBank & F_INSTRUMENT_DRUMS); /* set drum bit */
return debugstr_flags (flagmask, flags, sizeof(flags)/sizeof(flags[0]));
}
-/* dump whole DMUS_OBJECTDESC struct */
-const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc) {
- if (pDesc) {
- char buffer[1024] = "", *ptr = &buffer[0];
-
- ptr += sprintf(ptr, "DMUS_OBJECTDESC (%p):\n", pDesc);
- ptr += sprintf(ptr, " - dwSize = %d\n", pDesc->dwSize);
- ptr += sprintf(ptr, " - dwValidData = %s\n", debugstr_DMUS_OBJ_FLAGS (pDesc->dwValidData));
- if (pDesc->dwValidData & DMUS_OBJ_CLASS) ptr += sprintf(ptr, " - guidClass = %s\n", debugstr_dmguid(&pDesc->guidClass));
- if (pDesc->dwValidData & DMUS_OBJ_OBJECT) ptr += sprintf(ptr, " - guidObject = %s\n", debugstr_guid(&pDesc->guidObject));
- if (pDesc->dwValidData & DMUS_OBJ_DATE) ptr += sprintf(ptr, " - ftDate = FIXME\n");
- if (pDesc->dwValidData & DMUS_OBJ_VERSION) ptr += sprintf(ptr, " - vVersion = %s\n", debugstr_dmversion(&pDesc->vVersion));
- if (pDesc->dwValidData & DMUS_OBJ_NAME) ptr += sprintf(ptr, " - wszName = %s\n", debugstr_w(pDesc->wszName));
- if (pDesc->dwValidData & DMUS_OBJ_CATEGORY) ptr += sprintf(ptr, " - wszCategory = %s\n", debugstr_w(pDesc->wszCategory));
- if (pDesc->dwValidData & DMUS_OBJ_FILENAME) ptr += sprintf(ptr, " - wszFileName = %s\n", debugstr_w(pDesc->wszFileName));
- if (pDesc->dwValidData & DMUS_OBJ_MEMORY) ptr += sprintf(ptr, " - llMemLength = 0x%s\n - pbMemData = %p\n",
- wine_dbgstr_longlong(pDesc->llMemLength), pDesc->pbMemData);
- if (pDesc->dwValidData & DMUS_OBJ_STREAM) ptr += sprintf(ptr, " - pStream = %p", pDesc->pStream);
-
- return wine_dbg_sprintf("%s", buffer);
- } else {
- return wine_dbg_sprintf("(NULL)");
- }
+/* Dump whole DMUS_OBJECTDESC struct */
+void dump_DMUS_OBJECTDESC(LPDMUS_OBJECTDESC desc)
+{
+ TRACE("DMUS_OBJECTDESC (%p):\n", desc);
+ TRACE(" - dwSize = %d\n", desc->dwSize);
+ TRACE(" - dwValidData = %s\n", debugstr_DMUS_OBJ_FLAGS (desc->dwValidData));
+ if (desc->dwValidData & DMUS_OBJ_CLASS) TRACE(" - guidClass = %s\n", debugstr_dmguid(&desc->guidClass));
+ if (desc->dwValidData & DMUS_OBJ_OBJECT) TRACE(" - guidObject = %s\n", debugstr_guid(&desc->guidObject));
+ if (desc->dwValidData & DMUS_OBJ_DATE) TRACE(" - ftDate = FIXME\n");
+ if (desc->dwValidData & DMUS_OBJ_VERSION) TRACE(" - vVersion = %s\n", debugstr_dmversion(&desc->vVersion));
+ if (desc->dwValidData & DMUS_OBJ_NAME) TRACE(" - wszName = %s\n", debugstr_w(desc->wszName));
+ if (desc->dwValidData & DMUS_OBJ_CATEGORY) TRACE(" - wszCategory = %s\n", debugstr_w(desc->wszCategory));
+ if (desc->dwValidData & DMUS_OBJ_FILENAME) TRACE(" - wszFileName = %s\n", debugstr_w(desc->wszFileName));
+ if (desc->dwValidData & DMUS_OBJ_MEMORY) TRACE(" - llMemLength = 0x%s\n - pbMemData = %p\n",
+ wine_dbgstr_longlong(desc->llMemLength), desc->pbMemData);
+ if (desc->dwValidData & DMUS_OBJ_STREAM) TRACE(" - pStream = %p\n", desc->pStream);
+}
+
+/* Dump DMUS_PORTPARAMS flags */
+static const char* debugstr_DMUS_PORTPARAMS_FLAGS(DWORD flagmask)
+{
+ static const flag_info flags[] = {
+ FE(DMUS_PORTPARAMS_VOICES),
+ FE(DMUS_PORTPARAMS_CHANNELGROUPS),
+ FE(DMUS_PORTPARAMS_AUDIOCHANNELS),
+ FE(DMUS_PORTPARAMS_SAMPLERATE),
+ FE(DMUS_PORTPARAMS_EFFECTS),
+ FE(DMUS_PORTPARAMS_SHARE)
+ };
+ return debugstr_flags(flagmask, flags, sizeof(flags)/sizeof(flags[0]));
+}
+
+/* Dump whole DMUS_PORTPARAMS struct */
+void dump_DMUS_PORTPARAMS(LPDMUS_PORTPARAMS params)
+{
+ TRACE("DMUS_PORTPARAMS (%p):\n", params);
+ TRACE(" - dwSize = %d\n", params->dwSize);
+ TRACE(" - dwValidParams = %s\n", debugstr_DMUS_PORTPARAMS_FLAGS(params->dwValidParams));
+ if (params->dwValidParams & DMUS_PORTPARAMS_VOICES) TRACE(" - dwVoices = %u\n", params->dwVoices);
+ if (params->dwValidParams & DMUS_PORTPARAMS_CHANNELGROUPS) TRACE(" - dwChannelGroup = %u\n", params->dwChannelGroups);
+ if (params->dwValidParams & DMUS_PORTPARAMS_AUDIOCHANNELS) TRACE(" - dwAudioChannels = %u\n", params->dwAudioChannels);
+ if (params->dwValidParams & DMUS_PORTPARAMS_SAMPLERATE) TRACE(" - dwSampleRate = %u\n", params->dwSampleRate);
+ if (params->dwValidParams & DMUS_PORTPARAMS_EFFECTS) TRACE(" - dwEffectFlags = %x\n", params->dwEffectFlags);
+ if (params->dwValidParams & DMUS_PORTPARAMS_SHARE) TRACE(" - fShare = %u\n", params->fShare);
}
-/* DirectMusic Private Include
+/*
+ * DirectMusic Private Include
*
* Copyright (C) 2003-2004 Rok Mandeljc
+ * Copyright (C) 2012 Christian Costa
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
typedef struct IDirectMusicBufferImpl IDirectMusicBufferImpl;
typedef struct IDirectMusicDownloadedInstrumentImpl IDirectMusicDownloadedInstrumentImpl;
typedef struct IDirectMusicDownloadImpl IDirectMusicDownloadImpl;
-typedef struct IDirectMusicPortDownloadImpl IDirectMusicPortDownloadImpl;
-typedef struct IDirectMusicPortImpl IDirectMusicPortImpl;
-typedef struct IDirectMusicThruImpl IDirectMusicThruImpl;
typedef struct IReferenceClockImpl IReferenceClockImpl;
typedef struct IDirectMusicCollectionImpl IDirectMusicCollectionImpl;
typedef struct IDirectMusicInstrumentImpl IDirectMusicInstrumentImpl;
+typedef struct SynthPortImpl SynthPortImpl;
/*****************************************************************************
* Some stuff to make my life easier :=)
DMUSIC_PRIVATE_MCHANNEL channel[16]; /* 16 channels in a group */
} DMUSIC_PRIVATE_CHANNEL_GROUP, *LPDMUSIC_PRIVATE_CHANNEL_GROUP;
+typedef struct port_info {
+ DMUS_PORTCAPS caps;
+ HRESULT (*create)(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device);
+ ULONG device;
+} port_info;
+
+typedef struct instrument_region {
+ RGNHEADER header;
+ WAVELINK wave_link;
+ WSMPL wave_sample;
+ WLOOP wave_loop;
+ BOOL loop_present;
+} instrument_region;
+
+typedef struct instrument_articulation {
+ CONNECTIONLIST connections_list;
+ CONNECTION *connections;
+} instrument_articulation;
/*****************************************************************************
* ClassFactory
*/
-extern HRESULT WINAPI DMUSIC_CreateDirectMusicImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
-extern HRESULT WINAPI DMUSIC_CreateDirectMusicBufferImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
-extern HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadedInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
-extern HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
-extern HRESULT WINAPI DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
-extern HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
-extern HRESULT WINAPI DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
+/* CLSID */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl(LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
+
+/* Internal */
+extern HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_iface) DECLSPEC_HIDDEN;
+extern HRESULT DMUSIC_CreateDirectMusicDownloadImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
+extern HRESULT DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
+extern HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
/*****************************************************************************
* IDirectMusic8Impl implementation structure
*/
struct IDirectMusic8Impl {
- /* IUnknown fields */
- const IDirectMusic8Vtbl *lpVtbl;
- LONG ref;
-
- /* IDirectMusicImpl fields */
- IReferenceClockImpl* pMasterClock;
- IDirectMusicPort** ppPorts;
- int nrofports;
+ /* IUnknown fields */
+ IDirectMusic8 IDirectMusic8_iface;
+ LONG ref;
+
+ /* IDirectMusicImpl fields */
+ IReferenceClockImpl* pMasterClock;
+ IDirectMusicPort** ppPorts;
+ int nrofports;
+ port_info* system_ports;
+ int nb_system_ports;
};
/*****************************************************************************
* IDirectMusicBufferImpl implementation structure
*/
struct IDirectMusicBufferImpl {
- /* IUnknown fields */
- const IDirectMusicBufferVtbl *lpVtbl;
- LONG ref;
-
- /* IDirectMusicBufferImpl fields */
+ /* IUnknown fields */
+ IDirectMusicBuffer IDirectMusicBuffer_iface;
+ LONG ref;
+
+ /* IDirectMusicBufferImpl fields */
+ GUID format;
+ DWORD size;
+ LPBYTE data;
+ DWORD write_pos;
+ REFERENCE_TIME start_time;
};
/*****************************************************************************
* IDirectMusicDownloadedInstrumentImpl implementation structure
*/
struct IDirectMusicDownloadedInstrumentImpl {
- /* IUnknown fields */
- const IDirectMusicDownloadedInstrumentVtbl *lpVtbl;
- LONG ref;
+ /* IUnknown fields */
+ IDirectMusicDownloadedInstrument IDirectMusicDownloadedInstrument_iface;
+ LONG ref;
- /* IDirectMusicDownloadedInstrumentImpl fields */
+ /* IDirectMusicDownloadedInstrumentImpl fields */
+ BOOL downloaded;
+ void *data;
};
/*****************************************************************************
* IDirectMusicDownloadImpl implementation structure
*/
struct IDirectMusicDownloadImpl {
- /* IUnknown fields */
- const IDirectMusicDownloadVtbl *lpVtbl;
- LONG ref;
+ /* IUnknown fields */
+ IDirectMusicDownload IDirectMusicDownload_iface;
+ LONG ref;
- /* IDirectMusicDownloadImpl fields */
+ /* IDirectMusicDownloadImpl fields */
};
/*****************************************************************************
- * IDirectMusicPortImpl implementation structure
+ * SynthPortImpl implementation structure
*/
-struct IDirectMusicPortImpl {
- /* IUnknown fields */
- const IDirectMusicPortVtbl *lpVtbl;
- const IDirectMusicPortDownloadVtbl *lpDownloadVtbl;
- const IDirectMusicThruVtbl *lpThruVtbl;
- LONG ref;
-
- /* IDirectMusicPortImpl fields */
- IDirectSound* pDirectSound;
- IReferenceClock* pLatencyClock;
- BOOL fActive;
- DMUS_PORTCAPS caps;
- DMUS_PORTPARAMS params;
- int nrofgroups;
- DMUSIC_PRIVATE_CHANNEL_GROUP group[1];
+struct SynthPortImpl {
+ /* IUnknown fields */
+ IDirectMusicPort IDirectMusicPort_iface;
+ IDirectMusicPortDownload IDirectMusicPortDownload_iface;
+ IDirectMusicThru IDirectMusicThru_iface;
+ LONG ref;
+
+ /* IDirectMusicPort fields */
+ IDirectSound* pDirectSound;
+ IReferenceClock* pLatencyClock;
+ IDirectMusicSynth* synth;
+ IDirectMusicSynthSink* synth_sink;
+ BOOL fActive;
+ DMUS_PORTCAPS caps;
+ DMUS_PORTPARAMS params;
+ int nrofgroups;
+ DMUSIC_PRIVATE_CHANNEL_GROUP group[1];
};
-extern HRESULT WINAPI IDirectMusicPortImpl_Activate (LPDIRECTMUSICPORT iface, BOOL fActive);
-
/** Internal factory */
-extern HRESULT WINAPI DMUSIC_CreateDirectMusicPortImpl (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter, LPDMUS_PORTPARAMS pPortParams, LPDMUS_PORTCAPS pPortCaps);
+extern HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) DECLSPEC_HIDDEN;
+extern HRESULT DMUSIC_CreateMidiOutPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) DECLSPEC_HIDDEN;
+extern HRESULT DMUSIC_CreateMidiInPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) DECLSPEC_HIDDEN;
/*****************************************************************************
* IReferenceClockImpl implementation structure
*/
struct IReferenceClockImpl {
- /* IUnknown fields */
- const IReferenceClockVtbl *lpVtbl;
- LONG ref;
+ /* IUnknown fields */
+ IReferenceClock IReferenceClock_iface;
+ LONG ref;
- /* IReferenceClockImpl fields */
- REFERENCE_TIME rtTime;
- DMUS_CLOCKINFO pClockInfo;
+ /* IReferenceClockImpl fields */
+ REFERENCE_TIME rtTime;
+ DMUS_CLOCKINFO pClockInfo;
};
typedef struct _DMUS_PRIVATE_INSTRUMENT_ENTRY {
* IDirectMusicCollectionImpl implementation structure
*/
struct IDirectMusicCollectionImpl {
- /* IUnknown fields */
- const IUnknownVtbl *UnknownVtbl;
- const IDirectMusicCollectionVtbl *CollectionVtbl;
- const IDirectMusicObjectVtbl *ObjectVtbl;
- const IPersistStreamVtbl *PersistStreamVtbl;
- LONG ref;
-
- /* IDirectMusicCollectionImpl fields */
- IStream *pStm; /* stream from which we load collection and later instruments */
- LARGE_INTEGER liCollectionPosition; /* offset in a stream where collection was loaded from */
- LARGE_INTEGER liWavePoolTablePosition; /* offset in a stream where wave pool table can be found */
- LPDMUS_OBJECTDESC pDesc;
- CHAR* szCopyright; /* FIXME: should probably placed somewhere else */
- LPDLSHEADER pHeader;
- /* pool table */
- LPPOOLTABLE pPoolTable;
- LPPOOLCUE pPoolCues;
- /* instruments */
- struct list Instruments;
+ /* IUnknown fields */
+ IDirectMusicCollection IDirectMusicCollection_iface;
+ IDirectMusicObject IDirectMusicObject_iface;
+ IPersistStream IPersistStream_iface;
+ LONG ref;
+
+ /* IDirectMusicCollectionImpl fields */
+ IStream *pStm; /* stream from which we load collection and later instruments */
+ LARGE_INTEGER liCollectionPosition; /* offset in a stream where collection was loaded from */
+ LARGE_INTEGER liWavePoolTablePosition; /* offset in a stream where wave pool table can be found */
+ LPDMUS_OBJECTDESC pDesc;
+ CHAR* szCopyright; /* FIXME: should probably placed somewhere else */
+ LPDLSHEADER pHeader;
+ /* pool table */
+ LPPOOLTABLE pPoolTable;
+ LPPOOLCUE pPoolCues;
+ /* instruments */
+ struct list Instruments;
};
/*****************************************************************************
* IDirectMusicInstrumentImpl implementation structure
*/
struct IDirectMusicInstrumentImpl {
- /* IUnknown fields */
- const IUnknownVtbl *UnknownVtbl;
- const IDirectMusicInstrumentVtbl *InstrumentVtbl;
- LONG ref;
-
- /* IDirectMusicInstrumentImpl fields */
- LARGE_INTEGER liInstrumentPosition; /* offset in a stream where instrument chunk can be found */
- LPGUID pInstrumentID;
- LPINSTHEADER pHeader;
- WCHAR wszName[DMUS_MAX_NAME];
- /* instrument data */
+ /* IUnknown fields */
+ IDirectMusicInstrument IDirectMusicInstrument_iface;
+ LONG ref;
+
+ /* IDirectMusicInstrumentImpl fields */
+ LARGE_INTEGER liInstrumentPosition; /* offset in a stream where instrument chunk can be found */
+ ULONG length; /* Length of the instrument in the stream */
+ GUID id;
+ INSTHEADER header;
+ WCHAR wszName[DMUS_MAX_NAME];
+ /* instrument data */
+ BOOL loaded;
+ instrument_region *regions;
+ ULONG nb_articulations;
+ instrument_articulation *articulations;
};
+static inline IDirectMusicInstrumentImpl *impl_from_IDirectMusicInstrument(IDirectMusicInstrument *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectMusicInstrumentImpl, IDirectMusicInstrument_iface);
+}
+
/* custom :) */
-extern HRESULT WINAPI IDirectMusicInstrumentImpl_Custom_Load (LPDIRECTMUSICINSTRUMENT iface, LPSTREAM pStm);
+extern HRESULT IDirectMusicInstrumentImpl_CustomLoad(IDirectMusicInstrument *iface, IStream *stream) DECLSPEC_HIDDEN;
/**********************************************************************
* Dll lifetime tracking declaration for dmusic.dll
*/
-extern LONG DMUSIC_refCount;
+extern LONG DMUSIC_refCount DECLSPEC_HIDDEN;
static inline void DMUSIC_LockModule(void) { InterlockedIncrement( &DMUSIC_refCount ); }
static inline void DMUSIC_UnlockModule(void) { InterlockedDecrement( &DMUSIC_refCount ); }
#define GE(x) { &x, #x }
/* dwPatch from MIDILOCALE */
-extern DWORD MIDILOCALE2Patch (LPMIDILOCALE pLocale);
+extern DWORD MIDILOCALE2Patch (const MIDILOCALE *pLocale) DECLSPEC_HIDDEN;
/* MIDILOCALE from dwPatch */
-extern void Patch2MIDILOCALE (DWORD dwPatch, LPMIDILOCALE pLocale);
+extern void Patch2MIDILOCALE (DWORD dwPatch, LPMIDILOCALE pLocale) DECLSPEC_HIDDEN;
/* check whether the given DWORD is even (return 0) or odd (return 1) */
-extern int even_or_odd (DWORD number);
+extern int even_or_odd (DWORD number) DECLSPEC_HIDDEN;
/* FOURCC to string conversion for debug messages */
-extern const char *debugstr_fourcc (DWORD fourcc);
+extern const char *debugstr_fourcc (DWORD fourcc) DECLSPEC_HIDDEN;
/* returns name of given GUID */
-extern const char *debugstr_dmguid (const GUID *id);
-/* dump whole DMUS_OBJECTDESC struct */
-extern const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc);
+extern const char *debugstr_dmguid (const GUID *id) DECLSPEC_HIDDEN;
+/* Dump whole DMUS_OBJECTDESC struct */
+extern void dump_DMUS_OBJECTDESC(LPDMUS_OBJECTDESC desc) DECLSPEC_HIDDEN;
+/* Dump whole DMUS_PORTPARAMS struct */
+extern void dump_DMUS_PORTPARAMS(LPDMUS_PORTPARAMS params) DECLSPEC_HIDDEN;
-#endif /* __WINE_DMUSIC_PRIVATE_H */
+#endif /* __WINE_DMUSIC_PRIVATE_H */
-/* IDirectMusicDownload Implementation
+/*
+ * IDirectMusicDownload Implementation
*
* Copyright (C) 2003-2004 Rok Mandeljc
*
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+static inline IDirectMusicDownloadImpl* impl_from_IDirectMusicDownload(IDirectMusicDownload *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectMusicDownloadImpl, IDirectMusicDownload_iface);
+}
+
/* IDirectMusicDownloadImpl IUnknown part: */
-static HRESULT WINAPI IDirectMusicDownloadImpl_QueryInterface (LPDIRECTMUSICDOWNLOAD iface, REFIID riid, LPVOID *ppobj) {
- IDirectMusicDownloadImpl *This = (IDirectMusicDownloadImpl *)iface;
- TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
-
- if (IsEqualIID (riid, &IID_IUnknown)
- || IsEqualIID (riid, &IID_IDirectMusicDownload)) {
- IUnknown_AddRef(iface);
- *ppobj = This;
- return S_OK;
- }
- WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
- return E_NOINTERFACE;
+static HRESULT WINAPI IDirectMusicDownloadImpl_QueryInterface(IDirectMusicDownload *iface, REFIID riid, void **ret_iface)
+{
+ TRACE("(%p, %s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
+
+ if (IsEqualIID(riid, &IID_IUnknown) ||
+ IsEqualIID(riid, &IID_IDirectMusicDownload))
+ {
+ IDirectMusicDownload_AddRef(iface);
+ *ret_iface = iface;
+ return S_OK;
+ }
+
+ *ret_iface = NULL;
+ WARN("(%p, %s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
+ return E_NOINTERFACE;
}
-static ULONG WINAPI IDirectMusicDownloadImpl_AddRef (LPDIRECTMUSICDOWNLOAD iface) {
- IDirectMusicDownloadImpl *This = (IDirectMusicDownloadImpl *)iface;
- ULONG refCount = InterlockedIncrement(&This->ref);
+static ULONG WINAPI IDirectMusicDownloadImpl_AddRef(IDirectMusicDownload *iface)
+{
+ IDirectMusicDownloadImpl *This = impl_from_IDirectMusicDownload(iface);
+ ULONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
+ TRACE("(%p)->(): new ref = %u\n", iface, ref);
- DMUSIC_LockModule();
+ DMUSIC_LockModule();
- return refCount;
+ return ref;
}
-static ULONG WINAPI IDirectMusicDownloadImpl_Release (LPDIRECTMUSICDOWNLOAD iface) {
- IDirectMusicDownloadImpl *This = (IDirectMusicDownloadImpl *)iface;
- ULONG refCount = InterlockedDecrement(&This->ref);
+static ULONG WINAPI IDirectMusicDownloadImpl_Release(IDirectMusicDownload *iface)
+{
+ IDirectMusicDownloadImpl *This = impl_from_IDirectMusicDownload(iface);
+ ULONG ref = InterlockedDecrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
+ TRACE("(%p)->(): new ref = %u\n", iface, ref);
- if (!refCount) {
- HeapFree(GetProcessHeap(), 0, This);
- }
+ if (!ref)
+ HeapFree(GetProcessHeap(), 0, This);
- DMUSIC_UnlockModule();
-
- return refCount;
+ DMUSIC_UnlockModule();
+
+ return ref;
}
/* IDirectMusicDownloadImpl IDirectMusicDownload part: */
-static HRESULT WINAPI IDirectMusicDownloadImpl_GetBuffer (LPDIRECTMUSICDOWNLOAD iface, void** ppvBuffer, DWORD* pdwSize) {
- IDirectMusicDownloadImpl *This = (IDirectMusicDownloadImpl *)iface;
- FIXME("(%p, %p, %p): stub\n", This, ppvBuffer, pdwSize);
- return S_OK;
+static HRESULT WINAPI IDirectMusicDownloadImpl_GetBuffer(IDirectMusicDownload *iface, void **buffer, DWORD *size)
+{
+ FIXME("(%p, %p, %p): stub\n", iface, buffer, size);
+
+ return S_OK;
}
static const IDirectMusicDownloadVtbl DirectMusicDownload_Vtbl = {
- IDirectMusicDownloadImpl_QueryInterface,
- IDirectMusicDownloadImpl_AddRef,
- IDirectMusicDownloadImpl_Release,
- IDirectMusicDownloadImpl_GetBuffer
+ IDirectMusicDownloadImpl_QueryInterface,
+ IDirectMusicDownloadImpl_AddRef,
+ IDirectMusicDownloadImpl_Release,
+ IDirectMusicDownloadImpl_GetBuffer
};
/* for ClassFactory */
-HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
- IDirectMusicDownloadImpl* dmdl;
-
- dmdl = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicDownloadImpl));
- if (NULL == dmdl) {
- *ppobj = NULL;
- return E_OUTOFMEMORY;
- }
- dmdl->lpVtbl = &DirectMusicDownload_Vtbl;
- dmdl->ref = 0; /* will be inited by QueryInterface */
-
- return IDirectMusicDownloadImpl_QueryInterface ((LPDIRECTMUSICDOWNLOAD)dmdl, lpcGUID, ppobj);
+HRESULT DMUSIC_CreateDirectMusicDownloadImpl(const GUID *guid, void **ret_iface, IUnknown *unk_outer)
+{
+ IDirectMusicDownloadImpl *download;
+
+ download = HeapAlloc(GetProcessHeap(), 0, sizeof(*download));
+ if (!download)
+ {
+ *ret_iface = NULL;
+ return E_OUTOFMEMORY;
+ }
+
+ download->IDirectMusicDownload_iface.lpVtbl = &DirectMusicDownload_Vtbl;
+ download->ref = 1;
+ *ret_iface = download;
+ return S_OK;
}
+++ /dev/null
-/* IDirectMusicDownloadedInstrument Implementation
- *
- * Copyright (C) 2003-2004 Rok Mandeljc
- *
- * This program 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 program 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 program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#include "dmusic_private.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
-
-/* IDirectMusicDownloadedInstrumentImpl IUnknown part: */
-static HRESULT WINAPI IDirectMusicDownloadedInstrumentImpl_QueryInterface (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface, REFIID riid, LPVOID *ppobj) {
- IDirectMusicDownloadedInstrumentImpl *This = (IDirectMusicDownloadedInstrumentImpl *)iface;
- TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
-
- if (IsEqualIID (riid, &IID_IUnknown)
- || IsEqualIID (riid, &IID_IDirectMusicDownloadedInstrument)
- || IsEqualIID (riid, &IID_IDirectMusicDownloadedInstrument8)) {
- IUnknown_AddRef(iface);
- *ppobj = This;
- return S_OK;
- }
- WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
- return E_NOINTERFACE;
-}
-
-static ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_AddRef (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface) {
- IDirectMusicDownloadedInstrumentImpl *This = (IDirectMusicDownloadedInstrumentImpl *)iface;
- ULONG refCount = InterlockedIncrement(&This->ref);
-
- TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
-
- DMUSIC_LockModule();
-
- return refCount;
-}
-
-static ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_Release (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface) {
- IDirectMusicDownloadedInstrumentImpl *This = (IDirectMusicDownloadedInstrumentImpl *)iface;
- ULONG refCount = InterlockedDecrement(&This->ref);
-
- TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
-
- if (!refCount) {
- HeapFree(GetProcessHeap(), 0, This);
- }
-
- DMUSIC_UnlockModule();
-
- return refCount;
-}
-
-/* IDirectMusicDownloadedInstrumentImpl IDirectMusicDownloadedInstrument part: */
-/* none at this time */
-
-static const IDirectMusicDownloadedInstrumentVtbl DirectMusicDownloadedInstrument_Vtbl = {
- IDirectMusicDownloadedInstrumentImpl_QueryInterface,
- IDirectMusicDownloadedInstrumentImpl_AddRef,
- IDirectMusicDownloadedInstrumentImpl_Release
-};
-
-/* for ClassFactory */
-HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadedInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
- IDirectMusicDownloadedInstrumentImpl* dmdlinst;
-
- dmdlinst = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicDownloadedInstrumentImpl));
- if (NULL == dmdlinst) {
- *ppobj = NULL;
- return E_OUTOFMEMORY;
- }
- dmdlinst->lpVtbl = &DirectMusicDownloadedInstrument_Vtbl;
- dmdlinst->ref = 0; /* will be inited by QueryInterface */
-
- return IDirectMusicDownloadedInstrumentImpl_QueryInterface ((LPDIRECTMUSICDOWNLOADEDINSTRUMENT)dmdlinst, lpcGUID, ppobj);
-}
-/* IDirectMusicInstrument Implementation
+/*
+ * IDirectMusicInstrument Implementation
*
* Copyright (C) 2003-2004 Rok Mandeljc
*
#include "dmusic_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
-WINE_DECLARE_DEBUG_CHANNEL(dmfile);
-static const GUID IID_IDirectMusicInstrumentPRIVATE = {0xbcb20080,0xa40c,0x11d1,{0x86,0xbc,0x00,0xc0,0x4f,0xbf,0x8f,0xef}};
-
-static ULONG WINAPI IDirectMusicInstrumentImpl_IUnknown_AddRef (LPUNKNOWN iface);
-static ULONG WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_AddRef (LPDIRECTMUSICINSTRUMENT iface);
+static const GUID IID_IDirectMusicInstrumentPRIVATE = { 0xbcb20080, 0xa40c, 0x11d1, { 0x86, 0xbc, 0x00, 0xc0, 0x4f, 0xbf, 0x8f, 0xef } };
/* IDirectMusicInstrument IUnknown part: */
-static HRESULT WINAPI IDirectMusicInstrumentImpl_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) {
- ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, UnknownVtbl, iface);
- TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
-
- if (IsEqualIID (riid, &IID_IUnknown)) {
- *ppobj = &This->UnknownVtbl;
- IDirectMusicInstrumentImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
- return S_OK;
- } else if (IsEqualIID (riid, &IID_IDirectMusicInstrument)) {
- *ppobj = &This->InstrumentVtbl;
- IDirectMusicInstrumentImpl_IDirectMusicInstrument_AddRef ((LPDIRECTMUSICINSTRUMENT)&This->InstrumentVtbl);
- return S_OK;
- } else if (IsEqualIID (riid, &IID_IDirectMusicInstrumentPRIVATE)) {
- /* it seems to me that this interface is only basic IUnknown, without any
- other inherited functions... *sigh* this is the worst scenario, since it means
- that whoever calls it knows the layout of original implementation table and therefore
- tries to get data by direct access... expect crashes */
- FIXME("*sigh*... requested private/unspecified interface\n");
- *ppobj = &This->UnknownVtbl;
- IDirectMusicInstrumentImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
- return S_OK;
- }
-
- WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
- return E_NOINTERFACE;
-}
+static HRESULT WINAPI IDirectMusicInstrumentImpl_QueryInterface(LPDIRECTMUSICINSTRUMENT iface, REFIID riid, LPVOID *ret_iface)
+{
+ TRACE("(%p)->(%s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
-static ULONG WINAPI IDirectMusicInstrumentImpl_IUnknown_AddRef (LPUNKNOWN iface) {
- ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, UnknownVtbl, iface);
- ULONG refCount = InterlockedIncrement(&This->ref);
+ if (IsEqualIID(riid, &IID_IUnknown) ||
+ IsEqualIID(riid, &IID_IDirectMusicInstrument))
+ {
+ *ret_iface = iface;
+ IDirectMusicInstrument_AddRef(iface);
+ return S_OK;
+ }
+ else if (IsEqualIID(riid, &IID_IDirectMusicInstrumentPRIVATE))
+ {
+ /* it seems to me that this interface is only basic IUnknown, without any
+ * other inherited functions... *sigh* this is the worst scenario, since it means
+ * that whoever calls it knows the layout of original implementation table and therefore
+ * tries to get data by direct access... expect crashes
+ */
+ FIXME("*sigh*... requested private/unspecified interface\n");
- TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
+ *ret_iface = iface;
+ IDirectMusicInstrument_AddRef(iface);
+ return S_OK;
+ }
- DMUSIC_LockModule();
+ WARN("(%p)->(%s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
- return refCount;
+ return E_NOINTERFACE;
}
-static ULONG WINAPI IDirectMusicInstrumentImpl_IUnknown_Release (LPUNKNOWN iface) {
- ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, UnknownVtbl, iface);
- ULONG refCount = InterlockedDecrement(&This->ref);
+static ULONG WINAPI IDirectMusicInstrumentImpl_AddRef(LPDIRECTMUSICINSTRUMENT iface)
+{
+ IDirectMusicInstrumentImpl *This = impl_from_IDirectMusicInstrument(iface);
+ ULONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
+ TRACE("(%p)->(): new ref = %u\n", iface, ref);
- if (!refCount) {
- HeapFree(GetProcessHeap(), 0, This);
- }
+ DMUSIC_LockModule();
- DMUSIC_UnlockModule();
-
- return refCount;
+ return ref;
}
-static const IUnknownVtbl DirectMusicInstrument_Unknown_Vtbl = {
- IDirectMusicInstrumentImpl_IUnknown_QueryInterface,
- IDirectMusicInstrumentImpl_IUnknown_AddRef,
- IDirectMusicInstrumentImpl_IUnknown_Release
-};
+static ULONG WINAPI IDirectMusicInstrumentImpl_Release(LPDIRECTMUSICINSTRUMENT iface)
+{
+ IDirectMusicInstrumentImpl *This = impl_from_IDirectMusicInstrument(iface);
+ ULONG ref = InterlockedDecrement(&This->ref);
-/* IDirectMusicInstrumentImpl IDirectMusicInstrument part: */
-static HRESULT WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_QueryInterface (LPDIRECTMUSICINSTRUMENT iface, REFIID riid, LPVOID *ppobj) {
- ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, InstrumentVtbl, iface);
- return IDirectMusicInstrumentImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
-}
+ TRACE("(%p)->(): new ref = %u\n", iface, ref);
-static ULONG WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_AddRef (LPDIRECTMUSICINSTRUMENT iface) {
- ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, InstrumentVtbl, iface);
- return IDirectMusicInstrumentImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
-}
+ if (!ref)
+ {
+ ULONG i;
+
+ HeapFree(GetProcessHeap(), 0, This->regions);
+ for (i = 0; i < This->nb_articulations; i++)
+ HeapFree(GetProcessHeap(), 0, This->articulations->connections);
+ HeapFree(GetProcessHeap(), 0, This->articulations);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+
+ DMUSIC_UnlockModule();
-static ULONG WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_Release (LPDIRECTMUSICINSTRUMENT iface) {
- ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, InstrumentVtbl, iface);
- return IDirectMusicInstrumentImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
+ return ref;
}
-static HRESULT WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_GetPatch (LPDIRECTMUSICINSTRUMENT iface, DWORD* pdwPatch) {
- ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, InstrumentVtbl, iface);
- TRACE("(%p, %p)\n", This, pdwPatch);
- *pdwPatch = MIDILOCALE2Patch(&This->pHeader->Locale);
- return S_OK;
+/* IDirectMusicInstrumentImpl IDirectMusicInstrument part: */
+static HRESULT WINAPI IDirectMusicInstrumentImpl_GetPatch(LPDIRECTMUSICINSTRUMENT iface, DWORD* pdwPatch)
+{
+ IDirectMusicInstrumentImpl *This = impl_from_IDirectMusicInstrument(iface);
+
+ TRACE("(%p)->(%p)\n", This, pdwPatch);
+
+ *pdwPatch = MIDILOCALE2Patch(&This->header.Locale);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_SetPatch (LPDIRECTMUSICINSTRUMENT iface, DWORD dwPatch) {
- ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, InstrumentVtbl, iface);
- TRACE("(%p, %d): stub\n", This, dwPatch);
- Patch2MIDILOCALE(dwPatch, &This->pHeader->Locale);
- return S_OK;
+static HRESULT WINAPI IDirectMusicInstrumentImpl_SetPatch(LPDIRECTMUSICINSTRUMENT iface, DWORD dwPatch)
+{
+ IDirectMusicInstrumentImpl *This = impl_from_IDirectMusicInstrument(iface);
+
+ TRACE("(%p)->(%d): stub\n", This, dwPatch);
+
+ Patch2MIDILOCALE(dwPatch, &This->header.Locale);
+
+ return S_OK;
}
-static const IDirectMusicInstrumentVtbl DirectMusicInstrument_Instrument_Vtbl = {
- IDirectMusicInstrumentImpl_IDirectMusicInstrument_QueryInterface,
- IDirectMusicInstrumentImpl_IDirectMusicInstrument_AddRef,
- IDirectMusicInstrumentImpl_IDirectMusicInstrument_Release,
- IDirectMusicInstrumentImpl_IDirectMusicInstrument_GetPatch,
- IDirectMusicInstrumentImpl_IDirectMusicInstrument_SetPatch
+static const IDirectMusicInstrumentVtbl DirectMusicInstrument_Vtbl =
+{
+ IDirectMusicInstrumentImpl_QueryInterface,
+ IDirectMusicInstrumentImpl_AddRef,
+ IDirectMusicInstrumentImpl_Release,
+ IDirectMusicInstrumentImpl_GetPatch,
+ IDirectMusicInstrumentImpl_SetPatch
};
/* for ClassFactory */
-HRESULT WINAPI DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
+HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
IDirectMusicInstrumentImpl* dminst;
dminst = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicInstrumentImpl));
*ppobj = NULL;
return E_OUTOFMEMORY;
}
- dminst->UnknownVtbl = &DirectMusicInstrument_Unknown_Vtbl;
- dminst->InstrumentVtbl = &DirectMusicInstrument_Instrument_Vtbl;
+ dminst->IDirectMusicInstrument_iface.lpVtbl = &DirectMusicInstrument_Vtbl;
dminst->ref = 0; /* will be inited by QueryInterface */
- return IDirectMusicInstrumentImpl_IUnknown_QueryInterface ((LPUNKNOWN)&dminst->UnknownVtbl, lpcGUID, ppobj);
+ return IDirectMusicInstrument_QueryInterface(&dminst->IDirectMusicInstrument_iface, lpcGUID, ppobj);
}
-/* aux. function that completely loads instrument; my tests indicate that it's
- called somewhere around IDirectMusicCollection_GetInstrument */
-HRESULT WINAPI IDirectMusicInstrumentImpl_Custom_Load (LPDIRECTMUSICINSTRUMENT iface, LPSTREAM pStm) {
- ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, InstrumentVtbl, iface);
-
- DMUS_PRIVATE_CHUNK Chunk;
- DWORD ListSize[4], ListCount[4];
- LARGE_INTEGER liMove; /* used when skipping chunks */
-
- TRACE("(%p, %p, offset = %s)\n", This, pStm, wine_dbgstr_longlong(This->liInstrumentPosition.QuadPart));
+static HRESULT read_from_stream(IStream *stream, void *data, ULONG size)
+{
+ ULONG bytes_read;
+ HRESULT hr;
- /* goto the beginning of chunk */
- IStream_Seek (pStm, This->liInstrumentPosition, STREAM_SEEK_SET, NULL);
-
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_LIST: {
- IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
- TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
- ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
- ListCount[0] = 0;
- switch (Chunk.fccID) {
- case FOURCC_INS: {
- TRACE_(dmfile)(": instrument list\n");
- do {
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_INSH: {
- TRACE_(dmfile)(": instrument header chunk\n");
- /* should be already initialised */
- IStream_Read (pStm, This->pHeader, Chunk.dwSize, NULL);
- break;
- }
- case FOURCC_DLID: {
- TRACE_(dmfile)(": DLID (GUID) chunk\n");
- /* should be already initialised */
- IStream_Read (pStm, This->pInstrumentID, Chunk.dwSize, NULL);
- break;
- }
- case FOURCC_LIST: {
- IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
- TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
- ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
- ListCount[1] = 0;
- switch (Chunk.fccID) {
- case FOURCC_LRGN: {
- TRACE_(dmfile)(": regions list\n");
- do {
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_LIST: {
- IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
- TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
- ListSize[2] = Chunk.dwSize - sizeof(FOURCC);
- ListCount[2] = 0;
- switch (Chunk.fccID) {
- case FOURCC_RGN: {
- /* temporary structures */
- RGNHEADER tmpRegionHeader;
- WSMPL tmpWaveSample;
- WLOOP tmpWaveLoop;
- WAVELINK tmpWaveLink;
-
- TRACE_(dmfile)(": region list\n");
- do {
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- ListCount[2] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_RGNH: {
- TRACE_(dmfile)(": region header chunk\n");
- memset (&tmpRegionHeader, 0, sizeof(RGNHEADER)); /* reset */
- IStream_Read (pStm, &tmpRegionHeader, Chunk.dwSize, NULL);
- break;
- }
- case FOURCC_WSMP: {
- TRACE_(dmfile)(": wave sample chunk\n");
- memset (&tmpWaveSample, 0, sizeof(WSMPL)); /* reset */
- memset (&tmpWaveLoop, 0, sizeof(WLOOP)); /* reset */
- if (Chunk.dwSize != (sizeof(WSMPL) + sizeof(WLOOP))) ERR(": incorrect chunk size\n");
- IStream_Read (pStm, &tmpWaveSample, sizeof(WSMPL), NULL);
- IStream_Read (pStm, &tmpWaveLoop, sizeof(WLOOP), NULL);
- break;
- }
- case FOURCC_WLNK: {
- TRACE_(dmfile)(": wave link chunk\n");
- memset (&tmpWaveLink, 0, sizeof(WAVELINK)); /* reset */
- IStream_Read (pStm, &tmpWaveLink, Chunk.dwSize, NULL);
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown (skipping)\n");
- liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": ListCount[2] = %d < ListSize[2] = %d\n", ListCount[2], ListSize[2]);
- } while (ListCount[2] < ListSize[2]);
- FIXME(": need to write temporary data to instrument data\n");
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown (skipping)\n");
- liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": ListCount[1] = %d < ListSize[1] = %d\n", ListCount[1], ListSize[1]);
- } while (ListCount[1] < ListSize[1]);
- break;
- }
- case FOURCC_LART: {
- TRACE_(dmfile)(": articulators list\n");
- do {
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_ART1: {
- /* temporary structures */
- CONNECTIONLIST tmpConnectionList;
- LPCONNECTION tmpConnections;
-
- TRACE_(dmfile)(": level 1 articulator chunk\n");
- memset (&tmpConnectionList, 0, sizeof(CONNECTIONLIST)); /* reset */
- tmpConnections = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(CONNECTION)*tmpConnectionList.cConnections);
- if (Chunk.dwSize != (sizeof(CONNECTIONLIST) + sizeof(CONNECTION)*tmpConnectionList.cConnections)) ERR(": incorrect chunk size\n");
- IStream_Read (pStm, &tmpConnectionList, sizeof(CONNECTIONLIST), NULL);
- IStream_Read (pStm, tmpConnections, sizeof(CONNECTION)*tmpConnectionList.cConnections, NULL);
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": ListCount[1] = %d < ListSize[1] = %d\n", ListCount[1], ListSize[1]);
- } while (ListCount[1] < ListSize[1]);
- break;
- }
- case mmioFOURCC('I','N','F','O'): {
- TRACE_(dmfile)(": INFO list\n");
- do {
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case mmioFOURCC('I','N','A','M'): {
- TRACE_(dmfile)(": name chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[1] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- case mmioFOURCC('I','A','R','T'): {
- TRACE_(dmfile)(": artist chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[1] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- case mmioFOURCC('I','C','O','P'): {
- /* temporary structures */
- CHAR tmpCopyright[DMUS_MAX_NAME];
-
- TRACE_(dmfile)(": copyright chunk\n");
- IStream_Read (pStm, tmpCopyright, Chunk.dwSize, NULL);
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[1] ++;
- liMove.QuadPart = 1;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- }
- break;
- }
- case mmioFOURCC('I','S','B','J'): {
- TRACE_(dmfile)(": subject chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[1] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- case mmioFOURCC('I','C','M','T'): {
- TRACE_(dmfile)(": comment chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[1] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[1] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": ListCount[1] = %d < ListSize[1] = %d\n", ListCount[1], ListSize[1]);
- } while (ListCount[1] < ListSize[1]);
- break;
- }
-
- default: {
- TRACE_(dmfile)(": unknown (skipping)\n");
- liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
- } while (ListCount[0] < ListSize[0]);
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- break;
- }
- default: {
- TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
- return E_FAIL;
- }
- }
- /* DEBUG: dumps whole instrument object tree: */
-/* if (TRACE_ON(dmusic)) {
- TRACE("*** IDirectMusicInstrument (%p) ***\n", This);
- if (This->pInstrumentID)
- TRACE(" - GUID = %s\n", debugstr_dmguid(This->pInstrumentID));
-
- TRACE(" - Instrument header:\n");
- TRACE(" - cRegions: %ld\n", This->pHeader->cRegions);
- TRACE(" - Locale:\n");
- TRACE(" - ulBank: %ld\n", This->pHeader->Locale.ulBank);
- TRACE(" - ulInstrument: %ld\n", This->pHeader->Locale.ulInstrument);
- TRACE(" => dwPatch: %ld\n", MIDILOCALE2Patch(&This->pHeader->Locale));
- }*/
-
- return S_OK;
+ hr = IStream_Read(stream, data, size, &bytes_read);
+ if(FAILED(hr)){
+ TRACE("IStream_Read failed: %08x\n", hr);
+ return hr;
+ }
+ if (bytes_read < size) {
+ TRACE("Didn't read full chunk: %u < %u\n", bytes_read, size);
+ return E_FAIL;
+ }
+
+ return S_OK;
+}
+
+static inline DWORD subtract_bytes(DWORD len, DWORD bytes)
+{
+ if(bytes > len){
+ TRACE("Apparent mismatch in chunk lengths? %u bytes remaining, %u bytes read\n", len, bytes);
+ return 0;
+ }
+ return len - bytes;
+}
+
+static inline HRESULT advance_stream(IStream *stream, ULONG bytes)
+{
+ LARGE_INTEGER move;
+ HRESULT ret;
+
+ move.QuadPart = bytes;
+
+ ret = IStream_Seek(stream, move, STREAM_SEEK_CUR, NULL);
+ if (FAILED(ret))
+ WARN("IStream_Seek failed: %08x\n", ret);
+
+ return ret;
+}
+
+static HRESULT load_region(IDirectMusicInstrumentImpl *This, IStream *stream, instrument_region *region, ULONG length)
+{
+ HRESULT ret;
+ DMUS_PRIVATE_CHUNK chunk;
+
+ TRACE("(%p, %p, %p, %u)\n", This, stream, region, length);
+
+ while (length)
+ {
+ ret = read_from_stream(stream, &chunk, sizeof(chunk));
+ if (FAILED(ret))
+ return ret;
+
+ length = subtract_bytes(length, sizeof(chunk));
+
+ switch (chunk.fccID)
+ {
+ case FOURCC_RGNH:
+ TRACE("RGNH chunk (region header): %u bytes\n", chunk.dwSize);
+
+ ret = read_from_stream(stream, ®ion->header, sizeof(region->header));
+ if (FAILED(ret))
+ return ret;
+
+ length = subtract_bytes(length, sizeof(region->header));
+ break;
+
+ case FOURCC_WSMP:
+ TRACE("WSMP chunk (wave sample): %u bytes\n", chunk.dwSize);
+
+ ret = read_from_stream(stream, ®ion->wave_sample, sizeof(region->wave_sample));
+ if (FAILED(ret))
+ return ret;
+ length = subtract_bytes(length, sizeof(region->wave_sample));
+
+ if (!(region->loop_present = (chunk.dwSize != sizeof(region->wave_sample))))
+ break;
+
+ ret = read_from_stream(stream, ®ion->wave_loop, sizeof(region->wave_loop));
+ if (FAILED(ret))
+ return ret;
+
+ length = subtract_bytes(length, sizeof(region->wave_loop));
+ break;
+
+ case FOURCC_WLNK:
+ TRACE("WLNK chunk (wave link): %u bytes\n", chunk.dwSize);
+
+ ret = read_from_stream(stream, ®ion->wave_link, sizeof(region->wave_link));
+ if (FAILED(ret))
+ return ret;
+
+ length = subtract_bytes(length, sizeof(region->wave_link));
+ break;
+
+ default:
+ TRACE("Unknown chunk %s (skipping): %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+
+ ret = advance_stream(stream, chunk.dwSize);
+ if (FAILED(ret))
+ return ret;
+
+ length = subtract_bytes(length, chunk.dwSize);
+ break;
+ }
+ }
+
+ return S_OK;
+}
+
+static HRESULT load_articulation(IDirectMusicInstrumentImpl *This, IStream *stream, ULONG length)
+{
+ HRESULT ret;
+ instrument_articulation *articulation;
+
+ if (!This->articulations)
+ This->articulations = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->articulations));
+ else
+ This->articulations = HeapReAlloc(GetProcessHeap(), 0, This->articulations, sizeof(*This->articulations) * (This->nb_articulations + 1));
+ if (!This->articulations)
+ return E_OUTOFMEMORY;
+
+ articulation = &This->articulations[This->nb_articulations];
+
+ ret = read_from_stream(stream, &articulation->connections_list, sizeof(CONNECTIONLIST));
+ if (FAILED(ret))
+ return ret;
+
+ articulation->connections = HeapAlloc(GetProcessHeap(), 0, sizeof(CONNECTION) * articulation->connections_list.cConnections);
+ if (!articulation->connections)
+ return E_OUTOFMEMORY;
+
+ ret = read_from_stream(stream, articulation->connections, sizeof(CONNECTION) * articulation->connections_list.cConnections);
+ if (FAILED(ret))
+ {
+ HeapFree(GetProcessHeap(), 0, articulation->connections);
+ return ret;
+ }
+
+ subtract_bytes(length, sizeof(CONNECTIONLIST) + sizeof(CONNECTION) * articulation->connections_list.cConnections);
+
+ This->nb_articulations++;
+
+ return S_OK;
+}
+
+/* Function that loads all instrument data and which is called from IDirectMusicCollection_GetInstrument as in native */
+HRESULT IDirectMusicInstrumentImpl_CustomLoad(IDirectMusicInstrument *iface, IStream *stream)
+{
+ IDirectMusicInstrumentImpl *This = impl_from_IDirectMusicInstrument(iface);
+ HRESULT hr;
+ DMUS_PRIVATE_CHUNK chunk;
+ ULONG i = 0;
+ ULONG length = This->length;
+
+ TRACE("(%p, %p): offset = 0x%s, length = %u)\n", This, stream, wine_dbgstr_longlong(This->liInstrumentPosition.QuadPart), This->length);
+
+ if (This->loaded)
+ return S_OK;
+
+ hr = IStream_Seek(stream, This->liInstrumentPosition, STREAM_SEEK_SET, NULL);
+ if (FAILED(hr))
+ {
+ WARN("IStream_Seek failed: %08x\n", hr);
+ return DMUS_E_UNSUPPORTED_STREAM;
+ }
+
+ This->regions = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->regions) * This->header.cRegions);
+ if (!This->regions)
+ return E_OUTOFMEMORY;
+
+ while (length)
+ {
+ hr = read_from_stream(stream, &chunk, sizeof(chunk));
+ if (FAILED(hr))
+ goto error;
+
+ length = subtract_bytes(length, sizeof(chunk) + chunk.dwSize);
+
+ switch (chunk.fccID)
+ {
+ case FOURCC_INSH:
+ case FOURCC_DLID:
+ TRACE("Chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+
+ /* Instrument header and id are already set so just skip */
+ hr = advance_stream(stream, chunk.dwSize);
+ if (FAILED(hr))
+ goto error;
+
+ break;
+
+ case FOURCC_LIST: {
+ DWORD size = chunk.dwSize;
+
+ TRACE("LIST chunk: %u bytes\n", chunk.dwSize);
+
+ hr = read_from_stream(stream, &chunk.fccID, sizeof(chunk.fccID));
+ if (FAILED(hr))
+ goto error;
+
+ size = subtract_bytes(size, sizeof(chunk.fccID));
+
+ switch (chunk.fccID)
+ {
+ case FOURCC_LRGN:
+ TRACE("LRGN chunk (regions list): %u bytes\n", size);
+
+ while (size)
+ {
+ hr = read_from_stream(stream, &chunk, sizeof(chunk));
+ if (FAILED(hr))
+ goto error;
+
+ if (chunk.fccID != FOURCC_LIST)
+ {
+ TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+ goto error;
+ }
+
+ hr = read_from_stream(stream, &chunk.fccID, sizeof(chunk.fccID));
+ if (FAILED(hr))
+ goto error;
+
+ if (chunk.fccID == FOURCC_RGN)
+ {
+ TRACE("RGN chunk (region): %u bytes\n", chunk.dwSize);
+ hr = load_region(This, stream, &This->regions[i++], chunk.dwSize - sizeof(chunk.fccID));
+ }
+ else
+ {
+ TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+ hr = advance_stream(stream, chunk.dwSize - sizeof(chunk.fccID));
+ }
+ if (FAILED(hr))
+ goto error;
+
+ size = subtract_bytes(size, chunk.dwSize + sizeof(chunk));
+ }
+ break;
+
+ case FOURCC_LART:
+ TRACE("LART chunk (articulations list): %u bytes\n", size);
+
+ while (size)
+ {
+ hr = read_from_stream(stream, &chunk, sizeof(chunk));
+ if (FAILED(hr))
+ goto error;
+
+ if (chunk.fccID == FOURCC_ART1)
+ {
+ TRACE("ART1 chunk (level 1 articulation): %u bytes\n", chunk.dwSize);
+ hr = load_articulation(This, stream, chunk.dwSize);
+ }
+ else
+ {
+ TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+ hr = advance_stream(stream, chunk.dwSize);
+ }
+ if (FAILED(hr))
+ goto error;
+
+ size = subtract_bytes(size, chunk.dwSize + sizeof(chunk));
+ }
+ break;
+
+ default:
+ TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+
+ hr = advance_stream(stream, chunk.dwSize - sizeof(chunk.fccID));
+ if (FAILED(hr))
+ goto error;
+
+ size = subtract_bytes(size, chunk.dwSize - sizeof(chunk.fccID));
+ break;
+ }
+ break;
+ }
+
+ default:
+ TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+
+ hr = advance_stream(stream, chunk.dwSize);
+ if (FAILED(hr))
+ goto error;
+
+ break;
+ }
+ }
+
+ This->loaded = TRUE;
+
+ return S_OK;
+
+error:
+ HeapFree(GetProcessHeap(), 0, This->regions);
+ This->regions = NULL;
+
+ return DMUS_E_UNSUPPORTED_STREAM;
}
-/* IDirectMusicPort Implementation
+/*
+ * IDirectMusicPort Implementation
*
* Copyright (C) 2003-2004 Rok Mandeljc
+ * Copyright (C) 2012 Christian Costa
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include <assert.h>
#include "dmusic_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
-/* IDirectMusicPortImpl IUnknown part: */
-static HRESULT WINAPI IDirectMusicPortImpl_QueryInterface (LPDIRECTMUSICPORT iface, REFIID riid, LPVOID *ppobj) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpVtbl, iface);
-
- TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
-
- if (IsEqualIID (riid, &IID_IUnknown) ||
- IsEqualGUID(riid, &IID_IDirectMusicPort) ||
- IsEqualGUID(riid, &IID_IDirectMusicPort8)) {
- *ppobj = &This->lpVtbl;
- IDirectMusicPort_AddRef((LPDIRECTMUSICPORT)*ppobj);
- return S_OK;
- } else if (IsEqualGUID(riid, &IID_IDirectMusicPortDownload) ||
- IsEqualGUID(riid, &IID_IDirectMusicPortDownload8)) {
- *ppobj = &This->lpDownloadVtbl;
- IDirectMusicPortDownload_AddRef((LPDIRECTMUSICPORTDOWNLOAD)*ppobj);
- return S_OK;
- } else if (IsEqualGUID(riid, &IID_IDirectMusicThru) ||
- IsEqualGUID(riid, &IID_IDirectMusicThru8)) {
- *ppobj = &This->lpThruVtbl;
- IDirectMusicThru_AddRef((LPDIRECTMUSICTHRU)*ppobj);
- return S_OK;
- }
- WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
- return E_NOINTERFACE;
+static inline IDirectMusicDownloadedInstrumentImpl* impl_from_IDirectMusicDownloadedInstrument(IDirectMusicDownloadedInstrument *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectMusicDownloadedInstrumentImpl, IDirectMusicDownloadedInstrument_iface);
+}
+
+static inline SynthPortImpl *impl_from_SynthPortImpl_IDirectMusicPort(IDirectMusicPort *iface)
+{
+ return CONTAINING_RECORD(iface, SynthPortImpl, IDirectMusicPort_iface);
+}
+
+static inline SynthPortImpl *impl_from_SynthPortImpl_IDirectMusicPortDownload(IDirectMusicPortDownload *iface)
+{
+ return CONTAINING_RECORD(iface, SynthPortImpl, IDirectMusicPortDownload_iface);
}
-static ULONG WINAPI IDirectMusicPortImpl_AddRef (LPDIRECTMUSICPORT iface) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- ULONG refCount = InterlockedIncrement(&This->ref);
+static inline SynthPortImpl *impl_from_SynthPortImpl_IDirectMusicThru(IDirectMusicThru *iface)
+{
+ return CONTAINING_RECORD(iface, SynthPortImpl, IDirectMusicThru_iface);
+}
+
+/* IDirectMusicDownloadedInstrument IUnknown part follows: */
+static HRESULT WINAPI IDirectMusicDownloadedInstrumentImpl_QueryInterface(IDirectMusicDownloadedInstrument *iface, REFIID riid, VOID **ret_iface)
+{
+ TRACE("(%p, %s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
- TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
+ if (IsEqualIID(riid, &IID_IUnknown) ||
+ IsEqualIID(riid, &IID_IDirectMusicDownloadedInstrument) ||
+ IsEqualIID(riid, &IID_IDirectMusicDownloadedInstrument8))
+ {
+ IDirectMusicDownloadedInstrument_AddRef(iface);
+ *ret_iface = iface;
+ return S_OK;
+ }
- DMUSIC_LockModule();
+ WARN("(%p, %s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
- return refCount;
+ return E_NOINTERFACE;
}
-static ULONG WINAPI IDirectMusicPortImpl_Release (LPDIRECTMUSICPORT iface) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- ULONG refCount = InterlockedDecrement(&This->ref);
+static ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_AddRef(LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface)
+{
+ IDirectMusicDownloadedInstrumentImpl *This = impl_from_IDirectMusicDownloadedInstrument(iface);
+ ULONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
+ TRACE("(%p)->(): new ref = %u\n", iface, ref);
- if (!refCount) {
- HeapFree(GetProcessHeap(), 0, This);
- }
+ DMUSIC_LockModule();
+
+ return ref;
+}
- DMUSIC_UnlockModule();
+static ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_Release(LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface)
+{
+ IDirectMusicDownloadedInstrumentImpl *This = impl_from_IDirectMusicDownloadedInstrument(iface);
+ ULONG ref = InterlockedDecrement(&This->ref);
- return refCount;
+ TRACE("(%p)->(): new ref = %u\n", iface, ref);
+
+ if (!ref)
+ {
+ HeapFree(GetProcessHeap(), 0, This->data);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+
+ DMUSIC_UnlockModule();
+
+ return ref;
}
-/* IDirectMusicPortImpl IDirectMusicPort part: */
-static HRESULT WINAPI IDirectMusicPortImpl_PlayBuffer (LPDIRECTMUSICPORT iface, LPDIRECTMUSICBUFFER pBuffer) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p, %p): stub\n", This, pBuffer);
- return S_OK;
+static const IDirectMusicDownloadedInstrumentVtbl DirectMusicDownloadedInstrument_Vtbl = {
+ IDirectMusicDownloadedInstrumentImpl_QueryInterface,
+ IDirectMusicDownloadedInstrumentImpl_AddRef,
+ IDirectMusicDownloadedInstrumentImpl_Release
+};
+
+static inline IDirectMusicDownloadedInstrumentImpl* unsafe_impl_from_IDirectMusicDownloadedInstrument(IDirectMusicDownloadedInstrument *iface)
+{
+ if (!iface)
+ return NULL;
+ assert(iface->lpVtbl == &DirectMusicDownloadedInstrument_Vtbl);
+
+ return impl_from_IDirectMusicDownloadedInstrument(iface);
}
-static HRESULT WINAPI IDirectMusicPortImpl_SetReadNotificationHandle (LPDIRECTMUSICPORT iface, HANDLE hEvent) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p, %p): stub\n", This, hEvent);
- return S_OK;
+HRESULT DMUSIC_CreateDirectMusicDownloadedInstrumentImpl(IDirectMusicDownloadedInstrument **instrument)
+{
+ IDirectMusicDownloadedInstrumentImpl *object;
+
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ if (!object)
+ {
+ *instrument = NULL;
+ return E_OUTOFMEMORY;
+ }
+
+ object->IDirectMusicDownloadedInstrument_iface.lpVtbl = &DirectMusicDownloadedInstrument_Vtbl;
+ object->ref = 1;
+
+ *instrument = &object->IDirectMusicDownloadedInstrument_iface;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortImpl_Read (LPDIRECTMUSICPORT iface, LPDIRECTMUSICBUFFER pBuffer) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p, %p): stub\n", This, pBuffer);
- return S_OK;
+/* SynthPortImpl IDirectMusicPort IUnknown part follows: */
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_QueryInterface(LPDIRECTMUSICPORT iface, REFIID riid, LPVOID *ret_iface)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ TRACE("(%p/%p)->(%s, %p)\n", iface, This, debugstr_dmguid(riid), ret_iface);
+
+ if (IsEqualIID (riid, &IID_IUnknown) ||
+ IsEqualGUID(riid, &IID_IDirectMusicPort) ||
+ IsEqualGUID(riid, &IID_IDirectMusicPort8)) {
+ *ret_iface = &This->IDirectMusicPort_iface;
+ IDirectMusicPort_AddRef((LPDIRECTMUSICPORT)*ret_iface);
+ return S_OK;
+ } else if (IsEqualGUID(riid, &IID_IDirectMusicPortDownload) ||
+ IsEqualGUID(riid, &IID_IDirectMusicPortDownload8)) {
+ *ret_iface = &This->IDirectMusicPortDownload_iface;
+ IDirectMusicPortDownload_AddRef((LPDIRECTMUSICPORTDOWNLOAD)*ret_iface);
+ return S_OK;
+ } else if (IsEqualGUID(riid, &IID_IDirectMusicThru) ||
+ IsEqualGUID(riid, &IID_IDirectMusicThru8)) {
+ *ret_iface = &This->IDirectMusicThru_iface;
+ IDirectMusicThru_AddRef((LPDIRECTMUSICTHRU)*ret_iface);
+ return S_OK;
+ }
+
+ WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);
+
+ return E_NOINTERFACE;
}
-static HRESULT WINAPI IDirectMusicPortImpl_DownloadInstrument (LPDIRECTMUSICPORT iface, IDirectMusicInstrument* pInstrument, IDirectMusicDownloadedInstrument** ppDownloadedInstrument, DMUS_NOTERANGE* pNoteRanges, DWORD dwNumNoteRanges) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
+static ULONG WINAPI SynthPortImpl_IDirectMusicPort_AddRef(LPDIRECTMUSICPORT iface)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+ ULONG ref = InterlockedIncrement(&This->ref);
- FIXME("(%p, %p, %p, %p, %d): stub\n", This, pInstrument, ppDownloadedInstrument, pNoteRanges, dwNumNoteRanges);
+ TRACE("(%p)->(): new ref = %u\n", This, ref);
- if (!pInstrument || !ppDownloadedInstrument || (dwNumNoteRanges && !pNoteRanges))
- return E_POINTER;
+ DMUSIC_LockModule();
- return DMUSIC_CreateDirectMusicDownloadedInstrumentImpl(&IID_IDirectMusicDownloadedInstrument, (LPVOID*)ppDownloadedInstrument, NULL);
+ return ref;
}
-static HRESULT WINAPI IDirectMusicPortImpl_UnloadInstrument (LPDIRECTMUSICPORT iface, IDirectMusicDownloadedInstrument *pDownloadedInstrument) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p, %p): stub\n", This, pDownloadedInstrument);
- return S_OK;
+static ULONG WINAPI SynthPortImpl_IDirectMusicPort_Release(LPDIRECTMUSICPORT iface)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+ ULONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p)->(): new ref = %u\n", This, ref);
+
+ if (!ref)
+ {
+ IDirectMusicSynth_Activate(This->synth, FALSE);
+ IDirectMusicSynth_Close(This->synth);
+ IDirectMusicSynth_Release(This->synth);
+ IDirectMusicSynthSink_Release(This->synth_sink);
+ IReferenceClock_Release(This->pLatencyClock);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+
+ DMUSIC_UnlockModule();
+
+ return ref;
}
-static HRESULT WINAPI IDirectMusicPortImpl_GetLatencyClock (LPDIRECTMUSICPORT iface, IReferenceClock** ppClock) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- TRACE("(%p, %p)\n", This, ppClock);
- *ppClock = This->pLatencyClock;
- IReferenceClock_AddRef (*ppClock);
- return S_OK;
+/* SynthPortImpl IDirectMusicPort interface follows: */
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_PlayBuffer(LPDIRECTMUSICPORT iface, LPDIRECTMUSICBUFFER buffer)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+ HRESULT hr;
+ REFERENCE_TIME time;
+ LPBYTE data;
+ DWORD size;
+
+ TRACE("(%p/%p)->(%p)\n", iface, This, buffer);
+
+ if (!buffer)
+ return E_POINTER;
+
+ hr = IDirectMusicBuffer_GetStartTime(buffer, &time);
+
+ if (SUCCEEDED(hr))
+ hr = IDirectMusicBuffer_GetRawBufferPtr(buffer, &data);
+
+ if (SUCCEEDED(hr))
+ hr = IDirectMusicBuffer_GetUsedBytes(buffer, &size);
+
+ if (SUCCEEDED(hr))
+ hr = IDirectMusicSynth_PlayBuffer(This->synth, time, data, size);
+
+ return hr;
}
-static HRESULT WINAPI IDirectMusicPortImpl_GetRunningStats (LPDIRECTMUSICPORT iface, LPDMUS_SYNTHSTATS pStats) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p, %p): stub\n", This, pStats);
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_SetReadNotificationHandle(LPDIRECTMUSICPORT iface, HANDLE event)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ FIXME("(%p/%p)->(%p): stub\n", iface, This, event);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortImpl_Compact (LPDIRECTMUSICPORT iface) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p): stub\n", This);
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_Read(LPDIRECTMUSICPORT iface, LPDIRECTMUSICBUFFER buffer)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ FIXME("(%p/%p)->(%p): stub\n", iface, This, buffer);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortImpl_GetCaps (LPDIRECTMUSICPORT iface, LPDMUS_PORTCAPS pPortCaps) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- TRACE("(%p, %p)\n", This, pPortCaps);
- *pPortCaps = This->caps;
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_DownloadInstrument(LPDIRECTMUSICPORT iface, IDirectMusicInstrument* instrument, IDirectMusicDownloadedInstrument** downloaded_instrument, DMUS_NOTERANGE* note_ranges, DWORD num_note_ranges)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+ IDirectMusicInstrumentImpl *instrument_object;
+ HRESULT ret;
+ BOOL free;
+ HANDLE download;
+ DMUS_DOWNLOADINFO *info;
+ DMUS_OFFSETTABLE *offset_table;
+ DMUS_INSTRUMENT *instrument_info;
+ BYTE *data;
+ ULONG offset;
+ ULONG nb_regions;
+ ULONG size;
+ ULONG i;
+
+ TRACE("(%p/%p)->(%p, %p, %p, %d)\n", iface, This, instrument, downloaded_instrument, note_ranges, num_note_ranges);
+
+ if (!instrument || !downloaded_instrument || (num_note_ranges && !note_ranges))
+ return E_POINTER;
+
+ instrument_object = impl_from_IDirectMusicInstrument(instrument);
+
+ nb_regions = instrument_object->header.cRegions;
+ size = sizeof(DMUS_DOWNLOADINFO) + sizeof(ULONG) * (1 + nb_regions) + sizeof(DMUS_INSTRUMENT) + sizeof(DMUS_REGION) * nb_regions;
+
+ data = (BYTE*)HeapAlloc(GetProcessHeap(), 0, size);
+ if (!data)
+ return E_OUTOFMEMORY;
+
+ info = (DMUS_DOWNLOADINFO*)data;
+ offset_table = (DMUS_OFFSETTABLE*)(data + sizeof(DMUS_DOWNLOADINFO));
+ offset = sizeof(DMUS_DOWNLOADINFO) + sizeof(ULONG) * (1 + nb_regions);
+
+ info->dwDLType = DMUS_DOWNLOADINFO_INSTRUMENT2;
+ info->dwDLId = 0;
+ info->dwNumOffsetTableEntries = 1 + instrument_object->header.cRegions;
+ info->cbSize = size;
+
+ offset_table->ulOffsetTable[0] = offset;
+ instrument_info = (DMUS_INSTRUMENT*)(data + offset);
+ offset += sizeof(DMUS_INSTRUMENT);
+ instrument_info->ulPatch = MIDILOCALE2Patch(&instrument_object->header.Locale);
+ instrument_info->ulFirstRegionIdx = 1;
+ instrument_info->ulGlobalArtIdx = 0; /* FIXME */
+ instrument_info->ulFirstExtCkIdx = 0; /* FIXME */
+ instrument_info->ulCopyrightIdx = 0; /* FIXME */
+ instrument_info->ulFlags = 0; /* FIXME */
+
+ for (i = 0; i < nb_regions; i++)
+ {
+ DMUS_REGION *region = (DMUS_REGION*)(data + offset);
+
+ offset_table->ulOffsetTable[1 + i] = offset;
+ offset += sizeof(DMUS_REGION);
+ region->RangeKey = instrument_object->regions[i].header.RangeKey;
+ region->RangeVelocity = instrument_object->regions[i].header.RangeVelocity;
+ region->fusOptions = instrument_object->regions[i].header.fusOptions;
+ region->usKeyGroup = instrument_object->regions[i].header.usKeyGroup;
+ region->ulRegionArtIdx = 0; /* FIXME */
+ region->ulNextRegionIdx = i != (nb_regions - 1) ? (i + 2) : 0;
+ region->ulFirstExtCkIdx = 0; /* FIXME */
+ region->WaveLink = instrument_object->regions[i].wave_link;
+ region->WSMP = instrument_object->regions[i].wave_sample;
+ region->WLOOP[0] = instrument_object->regions[i].wave_loop;
+ }
+
+ ret = IDirectMusicSynth8_Download(This->synth, &download, (VOID*)data, &free);
+
+ if (SUCCEEDED(ret))
+ ret = DMUSIC_CreateDirectMusicDownloadedInstrumentImpl(downloaded_instrument);
+
+ if (SUCCEEDED(ret))
+ {
+ IDirectMusicDownloadedInstrumentImpl *downloaded_object = impl_from_IDirectMusicDownloadedInstrument(*downloaded_instrument);
+
+ downloaded_object->data = data;
+ downloaded_object->downloaded = TRUE;
+ }
+
+ *downloaded_instrument = NULL;
+ HeapFree(GetProcessHeap(), 0, data);
+
+ return E_FAIL;
}
-static HRESULT WINAPI IDirectMusicPortImpl_DeviceIoControl (LPDIRECTMUSICPORT iface, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p, %d, %p, %d, %p, %d, %p, %p): stub\n", This, dwIoControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpOverlapped);
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_UnloadInstrument(LPDIRECTMUSICPORT iface, IDirectMusicDownloadedInstrument *downloaded_instrument)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+ IDirectMusicDownloadedInstrumentImpl *downloaded_object = unsafe_impl_from_IDirectMusicDownloadedInstrument(downloaded_instrument);
+
+ TRACE("(%p/%p)->(%p)\n", iface, This, downloaded_instrument);
+
+ if (!downloaded_instrument)
+ return E_POINTER;
+
+ if (!downloaded_object->downloaded)
+ return DMUS_E_NOT_DOWNLOADED_TO_PORT;
+
+ HeapFree(GetProcessHeap(), 0, downloaded_object->data);
+ downloaded_object->data = NULL;
+ downloaded_object->downloaded = FALSE;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortImpl_SetNumChannelGroups (LPDIRECTMUSICPORT iface, DWORD dwChannelGroups) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p, %d): semi-stub\n", This, dwChannelGroups);
- This->nrofgroups = dwChannelGroups;
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetLatencyClock(LPDIRECTMUSICPORT iface, IReferenceClock** clock)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ TRACE("(%p/%p)->(%p)\n", iface, This, clock);
+
+ *clock = This->pLatencyClock;
+ IReferenceClock_AddRef(*clock);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortImpl_GetNumChannelGroups (LPDIRECTMUSICPORT iface, LPDWORD pdwChannelGroups) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- TRACE("(%p, %p)\n", This, pdwChannelGroups);
- *pdwChannelGroups = This->nrofgroups;
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetRunningStats(LPDIRECTMUSICPORT iface, LPDMUS_SYNTHSTATS stats)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ FIXME("(%p/%p)->(%p): stub\n", iface, This, stats);
+
+ return S_OK;
}
-HRESULT WINAPI IDirectMusicPortImpl_Activate (LPDIRECTMUSICPORT iface, BOOL fActive) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- TRACE("(%p, %d)\n", This, fActive);
- This->fActive = fActive;
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_Compact(LPDIRECTMUSICPORT iface)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ FIXME("(%p/%p)->(): stub\n", iface, This);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortImpl_SetChannelPriority (LPDIRECTMUSICPORT iface, DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p, %d, %d, %d): semi-stub\n", This, dwChannelGroup, dwChannel, dwPriority);
- if (dwChannel > 16) {
- WARN("isn't there supposed to be 16 channels (no. %d requested)?! (faking as it is ok)\n", dwChannel);
- /*return E_INVALIDARG;*/
- }
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetCaps(LPDIRECTMUSICPORT iface, LPDMUS_PORTCAPS port_caps)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ TRACE("(%p/%p)->(%p)\n", iface, This, port_caps);
+
+ *port_caps = This->caps;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortImpl_GetChannelPriority (LPDIRECTMUSICPORT iface, DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwPriority) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- TRACE("(%p, %d, %d, %p)\n", This, dwChannelGroup, dwChannel, pdwPriority);
- *pdwPriority = This->group[dwChannelGroup-1].channel[dwChannel].priority;
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_DeviceIoControl(LPDIRECTMUSICPORT iface, DWORD io_control_code, LPVOID in_buffer, DWORD in_buffer_size,
+ LPVOID out_buffer, DWORD out_buffer_size, LPDWORD bytes_returned, LPOVERLAPPED overlapped)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ FIXME("(%p/%p)->(%d, %p, %d, %p, %d, %p, %p): stub\n", iface, This, io_control_code, in_buffer, in_buffer_size, out_buffer, out_buffer_size, bytes_returned, overlapped);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortImpl_SetDirectSound (LPDIRECTMUSICPORT iface, LPDIRECTSOUND pDirectSound, LPDIRECTSOUNDBUFFER pDirectSoundBuffer) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p, %p, %p): stub\n", This, pDirectSound, pDirectSoundBuffer);
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_SetNumChannelGroups(LPDIRECTMUSICPORT iface, DWORD channel_groups)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ FIXME("(%p/%p)->(%d): semi-stub\n", iface, This, channel_groups);
+
+ This->nrofgroups = channel_groups;
+
+ return S_OK;
+}
+
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetNumChannelGroups(LPDIRECTMUSICPORT iface, LPDWORD channel_groups)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ TRACE("(%p/%p)->(%p)\n", iface, This, channel_groups);
+
+ *channel_groups = This->nrofgroups;
+
+ return S_OK;
+}
+
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_Activate(LPDIRECTMUSICPORT iface, BOOL active)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ TRACE("(%p/%p)->(%d)\n", iface, This, active);
+
+ This->fActive = active;
+
+ return S_OK;
+}
+
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_SetChannelPriority(LPDIRECTMUSICPORT iface, DWORD channel_group, DWORD channel, DWORD priority)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ FIXME("(%p/%p)->(%d, %d, %d): semi-stub\n", iface, This, channel_group, channel, priority);
+
+ if (channel > 16)
+ {
+ WARN("isn't there supposed to be 16 channels (no. %d requested)?! (faking as it is ok)\n", channel);
+ /*return E_INVALIDARG;*/
+ }
+
+ return S_OK;
+}
+
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetChannelPriority(LPDIRECTMUSICPORT iface, DWORD channel_group, DWORD channel, LPDWORD priority)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ TRACE("(%p/%p)->(%u, %u, %p)\n", iface, This, channel_group, channel, priority);
+
+ *priority = This->group[channel_group - 1].channel[channel].priority;
+
+ return S_OK;
+}
+
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_SetDirectSound(LPDIRECTMUSICPORT iface, LPDIRECTSOUND direct_sound, LPDIRECTSOUNDBUFFER direct_sound_buffer)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ FIXME("(%p/%p)->(%p, %p): stub\n", iface, This, direct_sound, direct_sound_buffer);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortImpl_GetFormat (LPDIRECTMUSICPORT iface, LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSize, LPDWORD pdwBufferSize) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetFormat(LPDIRECTMUSICPORT iface, LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSize, LPDWORD pdwBufferSize)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
WAVEFORMATEX format;
FIXME("(%p, %p, %p, %p): stub\n", This, pWaveFormatEx, pdwWaveFormatExSize, pdwBufferSize);
return S_OK;
}
-static const IDirectMusicPortVtbl DirectMusicPort_Vtbl = {
- IDirectMusicPortImpl_QueryInterface,
- IDirectMusicPortImpl_AddRef,
- IDirectMusicPortImpl_Release,
- IDirectMusicPortImpl_PlayBuffer,
- IDirectMusicPortImpl_SetReadNotificationHandle,
- IDirectMusicPortImpl_Read,
- IDirectMusicPortImpl_DownloadInstrument,
- IDirectMusicPortImpl_UnloadInstrument,
- IDirectMusicPortImpl_GetLatencyClock,
- IDirectMusicPortImpl_GetRunningStats,
- IDirectMusicPortImpl_Compact,
- IDirectMusicPortImpl_GetCaps,
- IDirectMusicPortImpl_DeviceIoControl,
- IDirectMusicPortImpl_SetNumChannelGroups,
- IDirectMusicPortImpl_GetNumChannelGroups,
- IDirectMusicPortImpl_Activate,
- IDirectMusicPortImpl_SetChannelPriority,
- IDirectMusicPortImpl_GetChannelPriority,
- IDirectMusicPortImpl_SetDirectSound,
- IDirectMusicPortImpl_GetFormat
+static const IDirectMusicPortVtbl SynthPortImpl_DirectMusicPort_Vtbl = {
+ /**** IDirectMusicPort IUnknown part methods ***/
+ SynthPortImpl_IDirectMusicPort_QueryInterface,
+ SynthPortImpl_IDirectMusicPort_AddRef,
+ SynthPortImpl_IDirectMusicPort_Release,
+ /**** IDirectMusicPort methods ***/
+ SynthPortImpl_IDirectMusicPort_PlayBuffer,
+ SynthPortImpl_IDirectMusicPort_SetReadNotificationHandle,
+ SynthPortImpl_IDirectMusicPort_Read,
+ SynthPortImpl_IDirectMusicPort_DownloadInstrument,
+ SynthPortImpl_IDirectMusicPort_UnloadInstrument,
+ SynthPortImpl_IDirectMusicPort_GetLatencyClock,
+ SynthPortImpl_IDirectMusicPort_GetRunningStats,
+ SynthPortImpl_IDirectMusicPort_Compact,
+ SynthPortImpl_IDirectMusicPort_GetCaps,
+ SynthPortImpl_IDirectMusicPort_DeviceIoControl,
+ SynthPortImpl_IDirectMusicPort_SetNumChannelGroups,
+ SynthPortImpl_IDirectMusicPort_GetNumChannelGroups,
+ SynthPortImpl_IDirectMusicPort_Activate,
+ SynthPortImpl_IDirectMusicPort_SetChannelPriority,
+ SynthPortImpl_IDirectMusicPort_GetChannelPriority,
+ SynthPortImpl_IDirectMusicPort_SetDirectSound,
+ SynthPortImpl_IDirectMusicPort_GetFormat
};
-/* IDirectMusicPortDownload IUnknown parts follow: */
-static HRESULT WINAPI IDirectMusicPortDownloadImpl_QueryInterface (LPDIRECTMUSICPORTDOWNLOAD iface, REFIID riid, LPVOID *ppobj) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpDownloadVtbl, iface);
- TRACE("(%p/%p)->(%s, %p)\n", This, iface, debugstr_dmguid(riid), ppobj);
- return IUnknown_QueryInterface((IUnknown *)&(This->lpVtbl), riid, ppobj);
+/* SynthPortImpl IDirectMusicPortDownload IUnknown part follows: */
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_QueryInterface(LPDIRECTMUSICPORTDOWNLOAD iface, REFIID riid, LPVOID *ret_iface)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
+
+ TRACE("(%p/%p)->(%s, %p)\n", iface, This, debugstr_dmguid(riid), ret_iface);
+
+ return IDirectMusicPort_QueryInterface(&This->IDirectMusicPort_iface, riid, ret_iface);
}
-static ULONG WINAPI IDirectMusicPortDownloadImpl_AddRef (LPDIRECTMUSICPORTDOWNLOAD iface) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpDownloadVtbl, iface);
- TRACE("(%p/%p)->()\n", This, iface);
- return IUnknown_AddRef((IUnknown *)&(This->lpVtbl));
+static ULONG WINAPI SynthPortImpl_IDirectMusicPortDownload_AddRef (LPDIRECTMUSICPORTDOWNLOAD iface)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
+
+ TRACE("(%p/%p)->()\n", iface, This);
+
+ return IDirectMusicPort_AddRef(&This->IDirectMusicPort_iface);
}
-static ULONG WINAPI IDirectMusicPortDownloadImpl_Release (LPDIRECTMUSICPORTDOWNLOAD iface) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpDownloadVtbl, iface);
- TRACE("(%p/%p)->()\n", This, iface);
- return IUnknown_Release((IUnknown *)&(This->lpVtbl));
+static ULONG WINAPI SynthPortImpl_IDirectMusicPortDownload_Release(LPDIRECTMUSICPORTDOWNLOAD iface)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
+
+ TRACE("(%p/%p)->()\n", iface, This);
+
+ return IDirectMusicPort_Release(&This->IDirectMusicPort_iface);
}
-/* IDirectMusicPortDownload Interface follow: */
-static HRESULT WINAPI IDirectMusicPortDownloadImpl_GetBuffer (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD dwDLId, IDirectMusicDownload** ppIDMDownload) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpDownloadVtbl, iface);
+/* SynthPortImpl IDirectMusicPortDownload Interface follows: */
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_GetBuffer(LPDIRECTMUSICPORTDOWNLOAD iface, DWORD DLId, IDirectMusicDownload** IDMDownload)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
- FIXME("(%p/%p)->(%d, %p): stub\n", This, iface, dwDLId, ppIDMDownload);
+ FIXME("(%p/%p)->(%u, %p): stub\n", iface, This, DLId, IDMDownload);
- if (!ppIDMDownload)
- return E_POINTER;
+ if (!IDMDownload)
+ return E_POINTER;
- return DMUSIC_CreateDirectMusicDownloadImpl(&IID_IDirectMusicDownload, (LPVOID*)ppIDMDownload, NULL);
+ return DMUSIC_CreateDirectMusicDownloadImpl(&IID_IDirectMusicDownload, (LPVOID*)IDMDownload, NULL);
}
-static HRESULT WINAPI IDirectMusicPortDownloadImpl_AllocateBuffer (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD dwSize, IDirectMusicDownload** ppIDMDownload) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpDownloadVtbl, iface);
- FIXME("(%p/%p)->(%d, %p): stub\n", This, iface, dwSize, ppIDMDownload);
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_AllocateBuffer(LPDIRECTMUSICPORTDOWNLOAD iface, DWORD size, IDirectMusicDownload** IDMDownload)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
+
+ FIXME("(%p/%p)->(%u, %p): stub\n", iface, This, size, IDMDownload);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortDownloadImpl_GetDLId (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD* pdwStartDLId, DWORD dwCount) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpDownloadVtbl, iface);
- FIXME("(%p/%p)->(%p, %d): stub\n", This, iface, pdwStartDLId, dwCount);
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_GetDLId(LPDIRECTMUSICPORTDOWNLOAD iface, DWORD* start_DLId, DWORD count)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
+
+ FIXME("(%p/%p)->(%p, %u): stub\n", iface, This, start_DLId, count);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortDownloadImpl_GetAppend (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD* pdwAppend) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p/%p)->(%p): stub\n", This, iface, pdwAppend);
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_GetAppend (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD* append)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
+
+ FIXME("(%p/%p)->(%p): stub\n", iface, This, append);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortDownloadImpl_Download (LPDIRECTMUSICPORTDOWNLOAD iface, IDirectMusicDownload* pIDMDownload) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p/%p)->(%p): stub\n", This, iface, pIDMDownload);
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_Download(LPDIRECTMUSICPORTDOWNLOAD iface, IDirectMusicDownload* IDMDownload)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
+
+ FIXME("(%p/%p)->(%p): stub\n", iface, This, IDMDownload);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortDownloadImpl_Unload (LPDIRECTMUSICPORTDOWNLOAD iface, IDirectMusicDownload* pIDMDownload) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p/%p)->(%p): stub\n", This, iface, pIDMDownload);
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_Unload(LPDIRECTMUSICPORTDOWNLOAD iface, IDirectMusicDownload* IDMDownload)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
+
+ FIXME("(%p/%p)->(%p): stub\n", iface, This, IDMDownload);
+
+ return S_OK;
}
-static const IDirectMusicPortDownloadVtbl DirectMusicPortDownload_Vtbl = {
- IDirectMusicPortDownloadImpl_QueryInterface,
- IDirectMusicPortDownloadImpl_AddRef,
- IDirectMusicPortDownloadImpl_Release,
- IDirectMusicPortDownloadImpl_GetBuffer,
- IDirectMusicPortDownloadImpl_AllocateBuffer,
- IDirectMusicPortDownloadImpl_GetDLId,
- IDirectMusicPortDownloadImpl_GetAppend,
- IDirectMusicPortDownloadImpl_Download,
- IDirectMusicPortDownloadImpl_Unload
+static const IDirectMusicPortDownloadVtbl SynthPortImpl_DirectMusicPortDownload_Vtbl = {
+ /*** IDirectMusicPortDownload IUnknown part methods ***/
+ SynthPortImpl_IDirectMusicPortDownload_QueryInterface,
+ SynthPortImpl_IDirectMusicPortDownload_AddRef,
+ SynthPortImpl_IDirectMusicPortDownload_Release,
+ /*** IDirectMusicPortDownload methods ***/
+ SynthPortImpl_IDirectMusicPortDownload_GetBuffer,
+ SynthPortImpl_IDirectMusicPortDownload_AllocateBuffer,
+ SynthPortImpl_IDirectMusicPortDownload_GetDLId,
+ SynthPortImpl_IDirectMusicPortDownload_GetAppend,
+ SynthPortImpl_IDirectMusicPortDownload_Download,
+ SynthPortImpl_IDirectMusicPortDownload_Unload
};
-/* IDirectMusicThru IUnknown parts follow: */
-static HRESULT WINAPI IDirectMusicThruImpl_QueryInterface (LPDIRECTMUSICTHRU iface, REFIID riid, LPVOID *ppobj) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpThruVtbl, iface);
- TRACE("(%p/%p)->(%s, %p)\n", This, iface, debugstr_dmguid(riid), ppobj);
- return IUnknown_QueryInterface((IUnknown *)&(This->lpVtbl), riid, ppobj);
-}
+/* SynthPortImpl IDirectMusicThru IUnknown part follows: */
+static HRESULT WINAPI SynthPortImpl_IDirectMusicThru_QueryInterface(LPDIRECTMUSICTHRU iface, REFIID riid, LPVOID *ret_iface)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicThru(iface);
-static ULONG WINAPI IDirectMusicThruImpl_AddRef (LPDIRECTMUSICTHRU iface) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpThruVtbl, iface);
- TRACE("(%p/%p)->()\n", This, iface);
- return IUnknown_AddRef((IUnknown *)&(This->lpVtbl));
+ TRACE("(%p/%p)->(%s, %p)\n", iface, This, debugstr_dmguid(riid), ret_iface);
+
+ return IDirectMusicPort_QueryInterface(&This->IDirectMusicPort_iface, riid, ret_iface);
}
-static ULONG WINAPI IDirectMusicThruImpl_Release (LPDIRECTMUSICTHRU iface) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpThruVtbl, iface);
- TRACE("(%p/%p)->()\n", This, iface);
- return IUnknown_Release((IUnknown *)&(This->lpVtbl));
+static ULONG WINAPI SynthPortImpl_IDirectMusicThru_AddRef(LPDIRECTMUSICTHRU iface)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicThru(iface);
+
+ TRACE("(%p/%p)->()\n", iface, This);
+
+ return IDirectMusicPort_AddRef(&This->IDirectMusicPort_iface);
}
-/* IDirectMusicThru Interface follow: */
-static HRESULT WINAPI IDirectMusicThruImpl_ThruChannel (LPDIRECTMUSICTHRU iface, DWORD dwSourceChannelGroup, DWORD dwSourceChannel, DWORD dwDestinationChannelGroup, DWORD dwDestinationChannel, LPDIRECTMUSICPORT pDestinationPort) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpThruVtbl, iface);
- FIXME("(%p/%p)->(%d, %d, %d, %d, %p): stub\n", This, iface, dwSourceChannelGroup, dwSourceChannel, dwDestinationChannelGroup, dwDestinationChannel, pDestinationPort);
- return S_OK;
+static ULONG WINAPI SynthPortImpl_IDirectMusicThru_Release(LPDIRECTMUSICTHRU iface)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicThru(iface);
+
+ TRACE("(%p/%p)->()\n", iface, This);
+
+ return IDirectMusicPort_Release(&This->IDirectMusicPort_iface);
}
-static const IDirectMusicThruVtbl DirectMusicThru_Vtbl = {
- IDirectMusicThruImpl_QueryInterface,
- IDirectMusicThruImpl_AddRef,
- IDirectMusicThruImpl_Release,
- IDirectMusicThruImpl_ThruChannel
-};
+/* SynthPortImpl IDirectMusicThru Interface follows: */
+static HRESULT WINAPI SynthPortImpl_IDirectMusicThru_ThruChannel(LPDIRECTMUSICTHRU iface, DWORD source_channel_group, DWORD source_channel, DWORD destination_channel_group,
+ DWORD destination_channel, LPDIRECTMUSICPORT destination_port)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicThru(iface);
-HRESULT WINAPI DMUSIC_CreateDirectMusicPortImpl (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter, LPDMUS_PORTPARAMS pPortParams, LPDMUS_PORTCAPS pPortCaps) {
- IDirectMusicPortImpl *obj;
+ FIXME("(%p/%p)->(%d, %d, %d, %d, %p): stub\n", iface, This, source_channel_group, source_channel, destination_channel_group, destination_channel, destination_port);
- TRACE("(%p,%p,%p)\n", lpcGUID, ppobj, pUnkOuter);
+ return S_OK;
+}
- obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicPortImpl));
- if (NULL == obj) {
- *ppobj = NULL;
- return E_OUTOFMEMORY;
- }
- obj->lpVtbl = &DirectMusicPort_Vtbl;
- obj->lpDownloadVtbl = &DirectMusicPortDownload_Vtbl;
- obj->lpThruVtbl = &DirectMusicThru_Vtbl;
- obj->ref = 0; /* will be inited by QueryInterface */
- obj->fActive = FALSE;
- obj->params = *pPortParams;
- obj->caps = *pPortCaps;
- obj->pDirectSound = NULL;
- obj->pLatencyClock = NULL;
- DMUSIC_CreateReferenceClockImpl(&IID_IReferenceClock, (LPVOID*)&obj->pLatencyClock, NULL);
-
-#if 0
- if (pPortParams->dwValidParams & DMUS_PORTPARAMS_CHANNELGROUPS) {
- obj->nrofgroups = pPortParams->dwChannelGroups;
- /* setting default priorities */
- for (j = 0; j < obj->nrofgroups; j++) {
- TRACE ("Setting default channel priorities on channel group %i\n", j + 1);
- obj->group[j].channel[0].priority = DAUD_CHAN1_DEF_VOICE_PRIORITY;
- obj->group[j].channel[1].priority = DAUD_CHAN2_DEF_VOICE_PRIORITY;
- obj->group[j].channel[2].priority = DAUD_CHAN3_DEF_VOICE_PRIORITY;
- obj->group[j].channel[3].priority = DAUD_CHAN4_DEF_VOICE_PRIORITY;
- obj->group[j].channel[4].priority = DAUD_CHAN5_DEF_VOICE_PRIORITY;
- obj->group[j].channel[5].priority = DAUD_CHAN6_DEF_VOICE_PRIORITY;
- obj->group[j].channel[6].priority = DAUD_CHAN7_DEF_VOICE_PRIORITY;
- obj->group[j].channel[7].priority = DAUD_CHAN8_DEF_VOICE_PRIORITY;
- obj->group[j].channel[8].priority = DAUD_CHAN9_DEF_VOICE_PRIORITY;
- obj->group[j].channel[9].priority = DAUD_CHAN10_DEF_VOICE_PRIORITY;
- obj->group[j].channel[10].priority = DAUD_CHAN11_DEF_VOICE_PRIORITY;
- obj->group[j].channel[11].priority = DAUD_CHAN12_DEF_VOICE_PRIORITY;
- obj->group[j].channel[12].priority = DAUD_CHAN13_DEF_VOICE_PRIORITY;
- obj->group[j].channel[13].priority = DAUD_CHAN14_DEF_VOICE_PRIORITY;
- obj->group[j].channel[14].priority = DAUD_CHAN15_DEF_VOICE_PRIORITY;
- obj->group[j].channel[15].priority = DAUD_CHAN16_DEF_VOICE_PRIORITY;
- }
- }
-#endif
+static const IDirectMusicThruVtbl SynthPortImpl_DirectMusicThru_Vtbl = {
+ /*** IDirectMusicThru IUnknown part methods */
+ SynthPortImpl_IDirectMusicThru_QueryInterface,
+ SynthPortImpl_IDirectMusicThru_AddRef,
+ SynthPortImpl_IDirectMusicThru_Release,
+ /*** IDirectMusicThru methods ***/
+ SynthPortImpl_IDirectMusicThru_ThruChannel
+};
- return IDirectMusicPortImpl_QueryInterface ((LPDIRECTMUSICPORT)obj, lpcGUID, ppobj);
+HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device)
+{
+ SynthPortImpl *obj;
+ HRESULT hr = E_FAIL;
+ int i;
+
+ TRACE("(%p,%p,%p,%p,%p%d)\n", guid, object, unkouter, port_params, port_caps, device);
+
+ *object = NULL;
+
+ obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SynthPortImpl));
+ if (!obj)
+ return E_OUTOFMEMORY;
+
+ obj->IDirectMusicPort_iface.lpVtbl = &SynthPortImpl_DirectMusicPort_Vtbl;
+ obj->IDirectMusicPortDownload_iface.lpVtbl = &SynthPortImpl_DirectMusicPortDownload_Vtbl;
+ obj->IDirectMusicThru_iface.lpVtbl = &SynthPortImpl_DirectMusicThru_Vtbl;
+ obj->ref = 0; /* Will be inited by QueryInterface */
+ obj->fActive = FALSE;
+ obj->params = *port_params;
+ obj->caps = *port_caps;
+
+ hr = DMUSIC_CreateReferenceClockImpl(&IID_IReferenceClock, (LPVOID*)&obj->pLatencyClock, NULL);
+ if (hr != S_OK)
+ {
+ HeapFree(GetProcessHeap(), 0, obj);
+ return hr;
+ }
+
+ if (SUCCEEDED(hr))
+ hr = CoCreateInstance(&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynth, (void**)&obj->synth);
+
+ if (SUCCEEDED(hr))
+ hr = CoCreateInstance(&CLSID_DirectMusicSynthSink, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynthSink, (void**)&obj->synth_sink);
+
+ if (SUCCEEDED(hr))
+ hr = IDirectMusicSynth_SetMasterClock(obj->synth, obj->pLatencyClock);
+
+ if (SUCCEEDED(hr))
+ hr = IDirectMusicSynthSink_SetMasterClock(obj->synth_sink, obj->pLatencyClock);
+
+ if (SUCCEEDED(hr))
+ hr = IDirectMusicSynth_SetSynthSink(obj->synth, obj->synth_sink);
+
+ if (SUCCEEDED(hr))
+ hr = IDirectMusicSynth_Open(obj->synth, port_params);
+
+ if (0)
+ {
+ if (port_params->dwValidParams & DMUS_PORTPARAMS_CHANNELGROUPS) {
+ obj->nrofgroups = port_params->dwChannelGroups;
+ /* Setting default priorities */
+ for (i = 0; i < obj->nrofgroups; i++) {
+ TRACE ("Setting default channel priorities on channel group %i\n", i + 1);
+ obj->group[i].channel[0].priority = DAUD_CHAN1_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[1].priority = DAUD_CHAN2_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[2].priority = DAUD_CHAN3_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[3].priority = DAUD_CHAN4_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[4].priority = DAUD_CHAN5_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[5].priority = DAUD_CHAN6_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[6].priority = DAUD_CHAN7_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[7].priority = DAUD_CHAN8_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[8].priority = DAUD_CHAN9_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[9].priority = DAUD_CHAN10_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[10].priority = DAUD_CHAN11_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[11].priority = DAUD_CHAN12_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[12].priority = DAUD_CHAN13_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[13].priority = DAUD_CHAN14_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[14].priority = DAUD_CHAN15_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[15].priority = DAUD_CHAN16_DEF_VOICE_PRIORITY;
+ }
+ }
+ }
+
+ if (SUCCEEDED(hr))
+ return IDirectMusicPort_QueryInterface((LPDIRECTMUSICPORT)obj, guid, object);
+
+ if (obj->synth)
+ IDirectMusicSynth_Release(obj->synth);
+ if (obj->synth_sink)
+ IDirectMusicSynthSink_Release(obj->synth_sink);
+ if (obj->pLatencyClock)
+ IReferenceClock_Release(obj->pLatencyClock);
+ HeapFree(GetProcessHeap(), 0, obj);
+
+ return hr;
+}
+
+HRESULT DMUSIC_CreateMidiOutPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device)
+{
+ TRACE("(%p,%p,%p,%p,%p,%d): stub\n", guid, object, unkouter, port_params, port_caps, device);
+
+ return E_NOTIMPL;
+}
+
+HRESULT DMUSIC_CreateMidiInPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device)
+{
+ TRACE("(%p,%p,%p,%p,%p,%d): stub\n", guid, object, unkouter, port_params, port_caps, device);
+
+ return E_NOTIMPL;
}
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#define WINE_OLESELFREGISTER
+1 WINE_REGISTRY dmusic.rgs
+
#define WINE_FILEDESCRIPTION_STR "Wine DirectMusic"
#define WINE_FILENAME_STR "dmusic.dll"
#define WINE_FILEVERSION 5,3,1,904
#define WINE_FILEVERSION_STR "5.3.1.904"
#define WINE_PRODUCTVERSION 5,3,1,904
#define WINE_PRODUCTVERSION_STR "5.3.1.904"
+#define WINE_EXTRAVALUES VALUE "OLESelfRegister",""
-#include "wine/wine_common_ver.rc"
+#include <wine/wine_common_ver.rc>
-
include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine)
spec2def(dplay.dll dplay.spec)
${CMAKE_CURRENT_BINARY_DIR}/dplay.def)
set_module_type(dplay win32dll UNICODE)
-
-target_link_libraries(dplay
- uuid
- wine)
-
-add_importlibs(dplay
- msvcrt
- user32
- advapi32
- ole32
- winmm
- dinput
- dplayx
- kernel32
- ntdll)
-
+add_importlibs(dplay dplayx msvcrt kernel32 ntdll)
add_dependencies(dplay psdk)
-
add_cd_file(TARGET dplay DESTINATION reactos/system32 FOR all)
-
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#define WINE_OLESELFREGISTER
#define WINE_FILEDESCRIPTION_STR "Wine DirectPlay"
#define WINE_FILENAME_STR "dplay.dll"
#define WINE_FILEVERSION 5,3,0,900
#define WINE_FILEVERSION_STR "5.3.0.900"
#define WINE_PRODUCTVERSION 5,3,0,900
#define WINE_PRODUCTVERSION_STR "5.3"
+#define WINE_EXTRAVALUES VALUE "OLESelfRegister",""
-#include "wine/wine_common_ver.rc"
+#include <wine/wine_common_ver.rc>
+add_definitions(
+ -DCOM_NO_WINDOWS_H
+ -D__WINESRC__)
+
+include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine)
+
spec2def(dplayx.dll dplayx.spec ADD_IMPORTLIB)
list(APPEND SOURCE
dplobby.c
lobbysp.c
name_server.c
- regsvr.c
- version.rc
${CMAKE_CURRENT_BINARY_DIR}/dplayx.def)
-include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine)
-
-add_library(dplayx SHARED ${SOURCE})
+add_library(dplayx SHARED ${SOURCE} version.rc)
set_module_type(dplayx win32dll)
-target_link_libraries(dplayx wine uuid dxguid)
-
-add_importlibs(dplayx
- advapi32
- ole32
- user32
- winmm
- msvcrt
- kernel32
- ntdll)
-
+target_link_libraries(dplayx dxguid uuid wine)
+add_importlibs(dplayx winmm ole32 user32 advapi32 msvcrt kernel32 ntdll)
add_cd_file(TARGET dplayx DESTINATION reactos/system32 FOR all)
*
* 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
//#include <stdarg.h>
//#include "objbase.h"
//#include "winerror.h"
#include <wine/debug.h>
+//#include "dplay.h"
+//#include "dplobby.h"
+//#include "initguid.h"
#include "dpinit.h"
WINE_DEFAULT_DEBUG_CHANNEL(dplay);
typedef struct
{
/* IUnknown fields */
- const IClassFactoryVtbl *lpVtbl;
- LONG ref;
+ IClassFactory IClassFactory_iface;
+ LONG ref;
} IClassFactoryImpl;
+static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
+{
+ return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
+}
+
static HRESULT WINAPI
DP_and_DPL_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
- IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+ IClassFactoryImpl *This = impl_from_IClassFactory(iface);
FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
static ULONG WINAPI
DP_and_DPL_AddRef(LPCLASSFACTORY iface) {
- IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+ IClassFactoryImpl *This = impl_from_IClassFactory(iface);
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI DP_and_DPL_Release(LPCLASSFACTORY iface) {
- IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+ IClassFactoryImpl *This = impl_from_IClassFactory(iface);
/* static class (reference starts @ 1), won't ever be freed */
return InterlockedDecrement(&This->ref);
}
static HRESULT WINAPI DP_and_DPL_CreateInstance(
LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
) {
- IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+ IClassFactoryImpl *This = impl_from_IClassFactory(iface);
TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
}
static HRESULT WINAPI DP_and_DPL_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
- IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+ IClassFactoryImpl *This = impl_from_IClassFactory(iface);
FIXME("(%p)->(%d),stub!\n",This,dolock);
return S_OK;
}
DP_and_DPL_LockServer
};
-static IClassFactoryImpl DP_and_DPL_CF = {&DP_and_DPL_Vtbl, 1 };
+static IClassFactoryImpl DP_and_DPL_CF = {{&DP_and_DPL_Vtbl}, 1 };
/*******************************************************************************
*/
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
{
- TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+ TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
if ( IsEqualCLSID( riid, &IID_IClassFactory ) )
{
- *ppv = (LPVOID)&DP_and_DPL_CF;
+ *ppv = &DP_and_DPL_CF;
IClassFactory_AddRef( (IClassFactory*)*ppv );
return S_OK;
}
- ERR("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+ ERR("(%s,%s,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
return CLASS_E_CLASSNOTAVAILABLE;
}
*
* 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_DPINIT_H
//#include "wtypes.h"
#include "dplay_global.h"
-extern HRESULT DP_CreateInterface( REFIID riid, LPVOID* ppvObj );
-extern HRESULT DPL_CreateInterface( REFIID riid, LPVOID* ppvObj );
+extern HRESULT DP_CreateInterface( REFIID riid, LPVOID* ppvObj ) DECLSPEC_HIDDEN;
+extern HRESULT DPL_CreateInterface( REFIID riid, LPVOID* ppvObj ) DECLSPEC_HIDDEN;
extern HRESULT DPSP_CreateInterface( REFIID riid, LPVOID* ppvObj,
- IDirectPlay2Impl* dp );
+ IDirectPlay2Impl* dp ) DECLSPEC_HIDDEN;
extern HRESULT DPLSP_CreateInterface( REFIID riid, LPVOID* ppvObj,
- IDirectPlay2Impl* dp );
+ IDirectPlay2Impl* dp ) DECLSPEC_HIDDEN;
#endif
*
* 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <config.h>
static lpPlayerData DP_CreatePlayer( IDirectPlay2Impl* iface, LPDPID lpid,
LPDPNAME lpName, DWORD dwFlags,
HANDLE hEvent, BOOL bAnsi );
-static BOOL DP_CopyDPNAMEStruct( LPDPNAME lpDst, LPDPNAME lpSrc, BOOL bAnsi );
+static BOOL DP_CopyDPNAMEStruct( LPDPNAME lpDst, const DPNAME *lpSrc, BOOL bAnsi );
static void DP_SetPlayerData( lpPlayerData lpPData, DWORD dwFlags,
LPVOID lpData, DWORD dwDataSize );
-static lpGroupData DP_CreateGroup( IDirectPlay2AImpl* iface, LPDPID lpid,
- LPDPNAME lpName, DWORD dwFlags,
+static lpGroupData DP_CreateGroup( IDirectPlay2AImpl* iface, const DPID *lpid,
+ const DPNAME *lpName, DWORD dwFlags,
DPID idParent, BOOL bAnsi );
static void DP_SetGroupData( lpGroupData lpGData, DWORD dwFlags,
LPVOID lpData, DWORD dwDataSize );
static const IDirectPlay4Vtbl directPlay4WVT;
/* Helper methods for player/group interfaces */
-static HRESULT WINAPI DP_IF_DeletePlayerFromGroup
+static HRESULT DP_IF_DeletePlayerFromGroup
( IDirectPlay2Impl* This, LPVOID lpMsgHdr, DPID idGroup,
DPID idPlayer, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_CreatePlayer
+static HRESULT DP_IF_CreatePlayer
( IDirectPlay2Impl* This, LPVOID lpMsgHdr, LPDPID lpidPlayer,
LPDPNAME lpPlayerName, HANDLE hEvent, LPVOID lpData,
DWORD dwDataSize, DWORD dwFlags, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_DestroyGroup
+static HRESULT DP_IF_DestroyGroup
( IDirectPlay2Impl* This, LPVOID lpMsgHdr, DPID idGroup, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_DestroyPlayer
+static HRESULT DP_IF_DestroyPlayer
( IDirectPlay2Impl* This, LPVOID lpMsgHdr, DPID idPlayer, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_EnumGroupPlayers
+static HRESULT DP_IF_EnumGroupPlayers
( IDirectPlay2Impl* This, DPID idGroup, LPGUID lpguidInstance,
LPDPENUMPLAYERSCALLBACK2 lpEnumPlayersCallback2,
LPVOID lpContext, DWORD dwFlags, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_EnumGroups
+static HRESULT DP_IF_EnumGroups
( IDirectPlay2Impl* This, LPGUID lpguidInstance,
LPDPENUMPLAYERSCALLBACK2 lpEnumPlayersCallback2,
LPVOID lpContext, DWORD dwFlags, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_EnumPlayers
+static HRESULT DP_IF_EnumPlayers
( IDirectPlay2Impl* This, LPGUID lpguidInstance,
LPDPENUMPLAYERSCALLBACK2 lpEnumPlayersCallback2,
LPVOID lpContext, DWORD dwFlags, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_GetGroupData
+static HRESULT DP_IF_GetGroupData
( IDirectPlay2Impl* This, DPID idGroup, LPVOID lpData,
LPDWORD lpdwDataSize, DWORD dwFlags, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_GetGroupName
+static HRESULT DP_IF_GetGroupName
( IDirectPlay2Impl* This, DPID idGroup, LPVOID lpData,
LPDWORD lpdwDataSize, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_GetPlayerData
+static HRESULT DP_IF_GetPlayerData
( IDirectPlay2Impl* This, DPID idPlayer, LPVOID lpData,
LPDWORD lpdwDataSize, DWORD dwFlags, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_GetPlayerName
+static HRESULT DP_IF_GetPlayerName
( IDirectPlay2Impl* This, DPID idPlayer, LPVOID lpData,
LPDWORD lpdwDataSize, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_SetGroupName
+static HRESULT DP_IF_SetGroupName
( IDirectPlay2Impl* This, DPID idGroup, LPDPNAME lpGroupName,
DWORD dwFlags, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_SetPlayerData
+static HRESULT DP_IF_SetPlayerData
( IDirectPlay2Impl* This, DPID idPlayer, LPVOID lpData,
DWORD dwDataSize, DWORD dwFlags, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_SetPlayerName
+static HRESULT DP_IF_SetPlayerName
( IDirectPlay2Impl* This, DPID idPlayer, LPDPNAME lpPlayerName,
DWORD dwFlags, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_AddGroupToGroup
+static HRESULT DP_IF_AddGroupToGroup
( IDirectPlay3Impl* This, DPID idParentGroup, DPID idGroup );
-static HRESULT WINAPI DP_IF_CreateGroup
+static HRESULT DP_IF_CreateGroup
( IDirectPlay2AImpl* This, LPVOID lpMsgHdr, LPDPID lpidGroup,
LPDPNAME lpGroupName, LPVOID lpData, DWORD dwDataSize,
DWORD dwFlags, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_CreateGroupInGroup
+static HRESULT DP_IF_CreateGroupInGroup
( IDirectPlay3Impl* This, LPVOID lpMsgHdr, DPID idParentGroup,
LPDPID lpidGroup, LPDPNAME lpGroupName, LPVOID lpData,
DWORD dwDataSize, DWORD dwFlags, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_AddPlayerToGroup
+static HRESULT DP_IF_AddPlayerToGroup
( IDirectPlay2Impl* This, LPVOID lpMsgHdr, DPID idGroup,
DPID idPlayer, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_DeleteGroupFromGroup
+static HRESULT DP_IF_DeleteGroupFromGroup
( IDirectPlay3Impl* This, DPID idParentGroup, DPID idGroup );
-static HRESULT WINAPI DP_SetSessionDesc
+static HRESULT DP_SetSessionDesc
( IDirectPlay2Impl* This, LPCDPSESSIONDESC2 lpSessDesc,
DWORD dwFlags, BOOL bInitial, BOOL bAnsi );
-static HRESULT WINAPI DP_SecureOpen
+static HRESULT DP_SecureOpen
( IDirectPlay2Impl* This, LPCDPSESSIONDESC2 lpsd, DWORD dwFlags,
LPCDPSECURITYDESC lpSecurity, LPCDPCREDENTIALS lpCredentials,
BOOL bAnsi );
-static HRESULT WINAPI DP_SendEx
+static HRESULT DP_SendEx
( IDirectPlay2Impl* This, DPID idFrom, DPID idTo, DWORD dwFlags,
LPVOID lpData, DWORD dwDataSize, DWORD dwPriority, DWORD dwTimeout,
LPVOID lpContext, LPDWORD lpdwMsgID, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_Receive
+static HRESULT DP_IF_Receive
( IDirectPlay2Impl* This, LPDPID lpidFrom, LPDPID lpidTo,
DWORD dwFlags, LPVOID lpData, LPDWORD lpdwDataSize, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_GetMessageQueue
+static HRESULT DP_IF_GetMessageQueue
( IDirectPlay4Impl* This, DPID idFrom, DPID idTo, DWORD dwFlags,
LPDWORD lpdwNumMsgs, LPDWORD lpdwNumBytes, BOOL bAnsi );
-static HRESULT WINAPI DP_SP_SendEx
+static HRESULT DP_SP_SendEx
( IDirectPlay2Impl* This, DWORD dwFlags,
LPVOID lpData, DWORD dwDataSize, DWORD dwPriority, DWORD dwTimeout,
LPVOID lpContext, LPDWORD lpdwMsgID );
-static HRESULT WINAPI DP_IF_SetGroupData
+static HRESULT DP_IF_SetGroupData
( IDirectPlay2Impl* This, DPID idGroup, LPVOID lpData,
DWORD dwDataSize, DWORD dwFlags, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_GetPlayerCaps
+static HRESULT DP_IF_GetPlayerCaps
( IDirectPlay2Impl* This, DPID idPlayer, LPDPCAPS lpDPCaps,
DWORD dwFlags );
-static HRESULT WINAPI DP_IF_Close( IDirectPlay2Impl* This, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_CancelMessage
+static HRESULT DP_IF_Close( IDirectPlay2Impl* This, BOOL bAnsi );
+static HRESULT DP_IF_CancelMessage
( IDirectPlay4Impl* This, DWORD dwMsgID, DWORD dwFlags,
DWORD dwMinPriority, DWORD dwMaxPriority, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_EnumGroupsInGroup
+static HRESULT DP_IF_EnumGroupsInGroup
( IDirectPlay3AImpl* This, DPID idGroup, LPGUID lpguidInstance,
LPDPENUMPLAYERSCALLBACK2 lpEnumPlayersCallback2,
LPVOID lpContext, DWORD dwFlags, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_GetGroupParent
+static HRESULT DP_IF_GetGroupParent
( IDirectPlay3AImpl* This, DPID idGroup, LPDPID lpidGroup,
BOOL bAnsi );
-static HRESULT WINAPI DP_IF_GetCaps
+static HRESULT DP_IF_GetCaps
( IDirectPlay2Impl* This, LPDPCAPS lpDPCaps, DWORD dwFlags );
-static HRESULT WINAPI DP_IF_EnumSessions
+static HRESULT DP_IF_EnumSessions
( IDirectPlay2Impl* This, LPDPSESSIONDESC2 lpsd, DWORD dwTimeout,
LPDPENUMSESSIONSCALLBACK2 lpEnumSessionsCallback2,
LPVOID lpContext, DWORD dwFlags, BOOL bAnsi );
-static HRESULT WINAPI DP_IF_InitializeConnection
+static HRESULT DP_IF_InitializeConnection
( IDirectPlay3Impl* This, LPVOID lpConnection, DWORD dwFlags, BOOL bAnsi );
static BOOL CALLBACK cbDPCreateEnumConnections( LPCGUID lpguidSP,
LPVOID lpConnection, DWORD dwConnectionSize, LPCDPNAME lpName,
DWORD dwFlags, LPVOID lpContext );
-static BOOL WINAPI DP_BuildSPCompoundAddr( LPGUID lpcSpGuid, LPVOID* lplpAddrBuf,
- LPDWORD lpdwBufSize );
+static BOOL DP_BuildSPCompoundAddr( LPGUID lpcSpGuid, LPVOID* lplpAddrBuf,
+ LPDWORD lpdwBufSize );
static inline DPID DP_NextObjectId(void);
static DPID DP_GetRemoteNextObjectId(void);
-
+static DWORD DP_CalcSessionDescSize( LPCDPSESSIONDESC2 lpSessDesc, BOOL bAnsi );
static void DP_CopySessionDesc( LPDPSESSIONDESC2 destSessionDesc,
LPCDPSESSIONDESC2 srcSessDesc, BOOL bAnsi );
static BOOL DP_CreateIUnknown( LPVOID lpDP )
{
- IDirectPlay2AImpl *This = (IDirectPlay2AImpl *)lpDP;
+ IDirectPlay2AImpl *This = lpDP;
This->unk = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->unk) ) );
if ( This->unk == NULL )
}
InitializeCriticalSection( &This->unk->DP_lock );
+ This->unk->DP_lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDirectPlay2AImpl*->DirectPlayIUnknownData*->DP_lock");
return TRUE;
}
static BOOL DP_DestroyIUnknown( LPVOID lpDP )
{
- IDirectPlay2AImpl *This = (IDirectPlay2AImpl *)lpDP;
+ IDirectPlay2AImpl *This = lpDP;
+ This->unk->DP_lock.DebugInfo->Spare[0] = 0;
DeleteCriticalSection( &This->unk->DP_lock );
HeapFree( GetProcessHeap(), 0, This->unk );
static BOOL DP_CreateDirectPlay2( LPVOID lpDP )
{
- IDirectPlay2AImpl *This = (IDirectPlay2AImpl *)lpDP;
+ IDirectPlay2AImpl *This = lpDP;
This->dp2 = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->dp2) ) );
if ( This->dp2 == NULL )
This->dp2->bConnectionOpen = FALSE;
This->dp2->hEnumSessionThread = INVALID_HANDLE_VALUE;
+ This->dp2->dwEnumSessionLock = 0;
This->dp2->bHostInterface = FALSE;
DPQ_INIT(This->dp2->receiveMsgs);
DPQ_INIT(This->dp2->sendMsgs);
- DPQ_INIT(This->dp2->replysExpected);
+ DPQ_INIT(This->dp2->repliesExpected);
if( !NS_InitializeSessionCache( &This->dp2->lpNameServerData ) )
{
HeapFree( GetProcessHeap(), 0, elem );
}
-/* Function to delete the list of groups with this interface. Needs to
- * delete the group and player lists associated with this group as well
- * as the group data associated with this group. It should not delete
- * player data as that is shared with the top player list and will be
- * deleted with that.
- */
-DPQ_DECL_DELETECB( cbDeleteGroupsElem, lpGroupList );
-DPQ_DECL_DELETECB( cbDeleteGroupsElem, lpGroupList )
-{
- DPQ_DELETEQ( elem->lpGData->groups, groups,
- lpGroupList, cbDeleteElemFromHeap );
- DPQ_DELETEQ( elem->lpGData->players, players,
- lpPlayerList, cbDeleteElemFromHeap );
- HeapFree( GetProcessHeap(), 0, elem->lpGData );
- HeapFree( GetProcessHeap(), 0, elem );
-}
-
-/* Function to delete the list of players with this interface. Needs to
- * delete the player data for all players as well.
- */
-DPQ_DECL_DELETECB( cbDeletePlayerElem, lpPlayerList );
-DPQ_DECL_DELETECB( cbDeletePlayerElem, lpPlayerList )
-{
- HeapFree( GetProcessHeap(), 0, elem->lpPData );
- HeapFree( GetProcessHeap(), 0, elem );
-}
-
static BOOL DP_DestroyDirectPlay2( LPVOID lpDP )
{
- IDirectPlay2AImpl *This = (IDirectPlay2AImpl *)lpDP;
+ IDirectPlay2AImpl *This = lpDP;
if( This->dp2->hEnumSessionThread != INVALID_HANDLE_VALUE )
{
FreeLibrary( This->dp2->hDPLobbyProvider );
}
-#if 0
- DPQ_DELETEQ( This->dp2->players, players, lpPlayerList, cbDeletePlayerElem );
- DPQ_DELETEQ( This->dp2->groups, groups, lpGroupList, cbDeleteGroupsElem );
-#endif
-
/* FIXME: Need to delete receive and send msgs queue contents */
NS_DeleteSessionCache( This->dp2->lpNameServerData );
static BOOL DP_CreateDirectPlay3( LPVOID lpDP )
{
- IDirectPlay3AImpl *This = (IDirectPlay3AImpl *)lpDP;
+ IDirectPlay3AImpl *This = lpDP;
This->dp3 = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->dp3) ) );
if ( This->dp3 == NULL )
static BOOL DP_DestroyDirectPlay3( LPVOID lpDP )
{
- IDirectPlay3AImpl *This = (IDirectPlay3AImpl *)lpDP;
+ IDirectPlay3AImpl *This = lpDP;
/* Delete the contents */
HeapFree( GetProcessHeap(), 0, This->dp3 );
static BOOL DP_CreateDirectPlay4( LPVOID lpDP )
{
- IDirectPlay4AImpl *This = (IDirectPlay4AImpl *)lpDP;
+ IDirectPlay4AImpl *This = lpDP;
This->dp4 = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->dp4) ) );
if ( This->dp4 == NULL )
static BOOL DP_DestroyDirectPlay4( LPVOID lpDP )
{
- IDirectPlay3AImpl *This = (IDirectPlay3AImpl *)lpDP;
+ IDirectPlay3AImpl *This = lpDP;
/* Delete the contents */
HeapFree( GetProcessHeap(), 0, This->dp4 );
/* Create a new interface */
-extern
HRESULT DP_CreateInterface
( REFIID riid, LPVOID* ppvObj )
{
if( IsEqualGUID( &IID_IDirectPlay2, riid ) )
{
- IDirectPlay2Impl *This = (IDirectPlay2Impl *)*ppvObj;
+ IDirectPlay2Impl *This = *ppvObj;
This->lpVtbl = &directPlay2WVT;
}
else if( IsEqualGUID( &IID_IDirectPlay2A, riid ) )
{
- IDirectPlay2AImpl *This = (IDirectPlay2AImpl *)*ppvObj;
+ IDirectPlay2AImpl *This = *ppvObj;
This->lpVtbl = &directPlay2AVT;
}
else if( IsEqualGUID( &IID_IDirectPlay3, riid ) )
{
- IDirectPlay3Impl *This = (IDirectPlay3Impl *)*ppvObj;
+ IDirectPlay3Impl *This = *ppvObj;
This->lpVtbl = &directPlay3WVT;
}
else if( IsEqualGUID( &IID_IDirectPlay3A, riid ) )
{
- IDirectPlay3AImpl *This = (IDirectPlay3AImpl *)*ppvObj;
+ IDirectPlay3AImpl *This = *ppvObj;
This->lpVtbl = &directPlay3AVT;
}
else if( IsEqualGUID( &IID_IDirectPlay4, riid ) )
{
- IDirectPlay4Impl *This = (IDirectPlay4Impl *)*ppvObj;
+ IDirectPlay4Impl *This = *ppvObj;
This->lpVtbl = &directPlay4WVT;
}
else if( IsEqualGUID( &IID_IDirectPlay4A, riid ) )
{
- IDirectPlay4AImpl *This = (IDirectPlay4AImpl *)*ppvObj;
+ IDirectPlay4AImpl *This = *ppvObj;
This->lpVtbl = &directPlay4AVT;
}
else
if( IsEqualGUID( &IID_IDirectPlay2, riid ) )
{
- IDirectPlay2Impl *This = (IDirectPlay2Impl *)*ppvObj;
+ IDirectPlay2Impl *This = *ppvObj;
This->lpVtbl = &directPlay2WVT;
}
else if( IsEqualGUID( &IID_IDirectPlay2A, riid ) )
{
- IDirectPlay2AImpl *This = (IDirectPlay2AImpl *)*ppvObj;
+ IDirectPlay2AImpl *This = *ppvObj;
This->lpVtbl = &directPlay2AVT;
}
else if( IsEqualGUID( &IID_IDirectPlay3, riid ) )
{
- IDirectPlay3Impl *This = (IDirectPlay3Impl *)*ppvObj;
+ IDirectPlay3Impl *This = *ppvObj;
This->lpVtbl = &directPlay3WVT;
}
else if( IsEqualGUID( &IID_IDirectPlay3A, riid ) )
{
- IDirectPlay3AImpl *This = (IDirectPlay3AImpl *)*ppvObj;
+ IDirectPlay3AImpl *This = *ppvObj;
This->lpVtbl = &directPlay3AVT;
}
else if( IsEqualGUID( &IID_IDirectPlay4, riid ) )
{
- IDirectPlay4Impl *This = (IDirectPlay4Impl *)*ppvObj;
+ IDirectPlay4Impl *This = *ppvObj;
This->lpVtbl = &directPlay4WVT;
}
else if( IsEqualGUID( &IID_IDirectPlay4A, riid ) )
{
- IDirectPlay4AImpl *This = (IDirectPlay4AImpl *)*ppvObj;
+ IDirectPlay4AImpl *This = *ppvObj;
This->lpVtbl = &directPlay4AVT;
}
else
ulObjRefCount = InterlockedIncrement( &This->unk->ulObjRef );
ulInterfaceRefCount = InterlockedIncrement( &This->ulInterfaceRef );
- TRACE( "ref count incremented to %lu:%lu for %p\n",
+ TRACE( "ref count incremented to %u:%u for %p\n",
ulInterfaceRefCount, ulObjRefCount, This );
return ulObjRefCount;
ulObjRefCount = InterlockedDecrement( &This->unk->ulObjRef );
ulInterfaceRefCount = InterlockedDecrement( &This->ulInterfaceRef );
- TRACE( "ref count decremented to %lu:%lu for %p\n",
+ TRACE( "ref count decremented to %u:%u for %p\n",
ulInterfaceRefCount, ulObjRefCount, This );
/* Deallocate if this is the last reference to the object */
WORD wCommandId, WORD wVersion,
LPVOID* lplpReply, LPDWORD lpdwMsgSize )
{
- TRACE( "(%p)->(%p,0x%08lx,%p,%u,%u)\n",
+ TRACE( "(%p)->(%p,0x%08x,%p,%u,%u)\n",
This, lpcMessageBody, dwMessageBodySize, lpcMessageHeader, wCommandId,
wVersion );
{
/* Name server needs to handle this request */
case DPMSGCMD_ENUMSESSIONSREQUEST:
- {
/* Reply expected */
NS_ReplyToEnumSessionsRequest( lpcMessageBody, lplpReply, lpdwMsgSize, This );
-
break;
- }
/* Name server needs to handle this request */
case DPMSGCMD_ENUMSESSIONSREPLY:
- {
/* No reply expected */
NS_AddRemoteComputerAsNameServer( lpcMessageHeader,
This->dp2->spData.dwSPHeaderSize,
- (LPDPMSG_ENUMSESSIONSREPLY)lpcMessageBody,
+ lpcMessageBody,
This->dp2->lpNameServerData );
break;
- }
case DPMSGCMD_REQUESTNEWPLAYERID:
{
- LPCDPMSG_REQUESTNEWPLAYERID lpcMsg =
- (LPCDPMSG_REQUESTNEWPLAYERID)lpcMessageBody;
+ LPCDPMSG_REQUESTNEWPLAYERID lpcMsg = lpcMessageBody;
LPDPMSG_NEWPLAYERIDREPLY lpReply;
*lplpReply = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, *lpdwMsgSize );
- FIXME( "Ignoring dwFlags 0x%08lx in request msg\n",
+ FIXME( "Ignoring dwFlags 0x%08x in request msg\n",
lpcMsg->dwFlags );
/* Setup the reply */
lpReply->dpidNewPlayerId = DP_NextObjectId();
- TRACE( "Allocating new playerid 0x%08lx from remote request\n",
+ TRACE( "Allocating new playerid 0x%08x from remote request\n",
lpReply->dpidNewPlayerId );
-
break;
}
case DPMSGCMD_GETNAMETABLEREPLY:
case DPMSGCMD_NEWPLAYERIDREPLY:
- {
-
#if 0
if( wCommandId == DPMSGCMD_NEWPLAYERIDREPLY )
DebugBreak();
#endif
DP_MSG_ReplyReceived( This, wCommandId, lpcMessageBody, dwMessageBodySize );
-
break;
- }
#if 1
case DPMSGCMD_JUSTENVELOPE:
- {
- TRACE( "GOT THE SELF MESSAGE: %p -> 0x%08lx\n", lpcMessageHeader, ((LPDWORD)lpcMessageHeader)[1] );
+ TRACE( "GOT THE SELF MESSAGE: %p -> 0x%08x\n", lpcMessageHeader, ((const DWORD *)lpcMessageHeader)[1] );
NS_SetLocalAddr( This->dp2->lpNameServerData, lpcMessageHeader, 20 );
DP_MSG_ReplyReceived( This, wCommandId, lpcMessageBody, dwMessageBodySize );
- }
#endif
case DPMSGCMD_FORWARDADDPLAYER:
- {
#if 0
DebugBreak();
#endif
#if 1
- TRACE( "Sending message to self to get my addr\n" );
- DP_MSG_ToSelf( This, 1 ); /* This is a hack right now */
+ TRACE( "Sending message to self to get my addr\n" );
+ DP_MSG_ToSelf( This, 1 ); /* This is a hack right now */
#endif
break;
- }
case DPMSGCMD_FORWARDADDPLAYERNACK:
- {
DP_MSG_ErrorReceived( This, wCommandId, lpcMessageBody, dwMessageBodySize );
break;
- }
default:
- {
FIXME( "Unknown wCommandId %u. Ignoring message\n", wCommandId );
DebugBreak();
break;
- }
}
/* FIXME: There is code in dplaysp.c to handle dplay commands. Move to here. */
}
-static HRESULT WINAPI DP_IF_AddPlayerToGroup
+static HRESULT DP_IF_AddPlayerToGroup
( IDirectPlay2Impl* This, LPVOID lpMsgHdr, DPID idGroup,
DPID idPlayer, BOOL bAnsi )
{
lpPlayerList lpPList;
lpPlayerList lpNewPList;
- TRACE( "(%p)->(%p,0x%08lx,0x%08lx,%u)\n",
+ TRACE( "(%p)->(%p,0x%08x,0x%08x,%u)\n",
This, lpMsgHdr, idGroup, idPlayer, bAnsi );
+ if( This->dp2->connectionInitialized == NO_PROVIDER )
+ {
+ return DPERR_UNINITIALIZED;
+ }
+
/* Find the group */
if( ( lpGData = DP_FindAnyGroup( This, idGroup ) ) == NULL )
{
return DP_IF_AddPlayerToGroup( This, NULL, idGroup, idPlayer, FALSE );
}
-static HRESULT WINAPI DP_IF_Close( IDirectPlay2Impl* This, BOOL bAnsi )
+static HRESULT DP_IF_Close( IDirectPlay2Impl* This, BOOL bAnsi )
{
HRESULT hr = DP_OK;
}
static
-lpGroupData DP_CreateGroup( IDirectPlay2AImpl* This, LPDPID lpid,
- LPDPNAME lpName, DWORD dwFlags,
+lpGroupData DP_CreateGroup( IDirectPlay2AImpl* This, const DPID *lpid,
+ const DPNAME *lpName, DWORD dwFlags,
DPID idParent, BOOL bAnsi )
{
lpGroupData lpGData;
/* FIXME: Should we validate the dwFlags? */
lpGData->dwFlags = dwFlags;
- TRACE( "Created group id 0x%08lx\n", *lpid );
+ TRACE( "Created group id 0x%08x\n", *lpid );
return lpGData;
}
{
lpGroupList lpGList;
- TRACE( "(%p)->(0x%08lx)\n", This, dpid );
+ TRACE( "(%p)->(0x%08x)\n", This, dpid );
DPQ_REMOVE_ENTRY( This->dp2->lpSysGroup->groups, groups, lpGData->dpid, ==, dpid, lpGList );
if( lpGList == NULL )
{
- ERR( "DPID 0x%08lx not found\n", dpid );
+ ERR( "DPID 0x%08x not found\n", dpid );
return;
}
{
lpGroupList lpGroups;
- TRACE( "(%p)->(0x%08lx)\n", This, dpid );
+ TRACE( "(%p)->(0x%08x)\n", This, dpid );
if( dpid == DPID_SYSTEM_GROUP )
{
return lpGroups->lpGData;
}
-static HRESULT WINAPI DP_IF_CreateGroup
+static HRESULT DP_IF_CreateGroup
( IDirectPlay2AImpl* This, LPVOID lpMsgHdr, LPDPID lpidGroup,
LPDPNAME lpGroupName, LPVOID lpData, DWORD dwDataSize,
DWORD dwFlags, BOOL bAnsi )
{
lpGroupData lpGData;
- TRACE( "(%p)->(%p,%p,%p,%p,0x%08lx,0x%08lx,%u)\n",
+ TRACE( "(%p)->(%p,%p,%p,%p,0x%08x,0x%08x,%u)\n",
This, lpMsgHdr, lpidGroup, lpGroupName, lpData, dwDataSize,
dwFlags, bAnsi );
+ if( This->dp2->connectionInitialized == NO_PROVIDER )
+ {
+ return DPERR_UNINITIALIZED;
+ }
+
/* If the name is not specified, we must provide one */
if( DPID_UNKNOWN == *lpidGroup )
{
/* Reallocate for new data */
if( lpData != NULL )
{
- LPVOID lpNewData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
- sizeof( dwDataSize ) );
- CopyMemory( lpNewData, lpData, dwDataSize );
-
if( dwFlags & DPSET_LOCAL )
{
lpGData->lpLocalData = lpData;
}
else
{
- lpGData->lpRemoteData = lpNewData;
+ lpGData->lpRemoteData = HeapAlloc( GetProcessHeap(), 0, dwDataSize );
+ CopyMemory( lpGData->lpRemoteData, lpData, dwDataSize );
lpGData->dwRemoteDataSize = dwDataSize;
}
}
/* Initialize the SP data section */
lpPData->lpSPPlayerData = DPSP_CreateSPPlayerData();
- TRACE( "Created player id 0x%08lx\n", *lpid );
+ TRACE( "Created player id 0x%08x\n", *lpid );
+
+ if( ~dwFlags & DPLAYI_PLAYER_SYSPLAYER )
+ This->dp2->lpSessionDesc->dwCurrentPlayers++;
return lpPData;
}
static void
DP_DeleteDPNameStruct( LPDPNAME lpDPName )
{
- HeapFree( GetProcessHeap(), HEAP_ZERO_MEMORY, lpDPName->lpszShortNameA );
- HeapFree( GetProcessHeap(), HEAP_ZERO_MEMORY, lpDPName->lpszLongNameA );
+ HeapFree( GetProcessHeap(), HEAP_ZERO_MEMORY, lpDPName->u1.lpszShortNameA );
+ HeapFree( GetProcessHeap(), HEAP_ZERO_MEMORY, lpDPName->u2.lpszLongNameA );
}
/* This method assumes that all links to it are already deleted */
{
lpPlayerList lpPList;
- TRACE( "(%p)->(0x%08lx)\n", This, dpid );
+ TRACE( "(%p)->(0x%08x)\n", This, dpid );
DPQ_REMOVE_ENTRY( This->dp2->lpSysGroup->players, players, lpPData->dpid, ==, dpid, lpPList );
if( lpPList == NULL )
{
- ERR( "DPID 0x%08lx not found\n", dpid );
+ ERR( "DPID 0x%08x not found\n", dpid );
return;
}
{
lpPlayerList lpPlayers;
- TRACE( "(%p)->(0x%08lx)\n", This, dpid );
+ TRACE( "(%p)->(0x%08x)\n", This, dpid );
+
+ if(This->dp2->lpSysGroup == NULL)
+ return NULL;
DPQ_FIND_ENTRY( This->dp2->lpSysGroup->players, players, lpPData->dpid, ==, dpid, lpPlayers );
}
/* Basic area for Dst must already be allocated */
-static BOOL DP_CopyDPNAMEStruct( LPDPNAME lpDst, LPDPNAME lpSrc, BOOL bAnsi )
+static BOOL DP_CopyDPNAMEStruct( LPDPNAME lpDst, const DPNAME *lpSrc, BOOL bAnsi )
{
if( lpSrc == NULL )
{
}
/* Delete any existing pointers */
- HeapFree( GetProcessHeap(), 0, lpDst->lpszShortNameA );
- HeapFree( GetProcessHeap(), 0, lpDst->lpszLongNameA );
+ HeapFree( GetProcessHeap(), 0, lpDst->u1.lpszShortNameA );
+ HeapFree( GetProcessHeap(), 0, lpDst->u2.lpszLongNameA );
/* Copy as required */
CopyMemory( lpDst, lpSrc, lpSrc->dwSize );
if( bAnsi )
{
- if( lpSrc->lpszShortNameA )
+ if( lpSrc->u1.lpszShortNameA )
{
- lpDst->lpszShortNameA = HeapAlloc( GetProcessHeap(), 0,
- strlen(lpSrc->lpszShortNameA)+1 );
- strcpy( lpDst->lpszShortNameA, lpSrc->lpszShortNameA );
+ lpDst->u1.lpszShortNameA = HeapAlloc( GetProcessHeap(), 0,
+ strlen(lpSrc->u1.lpszShortNameA)+1 );
+ strcpy( lpDst->u1.lpszShortNameA, lpSrc->u1.lpszShortNameA );
}
- if( lpSrc->lpszLongNameA )
+ if( lpSrc->u2.lpszLongNameA )
{
- lpDst->lpszLongNameA = HeapAlloc( GetProcessHeap(), 0,
- strlen(lpSrc->lpszLongNameA)+1 );
- strcpy( lpDst->lpszLongNameA, lpSrc->lpszLongNameA );
+ lpDst->u2.lpszLongNameA = HeapAlloc( GetProcessHeap(), 0,
+ strlen(lpSrc->u2.lpszLongNameA)+1 );
+ strcpy( lpDst->u2.lpszLongNameA, lpSrc->u2.lpszLongNameA );
}
}
else
{
- if( lpSrc->lpszShortNameA )
+ if( lpSrc->u1.lpszShortNameA )
{
- lpDst->lpszShortName = HeapAlloc( GetProcessHeap(), 0,
- (strlenW(lpSrc->lpszShortName)+1)*sizeof(WCHAR) );
- strcpyW( lpDst->lpszShortName, lpSrc->lpszShortName );
+ lpDst->u1.lpszShortName = HeapAlloc( GetProcessHeap(), 0,
+ (strlenW(lpSrc->u1.lpszShortName)+1)*sizeof(WCHAR) );
+ strcpyW( lpDst->u1.lpszShortName, lpSrc->u1.lpszShortName );
}
- if( lpSrc->lpszLongNameA )
+ if( lpSrc->u2.lpszLongNameA )
{
- lpDst->lpszLongName = HeapAlloc( GetProcessHeap(), 0,
- (strlenW(lpSrc->lpszLongName)+1)*sizeof(WCHAR) );
- strcpyW( lpDst->lpszLongName, lpSrc->lpszLongName );
+ lpDst->u2.lpszLongName = HeapAlloc( GetProcessHeap(), 0,
+ (strlenW(lpSrc->u2.lpszLongName)+1)*sizeof(WCHAR) );
+ strcpyW( lpDst->u2.lpszLongName, lpSrc->u2.lpszLongName );
}
}
/* Reallocate for new data */
if( lpData != NULL )
{
- LPVOID lpNewData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
- sizeof( dwDataSize ) );
- CopyMemory( lpNewData, lpData, dwDataSize );
if( dwFlags & DPSET_LOCAL )
{
}
else
{
- lpPData->lpRemoteData = lpNewData;
+ lpPData->lpRemoteData = HeapAlloc( GetProcessHeap(), 0, dwDataSize );
+ CopyMemory( lpPData->lpRemoteData, lpData, dwDataSize );
lpPData->dwRemoteDataSize = dwDataSize;
}
}
}
-static HRESULT WINAPI DP_IF_CreatePlayer
+static HRESULT DP_IF_CreatePlayer
( IDirectPlay2Impl* This,
LPVOID lpMsgHdr, /* NULL for local creation, non NULL for remote creation */
LPDPID lpidPlayer,
lpPlayerList lpPList;
DWORD dwCreateFlags = 0;
- TRACE( "(%p)->(%p,%p,%p,%p,0x%08lx,0x%08lx,%u)\n",
+ TRACE( "(%p)->(%p,%p,%p,%p,0x%08x,0x%08x,%u)\n",
This, lpidPlayer, lpPlayerName, hEvent, lpData,
dwDataSize, dwFlags, bAnsi );
+ if( This->dp2->connectionInitialized == NO_PROVIDER )
+ {
+ return DPERR_UNINITIALIZED;
+ }
if( dwFlags == 0 )
{
)
{
/* Assume non fatal failure */
- ERR( "unknown dwFlags = 0x%08lx\n", dwFlags );
+ ERR( "unknown dwFlags = 0x%08x\n", dwFlags );
}
/* If the name is not specified, we must provide one */
*/
}
- /* FIXME: Should we be storing these dwFlags or the creation ones? */
- lpPData = DP_CreatePlayer( This, lpidPlayer, lpPlayerName, dwFlags,
+ /* We pass creation flags, so we can distinguish sysplayers and not count them in the current
+ player total */
+ lpPData = DP_CreatePlayer( This, lpidPlayer, lpPlayerName, dwCreateFlags,
hEvent, bAnsi );
if( lpPData == NULL )
data.lpSPMessageHeader = lpMsgHdr;
data.lpISP = This->dp2->spData.lpISP;
- TRACE( "Calling SP CreatePlayer 0x%08lx: dwFlags: 0x%08lx lpMsgHdr: %p\n",
+ TRACE( "Calling SP CreatePlayer 0x%08x: dwFlags: 0x%08x lpMsgHdr: %p\n",
*lpidPlayer, data.dwFlags, data.lpSPMessageHeader );
hr = (*This->dp2->spData.lpCB->CreatePlayer)( &data );
{
IDirectPlay2Impl *This = (IDirectPlay2Impl *)iface;
+ if( lpidPlayer == NULL )
+ {
+ return DPERR_INVALIDPARAMS;
+ }
+
if( dwFlags & DPPLAYER_SERVERPLAYER )
{
*lpidPlayer = DPID_SERVERPLAYER;
{
IDirectPlay2Impl *This = (IDirectPlay2Impl *)iface;
+ if( lpidPlayer == NULL )
+ {
+ return DPERR_INVALIDPARAMS;
+ }
+
if( dwFlags & DPPLAYER_SERVERPLAYER )
{
*lpidPlayer = DPID_SERVERPLAYER;
return DP_NextObjectId();
}
-static HRESULT WINAPI DP_IF_DeletePlayerFromGroup
+static HRESULT DP_IF_DeletePlayerFromGroup
( IDirectPlay2Impl* This, LPVOID lpMsgHdr, DPID idGroup,
DPID idPlayer, BOOL bAnsi )
{
lpGroupData lpGData;
lpPlayerList lpPList;
- TRACE( "(%p)->(%p,0x%08lx,0x%08lx,%u)\n",
+ TRACE( "(%p)->(%p,0x%08x,0x%08x,%u)\n",
This, lpMsgHdr, idGroup, idPlayer, bAnsi );
/* Find the group */
{
lpDPRGOPContext lpCtxt = (lpDPRGOPContext)lpContext;
- TRACE( "Removing element:0x%08lx (type:0x%08lx) from element:0x%08lx\n",
+ TRACE( "Removing element:0x%08x (type:0x%08x) from element:0x%08x\n",
dpId, dwPlayerType, lpCtxt->idGroup );
if( dwPlayerType == DPPLAYERTYPE_GROUP )
)
)
{
- ERR( "Unable to delete group 0x%08lx from group 0x%08lx\n",
+ ERR( "Unable to delete group 0x%08x from group 0x%08x\n",
dpId, lpCtxt->idGroup );
}
}
)
)
{
- ERR( "Unable to delete player 0x%08lx from grp 0x%08lx\n",
+ ERR( "Unable to delete player 0x%08x from grp 0x%08x\n",
dpId, lpCtxt->idGroup );
}
}
return TRUE; /* Continue enumeration */
}
-static HRESULT WINAPI DP_IF_DestroyGroup
+static HRESULT DP_IF_DestroyGroup
( IDirectPlay2Impl* This, LPVOID lpMsgHdr, DPID idGroup, BOOL bAnsi )
{
lpGroupData lpGData;
DPRGOPContext context;
- FIXME( "(%p)->(%p,0x%08lx,%u): semi stub\n",
+ FIXME( "(%p)->(%p,0x%08x,%u): semi stub\n",
This, lpMsgHdr, idGroup, bAnsi );
/* Find the group */
/* Remove all players that this group has */
DP_IF_EnumGroupPlayers( This, idGroup, NULL,
- cbRemoveGroupOrPlayer, (LPVOID)&context, 0, bAnsi );
+ cbRemoveGroupOrPlayer, &context, 0, bAnsi );
/* Remove all links to groups that this group has since this is dp3 */
DP_IF_EnumGroupsInGroup( (IDirectPlay3Impl*)This, idGroup, NULL,
BOOL bAnsi;
} DPFAGContext, *lpDPFAGContext;
-static HRESULT WINAPI DP_IF_DestroyPlayer
+static HRESULT DP_IF_DestroyPlayer
( IDirectPlay2Impl* This, LPVOID lpMsgHdr, DPID idPlayer, BOOL bAnsi )
{
DPFAGContext cbContext;
- FIXME( "(%p)->(%p,0x%08lx,%u): semi stub\n",
+ FIXME( "(%p)->(%p,0x%08x,%u): semi stub\n",
This, lpMsgHdr, idPlayer, bAnsi );
if( This->dp2->connectionInitialized == NO_PROVIDER )
/* Find each group and call DeletePlayerFromGroup if the player is a
member of the group */
DP_IF_EnumGroups( This, NULL, cbDeletePlayerFromAllGroups,
- (LPVOID)&cbContext, DPENUMGROUPS_ALL, bAnsi );
+ &cbContext, DPENUMGROUPS_ALL, bAnsi );
/* Now delete player and player list from the sys group */
DP_DeletePlayer( This, idPlayer );
DP_IF_EnumGroupsInGroup( (IDirectPlay3Impl*)lpCtxt->This,
dpId, NULL,
cbDeletePlayerFromAllGroups,
- (LPVOID)lpContext, DPENUMGROUPS_ALL,
+ lpContext, DPENUMGROUPS_ALL,
lpCtxt->bAnsi );
}
else
{
- ERR( "Group callback has dwPlayerType = 0x%08lx\n", dwPlayerType );
+ ERR( "Group callback has dwPlayerType = 0x%08x\n", dwPlayerType );
}
return TRUE;
return DP_IF_DestroyPlayer( This, NULL, idPlayer, FALSE );
}
-static HRESULT WINAPI DP_IF_EnumGroupPlayers
+static HRESULT DP_IF_EnumGroupPlayers
( IDirectPlay2Impl* This, DPID idGroup, LPGUID lpguidInstance,
LPDPENUMPLAYERSCALLBACK2 lpEnumPlayersCallback2,
LPVOID lpContext, DWORD dwFlags, BOOL bAnsi )
lpGroupData lpGData;
lpPlayerList lpPList;
- FIXME("(%p)->(0x%08lx,%p,%p,%p,0x%08lx,%u): semi stub\n",
+ FIXME("(%p)->(0x%08x,%p,%p,%p,0x%08x,%u): semi stub\n",
This, idGroup, lpguidInstance, lpEnumPlayersCallback2,
lpContext, dwFlags, bAnsi );
for( ;; )
{
/* We do not enum the name server or app server as they are of no
- * concequence to the end user.
+ * consequence to the end user.
*/
if( ( lpPList->lpPData->dpid != DPID_NAME_SERVER ) &&
( lpPList->lpPData->dpid != DPID_SERVERPLAYER )
}
/* NOTE: This only enumerates top level groups (created with CreateGroup) */
-static HRESULT WINAPI DP_IF_EnumGroups
+static HRESULT DP_IF_EnumGroups
( IDirectPlay2Impl* This, LPGUID lpguidInstance,
LPDPENUMPLAYERSCALLBACK2 lpEnumPlayersCallback2,
LPVOID lpContext, DWORD dwFlags, BOOL bAnsi )
lpContext, dwFlags, FALSE );
}
-static HRESULT WINAPI DP_IF_EnumPlayers
+static HRESULT DP_IF_EnumPlayers
( IDirectPlay2Impl* This, LPGUID lpguidInstance,
LPDPENUMPLAYERSCALLBACK2 lpEnumPlayersCallback2,
LPVOID lpContext, DWORD dwFlags, BOOL bAnsi )
static DWORD CALLBACK DP_EnumSessionsSendAsyncRequestThread( LPVOID lpContext )
{
- EnumSessionAsyncCallbackData* data = (EnumSessionAsyncCallbackData*)lpContext;
+ EnumSessionAsyncCallbackData* data = lpContext;
HANDLE hSuicideRequest = data->hSuicideRequest;
DWORD dwTimeout = data->dwTimeout;
- TRACE( "Thread started with timeout = 0x%08lx\n", dwTimeout );
+ TRACE( "Thread started with timeout = 0x%08x\n", dwTimeout );
for( ;; )
{
}
}
-static HRESULT WINAPI DP_IF_EnumSessions
+static HRESULT DP_IF_EnumSessions
( IDirectPlay2Impl* This, LPDPSESSIONDESC2 lpsd, DWORD dwTimeout,
LPDPENUMSESSIONSCALLBACK2 lpEnumSessionsCallback2,
LPVOID lpContext, DWORD dwFlags, BOOL bAnsi )
{
HRESULT hr = DP_OK;
- TRACE( "(%p)->(%p,0x%08lx,%p,%p,0x%08lx,%u)\n",
+ TRACE( "(%p)->(%p,0x%08x,%p,%p,0x%08x,%u)\n",
This, lpsd, dwTimeout, lpEnumSessionsCallback2, lpContext, dwFlags,
bAnsi );
+ if( This->dp2->connectionInitialized == NO_PROVIDER )
+ {
+ return DPERR_UNINITIALIZED;
+ }
/* Can't enumerate if the interface is already open */
if( This->dp2->bConnectionOpen )
return hr;
}
- /* FIXME: Interface locking sucks in this method */
if( ( dwFlags & DPENUMSESSIONS_ASYNC ) )
{
/* Enumerate everything presently in the local session cache */
This->dp2->lpNameServerData, dwTimeout,
lpContext );
+ if( This->dp2->dwEnumSessionLock != 0 )
+ return DPERR_CONNECTING;
/* See if we've already created a thread to service this interface */
if( This->dp2->hEnumSessionThread == INVALID_HANDLE_VALUE )
{
DWORD dwThreadId;
+ This->dp2->dwEnumSessionLock++;
/* Send the first enum request inline since the user may cancel a dialog
* if one is presented. Also, may also have a connecting return code.
hr = NS_SendSessionRequestBroadcast( &lpsd->guidApplication,
dwFlags, &This->dp2->spData );
- if( !FAILED(hr) )
+ if( SUCCEEDED(hr) )
{
EnumSessionAsyncCallbackData* lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *lpData ) );
/* FIXME: need to kill the thread on object deletion */
lpData->lpSpData = &This->dp2->spData;
- CopyMemory( &lpData->requestGuid, &lpsd->guidApplication, sizeof(GUID) );
+ lpData->requestGuid = lpsd->guidApplication;
lpData->dwEnumSessionFlags = dwFlags;
lpData->dwTimeout = dwTimeout;
0,
&dwThreadId );
}
+ This->dp2->dwEnumSessionLock--;
}
}
else
lpContext, dwFlags, FALSE );
}
-static HRESULT WINAPI DP_IF_GetPlayerCaps
+static HRESULT DP_IF_GetPlayerCaps
( IDirectPlay2Impl* This, DPID idPlayer, LPDPCAPS lpDPCaps,
DWORD dwFlags )
{
DPSP_GETCAPSDATA data;
- TRACE("(%p)->(0x%08lx,%p,0x%08lx)\n", This, idPlayer, lpDPCaps, dwFlags);
+ TRACE("(%p)->(0x%08x,%p,0x%08x)\n", This, idPlayer, lpDPCaps, dwFlags);
+
+ if ( This->dp2->connectionInitialized == NO_PROVIDER )
+ {
+ return DPERR_UNINITIALIZED;
+ }
/* Query the service provider */
data.idPlayer = idPlayer;
return (*This->dp2->spData.lpCB->GetCaps)( &data );
}
-static HRESULT WINAPI DP_IF_GetCaps
+static HRESULT DP_IF_GetCaps
( IDirectPlay2Impl* This, LPDPCAPS lpDPCaps, DWORD dwFlags )
{
return DP_IF_GetPlayerCaps( This, DPID_ALLPLAYERS, lpDPCaps, dwFlags );
return DP_IF_GetCaps( This, lpDPCaps, dwFlags );
}
-static HRESULT WINAPI DP_IF_GetGroupData
+static HRESULT DP_IF_GetGroupData
( IDirectPlay2Impl* This, DPID idGroup, LPVOID lpData,
LPDWORD lpdwDataSize, DWORD dwFlags, BOOL bAnsi )
{
DWORD dwRequiredBufferSize;
LPVOID lpCopyDataFrom;
- TRACE( "(%p)->(0x%08lx,%p,%p,0x%08lx,%u)\n",
+ TRACE( "(%p)->(0x%08x,%p,%p,0x%08x,%u)\n",
This, idGroup, lpData, lpdwDataSize, dwFlags, bAnsi );
if( ( lpGData = DP_FindAnyGroup( This, idGroup ) ) == NULL )
dwFlags, FALSE );
}
-static HRESULT WINAPI DP_IF_GetGroupName
+static HRESULT DP_IF_GetGroupName
( IDirectPlay2Impl* This, DPID idGroup, LPVOID lpData,
LPDWORD lpdwDataSize, BOOL bAnsi )
{
lpGroupData lpGData;
- LPDPNAME lpName = (LPDPNAME)lpData;
+ LPDPNAME lpName = lpData;
DWORD dwRequiredDataSize;
- FIXME("(%p)->(0x%08lx,%p,%p,%u) ANSI ignored\n",
+ FIXME("(%p)->(0x%08x,%p,%p,%u) ANSI ignored\n",
This, idGroup, lpData, lpdwDataSize, bAnsi );
if( ( lpGData = DP_FindAnyGroup( This, idGroup ) ) == NULL )
dwRequiredDataSize = lpGData->name.dwSize;
- if( lpGData->name.lpszShortNameA )
+ if( lpGData->name.u1.lpszShortNameA )
{
- dwRequiredDataSize += strlen( lpGData->name.lpszShortNameA ) + 1;
+ dwRequiredDataSize += strlen( lpGData->name.u1.lpszShortNameA ) + 1;
}
- if( lpGData->name.lpszLongNameA )
+ if( lpGData->name.u2.lpszLongNameA )
{
- dwRequiredDataSize += strlen( lpGData->name.lpszLongNameA ) + 1;
+ dwRequiredDataSize += strlen( lpGData->name.u2.lpszLongNameA ) + 1;
}
if( ( lpData == NULL ) ||
/* Copy the structure */
CopyMemory( lpName, &lpGData->name, lpGData->name.dwSize );
- if( lpGData->name.lpszShortNameA )
+ if( lpGData->name.u1.lpszShortNameA )
{
strcpy( ((char*)lpName)+lpGData->name.dwSize,
- lpGData->name.lpszShortNameA );
+ lpGData->name.u1.lpszShortNameA );
}
else
{
- lpName->lpszShortNameA = NULL;
+ lpName->u1.lpszShortNameA = NULL;
}
- if( lpGData->name.lpszShortNameA )
+ if( lpGData->name.u1.lpszShortNameA )
{
strcpy( ((char*)lpName)+lpGData->name.dwSize,
- lpGData->name.lpszLongNameA );
+ lpGData->name.u2.lpszLongNameA );
}
else
{
- lpName->lpszLongNameA = NULL;
+ lpName->u2.lpszLongNameA = NULL;
}
return DP_OK;
return DP_IF_GetGroupName( This, idGroup, lpData, lpdwDataSize, FALSE );
}
-static HRESULT WINAPI DP_IF_GetMessageCount
+static HRESULT DP_IF_GetMessageCount
( IDirectPlay2Impl* This, DPID idPlayer,
LPDWORD lpdwCount, BOOL bAnsi )
{
- FIXME("(%p)->(0x%08lx,%p,%u): stub\n", This, idPlayer, lpdwCount, bAnsi );
+ FIXME("(%p)->(0x%08x,%p,%u): stub\n", This, idPlayer, lpdwCount, bAnsi );
return DP_IF_GetMessageQueue( (IDirectPlay4Impl*)This, 0, idPlayer,
DPMESSAGEQUEUE_RECEIVE, lpdwCount, NULL,
bAnsi );
( LPDIRECTPLAY2A iface, DPID idPlayer, LPVOID lpData, LPDWORD lpdwDataSize )
{
IDirectPlay2Impl *This = (IDirectPlay2Impl *)iface;
- FIXME("(%p)->(0x%08lx,%p,%p): stub\n", This, idPlayer, lpData, lpdwDataSize );
+ FIXME("(%p)->(0x%08x,%p,%p): stub\n", This, idPlayer, lpData, lpdwDataSize );
return DP_OK;
}
( LPDIRECTPLAY2 iface, DPID idPlayer, LPVOID lpData, LPDWORD lpdwDataSize )
{
IDirectPlay2Impl *This = (IDirectPlay2Impl *)iface;
- FIXME("(%p)->(0x%08lx,%p,%p): stub\n", This, idPlayer, lpData, lpdwDataSize );
+ FIXME("(%p)->(0x%08x,%p,%p): stub\n", This, idPlayer, lpData, lpdwDataSize );
return DP_OK;
}
return DP_IF_GetPlayerCaps( This, idPlayer, lpPlayerCaps, dwFlags );
}
-static HRESULT WINAPI DP_IF_GetPlayerData
+static HRESULT DP_IF_GetPlayerData
( IDirectPlay2Impl* This, DPID idPlayer, LPVOID lpData,
LPDWORD lpdwDataSize, DWORD dwFlags, BOOL bAnsi )
{
DWORD dwRequiredBufferSize;
LPVOID lpCopyDataFrom;
- TRACE( "(%p)->(0x%08lx,%p,%p,0x%08lx,%u)\n",
+ TRACE( "(%p)->(0x%08x,%p,%p,0x%08x,%u)\n",
This, idPlayer, lpData, lpdwDataSize, dwFlags, bAnsi );
if( This->dp2->connectionInitialized == NO_PROVIDER )
dwFlags, FALSE );
}
-static HRESULT WINAPI DP_IF_GetPlayerName
+static HRESULT DP_IF_GetPlayerName
( IDirectPlay2Impl* This, DPID idPlayer, LPVOID lpData,
LPDWORD lpdwDataSize, BOOL bAnsi )
{
lpPlayerList lpPList;
- LPDPNAME lpName = (LPDPNAME)lpData;
+ LPDPNAME lpName = lpData;
DWORD dwRequiredDataSize;
- FIXME( "(%p)->(0x%08lx,%p,%p,%u): ANSI\n",
+ FIXME( "(%p)->(0x%08x,%p,%p,%u): ANSI\n",
This, idPlayer, lpData, lpdwDataSize, bAnsi );
+ if( This->dp2->connectionInitialized == NO_PROVIDER )
+ {
+ return DPERR_UNINITIALIZED;
+ }
+
if( ( lpPList = DP_FindPlayer( This, idPlayer ) ) == NULL )
{
return DPERR_INVALIDPLAYER;
dwRequiredDataSize = lpPList->lpPData->name.dwSize;
- if( lpPList->lpPData->name.lpszShortNameA )
+ if( lpPList->lpPData->name.u1.lpszShortNameA )
{
- dwRequiredDataSize += strlen( lpPList->lpPData->name.lpszShortNameA ) + 1;
+ dwRequiredDataSize += strlen( lpPList->lpPData->name.u1.lpszShortNameA ) + 1;
}
- if( lpPList->lpPData->name.lpszLongNameA )
+ if( lpPList->lpPData->name.u2.lpszLongNameA )
{
- dwRequiredDataSize += strlen( lpPList->lpPData->name.lpszLongNameA ) + 1;
+ dwRequiredDataSize += strlen( lpPList->lpPData->name.u2.lpszLongNameA ) + 1;
}
if( ( lpData == NULL ) ||
/* Copy the structure */
CopyMemory( lpName, &lpPList->lpPData->name, lpPList->lpPData->name.dwSize );
- if( lpPList->lpPData->name.lpszShortNameA )
+ if( lpPList->lpPData->name.u1.lpszShortNameA )
{
strcpy( ((char*)lpName)+lpPList->lpPData->name.dwSize,
- lpPList->lpPData->name.lpszShortNameA );
+ lpPList->lpPData->name.u1.lpszShortNameA );
}
else
{
- lpName->lpszShortNameA = NULL;
+ lpName->u1.lpszShortNameA = NULL;
}
- if( lpPList->lpPData->name.lpszShortNameA )
+ if( lpPList->lpPData->name.u1.lpszShortNameA )
{
strcpy( ((char*)lpName)+lpPList->lpPData->name.dwSize,
- lpPList->lpPData->name.lpszLongNameA );
+ lpPList->lpPData->name.u2.lpszLongNameA );
}
else
{
- lpName->lpszLongNameA = NULL;
+ lpName->u2.lpszLongNameA = NULL;
}
return DP_OK;
return DP_IF_GetPlayerName( This, idPlayer, lpData, lpdwDataSize, FALSE );
}
-static HRESULT WINAPI DP_GetSessionDesc
+static HRESULT DP_GetSessionDesc
( IDirectPlay2Impl* This, LPVOID lpData, LPDWORD lpdwDataSize,
BOOL bAnsi )
{
}
-static HRESULT WINAPI DP_SecureOpen
+static HRESULT DP_SecureOpen
( IDirectPlay2Impl* This, LPCDPSESSIONDESC2 lpsd, DWORD dwFlags,
LPCDPSECURITYDESC lpSecurity, LPCDPCREDENTIALS lpCredentials,
BOOL bAnsi )
{
HRESULT hr = DP_OK;
- FIXME( "(%p)->(%p,0x%08lx,%p,%p): partial stub\n",
+ FIXME( "(%p)->(%p,0x%08x,%p,%p): partial stub\n",
This, lpsd, dwFlags, lpSecurity, lpCredentials );
+ if( This->dp2->connectionInitialized == NO_PROVIDER )
+ {
+ return DPERR_UNINITIALIZED;
+ }
+
+ if( lpsd->dwSize != sizeof(DPSESSIONDESC2) )
+ {
+ TRACE( ": rejecting invalid dpsd size (%d).\n", lpsd->dwSize );
+ return DPERR_INVALIDPARAMS;
+ }
+
if( This->dp2->bConnectionOpen )
{
TRACE( ": rejecting already open connection.\n" );
FIXME( "Not all data fields are correct. Need new parameter\n" );
- data.bCreate = (dwFlags & DPOPEN_CREATE ) ? TRUE : FALSE;
+ data.bCreate = (dwFlags & DPOPEN_CREATE ) != 0;
data.lpSPMessageHeader = (dwFlags & DPOPEN_CREATE ) ? NULL
: NS_GetNSAddr( This->dp2->lpNameServerData );
data.lpISP = This->dp2->spData.lpISP;
- data.bReturnStatus = (dwFlags & DPOPEN_RETURNSTATUS) ? TRUE : FALSE;
+ data.bReturnStatus = (dwFlags & DPOPEN_RETURNSTATUS) != 0;
data.dwOpenFlags = dwFlags;
data.dwSessionFlags = This->dp2->lpSessionDesc->dwFlags;
( LPDIRECTPLAY2A iface, LPDPSESSIONDESC2 lpsd, DWORD dwFlags )
{
IDirectPlay2Impl *This = (IDirectPlay2Impl *)iface;
- TRACE("(%p)->(%p,0x%08lx)\n", This, lpsd, dwFlags );
+ TRACE("(%p)->(%p,0x%08x)\n", This, lpsd, dwFlags );
return DP_SecureOpen( This, lpsd, dwFlags, NULL, NULL, TRUE );
}
( LPDIRECTPLAY2 iface, LPDPSESSIONDESC2 lpsd, DWORD dwFlags )
{
IDirectPlay2Impl *This = (IDirectPlay2Impl *)iface;
- TRACE("(%p)->(%p,0x%08lx)\n", This, lpsd, dwFlags );
+ TRACE("(%p)->(%p,0x%08x)\n", This, lpsd, dwFlags );
return DP_SecureOpen( This, lpsd, dwFlags, NULL, NULL, FALSE );
}
-static HRESULT WINAPI DP_IF_Receive
+static HRESULT DP_IF_Receive
( IDirectPlay2Impl* This, LPDPID lpidFrom, LPDPID lpidTo,
DWORD dwFlags, LPVOID lpData, LPDWORD lpdwDataSize, BOOL bAnsi )
{
LPDPMSG lpMsg = NULL;
- FIXME( "(%p)->(%p,%p,0x%08lx,%p,%p,%u): stub\n",
+ FIXME( "(%p)->(%p,%p,0x%08x,%p,%p,%u): stub\n",
This, lpidFrom, lpidTo, dwFlags, lpData, lpdwDataSize, bAnsi );
if( This->dp2->connectionInitialized == NO_PROVIDER )
( dwFlags & DPRECEIVE_FROMPLAYER )
)
{
- FIXME( "Find matching message 0x%08lx\n", dwFlags );
+ FIXME( "Find matching message 0x%08x\n", dwFlags );
}
else
{
- ERR( "Hmmm..dwFlags 0x%08lx\n", dwFlags );
+ ERR( "Hmmm..dwFlags 0x%08x\n", dwFlags );
}
if( lpMsg == NULL )
}
/* Copy into the provided buffer */
- CopyMemory( lpData, lpMsg->msg, *lpdwDataSize );
+ if (lpData) CopyMemory( lpData, lpMsg->msg, *lpdwDataSize );
return DP_OK;
}
0, 0, NULL, NULL, FALSE );
}
-static HRESULT WINAPI DP_IF_SetGroupData
+static HRESULT DP_IF_SetGroupData
( IDirectPlay2Impl* This, DPID idGroup, LPVOID lpData,
DWORD dwDataSize, DWORD dwFlags, BOOL bAnsi )
{
lpGroupData lpGData;
- TRACE( "(%p)->(0x%08lx,%p,0x%08lx,0x%08lx,%u)\n",
+ TRACE( "(%p)->(0x%08x,%p,0x%08x,0x%08x,%u)\n",
This, idGroup, lpData, dwDataSize, dwFlags, bAnsi );
/* Parameter check */
return DP_IF_SetGroupData( This, idGroup, lpData, dwDataSize, dwFlags, FALSE );
}
-static HRESULT WINAPI DP_IF_SetGroupName
+static HRESULT DP_IF_SetGroupName
( IDirectPlay2Impl* This, DPID idGroup, LPDPNAME lpGroupName,
DWORD dwFlags, BOOL bAnsi )
{
lpGroupData lpGData;
- TRACE( "(%p)->(0x%08lx,%p,0x%08lx,%u)\n", This, idGroup,
+ TRACE( "(%p)->(0x%08x,%p,0x%08x,%u)\n", This, idGroup,
lpGroupName, dwFlags, bAnsi );
if( ( lpGData = DP_FindAnyGroup( This, idGroup ) ) == NULL )
return DP_IF_SetGroupName( This, idGroup, lpGroupName, dwFlags, FALSE );
}
-static HRESULT WINAPI DP_IF_SetPlayerData
+static HRESULT DP_IF_SetPlayerData
( IDirectPlay2Impl* This, DPID idPlayer, LPVOID lpData,
DWORD dwDataSize, DWORD dwFlags, BOOL bAnsi )
{
lpPlayerList lpPList;
- TRACE( "(%p)->(0x%08lx,%p,0x%08lx,0x%08lx,%u)\n",
+ TRACE( "(%p)->(0x%08x,%p,0x%08x,0x%08x,%u)\n",
This, idPlayer, lpData, dwDataSize, dwFlags, bAnsi );
+ if( This->dp2->connectionInitialized == NO_PROVIDER )
+ {
+ return DPERR_UNINITIALIZED;
+ }
+
/* Parameter check */
if( ( lpData == NULL ) &&
( dwDataSize != 0 )
dwFlags, FALSE );
}
-static HRESULT WINAPI DP_IF_SetPlayerName
+static HRESULT DP_IF_SetPlayerName
( IDirectPlay2Impl* This, DPID idPlayer, LPDPNAME lpPlayerName,
DWORD dwFlags, BOOL bAnsi )
{
lpPlayerList lpPList;
- TRACE( "(%p)->(0x%08lx,%p,0x%08lx,%u)\n",
+ TRACE( "(%p)->(0x%08x,%p,0x%08x,%u)\n",
This, idPlayer, lpPlayerName, dwFlags, bAnsi );
+ if( This->dp2->connectionInitialized == NO_PROVIDER )
+ {
+ return DPERR_UNINITIALIZED;
+ }
+
if( ( lpPList = DP_FindPlayer( This, idPlayer ) ) == NULL )
{
return DPERR_INVALIDGROUP;
return DP_IF_SetPlayerName( This, idPlayer, lpPlayerName, dwFlags, FALSE );
}
-static HRESULT WINAPI DP_SetSessionDesc
+static HRESULT DP_SetSessionDesc
( IDirectPlay2Impl* This, LPCDPSESSIONDESC2 lpSessDesc,
DWORD dwFlags, BOOL bInitial, BOOL bAnsi )
{
DWORD dwRequiredSize;
LPDPSESSIONDESC2 lpTempSessDesc;
- TRACE( "(%p)->(%p,0x%08lx,%u,%u)\n",
+ TRACE( "(%p)->(%p,0x%08x,%u,%u)\n",
This, lpSessDesc, dwFlags, bInitial, bAnsi );
if( This->dp2->connectionInitialized == NO_PROVIDER )
HeapFree( GetProcessHeap(), 0, This->dp2->lpSessionDesc );
This->dp2->lpSessionDesc = lpTempSessDesc;
-
/* Set the new */
DP_CopySessionDesc( This->dp2->lpSessionDesc, lpSessDesc, bAnsi );
-
+ if( bInitial )
+ {
+ /*Initializing session GUID*/
+ CoCreateGuid( &(This->dp2->lpSessionDesc->guidInstance) );
+ }
/* If this is an external invocation of the interface, we should be
* letting everyone know that things have changed. Otherwise this is
* just an initialization and it doesn't need to be propagated.
}
/* FIXME: See about merging some of this stuff with dplayx_global.c stuff */
-DWORD DP_CalcSessionDescSize( LPCDPSESSIONDESC2 lpSessDesc, BOOL bAnsi )
+static DWORD DP_CalcSessionDescSize( LPCDPSESSIONDESC2 lpSessDesc, BOOL bAnsi )
{
DWORD dwSize = 0;
if( bAnsi )
{
- if( lpSessDesc->lpszSessionNameA )
+ if( lpSessDesc->u1.lpszSessionNameA )
{
- dwSize += lstrlenA( lpSessDesc->lpszSessionNameA ) + 1;
+ dwSize += lstrlenA( lpSessDesc->u1.lpszSessionNameA ) + 1;
}
- if( lpSessDesc->lpszPasswordA )
+ if( lpSessDesc->u2.lpszPasswordA )
{
- dwSize += lstrlenA( lpSessDesc->lpszPasswordA ) + 1;
+ dwSize += lstrlenA( lpSessDesc->u2.lpszPasswordA ) + 1;
}
}
else /* UNICODE */
{
- if( lpSessDesc->lpszSessionName )
+ if( lpSessDesc->u1.lpszSessionName )
{
dwSize += sizeof( WCHAR ) *
- ( lstrlenW( lpSessDesc->lpszSessionName ) + 1 );
+ ( lstrlenW( lpSessDesc->u1.lpszSessionName ) + 1 );
}
- if( lpSessDesc->lpszPassword )
+ if( lpSessDesc->u2.lpszPassword )
{
dwSize += sizeof( WCHAR ) *
- ( lstrlenW( lpSessDesc->lpszPassword ) + 1 );
+ ( lstrlenW( lpSessDesc->u2.lpszPassword ) + 1 );
}
}
return dwSize;
}
-/* Assumes that contugous buffers are already allocated. */
+/* Assumes that contiguous buffers are already allocated. */
static void DP_CopySessionDesc( LPDPSESSIONDESC2 lpSessionDest,
LPCDPSESSIONDESC2 lpSessionSrc, BOOL bAnsi )
{
if( bAnsi )
{
- if( lpSessionSrc->lpszSessionNameA )
+ if( lpSessionSrc->u1.lpszSessionNameA )
{
lstrcpyA( (LPSTR)lpStartOfFreeSpace,
- lpSessionDest->lpszSessionNameA );
- lpSessionDest->lpszSessionNameA = (LPSTR)lpStartOfFreeSpace;
+ lpSessionDest->u1.lpszSessionNameA );
+ lpSessionDest->u1.lpszSessionNameA = (LPSTR)lpStartOfFreeSpace;
lpStartOfFreeSpace +=
- lstrlenA( (LPSTR)lpSessionDest->lpszSessionNameA ) + 1;
+ lstrlenA( lpSessionDest->u1.lpszSessionNameA ) + 1;
}
- if( lpSessionSrc->lpszPasswordA )
+ if( lpSessionSrc->u2.lpszPasswordA )
{
lstrcpyA( (LPSTR)lpStartOfFreeSpace,
- lpSessionDest->lpszPasswordA );
- lpSessionDest->lpszPasswordA = (LPSTR)lpStartOfFreeSpace;
- lpStartOfFreeSpace +=
- lstrlenA( (LPSTR)lpSessionDest->lpszPasswordA ) + 1;
+ lpSessionDest->u2.lpszPasswordA );
+ lpSessionDest->u2.lpszPasswordA = (LPSTR)lpStartOfFreeSpace;
}
}
else /* UNICODE */
{
- if( lpSessionSrc->lpszSessionName )
+ if( lpSessionSrc->u1.lpszSessionName )
{
lstrcpyW( (LPWSTR)lpStartOfFreeSpace,
- lpSessionDest->lpszSessionName );
- lpSessionDest->lpszSessionName = (LPWSTR)lpStartOfFreeSpace;
+ lpSessionDest->u1.lpszSessionName );
+ lpSessionDest->u1.lpszSessionName = (LPWSTR)lpStartOfFreeSpace;
lpStartOfFreeSpace += sizeof(WCHAR) *
- ( lstrlenW( (LPWSTR)lpSessionDest->lpszSessionName ) + 1 );
+ ( lstrlenW( lpSessionDest->u1.lpszSessionName ) + 1 );
}
- if( lpSessionSrc->lpszPassword )
+ if( lpSessionSrc->u2.lpszPassword )
{
lstrcpyW( (LPWSTR)lpStartOfFreeSpace,
- lpSessionDest->lpszPassword );
- lpSessionDest->lpszPassword = (LPWSTR)lpStartOfFreeSpace;
- lpStartOfFreeSpace += sizeof(WCHAR) *
- ( lstrlenW( (LPWSTR)lpSessionDest->lpszPassword ) + 1 );
+ lpSessionDest->u2.lpszPassword );
+ lpSessionDest->u2.lpszPassword = (LPWSTR)lpStartOfFreeSpace;
}
}
}
-static HRESULT WINAPI DP_IF_AddGroupToGroup
+static HRESULT DP_IF_AddGroupToGroup
( IDirectPlay3Impl* This, DPID idParentGroup, DPID idGroup )
{
- lpGroupData lpGParentData;
lpGroupData lpGData;
lpGroupList lpNewGList;
- TRACE( "(%p)->(0x%08lx,0x%08lx)\n", This, idParentGroup, idGroup );
+ TRACE( "(%p)->(0x%08x,0x%08x)\n", This, idParentGroup, idGroup );
- if( ( lpGParentData = DP_FindAnyGroup( (IDirectPlay2AImpl*)This, idParentGroup ) ) == NULL )
+ if( This->dp2->connectionInitialized == NO_PROVIDER )
+ {
+ return DPERR_UNINITIALIZED;
+ }
+
+ if( DP_FindAnyGroup( (IDirectPlay2AImpl*)This, idParentGroup ) == NULL )
{
return DPERR_INVALIDGROUP;
}
return DP_IF_AddGroupToGroup( This, idParentGroup, idGroup );
}
-static HRESULT WINAPI DP_IF_CreateGroupInGroup
+static HRESULT DP_IF_CreateGroupInGroup
( IDirectPlay3Impl* This, LPVOID lpMsgHdr, DPID idParentGroup,
LPDPID lpidGroup, LPDPNAME lpGroupName, LPVOID lpData,
DWORD dwDataSize, DWORD dwFlags, BOOL bAnsi )
lpGroupList lpGList;
lpGroupData lpGData;
- TRACE( "(%p)->(0x%08lx,%p,%p,%p,0x%08lx,0x%08lx,%u)\n",
+ TRACE( "(%p)->(0x%08x,%p,%p,%p,0x%08x,0x%08x,%u)\n",
This, idParentGroup, lpidGroup, lpGroupName, lpData,
dwDataSize, dwFlags, bAnsi );
+ if( This->dp2->connectionInitialized == NO_PROVIDER )
+ {
+ return DPERR_UNINITIALIZED;
+ }
+
/* Verify that the specified parent is valid */
if( ( lpGParentData = DP_FindAnyGroup( (IDirectPlay2AImpl*)This,
idParentGroup ) ) == NULL
dwFlags, FALSE );
}
-static HRESULT WINAPI DP_IF_DeleteGroupFromGroup
+static HRESULT DP_IF_DeleteGroupFromGroup
( IDirectPlay3Impl* This, DPID idParentGroup, DPID idGroup )
{
lpGroupList lpGList;
lpGroupData lpGParentData;
- TRACE("(%p)->(0x%08lx,0x%08lx)\n", This, idParentGroup, idGroup );
+ TRACE("(%p)->(0x%08x,0x%08x)\n", This, idParentGroup, idGroup );
/* Is the parent group valid? */
if( ( lpGParentData = DP_FindAnyGroup( (IDirectPlay2AImpl*)This, idParentGroup ) ) == NULL )
return DP_IF_DeleteGroupFromGroup( This, idParentGroup, idGroup );
}
-static
-BOOL WINAPI DP_BuildSPCompoundAddr( LPGUID lpcSpGuid, LPVOID* lplpAddrBuf,
+static BOOL DP_BuildSPCompoundAddr( LPGUID lpcSpGuid, LPVOID* lplpAddrBuf,
LPDWORD lpdwBufSize )
{
DPCOMPOUNDADDRESSELEMENT dpCompoundAddress;
HRESULT hr;
dpCompoundAddress.dwDataSize = sizeof( GUID );
- memcpy( &dpCompoundAddress.guidDataType, &DPAID_ServiceProvider,
- sizeof( GUID ) ) ;
+ dpCompoundAddress.guidDataType = DPAID_ServiceProvider;
dpCompoundAddress.lpData = lpcSpGuid;
*lplpAddrBuf = NULL;
( LPDIRECTPLAY3A iface, LPCGUID lpguidApplication, LPDPENUMCONNECTIONSCALLBACK lpEnumCallback, LPVOID lpContext, DWORD dwFlags )
{
IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface;
- TRACE("(%p)->(%p,%p,%p,0x%08lx)\n", This, lpguidApplication, lpEnumCallback, lpContext, dwFlags );
+ TRACE("(%p)->(%p,%p,%p,0x%08x)\n", This, lpguidApplication, lpEnumCallback, lpContext, dwFlags );
/* A default dwFlags (0) is backwards compatible -- DPCONNECTION_DIRECTPLAY */
if( dwFlags == 0 )
return DPERR_INVALIDFLAGS;
}
- if( !lpEnumCallback || !*lpEnumCallback )
+ if( !lpEnumCallback )
{
return DPERR_INVALIDPARAMS;
}
&sizeOfReturnBuffer ) != ERROR_SUCCESS )
{
ERR(": missing GUID registry data members\n" );
+ RegCloseKey(hkServiceProvider);
continue;
}
+ RegCloseKey(hkServiceProvider);
/* FIXME: Check return types to ensure we're interpreting data right */
MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) );
/* Fill in the DPNAME struct for the service provider */
dpName.dwSize = sizeof( dpName );
dpName.dwFlags = 0;
- dpName.lpszShortNameA = subKeyName;
- dpName.lpszLongNameA = NULL;
+ dpName.u1.lpszShortNameA = subKeyName;
+ dpName.u2.lpszLongNameA = NULL;
/* Create the compound address for the service provider.
* NOTE: This is a gruesome architectural scar right now. DP
/* The enumeration will return FALSE if we are not to continue */
if( !lpEnumCallback( &serviceProviderGUID, lpAddressBuffer, dwAddressBufferSize,
- &dpName, DPCONNECTION_DIRECTPLAY, lpContext ) )
+ &dpName, dwFlags, lpContext ) )
{
return DP_OK;
}
&sizeOfReturnBuffer ) != ERROR_SUCCESS )
{
ERR(": missing GUID registry data members\n" );
+ RegCloseKey(hkServiceProvider);
continue;
}
+ RegCloseKey(hkServiceProvider);
/* FIXME: Check return types to ensure we're interpreting data right */
MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) );
/* Fill in the DPNAME struct for the service provider */
dpName.dwSize = sizeof( dpName );
dpName.dwFlags = 0;
- dpName.lpszShortNameA = subKeyName;
- dpName.lpszLongNameA = NULL;
+ dpName.u1.lpszShortNameA = subKeyName;
+ dpName.u2.lpszLongNameA = NULL;
/* Create the compound address for the service provider.
NOTE: This is a gruesome architectural scar right now. DP uses DPL and DPL uses DP
&dwAddressBufferSize, TRUE ) ) != DP_OK )
{
ERR( "can't create address: %s\n", DPLAYX_HresultToString( hr ) );
+ HeapFree( GetProcessHeap(), 0, lpAddressBuffer );
return hr;
}
/* The enumeration will return FALSE if we are not to continue */
if( !lpEnumCallback( &serviceProviderGUID, lpAddressBuffer, dwAddressBufferSize,
- &dpName, DPCONNECTION_DIRECTPLAYLOBBY, lpContext ) )
+ &dpName, dwFlags, lpContext ) )
{
+ HeapFree( GetProcessHeap(), 0, lpAddressBuffer );
return DP_OK;
}
+ HeapFree( GetProcessHeap(), 0, lpAddressBuffer );
}
}
( LPDIRECTPLAY3 iface, LPCGUID lpguidApplication, LPDPENUMCONNECTIONSCALLBACK lpEnumCallback, LPVOID lpContext, DWORD dwFlags )
{
IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface;
- FIXME("(%p)->(%p,%p,%p,0x%08lx): stub\n", This, lpguidApplication, lpEnumCallback, lpContext, dwFlags );
+ FIXME("(%p)->(%p,%p,%p,0x%08x): stub\n", This, lpguidApplication, lpEnumCallback, lpContext, dwFlags );
return DP_OK;
}
-static HRESULT WINAPI DP_IF_EnumGroupsInGroup
+static HRESULT DP_IF_EnumGroupsInGroup
( IDirectPlay3AImpl* This, DPID idGroup, LPGUID lpguidInstance,
LPDPENUMPLAYERSCALLBACK2 lpEnumPlayersCallback2,
LPVOID lpContext, DWORD dwFlags, BOOL bAnsi )
lpGroupList lpGList;
lpGroupData lpGData;
- FIXME( "(%p)->(0x%08lx,%p,%p,%p,0x%08lx,%u): semi stub\n",
+ FIXME( "(%p)->(0x%08x,%p,%p,%p,0x%08x,%u): semi stub\n",
This, idGroup, lpguidInstance, lpEnumPlayersCallback2,
lpContext, dwFlags, bAnsi );
+ if( This->dp2->connectionInitialized == NO_PROVIDER )
+ {
+ return DPERR_UNINITIALIZED;
+ }
+
if( ( lpGData = DP_FindAnyGroup( (IDirectPlay2AImpl*)This, idGroup ) ) == NULL )
{
return DPERR_INVALIDGROUP;
( LPDIRECTPLAY3A iface, DWORD dwFlags, DPID idGroup, LPVOID lpData, LPDWORD lpdwDataSize )
{
IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface;
- FIXME("(%p)->(0x%08lx,0x%08lx,%p,%p): stub\n", This, dwFlags, idGroup, lpData, lpdwDataSize );
+ FIXME("(%p)->(0x%08x,0x%08x,%p,%p): stub\n", This, dwFlags, idGroup, lpData, lpdwDataSize );
return DP_OK;
}
( LPDIRECTPLAY3 iface, DWORD dwFlags, DPID idGroup, LPVOID lpData, LPDWORD lpdwDataSize )
{
IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface;
- FIXME("(%p)->(0x%08lx,0x%08lx,%p,%p): stub\n", This, dwFlags, idGroup, lpData, lpdwDataSize );
+ FIXME("(%p)->(0x%08x,0x%08x,%p,%p): stub\n", This, dwFlags, idGroup, lpData, lpdwDataSize );
return DP_OK;
}
( IsEqualGUID( guidDataType, &DPAID_LobbyProvider ) )
)
{
- TRACE( "Found SP/LP (%s) %s (data size = 0x%08lx)\n",
+ TRACE( "Found SP/LP (%s) %s (data size = 0x%08x)\n",
debugstr_guid( guidDataType ), debugstr_guid( lpData ), dwDataSize );
if( dwDataSize != sizeof( GUID ) )
{
- ERR( "Invalid sp/lp guid size 0x%08lx\n", dwDataSize );
+ ERR( "Invalid sp/lp guid size 0x%08x\n", dwDataSize );
}
memcpy( lpContext, lpData, dwDataSize );
NULL, NULL, (LPBYTE)returnBuffer,
&sizeOfReturnBuffer ) ) != ERROR_SUCCESS )
{
- ERR(": missing PATH registry data members: 0x%08lx\n", dwTemp );
+ ERR(": missing PATH registry data members: 0x%08x\n", dwTemp );
continue;
}
return hr;
}
-static HRESULT WINAPI DP_IF_InitializeConnection
+static HRESULT DP_IF_InitializeConnection
( IDirectPlay3Impl* This, LPVOID lpConnection, DWORD dwFlags, BOOL bAnsi )
{
HMODULE hServiceProvider;
const DWORD dwAddrSize = 80; /* FIXME: Need to calculate it correctly */
BOOL bIsDpSp; /* TRUE if Direct Play SP, FALSE if Direct Play Lobby SP */
- TRACE("(%p)->(%p,0x%08lx,%u)\n", This, lpConnection, dwFlags, bAnsi );
+ TRACE("(%p)->(%p,0x%08x,%u)\n", This, lpConnection, dwFlags, bAnsi );
+
+ if ( lpConnection == NULL )
+ {
+ return DPERR_INVALIDPARAMS;
+ }
if( dwFlags != 0 )
{
return DPERR_INVALIDFLAGS;
}
+ if( This->dp2->connectionInitialized != NO_PROVIDER )
+ {
+ return DPERR_ALREADYINITIALIZED;
+ }
+
/* Find out what the requested SP is and how large this buffer is */
hr = DPL_EnumAddress( DP_GetSpLpGuidFromCompoundAddress, lpConnection,
dwAddrSize, &guidSP );
if( hServiceProvider == 0 )
{
- ERR( "Unable to load service provider\n" );
+ ERR( "Unable to load service provider %s\n", debugstr_guid(&guidSP) );
return DPERR_UNAVAILABLE;
}
( LPDIRECTPLAY3A iface, DPID idFrom, DPID idTo, DWORD dwFlags, LPDPCHAT lpChatMessage )
{
IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface;
- FIXME("(%p)->(0x%08lx,0x%08lx,0x%08lx,%p): stub\n", This, idFrom, idTo, dwFlags, lpChatMessage );
+ FIXME("(%p)->(0x%08x,0x%08x,0x%08x,%p): stub\n", This, idFrom, idTo, dwFlags, lpChatMessage );
return DP_OK;
}
( LPDIRECTPLAY3 iface, DPID idFrom, DPID idTo, DWORD dwFlags, LPDPCHAT lpChatMessage )
{
IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface;
- FIXME("(%p)->(0x%08lx,0x%08lx,0x%08lx,%p): stub\n", This, idFrom, idTo, dwFlags, lpChatMessage );
+ FIXME("(%p)->(0x%08x,0x%08x,0x%08x,%p): stub\n", This, idFrom, idTo, dwFlags, lpChatMessage );
return DP_OK;
}
( LPDIRECTPLAY3A iface, DWORD dwFlags, DPID idGroup, LPDPLCONNECTION lpConnection )
{
IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface;
- FIXME("(%p)->(0x%08lx,0x%08lx,%p): stub\n", This, dwFlags, idGroup, lpConnection );
+ FIXME("(%p)->(0x%08x,0x%08x,%p): stub\n", This, dwFlags, idGroup, lpConnection );
return DP_OK;
}
( LPDIRECTPLAY3 iface, DWORD dwFlags, DPID idGroup, LPDPLCONNECTION lpConnection )
{
IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface;
- FIXME("(%p)->(0x%08lx,0x%08lx,%p): stub\n", This, dwFlags, idGroup, lpConnection );
+ FIXME("(%p)->(0x%08x,0x%08x,%p): stub\n", This, dwFlags, idGroup, lpConnection );
return DP_OK;
}
( LPDIRECTPLAY3A iface, DWORD dwFlags, DPID idGroup )
{
IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface;
- FIXME("(%p)->(0x%08lx,0x%08lx): stub\n", This, dwFlags, idGroup );
+ FIXME("(%p)->(0x%08x,0x%08x): stub\n", This, dwFlags, idGroup );
return DP_OK;
}
( LPDIRECTPLAY3 iface, DWORD dwFlags, DPID idGroup )
{
IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface;
- FIXME("(%p)->(0x%08lx,0x%08lx): stub\n", This, dwFlags, idGroup );
+ FIXME("(%p)->(0x%08x,0x%08x): stub\n", This, dwFlags, idGroup );
return DP_OK;
}
( LPDIRECTPLAY3A iface, DPID idGroup, LPDWORD lpdwFlags )
{
IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface;
- FIXME("(%p)->(0x%08lx,%p): stub\n", This, idGroup, lpdwFlags );
+ FIXME("(%p)->(0x%08x,%p): stub\n", This, idGroup, lpdwFlags );
return DP_OK;
}
( LPDIRECTPLAY3 iface, DPID idGroup, LPDWORD lpdwFlags )
{
IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface;
- FIXME("(%p)->(0x%08lx,%p): stub\n", This, idGroup, lpdwFlags );
+ FIXME("(%p)->(0x%08x,%p): stub\n", This, idGroup, lpdwFlags );
return DP_OK;
}
-static HRESULT WINAPI DP_IF_GetGroupParent
+static HRESULT DP_IF_GetGroupParent
( IDirectPlay3AImpl* This, DPID idGroup, LPDPID lpidGroup,
BOOL bAnsi )
{
lpGroupData lpGData;
- TRACE("(%p)->(0x%08lx,%p,%u)\n", This, idGroup, lpidGroup, bAnsi );
+ TRACE("(%p)->(0x%08x,%p,%u)\n", This, idGroup, lpidGroup, bAnsi );
if( ( lpGData = DP_FindAnyGroup( (IDirectPlay2AImpl*)This, idGroup ) ) == NULL )
{
( LPDIRECTPLAY3A iface, DPID idPlayer, DWORD dwFlags, LPVOID lpData, LPDWORD lpdwDataSize )
{
IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface;
- FIXME("(%p)->(0x%08lx,0x%08lx,%p,%p): stub\n", This, idPlayer, dwFlags, lpData, lpdwDataSize );
+ FIXME("(%p)->(0x%08x,0x%08x,%p,%p): stub\n", This, idPlayer, dwFlags, lpData, lpdwDataSize );
return DP_OK;
}
( LPDIRECTPLAY3 iface, DPID idPlayer, DWORD dwFlags, LPVOID lpData, LPDWORD lpdwDataSize )
{
IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface;
- FIXME("(%p)->(0x%08lx,0x%08lx,%p,%p): stub\n", This, idPlayer, dwFlags, lpData, lpdwDataSize );
+ FIXME("(%p)->(0x%08x,0x%08x,%p,%p): stub\n", This, idPlayer, dwFlags, lpData, lpdwDataSize );
return DP_OK;
}
( LPDIRECTPLAY3A iface, DPID idPlayer, LPDWORD lpdwFlags )
{
IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface;
- FIXME("(%p)->(0x%08lx,%p): stub\n", This, idPlayer, lpdwFlags );
+ FIXME("(%p)->(0x%08x,%p): stub\n", This, idPlayer, lpdwFlags );
return DP_OK;
}
( LPDIRECTPLAY3 iface, DPID idPlayer, LPDWORD lpdwFlags )
{
IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface;
- FIXME("(%p)->(0x%08lx,%p): stub\n", This, idPlayer, lpdwFlags );
+ FIXME("(%p)->(0x%08x,%p): stub\n", This, idPlayer, lpdwFlags );
return DP_OK;
}
( LPDIRECTPLAY4A iface, DPID idGroup, LPDPID lpidGroupOwner )
{
IDirectPlay4Impl *This = (IDirectPlay4Impl *)iface;
- FIXME("(%p)->(0x%08lx,%p): stub\n", This, idGroup, lpidGroupOwner );
+ FIXME("(%p)->(0x%08x,%p): stub\n", This, idGroup, lpidGroupOwner );
return DP_OK;
}
( LPDIRECTPLAY4 iface, DPID idGroup, LPDPID lpidGroupOwner )
{
IDirectPlay4Impl *This = (IDirectPlay4Impl *)iface;
- FIXME("(%p)->(0x%08lx,%p): stub\n", This, idGroup, lpidGroupOwner );
+ FIXME("(%p)->(0x%08x,%p): stub\n", This, idGroup, lpidGroupOwner );
return DP_OK;
}
( LPDIRECTPLAY4A iface, DPID idGroup , DPID idGroupOwner )
{
IDirectPlay4Impl *This = (IDirectPlay4Impl *)iface;
- FIXME("(%p)->(0x%08lx,0x%08lx): stub\n", This, idGroup, idGroupOwner );
+ FIXME("(%p)->(0x%08x,0x%08x): stub\n", This, idGroup, idGroupOwner );
return DP_OK;
}
( LPDIRECTPLAY4 iface, DPID idGroup , DPID idGroupOwner )
{
IDirectPlay4Impl *This = (IDirectPlay4Impl *)iface;
- FIXME("(%p)->(0x%08lx,0x%08lx): stub\n", This, idGroup, idGroupOwner );
+ FIXME("(%p)->(0x%08x,0x%08x): stub\n", This, idGroup, idGroupOwner );
return DP_OK;
}
-static HRESULT WINAPI DP_SendEx
+static HRESULT DP_SendEx
( IDirectPlay2Impl* This, DPID idFrom, DPID idTo, DWORD dwFlags,
LPVOID lpData, DWORD dwDataSize, DWORD dwPriority, DWORD dwTimeout,
LPVOID lpContext, LPDWORD lpdwMsgID, BOOL bAnsi )
{
- lpPlayerList lpPList;
- lpGroupData lpGData;
BOOL bValidDestination = FALSE;
- FIXME( "(%p)->(0x%08lx,0x%08lx,0x%08lx,%p,0x%08lx,0x%08lx,0x%08lx,%p,%p,%u)"
+ FIXME( "(%p)->(0x%08x,0x%08x,0x%08x,%p,0x%08x,0x%08x,0x%08x,%p,%p,%u)"
": stub\n",
This, idFrom, idTo, dwFlags, lpData, dwDataSize, dwPriority,
dwTimeout, lpContext, lpdwMsgID, bAnsi );
+ if( This->dp2->connectionInitialized == NO_PROVIDER )
+ {
+ return DPERR_UNINITIALIZED;
+ }
+
/* FIXME: Add parameter checking */
- /* FIXME: First call to this needs to aquire a message id which will be
+ /* FIXME: First call to this needs to acquire a message id which will be
* used for multiple sends
*/
*/
if( idFrom != DPID_UNKNOWN )
{
- if( ( lpPList = DP_FindPlayer( This, idFrom ) ) == NULL )
+ if( DP_FindPlayer( This, idFrom ) == NULL )
{
- WARN( "INFO: Invalid from player 0x%08lx\n", idFrom );
+ WARN( "INFO: Invalid from player 0x%08x\n", idFrom );
return DPERR_INVALIDPLAYER;
}
}
( DP_FindPlayer( This, idTo ) != NULL )
)
{
- bValidDestination = TRUE;
-
/* Have the service provider send this message */
/* FIXME: Could optimize for local interface sends */
return DP_SP_SendEx( This, dwFlags, lpData, dwDataSize, dwPriority,
}
if( ( !bValidDestination ) &&
- ( ( lpGData = DP_FindAnyGroup( This, idTo ) ) != NULL )
+ ( DP_FindAnyGroup( This, idTo ) != NULL )
)
{
bValidDestination = TRUE;
dwPriority, dwTimeout, lpContext, lpdwMsgID, FALSE );
}
-static HRESULT WINAPI DP_SP_SendEx
+static HRESULT DP_SP_SendEx
( IDirectPlay2Impl* This, DWORD dwFlags,
LPVOID lpData, DWORD dwDataSize, DWORD dwPriority, DWORD dwTimeout,
LPVOID lpContext, LPDWORD lpdwMsgID )
return DP_OK;
}
-static HRESULT WINAPI DP_IF_GetMessageQueue
+static HRESULT DP_IF_GetMessageQueue
( IDirectPlay4Impl* This, DPID idFrom, DPID idTo, DWORD dwFlags,
LPDWORD lpdwNumMsgs, LPDWORD lpdwNumBytes, BOOL bAnsi )
{
HRESULT hr = DP_OK;
- FIXME( "(%p)->(0x%08lx,0x%08lx,0x%08lx,%p,%p,%u): semi stub\n",
+ FIXME( "(%p)->(0x%08x,0x%08x,0x%08x,%p,%p,%u): semi stub\n",
This, idFrom, idTo, dwFlags, lpdwNumMsgs, lpdwNumBytes, bAnsi );
/* FIXME: Do we need to do idFrom and idTo sanity checking here? */
lpdwNumBytes, FALSE );
}
-static HRESULT WINAPI DP_IF_CancelMessage
+static HRESULT DP_IF_CancelMessage
( IDirectPlay4Impl* This, DWORD dwMsgID, DWORD dwFlags,
DWORD dwMinPriority, DWORD dwMaxPriority, BOOL bAnsi )
{
HRESULT hr = DP_OK;
- FIXME( "(%p)->(0x%08lx,0x%08lx,%u): semi stub\n",
+ FIXME( "(%p)->(0x%08x,0x%08x,%u): semi stub\n",
This, dwMsgID, dwFlags, bAnsi );
if( This->dp2->spData.lpCB->Cancel )
};
#undef XCAST
-extern
HRESULT DP_GetSPPlayerData( IDirectPlay2Impl* lpDP,
DPID idPlayer,
LPVOID* lplpData )
return DP_OK;
}
-extern
HRESULT DP_SetSPPlayerData( IDirectPlay2Impl* lpDP,
DPID idPlayer,
LPVOID lpData )
'S', 'e', 'r', 'v', 'i', 'c', 'e', ' ', 'P', 'r', 'o', 'v', 'i', 'd', 'e', 'r', 's', 0 };
static const WCHAR guidKey[] = { 'G', 'u', 'i', 'd', 0 };
static const WCHAR descW[] = { 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'i', 'o', 'n', 'W', 0 };
-
+
DWORD dwIndex;
FILETIME filetime;
DWORD max_sizeOfDescriptionA = 0;
WCHAR *descriptionW = NULL;
DWORD max_sizeOfDescriptionW = 0;
-
+
if (!lpEnumCallbackA && !lpEnumCallbackW)
{
return DPERR_INVALIDPARAMS;
}
-
+
/* Need to loop over the service providers in the registry */
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, searchSubKey,
0, KEY_READ, &hkResult) != ERROR_SUCCESS)
ERR(": no service provider key in the registry - check your Wine installation !!!\n");
return DPERR_GENERIC;
}
-
+
/* Traverse all the service providers we have available */
dwIndex = 0;
while (1)
WCHAR guidKeyContent[(2 * 16) + 1 + 6 /* This corresponds to '{....-..-..-..-......}' */ ];
DWORD sizeOfGuidKeyContent = sizeof(guidKeyContent);
LONG ret_value;
-
+
ret_value = RegEnumKeyExW(hkResult, dwIndex, subKeyName, &sizeOfSubKeyName,
NULL, NULL, NULL, &filetime);
if (ret_value == ERROR_NO_MORE_ITEMS)
return DPERR_EXCEPTION;
}
TRACE(" this time through sub-key %s.\n", debugstr_w(subKeyName));
-
+
/* Open the key for this service provider */
if (RegOpenKeyExW(hkResult, subKeyName, 0, KEY_READ, &hkServiceProvider) != ERROR_SUCCESS)
{
ERR(": could not open registry key for service provider %s.\n", debugstr_w(subKeyName));
continue;
}
-
+
/* Get the GUID from the registry */
if (RegQueryValueExW(hkServiceProvider, guidKey,
NULL, NULL, (LPBYTE) guidKeyContent, &sizeOfGuidKeyContent) != ERROR_SUCCESS)
continue;
}
CLSIDFromString(guidKeyContent, &serviceProviderGUID );
-
+
/* The enumeration will return FALSE if we are not to continue.
*
* Note: on my windows box, major / minor version is 6 / 0 for all service providers
- * and have no relations to any of the two dwReserved1 and dwReserved2 keys.
+ * and have no relation to any of the two dwReserved1 and dwReserved2 keys.
* I think that it simply means that they are in-line with DirectX 6.0
*/
if (lpEnumCallbackA)
{
DWORD sizeOfDescription = 0;
-
- /* Note that this the the A case of this function, so use the A variant to get the description string */
+
+ /* Note that this is the A case of this function, so use the A variant to get the description string */
if (RegQueryValueExA(hkServiceProvider, "DescriptionA",
NULL, NULL, NULL, &sizeOfDescription) != ERROR_SUCCESS)
{
{
HeapFree(GetProcessHeap(), 0, descriptionA);
max_sizeOfDescriptionA = sizeOfDescription;
- descriptionA = HeapAlloc(GetProcessHeap(), 0, max_sizeOfDescriptionA);
}
descriptionA = HeapAlloc(GetProcessHeap(), 0, sizeOfDescription);
RegQueryValueExA(hkServiceProvider, "DescriptionA",
NULL, NULL, (LPBYTE) descriptionA, &sizeOfDescription);
-
+
if (!lpEnumCallbackA(&serviceProviderGUID, descriptionA, 6, 0, lpContext))
goto end;
}
else
{
DWORD sizeOfDescription = 0;
-
+
if (RegQueryValueExW(hkServiceProvider, descW,
NULL, NULL, NULL, &sizeOfDescription) != ERROR_SUCCESS)
{
{
HeapFree(GetProcessHeap(), 0, descriptionW);
max_sizeOfDescriptionW = sizeOfDescription;
- descriptionW = HeapAlloc(GetProcessHeap(), 0, max_sizeOfDescriptionW);
}
descriptionW = HeapAlloc(GetProcessHeap(), 0, sizeOfDescription);
RegQueryValueExW(hkServiceProvider, descW,
if (!lpEnumCallbackW(&serviceProviderGUID, descriptionW, 6, 0, lpContext))
goto end;
}
-
+
dwIndex++;
}
end:
HeapFree(GetProcessHeap(), 0, descriptionA);
HeapFree(GetProcessHeap(), 0, descriptionW);
-
+
return DP_OK;
}
HRESULT WINAPI DirectPlayEnumerateA(LPDPENUMDPCALLBACKA lpEnumCallback, LPVOID lpContext )
{
TRACE("(%p,%p)\n", lpEnumCallback, lpContext);
-
+
return DirectPlayEnumerateAW(lpEnumCallback, NULL, lpContext);
}
HRESULT WINAPI DirectPlayEnumerateW(LPDPENUMDPCALLBACKW lpEnumCallback, LPVOID lpContext )
{
TRACE("(%p,%p)\n", lpEnumCallback, lpContext);
-
+
return DirectPlayEnumerateAW(NULL, lpEnumCallback, lpContext);
}
*
*/
HRESULT WINAPI DirectPlayCreate
-( LPGUID lpGUID, LPDIRECTPLAY2 *lplpDP, IUnknown *pUnk)
+( LPGUID lpGUID, LPDIRECTPLAY *lplpDP, IUnknown *pUnk )
{
HRESULT hr;
LPDIRECTPLAY3A lpDP3A;
return CLASS_E_NOAGGREGATION;
}
+ if( (lplpDP == NULL) || (lpGUID == NULL) )
+ {
+ return DPERR_INVALIDPARAMS;
+ }
+
+
/* Create an IDirectPlay object. We don't support that so we'll cheat and
give them an IDirectPlay2A object and hope that doesn't cause problems */
if( DP_CreateInterface( &IID_IDirectPlay2A, (LPVOID*)lplpDP ) != DP_OK )
*
* 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_DPLAY_GLOBAL_INCLUDED
#define __WINE_DPLAY_GLOBAL_INCLUDED
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+
//#include <stdarg.h>
//#include "windef.h"
extern HRESULT DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback,
LPCVOID lpAddress, DWORD dwAddressSize,
- LPVOID lpContext );
-
-extern DWORD DP_CalcSessionDescSize( LPCDPSESSIONDESC2 lpSessDesc, BOOL bAnsi );
+ LPVOID lpContext ) DECLSPEC_HIDDEN;
/*****************************************************************************
* Predeclare the interface implementation structures
typedef struct tagDP_MSG_REPLY_STRUCT_LIST
{
- DPQ_ENTRY(tagDP_MSG_REPLY_STRUCT_LIST) replysExpected;
+ DPQ_ENTRY(tagDP_MSG_REPLY_STRUCT_LIST) repliesExpected;
DP_MSG_REPLY_STRUCT replyExpected;
} DP_MSG_REPLY_STRUCT_LIST, *LPDP_MSG_REPLY_STRUCT_LIST;
/* For async EnumSessions requests */
HANDLE hEnumSessionThread;
HANDLE hKillEnumSessionThreadEvent;
+ DWORD dwEnumSessionLock;
LPVOID lpNameServerData; /* DPlay interface doesn't know contents */
enum SPSTATE connectionInitialized;
/* Expected messages queue */
- DPQ_HEAD( tagDP_MSG_REPLY_STRUCT_LIST ) replysExpected;
+ DPQ_HEAD( tagDP_MSG_REPLY_STRUCT_LIST ) repliesExpected;
} DirectPlay2Data;
typedef struct tagDirectPlay3Data
HRESULT DP_HandleMessage( IDirectPlay2Impl* This, LPCVOID lpMessageBody,
DWORD dwMessageBodySize, LPCVOID lpMessageHeader,
WORD wCommandId, WORD wVersion,
- LPVOID* lplpReply, LPDWORD lpdwMsgSize );
+ LPVOID* lplpReply, LPDWORD lpdwMsgSize ) DECLSPEC_HIDDEN;
/* DP SP external interfaces into DirectPlay */
-extern HRESULT DP_GetSPPlayerData( IDirectPlay2Impl* lpDP, DPID idPlayer, LPVOID* lplpData );
-extern HRESULT DP_SetSPPlayerData( IDirectPlay2Impl* lpDP, DPID idPlayer, LPVOID lpData );
+extern HRESULT DP_GetSPPlayerData( IDirectPlay2Impl* lpDP, DPID idPlayer, LPVOID* lplpData ) DECLSPEC_HIDDEN;
+extern HRESULT DP_SetSPPlayerData( IDirectPlay2Impl* lpDP, DPID idPlayer, LPVOID lpData ) DECLSPEC_HIDDEN;
/* DP external interfaces to call into DPSP interface */
-extern LPVOID DPSP_CreateSPPlayerData(void);
+extern LPVOID DPSP_CreateSPPlayerData(void) DECLSPEC_HIDDEN;
#endif /* __WINE_DPLAY_GLOBAL_INCLUDED */
*
* 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
//#include <string.h>
} DP_SPPLAYERDATA, *LPDP_SPPLAYERDATA;
/* Create the SP interface */
-extern
HRESULT DPSP_CreateInterface( REFIID riid, LPVOID* ppvObj, IDirectPlay2Impl* dp )
{
TRACE( " for %s\n", debugstr_guid( riid ) );
if( IsEqualGUID( &IID_IDirectPlaySP, riid ) )
{
- IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)*ppvObj;
+ IDirectPlaySPImpl *This = *ppvObj;
This->lpVtbl = &directPlaySPVT;
}
else
static BOOL DPSP_CreateIUnknown( LPVOID lpSP )
{
- IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)lpSP;
+ IDirectPlaySPImpl *This = lpSP;
This->unk = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->unk) ) );
}
InitializeCriticalSection( &This->unk->DPSP_lock );
+ This->unk->DPSP_lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDirectPlaySPImpl*->DirectPlaySPIUnknownData*->DPSP_lock");
return TRUE;
}
static BOOL DPSP_DestroyIUnknown( LPVOID lpSP )
{
- IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)lpSP;
+ IDirectPlaySPImpl *This = lpSP;
+ This->unk->DPSP_lock.DebugInfo->Spare[0] = 0;
DeleteCriticalSection( &This->unk->DPSP_lock );
HeapFree( GetProcessHeap(), 0, This->unk );
static BOOL DPSP_CreateDirectPlaySP( LPVOID lpSP, IDirectPlay2Impl* dp )
{
- IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)lpSP;
+ IDirectPlaySPImpl *This = lpSP;
This->sp = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->sp) ) );
static BOOL DPSP_DestroyDirectPlaySP( LPVOID lpSP )
{
- IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)lpSP;
+ IDirectPlaySPImpl *This = lpSP;
/* Normally we should be keeping a reference, but since only the dplay
* interface that created us can destroy us, we do not keep a reference
if( IsEqualGUID( &IID_IDirectPlaySP, riid ) )
{
- IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)*ppvObj;
+ IDirectPlaySPImpl *This = *ppvObj;
This->lpVtbl = &directPlaySPVT;
}
else
ulObjRefCount = InterlockedIncrement( &This->unk->ulObjRef );
ulInterfaceRefCount = InterlockedIncrement( &This->ulInterfaceRef );
- TRACE( "ref count incremented to %lu:%lu for %p\n",
+ TRACE( "ref count incremented to %u:%u for %p\n",
ulInterfaceRefCount, ulObjRefCount, This );
return ulObjRefCount;
ulObjRefCount = InterlockedDecrement( &This->unk->ulObjRef );
ulInterfaceRefCount = InterlockedDecrement( &This->ulInterfaceRef );
- TRACE( "ref count decremented to %lu:%lu for %p\n",
+ TRACE( "ref count decremented to %u:%u for %p\n",
ulInterfaceRefCount, ulObjRefCount, This );
/* Deallocate if this is the last reference to the object */
/* Should be able to call the comctl32 undocumented MRU routines.
I suspect that the interface works appropriately */
- FIXME( "(%p)->(%p,%p%p,0x%08lx,0x%08lx): stub\n",
+ FIXME( "(%p)->(%p,%p%p,0x%08x,0x%08x): stub\n",
This, lpSection, lpKey, lpData, dwDataSize, dwMaxEntries );
return DP_OK;
{
IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
- FIXME( "(%p)->(%s,%s,%p,0x%08lx,%p,%p): stub\n",
+ FIXME( "(%p)->(%s,%s,%p,0x%08x,%p,%p): stub\n",
This, debugstr_guid(guidSP), debugstr_guid(guidDataType),
lpData, dwDataSize, lpAddress, lpdwAddressSize );
{
IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
- TRACE( "(%p)->(%p,%p,0x%08lx,%p)\n",
+ TRACE( "(%p)->(%p,%p,0x%08x,%p)\n",
This, lpEnumAddressCallback, lpAddress, dwAddressSize, lpContext );
DPL_EnumAddress( lpEnumAddressCallback, lpAddress, dwAddressSize, lpContext );
{
IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
- FIXME( "(%p)->(0x%08lx,%p): stub\n",
+ FIXME( "(%p)->(0x%08x,%p): stub\n",
This, idPlayer, lpdwPlayerFlags );
return DP_OK;
LPDP_SPPLAYERDATA lpPlayerData;
IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
- TRACE( "(%p)->(0x%08lx,%p,%p,0x%08lx)\n",
+ TRACE( "(%p)->(0x%08x,%p,%p,0x%08x)\n",
This, idPlayer, lplpData, lpdwDataSize, dwFlags );
hr = DP_GetSPPlayerData( This->sp->dplay, idPlayer, (LPVOID*)&lpPlayerData );
LPVOID lpMessageHeader
)
{
- LPDPMSG_SENDENVELOPE lpMsg = (LPDPMSG_SENDENVELOPE)lpMessageBody;
+ LPDPMSG_SENDENVELOPE lpMsg = lpMessageBody;
HRESULT hr = DPERR_GENERIC;
WORD wCommandId;
WORD wVersion;
IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
- FIXME( "(%p)->(%p,0x%08lx,%p): mostly stub\n",
+ FIXME( "(%p)->(%p,0x%08x,%p): mostly stub\n",
This, lpMessageBody, dwMessageBodySize, lpMessageHeader );
wCommandId = lpMsg->wCommandId;
wVersion = lpMsg->wVersion;
- TRACE( "Incoming message has envelope of 0x%08lx, %u, %u\n",
+ TRACE( "Incoming message has envelope of 0x%08x, %u, %u\n",
lpMsg->dwMagic, wCommandId, wVersion );
if( lpMsg->dwMagic != DPMSGMAGIC_DPLAYMSG )
{
- ERR( "Unknown magic 0x%08lx!\n", lpMsg->dwMagic );
+ ERR( "Unknown magic 0x%08x!\n", lpMsg->dwMagic );
return DPERR_GENERIC;
}
#if 0
{
- const LPDWORD lpcHeader = (LPDWORD)lpMessageHeader;
+ const LPDWORD lpcHeader = lpMessageHeader;
TRACE( "lpMessageHeader = [0x%08lx] [0x%08lx] [0x%08lx] [0x%08lx] [0x%08lx]\n",
lpcHeader[0], lpcHeader[1], lpcHeader[2], lpcHeader[3], lpcHeader[4] );
#if 0
HRESULT hr = DP_OK;
HANDLE hReceiveEvent = 0;
- /* FIXME: Aquire some sort of interface lock */
+ /* FIXME: Acquire some sort of interface lock */
/* FIXME: Need some sort of context for this callback. Need to determine
* how this is actually done with the SP
*/
{
case DPSYS_CREATEPLAYERORGROUP:
{
- LPDPMSG_CREATEPLAYERORGROUP msg = (LPDPMSG_CREATEPLAYERORGROUP)lpMsg;
+ LPDPMSG_CREATEPLAYERORGROUP msg = lpMsg;
if( msg->dwPlayerType == DPPLAYERTYPE_PLAYER )
{
case DPSYS_DESTROYPLAYERORGROUP:
{
- LPDPMSG_DESTROYPLAYERORGROUP msg = (LPDPMSG_DESTROYPLAYERORGROUP)lpMsg;
+ LPDPMSG_DESTROYPLAYERORGROUP msg = lpMsg;
if( msg->dwPlayerType == DPPLAYERTYPE_PLAYER )
{
case DPSYS_ADDPLAYERTOGROUP:
{
- LPDPMSG_ADDPLAYERTOGROUP msg = (LPDPMSG_ADDPLAYERTOGROUP)lpMsg;
+ LPDPMSG_ADDPLAYERTOGROUP msg = lpMsg;
hr = DP_IF_AddPlayerToGroup( This, msg->dpIdGroup, msg->dpIdPlayer, ... );
break;
case DPSYS_DELETEPLAYERFROMGROUP:
{
- LPDPMSG_DELETEPLAYERFROMGROUP msg = (LPDPMSG_DELETEPLAYERFROMGROUP)lpMsg;
+ LPDPMSG_DELETEPLAYERFROMGROUP msg = lpMsg;
hr = DP_IF_DeletePlayerFromGroup( This, msg->dpIdGroup, msg->dpIdPlayer,
... );
case DPSYS_SESSIONLOST:
{
- LPDPMSG_SESSIONLOST msg = (LPDPMSG_SESSIONLOST)lpMsg;
+ LPDPMSG_SESSIONLOST msg = lpMsg;
FIXME( "DPSYS_SESSIONLOST not handled\n" );
case DPSYS_HOST:
{
- LPDPMSG_HOST msg = (LPDPMSG_HOST)lpMsg;
+ LPDPMSG_HOST msg = lpMsg;
FIXME( "DPSYS_HOST not handled\n" );
case DPSYS_SETPLAYERORGROUPDATA:
{
- LPDPMSG_SETPLAYERORGROUPDATA msg = (LPDPMSG_SETPLAYERORGROUPDATA)lpMsg;
+ LPDPMSG_SETPLAYERORGROUPDATA msg = lpMsg;
if( msg->dwPlayerType == DPPLAYERTYPE_PLAYER )
{
case DPSYS_SETPLAYERORGROUPNAME:
{
- LPDPMSG_SETPLAYERORGROUPNAME msg = (LPDPMSG_SETPLAYERORGROUPNAME)lpMsg;
+ LPDPMSG_SETPLAYERORGROUPNAME msg = lpMsg;
if( msg->dwPlayerType == DPPLAYERTYPE_PLAYER )
{
case DPSYS_SETSESSIONDESC;
{
- LPDPMSG_SETSESSIONDESC msg = (LPDPMSG_SETSESSIONDESC)lpMsg;
+ LPDPMSG_SETSESSIONDESC msg = lpMsg;
hr = DP_IF_SetSessionDesc( This, &msg->dpDesc );
case DPSYS_ADDGROUPTOGROUP:
{
- LPDPMSG_ADDGROUPTOGROUP msg = (LPDPMSG_ADDGROUPTOGROUP)lpMsg;
+ LPDPMSG_ADDGROUPTOGROUP msg = lpMsg;
hr = DP_IF_AddGroupToGroup( This, msg->dpIdParentGroup, msg->dpIdGroup,
... );
case DPSYS_DELETEGROUPFROMGROUP:
{
- LPDPMSG_DELETEGROUPFROMGROUP msg = (LPDPMSG_DELETEGROUPFROMGROUP)lpMsg;
+ LPDPMSG_DELETEGROUPFROMGROUP msg = lpMsg;
hr = DP_IF_DeleteGroupFromGroup( This, msg->dpIdParentGroup,
msg->dpIdGroup, ... );
case DPSYS_SECUREMESSAGE:
{
- LPDPMSG_SECUREMESSAGE msg = (LPDPMSG_SECUREMESSAGE)lpMsg;
+ LPDPMSG_SECUREMESSAGE msg = lpMsg;
FIXME( "DPSYS_SECUREMESSAGE not implemented\n" );
case DPSYS_STARTSESSION:
{
- LPDPMSG_STARTSESSION msg = (LPDPMSG_STARTSESSION)lpMsg;
+ LPDPMSG_STARTSESSION msg = lpMsg;
FIXME( "DPSYS_STARTSESSION not implemented\n" );
case DPSYS_CHAT:
{
- LPDPMSG_CHAT msg = (LPDPMSG_CHAT)lpMsg;
+ LPDPMSG_CHAT msg = lpMsg;
FIXME( "DPSYS_CHAT not implemeneted\n" );
case DPSYS_SETGROUPOWNER:
{
- LPDPMSG_SETGROUPOWNER msg = (LPDPMSG_SETGROUPOWNER)lpMsg;
+ LPDPMSG_SETGROUPOWNER msg = lpMsg;
FIXME( "DPSYS_SETGROUPOWNER not implemented\n" );
case DPSYS_SENDCOMPLETE:
{
- LPDPMSG_SENDCOMPLETE msg = (LPDPMSG_SENDCOMPLETE)lpMsg;
+ LPDPMSG_SENDCOMPLETE msg = lpMsg;
FIXME( "DPSYS_SENDCOMPLETE not implemented\n" );
IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
/* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */
- TRACE( "(%p)->(0x%08lx,%p,0x%08lx,0x%08lx)\n",
+ TRACE( "(%p)->(0x%08x,%p,0x%08x,0x%08x)\n",
This, idPlayer, lpData, dwDataSize, dwFlags );
hr = DP_GetSPPlayerData( This->sp->dplay, idPlayer, (LPVOID*)&lpPlayerEntry );
{
IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
- FIXME( "(%p)->(%p,0x%08lx,%p,%p): stub\n",
+ FIXME( "(%p)->(%p,0x%08x,%p,%p): stub\n",
This, lpElements, dwElementCount, lpAddress, lpdwAddressSize );
return DP_OK;
IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
/* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */
- TRACE( "(%p)->(%p,%p,0x%08lx)\n",
+ TRACE( "(%p)->(%p,%p,0x%08x)\n",
This, lplpData, lpdwDataSize, dwFlags );
#if 0
*/
if( dwFlags != DPSET_REMOTE )
{
- TRACE( "Undocumented dwFlags 0x%08lx used\n", dwFlags );
+ TRACE( "Undocumented dwFlags 0x%08x used\n", dwFlags );
}
#endif
IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
/* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */
- TRACE( "(%p)->(%p,0x%08lx,0x%08lx)\n",
+ TRACE( "(%p)->(%p,0x%08x,0x%08x)\n",
This, lpData, dwDataSize, dwFlags );
#if 0
*/
if( dwFlags != DPSET_REMOTE )
{
- TRACE( "Undocumented dwFlags 0x%08lx used\n", dwFlags );
+ TRACE( "Undocumented dwFlags 0x%08x used\n", dwFlags );
}
#endif
{
IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
- FIXME( "(%p)->(%p,0x%08lx): stub\n",
+ FIXME( "(%p)->(%p,0x%08x): stub\n",
This, unknownA, unknownB );
}
/* DP external interfaces to call into DPSP interface */
/* Allocate the structure */
-extern LPVOID DPSP_CreateSPPlayerData(void)
+LPVOID DPSP_CreateSPPlayerData(void)
{
TRACE( "Creating SPPlayer data struct\n" );
return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
/*
- * Version information for hhctrl.ocx
+ * COM Classes for dplayx
*
- * Copyright 2004 Hans Leidekker
- * Copyright 2004 Tom Wickline
+ * Copyright 2010 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#define WINE_FILEDESCRIPTION_STR "Wine htmlhelp OCX"
-#define WINE_FILENAME_STR "hhctrl.ocx"
-#define WINE_FILEVERSION 5,2,3790,2744
-#define WINE_FILEVERSION_STR "5.2.3790.2744"
-#define WINE_PRODUCTVERSION 5,2,3790,2744
-#define WINE_PRODUCTVERSION_STR "5.2.3790.2744"
+[
+ helpstring("DirectPlay Object"),
+ threading(both),
+ uuid(d1eb6d20-8923-11d0-9d97-00a0c90a43cb)
+]
+coclass DirectPlay { interface IDirectPlay; }
-#include <wine/wine_common_ver.rc>
+[
+ helpstring("DirectPlayLobby Object"),
+ threading(both),
+ uuid(2fe8f810-b2a5-11d0-a787-0000f803abfc)
+]
+coclass DirectPlayLobby { interface IDirectPlayLobby; }
--- /dev/null
+HKCR
+{
+ NoRemove Interface
+ {
+ }
+ NoRemove CLSID
+ {
+ '{D1EB6D20-8923-11D0-9D97-00A0C90A43CB}' = s 'DirectPlay Object'
+ {
+ InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
+ }
+ '{2FE8F810-B2A5-11D0-A787-0000F803ABFC}' = s 'DirectPlayLobby Object'
+ {
+ InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
+ }
+ }
+}
*
* 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
*
- * NOTES:
+ * NOTES:
* o Implementation of all things which are associated with dplay on
- * the computer - ie shared resources and such. Methods in this
- * compilation unit should not call anything out side this unit
- * excepting base windows services and an interface to start the
+ * the computer - i.e. shared resources and such. Methods in this
+ * compilation unit should not call anything outside of this unit
+ * except base windows services and an interface to start the
* messaging thread.
* o Methods that begin with DPLAYX_ are used for dealing with
* dplayx.dll data which is accessible from all processes.
/* FIXME: Need to do all that fun other dll referencing type of stuff */
/* Static data for all processes */
-static LPCSTR lpszDplayxSemaName = "WINE_DPLAYX_SM";
+static const char lpszDplayxSemaName[] = "WINE_DPLAYX_SM";
static HANDLE hDplayxSema;
-static LPCSTR lpszDplayxFileMapping = "WINE_DPLAYX_FM";
+static const char lpszDplayxFileMapping[] = "WINE_DPLAYX_FM";
static HANDLE hDplayxSharedMem;
static LPVOID lpSharedStaticData = NULL;
-#define DPLAYX_AquireSemaphore() TRACE( "Waiting for DPLAYX semaphore\n" ); \
+#define DPLAYX_AcquireSemaphore() TRACE( "Waiting for DPLAYX semaphore\n" ); \
WaitForSingleObject( hDplayxSema, INFINITE );\
TRACE( "Through wait\n" )
static DPLAYX_MEM_SLICE* lpMemArea;
-void DPLAYX_PrivHeapFree( LPVOID addr );
-void DPLAYX_PrivHeapFree( LPVOID addr )
+static void DPLAYX_PrivHeapFree( LPVOID addr )
{
LPVOID lpAddrStart;
DWORD dwBlockUsed;
lpMemArea[ dwBlockUsed ].used = 0;
}
-/* FIXME: This should be static, but is being used for a hack right now */
-LPVOID DPLAYX_PrivHeapAlloc( DWORD flags, DWORD size );
-LPVOID DPLAYX_PrivHeapAlloc( DWORD flags, DWORD size )
+static LPVOID DPLAYX_PrivHeapAlloc( DWORD flags, DWORD size )
{
LPVOID lpvArea = NULL;
UINT uBlockUsed;
if( size > (dwBlockSize - sizeof(DWORD)) )
{
- FIXME( "Size exceeded. Request of 0x%08lx\n", size );
+ FIXME( "Size exceeded. Request of 0x%08x\n", size );
size = dwBlockSize - sizeof(DWORD);
}
{
/* Set the area used */
lpMemArea[ uBlockUsed ].used = 1;
- lpvArea = &(lpMemArea[ uBlockUsed ].data);
+ lpvArea = lpMemArea[ uBlockUsed ].data;
}
else
{
return lpvArea;
}
-LPSTR DPLAYX_strdupA( DWORD flags, LPCSTR str );
-LPSTR DPLAYX_strdupA( DWORD flags, LPCSTR str )
-{
- LPSTR p = DPLAYX_PrivHeapAlloc( flags, strlen(str) + 1 );
- if(p) {
- strcpy( p, str );
- }
- return p;
-}
-
-LPWSTR DPLAYX_strdupW( DWORD flags, LPCWSTR str );
-LPWSTR DPLAYX_strdupW( DWORD flags, LPCWSTR str )
-{
- INT len = strlenW(str) + 1;
- LPWSTR p = DPLAYX_PrivHeapAlloc( flags, len * sizeof(WCHAR) );
- if(p) {
- strcpyW( p, str );
- }
- return p;
-}
-
enum { numSupportedLobbies = 32, numSupportedSessions = 32 };
typedef struct tagDPLAYX_LOBBYDATA
static DPSESSIONDESC2* sessionData = NULL;
/* static DPSESSIONDESC2* sessionData[ numSupportedSessions ]; */
-/* Function prototypes */
-DWORD DPLAYX_SizeOfLobbyDataA( LPDPLCONNECTION lpDplData );
-DWORD DPLAYX_SizeOfLobbyDataW( LPDPLCONNECTION lpDplData );
-void DPLAYX_CopyConnStructA( LPDPLCONNECTION dest, LPDPLCONNECTION src );
-void DPLAYX_CopyConnStructW( LPDPLCONNECTION dest, LPDPLCONNECTION src );
-BOOL DPLAYX_IsAppIdLobbied( DWORD dwAppId, LPDPLAYX_LOBBYDATA* dplData );
-void DPLAYX_InitializeLobbyDataEntry( LPDPLAYX_LOBBYDATA lpData );
-BOOL DPLAYX_CopyIntoSessionDesc2A( LPDPSESSIONDESC2 lpSessionDest,
- LPCDPSESSIONDESC2 lpSessionSrc );
+static void DPLAYX_InitializeLobbyDataEntry( LPDPLAYX_LOBBYDATA lpData )
+{
+ ZeroMemory( lpData, sizeof( *lpData ) );
+}
+
+/* NOTE: This must be called with the semaphore acquired.
+ * TRUE/FALSE with a pointer to it's data returned. Pointer data is
+ * is only valid if TRUE is returned.
+ */
+static BOOL DPLAYX_IsAppIdLobbied( DWORD dwAppID, LPDPLAYX_LOBBYDATA* lplpDplData )
+{
+ UINT i;
+
+ *lplpDplData = NULL;
+
+ if( dwAppID == 0 )
+ {
+ dwAppID = GetCurrentProcessId();
+ TRACE( "Translated dwAppID == 0 into 0x%08x\n", dwAppID );
+ }
+
+ for( i=0; i < numSupportedLobbies; i++ )
+ {
+ if( lobbyData[ i ].dwAppID == dwAppID )
+ {
+ /* This process is lobbied */
+ TRACE( "Found 0x%08x @ %u\n", dwAppID, i );
+ *lplpDplData = &lobbyData[ i ];
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+/* Reserve a spot for the new application. TRUE means success and FALSE failure. */
+BOOL DPLAYX_CreateLobbyApplication( DWORD dwAppID )
+{
+ UINT i;
+
+ /* 0 is the marker for unused application data slots */
+ if( dwAppID == 0 )
+ {
+ return FALSE;
+ }
+
+ DPLAYX_AcquireSemaphore();
+
+ /* Find an empty space in the list and insert the data */
+ for( i=0; i < numSupportedLobbies; i++ )
+ {
+ if( lobbyData[ i ].dwAppID == 0 )
+ {
+ /* This process is now lobbied */
+ TRACE( "Setting lobbyData[%u] for (0x%08x,0x%08x)\n",
+ i, dwAppID, GetCurrentProcessId() );
+
+ lobbyData[ i ].dwAppID = dwAppID;
+ lobbyData[ i ].dwAppLaunchedFromID = GetCurrentProcessId();
+
+ /* FIXME: Where is the best place for this? In interface or here? */
+ lobbyData[ i ].hInformOnAppStart = 0;
+ lobbyData[ i ].hInformOnAppDeath = 0;
+ lobbyData[ i ].hInformOnSettingRead = 0;
+
+ DPLAYX_ReleaseSemaphore();
+ return TRUE;
+ }
+ }
+
+ ERR( "No empty lobbies\n" );
+
+ DPLAYX_ReleaseSemaphore();
+ return FALSE;
+}
+
+BOOL DPLAYX_SetLobbyHandles( DWORD dwAppID,
+ HANDLE hStart, HANDLE hDeath, HANDLE hConnRead )
+{
+ LPDPLAYX_LOBBYDATA lpLData;
+
+ /* Need to explicitly give lobby application. Can't set for yourself */
+ if( dwAppID == 0 )
+ {
+ return FALSE;
+ }
+
+ DPLAYX_AcquireSemaphore();
+
+ if( !DPLAYX_IsAppIdLobbied( dwAppID, &lpLData ) )
+ {
+ DPLAYX_ReleaseSemaphore();
+ return FALSE;
+ }
+
+ lpLData->hInformOnAppStart = hStart;
+ lpLData->hInformOnAppDeath = hDeath;
+ lpLData->hInformOnSettingRead = hConnRead;
+
+ DPLAYX_ReleaseSemaphore();
+
+ return TRUE;
+}
+
+static BOOL DPLAYX_GetThisLobbyHandles( LPHANDLE lphStart,
+ LPHANDLE lphDeath,
+ LPHANDLE lphConnRead,
+ BOOL bClearSetHandles )
+{
+ LPDPLAYX_LOBBYDATA lpLData;
+
+ DPLAYX_AcquireSemaphore();
+
+ if( !DPLAYX_IsAppIdLobbied( 0, &lpLData ) )
+ {
+ DPLAYX_ReleaseSemaphore();
+ return FALSE;
+ }
+
+ if( lphStart != NULL )
+ {
+ if( lpLData->hInformOnAppStart == 0 )
+ {
+ DPLAYX_ReleaseSemaphore();
+ return FALSE;
+ }
+
+ *lphStart = lpLData->hInformOnAppStart;
+
+ if( bClearSetHandles )
+ {
+ CloseHandle( lpLData->hInformOnAppStart );
+ lpLData->hInformOnAppStart = 0;
+ }
+ }
+
+ if( lphDeath != NULL )
+ {
+ if( lpLData->hInformOnAppDeath == 0 )
+ {
+ DPLAYX_ReleaseSemaphore();
+ return FALSE;
+ }
+
+ *lphDeath = lpLData->hInformOnAppDeath;
+
+ if( bClearSetHandles )
+ {
+ CloseHandle( lpLData->hInformOnAppDeath );
+ lpLData->hInformOnAppDeath = 0;
+ }
+ }
+
+ if( lphConnRead != NULL )
+ {
+ if( lpLData->hInformOnSettingRead == 0 )
+ {
+ DPLAYX_ReleaseSemaphore();
+ return FALSE;
+ }
+
+ *lphConnRead = lpLData->hInformOnSettingRead;
+
+ if( bClearSetHandles )
+ {
+ CloseHandle( lpLData->hInformOnSettingRead );
+ lpLData->hInformOnSettingRead = 0;
+ }
+ }
+
+ DPLAYX_ReleaseSemaphore();
+ return TRUE;
+}
/***************************************************************************
* Called to initialize the global data. This will only be used on the
s_attrib.lpSecurityDescriptor = NULL;
s_attrib.nLength = sizeof(s_attrib);
- hDplayxSema = CreateSemaphoreA( &s_attrib, 1, 1, lpszDplayxSemaName );
+ hDplayxSema = CreateSemaphoreA( &s_attrib, 0, 1, lpszDplayxSemaName );
/* First instance creates the semaphore. Others just use it */
if( GetLastError() == ERROR_SUCCESS )
else if ( GetLastError() == ERROR_ALREADY_EXISTS )
{
TRACE( "Found semaphore handle %p\n", hDplayxSema );
+ DPLAYX_AcquireSemaphore();
}
else
{
- ERR( ": semaphore error %ld\n", GetLastError() );
+ ERR( ": semaphore error %d\n", GetLastError() );
return FALSE;
}
SetLastError( ERROR_SUCCESS );
- DPLAYX_AquireSemaphore();
-
hDplayxSharedMem = CreateFileMappingA( INVALID_HANDLE_VALUE,
&s_attrib,
PAGE_READWRITE | SEC_COMMIT,
}
else
{
- ERR( ": unable to create shared memory (%ld)\n", GetLastError() );
+ ERR( ": unable to create shared memory (%d)\n", GetLastError() );
+ DPLAYX_ReleaseSemaphore();
return FALSE;
}
if( lpSharedStaticData == NULL )
{
- ERR( ": unable to map static data into process memory space (%ld)\n",
+ ERR( ": unable to map static data into process memory space (%d)\n",
GetLastError() );
+ DPLAYX_ReleaseSemaphore();
return FALSE;
}
else
else
{
/* Presently the shared data structures use pointers. If the
- * files are no mapped into the same area, the pointers will no
+ * files are not mapped into the same area, the pointers will no
* longer make any sense :(
* FIXME: In the future make the shared data structures have some
* sort of fixup to make them independent between data spaces.
lpMemArea = (LPVOID)((BYTE*)lpSharedStaticData + dwStaticSharedSize);
/* FIXME: Crude hack */
- lobbyData = (DPLAYX_LOBBYDATA*)lpSharedStaticData;
+ lobbyData = lpSharedStaticData;
sessionData = (DPSESSIONDESC2*)((BYTE*)lpSharedStaticData + (dwStaticSharedSize/2));
/* Initialize shared data segments. */
sessionData[i].dwSize = 0;
}
- /* Zero out the dynmaic area */
+ /* Zero out the dynamic area */
ZeroMemory( lpMemArea, dwDynamicSharedSize );
/* Just for fun sync the whole data area */
}
-void DPLAYX_InitializeLobbyDataEntry( LPDPLAYX_LOBBYDATA lpData )
+/* Assumption: Enough contiguous space was allocated at dest */
+static void DPLAYX_CopyConnStructA( LPDPLCONNECTION dest, const DPLCONNECTION *src )
{
- ZeroMemory( lpData, sizeof( *lpData ) );
-}
+ BYTE* lpStartOfFreeSpace;
-/* NOTE: This must be called with the semaphore aquired.
- * TRUE/FALSE with a pointer to it's data returned. Pointer data is
- * is only valid if TRUE is returned.
- */
-BOOL DPLAYX_IsAppIdLobbied( DWORD dwAppID, LPDPLAYX_LOBBYDATA* lplpDplData )
-{
- UINT i;
+ *dest = *src;
- *lplpDplData = NULL;
+ lpStartOfFreeSpace = ((BYTE*)dest) + sizeof( DPLCONNECTION );
- if( dwAppID == 0 )
+ /* Copy the LPDPSESSIONDESC2 structure if it exists */
+ if( src->lpSessionDesc )
{
- dwAppID = GetCurrentProcessId();
- TRACE( "Translated dwAppID == 0 into 0x%08lx\n", dwAppID );
+ dest->lpSessionDesc = (LPDPSESSIONDESC2)lpStartOfFreeSpace;
+ lpStartOfFreeSpace += sizeof( DPSESSIONDESC2 );
+ *dest->lpSessionDesc = *src->lpSessionDesc;
+
+ /* Session names may or may not exist */
+ if( src->lpSessionDesc->u1.lpszSessionNameA )
+ {
+ strcpy( (LPSTR)lpStartOfFreeSpace, src->lpSessionDesc->u1.lpszSessionNameA );
+ dest->lpSessionDesc->u1.lpszSessionNameA = (LPSTR)lpStartOfFreeSpace;
+ lpStartOfFreeSpace +=
+ strlen( dest->lpSessionDesc->u1.lpszSessionNameA ) + 1;
+ }
+
+ if( src->lpSessionDesc->u2.lpszPasswordA )
+ {
+ strcpy( (LPSTR)lpStartOfFreeSpace, src->lpSessionDesc->u2.lpszPasswordA );
+ dest->lpSessionDesc->u2.lpszPasswordA = (LPSTR)lpStartOfFreeSpace;
+ lpStartOfFreeSpace +=
+ strlen( dest->lpSessionDesc->u2.lpszPasswordA ) + 1;
+ }
}
- for( i=0; i < numSupportedLobbies; i++ )
+ /* DPNAME structure is optional */
+ if( src->lpPlayerName )
{
- if( lobbyData[ i ].dwAppID == dwAppID )
+ dest->lpPlayerName = (LPDPNAME)lpStartOfFreeSpace;
+ lpStartOfFreeSpace += sizeof( DPNAME );
+ *dest->lpPlayerName = *src->lpPlayerName;
+
+ if( src->lpPlayerName->u1.lpszShortNameA )
{
- /* This process is lobbied */
- TRACE( "Found 0x%08lx @ %u\n", dwAppID, i );
- *lplpDplData = &lobbyData[ i ];
- return TRUE;
+ strcpy( (LPSTR)lpStartOfFreeSpace, src->lpPlayerName->u1.lpszShortNameA );
+ dest->lpPlayerName->u1.lpszShortNameA = (LPSTR)lpStartOfFreeSpace;
+ lpStartOfFreeSpace +=
+ strlen( dest->lpPlayerName->u1.lpszShortNameA ) + 1;
+ }
+
+ if( src->lpPlayerName->u2.lpszLongNameA )
+ {
+ strcpy( (LPSTR)lpStartOfFreeSpace, src->lpPlayerName->u2.lpszLongNameA );
+ dest->lpPlayerName->u2.lpszLongNameA = (LPSTR)lpStartOfFreeSpace;
+ lpStartOfFreeSpace +=
+ strlen( (LPSTR)dest->lpPlayerName->u2.lpszLongName ) + 1 ;
}
+
}
- return FALSE;
+ /* Copy address if it exists */
+ if( src->lpAddress )
+ {
+ dest->lpAddress = lpStartOfFreeSpace;
+ CopyMemory( lpStartOfFreeSpace, src->lpAddress, src->dwAddressSize );
+ /* No need to advance lpStartOfFreeSpace as there is no more "dynamic" data */
+ }
}
-/* Reserve a spot for the new appliction. TRUE means success and FALSE failure. */
-BOOL DPLAYX_CreateLobbyApplication( DWORD dwAppID )
+/* Assumption: Enough contiguous space was allocated at dest */
+static void DPLAYX_CopyConnStructW( LPDPLCONNECTION dest, const DPLCONNECTION *src )
{
- UINT i;
+ BYTE* lpStartOfFreeSpace;
- /* 0 is the marker for unused application data slots */
- if( dwAppID == 0 )
- {
- return FALSE;
- }
+ *dest = *src;
- DPLAYX_AquireSemaphore();
+ lpStartOfFreeSpace = ( (BYTE*)dest) + sizeof( DPLCONNECTION );
- /* Find an empty space in the list and insert the data */
- for( i=0; i < numSupportedLobbies; i++ )
+ /* Copy the LPDPSESSIONDESC2 structure if it exists */
+ if( src->lpSessionDesc )
{
- if( lobbyData[ i ].dwAppID == 0 )
- {
- /* This process is now lobbied */
- TRACE( "Setting lobbyData[%u] for (0x%08lx,0x%08lx)\n",
- i, dwAppID, GetCurrentProcessId() );
-
- lobbyData[ i ].dwAppID = dwAppID;
- lobbyData[ i ].dwAppLaunchedFromID = GetCurrentProcessId();
+ dest->lpSessionDesc = (LPDPSESSIONDESC2)lpStartOfFreeSpace;
+ lpStartOfFreeSpace += sizeof( DPSESSIONDESC2 );
+ *dest->lpSessionDesc = *src->lpSessionDesc;
- /* FIXME: Where is the best place for this? In interface or here? */
- lobbyData[ i ].hInformOnAppStart = 0;
- lobbyData[ i ].hInformOnAppDeath = 0;
- lobbyData[ i ].hInformOnSettingRead = 0;
+ /* Session names may or may not exist */
+ if( src->lpSessionDesc->u1.lpszSessionName )
+ {
+ strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpSessionDesc->u1.lpszSessionName );
+ dest->lpSessionDesc->u1.lpszSessionName = (LPWSTR)lpStartOfFreeSpace;
+ lpStartOfFreeSpace += sizeof(WCHAR) *
+ ( strlenW( dest->lpSessionDesc->u1.lpszSessionName ) + 1 );
+ }
- DPLAYX_ReleaseSemaphore();
- return TRUE;
+ if( src->lpSessionDesc->u2.lpszPassword )
+ {
+ strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpSessionDesc->u2.lpszPassword );
+ dest->lpSessionDesc->u2.lpszPassword = (LPWSTR)lpStartOfFreeSpace;
+ lpStartOfFreeSpace += sizeof(WCHAR) *
+ ( strlenW( dest->lpSessionDesc->u2.lpszPassword ) + 1 );
}
}
- ERR( "No empty lobbies\n" );
-
- DPLAYX_ReleaseSemaphore();
- return FALSE;
-}
-
-/* I'm not sure when I'm going to need this, but here it is */
-BOOL DPLAYX_DestroyLobbyApplication( DWORD dwAppID )
-{
- UINT i;
-
- DPLAYX_AquireSemaphore();
-
- /* Find an empty space in the list and insert the data */
- for( i=0; i < numSupportedLobbies; i++ )
+ /* DPNAME structure is optional */
+ if( src->lpPlayerName )
{
- if( lobbyData[ i ].dwAppID == dwAppID )
+ dest->lpPlayerName = (LPDPNAME)lpStartOfFreeSpace;
+ lpStartOfFreeSpace += sizeof( DPNAME );
+ *dest->lpPlayerName = *src->lpPlayerName;
+
+ if( src->lpPlayerName->u1.lpszShortName )
{
- /* FIXME: Should free up anything unused. Tisk tisk :0 */
- /* Mark this entry unused */
- TRACE( "Marking lobbyData[%u] unused\n", i );
- DPLAYX_InitializeLobbyDataEntry( &lobbyData[ i ] );
+ strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpPlayerName->u1.lpszShortName );
+ dest->lpPlayerName->u1.lpszShortName = (LPWSTR)lpStartOfFreeSpace;
+ lpStartOfFreeSpace += sizeof(WCHAR) *
+ ( strlenW( dest->lpPlayerName->u1.lpszShortName ) + 1 );
+ }
- DPLAYX_ReleaseSemaphore();
- return TRUE;
+ if( src->lpPlayerName->u2.lpszLongName )
+ {
+ strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpPlayerName->u2.lpszLongName );
+ dest->lpPlayerName->u2.lpszLongName = (LPWSTR)lpStartOfFreeSpace;
+ lpStartOfFreeSpace += sizeof(WCHAR) *
+ ( strlenW( dest->lpPlayerName->u2.lpszLongName ) + 1 );
}
+
+ }
+
+ /* Copy address if it exists */
+ if( src->lpAddress )
+ {
+ dest->lpAddress = lpStartOfFreeSpace;
+ CopyMemory( lpStartOfFreeSpace, src->lpAddress, src->dwAddressSize );
+ /* No need to advance lpStartOfFreeSpace as there is no more "dynamic" data */
}
- DPLAYX_ReleaseSemaphore();
- ERR( "Unable to find global entry for application\n" );
- return FALSE;
}
-BOOL DPLAYX_SetLobbyHandles( DWORD dwAppID,
- HANDLE hStart, HANDLE hDeath, HANDLE hConnRead )
+static DWORD DPLAYX_SizeOfLobbyDataA( const DPLCONNECTION *lpConn )
{
- LPDPLAYX_LOBBYDATA lpLData;
+ DWORD dwTotalSize = sizeof( DPLCONNECTION );
- /* Need to explictly give lobby application. Can't set for yourself */
- if( dwAppID == 0 )
+ /* Just a safety check */
+ if( lpConn == NULL )
{
- return FALSE;
+ ERR( "lpConn is NULL\n" );
+ return 0;
}
- DPLAYX_AquireSemaphore();
-
- if( !DPLAYX_IsAppIdLobbied( dwAppID, &lpLData ) )
+ if( lpConn->lpSessionDesc != NULL )
{
- DPLAYX_ReleaseSemaphore();
- return FALSE;
+ dwTotalSize += sizeof( DPSESSIONDESC2 );
+
+ if( lpConn->lpSessionDesc->u1.lpszSessionNameA )
+ {
+ dwTotalSize += strlen( lpConn->lpSessionDesc->u1.lpszSessionNameA ) + 1;
+ }
+
+ if( lpConn->lpSessionDesc->u2.lpszPasswordA )
+ {
+ dwTotalSize += strlen( lpConn->lpSessionDesc->u2.lpszPasswordA ) + 1;
+ }
}
- lpLData->hInformOnAppStart = hStart;
- lpLData->hInformOnAppDeath = hDeath;
- lpLData->hInformOnSettingRead = hConnRead;
+ if( lpConn->lpPlayerName != NULL )
+ {
+ dwTotalSize += sizeof( DPNAME );
- DPLAYX_ReleaseSemaphore();
+ if( lpConn->lpPlayerName->u1.lpszShortNameA )
+ {
+ dwTotalSize += strlen( lpConn->lpPlayerName->u1.lpszShortNameA ) + 1;
+ }
- return TRUE;
+ if( lpConn->lpPlayerName->u2.lpszLongNameA )
+ {
+ dwTotalSize += strlen( lpConn->lpPlayerName->u2.lpszLongNameA ) + 1;
+ }
+
+ }
+
+ dwTotalSize += lpConn->dwAddressSize;
+
+ return dwTotalSize;
}
-BOOL DPLAYX_GetThisLobbyHandles( LPHANDLE lphStart,
- LPHANDLE lphDeath,
- LPHANDLE lphConnRead,
- BOOL bClearSetHandles )
+static DWORD DPLAYX_SizeOfLobbyDataW( const DPLCONNECTION *lpConn )
{
- LPDPLAYX_LOBBYDATA lpLData;
-
- DPLAYX_AquireSemaphore();
+ DWORD dwTotalSize = sizeof( DPLCONNECTION );
- if( !DPLAYX_IsAppIdLobbied( 0, &lpLData ) )
+ /* Just a safety check */
+ if( lpConn == NULL )
{
- DPLAYX_ReleaseSemaphore();
- return FALSE;
+ ERR( "lpConn is NULL\n" );
+ return 0;
}
- if( lphStart != NULL )
+ if( lpConn->lpSessionDesc != NULL )
{
- if( lpLData->hInformOnAppStart == 0 )
+ dwTotalSize += sizeof( DPSESSIONDESC2 );
+
+ if( lpConn->lpSessionDesc->u1.lpszSessionName )
{
- DPLAYX_ReleaseSemaphore();
- return FALSE;
+ dwTotalSize += sizeof( WCHAR ) *
+ ( strlenW( lpConn->lpSessionDesc->u1.lpszSessionName ) + 1 );
}
- *lphStart = lpLData->hInformOnAppStart;
-
- if( bClearSetHandles )
+ if( lpConn->lpSessionDesc->u2.lpszPassword )
{
- CloseHandle( lpLData->hInformOnAppStart );
- lpLData->hInformOnAppStart = 0;
+ dwTotalSize += sizeof( WCHAR ) *
+ ( strlenW( lpConn->lpSessionDesc->u2.lpszPassword ) + 1 );
}
}
- if( lphDeath != NULL )
+ if( lpConn->lpPlayerName != NULL )
{
- if( lpLData->hInformOnAppDeath == 0 )
- {
- DPLAYX_ReleaseSemaphore();
- return FALSE;
- }
-
- *lphDeath = lpLData->hInformOnAppDeath;
+ dwTotalSize += sizeof( DPNAME );
- if( bClearSetHandles )
+ if( lpConn->lpPlayerName->u1.lpszShortName )
{
- CloseHandle( lpLData->hInformOnAppDeath );
- lpLData->hInformOnAppDeath = 0;
+ dwTotalSize += sizeof( WCHAR ) *
+ ( strlenW( lpConn->lpPlayerName->u1.lpszShortName ) + 1 );
}
- }
- if( lphConnRead != NULL )
- {
- if( lpLData->hInformOnSettingRead == 0 )
+ if( lpConn->lpPlayerName->u2.lpszLongName )
{
- DPLAYX_ReleaseSemaphore();
- return FALSE;
+ dwTotalSize += sizeof( WCHAR ) *
+ ( strlenW( lpConn->lpPlayerName->u2.lpszLongName ) + 1 );
}
- *lphConnRead = lpLData->hInformOnSettingRead;
-
- if( bClearSetHandles )
- {
- CloseHandle( lpLData->hInformOnSettingRead );
- lpLData->hInformOnSettingRead = 0;
- }
}
- DPLAYX_ReleaseSemaphore();
+ dwTotalSize += lpConn->dwAddressSize;
- return TRUE;
+ return dwTotalSize;
}
-
HRESULT DPLAYX_GetConnectionSettingsA
( DWORD dwAppID,
LPVOID lpData,
DWORD dwRequiredDataSize = 0;
HANDLE hInformOnSettingRead;
- DPLAYX_AquireSemaphore();
+ DPLAYX_AcquireSemaphore();
if ( ! DPLAYX_IsAppIdLobbied( dwAppID, &lpDplData ) )
{
DPLAYX_ReleaseSemaphore();
- TRACE( "Application 0x%08lx is not lobbied\n", dwAppID );
+ TRACE( "Application 0x%08x is not lobbied\n", dwAppID );
return DPERR_NOTLOBBIED;
}
return DPERR_BUFFERTOOSMALL;
}
- DPLAYX_CopyConnStructA( (LPDPLCONNECTION)lpData, lpDplData->lpConn );
+ DPLAYX_CopyConnStructA( lpData, lpDplData->lpConn );
DPLAYX_ReleaseSemaphore();
return DP_OK;
}
-/* Assumption: Enough contiguous space was allocated at dest */
-void DPLAYX_CopyConnStructA( LPDPLCONNECTION dest, LPDPLCONNECTION src )
-{
- BYTE* lpStartOfFreeSpace;
-
- CopyMemory( dest, src, sizeof( DPLCONNECTION ) );
-
- lpStartOfFreeSpace = ((BYTE*)dest) + sizeof( DPLCONNECTION );
-
- /* Copy the LPDPSESSIONDESC2 structure if it exists */
- if( src->lpSessionDesc )
- {
- dest->lpSessionDesc = (LPDPSESSIONDESC2)lpStartOfFreeSpace;
- lpStartOfFreeSpace += sizeof( DPSESSIONDESC2 );
- CopyMemory( dest->lpSessionDesc, src->lpSessionDesc, sizeof( DPSESSIONDESC2 ) );
-
- /* Session names may or may not exist */
- if( src->lpSessionDesc->lpszSessionNameA )
- {
- strcpy( (LPSTR)lpStartOfFreeSpace, src->lpSessionDesc->lpszSessionNameA );
- dest->lpSessionDesc->lpszSessionNameA = (LPSTR)lpStartOfFreeSpace;
- lpStartOfFreeSpace +=
- strlen( (LPSTR)dest->lpSessionDesc->lpszSessionNameA ) + 1;
- }
-
- if( src->lpSessionDesc->lpszPasswordA )
- {
- strcpy( (LPSTR)lpStartOfFreeSpace, src->lpSessionDesc->lpszPasswordA );
- dest->lpSessionDesc->lpszPasswordA = (LPSTR)lpStartOfFreeSpace;
- lpStartOfFreeSpace +=
- strlen( (LPSTR)dest->lpSessionDesc->lpszPasswordA ) + 1;
- }
- }
-
- /* DPNAME structure is optional */
- if( src->lpPlayerName )
- {
- dest->lpPlayerName = (LPDPNAME)lpStartOfFreeSpace;
- lpStartOfFreeSpace += sizeof( DPNAME );
- CopyMemory( dest->lpPlayerName, src->lpPlayerName, sizeof( DPNAME ) );
-
- if( src->lpPlayerName->lpszShortNameA )
- {
- strcpy( (LPSTR)lpStartOfFreeSpace, src->lpPlayerName->lpszShortNameA );
- dest->lpPlayerName->lpszShortNameA = (LPSTR)lpStartOfFreeSpace;
- lpStartOfFreeSpace +=
- strlen( (LPSTR)dest->lpPlayerName->lpszShortNameA ) + 1;
- }
-
- if( src->lpPlayerName->lpszLongNameA )
- {
- strcpy( (LPSTR)lpStartOfFreeSpace, src->lpPlayerName->lpszLongNameA );
- dest->lpPlayerName->lpszLongNameA = (LPSTR)lpStartOfFreeSpace;
- lpStartOfFreeSpace +=
- strlen( (LPSTR)dest->lpPlayerName->lpszLongName ) + 1 ;
- }
-
- }
-
- /* Copy address if it exists */
- if( src->lpAddress )
- {
- dest->lpAddress = (LPVOID)lpStartOfFreeSpace;
- CopyMemory( lpStartOfFreeSpace, src->lpAddress, src->dwAddressSize );
- /* No need to advance lpStartOfFreeSpace as there is no more "dynamic" data */
- }
-}
-
HRESULT DPLAYX_GetConnectionSettingsW
( DWORD dwAppID,
LPVOID lpData,
DWORD dwRequiredDataSize = 0;
HANDLE hInformOnSettingRead;
- DPLAYX_AquireSemaphore();
+ DPLAYX_AcquireSemaphore();
if ( ! DPLAYX_IsAppIdLobbied( dwAppID, &lpDplData ) )
{
return DPERR_BUFFERTOOSMALL;
}
- DPLAYX_CopyConnStructW( (LPDPLCONNECTION)lpData, lpDplData->lpConn );
+ DPLAYX_CopyConnStructW( lpData, lpDplData->lpConn );
DPLAYX_ReleaseSemaphore();
return DP_OK;
}
-/* Assumption: Enough contiguous space was allocated at dest */
-void DPLAYX_CopyConnStructW( LPDPLCONNECTION dest, LPDPLCONNECTION src )
-{
- BYTE* lpStartOfFreeSpace;
-
- CopyMemory( dest, src, sizeof( DPLCONNECTION ) );
-
- lpStartOfFreeSpace = ( (BYTE*)dest) + sizeof( DPLCONNECTION );
-
- /* Copy the LPDPSESSIONDESC2 structure if it exists */
- if( src->lpSessionDesc )
- {
- dest->lpSessionDesc = (LPDPSESSIONDESC2)lpStartOfFreeSpace;
- lpStartOfFreeSpace += sizeof( DPSESSIONDESC2 );
- CopyMemory( dest->lpSessionDesc, src->lpSessionDesc, sizeof( DPSESSIONDESC2 ) );
-
- /* Session names may or may not exist */
- if( src->lpSessionDesc->lpszSessionName )
- {
- strcpyW( (LPWSTR)lpStartOfFreeSpace, dest->lpSessionDesc->lpszSessionName );
- src->lpSessionDesc->lpszSessionName = (LPWSTR)lpStartOfFreeSpace;
- lpStartOfFreeSpace += sizeof(WCHAR) *
- ( strlenW( (LPWSTR)dest->lpSessionDesc->lpszSessionName ) + 1 );
- }
-
- if( src->lpSessionDesc->lpszPassword )
- {
- strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpSessionDesc->lpszPassword );
- dest->lpSessionDesc->lpszPassword = (LPWSTR)lpStartOfFreeSpace;
- lpStartOfFreeSpace += sizeof(WCHAR) *
- ( strlenW( (LPWSTR)dest->lpSessionDesc->lpszPassword ) + 1 );
- }
- }
-
- /* DPNAME structure is optional */
- if( src->lpPlayerName )
- {
- dest->lpPlayerName = (LPDPNAME)lpStartOfFreeSpace;
- lpStartOfFreeSpace += sizeof( DPNAME );
- CopyMemory( dest->lpPlayerName, src->lpPlayerName, sizeof( DPNAME ) );
-
- if( src->lpPlayerName->lpszShortName )
- {
- strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpPlayerName->lpszShortName );
- dest->lpPlayerName->lpszShortName = (LPWSTR)lpStartOfFreeSpace;
- lpStartOfFreeSpace += sizeof(WCHAR) *
- ( strlenW( (LPWSTR)dest->lpPlayerName->lpszShortName ) + 1 );
- }
-
- if( src->lpPlayerName->lpszLongName )
- {
- strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpPlayerName->lpszLongName );
- dest->lpPlayerName->lpszLongName = (LPWSTR)lpStartOfFreeSpace;
- lpStartOfFreeSpace += sizeof(WCHAR) *
- ( strlenW( (LPWSTR)dest->lpPlayerName->lpszLongName ) + 1 );
- }
-
- }
-
- /* Copy address if it exists */
- if( src->lpAddress )
- {
- dest->lpAddress = (LPVOID)lpStartOfFreeSpace;
- CopyMemory( lpStartOfFreeSpace, src->lpAddress, src->dwAddressSize );
- /* No need to advance lpStartOfFreeSpace as there is no more "dynamic" data */
- }
-
-}
-
-/* Store the structure into the shared data structre. Ensure that allocs for
+/* Store the structure into the shared data structure. Ensure that allocs for
* variable length strings come from the shared data structure.
- * FIXME: We need to free information as well
+ * FIXME: We need to free information as well.
*/
HRESULT DPLAYX_SetConnectionSettingsA
( DWORD dwFlags,
DWORD dwAppID,
- LPDPLCONNECTION lpConn )
+ const DPLCONNECTION *lpConn )
{
LPDPLAYX_LOBBYDATA lpDplData;
/* Store information */
if( lpConn->dwSize != sizeof(DPLCONNECTION) )
{
- ERR(": old/new DPLCONNECTION type? Size=%08lx vs. expected=%ul bytes\n",
- lpConn->dwSize, sizeof( DPLCONNECTION ) );
+ ERR(": old/new DPLCONNECTION type? Size=%08x\n", lpConn->dwSize );
return DPERR_INVALIDPARAMS;
}
- DPLAYX_AquireSemaphore();
+ DPLAYX_AcquireSemaphore();
if ( ! DPLAYX_IsAppIdLobbied( dwAppID, &lpDplData ) )
{
{
DPLAYX_ReleaseSemaphore();
- ERR("DPSESSIONDESC passed in? Size=%lu vs. expected=%u bytes\n",
- lpConn->lpSessionDesc->dwSize, sizeof( DPSESSIONDESC2 ) );
+ ERR("DPSESSIONDESC passed in? Size=%u\n",
+ lpConn->lpSessionDesc?lpConn->lpSessionDesc->dwSize:0 );
return DPERR_INVALIDPARAMS;
}
return DP_OK;
}
-/* Store the structure into the shared data structre. Ensure that allocs for
+/* Store the structure into the shared data structure. Ensure that allocs for
* variable length strings come from the shared data structure.
* FIXME: We need to free information as well
*/
HRESULT DPLAYX_SetConnectionSettingsW
( DWORD dwFlags,
DWORD dwAppID,
- LPDPLCONNECTION lpConn )
+ const DPLCONNECTION *lpConn )
{
LPDPLAYX_LOBBYDATA lpDplData;
/* Store information */
if( lpConn->dwSize != sizeof(DPLCONNECTION) )
{
- ERR(": old/new DPLCONNECTION type? Size=%lu vs. expected=%u bytes\n",
- lpConn->dwSize, sizeof( DPLCONNECTION ) );
+ ERR(": old/new DPLCONNECTION type? Size=%u\n", lpConn->dwSize );
return DPERR_INVALIDPARAMS;
}
- DPLAYX_AquireSemaphore();
+ DPLAYX_AcquireSemaphore();
if ( ! DPLAYX_IsAppIdLobbied( dwAppID, &lpDplData ) )
{
return DP_OK;
}
-DWORD DPLAYX_SizeOfLobbyDataA( LPDPLCONNECTION lpConn )
-{
- DWORD dwTotalSize = sizeof( DPLCONNECTION );
-
- /* Just a safety check */
- if( lpConn == NULL )
- {
- ERR( "lpConn is NULL\n" );
- return 0;
- }
-
- if( lpConn->lpSessionDesc != NULL )
- {
- dwTotalSize += sizeof( DPSESSIONDESC2 );
-
- if( lpConn->lpSessionDesc->lpszSessionNameA )
- {
- dwTotalSize += strlen( lpConn->lpSessionDesc->lpszSessionNameA ) + 1;
- }
-
- if( lpConn->lpSessionDesc->lpszPasswordA )
- {
- dwTotalSize += strlen( lpConn->lpSessionDesc->lpszPasswordA ) + 1;
- }
- }
-
- if( lpConn->lpPlayerName != NULL )
- {
- dwTotalSize += sizeof( DPNAME );
-
- if( lpConn->lpPlayerName->lpszShortNameA )
- {
- dwTotalSize += strlen( lpConn->lpPlayerName->lpszShortNameA ) + 1;
- }
-
- if( lpConn->lpPlayerName->lpszLongNameA )
- {
- dwTotalSize += strlen( lpConn->lpPlayerName->lpszLongNameA ) + 1;
- }
-
- }
-
- dwTotalSize += lpConn->dwAddressSize;
-
- return dwTotalSize;
-}
-
-DWORD DPLAYX_SizeOfLobbyDataW( LPDPLCONNECTION lpConn )
-{
- DWORD dwTotalSize = sizeof( DPLCONNECTION );
-
- /* Just a safety check */
- if( lpConn == NULL )
- {
- ERR( "lpConn is NULL\n" );
- return 0;
- }
-
- if( lpConn->lpSessionDesc != NULL )
- {
- dwTotalSize += sizeof( DPSESSIONDESC2 );
-
- if( lpConn->lpSessionDesc->lpszSessionName )
- {
- dwTotalSize += sizeof( WCHAR ) *
- ( strlenW( lpConn->lpSessionDesc->lpszSessionName ) + 1 );
- }
-
- if( lpConn->lpSessionDesc->lpszPassword )
- {
- dwTotalSize += sizeof( WCHAR ) *
- ( strlenW( lpConn->lpSessionDesc->lpszPassword ) + 1 );
- }
- }
-
- if( lpConn->lpPlayerName != NULL )
- {
- dwTotalSize += sizeof( DPNAME );
-
- if( lpConn->lpPlayerName->lpszShortName )
- {
- dwTotalSize += sizeof( WCHAR ) *
- ( strlenW( lpConn->lpPlayerName->lpszShortName ) + 1 );
- }
-
- if( lpConn->lpPlayerName->lpszLongName )
- {
- dwTotalSize += sizeof( WCHAR ) *
- ( strlenW( lpConn->lpPlayerName->lpszLongName ) + 1 );
- }
-
- }
-
- dwTotalSize += lpConn->dwAddressSize;
-
- return dwTotalSize;
-}
-
-
-
-static LPDPSESSIONDESC2 DPLAYX_CopyAndAllocateSessionDesc2A( LPCDPSESSIONDESC2 lpSessionSrc )
-{
- LPDPSESSIONDESC2 lpSessionDest =
- HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *lpSessionSrc ) );
- DPLAYX_CopyIntoSessionDesc2A( lpSessionDest, lpSessionSrc );
-
- return lpSessionDest;
-}
-
-/* Copy an ANSI session desc structure to the given buffer */
-BOOL DPLAYX_CopyIntoSessionDesc2A( LPDPSESSIONDESC2 lpSessionDest,
- LPCDPSESSIONDESC2 lpSessionSrc )
-{
- CopyMemory( lpSessionDest, lpSessionSrc, sizeof( *lpSessionSrc ) );
-
- if( lpSessionSrc->lpszSessionNameA )
- {
- if ((lpSessionDest->lpszSessionNameA = HeapAlloc( GetProcessHeap(), 0,
- strlen(lpSessionSrc->lpszSessionNameA)+1 )))
- strcpy( lpSessionDest->lpszSessionNameA, lpSessionSrc->lpszSessionNameA );
- }
- if( lpSessionSrc->lpszPasswordA )
- {
- if ((lpSessionDest->lpszPasswordA = HeapAlloc( GetProcessHeap(), 0,
- strlen(lpSessionSrc->lpszPasswordA)+1 )))
- strcpy( lpSessionDest->lpszPasswordA, lpSessionSrc->lpszPasswordA );
- }
-
- return TRUE;
-}
-
-/* Start the index at 0. index will be updated to equal that which should
- be passed back into this function for the next element */
-LPDPSESSIONDESC2 DPLAYX_CopyAndAllocateLocalSession( UINT* index )
-{
- for( ; (*index) < numSupportedSessions; (*index)++ )
- {
- if( sessionData[(*index)].dwSize != 0 )
- {
- return DPLAYX_CopyAndAllocateSessionDesc2A( &sessionData[(*index)++] );
- }
- }
-
- /* No more sessions */
- return NULL;
-}
-
-/* Start the index at 0. index will be updated to equal that which should
- be passed back into this function for the next element */
-BOOL DPLAYX_CopyLocalSession( UINT* index, LPDPSESSIONDESC2 lpsd )
-{
- for( ; (*index) < numSupportedSessions; (*index)++ )
- {
- if( sessionData[(*index)].dwSize != 0 )
- {
- return DPLAYX_CopyIntoSessionDesc2A( lpsd, &sessionData[(*index)++] );
- }
- }
-
- /* No more sessions */
- return FALSE;
-}
-
-void DPLAYX_SetLocalSession( LPCDPSESSIONDESC2 lpsd )
-{
- UINT i;
-
- /* FIXME: Is this an error if it exists already? */
-
- /* Crude/wrong implementation for now. Just always add to first empty spot */
- for( i=0; i < numSupportedSessions; i++ )
- {
- /* Is this one empty? */
- if( sessionData[i].dwSize == 0 )
- {
- DPLAYX_CopyIntoSessionDesc2A( &sessionData[i], lpsd );
- break;
- }
- }
-
-}
-
BOOL DPLAYX_WaitForConnectionSettings( BOOL bWait )
{
LPDPLAYX_LOBBYDATA lpLobbyData;
- DPLAYX_AquireSemaphore();
+ DPLAYX_AcquireSemaphore();
if( !DPLAYX_IsAppIdLobbied( 0, &lpLobbyData ) )
{
UINT i;
BOOL bFound = FALSE;
- DPLAYX_AquireSemaphore();
+ DPLAYX_AcquireSemaphore();
for( i=0; i < numSupportedLobbies; i++ )
{
{
LPDPLAYX_LOBBYDATA lpLobbyData;
- DPLAYX_AquireSemaphore();
+ DPLAYX_AcquireSemaphore();
if( !DPLAYX_IsAppIdLobbied( dwAppId, &lpLobbyData ) )
{
default:
/* For errors not in the list, return HRESULT as a string
This part is not thread safe */
- WARN( "Unknown error 0x%08lx\n", hr );
+ WARN( "Unknown error 0x%08x\n", hr );
wsprintfA( szTempStr, "0x%08lx", hr );
return szTempStr;
}
*
* 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_DPLAYX_GLOBAL
#define WIN32_NO_STATUS
#define _INC_WINDOWS
-#define COM_NO_WINDOWS_H
#include <stdarg.h>
//#include "winuser.h"
#include <dplay.h>
-BOOL DPLAYX_ConstructData(void);
-BOOL DPLAYX_DestructData(void);
+BOOL DPLAYX_ConstructData(void) DECLSPEC_HIDDEN;
+BOOL DPLAYX_DestructData(void) DECLSPEC_HIDDEN;
HRESULT DPLAYX_GetConnectionSettingsA ( DWORD dwAppID,
LPVOID lpData,
- LPDWORD lpdwDataSize );
+ LPDWORD lpdwDataSize ) DECLSPEC_HIDDEN;
HRESULT DPLAYX_GetConnectionSettingsW ( DWORD dwAppID,
LPVOID lpData,
- LPDWORD lpdwDataSize );
+ LPDWORD lpdwDataSize ) DECLSPEC_HIDDEN;
HRESULT DPLAYX_SetConnectionSettingsA ( DWORD dwFlags,
DWORD dwAppID,
- LPDPLCONNECTION lpConn );
+ const DPLCONNECTION *lpConn ) DECLSPEC_HIDDEN;
HRESULT DPLAYX_SetConnectionSettingsW ( DWORD dwFlags,
DWORD dwAppID,
- LPDPLCONNECTION lpConn );
+ const DPLCONNECTION *lpConn ) DECLSPEC_HIDDEN;
-BOOL DPLAYX_CreateLobbyApplication( DWORD dwAppID );
-BOOL DPLAYX_DestroyLobbyApplication( DWORD dwAppID );
+BOOL DPLAYX_CreateLobbyApplication( DWORD dwAppID ) DECLSPEC_HIDDEN;
-BOOL DPLAYX_WaitForConnectionSettings( BOOL bWait );
-BOOL DPLAYX_AnyLobbiesWaitingForConnSettings(void);
+BOOL DPLAYX_WaitForConnectionSettings( BOOL bWait ) DECLSPEC_HIDDEN;
+BOOL DPLAYX_AnyLobbiesWaitingForConnSettings(void) DECLSPEC_HIDDEN;
BOOL DPLAYX_SetLobbyHandles( DWORD dwAppID,
- HANDLE hStart, HANDLE hDeath, HANDLE hConnRead );
-BOOL DPLAYX_GetThisLobbyHandles( LPHANDLE lphStart,
- LPHANDLE lphDeath,
- LPHANDLE lphConnRead, BOOL bClearSetHandles );
+ HANDLE hStart, HANDLE hDeath, HANDLE hConnRead ) DECLSPEC_HIDDEN;
-LPDPSESSIONDESC2 DPLAYX_CopyAndAllocateLocalSession( UINT* index );
-BOOL DPLAYX_CopyLocalSession( UINT* index, LPDPSESSIONDESC2 lpsd );
-void DPLAYX_SetLocalSession( LPCDPSESSIONDESC2 lpsd );
-
-BOOL DPLAYX_SetLobbyMsgThreadId( DWORD dwAppId, DWORD dwThreadId );
-
-/* FIXME: This should not be here */
-LPVOID DPLAYX_PrivHeapAlloc( DWORD flags, DWORD size );
-void DPLAYX_PrivHeapFree( LPVOID addr );
-
-LPSTR DPLAYX_strdupA( DWORD flags, LPCSTR str );
-LPWSTR DPLAYX_strdupW( DWORD flags, LPCWSTR str );
-/* FIXME: End shared data alloc which should be local */
+BOOL DPLAYX_SetLobbyMsgThreadId( DWORD dwAppId, DWORD dwThreadId ) DECLSPEC_HIDDEN;
/* Convert a DP or DPL HRESULT code into a string for human consumption */
-LPCSTR DPLAYX_HresultToString( HRESULT hr );
+LPCSTR DPLAYX_HresultToString( HRESULT hr ) DECLSPEC_HIDDEN;
#endif /* __WINE_DPLAYX_GLOBAL */
*
* 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* NOTES
* o DPMSGCMD_ENUMSESSIONSREPLY & DPMSGCMD_ENUMSESSIONSREQUEST
* Have most fields understood, but not all. Everything seems to work.
* o DPMSGCMD_REQUESTNEWPLAYERID & DPMSGCMD_NEWPLAYERIDREPLY
- * Barely work. This needs to be completed for sessions to start.
+ * Barely works. This needs to be completed for sessions to start.
* o A small issue will be the fact that DirectX 6.1(ie. DirectPlay4)
- * introduces a layer of functionality inside the DP objects which
+ * introduces a layer of functionality inside the DP objects which
* provide guaranteed protocol delivery. This is even if the native
* protocol, IPX or modem for instance, doesn't guarantee it. I'm going
- * to leave this kind of implementation to as close to the end as
- * possible. However, I will implement an abstraction layer, where
- * possible, for this functionality. It will do nothing to start, but
- * will require only the implementation of the guaranteness to give
+ * to leave this kind of implementation to as close to the end as
+ * possible. However, I will implement an abstraction layer, where
+ * possible, for this functionality. It will do nothing to start, but
+ * will require only the implementation of the guarantee to give
* final implementation.
*
* TODO:
* - Change RegEnumKeyEx enumeration pattern to allow error handling and to
* share registry implementation (or at least simplify).
* - Add in appropriate RegCloseKey calls for all the opening we're doing...
- * - Fix all the buffer sizes for registry calls. They're off by one -
+ * - Fix all the buffer sizes for registry calls. They're off by one -
* but in a safe direction.
* - Fix race condition on interface destruction
* - Handles need to be correctly reference counted
- * - Check if we need to deallocate any list objects when destroying
+ * - Check if we need to deallocate any list objects when destroying
* a dplay interface
- * - RunApplication process spawning needs to have correct syncronization.
+ * - RunApplication process spawning needs to have correct synchronization.
* - Need to get inter lobby messages working.
- * - Decypher dplay messages between applications and implement...
+ * - Decipher dplay messages between applications and implement...
* - Need to implement lobby session spawning.
* - Improve footprint and realtime blocking by setting up a separate data share
* between lobby application and client since there can be multiple apps per
* client. Also get rid of offset dependency by making data offset independent
* somehow.
*/
-//#include <stdarg.h>
+
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+
+#include <stdarg.h>
//#include "winerror.h"
-//#include "windef.h"
-//#include "winbase.h"
+#include <windef.h>
+#include <winbase.h>
+#include <objbase.h>
+#include <rpcproxy.h>
#include <wine/debug.h>
#include "dplayx_global.h"
WINE_DEFAULT_DEBUG_CHANNEL(dplay);
+static HINSTANCE instance;
+
/* This is a globally exported variable at ordinal 6 of DPLAYX.DLL */
DWORD gdwDPlaySPRefCount = 0; /* FIXME: Should it be initialized here? */
BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
{
- TRACE( "(%p,%ld,%p)\n", hinstDLL, fdwReason, lpvReserved );
+ TRACE( "(%p,%d,%p)\n", hinstDLL, fdwReason, lpvReserved );
switch ( fdwReason )
{
case DLL_PROCESS_ATTACH:
+ instance = hinstDLL;
DisableThreadLibraryCalls(hinstDLL);
/* First instance perform construction of global processor data */
return DPLAYX_ConstructData();
HRESULT hr = ( gdwDPlaySPRefCount > 0 ) ? S_FALSE : S_OK;
/* FIXME: Should I be putting a check in for class factory objects
- * as well
+ * as well?
*/
- TRACE( ": returning 0x%08lx\n", hr );
+ TRACE( ": returning 0x%08x\n", hr );
return hr;
}
+
+/***********************************************************************
+ * DllRegisterServer (DPLAYX.@)
+ */
+HRESULT WINAPI DllRegisterServer(void)
+{
+ return __wine_register_resources( instance );
+}
+
+/***********************************************************************
+ * DllUnregisterServer (DPLAYX.@)
+ */
+HRESULT WINAPI DllUnregisterServer(void)
+{
+ return __wine_unregister_resources( instance );
+}
*
* 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* NOTES
* o Messaging interface required for both DirectPlay and DirectPlayLobby.
static DWORD CALLBACK DPL_MSG_ThreadMain( LPVOID lpContext )
{
- LPMSGTHREADINFO lpThreadInfo = (LPMSGTHREADINFO)lpContext;
+ LPMSGTHREADINFO lpThreadInfo = lpContext;
DWORD dwWaitResult;
TRACE( "Msg thread created. Waiting on app startup\n" );
dwWaitResult = WaitForSingleObject( lpThreadInfo->hStart, 10000 /* 10 sec */ );
if( dwWaitResult == WAIT_TIMEOUT )
{
- FIXME( "Should signal app/wait creation failure (0x%08lx)\n", dwWaitResult );
+ FIXME( "Should signal app/wait creation failure (0x%08x)\n", dwWaitResult );
goto end_of_thread;
}
dwWaitResult = WaitForSingleObject( lpThreadInfo->hSettingRead, INFINITE );
if( dwWaitResult == WAIT_TIMEOUT )
{
- ERR( "App Read connection setting timeout fail (0x%08lx)\n", dwWaitResult );
+ ERR( "App Read connection setting timeout fail (0x%08x)\n", dwWaitResult );
}
/* Close this handle as it's not needed anymore */
CloseHandle( lpThreadInfo->hSettingRead );
lpThreadInfo->hSettingRead = 0;
- TRACE( "App created && intialized starting main message reception loop\n" );
+ TRACE( "App created && initialized starting main message reception loop\n" );
for ( ;; )
{
return 0;
}
-/* DP messageing stuff */
+/* DP messaging stuff */
static HANDLE DP_MSG_BuildAndLinkReplyStruct( IDirectPlay2Impl* This,
LPDP_MSG_REPLY_STRUCT_LIST lpReplyStructList,
WORD wReplyCommandId );
/* Insert into the message queue while locked */
EnterCriticalSection( &This->unk->DP_lock );
- DPQ_INSERT( This->dp2->replysExpected, lpReplyStructList, replysExpected );
+ DPQ_INSERT( This->dp2->repliesExpected, lpReplyStructList, repliesExpected );
LeaveCriticalSection( &This->unk->DP_lock );
return lpReplyStructList->replyExpected.hReceipt;
data.bSystemMessage = TRUE; /* Allow reply to be sent */
data.lpISP = This->dp2->spData.lpISP;
- TRACE( "Asking for player id w/ dwFlags 0x%08lx\n",
+ TRACE( "Asking for player id w/ dwFlags 0x%08x\n",
lpMsgBody->dwFlags );
DP_MSG_ExpectReply( This, &data, DPMSG_DEFAULT_WAIT_TIME, DPMSGCMD_NEWPLAYERIDREPLY,
}
/* Need to examine the data and extract the new player id */
- if( !FAILED(hr) )
+ if( SUCCEEDED(hr) )
{
LPCDPMSG_NEWPLAYERIDREPLY lpcReply;
- lpcReply = (LPCDPMSG_NEWPLAYERIDREPLY)lpMsg;
+ lpcReply = lpMsg;
*lpdpidAllocatedId = lpcReply->dpidNewPlayerId;
- TRACE( "Received reply for id = 0x%08lx\n", lpcReply->dpidNewPlayerId );
+ TRACE( "Received reply for id = 0x%08x\n", lpcReply->dpidNewPlayerId );
/* FIXME: I think that the rest of the message has something to do
* with remote data for the player that perhaps I need to setup.
* However, with the information that is passed, all that it could
- * be used for is a standardized intialization value, which I'm
+ * be used for is a standardized initialization value, which I'm
* guessing we can do without. Unless the message content is the same
* for several different messages?
*/
DWORD dwDataSize;
/* SP Player remote data needs to be propagated at some point - is this the point? */
- IDirectPlaySP_GetSPPlayerData( This->dp2->spData.lpISP, 0, (LPVOID*)&lpPData, &dwDataSize, DPSET_REMOTE );
+ IDirectPlaySP_GetSPPlayerData( This->dp2->spData.lpISP, 0, &lpPData, &dwDataSize, DPSET_REMOTE );
ERR( "Player Data size is 0x%08lx\n"
"[%02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x]\n"
lpMsgBody->unknown4[3] = NS_GetNsMagic( This->dp2->lpNameServerData ) -
0x02000000;
- TRACE( "Setting first magic to 0x%08lx\n", lpMsgBody->unknown4[3] );
+ TRACE( "Setting first magic to 0x%08x\n", lpMsgBody->unknown4[3] );
lpMsgBody->unknown4[4] = 0x0;
lpMsgBody->unknown4[5] = 0x0;
lpMsgBody->unknown4[6] = 0x0;
-#if 0
- lpMsgBody->unknown4[7] = NS_GetOtherMagic( This->dp2->lpNameServerData )
-#else
lpMsgBody->unknown4[7] = NS_GetNsMagic( This->dp2->lpNameServerData );
-#endif
- TRACE( "Setting second magic to 0x%08lx\n", lpMsgBody->unknown4[7] );
+ TRACE( "Setting second magic to 0x%08x\n", lpMsgBody->unknown4[7] );
lpMsgBody->unknown4[8] = 0x0;
lpMsgBody->unknown4[9] = 0x0;
data.bSystemMessage = TRUE; /* Allow reply to be sent */
data.lpISP = This->dp2->spData.lpISP;
- TRACE( "Sending forward player request with 0x%08lx\n", dpidServer );
+ TRACE( "Sending forward player request with 0x%08x\n", dpidServer );
lpMsg = DP_MSG_ExpectReply( This, &data,
DPMSG_WAIT_60_SECS,
hMsgReceipt = DP_MSG_BuildAndLinkReplyStruct( This, &replyStructList,
wReplyCommandId );
- TRACE( "Sending msg and expecting cmd %u in reply within %lu ticks\n",
+ TRACE( "Sending msg and expecting cmd %u in reply within %u ticks\n",
wReplyCommandId, dwWaitTime );
hr = (*This->dp2->spData.lpCB->Send)( lpData );
dwWaitReturn = WaitForSingleObject( hMsgReceipt, dwWaitTime );
if( dwWaitReturn != WAIT_OBJECT_0 )
{
- ERR( "Wait failed 0x%08lx\n", dwWaitReturn );
+ ERR( "Wait failed 0x%08x\n", dwWaitReturn );
return NULL;
}
* avoid problems.
*/
EnterCriticalSection( &This->unk->DP_lock );
- DPQ_REMOVE_ENTRY( This->dp2->replysExpected, replysExpected, replyExpected.wExpectedReply,\
+ DPQ_REMOVE_ENTRY( This->dp2->repliesExpected, repliesExpected, replyExpected.wExpectedReply,
==, wCommandId, lpReplyList );
LeaveCriticalSection( &This->unk->DP_lock );
{
LPCDPMSG_FORWARDADDPLAYERNACK lpcErrorMsg;
- lpcErrorMsg = (LPCDPMSG_FORWARDADDPLAYERNACK)lpMsgBody;
+ lpcErrorMsg = lpMsgBody;
ERR( "Received error message %u. Error is %s\n",
wCommandId, DPLAYX_HresultToString( lpcErrorMsg->errorCode) );
*
* 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_DPLAYX_MESSAGES__
#include "dplay_global.h"
DWORD CreateLobbyMessageReceptionThread( HANDLE hNotifyEvent, HANDLE hStart,
- HANDLE hDeath, HANDLE hConnRead );
+ HANDLE hDeath, HANDLE hConnRead ) DECLSPEC_HIDDEN;
HRESULT DP_MSG_SendRequestPlayerId( IDirectPlay2AImpl* This, DWORD dwFlags,
- LPDPID lpdipidAllocatedId );
-HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlay2AImpl* This, DPID dpidServer );
+ LPDPID lpdipidAllocatedId ) DECLSPEC_HIDDEN;
+HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlay2AImpl* This, DPID dpidServer ) DECLSPEC_HIDDEN;
void DP_MSG_ReplyReceived( IDirectPlay2AImpl* This, WORD wCommandId,
- LPCVOID lpMsgBody, DWORD dwMsgBodySize );
+ LPCVOID lpMsgBody, DWORD dwMsgBodySize ) DECLSPEC_HIDDEN;
void DP_MSG_ErrorReceived( IDirectPlay2AImpl* This, WORD wCommandId,
- LPCVOID lpMsgBody, DWORD dwMsgBodySize );
-void DP_MSG_ToSelf( IDirectPlay2AImpl* This, DPID dpidSelf );
+ LPCVOID lpMsgBody, DWORD dwMsgBodySize ) DECLSPEC_HIDDEN;
+void DP_MSG_ToSelf( IDirectPlay2AImpl* This, DPID dpidSelf ) DECLSPEC_HIDDEN;
/* Timings -> 1000 ticks/sec */
#define DPMSG_WAIT_5_SECS 5000
*
* 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* NOTES
* o Linked list implementation for dplay/dplobby. Based off of the BSD
* elm - how to find the next element
* field - to be concatenated to rc to compare with fieldToCompare
* fieldToCompare - The value that we're comparing against
- * compare_cb - Callback to invoke to determine if comparision should continue.
+ * compare_cb - Callback to invoke to determine if comparison should continue.
* Callback must be defined with DPQ_DECL_COMPARECB.
* rc - Variable to put the return code. Same type as (head).lpQHFirst
*/
* elm - how to find the next element
* field - to be concatenated to rc to compare with fieldToCompare
* fieldToCompare - The value that we're comparing against
- * compare_cb - Callback to invoke to determine if comparision should continue.
+ * compare_cb - Callback to invoke to determine if comparison should continue.
* Callback must be defined with DPQ_DECL_COMPARECB.
* rc - Variable to put the return code. Same type as (head).lpQHFirst
*/
#define DPQ_DECL_DELETECB( name, type ) void name( type elem )
/* Prototype of a method which just performs a HeapFree on the elem */
-DPQ_DECL_DELETECB( cbDeleteElemFromHeap, LPVOID );
+DPQ_DECL_DELETECB( cbDeleteElemFromHeap, LPVOID ) DECLSPEC_HIDDEN;
#endif /* __WINE_DPLAYX_QUEUE_H */
*
* 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
//#include <string.h>
/* Forward declarations for this module helper methods */
HRESULT DPL_CreateCompoundAddress ( LPCDPCOMPOUNDADDRESSELEMENT lpElements, DWORD dwElementCount,
- LPVOID lpAddress, LPDWORD lpdwAddressSize, BOOL bAnsiInterface );
+ LPVOID lpAddress, LPDWORD lpdwAddressSize, BOOL bAnsiInterface )DECLSPEC_HIDDEN;
-HRESULT DPL_CreateAddress( REFGUID guidSP, REFGUID guidDataType, LPCVOID lpData, DWORD dwDataSize,
+static HRESULT DPL_CreateAddress( REFGUID guidSP, REFGUID guidDataType, LPCVOID lpData, DWORD dwDataSize,
LPVOID lpAddress, LPDWORD lpdwAddressSize, BOOL bAnsiInterface );
extern HRESULT DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback, LPCVOID lpAddress,
DWORD dwAddressSize, LPVOID lpContext );
-static HRESULT WINAPI DPL_ConnectEx( IDirectPlayLobbyAImpl* This,
- DWORD dwFlags, REFIID riid,
- LPVOID* lplpDP, IUnknown* pUnk );
+static HRESULT DPL_ConnectEx( IDirectPlayLobbyAImpl* This,
+ DWORD dwFlags, REFIID riid,
+ LPVOID* lplpDP, IUnknown* pUnk );
-BOOL DPL_CreateAndSetLobbyHandles( DWORD dwDestProcessId, HANDLE hDestProcess,
+static BOOL DPL_CreateAndSetLobbyHandles( DWORD dwDestProcessId, HANDLE hDestProcess,
LPHANDLE lphStart, LPHANDLE lphDeath,
LPHANDLE lphRead );
static BOOL DPL_CreateIUnknown( LPVOID lpDPL )
{
- IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)lpDPL;
+ IDirectPlayLobbyAImpl *This = lpDPL;
This->unk = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->unk) ) );
if ( This->unk == NULL )
}
InitializeCriticalSection( &This->unk->DPL_lock );
+ This->unk->DPL_lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDirectPlayLobbyAImpl*->DirectPlayLobbyIUnknownData*->DPL_lock");
return TRUE;
}
static BOOL DPL_DestroyIUnknown( LPVOID lpDPL )
{
- IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)lpDPL;
+ IDirectPlayLobbyAImpl *This = lpDPL;
+ This->unk->DPL_lock.DebugInfo->Spare[0] = 0;
DeleteCriticalSection( &This->unk->DPL_lock );
HeapFree( GetProcessHeap(), 0, This->unk );
static BOOL DPL_CreateLobby1( LPVOID lpDPL )
{
- IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)lpDPL;
+ IDirectPlayLobbyAImpl *This = lpDPL;
This->dpl = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->dpl) ) );
if ( This->dpl == NULL )
static BOOL DPL_DestroyLobby1( LPVOID lpDPL )
{
- IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)lpDPL;
+ IDirectPlayLobbyAImpl *This = lpDPL;
if( This->dpl->dwMsgThread )
{
static BOOL DPL_CreateLobby2( LPVOID lpDPL )
{
- IDirectPlayLobby2AImpl *This = (IDirectPlayLobby2AImpl *)lpDPL;
+ IDirectPlayLobby2AImpl *This = lpDPL;
This->dpl2 = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->dpl2) ) );
if ( This->dpl2 == NULL )
static BOOL DPL_DestroyLobby2( LPVOID lpDPL )
{
- IDirectPlayLobby2AImpl *This = (IDirectPlayLobby2AImpl *)lpDPL;
+ IDirectPlayLobby2AImpl *This = lpDPL;
HeapFree( GetProcessHeap(), 0, This->dpl2 );
static BOOL DPL_CreateLobby3( LPVOID lpDPL )
{
- IDirectPlayLobby3AImpl *This = (IDirectPlayLobby3AImpl *)lpDPL;
+ IDirectPlayLobby3AImpl *This = lpDPL;
This->dpl3 = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->dpl3) ) );
if ( This->dpl3 == NULL )
static BOOL DPL_DestroyLobby3( LPVOID lpDPL )
{
- IDirectPlayLobby3AImpl *This = (IDirectPlayLobby3AImpl *)lpDPL;
+ IDirectPlayLobby3AImpl *This = lpDPL;
HeapFree( GetProcessHeap(), 0, This->dpl3 );
* successfully for a third interface, a query for the first interface
* through the pointer for the third interface must succeed.
*/
-extern
HRESULT DPL_CreateInterface
( REFIID riid, LPVOID* ppvObj )
{
if( IsEqualGUID( &IID_IDirectPlayLobby, riid ) )
{
- IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)*ppvObj;
+ IDirectPlayLobbyWImpl *This = *ppvObj;
This->lpVtbl = &directPlayLobbyWVT;
}
else if( IsEqualGUID( &IID_IDirectPlayLobbyA, riid ) )
{
- IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)*ppvObj;
+ IDirectPlayLobbyAImpl *This = *ppvObj;
This->lpVtbl = &directPlayLobbyAVT;
}
else if( IsEqualGUID( &IID_IDirectPlayLobby2, riid ) )
{
- IDirectPlayLobby2WImpl *This = (IDirectPlayLobby2WImpl *)*ppvObj;
+ IDirectPlayLobby2WImpl *This = *ppvObj;
This->lpVtbl = &directPlayLobby2WVT;
}
else if( IsEqualGUID( &IID_IDirectPlayLobby2A, riid ) )
{
- IDirectPlayLobby2AImpl *This = (IDirectPlayLobby2AImpl *)*ppvObj;
+ IDirectPlayLobby2AImpl *This = *ppvObj;
This->lpVtbl = &directPlayLobby2AVT;
}
else if( IsEqualGUID( &IID_IDirectPlayLobby3, riid ) )
{
- IDirectPlayLobby3WImpl *This = (IDirectPlayLobby3WImpl *)*ppvObj;
+ IDirectPlayLobby3WImpl *This = *ppvObj;
This->lpVtbl = &directPlayLobby3WVT;
}
else if( IsEqualGUID( &IID_IDirectPlayLobby3A, riid ) )
{
- IDirectPlayLobby3AImpl *This = (IDirectPlayLobby3AImpl *)*ppvObj;
+ IDirectPlayLobby3AImpl *This = *ppvObj;
This->lpVtbl = &directPlayLobby3AVT;
}
else
if( IsEqualGUID( &IID_IDirectPlayLobby, riid ) )
{
- IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)*ppvObj;
+ IDirectPlayLobbyWImpl *This = *ppvObj;
This->lpVtbl = &directPlayLobbyWVT;
}
else if( IsEqualGUID( &IID_IDirectPlayLobbyA, riid ) )
{
- IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)*ppvObj;
+ IDirectPlayLobbyAImpl *This = *ppvObj;
This->lpVtbl = &directPlayLobbyAVT;
}
else if( IsEqualGUID( &IID_IDirectPlayLobby2, riid ) )
{
- IDirectPlayLobby2WImpl *This = (IDirectPlayLobby2WImpl *)*ppvObj;
+ IDirectPlayLobby2WImpl *This = *ppvObj;
This->lpVtbl = &directPlayLobby2WVT;
}
else if( IsEqualGUID( &IID_IDirectPlayLobby2A, riid ) )
{
- IDirectPlayLobby2AImpl *This = (IDirectPlayLobby2AImpl *)*ppvObj;
+ IDirectPlayLobby2AImpl *This = *ppvObj;
This->lpVtbl = &directPlayLobby2AVT;
}
else if( IsEqualGUID( &IID_IDirectPlayLobby3, riid ) )
{
- IDirectPlayLobby3WImpl *This = (IDirectPlayLobby3WImpl *)*ppvObj;
+ IDirectPlayLobby3WImpl *This = *ppvObj;
This->lpVtbl = &directPlayLobby3WVT;
}
else if( IsEqualGUID( &IID_IDirectPlayLobby3A, riid ) )
{
- IDirectPlayLobby3AImpl *This = (IDirectPlayLobby3AImpl *)*ppvObj;
+ IDirectPlayLobby3AImpl *This = *ppvObj;
This->lpVtbl = &directPlayLobby3AVT;
}
else
ulObjRefCount = InterlockedIncrement( &This->unk->ulObjRef );
ulInterfaceRefCount = InterlockedIncrement( &This->ulInterfaceRef );
- TRACE( "ref count incremented to %lu:%lu for %p\n",
+ TRACE( "ref count incremented to %u:%u for %p\n",
ulInterfaceRefCount, ulObjRefCount, This );
return ulObjRefCount;
ulObjRefCount = InterlockedDecrement( &This->unk->ulObjRef );
ulInterfaceRefCount = InterlockedDecrement( &This->ulInterfaceRef );
- TRACE( "ref count decremented to %lu:%lu for %p\n",
+ TRACE( "ref count decremented to %u:%u for %p\n",
ulInterfaceRefCount, ulObjRefCount, This );
/* Deallocate if this is the last reference to the object */
* Returns an IDirectPlay interface.
*
*/
-static HRESULT WINAPI DPL_ConnectEx
+static HRESULT DPL_ConnectEx
( IDirectPlayLobbyAImpl* This,
DWORD dwFlags,
REFIID riid,
DWORD dwConnSize = 0;
LPDPLCONNECTION lpConn;
- FIXME("(%p)->(0x%08lx,%p,%p): semi stub\n", This, dwFlags, lplpDP, pUnk );
+ FIXME("(%p)->(0x%08x,%p,%p): semi stub\n", This, dwFlags, lplpDP, pUnk );
if( pUnk )
{
lpAddress, lpdwAddressSize, FALSE );
}
-HRESULT DPL_CreateAddress(
+static HRESULT DPL_CreateAddress(
REFGUID guidSP,
REFGUID guidDataType,
LPCVOID lpData,
const DWORD dwNumAddElements = 2; /* Service Provide & address data type */
DPCOMPOUNDADDRESSELEMENT addressElements[ 2 /* dwNumAddElements */ ];
- TRACE( "(%p)->(%p,%p,0x%08lx,%p,%p,%d)\n", guidSP, guidDataType, lpData, dwDataSize,
+ TRACE( "(%p)->(%p,%p,0x%08x,%p,%p,%d)\n", guidSP, guidDataType, lpData, dwDataSize,
lpAddress, lpdwAddressSize, bAnsiInterface );
addressElements[ 0 ].guidDataType = DPAID_ServiceProvider;
{
IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
- TRACE("(%p)->(%p,%p,0x%08lx,%p)\n", This, lpEnumAddressCallback, lpAddress,
+ TRACE("(%p)->(%p,%p,0x%08x,%p)\n", This, lpEnumAddressCallback, lpAddress,
dwAddressSize, lpContext );
return DPL_EnumAddress( lpEnumAddressCallback, lpAddress, dwAddressSize, lpContext );
{
IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface;
- TRACE("(%p)->(%p,%p,0x%08lx,%p)\n", This, lpEnumAddressCallback, lpAddress,
+ TRACE("(%p)->(%p,%p,0x%08x,%p)\n", This, lpEnumAddressCallback, lpAddress,
dwAddressSize, lpContext );
return DPL_EnumAddress( lpEnumAddressCallback, lpAddress, dwAddressSize, lpContext );
}
-extern HRESULT DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback, LPCVOID lpAddress,
- DWORD dwAddressSize, LPVOID lpContext )
+HRESULT DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback, LPCVOID lpAddress,
+ DWORD dwAddressSize, LPVOID lpContext )
{
DWORD dwTotalSizeEnumerated = 0;
while ( dwTotalSizeEnumerated < dwAddressSize )
{
- const DPADDRESS* lpElements = (const DPADDRESS*)lpAddress;
+ const DPADDRESS* lpElements = lpAddress;
DWORD dwSizeThisEnumeration;
/* Invoke the enum method. If false is returned, stop enumeration */
if ( !lpEnumAddressCallback( &lpElements->guidDataType,
lpElements->dwDataSize,
- (BYTE*)lpElements + sizeof( DPADDRESS ),
+ (const BYTE *)lpElements + sizeof( DPADDRESS ),
lpContext ) )
{
break;
char subKeyName[51];
FILETIME filetime;
- TRACE(" (%p)->(%p,%p,%p,0x%08lx)\n", This, lpEnumAddressTypeCallback, guidSP, lpContext, dwFlags );
+ TRACE(" (%p)->(%p,%p,%p,0x%08x)\n", This, lpEnumAddressTypeCallback, guidSP, lpContext, dwFlags );
if( dwFlags != 0 )
{
return DPERR_INVALIDPARAMS;
}
- if( !lpEnumAddressTypeCallback || !*lpEnumAddressTypeCallback )
+ if( !lpEnumAddressTypeCallback )
{
return DPERR_INVALIDPARAMS;
}
{
IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface;
- FIXME("(%p)->(%p,%p,0x%08lx):stub\n", This, lpEnumLocalAppCallback, lpContext, dwFlags );
+ FIXME("(%p)->(%p,%p,0x%08x):stub\n", This, lpEnumLocalAppCallback, lpContext, dwFlags );
return DPERR_OUTOFMEMORY;
}
char subKeyName[51];
FILETIME filetime;
- TRACE("(%p)->(%p,%p,0x%08lx)\n", This, lpEnumLocalAppCallback, lpContext, dwFlags );
+ TRACE("(%p)->(%p,%p,0x%08x)\n", This, lpEnumLocalAppCallback, lpContext, dwFlags );
if( dwFlags != 0 )
{
return DPERR_INVALIDPARAMS;
}
- if( !lpEnumLocalAppCallback || !*lpEnumLocalAppCallback )
+ if( !lpEnumLocalAppCallback )
{
return DPERR_INVALIDPARAMS;
}
IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
HRESULT hr;
- TRACE("(%p)->(0x%08lx,%p,%p)\n", This, dwAppID, lpData, lpdwDataSize );
+ TRACE("(%p)->(0x%08x,%p,%p)\n", This, dwAppID, lpData, lpdwDataSize );
EnterCriticalSection( &This->unk->DPL_lock );
IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface;
HRESULT hr;
- TRACE("(%p)->(0x%08lx,%p,%p)\n", This, dwAppID, lpData, lpdwDataSize );
+ TRACE("(%p)->(0x%08x,%p,%p)\n", This, dwAppID, lpData, lpdwDataSize );
EnterCriticalSection( &This->unk->DPL_lock );
LPDWORD lpdwDataSize )
{
IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
- FIXME(":stub %p %08lx %08lx %p %p %p\n", This, dwFlags, dwAppID, lpdwMessageFlags, lpData,
+ FIXME(":stub %p %08x %08x %p %p %p\n", This, dwFlags, dwAppID, lpdwMessageFlags, lpData,
lpdwDataSize );
return DPERR_OUTOFMEMORY;
}
LPDWORD lpdwDataSize )
{
IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface;
- FIXME(":stub %p %08lx %08lx %p %p %p\n", This, dwFlags, dwAppID, lpdwMessageFlags, lpData,
+ FIXME(":stub %p %08x %08x %p %p %p\n", This, dwFlags, dwAppID, lpdwMessageFlags, lpData,
lpdwDataSize );
return DPERR_OUTOFMEMORY;
}
return TRUE; /* Keep enumerating, haven't found the application yet */
}
-BOOL DPL_CreateAndSetLobbyHandles( DWORD dwDestProcessId, HANDLE hDestProcess,
+static BOOL DPL_CreateAndSetLobbyHandles( DWORD dwDestProcessId, HANDLE hDestProcess,
LPHANDLE lphStart, LPHANDLE lphDeath,
LPHANDLE lphRead )
{
DWORD dwSuspendCount;
HANDLE hStart, hDeath, hSettingRead;
- TRACE( "(%p)->(0x%08lx,%p,%p,%p)\n",
+ TRACE( "(%p)->(0x%08x,%p,%p,%p)\n",
This, dwFlags, lpdwAppID, lpConn, hReceiveEvent );
if( dwFlags != 0 )
/* Our callback function will fill up the enumData structure with all the information
required to start a new process */
IDirectPlayLobby_EnumLocalApplications( iface, RunApplicationA_EnumLocalApplications,
- (LPVOID)(&enumData), 0 );
+ (&enumData), 0 );
/* First the application name */
strcpy( temp, enumData.lpszPath );
/* Reserve this global application id! */
if( !DPLAYX_CreateLobbyApplication( newProcessInfo.dwProcessId ) )
{
- ERR( "Unable to create global application data for 0x%08lx\n",
+ ERR( "Unable to create global application data for 0x%08x\n",
newProcessInfo.dwProcessId );
}
/* Unsuspend the process - should return the prev suspension count */
if( ( dwSuspendCount = ResumeThread( newProcessInfo.hThread ) ) != 1 )
{
- ERR( "ResumeThread failed with 0x%08lx\n", dwSuspendCount );
+ ERR( "ResumeThread failed with 0x%08x\n", dwSuspendCount );
}
return DP_OK;
HANDLE hReceiveEvent )
{
IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface;
- FIXME( "(%p)->(0x%08lx,%p,%p,%p):stub\n", This, dwFlags, lpdwAppID, lpConn, (void *)hReceiveEvent );
+ FIXME( "(%p)->(0x%08x,%p,%p,%p):stub\n", This, dwFlags, lpdwAppID, lpConn, hReceiveEvent );
return DPERR_OUTOFMEMORY;
}
IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface;
HRESULT hr;
- TRACE("(%p)->(0x%08lx,0x%08lx,%p)\n", This, dwFlags, dwAppID, lpConn );
+ TRACE("(%p)->(0x%08x,0x%08x,%p)\n", This, dwFlags, dwAppID, lpConn );
EnterCriticalSection( &This->unk->DPL_lock );
hr = DPLAYX_SetConnectionSettingsW( dwFlags, dwAppID, lpConn );
- /* FIXME: Don't think that this is supposed to fail, but the docuementation
+ /* FIXME: Don't think that this is supposed to fail, but the documentation
is somewhat sketchy. I'll try creating a lobby application
for this... */
if( hr == DPERR_NOTLOBBIED )
IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
HRESULT hr;
- TRACE("(%p)->(0x%08lx,0x%08lx,%p)\n", This, dwFlags, dwAppID, lpConn );
+ TRACE("(%p)->(0x%08x,0x%08x,%p)\n", This, dwFlags, dwAppID, lpConn );
EnterCriticalSection( &This->unk->DPL_lock );
hr = DPLAYX_SetConnectionSettingsA( dwFlags, dwAppID, lpConn );
- /* FIXME: Don't think that this is supposed to fail, but the docuementation
+ /* FIXME: Don't think that this is supposed to fail, but the documentation
is somewhat sketchy. I'll try creating a lobby application
for this... */
if( hr == DPERR_NOTLOBBIED )
DWORD dwElements;
LPCDPCOMPOUNDADDRESSELEMENT lpOrigElements = lpElements;
- TRACE("(%p,0x%08lx,%p,%p)\n", lpElements, dwElementCount, lpAddress, lpdwAddressSize );
+ TRACE("(%p,0x%08x,%p,%p)\n", lpElements, dwElementCount, lpAddress, lpdwAddressSize );
/* Parameter check */
if( ( lpElements == NULL ) ||
/* Add the total size chunk */
{
- LPDPADDRESS lpdpAddress = (LPDPADDRESS)lpAddress;
+ LPDPADDRESS lpdpAddress = lpAddress;
- CopyMemory( &lpdpAddress->guidDataType, &DPAID_TotalSize, sizeof( GUID ) );
+ lpdpAddress->guidDataType = DPAID_TotalSize;
lpdpAddress->dwDataSize = sizeof( DWORD );
lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
( IsEqualGUID( &lpElements->guidDataType, &DPAID_LobbyProvider ) )
)
{
- LPDPADDRESS lpdpAddress = (LPDPADDRESS)lpAddress;
+ LPDPADDRESS lpdpAddress = lpAddress;
- CopyMemory( &lpdpAddress->guidDataType, &lpElements->guidDataType,
- sizeof( GUID ) );
+ lpdpAddress->guidDataType = lpElements->guidDataType;
lpdpAddress->dwDataSize = sizeof( GUID );
lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
( IsEqualGUID( &lpElements->guidDataType, &DPAID_INet ) )
)
{
- LPDPADDRESS lpdpAddress = (LPDPADDRESS)lpAddress;
+ LPDPADDRESS lpdpAddress = lpAddress;
- CopyMemory( &lpdpAddress->guidDataType, &lpElements->guidDataType,
- sizeof( GUID ) );
+ lpdpAddress->guidDataType = lpElements->guidDataType;
lpdpAddress->dwDataSize = lpElements->dwDataSize;
lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
- lstrcpynA( (LPSTR)lpAddress,
- (LPCSTR)lpElements->lpData,
- lpElements->dwDataSize );
+ lstrcpynA( lpAddress, lpElements->lpData, lpElements->dwDataSize );
lpAddress = (char *) lpAddress + lpElements->dwDataSize;
}
else if ( ( IsEqualGUID( &lpElements->guidDataType, &DPAID_PhoneW ) ) ||
( IsEqualGUID( &lpElements->guidDataType, &DPAID_INetW ) )
)
{
- LPDPADDRESS lpdpAddress = (LPDPADDRESS)lpAddress;
+ LPDPADDRESS lpdpAddress = lpAddress;
- CopyMemory( &lpdpAddress->guidDataType, &lpElements->guidDataType,
- sizeof( GUID ) );
+ lpdpAddress->guidDataType = lpElements->guidDataType;
lpdpAddress->dwDataSize = lpElements->dwDataSize;
lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
- lstrcpynW( (LPWSTR)lpAddress,
- (LPCWSTR)lpElements->lpData,
- lpElements->dwDataSize );
+ lstrcpynW( lpAddress, lpElements->lpData, lpElements->dwDataSize );
lpAddress = (char *) lpAddress + lpElements->dwDataSize * sizeof( WCHAR );
}
else if ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INetPort ) )
{
- LPDPADDRESS lpdpAddress = (LPDPADDRESS)lpAddress;
+ LPDPADDRESS lpdpAddress = lpAddress;
- CopyMemory( &lpdpAddress->guidDataType, &lpElements->guidDataType,
- sizeof( GUID ) );
+ lpdpAddress->guidDataType = lpElements->guidDataType;
lpdpAddress->dwDataSize = lpElements->dwDataSize;
lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
}
else if ( IsEqualGUID( &lpElements->guidDataType, &DPAID_ComPort ) )
{
- LPDPADDRESS lpdpAddress = (LPDPADDRESS)lpAddress;
+ LPDPADDRESS lpdpAddress = lpAddress;
- CopyMemory( &lpdpAddress->guidDataType, &lpElements->guidDataType,
- sizeof( GUID ) );
+ lpdpAddress->guidDataType = lpElements->guidDataType;
lpdpAddress->dwDataSize = lpElements->dwDataSize;
lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
( LPDIRECTPLAYLOBBY3 iface, DWORD dwFlags )
{
HRESULT hr = DP_OK;
- BOOL bStartWait = (dwFlags & DPLWAIT_CANCEL) ? FALSE : TRUE;
+ BOOL bStartWait = !(dwFlags & DPLWAIT_CANCEL);
- TRACE( "(%p)->(0x%08lx)\n", iface, dwFlags );
+ TRACE( "(%p)->(0x%08x)\n", iface, dwFlags );
if( DPLAYX_WaitForConnectionSettings( bStartWait ) )
{
( LPDIRECTPLAYLOBBY3A iface, DWORD dwFlags )
{
HRESULT hr = DP_OK;
- BOOL bStartWait = (dwFlags & DPLWAIT_CANCEL) ? FALSE : TRUE;
+ BOOL bStartWait = !(dwFlags & DPLWAIT_CANCEL);
- TRACE( "(%p)->(0x%08lx)\n", iface, dwFlags );
+ TRACE( "(%p)->(0x%08x)\n", iface, dwFlags );
if( DPLAYX_WaitForConnectionSettings( bStartWait ) )
{
/* Note: Hack so we can reuse the old functions without compiler warnings */
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
-# define XCAST(fun) (typeof(directPlayLobby2AVT.fun))
+# define XCAST(fun) (typeof(directPlayLobby2WVT.fun))
#else
# define XCAST(fun) (void*)
#endif
LPVOID lpData,
DWORD dwDataSize )
{
- TRACE("lpGUIDDSP=%p lplpDPL=%p lpUnk=%p lpData=%p dwDataSize=%08lx\n",
+ TRACE("lpGUIDDSP=%p lplpDPL=%p lpUnk=%p lpData=%p dwDataSize=%08x\n",
lpGUIDDSP,lplpDPL,lpUnk,lpData,dwDataSize);
/* Parameter Check: lpGUIDSP, lpUnk & lpData must be NULL. dwDataSize must
LPVOID lpData,
DWORD dwDataSize )
{
- TRACE("lpGUIDDSP=%p lplpDPL=%p lpUnk=%p lpData=%p dwDataSize=%08lx\n",
+ TRACE("lpGUIDDSP=%p lplpDPL=%p lpUnk=%p lpData=%p dwDataSize=%08x\n",
lpGUIDDSP,lplpDPL,lpUnk,lpData,dwDataSize);
/* Parameter Check: lpGUIDSP, lpUnk & lpData must be NULL. dwDataSize must
*
* 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
//#include "winerror.h"
if( IsEqualGUID( &IID_IDPLobbySP, riid ) )
{
- IDPLobbySPImpl *This = (IDPLobbySPImpl *)*ppvObj;
+ IDPLobbySPImpl *This = *ppvObj;
This->lpVtbl = &dpLobbySPVT;
}
else
static BOOL DPLSP_CreateIUnknown( LPVOID lpSP )
{
- IDPLobbySPImpl *This = (IDPLobbySPImpl *)lpSP;
+ IDPLobbySPImpl *This = lpSP;
This->unk = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->unk) ) );
}
InitializeCriticalSection( &This->unk->DPLSP_lock );
+ This->unk->DPLSP_lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDPLobbySPImpl*->DPLobbySPIUnknownData*->DPLSP_lock");
return TRUE;
}
static BOOL DPLSP_DestroyIUnknown( LPVOID lpSP )
{
- IDPLobbySPImpl *This = (IDPLobbySPImpl *)lpSP;
+ IDPLobbySPImpl *This = lpSP;
+ This->unk->DPLSP_lock.DebugInfo->Spare[0] = 0;
DeleteCriticalSection( &This->unk->DPLSP_lock );
HeapFree( GetProcessHeap(), 0, This->unk );
static BOOL DPLSP_CreateDPLobbySP( LPVOID lpSP, IDirectPlay2Impl* dp )
{
- IDPLobbySPImpl *This = (IDPLobbySPImpl *)lpSP;
+ IDPLobbySPImpl *This = lpSP;
This->sp = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->sp) ) );
static BOOL DPLSP_DestroyDPLobbySP( LPVOID lpSP )
{
- IDPLobbySPImpl *This = (IDPLobbySPImpl *)lpSP;
+ IDPLobbySPImpl *This = lpSP;
HeapFree( GetProcessHeap(), 0, This->sp );
if( IsEqualGUID( &IID_IDPLobbySP, riid ) )
{
- IDPLobbySPImpl *This = (IDPLobbySPImpl *)*ppvObj;
+ IDPLobbySPImpl *This = *ppvObj;
This->lpVtbl = &dpLobbySPVT;
}
else
ulObjRefCount = InterlockedIncrement( &This->unk->ulObjRef );
ulInterfaceRefCount = InterlockedIncrement( &This->ulInterfaceRef );
- TRACE( "ref count incremented to %lu:%lu for %p\n",
+ TRACE( "ref count incremented to %u:%u for %p\n",
ulInterfaceRefCount, ulObjRefCount, This );
return ulObjRefCount;
ulObjRefCount = InterlockedDecrement( &This->unk->ulObjRef );
ulInterfaceRefCount = InterlockedDecrement( &This->ulInterfaceRef );
- TRACE( "ref count decremented to %lu:%lu for %p\n",
+ TRACE( "ref count decremented to %u:%u for %p\n",
ulInterfaceRefCount, ulObjRefCount, This );
/* Deallocate if this is the last reference to the object */
*
* 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_LOBBY_SP_H
LPDPNAME lpName;
} SPDATA_ADDREMOTEPLAYERTOGROUP, *LPSPDATA_ADDREMOTEPLAYERTOGROUP;
-typedef struct SPDATA_BUILDPARENTALHEIRARCHY
+typedef struct SPDATA_BUILDPARENTALHIERARCHY
{
DWORD dwSize;
LPDPLOBBYSP lpISP;
DWORD dwGroupID;
DWORD dwMessage;
DWORD dwParentID;
-} SPDATA_BUILDPARENTALHEIRARCHY, *LPSPDATA_BUILDPARENTALHEIRARCHY;
+} SPDATA_BUILDPARENTALHIERARCHY, *LPSPDATA_BUILDPARENTALHIERARCHY;
typedef struct SPDATA_CLOSE
{
/* Prototypes for callbacks returned by DPLSPInit */
typedef HRESULT (WINAPI *LPSP_ADDGROUPTOGROUP)(LPSPDATA_ADDGROUPTOGROUP);
typedef HRESULT (WINAPI *LPSP_ADDPLAYERTOGROUP)(LPSPDATA_ADDPLAYERTOGROUP);
-typedef HRESULT (WINAPI *LPSP_BUILDPARENTALHEIRARCHY)(LPSPDATA_BUILDPARENTALHEIRARCHY);
+typedef HRESULT (WINAPI *LPSP_BUILDPARENTALHIERARCHY)(LPSPDATA_BUILDPARENTALHIERARCHY);
typedef HRESULT (WINAPI *LPSP_CLOSE)(LPSPDATA_CLOSE);
typedef HRESULT (WINAPI *LPSP_CREATEGROUP)(LPSPDATA_CREATEGROUP);
typedef HRESULT (WINAPI *LPSP_CREATEGROUPINGROUP)(LPSPDATA_CREATEGROUPINGROUP);
DWORD dwFlags;
LPSP_ADDGROUPTOGROUP AddGroupToGroup;
LPSP_ADDPLAYERTOGROUP AddPlayerToGroup;
- LPSP_BUILDPARENTALHEIRARCHY BuildParentalHeirarchy;
+ LPSP_BUILDPARENTALHIERARCHY BuildParentalHierarchy;
LPSP_CLOSE Close;
LPSP_CREATEGROUP CreateGroup;
LPSP_CREATEGROUPINGROUP CreateGroupInGroup;
} SPDATA_INIT, *LPSPDATA_INIT;
typedef HRESULT (WINAPI *LPSP_INIT)(LPSPDATA_INIT);
-HRESULT WINAPI DPLSPInit(LPSPDATA_INIT);
+HRESULT WINAPI DPLSPInit(LPSPDATA_INIT) DECLSPEC_HIDDEN;
/* Define the COM interface */
#define INTERFACE IDPLobbySP
/* This variable is exported from the DLL at ordinal 6 to be accessed by the
* SP directly. This is the same variable that the DP SP will use.
*/
-extern DWORD gdwDPlaySPRefCount;
+extern DWORD gdwDPlaySPRefCount DECLSPEC_HIDDEN;
#endif
*
* 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* NOTE: Methods with the NS_ prefix are name server methods */
typedef struct NSCache NSCache, *lpNSCache;
/* Function prototypes */
-DPQ_DECL_DELETECB( cbDeleteNSNodeFromHeap, lpNSCacheData );
+static DPQ_DECL_DELETECB( cbDeleteNSNodeFromHeap, lpNSCacheData );
/* Name Server functions
* ---------------------
*/
void NS_SetLocalComputerAsNameServer( LPCDPSESSIONDESC2 lpsd, LPVOID lpNSInfo )
{
-#if 0
- /* FIXME: Remove this method? */
- DPLAYX_SetLocalSession( lpsd );
-#endif
lpNSCache lpCache = (lpNSCache)lpNSInfo;
lpCache->bNsIsLocal = TRUE;
}
-void NS_SetRemoteComputerAsNameServer( LPCDPSESSIONDESC2 lpsd, LPVOID lpNSInfo )
-{
- lpNSCache lpCache = (lpNSCache)lpNSInfo;
-
- lpCache->bNsIsLocal = FALSE;
-}
-
static DPQ_DECL_COMPARECB( cbUglyPig, GUID )
{
return IsEqualGUID( elem1, elem2 );
}
/* Store the given NS remote address for future reference */
-/* FIXME: LPDPMSG_ENUMSESSIONSREPLY should be const */
-void NS_AddRemoteComputerAsNameServer( LPCVOID lpcNSAddrHdr,
- DWORD dwHdrSize,
- LPDPMSG_ENUMSESSIONSREPLY lpMsg,
- LPVOID lpNSInfo )
+void NS_AddRemoteComputerAsNameServer( LPCVOID lpcNSAddrHdr,
+ DWORD dwHdrSize,
+ LPCDPMSG_ENUMSESSIONSREPLY lpcMsg,
+ LPVOID lpNSInfo )
{
DWORD len;
lpNSCache lpCache = (lpNSCache)lpNSInfo;
lpNSCacheData lpCacheNode;
- TRACE( "%p, %p, %p\n", lpcNSAddrHdr, lpMsg, lpNSInfo );
+ TRACE( "%p, %p, %p\n", lpcNSAddrHdr, lpcMsg, lpNSInfo );
/* See if we can find this session. If we can, remove it as it's a dup */
DPQ_REMOVE_ENTRY_CB( lpCache->first, next, data->guidInstance, cbUglyPig,
- lpMsg->sd.guidInstance, lpCacheNode );
+ lpcMsg->sd.guidInstance, lpCacheNode );
if( lpCacheNode != NULL )
{
if( lpCacheNode->data == NULL )
{
ERR( "no memory for SESSIONDESC2\n" );
+ HeapFree( GetProcessHeap(), 0, lpCacheNode );
return;
}
- CopyMemory( lpCacheNode->data, &lpMsg->sd, sizeof( *lpCacheNode->data ) );
- len = WideCharToMultiByte( CP_ACP, 0, (LPWSTR)(lpMsg+1), -1, NULL, 0, NULL, NULL );
- if ((lpCacheNode->data->lpszSessionNameA = HeapAlloc( GetProcessHeap(), 0, len )))
+ *lpCacheNode->data = lpcMsg->sd;
+ len = WideCharToMultiByte( CP_ACP, 0, (LPCWSTR)(lpcMsg+1), -1, NULL, 0, NULL, NULL );
+ if ((lpCacheNode->data->u1.lpszSessionNameA = HeapAlloc( GetProcessHeap(), 0, len )))
{
- WideCharToMultiByte( CP_ACP, 0, (LPWSTR)(lpMsg+1), -1,
- lpCacheNode->data->lpszSessionNameA, len, NULL, NULL );
+ WideCharToMultiByte( CP_ACP, 0, (LPCWSTR)(lpcMsg+1), -1,
+ lpCacheNode->data->u1.lpszSessionNameA, len, NULL, NULL );
}
lpCacheNode->dwTime = timeGetTime();
/* Ok. Cheat and don't search for the correct stuff just take the first.
* FIXME: In the future how are we to know what is _THE_ enum we used?
* This is going to have to go into dplay somehow. Perhaps it
- * comes back with app server id for the join command! Oh...that
+ * comes back with app server id for the join command! Oh... that
* must be it. That would make this method obsolete once that's
* in place.
*/
/* Get the magic number associated with the Name Server */
DWORD NS_GetNsMagic( LPVOID lpNSInfo )
{
- LPDWORD lpHdrInfo = (LPDWORD)NS_GetNSAddr( lpNSInfo );
+ LPDWORD lpHdrInfo = NS_GetNSAddr( lpNSInfo );
return lpHdrInfo[1];
}
-/* Get the magic number associated with the non NS end */
-DWORD NS_GetOtherMagic( LPVOID lpNSInfo )
-{
- lpNSCache lpCache = (lpNSCache)lpNSInfo;
-
- return ((LPDWORD)lpCache->lpLocalAddrHdr)[1];
-}
-
void NS_SetLocalAddr( LPVOID lpNSInfo, LPCVOID lpHdr, DWORD dwHdrSize )
{
lpNSCache lpCache = (lpNSCache)lpNSInfo;
*/
HRESULT NS_SendSessionRequestBroadcast( LPCGUID lpcGuid,
DWORD dwFlags,
- LPSPINITDATA lpSpData )
+ const SPINITDATA *lpSpData )
{
DPSP_ENUMSESSIONSDATA data;
data.lpMessage = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
data.dwMessageSize );
data.lpISP = lpSpData->lpISP;
- data.bReturnStatus = (dwFlags & DPENUMSESSIONS_RETURNSTATUS) ? TRUE : FALSE;
+ data.bReturnStatus = (dwFlags & DPENUMSESSIONS_RETURNSTATUS) != 0;
lpMsg = (LPDPMSG_ENUMSESSIONSREQUEST)(((BYTE*)data.lpMessage)+lpSpData->dwSPHeaderSize);
lpMsg->dwPasswordSize = 0; /* FIXME: If enumerating passwords..? */
lpMsg->dwFlags = dwFlags;
- CopyMemory( &lpMsg->guidApplication, lpcGuid, sizeof( *lpcGuid ) );
+ lpMsg->guidApplication = *lpcGuid;
return (lpSpData->lpCB->EnumSessions)( &data );
}
/* Delete a name server node which has been allocated on the heap */
-DPQ_DECL_DELETECB( cbDeleteNSNodeFromHeap, lpNSCacheData )
+static DPQ_DECL_DELETECB( cbDeleteNSNodeFromHeap, lpNSCacheData )
{
/* NOTE: This proc doesn't deal with the walking pointer */
DWORD dwVariableSize;
DWORD dwVariableLen;
/* LPCDPMSG_ENUMSESSIONSREQUEST msg = (LPDPMSG_ENUMSESSIONSREQUEST)lpcMsg; */
- BOOL bAnsi = TRUE; /* FIXME: This needs to be in the DPLAY interface */
-
- FIXME( ": few fixed + need to check request for response\n" );
- if (bAnsi)
- {
- dwVariableLen = MultiByteToWideChar( CP_ACP, 0,
- lpDP->dp2->lpSessionDesc->lpszSessionNameA,
- -1, NULL, 0 );
- }
- else
- {
- dwVariableLen = strlenW( lpDP->dp2->lpSessionDesc->lpszSessionName ) + 1;
- }
+ /* FIXME: Should handle ANSI or WIDECHAR input. Currently just ANSI input */
+ FIXME( ": few fixed + need to check request for response, might need UNICODE input ability.\n" );
+ dwVariableLen = MultiByteToWideChar( CP_ACP, 0,
+ lpDP->dp2->lpSessionDesc->u1.lpszSessionNameA,
+ -1, NULL, 0 );
dwVariableSize = dwVariableLen * sizeof( WCHAR );
*lpdwReplySize = lpDP->dp2->spData.dwSPHeaderSize +
rmsg->envelope.wVersion = DPMSGVER_DP6;
CopyMemory( &rmsg->sd, lpDP->dp2->lpSessionDesc,
- sizeof( lpDP->dp2->lpSessionDesc->dwSize ) );
+ lpDP->dp2->lpSessionDesc->dwSize );
rmsg->dwUnknown = 0x0000005c;
- if( bAnsi )
- {
- MultiByteToWideChar( CP_ACP, 0, lpDP->dp2->lpSessionDesc->lpszSessionNameA, -1,
- (LPWSTR)(rmsg+1), dwVariableLen );
- }
- else
- {
- strcpyW( (LPWSTR)(rmsg+1), lpDP->dp2->lpSessionDesc->lpszSessionName );
- }
+ MultiByteToWideChar( CP_ACP, 0, lpDP->dp2->lpSessionDesc->u1.lpszSessionNameA, -1,
+ (LPWSTR)(rmsg+1), dwVariableLen );
}
*
* 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_DPLAYX_NAMESERVER
#include "dplayx_messages.h"
//#include "dplay_global.h"
-void NS_SetLocalComputerAsNameServer( LPCDPSESSIONDESC2 lpsd, LPVOID lpNSInfo );
-void NS_SetRemoteComputerAsNameServer( LPCDPSESSIONDESC2 lpsd, LPVOID lpNSInfo );
+void NS_SetLocalComputerAsNameServer( LPCDPSESSIONDESC2 lpsd, LPVOID lpNSInfo ) DECLSPEC_HIDDEN;
void NS_AddRemoteComputerAsNameServer( LPCVOID lpNSAddrHdr,
DWORD dwHdrSize,
- LPDPMSG_ENUMSESSIONSREPLY lpMsg,
- LPVOID lpNSInfo );
-LPVOID NS_GetNSAddr( LPVOID lpNSInfo );
-DWORD NS_GetNsMagic( LPVOID lpNSInfo );
-DWORD NS_GetOtherMagic( LPVOID lpNSInfo );
-void NS_SetLocalAddr( LPVOID lpNSInfo, LPCVOID lpHdr, DWORD dwHdrSize );
+ LPCDPMSG_ENUMSESSIONSREPLY lpcMsg,
+ LPVOID lpNSInfo ) DECLSPEC_HIDDEN;
+LPVOID NS_GetNSAddr( LPVOID lpNSInfo ) DECLSPEC_HIDDEN;
+DWORD NS_GetNsMagic( LPVOID lpNSInfo ) DECLSPEC_HIDDEN;
+void NS_SetLocalAddr( LPVOID lpNSInfo, LPCVOID lpHdr, DWORD dwHdrSize ) DECLSPEC_HIDDEN;
void NS_ReplyToEnumSessionsRequest( LPCVOID lpcMsg,
LPVOID* lplpReplyData,
LPDWORD lpdwReplySize,
- IDirectPlay2Impl* lpDP );
+ IDirectPlay2Impl* lpDP ) DECLSPEC_HIDDEN;
HRESULT NS_SendSessionRequestBroadcast( LPCGUID lpcGuid,
DWORD dwFlags,
- LPSPINITDATA lpSpData );
+ const SPINITDATA *lpSpData ) DECLSPEC_HIDDEN;
-BOOL NS_InitializeSessionCache( LPVOID* lplpNSInfo );
-void NS_DeleteSessionCache( LPVOID lpNSInfo );
-void NS_InvalidateSessionCache( LPVOID lpNSInfo );
+BOOL NS_InitializeSessionCache( LPVOID* lplpNSInfo ) DECLSPEC_HIDDEN;
+void NS_DeleteSessionCache( LPVOID lpNSInfo ) DECLSPEC_HIDDEN;
+void NS_InvalidateSessionCache( LPVOID lpNSInfo ) DECLSPEC_HIDDEN;
-void NS_ResetSessionEnumeration( LPVOID lpNSInfo );
-LPDPSESSIONDESC2 NS_WalkSessions( LPVOID lpNSInfo );
-void NS_PruneSessionCache( LPVOID lpNSInfo );
+void NS_ResetSessionEnumeration( LPVOID lpNSInfo ) DECLSPEC_HIDDEN;
+LPDPSESSIONDESC2 NS_WalkSessions( LPVOID lpNSInfo ) DECLSPEC_HIDDEN;
+void NS_PruneSessionCache( LPVOID lpNSInfo ) DECLSPEC_HIDDEN;
#endif /* __WINE_DPLAYX_NAMESERVER */
+++ /dev/null
-/*
- * self-registerable dll functions for dplayx.dll
- *
- * Copyright (C) 2003 John K. Hohm
- *
- * 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
- */
-
-#define WIN32_NO_STATUS
-#define _INC_WINDOWS
-#define COM_NO_WINDOWS_H
-
-#include <stdarg.h>
-//#include <string.h>
-
-#include <windef.h>
-#include <winbase.h>
-//#include "winuser.h"
-#include <winreg.h>
-//#include "winerror.h"
-
-//#include "dplay.h"
-#include <dplobby.h>
-
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(dplayx);
-
-/*
- * Near the bottom of this file are the exported DllRegisterServer and
- * DllUnregisterServer, which make all this worthwhile.
- */
-
-/***********************************************************************
- * interface for self-registering
- */
-struct regsvr_interface
-{
- IID const *iid; /* NULL for end of list */
- LPCSTR name; /* can be NULL to omit */
- IID const *base_iid; /* can be NULL to omit */
- int num_methods; /* can be <0 to omit */
- CLSID const *ps_clsid; /* can be NULL to omit */
- CLSID const *ps_clsid32; /* can be NULL to omit */
-};
-
-static HRESULT register_interfaces(struct regsvr_interface const *list);
-static HRESULT unregister_interfaces(struct regsvr_interface const *list);
-
-struct regsvr_coclass
-{
- CLSID const *clsid; /* NULL for end of list */
- LPCSTR name; /* can be NULL to omit */
- LPCSTR ips; /* can be NULL to omit */
- LPCSTR ips32; /* can be NULL to omit */
- LPCSTR ips32_tmodel; /* can be NULL to omit */
- LPCSTR progid; /* can be NULL to omit */
- LPCSTR viprogid; /* can be NULL to omit */
- LPCSTR progid_extra; /* can be NULL to omit */
-};
-
-static HRESULT register_coclasses(struct regsvr_coclass const *list);
-static HRESULT unregister_coclasses(struct regsvr_coclass const *list);
-
-/***********************************************************************
- * static string constants
- */
-static WCHAR const interface_keyname[10] = {
- 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', 'e', 0 };
-static WCHAR const base_ifa_keyname[14] = {
- 'B', 'a', 's', 'e', 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c',
- 'e', 0 };
-static WCHAR const num_methods_keyname[11] = {
- 'N', 'u', 'm', 'M', 'e', 't', 'h', 'o', 'd', 's', 0 };
-static WCHAR const ps_clsid_keyname[15] = {
- 'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
- 'i', 'd', 0 };
-static WCHAR const ps_clsid32_keyname[17] = {
- 'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
- 'i', 'd', '3', '2', 0 };
-static WCHAR const clsid_keyname[6] = {
- 'C', 'L', 'S', 'I', 'D', 0 };
-static WCHAR const curver_keyname[7] = {
- 'C', 'u', 'r', 'V', 'e', 'r', 0 };
-static WCHAR const ips_keyname[13] = {
- 'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
- 0 };
-static WCHAR const ips32_keyname[15] = {
- 'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
- '3', '2', 0 };
-static WCHAR const progid_keyname[7] = {
- 'P', 'r', 'o', 'g', 'I', 'D', 0 };
-static WCHAR const viprogid_keyname[25] = {
- 'V', 'e', 'r', 's', 'i', 'o', 'n', 'I', 'n', 'd', 'e', 'p',
- 'e', 'n', 'd', 'e', 'n', 't', 'P', 'r', 'o', 'g', 'I', 'D',
- 0 };
-static char const tmodel_valuename[] = "ThreadingModel";
-
-/***********************************************************************
- * static helper functions
- */
-static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid);
-static LONG register_key_defvalueW(HKEY base, WCHAR const *name,
- WCHAR const *value);
-static LONG register_key_defvalueA(HKEY base, WCHAR const *name,
- char const *value);
-static LONG register_progid(WCHAR const *clsid,
- char const *progid, char const *curver_progid,
- char const *name, char const *extra);
-static LONG recursive_delete_key(HKEY key);
-static LONG recursive_delete_keyA(HKEY base, char const *name);
-static LONG recursive_delete_keyW(HKEY base, WCHAR const *name);
-
-/***********************************************************************
- * register_interfaces
- */
-static HRESULT register_interfaces(struct regsvr_interface const *list)
-{
- LONG res = ERROR_SUCCESS;
- HKEY interface_key;
-
- res = RegCreateKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, NULL, 0,
- KEY_READ | KEY_WRITE, NULL, &interface_key, NULL);
- if (res != ERROR_SUCCESS) goto error_return;
-
- for (; res == ERROR_SUCCESS && list->iid; ++list) {
- WCHAR buf[39];
- HKEY iid_key;
-
- StringFromGUID2(list->iid, buf, 39);
- res = RegCreateKeyExW(interface_key, buf, 0, NULL, 0,
- KEY_READ | KEY_WRITE, NULL, &iid_key, NULL);
- if (res != ERROR_SUCCESS) goto error_close_interface_key;
-
- if (list->name) {
- res = RegSetValueExA(iid_key, NULL, 0, REG_SZ,
- (CONST BYTE*)(list->name),
- strlen(list->name) + 1);
- if (res != ERROR_SUCCESS) goto error_close_iid_key;
- }
-
- if (list->base_iid) {
- register_key_guid(iid_key, base_ifa_keyname, list->base_iid);
- if (res != ERROR_SUCCESS) goto error_close_iid_key;
- }
-
- if (0 <= list->num_methods) {
- static WCHAR const fmt[3] = { '%', 'd', 0 };
- HKEY key;
-
- res = RegCreateKeyExW(iid_key, num_methods_keyname, 0, NULL, 0,
- KEY_READ | KEY_WRITE, NULL, &key, NULL);
- if (res != ERROR_SUCCESS) goto error_close_iid_key;
-
- wsprintfW(buf, fmt, list->num_methods);
- res = RegSetValueExW(key, NULL, 0, REG_SZ,
- (CONST BYTE*)buf,
- (lstrlenW(buf) + 1) * sizeof(WCHAR));
- RegCloseKey(key);
-
- if (res != ERROR_SUCCESS) goto error_close_iid_key;
- }
-
- if (list->ps_clsid) {
- register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid);
- if (res != ERROR_SUCCESS) goto error_close_iid_key;
- }
-
- if (list->ps_clsid32) {
- register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32);
- if (res != ERROR_SUCCESS) goto error_close_iid_key;
- }
-
- error_close_iid_key:
- RegCloseKey(iid_key);
- }
-
-error_close_interface_key:
- RegCloseKey(interface_key);
-error_return:
- return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
-}
-
-/***********************************************************************
- * unregister_interfaces
- */
-static HRESULT unregister_interfaces(struct regsvr_interface const *list)
-{
- LONG res = ERROR_SUCCESS;
- HKEY interface_key;
-
- res = RegOpenKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0,
- KEY_READ | KEY_WRITE, &interface_key);
- if (res == ERROR_FILE_NOT_FOUND) return S_OK;
- if (res != ERROR_SUCCESS) goto error_return;
-
- for (; res == ERROR_SUCCESS && list->iid; ++list) {
- WCHAR buf[39];
-
- StringFromGUID2(list->iid, buf, 39);
- res = recursive_delete_keyW(interface_key, buf);
- }
-
- RegCloseKey(interface_key);
-error_return:
- return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
-}
-
-/***********************************************************************
- * register_coclasses
- */
-static HRESULT register_coclasses(struct regsvr_coclass const *list)
-{
- LONG res = ERROR_SUCCESS;
- HKEY coclass_key;
-
- res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0,
- KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL);
- if (res != ERROR_SUCCESS) goto error_return;
-
- for (; res == ERROR_SUCCESS && list->clsid; ++list) {
- WCHAR buf[39];
- HKEY clsid_key;
-
- StringFromGUID2(list->clsid, buf, 39);
- res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0,
- KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL);
- if (res != ERROR_SUCCESS) goto error_close_coclass_key;
-
- if (list->name) {
- res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ,
- (CONST BYTE*)(list->name),
- strlen(list->name) + 1);
- if (res != ERROR_SUCCESS) goto error_close_clsid_key;
- }
-
- if (list->ips) {
- res = register_key_defvalueA(clsid_key, ips_keyname, list->ips);
- if (res != ERROR_SUCCESS) goto error_close_clsid_key;
- }
-
- if (list->ips32) {
- HKEY ips32_key;
-
- res = RegCreateKeyExW(clsid_key, ips32_keyname, 0, NULL, 0,
- KEY_READ | KEY_WRITE, NULL,
- &ips32_key, NULL);
- if (res != ERROR_SUCCESS) goto error_close_clsid_key;
-
- res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ,
- (CONST BYTE*)list->ips32,
- lstrlenA(list->ips32) + 1);
- if (res == ERROR_SUCCESS && list->ips32_tmodel)
- res = RegSetValueExA(ips32_key, tmodel_valuename, 0, REG_SZ,
- (CONST BYTE*)list->ips32_tmodel,
- strlen(list->ips32_tmodel) + 1);
- RegCloseKey(ips32_key);
- if (res != ERROR_SUCCESS) goto error_close_clsid_key;
- }
-
- if (list->progid) {
- res = register_key_defvalueA(clsid_key, progid_keyname,
- list->progid);
- if (res != ERROR_SUCCESS) goto error_close_clsid_key;
-
- res = register_progid(buf, list->progid, NULL,
- list->name, list->progid_extra);
- if (res != ERROR_SUCCESS) goto error_close_clsid_key;
- }
-
- if (list->viprogid) {
- res = register_key_defvalueA(clsid_key, viprogid_keyname,
- list->viprogid);
- if (res != ERROR_SUCCESS) goto error_close_clsid_key;
-
- res = register_progid(buf, list->viprogid, list->progid,
- list->name, list->progid_extra);
- if (res != ERROR_SUCCESS) goto error_close_clsid_key;
- }
-
- error_close_clsid_key:
- RegCloseKey(clsid_key);
- }
-
-error_close_coclass_key:
- RegCloseKey(coclass_key);
-error_return:
- return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
-}
-
-/***********************************************************************
- * unregister_coclasses
- */
-static HRESULT unregister_coclasses(struct regsvr_coclass const *list)
-{
- LONG res = ERROR_SUCCESS;
- HKEY coclass_key;
-
- res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0,
- KEY_READ | KEY_WRITE, &coclass_key);
- if (res == ERROR_FILE_NOT_FOUND) return S_OK;
- if (res != ERROR_SUCCESS) goto error_return;
-
- for (; res == ERROR_SUCCESS && list->clsid; ++list) {
- WCHAR buf[39];
-
- StringFromGUID2(list->clsid, buf, 39);
- res = recursive_delete_keyW(coclass_key, buf);
- if (res != ERROR_SUCCESS) goto error_close_coclass_key;
-
- if (list->progid) {
- res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->progid);
- if (res != ERROR_SUCCESS) goto error_close_coclass_key;
- }
-
- if (list->viprogid) {
- res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->viprogid);
- if (res != ERROR_SUCCESS) goto error_close_coclass_key;
- }
- }
-
-error_close_coclass_key:
- RegCloseKey(coclass_key);
-error_return:
- return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
-}
-
-/***********************************************************************
- * regsvr_key_guid
- */
-static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid)
-{
- WCHAR buf[39];
-
- StringFromGUID2(guid, buf, 39);
- return register_key_defvalueW(base, name, buf);
-}
-
-/***********************************************************************
- * regsvr_key_defvalueW
- */
-static LONG register_key_defvalueW(
- HKEY base,
- WCHAR const *name,
- WCHAR const *value)
-{
- LONG res;
- HKEY key;
-
- res = RegCreateKeyExW(base, name, 0, NULL, 0,
- KEY_READ | KEY_WRITE, NULL, &key, NULL);
- if (res != ERROR_SUCCESS) return res;
- res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
- (lstrlenW(value) + 1) * sizeof(WCHAR));
- RegCloseKey(key);
- return res;
-}
-
-/***********************************************************************
- * regsvr_key_defvalueA
- */
-static LONG register_key_defvalueA(
- HKEY base,
- WCHAR const *name,
- char const *value)
-{
- LONG res;
- HKEY key;
-
- res = RegCreateKeyExW(base, name, 0, NULL, 0,
- KEY_READ | KEY_WRITE, NULL, &key, NULL);
- if (res != ERROR_SUCCESS) return res;
- res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
- lstrlenA(value) + 1);
- RegCloseKey(key);
- return res;
-}
-
-/***********************************************************************
- * regsvr_progid
- */
-static LONG register_progid(
- WCHAR const *clsid,
- char const *progid,
- char const *curver_progid,
- char const *name,
- char const *extra)
-{
- LONG res;
- HKEY progid_key;
-
- res = RegCreateKeyExA(HKEY_CLASSES_ROOT, progid, 0,
- NULL, 0, KEY_READ | KEY_WRITE, NULL,
- &progid_key, NULL);
- if (res != ERROR_SUCCESS) return res;
-
- if (name) {
- res = RegSetValueExA(progid_key, NULL, 0, REG_SZ,
- (CONST BYTE*)name, strlen(name) + 1);
- if (res != ERROR_SUCCESS) goto error_close_progid_key;
- }
-
- if (clsid) {
- res = register_key_defvalueW(progid_key, clsid_keyname, clsid);
- if (res != ERROR_SUCCESS) goto error_close_progid_key;
- }
-
- if (curver_progid) {
- res = register_key_defvalueA(progid_key, curver_keyname,
- curver_progid);
- if (res != ERROR_SUCCESS) goto error_close_progid_key;
- }
-
- if (extra) {
- HKEY extra_key;
-
- res = RegCreateKeyExA(progid_key, extra, 0,
- NULL, 0, KEY_READ | KEY_WRITE, NULL,
- &extra_key, NULL);
- if (res == ERROR_SUCCESS)
- RegCloseKey(extra_key);
- }
-
-error_close_progid_key:
- RegCloseKey(progid_key);
- return res;
-}
-
-/***********************************************************************
- * recursive_delete_key
- */
-static LONG recursive_delete_key(HKEY key)
-{
- LONG res;
- WCHAR subkey_name[MAX_PATH];
- DWORD cName;
- HKEY subkey;
-
- for (;;) {
- cName = sizeof(subkey_name) / sizeof(WCHAR);
- res = RegEnumKeyExW(key, 0, subkey_name, &cName,
- NULL, NULL, NULL, NULL);
- if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) {
- res = ERROR_SUCCESS; /* presumably we're done enumerating */
- break;
- }
- res = RegOpenKeyExW(key, subkey_name, 0,
- KEY_READ | KEY_WRITE, &subkey);
- if (res == ERROR_FILE_NOT_FOUND) continue;
- if (res != ERROR_SUCCESS) break;
-
- res = recursive_delete_key(subkey);
- RegCloseKey(subkey);
- if (res != ERROR_SUCCESS) break;
- }
-
- if (res == ERROR_SUCCESS) res = RegDeleteKeyW(key, 0);
- return res;
-}
-
-/***********************************************************************
- * recursive_delete_keyA
- */
-static LONG recursive_delete_keyA(HKEY base, char const *name)
-{
- LONG res;
- HKEY key;
-
- res = RegOpenKeyExA(base, name, 0, KEY_READ | KEY_WRITE, &key);
- if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
- if (res != ERROR_SUCCESS) return res;
- res = recursive_delete_key(key);
- RegCloseKey(key);
- return res;
-}
-
-/***********************************************************************
- * recursive_delete_keyW
- */
-static LONG recursive_delete_keyW(HKEY base, WCHAR const *name)
-{
- LONG res;
- HKEY key;
-
- res = RegOpenKeyExW(base, name, 0, KEY_READ | KEY_WRITE, &key);
- if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
- if (res != ERROR_SUCCESS) return res;
- res = recursive_delete_key(key);
- RegCloseKey(key);
- return res;
-}
-
-/***********************************************************************
- * coclass list
- */
-static struct regsvr_coclass const coclass_list[] = {
- { &CLSID_DirectPlay,
- "DirectPlay Object",
- NULL,
- "dplayx.dll",
- "Both"
- },
- { &CLSID_DirectPlayLobby,
- "DirectPlayLobby Object",
- NULL,
- "dplayx.dll",
- "Both"
- },
- { NULL } /* list terminator */
-};
-
-/***********************************************************************
- * interface list
- */
-
-static struct regsvr_interface const interface_list[] = {
- { NULL } /* list terminator */
-};
-
-/***********************************************************************
- * DllRegisterServer (DPLAYX.@)
- */
-HRESULT WINAPI DllRegisterServer(void)
-{
- HRESULT hr;
-
- TRACE("\n");
-
- hr = register_coclasses(coclass_list);
- if (SUCCEEDED(hr))
- hr = register_interfaces(interface_list);
- return hr;
-}
-
-/***********************************************************************
- * DllUnregisterServer (DPLAYX.@)
- */
-HRESULT WINAPI DllUnregisterServer(void)
-{
- HRESULT hr;
-
- TRACE("\n");
-
- hr = unregister_coclasses(coclass_list);
- if (SUCCEEDED(hr))
- hr = unregister_interfaces(interface_list);
- return hr;
-}
*
* 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#define WINE_OLESELFREGISTER
+1 WINE_REGISTRY dplayx.rgs
+
#define WINE_FILEDESCRIPTION_STR "Wine DirectPlay"
#define WINE_FILENAME_STR "dplayx.dll"
-#define WINE_FILEVERSION 5,3,0,900
-#define WINE_FILEVERSION_STR "5.3.0.900"
-#define WINE_PRODUCTVERSION 5,3,0,900
-#define WINE_PRODUCTVERSION_STR "5.3"
+#define WINE_FILEVERSION 5,3,1,904
+#define WINE_FILEVERSION_STR "5.3.1.904"
+#define WINE_PRODUCTVERSION 5,3,1,904
+#define WINE_PRODUCTVERSION_STR "5.3.1.904"
+#define WINE_EXTRAVALUES VALUE "OLESelfRegister",""
-#include "wine/wine_common_ver.rc"
+#include <wine/wine_common_ver.rc>
x86/common_x86.c
# x86/x86_xform.c
# x86/3dnow.c
- # x86/sse.c
+ x86/sse.c
x86/common_x86_asm.S
x86/x86_xform2.S
x86/x86_xform3.S
x86/3dnow_xform3.S
x86/3dnow_xform4.S
x86/3dnow_normal.S
- # x86/sse_xform1.S
- # x86/sse_xform2.S
- # x86/sse_xform3.S
- # x86/sse_xform4.S
- # x86/sse_normal.S
+ x86/sse_xform1.S
+ x86/sse_xform2.S
+ x86/sse_xform3.S
+ x86/sse_xform4.S
+ x86/sse_normal.S
x86/read_rgba_span_x86.S)
add_definitions(
-DUSE_X86_ASM
-DUSE_MMX_ASM
-DUSE_3DNOW_ASM
- # -DUSE_SSE_ASM
+ -DUSE_SSE_ASM
)
endif()
{
trust = CertOpenStore(CERT_STORE_PROV_COLLECTION, 0, 0,
CERT_STORE_CREATE_NEW_FLAG, NULL);
- if (root)
+ if (trust)
{
for (i = 0; i < cert->cTrustStores; i++)
CertAddStoreToCollection(trust, cert->rghstoreTrust[i], 0, 0);
WINE_DEFAULT_DEBUG_CHANNEL(cryptdll);
-static HMODULE CRYPTDLL_hModule;
-
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
TRACE("%p,%x,%p\n", hinstDLL, fdwReason, lpvReserved);
case DLL_PROCESS_ATTACH:
{
DisableThreadLibraryCalls(hinstDLL);
- CRYPTDLL_hModule = hinstDLL;
break;
}
case DLL_PROCESS_DETACH:
#define IS_INTOID(x) (((ULONG_PTR)(x) >> 16) == 0)
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
-{
- TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
-
- switch (fdwReason) {
- case DLL_PROCESS_ATTACH:
- DisableThreadLibraryCalls(hinstDLL);
- break;
- case DLL_PROCESS_DETACH:
- /* Do uninitialisation here */
- break;
- default: break;
- }
- return TRUE;
-}
-
static const WCHAR cryptNet[] = { 'c','r','y','p','t','n','e','t','.',
'd','l','l',0 };
TRACE("(%s, %p, %p)\n", debugstr_w(pszURL), pObject, pAuxInfo);
- ret = GetUrlCacheEntryInfoW(pszURL, NULL, &size);
- if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
+ RetrieveUrlCacheEntryFileW(pszURL, NULL, &size, 0);
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
+ return FALSE;
+
+ pCacheInfo = CryptMemAlloc(size);
+ if (!pCacheInfo)
{
- pCacheInfo = CryptMemAlloc(size);
- if (pCacheInfo)
- ret = TRUE;
- else
- SetLastError(ERROR_OUTOFMEMORY);
+ SetLastError(ERROR_OUTOFMEMORY);
+ return FALSE;
}
- if (ret && (ret = GetUrlCacheEntryInfoW(pszURL, pCacheInfo, &size)))
+
+ if ((ret = RetrieveUrlCacheEntryFileW(pszURL, pCacheInfo, &size, 0)))
{
FILETIME ft;
GetSystemTimeAsFileTime(&ft);
if (CompareFileTime(&pCacheInfo->ExpireTime, &ft) >= 0)
{
- HANDLE hFile = CreateFileW(pCacheInfo->lpszLocalFileName,
- GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ HANDLE hFile = CreateFileW(pCacheInfo->lpszLocalFileName, GENERIC_READ,
+ FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE)
{
DeleteUrlCacheEntryW(pszURL);
ret = FALSE;
}
+ UnlockUrlCacheEntryFileW(pszURL, 0);
}
CryptMemFree(pCacheInfo);
TRACE("returning %d\n", ret);
DWORD dwRetrievalFlags, FILETIME expires)
{
WCHAR cacheFileName[MAX_PATH];
- DWORD size = 0;
- BOOL ret, create = FALSE;
+ HANDLE hCacheFile;
+ DWORD size = 0, entryType;
+ FILETIME ft;
GetUrlCacheEntryInfoW(pszURL, NULL, &size);
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
INTERNET_CACHE_ENTRY_INFOW *info = CryptMemAlloc(size);
- if (info)
+ if (!info)
{
- FILETIME ft;
+ ERR("out of memory\n");
+ return;
+ }
- ret = GetUrlCacheEntryInfoW(pszURL, info, &size);
- if (ret)
- lstrcpyW(cacheFileName, info->lpszLocalFileName);
+ if (GetUrlCacheEntryInfoW(pszURL, info, &size))
+ {
+ lstrcpyW(cacheFileName, info->lpszLocalFileName);
/* Check if the existing cache entry is up to date. If it isn't,
* remove the existing cache entry, and create a new one with the
* new value.
GetSystemTimeAsFileTime(&ft);
if (CompareFileTime(&info->ExpireTime, &ft) < 0)
{
- create = TRUE;
DeleteUrlCacheEntryW(pszURL);
}
- CryptMemFree(info);
+ else
+ {
+ info->ExpireTime = expires;
+ SetUrlCacheEntryInfoW(pszURL, info, CACHE_ENTRY_EXPTIME_FC);
+ CryptMemFree(info);
+ return;
+ }
}
- else
- ret = FALSE;
- }
- else
- {
- ret = CreateUrlCacheEntryW(pszURL, pObject->rgBlob[0].cbData, NULL,
- cacheFileName, 0);
- create = TRUE;
+ CryptMemFree(info);
}
- if (ret)
- {
- DWORD entryType;
- FILETIME ft = { 0 };
- if (create)
- {
- HANDLE hCacheFile = CreateFileW(cacheFileName, GENERIC_WRITE, 0,
- NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (!CreateUrlCacheEntryW(pszURL, pObject->rgBlob[0].cbData, NULL, cacheFileName, 0))
+ return;
- if (hCacheFile != INVALID_HANDLE_VALUE)
- {
- DWORD bytesWritten;
+ hCacheFile = CreateFileW(cacheFileName, GENERIC_WRITE, 0,
+ NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ if(hCacheFile == INVALID_HANDLE_VALUE)
+ return;
- WriteFile(hCacheFile, pObject->rgBlob[0].pbData,
- pObject->rgBlob[0].cbData, &bytesWritten, NULL);
- CloseHandle(hCacheFile);
- }
- else
- ret = FALSE;
- }
- if (ret)
- {
- if (!(dwRetrievalFlags & CRYPT_STICKY_CACHE_RETRIEVAL))
- entryType = NORMAL_CACHE_ENTRY;
- else
- entryType = STICKY_CACHE_ENTRY;
- CommitUrlCacheEntryW(pszURL, cacheFileName, expires, ft, entryType,
- NULL, 0, NULL, NULL);
- }
- }
+ WriteFile(hCacheFile, pObject->rgBlob[0].pbData,
+ pObject->rgBlob[0].cbData, &size, NULL);
+ CloseHandle(hCacheFile);
+
+ if (!(dwRetrievalFlags & CRYPT_STICKY_CACHE_RETRIEVAL))
+ entryType = NORMAL_CACHE_ENTRY;
+ else
+ entryType = STICKY_CACHE_ENTRY;
+ memset(&ft, 0, sizeof(ft));
+ CommitUrlCacheEntryW(pszURL, cacheFileName, expires, ft, entryType,
+ NULL, 0, NULL, NULL);
}
static void CALLBACK CRYPT_InetStatusCallback(HINTERNET hInt,
else
ret = TRUE;
}
- /* We don't set ret to TRUE in this block to avoid masking
- * an error from HttpSendRequestExW.
- */
- if (!HttpEndRequestW(hHttp, NULL, 0, (DWORD_PTR)context) &&
+ if (ret &&
+ !(ret = HttpEndRequestW(hHttp, NULL, 0, (DWORD_PTR)context)) &&
GetLastError() == ERROR_IO_PENDING)
{
if (WaitForSingleObject(context->event,
context->timeout) == WAIT_TIMEOUT)
- {
SetLastError(ERROR_TIMEOUT);
- ret = FALSE;
- }
+ else
+ ret = TRUE;
}
if (ret)
ret = CRYPT_DownloadObject(dwRetrievalFlags, hHttp,
/* Try to create the file directly - Wine handles / in pathnames */
lstrcpynW(path, components.lpszUrlPath,
components.dwUrlPathLength + 1);
- hFile = CreateFileW(path, GENERIC_READ, 0, NULL, OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL, NULL);
+ hFile = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ,
+ NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
/* Try again on the current drive */
{
lstrcpynW(path + 2, components.lpszUrlPath,
components.dwUrlPathLength + 1);
- hFile = CreateFileW(path, GENERIC_READ, 0, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ hFile = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ,
+ NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
}
if (hFile == INVALID_HANDLE_VALUE)
{
{
lstrcpynW(path + 2, components.lpszUrlPath,
components.dwUrlPathLength + 1);
- hFile = CreateFileW(path, GENERIC_READ, 0, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ hFile = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ,
+ NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
}
}
}
{
if (comma)
*comma = 0;
- add_oid_to_usage(usage, ptr);
+ usage = add_oid_to_usage(usage, ptr);
}
}
return usage;
{
PCCRYPT_OID_INFO *ptr;
- for (ptr = usages; *ptr; ptr++)
+ for (ptr = usages; advancedUsage && *ptr; ptr++)
{
DWORD i;
BOOL disabled = FALSE;
(*ptr)->pszOID))
disabled = TRUE;
if (!disabled)
- add_oid_to_usage(advancedUsage,
+ advancedUsage = add_oid_to_usage(advancedUsage,
(LPSTR)(*ptr)->pszOID);
}
/* The individual strings are pointers to disabledUsagesStr,
DWORD conn;
LPDATAOBJECT dataObject = NULL;
HBITMAP bitmap = NULL;
- RECT rect;
STGMEDIUM stgm;
LPOLECLIENTSITE clientSite = NULL;
REOBJECT reObject;
LR_DEFAULTSIZE | LR_LOADTRANSPARENT);
if (!bitmap)
goto end;
- rect.left = rect.top = 0;
- rect.right = GetSystemMetrics(SM_CXICON);
- rect.bottom = GetSystemMetrics(SM_CYICON);
stgm.tymed = TYMED_GDI;
stgm.u.hBitmap = bitmap;
stgm.pUnkForRelease = NULL;
static void add_v1_fields(HWND hwnd, struct detail_data *data)
{
- int i;
+ unsigned int i;
PCCERT_CONTEXT cert = data->pCertViewInfo->pCertContext;
/* The last item in v1_fields is the public key, which is not in the loop
static void free_detail_fields(struct detail_data *data)
{
- DWORD i;
+ int i;
for (i = 0; i < data->cFields; i++)
HeapFree(GetProcessHeap(), 0, data->fields[i].detailed_value);
help.c
hhctrl.c
index.c
- regsvr.c
search.c
stream.c
webbrowser.c
- hhctrl.rc
+ hhctrl.rc
${CMAKE_CURRENT_BINARY_DIR}/hhctrl.def)
+add_typelib(hhctrl_tlb.idl)
+set_source_files_properties(hhctrl.rc PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/hhctrl_tlb.tlb)
set_module_type(hhctrl win32ocx)
target_link_libraries(hhctrl uuid wine itss_guid)
-
-add_importlibs(hhctrl
- advapi32
- comctl32
- shlwapi
- ole32
- oleaut32
- user32
- gdi32
- msvcrt
- kernel32
- ntdll)
-
+add_importlibs(hhctrl advapi32 comctl32 shlwapi ole32 oleaut32 user32 gdi32 msvcrt kernel32 ntdll)
add_dependencies(hhctrl wineheaders)
add_pch(hhctrl hhctrl.h)
add_cd_file(TARGET hhctrl DESTINATION reactos/system32 FOR all)
*/
#include "hhctrl.h"
+#include "stream.h"
#include <winreg.h>
#include <shlwapi.h>
WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp);
-#define BLOCK_BITS 12
-#define BLOCK_SIZE (1 << BLOCK_BITS)
-#define BLOCK_MASK (BLOCK_SIZE-1)
-
/* Reads a string from the #STRINGS section in the CHM file */
static LPCSTR GetChmString(CHMInfo *chm, DWORD offset)
{
heap_free(chm->defTitle);
chm->defTitle = strdupnAtoW(buf, entry.len);
break;
+ case 0x4:
+ /* TODO: Currently only the Locale ID is loaded from this field */
+ TRACE("Locale is: %d\n", *(LCID*)&buf[0]);
+ if(!GetLocaleInfoW(*(LCID*)&buf[0], LOCALE_IDEFAULTANSICODEPAGE|LOCALE_RETURN_NUMBER,
+ (WCHAR *)&chm->codePage, sizeof(chm->codePage)/sizeof(WCHAR)))
+ chm->codePage = CP_ACP;
+ break;
case 0x5:
- TRACE("Default window is %s\n", debugstr_an(buf, entry.len));
+ TRACE("Window name is %s\n", debugstr_an(buf, entry.len));
+ chm->defWindow = strdupnAtoW(buf, entry.len);
break;
case 0x6:
TRACE("Compiled file is %s\n", debugstr_an(buf, entry.len));
+ heap_free(chm->compiledFile);
+ chm->compiledFile = strdupnAtoW(buf, entry.len);
break;
case 0x9:
TRACE("Version is %s\n", debugstr_an(buf, entry.len));
return strdupAtoW(ret);
}
+/*
+ * Tests if the file <chmfile>.<ext> exists, used for loading Indices, Table of Contents, etc.
+ * when these files are not available from the HH_WINTYPE structure.
+ */
+static WCHAR *FindHTMLHelpSetting(HHInfo *info, const WCHAR *extW)
+{
+ static const WCHAR periodW[] = {'.',0};
+ IStorage *pStorage = info->pCHMInfo->pStorage;
+ IStream *pStream;
+ WCHAR *filename;
+ HRESULT hr;
+
+ filename = heap_alloc( (strlenW(info->pCHMInfo->compiledFile)
+ + strlenW(periodW) + strlenW(extW) + 1) * sizeof(WCHAR) );
+ strcpyW(filename, info->pCHMInfo->compiledFile);
+ strcatW(filename, periodW);
+ strcatW(filename, extW);
+ hr = IStorage_OpenStream(pStorage, filename, NULL, STGM_READ, 0, &pStream);
+ if (FAILED(hr))
+ {
+ heap_free(filename);
+ return strdupAtoW("");
+ }
+ IStream_Release(pStream);
+ return filename;
+}
+
+static inline WCHAR *MergeChmString(LPCWSTR src, WCHAR **dst)
+{
+ if(*dst == NULL)
+ *dst = strdupW(src);
+ return *dst;
+}
+
+void MergeChmProperties(HH_WINTYPEW *src, HHInfo *info, BOOL override)
+{
+ DWORD unhandled_params = src->fsValidMembers & ~(HHWIN_PARAM_PROPERTIES|HHWIN_PARAM_STYLES
+ |HHWIN_PARAM_EXSTYLES|HHWIN_PARAM_RECT|HHWIN_PARAM_NAV_WIDTH
+ |HHWIN_PARAM_SHOWSTATE|HHWIN_PARAM_INFOTYPES|HHWIN_PARAM_TB_FLAGS
+ |HHWIN_PARAM_EXPANSION|HHWIN_PARAM_TABPOS|HHWIN_PARAM_TABORDER
+ |HHWIN_PARAM_HISTORY_COUNT|HHWIN_PARAM_CUR_TAB);
+ HH_WINTYPEW *dst = &info->WinType;
+ DWORD merge = override ? src->fsValidMembers : src->fsValidMembers & ~dst->fsValidMembers;
+
+ if (unhandled_params)
+ FIXME("Unsupported fsValidMembers fields: 0x%x\n", unhandled_params);
+
+ dst->fsValidMembers |= merge;
+ if (dst->cbStruct == 0)
+ {
+ /* If the structure has not been filled in yet then use all of the values */
+ dst->cbStruct = sizeof(HH_WINTYPEW);
+ merge = ~0;
+ }
+ if (merge & HHWIN_PARAM_PROPERTIES) dst->fsWinProperties = src->fsWinProperties;
+ if (merge & HHWIN_PARAM_STYLES) dst->dwStyles = src->dwStyles;
+ if (merge & HHWIN_PARAM_EXSTYLES) dst->dwExStyles = src->dwExStyles;
+ if (merge & HHWIN_PARAM_RECT) dst->rcWindowPos = src->rcWindowPos;
+ if (merge & HHWIN_PARAM_NAV_WIDTH) dst->iNavWidth = src->iNavWidth;
+ if (merge & HHWIN_PARAM_SHOWSTATE) dst->nShowState = src->nShowState;
+ if (merge & HHWIN_PARAM_INFOTYPES) dst->paInfoTypes = src->paInfoTypes;
+ if (merge & HHWIN_PARAM_TB_FLAGS) dst->fsToolBarFlags = src->fsToolBarFlags;
+ if (merge & HHWIN_PARAM_EXPANSION) dst->fNotExpanded = src->fNotExpanded;
+ if (merge & HHWIN_PARAM_TABPOS) dst->tabpos = src->tabpos;
+ if (merge & HHWIN_PARAM_TABORDER) memcpy(dst->tabOrder, src->tabOrder, sizeof(src->tabOrder));
+ if (merge & HHWIN_PARAM_HISTORY_COUNT) dst->cHistory = src->cHistory;
+ if (merge & HHWIN_PARAM_CUR_TAB) dst->curNavType = src->curNavType;
+
+ /*
+ * Note: We assume that hwndHelp, hwndCaller, hwndToolBar, hwndNavigation, and hwndHTML cannot be
+ * modified by the user. rcHTML and rcMinSize are not currently supported, so don't bother to copy them.
+ */
+
+ dst->pszType = MergeChmString(src->pszType, &info->stringsW.pszType);
+ dst->pszFile = MergeChmString(src->pszFile, &info->stringsW.pszFile);
+ dst->pszToc = MergeChmString(src->pszToc, &info->stringsW.pszToc);
+ dst->pszIndex = MergeChmString(src->pszIndex, &info->stringsW.pszIndex);
+ dst->pszCaption = MergeChmString(src->pszCaption, &info->stringsW.pszCaption);
+ dst->pszHome = MergeChmString(src->pszHome, &info->stringsW.pszHome);
+ dst->pszJump1 = MergeChmString(src->pszJump1, &info->stringsW.pszJump1);
+ dst->pszJump2 = MergeChmString(src->pszJump2, &info->stringsW.pszJump2);
+ dst->pszUrlJump1 = MergeChmString(src->pszUrlJump1, &info->stringsW.pszUrlJump1);
+ dst->pszUrlJump2 = MergeChmString(src->pszUrlJump2, &info->stringsW.pszUrlJump2);
+
+ /* FIXME: pszCustomTabs is a list of multiple zero-terminated strings so ReadString won't
+ * work in this case
+ */
+#if 0
+ dst->pszCustomTabs = MergeChmString(src->pszCustomTabs, &info->pszCustomTabs);
+#endif
+}
+
+static inline WCHAR *ConvertChmString(HHInfo *info, const WCHAR **str)
+{
+ WCHAR *ret = NULL;
+
+ if(*str)
+ *str = ret = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)*str));
+ return ret;
+}
+
/* Loads the HH_WINTYPE data from the CHM file
*
* FIXME: There may be more than one window type in the file, so
BOOL LoadWinTypeFromCHM(HHInfo *info)
{
LARGE_INTEGER liOffset;
+ WCHAR *pszType = NULL, *pszFile = NULL, *pszToc = NULL, *pszIndex = NULL, *pszCaption = NULL;
+ WCHAR *pszHome = NULL, *pszJump1 = NULL, *pszJump2 = NULL, *pszUrlJump1 = NULL, *pszUrlJump2 = NULL;
IStorage *pStorage = info->pCHMInfo->pStorage;
- IStream *pStream;
+ IStream *pStream = NULL;
+ HH_WINTYPEW wintype;
HRESULT hr;
DWORD cbRead;
+ BOOL ret = FALSE;
+ static const WCHAR null[] = {0};
+ static const WCHAR toc_extW[] = {'h','h','c',0};
+ static const WCHAR index_extW[] = {'h','h','k',0};
static const WCHAR windowsW[] = {'#','W','I','N','D','O','W','S',0};
hr = IStorage_OpenStream(pStorage, windowsW, NULL, STGM_READ, 0, &pStream);
- if (FAILED(hr))
+ if (SUCCEEDED(hr))
+ {
+ /* jump past the #WINDOWS header */
+ liOffset.QuadPart = sizeof(DWORD) * 2;
+
+ hr = IStream_Seek(pStream, liOffset, STREAM_SEEK_SET, NULL);
+ if (FAILED(hr)) goto done;
+
+ /* read the HH_WINTYPE struct data */
+ hr = IStream_Read(pStream, &wintype, sizeof(wintype), &cbRead);
+ if (FAILED(hr)) goto done;
+
+ /* convert the #STRINGS offsets to actual strings */
+ pszType = ConvertChmString(info, &wintype.pszType);
+ pszFile = ConvertChmString(info, &wintype.pszFile);
+ pszToc = ConvertChmString(info, &wintype.pszToc);
+ pszIndex = ConvertChmString(info, &wintype.pszIndex);
+ pszCaption = ConvertChmString(info, &wintype.pszCaption);
+ pszHome = ConvertChmString(info, &wintype.pszHome);
+ pszJump1 = ConvertChmString(info, &wintype.pszJump1);
+ pszJump2 = ConvertChmString(info, &wintype.pszJump2);
+ pszUrlJump1 = ConvertChmString(info, &wintype.pszUrlJump1);
+ pszUrlJump2 = ConvertChmString(info, &wintype.pszUrlJump2);
+ }
+ else
{
/* no defined window types so use (hopefully) sane defaults */
static const WCHAR defaultwinW[] = {'d','e','f','a','u','l','t','w','i','n','\0'};
- static const WCHAR null[] = {0};
- memset((void*)&(info->WinType), 0, sizeof(info->WinType));
- info->WinType.cbStruct=sizeof(info->WinType);
- info->WinType.fUniCodeStrings=TRUE;
- info->WinType.pszType=strdupW(defaultwinW);
- info->WinType.pszToc = strdupW(info->pCHMInfo->defToc ? info->pCHMInfo->defToc : null);
- info->WinType.pszIndex = strdupW(null);
- info->WinType.fsValidMembers=0;
- info->WinType.fsWinProperties=HHWIN_PROP_TRI_PANE;
- info->WinType.pszCaption=strdupW(info->pCHMInfo->defTitle ? info->pCHMInfo->defTitle : null);
- info->WinType.dwStyles=WS_POPUP;
- info->WinType.dwExStyles=0;
- info->WinType.nShowState=SW_SHOW;
- info->WinType.pszFile=strdupW(info->pCHMInfo->defTopic ? info->pCHMInfo->defTopic : null);
- info->WinType.curNavType=HHWIN_NAVTYPE_TOC;
- return TRUE;
+ memset(&wintype, 0, sizeof(wintype));
+ wintype.cbStruct = sizeof(wintype);
+ wintype.fUniCodeStrings = TRUE;
+ wintype.pszType = pszType = strdupW(info->pCHMInfo->defWindow ? info->pCHMInfo->defWindow : defaultwinW);
+ wintype.pszToc = pszToc = strdupW(info->pCHMInfo->defToc ? info->pCHMInfo->defToc : null);
+ wintype.pszIndex = pszIndex = strdupW(null);
+ wintype.fsValidMembers = 0;
+ wintype.fsWinProperties = HHWIN_PROP_TRI_PANE;
+ wintype.dwStyles = WS_POPUP;
+ wintype.dwExStyles = 0;
+ wintype.nShowState = SW_SHOW;
+ wintype.curNavType = HHWIN_NAVTYPE_TOC;
}
- /* jump past the #WINDOWS header */
- liOffset.QuadPart = sizeof(DWORD) * 2;
-
- hr = IStream_Seek(pStream, liOffset, STREAM_SEEK_SET, NULL);
- if (FAILED(hr)) goto done;
-
- /* read the HH_WINTYPE struct data */
- hr = IStream_Read(pStream, &info->WinType, sizeof(info->WinType), &cbRead);
- if (FAILED(hr)) goto done;
-
- /* convert the #STRINGS offsets to actual strings */
- info->WinType.pszType = info->pszType = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)info->WinType.pszType));
- info->WinType.pszCaption = info->pszCaption = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)info->WinType.pszCaption));
- info->WinType.pszToc = info->pszToc = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)info->WinType.pszToc));
- info->WinType.pszIndex = info->pszIndex = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)info->WinType.pszIndex));
- info->WinType.pszFile = info->pszFile = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)info->WinType.pszFile));
- info->WinType.pszHome = info->pszHome = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)info->WinType.pszHome));
- info->WinType.pszJump1 = info->pszJump1 = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)info->WinType.pszJump1));
- info->WinType.pszJump2 = info->pszJump2 = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)info->WinType.pszJump2));
- info->WinType.pszUrlJump1 = info->pszUrlJump1 = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)info->WinType.pszUrlJump1));
- info->WinType.pszUrlJump2 = info->pszUrlJump2 = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)info->WinType.pszUrlJump2));
-
- /* FIXME: pszCustomTabs is a list of multiple zero-terminated strings so ReadString won't
- * work in this case
- */
-#if 0
- info->WinType.pszCustomTabs = info->pszCustomTabs = CHM_ReadString(pChmInfo, (DWORD_PTR)info->WinType.pszCustomTabs);
-#endif
+ /* merge the new data with any pre-existing HH_WINTYPE structure */
+ MergeChmProperties(&wintype, info, FALSE);
+ if (!info->WinType.pszCaption)
+ info->WinType.pszCaption = info->stringsW.pszCaption = strdupW(info->pCHMInfo->defTitle ? info->pCHMInfo->defTitle : null);
+ if (!info->WinType.pszFile)
+ info->WinType.pszFile = info->stringsW.pszFile = strdupW(info->pCHMInfo->defTopic ? info->pCHMInfo->defTopic : null);
+ if (!info->WinType.pszToc)
+ info->WinType.pszToc = info->stringsW.pszToc = FindHTMLHelpSetting(info, toc_extW);
+ if (!info->WinType.pszIndex)
+ info->WinType.pszIndex = info->stringsW.pszIndex = FindHTMLHelpSetting(info, index_extW);
+
+ heap_free(pszType);
+ heap_free(pszFile);
+ heap_free(pszToc);
+ heap_free(pszIndex);
+ heap_free(pszCaption);
+ heap_free(pszHome);
+ heap_free(pszJump1);
+ heap_free(pszJump2);
+ heap_free(pszUrlJump1);
+ heap_free(pszUrlJump2);
+ ret = TRUE;
done:
- IStream_Release(pStream);
+ if (pStream)
+ IStream_Release(pStream);
- return SUCCEEDED(hr);
+ return ret;
}
-static LPCWSTR skip_schema(LPCWSTR url)
+LPCWSTR skip_schema(LPCWSTR url)
{
static const WCHAR its_schema[] = {'i','t','s',':'};
static const WCHAR msits_schema[] = {'m','s','-','i','t','s',':'};
return stream;
}
+/*
+ * Retrieve a CHM document and parse the data from the <title> element to get the document's title.
+ */
+WCHAR *GetDocumentTitle(CHMInfo *info, LPCWSTR document)
+{
+ strbuf_t node, node_name, content;
+ WCHAR *document_title = NULL;
+ IStream *str = NULL;
+ IStorage *storage;
+ stream_t stream;
+ HRESULT hres;
+
+ TRACE("%s\n", debugstr_w(document));
+
+ storage = info->pStorage;
+ if(!storage) {
+ WARN("Could not open storage to obtain the title for a document.\n");
+ return NULL;
+ }
+ IStorage_AddRef(storage);
+
+ hres = IStorage_OpenStream(storage, document, NULL, STGM_READ, 0, &str);
+ IStorage_Release(storage);
+ if(FAILED(hres))
+ WARN("Could not open stream: %08x\n", hres);
+
+ stream_init(&stream, str);
+ strbuf_init(&node);
+ strbuf_init(&content);
+ strbuf_init(&node_name);
+
+ while(next_node(&stream, &node)) {
+ get_node_name(&node, &node_name);
+
+ TRACE("%s\n", node.buf);
+
+ if(!strcasecmp(node_name.buf, "title")) {
+ if(next_content(&stream, &content) && content.len > 1)
+ {
+ document_title = strdupnAtoW(&content.buf[1], content.len-1);
+ FIXME("magic: %s\n", debugstr_w(document_title));
+ break;
+ }
+ }
+
+ strbuf_zero(&node);
+ }
+
+ strbuf_free(&node);
+ strbuf_free(&content);
+ strbuf_free(&node_name);
+ IStream_Release(str);
+
+ return document_title;
+}
+
/* Opens the CHM file for reading */
CHMInfo *OpenCHM(LPCWSTR szFile)
{
if (!(ret = heap_alloc_zero(sizeof(CHMInfo))))
return NULL;
+ ret->codePage = CP_ACP;
if (!(ret->szFile = strdupW(szFile))) {
heap_free(ret);
}
heap_free(chm->strings);
+ heap_free(chm->defWindow);
heap_free(chm->defTitle);
heap_free(chm->defTopic);
heap_free(chm->defToc);
heap_free(chm->szFile);
+ heap_free(chm->compiledFile);
heap_free(chm);
return NULL;
/*
* Copyright 2007 Jacek Caban for CodeWeavers
+ * Copyright 2011 Owen Rudge for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include "hhctrl.h"
#include "stream.h"
+#include "resource.h"
#include <wine/debug.h>
}
}
-static void parse_obj_node_param(ContentItem *item, ContentItem *hhc_root, const char *text)
+static void parse_obj_node_param(ContentItem *item, ContentItem *hhc_root, const char *text, UINT code_page)
{
const char *ptr;
LPWSTR *param, merge;
- int len, wlen;
+ int len;
ptr = get_attr(text, "name", &len);
if(!ptr) {
return;
}
- wlen = MultiByteToWideChar(CP_ACP, 0, ptr, len, NULL, 0);
- *param = heap_alloc((wlen+1)*sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, ptr, len, *param, wlen);
- (*param)[wlen] = 0;
+ /*
+ * "merge" parameter data (referencing another CHM file) can be incorporated into the "local" parameter
+ * by specifying the filename in the format:
+ * MS-ITS:file.chm::/local_path.htm
+ */
+ if(param == &item->local && strstr(ptr, "::"))
+ {
+ const char *local = strstr(ptr, "::")+2;
+ int local_len = len-(local-ptr);
+
+ item->local = decode_html(local, local_len, code_page);
+ param = &merge;
+ }
+
+ *param = decode_html(ptr, len, code_page);
if(param == &merge) {
SetChmPath(&item->merge, hhc_root->merge.chm_file, merge);
if(!strcasecmp(node_name.buf, "/object"))
break;
if(!strcasecmp(node_name.buf, "param"))
- parse_obj_node_param(item, hhc_root, node.buf);
+ parse_obj_node_param(item, hhc_root, node.buf, info->pCHMInfo->codePage);
strbuf_zero(&node);
}
TVINSERTSTRUCTW tvis;
memset(&tvis, 0, sizeof(tvis));
- tvis.u.item.mask = TVIF_TEXT|TVIF_PARAM;
+ tvis.u.item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
tvis.u.item.cchTextMax = strlenW(item->name)+1;
tvis.u.item.pszText = item->name;
tvis.u.item.lParam = (LPARAM)item;
+ tvis.u.item.iImage = item->child ? HHTV_FOLDER : HHTV_DOCUMENT;
+ tvis.u.item.iSelectedImage = item->child ? HHTV_FOLDER : HHTV_DOCUMENT;
tvis.hParent = parent ? parent->id : 0;
tvis.hInsertAfter = TVI_LAST;
{
free_content_item(info->content);
}
+
+void ActivateContentTopic(HWND hWnd, LPCWSTR filename, ContentItem *item)
+{
+ if (lstrcmpiW(item->local, filename) == 0)
+ {
+ SendMessageW(hWnd, TVM_SELECTITEM, TVGN_CARET, (LPARAM) item->id);
+ return;
+ }
+
+ if (item->next)
+ ActivateContentTopic(hWnd, filename, item->next);
+
+ if (item->child)
+ ActivateContentTopic(hWnd, filename, item->child);
+}
*
* Copyright 2005 James Hawkins
* Copyright 2007 Jacek Caban for CodeWeavers
+ * Copyright 2011 Owen Rudge for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp);
static LRESULT Help_OnSize(HWND hWnd);
+static void ExpandContract(HHInfo *pHHInfo);
/* Window type defaults */
#define TAB_MARGIN 8
#define EDIT_HEIGHT 20
+struct list window_list = LIST_INIT(window_list);
+
static const WCHAR szEmpty[] = {0};
+struct html_encoded_symbol {
+ const char *html_code;
+ char ansi_symbol;
+};
+
+/*
+ * Table mapping the conversion between HTML encoded symbols and their ANSI code page equivalent.
+ * Note: Add additional entries in proper alphabetical order (a binary search is used on this table).
+ */
+struct html_encoded_symbol html_encoded_symbols[] =
+{
+ {"AElig", 0xC6},
+ {"Aacute", 0xC1},
+ {"Acirc", 0xC2},
+ {"Agrave", 0xC0},
+ {"Aring", 0xC5},
+ {"Atilde", 0xC3},
+ {"Auml", 0xC4},
+ {"Ccedil", 0xC7},
+ {"ETH", 0xD0},
+ {"Eacute", 0xC9},
+ {"Ecirc", 0xCA},
+ {"Egrave", 0xC8},
+ {"Euml", 0xCB},
+ {"Iacute", 0xCD},
+ {"Icirc", 0xCE},
+ {"Igrave", 0xCC},
+ {"Iuml", 0xCF},
+ {"Ntilde", 0xD1},
+ {"Oacute", 0xD3},
+ {"Ocirc", 0xD4},
+ {"Ograve", 0xD2},
+ {"Oslash", 0xD8},
+ {"Otilde", 0xD5},
+ {"Ouml", 0xD6},
+ {"THORN", 0xDE},
+ {"Uacute", 0xDA},
+ {"Ucirc", 0xDB},
+ {"Ugrave", 0xD9},
+ {"Uuml", 0xDC},
+ {"Yacute", 0xDD},
+ {"aacute", 0xE1},
+ {"acirc", 0xE2},
+ {"acute", 0xB4},
+ {"aelig", 0xE6},
+ {"agrave", 0xE0},
+ {"amp", '&'},
+ {"aring", 0xE5},
+ {"atilde", 0xE3},
+ {"auml", 0xE4},
+ {"brvbar", 0xA6},
+ {"ccedil", 0xE7},
+ {"cedil", 0xB8},
+ {"cent", 0xA2},
+ {"copy", 0xA9},
+ {"curren", 0xA4},
+ {"deg", 0xB0},
+ {"divide", 0xF7},
+ {"eacute", 0xE9},
+ {"ecirc", 0xEA},
+ {"egrave", 0xE8},
+ {"eth", 0xF0},
+ {"euml", 0xEB},
+ {"frac12", 0xBD},
+ {"frac14", 0xBC},
+ {"frac34", 0xBE},
+ {"gt", '>'},
+ {"iacute", 0xED},
+ {"icirc", 0xEE},
+ {"iexcl", 0xA1},
+ {"igrave", 0xEC},
+ {"iquest", 0xBF},
+ {"iuml", 0xEF},
+ {"laquo", 0xAB},
+ {"lt", '<'},
+ {"macr", 0xAF},
+ {"micro", 0xB5},
+ {"middot", 0xB7},
+ {"nbsp", ' '},
+ {"not", 0xAC},
+ {"ntilde", 0xF1},
+ {"oacute", 0xF3},
+ {"ocirc", 0xF4},
+ {"ograve", 0xF2},
+ {"ordf", 0xAA},
+ {"ordm", 0xBA},
+ {"oslash", 0xF8},
+ {"otilde", 0xF5},
+ {"ouml", 0xF6},
+ {"para", 0xB6},
+ {"plusmn", 0xB1},
+ {"pound", 0xA3},
+ {"quot", '"'},
+ {"raquo", 0xBB},
+ {"reg", 0xAE},
+ {"sect", 0xA7},
+ {"shy", 0xAD},
+ {"sup1", 0xB9},
+ {"sup2", 0xB2},
+ {"sup3", 0xB3},
+ {"szlig", 0xDF},
+ {"thorn", 0xFE},
+ {"times", 0xD7},
+ {"uacute", 0xFA},
+ {"ucirc", 0xFB},
+ {"ugrave", 0xF9},
+ {"uml", 0xA8},
+ {"uuml", 0xFC},
+ {"yacute", 0xFD},
+ {"yen", 0xA5},
+ {"yuml", 0xFF}
+};
+
+static inline BOOL navigation_visible(HHInfo *info)
+{
+ return ((info->WinType.fsWinProperties & HHWIN_PROP_TRI_PANE) && !info->WinType.fNotExpanded);
+}
+
/* Loads a string from the resource file */
static LPWSTR HH_LoadString(DWORD dwID)
{
return ret;
}
-BOOL NavigateToChm(HHInfo *info, LPCWSTR file, LPCWSTR index)
+static BOOL AppendFullPathURL(LPCWSTR file, LPWSTR buf, LPCWSTR index)
{
- WCHAR buf[INTERNET_MAX_URL_LENGTH];
- WCHAR full_path[MAX_PATH];
- LPWSTR ptr;
-
static const WCHAR url_format[] =
{'m','k',':','@','M','S','I','T','S','t','o','r','e',':','%','s',':',':','%','s','%','s',0};
static const WCHAR slash[] = {'/',0};
static const WCHAR empty[] = {0};
+ WCHAR full_path[MAX_PATH];
- TRACE("%p %s %s\n", info, debugstr_w(file), debugstr_w(index));
-
- if (!info->web_browser)
- return FALSE;
+ TRACE("%s %p %s\n", debugstr_w(file), buf, debugstr_w(index));
if(!GetFullPathNameW(file, sizeof(full_path)/sizeof(full_path[0]), full_path, NULL)) {
WARN("GetFullPathName failed: %u\n", GetLastError());
}
wsprintfW(buf, url_format, full_path, (!index || index[0] == '/') ? empty : slash, index);
+ return TRUE;
+}
+
+BOOL NavigateToChm(HHInfo *info, LPCWSTR file, LPCWSTR index)
+{
+ WCHAR buf[INTERNET_MAX_URL_LENGTH];
+
+ TRACE("%p %s %s\n", info, debugstr_w(file), debugstr_w(index));
- /* FIXME: HACK */
- if((ptr = strchrW(buf, '#')))
- *ptr = 0;
+ if ((!info->web_browser) || !AppendFullPathURL(file, buf, index))
+ return FALSE;
return SUCCEEDED(navigate_url(info, buf));
}
+static void DoSync(HHInfo *info)
+{
+ WCHAR buf[INTERNET_MAX_URL_LENGTH];
+ HRESULT hres;
+ BSTR url;
+
+ hres = IWebBrowser2_get_LocationURL(info->web_browser, &url);
+
+ if (FAILED(hres))
+ {
+ WARN("get_LocationURL failed: %08x\n", hres);
+ return;
+ }
+
+ /* If we're not currently viewing a page in the active .chm file, abort */
+ if ((!AppendFullPathURL(info->WinType.pszFile, buf, NULL)) || (lstrlenW(buf) > lstrlenW(url)))
+ {
+ SysFreeString(url);
+ return;
+ }
+
+ if (lstrcmpiW(buf, url) > 0)
+ {
+ static const WCHAR delimW[] = {':',':','/',0};
+ const WCHAR *index;
+
+ index = strstrW(url, delimW);
+
+ if (index)
+ ActivateContentTopic(info->tabs[TAB_CONTENTS].hwnd, index + 3, info->content); /* skip over ::/ */
+ }
+
+ SysFreeString(url);
+}
+
/* Size Bar */
#define SIZEBAR_WIDTH 4
static void SB_OnLButtonUp(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
- HHInfo *pHHInfo = (HHInfo *)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
+ HHInfo *pHHInfo = (HHInfo *)GetWindowLongPtrW(hWnd, 0);
POINT pt;
pt.x = (short)LOWORD(lParam);
wcex.style = 0;
wcex.lpfnWndProc = SizeBar_WndProc;
wcex.cbClsExtra = 0;
- wcex.cbWndExtra = 0;
+ wcex.cbWndExtra = sizeof(LONG_PTR);
wcex.hInstance = hhctrl_hinstance;
wcex.hIcon = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION);
wcex.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_SIZEWE);
{
HWND hWnd;
HWND hwndParent = pHHInfo->WinType.hwndHelp;
- DWORD dwStyles = WS_CHILDWINDOW | WS_VISIBLE | WS_OVERLAPPED;
+ DWORD dwStyles = WS_CHILDWINDOW | WS_OVERLAPPED;
DWORD dwExStyles = WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR;
RECT rc;
+ if (navigation_visible(pHHInfo))
+ dwStyles |= WS_VISIBLE;
+
SB_GetSizeBarRect(pHHInfo, &rc);
hWnd = CreateWindowExW(dwExStyles, szSizeBarClass, szEmpty, dwStyles,
return FALSE;
/* store the pointer to the HH info struct */
- SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)pHHInfo);
+ SetWindowLongPtrW(hWnd, 0, (LONG_PTR)pHHInfo);
pHHInfo->hwndSizeBar = hWnd;
return TRUE;
static LRESULT Child_OnSize(HWND hwnd)
{
- HHInfo *info = (HHInfo*)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
+ HHInfo *info = (HHInfo*)GetWindowLongPtrW(hwnd, 0);
RECT rect;
if(!info || hwnd != info->WinType.hwndNavigation)
ResizeTabChild(info, TAB_CONTENTS);
ResizeTabChild(info, TAB_INDEX);
+ ResizeTabChild(info, TAB_SEARCH);
return 0;
}
static LRESULT OnTabChange(HWND hwnd)
{
- HHInfo *info = (HHInfo*)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
+ HHInfo *info = (HHInfo*)GetWindowLongPtrW(hwnd, 0);
+ int tab_id, tab_index, i;
TRACE("%p\n", hwnd);
if(info->tabs[info->current_tab].hwnd)
ShowWindow(info->tabs[info->current_tab].hwnd, SW_HIDE);
- info->current_tab = SendMessageW(info->hwndTabCtrl, TCM_GETCURSEL, 0, 0);
+ tab_id = (int) SendMessageW(info->hwndTabCtrl, TCM_GETCURSEL, 0, 0);
+ /* convert the ID of the tab to an index in our tab list */
+ tab_index = -1;
+ for (i=0; i<TAB_NUMTABS; i++)
+ {
+ if (info->tabs[i].id == tab_id)
+ {
+ tab_index = i;
+ break;
+ }
+ }
+ if (tab_index == -1)
+ {
+ FIXME("Tab ID %d does not correspond to a valid index in the tab list.\n", tab_id);
+ return 0;
+ }
+ info->current_tab = tab_index;
if(info->tabs[info->current_tab].hwnd)
ShowWindow(info->tabs[info->current_tab].hwnd, SW_SHOW);
IndexSubItem *item = &iiter->items[i];
WCHAR *name = iiter->keyword;
+ if(!item->name)
+ item->name = GetDocumentTitle(info->pCHMInfo, item->local);
if(item->name)
name = item->name;
memset(&lvi, 0, sizeof(lvi));
case WM_SIZE:
return Child_OnSize(hWnd);
case WM_NOTIFY: {
- HHInfo *info = (HHInfo*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
+ HHInfo *info = (HHInfo*)GetWindowLongPtrW(hWnd, 0);
NMHDR *nmhdr = (NMHDR*)lParam;
switch(nmhdr->code) {
return OnTabChange(hWnd);
case TVN_SELCHANGEDW:
return OnTopicChange(info, (void*)((NMTREEVIEWW *)lParam)->itemNew.lParam);
+ case TVN_ITEMEXPANDINGW: {
+ TVITEMW *item = &((NMTREEVIEWW *)lParam)->itemNew;
+ HWND hwndTreeView = info->tabs[TAB_CONTENTS].hwnd;
+
+ item->mask = TVIF_IMAGE|TVIF_SELECTEDIMAGE;
+ if (item->state & TVIS_EXPANDED)
+ {
+ item->iImage = HHTV_FOLDER;
+ item->iSelectedImage = HHTV_FOLDER;
+ }
+ else
+ {
+ item->iImage = HHTV_OPENFOLDER;
+ item->iSelectedImage = HHTV_OPENFOLDER;
+ }
+ SendMessageW(hwndTreeView, TVM_SETITEMW, 0, (LPARAM)item);
+ return 0;
+ }
case NM_DBLCLK:
if(!info)
return 0;
wcex.style = 0;
wcex.lpfnWndProc = Child_WndProc;
wcex.cbClsExtra = 0;
- wcex.cbWndExtra = 0;
+ wcex.cbWndExtra = sizeof(LONG_PTR);
wcex.hInstance = hhctrl_hinstance;
wcex.hIcon = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION);
wcex.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW);
#define ICON_SIZE 20
+static void DisplayPopupMenu(HHInfo *info)
+{
+ HMENU menu, submenu;
+ TBBUTTONINFOW button;
+ MENUITEMINFOW item;
+ POINT coords;
+ RECT rect;
+ DWORD index;
+
+ menu = LoadMenuW(hhctrl_hinstance, MAKEINTRESOURCEW(MENU_POPUP));
+
+ if (!menu)
+ return;
+
+ submenu = GetSubMenu(menu, 0);
+
+ /* Update the Show/Hide menu item */
+ item.cbSize = sizeof(MENUITEMINFOW);
+ item.fMask = MIIM_FTYPE | MIIM_STATE | MIIM_STRING;
+ item.fType = MFT_STRING;
+ item.fState = MF_ENABLED;
+
+ if (info->WinType.fNotExpanded)
+ item.dwTypeData = HH_LoadString(IDS_SHOWTABS);
+ else
+ item.dwTypeData = HH_LoadString(IDS_HIDETABS);
+
+ SetMenuItemInfoW(submenu, IDTB_EXPAND, FALSE, &item);
+ heap_free(item.dwTypeData);
+
+ /* Find the index toolbar button */
+ button.cbSize = sizeof(TBBUTTONINFOW);
+ button.dwMask = TBIF_COMMAND;
+ index = SendMessageW(info->WinType.hwndToolBar, TB_GETBUTTONINFOW, IDTB_OPTIONS, (LPARAM) &button);
+
+ if (index == -1)
+ return;
+
+ /* Get position */
+ SendMessageW(info->WinType.hwndToolBar, TB_GETITEMRECT, index, (LPARAM) &rect);
+
+ coords.x = rect.left;
+ coords.y = rect.bottom;
+
+ ClientToScreen(info->WinType.hwndToolBar, &coords);
+ TrackPopupMenu(submenu, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_LEFTBUTTON | TPM_NOANIMATION, coords.x, coords.y, 0, info->WinType.hwndHelp, NULL);
+}
+
static void TB_OnClick(HWND hWnd, DWORD dwID)
{
- HHInfo *info = (HHInfo *)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
+ HHInfo *info = (HHInfo *)GetWindowLongPtrW(hWnd, 0);
switch (dwID)
{
case IDTB_FORWARD:
DoPageAction(info, WB_GOFORWARD);
break;
+ case IDTB_PRINT:
+ DoPageAction(info, WB_PRINT);
+ break;
case IDTB_EXPAND:
case IDTB_CONTRACT:
+ ExpandContract(info);
+ break;
case IDTB_SYNC:
- case IDTB_PRINT:
+ DoSync(info);
+ break;
case IDTB_OPTIONS:
+ DisplayPopupMenu(info);
+ break;
+ case IDTB_NOTES:
+ case IDTB_CONTENTS:
+ case IDTB_INDEX:
+ case IDTB_SEARCH:
+ case IDTB_HISTORY:
+ case IDTB_FAVORITES:
+ /* These are officially unimplemented as of the Windows 7 SDK */
+ break;
case IDTB_BROWSE_FWD:
case IDTB_BROWSE_BACK:
case IDTB_JUMP1:
}
}
-static void TB_AddButton(TBBUTTON *pButtons, DWORD dwIndex, DWORD dwID)
+static void TB_AddButton(TBBUTTON *pButtons, DWORD dwIndex, DWORD dwID, DWORD dwBitmap)
{
- /* FIXME: Load the correct button bitmaps */
- pButtons[dwIndex].iBitmap = STD_PRINT;
+ pButtons[dwIndex].iBitmap = dwBitmap;
pButtons[dwIndex].idCommand = dwID;
pButtons[dwIndex].fsState = TBSTATE_ENABLED;
pButtons[dwIndex].fsStyle = BTNS_BUTTON;
pButtons[dwIndex].iString = 0;
}
-static void TB_AddButtonsFromFlags(TBBUTTON *pButtons, DWORD dwButtonFlags, LPDWORD pdwNumButtons)
+static void TB_AddButtonsFromFlags(HHInfo *pHHInfo, TBBUTTON *pButtons, DWORD dwButtonFlags, LPDWORD pdwNumButtons)
{
+ int nHistBitmaps = 0, nStdBitmaps = 0, nHHBitmaps = 0;
+ HWND hToolbar = pHHInfo->WinType.hwndToolBar;
+ TBADDBITMAP tbAB;
+ DWORD unsupported;
+
+ /* Common bitmaps */
+ tbAB.hInst = HINST_COMMCTRL;
+ tbAB.nID = IDB_HIST_LARGE_COLOR;
+ nHistBitmaps = SendMessageW(hToolbar, TB_ADDBITMAP, 0, (LPARAM)&tbAB);
+ tbAB.nID = IDB_STD_LARGE_COLOR;
+ nStdBitmaps = SendMessageW(hToolbar, TB_ADDBITMAP, 0, (LPARAM)&tbAB);
+ /* hhctrl.ocx bitmaps */
+ tbAB.hInst = hhctrl_hinstance;
+ tbAB.nID = IDB_HHTOOLBAR;
+ nHHBitmaps = SendMessageW(hToolbar, TB_ADDBITMAP, HHTB_NUMBITMAPS, (LPARAM)&tbAB);
+
*pdwNumButtons = 0;
+ unsupported = dwButtonFlags & (HHWIN_BUTTON_BROWSE_FWD |
+ HHWIN_BUTTON_BROWSE_BCK | HHWIN_BUTTON_NOTES | HHWIN_BUTTON_CONTENTS |
+ HHWIN_BUTTON_INDEX | HHWIN_BUTTON_SEARCH | HHWIN_BUTTON_HISTORY |
+ HHWIN_BUTTON_FAVORITES | HHWIN_BUTTON_JUMP1 | HHWIN_BUTTON_JUMP2 |
+ HHWIN_BUTTON_ZOOM | HHWIN_BUTTON_TOC_NEXT | HHWIN_BUTTON_TOC_PREV);
+ if (unsupported)
+ FIXME("got asked for unsupported buttons: %06x\n", unsupported);
+
if (dwButtonFlags & HHWIN_BUTTON_EXPAND)
- TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_EXPAND);
+ {
+ TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_EXPAND, nHHBitmaps + HHTB_EXPAND);
+ TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_CONTRACT, nHHBitmaps + HHTB_CONTRACT);
+
+ if (pHHInfo->WinType.fNotExpanded)
+ pButtons[1].fsState |= TBSTATE_HIDDEN;
+ else
+ pButtons[0].fsState |= TBSTATE_HIDDEN;
+ }
if (dwButtonFlags & HHWIN_BUTTON_BACK)
- TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_BACK);
+ TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_BACK, nHistBitmaps + HIST_BACK);
if (dwButtonFlags & HHWIN_BUTTON_FORWARD)
- TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_FORWARD);
+ TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_FORWARD, nHistBitmaps + HIST_FORWARD);
if (dwButtonFlags & HHWIN_BUTTON_STOP)
- TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_STOP);
+ TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_STOP, nHHBitmaps + HHTB_STOP);
if (dwButtonFlags & HHWIN_BUTTON_REFRESH)
- TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_REFRESH);
+ TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_REFRESH, nHHBitmaps + HHTB_REFRESH);
if (dwButtonFlags & HHWIN_BUTTON_HOME)
- TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_HOME);
+ TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_HOME, nHHBitmaps + HHTB_HOME);
if (dwButtonFlags & HHWIN_BUTTON_SYNC)
- TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_SYNC);
+ TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_SYNC, nHHBitmaps + HHTB_SYNC);
if (dwButtonFlags & HHWIN_BUTTON_OPTIONS)
- TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_OPTIONS);
+ TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_OPTIONS, nStdBitmaps + STD_PROPERTIES);
if (dwButtonFlags & HHWIN_BUTTON_PRINT)
- TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_PRINT);
-
- if (dwButtonFlags & HHWIN_BUTTON_JUMP1)
- TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_JUMP1);
-
- if (dwButtonFlags & HHWIN_BUTTON_JUMP2)
- TB_AddButton(pButtons,(*pdwNumButtons)++, IDTB_JUMP2);
-
- if (dwButtonFlags & HHWIN_BUTTON_ZOOM)
- TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_ZOOM);
-
- if (dwButtonFlags & HHWIN_BUTTON_TOC_NEXT)
- TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_TOC_NEXT);
-
- if (dwButtonFlags & HHWIN_BUTTON_TOC_PREV)
- TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_TOC_PREV);
+ TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_PRINT, nStdBitmaps + STD_PRINT);
}
static BOOL HH_AddToolbar(HHInfo *pHHInfo)
HWND hwndParent = pHHInfo->WinType.hwndHelp;
DWORD toolbarFlags;
TBBUTTON buttons[IDTB_TOC_PREV - IDTB_EXPAND];
- TBADDBITMAP tbAB;
DWORD dwStyles, dwExStyles;
DWORD dwNumButtons, dwIndex;
else
toolbarFlags = HHWIN_DEF_BUTTONS;
- TB_AddButtonsFromFlags(buttons, toolbarFlags, &dwNumButtons);
-
- dwStyles = WS_CHILDWINDOW | WS_VISIBLE | TBSTYLE_FLAT |
- TBSTYLE_WRAPABLE | TBSTYLE_TOOLTIPS | CCS_NODIVIDER;
+ dwStyles = WS_CHILDWINDOW | TBSTYLE_FLAT | TBSTYLE_WRAPABLE | TBSTYLE_TOOLTIPS | CCS_NODIVIDER;
dwExStyles = WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR;
hToolbar = CreateWindowExW(dwExStyles, TOOLBARCLASSNAMEW, NULL, dwStyles,
hhctrl_hinstance, NULL);
if (!hToolbar)
return FALSE;
+ pHHInfo->WinType.hwndToolBar = hToolbar;
SendMessageW(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(ICON_SIZE, ICON_SIZE));
SendMessageW(hToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
SendMessageW(hToolbar, WM_SETFONT, (WPARAM)pHHInfo->hFont, TRUE);
- /* FIXME: Load correct icons for all buttons */
- tbAB.hInst = HINST_COMMCTRL;
- tbAB.nID = IDB_STD_LARGE_COLOR;
- SendMessageW(hToolbar, TB_ADDBITMAP, 0, (LPARAM)&tbAB);
+ TB_AddButtonsFromFlags(pHHInfo, buttons, toolbarFlags, &dwNumButtons);
for (dwIndex = 0; dwIndex < dwNumButtons; dwIndex++)
{
SendMessageW(hToolbar, TB_ADDBUTTONSW, dwNumButtons, (LPARAM)buttons);
SendMessageW(hToolbar, TB_AUTOSIZE, 0, 0);
- ShowWindow(hToolbar, SW_SHOW);
+ if (pHHInfo->WinType.fsWinProperties & HHWIN_PROP_TRI_PANE)
+ ShowWindow(hToolbar, SW_SHOW);
- pHHInfo->WinType.hwndToolBar = hToolbar;
return TRUE;
}
{
HWND hWnd, hwndTabCtrl;
HWND hwndParent = info->WinType.hwndHelp;
- DWORD dwStyles = WS_CHILDWINDOW | WS_VISIBLE;
+ DWORD dwStyles = WS_CHILDWINDOW;
DWORD dwExStyles = WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR;
RECT rc;
+ if (navigation_visible(info))
+ dwStyles |= WS_VISIBLE;
+
NP_GetNavigationRect(info, &rc);
hWnd = CreateWindowExW(dwExStyles, szChildClass, szEmpty, dwStyles,
if (!hWnd)
return FALSE;
- SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)info);
+ SetWindowLongPtrW(hWnd, 0, (LONG_PTR)info);
- hwndTabCtrl = CreateWindowExW(dwExStyles, WC_TABCONTROLW, szEmpty, dwStyles,
+ hwndTabCtrl = CreateWindowExW(dwExStyles, WC_TABCONTROLW, szEmpty, dwStyles | WS_VISIBLE,
0, TAB_TOP_PADDING,
rc.right - TAB_RIGHT_PADDING,
rc.bottom - TAB_TOP_PADDING,
RECT rectTB, rectWND, rectNP, rectSB;
GetClientRect(info->WinType.hwndHelp, &rectWND);
- GetClientRect(info->WinType.hwndToolBar, &rectTB);
- GetClientRect(info->WinType.hwndNavigation, &rectNP);
GetClientRect(info->hwndSizeBar, &rectSB);
- rc->left = rectNP.right + rectSB.right;
- rc->top = rectTB.bottom;
+ rc->left = 0;
+ rc->top = 0;
+ if (navigation_visible(info))
+ {
+ GetClientRect(info->WinType.hwndNavigation, &rectNP);
+ rc->left += rectNP.right + rectSB.right;
+ }
+ if (info->WinType.fsWinProperties & HHWIN_PROP_TRI_PANE)
+ {
+ GetClientRect(info->WinType.hwndToolBar, &rectTB);
+ rc->top += rectTB.bottom;
+ }
rc->right = rectWND.right - rc->left;
- rc->bottom = rectWND.bottom - rectTB.bottom;
+ rc->bottom = rectWND.bottom - rc->top;
}
static BOOL HH_AddHTMLPane(HHInfo *pHHInfo)
return FALSE;
/* store the pointer to the HH info struct */
- SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)pHHInfo);
+ SetWindowLongPtrW(hWnd, 0, (LONG_PTR)pHHInfo);
ShowWindow(hWnd, SW_SHOW);
UpdateWindow(hWnd);
static BOOL AddContentTab(HHInfo *info)
{
+ HIMAGELIST hImageList;
+ HBITMAP hBitmap;
+ HWND hWnd;
+
if(info->tabs[TAB_CONTENTS].id == -1)
return TRUE; /* No "Contents" tab */
- info->tabs[TAB_CONTENTS].hwnd = CreateWindowExW(WS_EX_CLIENTEDGE, WC_TREEVIEWW,
- szEmpty, WS_CHILD | WS_BORDER | 0x25, 50, 50, 100, 100,
- info->WinType.hwndNavigation, NULL, hhctrl_hinstance, NULL);
- if(!info->tabs[TAB_CONTENTS].hwnd) {
+ hWnd = CreateWindowExW(WS_EX_CLIENTEDGE, WC_TREEVIEWW, szEmpty, WS_CHILD | WS_BORDER | TVS_LINESATROOT
+ | TVS_SHOWSELALWAYS | TVS_HASBUTTONS, 50, 50, 100, 100,
+ info->WinType.hwndNavigation, NULL, hhctrl_hinstance, NULL);
+ if(!hWnd) {
ERR("Could not create treeview control\n");
return FALSE;
}
+ hImageList = ImageList_Create(16, 16, ILC_COLOR32, 0, HHTV_NUMBITMAPS);
+ hBitmap = LoadBitmapW(hhctrl_hinstance, MAKEINTRESOURCEW(IDB_HHTREEVIEW));
+ ImageList_Add(hImageList, hBitmap, NULL);
+ SendMessageW(hWnd, TVM_SETIMAGELIST, TVSIL_NORMAL, (LPARAM)hImageList);
+
+ info->contents.hImageList = hImageList;
+ info->tabs[TAB_CONTENTS].hwnd = hWnd;
ResizeTabChild(info, TAB_CONTENTS);
- ShowWindow(info->tabs[TAB_CONTENTS].hwnd, SW_SHOW);
+ ShowWindow(hWnd, SW_SHOW);
return TRUE;
}
info->search.hwndContainer = hwndContainer;
info->tabs[TAB_SEARCH].hwnd = hwndContainer;
- SetWindowLongPtrW(hwndContainer, GWLP_USERDATA, (LONG_PTR)info);
+ SetWindowLongPtrW(hwndContainer, 0, (LONG_PTR)info);
ResizeTabChild(info, TAB_SEARCH);
static LRESULT CALLBACK HelpPopup_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- HHInfo *info = (HHInfo *)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
+ HHInfo *info = (HHInfo *)GetWindowLongPtrW(hWnd, 0);
switch (message)
{
switch(nmhdr->code)
{
case NM_DBLCLK: {
- HHInfo *info = (HHInfo*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
+ HHInfo *info = (HHInfo*)GetWindowLongPtrW(hWnd, 0);
IndexSubItem *iter;
if(info == 0 || lParam == 0)
return 0;
}
case NM_RETURN: {
- HHInfo *info = (HHInfo*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
+ HHInfo *info = (HHInfo*)GetWindowLongPtrW(hWnd, 0);
IndexSubItem *iter;
LVITEMW lvItem;
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = HelpPopup_WndProc;
wcex.cbClsExtra = 0;
- wcex.cbWndExtra = 0;
+ wcex.cbWndExtra = sizeof(LONG_PTR);
wcex.hInstance = hhctrl_hinstance;
wcex.hIcon = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION);
wcex.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW);
wcex.style = 0;
wcex.lpfnWndProc = PopupChild_WndProc;
wcex.cbClsExtra = 0;
- wcex.cbWndExtra = 0;
+ wcex.cbWndExtra = sizeof(LONG_PTR);
wcex.hInstance = hhctrl_hinstance;
wcex.hIcon = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION);
wcex.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW);
info->popup.hwndCallback = hwndCallback;
info->popup.hwndPopup = hwndPopup;
info->popup.hwndList = hwndList;
- SetWindowLongPtrW(hwndPopup, GWLP_USERDATA, (LONG_PTR)info);
- SetWindowLongPtrW(hwndCallback, GWLP_USERDATA, (LONG_PTR)info);
+ SetWindowLongPtrW(hwndPopup, 0, (LONG_PTR)info);
+ SetWindowLongPtrW(hwndCallback, 0, (LONG_PTR)info);
ResizePopupChild(info);
ShowWindow(hwndList, SW_SHOW);
/* Viewer Window */
+static void ExpandContract(HHInfo *pHHInfo)
+{
+ RECT r, nav;
+
+ pHHInfo->WinType.fNotExpanded = !pHHInfo->WinType.fNotExpanded;
+ GetWindowRect(pHHInfo->WinType.hwndHelp, &r);
+ NP_GetNavigationRect(pHHInfo, &nav);
+
+ /* hide/show both the nav bar and the size bar */
+ if (pHHInfo->WinType.fNotExpanded)
+ {
+ ShowWindow(pHHInfo->WinType.hwndNavigation, SW_HIDE);
+ ShowWindow(pHHInfo->hwndSizeBar, SW_HIDE);
+ r.left = r.left + nav.right;
+
+ SendMessageW(pHHInfo->WinType.hwndToolBar, TB_HIDEBUTTON, IDTB_EXPAND, MAKELPARAM(FALSE, 0));
+ SendMessageW(pHHInfo->WinType.hwndToolBar, TB_HIDEBUTTON, IDTB_CONTRACT, MAKELPARAM(TRUE, 0));
+ }
+ else
+ {
+ ShowWindow(pHHInfo->WinType.hwndNavigation, SW_SHOW);
+ ShowWindow(pHHInfo->hwndSizeBar, SW_SHOW);
+ r.left = r.left - nav.right;
+
+ SendMessageW(pHHInfo->WinType.hwndToolBar, TB_HIDEBUTTON, IDTB_EXPAND, MAKELPARAM(TRUE, 0));
+ SendMessageW(pHHInfo->WinType.hwndToolBar, TB_HIDEBUTTON, IDTB_CONTRACT, MAKELPARAM(FALSE, 0));
+ }
+
+ MoveWindow(pHHInfo->WinType.hwndHelp, r.left, r.top, r.right-r.left, r.bottom-r.top, TRUE);
+}
+
static LRESULT Help_OnSize(HWND hWnd)
{
- HHInfo *pHHInfo = (HHInfo *)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
+ HHInfo *pHHInfo = (HHInfo *)GetWindowLongPtrW(hWnd, 0);
DWORD dwSize;
RECT rc;
if (!pHHInfo)
return 0;
- NP_GetNavigationRect(pHHInfo, &rc);
- SetWindowPos(pHHInfo->WinType.hwndNavigation, HWND_TOP, 0, 0,
- rc.right, rc.bottom, SWP_NOMOVE);
+ if (navigation_visible(pHHInfo))
+ {
+ NP_GetNavigationRect(pHHInfo, &rc);
+ SetWindowPos(pHHInfo->WinType.hwndNavigation, HWND_TOP, 0, 0,
+ rc.right, rc.bottom, SWP_NOMOVE);
- SB_GetSizeBarRect(pHHInfo, &rc);
- SetWindowPos(pHHInfo->hwndSizeBar, HWND_TOP, rc.left, rc.top,
- rc.right, rc.bottom, SWP_SHOWWINDOW);
+ SB_GetSizeBarRect(pHHInfo, &rc);
+ SetWindowPos(pHHInfo->hwndSizeBar, HWND_TOP, rc.left, rc.top,
+ rc.right, rc.bottom, SWP_SHOWWINDOW);
+
+ }
HP_GetHTMLRect(pHHInfo, &rc);
SetWindowPos(pHHInfo->WinType.hwndHTML, HWND_TOP, rc.left, rc.top,
return 0;
}
+void UpdateHelpWindow(HHInfo *info)
+{
+ if (!info->WinType.hwndHelp)
+ return;
+
+ WARN("Only the size of the window is currently updated.\n");
+ if (info->WinType.fsValidMembers & HHWIN_PARAM_RECT)
+ {
+ RECT *rect = &info->WinType.rcWindowPos;
+ INT x, y, width, height;
+
+ x = rect->left;
+ y = rect->top;
+ width = rect->right - x;
+ height = rect->bottom - y;
+ SetWindowPos(info->WinType.hwndHelp, NULL, rect->left, rect->top, width, height,
+ SWP_NOZORDER | SWP_NOACTIVATE);
+ }
+}
+
static LRESULT CALLBACK Help_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
case WM_SIZE:
return Help_OnSize(hWnd);
case WM_CLOSE:
- ReleaseHelpViewer((HHInfo *)GetWindowLongPtrW(hWnd, GWLP_USERDATA));
+ ReleaseHelpViewer((HHInfo *)GetWindowLongPtrW(hWnd, 0));
return 0;
case WM_DESTROY:
if(hh_process)
static BOOL HH_CreateHelpWindow(HHInfo *info)
{
- HWND hWnd;
+ HWND hWnd, parent = 0;
RECT winPos = info->WinType.rcWindowPos;
WNDCLASSEXW wcex;
DWORD dwStyles, dwExStyles;
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = Help_WndProc;
wcex.cbClsExtra = 0;
- wcex.cbWndExtra = 0;
+ wcex.cbWndExtra = sizeof(LONG_PTR);
wcex.hInstance = hhctrl_hinstance;
wcex.hIcon = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION);
wcex.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW);
/* Read in window parameters if available */
if (info->WinType.fsValidMembers & HHWIN_PARAM_STYLES)
- dwStyles = info->WinType.dwStyles | WS_OVERLAPPEDWINDOW;
+ {
+ dwStyles = info->WinType.dwStyles;
+ if (!(info->WinType.dwStyles & WS_CHILD))
+ dwStyles |= WS_OVERLAPPEDWINDOW;
+ }
else
dwStyles = WS_OVERLAPPEDWINDOW | WS_VISIBLE |
WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
height = WINTYPE_DEFAULT_HEIGHT;
}
+ if (!(info->WinType.fsWinProperties & HHWIN_PROP_TRI_PANE) && info->WinType.fNotExpanded)
+ {
+ if (!(info->WinType.fsValidMembers & HHWIN_PARAM_NAV_WIDTH) &&
+ info->WinType.iNavWidth == 0)
+ {
+ info->WinType.iNavWidth = WINTYPE_DEFAULT_NAVWIDTH;
+ }
+
+ x += info->WinType.iNavWidth;
+ width -= info->WinType.iNavWidth;
+ }
+
+
caption = info->WinType.pszCaption;
if (!*caption) caption = info->pCHMInfo->defTitle;
+ if (info->WinType.dwStyles & WS_CHILD)
+ parent = info->WinType.hwndCaller;
+
hWnd = CreateWindowExW(dwExStyles, windowClassW, caption,
- dwStyles, x, y, width, height, NULL, NULL, hhctrl_hinstance, NULL);
+ dwStyles, x, y, width, height, parent, NULL, hhctrl_hinstance, NULL);
if (!hWnd)
return FALSE;
UpdateWindow(hWnd);
/* store the pointer to the HH info struct */
- SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)info);
+ SetWindowLongPtrW(hWnd, 0, (LONG_PTR)info);
info->WinType.hwndHelp = hWnd;
return TRUE;
{
LOGFONTW lf;
- GetObjectW(GetStockObject(ANSI_VAR_FONT), sizeof(LOGFONTW), &lf);
+ GetObjectW(GetStockObject(DEFAULT_GUI_FONT), sizeof(LOGFONTW), &lf);
lf.lfWeight = FW_NORMAL;
lf.lfItalic = FALSE;
lf.lfUnderline = FALSE;
InitContent(pHHInfo);
InitIndex(pHHInfo);
+ pHHInfo->viewer_initialized = TRUE;
return TRUE;
}
+void wintype_stringsW_free(struct wintype_stringsW *stringsW)
+{
+ heap_free(stringsW->pszType);
+ heap_free(stringsW->pszCaption);
+ heap_free(stringsW->pszToc);
+ heap_free(stringsW->pszIndex);
+ heap_free(stringsW->pszFile);
+ heap_free(stringsW->pszHome);
+ heap_free(stringsW->pszJump1);
+ heap_free(stringsW->pszJump2);
+ heap_free(stringsW->pszUrlJump1);
+ heap_free(stringsW->pszUrlJump2);
+}
+
+void wintype_stringsA_free(struct wintype_stringsA *stringsA)
+{
+ heap_free(stringsA->pszType);
+ heap_free(stringsA->pszCaption);
+ heap_free(stringsA->pszToc);
+ heap_free(stringsA->pszIndex);
+ heap_free(stringsA->pszFile);
+ heap_free(stringsA->pszHome);
+ heap_free(stringsA->pszJump1);
+ heap_free(stringsA->pszJump2);
+ heap_free(stringsA->pszUrlJump1);
+ heap_free(stringsA->pszUrlJump2);
+ heap_free(stringsA->pszCustomTabs);
+}
+
void ReleaseHelpViewer(HHInfo *info)
{
TRACE("(%p)\n", info);
if (!info)
return;
- /* Free allocated strings */
- heap_free(info->pszType);
- heap_free(info->pszCaption);
- heap_free(info->pszToc);
- heap_free(info->pszIndex);
- heap_free(info->pszFile);
- heap_free(info->pszHome);
- heap_free(info->pszJump1);
- heap_free(info->pszJump2);
- heap_free(info->pszUrlJump1);
- heap_free(info->pszUrlJump2);
+ list_remove(&info->entry);
+
+ wintype_stringsA_free(&info->stringsA);
+ wintype_stringsW_free(&info->stringsW);
if (info->pCHMInfo)
CloseCHM(info->pCHMInfo);
ReleaseIndex(info);
ReleaseSearch(info);
+ if(info->contents.hImageList)
+ ImageList_Destroy(info->contents.hImageList);
if(info->WinType.hwndHelp)
DestroyWindow(info->WinType.hwndHelp);
OleUninitialize();
}
-HHInfo *CreateHelpViewer(LPCWSTR filename)
+HHInfo *CreateHelpViewer(HHInfo *info, LPCWSTR filename, HWND caller)
{
- HHInfo *info = heap_alloc_zero(sizeof(HHInfo));
- int i;
+ HHInfo *tmp_info;
+ unsigned int i;
+
+ if(!info)
+ {
+ info = heap_alloc_zero(sizeof(HHInfo));
+ list_add_tail(&window_list, &info->entry);
+ }
/* Set the invalid tab ID (-1) as the default value for all
* of the tabs, this matches a failed TCM_INSERTITEM call.
ReleaseHelpViewer(info);
return NULL;
}
+ info->WinType.hwndCaller = caller;
- if(!CreateViewer(info)) {
+ /* If the window is already open then load the file in that existing window */
+ if ((tmp_info = find_window(info->WinType.pszType)) && tmp_info != info)
+ {
+ ReleaseHelpViewer(info);
+ return CreateHelpViewer(tmp_info, filename, caller);
+ }
+
+ if(!info->viewer_initialized && !CreateViewer(info)) {
ReleaseHelpViewer(info);
return NULL;
}
return info;
}
+
+/*
+ * Search the table of HTML entities and return the corresponding ANSI symbol.
+ */
+static char find_html_symbol(const char *entity, int entity_len)
+{
+ int max = sizeof(html_encoded_symbols)/sizeof(html_encoded_symbols[0])-1;
+ int min = 0, dir;
+
+ while(min <= max)
+ {
+ int pos = (min+max)/2;
+ const char *encoded_symbol = html_encoded_symbols[pos].html_code;
+ dir = strncmp(encoded_symbol, entity, entity_len);
+ if(dir == 0 && !encoded_symbol[entity_len]) return html_encoded_symbols[pos].ansi_symbol;
+ if(dir < 0)
+ min = pos+1;
+ else
+ max = pos-1;
+ }
+ return 0;
+}
+
+/*
+ * Decode a string containing HTML encoded characters into a unicode string.
+ */
+WCHAR *decode_html(const char *html_fragment, int html_fragment_len, UINT code_page)
+{
+ const char *h = html_fragment, *amp, *sem;
+ char symbol, *tmp;
+ int len, tmp_len = 0;
+ WCHAR *unicode_text;
+
+ tmp = heap_alloc(html_fragment_len+1);
+ while(1)
+ {
+ symbol = 0;
+ amp = strchr(h, '&');
+ if(!amp) break;
+ len = amp-h;
+ /* Copy the characters prior to the HTML encoded character */
+ memcpy(&tmp[tmp_len], h, len);
+ tmp_len += len;
+ amp++; /* skip ampersand */
+ sem = strchr(amp, ';');
+ /* Require a semicolon after the ampersand */
+ if(!sem)
+ {
+ h = amp;
+ tmp[tmp_len++] = '&';
+ continue;
+ }
+ /* Find the symbol either by using the ANSI character number (prefixed by the pound symbol)
+ * or by searching the HTML entity table */
+ len = sem-amp;
+ if(amp[0] == '#')
+ {
+ char *endnum = NULL;
+ int tmp;
+
+ tmp = (char) strtol(amp, &endnum, 10);
+ if(endnum == sem)
+ symbol = tmp;
+ }
+ else
+ symbol = find_html_symbol(amp, len);
+ if(!symbol)
+ {
+ FIXME("Failed to translate HTML encoded character '&%.*s;'.\n", len, amp);
+ h = amp;
+ tmp[tmp_len++] = '&';
+ continue;
+ }
+ /* Insert the new symbol */
+ h = sem+1;
+ tmp[tmp_len++] = symbol;
+ }
+ /* Convert any remaining characters */
+ len = html_fragment_len-(h-html_fragment);
+ memcpy(&tmp[tmp_len], h, len);
+ tmp_len += len;
+ tmp[tmp_len++] = 0; /* NULL-terminate the string */
+
+ len = MultiByteToWideChar(code_page, 0, tmp, tmp_len, NULL, 0);
+ unicode_text = heap_alloc(len*sizeof(WCHAR));
+ MultiByteToWideChar(code_page, 0, tmp, tmp_len, unicode_text, len);
+ heap_free(tmp);
+ return unicode_text;
+}
+
+/* Find the HTMLHelp structure for an existing window title */
+HHInfo *find_window(const WCHAR *window)
+{
+ HHInfo *info;
+
+ LIST_FOR_EACH_ENTRY(info, &window_list, HHInfo, entry)
+ {
+ if (strcmpW(info->WinType.pszType, window) == 0)
+ return info;
+ }
+ return NULL;
+}
#include <wine/debug.h>
+#include <stdarg.h>
+
+#define COBJMACROS
+
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "winnls.h"
+#include "htmlhelp.h"
+#include "ole2.h"
+#include "rpcproxy.h"
+
#define INIT_GUID
#include "hhctrl.h"
HINSTANCE hhctrl_hinstance;
BOOL hh_process = FALSE;
+extern struct list window_list;
+
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, LPVOID lpvReserved)
{
TRACE("(%p,%d,%p)\n", hInstance, fdwReason, lpvReserved);
#undef X
}
-static BOOL resolve_filename(const WCHAR *filename, WCHAR *fullname, DWORD buflen)
+static BOOL resolve_filename(const WCHAR *filename, WCHAR *fullname, DWORD buflen, WCHAR **index, WCHAR **window)
{
+ const WCHAR *extra;
+ WCHAR chm_file[MAX_PATH];
+
static const WCHAR helpW[] = {'\\','h','e','l','p','\\',0};
+ static const WCHAR delimW[] = {':',':',0};
+ static const WCHAR delim2W[] = {'>',0};
+
+ filename = skip_schema(filename);
+
+ /* the format is "helpFile[::/index][>window]" */
+ if (index) *index = NULL;
+ if (window) *window = NULL;
+
+ extra = strstrW(filename, delim2W);
+ if (extra)
+ {
+ memcpy(chm_file, filename, (extra-filename)*sizeof(WCHAR));
+ chm_file[extra-filename] = 0;
+ filename = chm_file;
+ if (window)
+ *window = strdupW(extra+1);
+ }
+
+ extra = strstrW(filename, delimW);
+ if (extra)
+ {
+ if (filename != chm_file)
+ memcpy(chm_file, filename, (extra-filename)*sizeof(WCHAR));
+ chm_file[extra-filename] = 0;
+ filename = chm_file;
+ if (index)
+ *index = strdupW(extra+2);
+ }
GetFullPathNameW(filename, buflen, fullname, NULL);
if (GetFileAttributesW(fullname) == INVALID_FILE_ATTRIBUTES)
{
case HH_DISPLAY_TOPIC:
case HH_DISPLAY_TOC:
+ case HH_DISPLAY_INDEX:
case HH_DISPLAY_SEARCH:{
- static const WCHAR delimW[] = {':',':',0};
- HHInfo *info;
BOOL res;
- WCHAR chm_file[MAX_PATH];
- const WCHAR *index;
-
- FIXME("Not all HH cases handled correctly\n");
+ NMHDR nmhdr;
+ HHInfo *info = NULL;
+ WCHAR *window = NULL;
+ const WCHAR *index = NULL;
+ WCHAR *default_index = NULL;
+ int tab_index = TAB_CONTENTS;
if (!filename)
return NULL;
- index = strstrW(filename, delimW);
- if (index)
- {
- memcpy(chm_file, filename, (index-filename)*sizeof(WCHAR));
- chm_file[index-filename] = 0;
- filename = chm_file;
- index += 2; /* advance beyond "::" for calling NavigateToChm() later */
- }
-
- if (!resolve_filename(filename, fullname, MAX_PATH))
+ if (!resolve_filename(filename, fullname, MAX_PATH, &default_index, &window))
{
WARN("can't find %s\n", debugstr_w(filename));
return 0;
}
+ index = default_index;
+
+ if (window)
+ info = find_window(window);
- info = CreateHelpViewer(fullname);
+ info = CreateHelpViewer(info, fullname, caller);
if(!info)
+ {
+ heap_free(default_index);
+ heap_free(window);
return NULL;
+ }
if(!index)
index = info->WinType.pszFile;
+ if(!info->WinType.pszType)
+ info->WinType.pszType = info->stringsW.pszType = window;
+ else
+ heap_free(window);
+
+ /* called to load a specified topic */
+ switch(command)
+ {
+ case HH_DISPLAY_TOPIC:
+ case HH_DISPLAY_TOC:
+ if (data)
+ index = (const WCHAR *)data;
+ break;
+ }
res = NavigateToChm(info, info->pCHMInfo->szFile, index);
+ heap_free(default_index);
+
if(!res)
{
ReleaseHelpViewer(info);
return NULL;
}
+
+ switch(command)
+ {
+ case HH_DISPLAY_TOPIC:
+ case HH_DISPLAY_TOC:
+ tab_index = TAB_CONTENTS;
+ break;
+ case HH_DISPLAY_INDEX:
+ tab_index = TAB_INDEX;
+ if (data)
+ FIXME("Should select keyword '%s'.\n", debugstr_w((WCHAR *)data));
+ break;
+ case HH_DISPLAY_SEARCH:
+ tab_index = TAB_SEARCH;
+ if (data)
+ FIXME("Should display search specified by HH_FTS_QUERY structure.\n");
+ break;
+ }
+ /* open the requested tab */
+ memset(&nmhdr, 0, sizeof(nmhdr));
+ nmhdr.code = TCN_SELCHANGE;
+ SendMessageW(info->hwndTabCtrl, TCM_SETCURSEL, (WPARAM)info->tabs[tab_index].id, 0);
+ SendMessageW(info->WinType.hwndNavigation, WM_NOTIFY, 0, (LPARAM)&nmhdr);
+
return info->WinType.hwndHelp;
}
case HH_HELP_CONTEXT: {
- HHInfo *info;
+ WCHAR *window = NULL;
+ HHInfo *info = NULL;
LPWSTR url;
if (!filename)
return NULL;
- if (!resolve_filename(filename, fullname, MAX_PATH))
+ if (!resolve_filename(filename, fullname, MAX_PATH, NULL, &window))
{
WARN("can't find %s\n", debugstr_w(filename));
return 0;
}
- info = CreateHelpViewer(fullname);
+ if (window)
+ info = find_window(window);
+
+ info = CreateHelpViewer(info, fullname, caller);
if(!info)
+ {
+ heap_free(window);
return NULL;
+ }
+
+ if(!info->WinType.pszType)
+ info->WinType.pszType = info->stringsW.pszType = window;
+ else
+ heap_free(window);
url = FindContextAlias(info->pCHMInfo, data);
if(!url)
}
return 0;
}
+ case HH_CLOSE_ALL: {
+ HHInfo *info, *next;
+
+ LIST_FOR_EACH_ENTRY_SAFE(info, next, &window_list, HHInfo, entry)
+ {
+ TRACE("Destroying window %s.\n", debugstr_w(info->WinType.pszType));
+ ReleaseHelpViewer(info);
+ }
+ return 0;
+ }
+ case HH_SET_WIN_TYPE: {
+ HH_WINTYPEW *wintype = (HH_WINTYPEW *)data;
+ WCHAR *window = NULL;
+ HHInfo *info = NULL;
+
+ if (!filename && wintype->pszType)
+ window = strdupW(wintype->pszType);
+ else if (!filename || !resolve_filename(filename, fullname, MAX_PATH, NULL, &window) || !window)
+ {
+ WARN("can't find window name: %s\n", debugstr_w(filename));
+ return 0;
+ }
+ info = find_window(window);
+ if (!info)
+ {
+ info = heap_alloc_zero(sizeof(HHInfo));
+ info->WinType.pszType = info->stringsW.pszType = window;
+ list_add_tail(&window_list, &info->entry);
+ }
+ else
+ heap_free(window);
+
+ TRACE("Changing WINTYPE, fsValidMembers=0x%x\n", wintype->fsValidMembers);
+
+ MergeChmProperties(wintype, info, TRUE);
+ UpdateHelpWindow(info);
+ return 0;
+ }
+ case HH_GET_WIN_TYPE: {
+ HH_WINTYPEW *wintype = (HH_WINTYPEW *)data;
+ WCHAR *window = NULL;
+ HHInfo *info = NULL;
+
+ if (!filename || !resolve_filename(filename, fullname, MAX_PATH, NULL, &window) || !window)
+ {
+ WARN("can't find window name: %s\n", debugstr_w(filename));
+ return 0;
+ }
+ info = find_window(window);
+ if (!info)
+ {
+ WARN("Could not find window named %s.\n", debugstr_w(window));
+ heap_free(window);
+ return (HWND)~0;
+ }
+
+ TRACE("Retrieving WINTYPE for %s.\n", debugstr_w(window));
+ *wintype = info->WinType;
+ heap_free(window);
+ return 0;
+ }
default:
FIXME("HH case %s not handled.\n", command_to_string( command ));
}
return 0;
}
+static void wintypeAtoW(const HH_WINTYPEA *data, HH_WINTYPEW *wdata, struct wintype_stringsW *stringsW)
+{
+ memcpy(wdata, data, sizeof(*data));
+ /* convert all of the ANSI strings to Unicode */
+ wdata->pszType = stringsW->pszType = strdupAtoW(data->pszType);
+ wdata->pszCaption = stringsW->pszCaption = strdupAtoW(data->pszCaption);
+ wdata->pszToc = stringsW->pszToc = strdupAtoW(data->pszToc);
+ wdata->pszIndex = stringsW->pszIndex = strdupAtoW(data->pszIndex);
+ wdata->pszFile = stringsW->pszFile = strdupAtoW(data->pszFile);
+ wdata->pszHome = stringsW->pszHome = strdupAtoW(data->pszHome);
+ wdata->pszJump1 = stringsW->pszJump1 = strdupAtoW(data->pszJump1);
+ wdata->pszJump2 = stringsW->pszJump2 = strdupAtoW(data->pszJump2);
+ wdata->pszUrlJump1 = stringsW->pszUrlJump1 = strdupAtoW(data->pszUrlJump1);
+ wdata->pszUrlJump2 = stringsW->pszUrlJump2 = strdupAtoW(data->pszUrlJump2);
+ wdata->pszCustomTabs = stringsW->pszCustomTabs = strdupAtoW(data->pszCustomTabs);
+}
+
+static void wintypeWtoA(const HH_WINTYPEW *wdata, HH_WINTYPEA *data, struct wintype_stringsA *stringsA)
+{
+ memcpy(data, wdata, sizeof(*wdata));
+ /* convert all of the Unicode strings to ANSI */
+ data->pszType = stringsA->pszType = strdupWtoA(wdata->pszType);
+ data->pszCaption = stringsA->pszCaption = strdupWtoA(wdata->pszCaption);
+ data->pszToc = stringsA->pszToc = strdupWtoA(wdata->pszToc);
+ data->pszIndex = stringsA->pszFile = strdupWtoA(wdata->pszIndex);
+ data->pszFile = stringsA->pszFile = strdupWtoA(wdata->pszFile);
+ data->pszHome = stringsA->pszHome = strdupWtoA(wdata->pszHome);
+ data->pszJump1 = stringsA->pszJump1 = strdupWtoA(wdata->pszJump1);
+ data->pszJump2 = stringsA->pszJump2 = strdupWtoA(wdata->pszJump2);
+ data->pszUrlJump1 = stringsA->pszUrlJump1 = strdupWtoA(wdata->pszUrlJump1);
+ data->pszUrlJump2 = stringsA->pszUrlJump2 = strdupWtoA(wdata->pszUrlJump2);
+ data->pszCustomTabs = stringsA->pszCustomTabs = strdupWtoA(wdata->pszCustomTabs);
+}
+
/******************************************************************
* HtmlHelpA (HHCTRL.OCX.14)
*/
HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD_PTR data)
{
- WCHAR *wfile = NULL, *wdata = NULL;
- DWORD len;
- HWND result;
-
- if (filename)
- {
- len = MultiByteToWideChar( CP_ACP, 0, filename, -1, NULL, 0 );
- wfile = heap_alloc(len*sizeof(WCHAR));
- MultiByteToWideChar( CP_ACP, 0, filename, -1, wfile, len );
- }
+ WCHAR *wfile = strdupAtoW( filename );
+ HWND result = 0;
if (data)
{
case HH_DISPLAY_SEARCH:
case HH_DISPLAY_TEXT_POPUP:
case HH_GET_LAST_ERROR:
- case HH_GET_WIN_TYPE:
case HH_KEYWORD_LOOKUP:
- case HH_SET_WIN_TYPE:
case HH_SYNC:
FIXME("structures not handled yet\n");
break;
+ case HH_SET_WIN_TYPE:
+ {
+ struct wintype_stringsW stringsW;
+ HH_WINTYPEW wdata;
+
+ wintypeAtoW((HH_WINTYPEA *)data, &wdata, &stringsW);
+ result = HtmlHelpW( caller, wfile, command, (DWORD_PTR)&wdata );
+ wintype_stringsW_free(&stringsW);
+ goto done;
+ }
+ case HH_GET_WIN_TYPE:
+ {
+ HH_WINTYPEW wdata;
+ HHInfo *info;
+
+ result = HtmlHelpW( caller, wfile, command, (DWORD_PTR)&wdata );
+ if (!wdata.pszType) break;
+ info = find_window(wdata.pszType);
+ if (!info) break;
+ wintype_stringsA_free(&info->stringsA);
+ wintypeWtoA(&wdata, (HH_WINTYPEA *)data, &info->stringsA);
+ goto done;
+ }
+
case HH_DISPLAY_INDEX:
case HH_DISPLAY_TOPIC:
case HH_DISPLAY_TOC:
case HH_GET_WIN_HANDLE:
case HH_SAFE_DISPLAY_TOPIC:
- len = MultiByteToWideChar( CP_ACP, 0, (const char*)data, -1, NULL, 0 );
- wdata = heap_alloc(len*sizeof(WCHAR));
- MultiByteToWideChar( CP_ACP, 0, (const char*)data, -1, wdata, len );
- break;
+ {
+ WCHAR *wdata = strdupAtoW( (const char *)data );
+ result = HtmlHelpW( caller, wfile, command, (DWORD_PTR)wdata );
+ heap_free(wdata);
+ goto done;
+ }
case HH_CLOSE_ALL:
case HH_HELP_CONTEXT:
}
}
- result = HtmlHelpW( caller, wfile, command, wdata ? (DWORD_PTR)wdata : data );
-
+ result = HtmlHelpW( caller, wfile, command, data );
+done:
heap_free(wfile);
- heap_free(wdata);
return result;
}
int len, buflen, mapid = -1;
WCHAR *filename;
char *endq = NULL;
+ HWND hwnd;
hh_process = TRUE;
ptr += strlen("mapid")+1;
space = strchr(ptr, ' ');
+ /* command line ends without number */
+ if (!space)
+ return 0;
memcpy(idtxt, ptr, space-ptr);
idtxt[space-ptr] = '\0';
mapid = atoi(idtxt);
len = endq - szCmdLine;
else
len = strlen(szCmdLine);
+
+ /* no filename given */
+ if (!len)
+ return 0;
+
buflen = MultiByteToWideChar(CP_ACP, 0, szCmdLine, len, NULL, 0) + 1;
filename = heap_alloc(buflen * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, szCmdLine, len, filename, buflen);
/* Open a specific help topic */
if(mapid != -1)
- HtmlHelpW(GetDesktopWindow(), filename, HH_HELP_CONTEXT, mapid);
+ hwnd = HtmlHelpW(GetDesktopWindow(), filename, HH_HELP_CONTEXT, mapid);
else
- HtmlHelpW(GetDesktopWindow(), filename, HH_DISPLAY_TOPIC, 0);
+ hwnd = HtmlHelpW(GetDesktopWindow(), filename, HH_DISPLAY_TOPIC, 0);
heap_free(filename);
+ if (!hwnd)
+ {
+ ERR("Failed to open HTML Help file '%s'.\n", szCmdLine);
+ return 0;
+ }
+
while (GetMessageW(&msg, 0, 0, 0))
{
TranslateMessage(&msg);
FIXME("(%s %s %p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
return CLASS_E_CLASSNOTAVAILABLE;
}
+
+/***********************************************************************
+ * DllRegisterServer (HHCTRL.OCX.@)
+ */
+HRESULT WINAPI DllRegisterServer(void)
+{
+ return __wine_register_resources( hhctrl_hinstance );
+}
+
+/***********************************************************************
+ * DllUnregisterServer (HHCTRL.OCX.@)
+ */
+HRESULT WINAPI DllUnregisterServer(void)
+{
+ return __wine_unregister_resources( hhctrl_hinstance );
+}
#include <wine/itss.h>
#include <wine/unicode.h>
+#include <wine/list.h>
#define WB_GOBACK 0
#define WB_GOFORWARD 1
#define WB_SEARCH 3
#define WB_REFRESH 4
#define WB_STOP 5
+#define WB_PRINT 6
typedef struct {
LPWSTR chm_file;
char **strings;
DWORD strings_size;
+ WCHAR *compiledFile;
+ WCHAR *defWindow;
WCHAR *defTopic;
WCHAR *defTitle;
WCHAR *defToc;
+
+ UINT codePage;
} CHMInfo;
#define TAB_CONTENTS 0
#define TAB_INDEX 1
#define TAB_SEARCH 2
#define TAB_FAVORITES 3
+#define TAB_NUMTABS TAB_FAVORITES
typedef struct {
HWND hwnd;
HWND hwndContainer;
} SearchTab;
+typedef struct {
+ HIMAGELIST hImageList;
+} ContentsTab;
+
+struct wintype_stringsW {
+ WCHAR *pszType;
+ WCHAR *pszCaption;
+ WCHAR *pszToc;
+ WCHAR *pszIndex;
+ WCHAR *pszFile;
+ WCHAR *pszHome;
+ WCHAR *pszJump1;
+ WCHAR *pszJump2;
+ WCHAR *pszUrlJump1;
+ WCHAR *pszUrlJump2;
+ WCHAR *pszCustomTabs;
+};
+
+struct wintype_stringsA {
+ char *pszType;
+ char *pszCaption;
+ char *pszToc;
+ char *pszIndex;
+ char *pszFile;
+ char *pszHome;
+ char *pszJump1;
+ char *pszJump2;
+ char *pszUrlJump1;
+ char *pszUrlJump2;
+ char *pszCustomTabs;
+};
+
typedef struct {
IOleClientSite *client_site;
IWebBrowser2 *web_browser;
HH_WINTYPEW WinType;
- LPWSTR pszType;
- LPWSTR pszCaption;
- LPWSTR pszToc;
- LPWSTR pszIndex;
- LPWSTR pszFile;
- LPWSTR pszHome;
- LPWSTR pszJump1;
- LPWSTR pszJump2;
- LPWSTR pszUrlJump1;
- LPWSTR pszUrlJump2;
- LPWSTR pszCustomTabs;
+ struct wintype_stringsA stringsA;
+ struct wintype_stringsW stringsW;
+ struct list entry;
CHMInfo *pCHMInfo;
ContentItem *content;
IndexItem *index;
IndexPopup popup;
SearchTab search;
+ ContentsTab contents;
HWND hwndTabCtrl;
HWND hwndSizeBar;
HFONT hFont;
HHTab tabs[TAB_FAVORITES+1];
+ int viewer_initialized;
DWORD current_tab;
} HHInfo;
-BOOL InitWebBrowser(HHInfo*,HWND);
-void ReleaseWebBrowser(HHInfo*);
-void ResizeWebBrowser(HHInfo*,DWORD,DWORD);
-void DoPageAction(HHInfo*,DWORD);
-
-void InitContent(HHInfo*);
-void ReleaseContent(HHInfo*);
-
-void InitIndex(HHInfo*);
-void ReleaseIndex(HHInfo*);
-
-CHMInfo *OpenCHM(LPCWSTR szFile);
-BOOL LoadWinTypeFromCHM(HHInfo *info);
-CHMInfo *CloseCHM(CHMInfo *pCHMInfo);
-void SetChmPath(ChmPath*,LPCWSTR,LPCWSTR);
-IStream *GetChmStream(CHMInfo*,LPCWSTR,ChmPath*);
-LPWSTR FindContextAlias(CHMInfo*,DWORD);
-
-HHInfo *CreateHelpViewer(LPCWSTR);
-void ReleaseHelpViewer(HHInfo*);
-BOOL NavigateToUrl(HHInfo*,LPCWSTR);
-BOOL NavigateToChm(HHInfo*,LPCWSTR,LPCWSTR);
-
-void InitSearch(HHInfo *info, const char *needle);
-void ReleaseSearch(HHInfo *info);
+BOOL InitWebBrowser(HHInfo*,HWND) DECLSPEC_HIDDEN;
+void ReleaseWebBrowser(HHInfo*) DECLSPEC_HIDDEN;
+void ResizeWebBrowser(HHInfo*,DWORD,DWORD) DECLSPEC_HIDDEN;
+void DoPageAction(HHInfo*,DWORD) DECLSPEC_HIDDEN;
+
+void InitContent(HHInfo*) DECLSPEC_HIDDEN;
+void ReleaseContent(HHInfo*) DECLSPEC_HIDDEN;
+void ActivateContentTopic(HWND,LPCWSTR,ContentItem *) DECLSPEC_HIDDEN;
+
+void InitIndex(HHInfo*) DECLSPEC_HIDDEN;
+void ReleaseIndex(HHInfo*) DECLSPEC_HIDDEN;
+
+CHMInfo *OpenCHM(LPCWSTR szFile) DECLSPEC_HIDDEN;
+BOOL LoadWinTypeFromCHM(HHInfo *info) DECLSPEC_HIDDEN;
+CHMInfo *CloseCHM(CHMInfo *pCHMInfo) DECLSPEC_HIDDEN;
+void SetChmPath(ChmPath*,LPCWSTR,LPCWSTR) DECLSPEC_HIDDEN;
+IStream *GetChmStream(CHMInfo*,LPCWSTR,ChmPath*) DECLSPEC_HIDDEN;
+LPWSTR FindContextAlias(CHMInfo*,DWORD) DECLSPEC_HIDDEN;
+WCHAR *GetDocumentTitle(CHMInfo*,LPCWSTR) DECLSPEC_HIDDEN;
+
+HHInfo *CreateHelpViewer(HHInfo*,LPCWSTR,HWND) DECLSPEC_HIDDEN;
+void ReleaseHelpViewer(HHInfo*) DECLSPEC_HIDDEN;
+BOOL NavigateToUrl(HHInfo*,LPCWSTR) DECLSPEC_HIDDEN;
+BOOL NavigateToChm(HHInfo*,LPCWSTR,LPCWSTR) DECLSPEC_HIDDEN;
+void MergeChmProperties(HH_WINTYPEW*,HHInfo*,BOOL) DECLSPEC_HIDDEN;
+void UpdateHelpWindow(HHInfo *info) DECLSPEC_HIDDEN;
+
+void InitSearch(HHInfo *info, const char *needle) DECLSPEC_HIDDEN;
+void ReleaseSearch(HHInfo *info) DECLSPEC_HIDDEN;
+
+LPCWSTR skip_schema(LPCWSTR url) DECLSPEC_HIDDEN;
+void wintype_stringsA_free(struct wintype_stringsA *stringsA) DECLSPEC_HIDDEN;
+void wintype_stringsW_free(struct wintype_stringsW *stringsW) DECLSPEC_HIDDEN;
+WCHAR *decode_html(const char *html_fragment, int html_fragment_len, UINT code_page) DECLSPEC_HIDDEN;
+HHInfo *find_window(const WCHAR *window) DECLSPEC_HIDDEN;
/* memory allocation functions */
return strdupnAtoW(str, -1);
}
+static inline LPSTR strdupWtoA(LPCWSTR str)
+{
+ LPSTR ret;
+ DWORD len;
+
+ if(!str)
+ return NULL;
+
+ len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
+ ret = heap_alloc(len);
+ WideCharToMultiByte(CP_ACP, 0, str, -1, ret, len, NULL, NULL);
+ return ret;
+}
-extern HINSTANCE hhctrl_hinstance;
-extern BOOL hh_process;
+extern HINSTANCE hhctrl_hinstance DECLSPEC_HIDDEN;
+extern BOOL hh_process DECLSPEC_HIDDEN;
#endif
* HTML Help resources
*
* Copyright 2005 James Hawkins
+ * Copyright 2011 Owen Rudge for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
//#include "htmlhelp.h"
//#include "resource.h"
-LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
-
-#include "version.rc"
-
#ifdef LANGUAGE_CS_CZ
#include "Cs.rc"
#endif
#include "Zh.rc"
#endif
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+
+/* @makedep: hhtoolbar.bmp */
+IDB_HHTOOLBAR BITMAP hhtoolbar.bmp
+
+/* @makedep: hhtreeview.bmp */
+IDB_HHTREEVIEW BITMAP hhtreeview.bmp
+
+1 TYPELIB hhctrl_tlb.tlb
+
+#define WINE_FILEDESCRIPTION_STR "Wine htmlhelp OCX"
+#define WINE_FILENAME_STR "hhctrl.ocx"
+#define WINE_FILEVERSION 5,2,3790,2744
+#define WINE_FILEVERSION_STR "5.2.3790.2744"
+#define WINE_PRODUCTVERSION 5,2,3790,2744
+#define WINE_PRODUCTVERSION_STR "5.2.3790.2744"
+
+#include <wine/wine_common_ver.rc>
--- /dev/null
+/*
+ * Typelib for hhctrl
+ *
+ * Copyright 2010 Alexandre Julliard
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+import "unknwn.idl";
+import "objidl.idl";
+import "oaidl.idl";
+
+[
+ helpstring("HHCtrl 4.0 Type Library"),
+ version(4.0),
+ uuid(adb880a2-d8ff-11cf-9377-00aa003b7a11)
+]
+library HHCTRLLib
+{
+ importlib("stdole2.tlb");
+
+ [
+ helpstring("IHHCtrl Interface"),
+ odl,
+ dual,
+ oleautomation,
+ uuid(adb880a1-d8ff-11cf-9377-00aa003b7a11)
+ ]
+ interface IHHCtrl : IDispatch
+ {
+ /* FIXME */
+ }
+
+ [
+ helpstring("Event interface for HHCtrl"),
+ uuid(adb880a3-d8ff-11cf-9377-00aa003b7a11)
+ ]
+ dispinterface _HHCtrlEvents
+ {
+ properties:
+ methods:
+ [id(0)] void Click(BSTR ParamString);
+ }
+
+ [
+ helpstring("HHCtrl Object"),
+ progid("Internet.HHCtrl.1"),
+ vi_progid("Internet.HHCtrl"),
+ threading(apartment),
+ version(1.0),
+ uuid(adb880a6-d8ff-11cf-9377-00aa003b7a11)
+ ]
+ coclass OldHHCtrl1
+ {
+ [default] interface IHHCtrl;
+ [default, source] dispinterface _HHCtrlEvents;
+ }
+
+ [
+ helpstring("HHCtrl Object"),
+ progid("Internet.HHCtrl.1"),
+ vi_progid("Internet.HHCtrl"),
+ threading(apartment),
+ version(1.0),
+ uuid(41b23c28-488e-4e5c-ace2-bb0bbabe99e8)
+ ]
+ coclass OldHHCtrl2
+ {
+ [default] interface IHHCtrl;
+ [default, source] dispinterface _HHCtrlEvents;
+ }
+
+ [
+ helpstring("HHCtrl Object"),
+ progid("Internet.HHCtrl.1"),
+ vi_progid("Internet.HHCtrl"),
+ threading(apartment),
+ version(1.0),
+ uuid(52a2aaae-085d-4187-97ea-8c30db990436)
+ ]
+ coclass HHCtrl
+ {
+ [default] interface IHHCtrl;
+ [default, source] dispinterface _HHCtrlEvents;
+ }
+}
}
}
+static void item_realloc(IndexItem *item, int num_items)
+{
+ item->nItems = num_items;
+ item->items = heap_realloc(item->items, sizeof(IndexSubItem)*item->nItems);
+ item->items[item->nItems-1].name = NULL;
+ item->items[item->nItems-1].local = NULL;
+ item->itemFlags = 0x00;
+}
+
/* Parse the attributes correspond to a list item, including sub-topics.
*
* Each list item has, at minimum, a param of type "keyword" and two
* sub-topic then there isn't really a sub-topic, the index will jump
* directly to the requested item.
*/
-static void parse_index_obj_node_param(IndexItem *item, const char *text)
+static void parse_index_obj_node_param(IndexItem *item, const char *text, UINT code_page)
{
const char *ptr;
LPWSTR *param;
- int len, wlen;
+ int len;
ptr = get_attr(text, "name", &len);
if(!ptr) {
/* Allocate a new sub-item, either on the first run or whenever a
* sub-topic has filled out both the "name" and "local" params.
*/
- if(item->itemFlags == 0x11 && (!strncasecmp("name", ptr, len) || !strncasecmp("local", ptr, len))) {
- item->nItems++;
- item->items = heap_realloc(item->items, sizeof(IndexSubItem)*item->nItems);
- item->items[item->nItems-1].name = NULL;
- item->items[item->nItems-1].local = NULL;
- item->itemFlags = 0x00;
- }
+ if(item->itemFlags == 0x11 && (!strncasecmp("name", ptr, len) || !strncasecmp("local", ptr, len)))
+ item_realloc(item, item->nItems+1);
if(!strncasecmp("keyword", ptr, len)) {
param = &item->keyword;
}else if(!item->keyword && !strncasecmp("name", ptr, len)) {
/* Some HTML Help index files use an additional "name" parameter
* rather than the "keyword" parameter. In this case, the first
- * occurance of the "name" parameter is the keyword.
+ * occurrence of the "name" parameter is the keyword.
*/
param = &item->keyword;
}else if(!strncasecmp("name", ptr, len)) {
return;
}
- wlen = MultiByteToWideChar(CP_ACP, 0, ptr, len, NULL, 0);
- *param = heap_alloc((wlen+1)*sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, ptr, len, *param, wlen);
- (*param)[wlen] = 0;
+ *param = decode_html(ptr, len, code_page);
}
/* Parse the object tag corresponding to a list item.
TRACE("%s\n", node.buf);
if(!strcasecmp(node_name.buf, "param")) {
- parse_index_obj_node_param(item, node.buf);
+ parse_index_obj_node_param(item, node.buf, info->pCHMInfo->codePage);
}else if(!strcasecmp(node_name.buf, "/object")) {
break;
}else {
strbuf_zero(&node);
}
+ if(!ret)
+ FIXME("Failed to parse <li> tag!\n");
strbuf_free(&node);
strbuf_free(&node_name);
TRACE("%s\n", node.buf);
if(!strcasecmp(node_name.buf, "li")) {
- item->next = parse_li(info, &stream);
- item->next->merge = item->merge;
- item = item->next;
- item->indentLevel = indent_level;
+ IndexItem *new_item;
+
+ new_item = parse_li(info, &stream);
+ if(new_item && item->keyword && strcmpW(new_item->keyword, item->keyword) == 0) {
+ int num_items = item->nItems;
+
+ item_realloc(item, num_items+1);
+ memcpy(&item->items[num_items], &new_item->items[0], sizeof(IndexSubItem));
+ heap_free(new_item->keyword);
+ heap_free(new_item->items);
+ heap_free(new_item);
+ } else if(new_item) {
+ item->next = new_item;
+ item->next->merge = item->merge;
+ item = item->next;
+ item->indentLevel = indent_level;
+ }
}else if(!strcasecmp(node_name.buf, "ul")) {
indent_level++;
}else if(!strcasecmp(node_name.buf, "/ul")) {
IndexItem *item = info->index, *next;
int i;
+ if(!item) return;
/* Note: item->merge is identical for all items, only free once */
heap_free(item->merge.chm_file);
heap_free(item->merge.chm_index);
#define IDS_INDEX 2
#define IDS_SEARCH 3
#define IDS_FAVORITES 4
+#define IDS_HIDETABS 5
+#define IDS_SHOWTABS 6
+
+#define MENU_POPUP 1
+
+#define IDB_HHTOOLBAR 1000
+/* IDB_HHTOOLBAR bitmaps: */
+#define HHTB_STOP 0
+#define HHTB_REFRESH 1
+#define HHTB_HOME 2
+#define HHTB_SYNC 3
+#define HHTB_CONTRACT 4
+#define HHTB_EXPAND 5
+#define HHTB_NUMBITMAPS HHTB_EXPAND
+
+#define IDB_HHTREEVIEW 1001
+/* IDB_HHTREEVIEW bitmaps: */
+#define HHTV_DOCUMENT 0
+#define HHTV_FOLDER 1
+#define HHTV_OPENFOLDER 2
+#define HHTV_NUMBITMAPS HHTV_OPENFOLDER
FIXME("Unhandled IStorage stream element.\n");
}
}
+ IEnumSTATSTG_Release(elem);
return item;
}
heap_free(buf->buf);
}
-void strbuf_append(strbuf_t *buf, const char *data, int len)
+static void strbuf_append(strbuf_t *buf, const char *data, int len)
{
if(buf->len+len > buf->size) {
buf->size = buf->len+len;
stream->str = str;
}
-BOOL stream_chr(stream_t *stream, strbuf_t *buf, char c)
+static BOOL stream_chr(stream_t *stream, strbuf_t *buf, char c)
{
BOOL b = TRUE;
ULONG i;
#ifndef HHCTRL_STREAM_H
#define HHCTRL_STREAM_H
-#define BLOCK_SIZE 0x1000
+#define BLOCK_BITS 12
+#define BLOCK_SIZE (1 << BLOCK_BITS)
+#define BLOCK_MASK (BLOCK_SIZE-1)
typedef struct {
char *buf;
ULONG p;
} stream_t;
-void strbuf_init(strbuf_t *buf);
-void strbuf_zero(strbuf_t *buf);
-void strbuf_free(strbuf_t *buf);
-void strbuf_append(strbuf_t *buf, const char *data, int len);
-void stream_init(stream_t *stream, IStream *str);
-BOOL stream_chr(stream_t *stream, strbuf_t *buf, char c);
-void get_node_name(strbuf_t *node, strbuf_t *name);
-BOOL next_content(stream_t *stream, strbuf_t *buf);
-BOOL next_node(stream_t *stream, strbuf_t *buf);
-const char *get_attr(const char *node, const char *name, int *len);
+void strbuf_init(strbuf_t *buf) DECLSPEC_HIDDEN;
+void strbuf_zero(strbuf_t *buf) DECLSPEC_HIDDEN;
+void strbuf_free(strbuf_t *buf) DECLSPEC_HIDDEN;
+void stream_init(stream_t *stream, IStream *str) DECLSPEC_HIDDEN;
+void get_node_name(strbuf_t *node, strbuf_t *name) DECLSPEC_HIDDEN;
+BOOL next_content(stream_t *stream, strbuf_t *buf) DECLSPEC_HIDDEN;
+BOOL next_node(stream_t *stream, strbuf_t *buf) DECLSPEC_HIDDEN;
+const char *get_attr(const char *node, const char *name, int *len) DECLSPEC_HIDDEN;
#endif
WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp);
-#define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
-
typedef struct IOleClientSiteImpl
{
- const IOleClientSiteVtbl *lpVtbl;
- const IOleInPlaceSiteVtbl *lpvtblOleInPlaceSite;
- const IOleInPlaceFrameVtbl *lpvtblOleInPlaceFrame;
- const IDocHostUIHandlerVtbl *lpvtblDocHostUIHandler;
+ IOleClientSite IOleClientSite_iface;
+ IOleInPlaceSite IOleInPlaceSite_iface;
+ IOleInPlaceFrame IOleInPlaceFrame_iface;
+ IDocHostUIHandler IDocHostUIHandler_iface;
/* IOleClientSiteImpl data */
IOleObject *pBrowserObject;
HWND hwndWindow;
} IOleClientSiteImpl;
-#define CLIENTSITE(x) ((IOleClientSite*) &(x)->lpVtbl)
-#define DOCHOSTUI(x) ((IDocHostUIHandler*) &(x)->lpvtblDocHostUIHandler)
-#define INPLACESITE(x) ((IOleInPlaceSite*) &(x)->lpvtblOleInPlaceSite)
-#define INPLACEFRAME(x) ((IOleInPlaceFrame*) &(x)->lpvtblOleInPlaceFrame)
+static inline IOleClientSiteImpl *impl_from_IOleClientSite(IOleClientSite *iface)
+{
+ return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleClientSite_iface);
+}
static HRESULT STDMETHODCALLTYPE Site_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppvObj)
{
- ICOM_THIS_MULTI(IOleClientSiteImpl, lpVtbl, iface);
+ IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
*ppvObj = NULL;
if (IsEqualIID(riid, &IID_IUnknown)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppvObj);
- *ppvObj = CLIENTSITE(This);
+ *ppvObj = &This->IOleClientSite_iface;
}else if(IsEqualIID(riid, &IID_IOleClientSite)) {
TRACE("(%p)->(IID_IOleClientSite %p)\n", This, ppvObj);
- *ppvObj = CLIENTSITE(This);
+ *ppvObj = &This->IOleClientSite_iface;
}else if (IsEqualIID(riid, &IID_IOleInPlaceSite)) {
TRACE("(%p)->(IID_IOleInPlaceSite %p)\n", This, ppvObj);
- *ppvObj = &(This->lpvtblOleInPlaceSite);
+ *ppvObj = &This->IOleInPlaceSite_iface;
}else if (IsEqualIID(riid, &IID_IOleInPlaceFrame)) {
TRACE("(%p)->(IID_IOleInPlaceFrame %p)\n", This, ppvObj);
- *ppvObj = &(This->lpvtblOleInPlaceSite);
+ *ppvObj = &This->IOleInPlaceSite_iface;
}else if (IsEqualIID(riid, &IID_IDocHostUIHandler)) {
TRACE("(%p)->(IID_IDocHostUIHandler %p)\n", This, ppvObj);
- *ppvObj = &(This->lpvtblDocHostUIHandler);
+ *ppvObj = &This->IDocHostUIHandler_iface;
}else {
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObj);
return E_NOINTERFACE;
static ULONG STDMETHODCALLTYPE Site_AddRef(IOleClientSite *iface)
{
- ICOM_THIS_MULTI(IOleClientSiteImpl, lpVtbl, iface);
+ IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
LONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
static ULONG STDMETHODCALLTYPE Site_Release(IOleClientSite *iface)
{
- ICOM_THIS_MULTI(IOleClientSiteImpl, lpVtbl, iface);
+ IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
LONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
Site_RequestNewObjectLayout
};
+static inline IOleClientSiteImpl *impl_from_IDocHostUIHandler(IDocHostUIHandler *iface)
+{
+ return CONTAINING_RECORD(iface, IOleClientSiteImpl, IDocHostUIHandler_iface);
+}
+
static HRESULT STDMETHODCALLTYPE UI_QueryInterface(IDocHostUIHandler *iface, REFIID riid, LPVOID *ppvObj)
{
- ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblDocHostUIHandler, iface);
+ IOleClientSiteImpl *This = impl_from_IDocHostUIHandler(iface);
- return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppvObj);
+ return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppvObj);
}
static ULONG STDMETHODCALLTYPE UI_AddRef(IDocHostUIHandler *iface)
{
- ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblDocHostUIHandler, iface);
+ IOleClientSiteImpl *This = impl_from_IDocHostUIHandler(iface);
- return IOleClientSite_AddRef(CLIENTSITE(This));
+ return IOleClientSite_AddRef(&This->IOleClientSite_iface);
}
static ULONG STDMETHODCALLTYPE UI_Release(IDocHostUIHandler * iface)
{
- ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblDocHostUIHandler, iface);
+ IOleClientSiteImpl *This = impl_from_IDocHostUIHandler(iface);
- return IOleClientSite_Release(CLIENTSITE(This));
+ return IOleClientSite_Release(&This->IOleClientSite_iface);
}
static HRESULT STDMETHODCALLTYPE UI_ShowContextMenu(IDocHostUIHandler *iface, DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved)
UI_FilterDataObject
};
+static inline IOleClientSiteImpl *impl_from_IOleInPlaceSite(IOleInPlaceSite *iface)
+{
+ return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleInPlaceSite_iface);
+}
+
static HRESULT STDMETHODCALLTYPE InPlace_QueryInterface(IOleInPlaceSite *iface, REFIID riid, LPVOID *ppvObj)
{
- ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceSite, iface);
+ IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
- return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppvObj);
+ return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppvObj);
}
static ULONG STDMETHODCALLTYPE InPlace_AddRef(IOleInPlaceSite *iface)
{
- ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceSite, iface);
+ IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
- return IOleClientSite_AddRef(CLIENTSITE(This));
+ return IOleClientSite_AddRef(&This->IOleClientSite_iface);
}
static ULONG STDMETHODCALLTYPE InPlace_Release(IOleInPlaceSite *iface)
{
- ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceSite, iface);
+ IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
- return IOleClientSite_Release(CLIENTSITE(This));
+ return IOleClientSite_Release(&This->IOleClientSite_iface);
}
static HRESULT STDMETHODCALLTYPE InPlace_GetWindow(IOleInPlaceSite *iface, HWND *lphwnd)
{
- ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceSite, iface);
+ IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
*lphwnd = This->hwndWindow;
return S_OK;
static HRESULT STDMETHODCALLTYPE InPlace_GetWindowContext(IOleInPlaceSite *iface, LPOLEINPLACEFRAME *lplpFrame, LPOLEINPLACEUIWINDOW *lplpDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
{
- ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceSite, iface);
+ IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
- *lplpFrame = INPLACEFRAME(This);
- IOleInPlaceFrame_AddRef(INPLACEFRAME(This));
+ *lplpFrame = &This->IOleInPlaceFrame_iface;
+ IOleInPlaceFrame_AddRef(&This->IOleInPlaceFrame_iface);
*lplpDoc = NULL;
static HRESULT STDMETHODCALLTYPE InPlace_OnPosRectChange(IOleInPlaceSite *iface, LPCRECT lprcPosRect)
{
- ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceSite, iface);
+ IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
IOleInPlaceObject *inplace;
if (IOleObject_QueryInterface(This->pBrowserObject, &IID_IOleInPlaceObject,
InPlace_OnPosRectChange
};
+static inline IOleClientSiteImpl *impl_from_IOleInPlaceFrame(IOleInPlaceFrame *iface)
+{
+ return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleInPlaceFrame_iface);
+}
+
static HRESULT STDMETHODCALLTYPE Frame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, LPVOID *ppvObj)
{
- ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceFrame, iface);
+ IOleClientSiteImpl *This = impl_from_IOleInPlaceFrame(iface);
- return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppvObj);
+ return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppvObj);
}
static ULONG STDMETHODCALLTYPE Frame_AddRef(IOleInPlaceFrame *iface)
{
- ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceFrame, iface);
+ IOleClientSiteImpl *This = impl_from_IOleInPlaceFrame(iface);
- return IOleClientSite_AddRef(CLIENTSITE(This));
+ return IOleClientSite_AddRef(&This->IOleClientSite_iface);
}
static ULONG STDMETHODCALLTYPE Frame_Release(IOleInPlaceFrame *iface)
{
- ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceFrame, iface);
+ IOleClientSiteImpl *This = impl_from_IOleInPlaceFrame(iface);
- return IOleClientSite_Release(CLIENTSITE(This));
+ return IOleClientSite_Release(&This->IOleClientSite_iface);
}
static HRESULT STDMETHODCALLTYPE Frame_GetWindow(IOleInPlaceFrame *iface, HWND *lphwnd)
{
- ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceFrame, iface);
+ IOleClientSiteImpl *This = impl_from_IOleInPlaceFrame(iface);
*lphwnd = This->hwndWindow;
return S_OK;
return FALSE;
iOleClientSiteImpl->ref = 1;
- iOleClientSiteImpl->lpVtbl = &MyIOleClientSiteTable;
- iOleClientSiteImpl->lpvtblOleInPlaceSite = &MyIOleInPlaceSiteTable;
- iOleClientSiteImpl->lpvtblOleInPlaceFrame = &MyIOleInPlaceFrameTable;
+ iOleClientSiteImpl->IOleClientSite_iface.lpVtbl = &MyIOleClientSiteTable;
+ iOleClientSiteImpl->IOleInPlaceSite_iface.lpVtbl = &MyIOleInPlaceSiteTable;
+ iOleClientSiteImpl->IOleInPlaceFrame_iface.lpVtbl = &MyIOleInPlaceFrameTable;
iOleClientSiteImpl->hwndWindow = hwndParent;
- iOleClientSiteImpl->lpvtblDocHostUIHandler = &MyIDocHostUIHandlerTable;
+ iOleClientSiteImpl->IDocHostUIHandler_iface.lpVtbl = &MyIDocHostUIHandlerTable;
hr = OleCreate(&CLSID_WebBrowser, &IID_IOleObject, OLERENDER_DRAW, 0,
- (IOleClientSite *)iOleClientSiteImpl, &MyIStorage,
+ &iOleClientSiteImpl->IOleClientSite_iface, &MyIStorage,
(void **)&browserObject);
- info->client_site = (IOleClientSite *)iOleClientSiteImpl;
+ info->client_site = &iOleClientSiteImpl->IOleClientSite_iface;
info->wb_object = browserObject;
if (FAILED(hr)) goto error;
if (FAILED(hr)) goto error;
hr = IOleObject_DoVerb(browserObject, OLEIVERB_SHOW, NULL,
- (IOleClientSite *)iOleClientSiteImpl,
+ &iOleClientSiteImpl->IOleClientSite_iface,
-1, hwndParent, &rc);
if (FAILED(hr)) goto error;
break;
case WB_REFRESH:
IWebBrowser2_Refresh(pWebBrowser2);
+ break;
case WB_STOP:
IWebBrowser2_Stop(pWebBrowser2);
+ break;
+ case WB_PRINT:
+ IWebBrowser2_ExecWB(pWebBrowser2, OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0);
+ break;
}
}
{
/* Exit the thread */
ExitThread(ExitStatus);
+ return STATUS_SUCCESS;
}
BOOL
SAM_USER_FIXED_DATA FixedUserData;
PSAM_DB_OBJECT DomainObject;
PSAM_DB_OBJECT UserObject;
+ UCHAR LogonHours[23];
ULONG ulSize;
ULONG ulRid;
WCHAR szRid[9];
return Status;
}
- /* FIXME: Set LogonHours attribute*/
+ /* Set LogonHours attribute*/
+ *((PUSHORT)LogonHours) = 168;
+ memset(&(LogonHours[2]), 0xff, 21);
+
+ Status = SampSetObjectAttribute(UserObject,
+ L"LogonHours",
+ REG_BINARY,
+ &LogonHours,
+ sizeof(LogonHours));
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("failed with status 0x%08lx\n", Status);
+ return Status;
+ }
+
/* FIXME: Set Groups attribute*/
/* Set LMPwd attribute*/
REG_SZ,
Buffer->All.Parameters.Buffer,
Buffer->All.Parameters.MaximumLength);
+ if (!NT_SUCCESS(Status))
+ goto done;
+ }
+
+ if (WhichFields & USER_ALL_LOGONHOURS)
+ {
+ Status = SampSetLogonHoursAttrbute(UserObject,
+ &Buffer->All.LogonHours);
+ if (!NT_SUCCESS(Status))
+ goto done;
}
if (WhichFields & (USER_ALL_PRIMARYGROUPID |
/*
FIXME:
- USER_ALL_LOGONHOURS
USER_ALL_NTPASSWORDPRESENT
USER_ALL_LMPASSWORDPRESENT
USER_ALL_PASSWORDEXPIRED
Status = SampSetUserPreferences(UserObject,
Buffer);
break;
-/*
+
case UserLogonHoursInformation:
- Status = SampSetUserLogonHours(UserObject,
- Buffer);
+ Status = SampSetLogonHoursAttrbute(UserObject,
+ &Buffer->LogonHours.LogonHours);
break;
-*/
+
case UserNameInformation:
Status = SampSetObjectAttribute(UserObject,
L"Name",
}
+VOID
+NTAPI
+SamIFree_SAMPR_ENUMERATION_BUFFER(PSAMPR_ENUMERATION_BUFFER Ptr)
+{
+ ULONG i;
+
+ if (Ptr != NULL)
+ {
+ if (Ptr->Buffer != NULL)
+ {
+ for (i = 0; i < Ptr->EntriesRead; i++)
+ {
+ if (Ptr->Buffer[i].Name.Buffer != NULL)
+ MIDL_user_free(Ptr->Buffer[i].Name.Buffer);
+ }
+
+ MIDL_user_free(Ptr->Buffer);
+ }
+
+ MIDL_user_free(Ptr);
+ }
+}
+
+
VOID
NTAPI
SamIFree_SAMPR_PSID_ARRAY(PSAMPR_PSID_ARRAY Ptr)
NTSTATUS
SampGetLogonHoursAttrbute(IN PSAM_DB_OBJECT UserObject,
+ IN OUT PSAMPR_LOGON_HOURS LogonHours);
+
+NTSTATUS
+SampSetLogonHoursAttrbute(IN PSAM_DB_OBJECT UserObject,
IN PSAMPR_LOGON_HOURS LogonHours);
/* EOF */
@ stub SamIFree_SAMPR_ALIAS_INFO_BUFFER
@ stub SamIFree_SAMPR_DISPLAY_INFO_BUFFER
@ stub SamIFree_SAMPR_DOMAIN_INFO_BUFFER
-@ stub SamIFree_SAMPR_ENUMERATION_BUFFER
+@ stdcall SamIFree_SAMPR_ENUMERATION_BUFFER(ptr)
@ stub SamIFree_SAMPR_GET_GROUPS_BUFFER
@ stub SamIFree_SAMPR_GET_MEMBERS_BUFFER
@ stub SamIFree_SAMPR_GROUP_INFO_BUFFER
@ stub SamIGetBootKeyInformation
@ stub SamIGetDefaultAdministratorName
@ stub SamIGetFixedAttributes
-@ stub SamIGetinterdomainTrustAccountPasswordsForUpgrade
+@ stub SamIGetInterdomainTrustAccountPasswordsForUpgrade
@ stub SamIGetPrivateData
@ stub SamIGetResourceGroupmembershipsTransitive
@ stub SamIGetSerialNumberDomain
-@ stub SamIGetuserLogonInformation
-@ stub SamIGetuserLogonInformation2
-@ stub SamIGetuserLogonInformationEx
+@ stub SamIGetUserLogonInformation
+@ stub SamIGetUserLogonInformation2
+@ stub SamIGetUserLogonInformationEx
@ stub SamIImpersonateNullSession
@ stub SamIIncrementPerformanceCounter
@ stdcall SamIInitialize()
NTSTATUS
SampGetLogonHoursAttrbute(IN PSAM_DB_OBJECT UserObject,
- IN PSAMPR_LOGON_HOURS LogonHours)
+ IN OUT PSAMPR_LOGON_HOURS LogonHours)
{
PUCHAR RawBuffer = NULL;
ULONG Length = 0;
return Status;
}
+
+NTSTATUS
+SampSetLogonHoursAttrbute(IN PSAM_DB_OBJECT UserObject,
+ IN PSAMPR_LOGON_HOURS LogonHours)
+{
+ PUCHAR RawBuffer = NULL;
+ ULONG BufferLength;
+ ULONG Length = 0;
+ NTSTATUS Status;
+
+ if (LogonHours->UnitsPerWeek > 0)
+ {
+ BufferLength = (((ULONG)LogonHours->UnitsPerWeek) + 7) / 8;
+
+ Length = BufferLength + sizeof(USHORT);
+
+ RawBuffer = midl_user_allocate(Length);
+ if (RawBuffer == NULL)
+ {
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ goto done;
+ }
+
+ *((PUSHORT)RawBuffer) = LogonHours->UnitsPerWeek;
+
+ memcpy(&(RawBuffer[2]),
+ LogonHours->LogonHours,
+ BufferLength);
+ }
+
+ Status = SampSetObjectAttribute(UserObject,
+ L"LogonHours",
+ REG_BINARY,
+ RawBuffer,
+ Length);
+
+done:
+ if (RawBuffer != NULL)
+ midl_user_free(RawBuffer);
+
+ return Status;
+}
+
/* EOF */
PKSEVENT_ENTRY EventEntry;
PLIST_ENTRY Entry;
- /* get current irp stack location */
- IoStack = IoGetCurrentIrpStackLocation(Ctx->Irp);
-
- /* get event data */
- EventData = (PKSEVENTDATA)IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
-
if (!Ctx || !Ctx->List || !Ctx->FileObject || !Ctx->Irp)
{
/* invalid parameter */
return FALSE;
}
+ /* get current irp stack location */
+ IoStack = IoGetCurrentIrpStackLocation(Ctx->Irp);
+
+ /* get event data */
+ EventData = (PKSEVENTDATA)IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
+
/* point to first entry */
Entry = Ctx->List->Flink;
if (IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY &&
IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_METHOD &&
- IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY)
+ IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_ENABLE_EVENT &&
+ IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_DISABLE_EVENT)
{
if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KS_RESET_STATE)
{
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS RTL8139 Driver
+ * FILE: include/8139.h
+ * PURPOSE: 8139 NIC definitions
+ */
+
+#pragma once
+//Register addresses
+#define R_MAC 0x00 //MAC address uses bytes 0-5, 6 and 7 are reserved
+#define R_MCAST0 0x08 //Multicast registers
+#define R_MCAST1 0x09 //Multicast registers
+#define R_MCAST2 0x0A
+#define R_MCAST3 0x0B
+#define R_MCAST4 0x0C
+#define R_MCAST5 0x0D
+#define R_MCAST6 0x0E
+#define R_MCAST7 0x0F
+#define R_TXSTS0 0x10 //TX status, 0x10-0x13, 4 bytes
+#define R_TXSTS1 0x14
+#define R_TXSTS2 0x18
+#define R_TXSTS3 0x1C
+#define R_TXSAD0 0x20 //TX start address of descriptor 0
+#define R_TXSAD1 0x24
+#define R_TXSAD2 0x28
+#define R_TXSAD3 0x2C
+#define R_RXSA 0x30 //RX buffer start address
+#define R_ERXBC 0x34 //Early RX byte count register
+#define R_ERXSTS 0x36 //Early RX status register
+
+#define R_CMD 0x37 //Command register
+#define B_CMD_TXE 0x04 //Enable TX
+#define B_CMD_RXE 0x08 //Enable RX
+#define B_CMD_RST 0x10 //Reset bit
+
+#define R_CAPR 0x38 //Current address of packet read
+#define R_CBA 0x3A //Current buffer address
+#define R_IM 0x3C //Interrupt mask register
+#define R_IS 0x3E //Interrupt status register
+#define R_TC 0x40 //Transmit configuration register
+
+#define R_RC 0x44 //Receive configuration register
+#define B_RC_AAP 0x01 //Accept all packets
+#define B_RC_APM 0x02 //Accept packets sent to device MAC
+#define B_RC_AM 0x04 //Accept multicast packets
+#define B_RC_AB 0x08 //Accept broadcast packets
+#define B_RC_AR 0x10 //Accept runt (smaller than 64bytes) packets
+
+#define R_TCTR 0x48 //Timer counter register
+#define R_MPC 0x4C //Missed packet counter
+#define R_9346CR 0x50 //93C46 command register
+#define R_CFG0 0x51 //Configuration register 0
+#define R_CFG1 0x52
+#define R_TINTR 0x54 //Timer interrupt register
+#define R_MS 0x58 //Media status register
+#define R_CFG3 0x59 //Configuration register 3
+#define R_CFG4 0x5A //Configuration register 4
+#define R_MINTS 0x5C //Multiple interrupt select
+#define R_PCIID 0x5E //PCI Revision ID = 0x10
+#define R_DTSTS 0x60 //TX status of all descriptors
+#define R_BMC 0x62 //Basic mode control register
+#define R_BMSTS 0x64 //Basic mode status register
+#define R_ANA 0x66 //Auto-negotiation advertisement
+#define R_ANLP 0x68 //Auto-negotiation link partner
+#define R_ANEX 0x6A //Auto-negotiation expansion
+#define R_DCTR 0x6C //Disconnect counter
+#define R_FCSCTR 0x6E //False carrier sense counter
+#define R_NWT 0x70 //N-way test register
+#define R_RXERRCTR 0x72 //RX error counter
+#define R_CSCFG 0x74 //CS configuration register
+#define R_PHYP1 0x78 //PHY parameter 1
+#define R_TWP 0x7C //Twister parameter
+#define R_PHYP2 0x80 //PHY parameter 2
+#define R_PCRC0 0x84 //Power management CRC for wakeup frame 0
+#define R_PCRC1 0x85
+#define R_PCRC2 0x86
+#define R_PCRC3 0x87
+#define R_PCRC4 0x88
+#define R_PCRC5 0x89
+#define R_PCRC6 0x8A
+#define R_PCRC7 0x8B
+#define R_WAKE0 0x8C //Power management wakeup frame 0
+#define R_WAKE1 0x94
+#define R_WAKE2 0x9C
+#define R_WAKE3 0xA4
+#define R_WAKE4 0xAC
+#define R_WAKE5 0xB4
+#define R_WAKE6 0xBC
+#define R_WAKE7 0xC4
+#define R_LSBCRC0 0xCC //LSB of the mask byte of wakeup frame 0 within offset 12 to 75
+#define R_LSBCRC0 0xCD
+#define R_LSBCRC0 0xCE
+#define R_LSBCRC0 0xCF
+#define R_LSBCRC0 0xD0
+#define R_LSBCRC0 0xD1
+#define R_LSBCRC0 0xD2
+#define R_LSBCRC0 0xD3
+#define R_CFG5 0xD8 //Configuration register 5
+
+//EEPROM Control Bytes
+#define EE_DATA_READ 0x01 //Chip data out
+#define EE_DATA_WRITE 0x02 //Chip data in
+#define EE_SHIFT_CLK 0x04 //Chip shift clock
+#define EE_CS 0x08 //Chip select
+#define EE_ENB 0x88 //Chip enable
+
+
+//EEPROM Commands
+#define EE_READ_CMD 0x06
+
+
+/* NIC prepended structure to a received packet */
+typedef struct _PACKET_HEADER {
+ UCHAR Status; /* See RSR_* constants */
+ UCHAR NextPacket; /* Pointer to next packet in chain */
+ USHORT PacketLength; /* Length of packet including this header */
+} PACKET_HEADER, *PPACKET_HEADER;
+
+#define IEEE_802_ADDR_LENGTH 6
+
+/* Ethernet frame header */
+typedef struct _ETH_HEADER {
+ UCHAR Destination[IEEE_802_ADDR_LENGTH];
+ UCHAR Source[IEEE_802_ADDR_LENGTH];
+ USHORT PayloadType;
+} ETH_HEADER, *PETH_HEADER;
+
+typedef struct _DISCARD_HEADER {
+ PACKET_HEADER HWHeader;
+ ETH_HEADER EthernetHeader;
+} DISCARD_HEADER, *PDISCARD_HEADER;
+
+#define NICDisableInterrupts(Adapter) { \
+ NDIS_DbgPrint(MAX_TRACE, ("NICDisableInterrupts()\n")); \
+ NdisRawWritePortUchar((Adapter)->IOBase + PG0_IMR, 0x00); \
+}
+
+#define NICEnableInterrupts(Adapter) { \
+ NDIS_DbgPrint(MAX_TRACE, ("NICEnableInterrupts() Mask (0x%X)\n", (Adapter)->InterruptMask)); \
+ NdisRawWritePortUchar((Adapter)->IOBase + PG0_IMR, (Adapter)->InterruptMask); \
+}
+
+VOID NTAPI MiniportHandleInterrupt(
+ IN NDIS_HANDLE MiniportAdapterContext);
+
+/* EOF */
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS Novell Eagle 2000 driver
+ * FILE: include/debug.h
+ * PURPOSE: Debugging support macros
+ * DEFINES: DBG - Enable debug output
+ * NASSERT - Disable assertions
+ */
+
+#pragma once
+
+#define NORMAL_MASK 0x000000FF
+#define SPECIAL_MASK 0xFFFFFF00
+#define MIN_TRACE 0x00000001
+#define MID_TRACE 0x00000002
+#define MAX_TRACE 0x00000003
+
+#define DEBUG_MEMORY 0x00000100
+#define DEBUG_ULTRA 0xFFFFFFFF
+
+#if DBG
+
+extern ULONG DebugTraceLevel;
+
+#ifdef _MSC_VER
+
+#define NDIS_DbgPrint(_t_, _x_) \
+ if (((DebugTraceLevel & NORMAL_MASK) >= _t_) || \
+ ((DebugTraceLevel & _t_) > NORMAL_MASK)) { \
+ DbgPrint("(%s:%d) ", __FILE__, __LINE__); \
+ DbgPrint _x_ ; \
+ }
+
+#else /* _MSC_VER */
+
+#define NDIS_DbgPrint(_t_, _x_) \
+ if (((DebugTraceLevel & NORMAL_MASK) >= _t_) || \
+ ((DebugTraceLevel & _t_) > NORMAL_MASK)) { \
+ DbgPrint("(%s:%d)(%s) ", __FILE__, __LINE__, __FUNCTION__); \
+ DbgPrint _x_ ; \
+ }
+
+#endif /* _MSC_VER */
+
+
+#define ASSERT_IRQL(x) ASSERT(KeGetCurrentIrql() <= (x))
+#define ASSERT_IRQL_EQUAL(x) ASSERT(KeGetCurrentIrql() == (x))
+
+#else /* DBG */
+
+#define NDIS_DbgPrint(_t_, _x_)
+
+#define ASSERT_IRQL(x)
+#define ASSERT_IRQL_EQUAL(x)
+/* #define ASSERT(x) */ /* ndis.h */
+
+#endif /* DBG */
+
+
+#define assert(x) ASSERT(x)
+#define assert_irql(x) ASSERT_IRQL(x)
+
+
+#ifdef _MSC_VER
+
+#define UNIMPLEMENTED \
+ NDIS_DbgPrint(MIN_TRACE, ("The function at %s:%d is unimplemented, \
+ but come back another day.\n", __FILE__, __LINE__));
+
+#else /* _MSC_VER */
+
+#define UNIMPLEMENTED \
+ NDIS_DbgPrint(MIN_TRACE, ("%s at %s:%d is unimplemented, \
+ but come back another day.\n", __FUNCTION__, __FILE__, __LINE__));
+
+#endif /* _MSC_VER */
+
+
+#define CHECKPOINT \
+ do { NDIS_DbgPrint(MIN_TRACE, ("%s:%d\n", __FILE__, __LINE__)); } while(0);
+
+/* EOF */
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS Novell Eagle 2000 driver
+ * FILE: include/ne2000.h
+ * PURPOSE: NE2000 driver definitions
+ */
+
+#define NDIS_MINIPORT_DRIVER 1
+#define NDIS_LEGACY_MINIPORT 1
+#define NDIS51_MINIPORT 1
+#include <ndis.h>
+#include <8139.h>
+#include <debug.h>
+
+/* Define NOCARD to test NDIS without a card */
+//#define NOCARD
+
+/* NE2000 sepcific constants */
+#define NIC_DATA 0x10 /* Data register */
+#define NIC_RESET 0x1F /* Reset register */
+
+
+/* Global constants */
+
+#define DRIVER_NDIS_MAJOR_VERSION 0x05
+#define DRIVER_NDIS_MINOR_VERSION 0
+
+#define DRIVER_DEFAULT_IO_BASE_ADDRESS 0x280 /* bochs default */
+#define DRIVER_DEFAULT_INTERRUPT_NUMBER 9 /* bochs default */
+#define DRIVER_DEFAULT_INTERRUPT_SHARED FALSE
+#define DRIVER_DEFAULT_INTERRUPT_MODE NdisInterruptLatched
+
+#define DRIVER_MAX_MULTICAST_LIST_SIZE 8
+
+#define DRIVER_VENDOR_DESCRIPTION "RTL 8139 Adapter."
+#define DRIVER_VENDOR_DRIVER_VERSION 0x0100 /* 1.0 */
+
+#define DRIVER_FRAME_SIZE 1514 /* Size of an ethernet frame */
+#define DRIVER_HEADER_SIZE 14 /* Size of an ethernet header */
+#define DRIVER_LENGTH_OF_ADDRESS 6 /* Size of an ethernet address */
+
+/* Maximum lookahead buffer size */
+#define DRIVER_MAXIMUM_LOOKAHEAD (252 - DRIVER_HEADER_SIZE)
+
+/* Size of a block in a buffer ring */
+#define DRIVER_BLOCK_SIZE 256
+
+
+/* Default number of transmit buffers */
+#define DRIVER_DEFAULT_TX_BUFFER_COUNT 12
+#define BUFFERS_PER_TX_BUF 1
+
+/* Interrupt Mask Register value */
+#define DRIVER_INTERRUPT_MASK IMR_ALLE - IMR_RDCE
+
+/* Maximum number of interrupts handled per call to MiniportHandleInterrupt */
+#define INTERRUPT_LIMIT 10
+
+/* Global structures */
+
+typedef struct _MINIPORT_RESERVED
+{
+ PNDIS_PACKET Next;
+} MINIPORT_RESERVED, *PMINIPORT_RESERVED;
+
+#define RESERVED(Packet) ((PMINIPORT_RESERVED)((Packet)->MiniportReserved))
+
+typedef UCHAR DRIVER_HARDWARE_ADDRESS[DRIVER_LENGTH_OF_ADDRESS];
+
+/* Information about an adapter */
+typedef struct _NIC_ADAPTER
+{
+ /* Entry on global adapter list */
+ LIST_ENTRY ListEntry;
+ /* Adapter handle */
+ NDIS_HANDLE MiniportAdapterHandle;
+ /* NDIS interrupt object */
+ NDIS_MINIPORT_INTERRUPT Interrupt;
+
+ /* I/O base address and interrupt number of adapter */
+ ULONG_PTR IoBaseAddress;
+ ULONG InterruptLevel;
+ ULONG InterruptVector;
+ BOOLEAN InterruptShared;
+ KINTERRUPT_MODE InterruptMode;
+
+ /* Mapped address of the I/O base port */
+ PUCHAR IOBase;
+
+ /* TRUE if the NIC can transfer in word mode */
+ BOOLEAN WordMode;
+
+ /* Base address and size of the onboard memory window */
+ PUCHAR RamBase;
+ UINT RamSize;
+
+ /* Station Address PROM (SAPROM) */
+ UCHAR SAPROM[16];
+
+ /* Onboard ethernet address from the manufacturer */
+ DRIVER_HARDWARE_ADDRESS PermanentAddress;
+
+ /* Ethernet address currently in use */
+ DRIVER_HARDWARE_ADDRESS StationAddress;
+
+ /* Maximum number of multicast addresses this adapter supports */
+ ULONG MaxMulticastListSize;
+
+ /* List of multicast addresses in use */
+ DRIVER_HARDWARE_ADDRESS Addresses[DRIVER_MAX_MULTICAST_LIST_SIZE];
+
+ /* Current multicast address mask */
+ UCHAR MulticastAddressMask[8];
+
+ /* Masked interrupts (IMR value) */
+ ULONG InterruptMask;
+
+ /* Interrupts that have occurred */
+ UCHAR InterruptStatus;
+
+ /* Current packet filter */
+ ULONG PacketFilter;
+
+ /* Lookahead buffer */
+ UINT LookaheadSize;
+ UCHAR Lookahead[DRIVER_MAXIMUM_LOOKAHEAD + DRIVER_HEADER_SIZE];
+
+ /* Receive buffer ring */
+ UINT PageStart;
+ UINT PageStop;
+ UINT CurrentPage;
+ UINT NextPacket;
+
+ /* TRUE if there was a buffer overflow */
+ BOOLEAN BufferOverflow;
+
+ /* TRUE if an error occurred during reception of a packet */
+ BOOLEAN ReceiveError;
+
+ /* TRUE if an error occurred during transmission of a packet */
+ BOOLEAN TransmitError;
+
+ /* TRUE if a transmit interrupt is pending */
+ BOOLEAN TransmitPending;
+
+ /* Received packet header */
+ PACKET_HEADER PacketHeader;
+
+ /* Offset in onboard RAM of received packet */
+ ULONG PacketOffset;
+
+ /* TRUE if receive indications are done and should be completed */
+ BOOLEAN DoneIndicating;
+
+ /* Transmit buffers */
+ UINT TXStart; /* Start block of transmit buffer ring */
+ UINT TXCount; /* Number of blocks in transmit buffer ring */
+ UINT TXFree; /* Number of free transmit buffers */
+ UINT TXNext; /* Next buffer to use */
+ /* Length of packet. 0 means buffer is unused */
+ UINT TXSize[DRIVER_DEFAULT_TX_BUFFER_COUNT];
+ INT TXCurrent; /* Current buffer beeing transmitted. -1 means none */
+
+ /* Head of transmit queue */
+ PNDIS_PACKET TXQueueHead;
+ /* Tail of transmit queue */
+ PNDIS_PACKET TXQueueTail;
+
+ /* Statistics */
+ ULONG FrameAlignmentErrors;
+ ULONG CrcErrors;
+ ULONG MissedPackets;
+
+ /* Flags used for driver cleanup */
+ BOOLEAN IOPortRangeRegistered;
+ BOOLEAN InterruptRegistered;
+ BOOLEAN ShutdownHandlerRegistered;
+} NIC_ADAPTER, *PNIC_ADAPTER;
+
+/* Global driver information */
+typedef struct _DRIVER_INFORMATION
+{
+ NDIS_HANDLE NdisWrapperHandle; /* Returned from NdisInitializeWrapper */
+ NDIS_HANDLE NdisMacHandle; /* Returned from NdisRegisterMac */
+ LIST_ENTRY AdapterListHead; /* Adapters this driver control */
+} DRIVER_INFORMATION, *PDRIVER_INFORMATION;
+
+
+
+/* Global variable */
+
+extern DRIVER_INFORMATION DriverInfo;
+extern NDIS_PHYSICAL_ADDRESS HighestAcceptableMax;
+
+
+
+/* Prototypes */
+
+BOOLEAN NICCheck(
+ PNIC_ADAPTER Adapter);
+
+NDIS_STATUS NICInitialize(
+ PNIC_ADAPTER Adapter);
+
+NDIS_STATUS NICSetup(
+ PNIC_ADAPTER Adapter);
+
+NDIS_STATUS NICStart(
+ PNIC_ADAPTER Adapter);
+
+NDIS_STATUS NICStop(
+ PNIC_ADAPTER Adapter);
+
+NDIS_STATUS NICReset(
+ PNIC_ADAPTER Adapter);
+
+VOID NICUpdateCounters(
+ PNIC_ADAPTER Adapter);
+
+VOID NICReadDataAlign(
+ PNIC_ADAPTER Adapter,
+ PUSHORT Target,
+ ULONG_PTR Source,
+ USHORT Length);
+
+VOID NICWriteDataAlign(
+ PNIC_ADAPTER Adapter,
+ ULONG_PTR Target,
+ PUSHORT Source,
+ USHORT Length);
+
+VOID NICReadData(
+ PNIC_ADAPTER Adapter,
+ PUCHAR Target,
+ ULONG_PTR Source,
+ USHORT Length);
+
+VOID NICWriteData(
+ PNIC_ADAPTER Adapter,
+ ULONG_PTR Target,
+ PUCHAR Source,
+ USHORT Length);
+
+VOID NICTransmit(
+ PNIC_ADAPTER Adapter);
+
+/* EOF */
filter_wavecyclic.cpp
filter_wavepci.cpp
filter_wavert.cpp
- guids.cpp
interrupt.cpp
irp.cpp
irpstream.cpp
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS Kernel Streaming
- * FILE: drivers/wdm/audio/backpln/portcls/guids.cpp
- * PURPOSE: portcls guid mess
- * PROGRAMMER: Johannes Anderwald
- */
-
-#ifdef _MSC_VER
-#define PUT_GUIDS_HERE
-#endif
-#include "private.hpp"
-
-#ifndef _MSC_VER
-const GUID CLSID_PortTopology = {0xb4c90a32L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
-const GUID CLSID_PortMidi = {0xb4c90a43L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
-const GUID CLSID_PortWaveCyclic = {0xb4c90a2aL, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
-const GUID CLSID_PortWavePci = {0xb4c90a54L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
-const GUID CLSID_PortDMus = {0xb7902fe9L, 0xfb0a, 0x11d1, {0x81, 0xb0, 0x00, 0x60, 0x08, 0x33, 0x16, 0xc1}};
-const GUID CLSID_PortWaveRT = {0xcc9be57a, 0xeb9e, 0x42b4, {0x94, 0xfc, 0xc, 0xad, 0x3d, 0xbc, 0xe7, 0xfa}};
-
-const GUID IID_IMiniportDMus = {0xc096df9dL, 0xfb09, 0x11d1, {0x81, 0xb0, 0x00, 0x60, 0x08, 0x33, 0x16, 0xc1}};
-const GUID IID_IMiniportTopology = {0xb4c90a31L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
-const GUID IID_IMiniportMidi = {0xb4c90a41L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
-const GUID IID_IMiniportWavePci = {0xb4c90a52L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
-
-const GUID IID_IPortTopology = {0xb4c90a30L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
-
-const GUID CLSID_MiniportDriverDMusUART = {0xd3f0ce1c, 0xfffc, 0x11d1, {0x81, 0xb0, 0x00, 0x60, 0x08, 0x33, 0x16, 0xc1}};
-const GUID CLSID_MiniportDriverDMusUARTCapture = {0xd3f0ce1d, 0xfffc, 0x11d1, {0x81, 0xb0, 0x00, 0x60, 0x08, 0x33, 0x16, 0xc1}};
-const GUID CLSID_MiniportDriverUart = {0xb4c90ae1L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
-
-const GUID CLSID_MiniportDriverFmSynth = {0xb4c90ae0L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
-const GUID CLSID_MiniportDriverFmSynthWithVol = {0xe5a3c139L, 0xf0f2, 0x11d1, {0x81, 0xaf, 0x00, 0x60, 0x08, 0x33, 0x16, 0xc1}};
-
-const GUID IID_IPort = {0xb4c90a25L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
-const GUID IID_IDrmPort = {0x286D3DF8L, 0xCA22, 0x4E2E, {0xB9, 0xBC, 0x20, 0xB4, 0xF0, 0xE2, 0x01, 0xCE}};
-const GUID IID_IDrmPort2 = {0x1ACCE59CL, 0x7311, 0x4B6B, {0x9F, 0xBA, 0xCC, 0x3B, 0xA5, 0x9A, 0xCD, 0xCE}};
-const GUID IID_IInterruptSync = {0x22C6AC63L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE}};
-const GUID IID_IPortWavePci = {0xb4c90a50L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
-const GUID IID_IPortWavePciStream = {0xb4c90a51L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
-const GUID IID_IPortMidi = {0xb4c90a40L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
-const GUID IID_IPortDMus = {0xc096df9cL, 0xfb09, 0x11d1, {0x81, 0xb0, 0x00, 0x60, 0x08, 0x33, 0x16, 0xc1}};
-const GUID IID_IAdapterPowerManagement = {0x793417D0L, 0x35FE, 0x11D1, {0xAD, 0x08, 0x00, 0xA0, 0xC9, 0x0A, 0xB1, 0xB0}};
-
-const GUID IID_IMiniport = {0xb4c90a24, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
-const GUID IID_IMiniportWaveCyclic = {0xb4c90a27L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
-const GUID IID_IPortWaveCyclic = {0xb4c90a26L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
-const GUID IID_IResourceList = {0x22C6AC60L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE}};
-const GUID IID_IServiceGroup = {0x22C6AC65L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE}};
-const GUID IID_IPinCount = {0x5dadb7dcL, 0xa2cb, 0x4540, {0xa4, 0xa8, 0x42, 0x5e, 0xe4, 0xae, 0x90, 0x51}};
-const GUID IID_IPowerNotify = {0x3DD648B8L, 0x969F, 0x11D1, {0x95, 0xA9, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0xD3}};
-const GUID IID_IDmaChannelSlave = {0x22C6AC62L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE}};
-const GUID IID_IDmaChannel = {0x22C6AC61L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE}};
-const GUID IID_IRegistryKey = {0xE8DA4302l, 0xF304, 0x11D0, {0x95, 0x8B, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0xD3}};
-const GUID IID_IServiceSink = {0x22C6AC64L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE}};
-const GUID IID_IPortClsVersion = {0x7D89A7BBL, 0x869B, 0x4567, {0x8D, 0xBE, 0x1E, 0x16, 0x8C, 0xC8, 0x53, 0xDE}};
-const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x46}};
-const GUID IID_IPortEvents = {0xA80F29C4L, 0x5498, 0x11D2, {0x95, 0xD9, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0xD3}};
-const GUID IID_IMusicTechnology = {0x80396C3C, 0xCBCB, 0x409B, {0x9F, 0x65, 0x4F, 0x1E, 0x74, 0x67, 0xCD, 0xAF}};
-
-const GUID KSNAME_PIN = {0x146F1A80, 0x4791, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
-const GUID IID_IDrmAudioStream = {0x1915c967, 0x3299, 0x48cb, {0xa3, 0xe4, 0x69, 0xfd, 0x1d, 0x1b, 0x30, 0x6e}};
-
-//FIXME
-//
-const GUID KS_CATEGORY_AUDIO = {0x6994AD04, 0x93EF, 0x11D0, {0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
-const GUID KS_CATEGORY_RENDER = {0x65E8773E, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
-const GUID KS_CATEGORY_CAPTURE = {0x65E8773D, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
-const GUID KS_CATEGORY_TOPOLOGY = {0xDDA54A40, 0x1E4C, 0x11D1, {0xA0, 0x50, 0x40, 0x57, 0x05, 0xC1, 0x00, 0x00}};
-
-///
-/// undocumented guids
-
-const GUID IID_ISubdevice = {0xB4C90A61, 0x5791, 0x11D0, {0x86, 0xF9, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44}};
-const GUID IID_IIrpTarget = {0xB4C90A60, 0x5791, 0x11D0, {0xF9, 0x86, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44}};
-const GUID IID_IIrpTargetFactory = {0xB4C90A62, 0x5791, 0x11D0, {0xF9, 0x86, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44}};
-
-
-///
-/// >= Vista GUIDs
-///
-const GUID IID_IPortWaveRT = {0x339ff909, 0x68a9, 0x4310, {0xb0, 0x9b, 0x27, 0x4e, 0x96, 0xee, 0x4c, 0xbd}};
-const GUID IID_IPortWaveRTStream = {0x1809ce5a, 0x64bc, 0x4e62, {0xbd, 0x7d, 0x95, 0xbc, 0xe4, 0x3d, 0xe3, 0x93}};
-const GUID IID_IMiniportWaveRT = {0x0f9fc4d6, 0x6061, 0x4f3c, {0xb1, 0xfc, 0x7, 0x5e, 0x35, 0xf7, 0x96, 0xa}};
-const GUID IID_IMiniportWaveRTStream = {0x000ac9ab, 0xfaab, 0x4f3d, {0x94, 0x55, 0x6f, 0xf8, 0x30, 0x6a, 0x74, 0xa0}};
-const GUID IID_IMiniportWaveRTStreamNotification = {0x23759128, 0x96f1, 0x423b, {0xab, 0x4d, 0x81, 0x63, 0x5b, 0xcf, 0x8c, 0xa1}};
-const GUID IID_IUnregisterSubdevice = {0x16738177, 0xe199, 0x41f9, {0x9a, 0x87, 0xab, 0xb2, 0xa5, 0x43, 0x2f, 0x21}};
-const GUID IID_IUnregisterPhysicalConnection = {0x6c38e231, 0x2a0d, 0x428d, {0x81, 0xf8, 0x07, 0xcc, 0x42, 0x8b, 0xb9, 0xa4}};
-
-#endif
//UNICODE_STRING GuidString;
PIO_STACK_LOCATION IoStack;
- IoStack = IoGetCurrentIrpStackLocation(Irp);
-
//DPRINT("IPortPinWave_HandleKsProperty entered\n");
IoStack = IoGetCurrentIrpStackLocation(Irp);
if (m_Capture)
m_Position.WriteOffset += Data;
else
- m_Position.WriteOffset += Data;
+ m_Position.PlayOffset += Data;
if (bFailed)
{
* Andrew Greenwood
*/
+#include <initguid.h>
#include "private.hpp"
extern __m128 _mm_load_ss(float const*);
extern int _mm_cvt_ss2si(__m128);
+#ifdef _MSC_VER
+unsigned int _mm_getcsr(void);
+#pragma intrinsic(_mm_getcsr)
+void _mm_setcsr(unsigned int);
+#pragma intrinsic(_mm_setcsr)
+#else
+/*
+ * We can't use __builtin_ia32_* functions,
+ * are they are only available with the -msse2 compiler switch
+ */
+__INTRIN_INLINE unsigned int _mm_getcsr(void)
+{
+ unsigned int retval;
+ __asm__ __volatile__("stmxcsr %0" : "=m"(retval));
+ return retval;
+}
+
+__INTRIN_INLINE void _mm_setcsr(unsigned int val)
+{
+ __asm__ __volatile__("ldmxcsr %0" : : "m"(val));
+}
+#endif
+
/* Alternate names */
#define _mm_cvtss_si32 _mm_cvt_ss2si
/* ULONG
* BYTE_OFFSET(
- * IN PVOID Va)
+ * _In_ PVOID Va)
*/
#define BYTE_OFFSET(Va) \
((ULONG) ((ULONG_PTR) (Va) & (PAGE_SIZE - 1)))
/* ULONG
* BYTES_TO_PAGES(
- * IN ULONG Size)
+ * _In_ ULONG Size)
+ *
+ * Note: This needs to be like this to avoid overflows!
*/
#define BYTES_TO_PAGES(Size) \
- (((Size) + PAGE_SIZE - 1) >> PAGE_SHIFT)
+ (((Size) >> PAGE_SHIFT) + (((Size) & (PAGE_SIZE - 1)) != 0))
/* PVOID
* PAGE_ALIGN(
- * IN PVOID Va)
+ * _In_ PVOID Va)
*/
#define PAGE_ALIGN(Va) \
((PVOID) ((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1)))
/* ULONG_PTR
* ROUND_TO_PAGES(
- * IN ULONG_PTR Size)
+ * _In_ ULONG_PTR Size)
*/
#define ROUND_TO_PAGES(Size) \
(((ULONG_PTR) (Size) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
/* ULONG
* ADDRESS_AND_SIZE_TO_SPAN_PAGES(
- * IN PVOID Va,
- * IN ULONG Size)
+ * _In_ PVOID Va,
+ * _In_ ULONG Size)
*/
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size) \
((ULONG) ((((ULONG_PTR) (_Va) & (PAGE_SIZE - 1)) \
/*
* ULONG
* MmGetMdlByteCount(
- * IN PMDL Mdl)
+ * _In_ PMDL Mdl)
*/
#define MmGetMdlByteCount(_Mdl) \
((_Mdl)->ByteCount)
/*
* PPFN_NUMBER
* MmGetMdlPfnArray(
- * IN PMDL Mdl)
+ * _In_ PMDL Mdl)
*/
#define MmGetMdlPfnArray(_Mdl) \
((PPFN_NUMBER) ((_Mdl) + 1))
/*
* PVOID
* MmGetMdlVirtualAddress(
- * IN PMDL Mdl)
+ * _In_ PMDL Mdl)
*/
#define MmGetMdlVirtualAddress(_Mdl) \
((PVOID) ((PCHAR) ((_Mdl)->StartVa) + (_Mdl)->ByteOffset))
#define MmLockPagableCodeSection(Address) MmLockPagableDataSection(Address)
/* PVOID MmGetSystemAddressForMdl(
- * IN PMDL Mdl);
+ * _In_ PMDL Mdl);
*/
#define MmGetSystemAddressForMdl(Mdl) \
(((Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | \
/* PVOID
* MmGetSystemAddressForMdlSafe(
- * IN PMDL Mdl,
- * IN MM_PAGE_PRIORITY Priority)
+ * _In_ PMDL Mdl,
+ * _In_ MM_PAGE_PRIORITY Priority)
*/
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority) \
(((_Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA \
/*
* VOID
* MmInitializeMdl(
- * IN PMDL MemoryDescriptorList,
- * IN PVOID BaseVa,
- * IN SIZE_T Length)
+ * _In_ PMDL MemoryDescriptorList,
+ * _In_ PVOID BaseVa,
+ * _In_ SIZE_T Length)
*/
#define MmInitializeMdl(_MemoryDescriptorList, \
_BaseVa, \
/*
* VOID
* MmPrepareMdlForReuse(
- * IN PMDL Mdl)
+ * _In_ PMDL Mdl)
*/
#define MmPrepareMdlForReuse(_Mdl) \
{ \
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IDirectMusic methods ***/
STDMETHOD(EnumPort)(THIS_ DWORD dwIndex, LPDMUS_PORTCAPS pPortCaps) PURE;
- STDMETHOD(CreateMusicBuffer)(THIS_ LPDMUS_BUFFERDESC pBufferDesc, LPDIRECTMUSICBUFFER **ppBuffer, LPUNKNOWN pUnkOuter) PURE;
+ STDMETHOD(CreateMusicBuffer)(THIS_ LPDMUS_BUFFERDESC pBufferDesc, LPDIRECTMUSICBUFFER *ppBuffer, LPUNKNOWN pUnkOuter) PURE;
STDMETHOD(CreatePort)(THIS_ REFCLSID rclsidPort, LPDMUS_PORTPARAMS pPortParams, LPDIRECTMUSICPORT *ppPort, LPUNKNOWN pUnkOuter) PURE;
STDMETHOD(EnumMasterClock)(THIS_ DWORD dwIndex, LPDMUS_CLOCKINFO lpClockInfo) PURE;
STDMETHOD(GetMasterClock)(THIS_ LPGUID pguidClock, struct IReferenceClock **ppReferenceClock) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IDirectMusic methods ***/
STDMETHOD(EnumPort)(THIS_ DWORD dwIndex, LPDMUS_PORTCAPS pPortCaps) PURE;
- STDMETHOD(CreateMusicBuffer)(THIS_ LPDMUS_BUFFERDESC pBufferDesc, LPDIRECTMUSICBUFFER **ppBuffer, LPUNKNOWN pUnkOuter) PURE;
+ STDMETHOD(CreateMusicBuffer)(THIS_ LPDMUS_BUFFERDESC pBufferDesc, LPDIRECTMUSICBUFFER *ppBuffer, LPUNKNOWN pUnkOuter) PURE;
STDMETHOD(CreatePort)(THIS_ REFCLSID rclsidPort, LPDMUS_PORTPARAMS pPortParams, LPDIRECTMUSICPORT *ppPort, LPUNKNOWN pUnkOuter) PURE;
STDMETHOD(EnumMasterClock)(THIS_ DWORD dwIndex, LPDMUS_CLOCKINFO lpClockInfo) PURE;
STDMETHOD(GetMasterClock)(THIS_ LPGUID pguidClock, struct IReferenceClock **ppReferenceClock) PURE;
-
-#ifndef _DMUSICS_
-#define _DMUSICS_
-
-#include "dmusicc.h"
-
-#define REGSTR_PATH_SOFTWARESYNTHS "Software\\Microsoft\\DirectMusic\\SoftwareSynths"
-
-interface IDirectMusicSynth;
-interface IDirectMusicSynthSink;
-
+/*
+ * DirectMusic Software Synth Definitions
+ *
+ * Copyright (C) 2003-2004 Rok Mandeljc
+ *
+ * This program 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 program 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 program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef __WINE_DMUSIC_SOFTWARESYNTH_H
+#define __WINE_DMUSIC_SOFTWARESYNTH_H
+
+#include <dmusicc.h>
+
+/*****************************************************************************
+ * Registry path
+ */
+#define REGSTR_PATH_SOFTWARESYNTHS "Software\\Microsoft\\DirectMusic\\SoftwareSynths"
+
+
+/*****************************************************************************
+ * Predeclare the interfaces
+ */
+/* IIDs */
+DEFINE_GUID(IID_IDirectMusicSynth, 0x09823661,0x5c85,0x11d2,0xaf,0xa6,0x00,0xaa,0x00,0x24,0xd8,0xb6);
+DEFINE_GUID(IID_IDirectMusicSynth8, 0x53cab625,0x2711,0x4c9f,0x9d,0xe7,0x1b,0x7f,0x92,0x5f,0x6f,0xc8);
+DEFINE_GUID(IID_IDirectMusicSynthSink, 0x09823663,0x5c85,0x11d2,0xaf,0xa6,0x00,0xaa,0x00,0x24,0xd8,0xb6);
+
+/* typedef definitions */
+typedef struct IDirectMusicSynth *LPDIRECTMUSICSYNTH;
+typedef struct IDirectMusicSynth8 *LPDIRECTMUSICSYNTH8;
+typedef struct IDirectMusicSynthSink *LPDIRECTMUSICSYNTHSINK;
+
+/* GUIDs - property set */
+DEFINE_GUID(GUID_DMUS_PROP_SetSynthSink, 0x0a3a5ba5,0x37b6,0x11d2,0xb9,0xf9,0x00,0x00,0xf8,0x75,0xac,0x12);
+DEFINE_GUID(GUID_DMUS_PROP_SinkUsesDSound, 0xbe208857,0x8952,0x11d2,0xba,0x1c,0x00,0x00,0xf8,0x75,0xac,0x12);
+
+
+/*****************************************************************************
+ * Flags
+ */
+#define REFRESH_F_LASTBUFFER 0x1
+
+
+/*****************************************************************************
+ * Structures
+ */
#ifndef _DMUS_VOICE_STATE_DEFINED
#define _DMUS_VOICE_STATE_DEFINED
+/* typedef definition */
+typedef struct _DMUS_VOICE_STATE DMUS_VOICE_STATE, *LPDMUS_VOICE_STATE;
-DEFINE_GUID(IID_IDirectMusicSynth, 0x9823661, 0x5C85, 0x11D2, 0xAF, 0xA6, 0x00, 0xAA, 0x00, 0x24, 0xD8, 0xB6);
-DEFINE_GUID(IID_IDirectMusicSynth8, 0x53CAB625, 0x2711, 0x4C9F, 0x9D, 0xE7, 0x1B, 0x7F, 0x92, 0x5F, 0x6F, 0xC8);
-DEFINE_GUID(IID_IDirectMusicSynthSink, 0x09823663, 0x5C85, 0x11D2, 0xAF, 0xA6, 0x00, 0xAA, 0x00, 0x24, 0xD8, 0xB6);
-DEFINE_GUID(GUID_DMUS_PROP_SetSynthSink, 0x0A3A5BA5, 0x37B6, 0x11D2, 0xB9, 0xF9, 0x00, 0x00, 0xF8, 0x75, 0xAC, 0x12);
-DEFINE_GUID(GUID_DMUS_PROP_SinkUsesDSound, 0xBE208857, 0x8952, 0x11D2, 0xBA, 0x1C, 0x00, 0x00, 0xF8, 0x75, 0xAC, 0x12);
+/* actual structure */
+struct _DMUS_VOICE_STATE {
+ BOOL bExists;
+ SAMPLE_POSITION spPosition;
+};
+#endif /* _DMUS_VOICE_STATE_DEFINED */
-#define REFRESH_F_LASTBUFFER 0x00000001
-typedef struct _DMUS_VOICE_STATE
+/*****************************************************************************
+ * IDirectMusicSynth interface
+ */
+#define INTERFACE IDirectMusicSynth
+DECLARE_INTERFACE_(IDirectMusicSynth,IUnknown)
{
- BOOL bExists;
- SAMPLE_POSITION spPosition;
-} DMUS_VOICE_STATE;
-
-#endif
-
-#undef INTERFACE
-#define INTERFACE IDirectMusicSynth
-DECLARE_INTERFACE_(IDirectMusicSynth, IUnknown)
-{
- STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE;
- STDMETHOD_(ULONG,AddRef) (THIS) PURE;
- STDMETHOD_(ULONG,Release) (THIS) PURE;
- STDMETHOD(Open) (THIS_ LPDMUS_PORTPARAMS pPortParams) PURE;
- STDMETHOD(Close) (THIS) PURE;
- STDMETHOD(SetNumChannelGroups) (THIS_ DWORD dwGroups) PURE;
- STDMETHOD(Download) (THIS_ LPHANDLE phDownload, LPVOID pvData, LPBOOL pbFree ) PURE;
- STDMETHOD(Unload) (THIS_ HANDLE hDownload, HRESULT ( CALLBACK *lpFreeHandle)(HANDLE,HANDLE), HANDLE hUserData ) PURE;
- STDMETHOD(PlayBuffer) (THIS_ REFERENCE_TIME rt,LPBYTE pbBuffer, DWORD cbBuffer) PURE;
- STDMETHOD(GetRunningStats) (THIS_ LPDMUS_SYNTHSTATS pStats) PURE;
- STDMETHOD(GetPortCaps) (THIS_ LPDMUS_PORTCAPS pCaps) PURE;
- STDMETHOD(SetMasterClock) (THIS_ IReferenceClock *pClock) PURE;
- STDMETHOD(GetLatencyClock) (THIS_ IReferenceClock **ppClock) PURE;
- STDMETHOD(Activate) (THIS_ BOOL fEnable) PURE;
- STDMETHOD(SetSynthSink) (THIS_ struct IDirectMusicSynthSink *pSynthSink) PURE;
- STDMETHOD(Render) (THIS_ short *pBuffer, DWORD dwLength, LONGLONG llPosition) PURE;
- STDMETHOD(SetChannelPriority) (THIS_ DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority) PURE;
- STDMETHOD(GetChannelPriority) (THIS_ DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwPriority) PURE;
- STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSize) PURE;
- STDMETHOD(GetAppend) (THIS_ DWORD* pdwAppend) PURE;
+ /*** IUnknown methods ***/
+ STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ /*** IDirectMusicSynth methods ***/
+ STDMETHOD(Open)(THIS_ LPDMUS_PORTPARAMS pPortParams) PURE;
+ STDMETHOD(Close)(THIS) PURE;
+ STDMETHOD(SetNumChannelGroups)(THIS_ DWORD dwGroups) PURE;
+ STDMETHOD(Download)(THIS_ LPHANDLE phDownload, LPVOID pvData, LPBOOL pbFree) PURE;
+ STDMETHOD(Unload)(THIS_ HANDLE hDownload, HRESULT (CALLBACK* lpFreeHandle)(HANDLE,HANDLE), HANDLE hUserData) PURE;
+ STDMETHOD(PlayBuffer)(THIS_ REFERENCE_TIME rt, LPBYTE pbBuffer, DWORD cbBuffer) PURE;
+ STDMETHOD(GetRunningStats)(THIS_ LPDMUS_SYNTHSTATS pStats) PURE;
+ STDMETHOD(GetPortCaps)(THIS_ LPDMUS_PORTCAPS pCaps) PURE;
+ STDMETHOD(SetMasterClock)(THIS_ IReferenceClock *pClock) PURE;
+ STDMETHOD(GetLatencyClock)(THIS_ IReferenceClock **ppClock) PURE;
+ STDMETHOD(Activate)(THIS_ BOOL fEnable) PURE;
+ STDMETHOD(SetSynthSink)(THIS_ struct IDirectMusicSynthSink *pSynthSink) PURE;
+ STDMETHOD(Render)(THIS_ short *pBuffer, DWORD dwLength, LONGLONG llPosition) PURE;
+ STDMETHOD(SetChannelPriority)(THIS_ DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority) PURE;
+ STDMETHOD(GetChannelPriority)(THIS_ DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwPriority) PURE;
+ STDMETHOD(GetFormat)(THIS_ LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSiz) PURE;
+ STDMETHOD(GetAppend)(THIS_ DWORD *pdwAppend) PURE;
};
-#undef INTERFACE
+#undef INTERFACE
#if !defined(__cplusplus) || defined(CINTERFACE)
-#define IDirectMusicSynth_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b)
-#define IDirectMusicSynth_AddRef(p) (p)->lpVtbl->AddRef(p)
-#define IDirectMusicSynth_Release(p) (p)->lpVtbl->Release(p)
-#define IDirectMusicSynth_Open(p, a) (p)->lpVtbl->Open(p, a)
-#define IDirectMusicSynth_Close(p) (p)->lpVtbl->Close(p)
-#define IDirectMusicSynth_SetNumChannelGroups(p, a) (p)->lpVtbl->SetNumChannelGroups(p, a)
-#define IDirectMusicSynth_Download(p, a, b, c) (p)->lpVtbl->Download(p, a, b, c)
-#define IDirectMusicSynth_Unload(p, a, b, c) (p)->lpVtbl->Unload(p, a, b, c)
-#define IDirectMusicSynth_PlayBuffer(p, a, b, c) (p)->lpVtbl->PlayBuffer(p, a, b, c)
-#define IDirectMusicSynth_GetRunningStats(p, a) (p)->lpVtbl->GetRunningStats(p, a)
-#define IDirectMusicSynth_GetPortCaps(p, a) (p)->lpVtbl->GetPortCaps(p, a)
-#define IDirectMusicSynth_SetMasterClock(p, a) (p)->lpVtbl->SetMasterClock((p, a)
-#define IDirectMusicSynth_GetLatencyClock(p, a) (p)->lpVtbl->GetLatencyClock(p, a)
-#define IDirectMusicSynth_Activate(p, a) (p)->lpVtbl->Activate((p, a)
-#define IDirectMusicSynth_SetSynthSink(p, a) (p)->lpVtbl->SetSynthSink(p, a)
-#define IDirectMusicSynth_Render(p, a, b, c) (p)->lpVtbl->Render(p, a, b, c)
-#define IDirectMusicSynth_SetChannelPriority(p, a, b, c) (p)->lpVtbl->SetChannelPriority(p, a, b, c)
-#define IDirectMusicSynth_GetChannelPriority(p, a, b, c) (p)->lpVtbl->GetChannelPriority(p, a, b, c)
-#define IDirectMusicSynth_GetFormat(p, a, b) (p)->lpVtbl->GetFormat(p, a, b)
-#define IDirectMusicSynth_GetAppend(p, a) (p)->lpVtbl->GetAppend(p, a)
+/*** IUnknown methods ***/
+#define IDirectMusicSynth_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirectMusicSynth_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirectMusicSynth_Release(p) (p)->lpVtbl->Release(p)
+/*** IDirectMusicSynth methods ***/
+#define IDirectMusicSynth_Open(p,a) (p)->lpVtbl->Open(p,a)
+#define IDirectMusicSynth_Close(p) (p)->lpVtbl->Close(p)
+#define IDirectMusicSynth_SetNumChannelGroups(p,a) (p)->lpVtbl->SetNumChannelGroups(p,a)
+#define IDirectMusicSynth_Download(p,a,b,c) (p)->lpVtbl->Download(p,a,b,c)
+#define IDirectMusicSynth_Unload(p,a,b,c) (p)->lpVtbl->Unload(p,a,b,c)
+#define IDirectMusicSynth_PlayBuffer(p,a,b,c) (p)->lpVtbl->PlayBuffer(p,a,b,c)
+#define IDirectMusicSynth_GetRunningStats(p,a) (p)->lpVtbl->GetRunningStats(p,a)
+#define IDirectMusicSynth_GetPortCaps(p,a) (p)->lpVtbl->GetPortCaps(p,a)
+#define IDirectMusicSynth_SetMasterClock(p,a) (p)->lpVtbl->SetMasterClock(p,a)
+#define IDirectMusicSynth_GetLatencyClock(p,a) (p)->lpVtbl->GetLatencyClock(p,a)
+#define IDirectMusicSynth_Activate(p,a) (p)->lpVtbl->Activate(p,a)
+#define IDirectMusicSynth_SetSynthSink(p,a) (p)->lpVtbl->SetSynthSink(p,a)
+#define IDirectMusicSynth_Render(p,a,b,c) (p)->lpVtbl->Render(p,a,b,c)
+#define IDirectMusicSynth_SetChannelPriority(p,a,b,c) (p)->lpVtbl->SetChannelPriority(p,a,b,c)
+#define IDirectMusicSynth_GetChannelPriority(p,a,b,c) (p)->lpVtbl->GetChannelPriority(p,a,b,c)
+#define IDirectMusicSynth_GetFormat(p,a,b) (p)->lpVtbl->GetFormat(p,a,b)
+#define IDirectMusicSynth_GetAppend(p,a) (p)->lpVtbl->GetAppend(p,a)
#endif
-#define INTERFACE IDirectMusicSynth8
-DECLARE_INTERFACE_(IDirectMusicSynth8, IDirectMusicSynth)
+
+/*****************************************************************************
+ * IDirectMusicSynth8 interface
+ */
+#define INTERFACE IDirectMusicSynth8
+DECLARE_INTERFACE_(IDirectMusicSynth8,IDirectMusicSynth)
{
- STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE;
- STDMETHOD_(ULONG,AddRef) (THIS) PURE;
- STDMETHOD_(ULONG,Release) (THIS) PURE;
- STDMETHOD(Open) (THIS_ LPDMUS_PORTPARAMS pPortParams) PURE;
- STDMETHOD(Close) (THIS) PURE;
- STDMETHOD(SetNumChannelGroups) (THIS_ DWORD dwGroups) PURE;
- STDMETHOD(Download) (THIS_ LPHANDLE phDownload, LPVOID pvData, LPBOOL pbFree ) PURE;
- STDMETHOD(Unload) (THIS_ HANDLE hDownload, HRESULT ( CALLBACK *lpFreeHandle)(HANDLE,HANDLE), HANDLE hUserData ) PURE;
- STDMETHOD(PlayBuffer) (THIS_ REFERENCE_TIME rt, LPBYTE pbBuffer, DWORD cbBuffer) PURE;
- STDMETHOD(GetRunningStats) (THIS_ LPDMUS_SYNTHSTATS pStats) PURE;
- STDMETHOD(GetPortCaps) (THIS_ LPDMUS_PORTCAPS pCaps) PURE;
- STDMETHOD(SetMasterClock) (THIS_ IReferenceClock *pClock) PURE;
- STDMETHOD(GetLatencyClock) (THIS_ IReferenceClock **ppClock) PURE;
- STDMETHOD(Activate) (THIS_ BOOL fEnable) PURE;
- STDMETHOD(SetSynthSink) (THIS_ struct IDirectMusicSynthSink *pSynthSink) PURE;
- STDMETHOD(Render) (THIS_ short *pBuffer, DWORD dwLength, LONGLONG llPosition) PURE;
- STDMETHOD(SetChannelPriority) (THIS_ DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority) PURE;
- STDMETHOD(GetChannelPriority) (THIS_ DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwPriority) PURE;
- STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSize) PURE;
- STDMETHOD(GetAppend) (THIS_ DWORD* pdwAppend) PURE;
- STDMETHOD(PlayVoice) (THIS_ REFERENCE_TIME rt, DWORD dwVoiceId, DWORD dwChannelGroup, DWORD dwChannel, DWORD dwDLId, long prPitch, long vrVolume, SAMPLE_TIME stVoiceStart, SAMPLE_TIME stLoopStart, SAMPLE_TIME stLoopEnd) PURE;
- STDMETHOD(StopVoice) (THIS_ REFERENCE_TIME rt, DWORD dwVoiceId ) PURE;
- STDMETHOD(GetVoiceState) (THIS_ DWORD dwVoice[], DWORD cbVoice, DMUS_VOICE_STATE dwVoiceState[] ) PURE;
- STDMETHOD(Refresh) (THIS_ DWORD dwDownloadID, DWORD dwFlags) PURE;
- STDMETHOD(AssignChannelToBuses) (THIS_ DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwBuses, DWORD cBuses) PURE;
+ /*** IUnknown methods ***/
+ STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ /*** IDirectMusicSynth methods ***/
+ STDMETHOD(Open)(THIS_ LPDMUS_PORTPARAMS pPortParams) PURE;
+ STDMETHOD(Close)(THIS) PURE;
+ STDMETHOD(SetNumChannelGroups)(THIS_ DWORD dwGroups) PURE;
+ STDMETHOD(Download)(THIS_ LPHANDLE phDownload, LPVOID pvData, LPBOOL pbFree) PURE;
+ STDMETHOD(Unload)(THIS_ HANDLE hDownload, HRESULT (CALLBACK* lpFreeHandle)(HANDLE,HANDLE), HANDLE hUserData) PURE;
+ STDMETHOD(PlayBuffer)(THIS_ REFERENCE_TIME rt, LPBYTE pbBuffer, DWORD cbBuffer) PURE;
+ STDMETHOD(GetRunningStats)(THIS_ LPDMUS_SYNTHSTATS pStats) PURE;
+ STDMETHOD(GetPortCaps)(THIS_ LPDMUS_PORTCAPS pCaps) PURE;
+ STDMETHOD(SetMasterClock)(THIS_ IReferenceClock *pClock) PURE;
+ STDMETHOD(GetLatencyClock)(THIS_ IReferenceClock **ppClock) PURE;
+ STDMETHOD(Activate)(THIS_ BOOL fEnable) PURE;
+ STDMETHOD(SetSynthSink)(THIS_ struct IDirectMusicSynthSink *pSynthSink) PURE;
+ STDMETHOD(Render)(THIS_ short *pBuffer, DWORD dwLength, LONGLONG llPosition) PURE;
+ STDMETHOD(SetChannelPriority)(THIS_ DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority) PURE;
+ STDMETHOD(GetChannelPriority)(THIS_ DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwPriority) PURE;
+ STDMETHOD(GetFormat)(THIS_ LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSiz) PURE;
+ STDMETHOD(GetAppend)(THIS_ DWORD *pdwAppend) PURE;
+ /*** IDirectMusicSynth8 methods ***/
+ STDMETHOD(PlayVoice)(THIS_ REFERENCE_TIME rt, DWORD dwVoiceId, DWORD dwChannelGroup, DWORD dwChannel, DWORD dwDLId, LONG prPitch, LONG vrVolume, SAMPLE_TIME stVoiceStart, SAMPLE_TIME stLoopStart, SAMPLE_TIME stLoopEnd) PURE;
+ STDMETHOD(StopVoice)(THIS_ REFERENCE_TIME rt, DWORD dwVoiceId) PURE;
+ STDMETHOD(GetVoiceState)(THIS_ DWORD dwVoice[], DWORD cbVoice, DMUS_VOICE_STATE dwVoiceState[]) PURE;
+ STDMETHOD(Refresh)(THIS_ DWORD dwDownloadID, DWORD dwFlags) PURE;
+ STDMETHOD(AssignChannelToBuses)(THIS_ DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwBuses, DWORD cBuses) PURE;
};
-#undef INTERFACE
+#undef INTERFACE
#if !defined(__cplusplus) || defined(CINTERFACE)
-#define IDirectMusicSynth8_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b)
-#define IDirectMusicSynth8_AddRef(p) (p)->lpVtbl->AddRef(p)
-#define IDirectMusicSynth8_Release(p) (p)->lpVtbl->Release(p)
-#define IDirectMusicSynth8_Open(p, a) (p)->lpVtbl->Open(p, a)
-#define IDirectMusicSynth8_Close(p) (p)->lpVtbl->Close(p)
-#define IDirectMusicSynth8_SetNumChannelGroups(p, a) (p)->lpVtbl->SetNumChannelGroups(p, a)
-#define IDirectMusicSynth8_Download(p, a, b, c) (p)->lpVtbl->Download(p, a, b, c)
-#define IDirectMusicSynth8_Unload(p, a, b, c) (p)->lpVtbl->Unload(p, a, b, c)
-#define IDirectMusicSynth8_PlayBuffer(p, a, b, c) (p)->lpVtbl->PlayBuffer(p, a, b, c)
-#define IDirectMusicSynth8_GetRunningStats(p, a) (p)->lpVtbl->GetRunningStats(p, a)
-#define IDirectMusicSynth8_GetPortCaps(p, a) (p)->lpVtbl->GetPortCaps(p, a)
-#define IDirectMusicSynth8_SetMasterClock(p, a) (p)->lpVtbl->SetMasterClock((p, a)
-#define IDirectMusicSynth8_GetLatencyClock(p, a) (p)->lpVtbl->GetLatencyClock(p, a)
-#define IDirectMusicSynth8_Activate(p, a) (p)->lpVtbl->Activate((p, a)
-#define IDirectMusicSynth8_SetSynthSink(p, a) (p)->lpVtbl->SetSynthSink(p, a)
-#define IDirectMusicSynth8_Render(p, a, b, c) (p)->lpVtbl->Render(p, a, b, c)
-#define IDirectMusicSynth8_SetChannelPriority(p, a, b, c) (p)->lpVtbl->SetChannelPriority(p, a, b, c)
-#define IDirectMusicSynth8_GetChannelPriority(p, a, b, c) (p)->lpVtbl->GetChannelPriority(p, a, b, c)
-#define IDirectMusicSynth8_GetFormat(p, a, b) (p)->lpVtbl->GetFormat(p, a, b)
-#define IDirectMusicSynth8_GetAppend(p, a) (p)->lpVtbl->GetAppend(p, a)
-#define IDirectMusicSynth8_PlayVoice(p, a, b, c, d, e, f, g, h, i, j) (p)->lpVtbl->PlayVoice(p, a, b, c, d, e, f, g, h, i, j)
-#define IDirectMusicSynth8_StopVoice(p, a, b) (p)->lpVtbl->StopVoice(p, a, b)
-#define IDirectMusicSynth8_GetVoiceState(p, a, b, c) (p)->lpVtbl->GetVoiceState(p, a, b, c)
-#define IDirectMusicSynth8_Refresh(p, a, b) (p)->lpVtbl->Refresh(p, a, b)
-#define IDirectMusicSynth8_AssignChannelToBuses(p, a, b, c, d) (p)->lpVtbl->AssignChannelToBuses(p, a, b, c, d)
+/*** IUnknown methods ***/
+#define IDirectMusicSynth8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirectMusicSynth8_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirectMusicSynth8_Release(p) (p)->lpVtbl->Release(p)
+/*** IDirectMusicSynth methods ***/
+#define IDirectMusicSynth8_Open(p,a) (p)->lpVtbl->Open(p,a)
+#define IDirectMusicSynth8_Close(p) (p)->lpVtbl->Close(p)
+#define IDirectMusicSynth8_SetNumChannelGroups(p,a) (p)->lpVtbl->SetNumChannelGroups(p,a)
+#define IDirectMusicSynth8_Download(p,a,b,c) (p)->lpVtbl->Download(p,a,b,c)
+#define IDirectMusicSynth8_Unload(p,a,b,c) (p)->lpVtbl->Unload(p,a,b,c)
+#define IDirectMusicSynth8_PlayBuffer(p,a,b,c) (p)->lpVtbl->PlayBuffer(p,a,b,c)
+#define IDirectMusicSynth8_GetRunningStats(p,a) (p)->lpVtbl->GetRunningStats(p,a)
+#define IDirectMusicSynth8_GetPortCaps(p,a) (p)->lpVtbl->GetPortCaps(p,a)
+#define IDirectMusicSynth8_SetMasterClock(p,a) (p)->lpVtbl->SetMasterClock(p,a)
+#define IDirectMusicSynth8_GetLatencyClock(p,a) (p)->lpVtbl->GetLatencyClock(p,a)
+#define IDirectMusicSynth8_Activate(p,a) (p)->lpVtbl->Activate(p,a)
+#define IDirectMusicSynth8_SetSynthSink(p,a) (p)->lpVtbl->SetSynthSink(p,a)
+#define IDirectMusicSynth8_Render(p,a,b,c) (p)->lpVtbl->Render(p,a,b,c)
+#define IDirectMusicSynth8_SetChannelPriority(p,a,b,c) (p)->lpVtbl->SetChannelPriority(p,a,b,c)
+#define IDirectMusicSynth8_GetChannelPriority(p,a,b,c) (p)->lpVtbl->GetChannelPriority(p,a,b,c)
+#define IDirectMusicSynth8_GetFormat(p,a,b) (p)->lpVtbl->GetFormat(p,a,b)
+#define IDirectMusicSynth8_GetAppend(p,a) (p)->lpVtbl->GetAppend(p,a)
+/*** IDirectMusicSynth8 methods ***/
+#define IDirectMusicSynth8_PlayVoice(p,a,b,c,d,e,f,g,h,i,j) (p)->lpVtbl->PlayVoice(p,a,b,c,d,e,f,g,h,i,j)
+#define IDirectMusicSynth8_StopVoice(p,a,b) (p)->lpVtbl->StopVoice(p,a,b)
+#define IDirectMusicSynth8_GetVoiceState(p,a,b,c) (p)->lpVtbl->GetVoiceState(p,a,b,c)
+#define IDirectMusicSynth8_Refresh(p,a,b) (p)->lpVtbl->Refresh(p,a,b)
+#define IDirectMusicSynth8_AssignChannelToBuses(p,a,b,c,d) (p)->lpVtbl->AssignChannelToBuses(p,a,b,c,d)
#endif
-#define INTERFACE IDirectMusicSynthSink
-DECLARE_INTERFACE_(IDirectMusicSynthSink, IUnknown)
+
+/*****************************************************************************
+ * IDirectMusicSynthSink interface
+ */
+#define INTERFACE IDirectMusicSynthSink
+DECLARE_INTERFACE_(IDirectMusicSynthSink,IUnknown)
{
- STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE;
- STDMETHOD_(ULONG,AddRef) (THIS) PURE;
- STDMETHOD_(ULONG,Release) (THIS) PURE;
- STDMETHOD(Init) (THIS_ IDirectMusicSynth *pSynth) PURE;
- STDMETHOD(SetMasterClock) (THIS_ IReferenceClock *pClock) PURE;
- STDMETHOD(GetLatencyClock) (THIS_ IReferenceClock **ppClock) PURE;
- STDMETHOD(Activate) (THIS_ BOOL fEnable) PURE;
- STDMETHOD(SampleToRefTime) (THIS_ LONGLONG llSampleTime, REFERENCE_TIME *prfTime) PURE;
- STDMETHOD(RefTimeToSample) (THIS_ REFERENCE_TIME rfTime, LONGLONG *pllSampleTime) PURE;
- STDMETHOD(SetDirectSound) (THIS_ LPDIRECTSOUND pDirectSound, LPDIRECTSOUNDBUFFER pDirectSoundBuffer) PURE;
- STDMETHOD(GetDesiredBufferSize) (THIS_ LPDWORD pdwBufferSizeInSamples) PURE;
+ /*** IUnknown methods ***/
+ STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ /*** IDirectMusicSynthSink methods ***/
+ STDMETHOD(Init)(THIS_ IDirectMusicSynth *pSynth) PURE;
+ STDMETHOD(SetMasterClock)(THIS_ IReferenceClock *pClock) PURE;
+ STDMETHOD(GetLatencyClock)(THIS_ IReferenceClock **ppClock) PURE;
+ STDMETHOD(Activate)(THIS_ BOOL fEnable) PURE;
+ STDMETHOD(SampleToRefTime)(THIS_ LONGLONG llSampleTime, REFERENCE_TIME *prfTime) PURE;
+ STDMETHOD(RefTimeToSample)(THIS_ REFERENCE_TIME rfTime, LONGLONG *pllSampleTime) PURE;
+ STDMETHOD(SetDirectSound)(THIS_ LPDIRECTSOUND pDirectSound, LPDIRECTSOUNDBUFFER pDirectSoundBuffer) PURE;
+ STDMETHOD(GetDesiredBufferSize)(THIS_ LPDWORD pdwBufferSizeInSamples) PURE;
};
+#undef INTERFACE
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirectMusicSynthSink_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirectMusicSynthSink_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirectMusicSynthSink_Release(p) (p)->lpVtbl->Release(p)
+/*** IDirectMusicSynth methods ***/
+#define IDirectMusicSynthSink_Init(p,a) (p)->lpVtbl->Init(p,a)
+#define IDirectMusicSynthSink_SetMasterClock(p,a) (p)->lpVtbl->SetMasterClock(p,a)
+#define IDirectMusicSynthSink_GetLatencyClock(p,a) (p)->lpVtbl->GetLatencyClock(p,a)
+#define IDirectMusicSynthSink_Activate(p,a) (p)->lpVtbl->Activate(p,a)
+#define IDirectMusicSynthSink_SampleToRefTime(p,a,b) (p)->lpVtbl->SampleToRefTime(p,a,b)
+#define IDirectMusicSynthSink_RefTimeToSample(p,a,b) (p)->lpVtbl->RefTimeToSample(p,a,b)
+#define IDirectMusicSynthSink_SetDirectSound(p,a,b) (p)->lpVtbl->SetDirectSound(p,a,b)
+#define IDirectMusicSynthSink_GetDesiredBufferSize(p,a) (p)->lpVtbl->GetDesiredBufferSize(p,a)
#endif
+
+#endif /* __WINE_DMUSIC_SOFTWARESYNTH_H */
/*
- * dmksctrl.h
+ * Definition of IKsControl
*
- * Contributors:
- * Created by Johannes Anderwald
+ * Copyright (C) 2012 Christian Costa
*
- * THIS SOFTWARE IS NOT COPYRIGHTED
+ * 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 source code is offered for use in the public domain. You may
- * use, modify or distribute it freely.
- *
- * This code is distributed in the hope that it will be useful but
- * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- * DISCLAIMED. This includes but is not limited to warranties of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#ifndef _IKsControl_
-#define _IKsControl_
+#ifndef _DMKSCTRL_
+#define _DMKSCTRL_
+
+#include <pshpack8.h>
+
+#include <objbase.h>
+
+#ifndef _KS_
+#define _KS_
+
+typedef struct {
+ union {
+ struct {
+ GUID Set;
+ ULONG Id;
+ ULONG Flags;
+ } DUMMYSTRUCTNAME;
+ LONGLONG Alignment;
+ } DUMMYUNIONNAME;
+} KSIDENTIFIER, *PKSIDENTIFIER;
+
+typedef KSIDENTIFIER KSPROPERTY, *PKSPROPERTY, KSMETHOD, *PKSMETHOD, KSEVENT, *PKSEVENT;
+
+#define KSMETHOD_TYPE_NONE 0x00000000
+#define KSMETHOD_TYPE_READ 0x00000001
+#define KSMETHOD_TYPE_WRITE 0x00000002
+#define KSMETHOD_TYPE_MODIFY 0x00000003
+#define KSMETHOD_TYPE_SOURCE 0x00000004
+
+#define KSMETHOD_TYPE_SEND 0x00000001
+#define KSMETHOD_TYPE_SETSUPPORT 0x00000100
+#define KSMETHOD_TYPE_BASICSUPPORT 0x00000200
+
+#define KSPROPERTY_TYPE_GET 0x00000001
+#define KSPROPERTY_TYPE_SET 0x00000002
+#define KSPROPERTY_TYPE_SETSUPPORT 0x00000100
+#define KSPROPERTY_TYPE_BASICSUPPORT 0x00000200
+#define KSPROPERTY_TYPE_RELATIONS 0x00000400
+#define KSPROPERTY_TYPE_SERIALIZESET 0x00000800
+#define KSPROPERTY_TYPE_UNSERIALIZESET 0x00001000
+#define KSPROPERTY_TYPE_SERIALIZERAW 0x00002000
+#define KSPROPERTY_TYPE_UNSERIALIZERAW 0x00004000
+#define KSPROPERTY_TYPE_SERIALIZESIZE 0x00008000
+#define KSPROPERTY_TYPE_DEFAULTVALUES 0x00010000
+
+#define KSPROPERTY_TYPE_TOPOLOGY 0x10000000
-#undef INTERFACE
#define INTERFACE IKsControl
-DECLARE_INTERFACE_(IKsControl, IUnknown)
+DECLARE_INTERFACE_(IKsControl,IUnknown)
{
- /* IUnknown */
- STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE;
- STDMETHOD_(ULONG,AddRef) (THIS) PURE;
- STDMETHOD_(ULONG,Release) (THIS) PURE;
-
- /*IKsControl*/
- STDMETHOD(KsProperty)(
- THIS_
- IN PKSPROPERTY Property,
- IN ULONG PropertyLength,
- IN OUT LPVOID PropertyData,
- IN ULONG DataLength,
- OUT ULONG* BytesReturned
- ) PURE;
- STDMETHOD(KsMethod)(
- THIS_
- IN PKSMETHOD Method,
- IN ULONG MethodLength,
- IN OUT LPVOID MethodData,
- IN ULONG DataLength,
- OUT ULONG* BytesReturned
- ) PURE;
- STDMETHOD(KsEvent)(
- THIS_
- IN PKSEVENT Event OPTIONAL,
- IN ULONG EventLength,
- IN OUT LPVOID EventData,
- IN ULONG DataLength,
- OUT ULONG* BytesReturned
- ) PURE;
+ /*** IUnknown methods ***/
+ STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ /*** IKsControl methods ***/
+ STDMETHOD(KsProperty)(THIS_ PKSPROPERTY Property, ULONG PropertyLength, LPVOID PropertyData,
+ ULONG DataLength, ULONG* BytesReturned) PURE;
+ STDMETHOD(KsMethod)(THIS_ PKSMETHOD Method, ULONG MethodLength, LPVOID MethodData,
+ ULONG DataLength, ULONG* BytesReturned) PURE;
+ STDMETHOD(KsEvent)(THIS_ PKSEVENT Event, ULONG EventLength, LPVOID EventData,
+ ULONG DataLength, ULONG* BytesReturned) PURE;
};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IKsControl_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IKsControl_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IKsControl_Release(p) (p)->lpVtbl->Release(p)
+/*** IKsControl methods ***/
+#define IKsControl_KsProperty(p,a,b,c,d,e) (p)->lpVtbl->KsProperty(p,a,b,c,d,e)
+#define IKsControl_KsMethod(p,a,b,c,d,e) (p)->lpVtbl->KsMethod(p,a,b,c,d,e)
+#define IKsControl_KsEvent(p,a,b,c,d,e) (p)->lpVtbl->KsEvent(p,a,b,c,d,e)
+#endif
+
+#endif /* _KS_ */
+
+#include <poppack.h>
+
+
+DEFINE_GUID(IID_IKsControl, 0x28f54685, 0x06fd, 0x11d2, 0xb2, 0x7a, 0x00, 0xa0, 0xc9, 0x22, 0x31, 0x96);
+
+#ifndef _KSMEDIA_
+
+DEFINE_GUID(KSDATAFORMAT_SUBTYPE_MIDI, 0x1d262760, 0xe957, 0x11cf, 0xa5, 0xd6, 0x28, 0xdb, 0x04, 0xc1, 0x00, 0x00);
+DEFINE_GUID(KSDATAFORMAT_SUBTYPE_DIRECTMUSIC, 0x1a82f8bc, 0x3f8b, 0x11d2, 0xb7, 0x74, 0x00, 0x60, 0x08, 0x33, 0x16, 0xc1);
#endif
+
+#endif /* _DMKSCTRL_ */
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_DPLAY_H
{
LPWSTR lpszShortName;
LPSTR lpszShortNameA;
- };
+ } DUMMYUNIONNAME1;
union /*playerLongName */ /* Player's formal/real name */
{
LPWSTR lpszLongName;
LPSTR lpszLongNameA;
- };
+ } DUMMYUNIONNAME2;
} DPNAME, *LPDPNAME;
-
-
#define DPLONGNAMELEN 52
#define DPSHORTNAMELEN 20
#define DPSESSIONNAMELEN 32
{
LPWSTR lpszSessionName;
LPSTR lpszSessionNameA;
- };
+ } DUMMYUNIONNAME1;
union /* Optional password */
{
LPWSTR lpszPassword;
LPSTR lpszPasswordA;
- };
+ } DUMMYUNIONNAME2;
DWORD dwReserved1;
DWORD dwReserved2;
DWORD dwUser3;
DWORD dwUser4;
} DPSESSIONDESC2, *LPDPSESSIONDESC2;
-
-
typedef const DPSESSIONDESC2* LPCDPSESSIONDESC2;
#define DPOPEN_JOIN 0x00000001
#define DPSESSION_PASSWORDREQUIRED 0x00000400
#define DPSESSION_MULTICASTSERVER 0x00000800
#define DPSESSION_CLIENTSERVER 0x00001000
+#define DPSESSION_DIRECTPLAYPROTOCOL 0x00002000
+#define DPSESSION_NOPRESERVEORDER 0x00004000
+#define DPSESSION_OPTIMIZELATENCY 0x00008000
typedef struct tagDPLCONNECTION
{
extern HRESULT WINAPI DirectPlayEnumerateA( LPDPENUMDPCALLBACKA, LPVOID );
extern HRESULT WINAPI DirectPlayEnumerateW( LPDPENUMDPCALLBACKW, LPVOID );
-extern HRESULT WINAPI DirectPlayCreate( LPGUID lpGUID, LPDIRECTPLAY2 *lplpDP, IUnknown *pUnk);
+extern HRESULT WINAPI DirectPlayCreate( LPGUID lpGUID, LPDIRECTPLAY *lplpDP, IUnknown *pUnk );
typedef BOOL (CALLBACK *LPDPENUMPLAYERSCALLBACK)(
DPID dpId,
/* DirectPlay::Connect */
#define DPCONNECT_RETURNSTATUS (DPENUMSESSIONS_RETURNSTATUS)
+/* DirectPlay::GetCaps and DirectPlay::GetPlayerCaps */
+#define DPCAPS_ISHOST 0x00000002
+#define DPCAPS_GROUPOPTIMIZED 0x00000008
+#define DPCAPS_KEEPALIVEOPTIMIZED 0x00000010
+#define DPCAPS_GUARANTEEDOPTIMIZED 0x00000020
+#define DPCAPS_GUARANTEEDSUPPORTED 0x00000040
+#define DPCAPS_SIGNINGSUPPORTED 0x00000080
+#define DPCAPS_ENCRYPTIONSUPPORTED 0x00000100
+#define DPPLAYERCAPS_LOCAL 0x00000800
+#define DPCAPS_ASYNCCANCELSUPPORTED 0x00001000
+#define DPCAPS_ASYNCCANCELALLSUPPORTED 0x00002000
+#define DPCAPS_SENDTIMEOUTSUPPORTED 0x00004000
+#define DPCAPS_SENDPRIORITYSUPPORTED 0x00008000
+#define DPCAPS_ASYNCSUPPORTED 0x00010000
/** DirectPlay system messages **/
#define DEFINE_GUIDSTRUCT(guid, name) struct __declspec(uuid(guid)) name
#define DEFINE_GUIDNAMED(name) __uuidof(struct name)
#else
- extern "C++" {
- template<typename T> const GUID &__mingw_uuidof();
- }
- #define DEFINE_GUIDSTRUCT(guid, name) \
- struct __guid ## name; \
- extern "C++" { \
- template<> inline const GUID &__mingw_uuidof<__guid ## name>() { \
- static const IID iid = {STATICGUIDOF(name)}; \
- return iid; \
- } \
- template<> inline const GUID &__mingw_uuidof<__guid ## name *>() { \
- return __mingw_uuidof<__guid ## name>(); \
- } \
- }
- #define DEFINE_GUIDNAMED(name) __mingw_uuidof<__guid ## name>()
+ #define DEFINE_GUIDSTRUCT(guid, name) \
+ extern const DECLSPEC_SELECTANY GUID __uuid__##name={STATIC_##name};
+ #define DEFINE_GUIDNAMED(name) __uuid__##name
#endif
#else
#define DEFINE_GUIDSTRUCT(guid, name) DEFINE_GUIDEX(name)
*
* 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_DIRECT_PLAY_SP_H
#define __WINE_DIRECT_PLAY_SP_H
-#define WIN32_NO_STATUS
-#define _INC_WINDOWS
-#define COM_NO_WINDOWS_H
+#include <stdarg.h>
-//#include <stdarg.h>
-
-//#include "windef.h"
-#include <winbase.h>
-//#include "winuser.h"
-//#include "dplay.h"
-#include <dplobby.h>
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "dplay.h"
+#include "dplobby.h"
/* GUID for IDirectPlaySP {0C9F6360-CC61-11cf-ACEC-00AA006886E3} */
DEFINE_GUID(IID_IDirectPlaySP, 0xc9f6360, 0xcc61, 0x11cf, 0xac, 0xec, 0x0, 0xaa, 0x0, 0x68, 0x86, 0xe3);
/* ULONG
* BYTE_OFFSET(
- * IN PVOID Va)
+ * _In_ PVOID Va)
*/
#define BYTE_OFFSET(Va) \
((ULONG) ((ULONG_PTR) (Va) & (PAGE_SIZE - 1)))
/* ULONG
* BYTES_TO_PAGES(
- * IN ULONG Size)
+ * _In_ ULONG Size)
+ *
+ * Note: This needs to be like this to avoid overflows!
*/
#define BYTES_TO_PAGES(Size) \
- (((Size) + PAGE_SIZE - 1) >> PAGE_SHIFT)
+ (((Size) >> PAGE_SHIFT) + (((Size) & (PAGE_SIZE - 1)) != 0))
/* PVOID
* PAGE_ALIGN(
- * IN PVOID Va)
+ * _In_ PVOID Va)
*/
#define PAGE_ALIGN(Va) \
((PVOID) ((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1)))
/* ULONG_PTR
* ROUND_TO_PAGES(
- * IN ULONG_PTR Size)
+ * _In_ ULONG_PTR Size)
*/
#define ROUND_TO_PAGES(Size) \
(((ULONG_PTR) (Size) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
/* ULONG
* ADDRESS_AND_SIZE_TO_SPAN_PAGES(
- * IN PVOID Va,
- * IN ULONG Size)
+ * _In_ PVOID Va,
+ * _In_ ULONG Size)
*/
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size) \
((ULONG) ((((ULONG_PTR) (_Va) & (PAGE_SIZE - 1)) \
/*
* ULONG
* MmGetMdlByteCount(
- * IN PMDL Mdl)
+ * _In_ PMDL Mdl)
*/
#define MmGetMdlByteCount(_Mdl) \
((_Mdl)->ByteCount)
/*
* PPFN_NUMBER
* MmGetMdlPfnArray(
- * IN PMDL Mdl)
+ * _In_ PMDL Mdl)
*/
#define MmGetMdlPfnArray(_Mdl) \
((PPFN_NUMBER) ((_Mdl) + 1))
/*
* PVOID
* MmGetMdlVirtualAddress(
- * IN PMDL Mdl)
+ * _In_ PMDL Mdl)
*/
#define MmGetMdlVirtualAddress(_Mdl) \
((PVOID) ((PCHAR) ((_Mdl)->StartVa) + (_Mdl)->ByteOffset))
#define MmLockPagableCodeSection(Address) MmLockPagableDataSection(Address)
/* PVOID MmGetSystemAddressForMdl(
- * IN PMDL Mdl);
+ * _In_ PMDL Mdl);
*/
#define MmGetSystemAddressForMdl(Mdl) \
(((Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | \
/* PVOID
* MmGetSystemAddressForMdlSafe(
- * IN PMDL Mdl,
- * IN MM_PAGE_PRIORITY Priority)
+ * _In_ PMDL Mdl,
+ * _In_ MM_PAGE_PRIORITY Priority)
*/
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority) \
(((_Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA \
/*
* VOID
* MmInitializeMdl(
- * IN PMDL MemoryDescriptorList,
- * IN PVOID BaseVa,
- * IN SIZE_T Length)
+ * _In_ PMDL MemoryDescriptorList,
+ * _In_ PVOID BaseVa,
+ * _In_ SIZE_T Length)
*/
#define MmInitializeMdl(_MemoryDescriptorList, \
_BaseVa, \
/*
* VOID
* MmPrepareMdlForReuse(
- * IN PMDL Mdl)
+ * _In_ PMDL Mdl)
*/
#define MmPrepareMdlForReuse(_Mdl) \
{ \
while (next_xml_attr(xmlbuf, &attr_name, &attr_value, &error, end))
{
attr_nameU = xmlstr2unicode(&attr_name);
- attr_valueU = xmlstr2unicode(&attr_name);
+ attr_valueU = xmlstr2unicode(&attr_value);
DPRINT1( "unexpected attr %wZ=%wZ\n", &attr_nameU,
&attr_valueU);
}
len += GetLocaleInfoA(lcid, LOCALE_SENGCOUNTRY
|LOCALE_NOUSEROVERRIDE, &buf[len], 256-len);
buf[len-1] = '.';
- sprintf(buf+len, "%d", cp);
+ sprintf(buf+len, "%u", cp);
len += strlen(buf+len)+1;
loc->locinfo->lc_category[category].locale = MSVCRT_malloc(len);
(msvcrt_error_mode == _OUT_TO_STDERR))
{
/* Print 'Assertion failed: x<y, file foo.c, line 45' to stderr */
- fprintf(stderr, "Assertion failed: %s, file %s, line %d\n", exp, file, line);
+ fprintf(stderr, "Assertion failed: %s, file %s, line %u\n", exp, file, line);
abort();
}
uintptr_t __UNUSED_PARAM(pReserved))
{
#ifdef __MINGW_SHOW_INVALID_PARAMETER_EXCEPTION
- wprintf(L"Invalid parameter detected in function %s. File: %s Line: %d\n", function, file, line);
+ wprintf(L"Invalid parameter detected in function %s. File: %s Line: %u\n", function, file, line);
wprintf(L"Expression: %s\n", expression);
#endif
}
reactos/dll/directx/amstream # Synced to Wine-1.3.37
reactos/dll/directx/dinput # Synced to Wine-20090208
reactos/dll/directx/dinput8 # Synced to Wine-20090208
-reactos/dll/directx/dmusic # Synced to Wine-1_1_23
-reactos/dll/directx/dplay # Synced to Wine-0_9_5
-reactos/dll/directx/dplayx # Synced to Wine-0_9_5
+reactos/dll/directx/dmusic # Synced to Wine-1.5.26
+reactos/dll/directx/dplay # Synced to Wine-1.5.26
+reactos/dll/directx/dplayx # Synced to Wine-1.5.26
reactos/dll/directx/dxdiagn # Synced to Wine-0_9_5
reactos/dll/directx/msdmo # Autosync
reactos/dll/directx/qedit # Autosync
reactos/dll/win32/compstui # Synced to Wine-1.5.19
reactos/dll/win32/credui # Synced to Wine-1.5.4
reactos/dll/win32/crypt32 # Synced to Wine-1.5.26
-reactos/dll/win32/cryptdlg # Synced to Wine-1.5.4
-reactos/dll/win32/cryptdll # Synced to Wine-1.5.4
-reactos/dll/win32/cryptnet # Synced to Wine-1.3.37
-reactos/dll/win32/cryptui # Synced to Wine-1.5.4
+reactos/dll/win32/cryptdlg # Synced to Wine-1.5.26
+reactos/dll/win32/cryptdll # Synced to Wine-1.5.26
+reactos/dll/win32/cryptnet # Synced to Wine-1.5.26
+reactos/dll/win32/cryptui # Synced to Wine-1.5.26
reactos/dll/win32/dbghelp # Synced to Wine-1.3.37
reactos/dll/win32/dciman32 # Synced to Wine-1.5.19
reactos/dll/win32/dwmapi # Synced to Wine-1.5.19
reactos/dll/win32/faultrep # Synced to Wine-1.5.4
reactos/dll/win32/fusion # Synced to Wine-1.5.4
reactos/dll/win32/gdiplus # Synced to Wine-1.5.4
-reactos/dll/win32/hhctrl.ocx # Autosync
+reactos/dll/win32/hhctrl.ocx # Synced to Wine-1.5.26
reactos/dll/win32/hlink # Synced to Wine-1.5.4
reactos/dll/win32/hnetcfg # Synced to Wine-1.5.4
reactos/dll/win32/httpapi # Synced to Wine-1.5.4
//Ke386SaveFpuState(NpxSaveArea);
/* Update NPX state */
- Thread->NpxState = NPX_STATE_NOT_LOADED;
+ NpxThread->NpxState = NPX_STATE_NOT_LOADED;
}
/* Load FPU state */
//
// Make sure that this address range actually fits within the VAD for it
//
- if (((StartingAddress >> PAGE_SHIFT) < FoundVad->StartingVpn) &&
+ if (((StartingAddress >> PAGE_SHIFT) < FoundVad->StartingVpn) ||
((EndingAddress >> PAGE_SHIFT) > FoundVad->EndingVpn))
{
DPRINT1("Address range does not fit into the VAD\n");
case SB_VERT:
if(Wnd->ExStyle & WS_EX_LEFTSCROLLBAR)
{
- lprect->right = lprect->right;;
+ lprect->right = lprect->left;
lprect->left -= UserGetSystemMetrics(SM_CXVSCROLL);
}
else