View previous topic :: View next topic |
Author |
Message |
h4c0r-BG Master Cheater
Reputation: 0
Joined: 29 Nov 2006 Posts: 449 Location: The yogurt country
|
Posted: Sat Apr 04, 2009 9:17 am Post subject: Checking for a Killed TThread |
|
|
I have the handle and tid of the thread. I know how to check if the thread was suspended but how can i check if it was killed?
For some weird reason if i use OpenThread() it gives me valid handle (even if the thread is allready killed).
I am thinkink of using GetExitCodeThread() but i am not sure how, (tried already) and it kills my thread first and then my whole process. Who knows what i am doing wrong..
By the way i want to avoid using CreateToolhelp32Snapshot() for my goal, i believe there is an easier way.
_________________
|
|
Back to top |
|
 |
Skyone Grandmaster Cheater
Reputation: 0
Joined: 10 Sep 2006 Posts: 508
|
Posted: Sat Apr 04, 2009 9:22 am Post subject: |
|
|
???
Last edited by Skyone on Wed Dec 23, 2009 9:08 am; edited 8 times in total |
|
Back to top |
|
 |
h4c0r-BG Master Cheater
Reputation: 0
Joined: 29 Nov 2006 Posts: 449 Location: The yogurt country
|
Posted: Sat Apr 04, 2009 9:43 am Post subject: |
|
|
Skyone, thank you for your idea. I am working in Delphi 7. I did the following:
function GetThreadId(
hThread: tHandle): dword;
stdcall; external kernel32 name 'GetThreadId';
But there was a problem. There is no GetThreadId exported function in kernel32.dll
_________________
|
|
Back to top |
|
 |
Skyone Grandmaster Cheater
Reputation: 0
Joined: 10 Sep 2006 Posts: 508
|
Posted: Sat Apr 04, 2009 9:49 am Post subject: |
|
|
???
Last edited by Skyone on Wed Dec 23, 2009 9:08 am; edited 8 times in total |
|
Back to top |
|
 |
h4c0r-BG Master Cheater
Reputation: 0
Joined: 29 Nov 2006 Posts: 449 Location: The yogurt country
|
Posted: Sat Apr 04, 2009 9:56 am Post subject: |
|
|
return_value_of_func:=GetExitCodeThread(valid_handle_to_my_thread);
After being called once the "return_value_of_func" is 1, after that if i "recall" this line of code again:
return_value_of_func:=GetExitCodeThread(valid_handle_to_my_thread);
my application is terminated.
Edit:
BOOL WINAPI GetExitCodeThread(
__in HANDLE hThread,
__out LPDWORD lpExitCode
);
I have wrong syntaxis of my exported function. Fixing it right now.
Edit2:
if GetExitCodeThread(valid_handle_to_my_thread,asd) = true then messageboxa(0,pchar(inttohex(asd,1)),'getexitcode retvall',0);
I call the function once per second, and like after 5 seconds my application terminates without any errors or messageboxes.
_________________
Last edited by h4c0r-BG on Sat Apr 04, 2009 10:09 am; edited 1 time in total |
|
Back to top |
|
 |
Skyone Grandmaster Cheater
Reputation: 0
Joined: 10 Sep 2006 Posts: 508
|
Posted: Sat Apr 04, 2009 10:06 am Post subject: |
|
|
???
Last edited by Skyone on Wed Dec 23, 2009 9:08 am; edited 7 times in total |
|
Back to top |
|
 |
h4c0r-BG Master Cheater
Reputation: 0
Joined: 29 Nov 2006 Posts: 449 Location: The yogurt country
|
Posted: Sat Apr 04, 2009 10:12 am Post subject: |
|
|
Have tried:
GetExitCodeThread(cr_handle,259)
or
GetExitCodeThread(cr_handle,$259)
but my process still gets terminated like .. after ~5 seconds.
_________________
|
|
Back to top |
|
 |
Skyone Grandmaster Cheater
Reputation: 0
Joined: 10 Sep 2006 Posts: 508
|
Posted: Sat Apr 04, 2009 10:26 am Post subject: |
|
|
???
Last edited by Skyone on Wed Dec 23, 2009 9:08 am; edited 7 times in total |
|
Back to top |
|
 |
h4c0r-BG Master Cheater
Reputation: 0
Joined: 29 Nov 2006 Posts: 449 Location: The yogurt country
|
Posted: Sat Apr 04, 2009 10:42 am Post subject: |
|
|
I don't get it... my application terminates without any errors. :S
I use my "thread check" code in a dll file. I inject that dll in a process ... the process terminates like ~ after 5-6 seconds without any errors.
Will be glad to hear some more ideas and will continue to investigate where is the problem.
_________________
|
|
Back to top |
|
 |
BanMe Master Cheater
Reputation: 0
Joined: 29 Nov 2005 Posts: 375 Location: Farmington NH, USA
|
|
Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sat Apr 04, 2009 1:34 pm Post subject: |
|
|
You can use WaitForSingleObject() with a timeout of 0, and check the appropriate return value. Or if you want to wait until the thread exits before continuing, use a timeout of INFINITE.
|
|
Back to top |
|
 |
|