:fixer_menu 

@ECHO OFF
net session >nul 2>&1



Title Fixer 
rem Define variables 
set "ruleName=hola" 
set "softwareName=AndroidEmulatorEn" 
set "executablePath=" 
set "lastStatus=" 

rem Check for GameLoop installation path in the registry
FOR /F "usebackq tokens=2*" %%I IN (reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Tencent\MobileGamePC\UI" /v InstallPath) DO (
    SET "InstallPath=%%J"
)

rem Set the executable path directly
set "executablePath=%InstallPath%\AndroidEmulatorEn.exe"

:check_firewall 
rem Check if the firewall is enabled 
netsh advfirewall show allprofiles state | find "State" | find "ON" >nul 
if %errorlevel% neq 0 (
    cls 
    echo Windows Firewall is disabled. Please enable the firewall to use this fixer. 
    pause 
    goto fixer_menu 
)


:display_menu 
cls 
echo.............................................................................................................
echo BGMI FIXER
echo.............................................................................................................
echo. 

call :check_rule_status
call :display_status 
echo.
echo Select an option:
echo 1. Start Fixer [ALT + F]
echo 2. Stop Fixer [ALT + G]
echo 3. No match found fix [ALT + H]
echo 4. Ignore this option 
echo 5. Go back to main menu

:wait_for_input
rem Wait for user input or check status every second 
choice /C 12345 /N /T 1 /D 4 >nul
if errorlevel 5 (
    goto menu 
)
if errorlevel 4 (
    call :check_rule_status
    if "!currentStatus!" neq "!lastStatus!" (
        goto display_menu
    )
    goto wait_for_input
)
if errorlevel 3 (
    call :no_match_fix 
    goto display_menu
)
if errorlevel 2 (
    call :stop_fixer 
    goto display_menu
)
if errorlevel 1 (
    call :start_fixer 
    goto display_menu
)
goto wait_for_input

:check_rule_status
netsh advfirewall firewall show rule name="%ruleName%" >nul 2>&1 
if %errorlevel% equ 0 (
    set "currentStatus=on" 
) else (
    set "currentStatus=off" 
)
exit /b

:display_status
rem Set color and display current status
if "%currentStatus%"=="on" (
    color 2F 
    echo Current Status : Fixer on 
) else (
    color 4F 
    echo Current Status : Fixer off 
)
set "lastStatus=%currentStatus%"
exit /b

:start_fixer
echo Starting Fixer..
netsh advfirewall firewall add rule name="%ruleName%" protocol=TCP remoteport=80-17500 dir=out action=block program="%executablePath%"
powershell -c "[console]::beep(1500,500)" >nul 2>&1 
powershell -c "[console]::beep(1500,500)" >nul 2>&1 
exit /b

:stop_fixer
echo Stopping Fixer.... 
netsh advfirewall firewall delete rule name="%ruleName%" >nul 2>&1 
powershell -c "[console]::beep(500,1000)" >nul 2>&1 
exit /b

:no_match_fix
echo Fixing...
rem Allow outgoing TCP traffic on specific ports and block other outgoing traffic for the application in one go
netsh advfirewall firewall add rule name="allow_block_tcp" protocol=TCP dir=out action=allow remoteport=17500,8080,443 program="%executablePath%"
netsh advfirewall firewall add rule name="block_tcp" protocol=TCP dir=out action=block program="%executablePath%"

rem 0.5 second delay using ping
ping -n 1 -w 500 127.0.0.1 >nul

rem Delete the rules to clean up, combining commands into a single line
netsh advfirewall firewall delete rule name="block_tcp" & netsh advfirewall firewall delete rule name="allow_block_tcp"
powershell -c "[console]::beep(1500,500)" >nul 2>&1  
exit /b    : Modify the stop_fixer function such that it should give a beep first when selected , delte the rule which it does, and then it should instantly give another beep if any traffic is detected on 17500 port for AndroidEmulatorEn.exe