Advertisement
Guest User

KHBBS disc_bind

a guest
May 4th, 2010
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.58 KB | None | 0 0
  1. int sub_8815608(void)
  2. {
  3.     a1 = *(u8*)0x08b501a2;
  4.     if(a1)
  5.         return 1;
  6.     a1 = *(u8*)0x08b501a1;
  7.     if(a1)
  8.         return 1;
  9.  
  10.     return 0;
  11. }
  12.  
  13. typedef struct SceIoStat {
  14.     SceMode             st_mode;        /* 00: file type(file/dir) and mode(RWX) */
  15.     unsigned int        st_attr;        /* 04: device specific attribute */
  16.     SceOff              st_size;        /* 08: file size */
  17.     ScePspDateTime      st_ctime;       /* 10: time of file creation */
  18.     ScePspDateTime      st_atime;       /* 20: time of last access */
  19.     ScePspDateTime      st_mtime;       /* 30: time of last modification */
  20.     unsigned int        st_private[6];  /* 40: reserved */
  21. } SceIoStat;
  22.  
  23. int sub_880E720(int *pts, int *a1, a2, char *name, int t0, int t1)
  24. {
  25.     SceIoStat stat;
  26.  
  27.     a1[0] = 0;
  28.     a1[4] = 0;
  29.     a1[8] = 0;
  30.     a1[12] = 0;
  31.     s7 = t1&0xff;
  32.     s5 = a1;
  33.     s1 = a2;
  34.  
  35.     if(s7){
  36.         s0 = 0x28b0e;
  37.         while(1){
  38.             v0 = sub_8815608();
  39.             if(v0)
  40.                 break;
  41.             s2 = sceIoGetstat(name, &stat);
  42.             if(s2==0)
  43.                 break;
  44.             sceKernelDelayThreadCB(0x28b0e);
  45.         }
  46.     }else{
  47.         s2 = sceIoGetstat(name, &stat);
  48.     }
  49.  
  50.     if(s2<0){
  51.         s5[0] = s2;
  52.     }else{
  53.         a0 = stat.0x08;
  54.         a1 = stat.0x0c
  55.  
  56.         a3 = *(u32*)0x08b25cf4;
  57.         a2 = *(u32*)0x08b25cf0;
  58.         t0 = a0+a2;
  59.         t1 = (t0<a2)?1:0;
  60.         a0 = t1+a1;
  61.         a1 = a0+a3;
  62.  
  63.         a3 = *(u32*)0x08b25cfc;
  64.         a2 = *(u32*)0x08b25cf8;
  65.         a0 = t0;
  66.         a1 = a1&a3;
  67.         a0 = a0&a2;
  68.  
  69.         at = a1<<21;
  70.         a0 = a0>>11;
  71.         a1 = a1>>11;
  72.         a0 = a0|at;
  73.  
  74.         s5[2] = a0;
  75.  
  76.         a0 = s1;
  77.         s0 = -1;
  78.         if(a0>0 && a0<4){
  79.             a0 = s1<<4;
  80.             a0 += 0x08b25cc0-0x10;
  81.             s5[3] = a0;
  82.         }
  83.  
  84.         a0 = s5[3];
  85.         if(a0){
  86.             if(s7){
  87.                 while(1){
  88.                     v0 = sub_8815608();
  89.                     if(v0)
  90.                         break;
  91.                     s1 = sceIoOpen(name, 0x40000001, 0);
  92.                     if(s1>0){
  93.                         s0 = sceIoIoctl(s1, 0x04100001, s5[3], 0x10, 0, 0);
  94.                         if(s0<0){
  95.                             sceIoClose(s1);
  96.                         }else{
  97.                             s0 = s1;
  98.                         }
  99.                     }else{
  100.                         s0 = s1;
  101.                     }
  102.                     if(s0>0)
  103.                         break;
  104.                     sceKernelDelayThreadCB(0x28b0e);
  105.                 }
  106.             }else{
  107.                 s4 = sceIoOpen(name, 0x40000001, 0);
  108.                 if(s4>0){
  109.                     s0 = sceIoIoctl(s4, 0x04100001, s5[3], 0x10, 0, 0);
  110.                     if(s0<0){
  111.                         sceIoClose(s4);
  112.                     }else{
  113.                         s0 = s4;
  114.                     }
  115.                 }else{
  116.                     s0 = s4;
  117.                 }
  118.             }
  119.             s5[0] = s0;
  120.         }
  121.  
  122.         if(s0<0){
  123.             if(s7){
  124.                 if(fp<0){
  125.                     s5[0] = fp;
  126.                 }else{
  127.                     while(1){
  128.                         v0 = sub_8815608();
  129.                         if(v0)
  130.                             break;
  131.                         v0 = sub_8810110(1, 0);
  132.                         if(v0>0){
  133.                             s5[0] = v0;
  134.                             break;
  135.                         }
  136.                         sceKernelDelayThreadCB(0x28b0e);
  137.                     }
  138.                 }
  139.                 fp = stat.0x40
  140.                 s5[4] = fp;
  141.             }else{
  142.                 v0 = sceIoOpen(name, 1, 0);
  143.                 s5[0] = v0;
  144.             }
  145.         }
  146.     }
  147.  
  148.     a0 = s5[0];
  149.     if(a0<0)
  150.         return 0;
  151.     else
  152.         return 1;
  153. }
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163. int sub_880EA48(int *pts, char *dst, int length)
  164. {
  165.     pts[0] = dst;
  166.     pts[1] = dst+0x30;
  167.  
  168.     a1 = *(u16*)(dst+0x08);
  169.     a1 <<= 3;
  170.     a1 += dst+0x30;
  171.     pts[2] = a1;
  172.  
  173.     a1 = *(u32*)(dst+0x10);
  174.     a1 += dst;
  175.     pts[3] = a1;
  176.  
  177.     a3 = *(u32*)(dst+0x14);
  178.     a3 += dst;
  179.     pts[4] = a3;
  180.  
  181.     a3 = *(u16*)(dst+0x18);
  182.     if(a3){
  183.         a1 = a3<<11;
  184.         a1 += dst;
  185.     }else{
  186.         a1 = 0;
  187.     }
  188.     pts[5] = a1;
  189.  
  190.     a1 = (length+0x07ff)>>11;
  191.     a2 = *(u16*)(dst+0x1A);
  192.     if(a1<a2)
  193.         return 0;
  194.  
  195.     v0 = strcmp(dst, "bbsa", 4);
  196.     if(v0)
  197.         return 0;
  198.  
  199.     a0 = *(u16*)(dst+0x04);
  200.     if(a0!=5)
  201.         return 0;
  202.  
  203.     return 1;
  204. }
  205.  
  206. int sub_880DE0C(char *pts, char *name, char *dst, int length, int flag)
  207. {
  208.     int *s0 = (int*)(pts+0x18);
  209.     int v0, lba_len, fd, lba;
  210.  
  211.     v0 = sub_880E720(pts, s0, 0, name, -1, flag);
  212.     if(v0==0)
  213.         return 0;
  214.  
  215.     lba_len = (length+0x07ff)>>11;
  216.  
  217.     fd = s0[0];
  218.     lba = s0[4];
  219.     v0 = sub_88105D4(fd, lba, dst, lba_len);
  220.     if(v0!=lba_len){
  221.         if(fd>0)
  222.             sceIoClose(fd);
  223.         return 0;
  224.     }
  225.  
  226.     sub_880EA48(pts, dst, length);
  227.     return 1;
  228.  
  229. }
  230.  
  231. int sub_880DEF4(int a0, int index, int a2, char *name, int flag)
  232. {
  233.     char dst[2048];
  234.  
  235.     if(index==0 || index>4){
  236.         return 0;
  237.     }
  238.  
  239.     s0 = a0;
  240.     s2 = a2;
  241.     a0 = s0+0x18;
  242.     t0 = *(u32*)a0;
  243.  
  244.     s4 = sub_880E720(s0, a2, index, name, t0, flag);
  245.     if(s4==0){
  246.         return 0;
  247.     }
  248.  
  249.     s5 = 0;
  250.     a1 = s2[3];
  251.     fd = s2[0];
  252.     if(flag && (a1==0)){
  253.         lba = s2[1];
  254.         v0 = sub_88105D4(fd, lba, dst, 1);
  255.         s4 = v0^1;
  256.         s5 = 0;
  257.     }else{
  258.         if(flag)
  259.             s4 = 0;
  260.         else
  261.             s4 = 2;
  262.  
  263.         v0 = sub_8810320(fd, dst, 0x12, s4);
  264.         s4 = v0^0x12;
  265.  
  266.         if(flag==0){
  267.             do_lseek(fd, 0, 0);
  268.             a1 = do_lseek(fd, 0, 2);
  269.             if(a1>0){
  270.                 s5 = a1;
  271.             }
  272.             do_close(fd);
  273.         }
  274.     }
  275.     s4 = !(s4);
  276.  
  277.  
  278.     if(s4){
  279.         s4 = sub_880EB1C(s0, dst, index);
  280.     }
  281.  
  282.     return s4;
  283. }
  284.  
  285.  
  286.  
  287.  
  288. int discInfoBind(void)
  289. {
  290.     char buf[128], *dst;
  291.     int *pt;
  292.  
  293.     pt = (int*)0x08b50120;
  294.     dst = (char*)0x09a33740;
  295.  
  296.     sprintf(buf, "disc0:/PSP_GAME/USRDIR/BBS%d.DAT", 0);
  297.     v0 = sub_880DE0C(*pt, buf, dst, 0x33000, 1);
  298.     if(v0==0)
  299.         return 0;
  300.  
  301.     for(id=1; id<5; id++){
  302.         sprintf(buf, "disc0:/PSP_GAME/USRDIR/BBS%d.DAT", id);
  303.         v0 = sub_880DEF4(*pt, i, *pt+i*16, buf, 1);
  304.         if(v0==0)
  305.             return 0;
  306.     }
  307.  
  308.     *(int*)(0x09A667A8) = 1;
  309.     return 0;
  310. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement