修正windows下的golint问题

This commit is contained in:
lwch
2021-11-04 15:15:18 +08:00
parent 77f1ab1bde
commit c0c1091f91
7 changed files with 24 additions and 22 deletions

View File

@@ -37,8 +37,8 @@ const (
)
const (
// BI_RGB https://docs.microsoft.com/en-us/previous-versions/dd183376(v=vs.85)
BI_RGB = 0
// DIB_RGB_COLORS https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getdibits
DIB_RGB_COLORS = 0
// BIRGB https://docs.microsoft.com/en-us/previous-versions/dd183376(v=vs.85)
BIRGB = 0
// DIBRGBCOLORS https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getdibits
DIBRGBCOLORS = 0
)

View File

@@ -4,26 +4,26 @@ import "syscall"
var (
libKernel32, _ = syscall.LoadLibrary("kernel32.dll")
// FuncWTSGetActiveConsoleSessionId https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-wtsgetactiveconsolesessionid
FuncWTSGetActiveConsoleSessionId, _ = syscall.GetProcAddress(syscall.Handle(libKernel32), "WTSGetActiveConsoleSessionId")
// FuncWTSGetActiveConsoleSessionID https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-wtsgetactiveconsolesessionid
FuncWTSGetActiveConsoleSessionID, _ = syscall.GetProcAddress(syscall.Handle(libKernel32), "WTSGetActiveConsoleSessionId")
// FuncGlobalAlloc https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globalalloc
FuncGlobalAlloc, _ = syscall.GetProcAddress(syscall.Handle(libKernel32), "GlobalAlloc")
// FuncGlobalFree https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globalfree
FuncGlobalFree, _ = syscall.GetProcAddress(syscall.Handle(libKernel32), "GlobalFree")
)
// PROCESS_ALL_ACCESS https://docs.microsoft.com/en-us/windows/win32/procthread/process-security-and-access-rights
const PROCESS_ALL_ACCESS = 0x1F0FFF
// PROCESSALLACCESS https://docs.microsoft.com/en-us/windows/win32/procthread/process-security-and-access-rights
const PROCESSALLACCESS = 0x1F0FFF
const (
// GHND https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globalalloc
GHND = 0x0042
// GMEM_FIXED https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globalalloc
GMEM_FIXED = 0x0000
// GMEM_MOVEABLE https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globalalloc
GMEM_MOVEABLE = 0x0002
// GMEM_ZEROINIT https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globalalloc
GMEM_ZEROINIT = 0x0040
// GMEMFIXED https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globalalloc
GMEMFIXED = 0x0000
// GMEMMOVEABLE https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globalalloc
GMEMMOVEABLE = 0x0002
// GMEMZEROINIT https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globalalloc
GMEMZEROINIT = 0x0040
// GPTR https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globalalloc
GPTR = 0x0040
)

View File

@@ -65,6 +65,6 @@ type ICONINFO struct {
}
const (
// CURSOR_SHOWING https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-cursorinfo
CURSOR_SHOWING = 0x00000001
// CURSORSHOWING https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-cursorinfo
CURSORSHOWING = 0x00000001
)

View File

@@ -7,6 +7,7 @@ import (
"github.com/lwch/logging"
)
// CADEvent handle ctrl+alt+del event
func (p *Process) CADEvent() {
ok, _, err := syscall.Syscall(define.FuncSendSAS, 1, 0, 0, 0)
if ok == 0 {

View File

@@ -62,13 +62,13 @@ func parseProcessName(exeFile [syscall.MAX_PATH]uint16) string {
}
func getSessionID() uintptr {
id, _, _ := syscall.Syscall(define.FuncWTSGetActiveConsoleSessionId, 0, 0, 0, 0)
id, _, _ := syscall.Syscall(define.FuncWTSGetActiveConsoleSessionID, 0, 0, 0, 0)
return id
}
func getSessionUserTokenWin() windows.Token {
pid := getLogonPid(getSessionID())
process, err := windows.OpenProcess(define.PROCESS_ALL_ACCESS, false, pid)
process, err := windows.OpenProcess(define.PROCESSALLACCESS, false, pid)
if err != nil {
return 0
}

View File

@@ -92,7 +92,7 @@ func (worker *Worker) capture() error {
logging.Error("get cursor info: %v", err)
return nil
}
if curInfo.Flags == define.CURSOR_SHOWING {
if curInfo.Flags == define.CURSORSHOWING {
var info define.ICONINFO
ok, _, err = syscall.Syscall(define.FuncGetIconInfo, 2, uintptr(curInfo.HCursor), uintptr(unsafe.Pointer(&info)), 0)
if ok == 0 {
@@ -110,6 +110,7 @@ func (worker *Worker) capture() error {
return nil
}
// BITMAPINFOHEADER https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapinfoheader
type BITMAPINFOHEADER struct {
BiSize uint32
BiWidth int32
@@ -131,10 +132,10 @@ func (worker *Worker) copyImageData(hdc, bitmap uintptr) {
hdr.BiBitCount = uint16(worker.info.bits)
hdr.BiWidth = int32(worker.info.width)
hdr.BiHeight = int32(-worker.info.height)
hdr.BiCompression = define.BI_RGB
hdr.BiCompression = define.BIRGB
hdr.BiSizeImage = 0
lines, _, err := syscall.Syscall9(define.FuncGetDIBits, 7, hdc, bitmap, 0, uintptr(worker.info.height),
worker.buffer, uintptr(unsafe.Pointer(&hdr)), define.DIB_RGB_COLORS, 0, 0)
worker.buffer, uintptr(unsafe.Pointer(&hdr)), define.DIBRGBCOLORS, 0, 0)
if lines == 0 {
logging.Error("get bits: %v", err)
}

View File

@@ -100,7 +100,7 @@ func (worker *Worker) updateInfo(hdc uintptr) error {
}
func (worker *Worker) updateBuffer() error {
addr, _, err := syscall.Syscall(define.FuncGlobalAlloc, 2, define.GMEM_FIXED, uintptr(worker.info.bits*worker.info.width*worker.info.height/8), 0)
addr, _, err := syscall.Syscall(define.FuncGlobalAlloc, 2, define.GMEMFIXED, uintptr(worker.info.bits*worker.info.width*worker.info.height/8), 0)
if addr == 0 {
return fmt.Errorf("global alloc: %v", err)
}