ReactOS  0.4.14-dev-599-g2d4d3f5
handle.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS TDI interface
4  * FILE: handle.c
5  * PURPOSE: TDI transport handle management
6  */
7 
8 #include "precomp.h"
9 
10 const PWCHAR TcpFileName = L"\\Device\\Tcp";
11 
13 {
14  UNICODE_STRING fileName;
15  OBJECT_ATTRIBUTES objectAttributes;
16  IO_STATUS_BLOCK ioStatusBlock;
18 
19  RtlInitUnicodeString( &fileName, TcpFileName );
20 
21  InitializeObjectAttributes( &objectAttributes,
22  &fileName,
24  NULL,
25  NULL );
26 
27  status = NtOpenFile( tcpFile,
29  &objectAttributes,
30  &ioStatusBlock,
33 
34  /* String does not need to be freed: it points to the constant
35  * string we provided */
36 
37  if (!NT_SUCCESS(status))
38  *tcpFile = INVALID_HANDLE_VALUE;
39 
40  return status;
41 }
42 
44 {
46 
47  NtClose( h );
48 }
LONG NTSTATUS
Definition: precomp.h:26
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
uint16_t * PWCHAR
Definition: typedefs.h:54
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3951
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID closeTcpFile(HANDLE h)
Definition: handle.c:43
static const WCHAR L[]
Definition: oid.c:1250
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
#define SYNCHRONIZE
Definition: nt_native.h:61
const PWCHAR TcpFileName
Definition: handle.c:10
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
NTSTATUS openTcpFile(PHANDLE tcpFile, ACCESS_MASK DesiredAccess)
Definition: handle.c:12
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
static SERVICE_STATUS status
Definition: service.c:31
ULONG ACCESS_MASK
Definition: nt_native.h:40
Definition: ps.c:97