Author Topic: catwalk  (Read 227 times)

six_L

  • Member
  • **
  • Posts: 196
catwalk
« on: February 16, 2021, 04:36:26 AM »
the CatWalk example of thread control was written by Ron Thomas long times ago. it was a better example about thread control.
i translated it into x64 Uasm style. and added these "ExitThread,Ret "s function for a thread Exit.
pay attention to:
1. can't use ExitThread in your main thread, Use only own threads which will be exited.
2. monitoring the number of execution threads. 
3. relate to I/O, DLL, MEMORY. "RET" is best. "ExitThread" is better. "TerminateThread" isn't good on unless necessary

six_L

  • Member
  • **
  • Posts: 196
Re: catwalk
« Reply #1 on: February 16, 2021, 04:41:49 AM »
res1

six_L

  • Member
  • **
  • Posts: 196
Re: catwalk
« Reply #2 on: February 16, 2021, 04:43:23 AM »
res2

Biterider

  • Member
  • ****
  • Posts: 629
  • ObjAsm Developer
    • ObjAsm
Re: catwalk
« Reply #3 on: February 16, 2021, 04:53:42 AM »
Hi six_L

It works very well. Congrats  :thumbsup:
Nice work!

Biterider

Gunther

  • Member
  • *****
  • Posts: 3687
  • Forgive your enemies, but never forget their names
Re: catwalk
« Reply #4 on: February 16, 2021, 05:53:42 AM »
Works fine here. The sound is funny.  :thumbsup:

Gunther
Get your facts first, and then you can distort them.

TouEnMasm

  • Member
  • *****
  • Posts: 1573
    • EditMasm
Re: catwalk
« Reply #5 on: February 16, 2021, 09:18:26 PM »

 :thumbsup:

Find a little problem at rebuild.
Quote
      ;SendDlgItemMessageA PROTO hDlg:HWND ,nIDDlgItem:DWORD ,Msg:DWORD ,wParam:WPARAM ,lParam:LPARAM
WPARAM is a qword in X64 this made ThPriority1 (2) qword
Fa is a musical note to play with CL

six_L

  • Member
  • **
  • Posts: 196
Re: catwalk
« Reply #6 on: February 17, 2021, 05:47:37 AM »
hi: Biterider,Gunther,TouEnMasm
thank for your kind words and test.
especially,thank TouEnMasm for finding the error.
Code: [Select]
invoke SendDlgItemMessage, hdwnd, IDD_LB1, LB_GETCURSEL, 0,0
mov ThPriority1, rax
  invoke SendDlgItemMessage, hdwnd, IDD_LB2, LB_GETCURSEL, 0,0
mov ThPriority2, rax

mov rax,ThPriority1
sub eax, HOFFSET
  invoke SetThreadPriority, hThread1, eax

mov rax,ThPriority2
sub eax, HOFFSET
invoke SetThreadPriority, hThread2, eax
return TRUE
Quote
SetThreadPriority function (processthreadsapi.h)
Sets the priority value for the specified thread. This value, together with the priority class of the thread's process, determines the thread's base priority level.
Syntax
C++

BOOL SetThreadPriority(
  HANDLE hThread,
  int    nPriority
);

Gunther

  • Member
  • *****
  • Posts: 3687
  • Forgive your enemies, but never forget their names
Re: catwalk
« Reply #7 on: February 17, 2021, 08:27:18 AM »
hi: Biterider,Gunther,TouEnMasm
thank for your kind words and test.
especially,thank TouEnMasm for finding the error.

you're welcome. 

Good catch TouEnMasm.  :thup:

Gunther
Get your facts first, and then you can distort them.

TouEnMasm

  • Member
  • *****
  • Posts: 1573
    • EditMasm
Re: catwalk
« Reply #8 on: February 17, 2021, 08:56:32 PM »
The SetThreadPriority parameters are a bit old.https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreadpriority
I have changed those old parameters by the new in the upper link.
I have also added some various error messages.
bad parameters could be :
Quote
This value can be specified only if hThread is a handle to the current thread. The function fails
take care of that
Fa is a musical note to play with CL

six_L

  • Member
  • **
  • Posts: 196
Re: catwalk
« Reply #9 on: February 19, 2021, 03:55:45 AM »
hi,TouEnMasm
thank for you'd done on updating. :thumbsup:
There are more functions of thread control:
1. update to 9 levels priority;
2. add to the errors checking;
;----------------------------------------------
the deeper impression is used to translate between the list index and the priority index.