Advertisement
Guest User

DB!...

a guest
Nov 11th, 2017
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. http://forum.cheatengine.org/viewtopic.php?t=606184
  2.  
  3. hm, PostMessage should be able to manage it.
  4.  
  5. http://tools.stefankueng.com/SendMessage.html works
  6.  
  7. Though I tried creating this for x64 notepad and it didn't so clearly I've done something wrong
  8.  
  9. [code]local WM_KEYDOWN = 0x0100
  10. local WM_KEYUP = 0x0101
  11. local WM_CHAR = 0x102
  12.  
  13. local pmsScript = [[
  14. [ENABLE]
  15. alloc(postMessageStub,$1000)
  16. registerSymbol(postMessageStub)
  17. postMessageStub:
  18. push rbp
  19. mov rbp, rsp
  20. mov edx, [rcx+8]
  21. mov r8, [rcx+10]
  22. mov r9, [rcx+18]
  23. mov rcx, [rcx+0]
  24. sub rsp, 20
  25. call PostMessageA
  26. add rsp, 20
  27. pop rbp
  28. ret
  29. [DISABLE]
  30. unregisterSymbol(postMessageStub)
  31. dealloc(postMessageStub)
  32. ]]
  33. success, pms = autoAssemble(pmsScript)
  34. if not success then error('failed to create stub!') end
  35.  
  36. PostMessage = function(hwnd, msg, wparam, lparam)
  37. local postMessageMem = allocateMemory(32)
  38. writeQword(postMessageMem+0, hwnd)
  39. writeQword(postMessageMem+8, msg)
  40. writeQword(postMessageMem+16, wparam)
  41. writeQword(postMessageMem+24, lparam)
  42. executeCode('PostMessageStub',postMessageMem)
  43. deAlloc(postMessageMem)
  44. end
  45.  
  46. local hwnd = 0
  47. local t = createTimer()
  48. t.Interval = 100
  49. local sendCount = 0
  50. t.OnTimer = function(t)
  51. if hwnd == 0 then -- check if current foreground window is attached process's
  52. if getForegroundProcess() == getOpenedProcessID() then
  53. hwnd = getForegroundWindow()
  54. print('found')
  55. end
  56. else -- once we have the hwnd
  57. sendCount = sendCount + 1
  58. if sendCount >= 10 then
  59. t.destroy()
  60. autoAssemble(pmsScript, pms)
  61. print('done')
  62. return
  63. end
  64. PostMessage(hwnd, WM_KEYDOWN, VK_A, 1) -- VK_A = 65
  65. end
  66. end[/code]
  67.  
  68. Though I was able to use shellExecute to run that program from the command line essentially:
  69.  
  70. [code]local cmd = os.getenv('userprofile') .. '\\Desktop\\SendMessage-1.1.2.exe'
  71. local params ='/message:256 /wparam:65 /lparam:1 /post /windowclass:Edit /processname:' .. process
  72. shellExecute(cmd, params)
  73. [/code]
  74.  
  75. 65 is the code for 'a', F1 is 112 but I wanted something easier to test with. It also didn't work without the /windowclass but you can get that by running the SendMessage program and dragging the target/reticle to the game. Of course, once you get the window handle once
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement