Solved

Hide Application in Win9x/Nt Platforms without error

Posted on 2003-11-13
14
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 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