@@ -811,24 +811,151 @@ static const struct file_operations proc_single_file_operations = {
811811static  ssize_t  ureg_read (struct  file  *  file , char  __user  *  buf ,
812812size_t  count , loff_t  * ppos )
813813{
814+ ssize_t  retval ;
814815struct  task_struct  * task  =  get_proc_task (file -> f_path .dentry -> d_inode );
815816
816817printk ("Reading uregs on %d\n" , * ppos );
817818
818- long   retval  =  arch_ptrace (task , PTRACE_PEEKUSR ,  
819+ retval  =  arch_ptrace (task , PTRACE_PEEKUSR ,
819820(unsigned long ) * ppos , (unsigned long ) buf );
820821printk ("Retval: %ld\n" , retval );
821822
822823if  (retval  <  0 ) 
823824return  0 ;
825+ 
826+ ppos  +=  sizeof (unsigned long );
827+ 
824828return  sizeof (unsigned long );
825829}
826830
831+ static  ssize_t  ureg_write (struct  file  * file , const  unsigned char   __user  * buf ,
832+  size_t  count , loff_t  * ppos ) {
833+ ssize_t  retval ;
834+ unsigned long  word  =  0 ;
835+ int  i ;
836+ struct  task_struct  * task  =  get_proc_task (file -> f_path .dentry -> d_inode );
837+ 
838+ for  (i  =  0 ; i  <  count  &&  i  <  sizeof (word ); ++ i ) {
839+ word  |= buf [i ] << (i * 8 );
840+ }
841+ 
842+ printk ("Writing uregs word %ld on %lld\n" , word , * ppos );
843+ 
844+ retval  =  arch_ptrace (task , PTRACE_POKEUSR ,
845+ (unsigned long ) * ppos , word );
846+ 
847+ // sucess 
848+ if  (retval  ==  0 )
849+ return  sizeof (word );
850+ 
851+ return  retval ;
852+ }
853+ 
827854static  const  struct  file_operations  proc_ureg_operations  =  {
828855.read =  ureg_read ,
856+ .write =  ureg_write ,
829857.llseek =  generic_file_llseek ,
830858};
831859
860+ static  ssize_t  regs_read (struct  file  *  file , char  __user  *  buf ,
861+ size_t  count , loff_t  * ppos )
862+ {
863+ ssize_t  retval ;
864+ struct  task_struct  * task  =  get_proc_task (file -> f_path .dentry -> d_inode );
865+ 
866+ printk ("Reading regs" );
867+ 
868+ if  (count  <  sizeof (struct  user_regs_struct )) {
869+ printk ("Buffer too small" );
870+ return  - EIO ;
871+ }
872+ 
873+ retval  =  arch_ptrace (task , PTRACE_GETREGS ,
874+ 0 , (unsigned long ) buf );
875+ printk ("Retval: %ld\n" , retval );
876+ 
877+ if  (retval  <  0 )
878+ return  0 ;
879+ 
880+ return  sizeof (struct  user_regs_struct );
881+ }
882+ 
883+ static  ssize_t  regs_write (struct  file  * file , const  unsigned char   __user  * buf ,
884+  size_t  count , loff_t  * ppos ) {
885+ ssize_t  retval ;
886+ struct  task_struct  * task  =  get_proc_task (file -> f_path .dentry -> d_inode );
887+ 
888+ printk ("Writing regs" );
889+ 
890+ if  (count  <  sizeof (struct  user_regs_struct )) {
891+ printk ("Buffer too small" );
892+ return  - EIO ;
893+ }
894+ 
895+ retval  =  arch_ptrace (task , PTRACE_SETREGS ,
896+ 0 , (unsigned long ) buf );
897+ 
898+ // sucess 
899+ if  (retval  ==  0 )
900+ return  sizeof (struct  user_regs_struct );
901+ 
902+ return  retval ;
903+ }
904+ 
905+ static  const  struct  file_operations  proc_regs_operations  =  {
906+ .read =  regs_read ,
907+ .write =  regs_write ,
908+ };
909+ 
910+ static  ssize_t  fpregs_read (struct  file  *  file , char  __user  *  buf ,
911+ size_t  count , loff_t  * ppos )
912+ {
913+ ssize_t  retval ;
914+ struct  task_struct  * task  =  get_proc_task (file -> f_path .dentry -> d_inode );
915+ 
916+ printk ("Reading fpregs" );
917+ 
918+ if  (count  <  sizeof (struct  user_i387_struct )) {
919+ printk ("Buffer too small" );
920+ return  - EIO ;
921+ }
922+ 
923+ retval  =  arch_ptrace (task , PTRACE_GETFPREGS ,
924+ 0 , (unsigned long ) buf );
925+ printk ("Retval: %ld\n" , retval );
926+ 
927+ if  (retval  <  0 )
928+ return  0 ;
929+ 
930+ return  sizeof (struct  user_i387_struct );
931+ }
932+ 
933+ static  ssize_t  fpregs_write (struct  file  * file , const  unsigned char   __user  * buf ,
934+  size_t  count , loff_t  * ppos ) {
935+ ssize_t  retval ;
936+ struct  task_struct  * task  =  get_proc_task (file -> f_path .dentry -> d_inode );
937+ 
938+ printk ("Writing fpregs" );
939+ 
940+ if  (count  <  sizeof (struct  user_i387_struct )) {
941+ printk ("Buffer too small" );
942+ return  - EIO ;
943+ }
944+ 
945+ retval  =  arch_ptrace (task , PTRACE_SETFPREGS ,
946+ 0 , (unsigned long ) buf );
947+ 
948+ // sucess 
949+ if  (retval  ==  0 )
950+ return  sizeof (struct  user_i387_struct );
951+ 
952+ return  retval ;
953+ }
954+ 
955+ static  const  struct  file_operations  proc_fpregs_operations  =  {
956+ .read =  fpregs_read ,
957+ .write =  fpregs_write ,
958+ };
832959
833960static  int  mem_open (struct  inode *  inode , struct  file *  file )
834961{
@@ -3003,7 +3130,9 @@ static const struct pid_entry tgid_base_stuff[] = {
30033130REG ("mem" , S_IRUSR |S_IWUSR , proc_mem_operations ),
30043131REG ("ctl" , S_IWUSR , proc_ctl_operations ),
30053132REG ("wait" , S_IWUSR , proc_wait_operations ),
3006- REG ("uregs" , S_IRUGO , proc_ureg_operations ),
3133+ REG ("uregs" , S_IRUSR |S_IWUSR , proc_ureg_operations ),
3134+ REG ("regs" , S_IRUSR |S_IWUSR , proc_regs_operations ),
3135+ REG ("fpregs" , S_IRUSR |S_IWUSR , proc_fpregs_operations ),
30073136REG ("eventmessage" , S_IRUSR , proc_eventmessage_operations ),
30083137REG ("last_siginfo" , S_IRUSR , proc_last_siginfo_operations ),
30093138LNK ("cwd" , proc_cwd_link ),
0 commit comments