This release is a package of updated tools I have been working on regarding PK2 files. At this point, I fully understand the PK2 structures so I can easily read and write them. However, as with any complex process, it takes a lot of time and progress to come up with final polished solutions that give people everything they want. This release is a step in that direction. Included are 5 updated tools: Builder.exe, Defragmenter.exe, Editor.exe, Extractor.exe, and Lister.exe. Please refer to the Instructions section for a brief overview and then the Screenshots section to see more specific information.
The highlights of this new code is as follows:
* Updated PK2 reading code to work one directory at a time. This reduces overall memory usage and increases processing speed for quick tasks.
* Fully implemented the PK2 structure. All known fields and logic have been worked out. (* There is one potential thing left for testing, but it's not a huge concern for now)
* Updated the PK2Extractor to be really simple now. It does include more features than the older VB6 version though, such as being able to extract folders w/ children, see the file size, support multiple blowfish keys, and would show/extract all PK2 entries (there are some bugs in the VB6 version in this regards).
* Added a PK2Builder class for building new Pk2s. Through this logic, the Defragmenter is easily coded as well.
* Updated Defragmenter logic using PK2Builder and PK2Reader. It's a lot simpler now and easy to follow and use.
* Updated the old PK2Writer code that is dependent on GFXFileManager.dll. While I am working on code to replace this, it is still the primary means for editing Pk2 files without using a DownloadServer.
* Using updated core code for Blowfish and some other shared files in the Common folder.
While I have done quite a bit of testing with this code, I always find various bugs here and there in all my work, so please make backup copies of all your stuff before you use anything in case something goes wrong. While I try to make sure I get serious bugs out of the way, it is possible I might have missed some, but only extensive use of the tools will show that. I don't have an active dev machine for Windows 7 up yet, so I've only been able to test on XP myself so far.
Instructions:
Screens:Quote:
PK2Tools
pushedx
Builder.exe
Builds new PK2s from existing folders.
Usage:
Builder <input folder> <output name> <key index>
"input folder" - The path to the folder to create a PK2 of.
"output name" - The title of the PK2, do not add an extension.
"key index" - 0 for standard PK2 key, 1 for non-standard PK2 key (ZSZC, SWSRO)
Example:
Builder "C:\MyData" "mydata" 0
Defragmenter.exe
Defragments existing PK2s into optimized versions.
Usage:
Defragmenter <pk2>
"pk2" - The full path to the PK2 file to defragment. The output is saved
into this directory, so make sure you have Admin access to it.
*** Your PK2s are NOT modified in any way. ***
Example:
Defragmenter "C:\Program Files\Silkroad\media.pk2"
Lister.exe
Generates a log file of all PK2 entries.
Usage:
Lister <pk2>
"pk2" - The full path to the PK2 file to defragment. The output is saved
into this directory, so make sure you have Admin access to it.
*** Your PK2s are NOT modified in any way. ***
Example:
Lister "C:\Program Files\Silkroad\media.pk2"
Editor.exe
Allows adding new files and folders to a PK2.
*** GFXFileManager.dll must be in the same folder as the PK2 you are editing!
Extractor.exe
Allows extracting files from a PK2.
Builder.exe




Defragmenter.exe




Editor.exe



Extractor.exe






Lister.exe


Virus Scan:

Download: Attached (binary + source)
FAQ:
Q. Can I delete files?
A. Not yet! You can extract all files in a PK2 first, then run the builder on that folder after removing the files you no longer wish. That is not optimal for deleting a file or two, but if you really want the file gone...
Q. Is there a faster way to delete a file?
A. You can import in a new file with the same name and a 0 length to clear the content. But that's it. The PK2 structure was not really meant to have files deleted "easily" due to how the DownloadServer was setup.
Q. Can I use these tools with the older tools?
A. No. The older tools, most notably the PK2Reader, contain serious bugs that can cause problems or crashes. Use the new versions and report any bugs that you come across since they are now the current versions.
Q. What is the Lister for?
A. Since the PK2Extractor no longer has search capabilities, this tool has been added so users can at least use a document editor and find files as needed.
Q. Can I use the Builder for non-Silkroad stuff?
A. Yes! I have included the source code in a PK2 file to show this. However, the PK2 format is rather a lousy archive format, so it's not really recommended to use the PK2 format in place of something else outside of Silkroad. You can if you want though.
Q. After using the Defragmenter, Editor, or Builder, the PK2 files no longer work with Silkroad?
A. They should, please report the bug and be as detailed as you can as to what you were doing, which versions of Silkroad you were using, and any other useful information that could help me find the error and fix it.
End
Enjoy! Please report any bugs or leave feedback. Community involvement helps make for better tools and knowledge for everyone! I'll work on getting any reported bugs fixed over the weekend.






