Reverse engineering IRIX: The beginning.
#1
Reverse engineering IRIX: The beginning.
So thus far most of my time on development for new parts of the base has been replacement, not much else. 

Finally feel comfortable enough announcing a project I picked up purely because I thought I could do it. 

File Alteration Monitor is a part of the IRIX base system. The version shipped with 6.5.12+ was released as GPL2/LGPL2 (the latter for the library).
The original version 1 was as far as I understand never actually released. But the library is tiny, and I made friends with an excellent source code documentarian and developer. He was kind enough to pop the 5.3 era library through Ghidra and write out exactly what it did, function by function (and even function names, as he had debug symbols).

As I speak I was successful in reconstruction of it from the documentation he provided. He provided a significant analysis of each and I did my best to match the CFront era C++ function design and setup. As a result the code quality is atrocious and likely will not be my finest work, now or ever. I am currently working in getting it compiling and will build a few programs for testing purposes.

This library will not be acceptable to use as a drop in replacement likely. I did this strictly as an exercise and in hopes that someone with more brains and skill can make due of it. 

The source will be released under the MIT license, and I will do my best to document it both with comments and a short function manual. It is my hope that I or someone else can: 

1. Write a fam daemon from the library to replace the V1 daemon in 5.3

2. Upgrade the library to support version 2 that is widely distributed. 

3. Port it to other OSes, using OS specific functions for event based monitoring. 

4. Make it not suck or insecure.

It is my hope that barring some freak problem I should have this released within a month or less..

Far from stopping here I have a number of other libraries and commands that I plan to reverse engineer or help someone else do. 

I make no claims as to the quality of my work but only that I will do my best and hope that I can be a better developer because of it. My friend who's a artist once told me that is not about painting a Picasso your first time. Sometimes you have to get in practice and lots of it in order to actually be a better developer and he said a lot of it just takes time.

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,241
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
12-27-2021, 04:45 AM
#2
RE: Reverse engineering IRIX: The beginning.
Finally started testbuilding it for IRIX and FreeBSD -- as I figured a lot of code needs to be refactored

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,241
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
12-28-2021, 03:00 AM
#3
RE: Reverse engineering IRIX: The beginning.
Hey Raion, why not releasing your source code somewhere, so we can have a look? Shouldn't take more than 5 minutes to skim over it. And maybe I can give you some useful hints.
TruHobbyist
Developer

Trade Count: (0)
Posts: 195
Threads: 21
Joined: May 2018
Find Reply
12-28-2021, 08:12 AM
#4
RE: Reverse engineering IRIX: The beginning.
I wanted to release it in a functional state first.

I actually have it building now so I'll have it up soon ish

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,241
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
12-28-2021, 03:46 PM
#5
RE: Reverse engineering IRIX: The beginning.
http://gitea.irixce.org/Raion/OpenFAM

OpenFAM source code is here. It needs way more documentation/code review and bugfixing. But it does compile on IRIX, not yet on anything else. Gotta see if bzero() and pmap_getport(); exist on other platforms and if not what is needed to rewrite.

The fam.h header also lacks any documentation for it yet. I need to fix that.

If anyone has any questions on this by all means.

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,241
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
12-28-2021, 06:30 PM
#6
RE: Reverse engineering IRIX: The beginning.
(12-28-2021, 06:30 PM)Raion Wrote:  Gotta see if bzero() and pmap_getport(); exist on other platforms and if not what is needed to rewrite.

bzero() is ancient, apparently stemming from 4.3BSD.  It's deprecated in recent POSIX specifications, with memset() recommended instead.  It's a simple change: 
Code:
bzero( string, size )
becomes
Code:
memset( string, 0, size)

pmap_getport() is a pretty basic part of the RPC subsystem and should be pretty widely supported as a result.

SGI:  Indigo, Indigo2, Octane, Origin 300
Sun:  SPARCstation 20 (x4), Ultra 2, Blade 2500, T5240
HP:  9000/380, 425e, C8000
Digital: DECstation 5000/125, PWS 600au
jpstewart
Developer

Trade Count: (1)
Posts: 444
Threads: 6
Joined: May 2018
Location: SW Ontario, CA
Find Reply
12-28-2021, 09:14 PM
#7
RE: Reverse engineering IRIX: The beginning.
Thanks for the insight on that one because I've never seen that used before let alone finding documentation on what exactly it was doing.

Hopefully that will allow me to ditch the internal compiler header.

Besides documentation I have been weighing whether or not I want to do a full rewrite of certain portions of it, changing C printf to iostreams where possible and finding a good C++98 solution for a native snprintf type function (I've read a fair bit about C++11 std::string which isn't usable here)

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,241
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
12-28-2021, 09:20 PM
#8
RE: Reverse engineering IRIX: The beginning.
First code I open:
Code:
void getword(char *p, long *l)
{
        char    *pp;
        pp = (char *) l;
        *pp++ = *p++;
        *pp++ = *p++;
        *pp++ = *p++;
        *pp++ = *p++;
}

void putword(char *p, long *l)
{
        char *pp;

        pp = (char *) l;
        *p++ = *pp++;
        *p++ = *pp++;
        *p++ = *pp++;
        *p++ = *pp++;
}

This will do different things on big-endian and little endian platforms
This assumes sizeof(long) == 4 bytes
jan-jaap
SGI Collector

Trade Count: (0)
Posts: 1,049
Threads: 37
Joined: Jun 2018
Location: Netherlands
Website Find Reply
12-28-2021, 10:26 PM
#9
RE: Reverse engineering IRIX: The beginning.
That one is purely a Band-Aid until I unravel where in the code it's relying on long types.

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,241
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
12-28-2021, 11:00 PM
#10
RE: Reverse engineering IRIX: The beginning.
Ok, managed to add some progress:

Removed CC/libc.h dependency, corrected a few typos, and managed to change those functions to uint32_t.

It still won't build outside of IRIX, and that's ok. I'm just finishing up tests for it to make sure I didn't break something in all these changes.

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,241
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
12-29-2021, 02:42 AM


Forum Jump:


Users browsing this thread: 1 Guest(s)