Depending on the age of the client, the version identifier inside the client executable, is either stored as clear text or is stored inside the VERSIONINFO resource.
According to the list on this website : http://www.uoguide.com/List_of_Classic_Client_Patches, EA/OSI stopped using letters for versioning their clients in december 2007. Therefor I'm guessing that they started using the VERSIONINFO resource from that point-on forward.
To extract the version from a resource you can use an utility named "fvertest", which you can download here: http://www.westmesatech.com/wast.html.
This utility does give too much information, therefor I use "sed" to remove the unncessary text. "sed" is a Linux command-line utility which has been ported to Windows. Downloadable here: http://gnuwin32.sourceforge.net/packages/sed.htm"sed" can be compared to "FINDSTR", but more powerfull.
This is the command-line I came up with:
- Code: Select all
fvertest -f "client.exe" | sed -e "s/^.*\[\(.*\)\].*$/\1/"
If your Ultima Online client does not contain a VERSIONINFO resource then you need to extract the version from the EXE itself. This can be done by combining "Strings" (http://technet.microsoft.com/en-us/sysinternals/bb897439.aspx) with "sed".
With "strings" you can extract all ASCII strings like this:
- Code: Select all
strings -a -q "client.exe"
Then you feed this output to "sed"; and using regular expressions you look for the string that equals "X.Y[.Zabc]", where X and Y are numbers and Zabc is the optional version number (+ character).
This (more or less) turns into the following command-line:
- Code: Select all
strings -a -q "client.exe" | sed -e "/^[1-5]\.[0-9]\{1,2\}.*$/!d"
I've created a batch file that combines the two methods, the full source code, also downloadable below as a ZIP (without the required tools):
- Code: Select all
@ECHO OFF
REM UO Version Extraction by Batlin
REM
REM REQUIRES:
REM fvertest
REM sed
REM strings
REM Parameter checking
IF %1.==. GOTO :Help
IF NOT EXIST %1 GOTO :Error
GOTO :DoIt
:Help
ECHO Usage: uoversion ^<UO-client-exe-filename^>
GOTO :Done
:Error
ECHO Client file does not exist!
GOTO :Done
:DoIt
REM Tools:
REM http://technet.microsoft.com/en-us/sysinternals/bb897439.aspx
REM http://gnuwin32.sourceforge.net/packages/sed.htm
REM Tutorial:
REM http://users.cybercity.dk/~bse26236/batutil/help/SED.HTM
REM Do we have a version resource?
fvertest -q %1 > NUL
IF %ERRORLEVEL% EQU 0 goto :technique_fvertest
:technique_strings
REM No...
REM 1: extract all ascii strings
REM 2: look for and extract the version number
REM 3: fix-up (alpha client, returned value is probably bogus)
REM 4: fix-up (GOD client, maybe others too)
strings -a -q %1 | sed -e "/^[1-5]\.[0-9]\{1,2\}.*$/!d" | sed /[_]/d | sed 1!d
GOTO :done
:technique_fvertest
REM Yes...
REM 1: extract the version string
REM 2: clean-up
fvertest -f %1 | sed -e "s/^.*\[\(.*\)\].*$/\1/"
ECHO.
:Done