[C++] How can I log packets by hooking a WSARecv that uses lpOverlapped? menu

Shout-Out

User Tag List

Results 1 to 1 of 1
  1. #1
    masterp13's Avatar Private
    Reputation
    1
    Join Date
    Aug 2011
    Posts
    1
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [C++] How can I log packets by hooking a WSARecv that uses lpOverlapped?

    Alright, so I'm hooking WSARecv and I can log packets just fine except for the case where lpOverlapped is not null, and lpCompletionRoutine is null.

    There are two methods I have tried. One lets me log the packets and the game works as it normally would, except sometimes the logged packets are incorrect because the game changes the values in memory before I have a chance to look at them. The other method logs the packet correctly, but the game hangs waiting for some event to complete.

    I want to get the second method working, since it should be more reliable. The problem is, I don't know exactly what I need to do to notify the client (game) that the packet is done being received. Right now my code looks like this.

    Code:
    int proxyWSARecv(int unused, SOCKET s, LPWSABUF recvBuffer, DWORD bufferCount, LPDWORD bytesRecvd, LPDWORD flags,
        LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine){
    
    
        WSAOVERLAPPED wsaoverlapped;
        LPWSAOVERLAPPED ourOverlapped = &wsaoverlapped;
    
        int retnVal;
    
        __asm{
            push lpCompletionRoutine
            push ourOverlapped // our replacement lpoverlapped
            push flags
            push bytesRecvd
            push bufferCount
            push recvBuffer
            push s
            call p_WSARecv // real WSARecv
            mov retnVal, EAX
        }
    
        // get overlapped results and log packets here. etc
    }
    That will log the packet properly, but the game will hang waiting for the WSARecv event to finish (because I'm not using the same lpOverlapped for the WSARecv call). I need to be able to let the game know that the action is complete.

    I've been told that this can be done with PostQueuedCompletionStatus, but the problem is, the ioCompletionPort would be created before the game calls WSARecv, so I'm not quite sure how I could call PostQueuedCompletionStatus.

    I'm aware that I could hook GetQueuedCompletionStatus or whatever it's called, but I'm trying to only intercept ws2_32 functions if possible.

    Thanks!

    [C++] How can I log packets by hooking a WSARecv that uses lpOverlapped?

Similar Threads

  1. Replies: 3
    Last Post: 08-14-2016, 01:51 AM
  2. Replies: 0
    Last Post: 01-02-2015, 01:13 AM
  3. How can i hook with c++??
    By hamburger12 in forum WoW Memory Editing
    Replies: 1
    Last Post: 03-05-2010, 08:10 PM
  4. how can i usw wpe in patch 1.9.4
    By mgboss in forum World of Warcraft General
    Replies: 0
    Last Post: 08-14-2006, 04:19 PM
  5. How can I change textures?
    By Dregonx in forum World of Warcraft General
    Replies: 5
    Last Post: 06-20-2006, 01:28 PM
All times are GMT -5. The time now is 06:58 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search