Forum > Windows

Suspend/Resume/CloseThread and TThreadId

(1/2) > >>

440bx:
Hello,

I just noticed the following definitions in thread.inc
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function  SuspendThread (threadHandle : TThreadID) : dword;function  ResumeThread  (threadHandle : TThreadID) : dword;function  CloseThread   (threadHandle : TThreadID) : dword; where TThreadID is defined in sysosh.inc as
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  TThreadID = DWord;I believe this yields an incorrect definition because these thread functions, and many others declared as taking a TThreadID, take a THANDLE which in 64bit is 64 bit wide, not 32 bit.

This is important because in 64bit the TThreadId definition can cause the upper 32 bits of the handle to be truncated away.

Have I missed something or are these definitions working only due to sheer luck ?

Comments welcome.

Fibonacci:
AFAIK its thread ID, not the handle, and these functions you listed actually take the ID not the handle as a param

ASerge:

--- Quote from: Fibonacci on May 25, 2024, 04:02:32 pm ---AFAIK its thread ID, not the handle, and these functions you listed actually take the ID not the handle as a param

--- End quote ---
No, it really is. There is a loss of bitness. From systhrd.inc:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---    function  SysSuspendThread (threadHandle : TThreadID) : dword;    begin      SysSuspendThread:=WinSuspendThread(threadHandle); // WinSuspendThread equal kernel SuspendThread    end;Fortunately, this is not essential (so far). In the current implementation of Windows HANDLE is usually an index in the internal table of descriptors. I.e., in reality, even Word is enough.

Fibonacci:
You're right, I just checked and the thread handle is really low number

440bx:

--- Quote from: ASerge on May 25, 2024, 04:10:12 pm ---Fortunately, this is not essential (so far). In the current implementation of Windows HANDLE is usually an index in the internal table of descriptors. I.e., in reality, even Word is enough.

--- End quote ---
Yes, basically sheer luck.  If MS were to change how that handle is created, e.g, setting some bits to indicate some characteristics the O/S might want to save in the handle, those definitions may no longer work.

This is not a far fetched idea, MS does currently use some bits in some handles to indicate features/properties of the item represented by the handle, e.g, handles returned by LoadLibraryEx (they use the bottom two bits to indicate the mapping format.)

Navigation

[0] Message Index

[#] Next page

Go to full version