Example #1
0
void initSystem(void (*retAddr)(void))
{
	// Register newlib exit() syscall
	__syscalls.exit = __ctru_exit;
	__system_retAddr = __service_ptr ? retAddr : NULL;

	// Allocate the application heap
	heapBase = 0x08000000;
	svcControlMemory(&heapBase, heapBase, 0x0, __heap_size, MEMOP_ALLOC, 0x3);

	// Allocate the linear heap
	svcControlMemory(&__linear_heap, 0x0, 0x0, __linear_heap_size, MEMOP_ALLOC_LINEAR, 0x3);

	// Set up newlib heap
	fake_heap_start = (char*)heapBase;
	fake_heap_end = fake_heap_start + __heap_size;

	// Build argc/argv if present
	initArgv();

	// TODO: APT init goes here

	// Run the global constructors
	__libc_init_array();
}
Example #2
0
void initConfig(char *name, char *passwd,ARGV argv)
{
    int saveFlag = 0;	/* 是否需要保存参数 */
    int exitFlag = 0;	/* 0Nothing 1退出 2重启 */
    strcpy(userName,name);
    strcpy(password,passwd);
    initArgv(argv);
    // checkRunning(exitFlag);
    if (startMode%3==2 && gateway==0)	/* 赛尔且未填写网关地址 */
    {
        gateway = ip;	/* 据说赛尔的网关是ip前三字节,后一字节是2 */
        ((u_char *)&gateway)[3] = 0x02;
    }
    if(strstr(dhcpScript,"dhclient"))
    {
        dhcpScript[0]='\0';
        sprintf(dhcpScript,D_DHCPSCRIPT,nic);
    }

    if (dhcpScript[0] == '\0')	/* 未填写DHCP脚本? */
    {
        sprintf(dhcpScript,D_DHCPSCRIPT,nic);
    }
    newBuffer();
    printf("进入fillHeader,打开过滤\n");
    if(fillHeader()==-1)
    {
        printf("fillHear,Done\n");
        exit(-1);
    }
    if(openPcap()==-1)
    {
        printf("OpenPcap failed\n");
        exit(-1);
    }
}