Guest User

Untitled

a guest
Jul 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. #include <windows.h>;
  2. #include <tchar.h>
  3. #include <thread>
  4. #include <chrono>
  5. using namespace std;
  6. using namespace std::chrono_literals;
  7.  
  8. HMODULE g_hModule;
  9. DWORD g_threadID;
  10. DWORD WINAPI MyThread(LPVOID);
  11.  
  12. typedef long(__thiscall * SendChat)(void* _pThis, int messageMode, int channelId, const string& receiver, const string& message);
  13.  
  14. INT APIENTRY DllMain(HMODULE hDLL, DWORD Reason, LPVOID Reserved)
  15. {
  16.  
  17.  
  18. switch (Reason)
  19. {
  20. case DLL_PROCESS_ATTACH:
  21. {
  22. g_hModule = hDLL;
  23. DisableThreadLibraryCalls(hDLL);
  24. CreateThread(NULL, NULL, &MyThread, NULL, NULL, &g_threadID);
  25.  
  26. break;
  27. }
  28. case DLL_THREAD_ATTACH:
  29. case DLL_PROCESS_DETACH:
  30. case DLL_THREAD_DETACH:
  31. break;
  32. }
  33. return TRUE;
  34. }
  35.  
  36.  
  37. DWORD WINAPI MyThread(LPVOID)
  38. {
  39. SendChat sendChatFunc = (SendChat)0x5077b0;
  40. sendChatFunc((DWORD*)0x1122c3a8, 5, 0, receiver, message);
  41. FreeLibraryAndExitThread(g_hModule, 0);
  42. }
  43.  
  44. void ProtocolGame::sendTalk(Otc::MessageMode mode, int channelId, const std::string& receiver, const std::string& message)
  45. {
  46. if(message.empty())
  47. return;
  48.  
  49. if(message.length() > 255) {
  50. g_logger.traceError("message too large");
  51. return;
  52. }
  53.  
  54. OutputMessagePtr msg(new OutputMessage);
  55. msg->addU8(Proto::ClientTalk);
  56. msg->addU8(Proto::translateMessageModeToServer(mode));
  57.  
  58. switch(mode) {
  59. case Otc::MessagePrivateTo:
  60. case Otc::MessageGamemasterPrivateTo:
  61. case Otc::MessageRVRAnswer:
  62. msg->addString(receiver);
  63. break;
  64. case Otc::MessageChannel:
  65. case Otc::MessageChannelHighlight:
  66. case Otc::MessageChannelManagement:
  67. case Otc::MessageGamemasterChannel:
  68. msg->addU16(channelId);
  69. break;
  70. default:
  71. break;
  72. }
  73.  
  74. msg->addString(message);
  75. send(msg);
  76. }
Add Comment
Please, Sign In to add comment