ReactOS 0.4.15-dev-8145-ga541a46
InternetOpen.c File Reference
#include <apitest.h>
#include <windef.h>
#include <winsock2.h>
#include <wininet.h>
Include dependency graph for InternetOpen.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 
#define PROC(name)   (p##name = GetProc(#name))
 

Functions

struct hostent *WINAPIpgethostbyname (const char *)
 
 int (WINAPI *pWSACancelBlockingCall)(void)
 
 HINTERNET (WINAPI *pInternetOpen)(LPCTSTR
 
 BOOL (WINAPI *pInternetCloseHandle)(HINTERNET)
 
static PVOID GetProc (PCSTR FunctionName)
 
static BOOLEAN IsWinsockLoaded (VOID)
 
static BOOLEAN IsWinsockInitialized (VOID)
 
static BOOLEAN AreLegacyFunctionsSupported (VOID)
 
 START_TEST (InternetOpen)
 

Variables

 DWORD
 
 LPCTSTR
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 11 of file InternetOpen.c.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 12 of file InternetOpen.c.

◆ PROC

#define PROC (   name)    (p##name = GetProc(#name))

Definition at line 37 of file InternetOpen.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 10 of file InternetOpen.c.

Function Documentation

◆ AreLegacyFunctionsSupported()

static BOOLEAN AreLegacyFunctionsSupported ( VOID  )
static

Definition at line 63 of file InternetOpen.c.

64{
65 int Error;
66
68 return FALSE;
69
71 ok(Error == SOCKET_ERROR, "Error = %d\n", Error);
73 pWSAGetLastError() == WSAEINVAL, "WSAGetLastError = %d\n", pWSAGetLastError());
74
76}
#define PROC(name)
Definition: InternetOpen.c:37
#define ok(value,...)
Definition: atltest.h:57
BOOL Error
Definition: chkdsk.c:66
#define FALSE
Definition: types.h:117
LPFN_WSACANCELBLOCKINGCALL pWSACancelBlockingCall
Definition: handle.c:30
LPFN_WSAGETLASTERROR pWSAGetLastError
Definition: handle.c:29
#define WSAEOPNOTSUPP
Definition: winerror.h:1958
#define WSAEINVAL
Definition: winerror.h:1946
int PASCAL FAR WSAGetLastError(void)
Definition: dllmain.c:112
int PASCAL FAR WSACancelBlockingCall(void)
Definition: bhook.c:23
#define SOCKET_ERROR
Definition: winsock.h:333

Referenced by START_TEST().

◆ BOOL()

BOOL ( WINAPI pInternetCloseHandle)

◆ GetProc()

static PVOID GetProc ( PCSTR  FunctionName)
static

Definition at line 26 of file InternetOpen.c.

28{
29 HMODULE ModuleHandle;
30
31 ModuleHandle = GetModuleHandleW(L"ws2_32");
32 if (!ModuleHandle)
33 return NULL;
34 return GetProcAddress(ModuleHandle, FunctionName);
35}
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char * FunctionName
Definition: acpixf.h:1279
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define L(x)
Definition: ntvdm.h:50

◆ HINTERNET()

HINTERNET ( WINAPI pInternetOpen)

◆ int()

int ( WINAPI pWSACancelBlockingCall)

◆ IsWinsockInitialized()

static BOOLEAN IsWinsockInitialized ( VOID  )
static

Definition at line 48 of file InternetOpen.c.

49{
50 struct hostent *Hostent;
51
53 return FALSE;
54
55 Hostent = pgethostbyname("localhost");
56 if (!Hostent)
58 return Hostent != NULL;
59}
struct hostent *WINAPI * pgethostbyname(const char *)
#define ok_dec(expression, result)
Definition: atltest.h:101
PHOSTENT WSAAPI gethostbyname(IN const char FAR *name)
Definition: getxbyxx.c:221
#define WSANOTINITIALISED
Definition: winerror.h:1987

Referenced by START_TEST().

◆ IsWinsockLoaded()

static BOOLEAN IsWinsockLoaded ( VOID  )
static

Definition at line 41 of file InternetOpen.c.

42{
43 return GetModuleHandleW(L"ws2_32") != NULL;
44}

Referenced by START_TEST().

◆ pgethostbyname()

struct hostent *WINAPI * pgethostbyname ( const char )

Referenced by IsWinsockInitialized().

◆ START_TEST()

START_TEST ( InternetOpen  )

Definition at line 78 of file InternetOpen.c.

79{
80 HMODULE ModuleHandle;
81 HINTERNET InternetHandle;
83
84 ok(!IsWinsockLoaded(), "Winsock loaded on startup\n");
85 ok(!IsWinsockInitialized(), "Winsock initialized on startup\n");
86
87 ModuleHandle = GetModuleHandleW(L"wininet");
88 ok_ptr(ModuleHandle, NULL);
89 ModuleHandle = LoadLibraryW(L"wininet");
90 ok(ModuleHandle != NULL, "LoadLibrary failed, error %lu\n", GetLastError());
91
92 pInternetOpen = (PVOID)GetProcAddress(ModuleHandle, "InternetOpenW");
93 pInternetCloseHandle = (PVOID)GetProcAddress(ModuleHandle, "InternetCloseHandle");
94
95 ok(!IsWinsockLoaded(), "Winsock loaded after wininet load\n");
96 ok(!IsWinsockInitialized(), "Winsock initialized after wininet load\n");
97
98 InternetHandle = pInternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
99 ok(InternetHandle != NULL, "InternetHandle = NULL\n");
100
101 if (InternetHandle != NULL)
102 {
103 ok(IsWinsockLoaded(), "Winsock not loaded after InternetOpen\n");
104 ok(IsWinsockInitialized(), "Winsock not initialized after InternetOpen\n");
105 ok(!AreLegacyFunctionsSupported(), "Winsock initialized with version 1\n");
106 Success = pInternetCloseHandle(InternetHandle);
107 ok(Success, "InternetCloseHandle failed, error %lu\n", GetLastError());
108 }
109
110 ok(IsWinsockLoaded(), "Winsock unloaded after handle close\n");
111 ok(IsWinsockInitialized(), "Winsock uninitialized after handle close\n");
112
113 FreeLibrary(ModuleHandle);
114
115 ok(IsWinsockLoaded(), "Winsock unloaded after wininet unload\n");
116 trace("Winsock %sinitialized after wininet unload (should be uninitialized in 2003, still initialized in 7)\n",
117 IsWinsockInitialized() ? "" : "un");
118}
static BOOLEAN AreLegacyFunctionsSupported(VOID)
Definition: InternetOpen.c:63
static BOOLEAN IsWinsockLoaded(VOID)
Definition: InternetOpen.c:41
static BOOLEAN IsWinsockInitialized(VOID)
Definition: InternetOpen.c:48
#define trace
Definition: atltest.h:70
#define ok_ptr(expression, result)
Definition: atltest.h:108
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
@ Success
Definition: eventcreate.c:712
unsigned int BOOL
Definition: ntddk_ex.h:94
void * PVOID
Definition: typedefs.h:50
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define INTERNET_OPEN_TYPE_DIRECT
Definition: wininet.h:522

Variable Documentation

◆ DWORD

Definition at line 21 of file InternetOpen.c.

◆ LPCTSTR

Definition at line 21 of file InternetOpen.c.