Skip to content

Commit

Permalink
Define C_WORD
Browse files Browse the repository at this point in the history
  • Loading branch information
aveenismail committed Apr 24, 2024
1 parent 304c900 commit a0911eb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
31 changes: 17 additions & 14 deletions usb_winusb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion versioninfo_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a0911eb

Please sign in to comment.