Compare commits

..

1 commit

Author SHA1 Message Date
Elijah R b3e1c1dfa5 add http gateway 2024-06-15 01:25:34 -04:00
2 changed files with 24 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,24 @@ 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 ||
strcmp(server, "gateway.messenger.hotmail.com") == 0 ||
strcmp(server, "muser.gateway.messenger.hotmail.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 +82,6 @@ VOID LoadURL() {
SetFallbackService();
return;
}
REGISTRYROOT = key;
DWORD type;
DWORD size;
// Get size
@ -90,17 +89,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 +114,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 +154,6 @@ BOOL APIENTRY DllMain( HMODULE hModule,
//DetourDetach(&(PVOID&)Real_gethostbyname, Patched_gethostbyname);
DetourDetach(&(PVOID&)Real_getaddrinfo, Patched_getaddrinfo);
RegCloseKey(REGISTRYROOT);
DetourTransactionCommit();
break;
}
@ -159,5 +161,4 @@ BOOL APIENTRY DllMain( HMODULE hModule,
return TRUE;
}
__declspec(dllexport) void WINAPI ImportThis() {}
__declspec(dllexport) void WINAPI ImportMe() {}
__declspec(dllexport) void WINAPI ImportThis() {}