// checkdun.c - main (built with build.bat) // Copyright NAT Software, 2001 #include #include #define OK 1 #define SYSERR -1 char cur_dir[1024]; char sys_dir[1024]; char win_dir[1024]; OSVERSIONINFO version; int platform; int platform2; int completed; HINSTANCE hRasDll; int ras_loaded; char pbk_file[8192]; // RAS function prototypes DWORD APIENTRY (*pRasEnumEntries)(LPTSTR, LPTSTR, LPRASENTRYNAME, LPDWORD, LPDWORD); char buf[4096]; // Function prototypes DWORD FindNet95(HKEY hStartKey , char *pKeyName, char *rbuf); // // kprintf - low-level printf // int kprintf(char *fmt, ...) { va_list args; int i; int w; char buf[0x8000]; /* buf will be at top of stack */ va_start(args, fmt); vsprintf(buf, fmt, args); va_end(args); return MessageBox(NULL, buf, "NAT32 Dial-Up Connection Checker", MB_OKCANCEL | MB_SETFOREGROUND); } int main(int argc, char **argv) { if (argc != 1) { printf("Usage: checkdun\n"); return 0; } GetCurrentDirectory(1024, buf); GetShortPathName(buf, cur_dir, 1024); GetWindowsDirectory(win_dir, 1024); GetSystemDirectory(sys_dir, 1024); version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&version); if (version.dwPlatformId == VER_PLATFORM_WIN32_NT) platform = 1; if (version.dwMajorVersion == 5) platform2 = 1; // Windows 2000 if (platform2 == 0) load_ras(); CheckConnections(); return 0; } // // load_ras - load the RASAPI32.DLL if available // int load_ras() { hRasDll = LoadLibraryEx("rasapi32.dll", NULL, 0); if (hRasDll == 0) { ras_loaded = 0; return SYSERR; } // Load all needed functions if ((pRasEnumEntries = (int (*) ()) GetProcAddress(hRasDll, "RasEnumEntriesA")) == 0) { ras_loaded = 0; return SYSERR; } ras_loaded = 1; return OK; } // // CheckConnections - check all default phonebook RAS connections for // IP Header Compression, turning it off if needed. // int CheckConnections() { RASENTRYNAME names[256]; int i, n, size; int entries = 0; if (ras_loaded == 0) { printf("RAS not installed\n"); return SYSERR; } strcpy(pbk_file, sys_dir); strcat(pbk_file, "\\ras\\rasphone.pbk"); names[0].dwSize = sizeof(RASENTRYNAME); size = sizeof(names); n = pRasEnumEntries(NULL, NULL, names, &size, &entries); if (n) return OK; else for (i=0; i