Set process/task name from native win32 ? (for Java use)

4 views
Skip to first unread message

Morten Christensen

unread,
Oct 14, 1998, 3:00:00 AM10/14/98
to
Hi,

Does anyone know how to change the process/task (+ maybe window) name
from win32 under Windows NT etc.

I need this feature for solving a java problem: When running multiple
java programs in a production environment, each one in it's own
window/wm, is it a problem that all programs appear under the same title
and process name "java" or "jre". This is a problem when I want to kill
or view OS information for a particular Java program which is running.
Since they all have the same process name where should I look ? Also my
"kill.exe" utility which does this automatically requires the name of
the process to kill.

To solve this I am planning to make a native library (DLL file using
JNI) which makes it possible to specify the process name from a pure
java program. However I have one problem. I don't know "which bit to
turn" to change the process/task/window name from win32. Can anyone help
?

Thanks,
Morten Christensen,
Odense, Denmark


dave porter

unread,
Oct 14, 1998, 3:00:00 AM10/14/98
to
There's no such thing as a process name under NT. Therefore you
cannot change it.

The process structure points (loosely speaking) to the image file
(e.g. c:\foo\bar.exe) which was used as the 'main' image in the process.
Programs which want to list processes often use this file name
to label the process in the display, since it's handy for the
humans. But it's not really the name of the process in any pure
sense.

If the program has a window, then you can set the window name
to anything you like - try something like SetWindowText. However,
be aware that whatever programming framework you are using
may have other fixed ideas about how to name windows (e.g.,
an MFC MDI program typically sets the window name based on
the active document).

This is not a kernel programming question. A kernel programming
question is one about writing code which executes in kernel mode.
Please post more accurately in future. Please do not cross-post
quite so much.

dave

--
For email, please remove the 'w' from my address. Sorry.

Morten Christensen <m...@oss.dk> wrote in article
<362486CF...@oss.dk>...

Gary Nebbett

unread,
Oct 14, 1998, 3:00:00 AM10/14/98
to
dave porter <por...@wultranet.com> wrote in article
<01bdf776$a5ea4fc0$0ba17392@glastonbury>...

> There's no such thing as a process name under NT. Therefore you
> cannot change it.
>
> The process structure points (loosely speaking) to the image file
> (e.g. c:\foo\bar.exe) which was used as the 'main' image in the process.
> Programs which want to list processes often use this file name
> to label the process in the display, since it's handy for the
> humans. But it's not really the name of the process in any pure
> sense.
>

The EPROCESS structure contains 16 bytes that the kernel debugger extension
command "processfields" labels "ImageFileName[0]". I believe that this field
can be freely modified (i.e. I don't think that there are any consistency
checks which would detect a modification). The text in the field is returned
by ZwQuerySystemInformation and is used by pstat.exe, perfmon.exe and
taskmgr.exe to name the process.

There are some utilities which obtain the loaded module list of a process and
use the name of the .exe file as the process name - these utilities would not
reflect the changes made to the EPROCESS structure.

> This is not a kernel programming question. A kernel programming
> question is one about writing code which executes in kernel mode.

I don't think that there is any function (documented or not) which will
change the ImageFileName field of the EPROCESS structure from user or kernel
mode. One would have to call PsGetCurrentProcess() from kernel mode and
update the field directly.

Gary

msnews.microsoft.com

unread,
Oct 19, 1998, 3:00:00 AM10/19/98
to
Try using some windows Interrupts to change application title. I hope this
helps

----------------------------------------------------------------------------
-----------------------------------------
INT 2F - Windows95 - TITLE - SET APPLICATION TITLE
AX = 168Eh
DX = 0000h
ES:DI -> ASCIZ application title (max 79 chars+NUL)
Return: AX = status
0000h failed
0001h successful
Note: if ES:DI is 0000h:0000h or points at an empty string, the current
title is removed
BUG: this function can return a successful status even though the title
was
not changed; reportedly, waiting for two clock ticks after program
startup solves this problem
SeeAlso: AX=168Eh/DX=0001h,AX=168Eh/DX=0002h
----------------------------------------------------------------------------
-----------------------------------------

INT 2F - Windows95 - TITLE - GET APPLICATION TITLE
AX = 168Eh
DX = 0002h
ES:DI -> buffer for ASCIZ application title
CX = size of buffer in bytes
Return: AX = status
0000h failed
0001h successful
Desc: copy as much of the application's window title as possible to the
given
buffer, appending a terminating NUL to the buffer
SeeAlso: AX=168Eh/DX=0000h,AX=168Eh/DX=0003h
----------------------------------------------------------------------------
-----------------------------------------

>Morten Christensen wrote


>Hi,
>
>Does anyone know how to change the process/task (+ maybe window) name
>from win32 under Windows NT etc.
>
>I need this feature for solving a java problem: When running multiple
>java programs in a production environment, each one in it's own
>window/wm, is it a problem that all programs appear under the same title
>and process name "java" or "jre". This is a problem when I want to kill
>or view OS information for a particular Java program which is running.
>Since they all have the same process name where should I look ? Also my
>"kill.exe" utility which does this automatically requires the name of
>the process to kill.
>
>To solve this I am planning to make a native library (DLL file using
>JNI) which makes it possible to specify the process name from a pure
>java program. However I have one problem. I don't know "which bit to
>turn" to change the process/task/window name from win32. Can anyone help
>?

>Thanks,
>Morten Christensen,
>Odense, Denmark

Reply all
Reply to author
Forward
0 new messages