The object of this short tutorial is to demonstrate how processes can be hidden from the windows, its taskbar, and its task manager. It also contains my code to hide from the task manager on 9x machines without crashing when run on NT, or XP.
Terms of Agreement:
By using this article, you agree to the following terms...
You may use
this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
You may link to this article from another website, but ONLY if it is not wrapped in a frame.
You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
[Introduction]
Normally I don't write tutorials or submit code. I'm no Jerome ;p But trying to find good resources for *truely* hiding programs from windows was such a task for me that I figured I would share what knowledge I've found. If you are interested in hiding your program from windows and the task list or just curious about the different ways you can do so, then this file is for you!
[Hiding From Task Manager
#1]
The main way that everyone is telling you to do this is using code like this:
Simple enough, right? It seems so. Unfortunately when you try using this code under any OS except for a 9x machine, it will crash the entire program. It crashed mine even before I ever called the function! When I found this out I was frustrated because I wanted my bot to work universally on all OS's. Because of this, I finally found a way to make it work and wrote universally compatible code. If your code is meant only for Windows 9x machines, then there would be nothing wrong with using the previous code. If not, read on..
[Get Operating System]
In order to make the code that
follows work, we must have a variable that will find the operating system. To do
this, I have found (and slightly modified) the following code:
var
// Global OS vars
VersionInfo: TOSVersionInfo;
Platform: string;
MajorVersion,MinorVersion,Build: DWORD;
procedure GetOSVersion;
begin
VersionInfo.dwOSVersionInfoSize := SizeOf(VersionInfo);
GetVersionEx(VersionInfo);
with VersionInfo do
begin
case dwPlatformId of
VER_PLATFORM_WIN32s: Platform := '3.1';
VER_PLATFORM_WIN32_WINDOWS : Platform := '98';
VER_PLATFORM_WIN32_NT:
begin
Case dwMajorVersion of
5 : Platform := '2000/NT';
else
Platform :=
'NT';
end;
if
dwBuildNumber > = 2500 then Platform := 'XP'
end;
end;
Now that we have a function to check the OS version we can add my universally compatible code to hide from 9x machines. First we need to add the type TReg before your implementation:
type
TReg =
function (dwProcessID, dwType: DWord) : DWord;
Now for the
code. In this example we will assume that the following code is put in a form's
FormCreate event. Because that's most likely where you will want to put
it:
var
RegisterServiceProcess: TReg;
begin
// Determine the operating system
GetOsVersion;
// Check to see if OS is 9x
if Platform = '98' then begin
Handle :=
LoadLibrary('KERNEL32.DLL');
if
Handle <> 0 then begin
@RegisterServiceProcess := GetProcAddress(Handle, 'RegisterServiceProcess');
if
@RegisterServiceProcess <> nil then
RegisterServiceProcess(GetCurrentProcessID, RSPSIMPLESERVICE);
end;
FreeLibrary(Handle);
end;
end;
[Hiding From
NT]
This is a difficult task. NT boxes are not easily tricked. There is only one simple way that I've found to do this, and I believe it only works on NT 4.0. Go to your Project unit (IE. Project1) And find where it initializes and sets the application title. Replace it with this code:
Application.Initialize;
Application.Title:=
'';
The version of NT that this works with (NT 4.0?) will not show your process in the manager because it displays processes by their titles, and your program is now running without one!
[Hiding from taskbar & windows]
The following is just a little piece of code I wrote to ensure that my form is unseen. It is commented so I will not explain it here:
procedure HideMe();
begin
// Make sure the form is out of sight
form1.Left := 99999;
form1.Top := 99999;
// Make form dissapear
form1.Visible := false;
Application.Minimize;
// Hide window entirely (dissapears from task bar!)
ShowWindow(Application.Handle, SW_HIDE);
SetWindowLong(Application.Handle, GWL_EXSTYLE,
GetWindowLong(Application.Handle, GWL_EXSTYLE)
or WS_EX_TOOLWINDOW );
end;
[Note]
Some code used in this tutorial was based on other's code. Thanks to those who wrote the original code.
[Conclusion]
Hopefully
some of this has been helpful. I have no good HTML editor on this computer so
this isn't a nice flashy tutorial. Good luck in your programming! I always am
interested in hearing about new methods and techniques, so if you would like to
share some feel free to drop me a line. Also, if you have a question with
anything here or something else let me know and I'll do my best to help. Happy
c0d1ng!
;)
interesting.. but a normal process should not be hidden from os task manager, otherwise we can not kill it whenever it get stuck and crash your window.
anyway, this method of hiding process has open a little "secret" behind windows that i could use someday.
***** for revealing this little "secret"
(If this comment was disrespectful, please report it.)
Something I forgot to add. Most of you figured this out but I got a question so I figured I'd mention. In my method (Hiding from task manager #2) if you are getting an error about the variable (If this comment was disrespectful, please report it.)
i noticed on XP that the RegisterServiceProcess funtion is in the USER32.dll not the Kernel32.dll and it's Services not Service ???
function RegisterServicesProcess(dwProcessID,dwType: DWORD): DWORD; stdcall; external 'USER32.DLL'; (If this comment was disrespectful, please report it.)
3/9/2003 7:54:37 PM:
You are right, in Windows NT RegisterServicesProcess is in user32.dll. I tried calling it but it does not work. (If this comment was disrespectful, please report it.)
NT based systems don't have the ability to hide from the task list. This is a good thing for NT and XP users ;)~ RegisterServicesProcess for hiding is only good for 9x (If this comment was disrespectful, please report it.)
6/18/2003 12:08:23 AM:
can someoen email me a example code wif this. It seems no amtter how i setup this code in my own code, it keeps comeign up wif error after error. and example of a working version would be great appriacated if someone would be kind to email me one @ sniper_dude_rockz@hotmail.com (If this comment was disrespectful, please report it.)
9/13/2003 8:28:45 AM:
Can anyone mail me the whole working code too? email: jonas_renold@hotmail.com (If this comment was disrespectful, please report it.)
11/13/2003 5:47:07 AM:
This is what I was looking for. But I cant get it to work. I don´t know what I´m doing wrong. Does anyone have a Project as an example that can send it to me ? My e-mail is Fredy992@hotmail.com Thank You NaHeMiA
(If this comment was disrespectful, please report it.)
11/21/2003 8:35:38 AM:
No errors when I compile this, but it doesn't hide the process in the task bar either (unlike when I compiled using the tradional external kernal32 call). Any ideas why? I'd like to be able to compile this on an XP machine and have the code work on a 9x platform. Thanks. (If this comment was disrespectful, please report it.)
I dont think you need to check the OS first because if it isnt a 9x (or ME) the @RegisterServiceProcess will be nil and no errors will occour. And if someone has problems with the "filename.exe has coused an error in " its because they haven't used stdcall; its not TReg = function (dwProcessID, dwType: DWord) : DWord; but TReg = function (dwProcessID, dwType: DWord) : DWord; stdcall; Hope this helps. (If this comment was disrespectful, please report it.)
7/24/2004 8:15:34 PM:
dood nahemia msg me on efnet dawg--fr3d (If this comment was disrespectful, please report it.)
12/27/2004 7:48:03 PM:
Good work man .. but i have some problems .. It doesn't hide the process in the TaskMgr.. I have a modified copy of windows .. some of you might know it .. Retestrak .. With SP2 included .. Could this be the problem ? (If this comment was disrespectful, please report it.)
Anyone have any luck getting this working for XP? What I would really like, is to RENAME the process in the task manager process list. Anyone know how to do this for XP? (If this comment was disrespectful, please report it.)
Meh! this code is NOT i repeat NOT god for hiding processes under Win NT, dunno about ME and 9X but NT is NOT hiding it. I'm NOT going to reveal how to hide process(mainly because someone could do SPY programs and i'm NOT cool with that). I will give you guys a hint, if you understand or not i'm sorry(my reason are said above) ShowWindow(Application.Handle, SW_HIDE) -> this is for hiding form! simple as that, but process is still in taks list. But you can hide program behind another one.THINK ABOUT IT,sry i'm not more specific...GoodLuck (If this comment was disrespectful, please report it.)
lissen my friend. what im trying to achieve is that i play an online game and it has punkbuster in there and so i need something to make a process invisible to cheat punkbuster. I have an exe i run but i want it to be completely invisible. please help me out with this =) (If this comment was disrespectful, please report it.)
Add Your Feedback
Your feedback will be posted below and an email sent to
the author. Please remember that the author was kind enough to
share this with you, so any criticisms must be stated politely, or they
will be deleted. (For feedback not related to this particular article, please
click here instead.)