-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
159 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
[![Build Status](https://dev.azure.com/oneeyedelf1/wasm-imagemagick/_apis/build/status/KnicKnic.go-failovercluster-api?branchName=master)](https://dev.azure.com/oneeyedelf1/wasm-imagemagick/_build/latest?definitionId=4&branchName=master) | ||
[![Build Status](https://dev.azure.com/oneeyedelf1/powershell.native/_apis/build/status/KnicKnic.go-windows?branchName=master)](https://dev.azure.com/oneeyedelf1/powershell.native/_build/latest?definitionId=5&branchName=master) | ||
|
||
# Goal | ||
|
||
To create bindings to allow you a go application to call Microsoft Windows Server Failover Cluster Api. | ||
To create bindings to allow you a go application to call various Microsoft Windows Server Apis. | ||
|
||
Currently uses syscall to wrap the c clusapi.dll and resutils.dll code. | ||
|
||
## Completed | ||
## Contents (pkg/...) | ||
|
||
Parts of the following cluster api sets | ||
1. Cluster | ||
1. Resource | ||
1. Registry | ||
1. Crypto | ||
|
||
## TODO | ||
|
||
* add comments for public functions | ||
* Write more tests | ||
* complete more wrappers for functions | ||
* [Cluster](pkg/cluster/Readme.md) | ||
* Microsoft Windows Failover Cluster bindings | ||
* [kernel32](pkg/kernel32) | ||
* LocalAlloc & LocalFree | ||
* [ntdll](pkg/ntdll) | ||
* memcpy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
module github.com/KnicKnic/go-failovercluster-api | ||
module github.com/KnicKnic/go-windows | ||
|
||
go 1.13 | ||
|
||
require ( | ||
github.com/stretchr/testify v1.4.0 | ||
golang.org/dl v0.0.0-20191205014302-95494741406c // indirect | ||
golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Goal | ||
|
||
To create bindings to allow you a go application to call Microsoft Windows Server Failover Cluster Api. | ||
|
||
Currently uses syscall to wrap the c clusapi.dll and resutils.dll code. | ||
|
||
## Completed | ||
|
||
Parts of the following cluster api sets | ||
1. Cluster | ||
1. Resource | ||
1. Registry | ||
1. Crypto | ||
|
||
## TODO | ||
|
||
* add comments for public functions | ||
* Write more tests | ||
* complete more wrappers for functions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
package memory | ||
|
||
import ( | ||
"encoding/binary" | ||
"unsafe" | ||
) | ||
|
||
func Uint32ToByte(data uint32) (output []byte) { | ||
output = make([]byte, int(unsafe.Sizeof(data))) | ||
binary.LittleEndian.PutUint32(output, data) | ||
return | ||
} | ||
func Uint64ToByte(data uint64) (output []byte) { | ||
output = make([]byte, int(unsafe.Sizeof(data))) | ||
binary.LittleEndian.PutUint64(output, data) | ||
return | ||
} | ||
package util | ||
|
||
import ( | ||
"encoding/binary" | ||
"unsafe" | ||
) | ||
|
||
func Uint32ToByte(data uint32) (output []byte) { | ||
output = make([]byte, int(unsafe.Sizeof(data))) | ||
binary.LittleEndian.PutUint32(output, data) | ||
return | ||
} | ||
func Uint64ToByte(data uint64) (output []byte) { | ||
output = make([]byte, int(unsafe.Sizeof(data))) | ||
binary.LittleEndian.PutUint64(output, data) | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package memory | ||
|
||
// func TestGuidToByte(t *testing.T) { | ||
|
||
// syscall.GUID | ||
// } | ||
package util | ||
|
||
// func TestGuidToByte(t *testing.T) { | ||
|
||
// syscall.GUID | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,62 @@ | ||
package memory | ||
|
||
import ( | ||
"bytes" | ||
"crypto/rand" | ||
"encoding/binary" | ||
"fmt" | ||
) | ||
|
||
type GUID struct { | ||
Data1 uint32 | ||
Data2 uint16 | ||
Data3 uint16 | ||
Data4 [8]byte | ||
} | ||
|
||
func (guid GUID) String() string { | ||
return fmt.Sprintf("%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", | ||
guid.Data1, guid.Data2, guid.Data3, | ||
guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], | ||
guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]) | ||
} | ||
func GuidFromString(g string) (guid GUID, err error) { | ||
_, err = fmt.Sscanf(g, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", | ||
&guid.Data1, &guid.Data2, &guid.Data3, | ||
&guid.Data4[0], &guid.Data4[1], &guid.Data4[2], &guid.Data4[3], | ||
&guid.Data4[4], &guid.Data4[5], &guid.Data4[6], &guid.Data4[7]) | ||
return | ||
} | ||
|
||
func GenerateGuidByte() (data []byte, err error) { | ||
|
||
data = make([]byte, 16) | ||
_, err = rand.Read(data) | ||
return | ||
} | ||
|
||
func GenerateGuid() (guid GUID, err error) { | ||
data, err := GenerateGuidByte() | ||
if err != nil { | ||
return | ||
} | ||
guid, err = GuidFromBytes(data) | ||
return | ||
} | ||
|
||
func (data GUID) ToByte() (output []byte, err error) { | ||
|
||
buf := new(bytes.Buffer) | ||
err = binary.Write(buf, binary.LittleEndian, data) | ||
if err != nil { | ||
return | ||
} | ||
output = buf.Bytes() | ||
return | ||
} | ||
func GuidFromBytes(data []byte) (guid GUID, err error) { | ||
|
||
buf := bytes.NewReader(data) | ||
err = binary.Read(buf, binary.LittleEndian, &guid) | ||
return | ||
} | ||
package guid | ||
|
||
import ( | ||
"bytes" | ||
"crypto/rand" | ||
"encoding/binary" | ||
"fmt" | ||
) | ||
|
||
type GUID struct { | ||
Data1 uint32 | ||
Data2 uint16 | ||
Data3 uint16 | ||
Data4 [8]byte | ||
} | ||
|
||
func (guid GUID) String() string { | ||
return fmt.Sprintf("%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", | ||
guid.Data1, guid.Data2, guid.Data3, | ||
guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], | ||
guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]) | ||
} | ||
func FromString(g string) (guid GUID, err error) { | ||
_, err = fmt.Sscanf(g, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", | ||
&guid.Data1, &guid.Data2, &guid.Data3, | ||
&guid.Data4[0], &guid.Data4[1], &guid.Data4[2], &guid.Data4[3], | ||
&guid.Data4[4], &guid.Data4[5], &guid.Data4[6], &guid.Data4[7]) | ||
return | ||
} | ||
|
||
func GenerateBytes() (data []byte, err error) { | ||
|
||
data = make([]byte, 16) | ||
_, err = rand.Read(data) | ||
return | ||
} | ||
|
||
func Generate() (guid GUID, err error) { | ||
data, err := GenerateBytes() | ||
if err != nil { | ||
return | ||
} | ||
guid, err = FromBytes(data) | ||
return | ||
} | ||
|
||
func (data GUID) ToByte() (output []byte, err error) { | ||
|
||
buf := new(bytes.Buffer) | ||
err = binary.Write(buf, binary.LittleEndian, data) | ||
if err != nil { | ||
return | ||
} | ||
output = buf.Bytes() | ||
return | ||
} | ||
func FromBytes(data []byte) (guid GUID, err error) { | ||
|
||
buf := bytes.NewReader(data) | ||
err = binary.Read(buf, binary.LittleEndian, &guid) | ||
return | ||
} |
Oops, something went wrong.