删除无用代码,加入RPC调用

This commit is contained in:
2025-03-21 17:00:13 +08:00
parent 903472de6c
commit ded0148ba6
51 changed files with 483 additions and 57881 deletions

View File

@@ -1,6 +1,7 @@
package common
import (
"bytes"
"fmt"
"image"
"image/color"
@@ -50,7 +51,7 @@ func Bpp(BitsPerPixel uint16) (pixel int) {
pixel = 4
default:
glog.Error("非法位图数据")
glog.Error("invalid BitsPerPixel")
}
return
@@ -96,22 +97,15 @@ func DrawOneBitmap(bitmap *Bitmap, name string) {
}
draw.Draw(finalImg, finalImg.Bounds(), m, m.Bounds().Min, draw.Src)
//_, _ = os.ReadFile(fmt.Sprintf("%s.png", name))
outFile, err := os.Create(fmt.Sprintf("%s.png", name))
if err != nil {
glog.Errorf("创建文件失败: %v", err)
}
outFile, _ := os.Create(fmt.Sprintf("%s.png", name))
defer outFile.Close()
// 保存图像为PNG文件
err = png.Encode(outFile, finalImg)
if err != nil {
glog.Errorf("保存文件失败: %v", err)
}
_ = png.Encode(outFile, finalImg)
}
func DrawFullImage(outputName string, bitmapList []*Bitmap) {
func DrawFullImage(outputName string, bitmapList []*Bitmap) []byte {
// 对位图按 DestTop 和 DestLeft 排序
sort.Slice(bitmapList, func(i, j int) bool {
if bitmapList[i].DestTop == bitmapList[j].DestTop {
@@ -157,16 +151,15 @@ func DrawFullImage(outputName string, bitmapList []*Bitmap) {
}
// 创建保存PNG文件
outFile, err := os.Create(fmt.Sprintf("%s.png", outputName))
if err != nil {
glog.Errorf("创建文件失败: %v", err)
}
defer outFile.Close()
//outFile, _ := os.Create(fmt.Sprintf("%s.png", outputName))
//defer outFile.Close()
//_ = png.Encode(outFile, finalImg)
err = png.Encode(outFile, finalImg)
var buff bytes.Buffer
err := png.Encode(&buff, finalImg)
if err != nil {
glog.Errorf("保存文件失败: %v", err)
return nil
}
glog.Info("合并图像完成")
return buff.Bytes()
}

12
go.mod
View File

@@ -6,6 +6,14 @@ require (
github.com/huin/asn1ber v0.0.0-20120622192748-af09f62e6358
github.com/icodeface/tls v0.0.0-20230910023335-34df9250cd12
github.com/lunixbochs/struc v0.0.0-20241101090106-8d528fa2c543
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4
golang.org/x/crypto v0.31.0
golang.org/x/crypto v0.32.0
google.golang.org/grpc v1.71.0
google.golang.org/protobuf v1.36.4
)
require (
golang.org/x/net v0.34.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
)

40
go.sum
View File

@@ -1,10 +1,42 @@
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/huin/asn1ber v0.0.0-20120622192748-af09f62e6358 h1:hVXNJ57IHkOA8FBq80UG263MEBwNUMfS9c82J2QE5UQ=
github.com/huin/asn1ber v0.0.0-20120622192748-af09f62e6358/go.mod h1:qBE210J2T9uLXRB3GNc73SvZACDEFAmDCOlDkV47zbY=
github.com/icodeface/tls v0.0.0-20230910023335-34df9250cd12 h1:uSJXMFVNfN2hyXDLM19op2fNiCN/nL8xgdmNXgs5738=
github.com/icodeface/tls v0.0.0-20230910023335-34df9250cd12/go.mod h1:VJNHW2GxCtQP/IQtXykBIPBV8maPJ/dHWirVTwm9GwY=
github.com/lunixbochs/struc v0.0.0-20241101090106-8d528fa2c543 h1:GxMuVb9tJajC1QpbQwYNY1ZAo1EIE8I+UclBjOfjz/M=
github.com/lunixbochs/struc v0.0.0-20241101090106-8d528fa2c543/go.mod h1:vy1vK6wD6j7xX6O6hXe621WabdtNkou2h7uRtTfRMyg=
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 h1:udFKJ0aHUL60LboW/A+DfgoHVedieIzIXE8uylPue0U=
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc=
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY=
go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI=
go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ=
go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE=
go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A=
go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU=
go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk=
go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w=
go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k=
go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE=
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50=
google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg=
google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=
google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM=
google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=

View File

@@ -1,771 +0,0 @@
package cliprdr
import (
"bytes"
"encoding/hex"
"os"
"strings"
"unicode/utf16"
"github.com/lunixbochs/struc"
"ShotRDP/grdp/core"
"ShotRDP/grdp/glog"
"ShotRDP/grdp/plugin"
)
/**
* Initialization Sequence\n
* Client Server\n
* | |\n
* |<----------------------Server Clipboard Capabilities PDU-----------------|\n
* |<-----------------------------Monitor Ready PDU--------------------------|\n
* |-----------------------Client Clipboard Capabilities PDU---------------->|\n
* |---------------------------Temporary Directory PDU---------------------->|\n
* |-------------------------------Format List PDU-------------------------->|\n
* |<--------------------------Format List Response PDU----------------------|\n
*
*/
/**
* Data Transfer Sequences\n
* Shared Local\n
* Clipboard Owner Clipboard Owner\n
* | |\n
* |-------------------------------------------------------------------------|\n _
* |-------------------------------Format List PDU-------------------------->|\n |
* |<--------------------------Format List Response PDU----------------------|\n _| Copy
* Sequence
* |<---------------------Lock Clipboard Data PDU (Optional)-----------------|\n
* |-------------------------------------------------------------------------|\n
* |-------------------------------------------------------------------------|\n _
* |<--------------------------Format Data Request PDU-----------------------|\n | Paste
* Sequence Palette,
* |---------------------------Format Data Response PDU--------------------->|\n _| Metafile,
* File List Data
* |-------------------------------------------------------------------------|\n
* |-------------------------------------------------------------------------|\n _
* |<------------------------Format Contents Request PDU---------------------|\n | Paste
* Sequence
* |-------------------------Format Contents Response PDU------------------->|\n _| File
* Stream Data
* |<---------------------Lock Clipboard Data PDU (Optional)-----------------|\n
* |-------------------------------------------------------------------------|\n
*
*/
const (
ChannelName = plugin.CLIPRDR_SVC_CHANNEL_NAME
ChannelOption = plugin.CHANNEL_OPTION_INITIALIZED | plugin.CHANNEL_OPTION_ENCRYPT_RDP |
plugin.CHANNEL_OPTION_COMPRESS_RDP | plugin.CHANNEL_OPTION_SHOW_PROTOCOL
)
type MsgType uint16
const (
CB_MONITOR_READY = 0x0001
CB_FORMAT_LIST = 0x0002
CB_FORMAT_LIST_RESPONSE = 0x0003
CB_FORMAT_DATA_REQUEST = 0x0004
CB_FORMAT_DATA_RESPONSE = 0x0005
CB_TEMP_DIRECTORY = 0x0006
CB_CLIP_CAPS = 0x0007
CB_FILECONTENTS_REQUEST = 0x0008
CB_FILECONTENTS_RESPONSE = 0x0009
CB_LOCK_CLIPDATA = 0x000A
CB_UNLOCK_CLIPDATA = 0x000B
)
type MsgFlags uint16
const (
CB_RESPONSE_OK = 0x0001
CB_RESPONSE_FAIL = 0x0002
CB_ASCII_NAMES = 0x0004
)
type DwFlags uint32
const (
FILECONTENTS_SIZE = 0x00000001
FILECONTENTS_RANGE = 0x00000002
)
type CliprdrPDUHeader struct {
MsgType uint16 `struc:"little"`
MsgFlags uint16 `struc:"little"`
DataLen uint32 `struc:"little"`
}
func NewCliprdrPDUHeader(mType, flags uint16, ln uint32) *CliprdrPDUHeader {
return &CliprdrPDUHeader{
MsgType: mType,
MsgFlags: flags,
DataLen: ln,
}
}
func (h *CliprdrPDUHeader) serialize() []byte {
b := &bytes.Buffer{}
core.WriteUInt16LE(h.MsgType, b)
core.WriteUInt16LE(h.MsgFlags, b)
core.WriteUInt32LE(h.DataLen, b)
return b.Bytes()
}
type CliprdrGeneralCapabilitySet struct {
CapabilitySetType uint16 `struc:"little"`
CapabilitySetLength uint16 `struc:"little"`
Version uint32 `struc:"little"`
GeneralFlags uint32 `struc:"little"`
}
const (
CB_CAPSTYPE_GENERAL = 0x0001
)
type CliprdrCapabilitySets struct {
CapabilitySetType uint16 `struc:"little"`
LengthCapability uint16 `struc:"little"`
Version uint32 `struc:"little"`
GeneralFlags uint32 `struc:"little"`
//CapabilityData []byte `struc:"little"`
}
type CliprdrCapabilitiesPDU struct {
CCapabilitiesSets uint16 `struc:"little,sizeof=CapabilitySets"`
Pad1 uint16 `struc:"little"`
CapabilitySets []CliprdrGeneralCapabilitySet `struc:"little"`
}
type CliprdrMonitorReady struct {
}
type GeneralFlags uint32
const (
/* CLIPRDR_GENERAL_CAPABILITY.generalFlags */
CB_USE_LONG_FORMAT_NAMES = 0x00000002
CB_STREAM_FILECLIP_ENABLED = 0x00000004
CB_FILECLIP_NO_FILE_PATHS = 0x00000008
CB_CAN_LOCK_CLIPDATA = 0x00000010
CB_HUGE_FILE_SUPPORT_ENABLED = 0x00000020
)
const (
/* CLIPRDR_GENERAL_CAPABILITY.version */
CB_CAPS_VERSION_1 = 0x00000001
CB_CAPS_VERSION_2 = 0x00000002
)
const (
CB_CAPSTYPE_GENERAL_LEN = 12
)
const (
FD_CLSID = 0x00000001
FD_SIZEPOINT = 0x00000002
FD_ATTRIBUTES = 0x00000004
FD_CREATETIME = 0x00000008
FD_ACCESSTIME = 0x00000010
FD_WRITESTIME = 0x00000020
FD_FILESIZE = 0x00000040
FD_PROGRESSUI = 0x00004000
FD_LINKUI = 0x00008000
)
type FileGroupDescriptor struct {
CItems uint32 `struc:"little"`
Fgd []FileDescriptor `struc:"sizefrom=CItems"`
}
type FileDescriptor struct {
Flags uint32 `struc:"little"`
Clsid [16]byte `struc:"little"`
Sizel [8]byte `struc:"little"`
Pointl [8]byte `struc:"little"`
FileAttributes uint32 `struc:"little"`
CreationTime [8]byte `struc:"little"`
LastAccessTime [8]byte `struc:"little"`
LastWriteTime []byte `struc:"[8]byte"` //8
FileSizeHigh uint32 `struc:"little"`
FileSizeLow uint32 `struc:"little"`
FileName []byte `struc:"[512]byte"`
}
func (f *FileGroupDescriptor) Unpack(b []byte) error {
r := bytes.NewReader(b)
err := struc.Unpack(r, f)
if err != nil {
glog.Error(err)
}
return err
}
func (f *FileDescriptor) serialize() []byte {
b := &bytes.Buffer{}
core.WriteUInt32LE(f.Flags, b)
for i := 0; i < 32; i++ {
core.WriteByte(0, b)
}
core.WriteUInt32LE(f.FileAttributes, b)
for i := 0; i < 16; i++ {
core.WriteByte(0, b)
}
core.WriteBytes(f.LastWriteTime[:], b)
core.WriteUInt32LE(f.FileSizeHigh, b)
core.WriteUInt32LE(f.FileSizeLow, b)
name := make([]byte, 512)
copy(name, f.FileName)
core.WriteBytes(name, b)
return b.Bytes()
}
func (f *FileDescriptor) isDir() bool {
if f.Flags&FD_ATTRIBUTES != 0 {
return f.FileAttributes&FILE_ATTRIBUTE_DIRECTORY != 0
}
return false
}
func (f *FileDescriptor) hasFileSize() bool {
return f.Flags&FD_FILESIZE != 0
}
// temp dir
type CliprdrTempDirectory struct {
SzTempDir []byte `struc:"[260]byte"`
}
// format list
type CliprdrFormat struct {
FormatId uint32
FormatName string
}
type CliprdrFormatList struct {
NumFormats uint32
Formats []CliprdrFormat
}
type ClipboardFormats uint16
const (
CB_FORMAT_HTML = 0xD010
CB_FORMAT_PNG = 0xD011
CB_FORMAT_JPEG = 0xD012
CB_FORMAT_GIF = 0xD013
CB_FORMAT_TEXTURILIST = 0xD014
CB_FORMAT_GNOMECOPIEDFILES = 0xD015
CB_FORMAT_MATECOPIEDFILES = 0xD016
)
// lock or unlock
type CliprdrCtrlClipboardData struct {
ClipDataId uint32
}
// format data
type CliprdrFormatDataRequest struct {
RequestedFormatId uint32
}
type CliprdrFormatDataResponse struct {
RequestedFormatData []byte
}
// file contents
type CliprdrFileContentsRequest struct {
StreamId uint32 `struc:"little"`
Lindex uint32 `struc:"little"`
DwFlags uint32 `struc:"little"`
NPositionLow uint32 `struc:"little"`
NPositionHigh uint32 `struc:"little"`
CbRequested uint32 `struc:"little"`
ClipDataId uint32 `struc:"little"`
}
func FileContentsSizeRequest(i uint32) *CliprdrFileContentsRequest {
return &CliprdrFileContentsRequest{
StreamId: 1,
Lindex: i,
DwFlags: FILECONTENTS_SIZE,
NPositionLow: 0,
NPositionHigh: 0,
CbRequested: 65535,
ClipDataId: 0,
}
}
type CliprdrFileContentsResponse struct {
StreamId uint32
CbRequested uint32
RequestedData []byte
}
func (resp *CliprdrFileContentsResponse) Unpack(b []byte) {
r := bytes.NewReader(b)
resp.StreamId, _ = core.ReadUInt32LE(r)
resp.CbRequested = uint32(r.Len())
resp.RequestedData, _ = core.ReadBytes(int(resp.CbRequested), r)
}
type CliprdrClient struct {
w core.ChannelSender
useLongFormatNames bool
streamFileClipEnabled bool
fileClipNoFilePaths bool
canLockClipData bool
hasHugeFileSupport bool
formatIdMap map[uint32]uint32
Files []FileDescriptor
reply chan []byte
Control
}
func NewCliprdrClient() *CliprdrClient {
c := &CliprdrClient{
formatIdMap: make(map[uint32]uint32, 20),
Files: make([]FileDescriptor, 0, 20),
reply: make(chan []byte, 100),
}
go ClipWatcher(c)
return c
}
func (c *CliprdrClient) Send(s []byte) (int, error) {
glog.Debug("len:", len(s), "data:", hex.EncodeToString(s))
name, _ := c.GetType()
return c.w.SendToChannel(name, s)
}
func (c *CliprdrClient) Sender(f core.ChannelSender) {
c.w = f
}
func (c *CliprdrClient) GetType() (string, uint32) {
return ChannelName, ChannelOption
}
func (c *CliprdrClient) Process(s []byte) {
glog.Debug("recv:", hex.EncodeToString(s))
r := bytes.NewReader(s)
msgType, _ := core.ReadUint16LE(r)
flag, _ := core.ReadUint16LE(r)
length, _ := core.ReadUInt32LE(r)
glog.Debugf("cliprdr: type=0x%x flag=%d length=%d, all=%d", msgType, flag, length, r.Len())
b, _ := core.ReadBytes(int(length), r)
switch msgType {
case CB_CLIP_CAPS:
glog.Info("CB_CLIP_CAPS")
c.processClipCaps(b)
case CB_MONITOR_READY:
glog.Info("CB_MONITOR_READY")
c.processMonitorReady(b)
case CB_FORMAT_LIST:
glog.Info("CB_FORMAT_LIST")
c.processFormatList(b)
case CB_FORMAT_LIST_RESPONSE:
glog.Info("CB_FORMAT_LIST_RESPONSE")
c.processFormatListResponse(flag, b)
case CB_FORMAT_DATA_REQUEST:
glog.Info("CB_FORMAT_DATA_REQUEST")
c.processFormatDataRequest(b)
case CB_FORMAT_DATA_RESPONSE:
glog.Info("CB_FORMAT_DATA_RESPONSE")
c.processFormatDataResponse(flag, b)
case CB_FILECONTENTS_REQUEST:
glog.Info("CB_FILECONTENTS_REQUEST")
c.processFileContentsRequest(b)
case CB_FILECONTENTS_RESPONSE:
glog.Info("CB_FILECONTENTS_RESPONSE")
c.processFileContentsResponse(flag, b)
case CB_LOCK_CLIPDATA:
glog.Info("CB_LOCK_CLIPDATA")
c.processLockClipData(b)
case CB_UNLOCK_CLIPDATA:
glog.Info("CB_UNLOCK_CLIPDATA")
c.processUnlockClipData(b)
default:
glog.Errorf("type 0x%x not supported", msgType)
}
}
func (c *CliprdrClient) processClipCaps(b []byte) {
r := bytes.NewReader(b)
var cp CliprdrCapabilitiesPDU
err := struc.Unpack(r, &cp)
if err != nil {
glog.Error(err)
return
}
glog.Debugf("Capabilities:%+v", cp)
c.useLongFormatNames = cp.CapabilitySets[0].GeneralFlags&CB_USE_LONG_FORMAT_NAMES != 0
c.streamFileClipEnabled = cp.CapabilitySets[0].GeneralFlags&CB_STREAM_FILECLIP_ENABLED != 0
c.fileClipNoFilePaths = cp.CapabilitySets[0].GeneralFlags&CB_FILECLIP_NO_FILE_PATHS != 0
c.canLockClipData = cp.CapabilitySets[0].GeneralFlags&CB_CAN_LOCK_CLIPDATA != 0
c.hasHugeFileSupport = cp.CapabilitySets[0].GeneralFlags&CB_HUGE_FILE_SUPPORT_ENABLED != 0
glog.Info("UseLongFormatNames:", c.useLongFormatNames)
glog.Info("StreamFileClipEnabled:", c.streamFileClipEnabled)
glog.Info("FileClipNoFilePaths:", c.fileClipNoFilePaths)
glog.Info("CanLockClipData:", c.canLockClipData)
glog.Info("HasHugeFileSupport:", c.hasHugeFileSupport)
}
func (c *CliprdrClient) processMonitorReady(b []byte) {
//Client Clipboard Capabilities PDU
c.sendClientCapabilitiesPDU()
//Temporary Directory PDU
//c.sendTemporaryDirectoryPDU()
//Format List PDU
c.sendFormatListPDU()
}
func (c *CliprdrClient) processFormatList(b []byte) {
c.withOpenClipboard(func() {
if !EmptyClipboard() {
glog.Error("EmptyClipboard failed")
}
})
fl, hasFile := c.readForamtList(b)
glog.Info("numFormats:", fl.NumFormats)
if hasFile {
c.SendCliprdrMessage()
} else {
c.withOpenClipboard(func() {
if !EmptyClipboard() {
glog.Error("EmptyClipboard failed")
}
for i := range c.formatIdMap {
glog.Debug("i:", i)
SetClipboardData(i, 0)
}
})
}
c.sendFormatListResponse(CB_RESPONSE_OK)
}
func (c *CliprdrClient) processFormatListResponse(flag uint16, b []byte) {
if flag != CB_RESPONSE_OK {
glog.Error("Format List Response Failed")
return
}
glog.Error("Format List Response OK")
}
func getFilesDescriptor(name string) (FileDescriptor, error) {
var fd FileDescriptor
fd.Flags = FD_ATTRIBUTES | FD_FILESIZE | FD_WRITESTIME | FD_PROGRESSUI
f, e := os.Stat(name)
if e != nil {
glog.Error(e.Error())
return fd, e
}
fd.FileAttributes, fd.LastWriteTime,
fd.FileSizeHigh, fd.FileSizeLow = GetFileInfo(f.Sys())
fd.FileName = core.UnicodeEncode(name)
return fd, nil
}
func (c *CliprdrClient) processFormatDataRequest(b []byte) {
r := bytes.NewReader(b)
requestId, _ := core.ReadUInt32LE(r)
buff := &bytes.Buffer{}
if requestId == RegisterClipboardFormat(CFSTR_FILEDESCRIPTORW) {
fs := GetFileNames()
core.WriteUInt32LE(uint32(len(fs)), buff)
c.Files = c.Files[:0]
for _, v := range fs {
glog.Info("Name:", v)
f, _ := getFilesDescriptor(v)
buff.Write(f.serialize())
for i := 0; i < 8; i++ {
buff.WriteByte(0)
}
c.Files = append(c.Files, f)
}
} else {
c.withOpenClipboard(func() {
data := GetClipboardData(requestId)
glog.Debug("data:", data)
buff.Write(core.UnicodeEncode(data))
buff.Write([]byte{0, 0})
})
}
c.sendFormatDataResponse(buff.Bytes())
}
func (c *CliprdrClient) processFormatDataResponse(flag uint16, b []byte) {
if flag != CB_RESPONSE_OK {
glog.Error("Format Data Response Failed")
}
c.reply <- b
}
func (c *CliprdrClient) processFileContentsRequest(b []byte) {
r := bytes.NewReader(b)
var req CliprdrFileContentsRequest
struc.Unpack(r, &req)
if len(c.Files) <= int(req.Lindex) {
glog.Error("No found file:", req.Lindex)
c.sendFormatContentsResponse(req.StreamId, []byte{})
return
}
buff := &bytes.Buffer{}
/*o := OleGetClipboard()
var format_etc FORMATETC
var stg_medium STGMEDIUM
format_etc.CFormat = RegisterClipboardFormat(CFSTR_FILECONTENTS)
format_etc.Tymed = TYMED_ISTREAM
format_etc.Aspect = 1
format_etc.Index = req.Lindex
o.GetData(&format_etc, &stg_medium)
s, _ := stg_medium.Stream()*/
f := c.Files[req.Lindex]
if req.DwFlags == FILECONTENTS_SIZE {
core.WriteUInt32LE(f.FileSizeLow, buff)
core.WriteUInt32LE(f.FileSizeHigh, buff)
c.sendFormatContentsResponse(req.StreamId, buff.Bytes())
} else if req.DwFlags == FILECONTENTS_RANGE {
name := core.UnicodeDecode(f.FileName)
fi, err := os.Open(name)
if err != nil {
glog.Error(err.Error())
return
}
defer fi.Close()
data := make([]byte, req.CbRequested)
n, _ := fi.ReadAt(data, int64(f.FileSizeHigh))
c.sendFormatContentsResponse(req.StreamId, data[:n])
}
}
func (c *CliprdrClient) processFileContentsResponse(flag uint16, b []byte) {
if flag != CB_RESPONSE_OK {
glog.Error("File Contents Response Failed")
}
var resp CliprdrFileContentsResponse
resp.Unpack(b)
glog.Debug("Get File Contents Response:", resp.StreamId, resp.CbRequested)
c.reply <- resp.RequestedData
}
func (c *CliprdrClient) processLockClipData(b []byte) {
r := bytes.NewReader(b)
var l CliprdrCtrlClipboardData
l.ClipDataId, _ = core.ReadUInt32LE(r)
}
func (c *CliprdrClient) processUnlockClipData(b []byte) {
r := bytes.NewReader(b)
var l CliprdrCtrlClipboardData
l.ClipDataId, _ = core.ReadUInt32LE(r)
}
func (c *CliprdrClient) sendClientCapabilitiesPDU() {
glog.Info("Send Client Clipboard Capabilities PDU")
var cs CliprdrGeneralCapabilitySet
cs.CapabilitySetLength = 12
cs.CapabilitySetType = CB_CAPSTYPE_GENERAL
cs.Version = CB_CAPS_VERSION_2
cs.GeneralFlags = CB_USE_LONG_FORMAT_NAMES |
CB_STREAM_FILECLIP_ENABLED |
CB_FILECLIP_NO_FILE_PATHS
var cc CliprdrCapabilitiesPDU
cc.CCapabilitiesSets = 1
cc.Pad1 = 0
cc.CapabilitySets = make([]CliprdrGeneralCapabilitySet, 0, 1)
cc.CapabilitySets = append(cc.CapabilitySets, cs)
header := NewCliprdrPDUHeader(CB_CLIP_CAPS, 0, 16)
buff := &bytes.Buffer{}
buff.Write(header.serialize())
core.WriteUInt16LE(cc.CCapabilitiesSets, buff)
core.WriteUInt16LE(cc.Pad1, buff)
for _, v := range cc.CapabilitySets {
struc.Pack(buff, v)
}
c.Send(buff.Bytes())
}
func (c *CliprdrClient) sendTemporaryDirectoryPDU() {
glog.Info("Send Temporary Directory PDU")
var t CliprdrTempDirectory
header := &CliprdrPDUHeader{CB_TEMP_DIRECTORY, 0, 260}
t.SzTempDir = core.UnicodeEncode(os.TempDir())
buff := &bytes.Buffer{}
core.WriteBytes(header.serialize(), buff)
core.WriteBytes(t.SzTempDir, buff)
c.Send(buff.Bytes())
}
func (c *CliprdrClient) sendFormatListPDU() {
glog.Info("Send Format List PDU")
var f CliprdrFormatList
f.Formats = GetFormatList(c.hwnd)
f.NumFormats = uint32(len(f.Formats))
glog.Info("NumFormats:", f.NumFormats)
glog.Debug("Formats:", f.Formats)
b := &bytes.Buffer{}
for _, v := range f.Formats {
core.WriteUInt32LE(v.FormatId, b)
if v.FormatName == "" {
core.WriteUInt16LE(0, b)
} else {
n := core.UnicodeEncode(v.FormatName)
core.WriteBytes(n, b)
b.Write([]byte{0, 0})
}
}
header := NewCliprdrPDUHeader(CB_FORMAT_LIST, 0, uint32(b.Len()))
buff := &bytes.Buffer{}
buff.Write(header.serialize())
core.WriteBytes(b.Bytes(), buff)
c.Send(buff.Bytes())
}
func (c *CliprdrClient) readForamtList(b []byte) (*CliprdrFormatList, bool) {
r := bytes.NewReader(b)
fs := make([]CliprdrFormat, 0, 20)
var numFormats uint32 = 0
hasFile := false
c.formatIdMap = make(map[uint32]uint32, 0)
for r.Len() > 0 {
foramtId, _ := core.ReadUInt32LE(r)
bs := make([]uint16, 0, 20)
ln := r.Len()
for j := 0; j < ln; j++ {
b, _ := core.ReadUint16LE(r)
if b == 0 {
break
}
bs = append(bs, b)
}
name := string(utf16.Decode(bs))
if strings.EqualFold(name, CFSTR_FILEDESCRIPTORW) {
hasFile = true
}
glog.Infof("Foramt:%d Name:<%s>", foramtId, name)
if name != "" {
localId := RegisterClipboardFormat(name)
glog.Info("local:", localId, "remote:", foramtId)
c.formatIdMap[localId] = foramtId
} else {
c.formatIdMap[foramtId] = foramtId
}
numFormats++
fs = append(fs, CliprdrFormat{foramtId, name})
}
return &CliprdrFormatList{numFormats, fs}, hasFile
}
func (c *CliprdrClient) sendFormatListResponse(flags uint16) {
glog.Info("Send Format List Response")
header := NewCliprdrPDUHeader(CB_FORMAT_LIST_RESPONSE, flags, 0)
buff := &bytes.Buffer{}
buff.Write(header.serialize())
c.Send(buff.Bytes())
}
func (c *CliprdrClient) sendFormatDataRequest(id uint32) {
glog.Info("Send Format Data Request")
var r CliprdrFormatDataRequest
r.RequestedFormatId = id
header := NewCliprdrPDUHeader(CB_FORMAT_DATA_REQUEST, 0, 4)
buff := &bytes.Buffer{}
buff.Write(header.serialize())
core.WriteUInt32LE(r.RequestedFormatId, buff)
c.Send(buff.Bytes())
}
func (c *CliprdrClient) sendFormatDataResponse(b []byte) {
glog.Info("Send Format Data Response")
var resp CliprdrFormatDataResponse
resp.RequestedFormatData = b
header := NewCliprdrPDUHeader(CB_FORMAT_DATA_RESPONSE, CB_RESPONSE_OK, uint32(len(resp.RequestedFormatData)))
buff := &bytes.Buffer{}
buff.Write(header.serialize())
buff.Write(resp.RequestedFormatData)
c.Send(buff.Bytes())
}
func (c *CliprdrClient) sendFormatContentsRequest(r CliprdrFileContentsRequest) uint32 {
glog.Info("Send Format Contents Request")
glog.Debugf("Format Contents Request:%+v", r)
header := NewCliprdrPDUHeader(CB_FILECONTENTS_REQUEST, 0, 28)
buff := &bytes.Buffer{}
buff.Write(header.serialize())
core.WriteUInt32LE(r.StreamId, buff)
core.WriteUInt32LE(uint32(r.Lindex), buff)
core.WriteUInt32LE(r.DwFlags, buff)
core.WriteUInt32LE(r.NPositionLow, buff)
core.WriteUInt32LE(r.NPositionHigh, buff)
core.WriteUInt32LE(r.CbRequested, buff)
core.WriteUInt32LE(r.ClipDataId, buff)
c.Send(buff.Bytes())
return uint32(buff.Len())
}
func (c *CliprdrClient) sendFormatContentsResponse(streamId uint32, b []byte) {
glog.Info("Send Format Contents Response")
var r CliprdrFileContentsResponse
r.StreamId = streamId
r.RequestedData = b
r.CbRequested = uint32(len(b))
header := NewCliprdrPDUHeader(CB_FILECONTENTS_RESPONSE, CB_RESPONSE_OK, uint32(4+r.CbRequested))
buff := &bytes.Buffer{}
buff.Write(header.serialize())
core.WriteUInt32LE(r.StreamId, buff)
core.WriteBytes(r.RequestedData, buff)
c.Send(buff.Bytes())
}
func (c *CliprdrClient) sendLockClipData() {
glog.Info("Send Lock Clip Data")
var r CliprdrCtrlClipboardData
header := NewCliprdrPDUHeader(CB_LOCK_CLIPDATA, 0, 4)
buff := &bytes.Buffer{}
buff.Write(header.serialize())
core.WriteUInt32LE(r.ClipDataId, buff)
c.Send(buff.Bytes())
}
func (c *CliprdrClient) sendUnlockClipData() {
glog.Info("Send Unlock Clip Data")
var r CliprdrCtrlClipboardData
header := NewCliprdrPDUHeader(CB_UNLOCK_CLIPDATA, 0, 4)
buff := &bytes.Buffer{}
buff.Write(header.serialize())
core.WriteUInt32LE(r.ClipDataId, buff)
c.Send(buff.Bytes())
}

View File

@@ -1,353 +0,0 @@
// cliprdr_windows.go
package cliprdr
import (
"bytes"
"syscall"
"unicode/utf16"
"unsafe"
"github.com/shirou/w32"
"ShotRDP/grdp/core"
"ShotRDP/grdp/glog"
"ShotRDP/grdp/win"
)
const (
CFSTR_SHELLIDLIST = "Shell IDList Array"
CFSTR_SHELLIDLISTOFFSET = "Shell Object Offsets"
CFSTR_NETRESOURCES = "Net Resource"
CFSTR_FILECONTENTS = "FileContents"
CFSTR_FILENAMEA = "FileName"
CFSTR_FILENAMEMAPA = "FileNameMap"
CFSTR_FILEDESCRIPTORA = "FileGroupDescriptor"
CFSTR_INETURLA = "UniformResourceLocator"
CFSTR_SHELLURL = CFSTR_INETURLA
CFSTR_FILENAMEW = "FileNameW"
CFSTR_FILENAMEMAPW = "FileNameMapW"
CFSTR_FILEDESCRIPTORW = "FileGroupDescriptorW"
CFSTR_INETURLW = "UniformResourceLocatorW"
CFSTR_PRINTERGROUP = "PrinterFriendlyName"
CFSTR_INDRAGLOOP = "InShellDragLoop"
CFSTR_PASTESUCCEEDED = "Paste Succeeded"
CFSTR_PERFORMEDDROPEFFECT = "Performed DropEffect"
CFSTR_PREFERREDDROPEFFECT = "Preferred DropEffect"
)
const DVASPECT_CONTENT = 0x1
const (
CF_TEXT = 1
CF_BITMAP = 2
CF_METAFILEPICT = 3
CF_SYLK = 4
CF_DIF = 5
CF_TIFF = 6
CF_OEMTEXT = 7
CF_DIB = 8
CF_PALETTE = 9
CF_PENDATA = 10
CF_RIFF = 11
CF_WAVE = 12
CF_UNICODETEXT = 13
CF_ENHMETAFILE = 14
CF_HDROP = 15
CF_LOCALE = 16
CF_DIBV5 = 17
CF_MAX = 18
)
const (
WM_CLIPRDR_MESSAGE = (w32.WM_USER + 156)
OLE_SETCLIPBOARD = 1
)
type Control struct {
hwnd uintptr
dataObject *IDataObject
}
func (c *Control) withOpenClipboard(f func()) {
if OpenClipboard(c.hwnd) {
f()
CloseClipboard()
}
}
func ClipWatcher(c *CliprdrClient) {
win.OleInitialize(0)
defer win.OleUninitialize()
className := syscall.StringToUTF16Ptr("ClipboardHiddenMessageProcessor")
windowName := syscall.StringToUTF16Ptr("rdpclip")
wndClassEx := w32.WNDCLASSEX{
ClassName: className,
WndProc: syscall.NewCallback(func(hwnd w32.HWND, msg uint32, wParam, lParam uintptr) uintptr {
switch msg {
case w32.WM_CLIPBOARDUPDATE:
glog.Info("info: WM_CLIPBOARDUPDATE wParam:", wParam)
glog.Debug("IsClipboardOwner:", IsClipboardOwner(win.HWND(c.hwnd)))
glog.Debug("OleIsCurrentClipboard:", OleIsCurrentClipboard(c.dataObject))
if !IsClipboardOwner(win.HWND(c.hwnd)) && int(wParam) != 0 &&
!OleIsCurrentClipboard(c.dataObject) {
c.sendFormatListPDU()
}
case w32.WM_RENDERALLFORMATS:
glog.Info("info: WM_RENDERALLFORMATS")
c.withOpenClipboard(func() {
EmptyClipboard()
})
case w32.WM_RENDERFORMAT:
glog.Info("info: WM_RENDERFORMAT wParam:", wParam)
formatId := uint32(wParam)
c.sendFormatDataRequest(formatId)
b := <-c.reply
hmem := HmemAlloc(b)
SetClipboardData(formatId, hmem)
case WM_CLIPRDR_MESSAGE:
glog.Info("info: WM_CLIPRDR_MESSAGE wParam:", wParam)
if wParam == OLE_SETCLIPBOARD {
if !OleIsCurrentClipboard(c.dataObject) {
o := CreateDataObject(c)
OleSetClipboard(o)
c.dataObject = o
}
}
default:
return w32.DefWindowProc(hwnd, msg, wParam, lParam)
}
return 0
}),
Style: w32.CS_OWNDC,
}
wndClassEx.Size = uint32(unsafe.Sizeof(wndClassEx))
w32.RegisterClassEx(&wndClassEx)
hwnd := w32.CreateWindowEx(w32.WS_EX_LEFT, className, windowName, 0, 0, 0, 0, 0, w32.HWND_MESSAGE, 0, 0, nil)
c.hwnd = uintptr(hwnd)
w32.AddClipboardFormatListener(hwnd)
defer w32.RemoveClipboardFormatListener(hwnd)
msg := w32.MSG{}
for w32.GetMessage(&msg, 0, 0, 0) > 0 {
w32.DispatchMessage(&msg)
}
}
func OpenClipboard(hwnd uintptr) bool {
return win.OpenClipboard(win.HWND(hwnd))
}
func CloseClipboard() bool {
return win.CloseClipboard()
}
func CountClipboardFormats() int32 {
return win.CountClipboardFormats()
}
func IsClipboardFormatAvailable(id uint32) bool {
return win.IsClipboardFormatAvailable(win.UINT(id))
}
func EnumClipboardFormats(formatId uint32) uint32 {
id := win.EnumClipboardFormats(win.UINT(formatId))
return uint32(id)
}
func GetClipboardFormatName(id uint32) string {
buf := make([]uint16, 250)
n := win.GetClipboardFormatName(win.UINT(id), win.LPWSTR(unsafe.Pointer(&buf[0])), int32(len(buf)))
return string(utf16.Decode(buf[:n]))
}
func EmptyClipboard() bool {
return win.EmptyClipboard()
}
func RegisterClipboardFormat(format string) uint32 {
id := win.RegisterClipboardFormat(format)
return uint32(id)
}
func IsClipboardOwner(h win.HWND) bool {
hwnd := win.GetClipboardOwner()
return h == hwnd
}
func HmemAlloc(data []byte) uintptr {
ln := (len(data))
h := win.GlobalAlloc(0x0002, win.SIZE_T(ln))
if h == 0 {
return uintptr(h)
}
if ln == 0 {
return uintptr(h)
}
l := win.GlobalLock(h)
defer win.GlobalUnlock(h)
win.RtlCopyMemory(uintptr(unsafe.Pointer(l)), uintptr(unsafe.Pointer(&data[0])), win.SIZE_T(ln))
return uintptr(h)
}
func SetClipboardData(formatId uint32, hmem uintptr) bool {
r := win.SetClipboardData(win.UINT(formatId), win.HANDLE(hmem))
if r == 0 {
//glog.Error("SetClipboardData failed:", formatId, hmem)
return false
}
return true
}
func GetClipboardData(formatId uint32) string {
r := win.GetClipboardData(win.UINT(formatId))
if r == 0 {
return ""
}
h := win.GlobalHandle(uintptr(r))
size := win.GlobalSize(h)
l := win.GlobalLock(h)
defer win.GlobalUnlock(h)
result := make([]byte, size)
win.RtlCopyMemory(uintptr(unsafe.Pointer(&result[0])), uintptr(unsafe.Pointer(l)), size)
return core.UnicodeDecode(result)
}
func GetFormatList(hwnd uintptr) []CliprdrFormat {
list := make([]CliprdrFormat, 0, 10)
if OpenClipboard(hwnd) {
n := CountClipboardFormats()
if IsClipboardFormatAvailable(CF_HDROP) {
formatId := RegisterClipboardFormat(CFSTR_FILEDESCRIPTORW)
var f CliprdrFormat
f.FormatId = formatId
f.FormatName = CFSTR_FILEDESCRIPTORW
list = append(list, f)
formatId = RegisterClipboardFormat(CFSTR_FILECONTENTS)
var f1 CliprdrFormat
f1.FormatId = formatId
f1.FormatName = CFSTR_FILECONTENTS
list = append(list, f1)
} else {
var id uint32
for i := 0; i < int(n); i++ {
id = EnumClipboardFormats(id)
name := GetClipboardFormatName(id)
var f CliprdrFormat
f.FormatId = id
f.FormatName = name
list = append(list, f)
}
}
CloseClipboard()
}
return list
}
func OleGetClipboard() *IDataObject {
var dataObject *IDataObject
win.OleGetClipboard((**win.IDataObject)(unsafe.Pointer(&dataObject)))
return dataObject
}
func OleSetClipboard(dataObject *IDataObject) bool {
r := win.OleSetClipboard((*win.IDataObject)(unsafe.Pointer(dataObject)))
if r != 0 {
glog.Error("OleSetClipboard failed")
return false
}
return true
}
func OleIsCurrentClipboard(dataObject *IDataObject) bool {
r := win.OleIsCurrentClipboard((*win.IDataObject)(unsafe.Pointer(dataObject)))
if r != 0 {
return false
}
return true
}
func GlobalSize(hMem uintptr) win.SIZE_T {
return win.GlobalSize(win.HGLOBAL(hMem))
}
func GlobalLock(hMem uintptr) uintptr {
r := win.GlobalLock(win.HGLOBAL(hMem))
return uintptr(r)
}
func GlobalUnlock(hMem uintptr) {
win.GlobalUnlock(win.HGLOBAL(hMem))
}
func (c *Control) SendCliprdrMessage() {
win.PostMessage(win.HWND(c.hwnd), WM_CLIPRDR_MESSAGE, OLE_SETCLIPBOARD, 0)
}
func GetFileInfo(sys interface{}) (uint32, []byte, uint32, uint32) {
f := sys.(*syscall.Win32FileAttributeData)
b := &bytes.Buffer{}
core.WriteUInt32LE(f.LastWriteTime.LowDateTime, b)
core.WriteUInt32LE(f.LastWriteTime.HighDateTime, b)
return f.FileAttributes, b.Bytes(), f.FileSizeHigh, f.FileSizeLow
}
func GetFileNames() []string {
o := OleGetClipboard()
var formatEtc FORMATETC
var stgMedium STGMEDIUM
formatEtc.CFormat = CF_HDROP
formatEtc.Tymed = TYMED_HGLOBAL
formatEtc.Aspect = DVASPECT_CONTENT
formatEtc.Index = -1
o.GetData(&formatEtc, &stgMedium)
b, _ := stgMedium.Bytes()
//DROPFILES
r := bytes.NewReader(b[20:])
fs := make([]string, 0, 20)
for r.Len() > 0 {
bs := make([]uint16, 0, 20)
ln := r.Len()
for j := 0; j < ln; j++ {
b, _ := core.ReadUint16LE(r)
if b == 0 {
break
}
bs = append(bs, b)
}
name := string(utf16.Decode(bs))
if name == "" {
continue
}
fs = append(fs, name)
}
return fs
}
const (
/* File attribute flags */
FILE_SHARE_READ = 0x00000001
FILE_SHARE_WRITE = 0x00000002
FILE_SHARE_DELETE = 0x00000004
FILE_ATTRIBUTE_READONLY = 0x00000001
FILE_ATTRIBUTE_HIDDEN = 0x00000002
FILE_ATTRIBUTE_SYSTEM = 0x00000004
FILE_ATTRIBUTE_DIRECTORY = 0x00000010
FILE_ATTRIBUTE_ARCHIVE = 0x00000020
FILE_ATTRIBUTE_DEVICE = 0x00000040
FILE_ATTRIBUTE_NORMAL = 0x00000080
FILE_ATTRIBUTE_TEMPORARY = 0x00000100
FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200
FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400
FILE_ATTRIBUTE_COMPRESSED = 0x00000800
FILE_ATTRIBUTE_OFFLINE = 0x00001000
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000
FILE_ATTRIBUTE_ENCRYPTED = 0x00004000
FILE_ATTRIBUTE_INTEGRITY_STREAM = 0x00008000
FILE_ATTRIBUTE_VIRTUAL = 0x00010000
FILE_ATTRIBUTE_NO_SCRUB_DATA = 0x00020000
FILE_ATTRIBUTE_EA = 0x00040000
)
type DROPFILES struct {
pFiles uintptr
pt uintptr
fNC bool
fWide bool
}

View File

@@ -1,864 +0,0 @@
//go:build windows
// +build windows
// dataobject.go
package cliprdr
import (
"bytes"
"fmt"
"io"
"reflect"
"sync/atomic"
"syscall"
"unsafe"
"ShotRDP/grdp/core"
"ShotRDP/grdp/glog"
"ShotRDP/grdp/win"
)
const (
S_OK = 0x00000000
E_UNEXPECTED = 0x8000FFFF
E_NOTIMPL = 0x80004001
E_OUTOFMEMORY = 0x8007000E
E_INVALIDARG = 0x80070057
E_NOINTERFACE = 0x80004002
E_POINTER = 0x80004003
E_HANDLE = 0x80070006
E_ABORT = 0x80004004
E_FAIL = 0x80004005
E_ACCESSDENIED = 0x80070005
E_PENDING = 0x8000000A
E_ADVISENOTSUPPORTED = 0x80040003
E_FORMATETC = 0x80040064
CO_E_CLASSSTRING = 0x800401F3
)
type HRESULT uintptr
func (hr HRESULT) Error() string {
switch uint32(hr) {
case 0x80040064:
return "DV_E_FORMATETC (0x80040064)"
case 0x800401D3:
return "CLIPBRD_E_BAD_DATA (0x800401D3)"
case 0x80004005:
return "E_FAIL (0x80004005)"
case 0x00000001:
return "S_FALSE (0x00000001)"
}
return fmt.Sprintf("%d", hr)
}
const (
TYMED_NULL = 0x0
TYMED_HGLOBAL = 0x1
TYMED_FILE = 0x2
TYMED_ISTREAM = 0x4
TYMED_ISTORAGE = 0x8
TYMED_GDI = 0x10
TYMED_MFPICT = 0x20
TYMED_ENHMF = 0x40
)
type iUnknownVtbl struct {
QueryInterface uintptr
AddRef uintptr
Release uintptr
}
type iDataObjectVtbl struct {
iUnknownVtbl
GetData uintptr
GetDataHere uintptr
QueryGetData uintptr
GetCanonicalFormatEtc uintptr
SetData uintptr
EnumFormatEtc uintptr
DAdvise uintptr
DUnadvise uintptr
EnumDAdvise uintptr
}
type FORMATETC struct {
CFormat uint32
DvTargetDevice uintptr
Aspect uint32
Index int32
Tymed uint32
}
type STGMEDIUM struct {
Tymed uint32
UnionMember uintptr
PUnkForRelease *IUnknown
}
type ISequentialStreamVtbl struct {
iUnknownVtbl
Read uintptr
Write uintptr
}
type IUnknown struct {
vtbl iUnknownVtbl
}
func (obj *IUnknown) Release() error {
ret, _, _ := syscall.Syscall(
obj.vtbl.Release,
1,
uintptr(unsafe.Pointer(obj)),
0,
0,
)
if ret != 0 {
return HRESULT(ret)
}
return nil
}
func (m STGMEDIUM) Release() {
if m.PUnkForRelease == nil {
win.ReleaseStgMedium((*win.STGMEDIUM)(unsafe.Pointer(&m)))
}
}
func (m STGMEDIUM) Stream() (*IStream, error) {
if m.Tymed != TYMED_ISTREAM {
return nil, fmt.Errorf("invalid Tymed")
}
return (*IStream)(unsafe.Pointer(m.UnionMember)), nil
}
func (m STGMEDIUM) Bytes() ([]byte, error) {
if m.Tymed != TYMED_HGLOBAL {
return nil, fmt.Errorf("invalid Tymed")
}
size := GlobalSize(m.UnionMember)
l := GlobalLock(m.UnionMember)
defer GlobalUnlock(m.UnionMember)
result := make([]byte, size)
win.RtlCopyMemory(uintptr(unsafe.Pointer(&result[0])), uintptr(unsafe.Pointer(l)), size)
return result, nil
}
type IDataObject struct {
vtbl *iDataObjectVtbl
}
func (obj *IDataObject) Release() error {
ret, _, _ := syscall.Syscall(
obj.vtbl.Release,
1,
uintptr(unsafe.Pointer(obj)),
0,
0,
)
if ret != 0 {
return HRESULT(ret)
}
return nil
}
func (obj *IDataObject) GetData(formatEtc *FORMATETC, medium *STGMEDIUM) error {
s2 := unsafe.Sizeof(*medium)
_ = s2
ret, _, _ := syscall.Syscall(
obj.vtbl.GetData,
3,
uintptr(unsafe.Pointer(obj)),
uintptr(unsafe.Pointer(formatEtc)),
uintptr(unsafe.Pointer(medium)),
)
if ret != 0 {
return HRESULT(ret)
}
return nil
}
func (obj *IDataObject) GetDataHere(formatEtc *FORMATETC, medium *STGMEDIUM) error {
ret, _, _ := syscall.Syscall(
obj.vtbl.GetDataHere,
3,
uintptr(unsafe.Pointer(obj)),
uintptr(unsafe.Pointer(formatEtc)),
uintptr(unsafe.Pointer(medium)),
)
if ret != 0 {
return HRESULT(ret)
}
return nil
}
func (obj *IDataObject) QueryGetData(formatEtc *FORMATETC) error {
ret, _, _ := syscall.Syscall(
obj.vtbl.QueryGetData,
2,
uintptr(unsafe.Pointer(obj)),
uintptr(unsafe.Pointer(formatEtc)),
0,
)
if ret != 0 {
return HRESULT(ret)
}
return nil
}
func (obj *IDataObject) EnumFormatEtc(direction uint32, pIEnumFORMATETC **IEnumFORMATETC) error {
ret, _, _ := syscall.Syscall(
obj.vtbl.EnumFormatEtc,
3,
uintptr(unsafe.Pointer(obj)),
uintptr(direction),
uintptr(unsafe.Pointer(pIEnumFORMATETC)),
)
if ret != 0 {
return HRESULT(ret)
}
return nil
}
type iEnumFORMATETCVtbl struct {
iUnknownVtbl
Next uintptr
Skip uintptr
Reset uintptr
Clone uintptr
}
type IEnumFORMATETC struct {
vtbl *iEnumFORMATETCVtbl
}
func (obj *IEnumFORMATETC) Release() error {
ret, _, _ := syscall.Syscall(
obj.vtbl.Release,
1,
uintptr(unsafe.Pointer(obj)),
0,
0,
)
if ret != 0 {
return HRESULT(ret)
}
return nil
}
func (obj *IEnumFORMATETC) Next(formatEtc []FORMATETC, celtFetched *uint32) error {
ret, _, _ := syscall.Syscall6(
obj.vtbl.Next,
4,
uintptr(unsafe.Pointer(obj)),
uintptr(len(formatEtc)),
uintptr(unsafe.Pointer(&formatEtc[0])),
uintptr(unsafe.Pointer(celtFetched)),
0,
0,
)
if ret != 1 {
return HRESULT(ret)
}
return nil
}
type EnumInstance struct {
iEnumFORMATETC IEnumFORMATETC
refCount int32
index int
formatEtc []FORMATETC
}
var (
IID_IDataObject = win.GUID{0x10e, 0, 0, [8]byte{0xc0, 0, 0, 0, 0, 0, 0, 0x46}}
IID_IUnknown = win.GUID{0x000, 0, 0, [8]byte{0xc0, 0, 0, 0, 0, 0, 0, 0x46}}
IID_IEnumFORMATETC = win.GUID{0x103, 0, 0, [8]byte{0xc0, 0, 0, 0, 0, 0, 0, 0x46}}
IID_IStream = win.GUID{0x00c, 0, 0, [8]byte{0xc0, 0, 0, 0, 0, 0, 0, 0x46}}
)
func newEnumInstance(fs []FORMATETC) *EnumInstance {
var instance EnumInstance
ie := &instance.iEnumFORMATETC
ie.vtbl = new(iEnumFORMATETCVtbl)
ie.vtbl.QueryInterface = syscall.NewCallback((*EnumInstance).QueryInterface)
ie.vtbl.AddRef = syscall.NewCallback((*EnumInstance).AddRef)
ie.vtbl.Release = syscall.NewCallback((*EnumInstance).Release)
ie.vtbl.Next = syscall.NewCallback((*EnumInstance).Next)
ie.vtbl.Skip = syscall.NewCallback((*EnumInstance).Skip)
ie.vtbl.Reset = syscall.NewCallback((*EnumInstance).Reset)
ie.vtbl.Clone = syscall.NewCallback((*EnumInstance).Clone)
instance.refCount = 1
if len(fs) > 0 {
instance.formatEtc = make([]FORMATETC, len(fs))
copy(instance.formatEtc, fs)
}
return &instance
}
func (i *EnumInstance) QueryInterface(riid win.REFGUID, ppvObject *uintptr) uintptr {
if win.IsEqualGUID(riid, &IID_IEnumFORMATETC) ||
win.IsEqualGUID(riid, &IID_IUnknown) {
*ppvObject = uintptr(unsafe.Pointer(i))
i.AddRef()
return 0
}
*ppvObject = 0
return E_NOINTERFACE
}
func (i *EnumInstance) AddRef() uintptr {
n := atomic.AddInt32(&i.refCount, 1)
return uintptr(n)
}
func (i *EnumInstance) Release() uintptr {
n := atomic.AddInt32(&i.refCount, -1)
if n == 0 {
i = nil
return 0
}
return uintptr(n)
}
func (i *EnumInstance) Next(celt uint32, rgelt *FORMATETC, pceltFetched *uint32) uintptr {
r := make([]FORMATETC, celt)
var idx uint32
for i.index < len(i.formatEtc) && idx < celt {
r[idx] = i.formatEtc[i.index]
i.index++
idx++
}
*rgelt = r[0]
if pceltFetched != nil {
*pceltFetched = idx
}
if idx != celt {
return E_FAIL
}
return 0
}
func (i *EnumInstance) Skip(celt uint32) uintptr {
if i.index+int(celt) > len(i.formatEtc) {
return E_FAIL
}
i.index += int(celt)
return 0
}
func (i *EnumInstance) Reset() uintptr {
i.index = 0
return 0
}
func (i *EnumInstance) Clone(ppEnum **IEnumFORMATETC) uintptr {
ins := newEnumInstance(i.formatEtc)
ins.index = i.index
(*ppEnum) = (*IEnumFORMATETC)(unsafe.Pointer(ins))
return 0
}
func CreateDataObject(c *CliprdrClient) *IDataObject {
fmtetc := make([]FORMATETC, 2)
stgmeds := make([]STGMEDIUM, 2)
fmtetc[0].CFormat = RegisterClipboardFormat(CFSTR_FILEDESCRIPTORW)
fmtetc[0].Aspect = DVASPECT_CONTENT
fmtetc[0].Index = 0
//fmtetc[0].DvTargetDevice = nil
fmtetc[0].Tymed = TYMED_HGLOBAL
stgmeds[0].Tymed = TYMED_HGLOBAL
//stgmeds[0].UnionMember = nil
stgmeds[0].PUnkForRelease = nil
fmtetc[1].CFormat = RegisterClipboardFormat(CFSTR_FILECONTENTS)
fmtetc[1].Aspect = DVASPECT_CONTENT
fmtetc[1].Index = 0
//fmtetc[1].DvTargetDevice = nil
fmtetc[1].Tymed = TYMED_ISTREAM
stgmeds[1].Tymed = TYMED_ISTREAM
//stgmeds[1].UnionMember = nil
stgmeds[1].PUnkForRelease = nil
instance := newDataInstance()
instance.refCount = 1
instance.formatEtc = fmtetc
instance.stgMedium = stgmeds
instance.data = c
return (*IDataObject)(unsafe.Pointer(instance))
}
type DataInstance struct {
iDataObject IDataObject
refCount int32
idx int32
formatEtc []FORMATETC
stgMedium []STGMEDIUM
streams []*StreamInstance
data interface{}
}
func newDataInstance() *DataInstance {
var instance DataInstance
obj := &instance.iDataObject
obj.vtbl = new(iDataObjectVtbl)
obj.vtbl.QueryInterface = syscall.NewCallback((*DataInstance).QueryInterface)
obj.vtbl.AddRef = syscall.NewCallback((*DataInstance).AddRef)
obj.vtbl.Release = syscall.NewCallback((*DataInstance).Release)
obj.vtbl.GetData = syscall.NewCallback((*DataInstance).GetData)
obj.vtbl.GetDataHere = syscall.NewCallback((*DataInstance).GetDataHere)
obj.vtbl.QueryGetData = syscall.NewCallback((*DataInstance).QueryGetData)
obj.vtbl.GetCanonicalFormatEtc = syscall.NewCallback((*DataInstance).GetCanonicalFormatEtc)
obj.vtbl.SetData = syscall.NewCallback((*DataInstance).SetData)
obj.vtbl.EnumFormatEtc = syscall.NewCallback((*DataInstance).EnumFormatEtc)
obj.vtbl.DAdvise = syscall.NewCallback((*DataInstance).DAdvise)
obj.vtbl.DUnadvise = syscall.NewCallback((*DataInstance).DUnadvise)
obj.vtbl.EnumDAdvise = syscall.NewCallback((*DataInstance).EnumDAdvise)
return &instance
}
func (i *DataInstance) QueryInterface(riid win.REFGUID, ppvObject *uintptr) uintptr {
if win.IsEqualGUID(riid, &IID_IDataObject) ||
win.IsEqualGUID(riid, &IID_IUnknown) {
*ppvObject = uintptr(unsafe.Pointer(i))
i.AddRef()
return 0
}
*ppvObject = 0
return E_NOINTERFACE
}
func (i *DataInstance) AddRef() uintptr {
n := atomic.AddInt32(&i.refCount, 1)
return uintptr(n)
}
func (i *DataInstance) Release() uintptr {
n := atomic.AddInt32(&i.refCount, -1)
if n == 0 {
i = nil
return 0
}
return uintptr(n)
}
func (i *DataInstance) GetData(formatEtc *FORMATETC, medium *STGMEDIUM) uintptr {
idx := -1
for j, f := range i.formatEtc {
if formatEtc.Tymed&f.Tymed != 0 &&
formatEtc.CFormat == f.CFormat &&
formatEtc.Aspect&f.Aspect != 0 {
idx = j
}
}
if idx == -1 {
return E_FORMATETC
}
glog.Debugf("GetData:%+v, %s", formatEtc.CFormat, GetClipboardFormatName(formatEtc.CFormat))
medium.Tymed = i.formatEtc[idx].Tymed
if i.formatEtc[idx].CFormat == RegisterClipboardFormat(CFSTR_FILEDESCRIPTORW) {
c := i.data.(*CliprdrClient)
if remoteid, ok := c.formatIdMap[i.formatEtc[idx].CFormat]; ok {
c.sendFormatDataRequest(remoteid)
b := <-c.reply
if len(b) == 0 {
return E_FAIL
}
medium.UnionMember = HmemAlloc(b)
var dsc FileGroupDescriptor
dsc.Unpack(b)
if dsc.CItems > 0 {
glog.Debug("Items:", dsc.CItems)
i.streams = make([]*StreamInstance, dsc.CItems)
var j uint32
for j = 0; j < dsc.CItems; j++ {
glog.Debug("FileName:", core.UnicodeDecode(dsc.Fgd[j].FileName))
s := newStream(j, i.data, &dsc.Fgd[j])
i.streams[j] = s
}
}
}
} else if i.formatEtc[idx].CFormat == RegisterClipboardFormat(CFSTR_FILECONTENTS) {
if formatEtc.Index >= 0 && formatEtc.Index < int32(len(i.streams)) {
medium.UnionMember = uintptr(unsafe.Pointer(i.streams[formatEtc.Index]))
i.AddRef()
} else {
return E_INVALIDARG
}
} else {
return E_UNEXPECTED
}
return 0
}
func (i *DataInstance) GetDataHere(formatEtc *FORMATETC, medium *STGMEDIUM) uintptr {
return E_NOTIMPL
}
func (i *DataInstance) QueryGetData(formatEtc *FORMATETC) uintptr {
for _, f := range i.formatEtc {
if formatEtc.Tymed&f.Tymed != 0 &&
formatEtc.CFormat == f.CFormat &&
formatEtc.Aspect&f.Aspect != 0 {
return 0
}
}
return E_FORMATETC
}
func (i *DataInstance) GetCanonicalFormatEtc(informatEtc, outformatEtc *FORMATETC) uintptr {
return E_NOTIMPL
}
func (i *DataInstance) SetData(formatEtc *FORMATETC, medium *STGMEDIUM, r bool) uintptr {
return E_NOTIMPL
}
func (i *DataInstance) EnumFormatEtc(dwDirection uint32, ppenumFormatEtc **IEnumFORMATETC) uintptr {
if dwDirection == 1 {
ins := newEnumInstance(i.formatEtc)
(*ppenumFormatEtc) = (*IEnumFORMATETC)(unsafe.Pointer(ins))
return 0
}
return E_NOTIMPL
}
func (i *DataInstance) DAdvise(formatEtc *FORMATETC, advf uint32, pAdvSink uintptr, pdwConnection *uint32) uintptr {
return E_ADVISENOTSUPPORTED
}
func (i *DataInstance) DUnadvise(dwDirection uint32) uintptr {
return E_ADVISENOTSUPPORTED
}
func (i *DataInstance) EnumDAdvise(ppenumAdvise uintptr) uintptr {
return E_ADVISENOTSUPPORTED
}
const (
STREAM_SEEK_SET = 0
STREAM_SEEK_CUR = 1
STREAM_SEEK_END = 2
)
const (
STATFLAG_DEFAULT = 0
STATFLAG_NONAME = 1
STATFLAG_NOOPEN = 2
)
const (
STG_E_INSUFFICIENTMEMORY = 0x80030008
STG_E_INVALIDFLAG = 0x800300FF
)
const (
STGTY_STORAGE = 1
STGTY_STREAM = 2
STGTY_LOCKBYTES = 3
STGTY_PROPERTY = 4
)
const (
LOCK_WRITE = 1
LOCK_EXCLUSIVE = 2
LOCK_ONLYONCE = 4
)
const (
GENERIC_READ = 0x80000000
GENERIC_WRITE = 0x40000000
GENERIC_EXECUTE = 0x20000000
)
type IStreamVtbl struct {
ISequentialStreamVtbl
Seek uintptr
SetSize uintptr
CopyTo uintptr
Commit uintptr
Revert uintptr
LockRegion uintptr
UnlockRegion uintptr
Stat uintptr
Clone uintptr
}
type IStream struct {
vtbl *IStreamVtbl
}
type ULARGE_INTEGER struct {
QuadPart uint64
}
type LARGE_INTEGER struct {
QuadPart int64
}
func (l *ULARGE_INTEGER) LowPart() *uint32 {
return (*uint32)(unsafe.Pointer(&l.QuadPart))
}
func (l *ULARGE_INTEGER) HighPart() *uint32 {
return (*uint32)(unsafe.Pointer(uintptr(unsafe.Pointer(&l.QuadPart)) + uintptr(4)))
}
func (l *LARGE_INTEGER) LowPart() *uint32 {
return (*uint32)(unsafe.Pointer(&l.QuadPart))
}
func (l *LARGE_INTEGER) HighPart() *int32 {
return (*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&l.QuadPart)) + uintptr(4)))
}
type StreamInstance struct {
iStream IStream
streamId uint32
refCount int32
index uint32
lSize ULARGE_INTEGER
lOffset ULARGE_INTEGER
dsc FileDescriptor
data interface{}
}
type STATSTG struct {
pwcsName []uint16
sType uint32
cbSize ULARGE_INTEGER
mtime win.FILETIME
ctime win.FILETIME
atime win.FILETIME
grfMode uint32
grfLocksSupported uint32
clsid win.CLSID
grfStateBits uint32
reserved uint32
}
func (obj *IStream) Read(buffer []byte) (int, error) {
bufPtr := &buffer[0]
var read uint32
ret, _, _ := syscall.Syscall6(
obj.vtbl.Read,
4,
uintptr(unsafe.Pointer(obj)),
uintptr(unsafe.Pointer(bufPtr)),
uintptr(len(buffer)),
uintptr(unsafe.Pointer(&read)),
0,
0,
)
if ret == 1 {
return int(read), io.EOF
}
if ret != 0 {
return int(read), HRESULT(ret)
}
return int(read), nil
}
func (obj *IStream) Close() error {
return obj.Release()
}
func (obj *IStream) Release() error {
ret, _, _ := syscall.Syscall(
obj.vtbl.Release,
1,
uintptr(unsafe.Pointer(obj)),
0,
0,
)
if ret != 0 {
return HRESULT(ret)
}
return nil
}
func newStream(index uint32, data interface{}, dsc *FileDescriptor) *StreamInstance {
var instance StreamInstance
is := &instance.iStream
is.vtbl = new(IStreamVtbl)
is.vtbl.QueryInterface = syscall.NewCallback((*StreamInstance).QueryInterface)
is.vtbl.AddRef = syscall.NewCallback((*StreamInstance).AddRef)
is.vtbl.Release = syscall.NewCallback((*StreamInstance).Release)
is.vtbl.Read = syscall.NewCallback((*StreamInstance).Read)
is.vtbl.Write = syscall.NewCallback((*StreamInstance).Write)
is.vtbl.Seek = syscall.NewCallback((*StreamInstance).Seek)
is.vtbl.SetSize = syscall.NewCallback((*StreamInstance).SetSize)
is.vtbl.CopyTo = syscall.NewCallback((*StreamInstance).CopyTo)
is.vtbl.Commit = syscall.NewCallback((*StreamInstance).Commit)
is.vtbl.Revert = syscall.NewCallback((*StreamInstance).Revert)
is.vtbl.LockRegion = syscall.NewCallback((*StreamInstance).LockRegion)
is.vtbl.UnlockRegion = syscall.NewCallback((*StreamInstance).UnlockRegion)
is.vtbl.Stat = syscall.NewCallback((*StreamInstance).Stat)
is.vtbl.Clone = syscall.NewCallback((*StreamInstance).Clone)
instance.streamId = (uint32)(reflect.ValueOf(&instance).Pointer())
instance.refCount = 1
instance.dsc = *dsc
instance.data = data
instance.index = index
if !instance.dsc.hasFileSize() && !instance.dsc.isDir() {
c := data.(*CliprdrClient)
var r CliprdrFileContentsRequest
r.StreamId = instance.streamId
r.Lindex = instance.index
r.DwFlags = FILECONTENTS_SIZE
r.CbRequested = 8
c.sendFormatContentsRequest(r)
b := <-c.reply
instance.lSize.QuadPart = core.BytesToUint64(b)
} else {
b := &bytes.Buffer{}
core.WriteUInt32LE(dsc.FileSizeLow, b)
core.WriteUInt32LE(dsc.FileSizeHigh, b)
instance.lSize.QuadPart = core.BytesToUint64(b.Bytes())
}
return &instance
}
func (i *StreamInstance) QueryInterface(riid win.REFGUID, ppvObject *uintptr) uintptr {
if win.IsEqualGUID(riid, &IID_IStream) ||
win.IsEqualGUID(riid, &IID_IUnknown) {
*ppvObject = uintptr(unsafe.Pointer(i))
i.AddRef()
return 0
}
*ppvObject = 0
return E_NOINTERFACE
}
func (i *StreamInstance) AddRef() uintptr {
n := atomic.AddInt32(&i.refCount, 1)
return uintptr(n)
}
func (i *StreamInstance) Release() uintptr {
n := atomic.AddInt32(&i.refCount, -1)
if n == 0 {
i = nil
return 0
}
return uintptr(n)
}
func (i *StreamInstance) Read(pv uintptr, cb uint32, cbRead *uint32) uintptr {
glog.Debug("StreamInstance Read:", i.lOffset.QuadPart, i.lSize.QuadPart)
if i.lOffset.QuadPart >= i.lSize.QuadPart {
return 1
}
c := i.data.(*CliprdrClient)
*cbRead = 0
var r CliprdrFileContentsRequest
r.StreamId = i.streamId
r.Lindex = i.index
r.DwFlags = FILECONTENTS_RANGE
r.NPositionHigh = *(i.lOffset.HighPart())
r.NPositionLow = *(i.lOffset.LowPart())
r.CbRequested = cb
c.sendFormatContentsRequest(r)
b := <-c.reply
if len(b) == 0 {
return E_FAIL
}
win.RtlCopyMemory(pv, uintptr(unsafe.Pointer(&b[0])), win.SIZE_T(len(b)))
*cbRead = uint32(len(b))
i.lOffset.QuadPart += uint64(len(b))
glog.Debug("StreamInstance Read:", *cbRead, cb)
if *cbRead < cb {
return 1
}
return 0
}
func (i *StreamInstance) Write(pv uintptr, cb uint32, cbWritten *uint32) uintptr {
return E_ACCESSDENIED
}
func (i *StreamInstance) Seek(dlibMove LARGE_INTEGER, dwOrigin uint32, plibNewPosition *ULARGE_INTEGER) uintptr {
glog.Debug("StreamInstance Seek:", dwOrigin, dlibMove, plibNewPosition)
var newoffset uint64 = i.lOffset.QuadPart
switch dwOrigin {
case STREAM_SEEK_SET:
newoffset = uint64(dlibMove.QuadPart)
break
case STREAM_SEEK_CUR:
newoffset += uint64(dlibMove.QuadPart)
break
case STREAM_SEEK_END:
newoffset = i.lSize.QuadPart + uint64(dlibMove.QuadPart)
break
default:
return E_INVALIDARG
}
glog.Debug("StreamInstance Seek:", newoffset, i.lSize.QuadPart)
if newoffset < 0 || newoffset >= i.lSize.QuadPart {
return 1
}
i.lOffset.QuadPart = newoffset
if plibNewPosition != nil {
(*plibNewPosition).QuadPart = i.lOffset.QuadPart
}
return 0
}
func (i *StreamInstance) SetSize(libNewSize ULARGE_INTEGER) uintptr {
return E_NOTIMPL
}
func (i *StreamInstance) CopyTo(pstm *IStream, cb ULARGE_INTEGER, cbRead, cbWritten *ULARGE_INTEGER) uintptr {
return E_NOTIMPL
}
func (i *StreamInstance) Commit(grfCommitFlags uint32) uintptr {
return E_NOTIMPL
}
func (i *StreamInstance) Revert() uintptr {
return E_NOTIMPL
}
func (i *StreamInstance) LockRegion(libOffset, cb ULARGE_INTEGER, dwLockType uint32) uintptr {
return E_NOTIMPL
}
func (i *StreamInstance) UnlockRegion(libOffset, cb ULARGE_INTEGER, dwLockType uint32) uintptr {
return E_NOTIMPL
}
func (i *StreamInstance) Stat(pstatstg *STATSTG, grfStatFlag uint32) uintptr {
switch grfStatFlag {
case STATFLAG_DEFAULT:
return STG_E_INSUFFICIENTMEMORY
case STATFLAG_NONAME:
pstatstg.cbSize.QuadPart = i.lSize.QuadPart
pstatstg.grfLocksSupported = LOCK_EXCLUSIVE
pstatstg.grfMode = GENERIC_READ
pstatstg.grfStateBits = 0
pstatstg.sType = STGTY_STREAM
break
case STATFLAG_NOOPEN:
return STG_E_INVALIDFLAG
default:
return STG_E_INVALIDFLAG
}
return 0
}
func (i *StreamInstance) Clone(ppstm **IStream) uintptr {
return E_NOTIMPL
}

View File

@@ -11,7 +11,6 @@ import (
"ShotRDP/grdp/core"
"ShotRDP/grdp/emission"
"ShotRDP/grdp/glog"
"ShotRDP/grdp/plugin/cliprdr"
"ShotRDP/grdp/plugin/drdynvc"
"ShotRDP/grdp/plugin/rail"
"ShotRDP/grdp/protocol/t125/ber"
@@ -289,10 +288,6 @@ func (c *MCSClient) SetClientRemoteProgram() {
c.clientNetworkData.AddVirtualChannel(rail.ChannelName, rail.ChannelOption)
}
func (c *MCSClient) SetClientCliprdr() {
c.clientNetworkData.AddVirtualChannel(cliprdr.ChannelName, cliprdr.ChannelOption)
}
func (c *MCSClient) connect(selectedProtocol uint32) {
glog.Debug("mcs client on connect", selectedProtocol)
c.clientCoreData.ServerSelectedProtocol = selectedProtocol

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,135 +0,0 @@
// This file was automatically generated by https://github.com/kbinani/win/blob/generator/internal/cmd/gen/gen.go
// go run internal/cmd/gen/gen.go
// +build windows
package win
import (
"unsafe"
)
var (
// Library
libcomdlg32 uintptr
// Functions
chooseColor uintptr
chooseFont uintptr
commDlgExtendedError uintptr
findText uintptr
getFileTitle uintptr
getOpenFileName uintptr
getSaveFileName uintptr
pageSetupDlg uintptr
printDlgEx uintptr
printDlg uintptr
replaceText uintptr
)
func init() {
// Library
libcomdlg32 = doLoadLibrary("comdlg32.dll")
// Functions
chooseColor = doGetProcAddress(libcomdlg32, "ChooseColorW")
chooseFont = doGetProcAddress(libcomdlg32, "ChooseFontW")
commDlgExtendedError = doGetProcAddress(libcomdlg32, "CommDlgExtendedError")
findText = doGetProcAddress(libcomdlg32, "FindTextW")
getFileTitle = doGetProcAddress(libcomdlg32, "GetFileTitleW")
getOpenFileName = doGetProcAddress(libcomdlg32, "GetOpenFileNameW")
getSaveFileName = doGetProcAddress(libcomdlg32, "GetSaveFileNameW")
pageSetupDlg = doGetProcAddress(libcomdlg32, "PageSetupDlgW")
printDlgEx = doGetProcAddress(libcomdlg32, "PrintDlgExW")
printDlg = doGetProcAddress(libcomdlg32, "PrintDlgW")
replaceText = doGetProcAddress(libcomdlg32, "ReplaceTextW")
}
func ChooseColor(unnamed0 *CHOOSECOLOR) bool {
ret1 := syscall3(chooseColor, 1,
uintptr(unsafe.Pointer(unnamed0)),
0,
0)
return ret1 != 0
}
func ChooseFont(unnamed0 LPCHOOSEFONT) bool {
ret1 := syscall3(chooseFont, 1,
uintptr(unsafe.Pointer(unnamed0)),
0,
0)
return ret1 != 0
}
func CommDlgExtendedError() DWORD {
ret1 := syscall3(commDlgExtendedError, 0,
0,
0,
0)
return DWORD(ret1)
}
func FindText(unnamed0 LPFINDREPLACE) HWND {
ret1 := syscall3(findText, 1,
uintptr(unsafe.Pointer(unnamed0)),
0,
0)
return HWND(ret1)
}
func GetFileTitle(unnamed0 string, unnamed1 LPWSTR, unnamed2 WORD) int16 {
unnamed0Str := unicode16FromString(unnamed0)
ret1 := syscall3(getFileTitle, 3,
uintptr(unsafe.Pointer(&unnamed0Str[0])),
uintptr(unsafe.Pointer(unnamed1)),
uintptr(unnamed2))
return int16(ret1)
}
func GetOpenFileName(unnamed0 LPOPENFILENAME) bool {
ret1 := syscall3(getOpenFileName, 1,
uintptr(unsafe.Pointer(unnamed0)),
0,
0)
return ret1 != 0
}
func GetSaveFileName(unnamed0 LPOPENFILENAME) bool {
ret1 := syscall3(getSaveFileName, 1,
uintptr(unsafe.Pointer(unnamed0)),
0,
0)
return ret1 != 0
}
func PageSetupDlg(unnamed0 LPPAGESETUPDLG) bool {
ret1 := syscall3(pageSetupDlg, 1,
uintptr(unsafe.Pointer(unnamed0)),
0,
0)
return ret1 != 0
}
func PrintDlgEx(unnamed0 LPPRINTDLGEX) HRESULT {
ret1 := syscall3(printDlgEx, 1,
uintptr(unsafe.Pointer(unnamed0)),
0,
0)
return HRESULT(ret1)
}
func PrintDlg(unnamed0 LPPRINTDLG) bool {
ret1 := syscall3(printDlg, 1,
uintptr(unsafe.Pointer(unnamed0)),
0,
0)
return ret1 != 0
}
func ReplaceText(unnamed0 LPFINDREPLACE) HWND {
ret1 := syscall3(replaceText, 1,
uintptr(unsafe.Pointer(unnamed0)),
0,
0)
return HWND(ret1)
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,53 +0,0 @@
// This file was automatically generated by https://github.com/kbinani/win/blob/generator/internal/cmd/gen/gen.go
// go run internal/cmd/gen/gen.go
// +build windows
package win
import (
"unsafe"
)
var (
// Library
libgdiplus uintptr
// Functions
gdiplusNotificationHook uintptr
gdiplusNotificationUnhook uintptr
gdiplusStartup uintptr
)
func init() {
// Library
libgdiplus = doLoadLibrary("gdiplus.dll")
// Functions
gdiplusNotificationHook = doGetProcAddress(libgdiplus, "GdiplusNotificationHook")
gdiplusNotificationUnhook = doGetProcAddress(libgdiplus, "GdiplusNotificationUnhook")
gdiplusStartup = doGetProcAddress(libgdiplus, "GdiplusStartup")
}
func GdiplusNotificationHook(token *ULONG_PTR) GpStatus {
ret1 := syscall3(gdiplusNotificationHook, 1,
uintptr(unsafe.Pointer(token)),
0,
0)
return GpStatus(ret1)
}
func GdiplusNotificationUnhook(token *uint32) {
syscall3(gdiplusNotificationUnhook, 1,
uintptr(unsafe.Pointer(token)),
0,
0)
}
func GdiplusStartup(token *ULONG_PTR, input /*const*/ *GdiplusStartupInput, output *GdiplusStartupOutput) Status {
ret1 := syscall3(gdiplusStartup, 3,
uintptr(unsafe.Pointer(token)),
uintptr(unsafe.Pointer(input)),
uintptr(unsafe.Pointer(output)))
return Status(ret1)
}

View File

@@ -1,715 +0,0 @@
// This file was automatically generated by https://github.com/kbinani/win/blob/generator/internal/cmd/gen/gen.go
// go run internal/cmd/gen/gen.go
// +build windows
package win
import (
"syscall"
"unsafe"
)
var (
// Library
libimm32 uintptr
// Functions
immAssociateContext uintptr
immAssociateContextEx uintptr
immConfigureIME uintptr
immCreateContext uintptr
immDestroyContext uintptr
immDisableIME uintptr
immDisableTextFrameService uintptr
immEnumInputContext uintptr
immEnumRegisterWord uintptr
immEscape uintptr
immGetCandidateListCount uintptr
immGetCandidateList uintptr
immGetCandidateWindow uintptr
immGetCompositionFont uintptr
immGetCompositionString uintptr
immGetCompositionWindow uintptr
immGetContext uintptr
immGetConversionList uintptr
immGetConversionStatus uintptr
immGetDefaultIMEWnd uintptr
immGetDescription uintptr
immGetGuideLine uintptr
immGetIMEFileName uintptr
immGetImeMenuItems uintptr
immGetOpenStatus uintptr
immGetProperty uintptr
immGetRegisterWordStyle uintptr
immGetStatusWindowPos uintptr
immGetVirtualKey uintptr
immInstallIME uintptr
immIsIME uintptr
immIsUIMessage uintptr
immNotifyIME uintptr
immRegisterWord uintptr
immReleaseContext uintptr
immSetCandidateWindow uintptr
immSetCompositionFont uintptr
immSetCompositionString uintptr
immSetCompositionWindow uintptr
immSetConversionStatus uintptr
immSetOpenStatus uintptr
immSetStatusWindowPos uintptr
immSimulateHotKey uintptr
immUnregisterWord uintptr
immCreateIMCC uintptr
immCreateSoftKeyboard uintptr
immDestroyIMCC uintptr
immDestroySoftKeyboard uintptr
immGenerateMessage uintptr
immGetHotKey uintptr
immGetIMCCLockCount uintptr
immGetIMCCSize uintptr
immGetIMCLockCount uintptr
immLockIMC uintptr
immLockIMCC uintptr
immProcessKey uintptr
immReSizeIMCC uintptr
immRequestMessage uintptr
immShowSoftKeyboard uintptr
immTranslateMessage uintptr
immUnlockIMC uintptr
immUnlockIMCC uintptr
)
func init() {
// Library
libimm32 = doLoadLibrary("imm32.dll")
// Functions
immAssociateContext = doGetProcAddress(libimm32, "ImmAssociateContext")
immAssociateContextEx = doGetProcAddress(libimm32, "ImmAssociateContextEx")
immConfigureIME = doGetProcAddress(libimm32, "ImmConfigureIMEW")
immCreateContext = doGetProcAddress(libimm32, "ImmCreateContext")
immDestroyContext = doGetProcAddress(libimm32, "ImmDestroyContext")
immDisableIME = doGetProcAddress(libimm32, "ImmDisableIME")
immDisableTextFrameService = doGetProcAddress(libimm32, "ImmDisableTextFrameService")
immEnumInputContext = doGetProcAddress(libimm32, "ImmEnumInputContext")
immEnumRegisterWord = doGetProcAddress(libimm32, "ImmEnumRegisterWordW")
immEscape = doGetProcAddress(libimm32, "ImmEscapeW")
immGetCandidateListCount = doGetProcAddress(libimm32, "ImmGetCandidateListCountW")
immGetCandidateList = doGetProcAddress(libimm32, "ImmGetCandidateListW")
immGetCandidateWindow = doGetProcAddress(libimm32, "ImmGetCandidateWindow")
immGetCompositionFont = doGetProcAddress(libimm32, "ImmGetCompositionFontW")
immGetCompositionString = doGetProcAddress(libimm32, "ImmGetCompositionStringW")
immGetCompositionWindow = doGetProcAddress(libimm32, "ImmGetCompositionWindow")
immGetContext = doGetProcAddress(libimm32, "ImmGetContext")
immGetConversionList = doGetProcAddress(libimm32, "ImmGetConversionListW")
immGetConversionStatus = doGetProcAddress(libimm32, "ImmGetConversionStatus")
immGetDefaultIMEWnd = doGetProcAddress(libimm32, "ImmGetDefaultIMEWnd")
immGetDescription = doGetProcAddress(libimm32, "ImmGetDescriptionW")
immGetGuideLine = doGetProcAddress(libimm32, "ImmGetGuideLineW")
immGetIMEFileName = doGetProcAddress(libimm32, "ImmGetIMEFileNameW")
immGetImeMenuItems = doGetProcAddress(libimm32, "ImmGetImeMenuItemsW")
immGetOpenStatus = doGetProcAddress(libimm32, "ImmGetOpenStatus")
immGetProperty = doGetProcAddress(libimm32, "ImmGetProperty")
immGetRegisterWordStyle = doGetProcAddress(libimm32, "ImmGetRegisterWordStyleW")
immGetStatusWindowPos = doGetProcAddress(libimm32, "ImmGetStatusWindowPos")
immGetVirtualKey = doGetProcAddress(libimm32, "ImmGetVirtualKey")
immInstallIME = doGetProcAddress(libimm32, "ImmInstallIMEW")
immIsIME = doGetProcAddress(libimm32, "ImmIsIME")
immIsUIMessage = doGetProcAddress(libimm32, "ImmIsUIMessageW")
immNotifyIME = doGetProcAddress(libimm32, "ImmNotifyIME")
immRegisterWord = doGetProcAddress(libimm32, "ImmRegisterWordW")
immReleaseContext = doGetProcAddress(libimm32, "ImmReleaseContext")
immSetCandidateWindow = doGetProcAddress(libimm32, "ImmSetCandidateWindow")
immSetCompositionFont = doGetProcAddress(libimm32, "ImmSetCompositionFontW")
immSetCompositionString = doGetProcAddress(libimm32, "ImmSetCompositionStringW")
immSetCompositionWindow = doGetProcAddress(libimm32, "ImmSetCompositionWindow")
immSetConversionStatus = doGetProcAddress(libimm32, "ImmSetConversionStatus")
immSetOpenStatus = doGetProcAddress(libimm32, "ImmSetOpenStatus")
immSetStatusWindowPos = doGetProcAddress(libimm32, "ImmSetStatusWindowPos")
immSimulateHotKey = doGetProcAddress(libimm32, "ImmSimulateHotKey")
immUnregisterWord = doGetProcAddress(libimm32, "ImmUnregisterWordW")
immCreateIMCC = doGetProcAddress(libimm32, "ImmCreateIMCC")
immCreateSoftKeyboard = doGetProcAddress(libimm32, "ImmCreateSoftKeyboard")
immDestroyIMCC = doGetProcAddress(libimm32, "ImmDestroyIMCC")
immDestroySoftKeyboard = doGetProcAddress(libimm32, "ImmDestroySoftKeyboard")
immGenerateMessage = doGetProcAddress(libimm32, "ImmGenerateMessage")
immGetHotKey = doGetProcAddress(libimm32, "ImmGetHotKey")
immGetIMCCLockCount = doGetProcAddress(libimm32, "ImmGetIMCCLockCount")
immGetIMCCSize = doGetProcAddress(libimm32, "ImmGetIMCCSize")
immGetIMCLockCount = doGetProcAddress(libimm32, "ImmGetIMCLockCount")
immLockIMC = doGetProcAddress(libimm32, "ImmLockIMC")
immLockIMCC = doGetProcAddress(libimm32, "ImmLockIMCC")
immProcessKey = doGetProcAddress(libimm32, "ImmProcessKey")
immReSizeIMCC = doGetProcAddress(libimm32, "ImmReSizeIMCC")
immRequestMessage = doGetProcAddress(libimm32, "ImmRequestMessageW")
immShowSoftKeyboard = doGetProcAddress(libimm32, "ImmShowSoftKeyboard")
immTranslateMessage = doGetProcAddress(libimm32, "ImmTranslateMessage")
immUnlockIMC = doGetProcAddress(libimm32, "ImmUnlockIMC")
immUnlockIMCC = doGetProcAddress(libimm32, "ImmUnlockIMCC")
}
func ImmAssociateContext(unnamed0 HWND, unnamed1 HIMC) HIMC {
ret1 := syscall3(immAssociateContext, 2,
uintptr(unnamed0),
uintptr(unnamed1),
0)
return HIMC(ret1)
}
func ImmAssociateContextEx(unnamed0 HWND, unnamed1 HIMC, unnamed2 DWORD) bool {
ret1 := syscall3(immAssociateContextEx, 3,
uintptr(unnamed0),
uintptr(unnamed1),
uintptr(unnamed2))
return ret1 != 0
}
func ImmConfigureIME(unnamed0 HKL, unnamed1 HWND, unnamed2 DWORD, unnamed3 LPVOID) bool {
ret1 := syscall6(immConfigureIME, 4,
uintptr(unnamed0),
uintptr(unnamed1),
uintptr(unnamed2),
uintptr(unsafe.Pointer(unnamed3)),
0,
0)
return ret1 != 0
}
func ImmCreateContext() HIMC {
ret1 := syscall3(immCreateContext, 0,
0,
0,
0)
return HIMC(ret1)
}
func ImmDestroyContext(unnamed0 HIMC) bool {
ret1 := syscall3(immDestroyContext, 1,
uintptr(unnamed0),
0,
0)
return ret1 != 0
}
func ImmDisableIME(unnamed0 DWORD) bool {
ret1 := syscall3(immDisableIME, 1,
uintptr(unnamed0),
0,
0)
return ret1 != 0
}
func ImmDisableTextFrameService(idThread DWORD) bool {
ret1 := syscall3(immDisableTextFrameService, 1,
uintptr(idThread),
0,
0)
return ret1 != 0
}
func ImmEnumInputContext(idThread DWORD, lpfn IMCENUMPROC, lParam LPARAM) bool {
lpfnCallback := syscall.NewCallback(func(unnamed0RawArg HIMC, unnamed1RawArg LPARAM) uintptr {
ret := lpfn(unnamed0RawArg, unnamed1RawArg)
return uintptr(ret)
})
ret1 := syscall3(immEnumInputContext, 3,
uintptr(idThread),
lpfnCallback,
uintptr(lParam))
return ret1 != 0
}
func ImmEnumRegisterWord(unnamed0 HKL, unnamed1 REGISTERWORDENUMPROC, lpszReading string, unnamed3 DWORD, lpszRegister string, unnamed5 LPVOID) UINT {
lpszReadingStr := unicode16FromString(lpszReading)
lpszRegisterStr := unicode16FromString(lpszRegister)
unnamed1Callback := syscall.NewCallback(func(lpszReadingRawArg /*const*/ *uint16, unnamed1RawArg DWORD, lpszStringRawArg /*const*/ *uint16, unnamed3RawArg LPVOID) uintptr {
lpszReading := stringFromUnicode16(lpszReadingRawArg)
lpszString := stringFromUnicode16(lpszStringRawArg)
ret := unnamed1(lpszReading, unnamed1RawArg, lpszString, unnamed3RawArg)
return uintptr(ret)
})
ret1 := syscall6(immEnumRegisterWord, 6,
uintptr(unnamed0),
unnamed1Callback,
uintptr(unsafe.Pointer(&lpszReadingStr[0])),
uintptr(unnamed3),
uintptr(unsafe.Pointer(&lpszRegisterStr[0])),
uintptr(unsafe.Pointer(unnamed5)))
return UINT(ret1)
}
func ImmEscape(unnamed0 HKL, unnamed1 HIMC, unnamed2 UINT, unnamed3 LPVOID) LRESULT {
ret1 := syscall6(immEscape, 4,
uintptr(unnamed0),
uintptr(unnamed1),
uintptr(unnamed2),
uintptr(unsafe.Pointer(unnamed3)),
0,
0)
return LRESULT(ret1)
}
func ImmGetCandidateListCount(unnamed0 HIMC, lpdwListCount *uint32) DWORD {
ret1 := syscall3(immGetCandidateListCount, 2,
uintptr(unnamed0),
uintptr(unsafe.Pointer(lpdwListCount)),
0)
return DWORD(ret1)
}
func ImmGetCandidateList(unnamed0 HIMC, deIndex DWORD, unnamed2 *CANDIDATELIST, dwBufLen DWORD) DWORD {
ret1 := syscall6(immGetCandidateList, 4,
uintptr(unnamed0),
uintptr(deIndex),
uintptr(unsafe.Pointer(unnamed2)),
uintptr(dwBufLen),
0,
0)
return DWORD(ret1)
}
func ImmGetCandidateWindow(unnamed0 HIMC, unnamed1 DWORD, unnamed2 *CANDIDATEFORM) bool {
ret1 := syscall3(immGetCandidateWindow, 3,
uintptr(unnamed0),
uintptr(unnamed1),
uintptr(unsafe.Pointer(unnamed2)))
return ret1 != 0
}
func ImmGetCompositionFont(unnamed0 HIMC, unnamed1 LPLOGFONT) bool {
ret1 := syscall3(immGetCompositionFont, 2,
uintptr(unnamed0),
uintptr(unsafe.Pointer(unnamed1)),
0)
return ret1 != 0
}
func ImmGetCompositionString(unnamed0 HIMC, unnamed1 DWORD, unnamed2 LPVOID, unnamed3 DWORD) LONG {
ret1 := syscall6(immGetCompositionString, 4,
uintptr(unnamed0),
uintptr(unnamed1),
uintptr(unsafe.Pointer(unnamed2)),
uintptr(unnamed3),
0,
0)
return LONG(ret1)
}
func ImmGetCompositionWindow(unnamed0 HIMC, unnamed1 *COMPOSITIONFORM) bool {
ret1 := syscall3(immGetCompositionWindow, 2,
uintptr(unnamed0),
uintptr(unsafe.Pointer(unnamed1)),
0)
return ret1 != 0
}
func ImmGetContext(unnamed0 HWND) HIMC {
ret1 := syscall3(immGetContext, 1,
uintptr(unnamed0),
0,
0)
return HIMC(ret1)
}
func ImmGetConversionList(unnamed0 HKL, unnamed1 HIMC, unnamed2 string, unnamed3 *CANDIDATELIST, dwBufLen DWORD, uFlag UINT) DWORD {
unnamed2Str := unicode16FromString(unnamed2)
ret1 := syscall6(immGetConversionList, 6,
uintptr(unnamed0),
uintptr(unnamed1),
uintptr(unsafe.Pointer(&unnamed2Str[0])),
uintptr(unsafe.Pointer(unnamed3)),
uintptr(dwBufLen),
uintptr(uFlag))
return DWORD(ret1)
}
func ImmGetConversionStatus(unnamed0 HIMC, unnamed1 *uint32, unnamed2 *uint32) bool {
ret1 := syscall3(immGetConversionStatus, 3,
uintptr(unnamed0),
uintptr(unsafe.Pointer(unnamed1)),
uintptr(unsafe.Pointer(unnamed2)))
return ret1 != 0
}
func ImmGetDefaultIMEWnd(unnamed0 HWND) HWND {
ret1 := syscall3(immGetDefaultIMEWnd, 1,
uintptr(unnamed0),
0,
0)
return HWND(ret1)
}
func ImmGetDescription(unnamed0 HKL, unnamed1 LPWSTR, uBufLen UINT) UINT {
ret1 := syscall3(immGetDescription, 3,
uintptr(unnamed0),
uintptr(unsafe.Pointer(unnamed1)),
uintptr(uBufLen))
return UINT(ret1)
}
func ImmGetGuideLine(unnamed0 HIMC, dwIndex DWORD, unnamed2 LPWSTR, dwBufLen DWORD) DWORD {
ret1 := syscall6(immGetGuideLine, 4,
uintptr(unnamed0),
uintptr(dwIndex),
uintptr(unsafe.Pointer(unnamed2)),
uintptr(dwBufLen),
0,
0)
return DWORD(ret1)
}
func ImmGetIMEFileName(unnamed0 HKL, unnamed1 LPWSTR, uBufLen UINT) UINT {
ret1 := syscall3(immGetIMEFileName, 3,
uintptr(unnamed0),
uintptr(unsafe.Pointer(unnamed1)),
uintptr(uBufLen))
return UINT(ret1)
}
func ImmGetImeMenuItems(unnamed0 HIMC, unnamed1 DWORD, unnamed2 DWORD, unnamed3 LPIMEMENUITEMINFO, unnamed4 LPIMEMENUITEMINFO, unnamed5 DWORD) DWORD {
ret1 := syscall6(immGetImeMenuItems, 6,
uintptr(unnamed0),
uintptr(unnamed1),
uintptr(unnamed2),
uintptr(unsafe.Pointer(unnamed3)),
uintptr(unsafe.Pointer(unnamed4)),
uintptr(unnamed5))
return DWORD(ret1)
}
func ImmGetOpenStatus(unnamed0 HIMC) bool {
ret1 := syscall3(immGetOpenStatus, 1,
uintptr(unnamed0),
0,
0)
return ret1 != 0
}
func ImmGetProperty(unnamed0 HKL, unnamed1 DWORD) DWORD {
ret1 := syscall3(immGetProperty, 2,
uintptr(unnamed0),
uintptr(unnamed1),
0)
return DWORD(ret1)
}
func ImmGetRegisterWordStyle(unnamed0 HKL, nItem UINT, unnamed2 LPSTYLEBUF) UINT {
ret1 := syscall3(immGetRegisterWordStyle, 3,
uintptr(unnamed0),
uintptr(nItem),
uintptr(unsafe.Pointer(unnamed2)))
return UINT(ret1)
}
func ImmGetStatusWindowPos(unnamed0 HIMC, unnamed1 *POINT) bool {
ret1 := syscall3(immGetStatusWindowPos, 2,
uintptr(unnamed0),
uintptr(unsafe.Pointer(unnamed1)),
0)
return ret1 != 0
}
func ImmGetVirtualKey(unnamed0 HWND) UINT {
ret1 := syscall3(immGetVirtualKey, 1,
uintptr(unnamed0),
0,
0)
return UINT(ret1)
}
func ImmInstallIME(lpszIMEFileName string, lpszLayoutText string) HKL {
lpszIMEFileNameStr := unicode16FromString(lpszIMEFileName)
lpszLayoutTextStr := unicode16FromString(lpszLayoutText)
ret1 := syscall3(immInstallIME, 2,
uintptr(unsafe.Pointer(&lpszIMEFileNameStr[0])),
uintptr(unsafe.Pointer(&lpszLayoutTextStr[0])),
0)
return HKL(ret1)
}
func ImmIsIME(unnamed0 HKL) bool {
ret1 := syscall3(immIsIME, 1,
uintptr(unnamed0),
0,
0)
return ret1 != 0
}
func ImmIsUIMessage(unnamed0 HWND, unnamed1 UINT, unnamed2 WPARAM, unnamed3 LPARAM) bool {
ret1 := syscall6(immIsUIMessage, 4,
uintptr(unnamed0),
uintptr(unnamed1),
uintptr(unnamed2),
uintptr(unnamed3),
0,
0)
return ret1 != 0
}
func ImmNotifyIME(unnamed0 HIMC, dwAction DWORD, dwIndex DWORD, dwValue DWORD) bool {
ret1 := syscall6(immNotifyIME, 4,
uintptr(unnamed0),
uintptr(dwAction),
uintptr(dwIndex),
uintptr(dwValue),
0,
0)
return ret1 != 0
}
func ImmRegisterWord(unnamed0 HKL, lpszReading string, unnamed2 DWORD, lpszRegister string) bool {
lpszReadingStr := unicode16FromString(lpszReading)
lpszRegisterStr := unicode16FromString(lpszRegister)
ret1 := syscall6(immRegisterWord, 4,
uintptr(unnamed0),
uintptr(unsafe.Pointer(&lpszReadingStr[0])),
uintptr(unnamed2),
uintptr(unsafe.Pointer(&lpszRegisterStr[0])),
0,
0)
return ret1 != 0
}
func ImmReleaseContext(unnamed0 HWND, unnamed1 HIMC) bool {
ret1 := syscall3(immReleaseContext, 2,
uintptr(unnamed0),
uintptr(unnamed1),
0)
return ret1 != 0
}
func ImmSetCandidateWindow(unnamed0 HIMC, unnamed1 *CANDIDATEFORM) bool {
ret1 := syscall3(immSetCandidateWindow, 2,
uintptr(unnamed0),
uintptr(unsafe.Pointer(unnamed1)),
0)
return ret1 != 0
}
func ImmSetCompositionFont(unnamed0 HIMC, unnamed1 LPLOGFONT) bool {
ret1 := syscall3(immSetCompositionFont, 2,
uintptr(unnamed0),
uintptr(unsafe.Pointer(unnamed1)),
0)
return ret1 != 0
}
func ImmSetCompositionString(unnamed0 HIMC, dwIndex DWORD, lpComp LPVOID, unnamed3 DWORD, lpRead LPVOID, unnamed5 DWORD) bool {
ret1 := syscall6(immSetCompositionString, 6,
uintptr(unnamed0),
uintptr(dwIndex),
uintptr(unsafe.Pointer(lpComp)),
uintptr(unnamed3),
uintptr(unsafe.Pointer(lpRead)),
uintptr(unnamed5))
return ret1 != 0
}
func ImmSetCompositionWindow(unnamed0 HIMC, unnamed1 *COMPOSITIONFORM) bool {
ret1 := syscall3(immSetCompositionWindow, 2,
uintptr(unnamed0),
uintptr(unsafe.Pointer(unnamed1)),
0)
return ret1 != 0
}
func ImmSetConversionStatus(unnamed0 HIMC, unnamed1 DWORD, unnamed2 DWORD) bool {
ret1 := syscall3(immSetConversionStatus, 3,
uintptr(unnamed0),
uintptr(unnamed1),
uintptr(unnamed2))
return ret1 != 0
}
func ImmSetOpenStatus(unnamed0 HIMC, unnamed1 bool) bool {
ret1 := syscall3(immSetOpenStatus, 2,
uintptr(unnamed0),
getUintptrFromBool(unnamed1),
0)
return ret1 != 0
}
func ImmSetStatusWindowPos(unnamed0 HIMC, unnamed1 *POINT) bool {
ret1 := syscall3(immSetStatusWindowPos, 2,
uintptr(unnamed0),
uintptr(unsafe.Pointer(unnamed1)),
0)
return ret1 != 0
}
func ImmSimulateHotKey(unnamed0 HWND, unnamed1 DWORD) bool {
ret1 := syscall3(immSimulateHotKey, 2,
uintptr(unnamed0),
uintptr(unnamed1),
0)
return ret1 != 0
}
func ImmUnregisterWord(unnamed0 HKL, lpszReading string, unnamed2 DWORD, lpszUnregister string) bool {
lpszReadingStr := unicode16FromString(lpszReading)
lpszUnregisterStr := unicode16FromString(lpszUnregister)
ret1 := syscall6(immUnregisterWord, 4,
uintptr(unnamed0),
uintptr(unsafe.Pointer(&lpszReadingStr[0])),
uintptr(unnamed2),
uintptr(unsafe.Pointer(&lpszUnregisterStr[0])),
0,
0)
return ret1 != 0
}
func ImmCreateIMCC(size DWORD) HIMCC {
ret1 := syscall3(immCreateIMCC, 1,
uintptr(size),
0,
0)
return HIMCC(ret1)
}
func ImmCreateSoftKeyboard(uType UINT, hOwner UINT, x int32, y int32) HWND {
ret1 := syscall6(immCreateSoftKeyboard, 4,
uintptr(uType),
uintptr(hOwner),
uintptr(x),
uintptr(y),
0,
0)
return HWND(ret1)
}
func ImmDestroyIMCC(block HIMCC) HIMCC {
ret1 := syscall3(immDestroyIMCC, 1,
uintptr(block),
0,
0)
return HIMCC(ret1)
}
func ImmDestroySoftKeyboard(hSoftWnd HWND) bool {
ret1 := syscall3(immDestroySoftKeyboard, 1,
uintptr(hSoftWnd),
0,
0)
return ret1 != 0
}
func ImmGenerateMessage(hIMC HIMC) bool {
ret1 := syscall3(immGenerateMessage, 1,
uintptr(hIMC),
0,
0)
return ret1 != 0
}
func ImmGetHotKey(hotkey DWORD, modifiers *UINT, key *UINT, hkl HKL) bool {
ret1 := syscall6(immGetHotKey, 4,
uintptr(hotkey),
uintptr(unsafe.Pointer(modifiers)),
uintptr(unsafe.Pointer(key)),
uintptr(hkl),
0,
0)
return ret1 != 0
}
func ImmGetIMCCLockCount(imcc HIMCC) DWORD {
ret1 := syscall3(immGetIMCCLockCount, 1,
uintptr(imcc),
0,
0)
return DWORD(ret1)
}
func ImmGetIMCCSize(imcc HIMCC) DWORD {
ret1 := syscall3(immGetIMCCSize, 1,
uintptr(imcc),
0,
0)
return DWORD(ret1)
}
func ImmGetIMCLockCount(hIMC HIMC) DWORD {
ret1 := syscall3(immGetIMCLockCount, 1,
uintptr(hIMC),
0,
0)
return DWORD(ret1)
}
func ImmLockIMC(hIMC HIMC) *INPUTCONTEXT {
ret1 := syscall3(immLockIMC, 1,
uintptr(hIMC),
0,
0)
return (*INPUTCONTEXT)(unsafe.Pointer(ret1))
}
func ImmLockIMCC(imcc HIMCC) LPVOID {
ret1 := syscall3(immLockIMCC, 1,
uintptr(imcc),
0,
0)
return (LPVOID)(unsafe.Pointer(ret1))
}
func ImmProcessKey(hwnd HWND, hKL HKL, vKey UINT, lKeyData LPARAM, unknown DWORD) bool {
ret1 := syscall6(immProcessKey, 5,
uintptr(hwnd),
uintptr(hKL),
uintptr(vKey),
uintptr(lKeyData),
uintptr(unknown),
0)
return ret1 != 0
}
func ImmReSizeIMCC(imcc HIMCC, size DWORD) HIMCC {
ret1 := syscall3(immReSizeIMCC, 2,
uintptr(imcc),
uintptr(size),
0)
return HIMCC(ret1)
}
func ImmRequestMessage(hIMC HIMC, wParam WPARAM, lParam LPARAM) LRESULT {
ret1 := syscall3(immRequestMessage, 3,
uintptr(hIMC),
uintptr(wParam),
uintptr(lParam))
return LRESULT(ret1)
}
func ImmShowSoftKeyboard(hSoftWnd HWND, nCmdShow int32) bool {
ret1 := syscall3(immShowSoftKeyboard, 2,
uintptr(hSoftWnd),
uintptr(nCmdShow),
0)
return ret1 != 0
}
func ImmTranslateMessage(hwnd HWND, msg UINT, wParam WPARAM, lKeyData LPARAM) bool {
ret1 := syscall6(immTranslateMessage, 4,
uintptr(hwnd),
uintptr(msg),
uintptr(wParam),
uintptr(lKeyData),
0,
0)
return ret1 != 0
}
func ImmUnlockIMC(hIMC HIMC) bool {
ret1 := syscall3(immUnlockIMC, 1,
uintptr(hIMC),
0,
0)
return ret1 != 0
}
func ImmUnlockIMCC(imcc HIMCC) bool {
ret1 := syscall3(immUnlockIMCC, 1,
uintptr(imcc),
0,
0)
return ret1 != 0
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,328 +0,0 @@
// This file was automatically generated by https://github.com/kbinani/win/blob/generator/internal/cmd/gen/gen.go
// go run internal/cmd/gen/gen.go
// +build windows
package win
import (
"unsafe"
)
var (
// Library
libpdh uintptr
// Functions
pdhAddCounter uintptr
pdhAddEnglishCounter uintptr
pdhBindInputDataSource uintptr
pdhCalculateCounterFromRawValue uintptr
pdhCloseQuery uintptr
pdhCollectQueryData uintptr
pdhCollectQueryDataEx uintptr
pdhCollectQueryDataWithTime uintptr
pdhEnumObjectItems uintptr
pdhExpandCounterPath uintptr
pdhExpandWildCardPath uintptr
pdhGetCounterInfo uintptr
pdhGetCounterTimeBase uintptr
pdhGetDllVersion uintptr
pdhGetFormattedCounterValue uintptr
pdhGetLogFileType uintptr
pdhGetRawCounterValue uintptr
pdhLookupPerfIndexByName uintptr
pdhLookupPerfNameByIndex uintptr
pdhMakeCounterPath uintptr
pdhOpenQuery uintptr
pdhRemoveCounter uintptr
pdhSetCounterScaleFactor uintptr
pdhSetDefaultRealTimeDataSource uintptr
pdhValidatePathEx uintptr
pdhValidatePath uintptr
)
func init() {
// Library
libpdh = doLoadLibrary("pdh.dll")
// Functions
pdhAddCounter = doGetProcAddress(libpdh, "PdhAddCounterW")
pdhAddEnglishCounter = doGetProcAddress(libpdh, "PdhAddEnglishCounterW")
pdhBindInputDataSource = doGetProcAddress(libpdh, "PdhBindInputDataSourceW")
pdhCalculateCounterFromRawValue = doGetProcAddress(libpdh, "PdhCalculateCounterFromRawValue")
pdhCloseQuery = doGetProcAddress(libpdh, "PdhCloseQuery")
pdhCollectQueryData = doGetProcAddress(libpdh, "PdhCollectQueryData")
pdhCollectQueryDataEx = doGetProcAddress(libpdh, "PdhCollectQueryDataEx")
pdhCollectQueryDataWithTime = doGetProcAddress(libpdh, "PdhCollectQueryDataWithTime")
pdhEnumObjectItems = doGetProcAddress(libpdh, "PdhEnumObjectItemsW")
pdhExpandCounterPath = doGetProcAddress(libpdh, "PdhExpandCounterPathW")
pdhExpandWildCardPath = doGetProcAddress(libpdh, "PdhExpandWildCardPathW")
pdhGetCounterInfo = doGetProcAddress(libpdh, "PdhGetCounterInfoW")
pdhGetCounterTimeBase = doGetProcAddress(libpdh, "PdhGetCounterTimeBase")
pdhGetDllVersion = doGetProcAddress(libpdh, "PdhGetDllVersion")
pdhGetFormattedCounterValue = doGetProcAddress(libpdh, "PdhGetFormattedCounterValue")
pdhGetLogFileType = doGetProcAddress(libpdh, "PdhGetLogFileTypeW")
pdhGetRawCounterValue = doGetProcAddress(libpdh, "PdhGetRawCounterValue")
pdhLookupPerfIndexByName = doGetProcAddress(libpdh, "PdhLookupPerfIndexByNameW")
pdhLookupPerfNameByIndex = doGetProcAddress(libpdh, "PdhLookupPerfNameByIndexW")
pdhMakeCounterPath = doGetProcAddress(libpdh, "PdhMakeCounterPathW")
pdhOpenQuery = doGetProcAddress(libpdh, "PdhOpenQueryW")
pdhRemoveCounter = doGetProcAddress(libpdh, "PdhRemoveCounter")
pdhSetCounterScaleFactor = doGetProcAddress(libpdh, "PdhSetCounterScaleFactor")
pdhSetDefaultRealTimeDataSource = doGetProcAddress(libpdh, "PdhSetDefaultRealTimeDataSource")
pdhValidatePathEx = doGetProcAddress(libpdh, "PdhValidatePathExW")
pdhValidatePath = doGetProcAddress(libpdh, "PdhValidatePathW")
}
func PdhAddCounter(hquery PDH_HQUERY, path string, userdata *uint32, hcounter *PDH_HCOUNTER) PDH_STATUS {
pathStr := unicode16FromString(path)
ret1 := syscall6(pdhAddCounter, 4,
uintptr(hquery),
uintptr(unsafe.Pointer(&pathStr[0])),
uintptr(unsafe.Pointer(userdata)),
uintptr(unsafe.Pointer(hcounter)),
0,
0)
return PDH_STATUS(ret1)
}
func PdhAddEnglishCounter(query PDH_HQUERY, path string, userdata *uint32, counter *PDH_HCOUNTER) PDH_STATUS {
pathStr := unicode16FromString(path)
ret1 := syscall6(pdhAddEnglishCounter, 4,
uintptr(query),
uintptr(unsafe.Pointer(&pathStr[0])),
uintptr(unsafe.Pointer(userdata)),
uintptr(unsafe.Pointer(counter)),
0,
0)
return PDH_STATUS(ret1)
}
func PdhBindInputDataSource(source *PDH_HLOG, filenamelist /*const*/ *WCHAR) PDH_STATUS {
ret1 := syscall3(pdhBindInputDataSource, 2,
uintptr(unsafe.Pointer(source)),
uintptr(unsafe.Pointer(filenamelist)),
0)
return PDH_STATUS(ret1)
}
func PdhCalculateCounterFromRawValue(handle PDH_HCOUNTER, format DWORD, raw1 *PDH_RAW_COUNTER, raw2 *PDH_RAW_COUNTER, value *PDH_FMT_COUNTERVALUE) PDH_STATUS {
ret1 := syscall6(pdhCalculateCounterFromRawValue, 5,
uintptr(handle),
uintptr(format),
uintptr(unsafe.Pointer(raw1)),
uintptr(unsafe.Pointer(raw2)),
uintptr(unsafe.Pointer(value)),
0)
return PDH_STATUS(ret1)
}
func PdhCloseQuery(handle PDH_HQUERY) PDH_STATUS {
ret1 := syscall3(pdhCloseQuery, 1,
uintptr(handle),
0,
0)
return PDH_STATUS(ret1)
}
func PdhCollectQueryData(handle PDH_HQUERY) PDH_STATUS {
ret1 := syscall3(pdhCollectQueryData, 1,
uintptr(handle),
0,
0)
return PDH_STATUS(ret1)
}
func PdhCollectQueryDataEx(handle PDH_HQUERY, interval DWORD, event HANDLE) PDH_STATUS {
ret1 := syscall3(pdhCollectQueryDataEx, 3,
uintptr(handle),
uintptr(interval),
uintptr(event))
return PDH_STATUS(ret1)
}
func PdhCollectQueryDataWithTime(handle PDH_HQUERY, timestamp *LONGLONG) PDH_STATUS {
ret1 := syscall3(pdhCollectQueryDataWithTime, 2,
uintptr(handle),
uintptr(unsafe.Pointer(timestamp)),
0)
return PDH_STATUS(ret1)
}
func PdhEnumObjectItems(szDataSource string, szMachineName string, szObjectName string, mszCounterList LPWSTR, pcchCounterListLength *uint32, mszInstanceList LPWSTR, pcchInstanceListLength *uint32, dwDetailLevel DWORD, dwFlags DWORD) PDH_STATUS {
szDataSourceStr := unicode16FromString(szDataSource)
szMachineNameStr := unicode16FromString(szMachineName)
szObjectNameStr := unicode16FromString(szObjectName)
ret1 := syscall9(pdhEnumObjectItems, 9,
uintptr(unsafe.Pointer(&szDataSourceStr[0])),
uintptr(unsafe.Pointer(&szMachineNameStr[0])),
uintptr(unsafe.Pointer(&szObjectNameStr[0])),
uintptr(unsafe.Pointer(mszCounterList)),
uintptr(unsafe.Pointer(pcchCounterListLength)),
uintptr(unsafe.Pointer(mszInstanceList)),
uintptr(unsafe.Pointer(pcchInstanceListLength)),
uintptr(dwDetailLevel),
uintptr(dwFlags))
return PDH_STATUS(ret1)
}
func PdhExpandCounterPath(szWildCardPath string, mszExpandedPathList LPWSTR, pcchPathListLength *uint32) PDH_STATUS {
szWildCardPathStr := unicode16FromString(szWildCardPath)
ret1 := syscall3(pdhExpandCounterPath, 3,
uintptr(unsafe.Pointer(&szWildCardPathStr[0])),
uintptr(unsafe.Pointer(mszExpandedPathList)),
uintptr(unsafe.Pointer(pcchPathListLength)))
return PDH_STATUS(ret1)
}
func PdhExpandWildCardPath(szDataSource string, szWildCardPath string, mszExpandedPathList LPWSTR, pcchPathListLength *uint32, dwFlags DWORD) PDH_STATUS {
szDataSourceStr := unicode16FromString(szDataSource)
szWildCardPathStr := unicode16FromString(szWildCardPath)
ret1 := syscall6(pdhExpandWildCardPath, 5,
uintptr(unsafe.Pointer(&szDataSourceStr[0])),
uintptr(unsafe.Pointer(&szWildCardPathStr[0])),
uintptr(unsafe.Pointer(mszExpandedPathList)),
uintptr(unsafe.Pointer(pcchPathListLength)),
uintptr(dwFlags),
0)
return PDH_STATUS(ret1)
}
func PdhGetCounterInfo(handle PDH_HCOUNTER, text BOOLEAN, size *uint32, info *PDH_COUNTER_INFO) PDH_STATUS {
ret1 := syscall6(pdhGetCounterInfo, 4,
uintptr(handle),
uintptr(text),
uintptr(unsafe.Pointer(size)),
uintptr(unsafe.Pointer(info)),
0,
0)
return PDH_STATUS(ret1)
}
func PdhGetCounterTimeBase(handle PDH_HCOUNTER, base *LONGLONG) PDH_STATUS {
ret1 := syscall3(pdhGetCounterTimeBase, 2,
uintptr(handle),
uintptr(unsafe.Pointer(base)),
0)
return PDH_STATUS(ret1)
}
func PdhGetDllVersion(version *uint32) PDH_STATUS {
ret1 := syscall3(pdhGetDllVersion, 1,
uintptr(unsafe.Pointer(version)),
0,
0)
return PDH_STATUS(ret1)
}
func PdhGetFormattedCounterValue(handle PDH_HCOUNTER, format DWORD, aType *uint32, value *PDH_FMT_COUNTERVALUE) PDH_STATUS {
ret1 := syscall6(pdhGetFormattedCounterValue, 4,
uintptr(handle),
uintptr(format),
uintptr(unsafe.Pointer(aType)),
uintptr(unsafe.Pointer(value)),
0,
0)
return PDH_STATUS(ret1)
}
func PdhGetLogFileType(log /*const*/ *WCHAR, aType *uint32) PDH_STATUS {
ret1 := syscall3(pdhGetLogFileType, 2,
uintptr(unsafe.Pointer(log)),
uintptr(unsafe.Pointer(aType)),
0)
return PDH_STATUS(ret1)
}
func PdhGetRawCounterValue(handle PDH_HCOUNTER, aType *uint32, value *PDH_RAW_COUNTER) PDH_STATUS {
ret1 := syscall3(pdhGetRawCounterValue, 3,
uintptr(handle),
uintptr(unsafe.Pointer(aType)),
uintptr(unsafe.Pointer(value)))
return PDH_STATUS(ret1)
}
func PdhLookupPerfIndexByName(machine string, name string, index *uint32) PDH_STATUS {
machineStr := unicode16FromString(machine)
nameStr := unicode16FromString(name)
ret1 := syscall3(pdhLookupPerfIndexByName, 3,
uintptr(unsafe.Pointer(&machineStr[0])),
uintptr(unsafe.Pointer(&nameStr[0])),
uintptr(unsafe.Pointer(index)))
return PDH_STATUS(ret1)
}
func PdhLookupPerfNameByIndex(machine string, index DWORD, buffer LPWSTR, size *uint32) PDH_STATUS {
machineStr := unicode16FromString(machine)
ret1 := syscall6(pdhLookupPerfNameByIndex, 4,
uintptr(unsafe.Pointer(&machineStr[0])),
uintptr(index),
uintptr(unsafe.Pointer(buffer)),
uintptr(unsafe.Pointer(size)),
0,
0)
return PDH_STATUS(ret1)
}
func PdhMakeCounterPath(e *PDH_COUNTER_PATH_ELEMENTS, buffer LPWSTR, buflen *uint32, flags DWORD) PDH_STATUS {
ret1 := syscall6(pdhMakeCounterPath, 4,
uintptr(unsafe.Pointer(e)),
uintptr(unsafe.Pointer(buffer)),
uintptr(unsafe.Pointer(buflen)),
uintptr(flags),
0,
0)
return PDH_STATUS(ret1)
}
func PdhOpenQuery(source LPCWSTR, userdata *uint32, handle *PDH_HQUERY) PDH_STATUS {
//sourceStr := unicode16FromString(source)
ret1 := syscall3(pdhOpenQuery, 3,
uintptr(unsafe.Pointer(source)),
uintptr(unsafe.Pointer(userdata)),
uintptr(unsafe.Pointer(handle)))
return PDH_STATUS(ret1)
}
func PdhRemoveCounter(handle PDH_HCOUNTER) PDH_STATUS {
ret1 := syscall3(pdhRemoveCounter, 1,
uintptr(handle),
0,
0)
return PDH_STATUS(ret1)
}
func PdhSetCounterScaleFactor(handle PDH_HCOUNTER, factor LONG) PDH_STATUS {
ret1 := syscall3(pdhSetCounterScaleFactor, 2,
uintptr(handle),
uintptr(factor),
0)
return PDH_STATUS(ret1)
}
func PdhSetDefaultRealTimeDataSource(source DWORD) PDH_STATUS {
ret1 := syscall3(pdhSetDefaultRealTimeDataSource, 1,
uintptr(source),
0,
0)
return PDH_STATUS(ret1)
}
func PdhValidatePathEx(source PDH_HLOG, path string) PDH_STATUS {
pathStr := unicode16FromString(path)
ret1 := syscall3(pdhValidatePathEx, 2,
uintptr(source),
uintptr(unsafe.Pointer(&pathStr[0])),
0)
return PDH_STATUS(ret1)
}
func PdhValidatePath(path string) PDH_STATUS {
pathStr := unicode16FromString(path)
ret1 := syscall3(pdhValidatePath, 1,
uintptr(unsafe.Pointer(&pathStr[0])),
0,
0)
return PDH_STATUS(ret1)
}

View File

@@ -1,248 +0,0 @@
// This file was automatically generated by https://github.com/kbinani/win/blob/generator/internal/cmd/gen/gen.go
// go run internal/cmd/gen/gen.go
// +build windows
package win
import (
"syscall"
"unsafe"
)
var (
// Library
libpsapi uintptr
// Functions
emptyWorkingSet uintptr
enumDeviceDrivers uintptr
enumPageFiles uintptr
enumProcessModules uintptr
enumProcessModulesEx uintptr
enumProcesses uintptr
getDeviceDriverBaseName uintptr
getDeviceDriverFileName uintptr
getMappedFileName uintptr
getModuleBaseName uintptr
getModuleFileNameEx uintptr
getModuleInformation uintptr
getPerformanceInfo uintptr
getProcessImageFileName uintptr
getProcessMemoryInfo uintptr
getWsChanges uintptr
getWsChangesEx uintptr
initializeProcessForWsWatch uintptr
queryWorkingSet uintptr
queryWorkingSetEx uintptr
)
func init() {
// Library
libpsapi = doLoadLibrary("psapi.dll")
// Functions
emptyWorkingSet = doGetProcAddress(libpsapi, "EmptyWorkingSet")
enumDeviceDrivers = doGetProcAddress(libpsapi, "EnumDeviceDrivers")
enumPageFiles = doGetProcAddress(libpsapi, "EnumPageFilesW")
enumProcessModules = doGetProcAddress(libpsapi, "EnumProcessModules")
enumProcessModulesEx = doGetProcAddress(libpsapi, "EnumProcessModulesEx")
enumProcesses = doGetProcAddress(libpsapi, "EnumProcesses")
getDeviceDriverBaseName = doGetProcAddress(libpsapi, "GetDeviceDriverBaseNameW")
getDeviceDriverFileName = doGetProcAddress(libpsapi, "GetDeviceDriverFileNameW")
getMappedFileName = doGetProcAddress(libpsapi, "GetMappedFileNameW")
getModuleBaseName = doGetProcAddress(libpsapi, "GetModuleBaseNameW")
getModuleFileNameEx = doGetProcAddress(libpsapi, "GetModuleFileNameExW")
getModuleInformation = doGetProcAddress(libpsapi, "GetModuleInformation")
getPerformanceInfo = doGetProcAddress(libpsapi, "GetPerformanceInfo")
getProcessImageFileName = doGetProcAddress(libpsapi, "GetProcessImageFileNameW")
getProcessMemoryInfo = doGetProcAddress(libpsapi, "GetProcessMemoryInfo")
getWsChanges = doGetProcAddress(libpsapi, "GetWsChanges")
getWsChangesEx = doGetProcAddress(libpsapi, "GetWsChangesEx")
initializeProcessForWsWatch = doGetProcAddress(libpsapi, "InitializeProcessForWsWatch")
queryWorkingSet = doGetProcAddress(libpsapi, "QueryWorkingSet")
queryWorkingSetEx = doGetProcAddress(libpsapi, "QueryWorkingSetEx")
}
func EmptyWorkingSet(hProcess HANDLE) bool {
ret1 := syscall3(emptyWorkingSet, 1,
uintptr(hProcess),
0,
0)
return ret1 != 0
}
func EnumDeviceDrivers(lpImageBase *LPVOID, cb DWORD, lpcbNeeded *uint32) bool {
ret1 := syscall3(enumDeviceDrivers, 3,
uintptr(unsafe.Pointer(lpImageBase)),
uintptr(cb),
uintptr(unsafe.Pointer(lpcbNeeded)))
return ret1 != 0
}
func EnumPageFiles(pCallBackRoutine PENUM_PAGE_FILE_CALLBACK, pContext LPVOID) bool {
pCallBackRoutineCallback := syscall.NewCallback(func(pContextRawArg LPVOID, pPageFileInfoRawArg PENUM_PAGE_FILE_INFORMATION, lpFilenameRawArg /*const*/ *uint16) uintptr {
lpFilename := stringFromUnicode16(lpFilenameRawArg)
ret := pCallBackRoutine(pContextRawArg, pPageFileInfoRawArg, lpFilename)
return uintptr(ret)
})
ret1 := syscall3(enumPageFiles, 2,
pCallBackRoutineCallback,
uintptr(unsafe.Pointer(pContext)),
0)
return ret1 != 0
}
func EnumProcessModules(hProcess HANDLE, lphModule *HMODULE, cb DWORD, lpcbNeeded *uint32) bool {
ret1 := syscall6(enumProcessModules, 4,
uintptr(hProcess),
uintptr(unsafe.Pointer(lphModule)),
uintptr(cb),
uintptr(unsafe.Pointer(lpcbNeeded)),
0,
0)
return ret1 != 0
}
func EnumProcessModulesEx(hProcess HANDLE, lphModule *HMODULE, cb DWORD, lpcbNeeded *uint32, dwFilterFlag DWORD) bool {
ret1 := syscall6(enumProcessModulesEx, 5,
uintptr(hProcess),
uintptr(unsafe.Pointer(lphModule)),
uintptr(cb),
uintptr(unsafe.Pointer(lpcbNeeded)),
uintptr(dwFilterFlag),
0)
return ret1 != 0
}
func EnumProcesses(lpidProcess *uint32, cb DWORD, cbNeeded *uint32) bool {
ret1 := syscall3(enumProcesses, 3,
uintptr(unsafe.Pointer(lpidProcess)),
uintptr(cb),
uintptr(unsafe.Pointer(cbNeeded)))
return ret1 != 0
}
func GetDeviceDriverBaseName(imageBase LPVOID, lpBaseName LPWSTR, nSize DWORD) DWORD {
ret1 := syscall3(getDeviceDriverBaseName, 3,
uintptr(unsafe.Pointer(imageBase)),
uintptr(unsafe.Pointer(lpBaseName)),
uintptr(nSize))
return DWORD(ret1)
}
func GetDeviceDriverFileName(imageBase LPVOID, lpFilename LPWSTR, nSize DWORD) DWORD {
ret1 := syscall3(getDeviceDriverFileName, 3,
uintptr(unsafe.Pointer(imageBase)),
uintptr(unsafe.Pointer(lpFilename)),
uintptr(nSize))
return DWORD(ret1)
}
func GetMappedFileName(hProcess HANDLE, lpv LPVOID, lpFilename LPWSTR, nSize DWORD) DWORD {
ret1 := syscall6(getMappedFileName, 4,
uintptr(hProcess),
uintptr(unsafe.Pointer(lpv)),
uintptr(unsafe.Pointer(lpFilename)),
uintptr(nSize),
0,
0)
return DWORD(ret1)
}
func GetModuleBaseName(hProcess HANDLE, hModule HMODULE, lpBaseName LPWSTR, nSize DWORD) DWORD {
ret1 := syscall6(getModuleBaseName, 4,
uintptr(hProcess),
uintptr(hModule),
uintptr(unsafe.Pointer(lpBaseName)),
uintptr(nSize),
0,
0)
return DWORD(ret1)
}
func GetModuleFileNameEx(hProcess HANDLE, hModule HMODULE, lpFilename LPWSTR, nSize DWORD) DWORD {
ret1 := syscall6(getModuleFileNameEx, 4,
uintptr(hProcess),
uintptr(hModule),
uintptr(unsafe.Pointer(lpFilename)),
uintptr(nSize),
0,
0)
return DWORD(ret1)
}
func GetModuleInformation(hProcess HANDLE, hModule HMODULE, lpmodinfo *MODULEINFO, cb DWORD) bool {
ret1 := syscall6(getModuleInformation, 4,
uintptr(hProcess),
uintptr(hModule),
uintptr(unsafe.Pointer(lpmodinfo)),
uintptr(cb),
0,
0)
return ret1 != 0
}
func GetPerformanceInfo(pPerformanceInformation PPERFORMACE_INFORMATION, cb DWORD) bool {
ret1 := syscall3(getPerformanceInfo, 2,
uintptr(unsafe.Pointer(pPerformanceInformation)),
uintptr(cb),
0)
return ret1 != 0
}
func GetProcessImageFileName(hProcess HANDLE, lpImageFileName LPWSTR, nSize DWORD) DWORD {
ret1 := syscall3(getProcessImageFileName, 3,
uintptr(hProcess),
uintptr(unsafe.Pointer(lpImageFileName)),
uintptr(nSize))
return DWORD(ret1)
}
func GetProcessMemoryInfo(process HANDLE, ppsmemCounters PPROCESS_MEMORY_COUNTERS, cb DWORD) bool {
ret1 := syscall3(getProcessMemoryInfo, 3,
uintptr(process),
uintptr(unsafe.Pointer(ppsmemCounters)),
uintptr(cb))
return ret1 != 0
}
func GetWsChanges(hProcess HANDLE, lpWatchInfo PPSAPI_WS_WATCH_INFORMATION, cb DWORD) bool {
ret1 := syscall3(getWsChanges, 3,
uintptr(hProcess),
uintptr(unsafe.Pointer(lpWatchInfo)),
uintptr(cb))
return ret1 != 0
}
func GetWsChangesEx(hProcess HANDLE, lpWatchInfoEx PPSAPI_WS_WATCH_INFORMATION_EX, cb DWORD) bool {
ret1 := syscall3(getWsChangesEx, 3,
uintptr(hProcess),
uintptr(unsafe.Pointer(lpWatchInfoEx)),
uintptr(cb))
return ret1 != 0
}
func InitializeProcessForWsWatch(hProcess HANDLE) bool {
ret1 := syscall3(initializeProcessForWsWatch, 1,
uintptr(hProcess),
0,
0)
return ret1 != 0
}
func QueryWorkingSet(hProcess HANDLE, pv uintptr, cb DWORD) bool {
ret1 := syscall3(queryWorkingSet, 3,
uintptr(hProcess),
pv,
uintptr(cb))
return ret1 != 0
}
func QueryWorkingSetEx(hProcess HANDLE, pv uintptr, cb DWORD) bool {
ret1 := syscall3(queryWorkingSetEx, 3,
uintptr(hProcess),
pv,
uintptr(cb))
return ret1 != 0
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,340 +0,0 @@
// This file was automatically generated by https://github.com/kbinani/win/blob/generator/internal/cmd/gen/gen.go
package win
import (
"unsafe"
)
type INPUTCONTEXT struct {
storage [320]byte
}
func (this *INPUTCONTEXT) HWnd() *HWND { // 4
return (*HWND)(unsafe.Pointer(&this.storage[0]))
}
func (this *INPUTCONTEXT) FOpen() *BOOL { // 4
return (*BOOL)(unsafe.Pointer(&this.storage[4]))
}
func (this *INPUTCONTEXT) PtStatusWndPos() *POINT { // 8
return (*POINT)(unsafe.Pointer(&this.storage[8]))
}
func (this *INPUTCONTEXT) PtSoftKbdPos() *POINT { // 8
return (*POINT)(unsafe.Pointer(&this.storage[16]))
}
func (this *INPUTCONTEXT) FdwConversion() *DWORD { // 4
return (*DWORD)(unsafe.Pointer(&this.storage[24]))
}
func (this *INPUTCONTEXT) FdwSentence() *DWORD { // 4
return (*DWORD)(unsafe.Pointer(&this.storage[28]))
}
func (this *INPUTCONTEXT) LfFont() *LOGFONT { // 92
return (*LOGFONT)(unsafe.Pointer(&this.storage[32]))
}
func (this *INPUTCONTEXT) CfCompForm() *COMPOSITIONFORM { // 28
return (*COMPOSITIONFORM)(unsafe.Pointer(&this.storage[124]))
}
func (this *INPUTCONTEXT) CfCandForm() *[4]CANDIDATEFORM { // 128
return (*[4]CANDIDATEFORM)(unsafe.Pointer(&this.storage[152]))
}
func (this *INPUTCONTEXT) HCompStr() *HIMCC { // 4
return (*HIMCC)(unsafe.Pointer(&this.storage[280]))
}
func (this *INPUTCONTEXT) HCandInfo() *HIMCC { // 4
return (*HIMCC)(unsafe.Pointer(&this.storage[284]))
}
func (this *INPUTCONTEXT) HGuideLine() *HIMCC { // 4
return (*HIMCC)(unsafe.Pointer(&this.storage[288]))
}
func (this *INPUTCONTEXT) HPrivate() *HIMCC { // 4
return (*HIMCC)(unsafe.Pointer(&this.storage[292]))
}
func (this *INPUTCONTEXT) DwNumMsgBuf() *DWORD { // 4
return (*DWORD)(unsafe.Pointer(&this.storage[296]))
}
func (this *INPUTCONTEXT) HMsgBuf() *HIMCC { // 4
return (*HIMCC)(unsafe.Pointer(&this.storage[300]))
}
func (this *INPUTCONTEXT) FdwInit() *DWORD { // 4
return (*DWORD)(unsafe.Pointer(&this.storage[304]))
}
func (this *INPUTCONTEXT) DwReserve() *[3]DWORD { // 12
return (*[3]DWORD)(unsafe.Pointer(&this.storage[308]))
}
type IP_ADAPTER_ADDRESSES_LH struct {
union1 ULONGLONG
Next *IP_ADAPTER_ADDRESSES_LH
AdapterName PCHAR
FirstUnicastAddress PIP_ADAPTER_UNICAST_ADDRESS_LH
FirstAnycastAddress PIP_ADAPTER_ANYCAST_ADDRESS_XP
FirstMulticastAddress PIP_ADAPTER_MULTICAST_ADDRESS_XP
FirstDnsServerAddress PIP_ADAPTER_DNS_SERVER_ADDRESS_XP
DnsSuffix PWCHAR
Description PWCHAR
FriendlyName PWCHAR
PhysicalAddress [MAX_ADAPTER_ADDRESS_LENGTH]BYTE
PhysicalAddressLength ULONG
union2 ULONG
Mtu ULONG
IfType IFTYPE
OperStatus IF_OPER_STATUS
Ipv6IfIndex IF_INDEX
ZoneIndices [16]ULONG
FirstPrefix PIP_ADAPTER_PREFIX_XP
TransmitLinkSpeed ULONG64
ReceiveLinkSpeed ULONG64
FirstWinsServerAddress PIP_ADAPTER_WINS_SERVER_ADDRESS_LH
FirstGatewayAddress PIP_ADAPTER_GATEWAY_ADDRESS_LH
Ipv4Metric ULONG
Ipv6Metric ULONG
Luid IF_LUID
Dhcpv4Server SOCKET_ADDRESS
CompartmentId NET_IF_COMPARTMENT_ID
NetworkGuid NET_IF_NETWORK_GUID
ConnectionType NET_IF_CONNECTION_TYPE
TunnelType TUNNEL_TYPE
Dhcpv6Server SOCKET_ADDRESS
Dhcpv6ClientDuid [MAX_DHCPV6_DUID_LENGTH]BYTE
Dhcpv6ClientDuidLength ULONG
Dhcpv6Iaid ULONG
FirstDnsSuffix PIP_ADAPTER_DNS_SUFFIX
padding1 [4]byte
}
type IP_ADAPTER_ANYCAST_ADDRESS_XP struct {
union1 ULONGLONG
Next *IP_ADAPTER_ANYCAST_ADDRESS_XP
Address SOCKET_ADDRESS
padding1 [4]byte
}
type IP_ADAPTER_DNS_SERVER_ADDRESS_XP struct {
union1 ULONGLONG
Next *IP_ADAPTER_DNS_SERVER_ADDRESS_XP
Address SOCKET_ADDRESS
padding1 [4]byte
}
type IP_ADAPTER_GATEWAY_ADDRESS_LH struct {
union1 ULONGLONG
Next *IP_ADAPTER_GATEWAY_ADDRESS_LH
Address SOCKET_ADDRESS
padding1 [4]byte
}
type IP_ADAPTER_MULTICAST_ADDRESS_XP struct {
union1 ULONGLONG
Next *IP_ADAPTER_MULTICAST_ADDRESS_XP
Address SOCKET_ADDRESS
padding1 [4]byte
}
type IP_ADAPTER_WINS_SERVER_ADDRESS_LH struct {
union1 ULONGLONG
Next *IP_ADAPTER_WINS_SERVER_ADDRESS_LH
Address SOCKET_ADDRESS
padding1 [4]byte
}
type MIDIHDR struct {
storage [64]byte
}
func (this *MIDIHDR) LpData() *LPSTR { // 4
return (*LPSTR)(unsafe.Pointer(&this.storage[0]))
}
func (this *MIDIHDR) DwBufferLength() *DWORD { // 4
return (*DWORD)(unsafe.Pointer(&this.storage[4]))
}
func (this *MIDIHDR) DwBytesRecorded() *DWORD { // 4
return (*DWORD)(unsafe.Pointer(&this.storage[8]))
}
func (this *MIDIHDR) DwUser() *DWORD_PTR { // 4
return (*DWORD_PTR)(unsafe.Pointer(&this.storage[12]))
}
func (this *MIDIHDR) DwFlags() *DWORD { // 4
return (*DWORD)(unsafe.Pointer(&this.storage[16]))
}
func (this *MIDIHDR) LpNext() **MIDIHDR { // 4
return (**MIDIHDR)(unsafe.Pointer(&this.storage[20]))
}
func (this *MIDIHDR) Reserved() *DWORD_PTR { // 4
return (*DWORD_PTR)(unsafe.Pointer(&this.storage[24]))
}
func (this *MIDIHDR) DwOffset() *DWORD { // 4
return (*DWORD)(unsafe.Pointer(&this.storage[28]))
}
func (this *MIDIHDR) DwReserved() *[8]DWORD_PTR { // 32
return (*[8]DWORD_PTR)(unsafe.Pointer(&this.storage[32]))
}
type MIXERLINECONTROLS struct {
CbStruct DWORD
DwLineID DWORD
union1 DWORD
CControls DWORD
Cbmxctrl DWORD
storage1 [4]byte
}
type PRINTDLG struct {
storage [66]byte
}
func (this *PRINTDLG) LStructSize() *DWORD { // 4
return (*DWORD)(unsafe.Pointer(&this.storage[0]))
}
func (this *PRINTDLG) HwndOwner() *HWND { // 4
return (*HWND)(unsafe.Pointer(&this.storage[4]))
}
func (this *PRINTDLG) HDevMode() *HGLOBAL { // 4
return (*HGLOBAL)(unsafe.Pointer(&this.storage[8]))
}
func (this *PRINTDLG) HDevNames() *HGLOBAL { // 4
return (*HGLOBAL)(unsafe.Pointer(&this.storage[12]))
}
func (this *PRINTDLG) HDC() *HDC { // 4
return (*HDC)(unsafe.Pointer(&this.storage[16]))
}
func (this *PRINTDLG) Flags() *DWORD { // 4
return (*DWORD)(unsafe.Pointer(&this.storage[20]))
}
func (this *PRINTDLG) NFromPage() *WORD { // 2
return (*WORD)(unsafe.Pointer(&this.storage[24]))
}
func (this *PRINTDLG) NToPage() *WORD { // 2
return (*WORD)(unsafe.Pointer(&this.storage[26]))
}
func (this *PRINTDLG) NMinPage() *WORD { // 2
return (*WORD)(unsafe.Pointer(&this.storage[28]))
}
func (this *PRINTDLG) NMaxPage() *WORD { // 2
return (*WORD)(unsafe.Pointer(&this.storage[30]))
}
func (this *PRINTDLG) NCopies() *WORD { // 2
return (*WORD)(unsafe.Pointer(&this.storage[32]))
}
func (this *PRINTDLG) HInstance() *HINSTANCE { // 4
return (*HINSTANCE)(unsafe.Pointer(&this.storage[34]))
}
func (this *PRINTDLG) LCustData() *LPARAM { // 4
return (*LPARAM)(unsafe.Pointer(&this.storage[38]))
}
func (this *PRINTDLG) LpfnPrintHook() *uintptr { // 4
return (*uintptr)(unsafe.Pointer(&this.storage[42]))
}
func (this *PRINTDLG) LpfnSetupHook() *uintptr { // 4
return (*uintptr)(unsafe.Pointer(&this.storage[46]))
}
func (this *PRINTDLG) LpPrintTemplateName() *LPCWSTR { // 4
return (*LPCWSTR)(unsafe.Pointer(&this.storage[50]))
}
func (this *PRINTDLG) LpSetupTemplateName() *LPCWSTR { // 4
return (*LPCWSTR)(unsafe.Pointer(&this.storage[54]))
}
func (this *PRINTDLG) HPrintTemplate() *HGLOBAL { // 4
return (*HGLOBAL)(unsafe.Pointer(&this.storage[58]))
}
func (this *PRINTDLG) HSetupTemplate() *HGLOBAL { // 4
return (*HGLOBAL)(unsafe.Pointer(&this.storage[62]))
}
type SIZE_T uint32
type STRRET struct {
UType UINT
cStr [260]byte
}
type TASKDIALOGCONFIG struct {
storage [96]byte
}
func (this *TASKDIALOGCONFIG) CbSize() *UINT {
return (*UINT)(unsafe.Pointer(&this.storage[0]))
}
func (this *TASKDIALOGCONFIG) HwndParent() *HWND {
return (*HWND)(unsafe.Pointer(&this.storage[4]))
}
func (this *TASKDIALOGCONFIG) HInstance() *HINSTANCE {
return (*HINSTANCE)(unsafe.Pointer(&this.storage[8]))
}
func (this *TASKDIALOGCONFIG) DwFlags() *TASKDIALOG_FLAGS {
return (*TASKDIALOG_FLAGS)(unsafe.Pointer(&this.storage[12]))
}
func (this *TASKDIALOGCONFIG) DwCommonButtons() *TASKDIALOG_COMMON_BUTTON_FLAGS {
return (*TASKDIALOG_COMMON_BUTTON_FLAGS)(unsafe.Pointer(&this.storage[16]))
}
func (this *TASKDIALOGCONFIG) PszWindowTitle() *PCWSTR {
return (*PCWSTR)(unsafe.Pointer(&this.storage[20]))
}
func (this *TASKDIALOGCONFIG) HMainIcon() *HICON {
return (*HICON)(unsafe.Pointer(&this.storage[24]))
}
func (this *TASKDIALOGCONFIG) PszMainIcon() *PCWSTR {
return (*PCWSTR)(unsafe.Pointer(&this.storage[24]))
}
func (this *TASKDIALOGCONFIG) PszMainInstruction() *PCWSTR {
return (*PCWSTR)(unsafe.Pointer(&this.storage[28]))
}
func (this *TASKDIALOGCONFIG) PszContent() *PCWSTR {
return (*PCWSTR)(unsafe.Pointer(&this.storage[32]))
}
func (this *TASKDIALOGCONFIG) CButtons() *UINT {
return (*UINT)(unsafe.Pointer(&this.storage[36]))
}
func (this *TASKDIALOGCONFIG) PButtons() **TASKDIALOG_BUTTON {
return (**TASKDIALOG_BUTTON)(unsafe.Pointer(&this.storage[40]))
}
func (this *TASKDIALOGCONFIG) NDefaultButton() *int32 {
return (*int32)(unsafe.Pointer(&this.storage[44]))
}
func (this *TASKDIALOGCONFIG) CRadioButtons() *UINT {
return (*UINT)(unsafe.Pointer(&this.storage[48]))
}
func (this *TASKDIALOGCONFIG) PRadioButtons() **TASKDIALOG_BUTTON {
return (**TASKDIALOG_BUTTON)(unsafe.Pointer(&this.storage[52]))
}
func (this *TASKDIALOGCONFIG) NDefaultRadioButton() *int32 {
return (*int32)(unsafe.Pointer(&this.storage[56]))
}
func (this *TASKDIALOGCONFIG) PszVerificationText() *PCWSTR {
return (*PCWSTR)(unsafe.Pointer(&this.storage[60]))
}
func (this *TASKDIALOGCONFIG) PszExpandedInformation() *PCWSTR {
return (*PCWSTR)(unsafe.Pointer(&this.storage[64]))
}
func (this *TASKDIALOGCONFIG) PszExpandedControlText() *PCWSTR {
return (*PCWSTR)(unsafe.Pointer(&this.storage[68]))
}
func (this *TASKDIALOGCONFIG) PszCollapsedControlText() *PCWSTR {
return (*PCWSTR)(unsafe.Pointer(&this.storage[72]))
}
func (this *TASKDIALOGCONFIG) HFooterIcon() *HICON {
return (*HICON)(unsafe.Pointer(&this.storage[76]))
}
func (this *TASKDIALOGCONFIG) PszFooterIcon() *PCWSTR {
return (*PCWSTR)(unsafe.Pointer(&this.storage[76]))
}
func (this *TASKDIALOGCONFIG) PszFooter() *PCWSTR {
return (*PCWSTR)(unsafe.Pointer(&this.storage[80]))
}
func (this *TASKDIALOGCONFIG) PfCallback() *uintptr {
return (*uintptr)(unsafe.Pointer(&this.storage[84]))
}
func (this *TASKDIALOGCONFIG) LpCallbackData() *LONG_PTR {
return (*LONG_PTR)(unsafe.Pointer(&this.storage[88]))
}
func (this *TASKDIALOGCONFIG) CxWidth() *UINT {
return (*UINT)(unsafe.Pointer(&this.storage[92]))
}
type VARIANT struct {
union1 [16]byte
}
func (this *VARIANT) PRecInfo() *IRecordInfo {
return (*IRecordInfo)(unsafe.Pointer(&this.union1[12]))
}
type WSADATA struct {
WVersion uint16
WHighVersion uint16
SzDescription [WSADESCRIPTION_LEN + 1]byte
SzSystemStatus [WSASYS_STATUS_LEN + 1]byte
IMaxSockets uint16
IMaxUdpDg uint16
LpVendorInfo *byte
}

View File

@@ -1,337 +0,0 @@
// This file was automatically generated by https://github.com/kbinani/win/blob/generator/internal/cmd/gen/gen.go
package win
import (
"unsafe"
)
type INPUTCONTEXT struct {
storage [352]byte
}
func (this *INPUTCONTEXT) HWnd() *HWND { // 8
return (*HWND)(unsafe.Pointer(&this.storage[0]))
}
func (this *INPUTCONTEXT) FOpen() *BOOL { // 4
return (*BOOL)(unsafe.Pointer(&this.storage[8]))
}
func (this *INPUTCONTEXT) PtStatusWndPos() *POINT { // 8
return (*POINT)(unsafe.Pointer(&this.storage[12]))
}
func (this *INPUTCONTEXT) PtSoftKbdPos() *POINT { // 8
return (*POINT)(unsafe.Pointer(&this.storage[20]))
}
func (this *INPUTCONTEXT) FdwConversion() *DWORD { // 4
return (*DWORD)(unsafe.Pointer(&this.storage[28]))
}
func (this *INPUTCONTEXT) FdwSentence() *DWORD { // 4
return (*DWORD)(unsafe.Pointer(&this.storage[32]))
}
func (this *INPUTCONTEXT) LfFont() *LOGFONT { // 92
return (*LOGFONT)(unsafe.Pointer(&this.storage[36]))
}
func (this *INPUTCONTEXT) CfCompForm() *COMPOSITIONFORM { // 28
return (*COMPOSITIONFORM)(unsafe.Pointer(&this.storage[128]))
}
func (this *INPUTCONTEXT) CfCandForm() *[4]CANDIDATEFORM { // 128
return (*[4]CANDIDATEFORM)(unsafe.Pointer(&this.storage[156]))
}
func (this *INPUTCONTEXT) HCompStr() *HIMCC { // 8
return (*HIMCC)(unsafe.Pointer(&this.storage[288]))
}
func (this *INPUTCONTEXT) HCandInfo() *HIMCC { // 8
return (*HIMCC)(unsafe.Pointer(&this.storage[296]))
}
func (this *INPUTCONTEXT) HGuideLine() *HIMCC { // 8
return (*HIMCC)(unsafe.Pointer(&this.storage[304]))
}
func (this *INPUTCONTEXT) HPrivate() *HIMCC { // 8
return (*HIMCC)(unsafe.Pointer(&this.storage[312]))
}
func (this *INPUTCONTEXT) DwNumMsgBuf() *DWORD { // 4
return (*DWORD)(unsafe.Pointer(&this.storage[320]))
}
func (this *INPUTCONTEXT) HMsgBuf() *HIMCC { // 8
return (*HIMCC)(unsafe.Pointer(&this.storage[328]))
}
func (this *INPUTCONTEXT) FdwInit() *DWORD { // 4
return (*DWORD)(unsafe.Pointer(&this.storage[336]))
}
func (this *INPUTCONTEXT) DwReserve() *[3]DWORD { // 12
return (*[3]DWORD)(unsafe.Pointer(&this.storage[340]))
}
type IP_ADAPTER_ADDRESSES_LH struct {
union1 ULONGLONG
Next *IP_ADAPTER_ADDRESSES_LH
AdapterName PCHAR
FirstUnicastAddress PIP_ADAPTER_UNICAST_ADDRESS_LH
FirstAnycastAddress PIP_ADAPTER_ANYCAST_ADDRESS_XP
FirstMulticastAddress PIP_ADAPTER_MULTICAST_ADDRESS_XP
FirstDnsServerAddress PIP_ADAPTER_DNS_SERVER_ADDRESS_XP
DnsSuffix PWCHAR
Description PWCHAR
FriendlyName PWCHAR
PhysicalAddress [MAX_ADAPTER_ADDRESS_LENGTH]BYTE
PhysicalAddressLength ULONG
union2 ULONG
Mtu ULONG
IfType IFTYPE
OperStatus IF_OPER_STATUS
Ipv6IfIndex IF_INDEX
ZoneIndices [16]ULONG
FirstPrefix PIP_ADAPTER_PREFIX_XP
TransmitLinkSpeed ULONG64
ReceiveLinkSpeed ULONG64
FirstWinsServerAddress PIP_ADAPTER_WINS_SERVER_ADDRESS_LH
FirstGatewayAddress PIP_ADAPTER_GATEWAY_ADDRESS_LH
Ipv4Metric ULONG
Ipv6Metric ULONG
Luid IF_LUID
Dhcpv4Server SOCKET_ADDRESS
CompartmentId NET_IF_COMPARTMENT_ID
NetworkGuid NET_IF_NETWORK_GUID
ConnectionType NET_IF_CONNECTION_TYPE
TunnelType TUNNEL_TYPE
Dhcpv6Server SOCKET_ADDRESS
Dhcpv6ClientDuid [MAX_DHCPV6_DUID_LENGTH]BYTE
Dhcpv6ClientDuidLength ULONG
Dhcpv6Iaid ULONG
FirstDnsSuffix PIP_ADAPTER_DNS_SUFFIX
}
type IP_ADAPTER_ANYCAST_ADDRESS_XP struct {
union1 ULONGLONG
Next *IP_ADAPTER_ANYCAST_ADDRESS_XP
Address SOCKET_ADDRESS
}
type IP_ADAPTER_DNS_SERVER_ADDRESS_XP struct {
union1 ULONGLONG
Next *IP_ADAPTER_DNS_SERVER_ADDRESS_XP
Address SOCKET_ADDRESS
}
type IP_ADAPTER_GATEWAY_ADDRESS_LH struct {
union1 ULONGLONG
Next *IP_ADAPTER_GATEWAY_ADDRESS_LH
Address SOCKET_ADDRESS
}
type IP_ADAPTER_MULTICAST_ADDRESS_XP struct {
union1 ULONGLONG
Next *IP_ADAPTER_MULTICAST_ADDRESS_XP
Address SOCKET_ADDRESS
}
type IP_ADAPTER_WINS_SERVER_ADDRESS_LH struct {
union1 ULONGLONG
Next *IP_ADAPTER_WINS_SERVER_ADDRESS_LH
Address SOCKET_ADDRESS
}
type MIDIHDR struct {
storage [112]byte
}
func (this *MIDIHDR) LpData() *LPSTR {
return (*LPSTR)(unsafe.Pointer(&this.storage[0]))
}
func (this *MIDIHDR) DwBufferLength() *DWORD {
return (*DWORD)(unsafe.Pointer(&this.storage[8]))
}
func (this *MIDIHDR) DwBytesRecorded() *DWORD {
return (*DWORD)(unsafe.Pointer(&this.storage[12]))
}
func (this *MIDIHDR) DwUser() *DWORD_PTR {
return (*DWORD_PTR)(unsafe.Pointer(&this.storage[16]))
}
func (this *MIDIHDR) DwFlags() *DWORD {
return (*DWORD)(unsafe.Pointer(&this.storage[24]))
}
func (this *MIDIHDR) LpNext() **MIDIHDR {
return (**MIDIHDR)(unsafe.Pointer(&this.storage[28]))
}
func (this *MIDIHDR) Reserved() *DWORD_PTR {
return (*DWORD_PTR)(unsafe.Pointer(&this.storage[36]))
}
func (this *MIDIHDR) DwOffset() *DWORD {
return (*DWORD)(unsafe.Pointer(&this.storage[44]))
}
func (this *MIDIHDR) DwReserved() *[8]DWORD_PTR {
return (*[8]DWORD_PTR)(unsafe.Pointer(&this.storage[48]))
}
type MIXERLINECONTROLS struct {
CbStruct DWORD
DwLineID DWORD
union1 DWORD
CControls DWORD
Cbmxctrl DWORD
storage1 [4]byte
storage2 [4]byte
}
type PRINTDLG struct {
storage [120]byte
}
func (this *PRINTDLG) LStructSize() *DWORD { // 4
return (*DWORD)(unsafe.Pointer(&this.storage[0]))
}
func (this *PRINTDLG) HwndOwner() *HWND { // 8
return (*HWND)(unsafe.Pointer(&this.storage[8]))
}
func (this *PRINTDLG) HDevMode() *HGLOBAL { // 8
return (*HGLOBAL)(unsafe.Pointer(&this.storage[16]))
}
func (this *PRINTDLG) HDevNames() *HGLOBAL { // 8
return (*HGLOBAL)(unsafe.Pointer(&this.storage[24]))
}
func (this *PRINTDLG) HDC() *HDC { // 8
return (*HDC)(unsafe.Pointer(&this.storage[32]))
}
func (this *PRINTDLG) Flags() *DWORD { // 4
return (*DWORD)(unsafe.Pointer(&this.storage[40]))
}
func (this *PRINTDLG) NFromPage() *WORD { // 2
return (*WORD)(unsafe.Pointer(&this.storage[44]))
}
func (this *PRINTDLG) NToPage() *WORD { // 2
return (*WORD)(unsafe.Pointer(&this.storage[46]))
}
func (this *PRINTDLG) NMinPage() *WORD { // 2
return (*WORD)(unsafe.Pointer(&this.storage[48]))
}
func (this *PRINTDLG) NMaxPage() *WORD { // 2
return (*WORD)(unsafe.Pointer(&this.storage[50]))
}
func (this *PRINTDLG) NCopies() *WORD { // 2
return (*WORD)(unsafe.Pointer(&this.storage[52]))
}
func (this *PRINTDLG) HInstance() *HINSTANCE { // 8
return (*HINSTANCE)(unsafe.Pointer(&this.storage[56]))
}
func (this *PRINTDLG) LCustData() *LPARAM { // 8
return (*LPARAM)(unsafe.Pointer(&this.storage[64]))
}
func (this *PRINTDLG) LpfnPrintHook() *uintptr { // 8
return (*uintptr)(unsafe.Pointer(&this.storage[72]))
}
func (this *PRINTDLG) LpfnSetupHook() *uintptr { // 8
return (*uintptr)(unsafe.Pointer(&this.storage[80]))
}
func (this *PRINTDLG) LpPrintTemplateName() *LPCWSTR { // 8
return (*LPCWSTR)(unsafe.Pointer(&this.storage[88]))
}
func (this *PRINTDLG) LpSetupTemplateName() *LPCWSTR { // 8
return (*LPCWSTR)(unsafe.Pointer(&this.storage[96]))
}
func (this *PRINTDLG) HPrintTemplate() *HGLOBAL { // 8
return (*HGLOBAL)(unsafe.Pointer(&this.storage[104]))
}
func (this *PRINTDLG) HSetupTemplate() *HGLOBAL { // 8
return (*HGLOBAL)(unsafe.Pointer(&this.storage[112]))
}
type SIZE_T uint64
type STRRET struct {
UType UINT
padding1 [4]byte
cStr [260]byte
padding2 [4]byte
}
type TASKDIALOGCONFIG struct {
storage [160]byte
}
func (this *TASKDIALOGCONFIG) CbSize() *UINT {
return (*UINT)(unsafe.Pointer(&this.storage[0]))
}
func (this *TASKDIALOGCONFIG) HwndParent() *HWND {
return (*HWND)(unsafe.Pointer(&this.storage[4]))
}
func (this *TASKDIALOGCONFIG) HInstance() *HINSTANCE {
return (*HINSTANCE)(unsafe.Pointer(&this.storage[12]))
}
func (this *TASKDIALOGCONFIG) DwFlags() *TASKDIALOG_FLAGS {
return (*TASKDIALOG_FLAGS)(unsafe.Pointer(&this.storage[20]))
}
func (this *TASKDIALOGCONFIG) DwCommonButtons() *TASKDIALOG_COMMON_BUTTON_FLAGS {
return (*TASKDIALOG_COMMON_BUTTON_FLAGS)(unsafe.Pointer(&this.storage[24]))
}
func (this *TASKDIALOGCONFIG) PszWindowTitle() *PCWSTR {
return (*PCWSTR)(unsafe.Pointer(&this.storage[28]))
}
func (this *TASKDIALOGCONFIG) HMainIcon() *HICON {
return (*HICON)(unsafe.Pointer(&this.storage[36]))
}
func (this *TASKDIALOGCONFIG) PszMainIcon() *PCWSTR {
return (*PCWSTR)(unsafe.Pointer(&this.storage[36]))
}
func (this *TASKDIALOGCONFIG) PszMainInstruction() *PCWSTR {
return (*PCWSTR)(unsafe.Pointer(&this.storage[44]))
}
func (this *TASKDIALOGCONFIG) PszContent() *PCWSTR {
return (*PCWSTR)(unsafe.Pointer(&this.storage[52]))
}
func (this *TASKDIALOGCONFIG) CButtons() *UINT {
return (*UINT)(unsafe.Pointer(&this.storage[60]))
}
func (this *TASKDIALOGCONFIG) PButtons() **TASKDIALOG_BUTTON {
return (**TASKDIALOG_BUTTON)(unsafe.Pointer(&this.storage[64]))
}
func (this *TASKDIALOGCONFIG) NDefaultButton() *int32 {
return (*int32)(unsafe.Pointer(&this.storage[72]))
}
func (this *TASKDIALOGCONFIG) CRadioButtons() *UINT {
return (*UINT)(unsafe.Pointer(&this.storage[76]))
}
func (this *TASKDIALOGCONFIG) PRadioButtons() **TASKDIALOG_BUTTON {
return (**TASKDIALOG_BUTTON)(unsafe.Pointer(&this.storage[80]))
}
func (this *TASKDIALOGCONFIG) NDefaultRadioButton() *int32 {
return (*int32)(unsafe.Pointer(&this.storage[88]))
}
func (this *TASKDIALOGCONFIG) PszVerificationText() *PCWSTR {
return (*PCWSTR)(unsafe.Pointer(&this.storage[92]))
}
func (this *TASKDIALOGCONFIG) PszExpandedInformation() *PCWSTR {
return (*PCWSTR)(unsafe.Pointer(&this.storage[100]))
}
func (this *TASKDIALOGCONFIG) PszExpandedControlText() *PCWSTR {
return (*PCWSTR)(unsafe.Pointer(&this.storage[108]))
}
func (this *TASKDIALOGCONFIG) PszCollapsedControlText() *PCWSTR {
return (*PCWSTR)(unsafe.Pointer(&this.storage[116]))
}
func (this *TASKDIALOGCONFIG) HFooterIcon() *HICON {
return (*HICON)(unsafe.Pointer(&this.storage[124]))
}
func (this *TASKDIALOGCONFIG) PszFooterIcon() *PCWSTR {
return (*PCWSTR)(unsafe.Pointer(&this.storage[124]))
}
func (this *TASKDIALOGCONFIG) PszFooter() *PCWSTR {
return (*PCWSTR)(unsafe.Pointer(&this.storage[132]))
}
func (this *TASKDIALOGCONFIG) PfCallback() *uintptr {
return (*uintptr)(unsafe.Pointer(&this.storage[140]))
}
func (this *TASKDIALOGCONFIG) LpCallbackData() *LONG_PTR {
return (*LONG_PTR)(unsafe.Pointer(&this.storage[148]))
}
func (this *TASKDIALOGCONFIG) CxWidth() *UINT {
return (*UINT)(unsafe.Pointer(&this.storage[156]))
}
type VARIANT struct {
union1 [24]byte
}
func (this *VARIANT) PRecInfo() *IRecordInfo {
return (*IRecordInfo)(unsafe.Pointer(&this.union1[16]))
}
type WSADATA struct {
WVersion uint16
WHighVersion uint16
IMaxSockets uint16
IMaxUdpDg uint16
LpVendorInfo *byte
SzDescription [WSADESCRIPTION_LEN + 1]byte
SzSystemStatus [WSASYS_STATUS_LEN + 1]byte
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,841 +0,0 @@
// This file was automatically generated by https://github.com/kbinani/win/blob/generator/internal/cmd/gen/gen.go
// go run internal/cmd/gen/gen.go
// +build windows
package win
import (
"unsafe"
)
var (
// Library
libuxtheme uintptr
// Functions
beginPanningFeedback uintptr
endPanningFeedback uintptr
updatePanningFeedback uintptr
beginBufferedAnimation uintptr
beginBufferedPaint uintptr
bufferedPaintClear uintptr
bufferedPaintInit uintptr
bufferedPaintRenderAnimation uintptr
bufferedPaintSetAlpha uintptr
bufferedPaintStopAllAnimations uintptr
bufferedPaintUnInit uintptr
closeThemeData uintptr
drawThemeBackground uintptr
drawThemeBackgroundEx uintptr
drawThemeEdge uintptr
drawThemeIcon uintptr
drawThemeParentBackground uintptr
drawThemeText uintptr
drawThemeTextEx uintptr
enableThemeDialogTexture uintptr
enableTheming uintptr
endBufferedAnimation uintptr
endBufferedPaint uintptr
getBufferedPaintBits uintptr
getBufferedPaintDC uintptr
getBufferedPaintTargetDC uintptr
getBufferedPaintTargetRect uintptr
getCurrentThemeName uintptr
getThemeAppProperties uintptr
getThemeBackgroundContentRect uintptr
getThemeBackgroundExtent uintptr
getThemeBackgroundRegion uintptr
getThemeBool uintptr
getThemeColor uintptr
getThemeDocumentationProperty uintptr
getThemeEnumValue uintptr
getThemeFilename uintptr
getThemeFont uintptr
getThemeInt uintptr
getThemeIntList uintptr
getThemeMargins uintptr
getThemeMetric uintptr
getThemePartSize uintptr
getThemePosition uintptr
getThemePropertyOrigin uintptr
getThemeRect uintptr
getThemeString uintptr
getThemeSysBool uintptr
getThemeSysColor uintptr
getThemeSysColorBrush uintptr
getThemeSysFont uintptr
getThemeSysInt uintptr
getThemeSysSize uintptr
getThemeSysString uintptr
getThemeTextExtent uintptr
getThemeTextMetrics uintptr
getThemeTransitionDuration uintptr
getWindowTheme uintptr
hitTestThemeBackground uintptr
isAppThemed uintptr
isThemeActive uintptr
isThemeBackgroundPartiallyTransparent uintptr
isThemeDialogTextureEnabled uintptr
isThemePartDefined uintptr
openThemeData uintptr
openThemeDataEx uintptr
setThemeAppProperties uintptr
setWindowTheme uintptr
)
func init() {
// Library
libuxtheme = doLoadLibrary("uxtheme.dll")
// Functions
beginPanningFeedback = doGetProcAddress(libuxtheme, "BeginPanningFeedback")
endPanningFeedback = doGetProcAddress(libuxtheme, "EndPanningFeedback")
updatePanningFeedback = doGetProcAddress(libuxtheme, "UpdatePanningFeedback")
beginBufferedAnimation = doGetProcAddress(libuxtheme, "BeginBufferedAnimation")
beginBufferedPaint = doGetProcAddress(libuxtheme, "BeginBufferedPaint")
bufferedPaintClear = doGetProcAddress(libuxtheme, "BufferedPaintClear")
bufferedPaintInit = doGetProcAddress(libuxtheme, "BufferedPaintInit")
bufferedPaintRenderAnimation = doGetProcAddress(libuxtheme, "BufferedPaintRenderAnimation")
bufferedPaintSetAlpha = doGetProcAddress(libuxtheme, "BufferedPaintSetAlpha")
bufferedPaintStopAllAnimations = doGetProcAddress(libuxtheme, "BufferedPaintStopAllAnimations")
bufferedPaintUnInit = doGetProcAddress(libuxtheme, "BufferedPaintUnInit")
closeThemeData = doGetProcAddress(libuxtheme, "CloseThemeData")
drawThemeBackground = doGetProcAddress(libuxtheme, "DrawThemeBackground")
drawThemeBackgroundEx = doGetProcAddress(libuxtheme, "DrawThemeBackgroundEx")
drawThemeEdge = doGetProcAddress(libuxtheme, "DrawThemeEdge")
drawThemeIcon = doGetProcAddress(libuxtheme, "DrawThemeIcon")
drawThemeParentBackground = doGetProcAddress(libuxtheme, "DrawThemeParentBackground")
drawThemeText = doGetProcAddress(libuxtheme, "DrawThemeText")
drawThemeTextEx = doGetProcAddress(libuxtheme, "DrawThemeTextEx")
enableThemeDialogTexture = doGetProcAddress(libuxtheme, "EnableThemeDialogTexture")
enableTheming = doGetProcAddress(libuxtheme, "EnableTheming")
endBufferedAnimation = doGetProcAddress(libuxtheme, "EndBufferedAnimation")
endBufferedPaint = doGetProcAddress(libuxtheme, "EndBufferedPaint")
getBufferedPaintBits = doGetProcAddress(libuxtheme, "GetBufferedPaintBits")
getBufferedPaintDC = doGetProcAddress(libuxtheme, "GetBufferedPaintDC")
getBufferedPaintTargetDC = doGetProcAddress(libuxtheme, "GetBufferedPaintTargetDC")
getBufferedPaintTargetRect = doGetProcAddress(libuxtheme, "GetBufferedPaintTargetRect")
getCurrentThemeName = doGetProcAddress(libuxtheme, "GetCurrentThemeName")
getThemeAppProperties = doGetProcAddress(libuxtheme, "GetThemeAppProperties")
getThemeBackgroundContentRect = doGetProcAddress(libuxtheme, "GetThemeBackgroundContentRect")
getThemeBackgroundExtent = doGetProcAddress(libuxtheme, "GetThemeBackgroundExtent")
getThemeBackgroundRegion = doGetProcAddress(libuxtheme, "GetThemeBackgroundRegion")
getThemeBool = doGetProcAddress(libuxtheme, "GetThemeBool")
getThemeColor = doGetProcAddress(libuxtheme, "GetThemeColor")
getThemeDocumentationProperty = doGetProcAddress(libuxtheme, "GetThemeDocumentationProperty")
getThemeEnumValue = doGetProcAddress(libuxtheme, "GetThemeEnumValue")
getThemeFilename = doGetProcAddress(libuxtheme, "GetThemeFilename")
getThemeFont = doGetProcAddress(libuxtheme, "GetThemeFont")
getThemeInt = doGetProcAddress(libuxtheme, "GetThemeInt")
getThemeIntList = doGetProcAddress(libuxtheme, "GetThemeIntList")
getThemeMargins = doGetProcAddress(libuxtheme, "GetThemeMargins")
getThemeMetric = doGetProcAddress(libuxtheme, "GetThemeMetric")
getThemePartSize = doGetProcAddress(libuxtheme, "GetThemePartSize")
getThemePosition = doGetProcAddress(libuxtheme, "GetThemePosition")
getThemePropertyOrigin = doGetProcAddress(libuxtheme, "GetThemePropertyOrigin")
getThemeRect = doGetProcAddress(libuxtheme, "GetThemeRect")
getThemeString = doGetProcAddress(libuxtheme, "GetThemeString")
getThemeSysBool = doGetProcAddress(libuxtheme, "GetThemeSysBool")
getThemeSysColor = doGetProcAddress(libuxtheme, "GetThemeSysColor")
getThemeSysColorBrush = doGetProcAddress(libuxtheme, "GetThemeSysColorBrush")
getThemeSysFont = doGetProcAddress(libuxtheme, "GetThemeSysFont")
getThemeSysInt = doGetProcAddress(libuxtheme, "GetThemeSysInt")
getThemeSysSize = doGetProcAddress(libuxtheme, "GetThemeSysSize")
getThemeSysString = doGetProcAddress(libuxtheme, "GetThemeSysString")
getThemeTextExtent = doGetProcAddress(libuxtheme, "GetThemeTextExtent")
getThemeTextMetrics = doGetProcAddress(libuxtheme, "GetThemeTextMetrics")
getThemeTransitionDuration = doGetProcAddress(libuxtheme, "GetThemeTransitionDuration")
getWindowTheme = doGetProcAddress(libuxtheme, "GetWindowTheme")
hitTestThemeBackground = doGetProcAddress(libuxtheme, "HitTestThemeBackground")
isAppThemed = doGetProcAddress(libuxtheme, "IsAppThemed")
isThemeActive = doGetProcAddress(libuxtheme, "IsThemeActive")
isThemeBackgroundPartiallyTransparent = doGetProcAddress(libuxtheme, "IsThemeBackgroundPartiallyTransparent")
isThemeDialogTextureEnabled = doGetProcAddress(libuxtheme, "IsThemeDialogTextureEnabled")
isThemePartDefined = doGetProcAddress(libuxtheme, "IsThemePartDefined")
openThemeData = doGetProcAddress(libuxtheme, "OpenThemeData")
openThemeDataEx = doGetProcAddress(libuxtheme, "OpenThemeDataEx")
setThemeAppProperties = doGetProcAddress(libuxtheme, "SetThemeAppProperties")
setWindowTheme = doGetProcAddress(libuxtheme, "SetWindowTheme")
}
func BeginPanningFeedback(hwnd HWND) bool {
ret1 := syscall3(beginPanningFeedback, 1,
uintptr(hwnd),
0,
0)
return ret1 != 0
}
func EndPanningFeedback(hwnd HWND, fAnimateBack bool) bool {
ret1 := syscall3(endPanningFeedback, 2,
uintptr(hwnd),
getUintptrFromBool(fAnimateBack),
0)
return ret1 != 0
}
func UpdatePanningFeedback(hwnd HWND, lTotalOverpanOffsetX LONG, lTotalOverpanOffsetY LONG, fInInertia bool) bool {
ret1 := syscall6(updatePanningFeedback, 4,
uintptr(hwnd),
uintptr(lTotalOverpanOffsetX),
uintptr(lTotalOverpanOffsetY),
getUintptrFromBool(fInInertia),
0,
0)
return ret1 != 0
}
func BeginBufferedAnimation(hwnd HWND, hdcTarget HDC, rcTarget /*const*/ *RECT, dwFormat BP_BUFFERFORMAT, pPaintParams *BP_PAINTPARAMS, pAnimationParams *BP_ANIMATIONPARAMS, phdcFrom *HDC, phdcTo *HDC) HANIMATIONBUFFER {
ret1 := syscall9(beginBufferedAnimation, 8,
uintptr(hwnd),
uintptr(hdcTarget),
uintptr(unsafe.Pointer(rcTarget)),
uintptr(dwFormat),
uintptr(unsafe.Pointer(pPaintParams)),
uintptr(unsafe.Pointer(pAnimationParams)),
uintptr(unsafe.Pointer(phdcFrom)),
uintptr(unsafe.Pointer(phdcTo)),
0)
return HANIMATIONBUFFER(ret1)
}
func BeginBufferedPaint(hdcTarget HDC, prcTarget /*const*/ *RECT, dwFormat BP_BUFFERFORMAT, pPaintParams *BP_PAINTPARAMS, phdc *HDC) HPAINTBUFFER {
ret1 := syscall6(beginBufferedPaint, 5,
uintptr(hdcTarget),
uintptr(unsafe.Pointer(prcTarget)),
uintptr(dwFormat),
uintptr(unsafe.Pointer(pPaintParams)),
uintptr(unsafe.Pointer(phdc)),
0)
return HPAINTBUFFER(ret1)
}
func BufferedPaintClear(hBufferedPaint HPAINTBUFFER, prc /*const*/ *RECT) HRESULT {
ret1 := syscall3(bufferedPaintClear, 2,
uintptr(hBufferedPaint),
uintptr(unsafe.Pointer(prc)),
0)
return HRESULT(ret1)
}
func BufferedPaintInit() HRESULT {
ret1 := syscall3(bufferedPaintInit, 0,
0,
0,
0)
return HRESULT(ret1)
}
func BufferedPaintRenderAnimation(hwnd HWND, hdcTarget HDC) bool {
ret1 := syscall3(bufferedPaintRenderAnimation, 2,
uintptr(hwnd),
uintptr(hdcTarget),
0)
return ret1 != 0
}
func BufferedPaintSetAlpha(hBufferedPaint HPAINTBUFFER, prc /*const*/ *RECT, alpha BYTE) HRESULT {
ret1 := syscall3(bufferedPaintSetAlpha, 3,
uintptr(hBufferedPaint),
uintptr(unsafe.Pointer(prc)),
uintptr(alpha))
return HRESULT(ret1)
}
func BufferedPaintStopAllAnimations(hwnd HWND) HRESULT {
ret1 := syscall3(bufferedPaintStopAllAnimations, 1,
uintptr(hwnd),
0,
0)
return HRESULT(ret1)
}
func BufferedPaintUnInit() HRESULT {
ret1 := syscall3(bufferedPaintUnInit, 0,
0,
0,
0)
return HRESULT(ret1)
}
func CloseThemeData(hTheme HTHEME) HRESULT {
ret1 := syscall3(closeThemeData, 1,
uintptr(hTheme),
0,
0)
return HRESULT(ret1)
}
func DrawThemeBackground(hTheme HTHEME, hdc HDC, iPartId int32, iStateId int32, pRect /*const*/ *RECT, pClipRect /*const*/ *RECT) HRESULT {
ret1 := syscall6(drawThemeBackground, 6,
uintptr(hTheme),
uintptr(hdc),
uintptr(iPartId),
uintptr(iStateId),
uintptr(unsafe.Pointer(pRect)),
uintptr(unsafe.Pointer(pClipRect)))
return HRESULT(ret1)
}
func DrawThemeBackgroundEx(hTheme HTHEME, hdc HDC, iPartId int32, iStateId int32, pRect /*const*/ *RECT, pOptions /*const*/ *DTBGOPTS) HRESULT {
ret1 := syscall6(drawThemeBackgroundEx, 6,
uintptr(hTheme),
uintptr(hdc),
uintptr(iPartId),
uintptr(iStateId),
uintptr(unsafe.Pointer(pRect)),
uintptr(unsafe.Pointer(pOptions)))
return HRESULT(ret1)
}
func DrawThemeEdge(hTheme HTHEME, hdc HDC, iPartId int32, iStateId int32, pDestRect /*const*/ *RECT, uEdge UINT, uFlags UINT, pContentRect *RECT) HRESULT {
ret1 := syscall9(drawThemeEdge, 8,
uintptr(hTheme),
uintptr(hdc),
uintptr(iPartId),
uintptr(iStateId),
uintptr(unsafe.Pointer(pDestRect)),
uintptr(uEdge),
uintptr(uFlags),
uintptr(unsafe.Pointer(pContentRect)),
0)
return HRESULT(ret1)
}
func DrawThemeIcon(hTheme HTHEME, hdc HDC, iPartId int32, iStateId int32, pRect /*const*/ *RECT, himl HIMAGELIST, iImageIndex int32) HRESULT {
ret1 := syscall9(drawThemeIcon, 7,
uintptr(hTheme),
uintptr(hdc),
uintptr(iPartId),
uintptr(iStateId),
uintptr(unsafe.Pointer(pRect)),
uintptr(himl),
uintptr(iImageIndex),
0,
0)
return HRESULT(ret1)
}
func DrawThemeParentBackground(hwnd HWND, hdc HDC, prc *RECT) HRESULT {
ret1 := syscall3(drawThemeParentBackground, 3,
uintptr(hwnd),
uintptr(hdc),
uintptr(unsafe.Pointer(prc)))
return HRESULT(ret1)
}
func DrawThemeText(hTheme HTHEME, hdc HDC, iPartId int32, iStateId int32, pszText string, iCharCount int32, flags DWORD, flags2 DWORD, pRect /*const*/ *RECT) HRESULT {
pszTextStr := unicode16FromString(pszText)
ret1 := syscall9(drawThemeText, 9,
uintptr(hTheme),
uintptr(hdc),
uintptr(iPartId),
uintptr(iStateId),
uintptr(unsafe.Pointer(&pszTextStr[0])),
uintptr(iCharCount),
uintptr(flags),
uintptr(flags2),
uintptr(unsafe.Pointer(pRect)))
return HRESULT(ret1)
}
func DrawThemeTextEx(hTheme HTHEME, hdc HDC, iPartId int32, iStateId int32, pszText string, iCharCount int32, flags DWORD, rect *RECT, options /*const*/ *DTTOPTS) HRESULT {
pszTextStr := unicode16FromString(pszText)
ret1 := syscall9(drawThemeTextEx, 9,
uintptr(hTheme),
uintptr(hdc),
uintptr(iPartId),
uintptr(iStateId),
uintptr(unsafe.Pointer(&pszTextStr[0])),
uintptr(iCharCount),
uintptr(flags),
uintptr(unsafe.Pointer(rect)),
uintptr(unsafe.Pointer(options)))
return HRESULT(ret1)
}
func EnableThemeDialogTexture(hwnd HWND, dwFlags DWORD) HRESULT {
ret1 := syscall3(enableThemeDialogTexture, 2,
uintptr(hwnd),
uintptr(dwFlags),
0)
return HRESULT(ret1)
}
func EnableTheming(fEnable bool) HRESULT {
ret1 := syscall3(enableTheming, 1,
getUintptrFromBool(fEnable),
0,
0)
return HRESULT(ret1)
}
func EndBufferedAnimation(hbpAnimation HANIMATIONBUFFER, fUpdateTarget bool) HRESULT {
ret1 := syscall3(endBufferedAnimation, 2,
uintptr(hbpAnimation),
getUintptrFromBool(fUpdateTarget),
0)
return HRESULT(ret1)
}
func EndBufferedPaint(hPaintBuffer HPAINTBUFFER, fUpdateTarget bool) HRESULT {
ret1 := syscall3(endBufferedPaint, 2,
uintptr(hPaintBuffer),
getUintptrFromBool(fUpdateTarget),
0)
return HRESULT(ret1)
}
func GetBufferedPaintBits(hBufferedPaint HPAINTBUFFER, ppbBuffer **RGBQUAD, pcxRow *int) HRESULT {
ret1 := syscall3(getBufferedPaintBits, 3,
uintptr(hBufferedPaint),
uintptr(unsafe.Pointer(ppbBuffer)),
uintptr(unsafe.Pointer(pcxRow)))
return HRESULT(ret1)
}
func GetBufferedPaintDC(hBufferedPaint HPAINTBUFFER) HDC {
ret1 := syscall3(getBufferedPaintDC, 1,
uintptr(hBufferedPaint),
0,
0)
return HDC(ret1)
}
func GetBufferedPaintTargetDC(hBufferedPaint HPAINTBUFFER) HDC {
ret1 := syscall3(getBufferedPaintTargetDC, 1,
uintptr(hBufferedPaint),
0,
0)
return HDC(ret1)
}
func GetBufferedPaintTargetRect(hBufferedPaint HPAINTBUFFER, prc *RECT) HRESULT {
ret1 := syscall3(getBufferedPaintTargetRect, 2,
uintptr(hBufferedPaint),
uintptr(unsafe.Pointer(prc)),
0)
return HRESULT(ret1)
}
func GetCurrentThemeName(pszThemeFileName LPWSTR, dwMaxNameChars int32, pszColorBuff LPWSTR, cchMaxColorChars int32, pszSizeBuff LPWSTR, cchMaxSizeChars int32) HRESULT {
ret1 := syscall6(getCurrentThemeName, 6,
uintptr(unsafe.Pointer(pszThemeFileName)),
uintptr(dwMaxNameChars),
uintptr(unsafe.Pointer(pszColorBuff)),
uintptr(cchMaxColorChars),
uintptr(unsafe.Pointer(pszSizeBuff)),
uintptr(cchMaxSizeChars))
return HRESULT(ret1)
}
func GetThemeAppProperties() DWORD {
ret1 := syscall3(getThemeAppProperties, 0,
0,
0,
0)
return DWORD(ret1)
}
func GetThemeBackgroundContentRect(hTheme HTHEME, hdc HDC, iPartId int32, iStateId int32, pBoundingRect /*const*/ *RECT, pContentRect *RECT) HRESULT {
ret1 := syscall6(getThemeBackgroundContentRect, 6,
uintptr(hTheme),
uintptr(hdc),
uintptr(iPartId),
uintptr(iStateId),
uintptr(unsafe.Pointer(pBoundingRect)),
uintptr(unsafe.Pointer(pContentRect)))
return HRESULT(ret1)
}
func GetThemeBackgroundExtent(hTheme HTHEME, hdc HDC, iPartId int32, iStateId int32, pContentRect /*const*/ *RECT, pExtentRect *RECT) HRESULT {
ret1 := syscall6(getThemeBackgroundExtent, 6,
uintptr(hTheme),
uintptr(hdc),
uintptr(iPartId),
uintptr(iStateId),
uintptr(unsafe.Pointer(pContentRect)),
uintptr(unsafe.Pointer(pExtentRect)))
return HRESULT(ret1)
}
func GetThemeBackgroundRegion(hTheme HTHEME, hdc HDC, iPartId int32, iStateId int32, pRect /*const*/ *RECT, pRegion *HRGN) HRESULT {
ret1 := syscall6(getThemeBackgroundRegion, 6,
uintptr(hTheme),
uintptr(hdc),
uintptr(iPartId),
uintptr(iStateId),
uintptr(unsafe.Pointer(pRect)),
uintptr(unsafe.Pointer(pRegion)))
return HRESULT(ret1)
}
func GetThemeBool(hTheme HTHEME, iPartId int32, iStateId int32, iPropId int32, pfVal *BOOL) HRESULT {
ret1 := syscall6(getThemeBool, 5,
uintptr(hTheme),
uintptr(iPartId),
uintptr(iStateId),
uintptr(iPropId),
uintptr(unsafe.Pointer(pfVal)),
0)
return HRESULT(ret1)
}
func GetThemeColor(hTheme HTHEME, iPartId int32, iStateId int32, iPropId int32, pColor *COLORREF) HRESULT {
ret1 := syscall6(getThemeColor, 5,
uintptr(hTheme),
uintptr(iPartId),
uintptr(iStateId),
uintptr(iPropId),
uintptr(unsafe.Pointer(pColor)),
0)
return HRESULT(ret1)
}
func GetThemeDocumentationProperty(pszThemeName string, pszPropertyName string, pszValueBuff LPWSTR, cchMaxValChars int32) HRESULT {
pszThemeNameStr := unicode16FromString(pszThemeName)
pszPropertyNameStr := unicode16FromString(pszPropertyName)
ret1 := syscall6(getThemeDocumentationProperty, 4,
uintptr(unsafe.Pointer(&pszThemeNameStr[0])),
uintptr(unsafe.Pointer(&pszPropertyNameStr[0])),
uintptr(unsafe.Pointer(pszValueBuff)),
uintptr(cchMaxValChars),
0,
0)
return HRESULT(ret1)
}
func GetThemeEnumValue(hTheme HTHEME, iPartId int32, iStateId int32, iPropId int32, piVal *int) HRESULT {
ret1 := syscall6(getThemeEnumValue, 5,
uintptr(hTheme),
uintptr(iPartId),
uintptr(iStateId),
uintptr(iPropId),
uintptr(unsafe.Pointer(piVal)),
0)
return HRESULT(ret1)
}
func GetThemeFilename(hTheme HTHEME, iPartId int32, iStateId int32, iPropId int32, pszThemeFilename LPWSTR, cchMaxBuffChars int32) HRESULT {
ret1 := syscall6(getThemeFilename, 6,
uintptr(hTheme),
uintptr(iPartId),
uintptr(iStateId),
uintptr(iPropId),
uintptr(unsafe.Pointer(pszThemeFilename)),
uintptr(cchMaxBuffChars))
return HRESULT(ret1)
}
func GetThemeFont(hTheme HTHEME, hdc HDC, iPartId int32, iStateId int32, iPropId int32, pFont *LOGFONT) HRESULT {
ret1 := syscall6(getThemeFont, 6,
uintptr(hTheme),
uintptr(hdc),
uintptr(iPartId),
uintptr(iStateId),
uintptr(iPropId),
uintptr(unsafe.Pointer(pFont)))
return HRESULT(ret1)
}
func GetThemeInt(hTheme HTHEME, iPartId int32, iStateId int32, iPropId int32, piVal *int) HRESULT {
ret1 := syscall6(getThemeInt, 5,
uintptr(hTheme),
uintptr(iPartId),
uintptr(iStateId),
uintptr(iPropId),
uintptr(unsafe.Pointer(piVal)),
0)
return HRESULT(ret1)
}
func GetThemeIntList(hTheme HTHEME, iPartId int32, iStateId int32, iPropId int32, pIntList *INTLIST) HRESULT {
ret1 := syscall6(getThemeIntList, 5,
uintptr(hTheme),
uintptr(iPartId),
uintptr(iStateId),
uintptr(iPropId),
uintptr(unsafe.Pointer(pIntList)),
0)
return HRESULT(ret1)
}
func GetThemeMargins(hTheme HTHEME, hdc HDC, iPartId int32, iStateId int32, iPropId int32, prc *RECT, pMargins *MARGINS) HRESULT {
ret1 := syscall9(getThemeMargins, 7,
uintptr(hTheme),
uintptr(hdc),
uintptr(iPartId),
uintptr(iStateId),
uintptr(iPropId),
uintptr(unsafe.Pointer(prc)),
uintptr(unsafe.Pointer(pMargins)),
0,
0)
return HRESULT(ret1)
}
func GetThemeMetric(hTheme HTHEME, hdc HDC, iPartId int32, iStateId int32, iPropId int32, piVal *int) HRESULT {
ret1 := syscall6(getThemeMetric, 6,
uintptr(hTheme),
uintptr(hdc),
uintptr(iPartId),
uintptr(iStateId),
uintptr(iPropId),
uintptr(unsafe.Pointer(piVal)))
return HRESULT(ret1)
}
func GetThemePartSize(hTheme HTHEME, hdc HDC, iPartId int32, iStateId int32, prc *RECT, eSize THEMESIZE, psz *SIZE) HRESULT {
ret1 := syscall9(getThemePartSize, 7,
uintptr(hTheme),
uintptr(hdc),
uintptr(iPartId),
uintptr(iStateId),
uintptr(unsafe.Pointer(prc)),
uintptr(eSize),
uintptr(unsafe.Pointer(psz)),
0,
0)
return HRESULT(ret1)
}
func GetThemePosition(hTheme HTHEME, iPartId int32, iStateId int32, iPropId int32, pPoint *POINT) HRESULT {
ret1 := syscall6(getThemePosition, 5,
uintptr(hTheme),
uintptr(iPartId),
uintptr(iStateId),
uintptr(iPropId),
uintptr(unsafe.Pointer(pPoint)),
0)
return HRESULT(ret1)
}
func GetThemePropertyOrigin(hTheme HTHEME, iPartId int32, iStateId int32, iPropId int32, pOrigin *PROPERTYORIGIN) HRESULT {
ret1 := syscall6(getThemePropertyOrigin, 5,
uintptr(hTheme),
uintptr(iPartId),
uintptr(iStateId),
uintptr(iPropId),
uintptr(unsafe.Pointer(pOrigin)),
0)
return HRESULT(ret1)
}
func GetThemeRect(hTheme HTHEME, iPartId int32, iStateId int32, iPropId int32, pRect *RECT) HRESULT {
ret1 := syscall6(getThemeRect, 5,
uintptr(hTheme),
uintptr(iPartId),
uintptr(iStateId),
uintptr(iPropId),
uintptr(unsafe.Pointer(pRect)),
0)
return HRESULT(ret1)
}
func GetThemeString(hTheme HTHEME, iPartId int32, iStateId int32, iPropId int32, pszBuff LPWSTR, cchMaxBuffChars int32) HRESULT {
ret1 := syscall6(getThemeString, 6,
uintptr(hTheme),
uintptr(iPartId),
uintptr(iStateId),
uintptr(iPropId),
uintptr(unsafe.Pointer(pszBuff)),
uintptr(cchMaxBuffChars))
return HRESULT(ret1)
}
func GetThemeSysBool(hTheme HTHEME, iBoolID int32) bool {
ret1 := syscall3(getThemeSysBool, 2,
uintptr(hTheme),
uintptr(iBoolID),
0)
return ret1 != 0
}
func GetThemeSysColor(hTheme HTHEME, iColorID int32) COLORREF {
ret1 := syscall3(getThemeSysColor, 2,
uintptr(hTheme),
uintptr(iColorID),
0)
return COLORREF(ret1)
}
func GetThemeSysColorBrush(hTheme HTHEME, iColorID int32) HBRUSH {
ret1 := syscall3(getThemeSysColorBrush, 2,
uintptr(hTheme),
uintptr(iColorID),
0)
return HBRUSH(ret1)
}
func GetThemeSysFont(hTheme HTHEME, iFontID int32, plf *LOGFONT) HRESULT {
ret1 := syscall3(getThemeSysFont, 3,
uintptr(hTheme),
uintptr(iFontID),
uintptr(unsafe.Pointer(plf)))
return HRESULT(ret1)
}
func GetThemeSysInt(hTheme HTHEME, iIntID int32, piValue *int) HRESULT {
ret1 := syscall3(getThemeSysInt, 3,
uintptr(hTheme),
uintptr(iIntID),
uintptr(unsafe.Pointer(piValue)))
return HRESULT(ret1)
}
func GetThemeSysSize(hTheme HTHEME, iSizeID int32) int32 {
ret1 := syscall3(getThemeSysSize, 2,
uintptr(hTheme),
uintptr(iSizeID),
0)
return int32(ret1)
}
func GetThemeSysString(hTheme HTHEME, iStringID int32, pszStringBuff LPWSTR, cchMaxStringChars int32) HRESULT {
ret1 := syscall6(getThemeSysString, 4,
uintptr(hTheme),
uintptr(iStringID),
uintptr(unsafe.Pointer(pszStringBuff)),
uintptr(cchMaxStringChars),
0,
0)
return HRESULT(ret1)
}
func GetThemeTextExtent(hTheme HTHEME, hdc HDC, iPartId int32, iStateId int32, pszText string, iCharCount int32, dwTextFlags DWORD, pBoundingRect /*const*/ *RECT, pExtentRect *RECT) HRESULT {
pszTextStr := unicode16FromString(pszText)
ret1 := syscall9(getThemeTextExtent, 9,
uintptr(hTheme),
uintptr(hdc),
uintptr(iPartId),
uintptr(iStateId),
uintptr(unsafe.Pointer(&pszTextStr[0])),
uintptr(iCharCount),
uintptr(dwTextFlags),
uintptr(unsafe.Pointer(pBoundingRect)),
uintptr(unsafe.Pointer(pExtentRect)))
return HRESULT(ret1)
}
func GetThemeTextMetrics(hTheme HTHEME, hdc HDC, iPartId int32, iStateId int32, ptm *TEXTMETRIC) HRESULT {
ret1 := syscall6(getThemeTextMetrics, 5,
uintptr(hTheme),
uintptr(hdc),
uintptr(iPartId),
uintptr(iStateId),
uintptr(unsafe.Pointer(ptm)),
0)
return HRESULT(ret1)
}
func GetThemeTransitionDuration(hTheme HTHEME, iPartId int32, iStateIdFrom int32, iStateIdTo int32, iPropId int32, pdwDuration *uint32) HRESULT {
ret1 := syscall6(getThemeTransitionDuration, 6,
uintptr(hTheme),
uintptr(iPartId),
uintptr(iStateIdFrom),
uintptr(iStateIdTo),
uintptr(iPropId),
uintptr(unsafe.Pointer(pdwDuration)))
return HRESULT(ret1)
}
func GetWindowTheme(hwnd HWND) HTHEME {
ret1 := syscall3(getWindowTheme, 1,
uintptr(hwnd),
0,
0)
return HTHEME(ret1)
}
func HitTestThemeBackground(hTheme HTHEME, hdc HDC, iPartId int32, iStateId int32, dwOptions DWORD, pRect /*const*/ *RECT, hrgn HRGN, ptTest POINT, pwHitTestCode *WORD) HRESULT {
ret1 := syscall12(hitTestThemeBackground, 10,
uintptr(hTheme),
uintptr(hdc),
uintptr(iPartId),
uintptr(iStateId),
uintptr(dwOptions),
uintptr(unsafe.Pointer(pRect)),
uintptr(hrgn),
uintptr(ptTest.X),
uintptr(ptTest.Y),
uintptr(unsafe.Pointer(pwHitTestCode)),
0,
0)
return HRESULT(ret1)
}
func IsAppThemed() bool {
ret1 := syscall3(isAppThemed, 0,
0,
0,
0)
return ret1 != 0
}
func IsThemeActive() bool {
ret1 := syscall3(isThemeActive, 0,
0,
0,
0)
return ret1 != 0
}
func IsThemeBackgroundPartiallyTransparent(hTheme HTHEME, iPartId int32, iStateId int32) bool {
ret1 := syscall3(isThemeBackgroundPartiallyTransparent, 3,
uintptr(hTheme),
uintptr(iPartId),
uintptr(iStateId))
return ret1 != 0
}
func IsThemeDialogTextureEnabled(hwnd HWND) bool {
ret1 := syscall3(isThemeDialogTextureEnabled, 1,
uintptr(hwnd),
0,
0)
return ret1 != 0
}
func IsThemePartDefined(hTheme HTHEME, iPartId int32, iStateId int32) bool {
ret1 := syscall3(isThemePartDefined, 3,
uintptr(hTheme),
uintptr(iPartId),
uintptr(iStateId))
return ret1 != 0
}
func OpenThemeData(hwnd HWND, classlist string) HTHEME {
classlistStr := unicode16FromString(classlist)
ret1 := syscall3(openThemeData, 2,
uintptr(hwnd),
uintptr(unsafe.Pointer(&classlistStr[0])),
0)
return HTHEME(ret1)
}
func OpenThemeDataEx(hwnd HWND, pszClassList string, flags DWORD) HTHEME {
pszClassListStr := unicode16FromString(pszClassList)
ret1 := syscall3(openThemeDataEx, 3,
uintptr(hwnd),
uintptr(unsafe.Pointer(&pszClassListStr[0])),
uintptr(flags))
return HTHEME(ret1)
}
func SetThemeAppProperties(dwFlags DWORD) {
syscall3(setThemeAppProperties, 1,
uintptr(dwFlags),
0,
0)
}
func SetWindowTheme(hwnd HWND, pszSubAppName string, pszSubIdList string) HRESULT {
pszSubAppNameStr := unicode16FromString(pszSubAppName)
pszSubIdListStr := unicode16FromString(pszSubIdList)
ret1 := syscall3(setWindowTheme, 3,
uintptr(hwnd),
uintptr(unsafe.Pointer(&pszSubAppNameStr[0])),
uintptr(unsafe.Pointer(&pszSubIdListStr[0])))
return HRESULT(ret1)
}

View File

@@ -1,95 +0,0 @@
// This file was automatically generated by https://github.com/kbinani/win/blob/generator/internal/cmd/gen/gen.go
// go run internal/cmd/gen/gen.go
// +build windows
package win
import (
"unsafe"
)
var (
// Library
libversion uintptr
// Functions
getFileVersionInfoSize uintptr
getFileVersionInfo uintptr
verFindFile uintptr
verInstallFile uintptr
verQueryValue uintptr
)
func init() {
// Library
libversion = doLoadLibrary("version.dll")
// Functions
getFileVersionInfoSize = doGetProcAddress(libversion, "GetFileVersionInfoSizeW")
getFileVersionInfo = doGetProcAddress(libversion, "GetFileVersionInfoW")
verFindFile = doGetProcAddress(libversion, "VerFindFileW")
verInstallFile = doGetProcAddress(libversion, "VerInstallFileW")
verQueryValue = doGetProcAddress(libversion, "VerQueryValueW")
}
func GetFileVersionInfoSize(lptstrFilename string, lpdwHandle *uint32) DWORD {
lptstrFilenameStr := unicode16FromString(lptstrFilename)
ret1 := syscall3(getFileVersionInfoSize, 2,
uintptr(unsafe.Pointer(&lptstrFilenameStr[0])),
uintptr(unsafe.Pointer(lpdwHandle)),
0)
return DWORD(ret1)
}
func GetFileVersionInfo(lptstrFilename string, dwHandle DWORD, dwLen DWORD, lpData LPVOID) bool {
lptstrFilenameStr := unicode16FromString(lptstrFilename)
ret1 := syscall6(getFileVersionInfo, 4,
uintptr(unsafe.Pointer(&lptstrFilenameStr[0])),
uintptr(dwHandle),
uintptr(dwLen),
uintptr(unsafe.Pointer(lpData)),
0,
0)
return ret1 != 0
}
func VerFindFile(uFlags DWORD, szFileName LPWSTR, szWinDir LPWSTR, szAppDir LPWSTR, szCurDir LPWSTR, lpuCurDirLen *uint32, szDestDir LPWSTR, lpuDestDirLen *uint32) DWORD {
ret1 := syscall9(verFindFile, 8,
uintptr(uFlags),
uintptr(unsafe.Pointer(szFileName)),
uintptr(unsafe.Pointer(szWinDir)),
uintptr(unsafe.Pointer(szAppDir)),
uintptr(unsafe.Pointer(szCurDir)),
uintptr(unsafe.Pointer(lpuCurDirLen)),
uintptr(unsafe.Pointer(szDestDir)),
uintptr(unsafe.Pointer(lpuDestDirLen)),
0)
return DWORD(ret1)
}
func VerInstallFile(uFlags DWORD, szSrcFileName LPWSTR, szDestFileName LPWSTR, szSrcDir LPWSTR, szDestDir LPWSTR, szCurDir LPWSTR, szTmpFile LPWSTR, lpuTmpFileLen *uint32) DWORD {
ret1 := syscall9(verInstallFile, 8,
uintptr(uFlags),
uintptr(unsafe.Pointer(szSrcFileName)),
uintptr(unsafe.Pointer(szDestFileName)),
uintptr(unsafe.Pointer(szSrcDir)),
uintptr(unsafe.Pointer(szDestDir)),
uintptr(unsafe.Pointer(szCurDir)),
uintptr(unsafe.Pointer(szTmpFile)),
uintptr(unsafe.Pointer(lpuTmpFileLen)),
0)
return DWORD(ret1)
}
func VerQueryValue(pBlock /*const*/ LPVOID, lpSubBlock string, lplpBuffer LPVOID, puLen *uint32) bool {
lpSubBlockStr := unicode16FromString(lpSubBlock)
ret1 := syscall6(verQueryValue, 4,
uintptr(unsafe.Pointer(pBlock)),
uintptr(unsafe.Pointer(&lpSubBlockStr[0])),
uintptr(unsafe.Pointer(lplpBuffer)),
uintptr(unsafe.Pointer(puLen)),
0,
0)
return ret1 != 0
}

View File

@@ -1,32 +0,0 @@
package win
import (
"unicode/utf16"
"unsafe"
)
func unicode16FromString(s string) []uint16 {
r := make([]rune, 0)
for _, c := range s {
r = append(r, c)
}
b := utf16.Encode(r)
return append(b, uint16(0))
}
func stringFromUnicode16(s *uint16) string {
if s == nil {
return ""
}
buffer := []uint16{}
ptr := uintptr(unsafe.Pointer(s))
for true {
ch := *(*uint16)(unsafe.Pointer(ptr))
if ch == 0 {
break
}
buffer = append(buffer, ch)
ptr += unsafe.Sizeof(ch)
}
return string(utf16.Decode(buffer))
}

View File

@@ -1,13 +0,0 @@
package win
const ptrsize = 4
const is64 = false
const pad4for64_0for32 = 0
const pad0for64_4for32 = 4
const pad4for64_3for32 = 3
const pad11for64_7for32 = 7
const pad3for64_2for32 = 2
const pad3for64_1for32 = 1
const pad6for64_3for32 = 3
const pad6for64_0for32 = 0

View File

@@ -1,13 +0,0 @@
package win
const ptrsize = 8
const is64 = true
const pad4for64_0for32 = 4
const pad0for64_4for32 = 0
const pad4for64_3for32 = 4
const pad11for64_7for32 = 11
const pad3for64_2for32 = 3
const pad3for64_1for32 = 3
const pad6for64_3for32 = 6
const pad6for64_0for32 = 6

View File

@@ -1,12 +0,0 @@
// +build !windows
package win
import (
"syscall"
)
func syscall3(trap, nargs, a1, a2, a3 uintptr) uintptr {
ret, _, _ := syscall.Syscall(trap, a1, a2, a3)
return ret
}

View File

@@ -1,91 +0,0 @@
package win
import (
"fmt"
"math"
"syscall"
)
func doLoadLibrary(name string) uintptr {
lib, _ := syscall.LoadLibrary(name)
return uintptr(lib)
}
func doGetProcAddress(lib uintptr, name string) uintptr {
addr, _ := syscall.GetProcAddress(syscall.Handle(lib), name)
return uintptr(addr)
}
func syscall3(trap, nargs, a1, a2, a3 uintptr) uintptr {
ret, _, _ := syscall.Syscall(trap, nargs, a1, a2, a3)
return ret
}
func syscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) uintptr {
ret, _, _ := syscall.Syscall6(trap, nargs, a1, a2, a3, a4, a5, a6)
return ret
}
func syscall9(trap, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) uintptr {
ret, _, _ := syscall.Syscall9(trap, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9)
return ret
}
func syscall12(trap, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12 uintptr) uintptr {
ret, _, _ := syscall.Syscall12(trap, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12)
return ret
}
func syscall15(trap, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr) uintptr {
ret, _, _ := syscall.Syscall15(trap, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15)
return ret
}
func syscallN(trap uintptr, args []uintptr) uintptr {
n := len(args)
num := int(math.Max(1.0, math.Ceil(float64(n)/3.0))) * 3
for i := n; i < num; i++ {
args = append(args, 0)
}
if num == 3 {
ret, _, _ := syscall.Syscall(trap, uintptr(n),
args[0], args[1], args[2])
return ret
} else if num == 6 {
ret, _, _ := syscall.Syscall6(trap, uintptr(n),
args[0], args[1], args[2],
args[3], args[4], args[5])
return ret
} else if num == 9 {
ret, _, _ := syscall.Syscall9(trap, uintptr(n),
args[0], args[1], args[2],
args[3], args[4], args[5],
args[6], args[7], args[8])
return ret
} else if num == 12 {
ret, _, _ := syscall.Syscall12(trap, uintptr(n),
args[0], args[1], args[2],
args[3], args[4], args[5],
args[6], args[7], args[8],
args[9], args[10], args[11])
return ret
} else if num == 15 {
ret, _, _ := syscall.Syscall15(trap, uintptr(n),
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])
return ret
} else {
panic(fmt.Errorf("Too many syscall arguments: %d", n))
}
}
func getUintptrFromBool(b bool) uintptr {
if b {
return 1
} else {
return 0
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,904 +0,0 @@
// This file was automatically generated by https://github.com/kbinani/win/blob/generator/internal/cmd/gen/gen.go
// go run internal/cmd/gen/gen.go
// +build windows
package win
import (
"syscall"
"unsafe"
)
var (
// Library
libws2_32 uintptr
// Functions
freeAddrInfoExW uintptr
freeAddrInfoW uintptr
getAddrInfoEx uintptr
getAddrInfoW uintptr
getNameInfoW uintptr
inetNtopW uintptr
inetPtonW uintptr
wPUCompleteOverlappedRequest uintptr
wSAAccept uintptr
wSAAddressToString uintptr
wSAAsyncGetHostByAddr uintptr
wSAAsyncGetHostByName uintptr
wSAAsyncGetProtoByName uintptr
wSAAsyncGetProtoByNumber uintptr
wSAAsyncGetServByName uintptr
wSAAsyncGetServByPort uintptr
wSAAsyncSelect uintptr
wSACancelAsyncRequest uintptr
wSACancelBlockingCall uintptr
wSACleanup uintptr
wSACloseEvent uintptr
wSAConnect uintptr
wSACreateEvent uintptr
wSADuplicateSocket uintptr
wSAEnumNameSpaceProviders uintptr
wSAEnumNetworkEvents uintptr
wSAEnumProtocols uintptr
wSAEventSelect uintptr
wSAGetLastError uintptr
wSAGetOverlappedResult uintptr
wSAGetQOSByName uintptr
wSAGetServiceClassInfo uintptr
wSAGetServiceClassNameByClassId uintptr
wSAHtonl uintptr
wSAHtons uintptr
wSAInstallServiceClass uintptr
wSAIoctl uintptr
wSAIsBlocking uintptr
wSAJoinLeaf uintptr
wSALookupServiceBegin uintptr
wSALookupServiceEnd uintptr
wSALookupServiceNext uintptr
wSANSPIoctl uintptr
wSANtohl uintptr
wSANtohs uintptr
wSAPoll uintptr
wSAProviderConfigChange uintptr
wSARecv uintptr
wSARecvDisconnect uintptr
wSARecvFrom uintptr
wSARemoveServiceClass uintptr
wSASend uintptr
wSASendDisconnect uintptr
wSASendMsg uintptr
wSASendTo uintptr
wSASetBlockingHook uintptr
wSASetLastError uintptr
wSASetService uintptr
wSASocket uintptr
wSAStartup uintptr
wSAStringToAddress uintptr
wSAUnhookBlockingHook uintptr
wSApSetPostRoutine uintptr
wSCDeinstallProvider uintptr
wSCEnableNSProvider uintptr
wSCEnumProtocols uintptr
wSCGetProviderPath uintptr
wSCInstallNameSpace uintptr
wSCInstallProvider uintptr
wSCUnInstallNameSpace uintptr
wSCWriteProviderOrder uintptr
gethostname uintptr
)
func init() {
// Library
libws2_32 = doLoadLibrary("ws2_32.dll")
// Functions
freeAddrInfoExW = doGetProcAddress(libws2_32, "FreeAddrInfoExW")
freeAddrInfoW = doGetProcAddress(libws2_32, "FreeAddrInfoW")
getAddrInfoEx = doGetProcAddress(libws2_32, "GetAddrInfoExW")
getAddrInfoW = doGetProcAddress(libws2_32, "GetAddrInfoW")
getNameInfoW = doGetProcAddress(libws2_32, "GetNameInfoW")
inetNtopW = doGetProcAddress(libws2_32, "InetNtopW")
inetPtonW = doGetProcAddress(libws2_32, "InetPtonW")
wPUCompleteOverlappedRequest = doGetProcAddress(libws2_32, "WPUCompleteOverlappedRequest")
wSAAccept = doGetProcAddress(libws2_32, "WSAAccept")
wSAAddressToString = doGetProcAddress(libws2_32, "WSAAddressToStringW")
wSAAsyncGetHostByAddr = doGetProcAddress(libws2_32, "WSAAsyncGetHostByAddr")
wSAAsyncGetHostByName = doGetProcAddress(libws2_32, "WSAAsyncGetHostByName")
wSAAsyncGetProtoByName = doGetProcAddress(libws2_32, "WSAAsyncGetProtoByName")
wSAAsyncGetProtoByNumber = doGetProcAddress(libws2_32, "WSAAsyncGetProtoByNumber")
wSAAsyncGetServByName = doGetProcAddress(libws2_32, "WSAAsyncGetServByName")
wSAAsyncGetServByPort = doGetProcAddress(libws2_32, "WSAAsyncGetServByPort")
wSAAsyncSelect = doGetProcAddress(libws2_32, "WSAAsyncSelect")
wSACancelAsyncRequest = doGetProcAddress(libws2_32, "WSACancelAsyncRequest")
wSACancelBlockingCall = doGetProcAddress(libws2_32, "WSACancelBlockingCall")
wSACleanup = doGetProcAddress(libws2_32, "WSACleanup")
wSACloseEvent = doGetProcAddress(libws2_32, "WSACloseEvent")
wSAConnect = doGetProcAddress(libws2_32, "WSAConnect")
wSACreateEvent = doGetProcAddress(libws2_32, "WSACreateEvent")
wSADuplicateSocket = doGetProcAddress(libws2_32, "WSADuplicateSocketW")
wSAEnumNameSpaceProviders = doGetProcAddress(libws2_32, "WSAEnumNameSpaceProvidersW")
wSAEnumNetworkEvents = doGetProcAddress(libws2_32, "WSAEnumNetworkEvents")
wSAEnumProtocols = doGetProcAddress(libws2_32, "WSAEnumProtocolsW")
wSAEventSelect = doGetProcAddress(libws2_32, "WSAEventSelect")
wSAGetLastError = doGetProcAddress(libws2_32, "WSAGetLastError")
wSAGetOverlappedResult = doGetProcAddress(libws2_32, "WSAGetOverlappedResult")
wSAGetQOSByName = doGetProcAddress(libws2_32, "WSAGetQOSByName")
wSAGetServiceClassInfo = doGetProcAddress(libws2_32, "WSAGetServiceClassInfoW")
wSAGetServiceClassNameByClassId = doGetProcAddress(libws2_32, "WSAGetServiceClassNameByClassIdW")
wSAHtonl = doGetProcAddress(libws2_32, "WSAHtonl")
wSAHtons = doGetProcAddress(libws2_32, "WSAHtons")
wSAInstallServiceClass = doGetProcAddress(libws2_32, "WSAInstallServiceClassW")
wSAIoctl = doGetProcAddress(libws2_32, "WSAIoctl")
wSAIsBlocking = doGetProcAddress(libws2_32, "WSAIsBlocking")
wSAJoinLeaf = doGetProcAddress(libws2_32, "WSAJoinLeaf")
wSALookupServiceBegin = doGetProcAddress(libws2_32, "WSALookupServiceBeginW")
wSALookupServiceEnd = doGetProcAddress(libws2_32, "WSALookupServiceEnd")
wSALookupServiceNext = doGetProcAddress(libws2_32, "WSALookupServiceNextW")
wSANSPIoctl = doGetProcAddress(libws2_32, "WSANSPIoctl")
wSANtohl = doGetProcAddress(libws2_32, "WSANtohl")
wSANtohs = doGetProcAddress(libws2_32, "WSANtohs")
wSAPoll = doGetProcAddress(libws2_32, "WSAPoll")
wSAProviderConfigChange = doGetProcAddress(libws2_32, "WSAProviderConfigChange")
wSARecv = doGetProcAddress(libws2_32, "WSARecv")
wSARecvDisconnect = doGetProcAddress(libws2_32, "WSARecvDisconnect")
wSARecvFrom = doGetProcAddress(libws2_32, "WSARecvFrom")
wSARemoveServiceClass = doGetProcAddress(libws2_32, "WSARemoveServiceClass")
wSASend = doGetProcAddress(libws2_32, "WSASend")
wSASendDisconnect = doGetProcAddress(libws2_32, "WSASendDisconnect")
wSASendMsg = doGetProcAddress(libws2_32, "WSASendMsg")
wSASendTo = doGetProcAddress(libws2_32, "WSASendTo")
wSASetBlockingHook = doGetProcAddress(libws2_32, "WSASetBlockingHook")
wSASetLastError = doGetProcAddress(libws2_32, "WSASetLastError")
wSASetService = doGetProcAddress(libws2_32, "WSASetServiceW")
wSASocket = doGetProcAddress(libws2_32, "WSASocketW")
wSAStartup = doGetProcAddress(libws2_32, "WSAStartup")
wSAStringToAddress = doGetProcAddress(libws2_32, "WSAStringToAddressW")
wSAUnhookBlockingHook = doGetProcAddress(libws2_32, "WSAUnhookBlockingHook")
wSApSetPostRoutine = doGetProcAddress(libws2_32, "WSApSetPostRoutine")
wSCDeinstallProvider = doGetProcAddress(libws2_32, "WSCDeinstallProvider")
wSCEnableNSProvider = doGetProcAddress(libws2_32, "WSCEnableNSProvider")
wSCEnumProtocols = doGetProcAddress(libws2_32, "WSCEnumProtocols")
wSCGetProviderPath = doGetProcAddress(libws2_32, "WSCGetProviderPath")
wSCInstallNameSpace = doGetProcAddress(libws2_32, "WSCInstallNameSpace")
wSCInstallProvider = doGetProcAddress(libws2_32, "WSCInstallProvider")
wSCUnInstallNameSpace = doGetProcAddress(libws2_32, "WSCUnInstallNameSpace")
wSCWriteProviderOrder = doGetProcAddress(libws2_32, "WSCWriteProviderOrder")
gethostname = doGetProcAddress(libws2_32, "gethostname")
}
func FreeAddrInfoExW(ai *ADDRINFOEX) {
syscall3(freeAddrInfoExW, 1,
uintptr(unsafe.Pointer(ai)),
0,
0)
}
func FreeAddrInfoW(ai PADDRINFO) {
syscall3(freeAddrInfoW, 1,
uintptr(unsafe.Pointer(ai)),
0,
0)
}
func GetAddrInfoEx(name /*const*/ *WCHAR, servname /*const*/ *WCHAR, namespace DWORD, namespace_id *GUID, hints /*const*/ *ADDRINFOEX, result **ADDRINFOEX, timeout *Timeval, overlapped *OVERLAPPED, completion_routine LPLOOKUPSERVICE_COMPLETION_ROUTINE, handle *HANDLE) int32 {
completion_routineCallback := syscall.NewCallback(completion_routine)
ret1 := syscall12(getAddrInfoEx, 10,
uintptr(unsafe.Pointer(name)),
uintptr(unsafe.Pointer(servname)),
uintptr(namespace),
uintptr(unsafe.Pointer(namespace_id)),
uintptr(unsafe.Pointer(hints)),
uintptr(unsafe.Pointer(result)),
uintptr(unsafe.Pointer(timeout)),
uintptr(unsafe.Pointer(overlapped)),
completion_routineCallback,
uintptr(unsafe.Pointer(handle)),
0,
0)
return int32(ret1)
}
func GetAddrInfoW(nodename string, servname string, hints /*const*/ *ADDRINFO, res *PADDRINFO) int32 {
nodenameStr := unicode16FromString(nodename)
servnameStr := unicode16FromString(servname)
ret1 := syscall6(getAddrInfoW, 4,
uintptr(unsafe.Pointer(&nodenameStr[0])),
uintptr(unsafe.Pointer(&servnameStr[0])),
uintptr(unsafe.Pointer(hints)),
uintptr(unsafe.Pointer(res)),
0,
0)
return int32(ret1)
}
func GetNameInfoW(sa /*const*/ *SOCKADDR, salen Socklen_t, host PWCHAR, hostlen DWORD, serv PWCHAR, servlen DWORD, flags INT) int32 {
ret1 := syscall9(getNameInfoW, 7,
uintptr(unsafe.Pointer(sa)),
uintptr(salen),
uintptr(unsafe.Pointer(host)),
uintptr(hostlen),
uintptr(unsafe.Pointer(serv)),
uintptr(servlen),
uintptr(flags),
0,
0)
return int32(ret1)
}
func InetNtopW(family INT, addr uintptr, buffer PWSTR, aLen SIZE_T) string {
ret1 := syscall6(inetNtopW, 4,
uintptr(family),
addr,
uintptr(unsafe.Pointer(buffer)),
uintptr(aLen),
0,
0)
return stringFromUnicode16((*uint16)(unsafe.Pointer(ret1)))
}
func InetPtonW(family INT, addr string, buffer uintptr) INT {
addrStr := unicode16FromString(addr)
ret1 := syscall3(inetPtonW, 3,
uintptr(family),
uintptr(unsafe.Pointer(&addrStr[0])),
buffer)
return INT(ret1)
}
func WPUCompleteOverlappedRequest(s SOCKET, overlapped LPWSAOVERLAPPED, error DWORD, transferred DWORD, errcode *int32) WSAEVENT {
ret1 := syscall6(wPUCompleteOverlappedRequest, 5,
uintptr(s),
uintptr(unsafe.Pointer(overlapped)),
uintptr(error),
uintptr(transferred),
uintptr(unsafe.Pointer(errcode)),
0)
return WSAEVENT(ret1)
}
func WSAAccept(s SOCKET, addr *Sockaddr, addrlen *int32, lpfnCondition LPCONDITIONPROC, dwCallbackData *uint32) SOCKET {
lpfnConditionCallback := syscall.NewCallback(func(lpCallerIdRawArg LPWSABUF, lpCallerDataRawArg LPWSABUF, lpSQOSRawArg LPQOS, lpGQOSRawArg LPQOS, lpCalleeIdRawArg LPWSABUF, lpCalleeDataRawArg LPWSABUF, gRawArg *GROUP, dwCallbackDataRawArg DWORD_PTR) uintptr {
ret := lpfnCondition(lpCallerIdRawArg, lpCallerDataRawArg, lpSQOSRawArg, lpGQOSRawArg, lpCalleeIdRawArg, lpCalleeDataRawArg, gRawArg, dwCallbackDataRawArg)
return uintptr(ret)
})
ret1 := syscall6(wSAAccept, 5,
uintptr(s),
uintptr(unsafe.Pointer(addr)),
uintptr(unsafe.Pointer(addrlen)),
lpfnConditionCallback,
uintptr(unsafe.Pointer(dwCallbackData)),
0)
return SOCKET(ret1)
}
func WSAAddressToString(sockaddr *SOCKADDR, aLen DWORD, info LPWSAPROTOCOL_INFO, string LPWSTR, lenstr *uint32) INT {
ret1 := syscall6(wSAAddressToString, 5,
uintptr(unsafe.Pointer(sockaddr)),
uintptr(aLen),
uintptr(unsafe.Pointer(info)),
uintptr(unsafe.Pointer(string)),
uintptr(unsafe.Pointer(lenstr)),
0)
return INT(ret1)
}
func WSAAsyncGetHostByAddr(hWnd HWND, uMsg UINT, addr /*const*/ LPCSTR, aLen INT, aType INT, sbuf LPSTR, buflen INT) HANDLE {
ret1 := syscall9(wSAAsyncGetHostByAddr, 7,
uintptr(hWnd),
uintptr(uMsg),
uintptr(unsafe.Pointer(addr)),
uintptr(aLen),
uintptr(aType),
uintptr(unsafe.Pointer(sbuf)),
uintptr(buflen),
0,
0)
return HANDLE(ret1)
}
func WSAAsyncGetHostByName(hWnd HWND, uMsg UINT, name /*const*/ LPCSTR, sbuf LPSTR, buflen INT) HANDLE {
ret1 := syscall6(wSAAsyncGetHostByName, 5,
uintptr(hWnd),
uintptr(uMsg),
uintptr(unsafe.Pointer(name)),
uintptr(unsafe.Pointer(sbuf)),
uintptr(buflen),
0)
return HANDLE(ret1)
}
func WSAAsyncGetProtoByName(hWnd HWND, uMsg UINT, name /*const*/ LPCSTR, sbuf LPSTR, buflen INT) HANDLE {
ret1 := syscall6(wSAAsyncGetProtoByName, 5,
uintptr(hWnd),
uintptr(uMsg),
uintptr(unsafe.Pointer(name)),
uintptr(unsafe.Pointer(sbuf)),
uintptr(buflen),
0)
return HANDLE(ret1)
}
func WSAAsyncGetProtoByNumber(hWnd HWND, uMsg UINT, number INT, sbuf LPSTR, buflen INT) HANDLE {
ret1 := syscall6(wSAAsyncGetProtoByNumber, 5,
uintptr(hWnd),
uintptr(uMsg),
uintptr(number),
uintptr(unsafe.Pointer(sbuf)),
uintptr(buflen),
0)
return HANDLE(ret1)
}
func WSAAsyncGetServByName(hWnd HWND, uMsg UINT, name /*const*/ LPCSTR, proto /*const*/ LPCSTR, sbuf LPSTR, buflen INT) HANDLE {
ret1 := syscall6(wSAAsyncGetServByName, 6,
uintptr(hWnd),
uintptr(uMsg),
uintptr(unsafe.Pointer(name)),
uintptr(unsafe.Pointer(proto)),
uintptr(unsafe.Pointer(sbuf)),
uintptr(buflen))
return HANDLE(ret1)
}
func WSAAsyncGetServByPort(hWnd HWND, uMsg UINT, port INT, proto /*const*/ LPCSTR, sbuf LPSTR, buflen INT) HANDLE {
ret1 := syscall6(wSAAsyncGetServByPort, 6,
uintptr(hWnd),
uintptr(uMsg),
uintptr(port),
uintptr(unsafe.Pointer(proto)),
uintptr(unsafe.Pointer(sbuf)),
uintptr(buflen))
return HANDLE(ret1)
}
func WSAAsyncSelect(s SOCKET, hWnd HWND, uMsg UINT, lEvent LONG) INT {
ret1 := syscall6(wSAAsyncSelect, 4,
uintptr(s),
uintptr(hWnd),
uintptr(uMsg),
uintptr(lEvent),
0,
0)
return INT(ret1)
}
func WSACancelAsyncRequest(hAsyncTaskHandle HANDLE) INT {
ret1 := syscall3(wSACancelAsyncRequest, 1,
uintptr(hAsyncTaskHandle),
0,
0)
return INT(ret1)
}
func WSACancelBlockingCall() INT {
ret1 := syscall3(wSACancelBlockingCall, 0,
0,
0,
0)
return INT(ret1)
}
func WSACleanup() INT {
ret1 := syscall3(wSACleanup, 0,
0,
0,
0)
return INT(ret1)
}
func WSACloseEvent(event WSAEVENT) bool {
ret1 := syscall3(wSACloseEvent, 1,
uintptr(event),
0,
0)
return ret1 != 0
}
func WSAConnect(s SOCKET, name /*const*/ *Sockaddr, namelen int32, lpCallerData LPWSABUF, lpCalleeData LPWSABUF, lpSQOS *QOS, lpGQOS *QOS) int32 {
ret1 := syscall9(wSAConnect, 7,
uintptr(s),
uintptr(unsafe.Pointer(name)),
uintptr(namelen),
uintptr(unsafe.Pointer(lpCallerData)),
uintptr(unsafe.Pointer(lpCalleeData)),
uintptr(unsafe.Pointer(lpSQOS)),
uintptr(unsafe.Pointer(lpGQOS)),
0,
0)
return int32(ret1)
}
func WSACreateEvent() WSAEVENT {
ret1 := syscall3(wSACreateEvent, 0,
0,
0,
0)
return WSAEVENT(ret1)
}
func WSADuplicateSocket(s SOCKET, dwProcessId DWORD, lpProtocolInfo LPWSAPROTOCOL_INFO) int32 {
ret1 := syscall3(wSADuplicateSocket, 3,
uintptr(s),
uintptr(dwProcessId),
uintptr(unsafe.Pointer(lpProtocolInfo)))
return int32(ret1)
}
func WSAEnumNameSpaceProviders(aLen *uint32, buffer LPWSANAMESPACE_INFO) INT {
ret1 := syscall3(wSAEnumNameSpaceProviders, 2,
uintptr(unsafe.Pointer(aLen)),
uintptr(unsafe.Pointer(buffer)),
0)
return INT(ret1)
}
func WSAEnumNetworkEvents(s SOCKET, hEvent WSAEVENT, lpEvent *WSANETWORKEVENTS) int32 {
ret1 := syscall3(wSAEnumNetworkEvents, 3,
uintptr(s),
uintptr(hEvent),
uintptr(unsafe.Pointer(lpEvent)))
return int32(ret1)
}
func WSAEnumProtocols(protocols *int32, buffer LPWSAPROTOCOL_INFO, aLen *uint32) INT {
ret1 := syscall3(wSAEnumProtocols, 3,
uintptr(unsafe.Pointer(protocols)),
uintptr(unsafe.Pointer(buffer)),
uintptr(unsafe.Pointer(aLen)))
return INT(ret1)
}
func WSAEventSelect(s SOCKET, hEvent WSAEVENT, lEvent LONG) int32 {
ret1 := syscall3(wSAEventSelect, 3,
uintptr(s),
uintptr(hEvent),
uintptr(lEvent))
return int32(ret1)
}
func WSAGetLastError() INT {
ret1 := syscall3(wSAGetLastError, 0,
0,
0,
0)
return INT(ret1)
}
func WSAGetOverlappedResult(s SOCKET, lpOverlapped LPWSAOVERLAPPED, lpcbTransfer *uint32, fWait bool, lpdwFlags *uint32) bool {
ret1 := syscall6(wSAGetOverlappedResult, 5,
uintptr(s),
uintptr(unsafe.Pointer(lpOverlapped)),
uintptr(unsafe.Pointer(lpcbTransfer)),
getUintptrFromBool(fWait),
uintptr(unsafe.Pointer(lpdwFlags)),
0)
return ret1 != 0
}
func WSAGetQOSByName(s SOCKET, lpQOSName LPWSABUF, lpQOS *QOS) bool {
ret1 := syscall3(wSAGetQOSByName, 3,
uintptr(s),
uintptr(unsafe.Pointer(lpQOSName)),
uintptr(unsafe.Pointer(lpQOS)))
return ret1 != 0
}
func WSAGetServiceClassInfo(provider *GUID, service *GUID, aLen *uint32, info LPWSASERVICECLASSINFO) INT {
ret1 := syscall6(wSAGetServiceClassInfo, 4,
uintptr(unsafe.Pointer(provider)),
uintptr(unsafe.Pointer(service)),
uintptr(unsafe.Pointer(aLen)),
uintptr(unsafe.Pointer(info)),
0,
0)
return INT(ret1)
}
func WSAGetServiceClassNameByClassId(class *GUID, service LPWSTR, aLen *uint32) INT {
ret1 := syscall3(wSAGetServiceClassNameByClassId, 3,
uintptr(unsafe.Pointer(class)),
uintptr(unsafe.Pointer(service)),
uintptr(unsafe.Pointer(aLen)))
return INT(ret1)
}
func WSAHtonl(s SOCKET, hostlong ULONG, lpnetlong *ULONG) int32 {
ret1 := syscall3(wSAHtonl, 3,
uintptr(s),
uintptr(hostlong),
uintptr(unsafe.Pointer(lpnetlong)))
return int32(ret1)
}
func WSAHtons(s SOCKET, hostshort uint16, lpnetshort *uint16) int32 {
ret1 := syscall3(wSAHtons, 3,
uintptr(s),
uintptr(hostshort),
uintptr(unsafe.Pointer(lpnetshort)))
return int32(ret1)
}
func WSAInstallServiceClass(info LPWSASERVICECLASSINFO) int32 {
ret1 := syscall3(wSAInstallServiceClass, 1,
uintptr(unsafe.Pointer(info)),
0,
0)
return int32(ret1)
}
func WSAIoctl(s SOCKET, code DWORD, in_buff LPVOID, in_size DWORD, out_buff LPVOID, out_size DWORD, ret_size *uint32, overlapped LPWSAOVERLAPPED, completion LPWSAOVERLAPPED_COMPLETION_ROUTINE) INT {
completionCallback := syscall.NewCallback(completion)
ret1 := syscall9(wSAIoctl, 9,
uintptr(s),
uintptr(code),
uintptr(unsafe.Pointer(in_buff)),
uintptr(in_size),
uintptr(unsafe.Pointer(out_buff)),
uintptr(out_size),
uintptr(unsafe.Pointer(ret_size)),
uintptr(unsafe.Pointer(overlapped)),
completionCallback)
return INT(ret1)
}
func WSAIsBlocking() bool {
ret1 := syscall3(wSAIsBlocking, 0,
0,
0,
0)
return ret1 != 0
}
func WSAJoinLeaf(s SOCKET, addr /*const*/ *Sockaddr, addrlen int32, lpCallerData LPWSABUF, lpCalleeData LPWSABUF, lpSQOS *QOS, lpGQOS *QOS, dwFlags DWORD) SOCKET {
ret1 := syscall9(wSAJoinLeaf, 8,
uintptr(s),
uintptr(unsafe.Pointer(addr)),
uintptr(addrlen),
uintptr(unsafe.Pointer(lpCallerData)),
uintptr(unsafe.Pointer(lpCalleeData)),
uintptr(unsafe.Pointer(lpSQOS)),
uintptr(unsafe.Pointer(lpGQOS)),
uintptr(dwFlags),
0)
return SOCKET(ret1)
}
func WSALookupServiceBegin(lpqsRestrictions LPWSAQUERYSET, dwControlFlags DWORD, lphLookup *HANDLE) INT {
ret1 := syscall3(wSALookupServiceBegin, 3,
uintptr(unsafe.Pointer(lpqsRestrictions)),
uintptr(dwControlFlags),
uintptr(unsafe.Pointer(lphLookup)))
return INT(ret1)
}
func WSALookupServiceEnd(lookup HANDLE) INT {
ret1 := syscall3(wSALookupServiceEnd, 1,
uintptr(lookup),
0,
0)
return INT(ret1)
}
func WSALookupServiceNext(lookup HANDLE, flags DWORD, aLen *uint32, results LPWSAQUERYSET) INT {
ret1 := syscall6(wSALookupServiceNext, 4,
uintptr(lookup),
uintptr(flags),
uintptr(unsafe.Pointer(aLen)),
uintptr(unsafe.Pointer(results)),
0,
0)
return INT(ret1)
}
func WSANSPIoctl(hLookup HANDLE, dwControlCode DWORD, lpvInBuffer LPVOID, cbInBuffer DWORD, lpvOutBuffer LPVOID, cbOutBuffer DWORD, lpcbBytesReturned *uint32, lpCompletion *WSACOMPLETION) INT {
ret1 := syscall9(wSANSPIoctl, 8,
uintptr(hLookup),
uintptr(dwControlCode),
uintptr(unsafe.Pointer(lpvInBuffer)),
uintptr(cbInBuffer),
uintptr(unsafe.Pointer(lpvOutBuffer)),
uintptr(cbOutBuffer),
uintptr(unsafe.Pointer(lpcbBytesReturned)),
uintptr(unsafe.Pointer(lpCompletion)),
0)
return INT(ret1)
}
func WSANtohl(s SOCKET, netlong ULONG, lphostlong *ULONG) INT {
ret1 := syscall3(wSANtohl, 3,
uintptr(s),
uintptr(netlong),
uintptr(unsafe.Pointer(lphostlong)))
return INT(ret1)
}
func WSANtohs(s SOCKET, netshort uint16, lphostshort *uint16) INT {
ret1 := syscall3(wSANtohs, 3,
uintptr(s),
uintptr(netshort),
uintptr(unsafe.Pointer(lphostshort)))
return INT(ret1)
}
func WSAPoll(wfds *WSAPOLLFD, count ULONG, timeout int32) int32 {
ret1 := syscall3(wSAPoll, 3,
uintptr(unsafe.Pointer(wfds)),
uintptr(count),
uintptr(timeout))
return int32(ret1)
}
func WSAProviderConfigChange(handle *HANDLE, overlapped LPWSAOVERLAPPED, completion LPWSAOVERLAPPED_COMPLETION_ROUTINE) INT {
completionCallback := syscall.NewCallback(completion)
ret1 := syscall3(wSAProviderConfigChange, 3,
uintptr(unsafe.Pointer(handle)),
uintptr(unsafe.Pointer(overlapped)),
completionCallback)
return INT(ret1)
}
func WSARecv(s SOCKET, lpBuffers LPWSABUF, dwBufferCount DWORD, numberOfBytesReceived *uint32, lpFlags *uint32, lpOverlapped LPWSAOVERLAPPED, lpCompletionRoutine LPWSAOVERLAPPED_COMPLETION_ROUTINE) int32 {
lpCompletionRoutineCallback := syscall.NewCallback(lpCompletionRoutine)
ret1 := syscall9(wSARecv, 7,
uintptr(s),
uintptr(unsafe.Pointer(lpBuffers)),
uintptr(dwBufferCount),
uintptr(unsafe.Pointer(numberOfBytesReceived)),
uintptr(unsafe.Pointer(lpFlags)),
uintptr(unsafe.Pointer(lpOverlapped)),
lpCompletionRoutineCallback,
0,
0)
return int32(ret1)
}
func WSARecvDisconnect(s SOCKET, disconnectdata LPWSABUF) INT {
ret1 := syscall3(wSARecvDisconnect, 2,
uintptr(s),
uintptr(unsafe.Pointer(disconnectdata)),
0)
return INT(ret1)
}
func WSARecvFrom(s SOCKET, lpBuffers LPWSABUF, dwBufferCount DWORD, lpNumberOfBytesRecvd *uint32, lpFlags *uint32, lpFrom *Sockaddr, lpFromlen *int32, lpOverlapped LPWSAOVERLAPPED, lpCompletionRoutine LPWSAOVERLAPPED_COMPLETION_ROUTINE) INT {
lpCompletionRoutineCallback := syscall.NewCallback(lpCompletionRoutine)
ret1 := syscall9(wSARecvFrom, 9,
uintptr(s),
uintptr(unsafe.Pointer(lpBuffers)),
uintptr(dwBufferCount),
uintptr(unsafe.Pointer(lpNumberOfBytesRecvd)),
uintptr(unsafe.Pointer(lpFlags)),
uintptr(unsafe.Pointer(lpFrom)),
uintptr(unsafe.Pointer(lpFromlen)),
uintptr(unsafe.Pointer(lpOverlapped)),
lpCompletionRoutineCallback)
return INT(ret1)
}
func WSARemoveServiceClass(info *GUID) int32 {
ret1 := syscall3(wSARemoveServiceClass, 1,
uintptr(unsafe.Pointer(info)),
0,
0)
return int32(ret1)
}
func WSASend(s SOCKET, lpBuffers LPWSABUF, dwBufferCount DWORD, lpNumberOfBytesSent *uint32, dwFlags DWORD, lpOverlapped LPWSAOVERLAPPED, lpCompletionRoutine LPWSAOVERLAPPED_COMPLETION_ROUTINE) INT {
lpCompletionRoutineCallback := syscall.NewCallback(lpCompletionRoutine)
ret1 := syscall9(wSASend, 7,
uintptr(s),
uintptr(unsafe.Pointer(lpBuffers)),
uintptr(dwBufferCount),
uintptr(unsafe.Pointer(lpNumberOfBytesSent)),
uintptr(dwFlags),
uintptr(unsafe.Pointer(lpOverlapped)),
lpCompletionRoutineCallback,
0,
0)
return INT(ret1)
}
func WSASendDisconnect(s SOCKET, lpBuffers LPWSABUF) INT {
ret1 := syscall3(wSASendDisconnect, 2,
uintptr(s),
uintptr(unsafe.Pointer(lpBuffers)),
0)
return INT(ret1)
}
func WSASendMsg(s SOCKET, msg *WSAMSG, dwFlags DWORD, lpNumberOfBytesSent *uint32, lpOverlapped LPWSAOVERLAPPED, lpCompletionRoutine LPWSAOVERLAPPED_COMPLETION_ROUTINE) int32 {
lpCompletionRoutineCallback := syscall.NewCallback(lpCompletionRoutine)
ret1 := syscall6(wSASendMsg, 6,
uintptr(s),
uintptr(unsafe.Pointer(msg)),
uintptr(dwFlags),
uintptr(unsafe.Pointer(lpNumberOfBytesSent)),
uintptr(unsafe.Pointer(lpOverlapped)),
lpCompletionRoutineCallback)
return int32(ret1)
}
func WSASendTo(s SOCKET, lpBuffers LPWSABUF, dwBufferCount DWORD, lpNumberOfBytesSent *uint32, dwFlags DWORD, to /*const*/ *Sockaddr, tolen int32, lpOverlapped LPWSAOVERLAPPED, lpCompletionRoutine LPWSAOVERLAPPED_COMPLETION_ROUTINE) INT {
lpCompletionRoutineCallback := syscall.NewCallback(lpCompletionRoutine)
ret1 := syscall9(wSASendTo, 9,
uintptr(s),
uintptr(unsafe.Pointer(lpBuffers)),
uintptr(dwBufferCount),
uintptr(unsafe.Pointer(lpNumberOfBytesSent)),
uintptr(dwFlags),
uintptr(unsafe.Pointer(to)),
uintptr(tolen),
uintptr(unsafe.Pointer(lpOverlapped)),
lpCompletionRoutineCallback)
return INT(ret1)
}
func WSASetBlockingHook(lpBlockFunc FARPROC) FARPROC {
lpBlockFuncCallback := syscall.NewCallback(func() uintptr {
ret := lpBlockFunc()
return uintptr(unsafe.Pointer(ret))
})
ret1 := syscall3(wSASetBlockingHook, 1,
lpBlockFuncCallback,
0,
0)
return func() INT_PTR {
ret2 := syscall3(ret1, 0,
0,
0,
0)
return (INT_PTR)(unsafe.Pointer(ret2))
}
}
func WSASetLastError(iError INT) {
syscall3(wSASetLastError, 1,
uintptr(iError),
0,
0)
}
func WSASetService(query LPWSAQUERYSET, operation WSAESETSERVICEOP, flags DWORD) INT {
ret1 := syscall3(wSASetService, 3,
uintptr(unsafe.Pointer(query)),
uintptr(operation),
uintptr(flags))
return INT(ret1)
}
func WSASocket(af int32, aType int32, protocol int32, lpProtocolInfo LPWSAPROTOCOL_INFO, g GROUP, dwFlags DWORD) SOCKET {
ret1 := syscall6(wSASocket, 6,
uintptr(af),
uintptr(aType),
uintptr(protocol),
uintptr(unsafe.Pointer(lpProtocolInfo)),
uintptr(g),
uintptr(dwFlags))
return SOCKET(ret1)
}
func WSAStartup(wVersionRequested WORD, lpWSAData *WSADATA) int32 {
ret1 := syscall3(wSAStartup, 2,
uintptr(wVersionRequested),
uintptr(unsafe.Pointer(lpWSAData)),
0)
return int32(ret1)
}
func WSAStringToAddress(addressString LPWSTR, addressFamily INT, lpProtocolInfo LPWSAPROTOCOL_INFO, lpAddress *SOCKADDR, lpAddressLength *int32) INT {
ret1 := syscall6(wSAStringToAddress, 5,
uintptr(unsafe.Pointer(addressString)),
uintptr(addressFamily),
uintptr(unsafe.Pointer(lpProtocolInfo)),
uintptr(unsafe.Pointer(lpAddress)),
uintptr(unsafe.Pointer(lpAddressLength)),
0)
return INT(ret1)
}
func WSAUnhookBlockingHook() INT {
ret1 := syscall3(wSAUnhookBlockingHook, 0,
0,
0,
0)
return INT(ret1)
}
func WSApSetPostRoutine(lpPostRoutine LPWPUPOSTMESSAGE) INT {
lpPostRoutineCallback := syscall.NewCallback(func(unnamed0RawArg HWND, unnamed1RawArg UINT, unnamed2RawArg WPARAM, unnamed3RawArg LPARAM) uintptr {
ret := lpPostRoutine(unnamed0RawArg, unnamed1RawArg, unnamed2RawArg, unnamed3RawArg)
return uintptr(ret)
})
ret1 := syscall3(wSApSetPostRoutine, 1,
lpPostRoutineCallback,
0,
0)
return INT(ret1)
}
func WSCDeinstallProvider(lpProviderId *GUID, lpErrno *int32) INT {
ret1 := syscall3(wSCDeinstallProvider, 2,
uintptr(unsafe.Pointer(lpProviderId)),
uintptr(unsafe.Pointer(lpErrno)),
0)
return INT(ret1)
}
func WSCEnableNSProvider(provider *GUID, enable bool) INT {
ret1 := syscall3(wSCEnableNSProvider, 2,
uintptr(unsafe.Pointer(provider)),
getUintptrFromBool(enable),
0)
return INT(ret1)
}
func WSCEnumProtocols(protocols *int32, buffer LPWSAPROTOCOL_INFO, aLen *uint32, err *int32) INT {
ret1 := syscall6(wSCEnumProtocols, 4,
uintptr(unsafe.Pointer(protocols)),
uintptr(unsafe.Pointer(buffer)),
uintptr(unsafe.Pointer(aLen)),
uintptr(unsafe.Pointer(err)),
0,
0)
return INT(ret1)
}
func WSCGetProviderPath(provider *GUID, path LPWSTR, aLen *int32, errcode *int32) INT {
ret1 := syscall6(wSCGetProviderPath, 4,
uintptr(unsafe.Pointer(provider)),
uintptr(unsafe.Pointer(path)),
uintptr(unsafe.Pointer(aLen)),
uintptr(unsafe.Pointer(errcode)),
0,
0)
return INT(ret1)
}
func WSCInstallNameSpace(identifier LPWSTR, path LPWSTR, namespace DWORD, version DWORD, provider *GUID) INT {
ret1 := syscall6(wSCInstallNameSpace, 5,
uintptr(unsafe.Pointer(identifier)),
uintptr(unsafe.Pointer(path)),
uintptr(namespace),
uintptr(version),
uintptr(unsafe.Pointer(provider)),
0)
return INT(ret1)
}
func WSCInstallProvider(lpProviderId /*const*/ *GUID, lpszProviderDllPath string, lpProtocolInfoList /*const*/ LPWSAPROTOCOL_INFO, dwNumberOfEntries DWORD, lpErrno *int32) INT {
lpszProviderDllPathStr := unicode16FromString(lpszProviderDllPath)
ret1 := syscall6(wSCInstallProvider, 5,
uintptr(unsafe.Pointer(lpProviderId)),
uintptr(unsafe.Pointer(&lpszProviderDllPathStr[0])),
uintptr(unsafe.Pointer(lpProtocolInfoList)),
uintptr(dwNumberOfEntries),
uintptr(unsafe.Pointer(lpErrno)),
0)
return INT(ret1)
}
func WSCUnInstallNameSpace(lpProviderId *GUID) INT {
ret1 := syscall3(wSCUnInstallNameSpace, 1,
uintptr(unsafe.Pointer(lpProviderId)),
0,
0)
return INT(ret1)
}
func WSCWriteProviderOrder(entry *uint32, number DWORD) INT {
ret1 := syscall3(wSCWriteProviderOrder, 2,
uintptr(unsafe.Pointer(entry)),
uintptr(number),
0)
return INT(ret1)
}
func Gethostname(name *CHAR, namelen INT) int32 {
ret1 := syscall3(gethostname, 2,
uintptr(unsafe.Pointer(name)),
uintptr(namelen),
0)
return int32(ret1)
}

33
main.go Normal file
View File

@@ -0,0 +1,33 @@
package main
import (
"context"
"google.golang.org/grpc"
"net"
"ShotRDP/pb"
)
type Server struct {
pb.UnimplementedGetScreenServer
}
func (server *Server) GetScreen(ctx context.Context, in *pb.Request) (*pb.Response, error) {
imgBytes, err := getScreen(in.GetHost())
return &pb.Response{ImageBytes: imgBytes}, err
}
func main() {
listener, err := net.Listen("tcp", ":8972")
if err != nil {
panic(err)
}
server := grpc.NewServer()
pb.RegisterGetScreenServer(server, &Server{})
err = server.Serve(listener)
if err != nil {
panic(err)
}
}

View File

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 828 KiB

After

Width:  |  Height:  |  Size: 828 KiB

View File

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

177
pb/shotrdp.pb.go Normal file
View File

@@ -0,0 +1,177 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.5
// protoc v6.30.0
// source: shotrdp.proto
package pb
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type Request struct {
state protoimpl.MessageState `protogen:"open.v1"`
Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Request) Reset() {
*x = Request{}
mi := &file_shotrdp_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Request) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Request) ProtoMessage() {}
func (x *Request) ProtoReflect() protoreflect.Message {
mi := &file_shotrdp_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Request.ProtoReflect.Descriptor instead.
func (*Request) Descriptor() ([]byte, []int) {
return file_shotrdp_proto_rawDescGZIP(), []int{0}
}
func (x *Request) GetHost() string {
if x != nil {
return x.Host
}
return ""
}
type Response struct {
state protoimpl.MessageState `protogen:"open.v1"`
ImageBytes []byte `protobuf:"bytes,1,opt,name=image_bytes,json=imageBytes,proto3" json:"image_bytes,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Response) Reset() {
*x = Response{}
mi := &file_shotrdp_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Response) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Response) ProtoMessage() {}
func (x *Response) ProtoReflect() protoreflect.Message {
mi := &file_shotrdp_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Response.ProtoReflect.Descriptor instead.
func (*Response) Descriptor() ([]byte, []int) {
return file_shotrdp_proto_rawDescGZIP(), []int{1}
}
func (x *Response) GetImageBytes() []byte {
if x != nil {
return x.ImageBytes
}
return nil
}
var File_shotrdp_proto protoreflect.FileDescriptor
var file_shotrdp_proto_rawDesc = string([]byte{
0x0a, 0x0d, 0x73, 0x68, 0x6f, 0x74, 0x72, 0x64, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
0x02, 0x70, 0x62, 0x22, 0x1d, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12,
0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f,
0x73, 0x74, 0x22, 0x2b, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f,
0x0a, 0x0b, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0c, 0x52, 0x0a, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x42, 0x79, 0x74, 0x65, 0x73, 0x32,
0x33, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x12, 0x26, 0x0a, 0x09,
0x47, 0x65, 0x74, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x12, 0x0b, 0x2e, 0x70, 0x62, 0x2e, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0c, 0x5a, 0x0a, 0x73, 0x68, 0x6f, 0x74, 0x72, 0x64, 0x70, 0x2f,
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
})
var (
file_shotrdp_proto_rawDescOnce sync.Once
file_shotrdp_proto_rawDescData []byte
)
func file_shotrdp_proto_rawDescGZIP() []byte {
file_shotrdp_proto_rawDescOnce.Do(func() {
file_shotrdp_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_shotrdp_proto_rawDesc), len(file_shotrdp_proto_rawDesc)))
})
return file_shotrdp_proto_rawDescData
}
var file_shotrdp_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_shotrdp_proto_goTypes = []any{
(*Request)(nil), // 0: pb.Request
(*Response)(nil), // 1: pb.Response
}
var file_shotrdp_proto_depIdxs = []int32{
0, // 0: pb.GetScreen.GetScreen:input_type -> pb.Request
1, // 1: pb.GetScreen.GetScreen:output_type -> pb.Response
1, // [1:2] is the sub-list for method output_type
0, // [0:1] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_shotrdp_proto_init() }
func file_shotrdp_proto_init() {
if File_shotrdp_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_shotrdp_proto_rawDesc), len(file_shotrdp_proto_rawDesc)),
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_shotrdp_proto_goTypes,
DependencyIndexes: file_shotrdp_proto_depIdxs,
MessageInfos: file_shotrdp_proto_msgTypes,
}.Build()
File_shotrdp_proto = out.File
file_shotrdp_proto_goTypes = nil
file_shotrdp_proto_depIdxs = nil
}

16
pb/shotrdp.proto Normal file
View File

@@ -0,0 +1,16 @@
syntax = "proto3";
option go_package = "shotrdp/pb";
package pb;
message Request {
string host = 1;
}
message Response {
bytes image_bytes = 1;
}
service GetScreen {
rpc GetScreen (Request) returns (Response);
}

121
pb/shotrdp_grpc.pb.go Normal file
View File

@@ -0,0 +1,121 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v6.30.0
// source: shotrdp.proto
package pb
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
GetScreen_GetScreen_FullMethodName = "/pb.GetScreen/GetScreen"
)
// GetScreenClient is the client API for GetScreen service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type GetScreenClient interface {
GetScreen(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
}
type getScreenClient struct {
cc grpc.ClientConnInterface
}
func NewGetScreenClient(cc grpc.ClientConnInterface) GetScreenClient {
return &getScreenClient{cc}
}
func (c *getScreenClient) GetScreen(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(Response)
err := c.cc.Invoke(ctx, GetScreen_GetScreen_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// GetScreenServer is the server API for GetScreen service.
// All implementations must embed UnimplementedGetScreenServer
// for forward compatibility.
type GetScreenServer interface {
GetScreen(context.Context, *Request) (*Response, error)
mustEmbedUnimplementedGetScreenServer()
}
// UnimplementedGetScreenServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedGetScreenServer struct{}
func (UnimplementedGetScreenServer) GetScreen(context.Context, *Request) (*Response, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetScreen not implemented")
}
func (UnimplementedGetScreenServer) mustEmbedUnimplementedGetScreenServer() {}
func (UnimplementedGetScreenServer) testEmbeddedByValue() {}
// UnsafeGetScreenServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to GetScreenServer will
// result in compilation errors.
type UnsafeGetScreenServer interface {
mustEmbedUnimplementedGetScreenServer()
}
func RegisterGetScreenServer(s grpc.ServiceRegistrar, srv GetScreenServer) {
// If the following call pancis, it indicates UnimplementedGetScreenServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&GetScreen_ServiceDesc, srv)
}
func _GetScreen_GetScreen_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Request)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GetScreenServer).GetScreen(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: GetScreen_GetScreen_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GetScreenServer).GetScreen(ctx, req.(*Request))
}
return interceptor(ctx, in, info, handler)
}
// GetScreen_ServiceDesc is the grpc.ServiceDesc for GetScreen service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var GetScreen_ServiceDesc = grpc.ServiceDesc{
ServiceName: "pb.GetScreen",
HandlerType: (*GetScreenServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetScreen",
Handler: _GetScreen_GetScreen_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "shotrdp.proto",
}

18
rdp.go
View File

@@ -1,18 +0,0 @@
package main
import (
"ShotRDP/grdp/glog"
)
/*
修改部分grdp/protocol/x224/x224.go#New()
去除requestedProtocol中的PROTOCOL_HYBRID避免使用NLA
*/
func DoRDP(host string) {
client := NewClient(host, glog.INFO)
err := client.Login("", "", "")
if err != nil {
panic(err)
}
}

View File

@@ -1,14 +1,6 @@
package main
import (
"context"
"log"
"net"
"os"
"strings"
"sync"
"time"
"ShotRDP/common"
"ShotRDP/grdp/core"
"ShotRDP/grdp/glog"
@@ -19,9 +11,16 @@ import (
"ShotRDP/grdp/protocol/t125"
"ShotRDP/grdp/protocol/tpkt"
"ShotRDP/grdp/protocol/x224"
"context"
"log"
"net"
"os"
"strings"
"sync"
"time"
)
type Client struct {
type RdpClient struct {
Host string // 服务地址(ip:port)
tpkt *tpkt.TPKT // TPKT协议层
x224 *x224.X224 // X224协议层
@@ -44,20 +43,19 @@ var (
positionMap = make(map[Position]*common.Bitmap)
)
func NewClient(host string, logLevel glog.LEVEL) *Client {
func Newclient(host string, logLevel glog.LEVEL) *RdpClient {
_logger := log.New(os.Stdout, "", 0)
glog.SetLogger(_logger)
glog.SetLevel(logLevel)
return &Client{Host: host}
return &RdpClient{Host: host}
}
func (client *Client) Login(domain, username, password string) error {
conn, err := net.Dial("tcp", client.Host)
func (client *RdpClient) Login(domain, username, password string) ([]byte, error) {
conn, err := net.DialTimeout("tcp", client.Host, 3*time.Second)
if err != nil {
glog.Errorf("TCP连接失败%v", err)
return err
return nil, err
}
// 初始化协议栈
@@ -66,22 +64,45 @@ func (client *Client) Login(domain, username, password string) error {
// 建立X224连接
err = client.x224.Connect()
if err != nil {
glog.Errorf("建立X224连接失败%v", err)
return err
return nil, err
}
// 设置事件处理
client.setEventHandler()
// 合并登录界面位图
wg := &sync.WaitGroup{}
wg.Add(1)
// 设置事件处理
client.setEventHandler(wg)
var buff []byte
surfaceflingerCtx, _ := context.WithCancel(context.Background())
go func(ctx context.Context, c *RdpClient) {
outputName := strings.ReplaceAll(client.Host, ":", "_")
//for common.Opened(ctx) {}
// TODO: 寻找合适的截图时机
time.Sleep(5 * time.Second)
modifyMux.Lock()
var bitmapList = make([]*common.Bitmap, 0)
for _, bitmap := range positionMap {
//common.DrawOneBitmap(bitmap, fmt.Sprintf("%d-%d-%d-%d.png", pos.Left, pos.Top, pos.Right, pos.Bottom))
bitmapList = append(bitmapList, bitmap)
}
buff = common.DrawFullImage(outputName, bitmapList)
modifyMux.Unlock()
wg.Done()
}(surfaceflingerCtx, client)
wg.Wait()
return nil
return buff, nil
}
// initProtocolStack 初始化RDP协议栈
func (client *Client) initProtocolStack(conn net.Conn, domain, username, password string) {
func (client *RdpClient) initProtocolStack(conn net.Conn, domain, username, password string) {
// 创建协议层实例
client.tpkt = tpkt.New(core.NewSocketLayer(conn), nla.NewNTLMv2(domain, username, password))
client.x224 = x224.New(client.tpkt)
@@ -106,29 +127,24 @@ func (client *Client) initProtocolStack(conn net.Conn, domain, username, passwor
}
// setEventHandler 设置PDU事件处理器
func (client *Client) setEventHandler(wg *sync.WaitGroup) {
func (client *RdpClient) setEventHandler() {
client.pdu.On("ready", func() {
glog.Info("PDU连接就绪")
// Test
//glog.Infof("服务端核心信息: %+v", *client.sec.ServerCoreData())
//glog.Infof("服务端安全信息: %+v", *client.sec.ServerSecurityData())
})
client.pdu.On("success", func() {
glog.Info("PDU连接成功")
})
client.pdu.On("close", func() {
glog.Info("PDU连接关闭")
})
client.pdu.On("done", func() {
glog.Info("PDU处理完成")
})
client.pdu.On("error", func(err error) {
glog.Errorf("PDU错误事件%v", err)
client.pdu.Emit("done")
})
@@ -158,27 +174,14 @@ func (client *Client) setEventHandler(wg *sync.WaitGroup) {
}
modifyMux.Unlock()
})
// 合并登录界面位图
surfaceflingerCtx, _ := context.WithCancel(context.Background())
go func(ctx context.Context, c *Client) {
outputName := strings.ReplaceAll(client.Host, ":", "_")
for common.Opened(ctx) {
// TODO: 寻找合适的截图时机
time.Sleep(5 * time.Second)
modifyMux.Lock()
var bitmapList = make([]*common.Bitmap, 0)
for _, bitmap := range positionMap {
//common.DrawOneBitmap(bitmap, fmt.Sprintf("%d-%d-%d-%d.png", pos.Left, pos.Top, pos.Right, pos.Bottom))
bitmapList = append(bitmapList, bitmap)
}
common.DrawFullImage(outputName, bitmapList)
modifyMux.Unlock()
wg.Done()
}
}(surfaceflingerCtx, client)
}
/*
修改部分grdp/protocol/x224/x224.go#New()
去除requestedProtocol中的PROTOCOL_HYBRID避免使用NLA
*/
func getScreen(host string) ([]byte, error) {
client := Newclient(host, glog.INFO)
return client.Login("", "", "")
}

22
rdpClient_test.go Normal file
View File

@@ -0,0 +1,22 @@
package main
import (
"testing"
)
func TestGetScreen(t *testing.T) {
/* 测试成功版本:
Windows Server 2008 ✔
Windows Server 2012 ✔
Windows Server 2016 ✔
Windows 7 ✔
Windows 10 ✔
*/
imgBytes, err := getScreen("192.168.250.128:3389")
if err != nil {
t.Fatal(err)
}
t.Logf("Length of imgBytes: %v", len(imgBytes))
}

View File

@@ -1,21 +0,0 @@
package main
import (
"testing"
)
func TestDoRDP(t *testing.T) {
/* 测试成功版本:
Windows Server 2008 ✔
Windows Server 2012 ✔
Windows Server 2016 ✔
Windows 7 ✔
Windows 10 ✔
*/
//DoRDP("192.168.251.128:3389")
//DoRDP("192.168.251.129:3389")
//DoRDP("192.168.251.130:3389")
//DoRDP("192.168.251.131:3389")
//DoRDP("192.168.251.132:3389")
}