wineshm

package module
v0.0.0-...-4d7fa7c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2015 License: BSD-3-Clause Imports: 9 Imported by: 0

README

Wine Shm grabber in go

This package retrieves a Wine shared memory map file descriptor and makes it available in Linux.

Installation

Because of the dependency on C / compiled binary files the best way is to copy this repo and include it in your own project.

Example

// Get wine file descriptor
shmfd, err := GetWineShm("Local\\IRSDKMemMapFileName", FILE_MAP_READ)
if err != nil {
  log.Fatal(err)
}

// Turn file descriptor into os.File
file := os.NewFile(shmfd, "Local\\IRSDKMemMapFileName")

How it works

Go launches a windows binary through wine and passes a unix socket to the new wine process (shmwrapper1) by attaching the socket to the subprocess' stdout.

The wine process then opens the shared memory map and sets the file handle as it's stdin. Wine then launches a new linux process (shmwrapper2) which inherits the stdin & stdout from the parent process (shmwrapper1).

So now shmwrapper2 is a native Linux process with a unix socket as stdout and the windows shared memory map handle as it's stdin. It then uses a unix feature to send a file descriptor (stdin) over a unix socket (stdout) to the original go process initiating the wine process.

Thanks

Very special thanks to jspenguin for creating the c code and thinking of a way to share file descriptors between Linux and Wine.

Documentation

Index

Constants

View Source
const (
	TMP_PREFIX     = "wineshm-go"
	FILE_MAP_READ  = "r"
	FILE_MAP_WRITE = "w"
	SOCKET_TIMEOUT = 5 * time.Second
)

Variables

View Source
var (
	WineCmd = []string{"wine"}

	ErrSockTimeout        = errors.New("Timeout reading from unix socket")
	ErrUnexpectedConnType = errors.New("unexpected FileConn type; expected UnixConn")
	ErrTooManyMessages    = errors.New("expected 1 SocketControlMessage")
)

Functions

func GetWineShm

func GetWineShm(shmname string, mode string) (uintptr, error)

Types

This section is empty.

Directories

Path Synopsis
bin

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL