• Welcome to Valhalla Legends Archive.
 

Bnetauth Question

Started by shadypalm88, December 21, 2003, 06:23 PM

Previous topic - Next topic

shadypalm88

Hi, I'm working on porting Bnetauth.dll to Visual Basic.  I've been going through the source, transferring constants and declaring Windows API functions as needed.  I am at the point in CheckVersion where it actually reads the files.  It's using a Win32API function called MapViewOfFile.  MSDN says this is returning an LPVOID, which I am interpreting as a long pointer to anything.  Bnetauth typecasts it onto a LPDWORD (long pointer to unsigned long?).  Then later it steps through it like an array, and that's what has me puzzled.  Now I'm assuming that what it's actually doing is moving through memory addresses reading the file byte by byte but I'm not sure.

My C(++) experience is limited, and what I do have has thus far hasn't touched on anything MS-specific.  Here's a snippet of the code in question:      lpdwBuffer = (LPDWORD) MapViewOfFile(hFileMapping, FILE_MAP_READ, 0, 0, 0);
     if (lpdwBuffer == NULL) {
        CloseHandle(hFileMapping);
        CloseHandle(hFile);
        return FALSE;
     }
     if (i == 0) {
        GetFileTime(hFile, &ft, NULL, NULL);
        FileTimeToSystemTime(&ft, &st);
        dwTotalSize = GetFileSize(hFile, NULL);
     }
     dwSize = (GetFileSize(hFile, NULL) / 1024lu) * 1024lu;
     for (j = 0; j < (dwSize / 4lu); j++) {
        dwVariables[3] = lpdwBuffer[j];
Here's what I need to know:
1) When this uses MapViewOfFile and then accesses the return via lpdwBuffer[j], what's it actually doing?
2) Can I recreate this behavior in Visual Basic, and if so, how?

Thanks in advance.

Kp

Quote from: shadypalm88 on December 21, 2003, 06:23 PM
Now I'm assuming that what it's actually doing is moving through memory addresses reading the file byte by byte but I'm not sure.

Very close.  It's stepping through by dwords (32 bit values), not bytes (8 bit values).

Quote from: shadypalm88 on December 21, 2003, 06:23 PM
1) When this uses MapViewOfFile and then accesses the return via lpdwBuffer[j], what's it actually doing?

As above, it is stepping through the file's data, interpreted as a sequence of 32bit values.
Quote from: shadypalm88 on December 21, 2003, 06:23 PM
2) Can I recreate this behavior in Visual Basic, and if so, how?

Why would you want to?  It should be pretty easy to make bnetauth.dll callable from VB (if it isn't already), and it'll be a lot faster execution wise to do that than to run it as VB code. :)
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

effect

I actually had a problem with trying to call functions from Bnetauth , My IDE would just freeze up , i guess you get what you pay for ,  0
Quote from: Mangix on March 22, 2005, 03:03 AM
i am an expert Stealthbot VBScript. Recognize Bitch.

l)ragon

Quote from: Kp on December 21, 2003, 11:46 PM
Why would you want to?  It should be pretty easy to make bnetauth.dll callable from VB (if it isn't already), and it'll be a lot faster execution wise to do that than to run it as VB code. :)

True but trying to understand exactly how it works is part of learning is it not?
*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*ˆ¨¯¯¨ˆ*^~·.,l)ragon,.-·~^*ˆ¨¯¯¨ˆ*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*

Kp

Quote from: dRAgoN on December 26, 2003, 04:09 AMTrue but trying to understand exactly how it works is part of learning is it not?

Sure, but he made it pretty clear he wanted to actually translate it into VB, which suggests to me that he wants to *gasp* run it in VB, which is what I told him was a bad idea.  I failed to mention this previously, but even the C version doesn't run too speedily compared to Blizzard's implementation.  Redoing it in VB will just make things even worse.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Grok

Is it rumored there's a version which runs faster than Blizzard's?  Seems I heard something like that a few times.

Kp

Quote from: Grok on December 26, 2003, 12:45 PM
Is it rumored there's a version which runs faster than Blizzard's?  Seems I heard something like that a few times.

If so, not by much.  Theirs is very efficient.  I believe I have seen one which is approximately comparable to theirs, but I don't recall where or which one was faster (there was a speed difference down in the 1%-2% range iirc).
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!