From cc9cfdff795cb1dd4dd24c57dbde229d636ffea2 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 29 Sep 2000 00:31:57 +0000 Subject: [PATCH] Removed a few dependencies on kernel32 functions. --- dlls/ntdll/nt.c | 15 ++++++++++----- dlls/ntdll/rtl.c | 33 +++++++++++++++------------------ dlls/ntdll/sec.c | 31 ++++++++++++++++++++++--------- 3 files changed, 47 insertions(+), 32 deletions(-) diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c index 092a4e3689e..6b0bed5c084 100644 --- a/dlls/ntdll/nt.c +++ b/dlls/ntdll/nt.c @@ -584,12 +584,17 @@ NTSTATUS WINAPI NtCreatePagingFile( * * writes a string to the nt-textmode screen eg. during startup */ -NTSTATUS WINAPI NtDisplayString ( - PUNICODE_STRING string) +NTSTATUS WINAPI NtDisplayString ( PUNICODE_STRING string ) { - TRACE("%p(%s)\n",string->Buffer, debugstr_w(string->Buffer)); - WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), string->Buffer, string->Length, 0, 0); - return 0; + STRING stringA; + NTSTATUS ret; + + if (!(ret = RtlUnicodeStringToAnsiString( &stringA, string, TRUE ))) + { + MESSAGE( "%.*s", stringA.Length, stringA.Buffer ); + RtlFreeAnsiString( &stringA ); + } + return ret; } /****************************************************************************** diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c index 79c4fe03e00..3097148e08b 100644 --- a/dlls/ntdll/rtl.c +++ b/dlls/ntdll/rtl.c @@ -41,7 +41,7 @@ void WINAPI RtlInitializeResource(LPRTL_RWLOCK rwl) rwl->uSharedWaiters = 0; rwl->hOwningThreadId = 0; rwl->dwTimeoutBoost = 0; /* no info on this one, default value is 0 */ - InitializeCriticalSection( &rwl->rtlCS ); + RtlInitializeCriticalSection( &rwl->rtlCS ); NtCreateSemaphore( &rwl->hExclusiveReleaseSemaphore, 0, NULL, 0, 65535 ); NtCreateSemaphore( &rwl->hSharedReleaseSemaphore, 0, NULL, 0, 65535 ); } @@ -55,7 +55,7 @@ void WINAPI RtlDeleteResource(LPRTL_RWLOCK rwl) { if( rwl ) { - EnterCriticalSection( &rwl->rtlCS ); + RtlEnterCriticalSection( &rwl->rtlCS ); if( rwl->iNumberActive || rwl->uExclusiveWaiters || rwl->uSharedWaiters ) MESSAGE("Deleting active MRSW lock (%p), expect failure\n", rwl ); rwl->hOwningThreadId = 0; @@ -63,8 +63,8 @@ void WINAPI RtlDeleteResource(LPRTL_RWLOCK rwl) rwl->iNumberActive = 0; NtClose( rwl->hExclusiveReleaseSemaphore ); NtClose( rwl->hSharedReleaseSemaphore ); - LeaveCriticalSection( &rwl->rtlCS ); - DeleteCriticalSection( &rwl->rtlCS ); + RtlLeaveCriticalSection( &rwl->rtlCS ); + RtlDeleteCriticalSection( &rwl->rtlCS ); } } @@ -78,7 +78,7 @@ BYTE WINAPI RtlAcquireResourceExclusive(LPRTL_RWLOCK rwl, BYTE fWait) if( !rwl ) return 0; start: - EnterCriticalSection( &rwl->rtlCS ); + RtlEnterCriticalSection( &rwl->rtlCS ); if( rwl->iNumberActive == 0 ) /* lock is free */ { rwl->iNumberActive = -1; @@ -97,7 +97,7 @@ wait: { rwl->uExclusiveWaiters++; - LeaveCriticalSection( &rwl->rtlCS ); + RtlLeaveCriticalSection( &rwl->rtlCS ); if( WaitForSingleObject( rwl->hExclusiveReleaseSemaphore, INFINITE ) == WAIT_FAILED ) goto done; goto start; /* restart the acquisition to avoid deadlocks */ @@ -110,7 +110,7 @@ wait: if( retVal == 1 ) rwl->hOwningThreadId = GetCurrentThreadId(); done: - LeaveCriticalSection( &rwl->rtlCS ); + RtlLeaveCriticalSection( &rwl->rtlCS ); return retVal; } @@ -124,7 +124,7 @@ BYTE WINAPI RtlAcquireResourceShared(LPRTL_RWLOCK rwl, BYTE fWait) if( !rwl ) return 0; start: - EnterCriticalSection( &rwl->rtlCS ); + RtlEnterCriticalSection( &rwl->rtlCS ); if( rwl->iNumberActive < 0 ) { if( rwl->hOwningThreadId == GetCurrentThreadId() ) @@ -137,7 +137,7 @@ start: if( fWait ) { rwl->uSharedWaiters++; - LeaveCriticalSection( &rwl->rtlCS ); + RtlLeaveCriticalSection( &rwl->rtlCS ); if( (dwWait = WaitForSingleObject( rwl->hSharedReleaseSemaphore, INFINITE )) == WAIT_FAILED ) goto done; goto start; @@ -150,7 +150,7 @@ start: retVal = 1; } done: - LeaveCriticalSection( &rwl->rtlCS ); + RtlLeaveCriticalSection( &rwl->rtlCS ); return retVal; } @@ -160,7 +160,7 @@ done: */ void WINAPI RtlReleaseResource(LPRTL_RWLOCK rwl) { - EnterCriticalSection( &rwl->rtlCS ); + RtlEnterCriticalSection( &rwl->rtlCS ); if( rwl->iNumberActive > 0 ) /* have one or more readers */ { @@ -193,7 +193,7 @@ wake_exclusive: } } } - LeaveCriticalSection( &rwl->rtlCS ); + RtlLeaveCriticalSection( &rwl->rtlCS ); } @@ -421,12 +421,9 @@ LARGE_INTEGER WINAPI RtlExtendedIntegerMultiply( BOOLEAN WINAPI RtlDosPathNameToNtPathName_U( LPWSTR from,PUNICODE_STRING us,DWORD x2,DWORD x3) { - LPSTR fromA = HEAP_strdupWtoA(GetProcessHeap(),0,from); - - FIXME("(%s,%p,%08lx,%08lx)\n",fromA,us,x2,x3); - if (us) - RtlInitUnicodeString(us,HEAP_strdupW(GetProcessHeap(),0,from)); - return TRUE; + FIXME("(%s,%p,%08lx,%08lx)\n",debugstr_w(from),us,x2,x3); + if (us) RtlCreateUnicodeString( us, from ); + return TRUE; } diff --git a/dlls/ntdll/sec.c b/dlls/ntdll/sec.c index 7ff4bb16bff..8ca732966cf 100644 --- a/dlls/ntdll/sec.c +++ b/dlls/ntdll/sec.c @@ -11,6 +11,7 @@ #include #include "windef.h" #include "winbase.h" +#include "wine/exception.h" #include "wine/winestring.h" #include "file.h" #include "heap.h" @@ -27,6 +28,14 @@ DEFAULT_DEBUG_CHANNEL(ntdll); #define NT_SUCCESS(status) (status == STATUS_SUCCESS) +/* filter for page-fault exceptions */ +static WINE_EXCEPTION_FILTER(page_fault) +{ + if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION) + return EXCEPTION_EXECUTE_HANDLER; + return EXCEPTION_CONTINUE_SEARCH; +} + /* * SID FUNCTIONS */ @@ -226,19 +235,23 @@ DWORD WINAPI RtlCopySid( DWORD nDestinationSidLength, PSID pDestinationSid, PSID BOOL WINAPI RtlValidSid( PSID pSid ) { - if (IsBadReadPtr(pSid, 4)) + BOOL ret; + __TRY + { + ret = TRUE; + if (!pSid || pSid->Revision != SID_REVISION || + pSid->SubAuthorityCount > SID_MAX_SUB_AUTHORITIES) + { + ret = FALSE; + } + } + __EXCEPT(page_fault) { WARN("(%p): invalid pointer!\n", pSid); return FALSE; } - - if (pSid->SubAuthorityCount > SID_MAX_SUB_AUTHORITIES) - return FALSE; - - if (!pSid || pSid->Revision != SID_REVISION) - return FALSE; - - return TRUE; + __ENDTRY + return ret; }