< prev index next >

src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c

Print this page
rev 12879 : 8136556: Add the ability to perform static builds of MacOSX x64 binaries
Reviewed-by: ihse, bdelsart, gadams, lfoltan, rriggs, hseigel, twisti
   1 /*
   2  * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  70 #define MAX_ARGS                3
  71 #define MAX_PIPE_NAME_LENGTH    256
  72 
  73 typedef struct {
  74    GetModuleHandleFunc _GetModuleHandle;
  75    GetProcAddressFunc _GetProcAddress;
  76    char jvmLib[MAX_LIBNAME_LENGTH];         /* "jvm.dll" */
  77    char func1[MAX_FUNC_LENGTH];
  78    char func2[MAX_FUNC_LENGTH];
  79    char cmd[MAX_CMD_LENGTH];                /* "load", "dump", ...      */
  80    char arg[MAX_ARGS][MAX_ARG_LENGTH];      /* arguments to command     */
  81    char pipename[MAX_PIPE_NAME_LENGTH];
  82 } DataBlock;
  83 
  84 /*
  85  * Return codes from enqueue function executed in target VM
  86  */
  87 #define ERR_OPEN_JVM_FAIL           200
  88 #define ERR_GET_ENQUEUE_FUNC_FAIL   201
  89 




  90 
  91 /*
  92  * Code copied to target process
  93  */
  94 #pragma check_stack (off)
  95 /* Switch off all runtime checks (checks caused by /RTC<x>). They cause the
  96  * generated code to contain relative jumps to check functions which make
  97  * the code position dependent. */
  98 #pragma runtime_checks ("scu", off)
  99 DWORD WINAPI jvm_attach_thread_func(DataBlock *pData)
 100 {
 101     HINSTANCE h;
 102     EnqueueOperationFunc addr;
 103 
 104     h = pData->_GetModuleHandle(pData->jvmLib);
 105     if (h == NULL) {
 106         return ERR_OPEN_JVM_FAIL;
 107     }
 108 
 109     addr = (EnqueueOperationFunc)(pData->_GetProcAddress(h, pData->func1));


   1 /*
   2  * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  70 #define MAX_ARGS                3
  71 #define MAX_PIPE_NAME_LENGTH    256
  72 
  73 typedef struct {
  74    GetModuleHandleFunc _GetModuleHandle;
  75    GetProcAddressFunc _GetProcAddress;
  76    char jvmLib[MAX_LIBNAME_LENGTH];         /* "jvm.dll" */
  77    char func1[MAX_FUNC_LENGTH];
  78    char func2[MAX_FUNC_LENGTH];
  79    char cmd[MAX_CMD_LENGTH];                /* "load", "dump", ...      */
  80    char arg[MAX_ARGS][MAX_ARG_LENGTH];      /* arguments to command     */
  81    char pipename[MAX_PIPE_NAME_LENGTH];
  82 } DataBlock;
  83 
  84 /*
  85  * Return codes from enqueue function executed in target VM
  86  */
  87 #define ERR_OPEN_JVM_FAIL           200
  88 #define ERR_GET_ENQUEUE_FUNC_FAIL   201
  89 
  90 /*
  91  * Declare library specific JNI_Onload entry if static build
  92  */
  93 DEF_STATIC_JNI_OnLoad
  94 
  95 /*
  96  * Code copied to target process
  97  */
  98 #pragma check_stack (off)
  99 /* Switch off all runtime checks (checks caused by /RTC<x>). They cause the
 100  * generated code to contain relative jumps to check functions which make
 101  * the code position dependent. */
 102 #pragma runtime_checks ("scu", off)
 103 DWORD WINAPI jvm_attach_thread_func(DataBlock *pData)
 104 {
 105     HINSTANCE h;
 106     EnqueueOperationFunc addr;
 107 
 108     h = pData->_GetModuleHandle(pData->jvmLib);
 109     if (h == NULL) {
 110         return ERR_OPEN_JVM_FAIL;
 111     }
 112 
 113     addr = (EnqueueOperationFunc)(pData->_GetProcAddress(h, pData->func1));


< prev index next >