首页  编辑  

Win2000下隐身

Tags: /超级猛料/OS.操作系统/Process.进程/   Date Created:

以下是我在experts提出的关于Windows2000下进程隐身的问题

Question: Hide my program  Date: 12/27/2000 01:00AM PST

From: bruce_luo

Status: Previously Asked Question  Points: 75

  I want develop a server program like LAN proxy server, but how can I hide

my program in Task List(TaskMgr.exe)? I try use RegisterServiceProcess

function, but this function not support Win2000. I know somebody already

used OpenProcess function to hided program. but how to do?

Sorry for my english -  it's rather bad .

Bruce Luo - Dragon P.C.

Comment

From: Madshi  Date: 12/27/2000 02:17AM PST

For win2000 you need to make your application be a service. Look here for

some infos about services: http://www.jgsoftware.com/nt.htm

Regards, Madshi.

Comment

From: tongalite  Date: 12/27/2000 02:06PM PST

I found this.... Perhaps it will help you... It's short and sweet!

Preventing Applications from Showing in the Task Bar . The code below will

prevent your application from showing in the Windows Task bar and the Task

list.

Using it is pretty straightforward: in your DPR file, after

Application.Initialize, set Application.Showmainform to False. Add this

code:

SetWindowLong( application.handle, GWL_EXSTYLE,

             GetWindowLong( application.handle, GWL_EXSTYLE )

               or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW );

-------------------------------------------

so-long!

Tony

Comment

From: inthe  Date: 12/28/2000 12:51AM PST

you cant just execute services,

to create them you can use File-New-Service Application.

(if you have that option else youll need to add SvcMgr to the uses and

create manually.)

then when youve made it you can use

from dos prompt

project1 /install

or

project1 /uninstall

to install and uninstall the service then

net start service2

net stop service2

or use control panel-admin tools-services to start and stop it.

below is example of a service and below that is example of starting and

stopping a service from code

:

go to the control panel - administrative tools - services to see it stop and

start when the buttons

are clicked in our delphi app.(may have to press refresh in service window)

the service (just beeps the speaker every 5 secs) :

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Classes,SvcMgr, ExtCtrls  ;

type

TService2 = class(TService)

  Timer1: TTimer;

  procedure Timer1Timer(Sender: TObject);

private

  { Private declarations }

public

  function GetServiceController: TServiceController; override;

  { Public declarations }

end;

var

Service2: TService2;

implementation

{$R *.DFM}

procedure ServiceController(CtrlCode: DWord); stdcall;

begin

Service2.Controller(CtrlCode);

end;

function TService2.GetServiceController: TServiceController;

begin

Result := ServiceController;

end;

procedure TService2.Timer1Timer(Sender: TObject);

begin

MessageBeep(1);

end;

end.

control app(not nessesary if you use control panel) :

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls,WinSvc;

type

TForm1 = class(TForm)

  Button1: TButton;

  Button2: TButton;

  procedure Button1Click(Sender: TObject);

  procedure Button2Click(Sender: TObject);

private

  { Private declarations }

public

  { Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.DFM}

function ServiceStart(sMachine, sService: String) : Boolean;

var

 schm,   schs: SC_Handle;

 ss: TServiceStatus;

 psTemp: PChar;

 dwChkP: DWord;

begin

 ss.dwCurrentState := 0;

schm := OpenSCManager(PChar(sMachine), nil, SC_MANAGER_CONNECT);

 if (schm>0) then

 begin

  schs := OpenService(schm, PChar(sService), SERVICE_START or

SERVICE_QUERY_STATUS);

   if (schs>0) then

  begin

    psTemp := nil;

     if (StartService(schs, 0, psTemp)) then

       if (QueryServiceStatus(schs, ss)) then

        while (SERVICE_RUNNING<>ss.dwCurrentState) do

         begin

          dwChkP := ss.dwCheckPoint;

           Sleep(ss.dwWaitHint);

          if (not QueryServiceStatus(schs, ss)) then

           Break;

           if ss.dwCheckPoint <> 0 then

             Break;

         end;

     CloseServiceHandle(schs);

   end;

  CloseServiceHandle(schm);

 end;

Result := SERVICE_RUNNING=ss.dwCurrentState;

end;

function ServiceStop(sMachine, sService: String) : Boolean;

var   schm,   schs: SC_Handle;

 ss: TServiceStatus;

dwChkP: DWord;

begin

schm := OpenSCManager(PChar(sMachine), nil, SC_MANAGER_CONNECT);

if (schm>0) then   begin

   schs := OpenService(schm, PChar(sService), SERVICE_STOP or

SERVICE_QUERY_STATUS);

   if (schs>0) then

   begin

    if (ControlService(schs, SERVICE_CONTROL_STOP, ss)) then

       if (QueryServiceStatus(schs, ss)) then

        while (SERVICE_STOPPED<>ss.dwCurrentState) do

        begin

         dwChkP := ss.dwCheckPoint;

           Sleep(ss.dwWaitHint);

           if (not QueryServiceStatus(schs, ss)) then

             Break;

           if ss.dwCheckPoint <> 0 then

             Break;

         end;

     CloseServiceHandle(schs);

   end;

  CloseServiceHandle(schm);

 end;

 Result := SERVICE_STOPPED=ss.dwCurrentState;

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

ServiceStart('','Service2');

file://ServiceStart('\\computername','Alerter');

file://this would be for remote services

end;

procedure TForm1.Button2Click(Sender: TObject);

begin

ServiceStop('','Service2');

end;

end.

you can also install it from code (still working on that part myself) using

CreateService etc..

theres very little docs on services so if anyone else has any feel free to

add here :-)