]> Chaos Git - corbenik/ctrulib.git/commitdiff
Implemented FSUSER_GetProductInfo.
authoryellows8 <yellows8@users.noreply.github.com>
Sat, 7 Nov 2015 22:35:54 +0000 (17:35 -0500)
committeryellows8 <yellows8@users.noreply.github.com>
Sat, 7 Nov 2015 22:35:54 +0000 (17:35 -0500)
libctru/include/3ds/services/fs.h
libctru/source/services/fs.c

index acac55aac8c6bd2a76dee10221c64d69e54b3f21..eadff3cfc3f2ee406b38161a5154358b469c9b58 100644 (file)
@@ -127,6 +127,14 @@ typedef struct
   u64 fileSize;        //!< file size
 } FS_dirent;
 
+/*! ProductInfo. These strings are not NULL-terminated. */
+typedef struct
+{
+       char product_code[0x10];
+       char company_code[0x2];
+       u16 remaster_version;
+} FS_ProductInfo;
+
 Result fsInit(void);
 Result fsExit(void);
 Handle *fsGetSessionHandle();
@@ -150,6 +158,7 @@ Result FSUSER_GetSdmcArchiveResource(Handle *handle, u32 *sectorSize, u32 *clust
 Result FSUSER_GetNandArchiveResource(Handle *handle, u32 *sectorSize, u32 *clusterSize, u32 *numClusters, u32 *freeClusters);
 Result FSUSER_IsSdmcDetected(Handle *handle, u8 *detected);
 Result FSUSER_IsSdmcWritable(Handle *handle, u8 *writable);
+Result FSUSER_GetProductInfo(Handle *handle, u32 processid, FS_ProductInfo *out);
 Result FSUSER_GetMediaType(Handle *handle, u8* mediatype);
 
 Result FSFILE_Close(Handle handle);
index 04f93ad3247f5ea50a6999551fb0a75e2d9c274f..d66eb175233983de07abeef782387ff84207a377 100644 (file)
@@ -1051,6 +1051,54 @@ FSUSER_IsSdmcDetected(Handle *handle,
        return cmdbuf[1];
 }
 
+/*! Get the ProductInfo for the specified process.
+ *
+ *  @param[in]  handle    fs:USER handle
+ *  @param[in]  processid ProcessID
+ *  @param[out] out       Output ProductInfo
+ *
+ *  @returns error
+ *
+ *  @internal
+ *
+ *  #### Request
+ *
+ *  Index Word | Description
+ *  -----------|-------------------------
+ *  0          | Header code [0x082E0040]
+ *  1          | u32 processID
+ *
+ *  #### Response
+ *
+ *  Index Word | Description
+ *  -----------|-------------------------
+ *  0          | Header code
+ *  1          | Result code
+ *  2-6        | Output ProductInfo
+ */
+Result
+FSUSER_GetProductInfo(Handle *handle,
+                      u32    processid,
+                      FS_ProductInfo *out)
+{
+       if(!handle)
+               handle = &fsuHandle;
+
+       u32 *cmdbuf = getThreadCommandBuffer();
+
+       cmdbuf[0] = 0x082E0040;
+       cmdbuf[1] = processid;
+
+       Result ret = 0;
+       if((ret = svcSendSyncRequest(*handle)))
+               return ret;
+
+       if(out)
+               memcpy(out, &cmdbuf[2], sizeof(FS_ProductInfo));
+
+       return cmdbuf[1];
+}
+
 /*! Get curent process mediatype
  *
  *  @param[in]  handle   fs:USER handle