Beispiel #1
1
void initUsb(void) {
	int libUsb = sceKernelLoadStartModule("libSceUsbd.sprx", 0, NULL, 0, 0, 0);

	RESOLVE(libUsb, sceUsbdInit);
	RESOLVE(libUsb, sceUsbdExit);

	RESOLVE(libUsb, sceUsbdGetDeviceList);
	RESOLVE(libUsb, sceUsbdFreeDeviceList);

	RESOLVE(libUsb, sceUsbdGetDeviceDescriptor);

	RESOLVE(libUsb, sceUsbdOpen);
	RESOLVE(libUsb, sceUsbdOpenDeviceWithVidPid);
	RESOLVE(libUsb, sceUsbdClose);

	RESOLVE(libUsb, sceUsbdSetInterfaceAltSetting);
	RESOLVE(libUsb, sceUsbdClearHalt);
	RESOLVE(libUsb, sceUsbdResetDevice);
	RESOLVE(libUsb, sceUsbdCheckConnected);

	RESOLVE(libUsb, sceUsbdControlTransfer);
	RESOLVE(libUsb, sceUsbdBulkTransfer);
	RESOLVE(libUsb, sceUsbdInterruptTransfer);

	RESOLVE(libUsb, sceUsbdGetActiveConfigDescriptor);
	RESOLVE(libUsb, sceUsbdGetConfigDescriptor);
	RESOLVE(libUsb, sceUsbdGetConfigDescriptorByValue);
	RESOLVE(libUsb, sceUsbdFreeConfigDescriptor);
}
Beispiel #2
0
void initPad(void) {
	int libPad = sceKernelLoadStartModule("libScePad.sprx", 0, NULL, 0, 0, 0);
	
	RESOLVE(libPad, scePadInit);
	RESOLVE(libPad, scePadOpen);
	RESOLVE(libPad, scePadClose);
	RESOLVE(libPad, scePadRead);
	RESOLVE(libPad, scePadReadState);
	
	scePadInit();
}
Beispiel #3
0
void initCamera(void) {
	int libCamera = sceKernelLoadStartModule("libSceCamera.sprx", 0, NULL, 0, 0, 0);
	
	RESOLVE(libCamera, sceCameraOpen);
	RESOLVE(libCamera, sceCameraClose);
	RESOLVE(libCamera, sceCameraIsAttached);
	RESOLVE(libCamera, sceCameraGetFrameData);
	RESOLVE(libCamera, sceCameraStart);
	RESOLVE(libCamera, sceCameraStop);
	RESOLVE(libCamera, sceCameraGetDeviceInfo);
	RESOLVE(libCamera, sceCameraGetDeviceConfig);
	RESOLVE(libCamera, sceCameraGetConfig);
	RESOLVE(libCamera, sceCameraSetConfig);
}
Beispiel #4
0
int main(int argc, char **argv)
{
	int server, client;
	struct sockaddr_in serverAddress, clientAddress;
	char message[256];
	int stdfd[3];
	fpos_t stdpos[3];

	#ifdef __PS4__
	int libc = sceKernelLoadStartModule("libSceLibcInternal.sprx", 0, NULL, 0, 0, 0);
	sceKernelDlsym(libc, "__stdinp", (void **)&__stdinp_addr);
	sceKernelDlsym(libc, "__stdoutp", (void **)&__stdoutp_addr);
	sceKernelDlsym(libc, "__stderrp", (void **)&__stderrp_addr);
	sceKernelDlsym(libc, "__isthreaded", (void **)&__isthreaded_addr);
	__stdinp = *__stdinp_addr;
	__stdoutp = *__stdoutp_addr;
	__stderrp = *__stderrp_addr;
	__isthreaded = *__isthreaded_addr;
	#endif

	memset(&serverAddress, 0, sizeof(serverAddress));
	#ifdef __FreeBSD__ //parent of our __PS4__
	serverAddress.sin_len = sizeof(serverAddress);
	#endif
	serverAddress.sin_family = AF_INET;
	serverAddress.sin_addr.s_addr = htonl(INADDR_ANY);
	serverAddress.sin_port = htons(9025);

	memset(&clientAddress, 0, sizeof(clientAddress));

	server = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
	if(server < 0)
		return EXIT_FAILURE;

	if(bind(server, (struct sockaddr *)&serverAddress, sizeof(serverAddress)) < 0)
	{
		close(server);
		return EXIT_FAILURE;
	}

	if(listen(server, 10) < 0)
	{
		close(server);
		return EXIT_FAILURE;
	}

	while(1)
	{
		client = accept(server, NULL, NULL);

		if(client < 0)
			continue;

		stdIORedirect(client, stdfd, stdpos);

		struct sigaction action;

	    action.sa_handler = handler;
	    action.sa_flags = 0; // SA_NODEFER; /* repeated throws are caught */
	    sigemptyset(&action.sa_mask);
	    sigaction(SIGSEGV, &action, NULL);

		printf("loop\n");
		sigsetjmp(jmpbuf, 1);
		printf("oops\n");
		scanf("%s", message); // wait for input
		*((char *)0x42) = 42; /* provoke SIGSEGV */

		stdIOReset(stdfd, stdpos);

		close(client);
	}

	//close(server);
}
Beispiel #5
0
int main(int argc, char **argv)
{
	int server, client;
	struct sockaddr_in serverAddress, clientAddress;
	char message[256];
	int stdfd[3];
	fpos_t stdpos[3];

	pthread_t thread;

	#ifdef __PS4__
	int libc = sceKernelLoadStartModule("libSceLibcInternal.sprx", 0, NULL, 0, 0, 0);
	sceKernelDlsym(libc, "__stdinp", (void **)&__stdinp_addr);
	sceKernelDlsym(libc, "__stdoutp", (void **)&__stdoutp_addr);
	sceKernelDlsym(libc, "__stderrp", (void **)&__stderrp_addr);
	sceKernelDlsym(libc, "__isthreaded", (void **)&__isthreaded_addr);
	__stdinp = *__stdinp_addr;
	__stdoutp = *__stdoutp_addr;
	__stderrp = *__stderrp_addr;
	__isthreaded = *__isthreaded_addr;
	#endif

	memset(&serverAddress, 0, sizeof(serverAddress));
	#ifdef __FreeBSD__ //parent of our __PS4__
	serverAddress.sin_len = sizeof(serverAddress);
	#endif
	serverAddress.sin_family = AF_INET;
	serverAddress.sin_addr.s_addr = htonl(INADDR_ANY);
	serverAddress.sin_port = htons(9025);

	memset(&clientAddress, 0, sizeof(clientAddress));

	server = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
	if(server < 0)
		return EXIT_FAILURE;

	if(bind(server, (struct sockaddr *)&serverAddress, sizeof(serverAddress)) < 0)
	{
		close(server);
		return EXIT_FAILURE;
	}

	if(listen(server, 10) < 0)
	{
		close(server);
		return EXIT_FAILURE;
	}

	while(1)
	{
		volatile int run = 1;
		client = accept(server, NULL, NULL);

		if(client < 0)
			continue;

		stdIORedirect(client, stdfd, stdpos);

		pthread_create(&thread, NULL, start_routine, (void *)&run);
		scanf("%s", message); // block until input
		printf("main> %"PRIxPTR"\n", &errno);
		run = 0;
		pthread_join(thread, NULL);

		stdIOReset(stdfd, stdpos);

		close(client);
	}

	//close(server);
}
Beispiel #6
0
void initModule(void) {
	int libModule = sceKernelLoadStartModule("libSceSysmodule.sprx", 0, NULL, 0, 0, 0);
	
	// Just use sceKernelLoadStartModule instead
	RESOLVE(libModule, sceSysmoduleLoadModule);
}
Beispiel #7
0
int main(int argc, char **argv)
{
	int server, client;
	struct sockaddr_in serverAddress, clientAddress;
	//char message[256];
	int stdfd[3];
	fpos_t stdpos[3];

	#ifdef __PS4__
	int libc = sceKernelLoadStartModule("libSceLibcInternal.sprx", 0, NULL, 0, 0, 0);
	sceKernelDlsym(libc, "__stdinp", (void **)&__stdinp_addr);
	sceKernelDlsym(libc, "__stdoutp", (void **)&__stdoutp_addr);
	sceKernelDlsym(libc, "__stderrp", (void **)&__stderrp_addr);
	sceKernelDlsym(libc, "__isthreaded", (void **)&__isthreaded_addr);
	__stdinp = *__stdinp_addr;
	__stdoutp = *__stdoutp_addr;
	__stderrp = *__stderrp_addr;
	__isthreaded = *__isthreaded_addr;
	#endif

	memset(&serverAddress, 0, sizeof(serverAddress));
	#ifdef __FreeBSD__ //parent of our __PS4__
	serverAddress.sin_len = sizeof(serverAddress);
	#endif
	serverAddress.sin_family = AF_INET;
	serverAddress.sin_addr.s_addr = htonl(INADDR_ANY);
	serverAddress.sin_port = htons(9025);

	memset(&clientAddress, 0, sizeof(clientAddress));

	server = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
	if(server < 0)
		return EXIT_FAILURE;

	if(bind(server, (struct sockaddr *)&serverAddress, sizeof(serverAddress)) < 0)
	{
		close(server);
		return EXIT_FAILURE;
	}

	if(listen(server, 10) < 0)
	{
		close(server);
		return EXIT_FAILURE;
	}

	//while(1)
	{
	retry:
		client = accept(server, NULL, NULL);

		if(client < 0)
			goto retry;

		sleep(5);

		stdIORedirect(client, stdfd, stdpos);

		struct sigaction action;

		action.sa_handler = sigsegvHandler;
		action.sa_flags = 0; // SA_NODEFER; /* repeated throws are caught */
		sigemptyset(&action.sa_mask);
		sigaction(SIGSEGV, &action, NULL);

		ThreadCreate(0, t1);
		ThreadCreate(1, t2);

		pthread_join(threadData[0].thread, NULL);
		pthread_join(threadData[1].thread, NULL);

		stdIOReset(stdfd, stdpos);

		close(client);
	}

	close(server);

	return 0;
}