Register for your free account! | Forgot your password?

Go Back   elitepvpers > Popular Games > Silkroad Online > SRO Coding Corner
You last visited: Today at 13:13

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Release] C# Pk2 Reader (Including sourcecode)

Discussion on [Release] C# Pk2 Reader (Including sourcecode) within the SRO Coding Corner forum part of the Silkroad Online category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Mar 2009
Posts: 48
Received Thanks: 75
Post [Release] C# Pk2 Reader (Including sourcecode)

Hey guys,
today I want to release my Pk2Reader to you.
It's based on "bloodman"'s original class.

I Added alot of methods/functions to it and cleaned it up totaly.

[Features]
- Read .pk2 files with any Blowfish key
- Extract file(s) out of it
- Work around with .pk2 files

[Bugs]
- Nothing found (yet)

[Available Functions/Methods]
-
Quote:
- ExtractFile(File File, string OutputPath) (+1 overflow)
Extract any file out of the .pk2 and save it to HDD
Quote:
- GetFileExtension(File File) --> string (+1 overflow)
Return the file extension of any file located inside the .pk2 (e.g ".txt")
Quote:
- GetRootFiles() --> List<File>
Returns a list of all files within the root folder
Quote:
- GetRootFolders() --> List<Folder>
Returns a list of all folders within the root folder
Quote:
- GetFiles(string ParentFolder) --> List<File>
Returns a list of all files within a specific folder
Quote:
- GetSubFolders(string ParentFolder) --> List<Folder>
Returns a list of all folders within a specific folder
Quote:
- FileExists(string Name) --> Boolean
Returns if the file you've been searching for exsist inside the .pk2
Quote:
- GetFileBytes(string Name) --> Byte[] (+1 overflow)
Returns the requested file as Byte[]
Quote:
- GetFileText(string Name) --> string (+1 overflow)
Returns the file text (e.g in itemdata_XY.txt)
Quote:
- GetFileStream(string Name) --> System.IO.Stream (+1 overflow)
Returns the stream of a file (e.g Image.FromStream(this_function))
Quote:
- GetFileNames() --> List<string>
Returns a list with all filenames
Download:
Compiled (.dll)

Source (.zip)

Example (.zip)

Mini.pk2 (used in example)

(Blowfishkey = "test")


Conclusion:
I hope it helps you to create your own .pk2 extractor. Feel free to add your own stuff and post it into this thread. Also feel free to add me to your skype contacts: MrLordschaft.
Thanks for reading.

PS: If you know how to code a writer, please tell me.
torstmn is offline  
Thanks
9 Users
Old 03/10/2013, 20:09   #2
 
3DProgrammer's Avatar
 
elite*gold: 0
Join Date: Feb 2012
Posts: 133
Received Thanks: 98
Thanks for the release, but i already know how to do that (though more functions than i know)
If you knew how write tell me xD

#Edit : ExtractFile, It writes the data and never close the writer ^^
3DProgrammer is offline  
Old 03/10/2013, 21:40   #3
 
elite*gold: 130
Join Date: Mar 2008
Posts: 2,485
Received Thanks: 934
Awesome, let's snap our jaws on another small bit of C# code!

Currently examining it. :3
intercsaki is offline  
Old 03/11/2013, 00:46   #4
 
elite*gold: 0
Join Date: May 2009
Posts: 67
Received Thanks: 37
Nice to see that someone did something with my code.
You should try importing files as well. That should be a bit more of a challenge.
theonly112 is offline  
Old 03/11/2013, 02:23   #5

 
鳳凰城's Avatar
 
elite*gold: 273
Join Date: Aug 2012
Posts: 4,451
Received Thanks: 2,429
Going to test / review the results.

Result as your code:
And , where's the extract point? It only reads right?
I may work a lil bit on it but as a form * I hate consoles * and , I will post my final modified version.
鳳凰城 is offline  
Thanks
1 User
Old 03/11/2013, 08:49   #6
 
elite*gold: 0
Join Date: Mar 2009
Posts: 48
Received Thanks: 75
@phoenix1337:
The example is just an example. You can also work with a GUI instead of a console.

For extracting a file:
<Instance of Reader>.ExtractFile(File file, string OutputPath)

UPDATE:
- Fixed "ExtractFile()" - Writer now closes... (thx for the report)

Download (.dll)


Download source (.zip)
torstmn is offline  
Old 03/11/2013, 13:31   #7

 
鳳凰城's Avatar
 
elite*gold: 273
Join Date: Aug 2012
Posts: 4,451
Received Thanks: 2,429
Why do you use it in dll format? + Every command in your console , it closes the console automatically .
鳳凰城 is offline  
Thanks
1 User
Old 03/11/2013, 14:38   #8
 
elite*gold: 130
Join Date: Mar 2008
Posts: 2,485
Received Thanks: 934
Well, dll can be easily imported and used in applications. But one can use the source included, just bother to copy everything. Pros and cons at both side.
intercsaki is offline  
Old 03/11/2013, 20:02   #9
 
LastThief*'s Avatar
 
elite*gold: 60
Join Date: Feb 2012
Posts: 3,942
Received Thanks: 6,474
Quote:
Originally Posted by Phoenix 1337 View Post
Why do you use it in dll format? + Every command in your console , it closes the console automatically .
Console.ReadLine();
LastThief* is offline  
Thanks
2 Users
Old 03/11/2013, 20:42   #10
 
lesderid's Avatar
 
elite*gold: 0
Join Date: Dec 2007
Posts: 2,400
Received Thanks: 1,517
Quote:
Originally Posted by LastThief* View Post
Console.ReadLine();
Code:
System.Console.ReadKey(true);
imo
lesderid is offline  
Thanks
2 Users
Old 03/12/2013, 23:46   #11
 
elite*gold: 0
Join Date: Jun 2009
Posts: 48
Received Thanks: 9
Quote:
Originally Posted by intercsaki View Post
Well, dll can be easily imported and used in applications. But one can use the source included, just bother to copy everything. Pros and cons at both side.
.Net DLLs source code are easy to recover. Just use ILSpy or something like that. And about copying everything... Once you have a great solution for a problem, you are noob if u dont use that... Also you shouldnt use .Net or some classes in C#... You can write them from yourself
spartai333 is offline  
Old 03/13/2013, 10:23   #12
 
LastThief*'s Avatar
 
elite*gold: 60
Join Date: Feb 2012
Posts: 3,942
Received Thanks: 6,474
Quote:
Originally Posted by spartai333 View Post
.Net DLLs source code are easy to recover. Just use ILSpy or something like that. And about copying everything... Once you have a great solution for a problem, you are noob if u dont use that... Also you shouldnt use .Net or some classes in C#... You can write them from yourself
Dude ... ?
LastThief* is offline  
Old 03/13/2013, 18:03   #13

 
鳳凰城's Avatar
 
elite*gold: 273
Join Date: Aug 2012
Posts: 4,451
Received Thanks: 2,429
Quote:
Originally Posted by spartai333 View Post
.Net DLLs source code are easy to recover. Just use ILSpy or something like that. And about copying everything... Once you have a great solution for a problem, you are noob if u dont use that... Also you shouldnt use .Net or some classes in C#... You can write them from yourself
A noob , as you've said , at least he's helping people . Unless your worthless comment which creating a false point 100%. If he's a noob , we should teach him how to manage these ***** , To become a pro.
鳳凰城 is offline  
Old 03/13/2013, 19:54   #14
 
detCode's Avatar
 
elite*gold: 0
Join Date: Nov 2011
Posts: 104
Received Thanks: 73
lets make pk2 writer

simple writer fonction

public void WriteFile(string Source, string InputPath)
{
//gösterilen dosyayı oku
System.IO.FileStream str = new System.IO.FileStream(Source, System.IO.FileMode.Open);
System.IO.BinaryReader readbnr = new System.IO.BinaryReader(str);
Byte[] data = readbnr.ReadBytes((int)str.Length);
str.Close();

//yaz
System.IO.BinaryWriter wrt = new System.IO.BinaryWriter(m_FileStream);
File file = m_Files.Find(item => item.Name.ToLower() == Source.ToLower());
wrt.BaseStream.Position = file.Position;
wrt.Write(data);
wrt.Close();
}

How to use
first extract config.txt in mini.pk2
change config.txt
pk2Reader.ExtractFile("config.ini", "config.ini");
...

Problems..
Its works but you cant write extra byte from old data lenght
detCode is offline  
Old 03/14/2013, 12:40   #15
 
elite*gold: 130
Join Date: Mar 2008
Posts: 2,485
Received Thanks: 934
Quote:
Originally Posted by LastThief* View Post
Dude ... ?
Quote:
Originally Posted by Phoenix 1337 View Post
A noob , as you've said , at least he's helping people . Unless your worthless comment which creating a false point 100%. If he's a noob , we should teach him how to manage these ***** , To become a pro.
In my opinion, the main pont was this:
Quote:
Originally Posted by spartai333 View Post
And about copying everything... Once you have a great solution for a problem, you are noob if u dont use that...
Just sayin'.
intercsaki is offline  
Reply


Similar Threads Similar Threads
[Release] Der Reader
12/22/2013 - Metin2 PServer Guides & Strategies - 130 Replies
Guten Abend Volk. Ich Präsentiere euch heute Der Reader. Was zum Teufel ist Der Reader?! Der Reader ist ein Tool was euch hilft Archiver für fremde Client´s zu erstellen. Was ließt er aus? Er ließt folgendes aus:
[Release]Base Reader
02/27/2013 - Last Chaos - 39 Replies
Hey, Ich hatte mir gestern die Engine.dll mal genaue angeschaut und einige interessante Funktionen gefunden! Gleich mal ein kleines Tool gebastelt das die besagten Funktionen ausliest. Screenshot : http://grabilla.com/02b03-725bc792-1eca-43e3-bc45 -68b3e31abc17.png Download
[Release] Compose Log Reader - PHP
09/28/2012 - EO PServer Guides & Releases - 9 Replies
Since alot of servers lately that I have seen are over ran with auto composing, I figured I would create something that allows server owners and their staff to check the compose logs easier than using notepad. What this does: Owners put their compose logs in the folder, and go to the index.php page, enter the name of the file, example: sacrifice 2012-9-20.log Then hit the "Run" buttonNote: if your compose log is huge, this may take some time to insert the data. The script goes through...
[Release] IniFile Reader!
02/27/2012 - CO2 PServer Guides & Releases - 15 Replies
Greetings Guys, I was bored so I made a dll to read your Ini files. all you need is to add the dll as a reference to your project and start using it. an example: using System; using System.Collections.Generic; using System.Linq; using System.Text;



All times are GMT +1. The time now is 13:15.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.