Solved

Hide Application in Win9x/Nt Platforms without error

Posted on 2003-11-13
14
263 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb download file link ? 1 155
Print Graphic and Text to Epson TM-T88v 12 386
TEMBEDDEDWB how can i change its user agent ? 8 70
scroll down TListBox component in Delphi 1 19
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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

828 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