Author Topic: corrupted history file  (Read 3978 times)

0 Members and 1 Guest are viewing this topic.

Offline alkimiya

  • Moderator
  • Tireless poster
  • *****
  • Posts: 315
    • View Profile
corrupted history file
« on: May 28, 2002, 07:05:03 PM »
Yesterday I got a BSOD at the same time I got a message so the message wasn't entirely logged. Now when I click the history button in chat window a dialog telling me the history was corrupted is shown, then it shows all non-corrupt entries. Is there a way for me to locate the corrupt entry and delete it?

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12949
    • View Profile
corrupted history file
« Reply #1 on: May 29, 2002, 12:26:19 PM »
yes, i already done it a couple of times

once was caused by a bug, now fixed
another time it was cause another bug, i think, but i don't know what yet.

i'd like to examinate your corrupted file, to have an idea of the corruption.

The easiest thing to do for you is to suddenly move your history file to another folder. Cause history file is like a stream, and when we will fix your corrupted history file, you will be able to append the new one (that will be created in the while) to the fixed one.

you simply need to use a copy /b history1 + /b history2  historyfinal from the command line, or something like this...

Each message in the history file begins with a 4 byte FF FF FF FF.
It is not easy for you, however, to understand where is the corrtuped message.

Offline alkimiya

  • Moderator
  • Tireless poster
  • *****
  • Posts: 315
    • View Profile
corrupted history file
« Reply #2 on: May 29, 2002, 12:44:17 PM »
You're lucky it was my longest history file then :)
Is there some byte after FF FF FF FF that says how long a message should be?

I'm not sure the contact would like if I send the chat log..:)
I know the corrupt entry is in the last 1% of the file.

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12949
    • View Profile
corrupted history file
« Reply #3 on: May 29, 2002, 03:05:08 PM »
I'm not sure the contact would like if I send the chat log..
I know the corrupt entry is in the last 1% of the file.

Quote
Is there some byte after FF FF FF FF that says how long a message should be?

there's no single byte telling it, but this is the structure of an event in history file (i will document these kind of things before or later)

INT
-1 for events
BYTE
01 for messages, 02 for url, etc
INT
sender's uin
DOUBLE
timestamp (1.00 is 1 day)
INT
extra info length
N (as many bytes as the previous INT reports)
extra info
INT
info length
N (as many bytes as the previous INT reports)
info (text for messages)

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12949
    • View Profile
corrupted history file
« Reply #4 on: May 29, 2002, 03:09:32 PM »
http://www.chmaas.handshake.de/delphi/freeware/xvi32/xvi32.htm

here you can find a good and free hex editor

Offline alkimiya

  • Moderator
  • Tireless poster
  • *****
  • Posts: 315
    • View Profile
corrupted history file
« Reply #5 on: May 29, 2002, 05:48:02 PM »
Thanks, I'll look into it when my computer is up and running (memory issue I think). Btw. Ultraedit is quite good for hexedit :)

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12949
    • View Profile
corrupted history file
« Reply #6 on: May 29, 2002, 05:50:33 PM »
i use ultraedit too, but i would not advice a commercial software for things you can get for free :D

Offline alkimiya

  • Moderator
  • Tireless poster
  • *****
  • Posts: 315
    • View Profile
corrupted history file
« Reply #7 on: May 30, 2002, 08:19:17 PM »
Well I can almost read the corrupted file now.
I just need to know how to convert the timestamp bytes to a unix time format (seconds since 1970). Please help!  :!:  :)

Offline alkimiya

  • Moderator
  • Tireless poster
  • *****
  • Posts: 315
    • View Profile
corrupted history file
« Reply #8 on: May 30, 2002, 08:21:09 PM »
It seems after the "history is corrupted" dialog, it shows all entries before the crash so I know which entry is corrupted if I just could decrypt the history file or get the timestamp to search for.

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12949
    • View Profile
corrupted history file
« Reply #9 on: May 31, 2002, 10:19:55 AM »
Code: [Select]
function time_t2dateTime(UnixTime: Integer):TdateTime;
begin result:=25569+UnixTime/(24*60*60) end;

this is the function i use, but i think it is easier to get the datetime directly.
Tdatetime is a Double.
The integral part of a TDateTime value is the number of days that have passed since 12/30/1899. The fractional part of a TDateTime value is fraction of a 24 hour day that has elapsed.

Following are some examples of TDateTime values and their corresponding dates and times:

0   12/30/1899 12:00 am
2.75   1/1/1900 6:00 pm
-1.25   12/29/1899 6:00 am
35065   1/1/1996 12:00 am

Offline alkimiya

  • Moderator
  • Tireless poster
  • *****
  • Posts: 315
    • View Profile
corrupted history file
« Reply #10 on: May 31, 2002, 10:30:34 AM »
Alright, so when I read the history file I reverse your function to get the unixtime?

Then I'll just need to know how to get a double from the eight bytes.

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12949
    • View Profile
corrupted history file
« Reply #11 on: May 31, 2002, 10:57:32 AM »
i'm thinking about to log the byte offset in the history file where the corrupted event begins, this would solve your problem