News: 11 March 2016 - Forum Rules

Author Topic: Visual Novel Scenario Encyption?  (Read 8871 times)

Pencil

  • Jr. Member
  • **
  • Posts: 32
    • View Profile
Visual Novel Scenario Encyption?
« on: December 01, 2011, 02:35:49 pm »
My current project is a 2007 visual novel made by Spray using the RealLive engine. I've managed to identify most of the data on the disc (music, art, etc), but there are a few parts that I can't seem to access. If anyone could provide any kind of pointers or help, it'd be much appreciated.

-Most importantly is a 6MB .txt file called 'Seen'. From what I've read about other RealLive games, this is the scenario file, and should contain all of the in-game dialogue and narration. It crashes Notepad due to size, so I've been trying to open it in Word, but none of the available encodes make the contents look anything like actual code. I tried opening the file in EncodingReconvertion tool, which identifies the original encoding as 'Shift JIS', but when I try to reconvert it to ASCII, EUC, JIS, NECJIS, Unicode, Reversed Unicode or UTF-8, it still looks like a mishmash.
I should probably note that Word is the program I've mainly been using to try and view the code, since I'm used to screwing with config files in notepad. Also, there are some encodes which make the file look a little closer to what it might actually say. For example, when I try and open it in Word, and let it know it's Shift-JIS encoded, the information is laid out more logically, and there are no random wingdings, but it's still obviously not code.

-There's also a folder labelled 'dat', which contains a 5kb .cgm file (apparently an image library?) and a 10kb .tcc file, which I think is some other part of the code written in C++, but I have no idea how to decompile it.

I'd really appreciate it if someone could help me figure out how to access the data in these files. If I've missed something obvious, feel free to yell at me.  :-[
« Last Edit: December 01, 2011, 03:39:37 pm by Pencil »

Ryusui

  • Hero Member
  • *****
  • Posts: 4989
  • It's the greatest day.
    • View Profile
    • Tumblr
Re: Visual Novel Scenario Encyption?
« Reply #1 on: December 01, 2011, 04:28:14 pm »
Open the file in a program like WindHex and use one of our tables to test the encoding. Go to Documents on the left and search for "Table" - you'll find 'em all there.

You'll probably have to use Cartographer and Atlus to dump and reinsert the script. Worst-case, if the scenario data really is encrypted or compressed, you'll need to code your own tools.
In the event of a firestorm, the salad bar will remain open.

Nagato

  • Jr. Member
  • **
  • Posts: 41
    • View Profile
Re: Visual Novel Scenario Encyption?
« Reply #2 on: December 01, 2011, 08:10:23 pm »
Deleted.
« Last Edit: June 30, 2021, 06:48:42 am by Nagato »

jjjewel

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: Visual Novel Scenario Encyption?
« Reply #3 on: December 02, 2011, 12:33:00 am »
My current project is a 2007 visual novel made by Spray using the RealLive engine.
Is it possibly the one with the main character wearing eyeglasses?

If so, the text at the beginning of the game is in Seen0101.txt. Find any program that can display Shift-JIS encoding and you should see the text. Even internet browser like Firefox can display it if you have Shift-JIS supported. There are codes mixed in with text, so you will have to either find a program or write a custom program if you want to extract/insert text. (The dialog text isn't at the beginning of the file. You'll have to move down to see it.)

If it's not the same game, it might be similar. (If you don't find the text you want at file name 0001, try looking at file name 0101, etc.)

Pencil

  • Jr. Member
  • **
  • Posts: 32
    • View Profile
Re: Visual Novel Scenario Encyption?
« Reply #4 on: December 02, 2011, 01:45:19 am »
Holy crap, thank you guys so much for offering your advice on this, and replying so quickly.

Quote from: Ryusui
Open the file in a program like WindHex and use one of our tables to test the encoding. Go to Documents on the left and search for "Table" - you'll find 'em all there.

You'll probably have to use Cartographer and Atlus to dump and reinsert the script. Worst-case, if the scenario data really is encrypted or compressed, you'll need to code your own tools.

I tried every table on RHDN, and while some (namely, the Shift-JIS table) provide less messed-up results, it still looks to be encrypted. I'm trying out RLDev right now, but if that doesn't work, then this is certainly going to be an interesting project for me. (Especially since I haven't touched a drop of code in two years.) Still, if it turns out that there aren't any utilities that'll work with this particular file, then re-learning to code will at least be a fun learning experience.  :)

Quote from: Nagato
Haeleth released his rldev toolset for the Reallive engine a few years back but he has since left the community so it's pretty outdated. Here's an updated fork in case Haeleth's version doesn't work. If *that* one still doesn't work you can try tracking down Richard_23 and ask him for rldev 1.51. I'm not sure if he's released it publicly but I know he made his own fork for the Little Busters! project which has additional encryption that Haeleth's version doesn't support.

As for the .cgm and .tcc files, I don't recall us ever having to edit those for the Kanon project so you probably don't need to touch them unless you have a specific reason for wanting to modify them. If you're looking for the images then they are usually in the G00 folder. rldev supports conversion to and from the g00 format so you're covered there, too.

I'm trying out the fork as we speak, and hopefully I'll be able to report back on that on the morning. Currently I'm feeling like a bit of an idiot for tying to look up what on Earth this error message is telling me to do.

Spoiler:
Error:Error:unable to locate reallive.kfn. Try setting $RLDEV to your RLDev installation directory.

Actually, I was just curious as to what the heck those files were. I'd managed to figure out what most of the different file folders were for, but I didn't know if those two were something I'd need to worry about, so thanks for clearing that up. Also, seeing as you worked on Kanon, d'you mind if I ask whether that game had .gan files on the disc? I know they're some sort of scheduling/management program (which  reads them as corrupt), but do VN companies usually leave them in there? The game I'm working on has a whole folder of 'em, and it seems a little odd to me, but then again, I don't know a lot about how companies do their work.

Is it possibly the one with the main character wearing eyeglasses?

If so, the text at the beginning of the game is in Seen0101.txt. Find any program that can display Shift-JIS encoding and you should see the text. Even internet browser like Firefox can display it if you have Shift-JIS supported. There are codes mixed in with text, so you will have to either find a program or write a custom program if you want to extract/insert text. (The dialog text isn't at the beginning of the file. You'll have to move down to see it.)

Yeah, I'm playing around with Kichiku Megane right now. At the moment, all the Seen parts are compressed into a single file, though. After a little more research, I came across this thread, which talks about the same problem with other RealLive games. Reading that thread definitely made me think, but I'm not sure if that's a good or a bad thing.
 
Spoiler:
"...The same goes for the SEEN.TXT file you're trying to get to unzip and decode -- and it's been encoded at least twice and LZ77 compressed once. Unless all that is reversed without a single mistake it's going to look like pencil shavings to a human as well as to kprl, the decompiler."
Spoiler:
"1. The encryption of reallive games is done in two parts, masking some bytes the scenarios, and embed the key in the reallive executable and applying an out-of-box protection layer. So you can't find the key in the SEEN.TXT, and good luck trying to debug the copyright protected exe. :P
2. The key length is the same for all these games. Of course each game use a different key.
3. The main weakness of the protection scheme is that the encryption is too simple. As you may already know from the rldev source, it is just XOR.
Given another fact that reallive is a widely used engine by all companies (or workshops) under VisualArts, and not all released games are encrypted -- so the key is actually very easily recoverable by doing the following:
a. Get another unprotected game released around the same period
b. Extract a unencrypted utility scenario (these scenarios provides standard in-game services, and are game independent, and likely to be reused across multiple games)
c. Extract the encrypted utility scenario (usually having the same name/index) from your game
d. XOR them, now you get the key."

From what I can gather, both from those posts, and the fact that you've managed to view some of the individual, non-compressed Seen files, getting this to work is definitely doable. I just don't know how long it's going to take me to learn the skills to actually do it. Would you mind telling me how you accessed those indiviual files?

Anyway, sorry for the wall of text, everyone. I'm going to try some more things, fiddle around a little more, and see what happens. Right now, it's late, and I have a feeling I'm going to need to learn a lot to tackle this project.

Nagato

  • Jr. Member
  • **
  • Posts: 41
    • View Profile
Re: Visual Novel Scenario Encyption?
« Reply #5 on: December 02, 2011, 01:57:02 am »
Deleted.
« Last Edit: June 30, 2021, 06:48:47 am by Nagato »

jjjewel

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: Visual Novel Scenario Encyption?
« Reply #6 on: December 02, 2011, 01:57:49 am »
From what I can gather, both from those posts, and the fact that you've managed to view some of the individual, non-compressed Seen files, getting this to work is definitely doable. I just don't know how long it's going to take me to learn the skills to actually do it. Would you mind telling me how you accessed those indiviual files?

Anyway, sorry for the wall of text, everyone. I'm going to try some more things, fiddle around a little more, and see what happens. Right now, it's late, and I have a feeling I'm going to need to learn a lot to tackle this project.
I forgot to mention the program I used to view the text files. (Since you mentioned the file names, so I thought you managed extract them.) I used a program called crass and it can extract and convert the scripts to something readable. (Just google crass, cragegui, cg ripping guide, etc. You shouldn't have problem finding the program.)

However, I only used the program to extract files but I've never tried to edit or repack anything, so I don't know how useful it is. You might still need other tools if you want to make a game patch.

Pencil

  • Jr. Member
  • **
  • Posts: 32
    • View Profile
Re: Visual Novel Scenario Encyption?
« Reply #7 on: December 02, 2011, 02:51:53 am »
I'm actually not sure what program you are referring to. Kanon had 1 gan file but no programs for them from what I remember. GAN files are just animation instructions. You can convert the GAN files to xml with rlxml included with rldev if you want to look at them.

No wonder I was confused. I'd never heard of a file ending in .gan before, and when I looked it up, most of the links I found pointed me towards something called GanttProject, so I'd assumed that they were some sort of collaboration tool for the original programmers, like a schedule of who codes what. ::)

Alright, now I've managed to de-compress Seen into its various parts, and I just have two final questions before I scoot off and get back to translating.

Firstly, when I disassembled the code (no special options selected, just "-d seen.txt") kprl gave a fairly large number of warnings about the code. There were about fifty to a hundred mentions of "Out of parameters before strcmp call" near various lines, one unimplemented select function, and an "expected '{', found 0x0a in read_select".  Are these actual errors in the original game code, or something I messed up during the disassembly?

Secondly, can I edit the dialogue as it appears in the Seen files, or do I still need to mess around with hex editing and tables?

Nagato

  • Jr. Member
  • **
  • Posts: 41
    • View Profile
Re: Visual Novel Scenario Encyption?
« Reply #8 on: December 02, 2011, 03:24:11 am »
Deleted.
« Last Edit: June 30, 2021, 06:48:54 am by Nagato »

Pencil

  • Jr. Member
  • **
  • Posts: 32
    • View Profile
Re: Visual Novel Scenario Encyption?
« Reply #9 on: December 02, 2011, 10:06:54 pm »
Fantastic. Now I just need to brush up on my code enough to figure out just what went wrong, and then I'll be golden.  Hopefully, I'll be able to get things sufficiently tweaked within a week or two, but we'll see.

Another silly question, though: When I'm fiddling around with the dialogue, how much of a mind should I keep towards length? I know that making the new dialogue too lengthy will mess up how it looks in the dialogue box, but are there any good rules of thumb to keep in mind?

Nagato

  • Jr. Member
  • **
  • Posts: 41
    • View Profile
Re: Visual Novel Scenario Encyption?
« Reply #10 on: December 02, 2011, 10:18:25 pm »
Deleted.
« Last Edit: June 30, 2021, 06:48:58 am by Nagato »