Quantcast

Jump to content

» «
Photo

VB6 img,col gta3/vc archive

17 replies to this topic
Swoorup
  • Swoorup

    innovator

  • Feroci Racing
  • Joined: 28 Oct 2008
  • Nepal

#1

Posted 19 August 2011 - 10:58 AM

Can anyone tell me how to get inside the col and img archive's using Microsoft Visual Basic 6.0? I want to edit them and make tools for GTA3 and vice city!!Hope this is the right place

OzzySM12
  • OzzySM12

    Hmm...

  • Members
  • Joined: 07 Nov 2004

#2

Posted 19 August 2011 - 06:09 PM

You will have to find out the file layout of the files and then write the code to open and handle the data.

Check GTA Garage, you'll no doubt find a program that already does what you are looking for.

Swoorup
  • Swoorup

    innovator

  • Feroci Racing
  • Joined: 28 Oct 2008
  • Nepal

#3

Posted 19 August 2011 - 06:14 PM

QUOTE (OzzySM12 @ Friday, Aug 19 2011, 18:09)
You will have to find out the file layout of the files and then write the code to open and handle the data.

Check GTA Garage, you'll no doubt find a program that already does what you are looking for.

I know about the program already I just want the code so that I can use it with my won mod. Can some one just send me the sub programs or functions in VB6 code

nightwalker83
  • nightwalker83

    Don't mind me

  • Members
  • Joined: 10 Oct 2004

#4

Posted 20 August 2011 - 12:44 AM

I'm not sure but isn't it the same as reading an ordinary text file in VB6?

Swoorup
  • Swoorup

    innovator

  • Feroci Racing
  • Joined: 28 Oct 2008
  • Nepal

#5

Posted 20 August 2011 - 01:27 AM Edited by Swoorup, 22 August 2011 - 06:53 AM.

DELete

Swoorup
  • Swoorup

    innovator

  • Feroci Racing
  • Joined: 28 Oct 2008
  • Nepal

#6

Posted 20 August 2011 - 02:42 PM

Help...Sorry for DBP

Swoorup
  • Swoorup

    innovator

  • Feroci Racing
  • Joined: 28 Oct 2008
  • Nepal

#7

Posted 22 August 2011 - 06:51 AM

Can some one make transform this into usable VB6 code?

DIR file - contains list of files embedded inside IMG archive
QUOTE
File list:
Starts right on 0x0
Each entry description takes: 32 bytes.
Entry description:

Offset Type  Value
+0x0  DWORD  File offset, in blocks (file offset / 2048)
+0x4  DWORD  File size, in blocks (file size / 2048)
+0x8  CHAR[24] File name NULL (0x00) terminated.


IMG archive - includes file contents
QUOTE
File contents
File contents are in IMG archive. They are aligned to 2048 bytes boundaries. It means position of file in IMG archive must be divisible by 2048. Therefore file in sample archive can be stored on offsets 2048, 4096, 6144, 8192 and so forth.


It is very simple unlike IMG archives since GTA IV. When you want to add to an of archive, then you must add it end of IMG archive, but you must add on position divisible by 2048. And add to DIR file this position divided by 2048.
When you remove x file, then you must get position of this file from DIR file to variable, *= 2048 then, get size * 2048 too Remove file entry from DIR file.
Truncate IMG archive by size length which you have in a variable.
Decrease size of all entries after removed one in DIR file by size of removed one, because they are on lower positions.

Can someone transform this into code???

nightwalker83
  • nightwalker83

    Don't mind me

  • Members
  • Joined: 10 Oct 2004

#8

Posted 22 August 2011 - 07:09 AM Edited by nightwalker83, 22 August 2011 - 08:04 AM.

QUOTE (Swoorup @ Saturday, Aug 20 2011, 04:44)
QUOTE (OzzySM12 @ Friday, Aug 19 2011, 18:09)
You will have to find out the file layout of the files and then write the code to open and handle the data.

Check GTA Garage, you'll no doubt find a program that already does what you are looking for.

I know about the program already I just want the code so that I can use it with my won mod. Can some one just send me the sub programs or functions in VB6 code

How about contacting the author of the program and asking if you could use the code?

Edit:

I just found this.

Swoorup
  • Swoorup

    innovator

  • Feroci Racing
  • Joined: 28 Oct 2008
  • Nepal

#9

Posted 22 August 2011 - 08:31 AM Edited by Swoorup, 22 August 2011 - 08:33 AM.

Wow thanks a whole lot. Have a cookie.gif cookie.gif
Now just need a col editing source code man in VB6. Just this one and my tool is 99% complete

nightwalker83
  • nightwalker83

    Don't mind me

  • Members
  • Joined: 10 Oct 2004

#10

Posted 22 August 2011 - 10:46 AM

QUOTE (Swoorup @ Monday, Aug 22 2011, 19:01)
Wow thanks a whole lot. Have a cookie.gif cookie.gif
Now just need a col editing source code man in VB6. Just this one and my tool is 99% complete

No worries! I hope the comments/instructions from your mod are going to be in English unlike the above code? rolleyes.gif I can't read french although, I keep finding myself joining french websites/forums.

Swoorup
  • Swoorup

    innovator

  • Feroci Racing
  • Joined: 28 Oct 2008
  • Nepal

#11

Posted 22 August 2011 - 10:53 AM

Have a problem man!!! The img does not contain source to delete or add the files at all. Its just extracts files only!!!

nightwalker83
  • nightwalker83

    Don't mind me

  • Members
  • Joined: 10 Oct 2004

#12

Posted 23 August 2011 - 12:43 AM

QUOTE (Swoorup @ Monday, Aug 22 2011, 21:23)
Have a problem man!!! The img does not contain source to delete or add the files at all. Its just extracts files only!!!

Well, I have never worked with Binary files before maybe you could ask over at vbforums.com? My username there is "Nightwalker83".

Swoorup
  • Swoorup

    innovator

  • Feroci Racing
  • Joined: 28 Oct 2008
  • Nepal

#13

Posted 23 August 2011 - 03:42 AM Edited by Swoorup, 24 August 2011 - 04:21 AM.

VB Code:
Source: http://www.vbfrance....REAS_49333.aspx

This is just an extract part. Please implement add,delete part too
CODE

Option Explicit

Private lngCurrentOffset    As Long   'Offset courant
Private strFile             As String 'Chemin du fichier
Private strFileV1           As String 'Chemin du fichier de l'archive V1

Private Sub lvFile_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
   If Button = vbRightButton Then
       PopupMenu mnuCmd
   End If
End Sub

Private Sub mnuCmdExtract_Click()
   Dim strTemp As String 'Variable temporaire
   
   With CD
       .DialogTitle = "Enregistrer le fichier " & lvFile.SelectedItem.Text
       .Filter = "Tous les fichiers|*.*"
       .FileName = lvFile.SelectedItem.Text
       .ShowSave
       
       If .FileName = "" Then Exit Sub
       
       Open .FileName For Binary Access Write As #2
           Open strFile For Binary Access Read As #3
               strTemp = String((Val(lvFile.ListItems(lvFile.SelectedItem.Index).ListSubItems(2).Text) * 1024), &H0)
               Get #3, Val("&H" & lvFile.ListItems(lvFile.SelectedItem.Index).ListSubItems(1).Text) + 1, strTemp
               Put #2, 1, strTemp
           Close #3
       Close #2
   End With
End Sub

Private Sub mnuFileExit_Click()
   Unload Me
End Sub

Private Sub mnuHelpAbout_Click()
   MsgBox "Créé par gta126" & vbCrLf & "E-mail :", vbOKOnly + vbInformation, "Extraire IMG Version 2"
End Sub

Private Sub mnuFileOpen_Click()
   With CD
       .DialogTitle = "Ouvrir une archive IMG"
       .Filter = "Fichiers IMG|*.img"
       .ShowOpen
       
       If .FileName = "" Then Exit Sub
       strFile = .FileName
       
   End With
   
   lvFile.ListItems.Clear
   
   Select Case ExtractVersion
       Case "V2"
           Open strFile For Binary Access Read As #1
               ExtractInfosV2
           Close #1
       Case "V1"
           Open strFileV1 For Binary Access Read As #1
               ExtractInfosV1
           Close #1
       Case "V?"
           MsgBox "Pas un fichier IMG valide"
   End Select
End Sub

'Inverse les Bytes (Exemple : 4C01 après vaudra 014C)
Public Function ReverseByte(strData As String) As String
   Dim strTemp()       As String 'Tableau contenant la valeur de chaque byte
   Dim strRetour       As String 'Chaîne de retour
   Dim i               As Long   'Compteur
   Dim y               As Long   'Compteur 2
   
   ReDim strTemp(Len(strData) / 2)
   
   y = 1
   strRetour = ""
   
   For i = 0 To UBound(strTemp) - 1
       strTemp(i) = Mid(strData, y, 2)
       y = y + 2
   Next i
   
   For i = (UBound(strTemp) - 1) To 0 Step -1
       strRetour = strRetour & strTemp(i)
   Next i
   
   ReverseByte = strRetour
End Function

'Convertit la valeur lue dans le fichier en hexa et remet les bytes dans l'ordre
Public Function HexaCaractSort(strData As String) As String
   Dim i       As Long   'Compteur
   Dim strTemp As String 'Chaîne contenant les caractères en hexa
   
   strTemp = ""
   
   For i = 1 To Len(strData)
       If Len(Hex(Asc(Mid(strData, i, 1)))) = 1 Then
           strTemp = strTemp & "0" & Hex(Asc(Mid(strData, i, 1)))
       Else
           strTemp = strTemp & Hex(Asc(Mid(strData, i, 1)))
       End If
   Next i
   
   strTemp = ReverseByte(strTemp)
   
   HexaCaractSort = strTemp
End Function

'Obtenir valeur
Private Function GetValue(lngOffset As Long, lngSizeInByte As Long, Optional intOption As Integer = 2) As String
   Dim strTemp As String 'Variable temporaire
   
   strTemp = String(lngSizeInByte, &H0)
   Get #1, lngOffset + 1, strTemp
   
   Select Case intOption
       Case 0 'String
           GetValue = strTemp
       Case 1 'Hexadécimal
           GetValue = HexaCaractSort(strTemp)
       Case 2 'Décimal
           GetValue = Val("&H" & HexaCaractSort(strTemp))
       Case 3 'Booléen
           If HexaCaractSort(strTemp) = True Then GetValue = "True" Else GetValue = "False"
   End Select
End Function

'Déterminer la version de l'archive
Private Function ExtractVersion() As String
   Dim i           As Integer 'Compteur
   
   Open strFile For Binary Access Read As #1
       lngCurrentOffset = 0
       
       If GetValue(lngCurrentOffset, 4, 0) = "VER2" Then
           ExtractVersion = "V2"
           Close #1
           Exit Function
       End If
   Close #1
   
   i = 0
   
   Do
       i = InStr(i + 1, strFile, ".", vbBinaryCompare)
       If i = 0 Then Exit Do
       strFileV1 = Left$(strFile, i) & "dir"
   Loop
   
   If Dir(strFileV1) <> "" Then 'Tester si le fichier existe /!!!\ pas correct, car pas sécurisé
       ExtractVersion = "V1"
       Exit Function
   End If
   
   ExtractVersion = "V?"
End Function

'Extraction des informations du fichier IMG V2
Private Sub ExtractInfosV2()
   Dim i               As Integer 'Compteur
   Dim intNbrFichier   As Integer 'Nombre de fichiers
   
   lngCurrentOffset = 0
   
   intNbrFichier = GetValue(lngCurrentOffset + &H4, 4)
   
   If intNbrFichier <= 1 Then
       lblNbrFile.Caption = intNbrFichier & " fichier"
   Else
       lblNbrFile.Caption = intNbrFichier & " fichiers"
   End If
       
   With lvFile
       lngCurrentOffset = lngCurrentOffset + &H8
       
       For i = 0 To (intNbrFichier - 1)
           .ListItems.Add , , GetValue(lngCurrentOffset + &H8, 24, 0)
           
           .ListItems(i + 1).ListSubItems.Add , , Hex(Val(GetValue(lngCurrentOffset, 4)) * 2048)
           .ListItems(i + 1).ListSubItems.Add , , ((Val(GetValue(lngCurrentOffset + &H4, 4)) * 2048) / 1024) & " kb"
           
           lngCurrentOffset = lngCurrentOffset + 32
       Next i
   End With
End Sub

'Extraction des informations du fichier IMG V1
Private Sub ExtractInfosV1()
   Dim i               As Integer 'Compteur
   Dim intNbrFichier   As Integer 'Nombre de fichiers
   
   lngCurrentOffset = 0
   
   intNbrFichier = FileLen(strFileV1) / 32
   
   If intNbrFichier <= 1 Then
       lblNbrFile = intNbrFichier & " fichier"
   Else
       lblNbrFile = intNbrFichier & " fichiers"
   End If
   
   With lvFile
       For i = 0 To (intNbrFichier - 1)
           .ListItems.Add , , GetValue(lngCurrentOffset + &H8, 24, 0)
           
           .ListItems(i + 1).ListSubItems.Add , , Hex(Val(GetValue(lngCurrentOffset, 4)) * 2048)
           .ListItems(i + 1).ListSubItems.Add , , ((Val(GetValue(lngCurrentOffset + &H4, 4)) * 2048) / 1024) & " kb"
           
           lngCurrentOffset = lngCurrentOffset + 32
       Next i
   End With
End Sub

Swoorup
  • Swoorup

    innovator

  • Feroci Racing
  • Joined: 28 Oct 2008
  • Nepal

#14

Posted 28 August 2011 - 01:16 PM

Bump
@Nightwalker anything?

I have come to a complete halt in the last week for the progress of my tool.
BTW its nice to see VC mods are arising once again biggrin.gif

nightwalker83
  • nightwalker83

    Don't mind me

  • Members
  • Joined: 10 Oct 2004

#15

Posted 29 August 2011 - 01:15 AM Edited by nightwalker83, 29 August 2011 - 11:59 PM.

QUOTE (Swoorup @ Sunday, Aug 28 2011, 23:46)
Bump
@Nightwalker anything?

I have come to a complete halt in the last week for the progress of my tool.
BTW its nice to see VC mods are arising once again biggrin.gif

Nope, I have emailed the author of the above code to see if he can help.

Edit:

I posted his reply in your thread on vbforums here.

Swoorup
  • Swoorup

    innovator

  • Feroci Racing
  • Joined: 28 Oct 2008
  • Nepal

#16

Posted 30 August 2011 - 04:16 AM

I have understood it but still cant figure out the codes to do it. I have worked with databases and text files before as a part of my course but not binary files man! I have partly understood the code he made to extract and detect GTA 3/vc and San Andreas imgs. If I managed to do it it will take me some weeks or so to exactly figure out how to do it!

but anyways thank you man

vhj1995
  • vhj1995

    Modder

  • Members
  • Joined: 18 Jun 2011
  • None

#17

Posted 17 April 2013 - 02:05 PM

So, Did you Completed?

Ashwin.Star
  • Ashwin.Star

    Back for Next ♪♫

  • Members
  • Joined: 14 Nov 2010
  • India

#18

Posted 17 April 2013 - 03:02 PM

What a Bump !!! panic.gif




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users