├── .gitattributes ├── .gitignore ├── JRPC.sln ├── JRPC_Client ├── JRPC.cs ├── JRPC.csproj ├── Properties │ └── AssemblyInfo.cs ├── bin │ └── Debug │ │ ├── JRPC.dll │ │ ├── JRPC.dll.mdb │ │ └── JRPC.pdb └── obj │ └── Debug │ ├── DesignTimeResolveAssemblyReferencesInput.cache │ ├── JRPC.csproj.CoreCompileInputs.cache │ ├── JRPC.csproj.FileListAbsolute.txt │ ├── JRPC.dll │ ├── JRPC.pdb │ ├── JRPC_Client.csproj.CoreCompileInputs.cache │ ├── JRPC_Client.csproj.FileListAbsolute.txt │ └── JRPC_Client.csprojAssemblyReference.cache └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /JRPC.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.168 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JRPC", "JRPC_Client\JRPC.csproj", "{15FF3433-CD97-4E9F-ABA6-976E647B53B8}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {15FF3433-CD97-4E9F-ABA6-976E647B53B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {15FF3433-CD97-4E9F-ABA6-976E647B53B8}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {15FF3433-CD97-4E9F-ABA6-976E647B53B8}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {15FF3433-CD97-4E9F-ABA6-976E647B53B8}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {039EC9E2-339C-4CAE-92AB-47BD1D775AFB} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /JRPC_Client/JRPC.cs: -------------------------------------------------------------------------------- 1 | //Original Code By James If you ever see this thanks 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Runtime.InteropServices; 7 | using XDevkit; 8 | 9 | namespace JRPC_Client 10 | { 11 | public static class JRPC 12 | { 13 | private static readonly uint Void = 0, 14 | Int = 1, 15 | String = 2, 16 | Float = 3, 17 | Byte = 4, 18 | IntArray = 5, 19 | FloatArray = 6, 20 | ByteArray = 7, 21 | Uint64 = 8, 22 | Uint64Array = 9; 23 | private static uint connectionId; 24 | public static readonly uint JRPCVersion = 2; 25 | 26 | public static string ToHexString(this string String) 27 | { 28 | string Str = ""; 29 | foreach (byte b in String) 30 | Str += b.ToString("X2"); 31 | return Str; 32 | } 33 | 34 | public static void Push(this byte[] InArray, out byte[] OutArray, byte Value) 35 | { 36 | OutArray = new byte[InArray.Length + 1]; 37 | InArray.CopyTo(OutArray, 0); 38 | OutArray[InArray.Length] = Value; 39 | } 40 | 41 | public static byte[] ToByteArray(this string String) 42 | { 43 | byte[] Return = new byte[String.Length+1]; 44 | for (int i = 0; i < String.Length; i++) 45 | Return[i] = (byte)String[i]; 46 | return Return; 47 | } 48 | 49 | public static int find(this string String, string _Ptr) 50 | { 51 | if (_Ptr.Length == 0 || String.Length == 0) 52 | return -1; 53 | for (int i = 0; i < String.Length; i++) 54 | { 55 | if (String[i] == _Ptr[0]) 56 | { 57 | bool Found = true; 58 | for (int q = 0; q < _Ptr.Length; q++) 59 | if (String[i + q] != _Ptr[q]) 60 | Found = false; 61 | if (Found) 62 | return i; 63 | } 64 | } 65 | return -1; 66 | } 67 | 68 | public static bool Connect(this IXboxConsole console, out IXboxConsole Console, string XboxNameOrIP = "default") 69 | { 70 | IXboxConsole Con; 71 | if (XboxNameOrIP == "default") 72 | XboxNameOrIP = new XboxManager().DefaultConsole; 73 | Con = new XboxManager().OpenConsole(XboxNameOrIP); 74 | int retry = 0; 75 | bool Connected = false; 76 | while (!Connected) 77 | { 78 | try 79 | { 80 | connectionId = Con.OpenConnection(null); 81 | Connected = true; 82 | } 83 | catch (COMException ex) 84 | { 85 | if (ex.ErrorCode == UIntToInt(0x82DA0100)) 86 | { 87 | if (retry >= 3) // three attempts 88 | { 89 | Console = Con; 90 | return false; 91 | } 92 | retry++; 93 | System.Threading.Thread.Sleep(100); 94 | } 95 | else 96 | { 97 | Console = Con; 98 | return false; 99 | } 100 | } 101 | } 102 | Console = Con; 103 | return true; 104 | } 105 | 106 | public static string XboxIP(this IXboxConsole console) 107 | { 108 | byte[] address = BitConverter.GetBytes(console.IPAddress); 109 | Array.Reverse(address); 110 | return new System.Net.IPAddress(address).ToString(); 111 | } 112 | 113 | internal static ulong ConvertToUInt64(object o) 114 | { 115 | if (o is bool) 116 | return (ulong)(!(bool)o ? 0UL : 1UL); 117 | else 118 | { 119 | if (o is byte) 120 | return (ulong)(byte)o; 121 | if (o is short) 122 | return (ulong)(short)o; 123 | if (o is int) 124 | return (ulong)(int)o; 125 | if (o is long) 126 | return (ulong)(long)o; 127 | if (o is ushort) 128 | return (ulong)(ushort)o; 129 | if (o is uint) 130 | return (ulong)(uint)o; 131 | if (o is ulong) 132 | return (ulong)o; 133 | if (o is float) 134 | return (ulong)BitConverter.DoubleToInt64Bits((double)(float)o); 135 | if (o is double) 136 | return (ulong)BitConverter.DoubleToInt64Bits((double)o); 137 | else 138 | return 0UL; 139 | } 140 | } 141 | 142 | private static Dictionary ValueTypeSizeMap = new Dictionary() 143 | { 144 | { typeof (bool), 4 }, { typeof (byte), 1 }, { typeof (short), 2 }, { typeof (int), 4 }, 145 | { typeof (long), 8 }, { typeof (ushort), 2 }, { typeof (uint), 4 }, { typeof (ulong), 8 }, 146 | { typeof (float), 4 }, { typeof (double), 8 } 147 | }; 148 | private static Dictionary StructPrimitiveSizeMap = new Dictionary(); 149 | 150 | internal static bool IsValidStructType(Type t) 151 | { 152 | if (!t.IsPrimitive) 153 | return t.IsValueType; 154 | else 155 | return false; 156 | } 157 | 158 | private static HashSet ValidReturnTypes = new HashSet() 159 | { 160 | typeof (void), 161 | typeof (bool), 162 | typeof (byte), 163 | typeof (short), 164 | typeof (int), 165 | typeof (long), 166 | typeof (ushort), 167 | typeof (uint), 168 | typeof (ulong), 169 | typeof (float), 170 | typeof (double), 171 | typeof (string), 172 | typeof (bool[]), 173 | typeof (byte[]), 174 | typeof (short[]), 175 | typeof (int[]), 176 | typeof (long[]), 177 | typeof (ushort[]), 178 | typeof (uint[]), 179 | typeof (ulong[]), 180 | typeof (float[]), 181 | typeof (double[]), 182 | typeof (string[]) 183 | }; 184 | 185 | internal static bool IsValidReturnType(Type t) 186 | { 187 | return ValidReturnTypes.Contains(t); 188 | } 189 | 190 | static void ReverseBytes(byte[] buffer, int groupSize) 191 | { 192 | if (buffer.Length % groupSize != 0) 193 | throw new ArgumentException("Group size must be a multiple of the buffer length", "groupSize"); 194 | int num1 = 0; 195 | while (num1 < buffer.Length) 196 | { 197 | int index1 = num1; 198 | for (int index2 = num1 + groupSize - 1; index1 < index2; --index2) 199 | { 200 | byte num2 = buffer[index1]; 201 | buffer[index1] = buffer[index2]; 202 | buffer[index2] = num2; 203 | ++index1; 204 | } 205 | num1 += groupSize; 206 | } 207 | } 208 | 209 | ///////////////////////// Reading Memory \\\\\\\\\\\\\\\\\\\\\\\\\ 210 | public static byte[] GetMemory(this IXboxConsole console, uint Address, uint Length) 211 | { 212 | uint Out = 0; ; 213 | byte[] Return = new byte[Length]; 214 | console.DebugTarget.GetMemory(Address, Length, Return, out Out); 215 | console.DebugTarget.InvalidateMemoryCache(true, Address, Length); 216 | return Return; 217 | } 218 | 219 | public static sbyte ReadSByte(this IXboxConsole console, uint Address) 220 | { 221 | return (sbyte)GetMemory(console, Address, 1)[0]; 222 | } 223 | 224 | public static byte ReadByte(this IXboxConsole console, uint Address) 225 | { 226 | return GetMemory(console, Address, 1)[0]; 227 | } 228 | 229 | public static bool ReadBool(this IXboxConsole console, uint Address) 230 | { 231 | return GetMemory(console, Address, 1)[0] != 0; 232 | } 233 | 234 | public static float ReadFloat(this IXboxConsole console, uint Address) 235 | { 236 | byte[] Buff = GetMemory(console, Address, 4); 237 | ReverseBytes(Buff, 4); 238 | return BitConverter.ToSingle(Buff, 0); 239 | } 240 | 241 | public static float[] ReadFloat(this IXboxConsole console, uint Address, uint ArraySize) 242 | { 243 | float[] Return = new float[ArraySize]; 244 | byte[] Buff = GetMemory(console, Address, ArraySize * 4); 245 | ReverseBytes(Buff, 4); 246 | for (int i = 0; i < ArraySize; i++) 247 | Return[i] = BitConverter.ToSingle(Buff, i * 4); 248 | return Return; 249 | } 250 | 251 | public static short ReadInt16(this IXboxConsole console, uint Address) 252 | { 253 | byte[] Buff = GetMemory(console, Address, 2); 254 | ReverseBytes(Buff, 2); 255 | return BitConverter.ToInt16(Buff, 0); 256 | } 257 | 258 | public static short[] ReadInt16(this IXboxConsole console, uint Address, uint ArraySize) 259 | { 260 | short[] Return = new short[ArraySize]; 261 | byte[] Buff = GetMemory(console, Address, ArraySize * 2); 262 | ReverseBytes(Buff, 2); 263 | for (int i = 0; i < ArraySize; i++) 264 | Return[i] = BitConverter.ToInt16(Buff, i * 2); 265 | return Return; 266 | } 267 | 268 | public static ushort ReadUInt16(this IXboxConsole console, uint Address) 269 | { 270 | byte[] Buff = GetMemory(console, Address, 2); 271 | ReverseBytes(Buff, 2); 272 | return BitConverter.ToUInt16(Buff, 0); 273 | } 274 | 275 | public static ushort[] ReadUInt16(this IXboxConsole console, uint Address, uint ArraySize) 276 | { 277 | ushort[] Return = new ushort[ArraySize]; 278 | byte[] Buff = GetMemory(console, Address, ArraySize * 2); 279 | ReverseBytes(Buff, 2); 280 | for (int i = 0; i < ArraySize; i++) 281 | Return[i] = BitConverter.ToUInt16(Buff, i * 2); 282 | return Return; 283 | } 284 | 285 | public static int ReadInt32(this IXboxConsole console, uint Address) 286 | { 287 | byte[] Buff = GetMemory(console, Address, 4); 288 | ReverseBytes(Buff, 4); 289 | return BitConverter.ToInt32(Buff, 0); 290 | } 291 | 292 | public static int[] ReadInt32(this IXboxConsole console, uint Address, uint ArraySize) 293 | { 294 | int[] Return = new int[ArraySize]; 295 | byte[] Buff = GetMemory(console, Address, ArraySize * 4); 296 | ReverseBytes(Buff, 4); 297 | for (int i = 0; i < ArraySize; i++) 298 | Return[i] = BitConverter.ToInt32(Buff, i * 4); 299 | return Return; 300 | } 301 | 302 | public static uint ReadUInt32(this IXboxConsole console, uint Address) 303 | { 304 | byte[] Buff = GetMemory(console, Address, 4); 305 | ReverseBytes(Buff, 4); 306 | return BitConverter.ToUInt32(Buff, 0); 307 | } 308 | 309 | public static uint[] ReadUInt32(this IXboxConsole console, uint Address, uint ArraySize) 310 | { 311 | uint[] Return = new uint[ArraySize]; 312 | byte[] Buff = GetMemory(console, Address, ArraySize * 4); 313 | ReverseBytes(Buff, 4); 314 | for (int i = 0; i < ArraySize; i++) 315 | Return[i] = BitConverter.ToUInt32(Buff, i * 4); 316 | return Return; 317 | } 318 | 319 | public static long ReadInt64(this IXboxConsole console, uint Address) 320 | { 321 | byte[] Buff = GetMemory(console, Address, 8); 322 | ReverseBytes(Buff, 8); 323 | return BitConverter.ToInt64(Buff, 0); 324 | } 325 | 326 | public static long[] ReadInt64(this IXboxConsole console, uint Address, uint ArraySize) 327 | { 328 | long[] Return = new long[ArraySize]; 329 | byte[] Buff = GetMemory(console, Address, ArraySize * 8); 330 | ReverseBytes(Buff, 8); 331 | for (int i = 0; i < ArraySize; i++) 332 | Return[i] = BitConverter.ToUInt32(Buff, i * 8); 333 | return Return; 334 | } 335 | 336 | public static ulong ReadUInt64(this IXboxConsole console, uint Address) 337 | { 338 | byte[] Buff = GetMemory(console, Address, 8); 339 | ReverseBytes(Buff, 8); 340 | return BitConverter.ToUInt64(Buff, 0); 341 | } 342 | 343 | public static ulong[] ReadUInt64(this IXboxConsole console, uint Address, uint ArraySize) 344 | { 345 | ulong[] Return = new ulong[ArraySize]; 346 | byte[] Buff = GetMemory(console, Address, ArraySize * 8); 347 | ReverseBytes(Buff, 8); 348 | for (int i = 0; i < ArraySize; i++) 349 | Return[i] = BitConverter.ToUInt32(Buff, i * 8); 350 | return Return; 351 | } 352 | 353 | public static string ReadString(this IXboxConsole console, uint Address, uint size) 354 | { 355 | return Encoding.UTF8.GetString(GetMemory(console, Address, size)); 356 | } 357 | 358 | ///////////////////////// Writing Memory \\\\\\\\\\\\\\\\\\\\\\\\\ 359 | public static void SetMemory(this IXboxConsole console, uint Address, byte[] Data) 360 | { 361 | uint Out; 362 | console.DebugTarget.SetMemory(Address, (uint)Data.Length, Data, out Out); 363 | } 364 | 365 | public static void WriteSByte(this IXboxConsole console, uint Address, sbyte Value) 366 | { 367 | SetMemory(console, Address, new byte[1] { BitConverter.GetBytes(Value)[0] }); 368 | } 369 | 370 | public static void WriteSByte(this IXboxConsole console, uint Address, sbyte[] Value) 371 | { 372 | byte[] Bytes = new byte[0]; 373 | foreach (byte b in Value) 374 | Bytes.Push(out Bytes, b); 375 | SetMemory(console, Address, Bytes); 376 | } 377 | 378 | public static void WriteByte(this IXboxConsole console, uint Address, byte Value) 379 | { 380 | SetMemory(console, Address, new byte[1] { Value }); 381 | } 382 | 383 | public static void WriteByte(this IXboxConsole console, uint Address, byte[] Value) 384 | { 385 | SetMemory(console, Address, Value); 386 | } 387 | 388 | public static void WriteBool(this IXboxConsole console, uint Address, bool Value) 389 | { 390 | SetMemory(console, Address, new byte[1] { (byte)(Value ? 1 : 0) }); 391 | } 392 | 393 | public static void WriteBool(this IXboxConsole console, uint Address, bool[] Value) 394 | { 395 | byte[] Bytes = new byte[0]; 396 | for(int i = 0; i < Value.Length; i++) 397 | Bytes.Push(out Bytes, (byte)(Value[i] ? 1 : 0)); 398 | SetMemory(console, Address, Bytes); 399 | } 400 | 401 | public static void WriteFloat(this IXboxConsole console, uint Address, float Value) 402 | { 403 | byte[] Buff = BitConverter.GetBytes(Value); 404 | Array.Reverse(Buff); 405 | SetMemory(console, Address, Buff); 406 | } 407 | 408 | public static void WriteFloat(this IXboxConsole console, uint Address, float[] Value) 409 | { 410 | byte[] Buff = new byte[Value.Length * 4]; 411 | for (int i = 0; i < Value.Length; i++) 412 | BitConverter.GetBytes(Value[i]).CopyTo(Buff, i * 4); 413 | ReverseBytes(Buff, 4); 414 | SetMemory(console, Address, Buff); 415 | } 416 | 417 | public static void WriteInt16(this IXboxConsole console, uint Address, short Value) 418 | { 419 | byte[] Buff = BitConverter.GetBytes(Value); 420 | ReverseBytes(Buff, 2); 421 | SetMemory(console, Address, Buff); 422 | } 423 | 424 | public static void WriteInt16(this IXboxConsole console, uint Address, short[] Value) 425 | { 426 | byte[] Buff = new byte[Value.Length * 2]; 427 | for (int i = 0; i < Value.Length; i++) 428 | BitConverter.GetBytes(Value[i]).CopyTo(Buff, i * 2); 429 | ReverseBytes(Buff, 2); 430 | SetMemory(console, Address, Buff); 431 | } 432 | 433 | public static void WriteUInt16(this IXboxConsole console, uint Address, ushort Value) 434 | { 435 | byte[] Buff = BitConverter.GetBytes(Value); 436 | ReverseBytes(Buff, 2); 437 | SetMemory(console, Address, Buff); 438 | } 439 | 440 | public static void WriteUInt16(this IXboxConsole console, uint Address, ushort[] Value) 441 | { 442 | byte[] Buff = new byte[Value.Length * 2]; 443 | for (int i = 0; i < Value.Length; i++) 444 | BitConverter.GetBytes(Value[i]).CopyTo(Buff, i * 2); 445 | ReverseBytes(Buff, 2); 446 | SetMemory(console, Address, Buff); 447 | } 448 | 449 | public static void WriteInt32(this IXboxConsole console, uint Address, int Value) 450 | { 451 | byte[] Buff = BitConverter.GetBytes(Value); 452 | ReverseBytes(Buff, 4); 453 | SetMemory(console, Address, Buff); 454 | } 455 | 456 | public static void WriteInt32(this IXboxConsole console, uint Address, int[] Value) 457 | { 458 | byte[] Buff = new byte[Value.Length * 4]; 459 | for (int i = 0; i < Value.Length; i++) 460 | BitConverter.GetBytes(Value[i]).CopyTo(Buff, i * 4); 461 | ReverseBytes(Buff, 4); 462 | SetMemory(console, Address, Buff); 463 | } 464 | 465 | public static void WriteUInt32(this IXboxConsole console, uint Address, uint Value) 466 | { 467 | byte[] Buff = BitConverter.GetBytes(Value); 468 | ReverseBytes(Buff, 4); 469 | SetMemory(console, Address, Buff); 470 | } 471 | 472 | public static void WriteUInt32(this IXboxConsole console, uint Address, uint[] Value) 473 | { 474 | byte[] Buff = new byte[Value.Length * 4]; 475 | for (int i = 0; i < Value.Length; i++) 476 | BitConverter.GetBytes(Value[i]).CopyTo(Buff, i * 4); 477 | ReverseBytes(Buff, 4); 478 | SetMemory(console, Address, Buff); 479 | } 480 | 481 | public static void WriteInt64(this IXboxConsole console, uint Address, long Value) 482 | { 483 | byte[] Buff = BitConverter.GetBytes(Value); 484 | ReverseBytes(Buff, 8); 485 | SetMemory(console, Address, Buff); 486 | } 487 | 488 | public static void WriteInt64(this IXboxConsole console, uint Address, long[] Value) 489 | { 490 | byte[] Buff = new byte[Value.Length * 8]; 491 | for (int i = 0; i < Value.Length; i++) 492 | BitConverter.GetBytes(Value[i]).CopyTo(Buff, i * 8); 493 | ReverseBytes(Buff, 8); 494 | SetMemory(console, Address, Buff); 495 | } 496 | 497 | public static void WriteUInt64(this IXboxConsole console, uint Address, ulong Value) 498 | { 499 | byte[] Buff = BitConverter.GetBytes(Value); 500 | ReverseBytes(Buff, 8); 501 | SetMemory(console, Address, Buff); 502 | } 503 | 504 | public static void WriteUInt64(this IXboxConsole console, uint Address, ulong[] Value) 505 | { 506 | byte[] Buff = new byte[Value.Length * 8]; 507 | for (int i = 0; i < Value.Length; i++) 508 | BitConverter.GetBytes(Value[i]).CopyTo(Buff, i * 8); 509 | ReverseBytes(Buff, 8); 510 | SetMemory(console, Address, Buff); 511 | } 512 | 513 | public static void WriteString(this IXboxConsole console, uint Address, string String) 514 | { 515 | byte[] bValue = new byte[0]; 516 | foreach(byte b in String) 517 | bValue.Push(out bValue, b); 518 | bValue.Push(out bValue, 0); 519 | SetMemory(console, Address, bValue); 520 | } 521 | 522 | public static uint ResolveFunction(this IXboxConsole console, string ModuleName, uint Ordinal) 523 | { 524 | string cmd = "consolefeatures ver=" + JRPCVersion + " type=9 params=\"A\\0\\A\\2\\" + 525 | JRPC.String + "/" + ModuleName.Length + "\\" + ModuleName.ToHexString() + "\\" + 526 | JRPC.Int + "\\" + Ordinal + "\\\"", 527 | Responce = SendCommand(console, cmd); 528 | return uint.Parse(Responce.Substring(Responce.find(" ")+1), System.Globalization.NumberStyles.HexNumber); 529 | } 530 | 531 | public static string GetCPUKey(this IXboxConsole console) 532 | { 533 | string cmd = "consolefeatures ver=" + JRPCVersion + " type=10 params=\"A\\0\\A\\0\\\"", 534 | Responce = SendCommand(console, cmd); 535 | return Responce.Substring(Responce.find(" ") + 1); 536 | } 537 | 538 | public static void ShutDownConsole(this IXboxConsole console) 539 | { 540 | try 541 | { 542 | string cmd = "consolefeatures ver=" + JRPCVersion + " type=11 params=\"A\\0\\A\\0\\\""; 543 | SendCommand(console, cmd); 544 | } 545 | catch { } 546 | } 547 | 548 | public static byte[] WCHAR(string String) 549 | { 550 | byte[] Bytes = new byte[String.Length * 2 + 2]; 551 | int i = 1; 552 | foreach (byte b in String) 553 | { 554 | Bytes[i] = b; 555 | i += 2; 556 | } 557 | return Bytes; 558 | } 559 | 560 | public static byte[] ToWCHAR(this string String) 561 | { 562 | return WCHAR(String); 563 | } 564 | 565 | public static uint GetKernalVersion(this IXboxConsole console) 566 | { 567 | string cmd = "consolefeatures ver=" + JRPCVersion + " type=13 params=\"A\\0\\A\\0\\\"", 568 | Responce = SendCommand(console, cmd); 569 | return uint.Parse(Responce.Substring(Responce.find(" ") + 1)); 570 | } 571 | 572 | public enum LEDState 573 | { 574 | OFF = 0x00, 575 | RED = 0x08, 576 | GREEN = 0x80, 577 | ORANGE = 0x88, 578 | }; 579 | 580 | public static void SetLeds(this IXboxConsole console, LEDState Top_Left, LEDState Top_Right, LEDState Bottom_Left, LEDState Bottom_Right) 581 | { 582 | string cmd = "consolefeatures ver=" + JRPCVersion + " type=14 params=\"A\\0\\A\\4\\" + 583 | JRPC.Int + "\\" + (uint)Top_Left + "\\" + 584 | JRPC.Int + "\\" + (uint)Top_Right + "\\" + 585 | JRPC.Int + "\\" + (uint)Bottom_Left + "\\" + 586 | JRPC.Int + "\\" + (uint)Bottom_Right + "\\\"", 587 | Responce = SendCommand(console, cmd); 588 | } 589 | 590 | public enum TemperatureType 591 | { 592 | CPU, 593 | GPU, 594 | EDRAM, 595 | MotherBoard 596 | }; 597 | 598 | public static uint GetTemperature(this IXboxConsole console, TemperatureType TemperatureType) 599 | { 600 | string cmd = "consolefeatures ver=" + JRPCVersion + " type=15 params=\"A\\0\\A\\1\\" + 601 | JRPC.Int + "\\" + (int)TemperatureType + "\\\"", 602 | Responce = SendCommand(console, cmd); 603 | return uint.Parse(Responce.Substring(Responce.find(" ") + 1), System.Globalization.NumberStyles.HexNumber); 604 | } 605 | 606 | public static void XNotify(this IXboxConsole console, string Text) 607 | { 608 | XNotify(console, Text, 34); 609 | } 610 | 611 | public static void XNotify(this IXboxConsole console, string Text, uint Type) 612 | { 613 | string cmd = "consolefeatures ver=" + JRPCVersion + " type=12 params=\"A\\0\\A\\2\\" + 614 | JRPC.String + "/" + Text.Length + "\\" + Text.ToHexString() + "\\" + 615 | JRPC.Int + "\\" + Type + "\\\""; 616 | SendCommand(console, cmd); 617 | } 618 | 619 | public static uint XamGetCurrentTitleId(this IXboxConsole console) 620 | { 621 | string cmd = "consolefeatures ver=" + JRPCVersion + " type=16 params=\"A\\0\\A\\0\\\"", 622 | Responce = SendCommand(console, cmd); 623 | return uint.Parse(Responce.Substring(Responce.find(" ") + 1), System.Globalization.NumberStyles.HexNumber); 624 | } 625 | 626 | public static string ConsoleType(this IXboxConsole console) 627 | { 628 | string cmd = "consolefeatures ver=" + JRPCVersion + " type=17 params=\"A\\0\\A\\0\\\"", 629 | Responce = SendCommand(console, cmd); 630 | return Responce.Substring(Responce.find(" ") + 1); 631 | } 632 | 633 | public static void constantMemorySet(this IXboxConsole console, uint Address, uint Value) 634 | { 635 | constantMemorySetting(console, Address, Value, false, 0, false, 0); 636 | } 637 | 638 | public static void constantMemorySet(this IXboxConsole console, uint Address, uint Value, uint TitleID) 639 | { 640 | constantMemorySetting(console, Address, Value, false, 0, true, TitleID); 641 | } 642 | 643 | public static void constantMemorySet(this IXboxConsole console, uint Address, uint Value, uint IfValue, uint TitleID) 644 | { 645 | constantMemorySetting(console, Address, Value, true, IfValue, true, TitleID); 646 | } 647 | 648 | public static void constantMemorySetting(IXboxConsole console, uint Address, uint Value, bool useIfValue, uint IfValue, bool usetitleID, uint TitleID) 649 | { 650 | string cmd = "consolefeatures ver=" + JRPCVersion + " type=18 params=\"A\\" + Address.ToString("X") + "\\A\\5\\" + 651 | JRPC.Int + "\\" + UIntToInt(Value) + "\\" + 652 | JRPC.Int + "\\" + (useIfValue ? 1 : 0) + "\\" + 653 | JRPC.Int + "\\" + IfValue + "\\" + 654 | JRPC.Int + "\\" + (usetitleID ? 1 : 0) + "\\" + 655 | JRPC.Int + "\\" + UIntToInt(TitleID) + "\\\""; 656 | SendCommand(console, cmd); 657 | } 658 | 659 | private static uint TypeToType(bool Array) where T : struct 660 | { 661 | Type Type = typeof(T); 662 | if (Type == typeof(int) || Type == typeof(uint) || Type == typeof(short) || Type == typeof(ushort)) { 663 | if(Array) 664 | return JRPC.IntArray; 665 | return JRPC.Int; 666 | } 667 | if (Type == typeof(string) || Type == typeof(char[])) 668 | return JRPC.String; 669 | if (Type == typeof(float) || Type == typeof(double)) { 670 | if (Array) 671 | return JRPC.FloatArray; 672 | return JRPC.Float; 673 | } 674 | if (Type == typeof(byte) || Type == typeof(char)) { 675 | if (Array) 676 | return JRPC.ByteArray; 677 | return JRPC.Byte; 678 | } 679 | if (Type == typeof(ulong) || Type == typeof(long)) { 680 | if (Array) 681 | return JRPC.Uint64Array; 682 | return JRPC.Uint64; 683 | } 684 | return JRPC.Uint64; 685 | } 686 | 687 | public enum ThreadType 688 | { 689 | System, 690 | Title 691 | } 692 | 693 | public static T Call(this IXboxConsole console, uint Address, params object[] Arguments) where T : struct 694 | { 695 | return (T)CallArgs(console, true, TypeToType(false), typeof(T), null, 0, Address, 0, false, Arguments); 696 | } 697 | 698 | public static T Call(this IXboxConsole console, string module, int ordinal, params object[] Arguments) where T : struct 699 | { 700 | return (T)CallArgs(console, true, TypeToType(false), typeof(T), module, ordinal, 0, 0, false, Arguments); 701 | } 702 | 703 | public static T Call(this IXboxConsole console, ThreadType Type, uint Address, params object[] Arguments) where T : struct 704 | { 705 | return (T)CallArgs(console, Type == ThreadType.System, TypeToType(false), typeof(T), null, 0, Address, 0, false, Arguments); 706 | } 707 | 708 | public static T Call(this IXboxConsole console, ThreadType Type, string module, int ordinal, params object[] Arguments) where T : struct 709 | { 710 | return (T)CallArgs(console, Type == ThreadType.System, TypeToType(false), typeof(T), module, ordinal, 0, 0, false, Arguments); 711 | } 712 | 713 | public static void CallVoid(this IXboxConsole console, uint Address, params object[] Arguments) 714 | { 715 | CallArgs(console, true, JRPC.Void, typeof(void), null, 0, Address, 0, false, Arguments); 716 | } 717 | 718 | public static void CallVoid(this IXboxConsole console, string module, int ordinal, params object[] Arguments) 719 | { 720 | CallArgs(console, true, JRPC.Void, typeof(void), module, ordinal, 0, 0, false, Arguments); 721 | } 722 | 723 | public static void CallVoid(this IXboxConsole console, ThreadType Type, uint Address, params object[] Arguments) 724 | { 725 | CallArgs(console, Type == ThreadType.System, JRPC.Void, typeof(void), null, 0, Address, 0, false, Arguments); 726 | } 727 | 728 | public static void CallVoid(this IXboxConsole console, ThreadType Type, string module, int ordinal, params object[] Arguments) 729 | { 730 | CallArgs(console, Type == ThreadType.System, JRPC.Void, typeof(void), module, ordinal, 0, 0, false, Arguments); 731 | } 732 | 733 | private static T[] ArrayReturn(this IXboxConsole console, uint Address, uint Size) 734 | { 735 | if(Size == 0) 736 | return new T[1]; 737 | Type type = typeof(T); 738 | object Return = new object(); 739 | 740 | if (type == typeof(short)) 741 | Return = ReadInt16(console, Address, Size); 742 | if (type == typeof(ushort)) 743 | Return = ReadUInt16(console, Address, Size); 744 | if (type == typeof(int)) 745 | Return = ReadInt32(console, Address, Size); 746 | if (type == typeof(uint)) 747 | Return = ReadUInt32(console, Address, Size); 748 | if (type == typeof(long)) 749 | Return = ReadInt64(console, Address, Size); 750 | if (type == typeof(ulong)) 751 | Return = ReadUInt64(console, Address, Size); 752 | if (type == typeof(float)) 753 | Return = ReadFloat(console, Address, Size); 754 | if (type == typeof(byte)) 755 | Return = GetMemory(console, Address, Size); 756 | return (T[])Return; 757 | } 758 | 759 | public static T[] CallArray(this IXboxConsole console, uint Address, uint ArraySize, params object[] Arguments) where T : struct 760 | { 761 | if (ArraySize == 0) 762 | return new T[1]; 763 | return (T[])CallArgs(console, true, TypeToType(true), typeof(T), null, 0, Address, ArraySize, false, Arguments); 764 | } 765 | 766 | public static T[] CallArray(this IXboxConsole console, string module, int ordinal, uint ArraySize, params object[] Arguments) where T : struct 767 | { 768 | if (ArraySize == 0) 769 | return new T[1]; 770 | return (T[])CallArgs(console, true, TypeToType(true), typeof(T), module, ordinal, 0, ArraySize, false, Arguments); 771 | } 772 | 773 | public static T[] CallArray(this IXboxConsole console, ThreadType Type, uint Address, uint ArraySize, params object[] Arguments) where T : struct 774 | { 775 | if (ArraySize == 0) 776 | return new T[1]; 777 | return (T[])CallArgs(console, Type == ThreadType.System, TypeToType(true), typeof(T), null, 0, Address, ArraySize, false, Arguments); 778 | } 779 | 780 | public static T[] CallArray(this IXboxConsole console, ThreadType Type, string module, int ordinal, uint ArraySize, params object[] Arguments) where T : struct 781 | { 782 | if (ArraySize == 0) 783 | return new T[1]; 784 | return (T[])CallArgs(console, Type == ThreadType.System, TypeToType(true), typeof(T), module, ordinal, 0, ArraySize, false, Arguments); 785 | } 786 | 787 | public static string CallString(this IXboxConsole console, uint Address, params object[] Arguments) 788 | { 789 | return (string)CallArgs(console, true, JRPC.String, typeof(string), null, 0, Address, 0, false, Arguments); 790 | } 791 | 792 | public static string CallString(this IXboxConsole console, string module, int ordinal, params object[] Arguments) 793 | { 794 | return (string)CallArgs(console, true, JRPC.String, typeof(string), module, ordinal, 0, 0, false, Arguments); 795 | } 796 | 797 | public static string CallString(this IXboxConsole console, ThreadType Type, uint Address, params object[] Arguments) 798 | { 799 | return (string)CallArgs(console, Type == ThreadType.System, JRPC.String, typeof(string), null, 0, Address, 0, false, Arguments); 800 | } 801 | 802 | public static string CallString(this IXboxConsole console, ThreadType Type, string module, int ordinal, params object[] Arguments) 803 | { 804 | return (string)CallArgs(console, Type == ThreadType.System, JRPC.String, typeof(string), module, ordinal, 0, 0, false, Arguments); 805 | } 806 | 807 | private static int UIntToInt(uint Value) 808 | { 809 | byte[] array = BitConverter.GetBytes(Value); 810 | return BitConverter.ToInt32(array, 0); 811 | } 812 | 813 | private static byte[] IntArrayToByte(int[] iArray) 814 | { 815 | byte[] Bytes = new byte[iArray.Length * 4]; 816 | for (int i = 0, q = 0; i < iArray.Length; i++, q += 4) 817 | for (int w = 0; w < 4; w++) 818 | Bytes[q + w] = BitConverter.GetBytes(iArray[i])[w]; 819 | return Bytes; 820 | } 821 | 822 | public static T CallVM(this IXboxConsole console, uint Address, params object[] Arguments) where T : struct 823 | { 824 | return (T)CallArgs(console, true, TypeToType(false), typeof(T), null, 0, Address, 0, true, Arguments); 825 | } 826 | 827 | public static T CallVM(this IXboxConsole console, string module, int ordinal, params object[] Arguments) where T : struct 828 | { 829 | return (T)CallArgs(console, true, TypeToType(false), typeof(T), module, ordinal, 0, 0, true, Arguments); 830 | } 831 | 832 | public static T CallVM(this IXboxConsole console, ThreadType Type, uint Address, params object[] Arguments) where T : struct 833 | { 834 | return (T)CallArgs(console, Type == ThreadType.System, TypeToType(false), typeof(T), null, 0, Address, 0, true, Arguments); 835 | } 836 | 837 | public static T CallVM(this IXboxConsole console, ThreadType Type, string module, int ordinal, params object[] Arguments) where T : struct 838 | { 839 | return (T)CallArgs(console, Type == ThreadType.System, TypeToType(false), typeof(T), module, ordinal, 0, 0, true, Arguments); 840 | } 841 | 842 | public static void CallVMVoid(this IXboxConsole console, uint Address, params object[] Arguments) 843 | { 844 | CallArgs(console, true, JRPC.Void, typeof(void), null, 0, Address, 0, true, Arguments); 845 | } 846 | 847 | public static void CallVMVoid(this IXboxConsole console, string module, int ordinal, params object[] Arguments) 848 | { 849 | CallArgs(console, true, JRPC.Void, typeof(void), module, ordinal, 0, 0, true, Arguments); 850 | } 851 | 852 | public static void CallVMVoid(this IXboxConsole console, ThreadType Type, uint Address, params object[] Arguments) 853 | { 854 | CallArgs(console, Type == ThreadType.System, JRPC.Void, typeof(void), null, 0, Address, 0, true, Arguments); 855 | } 856 | 857 | public static void CallVMVoid(this IXboxConsole console, ThreadType Type, string module, int ordinal, params object[] Arguments) 858 | { 859 | CallArgs(console, Type == ThreadType.System, JRPC.Void, typeof(void), module, ordinal, 0, 0, true, Arguments); 860 | } 861 | 862 | public static T[] CallVMArray(this IXboxConsole console, uint Address, uint ArraySize, params object[] Arguments) where T : struct 863 | { 864 | if (ArraySize == 0) 865 | return new T[1]; 866 | return (T[])CallArgs(console, true, TypeToType(true), typeof(T), null, 0, Address, ArraySize, true, Arguments); 867 | } 868 | 869 | public static T[] CallVMArray(this IXboxConsole console, string module, int ordinal, uint ArraySize, params object[] Arguments) where T : struct 870 | { 871 | if (ArraySize == 0) 872 | return new T[1]; 873 | return (T[])CallArgs(console, true, TypeToType(true), typeof(T), module, ordinal, 0, ArraySize, true, Arguments); 874 | } 875 | 876 | public static T[] CallVMArray(this IXboxConsole console, ThreadType Type, uint Address, uint ArraySize, params object[] Arguments) where T : struct 877 | { 878 | if (ArraySize == 0) 879 | return new T[1]; 880 | return (T[])CallArgs(console, Type == ThreadType.System, TypeToType(true), typeof(T), null, 0, Address, ArraySize, true, Arguments); 881 | } 882 | 883 | public static T[] CallVMArray(this IXboxConsole console, ThreadType Type, string module, int ordinal, uint ArraySize, params object[] Arguments) where T : struct 884 | { 885 | if (ArraySize == 0) 886 | return new T[1]; 887 | return (T[])CallArgs(console, Type == ThreadType.System, TypeToType(true), typeof(T), module, ordinal, 0, ArraySize, true, Arguments); 888 | } 889 | 890 | public static string CallVMString(this IXboxConsole console, uint Address, params object[] Arguments) 891 | { 892 | return (string)CallArgs(console, true, JRPC.String, typeof(string), null, 0, Address, 0, true, Arguments); 893 | } 894 | 895 | public static string CallVMString(this IXboxConsole console, string module, int ordinal, params object[] Arguments) 896 | { 897 | return (string)CallArgs(console, true, JRPC.String, typeof(string), module, ordinal, 0, 0, true, Arguments); 898 | } 899 | 900 | public static string CallVMString(this IXboxConsole console, ThreadType Type, uint Address, params object[] Arguments) 901 | { 902 | return (string)CallArgs(console, Type == ThreadType.System, JRPC.String, typeof(string), null, 0, Address, 0, true, Arguments); 903 | } 904 | 905 | public static string CallVMString(this IXboxConsole console, ThreadType Type, string module, int ordinal, params object[] Arguments) 906 | { 907 | return (string)CallArgs(console, Type == ThreadType.System, JRPC.String, typeof(string), module, ordinal, 0, 0, true, Arguments); 908 | } 909 | 910 | private static string SendCommand(IXboxConsole console, string Command) 911 | { 912 | string Responce; 913 | if (connectionId == null) 914 | throw new Exception("IXboxConsole argument did not connect using JRPC's connect function."); 915 | try 916 | { 917 | console.SendTextCommand(connectionId, Command, out Responce); 918 | if (Responce.Contains("error=")) 919 | throw new Exception(Responce.Substring(11)); 920 | if (Responce.Contains("DEBUG")) 921 | throw new Exception("JRPC is not installed on the current console"); 922 | } 923 | catch (COMException ex) 924 | { 925 | if (ex.ErrorCode == UIntToInt(0x82DA0007)) 926 | throw new Exception("JRPC is not installed on the current console"); 927 | else 928 | throw ex; 929 | } 930 | return Responce; 931 | } 932 | 933 | private static object CallArgs(IXboxConsole console, bool SystemThread, uint Type, Type t, string module, int ordinal, uint Address, uint ArraySize, bool VM, params object[] Arguments) 934 | { 935 | if (!JRPC.IsValidReturnType(t)) 936 | throw new Exception("Invalid type " + (object)t.Name + Environment.NewLine + "JRPC only supports: " + "bool, byte," + 937 | " short, int, long, ushort, uint, ulong, float, double"); 938 | else 939 | { 940 | console.ConnectTimeout = console.ConversationTimeout = 4000000;//set to 400 secounds incase there is a little delay in recving 941 | string SendCMD = ""; 942 | uint NumOfArgs = 0; 943 | foreach (object obj in Arguments) 944 | { 945 | bool Done = false; 946 | if (obj is uint) 947 | { 948 | SendCMD += JRPC.Int + "\\" + UIntToInt((uint)obj) + "\\"; 949 | NumOfArgs += 1; 950 | Done = true; 951 | } 952 | if (obj is int || obj is bool || obj is byte) 953 | { 954 | if (obj is bool) 955 | { 956 | SendCMD += JRPC.Int + "\\" + Convert.ToInt32((bool)obj) + "\\"; 957 | } 958 | else 959 | { 960 | SendCMD += JRPC.Int + "\\" + ((obj is byte) ? Convert.ToByte(obj).ToString() : Convert.ToInt32(obj).ToString()) + "\\"; 961 | } 962 | NumOfArgs += 1; 963 | Done = true; 964 | } 965 | else if (obj is int[] || obj is uint[]) 966 | { 967 | if (!VM) 968 | { 969 | byte[] Array = IntArrayToByte((int[])obj); 970 | SendCMD += JRPC.ByteArray.ToString() + "/" + Array.Length + "\\"; 971 | for (int i = 0; i < Array.Length; i++) 972 | SendCMD += Array[i].ToString("X2"); 973 | SendCMD += "\\"; 974 | NumOfArgs += 1; 975 | } 976 | else 977 | { 978 | bool isInt = obj is int[]; 979 | int len; 980 | if(isInt) 981 | { 982 | int[] iarray = (int[])obj; 983 | len = iarray.Length; 984 | } 985 | else 986 | { 987 | uint[] iarray = (uint[])obj; 988 | len = iarray.Length; 989 | } 990 | int[] Iarray = new int[len]; 991 | for(int i = 0; i < len; i++) 992 | { 993 | if(isInt) 994 | { 995 | int[] tiarray = (int[])obj; 996 | Iarray[i] = tiarray[i]; 997 | } 998 | else 999 | { 1000 | uint[] tiarray = (uint[])obj; 1001 | Iarray[i] = UIntToInt(tiarray[i]); 1002 | } 1003 | SendCMD += JRPC.Int + "\\" + Iarray[i] + "\\"; 1004 | NumOfArgs += 1; 1005 | } 1006 | } 1007 | Done = true; 1008 | } 1009 | else if (obj is string) 1010 | { 1011 | string Str = (string)obj; 1012 | SendCMD += JRPC.ByteArray.ToString() + "/" + Str.Length + "\\" + JRPC.ToHexString((string)obj) + "\\"; 1013 | NumOfArgs += 1; 1014 | Done = true; 1015 | } 1016 | else if (obj is double) 1017 | { 1018 | double d = (double)obj; 1019 | SendCMD += JRPC.Float.ToString() + "\\" + d.ToString() + "\\"; 1020 | NumOfArgs += 1; 1021 | Done = true; 1022 | } 1023 | else if (obj is float) 1024 | { 1025 | float Fl = (float)obj; 1026 | SendCMD += JRPC.Float.ToString() + "\\" + Fl.ToString() + "\\"; 1027 | NumOfArgs += 1; 1028 | Done = true; 1029 | } 1030 | else if (obj is float[]) 1031 | { 1032 | float[] floatArray = (float[])obj; 1033 | if (!VM) 1034 | { 1035 | SendCMD += JRPC.ByteArray.ToString() + "/" + (floatArray.Length * 4).ToString() + "\\"; 1036 | for (int i = 0; i < floatArray.Length; i++) 1037 | { 1038 | byte[] bytes = BitConverter.GetBytes(floatArray[i]); 1039 | Array.Reverse(bytes); 1040 | for (int q = 0; q < 4; q++) 1041 | SendCMD += bytes[q].ToString("X2"); 1042 | } 1043 | SendCMD += "\\"; 1044 | NumOfArgs += 1; 1045 | } 1046 | else 1047 | { 1048 | for (int i = 0; i < floatArray.Length; i++) 1049 | { 1050 | SendCMD += JRPC.Float.ToString() + "\\" + floatArray[i].ToString() + "\\"; 1051 | NumOfArgs += 1; 1052 | } 1053 | } 1054 | Done = true; 1055 | } 1056 | else if (obj is byte[]) 1057 | { 1058 | byte[] ByteArray = (byte[])obj; 1059 | SendCMD += JRPC.ByteArray.ToString() + "/" + ByteArray.Length + "\\"; 1060 | for (int i = 0; i < ByteArray.Length; i++) 1061 | SendCMD += ByteArray[i].ToString("X2"); 1062 | SendCMD += "\\"; 1063 | NumOfArgs += 1; 1064 | Done = true; 1065 | } 1066 | 1067 | if (!Done) 1068 | { 1069 | SendCMD += JRPC.Uint64.ToString() + "\\" + ConvertToUInt64(obj).ToString()+ "\\"; 1070 | NumOfArgs += 1; 1071 | } 1072 | } 1073 | SendCMD += "\""; 1074 | 1075 | string startSendCMD = "consolefeatures ver=" + JRPCVersion + " type=" + Type + (SystemThread ? " system" : "") + 1076 | (module != null ? " module=\"" + module + "\" ord=" + ordinal : "") + 1077 | (VM ? " VM" : "") + 1078 | " as=" + ArraySize + " params=\"A\\" + Address.ToString("X") + "\\A\\" + NumOfArgs + "\\" + SendCMD, 1079 | Responce; 1080 | if (NumOfArgs > 37) 1081 | throw new Exception("Can not use more than 37 paramaters in a call"); 1082 | 1083 | Responce = SendCommand(console, startSendCMD); 1084 | string Find = "buf_addr="; 1085 | while (Responce.Contains(Find)) 1086 | { 1087 | System.Threading.Thread.Sleep(250); 1088 | uint address = uint.Parse(Responce.Substring(Responce.find(Find) + Find.Length), System.Globalization.NumberStyles.HexNumber); 1089 | Responce = SendCommand(console, "consolefeatures " + Find + "0x" + address.ToString("X")); 1090 | } 1091 | console.ConversationTimeout = 2000;//reset the timeout 1092 | console.ConnectTimeout = 5000; 1093 | 1094 | switch(Type) 1095 | { 1096 | case 1:/*Int*/ 1097 | uint uVal = uint.Parse(Responce.Substring(Responce.find(" ") + 1), System.Globalization.NumberStyles.HexNumber); 1098 | if(t == typeof(uint)) 1099 | return uVal; 1100 | if (t == typeof(int)) 1101 | return UIntToInt(uVal); 1102 | if (t == typeof(short)) 1103 | return short.Parse(Responce.Substring(Responce.find(" ") + 1), System.Globalization.NumberStyles.HexNumber); 1104 | if (t == typeof(ushort)) 1105 | return ushort.Parse(Responce.Substring(Responce.find(" ") + 1), System.Globalization.NumberStyles.HexNumber); 1106 | break; 1107 | case 2:/*String*/ 1108 | string sString = Responce.Substring(Responce.find(" ") + 1); 1109 | if (t == typeof(string)) 1110 | return sString; 1111 | if (t == typeof(char[])) 1112 | return sString.ToCharArray(); 1113 | break; 1114 | case 3:/*Float*/ 1115 | if (t == typeof(double)) 1116 | return double.Parse(Responce.Substring(Responce.find(" ") + 1)); 1117 | if (t == typeof(float)) 1118 | return float.Parse(Responce.Substring(Responce.find(" ") + 1));; 1119 | break; 1120 | case 4:/*Byte*/ 1121 | byte bByte = byte.Parse(Responce.Substring(Responce.find(" ") + 1), System.Globalization.NumberStyles.HexNumber); 1122 | if (t == typeof(byte)) 1123 | return bByte; 1124 | if (t == typeof(char)) 1125 | return (char)bByte; 1126 | break; 1127 | case 8:/*UInt64*/ 1128 | if (t == typeof(long)) 1129 | return long.Parse(Responce.Substring(Responce.find(" ") + 1), System.Globalization.NumberStyles.HexNumber); 1130 | if (t == typeof(ulong)) 1131 | return ulong.Parse(Responce.Substring(Responce.find(" ") + 1), System.Globalization.NumberStyles.HexNumber); 1132 | break; 1133 | } 1134 | if (Type == 5)//IntArray 1135 | { 1136 | string String = Responce.Substring(Responce.find(" ") + 1); 1137 | int Tmp = 0; 1138 | string Temp = ""; 1139 | uint[] Uarray = new uint[8]; 1140 | foreach (char Char1 in String) 1141 | { 1142 | if (Char1 != ',' && Char1 != ';') 1143 | Temp += Char1.ToString(); 1144 | else 1145 | { 1146 | Uarray[Tmp] = uint.Parse(Temp, System.Globalization.NumberStyles.HexNumber); 1147 | Tmp += 1; 1148 | Temp = ""; 1149 | } 1150 | if (Char1 == ';') 1151 | break; 1152 | } 1153 | return Uarray; 1154 | } 1155 | if (Type == 6)//FloatArray 1156 | { 1157 | string String = Responce.Substring(Responce.find(" ") + 1); 1158 | int Tmp = 0; 1159 | string Temp = ""; 1160 | float[] Farray = new float[ArraySize]; 1161 | foreach (char Char1 in String) 1162 | { 1163 | if (Char1 != ',' && Char1 != ';') 1164 | Temp += Char1.ToString(); 1165 | else 1166 | { 1167 | Farray[Tmp] = float.Parse(Temp); 1168 | Tmp += 1; 1169 | Temp = ""; 1170 | } 1171 | if (Char1 == ';') 1172 | break; 1173 | } 1174 | return Farray; 1175 | } 1176 | if (Type == 7)//ByteArray 1177 | { 1178 | string String = Responce.Substring(Responce.find(" ") + 1); 1179 | int Tmp = 0; 1180 | string Temp = ""; 1181 | byte[] Barray = new byte[ArraySize]; 1182 | foreach (char Char1 in String) 1183 | { 1184 | if (Char1 != ',' && Char1 != ';') 1185 | Temp += Char1.ToString(); 1186 | else 1187 | { 1188 | Barray[Tmp] = byte.Parse(Temp); 1189 | Tmp += 1; 1190 | Temp = ""; 1191 | } 1192 | if (Char1 == ';') 1193 | break; 1194 | } 1195 | return Barray; 1196 | } 1197 | if (Type == JRPC.Uint64Array) 1198 | { 1199 | string String = Responce.Substring(Responce.find(" ") + 1); 1200 | int Tmp = 0; 1201 | string Temp = ""; 1202 | ulong[] ulongArray = new ulong[ArraySize]; 1203 | foreach (char Char1 in String) 1204 | { 1205 | if (Char1 != ',' && Char1 != ';') 1206 | Temp += Char1.ToString(); 1207 | else 1208 | { 1209 | ulongArray[Tmp] =ulong.Parse(Temp); 1210 | Tmp += 1; 1211 | Temp = ""; 1212 | } 1213 | if (Char1 == ';') 1214 | break; 1215 | } 1216 | if(t == typeof(ulong)) 1217 | return ulongArray; 1218 | else if (t == typeof(long)) 1219 | { 1220 | long[] longArray = new long[ArraySize]; 1221 | for (int i = 0; i < ArraySize; i++) 1222 | longArray[i] = BitConverter.ToInt64(BitConverter.GetBytes(ulongArray[i]), 0); 1223 | return longArray; 1224 | } 1225 | } 1226 | 1227 | if (Type == JRPC.Void) 1228 | return 0; 1229 | return ulong.Parse(Responce.Substring(Responce.find(" ") + 1), System.Globalization.NumberStyles.HexNumber); 1230 | } 1231 | } 1232 | } 1233 | } 1234 | -------------------------------------------------------------------------------- /JRPC_Client/JRPC.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {15FF3433-CD97-4E9F-ABA6-976E647B53B8} 8 | Library 9 | Properties 10 | JRPC_Client 11 | JRPC 12 | v4.7.2 13 | 512 14 | true 15 | 16 | 17 | 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | ..\..\..\Dlls\xdevkit.dll 45 | True 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /JRPC_Client/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyTrademark("")] 10 | [assembly: AssemblyTitle("JRPC")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("Xx jAmes t xX")] 13 | [assembly: AssemblyProduct("JRPC")] 14 | [assembly: AssemblyCopyright("Copyright © Xx jAmes t xX 2014")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("05de0859-c8f5-4150-8539-c7da716d39af")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("2.0.0.0")] 35 | [assembly: AssemblyFileVersion("2.0.0.0")] 36 | -------------------------------------------------------------------------------- /JRPC_Client/bin/Debug/JRPC.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XboxChef/JRPC/a509833b0327b7ae0737c5c8c65bf14f0bfbadda/JRPC_Client/bin/Debug/JRPC.dll -------------------------------------------------------------------------------- /JRPC_Client/bin/Debug/JRPC.dll.mdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XboxChef/JRPC/a509833b0327b7ae0737c5c8c65bf14f0bfbadda/JRPC_Client/bin/Debug/JRPC.dll.mdb -------------------------------------------------------------------------------- /JRPC_Client/bin/Debug/JRPC.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XboxChef/JRPC/a509833b0327b7ae0737c5c8c65bf14f0bfbadda/JRPC_Client/bin/Debug/JRPC.pdb -------------------------------------------------------------------------------- /JRPC_Client/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XboxChef/JRPC/a509833b0327b7ae0737c5c8c65bf14f0bfbadda/JRPC_Client/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache -------------------------------------------------------------------------------- /JRPC_Client/obj/Debug/JRPC.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | 12b250df77560833fdfefa6d245e7cb76cfaf49e 2 | -------------------------------------------------------------------------------- /JRPC_Client/obj/Debug/JRPC.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | C:\Users\Serenity\source\repos\JRPC_Client\JRPC_Client\obj\Debug\JRPC.csproj.CoreCompileInputs.cache 2 | C:\Users\Serenity\source\repos\JRPC_Client\JRPC_Client\bin\Debug\JRPC.dll 3 | C:\Users\Serenity\source\repos\JRPC_Client\JRPC_Client\bin\Debug\JRPC.pdb 4 | C:\Users\Serenity\source\repos\JRPC_Client\JRPC_Client\obj\Debug\JRPC.dll 5 | C:\Users\Serenity\source\repos\JRPC_Client\JRPC_Client\obj\Debug\JRPC.pdb 6 | -------------------------------------------------------------------------------- /JRPC_Client/obj/Debug/JRPC.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XboxChef/JRPC/a509833b0327b7ae0737c5c8c65bf14f0bfbadda/JRPC_Client/obj/Debug/JRPC.dll -------------------------------------------------------------------------------- /JRPC_Client/obj/Debug/JRPC.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XboxChef/JRPC/a509833b0327b7ae0737c5c8c65bf14f0bfbadda/JRPC_Client/obj/Debug/JRPC.pdb -------------------------------------------------------------------------------- /JRPC_Client/obj/Debug/JRPC_Client.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | 12b250df77560833fdfefa6d245e7cb76cfaf49e 2 | -------------------------------------------------------------------------------- /JRPC_Client/obj/Debug/JRPC_Client.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | C:\Users\Serenity\source\repos\JRPC_Client\JRPC_Client\bin\Debug\JRPC_Client.dll 2 | C:\Users\Serenity\source\repos\JRPC_Client\JRPC_Client\bin\Debug\JRPC_Client.pdb 3 | C:\Users\Serenity\source\repos\JRPC_Client\JRPC_Client\obj\Debug\JRPC_Client.csprojAssemblyReference.cache 4 | C:\Users\Serenity\source\repos\JRPC_Client\JRPC_Client\obj\Debug\JRPC_Client.csproj.CoreCompileInputs.cache 5 | C:\Users\Serenity\source\repos\JRPC_Client\JRPC_Client\obj\Debug\JRPC_Client.dll 6 | C:\Users\Serenity\source\repos\JRPC_Client\JRPC_Client\obj\Debug\JRPC_Client.pdb 7 | -------------------------------------------------------------------------------- /JRPC_Client/obj/Debug/JRPC_Client.csprojAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XboxChef/JRPC/a509833b0327b7ae0737c5c8c65bf14f0bfbadda/JRPC_Client/obj/Debug/JRPC_Client.csprojAssemblyReference.cache -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Xbox Class (JRPC) 2 | Give A ⭐ To Support This Project. 3 | 4 | [![GitHub Latest Release](https://img.shields.io/badge/Latest-Release-red)](https://github.com/XboxVillain/JRPC/releases)[![Join our Discord](https://img.shields.io/badge/join%20Us-discord-7289DA)](https://discord.gg/QvdmNnfQ86) 5 | 6 | 7 | An open source library Made By James Am Just Realeasing It As An Archive For People To Use Etc 8 | 9 | I Am Known As Serenity And Also TeddyHammer So If You wanna reach me Join Me On This Server 10 | Have Any Ideas Or Suggestions? Join Us On [Discord Server](https://discord.gg/QvdmNnfQ86)! 11 | 12 | # Features 13 | 14 | ### General Features 15 | 16 | 17 | # Requirements 18 | **1. An Internet Connection** 19 | 20 | **2. A know How Of C# Programing language Development** 21 | 22 | **3. An Understand How The Xbox XDevkit Works** 23 | 24 | **4. An Understanding On How To Work A Modified Xbox Console** 25 | 26 | ## Code Example 27 | 28 | 29 | ## Quick Guide 30 | 31 | ### Getting Started 32 | 33 | You can Either Build Yourself By Downloading the Source Or Just Grabbing [The Latest Dll Extention](https://github.com/XboxVillain/JRPC/releases). 34 | 35 | ### Connection 36 | 37 | Have To Be under The Same Local Network and Make Sure both Devices Are Connected To Same Wifi Name Or If Wired make sure to be under the same Router. 38 | 39 | ### Xbox 360 Plugin Requirements 40 | xbdm.xex , JRPC2.xex 41 | 42 | ### Computer Requirements 43 | A Working Tool Using this Extention Properly 44 | ## Creator 45 | * [Xx jAmes t xX] 46 | ## Disclaimer 47 | I have no liability for any damages done to your system by using this extention. 48 | ## License 49 | This project is released under the GNU General Public License v3. 50 | --------------------------------------------------------------------------------