public static void setDataUpper(TCPGecko upper) { UInt32 mem; switch (upper.OsVersionRequest()) { case 400: case 410: mem = upper.peek_kern(0xffe8619c); break; case 500: case 510: return; // TODO: This doesn't work for some reason - crashes on connection? //mem = upper.peek_kern(0xffe8591c); //break; default: return; } UInt32 tbl = upper.peek_kern(mem + 4); UInt32 lst = upper.peek_kern(tbl + 20); UInt32 init_start = upper.peek_kern(lst + 0 + 0x00); UInt32 init_len = upper.peek_kern(lst + 4 + 0x00); UInt32 code_start = upper.peek_kern(lst + 0 + 0x10); UInt32 code_len = upper.peek_kern(lst + 4 + 0x10); UInt32 data_start = upper.peek_kern(lst + 0 + 0x20); UInt32 data_len = upper.peek_kern(lst + 4 + 0x20); ValidAreas[0] = new AddressRange(AddressType.Ex, init_start, init_start + init_len); ValidAreas[1] = new AddressRange(AddressType.Ex, code_start, code_start + code_len); ValidAreas[2] = new AddressRange(AddressType.Rw, data_start, data_start + data_len); }
public static void setDataUpper(TCPGecko upper) { uint num1 = upper.OsVersionRequest(); if (num1 <= 410U) { if ((int)num1 != 400 && (int)num1 != 410) { return; } uint num2 = upper.peek_kern(4293419420U); uint num3 = upper.peek_kern(num2 + 4U); uint num4 = upper.peek_kern(num3 + 20U); uint low1 = upper.peek_kern((uint)((int)num4 + 0 + 0)); uint num5 = upper.peek_kern((uint)((int)num4 + 4 + 0)); uint low2 = upper.peek_kern((uint)((int)num4 + 0 + 16)); uint num6 = upper.peek_kern((uint)((int)num4 + 4 + 16)); uint low3 = upper.peek_kern((uint)((int)num4 + 0 + 32)); uint num7 = upper.peek_kern((uint)((int)num4 + 4 + 32)); ValidMemory.ValidAreas[0] = new AddressRange(AddressType.Ex, low1, low1 + num5); ValidMemory.ValidAreas[1] = new AddressRange(AddressType.Ex, low2, low2 + num6); ValidMemory.ValidAreas[2] = new AddressRange(AddressType.Rw, low3, low3 + num7); } else if ((int)num1 == 500 || (int)num1 == 510) { ; } }
public static void setDataUpper(TCPGecko upper) { uint mem; switch (upper.OsVersionRequest()) { case 400: case 410: mem = upper.peek_kern(0xFFEB902C); break; case 500: case 510: mem = upper.peek_kern(0xFFEA9E4C); break; case 532: case 540: mem = upper.peek_kern(0xFFEAAA1C); break; case 551: mem = upper.peek_kern(0xFFEAB7AC); break; default: mem = upper.peek_kern(); break; } uint tbl = upper.peek_kern(mem + 4); uint lst = upper.peek_kern(tbl + 20); uint init_start = upper.peek_kern(lst + 0 + 0x00); uint init_len = upper.peek_kern(lst + 4 + 0x00); uint code_start = upper.peek_kern(lst + 0 + 0x10); uint code_len = upper.peek_kern(lst + 4 + 0x10); uint data_start = upper.peek_kern(lst + 0 + 0x20); uint data_len = upper.peek_kern(lst + 4 + 0x20); ValidAreas[0] = new AddressRange(AddressType.Ex, init_start, init_start + init_len); ValidAreas[1] = new AddressRange(AddressType.Ex, code_start, code_start + code_len); ValidAreas[2] = new AddressRange(AddressType.Rw, data_start, data_start + data_len); }
public void DumpTree(params String[] folders) { UInt32 FSInit; UInt32 FSAddClient; UInt32 FSDelClient; UInt32 FSInitCmdBlock; UInt32 FSOpenDir; UInt32 FSCloseDir; UInt32 FSReadDir; UInt32 memalign; UInt32 free; switch (gecko.OsVersionRequest()) { case 400: case 410: FSInit = 0x01060d70; FSAddClient = 0x01061290; FSDelClient = 0x0106129c; FSInitCmdBlock = 0x01061498; FSOpenDir = 0x01066f3c; FSCloseDir = 0x01066fac; FSReadDir = 0x0106702c; memalign = gecko.peek(0x10049edc); free = gecko.peek(0x100adc2c); break; case 500: case 510: FSInit = 0x010666fc; FSAddClient = 0x01066d80; FSDelClient = 0x01066d8c; FSInitCmdBlock = 0x01066fec; FSOpenDir = 0x0106db58; FSCloseDir = 0x0106dbc8; FSReadDir = 0x0106dc48; memalign = gecko.peek(0x1004e2d0); free = gecko.peek(0x100b41fc); break; case 532: case 540: FSInit = 0x010683C8; FSAddClient = 0x010689FC; FSDelClient = 0x01068A08; FSInitCmdBlock = 0x01068C54; FSOpenDir = 0x0106F690; FSCloseDir = 0x0106F700; FSReadDir = 0x0106F780; memalign = gecko.peek(0x100b4878); free = gecko.peek(0x100b487c); break; default: MessageBox.Show("Unsupported Wii U OS version.", "Version mismatch", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { UInt32 ret; ret = gecko.rpc(FSInit); UInt32 pClient = gecko.rpc(memalign, 0x1700, 0x20); if (pClient == 0) { goto noClient; } UInt32 pCmd = gecko.rpc(memalign, 0xA80, 0x20); if (pCmd == 0) { goto noCmd; } ret = gecko.rpc(FSAddClient, pClient, 0); ret = gecko.rpc(FSInitCmdBlock, pCmd); UInt32 pDh = gecko.rpc(memalign, 4, 4); if (pDh == 0) { goto noDh; } UInt32 pPath = gecko.rpc(memalign, 0x200, 0x20); if (pPath == 0) { goto noPath; } UInt32 pBuf = gecko.rpc(memalign, 0x200, 0x20); if (pBuf == 0) { goto noBuf; } root = new fileStructure("vol", -1); Queue <fileStructure> scanQueue = new Queue <fileStructure>(); foreach (String item in folders) { scanQueue.Enqueue(root.addSubFolder(item, -1)); } while (scanQueue.Count > 0) { fileStructure current = scanQueue.Dequeue(); using (MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes(current.Path + "\0"))) { gecko.Upload(pPath, pPath + (uint)ms.Length, ms); } ret = gecko.rpc(FSOpenDir, pClient, pCmd, pPath, pDh, 0xffffffff); if (ret != 0) { goto noDir; } UInt32 dh = gecko.peek(pDh); do { ret = gecko.rpc(FSReadDir, pClient, pCmd, dh, pBuf, 0xffffffff); if (ret != 0) { break; } using (MemoryStream ms = new MemoryStream()) { gecko.Dump(pBuf, pBuf + 0x200, ms); Byte[] data = ms.ToArray(); UInt32 attr = ByteSwap.Swap(BitConverter.ToUInt32(data, 0)); UInt32 size = ByteSwap.Swap(BitConverter.ToUInt32(data, 8)); String name = new String(Encoding.ASCII.GetChars(data, 0x64, 0x100)); name = name.Remove(name.IndexOf('\0')); if ((attr & 0x80000000) != 0) { scanQueue.Enqueue(current.addSubFolder(name, -1)); } else { current.addFile(name, -1, size); } } } while (true); gecko.rpc(FSCloseDir, pClient, pCmd, dh, 0); noDir: continue; } gecko.rpc(free, pBuf); noBuf: gecko.rpc(free, pPath); noPath: gecko.rpc(free, pDh); noDh: ret = gecko.rpc(FSDelClient, pClient); gecko.rpc(free, pCmd); noCmd: gecko.rpc(free, pClient); noClient: if (root != null) { root.Sort(); root.ToTreeView(treeView); } } catch (ETCPGeckoException e) { exceptionHandling.HandleException(e); } catch { } }