[IPHLPAPI] Implement GetOwnerModuleFromUdpEntry()

This commit is contained in:
Pierre Schweitzer 2018-12-01 14:49:00 +01:00
parent e6c4933c66
commit 81aa879c13
No known key found for this signature in database
GPG key ID: 7545556C3D585B0B
2 changed files with 52 additions and 23 deletions

View file

@ -61,7 +61,7 @@
@ stub GetOwnerModuleFromTcp6Entry
@ stdcall GetOwnerModuleFromTcpEntry ( ptr long ptr ptr )
@ stub GetOwnerModuleFromUdp6Entry
@ stub GetOwnerModuleFromUdpEntry
@ stdcall GetOwnerModuleFromUdpEntry ( ptr long ptr ptr )
@ stdcall GetPerAdapterInfo( long ptr ptr )
@ stdcall GetRTTAndHopCount( long ptr long ptr )
@ stub GetTcpExTable2FromStack

View file

@ -2286,38 +2286,19 @@ DWORD WINAPI GetNumberOfInterfaces(PDWORD pdwNumIf)
}
/******************************************************************
* GetOwnerModuleFromTcpEntry (IPHLPAPI.@)
*
* Get data about the module that issued the context bind for a specific IPv4 TCP endpoint in a MIB table row
*
* PARAMS
* pTcpEntry [in] pointer to a MIB_TCPROW_OWNER_MODULE structure
* Class [in] TCPIP_OWNER_MODULE_INFO_CLASS enumeration value
* Buffer [out] pointer a buffer containing a TCPIP_OWNER_MODULE_BASIC_INFO structure with the owner module data.
* pdwSize [in, out] estimated size of the structure returned in Buffer, in bytes
*
* RETURNS
* Success: NO_ERROR
* Failure: ERROR_INSUFFICIENT_BUFFER, ERROR_INVALID_PARAMETER, ERROR_NOT_ENOUGH_MEMORY
* ERROR_NOT_FOUND or ERROR_PARTIAL_COPY
*
* NOTES
* The type of data returned in Buffer is indicated by the value of the Class parameter.
*/
DWORD WINAPI GetOwnerModuleFromTcpEntry( PMIB_TCPROW_OWNER_MODULE pTcpEntry, TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)
static DWORD GetOwnerModuleFromPidEntry(DWORD OwningPid, TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)
{
HANDLE Process;
DWORD FileLen, PathLen;
WCHAR File[MAX_PATH], Path[MAX_PATH];
PTCPIP_OWNER_MODULE_BASIC_INFO BasicInfo;
if (pTcpEntry->dwOwningPid == 0)
if (OwningPid == 0)
{
return ERROR_NOT_FOUND;
}
Process = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pTcpEntry->dwOwningPid);
Process = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, OwningPid);
if (Process == NULL)
{
return GetLastError();
@ -2366,6 +2347,54 @@ DWORD WINAPI GetOwnerModuleFromTcpEntry( PMIB_TCPROW_OWNER_MODULE pTcpEntry, TCP
return NO_ERROR;
}
/******************************************************************
* GetOwnerModuleFromTcpEntry (IPHLPAPI.@)
*
* Get data about the module that issued the context bind for a specific IPv4 TCP endpoint in a MIB table row
*
* PARAMS
* pTcpEntry [in] pointer to a MIB_TCPROW_OWNER_MODULE structure
* Class [in] TCPIP_OWNER_MODULE_INFO_CLASS enumeration value
* Buffer [out] pointer a buffer containing a TCPIP_OWNER_MODULE_BASIC_INFO structure with the owner module data.
* pdwSize [in, out] estimated size of the structure returned in Buffer, in bytes
*
* RETURNS
* Success: NO_ERROR
* Failure: ERROR_INSUFFICIENT_BUFFER, ERROR_INVALID_PARAMETER, ERROR_NOT_ENOUGH_MEMORY
* ERROR_NOT_FOUND or ERROR_PARTIAL_COPY
*
* NOTES
* The type of data returned in Buffer is indicated by the value of the Class parameter.
*/
DWORD WINAPI GetOwnerModuleFromTcpEntry( PMIB_TCPROW_OWNER_MODULE pTcpEntry, TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)
{
return GetOwnerModuleFromPidEntry(pTcpEntry->dwOwningPid, Class, Buffer, pdwSize);
}
/******************************************************************
* GetOwnerModuleFromUdpEntry (IPHLPAPI.@)
*
* Get data about the module that issued the context bind for a specific IPv4 UDP endpoint in a MIB table row
*
* PARAMS
* pUdpEntry [in] pointer to a MIB_UDPROW_OWNER_MODULE structure
* Class [in] TCPIP_OWNER_MODULE_INFO_CLASS enumeration value
* Buffer [out] pointer a buffer containing a TCPIP_OWNER_MODULE_BASIC_INFO structure with the owner module data.
* pdwSize [in, out] estimated size of the structure returned in Buffer, in bytes
*
* RETURNS
* Success: NO_ERROR
* Failure: ERROR_INSUFFICIENT_BUFFER, ERROR_INVALID_PARAMETER, ERROR_NOT_ENOUGH_MEMORY
* ERROR_NOT_FOUND or ERROR_PARTIAL_COPY
*
* NOTES
* The type of data returned in Buffer is indicated by the value of the Class parameter.
*/
DWORD WINAPI GetOwnerModuleFromUdpEntry( PMIB_UDPROW_OWNER_MODULE pUdpEntry, TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)
{
return GetOwnerModuleFromPidEntry(pUdpEntry->dwOwningPid, Class, Buffer, pdwSize);
}
static void CreateNameServerListEnumNamesFunc( PWCHAR Interface, PWCHAR Server, PVOID Data)
{
IP_ADDR_STRING *pNext;