return S_OK;
}
那么键盘状态是如何被获得的呢?请看下面的ida分析结果
.text:6D18C5EA _CKbd_GetDeviceState@8 proc near ; DATA XREF: .text:6D18C37Co
.text:6D18C5EA
.text:6D18C5EA arg_0 = dword ptr 8
.text:6D18C5EA arg_4 = dword ptr 0Ch
.text:6D18C5EA
.text:6D18C5EA mov edi, edi
.text:6D18C5EC push ebp
.text:6D18C5ED mov ebp, esp
.text:6D18C5EF mov eax, [ebp+arg_0]
.text:6D18C5F2 mov ecx, [eax+8]
.text:6D18C5F5 test byte ptr [ecx], 2
.text:6D18C5F8 jz short loc_6D18C60D
.text:6D18C5FA push esi
.text:6D18C5FB mov esi, [eax+4] ;根据跟踪分析。esi指向的内存为一个键盘状态表不同的键位如果按下为0x80,没有按下为00
.text:6D18C5FE push edi
.text:6D18C5FF mov edi, [ebp+arg_4]
.text:6D18C602 push 40h ;拷贝长度为0x100字节40h*4
.text:6D18C604 pop ecx
.text:6D18C605 rep movsd ;拷贝键盘状态给外部接收缓冲区
.text:6D18C607 pop edi
.text:6D18C608 xor eax, eax
.text:6D18C60A pop esi
.text:6D18C60B jmp short loc_6D18C612
.text:6D18C60D ; ---------------------------------------------------------------------------
.text:6D18C60D
.text:6D18C60D loc_6D18C60D: ; CODE XREF: CKbd_GetDeviceState(x,x)+Ej
.text:6D18C60D mov eax, 8007001Eh
.text:6D18C612
.text:6D18C612 loc_6D18C612: ; CODE XREF: CKbd_GetDeviceState(x,x)+21j
.text:6D18C612 pop ebp
.text:6D18C613 retn 8
.text:6D18C613 _CKbd_GetDeviceState@8 endp
通过跟踪得知存放缓冲区的是一个全局变量内存区 键盘表对应键位如下 我列出常用键。
基地址为:6d1a4448 这个地址可以通过跟踪esi的内容得到
6d1a4448h+2 = 1 到 6d1a4448h+bh = 0
6d1a4448h+ch = -
6d1a4448h+dh = =
6d1a4448h+1eh = a
6d1a4448h+30h = b
6d1a4448h+2eh = c
6d1a4448h+20h = d
6d1a4448h+12h = e
6d1a4448h+21h = f
6d1a4448h+22h = g
6d1a4448h+23h = h
6d1a4448h+17h = i
6d1a4448h+24h = j
6d1a4448h+25h = k
6d1a4448h+26h = l
6d1a4448h+32h = m
6d1a4448h+31h = n
6d1a4448h+18h = o
6d1a4448h+19h = p
6d1a4448h+10h = q
6d1a4448h+13h = r
6d1a4448h+1fh = s
6d1a4448h+14h = t
6d1a4448h+16h = u
6d1a4448h+2fh = v
6d1a4448h+11h = w
6d1a4448h+2dh = x
6d1a4448h+15h = y
6d1a4448h+2ch = z
6d1a4448h+1ch = enter
6d1a4448h+c8h = up
6d1a4448h+d0h = down
6d1a4448h+cbh = left
6d1a4448h+cdh = right