some __stdcall fixes in ntoskrnl and ntdll

svn path=/trunk/; revision=629
This commit is contained in:
Emanuele Aliberti 1999-08-29 06:59:11 +00:00
parent 5aaaad5c93
commit fa3a5c2c71
35 changed files with 3547 additions and 1632 deletions

View file

@ -1,16 +1,53 @@
#ifndef _NTOS_EXFUNCS_H
#define _NTOS_EXFUNCS_H
/* EXECUTIVE ROUTINES ******************************************************/
VOID ExAcquireFastMutex(PFAST_MUTEX FastMutex);
VOID ExAcquireFastMutexUnsafe(PFAST_MUTEX FastMutex);
BOOLEAN ExAcquireResourceExclusive(PERESOURCE Resource, BOOLEAN Wait);
BOOLEAN ExAcquireResourceExclusiveLite(PERESOURCE Resource, BOOLEAN Wait);
BOOLEAN ExAcquireResourceSharedLite(PERESOURCE Resource, BOOLEAN Wait);
BOOLEAN ExAcquireSharedStarveExclusive(PERESOURCE Resource, BOOLEAN Wait);
BOOLEAN ExAcquireSharedWaitForExclusive(PERESOURCE Resource, BOOLEAN Wait);
PVOID ExAllocateFromNPagedLookasideList(PNPAGED_LOOKASIDE_LIST LookSide);
PVOID ExAllocateFromPagedLookasideList(PPAGED_LOOKASIDE_LIST LookSide);
PVOID ExAllocateFromZone(PZONE_HEADER Zone);
VOID
ExAcquireFastMutex (
PFAST_MUTEX FastMutex
);
VOID
ExAcquireFastMutexUnsafe (
PFAST_MUTEX FastMutex
);
BOOLEAN
ExAcquireResourceExclusive (
PERESOURCE Resource,
BOOLEAN Wait
);
BOOLEAN
ExAcquireResourceExclusiveLite (
PERESOURCE Resource,
BOOLEAN Wait
);
BOOLEAN
ExAcquireResourceSharedLite (
PERESOURCE Resource,
BOOLEAN Wait
);
BOOLEAN
ExAcquireSharedStarveExclusive (
PERESOURCE Resource,
BOOLEAN Wait
);
BOOLEAN
ExAcquireSharedWaitForExclusive (
PERESOURCE Resource,
BOOLEAN Wait
);
PVOID
ExAllocateFromNPagedLookasideList (
PNPAGED_LOOKASIDE_LIST LookSide
);
PVOID
ExAllocateFromPagedLookasideList (
PPAGED_LOOKASIDE_LIST LookSide
);
PVOID
ExAllocateFromZone (
PZONE_HEADER Zone
);
/*
* FUNCTION: Allocates memory from the nonpaged pool
@ -20,133 +57,371 @@ PVOID ExAllocateFromZone(PZONE_HEADER Zone);
* RETURNS:
* the address of the block if it succeeds
*/
PVOID ExAllocatePool(POOL_TYPE PoolType, ULONG size);
PVOID
ExAllocatePool (
POOL_TYPE PoolType,
ULONG size
);
PVOID ExAllocatePoolWithQuota(POOL_TYPE PoolType, ULONG NumberOfBytes);
PVOID ExAllocatePoolWithQuotaTag(POOL_TYPE PoolType, ULONG NumberOfBytes,
ULONG Tag);
PVOID ExAllocatePoolWithTag(POOL_TYPE PoolType, ULONG NumberOfBytes,
ULONG Tag);
VOID ExConvertExclusiveToSharedLite(PERESOURCE Resource);
VOID ExDeleteNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside);
VOID ExDeletePagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside);
NTSTATUS ExDeleteResource(PERESOURCE Resource);
NTSTATUS ExDeleteResourceLite(PERESOURCE Resource);
NTSTATUS ExExtendZone(PZONE_HEADER Zone, PVOID Segment, ULONG SegmentSize);
PVOID
ExAllocatePoolWithQuota (
POOL_TYPE PoolType,
ULONG NumberOfBytes
);
PVOID
ExAllocatePoolWithQuotaTag (
POOL_TYPE PoolType,
ULONG NumberOfBytes,
ULONG Tag
);
PVOID
ExAllocatePoolWithTag (
POOL_TYPE PoolType,
ULONG NumberOfBytes,
ULONG Tag
);
VOID
ExConvertExclusiveToSharedLite (
PERESOURCE Resource
);
VOID
ExDeleteNPagedLookasideList (
PNPAGED_LOOKASIDE_LIST Lookaside
);
VOID
ExDeletePagedLookasideList (
PPAGED_LOOKASIDE_LIST Lookaside
);
NTSTATUS
ExDeleteResource (
PERESOURCE Resource
);
NTSTATUS
ExDeleteResourceLite (
PERESOURCE Resource
);
NTSTATUS
ExExtendZone (
PZONE_HEADER Zone,
PVOID Segment,
ULONG SegmentSize
);
/*
* FUNCTION: Releases previously allocated memory
* ARGUMENTS:
* block = block to free
*/
VOID ExFreePool(PVOID block);
VOID
ExFreePool (
PVOID block
);
VOID ExFreeToNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside,
PVOID Entry);
VOID ExFreeToPagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside,
PVOID Entry);
PVOID ExFreeToZone(PZONE_HEADER Zone, PVOID Block);
ERESOURCE_THREAD ExGetCurrentResourceThread(VOID);
ULONG ExGetExclusiveWaiterCount(PERESOURCE Resource);
ULONG ExGetSharedWaiterCount(PERESOURCE Resource);
VOID ExInitializeFastMutex(PFAST_MUTEX FastMutex);
VOID ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside,
VOID
ExFreeToNPagedLookasideList (
PNPAGED_LOOKASIDE_LIST Lookaside,
PVOID Entry
);
VOID
ExFreeToPagedLookasideList (
PPAGED_LOOKASIDE_LIST Lookaside,
PVOID Entry
);
PVOID
ExFreeToZone (
PZONE_HEADER Zone,
PVOID Block
);
ERESOURCE_THREAD
ExGetCurrentResourceThread (
VOID
);
ULONG
ExGetExclusiveWaiterCount (
PERESOURCE Resource
);
ULONG
ExGetSharedWaiterCount (
PERESOURCE Resource
);
VOID
ExInitializeFastMutex (
PFAST_MUTEX FastMutex
);
VOID
ExInitializeNPagedLookasideList (
PNPAGED_LOOKASIDE_LIST Lookaside,
PALLOCATE_FUNCTION Allocate,
PFREE_FUNCTION Free,
ULONG Flags,
ULONG Size,
ULONG Tag,
USHORT Depth);
VOID ExInitializePagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside,
USHORT Depth
);
VOID
ExInitializePagedLookasideList (
PPAGED_LOOKASIDE_LIST Lookaside,
PALLOCATE_FUNCTION Allocate,
PFREE_FUNCTION Free,
ULONG Flags,
ULONG Size,
ULONG Tag,
USHORT Depth);
NTSTATUS ExInitializeResource(PERESOURCE Resource);
NTSTATUS ExInitializeResourceLite(PERESOURCE Resource);
VOID ExInitializeSListHead(PSLIST_HEADER SListHead);
VOID ExInitializeWorkItem(PWORK_QUEUE_ITEM Item,
USHORT Depth
);
NTSTATUS
ExInitializeResource (
PERESOURCE Resource
);
NTSTATUS
ExInitializeResourceLite (
PERESOURCE Resource
);
VOID
ExInitializeSListHead (
PSLIST_HEADER SListHead
);
VOID
ExInitializeWorkItem (
PWORK_QUEUE_ITEM Item,
PWORKER_THREAD_ROUTINE Routine,
PVOID Context);
NTSTATUS ExInitializeZone(PZONE_HEADER Zone,
PVOID Context
);
NTSTATUS
ExInitializeZone (
PZONE_HEADER Zone,
ULONG BlockSize,
PVOID InitialSegment,
ULONG InitialSegmentSize);
LARGE_INTEGER ExInterlockedAddLargeInteger(PLARGE_INTEGER Addend,
ULONG InitialSegmentSize
);
LARGE_INTEGER
ExInterlockedAddLargeInteger (
PLARGE_INTEGER Addend,
LARGE_INTEGER Increment,
PKSPIN_LOCK Lock);
ULONG ExInterlockedAddUlong(PULONG Addend, ULONG Increment, PKSPIN_LOCK Lock);
PKSPIN_LOCK Lock
);
ULONG
ExInterlockedAddUlong (
PULONG Addend,
ULONG Increment,
PKSPIN_LOCK Lock
);
VOID ExInterlockedRemoveEntryList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry,
PKSPIN_LOCK Lock);
VOID RemoveEntryFromList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry);
PLIST_ENTRY ExInterlockedRemoveHeadList(PLIST_ENTRY Head, PKSPIN_LOCK Lock);
PLIST_ENTRY ExInterlockedInsertTailList(PLIST_ENTRY ListHead,
VOID
ExInterlockedRemoveEntryList (
PLIST_ENTRY ListHead,
PLIST_ENTRY Entry,
PKSPIN_LOCK Lock
);
VOID
RemoveEntryFromList (
PLIST_ENTRY ListHead,
PLIST_ENTRY Entry
);
PLIST_ENTRY
ExInterlockedRemoveHeadList (
PLIST_ENTRY Head,
PKSPIN_LOCK Lock
);
PLIST_ENTRY
ExInterlockedInsertTailList (
PLIST_ENTRY ListHead,
PLIST_ENTRY ListEntry,
PKSPIN_LOCK Lock);
PLIST_ENTRY ExInterlockedInsertHeadList(PLIST_ENTRY ListHead,
PKSPIN_LOCK Lock
);
PLIST_ENTRY
ExInterlockedInsertHeadList (
PLIST_ENTRY ListHead,
PLIST_ENTRY ListEntry,
PKSPIN_LOCK Lock);
VOID ExQueueWorkItem(PWORK_QUEUE_ITEM WorkItem,
WORK_QUEUE_TYPE QueueType);
VOID ExRaiseStatus(NTSTATUS Status);
VOID ExReinitializeResourceLite(PERESOURCE Resource);
VOID ExReleaseFastMutex(PFAST_MUTEX Mutex);
VOID ExReleaseFastMutexUnsafe(PFAST_MUTEX Mutex);
VOID ExReleaseResource(PERESOURCE Resource);
VOID ExReleaseResourceForThread(PERESOURCE Resource,
ERESOURCE_THREAD ResourceThreadId);
VOID ExReleaseResourceForThreadLite(PERESOURCE Resource,
ERESOURCE_THREAD ResourceThreadId);
VOID ExSystemTimeToLocalTime(PLARGE_INTEGER SystemTime,
PLARGE_INTEGER LocalTime);
BOOLEAN ExTryToAcquireFastMutex(PFAST_MUTEX FastMutex);
BOOLEAN ExTryToAcquireResourceExclusiveLite(PERESOURCE Resource);
PVOID InterlockedCompareExchange(PVOID* Destination,
PKSPIN_LOCK Lock
);
VOID
ExQueueWorkItem (
PWORK_QUEUE_ITEM WorkItem,
WORK_QUEUE_TYPE QueueType
);
VOID
ExRaiseStatus (
NTSTATUS Status
);
VOID
ExReinitializeResourceLite (
PERESOURCE Resource
);
VOID
ExReleaseFastMutex (
PFAST_MUTEX Mutex
);
VOID
ExReleaseFastMutexUnsafe (
PFAST_MUTEX Mutex
);
VOID
ExReleaseResource (
PERESOURCE Resource
);
VOID
ExReleaseResourceForThread (
PERESOURCE Resource,
ERESOURCE_THREAD ResourceThreadId
);
VOID
ExReleaseResourceForThreadLite (
PERESOURCE Resource,
ERESOURCE_THREAD ResourceThreadId
);
VOID
ExSystemTimeToLocalTime (
PLARGE_INTEGER SystemTime,
PLARGE_INTEGER LocalTime
);
BOOLEAN
ExTryToAcquireFastMutex (
PFAST_MUTEX FastMutex
);
BOOLEAN
ExTryToAcquireResourceExclusiveLite (
PERESOURCE Resource
);
/*
LONG
FASTCALL
InterlockedCompareExchange (
PLONG Target,
LONG Value,
LONG Reference
);
*/
PVOID
FASTCALL
InterlockedCompareExchange (
PVOID * Destination,
PVOID Exchange,
PVOID Comperand);
LONG InterlockedDecrement(PLONG Addend);
LONG InterlockedExchange(PLONG Target, LONG Value);
LONG InterlockedExchangeAdd(PLONG Addend, LONG Value);
LONG InterlockedIncrement(PLONG Addend);
PVOID ExInterlockedAllocateFromZone(PZONE_HEADER Zone, PKSPIN_LOCK Lock);
PVOID ExInterlockedFreeToZone(PZONE_HEADER Zone, PVOID Block,
PKSPIN_LOCK Lock);
NTSTATUS ExInterlockedExtendZone(PZONE_HEADER Zone, PVOID Segment,
ULONG SegmentSize, PKSPIN_LOCK Lock);
PSINGLE_LIST_ENTRY ExInterlockedPopEntryList(PSINGLE_LIST_ENTRY ListHead,
PKSPIN_LOCK Lock);
PSINGLE_LIST_ENTRY ExInterlockedPushEntryList(PSINGLE_LIST_ENTRY ListHead,
PVOID Comperand
);
#ifdef _GNU_H_WINDOWS_H
#ifdef InterlockedDecrement
#undef InterlockedDecrement
#undef InterlockedExchange
#undef InterlockedExchangeAdd
#undef InterlockedIncrement
#endif /* def InterlockedDecrement */
#endif /* def _GNU_H_WINDOWS_H */
LONG
FASTCALL
InterlockedDecrement (
PLONG Addend
);
LONG
FASTCALL
InterlockedExchange (
PLONG Target,
LONG Value
);
LONG
FASTCALL
InterlockedExchangeAdd (
PLONG Addend,
LONG Value
);
LONG
FASTCALL
InterlockedIncrement (
PLONG Addend
);
/*---*/
PVOID
ExInterlockedAllocateFromZone (
PZONE_HEADER Zone,
PKSPIN_LOCK Lock
);
PVOID
ExInterlockedFreeToZone (
PZONE_HEADER Zone,
PVOID Block,
PKSPIN_LOCK Lock
);
NTSTATUS
ExInterlockedExtendZone (
PZONE_HEADER Zone,
PVOID Segment,
ULONG SegmentSize,
PKSPIN_LOCK Lock
);
PSINGLE_LIST_ENTRY
ExInterlockedPopEntryList (
PSINGLE_LIST_ENTRY ListHead,
PKSPIN_LOCK Lock
);
PSINGLE_LIST_ENTRY
ExInterlockedPushEntryList (
PSINGLE_LIST_ENTRY ListHead,
PSINGLE_LIST_ENTRY ListEntry,
PKSPIN_LOCK Lock);
PSINGLE_LIST_ENTRY ExInterlockedPushEntrySList(PSLIST_HEADER ListHead,
PKSPIN_LOCK Lock
);
PSINGLE_LIST_ENTRY
ExInterlockedPushEntrySList (
PSLIST_HEADER ListHead,
PSINGLE_LIST_ENTRY ListEntry,
PKSPIN_LOCK Lock);
PSINGLE_LIST_ENTRY ExInterlockedPopEntrySList(PSLIST_HEADER ListHead,
PKSPIN_LOCK Lock);
BOOLEAN ExIsFullZone(PZONE_HEADER Zone);
BOOLEAN ExIsObjectInFirstZoneSegment(PZONE_HEADER Zone, PVOID Object);
VOID ExLocalTimeToSystemTime(PLARGE_INTEGER LocalTime,
PLARGE_INTEGER SystemTime);
PKSPIN_LOCK Lock
);
PSINGLE_LIST_ENTRY
ExInterlockedPopEntrySList (
PSLIST_HEADER ListHead,
PKSPIN_LOCK Lock
);
BOOLEAN
ExIsFullZone (
PZONE_HEADER Zone
);
BOOLEAN
ExIsObjectInFirstZoneSegment (
PZONE_HEADER Zone,
PVOID Object
);
VOID
ExLocalTimeToSystemTime (
PLARGE_INTEGER LocalTime,
PLARGE_INTEGER SystemTime
);
typedef unsigned int (exception_hook)(CONTEXT* c, unsigned int exp);
unsigned int ExHookException(exception_hook fn, unsigned int exp);
INTERLOCKED_RESULT ExInterlockedDecrementLong(PLONG Addend,
PKSPIN_LOCK Lock);
ULONG ExInterlockedExchangeUlong(PULONG Target,
typedef
unsigned int
(exception_hook) (
CONTEXT * c,
unsigned int exp
);
unsigned int
ExHookException (
exception_hook fn,
unsigned int exp
);
INTERLOCKED_RESULT
ExInterlockedDecrementLong (
PLONG Addend,
PKSPIN_LOCK Lock
);
ULONG
ExInterlockedExchangeUlong (
PULONG Target,
ULONG Value,
PKSPIN_LOCK Lock);
INTERLOCKED_RESULT ExInterlockedIncrementLong(PLONG Addend,
PKSPIN_LOCK Lock);
BOOLEAN ExIsResourceAcquiredExclusiveLite(PERESOURCE Resource);
ULONG ExIsResourceAcquiredSharedLite(PERESOURCE Resource);
USHORT ExQueryDepthSListHead(PSLIST_HEADER SListHead);
PKSPIN_LOCK Lock
);
INTERLOCKED_RESULT
ExInterlockedIncrementLong (
PLONG Addend,
PKSPIN_LOCK Lock
);
BOOLEAN
ExIsResourceAcquiredExclusiveLite (
PERESOURCE Resource
);
ULONG
ExIsResourceAcquiredSharedLite (
PERESOURCE Resource
);
USHORT
ExQueryDepthSListHead (
PSLIST_HEADER SListHead
);
#endif /* ndef _NTOS_EXFUNCS_H */

View file

@ -370,6 +370,7 @@ IoCreateNotificationEvent (
);
NTSTATUS
STDCALL
IoCreateSymbolicLink (
PUNICODE_STRING SymbolicLinkName,
PUNICODE_STRING DeviceName
@ -382,6 +383,7 @@ IoCreateSynchronizationEvent (
);
NTSTATUS
STDCALL
IoCreateUnprotectedSymbolicLink (
PUNICODE_STRING SymbolicLinkName,
PUNICODE_STRING DeviceName
@ -404,6 +406,7 @@ IoDeleteDevice (
);
NTSTATUS
STDCALL
IoDeleteSymbolicLink (
PUNICODE_STRING SymbolicLinkName
);

View file

@ -20,6 +20,11 @@ extern "C"
#include <windows.h>
/* GCC can not handle __fastcall */
#ifndef FASTCALL
#define FASTCALL STDCALL
#endif
#include <internal/id.h>
#include <ddk/status.h>
#include <ddk/ntdef.h>

View file

@ -200,6 +200,7 @@ RtlCharToInteger (
);
NTSTATUS
STDCALL
RtlCheckRegistryKey (
ULONG RelativeTo,
PWSTR Path
@ -263,6 +264,7 @@ RtlCopyUnicodeString (
);
NTSTATUS
STDCALL
RtlCreateRegistryKey (
ULONG RelativeTo,
PWSTR Path
@ -275,6 +277,7 @@ RtlCreateSecurityDescriptor (
);
NTSTATUS
STDCALL
RtlDeleteRegistryValue (
ULONG RelativeTo,
PWSTR Path,
@ -575,6 +578,7 @@ RtlMoveMemory (
);
NTSTATUS
STDCALL
RtlQueryRegistryValues (
ULONG RelativeTo,
PWSTR Path,
@ -713,6 +717,7 @@ RtlValidSecurityDescriptor (
);
NTSTATUS
STDCALL
RtlWriteRegistryValue (
ULONG RelativeTo,
PWSTR Path,
@ -768,6 +773,7 @@ RtlUnlockHeap (
);
UINT
STDCALL
RtlCompactHeap (
HANDLE hheap,
DWORD flags

View file

@ -1,4 +1,4 @@
/* $Id: zw.h,v 1.17 1999/07/22 21:29:46 ekohl Exp $
/* $Id: zw.h,v 1.18 1999/08/29 06:58:59 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel

View file

@ -1,10 +1,36 @@
VOID WINAPI __RtlInitHeap(PVOID base, ULONG minsize, ULONG maxsize);
VOID
WINAPI
__RtlInitHeap (
PVOID base,
ULONG minsize,
ULONG maxsize
);
#define HEAP_BASE (0xa0000000)
VOID RtlDeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
VOID RtlEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
VOID RtlInitializeCriticalSection(LPCRITICAL_SECTION pcritical);
VOID RtlLeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
WINBOOL RtlTryEntryCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
DWORD WINAPI RtlCompactHeap( HANDLE heap, DWORD flags );
VOID
RtlDeleteCriticalSection (
LPCRITICAL_SECTION lpCriticalSection
);
VOID
RtlEnterCriticalSection (
LPCRITICAL_SECTION lpCriticalSection
);
VOID
RtlInitializeCriticalSection (
LPCRITICAL_SECTION pcritical
);
VOID
RtlLeaveCriticalSection (
LPCRITICAL_SECTION lpCriticalSection
);
WINBOOL
RtlTryEntryCriticalSection (
LPCRITICAL_SECTION lpCriticalSection
);
UINT
STDCALL
RtlCompactHeap (
HANDLE heap,
DWORD flags
);

View file

@ -7,7 +7,7 @@
#define RES_UINT_FV_MINOR 0
#define RES_UINT_FV_REVISION 14
/* Build number as YYYYMMDD */
#define RES_UINT_FV_BUILD 19990717
#define RES_UINT_FV_BUILD 19990828
/* ReactOS Product Version UINTs */

View file

@ -1,4 +1,5 @@
/*
/* $Id: find.c,v 1.21 1999/08/29 06:59:01 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/kernel32/file/find.c
@ -178,7 +179,10 @@ HANDLE STDCALL InternalFindFirstFile(LPCWSTR lpFileName,
return(IData);
}
HANDLE FindFirstFileA(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData)
HANDLE
STDCALL
FindFirstFileA(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData)
{
WCHAR lpFileNameW[MAX_PATH];
ULONG i;
@ -227,7 +231,10 @@ HANDLE FindFirstFileA(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData)
return(IData);
}
WINBOOL FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATA lpFindFileData)
WINBOOL
STDCALL
FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATA lpFindFileData)
{
PWIN32_FIND_DATA_ASCII Ret;
PKERNEL32_FIND_FILE_DATA IData;
@ -265,7 +272,10 @@ WINBOOL FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATA lpFindFileData)
return(TRUE);
}
BOOL FindClose(HANDLE hFindFile)
BOOL
STDCALL
FindClose(HANDLE hFindFile)
{
PKERNEL32_FIND_FILE_DATA IData;
@ -282,8 +292,13 @@ BOOL FindClose(HANDLE hFindFile)
return(TRUE);
}
HANDLE STDCALL FindFirstFileW(LPCWSTR lpFileName,
LPWIN32_FIND_DATA lpFindFileData)
HANDLE
STDCALL
FindFirstFileW (
LPCWSTR lpFileName,
LPWIN32_FIND_DATA lpFindFileData
)
{
PWIN32_FIND_DATA_UNICODE Ret;
PKERNEL32_FIND_FILE_DATA IData;
@ -299,8 +314,13 @@ HANDLE STDCALL FindFirstFileW(LPCWSTR lpFileName,
return(IData);
}
WINBOOL STDCALL FindNextFileW(HANDLE hFindFile,
LPWIN32_FIND_DATA lpFindFileData)
WINBOOL
STDCALL
FindNextFileW (
HANDLE hFindFile,
LPWIN32_FIND_DATA lpFindFileData
)
{
PWIN32_FIND_DATA_UNICODE Ret;
PKERNEL32_FIND_FILE_DATA IData;
@ -320,3 +340,6 @@ WINBOOL STDCALL FindNextFileW(HANDLE hFindFile,
return(TRUE);
}
/* EOF */

View file

@ -1,4 +1,5 @@
/*
/* $Id: lfile.c,v 1.4 1999/08/29 06:59:01 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/kernel32/file/lfile.c
@ -16,46 +17,83 @@
long _hread(
long
STDCALL
_hread(
HFILE hFile,
LPVOID lpBuffer,
long lBytes
)
{
DWORD NumberOfBytesRead;
if ( ReadFile((HANDLE)hFile,(LPVOID)lpBuffer,(DWORD)lBytes,&NumberOfBytesRead, NULL) == FALSE )
return -1;
else
return NumberOfBytesRead;
}
UINT STDCALL _lread(HFILE fd,LPVOID buffer,UINT count)
if (ReadFile(
(HANDLE) hFile,
(LPVOID) lpBuffer,
(DWORD) lBytes,
& NumberOfBytesRead,
NULL
) == FALSE)
{
return _hread(fd,buffer, count);
return -1;
}
return NumberOfBytesRead;
}
long _hwrite(
/*
//19990828.EA: aliased in DEF
UINT
STDCALL
_lread (
HFILE fd,
LPVOID buffer,
UINT count
)
{
return _hread(
fd,
buffer,
count
);
}
*/
long
STDCALL
_hwrite (
HFILE hFile,
LPCSTR lpBuffer,
long lBytes
)
{
DWORD NumberOfBytesWritten;
if ( lBytes == 0 ) {
if (lBytes == 0)
{
if ( SetEndOfFile((HANDLE) hFile ) == FALSE )
{
return -1;
else
}
return 0;
}
if ( WriteFile((HANDLE)hFile,(LPVOID)lpBuffer,(DWORD)lBytes, &NumberOfBytesWritten,NULL) == FALSE )
if ( WriteFile(
(HANDLE) hFile,
(LPVOID) lpBuffer,
(DWORD) lBytes,
& NumberOfBytesWritten,
NULL
) == FALSE )
{
return -1;
else
return NumberOfBytesWritten;
}
return NumberOfBytesWritten;
}
/*
//19990828.EA: aliased in DEF
UINT
STDCALL
@ -67,16 +105,16 @@ _lwrite(
{
return _hwrite(hFile,lpBuffer,uBytes);
}
*/
HFILE _lopen( LPCSTR lpPathName, int iReadWrite )
HFILE
STDCALL
_lopen (
LPCSTR lpPathName,
int iReadWrite
)
{
DWORD dwAccessMask = 0;
DWORD dwShareMode = 0;
@ -87,10 +125,6 @@ HFILE _lopen( LPCSTR lpPathName, int iReadWrite )
else if ( (iReadWrite & OF_WRITE ) == OF_WRITE )
dwAccessMask = GENERIC_WRITE;
if ((iReadWrite & OF_SHARE_COMPAT) == OF_SHARE_COMPAT )
dwShareMode = FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE;
else if ((iReadWrite & OF_SHARE_DENY_NONE) == OF_SHARE_DENY_NONE)
@ -105,13 +139,25 @@ else if ((iReadWrite & OF_SHARE_EXCLUSIVE) == OF_SHARE_EXCLUSIVE)
SetLastError(0);
return (HFILE) CreateFileA( lpPathName,dwAccessMask,dwShareMode,
NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
return (HFILE) CreateFileA(
lpPathName,
dwAccessMask,
dwShareMode,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL
);
}
HFILE _lcreat( LPCSTR lpPathName, int iAttribute )
HFILE
STDCALL
_lcreat (
LPCSTR lpPathName,
int iAttribute
)
{
DWORD FileAttributes = 0;
@ -125,28 +171,47 @@ HFILE _lcreat( LPCSTR lpPathName, int iAttribute )
else if ( iAttribute == 4 )
FileAttributes |= FILE_ATTRIBUTE_SYSTEM;
return(HFILE) CreateFileA( lpPathName,GENERIC_ALL,FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,CREATE_ALWAYS,iAttribute ,NULL);
return (HFILE) CreateFileA(
lpPathName,
GENERIC_ALL,
(FILE_SHARE_READ | FILE_SHARE_WRITE),
NULL,
CREATE_ALWAYS,
iAttribute,
NULL
);
}
int _lclose(
int
STDCALL
_lclose (
HFILE hFile
)
{
if ( CloseHandle((HANDLE)hFile) )
{
return 0;
else
}
return -1;
}
LONG _llseek(
LONG
STDCALL
_llseek(
HFILE hFile,
LONG lOffset,
int iOrigin
)
{
return SetFilePointer((HANDLE) hFile, lOffset, NULL,(DWORD)iOrigin );
return SetFilePointer(
(HANDLE) hFile,
lOffset,
NULL,
(DWORD) iOrigin
);
}
/* EOF */

View file

@ -1,4 +1,4 @@
; $Id: kernel32.edf,v 1.1 1999/07/17 23:10:20 ea Exp $
; $Id: kernel32.edf,v 1.2 1999/08/29 06:59:01 ea Exp $
;
; kernel32.edf
;
@ -649,8 +649,8 @@ _lclose=_lclose@4
_lcreat=_lcreat@8
_llseek=_llseek@12
_lopen=_lopen@8
_lread=_lread@12
_lwrite=_lwrite@12
_lread=_hread@12
_lwrite=_hwrite@12
lstrcat=lstrcatA@8
lstrcatA=lstrcatA@8
lstrcatW=lstrcatW@8

View file

@ -1,4 +1,5 @@
/*
/* $Id: heap.c,v 1.15 1999/08/29 06:59:01 ea Exp $
*
* kernel/heap.c
* Copyright (C) 1996, Onno Hovers, All rights reserved
*
@ -117,9 +118,17 @@ BOOL WINAPI HeapUnlock(HANDLE hheap)
* NT uses this function to compact moveable blocks and other things *
* Here it does not compact, but it finds the largest free region *
*********************************************************************/
UINT HeapCompact(HANDLE hheap, DWORD flags)
UINT
STDCALL
HeapCompact (
HANDLE hheap,
DWORD flags
)
{
return(RtlCompactHeap(hheap, flags));
return RtlCompactHeap(
hheap,
flags
);
}
/*********************************************************************
@ -140,3 +149,5 @@ BOOL WINAPI HeapValidate(HANDLE hheap, DWORD flags, LPCVOID pmem)
return(RtlValidateHeap(hheap, flags, (PVOID)pmem));
}
/* EOF */

View file

@ -1,3 +1,8 @@
/* $Id: error.c,v 1.11 1999/08/29 06:59:02 ea Exp $
*
* reactos/lib/kernel32/misc/error.c
*
*/
#include <windows.h>
#include <ddk/ntddk.h>
#include <ddk/ntddbeep.h>
@ -9,26 +14,39 @@
static DWORD LastError=0;
VOID SetLastError(DWORD dwErrorCode)
VOID
STDCALL
SetLastError (
DWORD dwErrorCode
)
{
/* FIXME: it is per thread */
LastError = dwErrorCode;
}
DWORD GetLastError(VOID)
DWORD
STDCALL
GetLastError (VOID)
{
return(LastError);
/* FIXME: it is per thread */
return LastError;
}
BOOL __ErrorReturnFalse(ULONG ErrorCode)
BOOL
__ErrorReturnFalse (ULONG ErrorCode)
{
return(FALSE);
}
PVOID __ErrorReturnNull(ULONG ErrorCode)
PVOID
__ErrorReturnNull (ULONG ErrorCode)
{
return(NULL);
}
WINBOOL
STDCALL
Beep (DWORD dwFreq, DWORD dwDuration)
@ -65,3 +83,5 @@ Beep (DWORD dwFreq, DWORD dwDuration)
return TRUE;
}
/* EOF */

View file

@ -1,4 +1,5 @@
/* $Id: stubs.c,v 1.2 1999/07/17 23:10:20 ea Exp $
/* $Id: stubs.c,v 1.3 1999/08/29 06:59:03 ea Exp $
*
* KERNEL32.DLL stubs (unimplemented functions)
* Remove from this file, if you implement them.
*/
@ -3443,17 +3444,6 @@ RegisterConsoleVDM (
}
WINBOOL
STDCALL
RegisterWaitForInputIdle (
DWORD Unknown0
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
WINBOOL
STDCALL
RegisterWowBaseHandlers (

View file

@ -1,4 +1,5 @@
/*
/* $Id: lib.c,v 1.3 1999/08/29 06:59:03 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/kernel32/proc/proc.c
@ -23,20 +24,37 @@
/* FUNCTIONS ****************************************************************/
HINSTANCE LoadLibraryW(LPCWSTR lpLibFileName)
HINSTANCE
STDCALL
LoadLibraryW (
LPCWSTR lpLibFileName
)
{
UNIMPLEMENTED;
return(NULL);
}
HINSTANCE LoadLibraryA(LPCSTR lpLibFileName)
HINSTANCE
STDCALL
LoadLibraryA (
LPCSTR lpLibFileName
)
{
UNIMPLEMENTED;
return(NULL);
}
BOOL STDCALL FreeLibrary(HMODULE hLibModule)
BOOL
STDCALL
FreeLibrary (
HMODULE hLibModule
)
{
UNIMPLEMENTED;
return(FALSE);
}
/* EOF */

View file

@ -1,4 +1,5 @@
/*
/* $Id: proc.c,v 1.19 1999/08/29 06:59:03 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/kernel32/proc/proc.c
@ -49,44 +50,79 @@ typedef struct _WSTARTUPINFO {
WaitForInputIdleType lpfnGlobalRegisterWaitForInputIdle;
VOID RegisterWaitForInputIdle(WaitForInputIdleType lpfnRegisterWaitForInputIdle);
VOID
STDCALL
RegisterWaitForInputIdle (
WaitForInputIdleType lpfnRegisterWaitForInputIdle
);
/* FUNCTIONS ****************************************************************/
WINBOOL STDCALL GetProcessId(HANDLE hProcess, LPDWORD lpProcessId);
WINBOOL
STDCALL
GetProcessId (
HANDLE hProcess,
LPDWORD lpProcessId
);
FARPROC GetProcAddress(HMODULE hModule, LPCSTR lpProcName)
FARPROC
STDCALL
GetProcAddress (
HMODULE hModule,
LPCSTR lpProcName
)
{
UNIMPLEMENTED;
return(NULL);
return NULL;
}
WINBOOL STDCALL GetProcessTimes(HANDLE hProcess,
WINBOOL
STDCALL
GetProcessTimes (
HANDLE hProcess,
LPFILETIME lpCreationTime,
LPFILETIME lpExitTime,
LPFILETIME lpKernelTime,
LPFILETIME lpUserTime)
LPFILETIME lpUserTime
)
{
dprintf("GetProcessTimes is unimplemented\n");
return(FALSE);
return FALSE;
}
HANDLE STDCALL GetCurrentProcess(VOID)
HANDLE
STDCALL
GetCurrentProcess (VOID)
{
return (HANDLE) NtCurrentProcess();
}
HANDLE STDCALL GetCurrentThread(VOID)
HANDLE
STDCALL
GetCurrentThread (VOID)
{
return (HANDLE) NtCurrentThread();
}
DWORD STDCALL GetCurrentProcessId(VOID)
DWORD
STDCALL
GetCurrentProcessId (VOID)
{
return (DWORD) (GetTeb()->Cid).UniqueProcess;
}
WINBOOL STDCALL GetExitCodeProcess(HANDLE hProcess, LPDWORD lpExitCode)
WINBOOL
STDCALL
GetExitCodeProcess (
HANDLE hProcess,
LPDWORD lpExitCode
)
{
NTSTATUS errCode;
PROCESS_BASIC_INFORMATION ProcessBasic;
@ -106,7 +142,13 @@ WINBOOL STDCALL GetExitCodeProcess(HANDLE hProcess, LPDWORD lpExitCode)
return TRUE;
}
WINBOOL STDCALL GetProcessId(HANDLE hProcess, LPDWORD lpProcessId )
WINBOOL
STDCALL
GetProcessId (
HANDLE hProcess,
LPDWORD lpProcessId
)
{
NTSTATUS errCode;
PROCESS_BASIC_INFORMATION ProcessBasic;
@ -126,7 +168,13 @@ WINBOOL STDCALL GetProcessId(HANDLE hProcess, LPDWORD lpProcessId )
return TRUE;
}
PWSTR InternalAnsiToUnicode(PWSTR Out, LPCSTR In, ULONG MaxLength)
PWSTR
InternalAnsiToUnicode (
PWSTR Out,
LPCSTR In,
ULONG MaxLength
)
{
ULONG i;
@ -148,9 +196,14 @@ PWSTR InternalAnsiToUnicode(PWSTR Out, LPCSTR In, ULONG MaxLength)
}
}
HANDLE STDCALL OpenProcess(DWORD dwDesiredAccess,
HANDLE
STDCALL
OpenProcess (
DWORD dwDesiredAccess,
WINBOOL bInheritHandle,
DWORD dwProcessId)
DWORD dwProcessId
)
{
NTSTATUS errCode;
HANDLE ProcessHandle;
@ -183,7 +236,13 @@ HANDLE STDCALL OpenProcess(DWORD dwDesiredAccess,
return ProcessHandle;
}
UINT WinExec (LPCSTR lpCmdLine, UINT uCmdShow)
UINT
STDCALL
WinExec (
LPCSTR lpCmdLine,
UINT uCmdShow
)
{
STARTUPINFO StartupInfo;
PROCESS_INFORMATION ProcessInformation;
@ -217,27 +276,45 @@ UINT WinExec (LPCSTR lpCmdLine, UINT uCmdShow)
}
VOID RegisterWaitForInputIdle(WaitForInputIdleType
lpfnRegisterWaitForInputIdle)
VOID
STDCALL
RegisterWaitForInputIdle (
WaitForInputIdleType lpfnRegisterWaitForInputIdle
)
{
lpfnGlobalRegisterWaitForInputIdle = lpfnRegisterWaitForInputIdle;
return;
}
DWORD STDCALL WaitForInputIdle(HANDLE hProcess,
DWORD dwMilliseconds)
DWORD
STDCALL
WaitForInputIdle (
HANDLE hProcess,
DWORD dwMilliseconds
)
{
return 0;
}
VOID STDCALL Sleep(DWORD dwMilliseconds)
VOID
STDCALL
Sleep (
DWORD dwMilliseconds
)
{
SleepEx (dwMilliseconds, FALSE);
return;
}
DWORD STDCALL SleepEx(DWORD dwMilliseconds, BOOL bAlertable)
DWORD
STDCALL
SleepEx (
DWORD dwMilliseconds,
BOOL bAlertable
)
{
TIME Interval;
NTSTATUS errCode;
@ -245,14 +322,20 @@ DWORD STDCALL SleepEx(DWORD dwMilliseconds, BOOL bAlertable)
Interval.QuadPart = dwMilliseconds * 1000;
errCode = NtDelayExecution(bAlertable,&Interval);
if ( !NT_SUCCESS(errCode) ) {
if ( !NT_SUCCESS(errCode) )
{
SetLastError(RtlNtStatusToDosError(errCode));
return -1;
}
return 0;
}
VOID STDCALL GetStartupInfoW(LPSTARTUPINFO _lpStartupInfo)
VOID
STDCALL
GetStartupInfoW (
LPSTARTUPINFO _lpStartupInfo
)
{
NT_PEB *pPeb = NtCurrentPeb();
LPWSTARTUPINFO lpStartupInfo = (LPWSTARTUPINFO)_lpStartupInfo;
@ -305,7 +388,11 @@ VOID STDCALL GetStartupInfoW(LPSTARTUPINFO _lpStartupInfo)
}
VOID STDCALL GetStartupInfoA(LPSTARTUPINFO lpStartupInfo)
VOID
STDCALL
GetStartupInfoA (
LPSTARTUPINFO lpStartupInfo
)
{
NT_PEB *pPeb = NtCurrentPeb();
ULONG i = 0;
@ -355,12 +442,22 @@ VOID STDCALL GetStartupInfoA(LPSTARTUPINFO lpStartupInfo)
return;
}
BOOL STDCALL FlushInstructionCache(HANDLE hProcess,
BOOL
STDCALL
FlushInstructionCache (
HANDLE hProcess,
LPCVOID lpBaseAddress,
DWORD dwSize)
DWORD dwSize
)
{
NTSTATUS errCode;
errCode = NtFlushInstructionCache(hProcess,(PVOID)lpBaseAddress,dwSize);
errCode = NtFlushInstructionCache(
hProcess,
(PVOID) lpBaseAddress,
dwSize
);
if (!NT_SUCCESS(errCode))
{
SetLastError(RtlNtStatusToDosError(errCode));
@ -369,12 +466,26 @@ BOOL STDCALL FlushInstructionCache(HANDLE hProcess,
return TRUE;
}
VOID STDCALL ExitProcess(UINT uExitCode)
VOID
STDCALL
ExitProcess (
UINT uExitCode
)
{
NtTerminateProcess(NtCurrentProcess(), uExitCode);
NtTerminateProcess(
NtCurrentProcess(),
uExitCode
);
}
WINBOOL STDCALL TerminateProcess(HANDLE hProcess, UINT uExitCode)
WINBOOL
STDCALL
TerminateProcess (
HANDLE hProcess,
UINT uExitCode
)
{
NTSTATUS errCode;
errCode = NtTerminateProcess(hProcess, uExitCode);
@ -386,7 +497,12 @@ WINBOOL STDCALL TerminateProcess(HANDLE hProcess, UINT uExitCode)
return TRUE;
}
VOID STDCALL FatalAppExitA(UINT uAction, LPCSTR lpMessageText)
VOID
STDCALL
FatalAppExitA (
UINT uAction,
LPCSTR lpMessageText
)
{
WCHAR MessageTextW[MAX_PATH];
UINT i;
@ -404,7 +520,15 @@ VOID STDCALL FatalAppExitA(UINT uAction, LPCSTR lpMessageText)
VOID STDCALL FatalAppExitW(UINT uAction, LPCWSTR lpMessageText)
VOID
STDCALL
FatalAppExitW (
UINT uAction,
LPCWSTR lpMessageText
)
{
return;
}
/* EOF */

View file

@ -1,4 +1,5 @@
/*
/* $Id: critical.c,v 1.5 1999/08/29 06:59:03 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/kernel32/sync/critical.c
@ -15,29 +16,46 @@
/* FUNCTIONS *****************************************************************/
VOID DeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
VOID
STDCALL
DeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
{
UNIMPLEMENTED;
}
VOID EnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
VOID
STDCALL
EnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
{
UNIMPLEMENTED;
}
VOID InitializeCriticalSection(LPCRITICAL_SECTION pcritical)
VOID
STDCALL
InitializeCriticalSection(LPCRITICAL_SECTION pcritical)
{
UNIMPLEMENTED;
}
VOID LeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
VOID
STDCALL
LeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
{
UNIMPLEMENTED;
}
WINBOOL TryEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
WINBOOL
STDCALL
TryEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
{
UNIMPLEMENTED;
return(FALSE);
}
/* EOF */

View file

@ -1,3 +1,7 @@
; $Id: ntdll.def,v 1.13 1999/08/29 06:59:04 ea Exp $
;
; ReactOS Operating System
;
EXPORTS
InitializeObjectAttributes
NtAcceptConnectPort@24

View file

@ -1,3 +1,7 @@
; $Id: ntdll.edf,v 1.4 1999/08/29 06:59:04 ea Exp $
;
; ReactOS Operating System
;
EXPORTS
InitializeObjectAttributes
NtAcceptConnectPort=NtAcceptConnectPort@24

View file

@ -1,4 +1,5 @@
/*
/* $Id: startup.c,v 1.9 1999/08/29 06:59:04 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/ntdll/ldr/startup.c
@ -9,6 +10,7 @@
/* INCLUDES *****************************************************************/
#include <reactos/config.h>
#define WIN32_NO_PEHDR
#include <windows.h>
#include <ddk/ntddk.h>
@ -18,7 +20,9 @@
#include <ntdll/ldr.h>
#include <ntdll/rtl.h>
#ifndef DBG_NTDLL_LDR_STARTUP
#define NDEBUG
#endif
#include <ntdll/ntdll.h>
/* GLOBALS *******************************************************************/
@ -30,8 +34,11 @@ extern HANDLE __ProcessHeap;
/* FUNCTIONS *****************************************************************/
NTSTATUS LdrMapNTDllForProcess(HANDLE ProcessHandle,
PHANDLE PtrNTDllSectionHandle)
NTSTATUS
LdrMapNTDllForProcess (
HANDLE ProcessHandle,
PHANDLE PtrNTDllSectionHandle
)
{
ULONG InitialViewSize;
NTSTATUS Status;
@ -125,3 +132,6 @@ VOID LdrStartup(HANDLE SectionHandle,
Status = EntryPoint();
ZwTerminateProcess(NtCurrentProcess(),Status);
}
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: utils.c,v 1.9 1999/07/17 23:10:24 ea Exp $
/* $Id: utils.c,v 1.10 1999/08/29 06:59:04 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -10,6 +10,7 @@
/* INCLUDES *****************************************************************/
#include <reactos/config.h>
#define WIN32_NO_PEHDR
#include <windows.h>
#include <ddk/ntddk.h>
@ -19,17 +20,46 @@
#include <wchar.h>
#include <ntdll/ldr.h>
#ifdef DBG_NTDLL_LDR_UTILS
#define NDEBUG
#endif
#include <ntdll/ntdll.h>
/* FUNCTIONS *****************************************************************/
typedef WINBOOL STDCALL (*PDLLMAIN_FUNC)(HANDLE hInst,
/* Type for a DLL's entry point */
typedef
WINBOOL
STDCALL
(* PDLLMAIN_FUNC) (
HANDLE hInst,
ULONG ul_reason_for_call,
LPVOID lpReserved);
LPVOID lpReserved
);
static NTSTATUS LdrLoadDll(PDLL* Dll, PCHAR Name)
/**********************************************************************
* NAME
* LdrLoadDll
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*
* NOTE
*
*/
static
NTSTATUS
LdrLoadDll (
PDLL * Dll,
PCHAR Name
)
{
char fqname [255] = "\\??\\C:\\reactos\\system32\\";
ANSI_STRING AnsiString;
@ -40,78 +70,134 @@ static NTSTATUS LdrLoadDll(PDLL* Dll, PCHAR Name)
NTSTATUS Status;
PIMAGE_NT_HEADERS NTHeaders;
PEPFUNC DllStartupAddr;
ULONG ImageSize, InitialViewSize;
ULONG ImageSize;
ULONG InitialViewSize;
PVOID ImageBase;
HANDLE FileHandle, SectionHandle;
HANDLE FileHandle;
HANDLE SectionHandle;
PDLLMAIN_FUNC Entrypoint;
DPRINT("LdrLoadDll(Base %x, Name %s)\n",Dll,Name);
DPRINT("LdrLoadDll(Base %x, Name \"%s\")\n", Dll, Name);
/*
* Build the DLL's absolute name
*/
strcat(fqname, Name);
DPRINT("fqname %s\n",fqname);
DPRINT("fqname \"%s\"\n", fqname);
/*
* Open the DLL's image file.
*/
RtlInitAnsiString(
& AnsiString,
fqname
);
RtlAnsiStringToUnicodeString(
& UnicodeString,
& AnsiString,
TRUE
);
RtlInitAnsiString(&AnsiString,fqname);
RtlAnsiStringToUnicodeString(&UnicodeString,&AnsiString,TRUE);
InitializeObjectAttributes(&FileObjectAttributes,
InitializeObjectAttributes(
& FileObjectAttributes,
& UnicodeString,
0,
NULL,
NULL);
DPRINT("Opening dll\n");
Status = ZwOpenFile(&FileHandle, FILE_ALL_ACCESS, &FileObjectAttributes,
NULL, 0, 0);
NULL
);
DPRINT("Opening dll \"%s\"\n", fqname);
Status = ZwOpenFile(
& FileHandle,
FILE_ALL_ACCESS,
& FileObjectAttributes,
NULL,
0,
0
);
if (!NT_SUCCESS(Status))
{
DPRINT("Dll open failed ");
DPRINT("Dll open failed: Status = 0x%08x\n", Status);
return Status;
}
Status = ZwReadFile(FileHandle, 0, 0, 0, 0, BlockBuffer, 1024, 0, 0);
Status = ZwReadFile(
FileHandle,
0,
0,
0,
0,
BlockBuffer,
sizeof BlockBuffer,
0,
0
);
if (!NT_SUCCESS(Status))
{
DPRINT("Dll header read failed ");
DPRINT("Dll header read failed: Status = 0x%08x\n", Status);
ZwClose(FileHandle);
return Status;
}
/*
* Overlay DOS and NT headers structures to the
* buffer with DLL's header raw data.
*/
DosHeader = (PIMAGE_DOS_HEADER) BlockBuffer;
if (DosHeader->e_magic != IMAGE_DOS_MAGIC ||
DosHeader->e_lfanew == 0L ||
*(PULONG)((PUCHAR)BlockBuffer + DosHeader->e_lfanew) != IMAGE_PE_MAGIC)
NTHeaders = (PIMAGE_NT_HEADERS) (BlockBuffer + DosHeader->e_lfanew);
/*
* Check it is a PE image file.
*/
if ( (DosHeader->e_magic != IMAGE_DOS_MAGIC)
|| (DosHeader->e_lfanew == 0L)
// || (*(PULONG)((PUCHAR)BlockBuffer + DosHeader->e_lfanew) != IMAGE_PE_MAGIC)
|| (*(PULONG)(NTHeaders) != IMAGE_PE_MAGIC)
)
{
DPRINT("NTDLL format invalid\n");
ZwClose(FileHandle);
return STATUS_UNSUCCESSFUL;
}
NTHeaders = (PIMAGE_NT_HEADERS)(BlockBuffer + DosHeader->e_lfanew);
// NTHeaders = (PIMAGE_NT_HEADERS) (BlockBuffer + DosHeader->e_lfanew);
ImageBase = (PVOID) NTHeaders->OptionalHeader.ImageBase;
ImageSize = NTHeaders->OptionalHeader.SizeOfImage;
DPRINT("ImageBase %x\n",ImageBase);
DllStartupAddr = (PEPFUNC)(ImageBase +
NTHeaders->OptionalHeader.AddressOfEntryPoint);
DPRINT("ImageBase 0x%08x\n", ImageBase);
/* Create a section for NTDLL */
Status = ZwCreateSection(&SectionHandle,
DllStartupAddr =
(PEPFUNC) (
ImageBase
+ NTHeaders->OptionalHeader.AddressOfEntryPoint
);
/*
* Create a section for NTDLL.
*/
Status = ZwCreateSection(
& SectionHandle,
SECTION_ALL_ACCESS,
NULL,
NULL,
PAGE_READWRITE,
MEM_COMMIT,
FileHandle);
FileHandle
);
if (!NT_SUCCESS(Status))
{
DPRINT("NTDLL create section failed ");
DPRINT("NTDLL create section failed: Status = 0x%08x\n", Status);
ZwClose(FileHandle);
return Status;
}
/* Map the NTDLL into the process */
InitialViewSize = DosHeader->e_lfanew + sizeof(IMAGE_NT_HEADERS)
/*
* Map the NTDLL into the process.
*/
InitialViewSize =
DosHeader->e_lfanew
+ sizeof (IMAGE_NT_HEADERS)
+ sizeof (IMAGE_SECTION_HEADER) * NTHeaders->FileHeader.NumberOfSections;
Status = ZwMapViewOfSection(SectionHandle,
Status = ZwMapViewOfSection(
SectionHandle,
NtCurrentProcess(),
(PVOID *) & ImageBase,
0,
@ -120,17 +206,22 @@ static NTSTATUS LdrLoadDll(PDLL* Dll, PCHAR Name)
& InitialViewSize,
0,
MEM_COMMIT,
PAGE_READWRITE);
PAGE_READWRITE
);
if (!NT_SUCCESS(Status))
{
DPRINT("NTDLL map view of secion failed ");
DPRINT("NTDLL.LDR: map view of section failed ");
ZwClose(FileHandle);
return Status;
}
ZwClose(FileHandle);
(*Dll) = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(DLL));
(*Dll) = RtlAllocateHeap(
RtlGetProcessHeap(),
0,
sizeof (DLL)
);
(*Dll)->Headers = NTHeaders;
(*Dll)->BaseAddress = (PVOID)ImageBase;
(*Dll)->Next = LdrDllListHead.Next;
@ -138,44 +229,92 @@ static NTSTATUS LdrLoadDll(PDLL* Dll, PCHAR Name)
LdrDllListHead.Next->Prev = (*Dll);
LdrDllListHead.Next = (*Dll);
Entrypoint = (PDLLMAIN_FUNC)LdrPEStartup(ImageBase, SectionHandle);
Entrypoint =
(PDLLMAIN_FUNC) LdrPEStartup(
ImageBase,
SectionHandle
);
if (Entrypoint != NULL)
{
DPRINT("Calling entry point at %x\n",Entrypoint);
Entrypoint(ImageBase, DLL_PROCESS_ATTACH, NULL);
DPRINT("Successful called entrypoint\n");
DPRINT("Calling entry point at 0x%08x\n", Entrypoint);
if (FALSE == Entrypoint(
ImageBase,
DLL_PROCESS_ATTACH,
NULL
))
{
DPRINT("NTDLL.LDR: DLL \"%s\" failed to initialize\n", fqname);
/* FIXME: should clean up and fail */
}
else
{
DPRINT("NTDLL.LDR: DLL \"%s\" initialized successfully\n", fqname);
}
}
else
{
DPRINT("NTDLL.LDR: Entrypoint is NULL for \"%s\"\n", fqname);
}
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
static NTSTATUS LdrFindDll(PDLL* Dll, PCHAR Name)
/**********************************************************************
* NAME LOCAL
* LdrFindDll
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*
* NOTE
*
*/
static
NTSTATUS
LdrFindDll (
PDLL * Dll,
PCHAR Name
)
{
PIMAGE_EXPORT_DIRECTORY ExportDir;
DLL * current;
PIMAGE_OPTIONAL_HEADER OptionalHeader;
DPRINT("LdrFindDll(Name %s)\n",Name);
DPRINT("NTDLL.LdrFindDll(Name %s)\n", Name);
current = & LdrDllListHead;
do
{
OptionalHeader = & current->Headers->OptionalHeader;
ExportDir = (PIMAGE_EXPORT_DIRECTORY)OptionalHeader->DataDirectory[
ExportDir = (PIMAGE_EXPORT_DIRECTORY)
OptionalHeader->DataDirectory[
IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
ExportDir = (PIMAGE_EXPORT_DIRECTORY)
((ULONG)ExportDir + (ULONG)current->BaseAddress);
DPRINT("Scanning %x %x %x\n", ExportDir->Name,
current->BaseAddress, ExportDir->Name + current->BaseAddress);
DPRINT("Scanning %s\n", ExportDir->Name + current->BaseAddress);
DPRINT("Scanning %x %x %x\n",
ExportDir->Name,
current->BaseAddress,
(ExportDir->Name + current->BaseAddress)
);
DPRINT("Scanning %s\n",
ExportDir->Name + current->BaseAddress
);
if (strcmp(ExportDir->Name + current->BaseAddress, Name) == 0)
{
*Dll = current;
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
current = current->Next;
} while (current != & LdrDllListHead);
dprintf("Failed to find dll %s\n",Name);
@ -183,15 +322,38 @@ static NTSTATUS LdrFindDll(PDLL* Dll, PCHAR Name)
return (LdrLoadDll(Dll, Name));
}
NTSTATUS LdrMapSections(HANDLE ProcessHandle,
/**********************************************************************
* NAME
* LdrMapSections
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*
* NOTE
*
*/
NTSTATUS
LdrMapSections (
HANDLE ProcessHandle,
PVOID ImageBase,
HANDLE SectionHandle,
PIMAGE_NT_HEADERS NTHeaders)
PIMAGE_NT_HEADERS NTHeaders
)
{
ULONG i;
NTSTATUS Status;
for (i=0; i<NTHeaders->FileHeader.NumberOfSections; i++)
for ( i = 0;
(i < NTHeaders->FileHeader.NumberOfSections);
i++
)
{
PIMAGE_SECTION_HEADER Sections;
LARGE_INTEGER Offset;
@ -201,7 +363,8 @@ NTSTATUS LdrMapSections(HANDLE ProcessHandle,
Base = (ULONG) (Sections[i].VirtualAddress + ImageBase);
Offset.u.LowPart = Sections[i].PointerToRawData;
Offset.u.HighPart = 0;
Status = ZwMapViewOfSection(SectionHandle,
Status = ZwMapViewOfSection(
SectionHandle,
ProcessHandle,
(PVOID *) & Base,
0,
@ -210,35 +373,91 @@ NTSTATUS LdrMapSections(HANDLE ProcessHandle,
(PULONG) & Sections[i].Misc.VirtualSize,
0,
MEM_COMMIT,
PAGE_READWRITE);
PAGE_READWRITE
);
if (!NT_SUCCESS(Status))
{
return Status;
}
}
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
static PVOID LdrGetExportByOrdinal(PDLL Module, ULONG Ordinal)
/**********************************************************************
* NAME LOCAL
* LdrGetExportByOrdinal
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*
* NOTE
*
*/
static
PVOID
LdrGetExportByOrdinal (
PDLL Module,
ULONG Ordinal
)
{
PIMAGE_EXPORT_DIRECTORY ExportDir;
PDWORD * ExFunctions;
USHORT * ExOrdinals;
ExportDir = (Module->BaseAddress +
(Module->Headers->OptionalHeader.
DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress));
ExportDir = (
Module->BaseAddress
+ (Module->Headers->OptionalHeader
.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT]
.VirtualAddress
)
);
ExOrdinals = (USHORT*)RVA(Module->BaseAddress,
ExportDir->AddressOfNameOrdinals);
ExFunctions = (PDWORD*)RVA(Module->BaseAddress,
ExportDir->AddressOfFunctions);
dprintf("LdrGetExportByOrdinal(Ordinal %d) = %x\n",
Ordinal,ExFunctions[ExOrdinals[Ordinal - ExportDir->Base]]);
ExOrdinals = (USHORT *)
RVA(
Module->BaseAddress,
ExportDir->AddressOfNameOrdinals
);
ExFunctions = (PDWORD *)
RVA(
Module->BaseAddress,
ExportDir->AddressOfFunctions
);
dprintf(
"LdrGetExportByOrdinal(Ordinal %d) = %x\n",
Ordinal,
ExFunctions[ExOrdinals[Ordinal - ExportDir->Base]]
);
return(ExFunctions[ExOrdinals[Ordinal - ExportDir->Base]]);
}
static PVOID LdrGetExportByName(PDLL Module, PUCHAR SymbolName)
/**********************************************************************
* NAME LOCAL
* LdrGetExportByName
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*
* NOTE
*
*/
static
PVOID
LdrGetExportByName (
PDLL Module,
PUCHAR SymbolName
)
{
PIMAGE_EXPORT_DIRECTORY ExportDir;
PDWORD * ExFunctions;
@ -248,64 +467,138 @@ static PVOID LdrGetExportByName(PDLL Module, PUCHAR SymbolName)
PVOID ExName;
ULONG Ordinal;
DPRINT("LdrFindExport(Module %x, SymbolName %s)\n",
Module, SymbolName);
DPRINT(
"LdrFindExport(Module %x, SymbolName %s)\n",
Module,
SymbolName
);
ExportDir = (Module->BaseAddress +
(Module->Headers->OptionalHeader.
DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress));
/* Get header pointers */
ExNames = (PDWORD*)RVA(Module->BaseAddress, ExportDir->AddressOfNames);
ExOrdinals = (USHORT*)RVA(Module->BaseAddress,
ExportDir->AddressOfNameOrdinals);
ExFunctions = (PDWORD*)RVA(Module->BaseAddress,
ExportDir->AddressOfFunctions);
for (i=0; i<ExportDir->NumberOfFunctions; i++)
ExportDir = (
Module->BaseAddress
+ (Module->Headers->OptionalHeader
.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT]
.VirtualAddress
)
);
/*
* Get header pointers
*/
ExNames = (PDWORD *)
RVA(
Module->BaseAddress,
ExportDir->AddressOfNames
);
ExOrdinals = (USHORT *)
RVA(
Module->BaseAddress,
ExportDir->AddressOfNameOrdinals
);
ExFunctions = (PDWORD *)
RVA(
Module->BaseAddress,
ExportDir->AddressOfFunctions
);
for ( i = 0;
( i < ExportDir->NumberOfFunctions);
i++
)
{
ExName = RVA(Module->BaseAddress, ExNames[i]);
DPRINT("Comparing '%s' '%s'\n",ExName,SymbolName);
ExName = RVA(
Module->BaseAddress,
ExNames[i]
);
DPRINT(
"Comparing '%s' '%s'\n",
ExName,
SymbolName
);
if (strcmp(ExName,SymbolName) == 0)
{
Ordinal = ExOrdinals[i];
return(RVA(Module->BaseAddress, ExFunctions[Ordinal]));
}
}
dprintf("LdrGetExportByName() = failed to find %s\n",SymbolName);
return(NULL);
return NULL;
}
static NTSTATUS LdrPerformRelocations(PIMAGE_NT_HEADERS NTHeaders,
PVOID ImageBase)
/**********************************************************************
* NAME LOCAL
* LdrPerformRelocations
*
* DESCRIPTION
* Relocate a DLL's memory image.
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*
* NOTE
*
*/
static
NTSTATUS
LdrPerformRelocations (
PIMAGE_NT_HEADERS NTHeaders,
PVOID ImageBase
)
{
USHORT NumberOfEntries;
PUSHORT pValue16;
ULONG RelocationRVA;
ULONG Delta32, Offset;
ULONG Delta32;
ULONG Offset;
PULONG pValue32;
PRELOCATION_DIRECTORY RelocationDir;
PRELOCATION_ENTRY RelocationBlock;
int i;
RelocationRVA = NTHeaders->OptionalHeader.DataDirectory[
IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress;
RelocationRVA =
NTHeaders->OptionalHeader
.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC]
.VirtualAddress;
if (RelocationRVA)
{
RelocationDir = (PRELOCATION_DIRECTORY)((PCHAR)ImageBase +
RelocationRVA);
RelocationDir = (PRELOCATION_DIRECTORY)
((PCHAR)ImageBase + RelocationRVA);
while (RelocationDir->SizeOfBlock)
{
Delta32 = (unsigned long)(ImageBase -
NTHeaders->OptionalHeader.ImageBase);
RelocationBlock = (PRELOCATION_ENTRY)
(RelocationRVA + ImageBase + sizeof(RELOCATION_DIRECTORY));
NumberOfEntries =
(RelocationDir->SizeOfBlock - sizeof(RELOCATION_DIRECTORY)) /
sizeof(RELOCATION_ENTRY);
for (i = 0; i < NumberOfEntries; i++)
Delta32 = (unsigned long) (
ImageBase
- NTHeaders->OptionalHeader.ImageBase
);
RelocationBlock = (PRELOCATION_ENTRY) (
RelocationRVA
+ ImageBase
+ sizeof (RELOCATION_DIRECTORY)
);
NumberOfEntries = (
RelocationDir->SizeOfBlock
- sizeof (RELOCATION_DIRECTORY)
)
/ sizeof (RELOCATION_ENTRY);
for ( i = 0;
(i < NumberOfEntries);
i++
)
{
Offset = (RelocationBlock[i].TypeOffset & 0xfff) +
RelocationDir->VirtualAddress;
Offset = (
RelocationBlock[i].TypeOffset
& 0xfff
)
+ RelocationDir->VirtualAddress;
/*
* What kind of relocations should we perform
* for the current entry?
*/
switch (RelocationBlock[i].TypeOffset >> 12)
{
case TYPE_RELOC_ABSOLUTE:
@ -328,35 +621,67 @@ static NTSTATUS LdrPerformRelocations(PIMAGE_NT_HEADERS NTHeaders,
case TYPE_RELOC_HIGHADJ:
/* FIXME: do the highadjust fixup */
DPRINT("TYPE_RELOC_HIGHADJ fixup not implemented"
", sorry\n");
DPRINT(
"TYPE_RELOC_HIGHADJ fixup not implemented"
", sorry\n"
);
return(STATUS_UNSUCCESSFUL);
default:
DPRINT("unexpected fixup type\n");
return(STATUS_UNSUCCESSFUL);
return STATUS_UNSUCCESSFUL;
}
}
RelocationRVA += RelocationDir->SizeOfBlock;
RelocationDir = (PRELOCATION_DIRECTORY)(ImageBase +
RelocationRVA);
RelocationDir = (PRELOCATION_DIRECTORY) (
ImageBase
+ RelocationRVA
);
}
}
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
static NTSTATUS LdrFixupImports(PIMAGE_NT_HEADERS NTHeaders,
PVOID ImageBase)
/**********************************************************************
* NAME LOCAL
* LdrFixupImports
*
* DESCRIPTION
* Compute the entry point for every symbol the DLL imports
* from other modules.
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*
* NOTE
*
*/
static
NTSTATUS
LdrFixupImports (
PIMAGE_NT_HEADERS NTHeaders,
PVOID ImageBase
)
{
PIMAGE_IMPORT_MODULE_DIRECTORY ImportModuleDirectory;
ULONG Ordinal;
PDLL Module;
NTSTATUS Status;
/* Process each import module */
ImportModuleDirectory = (PIMAGE_IMPORT_MODULE_DIRECTORY)
(ImageBase + NTHeaders->OptionalHeader.
DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
/*
* Process each import module.
*/
ImportModuleDirectory = (PIMAGE_IMPORT_MODULE_DIRECTORY) (
ImageBase
+ NTHeaders->OptionalHeader
.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT]
.VirtualAddress
);
while (ImportModuleDirectory->dwRVAModuleName)
{
PVOID * ImportAddressList;
@ -364,99 +689,187 @@ static NTSTATUS LdrFixupImports(PIMAGE_NT_HEADERS NTHeaders,
DWORD pName;
PWORD pHint;
Status = LdrFindDll(&Module,
(PCHAR)(ImageBase +
ImportModuleDirectory->dwRVAModuleName));
Status = LdrFindDll(
& Module,
(PCHAR) (
ImageBase
+ ImportModuleDirectory->dwRVAModuleName
)
);
if (!NT_SUCCESS(Status))
{
return(Status);
return Status;
}
/* Get the import address list */
ImportAddressList = (PVOID *)
(NTHeaders->OptionalHeader.ImageBase +
ImportModuleDirectory->dwRVAFunctionAddressList);
/* Get the list of functions to import */
/*
* Get the import address list.
*/
ImportAddressList = (PVOID *) (
NTHeaders->OptionalHeader.ImageBase
+ ImportModuleDirectory->dwRVAFunctionAddressList
);
/*
* Get the list of functions to import.
*/
if (ImportModuleDirectory->dwRVAFunctionNameList != 0)
{
FunctionNameList = (PULONG) (ImageBase +
ImportModuleDirectory->dwRVAFunctionNameList);
FunctionNameList = (PULONG) (
ImageBase
+ ImportModuleDirectory->dwRVAFunctionNameList
);
}
else
{
FunctionNameList = (PULONG) (ImageBase +
ImportModuleDirectory->dwRVAFunctionAddressList);
FunctionNameList = (PULONG) (
ImageBase
+ ImportModuleDirectory->dwRVAFunctionAddressList
);
}
/* Walk through function list and fixup addresses */
/*
* Walk through function list and fixup addresses.
*/
while (*FunctionNameList != 0L)
{
if ((*FunctionNameList) & 0x80000000)
{
Ordinal = (*FunctionNameList) & 0x7fffffff;
*ImportAddressList = LdrGetExportByOrdinal(Module, Ordinal);
*ImportAddressList =
LdrGetExportByOrdinal(
Module,
Ordinal
);
}
else
{
pName = (DWORD)(ImageBase + *FunctionNameList + 2);
pHint = (PWORD)(ImageBase + *FunctionNameList);
pName = (DWORD) (
ImageBase
+ *FunctionNameList
+ 2
);
pHint = (PWORD) (
ImageBase
+ *FunctionNameList
);
*ImportAddressList = LdrGetExportByName(Module,
(PUCHAR)pName);
*ImportAddressList =
LdrGetExportByName(
Module,
(PUCHAR) pName
);
if ((*ImportAddressList) == NULL)
{
return(STATUS_UNSUCCESSFUL);
return STATUS_UNSUCCESSFUL;
}
}
ImportAddressList++;
FunctionNameList++;
}
ImportModuleDirectory++;
}
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
PEPFUNC LdrPEStartup(PVOID ImageBase, HANDLE SectionHandle)
/**********************************************************************
* NAME
* LdrPEStartup
*
* DESCRIPTION
* 1. Map the DLL's sections into memory.
* 2. Relocate, if needed the DLL.
* 3. Fixup any imported symbol.
* 4. Compute the DLL's entry point.
*
* ARGUMENTS
* ImageBase
* Address at which the DLL's image
* is loaded.
*
* SectionHandle
* Handle of the section that contains
* the DLL's image.
*
* RETURN VALUE
* NULL on error; otherwise the entry point
* to call for initializing the DLL.
*
* REVISIONS
*
* NOTE
*
*/
PEPFUNC
LdrPEStartup (
PVOID ImageBase,
HANDLE SectionHandle
)
{
NTSTATUS Status;
PEPFUNC EntryPoint;
PIMAGE_DOS_HEADER DosHeader;
PIMAGE_NT_HEADERS NTHeaders;
/*
* Overlay DOS and WNT headers structures
* to the DLL's image.
*/
DosHeader = (PIMAGE_DOS_HEADER) ImageBase;
NTHeaders = (PIMAGE_NT_HEADERS) (ImageBase + DosHeader->e_lfanew);
/* Initialize Image sections */
LdrMapSections(NtCurrentProcess(), ImageBase, SectionHandle, NTHeaders);
/*
* Initialize image sections.
*/
LdrMapSections(
NtCurrentProcess(),
ImageBase,
SectionHandle,
NTHeaders
);
/*
* If the base address is different from the
* one the DLL is actually loaded, perform any
* relocation.
*/
if (ImageBase != (PVOID) NTHeaders->OptionalHeader.ImageBase)
{
Status = LdrPerformRelocations(NTHeaders, ImageBase);
Status = LdrPerformRelocations(
NTHeaders,
ImageBase
);
if (!NT_SUCCESS(Status))
{
dprintf("LdrPerformRelocations() failed\n");
return(NULL);
return NULL;
}
}
if (NTHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].
VirtualAddress != 0)
/*
* If the DLL's imports symbols from other
* modules, fixup the imported calls entry points.
*/
if (NTHeaders->OptionalHeader
.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT]
.VirtualAddress != 0)
{
Status = LdrFixupImports(NTHeaders, ImageBase);
Status = LdrFixupImports(
NTHeaders,
ImageBase
);
if (!NT_SUCCESS(Status))
{
dprintf("LdrFixupImports() failed\n");
return(NULL);
return NULL;
}
}
EntryPoint = (PEPFUNC)(ImageBase +
NTHeaders->OptionalHeader.AddressOfEntryPoint);
/*
* Compute the DLL's entry point's address.
*/
EntryPoint = (PEPFUNC) (
ImageBase
+ NTHeaders->OptionalHeader.AddressOfEntryPoint
);
dprintf("LdrPEStartup() = %x\n",EntryPoint);
return(EntryPoint);
return EntryPoint;
}
/* EOF */

View file

@ -1,4 +1,5 @@
/*
/* $Id: registry.c,v 1.18 1999/08/29 06:59:05 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/cm/registry.c
@ -363,13 +364,16 @@ CHECKPOINT;
NTSTATUS
NtCreateKey(OUT PHANDLE KeyHandle,
STDCALL
NtCreateKey (
OUT PHANDLE KeyHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes,
IN ULONG TitleIndex,
IN PUNICODE_STRING Class,
IN ULONG CreateOptions,
OUT PULONG Disposition)
OUT PULONG Disposition
)
{
#if PROTO_REG
PWSTR KeyNameBuf;
@ -455,7 +459,10 @@ NtCreateKey(OUT PHANDLE KeyHandle,
NTSTATUS
NtDeleteKey(IN HANDLE KeyHandle)
STDCALL
NtDeleteKey (
IN HANDLE KeyHandle
)
{
#ifdef PROTO_REG
NTSTATUS Status;
@ -489,12 +496,15 @@ NtDeleteKey(IN HANDLE KeyHandle)
NTSTATUS
NtEnumerateKey(IN HANDLE KeyHandle,
STDCALL
NtEnumerateKey (
IN HANDLE KeyHandle,
IN ULONG Index,
IN KEY_INFORMATION_CLASS KeyInformationClass,
OUT PVOID KeyInformation,
IN ULONG Length,
OUT PULONG ResultLength)
OUT PULONG ResultLength
)
{
#ifdef PROTO_REG
NTSTATUS Status;
@ -637,7 +647,9 @@ NtEnumerateKey(IN HANDLE KeyHandle,
#endif
}
NTSTATUS
STDCALL
NtEnumerateValueKey (
IN HANDLE KeyHandle,
IN ULONG Index,
@ -654,8 +666,12 @@ NtEnumerateValueKey (
#endif
}
NTSTATUS
NtFlushKey(IN HANDLE KeyHandle)
STDCALL
NtFlushKey (
IN HANDLE KeyHandle
)
{
#ifdef PROTO_REG
return STATUS_SUCCESS;
@ -664,10 +680,14 @@ NtFlushKey(IN HANDLE KeyHandle)
#endif
}
NTSTATUS
NtOpenKey(OUT PHANDLE KeyHandle,
STDCALL
NtOpenKey (
OUT PHANDLE KeyHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes)
IN POBJECT_ATTRIBUTES ObjectAttributes
)
{
#ifdef PROTO_REG
NTSTATUS Status;
@ -757,7 +777,9 @@ NtOpenKey(OUT PHANDLE KeyHandle,
#endif
}
NTSTATUS
STDCALL
NtQueryKey (
IN HANDLE KeyHandle,
IN KEY_INFORMATION_CLASS KeyInformationClass,
@ -895,7 +917,9 @@ NtQueryKey (
#endif
}
NTSTATUS
STDCALL
NtQueryValueKey (
IN HANDLE KeyHandle,
IN PUNICODE_STRING ValueName,
@ -1024,7 +1048,9 @@ NtQueryValueKey (
#endif
}
NTSTATUS
STDCALL
NtSetValueKey (
IN HANDLE KeyHandle,
IN PUNICODE_STRING ValueName,
@ -1088,7 +1114,8 @@ NtSetValueKey (
#endif
}
NTSTATUS STDCALL
NTSTATUS
STDCALL
NtDeleteValueKey (
IN HANDLE KeyHandle,
IN PUNICODE_STRING ValueName
@ -1246,6 +1273,7 @@ NtInitializeRegistry (
NTSTATUS
STDCALL
RtlCheckRegistryKey (
ULONG RelativeTo,
PWSTR Path
@ -1256,6 +1284,7 @@ RtlCheckRegistryKey (
NTSTATUS
STDCALL
RtlCreateRegistryKey (
IN ULONG RelativeTo,
IN PWSTR Path
@ -1266,6 +1295,7 @@ RtlCreateRegistryKey (
NTSTATUS
STDCALL
RtlDeleteRegistryValue (
IN ULONG RelativeTo,
IN PWSTR Path,
@ -1277,6 +1307,7 @@ RtlDeleteRegistryValue (
NTSTATUS
STDCALL
RtlQueryRegistryValues (
IN ULONG RelativeTo,
IN PWSTR Path,
@ -1290,6 +1321,7 @@ RtlQueryRegistryValues (
NTSTATUS
STDCALL
RtlWriteRegistryValue (
ULONG RelativeTo,
PWSTR Path,
@ -2690,4 +2722,4 @@ CmiReleaseBlock(PREGISTRY_FILE RegistryFile,
#endif
/* EOF */

View file

@ -1,4 +1,5 @@
/*
/* $Id: interlck.c,v 1.2 1999/08/29 06:59:06 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ex/interlck.c
@ -16,28 +17,46 @@
/* FUNCTIONS *****************************************************************/
INTERLOCKED_RESULT ExInterlockedDecrementLong(PLONG Addend,
PKSPIN_LOCK Lock)
INTERLOCKED_RESULT
ExInterlockedDecrementLong (
PLONG Addend,
PKSPIN_LOCK Lock
)
{
UNIMPLEMENTED;
}
ULONG ExInterlockedExchangeUlong(PULONG Target,
ULONG
ExInterlockedExchangeUlong (
PULONG Target,
ULONG Value,
PKSPIN_LOCK Lock)
PKSPIN_LOCK Lock
)
{
UNIMPLEMENTED;
}
ULONG ExInterlockedAddUlong(PULONG Addend,
ULONG
ExInterlockedAddUlong (
PULONG Addend,
ULONG Increment,
PKSPIN_LOCK Lock)
PKSPIN_LOCK Lock
)
{
UNIMPLEMENTED;
}
INTERLOCKED_RESULT ExInterlockedIncrementLong(PLONG Addend,
PKSPIN_LOCK Lock)
INTERLOCKED_RESULT
ExInterlockedIncrementLong (
PLONG Addend,
PKSPIN_LOCK Lock
)
{
UNIMPLEMENTED;
}
/* EOF */

View file

@ -1,4 +1,5 @@
/*
/* $Id: device.c,v 1.10 1999/08/29 06:59:06 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/io/device.c
@ -33,20 +34,32 @@ NtUnloadDriver (
}
/**********************************************************************
* NAME EXPORTED
* NtLoadDriver
*
* DESCRIPTION
* Loads a device driver.
*
* ARGUMENTS
* DriverServiceName
* Name of the service to load (registry key).
*
* RETURN VALUE
* Status.
*
* REVISIONS
*/
NTSTATUS
STDCALL
NtLoadDriver (
PUNICODE_STRING DriverServiceName
)
/*
* FUNCTION: Loads a driver
* ARGUMENTS:
* DriverServiceName = Name of the service to load (registry key)
* RETURNS: Status
*/
{
UNIMPLEMENTED;
}
NTSTATUS
IoAttachDeviceByPointer (
PDEVICE_OBJECT SourceDevice,
@ -307,3 +320,6 @@ NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject,
return(STATUS_SUCCESS);
}
/* EOF */

View file

@ -1,4 +1,5 @@
/*
/* $Id: file.c,v 1.9 1999/08/29 06:59:06 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/io/file.c
@ -89,7 +90,9 @@ NtQueryInformationFile (
return(Status);
}
NTSTATUS
STDCALL
NtSetInformationFile (
HANDLE FileHandle,
PIO_STATUS_BLOCK IoStatusBlock,
@ -104,59 +107,94 @@ NtSetInformationFile (
PIO_STACK_LOCATION StackPtr;
KEVENT Event;
DPRINT("NtSetInformationFile(Handle %x StatBlk %x FileInfo %x Length %d Class %d)\n",
DPRINT(
"NtSetInformationFile(Handle %x StatBlk %x FileInfo %x Length %d Class %d)\n",
FileHandle,
IoStatusBlock,
FileInformation,
Length,
FileInformationClass);
FileInformationClass
);
/* Get the file object from the file handle */
Status = ObReferenceObjectByHandle(FileHandle,
Status = ObReferenceObjectByHandle(
FileHandle,
FILE_WRITE_ATTRIBUTES,
IoFileType,
UserMode,
(PVOID *) & FileObject,
NULL);
NULL
);
if (!NT_SUCCESS(Status))
{
return Status;
}
DPRINT("FileObject %x\n", FileObject);
/* initialize an event object to wait on for the request */
KeInitializeEvent(&Event, NotificationEvent, FALSE);
/* build the IRP to be sent to the driver for the request */
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_SET_INFORMATION,
/*
* Initialize an event object to wait
* on for the request.
*/
KeInitializeEvent(
& Event,
NotificationEvent,
FALSE
);
/*
* Build the IRP to be sent to the driver
* for the request.
*/
Irp = IoBuildSynchronousFsdRequest(
IRP_MJ_SET_INFORMATION,
FileObject->DeviceObject,
FileInformation,
Length,
0,
& Event,
IoStatusBlock);
IoStatusBlock
);
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->FileObject = FileObject;
StackPtr->Parameters.SetFile.Length = Length;
StackPtr->Parameters.SetFile.FileInformationClass = FileInformationClass;
StackPtr->Parameters.SetFile.FileInformationClass =
FileInformationClass;
/* Pass the IRP to the FSD (and wait for it if required) */
/*
* Pass the IRP to the FSD (and wait for
* it if required)
*/
DPRINT("FileObject->DeviceObject %x\n", FileObject->DeviceObject);
Status = IoCallDriver(FileObject->DeviceObject, Irp);
if (Status == STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO))
Status = IoCallDriver(
FileObject->DeviceObject,
Irp
);
if ( (Status == STATUS_PENDING)
&& (FileObject->Flags & FO_SYNCHRONOUS_IO)
)
{
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
KeWaitForSingleObject(
& Event,
Executive,
KernelMode,
FALSE,
NULL
);
Status = Irp->IoStatus.Status;
}
return Status;
}
PGENERIC_MAPPING IoGetFileObjectGenericMapping(VOID)
PGENERIC_MAPPING
IoGetFileObjectGenericMapping(VOID)
{
UNIMPLEMENTED;
}
NTSTATUS
STDCALL
NtQueryAttributesFile (
@ -210,3 +248,4 @@ NtSetEaFile (
}
/* EOF */

View file

@ -1,4 +1,5 @@
/*
/* $Id: rw.c,v 1.26 1999/08/29 06:59:06 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/io/rw.c
@ -21,7 +22,22 @@
/* FUNCTIONS ***************************************************************/
/**********************************************************************
* NAME EXPORTED
* NtReadFile
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*
*/
NTSTATUS
STDCALL
NtReadFile (
HANDLE FileHandle,
HANDLE EventHandle,
@ -41,27 +57,37 @@ NtReadFile (
PKEVENT ptrEvent = NULL;
KEVENT Event;
DPRINT("NtReadFile(FileHandle %x Buffer %x Length %x ByteOffset %x, "
DPRINT(
"NtReadFile(FileHandle %x Buffer %x Length %x ByteOffset %x, "
"IoStatusBlock %x)\n",
FileHandle,Buffer,Length,ByteOffset,IoStatusBlock);
FileHandle,
Buffer,
Length,
ByteOffset,
IoStatusBlock
);
assert_irql(PASSIVE_LEVEL);
Status = ObReferenceObjectByHandle(FileHandle,
Status = ObReferenceObjectByHandle(
FileHandle,
FILE_READ_DATA,
IoFileType,
UserMode,
(PVOID *) & FileObject,
NULL);
NULL
);
if (!NT_SUCCESS(Status))
{
DPRINT("NtReadFile() = %x\n",Status);
return(Status);
return Status;
}
DPRINT("ByteOffset %x FileObject->CurrentByteOffset %d\n",
DPRINT(
"ByteOffset %x FileObject->CurrentByteOffset %d\n",
ByteOffset,
FileObject->CurrentByteOffset.LowPart);
FileObject->CurrentByteOffset.LowPart
);
if (ByteOffset == NULL)
{
ByteOffset = & (FileObject->CurrentByteOffset);
@ -69,31 +95,40 @@ NtReadFile (
if (EventHandle != NULL)
{
Status = ObReferenceObjectByHandle(EventHandle,
Status = ObReferenceObjectByHandle(
EventHandle,
SYNCHRONIZE,
ExEventType,
UserMode,
(PVOID *) ptrEvent,
NULL);
NULL
);
if (!NT_SUCCESS(Status))
{
return(Status);
return Status;
}
}
else
{
KeInitializeEvent(&Event,NotificationEvent,FALSE);
KeInitializeEvent(
& Event,
NotificationEvent,
FALSE
);
ptrEvent = & Event;
}
DPRINT("FileObject %x\n",FileObject);
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
Irp = IoBuildSynchronousFsdRequest(
IRP_MJ_READ,
FileObject->DeviceObject,
Buffer,
Length,
ByteOffset,
ptrEvent,
IoStatusBlock);
IoStatusBlock
);
Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine;
Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext;
@ -109,19 +144,48 @@ NtReadFile (
StackPtr->Parameters.Read.Key = 0;
}
Status = IoCallDriver(FileObject->DeviceObject, Irp);
if (Status == STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO))
Status = IoCallDriver(
FileObject->DeviceObject,
Irp
);
if (
(Status == STATUS_PENDING)
&& (FileObject->Flags & FO_SYNCHRONOUS_IO)
)
{
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
KeWaitForSingleObject(
& Event,
Executive,
KernelMode,
FALSE,
NULL
);
Status = IoStatusBlock->Status;
}
DPRINT("NtReadFile() = %x\n",Status);
assert_irql(PASSIVE_LEVEL);
return(Status);
return Status;
}
/**********************************************************************
* NAME EXPORTED
* NtWriteFile
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*
*/
NTSTATUS
STDCALL
NtWriteFile (
HANDLE FileHandle,
HANDLE EventHandle,
@ -140,37 +204,50 @@ NtWriteFile (
PIO_STACK_LOCATION StackPtr;
KEVENT Event;
DPRINT("NtWriteFile(FileHandle %x, Buffer %x, Length %d)\n",
FileHandle,Buffer,Length);
DPRINT(
"NtWriteFile(FileHandle %x, Buffer %x, Length %d)\n",
FileHandle,
Buffer,
Length
);
Status = ObReferenceObjectByHandle(FileHandle,
Status = ObReferenceObjectByHandle(
FileHandle,
FILE_WRITE_DATA,
IoFileType,
UserMode,
(PVOID *) & FileObject,
NULL);
NULL
);
if (!NT_SUCCESS(Status))
{
return(Status);
return Status;
}
if (ByteOffset == NULL)
{
ByteOffset = & (FileObject->CurrentByteOffset);
}
KeInitializeEvent(&Event,NotificationEvent,FALSE);
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_WRITE,
KeInitializeEvent(
& Event,
NotificationEvent,
FALSE
);
Irp = IoBuildSynchronousFsdRequest(
IRP_MJ_WRITE,
FileObject->DeviceObject,
Buffer,
Length,
ByteOffset,
& Event,
IoStatusBlock);
IoStatusBlock
);
Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine;
Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext;
DPRINT("FileObject->DeviceObject %x\n",FileObject->DeviceObject);
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->FileObject = FileObject;
if (Key != NULL)
@ -181,16 +258,41 @@ NtWriteFile (
{
StackPtr->Parameters.Write.Key = 0;
}
Status = IoCallDriver(FileObject->DeviceObject,Irp);
if (Status == STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO))
Status = IoCallDriver(
FileObject->DeviceObject,
Irp
);
if (
(Status == STATUS_PENDING)
&& (FileObject->Flags & FO_SYNCHRONOUS_IO)
)
{
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
KeWaitForSingleObject(
& Event,
Executive,
KernelMode,
FALSE,
NULL
);
Status = Irp->IoStatus.Status;
}
return(Status);
return Status;
}
/**********************************************************************
* NAME EXPORTED
* NtReadFileScatter
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*
*/
NTSTATUS
STDCALL
NtReadFileScatter (
@ -209,6 +311,19 @@ NtReadFileScatter (
}
/**********************************************************************
* NAME EXPORTED
* NtWriteFileGather
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*
*/
NTSTATUS
STDCALL
NtWriteFileGather (
@ -225,3 +340,6 @@ NtWriteFileGather (
{
UNIMPLEMENTED;
}
/* EOF */

View file

@ -1,4 +1,5 @@
/*
/* $Id: symlink.c,v 1.9 1999/08/29 06:59:08 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/io/symlink.c
@ -19,57 +20,121 @@
/* GLOBALS ******************************************************************/
typedef struct
typedef
struct
{
CSHORT Type;
CSHORT Size;
UNICODE_STRING TargetName;
OBJECT_ATTRIBUTES Target;
} SYMLNK_OBJECT, *PSYMLNK_OBJECT;
POBJECT_TYPE IoSymbolicLinkType = NULL;
POBJECT_TYPE
IoSymbolicLinkType = NULL;
/* FUNCTIONS *****************************************************************/
NTSTATUS IopCreateSymbolicLink(PVOID Object,
/**********************************************************************
* NAME INTERNAL
* IopCreateSymbolicLink
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURNN VALUE
* Status.
*
* REVISIONS
*/
NTSTATUS
IopCreateSymbolicLink (
PVOID Object,
PVOID Parent,
PWSTR RemainingPath,
POBJECT_ATTRIBUTES ObjectAttributes)
POBJECT_ATTRIBUTES ObjectAttributes
)
{
if (Parent != NULL && RemainingPath != NULL)
if ( (Parent != NULL)
&& (RemainingPath != NULL)
)
{
ObAddEntryDirectory(Parent, Object, RemainingPath+1);
ObAddEntryDirectory(
Parent,
Object,
RemainingPath + 1
);
}
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
PVOID IopParseSymbolicLink(PVOID Object,
PWSTR* RemainingPath)
/**********************************************************************
* NAME INTERNAL
* IopParseSymbolicLink
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURNN VALUE
*
* REVISIONS
*/
PVOID
IopParseSymbolicLink (
PVOID Object,
PWSTR * RemainingPath
)
{
NTSTATUS Status;
PSYMLNK_OBJECT SymlinkObject = (PSYMLNK_OBJECT) Object;
PVOID ReturnedObject;
Status = ObReferenceObjectByName(SymlinkObject->Target.ObjectName,
Status = ObReferenceObjectByName(
SymlinkObject->Target.ObjectName,
0,
NULL,
STANDARD_RIGHTS_REQUIRED,
NULL,
UserMode,
NULL,
&ReturnedObject);
& ReturnedObject
);
if (NT_SUCCESS(Status))
{
return(ReturnedObject);
return ReturnedObject;
}
return(NULL);
return NULL;
}
VOID IoInitSymbolicLinkImplementation(VOID)
/**********************************************************************
* NAME INTERNAL
* IoInitSymbolicLinkImplementation
*
* DESCRIPTION
*
* ARGUMENTS
* None.
*
* RETURNN VALUE
* None.
*
* REVISIONS
*/
VOID
IoInitSymbolicLinkImplementation (VOID)
{
ANSI_STRING AnsiString;
IoSymbolicLinkType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE));
IoSymbolicLinkType = ExAllocatePool(
NonPagedPool,
sizeof (OBJECT_TYPE)
);
IoSymbolicLinkType->TotalObjects = 0;
IoSymbolicLinkType->TotalHandles = 0;
@ -87,13 +152,33 @@ VOID IoInitSymbolicLinkImplementation(VOID)
IoSymbolicLinkType->OkayToClose = NULL;
IoSymbolicLinkType->Create = IopCreateSymbolicLink;
RtlInitAnsiString(&AnsiString,"Symbolic Link");
RtlAnsiStringToUnicodeString(&IoSymbolicLinkType->TypeName,
&AnsiString,TRUE);
RtlInitAnsiString(
& AnsiString,
"Symbolic Link"
);
RtlAnsiStringToUnicodeString(
& IoSymbolicLinkType->TypeName,
& AnsiString,
TRUE
);
}
/**********************************************************************
* NAME EXPORTED
* NtOpenSymbolicLinkObject
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*
*/
NTSTATUS
STDCALL
NtOpenSymbolicLinkObject (
OUT PHANDLE LinkHandle,
IN ACCESS_MASK DesiredAccess,
@ -103,34 +188,52 @@ NtOpenSymbolicLinkObject (
NTSTATUS Status;
PVOID Object;
Status = ObReferenceObjectByName(ObjectAttributes->ObjectName,
Status = ObReferenceObjectByName(
ObjectAttributes->ObjectName,
ObjectAttributes->Attributes,
NULL,
DesiredAccess,
NULL,
UserMode,
NULL,
&Object);
& Object
);
if (!NT_SUCCESS(Status))
{
return(Status);
return Status;
}
Status = ObCreateHandle(PsGetCurrentProcess(),
Status = ObCreateHandle(
PsGetCurrentProcess(),
Object,
DesiredAccess,
FALSE,
LinkHandle);
LinkHandle
);
if (!NT_SUCCESS(Status))
{
return(Status);
return Status;
}
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
/**********************************************************************
* NAME EXPORTED
* NtQuerySymbolicLinkObject
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*
*/
NTSTATUS
STDCALL
NtQuerySymbolicLinkObject (
IN HANDLE LinkHandle,
IN OUT PUNICODE_STRING LinkTarget,
@ -140,34 +243,79 @@ NtQuerySymbolicLinkObject (
PSYMLNK_OBJECT SymlinkObject;
NTSTATUS Status;
Status = ObReferenceObjectByHandle(LinkHandle,
Status = ObReferenceObjectByHandle(
LinkHandle,
SYMBOLIC_LINK_QUERY,
IoSymbolicLinkType,
UserMode,
(PVOID *) & SymlinkObject,
NULL);
NULL
);
if (Status != STATUS_SUCCESS)
{
return(Status);
return Status;
}
RtlCopyUnicodeString(LinkTarget,SymlinkObject->Target.ObjectName);
RtlCopyUnicodeString(
LinkTarget,
SymlinkObject->Target.ObjectName
);
if (ReturnedLength != NULL)
{
*ReturnedLength = SymlinkObject->Target.Length;
}
ObDereferenceObject(SymlinkObject);
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
NTSTATUS IoCreateUnprotectedSymbolicLink(PUNICODE_STRING SymbolicLinkName,
PUNICODE_STRING DeviceName)
/**********************************************************************
* NAME EXPORTED
* IoCreateUnprotectedSymbolicLink
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*
*/
NTSTATUS
STDCALL
IoCreateUnprotectedSymbolicLink (
PUNICODE_STRING SymbolicLinkName,
PUNICODE_STRING DeviceName
)
{
return(IoCreateSymbolicLink(SymbolicLinkName,DeviceName));
return IoCreateSymbolicLink(
SymbolicLinkName,
DeviceName
);
}
NTSTATUS IoCreateSymbolicLink(PUNICODE_STRING SymbolicLinkName,
PUNICODE_STRING DeviceName)
/**********************************************************************
* NAME EXPORTED
* IoCreateSymbolicLink
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*
*/
NTSTATUS
STDCALL
IoCreateSymbolicLink (
PUNICODE_STRING SymbolicLinkName,
PUNICODE_STRING DeviceName
)
{
OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE SymbolicLinkHandle;
@ -175,41 +323,97 @@ NTSTATUS IoCreateSymbolicLink(PUNICODE_STRING SymbolicLinkName,
assert_irql(PASSIVE_LEVEL);
DPRINT("IoCreateSymbolicLink(SymbolicLinkName %w, DeviceName %w)\n",
SymbolicLinkName->Buffer,DeviceName->Buffer);
DPRINT(
"IoCreateSymbolicLink(SymbolicLinkName %w, DeviceName %w)\n",
SymbolicLinkName->Buffer,
DeviceName->Buffer
);
InitializeObjectAttributes(&ObjectAttributes,SymbolicLinkName,0,NULL,NULL);
SymbolicLink = ObCreateObject(&SymbolicLinkHandle,
InitializeObjectAttributes(
& ObjectAttributes,
SymbolicLinkName,
0,
NULL,
NULL
);
SymbolicLink = ObCreateObject(
& SymbolicLinkHandle,
SYMBOLIC_LINK_ALL_ACCESS,
& ObjectAttributes,
IoSymbolicLinkType);
IoSymbolicLinkType
);
if (SymbolicLink == NULL)
{
return(STATUS_UNSUCCESSFUL);
return STATUS_UNSUCCESSFUL;
}
ZwClose(SymbolicLinkHandle);
SymbolicLink->TargetName.Length = 0;
SymbolicLink->TargetName.MaximumLength =
((wcslen(DeviceName->Buffer) + 1) * sizeof(WCHAR));
SymbolicLink->TargetName.Buffer = ExAllocatePool(NonPagedPool,
SymbolicLink->TargetName.MaximumLength);
RtlCopyUnicodeString(&(SymbolicLink->TargetName), DeviceName);
SymbolicLink->TargetName.Buffer =
ExAllocatePool(
NonPagedPool,
SymbolicLink->TargetName.MaximumLength
);
RtlCopyUnicodeString(
& (SymbolicLink->TargetName),
DeviceName
);
DPRINT("DeviceName %w\n", SymbolicLink->TargetName.Buffer);
InitializeObjectAttributes(&(SymbolicLink->Target),
&(SymbolicLink->TargetName),0,NULL,NULL);
InitializeObjectAttributes(
& (SymbolicLink->Target),
& (SymbolicLink->TargetName),
0,
NULL,
NULL
);
DPRINT("%s() = STATUS_SUCCESS\n",__FUNCTION__);
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
/**********************************************************************
* NAME EXPORTED
* IoDeleteSymbolicLink
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*
*/
NTSTATUS
IoDeleteSymbolicLink(PUNICODE_STRING DeviceName)
STDCALL
IoDeleteSymbolicLink (
PUNICODE_STRING DeviceName
)
{
UNIMPLEMENTED;
}
/**********************************************************************
* NAME (EXPORTED as Zw)
* NtCreateSymbolicLinkObject
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*
*/
NTSTATUS
STDCALL
NtCreateSymbolicLinkObject (
@ -222,3 +426,5 @@ NtCreateSymbolicLinkObject (
UNIMPLEMENTED;
}
/* EOF */

View file

@ -1,4 +1,5 @@
/*
/* $Id: main.c,v 1.22 1999/08/29 06:59:10 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/main.c
@ -107,13 +108,13 @@ extern int edata;
extern int end;
static char * INIData =
"[HKEY_LOCAL_MACHINE\HARDWARE]\r\n"
"[HKEY_LOCAL_MACHINE\\HARDWARE]\r\n"
"\r\n"
"[HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP]\r\n"
"[HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP]\r\n"
"\r\n"
"[HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\AtDisk]\r\n"
"[HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\AtDisk]\r\n"
"\r\n"
"[HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\AtDisk\Controller 0]\r\n"
"[HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\AtDisk\\Controller 0]\r\n"
"Controller Address=dword:000001f0\r\n"
"Controller Interrupt=dword:0000000e\r\n"
"\r\n"
@ -148,7 +149,7 @@ asmlinkage void _main(boot_param* _bp)
*/
HalInitConsole(&bp);
DbgPrint("Starting ReactOS "KERNEL_VERSION"\n");
DbgPrint("Starting ReactOS "KERNEL_VERSION" (Build "__DATE__", "__TIME__")\n");
start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]);
if (start < ((int)&end))
@ -214,3 +215,5 @@ asmlinkage void _main(boot_param* _bp)
PsTerminateSystemThread(STATUS_SUCCESS);
}
/* EOF */

View file

@ -1,4 +1,5 @@
/*
/* $Id: section.c,v 1.14 1999/08/29 06:59:10 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/section.c
@ -179,7 +180,26 @@ NtCreateSection (
}
/**********************************************************************
* NAME
* NtOpenSection
*
* DESCRIPTION
*
* ARGUMENTS
* SectionHandle
*
* DesiredAccess
*
* ObjectAttributes
*
* RETURN VALUE
*
* REVISIONS
*
*/
NTSTATUS
STDCALL
NtOpenSection (
PHANDLE SectionHandle,
ACCESS_MASK DesiredAccess,
@ -191,27 +211,79 @@ NtOpenSection (
*SectionHandle = 0;
Status = ObReferenceObjectByName(ObjectAttributes->ObjectName,
Status = ObReferenceObjectByName(
ObjectAttributes->ObjectName,
ObjectAttributes->Attributes,
NULL,
DesiredAccess,
MmSectionType,
UserMode,
NULL,
&Object);
& Object
);
if (!NT_SUCCESS(Status))
{
return(Status);
return Status;
}
Status = ObCreateHandle(PsGetCurrentProcess(),
Status = ObCreateHandle(
PsGetCurrentProcess(),
Object,
DesiredAccess,
FALSE,
SectionHandle);
return(Status);
SectionHandle
);
return Status;
}
/**********************************************************************
* NAME EXPORTED
* NtMapViewOfSection
*
* DESCRIPTION
* Maps a view of a section into the virtual address space of a
* process.
*
* ARGUMENTS
* SectionHandle
* Handle of the section.
*
* ProcessHandle
* Handle of the process.
*
* BaseAddress
* Desired base address (or NULL) on entry;
* Actual base address of the view on exit.
*
* ZeroBits
* Number of high order address bits that must be zero.
*
* CommitSize
* Size in bytes of the initially committed section of
* the view.
*
* SectionOffset
* Offset in bytes from the beginning of the section
* to the beginning of the view.
*
* ViewSize
* Desired length of map (or zero to map all) on entry
* Actual length mapped on exit.
*
* InheritDisposition
* Specified how the view is to be shared with
* child processes.
*
* AllocateType
* Type of allocation for the pages.
*
* Protect
* Protection for the committed region of the view.
*
* RETURN VALUE
* Status.
*/
NTSTATUS
STDCALL
NtMapViewOfSection (
@ -226,34 +298,14 @@ NtMapViewOfSection (
ULONG AllocationType,
ULONG Protect
)
/*
* FUNCTION: Maps a view of a section into the virtual address space of a
* process
* ARGUMENTS:
* SectionHandle = Handle of the section
* ProcessHandle = Handle of the process
* BaseAddress = Desired base address (or NULL) on entry
* Actual base address of the view on exit
* ZeroBits = Number of high order address bits that must be zero
* CommitSize = Size in bytes of the initially committed section of
* the view
* SectionOffset = Offset in bytes from the beginning of the section
* to the beginning of the view
* ViewSize = Desired length of map (or zero to map all) on entry
* Actual length mapped on exit
* InheritDisposition = Specified how the view is to be shared with
* child processes
* AllocateType = Type of allocation for the pages
* Protect = Protection for the committed region of the view
* RETURNS: Status
*/
{
PSECTION_OBJECT Section;
PEPROCESS Process;
MEMORY_AREA * Result;
NTSTATUS Status;
DPRINT("NtMapViewOfSection(Section:%08lx, Process:%08lx,\n"
DPRINT(
"NtMapViewOfSection(Section:%08lx, Process:%08lx,\n"
" Base:%08lx, ZeroBits:%08lx, CommitSize:%08lx,\n"
" SectionOffs:%08lx, *ViewSize:%08lx, InheritDisp:%08lx,\n"
" AllocType:%08lx, Protect:%08lx)\n",
@ -266,54 +318,67 @@ NtMapViewOfSection (
*ViewSize,
InheritDisposition,
AllocationType,
Protect);
Protect
);
DPRINT(" *Base:%08lx\n", *BaseAddress);
Status = ObReferenceObjectByHandle(SectionHandle,
Status = ObReferenceObjectByHandle(
SectionHandle,
SECTION_MAP_READ,
MmSectionType,
UserMode,
(PVOID *) & Section,
NULL);
NULL
);
if (Status != STATUS_SUCCESS)
{
DPRINT("ObReference failed rc=%x\n",Status);
return(Status);
return Status;
}
DPRINT("Section %x\n",Section);
Status = ObReferenceObjectByHandle(ProcessHandle,
Status = ObReferenceObjectByHandle(
ProcessHandle,
PROCESS_VM_OPERATION,
PsProcessType,
UserMode,
(PVOID *) & Process,
NULL);
NULL
);
if (Status != STATUS_SUCCESS)
{
ObDereferenceObject(Section);
return(Status);
return Status;
}
DPRINT("ViewSize %x\n",ViewSize);
if ((*ViewSize) > Section->MaximumSize.u.LowPart)
{
(*ViewSize) = Section->MaximumSize.u.LowPart;
}
Status = MmCreateMemoryArea(UserMode,
Status = MmCreateMemoryArea(
UserMode,
Process,
MEMORY_AREA_SECTION_VIEW_COMMIT,
BaseAddress,
* ViewSize,
Protect,
&Result);
& Result
);
if (!NT_SUCCESS(Status))
{
DPRINT("NtMapViewOfSection() = %x\n",Status);
ObDereferenceObject(Process);
ObDereferenceObject(Section);
return(Status);
return Status;
}
Result->Data.SectionData.Section = Section;
@ -325,17 +390,37 @@ NtMapViewOfSection (
}
else
{
Result->Data.SectionData.ViewOffset = SectionOffset->u.LowPart;
Result->Data.SectionData.ViewOffset =
SectionOffset->u.LowPart;
}
DPRINT("*BaseAddress %x\n",*BaseAddress);
ObDereferenceObject(Process);
ObDereferenceObject(Section);
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
/**********************************************************************
* NAME EXPORTED
* NtUnmapViewOfSection
*
* DESCRIPTION
*
* ARGUMENTS
* ProcessHandle
*
* BaseAddress
*
* RETURN VALUE
* Status.
*
* REVISIONS
*
*/
NTSTATUS
STDCALL
NtUnmapViewOfSection (
HANDLE ProcessHandle,
PVOID BaseAddress
@ -344,19 +429,27 @@ NtUnmapViewOfSection (
PEPROCESS Process;
NTSTATUS Status;
Status = ObReferenceObjectByHandle(ProcessHandle,
Status = ObReferenceObjectByHandle(
ProcessHandle,
PROCESS_VM_OPERATION,
PsProcessType,
UserMode,
(PVOID *) & Process,
NULL);
NULL
);
if (Status != STATUS_SUCCESS)
{
return(Status);
return Status;
}
Status = MmFreeMemoryArea(Process,BaseAddress,0,TRUE);
Status = MmFreeMemoryArea(
Process,
BaseAddress,
0,
TRUE
);
ObDereferenceObject(Process);
return(Status);
return Status;
}
@ -395,3 +488,6 @@ NtExtendSection (
{
UNIMPLEMENTED;
}
/* EOF */

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.def,v 1.15 1999/08/17 12:01:38 ekohl Exp $
; $Id: ntoskrnl.def,v 1.16 1999/08/29 06:59:05 ea Exp $
;
; reactos/ntoskrnl/ntoskrnl.def
;
@ -104,7 +104,7 @@ IoConnectInterrupt
IoCreateController
IoCreateDevice
IoCreateStreamFileObject
IoCreateSymbolicLink
IoCreateSymbolicLink@8
IoDeleteController
IoDeleteDevice
IoDisconnectInterrupt

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.edf,v 1.3 1999/08/17 12:01:39 ekohl Exp $
; $Id: ntoskrnl.edf,v 1.4 1999/08/29 06:59:05 ea Exp $
;
; reactos/ntoskrnl/ntoskrnl.def
;
@ -104,7 +104,7 @@ IoConnectInterrupt
IoCreateController
IoCreateDevice
IoCreateStreamFileObject
IoCreateSymbolicLink
IoCreateSymbolicLink=IoCreateSymbolicLink@8
IoDeleteController
IoDeleteDevice
IoDisconnectInterrupt
@ -129,7 +129,7 @@ NtAllocateUuids=NtAllocateUuids@12
NtAllocateVirtualMemory=NtAllocateVirtualMemory@24
;NtBuildNumber <--- variable?
NtClose=NtClose@4
;NtConnectPort=;NtConnectPort@32
;NtConnectPort@32
NtConnectPort=NtConnectPort@8
NtCreateEvent=NtCreateEvent@20
NtCreateFile=NtCreateFile@44
@ -155,13 +155,13 @@ NtQueryEaFile=NtQueryEaFile@36
NtQueryInformationFile=NtQueryInformationFile@20
NtQueryInformationProcess=NtQueryInformationProcess@20
NtQueryInformationToken=NtQueryInformationToken@20
;NtQueryOleDirectoryFile=;NtQueryOleDirectoryFile@ <--- ?
;NtQueryOleDirectoryFile@ <--- ?
NtQuerySecurityObject=NtQuerySecurityObject@20
NtQueryVolumeInformationFile=NtQueryVolumeInformationFile@20
NtReadFile=NtReadFile@36
;NtRequestPort=;NtRequestPort@8
;NtRequestPort@8
NtRequestPort=NtRequestPort@20
;NtRequestWaitReplyPort=;NtRequestWaitReplyPort@8
;NtRequestWaitReplyPort@8
NtRequestWaitReplyPort=NtRequestWaitReplyPort@0
NtSetEvent=NtSetEvent@8
NtSetInformationFile=NtSetInformationFile@20
@ -169,7 +169,7 @@ NtSetInformationProcess=NtSetInformationProcess@16
NtSetInformationThread=NtSetInformationThread@16
NtSetSecurityObject=NtSetSecurityObject@12
NtUnlockFile=NtUnlockFile@20
;NtVdmControl=;NtVdmControl@8 <--- ?
;NtVdmControl@8 <--- ?
NtWaitForSingleObject=NtWaitForSingleObject@12
NtWriteFile=NtWriteFile@36
RtlAnsiStringToUnicodeString

View file

@ -1,4 +1,5 @@
/*
/* $Id: dirobj.c,v 1.5 1999/08/29 06:59:10 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ob/dirobj.c
@ -22,50 +23,107 @@
/* FUNCTIONS **************************************************************/
/**********************************************************************
* NAME EXPORTED
* NtOpenDirectoryObject
*
* DESCRIPTION
* Opens a namespace directory object.
*
* ARGUMENTS
* DirectoryHandle (OUT)
* Variable which receives the directory handle.
*
* DesiredAccess
* Desired access to the directory.
*
* ObjectAttributes
* Structure describing the directory.
*
* RETURN VALUE
* Status.
*
* NOTES
* Undocumented.
*/
NTSTATUS
STDCALL
NtOpenDirectoryObject (
PHANDLE DirectoryHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes
)
/*
* FUNCTION: Opens a namespace directory object
* ARGUMENTS:
* DirectoryHandle (OUT) = Variable which receives the directory handle
* DesiredAccess = Desired access to the directory
* ObjectAttributes = Structure describing the directory
* RETURNS: Status
* NOTES: Undocumented
*/
{
PVOID Object;
NTSTATUS Status;
*DirectoryHandle = 0;
Status = ObReferenceObjectByName(ObjectAttributes->ObjectName,
Status = ObReferenceObjectByName(
ObjectAttributes->ObjectName,
ObjectAttributes->Attributes,
NULL,
DesiredAccess,
ObDirectoryType,
UserMode,
NULL,
&Object);
& Object
);
if (!NT_SUCCESS(Status))
{
return(Status);
return Status;
}
Status = ObCreateHandle(PsGetCurrentProcess(),
Status = ObCreateHandle(
PsGetCurrentProcess(),
Object,
DesiredAccess,
FALSE,
DirectoryHandle);
return(STATUS_SUCCESS);
DirectoryHandle
);
return STATUS_SUCCESS;
}
/**********************************************************************
* NAME EXPORTED
* NtQueryDirectoryObject
*
* DESCRIPTION
* Reads information from a namespace directory.
*
* ARGUMENTS
* DirObjInformation (OUT)
* Buffer to hold the data read.
*
* BufferLength
* Size of the buffer in bytes.
*
* GetNextIndex
* If TRUE then set ObjectIndex to the index of the
* next object.
* If FALSE then set ObjectIndex to the number of
* objects in the directory.
*
* IgnoreInputIndex
* If TRUE start reading at index 0.
* If FALSE start reading at the index specified
* by object index.
*
* ObjectIndex
* Zero based index into the directory, interpretation
* depends on IgnoreInputIndex and GetNextIndex.
*
* DataWritten (OUT)
* Caller supplied storage for the number of bytes
* written (or NULL).
*
* RETURN VALUE
* Status.
*/
NTSTATUS
STDCALL
NtQueryDirectoryObject (
IN HANDLE DirObjHandle,
OUT POBJDIR_INFORMATION DirObjInformation,
@ -75,24 +133,6 @@ NtQueryDirectoryObject (
IN OUT PULONG ObjectIndex,
OUT PULONG DataWritten OPTIONAL
)
/*
* FUNCTION: Reads information from a namespace directory
* ARGUMENTS:
* DirObjInformation (OUT) = Buffer to hold the data read
* BufferLength = Size of the buffer in bytes
* GetNextIndex = If TRUE then set ObjectIndex to the index of the
* next object
* If FALSE then set ObjectIndex to the number of
* objects in the directory
* IgnoreInputIndex = If TRUE start reading at index 0
* If FALSE start reading at the index specified
* by object index
* ObjectIndex = Zero based index into the directory, interpretation
* depends on IgnoreInputIndex and GetNextIndex
* DataWritten (OUT) = Caller supplied storage for the number of bytes
* written (or NULL)
* RETURNS: Status
*/
{
PDIRECTORY_OBJECT dir = NULL;
ULONG EntriesToRead;
@ -102,20 +142,30 @@ NtQueryDirectoryObject (
ULONG EntriesToSkip;
NTSTATUS Status;
DPRINT("NtQueryDirectoryObject(DirObjHandle %x)\n",DirObjHandle);
DPRINT("dir %x namespc_root %x\n",dir,HEADER_TO_BODY(&(namespc_root.hdr)));
DPRINT(
"NtQueryDirectoryObject(DirObjHandle %x)\n",
DirObjHandle
);
DPRINT(
"dir %x namespc_root %x\n",
dir,
HEADER_TO_BODY(&(namespc_root.hdr))
);
// assert_irql(PASSIVE_LEVEL);
Status = ObReferenceObjectByHandle(DirObjHandle,
Status = ObReferenceObjectByHandle(
DirObjHandle,
DIRECTORY_QUERY,
ObDirectoryType,
UserMode,
(PVOID *) & dir,
NULL);
NULL
);
if (Status != STATUS_SUCCESS)
{
return(Status);
return Status;
}
EntriesToRead = BufferLength / sizeof (OBJDIR_INFORMATION);
@ -133,7 +183,7 @@ NtQueryDirectoryObject (
CHECKPOINT;
EntriesToSkip = *ObjectIndex;
while ( i<EntriesToSkip && current_entry!=NULL)
while ( (i < EntriesToSkip) && (current_entry != NULL))
{
current_entry = current_entry->Flink;
}
@ -144,21 +194,41 @@ NtQueryDirectoryObject (
/*
* Read the maximum entries possible into the buffer
*/
while ( i<EntriesToRead && current_entry!=(&(dir->head)))
while ( (i < EntriesToRead) && (current_entry != (&(dir->head))))
{
current = CONTAINING_RECORD(current_entry,OBJECT_HEADER,Entry);
DPRINT("Scanning %w\n",current->Name.Buffer);
current = CONTAINING_RECORD(
current_entry,
OBJECT_HEADER,
Entry
);
DPRINT(
"Scanning %w\n",
current->Name.Buffer
);
DirObjInformation[i].ObjectName.Buffer =
ExAllocatePool(NonPagedPool,(current->Name.Length+1)*2);
DirObjInformation[i].ObjectName.Length = current->Name.Length;
DirObjInformation[i].ObjectName.MaximumLength = current->Name.Length;
DPRINT("DirObjInformation[i].ObjectName.Buffer %x\n",
DirObjInformation[i].ObjectName.Buffer);
RtlCopyUnicodeString(&DirObjInformation[i].ObjectName,
&(current->Name));
ExAllocatePool(
NonPagedPool,
(current->Name.Length + 1) * 2
);
DirObjInformation[i].ObjectName.Length =
current->Name.Length;
DirObjInformation[i].ObjectName.MaximumLength =
current->Name.Length;
DPRINT(
"DirObjInformation[i].ObjectName.Buffer %x\n",
DirObjInformation[i].ObjectName.Buffer
);
RtlCopyUnicodeString(
& DirObjInformation[i].ObjectName,
& (current->Name)
);
i++;
current_entry = current_entry->Flink;
(*DataWritten) = (*DataWritten) + sizeof (OBJDIR_INFORMATION);
CHECKPOINT;
}
CHECKPOINT;
@ -179,10 +249,33 @@ NtQueryDirectoryObject (
}
*ObjectIndex = i;
}
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
/**********************************************************************
* NAME (EXPORTED as Zw)
* NtCreateDirectoryObject
*
* DESCRIPTION
* Creates or opens a directory object (a container for other
* objects).
*
* ARGUMENTS
* DirectoryHandle (OUT)
* Caller supplied storage for the handle of the
* directory.
*
* DesiredAccess
* Access desired to the directory.
*
* ObjectAttributes
* Object attributes initialized with
* InitializeObjectAttributes.
*
* RETURN VALUE
* Status.
*/
NTSTATUS
STDCALL
NtCreateDirectoryObject (
@ -190,56 +283,77 @@ NtCreateDirectoryObject (
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes
)
/*
* FUNCTION: Creates or opens a directory object (a container for other
* objects)
* ARGUMENTS:
* DirectoryHandle (OUT) = Caller supplied storage for the handle
* of the directory
* DesiredAccess = Access desired to the directory
* ObjectAttributes = Object attributes initialized with
* InitializeObjectAttributes
* RETURNS: Status
*/
{
PDIRECTORY_OBJECT dir;
dir = ObCreateObject(DirectoryHandle,
dir = ObCreateObject(
DirectoryHandle,
DesiredAccess,
ObjectAttributes,
ObDirectoryType);
return(STATUS_SUCCESS);
ObDirectoryType
);
return STATUS_SUCCESS;
}
VOID InitializeObjectAttributes(POBJECT_ATTRIBUTES InitializedAttributes,
/**********************************************************************
* NAME (MACRO in DDK)
* InitializeObjectAttributes
*
* DESCRIPTION
* Sets up a parameter of type OBJECT_ATTRIBUTES for a
* subsequent call to ZwCreateXXX or ZwOpenXXX.
*
* ARGUMENTS
* InitializedAttributes (OUT)
* Caller supplied storage for the object attributes.
*
* ObjectName
* Full path name for object.
*
* Attributes
* Attributes for the object.
*
* RootDirectory
* Where the object should be placed or NULL.
*
* SecurityDescriptor
* Ignored.
*
* NOTE
* Either ObjectName is a fully qualified pathname or a path
* relative to RootDirectory.
*/
VOID
InitializeObjectAttributes (
POBJECT_ATTRIBUTES InitializedAttributes,
PUNICODE_STRING ObjectName,
ULONG Attributes,
HANDLE RootDirectory,
PSECURITY_DESCRIPTOR SecurityDescriptor)
/*
* FUNCTION: Sets up a parameter of type OBJECT_ATTRIBUTES for a
* subsequent call to ZwCreateXXX or ZwOpenXXX
* ARGUMENTS:
* InitializedAttributes (OUT) = Caller supplied storage for the
* object attributes
* ObjectName = Full path name for object
* Attributes = Attributes for the object
* RootDirectory = Where the object should be placed or NULL
* SecurityDescriptor = Ignored
*
* NOTE:
* Either ObjectName is a fully qualified pathname or a path relative
* to RootDirectory
*/
PSECURITY_DESCRIPTOR SecurityDescriptor
)
{
DPRINT("InitializeObjectAttributes(InitializedAttributes %x "
DPRINT(
"InitializeObjectAttributes(InitializedAttributes %x "
"ObjectName %x Attributes %x RootDirectory %x)\n",
InitializedAttributes,ObjectName,Attributes,RootDirectory);
InitializedAttributes->Length=sizeof(OBJECT_ATTRIBUTES);
InitializedAttributes->RootDirectory=RootDirectory;
InitializedAttributes->ObjectName=ObjectName;
InitializedAttributes->Attributes=Attributes;
InitializedAttributes->SecurityDescriptor=SecurityDescriptor;
InitializedAttributes->SecurityQualityOfService=NULL;
InitializedAttributes,
ObjectName,
Attributes,
RootDirectory
);
InitializedAttributes->Length =
sizeof (OBJECT_ATTRIBUTES);
InitializedAttributes->RootDirectory =
RootDirectory;
InitializedAttributes->ObjectName =
ObjectName;
InitializedAttributes->Attributes =
Attributes;
InitializedAttributes->SecurityDescriptor =
SecurityDescriptor;
InitializedAttributes->SecurityQualityOfService =
NULL;
}
/* EOF */

View file

@ -1,4 +1,5 @@
/*
/* $Id: handle.c,v 1.11 1999/08/29 06:59:11 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ob/handle.c
@ -35,7 +36,10 @@ typedef struct
/* FUNCTIONS ***************************************************************/
static PHANDLE_REP ObpGetObjectByHandle(PEPROCESS Process,
static
PHANDLE_REP
ObpGetObjectByHandle(PEPROCESS Process,
HANDLE h)
/*
* FUNCTION: Get the data structure for a handle
@ -70,6 +74,7 @@ static PHANDLE_REP ObpGetObjectByHandle(PEPROCESS Process,
return(&(blk->handles[handle%HANDLE_BLOCK_ENTRIES]));
}
NTSTATUS
STDCALL
NtDuplicateObject (
@ -150,7 +155,9 @@ NtDuplicateObject (
return(STATUS_SUCCESS);
}
VOID ObDeleteHandleTable(PEPROCESS Process)
VOID
ObDeleteHandleTable(PEPROCESS Process)
/*
* FUNCTION: Deletes the handle table associated with a process
*/
@ -185,7 +192,9 @@ VOID ObDeleteHandleTable(PEPROCESS Process)
}
}
VOID ObCreateHandleTable(PEPROCESS Parent,
VOID
ObCreateHandleTable(PEPROCESS Parent,
BOOLEAN Inherit,
PEPROCESS Process)
/*
@ -207,7 +216,9 @@ VOID ObCreateHandleTable(PEPROCESS Parent,
}
}
VOID ObDeleteHandle(HANDLE Handle)
VOID
ObDeleteHandle(HANDLE Handle)
{
PHANDLE_REP Rep;
@ -218,7 +229,9 @@ VOID ObDeleteHandle(HANDLE Handle)
DPRINT("Finished ObDeleteHandle()\n");
}
NTSTATUS ObCreateHandle(PEPROCESS Process,
NTSTATUS
ObCreateHandle(PEPROCESS Process,
PVOID ObjectBody,
ACCESS_MASK GrantedAccess,
BOOLEAN Inherit,
@ -289,7 +302,8 @@ NTSTATUS ObCreateHandle(PEPROCESS Process,
}
NTSTATUS ObReferenceObjectByHandle(HANDLE Handle,
NTSTATUS
ObReferenceObjectByHandle(HANDLE Handle,
ACCESS_MASK DesiredAccess,
POBJECT_TYPE ObjectType,
KPROCESSOR_MODE AccessMode,
@ -378,13 +392,24 @@ NTSTATUS ObReferenceObjectByHandle(HANDLE Handle,
return(STATUS_SUCCESS);
}
NTSTATUS NtClose(HANDLE Handle)
/*
* FUNCTION: Closes a handle reference to an object
* ARGUMENTS:
* Handle = handle to close
* RETURNS: Status
/**********************************************************************
* NAME EXPORTED
* NtClose
*
* DESCRIPTION
* Closes a handle reference to an object.
*
* ARGUMENTS
* Handle
* Handle to close.
*
* RETURN VALUE
* Status.
*/
NTSTATUS
STDCALL
NtClose(HANDLE Handle)
{
PVOID ObjectBody;
POBJECT_HEADER Header;
@ -394,11 +419,13 @@ NTSTATUS NtClose(HANDLE Handle)
DPRINT("NtClose(Handle %x)\n",Handle);
HandleRep = ObpGetObjectByHandle(PsGetCurrentProcess(),
Handle);
HandleRep = ObpGetObjectByHandle(
PsGetCurrentProcess(),
Handle
);
if (HandleRep == NULL)
{
return(STATUS_INVALID_HANDLE);
return STATUS_INVALID_HANDLE;
}
ObjectBody = HandleRep->ObjectBody;
@ -409,15 +436,22 @@ NTSTATUS NtClose(HANDLE Handle)
Header->RefCount++;
Header->HandleCount--;
if (Header->ObjectType != NULL &&
Header->ObjectType->Close != NULL)
if ( (Header->ObjectType != NULL)
&& (Header->ObjectType->Close != NULL)
)
{
Header->ObjectType->Close(ObjectBody, Header->HandleCount);
Header->ObjectType->Close(
ObjectBody,
Header->HandleCount
);
}
Header->RefCount--;
ObPerformRetentionChecks(Header);
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
/* EOF */

View file

@ -1,4 +1,5 @@
/*
/* $Id: ntobj.c,v 1.5 1999/08/29 06:59:11 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ob/ntobj.c
@ -47,7 +48,10 @@ NtQueryObject (
}
VOID ObMakeTemporaryObject(PVOID ObjectBody)
VOID
ObMakeTemporaryObject (
PVOID ObjectBody
)
{
POBJECT_HEADER ObjectHeader;
@ -56,7 +60,20 @@ VOID ObMakeTemporaryObject(PVOID ObjectBody)
}
/**********************************************************************
* NAME EXPORTED
* NtMakeTemporaryObject
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*/
NTSTATUS
STDCALL
NtMakeTemporaryObject (
HANDLE Handle
)
@ -65,15 +82,17 @@ NtMakeTemporaryObject (
NTSTATUS Status;
POBJECT_HEADER ObjectHeader;
Status = ObReferenceObjectByHandle(Handle,
Status = ObReferenceObjectByHandle(
Handle,
0,
NULL,
KernelMode,
& Object,
NULL);
NULL
);
if (Status != STATUS_SUCCESS)
{
return(Status);
return Status;
}
ObjectHeader = BODY_TO_HEADER(Object);
@ -81,5 +100,8 @@ NtMakeTemporaryObject (
ObDereferenceObject(Object);
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
/* EOF */

View file

@ -1,4 +1,5 @@
/*
/* $Id: thread.c,v 1.25 1999/08/29 06:59:11 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ps/thread.c
@ -117,7 +118,11 @@ VOID PsBeginThread(PKSTART_ROUTINE StartRoutine, PVOID StartContext)
KeBugCheck(0);
}
static PETHREAD PsScanThreadList(KPRIORITY Priority)
static
PETHREAD
PsScanThreadList (
KPRIORITY Priority
)
{
PLIST_ENTRY current_entry;
PETHREAD current;
@ -126,20 +131,29 @@ static PETHREAD PsScanThreadList(KPRIORITY Priority)
// DPRINT("PsScanThreadList(Priority %d)\n",Priority);
current_entry = PriorityListHead[THREAD_PRIORITY_MAX+Priority].Flink;
current_entry =
PriorityListHead[THREAD_PRIORITY_MAX + Priority].Flink;
while (current_entry != &PriorityListHead[THREAD_PRIORITY_MAX+Priority])
{
current = CONTAINING_RECORD(current_entry,ETHREAD,Tcb.Entry);
current = CONTAINING_RECORD(
current_entry,
ETHREAD,
Tcb.Entry
);
if (current->Tcb.State == THREAD_STATE_TERMINATED &&
current != CurrentThread)
if ( (current->Tcb.State == THREAD_STATE_TERMINATED)
&& (current != CurrentThread)
)
{
PsReleaseThread(current);
}
if (current->Tcb.State == THREAD_STATE_RUNNABLE)
{
if (oldest == NULL || oldest_time > current->Tcb.LastTick)
if ( (oldest == NULL)
|| (oldest_time > current->Tcb.LastTick)
)
{
oldest = current;
oldest_time = current->Tcb.LastTick;
@ -148,10 +162,12 @@ static PETHREAD PsScanThreadList(KPRIORITY Priority)
current_entry = current_entry->Flink;
}
// DPRINT("PsScanThreadList() = %x\n",oldest);
return(oldest);
return oldest;
}
VOID PsDispatchThread(VOID)
VOID
PsDispatchThread (VOID)
{
KPRIORITY CurrentPriority;
PETHREAD Candidate;
@ -163,7 +179,10 @@ VOID PsDispatchThread(VOID)
return;
}
KeAcquireSpinLock(&ThreadListLock, &irql);
KeAcquireSpinLock(
& ThreadListLock,
& irql
);
DPRINT("PsDispatchThread() Current %x\n",CurrentThread);
@ -173,8 +192,9 @@ VOID PsDispatchThread(VOID)
}
for ( CurrentPriority = THREAD_PRIORITY_TIME_CRITICAL;
CurrentPriority>=THREAD_PRIORITY_IDLE;
CurrentPriority--)
(CurrentPriority >= THREAD_PRIORITY_IDLE);
CurrentPriority--
)
{
Candidate = PsScanThreadList(CurrentPriority);
if (Candidate == CurrentThread)
@ -183,7 +203,10 @@ VOID PsDispatchThread(VOID)
KeQueryTickCount(&TickCount);
CurrentThread->Tcb.LastTick = TickCount.u.LowPart;
CurrentThread->Tcb.State = THREAD_STATE_RUNNING;
KeReleaseSpinLock(&ThreadListLock,irql);
KeReleaseSpinLock(
& ThreadListLock,
irql
);
return;
}
if (Candidate != NULL)
@ -198,7 +221,10 @@ VOID PsDispatchThread(VOID)
CurrentThread = Candidate;
HalTaskSwitch(&CurrentThread->Tcb);
KeReleaseSpinLock(&ThreadListLock, irql);
KeReleaseSpinLock(
& ThreadListLock,
irql
);
return;
}
}
@ -206,11 +232,15 @@ VOID PsDispatchThread(VOID)
KeBugCheck(0);
}
NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
NTSTATUS
PsInitializeThread (
HANDLE ProcessHandle,
PETHREAD * ThreadPtr,
PHANDLE ThreadHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ThreadAttributes)
POBJECT_ATTRIBUTES ThreadAttributes
)
{
PETHREAD Thread;
NTSTATUS Status;
@ -273,7 +303,9 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
return(STATUS_SUCCESS);
}
VOID PsResumeThread(PETHREAD Thread)
VOID
PsResumeThread(PETHREAD Thread)
{
DPRINT("PsResumeThread(Thread %x)\n",Thread);
Thread->Tcb.SuspendCount--;
@ -286,7 +318,9 @@ VOID PsResumeThread(PETHREAD Thread)
DPRINT("Finished PsResumeThread()\n");
}
VOID PsSuspendThread(PETHREAD Thread)
VOID
PsSuspendThread(PETHREAD Thread)
{
DPRINT("PsSuspendThread(Thread %x)\n",Thread);
Thread->Tcb.SuspendCount++;
@ -300,12 +334,16 @@ VOID PsSuspendThread(PETHREAD Thread)
}
}
VOID PiDeleteThread(PVOID ObjectBody)
VOID
PiDeleteThread(PVOID ObjectBody)
{
DbgPrint("PiDeleteThread(ObjectBody %x)\n",ObjectBody);
}
VOID PsInitThreadManagment(VOID)
VOID
PsInitThreadManagment(VOID)
/*
* FUNCTION: Initialize thread managment
*/
@ -354,7 +392,9 @@ VOID PsInitThreadManagment(VOID)
DoneInitYet = TRUE;
}
NTSTATUS
STDCALL
NtCreateThread (
PHANDLE ThreadHandle,
ACCESS_MASK DesiredAccess,
@ -400,7 +440,9 @@ NtCreateThread (
return(STATUS_SUCCESS);
}
NTSTATUS PsCreateSystemThread(PHANDLE ThreadHandle,
NTSTATUS
PsCreateSystemThread(PHANDLE ThreadHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
HANDLE ProcessHandle,
@ -454,12 +496,16 @@ NTSTATUS PsCreateSystemThread(PHANDLE ThreadHandle,
return(STATUS_SUCCESS);
}
LONG KeSetBasePriorityThread(PKTHREAD Thread, LONG Increment)
LONG
KeSetBasePriorityThread(PKTHREAD Thread, LONG Increment)
{
UNIMPLEMENTED;
}
KPRIORITY KeSetPriorityThread(PKTHREAD Thread, KPRIORITY Priority)
KPRIORITY
KeSetPriorityThread(PKTHREAD Thread, KPRIORITY Priority)
{
KPRIORITY OldPriority;
OldPriority = Thread->BasePriority;
@ -638,3 +684,6 @@ NtYieldExecution(VOID)
PsDispatchThread();
return(STATUS_SUCCESS);
}
/* EOF */

View file

@ -1,7 +1,27 @@
/* $Id: interlck.c,v 1.3 1999/08/29 06:59:11 ea Exp $
*
* reactos/ntoskrnl/rtl/interlck.c
*
* FIXME: change decorated names when __fastcall will be available
* (for both egcs 1.1.2 and gcc 2.95 FASTCALL == STDCALL).
*/
#include <reactos/config.h>
#include <ntos.h>
#include <internal/debug.h>
void InterlockedIncrement(void);
__asm__("\n\t.global _InterlockedIncrement\n\t"
"_InterlockedIncrement:\n\t"
/**********************************************************************
* FASTCALL: @InterlockedIncrement@0
* STDCALL : _InterlockedIncrement@4
*/
LONG
FASTCALL
InterlockedIncrement (
PLONG Addend
);
__asm__(
"\n\t.global _InterlockedIncrement@4\n\t"
"_InterlockedIncrement@4:\n\t"
"pushl %ebp\n\t"
"movl %esp,%ebp\n\t"
"pushl %ebx\n\t"
@ -11,21 +31,60 @@ void InterlockedIncrement(void);
"popl %ebx\n\t"
"movl %ebp,%esp\n\t"
"popl %ebp\n\t"
"ret\n\t");
"ret $4\n\t"
);
/*
__asm__(
#ifndef CONFIG_USE_FASTCALL
".global _InterlockedIncrement@4\n"
"\t_InterlockedIncrement@4:\n"
"\tmovl 4(%esp), %ecx\n"
#else
".global @InterlockedIncrement@0\n"
"\t@InterlockedIncrement@0:\n"
#endif
"\tmov $1, %eax\n"
"\txadd %ecx, %eax\n"
"\tinc %eax\n\n"
#ifndef CONFIG_USE_FASTCALL
"\tret $4\n"
#endif
);
*/
void InterlockedDecrement(void);
__asm__("\n\t.global _InterlockedDecrement\n\t"
"_InterlockedDecrement:\n\t"
/**********************************************************************
* FASTCALL: @InterlockedDecrement@0
* STDCALL : _InterlockedDecrement@4
*/
LONG
FASTCALL
InterlockedDecrement (
PLONG Addend
);
__asm__(
"\n\t.global _InterlockedDecrement@4\n\t"
"_InterlockedDecrement@4:\n\t"
"movl $0xffffffff,%eax\n\t"
"movl 4(%esp),%ebx\n\t"
"xaddl %eax,(%ebx)\n\t"
"decl %eax\n\t"
"ret\n\t");
"ret $4\n\t"
);
void InterlockedExchange(void);
__asm__("\n\t.global _InterlockedExchange\n\t"
"_InterlockedExchange:\n\t"
/**********************************************************************
* FASTCALL: @InterlockedExchange@0
* STDCALL : _InterlockedExchange@8
*/
LONG
FASTCALL
InterlockedExchange (
PLONG Target,
LONG Value
);
__asm__(
"\n\t.global _InterlockedExchange@8\n\t"
"_InterlockedExchange@8:\n\t"
"pushl %ebp\n\t"
"movl %esp,%ebp\n\t"
"pushl %eax\n\t"
@ -37,22 +96,115 @@ void InterlockedExchange(void);
"popl %eax\n\t"
"movl %ebp,%esp\n\t"
"popl %ebp\n\t"
"ret\n\t");
"ret $8\n\t"
);
/*
__asm__(
#ifndef CONFIG_USE_FASTCALL
".global _InterlockedExchange@8\n"
"_InterlockedExchange@8:\n"
"\tmovl 4(%esp), %ecx\n"
"\tmovl 8(%esp), %edx\n"
#else
".global @InterlockedExchange@0\n"
"@InterlockedExchange@0:\n"
#endif
"\tmovl %ecx, %eax\n"
"__InterlockedExchange_Loop:\n"
"\tlock\n"
"\tcmpxchg %ecx, %edx\n"
"\tjne __InterlockedExchange_Loop\n"
#ifndef CONFIG_USE_FASTCALL
"\tmovl %ecx, 4(%esp)\n"
"\tret $8\n"
#else
"\tret\n"
#endif
);
*/
void InterlockedExchangeAdd(void);
__asm__("\n\t.global _InterlockedExchangeAdd\n\t"
"_InterlockedExchangeAdd:\n\t"
/**********************************************************************
* FASTCALL: @InterlockedExchangeAdd@0
* STDCALL : _InterlockedExchangeAdd@8
*/
LONG
FASTCALL
InterlockedExchangeAdd (
PLONG Addend,
LONG Value
);
__asm__(
"\n\t.global _InterlockedExchangeAdd@8\n\t"
"_InterlockedExchangeAdd@8:\n\t"
"movl 8(%esp),%eax\n\t"
"movl 4(%esp),%ebx\n\t"
"xaddl %eax,(%ebx)\n\t"
"ret\n\t");
"ret $8\n\t"
);
/*
__asm__(
#ifndef CONFIG_USE_FASTCALL
".global _InterlockedExchangeAdd@8\n"
"\t_InterlockedExchangeAdd@8:\n"
"\tmovl 4(%esp), %ecx\n"
"\tmovl 8(%esp), %edx\n"
#else
".global @InterlockedExchangeAdd@0\n"
"\t@InterlockedExchangeAdd@0:\n"
#endif
"\txadd %edx, %ecx\n"
"\tmovl %edx, %eax\n"
#ifndef CONFIG_USE_FASTCALL
"\tret $8\n"
#else
"\tret\n"
#endif
);
*/
void InterlockedCompareExchange(void);
__asm__("\n\t.global _InterlockedCompareExchange\n\t"
"_InterlockedCompareExchange:\n\t"
/**********************************************************************
* FASTCALL: @InterlockedCompareExchange@4
* STDCALL : _InterlockedCompareExchange@12
*/
PVOID
FASTCALL
InterlockedCompareExchange (
PVOID * Destination,
PVOID Exchange,
PVOID Comperand
);
__asm__(
"\n\t.global _InterlockedCompareExchange@12\n\t"
"_InterlockedCompareExchange@12:\n\t"
"movl 12(%esp),%eax\n\t"
"movl 8(%esp),%edx\n\t"
"movl 4(%esp),%ebx\n\t"
"cmpxchg %edx,(%ebx)\n\t"
"movl %edx,%eax\n\t"
"ret\n\t");
"ret $12\n\t"
);
/*
__asm__(
#ifndef CONFIG_USE_FASTCALL
".global _InterlockedCompareExchange@12\n"
"\t_InterlockedCompareExchange@12:\n"
"\tmovl 4(%esp), %ecx\n"
"\tmovl 8(%esp), %edx\n"
"\tmovl 12(%esp), %eax\n"
#else
".global @InterlockedCompareExchange@4\n"
"\t@InterlockedCompareExchange@4:\n"
"\tmovl 4(%esp), %eax\n"
#endif
"\tcmpxchg %ecx, %edx\n"
#ifndef CONFIG_USE_FASTCALL
"\tret $12\n"
#else
"\tret $4\n"
#endif
*/
/* EOF */