I am trying to use SendInput while it has been hooked by another application. The hook seems to be made by placing a jump at the start of the entry to SendInput. I have been trying the following code to get around this:
However, it does not work properly. The data seems to reach SendInput fine as I see a keystroke from the above code but immediately after I get an error "access violation at address 22f572, read of address f6" error. i'm not sure what is stored at 22f572 but 22f554 contains GInput. I have gone trough this with a debugger and the exception occurs when the return call is made. Oh the code is running in user mode by the way.
If anyone could suggest what the problem may be I would be grateful as this is driving me mad.
Code:
function TForm3.SendInputTunnelUser(cInputs: dword; nInputs: PINPUT; cbSize: dword):cardinal; stdcall;
asm
push cbSize
push nInputs
push cInputs
call @@Tunnel
ret
@@Tunnel:
mov eax, $11F6
mov edx, $7FFE0300
call dword ptr [edx]
ret $0C
end;
procedure TForm3.Button1Click(Sender: TObject);
Var
GInput: TINPUT; //GENERALINPUT;
x: integer;
y: boolean;
begin
GInput.Itype := INPUT_KEYBOARD;
GInput.ki.wVk := $5A;
GInput.ki.wScan := 0;
GInput.ki.time := 0;
GInput.ki.dwExtraInfo := 0;
GInput.ki.dwFlags := 0; //key down
x:=SendInputTunnelUser( 1, @GInput, SizeOf(GInput) );
end
However, it does not work properly. The data seems to reach SendInput fine as I see a keystroke from the above code but immediately after I get an error "access violation at address 22f572, read of address f6" error. i'm not sure what is stored at 22f572 but 22f554 contains GInput. I have gone trough this with a debugger and the exception occurs when the return call is made. Oh the code is running in user mode by the way.
If anyone could suggest what the problem may be I would be grateful as this is driving me mad.