<?xml version="1.0" encoding="utf-8" ?>
<EternityPatchFile name="NewChara" enabled="new_chara" comment="This file enables the new characters patch">

<!-- The group of patches to make new slots are divided into two main parts. -->

<!-- Part1: patching the comunication with the ActionScript3 

The native and AS3 communicate with each other using a documented standard way (ActionScript external interface)
There are communications in both ways, native->as3 and as3->native

The native->as3 communication is done through a buffer (in the AS3 side) which has a default size of 5194 bytes (0x144A)
The native part passes the index of the buffer, and the value to set (more or less).
Each part of the buffer fulfills a role, which can be seen in the ReceiveType_* variables in CharaSele.as

The first part of the patch takes place mostly in the .dll, as things need to be computed at run time. The xml role here
will be to just find the patches.

These patches consist in patching several calls to the most high level routines that communicate the data to the as3 side 
(thsese routine are methods of some parent class of the native "chasel" object). In the very first exe version, these routines 
has an address of +0x2B4A10 and +0x2B4950
The patches consist in fixing the indexes to match the new layout after CharacterMax change. 
Also, the size must be patched.

-->
	<!-- Signature updated in 1.08 -->
	<Patch name="PatchReceiveTypeKey" type="hook" search_start="0x4FFBD8" comment="Takes place in chasel_func14" >
		<Instruction code="4C 8B C3" comment="mov r8, rbx" />
		<Instruction code="8D 97 8E 10 00 00" comment="lea edx, [rdi+108Eh]" />
		<Instruction code="49 8B CE" comment="mov rcx, r14" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method" />
		<Instruction code="E9 07020000" comment="jmp +0x207" />
		
		<Hook type="call" inst_index="3" value="PatchReceiveTypeKey" setup="CharaSetup" />
	</Patch>
	
	<!-- Signature updated in 1.08 -->
	<Patch name="PatchReceiveTypeKey2" type="hook" search_start="0x4FFE01" comment="Takes place in chasel_func14" >
		<Instruction code="4C 8B C3" comment="mov r8, rbx" />
		<Instruction code="8D 97 8E 10 00 00" comment="lea edx, [rdi+108Eh]" />
		<Instruction code="49 8B CE" comment="mov rcx, r14" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method" />
		<Instruction code="FF C7" comment="inc edi" />
		<Instruction code="49 83 C7 04" comment="add r15, 4" />
		<Instruction code="48 83 C3 20" comment="add rbx, 20h" />
		
		<Hook type="call" inst_index="3" value="PatchReceiveTypeKey" />
	</Patch>	
	
	<!-- Signature updated in 1.08 -->
	<Patch name="PatchReceiveTypeCharaSelected" type="hook" search_start="0x5013F0" comment="Takes place in chasel_func7" >
		<Instruction code="44 8B C0" comment="mov r8d, eax" />
		<Instruction code="8D 96 A6 10 00 00" comment="lea edx, [rsi+10A6h]" />
		<Instruction code="48 8B CD" comment="mov rcx, rbp" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="48 8B 0D XXXXXXXX" comment="mov rcx, cs:XXXXXXXX" />
		<Instruction code="E8 XXXXXXXX" comment="call XXXXXXXX" />
		
		<Hook type="call" inst_index="3" value="PatchReceiveTypeCharaSelected" setup="AS3Send2Setup"/>
	</Patch>
	
	<!-- Signature updated in 1.08 -->
	<Patch name="PatchReceiveTypeCharaVariation" type="hook" search_start="0x501427" comment="Takes place in chasel_func7" >
		<Instruction code="44 8B C0" comment="mov r8d, eax" />
		<Instruction code="8D 93 26 11 00 00" comment="lea edx, [rbx+1126h]" />
		<Instruction code="48 8B CD" comment="mov rcx, rbp" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="FF C3" comment="inc ebx" />
		<Instruction code="83 FB 20" comment="cmp ebx, 20h" />
		<Instruction code="7C D3" comment="jmp -0x2D" />
		
		<Hook type="call" inst_index="3" value="PatchReceiveTypeVariation" />
	</Patch>
	
	<!-- Signature updated in 1.08 -->
	<Patch name="PatchReceiveTypeSkillName" type="hook" search_start="0x50198F" comment="Takes place in chasel_func4" >
		<Instruction code="4C 8B C3" comment="mov r8, rbx" />
		<Instruction code="41 8D 96 9C 10 00 00" comment="lea edx, [r14+109Ch]" />
		<Instruction code="48 8B CE" comment="mov rcx, rsi" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method" />
		<Instruction code="41 FF C6" comment="inc r14d" />
		<Instruction code="49 83 C5 20" comment="add r13, 20h" />
		<Instruction code="49 83 C4 04" comment="add r12, 4" />
		
		<Hook type="call" inst_index="3" value="PatchReceiveTypeSkillName" />
	</Patch>
	
	<!-- Signature updated in 1.08 -->
	<Patch name="PatchReceiveTypeCharaVariation2" type="hook" search_start="0x5019E5" comment="Takes place in chasel_func4" >
		<Instruction code="44 8B C0" comment="mov r8d, eax" />
		<Instruction code="8D 97 26 11 00 00" comment="lea edx, [rdi+1126h]" />
		<Instruction code="48 8B CE" comment="mov rcx, rsi" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="FF C7" comment="inc edi" />
		<Instruction code="83 FF 20" comment="cmp edi, 20h" />
		<Instruction code="7C D3" comment="jmp -0x2D" />
		
		<Hook type="call" inst_index="3" value="PatchReceiveTypeVariation" />
	</Patch>
	
	<!-- Signature is 1.08 -->
	<Patch name="PatchReceiveTypeImageStr" type="hook" search_start="0x501B42" comment="Takes place in chasel_func5." >
		<Instruction code="41 8D 56 0E" comment="lea edx, [r14+0Eh]" />
		<Instruction code="4C 8B C7" comment="mov r8, rdi" />
		<Instruction code="48 8B CE" comment="mov rcx, rsi" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method" />
		<Instruction code="48 8B 5C 24 40" comment="mov rbx, [rsp+40h]" />
		<Instruction code="48 8B 6C 24 48" comment="mov rbp, [rsp+48h]" />
		<Instruction code="48 8B 74 24 50" comment="mov rsi, [rsp+50h]" />
		<Instruction code="48 8B 7C 24 58" comment="mov rdi, [rsp+58h]" />
		<Instruction code="48 83 C4 30" comment="add rsp, 30h" />
		
		<Hook type="call" inst_index="3" value="PatchReceiveTypeImageStr" />
	</Patch>
	
	<!-- Signature updated in 1.08 -->
	<Patch name="PatchReceiveTypeCharaSelected2" type="hook" search_start="0x5021CD" comment="Takes place in chasel_func_N1." >
		<Instruction code="44 8B C0" comment="mov r8d, eax" />
		<Instruction code="8D 93 A6 10 00 00" comment="lea edx, [rbx+10A6h]" />
		<Instruction code="48 8B CF" comment="mov rcx, rdi" />
		<Instruction code="48 8B 5C 24 30" comment="mov rbx, [rsp+30h]" />
		<Instruction code="48 83 C4 20" comment="mov rsp, 20h" />
		<Instruction code="5F" comment="pop rdi" />
		<Instruction code="E9 XXXXXXXX" comment="jmp send_method2" />
		
		<Hook type="call" inst_index="6" value="PatchReceiveTypeCharaSelected" />
	</Patch>
	
	<!-- This patch is new in 1.04.1 Signature updated in 1.09-->
	<Patch name="PatchReceiveTypeDLCUnlockFlag" type="hook" search_start="0x52A043" comment="Takes place in chasel_func13." >
		<Instruction code="44 8B C3" comment="mov r8d, ebx" />
		<Instruction code="BA 46 11 00 00" comment="mov edx, 1146h" />
		<Instruction code="49 8B CE" comment="mov rcx, r14" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="49 8B CE" comment="mov rcx, r14" />
		<Instruction code="E8 XXXXXXXX" comment="call chasel_func14" />
		<Instruction code="41 BF 8E 10 00 00" comment="mov r15d, 108Eh" />
		
		<Hook type="call" inst_index="3" value="PatchReceiveTypeDLCUnlockFlag" />
	</Patch>
	
	<!-- This patch is new in 1.04.1 Signature updated in 1.09-->
	<Patch name="PatchReceiveTypeKey3" type="hook" search_start="0x52A141" comment="Takes place in chasel_func13. r15d initial value 0x108E in 1.08+." >
		<Instruction code="4C 8B C3" comment="mov r8, rbx" />
		<Instruction code="41 8B D7" comment="mov edx, r15d" />
		<Instruction code="49 8B CE" comment="mov rcx, r14" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method" />
		<Instruction code="41 FF C7" comment="inc r15d" />
		<Instruction code="48 83 C7 04" comment="add rdi, 4" />
		<Instruction code="48 83 C3 20" comment="add rbx, 20h" />
		
		<Hook type="call" inst_index="3" value="PatchReceiveTypeKey" />
	</Patch>
	
	<!-- This patch is new in 1.04.1 Signature updated in 1.09-->
	<Patch name="PatchReceiveTypeImageStrNpc" type="hook" search_start="0x529D63" comment="Takes place in chasel_func13_ex." >
		<Instruction code="8D 95 A4 10 00 00" comment="lea edx, [rbp+10A4h]" />
		<Instruction code="4C 8B C3" comment="mov r8, rbx" />
		<Instruction code="48 8B CF" comment="mov rcx, rdi" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method" />
		<Instruction code="48 8B 5C 24 40" comment="mov rbx, [rsp+40h]" />
		<Instruction code="48 8B 6C 24 48" comment="mov rbp, [rsp+48h]" />
		<Instruction code="48 8B 74 24 50" comment="mov rsi, [rsp+50h]" />
		
		<Hook type="call" inst_index="3" value="PatchReceiveTypeImageStrNpc" />
	</Patch>
	
	<!-- This patch added in 1.05. Signature is 1.09 -->
	<Patch name="PatchReceiveTypeUseCustomList" type="hook" search_start="0x52A355" comment="Takes place in chasel_func13" >
		<Instruction code="BA F6 1E 00 00" comment="mov edx, 1EF6h" />
		<Instruction code="49 8B CE" comment="mov rcx, r14" />
		<Instruction code="41 83 BE FC 15 00 00 00" comment="cmp dword ptr [r14+15FCh], 0" />
		<Instruction code="0F 84 D0 00 00 00" comment="jz +0xD0" />
		<Instruction code="49 8B 9E D0 16 00 00" comment="mov rbx, [r14+16D0h]" />
		<Instruction code="49 2B 9E C8 16 00 00" comment="sub rbx, [r14+16C8h]" />
		<Instruction code="48 C1 FB 04" comment="sar rbx, 4" />		
		<Instruction code="41 B8 01 00 00 00" comment="mov r8d, 1" />		
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />		
		
		<Hook type="call" inst_index="8" value="PatchReceiveTypeUseCustomList" />
	</Patch>
	
	<!-- This patch added in 1.05. Signature updated in 1.09 -->
	<Patch name="PatchReceiveTypeUseCustomList2" type="hook" search_start="0x52A433" comment="Takes place in chasel_func13. edx is 1EF6" >
		<Instruction code="0F 8C 77 FF FF FF" comment="jz -89" />
		<Instruction code="EB 08" comment="jmp +8" />		
		<Instruction code="45 33 C0" comment="xor r8d, r8d" />		
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="45 33 C0" comment="xor r8d, r8d" />		
				
		<Hook type="call" inst_index="3" value="PatchReceiveTypeUseCustomList" />
	</Patch>
	
	<!-- This patch added in 1.05. Signature is 1.09 -->
	<Patch name="PatchReceiveTypeCustomListNum" type="hook" search_start="0x52A388" comment="Takes place in chasel_func13" >
		<Instruction code="44 8B C3" comment="mov r8d, ebx" />
		<Instruction code="BA F7 1E 00 00" comment="mov edx, 1EF7h" />
		<Instruction code="49 8B CE" comment="mov rcx, r14" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="4C 63 FB" comment="movsxd r15, ebx" />
		<Instruction code="85 DB" comment="test ebx, ebx" />
		
		<Hook type="call" inst_index="3" value="PatchReceiveTypeCustomListNum" />
	</Patch>
	
	<!-- This patch added in 1.05. Signature updated in 1.09 -->
	<Patch name="PatchReceiveType_CustomList_CID_Start" type="hook" search_start="0x52A3CC" comment="Takes place in chasel_func13. initial edi=0x1FF8. initial edi-0x100=0x1EF8" >
		<Instruction code="8D 97 00 FF FF FF" comment="lea edx, [rdi-100h]" />
		<Instruction code="4C 8B C0" comment="mov r8, rax" />
		<Instruction code="49 8B CE" comment="mov rcx, r14" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method3" />
		<Instruction code="49 8B 86 C8 16 00 00" comment="mov rax, [r14+16C8h]" />
		
		<Hook type="call" inst_index="3" value="PatchReceiveType_CustomList_CID_Start" setup="AS3Send3Setup" />
	</Patch>
	
	<!-- This patch added in 1.05. Signature updated in 1.09 -->
	<Patch name="PatchReceiveType_CustomList_MID_Start" type="hook" search_start="0x52A3DD" comment="Takes place in chasel_func13. initial edi=0x1FF8" >
		<Instruction code="49 8B 86 C8 16 00 00" comment="mov rax, [r14+16C8h]" />
		<Instruction code="44 8B 44 18 04" comment="mov r8d, [rax+rbx+4]" />
		<Instruction code="8B D7" comment="mov edx, edi" />
		<Instruction code="49 8B CE" comment="mov rcx, r14" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="49 8B 86 C8 16 00 00" comment="mov rax, [r14+16C8h]" />
		
		<Hook type="call" inst_index="4" value="PatchReceiveType_CustomList_MID_Start" />
	</Patch>
	
	<!-- This patch added in 1.05. Signature updated in 1.09 -->
	<Patch name="PatchReceiveType_CustomList_PID_Start" type="hook" search_start="0x52A3F3" comment="Takes place in chasel_func13. initial edi=0x1FF8. initial edi+0x100=0x20F8" >
		<Instruction code="49 8B 86 C8 16 00 00" comment="mov rax, [r14+16C8h]" />
		<Instruction code="8D 97 00 01 00 00" comment="lea edx, [rdi+100h]" />
		<Instruction code="44 8B 44 18 08" comment="mov r8d, [rax+rbx+8]" />
		<Instruction code="49 8B CE" comment="mov rcx, r14" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="49 8B 86 C8 16 00 00" comment="mov rax, [r14+16C8h]" />
		
		<Hook type="call" inst_index="4" value="PatchReceiveType_CustomList_PID_Start" />
	</Patch>
	
	<!-- This patch added in 1.09 -->
	<Patch name="PatchReceiveType_CustomList_PartnerJudge_Start" type="hook" search_start="0x52A40D" comment="Takes place in chasel_func13. initial edi=0x1FF8. initial edi+0x200=0x21F8" >
		<Instruction code="49 8B 86 C8 16 00 00" comment="mov rax, [r14+16C8h]" />
		<Instruction code="8D 97 00 02 00 00" comment="lea edx, [rdi+200h]" />
		<Instruction code="44 8B 44 18 0C" comment="mov r8d, [rax+rbx+0Ch]" />
		<Instruction code="49 8B CE" comment="mov rcx, r14" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="FF C7" comment="inc edi" />
		<Instruction code="48 FF C6" comment="inc rsi" />
		
		<Hook type="call" inst_index="4" value="PatchReceiveType_CustomList_PartnerJudge_Start" />
	</Patch>
	
	<!-- This patch added in 1.08. Signature updated in 1.09-->
	<Patch name="PatchJoyConSingleFlag" type="hook" search_start="0x52A443" comment="Takes place in chasel_func13" >
		<Instruction code="45 33 C0" comment="xor r8d, r8d" />
		<Instruction code="BA 47 11 00 00" comment="mov edx, 1147h" />
		<Instruction code="49 8B CE" comment="mov rcx, r14" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="90" comment="nop" />
		<Instruction code="48 8B 4D B8" comment="mov rcx, [rbp-48h]" />
				
		<Hook type="call" inst_index="3" value="PatchJoyConSingleFlag" />
		
	</Patch>
	
	<!-- Signature updated in 1.08 -->
	<Patch name="PatchReceiveTypeUnlockVar" type="hook" search_start="0x502214" comment="Takes place in chasel_func6" >
		<Instruction code="44 8B C0" comment="mov r8d, eax" />
		<Instruction code="8D 93 8E 00 00 00" comment="lea edx, [rbx+8Eh]" />
		<Instruction code="48 8B CF" comment="mov rcx, rdi" />
		<Instruction code="48 8B 5C 24 30" comment="mov rbx, [rsp+30h]" />
		<Instruction code="48 83 C4 20" comment="add rsp, 20h" />
		<Instruction code="5F" comment="pop rdi" />
		<Instruction code="E9 XXXXXXXX" comment="jmp send_method2" />
		
		<Hook type="call" inst_index="6" value="PatchReceiveTypeUnlockVar" />
	</Patch>
	
	<!-- Signature updated in 1.08 -->
	<Patch name="PatchReceiveTypeCharaVariation3" type="hook" search_start="0x502275" comment="Takes place in chasel_func10" >
		<Instruction code="44 8B C0" comment="mov r8d, eax" />
		<Instruction code="8D 93 26 11 00 00" comment="lea edx, [rbx+1126h]" />
		<Instruction code="48 8B CE" comment="mov rcx, rsi" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="FF C3" comment="inc ebx" />
		<Instruction code="83 FB 20" comment="cmp ebx, 20h" />
		<Instruction code="7C D3" comment="jmp -0x2D" />
		
		<Hook type="call" inst_index="3" value="PatchReceiveTypeVariation" />
	</Patch>
	
	<!-- This patch added in 1.09 -->
	<Patch name="PatchReceiveType_CostumeNum" type="hook" search_start="0x5291BA" comment="Takes place in chasel_cc" >
		<Instruction code="BA 48 11 00 00" comment="mov edx, 1148h" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="49 8B 8D 08 17 00 00" comment="mov rcx, [r13+1708h]" />
		<Instruction code="48 8B C7" comment="mov rax, rdi" />
		<Instruction code="49 2B 8D 00 17 00 00" comment="sub rcx, [r13+1700h]" />
		<Instruction code="48 F7 E9" comment="imul rcx" />
		
		<Hook type="call" inst_index="1" value="PatchReceiveType_CostumeNum" />
	</Patch>
	
	<!-- The following 10 patches addded in 1.09, and share same signature -->
	<Patch name="PatchReceiveType_CharacterTableStart" type="hook" search_start="0x529200" comment="Takes place in chasel_cc. initial rdi=0x114A" >
		<Instruction code="49 8B 9D 00 17 00 00" comment="mov rbx, [r13+1700h]" />
		<Instruction code="8D 57 FF" comment="lea edx, [rdi-1]" />
		<Instruction code="48 03 DE" comment="add rbx, rsi" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="44 8B 03" comment="mov r8d, [rbx]" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="4C 8D 43 04" comment="lea r8, [rbx+4]" />
		<Instruction code="8B D7" comment="mov edx, edi" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method3" />
		<Instruction code="44 0F BF 43 08" comment="movsx r8d, word ptr [rbx+8]" />
		<Instruction code="8D 57 01" comment="lea edx, [rdi+1]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0A" comment="movsx r8d, word ptr [rbx+0Ah]" />
		<Instruction code="8D 57 02" comment="lea edx, [rdi+2]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0C" comment="movsx r8d, word ptr [rbx+0Ch]" />
		<Instruction code="8D 57 03" comment="lea edx, [rdi+3]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0E" comment="movsx r8d, word ptr [rbx+0Eh]" />
		<Instruction code="8D 57 04" comment="lea edx, [rdi+4]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 10" comment="movsx r8d, word ptr [rbx+10h]" />
		<Instruction code="8D 57 05" comment="lea edx, [rdi+5]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 12" comment="movsx r8d, word ptr [rbx+12h]" />
		<Instruction code="8D 57 06" comment="lea edx, [rdi+6]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 8B 43 14" comment="mov r8d, [rbx+14h]" />
		<Instruction code="8D 57 07" comment="lea edx, [rdi+7]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 8B 43 18" comment="mov r8d, [rbx+18h]" />
		<Instruction code="8D 57 08" comment="lea edx, [rdi+8]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		
		<Hook type="call" inst_index="5" value="PatchReceiveType_CharacterTableStart" />	
	</Patch>
	
	<Patch name="PatchReceiveType_CharacterTableStart2" type="hook" search_start="0x529200" comment="Takes place in chasel_cc. initial rdi=0x114A" >
		<Instruction code="49 8B 9D 00 17 00 00" comment="mov rbx, [r13+1700h]" />
		<Instruction code="8D 57 FF" comment="lea edx, [rdi-1]" />
		<Instruction code="48 03 DE" comment="add rbx, rsi" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="44 8B 03" comment="mov r8d, [rbx]" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="4C 8D 43 04" comment="lea r8, [rbx+4]" />
		<Instruction code="8B D7" comment="mov edx, edi" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method3" />
		<Instruction code="44 0F BF 43 08" comment="movsx r8d, word ptr [rbx+8]" />
		<Instruction code="8D 57 01" comment="lea edx, [rdi+1]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0A" comment="movsx r8d, word ptr [rbx+0Ah]" />
		<Instruction code="8D 57 02" comment="lea edx, [rdi+2]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0C" comment="movsx r8d, word ptr [rbx+0Ch]" />
		<Instruction code="8D 57 03" comment="lea edx, [rdi+3]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0E" comment="movsx r8d, word ptr [rbx+0Eh]" />
		<Instruction code="8D 57 04" comment="lea edx, [rdi+4]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 10" comment="movsx r8d, word ptr [rbx+10h]" />
		<Instruction code="8D 57 05" comment="lea edx, [rdi+5]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 12" comment="movsx r8d, word ptr [rbx+12h]" />
		<Instruction code="8D 57 06" comment="lea edx, [rdi+6]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 8B 43 14" comment="mov r8d, [rbx+14h]" />
		<Instruction code="8D 57 07" comment="lea edx, [rdi+7]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 8B 43 18" comment="mov r8d, [rbx+18h]" />
		<Instruction code="8D 57 08" comment="lea edx, [rdi+8]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		
		<Hook type="call" inst_index="9" value="PatchReceiveType_CharacterTableStart2" />	
	</Patch>
	
	<Patch name="PatchReceiveType_CharacterTableStart3" type="hook" search_start="0x529200" comment="Takes place in chasel_cc. initial rdi=0x114A" >
		<Instruction code="49 8B 9D 00 17 00 00" comment="mov rbx, [r13+1700h]" />
		<Instruction code="8D 57 FF" comment="lea edx, [rdi-1]" />
		<Instruction code="48 03 DE" comment="add rbx, rsi" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="44 8B 03" comment="mov r8d, [rbx]" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="4C 8D 43 04" comment="lea r8, [rbx+4]" />
		<Instruction code="8B D7" comment="mov edx, edi" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method3" />
		<Instruction code="44 0F BF 43 08" comment="movsx r8d, word ptr [rbx+8]" />
		<Instruction code="8D 57 01" comment="lea edx, [rdi+1]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0A" comment="movsx r8d, word ptr [rbx+0Ah]" />
		<Instruction code="8D 57 02" comment="lea edx, [rdi+2]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0C" comment="movsx r8d, word ptr [rbx+0Ch]" />
		<Instruction code="8D 57 03" comment="lea edx, [rdi+3]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0E" comment="movsx r8d, word ptr [rbx+0Eh]" />
		<Instruction code="8D 57 04" comment="lea edx, [rdi+4]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 10" comment="movsx r8d, word ptr [rbx+10h]" />
		<Instruction code="8D 57 05" comment="lea edx, [rdi+5]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 12" comment="movsx r8d, word ptr [rbx+12h]" />
		<Instruction code="8D 57 06" comment="lea edx, [rdi+6]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 8B 43 14" comment="mov r8d, [rbx+14h]" />
		<Instruction code="8D 57 07" comment="lea edx, [rdi+7]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 8B 43 18" comment="mov r8d, [rbx+18h]" />
		<Instruction code="8D 57 08" comment="lea edx, [rdi+8]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		
		<Hook type="call" inst_index="13" value="PatchReceiveType_CharacterTableStart" />	
	</Patch>
	
	<Patch name="PatchReceiveType_CharacterTableStart4" type="hook" search_start="0x529200" comment="Takes place in chasel_cc. initial rdi=0x114A" >
		<Instruction code="49 8B 9D 00 17 00 00" comment="mov rbx, [r13+1700h]" />
		<Instruction code="8D 57 FF" comment="lea edx, [rdi-1]" />
		<Instruction code="48 03 DE" comment="add rbx, rsi" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="44 8B 03" comment="mov r8d, [rbx]" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="4C 8D 43 04" comment="lea r8, [rbx+4]" />
		<Instruction code="8B D7" comment="mov edx, edi" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method3" />
		<Instruction code="44 0F BF 43 08" comment="movsx r8d, word ptr [rbx+8]" />
		<Instruction code="8D 57 01" comment="lea edx, [rdi+1]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0A" comment="movsx r8d, word ptr [rbx+0Ah]" />
		<Instruction code="8D 57 02" comment="lea edx, [rdi+2]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0C" comment="movsx r8d, word ptr [rbx+0Ch]" />
		<Instruction code="8D 57 03" comment="lea edx, [rdi+3]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0E" comment="movsx r8d, word ptr [rbx+0Eh]" />
		<Instruction code="8D 57 04" comment="lea edx, [rdi+4]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 10" comment="movsx r8d, word ptr [rbx+10h]" />
		<Instruction code="8D 57 05" comment="lea edx, [rdi+5]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 12" comment="movsx r8d, word ptr [rbx+12h]" />
		<Instruction code="8D 57 06" comment="lea edx, [rdi+6]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 8B 43 14" comment="mov r8d, [rbx+14h]" />
		<Instruction code="8D 57 07" comment="lea edx, [rdi+7]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 8B 43 18" comment="mov r8d, [rbx+18h]" />
		<Instruction code="8D 57 08" comment="lea edx, [rdi+8]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		
		<Hook type="call" inst_index="17" value="PatchReceiveType_CharacterTableStart" />	
	</Patch>
	
	<Patch name="PatchReceiveType_CharacterTableStart5" type="hook" search_start="0x529200" comment="Takes place in chasel_cc. initial rdi=0x114A" >
		<Instruction code="49 8B 9D 00 17 00 00" comment="mov rbx, [r13+1700h]" />
		<Instruction code="8D 57 FF" comment="lea edx, [rdi-1]" />
		<Instruction code="48 03 DE" comment="add rbx, rsi" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="44 8B 03" comment="mov r8d, [rbx]" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="4C 8D 43 04" comment="lea r8, [rbx+4]" />
		<Instruction code="8B D7" comment="mov edx, edi" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method3" />
		<Instruction code="44 0F BF 43 08" comment="movsx r8d, word ptr [rbx+8]" />
		<Instruction code="8D 57 01" comment="lea edx, [rdi+1]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0A" comment="movsx r8d, word ptr [rbx+0Ah]" />
		<Instruction code="8D 57 02" comment="lea edx, [rdi+2]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0C" comment="movsx r8d, word ptr [rbx+0Ch]" />
		<Instruction code="8D 57 03" comment="lea edx, [rdi+3]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0E" comment="movsx r8d, word ptr [rbx+0Eh]" />
		<Instruction code="8D 57 04" comment="lea edx, [rdi+4]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 10" comment="movsx r8d, word ptr [rbx+10h]" />
		<Instruction code="8D 57 05" comment="lea edx, [rdi+5]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 12" comment="movsx r8d, word ptr [rbx+12h]" />
		<Instruction code="8D 57 06" comment="lea edx, [rdi+6]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 8B 43 14" comment="mov r8d, [rbx+14h]" />
		<Instruction code="8D 57 07" comment="lea edx, [rdi+7]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 8B 43 18" comment="mov r8d, [rbx+18h]" />
		<Instruction code="8D 57 08" comment="lea edx, [rdi+8]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		
		<Hook type="call" inst_index="21" value="PatchReceiveType_CharacterTableStart" />	
	</Patch>
	
	<Patch name="PatchReceiveType_CharacterTableStart6" type="hook" search_start="0x529200" comment="Takes place in chasel_cc. initial rdi=0x114A" >
		<Instruction code="49 8B 9D 00 17 00 00" comment="mov rbx, [r13+1700h]" />
		<Instruction code="8D 57 FF" comment="lea edx, [rdi-1]" />
		<Instruction code="48 03 DE" comment="add rbx, rsi" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="44 8B 03" comment="mov r8d, [rbx]" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="4C 8D 43 04" comment="lea r8, [rbx+4]" />
		<Instruction code="8B D7" comment="mov edx, edi" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method3" />
		<Instruction code="44 0F BF 43 08" comment="movsx r8d, word ptr [rbx+8]" />
		<Instruction code="8D 57 01" comment="lea edx, [rdi+1]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0A" comment="movsx r8d, word ptr [rbx+0Ah]" />
		<Instruction code="8D 57 02" comment="lea edx, [rdi+2]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0C" comment="movsx r8d, word ptr [rbx+0Ch]" />
		<Instruction code="8D 57 03" comment="lea edx, [rdi+3]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0E" comment="movsx r8d, word ptr [rbx+0Eh]" />
		<Instruction code="8D 57 04" comment="lea edx, [rdi+4]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 10" comment="movsx r8d, word ptr [rbx+10h]" />
		<Instruction code="8D 57 05" comment="lea edx, [rdi+5]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 12" comment="movsx r8d, word ptr [rbx+12h]" />
		<Instruction code="8D 57 06" comment="lea edx, [rdi+6]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 8B 43 14" comment="mov r8d, [rbx+14h]" />
		<Instruction code="8D 57 07" comment="lea edx, [rdi+7]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 8B 43 18" comment="mov r8d, [rbx+18h]" />
		<Instruction code="8D 57 08" comment="lea edx, [rdi+8]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		
		<Hook type="call" inst_index="25" value="PatchReceiveType_CharacterTableStart" />	
	</Patch>
	
	<Patch name="PatchReceiveType_CharacterTableStart7" type="hook" search_start="0x529200" comment="Takes place in chasel_cc. initial rdi=0x114A" >
		<Instruction code="49 8B 9D 00 17 00 00" comment="mov rbx, [r13+1700h]" />
		<Instruction code="8D 57 FF" comment="lea edx, [rdi-1]" />
		<Instruction code="48 03 DE" comment="add rbx, rsi" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="44 8B 03" comment="mov r8d, [rbx]" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="4C 8D 43 04" comment="lea r8, [rbx+4]" />
		<Instruction code="8B D7" comment="mov edx, edi" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method3" />
		<Instruction code="44 0F BF 43 08" comment="movsx r8d, word ptr [rbx+8]" />
		<Instruction code="8D 57 01" comment="lea edx, [rdi+1]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0A" comment="movsx r8d, word ptr [rbx+0Ah]" />
		<Instruction code="8D 57 02" comment="lea edx, [rdi+2]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0C" comment="movsx r8d, word ptr [rbx+0Ch]" />
		<Instruction code="8D 57 03" comment="lea edx, [rdi+3]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0E" comment="movsx r8d, word ptr [rbx+0Eh]" />
		<Instruction code="8D 57 04" comment="lea edx, [rdi+4]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 10" comment="movsx r8d, word ptr [rbx+10h]" />
		<Instruction code="8D 57 05" comment="lea edx, [rdi+5]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 12" comment="movsx r8d, word ptr [rbx+12h]" />
		<Instruction code="8D 57 06" comment="lea edx, [rdi+6]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 8B 43 14" comment="mov r8d, [rbx+14h]" />
		<Instruction code="8D 57 07" comment="lea edx, [rdi+7]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 8B 43 18" comment="mov r8d, [rbx+18h]" />
		<Instruction code="8D 57 08" comment="lea edx, [rdi+8]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		
		<Hook type="call" inst_index="29" value="PatchReceiveType_CharacterTableStart" />	
	</Patch>
	
	<Patch name="PatchReceiveType_CharacterTableStart8" type="hook" search_start="0x529200" comment="Takes place in chasel_cc. initial rdi=0x114A" >
		<Instruction code="49 8B 9D 00 17 00 00" comment="mov rbx, [r13+1700h]" />
		<Instruction code="8D 57 FF" comment="lea edx, [rdi-1]" />
		<Instruction code="48 03 DE" comment="add rbx, rsi" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="44 8B 03" comment="mov r8d, [rbx]" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="4C 8D 43 04" comment="lea r8, [rbx+4]" />
		<Instruction code="8B D7" comment="mov edx, edi" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method3" />
		<Instruction code="44 0F BF 43 08" comment="movsx r8d, word ptr [rbx+8]" />
		<Instruction code="8D 57 01" comment="lea edx, [rdi+1]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0A" comment="movsx r8d, word ptr [rbx+0Ah]" />
		<Instruction code="8D 57 02" comment="lea edx, [rdi+2]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0C" comment="movsx r8d, word ptr [rbx+0Ch]" />
		<Instruction code="8D 57 03" comment="lea edx, [rdi+3]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0E" comment="movsx r8d, word ptr [rbx+0Eh]" />
		<Instruction code="8D 57 04" comment="lea edx, [rdi+4]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 10" comment="movsx r8d, word ptr [rbx+10h]" />
		<Instruction code="8D 57 05" comment="lea edx, [rdi+5]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 12" comment="movsx r8d, word ptr [rbx+12h]" />
		<Instruction code="8D 57 06" comment="lea edx, [rdi+6]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 8B 43 14" comment="mov r8d, [rbx+14h]" />
		<Instruction code="8D 57 07" comment="lea edx, [rdi+7]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 8B 43 18" comment="mov r8d, [rbx+18h]" />
		<Instruction code="8D 57 08" comment="lea edx, [rdi+8]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		
		<Hook type="call" inst_index="33" value="PatchReceiveType_CharacterTableStart" />	
	</Patch>
	
	<Patch name="PatchReceiveType_CharacterTableStart9" type="hook" search_start="0x529200" comment="Takes place in chasel_cc. initial rdi=0x114A" >
		<Instruction code="49 8B 9D 00 17 00 00" comment="mov rbx, [r13+1700h]" />
		<Instruction code="8D 57 FF" comment="lea edx, [rdi-1]" />
		<Instruction code="48 03 DE" comment="add rbx, rsi" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="44 8B 03" comment="mov r8d, [rbx]" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="4C 8D 43 04" comment="lea r8, [rbx+4]" />
		<Instruction code="8B D7" comment="mov edx, edi" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method3" />
		<Instruction code="44 0F BF 43 08" comment="movsx r8d, word ptr [rbx+8]" />
		<Instruction code="8D 57 01" comment="lea edx, [rdi+1]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0A" comment="movsx r8d, word ptr [rbx+0Ah]" />
		<Instruction code="8D 57 02" comment="lea edx, [rdi+2]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0C" comment="movsx r8d, word ptr [rbx+0Ch]" />
		<Instruction code="8D 57 03" comment="lea edx, [rdi+3]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0E" comment="movsx r8d, word ptr [rbx+0Eh]" />
		<Instruction code="8D 57 04" comment="lea edx, [rdi+4]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 10" comment="movsx r8d, word ptr [rbx+10h]" />
		<Instruction code="8D 57 05" comment="lea edx, [rdi+5]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 12" comment="movsx r8d, word ptr [rbx+12h]" />
		<Instruction code="8D 57 06" comment="lea edx, [rdi+6]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 8B 43 14" comment="mov r8d, [rbx+14h]" />
		<Instruction code="8D 57 07" comment="lea edx, [rdi+7]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 8B 43 18" comment="mov r8d, [rbx+18h]" />
		<Instruction code="8D 57 08" comment="lea edx, [rdi+8]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		
		<Hook type="call" inst_index="37" value="PatchReceiveType_CharacterTableStart" />	
	</Patch>
	
	<Patch name="PatchReceiveType_CharacterTableStart10" type="hook" search_start="0x529200" comment="Takes place in chasel_cc. initial rdi=0x114A" >
		<Instruction code="49 8B 9D 00 17 00 00" comment="mov rbx, [r13+1700h]" />
		<Instruction code="8D 57 FF" comment="lea edx, [rdi-1]" />
		<Instruction code="48 03 DE" comment="add rbx, rsi" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="44 8B 03" comment="mov r8d, [rbx]" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="4C 8D 43 04" comment="lea r8, [rbx+4]" />
		<Instruction code="8B D7" comment="mov edx, edi" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method3" />
		<Instruction code="44 0F BF 43 08" comment="movsx r8d, word ptr [rbx+8]" />
		<Instruction code="8D 57 01" comment="lea edx, [rdi+1]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0A" comment="movsx r8d, word ptr [rbx+0Ah]" />
		<Instruction code="8D 57 02" comment="lea edx, [rdi+2]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0C" comment="movsx r8d, word ptr [rbx+0Ch]" />
		<Instruction code="8D 57 03" comment="lea edx, [rdi+3]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 0E" comment="movsx r8d, word ptr [rbx+0Eh]" />
		<Instruction code="8D 57 04" comment="lea edx, [rdi+4]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 10" comment="movsx r8d, word ptr [rbx+10h]" />
		<Instruction code="8D 57 05" comment="lea edx, [rdi+5]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 0F BF 43 12" comment="movsx r8d, word ptr [rbx+12h]" />
		<Instruction code="8D 57 06" comment="lea edx, [rdi+6]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 8B 43 14" comment="mov r8d, [rbx+14h]" />
		<Instruction code="8D 57 07" comment="lea edx, [rdi+7]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		<Instruction code="44 8B 43 18" comment="mov r8d, [rbx+18h]" />
		<Instruction code="8D 57 08" comment="lea edx, [rdi+8]" />
		<Instruction code="49 8B CD" comment="mov rcx, r13" />
		<Instruction code="E8 XXXXXXXX" comment="call send_method2" />
		
		<Hook type="call" inst_index="41" value="PatchReceiveType_CharacterTableStart" />	
	</Patch>
	
	<!-- Signature updated in 1.09 -->
	<Patch name="PatchReceiveTypeNum" type="notify" search_start="0x52645E" comment="Takes place in chasel_ctor." >
		<Instruction code="41 B8 F8 22 00 00" comment="mov r8d, 22F8h; r8d = ReceiveType_Num" />
		<Instruction code="E8 XXXXXXXX" comment="call base::ctor" />
		<Instruction code="90" comment="nop" />
		<Instruction code="48 8D 05 XX XX XX XX" comment="lea rax, chasel_vtable" />
		<Instruction code="48 89 07" comment="mov [rdi], rax; this->vtable = chasel_vtable" />
		<Instruction code="B9 06 00 00 00" comment="mov  ecx, 6" />
		<Instruction code="48 8D 87 F0 01 00 00" comment="lea rax, [rdi+1F0h]" />
		
		<Notify inst_index="0" inst_offset="2" value="PatchReceiveTypeNum" />		
	</Patch>
	
<!-- Part 2: modifying the C++ object layout 

The object that takes care about Character Selection in the native side is a C++ object with an allocation size of 0x1720 bytes.
The object has +29 methods (4 of them virtual), including the constructor and the virtual destructor.
The count doesn't include the methods of base classes (virtual methods or not), which are numerous (the object is estimated to be 
***at least*** the third one in the hierarchy)

Object layout:
Offset 0 -> vtable pointer
4-1AF -> base classes properties
1B0-171F -> this class properties

The most important field for our purposes is the one located at offset 0x3F8. 
The field there is a fixed array of ***128*** structures/objects, each one being 32 bytes (so the field takes the range 0x3F8-0x13F7).

Because the array size is the default number of max slots (128), we need to increase this field somehow to match our new number of slots.
There are two ways to solve this:

- Method 1: increase the space for the fixed array, by displacing all other fields offsets (and also increasing the C++ object memory)
Pros: it will only use the memory needed, not a single byte wasted.
Cons: this would require an insane amount of patches, as all fields offset accesses >= 13D8 would have to be modified. It would be difficult 
to maintain, and too prone to errors.

- Method 2: After increasing the C++ object memory, reallocate the fixed array to the old end (to offset 0x1720), and fix its references,
leaving the space 0x3F8-0x13F7 as dead/unused.

- Pros: much easier and faster to implement than 1. More safe because it is less prone to mistakess.
- Cons: ~3KB of memory will be wasted.

Method 2 will be used. Its simplicity well worths to waste 3K of memory.

Half of the implementation can be done in the xml. Only the C++ object increase, and array resize must be done in the .dll because the new size must be computed at runtime.

-->

	<!-- Signature updated in 1.09 -->
	<Patch name="IncreaseChaselMemory" type="notify" search_start="0x3BD38E" >
		<Instruction code="45 33 C9" comment="xor r9d, r9d" />
		<Instruction code="41 83 C8 FF" comment="or r8d, 0FFFFFFFFh" />
		<Instruction code="33 D2" comment="xor edx, edx" />
		<Instruction code="B9 20170000" comment="mov ecx, 1720h" />
		<Instruction code="FF 15 XXXXXXXX" comment="call operator new" />
		<Instruction code="4C 8B D0" comment="mov r10, rax" />
		
		<Notify inst_index="3" inst_offset="1" value="IncreaseChaselMemory" />
	</Patch>
	
	<!-- Signature updated in 1.09 -->
	<Patch name="IncreaseChaselSlotsArray" type="hook" search_start="0x5265A1" comment="Takes place in chasel_ctor." >
		<Instruction code="48 8D 8F F8 03 00 00" comment="lea rcx, [rdi+3F8h]" />
		<Instruction code="4C 89 6C 24 20" comment="mov [rsp+20h], r13" />
		<Instruction code="4C 8D 0D XXXXXXXX" comment="lea r9, some_function_ptr" />
		<Instruction code="BA 20 00 00 00" comment="mov edx, 20h" />
		<Instruction code="44 8D 42 60" comment="lea r8d, [rdx+60h]; 0x20+0x60=0x80=128 decimal" />
		<Instruction code="E8 XXXXXXXX" comment="call XXXXXXXX" />
		
		<Hook type="call" inst_index="5" value="IncreaseChaselSlotsArray" setup="SetupIncreaseChaselSlotsArray" />
	</Patch>
	
	<!-- Signature updated in 1.09-->
	<Patch name="IncreaseChaselSlotsArray2" type="hook" search_start="0x526DC4" comment="Takes place in chasel_func15, the function with most of the destructor implementation." >
		<Instruction code="48 8D 8B F8 03 00 00" comment="lea rcx, [rbx+3F8h]" />
		<Instruction code="4C 8D 0D XXXXXXXX" comment="lea r9, some_function_ptr" />
		<Instruction code="BA 20 00 00 00" comment="mov edx, 20h" />
		<Instruction code="44 8D 42 60" comment="lea r8d, [rdx+60h]; 0x20+0x60=0x80=128 decimal" />
		<Instruction code="E8 XXXXXXXX" comment="call XXXXXXXX" />
		<Instruction code="90" comment="nop" />
		
		<Hook type="call" inst_index="4" value="IncreaseChaselSlotsArray2" setup="SetupIncreaseChaselSlotsArray2" />
	</Patch>
	
	<!-- The following two patches signature are identical to the above two one, that is not an error -->
	<Patch name="ModifyArrayOffset1" type="write" search_start="0x5265A1" comment="Takes place in chasel_ctor." >
		<Instruction code="48 8D 8F F8 03 00 00" comment="lea rcx, [rdi+3F8h]" />
		<Instruction code="4C 89 6C 24 20" comment="mov [rsp+20h], r13" />
		<Instruction code="4C 8D 0D XXXXXXXX" comment="lea r9, some_function_ptr" />
		<Instruction code="BA 20 00 00 00" comment="mov edx, 20h" />
		<Instruction code="44 8D 42 60" comment="lea r8d, [rdx+60h]; 0x20+0x60=0x80=128 decimal" />
		<Instruction code="E8 XXXXXXXX" comment="call XXXXXXXX" />
		
		<Write inst_index="0" inst_offset="3" value="E0 16" />
	</Patch>
	
	<Patch name="ModifyArrayOffset2" type="write" search_start="0x526DC4" comment="Takes place in chasel_func15, the function with most of the destructor implementation." >
		<Instruction code="48 8D 8B F8 03 00 00" comment="lea rcx, [rbx+3F8h]" />
		<Instruction code="4C 8D 0D XXXXXXXX" comment="lea r9, some_function_ptr" />
		<Instruction code="BA 20 00 00 00" comment="mov edx, 20h" />
		<Instruction code="44 8D 42 60" comment="lea r8d, [rdx+60h]; 0x20+0x60=0x80=128 decimal" />
		<Instruction code="E8 XXXXXXXX" comment="call XXXXXXXX" />
		<Instruction code="90" comment="nop" />
		
		<Write inst_index="0" inst_offset="3" value="E0 16" />
	</Patch>
	
	<!-- Signature updated in 1.09 -->
	<Patch name="ModifyArrayOffset3_Multi" type="write" search_start="0x529C6D" comment="Takes place in chasel_func5." >
		<Instruction code="48 8D BE F8 03 00 00" comment="lea rdi, [rsi+3F8h]" />
		<Instruction code="49 8B DE" comment="mov rbx, r14" />
		<Instruction code="89 6C 24 28" comment="mov [rsp+28h], ebp" />
		<Instruction code="48 C1 E3 05" comment="shl rbx, 5" />
		<Instruction code="48 8D 8E 08 16 00 00" comment="lea rcx, [rsi+1608h]" />
		<Instruction code="48 03 FB" comment="add rdi, rbx" />
		<Instruction code="48 C7 44 24 20 00 00 00 00" comment="mov qword ptr[rsp+20h], 0" />
		<Instruction code="48 8B D7" comment="mov rdx, rdi" />
		<Instruction code="45 33 C0" comment="xor r8d, r8d" />
		<Instruction code="E8 XXXXXXXX" comment="call XXXXXXXX" />
		<Instruction code="48 83 BC 33 08 04 00 00 00" comment="cmp qword ptr [rbx+rsi+408h], 0" />
		
		<Write value="XXXXXX20170000 XXXXXX XXXXXXXX XXXXXXXX XXXXXXXXXXXXXX XXXXXX XXXXXXXXXXXXXXXXXX XXXXXX XXXXXX XXXXXXXXXX XXXXXXXX3017"  /> 
	</Patch>
	
</EternityPatchFile>