Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
fbcf44aa
Commit
fbcf44aa
authored
Oct 11, 2010
by
Andrew Nguyen
Committed by
Alexandre Julliard
Oct 11, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
taskkill: Disallow process self-termination.
parent
76e7fcc9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
0 deletions
+32
-0
En.rc
programs/taskkill/En.rc
+1
-0
taskkill.c
programs/taskkill/taskkill.c
+30
-0
taskkill.h
programs/taskkill/taskkill.h
+1
-0
No files found.
programs/taskkill/En.rc
View file @
fbcf44aa
...
@@ -38,4 +38,5 @@ STRINGTABLE
...
@@ -38,4 +38,5 @@ STRINGTABLE
STRING_SEARCH_FAILED, "Error: Could not find process \"%s\".\n"
STRING_SEARCH_FAILED, "Error: Could not find process \"%s\".\n"
STRING_ENUM_FAILED, "Error: Unable to enumerate the process list.\n"
STRING_ENUM_FAILED, "Error: Unable to enumerate the process list.\n"
STRING_TERMINATE_FAILED, "Error: Unable to terminate process \"%s\".\n"
STRING_TERMINATE_FAILED, "Error: Unable to terminate process \"%s\".\n"
STRING_SELF_TERMINATION, "Error: Process self-termination is not permitted.\n"
}
}
programs/taskkill/taskkill.c
View file @
fbcf44aa
...
@@ -204,6 +204,7 @@ static BOOL get_process_name_from_pid(DWORD pid, WCHAR *buf, DWORD chars)
...
@@ -204,6 +204,7 @@ static BOOL get_process_name_from_pid(DWORD pid, WCHAR *buf, DWORD chars)
static
int
send_close_messages
(
void
)
static
int
send_close_messages
(
void
)
{
{
DWORD
*
pid_list
,
pid_list_size
;
DWORD
*
pid_list
,
pid_list_size
;
DWORD
self_pid
=
GetCurrentProcessId
();
unsigned
int
i
;
unsigned
int
i
;
int
status_code
=
0
;
int
status_code
=
0
;
...
@@ -234,6 +235,13 @@ static int send_close_messages(void)
...
@@ -234,6 +235,13 @@ static int send_close_messages(void)
DWORD
pid
=
atoiW
(
task_list
[
i
]);
DWORD
pid
=
atoiW
(
task_list
[
i
]);
struct
pid_close_info
info
=
{
pid
};
struct
pid_close_info
info
=
{
pid
};
if
(
pid
==
self_pid
)
{
taskkill_message
(
STRING_SELF_TERMINATION
);
status_code
=
1
;
continue
;
}
EnumWindows
(
pid_enum_proc
,
(
LPARAM
)
&
info
);
EnumWindows
(
pid_enum_proc
,
(
LPARAM
)
&
info
);
if
(
info
.
found
)
if
(
info
.
found
)
taskkill_message_printfW
(
STRING_CLOSE_PID_SEARCH
,
pid
);
taskkill_message_printfW
(
STRING_CLOSE_PID_SEARCH
,
pid
);
...
@@ -258,6 +266,13 @@ static int send_close_messages(void)
...
@@ -258,6 +266,13 @@ static int send_close_messages(void)
struct
pid_close_info
info
=
{
pid_list
[
index
]
};
struct
pid_close_info
info
=
{
pid_list
[
index
]
};
found_process
=
TRUE
;
found_process
=
TRUE
;
if
(
pid_list
[
index
]
==
self_pid
)
{
taskkill_message
(
STRING_SELF_TERMINATION
);
status_code
=
1
;
continue
;
}
EnumWindows
(
pid_enum_proc
,
(
LPARAM
)
&
info
);
EnumWindows
(
pid_enum_proc
,
(
LPARAM
)
&
info
);
taskkill_message_printfW
(
STRING_CLOSE_PROC_SRCH
,
process_name
,
pid_list
[
index
]);
taskkill_message_printfW
(
STRING_CLOSE_PROC_SRCH
,
process_name
,
pid_list
[
index
]);
}
}
...
@@ -278,6 +293,7 @@ static int send_close_messages(void)
...
@@ -278,6 +293,7 @@ static int send_close_messages(void)
static
int
terminate_processes
(
void
)
static
int
terminate_processes
(
void
)
{
{
DWORD
*
pid_list
,
pid_list_size
;
DWORD
*
pid_list
,
pid_list_size
;
DWORD
self_pid
=
GetCurrentProcessId
();
unsigned
int
i
;
unsigned
int
i
;
int
status_code
=
0
;
int
status_code
=
0
;
...
@@ -308,6 +324,13 @@ static int terminate_processes(void)
...
@@ -308,6 +324,13 @@ static int terminate_processes(void)
DWORD
pid
=
atoiW
(
task_list
[
i
]);
DWORD
pid
=
atoiW
(
task_list
[
i
]);
HANDLE
process
;
HANDLE
process
;
if
(
pid
==
self_pid
)
{
taskkill_message
(
STRING_SELF_TERMINATION
);
status_code
=
1
;
continue
;
}
process
=
OpenProcess
(
PROCESS_TERMINATE
,
FALSE
,
pid
);
process
=
OpenProcess
(
PROCESS_TERMINATE
,
FALSE
,
pid
);
if
(
!
process
)
if
(
!
process
)
{
{
...
@@ -341,6 +364,13 @@ static int terminate_processes(void)
...
@@ -341,6 +364,13 @@ static int terminate_processes(void)
{
{
HANDLE
process
;
HANDLE
process
;
if
(
pid_list
[
index
]
==
self_pid
)
{
taskkill_message
(
STRING_SELF_TERMINATION
);
status_code
=
1
;
continue
;
}
process
=
OpenProcess
(
PROCESS_TERMINATE
,
FALSE
,
pid_list
[
index
]);
process
=
OpenProcess
(
PROCESS_TERMINATE
,
FALSE
,
pid_list
[
index
]);
if
(
!
process
)
if
(
!
process
)
{
{
...
...
programs/taskkill/taskkill.h
View file @
fbcf44aa
...
@@ -34,3 +34,4 @@
...
@@ -34,3 +34,4 @@
#define STRING_SEARCH_FAILED 111
#define STRING_SEARCH_FAILED 111
#define STRING_ENUM_FAILED 112
#define STRING_ENUM_FAILED 112
#define STRING_TERMINATE_FAILED 113
#define STRING_TERMINATE_FAILED 113
#define STRING_SELF_TERMINATION 114
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment