⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config95.c

📁 vc环境下的pgp源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*____________________________________________________________________________
	Copyright (C) 1998 Network Associates, Inc.
	All rights reserved.

	

	$Id: config95.c,v 1.11.4.2 1999/06/14 05:26:54 philipn Exp $
____________________________________________________________________________*/
#pragma message( "Compiling " __FILE__ ) 
#pragma message( "Last modified on " __TIMESTAMP__ ) 

#include <windows.h>
#include <stdio.h>
#include "Define.h"
#include "Lister.h"


char gNetSlot[5];
char gTransSlot[5];
char gEnumNetSlot[5];


/*
 *  Creates our "System\\CurrentControlSet\\Services\\Class\\NetTrans" Structure 	
 */
BOOL ConfigSystemNetTrans ()
{
	#define NetTransKey		"System\\CurrentControlSet\\Services\\Class\\NetTrans"
	#define Ndikey			"Ndi"
	#define Ndikeya			"Ndi\\Install"
	#define Ndikeyb			"Ndi\\Interfaces"
	#define Ndikeyc			"Ndi\\Remove"
	#define NDISkey			"NDIS"
	#define MAXKEYLENGTH	"1024"

	HKEY			hTransKey;
	HKEY			hNewKey;
	DWORD			dwIndex;
	LPSTR			SubKeyBuffer	= NULL;
	LPSTR			KeyBuffer		= NULL;
	DWORD			dwDisposition;
	char			Binary;

	dwIndex = 9999;
	/*Find an open position*/
	/*Assuming no forced order, we look for FIRST open position*/
	for(dwIndex = 9999; dwIndex > 0000; dwIndex --)
	{
		SubKeyBuffer = (char *)malloc (5);
		sprintf(SubKeyBuffer,"%04d", dwIndex);
		KeyBuffer = (char *)malloc (strlen(NetTransKey) +6);
		ZeroMemory (KeyBuffer, (strlen(NetTransKey) +6));
		strcat (KeyBuffer, NetTransKey);
		strcat (KeyBuffer, "\\");
		strcat (KeyBuffer, SubKeyBuffer);
		
		if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, KeyBuffer, 0, KEY_READ, &hTransKey)
						== ERROR_FILE_NOT_FOUND)
			break;

		RegCloseKey(hTransKey);
		free(KeyBuffer);
		free(SubKeyBuffer);
	}/*for*/
	//RegCloseKey(hTransKey);
	free(KeyBuffer);
	strcpy (gTransSlot, SubKeyBuffer);

	/*Create the tree structure*/
	/*ROOT*/	
	KeyBuffer = (char *)malloc (1024);
	ZeroMemory (KeyBuffer, (1024));

	strcat (KeyBuffer, NetTransKey);
	strcat (KeyBuffer, "\\");
	strcat (KeyBuffer, SubKeyBuffer);
	
	RegCreateKeyEx(HKEY_LOCAL_MACHINE, KeyBuffer,
	0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hNewKey,
	&dwDisposition);

	RegSetValueEx(hNewKey, "DeviceVxDs" , 0, REG_SZ, "PGPnet.vxd", 11);
	RegSetValueEx(hNewKey, "DevLoader" , 0, REG_SZ, "*ndis", 6);
	/*release date GET THIS FROM THE VXD*/
	RegSetValueEx(hNewKey, "DriverDate" , 0, REG_SZ, "06-10-99", 9);
	RegSetValueEx(hNewKey, "DeviceDesc" , 0, REG_SZ, "PGPnet Protocol driver", 24);
	//RegSetValueEx(hNewKey, "InfPath" , 0, REG_SZ, "PGPmact.inf", 12);
	RegSetValueEx(hNewKey, "PGPnetDelFlag" , 0, REG_SZ, "PGPnetDelFlag", 14);

	RegCloseKey(hNewKey);
 
	
	/*Create the tree structure*/
	/*Ndi*/
	ZeroMemory (KeyBuffer, (1024));

	strcat (KeyBuffer, NetTransKey);
	strcat (KeyBuffer, "\\");
	strcat (KeyBuffer, SubKeyBuffer);
	strcat (KeyBuffer, "\\");
	strcat (KeyBuffer, Ndikey);

	RegCreateKeyEx(HKEY_LOCAL_MACHINE, KeyBuffer,
	0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hNewKey,
	&dwDisposition);

	RegSetValueEx(hNewKey, "DeviceID" , 0, REG_SZ, "PGPtrans", 9);
	RegSetValueEx(hNewKey, "HelpText" , 0, REG_SZ,
				"PGPnet Protocol driver. By Network Associates Inc.", 51);
	RegSetValueEx(hNewKey, "InfSection" , 0, REG_SZ, "PGPtrans.ndi", 13);
	//RegSetValueEx(hNewKey, "InstallInf" , 0, REG_SZ, "", 1);
	RegSetValueEx(hNewKey, "MaxInstance" , 0, REG_SZ, "0", 2);

	RegCloseKey(hNewKey);

	/*Create the tree structure*/
	/*Ndi\\Install*/
	ZeroMemory (KeyBuffer, (1024));

	strcat (KeyBuffer, NetTransKey);
	strcat (KeyBuffer, "\\");
	strcat (KeyBuffer, SubKeyBuffer);
	strcat (KeyBuffer, "\\");
	strcat (KeyBuffer, Ndikeya);

	RegCreateKeyEx(HKEY_LOCAL_MACHINE, KeyBuffer,
	0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hNewKey,
	&dwDisposition);

	RegCloseKey(hNewKey);

	/*Create the tree structure*/
	/*Ndi\\Interfaces*/
	ZeroMemory (KeyBuffer, (1024));

	strcat (KeyBuffer, NetTransKey);
	strcat (KeyBuffer, "\\");
	strcat (KeyBuffer, SubKeyBuffer);
	strcat (KeyBuffer, "\\");
	strcat (KeyBuffer, Ndikeyb);

	RegCreateKeyEx(HKEY_LOCAL_MACHINE, KeyBuffer,
	0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hNewKey,
	&dwDisposition);

	RegSetValueEx(hNewKey, "DefLower" , 0, REG_SZ, "ndis3", 6);
	RegSetValueEx(hNewKey, "Lower" , 0, REG_SZ, "ndis3", 6);
	RegSetValueEx(hNewKey, "LowerRange" , 0, REG_SZ, "ndis3", 6);
	RegSetValueEx(hNewKey, "Upper" , 0, REG_SZ, "", 1);

	RegCloseKey(hNewKey);

	/*Create the tree structure*/
	/*Ndi\\Remove*/
	ZeroMemory (KeyBuffer, (1024));

	strcat (KeyBuffer, NetTransKey);
	strcat (KeyBuffer, "\\");
	strcat (KeyBuffer, SubKeyBuffer);
	strcat (KeyBuffer, "\\");
	strcat (KeyBuffer, Ndikeyc);

	RegCreateKeyEx(HKEY_LOCAL_MACHINE, KeyBuffer,
	0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hNewKey,
	&dwDisposition);

	RegCloseKey(hNewKey);

	/*Create the tree structure*/
	/*NDIS*/
	ZeroMemory (KeyBuffer, (1024));

	strcat (KeyBuffer, NetTransKey);
	strcat (KeyBuffer, "\\");
	strcat (KeyBuffer, SubKeyBuffer);
	strcat (KeyBuffer, "\\");
	strcat (KeyBuffer, NDISkey);

	RegCreateKeyEx(HKEY_LOCAL_MACHINE, KeyBuffer,
	0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hNewKey,
	&dwDisposition);

	
	RegSetValueEx(hNewKey, "LogDriverName" , 0, REG_SZ, "PGPMAC", 6);
	Binary = 3;
	RegSetValueEx(hNewKey, "MajorNdisVersion" , 0, REG_BINARY, &Binary, 1);
	Binary = 0x0a;
	RegSetValueEx(hNewKey, "MinorNdisVersion", 0, REG_BINARY, &Binary, 1);

	RegCloseKey(hNewKey);
	free(KeyBuffer);
	free(SubKeyBuffer);
	return TRUE;
}/*end*/


/*
 *  Creates our "System\\CurrentControlSet\\Services\\Class\\Net" Structure 	
 */
BOOL ConfigSystemNet ()
{
	#define NetKey			"System\\CurrentControlSet\\Services\\Class\\Net"
	#define Ndikey			"Ndi"
	#define Ndikeya			"Ndi\\Install"
	#define Ndikeyb			"Ndi\\Interfaces"
	#define NDISkey			"NDIS"
	#define MAXKEYLENGTH	"1024"

	HKEY			hNetKey;
	HKEY			hNewKey;
	DWORD			dwIndex;
	LPSTR			SubKeyBuffer	= NULL;
	LPSTR			KeyBuffer		= NULL;
	DWORD			dwDisposition;
	char			Binary;

	/*Find an open position*/
	/*Assuming no forced order, we look for FIRST open position*/
	for(dwIndex = 9999; dwIndex > 0000; dwIndex --)
	{
		SubKeyBuffer = (char *)malloc (5);
		sprintf(SubKeyBuffer,"%04d", dwIndex);
		KeyBuffer = (char *)malloc (strlen(NetKey) +6);
		ZeroMemory (KeyBuffer, (strlen(NetKey) +6));
		strcat (KeyBuffer, NetKey);
		strcat (KeyBuffer, "\\");
		strcat (KeyBuffer, SubKeyBuffer);
		
		if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, KeyBuffer, 0, KEY_READ, &hNetKey)
						== ERROR_FILE_NOT_FOUND)
			break;

		RegCloseKey(hNetKey);
		free(KeyBuffer);
		free(SubKeyBuffer);
	}/*for*/


	free(KeyBuffer);
	strcpy (gNetSlot, SubKeyBuffer);

	/*Create the tree structure*/
	/*ROOT*/	
	KeyBuffer = (char *)malloc (1024);
	ZeroMemory (KeyBuffer, (1024));

	strcat (KeyBuffer, NetKey);
	strcat (KeyBuffer, "\\");
	strcat (KeyBuffer, SubKeyBuffer);
	
	RegCreateKeyEx(HKEY_LOCAL_MACHINE, KeyBuffer,
	0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hNewKey,
	&dwDisposition);

	RegSetValueEx(hNewKey, "DeviceVxDs" , 0, REG_SZ, "PGPnet.vxd", 11);
	RegSetValueEx(hNewKey, "DevLoader" , 0, REG_SZ, "*ndis", 6);
	RegSetValueEx(hNewKey, "DeviceDesc" , 0, REG_SZ,
				"PGPnet Virtual Private Networking driver", 41);
	RegSetValueEx(hNewKey, "EnumPropPages" , 0, REG_SZ, "netdi.dll,EnumPropPages", 24);
	RegSetValueEx(hNewKey, "InfPath" , 0, REG_SZ, "Pgpmaca.inf", 12);
	RegSetValueEx(hNewKey, "PGPnetDelFlag" , 0, REG_SZ, "PGPnetDelFlag", 14);

	RegCloseKey(hNewKey);
 
	
	/*Create the tree structure*/
	/*Ndi*/
	ZeroMemory (KeyBuffer, (1024));

	strcat (KeyBuffer, NetKey);
	strcat (KeyBuffer, "\\");
	strcat (KeyBuffer, SubKeyBuffer);
	strcat (KeyBuffer, "\\");
	strcat (KeyBuffer, Ndikey);

	RegCreateKeyEx(HKEY_LOCAL_MACHINE, KeyBuffer,
	0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hNewKey,
	&dwDisposition);

	RegSetValueEx(hNewKey, "DeviceID" , 0, REG_SZ, "PGPmac", 7);
	RegSetValueEx(hNewKey, "HelpText" , 0, REG_SZ,
				"PGPnet Virtual Private Networking driver. By Network Associates Inc.", 69);
	RegSetValueEx(hNewKey, "InfSection" , 0, REG_SZ, "PGPmac.ndi", 11);
	RegSetValueEx(hNewKey, "InstallInf" , 0, REG_SZ, "", 1);

	RegCloseKey(hNewKey);

	/*Create the tree structure*/
	/*Ndi\\Install*/
	ZeroMemory (KeyBuffer, (1024));

	strcat (KeyBuffer, NetKey);
	strcat (KeyBuffer, "\\");
	strcat (KeyBuffer, SubKeyBuffer);
	strcat (KeyBuffer, "\\");
	strcat (KeyBuffer, Ndikeya);

	RegCreateKeyEx(HKEY_LOCAL_MACHINE, KeyBuffer,
	0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hNewKey,
	&dwDisposition);

	RegSetValueEx(hNewKey, "" , 0, REG_SZ, "PGPMAC.Install", 15);

	RegCloseKey(hNewKey);

	/*Create the tree structure*/
	/*Ndi\\Interfaces*/
	ZeroMemory (KeyBuffer, (1024));

	strcat (KeyBuffer, NetKey);
	strcat (KeyBuffer, "\\");
	strcat (KeyBuffer, SubKeyBuffer);
	strcat (KeyBuffer, "\\");
	strcat (KeyBuffer, Ndikeyb);

	RegCreateKeyEx(HKEY_LOCAL_MACHINE, KeyBuffer,
	0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hNewKey,
	&dwDisposition);

	RegSetValueEx(hNewKey, "DefLower" , 0, REG_SZ, "ethernet", 9);
	RegSetValueEx(hNewKey, "DefUpper" , 0, REG_SZ, "ndis3", 6);
	RegSetValueEx(hNewKey, "Lower" , 0, REG_SZ, "ethernet", 9);
	RegSetValueEx(hNewKey, "LowerRange" , 0, REG_SZ, "ethernet", 9);
	RegSetValueEx(hNewKey, "Upper" , 0, REG_SZ, "ndis3", 6);
	RegSetValueEx(hNewKey, "UpperRange" , 0, REG_SZ, "ndis3", 6);

	RegCloseKey(hNewKey);

	/*Create the tree structure*/
	/*NDIS*/
	ZeroMemory (KeyBuffer, (1024));

	strcat (KeyBuffer, NetKey);
	strcat (KeyBuffer, "\\");
	strcat (KeyBuffer, SubKeyBuffer);
	strcat (KeyBuffer, "\\");
	strcat (KeyBuffer, NDISkey);

	RegCreateKeyEx(HKEY_LOCAL_MACHINE, KeyBuffer,
	0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hNewKey,
	&dwDisposition);
	
	RegSetValueEx(hNewKey, "LogDriverName" , 0, REG_SZ, "PGPMAC", 7);

	Binary = 3;
	RegSetValueEx(hNewKey, "MajorNdisVersion" , 0, REG_BINARY, &Binary, 1);
	Binary = 0x0a;
	RegSetValueEx(hNewKey, "MinorNdisVersion", 0, REG_BINARY, &Binary, 1);

	RegCloseKey(hNewKey);
	free(KeyBuffer);
	free(SubKeyBuffer);
	#undef NetKey
	return TRUE;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -