From a0911eb4a190c65355267d4d76704492803285fb Mon Sep 17 00:00:00 2001 From: Aveen Ismail Date: Wed, 24 Apr 2024 13:58:26 +0200 Subject: [PATCH] Define C_WORD --- usb_winusb.go | 31 +++++++++++++++++-------------- versioninfo_windows.go | 2 +- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/usb_winusb.go b/usb_winusb.go index 3304688..6c1dc54 100644 --- a/usb_winusb.go +++ b/usb_winusb.go @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build windows // +build windows package main @@ -34,26 +35,28 @@ var device struct { mtx sync.Mutex } -func (e C.DWORD) Error() string { +type C_DWORD C.ulong + +func (e C_DWORD) Error() string { return fmt.Sprintf("Windows Error: 0x%x", uint(e)) } const ( - SUCCESS C.DWORD = C.ERROR_SUCCESS - ERROR_INVALID_STATE C.DWORD = C.ERROR_INVALID_STATE - ERROR_INVALID_HANDLE C.DWORD = C.ERROR_INVALID_HANDLE - ERROR_INVALID_PARAMETER C.DWORD = C.ERROR_INVALID_PARAMETER - ERROR_OUTOFMEMORY C.DWORD = C.ERROR_OUTOFMEMORY - ERROR_GEN_FAILURE C.DWORD = C.ERROR_GEN_FAILURE - ERROR_OBJECT_NOT_FOUND C.DWORD = C.ERROR_OBJECT_NOT_FOUND - ERROR_NOT_SUPPORTED C.DWORD = C.ERROR_NOT_SUPPORTED - ERROR_SHARING_VIOLATION C.DWORD = C.ERROR_SHARING_VIOLATION - ERROR_BAD_COMMAND C.DWORD = C.ERROR_BAD_COMMAND + SUCCESS C_DWORD = C.ERROR_SUCCESS + ERROR_INVALID_STATE C_DWORD = C.ERROR_INVALID_STATE + ERROR_INVALID_HANDLE C_DWORD = C.ERROR_INVALID_HANDLE + ERROR_INVALID_PARAMETER C_DWORD = C.ERROR_INVALID_PARAMETER + ERROR_OUTOFMEMORY C_DWORD = C.ERROR_OUTOFMEMORY + ERROR_GEN_FAILURE C_DWORD = C.ERROR_GEN_FAILURE + ERROR_OBJECT_NOT_FOUND C_DWORD = C.ERROR_OBJECT_NOT_FOUND + ERROR_NOT_SUPPORTED C_DWORD = C.ERROR_NOT_SUPPORTED + ERROR_SHARING_VIOLATION C_DWORD = C.ERROR_SHARING_VIOLATION + ERROR_BAD_COMMAND C_DWORD = C.ERROR_BAD_COMMAND ) -func winusbError(err error) error { - if err != SUCCESS { - return err +func winusbError(err C.ulong) error { + if err != C.ERROR_SUCCESS { + return C_DWORD(err) } return nil } diff --git a/versioninfo_windows.go b/versioninfo_windows.go index f48c664..d557679 100644 --- a/versioninfo_windows.go +++ b/versioninfo_windows.go @@ -12,6 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -go:generate goversioninfo -64 +// go:generate goversioninfo -64 package main