- Aug
- 2,058
- 83
Code:
:: Demonstration of using @WINAPI and Kernel32.dll functions
:: TCC 23.00.23 x64 Windows 7 [Version 6.1.7601]
::
:: This is a @WINAPI example showing how to use;
::
:: Kernel32.dll GetCommandLine function
::
:: Kernel32.dll lstrlenW function
::
:: Kernel32.dll RtlMoveMemory function
::
:: Run this .BTM from the;
:: TCC Command Line
:: TCC Debugger
:: CMDebug Debugger
:: to see the different command lines returned
::
@setlocal
@echo off
::
:: Get the address in memory where the Command Line is located
::
Set SADD=%@winapi[kernel32.dll,GetCommandLine]
echo The String Address for the Command Line is: %SADD
::
:: Get the length of the Command Line
::
Set StrLen=%@winapi[kernel32.dll,lstrlenW,%SADD]
::
:: This is a Wide String, so double the length returned
::
set StrLen=%@eval[%StrLen*2]
echo The Length of the Command Line is : %StrLen
::
:: Get the Command Line
::
set CommandLine=%@winapi[kernel32.dll,RtlMoveMemory,BUFFER,%SADD,%StrLen]
echo The Command Line is : %CommandLine
endlocal
quit
Example run on my TCC 23.00.23 x64 Windows 7 [Version 6.1.7601] system:
c:\users\jlc\utils>getcommandline.btm
The String Address for the Command Line is: 21968946
The Length of the Command Line is : 80
The Command Line is : "C:\Program Files\JPSoft\TCMD23\TCC.EXE"
Joe