- Add Alex's rasadhlp

- It builds on my WC but it may not build on trunk (because of our lacking headers)

svn path=/trunk/; revision=43510
This commit is contained in:
Cameron Gutman 2009-10-16 04:33:22 +00:00
parent 6a80145ce3
commit 181002e46e
6 changed files with 411 additions and 0 deletions

View file

@ -0,0 +1,123 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Winsock 2 SPI
* FILE: lib/mswsock/lib/init.c
* PURPOSE: DLL Initialization
*/
/* INCLUDES ******************************************************************/
#include "precomp.h"
/* DATA **********************************************************************/
/* FUNCTIONS *****************************************************************/
BOOLEAN
WINAPI
AcsHlpSendCommand(IN PAUTODIAL_COMMAND Command)
{
UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"\\Device\\RasAcd");
NTSTATUS Status;
HANDLE DriverHandle;
HANDLE EventHandle = NULL;
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock;
/* Initialize the object attributes */
InitializeObjectAttributes(&ObjectAttributes,
&DriverName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
/* Open a handle to it */
Status = NtCreateFile(&DriverHandle,
FILE_READ_DATA | FILE_WRITE_DATA,
&ObjectAttributes,
&IoStatusBlock,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_OPEN_IF,
0,
NULL,
0);
if (!NT_SUCCESS(Status)) return FALSE;
/* Create an event */
EventHandle = CreateEvent(NULL, FALSE, FALSE, NULL);
if (!EventHandle)
{
/* Event failed, fail us */
CloseHandle(DriverHandle);
return FALSE;
}
/* Connect to the driver */
Status = NtDeviceIoControlFile(DriverHandle,
EventHandle,
NULL,
NULL,
&IoStatusBlock,
IOCTL_ACD_CONNECT_ADDRESS,
Command,
sizeof(AUTODIAL_COMMAND),
NULL,
0);
/* Check if we need to wait */
if (Status == STATUS_PENDING)
{
/* Wait for the driver */
Status = WaitForSingleObject(EventHandle, INFINITE);
/* Update status */
Status = IoStatusBlock.Status;
}
/* Close handles and return */
CloseHandle(EventHandle);
CloseHandle(DriverHandle);
return NT_SUCCESS(Status);
}
/*
* @implemented
*/
BOOLEAN
WINAPI
AcsHlpAttemptConnection(IN PAUTODIAL_ADDR ConnectionAddress)
{
AUTODIAL_COMMAND Command;
/* Clear the command packet */
RtlZeroMemory(&Command, sizeof(AUTODIAL_COMMAND));
/* Copy the address into the command packet */
RtlCopyMemory(&Command.Address, ConnectionAddress, sizeof(AUTODIAL_ADDR));
/* Send it to the driver */
return AcsHlpSendCommand(&Command);
}
/*
* @implemented
*/
BOOLEAN
WINAPI
AcsHlpNoteNewConnection(IN PAUTODIAL_ADDR ConnectionAddress,
IN PAUTODIAL_CONN Connection)
{
AUTODIAL_COMMAND Command;
/* Copy the address into the command packet */
RtlCopyMemory(&Command.Address, ConnectionAddress, sizeof(AUTODIAL_ADDR));
/* Set the New Connection flag and copy the connection data */
Command.NewConnection = TRUE;
RtlCopyMemory(&Command.Connection, Connection, sizeof(AUTODIAL_CONN));
/* Send it to the driver */
return AcsHlpSendCommand(&Command);
}

View file

@ -0,0 +1,30 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Winsock 2 SPI
* FILE: lib/mswsock/lib/init.c
* PURPOSE: DLL Initialization
*/
/* INCLUDES ******************************************************************/
#include "precomp.h"
/* DATA **********************************************************************/
/* FUNCTIONS *****************************************************************/
BOOLEAN
WINAPI
DllMain(HINSTANCE Instance,
DWORD Reason,
LPVOID Reserved)
{
/* Check if we're being attached */
if (Reason == DLL_PROCESS_ATTACH)
{
/* Let's disable TLC calls as an optimization */
DisableThreadLibraryCalls(Instance);
}
/* We're done */
return TRUE;
}

View file

@ -0,0 +1,102 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Ancillary Function Driver DLL
* FILE: include/msafd.h
* PURPOSE: Ancillary Function Driver DLL header
*/
#define _WIN32_WINNT 0x502
#define _CRT_SECURE_NO_DEPRECATE
#define WIN32_NO_STATUS
/* PSDK Headers */
#include <winsock2.h>
#include <wsipx.h>
#include <wsnetbs.h>
#include <wininet.h>
/* NDK */
#include <iofuncs.h>
#include <rtltypes.h>
/* Shared GUIDs */
#include <nsp_dns.h>
/* These should go in rasadhlp.h */
#define FILE_DEVICE_ACD 0x000000F1
#define _ACD_CTL_CODE(function, method, access) \
CTL_CODE(FILE_DEVICE_ACD, function, method, access)
#define IOCTL_ACD_RESET \
_ACD_CTL_CODE(0, METHOD_BUFFERED, FILE_WRITE_ACCESS)
#define IOCTL_ACD_ENABLE \
_ACD_CTL_CODE(1, METHOD_BUFFERED, FILE_WRITE_ACCESS)
#define IOCTL_ACD_NOTIFICATION \
_ACD_CTL_CODE(2, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_ACD_KEEPALIVE \
_ACD_CTL_CODE(3, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_ACD_COMPLETION \
_ACD_CTL_CODE(4, METHOD_BUFFERED, FILE_WRITE_ACCESS)
#define IOCTL_ACD_CONNECT_ADDRESS \
_ACD_CTL_CODE(5, METHOD_BUFFERED, FILE_READ_ACCESS)
typedef enum
{
AutoDialIp,
AutoDialIpx,
AutoDialNetBios,
AutoDialIpHost
} AUTODIAL_FAMILY;
typedef enum
{
ConnectionIpxLana,
ConnectionIp,
ConnectionIpHost,
ConnectionNetBiosMac,
} CONNECTION_FAMILY;
typedef struct _AUTODIAL_ADDR
{
AUTODIAL_FAMILY Family;
union
{
IN_ADDR Ip4Address;
CHAR IpxNode[6];
CHAR NetBiosAddress[NETBIOS_NAME_LENGTH];
CHAR HostName[INTERNET_MAX_PATH_LENGTH];
};
} AUTODIAL_ADDR, *PAUTODIAL_ADDR;
typedef struct _AUTODIAL_CONN
{
CONNECTION_FAMILY Family;
union
{
UCHAR IpxLana;
ULONG Ip4Address;
WCHAR ConnectionName[32];
CHAR NetBiosMac[6];
};
} AUTODIAL_CONN, *PAUTODIAL_CONN;
typedef struct _AUTODIAL_COMMAND
{
AUTODIAL_ADDR Address;
BOOL NewConnection;
AUTODIAL_CONN Connection;
} AUTODIAL_COMMAND, *PAUTODIAL_COMMAND;
BOOLEAN
WINAPI
AcsHlpNoteNewConnection(
IN PAUTODIAL_ADDR ConnectionAddress,
IN PAUTODIAL_CONN Connection
);
BOOLEAN
WINAPI
AcsHlpAttemptConnection(
IN PAUTODIAL_ADDR ConnectionAddress
);

View file

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
<module name="rasadhlp" type="win32dll" installbase="system32" installname="rasadhlp.dll">
<importlibrary definition="rasadhlp.spec" />
<include base="ReactOS">include/reactos/winsock</include>
<include base="rasadhlp">.</include>
<library>kernel32</library>
<library>ntdll</library>
<library>ws2_32</library>
<file>autodial.c</file>
<file>init.c</file>
<file>winsock.c</file>
</module>

View file

@ -0,0 +1,6 @@
@ stdcall AcsHlpAttemptConnection(ptr)
@ stub AcsHlpNbConnection
@ stdcall AcsHlpNoteNewConnection(ptr ptr)
@ stdcall WSAttemptAutodialAddr(ptr long)
@ stdcall WSAttemptAutodialName(ptr)
@ stdcall WSNoteSuccessfulHostentLookup(ptr long)

View file

@ -0,0 +1,137 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Winsock 2 SPI
* FILE: lib/mswsock/lib/init.c
* PURPOSE: DLL Initialization
*/
/* INCLUDES ******************************************************************/
#include "precomp.h"
/* DATA **********************************************************************/
/* FUNCTIONS *****************************************************************/
/*
* @implemented
*/
BOOL
WINAPI
WSAttemptAutodialAddr(IN CONST SOCKADDR FAR *Name,
IN INT NameLength)
{
PSOCKADDR_IN Ip = (PSOCKADDR_IN)Name;
PSOCKADDR_NB NetBios = (PSOCKADDR_NB)Name;
AUTODIAL_ADDR AutodialAdddress;
/* Check the family type */
switch (Name->sa_family)
{
case AF_INET:
/* Normal IPv4, set the Autodial Address Data */
AutodialAdddress.Family = AutoDialIp;
AutodialAdddress.Ip4Address = Ip->sin_addr;
break;
case AF_NETBIOS:
/* NetBIOS, set the Autodial Address Data*/
AutodialAdddress.Family = AutoDialNetBios;
RtlCopyMemory(&AutodialAdddress.NetBiosAddress,
NetBios->snb_name,
NETBIOS_NAME_LENGTH);
break;
default:
/* Unsupported family type */
return FALSE;
}
/* Call the public routine */
return AcsHlpAttemptConnection(&AutodialAdddress);
}
/*
* @implemented
*/
BOOL
WINAPI
WSAttemptAutodialName(IN CONST LPWSAQUERYSETW Restrictions)
{
AUTODIAL_ADDR AutodialAdddress;
CHAR AnsiIp[17];
LPGUID Guid = Restrictions->lpServiceClassId;
/* Make sure we actually have a name */
if (!Restrictions->lpszServiceInstanceName) return FALSE;
/* Check if this is the Hostname GUID */
if (!memcmp(Guid, &HostnameGuid, sizeof(GUID)))
{
/* It is. Set up the Autodial Address Data */
AutodialAdddress.Family = AutoDialIpHost;
WideCharToMultiByte(CP_ACP,
0,
Restrictions->lpszServiceInstanceName,
-1,
AutodialAdddress.HostName,
INTERNET_MAX_PATH_LENGTH - 1,
0,
0);
/* Call the public routine */
return AcsHlpAttemptConnection(&AutodialAdddress);
}
else if (!memcmp(Guid, &AddressGuid, sizeof(GUID)))
{
/* It's actually the IP String GUID */
AutodialAdddress.Family = AutoDialIp;
/* Convert the IP String to ANSI and then convert it to IP */
WideCharToMultiByte(CP_ACP,
0,
Restrictions->lpszServiceInstanceName,
-1,
AnsiIp,
sizeof(AnsiIp) - 1,
0,
0);
_strlwr(AnsiIp);
AutodialAdddress.Ip4Address.S_un.S_addr = inet_addr(AnsiIp);
/* Make sure the IP is valid */
if (AutodialAdddress.Ip4Address.S_un.S_addr == -1) return FALSE;
/* Call the public routine */
return AcsHlpAttemptConnection(&AutodialAdddress);
}
else
{
/* Unknown GUID type */
return FALSE;
}
}
/*
* @implemented
*/
VOID
WINAPI
WSNoteSuccessfulHostentLookup(IN CONST CHAR FAR *Name,
IN CONST ULONG Address)
{
AUTODIAL_ADDR AutodialAdddress;
AUTODIAL_CONN AutodialConnection;
/* Make sure there actually is a name */
if (!(Name) || !strlen(Name)) return;
/* Setup the Address */
AutodialAdddress.Family = AutoDialIpHost;
strcpy(AutodialAdddress.HostName, Name);
/* Setup the new connection */
AutodialConnection.Family = ConnectionIp;
AutodialConnection.Ip4Address = Address;
AcsHlpNoteNewConnection(&AutodialAdddress, &AutodialConnection);
}