Please login or register.

Login with username, password and session length
Advanced search  

News:

Pages: [1]   Go Down

Author Topic: Grabing resources off a program  (Read 1606 times)

thirdbanana

  • 8 MB
  • **
  • Posts: 14
Grabing resources off a program
« on: October 10, 2024, 07:49:11 PM »

Long time ago, I wrote a program in Think C (hence my question in another thread), which I recently found, or at least some fragments. And a compiled version of the code. If I want to compile the code again, I will need the graphics and sound resources; can I fetch them off the executable file (i.e. program) using resedit or something like that?
Logged

Knezzen

  • Staff Member
  • 1024 MB
  • ******
  • Posts: 1258
  • Pro Tools Addict!
    • Macintosh Garden
Re: Grabing resources off a program
« Reply #1 on: October 10, 2024, 10:30:59 PM »

Yeah, that works for sure.
Logged
Pro Tools addict and staff member at Mac OS 9 Lives!, System 7 Today and Macintosh Garden.

Bolkonskij

  • Staff Member
  • 256 MB
  • *****
  • Posts: 296
    • Cornica.org
Re: Grabing resources off a program
« Reply #2 on: October 11, 2024, 05:39:18 AM »

If you added them via ResEdit before, you should be able to open up your resource file and get them out again. Also, while I don't remember any name, there's little applications that do that for you as well. You may want to check the Macintosh Garden for them, they're definitely there.
Logged

thirdbanana

  • 8 MB
  • **
  • Posts: 14
Re: Grabing resources off a program
« Reply #3 on: October 11, 2024, 10:15:01 AM »

If you added them via ResEdit before, you should be able to open up your resource file and get them out again. Also, while I don't remember any name, there's little applications that do that for you as well. You may want to check the Macintosh Garden for them, they're definitely there.

I am not sure; I know I used Think C 5.0 (I actually wrote in the code when I bought it, as it required some changes). I do not remember how the resources were fed: I want to say they were in a separate file which was then added into the binary somehow. Being able to save the resources will help a lot: while I have the original image file (before the different bits were cropped and added as individual components), the floppy I found was not the one I used to build it, so it has some missing files namely the resource and the header file. There is also a programname.mac file which I have no idea of what it is supposed to do.

My plan now is to get it such that it will successfully compile in Think C 5 (which I hope runs in OS9). Then I can decide if I want to switch to codewarrior or whatever, and clean the code some.  :-[
Logged

Bolkonskij

  • Staff Member
  • 256 MB
  • *****
  • Posts: 296
    • Cornica.org
Re: Grabing resources off a program
« Reply #4 on: October 12, 2024, 01:16:26 AM »

Traditionally, when programming the Mac, you would have created an empty resource file and then manually added your resources (pictures, sounds, windows, menu bars, constants etc.) to it which you'd later reference in code. So, in theory, you just need to fire up ResEdit and open the resource file located somewhere in the source folder. From there, you should be able to copy + paste stuff to where you need it. (provided the resource file actually IS in the sources folder)

As for other options, I've run into this application here on Garden:

http://macintoshgarden.org/apps/37thresex

It might do the trick for you, but I have no experience using it myself!
« Last Edit: October 12, 2024, 03:08:05 AM by Bolkonskij »
Logged

ssp3

  • 512 MB
  • *****
  • Posts: 924
Re: Grabing resources off a program
« Reply #5 on: October 12, 2024, 08:14:43 AM »

As for other options, I've run into this application here on Garden:

http://macintoshgarden.org/apps/37thresex

It might do the trick for you, but I have no experience using it myself!

Kagi and serial numbers. Eek!
Nothing comes close to the ResEdit.
Logged
If you're not part of the solution, you're part of the problem.

joevt

  • 64 MB
  • ****
  • Posts: 103
  • New Member
Re: Grabing resources off a program
« Reply #6 on: October 12, 2024, 11:56:09 AM »

Nothing comes close to the ResEdit.
I think Resorcerer has better templates and editors than ResEdit.
It has other features such as being able to look at the ROM resources.
Logged

robespierre

  • 128 MB
  • ****
  • Posts: 156
  • malfrat des logiciels
Re: Grabing resources off a program
« Reply #7 on: October 12, 2024, 12:43:17 PM »

When using MPW to do traditional Mac development, the tools called "Rez" and "DeRez" were used in a build script to add resources to an application. The source for the resources were in files with names ending with ".r", which were regular text files.

Lightspeed/THINK C usually used a file ending in ".rsrc" instead, which got merged with the application during the build phase. In this case you would use ResEdit or Resorcerer to create the resources using their templates.
Logged

ssp3

  • 512 MB
  • *****
  • Posts: 924
Re: Grabing resources off a program
« Reply #8 on: October 12, 2024, 01:32:39 PM »

I think Resorcerer has better templates and editors than ResEdit.
It has other features such as being able to look at the ROM resources.

Of course it does, but it wasn't free, like ResEdit. (I know, I know  ;) )
Logged
If you're not part of the solution, you're part of the problem.

thirdbanana

  • 8 MB
  • **
  • Posts: 14
Re: Grabing resources off a program
« Reply #9 on: October 16, 2024, 02:40:44 AM »

Lightspeed/THINK C usually used a file ending in ".rsrc" instead, which got merged with the application during the build phase. In this case you would use ResEdit or Resorcerer to create the resources using their templates.

Is the ".rsrc" file just the file created in ResEdit with the resources needed by the program? And shouldn't it be added to the project file? I found at the Macintosh Garden the book "Macintosh_C_Programming_Primer_1992.pdf," which is the one I bought (found it in a box but the pdf is more convenient right now), but had not reached the section on building a proper Mac program yet.

Funny you mentioned Lightspeed C; I did have it (v 2.somehing?) before I bought Think C 5.
Logged

sentient06

  • 4 MB
  • **
  • Posts: 7
Re: Grabing resources off a program
« Reply #10 on: Today at 03:58:21 AM »

I would try DeRez.

Steps:

1. Install MPW. (I put mine on the Applications folder;)
2. Open the MPW Shell;
3. Delete everything and type this:

Code: [Select]
DeRez -1 "Macintosh:Applications:MPW-GM:Interfaces & Libraries:Interfaces:RIncludes:" "Macintosh:Desktop Folder:MyApp" Carbon.r -s CODE -s DATA -s RELA > "Macintosh:Desktop Folder:MyApp.txt"

Make sure it's a single line, then position the cursor at the end and hit ⌘+Return.

Now, you can see a file will be created on your desktop. It's a text file with a creator type set to MPW. You can modify that with the FileType app or even MPW itself, or just drag into SimpleText.

Notice how we're skipping the resource types for "CODE", "DATA" and "RELA". They export a bunch of encoded stuff you probably don't care about. If you do, just don't exclude it. Removing the stuff after, and including the ">" sign will output the stuff to the shell.

You can put the new resource code into a file with the ".r" extension. If you use an IDE like CodeWarrior, there should be an option to run server tools there, and you can use it to re-encode this into an .rsrc file to be used by your project. Then you can manually change stuff on ResEdit.

Is the ".rsrc" file just the file created in ResEdit with the resources needed by the program? And shouldn't it be added to the project file?

Yes, the ".rsrc" is a file made by ResEdit. When programming with the help of resources, we make a file like that and set a bunch of data we replicate in the code. Stuff like window IDs. You can add a bunch of windows and id them with numbers like 128, 129, 130, etc, then declare those numbers as constants in your code. When your compiler links all the files, it picks up the ".rsrc" file and merges into the final executable.

But using graphical interface apps like ResEdit is not very good for versioning code, so Apple invented this C-like syntax to describe the resources instead. We use these tools Rez and DeRez to transform the stuff from code to ".rsrc" and back again. Rez compiles the code into ".rsrc" and DeRez decompiles it.

MPW is the toolset that Apple provided for developers that contains these tools. They can be used by other IDEs via a thing called a Tool Server. On CodeWarrior, for example, you need to link a folder from MPW inside CodeWarrior's folder, so it can find these tools. Then, in your project, you drop the ".r" file with the resource code, and spin up the server. Then you can select Rez and it shows you a GUI with options, so you don't have to poke about with a shell like we did on MPW in my above example. It then creates the ".rsrc" for you by encoding it with Rez.

The step-by-step I provided above is for using MPW to manually extract the resources code that would be in an ".r" file. It's an easy way of copying the resources from any file.
« Last Edit: Today at 04:09:24 AM by sentient06 »
Logged

IIO

  • Staff Member
  • 4096 MB
  • *******
  • Posts: 4669
  • just a number
Re: Grabing resources off a program
« Reply #11 on: Today at 02:41:09 PM »

37thresex
canopener
...

of course none of them can explode all resource types at once, writing them into files... while preserving the type and ID in some way...
Logged
insert arbitrary signature here
Pages: [1]   Go Up

Recent Topics