首页 > 编程语言 >Java Launcher

Java Launcher

时间:2023-02-25 19:59:16浏览次数:57  
标签:Java Launcher beginthreadex module -- env JLI class

Launcher

  1. main / WinMain
  2. env:  #define JLDEBUG_ENV_ENTRY "_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. 3866 (0x0f1a), verify, 0x002483b0

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
};

标签:Java,Launcher,beginthreadex,module,--,env,JLI,class
From: https://www.cnblogs.com/UPeRVv/p/17154840.html

相关文章

  • Java基础(1)
    面向过程和面向对象的概念面向过程:就是针对过程的开发,以什么正在发生为目标的编程开发,比如一辆车从出站到进站,只编写出站和进站两件事,然后依次调用,而不是针对车本身进行编......
  • Java中的方法 必须是小括号结尾的
    类packagecom.fqs.demo1;publicclassGirl{privateStringname;privateintage;//getset//赋值给的过程不需要返回值void空代表不......
  • Java中的void 关键字
    每次定义一个方法的时候需要定义是否需要返回值 比如赋值的方法 是一个给的过程 不需要返回值 void出现publicvoidsetName(Stringname){this.nam......
  • Java学习之多线程
    线程的三种创建线程Threadclass:继承实现线程类(不建议使用)Runnable接口:实现接口(推荐使用,避免单继承局限性)Callable接口:实现接口(了解)ThreadClass实现方式......
  • Java 正则表达式详解
    总结:搜索(匹配):在一个字符串中搜索出一个或多个与正则表达式相匹配的子字符串。搜索又分为匹配和子字符串搜索。匹配是对用户所提供的整个字符串进行判断,看其是否匹......
  • java swing创建一个窗口
    新建一个窗口类packagecom.rzk;importjavax.swing.*;importjava.awt.*;publicclassSwingFrameextendsJFrame{JLabellabel=newJLabel("输入名");......
  • java-树形结构数据
    在我们实际开发中会接触到树形结构,根节点子节点,然后添加数据构成了我们的树形结构,在Java后台利用递归思路进行构建树形结构数据,返回给前端,能以下拉菜单等形式进行展示......
  • Java中的代码块
    Java中的代码块我们在做笔试题的时候经常会遇到考察类中代码块运行顺序的题,所以我现在把它总结一下。在Java中,代码块(Block)是用一对大括号括起来的一段代码,它可以包含多条......
  • java security 详解_Spring Security入门教程
    SpringSecurity的简单使用简介SSM整合Security是比较麻烦的,虽然Security的功能比Shiro强大,相反却没有Shiro的使用量多SpringBoot出现后简化了Spring系列的配置......
  • java HashMap
    publicstaticvoidmain(String[]args){Map<Integer,String>m=newHashMap<>();//增m.put(1,"111");m.put(2,"2......