plants-vs.-zombies-online-battle

🧟 Plants vs. Zombies multiplayer battle, developed via reverse engineering, inline hook and dynamic-link library injection. Two online players defend and attack as the plant and zombie respectively.(通过逆向工程、内联Hook和动态链接库注入实现的《植物大战僵尸》双人网络对战,两名玩家分别使用植物或僵尸进行防守和攻击。)

https://github.com/zhuagenborn/plants-vs.-zombies-online-battle

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.4%) to scientific vocabulary

Keywords

cpp20 dll-injection game game-cheating hook inline-hook network reverse-engineering socket
Last synced: 6 months ago · JSON representation

Repository

🧟 Plants vs. Zombies multiplayer battle, developed via reverse engineering, inline hook and dynamic-link library injection. Two online players defend and attack as the plant and zombie respectively.(通过逆向工程、内联Hook和动态链接库注入实现的《植物大战僵尸》双人网络对战,两名玩家分别使用植物或僵尸进行防守和攻击。)

Basic Info
  • Host: GitHub
  • Owner: Zhuagenborn
  • License: mit
  • Language: C++
  • Default Branch: main
  • Homepage:
  • Size: 66.4 MB
Statistics
  • Stars: 597
  • Watchers: 13
  • Forks: 54
  • Open Issues: 0
  • Releases: 1
Topics
cpp20 dll-injection game game-cheating hook inline-hook network reverse-engineering socket
Created over 5 years ago · Last pushed over 1 year ago
Metadata Files
Readme License Citation

README.md

Plants vs. Zombies Online Battle

C++ MASM CMake Visual-Studio Windows License

Introduction

Cover

This project adds the multiplayer battle to Plants vs. Zombies via reverse engineering, inline hook and dynamic-link library injection. Two online players can defend and attack as Plant and Zombie respectively.

Getting Started

Prerequisites

Building

Set the location to the project folder and run:

bash mkdir -p build cd build cmake .. -G "Visual Studio 17 2022" -A Win32 cmake --build .

Two dynamic-link libraries plant.dll and zombie.dll will be generated in build/bin folder. Copy them to the game root folder.

IPv6

The default IP version is IPv4. Enable the following statement in libs/game/CMakeLists.txt if you want to build IPv6 libraries.

cmake target_compile_definitions(game PRIVATE INET6=1)

Usage

The project only works with Plants vs. Zombies *1.0.0.1051 CHINESE*** version, provided in game folder.

The MD5 of PlantsVsZombies.exe is 37B729B4056131722A556E646AC915E9.

In order to activate online functions, plant.dll and zombie.dll must be injected into the game when it starts. You can directly use this simple injection tool: Dll-Injector.

online-battle

Playing as Plant

If a player plays as the plant, the game will launch as a server.

bash Dll-Injector -f PlantsVsZombies.exe plant.dll

Or use Start-OnlineGame.ps1 directly. It needs to be copied to the game root folder.

powershell Start-OnlineGame.ps1 -Role Plant

Start I, Zombie Endless level, the game will pause and wait for a client to connect.

Playing as Zombie

If a player plays as the zombie, the game will launch as a client.

bash Dll-Injector -f PlantsVsZombies.exe zombie.dll

Or use Start-OnlineGame.ps1.

powershell Start-OnlineGame.ps1 -Role Zombie

Start I, Zombie Endless level, the game will try to connect to the server.

I, Zombie Endless

If the modification has been loaded successfully, I, Zombie Endless level will be converted into an online level. If your current progress does not have this level, you can copy game/userdata to C:\ProgramData\PopCap Games\PlantsVsZombies\userdata. Remember to back up your own save-files before copying.

In the Chinese version of the game, you can start this level as follows:

  1. Select "*", which means "Puzzle*" in English.

    puzzle-mode

  2. Select "*", the final level. It is "I, Zombie Endless*" in English.

    i-zombie-endless

  3. The game will display a dialog box shown as below. Select "*", the left button, meaning "Continue*" in English.

    continue-or-new-game

    Before starting an online battle, the progress of this level must be empty. Otherwise the battlefields of two online players will be different. If that happens, you need to restart the game without the modification, enter this level again but select "*", the right button, to reset the progress. It means "New Game*".

Configurations

Copy online_config.ini to the game root folder. You can set the server's IP address and port number in it.

ini [Network] ServerIP=127.0.0.1 Port=10000

Documents

The code comment style follows the Doxygen specification.

docs/Key Data and Functions.md describes key data and functions obtained by reverse engineering.

Class Diagram

```mermaid classDiagram

namespace state {

class Role {
    <<enumeration>>
    Plante
    Zombie
}

class Config {
    vector~int~ zombies
    vector~int~ plants
    string server_ip
    int port
}

class State

}

State --> Role State --> Config State --> TcpSocket

namespace network {

class IpAddr {
    <<interface>>
    Version() int
}

class Ipv4Addr
class Ipv6Addr

class Socket {
    SetAddr(IpAddr)
    Bind()
    Close()
}

class TcpSocket {
    <<>>
    Connect(IpAddr)
    Send(data) size
    Recv(buffer) size
}

class Listener {
    Bind(IpAddr)
    Listen()
    Accept() TcpSocket
    Close()
}

class Packet {
    Recv(TcpSocket)$ Packet
    Send(TcpSocket)
    Write(data) size
    Read() data
}

}

IpAddr <|.. Ipv4Addr IpAddr <|.. Ipv6Addr Socket --> IpAddr Socket <|-- TcpSocket Listener --> TcpSocket Packet ..> TcpSocket

class Mod { <> Enable() Disable() }

class ModLoader { Add(Mod) Load() }

ModLoader o-- Mod

class RemoveDefaultPlants Mod <|.. RemoveDefaultPlants

class SetSunAmount Mod <|.. SetSunAmount

class Hook { <> #From() address #To() address #JumpRet() optional~address~ }

Mod <|-- Hook

class BeforeLoadLevel Hook <|.. BeforeLoadLevel BeforeLoadLevel ..> CreateZombie BeforeLoadLevel ..> CreatePlant BeforeLoadLevel ..> LevelEnd BeforeLoadLevel ..> Listener BeforeLoadLevel ..> State

class AfterLoadLevel Hook <|.. AfterLoadLevel AfterLoadLevel ..> RemoveDefaultPlants AfterLoadLevel ..> InitSlots

class InitSlots Hook <|.. InitSlots InitSlots ..> State

class LevelEnd Hook <|.. LevelEnd LevelEnd ..> State LevelEnd ..> Packet

class CreateZombie Hook <|.. CreateZombie CreateZombie ..> State CreateZombie ..> Packet

class CreatePlant Hook <|.. CreatePlant CreatePlant ..> State CreatePlant ..> Packet

class Startup { Run() Stop() }

Startup --> ModLoader Startup --> State ```

Issues & Bugs

  • The game sometimes crashes when creating zombies.
  • If the progress of I, Zombie Endless level is not empty, two players will have different battlefields.
  • In order to simplify the code, the running menu and automatic pause are disabled.

License

Distributed under the MIT License. See LICENSE for more information.

Owner

  • Name: Zhuagenborn
  • Login: Zhuagenborn
  • Kind: organization
  • Location: Ireland

Software Development | Artificial Intelligence | Reverse Engineering.

GitHub Events

Total
  • Watch event: 46
  • Push event: 3
  • Fork event: 6
Last Year
  • Watch event: 46
  • Push event: 3
  • Fork event: 6

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 48
  • Total Committers: 1
  • Avg Commits per committer: 48.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 2
  • Committers: 1
  • Avg Commits per committer: 2.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Chenzs108 c****8@o****m 48

Issues and Pull Requests

Last synced: 9 months ago

All Time
  • Total issues: 2
  • Total pull requests: 0
  • Average time to close issues: 2 months
  • Average time to close pull requests: N/A
  • Total issue authors: 2
  • Total pull request authors: 0
  • Average comments per issue: 2.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • lianquke (1)
  • jwli6 (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels