/* DP messaging stuff */ static HANDLE DP_MSG_BuildAndLinkReplyStruct( IDirectPlayImpl *This, DP_MSG_REPLY_STRUCT_LIST *lpReplyStructList, WORD wReplyCommandId ) { lpReplyStructList->replyExpected.hReceipt = CreateEventW( NULL, FALSE, FALSE, NULL ); lpReplyStructList->replyExpected.wExpectedReply = wReplyCommandId; lpReplyStructList->replyExpected.lpReplyMsg = NULL; lpReplyStructList->replyExpected.dwMsgBodySize = 0; /* Insert into the message queue while locked */ EnterCriticalSection( &This->lock ); DPQ_INSERT( This->dp2->repliesExpected, lpReplyStructList, repliesExpected ); LeaveCriticalSection( &This->lock ); return lpReplyStructList->replyExpected.hReceipt; }
/* FIXME: LPDPMSG_ENUMSESSIONSREPLY should be const */ void NS_AddRemoteComputerAsNameServer( LPCVOID lpcNSAddrHdr, DWORD dwHdrSize, LPDPMSG_ENUMSESSIONSREPLY lpMsg, LPVOID lpNSInfo ) { DWORD len; lpNSCache lpCache = (lpNSCache)lpNSInfo; lpNSCacheData lpCacheNode; TRACE( "%p, %p, %p\n", lpcNSAddrHdr, lpMsg, 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 ); if( lpCacheNode != NULL ) { TRACE( "Duplicate session entry for %s removed - updated version kept\n", debugstr_guid( &lpCacheNode->data->guidInstance ) ); cbDeleteNSNodeFromHeap( lpCacheNode ); } /* Add this to the list */ lpCacheNode = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *lpCacheNode ) ); if( lpCacheNode == NULL ) { ERR( "no memory for NS node\n" ); return; } lpCacheNode->lpNSAddrHdr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwHdrSize ); CopyMemory( lpCacheNode->lpNSAddrHdr, lpcNSAddrHdr, dwHdrSize ); lpCacheNode->data = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(lpCacheNode->data) ) ); if( lpCacheNode->data == NULL ) { ERR( "no memory for SESSIONDESC2\n" ); 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 ))) { WideCharToMultiByte( CP_ACP, 0, (LPWSTR)(lpMsg+1), -1, lpCacheNode->data->lpszSessionNameA, len, NULL, NULL ); } lpCacheNode->dwTime = timeGetTime(); DPQ_INSERT(lpCache->first, lpCacheNode, next ); lpCache->present = lpCacheNode; /* Use this message as an opportunity to weed out any old sessions so * that we don't enum them again */ NS_PruneSessionCache( lpNSInfo ); }