Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
ef65feda
Commit
ef65feda
authored
Dec 08, 2011
by
Alex Brainman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
syscall: return error, not uintptr, when function returns error
R=rsc CC=golang-dev
https://golang.org/cl/5450119
parent
2fa987b6
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
193 additions
and
172 deletions
+193
-172
src/pkg/exp/wingui/gui.go
src/pkg/exp/wingui/gui.go
+14
-13
src/pkg/exp/wingui/winapi.go
src/pkg/exp/wingui/winapi.go
+10
-10
src/pkg/exp/wingui/zwinapi.go
src/pkg/exp/wingui/zwinapi.go
+30
-50
src/pkg/mime/type_windows.go
src/pkg/mime/type_windows.go
+5
-5
src/pkg/net/fd_windows.go
src/pkg/net/fd_windows.go
+2
-2
src/pkg/net/interface_windows.go
src/pkg/net/interface_windows.go
+2
-2
src/pkg/net/lookup_windows.go
src/pkg/net/lookup_windows.go
+5
-5
src/pkg/syscall/dll_windows.go
src/pkg/syscall/dll_windows.go
+0
-15
src/pkg/syscall/mksyscall_windows.pl
src/pkg/syscall/mksyscall_windows.pl
+5
-0
src/pkg/syscall/syscall_windows.go
src/pkg/syscall/syscall_windows.go
+40
-30
src/pkg/syscall/zsyscall_windows_386.go
src/pkg/syscall/zsyscall_windows_386.go
+40
-20
src/pkg/syscall/zsyscall_windows_amd64.go
src/pkg/syscall/zsyscall_windows_amd64.go
+40
-20
No files found.
src/pkg/exp/wingui/gui.go
View file @
ef65feda
...
@@ -18,8 +18,9 @@ func abortf(format string, a ...interface{}) {
...
@@ -18,8 +18,9 @@ func abortf(format string, a ...interface{}) {
os
.
Exit
(
1
)
os
.
Exit
(
1
)
}
}
func
abortErrNo
(
funcname
string
,
err
int
)
{
func
abortErrNo
(
funcname
string
,
err
error
)
{
abortf
(
"%s failed: %d %s
\n
"
,
funcname
,
err
,
syscall
.
Errstr
(
err
))
errno
,
_
:=
err
.
(
syscall
.
Errno
)
abortf
(
"%s failed: %d %s
\n
"
,
funcname
,
uint32
(
errno
),
err
)
}
}
// global vars
// global vars
...
@@ -33,7 +34,7 @@ var (
...
@@ -33,7 +34,7 @@ var (
func
WndProc
(
hwnd
syscall
.
Handle
,
msg
uint32
,
wparam
,
lparam
uintptr
)
(
rc
uintptr
)
{
func
WndProc
(
hwnd
syscall
.
Handle
,
msg
uint32
,
wparam
,
lparam
uintptr
)
(
rc
uintptr
)
{
switch
msg
{
switch
msg
{
case
WM_CREATE
:
case
WM_CREATE
:
var
e
int
var
e
error
// CreateWindowEx
// CreateWindowEx
bh
,
e
=
CreateWindowEx
(
bh
,
e
=
CreateWindowEx
(
0
,
0
,
...
@@ -42,7 +43,7 @@ func WndProc(hwnd syscall.Handle, msg uint32, wparam, lparam uintptr) (rc uintpt
...
@@ -42,7 +43,7 @@ func WndProc(hwnd syscall.Handle, msg uint32, wparam, lparam uintptr) (rc uintpt
WS_CHILD
|
WS_VISIBLE
|
BS_DEFPUSHBUTTON
,
WS_CHILD
|
WS_VISIBLE
|
BS_DEFPUSHBUTTON
,
75
,
70
,
140
,
25
,
75
,
70
,
140
,
25
,
hwnd
,
1
,
mh
,
0
)
hwnd
,
1
,
mh
,
0
)
if
e
!=
0
{
if
e
!=
nil
{
abortErrNo
(
"CreateWindowEx"
,
e
)
abortErrNo
(
"CreateWindowEx"
,
e
)
}
}
fmt
.
Printf
(
"button handle is %x
\n
"
,
bh
)
fmt
.
Printf
(
"button handle is %x
\n
"
,
bh
)
...
@@ -51,7 +52,7 @@ func WndProc(hwnd syscall.Handle, msg uint32, wparam, lparam uintptr) (rc uintpt
...
@@ -51,7 +52,7 @@ func WndProc(hwnd syscall.Handle, msg uint32, wparam, lparam uintptr) (rc uintpt
switch
syscall
.
Handle
(
lparam
)
{
switch
syscall
.
Handle
(
lparam
)
{
case
bh
:
case
bh
:
e
:=
PostMessage
(
hwnd
,
WM_CLOSE
,
0
,
0
)
e
:=
PostMessage
(
hwnd
,
WM_CLOSE
,
0
,
0
)
if
e
!=
0
{
if
e
!=
nil
{
abortErrNo
(
"PostMessage"
,
e
)
abortErrNo
(
"PostMessage"
,
e
)
}
}
default
:
default
:
...
@@ -69,23 +70,23 @@ func WndProc(hwnd syscall.Handle, msg uint32, wparam, lparam uintptr) (rc uintpt
...
@@ -69,23 +70,23 @@ func WndProc(hwnd syscall.Handle, msg uint32, wparam, lparam uintptr) (rc uintpt
}
}
func
rungui
()
int
{
func
rungui
()
int
{
var
e
int
var
e
error
// GetModuleHandle
// GetModuleHandle
mh
,
e
=
GetModuleHandle
(
nil
)
mh
,
e
=
GetModuleHandle
(
nil
)
if
e
!=
0
{
if
e
!=
nil
{
abortErrNo
(
"GetModuleHandle"
,
e
)
abortErrNo
(
"GetModuleHandle"
,
e
)
}
}
// Get icon we're going to use.
// Get icon we're going to use.
myicon
,
e
:=
LoadIcon
(
0
,
IDI_APPLICATION
)
myicon
,
e
:=
LoadIcon
(
0
,
IDI_APPLICATION
)
if
e
!=
0
{
if
e
!=
nil
{
abortErrNo
(
"LoadIcon"
,
e
)
abortErrNo
(
"LoadIcon"
,
e
)
}
}
// Get cursor we're going to use.
// Get cursor we're going to use.
mycursor
,
e
:=
LoadCursor
(
0
,
IDC_ARROW
)
mycursor
,
e
:=
LoadCursor
(
0
,
IDC_ARROW
)
if
e
!=
0
{
if
e
!=
nil
{
abortErrNo
(
"LoadCursor"
,
e
)
abortErrNo
(
"LoadCursor"
,
e
)
}
}
...
@@ -104,7 +105,7 @@ func rungui() int {
...
@@ -104,7 +105,7 @@ func rungui() int {
wc
.
MenuName
=
nil
wc
.
MenuName
=
nil
wc
.
ClassName
=
wcname
wc
.
ClassName
=
wcname
wc
.
IconSm
=
myicon
wc
.
IconSm
=
myicon
if
_
,
e
:=
RegisterClassEx
(
&
wc
);
e
!=
0
{
if
_
,
e
:=
RegisterClassEx
(
&
wc
);
e
!=
nil
{
abortErrNo
(
"RegisterClassEx"
,
e
)
abortErrNo
(
"RegisterClassEx"
,
e
)
}
}
...
@@ -116,7 +117,7 @@ func rungui() int {
...
@@ -116,7 +117,7 @@ func rungui() int {
WS_OVERLAPPEDWINDOW
,
WS_OVERLAPPEDWINDOW
,
CW_USEDEFAULT
,
CW_USEDEFAULT
,
300
,
200
,
CW_USEDEFAULT
,
CW_USEDEFAULT
,
300
,
200
,
0
,
0
,
mh
,
0
)
0
,
0
,
mh
,
0
)
if
e
!=
0
{
if
e
!=
nil
{
abortErrNo
(
"CreateWindowEx"
,
e
)
abortErrNo
(
"CreateWindowEx"
,
e
)
}
}
fmt
.
Printf
(
"main window handle is %x
\n
"
,
wh
)
fmt
.
Printf
(
"main window handle is %x
\n
"
,
wh
)
...
@@ -125,7 +126,7 @@ func rungui() int {
...
@@ -125,7 +126,7 @@ func rungui() int {
ShowWindow
(
wh
,
SW_SHOWDEFAULT
)
ShowWindow
(
wh
,
SW_SHOWDEFAULT
)
// UpdateWindow
// UpdateWindow
if
e
:=
UpdateWindow
(
wh
);
e
!=
0
{
if
e
:=
UpdateWindow
(
wh
);
e
!=
nil
{
abortErrNo
(
"UpdateWindow"
,
e
)
abortErrNo
(
"UpdateWindow"
,
e
)
}
}
...
@@ -133,7 +134,7 @@ func rungui() int {
...
@@ -133,7 +134,7 @@ func rungui() int {
var
m
Msg
var
m
Msg
for
{
for
{
r
,
e
:=
GetMessage
(
&
m
,
0
,
0
,
0
)
r
,
e
:=
GetMessage
(
&
m
,
0
,
0
,
0
)
if
e
!=
0
{
if
e
!=
nil
{
abortErrNo
(
"GetMessage"
,
e
)
abortErrNo
(
"GetMessage"
,
e
)
}
}
if
r
==
0
{
if
r
==
0
{
...
...
src/pkg/exp/wingui/winapi.go
View file @
ef65feda
...
@@ -110,22 +110,22 @@ var (
...
@@ -110,22 +110,22 @@ var (
IDI_INFORMATION
=
IDI_ASTERISK
IDI_INFORMATION
=
IDI_ASTERISK
)
)
//sys GetModuleHandle(modname *uint16) (handle syscall.Handle, err
no int
) = GetModuleHandleW
//sys GetModuleHandle(modname *uint16) (handle syscall.Handle, err
error
) = GetModuleHandleW
//sys RegisterClassEx(wndclass *Wndclassex) (atom uint16, err
no int
) = user32.RegisterClassExW
//sys RegisterClassEx(wndclass *Wndclassex) (atom uint16, err
error
) = user32.RegisterClassExW
//sys CreateWindowEx(exstyle uint32, classname *uint16, windowname *uint16, style uint32, x int32, y int32, width int32, height int32, wndparent syscall.Handle, menu syscall.Handle, instance syscall.Handle, param uintptr) (hwnd syscall.Handle, err
no int
) = user32.CreateWindowExW
//sys CreateWindowEx(exstyle uint32, classname *uint16, windowname *uint16, style uint32, x int32, y int32, width int32, height int32, wndparent syscall.Handle, menu syscall.Handle, instance syscall.Handle, param uintptr) (hwnd syscall.Handle, err
error
) = user32.CreateWindowExW
//sys DefWindowProc(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr) (lresult uintptr) = user32.DefWindowProcW
//sys DefWindowProc(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr) (lresult uintptr) = user32.DefWindowProcW
//sys DestroyWindow(hwnd syscall.Handle) (err
no int
) = user32.DestroyWindow
//sys DestroyWindow(hwnd syscall.Handle) (err
error
) = user32.DestroyWindow
//sys PostQuitMessage(exitcode int32) = user32.PostQuitMessage
//sys PostQuitMessage(exitcode int32) = user32.PostQuitMessage
//sys ShowWindow(hwnd syscall.Handle, cmdshow int32) (wasvisible bool) = user32.ShowWindow
//sys ShowWindow(hwnd syscall.Handle, cmdshow int32) (wasvisible bool) = user32.ShowWindow
//sys UpdateWindow(hwnd syscall.Handle) (err
no int
) = user32.UpdateWindow
//sys UpdateWindow(hwnd syscall.Handle) (err
error
) = user32.UpdateWindow
//sys GetMessage(msg *Msg, hwnd syscall.Handle, MsgFilterMin uint32, MsgFilterMax uint32) (ret int32, err
no int
) [failretval==-1] = user32.GetMessageW
//sys GetMessage(msg *Msg, hwnd syscall.Handle, MsgFilterMin uint32, MsgFilterMax uint32) (ret int32, err
error
) [failretval==-1] = user32.GetMessageW
//sys TranslateMessage(msg *Msg) (done bool) = user32.TranslateMessage
//sys TranslateMessage(msg *Msg) (done bool) = user32.TranslateMessage
//sys DispatchMessage(msg *Msg) (ret int32) = user32.DispatchMessageW
//sys DispatchMessage(msg *Msg) (ret int32) = user32.DispatchMessageW
//sys LoadIcon(instance syscall.Handle, iconname *uint16) (icon syscall.Handle, err
no int
) = user32.LoadIconW
//sys LoadIcon(instance syscall.Handle, iconname *uint16) (icon syscall.Handle, err
error
) = user32.LoadIconW
//sys LoadCursor(instance syscall.Handle, cursorname *uint16) (cursor syscall.Handle, err
no int
) = user32.LoadCursorW
//sys LoadCursor(instance syscall.Handle, cursorname *uint16) (cursor syscall.Handle, err
error
) = user32.LoadCursorW
//sys SetCursor(cursor syscall.Handle) (precursor syscall.Handle, err
no int
) = user32.SetCursor
//sys SetCursor(cursor syscall.Handle) (precursor syscall.Handle, err
error
) = user32.SetCursor
//sys SendMessage(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr) (lresult uintptr) = user32.SendMessageW
//sys SendMessage(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr) (lresult uintptr) = user32.SendMessageW
//sys PostMessage(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr) (err
no int
) = user32.PostMessageW
//sys PostMessage(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr) (err
error
) = user32.PostMessageW
func
MakeIntResource
(
id
uint16
)
*
uint16
{
func
MakeIntResource
(
id
uint16
)
*
uint16
{
return
(
*
uint16
)(
unsafe
.
Pointer
(
uintptr
(
id
)))
return
(
*
uint16
)(
unsafe
.
Pointer
(
uintptr
(
id
)))
...
...
src/pkg/exp/wingui/zwinapi.go
View file @
ef65feda
...
@@ -28,47 +28,41 @@ var (
...
@@ -28,47 +28,41 @@ var (
procPostMessageW
=
moduser32
.
NewProc
(
"PostMessageW"
)
procPostMessageW
=
moduser32
.
NewProc
(
"PostMessageW"
)
)
)
func
GetModuleHandle
(
modname
*
uint16
)
(
handle
syscall
.
Handle
,
err
no
int
)
{
func
GetModuleHandle
(
modname
*
uint16
)
(
handle
syscall
.
Handle
,
err
error
)
{
r0
,
_
,
e1
:=
syscall
.
Syscall
(
procGetModuleHandleW
.
Addr
(),
1
,
uintptr
(
unsafe
.
Pointer
(
modname
)),
0
,
0
)
r0
,
_
,
e1
:=
syscall
.
Syscall
(
procGetModuleHandleW
.
Addr
(),
1
,
uintptr
(
unsafe
.
Pointer
(
modname
)),
0
,
0
)
handle
=
syscall
.
Handle
(
r0
)
handle
=
syscall
.
Handle
(
r0
)
if
handle
==
0
{
if
handle
==
0
{
if
e1
!=
0
{
if
e1
!=
0
{
err
no
=
int
(
e1
)
err
=
error
(
e1
)
}
else
{
}
else
{
err
no
=
syscall
.
EINVAL
err
=
syscall
.
EINVAL
}
}
}
else
{
errno
=
0
}
}
return
return
}
}
func
RegisterClassEx
(
wndclass
*
Wndclassex
)
(
atom
uint16
,
err
no
int
)
{
func
RegisterClassEx
(
wndclass
*
Wndclassex
)
(
atom
uint16
,
err
error
)
{
r0
,
_
,
e1
:=
syscall
.
Syscall
(
procRegisterClassExW
.
Addr
(),
1
,
uintptr
(
unsafe
.
Pointer
(
wndclass
)),
0
,
0
)
r0
,
_
,
e1
:=
syscall
.
Syscall
(
procRegisterClassExW
.
Addr
(),
1
,
uintptr
(
unsafe
.
Pointer
(
wndclass
)),
0
,
0
)
atom
=
uint16
(
r0
)
atom
=
uint16
(
r0
)
if
atom
==
0
{
if
atom
==
0
{
if
e1
!=
0
{
if
e1
!=
0
{
err
no
=
int
(
e1
)
err
=
error
(
e1
)
}
else
{
}
else
{
err
no
=
syscall
.
EINVAL
err
=
syscall
.
EINVAL
}
}
}
else
{
errno
=
0
}
}
return
return
}
}
func
CreateWindowEx
(
exstyle
uint32
,
classname
*
uint16
,
windowname
*
uint16
,
style
uint32
,
x
int32
,
y
int32
,
width
int32
,
height
int32
,
wndparent
syscall
.
Handle
,
menu
syscall
.
Handle
,
instance
syscall
.
Handle
,
param
uintptr
)
(
hwnd
syscall
.
Handle
,
err
no
int
)
{
func
CreateWindowEx
(
exstyle
uint32
,
classname
*
uint16
,
windowname
*
uint16
,
style
uint32
,
x
int32
,
y
int32
,
width
int32
,
height
int32
,
wndparent
syscall
.
Handle
,
menu
syscall
.
Handle
,
instance
syscall
.
Handle
,
param
uintptr
)
(
hwnd
syscall
.
Handle
,
err
error
)
{
r0
,
_
,
e1
:=
syscall
.
Syscall12
(
procCreateWindowExW
.
Addr
(),
12
,
uintptr
(
exstyle
),
uintptr
(
unsafe
.
Pointer
(
classname
)),
uintptr
(
unsafe
.
Pointer
(
windowname
)),
uintptr
(
style
),
uintptr
(
x
),
uintptr
(
y
),
uintptr
(
width
),
uintptr
(
height
),
uintptr
(
wndparent
),
uintptr
(
menu
),
uintptr
(
instance
),
uintptr
(
param
))
r0
,
_
,
e1
:=
syscall
.
Syscall12
(
procCreateWindowExW
.
Addr
(),
12
,
uintptr
(
exstyle
),
uintptr
(
unsafe
.
Pointer
(
classname
)),
uintptr
(
unsafe
.
Pointer
(
windowname
)),
uintptr
(
style
),
uintptr
(
x
),
uintptr
(
y
),
uintptr
(
width
),
uintptr
(
height
),
uintptr
(
wndparent
),
uintptr
(
menu
),
uintptr
(
instance
),
uintptr
(
param
))
hwnd
=
syscall
.
Handle
(
r0
)
hwnd
=
syscall
.
Handle
(
r0
)
if
hwnd
==
0
{
if
hwnd
==
0
{
if
e1
!=
0
{
if
e1
!=
0
{
err
no
=
int
(
e1
)
err
=
error
(
e1
)
}
else
{
}
else
{
err
no
=
syscall
.
EINVAL
err
=
syscall
.
EINVAL
}
}
}
else
{
errno
=
0
}
}
return
return
}
}
...
@@ -79,16 +73,14 @@ func DefWindowProc(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintp
...
@@ -79,16 +73,14 @@ func DefWindowProc(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintp
return
return
}
}
func
DestroyWindow
(
hwnd
syscall
.
Handle
)
(
err
no
int
)
{
func
DestroyWindow
(
hwnd
syscall
.
Handle
)
(
err
error
)
{
r1
,
_
,
e1
:=
syscall
.
Syscall
(
procDestroyWindow
.
Addr
(),
1
,
uintptr
(
hwnd
),
0
,
0
)
r1
,
_
,
e1
:=
syscall
.
Syscall
(
procDestroyWindow
.
Addr
(),
1
,
uintptr
(
hwnd
),
0
,
0
)
if
int
(
r1
)
==
0
{
if
int
(
r1
)
==
0
{
if
e1
!=
0
{
if
e1
!=
0
{
err
no
=
int
(
e1
)
err
=
error
(
e1
)
}
else
{
}
else
{
err
no
=
syscall
.
EINVAL
err
=
syscall
.
EINVAL
}
}
}
else
{
errno
=
0
}
}
return
return
}
}
...
@@ -104,31 +96,27 @@ func ShowWindow(hwnd syscall.Handle, cmdshow int32) (wasvisible bool) {
...
@@ -104,31 +96,27 @@ func ShowWindow(hwnd syscall.Handle, cmdshow int32) (wasvisible bool) {
return
return
}
}
func
UpdateWindow
(
hwnd
syscall
.
Handle
)
(
err
no
int
)
{
func
UpdateWindow
(
hwnd
syscall
.
Handle
)
(
err
error
)
{
r1
,
_
,
e1
:=
syscall
.
Syscall
(
procUpdateWindow
.
Addr
(),
1
,
uintptr
(
hwnd
),
0
,
0
)
r1
,
_
,
e1
:=
syscall
.
Syscall
(
procUpdateWindow
.
Addr
(),
1
,
uintptr
(
hwnd
),
0
,
0
)
if
int
(
r1
)
==
0
{
if
int
(
r1
)
==
0
{
if
e1
!=
0
{
if
e1
!=
0
{
err
no
=
int
(
e1
)
err
=
error
(
e1
)
}
else
{
}
else
{
err
no
=
syscall
.
EINVAL
err
=
syscall
.
EINVAL
}
}
}
else
{
errno
=
0
}
}
return
return
}
}
func
GetMessage
(
msg
*
Msg
,
hwnd
syscall
.
Handle
,
MsgFilterMin
uint32
,
MsgFilterMax
uint32
)
(
ret
int32
,
err
no
int
)
{
func
GetMessage
(
msg
*
Msg
,
hwnd
syscall
.
Handle
,
MsgFilterMin
uint32
,
MsgFilterMax
uint32
)
(
ret
int32
,
err
error
)
{
r0
,
_
,
e1
:=
syscall
.
Syscall6
(
procGetMessageW
.
Addr
(),
4
,
uintptr
(
unsafe
.
Pointer
(
msg
)),
uintptr
(
hwnd
),
uintptr
(
MsgFilterMin
),
uintptr
(
MsgFilterMax
),
0
,
0
)
r0
,
_
,
e1
:=
syscall
.
Syscall6
(
procGetMessageW
.
Addr
(),
4
,
uintptr
(
unsafe
.
Pointer
(
msg
)),
uintptr
(
hwnd
),
uintptr
(
MsgFilterMin
),
uintptr
(
MsgFilterMax
),
0
,
0
)
ret
=
int32
(
r0
)
ret
=
int32
(
r0
)
if
ret
==
-
1
{
if
ret
==
-
1
{
if
e1
!=
0
{
if
e1
!=
0
{
err
no
=
int
(
e1
)
err
=
error
(
e1
)
}
else
{
}
else
{
err
no
=
syscall
.
EINVAL
err
=
syscall
.
EINVAL
}
}
}
else
{
errno
=
0
}
}
return
return
}
}
...
@@ -145,47 +133,41 @@ func DispatchMessage(msg *Msg) (ret int32) {
...
@@ -145,47 +133,41 @@ func DispatchMessage(msg *Msg) (ret int32) {
return
return
}
}
func
LoadIcon
(
instance
syscall
.
Handle
,
iconname
*
uint16
)
(
icon
syscall
.
Handle
,
err
no
int
)
{
func
LoadIcon
(
instance
syscall
.
Handle
,
iconname
*
uint16
)
(
icon
syscall
.
Handle
,
err
error
)
{
r0
,
_
,
e1
:=
syscall
.
Syscall
(
procLoadIconW
.
Addr
(),
2
,
uintptr
(
instance
),
uintptr
(
unsafe
.
Pointer
(
iconname
)),
0
)
r0
,
_
,
e1
:=
syscall
.
Syscall
(
procLoadIconW
.
Addr
(),
2
,
uintptr
(
instance
),
uintptr
(
unsafe
.
Pointer
(
iconname
)),
0
)
icon
=
syscall
.
Handle
(
r0
)
icon
=
syscall
.
Handle
(
r0
)
if
icon
==
0
{
if
icon
==
0
{
if
e1
!=
0
{
if
e1
!=
0
{
err
no
=
int
(
e1
)
err
=
error
(
e1
)
}
else
{
}
else
{
err
no
=
syscall
.
EINVAL
err
=
syscall
.
EINVAL
}
}
}
else
{
errno
=
0
}
}
return
return
}
}
func
LoadCursor
(
instance
syscall
.
Handle
,
cursorname
*
uint16
)
(
cursor
syscall
.
Handle
,
err
no
int
)
{
func
LoadCursor
(
instance
syscall
.
Handle
,
cursorname
*
uint16
)
(
cursor
syscall
.
Handle
,
err
error
)
{
r0
,
_
,
e1
:=
syscall
.
Syscall
(
procLoadCursorW
.
Addr
(),
2
,
uintptr
(
instance
),
uintptr
(
unsafe
.
Pointer
(
cursorname
)),
0
)
r0
,
_
,
e1
:=
syscall
.
Syscall
(
procLoadCursorW
.
Addr
(),
2
,
uintptr
(
instance
),
uintptr
(
unsafe
.
Pointer
(
cursorname
)),
0
)
cursor
=
syscall
.
Handle
(
r0
)
cursor
=
syscall
.
Handle
(
r0
)
if
cursor
==
0
{
if
cursor
==
0
{
if
e1
!=
0
{
if
e1
!=
0
{
err
no
=
int
(
e1
)
err
=
error
(
e1
)
}
else
{
}
else
{
err
no
=
syscall
.
EINVAL
err
=
syscall
.
EINVAL
}
}
}
else
{
errno
=
0
}
}
return
return
}
}
func
SetCursor
(
cursor
syscall
.
Handle
)
(
precursor
syscall
.
Handle
,
err
no
int
)
{
func
SetCursor
(
cursor
syscall
.
Handle
)
(
precursor
syscall
.
Handle
,
err
error
)
{
r0
,
_
,
e1
:=
syscall
.
Syscall
(
procSetCursor
.
Addr
(),
1
,
uintptr
(
cursor
),
0
,
0
)
r0
,
_
,
e1
:=
syscall
.
Syscall
(
procSetCursor
.
Addr
(),
1
,
uintptr
(
cursor
),
0
,
0
)
precursor
=
syscall
.
Handle
(
r0
)
precursor
=
syscall
.
Handle
(
r0
)
if
precursor
==
0
{
if
precursor
==
0
{
if
e1
!=
0
{
if
e1
!=
0
{
err
no
=
int
(
e1
)
err
=
error
(
e1
)
}
else
{
}
else
{
err
no
=
syscall
.
EINVAL
err
=
syscall
.
EINVAL
}
}
}
else
{
errno
=
0
}
}
return
return
}
}
...
@@ -196,16 +178,14 @@ func SendMessage(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr
...
@@ -196,16 +178,14 @@ func SendMessage(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr
return
return
}
}
func
PostMessage
(
hwnd
syscall
.
Handle
,
msg
uint32
,
wparam
uintptr
,
lparam
uintptr
)
(
err
no
int
)
{
func
PostMessage
(
hwnd
syscall
.
Handle
,
msg
uint32
,
wparam
uintptr
,
lparam
uintptr
)
(
err
error
)
{
r1
,
_
,
e1
:=
syscall
.
Syscall6
(
procPostMessageW
.
Addr
(),
4
,
uintptr
(
hwnd
),
uintptr
(
msg
),
uintptr
(
wparam
),
uintptr
(
lparam
),
0
,
0
)
r1
,
_
,
e1
:=
syscall
.
Syscall6
(
procPostMessageW
.
Addr
(),
4
,
uintptr
(
hwnd
),
uintptr
(
msg
),
uintptr
(
wparam
),
uintptr
(
lparam
),
0
,
0
)
if
int
(
r1
)
==
0
{
if
int
(
r1
)
==
0
{
if
e1
!=
0
{
if
e1
!=
0
{
err
no
=
int
(
e1
)
err
=
error
(
e1
)
}
else
{
}
else
{
err
no
=
syscall
.
EINVAL
err
=
syscall
.
EINVAL
}
}
}
else
{
errno
=
0
}
}
return
return
}
}
src/pkg/mime/type_windows.go
View file @
ef65feda
...
@@ -12,18 +12,18 @@ import (
...
@@ -12,18 +12,18 @@ import (
func
initMime
()
{
func
initMime
()
{
var
root
syscall
.
Handle
var
root
syscall
.
Handle
if
syscall
.
RegOpenKeyEx
(
syscall
.
HKEY_CLASSES_ROOT
,
syscall
.
StringToUTF16Ptr
(
`\`
),
if
syscall
.
RegOpenKeyEx
(
syscall
.
HKEY_CLASSES_ROOT
,
syscall
.
StringToUTF16Ptr
(
`\`
),
0
,
syscall
.
KEY_READ
,
&
root
)
!=
0
{
0
,
syscall
.
KEY_READ
,
&
root
)
!=
nil
{
return
return
}
}
defer
syscall
.
RegCloseKey
(
root
)
defer
syscall
.
RegCloseKey
(
root
)
var
count
uint32
var
count
uint32
if
syscall
.
RegQueryInfoKey
(
root
,
nil
,
nil
,
nil
,
&
count
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
)
!=
0
{
if
syscall
.
RegQueryInfoKey
(
root
,
nil
,
nil
,
nil
,
&
count
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
)
!=
nil
{
return
return
}
}
var
buf
[
1
<<
10
]
uint16
var
buf
[
1
<<
10
]
uint16
for
i
:=
uint32
(
0
);
i
<
count
;
i
++
{
for
i
:=
uint32
(
0
);
i
<
count
;
i
++
{
n
:=
uint32
(
len
(
buf
))
n
:=
uint32
(
len
(
buf
))
if
syscall
.
RegEnumKeyEx
(
root
,
i
,
&
buf
[
0
],
&
n
,
nil
,
nil
,
nil
,
nil
)
!=
0
{
if
syscall
.
RegEnumKeyEx
(
root
,
i
,
&
buf
[
0
],
&
n
,
nil
,
nil
,
nil
,
nil
)
!=
nil
{
continue
continue
}
}
ext
:=
syscall
.
UTF16ToString
(
buf
[
:
])
ext
:=
syscall
.
UTF16ToString
(
buf
[
:
])
...
@@ -33,14 +33,14 @@ func initMime() {
...
@@ -33,14 +33,14 @@ func initMime() {
var
h
syscall
.
Handle
var
h
syscall
.
Handle
if
syscall
.
RegOpenKeyEx
(
if
syscall
.
RegOpenKeyEx
(
syscall
.
HKEY_CLASSES_ROOT
,
syscall
.
StringToUTF16Ptr
(
`\`
+
ext
),
syscall
.
HKEY_CLASSES_ROOT
,
syscall
.
StringToUTF16Ptr
(
`\`
+
ext
),
0
,
syscall
.
KEY_READ
,
&
h
)
!=
0
{
0
,
syscall
.
KEY_READ
,
&
h
)
!=
nil
{
continue
continue
}
}
var
typ
uint32
var
typ
uint32
n
=
uint32
(
len
(
buf
)
*
2
)
// api expects array of bytes, not uint16
n
=
uint32
(
len
(
buf
)
*
2
)
// api expects array of bytes, not uint16
if
syscall
.
RegQueryValueEx
(
if
syscall
.
RegQueryValueEx
(
h
,
syscall
.
StringToUTF16Ptr
(
"Content Type"
),
h
,
syscall
.
StringToUTF16Ptr
(
"Content Type"
),
nil
,
&
typ
,
(
*
byte
)(
unsafe
.
Pointer
(
&
buf
[
0
])),
&
n
)
!=
0
{
nil
,
&
typ
,
(
*
byte
)(
unsafe
.
Pointer
(
&
buf
[
0
])),
&
n
)
!=
nil
{
syscall
.
RegCloseKey
(
h
)
syscall
.
RegCloseKey
(
h
)
continue
continue
}
}
...
...
src/pkg/net/fd_windows.go
View file @
ef65feda
...
@@ -25,8 +25,8 @@ var initErr error
...
@@ -25,8 +25,8 @@ var initErr error
func
init
()
{
func
init
()
{
var
d
syscall
.
WSAData
var
d
syscall
.
WSAData
e
:=
syscall
.
WSAStartup
(
uint32
(
0x202
),
&
d
)
e
:=
syscall
.
WSAStartup
(
uint32
(
0x202
),
&
d
)
if
e
!=
0
{
if
e
!=
nil
{
initErr
=
os
.
NewSyscallError
(
"WSAStartup"
,
syscall
.
Errno
(
e
)
)
initErr
=
os
.
NewSyscallError
(
"WSAStartup"
,
e
)
}
}
}
}
...
...
src/pkg/net/interface_windows.go
View file @
ef65feda
...
@@ -31,7 +31,7 @@ func getAdapterList() (*syscall.IpAdapterInfo, error) {
...
@@ -31,7 +31,7 @@ func getAdapterList() (*syscall.IpAdapterInfo, error) {
a
=
(
*
syscall
.
IpAdapterInfo
)(
unsafe
.
Pointer
(
&
b
[
0
]))
a
=
(
*
syscall
.
IpAdapterInfo
)(
unsafe
.
Pointer
(
&
b
[
0
]))
e
=
syscall
.
GetAdaptersInfo
(
a
,
&
l
)
e
=
syscall
.
GetAdaptersInfo
(
a
,
&
l
)
}
}
if
e
!=
0
{
if
e
!=
nil
{
return
nil
,
os
.
NewSyscallError
(
"GetAdaptersInfo"
,
e
)
return
nil
,
os
.
NewSyscallError
(
"GetAdaptersInfo"
,
e
)
}
}
return
a
,
nil
return
a
,
nil
...
@@ -77,7 +77,7 @@ func interfaceTable(ifindex int) ([]Interface, error) {
...
@@ -77,7 +77,7 @@ func interfaceTable(ifindex int) ([]Interface, error) {
row
:=
syscall
.
MibIfRow
{
Index
:
index
}
row
:=
syscall
.
MibIfRow
{
Index
:
index
}
e
:=
syscall
.
GetIfEntry
(
&
row
)
e
:=
syscall
.
GetIfEntry
(
&
row
)
if
e
!=
0
{
if
e
!=
nil
{
return
nil
,
os
.
NewSyscallError
(
"GetIfEntry"
,
e
)
return
nil
,
os
.
NewSyscallError
(
"GetIfEntry"
,
e
)
}
}
...
...
src/pkg/net/lookup_windows.go
View file @
ef65feda
...
@@ -80,7 +80,7 @@ func LookupPort(network, service string) (port int, err error) {
...
@@ -80,7 +80,7 @@ func LookupPort(network, service string) (port int, err error) {
func
LookupCNAME
(
name
string
)
(
cname
string
,
err
error
)
{
func
LookupCNAME
(
name
string
)
(
cname
string
,
err
error
)
{
var
r
*
syscall
.
DNSRecord
var
r
*
syscall
.
DNSRecord
e
:=
syscall
.
DnsQuery
(
name
,
syscall
.
DNS_TYPE_CNAME
,
0
,
nil
,
&
r
,
nil
)
e
:=
syscall
.
DnsQuery
(
name
,
syscall
.
DNS_TYPE_CNAME
,
0
,
nil
,
&
r
,
nil
)
if
e
!=
0
{
if
e
!=
nil
{
return
""
,
os
.
NewSyscallError
(
"LookupCNAME"
,
e
)
return
""
,
os
.
NewSyscallError
(
"LookupCNAME"
,
e
)
}
}
defer
syscall
.
DnsRecordListFree
(
r
,
1
)
defer
syscall
.
DnsRecordListFree
(
r
,
1
)
...
@@ -109,7 +109,7 @@ func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err err
...
@@ -109,7 +109,7 @@ func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err err
}
}
var
r
*
syscall
.
DNSRecord
var
r
*
syscall
.
DNSRecord
e
:=
syscall
.
DnsQuery
(
target
,
syscall
.
DNS_TYPE_SRV
,
0
,
nil
,
&
r
,
nil
)
e
:=
syscall
.
DnsQuery
(
target
,
syscall
.
DNS_TYPE_SRV
,
0
,
nil
,
&
r
,
nil
)
if
e
!=
0
{
if
e
!=
nil
{
return
""
,
nil
,
os
.
NewSyscallError
(
"LookupSRV"
,
e
)
return
""
,
nil
,
os
.
NewSyscallError
(
"LookupSRV"
,
e
)
}
}
defer
syscall
.
DnsRecordListFree
(
r
,
1
)
defer
syscall
.
DnsRecordListFree
(
r
,
1
)
...
@@ -125,7 +125,7 @@ func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err err
...
@@ -125,7 +125,7 @@ func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err err
func
LookupMX
(
name
string
)
(
mx
[]
*
MX
,
err
error
)
{
func
LookupMX
(
name
string
)
(
mx
[]
*
MX
,
err
error
)
{
var
r
*
syscall
.
DNSRecord
var
r
*
syscall
.
DNSRecord
e
:=
syscall
.
DnsQuery
(
name
,
syscall
.
DNS_TYPE_MX
,
0
,
nil
,
&
r
,
nil
)
e
:=
syscall
.
DnsQuery
(
name
,
syscall
.
DNS_TYPE_MX
,
0
,
nil
,
&
r
,
nil
)
if
e
!=
0
{
if
e
!=
nil
{
return
nil
,
os
.
NewSyscallError
(
"LookupMX"
,
e
)
return
nil
,
os
.
NewSyscallError
(
"LookupMX"
,
e
)
}
}
defer
syscall
.
DnsRecordListFree
(
r
,
1
)
defer
syscall
.
DnsRecordListFree
(
r
,
1
)
...
@@ -141,7 +141,7 @@ func LookupMX(name string) (mx []*MX, err error) {
...
@@ -141,7 +141,7 @@ func LookupMX(name string) (mx []*MX, err error) {
func
LookupTXT
(
name
string
)
(
txt
[]
string
,
err
error
)
{
func
LookupTXT
(
name
string
)
(
txt
[]
string
,
err
error
)
{
var
r
*
syscall
.
DNSRecord
var
r
*
syscall
.
DNSRecord
e
:=
syscall
.
DnsQuery
(
name
,
syscall
.
DNS_TYPE_TEXT
,
0
,
nil
,
&
r
,
nil
)
e
:=
syscall
.
DnsQuery
(
name
,
syscall
.
DNS_TYPE_TEXT
,
0
,
nil
,
&
r
,
nil
)
if
e
!=
0
{
if
e
!=
nil
{
return
nil
,
os
.
NewSyscallError
(
"LookupTXT"
,
e
)
return
nil
,
os
.
NewSyscallError
(
"LookupTXT"
,
e
)
}
}
defer
syscall
.
DnsRecordListFree
(
r
,
1
)
defer
syscall
.
DnsRecordListFree
(
r
,
1
)
...
@@ -163,7 +163,7 @@ func LookupAddr(addr string) (name []string, err error) {
...
@@ -163,7 +163,7 @@ func LookupAddr(addr string) (name []string, err error) {
}
}
var
r
*
syscall
.
DNSRecord
var
r
*
syscall
.
DNSRecord
e
:=
syscall
.
DnsQuery
(
arpa
,
syscall
.
DNS_TYPE_PTR
,
0
,
nil
,
&
r
,
nil
)
e
:=
syscall
.
DnsQuery
(
arpa
,
syscall
.
DNS_TYPE_PTR
,
0
,
nil
,
&
r
,
nil
)
if
e
!=
0
{
if
e
!=
nil
{
return
nil
,
os
.
NewSyscallError
(
"LookupAddr"
,
e
)
return
nil
,
os
.
NewSyscallError
(
"LookupAddr"
,
e
)
}
}
defer
syscall
.
DnsRecordListFree
(
r
,
1
)
defer
syscall
.
DnsRecordListFree
(
r
,
1
)
...
...
src/pkg/syscall/dll_windows.go
View file @
ef65feda
...
@@ -8,21 +8,6 @@ import (
...
@@ -8,21 +8,6 @@ import (
"sync"
"sync"
)
)
// Errno is the Windows error number.
type
Errno
uintptr
func
(
e
Errno
)
Error
()
string
{
return
errstr
(
e
)
}
func
(
e
Errno
)
Temporary
()
bool
{
return
e
==
EINTR
||
e
==
EMFILE
||
e
.
Timeout
()
}
func
(
e
Errno
)
Timeout
()
bool
{
return
e
==
EAGAIN
||
e
==
EWOULDBLOCK
||
e
==
ETIMEDOUT
}
// DLLError describes reasons for DLL load failures.
// DLLError describes reasons for DLL load failures.
type
DLLError
struct
{
type
DLLError
struct
{
Err
error
Err
error
...
...
src/pkg/syscall/mksyscall_windows.pl
View file @
ef65feda
...
@@ -260,6 +260,11 @@ while(<>) {
...
@@ -260,6 +260,11 @@ while(<>) {
$body
.=
"
\t\t\t
$name
=
${syscalldot}
EINVAL
\n
";
$body
.=
"
\t\t\t
$name
=
${syscalldot}
EINVAL
\n
";
$body
.=
"
\t\t
}
\n
";
$body
.=
"
\t\t
}
\n
";
$body
.=
"
\t
}
\n
";
$body
.=
"
\t
}
\n
";
}
elsif
(
$rettype
eq
"
error
")
{
# Set $reg to "error" only if returned value indicate failure
$body
.=
"
\t
if
$reg
!= 0 {
\n
";
$body
.=
"
\t\t
$name
= Errno(
$reg
)
\n
";
$body
.=
"
\t
}
\n
";
}
else
{
}
else
{
$body
.=
"
\t
$name
=
$rettype
(
$reg
)
\n
";
$body
.=
"
\t
$name
=
$rettype
(
$reg
)
\n
";
}
}
...
...
src/pkg/syscall/syscall_windows.go
View file @
ef65feda
...
@@ -76,6 +76,36 @@ func StringToUTF16Ptr(s string) *uint16 { return &StringToUTF16(s)[0] }
...
@@ -76,6 +76,36 @@ func StringToUTF16Ptr(s string) *uint16 { return &StringToUTF16(s)[0] }
func
Getpagesize
()
int
{
return
4096
}
func
Getpagesize
()
int
{
return
4096
}
// Errno is the Windows error number.
type
Errno
uintptr
func
(
e
Errno
)
Error
()
string
{
// deal with special go errors
idx
:=
int
(
e
-
APPLICATION_ERROR
)
if
0
<=
idx
&&
idx
<
len
(
errors
)
{
return
errors
[
idx
]
}
// ask windows for the remaining errors
var
flags
uint32
=
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_ARGUMENT_ARRAY
|
FORMAT_MESSAGE_IGNORE_INSERTS
b
:=
make
([]
uint16
,
300
)
n
,
err
:=
FormatMessage
(
flags
,
0
,
uint32
(
e
),
0
,
b
,
nil
)
if
err
!=
nil
{
return
"error "
+
itoa
(
int
(
e
))
+
" (FormatMessage failed with err="
+
itoa
(
int
(
err
.
(
Errno
)))
+
")"
}
// trim terminating \r and \n
for
;
n
>
0
&&
(
b
[
n
-
1
]
==
'\n'
||
b
[
n
-
1
]
==
'\r'
);
n
--
{
}
return
string
(
utf16
.
Decode
(
b
[
:
n
]))
}
func
(
e
Errno
)
Temporary
()
bool
{
return
e
==
EINTR
||
e
==
EMFILE
||
e
.
Timeout
()
}
func
(
e
Errno
)
Timeout
()
bool
{
return
e
==
EAGAIN
||
e
==
EWOULDBLOCK
||
e
==
ETIMEDOUT
}
// Converts a Go function to a function pointer conforming
// Converts a Go function to a function pointer conforming
// to the stdcall calling convention. This is useful when
// to the stdcall calling convention. This is useful when
// interoperating with Windows code requiring callbacks.
// interoperating with Windows code requiring callbacks.
...
@@ -84,7 +114,7 @@ func NewCallback(fn interface{}) uintptr
...
@@ -84,7 +114,7 @@ func NewCallback(fn interface{}) uintptr
// windows api calls
// windows api calls
//sys GetLastError() (lasterr
uintpt
r)
//sys GetLastError() (lasterr
erro
r)
//sys LoadLibrary(libname string) (handle Handle, err error) = LoadLibraryW
//sys LoadLibrary(libname string) (handle Handle, err error) = LoadLibraryW
//sys FreeLibrary(handle Handle) (err error)
//sys FreeLibrary(handle Handle) (err error)
//sys GetProcAddress(module Handle, procname string) (proc uintptr, err error)
//sys GetProcAddress(module Handle, procname string) (proc uintptr, err error)
...
@@ -154,34 +184,14 @@ func NewCallback(fn interface{}) uintptr
...
@@ -154,34 +184,14 @@ func NewCallback(fn interface{}) uintptr
//sys CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) = crypt32.CertOpenSystemStoreW
//sys CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) = crypt32.CertOpenSystemStoreW
//sys CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) [failretval==nil] = crypt32.CertEnumCertificatesInStore
//sys CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) [failretval==nil] = crypt32.CertEnumCertificatesInStore
//sys CertCloseStore(store Handle, flags uint32) (err error) = crypt32.CertCloseStore
//sys CertCloseStore(store Handle, flags uint32) (err error) = crypt32.CertCloseStore
//sys RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno
uintpt
r) = advapi32.RegOpenKeyExW
//sys RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno
erro
r) = advapi32.RegOpenKeyExW
//sys RegCloseKey(key Handle) (regerrno
uintpt
r) = advapi32.RegCloseKey
//sys RegCloseKey(key Handle) (regerrno
erro
r) = advapi32.RegCloseKey
//sys RegQueryInfoKey(key Handle, class *uint16, classLen *uint32, reserved *uint32, subkeysLen *uint32, maxSubkeyLen *uint32, maxClassLen *uint32, valuesLen *uint32, maxValueNameLen *uint32, maxValueLen *uint32, saLen *uint32, lastWriteTime *Filetime) (regerrno
uintpt
r) = advapi32.RegQueryInfoKeyW
//sys RegQueryInfoKey(key Handle, class *uint16, classLen *uint32, reserved *uint32, subkeysLen *uint32, maxSubkeyLen *uint32, maxClassLen *uint32, valuesLen *uint32, maxValueNameLen *uint32, maxValueLen *uint32, saLen *uint32, lastWriteTime *Filetime) (regerrno
erro
r) = advapi32.RegQueryInfoKeyW
//sys RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno
uintpt
r) = advapi32.RegEnumKeyExW
//sys RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno
erro
r) = advapi32.RegEnumKeyExW
//sys RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno
uintpt
r) = advapi32.RegQueryValueExW
//sys RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno
erro
r) = advapi32.RegQueryValueExW
// syscall interface implementation for other packages
// syscall interface implementation for other packages
func
errstr
(
errno
Errno
)
string
{
// deal with special go errors
e
:=
int
(
errno
-
APPLICATION_ERROR
)
if
0
<=
e
&&
e
<
len
(
errors
)
{
return
errors
[
e
]
}
// ask windows for the remaining errors
var
flags
uint32
=
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_ARGUMENT_ARRAY
|
FORMAT_MESSAGE_IGNORE_INSERTS
b
:=
make
([]
uint16
,
300
)
n
,
err
:=
FormatMessage
(
flags
,
0
,
uint32
(
errno
),
0
,
b
,
nil
)
if
err
!=
nil
{
return
"error "
+
itoa
(
int
(
errno
))
+
" (FormatMessage failed with err="
+
itoa
(
int
(
err
.
(
Errno
)))
+
")"
}
// trim terminating \r and \n
for
;
n
>
0
&&
(
b
[
n
-
1
]
==
'\n'
||
b
[
n
-
1
]
==
'\r'
);
n
--
{
}
return
string
(
utf16
.
Decode
(
b
[
:
n
]))
}
func
Exit
(
code
int
)
{
ExitProcess
(
uint32
(
code
))
}
func
Exit
(
code
int
)
{
ExitProcess
(
uint32
(
code
))
}
func
makeInheritSa
()
*
SecurityAttributes
{
func
makeInheritSa
()
*
SecurityAttributes
{
...
@@ -415,7 +425,7 @@ func Chmod(path string, mode uint32) (err error) {
...
@@ -415,7 +425,7 @@ func Chmod(path string, mode uint32) (err error) {
// net api calls
// net api calls
//sys WSAStartup(verreq uint32, data *WSAData) (sockerr
uintpt
r) = ws2_32.WSAStartup
//sys WSAStartup(verreq uint32, data *WSAData) (sockerr
erro
r) = ws2_32.WSAStartup
//sys WSACleanup() (err error) [failretval==-1] = ws2_32.WSACleanup
//sys WSACleanup() (err error) [failretval==-1] = ws2_32.WSACleanup
//sys WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) [failretval==-1] = ws2_32.WSAIoctl
//sys WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) [failretval==-1] = ws2_32.WSAIoctl
//sys socket(af int32, typ int32, protocol int32) (handle Handle, err error) [failretval==InvalidHandle] = ws2_32.socket
//sys socket(af int32, typ int32, protocol int32) (handle Handle, err error) [failretval==InvalidHandle] = ws2_32.socket
...
@@ -437,10 +447,10 @@ func Chmod(path string, mode uint32) (err error) {
...
@@ -437,10 +447,10 @@ func Chmod(path string, mode uint32) (err error) {
//sys GetServByName(name string, proto string) (s *Servent, err error) [failretval==nil] = ws2_32.getservbyname
//sys GetServByName(name string, proto string) (s *Servent, err error) [failretval==nil] = ws2_32.getservbyname
//sys Ntohs(netshort uint16) (u uint16) = ws2_32.ntohs
//sys Ntohs(netshort uint16) (u uint16) = ws2_32.ntohs
//sys GetProtoByName(name string) (p *Protoent, err error) [failretval==nil] = ws2_32.getprotobyname
//sys GetProtoByName(name string) (p *Protoent, err error) [failretval==nil] = ws2_32.getprotobyname
//sys DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status
Errno
) = dnsapi.DnsQuery_W
//sys DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status
error
) = dnsapi.DnsQuery_W
//sys DnsRecordListFree(rl *DNSRecord, freetype uint32) = dnsapi.DnsRecordListFree
//sys DnsRecordListFree(rl *DNSRecord, freetype uint32) = dnsapi.DnsRecordListFree
//sys GetIfEntry(pIfRow *MibIfRow) (errcode
Errno
) = iphlpapi.GetIfEntry
//sys GetIfEntry(pIfRow *MibIfRow) (errcode
error
) = iphlpapi.GetIfEntry
//sys GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode
Errno
) = iphlpapi.GetAdaptersInfo
//sys GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode
error
) = iphlpapi.GetAdaptersInfo
// For testing: clients can set this flag to force
// For testing: clients can set this flag to force
// creation of IPv6 sockets to return EAFNOSUPPORT.
// creation of IPv6 sockets to return EAFNOSUPPORT.
...
...
src/pkg/syscall/zsyscall_windows_386.go
View file @
ef65feda
...
@@ -118,9 +118,11 @@ var (
...
@@ -118,9 +118,11 @@ var (
procGetAdaptersInfo
=
modiphlpapi
.
NewProc
(
"GetAdaptersInfo"
)
procGetAdaptersInfo
=
modiphlpapi
.
NewProc
(
"GetAdaptersInfo"
)
)
)
func
GetLastError
()
(
lasterr
uintpt
r
)
{
func
GetLastError
()
(
lasterr
erro
r
)
{
r0
,
_
,
_
:=
Syscall
(
procGetLastError
.
Addr
(),
0
,
0
,
0
,
0
)
r0
,
_
,
_
:=
Syscall
(
procGetLastError
.
Addr
(),
0
,
0
,
0
,
0
)
lasterr
=
uintptr
(
r0
)
if
r0
!=
0
{
lasterr
=
Errno
(
r0
)
}
return
return
}
}
...
@@ -994,39 +996,51 @@ func CertCloseStore(store Handle, flags uint32) (err error) {
...
@@ -994,39 +996,51 @@ func CertCloseStore(store Handle, flags uint32) (err error) {
return
return
}
}
func
RegOpenKeyEx
(
key
Handle
,
subkey
*
uint16
,
options
uint32
,
desiredAccess
uint32
,
result
*
Handle
)
(
regerrno
uintpt
r
)
{
func
RegOpenKeyEx
(
key
Handle
,
subkey
*
uint16
,
options
uint32
,
desiredAccess
uint32
,
result
*
Handle
)
(
regerrno
erro
r
)
{
r0
,
_
,
_
:=
Syscall6
(
procRegOpenKeyExW
.
Addr
(),
5
,
uintptr
(
key
),
uintptr
(
unsafe
.
Pointer
(
subkey
)),
uintptr
(
options
),
uintptr
(
desiredAccess
),
uintptr
(
unsafe
.
Pointer
(
result
)),
0
)
r0
,
_
,
_
:=
Syscall6
(
procRegOpenKeyExW
.
Addr
(),
5
,
uintptr
(
key
),
uintptr
(
unsafe
.
Pointer
(
subkey
)),
uintptr
(
options
),
uintptr
(
desiredAccess
),
uintptr
(
unsafe
.
Pointer
(
result
)),
0
)
regerrno
=
uintptr
(
r0
)
if
r0
!=
0
{
regerrno
=
Errno
(
r0
)
}
return
return
}
}
func
RegCloseKey
(
key
Handle
)
(
regerrno
uintpt
r
)
{
func
RegCloseKey
(
key
Handle
)
(
regerrno
erro
r
)
{
r0
,
_
,
_
:=
Syscall
(
procRegCloseKey
.
Addr
(),
1
,
uintptr
(
key
),
0
,
0
)
r0
,
_
,
_
:=
Syscall
(
procRegCloseKey
.
Addr
(),
1
,
uintptr
(
key
),
0
,
0
)
regerrno
=
uintptr
(
r0
)
if
r0
!=
0
{
regerrno
=
Errno
(
r0
)
}
return
return
}
}
func
RegQueryInfoKey
(
key
Handle
,
class
*
uint16
,
classLen
*
uint32
,
reserved
*
uint32
,
subkeysLen
*
uint32
,
maxSubkeyLen
*
uint32
,
maxClassLen
*
uint32
,
valuesLen
*
uint32
,
maxValueNameLen
*
uint32
,
maxValueLen
*
uint32
,
saLen
*
uint32
,
lastWriteTime
*
Filetime
)
(
regerrno
uintpt
r
)
{
func
RegQueryInfoKey
(
key
Handle
,
class
*
uint16
,
classLen
*
uint32
,
reserved
*
uint32
,
subkeysLen
*
uint32
,
maxSubkeyLen
*
uint32
,
maxClassLen
*
uint32
,
valuesLen
*
uint32
,
maxValueNameLen
*
uint32
,
maxValueLen
*
uint32
,
saLen
*
uint32
,
lastWriteTime
*
Filetime
)
(
regerrno
erro
r
)
{
r0
,
_
,
_
:=
Syscall12
(
procRegQueryInfoKeyW
.
Addr
(),
12
,
uintptr
(
key
),
uintptr
(
unsafe
.
Pointer
(
class
)),
uintptr
(
unsafe
.
Pointer
(
classLen
)),
uintptr
(
unsafe
.
Pointer
(
reserved
)),
uintptr
(
unsafe
.
Pointer
(
subkeysLen
)),
uintptr
(
unsafe
.
Pointer
(
maxSubkeyLen
)),
uintptr
(
unsafe
.
Pointer
(
maxClassLen
)),
uintptr
(
unsafe
.
Pointer
(
valuesLen
)),
uintptr
(
unsafe
.
Pointer
(
maxValueNameLen
)),
uintptr
(
unsafe
.
Pointer
(
maxValueLen
)),
uintptr
(
unsafe
.
Pointer
(
saLen
)),
uintptr
(
unsafe
.
Pointer
(
lastWriteTime
)))
r0
,
_
,
_
:=
Syscall12
(
procRegQueryInfoKeyW
.
Addr
(),
12
,
uintptr
(
key
),
uintptr
(
unsafe
.
Pointer
(
class
)),
uintptr
(
unsafe
.
Pointer
(
classLen
)),
uintptr
(
unsafe
.
Pointer
(
reserved
)),
uintptr
(
unsafe
.
Pointer
(
subkeysLen
)),
uintptr
(
unsafe
.
Pointer
(
maxSubkeyLen
)),
uintptr
(
unsafe
.
Pointer
(
maxClassLen
)),
uintptr
(
unsafe
.
Pointer
(
valuesLen
)),
uintptr
(
unsafe
.
Pointer
(
maxValueNameLen
)),
uintptr
(
unsafe
.
Pointer
(
maxValueLen
)),
uintptr
(
unsafe
.
Pointer
(
saLen
)),
uintptr
(
unsafe
.
Pointer
(
lastWriteTime
)))
regerrno
=
uintptr
(
r0
)
if
r0
!=
0
{
regerrno
=
Errno
(
r0
)
}
return
return
}
}
func
RegEnumKeyEx
(
key
Handle
,
index
uint32
,
name
*
uint16
,
nameLen
*
uint32
,
reserved
*
uint32
,
class
*
uint16
,
classLen
*
uint32
,
lastWriteTime
*
Filetime
)
(
regerrno
uintpt
r
)
{
func
RegEnumKeyEx
(
key
Handle
,
index
uint32
,
name
*
uint16
,
nameLen
*
uint32
,
reserved
*
uint32
,
class
*
uint16
,
classLen
*
uint32
,
lastWriteTime
*
Filetime
)
(
regerrno
erro
r
)
{
r0
,
_
,
_
:=
Syscall9
(
procRegEnumKeyExW
.
Addr
(),
8
,
uintptr
(
key
),
uintptr
(
index
),
uintptr
(
unsafe
.
Pointer
(
name
)),
uintptr
(
unsafe
.
Pointer
(
nameLen
)),
uintptr
(
unsafe
.
Pointer
(
reserved
)),
uintptr
(
unsafe
.
Pointer
(
class
)),
uintptr
(
unsafe
.
Pointer
(
classLen
)),
uintptr
(
unsafe
.
Pointer
(
lastWriteTime
)),
0
)
r0
,
_
,
_
:=
Syscall9
(
procRegEnumKeyExW
.
Addr
(),
8
,
uintptr
(
key
),
uintptr
(
index
),
uintptr
(
unsafe
.
Pointer
(
name
)),
uintptr
(
unsafe
.
Pointer
(
nameLen
)),
uintptr
(
unsafe
.
Pointer
(
reserved
)),
uintptr
(
unsafe
.
Pointer
(
class
)),
uintptr
(
unsafe
.
Pointer
(
classLen
)),
uintptr
(
unsafe
.
Pointer
(
lastWriteTime
)),
0
)
regerrno
=
uintptr
(
r0
)
if
r0
!=
0
{
regerrno
=
Errno
(
r0
)
}
return
return
}
}
func
RegQueryValueEx
(
key
Handle
,
name
*
uint16
,
reserved
*
uint32
,
valtype
*
uint32
,
buf
*
byte
,
buflen
*
uint32
)
(
regerrno
uintpt
r
)
{
func
RegQueryValueEx
(
key
Handle
,
name
*
uint16
,
reserved
*
uint32
,
valtype
*
uint32
,
buf
*
byte
,
buflen
*
uint32
)
(
regerrno
erro
r
)
{
r0
,
_
,
_
:=
Syscall6
(
procRegQueryValueExW
.
Addr
(),
6
,
uintptr
(
key
),
uintptr
(
unsafe
.
Pointer
(
name
)),
uintptr
(
unsafe
.
Pointer
(
reserved
)),
uintptr
(
unsafe
.
Pointer
(
valtype
)),
uintptr
(
unsafe
.
Pointer
(
buf
)),
uintptr
(
unsafe
.
Pointer
(
buflen
)))
r0
,
_
,
_
:=
Syscall6
(
procRegQueryValueExW
.
Addr
(),
6
,
uintptr
(
key
),
uintptr
(
unsafe
.
Pointer
(
name
)),
uintptr
(
unsafe
.
Pointer
(
reserved
)),
uintptr
(
unsafe
.
Pointer
(
valtype
)),
uintptr
(
unsafe
.
Pointer
(
buf
)),
uintptr
(
unsafe
.
Pointer
(
buflen
)))
regerrno
=
uintptr
(
r0
)
if
r0
!=
0
{
regerrno
=
Errno
(
r0
)
}
return
return
}
}
func
WSAStartup
(
verreq
uint32
,
data
*
WSAData
)
(
sockerr
uintpt
r
)
{
func
WSAStartup
(
verreq
uint32
,
data
*
WSAData
)
(
sockerr
erro
r
)
{
r0
,
_
,
_
:=
Syscall
(
procWSAStartup
.
Addr
(),
2
,
uintptr
(
verreq
),
uintptr
(
unsafe
.
Pointer
(
data
)),
0
)
r0
,
_
,
_
:=
Syscall
(
procWSAStartup
.
Addr
(),
2
,
uintptr
(
verreq
),
uintptr
(
unsafe
.
Pointer
(
data
)),
0
)
sockerr
=
uintptr
(
r0
)
if
r0
!=
0
{
sockerr
=
Errno
(
r0
)
}
return
return
}
}
...
@@ -1273,9 +1287,11 @@ func GetProtoByName(name string) (p *Protoent, err error) {
...
@@ -1273,9 +1287,11 @@ func GetProtoByName(name string) (p *Protoent, err error) {
return
return
}
}
func
DnsQuery
(
name
string
,
qtype
uint16
,
options
uint32
,
extra
*
byte
,
qrs
**
DNSRecord
,
pr
*
byte
)
(
status
Errno
)
{
func
DnsQuery
(
name
string
,
qtype
uint16
,
options
uint32
,
extra
*
byte
,
qrs
**
DNSRecord
,
pr
*
byte
)
(
status
error
)
{
r0
,
_
,
_
:=
Syscall6
(
procDnsQuery_W
.
Addr
(),
6
,
uintptr
(
unsafe
.
Pointer
(
StringToUTF16Ptr
(
name
))),
uintptr
(
qtype
),
uintptr
(
options
),
uintptr
(
unsafe
.
Pointer
(
extra
)),
uintptr
(
unsafe
.
Pointer
(
qrs
)),
uintptr
(
unsafe
.
Pointer
(
pr
)))
r0
,
_
,
_
:=
Syscall6
(
procDnsQuery_W
.
Addr
(),
6
,
uintptr
(
unsafe
.
Pointer
(
StringToUTF16Ptr
(
name
))),
uintptr
(
qtype
),
uintptr
(
options
),
uintptr
(
unsafe
.
Pointer
(
extra
)),
uintptr
(
unsafe
.
Pointer
(
qrs
)),
uintptr
(
unsafe
.
Pointer
(
pr
)))
if
r0
!=
0
{
status
=
Errno
(
r0
)
status
=
Errno
(
r0
)
}
return
return
}
}
...
@@ -1284,14 +1300,18 @@ func DnsRecordListFree(rl *DNSRecord, freetype uint32) {
...
@@ -1284,14 +1300,18 @@ func DnsRecordListFree(rl *DNSRecord, freetype uint32) {
return
return
}
}
func
GetIfEntry
(
pIfRow
*
MibIfRow
)
(
errcode
Errno
)
{
func
GetIfEntry
(
pIfRow
*
MibIfRow
)
(
errcode
error
)
{
r0
,
_
,
_
:=
Syscall
(
procGetIfEntry
.
Addr
(),
1
,
uintptr
(
unsafe
.
Pointer
(
pIfRow
)),
0
,
0
)
r0
,
_
,
_
:=
Syscall
(
procGetIfEntry
.
Addr
(),
1
,
uintptr
(
unsafe
.
Pointer
(
pIfRow
)),
0
,
0
)
if
r0
!=
0
{
errcode
=
Errno
(
r0
)
errcode
=
Errno
(
r0
)
}
return
return
}
}
func
GetAdaptersInfo
(
ai
*
IpAdapterInfo
,
ol
*
uint32
)
(
errcode
Errno
)
{
func
GetAdaptersInfo
(
ai
*
IpAdapterInfo
,
ol
*
uint32
)
(
errcode
error
)
{
r0
,
_
,
_
:=
Syscall
(
procGetAdaptersInfo
.
Addr
(),
2
,
uintptr
(
unsafe
.
Pointer
(
ai
)),
uintptr
(
unsafe
.
Pointer
(
ol
)),
0
)
r0
,
_
,
_
:=
Syscall
(
procGetAdaptersInfo
.
Addr
(),
2
,
uintptr
(
unsafe
.
Pointer
(
ai
)),
uintptr
(
unsafe
.
Pointer
(
ol
)),
0
)
if
r0
!=
0
{
errcode
=
Errno
(
r0
)
errcode
=
Errno
(
r0
)
}
return
return
}
}
src/pkg/syscall/zsyscall_windows_amd64.go
View file @
ef65feda
...
@@ -118,9 +118,11 @@ var (
...
@@ -118,9 +118,11 @@ var (
procGetAdaptersInfo
=
modiphlpapi
.
NewProc
(
"GetAdaptersInfo"
)
procGetAdaptersInfo
=
modiphlpapi
.
NewProc
(
"GetAdaptersInfo"
)
)
)
func
GetLastError
()
(
lasterr
uintpt
r
)
{
func
GetLastError
()
(
lasterr
erro
r
)
{
r0
,
_
,
_
:=
Syscall
(
procGetLastError
.
Addr
(),
0
,
0
,
0
,
0
)
r0
,
_
,
_
:=
Syscall
(
procGetLastError
.
Addr
(),
0
,
0
,
0
,
0
)
lasterr
=
uintptr
(
r0
)
if
r0
!=
0
{
lasterr
=
Errno
(
r0
)
}
return
return
}
}
...
@@ -994,39 +996,51 @@ func CertCloseStore(store Handle, flags uint32) (err error) {
...
@@ -994,39 +996,51 @@ func CertCloseStore(store Handle, flags uint32) (err error) {
return
return
}
}
func
RegOpenKeyEx
(
key
Handle
,
subkey
*
uint16
,
options
uint32
,
desiredAccess
uint32
,
result
*
Handle
)
(
regerrno
uintpt
r
)
{
func
RegOpenKeyEx
(
key
Handle
,
subkey
*
uint16
,
options
uint32
,
desiredAccess
uint32
,
result
*
Handle
)
(
regerrno
erro
r
)
{
r0
,
_
,
_
:=
Syscall6
(
procRegOpenKeyExW
.
Addr
(),
5
,
uintptr
(
key
),
uintptr
(
unsafe
.
Pointer
(
subkey
)),
uintptr
(
options
),
uintptr
(
desiredAccess
),
uintptr
(
unsafe
.
Pointer
(
result
)),
0
)
r0
,
_
,
_
:=
Syscall6
(
procRegOpenKeyExW
.
Addr
(),
5
,
uintptr
(
key
),
uintptr
(
unsafe
.
Pointer
(
subkey
)),
uintptr
(
options
),
uintptr
(
desiredAccess
),
uintptr
(
unsafe
.
Pointer
(
result
)),
0
)
regerrno
=
uintptr
(
r0
)
if
r0
!=
0
{
regerrno
=
Errno
(
r0
)
}
return
return
}
}
func
RegCloseKey
(
key
Handle
)
(
regerrno
uintpt
r
)
{
func
RegCloseKey
(
key
Handle
)
(
regerrno
erro
r
)
{
r0
,
_
,
_
:=
Syscall
(
procRegCloseKey
.
Addr
(),
1
,
uintptr
(
key
),
0
,
0
)
r0
,
_
,
_
:=
Syscall
(
procRegCloseKey
.
Addr
(),
1
,
uintptr
(
key
),
0
,
0
)
regerrno
=
uintptr
(
r0
)
if
r0
!=
0
{
regerrno
=
Errno
(
r0
)
}
return
return
}
}
func
RegQueryInfoKey
(
key
Handle
,
class
*
uint16
,
classLen
*
uint32
,
reserved
*
uint32
,
subkeysLen
*
uint32
,
maxSubkeyLen
*
uint32
,
maxClassLen
*
uint32
,
valuesLen
*
uint32
,
maxValueNameLen
*
uint32
,
maxValueLen
*
uint32
,
saLen
*
uint32
,
lastWriteTime
*
Filetime
)
(
regerrno
uintpt
r
)
{
func
RegQueryInfoKey
(
key
Handle
,
class
*
uint16
,
classLen
*
uint32
,
reserved
*
uint32
,
subkeysLen
*
uint32
,
maxSubkeyLen
*
uint32
,
maxClassLen
*
uint32
,
valuesLen
*
uint32
,
maxValueNameLen
*
uint32
,
maxValueLen
*
uint32
,
saLen
*
uint32
,
lastWriteTime
*
Filetime
)
(
regerrno
erro
r
)
{
r0
,
_
,
_
:=
Syscall12
(
procRegQueryInfoKeyW
.
Addr
(),
12
,
uintptr
(
key
),
uintptr
(
unsafe
.
Pointer
(
class
)),
uintptr
(
unsafe
.
Pointer
(
classLen
)),
uintptr
(
unsafe
.
Pointer
(
reserved
)),
uintptr
(
unsafe
.
Pointer
(
subkeysLen
)),
uintptr
(
unsafe
.
Pointer
(
maxSubkeyLen
)),
uintptr
(
unsafe
.
Pointer
(
maxClassLen
)),
uintptr
(
unsafe
.
Pointer
(
valuesLen
)),
uintptr
(
unsafe
.
Pointer
(
maxValueNameLen
)),
uintptr
(
unsafe
.
Pointer
(
maxValueLen
)),
uintptr
(
unsafe
.
Pointer
(
saLen
)),
uintptr
(
unsafe
.
Pointer
(
lastWriteTime
)))
r0
,
_
,
_
:=
Syscall12
(
procRegQueryInfoKeyW
.
Addr
(),
12
,
uintptr
(
key
),
uintptr
(
unsafe
.
Pointer
(
class
)),
uintptr
(
unsafe
.
Pointer
(
classLen
)),
uintptr
(
unsafe
.
Pointer
(
reserved
)),
uintptr
(
unsafe
.
Pointer
(
subkeysLen
)),
uintptr
(
unsafe
.
Pointer
(
maxSubkeyLen
)),
uintptr
(
unsafe
.
Pointer
(
maxClassLen
)),
uintptr
(
unsafe
.
Pointer
(
valuesLen
)),
uintptr
(
unsafe
.
Pointer
(
maxValueNameLen
)),
uintptr
(
unsafe
.
Pointer
(
maxValueLen
)),
uintptr
(
unsafe
.
Pointer
(
saLen
)),
uintptr
(
unsafe
.
Pointer
(
lastWriteTime
)))
regerrno
=
uintptr
(
r0
)
if
r0
!=
0
{
regerrno
=
Errno
(
r0
)
}
return
return
}
}
func
RegEnumKeyEx
(
key
Handle
,
index
uint32
,
name
*
uint16
,
nameLen
*
uint32
,
reserved
*
uint32
,
class
*
uint16
,
classLen
*
uint32
,
lastWriteTime
*
Filetime
)
(
regerrno
uintpt
r
)
{
func
RegEnumKeyEx
(
key
Handle
,
index
uint32
,
name
*
uint16
,
nameLen
*
uint32
,
reserved
*
uint32
,
class
*
uint16
,
classLen
*
uint32
,
lastWriteTime
*
Filetime
)
(
regerrno
erro
r
)
{
r0
,
_
,
_
:=
Syscall9
(
procRegEnumKeyExW
.
Addr
(),
8
,
uintptr
(
key
),
uintptr
(
index
),
uintptr
(
unsafe
.
Pointer
(
name
)),
uintptr
(
unsafe
.
Pointer
(
nameLen
)),
uintptr
(
unsafe
.
Pointer
(
reserved
)),
uintptr
(
unsafe
.
Pointer
(
class
)),
uintptr
(
unsafe
.
Pointer
(
classLen
)),
uintptr
(
unsafe
.
Pointer
(
lastWriteTime
)),
0
)
r0
,
_
,
_
:=
Syscall9
(
procRegEnumKeyExW
.
Addr
(),
8
,
uintptr
(
key
),
uintptr
(
index
),
uintptr
(
unsafe
.
Pointer
(
name
)),
uintptr
(
unsafe
.
Pointer
(
nameLen
)),
uintptr
(
unsafe
.
Pointer
(
reserved
)),
uintptr
(
unsafe
.
Pointer
(
class
)),
uintptr
(
unsafe
.
Pointer
(
classLen
)),
uintptr
(
unsafe
.
Pointer
(
lastWriteTime
)),
0
)
regerrno
=
uintptr
(
r0
)
if
r0
!=
0
{
regerrno
=
Errno
(
r0
)
}
return
return
}
}
func
RegQueryValueEx
(
key
Handle
,
name
*
uint16
,
reserved
*
uint32
,
valtype
*
uint32
,
buf
*
byte
,
buflen
*
uint32
)
(
regerrno
uintpt
r
)
{
func
RegQueryValueEx
(
key
Handle
,
name
*
uint16
,
reserved
*
uint32
,
valtype
*
uint32
,
buf
*
byte
,
buflen
*
uint32
)
(
regerrno
erro
r
)
{
r0
,
_
,
_
:=
Syscall6
(
procRegQueryValueExW
.
Addr
(),
6
,
uintptr
(
key
),
uintptr
(
unsafe
.
Pointer
(
name
)),
uintptr
(
unsafe
.
Pointer
(
reserved
)),
uintptr
(
unsafe
.
Pointer
(
valtype
)),
uintptr
(
unsafe
.
Pointer
(
buf
)),
uintptr
(
unsafe
.
Pointer
(
buflen
)))
r0
,
_
,
_
:=
Syscall6
(
procRegQueryValueExW
.
Addr
(),
6
,
uintptr
(
key
),
uintptr
(
unsafe
.
Pointer
(
name
)),
uintptr
(
unsafe
.
Pointer
(
reserved
)),
uintptr
(
unsafe
.
Pointer
(
valtype
)),
uintptr
(
unsafe
.
Pointer
(
buf
)),
uintptr
(
unsafe
.
Pointer
(
buflen
)))
regerrno
=
uintptr
(
r0
)
if
r0
!=
0
{
regerrno
=
Errno
(
r0
)
}
return
return
}
}
func
WSAStartup
(
verreq
uint32
,
data
*
WSAData
)
(
sockerr
uintpt
r
)
{
func
WSAStartup
(
verreq
uint32
,
data
*
WSAData
)
(
sockerr
erro
r
)
{
r0
,
_
,
_
:=
Syscall
(
procWSAStartup
.
Addr
(),
2
,
uintptr
(
verreq
),
uintptr
(
unsafe
.
Pointer
(
data
)),
0
)
r0
,
_
,
_
:=
Syscall
(
procWSAStartup
.
Addr
(),
2
,
uintptr
(
verreq
),
uintptr
(
unsafe
.
Pointer
(
data
)),
0
)
sockerr
=
uintptr
(
r0
)
if
r0
!=
0
{
sockerr
=
Errno
(
r0
)
}
return
return
}
}
...
@@ -1273,9 +1287,11 @@ func GetProtoByName(name string) (p *Protoent, err error) {
...
@@ -1273,9 +1287,11 @@ func GetProtoByName(name string) (p *Protoent, err error) {
return
return
}
}
func
DnsQuery
(
name
string
,
qtype
uint16
,
options
uint32
,
extra
*
byte
,
qrs
**
DNSRecord
,
pr
*
byte
)
(
status
Errno
)
{
func
DnsQuery
(
name
string
,
qtype
uint16
,
options
uint32
,
extra
*
byte
,
qrs
**
DNSRecord
,
pr
*
byte
)
(
status
error
)
{
r0
,
_
,
_
:=
Syscall6
(
procDnsQuery_W
.
Addr
(),
6
,
uintptr
(
unsafe
.
Pointer
(
StringToUTF16Ptr
(
name
))),
uintptr
(
qtype
),
uintptr
(
options
),
uintptr
(
unsafe
.
Pointer
(
extra
)),
uintptr
(
unsafe
.
Pointer
(
qrs
)),
uintptr
(
unsafe
.
Pointer
(
pr
)))
r0
,
_
,
_
:=
Syscall6
(
procDnsQuery_W
.
Addr
(),
6
,
uintptr
(
unsafe
.
Pointer
(
StringToUTF16Ptr
(
name
))),
uintptr
(
qtype
),
uintptr
(
options
),
uintptr
(
unsafe
.
Pointer
(
extra
)),
uintptr
(
unsafe
.
Pointer
(
qrs
)),
uintptr
(
unsafe
.
Pointer
(
pr
)))
if
r0
!=
0
{
status
=
Errno
(
r0
)
status
=
Errno
(
r0
)
}
return
return
}
}
...
@@ -1284,14 +1300,18 @@ func DnsRecordListFree(rl *DNSRecord, freetype uint32) {
...
@@ -1284,14 +1300,18 @@ func DnsRecordListFree(rl *DNSRecord, freetype uint32) {
return
return
}
}
func
GetIfEntry
(
pIfRow
*
MibIfRow
)
(
errcode
Errno
)
{
func
GetIfEntry
(
pIfRow
*
MibIfRow
)
(
errcode
error
)
{
r0
,
_
,
_
:=
Syscall
(
procGetIfEntry
.
Addr
(),
1
,
uintptr
(
unsafe
.
Pointer
(
pIfRow
)),
0
,
0
)
r0
,
_
,
_
:=
Syscall
(
procGetIfEntry
.
Addr
(),
1
,
uintptr
(
unsafe
.
Pointer
(
pIfRow
)),
0
,
0
)
if
r0
!=
0
{
errcode
=
Errno
(
r0
)
errcode
=
Errno
(
r0
)
}
return
return
}
}
func
GetAdaptersInfo
(
ai
*
IpAdapterInfo
,
ol
*
uint32
)
(
errcode
Errno
)
{
func
GetAdaptersInfo
(
ai
*
IpAdapterInfo
,
ol
*
uint32
)
(
errcode
error
)
{
r0
,
_
,
_
:=
Syscall
(
procGetAdaptersInfo
.
Addr
(),
2
,
uintptr
(
unsafe
.
Pointer
(
ai
)),
uintptr
(
unsafe
.
Pointer
(
ol
)),
0
)
r0
,
_
,
_
:=
Syscall
(
procGetAdaptersInfo
.
Addr
(),
2
,
uintptr
(
unsafe
.
Pointer
(
ai
)),
uintptr
(
unsafe
.
Pointer
(
ol
)),
0
)
if
r0
!=
0
{
errcode
=
Errno
(
r0
)
errcode
=
Errno
(
r0
)
}
return
return
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment