• Welcome to Valhalla Legends Archive.
 

CheckRevision Code!! help please

Started by SubLiminaL_WolF, May 08, 2003, 12:19 PM

Previous topic - Next topic

SubLiminaL_WolF


BOOL CheckRevision(LPCTSTR lpszFileName1, LPCTSTR lpszFileName2, LPCTSTR lpszFileName3, LPCTSTR lpszValueString, DWORD * lpdwVersion, DWORD * lpdwChecksum, LPSTR lpExeInfoString, LPCTSTR lpszMpqFileName)
{
  DWORD dwMpqChecksumKeys[] = {0xE7F4CB62lu, 0xF6A14FFClu, 0xAA5504AFlu, 0x871FCDC2lu, 0x11BF6A18lu, 0xC57292E6lu, 0x7927D27Elu, 0x2FEC8733lu};
  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;
  AppendText(IDC_CHATWND, BLUE, "test1");

  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++;
  }
  AppendText(IDC_CHATWND, BLUE, "test2");
  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++;
  }
  AppendText(IDC_CHATWND, BLUE, "test3");
  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;
     AppendText(IDC_CHATWND, BLUE, "test4");
     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, NULL, NULL, &ft);
        FileTimeToSystemTime(&ft, &st);
        dwTotalSize = GetFileSize(hFile, NULL);
     }
     AppendText(IDC_CHATWND, BLUE, "test5");
     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;
           }
        }
     }
     AppendText(IDC_CHATWND, BLUE, "test6");
     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",
          lpszFileName + 5,
          st.wMonth,
          st.wDay,
          st.wYear % 100,
          st.wHour,
          st.wMinute,
          st.wSecond,
          dwTotalSize);
  *lpdwChecksum = dwVariables[2];
  AppendText(IDC_CHATWND, BLUE, "test6");
  return TRUE;
}

is that check revision only for jstr i doubt it but w/e
in the code i always seem to fail the check revision
s = strchr((char *) lpszMpqFileName, '.');
  if (s == NULL)
     return FALSE;
in the null part im using sexp for the check with the correct hashes

tA-Kane

Quote from: SubLiminaL_WolF on May 08, 2003, 12:19 PMs = strchr((char *) lpszMpqFileName, '.');
  if (s == NULL)
     return FALSE;
You're not providing a valid MPQ filename, such as IX86ver1.mpq, IX86ver5.mpq, PMACver3.mpq or XMACver0.mpq. You need to make sure that you are correctly extracting the MPQ file from the received 0x50 packet.

Quote from: SubLiminaL_WolF on May 08, 2003, 12:19 PMin the null part im using sexp for the check with the correct hashes
Are you meaning that you're doing:if (s == "SEXP")If that's the case, then that's why it's failing. Otherwise, I didn't understand what you were trying to say.
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

SubLiminaL_WolF

#2
no im doing s == sexp forget what i said there
should i declare the mpq in 0x50 as
packetbuf.insert(mpqname);
cuz i have to use the mpq in the revision

   case 0x50:
               //Mpq name & hash command
               strcpy(mpqname, buffer + 12);
               strcpy(hashcmd, buffer + 25);
               if(!CheckRevision("star\\starcraft.exe", "star\\storm.dll", "star\\battle.snp", hashcmd, &version, &checksum, exeinfo, mpqname)){
                  AppendText(IDC_CHATWND, WHITE, "%s", timestamp);
                  AppendText(IDC_CHATWND, RED, "CheckRevision() failed!\n");
                  Disconnect();
                  return;
               }
               AppendText(IDC_CHATWND, WHITE, "%s", timestamp);
               AppendText(IDC_CHATWND, WHITE, "Checking version & Cdkey...\n");
               break;

the bot im using was originally made for jstr mayb thats why bcuz its lookin for a jstr

Kp

Quote from: SubLiminaL_WolF on May 08, 2003, 04:55 PM
no im doing s == sexp forget what i said there
So sexp is an addr of something?  If so, what and where was it set?  If not, that's a syntax error.
Quote from: SubLiminaL_WolF on May 08, 2003, 04:55 PMshould i declare the mpq in 0x50 as
packetbuf.insert(mpqname);
No.  You don't insert data the server sends to you.  You extract it.
Quote from: SubLiminaL_WolF on May 08, 2003, 04:55 PM
the bot im using was originally made for jstr mayb thats why bcuz its lookin for a jstr
So you're lifting large portions of someone else's code?  Or you're just rewriting a bot you didn't write well enough to understand? :)
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Camel

checkrevision is the same for all game clients (except possibly war3?)

SubLiminaL_WolF

#5
kp its dmbot im adding and deleting alot of code i got 0x50 to work all i need is extracting mpqname cuz everytime check revision runs it says its null and thats why i get my revision fail

Kp

Quote from: SubLiminaL_WolF on May 08, 2003, 08:26 PM
kp its dmbot im adding and deleting alot of code i got 0x50 to work all i need is extracting mpqname cuz everytime check revision runs it says its null and thats why i get my revision fail
You don't need to extract the MPQname; it can be used in place.  Consult bnetdocs for the offset into the packet.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Zakath

Incidentally, I don't know how you got ahold of DMBot's source, but it was NOT as far as I know intended to be available to you. Shame on you for blatantly copying source you were never supposed to have.

* Zakath smites Subliminal Wolf
Quote from: iago on February 02, 2005, 03:07 PM
Yes, you can't have everybody...contributing to the main source repository.  That would be stupid and create chaos.

Opensource projects...would be dumb.

PaiD


Banana fanna fo fanna

Quote from: SubLiminaL_WolF on May 08, 2003, 08:26 PM
kp its dmbot im adding and deleting alot of code i got 0x50 to work all i need is extracting mpqname cuz everytime check revision runs it says its null and thats why i get my revision fail

Weren't you the one who said you built it yourself?

Zakath

Quote from: PaiD on May 11, 2003, 04:33 PM
DM bot is a Public Source

Really? When did DarkMinion release his source? If that's true, I'll be very suprised.
Quote from: iago on February 02, 2005, 03:07 PM
Yes, you can't have everybody...contributing to the main source repository.  That would be stupid and create chaos.

Opensource projects...would be dumb.

PaiD

Well I have it so it must be public then right?

Kp

Quote from: PaiD on May 11, 2003, 07:57 PM
Well I have it so it must be public then right?
Public is generally interpreted to imply that the author intended for it to be freely available.  If the code was released without the author's intent, it is usually referred to as 'leaked' instead of 'public'.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

SubLiminaL_WolF

Quote from: Zakath on May 11, 2003, 06:55 PM
Really? When did DarkMinion release his source? If that's true, I'll be very suprised.
dont smite me you bastard your the dumbass >:(