Java Launcher

Launcher

  1. main / WinMain
  2. env:  _JAVA_LAUNCHER_DEBUG
  3. -> JLI_Launch

JLI_Launch

  1. CreateExecutionEnvironment
    1. GetJREPath, jvmcfg, ReadKnownVMs, CheckJvmType, GetJVMPath
  2. LoadJavaVM
    1. LoadMSVCRT
      1. MSVCR, VCRUNTIME, MSVCP 
    2. LoadLibrary
    3. (void *)GetProcAddress(handle, "JNI_CreateJavaVM")
    4. (void *)GetProcAddress(handle, "JNI_GetDefaultJavaVMInitArgs")
    5. JNI_GetCreatedJavaVMs
  3. ParseArguments
    1. -jar, --module/-m, --source, --class-path/-classpath/-cp, --list-modules, --show-resolved-modules, --validate-modules, describe-module
    2. <white-space>
      1. -Xss, -Xmx, -Xms
    3. --module-path/-p/--upgrade-module-path/--add-modules/--enable-native-access/--limit-modules/--add-exports/--add-opens/--add-reads/--patch-module
    4. -help/-h/-?/--help/-version/--version/-showversion/--show-version/--dry-run/-X/--help-extra
    5. -XshowSettings, -Xdiag, --show-module-resolution
    6. <backward compatibility>
      1. -fullversion/--full-version, --verbosegc [ -verbose:gc ], -t [ -Xt ] , -tm [ -Xtm ], -debug [ -Xdebug ], -noclassgc [ -Xnoclassgc ], -Xfuture [ -Xverify:all ], -verify [ -Xverify:all ], -verifyremote [ -Xverify:remote ], -noverify [ -Xverify:no ],
      2. -ss/-oss/-ms/-mx [ -X%s ], -checksource/-cs/-noasyncgc, -splash:, -Djava.class.path=
  4. JVMInit(&ifn, threadStackSize, argc, argv, mode, what, ret)

JVMInit

  1. ShowSplashScreen
  2. ContinueInNewThread

ContinueInNewThread

  1. [JNI] GetDefaultJavaVMInitArgs
  2. CallJavaMainInNewThread

CallJavaMainInNewThread

  1. _beginthreadex(NULL, (unsigned)stack_size, ThreadJavaMain, args, STACK_SIZE_PARAM_IS_A_RESERVATION, &thread_id)
  2. WaitForSingleObject(thread_handle, INFINITE)
  3. GetExitCodeThread(thread_handle, &rslt)
  4. CloseHandle(thread_handle)

ThreadJavaMain

  1. InitializeJVM
  2. ?> ShowSettings, ShowResolvedModules, ListModules, DescribeModule, PrintJavaVersion, validateModules, PrintUsage
  3. LoadMainClass
  4. GetApplicationClass
  5. CreateApplicationArgs
  6. ?> dryRun
  7. PostJVMInit(env, appClass, vm)
  8. mainID = (*env)->GetStaticMethodID(env, mainClass, "main", "([Ljava/lang/String;)V");
  9. (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs)
  10. LEAVE

附加

Java.exe

  1. jli.dll
    1. (0x0001), JLI_AddArgsFromEnvVar, 0x00001000
      (0x0002), JLI_CmdToArgs, 0x00001a58
      (0x0003), JLI_GetAppArgIndex, 0x0000106c
      (0x0004), JLI_GetStdArgc, 0x00001c54
      (0x0005), JLI_GetStdArgs, 0x00001c5c
      (0x0006), JLI_InitArgProcessing, 0x00001074
      (0x0007), JLI_Launch, 0x00004ba8
      (0x0008), JLI_List_add, 0x00008dfc
      (0x0009), JLI_List_new, 0x0000908c
      (0x000a), JLI_ManifestIterate, 0x00009380
      (0x000b), JLI_MemAlloc, 0x00009178
      (0x000c), JLI_MemFree, 0x000091a8
      (0x000d), JLI_PreprocessArg, 0x000010b0
      (0x000e), JLI_ReportErrorMessage, 0x000084e4
      (0x000f), JLI_ReportErrorMessageSys, 0x000085e4
      (0x0010), JLI_ReportExceptionDescription, 0x000087c8
      (0x0011), JLI_ReportMessage, 0x00005078
      (0x0012), JLI_SetTraceLauncher, 0x000091e0
      (0x0013), JLI_StringDup, 0x0000924c
  2. jvm.dll
    1. <jni.cpp>
      1. 3618 (0x0e22),  JNI_CreateJavaVM, 0x003efd70
        3619 (0x0e23),  JNI_GetCreatedJavaVMs, 0x003efd90
        3620 (0x0e24),  JNI_GetDefaultJavaVMInitArgs, 0x003efdd0

OptionString

optionString
/*
 * optionString may be any option accepted by the JVM, or one of the
 * following:
 *
 * -D<name>=<value>          Set a system property.
 * -verbose[:class|gc|jni]   Enable verbose output, comma-separated. E.g.
 *                           "-verbose:class" or "-verbose:gc,class"
 *                           Standard names include: gc, class, and jni.
 *                           All nonstandard (VM-specific) names must begin
 *                           with "X".
 * vfprintf                  extraInfo is a pointer to the vfprintf hook.
 * exit                      extraInfo is a pointer to the exit hook.
 * abort                     extraInfo is a pointer to the abort hook.
 */

beginthreadex

_beginthreadex
_ACRTIMP uintptr_t __cdecl _beginthreadex(
    _In_opt_  void*                    _Security,
    _In_      unsigned                 _StackSize,
    _In_      _beginthreadex_proc_type _StartAddress,
    _In_opt_  void*                    _ArgList,
    _In_      unsigned                 _InitFlag,
    _Out_opt_ unsigned*                _ThrdAddr
    );

ref: c-runtime-library/reference/beginthread-beginthreadex

LaunchMode

LaunchMode
 enum LaunchMode {               // cf. sun.launcher.LauncherHelper
    LM_UNKNOWN = 0,
    LM_CLASS,
    LM_JAR,
    LM_MODULE,
    LM_SOURCE
};
posted @ 2023-02-25 21:00  UPeRVv  阅读(49)  评论(0编辑  收藏  举报