[Release] MRS DLL for Programmers


Is this a new version or something really diff.? And a new idea : Make an editor to edit .DLL files <3.

I'm inclined to think you have no idea what a DLL is.

Anyway, since the C++ code given in his example was a little botched and a little hard to read, I made a simple little project showing how to implement the DLL in C++ (using Visual Studio 2005, not sure if it'll work in 2008, I doubt it in a way).

Code:
#include <windows.h>
#include <iostream>
using namespace std;

typedef bool (__stdcall* _OpenMRSFile)(char* MRSFileName);
typedef bool (__stdcall* _CloseMRSFile)();
typedef int (__stdcall* _GetFileCount)();
typedef char* (__stdcall* _GetFileName)(int Index);

int main(int argc, char* argv[])
{
    _OpenMRSFile OpenMRSFile;
    _CloseMRSFile CloseMRSFile;
    _GetFileCount GetFileCount;
    _GetFileName GetFileName;
    HINSTANCE hInst = LoadLibrary(TEXT("MRSDLL.dll"));

    OpenMRSFile = (_OpenMRSFile)GetProcAddress(hInst, "OpenMRSFile");
    CloseMRSFile = (_CloseMRSFile)GetProcAddress(hInst, "CloseMRSFile");
    GetFileCount = (_GetFileCount)GetProcAddress(hInst, "GetFileCount");
    GetFileName = (_GetFileName)GetProcAddress(hInst, "GetFileName");

    if(OpenMRSFile("model.mrs"))
    {
        for(int i = 0; i < GetFileCount(); i++)
        {
            cout << "file " << i << ": " << GetFileName(i) << "\n";
        }

        CloseMRSFile;
    }

    return 0;
}

Opens model.mrs and shows all the files in it. Simple enough.
 
Thanks RoA, a little note to C++ users, when putting a full path use double backslashes.

Example Wrong: C:\IJJI\Gunz\system.mrs
Example Right: C:\\IJJI\\Gunz\\system.mrs
 
Just a note to everyone. This is really not a thread to read if your not into programming.
ThievingSix is kind enough to provide us with a very usefull, basic source to unpack an .mrs file.
The goal of this release is to get people like me to get and extend the source, build an eviroment around it, and especialy getting things off the to-do list. If you really want to help, I suggest you learn the basic of programming the source, which lies in C++.

Learn C++:
 
I'm inclined to think you have no idea what a DLL is.

Anyway, since the C++ code given in his example was a little botched and a little hard to read, I made a simple little project showing how to implement the DLL in C++ (using Visual Studio 2005, not sure if it'll work in 2008, I doubt it in a way).

Code:
#include <windows.h>
#include <iostream>
using namespace std;

typedef bool (__stdcall* _OpenMRSFile)(char* MRSFileName);
typedef bool (__stdcall* _CloseMRSFile)();
typedef int (__stdcall* _GetFileCount)();
typedef char* (__stdcall* _GetFileName)(int Index);

int main(int argc, char* argv[])
{
    _OpenMRSFile OpenMRSFile;
    _CloseMRSFile CloseMRSFile;
    _GetFileCount GetFileCount;
    _GetFileName GetFileName;
    HINSTANCE hInst = LoadLibrary(TEXT("MRSDLL.dll"));

    OpenMRSFile = (_OpenMRSFile)GetProcAddress(hInst, "OpenMRSFile");
    CloseMRSFile = (_CloseMRSFile)GetProcAddress(hInst, "CloseMRSFile");
    GetFileCount = (_GetFileCount)GetProcAddress(hInst, "GetFileCount");
    GetFileName = (_GetFileName)GetProcAddress(hInst, "GetFileName");

    if(OpenMRSFile("model.mrs"))
    {
        for(int i = 0; i < GetFileCount(); i++)
        {
            cout << "file " << i << ": " << GetFileName(i) << "\n";
        }

        CloseMRSFile;
    }

    return 0;
}
Opens model.mrs and shows all the files in it. Simple enough.

so for system.mrs is...

Code:
#include <windows.h>
#include <iostream>
using namespace std;

typedef bool (__stdcall* _OpenMRSFile)(char* MRSFileName);
typedef bool (__stdcall* _CloseMRSFile)();
typedef int (__stdcall* _GetFileCount)();
typedef char* (__stdcall* _GetFileName)(int Index);

int main(int argc, char* argv[])
{
    _OpenMRSFile OpenMRSFile;
    _CloseMRSFile CloseMRSFile;
    _GetFileCount GetFileCount;
    _GetFileName GetFileName;
    HINSTANCE hInst = LoadLibrary(TEXT("MRSDLL.dll"));

    OpenMRSFile = (_OpenMRSFile)GetProcAddress(hInst, "OpenMRSFile");
    CloseMRSFile = (_CloseMRSFile)GetProcAddress(hInst, "CloseMRSFile");
    GetFileCount = (_GetFileCount)GetProcAddress(hInst, "GetFileCount");
    GetFileName = (_GetFileName)GetProcAddress(hInst, "GetFileName");

    if(OpenMRSFile("system.mrs"))
    {
        for(int i = 0; i < GetFileCount(); i++)
        {
            cout << "file " << i << ": " << GetFileName(i) << "\n";
        }

        CloseMRSFile;
    }

    return 0;
}
 
so for system.mrs is...

Code:
#include <windows.h>
#include <iostream>
using namespace std;

typedef bool (__stdcall* _OpenMRSFile)(char* MRSFileName);
typedef bool (__stdcall* _CloseMRSFile)();
typedef int (__stdcall* _GetFileCount)();
typedef char* (__stdcall* _GetFileName)(int Index);

int main(int argc, char* argv[])
{
    _OpenMRSFile OpenMRSFile;
    _CloseMRSFile CloseMRSFile;
    _GetFileCount GetFileCount;
    _GetFileName GetFileName;
    HINSTANCE hInst = LoadLibrary(TEXT("MRSDLL.dll"));

    OpenMRSFile = (_OpenMRSFile)GetProcAddress(hInst, "OpenMRSFile");
    CloseMRSFile = (_CloseMRSFile)GetProcAddress(hInst, "CloseMRSFile");
    GetFileCount = (_GetFileCount)GetProcAddress(hInst, "GetFileCount");
    GetFileName = (_GetFileName)GetProcAddress(hInst, "GetFileName");

    if(OpenMRSFile("system.mrs"))
    {
        for(int i = 0; i < GetFileCount(); i++)
        {
            cout << "file " << i << ": " << GetFileName(i) << "\n";
        }

        CloseMRSFile;
    }

    return 0;
}

You are correct unless the system.mrs isn't in the same folder that the DLL is in. I recommend full file paths such for the DLL and the MRS file.
 
Back