wooteevar, post: 138719, member: 21189 wrote:
I think your main issue is you are kind of just plugging in without trying to understand the underlying code. I am not sure what old table you are using or the version of the game you are running so I will do this "craft anything" from okami-x's table 1.4.0.5 Intel (steam). I am running 1.4.0.4 AMD GoG so there will be differences (just lazy to patch it to the latest).
The most important thing for you are the assert bytes. Those are what the script checks to see if the code it wants to replace is present. The define parts are the location it expects that data to be.
In this particular case some of the offsets do match while others will be different. I first notice the offsets are pretty close the the beginning of the function, so all that I said before about aligning is really not necessary. Now just goto Terraria.Recipe::FindRecipes with no offset. Then scroll down manually to the first one +8D and get :
Code: Select all
Terraria.Recipe::FindRecipes+87 - 0F83 B50C0000 - jae Terraria.Recipe::FindRecipes+D42
Terraria.Recipe::FindRecipes+8D - 33 C9 - xor ecx,ecx
Terraria.Recipe::FindRecipes+8F - 89 4C 90 08 - mov [eax+edx*4+08],ecx
That is exactly what I needed recipe1 is looking for 33 C9 at location +8D so I don't need to change a thing here. So we move to the next one so it is looking for +9C so I scroll down some more and I get this:
Code: Select all
Terraria.Recipe::FindRecipes+96 - 3B 15 1C094706 - cmp edx,[0647091C]
Terraria.Recipe::FindRecipes+9C - 7C E1 - jl Terraria.Recipe::FindRecipes+7F
Terraria.Recipe::FindRecipes+9E - 33 D2 - xor edx,edx
Terraria.Recipe::FindRecipes+A0 - 89 15 1C0E4706 - mov [06470E1C],edx
I am looking for 33 D2 at +9C but it's not there. But it appears right below it at +9E so I have to change the define to be Terraria.Recipe::FindRecipes+9E to fix it. That takes care of recipe2. So next recipe3 is somewhere around +B0 so I scroll down some more and I get:
Code: Select all
Terraria.Recipe::FindRecipes+AB - 83 B8 90000000 00 - cmp dword ptr [eax+00000090],00
Terraria.Recipe::FindRecipes+B2 - 0F8E 7E000000 - jng Terraria.Recipe::FindRecipes+136
Terraria.Recipe::FindRecipes+B8 - A1 AC5CDB04 - mov eax,[04DB5CAC]
Terraria.Recipe::FindRecipes+BD - 83 B8 A4000000 00 - cmp dword ptr [eax+000000A4],00
So +B0 doesn't exist. So I have to change the define here. I look for the code it's looking for in the assert 0F 8E 7E 00 00 00 and I find it at +B2. That means I change the define to Terraria.Recipe::FindRecipes+B2 and if you assume we are done you are wrong, we are not. Now you have to go through the actual changes for each recipe especially for offsets, function calls, and jumps.
recipe1 - only changes a xor to a move between registers so that's fine.
recipe2 - just nops the xor of 2 registers so that's fine
recipe3 - changes a jump not greater than to a jump to another area of find recipes so we have to find and check that part of the code. This can be difficult to do since we have no assert clues to help us. okami-x's code wants to go to +12F but that doesn't exist for me. I get this:
Code: Select all
Terraria.Recipe::FindRecipes+129 - 85 C0 - test eax,eax
Terraria.Recipe::FindRecipes+12B - 0F94 C0 - sete al
Terraria.Recipe::FindRecipes+12E - 0FB6 C0 - movzx eax,al
Terraria.Recipe::FindRecipes+131 - 89 45 90 - mov [ebp-70],eax
So where do we need to go? To really get the answer we should really figure out what is going on but in this particular case we can make an educated guess. Recipe2 was +2 bytes away from where we needed to go. Similarly Recipe3 wanted +B0 but we found it at +B2 so it seems as if what we want is usually about +2 bytes away. Does that exist in this case? Yes it does. 12F + 2 (hex addition) = 131. So does +131 exist it does. So giving that a try we change:
Code: Select all
recipe3:
jmp Terraria.Recipe::FindRecipes+12F
To:
Code: Select all
recipe3:
jmp Terraria.Recipe::FindRecipes+131
You also have to double check the disable code and make sure they match the assert bytes. This is critical to do if you had to change the assert bytes due to a memory location change or a jump offset change. We didn't in this case so we are done.