Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "coreinit.h"
- #include "socket.h"
- void start()
- {
- /* Load a good stack */
- asm(
- "lis %r1, 0x1ab5 ;"
- "ori %r1, %r1, 0xd138 ;"
- );
- /* Get a handle to coreinit.rpl */
- unsigned int coreinit_handle, nsysnet_handle;
- OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
- OSDynLoad_Acquire("nsysnet.rpl", &nsysnet_handle);
- /* IOS functions */
- int (*IOS_Open)(unsigned char *path, int mode);
- int (*IOS_Ioctl)(int fd, int request, void *buffer1, int value, void *buffer2, int value2);
- void* (*OSAllocFromSystem)(int size, int align);
- /* Socket functions */
- int (*socket)(int family, int type, int proto);
- int (*connect)(int fd, struct sockaddr *addr, int addrlen);
- int (*recv)(int fd, void *buffer, int len, int flags);
- int (*send)(int fd, const void *buffer, int len, int flags);
- /* Read the address of OSSetExceptionCallback() */
- OSDynLoad_FindExport(coreinit_handle, 0, "IOS_Open", &IOS_Open);
- OSDynLoad_FindExport(coreinit_handle, 0, "IOS_Ioctl", &IOS_Ioctl);
- OSDynLoad_FindExport(coreinit_handle, 0, "OSAllocFromSystem", &OSAllocFromSystem);
- /* Read the addresses of socket(), connect(), and send() */
- OSDynLoad_FindExport(nsysnet_handle, 0, "socket", &socket);
- OSDynLoad_FindExport(nsysnet_handle, 0, "connect", &connect);
- OSDynLoad_FindExport(nsysnet_handle, 0, "recv", &recv);
- OSDynLoad_FindExport(nsysnet_handle, 0, "send", &send);
- /* Open /dev/uhs */
- int uhs0 = IOS_Open("/dev/uhs/0",1);
- /* Allocate the buffers */
- unsigned int *buffer1 = OSAllocFromSystem(0x10, 4);
- unsigned int *buffer2 = OSAllocFromSystem(0x5b0, 4);
- int i;
- for (i = 0; i < 0x16c; i++)
- {
- buffer2[i] = 0;
- }
- buffer1[0] = 0;
- buffer1[1] = 0;
- buffer1[2] = 0;
- buffer1[3] = 0;
- int test = IOS_Ioctl(uhs0, 0x11, buffer1, 0x10, buffer2, 4);
- /* Set up our socket address structure */
- struct sockaddr sin;
- sin.sin_family = AF_INET;
- sin.sin_port = 12345;
- sin.sin_addr.s_addr = PC_IP;
- for (j = 0; j < 8; j++)
- {
- sin.sin_zero[j] = 0;
- }
- /* Connect to the PC */
- int rpc = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- int status = connect(rpc, &sin, 0x10);
- if (status) OSFatal("Error connecting to RPC server");
- send(rpc, buffer1, 0x10, 0);
- send(rpc, buffer2, 0x5b0, 0);
- char buffer[256];
- __os_snprintf(buffer, 256, "IOS_Ioctl(): %d", test);
- OSFatal(buffer);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement