github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/internal/syscall/windows/security_windows.go (about)

     1  // Copyright 2016 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package windows
     6  
     7  import (
     8  	"github.com/shogo82148/std/syscall"
     9  )
    10  
    11  const (
    12  	SecurityAnonymous      = 0
    13  	SecurityIdentification = 1
    14  	SecurityImpersonation  = 2
    15  	SecurityDelegation     = 3
    16  )
    17  
    18  const (
    19  	TOKEN_ADJUST_PRIVILEGES = 0x0020
    20  	SE_PRIVILEGE_ENABLED    = 0x00000002
    21  )
    22  
    23  type LUID struct {
    24  	LowPart  uint32
    25  	HighPart int32
    26  }
    27  
    28  type LUID_AND_ATTRIBUTES struct {
    29  	Luid       LUID
    30  	Attributes uint32
    31  }
    32  
    33  type TOKEN_PRIVILEGES struct {
    34  	PrivilegeCount uint32
    35  	Privileges     [1]LUID_AND_ATTRIBUTES
    36  }
    37  
    38  func AdjustTokenPrivileges(token syscall.Token, disableAllPrivileges bool, newstate *TOKEN_PRIVILEGES, buflen uint32, prevstate *TOKEN_PRIVILEGES, returnlen *uint32) error
    39  
    40  type SID_AND_ATTRIBUTES struct {
    41  	Sid        *syscall.SID
    42  	Attributes uint32
    43  }
    44  
    45  type TOKEN_MANDATORY_LABEL struct {
    46  	Label SID_AND_ATTRIBUTES
    47  }
    48  
    49  func (tml *TOKEN_MANDATORY_LABEL) Size() uint32
    50  
    51  const SE_GROUP_INTEGRITY = 0x00000020
    52  
    53  type TokenType uint32
    54  
    55  const (
    56  	TokenPrimary       TokenType = 1
    57  	TokenImpersonation TokenType = 2
    58  )
    59  
    60  const (
    61  	LG_INCLUDE_INDIRECT  = 0x1
    62  	MAX_PREFERRED_LENGTH = 0xFFFFFFFF
    63  )
    64  
    65  type LocalGroupUserInfo0 struct {
    66  	Name *uint16
    67  }
    68  
    69  type UserInfo4 struct {
    70  	Name            *uint16
    71  	Password        *uint16
    72  	PasswordAge     uint32
    73  	Priv            uint32
    74  	HomeDir         *uint16
    75  	Comment         *uint16
    76  	Flags           uint32
    77  	ScriptPath      *uint16
    78  	AuthFlags       uint32
    79  	FullName        *uint16
    80  	UsrComment      *uint16
    81  	Parms           *uint16
    82  	Workstations    *uint16
    83  	LastLogon       uint32
    84  	LastLogoff      uint32
    85  	AcctExpires     uint32
    86  	MaxStorage      uint32
    87  	UnitsPerWeek    uint32
    88  	LogonHours      *byte
    89  	BadPwCount      uint32
    90  	NumLogons       uint32
    91  	LogonServer     *uint16
    92  	CountryCode     uint32
    93  	CodePage        uint32
    94  	UserSid         *syscall.SID
    95  	PrimaryGroupID  uint32
    96  	Profile         *uint16
    97  	HomeDirDrive    *uint16
    98  	PasswordExpired uint32
    99  }
   100  
   101  // GetSystemDirectory retrieves the path to current location of the system
   102  // directory, which is typically, though not always, `C:\Windows\System32`.
   103  //
   104  //go:linkname GetSystemDirectory
   105  func GetSystemDirectory() string