Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DHCP under Windows 95

0 views
Skip to first unread message

Alfons Hoogervorst

unread,
Dec 14, 1997, 3:00:00 AM12/14/97
to

Lo,

Not particulary useful; the data can also be retrieved using WinSock
API calls, or through registry API calls. However, it may be
interesting. Windows 95 (and 98) only; on RAS / dialup connections.
The DHCP data also has the DNS server addresses, but the layout of the
data doesn't seem to conform with the DHCP RFC (AFAIK).

There's also a VNBT VxD which seems to return network (not RAS)
specific data. I know how to call it, but I don't know exactly what
VNBT is for.

Bye.

---8<---

/* dhcpw32.c
* By Alfons Hoogervorst, 1997.
*/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock.h>
#include <stdlib.h>
#include <stdio.h>

#define DHCP_GET_DATA 1

int main()
{
HANDLE hDHCPVxD;
DWORD dhcp_size = 0, out = 0;
LPBYTE dhcp_data;

hDHCPVxD = CreateFile("\\\\.\\VDHCP.386",
0,
0,
NULL,
0,
FILE_FLAG_DELETE_ON_CLOSE,
0);

if ( hDHCPVxD == INVALID_HANDLE_VALUE )
{
printf("VxD not loaded, GetLastError(%ld)\n", GetLastError());
return 1;
}

if ( FALSE == DeviceIoControl(hDHCPVxD,
DHCP_GET_DATA,
&dhcp_size,
sizeof dhcp_size,
&dhcp_size,
sizeof dhcp_size,
&out,
NULL) )
/* Not big enough */
if ( GetLastError() == ERROR_BUFFER_OVERFLOW
&& NULL != (dhcp_data = malloc(dhcp_size)) )
{
/* Again, now with big buffer */
if ( FALSE == DeviceIoControl(hDHCPVxD,
DHCP_GET_DATA,
dhcp_data,
dhcp_size,
dhcp_data,
dhcp_size,
&out,
NULL) )
printf("Error getting data, GetLastError(%ld)\n",
GetLastError());
else
/* DHCP data according to Microsoft... */
printf("DHCP data returned address %s\n",
inet_ntoa(*((struct in_addr*)&dhcp_data[0x0C])));
free(dhcp_data);
}

CloseHandle(hDHCPVxD);

return 1;
}

+- Conceived Through Intercalation And Juxtaposition -+
| systems programmer / word player avant la lettre |
| proteus <hosted at> worldaccess nl |
+-----------------------------------------------------+

0 new messages