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 17 AcsHlpSendCommand(IN PAUTODIAL_COMMAND Command) 18 { 19 UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"\\Device\\RasAcd"); 20 NTSTATUS Status; 21 HANDLE DriverHandle; 22 HANDLE EventHandle = NULL; 23 OBJECT_ATTRIBUTES ObjectAttributes; 24 IO_STATUS_BLOCK IoStatusBlock; 25 26 /* Initialize the object attributes */ 27 InitializeObjectAttributes(&ObjectAttributes, 28 &DriverName, 29 OBJ_CASE_INSENSITIVE, 30 NULL, 31 NULL); 32 33 /* Open a handle to it */ 34 Status = NtCreateFile(&DriverHandle, 35 FILE_READ_DATA | FILE_WRITE_DATA, 36 &ObjectAttributes, 37 &IoStatusBlock, 38 NULL, 39 FILE_ATTRIBUTE_NORMAL, 40 FILE_SHARE_READ | FILE_SHARE_WRITE, 41 FILE_OPEN_IF, 42 0, 43 NULL, 44 0); 45 if (!NT_SUCCESS(Status)) return FALSE; 46 47 /* Create an event */ 48 EventHandle = CreateEvent(NULL, FALSE, FALSE, NULL); 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, 58 EventHandle, 59 NULL, 60 NULL, 61 &IoStatusBlock, 62 IOCTL_ACD_CONNECT_ADDRESS, 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 */ 72 Status = WaitForSingleObject(EventHandle, INFINITE); 73 74 /* Update status */ 75 Status = IoStatusBlock.Status; 76 } 77 78 /* Close handles and return */ 79 CloseHandle(EventHandle); 80 CloseHandle(DriverHandle); 81 return NT_SUCCESS(Status); 82 } 83 84 /* 85 * @implemented 86 */ 87 BOOLEAN 88 WINAPI 89 AcsHlpAttemptConnection(IN PAUTODIAL_ADDR ConnectionAddress) 90 { 91 AUTODIAL_COMMAND Command; 92 93 /* Clear the command packet */ 94 RtlZeroMemory(&Command, sizeof(AUTODIAL_COMMAND)); 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 108 AcsHlpNoteNewConnection(IN PAUTODIAL_ADDR ConnectionAddress, 109 IN PAUTODIAL_CONN Connection) 110 { 111 AUTODIAL_COMMAND Command; 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 } 123