mirror of
https://github.com/reactos/reactos.git
synced 2025-04-21 20:50:29 +00:00
Added some exports.
svn path=/trunk/; revision=3449
This commit is contained in:
parent
96561f80c2
commit
a8c82f2bfb
4 changed files with 401 additions and 12 deletions
65
reactos/lib/iphlpapi/debug.h
Normal file
65
reactos/lib/iphlpapi/debug.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS WinSock 2 Helper DLL for TCP/IP
|
||||
* FILE: include/debug.h
|
||||
* PURPOSE: Debugging support macros
|
||||
* DEFINES: DBG - Enable debug output
|
||||
* NASSERT - Disable assertions
|
||||
*/
|
||||
#ifndef __DEBUG_H
|
||||
#define __DEBUG_H
|
||||
|
||||
#define NORMAL_MASK 0x000000FF
|
||||
#define SPECIAL_MASK 0xFFFFFF00
|
||||
#define MIN_TRACE 0x00000001
|
||||
#define MID_TRACE 0x00000002
|
||||
#define MAX_TRACE 0x00000003
|
||||
|
||||
#define DEBUG_ULTRA 0xFFFFFFFF
|
||||
|
||||
#ifdef DBG
|
||||
|
||||
extern DWORD DebugTraceLevel;
|
||||
|
||||
#define WSH_DbgPrint(_t_, _x_) \
|
||||
if (((DebugTraceLevel & NORMAL_MASK) >= _t_) || \
|
||||
((DebugTraceLevel & _t_) > NORMAL_MASK)) { \
|
||||
DbgPrint("(%hS:%d)(%hS) ", __FILE__, __LINE__, __FUNCTION__); \
|
||||
DbgPrint _x_; \
|
||||
}
|
||||
|
||||
#ifdef ASSERT
|
||||
#undef ASSERT
|
||||
#endif
|
||||
|
||||
#ifdef NASSERT
|
||||
#define ASSERT(x)
|
||||
#else /* NASSERT */
|
||||
#define ASSERT(x) if (!(x)) { WSH_DbgPrint(MIN_TRACE, ("Assertion "#x" failed at %s:%d\n", __FILE__, __LINE__)); ExitProcess(0); }
|
||||
#endif /* NASSERT */
|
||||
|
||||
#else /* DBG */
|
||||
|
||||
#define WSH_DbgPrint(_t_, _x_)
|
||||
|
||||
#define ASSERT(x)
|
||||
|
||||
#endif /* DBG */
|
||||
|
||||
|
||||
#define assert(x) ASSERT(x)
|
||||
#define assert_irql(x) ASSERT_IRQL(x)
|
||||
|
||||
|
||||
#define UNIMPLEMENTED \
|
||||
WSH_DbgPrint(MIN_TRACE, ("(%s:%d)(%s) is unimplemented, \
|
||||
please try again later.\n", __FILE__, __LINE__, __FUNCTION__));
|
||||
|
||||
#define CHECKPOINT \
|
||||
WSH_DbgPrint(MIN_TRACE, ("\n"));
|
||||
|
||||
#define CP CHECKPOINT
|
||||
|
||||
#endif /* __DEBUG_H */
|
||||
|
||||
/* EOF */
|
314
reactos/lib/iphlpapi/iphlpapi.c
Normal file
314
reactos/lib/iphlpapi/iphlpapi.c
Normal file
|
@ -0,0 +1,314 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS Winsock 2 IP Helper API DLL
|
||||
* FILE: iphlpapi.c
|
||||
* PURPOSE: DLL entry
|
||||
* PROGRAMMERS: Robert Dickenson (robd@reactos.org)
|
||||
* REVISIONS:
|
||||
* RDD August 18, 2002 Created
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <iptypes.h>
|
||||
#include <ipexport.h>
|
||||
#include <iphlpapi.h>
|
||||
|
||||
#include "debug.h"
|
||||
//#include "trace.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define EXPORT STDCALL
|
||||
#else
|
||||
#define EXPORT CALLBACK
|
||||
#endif
|
||||
|
||||
#ifdef DBG
|
||||
|
||||
/* See debug.h for debug/trace constants */
|
||||
DWORD DebugTraceLevel = MAX_TRACE;
|
||||
|
||||
#endif /* DBG */
|
||||
|
||||
/* To make the linker happy */
|
||||
//VOID STDCALL KeBugCheck (ULONG BugCheckCode) {}
|
||||
|
||||
|
||||
BOOL
|
||||
EXPORT
|
||||
DllMain(HANDLE hInstDll,
|
||||
ULONG dwReason,
|
||||
PVOID Reserved)
|
||||
{
|
||||
//WSH_DbgPrint(MIN_TRACE, ("DllMain of iphlpapi.dll\n"));
|
||||
|
||||
switch (dwReason) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
/* Don't need thread attach notifications
|
||||
so disable them to improve performance */
|
||||
DisableThreadLibraryCalls(hInstDll);
|
||||
break;
|
||||
|
||||
case DLL_THREAD_ATTACH:
|
||||
break;
|
||||
|
||||
case DLL_THREAD_DETACH:
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
DWORD
|
||||
WINAPI
|
||||
AddIPAddress(IPAddr Address, IPMask IpMask, DWORD IfIndex, PULONG NTEContext, PULONG NTEInstance)
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
return 0L;
|
||||
}
|
||||
|
||||
|
||||
DWORD
|
||||
WINAPI
|
||||
SetIpNetEntry(PMIB_IPNETROW pArpEntry)
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
return 0L;
|
||||
}
|
||||
|
||||
DWORD
|
||||
WINAPI
|
||||
CreateIpForwardEntry(PMIB_IPFORWARDROW pRoute)
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
return 0L;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
DWORD
|
||||
WINAPI
|
||||
GetAdapterIndex(LPWSTR AdapterName, PULONG IfIndex)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD
|
||||
WINAPI
|
||||
GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DWORD
|
||||
WINAPI
|
||||
GetNumberOfInterfaces(OUT PDWORD pdwNumIf)
|
||||
{
|
||||
DWORD result = NO_ERROR;
|
||||
HKEY hKey;
|
||||
LONG errCode;
|
||||
int i = 0;
|
||||
|
||||
if (pdwNumIf == NULL) return ERROR_INVALID_PARAMETER;
|
||||
*pdwNumIf = 0;
|
||||
errCode = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Linkage", 0, KEY_READ, &hKey);
|
||||
if (errCode == ERROR_SUCCESS) {
|
||||
DWORD dwSize;
|
||||
errCode = RegQueryValueExW(hKey, L"Bind", NULL, NULL, NULL, &dwSize);
|
||||
if (errCode == ERROR_SUCCESS) {
|
||||
wchar_t* pData = (wchar_t*)malloc(dwSize * sizeof(wchar_t));
|
||||
errCode = RegQueryValueExW(hKey, L"Bind", NULL, NULL, (LPBYTE)pData, &dwSize);
|
||||
if (errCode == ERROR_SUCCESS) {
|
||||
wchar_t* pStr = pData;
|
||||
for (i = 0; *pStr != L'\0'; i++) {
|
||||
pStr = pStr + wcslen(pStr) + 1; // next string
|
||||
}
|
||||
}
|
||||
free(pData);
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
*pdwNumIf = i;
|
||||
} else {
|
||||
result = errCode;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
DWORD
|
||||
WINAPI
|
||||
GetInterfaceInfo(PIP_INTERFACE_INFO pIfTable, PULONG pOutBufLen)
|
||||
{
|
||||
DWORD result = ERROR_SUCCESS;
|
||||
DWORD dwSize;
|
||||
DWORD dwOutBufLen;
|
||||
DWORD dwNumIf;
|
||||
HKEY hKey;
|
||||
LONG errCode;
|
||||
int i = 0;
|
||||
|
||||
if ((errCode = GetNumberOfInterfaces(&dwNumIf)) != NO_ERROR) {
|
||||
_tprintf(_T("GetInterfaceInfo() failed with code 0x%08X - Use FormatMessage to obtain the message string for the returned error\n"), errCode);
|
||||
return errCode;
|
||||
}
|
||||
if (dwNumIf == 0) return ERROR_NO_DATA; // No adapter information exists for the local computer
|
||||
if (pOutBufLen == NULL) return ERROR_INVALID_PARAMETER;
|
||||
dwOutBufLen = sizeof(IP_INTERFACE_INFO) + dwNumIf * sizeof(IP_ADAPTER_INDEX_MAP);
|
||||
if (*pOutBufLen < dwOutBufLen || pIfTable == NULL) {
|
||||
*pOutBufLen = dwOutBufLen;
|
||||
return ERROR_INSUFFICIENT_BUFFER;
|
||||
}
|
||||
memset(pIfTable, 0, dwOutBufLen);
|
||||
pIfTable->NumAdapters = dwNumIf - 1;
|
||||
errCode = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Linkage", 0, KEY_READ, &hKey);
|
||||
if (errCode == ERROR_SUCCESS) {
|
||||
errCode = RegQueryValueExW(hKey, L"Bind", NULL, NULL, NULL, &dwSize);
|
||||
if (errCode == ERROR_SUCCESS) {
|
||||
wchar_t* pData = (wchar_t*)malloc(dwSize * sizeof(wchar_t));
|
||||
errCode = RegQueryValueExW(hKey, L"Bind", NULL, NULL, (LPBYTE)pData, &dwSize);
|
||||
if (errCode == ERROR_SUCCESS) {
|
||||
wchar_t* pStr = pData;
|
||||
for (i = 0; i < pIfTable->NumAdapters, *pStr != L'\0'; pStr += wcslen(pStr) + 1) {
|
||||
if (wcsstr(pStr, L"\\Device\\NdisWanIp") == 0) {
|
||||
wcsncpy(pIfTable->Adapter[i].Name, pStr, MAX_ADAPTER_NAME);
|
||||
pIfTable->Adapter[i].Index = i++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
free(pData);
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
} else {
|
||||
result = errCode;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
DWORD
|
||||
WINAPI
|
||||
GetNetworkParams(PFIXED_INFO pFixedInfo, PULONG pOutBufLen)
|
||||
{
|
||||
DWORD result = ERROR_SUCCESS;
|
||||
DWORD dwSize;
|
||||
HKEY hKey;
|
||||
LONG errCode;
|
||||
|
||||
if (pFixedInfo == NULL || pOutBufLen == NULL) return ERROR_INVALID_PARAMETER;
|
||||
|
||||
if (*pOutBufLen < sizeof(FIXED_INFO)) {
|
||||
*pOutBufLen = sizeof(FIXED_INFO);
|
||||
return ERROR_BUFFER_OVERFLOW;
|
||||
}
|
||||
memset(pFixedInfo, 0, sizeof(FIXED_INFO));
|
||||
|
||||
errCode = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters"), 0, KEY_READ, &hKey);
|
||||
if (errCode == ERROR_SUCCESS) {
|
||||
dwSize = sizeof(pFixedInfo->HostName);
|
||||
errCode = RegQueryValueExA(hKey, "Hostname", NULL, NULL, (LPBYTE)&pFixedInfo->HostName, &dwSize);
|
||||
dwSize = sizeof(pFixedInfo->DomainName);
|
||||
errCode = RegQueryValueExA(hKey, "Domain", NULL, NULL, (LPBYTE)&pFixedInfo->DomainName, &dwSize);
|
||||
if (errCode != ERROR_SUCCESS) {
|
||||
dwSize = sizeof(pFixedInfo->DomainName);
|
||||
errCode = RegQueryValueExA(hKey, "DhcpDomain", NULL, NULL, (LPBYTE)&pFixedInfo->DomainName, &dwSize);
|
||||
}
|
||||
dwSize = sizeof(pFixedInfo->EnableRouting);
|
||||
errCode = RegQueryValueEx(hKey, _T("IPEnableRouter"), NULL, NULL, (LPBYTE)&pFixedInfo->EnableRouting, &dwSize);
|
||||
RegCloseKey(hKey);
|
||||
} else {
|
||||
result = ERROR_NO_DATA; // No adapter information exists for the local computer
|
||||
}
|
||||
|
||||
errCode = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\Services\\NetBT\\Parameters"), 0, KEY_READ, &hKey);
|
||||
if (errCode == ERROR_SUCCESS) {
|
||||
dwSize = sizeof(pFixedInfo->ScopeId);
|
||||
errCode = RegQueryValueExA(hKey, "ScopeId", NULL, NULL, (LPBYTE)&pFixedInfo->ScopeId, &dwSize);
|
||||
if (errCode != ERROR_SUCCESS) {
|
||||
dwSize = sizeof(pFixedInfo->ScopeId);
|
||||
errCode = RegQueryValueExA(hKey, "DhcpScopeId", NULL, NULL, (LPBYTE)&pFixedInfo->ScopeId, &dwSize);
|
||||
}
|
||||
dwSize = sizeof(pFixedInfo->NodeType);
|
||||
errCode = RegQueryValueEx(hKey, _T("NodeType"), NULL, NULL, (LPBYTE)&pFixedInfo->NodeType, &dwSize);
|
||||
if (errCode != ERROR_SUCCESS) {
|
||||
dwSize = sizeof(pFixedInfo->NodeType);
|
||||
errCode = RegQueryValueExA(hKey, "DhcpNodeType", NULL, NULL, (LPBYTE)&pFixedInfo->NodeType, &dwSize);
|
||||
}
|
||||
dwSize = sizeof(pFixedInfo->EnableProxy);
|
||||
errCode = RegQueryValueEx(hKey, _T("EnableProxy"), NULL, NULL, (LPBYTE)&pFixedInfo->EnableProxy, &dwSize);
|
||||
dwSize = sizeof(pFixedInfo->EnableDns);
|
||||
errCode = RegQueryValueEx(hKey, _T("EnableDNS"), NULL, NULL, (LPBYTE)&pFixedInfo->EnableDns, &dwSize);
|
||||
RegCloseKey(hKey);
|
||||
} else {
|
||||
result = ERROR_NO_DATA; // No adapter information exists for the local computer
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DWORD
|
||||
WINAPI
|
||||
GetTcpStatistics(PMIB_TCPSTATS pStats)
|
||||
{
|
||||
DWORD result = NO_ERROR;
|
||||
|
||||
result = ERROR_NO_DATA;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DWORD
|
||||
WINAPI
|
||||
GetTcpTable(PMIB_TCPTABLE pTcpTable, PDWORD pdwSize, BOOL bOrder)
|
||||
{
|
||||
DWORD result = NO_ERROR;
|
||||
|
||||
result = ERROR_NO_DATA;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DWORD
|
||||
WINAPI
|
||||
GetUdpStatistics(PMIB_UDPSTATS pStats)
|
||||
{
|
||||
DWORD result = NO_ERROR;
|
||||
|
||||
result = ERROR_NO_DATA;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DWORD
|
||||
WINAPI
|
||||
GetUdpTable(PMIB_UDPTABLE pUdpTable, PDWORD pdwSize, BOOL bOrder)
|
||||
{
|
||||
DWORD result = NO_ERROR;
|
||||
|
||||
result = ERROR_NO_DATA;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DWORD
|
||||
WINAPI
|
||||
FlushIpNetTable(DWORD dwIfIndex)
|
||||
{
|
||||
DWORD result = NO_ERROR;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
@ -3,10 +3,15 @@
|
|||
LIBRARY iphlpapi.dll
|
||||
|
||||
EXPORTS
|
||||
AddIPAddress
|
||||
SetIpNetEntry
|
||||
CreateIpForwardEntry
|
||||
GetNetworkParams
|
||||
GetNumberOfInterfaces
|
||||
GetInterfaceInfo
|
||||
AddIPAddress @1
|
||||
SetIpNetEntry @107
|
||||
CreateIpForwardEntry @9
|
||||
GetNetworkParams @43
|
||||
GetNumberOfInterfaces @44
|
||||
GetInterfaceInfo @34
|
||||
GetTcpStatistics @47
|
||||
GetTcpTable @49
|
||||
GetUdpStatistics @51
|
||||
GetUdpTable @53
|
||||
FlushIpNetTable @17
|
||||
; EOF
|
||||
|
|
|
@ -3,10 +3,15 @@
|
|||
LIBRARY iphlpapi.dll
|
||||
|
||||
EXPORTS
|
||||
AddIPAddress=AddIPAddress@20
|
||||
SetIpNetEntry=SetIpNetEntry@4
|
||||
CreateIpForwardEntry=CreateIpForwardEntry@4
|
||||
GetNetworkParams=GetNetworkParams@8
|
||||
GetNumberOfInterfaces=GetNumberOfInterfaces@4
|
||||
GetInterfaceInfo=GetInterfaceInfo@8
|
||||
AddIPAddress=AddIPAddress@20 @1
|
||||
SetIpNetEntry=SetIpNetEntry@4 @107
|
||||
CreateIpForwardEntry=CreateIpForwardEntry@4 @9
|
||||
GetNetworkParams=GetNetworkParams@8 @43
|
||||
GetNumberOfInterfaces=GetNumberOfInterfaces@4 @44
|
||||
GetInterfaceInfo=GetInterfaceInfo@8 @34
|
||||
GetTcpStatistics=GetTcpStatistics@4 @47
|
||||
GetTcpTable=GetTcpTable@12 @49
|
||||
GetUdpStatistics=GetUdpStatistics@4 @51
|
||||
GetUdpTable=GetUdpTable@12 @53
|
||||
FlushIpNetTable=FlushIpNetTable@4 @17
|
||||
; EOF
|
||||
|
|
Loading…
Reference in a new issue