-
Notifications
You must be signed in to change notification settings - Fork 36
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
WinDivert.send() raises exception if LastError is nonzero #32
Comments
Quite strange, I could call |
Looking more closely, I think it might be |
To be clear, I think the solution you proposed (calling |
# 1.4.0: * Refactor FakeNet-NG to unify Windows and Linux packet handling * Remove Proxy Listener UDP stream abstraction to prevent issue where subsequent clients do not receive response packets because the proxy listener continues to send them to the old (expired) ephemeral port for the previous client * Stop flag command-line support for rudimentary IPC-based start/stop automation * Integration test script for MultiHost and SingleHost mode * Fixed Errno 98 (`TIME_WAIT`) issue with `RawTcpListener` * WinDivert `GetLastError` exception work-around for [WinDivert issue #32](ffalcinelli/pydivert#32)
If a prior Windows API function call changes the last error value for the thread,
pydivert.windivert.WinDivert
raises an exception of the same value. I was originally calling an API that I noted was causingGetLastError()
to return 87, and I thought it was a coincidence thatWinDivert.send()
was raising an exception that, when printed, read:But after some testing, I learned that calling
SetLastError(0)
after calling the (unrelated) Windows API I was using yields a successful invocation ofWinDivert.send()
regardless of the result of this other Windows API call.Here is an example where I have deliberately called
SetLastError(1234)
within a dev branch of FakeNet-NG just prior to invoking thesend()
method of aWinDivert
object:I surmise that either
pydivert
orWinDivert
is relying on the value ofGetLastError()
in at least one case where it has not yet called any Windows APIs that would callSetLastError(ERROR_SUCCESS)
.The text was updated successfully, but these errors were encountered: