// JP opened flex table

Click to See Complete Forum and Search --> : Using the Winsock API to send Pings under XP SP2


c-minus
December 2nd, 2007, 07:51 PM
Hi Folks,
I've written a test-app that runs under Windows XP and uses WS2_32.dll to send pings to multiple devices-under-test (aka: "DUTs".) Devices are tested in seperate threads - one thread may be pinging at 2Hz, another thread at 5Hz.

The app works fine as long as the user has admin privileges. For non-admins, pinging doesn't work. It _seems_ to be WS2_32 that's behaving differently, though I haven't trapped any errors during "setsockopt", "sendto"s, "select", "recvfrom", etc. Both admins and non-admins can ping DUTs from a DOS window.

Searches on WS2_32 and XP have turned-up some discussion about restrictions under SP2, but the app works for admins...

The app relys on socket-receive events - on a socket-receive event, WS2_32 relays a message to a [hidden] window which processes received pings for the test-app.

I realize this description is "sketchy" and it may not be a WS2_32 problem - but if the symptom sounds familier, your insight may help!

Thanks, Cheers!

Richard.J
December 3rd, 2007, 11:21 AM
If you use raw socket for the ICMP ping message, then I believe they are restricted to users with admin rights on Win XP SP2. That's why your app works for an admin account.

MikeAThon
December 3rd, 2007, 11:26 AM
Yes, raw sockets are probably the culprit, although the admin/non-admin distinction should not make a difference under XP SP2 (i.e., there are restrictions on raw sockets regardless of whether you are or are not an admin).. The admin/non-admin distinction shows itself clearly only under Win2K.

Mike

c-minus
December 16th, 2007, 06:03 PM
follow-up:
Improved (repaired) error-checking shows the "sendto" call is returning "FFFFFFFF" - no extended error detail seems available. Again, this only happens if user is not an Admin, otherwise pings work.

Really desperate for a work-around here. Registry-hack - anything (except for allowing everybody to logon with admin privileges.)

If admins can do it, there ought to be a way to let Users. Off to dig through MSDN (again) !

Cheers!

MikeAThon
December 16th, 2007, 08:05 PM
FFFFFFFF is #define'd as SOCKET_ERROR. Call WSAGetLastError() immediately after the call to sendto(), and tell us what the last error is. See http://msdn2.microsoft.com/en-us/library/ms740148.aspx for the list of errors that sendto() can throw.

Mike

c-minus
December 16th, 2007, 09:07 PM
Hi Mike,
Users allowed to send raw-socket pings!!!

The WSAGETLASTERROR code was actualy buried in error-gibberish (that my code built and) returned. 0x271D (10013) => WSAEACCESS. Searching on this subject seemed to go nowhere - at first.

To make a long story short, the "DisableRawSecurity" hack (below) didn't work for me, but using it as a search-term lead to the "AllowUserRawAccess" hack which worked for me. Again, my platform is WinXP, SP2.

The following is quoted from a page related to a "Fping" utility. I'm not using that utility, but these instructions were very valuable:

a) NT4 users should change / add the following registry variable
and set its value to DWORD 1:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Afd\Parameters\DisableRawSecurity
b) 2000 users should set the following registry variable to DWORD 1
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters\AllowUserRawAccess
after you change the registry, you will need to reboot.

THANKS! - Cheers!

//JP added flex table