コード例 #1
0
ファイル: codes.cs プロジェクト: maxarmin/NetCheatPS3
        /*
         * Loops through each code and calls ProcPreProcCode to run them
         */
        public static void WriteToPS32(MainForm.CodeDB Codes)
        {
            if (Codes.codes == null || Codes.CData == null)
            {
                return;
            }
            //splitList = Form1.Codes[ind].codes.Split('\n');
            int skip = 0;

            for (int x = 0; x < Codes.CData.Length; x++)
            {
                if (Codes.CData[x].type == '\0')
                {
                    break;
                }

                if (skip > 0)
                {
                    skip--;
                    goto SkipCodes;
                }
                skip = ProcPreProcCode(Codes, x);

                SkipCodes :;
            }
        }
コード例 #2
0
ファイル: codes.cs プロジェクト: maxarmin/NetCheatPS3
        /*
         * Processes joker code types (both D and E type)
         */
        public static int ParseJokerD(string[] splitList, int cnt, ref MainForm.CodeDB Code, int ind2)
        {
            String code = misc.sLeft(splitList[cnt], 19);
            String val  = misc.sRight(code, 8);

            if (val.IndexOf(' ') >= 0)
            {
                return(0);
            }
            Code.CData[ind2].jsize = int.Parse(misc.sLeft(val, 2), NumberStyles.HexNumber);
            Array.Resize(ref Code.CData, Code.CData.Length + Code.CData[ind2].jsize);
            int x = 0, y = 0, ret = Code.CData[ind2].jsize;

            Code.CData[ind2].jbool = BitConverter.GetBytes(int.Parse(misc.ReverseE("00" + misc.sRight(val, 6), 8), NumberStyles.HexNumber));

            ind2++;
            for (x = 0; x < ret; x++)
            {
                do
                {
                    y++;
                    if ((cnt + y) >= splitList.Length)
                    {
                        return(ind2);
                    }
                    code = misc.sLeft(splitList[cnt + y], 19);
                } while (code == null || code == "" || CheckForComment(code) == 1);

                int len = 0;
                Code.CData[ind2].type = code[0];

                switch (Code.CData[ind2].type)
                {
                case '0':
                    len = 2;
                    break;

                case '1':
                    len = 4;
                    break;

                case '2':
                case '6':
                case 'D':
                case 'E':
                    len = 8;
                    break;
                }

                Code.CData[ind2].addr = ulong.Parse(misc.sMid(code, 2, 8), NumberStyles.HexNumber);
                Code.CData[ind2].val  = BitConverter.GetBytes(int.Parse(misc.ReverseE(misc.sRight(code, len), 8), NumberStyles.HexNumber));
                ind2++;
            }

            return(ind2);
        }
コード例 #3
0
ファイル: fileio.cs プロジェクト: maxarmin/NetCheatPS3
        /*
         * Saves the code database save into file
         */
        public static bool SaveFile(string file, MainForm.CodeDB save)
        {
            if (file == "" || file == null)
            {
                //System.Windows.Forms.MessageBox.Show("Error: File path invalid!");
                return(false);
            }

            string[] str = { "{", save.state.ToString(), save.name, save.codes, "}\n" };
            File.WriteAllLines(file, str);
            return(true);
        }
コード例 #4
0
ファイル: fileio.cs プロジェクト: maxarmin/NetCheatPS3
        /*
         * Opens a code database
         */
        public static MainForm.CodeDB[] OpenFile(string file)
        {
            MainForm.CodeDB[] ret = null;
            int z = 1;

            if (file == "" || file == null)
            {
                System.Windows.Forms.MessageBox.Show("Error: File path invalid!");
                return(ret);
            }

            string[] tempStr;
            tempStr = File.ReadAllLines(file);

            int len = 0, y = 0;

            while (y < tempStr.Length)
            {
                if (tempStr[y] == "}")
                {
                    len++;
                }
                y++;
            }

            ret = new MainForm.CodeDB[len];

            for (int x = 0; z < tempStr.Length; x++)
            {
                ret[x].state = bool.Parse(tempStr[z]); z++;
                ret[x].name  = tempStr[z]; z++;

                while (tempStr[z] != "}")
                {
                    ret[x].codes += tempStr[z] + '\n';
                    z++;
                }
                z += 2;
            }

            return(ret);
        }
コード例 #5
0
ファイル: codes.cs プロジェクト: maxarmin/NetCheatPS3
        /*
         * Processes codes in the string array splitList
         */
        public static void ParseCodeString(string data, ref MainForm.CodeDB ret)
        {
            int strcnt = 0, skip = 0, cnt = 0;

            splitList = data.Split('\n');
            ret.CData = new MainForm.CodeData[0];

            foreach (string s in splitList)
            {
                int check = CheckForComment(splitList[strcnt]);
                if (check == 1 || MainForm.bComment == true || splitList[strcnt] == "")
                {
                    goto SkipUpdateCD;
                }

                if (skip > 0)
                {
                    skip--;
                    goto SkipUpdateCD;
                }

                String code = misc.sLeft(splitList[strcnt], 19);
                String val  = misc.sRight(code, 8);

                if (val.Length != 8 || code.Length != 19)
                {
                    goto SkipUpdateCD;
                }

                Array.Resize(ref ret.CData, ret.CData.Length + 1);

                if (cnt != 0 && ret.CData[cnt - 1].type != '6')
                {
                    ret.CData[cnt].addr = ulong.Parse(misc.sMid(code, 2, 8), NumberStyles.HexNumber);
                }
                else if (cnt == 0)
                {
                    ret.CData[cnt].addr = ulong.Parse(misc.sMid(code, 2, 8), NumberStyles.HexNumber);
                }
                ret.CData[cnt].type = splitList[strcnt][0];
                switch (ret.CData[cnt].type)
                {
                case '0':     //8 bit write
                    if (val.IndexOf(' ') >= 0)
                    {
                        break;
                    }
                    ret.CData[cnt].val = new byte[] { byte.Parse(misc.sLeft(val, 2), NumberStyles.HexNumber) };
                    break;

                case '1':     //16 bit write
                    if (val.IndexOf(' ') >= 0)
                    {
                        break;
                    }
                    byte[] sVal = BitConverter.GetBytes(int.Parse(misc.ReverseE(misc.sLeft(val, 4), 4), NumberStyles.HexNumber));
                    ret.CData[cnt].val = new byte[2] {
                        sVal[0], sVal[1]
                    };
                    break;

                case '2':     //32 bit write
                    if (val.IndexOf(' ') >= 0)
                    {
                        break;
                    }
                    ret.CData[cnt].val = BitConverter.GetBytes(int.Parse(misc.ReverseE(misc.sLeft(val, 8), 8), NumberStyles.HexNumber));
                    break;

                case '6':     //Pointer write
                    ret.CData[cnt].val = BitConverter.GetBytes(int.Parse(misc.ReverseE(misc.sLeft(val, 8), 8), NumberStyles.HexNumber));
                    int y = 1;

                    if (splitList.Length <= (cnt + y))
                    {
                        break;
                    }

                    //Skip comments and whatnot
                    check = CheckForComment(splitList[cnt + y]);
                    if (check == 1 || MainForm.bComment == true)
                    {
                        y++;
                    }
                    else if (check == 2)
                    {
                        while (MainForm.bComment == true)
                        {
                            y++;

                            if (splitList.Length <= (cnt + y))
                            {
                                break;
                            }

                            CheckForComment(splitList[cnt + y]);
                        }
                    }

                    byte[] pretByte = new byte[0x4];
                    MainForm.apiGetMem(ret.CData[cnt].addr, ref pretByte);

                    if (splitList.Length <= (cnt + y))
                    {
                        break;
                    }

                    Array.Resize(ref ret.CData, ret.CData.Length + 1);
                    ret.CData[cnt + 1].addr = (misc.ByteArrayToLong(pretByte, 0, 4) + ulong.Parse(misc.sLeft(val, 8), NumberStyles.HexNumber));
                    ret.CData[cnt + 1].val  = BitConverter.GetBytes(int.Parse(misc.sRight(splitList[cnt + y], 8), System.Globalization.NumberStyles.HexNumber));
                    ret.CData[cnt + 1].type = splitList[cnt + y][0];
                    break;

                case 'D':
                case 'E':     //Joker
                    skip  = ParseJokerD(splitList, strcnt, ref ret, cnt);
                    skip -= (cnt + 1);
                    cnt   = skip + cnt;
                    break;
                }

                cnt++;
SkipUpdateCD:
                strcnt++;
            }
        }
コード例 #6
0
ファイル: codes.cs プロジェクト: maxarmin/NetCheatPS3
        /*
         * Runs codes that have already been processed
         */
        public static int ProcPreProcCode(MainForm.CodeDB Codes, int cnt)
        {
            ulong addr = Codes.CData[cnt].addr;

            byte[] val  = Codes.CData[cnt].val;
            byte[] jval = Codes.CData[cnt].jbool;
            char   type = Codes.CData[cnt].type;
            int    skip = 0;

            //Make upper case
            if (type >= 0x61)
            {
                type -= (char)0x20;
            }

            switch (type)
            {
            case '0':
                byte[] stw0 = new byte[1];
                stw0[0] = val[val.Length - 1];
                MainForm.apiSetMem(addr, stw0);
                break;

            case '1':
                byte[] stw1 = new byte[2];
                stw1[0] = val[val.Length - 2];
                stw1[1] = val[val.Length - 1];
                MainForm.apiSetMem(addr, val);
                break;

            case '2':
                MainForm.apiSetMem(addr, val);
                //PS3TMAPI.ProcessSetMemory(0, PS3TMAPI.UnitType.PPU, Form1.ProcessID, 0, addr, val);
                break;

            case '6':
                byte[] pretByte = new byte[4];
                MainForm.apiGetMem(addr, ref pretByte);
                //apiGetMem(addr, ref pretByte);

                Codes.CData[cnt + 1].addr = (misc.ByteArrayToLong(pretByte, 0, 4) + misc.ByteArrayToLong(val, 0, 4));
                //ProcPreProcCode(Codes, cnt + 1);
                break;

            case 'D':
            case 'E':
                int size = Codes.CData[cnt].jsize;
                skip = size;

                byte[] retByte = new byte[0x4];
                MainForm.apiGetMem(addr, ref retByte);
                //apiGetMem(addr, ref retByte);

                bool ret = false;
                if (type == 'D')
                {
                    ret = misc.ArrayCompare(jval, retByte, new byte[1], 4, 0, 0, MainForm.compEq);
                }
                else if (type == 'E')
                {
                    ret = misc.ArrayCompare(jval, retByte, new byte[1], 4, 0, 0, MainForm.compANEq);
                }

                if (ret == false)
                {
                    break;
                }

                for (int x = (cnt + 1); x < (size + cnt + 1); x++)
                {
                    ProcPreProcCode(Codes, x);
                }
                break;
            }

            return(skip);
        }