Unit Grijjy.Winsock2

DescriptionUsesClasses, Interfaces, Objects and RecordsFunctions and ProceduresTypesConstantsVariables

Description

 

Overview

Classes, Interfaces, Objects and Records

Name Description
record ADDRINFOW  
packed record TMibTcpRowOwnerPid  
packed record MIB_TCPTABLE_OWNER_PID  

Functions and Procedures

function Init_Winsock: DWORD;
procedure Finalize_Winsock;
function IPV4ToString(const AValue: Integer): String;
function EnumerateTCPConnections(out ATcpTable: PMIB_TCPTABLE_OWNER_PID): Boolean;
procedure grNetstat;

Types

PPAddrInfoW = ˆPAddrInfoW;
PAddrInfoW = ˆADDRINFOW;
TAddrInfoW = ADDRINFOW;
LPADDRINFOW = PAddrInfoW;
LPFN_BIND = function(const ASocket: TSocket; const AName: PSockAddr; const ANameLength: Integer): Integer; stdcall;
LPFN_WSAIOCTL = function(const ASocket: TSocket; dwIoControlCode: DWORD; lpvInBuffer: Pointer; cbInBuffer: DWORD; lpvOutBuffer: Pointer; cbOutBuffer: DWORD; lpcbBytesReturned: LPDWORD; AOverlapped: Pointer; lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE): Integer; stdcall;
LPFN_ACCEPTEX = function(AListenSocket, AAcceptSocket: TSocket; lpOutputBuffer: Pointer; dwReceiveDataLength, dwLocalAddressLength, dwRemoteAddressLength: DWORD; var lpdwBytesReceived: DWORD; lpOverlapped: POverlapped): BOOL; stdcall;
LPFN_GETACCEPTEXSOCKADDRS = procedure(lpOutputBuffer: Pointer; dwReceiveDataLength, dwLocalAddressLength, dwRemoteAddressLength: DWORD; var LocalSockaddr: TSockAddr; var LocalSockaddrLength: Integer; var RemoteSockaddr: TSockAddr; var RemoteSockaddrLength: Integer); stdcall;
LPFN_CONNECTEX = function(const ASocket: TSocket; const AName: PSockAddr; const ANameLength: Integer; lpSendBuffer: Pointer; dwSendDataLength: DWORD; var lpdwBytesSent: DWORD; lpOverlapped: LPWSAOVERLAPPED): BOOL; stdcall;
LPFN_DISCONNECTEX = function(const ASocket: TSocket; AOverlapped: Pointer; const dwFlags: DWORD; const dwReserved: DWORD): BOOL; stdcall;
LPFN_GETADDRINFOW = function(NodeName: PWideChar; ServiceName: PWideChar; Hints: PaddrinfoW; ppResult: PPAddrInfoW): Integer; stdcall;
LPFN_GETNAMEINFOW = function(sa: PSockAddr; salen: DWORD; host: PWideChar; hostlen: DWORD; serv: PWideChar; servlen: DWORD; flags: Integer): Integer; stdcall;
LPFN_FREEADDRINFOW = procedure(ai: PaddrinfoW); stdcall;
TCP_TABLE_CLASS = Integer;
PMibTcpRowOwnerPid = ˆTMibTcpRowOwnerPid;
PMIB_TCPTABLE_OWNER_PID = ˆMIB_TCPTABLE_OWNER_PID;
LPFN_GetExtendedTcpTable = function(pTcpTable: Pointer; dwSize: PDWORD; bOrder: BOOL; lAf: ULONG; TableClass: TCP_TABLE_CLASS; Reserved: ULONG): DWord; stdcall;

Constants

WINSOCK2_DLL = 'WS2_32.DLL';
WSHIP6_DLL = 'WSHIP6.DLL';
IPHLPAPI_DLL = 'IPHLPAPI.dll';
TCP_STATES = 12;
TCP_STATE: array[1..TCP_STATES] of String = ( 'CLOSED', 'LISTEN', 'SYN-SENT', 'SYN-RECEIVED', 'ESTABLISHED', 'FIN-WAIT-1', 'FIN-WAIT-2', 'CLOSE-WAIT', 'CLOSING', 'LAST-ACK', 'TIME-WAIT', 'delete TCB');
TF_DISCONNECT = $01;
TF_REUSE_SOCKET = $02;
TF_WRITE_BEHIND = $04;
TF_USE_DEFAULT_WORKER = $00;
TF_USE_SYSTEM_THREAD = $10;
TF_USE_KERNEL_APC = $20;
WSAID_ACCEPTEX: TGuid = (D1:$b5367df1;D2:$cbac;D3:$11cf;D4:($95,$ca,$00,$80,$5f,$48,$a1,$92));
WSAID_CONNECTEX: TGuid = (D1:$25a207b9;D2:$ddf3;D3:$4660;D4:($8e,$e9,$76,$e5,$8c,$74,$06,$3e));
WSAID_DISCONNECTEX: TGuid = (D1:$7fda2e11;D2:$8630;D3:$436f;D4:($a0,$31,$f5,$36,$a6,$ee,$c1,$57));
WSAID_GETACCEPTEXSOCKADDRS: TGuid = (D1:$b5367df2;D2:$cbac;D3:$11cf;D4:($95,$ca,$00,$80,$5f,$48,$a1,$92));

Variables

bind: LPFN_BIND = nil;
WSAIoctl: LPFN_WSAIOCTL = nil;
AcceptEx: LPFN_ACCEPTEX = nil;
GetAcceptExSockAddrs: LPFN_GETACCEPTEXSOCKADDRS = nil;
ConnectEx: LPFN_CONNECTEX = nil;
DisconnectEx: LPFN_DISCONNECTEX = nil;
GetAddrInfo: LPFN_GETADDRINFOW = nil;
GetNameInfo: LPFN_GETNAMEINFOW = nil;
FreeAddrInfo: LPFN_FREEADDRINFOW = nil;
HandleIPHLPAPI: THandle = 0;
GetExtendedTcpTable: LPFN_GetExtendedTcpTable = nil;

Description

Functions and Procedures

function Init_Winsock: DWORD;

Missing Winsock2

procedure Finalize_Winsock;
 
function IPV4ToString(const AValue: Integer): String;

Helpers

function EnumerateTCPConnections(out ATcpTable: PMIB_TCPTABLE_OWNER_PID): Boolean;

NetStat

procedure grNetstat;
 

Types

PPAddrInfoW = ˆPAddrInfoW;
 
PAddrInfoW = ˆADDRINFOW;
 
TAddrInfoW = ADDRINFOW;
 
LPADDRINFOW = PAddrInfoW;
 
LPFN_BIND = function(const ASocket: TSocket; const AName: PSockAddr; const ANameLength: Integer): Integer; stdcall;
 
LPFN_WSAIOCTL = function(const ASocket: TSocket; dwIoControlCode: DWORD; lpvInBuffer: Pointer; cbInBuffer: DWORD; lpvOutBuffer: Pointer; cbOutBuffer: DWORD; lpcbBytesReturned: LPDWORD; AOverlapped: Pointer; lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE): Integer; stdcall;
 
LPFN_ACCEPTEX = function(AListenSocket, AAcceptSocket: TSocket; lpOutputBuffer: Pointer; dwReceiveDataLength, dwLocalAddressLength, dwRemoteAddressLength: DWORD; var lpdwBytesReceived: DWORD; lpOverlapped: POverlapped): BOOL; stdcall;
 
LPFN_GETACCEPTEXSOCKADDRS = procedure(lpOutputBuffer: Pointer; dwReceiveDataLength, dwLocalAddressLength, dwRemoteAddressLength: DWORD; var LocalSockaddr: TSockAddr; var LocalSockaddrLength: Integer; var RemoteSockaddr: TSockAddr; var RemoteSockaddrLength: Integer); stdcall;
 
LPFN_CONNECTEX = function(const ASocket: TSocket; const AName: PSockAddr; const ANameLength: Integer; lpSendBuffer: Pointer; dwSendDataLength: DWORD; var lpdwBytesSent: DWORD; lpOverlapped: LPWSAOVERLAPPED): BOOL; stdcall;
 
LPFN_DISCONNECTEX = function(const ASocket: TSocket; AOverlapped: Pointer; const dwFlags: DWORD; const dwReserved: DWORD): BOOL; stdcall;
 
LPFN_GETADDRINFOW = function(NodeName: PWideChar; ServiceName: PWideChar; Hints: PaddrinfoW; ppResult: PPAddrInfoW): Integer; stdcall;
 
LPFN_GETNAMEINFOW = function(sa: PSockAddr; salen: DWORD; host: PWideChar; hostlen: DWORD; serv: PWideChar; servlen: DWORD; flags: Integer): Integer; stdcall;
 
LPFN_FREEADDRINFOW = procedure(ai: PaddrinfoW); stdcall;
 
TCP_TABLE_CLASS = Integer;
 
PMibTcpRowOwnerPid = ˆTMibTcpRowOwnerPid;
 
PMIB_TCPTABLE_OWNER_PID = ˆMIB_TCPTABLE_OWNER_PID;
 
LPFN_GetExtendedTcpTable = function(pTcpTable: Pointer; dwSize: PDWORD; bOrder: BOOL; lAf: ULONG; TableClass: TCP_TABLE_CLASS; Reserved: ULONG): DWord; stdcall;
 

Constants

WINSOCK2_DLL = 'WS2_32.DLL';
 
WSHIP6_DLL = 'WSHIP6.DLL';
 
IPHLPAPI_DLL = 'IPHLPAPI.dll';
 
TCP_STATES = 12;

TCP states

TCP_STATE: array[1..TCP_STATES] of String = ( 'CLOSED', 'LISTEN', 'SYN-SENT', 'SYN-RECEIVED', 'ESTABLISHED', 'FIN-WAIT-1', 'FIN-WAIT-2', 'CLOSE-WAIT', 'CLOSING', 'LAST-ACK', 'TIME-WAIT', 'delete TCB');
 
TF_DISCONNECT = $01;
 
TF_REUSE_SOCKET = $02;
 
TF_WRITE_BEHIND = $04;
 
TF_USE_DEFAULT_WORKER = $00;
 
TF_USE_SYSTEM_THREAD = $10;
 
TF_USE_KERNEL_APC = $20;
 
WSAID_ACCEPTEX: TGuid = (D1:$b5367df1;D2:$cbac;D3:$11cf;D4:($95,$ca,$00,$80,$5f,$48,$a1,$92));
 
WSAID_CONNECTEX: TGuid = (D1:$25a207b9;D2:$ddf3;D3:$4660;D4:($8e,$e9,$76,$e5,$8c,$74,$06,$3e));
 
WSAID_DISCONNECTEX: TGuid = (D1:$7fda2e11;D2:$8630;D3:$436f;D4:($a0,$31,$f5,$36,$a6,$ee,$c1,$57));
 
WSAID_GETACCEPTEXSOCKADDRS: TGuid = (D1:$b5367df2;D2:$cbac;D3:$11cf;D4:($95,$ca,$00,$80,$5f,$48,$a1,$92));
 

Variables

bind: LPFN_BIND = nil;
 
WSAIoctl: LPFN_WSAIOCTL = nil;
 
AcceptEx: LPFN_ACCEPTEX = nil;
 
GetAcceptExSockAddrs: LPFN_GETACCEPTEXSOCKADDRS = nil;
 
ConnectEx: LPFN_CONNECTEX = nil;
 
DisconnectEx: LPFN_DISCONNECTEX = nil;
 
GetAddrInfo: LPFN_GETADDRINFOW = nil;
 
GetNameInfo: LPFN_GETNAMEINFOW = nil;
 
FreeAddrInfo: LPFN_FREEADDRINFOW = nil;
 
HandleIPHLPAPI: THandle = 0;
 
GetExtendedTcpTable: LPFN_GetExtendedTcpTable = nil;
 

Generated by P2PasDoc 0.13.0 on 2017-04-25 12:54:26