Cleaned up system libraries

svn path=/trunk/; revision=121
This commit is contained in:
David Welch 1998-12-19 17:48:53 +00:00
parent 0d71cd85bd
commit 7e398d4e22
4 changed files with 128 additions and 105 deletions

View file

@ -0,0 +1,128 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/kernel32/file/create.c
* PURPOSE: Directory functions
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
GetTempFileName is modified from WINE [ Alexandre Juiliard ]
* UPDATE HISTORY:
* Created 01/11/98
*/
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ddk/ntddk.h>
#include <wstring.h>
#include <string.h>
#include <kernel32/li.h>
#include <ddk/rtl.h>
HANDLE STDCALL CreateFileA(LPCSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile)
{
WCHAR FileNameW[MAX_PATH];
ULONG i = 0;
OutputDebugStringA("CreateFileA\n");
while ((*lpFileName)!=0 && i < MAX_PATH)
{
FileNameW[i] = *lpFileName;
lpFileName++;
i++;
}
FileNameW[i] = 0;
return CreateFileW(FileNameW,dwDesiredAccess,
dwShareMode,
lpSecurityAttributes,
dwCreationDisposition,
dwFlagsAndAttributes,
hTemplateFile);
}
HANDLE STDCALL CreateFileW(LPCWSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile)
{
HANDLE FileHandle;
NTSTATUS Status;
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock;
UNICODE_STRING FileNameString;
ULONG Flags = 0;
WCHAR PathNameW[MAX_PATH];
WCHAR *FilePart;
UINT Len = 0;
WCHAR CurrentDir[MAX_PATH];
OutputDebugStringA("CreateFileW\n");
if (!(dwFlagsAndAttributes & FILE_FLAG_OVERLAPPED))
{
Flags |= FILE_SYNCHRONOUS_IO_ALERT;
}
// lstrcpyW(PathNameW,L"\\??\\");
PathNameW[0] = '\\';
PathNameW[1] = '?';
PathNameW[2] = '?';
PathNameW[3] = '\\';
PathNameW[4] = 0;
dprintf("Name %w\n",PathNameW);
if (lpFileName[0] != L'\\' && lpFileName[1] != L':')
{
Len = GetCurrentDirectoryW(MAX_PATH,CurrentDir);
dprintf("CurrentDir %w\n",CurrentDir);
lstrcatW(PathNameW,CurrentDir);
dprintf("Name %w\n",PathNameW);
}
lstrcatW(PathNameW,lpFileName);
dprintf("Name %w\n",PathNameW);
FileNameString.Length = lstrlenW( PathNameW)*sizeof(WCHAR);
if ( FileNameString.Length == 0 )
return NULL;
if ( FileNameString.Length > MAX_PATH )
return NULL;
FileNameString.Buffer = (WCHAR *)PathNameW;
FileNameString.MaximumLength = FileNameString.Length;
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory = NULL;
ObjectAttributes.ObjectName = &FileNameString;
ObjectAttributes.Attributes = OBJ_CASE_INSENSITIVE;
ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService = NULL;
Status = NtCreateFile(&FileHandle,
dwDesiredAccess,
&ObjectAttributes,
&IoStatusBlock,
NULL,
dwFlagsAndAttributes,
dwShareMode,
dwCreationDisposition,
Flags,
NULL,
0);
return(FileHandle);
}

View file

@ -1,89 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS version of ntdll
* FILE: lib/ntdll/genntdll.c
* PURPOSE: Generates the system call stubs in ntdll
* PROGRAMMER: David Welch (welch@mcmail.com)
*/
/* INCLUDE ******************************************************************/
#include <stdio.h>
#include <stdlib.h>
/* FUNCTIONS ****************************************************************/
int process(FILE* in, FILE* out)
{
char line[255];
char* s;
char* name;
char* value;
char* nr_args;
fprintf(out,"; Machine generated, don't edit\n");
fprintf(out,"\n\n");
while (!feof(in) && fgets(line,255,in)!=NULL)
{
fgets(line,255,in);
if ((s=strchr(line,'\n'))!=NULL)
{
*s=0;
}
s=&line[0];
if ((*s)!='#')
{
name = strtok(s," \t");
value = strtok(NULL," \t");
nr_args = strtok(NULL," \t");
// printf("name %s value %s\n",name,value);
fprintf(out,"%s:\n",name);
fprintf(out,"\tmov\teax,%s\n",value);
fprintf(out,"\tlea\tedx,[esp+4]\n");
fprintf(out,"\tint\t2Eh\n");
fprintf(out,"\tret\t%s\n\n",nr_args);
}
}
}
void usage(void)
{
printf("Usage: genntdll infile.cll outfile.c\n");
}
int main(int argc, char* argv[])
{
FILE* in;
FILE* out;
int ret;
if (argc!=3)
{
usage();
return(1);
}
in = fopen(argv[1],"rb");
if (in==NULL)
{
perror("Failed to open input file");
return(1);
}
out = fopen(argv[2],"wb");
if (out==NULL)
{
perror("Failed to open output file");
return(1);
}
ret = process(in,out);
fclose(in);
fclose(out);
return(ret);
}

View file

@ -1,9 +0,0 @@
; Machine generated, don't edit
NtAlertThread:
mov eax,4
lea edx,[esp+4]
int 2Eh
ret 14

View file

@ -1,7 +0,0 @@
#
# This defines the kernel entry points used by ntdll
#
# They have the following format
# <name> <system call number> <size of the parameters in bytes>
#
NtAlertThread 4 14