github.com/racerxdl/gonx@v0.0.0-20210103083128-c5afc43bcbd2/services/am/iwc.go (about) 1 package am 2 3 import ( 4 "encoding/binary" 5 "github.com/racerxdl/gonx/nx/nxerrors" 6 "github.com/racerxdl/gonx/nx/nxtypes" 7 "github.com/racerxdl/gonx/services/ipc" 8 ) 9 10 func IwcGetAppletResourceUserId() (nxtypes.ARUID, error) { 11 if amInitializations <= 0 { 12 return 0, nxerrors.AMNotInitialized 13 } 14 15 rq := ipc.MakeDefaultRequest(1) 16 rs := ipc.ResponseFmt{} 17 rs.RawData = make([]byte, 8) // one uint64 18 19 err := ipc.Send(iWindowController, &rq, &rs) 20 if err != nil { 21 return 0, err 22 } 23 24 return nxtypes.ARUID(binary.LittleEndian.Uint64(rs.RawData)), nil 25 } 26 27 func IwcAcquireForegroundRights() error { 28 if amInitializations <= 0 { 29 return nxerrors.AMNotInitialized 30 } 31 32 rq := ipc.MakeDefaultRequest(10) 33 rs := ipc.ResponseFmt{} 34 35 return ipc.Send(iWindowController, &rq, &rs) 36 }