Click here to Skip to main content
15,907,913 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
JokeRe: Class wizard in VC 2005 Pin
ThatsAlok23-Nov-07 18:55
ThatsAlok23-Nov-07 18:55 
QuestionTerminateThread hangs Pin
maciu202023-Nov-07 15:10
maciu202023-Nov-07 15:10 
QuestionRe: TerminateThread hangs Pin
Mark Salsbery23-Nov-07 15:22
Mark Salsbery23-Nov-07 15:22 
AnswerRe: TerminateThread hangs [modified] Pin
maciu202023-Nov-07 21:11
maciu202023-Nov-07 21:11 
GeneralRe: TerminateThread hangs Pin
Mark Salsbery24-Nov-07 7:04
Mark Salsbery24-Nov-07 7:04 
GeneralRe: TerminateThread hangs Pin
maciu202024-Nov-07 7:28
maciu202024-Nov-07 7:28 
GeneralRe: TerminateThread hangs Pin
Mark Salsbery24-Nov-07 8:06
Mark Salsbery24-Nov-07 8:06 
GeneralRe: TerminateThread hangs [modified] Pin
maciu202024-Nov-07 8:47
maciu202024-Nov-07 8:47 
Mark Salsbery wrote:

Why did you pick 80ms to wait here? What if it takes 81ms?

Under normal conditions, it shouldn't take even 3ms on a fairly modern machine.
Why is it implemented this way? Because with insufficient access rights, NtQueryInformationFile doesn't return...at least not in reasonable time (I didn't write this code, but WAIT_TIMEOUT happens here up to 77 times on my machine. Also with 100 ms which was the default set several years ago by the author of this part).
_endthread() would need to be called by the thread itself, which is impossible when NtQueryInformationFile doesn't return. Yes, this can cause a resource leak, I need to rewrite it to use CreateThread instead.

Anyway, it's not the case. After a few hours of restarting my computer, I found where is the problem.
	INtDll::NtQueryObject ( handle, 1, NULL, 0, &size );<br />
<br />
	// let's try to use the default<br />
	if ( size == 0 )<br />
		size = 0x8000;<br />
<br />
	lpBuffer = (UCHAR*)HeapAlloc(hHeap = GetProcessHeap(), 0, sizeof(UCHAR)*size);<br />
<br />
	if ( INtDll::NtQueryObject( handle, 1, lpBuffer, size, NULL ) == 0 )<br />
	{<br />
		SystemInfoUtils::Unicode2CString( (UNICODE_STRING*)lpBuffer, str );<br />
		ret = TRUE;<br />
	}

Neither MSDN nor ntinternals.net write about thread security issues in NtQueryObject.
I'm going to try to put it in a critical section and see what happens. Need another restart though Sigh | :sigh:


-- modified at 15:13 Saturday 24th November, 2007
When there's a hung process in memory, it becomes totally unpredictable. Dead | X|
Even the single treaded, well tested version can hang here.
I'm leaving it for today, I'm too tired.
GeneralRe: TerminateThread hangs Pin
Mark Salsbery24-Nov-07 9:42
Mark Salsbery24-Nov-07 9:42 
GeneralRe: TerminateThread hangs Pin
maciu202024-Nov-07 10:15
maciu202024-Nov-07 10:15 
GeneralRe: TerminateThread hangs Pin
Mark Salsbery24-Nov-07 10:28
Mark Salsbery24-Nov-07 10:28 
GeneralRe: TerminateThread hangs Pin
maciu202024-Nov-07 22:27
maciu202024-Nov-07 22:27 
QuestionCan VC realize the localizable dialog ? Pin
BegtostudyBoy23-Nov-07 14:04
BegtostudyBoy23-Nov-07 14:04 
AnswerRe: Can VC realize the localizable dialog ? Pin
Nelek25-Nov-07 21:26
protectorNelek25-Nov-07 21:26 
GeneralRe: Can VC realize the localizable dialog ? Pin
BegtostudyBoy25-Nov-07 22:00
BegtostudyBoy25-Nov-07 22:00 
QuestionI have put PlaySound() in the View - and it dosent play any thing until at rest Pin
simon alec smith23-Nov-07 12:53
simon alec smith23-Nov-07 12:53 
QuestionRe: I have put PlaySound() in the View - and it dosent play any thing until at rest Pin
Mark Salsbery23-Nov-07 15:28
Mark Salsbery23-Nov-07 15:28 
AnswerRe: I have put PlaySound() in the View - and it dosent play any thing until at rest Pin
simon alec smith24-Nov-07 4:00
simon alec smith24-Nov-07 4:00 
GeneralRe: I have put PlaySound() in the View - and it dosent play any thing until at rest Pin
Mark Salsbery24-Nov-07 7:12
Mark Salsbery24-Nov-07 7:12 
QuestionMFC ON_COMMAND problem Pin
FredrickNorge23-Nov-07 10:19
FredrickNorge23-Nov-07 10:19 
QuestionRe: MFC ON_COMMAND problem Pin
Mark Salsbery23-Nov-07 10:23
Mark Salsbery23-Nov-07 10:23 
AnswerRe: MFC ON_COMMAND problem Pin
FredrickNorge23-Nov-07 10:27
FredrickNorge23-Nov-07 10:27 
GeneralRe: MFC ON_COMMAND problem Pin
Mark Salsbery23-Nov-07 10:32
Mark Salsbery23-Nov-07 10:32 
GeneralRe: MFC ON_COMMAND problem Pin
FredrickNorge23-Nov-07 10:46
FredrickNorge23-Nov-07 10:46 
GeneralRe: MFC ON_COMMAND problem Pin
Mark Salsbery23-Nov-07 11:00
Mark Salsbery23-Nov-07 11:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.