mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 23:34:52 +02:00
8268129: LibraryLookup::ofDefault leaks symbols from loaded libraries
Reviewed-by: jvernee, psandoz
This commit is contained in:
parent
40c9e258b5
commit
59a539fef1
47 changed files with 730 additions and 725 deletions
|
@ -26,7 +26,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
#include <psapi.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include "jni.h"
|
||||
|
@ -36,31 +35,6 @@ void* getProcessHandle() {
|
|||
return (void*)GetModuleHandle(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Windows doesn't have an RTLD_DEFAULT equivalent, so in stead we have to
|
||||
* iterate over all the modules loaded by the process to implement the
|
||||
* default library behaviour.
|
||||
*/
|
||||
void* findEntryInProcess(const char* name) {
|
||||
HANDLE hProcess = GetCurrentProcess();
|
||||
|
||||
HMODULE hMods[1024];
|
||||
DWORD cbNeeded; // array size in bytes
|
||||
|
||||
// first come, first served
|
||||
if (EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded)) {
|
||||
for (size_t i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) {
|
||||
HMODULE mod = hMods[i];
|
||||
FARPROC proc = GetProcAddress(mod, name);
|
||||
if(proc != NULL) {
|
||||
return proc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Windows symbols can be simple like JNI_OnLoad or __stdcall format
|
||||
* like _JNI_OnLoad@8. We need to handle both.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue