📄 lister.c
字号:
return TRUE;
}/*end*/
/*
* SetbWan
*/
BOOL SetbWan(HWND hwnd)
{
/*NT*/
UINT NumberOfItems;
int Flag;
DWORD dwIndex = 0;
int cchTextMax = 1024;
LPSTR pszText = NULL;
LPSTR pszServiceName = NULL;
/*9598*/
HKEY hMainKey = HKEY_LOCAL_MACHINE;
HKEY hNewKeyb = NULL;
HKEY hkey = NULL;
unsigned long MaxValueNameLen;
unsigned long MaxDataNameLen;
LPBYTE pData = NULL;
LPBYTE pDatab = NULL;
DWORD dwType;
DWORD dwSize;
DWORD dwDisposition;
if (bIsNT)
{
NumberOfItems = ListView_GetSelectedCount(hwnd);
if (NumberOfItems == 0)
return FALSE;
NumberOfItems = ListView_GetItemCount(hwnd);
pszText = malloc(cchTextMax);
for (dwIndex = 0; dwIndex < NumberOfItems; dwIndex++)
{
ListView_GetItemText(hwnd, dwIndex, 0, pszText, cchTextMax);
Flag = ListView_GetItemState(hwnd, dwIndex, LVNI_SELECTED);
if (Flag == 2)
{
bWan = TRUE;
if (strstr (pszText, "WAN") == NULL)
if (strstr (pszText, "Wan") == NULL)
if (strstr (pszText, "wan") == NULL)
bWan = FALSE;
}/*if*/
}/*for*/
free (pszText);
return TRUE;
}/*if*/
else/*running 9598*/
{
/*Try to open the key*/
if (RegOpenKey(hMainKey, PATHTOADAPTERLIST, &hNewKeyb) == ERROR_SUCCESS)
{
/*Query NETWORKCARDS_KEYVALUE*/
RegQueryInfoKey(hNewKeyb, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, &MaxValueNameLen,
&MaxDataNameLen, NULL, NULL);
pData = (LPBYTE) calloc(sizeof(BYTE), MaxDataNameLen + 1);
pDatab = (LPBYTE) calloc(sizeof(BYTE), MaxDataNameLen + 1);
dwSize = MaxDataNameLen;
RegQueryValueEx(hNewKeyb, "FullSecuredCard", 0,
&dwType, pData, &dwSize);
dwSize = MaxDataNameLen;
RegQueryValueEx(hNewKeyb, (LPSTR)pData, 0,
&dwType, pDatab, &dwSize);
RegCloseKey(hNewKeyb);
if(strstr((LPSTR)pDatab, "Enum\\Root\\Net") == NULL)
bWan = FALSE;
else
bWan = TRUE;
free(pData);
free(pDatab);
/*WAN*/
if (bWan)
{
RegCreateKeyEx(HKEY_LOCAL_MACHINE, PATHTOPGPNETREGKEY,
0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey,
&dwDisposition);
RegSetValueEx(hkey, "CardType", 0, REG_SZ, "NDISWAN",
8);
RegCloseKey(hkey);
}/*if*/
/*LAN*/
else
{
RegCreateKeyEx(HKEY_LOCAL_MACHINE, PATHTOPGPNETREGKEY,
0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey,
&dwDisposition);
RegSetValueEx(hkey, "CardType", 0, REG_SZ, "NDIS",
5);
RegCloseKey(hkey);
}/*else*/
}/*if*/
return TRUE;
}/*else*/
}/*end*/
/*
* Check for correct version of Windows
*/
BOOL IsCorrectVersion(VOID)
{
OSVERSIONINFO osid;
osid.dwOSVersionInfoSize = sizeof (osid);
GetVersionEx (&osid);
bIsNT = FALSE;
switch (osid.dwPlatformId)
{
case VER_PLATFORM_WIN32s :
return FALSE;
/*Windows 95*/
case VER_PLATFORM_WIN32_WINDOWS :
return TRUE;
/*Windows NT*/
case VER_PLATFORM_WIN32_NT :
{
if (osid.dwMajorVersion >= 4)
{
bIsNT = TRUE;
return TRUE;
}/*if*/
return FALSE;
}/*case*/
default:
return FALSE;
}/*switch*/
}/*end*/
/*
* Invokes a binding review
*/
BOOL BindReview (HWND hwnd)
{
FARPROC fpExportedFunction = NULL;
HMODULE hNetcfgDll = NULL;
LPCTSTR lpModuleName = NETCFGDLL;
BOOL brc;
int tResult;
hNetcfgDll = LoadLibrary(lpModuleName);
if (hNetcfgDll == NULL)
return FALSE;
fpExportedFunction = (NetReviewFunc *) GetProcAddress(hNetcfgDll, SZNETREVIEW);
if(fpExportedFunction == NULL)
{
brc = FreeLibrary(hNetcfgDll);
return FALSE;
}/*if*/
tResult = (*fpExportedFunction) (hwnd, 0);
brc = FreeLibrary(hNetcfgDll);
return TRUE;
}/*end*/
/*
* Installs an NT INF file (assumed in same directory)
*/
BOOL InstallInfFile (HWND hwnd)
{
HKEY hkey;
FARPROC fpExportedFunction = NULL;
HMODULE hNetcfgDll = NULL;
LPCTSTR lpModuleName = NETCFGDLL;
UINT nBufferLengthMax = 1024;
BOOL brc;
DWORD dwReturn;
DWORD dwDisposition;
int tResult;
wchar_t *pwcPathofInf = NULL;
wchar_t *pwcPathtoInf = NULL;
LPTSTR PathofInf;
LPTSTR PathtoInf;
int i;
/*Get current dir.*/
PathofInf = SetExePath();
PathtoInf = (char *)malloc(strlen(PathofInf) + 20);
strcat(PathofInf, "\\");
strcpy(PathtoInf, PathofInf);
strcat(PathtoInf, INFNAME);
//Get the short path (no spaces)
GetShortPathName(PathofInf, PathofInf, strlen(PathofInf) + 1);
GetShortPathName(PathtoInf, PathtoInf, strlen(PathtoInf) + 1);
SetCurrentDirectory(PathofInf);
/*Convert path of inf to wide char*/
pwcPathofInf = malloc((strlen(PathofInf) + 1)*2);
i = mbstowcs(pwcPathofInf, PathofInf, strlen(PathofInf) + 1);
/*Convert path to the inf to wide char*/
pwcPathtoInf = malloc((strlen(PathtoInf) + 1)*2);
i = mbstowcs(pwcPathtoInf, PathtoInf, strlen(PathtoInf) + 1);
hNetcfgDll = LoadLibrary(lpModuleName);
if (hNetcfgDll == NULL)
return FALSE;
fpExportedFunction = (NetInstallFunc *) GetProcAddress(hNetcfgDll, SZNETINSTALL);
if(fpExportedFunction == NULL)
{
brc = FreeLibrary(hNetcfgDll);
return FALSE;
}/*if*/
/*WAN*/
if (bWan)
{
RegCreateKeyEx(HKEY_LOCAL_MACHINE, PATHTOPGPNETREGKEY,
0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey,
&dwDisposition);
RegSetValueEx(hkey, "CardType", 0, REG_SZ, "NDISWAN",
8);
RegCloseKey(hkey);
tResult = (*fpExportedFunction) (hwnd, L"PgpMac" , pwcPathtoInf, pwcPathofInf, "", INFINSTALL_SUPPORTED | INFINSTALL_INPROCINTERP,
&dwReturn);
}/*if*/
/*LAN*/
else
{
RegCreateKeyEx(HKEY_LOCAL_MACHINE, PATHTOPGPNETREGKEY,
0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey,
&dwDisposition);
RegSetValueEx(hkey, "CardType", 0, REG_SZ, "NDIS",
5);
RegCloseKey(hkey);
tResult = (*fpExportedFunction) (hwnd, L"PgpMac" , pwcPathtoInf, pwcPathofInf, "", INFINSTALL_SUPPORTED | INFINSTALL_INPROCINTERP,
&dwReturn);
}/*else*/
free (PathofInf);
free (PathtoInf);
free (pwcPathofInf);
free (pwcPathtoInf);
brc = FreeLibrary(hNetcfgDll);
if (tResult != 0)
return FALSE;
return TRUE;
}/*end*/
/*
* Removes an NT INF file (assumed in same directory)
*/
BOOL RemoveInfFile ()
{
FARPROC fpExportedFunction = NULL;
HMODULE hNetcfgDll = NULL;
LPCTSTR lpModuleName = NETCFGDLL;
LPTSTR lpBuffer = NULL;
UINT nBufferLengthMax = 1024;
BOOL brc;
DWORD dwReturn;
int tResult;
HWND hDesktop;
RemoveInf();
hDesktop = GetDesktopWindow();
hNetcfgDll = LoadLibrary(lpModuleName);
if (hNetcfgDll == NULL)
return FALSE;
fpExportedFunction = (NetRemoveFunc *) GetProcAddress( hNetcfgDll, SZNETREMOVE );
if(fpExportedFunction == NULL)
{
brc = FreeLibrary(hNetcfgDll);
return FALSE;
}/*if*/
tResult = (*fpExportedFunction) (hDesktop, L"PgpMac", INFINSTALL_SUPPORTED | INFINSTALL_INPROCINTERP,
&dwReturn);
brc = BindReview (hDesktop);
brc = FreeLibrary(hNetcfgDll);
if (tResult != 0)
return FALSE;
return TRUE;
}/*end*/
/*
* DisableBinding
*/
BOOL DisableBinding(LPTSTR Binding)
{
HKEY hkey;
LPTSTR lpFullBinding;
DWORD MaxData = 1024;
/*Allocate memory*/
lpFullBinding = malloc(strlen(KEYSTUB) + strlen(Binding) + 1);
/*Build value to write to disable key*/
strcpy(lpFullBinding, KEYSTUB);
strcat(lpFullBinding, Binding);
/*Open Tcpip disable key key*/
RegOpenKeyEx(HKEY_LOCAL_MACHINE, KEYTCPIPDISABLE, 0, KEY_SET_VALUE, &hkey);
/*Set key value*/
RegSetValueEx(hkey, BIND, 0, REG_MULTI_SZ, lpFullBinding,
strlen(lpFullBinding) + 1);
RegCloseKey(hkey);
RegOpenKeyEx(HKEY_LOCAL_MACHINE, KEYNETBTDISABLE, 0, KEY_SET_VALUE, &hkey);
RegSetValueEx(hkey, BIND, 0, REG_MULTI_SZ, lpFullBinding,
strlen(lpFullBinding) + 1);
RegCloseKey(hkey);
free (lpFullBinding);
free (Binding);
return TRUE;
}/*end*/
/*
* AmIBoundToTcpip95
*/
BOOL AmIBoundToTcpip95 (char *Key)
{
HKEY hkey = NULL;
UINT nValues;
LPSTR pValueBuffer;
DWORD dwIndex;
DWORD nValueNameLen;
DWORD nValueNameLenb;
LONG lResult;
BOOL Pass;
char *BaseKey = NULL;
Pass = FALSE;
if(!Key)
return FALSE;
BaseKey = (char *)malloc(strlen(Key) + 12);
ZeroMemory(BaseKey, (strlen(Key) + 12));
strcat(BaseKey, Key);
strcat(BaseKey, "\\Bindings");
/*Open key*/
if (RegOpenKey(HKEY_LOCAL_MACHINE, BaseKey, &hkey) == ERROR_SUCCESS)
{
/*Determine number of keys to enumerate*/
RegQueryInfoKey(hkey, NULL, NULL, NULL, NULL,
NULL, NULL, &nValues, &nValueNameLen,
NULL, NULL, NULL);
/*Retrieve Registry values*/
pValueBuffer = malloc(nValueNameLen + 1);
for (dwIndex = 0; dwIndex < nValues; dwIndex++)
{
nValueNameLenb = nValueNameLen + 1;
ZeroMemory(pValueBuffer,(nValueNameLen + 1));
lResult = RegEnumValue( hkey, dwIndex, pValueBuffer,
&nValueNameLenb, NULL, NULL, NULL, NULL);
if (strstr(pValueBuffer, "MSTCP"))
Pass = TRUE;
}/*for*/
free(pValueBuffer);
RegCloseKey (hkey);
}/*if*/
free(BaseKey);
if (Pass)
return TRUE;
return FALSE;
}/*end*/
/*
* RebootYesNo
*/
BOOL RebootYesNo ()
{
int RC;
if(bIsNT)
{
TOKEN_PRIVILEGES TpNew;
HANDLE hToken;
LUID ShutDownValue;
OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES |
TOKEN_QUERY, &hToken);
LookupPrivilegeValue( (LPSTR)NULL, SE_SHUTDOWN_NAME, &ShutDownValue);
TpNew.PrivilegeCount = 1;
TpNew.Privileges[0].Luid = ShutDownValue;
TpNew.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges( hToken, FALSE, &TpNew, sizeof(TpNew),
(TOKEN_PRIVILEGES *)NULL, (DWORD *)NULL);
}
RC = MessageBox (GetFocus(), STDREBOOTMSG, "Network Settings Change", MB_ICONWARNING | MB_YESNO);
switch (RC)
{
case IDYES:
ExitWindowsEx (EWX_REBOOT, 0);
return TRUE;
case IDNO:
return FALSE;
default:
return FALSE;
}/*switch*/
}
/*
* PutSAinRunKey
*/
BOOL PutSAinRunKey()
{
char* CommandLine;
HKEY hMainKey = HKEY_LOCAL_MACHINE;
HKEY hOpenKey = NULL;
LPBYTE pValue = NULL;
CommandLine = SetExePath();
strcat (CommandLine, "\\SetAdapter.exe");
GetShortPathName(CommandLine, CommandLine, strlen(CommandLine) + 1);
strcat (CommandLine, " runonce");
//Set Runonce entry
if (RegOpenKeyEx(hMainKey, RUNKEY, 0, KEY_ALL_ACCESS, &hOpenKey)
== ERROR_SUCCESS)
{
RegSetValueEx(hOpenKey, "ZZRunSetAdapter" , 0, REG_SZ, CommandLine, strlen(CommandLine)+1);
RegCloseKey (hOpenKey);
}/*if*/
free (CommandLine);
return TRUE;
}
/*
* PutSAinRunKey
*/
BOOL NeedReboot()
{
HKEY hMainKey = HKEY_LOCAL_MACHINE;
HKEY hOpenKey = NULL;
LPSTR Path;
//Set Runonce entry
if (RegOpenKeyEx(hMainKey, RUNONCE, 0, KEY_ALL_ACCESS, &hOpenKey)
== ERROR_SUCCESS)
{
Path = SetExePath();
strcat(Path, "\\setadapter.exe void");
GetShortPathName(Path, Path, strlen(Path) + 1);
RegSetValueEx(hOpenKey, "PGPnetNeedsReboot" , 0, REG_SZ, Path, strlen(Path)+1);
RegCloseKey (hOpenKey);
free(Path);
}/*if*/
return TRUE;
}
/*
* SetExePath
*/
char* SetExePath()
{
char* CommandLine;
LPSTR pstring;
char* pstringb;
int index;
pstring = (char*)malloc(1024);
ZeroMemory (pstring, 1024);
GetModuleFileName(NULL, pstring, 1024);
GetShortPathName(pstring, pstring, strlen(pstring) + 1);
index = strlen(pstring);
//malloc index + 10 (10 needed for runonce)
CommandLine = (char*)malloc (index + 10);
ZeroMemory (CommandLine, index + 10);
pstringb = pstring;
while (*pstring == '"')
{
*pstring ++;
}
*pstringb = *pstring;
while (*pstringb != '\0')
{
*pstringb ++;
}
while (*pstringb != '\\')
{
*pstringb --;
}
for (index = 0; pstring != pstringb; index ++)
{
CommandLine[index] = pstring[0];
pstring++;
}
CommandLine[index] = '\0';
return CommandLine;
}
/*To install inf file:
fpNetInstall = (NetInstallFunc *) GetProcAddress( hNetcfgDll, SZNETINSTALL );
tResult = ( *fpNetInstall ) ( hWindow,
TZPRODUCTNAME,
szInfPath,
szSrcPath,
NULL,
INFINSTALL_SUPPORTED | INFINSTALL_INPROCINTERP,
&dwReturn );
char szMsg[200];
LoadString(g_hInst, IDS_WRONGOS, szMsg, sizeof(szMsg));
MessageBox (NULL, szMsg, g_szAppName,
MB_OK|MB_ICONEXCLAMATION);
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -