Skip to content

Commit

Permalink
updates and better AV handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Razviar committed Feb 16, 2022
1 parent 50ed285 commit 98c56bb
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 6 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mtgaprotracker",
"productName": "mtgaprotracker",
"version": "2.2.14",
"version": "2.2.15",
"description": "MTG Arena Pro Tracker",
"main": "./.webpack/main",
"scripts": {
Expand Down
10 changes: 10 additions & 0 deletions src/app/game_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const TWO_SECONDS = 2000;
class GameState {
private readonly startTimeMillis: number;
private running: boolean;
private AVBlocked: boolean;
private overlayInterval: NodeJS.Timeout | undefined;
private psListInterval: NodeJS.Timeout | undefined;
private processId: number | undefined;
Expand All @@ -36,6 +37,7 @@ class GameState {
constructor() {
this.startTimeMillis = Date.now();
this.running = false;
this.AVBlocked = false;
this.checkProcessId();
}

Expand All @@ -52,6 +54,14 @@ class GameState {
return this.startTimeMillis;
}

public setAVBlocked() {
this.AVBlocked = true;
}

public getAVBlocked() {
return this.AVBlocked;
}

public setRunning(running: boolean): void {
//console.log('setRunning', running, this.running, this.badErrorHappening);
if (!this.running && running) {
Expand Down
19 changes: 18 additions & 1 deletion src/app/locatewindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {ChildProcessWithoutNullStreams} from 'child_process';
import {screen} from 'electron';

import {gameState} from 'root/app/game_state';
import {sendMessageToOverlayWindow} from 'root/app/messages';
import {sendMessageToHomeWindow, sendMessageToOverlayWindow} from 'root/app/messages';
import {AccountV8} from 'root/app/settings-store/v9';
import {isMac} from 'root/lib/utils';
import ourActiveWin from 'root/our-active-win';
Expand Down Expand Up @@ -72,7 +72,24 @@ export class WindowLocator {
raw.split('\n').map((line: string) => {
if (line.indexOf('{') !== -1 && line.indexOf('}') !== -1) {
const process = JSON.parse(line) as ourActiveWin.Result;
if (process.cantDoInjection) {
sendMessageToOverlayWindow('cant-inject', undefined);
sendMessageToHomeWindow('show-status', {
message: 'SharpMonoInjector.dll is blocked by AV!',
color: '#cc2d2d',
});
gameState.setAVBlocked();
}
this.handleProcessRead(process);
} else {
if (line == 'ERROR') {
gameState.setAVBlocked();
sendMessageToOverlayWindow('cant-inject', undefined);
sendMessageToHomeWindow('show-status', {
message: 'SharpMonoInjector.dll is blocked by AV!',
color: '#cc2d2d',
});
}
}
});
} catch (error) {
Expand Down
4 changes: 4 additions & 0 deletions src/app/log-parser/log_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ export class LogParser {
throw new Error('No log file found');
}

if (gameState.getAVBlocked()) {
throw new Error('SharpMonoInjector.dll is blocked by AV!');
}

// Fetching fileId
//const [fileId] = await getFileId(path, {bytesRead: 0}, parsingMetadata);
const fileId = LogFromMTGAFolder.fileId;
Expand Down
1 change: 1 addition & 0 deletions src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export interface Messages {
'screen-recording-authorized': boolean;
'enable-screen-recording': undefined;
'need-to-restart-mtga': boolean;
'cant-inject': undefined;
}

export enum NetworkStatusMessage {
Expand Down
Binary file modified src/our-active-win/getFrontWindow.exe
Binary file not shown.
Binary file added src/our-active-win/getFrontWindow.pdb
Binary file not shown.
1 change: 1 addition & 0 deletions src/our-active-win/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ declare namespace ourActiveWin {
*/
owner: BaseOwner;
admin: boolean;
cantDoInjection: boolean;
}

interface MacOSOwner extends BaseOwner {
Expand Down
6 changes: 6 additions & 0 deletions src/windows/overlay/functions/messages_ipcmain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,12 @@ export function SetMessages(setInteractiveHandler: (overlaySettings: OverlaySett
}
}
});
onMessageFromIpcMain('cant-inject', (state) => {
if (overlayElements.AVWarning.classList.contains('hidden')) {
overlayElements.AVWarning.classList.remove('hidden');
}
});

onMessageFromIpcMain('restart-mtga', () => {
sendMessageToIpcMain('restart-mtga-now', undefined);
});
Expand Down
3 changes: 2 additions & 1 deletion src/windows/overlay/overlay.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ a[href^="ftp://"]
padding-bottom: 5px;
}

#RestartWarning {
#RestartWarning,
#AVWarning {
position: absolute;
bottom: 51px;
left: 50%;
Expand Down
4 changes: 4 additions & 0 deletions src/windows/overlay/overlay.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
<strong>MTGA is running with higher than Tracker system permissions.</strong><br />Most likely it was an update
or you've launched MTGA as Admin<br />Please restart the game (Alt+R) to keep using the Tracker.
</div>
<div id="AVWarning" class="hidden">
<strong>Your antivirus is blocking SharpMonoInjector.dll</strong><br />Tracker will be impaired<br />Please add
SharpMonoInjector.dll to exceptions list.
</div>
</div>
</body>
</html>
1 change: 1 addition & 0 deletions src/windows/overlay/overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const overlayElements = {
oppTimer: document.getElementById('oppTimer') as HTMLElement,
OverlayMenu: document.getElementById('OverlayMenu') as HTMLElement,
RestartWarning: document.getElementById('RestartWarning') as HTMLElement,
AVWarning: document.getElementById('AVWarning') as HTMLElement,
};

const Interactive = document.getElementsByClassName('Interactive');
Expand Down

0 comments on commit 98c56bb

Please sign in to comment.