Post Reply Home » Forums » EverQuest 2 » EverQuest 2 Premium Discussions

Decoding the EQ2 INI file : EverQuest 2 Premium Discussions

Posted: December 10th, 2004
richyrich
If anyone has any free cycles, to speed up getting MegaBot converted to EQ2, try to break down the character INI files for EQ2 as I'll need it to pull the X,Y coords from the windows, since all is customizable.

In DAOC, it was easy... was a text file, but in EQ2 it's a binary file, so a little reverse engineering is needed. I've started, but with all the code I have to convert, might take me awhile to get to it.

If you are wondering what MegaBot is, go to the DAOC downloads section and download the latest version and see what we have done in DAOC - same plus more (crafting) coming to EQ2!

Any help from anyone is much appreciated!

Chat logger and API functions for targets is the next big thing to wait for.

Rich
Posted: December 12th, 2004
dwear2
rich once u get the ini files setup send me over a copy i will do all the classes again... got eq2 last week.. it great
Posted: December 12th, 2004
richyrich
Still a long way to go until the MEgaBot is useful. Need a chat logger and the basic X, Y coords from the API before it can really work (and Monster/harvesting X,Y). The INI I'm talkin about in the post above is decoding the encoded INI that EQ2 is using to save window placements.

Since Wyv is working on the crafting stuff first, I might try to focus my MegaBot on going out and auto harvesting... but would need the back-end API opened up first, so as soon as Wyv can do that, I'll be moving along!

Rich
Posted: December 13th, 2004
richyrich
Ok, I have figured out a little bit of the encoded INI file and need some help to write some routines.

VBScript doesn't seem to handle binary files very well... I am trying to use the ADODB class and some sample code I found on the net and it kinda works...

I can get a file to read in in binary mode, but can't seem to do anything with the data once I have it in a variable. Using Typename() I can see it is BYTE type data, but nothing else.

Someone who knows VBScript better than me should be able to quickly figure this one out! :-)

Here is the end result of what I need.
Open the binary file (which will be the EQ2 ini file), skip to a specific part of the file, read in a few bytes, then I'll convert them to Decimal based on what I've decoded them to mean (using HexDump and a slow process)

Below is some sample code to show what I have. For anyone who needs some good debugging code, my debugging Class from MegaBot is included here for reuse - good way to debug and have a log file for your scripts!

Rich

Code: Select all

Option Explicit
Class DebugClass

	Private objLogFileFSO, objLogFile, DebugLevel, i

	Private Sub Class_Initialize()
		Dim sDir, cont
		Dim sLogFile, sLogFileVersion

		sLogFileVersion = 1

		DebugLevel = 0 ' Default
		cont = true

		sDir = "c:\dl\logtest"

		Set objLogFileFSO = CreateObject("Scripting.FileSystemObject") 

		do while cont
			sLogFile = sDir & cStr(sLogFileVersion) & ".log"
			If objLogFileFSO.FileExists(sLogFile) Then
				sLogFileVersion = sLogFileVersion + 1
			else
				cont = false
			end if
		loop
		Set objLogFile = objLogFileFSO.OpenTextFile(sLogFile, 8, True) 


		call Print ("", 0)
		call Print ("", 0)
		call Print ("*************************************", 0)
		call Print ("*************************************", 0)
		call Print ("*************************************", 0)
		call Print("LOG File Opened: " & sLogFile, 0)
	End Sub

	Private Sub Class_Terminate()
		' Close Log File
		objLogFile.Close 
	End Sub

	Public Sub SetDebugLevel(lvl)
		DebugLevel = CInt(lvl)
	End Sub
	
	Public Sub PrintDebugLevel()
		call Print("Debug Level is set to: " & DebugLevel, 0)
	End Sub

	Public Sub Print(str1, lvl)
		if (DebugLevel >= lvl) then 
			'objLogFile.WriteLine(Date & " " & Time & ": " & str1)
			objLogFile.WriteLine(CStr(str1))
		end if
	End Sub

End Class

Function SaveBinaryData(FileName, ByteArray)
  Const adTypeBinary = 1
  Const adSaveCreateOverWrite = 2
  
  'Create Stream object
  Dim BinaryStream
  Set BinaryStream = CreateObject("ADODB.Stream")
  
  'Specify stream type - we want To save binary data.
  BinaryStream.Type = adTypeBinary
  
  'Open the stream And write binary data To the object
  BinaryStream.Open
  BinaryStream.Write 1
  'BinaryStream.Write ByteArray
  
  'Save binary data To disk
  BinaryStream.SaveToFile FileName, adSaveCreateOverWrite
End Function

Function ReadBinaryFile(FileName)
  Const adTypeBinary = 1
  
  'Create Stream object
  Dim BinaryStream
  Set BinaryStream = CreateObject("ADODB.Stream")
  
  'Specify stream type - we want To get binary data.
  BinaryStream.Type = adTypeBinary
  
  'Open the stream
  BinaryStream.Open
  
  'Load the file data from disk To stream object
  BinaryStream.LoadFromFile FileName
  
  'Open the stream And get binary data from the object
  ReadBinaryFile = BinaryStream.Read
End Function

Function ReadTextFile(FileName, CharSet)
  Const adTypeText = 2
  
  'Create Stream object
  Dim BinaryStream
  Set BinaryStream = CreateObject("ADODB.Stream")
  
  'Specify stream type - we want To get binary data.
  BinaryStream.Type = adTypeText
  
  'Specify charset For the source text (unicode) data.
  If Len(CharSet) > 0 Then
    BinaryStream.CharSet = CharSet
  End If
  
  'Open the stream
  BinaryStream.Open
  
  'Load the file data from disk To stream object
  BinaryStream.LoadFromFile FileName
  
  'Open the stream And get binary data from the object
  ReadTextFile = BinaryStream.ReadText
End Function

Function SaveTextData(FileName, Text, CharSet)
  Const adTypeText = 2
  Const adSaveCreateOverWrite = 2
  
  'Create Stream object
  Dim BinaryStream
  Set BinaryStream = CreateObject("ADODB.Stream")
  
  'Specify stream type - we want To save text/string data.
  BinaryStream.Type = adTypeText
  
  'Specify charset For the source text (unicode) data.
  If Len(CharSet) > 0 Then
    BinaryStream.CharSet = CharSet
  End If
  
  'Open the stream And write binary data To the object
  BinaryStream.Open
  BinaryStream.WriteText Text
  
  'Save binary data To disk
  BinaryStream.SaveToFile FileName, adSaveCreateOverWrite
End Function


Dim objDebug, bin, txt, txt2

Set objDebug = New DebugClass
objDebug.Print "1", 0
'Call SaveBinaryData("c:\dl\savebin.txt", "12345")
bin = ReadBinaryFile("c:\dl\logtest1.log")
txt = ReadTextFile("c:\dl\logtest1.log", "")
objDebug.Print "2", 0
objDebug.Print TypeName(bin), 0
objDebug.Print TypeName(txt), 0
SaveTextData "c:\dl\output1.txt", txt, ""
'txt2=CStr(txt)
'objDebug.Print txt2, 0
'objDebug.Print CStr(bin(1)), 0
objDebug.Print "3", 0
Set objDebug = NOTHING
Posted: December 13th, 2004
User avatar
Total Posts:1168 Joined:2004
Doesnt the Scripting.FileSystemObject read in binary files? along with text files?


Did you read up on the syntax for using it?

I dont really tink you want to use a database parser to read files.

_________________
Help our site.. take a moment to click the Digg this post!!! v v v
Posted: December 13th, 2004
richyrich
Everywhere I look it always references ADODB as the way to handle binary files... Got me, I don't actually like VBScript... and while I can create a lot of stuff in it, when it comes to things I haven't played with in VBScript, I kinda hack until it works. If someone can jump start me, - please do!

Thx,
Rich
Posted: December 14th, 2004
User avatar
Premium
Total Posts:6718 Joined:2004
You probably already found this, but:

http://www.motobit.com/tips/detpg_read- ... ary-files/

_________________
Use Search first, ask questions later!
Posted: December 14th, 2004
darkfire5252
I'm could be wrong about this, but to get the binary value, can you not just use FileSystemObject.OpenTextFile and then use Asc() to get the numerical value? This would be a good example:

Code: Select all

Function ReadINI(FileName, Position, NumBytes)
	
	Dim fso, ts, buffer, rBuf, byteArr()
	ReDim byteArr(NumBytes)
	
	Const ForReading = 1
	
	Set fso = CreateObject("Scripting.FileSystemObject")
	
	Set ts = fso.OpenTextFile(FileName,ForReading)
	ts.Skip(Position-1)
	buffer = ts.Read(NumBytes)
	
'	ReadINI = StringToBin(buffer)
	ReadINI = buffer
End Function

Dim data
data = ReadINI("testlog", 1, 5)
For i = 1 to Len(data)
	WScript.Echo Mid(data,i,1) & " = " & Asc(Mid(data,i,1))
Next
Posted: December 14th, 2004
richyrich
[quote="wyvernx";p="50556"]You probably already found this, but:

http://www.motobit.com/tips/detpg_read- ... ary-files/[/quote]

Yeah, that is where I pulled the sample code I posted from... the problem is, it reads the file just fine with the ADODB but I can't seem to do anything with the var once in memory... every function I try to use on it just gives me a run-time error... :-(
Posted: December 14th, 2004
richyrich
[quote="darkfire5252";p="50557"]I'm could be wrong about this, but to get the binary value, can you not just use FileSystemObject.OpenTextFile and then use Asc() to get the numerical value? This would be a good example:

Code: Select all

Function ReadINI(FileName, Position, NumBytes)
	
	Dim fso, ts, buffer, rBuf, byteArr()
	ReDim byteArr(NumBytes)
	
	Const ForReading = 1
	
	Set fso = CreateObject("Scripting.FileSystemObject")
	
	Set ts = fso.OpenTextFile(FileName,ForReading)
	ts.Skip(Position-1)
	buffer = ts.Read(NumBytes)
	
'	ReadINI = StringToBin(buffer)
	ReadINI = buffer
End Function

Dim data
data = ReadINI("testlog", 1, 5)
For i = 1 to Len(data)
	WScript.Echo Mid(data,i,1) & " = " & Asc(Mid(data,i,1))
Next
[/quote]

Darkfire - awesome! It worked great! I just figured since it was OpenTextFile that it would skip any non-printable characters when reading the file (which is kinda what the docs say on it), so I never even tried it! I just tried it with the binary INI files from EQ2 and it works great! Thank you - you have saved me a lot of time figuring that out!

Rich
Posted: December 14th, 2004
darkfire5252
No problem, I've been looking for a good scripting language to use with EQ2 for a while, so let me know if there's anything else I could work on that would help you guys. I used to do a lot of work with VB 6.0 (I actually made a cheat program for Apprentice, the magic the gathering online program, if you ever used that.)
Posted: December 14th, 2004
richyrich
I've been writing all my code in VBScript using XU - see the DAOCMegaBot code in the DAOC downloads section for the code I've posted.
Posted: December 16th, 2004
grakun
[quote="richyrich";p="50476"]Need a chat logger and the basic X, Y coords from the API before it can really work (and Monster/harvesting X,Y).[/quote]

Type "/log" in game to turn on chat logging. It will be saved to EQ2DIR\logs\ServerName\eq2log_Charname.txt
Posted: December 17th, 2004
richyrich
Yes - thank you, Wyv pointed that out and it seems to work!

So getting X,Y coords of objects is really the last thing I'm missing, but I can do a lot of stuff even w/o that.
Posted: December 17th, 2004
darkfire5252
rich: if you want to do the game-related functionality, I can make a route runner that has good support, all i'd need is the player movement stuff, which I imagine wouldnt be too hard for ya.
Ready to join the community? Click here and see all of the benefits!
blue large dotWho is online
Users browsing this forum: No registered users and 20 guests
Post Reply