From 95b3fe1a857a417dc05d145374336c2a121ddddc Mon Sep 17 00:00:00 2001 From: "BitBase [ErgoZ] Riftbit" Date: Sun, 11 Aug 2019 14:32:38 +0300 Subject: [PATCH] big refactoring with back comp broke --- advapi32.go | 17 +++--- gdi32.go | 60 ++++++++++----------- gdiplus.go | 4 ++ kernel32.go | 35 ++++++------ user32.go | 149 +++++++++++++++------------------------------------- utils.go | 1 - 6 files changed, 103 insertions(+), 163 deletions(-) diff --git a/advapi32.go b/advapi32.go index 0650db8..b2d0a9b 100644 --- a/advapi32.go +++ b/advapi32.go @@ -30,7 +30,7 @@ var ( procRegDeleteTree = modadvapi32.NewProc("RegDeleteTreeW") procRegDeleteValue = modadvapi32.NewProc("RegDeleteValueW") procRegEnumKeyEx = modadvapi32.NewProc("RegEnumKeyExW") - procRegGetValue = modadvapi32.NewProc("RegGetValueW") + procRegGetValueW = modadvapi32.NewProc("RegGetValueW") procRegOpenKeyEx = modadvapi32.NewProc("RegOpenKeyExW") procRegSetValueEx = modadvapi32.NewProc("RegSetValueExW") procSetSecurityDescriptorDacl = modadvapi32.NewProc("SetSecurityDescriptorDacl") @@ -117,7 +117,7 @@ func InitializeSecurityDescriptor(rev uint16) (pSecurityDescriptor *SECURITY_DES func RegCreateKey(hKey HKEY, subKey string) HKEY { var result HKEY - ret, _, _ := procRegCreateKeyEx.Call( + _, _, _ = procRegCreateKeyEx.Call( uintptr(hKey), uintptr(pointerStringWithoutError(subKey)), uintptr(0), @@ -127,10 +127,11 @@ func RegCreateKey(hKey HKEY, subKey string) HKEY { uintptr(0), uintptr(unsafe.Pointer(&result)), uintptr(0)) - _ = ret + return result } +// TODO Validate this method!!! may be deprecated parts used func RegOpenKeyEx(hKey HKEY, subKey string, samDesired uint32) HKEY { var result HKEY ret, _, _ := procRegOpenKeyEx.Call( @@ -163,7 +164,7 @@ func RegGetRaw(hKey HKEY, subKey string, value string) []byte { if len(value) > 0 { valptr = pointerStringWithoutError(value) } - procRegGetValue.Call( + procRegGetValueW.Call( uintptr(hKey), uintptr(pointerStringWithoutError(subKey)), uintptr(valptr), @@ -177,7 +178,7 @@ func RegGetRaw(hKey HKEY, subKey string, value string) []byte { } buf := make([]byte, bufLen) - ret, _, _ := procRegGetValue.Call( + ret, _, _ := procRegGetValueW.Call( uintptr(hKey), uintptr(pointerStringWithoutError(subKey)), uintptr(valptr), @@ -255,7 +256,7 @@ func RegSetUint32(hKey HKEY, subKey string, value uint32) (errno int) { func RegGetString(hKey HKEY, subKey string, value string) string { var bufLen uint32 - procRegGetValue.Call( + procRegGetValueW.Call( uintptr(hKey), uintptr(pointerStringWithoutError(subKey)), uintptr(pointerStringWithoutError(value)), @@ -269,7 +270,7 @@ func RegGetString(hKey HKEY, subKey string, value string) string { } buf := make([]uint16, bufLen) - ret, _, _ := procRegGetValue.Call( + ret, _, _ := procRegGetValueW.Call( uintptr(hKey), uintptr(pointerStringWithoutError(subKey)), uintptr(pointerStringWithoutError(value)), @@ -287,7 +288,7 @@ func RegGetString(hKey HKEY, subKey string, value string) string { func RegGetUint32(hKey HKEY, subKey string, value string) (data uint32, errno int) { var dataLen uint32 = uint32(unsafe.Sizeof(data)) - ret, _, _ := procRegGetValue.Call( + ret, _, _ := procRegGetValueW.Call( uintptr(hKey), uintptr(pointerStringWithoutError(subKey)), uintptr(pointerStringWithoutError(value)), diff --git a/gdi32.go b/gdi32.go index 5782fd6..f8500c2 100644 --- a/gdi32.go +++ b/gdi32.go @@ -20,7 +20,7 @@ var ( procCreateBrushIndirect = modgdi32.NewProc("CreateBrushIndirect") procCreateCompatibleBitmap = modgdi32.NewProc("CreateCompatibleBitmap") procCreateCompatibleDC = modgdi32.NewProc("CreateCompatibleDC") - procCreateDC = modgdi32.NewProc("CreateDCW") + procCreateDCW = modgdi32.NewProc("CreateDCW") procCreateDIBSection = modgdi32.NewProc("CreateDIBSection") procCreateEnhMetaFile = modgdi32.NewProc("CreateEnhMetaFileW") procCreateFontIndirect = modgdi32.NewProc("CreateFontIndirectW") @@ -148,10 +148,10 @@ func CloseEnhMetaFile(hdc HDC) HENHMETAFILE { return HENHMETAFILE(ret) } -func CopyEnhMetaFile(hemfSrc HENHMETAFILE, lpszFile *uint16) HENHMETAFILE { +func CopyEnhMetaFile(hEnh HENHMETAFILE, lpFileName string) HENHMETAFILE { ret, _, _ := procCopyEnhMetaFile.Call( - uintptr(hemfSrc), - uintptr(unsafe.Pointer(lpszFile))) + uintptr(hEnh), + uintptr(pointerStringWithoutError(lpFileName))) return HENHMETAFILE(ret) } @@ -174,12 +174,12 @@ func CreateCompatibleDC(hdc HDC) HDC { return HDC(ret) } -func CreateDC(lpszDriver, lpszDevice, lpszOutput *uint16, lpInitData *DEVMODE) HDC { - ret, _, _ := procCreateDC.Call( - uintptr(unsafe.Pointer(lpszDriver)), - uintptr(unsafe.Pointer(lpszDevice)), - uintptr(unsafe.Pointer(lpszOutput)), - uintptr(unsafe.Pointer(lpInitData))) +func CreateDC(pwszDriver, pwszDevice, pszPort string, pdm *DEVMODE) HDC { + ret, _, _ := procCreateDCW.Call( + uintptr(pointerStringWithoutError(pwszDriver)), + uintptr(pointerStringWithoutError(pwszDevice)), + uintptr(pointerStringWithoutError(pszPort)), + uintptr(unsafe.Pointer(pdm))) return HDC(ret) } @@ -196,30 +196,28 @@ func CreateDIBSection(hdc HDC, pbmi *BITMAPINFO, iUsage uint, ppvBits *unsafe.Po return HBITMAP(ret) } -func CreateEnhMetaFile(hdcRef HDC, lpFilename *uint16, lpRect *RECT, lpDescription *uint16) HDC { +func CreateEnhMetaFile(hdc HDC, lpFilename string, lprc *RECT, lpDesc string) HDC { ret, _, _ := procCreateEnhMetaFile.Call( - uintptr(hdcRef), - uintptr(unsafe.Pointer(lpFilename)), - uintptr(unsafe.Pointer(lpRect)), - uintptr(unsafe.Pointer(lpDescription))) + uintptr(hdc), + uintptr(pointerStringWithoutError(lpFilename)), + uintptr(unsafe.Pointer(lprc)), + uintptr(pointerStringWithoutError(lpDesc))) return HDC(ret) } -func CreateIC(lpszDriver, lpszDevice, lpszOutput *uint16, lpdvmInit *DEVMODE) HDC { +func CreateIC(pszDriver, pszDevice string, pdm *DEVMODE) HDC { ret, _, _ := procCreateIC.Call( - uintptr(unsafe.Pointer(lpszDriver)), - uintptr(unsafe.Pointer(lpszDevice)), - uintptr(unsafe.Pointer(lpszOutput)), - uintptr(unsafe.Pointer(lpdvmInit))) + uintptr(pointerStringWithoutError(pszDriver)), + uintptr(pointerStringWithoutError(pszDevice)), + uintptr(nil), + uintptr(unsafe.Pointer(pdm))) return HDC(ret) } func DeleteDC(hdc HDC) bool { - ret, _, _ := procDeleteDC.Call( - uintptr(hdc)) - + ret, _, _ := procDeleteDC.Call(uintptr(hdc)) return ret != 0 } @@ -266,9 +264,9 @@ func ExtCreatePen(dwPenStyle, dwWidth uint, lplb *LOGBRUSH, dwStyleCount uint, l return HPEN(ret) } -func GetEnhMetaFile(lpszMetaFile *uint16) HENHMETAFILE { +func GetEnhMetaFile(lpName string) HENHMETAFILE { ret, _, _ := procGetEnhMetaFile.Call( - uintptr(unsafe.Pointer(lpszMetaFile))) + uintptr(pointerStringWithoutError(lpName))) return HENHMETAFILE(ret) } @@ -298,25 +296,25 @@ func GetStockObject(fnObject int) HGDIOBJ { return HGDIOBJ(ret) } -func GetTextExtentExPoint(hdc HDC, lpszStr *uint16, cchString, nMaxExtent int, lpnFit, alpDx *int, lpSize *SIZE) bool { +func GetTextExtentExPoint(hdc HDC, lpszString string, cchString, nMaxExtent int, lpnFit, lpnDx *int, lpSize *SIZE) bool { ret, _, _ := procGetTextExtentExPoint.Call( uintptr(hdc), - uintptr(unsafe.Pointer(lpszStr)), + uintptr(pointerStringWithoutError(lpszString)), uintptr(cchString), uintptr(nMaxExtent), uintptr(unsafe.Pointer(lpnFit)), - uintptr(unsafe.Pointer(alpDx)), + uintptr(unsafe.Pointer(lpnDx)), uintptr(unsafe.Pointer(lpSize))) return ret != 0 } -func GetTextExtentPoint32(hdc HDC, lpString *uint16, c int, lpSize *SIZE) bool { +func GetTextExtentPoint32(hdc HDC, lpString string, c int, psizl *SIZE) bool { ret, _, _ := procGetTextExtentPoint32.Call( uintptr(hdc), - uintptr(unsafe.Pointer(lpString)), + uintptr(pointerStringWithoutError(lpString)), uintptr(c), - uintptr(unsafe.Pointer(lpSize))) + uintptr(unsafe.Pointer(psizl))) return ret != 0 } diff --git a/gdiplus.go b/gdiplus.go index 9190ef8..24a279e 100644 --- a/gdiplus.go +++ b/gdiplus.go @@ -86,6 +86,9 @@ func GetGpStatus(s int32) string { return "Unknown Status Value" } +// TODO REFACTOR THIS LIBRARY +// TODO See https://docs.microsoft.com/en-us/windows/win32/gdiplus/-gdiplus-func-functions + var ( token uintptr @@ -114,6 +117,7 @@ func GdipCreateBitmapFromFile(filename string) (*uintptr, error) { return bitmap, nil } +// todo fix this method! func GdipCreateBitmapFromResource(instance HINSTANCE, resId *uint16) (*uintptr, error) { var bitmap *uintptr ret, _, _ := procGdipCreateBitmapFromResource.Call( diff --git a/kernel32.go b/kernel32.go index b96260d..174ecf6 100644 --- a/kernel32.go +++ b/kernel32.go @@ -218,33 +218,38 @@ func VirtualProtect(lpAddress uintptr, dwSize int, flNewProtect int, lpflOldProt } // https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx -func CreateProcessA(lpApplicationName *string, +func CreateProcessA(lpApplicationName string, lpCommandLine string, lpProcessAttributes *syscall.SecurityAttributes, lpThreadAttributes *syscall.SecurityAttributes, bInheritHandles bool, dwCreationFlags uint32, - lpEnvironment *string, - lpCurrentDirectory *uint16, + lpEnvironment string, + lpCurrentDirectory string, lpStartupInfo *syscall.StartupInfo, - lpProcessInformation *syscall.ProcessInformation) { + lpProcessInformation *syscall.ProcessInformation) (bool, error) { inherit := 0 if bInheritHandles { inherit = 1 } - procCreateProcessA.Call( - uintptr(pointerStringWithoutError(*lpApplicationName)), + ret, _, err := procCreateProcessA.Call( + uintptr(pointerStringWithoutError(lpApplicationName)), uintptr(pointerStringWithoutError(lpCommandLine)), uintptr(unsafe.Pointer(lpProcessAttributes)), uintptr(unsafe.Pointer(lpThreadAttributes)), uintptr(inherit), uintptr(dwCreationFlags), - uintptr(unsafe.Pointer(lpEnvironment)), - uintptr(unsafe.Pointer(lpCurrentDirectory)), + uintptr(pointerStringWithoutError(lpEnvironment)), + uintptr(pointerStringWithoutError(lpCurrentDirectory)), uintptr(unsafe.Pointer(lpStartupInfo)), uintptr(unsafe.Pointer(lpProcessInformation))) + + if ret == 0 && err.(syscall.Errno) != ERROR_SUCCESS { + return false, err + } + return ret != 0, nil } // https://msdn.microsoft.com/en-us/library/windows/desktop/aa366890(v=vs.85).aspx @@ -367,16 +372,16 @@ func GetUserDefaultLCID() uint32 { return uint32(ret) } -func Lstrlen(lpString *uint16) int { - ret, _, _ := procLstrlen.Call(uintptr(unsafe.Pointer(lpString))) +func Lstrlen(lpString string) int { + ret, _, _ := procLstrlen.Call(uintptr(pointerStringWithoutError(lpString))) return int(ret) } -func Lstrcpy(buf []uint16, lpString *uint16) { +func Lstrcpy(buf []uint16, lpString string) { procLstrcpy.Call( uintptr(unsafe.Pointer(&buf[0])), - uintptr(unsafe.Pointer(lpString))) + uintptr(pointerStringWithoutError(lpString))) } func GlobalAlloc(uFlags uint, dwBytes uint32) HGLOBAL { @@ -422,11 +427,11 @@ func MoveMemory(destination, source unsafe.Pointer, length uint32) { uintptr(length)) } -func FindResource(hModule HMODULE, lpName, lpType *uint16) (HRSRC, error) { +func FindResource(hModule HMODULE, lpName, lpType string) (HRSRC, error) { ret, _, _ := procFindResource.Call( uintptr(hModule), - uintptr(unsafe.Pointer(lpName)), - uintptr(unsafe.Pointer(lpType))) + uintptr(pointerStringWithoutError(lpName)), + uintptr(pointerStringWithoutError(lpType))) if ret == 0 { return 0, syscall.GetLastError() diff --git a/user32.go b/user32.go index 3e37f74..94b4cf0 100644 --- a/user32.go +++ b/user32.go @@ -179,81 +179,55 @@ func SetForegroundWindow(hwnd HWND) bool { } // https://github.com/AllenDang/w32/pull/62/commits/bf59645b86663a54dffb94ca82683cc0610a6de3 -func FindWindowExW(hwndParent, hwndChildAfter HWND, className, windowName *uint16) HWND { +func FindWindowExW(hWndParent, hWndChildAfter HWND, lpszClass, lpszWindow string) HWND { ret, _, _ := procFindWindowExW.Call( - uintptr(hwndParent), - uintptr(hwndChildAfter), - uintptr(unsafe.Pointer(className)), - uintptr(unsafe.Pointer(windowName))) + uintptr(hWndParent), + uintptr(hWndChildAfter), + uintptr(pointerStringWithoutError(lpszClass)), + uintptr(pointerStringWithoutError(lpszWindow))) return HWND(ret) } -func FindWindowExS(hwndParent, hwndChildAfter HWND, className, windowName *string) HWND { - var class *uint16 = nil - if className != nil { - class, _ = syscall.UTF16PtrFromString(*className) - } - var window *uint16 = nil - if windowName != nil { - window, _ = syscall.UTF16PtrFromString(*windowName) - } - return FindWindowExW(hwndParent, hwndChildAfter, class, window) -} - // https://github.com/AllenDang/w32/pull/62/commits/bf59645b86663a54dffb94ca82683cc0610a6de3 -func FindWindowW(className, windowName *uint16) HWND { +func FindWindowW(lpClassName, lpWindowName string) HWND { ret, _, _ := procFindWindowW.Call( - uintptr(unsafe.Pointer(className)), - uintptr(unsafe.Pointer(windowName))) + uintptr(pointerStringWithoutError(lpClassName)), + uintptr(pointerStringWithoutError(lpWindowName))) return HWND(ret) } -func FindWindowS(className, windowName *string) HWND { - var class *uint16 = nil - if className != nil { - class, _ = syscall.UTF16PtrFromString(*className) - } - var window *uint16 = nil - if windowName != nil { - window, _ = syscall.UTF16PtrFromString(*windowName) - } - return FindWindowW(class, window) -} - // https://github.com/AllenDang/w32/pull/62/commits/bf59645b86663a54dffb94ca82683cc0610a6de3 func EnumChildWindows(hWndParent HWND, lpEnumFunc WNDENUMPROC, lParam LPARAM) bool { ret, _, _ := procEnumChildWindows.Call( uintptr(hWndParent), - uintptr(syscall.NewCallback(lpEnumFunc)), + syscall.NewCallback(lpEnumFunc), uintptr(lParam), ) return ret != 0 } -func GetWindowTextW(hwnd syscall.Handle, str *uint16, maxCount int32) (len int32, err error) { - r0, _, e1 := syscall.Syscall(procGetWindowTextW.Addr(), 3, uintptr(hwnd), uintptr(unsafe.Pointer(str)), uintptr(maxCount)) - len = int32(r0) +func GetWindowTextW(hwnd syscall.Handle, str string, maxCount int32) (int32, error) { + r0, _, e1 := procGetWindowTextW.Call(uintptr(hwnd), uintptr(pointerStringWithoutError(str)), uintptr(maxCount)) + len := int32(r0) if len == 0 { - if e1 != 0 { - err = error(e1) + if !IsErrSuccess(e1) { + return 0, e1 } else { - err = syscall.EINVAL + return 0, syscall.EINVAL } } - return + return len, nil } -func GetForegroundWindow() (hwnd syscall.Handle, err error) { - r0, _, e1 := syscall.Syscall(procGetForegroundWindow.Addr(), 0, 0, 0, 0) - if e1 != 0 { - err = error(e1) - return +func GetForegroundWindow() (HWND, error) { + r0, _, e1 := procGetForegroundWindow.Call() + if !IsErrSuccess(e1) { + return HWND(nil), e1 } - hwnd = syscall.Handle(r0) - return + return HWND(r0), nil } func RegisterClassEx(wndClassEx *WNDCLASSEX) ATOM { @@ -261,40 +235,24 @@ func RegisterClassEx(wndClassEx *WNDCLASSEX) ATOM { return ATOM(ret) } -func LoadIcon(instance HINSTANCE, iconName *uint16) HICON { +func LoadIcon(instance HINSTANCE, iconName string) HICON { ret, _, _ := procLoadIcon.Call( uintptr(instance), - uintptr(unsafe.Pointer(iconName))) + uintptr(pointerStringWithoutError(iconName))) return HICON(ret) } -func LoadIconS(instance HINSTANCE, iconName *string) HICON { - var icon *uint16 = nil - if iconName != nil { - icon, _ = syscall.UTF16PtrFromString(*iconName) - } - return LoadIcon(instance, icon) -} - -func LoadCursor(instance HINSTANCE, cursorName *uint16) HCURSOR { +func LoadCursor(instance HINSTANCE, cursorName string) HCURSOR { ret, _, _ := procLoadCursor.Call( uintptr(instance), - uintptr(unsafe.Pointer(cursorName))) + uintptr(pointerStringWithoutError(cursorName))) return HCURSOR(ret) } -func LoadCursorS(instance HINSTANCE, cursorName *string) HCURSOR { - var cursor *uint16 = nil - if cursorName != nil { - cursor, _ = syscall.UTF16PtrFromString(*cursorName) - } - return LoadCursor(instance, cursor) -} - func ShowWindow(hwnd HWND, cmdshow int) bool { ret, _, _ := procShowWindow.Call( uintptr(hwnd), @@ -310,13 +268,13 @@ func UpdateWindow(hwnd HWND) bool { return ret != 0 } -func CreateWindowEx(exStyle uint, className, windowName *uint16, +func CreateWindowEx(exStyle uint, className, windowName string, style uint, x, y, width, height int, parent HWND, menu HMENU, instance HINSTANCE, param unsafe.Pointer) HWND { ret, _, _ := procCreateWindowEx.Call( uintptr(exStyle), - uintptr(unsafe.Pointer(className)), - uintptr(unsafe.Pointer(windowName)), + uintptr(pointerStringWithoutError(className)), + uintptr(pointerStringWithoutError(windowName)), uintptr(style), uintptr(x), uintptr(y), @@ -330,33 +288,6 @@ func CreateWindowEx(exStyle uint, className, windowName *uint16, return HWND(ret) } -func CreateWindowExS(exStyle uint, className, windowName *string, - style uint, x, y, width, height int, parent HWND, menu HMENU, - instance HINSTANCE, param unsafe.Pointer) HWND { - var class *uint16 = nil - if className != nil { - class, _ = syscall.UTF16PtrFromString(*className) - } - var window *uint16 = nil - if windowName != nil { - window, _ = syscall.UTF16PtrFromString(*windowName) - } - return CreateWindowEx( - exStyle, - class, - window, - style, - x, - y, - width, - height, - parent, - menu, - instance, - param, - ) -} - func AdjustWindowRectEx(rect *RECT, style uint, menu bool, exStyle uint) bool { ret, _, _ := procAdjustWindowRectEx.Call( uintptr(unsafe.Pointer(rect)), @@ -759,10 +690,10 @@ func UnionRect(dst, src1, src2 *RECT) bool { return ret != 0 } -func CreateDialog(hInstance HINSTANCE, lpTemplate *uint16, hWndParent HWND, lpDialogProc uintptr) HWND { +func CreateDialog(hInstance HINSTANCE, lpTemplate string, hWndParent HWND, lpDialogProc uintptr) HWND { ret, _, _ := procCreateDialogParam.Call( uintptr(hInstance), - uintptr(unsafe.Pointer(lpTemplate)), + uintptr(pointerStringWithoutError(lpTemplate)), uintptr(hWndParent), lpDialogProc, 0) @@ -770,10 +701,10 @@ func CreateDialog(hInstance HINSTANCE, lpTemplate *uint16, hWndParent HWND, lpDi return HWND(ret) } -func DialogBox(hInstance HINSTANCE, lpTemplateName *uint16, hWndParent HWND, lpDialogProc uintptr) int { +func DialogBox(hInstance HINSTANCE, lpTemplateName string, hWndParent HWND, lpDialogProc uintptr) int { ret, _, _ := procDialogBoxParam.Call( uintptr(hInstance), - uintptr(unsafe.Pointer(lpTemplateName)), + uintptr(pointerStringWithoutError(lpTemplateName)), uintptr(hWndParent), lpDialogProc, 0) @@ -993,14 +924,16 @@ func GetKeyState(vKey int) (keyState uint16) { return uint16(ret) } -func ToAscii(uVirtKey, uScanCode uint, lpKeyState *byte, lpChar *uint16, uFlags uint) int { +func ToAscii(uVirtKey, uScanCode uint, lpKeyState *byte, uFlags uint) (string, int) { + var lpCharLP *uint16 ret, _, _ := procToAscii.Call( uintptr(uVirtKey), uintptr(uScanCode), uintptr(unsafe.Pointer(lpKeyState)), - uintptr(unsafe.Pointer(lpChar)), + uintptr(unsafe.Pointer(lpCharLP)), uintptr(uFlags)) - return int(ret) + + return UTF16PtrToString(lpCharLP), int(ret) } func SwapMouseButton(fSwap bool) bool { @@ -1093,9 +1026,9 @@ func EnumDisplayMonitors(hdc HDC, clip *RECT, fnEnum, dwData uintptr) bool { return ret != 0 } -func EnumDisplaySettingsEx(szDeviceName *uint16, iModeNum uint32, devMode *DEVMODE, dwFlags uint32) bool { +func EnumDisplaySettingsEx(szDeviceName string, iModeNum uint32, devMode *DEVMODE, dwFlags uint32) bool { ret, _, _ := procEnumDisplaySettingsEx.Call( - uintptr(unsafe.Pointer(szDeviceName)), + uintptr(pointerStringWithoutError(szDeviceName)), uintptr(iModeNum), uintptr(unsafe.Pointer(devMode)), uintptr(dwFlags), @@ -1103,9 +1036,9 @@ func EnumDisplaySettingsEx(szDeviceName *uint16, iModeNum uint32, devMode *DEVMO return ret != 0 } -func ChangeDisplaySettingsEx(szDeviceName *uint16, devMode *DEVMODE, hwnd HWND, dwFlags uint32, lParam uintptr) int32 { +func ChangeDisplaySettingsEx(szDeviceName string, devMode *DEVMODE, hwnd HWND, dwFlags uint32, lParam uintptr) int32 { ret, _, _ := procChangeDisplaySettingsEx.Call( - uintptr(unsafe.Pointer(szDeviceName)), + uintptr(pointerStringWithoutError(szDeviceName)), uintptr(unsafe.Pointer(devMode)), uintptr(hwnd), uintptr(dwFlags), diff --git a/utils.go b/utils.go index c11334b..45e2d09 100644 --- a/utils.go +++ b/utils.go @@ -36,7 +36,6 @@ func BoolToBOOL(value bool) BOOL { if value { return 1 } - return 0 }