Removed a few dependencies on kernel32 functions.

This commit is contained in:
Alexandre Julliard 2000-09-29 00:31:57 +00:00
parent baa15566a0
commit cc9cfdff79
3 changed files with 47 additions and 32 deletions

View File

@ -584,12 +584,17 @@ NTSTATUS WINAPI NtCreatePagingFile(
* *
* writes a string to the nt-textmode screen eg. during startup * writes a string to the nt-textmode screen eg. during startup
*/ */
NTSTATUS WINAPI NtDisplayString ( NTSTATUS WINAPI NtDisplayString ( PUNICODE_STRING string )
PUNICODE_STRING string)
{ {
TRACE("%p(%s)\n",string->Buffer, debugstr_w(string->Buffer)); STRING stringA;
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), string->Buffer, string->Length, 0, 0); NTSTATUS ret;
return 0;
if (!(ret = RtlUnicodeStringToAnsiString( &stringA, string, TRUE )))
{
MESSAGE( "%.*s", stringA.Length, stringA.Buffer );
RtlFreeAnsiString( &stringA );
}
return ret;
} }
/****************************************************************************** /******************************************************************************

View File

@ -41,7 +41,7 @@ void WINAPI RtlInitializeResource(LPRTL_RWLOCK rwl)
rwl->uSharedWaiters = 0; rwl->uSharedWaiters = 0;
rwl->hOwningThreadId = 0; rwl->hOwningThreadId = 0;
rwl->dwTimeoutBoost = 0; /* no info on this one, default value is 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->hExclusiveReleaseSemaphore, 0, NULL, 0, 65535 );
NtCreateSemaphore( &rwl->hSharedReleaseSemaphore, 0, NULL, 0, 65535 ); NtCreateSemaphore( &rwl->hSharedReleaseSemaphore, 0, NULL, 0, 65535 );
} }
@ -55,7 +55,7 @@ void WINAPI RtlDeleteResource(LPRTL_RWLOCK rwl)
{ {
if( rwl ) if( rwl )
{ {
EnterCriticalSection( &rwl->rtlCS ); RtlEnterCriticalSection( &rwl->rtlCS );
if( rwl->iNumberActive || rwl->uExclusiveWaiters || rwl->uSharedWaiters ) if( rwl->iNumberActive || rwl->uExclusiveWaiters || rwl->uSharedWaiters )
MESSAGE("Deleting active MRSW lock (%p), expect failure\n", rwl ); MESSAGE("Deleting active MRSW lock (%p), expect failure\n", rwl );
rwl->hOwningThreadId = 0; rwl->hOwningThreadId = 0;
@ -63,8 +63,8 @@ void WINAPI RtlDeleteResource(LPRTL_RWLOCK rwl)
rwl->iNumberActive = 0; rwl->iNumberActive = 0;
NtClose( rwl->hExclusiveReleaseSemaphore ); NtClose( rwl->hExclusiveReleaseSemaphore );
NtClose( rwl->hSharedReleaseSemaphore ); NtClose( rwl->hSharedReleaseSemaphore );
LeaveCriticalSection( &rwl->rtlCS ); RtlLeaveCriticalSection( &rwl->rtlCS );
DeleteCriticalSection( &rwl->rtlCS ); RtlDeleteCriticalSection( &rwl->rtlCS );
} }
} }
@ -78,7 +78,7 @@ BYTE WINAPI RtlAcquireResourceExclusive(LPRTL_RWLOCK rwl, BYTE fWait)
if( !rwl ) return 0; if( !rwl ) return 0;
start: start:
EnterCriticalSection( &rwl->rtlCS ); RtlEnterCriticalSection( &rwl->rtlCS );
if( rwl->iNumberActive == 0 ) /* lock is free */ if( rwl->iNumberActive == 0 ) /* lock is free */
{ {
rwl->iNumberActive = -1; rwl->iNumberActive = -1;
@ -97,7 +97,7 @@ wait:
{ {
rwl->uExclusiveWaiters++; rwl->uExclusiveWaiters++;
LeaveCriticalSection( &rwl->rtlCS ); RtlLeaveCriticalSection( &rwl->rtlCS );
if( WaitForSingleObject( rwl->hExclusiveReleaseSemaphore, INFINITE ) == WAIT_FAILED ) if( WaitForSingleObject( rwl->hExclusiveReleaseSemaphore, INFINITE ) == WAIT_FAILED )
goto done; goto done;
goto start; /* restart the acquisition to avoid deadlocks */ goto start; /* restart the acquisition to avoid deadlocks */
@ -110,7 +110,7 @@ wait:
if( retVal == 1 ) if( retVal == 1 )
rwl->hOwningThreadId = GetCurrentThreadId(); rwl->hOwningThreadId = GetCurrentThreadId();
done: done:
LeaveCriticalSection( &rwl->rtlCS ); RtlLeaveCriticalSection( &rwl->rtlCS );
return retVal; return retVal;
} }
@ -124,7 +124,7 @@ BYTE WINAPI RtlAcquireResourceShared(LPRTL_RWLOCK rwl, BYTE fWait)
if( !rwl ) return 0; if( !rwl ) return 0;
start: start:
EnterCriticalSection( &rwl->rtlCS ); RtlEnterCriticalSection( &rwl->rtlCS );
if( rwl->iNumberActive < 0 ) if( rwl->iNumberActive < 0 )
{ {
if( rwl->hOwningThreadId == GetCurrentThreadId() ) if( rwl->hOwningThreadId == GetCurrentThreadId() )
@ -137,7 +137,7 @@ start:
if( fWait ) if( fWait )
{ {
rwl->uSharedWaiters++; rwl->uSharedWaiters++;
LeaveCriticalSection( &rwl->rtlCS ); RtlLeaveCriticalSection( &rwl->rtlCS );
if( (dwWait = WaitForSingleObject( rwl->hSharedReleaseSemaphore, INFINITE )) == WAIT_FAILED ) if( (dwWait = WaitForSingleObject( rwl->hSharedReleaseSemaphore, INFINITE )) == WAIT_FAILED )
goto done; goto done;
goto start; goto start;
@ -150,7 +150,7 @@ start:
retVal = 1; retVal = 1;
} }
done: done:
LeaveCriticalSection( &rwl->rtlCS ); RtlLeaveCriticalSection( &rwl->rtlCS );
return retVal; return retVal;
} }
@ -160,7 +160,7 @@ done:
*/ */
void WINAPI RtlReleaseResource(LPRTL_RWLOCK rwl) void WINAPI RtlReleaseResource(LPRTL_RWLOCK rwl)
{ {
EnterCriticalSection( &rwl->rtlCS ); RtlEnterCriticalSection( &rwl->rtlCS );
if( rwl->iNumberActive > 0 ) /* have one or more readers */ 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( BOOLEAN WINAPI RtlDosPathNameToNtPathName_U(
LPWSTR from,PUNICODE_STRING us,DWORD x2,DWORD x3) LPWSTR from,PUNICODE_STRING us,DWORD x2,DWORD x3)
{ {
LPSTR fromA = HEAP_strdupWtoA(GetProcessHeap(),0,from); FIXME("(%s,%p,%08lx,%08lx)\n",debugstr_w(from),us,x2,x3);
if (us) RtlCreateUnicodeString( us, from );
FIXME("(%s,%p,%08lx,%08lx)\n",fromA,us,x2,x3); return TRUE;
if (us)
RtlInitUnicodeString(us,HEAP_strdupW(GetProcessHeap(),0,from));
return TRUE;
} }

View File

@ -11,6 +11,7 @@
#include <math.h> #include <math.h>
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "wine/exception.h"
#include "wine/winestring.h" #include "wine/winestring.h"
#include "file.h" #include "file.h"
#include "heap.h" #include "heap.h"
@ -27,6 +28,14 @@ DEFAULT_DEBUG_CHANNEL(ntdll);
#define NT_SUCCESS(status) (status == STATUS_SUCCESS) #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 * SID FUNCTIONS
*/ */
@ -226,19 +235,23 @@ DWORD WINAPI RtlCopySid( DWORD nDestinationSidLength, PSID pDestinationSid, PSID
BOOL WINAPI BOOL WINAPI
RtlValidSid( PSID pSid ) 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); WARN("(%p): invalid pointer!\n", pSid);
return FALSE; return FALSE;
} }
__ENDTRY
if (pSid->SubAuthorityCount > SID_MAX_SUB_AUTHORITIES) return ret;
return FALSE;
if (!pSid || pSid->Revision != SID_REVISION)
return FALSE;
return TRUE;
} }