How work's a IPX Communications. 0) About IPX 1) IPX packet structure 2) Get IPX API entry 3) Call IPX functions 4) ECB - event control block. 5) Procedure: Send packet -> Receive packet 0. About IPX The Advanced Netware Internetwork Packet Exchange (IPX) Protocol is an implementations of Xerox's Internetwork PacketProtocol. The purpose of IPX is to allow applicatios running on a Netware workstation to take advantage of the Netware network drives to communicate with other workstations, servers, or devices on the internetwork. By using IPX you can spread your viruses or stole information on the network.:) IPX provide packets exchange on datagramm level. Datagramm mean's "sending w/o confirmation". That's mean that no warranty, that your packet can be sended or received succesfuly. cool? hehe:) To send packets from one workstation to other, you must know IPX packet structure,which you can find below. 1. IPX packet structure. [xx] CheckSum [xx] Lengt of Packet [x] TransportControl [x] PacketType [xxxx] Dest. Network [xxxxxx] Dest. Node [xx] Dest. Socket [xxxx] Source Network [xxxxxx] Source Node [xx] Source Socket [xx...-...xx] Data (from 0 to 546 bytes) IPX packet can be divided on header and data. DATA is the last part of IPX packet (DATA). 2. Get IPX API entry If you want to use IPX, you must call it. To call it you must get API entry. To get IPX API entry you need to do: mov ax,7A00h int 2Fh cmp al,0FFh jz Not_Installed_IPX ; es:di - pointer to IPX API entry mov IPXEntry,di mov IPXEntry+2,es 3. Call IPX functions. When you got IPX API entry you can call its functions. That's looks like this mov bx,0 ; Function number (Open Socket) mov al,0ffh ; Socket type (0 - Temporary, 0FFh - Permanent) mov dx,5555h ; socket number. if zero then get dynamicaly call IPX mov word ptr ds:[SaveSocket],dx or al,al ; if no error je all_fine ; continue ........ ........ IPX: db 09ah IPXEntry dw 0,0 ret 4. Description of Event Control Block For sending or receiving packets, your program must prepare packet of data make header, and make Event Control Block (ECB). In the ECB you must set address information for transfer and address of sended packet and some other information. The stucture of ECB looks like: [xxxx] Pointer to next ECB [xxxx] ESRAddress [x] In use flag [x] CCode (end proccess code) [xx] Socket to Send or Reply [xxxx] IPX work space [xxxxxx] Driver work space [xxxxxxxxxxxx] 12 bytes for adapter driver [xxxxxx] ImmAddress - address for send packet [xx] Fragment Count [xxxx] Address of fragment [xx] Size of Fragment [xxxx] Address of fragment [xx] Size of Fragment .... 5) Here you can find find 2 procedures which send and receive packet. As we remeber that's all work ok:) Send_Packet: ; Fill packet data to send mov dx,word ptr ds:[SaveSocket] ; mov word ptr ds:[Socket],dx ; Socket mov word ptr ds:[Socket11],dx ; mov byte ptr ds:[FragmentCnt],1 ; Fragment count lea si,IPXFormat ; mov word ptr ds:[Address],si ; Fragment Address mov word ptr ds:[Address+2],cs ; mov word ptr ds:[Size1],540 ; Packet Len call GetNetwareAddress ; Get User Address ; cmp al,0 ; If no errors je ok12 ; mov al,0ffh ; Set error flag jmp Exit ; and go to exit ok12: call GetLocalAddress ; Get LocalAddress ; cmp al,0 ; If no errors then je ok13 ; let's go mov al,0ffh ; set error flag jmp Exit ; jump to exit ok13: lea di,DestNetwork ; lea si,NetworkNumber ; Network number movsw ; of packet receiver movsw ; lea di,DestNode ; lea si,NodeAddress ; Node address mov cx,6 ; of packet receiver cld ; rep movsb ; lea si,DestSocket ; mov ax,word ptr ds:[SaveSocket] ; Socket of receiver xchg ah,al ; mov word ptr ds:[si],ax ; mov byte ptr ds:[PacketType],4 ; Packet type type - 4 mov word ptr ds:[EsrAddress+2],cs ; Address of ESR mov byte ptr ds:[Flag],0 ; Clear flag mov bx,3 ; IPXSendPacket lea si,ECB ; Call IPX call ipx ; ok14: cmp byte ptr ds:[Flag],1 je ok16 call Control jmp ok14 Exit: ret ok16: cmp byte ptr ds:[Ccode],0 ; If packet sended OK je ok15 ; then go jmp Send_Packet ; else retry ok15: xor al,al mov byte ptr ds:[Flag],0 jmp short Exit ; Get IPX Packet from another workstation GetPacket: Push Cs Cs Pop Ds Es Mov Cs:EsrAddress1+2,Cs Mov Cs:Address1+2,Cs mov ax,word ptr ds:[SaveSocket] ; Fill Packet mov word ptr ds:[Socket1],ax ; Mov Flag1,0 mov bx,4 ; lea si,ECB1 ; IPXListenForPacket call ipx ; call Control ret Control: Mov Bx,0Ah ; IPXRelinquishControl Call Ipx Ret Ipx: DB 9Ah API DW 0,0 Ret ; Get User Network Address ; Output: ; AL = FF, if error ; AL = 0, if all ok GetNetwareAddress: lea si,Send lea di,UserName call getlen ; Username length dec cx mov byte ptr ds:[si+2],15h ; Call ; GetObjectConnectionNumbers mov ax,1 ; xchg ah,al ; mov word ptr ds:[si+3],ax ; mov byte ptr ds:[si+5],cl ; mov word ptr ds:[si],cx ; add word ptr ds:[si],4 ; push si ; Fill packet and call function add si,6 ; xchg di,si ; cld ; rep movsb ; pop si ; lea di,Reply ; mov word ptr es:[di],101 ; mov ah,0e3h ; int 21h ; cmp al,0 ; If error, then jne ExitFunction ; exit mov dl,byte ptr ds:[di+3] ; Save Connection lea si,Send mov word ptr ds:[si],2 mov byte ptr ds:[si+2],13h ; Call function ; GetInterNetAddress mov byte ptr ds:[si+3],dl ; lea di,Reply ; Fill packet and call function mov word ptr es:[di],14 ; mov ah,0e3h ; int 21h ; cmp al,0 ; If error, then jne ExitFunction ; exit lea si,NetworkNumber ; add di,2 ; mov ax,word ptr ds:[di] ; mov word ptr ds:[si],ax ; add di,2 ; mov ax,word ptr ds:[di] ; mov word ptr ds:[si+2],ax ; Store NetworkNumber, add di,2 ; PhysicalNodeAddress lea si,NodeAddress ; xchg si,di ; cld ; mov cx,6 ; rep movsb ; xor al,al ; ExitFunction: ret GetLocalAddress: mov bx,2 lea si,LocalTab lea di,ImmAddress call ipx ret ESR: mov byte ptr cs:[flag],1 retf getlen: push ax di mov al,0 mov cx,0ffffh cld repne scasb not cx pop di ax ret ; Data ECB LABEL BYTE Link dw 0,0 EsrAddress dw offset ESR dw 0 InUse db 0 Ccode db 0 Socket dw 0 IPXWorkspace db 4 dup (0) DriverWorkspace db 12 dup (0) ImmAddress db 6 dup (0) FragmentCnt dw 1 Address dw 0,0 Size1 dw 0 IPXFormat LABEL BYTE CheckSum db 0,0 Length1 db 0,0 TransportCtrl db 0 PacketType db 4 DestNetwork db 4 dup (0) DestNode db 6 dup (0) DestSocket db 0,0 SourceNetwork db 4 dup (0) SourceNode db 6 dup (0) SourceSocket db 0,0 Data db 560 dup (0) ECB1 LABEL BYTE Link1 dw 0,0 EsrAddress1 dw offset ESR1 dw 0 InUse1 db 0 Ccode1 db 0 Socket1 dw 0 IPXWorkspace1 db 4 dup (0) DriverWorkspace1 db 12 dup (0) ImmAddress1 db 6 dup (0) FragmentCnt1 dw 1 Address1 dw OffSet IPxFormat1,0 Size11 dw 540 IPXFormat1 LABEL BYTE CheckSum1 db 0,0 Length11 db 0,0 TransportCtrl1 db 0 PacketType1 db 4 DestNetwork1 db 4 dup (0) DestNode1 db 6 dup (0) DestSocket1 db 0,0 SourceNetwork1 db 4 dup (0) SourceNode1 db 6 dup (0) SourceSocket1 db 0,0 Data1 db 560 dup (1) Send db 54 dup (0) Reply db 103 dup (0) LocalTab LABEL BYTE NetworkNumber dw 0,0 NodeAddress db 6 dup (0) Socket11 dw 0 Flag db 0 Flag1 db 0 SaveSocket dw 0 UserName db 'DUDE',16 dup (0)