Partially implemented LdrLock/UnlockLoaderLock.

This commit is contained in:
Alexandre Julliard 2003-03-20 04:29:21 +00:00
parent 114a31a2a8
commit 500a2f95f7
4 changed files with 48 additions and 8 deletions

View File

@ -210,6 +210,40 @@ WINE_MODREF *MODULE_FindModule(LPCSTR path)
return wm; return wm;
} }
/******************************************************************
* LdrLockLoaderLock (NTDLL.@)
*
* Note: flags are not implemented.
* Flag 0x01 is used to raise exceptions on errors.
* Flag 0x02 is used to avoid waiting on the section (does RtlTryEnterCriticalSection instead).
*/
NTSTATUS WINAPI LdrLockLoaderLock( ULONG flags, ULONG *result, ULONG *magic )
{
if (flags) FIXME( "flags %lx not supported\n", flags );
if (result) *result = 1;
if (!magic) return STATUS_INVALID_PARAMETER_3;
RtlEnterCriticalSection( &loader_section );
*magic = GetCurrentThreadId();
return STATUS_SUCCESS;
}
/******************************************************************
* LdrUnlockLoaderUnlock (NTDLL.@)
*/
NTSTATUS WINAPI LdrUnlockLoaderLock( ULONG flags, ULONG magic )
{
if (magic)
{
if (magic != GetCurrentThreadId()) return STATUS_INVALID_PARAMETER_2;
RtlLeaveCriticalSection( &loader_section );
}
return STATUS_SUCCESS;
}
/****************************************************************** /******************************************************************
* LdrGetDllHandle (NTDLL.@) * LdrGetDllHandle (NTDLL.@)
* *

View File

@ -43,12 +43,14 @@
@ stdcall LdrGetProcedureAddress(ptr ptr long ptr) @ stdcall LdrGetProcedureAddress(ptr ptr long ptr)
@ stub LdrInitializeThunk @ stub LdrInitializeThunk
@ stdcall LdrLoadDll(wstr long ptr ptr) @ stdcall LdrLoadDll(wstr long ptr ptr)
@ stdcall LdrLockLoaderLock(long ptr ptr)
@ stub LdrProcessRelocationBlock @ stub LdrProcessRelocationBlock
@ stub LdrQueryImageFileExecutionOptions @ stub LdrQueryImageFileExecutionOptions
@ stub LdrQueryProcessModuleInformation @ stub LdrQueryProcessModuleInformation
@ stdcall LdrShutdownProcess() @ stdcall LdrShutdownProcess()
@ stdcall LdrShutdownThread() @ stdcall LdrShutdownThread()
@ stdcall LdrUnloadDll(ptr) @ stdcall LdrUnloadDll(ptr)
@ stdcall LdrUnlockLoaderLock(long long)
@ stub LdrVerifyImageMatchesChecksum @ stub LdrVerifyImageMatchesChecksum
@ stub NPXEMULATORTABLE @ stub NPXEMULATORTABLE
@ extern NlsAnsiCodePage @ extern NlsAnsiCodePage

View File

@ -1204,19 +1204,21 @@ typedef struct _LDR_RESOURCE_INFO
ULONG Language; ULONG Language;
} LDR_RESOURCE_INFO, *PLDR_RESOURCE_INFO; } LDR_RESOURCE_INFO, *PLDR_RESOURCE_INFO;
NTSTATUS WINAPI LdrAccessResource(HMODULE, PIMAGE_RESOURCE_DATA_ENTRY, void**, PULONG);
NTSTATUS WINAPI LdrDisableThreadCalloutsForDll(HMODULE); NTSTATUS WINAPI LdrDisableThreadCalloutsForDll(HMODULE);
NTSTATUS WINAPI LdrFindEntryForAddress(const void*, PLDR_MODULE*); NTSTATUS WINAPI LdrFindEntryForAddress(const void*, PLDR_MODULE*);
NTSTATUS WINAPI LdrGetDllHandle(ULONG, ULONG, PUNICODE_STRING, HMODULE*); NTSTATUS WINAPI LdrFindResourceDirectory_U(HMODULE,PLDR_RESOURCE_INFO, DWORD,
NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE, PANSI_STRING, ULONG, void**);
NTSTATUS WINAPI LdrLoadDll(LPCWSTR, DWORD, PUNICODE_STRING, HMODULE*);
NTSTATUS WINAPI LdrShutdownThread(void);
NTSTATUS WINAPI LdrShutdownProcess(void);
NTSTATUS WINAPI LdrUnloadDll(HMODULE);
NTSTATUS WINAPI LdrAccessResource(HMODULE, PIMAGE_RESOURCE_DATA_ENTRY, void**, PULONG);
NTSTATUS WINAPI LdrFindResourceDirectory_U(HMODULE, PLDR_RESOURCE_INFO, DWORD,
PIMAGE_RESOURCE_DIRECTORY_ENTRY*); PIMAGE_RESOURCE_DIRECTORY_ENTRY*);
NTSTATUS WINAPI LdrFindResource_U(HMODULE, PLDR_RESOURCE_INFO, ULONG, NTSTATUS WINAPI LdrFindResource_U(HMODULE, PLDR_RESOURCE_INFO, ULONG,
PIMAGE_RESOURCE_DATA_ENTRY*); PIMAGE_RESOURCE_DATA_ENTRY*);
NTSTATUS WINAPI LdrGetDllHandle(ULONG, ULONG, PUNICODE_STRING, HMODULE*);
NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE, PANSI_STRING, ULONG, void**);
NTSTATUS WINAPI LdrLoadDll(LPCWSTR, DWORD, PUNICODE_STRING, HMODULE*);
NTSTATUS WINAPI LdrLockLoaderLock(ULONG,ULONG*,ULONG*);
NTSTATUS WINAPI LdrShutdownProcess(void);
NTSTATUS WINAPI LdrShutdownThread(void);
NTSTATUS WINAPI LdrUnloadDll(HMODULE);
NTSTATUS WINAPI LdrUnlockLoaderLock(ULONG,ULONG);
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

View File

@ -948,9 +948,11 @@ DWORD WINAPI GetModuleFileNameA(
*/ */
DWORD WINAPI GetModuleFileNameW( HMODULE hModule, LPWSTR lpFileName, DWORD size ) DWORD WINAPI GetModuleFileNameW( HMODULE hModule, LPWSTR lpFileName, DWORD size )
{ {
ULONG magic;
lpFileName[0] = 0; lpFileName[0] = 0;
RtlEnterCriticalSection( &loader_section ); LdrLockLoaderLock( 0, NULL, &magic );
if (!hModule && !(NtCurrentTeb()->tibflags & TEBF_WIN32)) if (!hModule && !(NtCurrentTeb()->tibflags & TEBF_WIN32))
{ {
/* 16-bit task - get current NE module name */ /* 16-bit task - get current NE module name */
@ -974,7 +976,7 @@ DWORD WINAPI GetModuleFileNameW( HMODULE hModule, LPWSTR lpFileName, DWORD size
else SetLastError( RtlNtStatusToDosError( nts ) ); else SetLastError( RtlNtStatusToDosError( nts ) );
} }
RtlLeaveCriticalSection( &loader_section ); LdrUnlockLoaderLock( 0, magic );
TRACE( "%s\n", debugstr_w(lpFileName) ); TRACE( "%s\n", debugstr_w(lpFileName) );
return strlenW(lpFileName); return strlenW(lpFileName);