-
Notifications
You must be signed in to change notification settings - Fork 0
/
BetterRandom.bat
93 lines (82 loc) · 2.24 KB
/
BetterRandom.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
@echo off
setlocal enabledelayedexpansion
REM BG EE: Baldur.exe
REM BG2 EE: Baldur.exe
REM IWD EE: Icewind.exe
REM Torment EE: Torment.exe
REM BG : BGMain2.exe
REM BG2 : BGMain.exe
REM IWD: IDMain.exe
REM Torment: Torment.exe
REM Check for original executables (BGMain2.exe is for BG and BGMain.exe is for BG2)
if exist "BGMain2.exe" (
set "TARGET_EXE=BGMain2.exe"
goto :next
)
if exist "BGMain.exe" (
set "TARGET_EXE=BGMain.exe"
goto :next
)
if exist "IDMain.exe" (
set "TARGET_EXE=IDMain.exe"
goto :next
)
if exist "Torment.exe" (
set "TARGET_EXE=Torment.exe"
goto :next
)
REM Check for EE executables
if exist "Baldur.exe" (
set "TARGET_EXE=Baldur.exe"
goto :next
)
if exist "Baldur2.exe" (
set "TARGET_EXE=Baldur2.exe"
goto :next
)
if exist "Icewind.exe" (
set "TARGET_EXE=Icewind.exe"
goto :next
)
if exist "Torment.exe" (
set "TARGET_EXE=Torment.exe"
goto :next
)
echo No matching executable found. Exiting...
exit /b 1
:next
REM Check if the executable is 32-bit
for /f %%G in ('powershell -NoProfile -Command "(get-content '%TARGET_EXE%' -totalcount 50) | select-string -Pattern 'PE..L' -Quiet"') do (
set "IS32EXE=%%G"
)
REM Check if the executable is 64-bit
for /f %%G in ('powershell -NoProfile -Command "(get-content '%TARGET_EXE%' -totalcount 50) | select-string -Pattern 'PE..d' -Quiet"') do (
set "IS64EXE=%%G"
)
REM Check for 32-bit target executable
if "!IS32EXE!"=="True" (
set "DLL_NAME=BetterRandom_x86.dll"
set "SETDLL=setdll_x86.exe"
REM Additional actions for 32-bit executable...
)
REM Check for 64-bit target executable
if "!IS64EXE!"=="True" (
set "DLL_NAME=BetterRandom_x64.dll"
set "SETDLL=setdll_x64.exe"
REM Additional actions for 64-bit executable...
)
REM Prompt user for action
echo 1. Add BetterRandom library to %TARGET_EXE%
echo 2. Remove BetterRandom library from %TARGET_EXE%
set /p "ACTION=Enter action number (1 or 2): "
REM Process user's choice
if "!ACTION!"=="1" (
REM Inject the BetterRandom library using setdll.exe
%SETDLL% /d:%DLL_NAME% %TARGET_EXE%
) else if "!ACTION!"=="2" (
REM Remove the BetterRandom library using setdll.exe
%SETDLL% /r %TARGET_EXE%
) else (
echo Invalid action number. Exiting...
)
endlocal