This repository has been archived by the owner on May 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 169
/
calc_target_offsets.bat
45 lines (33 loc) · 1.75 KB
/
calc_target_offsets.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
@echo off
echo Calculating offsets, please wait...
echo.
pushd tools
set cmd=dumpbin.exe /IMPORTS:ntoskrnl.exe "%windir%\system32\drivers\srvnet.sys" ^| findstr /c:"Import Address Table"
for /f "tokens=1" %%i in ('"%cmd%"') do set iat=%%i
set cmd=dumpbin.exe /IMPORTS:ntoskrnl.exe "%windir%\system32\drivers\srvnet.sys" ^| findstr /e /n IoSizeofWorkItem
for /f "tokens=1 delims=:" %%i in ('"%cmd%"') do set /a IoSizeofWorkItem=%%i-17
set cmd=dumpbin.exe /IMPORTS:ntoskrnl.exe "%windir%\system32\drivers\srvnet.sys" ^| findstr /e /n RtlCopyUnicodeString
for /f "tokens=1 delims=:" %%i in ('"%cmd%"') do set /a RtlCopyUnicodeString=%%i-17
set w=.echo ==========
set w=%w%; .printf \"\OFFSETS = { \x23\n\"
set w=%w%; .catch { .printf \"\ 'srvnet!SrvNetWskConnDispatch': 0x%%X, \x23\n\", srvnet!SrvNetWskConnDispatch-srvnet }
set w=%w%; .catch { .printf \"\ 'srvnet!imp_IoSizeofWorkItem': 0x%%X, \x23\n\", %iat%-srvnet+0n%IoSizeofWorkItem%*8 }
set w=%w%; .catch { .printf \"\ 'srvnet!imp_RtlCopyUnicodeString': 0x%%X, \x23\n\", %iat%-srvnet+0n%RtlCopyUnicodeString%*8 }
set w=%w%; .echo ==========
set w=%w%; q
set cmd=cdb.exe -y "SRV*%cd%*https://msdl.microsoft.com/download/symbols"
set cmd=%cmd% -z "%windir%\system32\drivers\srvnet.sys"
set cmd=%cmd% -c "%w%"
%cmd% | findstr #
set w=.echo ==========
set w=%w%; .catch { .printf \" 'nt!IoSizeofWorkItem': 0x%%X, \x23\n\", ntoskrnl!IoSizeofWorkItem-ntoskrnl }
set w=%w%; .catch { .printf \" 'nt!MiGetPteAddress': 0x%%X \x23\n\", ntoskrnl!MiGetPteAddress-ntoskrnl }
set w=%w%; .printf \"} \x23\n\"
set w=%w%; .echo ==========
set w=%w%; q
set cmd=cdb.exe -y "SRV*%cd%*https://msdl.microsoft.com/download/symbols"
set cmd=%cmd% -z "%windir%\system32\ntoskrnl.exe"
set cmd=%cmd% -c "%w%"
%cmd% | findstr #
popd
pause