Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

ZMRS Class

Joined
Sep 10, 2007
Messages
970
Reaction score
815
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.
 
Reverse Engineer
Joined
Mar 19, 2007
Messages
879
Reaction score
37
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
 

Guy

Divine Celestial
Joined
Apr 4, 2009
Messages
898
Reaction score
157
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()?!
 
Reverse Engineer
Joined
Mar 19, 2007
Messages
879
Reaction score
37
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.."

?
 

Guy

Divine Celestial
Joined
Apr 4, 2009
Messages
898
Reaction score
157
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.
 
Joined
Sep 10, 2007
Messages
970
Reaction score
815
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
 
Reverse Engineer
Joined
Mar 19, 2007
Messages
879
Reaction score
37
I gave you zlib source...do you want source on how to use it? Should have juts asked.
 
Junior Spellweaver
Joined
Aug 26, 2006
Messages
157
Reaction score
2
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...
 

Guy

Divine Celestial
Joined
Apr 4, 2009
Messages
898
Reaction score
157
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.
 
Reverse Engineer
Joined
Mar 19, 2007
Messages
879
Reaction score
37
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 =(
 
Legendary Battlemage
Joined
Nov 29, 2008
Messages
600
Reaction score
0
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.
 
Mythic Archon
Joined
Apr 8, 2007
Messages
759
Reaction score
21
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...

Are there any good reasons to keep it private?

I will probably use it. I didn't use T6's because it's Delphi. Very few use Delphi so it's no wonder few used it.
 
Skilled Illusionist
Joined
May 4, 2008
Messages
304
Reaction score
41
Nice!
Off-Topic: T6, Did you block my MSN or are you just not online?! 0.o
 

Guy

Divine Celestial
Joined
Apr 4, 2009
Messages
898
Reaction score
157
Are there any good reasons to keep it private?

I will probably use it. I didn't use T6's because it's Delphi. Very few use Delphi so it's no wonder few used it.

Delphi is very easy to port - I don't know why everyone is stating they need the native C equivalent...
 
DRGunZ 2 Creator
Loyal Member
Joined
Jan 21, 2007
Messages
4,493
Reaction score
161
good luck on the project public or not :)
 
Junior Spellweaver
Joined
Aug 26, 2006
Messages
157
Reaction score
2
T6's Class could be used in C++. He compiled a DLL with Exports. Meaning it could be implemented into any language. If you really want to do something advanced with MRS Files. Your better off learning yourself how to handle them. I made a simple project a while ago to handle MRS Files when i was learning about the MRS File System. It was pretty fast at Unpacking them too.
 
Back
Top