Welcome to the RaGEZONE - MMORPG development forums.

ZMRS Class

This is a discussion on ZMRS Class within the GunZ Development forums, part of the Gunz Online category; Alright so, I'm currently working on an open-source MRS class. I started on it last night and I'm now up ...

Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    Addicted to Bacon
    Rank
    Member +
    Join Date
    Sep 2007
    Posts
    1,098
    Liked
    488

    ZMRS Class

    Alright so, I'm currently working on an open-source MRS class. I started on it last night and I'm now up to reading the file + extracting it. I still need to add checking to see if the archive is a ZIP, MRS, or encrypted. I'll be adding a little method for you to place your won encryption for the MRS files, and soon I'll be moving Gunz to 7z as ColdFX keeps bitching at me to do.

    Example of ZMRS.cpp:

    Code:
    #include "Stdafx.h"
    #include "ZMRS.h"
    
    ZMRS::ZMRS(char *szFile)
    {
        FHeaderTemp = new FileHeader( );
        EndOfDir = new EndOfDirectory( );
        MRS *zMRS = new MRS( );
    
        FileHandle = CreateFileA ( szFile, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, 0 );
        
        if ( FileHandle == INVALID_HANDLE_VALUE ) return;
    
        SetFilePointer ( FileHandle, -22, NULL, FILE_END );
        Temp = (unsigned char *)malloc(26);
    
        if(readData (Temp,26))
        {
            memcpy ( EndOfDir,Temp,26);
            if ( EndOfDir->Signature == 0x5030208 )
            {
                SetFilePointer(FileHandle,(EndOfDir->SizeOfDirectory + EndOfDir->ZipFileCommentLen + 22) * -1,NULL,FILE_END);
                FileCount = EndOfDir->NumOfFiles;
                
                for ( int i = 0; i < FileCount; i++)
                {
    
                    if (!readData(FHeaderTemp,46))
                        return;
                    strcpy ( FHeaderTemp->FileName , getString ( FHeaderTemp->FileNameLen ));
                    FHeaderTemp->FileName[FHeaderTemp->FileNameLen] = 0;
                    strcpy(zMRS->szFile,FHeaderTemp->FileName);
                    zMRS->dwCRC = FHeaderTemp->CRC332;
                    zMRS->dwMagic = FHeaderTemp->RelativeOffset;
    
                    MRSFiles.push_back(zMRS);
                    zMRS = new MRS( );
                    FHeaderTemp = new FileHeader( );
    
                }
    
            }
        }
    }
    
    ZMRS::~ZMRS(void)
    {
    }
    
    void ZMRS::decryptData ( BYTE *pBuffer, int iLen)
    {
        for ( ; iLen >= 0; iLen--, pBuffer++ )
            *pBuffer = ~static_cast<unsigned char>((*pBuffer>>3)|(*pBuffer<<5));
    }
    
    void ZMRS::encryptData ( BYTE *pBuffer, int iLen)
    {
        for ( ; iLen >= 0; iLen--, pBuffer++ )
            *pBuffer = ~static_cast<unsigned char>((*pBuffer>>5)|(*pBuffer<<3));
    }
    
    
    bool ZMRS::readData ( void *pBuffer, int iLen )
    {
        DWORD dwReadBytes = 0;
    
        if (!ReadFile ( FileHandle, pBuffer, iLen, &dwReadBytes, NULL))
            return false;
    
        unsigned char *mall = (unsigned char *)malloc ( dwReadBytes );
        memcpy ( mall, pBuffer, dwReadBytes );
        decryptData ( mall , dwReadBytes );
        memcpy ( pBuffer, mall, dwReadBytes);
        return true;
    }
    
    char *ZMRS::getString ( int iCount )
    {
        char *szBuffer = ( char * ) malloc ( iCount );
        ZeroMemory ( szBuffer , iCount );
        if ( !readData ( szBuffer, iCount ) ) return NULL;
        return szBuffer;
    }
    
    void ZMRS::printData ( )
    {
        for each (MRS *mrs in MRSFiles)
        {
            printf ("File: [%s]. CRC32: [%u]. Relative Offset: [%u]\n",mrs->szFile, mrs->dwCRC, mrs->dwMagic);
        }
    }

    A lot of thanks to T6 for helping me out, lol. Also, Buga and Coldfx don't come bitching about me not freeing the memory. I was having slight issues with using free(); Like in readData(); I did:
    Code:
    free(&mall);
    and I get a heap error. Was annoying so I just left it.

  2. #2
    Apeopex Programmer
    Rank
    Member +
    Join Date
    Mar 2007
    Location
    California
    Posts
    963
    Liked
    37

    Re: ZMRS Class

    There is already an open source MRS class out there. People just won't use it....

    Also I really don't see the benefits of 7z..waste of time.

    Move the stuff(signatures, sizes, etc) to constants.

    Why are you reading to a temp variable then moving it..?

    Drop the FILE_FLAG's, they don't work like they should.

    Why are you zeroing memory right before you fill it with something..?

    Why are you allowing a delete share when you are reading from the file..?


    Kay, done with rant lmfao. I'm up really late so don't mind me xD
    Oh how I miss the old days.

  3. #3
    Guy
    Contributor
    Rank
    Member +
    Join Date
    Apr 2009
    Posts
    938
    Liked
    169

    Re: ZMRS Class

    Quote Originally Posted by ThievingSix View Post
    There is already an open source MRS class out there. People just won't use it....

    Also I really don't see the benefits of 7z..waste of time.

    Move the stuff(signatures, sizes, etc) to constants.

    Why are you reading to a temp variable then moving it..?

    Drop the FILE_FLAG's, they don't work like they should.

    Why are you zeroing memory right before you fill it with something..?

    Why are you allowing a delete share when you are reading from the file..?


    Kay, done with rant lmfao. I'm up really late so don't mind me xD
    Considering the boost you receive for file compression over MZIP, ZIP, RAR, etc I'd consider that a pretty substantial benefit.

    And I already pointed Jacob to CBWhiz'z old makeshift function - granted, there's still been others, iirc..

    Also, why aren't you using free()?!

  4. #4
    Apeopex Programmer
    Rank
    Member +
    Join Date
    Mar 2007
    Location
    California
    Posts
    963
    Liked
    37

    Re: ZMRS Class

    Eh size isn't a big deal to me is all, probably is to others xD.

    "And I already pointed Jacob to CBWhiz'z old makeshift function - granted, there's still been others, iirc.."

    ?
    Oh how I miss the old days.

  5. #5
    Guy
    Contributor
    Rank
    Member +
    Join Date
    Apr 2009
    Posts
    938
    Liked
    169

    Re: ZMRS Class

    Quote Originally Posted by ThievingSix View Post
    Eh size isn't a big deal to me is all, probably is to others xD.

    "And I already pointed Jacob to CBWhiz'z old makeshift function - granted, there's still been others, iirc.."

    ?
    There is already an open source MRS class out there. People just won't use it....
    Jacob's problems on MSN were mainly encrypting/decrypting the MZIP archive - I recommended he take a look at the couplet of functions for encryption/decryption CB had released eons ago - or, just take a look at the source of the projects you've worked on, relating to MZIP.

  6. #6
    Addicted to Bacon
    Rank
    Member +
    Join Date
    Sep 2007
    Posts
    1,098
    Liked
    488

    Re: ZMRS Class

    Quote Originally Posted by gWX0 View Post
    Jacob's problems on MSN were mainly encrypting/decrypting the MZIP archive - I recommended he take a look at the couplet of functions for encryption/decryption CB had released eons ago - or, just take a look at the source of the projects you've worked on, relating to MZIP.
    No my main issue was using zlib and read what I said about free() nab

  7. #7
    Apeopex Programmer
    Rank
    Member +
    Join Date
    Mar 2007
    Location
    California
    Posts
    963
    Liked
    37

    Re: ZMRS Class

    I gave you zlib source...do you want source on how to use it? Should have juts asked.
    Oh how I miss the old days.

  8. #8
    Addicted to Bacon
    Rank
    Member +
    Join Date
    Sep 2007
    Posts
    1,098
    Liked
    488

    Re: ZMRS Class

    It was before that when I was having issues, lol. It was like 4 pm when I talked to him

  9. #9
    Guy
    Contributor
    Rank
    Member +
    Join Date
    Apr 2009
    Posts
    938
    Liked
    169

    Re: ZMRS Class

    Quote Originally Posted by ThePhailure772 View Post
    No my main issue was using zlib and read what I said about free() nab
    That's not what she said.

  10. #10
    Ultimate Member
    Rank
    Member
    Join Date
    Aug 2006
    Posts
    184
    Liked
    1

    Re: ZMRS Class

    The point of making this project of yours public is 0... as T6 said. No one used his. I doub't many people will know how to compile it anyway. People can already write their own encryptions. When they write their encryption into this, they will ask how they can write it into their Gunz.exe

    You might aswell keep it a private project...

  11. #11
    Guy
    Contributor
    Rank
    Member +
    Join Date
    Apr 2009
    Posts
    938
    Liked
    169

    Re: ZMRS Class

    Quote Originally Posted by Gunner54 View Post
    The point of making this project of yours public is 0... as T6 said. No one used his. I doub't many people will know how to compile it anyway. People can already write their own encryptions. When they write their encryption into this, they will ask how they can write it into their Gunz.exe

    You might aswell keep it a private project...
    Part of the project is a signature searcher for finding the MRS algorithm in a specific client, then replacing it.

    Anyways, this topic is just intended to provide assistance to Phail - not to convince him to quit his project altogether.

  12. #12
    Apeopex Programmer
    Rank
    Member +
    Join Date
    Mar 2007
    Location
    California
    Posts
    963
    Liked
    37

    Re: ZMRS Class

    Quote Originally Posted by gWX0 View Post
    Anyways, this topic is just intended to provide assistance to Phail - not to convince him to quit his project altogether.
    Damn, I seemed to miss the entire point of this thread =(
    Oh how I miss the old days.

  13. #13
    Ultimate Member
    Rank
    Member
    Join Date
    Aug 2006
    Posts
    184
    Liked
    1

    Re: ZMRS Class

    You might aswell keep it a private project...
    Thats why i said that ^

  14. #14
    Guy
    Contributor
    Rank
    Member +
    Join Date
    Apr 2009
    Posts
    938
    Liked
    169

    Re: ZMRS Class

    Quote Originally Posted by Gunner54 View Post
    Thats why i said that ^
    That has nothing to do with what anyone has said..

  15. #15
    Baned
    Rank
    Member +
    Join Date
    Nov 2008
    Posts
    610
    Liked
    0

    Re: ZMRS Class

    Quote Originally Posted by Gunner54 View Post
    The point of making this project of yours public is 0... as T6 said. No one used his. I doub't many people will know how to compile it anyway. People can already write their own encryptions. When they write their encryption into this, they will ask how they can write it into their Gunz.exe

    You might aswell keep it a private project...
    I tried T6's delphi sources, but I'm not at delphi yet...
    And yes, there are people that would know how to use this.
    Gone & Left technology.

 

 
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •