C# Extracting Dev CID from Chkn

DataMine
by DataMine · 7 posts
10 years ago in .Net (C#, VB, etc)
Posted 10 years ago · Author
This is a method for extracting the developer cid out of a chkn file. I do not know what this could be used for yet but I accidentally made it while trying to modify the contents of a chkn.

This method works on the following logic:
Step 1: Open chkn file as an archive
Step 2: Search for the index file inside the archive
Step 3: Load contents of index file to string
Step 4: Look for the developer cid line
Step 5: extract cid from line
Step 6: return it to the user

This method requires an external library "Zipforge". You can download it here: http://www.componentace.com/.NET_zip_co ... pforge.htm

assemblies:
Code
using System.IO;
using ComponentAce.Compression.ZipForge;
using ComponentAce.Compression.Archiver;


Code
private void getDev_CID(string file)
{
   ZipForge archiver = new ZipForge();
   archiver.FileName = file;
   archiver.OpenArchive(FileMode.Open);
   ArchiveItem archiveItem = new ArchiveItem();

   string start = "<developer_id>", end = "</developer_id>";
   string cid = null;
   string temp_index;

   archiver.BeginUpdate();

   if (archiver.FindFirst("index.xml", ref archiveItem))
   {
      archiver.EndUpdate();

      archiver.ExtractToString("index.xml", out temp_index);

      if (temp_index.Contains(start) && temp_index.Contains(end))
      {
         int Pos1 = temp_index.IndexOf(start) + start.Length;
         int Pos2 = temp_index.IndexOf(end);

         cid = temp_index.Substring(Pos1, Pos2 - Pos1);

         if (!String.IsNullOrEmpty(cid))
         {
            MessageBox.Show(cid, "Cid Found", MessageBoxButtons.OK, MessageBoxIcon.None);
         }
         else
         {
            MessageBox.Show("CID is empty!", "No CID", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
      }
      else
      {
         MessageBox.Show("Index doesn't contain dev cid!", "No CID", MessageBoxButtons.OK, MessageBoxIcon.Error);
      }
   }
   else
   {
      MessageBox.Show("No Index file found!", "No Index", MessageBoxButtons.OK, MessageBoxIcon.Error);
   }
   archiver.CloseArchive();
}



Example usage:
Code
private void button2_Click(object sender, EventArgs e)
{
   openFileDialog1.CheckFileExists = true;
   openFileDialog1.CheckPathExists = true;
   openFileDialog1.DefaultExt = "chkn";
   openFileDialog1.FileName = "";
   openFileDialog1.Filter = "Text Files (*.chkn)|*.chkn|All Files (*.*)|*.*";
   openFileDialog1.Multiselect = false;
   if (openFileDialog1.ShowDialog() == DialogResult.OK)
   {
      getDev_CID(openFileDialog1.FileName);
   }           
}



I am sure there some more efficient ways of doing this. I welcome all code improvements or ideas.
Posted 7 years ago
well i can think of some way it can be used so lets say i have a product ready made question if i edit the index xml using this and let say my product is derived from somewhere i edit the index can i put another pid in there so my product is derived from another product?
Posted 7 years ago · Author
Adryan® wrote:
well i can think of some way it can be used so lets say i have a product ready made question if i edit the index xml using this and let say my product is derived from somewhere i edit the index can i put another pid in there so my product is derived from another product?


Yes but that will most likely break the product. It takes more work than simple modifying the parent pid to break a product from a derive chain AND make it a working product.
Posted 7 years ago
D.M wrote:
Adryan® wrote:well i can think of some way it can be used so lets say i have a product ready made question if i edit the index xml using this and let say my product is derived from somewhere i edit the index can i put another pid in there so my product is derived from another product?Yes but that will most likely break the product. It takes more work than simple modifying the parent pid to break a product from a derive chain AND make it a working product.


Well, I have done this on plenty of products already.
Though, I took some of the assets from another file
itself and replaced it in the mesh file and it worked
properly for me. As far as certain products that I still
have yet to come across to do this method and having an issue
with, I haven't experienced anything as of yet. So, I was
able to break products from the derive chain since a majority
of the users I go for as disabled, even the parents.
Posted 7 years ago · Author
sameswitch wrote:
D.M wrote: Adryan® wrote:well i can think of some way it can be used so lets say i have a product ready made question if i edit the index xml using this and let say my product is derived from somewhere i edit the index can i put another pid in there so my product is derived from another product?Yes but that will most likely break the product. It takes more work than simple modifying the parent pid to break a product from a derive chain AND make it a working product.Well, I have done this on plenty of products already.
Though, I took some of the assets from another file
itself and replaced it in the mesh file and it worked
properly for me.As far as certain products that I still
have yet to come across to do this method and having an issue
with, I haven't experienced anything as of yet. So, I was
able to break products from the derive chain since a majority
of the users I go for as disabled, even the parents.



Correct, that's what I meant by "more work".
Posted 5 years ago
does zipforge not work for VS 2017?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here

SIGN IN NOW

Create an account

Sign up for a new account in our community. It's easy!

REGISTER A NEW ACCOUNT
Select a forum Protection     Help & Support     Introductions     Mafia News     IMVU News General Discussion     IMVU Lounge        IMVU Series / Roleplaying        Social Games     Mafia Market     Mafia Tools        Premium IMVU Tools        Off Topic Tools     Off Topic     Contests Creator Corner     Graphics Design        Photoshop        GIMP     Basic Creator Help     Catalog And Product Showcase     3D Meshing        3Ds Max        Sketchup        Blender Gangsters with Connections     White Hat Activities        Google Hacking        Trackers Programming Corner     Coding        Python        .Net (C#, VB, etc)        Flash        JAVA        Autoit        Batch        HTML & CSS        Javascript        PHP        Other        IMVU Homepage Codes           General           About me Panel           Messages Panel           Special Someone Panel           Visitors Panel           New Products Panel           Rankings Panel           Wishlist Panel           My Badges Panel           Outfits Panel           Url Panel           Groups Panel           Slideshow Panel           My Room Panel           Sandbox panel           Layouts     Help & Requests Free Credits     Approved Methods     Submit Methods Free Money     Approved Methods     Submit Methods Adult Corner     Get Mafia AP Here     AP Lounge        AP Social Games        Casual Dating Tips     IMVU Slave Market & Escorts