ReactOS  0.4.13-dev-66-gc714b7f
autodial.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Winsock 2 SPI
4  * FILE: lib/mswsock/lib/init.c
5  * PURPOSE: DLL Initialization
6  */
7 
8 #include "precomp.h"
9 
10 #include <ndk/iofuncs.h>
11 #include <ndk/rtltypes.h>
12 
13 /* FUNCTIONS *****************************************************************/
14 
15 BOOLEAN
16 WINAPI
18 {
19  UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"\\Device\\RasAcd");
21  HANDLE DriverHandle;
25 
26  /* Initialize the object attributes */
28  &DriverName,
30  NULL,
31  NULL);
32 
33  /* Open a handle to it */
34  Status = NtCreateFile(&DriverHandle,
38  NULL,
42  0,
43  NULL,
44  0);
45  if (!NT_SUCCESS(Status)) return FALSE;
46 
47  /* Create an event */
49  if (!EventHandle)
50  {
51  /* Event failed, fail us */
52  CloseHandle(DriverHandle);
53  return FALSE;
54  }
55 
56  /* Connect to the driver */
57  Status = NtDeviceIoControlFile(DriverHandle,
59  NULL,
60  NULL,
63  Command,
64  sizeof(AUTODIAL_COMMAND),
65  NULL,
66  0);
67 
68  /* Check if we need to wait */
69  if (Status == STATUS_PENDING)
70  {
71  /* Wait for the driver */
73 
74  /* Update status */
76  }
77 
78  /* Close handles and return */
80  CloseHandle(DriverHandle);
81  return NT_SUCCESS(Status);
82 }
83 
84 /*
85  * @implemented
86  */
87 BOOLEAN
88 WINAPI
90 {
92 
93  /* Clear the command packet */
95 
96  /* Copy the address into the command packet */
97  RtlCopyMemory(&Command.Address, ConnectionAddress, sizeof(AUTODIAL_ADDR));
98 
99  /* Send it to the driver */
100  return AcsHlpSendCommand(&Command);
101 }
102 
103 /*
104  * @implemented
105  */
106 BOOLEAN
107 WINAPI
109  IN PAUTODIAL_CONN Connection)
110 {
112 
113  /* Copy the address into the command packet */
114  RtlCopyMemory(&Command.Address, ConnectionAddress, sizeof(AUTODIAL_ADDR));
115 
116  /* Set the New Connection flag and copy the connection data */
117  Command.NewConnection = TRUE;
118  RtlCopyMemory(&Command.Connection, Connection, sizeof(AUTODIAL_CONN));
119 
120  /* Send it to the driver */
121  return AcsHlpSendCommand(&Command);
122 }
#define CreateEvent
Definition: winbase.h:3562
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define CloseHandle
Definition: compat.h:398
#define FILE_OPEN_IF
Definition: from_kernel.h:56
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI NTSTATUS NTAPI NtDeviceIoControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
Definition: shell.h:41
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
BOOLEAN WINAPI AcsHlpAttemptConnection(IN PAUTODIAL_ADDR ConnectionAddress)
Definition: autodial.c:89
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define FILE_READ_DATA
Definition: nt_native.h:628
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define FILE_WRITE_DATA
Definition: nt_native.h:631
BOOLEAN WINAPI AcsHlpNoteNewConnection(IN PAUTODIAL_ADDR ConnectionAddress, IN PAUTODIAL_CONN Connection)
Definition: autodial.c:108
NTSTATUS NTAPI NtCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
struct Command Command
#define WINAPI
Definition: msvc.h:8
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
BOOLEAN WINAPI AcsHlpSendCommand(IN PAUTODIAL_COMMAND Command)
Definition: autodial.c:17
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define INFINITE
Definition: serial.h:102
#define IOCTL_ACD_CONNECT_ADDRESS
Definition: precomp.h:34
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
_Out_ PHANDLE EventHandle
Definition: iofuncs.h:855