How to implement LogonUserA function (winbase.h)?

290 views
Skip to first unread message

Chandan Kumar

unread,
Sep 1, 2022, 7:29:28 AM9/1/22
to golang-nuts
Hi,

I am trying to implement a program in which I need the function LogonUserA function (winbase.h) from windows API and this function is not available in the package golang.org/x/sys/windows so any advice would be helpful.

Marvin Renich

unread,
Sep 1, 2022, 8:07:45 AM9/1/22
to golan...@googlegroups.com
* Chandan Kumar <cks...@gmail.com> [220901 07:29]:
> Hi,
>
> I am trying to implement a program in which I need the function *LogonUserA
> function (winbase.h) *from windows API and this function is not available
> in the package *golang.org/x/sys/windows* so any advice would be helpful.

First, you need to determine in which DLL the function is. Suppose it
is in kernel32.dll:

import (
"golang.org/x/sys/windows"
"syscall"
"unsafe"
)

var (
modKernel32 = windows.NewLazySystemDLL("kernel32.dll")
procLogonUser = modKernel32.NewProc("LogonUserA")
)

func LogonUser(«arguments») («results», err error) {
var r1, ..., e1 = syscall.Syscall(procLogonUser.Addr(), «converted arguments», «fill with 0»)
// Convert results and error and return them.
}

I didn't bother to look up what the real arguments are to LogonUser, but
hopefully this gives you enough info to figure it out. Pointers will
need to be converted like this: uintptr(unsafe.Pointer(userName)) when
passing them to Syscall.

If you need more help, post the function signature for LogonUser.

...Marvin

Chandan Kumar

unread,
Sep 2, 2022, 5:11:42 AM9/2/22
to golang-nuts
Thanks. I will try your approach.
Reply all
Reply to author
Forward
0 new messages