mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 20:53:02 +00:00
Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys.
This commit is contained in:
parent
b94e2d8ca0
commit
c2c66aff7d
24198 changed files with 0 additions and 37285 deletions
11
sdk/lib/tdilib/CMakeLists.txt
Normal file
11
sdk/lib/tdilib/CMakeLists.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
# FIXFIX: You guys should move this header in include/reactos/libs/iphlpapi!
|
||||
include_directories(${REACTOS_SOURCE_DIR}/dll/win32/iphlpapi)
|
||||
list(APPEND SOURCE
|
||||
enum.c
|
||||
handle.c
|
||||
precomp.h)
|
||||
|
||||
add_library(tdilib ${SOURCE})
|
||||
add_pch(tdilib precomp.h SOURCE)
|
||||
add_dependencies(tdilib psdk)
|
124
sdk/lib/tdilib/enum.c
Normal file
124
sdk/lib/tdilib/enum.c
Normal file
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TDI interface
|
||||
* FILE: enum.c
|
||||
* PURPOSE: TDI entity enumeration
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
#include "tdilib.h"
|
||||
|
||||
/* A generic thing-getting function which interacts in the right way with
|
||||
* TDI. This may seem oblique, but I'm using it to reduce code and hopefully
|
||||
* make this thing easier to debug.
|
||||
*
|
||||
* The things returned can be any of:
|
||||
* TDIEntityID
|
||||
* TDIObjectID
|
||||
* IFEntry
|
||||
* IPSNMPInfo
|
||||
* IPAddrEntry
|
||||
* IPInterfaceInfo
|
||||
*/
|
||||
NTSTATUS tdiGetSetOfThings( HANDLE tcpFile,
|
||||
DWORD toiClass,
|
||||
DWORD toiType,
|
||||
DWORD toiId,
|
||||
DWORD teiEntity,
|
||||
DWORD teiInstance,
|
||||
DWORD fixedPart,
|
||||
DWORD entrySize,
|
||||
PVOID *tdiEntitySet,
|
||||
PDWORD numEntries ) {
|
||||
TCP_REQUEST_QUERY_INFORMATION_EX req = TCP_REQUEST_QUERY_INFORMATION_INIT;
|
||||
PVOID entitySet = 0;
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
DWORD allocationSizeForEntityArray = entrySize * MAX_TDI_ENTITIES,
|
||||
arraySize = entrySize * MAX_TDI_ENTITIES;
|
||||
|
||||
req.ID.toi_class = toiClass;
|
||||
req.ID.toi_type = toiType;
|
||||
req.ID.toi_id = toiId;
|
||||
req.ID.toi_entity.tei_entity = teiEntity;
|
||||
req.ID.toi_entity.tei_instance = teiInstance;
|
||||
|
||||
/* There's a subtle problem here...
|
||||
* If an interface is added at this exact instant, (as if by a PCMCIA
|
||||
* card insertion), the array will still not have enough entries after
|
||||
* have allocated it after the first DeviceIoControl call.
|
||||
*
|
||||
* We'll get around this by repeating until the number of interfaces
|
||||
* stabilizes.
|
||||
*/
|
||||
do {
|
||||
status = DeviceIoControl( tcpFile,
|
||||
IOCTL_TCP_QUERY_INFORMATION_EX,
|
||||
&req,
|
||||
sizeof(req),
|
||||
0,
|
||||
0,
|
||||
&allocationSizeForEntityArray,
|
||||
NULL );
|
||||
|
||||
if(!status)
|
||||
{
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
arraySize = allocationSizeForEntityArray;
|
||||
entitySet = HeapAlloc( GetProcessHeap(), 0, arraySize );
|
||||
|
||||
if( !entitySet ) {
|
||||
status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
return status;
|
||||
}
|
||||
|
||||
status = DeviceIoControl( tcpFile,
|
||||
IOCTL_TCP_QUERY_INFORMATION_EX,
|
||||
&req,
|
||||
sizeof(req),
|
||||
entitySet,
|
||||
arraySize,
|
||||
&allocationSizeForEntityArray,
|
||||
NULL );
|
||||
|
||||
/* This is why we have the loop -- we might have added an adapter */
|
||||
if( arraySize == allocationSizeForEntityArray )
|
||||
break;
|
||||
|
||||
HeapFree( GetProcessHeap(), 0, entitySet );
|
||||
entitySet = 0;
|
||||
|
||||
if(!status)
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
} while( TRUE ); /* We break if the array we received was the size we
|
||||
* expected. Therefore, we got here because it wasn't */
|
||||
|
||||
*numEntries = (arraySize - fixedPart) / entrySize;
|
||||
*tdiEntitySet = entitySet;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
VOID tdiFreeThingSet( PVOID things ) {
|
||||
HeapFree( GetProcessHeap(), 0, things );
|
||||
}
|
||||
|
||||
NTSTATUS tdiGetEntityIDSet( HANDLE tcpFile,
|
||||
TDIEntityID **entitySet,
|
||||
PDWORD numEntities ) {
|
||||
NTSTATUS status = tdiGetSetOfThings( tcpFile,
|
||||
INFO_CLASS_GENERIC,
|
||||
INFO_TYPE_PROVIDER,
|
||||
ENTITY_LIST_ID,
|
||||
GENERIC_ENTITY,
|
||||
0,
|
||||
0,
|
||||
sizeof(TDIEntityID),
|
||||
(PVOID *)entitySet,
|
||||
numEntities );
|
||||
|
||||
return status;
|
||||
}
|
||||
|
48
sdk/lib/tdilib/handle.c
Normal file
48
sdk/lib/tdilib/handle.c
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TDI interface
|
||||
* FILE: handle.c
|
||||
* PURPOSE: TDI transport handle management
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
const PWCHAR TcpFileName = L"\\Device\\Tcp";
|
||||
|
||||
NTSTATUS openTcpFile(PHANDLE tcpFile, ACCESS_MASK DesiredAccess)
|
||||
{
|
||||
UNICODE_STRING fileName;
|
||||
OBJECT_ATTRIBUTES objectAttributes;
|
||||
IO_STATUS_BLOCK ioStatusBlock;
|
||||
NTSTATUS status;
|
||||
|
||||
RtlInitUnicodeString( &fileName, TcpFileName );
|
||||
|
||||
InitializeObjectAttributes( &objectAttributes,
|
||||
&fileName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL );
|
||||
|
||||
status = NtOpenFile( tcpFile,
|
||||
DesiredAccess | SYNCHRONIZE,
|
||||
&objectAttributes,
|
||||
&ioStatusBlock,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
FILE_SYNCHRONOUS_IO_NONALERT);
|
||||
|
||||
/* String does not need to be freed: it points to the constant
|
||||
* string we provided */
|
||||
|
||||
if (!NT_SUCCESS(status))
|
||||
*tcpFile = INVALID_HANDLE_VALUE;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
VOID closeTcpFile( HANDLE h )
|
||||
{
|
||||
ASSERT(h != INVALID_HANDLE_VALUE);
|
||||
|
||||
NtClose( h );
|
||||
}
|
6
sdk/lib/tdilib/precomp.h
Normal file
6
sdk/lib/tdilib/precomp.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef _TDILIB_PCH_
|
||||
#define _TDILIB_PCH_
|
||||
|
||||
#include <iphlpapi_private.h>
|
||||
|
||||
#endif /* _TDILIB_PCH_ */
|
19
sdk/lib/tdilib/tdilib.h
Normal file
19
sdk/lib/tdilib/tdilib.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TDI interface
|
||||
* FILE: tdilib.h
|
||||
* PURPOSE: Shared TDI library header
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
NTSTATUS openTcpFile(PHANDLE tcpFile, ACCESS_MASK DesiredAccess);
|
||||
VOID closeTcpFile(HANDLE tcpFile);
|
||||
NTSTATUS tdiGetEntityIDSet( HANDLE tcpFile, TDIEntityID **entitySet,
|
||||
PDWORD numEntities );
|
||||
NTSTATUS tdiGetSetOfThings( HANDLE tcpFile, DWORD toiClass, DWORD toiType,
|
||||
DWORD toiId, DWORD teiEntity, DWORD teiInstance,
|
||||
DWORD fixedPart,
|
||||
DWORD entrySize, PVOID *tdiEntitySet,
|
||||
PDWORD numEntries );
|
||||
VOID tdiFreeThingSet( PVOID things );
|
Loading…
Add table
Add a link
Reference in a new issue