Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't use the lib #18

Open
3l0w opened this issue Jun 24, 2019 · 10 comments
Open

I can't use the lib #18

3l0w opened this issue Jun 24, 2019 · 10 comments

Comments

@3l0w
Copy link

3l0w commented Jun 24, 2019

I try to start to inject to csgo but nothing happens
index.js:

const { app, BrowserWindow } = require('electron')
const path = require('path')
const url = require('url')
const IOverlay = require("electron-overlay")
const IOVhook = require("node-ovhook")
const fs = require("fs")
let screen

app.disableHardwareAcceleration()
IOverlay.start()
IOverlay.setHotkeys([{
  name: "overlay.toggle",
  keyCode: 65,
  modifiers: { ctrl: true }
}])
IOverlay.setEventCallback((event, payload) => {
  if (event === "game.input") {
    const window = BrowserWindow.fromId(payload.windowId)
    if (window) {
      const intpuEvent = IOverlay.translateInputEvent(payload)
      if (payload.msg !== 512) {
        console.log(event, payload)
        console.log(`translate ${JSON.stringify(intpuEvent)}`)
      }

      if (intpuEvent) {
        window.webContents.sendInputEvent(intpuEvent)
      }
      const focusWin = BrowserWindow.fromId(payload.focusWindowId)
      if (focusWin) {
        focusWin.focusOnWebView()
      }
    }
  }
})

// Wait until the app is ready
app.once('ready', () => {
  screen = require("electron").screen
  let windowOverlay = new BrowserWindow({
    transparent: true,
    frame: false,
    show: false,
    webPreferences: {
      nodeIntegration: true,
      offscreen: true,
    },
    title: "Overlay"
  })
  addOverlayWindows("Overlay", windowOverlay, 0, 0, true)

  windowOverlay.webContents.on("paint", (event, dirty, image) => {
    IOverlay.sendFrameBuffer(
      windowOverlay.id,
      image.getBitmap(),
      image.getSize().width,
      image.getSize().height
    )
  })

  windowOverlay.on("resize", () => {
    IOverlay.sendWindowBounds(window.id, { rect: window.getBounds() })
  })

  fs.writeFileSync("process.json", JSON.stringify(IOVhook.getTopWindows(true)))

  let process
  for (let i = 0; i < IOVhook.getTopWindows(true).length; i++) {
    const element = IOVhook.getTopWindows(true)[i];
    if (element.title === "Counter-Strike: Global Offensive") {
      process = element
    }
  }
  console.log("process: " + JSON.stringify(process))
  if (process) {
    console.log("inject:" + IOVhook.injectProcess(process))
  }

  windowOverlay.loadURL(url.format({
    pathname: path.join(__dirname, 'overlay.html'),
    protocol: 'file:',
    slashes: true
  }))

  let window = null

})
function addOverlayWindows(name, window, dragborder = 0, captionHeight = 0, transparent = false) {
  const display = screen.getDisplayNearestPoint(
    screen.getCursorScreenPoint()
  )

  IOverlay.addWindow(window.id, {
    name,
    transparent,
    resizable: window.isResizable(),
    maxWidth: window.isResizable
      ? display.bounds.width
      : window.getBounds().width,
    maxHeight: window.isResizable
      ? display.bounds.height
      : window.getBounds().height,
    minWidth: window.isResizable ? 100 : window.getBounds().width,
    minHeight: window.isResizable ? 100 : window.getBounds().height,
    nativeHandle: window.getNativeWindowHandle().readUInt32LE(0),
    rect: window.getBounds(),
    caption: {
      left: dragborder,
      right: dragborder,
      top: dragborder,
      height: captionHeight
    },
    dragBorderWidth: dragborder
  })

}

overlay.html:

<h1>hello</h1>

logs :

PS H:\loloverlay\gelectron\test> npm start

> [email protected] start H:\loloverlay\gelectron\test
> electron .


 OverlayMain::addWindow
create share mem:1680,1050
process: {"windowId":1838298,"processId":13876,"threadId":15440,"title":"Counter-Strike: Global Offensive"}
inject:false

@hiitiger
Copy link
Owner

Are you using 32bit or 64bit nodejs?

@3l0w
Copy link
Author

3l0w commented Jun 25, 2019

C:\Users\gwilh>node -p "process"
process {
  version: 'v12.4.0',
  versions: {
    node: '12.4.0',
    v8: '7.4.288.27-node.18',
    uv: '1.29.1',
    zlib: '1.2.11',
    brotli: '1.0.7',
    ares: '1.15.0',
    modules: '72',
    nghttp2: '1.38.0',
    napi: '4',
    llhttp: '1.1.3',
    http_parser: '2.8.0',
    openssl: '1.1.1b',
    cldr: '35.1',
    icu: '64.2',
    tz: '2019a',
    unicode: '12.1'
  },
  arch: 'x64',
  platform: 'win32',

I use 64bit nodejs

@hiitiger
Copy link
Owner

hiitiger commented Jun 25, 2019

I think you need to use 32bit node , csgo is a 32bit game.

@3l0w
Copy link
Author

3l0w commented Jun 25, 2019

ok i will test that

@3l0w
Copy link
Author

3l0w commented Jun 25, 2019

I can't install electron-overlay:

PS H:\loloverlay\gelectron\test> ../../node/npm install ..\electron-overlay\
npm WARN lifecycle The node binary used for scripts is C:\Program Files\nodejs\node.exe but npm is using H:\loloverlay\node\node.exe itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> [email protected] install H:\loloverlay\gelectron\test\node_modules\electron-overlay
> node-gyp rebuild


H:\loloverlay\gelectron\test\node_modules\electron-overlay>if not defined npm_config_node_gyp (node "H:\loloverlay\node\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "H:\loloverlay\node\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Users\gwilh\AppData\Local\Programs\Python\Python37\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:290:12)
gyp ERR! stack     at ChildProcess.emit (events.js:200:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "H:\\loloverlay\\node\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd H:\loloverlay\gelectron\test\node_modules\electron-overlay
gyp ERR! node -v v12.4.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\gwilh\AppData\Roaming\npm-cache\_logs\2019-06-25T12_24_18_295Z-debug.log

2019-06-25T12_24_18_295Z-debug.log

EDIT: I fix that by set: npm config set python "C:\Python27\python.exe"

@3l0w
Copy link
Author

3l0w commented Jun 25, 2019

I have test with 32-but version of nodejs but that doesn't work too
where are n_overlay.dll?
tell me how i can debug your lib

@hiitiger
Copy link
Owner

n_overlay.dll is the dll that will be injected to game process. you need to build gameoverlay.sln

I think the problem is n_ovhelper.exe and n_overlay.dll is built under game-overlay's sub directory so node-ovhook can not find it, I need to add more document about it and improve some API and log for debug .

@hiitiger
Copy link
Owner

If you have successfully build gameoverlay.sln
try copy n_overlay.dll + n_ovhelper.exe into ...\node-ovhook\build\Release

@3l0w
Copy link
Author

3l0w commented Jun 26, 2019

I got a new error with n_overlay.dll n_ovhelper.exe placed in node-ovhook\build\Release

erreur1
erreur2

H:\loloverlay\gelectron\test>electron .

OverlayMain::addWindow
create share mem:1680,1050
process: {"windowId":1510540,"processId":16720,"threadId":18588,"title":"Counter-Strike: Global Offensive"}
inject:true
hook pid: 16720, thread:18588
OverlayConnector::start
OverlayConnector::saveClientIdOverlayMain::onClientConnect,8092
HookApp::findGameWindow, injectWindow: 00000000
HookApp::findGameWindow, graphicsWindow: 00000000

OverlayConnector::onLinkConnectOverlayMain::_sendOverlayInit{"directMessageInput":false,"dragMode":1,"fpsPosition":1,"hotkeys":[{"alt":false,"ctrl":true,"keyCode":65,"name":"overlay.toggle","passthrough":false,"shift":false}],"processEnabled":true,"shareMemMutex":"electron-overlay-sharemem-{4C4BD948-0F75-413F-9667-AC64A7944D8E}6084-315156984","showfps":false,"type":"overlay.init","windows":[{"bufferName":"electron-overlay-6084-315157093-1-image-1","caption":{"height":0,"left":0,"right":0,"top":0},"dragBorderWidth":0,"maxHeight":1050,"maxWidth":1680,"minHeight":100,"minWidth":100,"name":"Overlay","nativeHandle":3082880,"rect":{"height":600,"width":800,"x":440,"y":225},"resizable":true,"transparent":true,"type":"window","windowId":1}]}

HookApp::startHook
OverlayConnector::_updateFrameBufferwindow: 1, width:800, height:600
PostThreadMessage to hook windowOverlayMain::onClientConnect,16720
OverlayMain::_sendOverlayInit{"directMessageInput":false,"dragMode":1,"fpsPosition":1,"hotkeys":[{"alt":false,"ctrl":true,"keyCode":65,"name":"overlay.toggle","passthrough":false,"shift":false}],"processEnabled":true,"shareMemMutex":"electron-overlay-sharemem-{4C4BD948-0F75-413F-9667-AC64A7944D8E}6084-315156984","showfps":false,"type":"overlay.init","windows":[{"bufferName":"electron-overlay-6084-315157093-1-image-1","caption":{"height":0,"left":0,"right":0,"top":0},"dragBorderWidth":0,"maxHeight":1050,"maxWidth":1680,"minHeight":100,"minWidth":100,"name":"Overlay","nativeHandle":3082880,"rect":{"height":600,"width":800,"x":440,"y":225},"resizable":true,"transparent":true,"type":"window","windowId":1}]}
PostThreadMessage to hook windowPostThreadMessage to hook windowPostThreadMessage to hook windowPostThreadMessage to hook windowPostThreadMessage to hook windowPostThreadMessage to hook windowPostThreadMessage to hook windowPostThreadMessage to hook windowPostThreadMessage to hook windowPostThreadMessage to hook windowPostThreadMessage to hook windowPostThreadMessage to hook windowPostThreadMessage to hook windowPostThreadMessage to hook windowPostThreadMessage to hook windowPostThreadMessage to hook windowPostThreadMessage to hook windowPostThreadMessage to hook windowPostThreadMessage to hook windowsafeInject, pid:16720, result:1*** Leaked objects detected: 1 instance(s) of class WrapTask
OverlayMain::onClientClose,8092

@3l0w
Copy link
Author

3l0w commented Jun 26, 2019

The overlay don't show
I think i have the same problem of #13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants