Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

Making Img tool


xmen
 Share

Recommended Posts

hi there,

i m making a tool something like img tool but i have some problems that are

the tool read offset as 2 but the others img tool shows it 0001000

the same with size but i got it and multiplied it by 2 and it solved but offset is still making me crazy

 

 

 

can some one tell me how can i solve it

 

and how can i add/ extract and delete the files in it? im using C# 2005

 

i read spark source code but he made it so complicated that no one can understand it easily

 

thanks

 

Link to comment
Share on other sites

yeah, i wanna do something like that

but spark img code is complicated. You should use the IMGTool code and the Spark interface.

Link to comment
Share on other sites

 

What's so complicated about it?

 

You have to multiply by 2048 (or 0x800) to get the real offset and real size.

everything you wrote

 

2048...??? its showing offset is 2 and when i multiply it to 2048 then it will be 4096 but other img tools is showing 1000 not 4096

 

 

 

You should use the IMGTool code and the Spark interface.

where is IMGTool Code???

Edited by xmen
Link to comment
Share on other sites

i think its for gta 3/vc but i will check

any other thing you wanna say ?

thanks

Yea, but it shows you the format and how to read it in C#, then all you have to do is change it for VER2 archives which is almost the exact same, the first 4 bytes are the version and the next 4 bytes are the number of DIR items, then its the same from there on in.

 

Check that source code out and then check out GTAModding.com IMG Archive format page.

Link to comment
Share on other sites

i think its for gta 3/vc but i will check

any other thing you wanna say ?

thanks

Yea, but it shows you the format and how to read it in C#, then all you have to do is change it for VER2 archives which is almost the exact same, the first 4 bytes are the version and the next 4 bytes are the number of DIR items, then its the same from there on in.

 

Check that source code out and then check out GTAModding.com IMG Archive format page.

friend you misunderstood me, i knew already how to read img

i just wanna know how to convert offet to as in all img tools

and how to add/extract and delete files in img....

Link to comment
Share on other sites

The offset info is on gtamodding.com, the offset just like the size is multiplied by 2048, read the gtamodding.com page for the full details.

 

To extract a file you open the archive at the offset for that file and then save take the bytes for that file (size is gotten by multiplying the size by 2048) and put them into an external file.

 

To add a file you open the archive, go to the end of the file and add your external file, then you update the dir with the new info.

 

Just look up Binary File I/O for C# and you will see some examples, have a read of the gtamodding.com page and if you have any specific questions I will check back here during the day, im gonna get a sammich.

Link to comment
Share on other sites

ok, now i understand but i have one more question that is how to populate the bytes[] array ??

as filestream is asking for bytes[] not bytes

 

 

int offset = 2048 * currentoffset;int count = 2048 * currentsize;FileStream fs= new FileStream(@"C:\Documents and Settings\NoProblem\Desktop\amn.dff", FileMode.Create);     fs.Write(bytes[] array, offset, count) 

 

 

 

its just for checking

 

 

Link to comment
Share on other sites

 

Will you at least try and find things out first using google, programming sites and forums instead of just asking everything.

 

BinaryReader

BinaryReader ReadBytes Method

yeah i have already did that and wasted my half day in just searching but not a single site have the information about gta except of gtamodding and gtaforums

 

im not asking about reading bytes, i just wanna know what should be in bytes[] array

means

bytes[0] = ???

bytes[1] = ???

bytes =???

 

cant you explain little more..??

im still soo confuse about it

Edited by xmen
Link to comment
Share on other sites

Will you at least try and find things out first using google, programming sites and forums instead of just asking everything.

 

BinaryReader

BinaryReader ReadBytes Method

yeah i have already did that and wasted my half day in just searching but not a single site have the information about gta except of gtamodding and gtaforums

 

im not asking about reading bytes, i just wanna know what should be in bytes[] array

means

bytes[0] = ???

bytes[1] = ???

bytes =???

 

cant you explain little more..??

im still soo confuse about it

ok...

 

The IMG archive is nothing more than one file on top of another, think of it like a stack of files, now to make it faster for the machine the files are padded out to the nearest 2048 block.

So for example if a 1byte file is added 2047 bytes are added to make up the difference.

 

So now you know what the file is about.

 

What goes into your byte array is the blocks of 2048 bytes that make up that file.

 

For example take the first file in the archive thats size is 2 and its offset is 0.

You set your binary reader's position to 0.

You create your array of bytes with a size of 4096 (2 x 2048)

 

You use the readbytes method to read 4096 bytes into the array.

 

Close the binary reader and then create the new file and write the array of bytes to the file.

 

And thats it.

Link to comment
Share on other sites

ok as far as i understood that if i added file of 4000 bytes the 96 bytes will added as empty to make the difference, isnt it?

 

i will try it soon and post here the result

 

thank you buddy

Link to comment
Share on other sites

ok as far as i understood that if i added file of 4000 bytes the 96 bytes will added as empty to make the difference, isnt it?

 

i will try it soon and post here the result

 

thank you buddy

Yep thats right.

Link to comment
Share on other sites

oh , yeah i did , at last i extracted the file

 

thank you soooo much REspawn inlove.gifinlove.gif

 

 

Edited by xmen
Link to comment
Share on other sites

  • 3 weeks later...

Hey, what does 'rebuild archive' mean? Is it updating entries and deleting NULL bytes which were created after editing/deleting files from archives? mercie_blink.gif

Link to comment
Share on other sites

Hey, what does 'rebuild archive' mean? Is it updating entries and deleting NULL bytes which were created after editing/deleting files from archives? mercie_blink.gif

Yea pretty much, when you delete a file from the archive you tend to just remove it from the listing instead of removing the physical file so thats what rebuild cleans up.

Link to comment
Share on other sites

But if i replace file ex. afro.dff what is in gta archive and afro.dff from mod. But the second one has less blocks than first one. After replacing those files, in gta arch. there will be blank space (because oryginal file had 200kB but that from mod had only 100kB). So have I update entries after every replace operation? Or better to delete oryginal, and attach new file on end of archive?

 

Sorry about my english. but I think you understand me rolleyes.gif

Link to comment
Share on other sites

But if i replace file ex. afro.dff what is in gta archive and afro.dff from mod. But the second one has less blocks than first one. After replacing those files, in gta arch. there will be blank space (because oryginal file had 200kB but that from mod had only 100kB). So have I update entries after every replace operation? Or better to delete oryginal, and attach new file on end of archive?

 

Sorry about my english. but I think you understand me rolleyes.gif

i think replace function replace only the entry with new one and place the file at the end of archive

it just my guess, i never do that

Link to comment
Share on other sites

int offset = 2048 * currentoffset;int count = 2048 * currentsize;FileStream fs= new FileStream(@"C:\Documents and Settings\NoProblem\Desktop\amn.dff", FileMode.Create);     fs.Write(bytes[] array, offset, count) 

 

Is it C++? And what type is bytes[] array?

Link to comment
Share on other sites

Create an account or sign in to comment

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

Create an account

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

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.