mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 02:38:35 +00:00
Handle CORS requests (#6289)
This commit is contained in:
committed by
techknowlogick
parent
6fb58a8cdc
commit
34d06f4c6b
8
vendor/golang.org/x/sys/windows/dll_windows.go
generated
vendored
8
vendor/golang.org/x/sys/windows/dll_windows.go
generated
vendored
@@ -359,11 +359,11 @@ func loadLibraryEx(name string, system bool) (*DLL, error) {
|
||||
// trying to load "foo.dll" out of the system
|
||||
// folder, but LoadLibraryEx doesn't support
|
||||
// that yet on their system, so emulate it.
|
||||
windir, _ := Getenv("WINDIR") // old var; apparently works on XP
|
||||
if windir == "" {
|
||||
return nil, errString("%WINDIR% not defined")
|
||||
systemdir, err := GetSystemDirectory()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
loadDLL = windir + "\\System32\\" + name
|
||||
loadDLL = systemdir + "\\" + name
|
||||
}
|
||||
}
|
||||
h, err := LoadLibraryEx(loadDLL, 0, flags)
|
||||
|
171
vendor/golang.org/x/sys/windows/security_windows.go
generated
vendored
171
vendor/golang.org/x/sys/windows/security_windows.go
generated
vendored
@@ -169,6 +169,7 @@ const (
|
||||
//sys GetLengthSid(sid *SID) (len uint32) = advapi32.GetLengthSid
|
||||
//sys CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) = advapi32.CopySid
|
||||
//sys AllocateAndInitializeSid(identAuth *SidIdentifierAuthority, subAuth byte, subAuth0 uint32, subAuth1 uint32, subAuth2 uint32, subAuth3 uint32, subAuth4 uint32, subAuth5 uint32, subAuth6 uint32, subAuth7 uint32, sid **SID) (err error) = advapi32.AllocateAndInitializeSid
|
||||
//sys createWellKnownSid(sidType WELL_KNOWN_SID_TYPE, domainSid *SID, sid *SID, sizeSid *uint32) (err error) = advapi32.CreateWellKnownSid
|
||||
//sys FreeSid(sid *SID) (err error) [failretval!=0] = advapi32.FreeSid
|
||||
//sys EqualSid(sid1 *SID, sid2 *SID) (isEqual bool) = advapi32.EqualSid
|
||||
|
||||
@@ -286,6 +287,158 @@ func (sid *SID) LookupAccount(system string) (account, domain string, accType ui
|
||||
}
|
||||
}
|
||||
|
||||
// Various types of pre-specified sids that can be synthesized at runtime.
|
||||
type WELL_KNOWN_SID_TYPE uint32
|
||||
|
||||
const (
|
||||
WinNullSid = 0
|
||||
WinWorldSid = 1
|
||||
WinLocalSid = 2
|
||||
WinCreatorOwnerSid = 3
|
||||
WinCreatorGroupSid = 4
|
||||
WinCreatorOwnerServerSid = 5
|
||||
WinCreatorGroupServerSid = 6
|
||||
WinNtAuthoritySid = 7
|
||||
WinDialupSid = 8
|
||||
WinNetworkSid = 9
|
||||
WinBatchSid = 10
|
||||
WinInteractiveSid = 11
|
||||
WinServiceSid = 12
|
||||
WinAnonymousSid = 13
|
||||
WinProxySid = 14
|
||||
WinEnterpriseControllersSid = 15
|
||||
WinSelfSid = 16
|
||||
WinAuthenticatedUserSid = 17
|
||||
WinRestrictedCodeSid = 18
|
||||
WinTerminalServerSid = 19
|
||||
WinRemoteLogonIdSid = 20
|
||||
WinLogonIdsSid = 21
|
||||
WinLocalSystemSid = 22
|
||||
WinLocalServiceSid = 23
|
||||
WinNetworkServiceSid = 24
|
||||
WinBuiltinDomainSid = 25
|
||||
WinBuiltinAdministratorsSid = 26
|
||||
WinBuiltinUsersSid = 27
|
||||
WinBuiltinGuestsSid = 28
|
||||
WinBuiltinPowerUsersSid = 29
|
||||
WinBuiltinAccountOperatorsSid = 30
|
||||
WinBuiltinSystemOperatorsSid = 31
|
||||
WinBuiltinPrintOperatorsSid = 32
|
||||
WinBuiltinBackupOperatorsSid = 33
|
||||
WinBuiltinReplicatorSid = 34
|
||||
WinBuiltinPreWindows2000CompatibleAccessSid = 35
|
||||
WinBuiltinRemoteDesktopUsersSid = 36
|
||||
WinBuiltinNetworkConfigurationOperatorsSid = 37
|
||||
WinAccountAdministratorSid = 38
|
||||
WinAccountGuestSid = 39
|
||||
WinAccountKrbtgtSid = 40
|
||||
WinAccountDomainAdminsSid = 41
|
||||
WinAccountDomainUsersSid = 42
|
||||
WinAccountDomainGuestsSid = 43
|
||||
WinAccountComputersSid = 44
|
||||
WinAccountControllersSid = 45
|
||||
WinAccountCertAdminsSid = 46
|
||||
WinAccountSchemaAdminsSid = 47
|
||||
WinAccountEnterpriseAdminsSid = 48
|
||||
WinAccountPolicyAdminsSid = 49
|
||||
WinAccountRasAndIasServersSid = 50
|
||||
WinNTLMAuthenticationSid = 51
|
||||
WinDigestAuthenticationSid = 52
|
||||
WinSChannelAuthenticationSid = 53
|
||||
WinThisOrganizationSid = 54
|
||||
WinOtherOrganizationSid = 55
|
||||
WinBuiltinIncomingForestTrustBuildersSid = 56
|
||||
WinBuiltinPerfMonitoringUsersSid = 57
|
||||
WinBuiltinPerfLoggingUsersSid = 58
|
||||
WinBuiltinAuthorizationAccessSid = 59
|
||||
WinBuiltinTerminalServerLicenseServersSid = 60
|
||||
WinBuiltinDCOMUsersSid = 61
|
||||
WinBuiltinIUsersSid = 62
|
||||
WinIUserSid = 63
|
||||
WinBuiltinCryptoOperatorsSid = 64
|
||||
WinUntrustedLabelSid = 65
|
||||
WinLowLabelSid = 66
|
||||
WinMediumLabelSid = 67
|
||||
WinHighLabelSid = 68
|
||||
WinSystemLabelSid = 69
|
||||
WinWriteRestrictedCodeSid = 70
|
||||
WinCreatorOwnerRightsSid = 71
|
||||
WinCacheablePrincipalsGroupSid = 72
|
||||
WinNonCacheablePrincipalsGroupSid = 73
|
||||
WinEnterpriseReadonlyControllersSid = 74
|
||||
WinAccountReadonlyControllersSid = 75
|
||||
WinBuiltinEventLogReadersGroup = 76
|
||||
WinNewEnterpriseReadonlyControllersSid = 77
|
||||
WinBuiltinCertSvcDComAccessGroup = 78
|
||||
WinMediumPlusLabelSid = 79
|
||||
WinLocalLogonSid = 80
|
||||
WinConsoleLogonSid = 81
|
||||
WinThisOrganizationCertificateSid = 82
|
||||
WinApplicationPackageAuthoritySid = 83
|
||||
WinBuiltinAnyPackageSid = 84
|
||||
WinCapabilityInternetClientSid = 85
|
||||
WinCapabilityInternetClientServerSid = 86
|
||||
WinCapabilityPrivateNetworkClientServerSid = 87
|
||||
WinCapabilityPicturesLibrarySid = 88
|
||||
WinCapabilityVideosLibrarySid = 89
|
||||
WinCapabilityMusicLibrarySid = 90
|
||||
WinCapabilityDocumentsLibrarySid = 91
|
||||
WinCapabilitySharedUserCertificatesSid = 92
|
||||
WinCapabilityEnterpriseAuthenticationSid = 93
|
||||
WinCapabilityRemovableStorageSid = 94
|
||||
WinBuiltinRDSRemoteAccessServersSid = 95
|
||||
WinBuiltinRDSEndpointServersSid = 96
|
||||
WinBuiltinRDSManagementServersSid = 97
|
||||
WinUserModeDriversSid = 98
|
||||
WinBuiltinHyperVAdminsSid = 99
|
||||
WinAccountCloneableControllersSid = 100
|
||||
WinBuiltinAccessControlAssistanceOperatorsSid = 101
|
||||
WinBuiltinRemoteManagementUsersSid = 102
|
||||
WinAuthenticationAuthorityAssertedSid = 103
|
||||
WinAuthenticationServiceAssertedSid = 104
|
||||
WinLocalAccountSid = 105
|
||||
WinLocalAccountAndAdministratorSid = 106
|
||||
WinAccountProtectedUsersSid = 107
|
||||
WinCapabilityAppointmentsSid = 108
|
||||
WinCapabilityContactsSid = 109
|
||||
WinAccountDefaultSystemManagedSid = 110
|
||||
WinBuiltinDefaultSystemManagedGroupSid = 111
|
||||
WinBuiltinStorageReplicaAdminsSid = 112
|
||||
WinAccountKeyAdminsSid = 113
|
||||
WinAccountEnterpriseKeyAdminsSid = 114
|
||||
WinAuthenticationKeyTrustSid = 115
|
||||
WinAuthenticationKeyPropertyMFASid = 116
|
||||
WinAuthenticationKeyPropertyAttestationSid = 117
|
||||
WinAuthenticationFreshKeyAuthSid = 118
|
||||
WinBuiltinDeviceOwnersSid = 119
|
||||
)
|
||||
|
||||
// Creates a sid for a well-known predefined alias, generally using the constants of the form
|
||||
// Win*Sid, for the local machine.
|
||||
func CreateWellKnownSid(sidType WELL_KNOWN_SID_TYPE) (*SID, error) {
|
||||
return CreateWellKnownDomainSid(sidType, nil)
|
||||
}
|
||||
|
||||
// Creates a sid for a well-known predefined alias, generally using the constants of the form
|
||||
// Win*Sid, for the domain specified by the domainSid parameter.
|
||||
func CreateWellKnownDomainSid(sidType WELL_KNOWN_SID_TYPE, domainSid *SID) (*SID, error) {
|
||||
n := uint32(50)
|
||||
for {
|
||||
b := make([]byte, n)
|
||||
sid := (*SID)(unsafe.Pointer(&b[0]))
|
||||
err := createWellKnownSid(sidType, domainSid, sid, &n)
|
||||
if err == nil {
|
||||
return sid, nil
|
||||
}
|
||||
if err != ERROR_INSUFFICIENT_BUFFER {
|
||||
return nil, err
|
||||
}
|
||||
if n <= uint32(len(b)) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
// do not reorder
|
||||
TOKEN_ASSIGN_PRIMARY = 1 << iota
|
||||
@@ -372,6 +525,7 @@ type Tokengroups struct {
|
||||
//sys OpenProcessToken(h Handle, access uint32, token *Token) (err error) = advapi32.OpenProcessToken
|
||||
//sys GetTokenInformation(t Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) = advapi32.GetTokenInformation
|
||||
//sys GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) = userenv.GetUserProfileDirectoryW
|
||||
//sys getSystemDirectory(dir *uint16, dirLen uint32) (len uint32, err error) = kernel32.GetSystemDirectoryW
|
||||
|
||||
// An access token contains the security information for a logon session.
|
||||
// The system creates an access token when a user logs on, and every
|
||||
@@ -468,6 +622,23 @@ func (t Token) GetUserProfileDirectory() (string, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetSystemDirectory retrieves path to current location of the system
|
||||
// directory, which is typically, though not always, C:\Windows\System32.
|
||||
func GetSystemDirectory() (string, error) {
|
||||
n := uint32(MAX_PATH)
|
||||
for {
|
||||
b := make([]uint16, n)
|
||||
l, e := getSystemDirectory(&b[0], n)
|
||||
if e != nil {
|
||||
return "", e
|
||||
}
|
||||
if l <= n {
|
||||
return UTF16ToString(b[:l]), nil
|
||||
}
|
||||
n = l
|
||||
}
|
||||
}
|
||||
|
||||
// IsMember reports whether the access token t is a member of the provided SID.
|
||||
func (t Token) IsMember(sid *SID) (bool, error) {
|
||||
var b int32
|
||||
|
36
vendor/golang.org/x/sys/windows/svc/service.go
generated
vendored
36
vendor/golang.org/x/sys/windows/svc/service.go
generated
vendored
@@ -80,6 +80,7 @@ type ChangeRequest struct {
|
||||
EventType uint32
|
||||
EventData uintptr
|
||||
CurrentStatus Status
|
||||
Context uintptr
|
||||
}
|
||||
|
||||
// Handler is the interface that must be implemented to build Windows service.
|
||||
@@ -114,19 +115,18 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
k := syscall.MustLoadDLL("kernel32.dll")
|
||||
cSetEvent = k.MustFindProc("SetEvent").Addr()
|
||||
cWaitForSingleObject = k.MustFindProc("WaitForSingleObject").Addr()
|
||||
a := syscall.MustLoadDLL("advapi32.dll")
|
||||
cRegisterServiceCtrlHandlerExW = a.MustFindProc("RegisterServiceCtrlHandlerExW").Addr()
|
||||
k := windows.NewLazySystemDLL("kernel32.dll")
|
||||
cSetEvent = k.NewProc("SetEvent").Addr()
|
||||
cWaitForSingleObject = k.NewProc("WaitForSingleObject").Addr()
|
||||
a := windows.NewLazySystemDLL("advapi32.dll")
|
||||
cRegisterServiceCtrlHandlerExW = a.NewProc("RegisterServiceCtrlHandlerExW").Addr()
|
||||
}
|
||||
|
||||
// The HandlerEx prototype also has a context pointer but since we don't use
|
||||
// it at start-up time we don't have to pass it over either.
|
||||
type ctlEvent struct {
|
||||
cmd Cmd
|
||||
eventType uint32
|
||||
eventData uintptr
|
||||
context uintptr
|
||||
errno uint32
|
||||
}
|
||||
|
||||
@@ -238,13 +238,12 @@ func (s *service) run() {
|
||||
exitFromHandler <- exitCode{ss, errno}
|
||||
}()
|
||||
|
||||
status := Status{State: Stopped}
|
||||
ec := exitCode{isSvcSpecific: true, errno: 0}
|
||||
outcr := ChangeRequest{
|
||||
CurrentStatus: Status{State: Stopped},
|
||||
}
|
||||
var outch chan ChangeRequest
|
||||
inch := s.c
|
||||
var cmd Cmd
|
||||
var evtype uint32
|
||||
var evdata uintptr
|
||||
loop:
|
||||
for {
|
||||
select {
|
||||
@@ -255,10 +254,11 @@ loop:
|
||||
}
|
||||
inch = nil
|
||||
outch = cmdsToHandler
|
||||
cmd = r.cmd
|
||||
evtype = r.eventType
|
||||
evdata = r.eventData
|
||||
case outch <- ChangeRequest{cmd, evtype, evdata, status}:
|
||||
outcr.Cmd = r.cmd
|
||||
outcr.EventType = r.eventType
|
||||
outcr.EventData = r.eventData
|
||||
outcr.Context = r.context
|
||||
case outch <- outcr:
|
||||
inch = s.c
|
||||
outch = nil
|
||||
case c := <-changesFromHandler:
|
||||
@@ -271,7 +271,7 @@ loop:
|
||||
}
|
||||
break loop
|
||||
}
|
||||
status = c
|
||||
outcr.CurrentStatus = c
|
||||
case ec = <-exitFromHandler:
|
||||
break loop
|
||||
}
|
||||
@@ -315,8 +315,8 @@ func Run(name string, handler Handler) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ctlHandler := func(ctl uint32, evtype uint32, evdata uintptr, context uintptr) uintptr {
|
||||
e := ctlEvent{cmd: Cmd(ctl), eventType: evtype, eventData: evdata}
|
||||
ctlHandler := func(ctl, evtype, evdata, context uintptr) uintptr {
|
||||
e := ctlEvent{cmd: Cmd(ctl), eventType: uint32(evtype), eventData: evdata, context: context}
|
||||
// We assume that this callback function is running on
|
||||
// the same thread as Run. Nowhere in MS documentation
|
||||
// I could find statement to guarantee that. So putting
|
||||
|
3
vendor/golang.org/x/sys/windows/svc/sys_386.s
generated
vendored
3
vendor/golang.org/x/sys/windows/svc/sys_386.s
generated
vendored
@@ -22,7 +22,8 @@ TEXT ·servicemain(SB),7,$0
|
||||
MOVL AX, (SP)
|
||||
MOVL $·servicectlhandler(SB), AX
|
||||
MOVL AX, 4(SP)
|
||||
MOVL $0, 8(SP)
|
||||
// Set context to 123456 to test issue #25660.
|
||||
MOVL $123456, 8(SP)
|
||||
MOVL ·cRegisterServiceCtrlHandlerExW(SB), AX
|
||||
MOVL SP, BP
|
||||
CALL AX
|
||||
|
2
vendor/golang.org/x/sys/windows/svc/sys_amd64.s
generated
vendored
2
vendor/golang.org/x/sys/windows/svc/sys_amd64.s
generated
vendored
@@ -14,6 +14,8 @@ TEXT ·servicemain(SB),7,$0
|
||||
MOVQ ·sName(SB), CX
|
||||
MOVQ $·servicectlhandler(SB), DX
|
||||
// BUG(pastarmovj): Figure out a way to pass in context in R8.
|
||||
// Set context to 123456 to test issue #25660.
|
||||
MOVQ $123456, R8
|
||||
MOVQ ·cRegisterServiceCtrlHandlerExW(SB), AX
|
||||
CALL AX
|
||||
CMPQ AX, $0
|
||||
|
1
vendor/golang.org/x/sys/windows/syscall_windows.go
generated
vendored
1
vendor/golang.org/x/sys/windows/syscall_windows.go
generated
vendored
@@ -137,6 +137,7 @@ func NewCallbackCDecl(fn interface{}) uintptr {
|
||||
//sys CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile int32) (handle Handle, err error) [failretval==InvalidHandle] = CreateFileW
|
||||
//sys ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error)
|
||||
//sys WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error)
|
||||
//sys GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error)
|
||||
//sys SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) [failretval==0xffffffff]
|
||||
//sys CloseHandle(handle Handle) (err error)
|
||||
//sys GetStdHandle(stdhandle uint32) (handle Handle, err error) [failretval==InvalidHandle]
|
||||
|
16
vendor/golang.org/x/sys/windows/types_windows.go
generated
vendored
16
vendor/golang.org/x/sys/windows/types_windows.go
generated
vendored
@@ -126,9 +126,19 @@ const (
|
||||
OPEN_ALWAYS = 4
|
||||
TRUNCATE_EXISTING = 5
|
||||
|
||||
FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000
|
||||
FILE_FLAG_BACKUP_SEMANTICS = 0x02000000
|
||||
FILE_FLAG_OVERLAPPED = 0x40000000
|
||||
FILE_FLAG_OPEN_REQUIRING_OPLOCK = 0x00040000
|
||||
FILE_FLAG_FIRST_PIPE_INSTANCE = 0x00080000
|
||||
FILE_FLAG_OPEN_NO_RECALL = 0x00100000
|
||||
FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000
|
||||
FILE_FLAG_SESSION_AWARE = 0x00800000
|
||||
FILE_FLAG_POSIX_SEMANTICS = 0x01000000
|
||||
FILE_FLAG_BACKUP_SEMANTICS = 0x02000000
|
||||
FILE_FLAG_DELETE_ON_CLOSE = 0x04000000
|
||||
FILE_FLAG_SEQUENTIAL_SCAN = 0x08000000
|
||||
FILE_FLAG_RANDOM_ACCESS = 0x10000000
|
||||
FILE_FLAG_NO_BUFFERING = 0x20000000
|
||||
FILE_FLAG_OVERLAPPED = 0x40000000
|
||||
FILE_FLAG_WRITE_THROUGH = 0x80000000
|
||||
|
||||
HANDLE_FLAG_INHERIT = 0x00000001
|
||||
STARTF_USESTDHANDLES = 0x00000100
|
||||
|
46
vendor/golang.org/x/sys/windows/zsyscall_windows.go
generated
vendored
46
vendor/golang.org/x/sys/windows/zsyscall_windows.go
generated
vendored
@@ -77,6 +77,7 @@ var (
|
||||
procCreateFileW = modkernel32.NewProc("CreateFileW")
|
||||
procReadFile = modkernel32.NewProc("ReadFile")
|
||||
procWriteFile = modkernel32.NewProc("WriteFile")
|
||||
procGetOverlappedResult = modkernel32.NewProc("GetOverlappedResult")
|
||||
procSetFilePointer = modkernel32.NewProc("SetFilePointer")
|
||||
procCloseHandle = modkernel32.NewProc("CloseHandle")
|
||||
procGetStdHandle = modkernel32.NewProc("GetStdHandle")
|
||||
@@ -246,12 +247,14 @@ var (
|
||||
procGetLengthSid = modadvapi32.NewProc("GetLengthSid")
|
||||
procCopySid = modadvapi32.NewProc("CopySid")
|
||||
procAllocateAndInitializeSid = modadvapi32.NewProc("AllocateAndInitializeSid")
|
||||
procCreateWellKnownSid = modadvapi32.NewProc("CreateWellKnownSid")
|
||||
procFreeSid = modadvapi32.NewProc("FreeSid")
|
||||
procEqualSid = modadvapi32.NewProc("EqualSid")
|
||||
procCheckTokenMembership = modadvapi32.NewProc("CheckTokenMembership")
|
||||
procOpenProcessToken = modadvapi32.NewProc("OpenProcessToken")
|
||||
procGetTokenInformation = modadvapi32.NewProc("GetTokenInformation")
|
||||
procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW")
|
||||
procGetSystemDirectoryW = modkernel32.NewProc("GetSystemDirectoryW")
|
||||
)
|
||||
|
||||
func RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) {
|
||||
@@ -652,6 +655,24 @@ func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped)
|
||||
return
|
||||
}
|
||||
|
||||
func GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error) {
|
||||
var _p0 uint32
|
||||
if wait {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall6(procGetOverlappedResult.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(done)), uintptr(_p0), 0, 0)
|
||||
if r1 == 0 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) {
|
||||
r0, _, e1 := syscall.Syscall6(procSetFilePointer.Addr(), 4, uintptr(handle), uintptr(lowoffset), uintptr(unsafe.Pointer(highoffsetptr)), uintptr(whence), 0, 0)
|
||||
newlowoffset = uint32(r0)
|
||||
@@ -2653,6 +2674,18 @@ func AllocateAndInitializeSid(identAuth *SidIdentifierAuthority, subAuth byte, s
|
||||
return
|
||||
}
|
||||
|
||||
func createWellKnownSid(sidType WELL_KNOWN_SID_TYPE, domainSid *SID, sid *SID, sizeSid *uint32) (err error) {
|
||||
r1, _, e1 := syscall.Syscall6(procCreateWellKnownSid.Addr(), 4, uintptr(sidType), uintptr(unsafe.Pointer(domainSid)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sizeSid)), 0, 0)
|
||||
if r1 == 0 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func FreeSid(sid *SID) (err error) {
|
||||
r1, _, e1 := syscall.Syscall(procFreeSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
|
||||
if r1 != 0 {
|
||||
@@ -2718,3 +2751,16 @@ func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func getSystemDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
|
||||
r0, _, e1 := syscall.Syscall(procGetSystemDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
|
||||
len = uint32(r0)
|
||||
if len == 0 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user