-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
119 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
shmwrapper1.exe | ||
shmwrapper2.bin | ||
assets/* | ||
!assets/.gitkeep | ||
bindata.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
all: shmwrapper1.exe shmwrapper2.bin | ||
all: assets/shmwrapper1.exe assets/shmwrapper2.bin bindata.go | ||
|
||
CC=gcc | ||
WINECC=i686-w64-mingw32-gcc | ||
CFLAGS=-Wall -Os -g | ||
|
||
shmwrapper2.bin: shmwrapper2.c | ||
assets/shmwrapper2.bin: shmwrapper2.c | ||
$(CC) $< $(CFLAGS) -o $@ | ||
|
||
shmwrapper1.exe: shmwrapper1.c | ||
assets/shmwrapper1.exe: shmwrapper1.c | ||
$(WINECC) $< $(CFLAGS) -mconsole -o $@ | ||
|
||
bindata.go: assets/shmwrapper1.exe assets/shmwrapper2.bin | ||
go-bindata -pkg=wineshm -ignore=.gitkeep assets/ | ||
|
||
clean: | ||
rm -f shmwrapper1.exe shmwrapper2.bin | ||
rm -f assets/shmwrapper1.exe assets/shmwrapper2.bin bindata.go | ||
|
||
# vim: syntax=make ts=4 sw=4 sts=4 sr noet |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"unsafe" | ||
|
||
mmap "github.com/edsrzf/mmap-go" | ||
wineshm "github.com/leonb/wineshm-go" | ||
) | ||
|
||
type StatusField int32 | ||
|
||
const ( | ||
MAX_BUFS = 4 | ||
) | ||
|
||
type Header struct { | ||
Ver int32 // api version 1 for now | ||
Status StatusField // bitfield using StatusField | ||
TickRate int32 // ticks per second (60 or 360 etc) | ||
|
||
// session information, updated periodicaly | ||
SessionInfoUpdate int32 // Incremented when session info changes | ||
SessionInfoLen int32 // Length in bytes of session info string | ||
SessionInfoOffset int32 // Session info, encoded in YAML format | ||
|
||
// State data, output at tickRate | ||
NumVars int32 // length of array pointed to by varHeaderOffset | ||
VarHeaderOffset int32 // offset to VarHeader[numVars] array, Describes the variables recieved in varBuf | ||
|
||
NumBuf int32 // <= MAX_BUFS (3 for now) | ||
BufLen int32 // length in bytes for one line | ||
Pad1 [2]int32 // (16 byte align) | ||
VarBuf [MAX_BUFS]VarBuf | ||
} | ||
|
||
type VarBuf struct { | ||
TickCount int32 // used to detect changes in data | ||
BufOffset int32 // offset from header | ||
Pad [2]int32 // (16 byte align) | ||
} | ||
|
||
func main() { | ||
// Get wine file descriptor | ||
wineshm.WineCmd = []string{"/opt/iracing/bin/wine", "--bottle", "default"} | ||
shmfd, err := wineshm.GetWineShm("Local\\IRSDKMemMapFileName", wineshm.FILE_MAP_READ) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// Turn file descriptor into os.File | ||
file := os.NewFile(shmfd, "Local\\IRSDKMemMapFileName") | ||
|
||
mmap, err := mmap.Map(file, mmap.RDONLY, 0) | ||
if err != nil { | ||
log.Fatalf("error mapping: %s", err) | ||
} | ||
|
||
fmt.Println(len(mmap)) | ||
header := (*Header)(unsafe.Pointer(&mmap)) | ||
fmt.Printf("%+v", header) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters