System Idle
8 отговора
174 прегледа
System Idle
Някой да знае как да прихвана нещо от рода на System Idle (нещо като автоматичния Away на ICQ когато не се ползва компютъра)?
AquilaX
____________
умният знае кога да говори, мъдрият знае кога да мълчи
AquilaX
____________
умният знае кога да говори, мъдрият знае кога да мълчи
Re: System Idle
mi primerno TApplication.OnIdle ama newqrwam towa da ti trqbwa... moje da se proweri dali raboti screeen savera ama towa ne sam mnogo siguren kak se prawi :)) pus towa choweka moje dasi e pusnal defrag i da e otishal da gleda telewiziq...
p.s. SystemParametersInfo dawa informaciq a mnogo raboti incl. ScreenSaver-a
p.s. SystemParametersInfo dawa informaciq a mnogo raboti incl. ScreenSaver-a
Редактирано от SDR на
Re: System Idle
Ami w momenta ne se sestam za nisto po elegntno ot towa da slozish hook na mouse + kbd i da resetwash edin timer(ako ima dwizenie ;-))) - predpolagam 4e ti triabwa nesto ot sorta - ako usera ne e prawil nisto sled n minuti puskash programa ili nesto podobno
---
Е т'ва е живот!
---
Е т'ва е живот!
Re: System Idle
:) и аз се сетих за това но си е играчка пък и трябва да е във външен процес за да следи цялата система т.е ощте един файл. Чудех се дали няма по лесен начин понеже в ICQ се ползва нещо такова но изглежда че няма.
Благодаря все пак на всички.
AquilaX
____________
умният знае кога да говори, мъдрият знае кога да мълчи
Благодаря все пак на всички.
AquilaX
____________
умният знае кога да говори, мъдрият знае кога да мълчи
Re: System Idle
Ami mislia 4e imashe na4in da ne e otdelno prilozenie - a pak za procesa - e niama kak ste ti triabwa oste edin razbira se - ako ne mozesh da se setish drugo - imam niakde primer za hook - bez dll oba4e ;-))
---
Е т'ва е живот!
---
Е т'ва е живот!
Re: System Idle
HOOK bez DLL??? postni malko da widim - che sha mi razbiesh totalno predstawite za adresniq model na WIN
Re: System Idle
Доколкото съм чел HOOK без DLL може да се направи но HOOK-ва само в текущото приложение.
AquilaX
____________
умният знае кога да говори, мъдрият знае кога да мълчи
AquilaX
____________
умният знае кога да говори, мъдрият знае кога да мълчи
Re: System Idle
Za sazalenie ne moga da nameria wrazkta no sam zapazil 4ast ot primera - ima e-mail adress taka 4e ako isksh prosto pishi - edinstwenoto koeto si spomniam 4e niakoga biah tarsil info kak da si napiawia "residentna" programa za WIn - ne se smej - ideiata beshe programata da si e skrita i da se obajda samo pri natiskaneto na opredelena kombinacia.
Ste se porowia oste malko
//------------------------------------------------------------------------------
// HOOK METHOD INSTANCE
//
// These few lines of code implement for windows hooks what MakeObjectInstance
// and FreeObjectInstance do for windows message functions. They allow a method
// to be written and passed into the SetWindowsHookEx API function rather than a
// stand alone function which cannot directly access variables or methods.
//
///
// The code is based entirely on the MakeObjectInstance and FreeObjectInstance
// in the Delphi Forms unit. In fact my only input has been to change a few
// names and make it work for Hook calls rather than Message calls. So I don't
// claim a lot. Borland's ownership of this code is recognised and I hope
// noone there minds my borrowing it and bodging it for this purpose!/
// This way of writing a hook function is a bit wasteful of memory for what you
// are doing (but hell, what's 4KB nowadays!, this isn't a Z80 and CPM).
//
// Only tested under Delphi 3.02
//
// Version 1.00 5-2-98 Grahame Marsh
//
// Freeware - you get it for free, I take nothing, I make no promises!
//
// Please feel free to contact me: [email protected]
//------------------------------------------------------------------------------
unit
HookInst;
interface
uses
Windows;
type
THookCall = packed record
Code : integer;
WParam : WPARAM;
LParam : LPARAM;
Result : LResult
end;
THookMethod = procedure (var HookCall: THookCall) of object;
function MakeHookInstance (Method: THookMethod): pointer;
procedure FreeHookInstance (ObjectInstance: pointer);
implementation
const
InstanceCount = 313; // set so that sizeof (TInstanceBlock) < PageSize
type
PObjectInstance = ^TObjectInstance;
TObjectInstance = packed record
Code: Byte;
Offset: Integer;
case Integer of
0: (Next: PObjectInstance);
1: (Method: THookMethod);
end;
type
PInstanceBlock = ^TInstanceBlock;
TInstanceBlock = packed record
Next: PInstanceBlock;
Code: array[1..2] of Byte;
WndProcPtr: Pointer;
Instances: array[0..InstanceCount] of TObjectInstance;
end;
var
InstBlockList : PInstanceBlock = nil;
InstFreeList : PObjectInstance = nil;
function StdHookProc (Code, WParam: WPARAM; LParam: LPARAM): LResult; stdcall; assembler;
asm
XOR EAX,EAX
PUSH EAX
PUSH LParam
PUSH WParam
PUSH Code
MOV EDX,ESP
MOV EAX,[ECX].Longint[4]
CALL [ECX].Pointer
ADD ESP,12
POP EAX
end;
{ Allocate a hook method instance }
function CalcJmpOffset(Src, Dest: Pointer): Longint;
begin
Result := Longint(Dest) - (Longint(Src) + 5);
end;
function MakeHookInstance(Method: THookMethod): Pointer;
const
BlockCode: array [1..2] of Byte = ($59, $E9);
PageSize = 4096;
var
Block: PInstanceBlock;
Instance: PObjectInstance;
begin
if InstFreeList = nil then
begin
Block := VirtualAlloc (nil, PageSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
Block^.Next := InstBlockList;
Move(BlockCode, Block^.Code, SizeOf(BlockCode));
Block^.WndProcPtr := Pointer(CalcJmpOffset(@Block^.Code[2], @StdHookProc));
Instance := @Block^.Instances;
repeat
Instance^.Code := $E8;
Instance^.Offset := CalcJmpOffset(Instance, @Block^.Code);
Instance^.Next := InstFreeList;
InstFreeList := Instance;
Inc(Longint(Instance), SizeOf(TObjectInstance));
until Longint(Instance) - Longint(Block) >= SizeOf(TInstanceBlock);
InstBlockList := Block
end;
Result := InstFreeList;
Instance := InstFreeList;
InstFreeList := Instance^.Next;
Instance^.Method := Method
end;
{ Free a hook method instance }
procedure FreeHookInstance (ObjectInstance: Pointer);
begin
if ObjectInstance <> nil then
begin
PObjectInstance(ObjectInstance)^.Next := InstFreeList;
InstFreeList := ObjectInstance
end
end;
end.
--------------------------------------------------------------------------------
---
Е т'ва е живот!
Ste se porowia oste malko
//------------------------------------------------------------------------------
// HOOK METHOD INSTANCE
//
// These few lines of code implement for windows hooks what MakeObjectInstance
// and FreeObjectInstance do for windows message functions. They allow a method
// to be written and passed into the SetWindowsHookEx API function rather than a
// stand alone function which cannot directly access variables or methods.
//
///
// The code is based entirely on the MakeObjectInstance and FreeObjectInstance
// in the Delphi Forms unit. In fact my only input has been to change a few
// names and make it work for Hook calls rather than Message calls. So I don't
// claim a lot. Borland's ownership of this code is recognised and I hope
// noone there minds my borrowing it and bodging it for this purpose!/
// This way of writing a hook function is a bit wasteful of memory for what you
// are doing (but hell, what's 4KB nowadays!, this isn't a Z80 and CPM).
//
// Only tested under Delphi 3.02
//
// Version 1.00 5-2-98 Grahame Marsh
//
// Freeware - you get it for free, I take nothing, I make no promises!
//
// Please feel free to contact me: [email protected]
//------------------------------------------------------------------------------
unit
HookInst;
interface
uses
Windows;
type
THookCall = packed record
Code : integer;
WParam : WPARAM;
LParam : LPARAM;
Result : LResult
end;
THookMethod = procedure (var HookCall: THookCall) of object;
function MakeHookInstance (Method: THookMethod): pointer;
procedure FreeHookInstance (ObjectInstance: pointer);
implementation
const
InstanceCount = 313; // set so that sizeof (TInstanceBlock) < PageSize
type
PObjectInstance = ^TObjectInstance;
TObjectInstance = packed record
Code: Byte;
Offset: Integer;
case Integer of
0: (Next: PObjectInstance);
1: (Method: THookMethod);
end;
type
PInstanceBlock = ^TInstanceBlock;
TInstanceBlock = packed record
Next: PInstanceBlock;
Code: array[1..2] of Byte;
WndProcPtr: Pointer;
Instances: array[0..InstanceCount] of TObjectInstance;
end;
var
InstBlockList : PInstanceBlock = nil;
InstFreeList : PObjectInstance = nil;
function StdHookProc (Code, WParam: WPARAM; LParam: LPARAM): LResult; stdcall; assembler;
asm
XOR EAX,EAX
PUSH EAX
PUSH LParam
PUSH WParam
PUSH Code
MOV EDX,ESP
MOV EAX,[ECX].Longint[4]
CALL [ECX].Pointer
ADD ESP,12
POP EAX
end;
{ Allocate a hook method instance }
function CalcJmpOffset(Src, Dest: Pointer): Longint;
begin
Result := Longint(Dest) - (Longint(Src) + 5);
end;
function MakeHookInstance(Method: THookMethod): Pointer;
const
BlockCode: array [1..2] of Byte = ($59, $E9);
PageSize = 4096;
var
Block: PInstanceBlock;
Instance: PObjectInstance;
begin
if InstFreeList = nil then
begin
Block := VirtualAlloc (nil, PageSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
Block^.Next := InstBlockList;
Move(BlockCode, Block^.Code, SizeOf(BlockCode));
Block^.WndProcPtr := Pointer(CalcJmpOffset(@Block^.Code[2], @StdHookProc));
Instance := @Block^.Instances;
repeat
Instance^.Code := $E8;
Instance^.Offset := CalcJmpOffset(Instance, @Block^.Code);
Instance^.Next := InstFreeList;
InstFreeList := Instance;
Inc(Longint(Instance), SizeOf(TObjectInstance));
until Longint(Instance) - Longint(Block) >= SizeOf(TInstanceBlock);
InstBlockList := Block
end;
Result := InstFreeList;
Instance := InstFreeList;
InstFreeList := Instance^.Next;
Instance^.Method := Method
end;
{ Free a hook method instance }
procedure FreeHookInstance (ObjectInstance: Pointer);
begin
if ObjectInstance <> nil then
begin
PObjectInstance(ObjectInstance)^.Next := InstFreeList;
InstFreeList := ObjectInstance
end
end;
end.
--------------------------------------------------------------------------------
---
Е т'ва е живот!