Skip to content

Commit f4afa9d

Browse files
author
Didier Gehéniau
committed
Refactoring for Maintainability and further development
1 parent a377121 commit f4afa9d

File tree

140 files changed

+11782
-11076
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+11782
-11076
lines changed

AUTHORS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Carl Kittelberger <[email protected]>
1919
Carlos Cobo <[email protected]>
2020
Cary Cherng <[email protected]>
2121
Cory Redmond <[email protected]>
22+
D4v1dW3bb
2223
David Porter <[email protected]>
2324
Dmitry Bagdanov <[email protected]>
2425
gonutz
@@ -32,3 +33,4 @@ ryujimiya <[email protected]>
3233
Simon Rozman <[email protected]>
3334
Tiago Carvalho <[email protected]>
3435
36+

README.mdown

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
About win
22
=========
33

4-
win is a Windows API wrapper package for Go.
4+
winapi is a Windows API wrapper package for Go.
5+
It's a refactored version of the gitcom repository [win](https://github.com/lxn/win)
56

6-
Originally part of [walk](https://github.com/lxn/walk), it is now a separate
7-
project.
87

98
Setup
109
=====
1110

1211
Make sure you have a working Go installation.
1312
See [Getting Started](http://golang.org/doc/install.html)
1413

15-
Now run `go get github.com/lxn/win`
14+
Now run `go get github.com/D4v1dW3bb/winapi`

advapi32.go

Lines changed: 0 additions & 137 deletions
This file was deleted.

advapi32/advapi32_const.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright 2010 The win Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// +build windows
6+
7+
package advapi32
8+
9+
// Button control messages
10+
const KEY_READ REGSAM = 0x20019
11+
const KEY_WRITE REGSAM = 0x20006
12+
13+
const (
14+
HKEY_CLASSES_ROOT HKEY = 0x80000000
15+
HKEY_CURRENT_USER HKEY = 0x80000001
16+
HKEY_LOCAL_MACHINE HKEY = 0x80000002
17+
HKEY_USERS HKEY = 0x80000003
18+
HKEY_PERFORMANCE_DATA HKEY = 0x80000004
19+
HKEY_CURRENT_CONFIG HKEY = 0x80000005
20+
HKEY_DYN_DATA HKEY = 0x80000006
21+
)
22+
23+
const (
24+
ERROR_NO_MORE_ITEMS = 259
25+
)
26+
27+
const (
28+
REG_NONE uint64 = 0 // No value type
29+
REG_SZ = 1 // Unicode nul terminated string
30+
REG_EXPAND_SZ = 2 // Unicode nul terminated string
31+
32+
// (with environment variable references)
33+
REG_BINARY = 3 // Free form binary
34+
REG_DWORD = 4 // 32-bit number
35+
REG_DWORD_LITTLE_ENDIAN = 4 // 32-bit number (same as REG_DWORD)
36+
REG_DWORD_BIG_ENDIAN = 5 // 32-bit number
37+
REG_LINK = 6 // Symbolic Link (unicode)
38+
REG_MULTI_SZ = 7 // Multiple Unicode strings
39+
REG_RESOURCE_LIST = 8 // Resource list in the resource map
40+
REG_FULL_RESOURCE_DESCRIPTOR = 9 // Resource list in the hardware description
41+
REG_RESOURCE_REQUIREMENTS_LIST = 10
42+
REG_QWORD = 11 // 64-bit number
43+
REG_QWORD_LITTLE_ENDIAN = 11 // 64-bit number (same as REG_QWORD)
44+
45+
)

advapi32/advapi32_func.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright 2010 The win Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// +build windows
6+
7+
package advapi32
8+
9+
import (
10+
"syscall"
11+
"unsafe"
12+
)
13+
14+
func RegCloseKey(hKey HKEY) int32 {
15+
ret, _, _ := syscall.Syscall(regCloseKey.Addr(), 1,
16+
uintptr(hKey),
17+
0,
18+
0)
19+
20+
return int32(ret)
21+
}
22+
23+
func RegOpenKeyEx(hKey HKEY, lpSubKey *uint16, ulOptions uint32, samDesired REGSAM, phkResult *HKEY) int32 {
24+
ret, _, _ := syscall.Syscall6(regOpenKeyEx.Addr(), 5,
25+
uintptr(hKey),
26+
uintptr(unsafe.Pointer(lpSubKey)),
27+
uintptr(ulOptions),
28+
uintptr(samDesired),
29+
uintptr(unsafe.Pointer(phkResult)),
30+
0)
31+
32+
return int32(ret)
33+
}
34+
35+
func RegQueryValueEx(hKey HKEY, lpValueName *uint16, lpReserved, lpType *uint32, lpData *byte, lpcbData *uint32) int32 {
36+
ret, _, _ := syscall.Syscall6(regQueryValueEx.Addr(), 6,
37+
uintptr(hKey),
38+
uintptr(unsafe.Pointer(lpValueName)),
39+
uintptr(unsafe.Pointer(lpReserved)),
40+
uintptr(unsafe.Pointer(lpType)),
41+
uintptr(unsafe.Pointer(lpData)),
42+
uintptr(unsafe.Pointer(lpcbData)))
43+
44+
return int32(ret)
45+
}
46+
47+
func RegEnumValue(hKey HKEY, index uint32, lpValueName *uint16, lpcchValueName *uint32, lpReserved, lpType *uint32, lpData *byte, lpcbData *uint32) int32 {
48+
ret, _, _ := syscall.Syscall9(regEnumValue.Addr(), 8,
49+
uintptr(hKey),
50+
uintptr(index),
51+
uintptr(unsafe.Pointer(lpValueName)),
52+
uintptr(unsafe.Pointer(lpcchValueName)),
53+
uintptr(unsafe.Pointer(lpReserved)),
54+
uintptr(unsafe.Pointer(lpType)),
55+
uintptr(unsafe.Pointer(lpData)),
56+
uintptr(unsafe.Pointer(lpcbData)),
57+
0)
58+
return int32(ret)
59+
}
60+
61+
func RegSetValueEx(hKey HKEY, lpValueName *uint16, lpReserved, lpDataType uint64, lpData *byte, cbData uint32) int32 {
62+
ret, _, _ := syscall.Syscall6(regSetValueEx.Addr(), 6,
63+
uintptr(hKey),
64+
uintptr(unsafe.Pointer(lpValueName)),
65+
uintptr(lpReserved),
66+
uintptr(lpDataType),
67+
uintptr(unsafe.Pointer(lpData)),
68+
uintptr(cbData))
69+
return int32(ret)
70+
}

advapi32/advapi32_main.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2010 The win Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// +build windows
6+
7+
package advapi32
8+
9+
import "golang.org/x/sys/windows"
10+
11+
var (
12+
// Library
13+
libadvapi32 *windows.LazyDLL
14+
15+
// Functions
16+
regCloseKey *windows.LazyProc
17+
regOpenKeyEx *windows.LazyProc
18+
regQueryValueEx *windows.LazyProc
19+
regEnumValue *windows.LazyProc
20+
regSetValueEx *windows.LazyProc
21+
)
22+
23+
func init() {
24+
// Library
25+
libadvapi32 = windows.NewLazySystemDLL("advapi32.dll")
26+
27+
// Functions
28+
regCloseKey = libadvapi32.NewProc("RegCloseKey")
29+
regOpenKeyEx = libadvapi32.NewProc("RegOpenKeyExW")
30+
regQueryValueEx = libadvapi32.NewProc("RegQueryValueExW")
31+
regEnumValue = libadvapi32.NewProc("RegEnumValueW")
32+
regSetValueEx = libadvapi32.NewProc("RegSetValueExW")
33+
}

advapi32/advapi32_type.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2010 The win Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// +build windows
6+
7+
package advapi32
8+
9+
import "github.com/D4v1dW3bb/winapi/handle"
10+
11+
type (
12+
ACCESS_MASK uint32
13+
HKEY handle.HANDLE
14+
REGSAM ACCESS_MASK
15+
)

0 commit comments

Comments
 (0)