Open the Thread token if any (Impersonation) else return None. ``as_self`` tells which security context should be used :returns: :class:`~windows.winobject.token.Token` .. note:: see https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-proc
(self, flags=MAXIMUM_ALLOWED, as_self=False)
| 522 | |
| 523 | class Thread(utils.AutoHandle): |
| 524 | def open_token(self, flags=MAXIMUM_ALLOWED, as_self=False): |
| 525 | """Open the Thread token if any (Impersonation) else return None. |
| 526 | ``as_self`` tells which security context should be used |
| 527 | |
| 528 | :returns: :class:`~windows.winobject.token.Token` |
| 529 | |
| 530 | .. note:: |
| 531 | |
| 532 | see https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-openthreadtoken |
| 533 | |
| 534 | """ |
| 535 | token_handle = HANDLE() |
| 536 | try: |
| 537 | winproxy.OpenThreadToken(self.handle, flags, as_self, byref(token_handle)) |
| 538 | except WindowsError as e: |
| 539 | if e.winerror == gdef.ERROR_NO_TOKEN: |
| 540 | # No token to open: return None |
| 541 | return None |
| 542 | raise |
| 543 | return token.Token(token_handle.value) |
| 544 | |
| 545 | def set_token(self, token): |
| 546 | """Set the token for the thread (impersonation). Setting the token to None revert the impersonation""" |
nothing calls this directly
no outgoing calls
no test coverage detected