Registration Code (Part 1): w%kQ6
Registration Code (Part 2): b<#$1[*(cw~
In order to register on this forum, you must use the codes above. Combine them into one code (copy paste).

[SOURCE] Hook Connection To Any Server

Topics regarding the online game Nostale.
Post Reply
User avatar
atom0s
Site Admin
Posts: 411
Joined: Sun Jan 04, 2015 11:23 pm
Location: 127.0.0.1
Contact:

[SOURCE] Hook Connection To Any Server

Post by atom0s » Mon Nov 14, 2016 10:45 am

Here is how to connect to any server without altering the client exe at all. This can be done via DLL injection using the Detours library from Microsoft:
  1. /**
  2.  * Detour Prototypes
  3.  */
  4. extern "C"
  5. {
  6.     int         /**/(WINAPI *Real_connect)(SOCKET, const struct sockaddr*, int) = connect;
  7. };
  8.  
  9.  
  10. /**
  11.  * winsock2!connect Detour Callback
  12.  */
  13. int  __stdcall Mine_connect(SOCKET s, const struct sockaddr* name, int namelen)
  14. {
  15.     auto saddr = (sockaddr_in*)name;
  16.  
  17.  
  18.     // Check if this is a login attempt..
  19.     if (saddr->sin_port >= htons(4000) && saddr->sin_port <= htons(4013))
  20.     {
  21.         auto naddr = HookCore::instance().m_ConfigurationManager->GetConfigString("noshook", "override_server_addr");
  22.         auto nport = HookCore::instance().m_ConfigurationManager->GetConfigInt("noshook", "override_server_port", 4001);
  23.         saddr->sin_addr.s_addr = inet_addr(naddr);
  24.         saddr->sin_port = htons(nport);
  25.     }
  26.  
  27.  
  28.     return Real_connect(s, name, namelen);
  29. }
  30.  
  31.  
  32. // Apply the mutex detour:
  33. ::DetourTransactionBegin();
  34. ::DetourUpdateThread(::GetCurrentThread());
  35. ::DetourAttach(&(PVOID&)Real_connect, Mine_connect);
  36. ::DetourTransactionCommit();
Derp~
Need a great web host? Check out: AnHonestHost.com


Donations can be made via Paypal:
https://www.paypal.me/atom0s
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest