multithreading - Kernel32 does not contain a method named 'OpenThread' -


i trying write suspend-process function in powershell 5 , error method invocation failed because [kernel32] not contain method named 'openthread' powershell code follows

 #thread access constants  $terminate             = 0x0001  $suspend_resume        = 0x0002 $get_context           = 0x0008 $set_context           = 0x0010 $set_information       = 0x0020 $query_information     = 0x0040 $set_thread_token      = 0x0080   $impersonate           = 0x0100 $direct_impersonation  = 0x0200  add-type -typedefinition @"     using system; using system.diagnostics; using system.runtime.interopservices; public static class kernel32 {     [dllimport("kernel32.dll",setlasterror=true)]     public static extern int suspendthread(intptr hthread);      [dllimport("kernel32.dll",setlasterror=true)]     public static extern int resumethread(intptr hthread);      [dllimport("kernel32.dll", setlasterror=true)]     public static extern bool closehandle(intptr hhandle);      [dllimport("kernel32.dll", setlasterror = true)]     public static extern intptr openthread(uint dwdesiredaccess, bool       binherithandle, uint dwthreadid);     }  "@  $hprocess = get-process -name notepad  foreach($processthread in $hprocess.threads){   $hthread = [kernel32]::openthread($suspend_resume , $false, $processthread.id)   if ($hthread -ne [intptr]::zero) {    [kernel32]::suspendthread($hthread)    [kernel32]::closehandle($hthread)   }  } 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -