Migrated limewireExe to i2pExe

This commit is contained in:
str4d
2013-04-03 01:52:14 +00:00
parent b65898e0dd
commit 51f072cc72
16 changed files with 47 additions and 53 deletions

112
installer/c/i2pExe/I2P.rc Normal file
View File

@@ -0,0 +1,112 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource1.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,9,5,1
PRODUCTVERSION 0,9,5,1
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "Anonymity for the masses"
VALUE "CompanyName", "The I2P Project"
VALUE "FileDescription", "I2P"
VALUE "FileVersion", "0, 9, 5, 1"
VALUE "InternalName", "I2P"
VALUE "LegalCopyright", "Public Domain"
VALUE "OriginalFilename", "I2P.exe"
VALUE "ProductName", " I2P"
VALUE "ProductVersion", "0, 9, 5, 1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON "start.ico"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,22 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "I2P", "I2P.vcproj", "{0A74F3D1-C70A-4CF0-9390-C676025ED12F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
Release-alpha|Win32 = Release-alpha|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0A74F3D1-C70A-4CF0-9390-C676025ED12F}.Debug|Win32.ActiveCfg = Debug|Win32
{0A74F3D1-C70A-4CF0-9390-C676025ED12F}.Debug|Win32.Build.0 = Debug|Win32
{0A74F3D1-C70A-4CF0-9390-C676025ED12F}.Release|Win32.ActiveCfg = Release|Win32
{0A74F3D1-C70A-4CF0-9390-C676025ED12F}.Release|Win32.Build.0 = Release|Win32
{0A74F3D1-C70A-4CF0-9390-C676025ED12F}.Release-alpha|Win32.ActiveCfg = Release-alpha|Win32
{0A74F3D1-C70A-4CF0-9390-C676025ED12F}.Release-alpha|Win32.Build.0 = Release-alpha|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

BIN
installer/c/i2pExe/I2P.suo Normal file

Binary file not shown.

View File

@@ -0,0 +1,327 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="I2P"
ProjectGUID="{0A74F3D1-C70A-4CF0-9390-C676025ED12F}"
RootNamespace="I2P"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;C:\Program Files\Java\jdk1.6.0\include\win32&quot;;&quot;C:\Program Files\Java\jdk1.6.0\include&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="Shlwapi.lib"
OutputFile="$(OutDir)/I2P.exe"
LinkIncremental="2"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/I2P.pdb"
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
AdditionalManifestFiles="I2P.exe.manifest"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="0"
AdditionalIncludeDirectories="&quot;C:\Program Files\Java\jdk1.6.0_13\include&quot;;&quot;C:\Program Files\Java\jdk1.6.0_13\include\win32&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="shlwapi.lib"
OutputFile="$(OutDir)/I2P.exe"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release-alpha|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D&quot;ALPHA&quot;"
Optimization="2"
InlineFunctionExpansion="0"
AdditionalIncludeDirectories="&quot;C:\Program Files\Java\jdk1.6.0\include&quot;;&quot;C:\Program Files\Java\jdk1.6.0\include\win32&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="shlwapi.lib"
OutputFile="$(OutDir)/I2P.exe"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\i2p.c"
>
</File>
<File
RelativePath=".\java.c"
>
</File>
<File
RelativePath=".\java_md.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\errors.h"
>
</File>
<File
RelativePath=".\java.h"
>
</File>
<File
RelativePath=".\java_md.h"
>
</File>
<File
RelativePath=".\jni.h"
>
</File>
<File
RelativePath=".\jni_md.h"
>
</File>
<File
RelativePath=".\resource.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\I2P.rc"
>
</File>
<File
RelativePath="..\..\resources\start.ico"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,11 @@
#ifndef _I2P_ERRORS_H
#define _I2P_ERRORS_h
#define ERROR_COULDNT_LOAD_JVM 6
#define ERROR_COULDNT_PARSE_ARGUMENTS 7
#define ERROR_COULDNT_INITIALIZE_JVM 8
#define ERROR_STARTING_PROGRAM 9
#define ERROR_COULDNT_FIND_JVM 10
#endif /* _I2P_ERRORS_H */

234
installer/c/i2pExe/i2p.c Normal file
View File

@@ -0,0 +1,234 @@
/**
* Customized I2P launcher.
* Launches the JRE within the process, to allow Task Manager to show
* "I2P.exe" as the process, and firewalls to control access of
* "I2P.exe".
*/
#include "errors.h"
#include <windows.h>
#include <stdio.h>
#include <malloc.h>
#include <sys/stat.h>
//BOOL MoveFontPropertiesFile(const char *path);
void SetWorkingDirectory(char *path);
void readOptions(char***, int*);
//BOOL localJREExists(const char*);
BOOL exist(const char*);
// defined in java.c
extern void* MemAlloc(size_t);
// defined in java.c
extern int launchJVM(int, char**);
int
main(int argc, char** argv) {
int read_options_size;
char** read_options;
int ret = 0;
int current_argc = 0;
int new_argc;
char** new_argv;
int i;
char currentDirectory[MAX_PATH+1];
// Set/get the correct working directory.
SetWorkingDirectory(currentDirectory);
// Read in options from disk (launch.properties)
// or the default ones (if no launch.properties existed)
readOptions(&read_options, &read_options_size);
// Construct a new argc & argv to pass to launchJVM
new_argc = read_options_size + argc;
new_argv = (char**)MemAlloc(sizeof(char*) * (new_argc+1));
// copy process name
new_argv[0] = argv[0];
// copy arguments from properties file
for(i = 1; i <= read_options_size; i++)
new_argv[i] = read_options[i-1];
// copy argv arguments as arguments after the properties file
// (generally used as arguments for I2P)
for(current_argc = 1; current_argc < argc; current_argc++)
new_argv[i++] = argv[current_argc];
new_argv[i] = NULL;
// options are no longer necessary -- free them up.
if(read_options != 0)
free(read_options);
ret = launchJVM(new_argc, new_argv);
free(new_argv);
switch(ret) {
case ERROR_COULDNT_FIND_JVM:
case ERROR_COULDNT_INITIALIZE_JVM:
case ERROR_COULDNT_LOAD_JVM:
if (MessageBox(NULL, "I2P needs the Java Runtime Environment 5.0 or above. Click OK to go to www.java.com, where you can install Java.",
"I2P Launcher Error",
MB_ICONWARNING | MB_OKCANCEL) == IDOK)
ShellExecute(NULL, NULL, "http://www.java.com/", "", "", SW_SHOWNORMAL);
break;
case ERROR_COULDNT_PARSE_ARGUMENTS:
MessageBox(NULL, "I2P failed to parse the commandline arguments to Java.\n"
"Please download and install I2P again.",
"I2P Launcher Error", MB_OK);
break;
case ERROR_STARTING_PROGRAM:
MessageBox(NULL, "I2P was unable to load.\n"
"Please download and install I2P again.",
"I2P Launcher Error", MB_OK);
break;
}
return ret;
}
#define MAX_OPTION_SIZE 100
#define MAX_OPTIONS 100
/**
* Read in the launch.properties file and generate psuedo-commandline arguments.
*/
void readOptions(char*** options, int* size) {
FILE* file;
char* buffer;
int i;
size_t currentlen;
char* command;
file = fopen("launch.properties", "r");
if(file == NULL) {
// default to certain values.
*size = 10;
#ifdef ALPHA
*size = (*size) + 1;
#endif
*options = (char**)MemAlloc(sizeof(char*) * (*size));
i = 0;
(*options)[i++] = "-Xms64m";
(*options)[i++] = "-Xmx256m";
(*options)[i++] = "-Dasdf=fdsa";
(*options)[i++] = "-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog";
//(*options)[i++] = "-Djava.net.preferIPv6Addresses=false";
(*options)[i++] = "-Djava.net.preferIPv4Stack=true";
(*options)[i++] = "-ea:com.limegroup...";
(*options)[i++] = "-ea:org.limewire...";
(*options)[i++] = "-Djava.library.path=lib";
(*options)[i++] = "-jar";
(*options)[i++] = "lib\\MuWire.jar";
#ifdef ALPHA
#pragma message ("\n\n!!!!!!!!!!!!!! building ALPHA !!!!!!!!!!!!!!\n\n")
(*options)[(*size) - 3] = "-agentlib:yjpagent=port=11111";
(*options)[(*size) - 2] = "-jar";
(*options)[(*size) - 1] = "I2P.jar";
#endif
return;
}
*options = (char**)MemAlloc(sizeof(char*) * MAX_OPTIONS);
*size = 0;
for(i = 0; i < MAX_OPTIONS && !feof(file); i++) {
buffer = (char*)MemAlloc(sizeof(char) * MAX_OPTION_SIZE);
// get the next option.
if(fgets(buffer, MAX_OPTION_SIZE - 1, file) == NULL)
break;
// strip off the \n if it exists.
currentlen = strlen(buffer);
if(currentlen > 0 && buffer[currentlen-1] == '\n') {
buffer[currentlen-1] = 0;
currentlen--;
}
// downsize the storage for the command.
currentlen++; // (include \0)
command = (char*)MemAlloc(sizeof(char) * currentlen);
strcpy(command, buffer);
free(buffer);
// set the option & increase the size
if(currentlen > 0) {
(*options)[i] = command;
(*size)++;
}
}
if(file != NULL)
fclose(file);
}
/*
* Sets the current working directory to wherever I2P.exe is located
*/
static void
SetWorkingDirectory(char *path) {
GetModuleFileName(NULL, path, MAX_PATH + 1);
*strrchr(path, '\\') = '\0'; // remove the .exe
SetCurrentDirectory(path);
GetCurrentDirectory(MAX_PATH + 1, path);
}
/**
* Checks to see if an app-installed JRE exists.
*/
/*
BOOL localJREExists(const char* path) {
char localBuf[MAX_PATH + 1];
sprintf(localBuf, "%s\\jre\\bin\\hotspot\\jvm.dll\0", path);
return exist(localBuf);
}
*/
/**
* Copies the windows.font.properties file to the jre so that
* we use the proper fonts for international installs.
*/
/*
BOOL
MoveFontPropertiesFile(const char *path) {
char curFontFile[MAX_PATH + 1];
char newFontFile[MAX_PATH + 1];
BOOL copySucceeded;
sprintf(curFontFile, "%s\\windows.font.properties\0", path);
sprintf(newFontFile, "%s\\jre\\lib\\font.properties\0", path);
if(!exist(curFontFile))
return TRUE;
copySucceeded = CopyFile(curFontFile, newFontFile, FALSE);
if(copySucceeded)
DeleteFile(curFontFile);
return copySucceeded;
}
*/
BOOL exist(const char *filename) {
struct stat s;
return stat(filename, &s) == 0 ? TRUE : FALSE;
}
__declspec(dllimport) char **__initenv;
int WINAPI
WinMain(HINSTANCE inst, HINSTANCE previnst, LPSTR cmdline, int cmdshow)
{
int ret;
/* It turns out, that Windows can set thread locale to default user locale
* instead of default system locale. We correct this by explicitely setting
* thread locale to system default.
*/
SetThreadLocale(GetSystemDefaultLCID());
__initenv = _environ;
ret = main(__argc, __argv);
return ret;
}

1042
installer/c/i2pExe/java.c Normal file

File diff suppressed because it is too large Load Diff

76
installer/c/i2pExe/java.h Normal file
View File

@@ -0,0 +1,76 @@
/*
* @(#)java.h 1.23 04/04/24
*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/* Backported from Tiger (1.5) java.h 1.26 04/01/12 */
#ifndef _JAVA_H_
#define _JAVA_H_
/*
* Get system specific defines.
*/
#include "jni.h"
#include "java_md.h"
/*
* Pointers to the needed JNI invocation API, initialized by LoadJavaVM.
*/
typedef jint (JNICALL *CreateJavaVM_t)(JavaVM **pvm, void **env, void *args);
typedef jint (JNICALL *GetDefaultJavaVMInitArgs_t)(void *args);
typedef struct {
CreateJavaVM_t CreateJavaVM;
GetDefaultJavaVMInitArgs_t GetDefaultJavaVMInitArgs;
} InvocationFunctions;
/*
* Prototypes for launcher functions in the system specific java_md.c.
*/
jboolean
LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn);
jboolean
GetApplicationHome(char *buf, jint bufsize);
const char *
GetArch();
int CreateExecutionEnvironment(int *_argc,
char ***_argv,
char jrepath[],
jint so_jrepath,
char jvmpath[],
jint so_jvmpath,
char **original_argv);
/*
* Report an error message to stderr or a window as appropriate. The
* flag always is set to JNI_TRUE if message is to be reported to both
* strerr and windows and set to JNI_FALSE if the message should only
* be sent to a window.
*/
void ReportErrorMessage(char * message, jboolean always);
void ReportErrorMessage2(char * format, char * string, jboolean always);
/*
* Report an exception which terminates the vm to stderr or a window
* as appropriate.
*/
void ReportExceptionDescription(JNIEnv * env);
jboolean RemovableMachineDependentOption(char * option);
void PrintMachineDependentOptions();
/*
* Functions defined in java.c and used in java_md.c.
*/
jint ReadKnownVMs(const char *jrepath, char * arch, jboolean speculative);
char *CheckJvmType(int *argc, char ***argv, jboolean speculative);
void* MemAlloc(size_t size);
#endif /* _JAVA_H_ */

View File

@@ -0,0 +1,388 @@
/**
* Derived from the shared source for the 'java' commandline tool.
*/
/* Backported from Tiger (1.5) java_md.c 1.40 04/01/12 */
/* AMD64 support removed */
#include <windows.h>
#include <process.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "jni.h"
#include "java.h"
#define JVM_DLL "jvm.dll"
#define JAVA_DLL "java.dll"
/*
* Prototypes.
*/
static jboolean GetPublicJREHome(char *path, jint pathsize);
static jboolean GetJVMPath(const char *jrepath, const char *jvmtype,
char *jvmpath, jint jvmpathsize);
static jboolean GetJREPath(char *path, jint pathsize);
const char *
GetArch()
{
#ifdef _WIN64
return "ia64";
#else
return "i386";
#endif
}
/*
*
*/
int
CreateExecutionEnvironment(int *_argc,
char ***_argv,
char jrepath[],
jint so_jrepath,
char jvmpath[],
jint so_jvmpath,
char **original_argv) {
char * jvmtype;
/* Find out where the JRE is that we will be using. */
if (!GetJREPath(jrepath, so_jrepath)) {
ReportErrorMessage("Could not find a suitable Java 2 Runtime Environment.",
JNI_TRUE);
return 1;
}
/* Find the specified JVM type */
if (ReadKnownVMs(jrepath, (char*)GetArch(), JNI_FALSE) < 1) {
ReportErrorMessage("Error: no known VMs. (check for corrupt jvm.cfg file)",
JNI_TRUE);
return 1;
}
jvmtype = CheckJvmType(_argc, _argv, JNI_FALSE);
jvmpath[0] = '\0';
if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath)) {
char * message=NULL;
const char * format = "Error: no `%s' JVM at `%s'.";
message = (char *)MemAlloc((strlen(format)+strlen(jvmtype)+
strlen(jvmpath)) * sizeof(char));
sprintf(message,format, jvmtype, jvmpath);
ReportErrorMessage(message, JNI_TRUE);
return 1;
}
/* If we got here, jvmpath has been correctly initialized. */
return 0;
}
/*
* Find path to JRE based on .exe's location or registry settings.
*/
jboolean
GetJREPath(char *path, jint pathsize)
{
char javadll[MAXPATHLEN];
struct stat s;
//
// if (GetApplicationHome(path, pathsize)) {
// /* Is JRE co-located with the application? */
// sprintf(javadll, "%s\\bin\\" JAVA_DLL, path);
// if (stat(javadll, &s) == 0) {
// goto found;
// }
// /* Does this app ship a private JRE in <apphome>\jre directory? */
// sprintf(javadll, "%s\\jre\\bin\\" JAVA_DLL, path);
// if (stat(javadll, &s) == 0) {
// strcat(path, "\\jre");
// goto found;
// }
// }
/* Look for a public JRE on this machine. */
if (GetPublicJREHome(path, pathsize))
goto found;
fprintf(stderr, "Error: could not find " JAVA_DLL "\n");
return JNI_FALSE;
found:
{
// trick into thinking that the jre/bin path is in the PATH
char *oldPath = getenv("PATH");
char *newPath;
if(oldPath != NULL) {
newPath = MemAlloc(strlen(oldPath) + strlen(path) + 6 + 6 + 1); // PATH=<new>\bin;<old>
sprintf(newPath, "PATH=%s\\bin;%s", path, oldPath);
} else {
newPath = MemAlloc(strlen(path) + 6 + 1);
sprintf(newPath, "PATH=%s\\bin", path);
}
_putenv(newPath);
free(newPath);
}
return JNI_TRUE;
}
/*
* Given a JRE location and a JVM type, construct what the name the
* JVM shared library will be. Return true, if such a library
* exists, false otherwise.
*/
static jboolean
GetJVMPath(const char *jrepath, const char *jvmtype,
char *jvmpath, jint jvmpathsize)
{
struct stat s;
if (strchr(jvmtype, '/') || strchr(jvmtype, '\\')) {
sprintf(jvmpath, "%s\\" JVM_DLL, jvmtype);
} else {
sprintf(jvmpath, "%s\\bin\\%s\\" JVM_DLL, jrepath, jvmtype);
}
if (stat(jvmpath, &s) == 0) {
return JNI_TRUE;
} else {
return JNI_FALSE;
}
}
/*
* Load a jvm from "jvmpath" and initialize the invocation functions.
*/
jboolean
LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
{
HINSTANCE handle;
/* Load the Java VM DLL */
if ((handle = LoadLibrary(jvmpath)) == 0) {
ReportErrorMessage2("Error loading: %s", (char *)jvmpath, JNI_TRUE);
return JNI_FALSE;
}
/* Now get the function addresses */
ifn->CreateJavaVM =
(void *)GetProcAddress(handle, "JNI_CreateJavaVM");
ifn->GetDefaultJavaVMInitArgs =
(void *)GetProcAddress(handle, "JNI_GetDefaultJavaVMInitArgs");
if (ifn->CreateJavaVM == 0 || ifn->GetDefaultJavaVMInitArgs == 0) {
ReportErrorMessage2("Error: can't find JNI interfaces in: %s",
(char *)jvmpath, JNI_TRUE);
return JNI_FALSE;
}
return JNI_TRUE;
}
/*
* If app is "c:\foo\bin\javac", then put "c:\foo" into buf.
*/
jboolean
GetApplicationHome(char *buf, jint bufsize)
{
char *cp;
GetModuleFileName(0, buf, bufsize);
*strrchr(buf, '\\') = '\0'; /* remove .exe file name */
if ((cp = strrchr(buf, '\\')) == 0) {
/* This happens if the application is in a drive root, and
* there is no bin directory. */
buf[0] = '\0';
return JNI_FALSE;
}
if(strcmp(cp, "\\bin") == 0)
*cp = '\0'; /* remove the bin\ part */
// else c:\foo\something\javac
return JNI_TRUE;
}
/*
* Helpers to look in the registry for a public JRE.
*/
/* Same for 1.5.0, 1.5.1, 1.5.2 etc. */
#define DOTRELEASE JDK_MAJOR_VERSION "." JDK_MINOR_VERSION
#define JRE_KEY "Software\\JavaSoft\\Java Runtime Environment"
static jboolean
GetStringFromRegistry(HKEY key, const char *name, char *buf, jint bufsize)
{
DWORD type, size;
if (RegQueryValueEx(key, name, 0, &type, 0, &size) == 0
&& type == REG_SZ
&& (size < (unsigned int)bufsize)) {
if (RegQueryValueEx(key, name, 0, 0, buf, &size) == 0) {
return JNI_TRUE;
}
}
return JNI_FALSE;
}
static BOOL versionOk(char *version)
{
char *major;
int major_version;
int minor_version;
char *minor_start;
// 1. find the .
minor_start = strstr(version,".");
if (minor_start == NULL) // no . found.
return FALSE;
major = (char *)malloc(minor_start - version + 1);
strncpy(major,version,minor_start - version);
major[minor_start - version]='\0';
major_version = atoi(major);
free(major);
if (minor_start[1] == '\0') // "x." ?
return FALSE;
// anything less than 1.6 is not supported
minor_version = atoi(++minor_start);
if (major_version <1 || (major_version < 2 && minor_version < 6))
return FALSE;
return TRUE;
}
static jboolean
GetPublicJREHome(char *buf, jint bufsize)
{
HKEY key, subkey;
char version[MAXPATHLEN];
/* Find the current version of the JRE */
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, JRE_KEY, 0, KEY_READ, &key) != 0) {
fprintf(stderr, "Error opening registry key '" JRE_KEY "'\n");
return JNI_FALSE;
}
if (!GetStringFromRegistry(key, "CurrentVersion",
version, sizeof(version))) {
fprintf(stderr, "Failed reading value of registry key:\n\t"
JRE_KEY "\\CurrentVersion\n");
RegCloseKey(key);
return JNI_FALSE;
}
/* Check if the version is good */
if (!versionOk(version))
{
RegCloseKey(key);
return JNI_FALSE;
}
/* Find directory where the current version is installed. */
if (RegOpenKeyEx(key, version, 0, KEY_READ, &subkey) != 0) {
fprintf(stderr, "Error opening registry key '"
JRE_KEY "\\%s'\n", version);
RegCloseKey(key);
return JNI_FALSE;
}
if (!GetStringFromRegistry(subkey, "JavaHome", buf, bufsize)) {
fprintf(stderr, "Failed reading value of registry key:\n\t"
JRE_KEY "\\%s\\JavaHome\n", version);
RegCloseKey(key);
RegCloseKey(subkey);
return JNI_FALSE;
}
RegCloseKey(key);
RegCloseKey(subkey);
return JNI_TRUE;
}
void ReportErrorMessage(char * message, jboolean always) {
if (message != NULL) {
// MessageBox(NULL, message, "Java Virtual Machine Launcher",
// (MB_OK|MB_ICONSTOP|MB_APPLMODAL));
}
}
void ReportErrorMessage2(char * format, char * string, jboolean always) {
/*
* The format argument must be a printf format string with one %s
* argument, which is passed the string argument.
*/
size_t size;
char * message;
size = strlen(format) + strlen(string);
message = (char*)MemAlloc(size*sizeof(char));
sprintf(message, (const char *)format, string);
if (message != NULL) {
// MessageBox(NULL, message, "Java Virtual Machine Launcher",
// (MB_OK|MB_ICONSTOP|MB_APPLMODAL));
}
}
void ReportExceptionDescription(JNIEnv * env) {
/*
* This code should be replaced by code which opens a window with
* the exception detail message.
*/
(*env)->ExceptionDescribe(env);
}
/*
* Return JNI_TRUE for an option string that has no effect but should
* _not_ be passed on to the vm; return JNI_FALSE otherwise. On
* windows, there are no options that should be screened in this
* manner.
*/
jboolean RemovableMachineDependentOption(char * option) {
return JNI_FALSE;
}
void PrintMachineDependentOptions() {
return;
}
jboolean
ServerClassMachine() {
jboolean result = JNI_FALSE;
return result;
}
/*
* Wrapper for platform dependent unsetenv function.
*/
int
UnsetEnv(char *name)
{
int ret;
char *buf = MemAlloc(strlen(name) + 2);
buf = strcat(strcpy(buf, name), "=");
ret = _putenv(buf);
free(buf);
return (ret);
}
/*
* The following just map the common UNIX name to the Windows API name,
* so that the common UNIX name can be used in shared code.
*/
int
strcasecmp(const char *s1, const char *s2)
{
return (stricmp(s1, s2));
}
int
strncasecmp(const char *s1, const char *s2, size_t n)
{
return (strnicmp(s1, s2, n));
}

View File

@@ -0,0 +1,28 @@
/*
* @(#)java_md.h 1.10 04/04/24
*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/* Backported from Tiger (1.5) java_md.h 1.13 04/01/12 */
#ifndef JAVA_MD_H
#define JAVA_MD_H
#include "jni.h"
#include <windows.h>
#include <io.h>
#define PATH_SEPARATOR ';'
#define FILESEP "\\"
#define FILE_SEPARATOR '\\'
#define MAXPATHLEN MAX_PATH
#define MAXNAMELEN MAX_PATH
int UnsetEnv(char *name);
int strcasecmp(const char *s1, const char *s2);
int strncasecmp(const char *s1, const char *s2, size_t n);
#endif

1944
installer/c/i2pExe/jni.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
/*
* @(#)jni_md.h 1.15 05/11/17
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
#ifndef _JAVASOFT_JNI_MD_H_
#define _JAVASOFT_JNI_MD_H_
#define JNIEXPORT __declspec(dllexport)
#define JNIIMPORT __declspec(dllimport)
#define JNICALL __stdcall
typedef long jint;
typedef __int64 jlong;
typedef signed char jbyte;
#endif /* !_JAVASOFT_JNI_MD_H_ */

View File

@@ -0,0 +1,16 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by I2P.rc
//
#define IDI_ICON1 111
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 113
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif