ReactOS 0.4.15-dev-5666-gc548b97
open_osfhandle.c File Reference
#include "ws2_32.h"
#include <ndk/iofuncs.h>
#include <ndk/obfuncs.h>
#include <io.h>
#include <fcntl.h>
Include dependency graph for open_osfhandle.c:

Go to the source code of this file.

Macros

#define WINVER_WIN8   0x0602
 

Functions

static void run_open_osfhandle (void)
 
 START_TEST (open_osfhandle)
 

Macro Definition Documentation

◆ WINVER_WIN8

#define WINVER_WIN8   0x0602

Definition at line 14 of file open_osfhandle.c.

Function Documentation

◆ run_open_osfhandle()

static void run_open_osfhandle ( void  )
static

Definition at line 16 of file open_osfhandle.c.

17{
18 DWORD type;
19 int handle, err;
21 IO_STATUS_BLOCK StatusBlock;
23
25 ok (fd != INVALID_SOCKET, "Invalid socket\n");
26 if (fd == INVALID_SOCKET)
27 return;
28
30 ok(type == FILE_TYPE_PIPE, "Expected type FILE_TYPE_PIPE, was: %lu\n", type);
31
33 ok(Status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got 0x%lx\n", Status);
35 {
36 RTL_OSVERSIONINFOEXW rtlinfo = { sizeof(rtlinfo), 0 };
37 ULONG Characteristics;
38 DWORD dwWinVersion;
39 ok(DeviceInfo.DeviceType == FILE_DEVICE_NAMED_PIPE, "Expected FILE_DEVICE_NAMED_PIPE, got: 0x%lx\n", DeviceInfo.DeviceType);
40
42 dwWinVersion = (rtlinfo.dwMajorVersion << 8) | rtlinfo.dwMinorVersion;
43 Characteristics = dwWinVersion >= WINVER_WIN8 ? 0x20000 : 0;
44 ok(DeviceInfo.Characteristics == Characteristics, "Expected 0x%lx, got: 0x%lx\n", Characteristics, DeviceInfo.Characteristics);
45 }
46
48 err = *_errno();
49
50 ok(handle != -1, "Expected a valid handle (%i)\n", err);
51 if (handle != -1)
52 {
53 /* To close a file opened with _open_osfhandle, call _close. The underlying handle is also closed by
54 a call to _close, so it is not necessary to call the Win32 function CloseHandle on the original handle. */
56 }
57 else
58 {
60 }
61}
#define ok(value,...)
Definition: atltest.h:57
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
NTSTATUS NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
Definition: version.c:158
#define _O_RDWR
Definition: cabinet.h:39
#define _O_BINARY
Definition: cabinet.h:51
DWORD WINAPI GetFileType(HANDLE hFile)
Definition: fileinfo.c:269
#define SOCK_STREAM
Definition: tcpip.h:118
#define AF_INET
Definition: tcpip.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
@ FileFsDeviceInformation
Definition: from_kernel.h:222
Status
Definition: gdiplustypes.h:25
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
unsigned int ULONG
Definition: retypes.h:1
#define closesocket
Definition: ncftp.h:477
#define WINVER_WIN8
#define FILE_DEVICE_NAMED_PIPE
Definition: winioctl.h:123
#define err(...)
_CRTIMP int *__cdecl _errno(void)
Definition: errno.c:19
_Check_return_opt_ _CRTIMP int __cdecl _close(_In_ int _FileHandle)
_CRTIMP int __cdecl _open_osfhandle(_In_ intptr_t _OSFileHandle, _In_ int _Flags)
static int fd
Definition: io.c:51
NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FsInformation, ULONG Length, FS_INFORMATION_CLASS FsInformationClass)
#define STATUS_SUCCESS
Definition: shellext.h:65
SOCKET WSAAPI WSASocketA(IN INT af, IN INT type, IN INT protocol, IN LPWSAPROTOCOL_INFOA lpProtocolInfo, IN GROUP g, IN DWORD dwFlags)
Definition: socklife.c:444
ULONG dwMajorVersion
Definition: rtltypes.h:270
ULONG dwMinorVersion
Definition: rtltypes.h:271
#define FILE_TYPE_PIPE
Definition: winbase.h:261
#define INVALID_SOCKET
Definition: winsock.h:332
UINT_PTR SOCKET
Definition: winsock.h:47

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( open_osfhandle  )

Definition at line 63 of file open_osfhandle.c.

64{
65 WSADATA wdata;
66 int iResult = WSAStartup(MAKEWORD(2, 2), &wdata);
67 ok(iResult == 0, "WSAStartup failed, iResult == %d\n", iResult);
69 WSACleanup();
70}
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
static void run_open_osfhandle(void)
#define MAKEWORD(a, b)
Definition: typedefs.h:248
int PASCAL FAR WSACleanup(void)
Definition: startup.c:60