由于CAPI1.2不兼容win8以上系统,Defanive大神的MotaHD无法加载CAPI,导致无法在新系统上运行…
本身多么经典的批处理游戏,就这样陪着旧系统长眠了???? NO NO NO 改下加载方式依然复活如初!!!
请允许我不厚道的转载并添加了自己的名字。毕竟这么好的东西没人修复,太可惜了。算是我动手留念吧
论真的修复倒是算不上,只是将CAPI换成CAPIx,并且分别使用两种加载方式而已。
画面,手感,声音,菜单,样样俱全!!但依然是批处理游戏,刺激不!?
我在XPX32和WIN10X64系统下测试,无问题!其他人也可以测试测试
1 2 3 |
%1@ver|find "5." > NUL && CAPIx || start /b "" "%~dp0cmd.exe" "/c %~fs0 :" &&exit ::%1for /f "tokens=4,5 delims=. " %%a in ('ver') do (if %%a%%b gtr 60 (start /b "" "%~dps0cmd.exe" "/c %~fs0 :" &exit) else (CAPIx)) |
上面是切换加载CAPIx的方式,两行好像都行
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 |
@echo off %1@ver|find "5." > NUL && CAPIx || start /b "" "%~dp0cmd.exe" "/c %~fs0 :" &&exit ::%1for /f "tokens=4,5 delims=. " %%a in ('ver') do (if %%a%%b gtr 60 (start /b "" "%~dps0cmd.exe" "/c %~fs0 :" &exit) else (CAPIx)) REM ———————————————————— REM MotaHD REM Made By Defanive REM Repaired By ZhangZsky REM ———————————————————— REM Version 1.1 REM Original 21 Floors REM ———————————————————— REM CAPI REM 1.2 Build 1D910 x32 REM ———————————————————— REM Added "restart" menu and shortcut key 'R' REM Added CAPI check REM Removed default menus REM Removed unused files REM Fixed game logic errors REM Fixed chatting dialog reacting too fast REM Fixed sound played before action completed REM ———————————————————— title Loading... call :InitFunctions call :InitCAPI setlocal enabledelayedexpansion (%Function_InitVars%) (%Function_InitCMD%) (%Function_InitWindow%) (%Function_InitMenu%) (%Function_InitGDI%) (%Function_InitText%) (%Function_InitBlock%) (%Function_InitEnter%) (%Function_InitGraphics%) (%Function_PlayBGM%) :Game_Restart (%Function_InitPlayerData%) (%Function_InitMaps:#MapName#=Map%) call :Function_GotoFloor 0 set "Screen_UI_Message=方向键 移动,空格键 确认,S/A键 保存/读取" (%Function_DrawUI%) :Game_Main (%Function_DrawMap%) (%Function_DrawScreen%) set CAPI=API Call kernel32 ReadConsoleInputW ;%hIn% ;%lpIR% ;1 ;%lpData% set CAPI=Mem Print ;%lpIR% :IRType @2 ;IRData1 @2 :IRData2 set /a Player_New_X=Player_X,Player_New_Y=Player_Y if "%IRType%-%IRData1%"=="1-1" ( if "%Screen_UI_Message%" neq "" set "Screen_UI_Message="&(%Function_DrawUI%) if "%IRData2%"=="38" set hIco_Player=!hIco_p1!&if "!Player_Y!" neq "0" (set /a Player_New_Y=Player_Y-1,Player_New_X=Player_X) else goto :Game_Main if "%IRData2%"=="40" set hIco_Player=!hIco_p3!&if "!Player_Y!" neq "10" (set /a Player_New_Y=Player_Y+1,Player_New_X=Player_X) else goto :Game_Main if "%IRData2%"=="37" set hIco_Player=!hIco_p0!&if "!Player_X!" neq "0" (set /a Player_New_X=Player_X-1,Player_New_Y=Player_Y) else goto :Game_Main if "%IRData2%"=="39" set hIco_Player=!hIco_p2!&if "!Player_X!" neq "10" (set /a Player_New_X=Player_X+1,Player_New_Y=Player_Y) else goto :Game_Main if "%IRData2%"=="76" if "%Player_ShowEnemyData%"=="1" call :Function_ShowEnemyData if "%IRData2%"=="74" if "%Player_JumpFloor%"=="1" if "%Player_Floor%" neq "21" call :Function_JumpFloor&goto :Game_Main if "%IRData2%"=="83" call :Function_SaveData&goto :Game_Main if "%IRData2%"=="65" call :Function_LoadData&goto :Game_Main if "%IRData2%"=="82" goto :Game_Restart ) else if "%IRType%"=="8" ( if "%IRData1%"=="501" call :Function_SaveData if "%IRData1%"=="502" call :Function_LoadData if "%IRData1%"=="503" goto :Game_Restart if "%IRData1%"=="504" (%Function_ShowAbout%) goto :Game_Main ) set "Event_Block=!Map_Source_%Player_Floor%_%Player_New_Y%:~%Player_New_X%,1!" goto :Function_Event_!Block_%Event_Block%_:~6,1! :Game_End (%Function_DrawMap%) (%Function_DrawScreen%) call :Function_ShowChat p3 "系统" "杀死魔王,游戏结束!" (%Function_ShowAbout%) exit goto :eof :InitCAPI CAPI 2>nul set CAPI_Ret= set CAPI=CAPIDll Ver if "%CAPI_Ret%"=="" ( echo CAPI加载失败 echo 请尝试关闭杀软或将本文件夹设为信任 pause>nul exit ) goto :eof :InitFunctions set "Function_InitCMD=mode con: cols=44 lines=31&set CAPI=Mem Alloc 8&set lpCCI=!CAPI_Ret!&set CAPI=Mem Put ;!lpCCI! ;100&set CAPI=API Call kernel32 SetConsoleCursorInfo ;!hOut! ;!lpCCI!&set CAPI=Mem Free !lpCCI!&set CAPI=API Call user32 LoadImageW ;0 $Graphics\_cmd.ico ;1 ;0 ;0 ;16&set hIco_cmd=!CAPI_Ret!&set CAPI=API Call kernel32 SetConsoleIcon ;!hIco_cmd!" set "Function_InitWindow=set CAPI=API Call kernel32 GetConsoleWindow&set hCMD=!CAPI_Ret!&set CAPI=Mem Alloc 16&set lpRC=!CAPI_Ret!&set CAPI=API Call user32 GetWindowRect ;!hCMD! ;!lpRC!&set CAPI=Mem Print ;!lpRC! ;xLeft ;yTop ;xRight ;yBottom&set /a xWidth=xRight-xLeft,yHeight=yBottom-yTop&set CAPI=API Call user32 ScreenToClient ;!hCMD! ;!lpRC!&set CAPI=Mem Print ;!lpRC! ;xWnd ;yWnd&set /a xWnd=-xWnd,yWnd=-yWnd&set CAPI=API Call user32 GetDesktopWindow&set CAPI=API Call user32 GetClientRect ;!CAPI_Ret! ;!lpRC!&set CAPI=Mem Print ;!lpRC! @8 ;xScreen ;yScreen&set /a xPos=xScreen-xWidth,xPos/=2,yPos=yScreen-yHeight,yPos/=2&set CAPI=API Call user32 MoveWindow ;!hCMD! ;!xPos! ;!yPos! ;!xWidth! ;!yHeight! ;1&set CAPI=Mem Free !lpRC!" set "Function_InitMenu=set CAPI=API Call kernel32 ConsoleMenuControl ;!hOut! ;501 ;504&set hMenu=!CAPI_Ret!&set CAPI=API Call user32 GetMenuItemCount ;!hMenu!&(for /l %%a in (!CAPI_Ret!,-1,0) do (set CAPI=API Call user32 GetMenuItemID ;!hMenu! ;%%a&if "!CAPI_Ret!" neq "61536" set CAPI=API Call user32 DeleteMenu ;!hMenu! ;%%a ;1024))&set CAPI=API Call user32 AppendMenuW ;!hMenu! ;2048 ;0 ;0&set CAPI=API Call user32 AppendMenuW ;!hMenu! ;0 ;501 "$保存进度(^&S)"&set CAPI=API Call user32 AppendMenuW ;!hMenu! ;0 ;502 "$读取进度(^&A)"&set CAPI=API Call user32 AppendMenuW ;!hMenu! ;0 ;503 "$重新开始(^&R)"&set CAPI=API Call user32 AppendMenuW ;!hMenu! ;0 ;504 "$关于(^&I)"" set "Function_InitGDI=set CAPI=API Call user32 GetWindowDC ;!hCMD!&set hDC=!CAPI_Ret!&set CAPI=API Call gdi32 CreateCompatibleDC ;!hDC!&set hDCMap=!CAPI_Ret!&set CAPI=API Call gdi32 CreateCompatibleBitmap ;!hDC! ;352 ;352&set hBMPMap=!CAPI_Ret!&set CAPI=API Call gdi32 SelectObject ;!hDCMap! ;!hBMPMap!&set CAPI=API Call gdi32 CreateCompatibleDC ;!hDC!&set hDCMem=!CAPI_Ret!&set CAPI=API Call gdi32 CreateCompatibleBitmap ;!hDC! ;352 ;496&set hBMPMem=!CAPI_Ret!&set CAPI=API Call gdi32 SelectObject ;!hDCMem! ;!hBMPMem!" set "Function_InitText=set CAPI=API Call user32 GetDC ;0&set CAPI=API Call gdi32 GetDeviceCaps ;!CAPI_Ret! ;90&set CAPI=API Call kernel32 MulDiv ;12 ;!CAPI_Ret! ;72&set /a nHeight=-!CAPI_Ret!&set CAPI=API Call gdi32 CreateFontW ;!nHeight! ;0 ;0 ;0 ;500 ;0 ;0 ;0 ;1 ;0 ;0 ;2 ;0 "$微软雅黑"&set CAPI=API Call gdi32 SelectObject ;!hDCMem! ;!CAPI_Ret!&set CAPI=API Call gdi32 SetBkMode ;!hDCMem! ;1&set CAPI=API Call gdi32 SetTextColor ;!hDCMem! ;0&set CAPI=Mem Alloc 48&set /a lpRC1=!CAPI_Ret!,lpRC2=lpRC1+16,lpRC3=lpRC2+16&set CAPI=Mem Put ;!lpRC1! ;96 ;24 ;352 ;72 ;16 ;448 ;336 ;496 ;80 ;288 ;320 ;416" set "Function_InitBlock=for /f "usebackq delims=" %%a in ("%~dp0Data\Block.txt") do (set "t=%%a"&set "Block_!t:~0,1!_=._._._!t:~1,1!_!t:~2!"&set CAPI=API Call user32 LoadImageW ;0 $Graphics\!t:~0,1!.ico ;1 ;0 ;0 ;16&set hIco_!t:~0,1!=!CAPI_Ret!)" set "Function_InitMaps=set i=0&for /f "usebackq delims=" %%a in ("%~dp0Data\#MapName#.txt") do (set /a "MapID=i/11"&set /a "LineID=i%%11"&set "Map_Source_!MapID!_!LineID!=%%a"&set /a i+=1)" set "Function_InitEnter=set t=0&for /f "usebackq tokens=1-4 delims=," %%a in ("%~dp0Data\Enter.txt") do (set "Map_Enter_!t!_IX=%%a"&set "Map_Enter_!t!_IY=%%b"&set "Map_Enter_!t!_OX=%%c"&set "Map_Enter_!t!_OY=%%d"&set /a t+=1)" set "Function_InitGraphics=(for /l %%a in (0,1,3) do (set CAPI=API Call user32 LoadImageW ;0 $Graphics\_p%%a.ico ;1 ;0 ;0 ;16&set hIco_p%%a=!CAPI_Ret!))&set CAPI=API Call user32 LoadImageW ;0 $Graphics\_ground.ico ;1 ;0 ;0 ;16&set hIco_ground=!CAPI_Ret!&set CAPI=API Call user32 LoadImageW ;0 $Graphics\_ui.ico ;1 ;0 ;0 ;16&set hIco_ui=!CAPI_Ret!&set CAPI=API Call user32 LoadImageW ;0 $Graphics\_uig.ico ;1 ;0 ;0 ;16&set hIco_uig=!CAPI_Ret!&set CAPI=API Call user32 LoadImageW ;0 $Graphics\_gblock.ico ;1 ;0 ;0 ;16&set hIco_gblock=!CAPI_Ret!&set CAPI=API Call user32 LoadImageW ;0 $Graphics\_uidialog.ico ;1 ;0 ;0 ;16&set hIco_uidialog=!CAPI_Ret!" set "Function_InitPlayerData=set "Player_HP=1000"&set "Player_Att=10"&set "Player_Def=10"&set "Player_Coin=0"&set "Player_Exp=0"&set "Player_YKey=0"&set "Player_BKey=0"&set "Player_RKey=0"&set "Player_BeenTo=0"&set "Player_ShowEnemyData=0"&set "Player_JumpFloor=0"&set "Player_Get18=0"&set "Player_GetCross=0"&set "Player_Floor=0"&set hIco_Player=!hIco_p3!" set "Function_InitVars=set "Return_Choice=1"&set "Screen_UI_Message="&set CAPI=Mem Alloc 20&set lpIR=!CAPI_Ret!&set CAPI=Mem Alloc 4&set lpData=!CAPI_Ret!&set CAPI=API Call kernel32 GetStdHandle ;-10&set hIn=!CAPI_Ret!&set CAPI=API Call kernel32 GetStdHandle ;-11&set hOut=!CAPI_Ret!" set "Function_PlaySound=set CAPI=API Call winmm sndPlaySoundW $Sound\snd#snd#.wav ;1" set "Function_PlayBGM=set CAPI=API Call winmm mciSendStringW "$open "Sound\sndBGM.mp3" type mpegvideo alias bgm wait" ;0 ;0 ;0&set CAPI=API Call winmm mciSendStringW "$play bgm repeat" ;0 ;0 ;0" set "Function_DrawMap=set CAPI=API Call gdi32 BitBlt ;!hDCMem! ;0 ;96 ;352 ;352 ;!hDCMap! ;0 ;0 ;13369376&set /a xPos=Player_X*32,yPos=Player_Y*32+96&set CAPI=API Call user32 DrawIconEx ;!hDCMem! ;!xPos! ;!yPos! ;!hIco_Player! ;32 ;32 ;0 ;0 ;3" set "Function_DrawUI=set CAPI=API Call user32 DrawIconEx ;!hDCMem! ;0 ;0 ;!hIco_ui! ;352 ;96 ;0 ;0 ;3&set CAPI=API Call user32 DrawIconEx ;!hDCMem! ;0 ;448 ;!hIco_ui! ;352 ;96 ;0 ;0 ;3&set CAPI=API Call user32 DrawIconEx ;!hDCMem! ;16 ;16 ;!hIco_uig! ;64 ;64 ;0 ;0 ;3&set CAPI=API Call user32 DrawIconEx ;!hDCMem! ;32 ;32 ;!hIco_p3! ;32 ;32 ;0 ;0 ;3&set CAPI=API Call user32 DrawTextW ;!hDCMem! "$血 !Player_HP! 攻 !Player_Att! 防 !Player_Def!!CrLf!币 !Player_Coin! 经 !Player_Exp! 黄 !Player_YKey! 蓝 !Player_BKey! 红 !Player_RKey!" ;-1 ;!lpRC1! ;0&set CAPI=API Call user32 DrawTextW ;!hDCMem! "$!Screen_UI_Message!" ;-1 ;!lpRC2! ;36" set "Function_DrawScreen=set CAPI=API Call gdi32 BitBlt ;!hDC! ;!xWnd! ;!yWnd! ;!xWidth! ;!yHeight! ;!hDCMem! ;0 ;0 ;13369376" set "Function_AfterGetItem=(%Function_DrawUI%)&call :Function_ChangeBlock !Player_New_X! !Player_New_Y! q !Player_Floor!" set "Function_SetTitle=set CAPI=API Call kernel32.dll SetConsoleTitleW "$#Title#"" set "Function_ShowAbout=call :Function_ShowChat cmd "MotaHD" "批处理制作:^^!CrLf^^! Defanive, Neoix Team^^!CrLf^^! 第三方工具:^^!CrLf^^! CAPI"" set CrLf=^ goto :eof :Function_ChangeBlock set /a "t1=%~1*2+%~2*48+1","t2=t1+2","t3=%~1*2+%~2*48+25-t2","t4=t3+t2+2","t5=%~1*4+%~2*96+2","t6=t5+4","t7=%~1*4+%~2*96+50-t6","t8=t7+t6+4","t9=%~1+1" set "Map_Source_%~4_%~2=!Map_Source_%~4_%~2:~0,%~1!%~3!Map_Source_%~4_%~2:~%t9%!" if "%~4"=="%Player_Floor%" ( set /a xPos=%~1*32,yPos=%~2*32 set CAPI=API Call user32 DrawIconEx ;!hDCMap! ;!xPos! ;!yPos! ;!hIco_gblock! ;32 ;32 ;0 ;0 ;3 set CAPI=API Call user32 DrawIconEx ;!hDCMap! ;!xPos! ;!yPos! ;!hIco_%~3! ;32 ;32 ;0 ;0 ;3 ) goto :eof :Function_ShowChat set CAPI=API Call user32 DrawIconEx ;!hDCMem! ;16 ;272 ;!hIco_uidialog! ;320 ;160 ;0 ;0 ;3 set CAPI=API Call user32 DrawIconEx ;!hDCMem! ;32 ;288 ;!hIco_%~1! ;32 ;32 ;0 ;0 ;3 set CAPI=API Call gdi32 SetTextColor ;!hDCMem! ;16777215 set CAPI=API Call user32 DrawTextW ;!hDCMem! "$%~2:!CrLf! %~3" ;-1 ;!lpRC3! ;16 set CAPI=API Call gdi32 SetTextColor ;!hDCMem! ;0 (%Function_DrawScreen%) set CAPI=API Call kernel32 Sleep ;200 pause>nul (%Function_PlaySound:#snd#=Chat%) goto :eof :Function_ShowChoice (%Function_DrawMap%) set /a Return_Choice-=1 set "Message=%~2" :Function_ShowChoice_Loop set "Choice0= %~3" set "Choice1= %~4" set "Choice2= %~5" set "Choice3= 取消" set "Choice%Return_Choice%==>!Choice%Return_Choice%!" set CAPI=API Call user32 DrawIconEx ;!hDCMem! ;16 ;272 ;!hIco_uidialog! ;320 ;160 ;0 ;0 ;3 set CAPI=API Call user32 DrawIconEx ;!hDCMem! ;32 ;288 ;!hIco_%~1! ;32 ;32 ;0 ;0 ;3 set CAPI=API Call gdi32 SetTextColor ;!hDCMem! ;16777215 set CAPI=API Call user32 DrawTextW ;!hDCMem! "$!Message!!CrLf!!Choice0!!CrLf!!Choice1!!CrLf!!Choice2!!CrLf!!Choice3!" ;-1 ;!lpRC3! ;1232 set CAPI=API Call gdi32 SetTextColor ;!hDCMem! ;0 (%Function_DrawScreen%) set CAPI=API Call kernel32 ReadConsoleInputW ;%hIn% ;%lpIR% ;1 ;%lpData% set CAPI=Mem Print ;%lpIR% :IRType @2 ;IRData1 @2 :IRData2 if "%IRType%-%IRData1%"=="1-1" ( if "%IRData2%"=="38" set /a "Return_Choice=(Return_Choice+3)%%4"&(%Function_PlaySound:#snd#=Select%) if "%IRData2%"=="40" set /a "Return_Choice=(Return_Choice+1)%%4"&(%Function_PlaySound:#snd#=Select%) if "%IRData2%"=="32" set /a Return_Choice+=1&goto :eof ) goto :Function_ShowChoice_Loop :Function_RedrawMap set CAPI=API Call user32 DrawIconEx ;!hDCMap! ;0 ;0 ;!hIco_ground! ;352 ;352 ;0 ;0 ;3 for /l %%a in (0,1,10) do ( for /l %%b in (0,1,10) do ( for %%c in ("!Map_Source_%Player_Floor%_%%a:~%%b,1!") do ( set /a xPos=%%b*32,yPos=%%a*32 set CAPI=API Call user32 DrawIconEx ;!hDCMap! ;!xPos! ;!yPos! ;!hIco_%%~c! ;32 ;32 ;0 ;0 ;3 ) ) ) goto :eof :Function_GotoFloor set "Player_D=2" if %~1 geq !Player_Floor! ( set "Player_X=!Map_Enter_%~1_IX!" set "Player_Y=!Map_Enter_%~1_IY!" ) else ( set "Player_X=!Map_Enter_%~1_OX!" set "Player_Y=!Map_Enter_%~1_OY!" ) if %Player_BeenTo% lss %~1 set "Player_BeenTo=%~1" set "Player_Floor=%~1" set "hIco_Player=%hIco_p3%" call :Function_RedrawMap set "Screen_UI_Message=进入 第!Player_Floor!层" (%Function_SetTitle:#Title#=魔塔 第!Player_Floor!层%) (%Function_DrawUI%) goto :eof :Function_CalcBattle for /f "tokens=5-7,10 delims=_" %%a in ("!Block_%~1_!") do ( set "DHP=%%a" set "DAtt=%%b" set "DDef=%%c" set "DType=%%d" ) set /a "P2D=Player_Att-DDef" set /a "D2P=DAtt-Player_Def" if %D2P% lss 0 set "D2P=0" if %P2D% leq 0 ( set "LHP=XXX" ) else ( set /a "LHP=DHP/P2D" set /a "t=DHP%%P2D" if "!t!"=="0" set /a "LHP-=1" set /a "LHP*=D2P" if "!DType!"=="1" set /a "LHP+=100" if "!DType!"=="2" set /a "LHP+=300" if "!DType!"=="3" set /a "LHP+=Player_HP/4" if "!DType!"=="4" set /a "LHP+=Player_HP/3" ) goto :eof :Function_ShowEnemyData set "EnemyList=" set "t=" for /l %%a in (0,1,10) do set "t=!t!!Map_Source_%Player_Floor%_%%a!" :Function_ShowEnemyData_Loop set "t1=!t:~0,1!" if "!Block_%t1%_:~6,1!"=="7" set "EnemyList=!EnemyList!!t1!" set "t=!t:%t1%=!" if "!t!" neq "" goto :Function_ShowEnemyData_Loop if "!EnemyList!"=="" goto :eof set CAPI=API Call user32 DrawIconEx ;!hDCMem! ;0 ;96 ;!hIco_ground! ;352 ;352 ;0 ;0 ;3 set CAPI=Mem Alloc 16 set lpRCEnemy=%CAPI_Ret% set CAPI=Mem Put ;%lpRCEnemy% ;64 @4 ;336 set CAPI=API Call gdi32 SetTextColor ;!hDCMem! ;16777215 for /l %%j in (0,1,7) do ( set "t1=!EnemyList:~%%j,1!" for %%k in ("!t1!") do ( if "%%~k" neq "" ( set /a yPos=40*%%~j+112,yText1=yPos-4,yText2=yPos+36 set CAPI=API Call user32 DrawIconEx ;!hDCMem! ;16 ;!yPos! ;!hIco_%%~k! ;32 ;32 ;0 ;0 ;3 set "t2=!Block_%%~k_!" call :Function_CalcBattle "%%~k" for /f "tokens=1-3,5-9,11 delims=_" %%a in ("!t2!") do ( set CAPI=Mem Put ;%lpRCEnemy% @4 ;!yText1! @4 ;!yText2! set CAPI=API Call user32 DrawTextW ;!hDCMem! "$%%i 攻 %%e 金经 %%g-%%h!CrLf!血 %%d 防 %%f 损失 !LHP!" ;-1 ;%lpRCEnemy% ;2768 ) ) ) ) set CAPI=API Call gdi32 SetTextColor ;!hDCMem! ;0 set CAPI=Mem Free %lpRCEnemy% (%Function_DrawScreen%) pause>nul goto :eof :Function_JumpFloor set "Floor_Choice=!Player_Floor!" if "%Floor_Choice%"=="0" set "Floor_Choice=1" set CAPI=Mem Alloc 48 set /a lpRCJump1=%CAPI_Ret%,lpRCJump2=lpRCJump1+16,lpRCJump3=lpRCJump2+16 set CAPI=Mem Put ;%lpRCJump1% ;32 ;160 ;176 ;416 ;176 ;160 ;320 ;416 ;32 ;128 ;320 ;160 if %Player_BeenTo% gtr 10 (set LColumn=10) else set LColumn=%Player_BeenTo% set "Message=跳转楼层" :Function_JumpFloor_Loop set "LMessage="&set "RMessage=" for /l %%a in (1,1,!LColumn!) do ( set "Floor=0%%a" if "%%a"=="%Floor_Choice%" ( set "LMessage=!LMessage!!CrLf!=> 第 !Floor:~-2! 层 <=" ) else ( set "LMessage=!LMessage!!CrLf!第 !Floor:~-2! 层" ) ) for /l %%a in (11,1,!Player_BeenTo!) do ( set "Floor=0%%a" if "%%a"=="%Floor_Choice%" ( set "RMessage=!RMessage!!CrLf!=> 第 !Floor:~-2! 层 <=" ) else ( set "RMessage=!RMessage!!CrLf!第 !Floor:~-2! 层" ) ) set CAPI=API Call user32 DrawIconEx ;!hDCMem! ;0 ;96 ;!hIco_ground! ;352 ;352 ;0 ;0 ;3 set CAPI=API Call gdi32 SetTextColor ;!hDCMem! ;16777215 set CAPI=API Call user32 DrawTextW ;!hDCMem! "$!LMessage!" ;-1 ;%lpRCJump1% ;1 set CAPI=API Call user32 DrawTextW ;!hDCMem! "$!RMessage!" ;-1 ;%lpRCJump2% ;1 set CAPI=API Call user32 DrawTextW ;!hDCMem! "$!Message!" ;-1 ;%lpRCJump3% ;1 set CAPI=API Call gdi32 SetTextColor ;!hDCMem! ;0 (%Function_DrawScreen%) set CAPI=API Call kernel32 ReadConsoleInputW ;%hIn% ;%lpIR% ;1 ;%lpData% set CAPI=Mem Print ;%lpIR% :IRType @2 ;IRData1 @2 :IRData2 if "%IRType%-%IRData1%"=="1-1" ( if "%IRData2%"=="38" (if "!Floor_Choice!"=="1" (set "Floor_Choice=!Player_BeenTo!") else (set /a "Floor_Choice-=1"))&(%Function_PlaySound:#snd#=Select%) if "%IRData2%"=="40" (if "!Floor_Choice!"=="!Player_BeenTo!" (set "Floor_Choice=1") else (set /a "Floor_Choice+=1"))&(%Function_PlaySound:#snd#=Select%) if "%IRData2%"=="32" call :Function_GotoFloor "!Floor_Choice!"&set CAPI=Mem Free %lpRCJump1%&(%Function_PlaySound:#snd#=Buy%)&goto :eof ) goto :Function_JumpFloor_Loop :Function_SaveData ( echo ;_!Player_HP!_!Player_Att!_!Player_Def!_!Player_Coin!_!Player_Exp!_!Player_YKey!_!Player_BKey!_!Player_RKey!_!Player_BeenTo!_!Player_ShowEnemyData!_!Player_JumpFloor!_!Player_Get18!_!Player_GetCross!_!Player_Floor!_!Player_X!_!Player_Y!_ for /l %%a in (0,1,21) do ( for /l %%b in (0,1,10) do ( echo !Map_Source_%%a_%%b! ) ) )>"%~dp0Data\SaveData.txt" (%Function_PlaySound:#snd#=Data%) set "Screen_UI_Message=保存成功!" (%Function_DrawUI%) goto :eof :Function_LoadData if not exist "%~dp0Data\SaveData.txt" set "Screen_UI_Message=没有存档记录!"&(%Function_DrawUI%)&(%Function_PlaySound:#snd#=Select%)&goto :eof set /p LoadData=<"%~dp0Data\SaveData.txt" (%Function_InitMaps:#MapName#=SaveData%) for /f "tokens=2-17 delims=_ eol=" %%a in ("%LoadData%") do ( set "Player_HP=%%a" set "Player_Att=%%b" set "Player_Def=%%c" set "Player_Coin=%%d" set "Player_Exp=%%e" set "Player_YKey=%%f" set "Player_BKey=%%g" set "Player_RKey=%%h" set "Player_BeenTo=%%i" set "Player_ShowEnemyData=%%j" set "Player_JumpFloor=%%k" set "Player_Get18=%%l" set "Player_GetCross=%%m" call :Function_GotoFloor "%%n" set "Player_X=%%o" set "Player_Y=%%p" ) (%Function_PlaySound:#snd#=Data%) set "Screen_UI_Message=读取成功!" (%Function_DrawUI%) goto :eof :Function_Event_0 goto :Function_Event_Special_%Player_New_X%_%Player_New_Y%_%Player_Floor% :Function_Event_1 set /a Player_X=Player_New_X,Player_Y=Player_New_Y goto :Game_Main :Function_Event_2 goto :Game_Main :Function_Event_3 set /a "t=!Player_Floor!-1" call :Function_GotoFloor "!t!" (%Function_PlaySound:#snd#=Stair%) goto :Game_Main :Function_Event_4 set /a "t=!Player_Floor!+1" call :Function_GotoFloor "!t!" (%Function_PlaySound:#snd#=Stair%) goto :Game_Main :Function_Event_5 for /f "tokens=5-7 delims=_" %%a in ("!Block_%Event_Block%_!") do ( set /a "Player_%%a+=%%b" set "Screen_UI_Message=获得 %%c" (%Function_AfterGetItem%) ) (%Function_PlaySound:#snd#=Item1%) goto :Game_Main :Function_Event_6 for /f "tokens=5-7 delims=_" %%a in ("!Block_%Event_Block%_!") do ( if "!Player_%%a!"=="0" ( set "Screen_UI_Message=没有 %%c" (%Function_DrawUI%) (%Function_PlaySound:#snd#=Select%) ) else ( set /a "Player_%%a-=%%b" set "Screen_UI_Message=使用了 %%c 打开门" (%Function_AfterGetItem%) (%Function_PlaySound:#snd#=Stair%) ) ) goto :Game_Main :Function_Event_7 call :Function_CalcBattle "%Event_Block%" for /f "tokens=8,9,11 delims=_" %%a in ("!Block_%Event_Block%_!") do ( set "DCoin=%%a" set "DExp=%%b" set "DName=%%c" ) if "!LHP!"=="XXX" ( set "Screen_UI_Message=无法战胜" (%Function_DrawUI%) (%Function_PlaySound:#snd#=Select%) ) else ( if !Player_HP! lss !LHP! ( set "Screen_UI_Message=无法战胜" (%Function_DrawUI%) (%Function_PlaySound:#snd#=Select%) ) else ( set "Screen_UI_Message=战胜 !DName!,损失 !LHP!HP,获得 !DCoin!币 !DExp!经" set /a "Player_HP-=LHP" set /a "Player_Coin+=DCoin" set /a "Player_Exp+=DExp" (%Function_AfterGetItem%) (%Function_PlaySound:#snd#=Fight%) if "%Event_Block%"=="C" goto :Game_End ) ) goto :Game_Main :Function_Event_8 call :Function_ChangeBlock !Player_New_X! !Player_New_Y! q !Player_Floor! (%Function_PlaySound:#snd#=Stair%) goto :Game_Main :Function_Event_9 set /a "Player_YKey+=1","Player_BKey+=1","Player_RKey+=1" set "Screen_UI_Message=获得 钥匙盒,各种钥匙+1" (%Function_AfterGetItem%) (%Function_PlaySound:#snd#=Item1%) goto :Game_Main :Function_Event_A set "Screen_UI_Message=获得 小飞羽,等级提升一级" set /a "Player_HP+=1000" set /a "Player_Att+=10" set /a "Player_Def+=10" (%Function_AfterGetItem%) (%Function_PlaySound:#snd#=Item1%) goto :Game_Main :Function_Event_B for /f "tokens=5-6 delims=_" %%a in ("!Block_%Event_Block%_!") do ( set /a "Player_%%a=1" call :Function_ShowChat "%Event_Block%" "系统" "%%b" (%Function_AfterGetItem%) ) (%Function_PlaySound:#snd#=Item2%) goto :Game_Main :Function_Event_C set "Screen_UI_Message=获得 大飞羽,等级提升三级" set /a "Player_HP+=3000" set /a "Player_Att+=30" set /a "Player_Def+=30" (%Function_AfterGetItem%) (%Function_PlaySound:#snd#=Item1%) goto :Game_Main :Function_Event_Special_5_8_0 call :Function_ShowChat n "仙子" "不废话,剑在 第3层,盾在 第5层,十字架在 第7层,找到十字架后找我" set /a "Player_YKey+=1" set /a "Player_BKey+=1" set /a "Player_RKey+=1" (%Function_AfterGetItem%) call :Function_ChangeBlock 4 8 n 0 goto :Game_Main :Function_Event_Special_4_8_0 if "%Player_GetCross%"=="1" ( call :Function_ShowChat p3 "勇士" "找到十字架了" call :Function_ShowChat n "仙子" "好的,提升了你的能力了,还有在没做好准备前不要去 第21层" set /a "Player_HP+=Player_HP/3" set /a "Player_Att+=Player_Att/3" set /a "Player_Def+=Player_Def/3" (%Function_AfterGetItem%) ) goto :Game_Main :Function_Event_Special_7_10_2 call :Function_ShowChat p3 "勇士" "你得救了,快谢谢我" call :Function_ShowChat ⑷ "老人" "好吧,给你把剑吧" set /a "Player_Att+=70" set "Screen_UI_Message=获得 钢剑,攻击力+70" (%Function_AfterGetItem%) (%Function_PlaySound:#snd#=Item1%) goto :Game_Main :Function_Event_Special_9_10_2 call :Function_ShowChat p3 "勇士" "你自由了,快帮助我" call :Function_ShowChat ⑷ "老人" "好吧,给你个盾吧" set /a "Player_Def+=30" set "Screen_UI_Message=获得 钢盾,防御力+30" (%Function_AfterGetItem%) (%Function_PlaySound:#snd#=Item1%) goto :Game_Main :Function_Event_Special_5_0_3 call :Function_ShowChoice ⑻ "使用 25金币,你可以:" "增加 800点生命" "增加 4点攻击" "增加 4点防御" if "%Return_Choice%"=="4" set Return_Choice=1&(%Function_PlaySound:#snd#=Stair%)&goto :Game_Main if !Player_Coin! lss 25 ( set "Screen_UI_Message=没有 25金币" set Return_Choice=1 (%Function_DrawUI%) (%Function_PlaySound:#snd#=Cancel%) goto :Game_Main ) set /a "Player_Coin-=25" if "%Return_Choice%"=="1" set /a "Player_HP+=800" if "%Return_Choice%"=="2" set /a "Player_Att+=4" if "%Return_Choice%"=="3" set /a "Player_Def+=4" (%Function_DrawUI%) (%Function_PlaySound:#snd#=Buy%) goto :Function_Event_Special_5_0_3 :Function_Event_Special_5_0_4 if "%Map_Source_2_6:~1,1%"=="⑴" ( call :Function_ShowChat p3 "勇士" "你得救了,我知道你会开门,快帮我开 第2层 的门" call :Function_ShowChat ⒁ "小偷" "好的。找到嵌有红宝石的铁锒头给我,帮你开 第18层 的路" call :Function_ChangeBlock 1 6 q 2 ) else ( if "%Player_Get18%"=="1" ( call :Function_ShowChat p3 "勇士" "找到那个铁锒头了,快去帮我开路" call :Function_ShowChat ⒁ "小偷" "好的" call :Function_ChangeBlock 5 8 q 18 call :Function_ChangeBlock 5 9 q 18 (%Function_AfterGetItem%) ) ) goto :Game_Main :Function_Event_Special_1_7_5 call :Function_ShowChoice ⑷ "消耗经验,你可以:" "提升 1级(100点)" "增加 5点攻击(30点)" "增加 5点防御(30点)" if "%Return_Choice%"=="4" set Return_Choice=1&(%Function_PlaySound:#snd#=Stair%)&goto :Game_Main if "%Return_Choice%"=="1" ( if !Player_Exp! lss 100 ( set "Screen_UI_Message=没有 100经验" set Return_Choice=1 (%Function_DrawUI%) (%Function_PlaySound:#snd#=Cancel%) goto :Game_Main ) else ( set /a "Player_Exp-=100" set /a "Player_HP+=1000" set /a "Player_Att+=7" set /a "Player_Def+=7" (%Function_PlaySound:#snd#=Buy%) ) ) else ( if !Player_Exp! lss 30 ( set "Screen_UI_Message=没有 30经验" set Return_Choice=1 (%Function_DrawUI%) (%Function_PlaySound:#snd#=Cancel%) goto :Game_Main ) set /a "Player_Exp-=30" if "%Return_Choice%"=="2" set /a "Player_Att+=5" if "%Return_Choice%"=="3" set /a "Player_Def+=5" (%Function_PlaySound:#snd#=Buy%) ) (%Function_DrawUI%) goto :Function_Event_Special_1_7_5 :Function_Event_Special_10_3_5 call :Function_ShowChoice ⑸ "你可以在这里购买钥匙:" "黄钥匙 10金币" "蓝钥匙 50金币" "红钥匙 100金币" if "%Return_Choice%"=="4" set Return_Choice=1&(%Function_PlaySound:#snd#=Stair%)&goto :Game_Main if "%Return_Choice%"=="1" ( if !Player_Coin! lss 10 ( set "Screen_UI_Message=没有 10金币" set Return_Choice=1 (%Function_DrawUI%) (%Function_PlaySound:#snd#=Cancel%) goto :Game_Main ) set /a "Player_Coin-=10" set /a "Player_YKey+=1" (%Function_PlaySound:#snd#=Buy%) ) if "%Return_Choice%"=="2" ( if !Player_Coin! lss 50 ( set "Screen_UI_Message=没有 50金币" set Return_Choice=1 (%Function_DrawUI%) (%Function_PlaySound:#snd#=Cancel%) goto :Game_Main ) set /a "Player_Coin-=50" set /a "Player_BKey+=1" (%Function_PlaySound:#snd#=Buy%) ) if "%Return_Choice%"=="3" ( if !Player_Coin! lss 100 ( set "Screen_UI_Message=没有 100金币" set Return_Choice=1 (%Function_DrawUI%) (%Function_PlaySound:#snd#=Cancel%) goto :Game_Main ) set /a "Player_Coin-=100" set /a "Player_RKey+=1" (%Function_PlaySound:#snd#=Buy%) ) (%Function_DrawUI%) goto :Function_Event_Special_10_3_5 :Function_Event_Special_5_8_11 call :Function_ShowChoice ⑻ "使用 100金币,你可以:" "增加 4000点生命" "增加 20点攻击" "增加 20点防御" if "%Return_Choice%"=="4" set Return_Choice=1&(%Function_PlaySound:#snd#=Stair%)&goto :Game_Main if !Player_Coin! lss 100 ( set "Screen_UI_Message=没有 100金币" set Return_Choice=1 (%Function_DrawUI%) (%Function_PlaySound:#snd#=Cancel%) goto :Game_Main ) set /a "Player_Coin-=100" if "%Return_Choice%"=="1" set /a "Player_HP+=4000" if "%Return_Choice%"=="2" set /a "Player_Att+=20" if "%Return_Choice%"=="3" set /a "Player_Def+=20" (%Function_DrawUI%) (%Function_PlaySound:#snd#=Buy%) goto :Function_Event_Special_5_8_11 :Function_Event_Special_0_0_12 call :Function_ShowChoice ⑸ "卖钥匙给我吧:" "卖黄钥匙 7金币" "卖蓝钥匙 35金币" "卖红钥匙 70金币" if "%Return_Choice%"=="4" set Return_Choice=1&(%Function_PlaySound:#snd#=Stair%)&goto :Game_Main if "%Return_Choice%"=="1" ( if "!Player_YKey!"=="0" ( set "Screen_UI_Message=没有 黄钥匙" set Return_Choice=1 (%Function_PlaySound:#snd#=Cancel%) ) else ( set /a "Player_Coin+=7" set /a "Player_YKey-=1" (%Function_PlaySound:#snd#=Buy%) ) ) if "%Return_Choice%"=="2" ( if "!Player_BKey!"=="0" ( set "Screen_UI_Message=没有 蓝钥匙" set Return_Choice=1 (%Function_PlaySound:#snd#=Cancel%) ) else ( set /a "Player_Coin+=35" set /a "Player_BKey-=1" (%Function_PlaySound:#snd#=Buy%) ) ) if "%Return_Choice%"=="3" ( if "!Player_RKey!"=="0" ( set "Screen_UI_Message=没有 红钥匙" set Return_Choice=1 (%Function_PlaySound:#snd#=Cancel%) ) else ( set /a "Player_Coin+=70" set /a "Player_RKey-=1" (%Function_PlaySound:#snd#=Buy%) ) ) (%Function_DrawUI%) goto :Function_Event_Special_0_0_12 :Function_Event_Special_4_6_13 call :Function_ShowChoice ⑷ "消耗经验,你可以:" "提升 3级(270点)" "增加 18点攻击(95点)" "增加 17点防御(95点)" if "%Return_Choice%"=="4" (%Function_PlaySound:#snd#=Stair%)&set Return_Choice=1&goto :Game_Main if "%Return_Choice%"=="1" ( if !Player_Exp! lss 270 ( set "Screen_UI_Message=没有 270经验" set Return_Choice=1 (%Function_PlaySound:#snd#=Cancel%) ) else ( set /a "Player_Exp-=270" set /a "Player_HP+=3000" set /a "Player_Att+=20" set /a "Player_Def+=20" (%Function_PlaySound:#snd#=Buy%) ) ) else ( if !Player_Exp! lss 95 ( set "Screen_UI_Message=没有 95经验" set Return_Choice=1 (%Function_PlaySound:#snd#=Cancel%) ) else ( set /a "Player_Exp-=95" if "%Return_Choice%"=="2" set /a "Player_Att+=17" if "%Return_Choice%"=="3" set /a "Player_Def+=17" (%Function_PlaySound:#snd#=Buy%) ) ) (%Function_DrawUI%) goto :Function_Event_Special_4_6_13 :Function_Event_Special_5_3_14 set /a "Player_HP*=2" set "Screen_UI_Message=获得 圣水瓶,生命值加倍" (%Function_AfterGetItem%) (%Function_PlaySound:#snd#=Item2%) goto :Game_Main :Function_Event_Special_4_3_15 if %Player_Exp% geq 500 ( call :Function_ShowChat ⑷ "老人" "用 500经验 换 攻击120的剑" set "Screen_UI_Message=获得 圣光剑,攻击力+120" set /a "Player_Att+=120" set /a "Player_Exp-=500" (%Function_AfterGetItem%) (%Function_PlaySound:#snd#=Item1%) ) else ( call :Function_ShowChat ⑷ "老人" "等你有 500经验 再说吧" ) goto :Game_Main :Function_Event_Special_6_3_15 if %Player_Coin% geq 500 ( call :Function_ShowChat ⑸ "商人" "用 500金币 换 防御120的盾" set "Screen_UI_Message=获得 星光盾,防御力+120" set /a "Player_Def+=120" set /a "Player_Coin-=500" (%Function_AfterGetItem%) (%Function_PlaySound:#snd#=Item1%) ) else ( call :Function_ShowChat ⑸ "商人" "等你有 500金币 再说吧" ) goto :Game_Main :Function_Event_Special_5_4_16 call :Function_ShowChat 2 "魔王" "停止吧,愚蠢的人类!" (%Function_AfterGetItem%) goto :Game_Main :Function_Event_Special_5_4_18 if "%Map_Source_18_10:~10,1%"=="q" ( call :Function_ShowChat p3 "勇士" "你得救了!" call :Function_ShowChat 3 "公主" "快去杀了魔王,不然我不跟你走" call :Function_ChangeBlock 10 10 t 18 ) goto :Game_Main :Function_Event_Special_5_7_19 call :Function_ShowChat 4 "冥灵魔王" "废话少说,决斗吧!" (%Function_AfterGetItem%) goto :Game_Main |
下载地址:MotaHD(Repaired by ZhangZsky).7z
以下为原帖地址:
MotaHD defanive
http://www.bathome.net/thread-20217-1-1.html
CAPIx bailong360
http://www.bathome.net/thread-39367-1-1.html
CAPIx 2 bailong360
http://www.bathome.net/thread-43107-1-1.html
CAPIx 2.0 帮助
Table of Contents
1 简介
致敬D大和他的CAPI(注入版)
简介:
CAPI是bathome的defanvie开发的一款第三方,堪称批处理第三方的登峰造极之作
CAPI提供的最大功能就是一个:调用系统API 除此之外,CAPI并没有任何功能
而且其注入式的特点,一方面使得其调用速度得到了飞一般的提升,另一方面也使得其能够保存进程数据
这两个功能,赋予了CAPI无穷的力量
何为系统API?简而言之,是MS为了便利开发者,而封装在dll中的一系列函数
通过这些函数,开发者可以不需要理解系统的内部原理就方便地开发出产品
比如著名的image(第一代),就是调用了gdi32中的API从而实现了绘图功能
而利用CAPI,我们可以轻松地实现这个功能,而且由于CAPI是注入式的,我们可以甚至可以实现双缓冲
即先把图片画到内存中的画布上,等待所有的图片都绘制完成,再将整块画布复制到CMD中
这样做的最大好处就是可以避免闪烁,实现流畅地绘制
然而CAPI有几个问题,导致了它虽然强大,但却很少被使用
1.采取远程线程注入的方法将dll注入到cmd中,这是病毒的常用伎俩,因此误杀率极高
2.开发者defanvie已经很久没有现身,而且CAPI没有开源.已经无法在最新的系统上运行了
CAPIx就是为了解决这两个问题而开发的
首先CAPIx摒弃了远程线程注入的方式,而是使用一个修改过的提取自win 2003的cmd
这个cmd在启动时会自动加载CAPIx.dll,免去了注入的危险
其次CAPIx的开发者是可以联系到的,而且CAPIx完全开源,这为修复bug和增加功能提供了方便
并且CAPIx在API调用的功能上做出了进一步的加强
在API Call之外又提供了一个新命令API Exec,用来调用遵循__cdecl约定的函数
简而言之,可以调用其他dll中的函数,比如msvcrt中的大部分函数,像printf, scanf之类的
又比如调用regex2.dll实现正则匹配,还可以自己写dll供Exec调用,比如写一个浮点运算的dll代替set/a之类的
CAPIx潜力无限!
下载地址: https://github.com/YinTianliang/CAPIx/tree/master/bin
请务必下载CAPIx.dll和cmd.exe, CAPIx_Help.html为详细帮助,建议下载
使用CAPIx进行的程序只能在上面这个cmd.exe中正常运行
所以建议使用以下JS启动游戏(该cmd.exe需要与js, capix.dll放在同一目录下)
或者在批处理开头加上这两行
为了兼容以前的的CAPI作品, CAPIx的语法和CAPI是一样的, 只是在此基础之上做了加强, 使之更加人性化
本文档中的大部分内容来自http://www.bathome.net/thread-19238-1-1.html
2 标识符
标识符用来添加在参数前面, 指定这个参数的类型
3 基本命令
3.1 Mem
3.1.1 Alloc
Mem Alloc [size]
3.1.2 Free
Mem Free [addr]
3.1.3 Put
Mem Put [s][addr] [s][data] [s][data] …
3.1.4 Print
Mem Print [s][addr] [s][var] [s][var] …
# $ * @", [var]为变量名
3.1.5 Copy
Mem Copy [s][dst] [s][src] [sz]
3.1.6 用途
Mem系列的命令提供了对内存的操作,其最大的意义就在于实现结构体或数组
使用时要注意结构体的对齐
3.2 API
3.2.1 Call
API Call [dll] [s][API] [s][data] [s][data] …
3.2.2 Exec
API Exec [dll] [s][API] [s][data] [s][data] …
3.2.3 注
API是可以指定返回值类型的
以上两个命令的[s][API]可以用该函数在内存中对应的地址来表示,此时[dll]应为”0″
如set CAPI=API Exec 0 16777215 ;0 ;1
3.3 CAPIDll
3.4 Var
3.4.1 SetCall
3.4.2 GetCall
4 实例
4.1 Mem Alloc Free
创建了一块大小为4的内存,内存地址保存在lpAddress里
在批处理第一次暂停时,使用工具查看cmd.exe内存,可以看到在输出的地址处为4个空白字节的内存,第二次pause时,可以看到内存已经被释放
4.2 Mem Put
执行前data变量的内存内容为30 00 31 00 32 00 33 00 34 00 35 00 36 00 37 00 38 00 39 00
执行写入命令时,此时指针指向第1个字节,.97将1个字节为97写入,于是变成了61 00 31 00 …,指针后移1位,指向第2个字节
@1将指针后移1位,此时指针指向第3个字节
:25105,此时指针指向第3个字节,将2个字节为25105写入,于是变成了61 00 62 11 32 00 …,指针后移2位
#ab,此时指针指向第5位,将2个字节的ANSI字符串ab写入,于是变成了61 00 62 11 61 62 33 00 34 00 …,指针后移2位
$ab,此时指针指向第7位,将4个字节的Unicode字符串ab写入,于是变成了61 00 62 11 61 62 61 00 62 00 …,指针后移4位
/h*var,此时指针指向第11位,将var变量h的内容全部写入
4.3 Mem Copy
执行时,将var变量的前4个字节复制到data变量中,即是“hel”
因此输出“hel3456789”
4.4 Mem Print
var变量的内容为30 00 31 00 32 00 33 00 34 00 35 00 36 00
.output_1,此时指向第1个字节,将1字节的内容“31”放入output_1变量中,也就是48
@2,此时指针指向第2个字节,将指针后移2位,此时指针指向第4个字节
:output_2,此时指针指向第4个字节,将2字节的内容“00 32”放入output_2变量中,也就是12800
@1,此时指针指向第6个字节,将指针后移1位,此时指针指向第7个字节
#output_3,此时指针指向第7个字节,将接下来的内容作为ANSI字符串放入output_3变量中,也就是“33”,字符串3
$output_4,此时指针指向第9个字节,将接下来的内容作为Unicode字符串放入output_4变量中,也就是“34 00 35 00 36 00”,字符串456
4.5 API Call
调用API MessageBox,第一个参数为0,第二个参数为data变量的地址,第三个参数为Unicode字符串title,第四个参数为1
由于CMD内部将变量data储存为Unicode,因此应使用Unicode版本的API,也就是MessageBoxW
(注:CAPIx的*标识符得到了增强,可以使用*#data来强制将data转换为ANSI字符串)
4.6 API Exec
调用C语言库函数sscanf,该函数遵循cdecl调用协定,因此只能使用Exec调用
第一个参数*#data表示取变量data的内容, 转换为ANSI字符串, 第二个参数为sscanf的Format, 第三个和第四个参数取了两个整形变量地址
调用C语言库函数sqrt,且指定返回值类型为双浮点数
调用C语言库函数scanf, *;_1 的意思是取环境变量_1的地址,将其当作整形变量传给scanf
4.7 GetCall
5 CAPIx相对CAPI有哪些改进
6 等待加入的功能
Author: aiwozhonghuaba
Created: 2017-02-11 Sat 19:55
Emacs 25.1.1 (Org mode 8.2.10)
Validate
呃,后来发现CAPIx作者有发布过修复版……自己多余了……
但是,这个可以也在xp上运行