1
Scripting and Reverse Engineering / [PC FF7 2012] FF7 ReRelease IPC (Inter-Process Communication)
« on: 2012-09-10 21:17:55 »
IPC Description
Shared memory is used for sending data between Launcher and FF7 (CreateFileMapping -> MapViewOfFile):
Semaphores are used for synchronizing traffic between Launcher and FF7 (CreateSemaphore/OpenSemaphore -> WaitForSingleObject/ReleaseSemaphore):
IPC Protocol
For starters, the [] (square brackets) will be used for denoting the unicode string:
Commands sent by the game:
CMD_G2L_01: Achievement unlocked
CMD_G2L_02: Sync saved games
CMD_G2L_03: Game saved/loaded
CMD_G2L_04: Ready for init data
Commands sent by the launcher:
CMD_L2G_01: Set unlocked achievement
CMD_L2G_07: Saved games synced successfully
CMD_L2G_08: Failed to sync saved games
CMD_L2G_09: Set save path
CMD_L2G_0A: Set config dir
CMD_L2G_0B: Set game dir
CMD_L2G_0C: Set lang dir
CMD_L2G_0D: Set achievement data
CMD_L2G_0E: Set localization data
CMD_L2G_0F: Set keyboard data
CMD_L2G_10: Show message
CMD_L2G_11: Set version info
CMD_L2G_12: Pause game
CMD_L2G_13: Unpause game
CMD_L2G_14: Run the game
AppendixA: List of achievements with their Ids.
AppendixB: List of localization texts with their Ids.
Shared memory is used for sending data between Launcher and FF7 (CreateFileMapping -> MapViewOfFile):
Code: [Select]
ff7_sharedMemoryWithLauncher - name of the shared memory resource.
Notes: The size of the shared block is 0x20000 bytes in length. First 0x10000 bytes are for Game->Launcher traffic (G2L), following 0x10000 bytes are for Launcher->Game traffic (L2G).Semaphores are used for synchronizing traffic between Launcher and FF7 (CreateSemaphore/OpenSemaphore -> WaitForSingleObject/ReleaseSemaphore):
Code: [Select]
ff7_launcherCanReadMsgSem - Launcher waits on this semaphore, it's released by FF7 when the data is ready to be read by Launcher.
ff7_launcherDidReadMsgSem - FF7 waits on this semaphore, it's released by Launcher when data to be read by Launcher has been read.
ff7_gameCanReadMsgSem - FF7 waits on this semaphore, it's released by Launcher when data is ready to be read by FF7.
ff7_gameDidReadMsgSem - Launcher waits on this semaphore, it's released by FF7 when data to be read by FF7 has been read.
IPC Protocol
For starters, the [] (square brackets) will be used for denoting the unicode string:
Code: [Select]
[Unicode string] - Basically a unicode string with first 4 bytes (little endian) being the length of the string in wide chars.
If you need a complicated description, it's a structure built like this:
X1 X2 X3 X4 C0 D0 C1 D1 C2 D2 ...
X4X3X2X1 - string length in wide chars
D0C0 - unicode character no0
D1C1 - unicode character no1
D1C1 - unicode character no2
...
No null terminator since the length is specified. Example of string "Hi!":
03 00 00 00 48 00 69 00 21 00 | ....H.i.!.
Commands sent by the game:
CMD_G2L_01: Achievement unlocked
Code: [Select]
01 00 00 00 XX 00 00 00
XX - Achievement Id
Notes: Sent by FF7 when new achievement has been unlocked.CMD_G2L_02: Sync saved games
Code: [Select]
02 00 00 00
Notes: Sent when FF7 thinks it need the saved games to be synced. It greys out the save slot choose menu until either CMD_L2G_07 or CMD_L2G_08 is received.CMD_G2L_03: Game saved/loaded
Code: [Select]
03 00 00 00 03 00 00 00 XX 00 00 00 YY 00 00 00 ZZ 00 00 00
XX - 00 if saved, 01 if loaded
YY - Save data file Id (00 - 09)
ZZ - Saved game Id (00 - 0F)
Notes: Sent by FF7 when game has been saved or loaded.CMD_G2L_04: Ready for init data
Code: [Select]
04 00 00 00
Notes: Sent by FF7 when it has inited the IPC module.Commands sent by the launcher:
CMD_L2G_01: Set unlocked achievement
Code: [Select]
01 00 00 00 XX 00 00 00
XX - Achievement Id
Notes: It is sent at startup for each achievement already unlocked.CMD_L2G_07: Saved games synced successfully
Code: [Select]
07 00 00 00
CMD_L2G_08: Failed to sync saved games
Code: [Select]
08 00 00 00
CMD_L2G_09: Set save path
Code: [Select]
09 00 00 00 [Unicode string]
Notes: Sent at startup.CMD_L2G_0A: Set config dir
Code: [Select]
0A 00 00 00 [Unicode string]
Notes: Sent at startup.CMD_L2G_0B: Set game dir
Code: [Select]
0B 00 00 00 [Unicode string]
Notes: Sent at startup.CMD_L2G_0C: Set lang dir
Code: [Select]
0C 00 00 00 [Unicode string]
Notes: Sent at startup.CMD_L2G_0D: Set achievement data
Code: [Select]
0D 00 00 00
00 00 00 00 [Achievement 0 name] [Achievement 0 description] [Achievement 0 icon]
01 00 00 00 [Achievement 1 name] [Achievement 1 description] [Achievement 1 icon]
02 00 00 00 [Achievement 2 name] [Achievement 2 description] [Achievement 2 icon]
.. .. .. ..
23 00 00 00 [Achievement 35 name] [Achievement 35 description] [Achievement 35 icon]
Notes: Sent at startup - 36 entries total. Icons are in the data/xarch directory (*.fgt files being pngs). List of achievement Ids in the AppendixA.CMD_L2G_0E: Set localization data
Code: [Select]
0E 00 00 00
00 00 00 00 [Text 0]
01 00 00 00 [Text 1]
02 00 00 00 [Text 2]
.. ...
A2 00 00 00 [Text 162]
Notes: Sent at startup - 163 entries total. List of localization data in the AppendixB.CMD_L2G_0F: Set keyboard data
Code: [Select]
0F 00 00 00 0E 00 00 00
X0 00 00 00
X1 00 00 00
X2 00 00 00
..
XD 00 00 00
Notes: Sent at startup - 14 entries total being the keycodes. Note that this list only sends the data to be shown in the New game "Keyboard" screen, ff7input.cfg still holds the actual config. The order of the data is the same as in AppendixB list of Ids starting from 05, ending at 18.CMD_L2G_10: Show message
Code: [Select]
10 00 00 00 [Message]
Notes: Mostly used for "Downloading save files".CMD_L2G_11: Set version info
Code: [Select]
11 00 00 00 [Version string]
Notes: Sent at startup.CMD_L2G_12: Pause game
Code: [Select]
12 00 00 00
Notes: Freezes the whole game (no "PAUSE")CMD_L2G_13: Unpause game
Code: [Select]
13 00 00 00
Notes: Unfreezes the game.CMD_L2G_14: Run the game
Code: [Select]
14 00 00 00
Notes: Sent when the launcher is done sending init data.AppendixA: List of achievements with their Ids.
Code: [Select]
Achievement Id: 0
Name: End of Part I
Desc: Complete the first part of the game
File: 48464.fgt
Achievement Id: 1
Name: End of Part II
Desc: Complete the second part of the game
File: 86789746.fgt
Achievement Id: 2
Name: End of Game
Desc: Complete FINAL FANTASY VII
File: 788923.fgt
Achievement Id: 3
Name: Master Materia
Desc: Reach the maximum level of any Materia
File: 048748899.fgt
Achievement Id: 4
Name: Master of Gil
Desc: 99,999,999 Gil
File: 1248996.fgt
Achievement Id: 5
Name: Top Level
Desc: Reach level 99 with any character
File: 3124788.fgt
Achievement Id: 6
Name: Knights of the Round
Desc: Get materia Knights of the Round
File: 780075644896.fgt
Achievement Id: 7
Name: Omnislash
Desc: Get Cloud's last Limit Break
File: 6574897441.fgt
Achievement Id: 8
Name: Catastrophe
Desc: Get Barret's last Limit Break
File: 7411663323.fgt
Achievement Id: 9
Name: Chaos
Desc: Get Vincent's last Limit Break
File: 34577888.fgt
Achievement Id: 10
Name: Great Gospel
Desc: Get Aeris's last Limit Break
File: 9678414515.fgt
Achievement Id: 11
Name: Highwind
Desc: Get Cid's last Limit Break
File: 1548549646.fgt
Achievement Id: 12
Name: Final Heaven
Desc: Get Tifa's last Limit Break
File: 15896335.fgt
Achievement Id: 13
Name: All Creation
Desc: Get Yuffie's last Limit Break
File: 64848486.fgt
Achievement Id: 14
Name: Cosmo Memory
Desc: Get Red XIII's last Limit Break
File: 247889666.fgt
Achievement Id: 15
Name: Slots
Desc: Get Cait Sith's last Limit Break
File: 7478989663.fgt
Achievement Id: 16
Name: Bahamut Zero
Desc: Get materia Bahamut Zero
File: 48748955454.fgt
Achievement Id: 17
Name: Ultimate Weapon
Desc: Defeat the Ultimate Weapon
File: 97444543361.fgt
Achievement Id: 18
Name: Diamond Weapon
Desc: Defeat the Diamond Weapon
File: 347895142.fgt
Achievement Id: 19
Name: Ruby Weapon
Desc: Defeat the Ruby Weapon
File: 4154425789.fgt
Achievement Id: 20
Name: Emerald Weapon
Desc: Defeat the Emerald Weapon
File: 3377854.fgt
Achievement Id: 21
Name: Vincent
Desc: Get Vincent on your team
File: 1132477952.fgt
Achievement Id: 22
Name: Yuffie
Desc: Get Yuffie on your team
File: 47851852.fgt
Achievement Id: 23
Name: Materia Overlord
Desc: Master all Materias
File: 852963745.fgt
Achievement Id: 24
Name: Battle Square
Desc: Start a battle in the Battle Square
File: 1587462895.fgt
Achievement Id: 25
Name: Gold Chocobo
Desc: Get a Gold Chocobo
File: 358749685.fgt
Achievement Id: 26
Name: Won 1st battle
Desc: Win your first battle
File: 95856245.fgt
Achievement Id: 27
Name: Braver
Desc: Use Cloud's 1st limit
File: 184575825.fgt
Achievement Id: 28
Name: Big Shot
Desc: Use Barret's 1st limit
File: 6657748235.fgt
Achievement Id: 29
Name: Galian Beast
Desc: Use Vincent's 1st limit
File: 075841114.fgt
Achievement Id: 30
Name: Healing Wind
Desc: Use Aeris's 1st limit
File: 57484155.fgt
Achievement Id: 31
Name: Boost Jump
Desc: Use Cid's 1st limit
File: 36851458.fgt
Achievement Id: 32
Name: Beat Rush
Desc: Use Tifa's 1st limit
File: 6478254145.fgt
Achievement Id: 33
Name: Greased Lightning
Desc: Use Yuffie's 1st limit
File: 78564198.fgt
Achievement Id: 34
Name: Sled Fang
Desc: Use Red XIII's 1st limit
File: 25366999.fgt
Achievement Id: 35
Name: Dice
Desc: Use Cait Sith's 1st limit
File: 748574726.fgt
AppendixB: List of localization texts with their Ids.
Code: [Select]
Entry Id: 0 Text: Achievement Unlocked
Entry Id: 1 Text: Failed to sync save files, your progression will only be saved locally
Entry Id: 2 Text: Save files have been synced
Entry Id: 3 Text: Keyboard
Entry Id: 4 Text: SELECT "QUIT" IN THE GAME MENU TO EXIT THE GAME.
Entry Id: 5 Text: OK
Entry Id: 6 Text: Cancel
Entry Id: 7 Text: Menu
Entry Id: 8 Text: Up
Entry Id: 9 Text: Left
Entry Id: 10 Text: Right
Entry Id: 11 Text: Down
Entry Id: 12 Text: Start
Entry Id: 13 Text: Switch
Entry Id: 14 Text: Page up
Entry Id: 15 Text: Page down
Entry Id: 16 Text: Target
Entry Id: 17 Text: Assist
Entry Id: 18 Text: Camera
Entry Id: 19 Text: Esc
Entry Id: 20 Text: 1
Entry Id: 21 Text: 2
Entry Id: 22 Text: 3
Entry Id: 23 Text: 4
Entry Id: 24 Text: 5
Entry Id: 25 Text: 6
Entry Id: 26 Text: 7
Entry Id: 27 Text: 8
Entry Id: 28 Text: 9
Entry Id: 29 Text: 0
Entry Id: 30 Text: -
Entry Id: 31 Text: =
Entry Id: 32 Text: Backspace
Entry Id: 33 Text: Tab
Entry Id: 34 Text: Q
Entry Id: 35 Text: W
Entry Id: 36 Text: E
Entry Id: 37 Text: R
Entry Id: 38 Text: T
Entry Id: 39 Text: Y
Entry Id: 40 Text: U
Entry Id: 41 Text: I
Entry Id: 42 Text: O
Entry Id: 43 Text: P
Entry Id: 44 Text: [
Entry Id: 45 Text: ]
Entry Id: 46 Text: Enter
Entry Id: 47 Text: Ctrl
Entry Id: 48 Text: A
Entry Id: 49 Text: S
Entry Id: 50 Text: D
Entry Id: 51 Text: F
Entry Id: 52 Text: G
Entry Id: 53 Text: H
Entry Id: 54 Text: J
Entry Id: 55 Text: K
Entry Id: 56 Text: L
Entry Id: 57 Text: ;
Entry Id: 58 Text: '
Entry Id: 59 Text: `
Entry Id: 60 Text: Shift
Entry Id: 61 Text: \
Entry Id: 62 Text: Z
Entry Id: 63 Text: X
Entry Id: 64 Text: C
Entry Id: 65 Text: V
Entry Id: 66 Text: B
Entry Id: 67 Text: N
Entry Id: 68 Text: M
Entry Id: 69 Text: ,
Entry Id: 70 Text: .
Entry Id: 71 Text: /
Entry Id: 72 Text: Right Shift
Entry Id: 73 Text: *
Entry Id: 74 Text: Alt
Entry Id: 75 Text: Space
Entry Id: 76 Text: Caps Lock
Entry Id: 77 Text: F1
Entry Id: 78 Text: F2
Entry Id: 79 Text: F3
Entry Id: 80 Text: F4
Entry Id: 81 Text: F5
Entry Id: 82 Text: F6
Entry Id: 83 Text: F7
Entry Id: 84 Text: F8
Entry Id: 85 Text: F9
Entry Id: 86 Text: F10
Entry Id: 87 Text: Num Lock
Entry Id: 88 Text: Scroll Lock
Entry Id: 89 Text: Num 7
Entry Id: 90 Text: Num 8
Entry Id: 91 Text: Num 9
Entry Id: 92 Text: -
Entry Id: 93 Text: Num 4
Entry Id: 94 Text: Num 5
Entry Id: 95 Text: Num 6
Entry Id: 96 Text: +
Entry Id: 97 Text: Num 1
Entry Id: 98 Text: Num 2
Entry Id: 99 Text: Num 3
Entry Id: 100 Text: Num 0
Entry Id: 101 Text: Num Del
Entry Id: 102 Text: \
Entry Id: 103 Text: F11
Entry Id: 104 Text: F12
Entry Id: 105 Text:
Entry Id: 106 Text:
Entry Id: 107 Text:
Entry Id: 108 Text:
Entry Id: 109 Text:
Entry Id: 110 Text:
Entry Id: 111 Text:
Entry Id: 112 Text:
Entry Id: 113 Text: F15
Entry Id: 114 Text:
Entry Id: 115 Text:
Entry Id: 116 Text:
Entry Id: 117 Text:
Entry Id: 118 Text:
Entry Id: 119 Text:
Entry Id: 120 Text:
Entry Id: 121 Text:
Entry Id: 122 Text:
Entry Id: 123 Text:
Entry Id: 124 Text: Num Enter
Entry Id: 125 Text: Right Ctrl
Entry Id: 126 Text:
Entry Id: 127 Text:
Entry Id: 128 Text:
Entry Id: 129 Text:
Entry Id: 130 Text:
Entry Id: 131 Text:
Entry Id: 132 Text:
Entry Id: 133 Text:
Entry Id: 134 Text: Num /
Entry Id: 135 Text: Prnt Scrn
Entry Id: 136 Text: Right Alt
Entry Id: 137 Text: Pause
Entry Id: 138 Text: Home
Entry Id: 139 Text: Up
Entry Id: 140 Text: Page Up
Entry Id: 141 Text: Left
Entry Id: 142 Text: Right
Entry Id: 143 Text: End
Entry Id: 144 Text: Down
Entry Id: 145 Text: Page Down
Entry Id: 146 Text: Insert
Entry Id: 147 Text: Delete
Entry Id: 148 Text: Left Windows
Entry Id: 149 Text: Right Windows
Entry Id: 150 Text: Application
Entry Id: 151 Text:
Entry Id: 152 Text:
Entry Id: 153 Text:
Entry Id: 154 Text:
Entry Id: 155 Text:
Entry Id: 156 Text:
Entry Id: 157 Text:
Entry Id: 158 Text: Forward
Entry Id: 159 Text:
Entry Id: 160 Text:
Entry Id: 161 Text:
Entry Id: 162 Text: