Mercurial > hg > graal-compiler
diff src/os/windows/vm/os_windows.hpp @ 3429:5def270bc147
7016797: Hotspot: securely/restrictive load dlls and new API for loading system dlls
Summary: Created Windows Dll wrapped to handle jdk6 and jdk7 platform requirements, also provided more restictive Dll search orders for Windows system Dlls.
Reviewed-by: acorn, dcubed, ohair, alanb
author | zgu |
---|---|
date | Fri, 15 Apr 2011 09:34:43 -0400 |
parents | 63d374c54045 |
children | 3cd0157e1d4d |
line wrap: on
line diff
--- a/src/os/windows/vm/os_windows.hpp Thu Apr 21 22:07:32 2011 -0700 +++ b/src/os/windows/vm/os_windows.hpp Fri Apr 15 09:34:43 2011 -0400 @@ -24,7 +24,6 @@ #ifndef OS_WINDOWS_VM_OS_WINDOWS_HPP #define OS_WINDOWS_VM_OS_WINDOWS_HPP - // Win32_OS defines the interface to windows operating systems class win32 { @@ -55,6 +54,9 @@ static julong available_memory(); static julong physical_memory() { return _physical_memory; } + // load dll from Windows system directory or Windows directory + static HINSTANCE load_Windows_dll(const char* name, char *ebuf, int ebuflen); + public: // Generic interface: @@ -132,4 +134,100 @@ } ; +// JDK7 requires VS2010 +#if _MSC_VER < 1600 +#define JDK6_OR_EARLIER 1 +#endif + + + +class WinSock2Dll: AllStatic { +public: + static BOOL WSAStartup(WORD, LPWSADATA); + static struct hostent* gethostbyname(const char *name); + static BOOL WinSock2Available(); +#ifdef JDK6_OR_EARLIER +private: + static int (PASCAL FAR* _WSAStartup)(WORD, LPWSADATA); + static struct hostent *(PASCAL FAR *_gethostbyname)(...); + static BOOL initialized; + + static void initialize(); +#endif +}; + +class Kernel32Dll: AllStatic { +public: + static BOOL SwitchToThread(); + static SIZE_T GetLargePageMinimum(); + + static BOOL SwitchToThreadAvailable(); + static BOOL GetLargePageMinimumAvailable(); + + // Help tools + static BOOL HelpToolsAvailable(); + static HANDLE CreateToolhelp32Snapshot(DWORD,DWORD); + static BOOL Module32First(HANDLE,LPMODULEENTRY32); + static BOOL Module32Next(HANDLE,LPMODULEENTRY32); + + static BOOL GetNativeSystemInfoAvailable(); + static void GetNativeSystemInfo(LPSYSTEM_INFO); + +private: + // GetLargePageMinimum available on Windows Vista/Windows Server 2003 + // and later + static SIZE_T (WINAPI *_GetLargePageMinimum)(void); + static BOOL initialized; + + static void initialize(); + +#ifdef JDK6_OR_EARLIER +private: + static BOOL (WINAPI *_SwitchToThread)(void); + static HANDLE (WINAPI* _CreateToolhelp32Snapshot)(DWORD,DWORD); + static BOOL (WINAPI* _Module32First)(HANDLE,LPMODULEENTRY32); + static BOOL (WINAPI* _Module32Next)(HANDLE,LPMODULEENTRY32); + static void (WINAPI *_GetNativeSystemInfo)(LPSYSTEM_INFO); +#endif + +}; + +class Advapi32Dll: AllStatic { +public: + static BOOL AdjustTokenPrivileges(HANDLE, BOOL, PTOKEN_PRIVILEGES, DWORD, PTOKEN_PRIVILEGES, PDWORD); + static BOOL OpenProcessToken(HANDLE, DWORD, PHANDLE); + static BOOL LookupPrivilegeValue(LPCTSTR, LPCTSTR, PLUID); + + static BOOL AdvapiAvailable(); + +#ifdef JDK6_OR_EARLIER +private: + static BOOL (WINAPI *_AdjustTokenPrivileges)(HANDLE, BOOL, PTOKEN_PRIVILEGES, DWORD, PTOKEN_PRIVILEGES, PDWORD); + static BOOL (WINAPI *_OpenProcessToken)(HANDLE, DWORD, PHANDLE); + static BOOL (WINAPI *_LookupPrivilegeValue)(LPCTSTR, LPCTSTR, PLUID); + static BOOL initialized; + + static void initialize(); +#endif +}; + +class PSApiDll: AllStatic { +public: + static BOOL EnumProcessModules(HANDLE, HMODULE *, DWORD, LPDWORD); + static DWORD GetModuleFileNameEx(HANDLE, HMODULE, LPTSTR, DWORD); + static BOOL GetModuleInformation(HANDLE, HMODULE, LPMODULEINFO, DWORD); + + static BOOL PSApiAvailable(); + +#ifdef JDK6_OR_EARLIER +private: + static BOOL (WINAPI *_EnumProcessModules)(HANDLE, HMODULE *, DWORD, LPDWORD); + static BOOL (WINAPI *_GetModuleFileNameEx)(HANDLE, HMODULE, LPTSTR, DWORD);; + static BOOL (WINAPI *_GetModuleInformation)(HANDLE, HMODULE, LPMODULEINFO, DWORD); + static BOOL initialized; + + static void initialize(); +#endif +}; + #endif // OS_WINDOWS_VM_OS_WINDOWS_HPP