| 04-09-2008, 02:44 AM | #1 |
I'm trying to achieve the use of sfmpq.dll in C++, but there is some weird problem that has me completely stuck. I think that the problem is with memory allocation, but I'm doing all right using new BYTE[size]. I've made a simple program to read files from War3x.mpq, it can reads a small file with some KB and a big one with 2 MB. The program only works if I have this line uncommented inside the read function: char this_reserve_space_in_data_segmen_and_now_the_program_works[1000]; (found at the end of the code below) If you comment this line it crash, if you have it uncommented it leaks the buffer memory allocated every time you press a button to read file inside the .mpq (you can see it trough the task mananger). So, if someone could help me with a better implementation to read files inside mpqs or solve my problem, I've atached the source and the sample program. Here is where leaves the problem (I think): PHP Code:
|
| 04-09-2008, 10:00 AM | #2 |
I can't spot the error, but here's my version of a library that can extract files from mpq archives. |
| 04-09-2008, 10:03 AM | #3 |
Oh, here's my sfmpq function pointer initialization, in case you wanna use that. It's the default implementation that comes with sfmpq anyway. |
| 04-09-2008, 12:16 PM | #4 | |
Quote:
|
| 04-11-2008, 03:35 PM | #5 | |
Quote:
Well in the one I've posted there's also a function that adds a file/buffer to an archive. But the archive needs to be opened without the read-only flag. Other than that I don't have anything. I also have an mpqrewriter class that copies an existing archive to a new one with adjusted max hashtable size. |
| 04-11-2008, 03:36 PM | #6 | |
Quote:
Perhaps I can port it to Linux g++ when I get time. |
| 06-01-2009, 07:18 AM | #7 |
You will need either Visual C++ 2003, 2005 or 2008. Visual C++ Express 2008 works fine and is freely available. If you are using a version older than 2008 (or 2005/2003 Pro), you will need the Windows Platform SDK installed and properly configured (use 2008 if you are unsure how). |
