github.com/cellofellow/gopkg@v0.0.0-20140722061823-eec0544a62ad/osext/winsvc/winapi/zwinapi.go (about)

     1  // mksyscall_windows.pl event.go eventlog.go registry.go security.go service.go syscall.go
     2  // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
     3  
     4  package winapi
     5  
     6  import "unsafe"
     7  import "syscall"
     8  
     9  var (
    10  	modkernel32 = syscall.NewLazyDLL("kernel32.dll")
    11  	modadvapi32 = syscall.NewLazyDLL("advapi32.dll")
    12  
    13  	procCreateEventW                = modkernel32.NewProc("CreateEventW")
    14  	procSetEvent                    = modkernel32.NewProc("SetEvent")
    15  	procRegisterEventSourceW        = modadvapi32.NewProc("RegisterEventSourceW")
    16  	procDeregisterEventSource       = modadvapi32.NewProc("DeregisterEventSource")
    17  	procReportEventW                = modadvapi32.NewProc("ReportEventW")
    18  	procRegCreateKeyExW             = modadvapi32.NewProc("RegCreateKeyExW")
    19  	procRegDeleteKeyW               = modadvapi32.NewProc("RegDeleteKeyW")
    20  	procRegSetValueExW              = modadvapi32.NewProc("RegSetValueExW")
    21  	procAllocateAndInitializeSid    = modadvapi32.NewProc("AllocateAndInitializeSid")
    22  	procFreeSid                     = modadvapi32.NewProc("FreeSid")
    23  	procEqualSid                    = modadvapi32.NewProc("EqualSid")
    24  	procOpenSCManagerW              = modadvapi32.NewProc("OpenSCManagerW")
    25  	procCloseServiceHandle          = modadvapi32.NewProc("CloseServiceHandle")
    26  	procCreateServiceW              = modadvapi32.NewProc("CreateServiceW")
    27  	procOpenServiceW                = modadvapi32.NewProc("OpenServiceW")
    28  	procDeleteService               = modadvapi32.NewProc("DeleteService")
    29  	procStartServiceW               = modadvapi32.NewProc("StartServiceW")
    30  	procQueryServiceStatus          = modadvapi32.NewProc("QueryServiceStatus")
    31  	procControlService              = modadvapi32.NewProc("ControlService")
    32  	procStartServiceCtrlDispatcherW = modadvapi32.NewProc("StartServiceCtrlDispatcherW")
    33  	procSetServiceStatus            = modadvapi32.NewProc("SetServiceStatus")
    34  	procChangeServiceConfigW        = modadvapi32.NewProc("ChangeServiceConfigW")
    35  	procQueryServiceConfigW         = modadvapi32.NewProc("QueryServiceConfigW")
    36  	procChangeServiceConfig2W       = modadvapi32.NewProc("ChangeServiceConfig2W")
    37  	procQueryServiceConfig2W        = modadvapi32.NewProc("QueryServiceConfig2W")
    38  	procGetCurrentThreadId          = modkernel32.NewProc("GetCurrentThreadId")
    39  )
    40  
    41  func CreateEvent(eventAttrs *syscall.SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle syscall.Handle, err error) {
    42  	r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(manualReset), uintptr(initialState), uintptr(unsafe.Pointer(name)), 0, 0)
    43  	handle = syscall.Handle(r0)
    44  	if handle == 0 {
    45  		if e1 != 0 {
    46  			err = error(e1)
    47  		} else {
    48  			err = syscall.EINVAL
    49  		}
    50  	}
    51  	return
    52  }
    53  
    54  func SetEvent(event syscall.Handle) (err error) {
    55  	r1, _, e1 := syscall.Syscall(procSetEvent.Addr(), 1, uintptr(event), 0, 0)
    56  	if int(r1) == 0 {
    57  		if e1 != 0 {
    58  			err = error(e1)
    59  		} else {
    60  			err = syscall.EINVAL
    61  		}
    62  	}
    63  	return
    64  }
    65  
    66  func RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle syscall.Handle, err error) {
    67  	r0, _, e1 := syscall.Syscall(procRegisterEventSourceW.Addr(), 2, uintptr(unsafe.Pointer(uncServerName)), uintptr(unsafe.Pointer(sourceName)), 0)
    68  	handle = syscall.Handle(r0)
    69  	if handle == 0 {
    70  		if e1 != 0 {
    71  			err = error(e1)
    72  		} else {
    73  			err = syscall.EINVAL
    74  		}
    75  	}
    76  	return
    77  }
    78  
    79  func DeregisterEventSource(handle syscall.Handle) (err error) {
    80  	r1, _, e1 := syscall.Syscall(procDeregisterEventSource.Addr(), 1, uintptr(handle), 0, 0)
    81  	if int(r1) == 0 {
    82  		if e1 != 0 {
    83  			err = error(e1)
    84  		} else {
    85  			err = syscall.EINVAL
    86  		}
    87  	}
    88  	return
    89  }
    90  
    91  func ReportEvent(log syscall.Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) {
    92  	r1, _, e1 := syscall.Syscall9(procReportEventW.Addr(), 9, uintptr(log), uintptr(etype), uintptr(category), uintptr(eventId), uintptr(usrSId), uintptr(numStrings), uintptr(dataSize), uintptr(unsafe.Pointer(strings)), uintptr(unsafe.Pointer(rawData)))
    93  	if int(r1) == 0 {
    94  		if e1 != 0 {
    95  			err = error(e1)
    96  		} else {
    97  			err = syscall.EINVAL
    98  		}
    99  	}
   100  	return
   101  }
   102  
   103  func RegCreateKeyEx(key syscall.Handle, subkey *uint16, reserved uint32, class *uint16, options uint32, desired uint32, sa *syscall.SecurityAttributes, result *syscall.Handle, disposition *uint32) (regerrno error) {
   104  	r0, _, _ := syscall.Syscall9(procRegCreateKeyExW.Addr(), 9, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(reserved), uintptr(unsafe.Pointer(class)), uintptr(options), uintptr(desired), uintptr(unsafe.Pointer(sa)), uintptr(unsafe.Pointer(result)), uintptr(unsafe.Pointer(disposition)))
   105  	if r0 != 0 {
   106  		regerrno = syscall.Errno(r0)
   107  	}
   108  	return
   109  }
   110  
   111  func RegDeleteKey(key syscall.Handle, subkey *uint16) (regerrno error) {
   112  	r0, _, _ := syscall.Syscall(procRegDeleteKeyW.Addr(), 2, uintptr(key), uintptr(unsafe.Pointer(subkey)), 0)
   113  	if r0 != 0 {
   114  		regerrno = syscall.Errno(r0)
   115  	}
   116  	return
   117  }
   118  
   119  func RegSetValueEx(key syscall.Handle, valueName *uint16, reserved uint32, vtype uint32, buf *byte, bufsize uint32) (regerrno error) {
   120  	r0, _, _ := syscall.Syscall6(procRegSetValueExW.Addr(), 6, uintptr(key), uintptr(unsafe.Pointer(valueName)), uintptr(reserved), uintptr(vtype), uintptr(unsafe.Pointer(buf)), uintptr(bufsize))
   121  	if r0 != 0 {
   122  		regerrno = syscall.Errno(r0)
   123  	}
   124  	return
   125  }
   126  
   127  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) {
   128  	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)
   129  	if int(r1) == 0 {
   130  		if e1 != 0 {
   131  			err = error(e1)
   132  		} else {
   133  			err = syscall.EINVAL
   134  		}
   135  	}
   136  	return
   137  }
   138  
   139  func FreeSid(sid *syscall.SID) (err error) {
   140  	r1, _, e1 := syscall.Syscall(procFreeSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
   141  	if int(r1) != 0 {
   142  		if e1 != 0 {
   143  			err = error(e1)
   144  		} else {
   145  			err = syscall.EINVAL
   146  		}
   147  	}
   148  	return
   149  }
   150  
   151  func EqualSid(sid1 *syscall.SID, sid2 *syscall.SID) (isEqual bool) {
   152  	r0, _, _ := syscall.Syscall(procEqualSid.Addr(), 2, uintptr(unsafe.Pointer(sid1)), uintptr(unsafe.Pointer(sid2)), 0)
   153  	isEqual = bool(r0 != 0)
   154  	return
   155  }
   156  
   157  func OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle syscall.Handle, err error) {
   158  	r0, _, e1 := syscall.Syscall(procOpenSCManagerW.Addr(), 3, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(databaseName)), uintptr(access))
   159  	handle = syscall.Handle(r0)
   160  	if handle == 0 {
   161  		if e1 != 0 {
   162  			err = error(e1)
   163  		} else {
   164  			err = syscall.EINVAL
   165  		}
   166  	}
   167  	return
   168  }
   169  
   170  func CloseServiceHandle(handle syscall.Handle) (err error) {
   171  	r1, _, e1 := syscall.Syscall(procCloseServiceHandle.Addr(), 1, uintptr(handle), 0, 0)
   172  	if int(r1) == 0 {
   173  		if e1 != 0 {
   174  			err = error(e1)
   175  		} else {
   176  			err = syscall.EINVAL
   177  		}
   178  	}
   179  	return
   180  }
   181  
   182  func CreateService(mgr syscall.Handle, serviceName *uint16, displayName *uint16, access uint32, srvType uint32, startType uint32, errCtl uint32, pathName *uint16, loadOrderGroup *uint16, tagId *uint32, dependencies *uint16, serviceStartName *uint16, password *uint16) (handle syscall.Handle, err error) {
   183  	r0, _, e1 := syscall.Syscall15(procCreateServiceW.Addr(), 13, uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(unsafe.Pointer(displayName)), uintptr(access), uintptr(srvType), uintptr(startType), uintptr(errCtl), uintptr(unsafe.Pointer(pathName)), uintptr(unsafe.Pointer(loadOrderGroup)), uintptr(unsafe.Pointer(tagId)), uintptr(unsafe.Pointer(dependencies)), uintptr(unsafe.Pointer(serviceStartName)), uintptr(unsafe.Pointer(password)), 0, 0)
   184  	handle = syscall.Handle(r0)
   185  	if handle == 0 {
   186  		if e1 != 0 {
   187  			err = error(e1)
   188  		} else {
   189  			err = syscall.EINVAL
   190  		}
   191  	}
   192  	return
   193  }
   194  
   195  func OpenService(mgr syscall.Handle, serviceName *uint16, access uint32) (handle syscall.Handle, err error) {
   196  	r0, _, e1 := syscall.Syscall(procOpenServiceW.Addr(), 3, uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(access))
   197  	handle = syscall.Handle(r0)
   198  	if handle == 0 {
   199  		if e1 != 0 {
   200  			err = error(e1)
   201  		} else {
   202  			err = syscall.EINVAL
   203  		}
   204  	}
   205  	return
   206  }
   207  
   208  func DeleteService(service syscall.Handle) (err error) {
   209  	r1, _, e1 := syscall.Syscall(procDeleteService.Addr(), 1, uintptr(service), 0, 0)
   210  	if int(r1) == 0 {
   211  		if e1 != 0 {
   212  			err = error(e1)
   213  		} else {
   214  			err = syscall.EINVAL
   215  		}
   216  	}
   217  	return
   218  }
   219  
   220  func StartService(service syscall.Handle, numArgs uint32, argVectors **uint16) (err error) {
   221  	r1, _, e1 := syscall.Syscall(procStartServiceW.Addr(), 3, uintptr(service), uintptr(numArgs), uintptr(unsafe.Pointer(argVectors)))
   222  	if int(r1) == 0 {
   223  		if e1 != 0 {
   224  			err = error(e1)
   225  		} else {
   226  			err = syscall.EINVAL
   227  		}
   228  	}
   229  	return
   230  }
   231  
   232  func QueryServiceStatus(service syscall.Handle, status *SERVICE_STATUS) (err error) {
   233  	r1, _, e1 := syscall.Syscall(procQueryServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(status)), 0)
   234  	if int(r1) == 0 {
   235  		if e1 != 0 {
   236  			err = error(e1)
   237  		} else {
   238  			err = syscall.EINVAL
   239  		}
   240  	}
   241  	return
   242  }
   243  
   244  func ControlService(service syscall.Handle, control uint32, status *SERVICE_STATUS) (err error) {
   245  	r1, _, e1 := syscall.Syscall(procControlService.Addr(), 3, uintptr(service), uintptr(control), uintptr(unsafe.Pointer(status)))
   246  	if int(r1) == 0 {
   247  		if e1 != 0 {
   248  			err = error(e1)
   249  		} else {
   250  			err = syscall.EINVAL
   251  		}
   252  	}
   253  	return
   254  }
   255  
   256  func StartServiceCtrlDispatcher(serviceTable *SERVICE_TABLE_ENTRY) (err error) {
   257  	r1, _, e1 := syscall.Syscall(procStartServiceCtrlDispatcherW.Addr(), 1, uintptr(unsafe.Pointer(serviceTable)), 0, 0)
   258  	if int(r1) == 0 {
   259  		if e1 != 0 {
   260  			err = error(e1)
   261  		} else {
   262  			err = syscall.EINVAL
   263  		}
   264  	}
   265  	return
   266  }
   267  
   268  func SetServiceStatus(service syscall.Handle, serviceStatus *SERVICE_STATUS) (err error) {
   269  	r1, _, e1 := syscall.Syscall(procSetServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(serviceStatus)), 0)
   270  	if int(r1) == 0 {
   271  		if e1 != 0 {
   272  			err = error(e1)
   273  		} else {
   274  			err = syscall.EINVAL
   275  		}
   276  	}
   277  	return
   278  }
   279  
   280  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) (err error) {
   281  	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)
   282  	if int(r1) == 0 {
   283  		if e1 != 0 {
   284  			err = error(e1)
   285  		} else {
   286  			err = syscall.EINVAL
   287  		}
   288  	}
   289  	return
   290  }
   291  
   292  func QueryServiceConfig(service syscall.Handle, serviceConfig *QUERY_SERVICE_CONFIG, bufSize uint32, bytesNeeded *uint32) (err error) {
   293  	r1, _, e1 := syscall.Syscall6(procQueryServiceConfigW.Addr(), 4, uintptr(service), uintptr(unsafe.Pointer(serviceConfig)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0)
   294  	if int(r1) == 0 {
   295  		if e1 != 0 {
   296  			err = error(e1)
   297  		} else {
   298  			err = syscall.EINVAL
   299  		}
   300  	}
   301  	return
   302  }
   303  
   304  func ChangeServiceConfig2(service syscall.Handle, infoLevel uint32, info *byte) (err error) {
   305  	r1, _, e1 := syscall.Syscall(procChangeServiceConfig2W.Addr(), 3, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(info)))
   306  	if int(r1) == 0 {
   307  		if e1 != 0 {
   308  			err = error(e1)
   309  		} else {
   310  			err = syscall.EINVAL
   311  		}
   312  	}
   313  	return
   314  }
   315  
   316  func QueryServiceConfig2(service syscall.Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) {
   317  	r1, _, e1 := syscall.Syscall6(procQueryServiceConfig2W.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
   318  	if int(r1) == 0 {
   319  		if e1 != 0 {
   320  			err = error(e1)
   321  		} else {
   322  			err = syscall.EINVAL
   323  		}
   324  	}
   325  	return
   326  }
   327  
   328  func GetCurrentThreadId() (id uint32) {
   329  	r0, _, _ := syscall.Syscall(procGetCurrentThreadId.Addr(), 0, 0, 0, 0)
   330  	id = uint32(r0)
   331  	return
   332  }