I spent most of December hacking away on the Genesis ECU, did pretty well with it, its turned over to the dyno and mechanical guys now ! My stupid iPhone failed miserably at retaining the pictures I took, seem its falls apart if you take too many.
I spent a lot of time in the Hotel, gave me an opportunity to work on the OBD II reflash code. Considering it looked like this outside, a good thing!
A few days before the snow
My car getting a few mods.
Setting up a ram tracer
Messing about with the scooby ecu’s, I threw together a little board to flash them.
Test ‘jig’
This is one of the three or four boxes of Toyota ECU’s I have.
I came across tmbinc’s bgrep and modified it a bit to run natively under windows (rather than cygwin), the recurse directory code is just from msdn, I didn’t spent a lot of time with it. Binary grep is very useful, i keep meaning to write one. i didn’t test the stdin.
// Written in April 2009 by Felix Domke <tmbinc@elitedvb.net>
//
// Placed in the public domain April 2009 by the author: no copyright is
// claimed, and you may use it for any purpose you like.
//
// No warranty for any purpose is expressed or implied by the author.
// Report bugs and send enhancements to the author.
#include <windows.h>
#include <stdio.h>
#include <sys/types.h>
int ascii2hex(char c)
{
if (c < ‘0’)
return -1;
else if (c <= ‘9’)
return c – ‘0’;
else if (c < ‘A’)
return -1;
else if (c <= ‘F’)
return c – ‘A’ + 10;
else if (c < ‘a’)
return -1;
else if (c <= ‘f’)
return c – ‘a’ + 10;
else
return -1;
}
void searchfile(const char *filename, FILE*fd, const unsigned char *value, const unsigned char *mask, int len)
{
int o, i;
off_t offset = 0;
unsigned char buf[1024];
if(fd == NULL) return;
while (1)
{
int r;
memcpy(buf, buf + len, len);
r = fread(buf + len, 1,1024 – len,fd);
if (r < 0)
{
perror("read");
return;
} else if (!r)
return;
for (o = offset ? len : 0; o < r – len + 1; ++o)
{
for (i = 0; i < len; ++i)
if ((buf[o + i] & mask[i]) != value[i])
break;
if (i == len)
{
printf("%s: 0x%08llx\n", filename, (unsigned long long)(offset + o – len));
}
}
offset += r;
}
}
void recurse(const char *path, const unsigned char *value, const unsigned char *mask, int len)
{
BOOL fFinished;
HANDLE hList;
TCHAR szDir[MAX_PATH+1];
TCHAR szSubDir[MAX_PATH+1];
WIN32_FIND_DATA FileData;
// Get the proper directory path
sprintf(szDir, "%s\\*", path);
// Get the first file
hList = FindFirstFile(szDir, &FileData);
if (hList == INVALID_HANDLE_VALUE)
{
printf("No files found\n\n");
}
else
{
// Traverse through the directory structure
fFinished = FALSE;
while (!fFinished)
{
// Check the object is a directory or not
if (FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if ((strcmp(FileData.cFileName, ".") != 0) && (strcmp(FileData.cFileName, "..") != 0))
{
// Get the full path for sub directory
sprintf(szSubDir, "%s\\%s", path,FileData.cFileName);
recurse(szSubDir,value,mask,len);
}
}
else{
FILE*fd;
sprintf(szSubDir, "%s\\%s", path,FileData.cFileName);
fd = fopen(szSubDir,"rb");
if(fd){
searchfile(szSubDir, fd, value, mask, len);
printf("%s\n", szSubDir);
}
}
if (!FindNextFile(hList, &FileData))
{
if (GetLastError() == ERROR_NO_MORE_FILES)
{
fFinished = TRUE;
}
}
}
}
FindClose(hList);
}
int main(int argc, char **argv)
{
char*h;
unsigned char value[0x100], mask[0x100];
int len = 0;
if (argc < 2)
{
fprintf(stderr, "usage: %s <hex> [<path> […]]\n<hex> = FFFF, FF or FF??. F, or F?F unsupported, ?? = wildcard\n", *argv);
return 1;
}
h = argv[1];
while (*h && h[1] && len < 0x100)
{
if (h[0] == ‘?’ && h[1] == ‘?’)
{
value[len] = mask[len] = 0;
len++;
h += 2;
} else
{
int v0 = ascii2hex(*h++);
int v1 = ascii2hex(*h++);
if ((v0 == -1) || (v1 == -1))
{
fprintf(stderr, "invalid hex string!\n");
return 2;
}
value[len] = (v0 << 4) | v1; mask[len++] = 0xFF;
}
}
if (!len || *h)
{
fprintf(stderr, "invalid/empty search string\n");
return 2;
}
if (argc < 3) {
searchfile("stdin", 0, value, mask, len);
} else
{
int c = 2;
while (c < argc)
recurse(argv[c++], value, mask, len);
}
return 0;
}
Charliex2,
Saw your blog on hacking the genesis coupe ecu. How far are you from being able to read and write to the ecu. We’re interesting in a tuning solution for the genesis coupe 2.0T via flash. Let me know if you have any more information regarding the genesis ecu.
Regards,
MrC
I did that last year.