Valhalla Legends Forums Archive | Battle.net Bot Development | The CheckRevision value string

AuthorMessageTime
Myndfyr
Oooooo-kay!

I have a few questions about the value string.

1.) Has anyone ever observed a value string in a format besides:
A=value B=value C=value number-of-operations operation-list?

2.) Has anyone ever observed a number of operations other than 4?

3.) I realize that S is *something* to do with the file, but what?

While it's not necessarily good practice, I want to make the assumption that the A, B, and C values always appear in that order, and that there are four operations.  I am aiming to do something like this:

[code]
[CLSCompliant(false)]
public static uint DoEmitCheckRevision(
string VersionString,
string[] FileList,
int MpqNum)
{
string[] tokens = VersionString.Split(new char[] { ' ' } );

AssemblyName asmName = new AssemblyName();
asmName.Name = "DynCheckRevision";
asmName.Version = new Version(1, 0, 0, 0);

AssemblyBuilder assembly = AppDomain.CurrentDomain.DefineDynamicAssembly(
asmName, AssemblyBuilderAccess.Run);

ModuleBuilder module = assembly.DefineDynamicModule("DynCheckRevision",
"dcr.dll", false);

TypeBuilder crclass = module.DefineType("CR", TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed);

FieldBuilder val_A = crclass.DefineField("a", typeof(uint),
FieldAttributes.Literal);
val_A.SetConstant( int.Parse( tokens[0].Substring(2) ) );

FieldBuilder val_B = crclass.DefineField("b", typeof(uint),
FieldAttributes.Literal);
val_B.SetConstant( int.Parse( tokens[1].Substring(2) ) );

FieldBuilder val_C = crclass.DefineField("c", typeof(uint),
FieldAttributes.Literal);
val_C.SetConstant( int.Parse( tokens[2].Substring(2) ) );

MethodBuilder calc = crclass.DefineMethod("Calc",
MethodAttributes.Public | MethodAttributes.Static,
CallingConventions.Standard, typeof(uint), new Type[] {
  typeof(uint),
  typeof(BinaryReader[])
  }
);

// do something

}
[/code]

More or less, I want to emit a runtime assembly that calculates the revision check.

Thoughts?
April 12, 2005, 12:17 AM
Arta
Version checking is rather more complicated than that. I'd recommend some disassembling if you want the whole story :)
April 12, 2005, 9:59 AM
iago
The "S" represents the "current dword" that is being processed.  It loops through each dword in each file (although it rounds the file's size down to the nearest multiple of 1024 first).

And I've never seen a format string that doesn't look like this:
A=x B=y C=z 4 A=A?S B=B?C C=C?A A=A?B
In my code, I assume it'll be in that exact format.  If it's not, I fall back on some slower code.

April 12, 2005, 11:44 AM
tA-Kane
So ermmm..., since the algorithm rounds the file down to the nearest 1024 ... what happens if the file's size is < 1024?
April 12, 2005, 2:04 PM
Myndfyr
[quote author=tA-Kane link=topic=11245.msg108326#msg108326 date=1113314681]
So ermmm..., since the algorithm rounds the file down to the nearest 1024 ... what happens if the file's size is < 1024?
[/quote]

I don't think they need to worry about that.  Have you seen any of their files (ever?) to be less than 1kb?

[quote author=Arta[vL] link=topic=11245.msg108321#msg108321 date=1113299986]
Version checking is rather more complicated than that. I'd recommend some disassembling if you want the whole story :)
[/quote]

Are you referring to the code I've put in?  It is obviously incomplete.  It was just there to give you an idea about where I wanted to go.
April 12, 2005, 2:07 PM
iago
[quote author=tA-Kane link=topic=11245.msg108326#msg108326 date=1113314681]
So ermmm..., since the algorithm rounds the file down to the nearest 1024 ... what happens if the file's size is < 1024?
[/quote]

If that came up, it would round down to 0 and the initial (seed) value would be returned.
April 12, 2005, 3:48 PM
shout
[quote author=MyndFyre link=topic=11245.msg108260#msg108260 date=1113265052]
More or less, I want to emit a runtime assembly that calculates the revision check.
[/quote]

Why? (just want to know)
April 12, 2005, 3:52 PM
Myndfyr
[quote author=Shout link=topic=11245.msg108341#msg108341 date=1113321139]
[quote author=MyndFyre link=topic=11245.msg108260#msg108260 date=1113265052]
More or less, I want to emit a runtime assembly that calculates the revision check.
[/quote]

Why? (just want to know)
[/quote]

I'm curious to see if runtime-generated calculation is faster than the three for loops.
April 12, 2005, 7:41 PM
iago
My new code takes about 40% of the time that my old code does.  That's based on the fact that it's always in the same format as above.

I couldn't see gaining a lot more speed than that, since you just lose a short jump each loop and little else.  But who knows?
April 12, 2005, 7:58 PM
OnlyMeat
Parsing the equation string is trivial. The most time consuming part is performing the actual hash operations on the file as 4 byte blocks.

I did a vb 6.0 version check, and that was the biggest bottleneck.
April 12, 2005, 8:55 PM
iago
The problem is if you're checking every operation AND variable in every loop, it's checking the operation and variable A LOT.  I found when I assumed that the variables would always be the same, it sped up a ton.  I should unroll all possible operators combinations (3 * 3 * 3 * 3 = 81 combos) :)
April 12, 2005, 9:08 PM

Search