[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Hide Application in Win9x/Nt Platforms without error

Posted on 2003-11-13
14
Medium Priority
?
270 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month20 days, left to enroll

872 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