View Single Post
  #18  
Old May 15th 13, 05:13 PM posted to alt.windows7.general
Paul
external usenet poster
 
Posts: 18,275
Default How to Edit an xml file

Dave C wrote:
On Mon, 13 May 2013 15:03:55 -0400, Zaphod Beeblebrox
wrote:

On Mon, 13 May 2013 14:30:43 -0400, "Dave C" wrote in article
...
I have been playing Win 7, Free Cell for months. I always intended to
retry a given game until I won. On game 2710, I inadvertently accepted
my First Loss.

I now know that my Free Cell stats are stored in an xml file. How
might I edit that file, to edit (delete) that one lose.

While surely minor, compared to many the REAL problems discussed here,
I am most annoyed at myself. I sure would appreciate any/all advice on
how to edit that file.

dave

As I understand it, Free Cell stats are stored in:

C:\Users\your user name\Appdata\Local\Microsoft Games\Freecell\Freecellsettings.xml

To edit it, all you need is notepad or any other text editor.
Then, find the appropriate entry and modify it, then save.


First, a Sincere Thank You, to the many responders. My question is FAR
less important than most other requests on this board.

Certainly I followed up on the various suggestions. I D/L'ed installed
the XML Notepad 2007, as well as another XML editor (Altova XMLSpy
2013) I found on the net. Neither xml editor allows acces to that
file. I have verified that the File Properties are not restricted from
editing. Both editors give me two, most similar error messages:

Sorry file c:\users\ ... \games \freecell \freecellsettings.xml
cannot be opened.

Can't load binary file c:\users\ ... \games \freecell
\freecellsettings.xml

Note: Above, I have truncated the the full file directory info. For
sure I did locate the applicable Frrecell file.

I sure would aprreciate further advice, as to how I can open and edit
that Freecell file, in an xml editor.

Thanks


Arrgh!

OK, I dug out the Windows 7 laptop, played a game of Freecell
(don't know how, quit and accepted a loss).

OK, brought the freecellsettings.xml back to my WinXP machine
for analysis.

Loaded it in a hex editor. It isn't an XML file that I can see. It
is a two part file, consisting of a binary PNG at the front,
followed by unicode text. Didn't anyone scroll to the end
of the file ? Unicode text in Windows, uses two bytes per character.

Snip the file, leaving hex 89 followed by the letters PNG.
That's the beginning of a PNG file.

This is what is contained in the PNG file I got as a result.
This is magnified by a factor of four, for those with poor eyesight.
It's actually 256x192. Now, why it was important to record this, I'll
never know.

http://imageshack.us/a/img541/4653/test3o.png

There is a PNG spec here, if anyone is interested.

http://www.w3.org/TR/PNG/

I left the text at the end of it (which is past the IEND segment
of the PNG), as it doesn't hurt anything. In other words, with a
hex editor, you snip until you find 137 80 78 71 13 10 26 10 decimal.
137 decimal is 89 hex. Capital P is 80 decimal. (search for "man ascii"
in Google.) So splat PNG, four characters, is the header of a PNG file.
Depending on your image editor, you don't need to precisely snip off
the end, to see the PNG. The image loader will ignore input past
the IEND thing.

We need to remove the PNG file, then analyse the rest of it. The rest
is in unicode. And Notepad should handle it. The end of the PNG is near
IEND, followed by four other characters.

OK, long story short, while keeping your eye on the IEND thing
(which is near the end of the PNG), look for

hex 0xFF, hex 0xFE, then unicode looking like .R.o.o.t.

You want to keep the 0xFF and 0xFE preamble. Snip everything before
that. Save that as test.xml say. Load in Wordpad. You will see

Root
Stats
Version0/Version
GamesPlayed1/GamesPlayed
GamesWon0/GamesWon
MaxWinStreakLength0/MaxWinStreakLength
MaxLoseStreakLength1/MaxLoseStreakLength
CurrStreakLength1/CurrStreakLength
WonlastGamefalse/WonlastGame
/Stats
Options
Version2/Version
PlaySoundstrue/PlaySounds
PlayAnimationstrue/PlayAnimations
RandomAppearancefalse/RandomAppearance
AutoLoadfalse/AutoLoad
TurnOffTipsfalse/TurnOffTips
AutoSaveGameOnExitfalse/AutoSaveGameOnExit
FirstPlayfalse/FirstPlay
CurrDeckSkin2/CurrDeckSkin
CurrBackground0/CurrBackground
/Options
/Root

This is actually unicode, so every character is represented by two bytes.

The only question that remains, is whether the garbage between the
end of the PNG IEND and the beginning of the 0xFF 0xFE unicode
preamble, is a checksum or not.

Hacking the rest of it, is left as a joyous exercise for the
reader.

So it's not "quantum cryptography", it's just obfuscation.
Cut the file in two, edit the text trailer, reassemble.
If it is protected by a checksum, there are some bytes between
IENDxxxx and 0xFF 0xFE that I cannot account for. Make a backup
of the file, before loading your hacked one.

At the very end of the file, I see 0x00 0x0a 0x00 0x00 0x00,
and you probably can't create that with a text editor. When
reassembling the file and bolting it back together, check
that the postamble is correct. I don't know why there is a
Unicode zero down there. A text editor shows that character
as a square. If saving out the file happens to remove it,
you can put that back with the hex editor.

Have fun,

Paul
Ads