TSMyKernel32User32DllFuntion.cpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #include "StdAfx.h"
  2. #include "TSMyUser32DllFuntion.h"
  3. #include "TSMyKernel32DllFuntion.h"
  4. #include "TSRuntime.h"
  5. myWindowFromPoint my_WindowFromPoint = NULL;
  6. myGetWindowLong my_GetWindowLong = NULL;
  7. myFindWindowEx my_FindWindowEx = NULL;
  8. mySendMessage my_SendMessage = NULL;
  9. myPostMessage my_PostMessage = NULL;
  10. myGetWindowThreadProcessId my_GetWindowThreadProcessId = NULL;
  11. myFindWindow my_FindWindow = NULL;
  12. myGetWindow my_GetWindow = NULL;
  13. myScreenToClient my_ScreenToClient = NULL;
  14. myClientToScreen my_ClientToScreen = NULL;
  15. myGetCursorPos my_GetCursorPos = NULL;
  16. myIsWindow my_IsWindow = NULL;
  17. myZwOpenProcess my_ZwOpenProcess = NULL;
  18. myOpenProcess my_OpenProcess = NULL;
  19. myVirtualProtect my_VirtualProtect = NULL;
  20. myVirtualProtectEx my_VirtualProtectEx = NULL;
  21. myReadProcessMemory my_ReadProcessMemory = NULL;
  22. myWriteProcessMemory my_WriteProcessMemory = NULL;
  23. myTerminateProcess my_TerminateProcess = NULL;
  24. myCreateRemoteThread my_CreateRemoteThread = NULL;
  25. myDeviceIoControl my_DeviceIoControl = NULL;
  26. myGetTickCount my_myGetTickCount = NULL;
  27. mySleep my_sleep = NULL;
  28. bool InitialMykernel32DllWIN7()
  29. {
  30. bool bret = false;
  31. //my_ZwOpenProcess
  32. HMODULE hmod = ::LoadLibrary(L"ntdll.dll");
  33. if (hmod)
  34. {
  35. my_ZwOpenProcess = (myZwOpenProcess)::GetProcAddress(hmod, "ZwOpenProcess");
  36. if (my_ZwOpenProcess != NULL)
  37. bret = true;
  38. }
  39. return bret;
  40. }
  41. bool InitialMykernel32Dll()
  42. {
  43. bool bret = false;
  44. my_OpenProcess = (myOpenProcess)TSRuntime::GetPassR3HookFuntionAddr("kernel32.dll", "OpenProcess");
  45. my_VirtualProtect = (myVirtualProtect)TSRuntime::GetPassR3HookFuntionAddr("kernel32.dll", "VirtualProtect");
  46. my_ReadProcessMemory = (myReadProcessMemory)TSRuntime::GetPassR3HookFuntionAddr("kernel32.dll", "ReadProcessMemory");
  47. my_WriteProcessMemory = (myWriteProcessMemory)TSRuntime::GetPassR3HookFuntionAddr("kernel32.dll", "WriteProcessMemory");
  48. my_TerminateProcess = (myTerminateProcess)TSRuntime::GetPassR3HookFuntionAddr("kernel32.dll", "TerminateProcess");
  49. my_VirtualProtectEx = (myVirtualProtectEx)TSRuntime::GetPassR3HookFuntionAddr("kernel32.dll", "VirtualProtectEx");
  50. my_CreateRemoteThread = (myCreateRemoteThread)TSRuntime::GetPassR3HookFuntionAddr("kernel32.dll", "CreateRemoteThread");
  51. my_DeviceIoControl = (myDeviceIoControl)TSRuntime::GetPassR3HookFuntionAddr("kernel32.dll", "DeviceIoControl");
  52. my_myGetTickCount = (myGetTickCount)TSRuntime::GetPassR3HookFuntionAddr("kernel32.dll", "GetTickCount");
  53. my_sleep = (mySleep)TSRuntime::GetPassR3HookFuntionAddr("kernel32.dll", "Sleep");
  54. //my_ScreenToClient=(myScreenToClient)TSRuntime::GetPassR3HookFuntionAddr("user32.dll","ScreenToClient");
  55. //my_GetWindow=(myGetWindow)TSRuntime::GetPassR3HookFuntionAddr("user32.dll","GetWindow");
  56. //my_FindWindow=(myFindWindow)TSRuntime::GetPassR3HookFuntionAddr("user32.dll","FindWindowW");
  57. //my_WindowFromPoint=(myWindowFromPoint)TSRuntime::GetPassR3HookFuntionAddr("user32.dll","WindowFromPoint");
  58. //my_GetWindowLong=(myGetWindowLong)TSRuntime::GetPassR3HookFuntionAddr("user32.dll","GetWindowLongW");
  59. //my_FindWindowEx=(myFindWindowEx)TSRuntime::GetPassR3HookFuntionAddr("user32.dll","FindWindowExW");
  60. //TSRuntime::add_log( "my_GetCursorPos:%d,my_ClientToScreen:%d,my_ScreenToClient:%d,my_GetWindow:%d,my_FindWindow:%d,my_WindowFromPoint:%d,my_GetWindowLong:%d,my_FindWindowEx:%d",my_GetCursorPos,my_ClientToScreen
  61. // ,my_ScreenToClient,my_GetWindow,my_FindWindow,my_WindowFromPoint,my_GetWindowLong,my_FindWindowEx);
  62. if (my_OpenProcess == NULL
  63. || my_VirtualProtect == NULL
  64. || my_WriteProcessMemory == NULL
  65. || my_ReadProcessMemory == NULL
  66. || my_VirtualProtectEx == NULL
  67. || my_TerminateProcess == NULL
  68. || my_CreateRemoteThread == NULL)
  69. return bret;
  70. else
  71. bret = true;
  72. return bret;
  73. }
  74. bool InitialMyUser32Dll()
  75. {
  76. bool bret = false;
  77. my_GetCursorPos = (myGetCursorPos)TSRuntime::GetPassR3HookFuntionAddr("user32.dll", "GetCursorPos");
  78. my_ClientToScreen = (myClientToScreen)TSRuntime::GetPassR3HookFuntionAddr("user32.dll", "ClientToScreen");
  79. my_ScreenToClient = (myScreenToClient)TSRuntime::GetPassR3HookFuntionAddr("user32.dll", "ScreenToClient");
  80. my_GetWindow = (myGetWindow)TSRuntime::GetPassR3HookFuntionAddr("user32.dll", "GetWindow");
  81. my_FindWindow = (myFindWindow)TSRuntime::GetPassR3HookFuntionAddr("user32.dll", "FindWindowW");
  82. my_WindowFromPoint = (myWindowFromPoint)TSRuntime::GetPassR3HookFuntionAddr("user32.dll", "WindowFromPoint");
  83. my_GetWindowLong = (myGetWindowLong)TSRuntime::GetPassR3HookFuntionAddr("user32.dll", "GetWindowLongW");
  84. my_FindWindowEx = (myFindWindowEx)TSRuntime::GetPassR3HookFuntionAddr("user32.dll", "FindWindowExW");
  85. my_SendMessage = (mySendMessage)TSRuntime::GetPassR3HookFuntionAddr("user32.dll", "SendMessageW");
  86. my_PostMessage = (myPostMessage)TSRuntime::GetPassR3HookFuntionAddr("user32.dll", "PostMessageW");
  87. my_GetWindowThreadProcessId = (myGetWindowThreadProcessId)TSRuntime::GetPassR3HookFuntionAddr("user32.dll", "GetWindowThreadProcessId");
  88. my_IsWindow = (myIsWindow)TSRuntime::GetPassR3HookFuntionAddr("user32.dll", "IsWindow");
  89. //TSRuntime::add_log( "my_GetCursorPos:%d,my_ClientToScreen:%d,my_ScreenToClient:%d,my_GetWindow:%d,my_FindWindow:%d,my_WindowFromPoint:%d,my_GetWindowLong:%d,my_FindWindowEx:%d",my_GetCursorPos,my_ClientToScreen
  90. // ,my_ScreenToClient,my_GetWindow,my_FindWindow,my_WindowFromPoint,my_GetWindowLong,my_FindWindowEx);
  91. if (my_GetCursorPos == NULL
  92. || my_ClientToScreen == NULL
  93. || my_ScreenToClient == NULL
  94. || my_GetWindow == NULL
  95. || my_FindWindow == NULL
  96. || my_WindowFromPoint == NULL
  97. || my_GetWindowLong == NULL
  98. || my_FindWindowEx == NULL
  99. || my_SendMessage == NULL
  100. || my_PostMessage == NULL)
  101. return bret;
  102. else
  103. bret = true;
  104. return bret;
  105. }