C# Lib.cs (Mainly for PS3)

  • Hello Guest! Welcome to ConsoleCrunch, to help support our site check out the premium upgrades HERE! to get exclusive access to our hidden content.
  • Unable to load portions of the website...
    If you use an ad blocker addon, you should disable it because it interferes with several elements of the site and blocks more than just adverts.
  • Read Rules Before Posting Post Virus Scans with every program.

Elite_Modz

Active Poster
Retired Staff
Active Member
Console ID Poster
Dec 19, 2014
517
380
133
Crunch
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using PS3Lib;
using DevComponents;
using System.IO;
using PS3Lib.NET;

namespace WindowsFormsApplication1
{
class Lib
{
private static SelectAPI CurrentAPI;
public static PS3API DEX = new PS3API();
public static byte[] BIND = new byte[4];
private static PS3API PS3 = new PS3API();
private static PS3API PS32 = new PS3API();
public static PS3API Ar = new PS3API();
private CCAPI PS3CCAPI = new CCAPI();
public static int HostClientNumber = 0;
public static uint HostClientNumber1 = 0u;
public static PS3TMAPI.ConnectStatus connectStatus;
public static string Status;
PS3API APi = new PS3API();
CCAPI CCAPI = new CCAPI();
private Thread TargetInfo;
public static uint ProcessID;
public static uint[] processIDs;
private int ClientInt = 0;
private uint ClientUInt = 0;

public static string char_to_wchar(string text)
{
string str = text;
for (int i = 0; i < text.Length; i++)
{
str = str.Insert(i * 2, "\0");
}
return str;
}

public static bool CompareByteArray(byte[] byte_0, byte[] byte_1)
{
int num = 0;
for (int i = 0; i < byte_0.Length; i++)
{
if (byte_0 == byte_1)
{
num++;
}
}
return (num == byte_0.Length);
}

public static byte[] ReverseBytes(byte[] toReverse)
{
Array.Reverse(toReverse);
return toReverse;
}

public static void WriteBool(uint address, bool input)
{
byte[] bytes = new byte[] { input ? ((byte)1) : ((byte)0) };
PS3.SetMemory(address, bytes);
}

public static void WriteByte(uint address, byte input)
{
PS3.SetMemory(address, new byte[] { input });
}

public static void WriteBytes(uint address, byte[] input)
{
PS3.SetMemory(address, input);
}

public static void WriteDouble(uint address, double input)
{
byte[] array = new byte[8];
BitConverter.GetBytes(input).CopyTo(array, 0);
Array.Reverse(array, 0, 8);
PS3.SetMemory(address, array);
}

public static void WriteDouble(uint address, double[] input)
{
int length = input.Length;
byte[] array = new byte[length * 8];
for (int i = 0; i < length; i++)
{
ReverseBytes(BitConverter.GetBytes(input)).CopyTo(array, (int)(i * 8));
}
PS3.SetMemory(address, array);
}

public static void WriteInt16(uint address, short input)
{
byte[] array = new byte[2];
ReverseBytes(BitConverter.GetBytes(input)).CopyTo(array, 0);
PS3.SetMemory(address, array);
}

public static void WriteInt16(uint address, short[] input)
{
int length = input.Length;
byte[] array = new byte[length * 2];
for (int i = 0; i < length; i++)
{
ReverseBytes(BitConverter.GetBytes(input)).CopyTo(array, (int)(i * 2));
}
PS3.SetMemory(address, array);
}

public static void WriteInt32(uint address, int input)
{
byte[] array = new byte[4];
ReverseBytes(BitConverter.GetBytes(input)).CopyTo(array, 0);
PS3.SetMemory(address, array);
}

public static void WriteInt32(uint address, int[] input)
{
int length = input.Length;
byte[] array = new byte[length * 4];
for (int i = 0; i < length; i++)
{
ReverseBytes(BitConverter.GetBytes(input)).CopyTo(array, (int)(i * 4));
}
PS3.SetMemory(address, array);
}

public static void WriteInt64(uint address, long input)
{
byte[] array = new byte[8];
ReverseBytes(BitConverter.GetBytes(input)).CopyTo(array, 0);
PS3.SetMemory(address, array);
}

public static void WriteInt64(uint address, long[] input)
{
int length = input.Length;
byte[] array = new byte[length * 8];
for (int i = 0; i < length; i++)
{
ReverseBytes(BitConverter.GetBytes(input)).CopyTo(array, (int)(i * 8));
}
PS3.SetMemory(address, array);
}

public static void WriteSByte(uint address, sbyte input)
{
byte[] bytes = new byte[] { (byte)input };
PS3.SetMemory(address, bytes);
}

public static void WriteSBytes(uint address, sbyte[] input)
{
int length = input.Length;
byte[] bytes = new byte[length];
for (int i = 0; i < length; i++)
{
bytes = (byte)input;
}
PS3.SetMemory(address, bytes);
}

public static void WriteSingle(uint address, float input)
{
byte[] array = new byte[4];
BitConverter.GetBytes(input).CopyTo(array, 0);
Array.Reverse(array, 0, 4);
PS3.SetMemory(address, array);
}

public static void WriteSingle(uint address, float[] input)
{
int length = input.Length;
byte[] array = new byte[length * 4];
for (int i = 0; i < length; i++)
{
ReverseBytes(BitConverter.GetBytes(input)).CopyTo(array, (int)(i * 4));
}
PS3.SetMemory(address, array);
}

public static void WriteString(uint address, string input)
{
byte[] bytes = Encoding.UTF8.GetBytes(input);
Array.Resize<byte>(ref bytes, bytes.Length + 1);
PS3.SetMemory(address, bytes);
}

public static void WriteUInt16(uint address, ushort input)
{
byte[] array = new byte[2];
BitConverter.GetBytes(input).CopyTo(array, 0);
Array.Reverse(array, 0, 2);
PS3.SetMemory(address, array);
}

public static void WriteUInt16(uint address, ushort[] input)
{
int length = input.Length;
byte[] array = new byte[length * 2];
for (int i = 0; i < length; i++)
{
ReverseBytes(BitConverter.GetBytes(input)).CopyTo(array, (int)(i * 2));
}
PS3.SetMemory(address, array);
}

public static void WriteUInt32(uint address, uint input)
{
byte[] array = new byte[4];
BitConverter.GetBytes(input).CopyTo(array, 0);
Array.Reverse(array, 0, 4);
PS3.SetMemory(address, array);
}

public static void WriteUInt32(uint address, uint[] input)
{
int length = input.Length;
byte[] array = new byte[length * 4];
for (int i = 0; i < length; i++)
{
ReverseBytes(BitConverter.GetBytes(input)).CopyTo(array, (int)(i * 4));
}
PS3.SetMemory(address, array);
}

public static void WriteUInt64(uint address, ulong input)
{
byte[] array = new byte[8];
BitConverter.GetBytes(input).CopyTo(array, 0);
Array.Reverse(array, 0, 8);
PS3.SetMemory(address, array);
}

public static void WriteUInt64(uint address, ulong[] input)
{
int length = input.Length;
byte[] array = new byte[length * 8];
for (int i = 0; i < length; i++)
{
ReverseBytes(BitConverter.GetBytes(input)).CopyTo(array, (int)(i * 8));
}
PS3.SetMemory(address, array);
}

public static float[] GetOrigin(int Client)
{
float[] Position = ReadSingle(0x1780F50 + ((uint)Client * 0x5808), 3);
return Position;
}

public static float[] ReadSingle(uint address, int length)
{
byte[] memory = PS3.Extension.ReadBytes(address, length * 4);
ReverseBytes(memory);
float[] numArray = new float[length];
for (int index = 0; index < length; ++index)
numArray[index] = BitConverter.ToSingle(memory, (length - 1 - index) * 4);
return numArray;
}

public static void GetMem(uint offset, byte[] buffer, SelectAPI API)
{
if (API == SelectAPI.ControlConsole)
{
GetMemoryR(offset, buffer);
}
else if (API == SelectAPI.TargetManager)
{
GetMemoryR(offset, buffer);
}
}

public static bool ReadBool(uint offset)
{
byte[] buffer = new byte[1];
GetMem(offset, buffer, CurrentAPI);
return (buffer[0] != 0);
}
public static byte[] GetBytes(uint offset, int length, SelectAPI API)
{
byte[] bytes = new byte[length];
if (API == SelectAPI.ControlConsole)
{
CurrentAPI = GetCurrentAPI();
return DEX.GetBytes(offset, length);
}
if (API == SelectAPI.TargetManager)
{
CurrentAPI = GetCurrentAPI();
bytes = DEX.GetBytes(offset, length);
}
return bytes;
}

public static byte[] GetMemory(uint offset, int length)
{
byte[] array = new byte[length];
DEX.GetMemory(offset, array);
return array;
}
public static void ChangeAPI(SelectAPI API)
{
DEX.ChangeAPI(API);
}
public static SelectAPI GetCurrentAPI()
{
return DEX.GetCurrentAPI();
}
public static byte[] GetMemoryL(uint address, int length)
{
byte[] buffer = new byte[length];
DEX.GetMemory(address, buffer);
return buffer;
}
public static void SetMemory(uint Address, byte[] Bytes)
{
DEX.SetMemory(Address, Bytes);
}
public static void GetMemoryR(uint Address, byte[] Bytes)
{
DEX.GetMemory(Address, Bytes);
}

public static byte ReadByte(uint offset)
{
return GetBytes(offset, 1, CurrentAPI)[0];
}

public static byte[] ReadBytes(uint offset, int length)
{
return GetBytes(offset, length, CurrentAPI);
}

public static float ReadFloat(uint offset)
{
byte[] array = GetBytes(offset, 4, CurrentAPI);
Array.Reverse(array, 0, 4);
return BitConverter.ToSingle(array, 0);
}

public static short ReadInt16(uint offset)
{
byte[] array = GetBytes(offset, 2, CurrentAPI);
Array.Reverse(array, 0, 2);
return BitConverter.ToInt16(array, 0);
}

public static int ReadInt32(uint offset)
{
byte[] array = GetBytes(offset, 4, CurrentAPI);
Array.Reverse(array, 0, 4);
return BitConverter.ToInt32(array, 0);
}

public static byte[] ToHexFloat(float Axis)
{
byte[] bytes = BitConverter.GetBytes(Axis);
Array.Reverse(bytes);
return bytes;
}
}
}

This may be hard to find on the internet or might even not be on the internet so figured it might help you devs out a bit :)

Credits: iMCSx, Enstone, BuC-SHoTz, Choco, and Everyone else who helped out with the PS3 Library
 
General chit-chat
Help Users
  • @ danielpadilla1999:
    Np. Could you anonymize my account, please? Change my username to a random one, clear data, etc
  • @ QM|T_JinX:
    the best thing to do is message younis for things like that we super mod cant do that
  • @ danielpadilla1999:
    Alright. Could you let him know to do it, please?
  • @ danielpadilla1999:
    You do not have permission to view this page or perform this action.
  • @ QM|T_JinX:
    ok i will send younis message in your name not sure if he will do things like that just letting you know
  • @ danielpadilla1999:
    Thank you very much mate
  • @ QM|T_JinX:
    np
  • @ QM|T_JinX:
    can i ask you why you want the account deleted or rest ? you can just not log in anymore and be done with it right ?
  • Chat Bot:
    Lindows has joined the room.
  • Chat Bot:
    HalfDeafGuy is our newest member. Welcome!
  • Chat Bot:
    XKuro_Buuny589 is our newest member. Welcome!
  • Chat Bot:
    webvedha is our newest member. Welcome!
  • @ lurch6661:
    zap zap ill smoke to that
  • @ QM|T_JinX:
    1+ hour the new reveal trailer assassins creed shadows
  • @ lurch6661:
    cool
  • Chat Bot:
    Lindows has joined the room.
  • Chat Bot:
    lechon201 is our newest member. Welcome!
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    Lindows has joined the room.
  • Chat Bot:
    KTLOG is our newest member. Welcome!
  • @ KTLOG:
    yo ***** @Memo
  • @ KTLOG:
    remember me
    @ KTLOG: remember me