植物大战僵尸的简单修改

植物大战僵尸的修改

第一天 我学会了如何使用Hex Editor 二进制器修改植物大战僵尸的数据进而对植物大战僵尸修改

🐟:第一步找到 用户数据宝开游戏的植物大战僵尸的数据文件
目录为:C:\ProgramData\PopCap Games\PlantsVsZombies\userdata
用Hex编辑器打开 
🐟:第二步 : 通过 运行游戏观察数值的变化来确定 关卡 特殊关卡 所在位置进行相应的修改。
🐟:必备知识 进制的转换
🐟:通过这次修改 我有了想用Java来实现的想法 但是尝试了一下 并没有成功 以后 有了新的目标 将植物大战僵尸的修改器手打出来
🐟:这次有了收获 可以通过java来判断是否可以检测系统进程的运行。 复习了相关io流知识 使 Javaio流知识使用更加熟练了 

以下为成功示例

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

想通过Java实现

由于最近在学io流这个技术

就想到了这些二进制文件可以通过流来传输

然后又有集合的知识 将这每一个二进制位置传入集合

判断异同 找出不同的位置 然后修改

但是并没有实现!


import java.io.*;

public class FileCopy {
    //拷贝文件
    static  void copy() {
        FileInputStream inputStream = null;
        FileOutputStream outputStream = null;
        String filePath = "C:\\ProgramData\\PopCap Games\\PlantsVsZombies\\userdata\\user1.dat";
        String copyPath = "D:\\zmTest\\data.txt";
        File file1 = new File(copyPath);
        File file = new File(filePath);
        try {
            outputStream = new FileOutputStream(file1);
            inputStream = new FileInputStream(file);
//            byte[] a = new byte[10];
            Integer i = 0;
            while ((i = inputStream.read()) != -1) {
                outputStream.write(Integer.parseInt(Integer.toBinaryString(i)));
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                inputStream.close();
                outputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}

import java.io.*;
import java.util.ArrayList;
import java.util.List;
public class Xgq {
    String jiu = "C:\\ProgramData\\PopCap Games\\PlantsVsZombies\\userdata\\user1.dat";
    String xin = "D:\\zmTest\\data.txt";
        public void ifRun() {
            String keyWord = "PlantsVsZombies.exe";
            Runtime runtime = Runtime.getRuntime();
            BufferedReader in = null;
            try {
                Process process = runtime.exec("cmd /c Tasklist");
                 in = new BufferedReader(new InputStreamReader(process.getInputStream()));
                String s;
                while ((s = in.readLine()) != null) {
                    s = s.toLowerCase();
                    if (s.startsWith(keyWord)) {
                        FileCopy.copy();
                        System.out.println("成功" );
                        compareTwoFile(jiu,xin);
                    }
//                    if (!(s.startsWith(keyWord))) {
//                        String path = "C:\\ProgramData\\PopCap Games\\PlantsVsZombies\\userdata\\user1.dat";
//                        File file = new File(path);
//                        File file1 = new File("D\\zmTest\\data.txt1");
//                        FileOutputStream fileOutputStream = new FileOutputStream(file1);
//                        FileInputStream fileInputStream = new FileInputStream(file);
//                        byte[] b = new byte[10];
//                        Integer i = 0;
//                        while ((i = fileInputStream.read(b)) != -1) {
//                            fileOutputStream.write(b, 0, i);
//                        }
//                        fileInputStream.close();
//                        fileOutputStream.close();
//                    }
//                }
//
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            finally{
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
            public void compareTwoFile(String oldFile,String newFile) {
                System.out.println(1);
                List<String> list = new ArrayList<>();
                List<String> list1 = new ArrayList<>();
                FileOutputStream outputStream = null;
                FileInputStream inputStream = null;
                try {
                    outputStream = new FileOutputStream(jiu);
                    inputStream = new FileInputStream(xin);
//            byte[] a = new byte[10];
                    Integer i = 0 , j = 0;
                    while ((i = inputStream.read()) != -1 && (j = inputStream.read()) != -1) {
                        list.add(Integer.toBinaryString(i));
                        list1.add(Integer.toBinaryString(j));
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                } finally {
                    try {
                        inputStream.close();
                        outputStream.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }

                for (int i = 0; i < list.size(); i++) {
                    if (!list.get(i).equals(list1.get(i))){
                        System.out.println(i);
                    }
                }
        }
    public static void main(String[] args) {
        Xgq xz = new Xgq();
        xz.ifRun();
        }
        }









  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值