Question Problem With Opening Binary File into List Box

SteveMack

Member
Joined
Aug 17, 2022
Messages
12
Programming Experience
10+
Hi,
I am stuck on this, I haven't really dealt with file reading.
I'm trying to read a file like this opened in note pad:
MGVS 0 S Bodo FNKW richmond_night FCRD NCS22 v1 Ò7NÅÐ h €Ò N Z Œ( ÿ –D 4C ÿ D < ¨I SLRD Ô TNRD ¯ S Bodo 4_kh_gearwrench.cup.car – TNRD ¯ Pace Car ÿÿÿÿ TNRD ¯ Chase Elliott 12-22#9^Elliott.cup.car ú TNRD ¯ Kyle Busch 18_KB_Myms.cup.car ú TNRD ¯ Aric Almirola 12-22#10^Almirola.cup.car
ú TNRD ¯ Martin Truex, Jr. 19_mtj_basspro.cup.car ú TNRD ¯ Cole Custer 41_Custer_PAG.cup.car ) ú ! TNRD ¯ Tyler Reddick 8_tr_chevrolet.cup.car ú " TNRD ¯ Kyle Larson 5_kl_hendrickcars.cup.car ú # TNRD ¯ Joey Logano 22VerizonFrontline.car ú $ TNRD ¯ Brad Keselowski 6_bk_fastenal.cup.car ú %
TNRD ¯ Aj Allmendinger 16_A_Allmendinger.cup.car ú &
TNRD ¯ Ross Chastain 1_rc_trackhouse.cup.car ú ' TNRD ¯ Austin Dillon 3basspro2022.cup.car ú (
TNRD ¯ Ryan Blaney 12_rb_menards.cup.car ú ) TNRD ¯ Erik Jones 43_ej_focusfactor.cup.car + ú * TNRD ¯ Alex Bowman 48_ab_ally.cup.car 0 ú + TNRD ¯ Chris Buescher 17_cb_fastenal.cup.car ú , TNRD ¯ Daniel Suarez 99_ds_tootsies.cup.car c ú - TNRD ¯ Ricky Stenhouse, Jr. 47_rs_sweetleaf.cup.car / ú . TNRD ¯ Harrison Burton 21_hb_motorcraft.cup.car ú / TNRD ¯ Ty Dillon 42_td_pettygms.cup.car * ú 0 TNRD ¯ Corey LaJoie 7_cl_spire.cup.car ú 1 TNRD ¯ Austin Cindric 2_ac_menards.cup.car ú 2 TNRD ¯ Cody Ware 51_cw_nurtecd.cup.car 3 ú 3 TNRD ¯ Noah Gragson 62_ng_beard.cup.car > ú 4 TNRD ¯ Denny Hamlin DH11_22FDX.cup.car
ú 5 SER €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ÿÿÿÿ SER í|A °
b²A ° n²A °¬²A °…²A °û©²A °
E¶²A °
ײA °çû²A °

Ä ³A °-³A °
X9³A °—n³A °
°r³A °åгA °¶ó³A °Ý$´A ° °r´A °\´A °
×µA °C‹¶A ° ·A °1·A °lç·A °ºA °®GÁA €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿí|A (
€¿ÿÿÿÿ SER €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ÿÿÿÿ SER í|A
b²A n²A ¬²A …²A û©²A
E¶²A
ײA çû²A

Ä ³A -³A
X9³A —n³A
°r³A åгA ¶ó³A Ý$´A °r´A \´A
×µA C‹¶A ·A 1·A lç·A ºA ®GÁA €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿí|A (
€¿ÿÿÿÿ SER €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿÿÿÿÿ €¿ÿÿÿÿ SER í|A °
b²A ° n²A °¬²A °…²A °û©²A °
E¶²A °
ײA °çû²A °

Ä ³A °-³A °
X9³A °—n³A °
°r³A °åгA °¶ó³A °Ý$´A ° °r´A °\´A °
×µA °C‹¶A ° ·A °1·A °lç·A °ºA °®GÁA €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿí|A (
€¿ÿÿÿÿ SER €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿÿÿÿÿ €¿ÿÿÿÿ SER í|A
b²A n²A ¬²A …²A û©²A
E¶²A
ײA çû²A

Ä ³A -³A
X9³A —n³A
°r³A åгA ¶ó³A Ý$´A °r´A \´A
×µA C‹¶A ·A 1·A lç·A ºA ®GÁA €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿ €¿ ÿí|A (
€¿ÿÿÿÿ BTPL BTPL ORPL Ά p(æ ˆD BTPL
I have tried just about everything I can for days now and the code below pretty much
does the same thing as anything else I tried, it's either a horizontal line or a vertical line
in the list box:
It's just a line of text like: TUdWUwAAAAAwAAAAW
Longer with some numbers mixed in, I wasn't able to copy from the list box.

C#:
 if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {

                string filename = openFileDialog1.FileName;
                string resultStr = string.Empty;
                FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
                BinaryReader br = new BinaryReader(fs);
                br.BaseStream.Position = 0;
                listBox1.BeginUpdate();
                listBox1.Items.Clear();
                Byte[] bytes = br.ReadBytes(Convert.ToInt32(fs.Length));
                resultStr = Convert.ToBase64String(bytes);
                listBox1.Items.Add(resultStr);
                listBox1.EndUpdate();
                br.Close();
                fs.Close();

I want to read the file and be able to move lines in the list box up and down
and also randomize the list and save the file again.
Main thing right now is just reading the file into the box.

Thanks for any help.
Steve
 
Hi
Time to start reverse engineering the file them. Generate two, with slightly different data e.g. one with John at the top of the leaderboard and one with Jane. Use e.g. HexCmp to compare the differences - maybe you'll find it's really simple, or maybe there will be checksums and calculated values dotted around the file to protect it from edit attempts/check the data is sane.. Then do a third, and fourth etc. Add more people to the leaderboard etc etc

Maybe you'll find that it's e,g. just 128 irrelevant bytes, then up to 4096 bytes for leaderboard and theyre always in order of "name, 128 bytes, position 2 bytes, end of record larker, 4 bytes", then a count of the entries, 4 bytes, then remainder irrelevant bytes. Rewriting it is an exercise of copying some bytes you don't care about (the first 128, the trailing bytes from position 4224 onwards) and constructing others you do care about (the leaderboard)

At that point you will then have created a program that makes a meaningful interpretation of the file contents. If your new file doesn't work, you missed something; go over the diffs again
Hi, after using my head I have figured that the file is actually the contents of a datatable, the file in the sim can also be exported as an html file, that displays as a html table, along with some html headers, problem is that the application and the sim still reads the file I put up, not the html file, changing it to reading the html file might be an option, I do still have to know how to read the html file into a list box move the items and then save as html again. As I think again knowing that would be great but I still think I need to open the original file and read it, but that all being said I think the sim fills the datatable and saves the content and the app opens the saved file into a listbox letting the user manipulate the contents an save it and the sim can open it to use the new list.

Any thoughts would be cool.

Thanks
Steve
 
If you can find a forum (or two) related to the racing simulator you are using, more often than not they will have a subforum dedicated to modding and writing code for the sim. There is a high probability that someone has already reverse engineered the file format and documented it.
 
If you can find a forum (or two) related to the racing simulator you are using, more often than not they will have a subforum dedicated to modding and writing code for the sim. There is a high probability that someone has already reverse engineered the file format and documented it.
I have looked for that and there is nothing.
 
What's the name of the game?
 
And what is the file extension for that file you are trying to reverse engineer? Or what do you call that file in game speak?

Just trying to figure out what keywords to search for.
 
I don't know enough about the game to be able to do an appropriate search, but based on my skimming of the article below, Project WildFire did the most extensive digging into the original game code to reverse engineer, and then mod the game. That maybe a starting point for your searches. Also in that article, it sounded like there is more than one starting line up editor. Instead of rolling your own, perhaps just another one that can handle a bigger field than the original limit of 44 cars from NASCAR back in the day.

 
I'm was taking this on as a learning experience so that's why I'm sticking with it. The extension is .svg , stands for save game. It is not scalable vector graphics.
 
I don't know enough about the game to be able to do an appropriate search, but based on my skimming of the article below, Project WildFire did the most extensive digging into the original game code to reverse engineer, and then mod the game. That maybe a starting point for your searches. Also in that article, it sounded like there is more than one starting line up editor. Instead of rolling your own, perhaps just another one that can handle a bigger field than the original limit of 44 cars from NASCAR back in the day.

I replied to you above also I am seeing some things on reversing save game files, a little info there.
 
I only dug around for about 20-30 minutes and then stopped. I ran across about forum discussions about track files and car files, but not anything about the save game file.

I left with the impression that the coding community around NR2003 was very similar to the various NASCAR teams. Very supportive of people in the community. Very willing to show off the results of their work, but at the same time very secretive about how the work is done. I guess the virtual NASCAR world mimics the real NASCAR world. :) (I used to be married to a NASCAR fan, and her mother was 5x even more a fan. Her mom ended up doing some freelance work for various teams and garages, but it took a lot of work to be accepted with in that inner circle.)
 
> problem is that the application and the sim still reads the file I put up

Indeed; an "export" may not necessarily be paired with an "import". If you want to edit the in-game results table you might have to twiddle the "binary" file rather than the HTML one

> how to read the html file into a list box

Well, you don't necessarily specifically do that; the listbox is jsut a visualization of what you've read in; you could read into a List<string> for example. Ultimately you need to write the output format in a certain order, and that involves reading all the file, writing the header you don't care about, writing N items in an order you DO care about, then writing the rest of the file that you don't care about. And hope the file doesn't contain a checksum
 

Latest posts

Back
Top Bottom