Switch to full style
In-depth technology research: finding new ways to recover data, accessing firmware, writing programs, reading bits off the platter, recovering data from dust.

Forum rules

Please do not post questions about data recovery cases here (use this forum instead). This forum is for topics on finding new ways to recover data. Accessing firmware, writing programs, reading bits off the platter, recovering data from dust...
Post a reply

Tracks to Mod issues

October 17th, 2018, 7:50

Hi, I rx a drive from Gujrat (beautiful state in India btw) from a a starter DR guy. It was a WD PURZ with MOD 01 erased.
I tried to load various other available 01s in RAM to access the SA however very less portion of the SA alligned with the address pointer loaded in the RAM (ie donor 01). So it was decided to take a track dump from primary heads 0 and 1.
DFL has an option to do Tracks to Mods however it apparently first locates 01 in the track files and then using the same as reference manages to extract other modules while also performing the checksum on them (can save mods with err in checksum aswell).

So I wrote a little C program to find all ROYL headers in the loaded track file, display its offset and display the mod name associated with the header...
Here it is, hope you enjoy. Also, last step needs to be programmed where it perform this program over and over for all track files.
I may have included extra header files. One can also load up ROM code to localize mods.


#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<stddef.h>
#include <string.h>
int main(void) {
FILE *file;
unsigned char *buffer;
unsigned long fileLen;
unsigned char roylheader[4] = {0x52,0x4F,0x59,0x4C};
file = fopen("C:\\rom.bin","rb");
//Get file length
fseek(file, 0, SEEK_END);
fileLen=ftell(file);
fseek(file, 0, SEEK_SET);
//Allocate memory
buffer=(unsigned char *)malloc(fileLen+1);
if (!buffer)
{
fprintf(stderr, "Memory error!");
fclose(file);
return 0 ;
}
//Read file contents into buffer
fread(buffer, fileLen, 1, file);
fclose(file);
//Do what ever with buffer
int i=0;
while ( i <fileLen) {
int j = i;
//printf("%X ", buffer[i]);
// if ((i+1)%16 == 0) printf("\n");
if(buffer[j] == roylheader[0] && buffer[j+1] == roylheader[1] && buffer[j+2] == roylheader[2] && buffer[j+3] == roylheader[3] )
{
char hex[5];
sprintf(hex, "%x", j);
printf("Royl header with modname %x%x found at offset\t", buffer[i+8] , buffer[i+9]); puts(hex);
j=0; //set current location j to zero so that it aligns with i later on//
}
i++;
}
}

Re: Tracks to Mod issues

October 17th, 2018, 15:45

Thanks.

Re: Tracks to Mod issues

February 29th, 2020, 17:09

Sorry, just a little correction. Now the mod names should load up perfectly.
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<stddef.h>
#include <string.h>
int main(void) {
FILE *file;
unsigned char *buffer;
unsigned long fileLen;
unsigned char roylheader[4] = {0x52,0x4F,0x59,0x4C};
file = fopen("C:\\rom.bin","rb");
//Get file length
fseek(file, 0, SEEK_END);
fileLen=ftell(file);
fseek(file, 0, SEEK_SET);
//Allocate memory
buffer=(unsigned char *)malloc(fileLen+1);
if (!buffer)
{
fprintf(stderr, "Memory error!");
fclose(file);
return 0 ;
}
//Read file contents into buffer
fread(buffer, fileLen, 1, file);
fclose(file);
//Do what ever with buffer
int i=0;
while ( i <fileLen) {
int j = i;
//printf("%X ", buffer[i]);
// if ((i+1)%16 == 0) printf("\n");
if(buffer[j] == roylheader[0] && buffer[j+1] == roylheader[1] && buffer[j+2] == roylheader[2] && buffer[j+3] == roylheader[3] )
{
char hex[5];
sprintf(hex, "%x", j);

//correction being here
printf("Royl header with modname %x%x found at offset\t", buffer[i+9] , buffer[i+8]); puts(hex);
j=0; //set current location j to zero so that it aligns with i later on//
}
i++;
}
}

Now the mod names should display correctly with appropriate sequence of letters as required.
Thanks
--

Re: Tracks to Mod issues

March 2nd, 2020, 15:23

take one more step and build dir module based on your findings...

pepe

Re: Tracks to Mod issues

March 4th, 2020, 7:05

Thanks for motivation. Means a lot to me you replying to this thread.

There are bugs in this code itself in terms of naming of the found royl mods. The rest of the code may also have uninvestigated flaws..


I have tried to do something on the lines you are guiding me by taking a working wd, relocating its mods and finding the changes in 01....i could map the the differences and calculate the internal offsets but never tried to program it for any representation of 01 or edit.

Thanks a ton.

Simran Arora
--
Post a reply