ReactOS  0.4.14-dev-583-g2a1ba2c
iphlpapi_reactos.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Networking
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: dll/win32/iphlpapi/iphlpapi_reactos.c
5  * PURPOSE: DHCP helper functions for ReactOS
6  * PROGRAMMERS: Pierre Schweitzer <pierre@reactos.org>
7  */
8 
9 #include "iphlpapi_private.h"
10 
12 
13 DWORD TCPSendIoctl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, PULONG pInBufferSize, LPVOID lpOutBuffer, PULONG pOutBufferSize)
14 {
15  BOOL Hack = FALSE;
16  HANDLE Event;
19 
20  /* FIXME: We don't have a global handle opened to \Device\Ip, so open one each time
21  * we need. In a future, it would be cool, just to pass it to TCPSendIoctl using the first arg
22  */
23  if (hDevice == INVALID_HANDLE_VALUE)
24  {
25  UNICODE_STRING DevName = RTL_CONSTANT_STRING(L"\\Device\\Ip");
27 
28  FIXME("Using the handle hack\n");
29  Hack = TRUE;
30 
32  &DevName,
34  NULL,
35  NULL);
36 
39  0, NULL, 0);
40  if (!NT_SUCCESS(Status))
41  {
43  }
44  }
45 
46  /* Sync event */
48  if (Event == NULL)
49  {
50  /* FIXME: See upper */
51  if (Hack)
52  {
53  CloseHandle(hDevice);
54  }
55  return GetLastError();
56  }
57 
58  /* Reinit, and call the networking stack */
61  Status = NtDeviceIoControlFile(hDevice, Event, NULL, NULL, &IoStatusBlock, dwIoControlCode, lpInBuffer, *pInBufferSize, lpOutBuffer, *pOutBufferSize);
62  if (Status == STATUS_PENDING)
63  {
66  }
67 
68  /* Close & return size info */
70  *pOutBufferSize = IoStatusBlock.Information;
71 
72  /* FIXME: See upper */
73  if (Hack)
74  {
75  CloseHandle(hDevice);
76  }
77 
78  /* Return result */
79  if (!NT_SUCCESS(Status))
80  {
82  }
83 
84  return ERROR_SUCCESS;
85 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
#define FILE_OPEN_IF
Definition: from_kernel.h:56
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG NTSTATUS
Definition: precomp.h:26
DWORD TCPSendIoctl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, PULONG pInBufferSize, LPVOID lpOutBuffer, PULONG pOutBufferSize)
WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi)
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
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)
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
smooth NULL
Definition: ftsmooth.c:416
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
unsigned long DWORD
Definition: ntddk_ex.h:95
#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
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
unsigned int * PULONG
Definition: retypes.h:1
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define GENERIC_EXECUTE
Definition: nt_native.h:91
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
_In_ DWORD dwIoControlCode
Definition: winddi.h:1700
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)