Example #1
0
int Playlog_Delete(void) //Make Wiiflow not show in playlog
{
	//Open play_rec.dat
	s32 playrec_fd = IOS_Open(PLAYRECPATH, IPC_OPEN_RW);
	if(playrec_fd < 0)
		goto error_2;

	//Read play_rec.dat
	if(IOS_Read(playrec_fd, &playrec_buf, sizeof(playrec_buf)) != sizeof(playrec_buf))
		goto error_1;

	if(IOS_Seek(playrec_fd, 0, 0) < 0)
		goto error_1;
    
	// invalidate checksum
	playrec_buf.checksum=0;

	if(IOS_Write(playrec_fd, &playrec_buf, sizeof(playrec_buf)) != sizeof(playrec_buf))
		goto error_1;

	IOS_Close(playrec_fd);
	return 0;

error_1:
	IOS_Close(playrec_fd);

error_2:
	return -1;
}
Example #2
0
int Playlog_Update(const char * ID, const u16 * title)
{
	if(!ID || !title)
		return -1;

	//If not started from SystemMenu, create playlog
	Playlog_Create();

	s32 fd = -1, res = -1;
	u32 sum = 0;
	u8 i;

	//Open play_rec.dat
	fd = IOS_Open(PLAYRECPATH, IPC_OPEN_RW);
	if(fd == -106)
	{
		//In case the play_rec.dat wasn´t found create one and try again
		int ret = Playlog_Create();
		if(ret < 0)
			return ret;

		fd = IOS_Open(PLAYRECPATH, IPC_OPEN_RW);
	}

	if(fd < 0)
		return res;

	PlayRec * playrec_buf = memalign(32, ALIGN32(sizeof(PlayRec))); //! Should be 32 byte aligned
	if(!playrec_buf)
	{
		IOS_Close(fd);
		return res;
	}

	memset(playrec_buf, 0, sizeof(PlayRec));

	u64 stime = getWiiTime();
	playrec_buf->ticks_boot = stime;
	playrec_buf->ticks_last = stime;

	//Update channel name and ID
	memcpy(playrec_buf->name, title, 84);
	memcpy(playrec_buf->title_id, ID, 6);

	//Calculate and update checksum
	for(i = 0; i < 31; i++)
		sum += playrec_buf->data[i];

	playrec_buf->checksum = sum;

	//Write play_rec.dat
	if(IOS_Write(fd, playrec_buf, sizeof(PlayRec)) == sizeof(PlayRec))
		res = 0;

	IOS_Close(fd);

	free(playrec_buf);

	return res;
}
Example #3
0
int Playlog_Update(const char ID[6], const u8 title[84])
{
	gprintf("Update Play log\n");
	u32 sum = 0;
	u8 i;

	//Open play_rec.dat
	s32 playrec_fd = IOS_Open(PLAYRECPATH, IPC_OPEN_RW);
	if(playrec_fd == -106)
	{
		gprintf("IOS_Open error ret: %i\n",playrec_fd);
		IOS_Close(playrec_fd);
		
		//In case the play_rec.dat wasn´t found create one and try again
		if(ISFS_CreateFile(PLAYRECPATH,0,3,3,3) < 0 )
			goto error_2;
			
		playrec_fd = IOS_Open(PLAYRECPATH, IPC_OPEN_RW);
		if(playrec_fd < 0)
			goto error_2;
	}
	else if(playrec_fd < 0)
		goto error_2;

    u64 stime = getWiiTime();
	playrec_buf.ticks_boot = stime;
	playrec_buf.ticks_last = stime;

	//Update channel name and ID
	memcpy(playrec_buf.name, title, 84);
	strcpy(playrec_buf.title_id, ID);

	memset(playrec_buf.padding2, 0, 18);

	//Calculate and update checksum
	for(i=0; i<31; i++)
		sum += playrec_buf.data[i];
	playrec_buf.checksum=sum;

	//Write play_rec.dat
	if(IOS_Write(playrec_fd, &playrec_buf, sizeof(playrec_buf)) != sizeof(playrec_buf))
		goto error_1;

	IOS_Close(playrec_fd);
	return 0;

error_1:
	gprintf("error_1\n");
	IOS_Close(playrec_fd);

error_2:
	gprintf("error_2\n");
	return -1;
}
Example #4
0
s32 Sys_GetCerts(signed_blob **certs, u32 *len)
{
	static signed_blob certificates[CERTS_LEN] ATTRIBUTE_ALIGN(32);

	s32 fd, ret;

	/* Open certificates file */
	fd = IOS_Open(certs_fs, 1);
	if (fd < 0)
		return fd;

	/* Read certificates */
	ret = IOS_Read(fd, certificates, sizeof(certificates));

	/* Close file */
	IOS_Close(fd);

	/* Set values */
	if (ret > 0) {
		*certs = certificates;
		*len   = sizeof(certificates);
	}

	return ret;
}
Example #5
0
void tell_cIOS_to_return_to_channel(void)
	{
    if (TITLE_UPPER(old_title_id) > 1 && TITLE_LOWER(old_title_id) > 2) // Don't change anything for system menu or no title id
        {
		static u64 sm_title_id ATTRIBUTE_ALIGN(32);
		sm_title_id = old_title_id; // title id to be launched in place of the system menu
		
		int ret;
		
		static ioctlv vector[0x08] ATTRIBUTE_ALIGN(32);

		vector[0].data = &sm_title_id;
		vector[0].len = 8;

		int es_fd = IOS_Open("/dev/es", 0);
		if (es_fd < 0)
			{
			debug("Couldn't open ES module\n");
			return;
			}
		
		ret = IOS_Ioctlv(es_fd, 0xA1, 1, 0, vector);
		
		debug ("tell_cIOS_to_return_to_channel = %d\n", ret);

		IOS_Close(es_fd);
        }
	}
Example #6
0
File: usb.c Project: comex/libogc
s32 USB_GetDeviceList(const char *devpath,void *descr_buffer,u8 num_descr,u8 b0,u8 *cnt_descr)
{
	s32 fd,ret;
	char *path;
	u32 cntdevs;

	if(devpath==NULL || *devpath=='\0') return IPC_EINVAL;

	path = (char*)iosAlloc(hId,IPC_MAXPATH_LEN);
	if(path==NULL) return IPC_ENOMEM;
	
	strncpy(path,devpath,IPC_MAXPATH_LEN);
	fd = IOS_Open(path,IPC_OPEN_NONE);
	if(fd<0) {
		iosFree(hId,path);
		return fd;
	}

	cntdevs = 0;
	ret = IOS_IoctlvFormat(hId,fd,USB_IOCTL_GETDEVLIST,"bb:bd",num_descr,b0,&cntdevs,descr_buffer,(num_descr<<3));
	if(ret>=0) *cnt_descr = cntdevs;
	
	iosFree(hId,path);
	IOS_Close(fd);
	return ret;
}
Example #7
0
int Playlog_Delete(void)
{
	s32 res = -1;

	//Open play_rec.dat
	s32 fd = IOS_Open(PLAYRECPATH, IPC_OPEN_RW);
	if(fd < 0)
		return fd;

	PlayRec * playrec_buf = memalign(32, ALIGN32(sizeof(PlayRec)));
	if(!playrec_buf)
		goto cleanup;

	//Read play_rec.dat
	if(IOS_Read(fd, playrec_buf, sizeof(PlayRec)) != sizeof(PlayRec))
		goto cleanup;

	if(IOS_Seek(fd, 0, 0) < 0)
		goto cleanup;

	// invalidate checksum
	playrec_buf->checksum = 0;

	if(IOS_Write(fd, playrec_buf, sizeof(PlayRec)) != sizeof(PlayRec))
		goto cleanup;

	res = 0;

cleanup:
	free(playrec_buf);
	IOS_Close(fd);
	return res;
}
Example #8
0
s32 Nand_Enable(nandDevice *dev)
{
	s32 fd, ret;

	/* Open /dev/fs */
	fd = IOS_Open("/dev/fs", 0);
	if (fd < 0)
		return fd;

	memset(inbuf, 0, sizeof(inbuf));

	/* Set input buffer */
	if (IOS_GetRevision() >= 20)
	{
		// New method, fully enable full emulation
		inbuf[0] = dev->mode | 0x100;
	} else
	{
		// Old method
		inbuf[0] = dev->mode;
	}

	/* Enable NAND emulator */
	ret = IOS_Ioctl(fd, 100, inbuf, sizeof(inbuf), NULL, 0);

	/* Close /dev/fs */
	IOS_Close(fd);

	return ret;
} 
Example #9
0
void DIP::Close()
{
	if (Device_Handle > 0)
	{
		IOS_Close(Device_Handle);
		Device_Handle = -1;
	}
}
Example #10
0
File: usb.c Project: comex/libogc
s32 USB_DeviceInsertNotifyAsync(const char *devpath,u16 vid,u16 pid,usbcallback cb,void *usrdata)
{
	char *path;
	s32 fd = -1;
	s32 ret = IPC_ENOMEM;
	u16 *pvid = NULL;
	u16 *ppid = NULL;
	ioctlv *vec = NULL;
	struct _usb_cb *msgcb = NULL;

	if(devpath==NULL || *devpath=='\0') return IPC_EINVAL;

	path = (char*)iosAlloc(hId,IPC_MAXPATH_LEN);
	if(path==NULL) return IPC_ENOMEM;
	
	strncpy(path,devpath,IPC_MAXPATH_LEN);
	fd = IOS_Open(path,IPC_OPEN_NONE);
	if(fd<0) {
		ret = fd;
		goto done;
	}

	vec = iosAlloc(hId,sizeof(ioctlv)*2);
	if(vec==NULL) goto done;

	msgcb = iosAlloc(hId,sizeof(struct _usb_cb));
	if(msgcb==NULL) goto done;

	pvid = iosAlloc(hId,32);
	if(pvid==NULL) goto done;
	*pvid = vid;

	ppid = iosAlloc(hId,32);
	if(ppid==NULL) goto done;
	*ppid = pid;

	vec[0].data = pvid;
	vec[0].len = sizeof(u16);
	vec[1].data = ppid;
	vec[1].len = sizeof(u16);

	msgcb->fd = fd;
	msgcb->cb = cb;
	msgcb->vec = vec;
	msgcb->usrdata = usrdata;
	return IOS_IoctlvAsync(fd,USB_IOCTL_DEVINSERTHOOK,2,0,vec,__usb_device_notificationCB,msgcb);

done:
	if(ppid!=NULL) iosFree(hId,ppid);
	if(pvid!=NULL) iosFree(hId,pvid);
	if(msgcb!=NULL) iosFree(hId,msgcb);
	if(vec!=NULL) iosFree(hId,vec);
	if(path!=NULL) iosFree(hId,path);
	
	if(fd>=0) IOS_Close(fd);

	return ret;
}
Example #11
0
void USBStorage2_Deinit()
{
	/* Close USB device */
	if (fd >= 0)
	{
		IOS_Close(fd);
		fd = -1;
	}
}
void USBStorage2_Deinit()
{
	/* Close USB device */
	if (fd >= 0)
	{
		IOS_Close(fd);  // not sure to close the fd is needed
		fd = -1;
	}
}
Example #13
0
File: usb.c Project: comex/libogc
s32 USB_CloseDevice(s32 *fd)
{
	s32 ret = IPC_OK;

	if(fd && *fd>=0) {
		ret = IOS_Close(*fd);
		if(ret>=0) *fd = -1;
	}
	return ret;
}
s32 WDVD_Close(void)
{
	if (di_fd >= 0)
	{
		IOS_Close( di_fd );
		di_fd = -1;
	}

	return 0;
}
Example #15
0
s32 WDVD_Close(void)
{
	/* Close "/dev/di" */
	if(di_fd >= 0)
	{
		IOS_Close(di_fd);
		di_fd = -1;
	}
	return 0;
}
Example #16
0
File: stm.c Project: comex/libogc
s32 __STM_Close()
{
	s32 res;
	s32 ret = 0;
	__STM_ReleaseEventHook();
	
	if(__stm_imm_fd >= 0) {
		res = IOS_Close(__stm_imm_fd);
		if(res < 0) ret = res;
		__stm_imm_fd = -1;
	}
	if(__stm_eh_fd >= 0) {
		res = IOS_Close(__stm_eh_fd);
		if(res < 0) ret = res;
		__stm_eh_fd = -1;
	}
	__stm_initialized = 0;
	return ret;
}
Example #17
0
s32 CheckDisk(void *id)
	{
	const char di_fs[] ATTRIBUTE_ALIGN(32) = "/dev/di";
	s32 di_fd = -1;
	u32 inbuf[8]  ATTRIBUTE_ALIGN(32);
	u32 outbuf[8] ATTRIBUTE_ALIGN(32);	
	
	/* Open "/dev/di" */
	di_fd = IOS_Open(di_fs, 0);
	if (di_fd < 0) return di_fd; // error

	/* Reset drive */
	memset(inbuf, 0, sizeof(inbuf));
	inbuf[0] = IOCTL_DI_RESET << 24;
	inbuf[1] = 1;

	s32 ret = IOS_Ioctl(di_fd, IOCTL_DI_RESET, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf));
	if (ret < 0) 
		{
		IOS_Close(di_fd);
		return ret;
		}

	/* Read disc ID */
	memset(inbuf, 0, sizeof(inbuf));
	inbuf[0] = IOCTL_DI_READID << 24;
	ret = IOS_Ioctl(di_fd, IOCTL_DI_READID, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf));
	if (ret < 0) return ret;
	if (ret == 1 && id)
		memcpy(id, outbuf, sizeof(dvddiskid));
		
	/* Stop motor */
	memset(inbuf, 0, sizeof(inbuf));
	inbuf[0] = IOCTL_DI_STOPMOTOR << 24;
	IOS_Ioctl(di_fd, IOCTL_DI_STOPMOTOR, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf));
	IOS_Close(di_fd);

	if (ret != 1)
		{
		grlib_menu (0, "Sorry, no disc is detected in your WII", " OK ");
		}
	return ret;
	}
Example #18
0
File: DI.c Project: BhaaLseN/sneek
s32 DVDInsertDisc( void )
{
	s32 fd = IOS_Open("/dev/di", 0 );
	if( fd < 0 )
		return fd;

	s32 r = IOS_Ioctl( fd, DVD_INSERT_DISC, NULL, 0, NULL, 0 );

	IOS_Close( fd );

	return r;
}
Example #19
0
File: DI.c Project: BhaaLseN/sneek
s32 DVDGetGameCount( u32 *Count )
{
	s32 fd = IOS_Open("/dev/di", 0 );
	if( fd < 0 )
		return fd;

	s32 r = IOS_Ioctl( fd, DVD_GET_GAMECOUNT, NULL, 0, Count, sizeof(u32) );

	IOS_Close( fd );

	return r;
}
Example #20
0
File: DI.c Project: BhaaLseN/sneek
s32 DVDLowPrepareCoverRegister( u32 *Cover )
{
	s32 fd = IOS_Open("/dev/di", 0 );
	if( fd < 0 )
		return fd;

	s32 r = IOS_Ioctl( fd, 0x7A, NULL, 0, Cover, sizeof(u32) );

	IOS_Close( fd );

	return r;
}
Example #21
0
File: DI.c Project: BhaaLseN/sneek
s32 DVDConnected( void )
{
	s32 fd = IOS_Open("/dev/di", 0 );
	if( fd < 0 )
		return fd;

	s32 r = IOS_Ioctl( fd, DVD_CONNECTED, NULL, 0, NULL, 0);
	
	IOS_Close( fd );

	return r;
}
Example #22
0
File: DI.c Project: BhaaLseN/sneek
s32 DVDEjectDisc( void )
{
	s32 fd = IOS_Open("/dev/di", 0 );
	if( fd < 0 )
		return fd;

	s32 r = IOS_Ioctl( fd, DVD_EJECT_DISC, NULL, 0, NULL, 0 );

	IOS_Close( fd );

	return r;
}
Example #23
0
void MCPHookClose()
{
   if (mcp_hook_fd < 0)
      return;

   //close down wupserver, return control to mcp
   IOSUHAX_Close();
   //wait for mcp to return
   retro_sleep(1000);
   IOS_Close(mcp_hook_fd);
   mcp_hook_fd = -1;
}
Example #24
0
BSPError
bspShutdownShimInterface()
{
   auto result = IOS_Close(sBspData->bspHandle);

   if (IOS_FAILED(result)) {
      return BSPError::IosError;
   }

   sBspData->bspHandle = IOSError::Invalid;
   return BSPError::OK;
}
Example #25
0
u8 *NANDLoadFile( char *path, u32 *Size )
{
	s32 fd = IOS_Open( path, 1 );
	if( fd < 0 )
	{
		//dbgprintf("ES:NANDLoadFile->IOS_Open(\"%s\", 1 ):%d\n", path, fd );
		*Size = fd;
		return (u8*)NULL;
	}
	//dbgprintf("ES:NANDLoadFile->IOS_Open(\"%s\", 1 ):%d\n", path, fd );

	*Size = IOS_Seek( fd, 0, SEEK_END );
	//dbgprintf("ES:NANDLoadFile->Size:%d\n", *Size );

	IOS_Seek( fd, 0, 0 );

	u8 *data = (u8*)heap_alloc_aligned( 0, *Size, 0x40 );
	if( data == NULL )
	{
		//dbgprintf("ES:NANDLoadFile(\"%s\")->Failed to alloc %d bytes!\n", path, status->Size );
		IOS_Close( fd );
		return (u8*)NULL;
	}

	s32 r = IOS_Read( fd, data, *Size );
	//dbgprintf("ES:NANDLoadFile->IOS_Read():%d\n", r );
	if( r < 0 )
	{
		//dbgprintf("ES:NANDLoadFile->IOS_Read():%d\n", r );
		*Size = r;
		IOS_Close( fd );
		return (u8*)NULL;
	}

	IOS_Close( fd );

	return data;
}
Example #26
0
bool SDHC_Close(void)
{
	/* Close SDHC device */
	if (fd > 0) {
		IOS_Close(fd);
		fd = -1;
	}

	/*if (hid > 0) {
		iosDestroyHeap(hid);
		hid = -1;
	}*/

	return true;
}
Example #27
0
/****************************************************************************
 * Get network IP
 ***************************************************************************/
bool ShutdownWC24() {
    bool onlinefix = IsNetworkInit();
    if (onlinefix) {
        s32 kd_fd, ret;
        STACK_ALIGN(u8, kd_buf, 0x20, 32);

        kd_fd = IOS_Open("/dev/net/kd/request", 0);
        if (kd_fd >= 0) {
            ret = IOS_Ioctl(kd_fd, 7, NULL, 0, kd_buf, 0x20);
            if (ret >= 0)
                onlinefix = false; // fixed no IOS reload needed
            IOS_Close(kd_fd);
        }
    }
    return onlinefix;
}
Example #28
0
u32 ssl_close(void){
	s32 ret;

	if(__ssl_fd < 0){
		return 0;
	}

	ret = IOS_Close(__ssl_fd);

	__ssl_fd = -1;

	if(ret<0){
		return ret;
	}

	return 0;
}
Example #29
0
File: DI.c Project: BhaaLseN/sneek
s32 DVDWriteDIConfig( void *DIConfig )
{
	s32 fd = IOS_Open("/dev/di", 0 );
	if( fd < 0 )
		return fd;

	u32 *vec = (u32 *)malloca( sizeof(u32) * 1, 32 );
	vec[0] = (u32)DIConfig;

	s32 r = IOS_Ioctl( fd, DVD_WRITE_CONFIG, vec, sizeof(u32) * 1, NULL, 0 );

	IOS_Close( fd );

	free( vec );

	return r;
}
Example #30
0
File: DI.c Project: BhaaLseN/sneek
s32 DVDSelectGame( u32 SlotID )
{
	s32 fd = IOS_Open("/dev/di", 0 );
	if( fd < 0 )
		return fd;

	u32 *vec = (u32 *)malloca( sizeof(u32) * 1, 32 );
	vec[0] = SlotID;

	s32 r = IOS_Ioctl( fd, DVD_SELECT_GAME, vec, sizeof(u32) * 1, NULL, 0 );

	IOS_Close( fd );

	free( vec );

	return r;
}