Ok, I'll do my best to explain the problem as concisely as possible. I have an application which I wrote, that when certain circumstances are set, it goes through all the ports on the local machine, and binds them to my application socket. The problem is when I run across an application that is bound to a port using the SO_EXCLUSIVEADDRUSE socket option.
The option is specifically to prevent other applications from multiplexing with the port in question. Barring being able to multiplex with the port, I need to find some other way to terminate that applications connection to the port (or at the very least terminate the application). (I know multiplexing does not terminate the other applications connection with the port, but once multiplexing is initiated there are ways to do it).
What I thought is that I could find the application handle associated with the application using the port, and then follow it to the parent handle, and terminate the application there. (One problem with this is when a port that is bound with the socket option SO_EXCLUSIVEADDRUSE and it is closed improperly then the port is not always free to use immediatedly, and sometimes requires a reboot to free.) There are some dangers associated with this approach, I know, but if I am careful and make proper allowances it should work.
Anyway, the problem here is that while I am very proficient with C/C++ and sockets, my OS specific code (aside from socket modifications) is weak at best. What I am asking for is any advice/pointers/links/etc... that you good people may have from your experience dealing with the windows API. Also, just for the record, I am not writing any "hacks" or malicious code of any kind. I keep getting accused of that when asking questions about this online, so I wanted to get that cleared up at the get go. Anyway, thanks for reading this, and I hope to hear from you all soon