Compare commits
2 commits
master
...
experiment
Author | SHA1 | Date | |
---|---|---|---|
3444c7e2c5 | |||
80bcc4f900 |
2 changed files with 24 additions and 22 deletions
|
@ -2,3 +2,4 @@ LIBRARY MSNRedirector.dll
|
|||
|
||||
EXPORTS
|
||||
ImportThis @1
|
||||
ImportMe @2
|
||||
|
|
|
@ -9,6 +9,8 @@ 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;
|
||||
|
||||
|
@ -16,22 +18,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) {
|
||||
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*/
|
||||
);
|
||||
// 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;
|
||||
}
|
||||
|
||||
HINTERNET WINAPI Patched_InternetConnectA(HINTERNET hInternet, LPCSTR lpszServerName, INTERNET_PORT nServerPort, LPCSTR lpszUserName, LPCSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext) {
|
||||
|
@ -80,6 +82,7 @@ VOID LoadURL() {
|
|||
SetFallbackService();
|
||||
return;
|
||||
}
|
||||
REGISTRYROOT = key;
|
||||
DWORD type;
|
||||
DWORD size;
|
||||
// Get size
|
||||
|
@ -87,20 +90,17 @@ 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,11 +112,9 @@ 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;
|
||||
}
|
||||
|
@ -152,6 +150,8 @@ BOOL APIENTRY DllMain( HMODULE hModule,
|
|||
//DetourDetach(&(PVOID&)Real_gethostbyname, Patched_gethostbyname);
|
||||
DetourDetach(&(PVOID&)Real_getaddrinfo, Patched_getaddrinfo);
|
||||
|
||||
RegCloseKey(REGISTRYROOT);
|
||||
|
||||
DetourTransactionCommit();
|
||||
break;
|
||||
}
|
||||
|
@ -159,4 +159,5 @@ BOOL APIENTRY DllMain( HMODULE hModule,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
__declspec(dllexport) void WINAPI ImportThis() {}
|
||||
__declspec(dllexport) void WINAPI ImportThis() {}
|
||||
__declspec(dllexport) void WINAPI ImportMe() {}
|
||||
|
|
Loading…
Reference in a new issue