Valhalla Legends Forums Archive | Battle.net Bot Development | [Java] 0x50 Complications

AuthorMessageTime
Spilled[DW]
Hi, in my first attempt to make a bot in java, i have ran into a problem. When i recieve 0x50, extracting the data from it has been harder then i thought and am seeking your help.

In VB i did this like so:
[code]
            Hashing.ServerToken = Val("&H" & Connection.StrToHex(StrReverse(Mid(strData, 9, 4))))
            Hashing.Hash = Mid(strData, 38, Len(strData) - 2)
            Hashing.MpqName = CStr(Mid(Mid(strData, InStr(1, strData, "IX86ver"), Len(strData)), 1, 12))
[/code]

Is there an easier way then writing a reverse function and a strtohex function? What about the Val and the CStr? Any tips would be appreciated because I am kinda lost in this problem.

Spilled[DW]
October 10, 2005, 4:30 AM
JoeTheOdd
Uh, you're probably going to want to use a debuffer.

http://www.javaop.com/javaop2/src/javaop2_pub/src/util/BNetPacket.java
http://www.javaop.com/javaop2/src/javaop2_pub/src/util/Buffer.java

LoginType = packet.RemoveDWORD();
ServerToken = packet.RemoveDWORD();
UDPValue = packet.RemoveDWORD();
MPQFiletime = packet.RemoveQWORD();
MPQName = packet.RemoveNTString();
ValueString = packet.RemoveNTString();
October 10, 2005, 5:33 AM
UserLoser.
[quote]
[code]
Val("&H" & Connection.StrToHex(StrReverse(Mid(strData, 9, 4))))
[/code]
[/quote]

wtf.  Do us all and your computer a favor by using memcpy/CopyMemory
October 10, 2005, 6:42 AM
JoeTheOdd
Oh god, didn't even notice that was a DWORD. =p
October 10, 2005, 12:15 PM
Dynobird
Well, you could make a class for receiving 0x50, and have methods that return the bytes/words/dwords that you want to get from it because those methods will know the offset and length ints for your byte array.

Or you could have a generic packet debuffer class in which you give it a Packet or a byte array and call methods that take a given offset. You wouldn't need a length because you could have separate methods for getWord, getDword etc. and they will know the lengths.

~~

String to hex is simply...
String strToHex = new String();
byte strbytes[] = strToHex.getBytes();
the method returns a byte array

Conversion in Java isn't that hard, you should look at the api's
http://java.sun.com/j2se/1.5.0/docs/api/ search for String and you'll see the getBytes() method there.

Perhaps you should read a book on Java or OOP b/c its very different than VB.
October 10, 2005, 6:08 PM
Spilled[DW]
Yea, i am currently reading a book on Java because we are taking it at my college. But anyways off that subject How would i load the checkrevision.dll library? would i use System.loadLibrary("CheckRevision.dll") ? And if this is how, how come i cant use the functions inside it? I try to but its not letting me.

[code]
static
{
System.loadLibrary("CheckRevision.dll");
}
[/code]

Also is this how i would load the hashes? Thanks in advance!
October 10, 2005, 9:39 PM
Dynobird
I don't know that much about the C family, but as I see it you're trying use the functions of .dll's in the Java file? Well, I don't know much about that. The weird thing about the System.loadLibrary() call is that it doesn't return anything. So I guess that it does the functions of the .dll itself... but you said you wanted to use the functions of the dll yourself inside your java class?

Here's another idea, you can make an .exe that does it for you, perhaps a VB .exe if you wish, b/c its easy to run exe's through Java. You use sun's Runtime class to do it.

Example:
[code]
Runtime cmd = Runtime.getRuntime();        // I don't think you can instantiate Runtime any other way, it's probably protected
cmd.exec("start DoCheckRevision.exe");
[/code]

Hope that helps.
October 10, 2005, 10:40 PM
Spilled[DW]
Any other ideas?
October 11, 2005, 5:18 AM
Kp
Why're you loading a DLL?  That's inherently non-portable, which negates the primary benefit of writing this in Java.  Besides which, if that's the Blizzard CheckRevision DLL, it won't work for you anyway.
October 11, 2005, 11:52 PM
JoeTheOdd
Using a DLL in Java is possible, I think, but rather messy and totally distroys Java's main advantage, its cross-platformness. You can do it if you want, but I suggest recreating checkrevision in Java.

EDIT -
WAR3 Stuff
October 11, 2005, 11:59 PM
Spilled[DW]
[quote author=Joe link=topic=13001.msg130725#msg130725 date=1129075157]
Using a DLL in Java is possible, I think, but rather messy and totally distroys Java's main advantage, its cross-platformness. You can do it if you want, but I suggest recreating checkrevision in Java.

EDIT -
WAR3 Stuff
[/quote]

What variable does this CheckRevision return? The CheckSum or the Version ID?, and how would i get the other stuff that i need? Including the exeinfo and anything else i need? Please no flaming I have never worked with doing CheckRevision in any other language then VB, which is already provided by the dll and im eager to learn how to do it in Java. All help is appreciated!
October 12, 2005, 6:26 PM
HdxBmx27
Crev() return the checksum.
I will post info on how to get the exeinfo when i get home. And I'm not sure how to get the EXEVer automatically in java so I'm interested in this to.
~-~(HDX)~-~
October 12, 2005, 9:29 PM
Spilled[DW]
ahh i c, Thanks again Hdx. Get back as soon as possible. :)
October 12, 2005, 10:02 PM
HdxBmx27
[code] /** Compiles BNET Exe Info of a given game set
* @return Exe Info String
* @param files - file list
* */
    private static String getExeInfo(String[] files)
    {
        //return "starcraft.exe 03/28/03 04:21:56 1064960";

        File f = new File(files[0]);
       
        // Set up a calendar to point at the last modified time
        Calendar c = Calendar.getInstance();
        c.setTime(new Date(f.lastModified()));
       
        StringBuffer exeInfo = new StringBuffer();
       
        // Write to the exeInfo buffer
        exeInfo.append(f.getName()).append(" ");
       
        // date
        exeInfo.append(PadString.padNumber(c.get(Calendar.MONTH), 2)).append("/");
        exeInfo.append(PadString.padNumber(c.get(Calendar.DAY_OF_MONTH), 2)).append("/");
        exeInfo.append(PadString.padNumber((c.get(Calendar.YEAR) % 100), 2)).append(" ");
       
        // time
        exeInfo.append(PadString.padNumber(c.get(Calendar.HOUR_OF_DAY), 2)).append(":");
        exeInfo.append(PadString.padNumber(c.get(Calendar.MINUTE), 2)).append(":");
        exeInfo.append(PadString.padNumber(c.get(Calendar.SECOND), 2)).append(" ");
       
        // size
        exeInfo.append(f.length());
       
        return exeInfo.toString();
    }[/code]
Code was writtin by iago, It's part of many open source programs so He shouldn't have a problem with you using it. you need his PadString class. It jsut makes life easier >.<
Also as for the ExeVer I beleave you can set it to null due to Macs not having the proper functions to get it.
~-~(HDX)~-~
October 12, 2005, 11:09 PM
Spilled[DW]
o, nice nice Thanks HdX and Thanks Iago i  hope you dont mind ;)

Hrmm now what about the Bnetauth class and the hash class? Anyone mind helping me with those functions? Thanks in advance!
October 13, 2005, 4:18 AM

Search