@@ -146,19 +146,15 @@ public static unsafe Int32 RecvFrom_Hook(Int32 socket, IntPtr buffer, Int32 leng
146146
147147 public static unsafe SocketError WSASend_Hook ( Int32 Socket , IntPtr lpBuffers , Int32 dwBufferCount , IntPtr lpNumberOfBytesSent , ref SocketFlags dwFlags , IntPtr lpOverlapped , IntPtr lpCompletionRoutine )
148148 {
149- for ( int i = 0 ; i < dwBufferCount ; i ++ )
150- {
151- IntPtr lpNewBuffer = IntPtr . Add ( lpBuffers , sizeof ( Socket_Cache . SocketPacket . WSABUF ) * i ) ;
149+ int BytesSent = Marshal . ReadInt32 ( lpNumberOfBytesSent ) ;
152150
153- Socket_Cache . SocketPacket . WSABUF wsBuffer = Marshal . PtrToStructure < Socket_Cache . SocketPacket . WSABUF > ( lpNewBuffer ) ;
154- Socket_Cache . FilterList . DoFilter ( wsBuffer . buf , wsBuffer . len ) ;
155- }
151+ Socket_Cache . FilterList . DoFilter_WSABUF ( lpBuffers , dwBufferCount , BytesSent ) ;
156152
157- SocketError res = WSASend ( Socket , lpBuffers , dwBufferCount , lpNumberOfBytesSent , ref dwFlags , lpOverlapped , lpCompletionRoutine ) ;
158- int BytesSent = Marshal . ReadInt32 ( lpNumberOfBytesSent ) ;
153+ SocketError res = WSASend ( Socket , lpBuffers , dwBufferCount , lpNumberOfBytesSent , ref dwFlags , lpOverlapped , lpCompletionRoutine ) ;
159154
160- if ( res == SocketError . Success && BytesSent > 0 )
155+ if ( res == SocketError . Success )
161156 {
157+ BytesSent = Marshal . ReadInt32 ( lpNumberOfBytesSent ) ;
162158 byte [ ] bBuff = Socket_Operation . GetByteFromWSABUF ( lpBuffers , dwBufferCount , BytesSent ) ;
163159
164160 Task . Run ( ( ) =>
@@ -184,18 +180,13 @@ public static unsafe SocketError WSASend_Hook(Int32 Socket, IntPtr lpBuffers, In
184180
185181 public static unsafe SocketError WSARecv_Hook ( Int32 Socket , IntPtr lpBuffers , Int32 dwBufferCount , IntPtr lpNumberOfBytesRecvd , ref SocketFlags flags , IntPtr overlapped , IntPtr completionRoutine )
186182 {
187- SocketError res = WSARecv ( Socket , lpBuffers , dwBufferCount , lpNumberOfBytesRecvd , ref flags , overlapped , completionRoutine ) ;
188- int BytesRecvd = Marshal . ReadInt32 ( lpNumberOfBytesRecvd ) ;
183+ SocketError res = WSARecv ( Socket , lpBuffers , dwBufferCount , lpNumberOfBytesRecvd , ref flags , overlapped , completionRoutine ) ;
189184
190- if ( res == SocketError . Success && BytesRecvd > 0 )
185+ if ( res == SocketError . Success )
191186 {
192- for ( int i = 0 ; i < dwBufferCount ; i ++ )
193- {
194- IntPtr lpNewBuffer = IntPtr . Add ( lpBuffers , sizeof ( Socket_Cache . SocketPacket . WSABUF ) * i ) ;
187+ int BytesRecvd = Marshal . ReadInt32 ( lpNumberOfBytesRecvd ) ;
195188
196- Socket_Cache . SocketPacket . WSABUF wsBuffer = Marshal . PtrToStructure < Socket_Cache . SocketPacket . WSABUF > ( lpNewBuffer ) ;
197- Socket_Cache . FilterList . DoFilter ( wsBuffer . buf , wsBuffer . len ) ;
198- }
189+ Socket_Cache . FilterList . DoFilter_WSABUF ( lpBuffers , dwBufferCount , BytesRecvd ) ;
199190
200191 byte [ ] bBuff = Socket_Operation . GetByteFromWSABUF ( lpBuffers , dwBufferCount , BytesRecvd ) ;
201192
@@ -222,19 +213,15 @@ public static unsafe SocketError WSARecv_Hook(Int32 Socket, IntPtr lpBuffers, In
222213
223214 public static unsafe SocketError WSASendTo_Hook ( Int32 Socket , IntPtr lpBuffers , Int32 dwBufferCount , IntPtr lpNumberOfBytesSent , ref SocketFlags dwFlags , IntPtr To , Int32 toLenth , IntPtr lpOverlapped , IntPtr lpCompletionRoutine )
224215 {
225- for ( int i = 0 ; i < dwBufferCount ; i ++ )
226- {
227- IntPtr lpNewBuffer = IntPtr . Add ( lpBuffers , sizeof ( Socket_Cache . SocketPacket . WSABUF ) * i ) ;
216+ int BytesSent = Marshal . ReadInt32 ( lpNumberOfBytesSent ) ;
228217
229- Socket_Cache . SocketPacket . WSABUF wsBuffer = Marshal . PtrToStructure < Socket_Cache . SocketPacket . WSABUF > ( lpNewBuffer ) ;
230- Socket_Cache . FilterList . DoFilter ( wsBuffer . buf , wsBuffer . len ) ;
231- }
218+ Socket_Cache . FilterList . DoFilter_WSABUF ( lpBuffers , dwBufferCount , BytesSent ) ;
232219
233- SocketError res = WSASendTo ( Socket , lpBuffers , dwBufferCount , lpNumberOfBytesSent , ref dwFlags , To , toLenth , lpOverlapped , lpCompletionRoutine ) ;
234- int BytesSent = Marshal . ReadInt32 ( lpNumberOfBytesSent ) ;
220+ SocketError res = WSASendTo ( Socket , lpBuffers , dwBufferCount , lpNumberOfBytesSent , ref dwFlags , To , toLenth , lpOverlapped , lpCompletionRoutine ) ;
235221
236- if ( res == SocketError . Success && BytesSent > 0 )
222+ if ( res == SocketError . Success )
237223 {
224+ BytesSent = Marshal . ReadInt32 ( lpNumberOfBytesSent ) ;
238225 byte [ ] bBuff = Socket_Operation . GetByteFromWSABUF ( lpBuffers , dwBufferCount , BytesSent ) ;
239226
240227 Task . Run ( ( ) =>
@@ -261,18 +248,13 @@ public static unsafe SocketError WSASendTo_Hook(Int32 Socket, IntPtr lpBuffers,
261248
262249 public static unsafe SocketError WSARecvFrom_Hook ( Int32 Socket , IntPtr lpBuffers , Int32 dwBufferCount , IntPtr lpNumberOfBytesRecvd , ref SocketFlags flags , IntPtr from , Int32 fromLen , IntPtr overlapped , IntPtr completionRoutine )
263250 {
264- SocketError res = WSARecvFrom ( Socket , lpBuffers , dwBufferCount , lpNumberOfBytesRecvd , ref flags , from , fromLen , overlapped , completionRoutine ) ;
265- int BytesRecvd = Marshal . ReadInt32 ( lpNumberOfBytesRecvd ) ;
251+ SocketError res = WSARecvFrom ( Socket , lpBuffers , dwBufferCount , lpNumberOfBytesRecvd , ref flags , from , fromLen , overlapped , completionRoutine ) ;
266252
267- if ( res == SocketError . Success && BytesRecvd > 0 )
253+ if ( res == SocketError . Success )
268254 {
269- for ( int i = 0 ; i < dwBufferCount ; i ++ )
270- {
271- IntPtr lpNewBuffer = IntPtr . Add ( lpBuffers , sizeof ( Socket_Cache . SocketPacket . WSABUF ) * i ) ;
255+ int BytesRecvd = Marshal . ReadInt32 ( lpNumberOfBytesRecvd ) ;
272256
273- Socket_Cache . SocketPacket . WSABUF wsBuffer = Marshal . PtrToStructure < Socket_Cache . SocketPacket . WSABUF > ( lpNewBuffer ) ;
274- Socket_Cache . FilterList . DoFilter ( wsBuffer . buf , wsBuffer . len ) ;
275- }
257+ Socket_Cache . FilterList . DoFilter_WSABUF ( lpBuffers , dwBufferCount , BytesRecvd ) ;
276258
277259 byte [ ] bBuff = Socket_Operation . GetByteFromWSABUF ( lpBuffers , dwBufferCount , BytesRecvd ) ;
278260
0 commit comments