diff --git a/bindings/java/jni/dataModel_SleuthkitJNI.cpp b/bindings/java/jni/dataModel_SleuthkitJNI.cpp index 748ebbeb4c254a49d00881dd62bfc122533d25db..908c709b3020e7af04b06a74e7d0eab8dfa67c03 100644 --- a/bindings/java/jni/dataModel_SleuthkitJNI.cpp +++ b/bindings/java/jni/dataModel_SleuthkitJNI.cpp @@ -3,7 +3,7 @@ ** The Sleuth Kit ** ** Brian Carrier [carrier <at> sleuthkit [dot] org] - ** Copyright (c) 2010-2014 Brian Carrier. All Rights reserved + ** Copyright (c) 2010-2018 Brian Carrier. All Rights reserved ** ** This software is distributed under the Common Public License 1.0 ** @@ -1312,16 +1312,17 @@ JNIEXPORT jlong JNICALL /* - * Open an image pointer for the given image + * Open an image pointer for the given image. * @return the created TSK_IMG_INFO pointer * @param env pointer to java environment this was called from * @param obj the java object this was called from * @param paths the paths to the image parts * @param num_imgs number of image parts + * @param sector_size the sector size (use '0' for autodetect) */ JNIEXPORT jlong JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_openImgNat(JNIEnv * env, - jclass obj, jobjectArray paths, jint num_imgs) { + jclass obj, jobjectArray paths, jint num_imgs, jint sector_size) { TSK_IMG_INFO *img_info; jboolean isCopy; @@ -1342,7 +1343,7 @@ JNIEXPORT jlong JNICALL // open the image img_info = tsk_img_open_utf8((int) num_imgs, imagepaths8, TSK_IMG_TYPE_DETECT, - 0); + sector_size); if (img_info == NULL) { setThrowTskCoreError(env, tsk_error_get()); } diff --git a/bindings/java/jni/dataModel_SleuthkitJNI.h b/bindings/java/jni/dataModel_SleuthkitJNI.h index b4c2d9cd5ba7470c1dec16bea8f3e78de68eefe1..52a7a85a46872c3a04cf89ccd6fe3e1be526bff1 100644 --- a/bindings/java/jni/dataModel_SleuthkitJNI.h +++ b/bindings/java/jni/dataModel_SleuthkitJNI.h @@ -266,10 +266,10 @@ JNIEXPORT jlong JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_commitAddImgNa /* * Class: org_sleuthkit_datamodel_SleuthkitJNI * Method: openImgNat - * Signature: ([Ljava/lang/String;I)J + * Signature: ([Ljava/lang/String;II)J */ JNIEXPORT jlong JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_openImgNat - (JNIEnv *, jclass, jobjectArray, jint); + (JNIEnv *, jclass, jobjectArray, jint, jint); /* * Class: org_sleuthkit_datamodel_SleuthkitJNI diff --git a/bindings/java/src/org/sleuthkit/datamodel/Examples/Sample.java b/bindings/java/src/org/sleuthkit/datamodel/Examples/Sample.java index 3f6620ae56d8afd6e31c045e42ff15e76984ef8a..6dde39acbcf7505aa675faaa904601fb37f574a8 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/Examples/Sample.java +++ b/bindings/java/src/org/sleuthkit/datamodel/Examples/Sample.java @@ -47,7 +47,7 @@ public static void run(String imagePath) { ArrayList<String> paths = new ArrayList<String>(); paths.add(imagePath); try { - process.run(UUID.randomUUID().toString(), paths.toArray(new String[paths.size()])); + process.run(UUID.randomUUID().toString(), paths.toArray(new String[paths.size()]), 0); } catch (TskDataException ex) { Logger.getLogger(Sample.class.getName()).log(Level.SEVERE, null, ex); } diff --git a/bindings/java/src/org/sleuthkit/datamodel/Image.java b/bindings/java/src/org/sleuthkit/datamodel/Image.java index cc85db8783b45dca08e837823c93812f7bae4afa..083615212a2d4753e758e96ceffcc4a01caac9df 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/Image.java +++ b/bindings/java/src/org/sleuthkit/datamodel/Image.java @@ -114,7 +114,7 @@ protected Image(SleuthkitCase db, long obj_id, long type, long ssize, String nam */ public synchronized long getImageHandle() throws TskCoreException { if (imageHandle == 0) { - imageHandle = SleuthkitJNI.openImage(paths); + imageHandle = SleuthkitJNI.openImage(paths, (int)ssize); } return imageHandle; diff --git a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java index ba600c9233d3cb9ededc0624a061f5f883408a58..b2283721c7099bf7606901f0bce02c4397000f0a 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java +++ b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java @@ -289,6 +289,7 @@ private AddImageProcess(String timeZone, boolean addUnallocSpace, boolean skipFa * should be unique across multiple cases * (e.g., a UUID). * @param imageFilePaths Full path(s) to the image file(s). + * @param sectorSize The sector size (use '0' for autodetect). * * @throws TskCoreException if a critical error occurs within the * SleuthKit. @@ -296,14 +297,14 @@ private AddImageProcess(String timeZone, boolean addUnallocSpace, boolean skipFa * the SleuthKit (should be OK to continue * the process) */ - public void run(String deviceId, String[] imageFilePaths) throws TskCoreException, TskDataException { + public void run(String deviceId, String[] imageFilePaths, int sectorSize) throws TskCoreException, TskDataException { long imageHandle = 0; synchronized (this) { if (0 != tskAutoDbPointer) { throw new TskCoreException("Add image process already started"); } if (!isCanceled) { //with isCanceled being guarded by this it will have the same value everywhere in this synchronized block - imageHandle = openImage(imageFilePaths, false); + imageHandle = openImage(imageFilePaths, sectorSize, false); tskAutoDbPointer = initAddImgNat(caseDbPointer, timezoneLongToShort(timeZone), addUnallocSpace, skipFatFsOrphans); } if (0 == tskAutoDbPointer) { @@ -395,7 +396,29 @@ public synchronized String currentDirectory() { */ @Deprecated public void run(String[] imageFilePaths) throws TskCoreException, TskDataException { - run(null, imageFilePaths); + run(null, imageFilePaths, 0); + } + + /** + * Starts the process of adding an image to the case database. + * Either AddImageProcess.commit or AddImageProcess.revert MUST be + * called after calling AddImageProcess.run. + * + * @param deviceId An ASCII-printable identifier for the + * device associated with the image that + * should be unique across multiple cases + * (e.g., a UUID). + * @param imageFilePaths Full path(s) to the image file(s). + * + * @throws TskCoreException if a critical error occurs within the + * SleuthKit. + * @throws TskDataException if a non-critical error occurs within + * the SleuthKit (should be OK to continue + * the process) + */ + @Deprecated + public void run(String deviceId, String[] imageFilePaths) throws TskCoreException, TskDataException { + run(deviceId, imageFilePaths, 0); } } @@ -480,7 +503,7 @@ public static void startVerboseLogging(String logPath) { } /** - * open the image and return the image info pointer + * Open the image and return the image info pointer. * * @param imageFiles the paths to the images * @@ -490,16 +513,49 @@ public static void startVerboseLogging(String logPath) { * TSK */ public static long openImage(String[] imageFiles) throws TskCoreException { - return openImage(imageFiles, true); + return openImage(imageFiles, 0, true); + } + + /** + * Open the image with a specified sector size and return the image info + * pointer. + * + * @param imageFiles the paths to the images + * @param sSize the sector size (use '0' for autodetect) + * + * @return the image info pointer + * + * @throws TskCoreException exception thrown if critical error occurs within + * TSK + */ + public static long openImage(String[] imageFiles, int sSize) throws TskCoreException { + return openImage(imageFiles, sSize, true); + } + + /** + * Open the image and return the image info pointer. + * + * @param imageFiles the paths to the images + * @param useCache true if the image handle cache should be used, false to + * always go to TSK to open a fresh copy + * + * @return the image info pointer + * + * @throws TskCoreException exception thrown if critical error occurs within + * TSK + */ + public static long openImage(String[] imageFiles, boolean useCache) throws TskCoreException { + return openImage(imageFiles, 0, useCache); } /** - * open the image and return the image info pointer This is a temporary + * Open the image and return the image info pointer. This is a temporary * measure to allow ingest of multiple local disks on the same drive letter. * We need to clear the cache to make sure cached data from the first drive * is not used. * * @param imageFiles the paths to the images + * @param sSize the sector size (use '0' for autodetect) * @param useCache true if the image handle cache should be used, false to * always go to TSK to open a fresh copy * @@ -508,7 +564,7 @@ public static long openImage(String[] imageFiles) throws TskCoreException { * @throws TskCoreException exception thrown if critical error occurs within * TSK */ - private static long openImage(String[] imageFiles, boolean useCache) throws TskCoreException { + private static long openImage(String[] imageFiles, int sSize, boolean useCache) throws TskCoreException { long imageHandle; @@ -531,7 +587,7 @@ private static long openImage(String[] imageFiles, boolean useCache) throws TskC imageHandle = HandleCache.imageHandleCache.get(imageKey); } else { //open new handle and cache it - imageHandle = openImgNat(imageFiles, imageFiles.length); + imageHandle = openImgNat(imageFiles, imageFiles.length, sSize); HandleCache.fsHandleCache.put(imageHandle, new HashMap<Long, Long>()); HandleCache.imageHandleCache.put(imageKey, imageHandle); } @@ -1206,7 +1262,7 @@ public static boolean isImageSupported(String imagePath) { private static native long commitAddImgNat(long process) throws TskCoreException; - private static native long openImgNat(String[] imgPath, int splits) throws TskCoreException; + private static native long openImgNat(String[] imgPath, int splits, int sSize) throws TskCoreException; private static native long openVsNat(long imgHandle, long vsOffset) throws TskCoreException;