pattisahusiwa Posted April 24, 2012 Share Posted April 24, 2012 Hi All.I need some Win32 Api functions for enum all open port (TCP, UDP, etc) that can be implemented on XP, 7, or below. is there any function that i can be used for? Link to comment
deepzero Posted April 24, 2012 Share Posted April 24, 2012 create tcp stream socket & try to connect() to it. Do that for all the ports in your range.I dont really see any other way... Link to comment
kao Posted April 24, 2012 Share Posted April 24, 2012 GetTcpTable (http://msdn.microsof...6(v=vs.85).aspx) Link to comment
atom0s Posted April 24, 2012 Share Posted April 24, 2012 You can use the IP helper library that is part of Windows, see this MSDN link:/>http://msdn.microsoft.com/en-us/library/windows/desktop/aa366071%28v=vs.85%29.aspx Link to comment
0xFF Posted April 26, 2012 Share Posted April 26, 2012 (edited) create tcp stream socket & try to connect() to it. Do that for all the ports in your range.I dont really see any other way...trying to connect() to every possible existing port inside a loop is not a smart way....i'm with kao, GetTcpTable / GetExtendedTcpTable. Edited April 26, 2012 by rotem156 Link to comment
ghandi Posted April 27, 2012 Share Posted April 27, 2012 http://www.codeproject.com/Articles/5453/Enhance-netstatThe main idea of this project was already implemented and presented by some guys around here: using GetTcpTable and GetUdpTable to read connection states of running processes. Yet another thing that is mentioned in this kind of articles are two undocumented APIs from iphlpapi.dll: AllocateAndGetTcpExTableFromStack and AllocateAndGetUdpExTableFromStack. Using these APIs, we can get access to the name of the process that holds the running connection. Unfortunately it does work only with Win2000, WinXP or newer versions.Amazing what happens if you actually perform a Google search for something relating to this subject, like: "Detect open ports C++"HR,Ghandi Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now