TSRuntime.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. 本源码由TC简单软件科技有限公司开源,功能可以自由修改、发布、
  3. 长沙简单软件科技有限公司对于源码不做后期维护,,请大家在使用过程中遵循开源协议
  4. */
  5. #pragma once
  6. #include "TSMessage.h"
  7. #include "KeyMouse/MyKeyboardNamespace.h"
  8. #include "KeyMouse/MyMouseNamespace.h"
  9. ////TS保护盾的其他属性
  10. #define TSPROTECT_HIDE 0x00000001L //"phide [pid]" : 保护指定进程以及进程内的窗口不被非法访问.默认保护当前进程.(此模式需要加载驱动,目前仅支持32位系统)
  11. #define TSPROTECT_HIDE2 0x00000002L //"phide2 [pid]" : 同phide. 只是进程不隐藏(可在任务管理器中操作)
  12. typedef void* HMEMORYLOADER;
  13. void MemoryFreeLibrary(HMEMORYLOADER mod);
  14. class DXBind;
  15. class TSRuntime
  16. {
  17. public:
  18. static MyMouseNamespace g_Mouse;
  19. static MyKeyboardNamespace g_KeyBoard;
  20. static DXBind g_DxObj; //DX后台操作对象,全局唯一,就是一个com只能绑定一个窗口,多窗口就要多实例化几次了
  21. static CMessageData* pData; //定义为静态类成员,方便保存共享数据指针
  22. static HANDLE MapViewThread; //保存检测共享内存线程,方便卸载时调用TerminateThread结束线程
  23. static DWORD m_displayMode;
  24. static DWORD m_dwExStyle;
  25. static wchar_t RetStr[MAX_PATH * 4];
  26. static wchar_t SetPath[MAX_PATH];
  27. static LPOLESTR KeyPressCharMap[0x100]; //256个键位
  28. static BYTE VirtualToASCIIMap[0x100]; //256个键位
  29. static BYTE keyMap[0x100];
  30. static BYTE KeyPressMap[0x100];
  31. static BYTE RawInputKeyPressMap[0x100];
  32. static BYTE KeyPressMap_Mouse[0x100];
  33. static bool IsVipLogin;
  34. static bool IsRegLogin;
  35. static DWORD g_nChecktime;//记录时间
  36. static bool IsStartProtect;
  37. static HANDLE h_checkthread;//验证线程句柄
  38. static INT64 checkthreadtime;//校验线程时间
  39. static bool g_IsSYSKEY;//按下系统键例如:ATL
  40. static pMyDictInfo MyDictCount[20]; //存储当前所有字库,默认最大字库个数为20个
  41. static int nMaxStrHight[20]; //记录每个字库中,最高的字高.
  42. static int nMyDictCountsize[20]; //记录每个字库的数量
  43. static int NowUsingDictIndex;//记录当前正在使用字库的下标
  44. static COLORREF pLoadstrBuffer[11][MAX_PATH];//存储字库点阵还原图片颜色矩阵COLORREF
  45. static char bytestr[1024 * 3]; //存储点阵二进制信息最大存储为250*11
  46. static bool IsVirtualProtectEx;//是否驱动模式远程修改注入进程的页面保护属性
  47. static HWND hookHwnd;//记录要注入的窗口句柄
  48. static HMEMORYLOADER myUser32module;
  49. static HMEMORYLOADER mykernel32module;
  50. static bool IsInitialmyUser32module;
  51. static bool IsInitialmykernel32module;
  52. static wchar_t membstr[MAX_PATH * 400];
  53. static bool IsShowErrorMsg;
  54. static bool IsNpProtect;
  55. static bool IsWin7X64;
  56. static bool IsWin8X64;
  57. static DWORD IsProid;
  58. static DWORD ProtectPid[20];
  59. static wchar_t Regcode[MAX_PATH];//记录注册码信息
  60. static wchar_t VipCountCode[MAX_PATH];//记录VIP用户账户信息
  61. static DWORD ZwProtectVirtualMemoryRet;
  62. static wchar_t SetDictPwdString[MAX_PATH];
  63. static wchar_t SetPicPwdString[MAX_PATH];
  64. static wchar_t MachineCode[MAX_PATH];//
  65. static bool IsLoginlog;
  66. static BYTE SetSimModeType;
  67. static bool g_IsLoadDrive;
  68. //static CComBSTR newbstr;
  69. public:
  70. static HWND GetProcessMainWnd(DWORD dwProcessId); //获取自身窗口句柄
  71. static void getMode(wchar_t* mouse, wchar_t* key, wchar_t* display, DWORD& dwMouse, DWORD& dwKey, DWORD& dwDisplay);
  72. static void my_split(TCHAR* sourcestr, TCHAR* oldstr, TCHAR(*temp)[28], int& rlen);
  73. static void add_log(const char* fmt, ...);
  74. static int InitialWindowsVersion();//获取系统版本
  75. static bool EnablePrivilege(LPCTSTR pszPrivName, bool fEnable);
  76. static void initial();
  77. static bool MyWriteMemory(IN PWriteMemoryInfo WriteInfo);
  78. static int VipLogin(wchar_t* regcode, int type, bool isvip = true);
  79. static bool GetComPath(TCHAR* Path);
  80. static bool StartProtect(long enable, long type, int Pid = 0);
  81. static void InitKeyPressCharMap();//初始化KeyPressCharMap
  82. static void InitVirtualToASCIIMap();
  83. static void InitKeyMap();
  84. static void InitKeyPressMap();
  85. static int retrunLparamDown(int key);
  86. static BOOL MByteToWChar(LPCSTR lpcszStr, LPWSTR lpwszStr, DWORD dwSize);
  87. static BOOL WCharToMByte(LPCWSTR lpcwszStr, LPSTR lpszStr, DWORD dwSize);
  88. static DWORD GetPassR3HookFuntionAddr(char* modename, char* funname);
  89. static HMODULE GetRemoteModuleHandle(const wchar_t* module, short nPID);//获取指定进程ID的DLL模块句柄
  90. static HMODULE TSRuntime::GetRemoteModuleBase(const wchar_t* module, short nPID);
  91. static DWORD GetRemoteModuleBaseAddr(const wchar_t* module, short nPID);//获取指定进程ID的DLL模块地址
  92. static bool GetRemoteModulePath(const wchar_t* module, short nPID, wchar_t* modulepath);//获取指定进程ID的DLL模块路径
  93. static FARPROC GetRemoteProcAddress(wchar_t* module, const char* func, short nPID);//获取指定进程ID的DLL模块函数的地址
  94. static bool MyLoadLibrary();
  95. private:
  96. TSRuntime(void);
  97. ~TSRuntime(void);
  98. };
  99. ////访问控制
  100. //class TsMutex//创建临界区和销毁临界区
  101. //{
  102. //public:
  103. // TsMutex();
  104. // ~TsMutex();
  105. // CRITICAL_SECTION m_mutex;
  106. // void lock();
  107. // void unlock();
  108. //
  109. //};
  110. //
  111. //class TsMutexlock//进入和离开临界区
  112. //{
  113. //public:
  114. // TsMutexlock(TsMutex *ptcmutex);
  115. // ~TsMutexlock();
  116. // TsMutex *m_ptcmutex;
  117. //};