Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1
    Dwar
    Dwar is offline
    Veteran Dwar's Avatar
    Join Date
    2010 Mar
    Posts
    2,222
    Thanks Thanks Given 
    211
    Thanks Thanks Received 
    2,230
    Thanked in
    292 Posts
    Rep Power
    10

    deSQP Sqp archive manager Full Source

    deSQP Full C-Sharp Source is a complete project for extracting or re-packing SQP archives.

    Key features:
    • Threads
    • WPF
    • Reading and writing binary files
    • Packing and unpacking data with zLib
    • Exporting and using functions from C++ library
    • Loading libraries from resources into memory (read special notices)
    • Playing XM media (read special notices)


    How this thing works? There are two major parts
    • Actual unpacker/packer with libraries
    • File list creator

    I will not pay much attention to how exactly works deSQP (there are enough comments in source), but will describe main aspects of using library, which was written in C++ by Genz.

    SQPE.dll provides several functions for extracting data from SQP and packing them back. This library can’t create completely new SQP archive or add new files into existed one. You can only replace files with same names. That was done due simple reason: game client do not know anything about your files with custom names.

    Part 1. deSQP.

    This tool was written in C# WPF. It utilizes one special dll: SQPE.dll which exports following functions:
    • sqpUnpack (IntPtr archiveName, IntPtr destFolder);
      archiveNamepointer to archive name
      destFolder – pointer to destination folder
    • sqpPack (IntPtr archiveName, IntPtr sourceFolder, bool doCompact);
      archiveName – pointer to string with archive name
      sourceFolder – pointer to string with source Folder.
      doCompact - Whether archive should be compressed or not.
    • GetErrorCode()
    • sqpInit (IntPtr NamesFile);
      NamesFile – pointer to array of bytes with filenames, hashes etc.
    • sqpUninit();
    • sqpEmergencyExit (UInt32 Value);
    • sqpGetFilesCount()
    • sqpGetProgress()
    • sqpGetFileName()

    First of all, _sqpInit with NamesFile parameter should be called. This function prepares needed structures.

    Code:
    // Before loading SQP module, we should pass a list of available file names
     
    // load file list from resources and pass pointer to dll
    IntPtr filelistPtr = LoadFileList();
     
    //init sqp module
    sqpInit(filelistPtr);
    where LoadFileList() reads data from binary file, allocates memory, saves data in allocated memory and returns pointer to this memory region.
    More about binary file with filenames in section 2.

    After that we can use sqpUnpack and sqpPack in order to Unpack or Pack data.
    You can notice that during unpacking the “Files.db” is created inside folder with extracted data. This file stores some info about unpacked files and can be safely removed if you don’t plan to repack SQP. If Files.db have been corrupted or removed, sqpPack will return error and repacking will not be finished.

    Also sqpPack has doCompact parameter which can be set to True for compressing output SQP. It is a native SQP feature so game client should work with packed archive (I’ve never tested it, so I can’t say anything else)

    Part 2. SQPF creator.

    As we know, SQP archive doesn’t store file names or even file paths. Each file name represented as combination of two hashes.
    To properly extract data from SQP we got all available patches from game servers, extracted them (‘cuz they contain files with readable names) and make a special binary file. sqpf.dat stores full filenames, paths and filename hashes.
    The structure of sqpf.dat is:

    Code:
    struct sqpfHeader
    {
                dword FileSig; // = 53515046, "SQPF"
                dword FileCount;
    }
     
    struct sqpFiles
    {
                ubyte FileNameLength;
                char  fileName[FileNameLength];
                ubyte Zero;
                dword HashA;
                dword HashB;
    }
    SQPF creator just read line-by-line plain text file
    Code:
    Bin\Config\DynamicGroup.xml
    Bin\Config\EnergyLevelUp.xml
    Bin\Config\G_configures.xml
    Bin\Config\MapLinkWays.xml
    Bin\Config\Setting\Color.xml

    then calculate hashes and write all data into binary file.
    Main functions are: BuildStormBuffer, HashString. Before calculating hashes we should init keys array by calling BuildStormBuffer(); and then, call for each filename HashString()
    Code:
    hashA = HashString(tempstr, HASH_NAME_A);
    hashB = HashString(tempstr, HASH_NAME_B);
    Functions:
    Code:
            //Init hash 
            private static uint[] sStormBuffer;
            const int HASH_NAME_A = 1;
            const int HASH_NAME_B = 2;
     
            /// <summary>
            /// Init sStormBuffer for hashing
            /// </summary>
            /// <returns>Array of dwords</returns>
            private static uint[] BuildStormBuffer()
                            {
                                       uint seed = 0x100001;
                                      
                                       uint[] result = new uint[0x500];
                                      
                                       for(uint index1 = 0; index1 < 0x100; index1++)
                                       {
                                                   uint index2 = index1;
                                                   for(int i = 0; i < 5; i++, index2 += 0x100)
                                                   {
                                                               seed = (seed * 125 + 3) % 0x2aaaab;
                                                               uint temp = (seed & 0xffff) << 16;
                                                               seed = (seed * 125 + 3) % 0x2aaaab;
     
                                                               result[index2]  = temp | (seed & 0xffff);
                                                   }
                                       }
     
                                       return result;
                            }
     
            /// <summary>
            /// Creating hash for string name. Before calling this function
            /// sStormBuffer should be initialized
            /// </summary>
            /// <param name="input">Input string name</param>
            /// <param name="offset">Hash type: 1 or 2</param>
            /// <returns></returns>
            internal static uint HashString(string input, int offset)
                            {
                // magic seeds
                                       uint seed1 = 0x7fed7fed;
                                       uint seed2 = 0xeeeeeeee;
                                      
                                       foreach(char c in input)
                                       {
                                                   int val = (int)char.ToUpper(c);
                                                   seed1 = sStormBuffer[(offset << 8 ) + val] ^ (seed1 + seed2);
                                                   seed2 = (uint)val + seed1 + seed2 + (seed2 << 5) + 3;
                                       }
                                       return seed1;
                            }
     
     
        }
    As additional, “SQPF creator” pack output file with zlib.


    Dependences:

    Project already contains needed classes and dlls, so everything should be compiled without problem.
    Also I’ve added comments to every function.

    What should be changed (if someone would take this job):
    • Read filename directly from file, not from resources
    • Finish CheckSQPpack function


    P.S. If you will make modifications or will use SQPE.dll in your own projects, please, save proper credits and notify me about your work.
    P.P.S. Also, please post your suggestion or maybe tips about improving etc…

    Author: Dwar & Genz

    Compiled project: https://progamercity.net/game-files/...-unpacker.html

    License

    Please register or login to download attachments.

    Please, post your questions on forum, not by PM or mail

    I spend my time, so please pay a little bit of your time to keep world in equilibrium

  2. The Following 9 Users Say Thank You to Dwar For This Useful Post:


  3. #2
    h4x0r
    h4x0r is offline
    h4x0r's Avatar
    Join Date
    2011 Aug
    Location
    ..\root\home\pgc
    Posts
    826
    Thanks Thanks Given 
    64
    Thanks Thanks Received 
    525
    Thanked in
    205 Posts
    Rep Power
    14
    Oh god awesome

    @Edited: no source's for SQPE.dll ?
    Last edited by h4x0r; 2012-08-25 at 09:28 AM.

  4. #3
    femida
    femida is offline
    Guest
    Join Date
    2012 Jun
    Posts
    3
    Thanks Thanks Given 
    1
    Thanks Thanks Received 
    1
    Thanked in
    1 Post
    Rep Power
    0
    Не могу написать в личку, так как не имею 15 сообщений. Интересует полная версия. Как можно ее получить?

    С уважением

  5. #4
    hex1r0
    hex1r0 is offline
    Guest
    Join Date
    2012 Sep
    Posts
    2
    Thanks Thanks Given 
    2
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts
    Rep Power
    0

    Question

    First of all thank you for publishing source code of tool. Everything seems to be ok BUT in

    Dmex.cs:424
    Code:
    dest = VirtualAlloc((IntPtr)((int)codeBase + (int)sections[i].VirtualAddress), sections[i].SizeOfRawData, 0x1000, 0x0004);
    returns 0, so
    Code:
    dest == 0
    which causes next line to crash

    Values of arguments:
    Code:
    i == 0
    codebase == 0
    sections[i].VirtualAddress == 4096
    sections[i].SizeOfRawData == 6656
    Code:
    GetLastError
    shows 87

    so somehow first argument is not accepted, but I have no idea why? Do you have any suggestions? Thanks again for your work.

  6. #5
    femida
    femida is offline
    Guest
    Join Date
    2012 Jun
    Posts
    3
    Thanks Thanks Given 
    1
    Thanks Thanks Received 
    1
    Thanked in
    1 Post
    Rep Power
    0
    I buy pack version tool... icq 639417226

  7. #6
    gzwpow3
    gzwpow3 is offline
    New member
    Join Date
    2013 Jan
    Posts
    5
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts
    Rep Power
    0

    [Tutorial] How to add local password protection onto your program

    this is where the user creates his username & password:

    Code:
    Public Class Form1
    
        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            Dim temppassword1 As String
            Dim temppassword2 As String
            Dim password As String = My.Settings.Password
            Dim username As String = My.Settings.Username
            temppassword1 = password.Text
            temppassword2 = confirmpassword.Text
            If Not password = ("") Then
                login.Show()
                Me.Close()
                End
            End If
            If password = ("") Then password = confirmpassword.Text
            If username.Text = ("") Then
                MsgBox("Please create a Username!")
            End If
            If confirmpassword.Text = ("") Or confirmpassword.Text = ("") Then
                MsgBox("Please create a Password!")
            End If
            If Not temppassword1 = temppassword2 Then
                MsgBox("Error! Passwords do not match")
            End If
            username = username.Text
            password = confirmpassword.Text
            login.Show()
            Me.Close()
        End Sub
    End Classthen we create the actual login prompt:
    
    Code:
    Public Class login
    
        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Pass.Click
            If TextBox1.Text = (My.Settings.Password) Then
                MsgBox("Access Granted!")
                'Do Something
                End
            Else
                MsgBox("Access Denied!")
            End If
        End Sub
    
        Private Sub login_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            label2.text = ("Welcome " & My.Settings.Username & ", Please enter your password!")
        End Sub
    End Class
    And now you're done, Enjoy!

  8. #7
    rokeys
    rokeys is offline
    New member
    Join Date
    2012 Aug
    Posts
    20
    Thanks Thanks Given 
    1
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts
    Rep Power
    0

    Smile

    study it,thanks

  9. #8
    versato
    versato is offline
    Guest
    Join Date
    2013 Sep
    Posts
    2
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts
    Rep Power
    0
    This is very nice & handy tool. Because you guys have the only tool to repack the sqp files

  10. #9
    gzwpow3
    gzwpow3 is offline
    New member
    Join Date
    2013 Jan
    Posts
    5
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts
    Rep Power
    0
    This is very nice & handy tool. Because you guys have the only tool to repack the sqp files

  11. #10
    impostor
    impostor is offline
    Guest
    Join Date
    2014 Oct
    Posts
    1
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts
    Rep Power
    0
    Hello!
    who knows how to put the server-list into Other.sqp

Page 1 of 2 12 LastLast

Similar Threads

  1. [Release] deSQP - Sqp archive packer/unpacker
    By Dwar in forum Game Files
    Replies: 46
    Last Post: 2017-06-05, 07:15 PM
  2. Replies: 4
    Last Post: 2015-12-03, 09:56 AM
  3. [C#] Packet Sniffer/Editor Full Source
    By Dwar in forum VB, .NET Framework
    Replies: 1
    Last Post: 2013-01-15, 07:03 AM
  4. Replies: 0
    Last Post: 2012-08-01, 09:11 AM
  5. [Source] Aika jit to dds Converter Full Delphi source.
    By Dwar in forum Delphi
    Replies: 1
    Last Post: 2012-07-23, 02:21 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •