Results 1 to 5 of 5

Thread: Packet sniffing without subclassing

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2014
    Location
    USA
    Posts
    134

    Packet sniffing without subclassing

    I want to preface this by saying I try not to bug you guys with tons of questions I can figure out on my own with some research, but I'm at my wits end on this one. I've been playing with one of the packet sniffer projects from PSC, but I noticed when there's a lot of network traffic, the subclassed event fires so fast it locks out the user, jacks up the CPU usage, etc. I've tried adding DoEvents in different areas and prevented it from updating the TreeView since it's a CPU hog, but I can't get it to behave much better. I've tried a number of other sniffers on PSC and elsewhere and they all seem to use the same subclassing method.

    I did some reading about WSAIoctl() that's used for sniffing (without winpcap) and it mentions an overlap option (with a completion routine, etc), but I'm not sure how to implement it. I've searched for VB6 source code using this option, but can't find anything. I'm not even sure if that would solve the issue, but I would like to not be at the mercy of the callback if possible. And I like to not deal with subclassing when at all possible. Ideally I'd like to call a routine that checks a buffer or something to see if any new network events have come through and cycle through it.

    Anyone know what a solution might be? Any help would be greatly appreciated. I've been studying this for days with no luck! :/

    Here's the project I've been fiddling with:
    http://www.planet-source-code.com/vb...46567&lngWId=1
    Last edited by CrazyDude; Jan 9th, 2017 at 06:36 PM.

  2. #2
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,229

    Re: Packet sniffing without subclassing

    you shouldn't be updating UI in a callback.

    use the callback to update some buffers or data structures with the info you need,
    and then use a timer to refresh the UI based on the data.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2014
    Location
    USA
    Posts
    134

    Re: Packet sniffing without subclassing

    Thanks, that's a good idea. I was hoping to bypass using subclassing altogether and passing off the buffering to the OS rather than having to handle it myself. Sorta like how one would do with regular winsock operations. Plus who loves subclassing? But if I can't get the overlapped thing figured out, if that's even the solution, I'll have to create my own buffers and do it that way.

  4. #4
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,229

    Re: Packet sniffing without subclassing

    If I remember correctly, Overlapped IO is just as tricky as subclassing depending on the method (callbacks can also be used).
    I think I've only ever seen it done correctly in VB or VBA once, with many bad examples out there of non-working methods.

    Personally If I had the time though, I would love to get Overlapped IO working.
    It's just another can of worms similar to subclassing, and who has the time?

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Feb 2014
    Location
    USA
    Posts
    134

    Re: Packet sniffing without subclassing

    Yeah, I hear ya man. I actually don't mind paying for this kind of thing when I'm unable. It's just finding the right person who's not too expensive. I'm considering trying that Freelancer-dot-com site. Not sure if that's the best place, but I've gotten a lot done in the past when it was vworker. Seems like all the experts are right here on vbforums tho.

    And believe it or not, you helped out a lot. Good advice.
    Last edited by CrazyDude; Jan 10th, 2017 at 06:15 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width