Advertisement
Reisyukaku

Get NcaIDs

Mar 21st, 2018
946
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var STORAGE_NONE = 0;
  2. var STORAGE_HOST = 1;
  3. var STORAGE_GAMECARD = 2;
  4. var STORAGE_NANDSYS = 3;
  5. var STORAGE_NANDUSER = 4;
  6. var STORAGE_SDCARD = 5;
  7.  
  8. var TITLE_STORAGE = STORAGE_SDCARD;
  9. var tid = '01007EF00011E800';
  10.  
  11. var types = ['CMNT','PROG','DATA','ICON','DOC','INFO'];
  12. for(var ind = 0; ind < 5; ind++){
  13.     //Get NCA ID
  14.     var nca_id = new Uint32Array(4);
  15.     try{
  16.     sc.ipcMsg(5).datau32(TITLE_STORAGE).sendTo('ncm').asResult().andThen(res => {
  17.         sc.withHandle(res.movedHandles[0], function(hnd) {
  18.             var res = sc.ipcMsg(6).datau64(utils.parseAddr(tid)).sendTo(hnd);
  19.             res = sc.ipcMsg(3).datau32(ind, 0, res.data[0], res.data[1], res.data[2], res.data[3]).sendTo(hnd);
  20.             for (var i = 0; i < 4; i++) {
  21.                 nca_id[i] = res.data[i];
  22.             }
  23.         });
  24.     });
  25.     }catch(e){
  26.        
  27.     }
  28.  
  29.     //Get NCA string for pretty printing.
  30.     var nca_id_str = '';
  31.     for (var i = 0; i < 4; i++) {
  32.         var val = nca_id[i];
  33.         for (var j = 0; j < 4; j++) {
  34.             var b = (val >> (j*8)) & 0xFF;
  35.             nca_id_str += ('00' + b.toString(16)).slice(-2);
  36.         }
  37.     }
  38.     utils.log('NcaId[' + types[ind] + ']: ' + nca_id_str);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement