• Welcome to Valhalla Legends Archive.
 

C++ CheckRevision

Started by Spilled, October 17, 2005, 01:31 PM

Previous topic - Next topic

Spilled

having a hardtime doing checkrevision in C++ and im seeking your help. Its giving me error's in the parameters.
(char* to char). Just some feedback on what im doing wrong and what way i should do it is what im seeking. Heres my code:

parsep:


        case 0x50:
             {
             cout << "0x50 Recieved!\n";
             char hash[len-38];
             CopyMemory(hashing.serverToken,strData+8,4);
             CopyMemory(hash,strData+37,sizeof(hash));
             CopyMemory(hashing.mpqnum,strData+31,1);
             cout << hashing.mpqnum << endl;
             int checksum = 0;
             long versionID = 0;
             char exeInfo[256];
             send(wSock,strData,len,0);
             string ix = "IX86ver";
             ix += hashing.mpqnum;
             checkRevision("STAR/starcraft.exe", "STAR/storm.dll", "STAR/battle.snp", *hash, versionID, checksum, exeInfo, ix); 
             }
        break;


this is how i load the dll -


typedef int (CALLBACK* cbChkRev)(string, string, string, char, long, int, char*, string);
cbChkRev checkRevision;

    chkRev = LoadLibrary("CheckRevision.dll");
    checkRevision = (cbChkRev)GetProcAddress(chkRev, "CheckRevision");
    if(chkRev != 0)
      cout << "CheckRevision.dll Loaded!\n";
    else
      cout << "Failed to load CheckRevision.dll!\n";



hashing struct:

struct HASHING
{
       char serverToken[4];
       char* mpqnum;
};


I know im probably doign somethign wrong but this is my first time so no flaming plz. I just need to know what the parameter types i should be passing.
Thanks in advance,
Spilled[DW]

UserLoser.

#1
Just a reminder, that will not work because the CheckRevision DLLs from Blizzard uses GetModuleHandle(0) and ignores the first parameter.  And that parameter should be char*, not char.  Anyways, with calling CheckRevision from those DLLs, I'm not sure if string would work because that's some class and not a 'built in' type, no?

Spilled

So, what do you suggest? i ran into the same problem with my bot in java. The check revision and the functions in hash.dll and bnetauth.dll i used... and i couldnt find no help with those functions. Im lost here bro any help would be appreciated...

Arta

char*, not string.

You should learn more about C++ before attempting this. Go read about pointers.

Spilled

#4
hrmm, since as UserLoser said this wont work. Thanks to LordVader I have recieved Yobgul's checkrevision code. My thanks out to lordvader but this leaves me with another question. Would i be able to use the Hash.dll and the Bnetauth.dll functions?
All help would be appreciated. Thanks in advance!

Userloser, MyndFyre, Arta[vL], Kp - I need your knowledge!

Kp

Quote from: Spilled[DW] on October 19, 2005, 02:31 AMhrmm, since as UserLoser said this wont work. Thanks to LordVader I have recieved Yobgul's checkrevision code. My thanks out to lordvader but this leaves me with another question. Would i be able to use the Hash.dll and the Bnetauth.dll functions?
All help would be appreciated. Thanks in advance!

Userloser, MyndFyre, Arta[vL], Kp - I need your knowledge!

Those DLLs are unsupported.  Use BNLS or BNCSutil, depending on whether you want remote or local computations.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Spilled

#6
Thanks to Bnetweb.com, I found the source to bnetauth.dll and it has all the functions I need for 0x51 and more... But When I include the header file and try to create a variable for the Header File I get an error. Im not sure if the error is in the bnetauth coding or i've just been staring at the code so long I'm going brain dead. (like I wasn't before :) ) But hey if you can help I would appreciate it.
Heres my code:

Edit: For my sake and MyndFyre's heres my class again Edited.

Solved.

MyndFyre

All in all, my guess would be that there is NOT A CLASS called "BnetAuth".

I could just see the error....

"Error C2065: 'BnetAuth': undeclared identifier."

Spilled, I want you to look through that code and tell me if you see a class, struct, or typedef that defined "BnetAuth".  Let me know how it works out.

In the future, you might attempt trying to understand the error message instead of blindly flailing about.

Sorry for being an ass, but this is one of the most egregious instances of being oblivious to the information on the screen EVER.
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.

Spilled

Well like i said im still learning so im sorry about that so go ahead and flame me, Now that I have gotten that to work passing the DWORD* to function is giving me an error....

I declare the variables like so:


        case 0x50:
             {
             cout << "0x50 Recieved!\n";
             LPCTSTR files[] = {"/STAR/starcraft.exe", "/STAR/storm.dll", "/STAR/battle.snp"};
             //cout << "1: " << files[0] << " \n2: " << files[1] << " \n3: " << files[2] << "\n";
             LPCTSTR mpqName;
             LPCTSTR hash;
             CopyMemory(&hash,&strData+37,len-38);
             DWORD *versionID;
             DWORD *checksum;
             LPSTR exeInfo;
             CopyMemory(hashing.serverToken,strData+8,4);


Pass to CheckVersion like so..

             if(auth.CheckVersion(files[0], files[1], files[2], hash, versionID, checksum, exeInfo, mpqName) == true)
                              cout << "true! \n";
             else
                              cout << "false! \n";


and heres the CheckVersion functions if you need it...

BOOL BnetAuth::CheckVersion(LPCTSTR lpszFileName1, LPCTSTR lpszFileName2, LPCTSTR lpszFileName3, LPCTSTR lpszValueString, DWORD * lpdwVersion, DWORD * lpdwChecksum, LPSTR lpExeInfoString, LPCTSTR lpszMpqFileName) {
   HANDLE hFile, hFileMapping;
   char * s, lpszFileName[256], cOperations[16];
   int nHashFile, nVariable1[16], nVariable2[16], nVariable3[16], nVariable, i, k, nHashOperations;
   DWORD dwTotalSize, dwSize, j, dwBytesRead, dwVariables[4], dwMpqKey, * lpdwBuffer;
   LPSTR lpszFileNames[3];
   FILETIME ft;
   SYSTEMTIME st;
   LPBYTE lpbBuffer;
   VS_FIXEDFILEINFO * ffi;

   s = strchr((char *) lpszMpqFileName, '.');
   if (s == NULL)
      return FALSE;
   nHashFile = (int) (*(s - 1) - '0');
   if (nHashFile > 7 || nHashFile < 0)
      return FALSE;
   dwMpqKey = dwMpqChecksumKeys[nHashFile];
   lpszFileNames[0] = (LPSTR) lpszFileName1;
   lpszFileNames[1] = (LPSTR) lpszFileName2;
   lpszFileNames[2] = (LPSTR) lpszFileName3;
   s = (char *) lpszValueString;
   while (*s != '\0') {
      if (isalpha(*s))
         nVariable = (int) (toupper(*s) - 'A');
      else {
         nHashOperations = (int) (*s - '0');
         s = strchr(s, ' ');
         if (s == NULL)
            return FALSE;
         s++;
         break;
      }
      if (*(++s) == '=')
         s++;
      dwVariables[nVariable] = atol(s);
      s = strchr(s, ' ');
      if (s == NULL)
         return FALSE;
      s++;
   }
   for (i = 0; i < nHashOperations; i++) {
      if (!isalpha(*s))
         return FALSE;
      nVariable1[i] = (int) (toupper(*s) - 'A');
      if (*(++s) == '=')
         s++;
      if (toupper(*s) == 'S')
         nVariable2[i] = 3;
      else
         nVariable2[i] = (int) (toupper(*s) - 'A');
      cOperations[i] = *(++s);
      s++;
      if (toupper(*s) == 'S')
         nVariable3[i] = 3;
      else
         nVariable3[i] = (int) (toupper(*s) - 'A');
      s = strchr(s, ' ');
      if (s == NULL)
         break;
      s++;
   }
   dwVariables[0] ^= dwMpqKey;
   for (i = 0; i < 3; i++) {
      if (lpszFileNames[i][0] == '\0')
         continue;
      hFile = CreateFile(lpszFileNames[i], GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
      if (hFile == (HANDLE) INVALID_HANDLE_VALUE)
         return FALSE;
      hFileMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
      if (hFileMapping == NULL) {
         CloseHandle(hFile);
         return FALSE;
      }
      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];
         for (k = 0; k < nHashOperations; k++) {
            switch (cOperations[k]) {
               case '+':
                  dwVariables[nVariable1[k]] = dwVariables[nVariable2[k]] + dwVariables[nVariable3[k]];
                  break;
               case '-':
                  dwVariables[nVariable1[k]] = dwVariables[nVariable2[k]] - dwVariables[nVariable3[k]];
                  break;
               case '^':
                  dwVariables[nVariable1[k]] = dwVariables[nVariable2[k]] ^ dwVariables[nVariable3[k]];
                  break;
               default:
                  return FALSE;
            }
         }
      }
      UnmapViewOfFile(lpdwBuffer);
      CloseHandle(hFileMapping);
      CloseHandle(hFile);
   }
   strcpy(lpszFileName, lpszFileName1);
   dwSize = GetFileVersionInfoSize(lpszFileName, &dwBytesRead);
   lpbBuffer = (LPBYTE) VirtualAlloc(NULL, dwSize, MEM_COMMIT, PAGE_READWRITE);
   if (lpbBuffer == NULL)
      return FALSE;
   if (GetFileVersionInfo(lpszFileName, NULL, dwSize, lpbBuffer) == FALSE)
      return FALSE;
   if (VerQueryValue(lpbBuffer, "\\", (LPVOID *) &ffi, (PUINT) &dwSize) == FALSE)
      return FALSE;
   *lpdwVersion = ((HIWORD(ffi->dwProductVersionMS) & 0xFF) << 24) | ((LOWORD(ffi->dwProductVersionMS) & 0xFF) << 16) | ((HIWORD(ffi->dwProductVersionLS) & 0xFF) << 8) | (LOWORD(ffi->dwProductVersionLS) & 0xFF);
   VirtualFree(lpbBuffer, 0lu, MEM_RELEASE);
   s = (char *) &lpszFileName[strlen(lpszFileName)-1];
   while (*s != '\\' && s > (char *) lpszFileName)
      s--;
   s++;
   sprintf(lpExeInfoString, "%s %02u/%02u/%02u %02u:%02u:%02u %lu", s, st.wMonth, st.wDay, st.wYear % 100, st.wHour, st.wMinute, st.wSecond, dwTotalSize);
   *lpdwChecksum = dwVariables[2];
   return TRUE;
}


Would appreciate some help vL!
Thanks

Arta

Nobody will be interested in helping you if you don't try harder to help yourself. I already gave you some sound advice: go learn about pointers. You're not going to accomplish anything quickly if you persist with this trial and error approach. Go and read up about the language and learn some stuff. Then come back to this.

Kp

Quote from: Spilled[DW] on October 24, 2005, 02:26 PMWell like i said im still learning so im sorry about that so go ahead and flame me, Now that I have gotten that to work passing the DWORD* to function is giving me an error....

Would appreciate some help vL!
Thanks

A very cursory glance through your code shows several mistakes, some of which the compiler is not going to catch for you because you've used constructs which convince it (wrongly!) that you know what you're doing.  Stop thinking like this is VB, and stop using CopyMemory unnecessarily.  It's prototyped as taking void pointers, which makes it very dangerous for you right now.

I'd tell you what you're doing wrong, but I agree with Arta.  Besides which, the last time I gave you advice, you proceeded to completely ignore me.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Spilled

Quote from: Kp on October 24, 2005, 08:16 PM
Quote from: Spilled[DW] on October 24, 2005, 02:26 PMWell like i said im still learning so im sorry about that so go ahead and flame me, Now that I have gotten that to work passing the DWORD* to function is giving me an error....

Would appreciate some help vL!
Thanks

A very cursory glance through your code shows several mistakes, some of which the compiler is not going to catch for you because you've used constructs which convince it (wrongly!) that you know what you're doing. Stop thinking like this is VB, and stop using CopyMemory unnecessarily. It's prototyped as taking void pointers, which makes it very dangerous for you right now.

I'd tell you what you're doing wrong, but I agree with Arta. Besides which, the last time I gave you advice, you proceeded to completely ignore me.

The last time you gave me advice I didn't ignore it, I just didn't understand what you were talking about if I recal right. As for the reading a book, I currently am reading C++ for dummies, which is where I got the dev-C++ compiler. Was just asking what I was doing wrong, but it's ok. I'll go and read somemore. Thanks guys.

Spilled[DW]

Arta

Btw, if you have a problem with some code and you really can't see the mistake, do feel free to post a *small* snippet - people will generally be willing to look at that. Practically no one, however, wants to dig through 100+ lines of code.

Spilled

Quote from: Arta[vL] on October 25, 2005, 05:43 AM
Btw, if you have a problem with some code and you really can't see the mistake, do feel free to post a *small* snippet - people will generally be willing to look at that. Practically no one, however, wants to dig through 100+ lines of code.

I applogize about that. As for your advice, I've read page after page today and I have gotten the values I needed to pass to CheckVersion in the Correct variables except for ExeInfo, in which I am working on currently. Thanks for the help and advice and also the flaming ;)

Kp

Quote from: Kp on October 23, 2005, 10:27 AMThose DLLs are unsupported.  Use BNLS or BNCSutil, depending on whether you want remote or local computations.

Quote from: Spilled[DW] on October 25, 2005, 12:31 AM
Quote from: Kp on October 24, 2005, 08:16 PMI'd tell you what you're doing wrong, but I agree with Arta. Besides which, the last time I gave you advice, you proceeded to completely ignore me.
The last time you gave me advice I didn't ignore it, I just didn't understand what you were talking about if I recal right. As for the reading a book, I currently am reading C++ for dummies, which is where I got the dev-C++ compiler. Was just asking what I was doing wrong, but it's ok. I'll go and read somemore. Thanks guys.

I see no indication that you even responded to my advice, much less heeded it or even attempted to understand it.  Indeed, the very next post you made after I suggested BNLS || BNCSutil shows you persisting in digging for inferior code, when the tools I suggested are easily available, well known here, and therefore easier to support here.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!