Skip to content

Commit a8f80ce

Browse files
committed
feat: improve game window hook
1 parent 2b9895d commit a8f80ce

File tree

3 files changed

+56
-40
lines changed

3 files changed

+56
-40
lines changed

apps/app/resources/detect-game.js

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,48 @@
1-
const {getProcessInfo} = require('windows-tlist')
1+
const { getProcessInfo } = require('windows-tlist')
22
const wqlImport = import('wql-process-monitor')
33

4+
45
function send(...args) {
5-
process.send(...args)
6+
process.send(...args)
67
}
78

89
wqlImport.then((wql) => {
9-
const {subscribe} = wql
10-
return subscribe({
11-
creation: true,
12-
deletion: false,
13-
bin: {
14-
filter: ['cmd.exe', 'tlist.exe', 'conhost.exe'],
15-
},
16-
})
10+
const { subscribe } = wql
11+
return subscribe({
12+
creation: true,
13+
deletion: false,
14+
bin: {
15+
filter: ['cmd.exe', 'tlist.exe', 'conhost.exe'],
16+
},
17+
})
1718
})
18-
.then((processMonitor) => {
19+
.then((processMonitor) => {
1920

20-
processMonitor.on('creation', ([process, pid, filepath, user]) => {
21+
processMonitor.on('creation', ([process, pid, filepath, user]) => {
2122

22-
console.log(`[game-detection]: process creation - ${process}::${pid}(${user}) ["${filepath}"]`)
23-
// getProcessInfo(pid)
24-
// .then(processInfo => {
25-
const isGame = [
26-
// processInfo.modules.find(module => module.path.includes('d3d')),
27-
// processInfo.modules.find(module => module.path.includes('dxgi')),
28-
// processInfo.modules.find(module => module.path.includes('steamapps')),
29-
filepath.includes('steamapps'),
30-
filepath.includes('demo.exe'),
31-
].some(Boolean)
32-
if (isGame) {
33-
console.log('[game-detection]: Game launched', filepath)
34-
send({
35-
type: 'game-detection',
36-
payload: {
37-
process, pid, filepath, user,
38-
},
39-
})
40-
}
41-
// })
23+
console.log(`[game-detection]: process creation - ${process}::${pid}(${user}) ["${filepath}"]`)
24+
// getProcessInfo(pid)
25+
// .then(processInfo => {
26+
const isGame = [
27+
// processInfo.modules.find(module => module.path.includes('d3d')),
28+
// processInfo.modules.find(module => module.path.includes('dxgi')),
29+
// processInfo.modules.find(module => module.path.includes('steamapps')),
30+
filepath.includes('steamapps'),
31+
filepath.includes('demo.exe'),
32+
].some(Boolean)
33+
if (isGame) {
34+
console.log('[game-detection]: Game launched', filepath)
35+
send({
36+
type: 'game-detection',
37+
payload: {
38+
process, pid, filepath, user,
39+
},
4240
})
41+
// getProcessInfo(pid).then(console.log)
42+
}
43+
// })
4344
})
45+
})
4446

4547
setInterval(() => {
4648
}, 1000 * 60 * 60)

0 commit comments

Comments
 (0)