SHARE
TWEET

Send keyboard and mouse

a guest Jun 5th, 2018 176 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3.  
  4. #KEY_MOD_LCTRL   = $01
  5. #KEY_MOD_LSHIFT  = $02
  6. #KEY_MOD_LALT    = $04
  7. #KEY_MOD_LMETA   = $08
  8. #KEY_MOD_RCTRL   = $10
  9. #KEY_MOD_RSHIFT  = $20
  10. #KEY_MOD_RALT    = $40
  11. #KEY_MOD_RMETA   = $80
  12.  
  13.  
  14. #KEY_NONE  = $00 ; No key pressed
  15. #KEY_ERR_OVF  = $01 ;  Keyboard Error Roll Over - used For all slots If too many keys are pressed ("Phantom key")
  16. ;  = $02 ;  Keyboard POST Fail
  17. ;  = $03 ;  Keyboard Error Undefined
  18. #KEY_A  = $04 ; Keyboard a And A
  19. #KEY_B  = $05 ; Keyboard b And B
  20. #KEY_C  = $06 ; Keyboard c And C
  21. #KEY_D  = $07 ; Keyboard d And D
  22. #KEY_E  = $08 ; Keyboard e And E
  23. #KEY_F  = $09 ; Keyboard f And F
  24. #KEY_G  = $0a ; Keyboard g And G
  25. #KEY_H  = $0b ; Keyboard h And H
  26. #KEY_I  = $0c ; Keyboard i And I
  27. #KEY_J  = $0d ; Keyboard j And J
  28. #KEY_K  = $0e ; Keyboard k And K
  29. #KEY_L  = $0f ; Keyboard l And L
  30. #KEY_M  = $10 ; Keyboard m And M
  31. #KEY_N  = $11 ; Keyboard n And N
  32. #KEY_O  = $12 ; Keyboard o And O
  33. #KEY_P  = $13 ; Keyboard p And P
  34. #KEY_Q  = $14 ; Keyboard q And Q
  35. #KEY_R  = $15 ; Keyboard r And R
  36. #KEY_S  = $16 ; Keyboard s And S
  37. #KEY_T  = $17 ; Keyboard t And T
  38. #KEY_U  = $18 ; Keyboard u And U
  39. #KEY_V  = $19 ; Keyboard v And V
  40. #KEY_W  = $1a ; Keyboard w And W
  41. #KEY_X  = $1b ; Keyboard x And X
  42. #KEY_Y  = $1c ; Keyboard y And Y
  43. #KEY_Z  = $1d ; Keyboard z And Z
  44.  
  45. #KEY_1  = $1e ; Keyboard 1 And !
  46. #KEY_2  = $1f ; Keyboard 2 And @
  47. #KEY_3  = $20 ; Keyboard 3 And #
  48. #KEY_4  = $21 ; Keyboard 4 And $
  49. #KEY_5  = $22 ; Keyboard 5 And %
  50. #KEY_6  = $23 ; Keyboard 6 And ^
  51. #KEY_7  = $24 ; Keyboard 7 And &
  52. #KEY_8  = $25 ; Keyboard 8 And *
  53. #KEY_9  = $26 ; Keyboard 9 And (
  54. #KEY_0  = $27 ; Keyboard 0 And )
  55.  
  56. #KEY_ENTER  = $28 ; Keyboard Return (ENTER)
  57. #KEY_ESC  = $29 ; Keyboard ESCAPE
  58. #KEY_BACKSPACE  = $2a ; Keyboard DELETE (Backspace)
  59. #KEY_TAB  = $2b ; Keyboard Tab
  60. #KEY_SPACE  = $2c ; Keyboard Spacebar
  61. #KEY_MINUS  = $2d ; Keyboard - And _
  62. #KEY_EQUAL  = $2e ; Keyboard = And +
  63. #KEY_LEFTBRACE  = $2f ; Keyboard [ And {
  64. #KEY_RIGHTBRACE  = $30 ; Keyboard ] And }
  65. #KEY_BACKSLASH  = $31 ; Keyboard \ and |
  66. #KEY_HASHTILDE  = $32 ; Keyboard Non-US # And ~
  67. #KEY_SEMICOLON  = $33 ; Keyboard ; and :
  68. #KEY_APOSTROPHE  = $34 ; Keyboard ' and "
  69. #KEY_GRAVE  = $35 ; Keyboard ` And ~
  70. #KEY_COMMA  = $36 ; Keyboard , And <
  71. #KEY_DOT  = $37 ; Keyboard . And >
  72. #KEY_SLASH  = $38 ; Keyboard / And ?
  73. #KEY_CAPSLOCK  = $39 ; Keyboard Caps Lock
  74.  
  75. #KEY_F1  = $3a ; Keyboard F1
  76. #KEY_F2  = $3b ; Keyboard F2
  77. #KEY_F3  = $3c ; Keyboard F3
  78. #KEY_F4  = $3d ; Keyboard F4
  79. #KEY_F5  = $3e ; Keyboard F5
  80. #KEY_F6  = $3f ; Keyboard F6
  81. #KEY_F7  = $40 ; Keyboard F7
  82. #KEY_F8  = $41 ; Keyboard F8
  83. #KEY_F9  = $42 ; Keyboard F9
  84. #KEY_F10  = $43 ; Keyboard F10
  85. #KEY_F11  = $44 ; Keyboard F11
  86. #KEY_F12  = $45 ; Keyboard F12
  87.  
  88. #KEY_SYSRQ  = $46 ; Keyboard Print Screen
  89. #KEY_SCROLLLOCK  = $47 ; Keyboard Scroll Lock
  90. #KEY_PAUSE  = $48 ; Keyboard Pause
  91. #KEY_INSERT  = $49 ; Keyboard Insert
  92. #KEY_HOME  = $4a ; Keyboard Home
  93. #KEY_PAGEUP  = $4b ; Keyboard Page Up
  94. #KEY_DELETE  = $4c ; Keyboard Delete Forward
  95. #KEY_END  = $4d ; Keyboard End
  96. #KEY_PAGEDOWN  = $4e ; Keyboard Page Down
  97. #KEY_RIGHT  = $4f ; Keyboard Right Arrow
  98. #KEY_LEFT  = $50 ; Keyboard Left Arrow
  99. #KEY_DOWN  = $51 ; Keyboard Down Arrow
  100. #KEY_UP  = $52 ; Keyboard Up Arrow
  101.  
  102. #KEY_NUMLOCK  = $53 ; Keyboard Num Lock And Clear
  103. #KEY_KPSLASH  = $54 ; Keypad /
  104. #KEY_KPASTERISK  = $55 ; Keypad *
  105. #KEY_KPMINUS  = $56 ; Keypad -
  106. #KEY_KPPLUS  = $57 ; Keypad +
  107. #KEY_KPENTER  = $58 ; Keypad ENTER
  108. #KEY_KP1  = $59 ; Keypad 1 And End
  109. #KEY_KP2  = $5a ; Keypad 2 And Down Arrow
  110. #KEY_KP3  = $5b ; Keypad 3 And PageDn
  111. #KEY_KP4  = $5c ; Keypad 4 And Left Arrow
  112. #KEY_KP5  = $5d ; Keypad 5
  113. #KEY_KP6  = $5e ; Keypad 6 And Right Arrow
  114. #KEY_KP7  = $5f ; Keypad 7 And Home
  115. #KEY_KP8  = $60 ; Keypad 8 And Up Arrow
  116. #KEY_KP9  = $61 ; Keypad 9 And Page Up
  117. #KEY_KP0  = $62 ; Keypad 0 And Insert
  118. #KEY_KPDOT  = $63 ; Keypad . And Delete
  119.  
  120. #KEY_102ND  = $64 ; Keyboard Non-US \ and |
  121. #KEY_COMPOSE  = $65 ; Keyboard Application
  122. #KEY_POWER  = $66 ; Keyboard Power
  123. #KEY_KPEQUAL  = $67 ; Keypad =
  124.  
  125. #KEY_F13  = $68 ; Keyboard F13
  126. #KEY_F14  = $69 ; Keyboard F14
  127. #KEY_F15  = $6a ; Keyboard F15
  128. #KEY_F16  = $6b ; Keyboard F16
  129. #KEY_F17  = $6c ; Keyboard F17
  130. #KEY_F18  = $6d ; Keyboard F18
  131. #KEY_F19  = $6e ; Keyboard F19
  132. #KEY_F20  = $6f ; Keyboard F20
  133. #KEY_F21  = $70 ; Keyboard F21
  134. #KEY_F22  = $71 ; Keyboard F22
  135. #KEY_F23  = $72 ; Keyboard F23
  136. #KEY_F24  = $73 ; Keyboard F24
  137.  
  138. #KEY_OPEN  = $74 ; Keyboard Execute
  139. #KEY_HELP  = $75 ; Keyboard Help
  140. #KEY_PROPS  = $76 ; Keyboard Menu
  141. #KEY_FRONT  = $77 ; Keyboard Select
  142. #KEY_STOP  = $78 ; Keyboard Stop
  143. #KEY_AGAIN  = $79 ; Keyboard Again
  144. #KEY_UNDO  = $7a ; Keyboard Undo
  145. #KEY_CUT  = $7b ; Keyboard Cut
  146. #KEY_COPY  = $7c ; Keyboard Copy
  147. #KEY_PASTE  = $7d ; Keyboard Paste
  148. #KEY_FIND  = $7e ; Keyboard Find
  149. #KEY_MUTE  = $7f ; Keyboard Mute
  150. #KEY_VOLUMEUP  = $80 ; Keyboard Volume Up
  151. #KEY_VOLUMEDOWN  = $81 ; Keyboard Volume Down
  152. ;  = $82  Keyboard Locking Caps Lock
  153. ;  = $83  Keyboard Locking Num Lock
  154. ;  = $84  Keyboard Locking Scroll Lock
  155. #KEY_KPCOMMA  = $85 ; Keypad Comma
  156. ;  = $86  Keypad Equal Sign
  157. #KEY_RO  = $87 ; Keyboard International1
  158. #KEY_KATAKANAHIRAGANA  = $88 ; Keyboard International2
  159. #KEY_YEN  = $89 ; Keyboard International3
  160. #KEY_HENKAN  = $8a ; Keyboard International4
  161. #KEY_MUHENKAN  = $8b ; Keyboard International5
  162. #KEY_KPJPCOMMA  = $8c ; Keyboard International6
  163. ;  = $8d  Keyboard International7
  164. ;  = $8e  Keyboard International8
  165. ;  = $8f  Keyboard International9
  166. #KEY_HANGEUL  = $90 ; Keyboard LANG1
  167. #KEY_HANJA  = $91 ; Keyboard LANG2
  168. #KEY_KATAKANA  = $92 ; Keyboard LANG3
  169. #KEY_HIRAGANA  = $93 ; Keyboard LANG4
  170. #KEY_ZENKAKUHANKAKU  = $94 ; Keyboard LANG5
  171. ;  = $95  Keyboard LANG6
  172. ;  = $96  Keyboard LANG7
  173. ;  = $97  Keyboard LANG8
  174. ;  = $98  Keyboard LANG9
  175. ;  = $99  Keyboard Alternate Erase
  176. ;  = $9a  Keyboard SysReq/Attention
  177. ;  = $9b  Keyboard Cancel
  178. ;  = $9c  Keyboard Clear
  179. ;  = $9d  Keyboard Prior
  180. ;  = $9e  Keyboard Return
  181. ;  = $9f  Keyboard Separator
  182. ;  = $a0  Keyboard Out
  183. ;  = $a1  Keyboard Oper
  184. ;  = $a2  Keyboard Clear/Again
  185. ;  = $a3  Keyboard CrSel/Props
  186. ;  = $a4  Keyboard ExSel
  187.  
  188. ;  = $b0  Keypad 00
  189. ;  = $b1  Keypad 000
  190. ;  = $b2  Thousands Separator
  191. ;  = $b3  Decimal Separator
  192. ;  = $b4  Currency Unit
  193. ;  = $b5  Currency Sub-unit
  194. #KEY_KPLEFTPAREN  = $b6 ; Keypad (
  195. #KEY_KPRIGHTPAREN  = $b7 ; Keypad )
  196. ;  = $b8  Keypad {
  197. ;  = $b9  Keypad }
  198. ;  = $ba  Keypad Tab
  199. ;  = $bb  Keypad Backspace
  200. ;  = $bc  Keypad A
  201. ;  = $bd  Keypad B
  202. ;  = $be  Keypad C
  203. ;  = $bf  Keypad D
  204. ;  = $c0  Keypad E
  205. ;  = $c1  Keypad F
  206. ;  = $c2  Keypad XOr
  207. ;  = $c3  Keypad ^
  208. ;  = $c4  Keypad %
  209. ;  = $c5  Keypad <
  210. ;  = $c6  Keypad >
  211. ;  = $c7  Keypad &
  212. ;  = $c8  Keypad &&
  213. ;  = $c9  Keypad |
  214. ;  = $ca  Keypad ||
  215. ;  = $cb  Keypad :
  216. ;  = $cc  Keypad #
  217. ;  = $cd  Keypad Space
  218. ;  = $ce  Keypad @
  219. ;  = $cf  Keypad !
  220. ;  = $d0  Keypad Memory Store
  221. ;  = $d1  Keypad Memory Recall
  222. ;  = $d2  Keypad Memory Clear
  223. ;  = $d3  Keypad Memory Add
  224. ;  = $d4  Keypad Memory Subtract
  225. ;  = $d5  Keypad Memory Multiply
  226. ;  = $d6  Keypad Memory Divide
  227. ;  = $d7  Keypad +/-
  228. ;  = $d8  Keypad Clear
  229. ;  = $d9  Keypad Clear Entry
  230. ;  = $da  Keypad Binary
  231. ;  = $db  Keypad Octal
  232. ;  = $dc  Keypad Decimal
  233. ;  = $dd  Keypad Hexadecimal
  234.  
  235. #KEY_LEFTCTRL  = $e0 ; Keyboard Left Control
  236. #KEY_LEFTSHIFT  = $e1 ; Keyboard Left Shift
  237. #KEY_LEFTALT  = $e2 ; Keyboard Left Alt
  238. #KEY_LEFTMETA  = $e3 ; Keyboard Left GUI
  239. #KEY_RIGHTCTRL  = $e4 ; Keyboard Right Control
  240. #KEY_RIGHTSHIFT  = $e5 ; Keyboard Right Shift
  241. #KEY_RIGHTALT  = $e6 ; Keyboard Right Alt
  242. #KEY_RIGHTMETA  = $e7 ; Keyboard Right GUI
  243.  
  244. #KEY_MEDIA_PLAYPAUSE  = $e8
  245. #KEY_MEDIA_STOPCD  = $e9
  246. #KEY_MEDIA_PREVIOUSSONG  = $ea
  247. #KEY_MEDIA_NEXTSONG  = $eb
  248. #KEY_MEDIA_EJECTCD  = $ec
  249. #KEY_MEDIA_VOLUMEUP  = $ed
  250. #KEY_MEDIA_VOLUMEDOWN  = $ee
  251. #KEY_MEDIA_MUTE  = $ef
  252. #KEY_MEDIA_WWW  = $f0
  253. #KEY_MEDIA_BACK  = $f1
  254. #KEY_MEDIA_FORWARD  = $f2
  255. #KEY_MEDIA_STOP  = $f3
  256. #KEY_MEDIA_FIND  = $f4
  257. #KEY_MEDIA_SCROLLUP  = $f5
  258. #KEY_MEDIA_SCROLLDOWN  = $f6
  259. #KEY_MEDIA_EDIT  = $f7
  260. #KEY_MEDIA_SLEEP  = $f8
  261. #KEY_MEDIA_COFFEE  = $f9
  262. #KEY_MEDIA_REFRESH  = $fa
  263. #KEY_MEDIA_CALC  = $fb
  264.  
  265.  
  266.  
  267. Structure SCSI_PASS_THROUGH_DIRECT ;PACK
  268.     Length.w ;0
  269.     ScsiStatus.b ;2
  270.     PathId.b ;3
  271.     TargetId.b ;4
  272.     Lun.b ;5
  273.     CdbLength.b ;6
  274.     SenseInfoLength.b ; 7
  275.     DataIn.b          ; 8    
  276.     __pack1.b
  277.     __pack2.b
  278.     __pack3.b
  279.     DataTransferLength.l ; 9 /  12
  280.     TimeOutValue.l
  281.     DataBuffer.l
  282.     SenseInfoOffset.l
  283.     Cdb.b[16]
  284.   EndStructure
  285.  
  286. #SCSI_IOCTL_DATA_OUT =          0
  287. #SCSI_IOCTL_DATA_IN  =          1
  288. #SCSI_IOCTL_DATA_UNSPECIFIED=       2
  289.  
  290.  
  291. Procedure _sendKeyboard(*p.SCSI_PASS_THROUGH_DIRECT, usb_key_mod, usb_key)
  292. *p\Length = SizeOf(SCSI_PASS_THROUGH_DIRECT)
  293. *p\ScsiStatus=0
  294. *p\PathId=0
  295. *p\TargetId=0
  296. *p\Lun=0
  297. *p\CdbLength=16
  298. *p\SenseInfoLength=24
  299. *p\DataIn=#SCSI_IOCTL_DATA_IN
  300. *p\DataTransferLength=0
  301. *p\TimeOutValue=5
  302. *p\DataBuffer=80
  303. *p\SenseInfoOffset=48
  304. *p\Cdb[0]=-39
  305. *p\Cdb[1]=52
  306. *p\Cdb[2]=usb_key_mod
  307. *p\Cdb[3]=0
  308. *p\Cdb[4]=usb_key
  309. *p\Cdb[5]=0
  310. *p\Cdb[6]=0
  311. *p\Cdb[7]=0
  312. *p\Cdb[8]=0
  313. *p\Cdb[9]=0
  314. *p\Cdb[10]=0
  315. *p\Cdb[11]=0
  316. *p\Cdb[12]=0
  317. *p\Cdb[13]=0
  318. *p\Cdb[14]=79
  319. *p\Cdb[15]=84
  320. EndProcedure  
  321.  
  322. Procedure _sendMouse(*p.SCSI_PASS_THROUGH_DIRECT, usb_mouse_keys, usb_mouse_dx, usb_mouse_dy)
  323. *p\Length = SizeOf(SCSI_PASS_THROUGH_DIRECT)
  324. *p\ScsiStatus=0
  325. *p\PathId=0
  326. *p\TargetId=0
  327. *p\Lun=0
  328. *p\CdbLength=16
  329. *p\SenseInfoLength=24
  330. *p\DataIn=#SCSI_IOCTL_DATA_IN
  331. *p\DataTransferLength=0
  332. *p\TimeOutValue=5
  333. *p\DataBuffer=80
  334. *p\SenseInfoOffset=48
  335. *p\Cdb[0]=-39
  336. *p\Cdb[1]=51
  337. *p\Cdb[2]=usb_mouse_keys
  338. *p\Cdb[3]=usb_mouse_dx
  339. *p\Cdb[4]=usb_mouse_dy
  340. *p\Cdb[5]=0
  341. *p\Cdb[6]=0
  342. *p\Cdb[7]=0
  343. *p\Cdb[8]=0
  344. *p\Cdb[9]=0
  345. *p\Cdb[10]=0
  346. *p\Cdb[11]=0
  347. *p\Cdb[12]=0
  348. *p\Cdb[13]=0
  349. *p\Cdb[14]=79
  350. *p\Cdb[15]=84
  351. EndProcedure  
  352.  
  353.  
  354.  
  355. Debug Hex(315396)
  356.  
  357.  
  358. in = AllocateMemory(65536)
  359. dev = CreateFile_("\\.\H:", #GENERIC_READ|#GENERIC_WRITE, #FILE_SHARE_READ | #FILE_SHARE_WRITE,0,#OPEN_EXISTING,0,0)
  360.  
  361.  
  362.  Debug dev
  363. Repeat
  364.  
  365.   t=t+1
  366.   IO=315412;315396;
  367.  
  368.   _sendKeyboard(in,#KEY_MOD_RSHIFT,#KEY_S)
  369.   DeviceIoControl_(dev,IO,in,44,in,80,@ret,#Null)
  370.   Delay(100)
  371.   _sendKeyboard(in,0,0)
  372.   DeviceIoControl_(dev,IO,in,44,in,80,@ret,#Null)
  373.  
  374.  
  375.   _sendMouse(in, 0, 1, 1)
  376.   DeviceIoControl_(dev,IO,in,44,in,80,@ret,#Null)
  377. ;_readData(in,buf, 65536)
  378. ;DeviceIoControl_(dev,315412,in,44,in,80,@ret,#Null)
  379.  
  380. Debug ret
  381. Delay(100)
  382.  
  383.  
  384.  
  385.  
  386. ForEver
  387.  
  388. Debug ret
  389. CloseHandle_(dev)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top