*** empty log message ***

svn path=/trunk/; revision=143
This commit is contained in:
David Welch 1999-01-01 22:03:17 +00:00
parent d55d012d33
commit 02e3d7b08e
45 changed files with 6603 additions and 7008 deletions

View file

@ -0,0 +1,10 @@
#include <ddk/ntddk.h>
#include <stdarg.h>
#include <string.h>
void main()
{
NtDisplayString("Shell Starting...\n");
ExitThread(0);
}

View file

@ -1,7 +1,9 @@
all: test.bin
all: hello.bin
test.bin: test.o
$(LD) -Ttext 0x10000 test.o ../../lib/ntdll/ntdll.a -o test.exe
$(OBJCOPY) -O binary test.exe test.bin
OBJECTS = ../common/crt0.o hello.o
hello.bin: $(OBJECTS)
$(LD) -Ttext 0x10000 $(OBJECTS) ../../lib/kernel32/kernel32.a ../../lib/ntdll/ntdll.a -o hello.exe
$(OBJCOPY) -O binary hello.exe hello.bin
include ../../rules.mak

View file

@ -1,11 +0,0 @@
BITS 32
EXTERN _NtDisplayString
_main:
push dword _string
call _NtDisplayString
l1:
jmp l1
_string db 'Hello world from user mode!',0xa,0

View file

@ -50,6 +50,19 @@ void ExecuteCd(char* cmdline)
void ExecuteDir(char* cmdline)
{
HANDLE shandle;
WIN32_FIND_DATA FindData;
shandle = FindFirstFile("*.*",&FindData);
if (shandle==INVALID_HANDLE_VALUE)
{
return;
}
do
{
debug_printf("Scanning %s\n",FindData.cFileName);
} while(FindNextFile(shandle,&FindData));
}
void ExecuteType(char* cmdline)
@ -76,6 +89,28 @@ void ExecuteType(char* cmdline)
}
}
int ExecuteProcess(char* name, char* cmdline)
{
PROCESS_INFORMATION ProcessInformation;
STARTUPINFO StartupInfo;
char arguments;
memset(&StartupInfo,0,sizeof(StartupInfo));
StartupInfo.cb = sizeof(STARTUPINFO);
StartupInfo.lpTitle = name;
return(CreateProcessA(name,
cmdline,
NULL,
NULL,
TRUE,
CREATE_NEW_CONSOLE,
NULL,
NULL,
&StartupInfo,
&ProcessInformation));
}
void ExecuteCommand(char* line)
{
char* cmd;
@ -122,6 +157,11 @@ void ExecuteCommand(char* line)
ExecuteType(tail);
return;
}
if (ExecuteProcess(cmd,tail))
{
debug_printf("Done ExecuteProcess\n");
return;
}
debug_printf("Unknown command\n");
}
@ -156,6 +196,8 @@ void main()
{
static char line[255];
KERNEL32_Init();
NtDisplayString("Shell Starting...\n");
KeyboardHandle = CreateFile("Keyboard",

View file

@ -486,12 +486,7 @@ NtContinue(
IN CINT IrqLevel
);
NTSTATUS
STDCALL
ZwContinue(
IN PCONTEXT Context,
IN CINT IrqLevel
);
NTSTATUS STDCALL ZwContinue(IN PCONTEXT Context, IN CINT IrqLevel);
/*

View file

@ -1,31 +1,34 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/stdlib/malloc.c
* PURPOSE: stdc memory allocation functions
* PROGRAMMER: ??
*/
/* INCLUDES ******************************************************************/
#include <windows.h>
#include <types.h>
/* FUNCTIONS *****************************************************************/
void* malloc(size_t size)
{
return(HeapAlloc(GetProcessHeap(),
0,
size));
return(HeapAlloc(GetProcessHeap(), 0, size));
}
void free(void* ptr)
{
HeapFree(GetProcessHeap(),
0,
ptr);
HeapFree(GetProcessHeap(), 0, ptr);
}
void* calloc(size_t nmemb, size_t size)
{
return(HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
nmemb*size));
return(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nmemb*size));
}
void* realloc(void* ptr, size_t size)
{
return(HeapReAlloc(GetProcessHeap(),
0,
ptr,
size));
return(HeapReAlloc(GetProcessHeap(), 0, ptr, size));
}

View file

@ -0,0 +1,68 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/kernel32/file/find.c
* PURPOSE: Find functions
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
* UPDATE HISTORY:
* Created 01/11/98
*/
#include <windows.h>
#include <wstring.h>
WINBOOL
FindCloseChangeNotification(
HANDLE hChangeHandle
)
{
return FALSE;
}
HANDLE
STDCALL
FindFirstChangeNotificationA(
LPCSTR lpPathName,
WINBOOL bWatchSubtree,
DWORD dwNotifyFilter
)
{
ULONG i;
WCHAR PathNameW[MAX_PATH];
i = 0;
while ((*lpPathName)!=0 && i < MAX_PATH)
{
PathNameW[i] = *lpPathName;
lpPathName++;
i++;
}
PathNameW[i] = 0;
return FindFirstChangeNotificationW(PathNameW, bWatchSubtree, dwNotifyFilter );
}
HANDLE
STDCALL
FindFirstChangeNotificationW(
LPCWSTR lpPathName,
WINBOOL bWatchSubtree,
DWORD dwNotifyFilter
)
{
return NULL;
}
WINBOOL
STDCALL
FindNextChangeNotification(
HANDLE hChangeHandle
)
{
return FALSE;
}

View file

@ -0,0 +1,450 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/kernel32/file/find.c
* PURPOSE: Find functions
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
* UPDATE HISTORY:
* Created 01/11/98
*/
#include <windows.h>
#include <wstring.h>
#include <ddk/ntddk.h>
typedef enum _FINDEX_INFO_LEVELS
{
FindExSearchNameMatch,
FindExSearchLimitToDirectories,
FindExSearchLimitToDevices,
} FINDEX_INFO_LEVELS ;
typedef enum _FINDEX_SEARCH_OPS
{
FindExInfoStandard
} FINDEX_SEARCH_OPS;
int wcharicmp ( WCHAR char1, WCHAR char2 );
WINBOOL
mfs_regexp(LPCWSTR lpFileName,LPCWSTR lpFilter);
HANDLE
STDCALL
FindFirstFileW(
LPCWSTR lpFileName,
LPWIN32_FIND_DATA lpFindFileData
);
WINBOOL
STDCALL
FindNextFileW(
HANDLE hFind,
LPWIN32_FIND_DATA lpFindFileData
);
HANDLE
STDCALL
FindFirstFileExA(
LPCSTR lpFileName,
FINDEX_INFO_LEVELS fInfoLevelId,
LPVOID lpFindFileData,
FINDEX_SEARCH_OPS fSearchOp,
LPVOID lpSearchFilter,
DWORD dwAdditionalFlags
);
HANDLE
STDCALL
FindFirstFileExW(
LPCWSTR lpFileName,
FINDEX_INFO_LEVELS fInfoLevelId,
LPVOID lpFindFileData,
FINDEX_SEARCH_OPS fSearchOp,
LPVOID lpSearchFilter,
DWORD dwAdditionalFlags
);
typedef struct _FIND_FILE_INFO
{
ULONG Offset;
PVOID SearchFilter;
WCHAR FileName[MAX_PATH];
WCHAR PathName[MAX_PATH];
FILE_DIRECTORY_INFORMATION *FileDirectory;
} FIND_FILE_INFO;
typedef struct _WIN32_FIND_DATAW {
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
DWORD dwReserved0;
DWORD dwReserved1;
WCHAR cFileName[ MAX_PATH ];
WCHAR cAlternateFileName[ 14 ];
} WIN32_FIND_DATAW, *LPWIN32_FIND_DATAW, *PWIN32_FIND_DATAW;
WINBOOL
STDCALL
FindClose(
HANDLE hFind
)
{
if ( hFind == NULL)
return FALSE;
HeapFree(GetProcessHeap(),0,((FIND_FILE_INFO *)hFind)->FileDirectory);
HeapFree(GetProcessHeap(),0,hFind);
return TRUE;
}
HANDLE
STDCALL
FindFirstFileA(
LPCSTR lpFileName,
LPWIN32_FIND_DATA lpFindFileData
)
{
WIN32_FIND_DATA FindFileDataW;
WCHAR FileNameW[MAX_PATH];
ULONG i;
i = 0;
while ((*lpFileName)!=0 && i < MAX_PATH)
{
FileNameW[i] = *lpFileName;
lpFileName++;
i++;
}
FileNameW[i] = 0;
FindFirstFileW(FileNameW,&FindFileDataW);
// converteer FindFileDataW
}
HANDLE
STDCALL
FindFirstFileW(
LPCWSTR lpFileName,
LPWIN32_FIND_DATA lpFindFileData
)
{
return FindFirstFileExW(lpFileName,FindExInfoStandard,lpFindFileData,FindExSearchNameMatch,NULL,0);
}
WINBOOL
STDCALL
FindNextFileA(
HANDLE hFind,
LPWIN32_FIND_DATA lpFindFileData
)
{
WIN32_FIND_DATA FindFileDataW;
FindNextFileW(hFind,&FindFileDataW);
// converteer FindFileDataW
}
WINBOOL
STDCALL
FindNextFileW(
HANDLE hFind,
LPWIN32_FIND_DATA lpFindFileData
)
{
int i;
WCHAR *pNameRead;
WCHAR FileName[MAX_PATH];
FIND_FILE_INFO *FindPtr = hFind;
FILE_DIRECTORY_INFORMATION *FileDirectory;
if ( FindPtr == NULL )
return FALSE;
/* Try to find a file */
FileDirectory = FindPtr->Offset + FindPtr->FileDirectory;
while ( FileDirectory->NextEntryOffset != 0 ) {
pNameRead = FileDirectory->FileName;
FindPtr->Offset += FileDirectory->NextEntryOffset;
for(i=0;i<FileDirectory->FileNameLength;i++)
dprintf("%c\n",(char)pNameRead[i]);
if (mfs_regexp(pNameRead, FindPtr->FileName))
{
/* We found one! */
if (FindPtr->PathName[0] != L'\0')
{
lstrcpyW(lpFindFileData->cFileName, FindPtr->PathName);
lstrcatW(lpFindFileData->cFileName, L"/");
lstrcatW(lpFindFileData->cFileName, pNameRead);
}
else
lstrcpyW(lpFindFileData->cFileName, pNameRead);
lstrcpyW(lpFindFileData->cAlternateFileName, L"");
lpFindFileData->dwReserved0 = 0;
lpFindFileData->dwReserved1 = 0;
return TRUE;
}
FileDirectory = FindPtr->Offset + FindPtr->FileDirectory;
}
return FALSE;
}
HANDLE
STDCALL
FindFirstFileExA(
LPCSTR lpFileName,
FINDEX_INFO_LEVELS fInfoLevelId,
LPVOID lpFindFileData,
FINDEX_SEARCH_OPS fSearchOp,
LPVOID lpSearchFilter,
DWORD dwAdditionalFlags
)
{
WCHAR FileNameW[MAX_PATH];
WIN32_FIND_DATAW FindFileDataW;
FindFirstFileExW(FileNameW,fInfoLevelId,&FindFileDataW,fSearchOp,lpSearchFilter,dwAdditionalFlags);
// conerteer FindFileDataW
}
HANDLE
STDCALL
FindFirstFileExW(
LPCWSTR lpFileName,
FINDEX_INFO_LEVELS fInfoLevelId,
LPVOID lpFindFileData,
FINDEX_SEARCH_OPS fSearchOp,
LPVOID lpSearchFilter,
DWORD dwAdditionalFlags
)
{
NTSTATUS errCode;
IO_STATUS_BLOCK IoStatusBlock;
HANDLE FileHandle = NULL;
FIND_FILE_INFO *hFind;
WCHAR *FilePart;
UNICODE_STRING FileNameString, PathNameString;
OBJECT_ATTRIBUTES ObjectAttributes;
ACCESS_MASK DesiredAccess=FILE_READ_DATA;
ULONG FileAttributes=FILE_ATTRIBUTE_DIRECTORY;
ULONG ShareAccess=FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
ULONG CreateDisposition=FILE_OPEN;
ULONG CreateOptions=FILE_DIRECTORY_FILE;
hFind = HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,sizeof(FIND_FILE_INFO));
hFind->FileDirectory = HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,8192);
/* Try to find a path and a filename in the passed filename */
lstrcpyW(hFind->PathName, lpFileName);
FilePart = wcsrchr(hFind->PathName, '\\');
if (FilePart == NULL){
GetCurrentDirectory(MAX_PATH, hFind->PathName);
lstrcpyW(hFind->FileName, lpFileName);
}
else {
FilePart[0] = L'\0';
lstrcpyW(hFind->FileName, &FilePart[1]);
}
hFind->Offset = 0;
PathNameString.Length = lstrlenW(hFind->PathName)*sizeof(WCHAR);
PathNameString.Buffer = hFind->PathName;
PathNameString.MaximumLength = FileNameString.Length;
FileNameString.Length = lstrlenW(hFind->FileName)*sizeof(WCHAR);
FileNameString.Buffer = hFind->FileName;
FileNameString.MaximumLength = FileNameString.Length;
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory = NULL;
ObjectAttributes.ObjectName = &PathNameString;
ObjectAttributes.Attributes = OBJ_CASE_INSENSITIVE| OBJ_INHERIT;
ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService = NULL;
errCode = NtCreateFile(
&FileHandle,
DesiredAccess,
&ObjectAttributes,
&IoStatusBlock,
NULL, // AllocationSize
FileAttributes,
ShareAccess,
CreateDisposition,
CreateOptions,
NULL, // EaBuffer
0); //
if ( !NT_SUCCESS(errCode) ) {
printf("%x\n",errCode);
return NULL;
}
errCode = NtQueryDirectoryFile(
FileHandle,
NULL,
NULL,
NULL,
&IoStatusBlock,
hFind->FileDirectory,
8192,
FileDirectoryInformation,
FALSE,
&FileNameString,
FALSE
);
if ( !NT_SUCCESS(errCode) ) {
printf("%x\n",errCode);
return NULL;
}
if ( FindNextFileW(hFind,lpFindFileData) )
return hFind;
else {
FindClose(hFind);
return NULL;
}
return NULL;
}
/************************************************************************/
WINBOOL
mfs_regexp(LPCWSTR lpFileName,LPCWSTR lpFilter)
{
/* The following code is provided by Tarang and I trust him...
*/
LPWSTR lpTempFileName = (LPWSTR)lpFileName;
LPWSTR lpTempFilter = (LPWSTR)lpFilter;
WCHAR TempToken [ 2 ];
WCHAR TempFilter [ 2 ];
WINBOOL Matched = FALSE;
if ( ( ! (LPWSTR)lpFileName ) || ( ! *(LPWSTR)lpFileName ) ||
( ! (LPWSTR)lpFilter ) || ( ! *(LPWSTR)lpFilter ) )
return 0L;
if ( ! lstrcmpW ( ( LPSTR )lpFilter, "*.*" ) )
{
wsprintf ( TempFilter, "*" );
lpTempFilter = TempFilter;
lpFilter = TempFilter;
}
while ( ( lpTempFilter ) && ( *lpTempFilter ) && ( ! Matched ) )
{
memset ( TempToken, 0, sizeof ( TempToken ) );
switch ( *lpTempFilter )
{
default:
if ( wcharicmp ( *lpTempFileName, *lpTempFilter ) )
{
lpTempFileName = (LPWSTR)lpFileName;
lpTempFilter = wcspbrk ( lpTempFilter, L" ,;" );
if ( lpTempFilter )
lpTempFilter+=sizeof(WCHAR);
}
else
{
lpTempFilter+=sizeof(WCHAR);
lpTempFileName+=sizeof(WCHAR);
switch ( *lpTempFilter )
{
default:
break;
case L'\0':
case L' ':
case L',':
case L';':
if ( ! *lpTempFileName )
Matched = TRUE;
break;
}
}
break;
case L'?':
lpTempFilter+=sizeof(WCHAR);
lpTempFileName+=sizeof(WCHAR);
break;
case L'*':
lpTempFilter += sizeof(WCHAR);
if ( ! ( TempToken [ 0 ] = *( lpTempFilter ) ) )
Matched = TRUE;
else
{
lpTempFilter+=sizeof(WCHAR);
while ( ( lpTempFileName = wcspbrk ( lpTempFileName, TempToken ) ) &&
( ! Matched ) ) {
lpTempFileName+= sizeof(WCHAR);
Matched = mfs_regexp ( lpTempFileName, lpTempFilter );
}
if ( ( ! lpTempFileName ) && ( ! Matched ) )
{
lpTempFileName = (LPWSTR)lpFileName;
lpTempFilter = wcspbrk ( lpTempFilter, L" ,;" );
if ( lpTempFilter )
lpTempFilter+=sizeof(WCHAR);
}
}
break;
case L'\0':
case L' ':
case L',':
case L';':
Matched = TRUE;
break;
}
}
return (DWORD)Matched;
}
int wcharicmp ( WCHAR char1, WCHAR char2 )
{
WCHAR Char1 = ( L'a' <= char1 ) && ( char1 <= L'z' ) ?
char1 - L'a' + L'A' : char1;
WCHAR Char2 = ( L'a' <= char2 ) && ( char2 <= L'z' ) ?
char2 - L'a' + L'A' : char2;
return ( Char2 - Char1 );
}

View file

@ -7,515 +7,123 @@
* UPDATE HISTORY:
* Created 01/11/98
*/
/* INCLUDES *****************************************************************/
#include <windows.h>
#include <wstring.h>
#include <ddk/ntddk.h>
typedef enum _FINDEX_INFO_LEVELS
/* TYPES ********************************************************************/
typedef struct _KERNEL32_FIND_FILE_DATA
{
FindExSearchNameMatch,
FindExSearchLimitToDirectories,
FindExSearchLimitToDevices,
HANDLE DirectoryHandle;
FILE_DIRECTORY_INFORMATION FileInfo;
} KERNEL32_FIND_FILE_DATA, *PKERNEL32_FIND_FILE_DATA;
} FINDEX_INFO_LEVELS ;
/* FUNCTIONS *****************************************************************/
typedef enum _FINDEX_SEARCH_OPS
HANDLE FindFirstFileA(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData)
{
FindExInfoStandard
} FINDEX_SEARCH_OPS;
int wcharicmp ( WCHAR char1, WCHAR char2 );
WINBOOL
mfs_regexp(LPCWSTR lpFileName,LPCWSTR lpFilter);
HANDLE
STDCALL
FindFirstFileW(
LPWSTR lpFileName,
LPWIN32_FIND_DATA lpFindFileData
);
WINBOOL
STDCALL
FindNextFileW(
HANDLE hFind,
LPWIN32_FIND_DATA lpFindFileData
);
HANDLE
STDCALL
FindFirstFileExA(
LPCSTR lpFileName,
FINDEX_INFO_LEVELS fInfoLevelId,
LPVOID lpFindFileData,
FINDEX_SEARCH_OPS fSearchOp,
LPVOID lpSearchFilter,
DWORD dwAdditionalFlags
);
HANDLE
STDCALL
FindFirstFileExW(
LPCWSTR lpFileName,
FINDEX_INFO_LEVELS fInfoLevelId,
LPVOID lpFindFileData,
FINDEX_SEARCH_OPS fSearchOp,
LPVOID lpSearchFilter,
DWORD dwAdditionalFlags
);
typedef struct _FIND_FILE_INFO
{
ULONG Offset;
PVOID SearchFilter;
WCHAR FileName[MAX_PATH];
WCHAR PathName[MAX_PATH];
FILE_DIRECTORY_INFORMATION *FileDirectory;
} FIND_FILE_INFO;
/*
typedef struct _WIN32_FIND_DATAW {
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
DWORD dwReserved0;
DWORD dwReserved1;
WCHAR cFileName[ MAX_PATH ];
WCHAR cAlternateFileName[ 14 ];
} WIN32_FIND_DATAW, *LPWIN32_FIND_DATAW, *PWIN32_FIND_DATAW;
*/
WINBOOL
STDCALL
FindClose(
HANDLE hFind
)
{
if ( hFind == NULL)
return FALSE;
HeapFree(GetProcessHeap(),0,((FIND_FILE_INFO *)hFind)->FileDirectory);
HeapFree(GetProcessHeap(),0,hFind);
return TRUE;
}
HANDLE
STDCALL
FindFirstFileA(
LPCSTR lpFileName,
LPWIN32_FIND_DATA lpFindFileData
)
{
WIN32_FIND_DATA FindFileDataW;
WCHAR FileNameW[MAX_PATH];
WCHAR lpFileNameW[MAX_PATH];
ULONG i;
i = 0;
while ((*lpFileName)!=0 && i < MAX_PATH)
while (lpFileName[i]!=0)
{
FileNameW[i] = *lpFileName;
lpFileName++;
lpFileNameW[i] = lpFileName[i];
i++;
}
FileNameW[i] = 0;
FindFirstFileW(FileNameW,&FindFileDataW);
// converteer FindFileDataW
return(FindFirstFileW(lpFileNameW,lpFindFileData));
}
HANDLE
STDCALL
FindFirstFileW(
LPWSTR lpFileName,
LPWIN32_FIND_DATA lpFindFileData
)
WINBOOL FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATA lpFindFileData)
{
return FindFirstFileExW(lpFileName,FindExInfoStandard,lpFindFileData,FindExSearchNameMatch,NULL,0);
return(FindNextFileW(hFindFile, lpFindFileData));
}
WINBOOL
STDCALL
FindNextFileA(
HANDLE hFind,
LPWIN32_FIND_DATA lpFindFileData
)
BOOL FindClose(HANDLE hFindFile)
{
WIN32_FIND_DATA FindFileDataW;
FindNextFileW(hFind,&FindFileDataW);
// converteer FindFileDataW
PKERNEL32_FIND_FILE_DATA IData;
IData = (PKERNEL32_FIND_FILE_DATA)hFindFile;
NtClose(IData->DirectoryHandle);
HeapFree(GetProcessHeap(), 0, IData);
return(TRUE);
}
WINBOOL
STDCALL
FindNextFileW(
HANDLE hFind,
LPWIN32_FIND_DATA lpFindFileData
)
HANDLE STDCALL FindFirstFileW(LPCWSTR lpFileName,
LPWIN32_FIND_DATA lpFindFileData)
{
int i;
WCHAR *pNameRead;
WCHAR FileName[MAX_PATH];
FIND_FILE_INFO *FindPtr = hFind;
FILE_DIRECTORY_INFORMATION *FileDirectory;
if ( FindPtr == NULL )
return FALSE;
/* Try to find a file */
FileDirectory = FindPtr->Offset + FindPtr->FileDirectory;
while ( FileDirectory->NextEntryOffset != 0 ) {
pNameRead = FileDirectory->FileName;
FindPtr->Offset += FileDirectory->NextEntryOffset;
for(i=0;i<FileDirectory->FileNameLength;i++)
printf("%c\n",(char)pNameRead[i]);
if (mfs_regexp(pNameRead, FindPtr->FileName))
{
/* We found one! */
if (FindPtr->PathName[0] != L'\0')
{
lstrcpyW(lpFindFileData->cFileName, FindPtr->PathName);
lstrcatW(lpFindFileData->cFileName, L"/");
lstrcatW(lpFindFileData->cFileName, pNameRead);
}
else
lstrcpyW(lpFindFileData->cFileName, pNameRead);
lstrcpyW(lpFindFileData->cAlternateFileName, L"");
lpFindFileData->dwReserved0 = 0;
lpFindFileData->dwReserved1 = 0;
return TRUE;
}
FileDirectory = FindPtr->Offset + FindPtr->FileDirectory;
}
return FALSE;
}
HANDLE
STDCALL
FindFirstFileExA(
LPCSTR lpFileName,
FINDEX_INFO_LEVELS fInfoLevelId,
LPVOID lpFindFileData,
FINDEX_SEARCH_OPS fSearchOp,
LPVOID lpSearchFilter,
DWORD dwAdditionalFlags
)
{
WCHAR FileNameW[MAX_PATH];
WIN32_FIND_DATAW FindFileDataW;
FindFirstFileExW(FileNameW,fInfoLevelId,&FindFileDataW,fSearchOp,lpSearchFilter,dwAdditionalFlags);
// conerteer FindFileDataW
}
HANDLE
STDCALL
FindFirstFileExW(
LPCWSTR lpFileName,
FINDEX_INFO_LEVELS fInfoLevelId,
LPVOID lpFindFileData,
FINDEX_SEARCH_OPS fSearchOp,
LPVOID lpSearchFilter,
DWORD dwAdditionalFlags
)
{
NTSTATUS errCode;
IO_STATUS_BLOCK IoStatusBlock;
HANDLE FileHandle = NULL;
FIND_FILE_INFO *hFind;
WCHAR *FilePart;
UNICODE_STRING FileNameString, PathNameString;
WCHAR CurrentDirectory[MAX_PATH];
WCHAR Pattern[MAX_PATH];
WCHAR Directory[MAX_PATH];
PWSTR End;
PKERNEL32_FIND_FILE_DATA IData;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING DirectoryNameStr;
IO_STATUS_BLOCK IoStatusBlock;
UNICODE_STRING PatternStr;
dprintf("FindFirstFileW(lpFileName %w, lpFindFileData %x)\n",
lpFileName, lpFindFileData);
ACCESS_MASK DesiredAccess=FILE_READ_DATA;
GetCurrentDirectoryW(MAX_PATH, CurrentDirectory);
Directory[0] = '\\';
Directory[1] = '?';
Directory[2] = '?';
Directory[3] = '\\';
Directory[4] = 0;
wcscat(Directory, CurrentDirectory);
wcscat(Directory, lpFileName);
End = wcschr(Directory, '\\');
*End = 0;
ULONG FileAttributes=FILE_ATTRIBUTE_DIRECTORY;
ULONG ShareAccess=FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
ULONG CreateDisposition=FILE_OPEN;
ULONG CreateOptions=FILE_DIRECTORY_FILE;
wcscpy(Pattern, End+1);
dprintf("Directory %w End %w\n",Directory,End);
hFind = HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,sizeof(FIND_FILE_INFO));
IData = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(KERNEL32_FIND_FILE_DATA));
hFind->FileDirectory = HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,8192);
RtlInitUnicodeString(&DirectoryNameStr, Directory);
InitializeObjectAttributes(&ObjectAttributes,
&DirectoryNameStr,
0,
NULL,
NULL);
/* Try to find a path and a filename in the passed filename */
lstrcpyW(hFind->PathName, lpFileName);
FilePart = wcsrchr(hFind->PathName, '\\');
if (FilePart == NULL){
GetCurrentDirectory(MAX_PATH, hFind->PathName);
lstrcpyW(hFind->FileName, lpFileName);
}
else {
FilePart[0] = L'\0';
lstrcpyW(hFind->FileName, &FilePart[1]);
}
hFind->Offset = 0;
PathNameString.Length = lstrlenW(hFind->PathName)*sizeof(WCHAR);
PathNameString.Buffer = hFind->PathName;
PathNameString.MaximumLength = FileNameString.Length;
FileNameString.Length = lstrlenW(hFind->FileName)*sizeof(WCHAR);
FileNameString.Buffer = hFind->FileName;
FileNameString.MaximumLength = FileNameString.Length;
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory = NULL;
ObjectAttributes.ObjectName = &PathNameString;
ObjectAttributes.Attributes = OBJ_CASE_INSENSITIVE| OBJ_INHERIT;
ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService = NULL;
errCode = NtCreateFile(
&FileHandle,
DesiredAccess,
if (ZwOpenFile(&IData->DirectoryHandle,
FILE_TRAVERSE,
&ObjectAttributes,
&IoStatusBlock,
NULL, // AllocationSize
FileAttributes,
ShareAccess,
CreateDisposition,
CreateOptions,
NULL, // EaBuffer
0); //
if ( !NT_SUCCESS(errCode) ) {
printf("%x\n",errCode);
return NULL;
0,
OPEN_EXISTING)!=STATUS_SUCCESS)
{
return(NULL);
}
errCode = NtQueryDirectoryFile(
FileHandle,
RtlInitUnicodeString(&PatternStr, Pattern);
NtQueryDirectoryFile(IData->DirectoryHandle,
NULL,
NULL,
NULL,
&IoStatusBlock,
hFind->FileDirectory,
8192,
(PVOID)&IData->FileInfo,
sizeof(IData->FileInfo),
FileDirectoryInformation,
FALSE,
&FileNameString,
FALSE
);
if ( !NT_SUCCESS(errCode) ) {
printf("%x\n",errCode);
return NULL;
TRUE,
&PatternStr,
FALSE);
return(IData);
}
if ( FindNextFileW(hFind,lpFindFileData) )
return hFind;
else {
FindClose(hFind);
return NULL;
}
return NULL;
}
WINBOOL
FindCloseChangeNotification(
HANDLE hChangeHandle
)
WINBOOL STDCALL FindNextFileW(HANDLE hFindFile,
LPWIN32_FIND_DATA lpFindFileData)
{
return FALSE;
}
HANDLE
STDCALL
FindFirstChangeNotificationA(
LPCSTR lpPathName,
WINBOOL bWatchSubtree,
DWORD dwNotifyFilter
)
{
ULONG i;
WCHAR PathNameW[MAX_PATH];
i = 0;
while ((*lpPathName)!=0 && i < MAX_PATH)
{
PathNameW[i] = *lpPathName;
lpPathName++;
i++;
}
PathNameW[i] = 0;
return FindFirstChangeNotificationW(PathNameW, bWatchSubtree, dwNotifyFilter );
}
HANDLE
STDCALL
FindFirstChangeNotificationW(
LPCWSTR lpPathName,
WINBOOL bWatchSubtree,
DWORD dwNotifyFilter
)
{
return NULL;
}
WINBOOL
STDCALL
FindNextChangeNotification(
HANDLE hChangeHandle
)
{
return FALSE;
}
/************************************************************************/
WINBOOL
mfs_regexp(LPCWSTR lpFileName,LPCWSTR lpFilter)
{
/* The following code is provided by Tarang and I trust him...
*/
LPWSTR lpTempFileName = (LPWSTR)lpFileName;
LPWSTR lpTempFilter = (LPWSTR)lpFilter;
WCHAR TempToken [ 2 ];
WCHAR TempFilter [ 2 ];
WINBOOL Matched = FALSE;
if ( ( ! (LPWSTR)lpFileName ) || ( ! *(LPWSTR)lpFileName ) ||
( ! (LPWSTR)lpFilter ) || ( ! *(LPWSTR)lpFilter ) )
return 0L;
if ( ! lstrcmpW ( ( LPSTR )lpFilter, "*.*" ) )
{
wsprintf ( TempFilter, "*" );
lpTempFilter = TempFilter;
lpFilter = TempFilter;
}
while ( ( lpTempFilter ) && ( *lpTempFilter ) && ( ! Matched ) )
{
memset ( TempToken, 0, sizeof ( TempToken ) );
switch ( *lpTempFilter )
{
default:
if ( wcharicmp ( *lpTempFileName, *lpTempFilter ) )
{
lpTempFileName = (LPWSTR)lpFileName;
lpTempFilter = wcspbrk ( lpTempFilter, L" ,;" );
if ( lpTempFilter )
lpTempFilter+=sizeof(WCHAR);
}
else
{
lpTempFilter+=sizeof(WCHAR);
lpTempFileName+=sizeof(WCHAR);
switch ( *lpTempFilter )
{
default:
break;
case L'\0':
case L' ':
case L',':
case L';':
if ( ! *lpTempFileName )
Matched = TRUE;
break;
}
}
break;
case L'?':
lpTempFilter+=sizeof(WCHAR);
lpTempFileName+=sizeof(WCHAR);
break;
case L'*':
lpTempFilter += sizeof(WCHAR);
if ( ! ( TempToken [ 0 ] = *( lpTempFilter ) ) )
Matched = TRUE;
else
{
lpTempFilter+=sizeof(WCHAR);
while ( ( lpTempFileName = wcspbrk ( lpTempFileName, TempToken ) ) &&
( ! Matched ) ) {
lpTempFileName+= sizeof(WCHAR);
Matched = mfs_regexp ( lpTempFileName, lpTempFilter );
}
if ( ( ! lpTempFileName ) && ( ! Matched ) )
{
lpTempFileName = (LPWSTR)lpFileName;
lpTempFilter = wcspbrk ( lpTempFilter, L" ,;" );
if ( lpTempFilter )
lpTempFilter+=sizeof(WCHAR);
}
}
break;
case L'\0':
case L' ':
case L',':
case L';':
Matched = TRUE;
break;
}
}
return (DWORD)Matched;
}
int wcharicmp ( WCHAR char1, WCHAR char2 )
{
WCHAR Char1 = ( L'a' <= char1 ) && ( char1 <= L'z' ) ?
char1 - L'a' + L'A' : char1;
WCHAR Char2 = ( L'a' <= char2 ) && ( char2 <= L'z' ) ?
char2 - L'a' + L'A' : char2;
return ( Char2 - Char1 );
}

View file

@ -0,0 +1,124 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/kernel32/file/find.c
* PURPOSE: Find functions
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
* UPDATE HISTORY:
* Created 01/11/98
*/
/* INCLUDES *****************************************************************/
#include <windows.h>
#include <wstring.h>
#include <ddk/ntddk.h>
/* TYPES ********************************************************************/
typedef struct _KERNEL32_FIND_FILE_DATA;
{
HANDLE DirectoryHandle;
FILE_DIRECTORY_INFORMATION FileInfo;
} KERNEL32_FIND_FILE_DATA, *PKERNEL32_FIND_FILE_DATA;
/* FUNCTIONS *****************************************************************/
HANDLE FindFirstFileA(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData)
{
WCHAR lpFileNameW[MAX_PATH];
ULONG i;
i = 0;
while (lpFileName[i]!=0)
{
lpFileName[i] = lpFileName[i];
i++;
}
return(FindFirstFileW(lpFileName,lpFindFileData));
}
BOOLEAN FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATA lpFindFileData)
{
return(FindNextFileW(hFindFile, lpFindFileData));
}
BOOL FindClose(HANDLE hFindFile)
{
PKERNEL32_FIND_FILE_DATA IData;
IData = (PKERNEL32_FIND_FILE_DATA)hFindFile;
NtClose(IData->DirectoryHandle);
HeapFree(IData);
}
HANDLE STDCALL FindFirstFileW(LPCWSTR lpFileName,
LPWIN32_FIND_DATA lpFindFileData)
{
WCHAR CurrentDirectory[MAX_PATH];
WCHAR Pattern[MAX_PATH];
WCHAR Directory[MAX_PATH];
PWSTR End;
PKERNEL32_FIND_FILE_DATA IData;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING DirectoryNameStr;
IO_STATUS_BLOCK IoStatusBlock;
dprintf("FindFirstFileW(lpFileName %w, lpFindFileData %x)\n",
lpFileName, lpFindFileData);
GetCurrentDirectoryW(MAX_PATH, CurrentDirectory);
Directory[0] = '\\';
Directory[1] = '?';
Directory[2] = '?';
Directory[3] = '\\';
Directory[4] = 0;
wstrcat(Directory, CurrentDirectory);
wstrcat(Directory, lpFileName);
End = wstrchr(Directory, '\\');
*End = 0;
wstrcpy(Pattern, End+1);
dprintf("Directory %w End %w\n",Directory,End);
IData = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(KERNEL32_FIND_FILE_DATA));
RtlInitUnicodeString(&DirectoryNameStr, Directory);
InitializeObjectAttributes(&ObjectAttributes,
&DirectoryNameStr,
0,
NULL,
NULL);
if (ZwOpenFile(&IData->DirectoryHandle,
FILE_TRAVERSE,
&ObjectAttributes,
0,
OPEN_EXISTING)!=STATUS_SUCCESS)
{
return(NULL);
}
NtQueryDirectoryFile(IData->DirectoryHandle,
NULL,
NULL,
NULL,
&IoStatusBlock,
&IData->FileInfo,
sizeof(IData->FileInfo),
FileDirectoryInformation,
TRUE,
Pattern,
FALSE);
return(IData);
}
WINBOOL STDCALL FindNextFileW(HANDLE hFindFile,
LPWIN32_FIND_DATA lpFindFileData)
{
}

View file

@ -0,0 +1,8 @@
#include <windows.h>
#include <ddk/ntddk.h>
#include <stdarg.h>
VOID KERNEL32_Init(VOID)
{
__HeapInit(0, 4*1024*1024, 4*1024*1024);
}

View file

@ -1,379 +0,0 @@
/*
* linux/lib/vsprintf.c
*
* Copyright (C) 1991, 1992 Linus Torvalds
*/
/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
/*
* Wirzenius wrote this portably, Torvalds fucked it up :-)
*/
/*
* Appropiated for the reactos kernel, March 1998 -- David Welch
*/
#include <stdarg.h>
#include <internal/debug.h>
#include <internal/ctype.h>
#include <internal/string.h>
unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
{
unsigned long result = 0,value;
if (!base) {
base = 10;
if (*cp == '0') {
base = 8;
cp++;
if ((*cp == 'x') && isxdigit(cp[1])) {
cp++;
base = 16;
}
}
}
while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp)
? toupper(*cp) : *cp)-'A'+10) < base) {
result = result*base + value;
cp++;
}
if (endp)
*endp = (char *)cp;
return result;
}
/* we use this so that we can do without the ctype library */
#define is_digit(c) ((c) >= '0' && (c) <= '9')
static int skip_atoi(const char **s)
{
int i=0;
while (is_digit(**s))
i = i*10 + *((*s)++) - '0';
return i;
}
#define ZEROPAD 1 /* pad with zero */
#define SIGN 2 /* unsigned/signed long */
#define PLUS 4 /* show plus */
#define SPACE 8 /* space if plus */
#define LEFT 16 /* left justified */
#define SPECIAL 32 /* 0x */
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
#define do_div(n,base) ({ \
int __res; \
__res = ((unsigned long) n) % (unsigned) base; \
n = ((unsigned long) n) / (unsigned) base; \
__res; })
static char * number(char * str, long num, int base, int size, int precision
,int type)
{
char c,sign,tmp[66];
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
int i;
if (type & LARGE)
digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (type & LEFT)
type &= ~ZEROPAD;
if (base < 2 || base > 36)
return 0;
c = (type & ZEROPAD) ? '0' : ' ';
sign = 0;
if (type & SIGN) {
if (num < 0) {
sign = '-';
num = -num;
size--;
} else if (type & PLUS) {
sign = '+';
size--;
} else if (type & SPACE) {
sign = ' ';
size--;
}
}
if (type & SPECIAL) {
if (base == 16)
size -= 2;
else if (base == 8)
size--;
}
i = 0;
if (num == 0)
tmp[i++]='0';
else while (num != 0)
tmp[i++] = digits[do_div(num,base)];
if (i > precision)
precision = i;
size -= precision;
if (!(type&(ZEROPAD+LEFT)))
while(size-->0)
*str++ = ' ';
if (sign)
*str++ = sign;
if (type & SPECIAL)
if (base==8)
*str++ = '0';
else if (base==16) {
*str++ = '0';
*str++ = digits[33];
}
if (!(type & LEFT))
while (size-- > 0)
*str++ = c;
while (i < precision--)
*str++ = '0';
while (i-- > 0)
*str++ = tmp[i];
while (size-- > 0)
*str++ = ' ';
return str;
}
int vsprintf(char *buf, const char *fmt, va_list args)
{
int len;
unsigned long num;
int i, base;
char * str;
const char *s;
const short int* sw;
int flags; /* flags to number() */
int field_width; /* width of output field */
int precision; /* min. # of digits for integers; max
number of chars for from string */
int qualifier; /* 'h', 'l', or 'L' for integer fields */
for (str=buf ; *fmt ; ++fmt) {
if (*fmt != '%') {
*str++ = *fmt;
continue;
}
/* process flags */
flags = 0;
repeat:
++fmt; /* this also skips first '%' */
switch (*fmt) {
case '-': flags |= LEFT; goto repeat;
case '+': flags |= PLUS; goto repeat;
case ' ': flags |= SPACE; goto repeat;
case '#': flags |= SPECIAL; goto repeat;
case '0': flags |= ZEROPAD; goto repeat;
}
/* get field width */
field_width = -1;
if (is_digit(*fmt))
field_width = skip_atoi(&fmt);
else if (*fmt == '*') {
++fmt;
/* it's the next argument */
field_width = va_arg(args, int);
if (field_width < 0) {
field_width = -field_width;
flags |= LEFT;
}
}
/* get the precision */
precision = -1;
if (*fmt == '.') {
++fmt;
if (is_digit(*fmt))
precision = skip_atoi(&fmt);
else if (*fmt == '*') {
++fmt;
/* it's the next argument */
precision = va_arg(args, int);
}
if (precision < 0)
precision = 0;
}
/* get the conversion qualifier */
qualifier = -1;
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
qualifier = *fmt;
++fmt;
}
/* default base */
base = 10;
switch (*fmt) {
case 'c':
if (!(flags & LEFT))
while (--field_width > 0)
*str++ = ' ';
*str++ = (unsigned char) va_arg(args, int);
while (--field_width > 0)
*str++ = ' ';
continue;
case 'w':
sw = va_arg(args,short int *);
// DPRINT("L %x\n",sw);
if (sw==NULL)
{
// CHECKPOINT;
s = "<NULL>";
while ((*s)!=0)
{
*str++ = *s++;
}
// CHECKPOINT;
// DbgPrint("str %x\n",str);
}
else
{
while ((*sw)!=0)
{
*str++ = (char)(*sw++);
}
}
// CHECKPOINT;
continue;
case 's':
s = va_arg(args, char *);
if (!s)
s = "<NULL>";
len = strnlen(s, precision);
if (!(flags & LEFT))
while (len < field_width--)
*str++ = ' ';
for (i = 0; i < len; ++i)
*str++ = *s++;
while (len < field_width--)
*str++ = ' ';
continue;
case 'p':
if (field_width == -1) {
field_width = 2*sizeof(void *);
flags |= ZEROPAD;
}
str = number(str,
(unsigned long) va_arg(args, void *), 16,
field_width, precision, flags);
continue;
case 'n':
if (qualifier == 'l') {
long * ip = va_arg(args, long *);
*ip = (str - buf);
} else {
int * ip = va_arg(args, int *);
*ip = (str - buf);
}
continue;
/* integer number formats - set up the flags and "break" */
case 'o':
base = 8;
break;
case 'b':
base = 2;
break;
case 'X':
flags |= LARGE;
case 'x':
base = 16;
break;
case 'd':
case 'i':
flags |= SIGN;
case 'u':
break;
default:
if (*fmt != '%')
*str++ = '%';
if (*fmt)
*str++ = *fmt;
else
--fmt;
continue;
}
if (qualifier == 'l')
num = va_arg(args, unsigned long);
else if (qualifier == 'h')
if (flags & SIGN)
num = va_arg(args, short);
else
num = va_arg(args, unsigned short);
else if (flags & SIGN)
num = va_arg(args, int);
else
num = va_arg(args, unsigned int);
str = number(str, num, base, field_width, precision, flags);
}
*str = '\0';
return str-buf;
}
int sprintf(char * buf, const char *fmt, ...)
{
va_list args;
int i;
va_start(args, fmt);
i=vsprintf(buf,fmt,args);
va_end(args);
return i;
}
int wsprintfA(char * buf, const char *fmt, ...)
{
va_list args;
int i;
va_start(args, fmt);
i=vsprintf(buf,fmt,args);
va_end(args);
return i;
}
int wsprintfW(unsigned short * buf, const unsigned short *fmt, ...)
{
va_list args;
int i;
va_start(args, fmt);
//i=vsprintf(buf,fmt,args);
va_end(args);
return i;
}
unsigned short towupper(unsigned short w)
{
if ( w < L'A' )
return w + 'A';
else
return w;
}
char iswlower(unsigned short w)
{
if ( w < L'A' )
return 1;
else
return 0;
}

View file

@ -6,17 +6,17 @@ MISC_OBJECTS = misc/error.o misc/atom.o misc/handle.o misc/env.o misc/dllmain.o
FILE_OBJECTS = file/file.o file/curdir.o file/lfile.o file/dir.o \
file/iocompl.o file/volume.o file/deviceio.o file/dosdev.o \
file/create.o
file/create.o file/find.o file/cnotify.o
MEM_OBJECTS = mem/virtual.o mem/heap.o mem/utils.o
THREAD_OBJECTS = thread/thread.o
PROCESS_OBJECTS = process/proc.o
PROCESS_OBJECTS = process/proc.o process/cmdline.o
STRING_OBJECTS = string/lstring.o
INTERNAL_OBJECTS = internal/dprintf.o
INTERNAL_OBJECTS = internal/dprintf.o internal/init.o
EXCEPT_OBJECTS = except/except.o
@ -29,7 +29,7 @@ OBJECTS = $(MISC_OBJECTS) $(FILE_OBJECTS) $(THREAD_OBJECTS) \
kernel32.a: $(OBJECTS)
$(AR) vrcs kernel32.a $(OBJECTS)
$(AR) rcs kernel32.a $(OBJECTS)
dummy:

View file

@ -44,7 +44,7 @@ static HEAP_BUCKET __HeapDefaultBuckets[]=
{ NULL, 256, 15, 4088 },
};
PHEAP __ProcessHeap;
PHEAP __ProcessHeap = NULL;
static BOOL __HeapCommit(PHEAP pheap, LPVOID start, LPVOID end);
static BOOL __HeapDecommit(PHEAP pheap, LPVOID start, LPVOID end);
@ -61,8 +61,6 @@ static BOOL __HeapFreeFragment(PHEAP pheap, ULONG flags, LPVOID ptr);
static PHEAP __HeapPrepare(LPVOID base, ULONG minsize, ULONG maxsize,
ULONG flags);
/*********************************************************************
* __HeapCommit *
* *
@ -625,7 +623,7 @@ PHEAP __HeapPrepare(LPVOID base, ULONG minsize, ULONG maxsize, ULONG flags)
VOID WINAPI __HeapInit(LPVOID base, ULONG minsize, ULONG maxsize)
{
VirtualAlloc(base,maxsize,MEM_RESERVE,PAGE_READWRITE);
base = VirtualAlloc(base,maxsize,MEM_RESERVE,PAGE_READWRITE);
VirtualAlloc(base,PAGESIZE,MEM_COMMIT,PAGE_READWRITE);
__HeapPrepare(base, minsize, maxsize, 0);

View file

@ -0,0 +1,47 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/kernel32/proc/proc.c
* PURPOSE: Process functions
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
* UPDATE HISTORY:
* Created 01/11/98
*/
/* INCLUDES ****************************************************************/
#define UNICODE
#include <windows.h>
#include <kernel32/proc.h>
#include <kernel32/thread.h>
#include <wstring.h>
#include <string.h>
#include <ddk/rtl.h>
#include <ddk/li.h>
/* GLOBALS ******************************************************************/
unsigned char CommandLineA[MAX_PATH];
/* FUNCTIONS ****************************************************************/
LPSTR STDCALL GetCommandLineA(VOID)
{
WCHAR *CommandLineW;
ULONG i = 0;
CommandLineW = GetCommandLineW();
while ((CommandLineW[i])!=0 && i < MAX_PATH)
{
CommandLineA[i] = (unsigned char)CommandLineW[i];
i++;
}
CommandLineA[i] = 0;
return CommandLineA;
}
LPWSTR STDCALL GetCommandLineW(VOID)
{
return GetCurrentPeb()->StartupInfo->CommandLine;
}

View file

@ -7,6 +7,9 @@
* UPDATE HISTORY:
* Created 01/11/98
*/
/* INCLUDES ****************************************************************/
#define UNICODE
#include <windows.h>
#include <kernel32/proc.h>
@ -16,6 +19,8 @@
#include <ddk/rtl.h>
#include <ddk/li.h>
/* GLOBALS *****************************************************************/
extern NT_PEB *CurrentPeb;
extern NT_PEB Peb;
@ -23,10 +28,9 @@ WaitForInputIdleType lpfnGlobalRegisterWaitForInputIdle;
VOID RegisterWaitForInputIdle(WaitForInputIdleType lpfnRegisterWaitForInputIdle);
WINBOOL
STDCALL
GetProcessId(HANDLE hProcess, LPDWORD lpProcessId );
/* FUNCTIONS ****************************************************************/
WINBOOL STDCALL GetProcessId(HANDLE hProcess, LPDWORD lpProcessId);
NT_PEB *GetCurrentPeb(VOID)
{
@ -46,92 +50,74 @@ HANDLE STDCALL GetCurrentThread(VOID)
return (HANDLE)NtCurrentThread();
}
DWORD
STDCALL
GetCurrentProcessId(VOID)
DWORD STDCALL GetCurrentProcessId(VOID)
{
return (DWORD)(GetTeb()->Cid).UniqueProcess;
}
unsigned char CommandLineA[MAX_PATH];
LPSTR
STDCALL
GetCommandLineA(
VOID
)
{
WCHAR *CommandLineW;
ULONG i = 0;
CommandLineW = GetCommandLineW();
while ((CommandLineW[i])!=0 && i < MAX_PATH)
{
CommandLineA[i] = (unsigned char)CommandLineW[i];
i++;
}
CommandLineA[i] = 0;
return CommandLineA;
}
LPWSTR
STDCALL
GetCommandLineW(
VOID
)
{
return GetCurrentPeb()->StartupInfo->CommandLine;
}
WINBOOL
STDCALL
GetExitCodeProcess(
HANDLE hProcess,
LPDWORD lpExitCode
)
WINBOOL STDCALL GetExitCodeProcess(HANDLE hProcess, LPDWORD lpExitCode )
{
NTSTATUS errCode;
PROCESS_BASIC_INFORMATION ProcessBasic;
ULONG BytesWritten;
errCode = NtQueryInformationProcess(hProcess,ProcessBasicInformation,&ProcessBasic,sizeof(PROCESS_BASIC_INFORMATION),&BytesWritten);
if ( !NT_SUCCESS(errCode) ) {
errCode = NtQueryInformationProcess(hProcess,
ProcessBasicInformation,
&ProcessBasic,
sizeof(PROCESS_BASIC_INFORMATION),
&BytesWritten);
if (!NT_SUCCESS(errCode))
{
SetLastError(RtlNtStatusToDosError(errCode));
return FALSE;
}
memcpy( lpExitCode ,&ProcessBasic.ExitStatus,sizeof(DWORD));
return TRUE;
}
WINBOOL
STDCALL
GetProcessId(
HANDLE hProcess,
LPDWORD lpProcessId
)
WINBOOL STDCALL GetProcessId(HANDLE hProcess, LPDWORD lpProcessId )
{
NTSTATUS errCode;
PROCESS_BASIC_INFORMATION ProcessBasic;
ULONG BytesWritten;
errCode = NtQueryInformationProcess(hProcess,ProcessBasicInformation,&ProcessBasic,sizeof(PROCESS_BASIC_INFORMATION),&BytesWritten);
if ( !NT_SUCCESS(errCode) ) {
errCode = NtQueryInformationProcess(hProcess,
ProcessBasicInformation,
&ProcessBasic,
sizeof(PROCESS_BASIC_INFORMATION),
&BytesWritten);
if (!NT_SUCCESS(errCode))
{
SetLastError(RtlNtStatusToDosError(errCode));
return FALSE;
}
memcpy( lpProcessId ,&ProcessBasic.UniqueProcessId,sizeof(DWORD));
return TRUE;
}
WINBOOL
STDCALL
CreateProcessA(
LPCSTR lpApplicationName,
PWSTR InternalAnsiToUnicode(PWSTR Out, LPCSTR In, ULONG MaxLength)
{
ULONG i;
if (In == NULL)
{
return(NULL);
}
else
{
i = 0;
while ((*In)!=0 && i < MaxLength)
{
Out[i] = *In;
In++;
i++;
}
Out[i] = 0;
return(Out);
}
}
WINBOOL STDCALL CreateProcessA(LPCSTR lpApplicationName,
LPSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
@ -140,56 +126,57 @@ CreateProcessA(
LPVOID lpEnvironment,
LPCSTR lpCurrentDirectory,
LPSTARTUPINFO lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation
)
LPPROCESS_INFORMATION lpProcessInformation)
/*
* FUNCTION: The CreateProcess function creates a new process and its
* primary thread. The new process executes the specified executable file
* ARGUMENTS:
*
* lpApplicationName = Pointer to name of executable module
* lpCommandLine = Pointer to command line string
* lpProcessAttributes = Process security attributes
* lpThreadAttributes = Thread security attributes
* bInheritHandles = Handle inheritance flag
* dwCreationFlags = Creation flags
* lpEnvironment = Pointer to new environment block
* lpCurrentDirectory = Pointer to current directory name
* lpStartupInfo = Pointer to startup info
* lpProcessInformation = Pointer to process information
*/
{
WCHAR ApplicationNameW[MAX_PATH];
WCHAR CommandLineW[MAX_PATH];
WCHAR CurrentDirectoryW[MAX_PATH];
PWSTR PApplicationNameW;
PWSTR PCommandLineW;
PWSTR PCurrentDirectoryW;
ULONG i;
i = 0;
while ((*lpApplicationName)!=0 && i < MAX_PATH)
{
ApplicationNameW[i] = *lpApplicationName;
lpApplicationName++;
i++;
}
ApplicationNameW[i] = 0;
OutputDebugStringA("CreateProcessA\n");
i = 0;
while ((*lpCommandLine)!=0 && i < MAX_PATH)
{
CommandLineW[i] = *lpCommandLine;
lpCommandLine++;
i++;
}
CommandLineW[i] = 0;
i = 0;
while ((*lpCurrentDirectory)!=0 && i < MAX_PATH)
{
CurrentDirectoryW[i] = *lpCurrentDirectory;
lpCurrentDirectory++;
i++;
}
CurrentDirectoryW[i] = 0;
return CreateProcessW(ApplicationNameW,CommandLineW, lpProcessAttributes,lpThreadAttributes,
bInheritHandles,dwCreationFlags,lpEnvironment,CurrentDirectoryW,lpStartupInfo,
PApplicationNameW = InternalAnsiToUnicode(ApplicationNameW,
lpApplicationName,
MAX_PATH);
PCommandLineW = InternalAnsiToUnicode(CommandLineW,
lpCommandLine,
MAX_PATH);
PCurrentDirectoryW = InternalAnsiToUnicode(CurrentDirectoryW,
lpCurrentDirectory,
MAX_PATH);
return CreateProcessW(PApplicationNameW,
PCommandLineW,
lpProcessAttributes,
lpThreadAttributes,
bInheritHandles,
dwCreationFlags,
lpEnvironment,
PCurrentDirectoryW,
lpStartupInfo,
lpProcessInformation);
}
WINBOOL
STDCALL
CreateProcessW(
LPCWSTR lpApplicationName,
WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
LPWSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
@ -198,130 +185,173 @@ CreateProcessW(
LPVOID lpEnvironment,
LPCWSTR lpCurrentDirectory,
LPSTARTUPINFO lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation
)
LPPROCESS_INFORMATION lpProcessInformation)
{
HANDLE hFile, hSection, hProcess, hThread;
KPRIORITY PriorityClass;
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock;
BOOLEAN CreateSuspended;
NTSTATUS errCode;
UNICODE_STRING ApplicationNameString;
LPTHREAD_START_ROUTINE lpStartAddress = NULL;
LPVOID lpParameter = NULL;
PSECURITY_DESCRIPTOR SecurityDescriptor = NULL;
WCHAR TempApplicationName[255];
WCHAR TempFileName[255];
WCHAR TempDirectoryName[255];
ULONG i;
ULONG BaseAddress;
ULONG Size;
LARGE_INTEGER SectionOffset;
dprintf("CreateProcessW(lpApplicationName '%w', lpCommandLine '%w')\n",
lpApplicationName,lpCommandLine);
hFile = NULL;
ApplicationNameString.Length = lstrlenW(lpApplicationName)*sizeof(WCHAR);
/*
* Find the application name
*/
TempApplicationName[0] = '\\';
TempApplicationName[1] = '?';
TempApplicationName[2] = '?';
TempApplicationName[3] = '\\';
TempApplicationName[4] = 0;
ApplicationNameString.Buffer = (WCHAR *)lpApplicationName;
ApplicationNameString.MaximumLength = ApplicationNameString.Length;
dprintf("TempApplicationName '%w'\n",TempApplicationName);
if (lpApplicationName != NULL)
{
wcscpy(TempFileName, lpApplicationName);
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory = NULL;
if ( lpProcessAttributes != NULL ) {
if ( lpProcessAttributes->bInheritHandle )
ObjectAttributes.Attributes = OBJ_INHERIT;
else
ObjectAttributes.Attributes = 0;
ObjectAttributes.SecurityDescriptor = lpProcessAttributes->lpSecurityDescriptor;
dprintf("TempFileName '%w'\n",TempFileName);
}
ObjectAttributes.Attributes |= OBJ_CASE_INSENSITIVE;
else
{
wcscpy(TempFileName, lpCommandLine);
errCode = NtOpenFile(&hFile,(SYNCHRONIZE|FILE_EXECUTE), &ObjectAttributes,
&IoStatusBlock,(FILE_SHARE_DELETE|FILE_SHARE_READ),(FILE_SYNCHRONOUS_IO_NONALERT|FILE_NON_DIRECTORY_FILE));
dprintf("TempFileName '%w'\n",TempFileName);
if ( !NT_SUCCESS(errCode) ) {
for (i=0; TempFileName[i]!=' ' && TempFileName[i] != 0; i++);
TempFileName[i]=0;
}
if (TempFileName[1] != ':')
{
GetCurrentDirectoryW(MAX_PATH,TempDirectoryName);
wcscat(TempApplicationName,TempDirectoryName);
}
wcscat(TempApplicationName,TempFileName);
RtlInitUnicodeString(&ApplicationNameString, TempApplicationName);
dprintf("ApplicationName %w\n",ApplicationNameString.Buffer);
InitializeObjectAttributes(&ObjectAttributes,
&ApplicationNameString,
OBJ_CASE_INSENSITIVE,
NULL,
SecurityDescriptor);
/*
* Try to open the executable
*/
errCode = NtOpenFile(&hFile,
SYNCHRONIZE|FILE_EXECUTE|FILE_READ_DATA,
&ObjectAttributes,
&IoStatusBlock,
FILE_SHARE_DELETE|FILE_SHARE_READ,
FILE_SYNCHRONOUS_IO_NONALERT|FILE_NON_DIRECTORY_FILE);
if ( !NT_SUCCESS(errCode) )
{
SetLastError(RtlNtStatusToDosError(errCode));
return FALSE;
}
errCode = NtCreateSection(&hSection,SECTION_ALL_ACCESS,NULL,NULL,PAGE_EXECUTE,SEC_IMAGE,hFile);
errCode = NtCreateSection(&hSection,
SECTION_ALL_ACCESS,
NULL,
NULL,
PAGE_EXECUTE,
SEC_IMAGE,
hFile);
NtClose(hFile);
if ( !NT_SUCCESS(errCode) ) {
if ( !NT_SUCCESS(errCode) )
{
SetLastError(RtlNtStatusToDosError(errCode));
return FALSE;
}
errCode = NtCreateProcess(&hProcess,
PROCESS_ALL_ACCESS,
NULL,
NtCurrentProcess(),
bInheritHandles,
NULL,
NULL,
NULL);
BaseAddress = (PVOID)0x10000;
LARGE_INTEGER_QUAD_PART(SectionOffset) = 0;
Size = 0x10000;
NtMapViewOfSection(hSection,
hProcess,
&BaseAddress,
0,
Size,
&SectionOffset,
&Size,
0,
MEM_COMMIT,
PAGE_READWRITE);
if ( lpProcessAttributes != NULL ) {
if ( lpProcessAttributes->bInheritHandle )
ObjectAttributes.Attributes = OBJ_INHERIT;
else
ObjectAttributes.Attributes = 0;
ObjectAttributes.SecurityDescriptor = lpProcessAttributes->lpSecurityDescriptor;
}
errCode = NtCreateProcess(&hProcess,PROCESS_ALL_ACCESS, &ObjectAttributes,NtCurrentProcess(),bInheritHandles,hSection,NULL,NULL);
NtClose(hSection);
if ( !NT_SUCCESS(errCode) ) {
if ( !NT_SUCCESS(errCode) )
{
SetLastError(RtlNtStatusToDosError(errCode));
return FALSE;
}
#if 0
PriorityClass = NORMAL_PRIORITY_CLASS;
NtSetInformationProcess(hProcess,ProcessBasePriority,&PriorityClass,sizeof(KPRIORITY));
if ( ( dwCreationFlags & CREATE_SUSPENDED ) == CREATE_SUSPENDED)
CreateSuspended = TRUE;
else
CreateSuspended = FALSE;
hThread = CreateRemoteThread(
hProcess,
NtSetInformationProcess(hProcess,
ProcessBasePriority,
&PriorityClass,
sizeof(KPRIORITY));
#endif
dprintf("Creating thread for process\n");
lpStartAddress = BaseAddress;
hThread = CreateRemoteThread(hProcess,
lpThreadAttributes,
4096, // 1 page ??
lpStartAddress,
lpParameter,
CREATE_SUSPENDED,
&lpProcessInformation->dwThreadId
);
dwCreationFlags,
&lpProcessInformation->dwThreadId);
if ( hThread == NULL )
return FALSE;
lpProcessInformation->hProcess = hProcess;
lpProcessInformation->hThread = hThread;
GetProcessId(hProcess,&lpProcessInformation->dwProcessId);
return TRUE;
}
HANDLE
STDCALL
OpenProcess(
DWORD dwDesiredAccess,
HANDLE STDCALL OpenProcess(DWORD dwDesiredAccess,
WINBOOL bInheritHandle,
DWORD dwProcessId
)
DWORD dwProcessId)
{
NTSTATUS errCode;
HANDLE ProcessHandle;
OBJECT_ATTRIBUTES ObjectAttributes;
@ -338,8 +368,12 @@ OpenProcess(
else
ObjectAttributes.Attributes = 0;
errCode = NtOpenProcess ( &ProcessHandle, dwDesiredAccess, &ObjectAttributes, &ClientId);
if ( !NT_SUCCESS(errCode) ) {
errCode = NtOpenProcess(&ProcessHandle,
dwDesiredAccess,
&ObjectAttributes,
&ClientId);
if (!NT_SUCCESS(errCode))
{
SetLastError(RtlNtStatusToDosError(errCode));
return NULL;
}

View file

@ -13,7 +13,7 @@
#include <kernel32/thread.h>
#include <ddk/ntddk.h>
#include <string.h>
#include <internal/i386/segment.h>
HANDLE
STDCALL
@ -52,6 +52,7 @@ CreateRemoteThread(
CONTEXT ThreadContext;
INITIAL_TEB InitialTeb;
BOOLEAN CreateSuspended = FALSE;
ULONG BaseAddress;
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory = NULL;
@ -68,20 +69,36 @@ CreateRemoteThread(
CreateSuspended = TRUE;
else
CreateSuspended = FALSE;
// fix context
GetThreadContext(NtCurrentThread(),&ThreadContext);
// fix teb [ stack context ] --> check the image file
errCode = NtCreateThread(
&ThreadHandle,
BaseAddress = 0;
ZwAllocateVirtualMemory(hProcess,
&BaseAddress,
0,
&dwStackSize,
MEM_COMMIT,
PAGE_READWRITE);
memset(&ThreadContext,0,sizeof(CONTEXT));
ThreadContext.Eip = lpStartAddress;
ThreadContext.SegGs = USER_DS;
ThreadContext.SegFs = USER_DS;
ThreadContext.SegEs = USER_DS;
ThreadContext.SegDs = USER_DS;
ThreadContext.SegCs = USER_CS;
ThreadContext.SegSs = USER_DS;
ThreadContext.Esp = BaseAddress + dwStackSize;
ThreadContext.EFlags = (1<<1) + (1<<9);
errCode = NtCreateThread(&ThreadHandle,
THREAD_ALL_ACCESS,
&ObjectAttributes,
hProcess,
&ClientId,
&ThreadContext,
&InitialTeb,
CreateSuspended
);
CreateSuspended);
if ( lpThreadId != NULL )
memcpy(lpThreadId, &ClientId.UniqueThread,sizeof(ULONG));

View file

@ -1,6 +1,7 @@
all: ntdll.a
OBJECTS = napi.o stubs/stubs.o string/wstring.o stdio/vsprintf.o
OBJECTS = napi.o stubs/stubs.o string/wstring.o stdio/vsprintf.o \
rtl/unicode.o rtl/namespc.o
ntdll.a: $(OBJECTS)
$(AR) vcsr ntdll.a $(OBJECTS)

View file

@ -71,6 +71,7 @@ wchar_t* wcscpy(wchar_t* str1, const wchar_t* str2)
s++;
str2++;
}
*s = 0;
return(str1);
}

View file

@ -1,6 +1,6 @@
#include <windows.h>
#define STUB(x) void x(void) { NtDisplayString("NTDLL: Stub for "#x); }
#define STUB(x) void x(void) { NtDisplayString("NTDLL: Stub for "#x"\n"); }
// ?Allocate@CBufferAllocator@@UAEPAXK@Z
STUB(PropertyLengthAsVariant)
@ -78,12 +78,8 @@ STUB(RtlAllocateAndInitializeSid)
STUB(RtlAllocateHandle)
STUB(RtlAllocateHeap)
STUB(RtlAnsiCharToUnicodeChar)
STUB(RtlAnsiStringToUnicodeSize)
STUB(RtlAnsiStringToUnicodeString)
STUB(RtlAppendAsciizToString)
STUB(RtlAppendStringToString)
STUB(RtlAppendUnicodeStringToString)
STUB(RtlAppendUnicodeToString)
STUB(RtlApplyRXact)
STUB(RtlApplyRXactNoFlush)
STUB(RtlAreAllAccessesGranted)
@ -92,7 +88,6 @@ STUB(RtlAreBitsClear)
STUB(RtlAreBitsSet)
STUB(RtlAssert)
STUB(RtlCaptureStackBackTrace)
STUB(RtlCharToInteger)
STUB(RtlCheckRegistryKey)
STUB(RtlClearAllBits)
STUB(RtlClearBits)
@ -100,8 +95,6 @@ STUB(RtlClosePropertySet)
STUB(RtlCompactHeap)
STUB(RtlCompareMemory)
STUB(RtlCompareMemoryUlong)
STUB(RtlCompareString)
STUB(RtlCompareUnicodeString)
STUB(RtlCompressBuffer)
STUB(RtlConsoleMultiByteToUnicodeN)
STUB(RtlConvertExclusiveToShared)
@ -115,8 +108,6 @@ STUB(RtlCopyLuidAndAttributesArray)
STUB(RtlCopySecurityDescriptor)
STUB(RtlCopySid)
STUB(RtlCopySidAndAttributesArray)
STUB(RtlCopyString)
STUB(RtlCopyUnicodeString)
STUB(RtlCreateAcl)
STUB(RtlCreateAndSetSD)
STUB(RtlCreateAtomTable)
@ -173,8 +164,6 @@ STUB(RtlEqualDomainName)
STUB(RtlEqualLuid)
STUB(RtlEqualPrefixSid)
STUB(RtlEqualSid)
STUB(RtlEqualString)
STUB(RtlEqualUnicodeString)
STUB(RtlEraseUnicodeString)
STUB(RtlExpandEnvironmentStrings_U)
STUB(RtlExtendHeap)
@ -194,12 +183,10 @@ STUB(RtlFirstFreeAce)
STUB(RtlFlushPropertySet)
STUB(RtlFormatCurrentUserKeyPath)
STUB(RtlFormatMessage)
STUB(RtlFreeAnsiString)
STUB(RtlFreeHandle)
STUB(RtlFreeHeap)
STUB(RtlFreeOemString)
STUB(RtlFreeSid)
STUB(RtlFreeUnicodeString)
STUB(RtlFreeUserThreadStack)
STUB(RtlGenerate8dot3Name)
STUB(RtlGetAce)
@ -225,11 +212,8 @@ STUB(RtlImageNtHeader)
STUB(RtlImageRvaToSection)
STUB(RtlImageRvaToVa)
STUB(RtlImpersonateSelf)
STUB(RtlInitAnsiString)
STUB(RtlInitCodePageTable)
STUB(RtlInitNlsTables)
STUB(RtlInitString)
STUB(RtlInitUnicodeString)
STUB(RtlInitializeAtomPackage)
STUB(RtlInitializeBitMap)
STUB(RtlInitializeContext)
@ -242,7 +226,6 @@ STUB(RtlInitializeResource)
STUB(RtlInitializeSid)
STUB(RtlInsertElementGenericTable)
STUB(RtlIntegerToChar)
STUB(RtlIntegerToUnicodeString)
STUB(RtlIsDosDeviceName_U)
STUB(RtlIsGenericTableEmpty)
STUB(RtlIsNameLegalDOS8Dot3)
@ -353,9 +336,7 @@ STUB(RtlTimeToSecondsSince1980)
STUB(RtlTimeToTimeFields)
STUB(RtlTryEnterCriticalSection)
STUB(RtlUnicodeStringToAnsiSize)
STUB(RtlUnicodeStringToAnsiString)
STUB(RtlUnicodeStringToCountedOemString)
STUB(RtlUnicodeStringToInteger)
STUB(RtlUnicodeStringToOemSize)
STUB(RtlUnicodeStringToOemString)
STUB(RtlUnicodeToCustomCPN)
@ -366,7 +347,6 @@ STUB(RtlUniform)
STUB(RtlUnlockHeap)
STUB(RtlUnwind)
STUB(RtlUpcaseUnicodeChar)
STUB(RtlUpcaseUnicodeString)
STUB(RtlUpcaseUnicodeStringToAnsiString)
STUB(RtlUpcaseUnicodeStringToCountedOemString)
STUB(RtlUpcaseUnicodeStringToOemString)
@ -374,7 +354,6 @@ STUB(RtlUpcaseUnicodeToCustomCPN)
STUB(RtlUpcaseUnicodeToMultiByteN)
STUB(RtlUpcaseUnicodeToOemN)
STUB(RtlUpperChar)
STUB(RtlUpperString)
STUB(RtlUsageHeap)
STUB(RtlValidAcl)
STUB(RtlValidSecurityDescriptor)

Binary file not shown.

Binary file not shown.

View file

@ -31,7 +31,7 @@ LOADERS = dos
# Select the device drivers and filesystems you want
#
KERNEL_SERVICES = parallel keyboard null mouse serial sound ide test sdisk \
minix vfat # ext2fs
minix vfat ext2
APPS = hello shell
@ -104,8 +104,8 @@ serial: dummy
sound: dummy
make -C services/dd/sound
ext2fs: dummy
make -C services/fs/ext2fs
ext2: dummy
make -C services/fs/ext2
#
# Kernel loaders

View file

@ -17,12 +17,14 @@ _irq_handler_%1:
;
pusha
push ds
push es
;
; Load DS
;
mov ax,KERNEL_DS
mov ds,ax
mov es,ax
;
; Mask the corresponding vector at the PIC
@ -43,6 +45,7 @@ _irq_handler_%1:
; Restore stack, registers and return to interrupted routine
;
pop eax
pop es
pop ds
popa
iret

View file

@ -223,11 +223,7 @@ BOOL is_page_present(unsigned int vaddr)
* buffer from an irq.
*/
{
#if 0
unsigned int* page_dir = physical_to_linear(current_task->cr3);
#else
unsigned int* page_dir = get_page_directory();
#endif
unsigned int* page_tlb = NULL;
/*

View file

@ -150,7 +150,7 @@ NTSTATUS KeValidateUserContext(PCONTEXT Context)
(Context->EFlags & FLAG_VM) ||
(!(Context->EFlags & FLAG_IF)))
{
return(STATUS_SUCCESS);
return(STATUS_UNSUCCESSFUL);
}
return(STATUS_SUCCESS);
}

View file

@ -125,7 +125,7 @@ NTSTATUS InitalizeLoadedDriver(PDRIVER_INITIALIZE entry)
/*
* Allocate memory for a driver object
* NOTE: The object only becomes system visible once the associated
* device objects are intialized
* device objects are initialized
*/
DriverObject=ExAllocatePool(NonPagedPool,sizeof(DRIVER_OBJECT));
if (DriverObject==NULL)

View file

@ -306,3 +306,4 @@ VOID IoCompleteRequest(PIRP Irp, CCHAR PriorityBoost)
IoSecondStageCompletion(Irp,PriorityBoost);
}
}
>>>>>>> 1.7

View file

@ -28,6 +28,9 @@ NTSTATUS IoPageRead(PFILE_OBJECT FileObject,
PIO_STACK_LOCATION StackPtr;
NTSTATUS Status;
DPRINT("IoPageRead(FileObject %x, Address %x)\n",
FileObject,Address);
KeInitializeEvent(&Event,NotificationEvent,FALSE);
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
FileObject->DeviceObject,

View file

@ -117,7 +117,7 @@ asmlinkage void _main(boot_param* _bp)
unsigned int start1;
boot_param bp;
// memset((void *)&edata,0,((int)&end)-((int)&edata));
memset((void *)&edata,0,((int)&end)-((int)&edata));
/*
* Copy the parameters to a local buffer because lowmem will go away
@ -139,15 +139,7 @@ asmlinkage void _main(boot_param* _bp)
DbgPrint("Reduce the amount of uninitialized data\n");
for(;;);
}
DPRINT("MmGetPhysicalAddress(start) = %x\n",MmGetPhysicalAddress((void *)start));
DPRINT("bp.module_length[0] %x PAGE_ROUND_UP(bp.module_length[0]) %x\n",
bp.module_length[0],PAGE_ROUND_UP(bp.module_length[0]));
start1 = start+PAGE_ROUND_UP(bp.module_length[1]);
DPRINT("bp.module_length[1] %x PAGE_ROUND_UP(bp.module_length[1]) %x\n",
bp.module_length[1],PAGE_ROUND_UP(bp.module_length[1]));
DPRINT("start %x *start %x\n",start,*((unsigned int *)start));
DPRINT("start1 %x *start1 %x\n",start1,*((unsigned int *)start1));
/*
@ -155,15 +147,10 @@ asmlinkage void _main(boot_param* _bp)
*/
HalInit(&bp);
MmInitalize(&bp);
CHECKPOINT;
KeInit();
CHECKPOINT;
ObInit();
CHECKPOINT;
PsInit();
CHECKPOINT;
IoInit();
CHECKPOINT;
/*
* Initalize services loaded at boot time
@ -172,11 +159,9 @@ asmlinkage void _main(boot_param* _bp)
start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]);
start1 = start+PAGE_ROUND_UP(bp.module_length[1]);
// DbgPrint("start1 %x *start1 %x\n",start1,*((unsigned int *)start1));
for (i=1;i<bp.nr_files;i++)
{
process_boot_module(start);
// DbgPrint("start1 %x *start1 %x\n",start1,*((unsigned int *)start1));
start=start+PAGE_ROUND_UP(bp.module_length[i]);
}

View file

@ -37,7 +37,7 @@ static unsigned long long system_time = 0;
/*
* Number of timer interrupts since initialisation
*/
static volatile unsigned long long ticks=0;
volatile ULONGLONG KiTimerTicks;
/*
* The increment in the system clock every timer tick (in system time units)
@ -76,10 +76,10 @@ VOID KeCalibrateTimerLoop(VOID)
for (i=0;i<20;i++)
{
start_tick = ticks;
start_tick = KiTimerTicks;
microseconds = 0;
while (start_tick == ticks);
while (ticks == (start_tick+TICKS_TO_CALIBRATE))
while (start_tick == KiTimerTicks);
while (KiTimerTicks == (start_tick+TICKS_TO_CALIBRATE))
{
KeStallExecutionProcessor(1);
microseconds++;
@ -418,7 +418,7 @@ VOID KeQueryTickCount(PLARGE_INTEGER TickCount)
* TickCount (OUT) = Points to storage for the number of ticks
*/
{
LARGE_INTEGER_QUAD_PART(*TickCount) = ticks;
LARGE_INTEGER_QUAD_PART(*TickCount) = KiTimerTicks;
}
static void HandleExpiredTimer(PKTIMER current)
@ -484,11 +484,13 @@ BOOLEAN KiTimerInterrupt(VOID)
char* vidmem=(char *)physical_to_linear(0xb8000 + 160 - 36);
int i;
int x,y;
extern ULONG PiNrThreads;
extern ULONG EiNrUsedBlocks;
/*
* Increment the number of timers ticks
*/
ticks++;
KiTimerTicks++;
system_time = system_time + CLOCK_INCREMENT;
/*
@ -508,7 +510,8 @@ BOOLEAN KiTimerInterrupt(VOID)
(EiFreeNonPagedPool + EiUsedNonPagedPool);
}
// sprintf(str,"%.8u %.8u",EiFreeNonPagedPool,ticks);
sprintf(str,"%.4u %.4u %.7u",x,y,ticks);
memset(str, 0, sizeof(str));
sprintf(str,"%.8u %.8u",EiNrUsedBlocks,KiTimerTicks);
// sprintf(str,"%.8u %.8u",EiFreeNonPagedPool,EiUsedNonPagedPool);
for (i=0;i<17;i++)
{

View file

@ -28,7 +28,7 @@
#include <ddk/ntddk.h>
#if CHECKED
#if 0
#define VALIDATE_POOL validate_kernel_pool()
#else
#define VALIDATE_POOL
@ -44,7 +44,7 @@
typedef struct _block_hdr
{
ULONG magic;
unsigned int size;
ULONG size;
struct _block_hdr* previous;
struct _block_hdr* next;
ULONG tag;
@ -62,8 +62,8 @@ static unsigned int kernel_pool_base = 0;
*/
static block_hdr* free_list_head = NULL;
static block_hdr* used_list_head = NULL;
static unsigned int nr_free_blocks = 0;
unsigned int nr_used_blocks = 0;
static ULONG nr_free_blocks;
ULONG EiNrUsedBlocks = 0;
#define ALLOC_MAP_SIZE (NONPAGED_POOL_SIZE / PAGESIZE)
@ -157,7 +157,7 @@ static void validate_used_list(void)
for(;;);
}
blocks_seen++;
if (blocks_seen > nr_used_blocks)
if (blocks_seen > EiNrUsedBlocks)
{
printk("Too many blocks on list\n");
for(;;);
@ -278,7 +278,7 @@ static void add_to_used_list(block_hdr* blk)
used_list_head->previous=blk;
}
used_list_head=blk;
nr_used_blocks++;
EiNrUsedBlocks++;
}
@ -335,7 +335,7 @@ static void remove_from_used_list(block_hdr* current)
current->previous->next=NULL;
}
}
nr_used_blocks--;
EiNrUsedBlocks--;
}
@ -529,12 +529,10 @@ asmlinkage VOID ExFreePool(PVOID block)
*/
{
block_hdr* blk=address_to_block(block);
OLD_DPRINT("(%s:%d) freeing block %x\n",__FILE__,__LINE__,blk);
OLD_DPRINT("ExFreePool(block %x), size %d, caller %x\n",
block,
blk->size,
((PULONG)&block)[-1]);
OLD_DPRINT("freeing block %x\n",blk);
// DbgPrint("ExFreePool(block %x), size %d, caller %x\n",block,blk->size,
// ((PULONG)&block)[-1]);
VALIDATE_POOL;
@ -562,9 +560,9 @@ PVOID ExAllocateNonPagedPoolWithTag(ULONG type, ULONG size, ULONG Tag)
block_hdr* current=NULL;
void* block;
OLD_DPRINT("Blocks on free list %d\n",nr_free_blocks);
OLD_DPRINT("Blocks on used list %d\n",nr_used_blocks);
OLD_DPRINT("ExAllocateNonPagedPool(type %d, size %d)\n",type,size);
// DbgPrint("Blocks on free list %d\n",nr_free_blocks);
// DbgPrint("Blocks on used list %d\n",eiNrUsedblocks);
// OLD_DPRINT("ExAllocateNonPagedPool(type %d, size %d)\n",type,size);
VALIDATE_POOL;
/*
@ -593,6 +591,7 @@ PVOID ExAllocateNonPagedPoolWithTag(ULONG type, ULONG size, ULONG Tag)
{
OLD_DPRINT("found block %x of size %d\n",current,size);
block=take_block(current,size);
VALIDATE_POOL;
memset(block,0,size);
return(block);
}
@ -603,7 +602,7 @@ PVOID ExAllocateNonPagedPoolWithTag(ULONG type, ULONG size, ULONG Tag)
* Otherwise create a new block
*/
block=block_to_address(grow_kernel_pool(size));
VALIDATE_POOL;
memset(block,0,size);
return block;
return(block);
}

View file

@ -45,16 +45,11 @@ PVOID ExAllocatePool(POOL_TYPE PoolType, ULONG NumberOfBytes)
*/
{
PVOID Block;
OLD_DPRINT("ExAllocatePool(NumberOfBytes %d) caller %x\n",
NumberOfBytes,
((PULONG)&PoolType)[-1]);
// DbgPrint("ExAllocatePool(NumberOfBytes %d) caller %x\n",
// NumberOfBytes,((PULONG)&PoolType)[-1]);
Block = ExAllocatePoolWithTag(PoolType,NumberOfBytes,TAG_NONE);
OLD_DPRINT("ExAllocatePool() = %x\n",Block);
return Block;
// DbgPrint("ExAllocatePool() = %x\n",Block);
return(Block);
}
PVOID ExAllocatePoolWithTag(ULONG type, ULONG size, ULONG Tag)
@ -121,4 +116,3 @@ PVOID ExAllocatePoolWithQuota(POOL_TYPE PoolType, ULONG NumberOfBytes)
{
return(ExAllocatePoolWithQuotaTag(PoolType,NumberOfBytes,TAG_NONE));
}

View file

@ -104,7 +104,7 @@ NTSTATUS STDCALL ZwCreateSection(OUT PHANDLE SectionHandle,
PSECTION_OBJECT Section;
NTSTATUS Status;
DPRINT("ZwCreateSection()\n");
DbgPrint("ZwCreateSection()\n");
Section = ObGenericCreateObject(SectionHandle,
DesiredAccess,
@ -128,11 +128,13 @@ NTSTATUS STDCALL ZwCreateSection(OUT PHANDLE SectionHandle,
NULL);
if (Status != STATUS_SUCCESS)
{
DPRINT("ZwCreateSection() = %x\n",Status);
return(Status);
}
Section->AllocateAttributes = AllocationAttributes;
DPRINT("ZwCreateSection() = STATUS_SUCCESS\n");
return(STATUS_SUCCESS);
}

View file

@ -547,6 +547,7 @@ NTSTATUS ObLookupObject(HANDLE rootdir, PWSTR string, PVOID* Object,
}
CHECKPOINT;
*Object = current_dir;
DPRINT("(%s:%d) current_dir %x\n",__FILE__,__LINE__,current_dir);
return(Status);
}

View file

@ -13,6 +13,7 @@
#include <ddk/ntddk.h>
#include <internal/ob.h>
#include <wstring.h>
#include <string.h>
#define NDEBUG
#include <internal/debug.h>
@ -96,10 +97,11 @@ PVOID ObGenericCreateObject(PHANDLE Handle,
POBJECT_TYPE Type)
{
POBJECT_HEADER hdr = NULL;
UNICODE_STRING ObjectName;
PWSTR path;
PWSTR name;
PWSTR Ignored;
PULONG addr;
PWSTR Buffer;
DPRINT("ObGenericCreateObject(Handle %x, DesiredAccess %x,"
"ObjectAttributes %x, Type %x)\n",Handle,DesiredAccess,
@ -109,15 +111,18 @@ PVOID ObGenericCreateObject(PHANDLE Handle,
* Allocate the object body and header
*/
hdr=(POBJECT_HEADER)ExAllocatePool(NonPagedPool,OBJECT_ALLOC_SIZE(Type));
DPRINT("OBJECT_ALLOC_SIZE(Type) %d\n",OBJECT_ALLOC_SIZE(Type));
if (hdr==NULL)
{
return(NULL);
}
DPRINT("hdr %x\n",hdr);
/*
* If unnamed then initalize
*/
if (ObjectAttributes==NULL)
if (ObjectAttributes==NULL || ObjectAttributes->ObjectName==NULL)
{
ObInitializeObjectHeader(Type,NULL,hdr);
if (Handle != NULL)
@ -130,44 +135,53 @@ PVOID ObGenericCreateObject(PHANDLE Handle,
return(HEADER_TO_BODY(hdr));
}
/*
* Copy the object name into a buffer
*/
DPRINT("ObjectAttributes->ObjectName %x\n",ObjectAttributes->ObjectName);
DPRINT("ObjectAttributes->ObjectName->Length %d\n",
ObjectAttributes->ObjectName->Length);
ObjectName.MaximumLength = ObjectAttributes->ObjectName->Length;
ObjectName.Buffer = ExAllocatePool(NonPagedPool,
// DbgPrint("ObjectAttributes->ObjectName %x\n",ObjectAttributes->ObjectName);
// DbgPrint("ObjectAttributes->ObjectName->Length %d\n",
// ObjectAttributes->ObjectName->Length);
// DbgPrint("ObjectAttributes->ObjectName->MaximumLength %d\n",
// ObjectAttributes->ObjectName->MaximumLength);
Buffer = ExAllocatePool(NonPagedPool,
((ObjectAttributes->ObjectName->Length+1)*2));
if (ObjectName.Buffer==NULL)
if (Buffer==NULL)
{
return(NULL);
}
RtlCopyUnicodeString(&ObjectName,ObjectAttributes->ObjectName);
memcpy(Buffer, ObjectAttributes->ObjectName->Buffer,
(ObjectAttributes->ObjectName->Length+1)*2);
/*
* Seperate the name into a path and name
*/
name = wcsrchr(ObjectName.Buffer,'\\');
name = wcsrchr(Buffer,'\\');
if (name==NULL)
{
name=ObjectName.Buffer;
name=Buffer;
path=NULL;
}
else
{
path=ObjectName.Buffer;
path=Buffer;
*name=0;
name=name+1;
}
DPRINT("name %w path %w\n",name,path);
ObLookupObject(ObjectAttributes->RootDirectory,path,
&hdr->Parent,&Ignored, 0L);
ObLookupObject(ObjectAttributes->RootDirectory,
path,
&hdr->Parent,
&Ignored,
0L);
/*
* Initialize the object header
*/
ObInitializeObjectHeader(Type,name,hdr);
ObCreateEntry(hdr->Parent,hdr);
DPRINT("Handle %x\n",Handle);
@ -192,6 +206,7 @@ VOID ObInitializeObjectHeader(POBJECT_TYPE Type, PWSTR name,
*/
{
PWSTR temp_name;
extern unsigned long long ticks;
DPRINT("ObInitializeObjectHeader(id %x name %w obj %x)\n",Type,
name,ObjectHeader);
@ -207,10 +222,7 @@ VOID ObInitializeObjectHeader(POBJECT_TYPE Type, PWSTR name,
}
else
{
ObjectHeader->Name.MaximumLength = wstrlen(name);
ObjectHeader->Name.Buffer = ExAllocatePool(NonPagedPool,
(ObjectHeader->Name.MaximumLength+1)*2);
RtlInitUnicodeString(&ObjectHeader->Name,name);
RtlInitUnicodeString(&(ObjectHeader->Name),name);
}
}

View file

@ -1,468 +0,0 @@
.file "object.c"
.version "01.01"
gcc2_compiled.:
.text
.align 16
.globl NtSetInformationObject
.type NtSetInformationObject,@function
NtSetInformationObject:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 8(%ebp),%ebx
movl 12(%ebp),%ecx
movl 16(%ebp),%edx
movl 20(%ebp),%eax
pushl %eax
pushl %edx
pushl %ecx
pushl %ebx
call ZwSetInformationObject
movl -4(%ebp),%ebx
movl %ebp,%esp
popl %ebp
ret $16
.Lfe1:
.size NtSetInformationObject,.Lfe1-NtSetInformationObject
.section .rodata
.LC0:
.string "object.c"
.LC1:
.string "ZwSetInformationObject"
.LC2:
.string "%s at %s:%d is unimplemented, have a nice day\n"
.text
.align 16
.globl ZwSetInformationObject
.type ZwSetInformationObject,@function
ZwSetInformationObject:
pushl %ebp
movl %esp,%ebp
pushl $38
pushl $.LC0
pushl $.LC1
pushl $.LC2
call DbgPrint
.align 4
.L17:
jmp .L17
.align 16
.Lfe2:
.size ZwSetInformationObject,.Lfe2-ZwSetInformationObject
.align 16
.globl NtQueryObject
.type NtQueryObject,@function
NtQueryObject:
pushl %ebp
movl %esp,%ebp
pushl %esi
pushl %ebx
movl 8(%ebp),%esi
movl 12(%ebp),%ebx
movl 16(%ebp),%ecx
movl 20(%ebp),%edx
movl 24(%ebp),%eax
pushl %eax
pushl %edx
pushl %ecx
pushl %ebx
pushl %esi
call ZwQueryObject
leal -8(%ebp),%esp
popl %ebx
popl %esi
movl %ebp,%esp
popl %ebp
ret $20
.Lfe3:
.size NtQueryObject,.Lfe3-NtQueryObject
.section .rodata
.LC3:
.string "ZwQueryObject"
.text
.align 16
.globl ZwQueryObject
.type ZwQueryObject,@function
ZwQueryObject:
pushl %ebp
movl %esp,%ebp
pushl $60
pushl $.LC0
pushl $.LC3
pushl $.LC2
call DbgPrint
.align 4
.L26:
jmp .L26
.align 16
.Lfe4:
.size ZwQueryObject,.Lfe4-ZwQueryObject
.align 16
.globl NtMakeTemporaryObject
.type NtMakeTemporaryObject,@function
NtMakeTemporaryObject:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
pushl %eax
call ZwMakeTemporaryObject
movl %ebp,%esp
popl %ebp
ret $4
.Lfe5:
.size NtMakeTemporaryObject,.Lfe5-NtMakeTemporaryObject
.align 16
.globl ZwMakeTemporaryObject
.type ZwMakeTemporaryObject,@function
ZwMakeTemporaryObject:
pushl %ebp
movl %esp,%ebp
subl $4,%esp
movl 8(%ebp),%edx
pushl $0
leal -4(%ebp),%eax
pushl %eax
pushl $0
pushl $0
pushl $0
pushl %edx
call ObReferenceObjectByHandle
addl $24,%esp
testl %eax,%eax
jne .L30
movl -4(%ebp),%eax
movb $0,-12(%eax)
movl -4(%ebp),%eax
pushl %eax
call ObDereferenceObject
xorl %eax,%eax
movl %ebp,%esp
popl %ebp
ret $4
.align 16
.L30:
movl %ebp,%esp
popl %ebp
ret $4
.Lfe6:
.size ZwMakeTemporaryObject,.Lfe6-ZwMakeTemporaryObject
.align 16
.globl ObGenericCreateObject
.type ObGenericCreateObject,@function
ObGenericCreateObject:
pushl %ebp
movl %esp,%ebp
subl $12,%esp
pushl %edi
pushl %esi
pushl %ebx
movl 16(%ebp),%edi
movl 20(%ebp),%ecx
movl 28(%ecx),%eax
addl $36,%eax
pushl %eax
pushl $0
call ExAllocatePool
movl %eax,%esi
addl $8,%esp
testl %esi,%esi
je .L46
testl %edi,%edi
jne .L35
pushl %esi
pushl $0
movl 20(%ebp),%ecx
pushl %ecx
call ObInitializeObjectHeader
addl $12,%esp
jmp .L47
.align 16
.L35:
movl 8(%edi),%ecx
movw (%ecx),%dx
sall $16,%edx
movzwl -8(%ebp),%eax
orl %edx,%eax
movl %eax,-8(%ebp)
movzwl (%ecx),%eax
leal 2(,%eax,2),%eax
pushl %eax
pushl $0
call ExAllocatePool
movl %eax,-4(%ebp)
addl $8,%esp
testl %eax,%eax
jne .L39
.L46:
xorl %eax,%eax
jmp .L45
.align 16
.L39:
movl 8(%edi),%eax
pushl %eax
leal -8(%ebp),%eax
pushl %eax
call RtlCopyUnicodeString
pushl $92
movl -4(%ebp),%eax
pushl %eax
call wcsrchr
movl %eax,%ebx
addl $16,%esp
testl %ebx,%ebx
jne .L40
movl -4(%ebp),%ebx
xorl %edx,%edx
jmp .L41
.align 16
.L40:
movl -4(%ebp),%edx
movw $0,(%ebx)
addl $2,%ebx
.L41:
leal -12(%ebp),%eax
pushl %eax
leal 28(%esi),%eax
pushl %eax
pushl %edx
movl 4(%edi),%eax
pushl %eax
call ObLookupObject
pushl %esi
pushl %ebx
movl 20(%ebp),%ecx
pushl %ecx
call ObInitializeObjectHeader
pushl %esi
movl 28(%esi),%eax
pushl %eax
call ObCreateEntry
addl $36,%esp
.L47:
cmpl $0,8(%ebp)
je .L42
pushl $0
movl 12(%ebp),%ecx
pushl %ecx
leal 36(%esi),%eax
pushl %eax
call KeGetCurrentProcess
pushl %eax
call ObInsertHandle
movl 8(%ebp),%ecx
movl %eax,(%ecx)
.L42:
leal 36(%esi),%eax
.L45:
leal -24(%ebp),%esp
popl %ebx
popl %esi
popl %edi
movl %ebp,%esp
popl %ebp
ret
.Lfe7:
.size ObGenericCreateObject,.Lfe7-ObGenericCreateObject
.align 16
.globl ObInitializeObjectHeader
.type ObInitializeObjectHeader,@function
ObInitializeObjectHeader:
pushl %ebp
movl %esp,%ebp
pushl %esi
pushl %ebx
movl 8(%ebp),%eax
movl 12(%ebp),%esi
movl 16(%ebp),%ebx
movl $0,20(%ebx)
movl $0,16(%ebx)
movl %eax,32(%ebx)
movb $0,24(%ebx)
testl %esi,%esi
jne .L49
movw $0,(%ebx)
movl $0,4(%ebx)
jmp .L50
.align 16
.L49:
pushl %esi
call wstrlen
movw %ax,2(%ebx)
andl $65535,%eax
leal 2(,%eax,2),%eax
pushl %eax
pushl $0
call ExAllocatePool
movl %eax,4(%ebx)
pushl %esi
pushl %ebx
call RtlInitUnicodeString
.L50:
leal -8(%ebp),%esp
popl %ebx
popl %esi
movl %ebp,%esp
popl %ebp
ret
.Lfe8:
.size ObInitializeObjectHeader,.Lfe8-ObInitializeObjectHeader
.align 16
.globl ObReferenceObjectByPointer
.type ObReferenceObjectByPointer,@function
ObReferenceObjectByPointer:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
incl -20(%eax)
xorl %eax,%eax
movl %ebp,%esp
popl %ebp
ret
.Lfe9:
.size ObReferenceObjectByPointer,.Lfe9-ObReferenceObjectByPointer
.align 16
.globl ObPerformRetentionChecks
.type ObPerformRetentionChecks,@function
ObPerformRetentionChecks:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 8(%ebp),%ebx
cmpl $0,16(%ebx)
jne .L54
cmpl $0,20(%ebx)
jne .L54
cmpb $0,24(%ebx)
jne .L54
pushl %ebx
call ObRemoveEntry
pushl %ebx
call ExFreePool
.L54:
xorl %eax,%eax
movl -4(%ebp),%ebx
movl %ebp,%esp
popl %ebp
ret
.Lfe10:
.size ObPerformRetentionChecks,.Lfe10-ObPerformRetentionChecks
.align 16
.globl ObDereferenceObject
.type ObDereferenceObject,@function
ObDereferenceObject:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
leal -36(%eax),%edx
decl -20(%eax)
pushl %edx
call ObPerformRetentionChecks
movl %ebp,%esp
popl %ebp
ret
.Lfe11:
.size ObDereferenceObject,.Lfe11-ObDereferenceObject
.align 16
.globl NtClose
.type NtClose,@function
NtClose:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
pushl %eax
call ZwClose
movl %ebp,%esp
popl %ebp
ret $4
.Lfe12:
.size NtClose,.Lfe12-NtClose
.align 16
.globl ZwClose
.type ZwClose,@function
ZwClose:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
pushl %eax
call KeGetCurrentProcess
pushl %eax
call ObTranslateHandle
movl %eax,%edx
addl $8,%esp
testl %edx,%edx
je .L59
movl (%edx),%eax
movl $0,(%edx)
leal -36(%eax),%edx
decl -16(%eax)
pushl %edx
call ObPerformRetentionChecks
xorl %eax,%eax
movl %ebp,%esp
popl %ebp
ret $4
.align 16
.L59:
movl $-1073741816,%eax
movl %ebp,%esp
popl %ebp
ret $4
.Lfe13:
.size ZwClose,.Lfe13-ZwClose
.align 16
.globl ObReferenceObjectByHandle
.type ObReferenceObjectByHandle,@function
ObReferenceObjectByHandle:
pushl %ebp
movl %esp,%ebp
pushl %edi
pushl %esi
pushl %ebx
movl 8(%ebp),%eax
movl 16(%ebp),%ebx
movl 24(%ebp),%esi
pushl %eax
call KeGetCurrentProcess
pushl %eax
call ObTranslateHandle
testl %eax,%eax
je .L64
movl (%eax),%edx
testl %edx,%edx
jne .L63
.L64:
movl $-1073741816,%eax
jmp .L68
.align 16
.L63:
leal -36(%edx),%ecx
testl %ebx,%ebx
je .L66
cmpl %ebx,-4(%edx)
je .L66
movl $-2147483605,%eax
jmp .L68
.align 16
.L66:
movl 12(%ebp),%edi
testl %edi,4(%eax)
jne .L67
incl 16(%ecx)
movl (%eax),%eax
movl %eax,(%esi)
xorl %eax,%eax
jmp .L68
.align 16
.L67:
movl $-2147483557,%eax
.L68:
leal -12(%ebp),%esp
popl %ebx
popl %esi
popl %edi
movl %ebp,%esp
popl %ebp
ret
.Lfe14:
.size ObReferenceObjectByHandle,.Lfe14-ObReferenceObjectByHandle
.ident "GCC: (GNU) 2.7.2.3"

View file

@ -1,9 +1,9 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/bug.c
* PURPOSE: Graceful system shutdown if a bug is detected
* PROGRAMMER: David Welch (welch@mcmail.com)
* FILE: ntoskrnl/ps/idle.c
* PURPOSE: Using idle time
* PROGRAMMER: David Welch (welch@cwcom.net)
* UPDATE HISTORY:
* Created 22/05/98
*/

View file

@ -13,9 +13,13 @@
#include <ddk/ntddk.h>
#include <internal/ps.h>
#define NDEBUG
//#define NDEBUG
#include <internal/debug.h>
/* GLBOALS *******************************************************************/
extern ULONG PiNrThreads;
/* FUNCTIONS *****************************************************************/
NTSTATUS STDCALL NtTerminateThread(IN HANDLE ThreadHandle,
@ -51,6 +55,14 @@ NTSTATUS STDCALL ZwTerminateThread(IN HANDLE ThreadHandle,
}
}
VOID PsReleaseThread(PETHREAD Thread)
{
DPRINT("PsReleaseThread(Thread %x)\n",Thread);
RemoveEntryList(&Thread->Tcb.Entry);
ExFreePool(Thread);
}
NTSTATUS PsTerminateSystemThread(NTSTATUS ExitStatus)
/*
@ -63,6 +75,8 @@ NTSTATUS PsTerminateSystemThread(NTSTATUS ExitStatus)
KIRQL oldlvl;
PETHREAD CurrentThread;
PiNrThreads--;
CurrentThread = PsGetCurrentThread();
CurrentThread->ExitStatus = ExitStatus;
@ -70,7 +84,6 @@ NTSTATUS PsTerminateSystemThread(NTSTATUS ExitStatus)
DPRINT("terminating %x\n",CurrentThread);
KeRaiseIrql(DISPATCH_LEVEL,&oldlvl);
CurrentThread->Tcb.ThreadState = THREAD_STATE_TERMINATED;
RemoveEntryList(&CurrentThread->Tcb.Entry);
ZwYieldExecution();
for(;;);
}

View file

@ -15,7 +15,7 @@
#include <internal/mm.h>
#include <internal/string.h>
#define NDEBUG
//#define NDEBUG
#include <internal/debug.h>
/* GLOBALS ******************************************************************/
@ -157,20 +157,25 @@ NTSTATUS STDCALL ZwCreateProcess(
LARGE_INTEGER Offset;
NTSTATUS Status;
DPRINT("ZwCreateProcess(ObjectAttributes %x)\n",ObjectAttributes);
Status = ObReferenceObjectByHandle(ParentProcessHandle,
PROCESS_CREATE_PROCESS,
PsProcessType,
UserMode,
&ParentProcessHandle,
NULL);
if (Status != STATUS_SUCCESS)
{
DPRINT("ZwCreateProcess() = %x\n",Status);
return(Status);
}
Process = ObGenericCreateObject(ProcessHandle,DesiredAccess,
ObjectAttributes,PsProcessType);
Process = ObGenericCreateObject(ProcessHandle,
DesiredAccess,
ObjectAttributes,
PsProcessType);
KProcess = &(Process->Pcb);
InitializeListHead(&(KProcess->MemoryAreaList));
@ -187,6 +192,14 @@ NTSTATUS STDCALL ZwCreateProcess(
PageDirectory[i]=CurrentPageDirectory[i];
}
/*
* FIXME: I don't what I'm supposed to know with a section handle
*/
if (SectionHandle != NULL)
{
DbgPrint("ZwCreateProcess() non-NULL SectionHandle\n");
return(STATUS_UNSUCCESSFUL);
}
return(STATUS_SUCCESS);
}

View file

@ -45,6 +45,7 @@ static KSPIN_LOCK ThreadListLock = {0,};
*/
static LIST_ENTRY PriorityListHead[NR_THREAD_PRIORITY_LEVELS]={{NULL,NULL},};
static BOOLEAN DoneInitYet = FALSE;
ULONG PiNrThreads = 0;
static PETHREAD CurrentThread = NULL;
@ -66,7 +67,8 @@ static VOID PsInsertIntoThreadList(KPRIORITY Priority, PETHREAD Thread)
{
KIRQL oldlvl;
DPRINT("PsInsertIntoThreadList(Priority %d, Thread %x)\n",Priority,Thread);
DPRINT("PsInsertIntoThreadList(Priority %x, Thread %x)\n",Priority,
Thread);
KeAcquireSpinLock(&ThreadListLock,&oldlvl);
InsertTailList(&PriorityListHead[THREAD_PRIORITY_MAX+Priority],
@ -91,12 +93,19 @@ static PETHREAD PsScanThreadList(KPRIORITY Priority)
PETHREAD oldest = NULL;
ULONG oldest_time = 0;
DPRINT("PsScanThreadList(Priority %d)\n",Priority);
// DPRINT("PsScanThreadList(Priority %d)\n",Priority);
current_entry = PriorityListHead[THREAD_PRIORITY_MAX+Priority].Flink;
while (current_entry != &PriorityListHead[THREAD_PRIORITY_MAX+Priority])
{
current = CONTAINING_RECORD(current_entry,ETHREAD,Tcb.Entry);
#if 0
if (current->Tcb.ThreadState == THREAD_STATE_TERMINATED &&
current != CurrentThread)
{
PsReleaseThread(CurrentThread);
}
#endif
if (current->Tcb.ThreadState == THREAD_STATE_RUNNABLE)
{
if (oldest == NULL || oldest_time > current->Tcb.LastTick)
@ -107,7 +116,7 @@ static PETHREAD PsScanThreadList(KPRIORITY Priority)
}
current_entry = current_entry->Flink;
}
DPRINT("PsScanThreadList() = %x\n",oldest);
// DPRINT("PsScanThreadList() = %x\n",oldest);
return(oldest);
}
@ -139,7 +148,7 @@ VOID PsDispatchThread(VOID)
Candidate = PsScanThreadList(CurrentPriority);
if (Candidate == CurrentThread)
{
DPRINT("Scheduling current thread\n");
// DbgPrint("Scheduling current thread\n");
KeQueryTickCount(&TickCount);
CurrentThread->Tcb.LastTick = GET_LARGE_INTEGER_LOW_PART(TickCount);
CurrentThread->Tcb.ThreadState = THREAD_STATE_RUNNING;
@ -148,7 +157,7 @@ VOID PsDispatchThread(VOID)
}
if (Candidate != NULL)
{
DPRINT("Scheduling %x\n",Candidate);
// DbgPrint("Scheduling %x\n",Candidate);
Candidate->Tcb.ThreadState = THREAD_STATE_RUNNING;
@ -175,6 +184,8 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
PETHREAD Thread;
NTSTATUS Status;
PiNrThreads++;
Thread = ObGenericCreateObject(ThreadHandle,
DesiredAccess,
ThreadAttributes,
@ -202,15 +213,23 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
else
{
Thread->ThreadsProcess=SystemProcess;
ObReferenceObjectByPointer(Thread->ThreadsProcess,
PROCESS_CREATE_THREAD,
PsProcessType,
UserMode);
}
ObReferenceObjectByPointer(Thread->ThreadsProcess,
PROCESS_CREATE_THREAD,
PsProcessType,
UserMode);
InitializeListHead(Thread->Tcb.ApcList);
InitializeListHead(&(Thread->IrpList));
Thread->Cid.UniqueThread=NextThreadUniqueId++;
// thread->Cid.ThreadId=InterlockedIncrement(&NextThreadUniqueId);
Thread->Cid.UniqueThread=InterlockedIncrement(&NextThreadUniqueId);
PsInsertIntoThreadList(Thread->Tcb.CurrentPriority,Thread);
*ThreadPtr = Thread;
ObDereferenceObject(Thread->ThreadsProcess);
return(STATUS_SUCCESS);
}
@ -325,6 +344,9 @@ NTSTATUS ZwCreateThread(PHANDLE ThreadHandle,
PETHREAD Thread;
NTSTATUS Status;
DbgPrint("ZwCreateThread(ThreadHandle %x, PCONTEXT %x)\n",
ThreadHandle,ThreadContext);
Status = PsInitializeThread(ProcessHandle,&Thread,ThreadHandle,
DesiredAccess,ObjectAttributes);
if (Status != STATUS_SUCCESS)
@ -509,6 +531,7 @@ NTSTATUS STDCALL ZwResumeThread(IN HANDLE ThreadHandle,
Thread->Tcb.ThreadState = THREAD_STATE_RUNNABLE;
}
ObDereferenceObject(Thread);
return(STATUS_SUCCESS);
}
@ -570,6 +593,7 @@ NTSTATUS STDCALL ZwSuspendThread(IN HANDLE ThreadHandle,
}
}
ObDereferenceObject(Thread);
return(STATUS_SUCCESS);
}

View file

@ -2,9 +2,22 @@ bits 32
section .text
DECLARE_GLOBAL_SYMBOL InterlockedIncrement
push ebp
mov ebp,esp
push eax
push ebx
mov eax,1
mov ebx,[esp+4]
mov ebx,[ebp+8]
xadd [ebx],eax
pop ebx
pop eax
mov esp,ebp
pop ebp
ret

View file

@ -223,25 +223,25 @@ VOID RtlCopyUnicodeString(IN OUT PUNICODE_STRING DestinationString,
{
unsigned long copylen, i;
if(SourceString==NULL) {
if(SourceString==NULL)
{
DestinationString->Length=0;
} else {
if(SourceString->Length<DestinationString->MaximumLength) {
copylen=SourceString->Length;
} else {
copylen=DestinationString->MaximumLength;
};
}
else
{
copylen = min(DestinationString->MaximumLength,
SourceString->Length);
for(i=0; i<copylen; i++)
{
*DestinationString->Buffer=*SourceString->Buffer;
DestinationString->Buffer++;
SourceString->Buffer++;
};
}
*DestinationString->Buffer=0;
DestinationString->Buffer-=copylen;
SourceString->Buffer-=copylen;
};
};
}
}
BOOLEAN RtlEqualString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive)
{
@ -350,20 +350,24 @@ VOID RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString,
IN PCWSTR SourceString)
{
unsigned long i, DestSize;
UNICODE_STRING Dest=*DestinationString;
if(SourceString==NULL) {
DPRINT("RtlInitUnicodeString(DestinationString %x, "
"SourceString %x)\n",DestinationString,SourceString);
if (SourceString==NULL)
{
DestinationString->Length=0;
DestinationString->MaximumLength=0;
DestinationString->Buffer=NULL;
} else {
}
else
{
DestSize=wstrlen((PWSTR)SourceString);
DestinationString->Length=DestSize;
DestinationString->MaximumLength=DestSize+1;
DestinationString->Buffer=(PWSTR)SourceString;
};
};
}
}
NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base, /* optional */
IN OUT PUNICODE_STRING String)

View file

@ -129,7 +129,7 @@ VOID ExExecuteShell(VOID)
BaseAddress = (PVOID)0x10000;
LARGE_INTEGER_QUAD_PART(SectionOffset) = 0;
Size = 0x10000;
Size = 0x20000;
ZwMapViewOfSection(SectionHandle,
ShellHandle,
&BaseAddress,