* autoload.cc (EnumProcessModules): Remove.
* dlfcn.cc (dlopen): Make sure errno is set if an error occurs. (dlsym): Rewrite using RtlQueryProcessDebugInformation instead of EnumProcessModules. * ntdll.h (struct _DEBUG_MODULE_ARRAY): Define. (RtlCreateQueryDebugBuffer): Declare. (RtlDestroyQueryDebugBuffer): Declare. (RtlQueryProcessDebugInformation): Declare.
This commit is contained in:
parent
b27800ad45
commit
31ddf45dd8
@ -1,3 +1,14 @@
|
|||||||
|
2011-05-11 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* autoload.cc (EnumProcessModules): Remove.
|
||||||
|
* dlfcn.cc (dlopen): Make sure errno is set if an error occurs.
|
||||||
|
(dlsym): Rewrite using RtlQueryProcessDebugInformation instead of
|
||||||
|
EnumProcessModules.
|
||||||
|
* ntdll.h (struct _DEBUG_MODULE_ARRAY): Define.
|
||||||
|
(RtlCreateQueryDebugBuffer): Declare.
|
||||||
|
(RtlDestroyQueryDebugBuffer): Declare.
|
||||||
|
(RtlQueryProcessDebugInformation): Declare.
|
||||||
|
|
||||||
2011-05-11 Corinna Vinschen <corinna@vinschen.de>
|
2011-05-11 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* autoload.cc (GetModuleFileNameExW): Remove.
|
* autoload.cc (GetModuleFileNameExW): Remove.
|
||||||
|
@ -414,8 +414,6 @@ LoadDLLfunc (RtlSetCurrentTransaction, 4, ntdll)
|
|||||||
|
|
||||||
LoadDLLfunc (CoTaskMemFree, 4, ole32)
|
LoadDLLfunc (CoTaskMemFree, 4, ole32)
|
||||||
|
|
||||||
LoadDLLfunc (EnumProcessModules, 16, psapi)
|
|
||||||
|
|
||||||
LoadDLLfunc (LsaDeregisterLogonProcess, 4, secur32)
|
LoadDLLfunc (LsaDeregisterLogonProcess, 4, secur32)
|
||||||
LoadDLLfunc (LsaFreeReturnBuffer, 4, secur32)
|
LoadDLLfunc (LsaFreeReturnBuffer, 4, secur32)
|
||||||
LoadDLLfunc (LsaLogonUser, 56, secur32)
|
LoadDLLfunc (LsaLogonUser, 56, secur32)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/* dlfcn.cc
|
/* dlfcn.cc
|
||||||
|
|
||||||
Copyright 1998, 2000, 2001, 2002, 2003, 2004, 2008, 2009, 2010 Red Hat, Inc.
|
Copyright 1998, 2000, 2001, 2002, 2003, 2004, 2008, 2009, 2010,
|
||||||
|
2011 Red Hat, Inc.
|
||||||
|
|
||||||
This file is part of Cygwin.
|
This file is part of Cygwin.
|
||||||
|
|
||||||
@ -17,6 +18,7 @@ details. */
|
|||||||
#include "dlfcn.h"
|
#include "dlfcn.h"
|
||||||
#include "cygtls.h"
|
#include "cygtls.h"
|
||||||
#include "tls_pbuf.h"
|
#include "tls_pbuf.h"
|
||||||
|
#include "ntdll.h"
|
||||||
|
|
||||||
static void __stdcall
|
static void __stdcall
|
||||||
set_dl_error (const char *str)
|
set_dl_error (const char *str)
|
||||||
@ -71,7 +73,11 @@ dlopen (const char *name, int)
|
|||||||
void *ret;
|
void *ret;
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
|
{
|
||||||
ret = (void *) GetModuleHandle (NULL); /* handle for the current module */
|
ret = (void *) GetModuleHandle (NULL); /* handle for the current module */
|
||||||
|
if (!ret)
|
||||||
|
__seterrno ();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* handle for the named library */
|
/* handle for the named library */
|
||||||
@ -112,7 +118,7 @@ dlopen (const char *name, int)
|
|||||||
/* Restore original cxx_malloc pointer. */
|
/* Restore original cxx_malloc pointer. */
|
||||||
__cygwin_user_data.cxx_malloc = tmp_malloc;
|
__cygwin_user_data.cxx_malloc = tmp_malloc;
|
||||||
|
|
||||||
if (ret == NULL)
|
if (!ret)
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,26 +134,42 @@ void *
|
|||||||
dlsym (void *handle, const char *name)
|
dlsym (void *handle, const char *name)
|
||||||
{
|
{
|
||||||
void *ret = NULL;
|
void *ret = NULL;
|
||||||
|
|
||||||
if (handle == RTLD_DEFAULT)
|
if (handle == RTLD_DEFAULT)
|
||||||
{ /* search all modules */
|
{ /* search all modules */
|
||||||
HANDLE cur_proc = GetCurrentProcess ();
|
PDEBUG_BUFFER buf;
|
||||||
HMODULE *modules;
|
NTSTATUS status;
|
||||||
DWORD needed, i;
|
|
||||||
if (!EnumProcessModules (cur_proc, NULL, 0, &needed))
|
buf = RtlCreateQueryDebugBuffer (0, FALSE);
|
||||||
|
if (!buf)
|
||||||
{
|
{
|
||||||
dlsym_fail:
|
set_errno (ENOMEM);
|
||||||
set_dl_error ("dlsym");
|
set_dl_error ("dlsym");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
modules = (HMODULE*) alloca (needed);
|
status = RtlQueryProcessDebugInformation (GetCurrentProcessId (),
|
||||||
if (!EnumProcessModules (cur_proc, modules, needed, &needed))
|
PDI_MODULES, buf);
|
||||||
goto dlsym_fail;
|
if (!NT_SUCCESS (status))
|
||||||
for (i = 0; i < needed / sizeof (HMODULE); i++)
|
__seterrno_from_nt_status (status);
|
||||||
if ((ret = (void *) GetProcAddress (modules[i], name)))
|
else
|
||||||
|
{
|
||||||
|
PDEBUG_MODULE_ARRAY mods = (PDEBUG_MODULE_ARRAY)
|
||||||
|
buf->ModuleInformation;
|
||||||
|
for (ULONG i = 0; i < mods->Count; ++i)
|
||||||
|
if ((ret = (void *)
|
||||||
|
GetProcAddress ((HMODULE) mods->Modules[i].Base, name)))
|
||||||
break;
|
break;
|
||||||
|
if (!ret)
|
||||||
|
set_errno (ENOENT);
|
||||||
|
}
|
||||||
|
RtlDestroyQueryDebugBuffer (buf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ret = (void *) GetProcAddress ((HMODULE) handle, name);
|
ret = (void *) GetProcAddress ((HMODULE) handle, name);
|
||||||
|
if (!ret)
|
||||||
|
__seterrno ();
|
||||||
|
}
|
||||||
if (!ret)
|
if (!ret)
|
||||||
set_dl_error ("dlsym");
|
set_dl_error ("dlsym");
|
||||||
debug_printf ("ret %p", ret);
|
debug_printf ("ret %p", ret);
|
||||||
|
@ -538,6 +538,12 @@ typedef struct _DEBUG_MODULE_INFORMATION
|
|||||||
CHAR ImageName[256];
|
CHAR ImageName[256];
|
||||||
} DEBUG_MODULE_INFORMATION, *PDEBUG_MODULE_INFORMATION;
|
} DEBUG_MODULE_INFORMATION, *PDEBUG_MODULE_INFORMATION;
|
||||||
|
|
||||||
|
typedef struct _DEBUG_MODULE_ARRAY
|
||||||
|
{
|
||||||
|
ULONG Count;
|
||||||
|
DEBUG_MODULE_INFORMATION Modules[1];
|
||||||
|
} DEBUG_MODULE_ARRAY, *PDEBUG_MODULE_ARRAY;
|
||||||
|
|
||||||
typedef struct _KERNEL_USER_TIMES
|
typedef struct _KERNEL_USER_TIMES
|
||||||
{
|
{
|
||||||
LARGE_INTEGER CreateTime;
|
LARGE_INTEGER CreateTime;
|
||||||
@ -1143,10 +1149,12 @@ extern "C"
|
|||||||
NTSTATUS NTAPI RtlCopySid (ULONG, PSID, PSID);
|
NTSTATUS NTAPI RtlCopySid (ULONG, PSID, PSID);
|
||||||
VOID NTAPI RtlCopyUnicodeString (PUNICODE_STRING, PUNICODE_STRING);
|
VOID NTAPI RtlCopyUnicodeString (PUNICODE_STRING, PUNICODE_STRING);
|
||||||
NTSTATUS NTAPI RtlCreateAcl (PACL, ULONG, ULONG);
|
NTSTATUS NTAPI RtlCreateAcl (PACL, ULONG, ULONG);
|
||||||
|
PDEBUG_BUFFER NTAPI RtlCreateQueryDebugBuffer (ULONG, BOOLEAN);
|
||||||
NTSTATUS NTAPI RtlCreateRegistryKey (ULONG, PCWSTR);
|
NTSTATUS NTAPI RtlCreateRegistryKey (ULONG, PCWSTR);
|
||||||
NTSTATUS NTAPI RtlCreateSecurityDescriptor (PSECURITY_DESCRIPTOR, ULONG);
|
NTSTATUS NTAPI RtlCreateSecurityDescriptor (PSECURITY_DESCRIPTOR, ULONG);
|
||||||
BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz (PUNICODE_STRING, PCSTR);
|
BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz (PUNICODE_STRING, PCSTR);
|
||||||
NTSTATUS NTAPI RtlDeleteSecurityObject (PSECURITY_DESCRIPTOR *);
|
NTSTATUS NTAPI RtlDeleteSecurityObject (PSECURITY_DESCRIPTOR *);
|
||||||
|
NTSTATUS NTAPI RtlDestroyQueryDebugBuffer (PDEBUG_BUFFER);
|
||||||
NTSTATUS NTAPI RtlDowncaseUnicodeString (PUNICODE_STRING, PUNICODE_STRING,
|
NTSTATUS NTAPI RtlDowncaseUnicodeString (PUNICODE_STRING, PUNICODE_STRING,
|
||||||
BOOLEAN);
|
BOOLEAN);
|
||||||
NTSTATUS NTAPI RtlEnterCriticalSection (PRTL_CRITICAL_SECTION);
|
NTSTATUS NTAPI RtlEnterCriticalSection (PRTL_CRITICAL_SECTION);
|
||||||
@ -1184,6 +1192,7 @@ extern "C"
|
|||||||
BOOLEAN);
|
BOOLEAN);
|
||||||
BOOLEAN NTAPI RtlPrefixUnicodeString (PUNICODE_STRING, PUNICODE_STRING,
|
BOOLEAN NTAPI RtlPrefixUnicodeString (PUNICODE_STRING, PUNICODE_STRING,
|
||||||
BOOLEAN);
|
BOOLEAN);
|
||||||
|
NTSTATUS NTAPI RtlQueryProcessDebugInformation (ULONG, ULONG, PDEBUG_BUFFER);
|
||||||
NTSTATUS NTAPI RtlQueryRegistryValues (ULONG, PCWSTR,
|
NTSTATUS NTAPI RtlQueryRegistryValues (ULONG, PCWSTR,
|
||||||
PRTL_QUERY_REGISTRY_TABLE, PVOID,
|
PRTL_QUERY_REGISTRY_TABLE, PVOID,
|
||||||
PVOID);
|
PVOID);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user