ReactOS  0.4.15-dev-1203-g0e5a4d5
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
static int Family
Definition: ping.c:62
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
DWORD WINAPI GetExtendedUdpTable(PVOID pUdpTable, PDWORD pdwSize, BOOL bOrder, ULONG ulAf, UDP_TABLE_CLASS TableClass, ULONG Reserved)
#define HeapFree(x, y, z)
Definition: compat.h:594
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( GetOwnerModuleFromUdpEntry  )

Definition at line 41 of file GetOwnerModuleFromUdpEntry.c.

42 {
43  WSADATA wsaData;
44  SOCKET sock;
46  PMIB_UDPTABLE_OWNER_MODULE UdpTableOwnerMod;
47  DWORD i;
48  BOOLEAN Found;
49  FILETIME Creation;
50  LARGE_INTEGER CreationTime;
51  DWORD Pid = GetCurrentProcessId();
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  {
118  PWSTR FileName;
119 
121  {
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 
151 quit2:
152  closesocket(sock);
153 quit:
154  WSACleanup();
155 }
DWORD WINAPI GetOwnerModuleFromUdpEntry(PMIB_UDPROW_OWNER_MODULE pUdpEntry, TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)
#define SOCKET_ERROR
Definition: winsock.h:333
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
#define LL
Definition: tui.h:84
static rfbScreenInfoPtr server
Definition: vnc.c:74
static SOCKET sock
Definition: syslog.c:45
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
#define ERROR_SUCCESS
Definition: deptool.c:10
#define htonl(x)
Definition: module.h:212
#define MAKEWORD(a, b)
Definition: typedefs.h:248
#define TRUE
Definition: types.h:120
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
uint16_t * PWSTR
Definition: typedefs.h:56
void quit(int argc, const char *argv[])
Definition: cmds.c:1606
#define closesocket
Definition: precomp.h:57
INT WSAAPI WSACleanup(VOID)
Definition: startup.c:60
#define INADDR_ANY
Definition: StrAddr.c:4
#define ZeroMemory
Definition: winbase.h:1648
DWORD dwHighDateTime
Definition: mapidefs.h:66
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
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
smooth NULL
Definition: ftsmooth.c:416
return Found
Definition: dirsup.c:1270
PLOADER_MODULE CurrentModule
Definition: mboot.c:66
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define INVALID_SOCKET
Definition: winsock.h:332
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
ULONG LowPart
Definition: typedefs.h:106
static DWORD GetExtendedUdpTableWithAlloc(PVOID *UdpTable, BOOL Order, DWORD Family, UDP_TABLE_CLASS Class)
#define wcsrchr
Definition: compat.h:16
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
struct _FileName FileName
Definition: fatprocs.h:893
#define ok(value,...)
Definition: atltest.h:57
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
Definition: tcpcore.h:1455
#define skip(...)
Definition: atltest.h:64
#define AF_INET
Definition: tcpip.h:117
UINT_PTR SOCKET
Definition: winsock.h:47
#define htons(x)
Definition: module.h:213
#define SOCK_DGRAM
Definition: winsock.h:336
#define HeapFree(x, y, z)
Definition: compat.h:594
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
DWORD dwLowDateTime
Definition: mapidefs.h:65
DWORD WINAPI GetCurrentProcessId(VOID)
Definition: proc.c:1158
LONGLONG QuadPart
Definition: typedefs.h:114
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10