-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DivertAsyncResult with send (and receive) #10
Comments
Found the reason, it's a bug in SendAsync. There are some more bugs and problems with the code, I'll see if I can create a PR soon. |
@Areithus It's a bug in my version of SendAsync? Or in WinDivert? If it's a bug in my code I'll re-open. |
I have to admit the async part posed a problem because they're static helpers. Actually everything is, so I had to do a lot of trickery to make the appearance of a class based system. Curious what other bugs you found, please let me know and thank you for the report. |
Arg, disregard last message. Deleted it because I was too hasty to read that you are indeed calling |
Yes, it's a bug in SendAsync, It's providing
There were also some other things but I have to look that up 👍 |
@Areithus Alright thanks, will check into this when I have time ( busy with work right now ) and get back to you. Thanks again. |
BTW, did you ever find a reliable way to cache the results from GetTcpTable2? Ideally the caching should be done by Divert.Net. What I thought of was to introduce a global variable to store the result in. If a match in that table exists with the address and port of the current packet -> return the process from that table. If not, do a new lookup of GetTcpTable2. However, I'm not sure how reliable that would be. On the other hand, caching data for a certain amount of time might not always be perfect either because of processes getting started and killed. Maybe a combination of both? |
I cache by holding results for 2 seconds. You're right, this definitely will have a degree of inaccuracy but so far this has been a good trade off for me, especially when diverting HTTP. I was doing some research yesterday that had led me to believe that the binary behind a stream is actually available in the Windows Filtering Platform. It's actually possible to write a filter that matches against a binary's path. I don't think basil, the person behind WinDivert knows this because I've seen him/her comment on my process matching function saying this ain't available in WFP. Ideally, leveraging this is the way to go in the driver itself so we don't have to do expensive and inaccurate GetXXXTable methods. |
In order to 100℅ accurately map this you'd have to track all captured flows 100℅. That's a lot of work and I found for my purposes that a very short cache period, using thread local caches, was accurate enough and cuts CPU to nil, but I didn't want to impose this on users. |
It indeed seems like that information is available (https://msdn.microsoft.com/en-us/library/windows/hardware/ff552397(v=vs.85).aspx). Would be nice if basil00 could somehow add that information. I did some testing with caching like this: |
@Areithus A more reliable way to cache the results is to keep an array of length |
In the DivertTests the DivertAsyncResult is used, which works.
However, I cannot get DivertAsyncResult to work in the NetDump example, it keeps failing with error code 87 (invalid parameter).
I modified the Send with:
This is identical to the code from DivertTests but that's using a combination of different filters and divert handles. Am I doing something wrong or how can I adapt this?
What is interesting is that ReceiveAsync seems to work just fine.
The text was updated successfully, but these errors were encountered: