;--------------- Initialized data segment follows -------------------
dataseg
align 4

CLSID_DirectPlay8Client GUID <0743F1DC6h, 05ABAh, 0429Fh, 08Bh, 0DFh, 0C5h, 04Dh, 003h, 025h, 03Dh, 0C2h>
IID_IDirectPlay8Client GUID <05102DACDh, 0241Bh, 011D3h, 0AEh, 0A7h, 000h, 060h, 097h, 0B0h, 014h, 011h>
CLSID_DirectPlay8Address GUID <0934A9523h, 0A3CAh, 04BC5h, 0ADh, 0A0h, 0D6h, 0D9h, 05Dh, 097h, 094h, 021h>
IID_IDirectPlay8Address GUID <083783300h, 04063h, 04C8Ah, 09Dh, 0B3h, 082h, 083h, 00Ah, 07Fh, 0EBh, 031h>
CLSID_DP8SP_TCPIP GUID <0EBFE7BA0h, 0628Dh, 011D2h, 0AEh, 00Fh, 000h, 060h, 097h, 0B0h, 014h, 011h>
IPfmtW dw "%","d",".","%","d",".","%","d",".","%","d",0
key_hostname dw "h","o","s","t","n","a","m","e",0,0
;-------------- Uninitialized data segment follows ------------------
udataseg
align 4
lpDP8 dd ? ;DirectPlay8Server, or DirectPlay8Client
ReleaselpDP dd ? ;pointer to DirectPlay8's Release method
Initialize dd ? ;pointer to DirectPlay8's Initialize method
Close dd ? ;pointer to DirectPlay8's Close method
SetServerInfo dd ? ;pointer to DirectPlay8's SetServerInfo method
Host dd ? ;pointer to DirectPlay8's Host method
GetClientInfo dd ? ;pointer to DirectPlay8's GetClientInfo method
DestroyClient dd ? ;pointer to DirectPlay8's DestroyClient method
Connect dd ? ;pointer to DirectPlay8's Connect method
lpDP8Addr dd ? ;IID_IDirectPlay8Address
ReleaseAddr dd ? ;pointer to DirectPlay8Address' Release method
SetSP dd ? ;pointer to DirectPlay8Address' SetSP method
lpDP8Addr2 dd ? ;IID_IDirectPlay8Address
ReleaseAddr2 dd ? ;pointer to DirectPlay8Address's Release method
SetSP2 dd ? ;pointer to DirectPlay8Address's SetSP method
AddComponent dd ? ;pointer to DirectPlay8Address's AddComponent method
IPbufW db 40 DUP (?) ;buffer for IP
appdesc DPN_APPLICATION_DESC ?

;--------------------------------------------------------------
;------code segment follows------------------------------------

xor edi, edi
;--client creation
call CoCreateInstance, offset CLSID_DirectPlay8Client, edi, CLSCTX_INPROC_SERVER, offset IID_IDirectPlay8Client, offset lpDP8
or eax, eax
jnz handle_error
; acquire pointers
mov eax,
mov eax,
mov ecx,
mov edx,
mov , ecx
mov , edx
mov ecx,
mov edx,
mov , ecx
mov , edx
; start the client
call , , edi, offset clientmessage, edi
or eax, eax
jnz handle_error
; Create DPLay address for the client
call CoCreateInstance, offset CLSID_DirectPlay8Address, edi, CLSCTX_ALL, offset IID_IDirectPlay8Address, offset lpDP8Addr
or eax, eax
jnz handle_error
; Acquire pointers
mov eax,
mov eax,
mov ecx,
mov edx,
mov , ecx
mov , edx
; Set SP to TCPIP
call , , offset CLSID_DP8SP_TCPIP
or eax, eax
jnz handle_error
; Create DPLay address for the server
call CoCreateInstance, offset CLSID_DirectPlay8Address, edi, CLSCTX_ALL, offset IID_IDirectPlay8Address, offset lpDP8Addr2
or eax, eax
jnz handle_error
; Acquire pointers
mov eax,
mov eax,
mov ecx,
mov edx,
mov , ecx
mov , edx
mov ecx,
mov , ecx
; Set SP to TCPIP
call , , offset CLSID_DP8SP_TCPIP
or eax, eax
jnz handle_error
; Add IP number
mov eax, ;IP in format
mov ebx, eax
mov ecx, eax
mov edx, eax
and eax, 255
shr ebx, 8
shr ecx, 16
shr edx, 24
and ebx, 255
and ecx, 255
call wsprintfW, offset IPbufW, offset IPfmtW, edx, ecx, ebx, eax ;now we have unicode IP at IPbufW
call lstrlenW, offset IPbufW ;size
inc eax ;+null
shl eax, 1 ;*2 (unicode)
call , , offset key_hostname, offset IPbufW, eax, DPNA_DATATYPE_STRING
or eax, eax
jnz handle_error
;set the appdesc struct
mov edi, offset appdesc
mov ecx, (size DPN_APPLICATION_DESC)/4
xor eax, eax
cld
rep stosd
xor edi, edi
;fill GUID_APPLICATION with "P2Pfileshare_001", dwSize with size DPN_APPLICATION_DESC, and dwFlags with DPNSESSION_CLIENT_SERVER or DPNSESSION_NODPNSVR
mov , "fP2P" ;GUID_APPLICATION
mov , size DPN_APPLICATION_DESC
mov , "seli" ;GUID_APPLICATION+4
mov , DPNSESSION_CLIENT_SERVER or DPNSESSION_NODPNSVR
mov , "erah" ;GUID_APPLICATION+8
mov , "001_"
;connect to host
call , , offset appdesc, offset lpDP8Addr2, offset lpDP8Addr, edi, edi, edi, edi, edi, edi, DPNCONNECT_SYNC
or eax, eax
jnz handle_error

;call crashes!! it doesn't return - causes error c0000005
Posted on 2003-12-04 13:21:51 by ti_mo_n