[sys] windows: add DWM window attribute related syscalls

363 views
Skip to first unread message

Gerrit Bot (Gerrit)

unread,
Apr 8, 2022, 10:52:02 AM4/8/22
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gerrit Bot has uploaded this change for review.

View Change

windows: add DWM window attribute related syscalls

https://docs.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmgetwindowattribute
https://docs.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmsetwindowattribute

Change-Id: I96a68f91f745601e93c0cc21cc4f1f4c5e7d8b9e
GitHub-Last-Rev: 2be050feaab0bee03c6a9f13ed64d4f4b3104b62
GitHub-Pull-Request: golang/sys#123
---
M windows/syscall_windows.go
M windows/types_windows.go
M windows/zsyscall_windows.go
3 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/windows/syscall_windows.go b/windows/syscall_windows.go
index ce3075c..f3fec59 100644
--- a/windows/syscall_windows.go
+++ b/windows/syscall_windows.go
@@ -438,6 +438,10 @@
//sys RtlAddFunctionTable(functionTable *RUNTIME_FUNCTION, entryCount uint32, baseAddress uintptr) (ret bool) = ntdll.RtlAddFunctionTable
//sys RtlDeleteFunctionTable(functionTable *RUNTIME_FUNCTION) (ret bool) = ntdll.RtlDeleteFunctionTable

+// Desktop Window Manager API (Dwmapi)
+//sys DwmGetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) = dwmapi.DwmGetWindowAttribute
+//sys DwmSetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) = dwmapi.DwmSetWindowAttribute
+
// syscall interface implementation for other packages

// GetCurrentProcess returns the handle for the current process.
diff --git a/windows/types_windows.go b/windows/types_windows.go
index e19471c..3de6e94 100644
--- a/windows/types_windows.go
+++ b/windows/types_windows.go
@@ -3174,3 +3174,29 @@
}

const ALL_PROCESSOR_GROUPS = 0xFFFF
+
+const (
+ DWMWA_NCRENDERING_ENABLED = 1
+ DWMWA_NCRENDERING_POLICY = 2
+ DWMWA_TRANSITIONS_FORCEDISABLED = 3
+ DWMWA_ALLOW_NCPAINT = 4
+ DWMWA_CAPTION_BUTTON_BOUNDS = 5
+ DWMWA_NONCLIENT_RTL_LAYOUT = 6
+ DWMWA_FORCE_ICONIC_REPRESENTATION = 7
+ DWMWA_FLIP3D_POLICY = 8
+ DWMWA_EXTENDED_FRAME_BOUNDS = 9
+ DWMWA_HAS_ICONIC_BITMAP = 10
+ DWMWA_DISALLOW_PEEK = 11
+ DWMWA_EXCLUDED_FROM_PEEK = 12
+ DWMWA_CLOAK = 13
+ DWMWA_CLOAKED = 14
+ DWMWA_FREEZE_REPRESENTATION = 15
+ DWMWA_PASSIVE_UPDATE_MODE = 16
+ DWMWA_USE_HOSTBACKDROPBRUSH = 17
+ DWMWA_USE_IMMERSIVE_DARK_MODE = 20
+ DWMWA_WINDOW_CORNER_PREFERENCE = 33
+ DWMWA_BORDER_COLOR = 34
+ DWMWA_CAPTION_COLOR = 35
+ DWMWA_TEXT_COLOR = 36
+ DWMWA_VISIBLE_FRAME_BORDER_THICKNESS = 37
+)
diff --git a/windows/zsyscall_windows.go b/windows/zsyscall_windows.go
index 68f52c1..7a0d863 100644
--- a/windows/zsyscall_windows.go
+++ b/windows/zsyscall_windows.go
@@ -40,6 +40,7 @@
modadvapi32 = NewLazySystemDLL("advapi32.dll")
modcrypt32 = NewLazySystemDLL("crypt32.dll")
moddnsapi = NewLazySystemDLL("dnsapi.dll")
+ moddwmapi = NewLazySystemDLL("dwmapi.dll")
modiphlpapi = NewLazySystemDLL("iphlpapi.dll")
modkernel32 = NewLazySystemDLL("kernel32.dll")
modmswsock = NewLazySystemDLL("mswsock.dll")
@@ -175,6 +176,8 @@
procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W")
procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W")
procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree")
+ procDwmGetWindowAttribute = moddwmapi.NewProc("DwmGetWindowAttribute")
+ procDwmSetWindowAttribute = moddwmapi.NewProc("DwmSetWindowAttribute")
procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo")
procGetIfEntry = modiphlpapi.NewProc("GetIfEntry")
@@ -1523,6 +1526,22 @@
return
}

+func DwmGetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) {
+ r0, _, _ := syscall.Syscall6(procDwmGetWindowAttribute.Addr(), 4, uintptr(hwnd), uintptr(attribute), uintptr(value), uintptr(size), 0, 0)
+ if r0 != 0 {
+ ret = syscall.Errno(r0)
+ }
+ return
+}
+
+func DwmSetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) {
+ r0, _, _ := syscall.Syscall6(procDwmSetWindowAttribute.Addr(), 4, uintptr(hwnd), uintptr(attribute), uintptr(value), uintptr(size), 0, 0)
+ if r0 != 0 {
+ ret = syscall.Errno(r0)
+ }
+ return
+}
+
func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0)
if r0 != 0 {

To view, visit change 399135. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: sys
Gerrit-Branch: master
Gerrit-Change-Id: I96a68f91f745601e93c0cc21cc4f1f4c5e7d8b9e
Gerrit-Change-Number: 399135
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-MessageType: newchange

Gerrit Bot (Gerrit)

unread,
Sep 12, 2022, 6:14:02 PM9/12/22
to Michael Lelli, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Attention is currently required from: Alex Brainman.

Gerrit Bot uploaded patch set #2 to this change.

View Change

GitHub-Last-Rev: e5413cfa428fc718a6e3d9be801fb972561283af

GitHub-Pull-Request: golang/sys#123
---
M windows/syscall_windows.go
M windows/types_windows.go
M windows/zsyscall_windows.go
3 files changed, 63 insertions(+), 0 deletions(-)

To view, visit change 399135. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: sys
Gerrit-Branch: master
Gerrit-Change-Id: I96a68f91f745601e93c0cc21cc4f1f4c5e7d8b9e
Gerrit-Change-Number: 399135
Gerrit-PatchSet: 2
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
Gerrit-CC: Brad Fitzpatrick <brad...@golang.org>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-CC: Michael Lelli <michae...@steelseries.com>
Gerrit-Attention: Alex Brainman <alex.b...@gmail.com>
Gerrit-MessageType: newpatchset

Bryan Mills (Gerrit)

unread,
Sep 13, 2022, 10:49:24 AM9/13/22
to Gerrit Bot, Michael Lelli, goph...@pubsubhelper.golang.org, Bryan Mills, Alex Brainman, Brad Fitzpatrick, Gopher Robot, golang-co...@googlegroups.com

Attention is currently required from: Alex Brainman.

Patch set 2:Run-TryBot +1Code-Review +1

View Change

    To view, visit change 399135. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: sys
    Gerrit-Branch: master
    Gerrit-Change-Id: I96a68f91f745601e93c0cc21cc4f1f4c5e7d8b9e
    Gerrit-Change-Number: 399135
    Gerrit-PatchSet: 2
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-CC: Brad Fitzpatrick <brad...@golang.org>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Michael Lelli <michae...@steelseries.com>
    Gerrit-Attention: Alex Brainman <alex.b...@gmail.com>
    Gerrit-Comment-Date: Tue, 13 Sep 2022 14:49:20 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Gerrit Bot (Gerrit)

    unread,
    Sep 17, 2022, 6:48:34 PM9/17/22
    to Michael Lelli, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Attention is currently required from: Alex Brainman, Bryan Mills.

    Gerrit Bot uploaded patch set #3 to this change.

    View Change

    The following approvals got outdated and were removed: Run-TryBot+1 by Bryan Mills, TryBot-Result+1 by Gopher Robot

    GitHub-Last-Rev: bdbe2ccb22d4c680511fcacc022ce1e13c445828

    GitHub-Pull-Request: golang/sys#123
    ---
    M windows/syscall_windows.go
    M windows/types_windows.go
    M windows/zsyscall_windows.go
    3 files changed, 63 insertions(+), 0 deletions(-)

    To view, visit change 399135. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: sys
    Gerrit-Branch: master
    Gerrit-Change-Id: I96a68f91f745601e93c0cc21cc4f1f4c5e7d8b9e
    Gerrit-Change-Number: 399135
    Gerrit-PatchSet: 3
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
    Gerrit-CC: Brad Fitzpatrick <brad...@golang.org>
    Gerrit-CC: Michael Lelli <michae...@steelseries.com>
    Gerrit-Attention: Bryan Mills <bcm...@google.com>

    Alex Brainman (Gerrit)

    unread,
    Sep 19, 2022, 4:26:16 AM9/19/22
    to Gerrit Bot, Michael Lelli, goph...@pubsubhelper.golang.org, Gopher Robot, Bryan Mills, Brad Fitzpatrick, golang-co...@googlegroups.com

    Attention is currently required from: Bryan Mills.

    Patch set 3:Code-Review +2

    View Change

    1 comment:

    • Patchset:

      • Patch Set #3:

        LGTM.

        I will go and find another googler +1 and then I will submit.

        Thank you.

        Alex

    To view, visit change 399135. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: sys
    Gerrit-Branch: master
    Gerrit-Change-Id: I96a68f91f745601e93c0cc21cc4f1f4c5e7d8b9e
    Gerrit-Change-Number: 399135
    Gerrit-PatchSet: 3
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
    Gerrit-CC: Brad Fitzpatrick <brad...@golang.org>
    Gerrit-CC: Michael Lelli <michae...@steelseries.com>
    Gerrit-Attention: Bryan Mills <bcm...@google.com>
    Gerrit-Comment-Date: Mon, 19 Sep 2022 08:26:10 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Benny Siegert (Gerrit)

    unread,
    Sep 19, 2022, 4:53:29 AM9/19/22
    to Gerrit Bot, Michael Lelli, goph...@pubsubhelper.golang.org, Benny Siegert, Alex Brainman, Gopher Robot, Bryan Mills, Brad Fitzpatrick, golang-co...@googlegroups.com

    Attention is currently required from: Bryan Mills.

    Patch set 3:Run-TryBot +1Code-Review +2

    View Change

      To view, visit change 399135. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: sys
      Gerrit-Branch: master
      Gerrit-Change-Id: I96a68f91f745601e93c0cc21cc4f1f4c5e7d8b9e
      Gerrit-Change-Number: 399135
      Gerrit-PatchSet: 3
      Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
      Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
      Gerrit-Reviewer: Benny Siegert <bsie...@gmail.com>
      Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
      Gerrit-CC: Brad Fitzpatrick <brad...@golang.org>
      Gerrit-CC: Michael Lelli <michae...@steelseries.com>
      Gerrit-Attention: Bryan Mills <bcm...@google.com>
      Gerrit-Comment-Date: Mon, 19 Sep 2022 08:53:23 +0000

      Benny Siegert (Gerrit)

      unread,
      Sep 19, 2022, 5:18:54 AM9/19/22
      to Gerrit Bot, Michael Lelli, Benny Siegert, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Gopher Robot, Alex Brainman, Bryan Mills, Brad Fitzpatrick, golang-co...@googlegroups.com

      Benny Siegert submitted this change.

      View Change


      Approvals: Alex Brainman: Looks good to me, approved Gopher Robot: TryBots succeeded Benny Siegert: Looks good to me, approved; Run TryBots Bryan Mills: Looks good to me, but someone else must approve
      windows: add DWM window attribute related syscalls

      https://docs.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmgetwindowattribute
      https://docs.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmsetwindowattribute

      Change-Id: I96a68f91f745601e93c0cc21cc4f1f4c5e7d8b9e
      GitHub-Last-Rev: bdbe2ccb22d4c680511fcacc022ce1e13c445828
      GitHub-Pull-Request: golang/sys#123
      Reviewed-on: https://go-review.googlesource.com/c/sys/+/399135
      Reviewed-by: Bryan Mills <bcm...@google.com>
      TryBot-Result: Gopher Robot <go...@golang.org>
      Reviewed-by: Benny Siegert <bsie...@gmail.com>
      Run-TryBot: Benny Siegert <bsie...@gmail.com>
      Reviewed-by: Alex Brainman <alex.b...@gmail.com>

      ---
      M windows/syscall_windows.go
      M windows/types_windows.go
      M windows/zsyscall_windows.go
      3 files changed, 69 insertions(+), 0 deletions(-)

      diff --git a/windows/syscall_windows.go b/windows/syscall_windows.go
      index 29737b2..3f2cbb6 100644
      --- a/windows/syscall_windows.go
      +++ b/windows/syscall_windows.go
      @@ -442,6 +442,10 @@

      //sys RtlAddFunctionTable(functionTable *RUNTIME_FUNCTION, entryCount uint32, baseAddress uintptr) (ret bool) = ntdll.RtlAddFunctionTable
      //sys RtlDeleteFunctionTable(functionTable *RUNTIME_FUNCTION) (ret bool) = ntdll.RtlDeleteFunctionTable

      +// Desktop Window Manager API (Dwmapi)
      +//sys DwmGetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) = dwmapi.DwmGetWindowAttribute
      +//sys DwmSetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) = dwmapi.DwmSetWindowAttribute
      +
      // syscall interface implementation for other packages

      // GetCurrentProcess returns the handle for the current process.
      diff --git a/windows/types_windows.go b/windows/types_windows.go
      index ef489f5..0c4add9 100644
      --- a/windows/types_windows.go
      +++ b/windows/types_windows.go
      @@ -3232,3 +3232,29 @@
      CaretHandle HWND
      CaretRect Rect
      index 6c6f27b..96ba855 100644

      --- a/windows/zsyscall_windows.go
      +++ b/windows/zsyscall_windows.go
      @@ -40,6 +40,7 @@
      modadvapi32 = NewLazySystemDLL("advapi32.dll")
      modcrypt32 = NewLazySystemDLL("crypt32.dll")
      moddnsapi = NewLazySystemDLL("dnsapi.dll")
      + moddwmapi = NewLazySystemDLL("dwmapi.dll")
      modiphlpapi = NewLazySystemDLL("iphlpapi.dll")
      modkernel32 = NewLazySystemDLL("kernel32.dll")
      modmswsock = NewLazySystemDLL("mswsock.dll")
      @@ -175,6 +176,8 @@
      procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W")
      procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W")
      procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree")
      + procDwmGetWindowAttribute = moddwmapi.NewProc("DwmGetWindowAttribute")
      + procDwmSetWindowAttribute = moddwmapi.NewProc("DwmSetWindowAttribute")
      procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
      procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo")
       	procGetBestInterfaceEx                                   = modiphlpapi.NewProc("GetBestInterfaceEx")
      @@ -1534,6 +1537,22 @@

      return
      }

      +func DwmGetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) {
      + r0, _, _ := syscall.Syscall6(procDwmGetWindowAttribute.Addr(), 4, uintptr(hwnd), uintptr(attribute), uintptr(value), uintptr(size), 0, 0)
      + if r0 != 0 {
      + ret = syscall.Errno(r0)
      + }
      + return
      +}
      +
      +func DwmSetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) {
      + r0, _, _ := syscall.Syscall6(procDwmSetWindowAttribute.Addr(), 4, uintptr(hwnd), uintptr(attribute), uintptr(value), uintptr(size), 0, 0)
      + if r0 != 0 {
      + ret = syscall.Errno(r0)
      + }
      + return
      +}
      +
      func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
      r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0)
      if r0 != 0 {

      To view, visit change 399135. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: sys
      Gerrit-Branch: master
      Gerrit-Change-Id: I96a68f91f745601e93c0cc21cc4f1f4c5e7d8b9e
      Gerrit-Change-Number: 399135
      Gerrit-PatchSet: 4
      Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
      Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
      Gerrit-Reviewer: Benny Siegert <bsie...@gmail.com>
      Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
      Gerrit-CC: Brad Fitzpatrick <brad...@golang.org>
      Gerrit-CC: Michael Lelli <michae...@steelseries.com>
      Gerrit-MessageType: merged

      Alex Brainman (Gerrit)

      unread,
      Sep 19, 2022, 7:06:18 AM9/19/22
      to Gerrit Bot, Michael Lelli, Benny Siegert, goph...@pubsubhelper.golang.org, Gopher Robot, Bryan Mills, Brad Fitzpatrick, golang-co...@googlegroups.com

      View Change

      1 comment:

      To view, visit change 399135. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: sys
      Gerrit-Branch: master
      Gerrit-Change-Id: I96a68f91f745601e93c0cc21cc4f1f4c5e7d8b9e
      Gerrit-Change-Number: 399135
      Gerrit-PatchSet: 4
      Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
      Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
      Gerrit-Reviewer: Benny Siegert <bsie...@gmail.com>
      Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
      Gerrit-CC: Brad Fitzpatrick <brad...@golang.org>
      Gerrit-CC: Michael Lelli <michae...@steelseries.com>
      Gerrit-Comment-Date: Mon, 19 Sep 2022 11:06:11 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Gerrit-MessageType: comment
      Reply all
      Reply to author
      Forward
      0 new messages