Commit cc9cfdff authored by Alexandre Julliard's avatar Alexandre Julliard

Removed a few dependencies on kernel32 functions.

parent baa15566
......@@ -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;
}
/******************************************************************************
......
......@@ -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;
}
......
......@@ -11,6 +11,7 @@
#include <math.h>
#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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment