Valhalla Legends Forums Archive | Battle.net Bot Development | Bnetauth Question

AuthorMessageTime
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:[code] 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];[/code]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.
December 22, 2003, 12:23 AM
Kp
[quote author=shadypalm88 link=board=17;threadid=4387;start=0#msg36662 date=1072052632]
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.[/quote]

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

[quote author=shadypalm88 link=board=17;threadid=4387;start=0#msg36662 date=1072052632]
1) When this uses MapViewOfFile and then accesses the return via lpdwBuffer[j], what's it actually doing?[/quote]

As above, it is stepping through the file's data, interpreted as a sequence of 32bit values.
[quote author=shadypalm88 link=board=17;threadid=4387;start=0#msg36662 date=1072052632]
2) Can I recreate this behavior in Visual Basic, and if so, how?[/quote]

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. :)
December 22, 2003, 5:46 AM
Null
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
December 22, 2003, 8:49 AM
dRAgoN
[quote author=Kp link=board=17;threadid=4387;start=0#msg36683 date=1072072010]
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. :)
[/quote]

True but trying to understand exactly how it works is part of learning is it not?
December 26, 2003, 10:09 AM
Kp
[quote author=dRAgoN link=board=17;threadid=4387;start=0#msg37156 date=1072433362]True but trying to understand exactly how it works is part of learning is it not?[/quote]

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.
December 26, 2003, 6:27 PM
Grok
Is it rumored there's a version which runs faster than Blizzard's? Seems I heard something like that a few times.
December 26, 2003, 6:45 PM
Kp
[quote author=Grok link=board=17;threadid=4387;start=0#msg37180 date=1072464344]
Is it rumored there's a version which runs faster than Blizzard's? Seems I heard something like that a few times.[/quote]

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).
December 26, 2003, 7:24 PM

Search