Exemple #1
0
func (self SecurityID) String() (string, error) {
	var stringSid *uint16
	if err := wrappers.ConvertSidToStringSid(self.sid, &stringSid); err != nil {
		return "", NewWindowsError("ConvertSidToStringSid", err)
	}
	defer wrappers.LocalFree(syscall.Handle(unsafe.Pointer(stringSid)))
	return LpstrToString(stringSid), nil
}
Exemple #2
0
func (self COMError) Error() string {
	var message *uint16
	_, err := wrappers.FormatMessage(
		wrappers.FORMAT_MESSAGE_ALLOCATE_BUFFER|wrappers.FORMAT_MESSAGE_IGNORE_INSERTS|wrappers.FORMAT_MESSAGE_FROM_SYSTEM,
		0,
		uint32(self),
		0,
		(*uint16)(unsafe.Pointer(&message)),
		65536,
		nil)
	if err != nil {
		return fmt.Sprintf("com error 0x%08X", uint32(self))
	}
	defer wrappers.LocalFree(syscall.Handle(unsafe.Pointer(message)))
	return strings.TrimRight(LpstrToString(message), "\r\n")
}
Exemple #3
0
func (self NTError) Error() string {
	hModule, err := wrappers.LoadLibrary(syscall.StringToUTF16Ptr("ntdll.dll"))
	if err != nil {
		return fmt.Sprintf("nt error 0x%08X", uint32(self))
	}
	defer wrappers.FreeLibrary(hModule)
	var message *uint16
	_, err = wrappers.FormatMessage(
		wrappers.FORMAT_MESSAGE_ALLOCATE_BUFFER|wrappers.FORMAT_MESSAGE_FROM_SYSTEM|wrappers.FORMAT_MESSAGE_FROM_HMODULE,
		uintptr(hModule),
		uint32(self),
		0,
		(*uint16)(unsafe.Pointer(&message)),
		0,
		nil)
	if err != nil {
		return fmt.Sprintf("nt error 0x%08X", uint32(self))
	}
	defer wrappers.LocalFree(syscall.Handle(unsafe.Pointer(message)))
	return strings.TrimRight(LpstrToString(message), "\r\n")
}