![]() |
|
|
#1 |
|
Архивный участник
Join Date: Jan 2006
Posts: 363
|
[原创] 使用数组方式实现的 //create_pet,支持任意多组宠物并可自由� ��展
by ET2004 (QQ 52923913, EMail: [email protected]) * 转贴请保持完整,谢谢合作 * 最后更新于 2006/05/29 15:10 实现原理 00414444 处为一个 int/int 类型的数组,共 15 个元素,程序从 //create_pet n 命令 得到数组索引,依据索引定位对应的 NPC ID / 物品 ID,取出对应的值并作为参数传递给 CreatePet 函数。如果需要使用超过 15 组的 //create_pet,请将数组移至其他位置,并 修改间接寻址基址。 结构体定义 typedef struct tagPETSTRUCT { int nNpcId; int nItemId; } PETSTRUCT; NPC ID/Item ID 对应关系 id: address : npc id / item : npc id / item : npc class ----------------------------------------------------------------------- 01: 00414444 : 000F716D / 0947 : 1012077 / 2375 : wolf 02: 0041444C : 000F7257 / 0DAC : 1012311 / 3500 : hatchling_of_wind 03: 00414454 : 000F7258 / 0DAD : 1012312 / 3501 : hatchling_of_star 04: 0041445C : 000F7259 / 0DAE : 1012313 / 3502 : hatchling_of_twilight 05: 00414464 : 000F732E / 1146 : 1012526 / 4422 : wind_strider 06: 0041446C : 000F732F / 1147 : 1012527 / 4423 : star_strider 07: 00414474 : 000F7330 / 1148 : 1012528 / 4424 : twilight_strider 08: 0041447C : 000F738D / 0421 : 1012621 / 1057 : wyvern 09: 00414484 : 000F742C / 19F8 : 1012780 / 6648 : pet_baby_buffalo 10: 00414494 : 000F742E / 19FA : 1012782 / 6649 : pet_baby_cougar 11: 0041448C : 000F742D / 19F9 : 1012781 / 6650 : pet_baby_kukaburo ; for future using 12: 0041449C : 000F738D / 0421 : 1012621 / 1057 : wyvern 13: 004144A4 : 000F738D / 0421 : 1012621 / 1057 : wyvern 14: 004144AC : 000F738D / 0421 : 1012621 / 1057 : wyvern 15: 004144B4 : 000F738D / 0421 : 1012621 / 1057 : wyvern Server 代码,请使用 Asm 或 Hex 方式直接写入 004143B4 74 40 je short L2Server.004143F6 004143DC 83F8 0A cmp eax,0A ; index=ID-1 004143DF 76 3A jbe short L2Server.0041441B 004143E1 8B45 0C mov eax,dword ptr ss:[ebp+C] 004143E4 8B88 B8190000 mov ecx,dword ptr ds:[eax+19B8] 004143EA 68 90CF5B00 push L2Server.005BCF90 ; UNICODE "create_pet 1~15 (1=fox, 2~4=hatchling)" 004143EF 68 88CF5B00 push L2Server.005BCF88 ; UNICODE "pet" 004143F4 EB 0D jmp short L2Server.00414403 004143F6 8B4D 08 mov ecx,dword ptr ss:[ebp+8] 004143F9 68 DCCF5B00 push L2Server.005BCFDC ; UNICODE "create_pet 1~15" 004143FE 68 FCCA5B00 push L2Server.005BCAFC ; UNICODE "SYS" 00414403 E8 A8200F00 call L2Server.005064B0 00414408 32C0 xor al,al 0041440A 8B4D F4 mov ecx,dword ptr ss:[ebp-C] 0041440D 64:890D 00000000 mov dword ptr fs:[0],ecx 00414414 5F pop edi 00414415 5E pop esi 00414416 5B pop ebx 00414417 8BE5 mov esp,ebp 00414419 5D pop ebp 0041441A C3 retn 0041441B 90 nop 0041441C 8B0CC5 44444100 mov ecx,dword ptr ds:[eax*8+414444] 00414423 85C9 test ecx,ecx 00414425 74 BA je short L2Server.004143E1 00414427 8B04C5 48444100 mov eax,dword ptr ds:[eax*8+414448] 0041442E 85C0 test eax,eax 00414430 74 AF je short L2Server.004143E1 00414432 8B55 0C mov edx,dword ptr ss:[ebp+C] 00414435 51 push ecx 00414436 50 push eax 00414437 52 push edx 00414438 E8 B3861300 call L2Server.0054CAF0 0041443D 83C4 0C add esp,0C 00414440 ^ EB C6 jmp short L2Server.00414408 00414442 90 nop 00414443 90 nop 数组数据,请使用 Hex 方式直接写入 ; Pet/Item table (15 pairs) 00414444 6D 71 0F 00 47 09 00 00 57 72 0F 00 AC 0D 00 00 00414454 58 72 0F 00 AD 0D 00 00 59 72 0F 00 AE 0D 00 00 00414464 2E 73 0F 00 46 11 00 00 2F 73 0F 00 47 11 00 00 00414474 30 73 0F 00 48 11 00 00 8D 73 0F 00 21 04 00 00 00414484 2C 74 0F 00 F8 19 00 00 2E 74 0F 00 F9 19 00 00 00414494 2D 74 0F 00 FA 19 00 00 8D 73 0F 00 21 04 00 00 004144A4 8D 73 0F 00 21 04 00 00 8D 73 0F 00 21 04 00 00 004144B4 8D 73 0F 00 21 04 00 00 系统提示,请使用 Hex 方式直接写入 ; UNICODE "create_pet 1~15 (1=fox, 2~4=hatchling)" 005BCF90 63 00 72 00 65 00 61 00 74 00 65 00 5F 00 70 00 005BCFA0 65 00 74 00 20 00 31 00 7E 00 31 00 31 00 20 00 005BCFB0 28 00 31 00 3D 00 66 00 6F 00 78 00 2C 00 20 00 005BCFC0 32 00 3D 00 68 00 61 00 74 00 63 00 68 00 6C 00 005BCFD0 69 00 6E 00 67 00 29 00 00 00 00 00 ; UNICODE "create_pet 1~15" 005BCFDC 63 00 72 00 65 00 61 00 74 00 65 00 5F 00 70 00 005BCFEC 65 00 74 00 20 00 31 00 7E 00 31 00 31 00 00 00 005BCFFC 00 00 00 00 12-15 为备用 ID,所以上述代码中限制了 ID 为 1-11,放宽此限制可做如下修改: ; 004143DC 83F8 0E cmp eax,0E 注意: 如果数组中使用了 npcdata/npc_pch.txt 中未定义的 npc id,//create_pet 会导致 Server 异常退出。 |
|
|
|
|
#2 |
|
Архивный участник
Join Date: Apr 2006
Posts: 30
|
Oww,nice info thx
.
|
|
|
|
|
#3 |
|
Архивный участник
Join Date: May 2006
Posts: 25
|
et pet_X good
|
|
|
|
|
#4 |
|
Архивный участник
Join Date: Jul 2005
Posts: 371
|
in case you wanna know how everything works
http://bbs.99nets.com/read.php?tid=216308&keyword= 【共享】究竟当初诺飞是用何种方法� �改create_pet的呢,听我说来 用Ollydbg打开原始的L2Server 然后点右键选择Search for然后选All referenced text strings 在搜索的结果中搜索create_pet Text strings referenced in L2Server:.text, item 1012 Address=004143EF Disassembly=PUSH L2Server.005BCFDC Text string=UNICODE "//create_pet 1~3" 他会给你一个这个 双击它 然后会跳转到 004143DC |. 83F8 03 CMP EAX,3 004143DF |. 0F87 D8000000 JA L2Server.004144BD 004143E5 |. FF2485 0045410>JMP DWORD PTR DS:[EAX*4+414500] 004143EC |> 8B4D 08 MOV ECX,DWORD PTR SS:[EBP+8] 004143EF |. 68 DCCF5B00 PUSH L2Server.005BCFDC ; /Arg2 = 005BCFDC 004143F4 |. 68 FCCA5B00 PUSH L2Server.005BCAFC ; |Arg1 = 005BCAFC 004143F9 |> E8 B2200F00 CALL L2Server.005064B0 ; \L2Server.005064B0 004143FE |. 32C0 XOR AL,AL 00414400 |. 8B4D F4 MOV ECX,DWORD PTR SS:[EBP-C] 00414403 |. 64:890D 000000>MOV DWORD PTR FS:[0],ECX 0041440A |. 5F POP EDI 0041440B |. 5E POP ESI 0041440C |. 5B POP EBX 0041440D |. 8BE5 MOV ESP,EBP 0041440F |. 5D POP EBP 00414410 |. C3 RETN 这一段就是create_pet这个指令的汇编段 红色的是跳转以后的地方 004143DC |. 83F8 03 CMP EAX,3 ;比较EAX跟3 004143DF |. 0F87 D8000000 JA L2Server.004144BD ;如果高于3的话,跳转到001144BD也就是� ��示create_pet 1~2 (1=fox, 2=hatchling) 004143E5 |. FF2485 0045410>JMP DWORD PTR DS:[EAX*4+414500] ;414500是个Switch table,它返回的是 //======================== 00414500 . 11444100 DD L2Server.00414411 ; Switch table used at 004143E5 ;0x4+414500 00414504 . 3C444100 DD L2Server.0041443C ;1x4+414500 00414508 . 67444100 DD L2Server.00414467 ;2x4+414500 0041450C . 92444100 DD L2Server.00414492 ;3x4+414500 里头DD的值就是对应的地址,DWORD PTR DS:[EAX*4+414500]就把它变为地址,然后jmp过去 这个是宠物添加的基本框架 MOV EDX,DWORD PTR SS:[EBP+C] MOV ECX,0F716D ;npc的编号hex格式 1012077 PUSH ECX ;int nPetNpcClassID MOV EAX,947 ;召唤道具的hex格式 2375 PUSH EAX ; int nPetCollarClassID PUSH EDX ;CSharedCreatureData* to CALL 0054CAF0 ;void CNPC::CreatePet(CSharedCreatureData* to, int nPetCollarClassID, int nPetNpcClassID) ADD ESP,0C XOR AL,AL MOV ECX,DWORD PTR SS:[EBP-C] MOV DWORD PTR FS:[0],ECX POP EDI POP ESI POP EBX MOV ESP,EBP POP EBP RETN 诺飞所作的其实就是扩展Switch table,在后面添加3个新的地址,每个� �址指向一个新的位置,然后跳转过去 我能说得就这么多了,修改程序难的� �方在于如何找到需要改的东西的地址� ��而不在于修改的东西 |
|
|
|
|
#5 |
|
Архивный участник
Join Date: Apr 2006
Posts: 729
|
Very good manual! Thank you!
|
|
|
|
|
#6 | |
|
Архивный участник
Join Date: Nov 2005
Posts: 146
|
Quote:
I remember not so long time ago community shout "Don't write in russian! Repect other ppls! Write in English!"... Funny things... |
|
|
|
|
|
#7 |
|
Архивный участник
Join Date: Jun 2005
Posts: 262
|
Ok I'm trying to understand here...
I understand this: Code:
MOV EDX,DWORD PTR SS:[EBP+C] MOV ECX,0F716D ;npc的编号hex格式 1012077 PUSH ECX ;int nPetNpcClassID MOV EAX,947 ;召唤道具的hex格式 2375 PUSH EAX ; int nPetCollarClassID PUSH EDX ;CSharedCreatureData* to CALL 0054CAF0 ;void CNPC::CreatePet(CSharedCreatureData* to, int nPetCollarClassID, int nPetNpcClassID) ADD ESP,0C XOR AL,AL MOV ECX,DWORD PTR SS:[EBP-C] MOV DWORD PTR FS:[0],ECX POP EDI POP ESI POP EBX MOV ESP,EBP POP EBP RETN I think it's Code:
004143EF |. 68 DCCF5B00 PUSH L2Server.005BCFDC ; /Arg2 = 005BCFDC 004143F4 |. 68 FCCA5B00 PUSH L2Server.005BCAFC ; |Arg1 = 005BCAFC 004143F9 |> E8 B2200F00 CALL L2Server.005064B0 ; \L2Server.005064B0 |
|
|
|
|
#8 | ||
|
Архивный участник
Join Date: Oct 2005
Posts: 17
|
Quote:
|
||
|
|
|
|
#9 | ||
|
Архивный участник
Join Date: Aug 2005
Posts: 1,531
|
Quote:
We need know all on this language
|
||
|
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|