Solved

Hide Application in Win9x/Nt Platforms without error

Posted on 2003-11-13
14
253 Views
Last Modified: 2010-04-05
I asked before how to hide my application from the task manager in Win9x and NT Platforms. All of the code worked BUT. When a run it on NT Platform the Win9x code seems to crash my application. What can I do to work on both Platforms withou crashing my Application. Thanx
0
Comment
Question by:fabyola
14 Comments
 
LVL 6

Expert Comment

by:DaFox
ID: 9739065
Hi,

procedure TForm1.Button1.Click(Sender: TObject);

  function isNT: Boolean;
  var
    osv: TOSVERSIONINFO;
  begin
    Result := false;
    osv.dwOSVersionInfoSize:=SizeOf(TOSVERSIONINFO);
    GetVersionEx(osv);
    if osv.dwPlatformId = VER_PLATFORM_WIN32_NT then result:= true;
  end;

begin
  if isNT then
  begin
    // place NT code here
  end else
  begin
    // place 9x code here
  end;
end;

Markus
0
 
LVL 17

Expert Comment

by:geobul
ID: 9739332
Or:

  if (GetVersion < $80000000) then begin
    ShowMessage('winNT family'); // your NT code here
  end else begin
    ShowMessage('win9x family'); // your Win9x code here
  end;

Regards, Geo
0
 

Author Comment

by:fabyola
ID: 9740250
But the problem is when I put in the Win9x code in the project, and when the application runs it crashes it. The application doesn´t even run. I need the a code that hides from the task manager in which it has both the Win9x and NT Platforms and it won´t crash the application.
0
 

Author Comment

by:fabyola
ID: 9741550
The Crash happens right after i try to open the application.
0
 

Author Comment

by:fabyola
ID: 9747000
Nobody answered me. I guess this one is a tough one. I promise that who ever get´s this one for me I´ll increase the points to 225. I need this quick. Please
0
 
LVL 6

Accepted Solution

by:
DaFox earned 125 total points
ID: 9749098
Hi,

type
  TFNRegSvcPrc = function(dwProcessId: Cardinal; dwType: Cardinal): Cardinal; stdcall;

// ...

procedure TForm1.Button1.Click(Sender: TObject);

  function isNT: Boolean;
  var
    osv: TOSVERSIONINFO;
  begin
    Result := false;
    osv.dwOSVersionInfoSize:=SizeOf(TOSVERSIONINFO);
    GetVersionEx(osv);
    if osv.dwPlatformId = VER_PLATFORM_WIN32_NT then result:= true;
  end;

var
  RegisterServiceProcess: TFNRegSvcPrc;
begin
  if isNT then
  begin
    // place NT code here
  end else
  begin
    @RegisterServiceProcess := GetProcAddress(GetModuleHandle('KERNEL32'), 'RegisterServiceProcess');
    RegisterServiceProcess(0, 1);
  end;
end;

Markus
0
 
LVL 6

Expert Comment

by:pritaeas
ID: 9763195
Hi. This trick does NOT work on NT4. RegisterServiceProcess is not in the WinNT API's. The only way is to write an actual service.

hth, pritaeas
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 6

Expert Comment

by:DaFox
ID: 9763391
Hi,

>> This trick does NOT work on NT4. RegisterServiceProcess is not in the WinNT API's. The only way is to write an actual service.

This was fabyola's question:

"I asked BEFORE how to hide my application from the task manager in WIN9X AND NT PLATFORMS. ALL OF THE CODE WORKED BUT. When a run it on NT Platform the Win9x code seems to crash my application. What can I do to work on both Platforms withou crashing my Application."

He already has the code; 9x: RegisterServiceProcess(), NT: hook NtQuerySystemInformation()

This was my answer:

// cut

var
  RegisterServiceProcess: TFNRegSvcPrc;
begin
  if isNT then
  begin
    // this code gets executed if current OS is NT platform
  end else
  begin
    // this code gets executed if current OS is 9x/ME
    @RegisterServiceProcess := GetProcAddress(GetModuleHandle('KERNEL32'), 'RegisterServiceProcess');
    RegisterServiceProcess(0, 1);
  end;
end;

// cut

The problem with the code fabyola has is that he statically linked to kernel32.RegisterServiceProcess, but we have to link dynamically to it to not get an AV if running on NT platform. I never said that RegisterServiceProcess works in NT, it doesn't, and that's why I placed the function in the lower part of the if statement.

Markus
0
 

Author Comment

by:fabyola
ID: 9772125
What can I do to work on NT4 ???
0
 
LVL 6

Expert Comment

by:DaFox
ID: 9773086
Didn't you already accept the other question? I thought you already have the information...

Markus
0
 

Author Comment

by:fabyola
ID: 9780170
Is it the same way that I do in any NT platform. Windows 200/XP etc.. ?
0
 
LVL 6

Expert Comment

by:DaFox
ID: 9780392
Yes, on NT, 2000, XP, 2003 you have to hook NtQuerySystemInformation API. There's no other/easier way. Normally an application shouldn't hide itself from the process list, that's because MS made it that difficult for you.
It's the same for all NT platform operating systems.

Markus
0
 

Author Comment

by:fabyola
ID: 9818798
But what i want is to hide only from the task manager. Not in the process list. I made it hide it from tha task in Windows 200. Do you think that it would work in NT4 ?
0
 
LVL 6

Expert Comment

by:DaFox
ID: 9819645
What makes you think it doesn't work for the task manager in Windows NT? AFAIK it uses the same APIs for all NT platforms. If it works on W2k it should also work on NT4.

Markus
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now