aboutsummaryrefslogtreecommitdiffstats
path: root/find_java
diff options
context:
space:
mode:
authorDavid Herman <davidherman@google.com>2014-10-15 09:03:35 -0700
committerDavid Herman <davidherman@google.com>2014-10-17 14:29:53 -0700
commit127af49b6548e0a20cb02fa8ce86c90d1da7f875 (patch)
treea20b324633bd7b5ac4c3a4ceadc09b1ef408a357 /find_java
parent411ca610db2c1b2e4ba677819c38b39c41bc9979 (diff)
downloadplatform_sdk-127af49b6548e0a20cb02fa8ce86c90d1da7f875.tar.gz
platform_sdk-127af49b6548e0a20cb02fa8ce86c90d1da7f875.tar.bz2
platform_sdk-127af49b6548e0a20cb02fa8ce86c90d1da7f875.zip
find_java now supports 64-bit builds
Change-Id: I46f2462f396c7c2f40238b7da438189b9de02a15
Diffstat (limited to 'find_java')
-rwxr-xr-xfind_java/find_java.sln18
-rw-r--r--find_java/find_java_exe.vcxproj66
-rw-r--r--find_java/find_java_lib.vcxproj52
-rw-r--r--find_java/src/source/find_java_exe.cpp5
-rwxr-xr-xfind_java/src/source/find_java_lib.cpp80
-rwxr-xr-xfind_java/src/source/utils.h30
6 files changed, 174 insertions, 77 deletions
diff --git a/find_java/find_java.sln b/find_java/find_java.sln
index 2242d9533..510ab9bbc 100755
--- a/find_java/find_java.sln
+++ b/find_java/find_java.sln
@@ -12,25 +12,43 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
+ Debug|Win64 = Debug|Win64
Release|Win32 = Release|Win32
+ Release|Win64 = Release|Win64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D194C98B-3FA4-4DAB-908A-16C03C15EC35}.Debug|Win32.ActiveCfg = Debug|Win32
{D194C98B-3FA4-4DAB-908A-16C03C15EC35}.Debug|Win32.Build.0 = Debug|Win32
+ {D194C98B-3FA4-4DAB-908A-16C03C15EC35}.Debug|Win64.ActiveCfg = Debug|x64
+ {D194C98B-3FA4-4DAB-908A-16C03C15EC35}.Debug|Win64.Build.0 = Debug|x64
{D194C98B-3FA4-4DAB-908A-16C03C15EC35}.Release|Win32.ActiveCfg = Release|Win32
{D194C98B-3FA4-4DAB-908A-16C03C15EC35}.Release|Win32.Build.0 = Release|Win32
+ {D194C98B-3FA4-4DAB-908A-16C03C15EC35}.Release|Win64.ActiveCfg = Release|x64
+ {D194C98B-3FA4-4DAB-908A-16C03C15EC35}.Release|Win64.Build.0 = Release|x64
{F116176E-AE3E-42E6-9249-663F49FAAFAE}.Debug|Win32.ActiveCfg = Debug|Win32
{F116176E-AE3E-42E6-9249-663F49FAAFAE}.Debug|Win32.Build.0 = Debug|Win32
+ {F116176E-AE3E-42E6-9249-663F49FAAFAE}.Debug|Win64.ActiveCfg = Debug|x64
+ {F116176E-AE3E-42E6-9249-663F49FAAFAE}.Debug|Win64.Build.0 = Debug|x64
{F116176E-AE3E-42E6-9249-663F49FAAFAE}.Release|Win32.ActiveCfg = Release|Win32
{F116176E-AE3E-42E6-9249-663F49FAAFAE}.Release|Win32.Build.0 = Release|Win32
+ {F116176E-AE3E-42E6-9249-663F49FAAFAE}.Release|Win64.ActiveCfg = Release|x64
+ {F116176E-AE3E-42E6-9249-663F49FAAFAE}.Release|Win64.Build.0 = Release|x64
{42701EC1-6226-47FD-8817-57A3DEC7A1E2}.Debug|Win32.ActiveCfg = Debug|Win32
{42701EC1-6226-47FD-8817-57A3DEC7A1E2}.Debug|Win32.Build.0 = Debug|Win32
+ {42701EC1-6226-47FD-8817-57A3DEC7A1E2}.Debug|Win64.ActiveCfg = Debug|x64
+ {42701EC1-6226-47FD-8817-57A3DEC7A1E2}.Debug|Win64.Build.0 = Debug|x64
{42701EC1-6226-47FD-8817-57A3DEC7A1E2}.Release|Win32.ActiveCfg = Release|Win32
{42701EC1-6226-47FD-8817-57A3DEC7A1E2}.Release|Win32.Build.0 = Release|Win32
+ {42701EC1-6226-47FD-8817-57A3DEC7A1E2}.Release|Win64.ActiveCfg = Release|x64
+ {42701EC1-6226-47FD-8817-57A3DEC7A1E2}.Release|Win64.Build.0 = Release|x64
{331EADA4-DC19-429D-AAD0-5B9632B4CBC1}.Debug|Win32.ActiveCfg = Debug|Win32
{331EADA4-DC19-429D-AAD0-5B9632B4CBC1}.Debug|Win32.Build.0 = Debug|Win32
+ {331EADA4-DC19-429D-AAD0-5B9632B4CBC1}.Debug|Win64.ActiveCfg = Debug|x64
+ {331EADA4-DC19-429D-AAD0-5B9632B4CBC1}.Debug|Win64.Build.0 = Debug|x64
{331EADA4-DC19-429D-AAD0-5B9632B4CBC1}.Release|Win32.ActiveCfg = Release|Win32
{331EADA4-DC19-429D-AAD0-5B9632B4CBC1}.Release|Win32.Build.0 = Release|Win32
+ {331EADA4-DC19-429D-AAD0-5B9632B4CBC1}.Release|Win64.ActiveCfg = Release|x64
+ {331EADA4-DC19-429D-AAD0-5B9632B4CBC1}.Release|Win64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/find_java/find_java_exe.vcxproj b/find_java/find_java_exe.vcxproj
index 1812ffbd1..215a9788b 100644
--- a/find_java/find_java_exe.vcxproj
+++ b/find_java/find_java_exe.vcxproj
@@ -5,10 +5,18 @@
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>FindJavaExe</ProjectName>
@@ -22,28 +30,51 @@
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)..\..\out\host\windows-x86\$(Configuration)\$(ProjectName)\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)..\..\out\host\windows-x64\$(Configuration)\$(ProjectName)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)..\..\out\host\windows-x86\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)..\..\out\host\windows-x64\$(Configuration)\$(ProjectName)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)..\..\out\host\windows-x86\$(Configuration)\$(ProjectName)\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)..\..\out\host\windows-x64\$(Configuration)\$(ProjectName)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)..\..\out\host\windows-x86\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)..\..\out\host\windows-x64\$(Configuration)\$(ProjectName)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectName)64</TargetName>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectName)64</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -63,6 +94,22 @@
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ </Link>
+ </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
@@ -83,6 +130,25 @@
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ </Link>
+ </ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\source\find_java_exe.cpp" />
<ClCompile Include="src\source\find_java_lib.cpp" />
diff --git a/find_java/find_java_lib.vcxproj b/find_java/find_java_lib.vcxproj
index cff70beef..7ca34990f 100644
--- a/find_java/find_java_lib.vcxproj
+++ b/find_java/find_java_lib.vcxproj
@@ -5,10 +5,18 @@
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>FindJavaLib</ProjectName>
@@ -22,26 +30,45 @@
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)..\..\out\host\windows-x86\$(Configuration)\$(ProjectName)\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)..\..\out\host\windows-x64\$(Configuration)\$(ProjectName)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)..\..\out\host\windows-x86\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)..\..\out\host\windows-x64\$(Configuration)\$(ProjectName)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)..\..\out\host\windows-x86\$(Configuration)\$(ProjectName)\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)..\..\out\host\windows-x64\$(Configuration)\$(ProjectName)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)..\..\out\host\windows-x86\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)..\..\out\host\windows-x64\$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -56,6 +83,18 @@
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
</ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
@@ -69,6 +108,19 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
</ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ </ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\source\find_java_lib.cpp" />
<ClCompile Include="src\source\utils.cpp" />
diff --git a/find_java/src/source/find_java_exe.cpp b/find_java/src/source/find_java_exe.cpp
index 6b1add9f5..fa5746ab5 100644
--- a/find_java/src/source/find_java_exe.cpp
+++ b/find_java/src/source/find_java_exe.cpp
@@ -117,15 +117,12 @@ int main(int argc, char* argv[]) {
_ASSERT(!javaPath.isEmpty());
if (doShortPath) {
- PVOID oldWow64Value = disableWow64FsRedirection();
if (!javaPath.toShortPath(&javaPath)) {
- revertWow64FsRedirection(&oldWow64Value);
fprintf(stderr,
"Failed to convert path to a short DOS path: %s\n",
javaPath.cstr());
return 1;
}
- revertWow64FsRedirection(&oldWow64Value);
}
if (doVersion) {
@@ -140,11 +137,9 @@ int main(int argc, char* argv[]) {
CPath javawPath(javaPath);
javawPath.replaceName("java.exe", "javaw.exe");
// Only accept it if we can actually find the exec
- PVOID oldWow64Value = disableWow64FsRedirection();
if (javawPath.fileExists()) {
javaPath.set(javawPath.cstr());
}
- revertWow64FsRedirection(&oldWow64Value);
}
// Print java.exe path found
diff --git a/find_java/src/source/find_java_lib.cpp b/find_java/src/source/find_java_lib.cpp
index f292171e2..95d0729ea 100755
--- a/find_java/src/source/find_java_lib.cpp
+++ b/find_java/src/source/find_java_lib.cpp
@@ -35,6 +35,17 @@
typedef LONG LSTATUS;
#endif
+// Check to see if the application is running in 32-bit or 64-bit mode. In other words, this will
+// return false if you run a 32-bit build even on a 64-bit machine.
+static bool isApplication64() {
+ SYSTEM_INFO sysInfo;
+ GetSystemInfo(&sysInfo);
+
+ // Note: The constant name here is a bit misleading, as it actually covers all 64-bit processors
+ // and not just AMD.
+ // See also: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724958(v=vs.85).aspx
+ return (sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64);
+}
// Extract the first thing that looks like (digit.digit+).
// Note: this will break when java reports a version with major > 9.
@@ -79,7 +90,6 @@ static int checkPath(CPath *inOutPath) {
inOutPath->addPath("java.exe");
int result = 0;
- PVOID oldWow64Value = disableWow64FsRedirection();
if (inOutPath->fileExists()) {
// Run java -version
// Reject the version if it's not at least our current minimum.
@@ -88,7 +98,6 @@ static int checkPath(CPath *inOutPath) {
}
}
- revertWow64FsRedirection(oldWow64Value);
return result;
}
@@ -305,44 +314,18 @@ static bool getMaxJavaInRegistry(const char *entry, REGSAM access, CPath *outJav
}
int findJavaInRegistry(CPath *outJavaPath) {
- // We'll do the registry test 3 times: first using the default mode,
- // then forcing the use of the 32-bit registry then forcing the use of
- // 64-bit registry. On Windows 2k, the 2 latter will fail since the
- // flags are not supported. On a 32-bit OS the 64-bit is obviously
- // useless and the 2 first tests should be equivalent so we just
- // need the first case.
-
// Check the JRE first, then the JDK.
int version = MIN_JAVA_VERSION - 1;
bool result = false;
result |= getMaxJavaInRegistry("Java Runtime Environment", 0, outJavaPath, &version);
result |= getMaxJavaInRegistry("Java Development Kit", 0, outJavaPath, &version);
- // Get the app sysinfo state (the one hidden by WOW64)
- SYSTEM_INFO sysInfo;
- GetSystemInfo(&sysInfo);
- WORD programArch = sysInfo.wProcessorArchitecture;
- // Check the real sysinfo state (not the one hidden by WOW64) for x86
- GetNativeSystemInfo(&sysInfo);
- WORD actualArch = sysInfo.wProcessorArchitecture;
-
- // Only try to access the WOW64-32 redirected keys on a 64-bit system.
- // There's no point in doing this on a 32-bit system.
- if (actualArch == PROCESSOR_ARCHITECTURE_AMD64) {
- if (programArch != PROCESSOR_ARCHITECTURE_INTEL) {
- // If we did the 32-bit case earlier, don't do it twice.
- result |= getMaxJavaInRegistry(
- "Java Runtime Environment", KEY_WOW64_32KEY, outJavaPath, &version);
- result |= getMaxJavaInRegistry(
- "Java Development Kit", KEY_WOW64_32KEY, outJavaPath, &version);
-
- } else if (programArch != PROCESSOR_ARCHITECTURE_AMD64) {
- // If we did the 64-bit case earlier, don't do it twice.
- result |= getMaxJavaInRegistry(
- "Java Runtime Environment", KEY_WOW64_64KEY, outJavaPath, &version);
- result |= getMaxJavaInRegistry(
- "Java Development Kit", KEY_WOW64_64KEY, outJavaPath, &version);
- }
+ // Even if we're 64-bit, try again but check the 32-bit registry, looking for 32-bit java.
+ if (isApplication64()) {
+ result |= getMaxJavaInRegistry(
+ "Java Runtime Environment", KEY_WOW64_32KEY, outJavaPath, &version);
+ result |= getMaxJavaInRegistry(
+ "Java Development Kit", KEY_WOW64_32KEY, outJavaPath, &version);
}
return result ? version : 0;
@@ -350,12 +333,13 @@ int findJavaInRegistry(CPath *outJavaPath) {
// --------------
-static bool checkProgramFiles(CPath *outJavaPath, int *inOutVersion) {
+static bool checkProgramFiles(CPath *outJavaPath, int *inOutVersion, bool force32bit) {
char programFilesPath[MAX_PATH + 1];
+ int nFolder = force32bit ? CSIDL_PROGRAM_FILESX86 : CSIDL_PROGRAM_FILES;
HRESULT result = SHGetFolderPathA(
NULL, // hwndOwner
- CSIDL_PROGRAM_FILES, // nFolder
+ nFolder,
NULL, // hToken
SHGFP_TYPE_CURRENT, // dwFlags
programFilesPath); // pszPath
@@ -364,7 +348,7 @@ static bool checkProgramFiles(CPath *outJavaPath, int *inOutVersion) {
CPath path(programFilesPath);
path.addPath("Java");
- // Do we have a C:\\Program Files\\Java directory?
+ // Do we have a C:\Program Files\Java directory?
if (!path.dirExists()) return false;
CPath glob(path);
@@ -378,7 +362,7 @@ static bool checkProgramFiles(CPath *outJavaPath, int *inOutVersion) {
if ((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) {
CPath temp(path);
temp.addPath(findData.cFileName);
- // Check C:\\Program Files[x86]\\Java\\j*\\bin\\java.exe
+ // Check C:\Program Files\Java\j*\bin\java.exe
int v = checkBinPath(&temp);
if (v > *inOutVersion) {
found = true;
@@ -394,23 +378,15 @@ static bool checkProgramFiles(CPath *outJavaPath, int *inOutVersion) {
int findJavaInProgramFiles(CPath *outJavaPath) {
- // Check the C:\\Program Files (x86) directory
- // With WOW64 fs redirection in place by default, we should get the x86
- // version on a 64-bit OS since this app is a 32-bit itself.
+ // Check the C:\Program Files directory
bool result = false;
int version = MIN_JAVA_VERSION - 1;
- result |= checkProgramFiles(outJavaPath, &version);
+ result |= checkProgramFiles(outJavaPath, &version, false);
- // Check the real sysinfo state (not the one hidden by WOW64) for x86
- SYSTEM_INFO sysInfo;
- GetNativeSystemInfo(&sysInfo);
-
- if (sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
- // On a 64-bit OS, try again by disabling the fs redirection so
- // that we can try the real C:\\Program Files directory.
- PVOID oldWow64Value = disableWow64FsRedirection();
- result |= checkProgramFiles(outJavaPath, &version);
- revertWow64FsRedirection(oldWow64Value);
+ // Even if we're 64-bit, try again but check the C:\Program Files (x86) directory, looking for
+ // 32-bit java.
+ if (isApplication64()) {
+ result |= checkProgramFiles(outJavaPath, &version, true);
}
return result ? version : 0;
diff --git a/find_java/src/source/utils.h b/find_java/src/source/utils.h
index dc9031dbe..a65e6fe50 100755
--- a/find_java/src/source/utils.h
+++ b/find_java/src/source/utils.h
@@ -73,7 +73,7 @@ public:
CString() { mStr = NULL; }
CString(const CString &str) { mStr = NULL; set(str.mStr); }
explicit CString(const char *str) { mStr = NULL; set(str); }
- CString(const char *start, int length) { mStr = NULL; set(start, length); }
+ CString(const char *start, size_t length) { mStr = NULL; set(start, length); }
CString& operator=(const CString &str) {
return set(str.cstr());
@@ -89,7 +89,7 @@ public:
return *this;
}
- CString& set(const char *start, int length) {
+ CString& set(const char *start, size_t length) {
_free();
if (start != NULL) {
mStr = (char *)malloc(length + 1);
@@ -103,7 +103,7 @@ public:
_free();
// _vscprintf(str, ap) is only available with the MSVCRT, not MinGW.
// Instead we'll iterate till we have enough space to generate the string.
- int len = strlen(str) + 1024;
+ size_t len = strlen(str) + 1024;
mStr = (char *)malloc(len);
strcpy(mStr, str); // provide a default in case vsnprintf totally fails
for (int guard = 0; guard < 10; guard++) {
@@ -145,7 +145,7 @@ public:
return mStr == NULL || *mStr == 0;
}
- int length() const {
+ size_t length() const {
return mStr == NULL ? 0 : strlen(mStr);
}
@@ -163,7 +163,7 @@ public:
if (mStr == NULL) {
set(str, length);
} else {
- int l1 = strlen(mStr);
+ size_t l1 = strlen(mStr);
mStr = (char *)realloc((void *)mStr, l1 + length + 1);
strncpy(mStr + l1, str, length);
mStr[l1 + length] = 0;
@@ -256,7 +256,7 @@ public:
CPath& addPath(const char *s) {
_ASSERT(s != NULL);
if (s != NULL && s[0] != 0) {
- int n = length();
+ size_t n = length();
if (n > 0 && s[0] != '\\' && mStr[n-1] != '\\') add("\\");
add(s);
}
@@ -308,12 +308,12 @@ public:
// If the path ends with the given searchName, replace in-place by the new name
void replaceName(const char *searchName, const char* newName) {
if (mStr == NULL) return;
- int n = length();
- int sn = strlen(searchName);
+ size_t n = length();
+ size_t sn = strlen(searchName);
if (n < sn) return;
// if mStr ends with searchName
if (strcmp(mStr + n - sn, searchName) == 0) {
- int sn2 = strlen(newName);
+ size_t sn2 = strlen(newName);
if (sn2 > sn) {
mStr = (char *)realloc((void *)mStr, n + sn2 - sn + 1);
}
@@ -330,7 +330,7 @@ public:
const char *longPath = mStr;
if (mStr == NULL) return false;
- DWORD lenShort = strlen(longPath) + 1;
+ DWORD lenShort = (DWORD)strlen(longPath) + 1; // GetShortPathName deals with DWORDs
char * shortPath = (char *)malloc(lenShort);
DWORD length = GetShortPathName(longPath, shortPath, lenShort);
@@ -366,15 +366,5 @@ int execWait(const char *cmd);
bool getModuleDir(CPath *outDir);
-// Disables the FS redirection done by WOW64.
-// Because this runs as a 32-bit app, Windows automagically remaps some
-// folder under the hood (e.g. "Programs Files(x86)" is mapped as "Program Files").
-// This prevents the app from correctly searching for java.exe in these folders.
-// The registry is also remapped.
-PVOID disableWow64FsRedirection();
-
-// Reverts the redirection disabled in disableWow64FsRedirection.
-void revertWow64FsRedirection(PVOID oldWow64Value);
-
#endif /* _WIN32 */
#endif /* _H_UTILS */