Compare commits

..

No commits in common. "3444c7e2c50acb80d71e094c70629da6430dd1eb" and "768cdde0aaaaff2015385777d5d2d4afe096744f" have entirely different histories.

2 changed files with 22 additions and 24 deletions

View file

@ -2,4 +2,3 @@ LIBRARY MSNRedirector.dll
EXPORTS
ImportThis @1
ImportMe @2

View file

@ -9,8 +9,6 @@ const char* MESSENGERSERVICE_DEFAULT = "vm9.computernewb.com";
char* MESSENGERSERVICE = NULL;
HKEY REGISTRYROOT;
HINTERNET(WINAPI * Real_InternetConnectA) (HINTERNET hInternet, LPCSTR lpszServerName, INTERNET_PORT nServerPort, LPCSTR lpszUserName, LPCSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext) = InternetConnectA;
HINTERNET(WINAPI * Real_InternetConnectW) (HINTERNET hInternet, LPCWSTR lpszServerName, INTERNET_PORT nServerPort, LPCWSTR lpszUserName, LPCWSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContect) = InternetConnectW;
@ -18,22 +16,22 @@ 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) {
// don't redirect the service itself that's BAD
if(strcmp(server, MESSENGERSERVICE) == 0) {
return false;
}
#if DEBUG
MessageBoxA(NULL, server, "checking for", MB_OK | MB_ICONINFORMATION);
#endif
LSTATUS status = RegQueryValueExA(REGISTRYROOT, server, NULL, NULL, NULL, NULL);
if (status == ERROR_SUCCESS) {
// TODO?: read keys to see where to go to
return true;
}
#if DEBUG
MessageBoxA(NULL, server, "no key for", MB_OK | MB_ICONERROR);
#endif
return false;
return (
/* msn live domains, commonly used */
strcmp(server, "nexus.passport.com") == 0 ||
strcmp(server, "messenger.hotmail.com") == 0 ||
strcmp(server, "loginnet.passport.com") == 0 ||
strcmp(server, "config.messenger.msn.com") == 0 ||
/* msn internal domains, rarely used, common in betas */
strcmp(server, "nexus.passport-int.com") == 0 ||
strcmp(server, "messenger.hotmail-int.com") == 0 ||
strcmp(server, "config.messenger.msn-int.com") == 0 /* || */
/* msn pre-production environment domains, very rarely used */
/*strcmp(server, "nexus.passport-ppe.com") == 0 ||
strcmp(server, "nexus.passporttest.com") == 0 ||
strcmp(server, "messenger.hotmail-ppe.com") == 0 ||
strcmp(server, "config.messenger.msn-ppe.com") == 0*/
);
}
HINTERNET WINAPI Patched_InternetConnectA(HINTERNET hInternet, LPCSTR lpszServerName, INTERNET_PORT nServerPort, LPCSTR lpszUserName, LPCSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext) {
@ -82,7 +80,6 @@ VOID LoadURL() {
SetFallbackService();
return;
}
REGISTRYROOT = key;
DWORD type;
DWORD size;
// Get size
@ -90,17 +87,20 @@ VOID LoadURL() {
if (status == ERROR_FILE_NOT_FOUND) {
SetFallbackService();
RegSetValueExA(key, "Server", 0, REG_SZ, (byte*)MESSENGERSERVICE, strlen(MESSENGERSERVICE));
RegCloseKey(key);
return;
}
if (status != ERROR_SUCCESS) {
char c[128];
sprintf_s(c, "Reading MSNRedirector Server from registry failed with system error %d\nFalling back to default", status);
MessageBoxA(NULL, c, "Computernewb MSNRedirector", MB_OK | MB_ICONERROR);
RegCloseKey(key);
SetFallbackService();
return;
}
if (type != REG_SZ) {
MessageBoxA(NULL, "Reading MSNRedirector Server from registry failed because the value is not a string.\nFalling back to default", "Computernewb MSNRedirector", MB_OK | MB_ICONERROR);
RegCloseKey(key);
SetFallbackService();
return;
}
@ -112,9 +112,11 @@ VOID LoadURL() {
sprintf_s(c, "Reading MSNRedirector Server from registry failed with system error %d\nFalling back to default", status);
MessageBoxA(NULL, c, "Computernewb MSNRedirector", MB_OK | MB_ICONERROR);
free(data);
RegCloseKey(key);
SetFallbackService();
return;
}
RegCloseKey(key);
MESSENGERSERVICE = (char*)data;
return;
}
@ -150,8 +152,6 @@ BOOL APIENTRY DllMain( HMODULE hModule,
//DetourDetach(&(PVOID&)Real_gethostbyname, Patched_gethostbyname);
DetourDetach(&(PVOID&)Real_getaddrinfo, Patched_getaddrinfo);
RegCloseKey(REGISTRYROOT);
DetourTransactionCommit();
break;
}
@ -159,5 +159,4 @@ BOOL APIENTRY DllMain( HMODULE hModule,
return TRUE;
}
__declspec(dllexport) void WINAPI ImportThis() {}
__declspec(dllexport) void WINAPI ImportMe() {}
__declspec(dllexport) void WINAPI ImportThis() {}