* autoload.cc: New file keeping all autoload stuff.
* Makefile.in: Add autoload.o to dependencies. * dcrt0.cc: Move all autoload stuff to autoload.cc. * fhandler_mem.cc: Ditto. * net.cc: Ditto. * uinfo.cc: Ditto.
This commit is contained in:
@@ -13,7 +13,6 @@ details. */
|
||||
#include <stdlib.h>
|
||||
#include "glob.h"
|
||||
#include "exceptions.h"
|
||||
#include "autoload.h"
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include "sync.h"
|
||||
@@ -1103,184 +1102,3 @@ cygbench (const char *s)
|
||||
small_printf ("%05d ***** %s : %10d\n", GetCurrentProcessId (), s, strace.microseconds ());
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
|
||||
/* This struct is unused, but it illustrates the layout of a DLL
|
||||
information block. */
|
||||
struct DLLinfo
|
||||
{
|
||||
char jmpinst[4];
|
||||
HANDLE h;
|
||||
DWORD flag;
|
||||
char name[0];
|
||||
};
|
||||
|
||||
/* FIXME: This is not thread-safe! */
|
||||
__asm__ ("
|
||||
msg1:
|
||||
.ascii \"couldn't dynamically determine load address for '%s' (handle %p), %E\\0\"
|
||||
|
||||
.align 32
|
||||
noload:
|
||||
popl %edx # Get the address of the information block
|
||||
movl 8(%edx),%eax # Should we 'ignore' the lack
|
||||
test $1,%eax # of this function?
|
||||
jz 1f # Nope.
|
||||
decl %eax # Yes. This is the # of bytes + 1
|
||||
popl %edx # Caller's caller
|
||||
addl %eax,%esp # Pop off bytes
|
||||
xor %eax,%eax # Zero functional return
|
||||
jmp *%edx # Return
|
||||
1:
|
||||
movl 4(%edx),%eax # Handle value
|
||||
pushl (%eax)
|
||||
leal 12(%edx),%eax # Location of name of function
|
||||
push %eax
|
||||
push $msg1 # The message
|
||||
call ___api_fatal # Print message. Never returns
|
||||
|
||||
.globl cygwin_dll_func_load
|
||||
cygwin_dll_func_load:
|
||||
movl (%esp),%eax # 'Return address' contains load info
|
||||
addl $12,%eax # Address of name of function to load
|
||||
pushl %eax # Second argument
|
||||
movl -8(%eax),%eax # Address of Handle to DLL
|
||||
pushl (%eax) # Handle to DLL
|
||||
call _GetProcAddress@8# Load it
|
||||
test %eax,%eax # Success?
|
||||
jne gotit # Yes
|
||||
jmp noload # Issue an error or return
|
||||
gotit:
|
||||
popl %ecx # Pointer to 'return address'
|
||||
movb $0xe0,-1(%ecx) # Turn preceding call to a jmp *%eax
|
||||
movl %eax,(%ecx) # Point dispatch to address loaded above
|
||||
jmp *%eax
|
||||
");
|
||||
|
||||
LoadDLLinitfunc (user32)
|
||||
{
|
||||
HANDLE h;
|
||||
static NO_COPY LONG here = -1L;
|
||||
|
||||
while (InterlockedIncrement (&here))
|
||||
{
|
||||
InterlockedDecrement (&here);
|
||||
Sleep (0);
|
||||
}
|
||||
|
||||
if (user32_handle)
|
||||
/* nothing to do */;
|
||||
else if ((h = LoadLibrary ("user32.dll")) != NULL)
|
||||
user32_handle = h;
|
||||
else if (!user32_handle)
|
||||
api_fatal ("could not load user32.dll, %E");
|
||||
|
||||
InterlockedDecrement (&here);
|
||||
return 0; /* Already done by another thread? */
|
||||
}
|
||||
|
||||
LoadDLLinitfunc (advapi32)
|
||||
{
|
||||
HANDLE h;
|
||||
static NO_COPY LONG here = -1L;
|
||||
|
||||
while (InterlockedIncrement (&here))
|
||||
{
|
||||
InterlockedDecrement (&here);
|
||||
Sleep (0);
|
||||
}
|
||||
|
||||
if (advapi32_handle)
|
||||
/* nothing to do */;
|
||||
else if ((h = LoadLibrary ("advapi32.dll")) != NULL)
|
||||
advapi32_handle = h;
|
||||
else if (!advapi32_handle)
|
||||
api_fatal ("could not load advapi32.dll, %E");
|
||||
|
||||
InterlockedDecrement (&here);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dummy_autoload (void) __attribute__ ((unused));
|
||||
static void
|
||||
dummy_autoload (void)
|
||||
{
|
||||
LoadDLLinit (user32)
|
||||
LoadDLLfunc (CharToOemBuffA, 12, user32)
|
||||
LoadDLLfunc (CloseClipboard, 0, user32)
|
||||
LoadDLLfunc (CreateWindowExA, 48, user32)
|
||||
LoadDLLfunc (DefWindowProcA, 16, user32)
|
||||
LoadDLLfunc (DispatchMessageA, 4, user32)
|
||||
LoadDLLfunc (FindWindowA, 8, user32)
|
||||
LoadDLLfunc (GetClipboardData, 4, user32)
|
||||
LoadDLLfunc (GetMessageA, 16, user32)
|
||||
LoadDLLfunc (GetProcessWindowStation, 0, user32)
|
||||
LoadDLLfunc (GetThreadDesktop, 4, user32)
|
||||
LoadDLLfunc (GetUserObjectInformationA, 20, user32)
|
||||
LoadDLLfunc (KillTimer, 8, user32)
|
||||
LoadDLLfunc (MessageBoxA, 16, user32)
|
||||
LoadDLLfunc (MsgWaitForMultipleObjects, 20, user32)
|
||||
LoadDLLfunc (OemToCharBuffA, 12, user32)
|
||||
LoadDLLfunc (OpenClipboard, 4, user32)
|
||||
LoadDLLfunc (PeekMessageA, 20, user32)
|
||||
LoadDLLfunc (PostMessageA, 16, user32)
|
||||
LoadDLLfunc (PostQuitMessage, 4, user32)
|
||||
LoadDLLfunc (RegisterClassA, 4, user32)
|
||||
LoadDLLfunc (SendMessageA, 16, user32)
|
||||
LoadDLLfunc (SetTimer, 16, user32)
|
||||
LoadDLLfunc (SetUserObjectSecurity, 12, user32)
|
||||
|
||||
LoadDLLinit (advapi32)
|
||||
LoadDLLfunc (AddAccessAllowedAce, 16, advapi32)
|
||||
LoadDLLfunc (AddAccessDeniedAce, 16, advapi32)
|
||||
LoadDLLfunc (AddAce, 20, advapi32)
|
||||
LoadDLLfunc (AdjustTokenPrivileges, 24, advapi32)
|
||||
LoadDLLfunc (CopySid, 12, advapi32)
|
||||
LoadDLLfunc (CreateProcessAsUserA, 44, advapi32)
|
||||
LoadDLLfuncEx (CryptAcquireContextA, 20, advapi32, 1)
|
||||
LoadDLLfuncEx (CryptGenRandom, 12, advapi32, 1)
|
||||
LoadDLLfuncEx (CryptReleaseContext, 8, advapi32, 1)
|
||||
LoadDLLfunc (DeregisterEventSource, 4, advapi32)
|
||||
LoadDLLfunc (EqualSid, 8, advapi32)
|
||||
LoadDLLfunc (GetAce, 12, advapi32)
|
||||
LoadDLLfunc (GetFileSecurityA, 20, advapi32)
|
||||
LoadDLLfunc (GetLengthSid, 4, advapi32)
|
||||
LoadDLLfunc (GetSecurityDescriptorDacl, 16, advapi32)
|
||||
LoadDLLfunc (GetSecurityDescriptorGroup, 12, advapi32)
|
||||
LoadDLLfunc (GetSecurityDescriptorOwner, 12, advapi32)
|
||||
LoadDLLfunc (GetSidIdentifierAuthority, 4, advapi32)
|
||||
LoadDLLfunc (GetSidSubAuthority, 8, advapi32)
|
||||
LoadDLLfunc (GetSidSubAuthorityCount, 4, advapi32)
|
||||
LoadDLLfunc (GetTokenInformation, 20, advapi32)
|
||||
LoadDLLfunc (GetUserNameA, 8, advapi32)
|
||||
LoadDLLfunc (ImpersonateLoggedOnUser, 4, advapi32)
|
||||
LoadDLLfunc (InitializeAcl, 12, advapi32)
|
||||
LoadDLLfunc (InitializeSecurityDescriptor, 8, advapi32)
|
||||
LoadDLLfunc (InitializeSid, 12, advapi32)
|
||||
LoadDLLfunc (IsValidSid, 4, advapi32)
|
||||
LoadDLLfunc (LogonUserA, 24, advapi32)
|
||||
LoadDLLfunc (LookupAccountNameA, 28, advapi32)
|
||||
LoadDLLfunc (LookupAccountSidA, 28, advapi32)
|
||||
LoadDLLfunc (LookupPrivilegeValueA, 12, advapi32)
|
||||
LoadDLLfunc (MakeSelfRelativeSD, 12, advapi32)
|
||||
LoadDLLfunc (OpenProcessToken, 12, advapi32)
|
||||
LoadDLLfunc (RegCloseKey, 4, advapi32)
|
||||
LoadDLLfunc (RegCreateKeyExA, 36, advapi32)
|
||||
LoadDLLfunc (RegDeleteKeyA, 8, advapi32)
|
||||
LoadDLLfunc (RegDeleteValueA, 8, advapi32)
|
||||
LoadDLLfunc (RegLoadKeyA, 12, advapi32)
|
||||
LoadDLLfunc (RegEnumKeyExA, 32, advapi32)
|
||||
LoadDLLfunc (RegEnumValueA, 32, advapi32)
|
||||
LoadDLLfunc (RegOpenKeyExA, 20, advapi32)
|
||||
LoadDLLfunc (RegQueryValueExA, 24, advapi32)
|
||||
LoadDLLfunc (RegSetValueExA, 24, advapi32)
|
||||
LoadDLLfunc (RegisterEventSourceA, 8, advapi32)
|
||||
LoadDLLfunc (ReportEventA, 36, advapi32)
|
||||
LoadDLLfunc (RevertToSelf, 0, advapi32)
|
||||
LoadDLLfunc (SetKernelObjectSecurity, 12, advapi32)
|
||||
LoadDLLfunc (SetSecurityDescriptorDacl, 16, advapi32)
|
||||
LoadDLLfunc (SetSecurityDescriptorGroup, 12, advapi32)
|
||||
LoadDLLfunc (SetSecurityDescriptorOwner, 12, advapi32)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user