diff --git a/MSNRedirector/dllmain.cpp b/MSNRedirector/dllmain.cpp index bcdb923..2b52848 100644 --- a/MSNRedirector/dllmain.cpp +++ b/MSNRedirector/dllmain.cpp @@ -15,29 +15,37 @@ HINTERNET(WINAPI * Real_InternetConnectW) (HINTERNET hInternet, LPCWSTR lpszServ hostent * (WSAAPI * Real_gethostbyname) (const char *name) = gethostbyname; INT(WSAAPI * Real_getaddrinfo) (PCSTR pNodeName, PCSTR pServiceName, const ADDRINFOA *pHints, PADDRINFOA *ppResult) = getaddrinfo; +BOOL ServerNeedsPatching(const char* server) { + return ( + strcmp(server, "nexus.passport.com") == 0 || + strcmp(server, "messenger.hotmail.com") == 0 || + strcmp(server, "loginnet.passport.com") == 0 + ); +} + HINTERNET WINAPI Patched_InternetConnectA(HINTERNET hInternet, LPCSTR lpszServerName, INTERNET_PORT nServerPort, LPCSTR lpszUserName, LPCSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext) { - if (strcmp(lpszServerName, "nexus.passport.com") == 0 || strcmp(lpszServerName, "messenger.hotmail.com") == 0) { + if (ServerNeedsPatching(lpszServerName)) { return Real_InternetConnectA(hInternet, MESSENGERSERVICE, nServerPort, lpszUserName, lpszPassword, dwService, dwFlags, dwContext); } return Real_InternetConnectA(hInternet, lpszServerName, nServerPort, lpszUserName, lpszPassword, dwService, dwFlags, dwContext); } HINTERNET WINAPI Patched_InternetConnectW(HINTERNET hInternet, LPCWSTR lpszServerName, INTERNET_PORT nServerPort, LPCWSTR lpszUserName, LPCWSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext) { - if (lstrcmpW(lpszServerName, L"nexus.passport.com") == 0 || lstrcmpW(lpszServerName, L"messenger.hotmail.com") == 0) { + if (ServerNeedsPatching(CT2CA(lpszServerName))) { return Real_InternetConnectW(hInternet, CA2CT(MESSENGERSERVICE), nServerPort, lpszUserName, lpszPassword, dwService, dwFlags, dwContext); } return Real_InternetConnectW(hInternet, lpszServerName, nServerPort, lpszUserName, lpszPassword, dwService, dwFlags, dwContext); } hostent *WSAAPI Patched_gethostbyname(const char* name) { - if (strcmp(name, "messenger.hotmail.com") == 0) { + if (ServerNeedsPatching(name)) { name = MESSENGERSERVICE; } return Real_gethostbyname(name); } INT WSAAPI Patched_getaddrinfo(PCSTR pNodeName, PCSTR pServiceName, const ADDRINFOA *pHints, PADDRINFOA *ppResult) { - if (pNodeName != NULL && strcmp(pNodeName, "messenger.hotmail.com") == 0) { + if (pNodeName != NULL && ServerNeedsPatching(pNodeName)) { pNodeName = MESSENGERSERVICE; } return Real_getaddrinfo(pNodeName, pServiceName, pHints, ppResult);