VB icon

Stealth

Email
Submitted on: 1/1/2015 7:00:00 AM
By: Dave Bayliss (from psc cd)  
Level: Intermediate
User Rating: By 4 Users
Compatibility: Delphi 5
Views: 1457
 
     Hide your porgams in the task manager, and from process lists. No one will ever know its there!
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
!**************************************
! for :Stealth
!**************************************
If you Like it then vote.
If you dont like it then tell me how to make it better!
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
!**************************************
! Name: Stealth
! Description:Hide your porgams in the task manager, and from process lists.
No one will ever know its there!
! By: Dave Bayliss (from psc cd)
!
! Assumes:This control does not work under Windows 2000 as the tasking is different, I use it on win 95, 98, ME systems and it works great!
!**************************************

{Created By David Bayliss http://www.dbayliss.com}
unit Stealth;
interface
uses
 WinTypes, WinProcs, Classes, Forms, SysUtils, Controls, Messages;
type
 TDuplicateComponent = class(Exception);
 TFormNotOwner = class(Exception);
 TStealth = class(TComponent)
 private
FHideForm: Boolean;
fHideApp: Boolean;
OldWndProc: TFarProc;
NewWndProc: Pointer;
function IsIt: Boolean;
procedure SetIt (Value: Boolean);
procedure SetHideApp(Value: Boolean);
procedure HookParent;
procedure UnhookParent;
procedure HookWndProc(var Message: TMessage);
 protected
{ Protected declarations }
procedure HideApplication;
procedure ShowApplication;
 public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Loaded; override;
procedure ProcessEnabled;
 published
{ Published declarations }
property HideForm: Boolean read IsIt write SetIt stored true default true;
property HideApp: Boolean read fHideApp write SetHideApp;
 end;
function RegisterServiceProcess(dwProcessID, dwType: Integer): Integer; stdcall; external 'KERNEL32.DLL';
procedure Register;
implementation
destructor TStealth.Destroy;
begin
 ShowApplication;
 UnhookParent;
 inherited destroy;
end;
constructor TStealth.Create(AOwner: TComponent);
var
 i: Word;
 CompCount: Byte;
begin
 inherited Create(AOwner);
 fHideform := true;
 NewWndProc := nil;
 OldWndProc := nil;
 CompCount := 0;
 if (csDesigning in ComponentState) then
if (AOwner is TForm) then
 with (AOwner as TForm) do
 begin
for i := 0 to ComponentCount - 1 do
 if Components[i] is TStealth then Inc(CompCount);
if CompCount > 1 then raise TDuplicateComponent.Create('There is already a TStealth component on this Form');
 end
 else
raise TFormNotOwner.Create('The owner of TStealth Component is not a TForm');
 HookParent;
end;
procedure TStealth.SetHideApp(Value: Boolean);
begin
 fHideApp := Value;
 if Value then
HideApplication
 else
ShowApplication;
end;
procedure TStealth.HideApplication;
begin
 if not (csDesigning in ComponentState) then
RegisterServiceProcess(GetCurrentProcessID, 1);
end;
procedure TStealth.ShowApplication;
begin
 if not (csDesigning in ComponentState) then
RegisterServiceProcess(GetCurrentProcessID, 0);
end;
procedure TStealth.Loaded;
begin
 inherited Loaded; { Always call inherited Loaded method }
 if not (csDesigning in ComponentState) then
ProcessEnabled;
end;
procedure TStealth.ProcessEnabled;
begin
 if not (csDesigning in ComponentState) then
if fHideform then
 ShowWindow(FindWindow(nil, @Application.Title[1]), SW_HIDE)
else
 ShowWindow(FindWindow(nil, @Application.Title[1]), SW_RESTORE);
end;
function TStealth.IsIt: Boolean;
begin
 Result := fHideform;
end;
procedure TStealth.SetIt(Value: Boolean);
begin
 fHideform := value;
 ProcessEnabled;
end;
procedure TStealth.HookParent;
begin
 if owner = nil then exit;
 OldWndProc := TFarProc(GetWindowLong((owner as TForm).Handle, GWL_WNDPROC));
 NewWndProc := MakeObjectInstance(HookWndProc);
 SetWindowLong((owner as TForm).Handle, GWL_WNDPROC, LongInt(NewWndProc));
end;
procedure TStealth.UnhookParent;
begin
 if (owner <> NIL) and Assigned(OldWndProc) then
SetWindowLong((owner as TForm).Handle, GWL_WNDPROC, LongInt(OldWndProc));
 if Assigned(NewWndProc) then
FreeObjectInstance(NewWndProc);
 NewWndProc := NIL;
 OldWndProc := NIL;
end;
procedure Register;
begin
 RegisterComponents('Dbayliss', [TStealth]);
end;
procedure TStealth.HookWndProc(var Message: TMessage);
begin
 if owner = NIL then exit;
if (Message.Msg = WM_SHOWWINDOW) then
 if (Message.wParam <> 0) then
ProcessEnabled;
 Message.Result := CallWindowProc(OldWndProc, (owner as TForm).Handle, Message.Msg, Message.wParam, Message.lParam);
end;
end.


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.