func AllocateAndInitializeSid(identifierAuthority *SID_IDENTIFIER_AUTHORITY, subAuthorityCount byte, subAuthority0 uint32, subAuthority1 uint32, subAuthority2 uint32, subAuthority3 uint32, subAuthority4 uint32, subAuthority5 uint32, subAuthority6 uint32, subAuthority7 uint32, sid **SID) error { r1, _, e1 := syscall.Syscall12( procAllocateAndInitializeSid.Addr(), 11, uintptr(unsafe.Pointer(identifierAuthority)), uintptr(subAuthorityCount), uintptr(subAuthority0), uintptr(subAuthority1), uintptr(subAuthority2), uintptr(subAuthority3), uintptr(subAuthority4), uintptr(subAuthority5), uintptr(subAuthority6), uintptr(subAuthority7), uintptr(unsafe.Pointer(sid)), 0) if r1 == 0 { if e1 != ERROR_SUCCESS { return e1 } else { return syscall.EINVAL } } return nil }
func CreateProcess(applicationName *uint16, commandLine *uint16, processAttributes *SECURITY_ATTRIBUTES, threadAttributes *SECURITY_ATTRIBUTES, inheritHandles bool, creationFlags uint32, environment *byte, currentDirectory *uint16, startupInfo *STARTUPINFO, processInformation *PROCESS_INFORMATION) error { var inheritHandlesRaw int32 if inheritHandles { inheritHandlesRaw = 1 } else { inheritHandlesRaw = 0 } r1, _, e1 := syscall.Syscall12( procCreateProcessW.Addr(), 10, uintptr(unsafe.Pointer(applicationName)), uintptr(unsafe.Pointer(commandLine)), uintptr(unsafe.Pointer(processAttributes)), uintptr(unsafe.Pointer(threadAttributes)), uintptr(inheritHandlesRaw), uintptr(creationFlags), uintptr(unsafe.Pointer(environment)), uintptr(unsafe.Pointer(currentDirectory)), uintptr(unsafe.Pointer(startupInfo)), uintptr(unsafe.Pointer(processInformation)), 0, 0) if r1 == 0 { if e1 != ERROR_SUCCESS { return e1 } else { return syscall.EINVAL } } return nil }
func ChangeServiceConfig(service syscall.Handle, serviceType uint32, startType uint32, errorControl uint32, binaryPathName *uint16, loadOrderGroup *uint16, tagId *uint32, dependencies *uint16, serviceStartName *uint16, password *uint16, displayName *uint16) error { r1, _, e1 := syscall.Syscall12( procChangeServiceConfigW.Addr(), 11, uintptr(service), uintptr(serviceType), uintptr(startType), uintptr(errorControl), uintptr(unsafe.Pointer(binaryPathName)), uintptr(unsafe.Pointer(loadOrderGroup)), uintptr(unsafe.Pointer(tagId)), uintptr(unsafe.Pointer(dependencies)), uintptr(unsafe.Pointer(serviceStartName)), uintptr(unsafe.Pointer(password)), uintptr(unsafe.Pointer(displayName)), 0) if r1 == 0 { if e1 != ERROR_SUCCESS { return e1 } else { return syscall.EINVAL } } return nil }
func _AlphaBlend(dcdest syscall.Handle, xoriginDest int32, yoriginDest int32, wDest int32, hDest int32, dcsrc syscall.Handle, xoriginSrc int32, yoriginSrc int32, wsrc int32, hsrc int32, ftn uintptr) (err error) { r1, _, e1 := syscall.Syscall12(procAlphaBlend.Addr(), 11, uintptr(dcdest), uintptr(xoriginDest), uintptr(yoriginDest), uintptr(wDest), uintptr(hDest), uintptr(dcsrc), uintptr(xoriginSrc), uintptr(yoriginSrc), uintptr(wsrc), uintptr(hsrc), uintptr(ftn), 0) if r1 == 0 { if e1 != 0 { err = error(e1) } else { err = syscall.EINVAL } } return }
func enumServicesStatus(h windows.Handle, InfoLevel SC_ENUM_TYPE, dwServiceType uint32, dwServiceState uint32, lpServices uintptr, cbBufSize uint32, pcbBytesNeeded *uint32, lpServicesReturned *uint32, lpResumeHandle *uint32, pszGroupName *uint32) (err error) { r1, _, e1 := syscall.Syscall12(procEnumServicesStatusExW.Addr(), 10, uintptr(h), uintptr(InfoLevel), uintptr(dwServiceType), uintptr(dwServiceState), uintptr(lpServices), uintptr(cbBufSize), uintptr(unsafe.Pointer(pcbBytesNeeded)), uintptr(unsafe.Pointer(lpServicesReturned)), uintptr(unsafe.Pointer(lpResumeHandle)), uintptr(unsafe.Pointer(pszGroupName)), 0, 0) if r1 == 0 { if e1 != 0 { err = error(e1) } else { err = syscall.EINVAL } } return }
func gdiAlphaBlend(hdcDest Handle, xoriginDest int32, yoriginDest int32, wDest int32, hDest int32, hdcSrc Handle, xoriginSrc int32, yoriginSrc int32, wSrc int32, hSrc int32, ftn uint32) (err error) { r1, _, e1 := syscall.Syscall12(procGdiAplhaBlend.Addr(), 11, uintptr(hdcDest), uintptr(xoriginDest), uintptr(yoriginDest), uintptr(wDest), uintptr(hDest), uintptr(hdcSrc), uintptr(xoriginSrc), uintptr(yoriginSrc), uintptr(wSrc), uintptr(hSrc), uintptr(ftn), 0) if r1 == 0 { if e1 != 0 { err = error(e1) } else { err = syscall.EINVAL } } return }
func AllocateAndInitializeSid(identAuth *SidIdentifierAuthority, subAuth byte, subAuth0 uint32, subAuth1 uint32, subAuth2 uint32, subAuth3 uint32, subAuth4 uint32, subAuth5 uint32, subAuth6 uint32, subAuth7 uint32, sid **syscall.SID) (err error) { r1, _, e1 := syscall.Syscall12(procAllocateAndInitializeSid.Addr(), 11, uintptr(unsafe.Pointer(identAuth)), uintptr(subAuth), uintptr(subAuth0), uintptr(subAuth1), uintptr(subAuth2), uintptr(subAuth3), uintptr(subAuth4), uintptr(subAuth5), uintptr(subAuth6), uintptr(subAuth7), uintptr(unsafe.Pointer(sid)), 0) if r1 == 0 { if e1 != 0 { err = error(e1) } else { err = syscall.EINVAL } } return }
func Call(proc uintptr, args ...uintptr) (r1, r2 uintptr, lastErr error) { addr := proc switch len(args) { case 0: return syscall.Syscall(addr, uintptr(len(args)), 0, 0, 0) case 1: return syscall.Syscall(addr, uintptr(len(args)), args[0], 0, 0) case 2: return syscall.Syscall(addr, uintptr(len(args)), args[0], args[1], 0) case 3: return syscall.Syscall(addr, uintptr(len(args)), args[0], args[1], args[2]) case 4: return syscall.Syscall6(addr, uintptr(len(args)), args[0], args[1], args[2], args[3], 0, 0) case 5: return syscall.Syscall6(addr, uintptr(len(args)), args[0], args[1], args[2], args[3], args[4], 0) case 6: return syscall.Syscall6(addr, uintptr(len(args)), args[0], args[1], args[2], args[3], args[4], args[5]) case 7: return syscall.Syscall9(addr, uintptr(len(args)), args[0], args[1], args[2], args[3], args[4], args[5], args[6], 0, 0) case 8: return syscall.Syscall9(addr, uintptr(len(args)), args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], 0) case 9: return syscall.Syscall9(addr, uintptr(len(args)), args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]) case 10: return syscall.Syscall12(addr, uintptr(len(args)), args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], 0, 0) case 11: return syscall.Syscall12(addr, uintptr(len(args)), args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], 0) case 12: return syscall.Syscall12(addr, uintptr(len(args)), args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11]) case 13: return syscall.Syscall15(addr, uintptr(len(args)), args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11], args[12], 0, 0) case 14: return syscall.Syscall15(addr, uintptr(len(args)), args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11], args[12], args[13], 0) case 15: return syscall.Syscall15(addr, uintptr(len(args)), args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11], args[12], args[13], args[14]) default: panic(fmt.Sprintf("Call \"%d\" with too many arguments @ %d.", proc, len(args))) } return }
func CreateWindowEx(exstyle uint32, classname *uint16, windowname *uint16, style uint32, x int32, y int32, width int32, height int32, wndparent uint32, menu uint32, instance uint32, param uintptr) (hwnd uint32, err syscall.Errno) { 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 = uint32(r0) if hwnd == 0 { if e1 != 0 { err = syscall.Errno(e1) } else { err = syscall.EINVAL } } return }
func _CreateWindowEx(exstyle uint32, className *uint16, windowText *uint16, style uint32, x int32, y int32, width int32, height int32, parent syscall.Handle, menu syscall.Handle, hInstance syscall.Handle, lpParam uintptr) (hwnd syscall.Handle, err error) { r0, _, e1 := syscall.Syscall12(procCreateWindowExW.Addr(), 12, uintptr(exstyle), uintptr(unsafe.Pointer(className)), uintptr(unsafe.Pointer(windowText)), uintptr(style), uintptr(x), uintptr(y), uintptr(width), uintptr(height), uintptr(parent), uintptr(menu), uintptr(hInstance), uintptr(lpParam)) hwnd = syscall.Handle(r0) if hwnd == 0 { if e1 != 0 { err = error(e1) } else { err = syscall.EINVAL } } return }
func CreateWindowEx(exStyle uint32, className *uint16, windowName *uint16, style uint32, x int, y int, width int, height int, wndParent Handle, menu Handle, instance Handle, param uintptr) (hwnd 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)) hwnd = Handle(r0) if hwnd == 0 { if e1 != 0 { err = error(e1) } else { err = syscall.EINVAL } } return }
// Call executes procedure p with arguments a. It will panic, if more then 15 arguments // are supplied. // // The returned error is always non-nil, constructed from the result of GetLastError. // Callers must inspect the primary return value to decide whether an error occurred // (according to the semantics of the specific function being called) before consulting // the error. The error will be guaranteed to contain windows.Errno. func (p *Proc) Call(a ...uintptr) (r1, r2 uintptr, lastErr error) { switch len(a) { case 0: return syscall.Syscall(p.Addr(), uintptr(len(a)), 0, 0, 0) case 1: return syscall.Syscall(p.Addr(), uintptr(len(a)), a[0], 0, 0) case 2: return syscall.Syscall(p.Addr(), uintptr(len(a)), a[0], a[1], 0) case 3: return syscall.Syscall(p.Addr(), uintptr(len(a)), a[0], a[1], a[2]) case 4: return syscall.Syscall6(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], 0, 0) case 5: return syscall.Syscall6(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], 0) case 6: return syscall.Syscall6(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5]) case 7: return syscall.Syscall9(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], 0, 0) case 8: return syscall.Syscall9(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], 0) case 9: return syscall.Syscall9(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]) case 10: return syscall.Syscall12(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], 0, 0) case 11: return syscall.Syscall12(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], 0) case 12: return syscall.Syscall12(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11]) case 13: return syscall.Syscall15(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], 0, 0) case 14: return syscall.Syscall15(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], 0) case 15: return syscall.Syscall15(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14]) default: panic("Call " + p.Name + " with too many arguments " + itoa(len(a)) + ".") } return }
func (auth *SSPIAuth) NextBytes(bytes []byte) ([]byte, error) { var in_buf, out_buf SecBuffer var in_desc, out_desc SecBufferDesc in_desc.ulVersion = SECBUFFER_VERSION in_desc.cBuffers = 1 in_desc.pBuffers = &in_buf out_desc.ulVersion = SECBUFFER_VERSION out_desc.cBuffers = 1 out_desc.pBuffers = &out_buf in_buf.BufferType = SECBUFFER_TOKEN in_buf.pvBuffer = &bytes[0] in_buf.cbBuffer = uint32(len(bytes)) outbuf := make([]byte, NTLMBUF_LEN) out_buf.BufferType = SECBUFFER_TOKEN out_buf.pvBuffer = &outbuf[0] out_buf.cbBuffer = NTLMBUF_LEN var attrs uint32 var ts TimeStamp sec_ok, _, _ := syscall.Syscall12(sec_fn.InitializeSecurityContext, 12, uintptr(unsafe.Pointer(&auth.cred)), uintptr(unsafe.Pointer(&auth.ctxt)), uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(auth.Service))), ISC_REQ, 0, SECURITY_NETWORK_DREP, uintptr(unsafe.Pointer(&in_desc)), 0, uintptr(unsafe.Pointer(&auth.ctxt)), uintptr(unsafe.Pointer(&out_desc)), uintptr(unsafe.Pointer(&attrs)), uintptr(unsafe.Pointer(&ts))) if sec_ok == SEC_I_COMPLETE_AND_CONTINUE || sec_ok == SEC_I_COMPLETE_NEEDED { syscall.Syscall6(sec_fn.CompleteAuthToken, 2, uintptr(unsafe.Pointer(&auth.ctxt)), uintptr(unsafe.Pointer(&out_desc)), 0, 0, 0, 0) } else if sec_ok != SEC_E_OK && sec_ok != SEC_I_CONTINUE_NEEDED { return nil, fmt.Errorf("NextBytes InitializeSecurityContext failed %x", sec_ok) } return outbuf[:out_buf.cbBuffer], nil }
func (p comProc) Call(a ...uintptr) (r1, r2 uintptr, lastErr syscall.Errno) { switch len(a) { case 0: return syscall.Syscall(uintptr(p), uintptr(len(a)), 0, 0, 0) case 1: return syscall.Syscall(uintptr(p), uintptr(len(a)), a[0], 0, 0) case 2: return syscall.Syscall(uintptr(p), uintptr(len(a)), a[0], a[1], 0) case 3: return syscall.Syscall(uintptr(p), uintptr(len(a)), a[0], a[1], a[2]) case 4: return syscall.Syscall6(uintptr(p), uintptr(len(a)), a[0], a[1], a[2], a[3], 0, 0) case 5: return syscall.Syscall6(uintptr(p), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], 0) case 6: return syscall.Syscall6(uintptr(p), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5]) case 7: return syscall.Syscall9(uintptr(p), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], 0, 0) case 8: return syscall.Syscall9(uintptr(p), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], 0) case 9: return syscall.Syscall9(uintptr(p), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]) case 10: return syscall.Syscall12(uintptr(p), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], 0, 0) case 11: return syscall.Syscall12(uintptr(p), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], 0) case 12: return syscall.Syscall12(uintptr(p), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11]) case 13: return syscall.Syscall15(uintptr(p), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], 0, 0) case 14: return syscall.Syscall15(uintptr(p), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], 0) case 15: return syscall.Syscall15(uintptr(p), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14]) } panic("too many arguments") }
//为调用DLL中的方法提供一个统一的接口 func CallProc(handle uintptr, args ...uintptr) (r1, r2 uintptr, err syscall.Errno) { l := uintptr(len(args)) switch { case l <= 3: tmp := make([]uintptr, 3) for i, v := range args { tmp[i] = v } return syscall.Syscall(handle, l, tmp[0], tmp[1], tmp[2]) case l <= 6: tmp := make([]uintptr, 6) for i, v := range args { tmp[i] = v } return syscall.Syscall6(handle, l, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5]) case l <= 9: tmp := make([]uintptr, 9) for i, v := range args { tmp[i] = v } return syscall.Syscall9(handle, l, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6], tmp[7], tmp[8]) case l <= 12: tmp := make([]uintptr, 12) for i, v := range args { tmp[i] = v } return syscall.Syscall12(handle, l, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6], tmp[7], tmp[8], tmp[9], tmp[10], tmp[11]) case l <= 15: tmp := make([]uintptr, 15) for i, v := range args { tmp[i] = v } return syscall.Syscall15(handle, l, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6], tmp[7], tmp[8], tmp[9], tmp[10], tmp[11], tmp[12], tmp[13], tmp[14]) default: return uintptr(0), uintptr(0), syscall.E2BIG } }
func CreateWindowEx(dwExStyle uint32, lpClassName, lpWindowName *uint16, dwStyle uint32, x, y, nWidth, nHeight int32, hWndParent HWND, hMenu HMENU, hInstance HINSTANCE, lpParam unsafe.Pointer) HWND { ret, _, _ := syscall.Syscall12(createWindowEx, 12, uintptr(dwExStyle), uintptr(unsafe.Pointer(lpClassName)), uintptr(unsafe.Pointer(lpWindowName)), uintptr(dwStyle), uintptr(x), uintptr(y), uintptr(nWidth), uintptr(nHeight), uintptr(hWndParent), uintptr(hMenu), uintptr(hInstance), uintptr(lpParam)) return HWND(ret) }
func StretchBlt(hdcDest HDC, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest int32, hdcSrc HDC, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc int32, dwRop uint32) bool { ret, _, _ := syscall.Syscall12(stretchBlt, 11, uintptr(hdcDest), uintptr(nXOriginDest), uintptr(nYOriginDest), uintptr(nWidthDest), uintptr(nHeightDest), uintptr(hdcSrc), uintptr(nXOriginSrc), uintptr(nYOriginSrc), uintptr(nWidthSrc), uintptr(nHeightSrc), uintptr(dwRop), 0) return ret != 0 }
func WglUseFontOutlines(hdc HDC, first, count, listbase uint32, deviation, extrusion float32, format int, pgmf *GLYPHMETRICSFLOAT) bool { ret, _, _ := syscall.Syscall12(wglUseFontBitmaps, 8, uintptr(hdc), uintptr(first), uintptr(count), uintptr(listbase), uintptr(deviation), uintptr(extrusion), uintptr(format), uintptr(unsafe.Pointer(pgmf)), 0, 0, 0, 0) return ret != 0 }
func StretchBlt(hdcDest HDC, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest int, hdcSrc HDC, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc int, dwRop uint) { ret, _, _ := syscall.Syscall12(procStretchBlt, 11, uintptr(hdcDest), uintptr(nXOriginDest), uintptr(nYOriginDest), uintptr(nWidthDest), uintptr(nHeightDest), uintptr(hdcSrc), uintptr(nXOriginSrc), uintptr(nYOriginSrc), uintptr(nWidthSrc), uintptr(nHeightSrc), uintptr(dwRop), 0) if ret == 0 { panic("StretchBlt failed") } }
func CreateWindowEx(exStyle uint, className, windowName *uint16, style uint, x, y, width, height int, parent HWND, menu HMENU, instance HINSTANCE, param unsafe.Pointer) HWND { ret, _, _ := syscall.Syscall12(procCreateWindowEx, 12, uintptr(exStyle), uintptr(unsafe.Pointer(className)), uintptr(unsafe.Pointer(windowName)), uintptr(style), uintptr(x), uintptr(y), uintptr(width), uintptr(height), uintptr(parent), uintptr(menu), uintptr(instance), uintptr(param)) return HWND(ret) }
func RegQueryInfoKey(key syscall.Handle, class *uint16, cClass *uint32, reserved *uint32, subKeys *uint32, maxSubKeyLen *uint32, maxClassLen *uint32, values *uint32, maxValueNameLen *uint32, maxValueLen *uint32, cbSecurityDescriptor *uint32, lastWriteTime *FILETIME) error { r1, _, _ := syscall.Syscall12( procRegQueryInfoKeyW.Addr(), 12, uintptr(key), uintptr(unsafe.Pointer(class)), uintptr(unsafe.Pointer(cClass)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(subKeys)), uintptr(unsafe.Pointer(maxSubKeyLen)), uintptr(unsafe.Pointer(maxClassLen)), uintptr(unsafe.Pointer(values)), uintptr(unsafe.Pointer(maxValueNameLen)), uintptr(unsafe.Pointer(maxValueLen)), uintptr(unsafe.Pointer(cbSecurityDescriptor)), uintptr(unsafe.Pointer(lastWriteTime))) if err := syscall.Errno(r1); err != ERROR_SUCCESS { return err } return nil }
// Call calls f with the argument list specified by argPtr and argLen. // The argument list needs to have the same layout in memory as the arguments // that f expects. // argPtr points to the first argument in the list. argLen is the number of // CPU words in the argument list. Normally this is the same as the number of // arguments, but it is larger if any of the arguments is larger than a CPU // word. // // There are two main options for how to construct the argument list. // One is to use the argument list of a wrapper function; take the address of // the first argument (or potentially the method receiver). // The other is to create a custom struct type to hold the argument list. func (f Func) Call(argPtr unsafe.Pointer, argLen uintptr) (r1 uintptr, r2 uintptr, err error) { if argLen <= 3 { argPtrs := (*Args)(argPtr) args := make([]uintptr, 3, 3) for i := uintptr(0); i < argLen; i++ { args[i] = argPtrs.Args[i] } return syscall.Syscall(uintptr(f), argLen, args[0], args[1], args[2]) } else if argLen <= 6 { argPtrs := (*Args)(argPtr) args := make([]uintptr, 6, 6) for i := uintptr(0); i < argLen; i++ { args[i] = argPtrs.Args[i] } return syscall.Syscall6(uintptr(f), argLen, args[0], args[1], args[2], args[3], args[4], args[5]) } else if argLen <= 9 { argPtrs := (*Args)(argPtr) args := make([]uintptr, 9, 9) for i := uintptr(0); i < argLen; i++ { args[i] = argPtrs.Args[i] } return syscall.Syscall9(uintptr(f), argLen, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]) } else if argLen <= 12 { argPtrs := (*Args)(argPtr) args := make([]uintptr, 12, 12) for i := uintptr(0); i < argLen; i++ { args[i] = argPtrs.Args[i] } return syscall.Syscall12(uintptr(f), argLen, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11]) } else { argPtrs := (*Args)(argPtr) args := make([]uintptr, 15, 15) for i := uintptr(0); i < argLen; i++ { args[i] = argPtrs.Args[i] } return syscall.Syscall15(uintptr(f), argLen, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11], args[12], args[13], args[14]) } }
func InitializeSecurityContext(credential *CredHandle, context *CtxtHandle, targname *uint16, contextreq uint32, reserved1 uint32, targdatarep uint32, input *SecBufferDesc, reserved2 uint32, newcontext *CtxtHandle, output *SecBufferDesc, contextattr *uint32, expiry *syscall.Filetime) (ret syscall.Errno) { r0, _, _ := syscall.Syscall12(procInitializeSecurityContextW.Addr(), 12, uintptr(unsafe.Pointer(credential)), uintptr(unsafe.Pointer(context)), uintptr(unsafe.Pointer(targname)), uintptr(contextreq), uintptr(reserved1), uintptr(targdatarep), uintptr(unsafe.Pointer(input)), uintptr(reserved2), uintptr(unsafe.Pointer(newcontext)), uintptr(unsafe.Pointer(output)), uintptr(unsafe.Pointer(contextattr)), uintptr(unsafe.Pointer(expiry))) ret = syscall.Errno(r0) return }
func InitializeSecurityContext(credential *CredHandle, context *CtxtHandle, targetname *uint16, contextreq uint32, reserved1 uint32, targetdatarep uint32, input *SecBufferDesc, reserved2 uint32, newcontext *CtxtHandle, output *SecBufferDesc, contextattr *uint32, expiry *TimeStamp) (status SECURITY_STATUS) { r0, _, _ := syscall.Syscall12(procInitializeSecurityContextW.Addr(), 12, uintptr(unsafe.Pointer(credential)), uintptr(unsafe.Pointer(context)), uintptr(unsafe.Pointer(targetname)), uintptr(contextreq), uintptr(reserved1), uintptr(targetdatarep), uintptr(unsafe.Pointer(input)), uintptr(reserved2), uintptr(unsafe.Pointer(newcontext)), uintptr(unsafe.Pointer(output)), uintptr(unsafe.Pointer(contextattr)), uintptr(unsafe.Pointer(expiry))) status = SECURITY_STATUS(r0) return }
func (dllCls *DLLClass) Call(apiName interface{}, argvs ...uintptr) uintptr { var nArgvs = uintptr(len(argvs)) var apiFunc uintptr switch apiName.(type) { case string: apiFunc = MustGetProcAddress(dllCls.Handle, apiName.(string)) case uintptr: apiFunc = apiName.(uintptr) default: panic("The parameters of the function < " + apiName.(string) + " > must be uintptr or string type") } if nArgvs <= 3 { cArgs := []uintptr{0, 0, 0} for k, v := range argvs { cArgs[k] = v } apiRet, _, _ := syscall.Syscall(apiFunc, nArgvs, cArgs[0], cArgs[1], cArgs[2]) return apiRet } else if nArgvs <= 6 { cArgs := []uintptr{0, 0, 0, 0, 0, 0} for k, v := range argvs { cArgs[k] = v } apiRet, _, _ := syscall.Syscall6(apiFunc, nArgvs, cArgs[0], cArgs[1], cArgs[2], cArgs[3], cArgs[4], cArgs[5]) return apiRet } else if nArgvs <= 9 { cArgs := []uintptr{0, 0, 0, 0, 0, 0, 0, 0, 0} for k, v := range argvs { cArgs[k] = v } apiRet, _, _ := syscall.Syscall9(apiFunc, nArgvs, cArgs[0], cArgs[1], cArgs[2], cArgs[3], cArgs[4], cArgs[5], cArgs[6], cArgs[7], cArgs[8]) return apiRet } else if nArgvs <= 12 { cArgs := []uintptr{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} for k, v := range argvs { cArgs[k] = v } apiRet, _, _ := syscall.Syscall12(apiFunc, nArgvs, cArgs[0], cArgs[1], cArgs[2], cArgs[3], cArgs[4], cArgs[5], cArgs[6], cArgs[7], cArgs[8], cArgs[9], cArgs[10], cArgs[11]) return apiRet } else if nArgvs <= 15 { cArgs := []uintptr{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} for k, v := range argvs { cArgs[k] = v } apiRet, _, _ := syscall.Syscall15(apiFunc, nArgvs, cArgs[0], cArgs[1], cArgs[2], cArgs[3], cArgs[4], cArgs[5], cArgs[6], cArgs[7], cArgs[8], cArgs[9], cArgs[10], cArgs[11], cArgs[12], cArgs[13], cArgs[14]) return apiRet } else { panic("Function < " + apiName.(string) + " > Call too many parameters.") } }
func (auth *SSPIAuth) InitialBytes() ([]byte, error) { var identity *SEC_WINNT_AUTH_IDENTITY if auth.UserName != "" { identity = &SEC_WINNT_AUTH_IDENTITY{ Flags: SEC_WINNT_AUTH_IDENTITY_UNICODE, Password: syscall.StringToUTF16Ptr(auth.Password), PasswordLength: uint32(len(auth.Password)), Domain: syscall.StringToUTF16Ptr(auth.Domain), DomainLength: uint32(len(auth.Domain)), User: syscall.StringToUTF16Ptr(auth.UserName), UserLength: uint32(len(auth.UserName)), } } var ts TimeStamp sec_ok, _, _ := syscall.Syscall9(sec_fn.AcquireCredentialsHandle, 9, 0, uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr("Negotiate"))), SECPKG_CRED_OUTBOUND, 0, uintptr(unsafe.Pointer(identity)), 0, 0, uintptr(unsafe.Pointer(&auth.cred)), uintptr(unsafe.Pointer(&ts))) if sec_ok != SEC_E_OK { return nil, fmt.Errorf("AcquireCredentialsHandle failed %x", sec_ok) } var buf SecBuffer var desc SecBufferDesc desc.ulVersion = SECBUFFER_VERSION desc.cBuffers = 1 desc.pBuffers = &buf outbuf := make([]byte, NTLMBUF_LEN) buf.cbBuffer = NTLMBUF_LEN buf.BufferType = SECBUFFER_TOKEN buf.pvBuffer = &outbuf[0] var attrs uint32 sec_ok, _, _ = syscall.Syscall12(sec_fn.InitializeSecurityContext, 12, uintptr(unsafe.Pointer(&auth.cred)), 0, uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(auth.Service))), ISC_REQ, 0, SECURITY_NETWORK_DREP, 0, 0, uintptr(unsafe.Pointer(&auth.ctxt)), uintptr(unsafe.Pointer(&desc)), uintptr(unsafe.Pointer(&attrs)), uintptr(unsafe.Pointer(&ts))) if sec_ok == SEC_I_COMPLETE_AND_CONTINUE || sec_ok == SEC_I_COMPLETE_NEEDED { syscall.Syscall6(sec_fn.CompleteAuthToken, 2, uintptr(unsafe.Pointer(&auth.ctxt)), uintptr(unsafe.Pointer(&desc)), 0, 0, 0, 0) } else if sec_ok != SEC_E_OK && sec_ok != SEC_I_CONTINUE_NEEDED { syscall.Syscall6(sec_fn.FreeCredentialsHandle, 1, uintptr(unsafe.Pointer(&auth.cred)), 0, 0, 0, 0, 0) return nil, fmt.Errorf("InitialBytes InitializeSecurityContext failed %x", sec_ok) } return outbuf[:buf.cbBuffer], nil }
func SQLGetDescRec(descriptorHandle SQLHandle, recNumber SQLSMALLINT, name *SQLCHAR, bufferLength SQLSMALLINT, stringLengthPtr *SQLSMALLINT, typePtr *SQLSMALLINT, subTypePtr *SQLSMALLINT, lengthPtr *SQLLEN, precisionPtr *SQLSMALLINT, scalePtr *SQLSMALLINT, nullablePtr *SQLSMALLINT) (ret SQLReturn) { r0, _, _ := syscall.Syscall12(procSQLGetDescRecW.Addr(), 11, uintptr(descriptorHandle), uintptr(recNumber), uintptr(unsafe.Pointer(name)), uintptr(bufferLength), uintptr(unsafe.Pointer(stringLengthPtr)), uintptr(unsafe.Pointer(typePtr)), uintptr(unsafe.Pointer(subTypePtr)), uintptr(unsafe.Pointer(lengthPtr)), uintptr(unsafe.Pointer(precisionPtr)), uintptr(unsafe.Pointer(scalePtr)), uintptr(unsafe.Pointer(nullablePtr)), 0) ret = SQLReturn(r0) return }
func SQLBindParameter(statementHandle SQLHSTMT, parameterNumber SQLUSMALLINT, inputOutputType SQLSMALLINT, valueType SQLSMALLINT, parameterType SQLSMALLINT, columnSize SQLULEN, decimalDigits SQLSMALLINT, parameterValue SQLPOINTER, bufferLength SQLLEN, ind *SQLLEN) (ret SQLRETURN) { r0, _, _ := syscall.Syscall12(procSQLBindParameter.Addr(), 10, uintptr(statementHandle), uintptr(parameterNumber), uintptr(inputOutputType), uintptr(valueType), uintptr(parameterType), uintptr(columnSize), uintptr(decimalDigits), uintptr(parameterValue), uintptr(bufferLength), uintptr(unsafe.Pointer(ind)), 0, 0) ret = SQLRETURN(r0) return }
func SetDIBitsToDevice(hDC Handle, xDext int32, yDest int32, width int32, height int32, xSrc int32, ySrc int32, startScan uint32, scanLines uint32, bits uintptr, bmi *BITMAPINFO, colorUse uint32) (lines int32) { r0, _, _ := syscall.Syscall12(procSetDIBitsToDevice.Addr(), 12, uintptr(hDC), uintptr(xDext), uintptr(yDest), uintptr(width), uintptr(height), uintptr(xSrc), uintptr(ySrc), uintptr(startScan), uintptr(scanLines), uintptr(bits), uintptr(unsafe.Pointer(bmi)), uintptr(colorUse)) lines = int32(r0) return }
func New() *Window { var dwExStyle uintptr = ws_ex_dlgmodalframe var dwStyle uintptr = ws_caption | ws_sysmenu | ws_overlapped | ws_thickframe | ws_maximizebox | ws_minimizebox hWnd, _, err := syscall.Syscall12( createWindowEx, 12, dwExStyle, wc.lpszClassName, 0, dwStyle, 0, 0, 0, 0, 0, 0, hProcess, 0, ) if hWnd == 0 { fmt.Println("oswnd:", err) return nil } boundDiffs := bounds32{500, 500, 1000, 1000} syscall.Syscall6(adjustWindowRectEx, 4, uintptr(unsafe.Pointer(&boundDiffs)), dwStyle, 0, dwExStyle, 0, 0) boundDiffs.Left = 500 - boundDiffs.Left boundDiffs.Top = 500 - boundDiffs.Top boundDiffs.Right -= 1000 boundDiffs.Bottom -= 1000 wnd := &Window{ id: hWnd, keyCounts: map[uintptr]int{}, EventListeners: EventListeners{}, padding: Bounds{ int(boundDiffs.Left), int(boundDiffs.Bottom), int(boundDiffs.Right), int(boundDiffs.Bottom), }, border: Bounds{ 0, int(boundDiffs.Top - boundDiffs.Bottom), 0, 0, }, sizeDiff: Size{ int(boundDiffs.Left + boundDiffs.Right), int(boundDiffs.Top + boundDiffs.Bottom), }, } wnd.did, _, _ = syscall.Syscall(getDC, 1, wnd.id, 0, 0) wnd.msgHandlers = map[uintptr]msgHandler{ wm_keydown: func(wParam, lParam uintptr) bool { wnd.keyCounts[wParam]++ if wnd.OnKeyDown != nil { wnd.OnKeyDown(int(wParam), wnd.keyCounts[wParam]) } return true }, wm_keyup: func(wParam, lParam uintptr) bool { wnd.keyCounts[wParam] = 0 if wnd.OnKeyUp != nil { wnd.OnKeyUp(int(wParam)) } return true }, wm_destroy: func(wParam, lParam uintptr) bool { syscall.Syscall(releaseDC, 1, wnd.did, 0, 0) delete(wndMap, wnd.id) if len(wndMap) == 0 { syscall.Syscall(postQuitMessage, 1, 0, 0, 0) return false } return true }, wm_paint: func(wParam, lParam uintptr) bool { if wnd.OnPaint != nil { wnd.OnPaint() syscall.Syscall(validateRect, 2, wnd.id, 0, 0) return false } return true }, wm_size: func(wParam, lParam uintptr) bool { if wnd.OnSize != nil { wnd.OnSize() } if wnd.OnPaint != nil { wnd.OnPaint() } return true }, } wndMap[wnd.id] = wnd return wnd }