Example #1
0
void __attribute__((noreturn)) __libctru_exit(int rc)
{
	u32 tmp=0;

   if(__system_argv)
      free(__system_argv);

	// Unmap the linear heap
	svcControlMemory(&tmp, __linear_heap, 0x0, __linear_heap_size, MEMOP_FREE, 0x0);

	// Unmap the application heap
	svcControlMemory(&tmp, __heapBase, 0x0, __heap_size, MEMOP_FREE, 0x0);

   if (__stack_size_extra)
      svcControlMemory(&tmp, __stack_bottom, 0x0, __stack_size_extra, MEMOP_FREE, 0x0);

	// Close some handles
	envDestroyHandles();

   if (__sync_fini)
		__sync_fini();

	// Jump to the loader if it provided a callback
	if (__system_retAddr)
		__system_retAddr();

	// Since above did not jump, end this process
	svcExitProcess();
}
int main()
{
	//Grab the status of the app (running, suspending, sleeping, exiting)
	APP_STATUS status;

	//Initialize 3ds services
	srvInit();
	fsInit();
	aptInit();
	gfxInit();
	hidInit(NULL);
	//Setup event handler to listen for changes in status
	aptSetupEventHandler();


	while ((status = aptGetStatus()) != APP_EXITING)
	{

		if (status == APP_RUNNING)
		{
			//If the app is currently in the forground running, execute the program.
			program();
		}
		else if (status == APP_SUSPENDING)
		{
			//If the app is currently suspended in the background, return to the home menu.
			aptReturnToMenu();
		}
		else if (status == APP_SLEEPMODE)
		{
			//If the app is currently suspended in sleep mode, wait.
			aptWaitStatusEvent();
		}

		//Wait for GPU
		gspWaitForVBlank();

	}

	//Close all opened services.
	hidExit();
	gfxExit();
	aptExit();
	srvExit();
	//Kill the process.
	svcExitProcess();
	return 0;
}
Example #3
0
void __attribute__((noreturn)) __ctru_exit(int rc)
{
	// Run the global destructors
	__libc_fini_array();

	// TODO: APT exit goes here

	// Unmap the linear heap
	svcControlMemory(&__linear_heap, __linear_heap, 0x0, __linear_heap_size, MEMOP_FREE, 0x0);

	// Unmap the application heap
	svcControlMemory(&heapBase, heapBase, 0x0, __heap_size, MEMOP_FREE, 0x0);

	// Jump to the loader if it provided a callback
	if (__system_retAddr)
		__system_retAddr();

	// Since above did not jump, end this process
	svcExitProcess();
}
Example #4
0
void __attribute__((noreturn)) __libctru_exit(int rc)
{
	u32 tmp=0;

	// Unmap the linear heap
	svcControlMemory(&tmp, __linear_heap, 0x0, linear_heap_size, MEMOP_FREE, 0x0);

	// Unmap the application heap
	svcControlMemory(&tmp, __heapBase, 0x0, heap_size, MEMOP_FREE, 0x0);

	// Close some handles
	__destroy_handle_list();

	// Jump to the loader if it provided a callback
	if (__system_retAddr)
		__system_retAddr();

	// Since above did not jump, end this process
	svcExitProcess();
}
Example #5
0
void _exit() { svcExitProcess(); }
Example #6
0
void __ctru_exit()
{
  __appExit();
  __sync_fini();
  svcExitProcess();
}