diff --git a/Core/src/org/sleuthkit/autopsy/core/Installer.java b/Core/src/org/sleuthkit/autopsy/core/Installer.java index ba4a553fab15c234253f186e56279ac8c98b8ac9..1839c9b8ab4cef6865264cec560685c4d0612137 100644 --- a/Core/src/org/sleuthkit/autopsy/core/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/core/Installer.java @@ -69,7 +69,7 @@ private static void loadDynLibraries() { logger.log(Level.INFO, "MSVCR100 and MSVCP100 libraries loaded"); //NON-NLS } catch (UnsatisfiedLinkError e) { - logger.log(Level.SEVERE, "Error loading MSVCR100 and MSVCP100 libraries, ", e); //NON-NLS + logger.log(Level.WARNING, "Error loading MSVCR100 and MSVCP100 libraries"); //NON-NLS } try { diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/PlatformUtil.java b/Core/src/org/sleuthkit/autopsy/coreutils/PlatformUtil.java index c0cc04033539e2c623768fa4277c644a315b80ac..b68fa51a2af2f4952e0175c31a289314e1ce4a6f 100644 --- a/Core/src/org/sleuthkit/autopsy/coreutils/PlatformUtil.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/PlatformUtil.java @@ -201,14 +201,9 @@ public static String getLogDirectory() { * @return Lib path string */ public static String getLibsPath() { - System.out.println(PlatformUtil.getInstallPath()); - System.out.println(PlatformUtil.getInstallModulesPath()); - System.out.println(PlatformUtil.getLogDirectory()); - System.out.println(PlatformUtil.getUserModulesPath()); - System.out.println(PlatformUtil.getUserDirectory()); - File coreFolder = InstalledFileLocator.getDefault().locate("core", PlatformUtil.class.getPackage().getName(), false); //NON-NLS - File rootPath = coreFolder.getParentFile().getParentFile(); - return new File(".").getAbsolutePath() + ".\\build\\cluster\\modules\\lib\\" + getOSArch() + "\\"; + // locate uses "/" regardless of format + File libFolder = InstalledFileLocator.getDefault().locate("modules/lib/" + getOSArch(), PlatformUtil.class.getPackage().getName(), false); //NON-NLS + return libFolder.getAbsolutePath(); } public static String getDefaultPlatformFileEncoding() { @@ -292,8 +287,13 @@ public static String getOSArch() { return arch.endsWith("64") ? "x86_64" : "x86"; //NON-NLS } + /** + * load library from library path (hardcoded .dll for now). + * + * @param libName name of library to be loaded + */ public static void loadLibrary(String libName) { - String path = getLibsPath(); + String path = getLibsPath() + File.separator; String ext = ".dll"; System.load(path + libName + ext); } diff --git a/CoreLibs/nbproject/project.xml b/CoreLibs/nbproject/project.xml index bc106e6d83ed9dee26b162e1c5512c49d009080f..646e0f74e7bbd1a62f6b7d6c1128f73351888175 100644 --- a/CoreLibs/nbproject/project.xml +++ b/CoreLibs/nbproject/project.xml @@ -6,6 +6,14 @@ <code-name-base>org.sleuthkit.autopsy.corelibs</code-name-base> <suite-component/> <module-dependencies> + <dependency> + <code-name-base>org.openide.modules</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>7.43.1</specification-version> + </run-dependency> + </dependency> <dependency> <code-name-base>org.openide.util</code-name-base> <build-prerequisite/> diff --git a/CoreLibs/src/org/sleuthkit/autopsy/corelibs/Bundle.properties b/CoreLibs/src/org/sleuthkit/autopsy/corelibs/Bundle.properties index 6c4bc4b0d3ee29b053f933773543a913e8afa194..6d8f9da0cde99f0ea0a0c34664f03017f2147f3e 100644 --- a/CoreLibs/src/org/sleuthkit/autopsy/corelibs/Bundle.properties +++ b/CoreLibs/src/org/sleuthkit/autopsy/corelibs/Bundle.properties @@ -5,3 +5,4 @@ OpenIDE-Module-Long-Description=\ OpenIDE-Module-Name=Autopsy-CoreLibs OpenIDE-Module-Short-Description=Autopsy Core module external libraries SigarLoader.linkErr.msg=Could not load sigar library for your environment (non-critical), OS-level metrics will be unavailable. +ScalpelCarver.archUnknown=unknown diff --git a/CoreLibs/src/org/sleuthkit/autopsy/corelibs/LibsPathUtil.java b/CoreLibs/src/org/sleuthkit/autopsy/corelibs/LibsPathUtil.java new file mode 100755 index 0000000000000000000000000000000000000000..abe3cc4659300b9fce6bb8db230808e948bda19a --- /dev/null +++ b/CoreLibs/src/org/sleuthkit/autopsy/corelibs/LibsPathUtil.java @@ -0,0 +1,70 @@ + /* + * + * Autopsy Forensic Browser + * + * Copyright 2012-15 Basis Technology Corp. + * + * Copyright 2012 42six Solutions. + * Contact: aebadirad <at> 42six <dot> com + * Project Contact/Architect: carrier <at> sleuthkit <dot> org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.sleuthkit.autopsy.corelibs; + + +import java.io.File; +import org.openide.modules.InstalledFileLocator; +import org.openide.util.NbBundle; + +class LibsPathUtil { + + public static final String OS_ARCH_UNKNOWN = NbBundle.getMessage(LibsPathUtil.class, "LibsPathUtil.archUnknown"); + + private LibsPathUtil() {} + + /** + * load library from library path (hardcoded .dll for now). + * + * @param libName name of library to be loaded + */ + public static void loadLibrary(String libName) { + String path = getLibsPath() + File.separator; + String ext = ".dll"; + System.load(path + libName + ext); + } + + /** + * Gets the absolute path to the lib folder + * + * @return Lib path string + */ + public static String getLibsPath() { + // locate uses "/" regardless of format + File libFolder = InstalledFileLocator.getDefault().locate("modules/lib/" + getOSArch(), LibsPathUtil.class.getPackage().getName(), false); //NON-NLS + return libFolder.getAbsolutePath(); + } + + /** + * Get OS arch details, or OS_ARCH_UNKNOWN + * + * @return OS arch string + */ + public static String getOSArch() { + String arch = System.getProperty("os.arch"); //NON-NLS + if(arch == null) + return OS_ARCH_UNKNOWN; + else + return arch.endsWith("64") ? "x86_64" : "x86"; //NON-NLS + } +} diff --git a/CoreLibs/src/org/sleuthkit/autopsy/corelibs/SigarLoader.java b/CoreLibs/src/org/sleuthkit/autopsy/corelibs/SigarLoader.java index 12a135c6e18232430c839f44a590c371b3864584..546ba2aa9f6098531222b47223b90301f95a7afc 100644 --- a/CoreLibs/src/org/sleuthkit/autopsy/corelibs/SigarLoader.java +++ b/CoreLibs/src/org/sleuthkit/autopsy/corelibs/SigarLoader.java @@ -44,9 +44,9 @@ public static Sigar getSigar() { try { //rely on netbeans / jna to locate the lib variation for architecture/OS if (PlatformUtil.isWindows()) { - System.loadLibrary("libsigar"); //NON-NLS + LibsPathUtil.loadLibrary("libsigar"); //NON-NLS } else { - System.loadLibrary("sigar"); //NON-NLS + LibsPathUtil.loadLibrary("sigar"); //NON-NLS } sigar = new Sigar(); sigar.enableLogging(false); //forces a test diff --git a/ScalpelCarver/nbproject/project.xml b/ScalpelCarver/nbproject/project.xml index 866c390d453453f2b8663d3f45af701b6262861d..c13362f08f2992e9cde8d0164423e02427a94a8a 100644 --- a/ScalpelCarver/nbproject/project.xml +++ b/ScalpelCarver/nbproject/project.xml @@ -6,6 +6,14 @@ <code-name-base>org.sleuthkit.autopsy.scalpel</code-name-base> <standalone/> <module-dependencies> + <dependency> + <code-name-base>org.openide.modules</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>7.43.1</specification-version> + </run-dependency> + </dependency> <dependency> <code-name-base>org.openide.util</code-name-base> <build-prerequisite/> diff --git a/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/jni/Bundle.properties b/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/jni/Bundle.properties index 846b5613c86daf2f439cc13b8192c4a33ddbc368..19aa7e440a0909f3fa7ed90bbfd2181c18c63553 100644 --- a/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/jni/Bundle.properties +++ b/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/jni/Bundle.properties @@ -5,4 +5,5 @@ ScalpelCarver.carve.exception.invalidArgs=Invalid arguments for scalpel carving. ScalpelCarver.carve.exception.cannotReadConfig=Cannot read libscalpel config file\: {0} ScalpelCarver.carve.exception.cannotWriteConfig=Cannot write to libscalpel output dir\: {0} ScalpelOutputParser.outputStart.text=The following files were carved\: -ScalpelOutputParser.toString.text=CarvedFileMeta'{'fileName\={0}, start\: {1}, size\: {2}'}' \ No newline at end of file +ScalpelOutputParser.toString.text=CarvedFileMeta'{'fileName\={0}, start\: {1}, size\: {2}'}' +LibsPathUtil.archUnknown=unknown \ No newline at end of file diff --git a/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/jni/ScalpelCarver.java b/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/jni/ScalpelCarver.java index e93803dd0c0a6d0b49b58c7f87f56f38b4a90b40..4efad2010ee04e3a7d96822fcee42c85ed102c42 100644 --- a/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/jni/ScalpelCarver.java +++ b/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/jni/ScalpelCarver.java @@ -27,6 +27,7 @@ import java.util.logging.Level; import org.openide.util.NbBundle; +import org.openide.modules.InstalledFileLocator; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.scalpel.jni.ScalpelOutputParser.CarvedFileMeta; import org.sleuthkit.datamodel.AbstractFile; @@ -75,7 +76,7 @@ private static boolean loadLib(String id) { boolean success = false; try { //rely on netbeans / jna to locate the lib variation for architecture/OS - System.loadLibrary(id); + loadLibrary(id); success = true; } catch (UnsatisfiedLinkError ex) { String msg = NbBundle.getMessage(ScalpelCarver.class, "ScalpelCarver.loadLib.errMsg.cannotLoadLib", id); @@ -89,6 +90,41 @@ private static boolean loadLib(String id) { return success; } + + /** + * load library from library path (hardcoded .dll for now). + * + * @param libName name of library to be loaded + */ + private static void loadLibrary(String libName) { + String path = getLibsPath() + File.separator; + String ext = ".dll"; + System.load(path + libName + ext); + } + + /** + * Gets the absolute path to the lib folder + * + * @return Lib path string + */ + public static String getLibsPath() { + // locate uses "/" regardless of format + File libFolder = InstalledFileLocator.getDefault().locate("modules/lib/" + getOSArch(), ScalpelCarver.class.getPackage().getName(), false); //NON-NLS + return libFolder.getAbsolutePath(); + } + + /** + * Get OS arch details, or OS_ARCH_UNKNOWN + * + * @return OS arch string + */ + private static String getOSArch() { + String arch = System.getProperty("os.arch"); //NON-NLS + if(arch == null) + return NbBundle.getMessage(ScalpelCarver.class, "ScalpelCarver.archUnknown"); + else + return arch.endsWith("64") ? "x86_64" : "x86"; //NON-NLS + } /**