コード例 #1
0
ファイル: windows.go プロジェクト: jmptrader/com
func NewHString(s string) (hstring hstr.HString, err error) {
	u16 := windows.StringToUTF16Ptr(s)
	len := uint32(utf8.RuneCountInString(s))
	err = errors.MaybeError(procWindowsCreateString.Call(
		uintptr(unsafe.Pointer(u16)),
		uintptr(len),
		uintptr(unsafe.Pointer(&hstring))))
	return
}
コード例 #2
0
ファイル: util.go プロジェクト: aws/amazon-ssm-agent
// Create an ExplicitAccess instance denying permissions to the provided name.
func DenyName(accessPermissions uint32, name string) api.ExplicitAccess {
	return api.ExplicitAccess{
		AccessPermissions: accessPermissions,
		AccessMode:        api.DENY_ACCESS,
		Inheritance:       api.SUB_CONTAINERS_AND_OBJECTS_INHERIT,
		Trustee: api.Trustee{
			TrusteeForm: api.TRUSTEE_IS_NAME,
			Name:        windows.StringToUTF16Ptr(name),
		},
	}
}
コード例 #3
0
ファイル: secinfo.go プロジェクト: aws/amazon-ssm-agent
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa379579.aspx
func SetNamedSecurityInfo(objectName string, objectType int32, secInfo uint32, owner, group *windows.SID, dacl, sacl windows.Handle) error {
	ret, _, err := procSetNamedSecurityInfoW.Call(
		uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(objectName))),
		uintptr(objectType),
		uintptr(secInfo),
		uintptr(unsafe.Pointer(owner)),
		uintptr(unsafe.Pointer(group)),
		uintptr(dacl),
		uintptr(sacl),
	)
	if ret != 0 {
		return err
	}
	return nil
}
コード例 #4
0
ファイル: directory_windows.go プロジェクト: encryptio/slime
func (ds *Directory) FreeSpace(cancel <-chan struct{}) (int64, error) {
	dir, err := filepath.Abs(ds.Dir)
	if err != nil {
		return 0, err
	}

	// TODO: this doesn't look like it's safe under garbage collection
	var avail, total, free int64
	r1, _, err := getDiskFreeSpaceExW.Call(
		uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(dir))),
		uintptr(unsafe.Pointer(&avail)),
		uintptr(unsafe.Pointer(&total)),
		uintptr(unsafe.Pointer(&free)))
	if r1 == 0 {
		return 0, err
	}

	return free, nil
}
コード例 #5
0
ファイル: acl_test.go プロジェクト: aws/amazon-ssm-agent
func TestSetEntriesInAcl(t *testing.T) {
	var (
		entries = []ExplicitAccess{
			{
				AccessPermissions: windows.GENERIC_READ,
				AccessMode:        GRANT_ACCESS,
				Inheritance:       NO_INHERITANCE,
				Trustee: Trustee{
					TrusteeForm: TRUSTEE_IS_NAME,
					Name:        windows.StringToUTF16Ptr("CURRENT_USER"),
				},
			},
		}
		acl windows.Handle
	)
	if err := SetEntriesInAcl(
		entries,
		0,
		&acl,
	); err != nil {
		t.Fatal(err)
	}
	defer windows.LocalFree(acl)
}
コード例 #6
0
ファイル: windows.go プロジェクト: jmptrader/com
func SysAllocString(v string) (ss *int16) {
	pss, _, _ := procSysAllocString.Call(uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(v))))
	ss = (*int16)(unsafe.Pointer(pss))
	return
}