• Welcome to Valhalla Legends Archive.
 

The CheckRevision value string

Started by MyndFyre, April 11, 2005, 07:17 PM

Previous topic - Next topic

MyndFyre

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:


[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

}


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

Thoughts?
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Arta

Version checking is rather more complicated than that. I'd recommend some disassembling if you want the whole story :)

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.

This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


tA-Kane

So ermmm..., since the algorithm rounds the file down to the nearest 1024 ... what happens if the file's size is < 1024?
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

MyndFyre

Quote from: tA-Kane on April 12, 2005, 09:04 AM
So ermmm..., since the algorithm rounds the file down to the nearest 1024 ... what happens if the file's size is < 1024?

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

Quote from: Arta[vL] on April 12, 2005, 04:59 AM
Version checking is rather more complicated than that. I'd recommend some disassembling if you want the whole story :)

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.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

iago

Quote from: tA-Kane on April 12, 2005, 09:04 AM
So ermmm..., since the algorithm rounds the file down to the nearest 1024 ... what happens if the file's size is < 1024?

If that came up, it would round down to 0 and the initial (seed) value would be returned.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


shout

Quote from: MyndFyre on April 11, 2005, 07:17 PM
More or less, I want to emit a runtime assembly that calculates the revision check.

Why? (just want to know)

MyndFyre

Quote from: Shout on April 12, 2005, 10:52 AM
Quote from: MyndFyre on April 11, 2005, 07:17 PM
More or less, I want to emit a runtime assembly that calculates the revision check.

Why? (just want to know)

I'm curious to see if runtime-generated calculation is faster than the three for loops.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

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?
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


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.

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) :)
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*