ReactOS 0.4.15-dev-7674-gc0b4db1
GetOwnerModuleFromUdpEntry.c File Reference
#include <apitest.h>
#include <iphlpapi.h>
#include <winsock2.h>
Include dependency graph for GetOwnerModuleFromUdpEntry.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 

Functions

static DWORD GetExtendedUdpTableWithAlloc (PVOID *UdpTable, BOOL Order, DWORD Family, UDP_TABLE_CLASS Class)
 
 START_TEST (GetOwnerModuleFromUdpEntry)
 

Macro Definition Documentation

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 10 of file GetOwnerModuleFromUdpEntry.c.

Function Documentation

◆ GetExtendedUdpTableWithAlloc()

static DWORD GetExtendedUdpTableWithAlloc ( PVOID UdpTable,
BOOL  Order,
DWORD  Family,
UDP_TABLE_CLASS  Class 
)
static

Definition at line 14 of file GetOwnerModuleFromUdpEntry.c.

15{
16 DWORD ret;
17 DWORD Size = 0;
18
19 *UdpTable = NULL;
20
21 ret = GetExtendedUdpTable(*UdpTable, &Size, Order, Family, Class, 0);
23 {
24 *UdpTable = HeapAlloc(GetProcessHeap(), 0, Size);
25 if (*UdpTable == NULL)
26 {
27 return ERROR_OUTOFMEMORY;
28 }
29
30 ret = GetExtendedUdpTable(*UdpTable, &Size, Order, Family, Class, 0);
31 if (ret != NO_ERROR)
32 {
33 HeapFree(GetProcessHeap(), 0, *UdpTable);
34 *UdpTable = NULL;
35 }
36 }
37
38 return ret;
39}
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI GetExtendedUdpTable(PVOID pUdpTable, PDWORD pdwSize, BOOL bOrder, ULONG ulAf, UDP_TABLE_CLASS TableClass, ULONG Reserved)
static int Family
Definition: ping.c:62
int ret
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( GetOwnerModuleFromUdpEntry  )

Definition at line 41 of file GetOwnerModuleFromUdpEntry.c.

42{
43 WSADATA wsaData;
46 PMIB_UDPTABLE_OWNER_MODULE UdpTableOwnerMod;
47 DWORD i;
49 FILETIME Creation;
50 LARGE_INTEGER CreationTime;
52
53 if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
54 {
55 skip("Failed to init WS2\n");
56 return;
57 }
58
59 GetSystemTimeAsFileTime(&Creation);
60 CreationTime.LowPart = Creation.dwLowDateTime;
61 CreationTime.HighPart = Creation.dwHighDateTime;
62
64 if (sock == INVALID_SOCKET)
65 {
66 skip("Cannot create socket\n");
67 goto quit;
68 }
69
70 ZeroMemory(&server, sizeof(SOCKADDR_IN));
71 server.sin_family = AF_INET;
72 server.sin_addr.s_addr = htonl(INADDR_ANY);
73 server.sin_port = htons(9876);
74
75 if (bind(sock, (SOCKADDR*)&server, sizeof(SOCKADDR_IN)) == SOCKET_ERROR)
76 {
77 skip("Cannot bind socket\n");
78 goto quit2;
79 }
80
82 {
83 ok(UdpTableOwnerMod->dwNumEntries > 0, "No UDP connections?!\n");
84
85 Found = FALSE;
86 for (i = 0; i < UdpTableOwnerMod->dwNumEntries; ++i)
87 {
88 if (UdpTableOwnerMod->table[i].dwLocalAddr == 0 &&
89 UdpTableOwnerMod->table[i].dwLocalPort == htons(9876))
90 {
91 Found = TRUE;
92 break;
93 }
94 }
95
96 if (!Found)
97 {
98 skip("Our socket wasn't found!\n");
99 }
100 else
101 {
102 DWORD Size = 0;
104
105 ok(UdpTableOwnerMod->table[i].dwOwningPid == Pid, "Invalid owner\n");
106
107 ok(UdpTableOwnerMod->table[i].liCreateTimestamp.QuadPart >= CreationTime.QuadPart, "Invalid time\n");
108 ok(UdpTableOwnerMod->table[i].liCreateTimestamp.QuadPart <= CreationTime.QuadPart + 60000000000LL, "Invalid time\n");
109
110 if (GetOwnerModuleFromUdpEntry(&UdpTableOwnerMod->table[i], TCPIP_OWNER_MODULE_INFO_BASIC, BasicInfo, &Size) == ERROR_INSUFFICIENT_BUFFER)
111 {
113 ok(BasicInfo != NULL, "HeapAlloc failed\n");
114
115 if (GetOwnerModuleFromUdpEntry(&UdpTableOwnerMod->table[i], TCPIP_OWNER_MODULE_INFO_BASIC, BasicInfo, &Size) == ERROR_SUCCESS)
116 {
117 WCHAR CurrentModule[MAX_PATH];
119
120 if (GetModuleFileNameW(NULL, CurrentModule, MAX_PATH) != 0)
121 {
122 FileName = wcsrchr(CurrentModule, L'\\');
123 ++FileName;
124
125 ok(_wcsicmp(CurrentModule, BasicInfo->pModulePath) == 0, "Mismatching names (%S, %S)\n", CurrentModule, BasicInfo->pModulePath);
126 ok(_wcsicmp(FileName, BasicInfo->pModuleName) == 0, "Mismatching names (%S, %S)\n", FileName, BasicInfo->pModuleName);
127 }
128 else
129 {
130 skip("GetModuleFileNameW failed\n");
131 }
132 }
133 else
134 {
135 skip("GetOwnerModuleFromTcpEntry failed\n");
136 }
137 }
138 else
139 {
140 skip("GetOwnerModuleFromTcpEntry failed\n");
141 }
142 }
143
144 HeapFree(GetProcessHeap(), 0, UdpTableOwnerMod);
145 }
146 else
147 {
148 skip("GetExtendedUdpTableWithAlloc failure\n");
149 }
150
151quit2:
153quit:
154 WSACleanup();
155}
static DWORD GetExtendedUdpTableWithAlloc(PVOID *UdpTable, BOOL Order, DWORD Family, UDP_TABLE_CLASS Class)
unsigned char BOOLEAN
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
void quit(int argc, const char *argv[])
Definition: cmds.c:1606
return Found
Definition: dirsup.c:1270
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define wcsrchr
Definition: compat.h:16
#define MAX_PATH
Definition: compat.h:34
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
#define IPPROTO_UDP
Definition: ip.h:197
#define AF_INET
Definition: tcpip.h:117
struct _FileName FileName
Definition: fatprocs.h:896
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
DWORD WINAPI GetOwnerModuleFromUdpEntry(PMIB_UDPROW_OWNER_MODULE pUdpEntry, TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)
@ TCPIP_OWNER_MODULE_INFO_BASIC
Definition: iprtrmib.h:51
@ UDP_TABLE_OWNER_MODULE
Definition: iprtrmib.h:45
#define INADDR_ANY
Definition: inet.h:53
#define htons(x)
Definition: module.h:215
#define htonl(x)
Definition: module.h:214
#define closesocket
Definition: ncftp.h:477
#define L(x)
Definition: ntvdm.h:50
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
Definition: tcpcore.h:1455
uint16_t * PWSTR
Definition: typedefs.h:56
#define MAKEWORD(a, b)
Definition: typedefs.h:248
LONGLONG QuadPart
Definition: typedefs.h:114
ULONG LowPart
Definition: typedefs.h:106
static rfbScreenInfoPtr server
Definition: vnc.c:74
#define ZeroMemory
Definition: winbase.h:1712
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158
int PASCAL FAR WSACleanup(void)
Definition: startup.c:60
#define INVALID_SOCKET
Definition: winsock.h:332
#define SOCK_DGRAM
Definition: winsock.h:336
UINT_PTR SOCKET
Definition: winsock.h:47
#define SOCKET_ERROR
Definition: winsock.h:333
__wchar_t WCHAR
Definition: xmlstorage.h:180