From d7045620829fb153193fb9bcf832dee0b79e1e8c Mon Sep 17 00:00:00 2001 From: Rex Jolliff Date: Fri, 19 Mar 1999 05:55:55 +0000 Subject: [PATCH] Merged mingw32 branch into main trunk svn path=/trunk/; revision=321 --- reactos/NEWS | 2 +- reactos/apps/tests/args/args.c | 35 + reactos/apps/tests/args/makefile | 11 + reactos/apps/utils/shell/makefile | 9 +- reactos/apps/utils/shell/shell.c | 13 +- reactos/boot.bat | 2 +- reactos/bootflop.bat | 16 +- reactos/drivers/dd/blue/.cvsignore | 4 + reactos/drivers/dd/blue/{blues.c => blue.c} | 5 +- reactos/drivers/dd/blue/makefile | 23 + reactos/drivers/dd/event/exe/eventtes.c | 2 +- reactos/drivers/dd/event/sys/event.c | 2 +- reactos/drivers/dd/ide/.cvsignore | 3 + reactos/drivers/dd/ide/ide.c | 3 +- reactos/drivers/dd/ide/makefile | 21 +- reactos/drivers/dd/ide/partitio.h | 16 +- reactos/drivers/dd/keyboard/.cvsignore | 4 + reactos/drivers/dd/keyboard/keyboard.c | 5 +- reactos/drivers/dd/keyboard/makefile | 16 +- reactos/drivers/dd/sound/dsp.c | 2 +- reactos/drivers/dd/sound/mixer.c | 2 +- reactos/drivers/dd/sound/sb16.h | 2 +- reactos/drivers/dd/sound/sb_waveout.c | 2 +- reactos/drivers/dd/sound/sound.c | 1 + reactos/drivers/dd/sound/wave.c | 126 +++ reactos/drivers/dd/sound/wave.h | 2 +- reactos/drivers/dd/test/.cvsignore | 4 + reactos/drivers/dd/test/makefile | 17 +- reactos/drivers/dd/test/test.c | 17 +- reactos/drivers/fs/ext2/blockdev.c | 1 + reactos/drivers/fs/ext2/dir.c | 2 +- reactos/drivers/fs/ext2/file.c | 2 - reactos/drivers/fs/ext2/makefile | 21 +- reactos/drivers/fs/ext2/rw.c | 2 - reactos/drivers/fs/ext2/super.c | 2 +- reactos/drivers/fs/minix/block.c | 2 - reactos/drivers/fs/minix/blockdev.c | 1 + reactos/drivers/fs/minix/dir.c | 2 - reactos/drivers/fs/minix/inode.c | 1 + reactos/drivers/fs/minix/mount.c | 2 - reactos/drivers/fs/minix/rw.c | 2 - reactos/drivers/fs/vfat/.cvsignore | 4 + reactos/drivers/fs/vfat/blockdev.c | 2 - reactos/drivers/fs/vfat/dir.c | 30 +- reactos/drivers/fs/vfat/dirwr.c | 93 +- reactos/drivers/fs/vfat/iface.c | 608 +++++----- reactos/drivers/fs/vfat/makefile | 33 +- reactos/drivers/fs/vfat/vfat.h | 20 +- reactos/drivers/fs/vfat/vfat005.1st | 2 +- reactos/drivers/svc_specs | 78 ++ reactos/iface/native/genntdll.c | 11 +- reactos/iface/native/makefile | 4 +- reactos/iface/native/sysfuncs.lst | 2 +- reactos/include/base.h | 8 +- reactos/include/conio.h | 67 -- reactos/include/{ => crtdll}/assert.h | 6 +- reactos/include/crtdll/conio.h | 111 ++ reactos/include/{ => crtdll}/ctype.h | 58 +- reactos/include/{ => crtdll}/dir.h | 6 +- reactos/include/crtdll/direct.h | 27 + reactos/include/{ => crtdll}/dirent.h | 6 +- reactos/include/crtdll/dos.h | 158 +++ reactos/include/{ => crtdll}/errno.h | 10 +- reactos/include/crtdll/fcntl.h | 164 +++ reactos/include/{ => crtdll}/float.h | 12 +- reactos/include/{ => crtdll}/io.h | 6 +- reactos/include/{ => crtdll}/math.h | 6 +- reactos/include/{ => crtdll}/process.h | 6 +- reactos/include/{ => crtdll}/share.h | 2 +- reactos/include/{ => crtdll}/signal.h | 4 +- reactos/include/{ => crtdll}/stdarg.h | 6 +- reactos/include/{ => crtdll}/stddef.h | 6 +- reactos/include/crtdll/stdio.h | 157 +++ reactos/include/{ => crtdll}/stdlib.h | 6 +- reactos/include/{ => crtdll}/sys/djtypes.h | 0 reactos/include/crtdll/sys/stat.h | 128 +++ reactos/include/crtdll/sys/types.h | 67 ++ reactos/include/{ => crtdll}/time.h | 4 +- reactos/include/ddk/extypes.h | 1 + reactos/include/ddk/iodef.h | 6 - reactos/include/ddk/iotypes.h | 11 - reactos/include/ddk/ketypes.h | 8 +- reactos/include/ddk/ntddk.h | 2 +- reactos/include/ddk/rtl.h | 36 +- reactos/include/ddk/status.h | 6 +- reactos/include/ddk/zw.h | 81 +- reactos/include/devices.h | 2 +- reactos/include/direct.h | 63 -- reactos/include/dos.h | 68 -- reactos/include/fcntl.h | 113 -- reactos/include/funcs.h | 2 + reactos/include/in.h | 2 +- reactos/include/internal/hal/ddk.h | 1 + reactos/include/internal/i386/mmhal.h | 15 +- reactos/include/internal/i386/string.h | 487 ++++++++ reactos/include/internal/id.h | 13 +- reactos/include/internal/io.h | 6 +- reactos/include/internal/ke.h | 8 +- reactos/include/internal/ldr.h | 6 + reactos/include/internal/ntoskrnl.h | 6 +- reactos/include/internal/string.h | 369 ++---- reactos/include/internal/types.h | 6 +- reactos/include/kernel32/kernel32.h | 4 + reactos/include/kernel32/li.h | 2 +- reactos/include/libc/file.h | 2 - reactos/include/ntdll/.cvsignore | 1 + reactos/include/ntdll/ntdll.h | 14 + reactos/include/pe.h | 152 +-- reactos/include/stdio.h | 8 +- reactos/include/string.h | 921 --------------- reactos/include/structs.h | 4 + reactos/include/sys/stat.h | 119 -- reactos/include/sys/types.h | 112 -- reactos/include/types.h | 61 - reactos/include/wchar.h | 31 - reactos/include/wstring.h | 88 -- reactos/lib/advapi32/reg/reg.c | 1 + reactos/lib/advapi32/sec/sec.c | 2 +- reactos/lib/crtdll/conio/cputs.c | 2 +- reactos/lib/crtdll/conio/getch.c | 10 +- reactos/lib/crtdll/conio/ungetch.c | 2 +- reactos/lib/crtdll/ctype/isctype.c | 1 - reactos/lib/crtdll/direct/chdir.c | 3 +- reactos/lib/crtdll/direct/getdfree.c | 2 +- reactos/lib/crtdll/direct/mkdir.c | 2 +- reactos/lib/crtdll/direct/rmdir.c | 2 +- reactos/lib/crtdll/io/access.c | 21 +- reactos/lib/crtdll/io/close.c | 12 +- reactos/lib/crtdll/io/create.c | 6 +- reactos/lib/crtdll/io/dup.c | 12 +- reactos/lib/crtdll/io/dup2.c | 13 +- reactos/lib/crtdll/io/find.c | 14 +- reactos/lib/crtdll/io/fmode.c | 1 + reactos/lib/crtdll/io/isatty.c | 8 +- reactos/lib/crtdll/io/lseek.c | 11 +- reactos/lib/crtdll/io/open.c | 14 +- reactos/lib/crtdll/io/read.c | 8 +- reactos/lib/crtdll/io/setmode.c | 2 +- reactos/lib/crtdll/io/unlink.c | 6 +- reactos/lib/crtdll/io/write.c | 7 +- reactos/lib/crtdll/misc/GetArgs.c | 6 +- reactos/lib/crtdll/misc/sleep.c | 2 +- reactos/lib/crtdll/misc/unwind.c | 2 +- reactos/lib/crtdll/process/Cwait.c | 2 +- reactos/lib/crtdll/process/execl.c | 4 +- reactos/lib/crtdll/process/execle.c | 4 +- reactos/lib/crtdll/process/execlp.c | 6 +- reactos/lib/crtdll/process/execlpe.c | 4 +- reactos/lib/crtdll/process/execv.c | 7 +- reactos/lib/crtdll/process/execve.c | 7 +- reactos/lib/crtdll/process/execvp.c | 6 +- reactos/lib/crtdll/process/execvpe.c | 9 +- reactos/lib/crtdll/process/spawnl.c | 6 +- reactos/lib/crtdll/process/spawnle.c | 4 +- reactos/lib/crtdll/process/spawnlp.c | 4 +- reactos/lib/crtdll/process/spawnlpe.c | 2 +- reactos/lib/crtdll/process/spawnv.c | 6 +- reactos/lib/crtdll/process/spawnve.c | 15 +- reactos/lib/crtdll/process/spawnvp.c | 6 +- reactos/lib/crtdll/process/spawnvpe.c | 18 +- reactos/lib/crtdll/stdio/allocfil.c | 3 +- reactos/lib/crtdll/stdio/doprnt.c | 5 - reactos/lib/crtdll/stdio/fclose.c | 8 +- reactos/lib/crtdll/stdio/fileno.c | 2 +- reactos/lib/crtdll/stdio/flsbuf.c | 4 +- reactos/lib/crtdll/stdio/fopen.c | 7 +- reactos/lib/crtdll/stdio/fprintf.c | 23 - reactos/lib/crtdll/stdio/fputs.c | 2 +- reactos/lib/crtdll/stdio/freopen.c | 4 +- reactos/lib/crtdll/stdio/fscanf.c | 2 +- reactos/lib/crtdll/stdio/fsetpos.c | 2 +- reactos/lib/crtdll/stdio/getc.c | 5 +- reactos/lib/crtdll/stdio/getenv.c | 2 +- reactos/lib/crtdll/stdio/printf.c | 14 - reactos/lib/crtdll/stdio/putc.c | 2 +- reactos/lib/crtdll/stdio/puts.c | 2 +- reactos/lib/crtdll/stdio/remove.c | 1 - reactos/lib/crtdll/stdio/rename.c | 7 +- reactos/lib/crtdll/stdio/sprintf.c | 13 - reactos/lib/crtdll/stdio/stdhnd.c | 1 + reactos/lib/crtdll/stdio/tempnam.c | 2 +- reactos/lib/crtdll/stdio/tmpfile.c | 8 +- reactos/lib/crtdll/stdio/vfprintf.c | 22 - reactos/lib/crtdll/stdio/vprintf.c | 9 - reactos/lib/crtdll/stdio/vsprintf.c | 13 - reactos/lib/crtdll/stdlib/Exit.c | 3 +- reactos/lib/crtdll/stdlib/abort.c | 2 +- reactos/lib/crtdll/stdlib/abs.c | 4 +- reactos/lib/crtdll/stdlib/atold.c | 1 - reactos/lib/crtdll/stdlib/bsearch.c | 5 +- reactos/lib/crtdll/stdlib/errno.c | 10 +- reactos/lib/crtdll/stdlib/fullpath.c | 7 + reactos/lib/crtdll/stdlib/makepath.c | 2 +- reactos/lib/crtdll/stdlib/malloc.c | 20 +- reactos/lib/crtdll/stdlib/putenv.c | 3 +- reactos/lib/crtdll/stdlib/qsort.c | 2 +- reactos/lib/crtdll/stdlib/senv.c | 2 +- reactos/lib/crtdll/stdlib/strtod.c | 96 +- reactos/lib/crtdll/stdlib/strtol.c | 90 +- reactos/lib/crtdll/stdlib/strtoul.c | 70 +- reactos/lib/crtdll/string/memmove.c | 2 +- reactos/lib/crtdll/string/memset.c | 2 +- reactos/lib/crtdll/string/strerror.c | 1 + reactos/lib/crtdll/string/strlwr.c | 2 +- reactos/lib/crtdll/string/strtoul.c | 2 +- reactos/lib/crtdll/sys_stat/fstat.c | 2 +- reactos/lib/crtdll/sys_stat/stat.c | 2 +- reactos/lib/crtdll/time/ctime.c | 17 +- reactos/lib/crtdll/time/strftime.c | 17 + reactos/lib/crtdll/time/time.c | 20 +- reactos/lib/crtdll/wchar/wcscmp.c | 2 +- reactos/lib/crtdll/wchar/wcscoll.c | 2 +- reactos/lib/crtdll/wchar/wcscpy.c | 2 +- reactos/lib/crtdll/wchar/wcscspn.c | 2 +- reactos/lib/crtdll/wchar/wcsicmp.c | 2 +- reactos/lib/crtdll/wchar/wcslwr.c | 2 +- reactos/lib/crtdll/wchar/wcsrchr.c | 2 +- reactos/lib/crtdll/wchar/wcsrev.c | 2 +- reactos/lib/crtdll/wchar/wcsspn.c | 2 +- reactos/lib/crtdll/wchar/wcsstr.c | 2 +- reactos/lib/crtdll/wchar/wcstok.c | 2 +- reactos/lib/crtdll/wchar/wcstombs.c | 2 +- reactos/lib/kernel32/file/copy.c | 237 ++++ reactos/lib/kernel32/file/create.c | 27 +- reactos/lib/kernel32/file/curdir.c | 21 +- reactos/lib/kernel32/file/dir.c | 25 +- reactos/lib/kernel32/file/file.c | 573 +++------- reactos/lib/kernel32/file/find.c | 8 +- reactos/lib/kernel32/file/find1.c | 124 --- reactos/lib/kernel32/file/iocompl.c | 3 +- reactos/lib/kernel32/file/lfile.c | 2 +- reactos/lib/kernel32/file/volume.c | 4 +- reactos/lib/kernel32/internal/dprintf.c | 44 +- reactos/lib/kernel32/internal/init.c | 8 +- reactos/lib/kernel32/internal/string.c | 21 + reactos/lib/kernel32/makefile | 8 +- reactos/lib/kernel32/mem/heap.c | 2 +- reactos/lib/kernel32/misc/atom.c | 8 +- reactos/lib/kernel32/misc/console.c | 8 +- reactos/lib/kernel32/misc/dllmain.c | 2 +- reactos/lib/kernel32/misc/env.c | 2 +- reactos/lib/kernel32/misc/error.c | 7 +- reactos/lib/kernel32/misc/handle.c | 2 +- reactos/lib/kernel32/misc/time.c | 332 ++---- reactos/lib/kernel32/process/cmdline.c | 4 +- reactos/lib/kernel32/process/proc.c | 6 +- reactos/lib/kernel32/string/lstring.c | 4 +- reactos/lib/kernel32/synch/event.c | 7 +- reactos/lib/kernel32/synch/wait.c | 3 +- reactos/lib/mingw32/main.c | 92 -- reactos/lib/mingw32/makefile | 10 - reactos/lib/ntdll/.cvsignore | 6 + reactos/lib/ntdll/def/ntdll.def | 869 ++++++++------- reactos/lib/ntdll/ldr/startup.c | 380 +++++++ reactos/lib/ntdll/main/dllmain.c | 33 +- reactos/lib/ntdll/makefile | 48 +- reactos/lib/ntdll/ntdll_specs | 78 ++ reactos/lib/ntdll/rtl/critical.c | 41 + reactos/lib/ntdll/rtl/heap.c | 1116 +++++++++++++++++++ reactos/lib/ntdll/rtl/largeint.c | 277 +++++ reactos/lib/ntdll/rtl/mem.c | 74 ++ reactos/lib/ntdll/rtl/unicode.c | 16 +- reactos/lib/ntdll/stdio/vsprintf.c | 6 +- reactos/lib/ntdll/string/memset.c | 13 + reactos/lib/ntdll/string/strcat.c | 12 + reactos/lib/ntdll/string/strcmp.c | 15 + reactos/lib/ntdll/string/strcpy.c | 10 + reactos/lib/ntdll/string/stricmp.c | 16 + reactos/lib/ntdll/string/strncmp.c | 18 + reactos/lib/ntdll/string/strncpy.c | 21 + reactos/lib/ntdll/string/strnlen.c | 14 + reactos/lib/ntdll/string/strrchr.c | 21 + reactos/lib/ntdll/string/wstring.c | 444 +------- reactos/lib/ntdll/stubs/stubs.c | 314 +----- reactos/loaders/dos/loadros.asm | 2 +- reactos/makedisk.bat | 15 +- reactos/makefile.dos | 41 +- reactos/makefile_rex | 130 ++- reactos/ntoskrnl/.cvsignore | 3 + reactos/ntoskrnl/dbg/errinfo.c | 1 + reactos/ntoskrnl/ex/napi.c | 3 +- reactos/ntoskrnl/exports.lst | 6 +- reactos/ntoskrnl/hal/x86/bios32.c | 1 + reactos/ntoskrnl/hal/x86/dma.c | 2 +- reactos/ntoskrnl/hal/x86/exp.c | 25 +- reactos/ntoskrnl/hal/x86/head.s | 2 + reactos/ntoskrnl/hal/x86/irq.c | 1 + reactos/ntoskrnl/hal/x86/irql.c | 6 +- reactos/ntoskrnl/hal/x86/page.c | 10 +- reactos/ntoskrnl/hal/x86/printk.c | 25 +- reactos/ntoskrnl/hal/x86/sources | 1 + reactos/ntoskrnl/hal/x86/thread.c | 21 +- reactos/ntoskrnl/io/cleanup.c | 1 + reactos/ntoskrnl/io/create.c | 81 +- reactos/ntoskrnl/io/device.c | 110 +- reactos/ntoskrnl/io/ioctrl.c | 1 + reactos/ntoskrnl/io/irp.c | 3 +- reactos/ntoskrnl/io/mailslot.c | 2 +- reactos/ntoskrnl/io/rw.c | 32 +- reactos/ntoskrnl/io/vpb.c | 1 + reactos/ntoskrnl/ke/.cvsignore | 1 + reactos/ntoskrnl/ke/apc.c | 1 + reactos/ntoskrnl/ke/bug.c | 2 +- reactos/ntoskrnl/ke/event.c | 1 + reactos/ntoskrnl/ke/kernel.c | 2 +- reactos/ntoskrnl/ke/main.c | 12 +- reactos/ntoskrnl/ke/module.c | 400 ------- reactos/ntoskrnl/ke/timer.c | 6 +- reactos/ntoskrnl/ldr/loader.c | 979 ++++++---------- reactos/ntoskrnl/makefile_rex | 50 +- reactos/ntoskrnl/mm/freelist.new.c | 149 +++ reactos/ntoskrnl/mm/mdl.c | 1 + reactos/ntoskrnl/mm/mm.c | 1 + reactos/ntoskrnl/mm/npool.c | 1 + reactos/ntoskrnl/mm/section.c | 96 +- reactos/ntoskrnl/mm/virtual.c | 4 +- reactos/ntoskrnl/ntoskrnl.def | 66 ++ reactos/ntoskrnl/ntoskrnl.full.def | 1070 ++++++++++++++++++ reactos/ntoskrnl/ob/dirobj.c | 15 +- reactos/ntoskrnl/ob/handle.c | 1 + reactos/ntoskrnl/ob/namespc.c | 5 +- reactos/ntoskrnl/ob/ntobj.c | 2 +- reactos/ntoskrnl/ob/object.c | 4 +- reactos/ntoskrnl/ps/process.c | 1 + reactos/ntoskrnl/ps/thread.c | 1 + reactos/ntoskrnl/rtl/ctype.c | 35 +- reactos/ntoskrnl/rtl/mem.c | 3 +- reactos/ntoskrnl/rtl/memcpy.c | 31 + reactos/ntoskrnl/rtl/strtok.c | 48 + reactos/ntoskrnl/rtl/time.c | 2 +- reactos/ntoskrnl/rtl/unicode.c | 9 +- reactos/ntoskrnl/rtl/vsprintf.c | 2 +- reactos/ntoskrnl/rtl/wstring.c | 426 +------ reactos/ntoskrnl/se/semgr.c | 18 +- reactos/ntoskrnl/tst/test.c | 1 + reactos/ntoskrnl/utils/export/export | Bin 3292 -> 0 bytes reactos/ntoskrnl/utils/export/export.c | 2 +- reactos/ntoskrnl/utils/pe2bin/.cvsignore | 1 + reactos/ntoskrnl/utils/pe2bin/pe2bin.c | 88 ++ reactos/rules.mak | 46 +- reactos/specs | 78 ++ 341 files changed, 8425 insertions(+), 7213 deletions(-) create mode 100644 reactos/apps/tests/args/args.c create mode 100644 reactos/apps/tests/args/makefile create mode 100644 reactos/drivers/dd/blue/.cvsignore rename reactos/drivers/dd/blue/{blues.c => blue.c} (97%) create mode 100644 reactos/drivers/dd/blue/makefile create mode 100644 reactos/drivers/dd/ide/.cvsignore create mode 100644 reactos/drivers/dd/keyboard/.cvsignore create mode 100644 reactos/drivers/dd/sound/wave.c create mode 100644 reactos/drivers/dd/test/.cvsignore create mode 100644 reactos/drivers/fs/vfat/.cvsignore create mode 100644 reactos/drivers/svc_specs delete mode 100644 reactos/include/conio.h rename reactos/include/{ => crtdll}/assert.h (94%) create mode 100644 reactos/include/crtdll/conio.h rename reactos/include/{ => crtdll}/ctype.h (74%) rename reactos/include/{ => crtdll}/dir.h (97%) create mode 100644 reactos/include/crtdll/direct.h rename reactos/include/{ => crtdll}/dirent.h (94%) create mode 100644 reactos/include/crtdll/dos.h rename reactos/include/{ => crtdll}/errno.h (96%) create mode 100644 reactos/include/crtdll/fcntl.h rename reactos/include/{ => crtdll}/float.h (95%) rename reactos/include/{ => crtdll}/io.h (98%) rename reactos/include/{ => crtdll}/math.h (97%) rename reactos/include/{ => crtdll}/process.h (98%) rename reactos/include/{ => crtdll}/share.h (97%) rename reactos/include/{ => crtdll}/signal.h (98%) rename reactos/include/{ => crtdll}/stdarg.h (97%) rename reactos/include/{ => crtdll}/stddef.h (98%) create mode 100644 reactos/include/crtdll/stdio.h rename reactos/include/{ => crtdll}/stdlib.h (98%) rename reactos/include/{ => crtdll}/sys/djtypes.h (100%) create mode 100644 reactos/include/crtdll/sys/stat.h create mode 100644 reactos/include/crtdll/sys/types.h rename reactos/include/{ => crtdll}/time.h (98%) delete mode 100644 reactos/include/direct.h delete mode 100644 reactos/include/dos.h delete mode 100644 reactos/include/fcntl.h create mode 100644 reactos/include/internal/i386/string.h create mode 100644 reactos/include/internal/ldr.h create mode 100644 reactos/include/ntdll/.cvsignore create mode 100644 reactos/include/ntdll/ntdll.h delete mode 100644 reactos/include/string.h delete mode 100644 reactos/include/sys/stat.h delete mode 100644 reactos/include/sys/types.h delete mode 100644 reactos/include/types.h delete mode 100644 reactos/include/wchar.h delete mode 100644 reactos/include/wstring.h create mode 100644 reactos/lib/kernel32/file/copy.c delete mode 100644 reactos/lib/kernel32/file/find1.c create mode 100644 reactos/lib/kernel32/internal/string.c delete mode 100644 reactos/lib/mingw32/main.c delete mode 100644 reactos/lib/mingw32/makefile create mode 100644 reactos/lib/ntdll/.cvsignore create mode 100644 reactos/lib/ntdll/ldr/startup.c create mode 100644 reactos/lib/ntdll/ntdll_specs create mode 100644 reactos/lib/ntdll/rtl/critical.c create mode 100644 reactos/lib/ntdll/rtl/heap.c create mode 100644 reactos/lib/ntdll/rtl/largeint.c create mode 100644 reactos/lib/ntdll/rtl/mem.c create mode 100644 reactos/lib/ntdll/string/memset.c create mode 100644 reactos/lib/ntdll/string/strcat.c create mode 100644 reactos/lib/ntdll/string/strcmp.c create mode 100644 reactos/lib/ntdll/string/strcpy.c create mode 100644 reactos/lib/ntdll/string/stricmp.c create mode 100644 reactos/lib/ntdll/string/strncmp.c create mode 100644 reactos/lib/ntdll/string/strncpy.c create mode 100644 reactos/lib/ntdll/string/strnlen.c create mode 100644 reactos/lib/ntdll/string/strrchr.c create mode 100644 reactos/ntoskrnl/.cvsignore create mode 100644 reactos/ntoskrnl/ke/.cvsignore delete mode 100644 reactos/ntoskrnl/ke/module.c create mode 100644 reactos/ntoskrnl/mm/freelist.new.c create mode 100644 reactos/ntoskrnl/ntoskrnl.def create mode 100644 reactos/ntoskrnl/ntoskrnl.full.def create mode 100644 reactos/ntoskrnl/rtl/memcpy.c delete mode 100644 reactos/ntoskrnl/utils/export/export create mode 100644 reactos/ntoskrnl/utils/pe2bin/.cvsignore create mode 100644 reactos/ntoskrnl/utils/pe2bin/pe2bin.c create mode 100644 reactos/specs diff --git a/reactos/NEWS b/reactos/NEWS index 28e7d886500..654b9a26a67 100644 --- a/reactos/NEWS +++ b/reactos/NEWS @@ -1,4 +1,4 @@ -0.0.14 (so far): +0.0.14 (so far): 0.0.13: Mostly bugfixes (I think) diff --git a/reactos/apps/tests/args/args.c b/reactos/apps/tests/args/args.c new file mode 100644 index 00000000000..05055fc6033 --- /dev/null +++ b/reactos/apps/tests/args/args.c @@ -0,0 +1,35 @@ +#include + +#include +#include +#include + +HANDLE OutputHandle; +HANDLE InputHandle; + +void debug_printf(char* fmt, ...) +{ + va_list args; + char buffer[255]; + + va_start(args,fmt); + vsprintf(buffer,fmt,args); + WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL); + va_end(args); +} + + +void main(int argc, char* argv[]) +{ + int i; + + AllocConsole(); + InputHandle = GetStdHandle(STD_INPUT_HANDLE); + OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE); + + for (i=0; i args.sym + ../../ntoskrnl/utils/pe2bin/pe2bin$(EXE_POSTFIX) 0x10000 args.exe \ + args.bin diff --git a/reactos/apps/utils/shell/makefile b/reactos/apps/utils/shell/makefile index 866d060a3bc..2d9dc91c65b 100644 --- a/reactos/apps/utils/shell/makefile +++ b/reactos/apps/utils/shell/makefile @@ -1,11 +1,10 @@ -all: shell.bin +all: shell.exe OBJECTS= ../common/crt0.o shell.o -LIBS= ../../lib/kernel32/kernel32.a ../../lib/ntdll/ntdll.a ../../ntoskrnl/libgcc.a +LIBS= ../../lib/kernel32/kernel32.a ../../lib/ntdll/ntdll.a -shell.bin: $(OBJECTS) $(LIBS) - $(LD) -Ttext 0x10000 $(OBJECTS) $(LIBS) -o shell.exe +shell.exe: $(OBJECTS) $(LIBS) + $(CC) -specs=../../specs $(OBJECTS) $(LIBS) -lgcc -o shell.exe $(NM) --numeric-sort shell.exe > shell.sym - $(OBJCOPY) -O binary shell.exe shell.bin include ../../rules.mak diff --git a/reactos/apps/utils/shell/shell.c b/reactos/apps/utils/shell/shell.c index e69a0250e50..3a394c24586 100644 --- a/reactos/apps/utils/shell/shell.c +++ b/reactos/apps/utils/shell/shell.c @@ -46,10 +46,10 @@ void ExecuteDir(char* cmdline) debug_printf(" "),nRep++; else debug_printf(" %10d ",FindData.nFileSizeLow),nFile++; - RtlTimeToTimeFields(&FindData.ftLastWriteTime ,&fTime); - debug_printf("%02d/%02d/%04d %02d:%02d:%02d " - ,fTime.Month,fTime.Day,fTime.Year - ,fTime.Hour,fTime.Minute,fTime.Second); + // RtlTimeToTimeFields(&FindData.ftLastWriteTime ,&fTime); +// debug_printf("%02d/%02d/%04d %02d:%02d:%02d " +// ,fTime.Month,fTime.Day,fTime.Year +// ,fTime.Hour,fTime.Minute,fTime.Second); debug_printf("%s\n",FindData.cFileName); } while(FindNextFile(shandle,&FindData)); debug_printf("\n %d files\n %d directories\n\n",nFile,nRep); @@ -159,6 +159,11 @@ void ExecuteCommand(char* line) ExecuteType(tail); return; } + if (strcmp(cmd,"exit")==0) + { + ExitProcess(0); + return; + } if (ExecuteProcess(cmd,tail)) { return; diff --git a/reactos/boot.bat b/reactos/boot.bat index 8be33a7cf03..3119fbc6258 100644 --- a/reactos/boot.bat +++ b/reactos/boot.bat @@ -1 +1 @@ -loaders\dos\loadros ntoskrnl\kimage.bin services\dd\ide\ide.o services\fs\vfat\vfatfsd.o services\dd\keyboard\keyboard.o ext2fs.sys +loadros kimage.bin ide.o vfatfsd.o keyboard.o diff --git a/reactos/bootflop.bat b/reactos/bootflop.bat index 240b29ba039..15fb87835fe 100644 --- a/reactos/bootflop.bat +++ b/reactos/bootflop.bat @@ -3,9 +3,11 @@ : : copy files to HD... : -COPY /Y SHELL.BIN C:\reactos\system\SHELL.bin -COPY /Y BLUES.o C:\reactos\system\drivers\BLUES.o -COPY /Y KEYBOARD.o C:\reactos\system\drivers\KEYBOARD.o +COPY /Y BLUE.SYS C:\reactos\system\drivers\blue.SYS +COPY /Y KEYBOARD.SYS C:\reactos\system\drivers\KEYBOARD.SYS +COPY /Y NTDLL.DLL C:\reactos\system\NTDLL.DLL +: COPY /Y CRTDLL.DLL C:\reactos\system\CRTDLL.DLL +COPY /Y SHELL.EXE C:\reactos\system\SHELL.EXE : : present a menu to the booter... @@ -13,23 +15,23 @@ COPY /Y KEYBOARD.o C:\reactos\system\drivers\KEYBOARD.o ECHO 1) Keyboard,IDE,VFatFSD ECHO 2) IDE,VFatFSD ECHO 3) No Drivers -CHOICE /C:123 /T:2,10 "Select kernel boot config" +CHOICE /C:123 /T:2,3 "Select kernel boot config" IF ERRORLEVEL 3 GOTO :L3 IF ERRORLEVEL 2 GOTO :L2 :L1 CLS -LOADROS KIMAGE.BIN KEYBOARD.O IDE.O VFATFSD.O +LOADROS NTOSKRNL.EXE KEYBOARD.O IDE.SYS VFATFSD.SYS GOTO :END :L2 CLS -LOADROS KIMAGE.BIN IDE.O VFATFSD.O +LOADROS NTOSKRNL.EXE IDE.SYS VFATFSD.SYS GOTO :END :L3 CLS -LOADROS KIMAGE.BIN +LOADROS NTOSKRNL.EXE GOTO :END :END diff --git a/reactos/drivers/dd/blue/.cvsignore b/reactos/drivers/dd/blue/.cvsignore new file mode 100644 index 00000000000..ab5be07adb4 --- /dev/null +++ b/reactos/drivers/dd/blue/.cvsignore @@ -0,0 +1,4 @@ +base.tmp +junk.tmp +temp.exp + diff --git a/reactos/drivers/dd/blue/blues.c b/reactos/drivers/dd/blue/blue.c similarity index 97% rename from reactos/drivers/dd/blue/blues.c rename to reactos/drivers/dd/blue/blue.c index 7103cd2d149..b7d25ad4cfe 100644 --- a/reactos/drivers/dd/blue/blues.c +++ b/reactos/drivers/dd/blue/blue.c @@ -1,8 +1,8 @@ -#undef WIN32_LEAN_AND_MEAN #include #include #include +#include #include #include @@ -79,7 +79,8 @@ NTSTATUS ScrDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp) /* * Module entry point */ -NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) +STDCALL NTSTATUS +DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) { PDEVICE_OBJECT DeviceObject; ANSI_STRING adevice_name; diff --git a/reactos/drivers/dd/blue/makefile b/reactos/drivers/dd/blue/makefile new file mode 100644 index 00000000000..a708b400456 --- /dev/null +++ b/reactos/drivers/dd/blue/makefile @@ -0,0 +1,23 @@ +# +# +# + +all: blue.sys + +.phony: all + +OBJECTS = blue.o ../../../ntoskrnl/ntoskrnl.a + +blue.sys: $(OBJECTS) + $(CC) -specs=../../svc_specs -mdll -o junk.tmp -Wl,--defsym,_end=end \ + -Wl,--defsym,_edata=__data_end__ -Wl,--defsym,_etext=etext \ + -Wl,--base-file,base.tmp $(OBJECTS) + - $(RM) junk.tmp + $(DLLTOOL) --dllname blue.sys --base-file base.tmp \ + --output-exp temp.exp + - $(RM) base.tmp + $(CC) --verbose -Wl,--image-base,0x10000 -Wl,-e,_DriverEntry@8 \ + -specs=../../svc_specs -mdll -o blue.sys $(OBJECTS) -Wl,temp.exp + - $(RM) temp.exp + + diff --git a/reactos/drivers/dd/event/exe/eventtes.c b/reactos/drivers/dd/event/exe/eventtes.c index 8086ead4e7e..a8926a9ddaf 100644 --- a/reactos/drivers/dd/event/exe/eventtes.c +++ b/reactos/drivers/dd/event/exe/eventtes.c @@ -165,4 +165,4 @@ main( } -// EOF \ No newline at end of file +// EOF diff --git a/reactos/drivers/dd/event/sys/event.c b/reactos/drivers/dd/event/sys/event.c index e9298e703fb..bac8b154e43 100644 --- a/reactos/drivers/dd/event/sys/event.c +++ b/reactos/drivers/dd/event/sys/event.c @@ -444,4 +444,4 @@ Return Value: } -// EOF \ No newline at end of file +// EOF diff --git a/reactos/drivers/dd/ide/.cvsignore b/reactos/drivers/dd/ide/.cvsignore new file mode 100644 index 00000000000..2e5d5e24473 --- /dev/null +++ b/reactos/drivers/dd/ide/.cvsignore @@ -0,0 +1,3 @@ +base.tmp +junk.tmp +temp.exp diff --git a/reactos/drivers/dd/ide/ide.c b/reactos/drivers/dd/ide/ide.c index ec7fff6326c..7fa4c03601d 100644 --- a/reactos/drivers/dd/ide/ide.c +++ b/reactos/drivers/dd/ide/ide.c @@ -72,6 +72,7 @@ typedef DISK_GEOMETRY *PDISK_GEOMETRY; // ------------------------------------------------------------------------- #include +#include #include #define NDEBUG @@ -230,7 +231,7 @@ IDESwapBytePairs(char *Buf, // RETURNS: // NTSTATUS -NTSTATUS +STDCALL NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath) { diff --git a/reactos/drivers/dd/ide/makefile b/reactos/drivers/dd/ide/makefile index 60e982b5e77..36a6d0093f0 100644 --- a/reactos/drivers/dd/ide/makefile +++ b/reactos/drivers/dd/ide/makefile @@ -1,9 +1,16 @@ -# -# -# +all: ide.sys -all: ide.o +OBJECTS = ide.o ../../../ntoskrnl/ntoskrnl.a -ide.o: ide.c ide.h idep.h partitio.h - -include ../../../rules.mak +# --def ide.def --def ide.def +ide.sys: $(OBJECTS) + $(DLLTOOL) --dllname ide.sys --output-lib ide.a + $(CC) -specs=../../svc_specs -mdll -o junk.tmp -Wl,--defsym,_end=end \ + -Wl,--defsym,_edata=__data_end__ -Wl,--defsym,_etext=etext \ + -Wl,--base-file,base.tmp $(OBJECTS) + - $(RM) junk.tmp + $(DLLTOOL) --dllname ide.sys --base-file base.tmp \ + --output-exp temp.exp + - $(RM) base.tmp + $(CC) --verbose -Wl,--image-base,0x10000 -Wl,-e,_DriverEntry@8 -specs=../../svc_specs -mdll -o ide.sys $(OBJECTS) -Wl,temp.exp + - $(RM) temp.exp diff --git a/reactos/drivers/dd/ide/partitio.h b/reactos/drivers/dd/ide/partitio.h index 14eaf49426d..6d0f39ea788 100644 --- a/reactos/drivers/dd/ide/partitio.h +++ b/reactos/drivers/dd/ide/partitio.h @@ -75,14 +75,14 @@ typedef enum PartitionTypes { ((P)->PartitionType == PTDosExtended) typedef struct Partition { - __u8 BootFlags; - __u8 StartingHead; - __u8 StartingSector; - __u8 StartingCylinder; - __u8 PartitionType; - __u8 EndingHead; - __u8 EndingSector; - __u8 EndingCylinder; + unsigned char BootFlags; + unsigned char StartingHead; + unsigned char StartingSector; + unsigned char StartingCylinder; + unsigned char PartitionType; + unsigned char EndingHead; + unsigned char EndingSector; + unsigned char EndingCylinder; unsigned int StartingBlock; unsigned int SectorCount; diff --git a/reactos/drivers/dd/keyboard/.cvsignore b/reactos/drivers/dd/keyboard/.cvsignore new file mode 100644 index 00000000000..ab5be07adb4 --- /dev/null +++ b/reactos/drivers/dd/keyboard/.cvsignore @@ -0,0 +1,4 @@ +base.tmp +junk.tmp +temp.exp + diff --git a/reactos/drivers/dd/keyboard/keyboard.c b/reactos/drivers/dd/keyboard/keyboard.c index b2654d505d3..c3ea0721e3b 100644 --- a/reactos/drivers/dd/keyboard/keyboard.c +++ b/reactos/drivers/dd/keyboard/keyboard.c @@ -20,10 +20,10 @@ ** */ -#undef WIN32_LEAN_AND_MEAN #include #include #include +#include #include #include @@ -689,7 +689,8 @@ NTSTATUS KbdDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp) /* * Module entry point */ -NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) +STDCALL NTSTATUS +DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) { PDEVICE_OBJECT DeviceObject; ANSI_STRING adevice_name; diff --git a/reactos/drivers/dd/keyboard/makefile b/reactos/drivers/dd/keyboard/makefile index 77cf518f207..a1583c87dbf 100644 --- a/reactos/drivers/dd/keyboard/makefile +++ b/reactos/drivers/dd/keyboard/makefile @@ -1 +1,15 @@ -all: keyboard.o +all: keyboard.sys + +OBJECTS = keyboard.o ../../../ntoskrnl/ntoskrnl.a + +keyboard.sys: $(OBJECTS) + $(CC) -specs=../../svc_specs -mdll -o junk.tmp -Wl,--defsym,_end=end \ + -Wl,--defsym,_edata=__data_end__ -Wl,--defsym,_etext=etext \ + -Wl,--base-file,base.tmp $(OBJECTS) + - $(RM) junk.tmp + $(DLLTOOL) --dllname keyboard.sys --base-file base.tmp \ + --output-exp temp.exp + - $(RM) base.tmp + $(CC) --verbose -Wl,--image-base,0x10000 -Wl,-e,_DriverEntry@8 \ + -specs=../../svc_specs -mdll -o keyboard.sys $(OBJECTS) -Wl,temp.exp + - $(RM) temp.exp diff --git a/reactos/drivers/dd/sound/dsp.c b/reactos/drivers/dd/sound/dsp.c index e318a59d29c..c67252a1f60 100644 --- a/reactos/drivers/dd/sound/dsp.c +++ b/reactos/drivers/dd/sound/dsp.c @@ -58,4 +58,4 @@ void write_dsp(unsigned short base,unsigned char data) while ((inb(base+DSP_WRITE_PORT) & 0x80) != 0); outb(base+DSP_WRITE_PORT, data); } - \ No newline at end of file + diff --git a/reactos/drivers/dd/sound/mixer.c b/reactos/drivers/dd/sound/mixer.c index 0be3de4135f..83b331c1f67 100644 --- a/reactos/drivers/dd/sound/mixer.c +++ b/reactos/drivers/dd/sound/mixer.c @@ -29,4 +29,4 @@ void get_dma(SB16* sb16) if(lo==0x08) sb16->dma8=3; if(lo==0x02) sb16->dma8=1; if(lo==0x01) sb16->dma8=0; -} \ No newline at end of file +} diff --git a/reactos/drivers/dd/sound/sb16.h b/reactos/drivers/dd/sound/sb16.h index cbe6704fe93..822f2d8004c 100644 --- a/reactos/drivers/dd/sound/sb16.h +++ b/reactos/drivers/dd/sound/sb16.h @@ -6,4 +6,4 @@ typedef struct unsigned char dma16; unsigned char* buffer; }SB16; - \ No newline at end of file + diff --git a/reactos/drivers/dd/sound/sb_waveout.c b/reactos/drivers/dd/sound/sb_waveout.c index eeb523d69d9..826145e79c9 100644 --- a/reactos/drivers/dd/sound/sb_waveout.c +++ b/reactos/drivers/dd/sound/sb_waveout.c @@ -1,3 +1,3 @@ void write_wave() { -} \ No newline at end of file +} diff --git a/reactos/drivers/dd/sound/sound.c b/reactos/drivers/dd/sound/sound.c index 6feffc84e19..cf5befa44bc 100644 --- a/reactos/drivers/dd/sound/sound.c +++ b/reactos/drivers/dd/sound/sound.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include "sb16.h" diff --git a/reactos/drivers/dd/sound/wave.c b/reactos/drivers/dd/sound/wave.c new file mode 100644 index 00000000000..0349be74fd2 --- /dev/null +++ b/reactos/drivers/dd/sound/wave.c @@ -0,0 +1,126 @@ +ULONG OldIRQ; +PKINTERRUPT IrqObject; +BOOLEAN DMAOutputISR(PKINTERRUPT Interrupt, PVOID ServiceContext) +{ + printk("interrupt\n"); + return FALSE; +} + +void sb16_play(WAVE_HDR* wave) +{ + unsigned int eflags; + ULONG MappedIrq; + KIRQL Dirql; + KAFFINITY Affinity; + PKINTERRUPT IrqObject; + unsigned int mask,newmask; + + unsigned int i; + unsigned int tmp[255]; + i=0; + dump_wav(wave); + do + { + tmp[i++]=get_dma_page(0x0fffff+IDMAP_BASE); + printk("0x%x ",tmp[i-1]); + } + while((tmp[i-1]&0xffff)!=0); + free_page((tmp[0])-IDMAP_BASE,i-1); + sb16.buffer=((unsigned char*)tmp[i-1]); + + /* + * Because this is used by alomost every subsystem including irqs it + * must be atomic. The following code sequence disables interrupts after + * saving the previous state of the interrupt flag + */ + + __asm__("pushf\n\tpop %0\n\tcli\n\t" + : "=m" (eflags) + : ); + + memcpy(sb16.buffer,(&wave->data),wave->dLen); + + + MappedIrq = HalGetInterruptVector(Internal,0,0,8+sb16.irq,&Dirql,&Affinity); + + + + IoConnectInterrupt(&IrqObject,DMAOutputISR,0,NULL,MappedIrq,Dirql,Dirql,0,FALSE,Affinity,FALSE); + + mask=inb(0x21); + newmask=((int)1<dLen); + set_dma_mode(1,DMA_MODE_WRITE); + //outb(0xb,0x49); + //outb(0x3,(wave->dLen)&0xff); + //outb(0x3,((unsigned int)(wave->dLen)>>8)&0xff); + set_dma_addr(sb16.dma8,(unsigned int)sb16.buffer-IDMAP_BASE); + //outb(0x83,(((unsigned int)(sb16.buffer-IDMAP_BASE)>>16))&0xf); + //outb(0x2,((unsigned int)sb16.buffer&0xff)); + //outb(0x2,(((unsigned int)(sb16.buffer-IDMAP_BASE)>>8))&0xff); + enable_dma(sb16.dma8); + //outb(0xa,1); + + write_dsp(sb16.base,0x00D1); + + write_dsp(sb16.base,0x40); + write_dsp(sb16.base,((unsigned char)256-(1000000/wave->nSamplesPerSec))); + + outb(sb16.base + 4, (int) 0xa); + outb(sb16.base + 5, (int) 0x00); + + outb(sb16.base + 4, (int) 4); + outb(sb16.base + 5, (int) 0xFF); + + outb(sb16.base + 4, (int) 0x22); + outb(sb16.base + 5, (int) 0xFF); + + write_dsp(sb16.base,0x14); + write_dsp(sb16.base,(wave->dLen&0x00ff)); + write_dsp(sb16.base,((wave->dLen)&0xff00)>>8); + +// write_dsp(sb16.base,0xc0); +// write_dsp(sb16.base,0x0); +// OldIRQ=HalGetInterruptVector(Internal,0,0,irq+8,&irql,&affinity); +// printk("OldIRQ: 0x%x\n",OldIRQ); + +// status=IoConnectInterrupt(&IrqObject,playRoutine,0,NULL,OldIRQ,irql,irql,0,FALSE,affinity,FALSE); +// if(status!=STATUS_SUCCESS) printk("Couldn't set irq\n"); +// else printk("IRQ set\n"); + +} + +void dump_wav(WAVE_HDR* wave) +{ + printk("wave.rID: %c%c%c%c\n",wave->rID[0],wave->rID[1],wave->rID[2],wave->rID[3]); + printk("wave.rLen: 0x%x\n",wave->rLen); + printk("wave.wID: %c%c%c%c\n",wave->wID[0],wave->wID[1],wave->wID[2],wave->wID[3]); + printk("wave.fID: %c%c%c%c\n",wave->fID[0],wave->fID[1],wave->fID[2],wave->fID[3]); + printk("wave.fLen: 0x%x\n",wave->fLen); + printk("wave.wFormatTag: 0x%x\n",wave->wFormatTag); + printk("wave.nChannels: 0x%x\n",wave->nChannels); + printk("wave.nSamplesPerSec: 0x%x\n",wave->nSamplesPerSec); + printk("wave.nAvgBytesPerSec: 0x%x\n",wave->nAvgBytesPerSec); + printk("wave.nBlockAlign: 0x%x\n",wave->nBlockAlign); + printk("wave.FormatSpecific: 0x%x\n",wave->FormatSpecific); + printk("wave.dID: %c%c%c%c\n",wave->dID[0],wave->dID[1],wave->dID[2],wave->dID[3]); + printk("wave.dLen: 0x%x\n",wave->dLen); +} + +BOOLEAN playRoutine(PKINTERRUPT Interrupt,PVOID ServiceContext) +{ + return FALSE; +} diff --git a/reactos/drivers/dd/sound/wave.h b/reactos/drivers/dd/sound/wave.h index 7b1ca7afc8e..e17ddf70aa5 100644 --- a/reactos/drivers/dd/sound/wave.h +++ b/reactos/drivers/dd/sound/wave.h @@ -21,4 +21,4 @@ typedef struct void sb16_play(WAVE_HDR* wave); void dump_wav(WAVE_HDR* wave); -BOOLEAN playRoutine(PKINTERRUPT Interrupt,PVOID ServiceContext); \ No newline at end of file +BOOLEAN playRoutine(PKINTERRUPT Interrupt,PVOID ServiceContext); diff --git a/reactos/drivers/dd/test/.cvsignore b/reactos/drivers/dd/test/.cvsignore new file mode 100644 index 00000000000..ab5be07adb4 --- /dev/null +++ b/reactos/drivers/dd/test/.cvsignore @@ -0,0 +1,4 @@ +base.tmp +junk.tmp +temp.exp + diff --git a/reactos/drivers/dd/test/makefile b/reactos/drivers/dd/test/makefile index 20523bea608..7d91270a560 100644 --- a/reactos/drivers/dd/test/makefile +++ b/reactos/drivers/dd/test/makefile @@ -1 +1,16 @@ -all: test.o +all: test.sys + +OBJECTS = test.o ../../../ntoskrnl/ntoskrnl.a + +# --def test.def --def test.def +test.sys: test.o + $(DLLTOOL) --dllname test.sys --output-lib test.a + $(CC) -specs=$(KM_SPECS) -mdll -o junk.tmp -Wl,--defsym,_end=end \ + -Wl,--defsym,_edata=__data_end__ -Wl,--defsym,_etext=etext \ + -Wl,--base-file,base.tmp $(OBJECTS) + - $(RM) junk.tmp + $(DLLTOOL) --dllname test.sys --base-file base.tmp \ + --output-exp temp.exp + - $(RM) base.tmp + $(CC) --verbose -Wl,--image-base,0x10000 -Wl,-e,_DriverEntry -specs=$(KM_SPECS) -mdll -o test.sys $(OBJECTS) -Wl,temp.exp + - $(RM) temp.exp diff --git a/reactos/drivers/dd/test/test.c b/reactos/drivers/dd/test/test.c index 5eda21532fd..85398a1af29 100644 --- a/reactos/drivers/dd/test/test.c +++ b/reactos/drivers/dd/test/test.c @@ -15,12 +15,14 @@ /* FUNCTIONS **************************************************************/ +#if 0 + NTSTATUS TestWrite(PIRP Irp, PIO_STACK_LOCATION Stk) { PVOID Address; Address = MmGetSystemAddressForMdl(Irp->MdlAddress); - printk("Asked to write '%s'\n",(PCH)Address); + DbgPrint("Asked to write '%s'\n",(PCH)Address); return(STATUS_SUCCESS); } @@ -40,7 +42,7 @@ NTSTATUS TestDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp) switch (Stack->MajorFunction) { case IRP_MJ_CREATE: - printk("(Test Driver) Creating\n"); + DbgPrint("(Test Driver) Creating\n"); status = STATUS_SUCCESS; break; @@ -49,7 +51,7 @@ NTSTATUS TestDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp) break; case IRP_MJ_WRITE: - printk("(Test Driver) Writing\n"); + DbgPrint("(Test Driver) Writing\n"); status = TestWrite(Irp,Stack); break; @@ -65,6 +67,8 @@ NTSTATUS TestDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp) return(status); } +#endif + NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) /* * FUNCTION: Called by the system to initalize the driver @@ -79,8 +83,9 @@ NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) ANSI_STRING astr; UNICODE_STRING ustr; - printk("Test Driver 0.0.1\n"); - + DbgPrint("Test Driver 0.0.1\n"); + + #if 0 RtlInitAnsiString(&astr,"\\Device\\Test"); RtlAnsiStringToUnicodeString(&ustr,&astr,TRUE); ret = IoCreateDevice(DriverObject,0,&ustr, @@ -96,7 +101,7 @@ NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) DriverObject->MajorFunction[IRP_MJ_WRITE] = TestDispatch; DriverObject->MajorFunction[IRP_MJ_WRITE] = TestDispatch; DriverObject->DriverUnload = NULL; - + #endif return(STATUS_SUCCESS); } diff --git a/reactos/drivers/fs/ext2/blockdev.c b/reactos/drivers/fs/ext2/blockdev.c index fe8e0f20a7c..1eba63fa213 100644 --- a/reactos/drivers/fs/ext2/blockdev.c +++ b/reactos/drivers/fs/ext2/blockdev.c @@ -10,6 +10,7 @@ /* INCLUDES *****************************************************************/ #include +#include #include #define NDEBUG diff --git a/reactos/drivers/fs/ext2/dir.c b/reactos/drivers/fs/ext2/dir.c index 50948cdae65..68485e50894 100644 --- a/reactos/drivers/fs/ext2/dir.c +++ b/reactos/drivers/fs/ext2/dir.c @@ -10,8 +10,8 @@ /* INCLUDES *****************************************************************/ #include +#include #include -#include #define NDEBUG #include diff --git a/reactos/drivers/fs/ext2/file.c b/reactos/drivers/fs/ext2/file.c index 0d6e0a9b399..7cdb4b2c3ca 100644 --- a/reactos/drivers/fs/ext2/file.c +++ b/reactos/drivers/fs/ext2/file.c @@ -10,8 +10,6 @@ /* INCLUDES *****************************************************************/ #include -#include -#include #define NDEBUG #include diff --git a/reactos/drivers/fs/ext2/makefile b/reactos/drivers/fs/ext2/makefile index e4ca51b50a2..243b13c7a1e 100644 --- a/reactos/drivers/fs/ext2/makefile +++ b/reactos/drivers/fs/ext2/makefile @@ -1,9 +1,16 @@ -OBJECTS = super.o blockdev.o inode.o file.o dir.o rw.o +all: ext2fs.sys -all: ext2.o - -ext2.o: $(OBJECTS) - $(LD) -r $(OBJECTS) -o ext2fs.sys - -include ../../../rules.mak +OBJECTS = super.o blockdev.o inode.o file.o dir.o rw.o \ + ../../../ntoskrnl/ntoskrnl.a +ext2fs.sys: $(OBJECTS) + $(CC) -specs=$(KM_SPECS) -mdll -o junk.tmp -Wl,--defsym,_end=end \ + -Wl,--defsym,_edata=__data_end__ -Wl,--defsym,_etext=etext \ + -Wl,--base-file,base.tmp $(OBJECTS) + $(RM) junk.tmp + $(DLLTOOL) --dllname ext2fs.sys --base-file base.tmp \ + --output-exp temp.exp + $(RM) base.tmp + $(CC) --verbose -Wl,--image-base,0x10000 -Wl,-e,_DriverEntry \ + -specs=$(KM_SPECS) -mdll -o ext2fs.sys $(OBJECTS) -Wl,temp.exp + $(RM) temp.exp diff --git a/reactos/drivers/fs/ext2/rw.c b/reactos/drivers/fs/ext2/rw.c index 51659963f03..da92da738e0 100644 --- a/reactos/drivers/fs/ext2/rw.c +++ b/reactos/drivers/fs/ext2/rw.c @@ -10,8 +10,6 @@ /* INCLUDES *****************************************************************/ #include -#include -#include #define NDEBUG #include diff --git a/reactos/drivers/fs/ext2/super.c b/reactos/drivers/fs/ext2/super.c index 81f13988a0b..8d23a756129 100644 --- a/reactos/drivers/fs/ext2/super.c +++ b/reactos/drivers/fs/ext2/super.c @@ -10,8 +10,8 @@ /* INCLUDES *****************************************************************/ #include +#include #include -#include #define NDEBUG #include diff --git a/reactos/drivers/fs/minix/block.c b/reactos/drivers/fs/minix/block.c index ba3670c472a..be9b222899a 100644 --- a/reactos/drivers/fs/minix/block.c +++ b/reactos/drivers/fs/minix/block.c @@ -10,8 +10,6 @@ /* INCLUDES *****************************************************************/ #include -#include -#include #define NDEBUG #include diff --git a/reactos/drivers/fs/minix/blockdev.c b/reactos/drivers/fs/minix/blockdev.c index 5eab09286e8..cf591efb7cf 100644 --- a/reactos/drivers/fs/minix/blockdev.c +++ b/reactos/drivers/fs/minix/blockdev.c @@ -10,6 +10,7 @@ /* INCLUDES *****************************************************************/ #include +#include #include #define NDEBUG diff --git a/reactos/drivers/fs/minix/dir.c b/reactos/drivers/fs/minix/dir.c index 902b826a1bb..c32ba3022f3 100644 --- a/reactos/drivers/fs/minix/dir.c +++ b/reactos/drivers/fs/minix/dir.c @@ -10,8 +10,6 @@ /* INCLUDES *****************************************************************/ #include -#include -#include #define NDEBUG #include diff --git a/reactos/drivers/fs/minix/inode.c b/reactos/drivers/fs/minix/inode.c index 11560e292bd..4ff5b7931cd 100644 --- a/reactos/drivers/fs/minix/inode.c +++ b/reactos/drivers/fs/minix/inode.c @@ -10,6 +10,7 @@ /* INCLUDES *****************************************************************/ #include +#include #include #include #include diff --git a/reactos/drivers/fs/minix/mount.c b/reactos/drivers/fs/minix/mount.c index 64f9e5f6069..32209665b2d 100644 --- a/reactos/drivers/fs/minix/mount.c +++ b/reactos/drivers/fs/minix/mount.c @@ -11,8 +11,6 @@ #include #include -#include -#include #define NDEBUG #include diff --git a/reactos/drivers/fs/minix/rw.c b/reactos/drivers/fs/minix/rw.c index bdb987151f7..df5b317fca1 100644 --- a/reactos/drivers/fs/minix/rw.c +++ b/reactos/drivers/fs/minix/rw.c @@ -10,8 +10,6 @@ /* INCLUDES *****************************************************************/ #include -#include -#include #define NDEBUG #include diff --git a/reactos/drivers/fs/vfat/.cvsignore b/reactos/drivers/fs/vfat/.cvsignore new file mode 100644 index 00000000000..ab5be07adb4 --- /dev/null +++ b/reactos/drivers/fs/vfat/.cvsignore @@ -0,0 +1,4 @@ +base.tmp +junk.tmp +temp.exp + diff --git a/reactos/drivers/fs/vfat/blockdev.c b/reactos/drivers/fs/vfat/blockdev.c index 6db8d240b4f..d468372b819 100644 --- a/reactos/drivers/fs/vfat/blockdev.c +++ b/reactos/drivers/fs/vfat/blockdev.c @@ -10,8 +10,6 @@ /* INCLUDES *****************************************************************/ #include -#include -#include #define NDEBUG #include diff --git a/reactos/drivers/fs/vfat/dir.c b/reactos/drivers/fs/vfat/dir.c index bef9703e644..da0a384a0fd 100644 --- a/reactos/drivers/fs/vfat/dir.c +++ b/reactos/drivers/fs/vfat/dir.c @@ -7,9 +7,10 @@ 19-12-1998 : created */ -#include + +#include #include -#include +#include #include #include @@ -36,7 +37,7 @@ BOOL fsdDosDateTimeToFileTime(WORD wDosDate,WORD wDosTime, TIME *FileTime) long long int mult; Day=wDosDate&0x001f; Month= (wDosDate&0x00e0)>>5;//1=January - Year= ((wDosDate&0xfe00)>>9)+1980; + Year= ((wDosDate&0xff00)>>8)+1980; Second=(wDosTime&0x001f)<<1; Minute=(wDosTime&0x07e0)>>5; Hour= (wDosTime&0xf100)>>11; @@ -49,13 +50,13 @@ BOOL fsdDosDateTimeToFileTime(WORD wDosDate,WORD wDosTime, TIME *FileTime) mult *=24; *pTime +=(Day-1)*mult; if((Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) ? 1 : 0)) - *pTime += MonthsDF1[1][Month-1]*mult; + *pTime += MonthsDF1[1][Month-1]; else - *pTime += MonthsDF1[0][Month-1]*mult; - *pTime +=((Year-1601)*365 + *pTime += MonthsDF1[0][Month-1]; + *pTime +=(Year-1601)*mult*365 +(Year-1601)/4 -(Year-1601)/100 - +(Year-1601)/400)*mult; + +(Year-1601)/400; return TRUE; } #define DosDateTimeToFileTime fsdDosDateTimeToFileTime @@ -215,7 +216,7 @@ NTSTATUS DoQuery(PDEVICE_OBJECT DeviceObject, PIRP Irp,PIO_STACK_LOCATION Stack) PVfatCCB pCcb; PDEVICE_EXTENSION DeviceExt; WCHAR star[5],*pCharPattern; - unsigned long OldEntry; + unsigned long OldEntry,OldSector; DeviceExt = DeviceObject->DeviceExtension; // Obtain the callers parameters BufferLength = Stack->Parameters.QueryDirectory.Length; @@ -227,7 +228,7 @@ NTSTATUS DoQuery(PDEVICE_OBJECT DeviceObject, PIRP Irp,PIO_STACK_LOCATION Stack) pFcb = pCcb->pFcb; if(Stack->Flags & SL_RESTART_SCAN) {//FIXME : what is really use of RestartScan ? - pCcb->StartEntry=0; + pCcb->StartEntry=pCcb->StartSector=0; } // determine Buffer for result : if (Irp->MdlAddress) @@ -245,12 +246,12 @@ NTSTATUS DoQuery(PDEVICE_OBJECT DeviceObject, PIRP Irp,PIO_STACK_LOCATION Stack) tmpFcb.ObjectName=tmpFcb.PathName; while(RC==STATUS_SUCCESS && BufferLength >0) { + OldSector=pCcb->StartSector; OldEntry=pCcb->StartEntry; -CHECKPOINT; - RC=FindFile(DeviceExt,&tmpFcb,pFcb,pCharPattern,&pCcb->StartEntry); -DPRINT("Found %w,RC=%x,entry %x\n",tmpFcb.ObjectName,RC - ,pCcb->StartEntry); - pCcb->StartEntry++; + if(OldSector)pCcb->StartEntry++; + RC=FindFile(DeviceExt,&tmpFcb,pFcb,pCharPattern,&pCcb->StartSector,&pCcb->StartEntry); +DPRINT("Found %w,RC=%x, sector %x entry %x\n",tmpFcb.ObjectName,RC + ,pCcb->StartSector,pCcb->StartEntry); if (NT_SUCCESS(RC)) { switch(FileInformationClass) @@ -283,6 +284,7 @@ DPRINT("Found %w,RC=%x,entry %x\n",tmpFcb.ObjectName,RC if(RC==STATUS_BUFFER_OVERFLOW) { if(Buffer0) Buffer0->NextEntryOffset=0; + pCcb->StartSector=OldSector; pCcb->StartEntry=OldEntry; break; } diff --git a/reactos/drivers/fs/vfat/dirwr.c b/reactos/drivers/fs/vfat/dirwr.c index de50ecd46a2..4bbbec20a74 100644 --- a/reactos/drivers/fs/vfat/dirwr.c +++ b/reactos/drivers/fs/vfat/dirwr.c @@ -8,10 +8,10 @@ /* INCLUDES *****************************************************************/ -#include +#include +#include #include -#include -#include +#include #include #define NDEBUG @@ -19,22 +19,23 @@ #include "vfat.h" - -NTSTATUS updEntry(PDEVICE_EXTENSION DeviceExt,PVfatFCB pFcb) +NTSTATUS updEntry(PDEVICE_EXTENSION DeviceExt,PFILE_OBJECT pFileObject) /* update an existing FAT entry */ { WCHAR DirName[MAX_PATH],*FileName,*PathFileName; VfatFCB FileFcb; - ULONG Entry=0; + ULONG Sector=0,Entry=0; + PUCHAR Buffer; + FATDirEntry * pEntries; NTSTATUS status; FILE_OBJECT FileObject; PVfatCCB pDirCcb; - PVfatFCB pDirFcb; + PVfatFCB pDirFcb,pFcb; short i,posCar,NameLen; - CHECKPOINT; - PathFileName=pFcb->PathName; + PathFileName=pFileObject->FileName.Buffer; + pFcb=((PVfatCCB)pFileObject->FsContext2)->pFcb; //find last \ in PathFileName posCar=-1; for(i=0;PathFileName[i];i++) @@ -49,8 +50,6 @@ NTSTATUS updEntry(PDEVICE_EXTENSION DeviceExt,PVfatFCB pFcb) if(FileName[0]==0 && DirName[0]==0) return STATUS_SUCCESS;//root : nothing to do ? memset(&FileObject,0,sizeof(FILE_OBJECT)); - FileObject.FileName.Buffer=DirName; - FileObject.FileName.Length=posCar; DPRINT("open directory %w for update of entry %w\n",DirName,FileName); status=FsdOpenFile(DeviceExt,&FileObject,DirName); pDirCcb=(PVfatCCB)FileObject.FsContext2; @@ -58,15 +57,18 @@ DPRINT("open directory %w for update of entry %w\n",DirName,FileName); pDirFcb=pDirCcb->pFcb; assert(pDirFcb); FileFcb.ObjectName=&FileFcb.PathName[0]; - status=FindFile(DeviceExt,&FileFcb,pDirFcb,FileName,&Entry); + status=FindFile(DeviceExt,&FileFcb,pDirFcb,FileName,&Sector,&Entry); if(NT_SUCCESS(status)) { - DPRINT("update entry: entry %d\n",Entry); - status=FsdWriteFile(DeviceExt,pDirFcb,&pFcb->entry,sizeof(FATDirEntry) - ,Entry*sizeof(FATDirEntry)); + Buffer=ExAllocatePool(NonPagedPool,BLOCKSIZE); + DPRINT("update entry: sector %d, entry %d\n",Sector,Entry); + VFATReadSectors(DeviceExt->StorageDevice,Sector,1,Buffer); + pEntries=(FATDirEntry *)Buffer; + memcpy(&pEntries[Entry],&pFcb->entry,sizeof(FATDirEntry)); + VFATWriteSectors(DeviceExt->StorageDevice,Sector,1,Buffer); + ExFreePool(Buffer); } FsdCloseFile(DeviceExt,&FileObject); - CHECKPOINT; return status; } @@ -85,13 +87,11 @@ NTSTATUS addEntry(PDEVICE_EXTENSION DeviceExt slot *pSlots; ULONG LengthRead,Offset; short nbSlots=0,nbFree=0,i,j,posCar,NameLen; - PUCHAR Buffer; + PUCHAR Buffer,Buffer2; BOOLEAN needTilde=FALSE,needLong=FALSE; - PVfatFCB newFCB,pDirFCB; - PVfatCCB newCCB,pDirCCB; + PVfatFCB newFCB; + PVfatCCB newCCB; ULONG CurrentCluster; - TIME_FIELDS RTCTime; - CHECKPOINT; PathFileName=pFileObject->FileName.Buffer; DPRINT("addEntry: Pathname=%w\n",PathFileName); //find last \ in PathFileName @@ -108,8 +108,6 @@ NTSTATUS addEntry(PDEVICE_EXTENSION DeviceExt // open parent directory memset(&FileObject,0,sizeof(FILE_OBJECT)); status=FsdOpenFile(DeviceExt,&FileObject,DirName); - pDirCCB=FileObject.FsContext2; - pDirFCB=pDirCCB->pFcb; nbSlots=(NameLen+12)/13+1;//nb of entry needed for long name+normal entry DPRINT("NameLen= %d, nbSlots =%d\n",NameLen,nbSlots); Buffer=ExAllocatePool(NonPagedPool,(nbSlots+1)*sizeof(FATDirEntry)); @@ -128,6 +126,7 @@ NTSTATUS addEntry(PDEVICE_EXTENSION DeviceExt memset(pEntry,' ',11); for(i=0,j=0;j<8 && iFilename[7]='0'+i; status=FindFile(DeviceExt,&FileFcb - ,&DirFcb,DirName,NULL); + ,&DirFcb,DirName,NULL,NULL); if(status!=STATUS_SUCCESS)break; } //try second with xxxxx~yy.zzz @@ -180,7 +179,7 @@ NTSTATUS addEntry(PDEVICE_EXTENSION DeviceExt DirName[7]='0'+i; pEntry->Filename[7]='0'+i; status=FindFile(DeviceExt,&FileFcb - ,&DirFcb,DirName,NULL); + ,&DirFcb,DirName,NULL,NULL); if(status!=STATUS_SUCCESS)break; } } @@ -225,19 +224,13 @@ DPRINT("i=%d,j=%d,%d,%d\n",i,j,pEntry->Filename[i],FileName[i]); DirName[NameLen]=0; } DPRINT("dos name=%11.11s\n",pEntry->Filename); - // set attributes, dates, times + //FIXME : set attributes, dates, times pEntry->Attrib=ReqAttr; if(RequestedOptions&FILE_DIRECTORY_FILE) pEntry->Attrib |= FILE_ATTRIBUTE_DIRECTORY; - HalQueryRealTimeClock(&RTCTime); - pEntry->CreationTime - = (RTCTime.Second>>1)+(RTCTime.Minute<<5)+(RTCTime.Hour<<11); - pEntry->CreationDate - = RTCTime.Day+(RTCTime.Month<<5)+((RTCTime.Year-1980)<<9); - pEntry->UpdateDate=pEntry->CreationDate; - pEntry->UpdateTime=pEntry->CreationTime; - pEntry->AccessDate=pEntry->CreationDate; + pEntry->CreationDate=0x21; + pEntry->UpdateDate=0x21; // calculate checksum for 8.3 name for(pSlots[0].alias_checksum=i=0;i<11;i++) { @@ -256,28 +249,33 @@ DPRINT("i=%d,j=%d,%d,%d\n",i,j,pEntry->Filename[i],FileName[i]); pSlots[i].id=nbSlots-i-1+0x40; pSlots[i].alias_checksum=pSlots[0].alias_checksum; //FIXME pSlots[i].start=; - memcpy(pSlots[i].name0_4 ,DirName+(nbSlots-i-2)*13 + memcpy(pSlots[i].name0_4 ,FileName+(nbSlots-i-2)*13 ,5*sizeof(WCHAR)); - memcpy(pSlots[i].name5_10 ,DirName+(nbSlots-i-2)*13+5 + memcpy(pSlots[i].name5_10 ,FileName+(nbSlots-i-2)*13+5 ,6*sizeof(WCHAR)); - memcpy(pSlots[i].name11_12,DirName+(nbSlots-i-2)*13+11 + memcpy(pSlots[i].name11_12,FileName+(nbSlots-i-2)*13+11 ,2*sizeof(WCHAR)); } //try to find nbSlots contiguous entries frees in directory for(i=0,status=STATUS_SUCCESS;status==STATUS_SUCCESS;i++) { - status=FsdReadFile(DeviceExt,pDirFCB,&FatEntry + status=FsdReadFile(DeviceExt,&FileObject,&FatEntry ,sizeof(FATDirEntry),i*sizeof(FATDirEntry),&LengthRead); - if(IsLastEntry(&FatEntry)) + if(IsLastEntry(&FatEntry,0)) break; - if(IsDeletedEntry(&FatEntry)) nbFree++; + if(IsDeletedEntry(&FatEntry,0)) nbFree++; else nbFree=0; if (nbFree==nbSlots) break; } DPRINT("NbFree %d, entry number %d\n",nbFree,i); if(RequestedOptions&FILE_DIRECTORY_FILE) - { // directory has always a first cluster + { CurrentCluster=GetNextWriteCluster(DeviceExt,0); + // zero the cluster + Buffer2=ExAllocatePool(NonPagedPool,DeviceExt->BytesPerCluster); + memset(Buffer2,0,DeviceExt->BytesPerCluster); + VFATWriteCluster(DeviceExt,Buffer2,CurrentCluster); + ExFreePool(Buffer2); if (DeviceExt->FatType == FAT32) { pEntry->FirstClusterHigh=CurrentCluster>>16; @@ -289,13 +287,13 @@ DPRINT("i=%d,j=%d,%d,%d\n",i,j,pEntry->Filename[i],FileName[i]); if(nbFree==nbSlots) {//use old slots Offset=(i-nbSlots+1)*sizeof(FATDirEntry); - status=FsdWriteFile(DeviceExt,pDirFCB,Buffer + status=FsdWriteFile(DeviceExt,&FileObject,Buffer ,sizeof(FATDirEntry)*nbSlots,Offset); } else {//write at end of directory Offset=(i-nbFree)*sizeof(FATDirEntry); - status=FsdWriteFile(DeviceExt,pDirFCB,Buffer + status=FsdWriteFile(DeviceExt,&FileObject,Buffer ,sizeof(FATDirEntry)*(nbSlots+1),Offset); } DPRINT("write entry offset %d status=%x\n",Offset,status); @@ -307,13 +305,10 @@ DPRINT("i=%d,j=%d,%d,%d\n",i,j,pEntry->Filename[i],FileName[i]); newCCB->PtrFileObject=pFileObject; newFCB->RefCount++; //FIXME : initialize all fields in FCB and CCB - newFCB->Buffer=ExAllocatePool(NonPagedPool,DeviceExt->BytesPerCluster); - newFCB->Cluster=0xFFFFFFFF; - newFCB->Flags=0; + newFCB->nextFcb=pFirstFcb; memcpy(&newFCB->entry,pEntry,sizeof(FATDirEntry)); DPRINT("new : entry=%11.11s\n",newFCB->entry.Filename); DPRINT("new : entry=%11.11s\n",pEntry->Filename); - newFCB->nextFcb=pFirstFcb; pFirstFcb=newFCB; vfat_wcsncpy(newFCB->PathName,PathFileName,MAX_PATH); newFCB->ObjectName=newFCB->PathName+(PathFileName-FileName); @@ -324,7 +319,7 @@ DPRINT("new : entry=%11.11s\n",pEntry->Filename); { // create . and .. memcpy(pEntry->Filename,". ",11); - status=FsdWriteFile(DeviceExt,newFCB,pEntry + status=FsdWriteFile(DeviceExt,pFileObject,pEntry ,sizeof(FATDirEntry),0L); pEntry->FirstCluster =((VfatCCB *)(FileObject.FsContext2))->pFcb->entry.FirstCluster; @@ -333,7 +328,7 @@ DPRINT("new : entry=%11.11s\n",pEntry->Filename); memcpy(pEntry->Filename,".. ",11); if(pEntry->FirstCluster==1 && DeviceExt->FatType!=FAT32) pEntry->FirstCluster=0; - status=FsdWriteFile(DeviceExt,newFCB,pEntry + status=FsdWriteFile(DeviceExt,pFileObject,pEntry ,sizeof(FATDirEntry),sizeof(FATDirEntry)); } FsdCloseFile(DeviceExt,&FileObject); diff --git a/reactos/drivers/fs/vfat/iface.c b/reactos/drivers/fs/vfat/iface.c index b59ff1d9a14..8749dcfdaf5 100644 --- a/reactos/drivers/fs/vfat/iface.c +++ b/reactos/drivers/fs/vfat/iface.c @@ -1,4 +1,5 @@ + /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -22,9 +23,9 @@ /* INCLUDES *****************************************************************/ -#include +#include #include -#include +#include #include #define NDEBUG @@ -32,6 +33,7 @@ #include "vfat.h" +//#include "dbgpool.c" /* GLOBALS *****************************************************************/ @@ -73,6 +75,7 @@ ULONG Fat16GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) CurrentCluster = Block[CurrentCluster]; if (CurrentCluster >= 0xfff8 && CurrentCluster <= 0xffff) CurrentCluster = 0xffffffff; + DPRINT("Returning %x\n",CurrentCluster); return(CurrentCluster); } @@ -97,8 +100,10 @@ ULONG Fat12GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) Entry = (CBlock[FATOffset] >> 4); Entry |= (CBlock[FATOffset+1] << 4); } + DPRINT("Entry %x\n",Entry); if (Entry >= 0xff8 && Entry <= 0xfff) Entry = 0xffffffff; + DPRINT("Returning %x\n",Entry); return(Entry); } @@ -108,6 +113,8 @@ ULONG GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) */ { + DPRINT("GetNextCluster(DeviceExt %x, CurrentCluster %x)\n", + DeviceExt,CurrentCluster); if (DeviceExt->FatType == FAT16) return(Fat16GetNextCluster(DeviceExt, CurrentCluster)); else if (DeviceExt->FatType == FAT32) @@ -306,7 +313,9 @@ ULONG GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) */ { ULONG LastCluster, NewCluster; - UCHAR *Buffer2; + DPRINT("GetNextWriteCluster(DeviceExt %x, CurrentCluster %x)\n", + DeviceExt,CurrentCluster); + /* Find out what was happening in the last cluster's AU */ LastCluster=GetNextCluster(DeviceExt,CurrentCluster); /* Check to see if we must append or overwrite */ @@ -326,11 +335,6 @@ ULONG GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) found AU */ if(CurrentCluster) WriteCluster(DeviceExt, CurrentCluster, NewCluster); - // fill cluster with zero : essential for directories, not for file - Buffer2=ExAllocatePool(NonPagedPool,DeviceExt->BytesPerCluster); - memset(Buffer2,0,DeviceExt->BytesPerCluster); - VFATWriteCluster(DeviceExt,Buffer2,NewCluster); - ExFreePool(Buffer2); /* Return NewCluster as CurrentCluster */ return NewCluster; } @@ -432,7 +436,7 @@ wchar_t * vfat_wcsncpy(wchar_t * dest, const wchar_t *src,size_t wcount) return(dest); } -wchar_t * vfat_movstr(wchar_t *src, ULONG dpos, +wchar_t * vfat_movstr(const wchar_t *src, ULONG dpos, ULONG spos, ULONG len) /* * FUNCTION: Move the characters in a string to a new position in the same @@ -461,87 +465,109 @@ wchar_t * vfat_movstr(wchar_t *src, ULONG dpos, return(src); } -BOOLEAN IsLastEntry(FATDirEntry *pEntry) +BOOLEAN IsLastEntry(PVOID Block, ULONG Offset) /* * FUNCTION: Determine if the given directory entry is the last */ { - return(pEntry->Filename[0] == 0); + return(((FATDirEntry *)Block)[Offset].Filename[0] == 0); } -BOOLEAN IsVolEntry(FATDirEntry *pEntry) +BOOLEAN IsVolEntry(PVOID Block, ULONG Offset) /* * FUNCTION: Determine if the given directory entry is a vol entry */ { - if( (pEntry->Attrib)==0x28 ) return TRUE; + if( (((FATDirEntry *)Block)[Offset].Attrib)==0x28 ) return TRUE; else return FALSE; } -BOOLEAN IsDeletedEntry(FATDirEntry *pEntry) +BOOLEAN IsDeletedEntry(PVOID Block, ULONG Offset) /* * FUNCTION: Determines if the given entry is a deleted one */ { /* Checks special character */ - return (pEntry->Filename[0] == 0xe5); + + return ((((FATDirEntry *)Block)[Offset].Filename[0] == 0xe5)); } -BOOLEAN GetEntryName(PDEVICE_EXTENSION DeviceExt,PVfatFCB pFcb,PULONG pEntry - , PWSTR Name,FATDirEntry *pFatEntry) +BOOLEAN GetEntryName(PVOID Block, PULONG _Offset, PWSTR Name, PULONG _jloop, + PDEVICE_EXTENSION DeviceExt, ULONG * _StartingSector) /* * FUNCTION: Retrieves the file name, be it in short or long file name format */ { - slot* test2; - ULONG cpos,LengthRead; - NTSTATUS Status; + FATDirEntry* test; + slot* test2; + ULONG Offset = *_Offset; + ULONG StartingSector = *_StartingSector; + ULONG jloop = *_jloop; + ULONG cpos; + WCHAR tmp[256]; - test2 = (slot *)pFatEntry; + test = (FATDirEntry *)Block; + test2 = (slot *)Block; *Name = 0; - if (IsDeletedEntry(pFatEntry)) - { - return(FALSE); - } - - if(test2->attr == 0x0f) - { // long name : we read the long name, then we read the entry - vfat_initstr(Name, 256); - vfat_wcsncpy(Name,test2->name0_4,5); - vfat_wcsncat(Name,test2->name5_10,5,6); - vfat_wcsncat(Name,test2->name11_12,11,2); - - cpos=0; - while((test2->id!=0x41) && (test2->id!=0x01) && - (test2->attr>0)) + if (IsDeletedEntry(Block,Offset)) { - (*pEntry)++; - Status=FsdReadFile(DeviceExt,pFcb,pFatEntry,sizeof(FATDirEntry) - ,(*pEntry)*sizeof(FATDirEntry),&LengthRead); - if(!(NT_SUCCESS(Status))) return FALSE; - cpos++; - vfat_movstr(Name, 13, 0, cpos*13); - vfat_wcsncpy(Name,test2->name0_4, 5); - vfat_wcsncat(Name,test2->name5_10,5,6); - vfat_wcsncat(Name,test2->name11_12,11,2); + return(FALSE); } - // now read the entry - (*pEntry)++; - Status=FsdReadFile(DeviceExt,pFcb,pFatEntry,sizeof(FATDirEntry) - ,(*pEntry)*sizeof(FATDirEntry),&LengthRead); - if (IsDeletedEntry(pFatEntry)) + + if(test2[Offset].attr == 0x0f) + { + vfat_initstr(Name, 256); + vfat_wcsncpy(Name,test2[Offset].name0_4,5); + vfat_wcsncat(Name,test2[Offset].name5_10,5,6); + vfat_wcsncat(Name,test2[Offset].name11_12,11,2); + + cpos=0; + while((test2[Offset].id!=0x41) && (test2[Offset].id!=0x01) && + (test2[Offset].attr>0)) + { + Offset++; + if(Offset==ENTRIES_PER_SECTOR) { + Offset=0; + StartingSector++;//FIXME : nor always the next sector + jloop++; + VFATReadSectors(DeviceExt->StorageDevice,StartingSector,1,Block); + test2 = (slot *)Block; + } + cpos++; + vfat_movstr(Name, 13, 0, cpos*13); + vfat_wcsncpy(Name, test2[Offset].name0_4, 5); + vfat_wcsncat(Name,test2[Offset].name5_10,5,6); + vfat_wcsncat(Name,test2[Offset].name11_12,11,2); + + } + + if (IsDeletedEntry(Block,Offset+1)) + { + Offset++; + *_Offset = Offset; + *_jloop = jloop; + *_StartingSector = StartingSector; return(FALSE); - return(TRUE); - } + } + + *_Offset = Offset; + *_jloop = jloop; + *_StartingSector = StartingSector; + + return(TRUE); + } - RtlAnsiToUnicode(Name,pFatEntry->Filename,8); - if (pFatEntry->Ext[0]!=' ') - { - RtlCatAnsiToUnicode(Name,".",1); - } - RtlCatAnsiToUnicode(Name,pFatEntry->Ext,3); + RtlAnsiToUnicode(Name,test[Offset].Filename,8); + if (test[Offset].Ext[0]!=' ') + { + RtlCatAnsiToUnicode(Name,".",1); + } + RtlCatAnsiToUnicode(Name,test[Offset].Ext,3); + + *_Offset = Offset; + return(TRUE); } @@ -589,22 +615,39 @@ BOOLEAN wstrcmpjoki(PWSTR s1, PWSTR s2) } NTSTATUS FindFile(PDEVICE_EXTENSION DeviceExt, PVfatFCB Fcb, - PVfatFCB Parent, PWSTR FileToFind,ULONG *Entry) + PVfatFCB Parent, PWSTR FileToFind,ULONG *StartSector,ULONG *Entry) /* * FUNCTION: Find a file */ { - ULONG i; + ULONG i, j; ULONG Size; + char* block; WCHAR name[256]; - FATDirEntry FatEntry; - NTSTATUS Status; - ULONG LengthRead; - VfatFCB TempFcb; + ULONG StartingSector; + ULONG NextCluster; + WCHAR TempStr[2]; + + DPRINT("FindFile(Parent %x, FileToFind '%w')\n",Parent,FileToFind); + + if (wcslen(FileToFind)==0) + { + TempStr[0] = (WCHAR)'.'; + TempStr[1] = 0; + FileToFind=&TempStr; + } + if (Parent != NULL) + { + DPRINT("Parent->entry.FirstCluster %d\n",Parent->entry.FirstCluster); + } + if (Parent == NULL||Parent->entry.FirstCluster==1) { Size = DeviceExt->rootDirectorySectors;//FIXME : in fat32, no limit - if(FileToFind[0]==0 ||(FileToFind[0]=='\\' && FileToFind[1]==0)) + StartingSector = DeviceExt->rootStart; + NextCluster=0; + if(FileToFind[0]==0 ||(FileToFind[0]=='\\' && FileToFind[1]==0) || + (FileToFind[0]=='.' && FileToFind[1]==0)) {// it's root : complete essentials fields then return ok memset(Fcb,0,sizeof(VfatFCB)); memset(Fcb->entry.Filename,' ',11); @@ -613,54 +656,97 @@ NTSTATUS FindFile(PDEVICE_EXTENSION DeviceExt, PVfatFCB Fcb, if (DeviceExt->FatType == FAT32) Fcb->entry.FirstCluster=2; else Fcb->entry.FirstCluster=1;//FIXME : is 1 the good value for mark root? + if(StartSector) *StartSector=StartingSector; if(Entry) *Entry=0; return(STATUS_SUCCESS); } } - TempFcb.Buffer=NULL; - if (Parent==NULL) + else { - memset(&TempFcb,0,sizeof(VfatFCB)); - memset(TempFcb.entry.Filename,' ',11); - TempFcb.entry.FileSize=DeviceExt->rootDirectorySectors*BLOCKSIZE; - TempFcb.entry.Attrib=FILE_ATTRIBUTE_DIRECTORY; - TempFcb.Buffer=ExAllocatePool(NonPagedPool,DeviceExt->BytesPerCluster); - TempFcb.Cluster=0xFFFFFFFF; - TempFcb.Flags=0; - if (DeviceExt->FatType == FAT32) - TempFcb.entry.FirstCluster=2; - else - TempFcb.entry.FirstCluster=1;//FIXME : is 1 the good value for mark root? - Parent=&TempFcb; - } - i=(Entry)?(*Entry):0; - for(; ; i++) - { - Status=FsdReadFile(DeviceExt,Parent,&FatEntry,sizeof(FATDirEntry) - ,i*sizeof(FATDirEntry),&LengthRead); - if(!NT_SUCCESS(Status)) - break; - if (IsVolEntry(&FatEntry)) - continue; - if (IsLastEntry(&FatEntry)) - { - if(Entry) *Entry=i; - return(STATUS_UNSUCCESSFUL); + DPRINT("Parent->entry.FileSize %x\n",Parent->entry.FileSize); + + Size = ULONG_MAX; + if (DeviceExt->FatType == FAT32) + NextCluster = Parent->entry.FirstCluster + +Parent->entry.FirstClusterHigh*65536; + else + NextCluster = Parent->entry.FirstCluster; + StartingSector = ClusterToSector(DeviceExt, NextCluster); + if(Parent->entry.FirstCluster==1 && DeviceExt->FatType!=FAT32) + {// read of root directory in FAT16 or FAT12 + StartingSector=DeviceExt->rootStart; } - if (GetEntryName(DeviceExt,Parent,&i,name,&FatEntry)) + } + block = ExAllocatePool(NonPagedPool,BLOCKSIZE); + if (StartSector && (*StartSector)) StartingSector=*StartSector; + i=(Entry)?(*Entry):0; + DPRINT("FindFile : start at sector %lx, entry %ld\n",StartingSector,i); + for (j=0; jStorageDevice,StartingSector,1,block); + + for (i=(Entry)?(*Entry):0; ientry,&FatEntry,sizeof(FATDirEntry)); - vfat_wcsncpy(Fcb->ObjectName,name,MAX_PATH); + ExFreePool(block); + if(StartSector) *StartSector=StartingSector; if(Entry) *Entry=i; - if(TempFcb.Buffer) ExFreePool(TempFcb.Buffer); - return(STATUS_SUCCESS); + return(STATUS_UNSUCCESSFUL); + } + if (GetEntryName((PVOID)block,&i,name,&j,DeviceExt,&StartingSector)) + { + DPRINT("Comparing '%w' '%w'\n",name,FileToFind); + if (wstrcmpjoki(name,FileToFind)) + { + /* In the case of a long filename, the firstcluster is stored in + the next record -- where it's short name is */ + if(((FATDirEntry *)block)[i].Attrib==0x0f) i++; + if( i==(ENTRIES_PER_SECTOR)) + {// entry is in next sector + StartingSector++; + //FIXME : treat case of next sector fragmented + VFATReadSectors(DeviceExt->StorageDevice,StartingSector,1,block); + i=0; + } + memcpy(&Fcb->entry,&((FATDirEntry *)block)[i], + sizeof(FATDirEntry)); + vfat_wcsncpy(Fcb->ObjectName,name,MAX_PATH); + ExFreePool(block); + if(StartSector) *StartSector=StartingSector; + if(Entry) *Entry=i; + return(STATUS_SUCCESS); + } + } + } + // not found in this sector, try next : + + /* directory can be fragmented although it is best to keep them + unfragmented */ + if(Entry) *Entry=0; + StartingSector++; + if ((Parent != NULL && Parent->entry.FirstCluster!=1) + || DeviceExt->FatType ==FAT32) + { + if(StartingSector==ClusterToSector(DeviceExt,NextCluster+1)) + { + NextCluster = GetNextCluster(DeviceExt,NextCluster); + if (NextCluster == 0||NextCluster==0xffffffff) + { + if(StartSector) *StartSector=StartingSector; + if(Entry) *Entry=i; + ExFreePool(block); + return(STATUS_UNSUCCESSFUL); + } + StartingSector = ClusterToSector(DeviceExt,NextCluster); } } } + ExFreePool(block); + if(StartSector) *StartSector=StartingSector; if(Entry) *Entry=i; - if(TempFcb.Buffer) ExFreePool(TempFcb.Buffer); return(STATUS_UNSUCCESSFUL); } @@ -672,12 +758,21 @@ NTSTATUS FsdCloseFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject) { PVfatFCB pFcb; PVfatCCB pCcb; + + DPRINT("FsdCloseFile(DeviceExt %x, FileObject %x)\n", + DeviceExt,FileObject); + //FIXME : update entry in directory ? - assert(FileObject); pCcb = (PVfatCCB)(FileObject->FsContext2); - if(!pCcb) return STATUS_UNSUCCESSFUL; + + DPRINT("pCcb %x\n",pCcb); + if (pCcb == NULL) + { + return(STATUS_SUCCESS); + } + pFcb = pCcb->pFcb; - assert(pFcb); + pFcb->RefCount--; if(pFcb->RefCount<=0) { @@ -687,7 +782,6 @@ NTSTATUS FsdCloseFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject) pFirstFcb=pFcb->nextFcb; if(pFcb->nextFcb) pFcb->nextFcb->prevFcb=pFcb->prevFcb; - ExFreePool(pFcb->Buffer); ExFreePool(pFcb); } ExFreePool(pCcb); @@ -711,12 +805,16 @@ NTSTATUS FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, PFILE_OBJECT pRelFileObject; PWSTR AbsFileName=NULL; short i,j; - if(FileObject->FileName.Length>0 - && FileName[FileObject->FileName.Length-1]=='\\') - FileName[FileObject->FileName.Length-1]=0; - // treat relative name + + DPRINT("FsdOpenFile(%08lx, %08lx, %w)\n", + DeviceExt, + FileObject, + FileName); + + //FIXME : treat relative name if(FileObject->RelatedFileObject) { +DbgPrint("try related for %w\n",FileName); pRelFileObject=FileObject->RelatedFileObject; pRelCcb=pRelFileObject->FsContext2; assert(pRelCcb); @@ -730,7 +828,7 @@ NTSTATUS FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, return Status; } // construct absolute path name - AbsFileName=ExAllocatePool(NonPagedPool,MAX_PATH*sizeof(WCHAR)); + AbsFileName=ExAllocatePool(NonPagedPool,MAX_PATH); for (i=0;pRelFcb->PathName[i];i++) AbsFileName[i]=pRelFcb->PathName[i]; AbsFileName[i++]='\\'; @@ -762,80 +860,60 @@ NTSTATUS FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, Fcb = ExAllocatePool(NonPagedPool, sizeof(VfatFCB)); memset(Fcb,0,sizeof(VfatFCB)); Fcb->ObjectName=Fcb->PathName; - Fcb->Buffer=ExAllocatePool(NonPagedPool,DeviceExt->BytesPerCluster); - Fcb->Cluster=0xFFFFFFFF; - Fcb->Flags=0; - next = &string[0]; - current = next+1; - - if(*next==0) // root - { - memset(Fcb->entry.Filename,' ',11); - Fcb->entry.FileSize=DeviceExt->rootDirectorySectors*BLOCKSIZE; - Fcb->entry.Attrib=FILE_ATTRIBUTE_DIRECTORY; - if (DeviceExt->FatType == FAT32) - Fcb->entry.FirstCluster=2; - else Fcb->entry.FirstCluster=1;//FIXME : is 1 the good value for mark root? - ParentFcb=Fcb; - Fcb=NULL; - } - else + next = &string[0]; + while (next!=NULL) { *next = '\\'; current = next+1; next = wcschr(next+1,'\\'); if (next!=NULL) - *next=0; - Status = FindFile(DeviceExt,Fcb,ParentFcb,current,NULL); - if (Status != STATUS_SUCCESS) - { - if (Fcb != NULL) - ExFreePool(Fcb); - if (ParentFcb != NULL) - ExFreePool(ParentFcb); - if(AbsFileName)ExFreePool(AbsFileName); - return(Status); - } - Temp = Fcb; - if (ParentFcb == NULL) - { - Fcb = ExAllocatePool(NonPagedPool,sizeof(VfatFCB)); - memset(Fcb,0,sizeof(VfatFCB)); - Fcb->ObjectName=Fcb->PathName; - Fcb->Buffer=ExAllocatePool(NonPagedPool,DeviceExt->BytesPerCluster); - Fcb->Cluster=0xFFFFFFFF; - Fcb->Flags=0; - } - else Fcb = ParentFcb; - ParentFcb = Temp; + { + *next=0; + } + DPRINT("current '%w'\n",current); + Status = FindFile(DeviceExt,Fcb,ParentFcb,current,NULL,NULL); + if (Status != STATUS_SUCCESS) + { + if (Fcb != NULL) + ExFreePool(Fcb); + if (ParentFcb != NULL) + ExFreePool(ParentFcb); + if(AbsFileName)ExFreePool(AbsFileName); + return(Status); + } + Temp = Fcb; + if (ParentFcb == NULL) + { + Fcb = ExAllocatePool(NonPagedPool,sizeof(VfatFCB)); + memset(Fcb,0,sizeof(VfatFCB)); + Fcb->ObjectName=Fcb->PathName; + } + else Fcb = ParentFcb; + ParentFcb = Temp; } - CHECKPOINT; - FileObject->FsContext =(PVOID) &ParentFcb->NTRequiredFCB; - newCCB = ExAllocatePool(NonPagedPool,sizeof(VfatCCB)); - memset(newCCB,0,sizeof(VfatCCB)); - FileObject->FsContext2 = newCCB; - newCCB->pFcb=ParentFcb; - newCCB->PtrFileObject=FileObject; - ParentFcb->RefCount++; - //FIXME : initialize all fields in FCB and CCB - ParentFcb->Cluster=0xFFFFFFFF; - ParentFcb->Flags=0; - ParentFcb->nextFcb=pFirstFcb; - pFirstFcb=ParentFcb; + FileObject->FsContext =(PVOID) &ParentFcb->NTRequiredFCB; + newCCB = ExAllocatePool(NonPagedPool,sizeof(VfatCCB)); + memset(newCCB,0,sizeof(VfatCCB)); + FileObject->FsContext2 = newCCB; + newCCB->pFcb=ParentFcb; + newCCB->PtrFileObject=FileObject; + ParentFcb->RefCount++; + //FIXME : initialize all fields in FCB and CCB + ParentFcb->nextFcb=pFirstFcb; + pFirstFcb=ParentFcb; vfat_wcsncpy(ParentFcb->PathName,FileName,MAX_PATH); - ParentFcb->ObjectName=ParentFcb->PathName+(current-FileName); - ParentFcb->pDevExt=DeviceExt; - if(Fcb) - { - ExFreePool(Fcb->Buffer); - ExFreePool(Fcb); - } - if(AbsFileName)ExFreePool(AbsFileName); + ParentFcb->ObjectName=ParentFcb->PathName+(current-FileName); + ParentFcb->pDevExt=DeviceExt; + DPRINT("file open, fcb=%x\n",ParentFcb); + DPRINT("FileSize %d\n",ParentFcb->entry.FileSize); + if(Fcb) ExFreePool(Fcb); + if(AbsFileName)ExFreePool(AbsFileName); return(STATUS_SUCCESS); -} - -BOOLEAN FsdHasFileSystem(PDEVICE_OBJECT DeviceToMount) + } + + + BOOLEAN FsdHasFileSystem(PDEVICE_OBJECT DeviceToMount) /* * FUNCTION: Tests if the device contains a filesystem that can be mounted * by this fsd @@ -843,7 +921,7 @@ BOOLEAN FsdHasFileSystem(PDEVICE_OBJECT DeviceToMount) { BootSector* Boot; - Boot = ExAllocatePool(NonPagedPool,BLOCKSIZE); + Boot = ExAllocatePool(NonPagedPool,512); VFATReadSectors(DeviceToMount, 0, 1, (UCHAR *)Boot); @@ -866,7 +944,8 @@ NTSTATUS FsdMountDevice(PDEVICE_EXTENSION DeviceExt, { DPRINT("Mounting VFAT device..."); DPRINT("DeviceExt %x\n",DeviceExt); - DeviceExt->Boot = ExAllocatePool(NonPagedPool,BLOCKSIZE); + + DeviceExt->Boot = ExAllocatePool(NonPagedPool,512); VFATReadSectors(DeviceToMount, 0, 1, (UCHAR *)DeviceExt->Boot); DPRINT("DeviceExt->Boot->BytesPerSector %x\n", @@ -916,6 +995,10 @@ void VFATLoadCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster) */ { ULONG Sector; + + DPRINT("VFATLoadCluster(DeviceExt %x, Buffer %x, Cluster %d)\n", + DeviceExt,Buffer,Cluster); + Sector = ClusterToSector(DeviceExt, Cluster); VFATReadSectors(DeviceExt->StorageDevice, @@ -930,6 +1013,9 @@ void VFATWriteCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster) */ { ULONG Sector; + DPRINT("VFATWriteCluster(DeviceExt %x, Buffer %x, Cluster %d)\n", + DeviceExt,Buffer,Cluster); + Sector = ClusterToSector(DeviceExt, Cluster); VFATWriteSectors(DeviceExt->StorageDevice, @@ -938,7 +1024,7 @@ void VFATWriteCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster) Buffer); } -NTSTATUS FsdReadFile(PDEVICE_EXTENSION DeviceExt, PVfatFCB Fcb, +NTSTATUS FsdReadFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, PVOID Buffer, ULONG Length, ULONG ReadOffset, PULONG LengthRead) /* @@ -948,21 +1034,29 @@ NTSTATUS FsdReadFile(PDEVICE_EXTENSION DeviceExt, PVfatFCB Fcb, ULONG CurrentCluster; ULONG FileOffset; ULONG FirstCluster; -// PVOID Temp; + PVfatFCB Fcb; + PVOID Temp; ULONG TempLength; /* PRECONDITION */ assert(DeviceExt != NULL); assert(DeviceExt->BytesPerCluster != 0); - assert(Fcb); - assert(Fcb->Buffer != NULL); + assert(FileObject != NULL); + assert(FileObject->FsContext != NULL); + DPRINT("FsdReadFile(DeviceExt %x, FileObject %x, Buffer %x, " + "Length %d, ReadOffset %d)\n",DeviceExt,FileObject,Buffer, + Length,ReadOffset); + + Fcb = ((PVfatCCB)(FileObject->FsContext2))->pFcb; if (DeviceExt->FatType == FAT32) CurrentCluster = Fcb->entry.FirstCluster +Fcb->entry.FirstClusterHigh*65536; else CurrentCluster = Fcb->entry.FirstCluster; FirstCluster=CurrentCluster; + DPRINT("DeviceExt->BytesPerCluster %x\n",DeviceExt->BytesPerCluster); + if (ReadOffset >= Fcb->entry.FileSize && !(Fcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY)) { @@ -974,6 +1068,9 @@ NTSTATUS FsdReadFile(PDEVICE_EXTENSION DeviceExt, PVfatFCB Fcb, Length = Fcb->entry.FileSize - ReadOffset; } *LengthRead = 0; + /* FIXME: optimize by remembering the last cluster read and using if possible */ + Temp = ExAllocatePool(NonPagedPool,DeviceExt->BytesPerCluster); + if(!Temp) return STATUS_UNSUCCESSFUL; if (FirstCluster==1) { //root of FAT16 or FAT12 CurrentCluster=DeviceExt->rootStart+ReadOffset @@ -985,84 +1082,76 @@ NTSTATUS FsdReadFile(PDEVICE_EXTENSION DeviceExt, PVfatFCB Fcb, { CurrentCluster = GetNextCluster(DeviceExt,CurrentCluster); } + CHECKPOINT; if ((ReadOffset % DeviceExt->BytesPerCluster)!=0) { if (FirstCluster==1) { - if(CurrentCluster!=Fcb->Cluster) - VFATReadSectors(DeviceExt->StorageDevice,CurrentCluster - ,DeviceExt->Boot->SectorsPerCluster,Fcb->Buffer); - Fcb->Cluster=CurrentCluster; + VFATReadSectors(DeviceExt->StorageDevice,CurrentCluster + ,DeviceExt->Boot->SectorsPerCluster,Temp); CurrentCluster += DeviceExt->Boot->SectorsPerCluster; } else { - if(CurrentCluster!=Fcb->Cluster) - VFATLoadCluster(DeviceExt,Fcb->Buffer,CurrentCluster); - Fcb->Cluster=CurrentCluster; + VFATLoadCluster(DeviceExt,Temp,CurrentCluster); CurrentCluster = GetNextCluster(DeviceExt, CurrentCluster); } TempLength = min(Length,DeviceExt->BytesPerCluster - (ReadOffset % DeviceExt->BytesPerCluster)); - memcpy(Buffer, Fcb->Buffer + ReadOffset % DeviceExt->BytesPerCluster, + memcpy(Buffer, Temp + ReadOffset % DeviceExt->BytesPerCluster, TempLength); (*LengthRead) = (*LengthRead) + TempLength; Length = Length - TempLength; Buffer = Buffer + TempLength; } + CHECKPOINT; while (Length >= DeviceExt->BytesPerCluster) { if (FirstCluster==1) { - if(CurrentCluster!=Fcb->Cluster) - VFATReadSectors(DeviceExt->StorageDevice,CurrentCluster - ,DeviceExt->Boot->SectorsPerCluster,Fcb->Buffer); - Fcb->Cluster=CurrentCluster; + VFATReadSectors(DeviceExt->StorageDevice,CurrentCluster + ,DeviceExt->Boot->SectorsPerCluster,Buffer); CurrentCluster += DeviceExt->Boot->SectorsPerCluster; } else { - if(CurrentCluster!=Fcb->Cluster) - VFATLoadCluster(DeviceExt,Fcb->Buffer,CurrentCluster); - Fcb->Cluster=CurrentCluster; + VFATLoadCluster(DeviceExt,Buffer,CurrentCluster); CurrentCluster = GetNextCluster(DeviceExt, CurrentCluster); } - memcpy(Buffer, Fcb->Buffer, DeviceExt->BytesPerCluster); - if (CurrentCluster == 0xffffffff) + if (CurrentCluster == 0xffffffff) { + ExFreePool(Temp); return(STATUS_SUCCESS); } (*LengthRead) = (*LengthRead) + DeviceExt->BytesPerCluster; Buffer = Buffer + DeviceExt->BytesPerCluster; Length = Length - DeviceExt->BytesPerCluster; - } + } + CHECKPOINT; if (Length > 0) - { + { (*LengthRead) = (*LengthRead) + Length; if (FirstCluster==1) - { - if(CurrentCluster!=Fcb->Cluster) + { VFATReadSectors(DeviceExt->StorageDevice,CurrentCluster - ,DeviceExt->Boot->SectorsPerCluster,Fcb->Buffer); - Fcb->Cluster=CurrentCluster; - CurrentCluster += DeviceExt->Boot->SectorsPerCluster; - } + ,DeviceExt->Boot->SectorsPerCluster,Temp); + CurrentCluster += DeviceExt->Boot->SectorsPerCluster; + } else { - if(CurrentCluster!=Fcb->Cluster) - VFATLoadCluster(DeviceExt,Fcb->Buffer,CurrentCluster); - Fcb->Cluster=CurrentCluster; + VFATLoadCluster(DeviceExt,Temp,CurrentCluster); CurrentCluster = GetNextCluster(DeviceExt, CurrentCluster); } - memcpy(Buffer, Fcb->Buffer, Length); + memcpy(Buffer, Temp, Length); } + ExFreePool(Temp); return(STATUS_SUCCESS); } -NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PVfatFCB Fcb, +NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, PVOID Buffer, ULONG Length, ULONG WriteOffset) /* * FUNCTION: Writes data to file @@ -1071,23 +1160,26 @@ NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PVfatFCB Fcb, ULONG CurrentCluster; ULONG FileOffset; ULONG FirstCluster; + PVfatFCB Fcb; + PVfatCCB pCcb; + PVOID Temp; ULONG TempLength,Length2=Length; - CHECKPOINT; /* Locate the first cluster of the file */ + assert(FileObject); + pCcb=(PVfatCCB)(FileObject->FsContext2); + assert(pCcb); + Fcb = pCcb->pFcb; assert(Fcb); - if(WriteOffset==FILE_WRITE_TO_END_OF_FILE) - WriteOffset=Fcb->entry.FileSize; - if(!(Fcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY) && WriteOffset>Fcb->entry.FileSize) - { - //FIXME : we must extend the file with null bytes then write buffer - return STATUS_UNSUCCESSFUL; - } if (DeviceExt->FatType == FAT32) CurrentCluster = Fcb->entry.FirstCluster+Fcb->entry.FirstClusterHigh*65536; else CurrentCluster = Fcb->entry.FirstCluster; FirstCluster=CurrentCluster; + /* Allocate a buffer to hold 1 cluster of data */ + + Temp = ExAllocatePool(NonPagedPool,DeviceExt->BytesPerCluster); + assert(Temp); /* Find the cluster according to the offset in the file */ @@ -1126,29 +1218,26 @@ NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PVfatFCB Fcb, TempLength = min(Length,DeviceExt->BytesPerCluster - (WriteOffset % DeviceExt->BytesPerCluster)); /* Read in the existing cluster data */ - if(CurrentCluster!=Fcb->Cluster) - { - if (FirstCluster==1) - VFATReadSectors(DeviceExt->StorageDevice,CurrentCluster - ,DeviceExt->Boot->SectorsPerCluster,Fcb->Buffer); - else - VFATLoadCluster(DeviceExt,Fcb->Buffer,CurrentCluster); - Fcb->Cluster=CurrentCluster; - } + if (FirstCluster==1) + VFATReadSectors(DeviceExt->StorageDevice,CurrentCluster + ,DeviceExt->Boot->SectorsPerCluster,Temp); + else + VFATLoadCluster(DeviceExt,Temp,CurrentCluster); + /* Overwrite the last parts of the data as necessary */ - memcpy(Fcb->Buffer + (WriteOffset % DeviceExt->BytesPerCluster), Buffer, + memcpy(Temp + (WriteOffset % DeviceExt->BytesPerCluster), Buffer, TempLength); /* Write the cluster back */ if (FirstCluster==1) { VFATWriteSectors(DeviceExt->StorageDevice,CurrentCluster - ,DeviceExt->Boot->SectorsPerCluster,Fcb->Buffer); + ,DeviceExt->Boot->SectorsPerCluster,Temp); CurrentCluster += DeviceExt->Boot->SectorsPerCluster; } else { - VFATWriteCluster(DeviceExt,Fcb->Buffer,CurrentCluster); + VFATWriteCluster(DeviceExt,Temp,CurrentCluster); CurrentCluster = GetNextCluster(DeviceExt, CurrentCluster); } Length2 -= TempLength; @@ -1163,21 +1252,18 @@ NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PVfatFCB Fcb, CHECKPOINT; if (CurrentCluster == 0) { + ExFreePool(Temp); return(STATUS_UNSUCCESSFUL); } if (FirstCluster==1) { VFATWriteSectors(DeviceExt->StorageDevice,CurrentCluster ,DeviceExt->Boot->SectorsPerCluster,Buffer); - Fcb->Cluster=CurrentCluster; - memcpy(Fcb->Buffer,Buffer,DeviceExt->Boot->SectorsPerCluster); CurrentCluster += DeviceExt->Boot->SectorsPerCluster; } else { VFATWriteCluster(DeviceExt,Buffer,CurrentCluster); - Fcb->Cluster=CurrentCluster; - memcpy(Fcb->Buffer,Buffer,DeviceExt->Boot->SectorsPerCluster); CurrentCluster = GetNextCluster(DeviceExt, CurrentCluster); } Buffer = Buffer + DeviceExt->BytesPerCluster; @@ -1189,37 +1275,40 @@ NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PVfatFCB Fcb, if (Length2 > 0) { + CHECKPOINT; if (CurrentCluster == 0) { + ExFreePool(Temp); return(STATUS_UNSUCCESSFUL); } + CHECKPOINT; /* Read in the existing cluster data */ - if(CurrentCluster!=Fcb->Cluster) - { - if (FirstCluster==1) - VFATReadSectors(DeviceExt->StorageDevice,CurrentCluster - ,DeviceExt->Boot->SectorsPerCluster,Fcb->Buffer); - else - VFATLoadCluster(DeviceExt,Fcb->Buffer,CurrentCluster); - Fcb->Cluster=CurrentCluster; - } - memcpy(Fcb->Buffer, Buffer, Length2); + if (FirstCluster==1) + VFATReadSectors(DeviceExt->StorageDevice,CurrentCluster + ,DeviceExt->Boot->SectorsPerCluster,Temp); + else + VFATLoadCluster(DeviceExt,Temp,CurrentCluster); + CHECKPOINT; + memcpy(Temp, Buffer, Length2); + CHECKPOINT; if (FirstCluster==1) { VFATWriteSectors(DeviceExt->StorageDevice,CurrentCluster - ,DeviceExt->Boot->SectorsPerCluster,Fcb->Buffer); + ,DeviceExt->Boot->SectorsPerCluster,Temp); } else - VFATWriteCluster(DeviceExt,Fcb->Buffer,CurrentCluster); + VFATWriteCluster(DeviceExt,Temp,CurrentCluster); } + CHECKPOINT; //FIXME : set last write time and date if(Fcb->entry.FileSizeentry.Attrib &FILE_ATTRIBUTE_DIRECTORY)) { Fcb->entry.FileSize=WriteOffset+Length; // update entry in directory - updEntry(DeviceExt,Fcb); + updEntry(DeviceExt,FileObject); } + ExFreePool(Temp); return(STATUS_SUCCESS); } @@ -1233,6 +1322,8 @@ NTSTATUS FsdClose(PDEVICE_OBJECT DeviceObject, PIRP Irp) PDEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension; NTSTATUS Status; + DPRINT("FsdClose(DeviceObject %x, Irp %x)\n",DeviceObject, Irp); + Status = FsdCloseFile(DeviceExtension,FileObject); Irp->IoStatus.Status = Status; @@ -1254,6 +1345,7 @@ NTSTATUS FsdCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp) ULONG RequestedDisposition,RequestedOptions; PVfatCCB pCcb; PVfatFCB pFcb; + assert(DeviceObject); assert(Irp); if(DeviceObject->Size==sizeof(DEVICE_OBJECT)) @@ -1322,7 +1414,6 @@ NTSTATUS FsdCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp) IoCompleteRequest(Irp, IO_NO_INCREMENT); ExReleaseResourceForThreadLite(&(DeviceExt->Resource),ExGetCurrentResourceThread()); -DbgPrint("open, Status=%x\n",Status); return Status; } @@ -1339,7 +1430,6 @@ NTSTATUS FsdWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp) PFILE_OBJECT FileObject = Stack->FileObject; PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension; NTSTATUS Status; - PVfatFCB pFcb; DPRINT("FsdWrite(DeviceObject %x Irp %x)\n",DeviceObject,Irp); @@ -1347,9 +1437,7 @@ NTSTATUS FsdWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp) Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress); Offset = GET_LARGE_INTEGER_LOW_PART(Stack->Parameters.Write.ByteOffset); - assert(FileObject->FsContext2 != NULL); - pFcb = ((PVfatCCB)(FileObject->FsContext2))->pFcb; - Status = FsdWriteFile(DeviceExt,pFcb,Buffer,Length,Offset); + Status = FsdWriteFile(DeviceExt,FileObject,Buffer,Length,Offset); Irp->IoStatus.Status = Status; Irp->IoStatus.Information = Length; @@ -1371,8 +1459,9 @@ NTSTATUS FsdRead(PDEVICE_OBJECT DeviceObject, PIRP Irp) PDEVICE_EXTENSION DeviceExt; NTSTATUS Status; ULONG LengthRead; - PVfatFCB pFcb; + DPRINT("FsdRead(DeviceObject %x, Irp %x)\n",DeviceObject,Irp); + /* Precondition / Initialization */ assert(Irp != NULL); Stack = IoGetCurrentIrpStackLocation(Irp); @@ -1385,10 +1474,8 @@ NTSTATUS FsdRead(PDEVICE_OBJECT DeviceObject, PIRP Irp) Length = Stack->Parameters.Read.Length; Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress); Offset = GET_LARGE_INTEGER_LOW_PART(Stack->Parameters.Read.ByteOffset); - assert(FileObject->FsContext2 != NULL); - pFcb = ((PVfatCCB)(FileObject->FsContext2))->pFcb; - assert(pFcb); - Status = FsdReadFile(DeviceExt,pFcb,Buffer,Length,Offset, + + Status = FsdReadFile(DeviceExt,FileObject,Buffer,Length,Offset, &LengthRead); Irp->IoStatus.Status = Status; @@ -1452,6 +1539,7 @@ NTSTATUS FsdFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp) Irp->IoStatus.Status = Status; Irp->IoStatus.Information = 0; + IoCompleteRequest(Irp, IO_NO_INCREMENT); return(Status); } @@ -1537,8 +1625,8 @@ NTSTATUS FsdQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp) return RC; } -NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject, - PUNICODE_STRING RegistryPath) +STDCALL NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject, + PUNICODE_STRING RegistryPath) /* * FUNCTION: Called by the system to initalize the driver * ARGUMENTS: @@ -1552,7 +1640,7 @@ NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject, UNICODE_STRING ustr; ANSI_STRING astr; - DbgPrint("VFAT 0.0.7\n"); + DbgPrint("VFAT 0.0.6\n"); pFirstFcb=NULL; VFATDriverObject = _DriverObject; diff --git a/reactos/drivers/fs/vfat/makefile b/reactos/drivers/fs/vfat/makefile index 1b5771a2dd3..53fc8b80fbd 100644 --- a/reactos/drivers/fs/vfat/makefile +++ b/reactos/drivers/fs/vfat/makefile @@ -1,22 +1,15 @@ -%.o: %.cc - $(CC) $(CFLAGS) -c $< -o $@ -%.o: %.asm - $(NASM) $(NFLAGS) $< -o $@ +all: vfatfsd.sys -OBJECTS= blockdev.o iface.o dir.o dirwr.o +OBJECTS = blockdev.o dir.o dirwr.o iface.o ../../../ntoskrnl/ntoskrnl.a -all: vfatfsd.o -tests: tstvfat5.bin tstvfat6.bin - -vfatfsd.o: $(OBJECTS) - $(LD) $(OBJECTS) -r -o vfatfsd.o - $(NM) --numeric-sort vfatfsd.o > vfatfsd.sym - -OBJECTS2 = ../../../apps/common/crt0.o -LIBS= ../../../lib/kernel32/kernel32.a ../../../lib/ntdll/ntdll.a - -%.bin: $(OBJECTS) %.o - $(LD) -Ttext 0x10000 $(OBJECTS2) $*.o $(LIBS) -o $*.exe - $(OBJCOPY) -O binary $*.exe $*.bin - -include ../../../rules.mak +vfatfsd.sys: $(OBJECTS) + $(CC) -specs=../../svc_specs -mdll -o junk.tmp -Wl,--defsym,_end=end \ + -Wl,--defsym,_edata=__data_end__ -Wl,--defsym,_etext=etext \ + -Wl,--base-file,base.tmp $(OBJECTS) + - $(RM) junk.tmp + $(DLLTOOL) --dllname vfatfsd.sys --base-file base.tmp \ + --output-exp temp.exp + - $(RM) base.tmp + $(CC) --verbose -Wl,--image-base,0x10000 -Wl,-e,_DriverEntry@8 \ + -specs=../../svc_specs -mdll -o vfatfsd.sys $(OBJECTS) -Wl,temp.exp + - $(RM) temp.exp diff --git a/reactos/drivers/fs/vfat/vfat.h b/reactos/drivers/fs/vfat/vfat.h index 9e972fb05d5..7fff0ab6eee 100644 --- a/reactos/drivers/fs/vfat/vfat.h +++ b/reactos/drivers/fs/vfat/vfat.h @@ -1,4 +1,4 @@ - +#include @@ -113,9 +113,6 @@ typedef struct _VfatFCB PDEVICE_EXTENSION pDevExt; struct _VfatFCB * nextFcb, *prevFcb; struct _VfatFCB * parentFcb; - UCHAR *Buffer; - long Flags; - ULONG Cluster; } VfatFCB, *PVfatFCB; typedef struct @@ -124,6 +121,7 @@ typedef struct LIST_ENTRY NextCCB; PFILE_OBJECT PtrFileObject; LARGE_INTEGER CurrentByteOffset; + ULONG StartSector; // for DirectoryControl ULONG StartEntry; //for DirectoryControl // PSTRING DirectorySearchPattern;// for DirectoryControl ? } VfatCCB, *PVfatCCB; @@ -158,27 +156,27 @@ BOOLEAN VFATWriteSectors(IN PDEVICE_OBJECT pDeviceObject, //internal functions in iface.c : NTSTATUS FindFile(PDEVICE_EXTENSION DeviceExt, PVfatFCB Fcb, - PVfatFCB Parent, PWSTR FileToFind,ULONG *Entry); + PVfatFCB Parent, PWSTR FileToFind,ULONG *StartSector,ULONG *Entry); NTSTATUS FsdCloseFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject); NTSTATUS FsdGetStandardInformation(PVfatFCB FCB, PDEVICE_OBJECT DeviceObject, PFILE_STANDARD_INFORMATION StandardInfo); NTSTATUS FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, PWSTR FileName); -NTSTATUS FsdReadFile(PDEVICE_EXTENSION DeviceExt, PVfatFCB pFcb, +NTSTATUS FsdReadFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, PVOID Buffer, ULONG Length, ULONG ReadOffset, PULONG LengthRead); -NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PVfatFCB pFcb, - PVOID Buffer, ULONG Length, ULONG WriteOffset); +NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, + PVOID Buffer, ULONG Length, ULONG WriteOffset); ULONG GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster); -BOOLEAN IsDeletedEntry(FATDirEntry *pEntry); -BOOLEAN IsLastEntry(FATDirEntry *pEntry); +BOOLEAN IsDeletedEntry(PVOID Block, ULONG Offset); +BOOLEAN IsLastEntry(PVOID Block, ULONG Offset); wchar_t * vfat_wcsncpy(wchar_t * dest, const wchar_t *src,size_t wcount); void VFATWriteCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster); //internal functions in dirwr.c NTSTATUS addEntry(PDEVICE_EXTENSION DeviceExt ,PFILE_OBJECT pFileObject,ULONG RequestedOptions,UCHAR ReqAttr); -NTSTATUS updEntry(PDEVICE_EXTENSION DeviceExt,PVfatFCB pFcb); +NTSTATUS updEntry(PDEVICE_EXTENSION DeviceExt,PFILE_OBJECT pFileObject); //FIXME : following defines must be removed diff --git a/reactos/drivers/fs/vfat/vfat005.1st b/reactos/drivers/fs/vfat/vfat005.1st index e661bcc2c36..71af436576d 100644 --- a/reactos/drivers/fs/vfat/vfat005.1st +++ b/reactos/drivers/fs/vfat/vfat005.1st @@ -9,4 +9,4 @@ To install : What's new : - some bugfixes - support for IRP_MJ_DIRECTORY_CONTROL - (see reactos/tst/sshell.c for use of ZwQueryDirectoryFile) \ No newline at end of file + (see reactos/tst/sshell.c for use of ZwQueryDirectoryFile) diff --git a/reactos/drivers/svc_specs b/reactos/drivers/svc_specs new file mode 100644 index 00000000000..6dac69481ed --- /dev/null +++ b/reactos/drivers/svc_specs @@ -0,0 +1,78 @@ +*asm: + + +*asm_final: + + +*cpp: +-remap %(cpp_cpu) %{posix:-D_POSIX_SOURCE} + +*cc1: +%(cc1_spec) + +*cc1plus: + + +*endfile: + + +*link: +%{mwindows:--subsystem windows} %{mdll:--dll -e _DriverEntry@8} + +*lib: + + +*libgcc: + + +*startfile: + + +*switches_need_spaces: + + +*signed_char: +%{funsigned-char:-D__CHAR_UNSIGNED__} + +*predefines: +-Di386 -D_WIN32 -DWIN32 -D__WIN32__ -D__MINGW32__ -DWINNT -D_X86_=1 -D__STDC__=1 -D__stdcall=__attribute__((__stdcall__)) _D_stdcall=__attribute__((__stdcall__)) -D__cdecl=__attribute__((__cdecl__)) -D__declspec(x)=__attribute__((x)) -Asystem(winnt) -Acpu(i386) -Amachine(i386) + +*cross_compile: +1 + +*version: +egcs-2.91.57 + +*multilib: +. ; + +*multilib_defaults: + + +*multilib_extra: + + +*multilib_matches: + + +*linker: +collect2 + +*cpp_486: +%{!ansi:-Di486} -D__i486 -D__i486__ + +*cpp_586: +%{!ansi:-Di586 -Dpentium} -D__i586 -D__i586__ -D__pentium -D__pentium__ + +*cpp_686: +%{!ansi:-Di686 -Dpentiumpro} -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ + +*cpp_cpu_default: +%(cpp_586) + +*cpp_cpu: +-Acpu(i386) -Amachine(i386) %{!ansi:-Di386} -D__i386 -D__i386__ %{mcpu=i486:%(cpp_486)} %{m486:%(cpp_486)} %{mpentium:%(cpp_586)} %{mcpu=pentium:%(cpp_586)} %{mpentiumpro:%(cpp_686)} %{mcpu=pentiumpro:%(cpp_686)} %{!mcpu*:%{!m486:%{!mpentium*:%(cpp_cpu_default)}}} + +*cc1_cpu: +%{!mcpu*: %{m386:-mcpu=i386 -march=i386} %{mno-486:-mcpu=i386 -march=i386} %{m486:-mcpu=i486 -march=i486} %{mno-386:-mcpu=i486 -march=i486} %{mno-pentium:-mcpu=i486 -march=i486} %{mpentium:-mcpu=pentium} %{mno-pentiumpro:-mcpu=pentium} %{mpentiumpro:-mcpu=pentiumpro}} + diff --git a/reactos/iface/native/genntdll.c b/reactos/iface/native/genntdll.c index 057238982d2..e390c06d0d8 100644 --- a/reactos/iface/native/genntdll.c +++ b/reactos/iface/native/genntdll.c @@ -10,10 +10,13 @@ #include #include +#include #define TRUE 1 #define FALSE 0 +#define PARAMETERIZED_LIBS + /* FUNCTIONS ****************************************************************/ int process(FILE* in, FILE* out, FILE *out2) @@ -24,7 +27,8 @@ int process(FILE* in, FILE* out, FILE *out2) char* name2; int value; char* nr_args; - + char* stmp; + unsigned char first1 = TRUE; fprintf(out,"// Machine generated, don't edit\n"); @@ -53,6 +57,11 @@ int process(FILE* in, FILE* out, FILE *out2) // value = strtok(NULL," \t"); nr_args = (char *)strtok(NULL," \t"); + if ((stmp=strchr(nr_args,'\n'))!=NULL) + { + *stmp=0; + } + // printf("name %s value %d\n",name,value); #ifdef PARAMETERIZED_LIBS fprintf(out,"__asm__(\"\\n\\t.global _%s@%s\\n\\t\"\n",name,nr_args); diff --git a/reactos/iface/native/makefile b/reactos/iface/native/makefile index fdf7bb30543..cbac27951b2 100644 --- a/reactos/iface/native/makefile +++ b/reactos/iface/native/makefile @@ -11,8 +11,8 @@ genntdll$(EXE_POSTFIX): genntdll.c sysfuncs.lst: dummy clean: dummy - - $(RM) ../../lib/ntdll/sysfuncs.lst - - $(RM) ../../include/ntdll/napi.h + $(RM) ../../lib/ntdll/sysfuncs.lst + $(RM) ../../include/ntdll/napi.h dummy: diff --git a/reactos/iface/native/sysfuncs.lst b/reactos/iface/native/sysfuncs.lst index 2b90351fcc1..5de9fea5542 100644 --- a/reactos/iface/native/sysfuncs.lst +++ b/reactos/iface/native/sysfuncs.lst @@ -60,7 +60,7 @@ NtFreeVirtualMemory ZwFreeVirtualMemory 16 NtFsControlFile ZwFsControlFile 40 NtGetContextThread ZwGetContextThread 8 NtGetPlugPlayEvent ZwGetPlugPlayEvent 16 -NtGetTickCount ZwGetTickCount 0 +NtGetTickCount ZwGetTickCount 4 NtImpersonateClientOfPort ZwImpersonateClientOfPort 8 NtImpersonateThread ZwImpersonateThread 12 NtInitializeRegistry ZwInitializeRegistry 4 diff --git a/reactos/include/base.h b/reactos/include/base.h index eeb6e67f072..5dd506ca5d5 100644 --- a/reactos/include/base.h +++ b/reactos/include/base.h @@ -65,6 +65,10 @@ typedef unsigned short *PUSHORT; typedef void *PVOID; typedef unsigned char BYTE; typedef void *LPVOID; +typedef DWORD *PDWORD; +typedef float *PFLOAT; +typedef unsigned short *PWCH; +typedef unsigned short *PWORD; /* Check VOID before defining CHAR, SHORT, and LONG */ #ifndef VOID @@ -274,8 +278,6 @@ typedef BYTE *PBYTE; typedef const CHAR *PCCH; typedef const char *PCSTR; typedef const unsigned short *PCWCH; -typedef DWORD *PDWORD; -typedef float *PFLOAT; /* typedef PHKEY; */ typedef int *PINT; /* typedef LCID *PLCID; */ @@ -296,8 +298,6 @@ typedef char *PTCHAR; typedef char *PTSTR; #endif /* UNICODE */ -typedef unsigned short *PWCH; -typedef unsigned short *PWORD; /* typedef PWSTR; typedef REGSAM; diff --git a/reactos/include/conio.h b/reactos/include/conio.h deleted file mode 100644 index 4430f8e25d9..00000000000 --- a/reactos/include/conio.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * conio.h - * - * Low level console I/O functions. Pretty please try to use the ANSI - * standard ones if you are writing new code. - * - * This file is part of the Mingw32 package. - * - * Contributors: - * Created by Colin Peters - * - * THIS SOFTWARE IS NOT COPYRIGHTED - * - * This source code is offered for use in the public domain. You may - * use, modify or distribute it freely. - * - * This code is distributed in the hope that it will be useful but - * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY - * DISCLAMED. This includes but is not limited to warranties of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * $Revision: 1.4 $ - * $Author: ariadne $ - * $Date: 1999/02/25 22:51:47 $ - * - */ - -#ifndef __STRICT_ANSI__ - -#ifndef _CONIO_H_ -#define _CONIO_H_ - -#ifdef __cplusplus -extern "C" { -#endif - - -char* _cgets (char* szBuffer); -int _cprintf (const char* szFormat, ...); -int _cputs (const char* szString); -int _cscanf (char* szFormat, ...); - -int _getch (void); -int _getche (void); -int _kbhit (void); -int _putch (int cPut); -int _ungetch (int cUnget); - - -#ifndef _NO_OLDNAMES - -#define getch _getch -#define getche _getche -#define kbhit _kbhit -#define putch _putch -#define ungetch _ungetch - -#endif /* Not _NO_OLDNAMES */ - - -#ifdef __cplusplus -} -#endif - -#endif /* Not _CONIO_H_ */ - -#endif /* Not __STRICT_ANSI__ */ diff --git a/reactos/include/assert.h b/reactos/include/crtdll/assert.h similarity index 94% rename from reactos/include/assert.h rename to reactos/include/crtdll/assert.h index 55d3eb1a403..f90a1242c61 100644 --- a/reactos/include/assert.h +++ b/reactos/include/crtdll/assert.h @@ -18,9 +18,9 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.1 $ - * $Author: ariadne $ - * $Date: 1999/02/25 22:51:47 $ + * $Revision: 1.2 $ + * $Author: rex $ + * $Date: 1999/03/19 05:55:07 $ * */ diff --git a/reactos/include/crtdll/conio.h b/reactos/include/crtdll/conio.h new file mode 100644 index 00000000000..3c0b26be697 --- /dev/null +++ b/reactos/include/crtdll/conio.h @@ -0,0 +1,111 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_conio_h_ +#define __dj_include_conio_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + + +extern int directvideo; /* ignored by gppconio */ +extern int _wscroll; + +#define _NOCURSOR 0 +#define _SOLIDCURSOR 1 +#define _NORMALCURSOR 2 + +struct text_info { + unsigned char winleft; + unsigned char wintop; + unsigned char winright; + unsigned char winbottom; + unsigned char attribute; + unsigned char normattr; + unsigned char currmode; + unsigned char screenheight; + unsigned char screenwidth; + unsigned char curx; + unsigned char cury; +}; + +enum text_modes { LASTMODE=-1, BW40=0, C40, BW80, C80, MONO=7, C4350=64 }; + +enum COLORS { + /* dark colors */ + BLACK, + BLUE, + GREEN, + CYAN, + RED, + MAGENTA, + BROWN, + LIGHTGRAY, + /* light colors */ + DARKGRAY, + LIGHTBLUE, + LIGHTGREEN, + LIGHTCYAN, + LIGHTRED, + LIGHTMAGENTA, + YELLOW, + WHITE +}; + +#define BLINK 0x80 /* blink bit */ + +void blinkvideo(void); +char * cgets(char *_str); +void clreol(void); +void clrscr(void); +int _conio_kbhit(void); /* checks for ungetch char */ +//int cprintf(const char *_format, ...) __attribute__((format(printf,1,2))); +int cputs(const char *_str); +//int cscanf(const char *_format, ...) __attribute__((format(scanf,1,2))); +void delline(void); +int getch(void); +int getche(void); +int gettext(int _left, int _top, int _right, int _bottom, void *_destin); +void gettextinfo(struct text_info *_r); +void gotoxy(int _x, int _y); +void gppconio_init(void); +void highvideo(void); +void insline(void); +void intensevideo(void); +void lowvideo(void); +int movetext(int _left, int _top, int _right, int _bottom, int _destleft, int _desttop); +void normvideo(void); +int putch(int _c); +int puttext(int _left, int _top, int _right, int _bottom, void *_source); +void _setcursortype(int _type); +void _set_screen_lines(int _nlines); +void textattr(int _attr); +void textbackground(int _color); +void textcolor(int _color); +void textmode(int _mode); +int ungetch(int); +unsigned int wherex(void); +unsigned int wherey(void); +void window(int _left, int _top, int _right, int _bottom); + +#define kbhit _conio_kbhit /* Who ever includes gppconio.h probably + also wants _conio_kbhit and not kbhit + from libc */ + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_conio_h_ */ diff --git a/reactos/include/ctype.h b/reactos/include/crtdll/ctype.h similarity index 74% rename from reactos/include/ctype.h rename to reactos/include/crtdll/ctype.h index 869d52290f4..b09105cb47b 100644 --- a/reactos/include/ctype.h +++ b/reactos/include/crtdll/ctype.h @@ -19,8 +19,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * $Revision: 1.2 $ - * $Author: ariadne $ - * $Date: 1999/03/07 13:35:10 $ + * $Author: rex $ + * $Date: 1999/03/19 05:55:07 $ * */ #ifndef _LINUX_CTYPE_H @@ -50,10 +50,18 @@ #define _ALPHA 0x0103 -// additionally defined -#define _PRINT 0x0200 -#define _GRAPH 0x0400 - +/* from DJGPP, see appropriate licence */ +#define __dj_ISALNUM 0x0001 +#define __dj_ISALPHA 0x0002 +#define __dj_ISCNTRL 0x0004 +#define __dj_ISDIGIT 0x0008 +#define __dj_ISGRAPH 0x0010 +#define __dj_ISLOWER 0x0020 +#define __dj_ISPRINT 0x0040 +#define __dj_ISPUNCT 0x0080 +#define __dj_ISSPACE 0x0100 +#define __dj_ISUPPER 0x0200 +#define __dj_ISXDIGIT 0x0400 #ifdef __cplusplus extern "C" { @@ -72,7 +80,7 @@ int isupper(int c); int isxdigit(int c); #ifndef __STRICT_ANSI__ -int _isctype (unsigned char c, int ctypeFlags); +int _isctype (unsigned int c, int ctypeFlags); #endif int tolower(int c); @@ -103,20 +111,20 @@ int _toupper(int c); typedef int wctype_t; /* Wide character equivalents */ -int iswalnum(int wc); -int iswalpha(int wc); -int iswascii(int wc); -int iswcntrl(int wc); -int iswctype(unsigned short wc, int wctypeFlags); -int is_wctype(unsigned short wc, int wctypeFlags); /* Obsolete! */ -int iswdigit(int wc); -int iswgraph(int wc); -int iswlower(int wc); -int iswprint(int wc); -int iswpunct(int wc); -int iswspace(int wc); -int iswupper(int wc); -int iswxdigit(int wc); +int iswalnum(wint_t wc); +int iswalpha(wint_t wc); +int iswascii(wint_t wc); +int iswcntrl(wint_t wc); +int iswctype(wint_t wc, wctype_t wctypeFlags); +int is_wctype(wint_t wc, wctype_t wctypeFlags); /* Obsolete! */ +int iswdigit(wint_t wc); +int iswgraph(wint_t wc); +int iswlower(wint_t wc); +int iswprint(wint_t wc); +int iswpunct(wint_t wc); +int iswspace(wint_t wc); +int iswupper(wint_t wc); +int iswxdigit(wint_t wc); wchar_t towlower(wchar_t c); wchar_t towupper(wchar_t c); @@ -130,10 +138,10 @@ int __iscsymf (int c); /* Valid first character in C symbol */ int __iscsym (int c); /* Valid character in C symbol (after first) */ #ifndef _NO_OLDNAMES -#define isascii(c) (!((c)&(~0x7f))) -#define toascii(c) ((unsigned)(c) &0x7F) -#define iscsymf(c) (isalpha(c) || ( c == '_' )) -#define iscsym(c) (isalnum(c) || ( c == '_' )) +int isascii (int c); +int toascii (int c); +int iscsymf (int c); +int iscsym (int c); #endif /* Not _NO_OLDNAMES */ #endif /* Not __STRICT_ANSI__ */ diff --git a/reactos/include/dir.h b/reactos/include/crtdll/dir.h similarity index 97% rename from reactos/include/dir.h rename to reactos/include/crtdll/dir.h index 23f2490f4d5..6e873768a75 100644 --- a/reactos/include/dir.h +++ b/reactos/include/crtdll/dir.h @@ -18,9 +18,9 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.1 $ - * $Author: ariadne $ - * $Date: 1999/02/25 22:51:47 $ + * $Revision: 1.2 $ + * $Author: rex $ + * $Date: 1999/03/19 05:55:07 $ * */ diff --git a/reactos/include/crtdll/direct.h b/reactos/include/crtdll/direct.h new file mode 100644 index 00000000000..49dc129b68c --- /dev/null +++ b/reactos/include/crtdll/direct.h @@ -0,0 +1,27 @@ +#ifndef __include_direct_h_ +#define __include_direct_h_ + +struct _diskfree_t { + unsigned short total_clusters; + unsigned short avail_clusters; + unsigned short sectors_per_cluster; + unsigned short bytes_per_sector; +}; + + +int _chdrive( int drive ); +int _getdrive( void ); +char *_getcwd( char *buffer, int maxlen ); + +int _chdir(const char *_path); +char *_getcwd(char *, int); +int _mkdir(const char *_path); +int _rmdir(const char *_path); +unsigned int _getdiskfree(unsigned int _drive, struct _diskfree_t *_diskspace); +#define chdir _chdir +#define getcwd _getcwd +#define mkdir _mkdir +#define rmdir _rmdir + + +#endif diff --git a/reactos/include/dirent.h b/reactos/include/crtdll/dirent.h similarity index 94% rename from reactos/include/dirent.h rename to reactos/include/crtdll/dirent.h index af876a5e229..93e541d6e11 100644 --- a/reactos/include/dirent.h +++ b/reactos/include/crtdll/dirent.h @@ -14,9 +14,9 @@ * DISCLAMED. This includeds but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.1 $ - * $Author: ariadne $ - * $Date: 1999/02/25 22:51:47 $ + * $Revision: 1.2 $ + * $Author: rex $ + * $Date: 1999/03/19 05:55:07 $ * */ diff --git a/reactos/include/crtdll/dos.h b/reactos/include/crtdll/dos.h new file mode 100644 index 00000000000..92670be4de9 --- /dev/null +++ b/reactos/include/crtdll/dos.h @@ -0,0 +1,158 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_h_ +#define __dj_include_h_ + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + + + +struct ftime { + unsigned ft_tsec:5; /* 0-29, double to get real seconds */ + unsigned ft_min:6; /* 0-59 */ + unsigned ft_hour:5; /* 0-23 */ + unsigned ft_day:5; /* 1-31 */ + unsigned ft_month:4; /* 1-12 */ + unsigned ft_year:7; /* since 1980 */ +}; + +struct date { + short da_year; + char da_day; + char da_mon; +}; + +struct time { + unsigned char ti_min; + unsigned char ti_hour; + unsigned char ti_hund; + unsigned char ti_sec; +}; + +struct dfree { + unsigned df_avail; + unsigned df_total; + unsigned df_bsec; + unsigned df_sclus; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +extern unsigned short _osmajor, _osminor; +extern const char * _os_flavor; + +unsigned short _get_version(int); + + + + +int getftime(int handle, struct ftime *ftimep); +int setftime(int handle, struct ftime *ftimep); + +int getcbrk(void); +int setcbrk(int new_value); + +void getdate(struct date *); +void gettime(struct time *); +void setdate(struct date *); +void settime(struct time *); + +void getdfree(unsigned char drive, struct dfree *ptr); + +void delay(unsigned msec); +/* int _get_default_drive(void); +void _fixpath(const char *, char *); */ + + +/* + * For compatibility with other DOS C compilers. + */ + +#define _A_NORMAL 0x00 /* Normal file - No read/write restrictions */ +#define _A_RDONLY 0x01 /* Read only file */ +#define _A_HIDDEN 0x02 /* Hidden file */ +#define _A_SYSTEM 0x04 /* System file */ +#define _A_VOLID 0x08 /* Volume ID file */ +#define _A_SUBDIR 0x10 /* Subdirectory */ +#define _A_ARCH 0x20 /* Archive file */ + +#define _enable enable +#define _disable disable + +struct date_t { + unsigned char day; /* 1-31 */ + unsigned char month; /* 1-12 */ + unsigned short year; /* 1980-2099 */ + unsigned char dayofweek; /* 0-6, 0=Sunday */ +}; +#define dosdate_t date_t + +struct time_t { + unsigned char hour; /* 0-23 */ + unsigned char minute; /* 0-59 */ + unsigned char second; /* 0-59 */ + unsigned char hsecond; /* 0-99 */ +}; +#define dostime_t time_t + + + +#define finddata_t _finddata_t + + +#define diskfree_t _diskfree_t + +struct _DOSERROR { + int exterror; + #ifdef __cplusplus + char errclass; + #else + char class; + #endif + char action; + char locus; +}; +#define DOSERROR _DOSERROR + + + + +void _getdate(struct date_t *_date); +unsigned int _setdate(struct date_t *_date); +void _gettime(struct time_t *_time); +unsigned int _settime(struct time_t *_time); + +unsigned int _getftime(int _handle, unsigned int *_p_date, unsigned int *_p_time); +unsigned int _setftime(int _handle, unsigned int _date, unsigned int _time); +unsigned int _getfileattr(const char *_filename, unsigned int *_p_attr); +unsigned int _setfileattr(const char *_filename, unsigned int _attr); + + +void _setdrive(unsigned int _drive, unsigned int *_p_drives); + + +int exterr(struct _DOSERROR *_p_error); +#define dosexterr(_ep) exterr(_ep) + +#include + +#define int386(_i, _ir, _or) int86(_i, _ir, _or) +#define int386x(_i, _ir, _or, _sr) int86x(_i, _ir, _or, _sr) + +#ifdef __cplusplus +} +#endif + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#endif /* !__dj_include_h_ */ diff --git a/reactos/include/errno.h b/reactos/include/crtdll/errno.h similarity index 96% rename from reactos/include/errno.h rename to reactos/include/crtdll/errno.h index e9664efb664..b68c1f85f12 100644 --- a/reactos/include/errno.h +++ b/reactos/include/crtdll/errno.h @@ -18,9 +18,9 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.1 $ - * $Author: ariadne $ - * $Date: 1999/02/25 22:51:47 $ + * $Revision: 1.2 $ + * $Author: rex $ + * $Date: 1999/03/19 05:55:07 $ * */ @@ -96,10 +96,10 @@ extern "C" { * sys_errlist. */ int* _errno(void); -#define errno (*_errno(void)) +#define errno (*_errno()) int* __doserrno(void); -#define _doserrno (*__doserrno(void)) +#define _doserrno (*__doserrno()) #if __MSVCRT__ /* One of the MSVCRTxx libraries */ diff --git a/reactos/include/crtdll/fcntl.h b/reactos/include/crtdll/fcntl.h new file mode 100644 index 00000000000..d6f772ab32e --- /dev/null +++ b/reactos/include/crtdll/fcntl.h @@ -0,0 +1,164 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_fcntl_h_ +#define __dj_include_fcntl_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define _IOREAD 000010 +#define _IOWRT 000020 +#define _IOMYBUF 000040 +#define _IOEOF 000100 +#define _IOERR 000200 +#define _IOSTRG 000400 +#define _IORW 001000 +#define _IOAPPEND 002000 +#define _IORMONCL 004000 /* remove on close, for temp files */ +/* if _flag & _IORMONCL, ._name_to_remove needs freeing */ +#define _IOUNGETC 010000 /* there is an ungetc'ed character in the buffer */ + + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#define FD_CLOEXEC 0x0001 + +#define F_DUPFD 1 +#define F_GETFD 2 +#define F_GETFL 3 +#define F_GETLK 4 +#define F_SETFD 5 +#define F_SETFL 6 +#define F_SETLK 7 +#define F_SETLKW 8 + +#define F_UNLCK 0 +#define F_RDLCK 1 +#define F_WRLCK 2 + +#define O_RDONLY 0x0000 +#define O_WRONLY 0x0001 +#define O_RDWR 0x0002 +#define O_ACCMODE 0x0003 + +#define O_BINARY 0x0004 /* must fit in char, reserved by dos */ +#define O_TEXT 0x0008 /* must fit in char, reserved by dos */ + +#define O_RANDOM 0x0010 +#define O_SEQUENTIAL 0x0020 + + +#define O_TEMPORARY 0x0040 + +/* temporary access hint */ + + + +/* sequential/random access hints */ + + + + +#define O_NOINHERIT 0x0080 /* DOS-specific */ + +#define O_CREAT 0x0100 /* second byte, away from DOS bits */ +#define O_EXCL 0x0200 +#define O_NOCTTY 0x0400 +#define O_TRUNC 0x0800 +#define O_APPEND 0x1000 +#define O_NONBLOCK 0x2000 + +#define O_SHORT_LIVED 0x1000 + +//#include +#include + +//typedef int dev_t; +//typedef int ino_t; +//typedef int mode_t; +//typedef int nlink_t; + +#include + + +struct flock { + off_t l_len; + pid_t l_pid; + off_t l_start; + short l_type; + short l_whence; +}; + +extern int _fmode; /* O_TEXT or O_BINARY */ + +//int open(const char *_path, int _oflag, ...); +//int creat(const char *_path, int _mode); +int fcntl(int _fildes, int _cmd, ...); + +#ifndef _POSIX_SOURCE + + +#define S_IREAD S_IRUSR +#define S_IWRITE S_IWUSR +#define S_IEXEC S_IXUSR + +/* + * For compatibility with other DOS C compilers. + */ + +#define _O_RDONLY O_RDONLY +#define _O_WRONLY O_WRONLY +#define _O_RDWR O_RDWR +#define _O_APPEND O_APPEND +#define _O_CREAT O_CREAT +#define _O_TRUNC O_TRUNC +#define _O_EXCL O_EXCL +#define _O_TEXT O_TEXT +#define _O_BINARY O_BINARY +#define _O_NOINHERIT O_NOINHERIT +#define _O_RANDOM O_RANDOM +#define _O_SEQUENTIAL O_RANDOM +#define _O_SHORT_LIVED O_SHORT_LIVED +#define _O_TEMPORARY O_TEMPORARY + +#define _S_IREAD S_IRUSR +#define _S_IWRITE S_IWUSR +#define _S_IEXEC S_IXUSR + +/* + * Support for advanced filesystems (Windows 9x VFAT, NTFS, LFN etc.) + */ + +#define _FILESYS_UNKNOWN 0x80000000U +#define _FILESYS_CASE_SENSITIVE 0x0001 +#define _FILESYS_CASE_PRESERVED 0x0002 +#define _FILESYS_UNICODE 0x0004 +#define _FILESYS_LFN_SUPPORTED 0x4000 +#define _FILESYS_VOL_COMPRESSED 0x8000 + +unsigned _get_volume_info (const char *_path, int *_max_file_len, int *_max_path_len, char *_filesystype); +char _use_lfn (const char *_path); +char *_lfn_gen_short_fname (const char *_long_fname, char *_short_fname); + +#define _LFN_CTIME 1 +#define _LFN_ATIME 2 + +unsigned _lfn_get_ftime (int _handle, int _which); + +char _preserve_fncase (void); +#define _USE_LFN _use_lfn(0) /* assume it's the same on ALL drives */ + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_fcntl_h_ */ diff --git a/reactos/include/float.h b/reactos/include/crtdll/float.h similarity index 95% rename from reactos/include/float.h rename to reactos/include/crtdll/float.h index f4ffc88d4b7..d919986c0be 100644 --- a/reactos/include/float.h +++ b/reactos/include/crtdll/float.h @@ -28,8 +28,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * $Revision: 1.2 $ - * $Author: ariadne $ - * $Date: 1999/03/07 13:35:10 $ + * $Author: rex $ + * $Date: 1999/03/19 05:55:07 $ * */ @@ -146,15 +146,15 @@ unsigned int _controlfp (unsigned int unNew, unsigned int unMask); unsigned int _control87 (unsigned int unNew, unsigned int unMask); -unsigned int _clearfp (void); /* Clear the FPU status word */ -unsigned int _statusfp (void); /* Report the FPU status word */ +unsigned int _clearfp (); /* Clear the FPU status word */ +unsigned int _statusfp (); /* Report the FPU status word */ #define _clear87 _clearfp #define _status87 _statusfp -void _fpreset (void); /* Reset the FPU */ +void _fpreset (); /* Reset the FPU */ /* Global 'variable' for the current floating point error code. */ -int * __fpecode(void); +int * __fpecode(); #define _fpecode (*(__fpecode())) /* diff --git a/reactos/include/io.h b/reactos/include/crtdll/io.h similarity index 98% rename from reactos/include/io.h rename to reactos/include/crtdll/io.h index bf47939ae09..3b35717e317 100644 --- a/reactos/include/io.h +++ b/reactos/include/crtdll/io.h @@ -18,9 +18,9 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.5 $ - * $Author: ariadne $ - * $Date: 1999/03/07 13:35:10 $ + * $Revision: 1.2 $ + * $Author: rex $ + * $Date: 1999/03/19 05:55:07 $ * */ /* Appropriated for Reactos Crtdll by Ariadne */ diff --git a/reactos/include/math.h b/reactos/include/crtdll/math.h similarity index 97% rename from reactos/include/math.h rename to reactos/include/crtdll/math.h index 73300e30605..c028ed8d6b5 100644 --- a/reactos/include/math.h +++ b/reactos/include/crtdll/math.h @@ -18,9 +18,9 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.1 $ - * $Author: ariadne $ - * $Date: 1999/02/25 22:51:47 $ + * $Revision: 1.2 $ + * $Author: rex $ + * $Date: 1999/03/19 05:55:07 $ * */ diff --git a/reactos/include/process.h b/reactos/include/crtdll/process.h similarity index 98% rename from reactos/include/process.h rename to reactos/include/crtdll/process.h index b554851bb81..60760a11cfa 100644 --- a/reactos/include/process.h +++ b/reactos/include/crtdll/process.h @@ -18,9 +18,9 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.3 $ - * $Author: ariadne $ - * $Date: 1999/03/07 13:35:10 $ + * $Revision: 1.2 $ + * $Author: rex $ + * $Date: 1999/03/19 05:55:09 $ * */ /* Appropriated for Reactos Crtdll by Ariadne */ diff --git a/reactos/include/share.h b/reactos/include/crtdll/share.h similarity index 97% rename from reactos/include/share.h rename to reactos/include/crtdll/share.h index c6087e177af..8e3af3f29ed 100644 --- a/reactos/include/share.h +++ b/reactos/include/crtdll/share.h @@ -14,4 +14,4 @@ #define _SH_DENYRD SH_DENYRD #define _SH_DENYNO SH_DENYNO -#endif \ No newline at end of file +#endif diff --git a/reactos/include/signal.h b/reactos/include/crtdll/signal.h similarity index 98% rename from reactos/include/signal.h rename to reactos/include/crtdll/signal.h index 17f9b0f388f..07ecbf90b91 100644 --- a/reactos/include/signal.h +++ b/reactos/include/crtdll/signal.h @@ -19,8 +19,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * $Revision: 1.2 $ - * $Author: ariadne $ - * $Date: 1999/03/07 13:35:10 $ + * $Author: rex $ + * $Date: 1999/03/19 05:55:09 $ * */ /* added some extra signal constants */ diff --git a/reactos/include/stdarg.h b/reactos/include/crtdll/stdarg.h similarity index 97% rename from reactos/include/stdarg.h rename to reactos/include/crtdll/stdarg.h index 617a3e4265d..5fe01725d47 100644 --- a/reactos/include/stdarg.h +++ b/reactos/include/crtdll/stdarg.h @@ -26,9 +26,9 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.1 $ - * $Author: ariadne $ - * $Date: 1999/02/21 13:29:56 $ + * $Revision: 1.2 $ + * $Author: rex $ + * $Date: 1999/03/19 05:55:09 $ * */ /* Appropriated for Reactos Crtdll by Ariadne */ diff --git a/reactos/include/stddef.h b/reactos/include/crtdll/stddef.h similarity index 98% rename from reactos/include/stddef.h rename to reactos/include/crtdll/stddef.h index 12787a4502c..602dde00f2f 100644 --- a/reactos/include/stddef.h +++ b/reactos/include/crtdll/stddef.h @@ -28,9 +28,9 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.3 $ - * $Author: ariadne $ - * $Date: 1999/02/21 20:59:55 $ + * $Revision: 1.2 $ + * $Author: rex $ + * $Date: 1999/03/19 05:55:09 $ * */ diff --git a/reactos/include/crtdll/stdio.h b/reactos/include/crtdll/stdio.h new file mode 100644 index 00000000000..85f4ef8d75b --- /dev/null +++ b/reactos/include/crtdll/stdio.h @@ -0,0 +1,157 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ + +#ifndef __dj_include_stdio_h_ +#define __dj_include_stdio_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#include + +#define _IOFBF 00001 +#define _IONBF 00002 +#define _IOLBF 00004 + +#define BUFSIZ 16384 +#define EOF (-1) +#define FILENAME_MAX 260 +#define FOPEN_MAX 20 +#define L_tmpnam 260 +#ifndef NULL +#define NULL 0 +#endif +#define TMP_MAX 999999 + +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + +#define _IOREAD 000010 +#define _IOWRT 000020 +#define _IOMYBUF 000040 +#define _IOEOF 000100 +#define _IOERR 000200 +#define _IOSTRG 000400 +#define _IORW 001000 +#define _IOAPPEND 002000 +#define _IORMONCL 004000 /* remove on close, for temp files */ +/* if _flag & _IORMONCL, ._name_to_remove needs freeing */ +#define _IOUNGETC 010000 /* there is an ungetc'ed character in the buffer */ + + +#include + +__DJ_va_list +#undef __DJ_va_list +#define __DJ_va_list + +#ifndef _FILE_DEFINED +typedef struct { + char *_ptr; + int _cnt; + char *_base; + int _flag; + int _file; + int _ungotchar; + int _bufsiz; + char *_name_to_remove; +} FILE; +#define _FILE_DEFINED +#endif + +typedef unsigned long fpos_t; + +extern FILE _iob[]; + +#define stdin (&_iob[0]) +#define stdout (&_iob[1]) +#define stderr (&_iob[2]) +#define stdaux (&_iob[3]) +#define stdprn (&_iob[4]) + +void clearerr(FILE *_stream); +int fclose(FILE *_stream); +int feof(FILE *_stream); +int ferror(FILE *_stream); +int fflush(FILE *_stream); +int fgetc(FILE *_stream); +int fgetpos(FILE *_stream, fpos_t *_pos); +char * fgets(char *_s, int _n, FILE *_stream); +FILE * fopen(const char *_filename, const char *_mode); +int fprintf(FILE *_stream, const char *_format, ...); +int fputc(int _c, FILE *_stream); +int fputs(const char *_s, FILE *_stream); +size_t fread(void *_ptr, size_t _size, size_t _nelem, FILE *_stream); +FILE * freopen(const char *_filename, const char *_mode, FILE *_stream); +int fscanf(FILE *_stream, const char *_format, ...); +int fseek(FILE *_stream, long _offset, int _mode); +int fsetpos(FILE *_stream, const fpos_t *_pos); +long ftell(FILE *_stream); +size_t fwrite(const void *_ptr, size_t _size, size_t _nelem, FILE *_stream); +int getc(FILE *_stream); +int getchar(void); +char * gets(char *_s); +void perror(const char *_s); +int printf(const char *_format, ...); +int putc(int _c, FILE *_stream); +int putchar(int _c); +int puts(const char *_s); +int remove(const char *_filename); +int rename(const char *_old, const char *_new); +void rewind(FILE *_stream); +int scanf(const char *_format, ...); +void setbuf(FILE *_stream, char *_buf); +int setvbuf(FILE *_stream, char *_buf, int _mode, size_t _size); +int sprintf(char *_s, const char *_format, ...); +int sscanf(const char *_s, const char *_format, ...); +FILE * tmpfile(void); +char * tmpnam(char *_s); +char * _tmpnam(char *_s); +int ungetc(int _c, FILE *_stream); +int vfprintf(FILE *_stream, const char *_format, va_list _ap); +int vprintf(const char *_format, va_list _ap); +int vsprintf(char *_s, const char *_format, va_list _ap); + +#ifndef __STRICT_ANSI__ + +#define L_ctermid +#define L_cusrid +/* #define STREAM_MAX 20 - DOS can change this */ + +int fileno(FILE *_stream); +int _fileno(FILE *_stream); +FILE * fdopen(int _fildes, const char *_type); +int pclose(FILE *_pf); +FILE * popen(const char *_command, const char *_mode); + +#ifndef _POSIX_SOURCE + +void _djstat_describe_lossage(FILE *_to_where); +int _doprnt(const char *_fmt, va_list _args, FILE *_f); +int _doscan(FILE *_f, const char *_fmt, void **_argp); +int _doscan_low(FILE *, int (*)(FILE *_get), int (*_unget)(int, FILE *), const char *_fmt, void **_argp); +int fpurge(FILE *_f); +int getw(FILE *_f); +int mkstemp(char *_template); +char * mktemp(char *_template); +int putw(int _v, FILE *_f); +void setbuffer(FILE *_f, void *_buf, int _size); +void setlinebuf(FILE *_f); +char * tempnam(const char *_dir, const char *_prefix); +int _rename(const char *_old, const char *_new); /* Simple (no directory) */ + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_stdio_h_ */ diff --git a/reactos/include/stdlib.h b/reactos/include/crtdll/stdlib.h similarity index 98% rename from reactos/include/stdlib.h rename to reactos/include/crtdll/stdlib.h index f39b42aefe1..953255a18d2 100644 --- a/reactos/include/stdlib.h +++ b/reactos/include/crtdll/stdlib.h @@ -18,9 +18,9 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.3 $ - * $Author: ariadne $ - * $Date: 1999/02/25 22:51:47 $ + * $Revision: 1.2 $ + * $Author: rex $ + * $Date: 1999/03/19 05:55:09 $ * */ /* Appropriated for Reactos Crtdll by Ariadne */ diff --git a/reactos/include/sys/djtypes.h b/reactos/include/crtdll/sys/djtypes.h similarity index 100% rename from reactos/include/sys/djtypes.h rename to reactos/include/crtdll/sys/djtypes.h diff --git a/reactos/include/crtdll/sys/stat.h b/reactos/include/crtdll/sys/stat.h new file mode 100644 index 00000000000..134fd7c9c55 --- /dev/null +++ b/reactos/include/crtdll/sys/stat.h @@ -0,0 +1,128 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_stat_h_ +#define __dj_include_sys_stat_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#define S_ISBLK(m) (((m) & 0xf000) == 0x1000) +#define S_ISCHR(m) (((m) & 0xf000) == 0x2000) +#define S_ISDIR(m) (((m) & 0xf000) == 0x3000) +#define S_ISFIFO(m) (((m) & 0xf000) == 0x4000) +#define S_ISREG(m) (((m) & 0xf000) == 0x0000) + +#define S_ISUID 0x80000000 +#define S_ISGID 0x40000000 + +#define S_IRUSR 00400 +#define S_IRGRP 00040 +#define S_IROTH 00004 +#define S_IWUSR 00200 +#define S_IWGRP 00020 +#define S_IWOTH 00002 +#define S_IXUSR 00100 +#define S_IXGRP 00010 +#define S_IXOTH 00001 +#define S_IRWXU 00700 +#define S_IRWXG 00070 +#define S_IRWXO 00007 + +#include +#include +//#include +__DJ_time_t +#undef __DJ_time_t +#define __DJ_time_t + +struct stat { + time_t st_atime; + time_t st_ctime; + dev_t st_dev; + gid_t st_gid; + ino_t st_ino; + mode_t st_mode; + time_t st_mtime; + nlink_t st_nlink; + off_t st_size; + off_t st_blksize; + uid_t st_uid; + dev_t st_rdev; /* unused */ +}; + +int chmod(const char *_path, mode_t _mode); +int fstat(int _fildes, struct stat *_buf); +//int mkdir(const char *_path, mode_t _mode); +int mkfifo(const char *_path, mode_t _mode); +int stat(const char *_path, struct stat *_buf); +mode_t umask(mode_t _cmask); + +#ifndef _POSIX_SOURCE + +/* POSIX.1 doesn't mention these at all */ + +#define S_IFMT 0xf000 + +#define S_IFREG 0x0000 +#define S_IFBLK 0x1000 +#define S_IFCHR 0x2000 +#define S_IFDIR 0x3000 +#define S_IFIFO 0x4000 +#define S_IFFIFO S_IFIFO + +#define S_IFLABEL 0x5000 +#define S_ISLABEL(m) (((m) & 0xf000) == 0x5000) + +void _fixpath(const char *, char *); +unsigned short _get_magic(const char *, int); +int _is_executable(const char *, int, const char *); +int mknod(const char *_path, mode_t _mode, dev_t _dev); +char * _truename(const char *, char *); + +/* Bit-mapped variable _djstat_flags describes what expensive + f?stat() features our application needs. If you don't need a + feature, set its bit in the variable. By default, all the + bits are cleared (i.e., you get the most expensive code). */ +#define _STAT_INODE 1 /* should we bother getting inode numbers? */ +#define _STAT_EXEC_EXT 2 /* get execute bits from file extension? */ +#define _STAT_EXEC_MAGIC 4 /* get execute bits from magic signature? */ +#define _STAT_DIRSIZE 8 /* compute directory size? */ +#define _STAT_ROOT_TIME 0x10 /* try to get root dir time stamp? */ +#define _STAT_WRITEBIT 0x20 /* fstat() needs write bit? */ + +extern unsigned short _djstat_flags; + +/* Bit-mapped variable _djstat_fail_bits describes which individual + undocumented features f?stat() failed to use. To get a human- + readable description of the bits, call _djstat_describe_lossage(). */ +#define _STFAIL_SDA 1 /* Get SDA call failed */ +#define _STFAIL_OSVER 2 /* Unsupported DOS version */ +#define _STFAIL_BADSDA 4 /* Bad pointer to SDA */ +#define _STFAIL_TRUENAME 8 /* _truename() failed */ +#define _STFAIL_HASH 0x10 /* inode defaults to hashing */ +#define _STFAIL_LABEL 0x20 /* Root dir, but no volume label */ +#define _STFAIL_DCOUNT 0x40 /* dirent_count ridiculously large */ +#define _STFAIL_WRITEBIT 0x80 /* fstat() failed to get write access bit */ +#define _STFAIL_DEVNO 0x100 /* fstat() failed to get device number */ +#define _STFAIL_BADSFT 0x200 /* SFT entry found, but can't be trusted */ +#define _STFAIL_SFTIDX 0x400 /* bad SFT index in JFT */ +#define _STFAIL_SFTNF 0x800 /* file entry not found in SFT array */ + +extern unsigned short _djstat_fail_bits; + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_stat_h_ */ diff --git a/reactos/include/crtdll/sys/types.h b/reactos/include/crtdll/sys/types.h new file mode 100644 index 00000000000..5c5df14b3ed --- /dev/null +++ b/reactos/include/crtdll/sys/types.h @@ -0,0 +1,67 @@ +/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_types_h_ +#define __dj_include_sys_types_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#include + +typedef int dev_t; +typedef int ino_t; +typedef int mode_t; +typedef int nlink_t; + +__DJ_gid_t +#undef __DJ_gid_t +#define __DJ_gid_t +__DJ_off_t +#undef __DJ_off_t +#define __DJ_off_t +__DJ_pid_t +#undef __DJ_pid_t +#define __DJ_pid_t +//__DJ_size_t +#undef __DJ_size_t +#define __DJ_size_t +__DJ_ssize_t +#undef __DJ_ssize_t +#define __DJ_ssize_t +__DJ_uid_t +#undef __DJ_uid_t +#define __DJ_uid_t + +#ifndef _POSIX_SOURCE + +/* Allow including program to override. */ +#ifndef FD_SETSIZE +#define FD_SETSIZE 256 +#endif + +typedef struct fd_set { + unsigned char fd_bits [((FD_SETSIZE) + 7) / 8]; +} fd_set; + +#define FD_SET(n, p) ((p)->fd_bits[(n) / 8] |= (1 << ((n) & 7))) +#define FD_CLR(n, p) ((p)->fd_bits[(n) / 8] &= ~(1 << ((n) & 7))) +#define FD_ISSET(n, p) ((p)->fd_bits[(n) / 8] & (1 << ((n) & 7))) +#define FD_ZERO(p) memset ((void *)(p), 0, sizeof (*(p))) + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_types_h_ */ diff --git a/reactos/include/time.h b/reactos/include/crtdll/time.h similarity index 98% rename from reactos/include/time.h rename to reactos/include/crtdll/time.h index db6a7fdc333..e992db91fc5 100644 --- a/reactos/include/time.h +++ b/reactos/include/crtdll/time.h @@ -19,8 +19,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * $Revision: 1.2 $ - * $Author: ariadne $ - * $Date: 1999/02/21 13:29:57 $ + * $Author: rex $ + * $Date: 1999/03/19 05:55:10 $ * */ /* Appropriated for Reactos Crtdll by Ariadne */ diff --git a/reactos/include/ddk/extypes.h b/reactos/include/ddk/extypes.h index 29b3587c85b..6c1d443b412 100644 --- a/reactos/include/ddk/extypes.h +++ b/reactos/include/ddk/extypes.h @@ -1,4 +1,5 @@ +extern POBJECT_TYPE ExEventType; typedef ULONG INTERLOCKED_RESULT; typedef ULONG WORK_QUEUE_TYPE; diff --git a/reactos/include/ddk/iodef.h b/reactos/include/ddk/iodef.h index f6c05518960..431564c35dc 100644 --- a/reactos/include/ddk/iodef.h +++ b/reactos/include/ddk/iodef.h @@ -242,12 +242,6 @@ enum #define FILE_EXISTS 0x0004 #define FILE_DOES_NOT_EXIST 0x0005 -/* - * ByteOffset parameter : special values - */ - -#define FILE_WRITE_TO_END_OF_FILE 0xffffffff -#define FILE_USE_FILE_POINTER_POSITION 0xfffffffe /* * file creation flags diff --git a/reactos/include/ddk/iotypes.h b/reactos/include/ddk/iotypes.h index f899bc278d2..6ed45ec3832 100644 --- a/reactos/include/ddk/iotypes.h +++ b/reactos/include/ddk/iotypes.h @@ -152,10 +152,6 @@ typedef struct _IO_STACK_LOCATION HANDLE DeleteHandle; } u; } SetFile; - - /* - * This is a guess - */ struct { ULONG Length; @@ -175,14 +171,7 @@ typedef struct _IO_STACK_LOCATION typedef struct _IO_STATUS_BLOCK { - /* - * Is the completion status - */ NTSTATUS Status; - - /* - * Is a request dependant value - */ ULONG Information; } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; diff --git a/reactos/include/ddk/ketypes.h b/reactos/include/ddk/ketypes.h index 2138953e012..49f0cfe824f 100644 --- a/reactos/include/ddk/ketypes.h +++ b/reactos/include/ddk/ketypes.h @@ -147,13 +147,7 @@ typedef struct } KSEMAPHORE, *PKSEMAPHORE; typedef struct _KEVENT -/* - * PURPOSE: Describes an event - */ { - /* - * PURPOSE: So we can use the general wait routine - */ DISPATCHER_HEADER Header; } KEVENT, *PKEVENT; @@ -222,7 +216,7 @@ typedef struct _WAIT_CONTEXT_BLOCK struct _KINTERRUPT; typedef BOOLEAN (*PKSERVICE_ROUTINE)(struct _KINTERRUPT* Interrupt, - PVOID ServiceContext); + PVOID ServiceContext); typedef struct _KINTERRUPT { diff --git a/reactos/include/ddk/ntddk.h b/reactos/include/ddk/ntddk.h index 8cb8432ed7d..20f0b208911 100644 --- a/reactos/include/ddk/ntddk.h +++ b/reactos/include/ddk/ntddk.h @@ -38,9 +38,9 @@ extern "C" #include #include #include - #include #include + #include #include #include diff --git a/reactos/include/ddk/rtl.h b/reactos/include/ddk/rtl.h index b9ff79f87aa..308622829a5 100644 --- a/reactos/include/ddk/rtl.h +++ b/reactos/include/ddk/rtl.h @@ -280,33 +280,21 @@ typedef struct { // Heap creation routine -HANDLE -STDCALL -RtlCreateHeap( - ULONG Flags, - PVOID BaseAddress, - ULONG SizeToReserve, - ULONG SizeToCommit, - PVOID Unknown, - PRTL_HEAP_DEFINITION Definition - ); +HANDLE STDCALL RtlCreateHeap(ULONG Flags, + PVOID BaseAddress, + ULONG SizeToReserve, + ULONG SizeToCommit, + PVOID Unknown, + PRTL_HEAP_DEFINITION Definition); -PVOID -STDCALL -RtlAllocateHeap( - HANDLE Heap, - ULONG Flags, - ULONG Size - ); +PVOID STDCALL RtlAllocateHeap(HANDLE Heap, + ULONG Flags, + ULONG Size); -BOOLEAN -STDCALL -RtlFreeHeap( - HANDLE Heap, - ULONG Flags, - PVOID Address - ); +BOOLEAN STDCALL RtlFreeHeap(HANDLE Heap, + ULONG Flags, + PVOID Address); NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString, IN PUNICODE_STRING SourceString, diff --git a/reactos/include/ddk/status.h b/reactos/include/ddk/status.h index d49437619e6..6361cdebf5a 100644 --- a/reactos/include/ddk/status.h +++ b/reactos/include/ddk/status.h @@ -108,7 +108,7 @@ enum STATUS_ALREADY_DISCONNECTED, STATUS_LONGJUMP, - STATUS_UNSUCCESSFUL=0xC0000001, + STATUS_UNSUCCESSFUL=0xC0000001, STATUS_NOT_IMPLEMENTED, STATUS_INVALID_INFO_CLASS, STATUS_INFO_LENGTH_MISMATCH, @@ -123,6 +123,8 @@ enum STATUS_INVALID_PARAMETER, STATUS_NO_SUCH_DEVICE, STATUS_NO_SUCH_FILE, + +// c0000010 STATUS_INVALID_DEVICE_REQUEST, STATUS_END_OF_FILE, STATUS_WRONG_VOLUME, @@ -139,6 +141,8 @@ enum STATUS_ILLEGAL_INSTRUCTION, STATUS_INVALID_LOCK_SEQUENCE, STATUS_INVALID_VIEW_SIZE, + +// c0000020 STATUS_INVALID_FILE_FOR_SECTION, STATUS_ALREADY_COMMITTED, STATUS_ACCESS_DENIED, diff --git a/reactos/include/ddk/zw.h b/reactos/include/ddk/zw.h index 60dc6f7a318..3442d61199c 100644 --- a/reactos/include/ddk/zw.h +++ b/reactos/include/ddk/zw.h @@ -15,15 +15,11 @@ #ifndef __DDK_ZW_H #define __DDK_ZW_H + #include //#ifndef WIN32_LEAN_AND_MEAN -#define PTOKEN_USER PVOID #define PTOKEN_GROUPS PVOID -#define PTOKEN_OWNER PVOID #define PTOKEN_PRIVILEGES PVOID -#define PTOKEN_PRIMARY_GROUP PVOID -#define PTOKEN_DEFAULT_DACL PVOID -#define PTOKEN_SOURCE PVOID #define TOKEN_INFORMATION_CLASS CINT #define LCID ULONG #define SECURITY_INFORMATION ULONG @@ -325,16 +321,13 @@ NtAllocateVirtualMemory( IN ULONG Protect ); -NTSTATUS -STDCALL -ZwAllocateVirtualMemory( - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN ULONG ZeroBits, - IN OUT PULONG RegionSize, - IN ULONG AllocationType, - IN ULONG Protect - ); +NTSTATUS STDCALL ZwAllocateVirtualMemory(IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN ULONG ZeroBits, + IN OUT PULONG RegionSize, + IN ULONG AllocationType, + IN ULONG Protect); + /* * FUNCTION: Returns from a callback into user mode * ARGUMENTS: @@ -1084,63 +1077,6 @@ ZwCreateTimer( IN CINT TimerType ); -/* - * FUNCTION: Creates a token. - * ARGUMENTS: - * TokenHandle (OUT) = Caller supplied storage for the resulting handle - * DesiredAccess = Specifies the allowed or desired access to the process can - * be a combinate of STANDARD_RIGHTS_REQUIRED| .. - * ObjectAttribute = Initialized attributes for the object, contains the rootdirectory and the filename - * TokenType = - * AuthenticationId = - * ExpirationTime = - * TokenUser = - * TokenGroups = - * TokenPrivileges = - * TokenOwner = - * TokenPrimaryGroup = - * TokenDefaultDacl = - * TokenSource = - * REMARKS: - * This function does not map to a win32 function - * RETURNS: Status - */ - -NTSTATUS -STDCALL -NtCreateToken( - OUT PHANDLE TokenHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN TOKEN_TYPE TokenType, - IN PLUID AuthenticationId, - IN PLARGE_INTEGER ExpirationTime, - IN PTOKEN_USER TokenUser, - IN PTOKEN_GROUPS TokenGroups, - IN PTOKEN_PRIVILEGES TokenPrivileges, - IN PTOKEN_OWNER TokenOwner, - IN PTOKEN_PRIMARY_GROUP TokenPrimaryGroup, - IN PTOKEN_DEFAULT_DACL TokenDefaultDacl, - IN PTOKEN_SOURCE TokenSource - ); - -NTSTATUS -STDCALL -ZwCreateToken( - OUT PHANDLE TokenHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN TOKEN_TYPE TokenType, - IN PLUID AuthenticationId, - IN PLARGE_INTEGER ExpirationTime, - IN PTOKEN_USER TokenUser, - IN PTOKEN_GROUPS TokenGroups, - IN PTOKEN_PRIVILEGES TokenPrivileges, - IN PTOKEN_OWNER TokenOwner, - IN PTOKEN_PRIMARY_GROUP TokenPrimaryGroup, - IN PTOKEN_DEFAULT_DACL TokenDefaultDacl, - IN PTOKEN_SOURCE TokenSource - ); /* * FUNCTION: Returns the callers thread TEB. @@ -5137,6 +5073,7 @@ NTSTATUS STDCALL NtCompleteConnectPort(VOID); NTSTATUS STDCALL NtConnectPort(VOID); NTSTATUS STDCALL NtCreatePort(VOID); +NTSTATUS STDCALL NtCreateToken(VOID); NTSTATUS STDCALL NtGetPlugPlayEvent(VOID); NTSTATUS STDCALL NtImpersonateClientOfPort(VOID); diff --git a/reactos/include/devices.h b/reactos/include/devices.h index 5f8dd62e57d..ada5eb8c768 100644 --- a/reactos/include/devices.h +++ b/reactos/include/devices.h @@ -13,4 +13,4 @@ typedef struct PVOID DevCapsRoutine; PVOID HwSetVolume; ULONG IoMethod; -}SOUND_DEVICE_INIT; \ No newline at end of file +}SOUND_DEVICE_INIT; diff --git a/reactos/include/direct.h b/reactos/include/direct.h deleted file mode 100644 index fcd43aa2ee5..00000000000 --- a/reactos/include/direct.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * direct.h - * - * Functions for manipulating paths and directories (included from dir.h) - * plus functions for setting the current drive. - * - * This file is part of the Mingw32 package. - * - * Contributors: - * Created by Colin Peters - * - * THIS SOFTWARE IS NOT COPYRIGHTED - * - * This source code is offered for use in the public domain. You may - * use, modify or distribute it freely. - * - * This code is distributed in the hope that it will be useful but - * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY - * DISCLAMED. This includes but is not limited to warranties of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * $Revision: 1.3 $ - * $Author: ariadne $ - * $Date: 1999/02/25 22:51:47 $ - * - */ - -#ifndef __STRICT_ANSI__ - -#ifndef _DIRECT_H_ -#define _DIRECT_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct _diskfree_t { - unsigned long total_clusters; - unsigned long avail_clusters; - unsigned long sectors_per_cluster; - unsigned long bytes_per_sector; -}; -#define diskfree_t _diskfree_t - -/* - * You really shouldn't be using these. Use the Win32 API functions instead. - * However, it does make it easier to port older code. - */ - - -int _chdrive (int nDrive); -char* _getdcwd (int nDrive, char* caBuffer, int nBufLen); -unsigned int _getdiskfree(unsigned int _drive, struct _diskfree_t *_diskspace); - -#ifdef __cplusplus -} -#endif - -#endif /* Not _DIRECT_H_ */ - -#endif /* Not __STRICT_ANSI__ */ diff --git a/reactos/include/dos.h b/reactos/include/dos.h deleted file mode 100644 index 795e7a7a470..00000000000 --- a/reactos/include/dos.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * dos.h - * - * Definitions for MS-DOS interface routines - * - * This header file is meant for use with CRTDLL.DLL as included with - * Windows 95(tm) and Windows NT(tm). In conjunction with other versions - * of the standard C library things may or may not work so well. - * - * Contributors: - * Created by J.J. van der Heijden - * - * THIS SOFTWARE IS NOT COPYRIGHTED - * - * This source code is offered for use in the public domain. You may - * use, modify or distribute it freely. - * - * This code is distributed in the hope that it will be useful but - * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY - * DISCLAMED. This includes but is not limited to warranties of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef __STRICT_ANSI__ - -#ifndef _DOS_H_ -#define _DOS_H_ - -#define __need_wchar_t -#include - -/* For DOS file attributes */ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -extern char** __imp__pgmptr_dll; -#define _pgmptr (*__imp__pgmptr_dll) - -/* Wide character equivalent */ -extern wchar_t** __imp__wpgmptr_dll; -#define _wpgmptr (*__imp__wpgmptr_dll) - -/* These are obsolete, but some may find them useful */ -extern unsigned int* __imp__basemajor_dll; -extern unsigned int* __imp__baseminor_dll; -extern unsigned int* __imp__baseversion_dll; -extern unsigned int* __imp__osmajor_dll; -extern unsigned int* __imp__osminor_dll; -extern unsigned int* __imp__osversion_dll; - -#define _basemajor (*__imp__basemajor_dll) -#define _baseminor (*__imp__baseminor_dll) -#define _baseversion (*__imp__baseversion_dll) -#define _osmajor (*__imp__osmajor_dll) -#define _osminor (*__imp__osminor_dll) -#define _osversion (*__imp__osversion_dll) - -#ifdef __cplusplus -} -#endif - -#endif /* _DOS_H_ */ - -#endif /* Not __STRICT_ANSI__ */ - diff --git a/reactos/include/fcntl.h b/reactos/include/fcntl.h deleted file mode 100644 index d8c650ebf04..00000000000 --- a/reactos/include/fcntl.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * fcntl.h - * - * Access constants for _open. Note that the permissions constants are - * in sys/stat.h (ick). - * - * This code is part of the Mingw32 package. - * - * Contributors: - * Created by Colin Peters - * - * THIS SOFTWARE IS NOT COPYRIGHTED - * - * This source code is offered for use in the public domain. You may - * use, modify or distribute it freely. - * - * This code is distributed in the hope that it will be useful but - * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY - * DISCLAMED. This includes but is not limited to warranties of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * $Revision: 1.2 $ - * $Author: ariadne $ - * $Date: 1999/02/21 13:29:56 $ - * - */ -/* Appropriated for Reactos Crtdll by Ariadne */ -/* added _O_RANDOM_O_SEQUENTIAL _O_SHORT_LIVED*/ -#ifndef _FCNTL_H_ -#define _FCNTL_H_ - -/* - * It appears that fcntl.h should include io.h for compatibility... - */ -#include - -/* - * This variable determines the default file mode. - * TODO: Which flags work? - */ -#if __MSVCRT__ -extern unsigned int* __imp__fmode; -#define _fmode (*__imp__fmode) -#else -/* CRTDLL */ -extern unsigned int* __imp__fmode_dll; -#define _fmode (*__imp__fmode_dll) -#endif - -/* Specifiy one of these flags to define the access mode. */ -#define _O_RDONLY 0 -#define _O_WRONLY 1 -#define _O_RDWR 2 - -/* Mask for access mode bits in the _open flags. */ -#define _O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) - -#define _O_APPEND 0x0008 /* Writes will add to the end of the file. */ -#define _O_CREAT 0x0100 /* Create the file if it does not exist. */ -#define _O_TRUNC 0x0200 /* Truncate the file if it does exist. */ -#define _O_EXCL 0x0400 /* Open only if the file does not exist. */ - -/* NOTE: Text is the default even if the given _O_TEXT bit is not on. */ -#define _O_TEXT 0x4000 /* CR-LF in file becomes LF in memory. */ -#define _O_BINARY 0x8000 /* Input and output is not translated. */ -#define _O_RAW _O_BINARY - -#define _O_TEMPORARY 0x0040 /* Make the file dissappear after closing. - * WARNING: Even if not created by _open! */ - - -#define _O_RANDOM 0x0010 -#define _O_SEQUENTIAL _O_RANDOM -#define _O_SHORT_LIVED 0x1000 - -#ifndef __STRICT_ANSI__ -#ifndef _NO_OLDNAMES - -/* POSIX/Non-ANSI names for increased portability */ -#define O_RDONLY _O_RDONLY -#define O_WRONLY _O_WRONLY -#define O_RDWR _O_RDWR -#define O_ACCMODE _O_ACCMODE -#define O_APPEND _O_APPEND -#define O_CREAT _O_CREAT -#define O_TRUNC _O_TRUNC -#define O_EXCL _O_EXCL -#define O_TEXT _O_TEXT -#define O_BINARY _O_BINARY -#define O_TEMPORARY _O_TEMPORARY - -#define O_RANDOM _O_RANDOM -#define O_SEQUENTIAL _O_RANDOM -#define O_SHORT_LIVED _O_SHORT_LIVED - -#endif /* Not _NO_OLDNAMES */ - -#ifdef __cplusplus -extern "C" { -#endif - -int _setmode (int nHandle, int nAccessMode); - -#ifndef _NO_OLDNAMES -int setmode (int nHandle, int nAccessMode); -#endif /* Not _NO_OLDNAMES */ - -#ifdef __cplusplus -} -#endif - -#endif /* Not __STRICT_ANSI__ */ -#endif /* Not _FCNTL_H_ */ diff --git a/reactos/include/funcs.h b/reactos/include/funcs.h index b4720840e54..56adaaec054 100644 --- a/reactos/include/funcs.h +++ b/reactos/include/funcs.h @@ -7435,6 +7435,8 @@ DWORD STDCALL NetLocalGroupEnum (LPWSTR, DWORD, LPBYTE*, DWORD, LPDWORD, VOID CopyMemory(PVOID Destination, CONST VOID* Source, DWORD Length); +DWORD STDCALL GetCurrentTime(VOID); + void WINAPI SHAddToRecentDocs (UINT, LPCVOID); diff --git a/reactos/include/in.h b/reactos/include/in.h index e50cbf09bcc..a6d0b8579ea 100644 --- a/reactos/include/in.h +++ b/reactos/include/in.h @@ -488,4 +488,4 @@ unsigned char wave[]={ 0x7d,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e, 0x7e,0x7e,0x7e,0x7f,0x7f,0x7f,0x7f,0x7f, 0x7f,0x7f,0x80,0x80,0x80,0x80,0x80,0x80, -}; \ No newline at end of file +}; diff --git a/reactos/include/internal/hal/ddk.h b/reactos/include/internal/hal/ddk.h index 917b1732f27..09c12aace7f 100644 --- a/reactos/include/internal/hal/ddk.h +++ b/reactos/include/internal/hal/ddk.h @@ -115,4 +115,5 @@ BOOLEAN HalTranslateBusAddress(INTERFACE_TYPE InterfaceType, PPHYSICAL_ADDRESS TranslatedAddress); BOOLEAN HalMakeBeep(ULONG Frequency); VOID HalQueryRealTimeClock(PTIME_FIELDS pTime); + #endif /* __INCLUDE_INTERNAL_HAL_DDK_H */ diff --git a/reactos/include/internal/i386/mmhal.h b/reactos/include/internal/i386/mmhal.h index d412e87927d..54ecbfde08c 100644 --- a/reactos/include/internal/i386/mmhal.h +++ b/reactos/include/internal/i386/mmhal.h @@ -9,16 +9,7 @@ #define PAGESIZE (4096) -PULONG MmGetPageEntry(PEPROCESS Process, ULONG Address); - -/* - * Sets a page entry - * vaddr: The virtual address to set the page entry for - * attributes: The access attributes to give the page - * physaddr: The physical address the page should map to - */ -void set_page(unsigned int vaddr, unsigned int attributes, - unsigned int physaddr); +PULONG MmGetPageEntry(PEPROCESS Process, PVOID Address); /* @@ -75,10 +66,6 @@ extern inline unsigned int* get_page_directory(void) #define VADDR_TO_PT_OFFSET(x) (((x/1024)%4096)) #define VADDR_TO_PD_OFFSET(x) ((x)/(4*1024*1024)) -unsigned int* get_page_entry(unsigned int vaddr); - -BOOL is_page_present(unsigned int vaddr); - VOID MmSetPage(PEPROCESS Process, PVOID Address, ULONG flProtect, diff --git a/reactos/include/internal/i386/string.h b/reactos/include/internal/i386/string.h new file mode 100644 index 00000000000..48b119895da --- /dev/null +++ b/reactos/include/internal/i386/string.h @@ -0,0 +1,487 @@ +#ifndef _I386_STRING_H_ +#define _I386_STRING_H_ + +/* + * On a 486 or Pentium, we are better off not using the + * byte string operations. But on a 386 or a PPro the + * byte string ops are faster than doing it by hand + * (MUCH faster on a Pentium). + * + * Also, the byte strings actually work correctly. Forget + * the i486 routines for now as they may be broken.. + */ +#if FIXED_486_STRING && (CPU == 486 || CPU == 586) +#include +#else + +/* + * This string-include defines all string functions as inline + * functions. Use gcc. It also assumes ds=es=data space, this should be + * normal. Most of the string-functions are rather heavily hand-optimized, + * see especially strtok,strstr,str[c]spn. They should work, but are not + * very easy to understand. Everything is done entirely within the register + * set, making the functions fast and clean. String instructions have been + * used through-out, making for "slightly" unclear code :-) + * + * NO Copyright (C) 1991, 1992 Linus Torvalds, + * consider these trivial functions to be PD. + */ + +#define __HAVE_ARCH_STRCPY +extern inline char * strcpy(char * dest,const char *src) +{ +int d0, d1, d2; +__asm__ __volatile__( + "cld\n" + "1:\tlodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b" + : "=&S" (d0), "=&D" (d1), "=&a" (d2) + :"0" (src),"1" (dest) : "memory"); +return dest; +} + +#define __HAVE_ARCH_STRNCPY +extern inline char * strncpy(char * dest,const char *src,size_t count) +{ +int d0, d1, d2, d3; +__asm__ __volatile__( + "cld\n" + "1:\tdecl %2\n\t" + "js 2f\n\t" + "lodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "rep\n\t" + "stosb\n" + "2:" + : "=&S" (d0), "=&D" (d1), "=&c" (d2), "=&a" (d3) + :"0" (src),"1" (dest),"2" (count) : "memory"); +return dest; +} + +#define __HAVE_ARCH_STRCAT +extern inline char * strcat(char * dest,const char * src) +{ +int d0, d1, d2, d3; +__asm__ __volatile__( + "cld\n\t" + "repne\n\t" + "scasb\n\t" + "decl %1\n" + "1:\tlodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b" + : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3) + : "0" (src), "1" (dest), "2" (0), "3" (0xffffffff):"memory"); +return dest; +} + +#define __HAVE_ARCH_STRNCAT +extern inline char * strncat(char * dest,const char * src,size_t count) +{ +int d0, d1, d2, d3; +__asm__ __volatile__( + "cld\n\t" + "repne\n\t" + "scasb\n\t" + "decl %1\n\t" + "movl %8,%3\n" + "1:\tdecl %3\n\t" + "js 2f\n\t" + "lodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n" + "2:\txorl %2,%2\n\t" + "stosb" + : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3) + : "0" (src),"1" (dest),"2" (0),"3" (0xffffffff), "g" (count) + : "memory"); +return dest; +} + +#define __HAVE_ARCH_STRCMP +extern inline int strcmp(const char * cs,const char * ct) +{ +int d0, d1; +register int __res; +__asm__ __volatile__( + "cld\n" + "1:\tlodsb\n\t" + "scasb\n\t" + "jne 2f\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "xorl %%eax,%%eax\n\t" + "jmp 3f\n" + "2:\tsbbl %%eax,%%eax\n\t" + "orb $1,%%al\n" + "3:" + :"=a" (__res), "=&S" (d0), "=&D" (d1) + :"1" (cs),"2" (ct)); +return __res; +} + +#define __HAVE_ARCH_STRNCMP +extern inline int strncmp(const char * cs,const char * ct,size_t count) +{ +register int __res; +int d0, d1, d2; +__asm__ __volatile__( + "cld\n" + "1:\tdecl %3\n\t" + "js 2f\n\t" + "lodsb\n\t" + "scasb\n\t" + "jne 3f\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n" + "2:\txorl %%eax,%%eax\n\t" + "jmp 4f\n" + "3:\tsbbl %%eax,%%eax\n\t" + "orb $1,%%al\n" + "4:" + :"=a" (__res), "=&S" (d0), "=&D" (d1), "=&c" (d2) + :"1" (cs),"2" (ct),"3" (count)); +return __res; +} + +#define __HAVE_ARCH_STRCHR +extern inline char * strchr(const char * s, int c) +{ +int d0; +register char * __res; +__asm__ __volatile__( + "cld\n\t" + "movb %%al,%%ah\n" + "1:\tlodsb\n\t" + "cmpb %%ah,%%al\n\t" + "je 2f\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "movl $1,%1\n" + "2:\tmovl %1,%0\n\t" + "decl %0" + :"=a" (__res), "=&S" (d0) : "1" (s),"0" (c)); +return __res; +} + +#define __HAVE_ARCH_STRRCHR +extern inline char * strrchr(const char * s, int c) +{ +int d0, d1; +register char * __res; +__asm__ __volatile__( + "cld\n\t" + "movb %%al,%%ah\n" + "1:\tlodsb\n\t" + "cmpb %%ah,%%al\n\t" + "jne 2f\n\t" + "leal -1(%%esi),%0\n" + "2:\ttestb %%al,%%al\n\t" + "jne 1b" + :"=g" (__res), "=&S" (d0), "=&a" (d1) :"0" (0),"1" (s),"2" (c)); +return __res; +} + +#define __HAVE_ARCH_STRLEN +extern inline size_t strlen(const char * s) +{ +int d0; +register int __res; +__asm__ __volatile__( + "cld\n\t" + "repne\n\t" + "scasb\n\t" + "notl %0\n\t" + "decl %0" + :"=c" (__res), "=&D" (d0) :"1" (s),"a" (0), "0" (0xffffffff)); +return __res; +} + +extern inline void * __memcpy(void * to, const void * from, size_t n) +{ +int d0, d1, d2; +__asm__ __volatile__( + "cld\n\t" + "rep ; movsl\n\t" + "testb $2,%b4\n\t" + "je 1f\n\t" + "movsw\n" + "1:\ttestb $1,%b4\n\t" + "je 2f\n\t" + "movsb\n" + "2:" + : "=&c" (d0), "=&D" (d1), "=&S" (d2) + :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from) + : "memory"); +return (to); +} + +/* + * This looks horribly ugly, but the compiler can optimize it totally, + * as the count is constant. + */ +extern inline void * __constant_memcpy(void * to, const void * from, size_t n) +{ + switch (n) { + case 0: + return to; + case 1: + *(unsigned char *)to = *(const unsigned char *)from; + return to; + case 2: + *(unsigned short *)to = *(const unsigned short *)from; + return to; + case 3: + *(unsigned short *)to = *(const unsigned short *)from; + *(2+(unsigned char *)to) = *(2+(const unsigned char *)from); + return to; + case 4: + *(unsigned long *)to = *(const unsigned long *)from; + return to; + case 6: /* for Ethernet addresses */ + *(unsigned long *)to = *(const unsigned long *)from; + *(2+(unsigned short *)to) = *(2+(const unsigned short *)from); + return to; + case 8: + *(unsigned long *)to = *(const unsigned long *)from; + *(1+(unsigned long *)to) = *(1+(const unsigned long *)from); + return to; + case 12: + *(unsigned long *)to = *(const unsigned long *)from; + *(1+(unsigned long *)to) = *(1+(const unsigned long *)from); + *(2+(unsigned long *)to) = *(2+(const unsigned long *)from); + return to; + case 16: + *(unsigned long *)to = *(const unsigned long *)from; + *(1+(unsigned long *)to) = *(1+(const unsigned long *)from); + *(2+(unsigned long *)to) = *(2+(const unsigned long *)from); + *(3+(unsigned long *)to) = *(3+(const unsigned long *)from); + return to; + case 20: + *(unsigned long *)to = *(const unsigned long *)from; + *(1+(unsigned long *)to) = *(1+(const unsigned long *)from); + *(2+(unsigned long *)to) = *(2+(const unsigned long *)from); + *(3+(unsigned long *)to) = *(3+(const unsigned long *)from); + *(4+(unsigned long *)to) = *(4+(const unsigned long *)from); + return to; + } +#define COMMON(x) \ +__asm__ __volatile__( \ + "cld\n\t" \ + "rep ; movsl" \ + x \ + : "=&c" (d0), "=&D" (d1), "=&S" (d2) \ + : "0" (n/4),"1" ((long) to),"2" ((long) from) \ + : "memory"); +{ + int d0, d1, d2; + switch (n % 4) { + case 0: COMMON(""); return to; + case 1: COMMON("\n\tmovsb"); return to; + case 2: COMMON("\n\tmovsw"); return to; + default: COMMON("\n\tmovsw\n\tmovsb"); return to; + } +} + +#undef COMMON +} + +#define __HAVE_ARCH_MEMCPY +#define memcpy(t, f, n) \ +(__builtin_constant_p(n) ? \ + __constant_memcpy((t),(f),(n)) : \ + __memcpy((t),(f),(n))) + +#define __HAVE_ARCH_MEMMOVE +extern inline void * memmove(void * dest,const void * src, size_t n) +{ +int d0, d1, d2; +if (dest +#endif + /* * On a 486 or Pentium, we are better off not using the * byte string operations. But on a 386 or a PPro the @@ -65,26 +27,29 @@ extern int memcmp(const void *,const void *,__kernel_size_t); * set, making the functions fast and clean. String instructions have been * used through-out, making for "slightly" unclear code :-) * - * Copyright (C) 1991, 1992 Linus Torvalds + * NO Copyright (C) 1991, 1992 Linus Torvalds, + * consider these trivial functions to be PD. */ #define __HAVE_ARCH_STRCPY extern inline char * strcpy(char * dest,const char *src) { +int d0, d1, d2; __asm__ __volatile__( "cld\n" "1:\tlodsb\n\t" "stosb\n\t" "testb %%al,%%al\n\t" "jne 1b" - : /* no output */ - :"S" (src),"D" (dest):"si","di","ax","memory"); + : "=&S" (d0), "=&D" (d1), "=&a" (d2) + :"0" (src),"1" (dest) : "memory"); return dest; } #define __HAVE_ARCH_STRNCPY extern inline char * strncpy(char * dest,const char *src,size_t count) { +int d0, d1, d2, d3; __asm__ __volatile__( "cld\n" "1:\tdecl %2\n\t" @@ -96,14 +61,15 @@ __asm__ __volatile__( "rep\n\t" "stosb\n" "2:" - : /* no output */ - :"S" (src),"D" (dest),"c" (count):"si","di","ax","cx","memory"); + : "=&S" (d0), "=&D" (d1), "=&c" (d2), "=&a" (d3) + :"0" (src),"1" (dest),"2" (count) : "memory"); return dest; } #define __HAVE_ARCH_STRCAT extern inline char * strcat(char * dest,const char * src) { +int d0, d1, d2, d3; __asm__ __volatile__( "cld\n\t" "repne\n\t" @@ -113,20 +79,21 @@ __asm__ __volatile__( "stosb\n\t" "testb %%al,%%al\n\t" "jne 1b" - : /* no output */ - :"S" (src),"D" (dest),"a" (0),"c" (0xffffffff):"si","di","ax","cx"); + : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3) + : "0" (src), "1" (dest), "2" (0), "3" (0xffffffff):"memory"); return dest; } #define __HAVE_ARCH_STRNCAT extern inline char * strncat(char * dest,const char * src,size_t count) { +int d0, d1, d2, d3; __asm__ __volatile__( "cld\n\t" "repne\n\t" "scasb\n\t" "decl %1\n\t" - "movl %4,%3\n" + "movl %8,%3\n" "1:\tdecl %3\n\t" "js 2f\n\t" "lodsb\n\t" @@ -135,15 +102,16 @@ __asm__ __volatile__( "jne 1b\n" "2:\txorl %2,%2\n\t" "stosb" - : /* no output */ - :"S" (src),"D" (dest),"a" (0),"c" (0xffffffff),"g" (count) - :"si","di","ax","cx","memory"); + : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3) + : "0" (src),"1" (dest),"2" (0),"3" (0xffffffff), "g" (count) + : "memory"); return dest; } #define __HAVE_ARCH_STRCMP extern inline int strcmp(const char * cs,const char * ct) { +int d0, d1; register int __res; __asm__ __volatile__( "cld\n" @@ -155,9 +123,10 @@ __asm__ __volatile__( "xorl %%eax,%%eax\n\t" "jmp 3f\n" "2:\tsbbl %%eax,%%eax\n\t" - "orb $1,%%eax\n" + "orb $1,%%al\n" "3:" - :"=a" (__res):"S" (cs),"D" (ct):"si","di"); + :"=a" (__res), "=&S" (d0), "=&D" (d1) + :"1" (cs),"2" (ct)); return __res; } @@ -165,6 +134,7 @@ return __res; extern inline int strncmp(const char * cs,const char * ct,size_t count) { register int __res; +int d0, d1, d2; __asm__ __volatile__( "cld\n" "1:\tdecl %3\n\t" @@ -179,13 +149,15 @@ __asm__ __volatile__( "3:\tsbbl %%eax,%%eax\n\t" "orb $1,%%al\n" "4:" - :"=a" (__res):"S" (cs),"D" (ct),"c" (count):"si","di","cx"); + :"=a" (__res), "=&S" (d0), "=&D" (d1), "=&c" (d2) + :"1" (cs),"2" (ct),"3" (count)); return __res; } #define __HAVE_ARCH_STRCHR extern inline char * strchr(const char * s, int c) { +int d0; register char * __res; __asm__ __volatile__( "cld\n\t" @@ -198,13 +170,14 @@ __asm__ __volatile__( "movl $1,%1\n" "2:\tmovl %1,%0\n\t" "decl %0" - :"=a" (__res):"S" (s),"0" (c):"si"); + :"=a" (__res), "=&S" (d0) : "1" (s),"0" (c)); return __res; } #define __HAVE_ARCH_STRRCHR extern inline char * strrchr(const char * s, int c) { +int d0, d1; register char * __res; __asm__ __volatile__( "cld\n\t" @@ -215,123 +188,14 @@ __asm__ __volatile__( "leal -1(%%esi),%0\n" "2:\ttestb %%al,%%al\n\t" "jne 1b" - :"=d" (__res):"0" (0),"S" (s),"a" (c):"ax","si"); -return __res; -} - -#define __HAVE_ARCH_STRSPN -extern inline size_t strspn(const char * cs, const char * ct) -{ -register char * __res; -__asm__ __volatile__( - "cld\n\t" - "movl %4,%%edi\n\t" - "repne\n\t" - "scasb\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "movl %%ecx,%%edx\n" - "1:\tlodsb\n\t" - "testb %%al,%%al\n\t" - "je 2f\n\t" - "movl %4,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne\n\t" - "scasb\n\t" - "je 1b\n" - "2:\tdecl %0" - :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) - :"ax","cx","dx","di"); -return __res-cs; -} - -#define __HAVE_ARCH_STRCSPN -extern inline size_t strcspn(const char * cs, const char * ct) -{ -register char * __res; -__asm__ __volatile__( - "cld\n\t" - "movl %4,%%edi\n\t" - "repne\n\t" - "scasb\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "movl %%ecx,%%edx\n" - "1:\tlodsb\n\t" - "testb %%al,%%al\n\t" - "je 2f\n\t" - "movl %4,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne\n\t" - "scasb\n\t" - "jne 1b\n" - "2:\tdecl %0" - :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) - :"ax","cx","dx","di"); -return __res-cs; -} - -#define __HAVE_ARCH_STRPBRK -extern inline char * strpbrk(const char * cs,const char * ct) -{ -register char * __res; -__asm__ __volatile__( - "cld\n\t" - "movl %4,%%edi\n\t" - "repne\n\t" - "scasb\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "movl %%ecx,%%edx\n" - "1:\tlodsb\n\t" - "testb %%al,%%al\n\t" - "je 2f\n\t" - "movl %4,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne\n\t" - "scasb\n\t" - "jne 1b\n\t" - "decl %0\n\t" - "jmp 3f\n" - "2:\txorl %0,%0\n" - "3:" - :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) - :"ax","cx","dx","di"); -return __res; -} - -#define __HAVE_ARCH_STRSTR -extern inline char * strstr(const char * cs,const char * ct) -{ -register char * __res; -__asm__ __volatile__( - "cld\n\t" \ - "movl %4,%%edi\n\t" - "repne\n\t" - "scasb\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */ - "movl %%ecx,%%edx\n" - "1:\tmovl %4,%%edi\n\t" - "movl %%esi,%%eax\n\t" - "movl %%edx,%%ecx\n\t" - "repe\n\t" - "cmpsb\n\t" - "je 2f\n\t" /* also works for empty string, see above */ - "xchgl %%eax,%%esi\n\t" - "incl %%esi\n\t" - "cmpb $0,-1(%%eax)\n\t" - "jne 1b\n\t" - "xorl %%eax,%%eax\n\t" - "2:" - :"=a" (__res):"0" (0),"c" (0xffffffff),"S" (cs),"g" (ct) - :"cx","dx","di","si"); + :"=g" (__res), "=&S" (d0), "=&a" (d1) :"0" (0),"1" (s),"2" (c)); return __res; } #define __HAVE_ARCH_STRLEN extern inline size_t strlen(const char * s) { +int d0; register int __res; __asm__ __volatile__( "cld\n\t" @@ -339,86 +203,26 @@ __asm__ __volatile__( "scasb\n\t" "notl %0\n\t" "decl %0" - :"=c" (__res):"D" (s),"a" (0),"0" (0xffffffff):"di"); -return __res; -} - -#define __HAVE_ARCH_STRTOK -extern inline char * strtok(char * s,const char * ct) -{ -register char * __res; -__asm__ __volatile__( - "testl %1,%1\n\t" - "jne 1f\n\t" - "testl %0,%0\n\t" - "je 8f\n\t" - "movl %0,%1\n" - "1:\txorl %0,%0\n\t" - "movl $-1,%%ecx\n\t" - "xorl %%eax,%%eax\n\t" - "cld\n\t" - "movl %4,%%edi\n\t" - "repne\n\t" - "scasb\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "je 7f\n\t" /* empty delimiter-string */ - "movl %%ecx,%%edx\n" - "2:\tlodsb\n\t" - "testb %%al,%%al\n\t" - "je 7f\n\t" - "movl %4,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne\n\t" - "scasb\n\t" - "je 2b\n\t" - "decl %1\n\t" - "cmpb $0,(%1)\n\t" - "je 7f\n\t" - "movl %1,%0\n" - "3:\tlodsb\n\t" - "testb %%al,%%al\n\t" - "je 5f\n\t" - "movl %4,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne\n\t" - "scasb\n\t" - "jne 3b\n\t" - "decl %1\n\t" - "cmpb $0,(%1)\n\t" - "je 5f\n\t" - "movb $0,(%1)\n\t" - "incl %1\n\t" - "jmp 6f\n" - "5:\txorl %1,%1\n" - "6:\tcmpb $0,(%0)\n\t" - "jne 7f\n\t" - "xorl %0,%0\n" - "7:\ttestl %0,%0\n\t" - "jne 8f\n\t" - "movl %0,%1\n" - "8:" - :"=b" (__res),"=S" (___strtok) - :"0" (___strtok),"1" (s),"g" (ct) - :"ax","cx","dx","di","memory"); + :"=c" (__res), "=&D" (d0) :"1" (s),"a" (0), "0" (0xffffffff)); return __res; } extern inline void * __memcpy(void * to, const void * from, size_t n) { +int d0, d1, d2; __asm__ __volatile__( "cld\n\t" "rep ; movsl\n\t" - "testb $2,%b1\n\t" + "testb $2,%b4\n\t" "je 1f\n\t" "movsw\n" - "1:\ttestb $1,%b1\n\t" + "1:\ttestb $1,%b4\n\t" "je 2f\n\t" "movsb\n" "2:" - : /* no output */ - :"c" (n/4), "q" (n),"D" ((long) to),"S" ((long) from) - : "cx","di","si","memory"); + : "=&c" (d0), "=&D" (d1), "=&S" (d2) + :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from) + : "memory"); return (to); } @@ -444,6 +248,10 @@ extern inline void * __constant_memcpy(void * to, const void * from, size_t n) case 4: *(unsigned long *)to = *(const unsigned long *)from; return to; + case 6: /* for Ethernet addresses */ + *(unsigned long *)to = *(const unsigned long *)from; + *(2+(unsigned short *)to) = *(2+(const unsigned short *)from); + return to; case 8: *(unsigned long *)to = *(const unsigned long *)from; *(1+(unsigned long *)to) = *(1+(const unsigned long *)from); @@ -468,19 +276,23 @@ extern inline void * __constant_memcpy(void * to, const void * from, size_t n) return to; } #define COMMON(x) \ -__asm__("cld\n\t" \ +__asm__ __volatile__( \ + "cld\n\t" \ "rep ; movsl" \ x \ - : /* no outputs */ \ - : "c" (n/4),"D" ((long) to),"S" ((long) from) \ - : "cx","di","si","memory"); - + : "=&c" (d0), "=&D" (d1), "=&S" (d2) \ + : "0" (n/4),"1" ((long) to),"2" ((long) from) \ + : "memory"); +{ + int d0, d1, d2; switch (n % 4) { case 0: COMMON(""); return to; case 1: COMMON("\n\tmovsb"); return to; case 2: COMMON("\n\tmovsw"); return to; - case 3: COMMON("\n\tmovsw\n\tmovsb"); return to; + default: COMMON("\n\tmovsw\n\tmovsb"); return to; } +} + #undef COMMON } @@ -493,25 +305,26 @@ __asm__("cld\n\t" \ #define __HAVE_ARCH_MEMMOVE extern inline void * memmove(void * dest,const void * src, size_t n) { +int d0, d1, d2; if (dest - * - * THIS SOFTWARE IS NOT COPYRIGHTED - * - * This source code is offered for use in the public domain. You may - * use, modify or distribute it freely. - * - * This code is distributed in the hope that it will be useful but - * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY - * DISCLAMED. This includes but is not limited to warranties of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * $Revision: 1.5 $ - * $Author: ariadne $ - * $Date: 1999/02/21 20:59:55 $ - * - */ -/* Appropriated for Reactos Crtdll by Ariadne */ -/* changed prototype for _strerror */ -#ifndef _LINUX_WSTRING_H_ -#define _LINUX_WSTRING_H_ - -#ifndef _LINUX_STRING_H_ -#define _LINUX_STRING_H_ - -#ifndef _STRING_H_ -#define _STRING_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Define size_t, wchar_t and NULL - */ -#define __need_size_t -#define __need_wchar_t -#define __need_NULL -#include - -char * ___strtok; // removed extern specifier 02-06-98, BD - -/* - * Prototypes of the ANSI Standard C library string functions. - */ -void* memchr (const void* p, int cSearchFor, size_t sizeSearch); -int memcmp (const void* p1, const void* p2, size_t sizeSearch); -void* memcpy (void* pCopyTo, const void* pSource, size_t sizeSource); -void* memmove (void* pMoveTo, const void* pSource, size_t sizeSource); -void* memset (void* p, int cFill, size_t sizeRepeatCount); -char* strcat (char* szAddTo, const char* szAdd); -char* strchr (const char* szSearch, int cFor); -int strcmp (const char* sz1, const char* sz2); -int strcoll (const char* sz1, const char* sz2); /* Compare using locale */ -char* strcpy (char* szCopyTo, const char* szSource); -size_t strcspn (const char* szGetPrefix, const char* szNotIncluding); -char* strerror (int nError); /* NOTE: NOT an old name wrapper. */ -char * _strerror(const char *s); -size_t strlen (const char* sz); -char* strncat (char* szAddTo, const char* szAdd, size_t sizeMaxAdd); -int strncmp (const char* sz1, const char* sz2, size_t sizeMaxCompare); -char* strncpy (char* szCopyTo, const char* szSource, size_t sizeMaxCopy); -char* strpbrk (const char* szSearch, const char* szAnyOf); -char* strrchr (const char* szSearch, int cFor); -size_t strspn (const char* szGetPrefix, const char *szIncluding); -char* strstr (const char* szSearch, const char *szFor); -char* strtok (char* szTokenize, const char* szDelimiters); -size_t strxfrm (char* szTransformed, const char *szSource, - size_t sizeTransform); - -#ifndef __STRICT_ANSI__ -/* - * Extra non-ANSI functions provided by the CRTDLL library - */ -void* _memccpy (void* pCopyTo, const void* pSource, int cTerminator, - size_t sizeMaxCopy); -int _memicmp (const void* p1, const void* p2, size_t sizeSearch); -char* _strdup (const char *szDuplicate); -int _strcmpi (const char* sz1, const char* sz2); -int _stricmp (const char* sz1, const char* sz2); -int _stricoll (const char* sz1, const char* sz2); -char* _strlwr (char* szToConvert); -int _strnicmp (const char* sz1, const char* sz2, - size_t sizeMaxCompare); -char* _strnset (char* szToFill, int cFill, size_t sizeMaxFill); -char* _strrev (char* szToReverse); -char* _strset (char* szToFill, int cFill); -char* _strupr (char* szToConvert); -void _swab (const char* caFrom, char* caTo, size_t sizeToCopy); - -#endif /* Not __STRICT_ANSI__ */ - - -/* - * Unicode versions of the standard calls. - */ -wchar_t* wcscat (wchar_t* wsAddTo, const wchar_t* wsAdd); -wchar_t* wcschr (const wchar_t* wsSearch, wchar_t wcFor); -int wcscmp (const wchar_t* ws1, const wchar_t* ws2); -int wcscoll (const wchar_t* ws1, const wchar_t* ws2); -wchar_t* wcscpy (wchar_t* wsCopyTo, const wchar_t* wsSource); -size_t wcscspn (const wchar_t* wsGetPrefix, const wchar_t* wsNotIncluding); -/* Note: No wcserror in CRTDLL. */ -size_t wcslen (const wchar_t* ws); -wchar_t* wcsncat (wchar_t* wsAddTo, const wchar_t* wsAdd, size_t sizeMaxAdd); -int wcsncmp(const wchar_t* ws1, const wchar_t* ws2, size_t sizeMaxCompare); -wchar_t* wcsncpy(wchar_t* wsCopyTo, const wchar_t* wsSource, - size_t sizeMaxCopy); -wchar_t* wcspbrk(const wchar_t* wsSearch, const wchar_t* wsAnyOf); -wchar_t* wcsrchr(const wchar_t* wsSearch, wchar_t wcFor); -size_t wcsspn(const wchar_t* wsGetPrefix, const wchar_t* wsIncluding); -wchar_t* wcsstr(const wchar_t* wsSearch, const wchar_t* wsFor); -wchar_t* wcstok(wchar_t* wsTokenize, const wchar_t* wsDelimiters); -size_t wcsxfrm(wchar_t* wsTransformed, const wchar_t *wsSource, - size_t sizeTransform); - - -#ifndef __STRICT_ANSI__ -/* - * Unicode versions of non-ANSI functions provided by CRTDLL. - */ - -/* NOTE: _wcscmpi not provided by CRTDLL, this define is for portability */ -#define _wcscmpi _wcsicmp - -wchar_t* _wcsdup (const wchar_t* wsToDuplicate); -int _wcsicmp (const wchar_t* ws1, const wchar_t* ws2); -int _wcsicoll (const wchar_t* ws1, const wchar_t* ws2); -wchar_t* _wcslwr (wchar_t* wsToConvert); -int _wcsnicmp (const wchar_t* ws1, const wchar_t* ws2, - size_t sizeMaxCompare); -wchar_t* _wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill); -wchar_t* _wcsrev (wchar_t* wsToReverse); -wchar_t* _wcsset (wchar_t* wsToFill, wchar_t wcToFill); -wchar_t* _wcsupr (wchar_t* wsToConvert); - -#endif /* Not __STRICT_ANSI__ */ - - -#ifndef __STRICT_ANSI__ -#ifndef _NO_OLDNAMES - -/* - * Non-underscored versions of non-ANSI functions. They live in liboldnames.a - * and provide a little extra portability. Also a few extra UNIX-isms like - * strcasecmp. - */ - -void* memccpy (void* pCopyTo, const void* pSource, int cTerminator, - size_t sizeMaxCopy); -int memicmp (const void* p1, const void* p2, size_t sizeSearch); -char* strdup (const char *szDuplicate); -int strcmpi (const char* sz1, const char* sz2); -int stricmp (const char* sz1, const char* sz2); -int strcasecmp (const char* sz1, const char* sz2); -int stricoll (const char* sz1, const char* sz2); -char* strlwr (char* szToConvert); -int strnicmp (const char* sz1, const char* sz2, size_t sizeMaxCompare); -int strncasecmp (const char* sz1, const char* sz2, size_t sizeMaxCompare); -char* strnset (char* szToFill, int cFill, size_t sizeMaxFill); -char* strrev (char* szToReverse); -char* strset (char* szToFill, int cFill); -char* strupr (char* szToConvert); -void swab (const char* caFrom, char* caTo, size_t sizeToCopy); - -/* NOTE: There is no _wcscmpi, but this is for compatibility. */ -int wcscmpi (const wchar_t* ws1, const wchar_t* ws2); -wchar_t* wcsdup (const wchar_t* wsToDuplicate); -int wcsicmp (const wchar_t* ws1, const wchar_t* ws2); -int wcsicoll (const wchar_t* ws1, const wchar_t* ws2); -wchar_t* wcslwr (wchar_t* wsToConvert); -int wcsnicmp (const wchar_t* ws1, const wchar_t* ws2, - size_t sizeMaxCompare); -wchar_t* wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill); -wchar_t* wcsrev (wchar_t* wsToReverse); -wchar_t* wcsset (wchar_t* wsToFill, wchar_t wcToFill); -wchar_t* wcsupr (wchar_t* wsToConvert); - -#endif /* Not _NO_OLDNAMES */ -#endif /* Not strict ANSI */ - - - -/* - * Include machine specific inline routines - */ -#ifndef _I386_STRING_H_ -#define _I386_STRING_H_ - -/* - * On a 486 or Pentium, we are better off not using the - * byte string operations. But on a 386 or a PPro the - * byte string ops are faster than doing it by hand - * (MUCH faster on a Pentium). - * - * Also, the byte strings actually work correctly. Forget - * the i486 routines for now as they may be broken.. - */ -#if FIXED_486_STRING && (CPU == 486 || CPU == 586) - #include -#else - -/* - * This string-include defines all string functions as inline - * functions. Use gcc. It also assumes ds=es=data space, this should be - * normal. Most of the string-functions are rather heavily hand-optimized, - * see especially strtok,strstr,str[c]spn. They should work, but are not - * very easy to understand. Everything is done entirely within the register - * set, making the functions fast and clean. String instructions have been - * used through-out, making for "slightly" unclear code :-) - * - * Copyright (C) 1991, 1992 Linus Torvalds - */ - -#define __HAVE_ARCH_STRCPY -extern inline char * strcpy(char * dest,const char *src) -{ -__asm__ __volatile__( - "cld\n" - "1:\tlodsb\n\t" - "stosb\n\t" - "testb %%al,%%al\n\t" - "jne 1b" - : /* no output */ - :"S" (src),"D" (dest):"si","di","ax","memory"); -return dest; -} - -#define __HAVE_ARCH_STRNCPY -extern inline char * strncpy(char * dest,const char *src,size_t count) -{ -__asm__ __volatile__( - "cld\n" - "1:\tdecl %2\n\t" - "js 2f\n\t" - "lodsb\n\t" - "stosb\n\t" - "testb %%al,%%al\n\t" - "jne 1b\n\t" - "rep\n\t" - "stosb\n" - "2:" - : /* no output */ - :"S" (src),"D" (dest),"c" (count):"si","di","ax","cx","memory"); -return dest; -} - -#define __HAVE_ARCH_STRCAT -extern inline char * strcat(char * dest,const char * src) -{ -__asm__ __volatile__( - "cld\n\t" - "repne\n\t" - "scasb\n\t" - "decl %1\n" - "1:\tlodsb\n\t" - "stosb\n\t" - "testb %%al,%%al\n\t" - "jne 1b" - : /* no output */ - :"S" (src),"D" (dest),"a" (0),"c" (0xffffffff):"si","di","ax","cx"); -return dest; -} - -#define __HAVE_ARCH_STRNCAT -extern inline char * strncat(char * dest,const char * src,size_t count) -{ -__asm__ __volatile__( - "cld\n\t" - "repne\n\t" - "scasb\n\t" - "decl %1\n\t" - "movl %4,%3\n" - "1:\tdecl %3\n\t" - "js 2f\n\t" - "lodsb\n\t" - "stosb\n\t" - "testb %%al,%%al\n\t" - "jne 1b\n" - "2:\txorl %2,%2\n\t" - "stosb" - : /* no output */ - :"S" (src),"D" (dest),"a" (0),"c" (0xffffffff),"g" (count) - :"si","di","ax","cx","memory"); -return dest; -} - -#define __HAVE_ARCH_STRCMP -extern inline int strcmp(const char * cs,const char * ct) -{ -register int __res; -__asm__ __volatile__( - "cld\n" - "1:\tlodsb\n\t" - "scasb\n\t" - "jne 2f\n\t" - "testb %%al,%%al\n\t" - "jne 1b\n\t" - "xorl %%eax,%%eax\n\t" - "jmp 3f\n" - "2:\tsbbl %%eax,%%eax\n\t" - "orb $1,%%eax\n" - "3:" - :"=a" (__res):"S" (cs),"D" (ct):"si","di"); -return __res; -} - -#define __HAVE_ARCH_STRNCMP -extern inline int strncmp(const char * cs,const char * ct,size_t count) -{ -register int __res; -__asm__ __volatile__( - "cld\n" - "1:\tdecl %3\n\t" - "js 2f\n\t" - "lodsb\n\t" - "scasb\n\t" - "jne 3f\n\t" - "testb %%al,%%al\n\t" - "jne 1b\n" - "2:\txorl %%eax,%%eax\n\t" - "jmp 4f\n" - "3:\tsbbl %%eax,%%eax\n\t" - "orb $1,%%al\n" - "4:" - :"=a" (__res):"S" (cs),"D" (ct),"c" (count):"si","di","cx"); -return __res; -} - -#define __HAVE_ARCH_STRCHR -extern inline char * strchr(const char * s, int c) -{ -register char * __res; -__asm__ __volatile__( - "cld\n\t" - "movb %%al,%%ah\n" - "1:\tlodsb\n\t" - "cmpb %%ah,%%al\n\t" - "je 2f\n\t" - "testb %%al,%%al\n\t" - "jne 1b\n\t" - "movl $1,%1\n" - "2:\tmovl %1,%0\n\t" - "decl %0" - :"=a" (__res):"S" (s),"0" (c):"si"); -return __res; -} - -#define __HAVE_ARCH_STRRCHR -extern inline char * strrchr(const char * s, int c) -{ -register char * __res; -__asm__ __volatile__( - "cld\n\t" - "movb %%al,%%ah\n" - "1:\tlodsb\n\t" - "cmpb %%ah,%%al\n\t" - "jne 2f\n\t" - "leal -1(%%esi),%0\n" - "2:\ttestb %%al,%%al\n\t" - "jne 1b" - :"=d" (__res):"0" (0),"S" (s),"a" (c):"ax","si"); -return __res; -} - -#define __HAVE_ARCH_STRSPN -extern inline size_t strspn(const char * cs, const char * ct) -{ -register char * __res; -__asm__ __volatile__( - "cld\n\t" - "movl %4,%%edi\n\t" - "repne\n\t" - "scasb\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "movl %%ecx,%%edx\n" - "1:\tlodsb\n\t" - "testb %%al,%%al\n\t" - "je 2f\n\t" - "movl %4,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne\n\t" - "scasb\n\t" - "je 1b\n" - "2:\tdecl %0" - :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) - :"ax","cx","dx","di"); -return __res-cs; -} - -#define __HAVE_ARCH_STRCSPN -extern inline size_t strcspn(const char * cs, const char * ct) -{ -register char * __res; -__asm__ __volatile__( - "cld\n\t" - "movl %4,%%edi\n\t" - "repne\n\t" - "scasb\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "movl %%ecx,%%edx\n" - "1:\tlodsb\n\t" - "testb %%al,%%al\n\t" - "je 2f\n\t" - "movl %4,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne\n\t" - "scasb\n\t" - "jne 1b\n" - "2:\tdecl %0" - :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) - :"ax","cx","dx","di"); -return __res-cs; -} - -#define __HAVE_ARCH_STRPBRK -extern inline char * strpbrk(const char * cs,const char * ct) -{ -register char * __res; -__asm__ __volatile__( - "cld\n\t" - "movl %4,%%edi\n\t" - "repne\n\t" - "scasb\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "movl %%ecx,%%edx\n" - "1:\tlodsb\n\t" - "testb %%al,%%al\n\t" - "je 2f\n\t" - "movl %4,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne\n\t" - "scasb\n\t" - "jne 1b\n\t" - "decl %0\n\t" - "jmp 3f\n" - "2:\txorl %0,%0\n" - "3:" - :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) - :"ax","cx","dx","di"); -return __res; -} - -#define __HAVE_ARCH_STRSTR -extern inline char * strstr(const char * cs,const char * ct) -{ -register char * __res; -__asm__ __volatile__( - "cld\n\t" \ - "movl %4,%%edi\n\t" - "repne\n\t" - "scasb\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */ - "movl %%ecx,%%edx\n" - "1:\tmovl %4,%%edi\n\t" - "movl %%esi,%%eax\n\t" - "movl %%edx,%%ecx\n\t" - "repe\n\t" - "cmpsb\n\t" - "je 2f\n\t" /* also works for empty string, see above */ - "xchgl %%eax,%%esi\n\t" - "incl %%esi\n\t" - "cmpb $0,-1(%%eax)\n\t" - "jne 1b\n\t" - "xorl %%eax,%%eax\n\t" - "2:" - :"=a" (__res):"0" (0),"c" (0xffffffff),"S" (cs),"g" (ct) - :"cx","dx","di","si"); -return __res; -} - -#define __HAVE_ARCH_STRLEN -extern inline size_t strlen(const char * s) -{ -register int __res; -__asm__ __volatile__( - "cld\n\t" - "repne\n\t" - "scasb\n\t" - "notl %0\n\t" - "decl %0" - :"=c" (__res):"D" (s),"a" (0),"0" (0xffffffff):"di"); -return __res; -} - -#define __HAVE_ARCH_STRTOK -extern inline char * strtok(char * s,const char * ct) -{ -register char * __res; -__asm__ __volatile__( - "testl %1,%1\n\t" - "jne 1f\n\t" - "testl %0,%0\n\t" - "je 8f\n\t" - "movl %0,%1\n" - "1:\txorl %0,%0\n\t" - "movl $-1,%%ecx\n\t" - "xorl %%eax,%%eax\n\t" - "cld\n\t" - "movl %4,%%edi\n\t" - "repne\n\t" - "scasb\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "je 7f\n\t" /* empty delimiter-string */ - "movl %%ecx,%%edx\n" - "2:\tlodsb\n\t" - "testb %%al,%%al\n\t" - "je 7f\n\t" - "movl %4,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne\n\t" - "scasb\n\t" - "je 2b\n\t" - "decl %1\n\t" - "cmpb $0,(%1)\n\t" - "je 7f\n\t" - "movl %1,%0\n" - "3:\tlodsb\n\t" - "testb %%al,%%al\n\t" - "je 5f\n\t" - "movl %4,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne\n\t" - "scasb\n\t" - "jne 3b\n\t" - "decl %1\n\t" - "cmpb $0,(%1)\n\t" - "je 5f\n\t" - "movb $0,(%1)\n\t" - "incl %1\n\t" - "jmp 6f\n" - "5:\txorl %1,%1\n" - "6:\tcmpb $0,(%0)\n\t" - "jne 7f\n\t" - "xorl %0,%0\n" - "7:\ttestl %0,%0\n\t" - "jne 8f\n\t" - "movl %0,%1\n" - "8:" - :"=b" (__res),"=S" (___strtok) - :"0" (___strtok),"1" (s),"g" (ct) - :"ax","cx","dx","di","memory"); -return __res; -} - - -#define __HAVE_ARCH_STRICMP -extern inline int stricmp(const char* cs,const char * ct) -{ -register int __res; - - -__asm__ __volatile__( - "cld\n" - "1:\tmovb (%%esi), %%eax\n\t" - "movb (%%edi), %%dl \n\t" - "cmpb $0x5A, %%al\n\t" - "ja 2f\t\n" - "cmpb $0x40, %%al\t\n" - "jbe 2f\t\n" - "addb $0x20, %%al\t\n" - "2:\t cmpb $0x5A, %%dl\t\n" - "ja 3f\t\n" - "cmpb $0x40, %%dl\t\n" - "jbe 3f\t\n" - "addb $0x20, %%dl\t\n" - "3:\t inc %%esi\t\n" - "inc %%edi\t\n" - "cmpb %%al, %%dl\t\n" - "jne 4f\n\t" - "cmpb $00, %%al\n\t" - "jne 1b\n\t" - "xorl %%eax,%%eax\n\t" - "jmp 5f\n" - "4:\tsbbl %%eax,%%eax\n\t" - "orb $1,%%eax\n" - "5:" - :"=a" (__res):"S" (cs),"D" (ct):"si","di"); - -return __res; -} - - -#define __HAVE_ARCH_STRNICMP -extern inline int strnicmp(const char* cs,const char * ct, size_t count) -{ -register int __res; - - -__asm__ __volatile__( - "cld\n" - "1:\t decl %3\n\t" - "js 6f\n\t" - "movb (%%esi), %%al\n\t" - "movb (%%edi), %%dl \n\t" - "cmpb $0x5A, %%al\n\t" - "ja 2f\t\n" - "cmpb $0x40, %%al\t\n" - "jbe 2f\t\n" - "addb $0x20, %%al\t\n" - "2:\t cmpb $0x5A, %%dl\t\n" - "ja 3f\t\n" - "cmpb $0x40, %%dl\t\n" - "jbe 3f\t\n" - "addb $0x20, %%dl\t\n" - "3:\t inc %%esi\t\n" - "inc %%edi\t\n" - "cmpb %%al, %%dl\t\n" - "jne 4f\n\t" - "cmpb $00, %%al\n\t" - "jne 1b\n\t" - "6:xorl %%eax,%%eax\n\t" - "jmp 5f\n" - "4:\tsbbl %%eax,%%eax\n\t" - "orb $1,%%eax\n" - "5:" - :"=a" (__res):"S" (cs),"D" (ct), "c" (count):"si","di", "cx"); - - -return __res; -} - - - - - - -extern inline void * __memcpy(void * to, const void * from, size_t n) -{ -__asm__ __volatile__( - "cld\n\t" - "rep ; movsl\n\t" - "testb $2,%b1\n\t" - "je 1f\n\t" - "movsw\n" - "1:\ttestb $1,%b1\n\t" - "je 2f\n\t" - "movsb\n" - "2:" - : /* no output */ - :"c" (n/4), "q" (n),"D" ((long) to),"S" ((long) from) - : "cx","di","si","memory"); -return (to); -} - -/* - * This looks horribly ugly, but the compiler can optimize it totally, - * as the count is constant. - */ -extern inline void * __constant_memcpy(void * to, const void * from, size_t n) -{ - switch (n) { - case 0: - return to; - case 1: - *(unsigned char *)to = *(const unsigned char *)from; - return to; - case 2: - *(unsigned short *)to = *(const unsigned short *)from; - return to; - case 3: - *(unsigned short *)to = *(const unsigned short *)from; - *(2+(unsigned char *)to) = *(2+(const unsigned char *)from); - return to; - case 4: - *(unsigned long *)to = *(const unsigned long *)from; - return to; - case 8: - *(unsigned long *)to = *(const unsigned long *)from; - *(1+(unsigned long *)to) = *(1+(const unsigned long *)from); - return to; - case 12: - *(unsigned long *)to = *(const unsigned long *)from; - *(1+(unsigned long *)to) = *(1+(const unsigned long *)from); - *(2+(unsigned long *)to) = *(2+(const unsigned long *)from); - return to; - case 16: - *(unsigned long *)to = *(const unsigned long *)from; - *(1+(unsigned long *)to) = *(1+(const unsigned long *)from); - *(2+(unsigned long *)to) = *(2+(const unsigned long *)from); - *(3+(unsigned long *)to) = *(3+(const unsigned long *)from); - return to; - case 20: - *(unsigned long *)to = *(const unsigned long *)from; - *(1+(unsigned long *)to) = *(1+(const unsigned long *)from); - *(2+(unsigned long *)to) = *(2+(const unsigned long *)from); - *(3+(unsigned long *)to) = *(3+(const unsigned long *)from); - *(4+(unsigned long *)to) = *(4+(const unsigned long *)from); - return to; - } -#define COMMON(x) \ -__asm__("cld\n\t" \ - "rep ; movsl" \ - x \ - : /* no outputs */ \ - : "c" (n/4),"D" ((long) to),"S" ((long) from) \ - : "cx","di","si","memory"); - - switch (n % 4) { - case 0: COMMON(""); return to; - case 1: COMMON("\n\tmovsb"); return to; - case 2: COMMON("\n\tmovsw"); return to; - case 3: COMMON("\n\tmovsw\n\tmovsb"); return to; - } -#undef COMMON -} - -#define __HAVE_ARCH_MEMCPY -#define memcpy(t, f, n) \ -(__builtin_constant_p(n) ? \ - __constant_memcpy((t),(f),(n)) : \ - __memcpy((t),(f),(n))) - -#define __HAVE_ARCH_MEMMOVE -extern inline void * memmove(void * dest,const void * src, size_t n) -{ -if (dest - * - * THIS SOFTWARE IS NOT COPYRIGHTED - * - * This source code is offered for use in the public domain. You may - * use, modify or distribute it freely. - * - * This code is distributed in the hope that it will be useful but - * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY - * DISCLAMED. This includes but is not limited to warranties of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * $Revision: 1.2 $ - * $Author: ariadne $ - * $Date: 1999/02/21 13:29:57 $ - * - */ - -#ifndef __STRICT_ANSI__ - -#ifndef _STAT_H_ -#define _STAT_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - - - -/* - * Constants for the stat st_mode member. - */ -#define S_IFIFO 0x1000 /* FIFO */ -#define S_IFCHR 0x2000 /* Character */ -#define S_IFBLK 0x3000 /* Block */ -#define S_IFDIR 0x4000 /* Directory */ -#define S_IFREG 0x8000 /* Regular */ - -#define S_IFMT 0xF000 /* File type mask */ - -#define S_IEXEC 0x0040 -#define S_IWRITE 0x0080 -#define S_IREAD 0x0100 - -#define _S_IREAD S_IREAD -#define _S_IWRITE S_IWRITE -#define _S_IEXEC S_IEXEC - - - -#define S_ISDIR(m) ((m) & S_IFDIR) -#define S_ISFIFO(m) ((m) & S_IFIFO) -#define S_ISCHR(m) ((m) & S_IFCHR) -#define S_ISBLK(m) ((m) & S_IFBLK) -#define S_ISREG(m) ((m) & S_IFREG) - -#define S_IRWXU (S_IREAD | S_IWRITE | S_IEXEC) -#define S_IXUSR S_IEXEC -#define S_IWUSR S_IWRITE -#define S_IRUSR S_IREAD - -/* - * The structure manipulated and returned by stat and fstat. - * - * NOTE: If called on a directory the values in the time fields are not only - * invalid, they will cause localtime et. al. to return NULL. And calling - * asctime with a NULL pointer causes an Invalid Page Fault. So watch it! - */ -struct stat -{ - short st_dev; /* Equivalent to drive number 0=A 1=B ... */ - short st_ino; /* Always zero ? */ - short st_mode; /* See above constants */ - short st_nlink; /* Number of links. */ - int st_uid; /* User: Maybe significant on NT ? */ - short st_gid; /* Group: Ditto */ - short st_rdev; /* Seems useless (not even filled in) */ - long st_size; /* File size in bytes */ - time_t st_atime; /* Accessed date (always 00:00 hrs local - * on FAT) */ - time_t st_mtime; /* Modified time */ - time_t st_ctime; /* Creation time */ -}; - - -int _fstat (int nHandle, struct stat* pstat); -int _chmod (const char* szPath, int nMode); -int _stat (const char* szPath, struct stat* pstat); - - -#ifndef _NO_OLDNAMES - -/* These functions live in liboldnames.a. */ -int fstat (int nHandle, struct stat* pstat); -int chmod (const char* szPath, int nMode); -int stat (const char* szPath, struct stat* pstat); - -#endif /* Not _NO_OLDNAMES */ - - -#ifdef __cplusplus -} -#endif - -#endif /* Not _STAT_H_ */ - -#endif /* Not __STRICT_ANSI__ */ diff --git a/reactos/include/sys/types.h b/reactos/include/sys/types.h deleted file mode 100644 index 06470933c24..00000000000 --- a/reactos/include/sys/types.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * types.h - * - * The definition of constants, data types and global variables. - * - * This file is part of the Mingw32 package. - * - * Contributors: - * Created by Colin Peters - * Lots of types supplied by Pedro A. Aranda - * - * THIS SOFTWARE IS NOT COPYRIGHTED - * - * This source code is offered for use in the public domain. You may - * use, modify or distribute it freely. - * - * This code is distributed in the hope that it will be useful but - * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY - * DISCLAMED. This includes but is not limited to warrenties of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * $Revision: 1.2 $ - * $Author: ariadne $ - * $Date: 1999/02/21 13:29:57 $ - * - */ -/* Appropriated for Reactos Crtdll by Ariadne */ - -#ifndef _TYPES_H_ -#define _TYPES_H_ - -#define __need_wchar_t -#define __need_size_t -#define __need_ptrdiff_t -#include - -#ifndef RC_INVOKED - -#ifndef _TIME_T_ -#define _TIME_T_ -typedef long time_t; -#endif - - -#ifndef __STRICT_ANSI__ - -#ifndef _OFF_T_ -#define _OFF_T_ -typedef long _off_t; - -#ifndef _NO_OLDNAMES -typedef _off_t off_t; -#endif -#endif /* Not _OFF_T_ */ - - -#ifndef _DEV_T_ -#define _DEV_T_ -typedef short _dev_t; - -#ifndef _NO_OLDNAMES -typedef _dev_t dev_t; -#endif -#endif /* Not _DEV_T_ */ - - -#ifndef _INO_T_ -#define _INO_T_ -typedef short _ino_t; - -#ifndef _NO_OLDNAMES -typedef _ino_t ino_t; -#endif -#endif /* Not _INO_T_ */ - - -#ifndef _PID_T_ -#define _PID_T_ -typedef int _pid_t; - -#ifndef _NO_OLDNAMES -typedef _pid_t pid_t; -#endif -#endif /* Not _PID_T_ */ - - -#ifndef _MODE_T_ -#define _MODE_T_ -typedef unsigned short _mode_t; - -#ifndef _NO_OLDNAMES -typedef _mode_t mode_t; -#endif -#endif /* Not _MODE_T_ */ - - -#ifndef _SIGSET_T_ -#define _SIGSET_T_ -typedef int _sigset_t; - - - -#ifndef _NO_OLDNAMES -typedef _sigset_t sigset_t; -#endif -#endif /* Not _SIGSET_T_ */ - -#endif /* Not __STRICT_ANSI__ */ - -#endif /* Not RC_INVOKED */ - -#endif /* Not _TYPES_H_ */ diff --git a/reactos/include/types.h b/reactos/include/types.h deleted file mode 100644 index d7ad3dfe328..00000000000 --- a/reactos/include/types.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Added wide character type wchar_t, june 1998 -- Boudewijn Dekker - */ -#ifndef _LINUX_TYPES_H -#define _LINUX_TYPES_H - -#ifndef NULL -# define NULL ((void *) 0) -#endif - - -#ifndef _I386_TYPES_H -#define _I386_TYPES_H - -/* - * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the - * header files exported to user space - */ - -typedef __signed__ char __s8; -typedef unsigned char __u8; - -typedef __signed__ short __s16; -typedef unsigned short __u16; - -typedef __signed__ int __s32; -typedef unsigned int __u32; - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -typedef __signed__ long long __s64; -typedef unsigned long long __u64; -#endif - -/* - * These aren't exported outside the kernel to avoid name space clashes - */ -#ifdef __KERNEL__ - -typedef signed char s8; -typedef unsigned char u8; - -typedef signed short s16; -typedef unsigned short u16; - -typedef signed int s32; -typedef unsigned int u32; - -typedef signed long long s64; -typedef unsigned long long u64; - -#endif /* __KERNEL__ */ - -#endif - - -typedef unsigned int size_t; -typedef size_t __kernel_size_t; -//typedef unsigned short wchar_t; - - -#endif /* _LINUX_TYPES_H */ diff --git a/reactos/include/wchar.h b/reactos/include/wchar.h deleted file mode 100644 index 94866a4f9e9..00000000000 --- a/reactos/include/wchar.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * wchar.h - * - * Defines of all functions for supporting wide characters. Actually it - * just includes all those headers, which is not a good thing to do from a - * processing time point of view, but it does mean that everything will be - * in sync. - * - * This file is part of the Mingw32 package. - * - * THIS SOFTWARE IS NOT COPYRIGHTED - * - * This source code is offered for use in the public domain. You may - * use, modify or distribute it freely. - * - * This code is distributed in the hope that it will be useful but - * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY - * DISCLAMED. This includes but is not limited to warranties of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * $Revision: 1.3 $ - * $Author: ariadne $ - * $Date: 1999/02/21 17:43:45 $ - * - */ - -#include -#include -#include -#include -#include diff --git a/reactos/include/wstring.h b/reactos/include/wstring.h deleted file mode 100644 index 1075d418f84..00000000000 --- a/reactos/include/wstring.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Adapted from linux for the reactos kernel, march 1998 -- David Welch - * Added wide character string functions, june 1998 -- Boudewijn Dekker - * Removed extern specifier from ___wcstok, june 1998 -- Boudewijn Dekker - * Added wcsicmp and wcsnicmp -- Boudewijn Dekker - */ - -#ifndef _STRING_H_ -#define _STRING_H_ - - -#ifndef _LINUX_WSTRING_H_ -#define _LINUX_WSTRING_H_ - -#include - - - - - -#ifndef _WCHAR_T_ -#define _WCHAR_T_ -#define _WCHAR_T - typedef unsigned short wchar_t; -#endif -#define Aa_Difference (L'A'-L'a') - -#define towupper(c) (((c>=L'a') && (c<=L'z')) ? c+Aa_Difference : c) -#define towlower(c) (((c>=L'A') && (c<=L'Z')) ? c-Aa_Difference : c) - -//obsolete -wchar_t wtolower(wchar_t c ); -wchar_t wtoupper(wchar_t c ); - - -#define iswlower(c) ((c) >= L'a' && (c) <= L'z') -#define iswupper(c) ((c) >= L'A' && (c) <= L'Z') - -#define iswdigit(c) ((c) >= L'0' && (c) <= L'9') -#define iswxdigit(c) (((c) >= L'0' && (c) <= L'9') || ((c) >= L'A' && (c) <= L'F') || ((c) >= L'a' && (c) <= L'f') ) - -#ifndef NULL -#define NULL ((void *) 0) -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -//wchar_t * ___wcstok = NULL; -wchar_t * wcscpy(wchar_t *,const wchar_t *); -wchar_t * wcsncpy(wchar_t *,const wchar_t *, size_t); -wchar_t * wcscat(wchar_t *, const wchar_t *); -wchar_t * wcsncat(wchar_t *, const wchar_t *, size_t); -int wcscmp(const wchar_t *,const wchar_t *); -int wcsncmp(const wchar_t *,const wchar_t *,size_t); -wchar_t* wcschr(const wchar_t* str, wchar_t ch); -wchar_t * wcsrchr(const wchar_t *,wchar_t); -wchar_t * wcspbrk(const wchar_t *,const wchar_t *); -wchar_t * wcstok(wchar_t *,const wchar_t *); -wchar_t * wcsstr(const wchar_t *,const wchar_t *); -size_t wcslen(const wchar_t * s); -size_t wcsnlen(const wchar_t * s, size_t count); -int wcsicmp(const wchar_t* cs,const wchar_t * ct); -int wcsnicmp(const wchar_t* cs,const wchar_t * ct, size_t count); -size_t wcsspn(const wchar_t *str,const wchar_t *accept); -size_t wcscspn(const wchar_t *str,const wchar_t *reject); -wchar_t *wcsrev(wchar_t *s); -wchar_t *wcsstr(const wchar_t *s,const wchar_t *b); -wchar_t *wcsdup(const wchar_t *ptr); -wchar_t *wcsupr(wchar_t *x); -wchar_t * wcslwr(wchar_t *x); - -//obsolete -size_t wstrlen(const wchar_t * s); -int wcscmpi (const wchar_t* ws1, const wchar_t* ws2); - - - - - -#ifdef __cplusplus -} -#endif - -#endif - -#endif diff --git a/reactos/lib/advapi32/reg/reg.c b/reactos/lib/advapi32/reg/reg.c index 9ed9848cedd..e09439a8e5a 100644 --- a/reactos/lib/advapi32/reg/reg.c +++ b/reactos/lib/advapi32/reg/reg.c @@ -859,3 +859,4 @@ RegUnLoadKeyW( /* EOF */ + diff --git a/reactos/lib/advapi32/sec/sec.c b/reactos/lib/advapi32/sec/sec.c index 9431075b695..1c008bc1d0f 100644 --- a/reactos/lib/advapi32/sec/sec.c +++ b/reactos/lib/advapi32/sec/sec.c @@ -14,4 +14,4 @@ GetSecurityDescriptorLength ( ) { return RtlSetSecurityDescriptorLength(pSecurityDescriptor); -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/conio/cputs.c b/reactos/lib/crtdll/conio/cputs.c index 05dfab50dfc..01c62795d02 100644 --- a/reactos/lib/crtdll/conio/cputs.c +++ b/reactos/lib/crtdll/conio/cputs.c @@ -18,4 +18,4 @@ int cputs(const char *_str) if ( !WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),_str,len,&written,NULL)) return -1; return 0; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/conio/getch.c b/reactos/lib/crtdll/conio/getch.c index 90f6fa1128a..5da123465ce 100644 --- a/reactos/lib/crtdll/conio/getch.c +++ b/reactos/lib/crtdll/conio/getch.c @@ -7,15 +7,17 @@ * UPDATE HISTORY: * 28/12/98: Created */ -#include #include #include -#include - +#include extern int char_avail; extern int ungot_char; +int getch( void ) +{ + return _getch(); +} int _getch(void) @@ -30,7 +32,7 @@ _getch(void) } else { - ReadConsoleA(_get_osfhandle(stdin->_file), &c,1,&NumberOfCharsRead ,NULL); + ReadConsoleA(filehnd(stdin->_file), &c,1,&NumberOfCharsRead ,NULL); } if ( c == 10 ) diff --git a/reactos/lib/crtdll/conio/ungetch.c b/reactos/lib/crtdll/conio/ungetch.c index 5e08fdadc21..17c28fb3b0f 100644 --- a/reactos/lib/crtdll/conio/ungetch.c +++ b/reactos/lib/crtdll/conio/ungetch.c @@ -25,4 +25,4 @@ ungetch(int c) ungot_char = c; char_avail = 1; return(c); -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/ctype/isctype.c b/reactos/lib/crtdll/ctype/isctype.c index e5c07913d1a..90de53c2d59 100644 --- a/reactos/lib/crtdll/ctype/isctype.c +++ b/reactos/lib/crtdll/ctype/isctype.c @@ -301,4 +301,3 @@ int is_wctype(unsigned short c, int t) return ((_pctype_dll[(c & 0xFF)]&t) == t ); } - diff --git a/reactos/lib/crtdll/direct/chdir.c b/reactos/lib/crtdll/direct/chdir.c index 87a0ca49868..39e651a5c3e 100644 --- a/reactos/lib/crtdll/direct/chdir.c +++ b/reactos/lib/crtdll/direct/chdir.c @@ -2,7 +2,8 @@ #include #include - +char _SetCurrentDirectory(char *dir); +int _GetCurrentDirectory(int count,char *buffer); #undef chdir int chdir( const char *_path ) diff --git a/reactos/lib/crtdll/direct/getdfree.c b/reactos/lib/crtdll/direct/getdfree.c index 333229339a0..0b1d538b2d3 100644 --- a/reactos/lib/crtdll/direct/getdfree.c +++ b/reactos/lib/crtdll/direct/getdfree.c @@ -16,4 +16,4 @@ unsigned int _getdiskfree(unsigned int _drive, struct _diskfree_t *_diskspace) if ( !GetDiskFreeSpaceA(RootPathName,&_diskspace->sectors_per_cluster,&_diskspace->bytes_per_sector,&_diskspace->avail_clusters,&_diskspace->total_clusters ) ) return 0; return _diskspace->avail_clusters; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/direct/mkdir.c b/reactos/lib/crtdll/direct/mkdir.c index 059eab6e41a..4d359f65068 100644 --- a/reactos/lib/crtdll/direct/mkdir.c +++ b/reactos/lib/crtdll/direct/mkdir.c @@ -11,4 +11,4 @@ int _mkdir( const char *_path ) if (!CreateDirectoryA(_path,NULL)) return -1; return 0; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/direct/rmdir.c b/reactos/lib/crtdll/direct/rmdir.c index 8890006dac8..2027994558f 100644 --- a/reactos/lib/crtdll/direct/rmdir.c +++ b/reactos/lib/crtdll/direct/rmdir.c @@ -12,4 +12,4 @@ int _rmdir( const char *_path ) if (!RemoveDirectoryA(_path)) return -1; return 0; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/io/access.c b/reactos/lib/crtdll/io/access.c index d7108c1d08f..6b6fb7278fb 100644 --- a/reactos/lib/crtdll/io/access.c +++ b/reactos/lib/crtdll/io/access.c @@ -1,5 +1,16 @@ -#include #include +#include + +#define F_OK 0x01 +#define R_OK 0x02 +#define W_OK 0x04 +#define X_OK 0x08 +#define D_OK 0x10 + +int access(const char *_path, int _amode) +{ + return _access(_path,_amode); +} int _access( const char *_path, int _amode ) { @@ -8,13 +19,13 @@ int _access( const char *_path, int _amode ) if ( Attributes == -1 ) return -1; - if ( (_amode & W_OK) == W_OK ) { + if ( _amode & W_OK == W_OK ) { if ( (Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY ) return -1; } - if ( (_amode & D_OK) != D_OK ) { - if ( (Attributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY ) - return -1; + if ( _amode & D_OK == D_OK ) { + if ( (Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY ) + return 0; } return 0; diff --git a/reactos/lib/crtdll/io/close.c b/reactos/lib/crtdll/io/close.c index 2431a04cd05..d51a7f0a923 100644 --- a/reactos/lib/crtdll/io/close.c +++ b/reactos/lib/crtdll/io/close.c @@ -1,10 +1,16 @@ -#include #include -#include +#include +//#include + + +int close(int _fd) +{ + return _close(_fd); +} int _close(int _fd) { - CloseHandle(_get_osfhandle(_fd)); + CloseHandle(filehnd(_fd)); return __fileno_close(_fd); } diff --git a/reactos/lib/crtdll/io/create.c b/reactos/lib/crtdll/io/create.c index 402c51e4916..bd382e9218b 100644 --- a/reactos/lib/crtdll/io/create.c +++ b/reactos/lib/crtdll/io/create.c @@ -1,8 +1,8 @@ #include #include - -int _creat(const char *filename, int mode) +#undef creat +int creat(const char *filename, int mode) { - return _open(filename,_O_CREAT|_O_TRUNC,mode); + return open(filename,_O_CREAT|_O_TRUNC,mode); } diff --git a/reactos/lib/crtdll/io/dup.c b/reactos/lib/crtdll/io/dup.c index 12a09226825..ef19d4975b7 100644 --- a/reactos/lib/crtdll/io/dup.c +++ b/reactos/lib/crtdll/io/dup.c @@ -1,9 +1,13 @@ #include #include - - -int _dup( int _fd ) +#undef dup +int dup( int handle ) { - return _open_osfhandle(_get_osfhandle(_fd), 0666); + return _dup(handle); +} + +int _dup( int handle ) +{ + return _open_osfhandle(filehnd(handle), 0666); } diff --git a/reactos/lib/crtdll/io/dup2.c b/reactos/lib/crtdll/io/dup2.c index e59fa232163..bafe19a5198 100644 --- a/reactos/lib/crtdll/io/dup2.c +++ b/reactos/lib/crtdll/io/dup2.c @@ -1,9 +1,14 @@ #include #include -#include - -int _dup2( int _fd1, int _fd2 ) +#undef dup2 +int dup2( int handle1, int handle2 ) { - return __fileno_dup2( _fd1, _fd2 ); + return _dup2(handle1,handle2); +} + + +int _dup2( int handle1, int handle2 ) +{ + return __fileno_dup2( handle1, handle2 ); } diff --git a/reactos/lib/crtdll/io/find.c b/reactos/lib/crtdll/io/find.c index 5010cf15f4a..2015fef82fe 100644 --- a/reactos/lib/crtdll/io/find.c +++ b/reactos/lib/crtdll/io/find.c @@ -2,6 +2,10 @@ #include #include +#if 0 + +//UnixTimeToFileTime +//FileTimeToUnixTime /* * DOS file system functions * @@ -14,7 +18,7 @@ void UnixTimeToFileTime( time_t unix_time, FILETIME *filetime, DWORD remainder ) time_t FileTimeToUnixTime( const FILETIME *filetime, DWORD *remainder ); -int _findfirst(const char *_name, struct _finddata_t *result) +long _findfirst(char *_name, struct _finddata_t *result) { WIN32_FIND_DATA FindFileData; char dir[MAX_PATH]; @@ -28,7 +32,7 @@ int _findfirst(const char *_name, struct _finddata_t *result) } else strcpy(dir,_name); - hFindFile = FindFirstFileA( dir, &FindFileData ); + hFindFile = FindFirstFile( dir, &FindFileData ); result->attrib = FindFileData.dwFileAttributes; @@ -40,7 +44,7 @@ int _findfirst(const char *_name, struct _finddata_t *result) return hFindFile; } -int _findnext(int handle, struct _finddata_t *result) +int _findnext(long handle, struct _finddata_t *result) { WIN32_FIND_DATA FindFileData; if (handle == -1 ) @@ -57,7 +61,7 @@ int _findnext(int handle, struct _finddata_t *result) strncpy(result->name,&FindFileData.cFileName,260); return 0; } -int _findclose(int handle) +int _findclose(long handle) { return FindClose(handle); } @@ -248,4 +252,4 @@ time_t FileTimeToUnixTime( const FILETIME *filetime, DWORD *remainder ) } - +#endif diff --git a/reactos/lib/crtdll/io/fmode.c b/reactos/lib/crtdll/io/fmode.c index 35f4c1b3eb3..6fd48c8d2bf 100644 --- a/reactos/lib/crtdll/io/fmode.c +++ b/reactos/lib/crtdll/io/fmode.c @@ -6,3 +6,4 @@ unsigned int _fmode = O_TEXT; unsigned int *_fmode_dll = &_fmode; + diff --git a/reactos/lib/crtdll/io/isatty.c b/reactos/lib/crtdll/io/isatty.c index b1437809963..a8a74e631a2 100644 --- a/reactos/lib/crtdll/io/isatty.c +++ b/reactos/lib/crtdll/io/isatty.c @@ -1,10 +1,8 @@ #include +#undef isatty - -int _isatty( int handle ) +int isatty( int handle ) { - if ( handle < 5 ) - return 1; - return 0; + return (handle & 3); } diff --git a/reactos/lib/crtdll/io/lseek.c b/reactos/lib/crtdll/io/lseek.c index f078cf8bd30..cba29e64f4d 100644 --- a/reactos/lib/crtdll/io/lseek.c +++ b/reactos/lib/crtdll/io/lseek.c @@ -1,9 +1,16 @@ #include #include +//#include -off_t _lseek(int _fd, off_t _offset, int _whence) +#undef lseek +long lseek(int _fildes, long _offset, int _whence) { - return _llseek((HFILE)_get_osfhandle(_fd),_offset,_whence); + return _lseek(_fildes,_offset,_whence); +} + +long _lseek(int _fildes, long _offset, int _whence) +{ + //return _llseek(filehnd(_fildes),_offset,_whence); } diff --git a/reactos/lib/crtdll/io/open.c b/reactos/lib/crtdll/io/open.c index e17f5378b8e..eb68528ca32 100644 --- a/reactos/lib/crtdll/io/open.c +++ b/reactos/lib/crtdll/io/open.c @@ -36,6 +36,16 @@ char __is_text_file(FILE *p) { + +int __fileno_alloc(HANDLE hFile, int mode); + +// fixme +#undef open +int open(const char *_path, int _oflag,...) +{ + return _open(_path,_oflag); +} + int _open(const char *_path, int _oflag,...) { @@ -158,7 +168,7 @@ __fileno_alloc(HANDLE hFile, int mode) return i; } -void *_get_osfhandle(int fileno) +void *filehnd(int fileno) { @@ -235,8 +245,6 @@ int __fileno_close(int _fd) fileno_modes[_fd].fd = -1; fileno_modes[_fd].hFile = (HANDLE)-1; - - return 0; } diff --git a/reactos/lib/crtdll/io/read.c b/reactos/lib/crtdll/io/read.c index 332ae71cb13..c8a6ee35bcc 100644 --- a/reactos/lib/crtdll/io/read.c +++ b/reactos/lib/crtdll/io/read.c @@ -10,11 +10,15 @@ #include #include - +size_t read(int _fd, void *_buf, size_t _nbyte) +{ + return _read(_fd,_buf,_nbyte); +} size_t _read(int _fd, void *_buf, size_t _nbyte) { size_t _rbyte; - if ( !ReadFile(_get_osfhandle(_fd),_buf,_nbyte,&_rbyte,NULL) ) { + if ( !ReadFile(filehnd(_fd),_buf,_nbyte,&_rbyte,NULL) ) { + printf("%d\n",GetLastError()); return -1; } diff --git a/reactos/lib/crtdll/io/setmode.c b/reactos/lib/crtdll/io/setmode.c index f5b9ff58dc2..8510f56e77f 100644 --- a/reactos/lib/crtdll/io/setmode.c +++ b/reactos/lib/crtdll/io/setmode.c @@ -21,4 +21,4 @@ int setmode(int _fd, int _newmode) int _setmode(int _fd, int _newmode) { return __fileno_setmode(_fd, _newmode); -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/io/unlink.c b/reactos/lib/crtdll/io/unlink.c index c051e604b61..d8ac7c29917 100644 --- a/reactos/lib/crtdll/io/unlink.c +++ b/reactos/lib/crtdll/io/unlink.c @@ -10,10 +10,14 @@ #include #include +int unlink( const char *filename ) +{ + return _unlink(filename); +} int _unlink( const char *filename ) { - if ( !DeleteFileA(filename) ) + if ( !DeleteFile(filename) ) return -1; return 0; } diff --git a/reactos/lib/crtdll/io/write.c b/reactos/lib/crtdll/io/write.c index 4209b0bed8a..5572b60f620 100644 --- a/reactos/lib/crtdll/io/write.c +++ b/reactos/lib/crtdll/io/write.c @@ -10,11 +10,16 @@ #include #include +int write(int _fd, const void *_buf,int _nbyte) +{ + return _write(_fd,_buf,_nbyte); +} size_t _write(int _fd, const void *_buf, size_t _nbyte) { size_t _wbyte; - if ( !WriteFile(_get_osfhandle(_fd),_buf,_nbyte,(DWORD *)&_wbyte,NULL) ) { + if ( !WriteFile(filehnd(_fd),_buf,_nbyte,&_wbyte,NULL) ) { + printf("%d\n",GetLastError()); return -1; } return _wbyte; diff --git a/reactos/lib/crtdll/misc/GetArgs.c b/reactos/lib/crtdll/misc/GetArgs.c index cd581898e89..b6e6f5da59d 100644 --- a/reactos/lib/crtdll/misc/GetArgs.c +++ b/reactos/lib/crtdll/misc/GetArgs.c @@ -50,13 +50,13 @@ int __GetMainArgs(int *argc,char ***argv,char **env,int flag) cmdline = GetCommandLineA(); afterlastspace=0; - //dprintf("cmdline '%s'\n",cmdline); + dprintf("cmdline '%s'\n",cmdline); while (cmdline[i]) { if (cmdline[i]==' ') { - // dprintf("cmdline '%s'\n",cmdline); + dprintf("cmdline '%s'\n",cmdline); __argc++; cmdline[i]='\0'; __argv[__argc-1] = strdup( cmdline+afterlastspace); @@ -90,7 +90,7 @@ int __GetMainArgs(int *argc,char ***argv,char **env,int flag) return 0; } -int _chkstk(void) +int _chkstk() { return 0; } diff --git a/reactos/lib/crtdll/misc/sleep.c b/reactos/lib/crtdll/misc/sleep.c index 301edcffde8..8735808c110 100644 --- a/reactos/lib/crtdll/misc/sleep.c +++ b/reactos/lib/crtdll/misc/sleep.c @@ -4,4 +4,4 @@ void sleep(unsigned long timeout) { Sleep((timeout)?timeout:1); -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/misc/unwind.c b/reactos/lib/crtdll/misc/unwind.c index 38e9027fc2c..a69fba1e625 100644 --- a/reactos/lib/crtdll/misc/unwind.c +++ b/reactos/lib/crtdll/misc/unwind.c @@ -7,4 +7,4 @@ void _global_unwind2( PEXCEPTION_FRAME frame ) void _local_unwind2( PEXCEPTION_FRAME endframe, DWORD nr ) { TRACE(crtdll,"(%p,%ld)\n",endframe,nr); -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/process/Cwait.c b/reactos/lib/crtdll/process/Cwait.c index 2217f14c765..e7fdb2268a3 100644 --- a/reactos/lib/crtdll/process/Cwait.c +++ b/reactos/lib/crtdll/process/Cwait.c @@ -17,4 +17,4 @@ int _cwait( int *termstat, int procHandle, int action ) return -1; // WAIT_TIMEOUT -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/process/execl.c b/reactos/lib/crtdll/process/execl.c index 1e191848bad..f971024031f 100644 --- a/reactos/lib/crtdll/process/execl.c +++ b/reactos/lib/crtdll/process/execl.c @@ -4,7 +4,7 @@ extern char *const *_environ; -int _execl(const char *path, const char *argv0, ...) +int execl(const char *path, const char *argv0, ...) { - return _spawnve(P_OVERLAY, path, (const char *const*)&argv0,(const char *const*) _environ); + return spawnve(P_OVERLAY, path, (char *const*)&argv0, _environ); } diff --git a/reactos/lib/crtdll/process/execle.c b/reactos/lib/crtdll/process/execle.c index 3d7c3b30650..c68ec0f0868 100644 --- a/reactos/lib/crtdll/process/execle.c +++ b/reactos/lib/crtdll/process/execle.c @@ -10,8 +10,8 @@ u.ccp = *++ptr; \ ptr = u.ccpp; -int _execle(const char *path, const char *argv0, ... /*, const char **envp */) +int execle(const char *path, const char *argv0, ... /*, const char **envp */) { scan_ptr(); - return _spawnve(P_OVERLAY, path, (const char *const *)&argv0, (const char *const *)ptr); + return spawnve(P_OVERLAY, path, (char *const *)&argv0, (char *const *)ptr); } diff --git a/reactos/lib/crtdll/process/execlp.c b/reactos/lib/crtdll/process/execlp.c index ab9cbe3fb36..45c11924729 100644 --- a/reactos/lib/crtdll/process/execlp.c +++ b/reactos/lib/crtdll/process/execlp.c @@ -3,9 +3,9 @@ #include -extern char **_environ; +extern char * const *_environ; -int _execlp(const char *path, const char *argv0, ...) +int execlp(const char *path, const char *argv0, ...) { - return _spawnvpe(P_OVERLAY, path, (const char * const *)&argv0,(const char *const*) _environ); + return spawnvpe(P_OVERLAY, path, (char * const *)&argv0, _environ); } diff --git a/reactos/lib/crtdll/process/execlpe.c b/reactos/lib/crtdll/process/execlpe.c index 9afa1137b86..da5f70848e5 100644 --- a/reactos/lib/crtdll/process/execlpe.c +++ b/reactos/lib/crtdll/process/execlpe.c @@ -10,8 +10,8 @@ u.ccp = *++ptr; \ ptr = u.ccpp; -int _execlpe(const char *path, const char *argv0, ... /*, const char **envp */) +int execlpe(const char *path, const char *argv0, ... /*, const char **envp */) { scan_ptr(); - return _spawnvpe(P_OVERLAY, path, (const char * const *)&argv0, (const char * const *)ptr); + return spawnvpe(P_OVERLAY, path, (char * const *)&argv0, (char * const *)ptr); } diff --git a/reactos/lib/crtdll/process/execv.c b/reactos/lib/crtdll/process/execv.c index 20a525ede8d..893cf85533a 100644 --- a/reactos/lib/crtdll/process/execv.c +++ b/reactos/lib/crtdll/process/execv.c @@ -1,10 +1,11 @@ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - +//#include +//#include #include extern char * const *_environ; -int _execv(const char *path, const char * const *argv) +int execv(const char *path, const char * const *argv) { - return _spawnve(P_OVERLAY, path, argv,(const char *const*) _environ); + return spawnve(P_OVERLAY, path, argv, _environ); } diff --git a/reactos/lib/crtdll/process/execve.c b/reactos/lib/crtdll/process/execve.c index 2bc3ca821d5..38b4a96b7c2 100644 --- a/reactos/lib/crtdll/process/execve.c +++ b/reactos/lib/crtdll/process/execve.c @@ -1,8 +1,9 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - +//#include +//#include #include -int _execve(const char *path,const char * const argv[], char * const envp[]) +int execve(const char *path,const char * const argv[], char * const envp[]) { - return _spawnve(P_OVERLAY, path, argv, envp); + return spawnve(P_OVERLAY, path, argv, envp); } diff --git a/reactos/lib/crtdll/process/execvp.c b/reactos/lib/crtdll/process/execvp.c index 6b5f3088104..cdaad875545 100644 --- a/reactos/lib/crtdll/process/execvp.c +++ b/reactos/lib/crtdll/process/execvp.c @@ -1,9 +1,11 @@ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +//#include +//#include #include extern char *const *_environ; -int _execvp(const char *path,const char * const argv[]) +int execvp(const char *path,const char * const argv[]) { - return _spawnvpe(P_OVERLAY,path,(const char *const*) argv,(const char *const*) _environ); + return spawnvpe(P_OVERLAY, path, argv, _environ); } diff --git a/reactos/lib/crtdll/process/execvpe.c b/reactos/lib/crtdll/process/execvpe.c index 4d1a4c23e4f..7dc668bb1e1 100644 --- a/reactos/lib/crtdll/process/execvpe.c +++ b/reactos/lib/crtdll/process/execvpe.c @@ -3,10 +3,13 @@ #include -int _execvpe(const char *path,const char * const argv[],const char * const envp[]) +int execvpe(const char *path,const char * const argv[],const char * const envp[]) { - return _spawnvpe(P_OVERLAY, path, argv, envp); + return spawnvpe(P_OVERLAY, path, argv, envp); } - +int _execvpe(const char *path,const char * const argv[],const char * const envp[]) +{ + return spawnvpe(P_OVERLAY, path, argv, envp); +} diff --git a/reactos/lib/crtdll/process/spawnl.c b/reactos/lib/crtdll/process/spawnl.c index a706a87aa46..0397fb90413 100644 --- a/reactos/lib/crtdll/process/spawnl.c +++ b/reactos/lib/crtdll/process/spawnl.c @@ -2,9 +2,9 @@ #include -extern char *_environ[]; +extern char **_environ; -int _spawnl(int mode, const char *path, const char *argv0, ...) +int spawnl(int mode, const char *path, const char *argv0, ...) { - return _spawnve(mode, path, (const char * const *)&argv0,(const char *const *) _environ); + return spawnve(mode, path, (char * const *)&argv0, _environ); } diff --git a/reactos/lib/crtdll/process/spawnle.c b/reactos/lib/crtdll/process/spawnle.c index cf14aa54d11..157caad1fe5 100644 --- a/reactos/lib/crtdll/process/spawnle.c +++ b/reactos/lib/crtdll/process/spawnle.c @@ -9,8 +9,8 @@ u.ccp = *++ptr; \ ptr = u.ccpp; -int _spawnle(int mode, const char *path, const char *argv0, ... /*, const char **envp */) +int spawnle(int mode, const char *path, const char *argv0, ... /*, const char **envp */) { scan_ptr(); - return _spawnve(mode, path, (const char * const *)&argv0, (const char * const *)ptr); + return spawnve(mode, path, (char * const *)&argv0, (char * const *)ptr); } diff --git a/reactos/lib/crtdll/process/spawnlp.c b/reactos/lib/crtdll/process/spawnlp.c index 4d1a1107694..8813e5cf3a3 100644 --- a/reactos/lib/crtdll/process/spawnlp.c +++ b/reactos/lib/crtdll/process/spawnlp.c @@ -4,7 +4,7 @@ extern char **_environ; -int _spawnlp(int mode, const char *path, const char *argv0, ...) +int spawnlp(int mode, const char *path, const char *argv0, ...) { - return _spawnvpe(mode, path, (const char * const *)&argv0, (const char * const *)_environ); + return spawnvpe(mode, path, (char * const *)&argv0, (char * const *)_environ); } diff --git a/reactos/lib/crtdll/process/spawnlpe.c b/reactos/lib/crtdll/process/spawnlpe.c index 38558a4f7f7..908e2f4bc24 100644 --- a/reactos/lib/crtdll/process/spawnlpe.c +++ b/reactos/lib/crtdll/process/spawnlpe.c @@ -11,5 +11,5 @@ int spawnlpe(int mode, const char *path, const char *argv0, ... /*, const char **envp */) { scan_ptr(); - return spawnvpe(mode, path, (const char * const *)&argv0, (const char * const *)ptr); + return spawnvpe(mode, path, (char * const *)&argv0, (char * const *)ptr); } diff --git a/reactos/lib/crtdll/process/spawnv.c b/reactos/lib/crtdll/process/spawnv.c index edc135a9730..a41b777fff2 100644 --- a/reactos/lib/crtdll/process/spawnv.c +++ b/reactos/lib/crtdll/process/spawnv.c @@ -2,9 +2,9 @@ #include -extern char *_environ[]; +extern char **_environ; -int _spawnv(int mode, const char *path,const char *const argv[]) +int spawnv(int mode, const char *path,const char *const argv[]) { - return _spawnve(mode, path, (const char * const *)argv,(const char * const *) _environ); + return spawnve(mode, path, (char * const *)argv, _environ); } diff --git a/reactos/lib/crtdll/process/spawnve.c b/reactos/lib/crtdll/process/spawnve.c index 3d21e7b7c14..c848475154f 100644 --- a/reactos/lib/crtdll/process/spawnve.c +++ b/reactos/lib/crtdll/process/spawnve.c @@ -1,12 +1,11 @@ -#include #include #include +#include #include -#include int _p_overlay = 2; -int _spawnve(int mode, const char *path,const char *const argv[],const char *const envp[]) +int spawnve(int mode, const char *path,const char *const argv[],const char *const envp[]) { char ApplicationName[MAX_PATH]; @@ -29,15 +28,15 @@ int _spawnve(int mode, const char *path,const char *const argv[],const char *con StartupInfo.dwFlags = 0; - if ( CreateProcessA(ApplicationName,CommandLine,NULL,NULL,TRUE,CREATE_NEW_CONSOLE|NORMAL_PRIORITY_CLASS,NULL,*envp,&StartupInfo,&ProcessInformation) ) { - //errno = GetLastError(); - return -1; - } +// if ( CreateProcessA(ApplicationName,CommandLine,NULL,NULL,TRUE,CREATE_NEW_CONSOLE|NORMAL_PRIORITY_CLASS,NULL,*envp,&StartupInfo,&ProcessInformation) ) { +// errno = GetLastError(); +// return -1; +// } if (mode == P_OVERLAY) exit(i); // _P_NOWAIT or _P_NOWAITO - return (int)ProcessInformation.hProcess; + return ProcessInformation.hProcess; } diff --git a/reactos/lib/crtdll/process/spawnvp.c b/reactos/lib/crtdll/process/spawnvp.c index 5757a50db16..34b39ccba75 100644 --- a/reactos/lib/crtdll/process/spawnvp.c +++ b/reactos/lib/crtdll/process/spawnvp.c @@ -2,9 +2,9 @@ #include -extern char *_environ[]; +extern char **_environ; -int _spawnvp(int mode, const char *path,const char *const argv[]) +int spawnvp(int mode, const char *path,const char *const argv[]) { - return _spawnvpe(mode, path, (const char * const *)argv,(const char * const *) _environ); + return spawnvpe(mode, path, (char * const *)argv, _environ); } diff --git a/reactos/lib/crtdll/process/spawnvpe.c b/reactos/lib/crtdll/process/spawnvpe.c index b580de66760..4ba9a2ec148 100644 --- a/reactos/lib/crtdll/process/spawnvpe.c +++ b/reactos/lib/crtdll/process/spawnvpe.c @@ -4,10 +4,20 @@ #include -int _spawnvpe(int mode, const char *path,const char *const argv[],const char *const envp[]) +int spawnvpe(int mode, const char *path,const char *const argv[],const char *const envp[]) { -// djgpp does something like a searchpath here - - return _spawnve(mode, path, argv, envp); + + char rpath[300]; + union {const char * const *cpcp; char **cpp; } u; + u.cpcp = envp; +/* + if (!__dosexec_find_on_path(path, u.cpp, rpath)) + { + errno = ENOENT; + return -1; + } + else +*/ + return spawnve(mode, rpath, argv, envp); } diff --git a/reactos/lib/crtdll/stdio/allocfil.c b/reactos/lib/crtdll/stdio/allocfil.c index aea7a3ce75b..e438eb816a3 100644 --- a/reactos/lib/crtdll/stdio/allocfil.c +++ b/reactos/lib/crtdll/stdio/allocfil.c @@ -3,7 +3,8 @@ #include #include #include - +//#include +//#include FILE * __alloc_file(void); diff --git a/reactos/lib/crtdll/stdio/doprnt.c b/reactos/lib/crtdll/stdio/doprnt.c index 9e06dea9231..ad4a15a9436 100644 --- a/reactos/lib/crtdll/stdio/doprnt.c +++ b/reactos/lib/crtdll/stdio/doprnt.c @@ -315,10 +315,5 @@ int _doprnt(const char *fmt, va_list args, FILE *f) return 0; } -int _dowprnt(const wchar_t *fmt, va_list args, FILE *f) -{ - return 0; -} - diff --git a/reactos/lib/crtdll/stdio/fclose.c b/reactos/lib/crtdll/stdio/fclose.c index af32be0be83..dc6b79f4a88 100644 --- a/reactos/lib/crtdll/stdio/fclose.c +++ b/reactos/lib/crtdll/stdio/fclose.c @@ -1,12 +1,18 @@ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +//#include #include #include #include #include #include - +//#include #include +#if 0 +#ifndef __dj_include_stdio_h_ +#define _name_to_remove _tmpfname +#endif +#endif int fclose(FILE *f) diff --git a/reactos/lib/crtdll/stdio/fileno.c b/reactos/lib/crtdll/stdio/fileno.c index 7cd0160f1b5..a9e07e2caa0 100644 --- a/reactos/lib/crtdll/stdio/fileno.c +++ b/reactos/lib/crtdll/stdio/fileno.c @@ -10,4 +10,4 @@ int fileno(FILE *f) int _fileno(FILE *f) { return f->_file; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/stdio/flsbuf.c b/reactos/lib/crtdll/stdio/flsbuf.c index 24c8ab7455c..1cbfedc4669 100644 --- a/reactos/lib/crtdll/stdio/flsbuf.c +++ b/reactos/lib/crtdll/stdio/flsbuf.c @@ -1,9 +1,11 @@ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - +//#include #include #include #include +//#include +//#include #include #include diff --git a/reactos/lib/crtdll/stdio/fopen.c b/reactos/lib/crtdll/stdio/fopen.c index 40ee5b7d24d..a2121282968 100644 --- a/reactos/lib/crtdll/stdio/fopen.c +++ b/reactos/lib/crtdll/stdio/fopen.c @@ -1,14 +1,17 @@ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - +//#include #include #include #include #include +//#include #include - +//#include +//#include FILE * __alloc_file(void); +extern int _fmode; FILE * fopen(const char *file, const char *mode) diff --git a/reactos/lib/crtdll/stdio/fprintf.c b/reactos/lib/crtdll/stdio/fprintf.c index 014dcacf3c2..fbca105d4ed 100644 --- a/reactos/lib/crtdll/stdio/fprintf.c +++ b/reactos/lib/crtdll/stdio/fprintf.c @@ -24,26 +24,3 @@ fprintf(register FILE *iop, const char *fmt, ...) len = _doprnt(fmt, (&fmt)+1, iop); return ferror(iop) ? EOF : len; } - -int -fwprintf(register FILE *iop, const wchar_t *fmt, ...) -{ - int len; - wchar_t localbuf[BUFSIZ]; - - if (iop->_flag & _IONBF) - { - iop->_flag &= ~_IONBF; - iop->_ptr = iop->_base = localbuf; - iop->_bufsiz = BUFSIZ; - len = _dowprnt(fmt, (&fmt)+sizeof(wchar_t), iop); - fflush(iop); - iop->_flag |= _IONBF; - iop->_base = NULL; - iop->_bufsiz = 0; - iop->_cnt = 0; - } - else - len = _dowprnt(fmt, (va_list)(&fmt)+sizeof(wchar_t), iop); - return ferror(iop) ? EOF : len; -} diff --git a/reactos/lib/crtdll/stdio/fputs.c b/reactos/lib/crtdll/stdio/fputs.c index be90a5ed787..60b030b4b33 100644 --- a/reactos/lib/crtdll/stdio/fputs.c +++ b/reactos/lib/crtdll/stdio/fputs.c @@ -35,7 +35,7 @@ fputs(const char *s, FILE *f) return(r); */ int r = 0; - if ( !WriteFile(_get_osfhandle(f->_file),s,strlen(s),&r,NULL) ) + if ( !WriteFile(filehnd(f->_file),s,strlen(s),&r,NULL) ) return -1; return r; diff --git a/reactos/lib/crtdll/stdio/freopen.c b/reactos/lib/crtdll/stdio/freopen.c index 015d07d4c93..6940e852764 100644 --- a/reactos/lib/crtdll/stdio/freopen.c +++ b/reactos/lib/crtdll/stdio/freopen.c @@ -1,11 +1,13 @@ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - +//#include #include #include #include +//#include #include #include +extern int _fmode; FILE * freopen(const char *file, const char *mode, FILE *f) diff --git a/reactos/lib/crtdll/stdio/fscanf.c b/reactos/lib/crtdll/stdio/fscanf.c index b6249e415d6..2b134834565 100644 --- a/reactos/lib/crtdll/stdio/fscanf.c +++ b/reactos/lib/crtdll/stdio/fscanf.c @@ -9,7 +9,7 @@ fscanf(FILE *f, const char *fmt, ...) int r; va_list a=0; va_start(a, fmt); - r = _doscan(f, fmt,(void *) a); + r = _doscan(f, fmt, a); va_end(a); return r; } diff --git a/reactos/lib/crtdll/stdio/fsetpos.c b/reactos/lib/crtdll/stdio/fsetpos.c index 9798af92682..1511e188a04 100644 --- a/reactos/lib/crtdll/stdio/fsetpos.c +++ b/reactos/lib/crtdll/stdio/fsetpos.c @@ -3,7 +3,7 @@ #include int -fsetpos(FILE *stream, fpos_t *pos) +fsetpos(FILE *stream, const fpos_t *pos) { if (stream && pos) { diff --git a/reactos/lib/crtdll/stdio/getc.c b/reactos/lib/crtdll/stdio/getc.c index 5e3c3c87c60..fa976d4e6f9 100644 --- a/reactos/lib/crtdll/stdio/getc.c +++ b/reactos/lib/crtdll/stdio/getc.c @@ -1,15 +1,14 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include -#include #include #include - +#undef getc int getc(FILE *f) { int c; DWORD NumberOfBytesRead; - if ( !ReadFile(_get_osfhandle(f->_file),&c, 1, &NumberOfBytesRead, NULL) ) + if ( !ReadFile(filehnd(f->_file),&c, 1, &NumberOfBytesRead, NULL) ) return -1; if ( NumberOfBytesRead == 0 ) return -1; diff --git a/reactos/lib/crtdll/stdio/getenv.c b/reactos/lib/crtdll/stdio/getenv.c index fbbb27a8834..9ee76ca5e43 100644 --- a/reactos/lib/crtdll/stdio/getenv.c +++ b/reactos/lib/crtdll/stdio/getenv.c @@ -13,4 +13,4 @@ char *getenv(const char *name) if ( GetEnvironmentVariableA(name,buffer,MAX_PATH) == 0 ) return NULL; return buffer; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/stdio/printf.c b/reactos/lib/crtdll/stdio/printf.c index cb4acd850cd..0666bfb2e10 100644 --- a/reactos/lib/crtdll/stdio/printf.c +++ b/reactos/lib/crtdll/stdio/printf.c @@ -17,17 +17,3 @@ printf(const char *fmt, ...) return ferror(stdout) ? EOF : len; } - -int wprintf(const wchar_t *fmt, ...) -{ - int len; - - len = _dowprnt(fmt, (&fmt)+sizeof(wchar_t), stdout); - - /* People were confused when printf() didn't flush stdout, - so we'll do it to reduce confusion */ - if (stdout->_flag & _IOLBF) - fflush(stdout); - - return ferror(stdout) ? EOF : len; -} diff --git a/reactos/lib/crtdll/stdio/putc.c b/reactos/lib/crtdll/stdio/putc.c index 447568e8344..7db1d620ab1 100644 --- a/reactos/lib/crtdll/stdio/putc.c +++ b/reactos/lib/crtdll/stdio/putc.c @@ -21,7 +21,7 @@ int putc(int c, FILE *fp) } return(_flsbuf(c,fp)); } - if ( !WriteFile(_get_osfhandle(fp->_file),&c,1,&r,NULL) ) + if ( !WriteFile(filehnd(fp->_file),&c,1,&r,NULL) ) return -1; return r; diff --git a/reactos/lib/crtdll/stdio/puts.c b/reactos/lib/crtdll/stdio/puts.c index 0edc6c1e865..6df4b63a4e3 100644 --- a/reactos/lib/crtdll/stdio/puts.c +++ b/reactos/lib/crtdll/stdio/puts.c @@ -14,7 +14,7 @@ puts(const char *s) return putchar('\n'); */ int r = 0; - if ( !WriteFile(_get_osfhandle(stdout->_file),s,strlen(s),&r,NULL) ) + if ( !WriteFile(filehnd(stdout->_file),s,strlen(s),&r,NULL) ) return -1; return putchar('\n');; diff --git a/reactos/lib/crtdll/stdio/remove.c b/reactos/lib/crtdll/stdio/remove.c index 5230ada3efc..8fc77bdbda7 100644 --- a/reactos/lib/crtdll/stdio/remove.c +++ b/reactos/lib/crtdll/stdio/remove.c @@ -1,5 +1,4 @@ #include -#include int remove(const char *fn) { diff --git a/reactos/lib/crtdll/stdio/rename.c b/reactos/lib/crtdll/stdio/rename.c index fb471a39be9..d4b1ecbcbe1 100644 --- a/reactos/lib/crtdll/stdio/rename.c +++ b/reactos/lib/crtdll/stdio/rename.c @@ -2,9 +2,12 @@ #include #include - - int rename(const char *old, const char *new) +{ + return _rename(old,new); +} + +int _rename(const char *old, const char *new) { if ( !MoveFile(old,new) ) return -1; diff --git a/reactos/lib/crtdll/stdio/sprintf.c b/reactos/lib/crtdll/stdio/sprintf.c index 86012f5f939..87039b9a91e 100644 --- a/reactos/lib/crtdll/stdio/sprintf.c +++ b/reactos/lib/crtdll/stdio/sprintf.c @@ -17,16 +17,3 @@ sprintf(char *str, const char *fmt, ...) *_strbuf._ptr = 0; return len; } - -swprintf(wchar_t *str, const wchar_t *fmt, ...) -{ - FILE _strbuf; - int len; - - _strbuf._flag = _IOWRT|_IOSTRG; - _strbuf._ptr = str; - _strbuf._cnt = INT_MAX; - len = _dowprnt(fmt,(va_list) &(fmt)+sizeof(wchar_t), &_strbuf); - *_strbuf._ptr = 0; - return len; -} diff --git a/reactos/lib/crtdll/stdio/stdhnd.c b/reactos/lib/crtdll/stdio/stdhnd.c index 1cc788ce9a1..2cfcd121522 100644 --- a/reactos/lib/crtdll/stdio/stdhnd.c +++ b/reactos/lib/crtdll/stdio/stdhnd.c @@ -1,6 +1,7 @@ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include #include +//#include diff --git a/reactos/lib/crtdll/stdio/tempnam.c b/reactos/lib/crtdll/stdio/tempnam.c index 8d6a8c23516..9c510d7f2e3 100644 --- a/reactos/lib/crtdll/stdio/tempnam.c +++ b/reactos/lib/crtdll/stdio/tempnam.c @@ -14,4 +14,4 @@ char *_tempnam(const char *dir,const char *prefix ) TempFileName ); return TempFileName; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/stdio/tmpfile.c b/reactos/lib/crtdll/stdio/tmpfile.c index 11d04fb3f6a..9329fca80db 100644 --- a/reactos/lib/crtdll/stdio/tmpfile.c +++ b/reactos/lib/crtdll/stdio/tmpfile.c @@ -2,16 +2,22 @@ /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - +//#include #include #include #include #include #include +//#include #include #include #include +#if 0 +#ifndef __dj_include_stdio_h_ +#define _name_to_remove _tmpfname +#endif +#endif FILE * __alloc_file(void); diff --git a/reactos/lib/crtdll/stdio/vfprintf.c b/reactos/lib/crtdll/stdio/vfprintf.c index debfe0715b4..8b4f5e690f8 100644 --- a/reactos/lib/crtdll/stdio/vfprintf.c +++ b/reactos/lib/crtdll/stdio/vfprintf.c @@ -25,25 +25,3 @@ vfprintf(FILE *f, const char *fmt, va_list ap) len = _doprnt(fmt, ap, f); return (ferror(f) ? EOF : len); } - -int vfwprintf(FILE *f, const wchar_t *fmt, va_list ap) -{ - int len; - wchar_t localbuf[BUFSIZ]; - - if (f->_flag & _IONBF) - { - f->_flag &= ~_IONBF; - f->_ptr = f->_base = localbuf; - f->_bufsiz = BUFSIZ; - len = _dowprnt(fmt, ap, f); - (void)fflush(f); - f->_flag |= _IONBF; - f->_base = NULL; - f->_bufsiz = 0; - f->_cnt = 0; - } - else - len = _dowprnt(fmt, ap, f); - return (ferror(f) ? EOF : len); -} diff --git a/reactos/lib/crtdll/stdio/vprintf.c b/reactos/lib/crtdll/stdio/vprintf.c index 2c436e9e940..c9e71d9bb31 100644 --- a/reactos/lib/crtdll/stdio/vprintf.c +++ b/reactos/lib/crtdll/stdio/vprintf.c @@ -11,12 +11,3 @@ vprintf(const char *fmt, va_list ap) len = _doprnt(fmt, ap, stdout); return (ferror(stdout) ? EOF : len); } - -int -vwprintf(const wchar_t *fmt, va_list ap) -{ - int len; - - len = _dowprnt(fmt, ap, stdout); - return (ferror(stdout) ? EOF : len); -} \ No newline at end of file diff --git a/reactos/lib/crtdll/stdio/vsprintf.c b/reactos/lib/crtdll/stdio/vsprintf.c index ba4803bb839..425725acade 100644 --- a/reactos/lib/crtdll/stdio/vsprintf.c +++ b/reactos/lib/crtdll/stdio/vsprintf.c @@ -17,16 +17,3 @@ vsprintf(char *str, const char *fmt, va_list ap) *f._ptr = 0; return len; } - -vswprintf(wchar_t *str, const wchar_t *fmt, va_list ap) -{ - FILE f; - int len; - - f._flag = _IOWRT|_IOSTRG; - f._ptr = str; - f._cnt = INT_MAX; - len = _dowprnt(fmt, ap, &f); - *f._ptr = 0; - return len; -} \ No newline at end of file diff --git a/reactos/lib/crtdll/stdlib/Exit.c b/reactos/lib/crtdll/stdlib/Exit.c index 59364a9c53f..ee3e979f1bf 100644 --- a/reactos/lib/crtdll/stdlib/Exit.c +++ b/reactos/lib/crtdll/stdlib/Exit.c @@ -4,6 +4,7 @@ #include #include +void _exit(int _status); struct __atexit *__atexit_ptr = 0; @@ -33,7 +34,7 @@ exit(int status) void _exit(int _status) { - ExitProcess(_status); + //ExitProcess(_status); } void _cexit( void ) diff --git a/reactos/lib/crtdll/stdlib/abort.c b/reactos/lib/crtdll/stdlib/abort.c index 240796fa142..29ecabdc184 100644 --- a/reactos/lib/crtdll/stdlib/abort.c +++ b/reactos/lib/crtdll/stdlib/abort.c @@ -5,7 +5,7 @@ static char msg[] = "Abort!\r\n"; void -abort(void) +abort() { _write(stderr->_file, msg, sizeof(msg)-1); _exit(1); diff --git a/reactos/lib/crtdll/stdlib/abs.c b/reactos/lib/crtdll/stdlib/abs.c index 2b86f2d2c03..3bd28bd8339 100644 --- a/reactos/lib/crtdll/stdlib/abs.c +++ b/reactos/lib/crtdll/stdlib/abs.c @@ -2,7 +2,7 @@ #include int -abs(int _i) +abs(int j) { - return _i<0 ? -_i : _i; + return j<0 ? -j : j; } diff --git a/reactos/lib/crtdll/stdlib/atold.c b/reactos/lib/crtdll/stdlib/atold.c index 8f553452b63..ce3f33ac434 100644 --- a/reactos/lib/crtdll/stdlib/atold.c +++ b/reactos/lib/crtdll/stdlib/atold.c @@ -1,6 +1,5 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include -#include long double _atold(const char *ascii) diff --git a/reactos/lib/crtdll/stdlib/bsearch.c b/reactos/lib/crtdll/stdlib/bsearch.c index 48123456b77..5d6b5d64128 100644 --- a/reactos/lib/crtdll/stdlib/bsearch.c +++ b/reactos/lib/crtdll/stdlib/bsearch.c @@ -1,12 +1,11 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include -#include +// #include void * -bsearch(const void *key, const void *base0, size_t nelem, +bsearch(const void *key, const void *base, size_t nelem, size_t size, int (*cmp)(const void *ck, const void *ce)) { - char *base = unconst(base0, char *); int lim, cmpval; void *p; diff --git a/reactos/lib/crtdll/stdlib/errno.c b/reactos/lib/crtdll/stdlib/errno.c index be03d4e8249..e3c72ca7c93 100644 --- a/reactos/lib/crtdll/stdlib/errno.c +++ b/reactos/lib/crtdll/stdlib/errno.c @@ -1,17 +1,13 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include #include +#undef errno +int errno; + #undef _doserrno int _doserrno; -#undef errno -unsigned int errno; - - int *_errno(void) { - return &errno; } diff --git a/reactos/lib/crtdll/stdlib/fullpath.c b/reactos/lib/crtdll/stdlib/fullpath.c index a7844561803..35a68e7439e 100644 --- a/reactos/lib/crtdll/stdlib/fullpath.c +++ b/reactos/lib/crtdll/stdlib/fullpath.c @@ -10,9 +10,16 @@ #include #include +#undef fullpath +char *fullpath( char *absPath, const char *relPath, size_t maxLength ) +{ + return _fullpath(absPath,relPath,maxLength ); +} char *_fullpath( char *absPath, const char *relPath, size_t maxLength ) { + + char *lpFilePart; if ( GetFullPathName(relPath,maxLength,absPath,&lpFilePart) == 0 ) return NULL; diff --git a/reactos/lib/crtdll/stdlib/makepath.c b/reactos/lib/crtdll/stdlib/makepath.c index 6bc074fa1de..f851b672482 100644 --- a/reactos/lib/crtdll/stdlib/makepath.c +++ b/reactos/lib/crtdll/stdlib/makepath.c @@ -27,4 +27,4 @@ void _makepath( char *path, const char *drive, const char *dir, const char *fnam } -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/stdlib/malloc.c b/reactos/lib/crtdll/stdlib/malloc.c index 9fdcfaba550..bfc854715bb 100644 --- a/reactos/lib/crtdll/stdlib/malloc.c +++ b/reactos/lib/crtdll/stdlib/malloc.c @@ -1,23 +1,33 @@ #include #include -//#include +//#include +#include 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)); } diff --git a/reactos/lib/crtdll/stdlib/putenv.c b/reactos/lib/crtdll/stdlib/putenv.c index f69ac31406d..0dc3b747d26 100644 --- a/reactos/lib/crtdll/stdlib/putenv.c +++ b/reactos/lib/crtdll/stdlib/putenv.c @@ -3,8 +3,9 @@ #include + int -_putenv(const char *val) +putenv(const char *val) { char buffer[1024]; diff --git a/reactos/lib/crtdll/stdlib/qsort.c b/reactos/lib/crtdll/stdlib/qsort.c index 4551a59a16f..456834ffe74 100644 --- a/reactos/lib/crtdll/stdlib/qsort.c +++ b/reactos/lib/crtdll/stdlib/qsort.c @@ -173,7 +173,7 @@ qst(char *base, char *max) */ void -qsort(const void *base0, size_t n, size_t size, _pfunccmp_t compar) +qsort(void *base0, size_t n, size_t size, int (*compar)(const void *, const void *)) { char *base = (char *)base0; char c, *i, *j, *lo, *hi; diff --git a/reactos/lib/crtdll/stdlib/senv.c b/reactos/lib/crtdll/stdlib/senv.c index 030abb39ad4..9bc467f7523 100644 --- a/reactos/lib/crtdll/stdlib/senv.c +++ b/reactos/lib/crtdll/stdlib/senv.c @@ -25,4 +25,4 @@ void _searchenv(const char *file,const char *var,char *path ) } return; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/stdlib/strtod.c b/reactos/lib/crtdll/stdlib/strtod.c index 8fec8235046..832cb2efc12 100644 --- a/reactos/lib/crtdll/stdlib/strtod.c +++ b/reactos/lib/crtdll/stdlib/strtod.c @@ -2,7 +2,7 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include #include -#include + double strtod(const char *s, char **sret) @@ -95,97 +95,3 @@ strtod(const char *s, char **sret) *sret = (char *)s; return r * sign; } - - -double -wcstod(const wchar_t *s, wchar_t **sret) -{ - long double r; /* result */ - int e; /* exponent */ - long double d; /* scale */ - int sign; /* +- 1.0 */ - int esign; - int i; - int flags=0; - - r = 0.0; - sign = 1; - e = 0; - esign = 1; - - while ((*s == ' ') || (*s == '\t')) - s++; - - if (*s == '+') - s++; - else if (*s == '-') - { - sign = -1; - s++; - } - - while ((*s >= '0') && (*s <= '9')) - { - flags |= 1; - r *= 10.0; - r += *s - '0'; - s++; - } - - if (*s == '.') - { - d = 0.1L; - s++; - while ((*s >= '0') && (*s <= '9')) - { - flags |= 2; - r += d * (*s - '0'); - s++; - d *= 0.1L; - } - } - - if (flags == 0) - { - if (sret) - *sret = (wchar_t *)s; - return 0; - } - - if ((*s == 'e') || (*s == 'E')) - { - s++; - if (*s == '+') - s++; - else if (*s == '-') - { - s++; - esign = -1; - } - if ((*s < '0') || (*s > '9')) - { - if (sret) - *sret = (wchar_t *)s; - return r; - } - - while ((*s >= '0') && (*s <= '9')) - { - e *= 10; - e += *s - '0'; - s++; - } - } - - if (esign < 0) - for (i = 1; i <= e; i++) - r *= 0.1L; - else - for (i = 1; i <= e; i++) - r *= 10.0; - - if (sret) - *sret = (wchar_t *)s; - return r * sign; -} - diff --git a/reactos/lib/crtdll/stdlib/strtol.c b/reactos/lib/crtdll/stdlib/strtol.c index 14861a3dd7a..362f9bcce2e 100644 --- a/reactos/lib/crtdll/stdlib/strtol.c +++ b/reactos/lib/crtdll/stdlib/strtol.c @@ -3,7 +3,6 @@ #include #include #include -#include long @@ -82,7 +81,7 @@ strtol(const char *nptr, char **endptr, int base) if (any < 0) { acc = neg ? LONG_MIN : LONG_MAX; -// errno = ERANGE; + errno = ERANGE; } else if (neg) acc = -acc; @@ -90,90 +89,3 @@ strtol(const char *nptr, char **endptr, int base) *endptr = any ? (char *)s - 1 : (char *)nptr; return acc; } - - -long -wcstol(const wchar_t *nptr, wchar_t **endptr, int base) -{ - const wchar_t *s = nptr; - unsigned long acc; - int c; - unsigned long cutoff; - int neg = 0, any, cutlim; - - /* - * Skip white space and pick up leading +/- sign if any. - * If base is 0, allow 0x for hex and 0 for octal, else - * assume decimal; if base is already 16, allow 0x. - */ - do { - c = *s++; - } while (isspace(c)); - if (c == '-') - { - neg = 1; - c = *s++; - } - else if (c == '+') - c = *s++; - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) - { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == '0' ? 8 : 10; - - /* - * Compute the cutoff value between legal numbers and illegal - * numbers. That is the largest legal value, divided by the - * base. An input number that is greater than this value, if - * followed by a legal input character, is too big. One that - * is equal to this value may be valid or not; the limit - * between valid and invalid numbers is then based on the last - * digit. For instance, if the range for longs is - * [-2147483648..2147483647] and the input base is 10, - * cutoff will be set to 214748364 and cutlim to either - * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated - * a value > 214748364, or equal but the next digit is > 7 (or 8), - * the number is too big, and we will return a range error. - * - * Set any if any `digits' consumed; make it negative to indicate - * overflow. - */ - cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; - cutlim = cutoff % (unsigned long)base; - cutoff /= (unsigned long)base; - for (acc = 0, any = 0;; c = *s++) - { - if (isdigit(c)) - c -= '0'; - else if (isalpha(c)) - c -= isupper(c) ? 'A' - 10 : 'a' - 10; - else - break; - if (c >= base) - break; - if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) - any = -1; - else - { - any = 1; - acc *= base; - acc += c; - } - } - if (any < 0) - { - acc = neg ? LONG_MIN : LONG_MAX; - // errno = ERANGE; - } - else if (neg) - acc = -acc; - if (endptr != 0) - *endptr = any ? (wchar_t *)s - 1 : (wchar_t *)nptr; - return acc; -} - diff --git a/reactos/lib/crtdll/stdlib/strtoul.c b/reactos/lib/crtdll/stdlib/strtoul.c index dfe6f8542d1..d62bd5366b0 100644 --- a/reactos/lib/crtdll/stdlib/strtoul.c +++ b/reactos/lib/crtdll/stdlib/strtoul.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include /* * Convert a string to an unsigned long integer. @@ -65,75 +65,11 @@ strtoul(const char *nptr, char **endptr, int base) if (any < 0) { acc = ULONG_MAX; - // errno = ERANGE; + errno = ERANGE; } else if (neg) acc = -acc; if (endptr != 0) - *endptr = any ? (char *)s - 1 : (char *)nptr; + *endptr = any ? unconst(s, char *) - 1 : unconst(nptr, char *); return acc; } - -unsigned long -wcstoul(const wchar_t *nptr, wchar_t **endptr, int base) -{ - const wchar_t *s = nptr; - unsigned long acc; - int c; - unsigned long cutoff; - int neg = 0, any, cutlim; - - /* - * See strtol for comments as to the logic used. - */ - do { - c = *s++; - } while (isspace(c)); - if (c == '-') - { - neg = 1; - c = *s++; - } - else if (c == '+') - c = *s++; - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) - { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == '0' ? 8 : 10; - cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; - cutlim = (unsigned long)ULONG_MAX % (unsigned long)base; - for (acc = 0, any = 0;; c = *s++) - { - if (isdigit(c)) - c -= '0'; - else if (isalpha(c)) - c -= isupper(c) ? 'A' - 10 : 'a' - 10; - else - break; - if (c >= base) - break; - if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) - any = -1; - else { - any = 1; - acc *= base; - acc += c; - } - } - if (any < 0) - { - acc = ULONG_MAX; - // errno = ERANGE; - } - else if (neg) - acc = -acc; - if (endptr != 0) - *endptr = any ? (wchar_t *)s - 1 : (wchar_t *)nptr; - return acc; -} - diff --git a/reactos/lib/crtdll/string/memmove.c b/reactos/lib/crtdll/string/memmove.c index f2c2da18427..6d8940adf7e 100644 --- a/reactos/lib/crtdll/string/memmove.c +++ b/reactos/lib/crtdll/string/memmove.c @@ -17,4 +17,4 @@ void * memmove(void *dest,const void *src,size_t count) return dest; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/string/memset.c b/reactos/lib/crtdll/string/memset.c index a17ed3f04f3..24ec583dfc9 100644 --- a/reactos/lib/crtdll/string/memset.c +++ b/reactos/lib/crtdll/string/memset.c @@ -10,4 +10,4 @@ void * memset(void *src,int val,size_t count) count--; } return src; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/string/strerror.c b/reactos/lib/crtdll/string/strerror.c index 0e7fbba7e35..bd28973826a 100644 --- a/reactos/lib/crtdll/string/strerror.c +++ b/reactos/lib/crtdll/string/strerror.c @@ -3,6 +3,7 @@ #include #include #include +//#include char __syserr00[] = "No Error"; diff --git a/reactos/lib/crtdll/string/strlwr.c b/reactos/lib/crtdll/string/strlwr.c index 2bacd51c0fe..cb0d28f506f 100644 --- a/reactos/lib/crtdll/string/strlwr.c +++ b/reactos/lib/crtdll/string/strlwr.c @@ -20,4 +20,4 @@ char * strlwr(char *x) y++; } return x; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/string/strtoul.c b/reactos/lib/crtdll/string/strtoul.c index 21285770251..320c653f300 100644 --- a/reactos/lib/crtdll/string/strtoul.c +++ b/reactos/lib/crtdll/string/strtoul.c @@ -24,4 +24,4 @@ unsigned long strtoul(const char *cp,char **endp,unsigned int base) if (endp) *endp = (char *)cp; return result; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/sys_stat/fstat.c b/reactos/lib/crtdll/sys_stat/fstat.c index d8deb06828c..dc7b05455bb 100644 --- a/reactos/lib/crtdll/sys_stat/fstat.c +++ b/reactos/lib/crtdll/sys_stat/fstat.c @@ -20,7 +20,7 @@ fstat(int handle, struct stat *statbuf) return -1; } - if ( !GetFileInformationByHandle(_get_osfhandle(handle),&FileInformation) ) + if ( !GetFileInformationByHandle(filehnd(handle),&FileInformation) ) return -1; statbuf->st_ctime = FileTimeToUnixTime( &FileInformation.ftCreationTime,NULL); statbuf->st_atime = FileTimeToUnixTime( &FileInformation.ftLastAccessTime,NULL); diff --git a/reactos/lib/crtdll/sys_stat/stat.c b/reactos/lib/crtdll/sys_stat/stat.c index 5de9b4f1876..f10455f5a35 100644 --- a/reactos/lib/crtdll/sys_stat/stat.c +++ b/reactos/lib/crtdll/sys_stat/stat.c @@ -19,4 +19,4 @@ int _stat( const char *path, struct stat *buffer ) return ret; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/time/ctime.c b/reactos/lib/crtdll/time/ctime.c index 4bf696cd746..b16b38fe783 100644 --- a/reactos/lib/crtdll/time/ctime.c +++ b/reactos/lib/crtdll/time/ctime.c @@ -37,7 +37,22 @@ static char sccsid[] = "@(#)ctime.c 5.23 (Berkeley) 6/22/90"; */ - +#ifndef _TM_DEFINED +struct tm { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; + char *tm_zone; + int tm_gmtoff; +}; +#define _TM_DEFINED +#endif //#include #include diff --git a/reactos/lib/crtdll/time/strftime.c b/reactos/lib/crtdll/time/strftime.c index ee5678b6928..32c6973950a 100644 --- a/reactos/lib/crtdll/time/strftime.c +++ b/reactos/lib/crtdll/time/strftime.c @@ -1,5 +1,22 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include +#ifndef _TM_DEFINED +struct tm { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; + char *tm_zone; + int tm_gmtoff; +}; +#define _TM_DEFINED +#endif + #include #define TM_YEAR_BASE 1900 diff --git a/reactos/lib/crtdll/time/time.c b/reactos/lib/crtdll/time/time.c index af500dc54a1..4ff00485a74 100644 --- a/reactos/lib/crtdll/time/time.c +++ b/reactos/lib/crtdll/time/time.c @@ -1,5 +1,20 @@ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - +#ifndef _TM_DEFINED +struct tm { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; + char *tm_zone; + int tm_gmtoff; +}; +#define _TM_DEFINED +#endif #include #include @@ -10,5 +25,6 @@ time(time_t *t) { SYSTEMTIME SystemTime; GetLocalTime(&SystemTime); - + + } diff --git a/reactos/lib/crtdll/wchar/wcscmp.c b/reactos/lib/crtdll/wchar/wcscmp.c index 2fc95c9d3a3..997bfb88f50 100644 --- a/reactos/lib/crtdll/wchar/wcscmp.c +++ b/reactos/lib/crtdll/wchar/wcscmp.c @@ -13,4 +13,4 @@ int wcscmp(const wchar_t* cs,const wchar_t * ct) } return *cs - *ct; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/wchar/wcscoll.c b/reactos/lib/crtdll/wchar/wcscoll.c index a41fd451790..712733e74e8 100644 --- a/reactos/lib/crtdll/wchar/wcscoll.c +++ b/reactos/lib/crtdll/wchar/wcscoll.c @@ -14,4 +14,4 @@ size_t wcscoll(wchar_t *a1,wchar_t *a2) { /* FIXME: handle collates */ return wcscmp(a1,a2); -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/wchar/wcscpy.c b/reactos/lib/crtdll/wchar/wcscpy.c index d17d96b700f..4e122f52e8a 100644 --- a/reactos/lib/crtdll/wchar/wcscpy.c +++ b/reactos/lib/crtdll/wchar/wcscpy.c @@ -8,4 +8,4 @@ wchar_t * wcscpy(wchar_t * str1,const wchar_t * str2) for (; (*str1 = *str2); ++str2, ++str1); return save; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/wchar/wcscspn.c b/reactos/lib/crtdll/wchar/wcscspn.c index d1f2ff19b32..64d84751aa7 100644 --- a/reactos/lib/crtdll/wchar/wcscspn.c +++ b/reactos/lib/crtdll/wchar/wcscspn.c @@ -17,4 +17,4 @@ size_t wcscspn(const wchar_t *str,const wchar_t *reject) s++; } while (*s); return s-str; /* nr of wchars */ -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/wchar/wcsicmp.c b/reactos/lib/crtdll/wchar/wcsicmp.c index db14731e26c..658e2d1aec1 100644 --- a/reactos/lib/crtdll/wchar/wcsicmp.c +++ b/reactos/lib/crtdll/wchar/wcsicmp.c @@ -13,4 +13,4 @@ int wcsicmp(const wchar_t* cs,const wchar_t * ct) } return towlower(*cs) - towlower(*ct); -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/wchar/wcslwr.c b/reactos/lib/crtdll/wchar/wcslwr.c index a7b3b7e3c6b..a4dc2eead66 100644 --- a/reactos/lib/crtdll/wchar/wcslwr.c +++ b/reactos/lib/crtdll/wchar/wcslwr.c @@ -19,4 +19,4 @@ wchar_t * wcslwr(wchar_t *x) y++; } return x; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/wchar/wcsrchr.c b/reactos/lib/crtdll/wchar/wcsrchr.c index 52a091128a5..29067768a81 100644 --- a/reactos/lib/crtdll/wchar/wcsrchr.c +++ b/reactos/lib/crtdll/wchar/wcsrchr.c @@ -11,4 +11,4 @@ wchar_t* wcsrchr(const wchar_t* str, wchar_t ch) if (ch == 0) sp = (wchar_t *)str; return sp; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/wchar/wcsrev.c b/reactos/lib/crtdll/wchar/wcsrev.c index 78e42771513..feaa2704a55 100644 --- a/reactos/lib/crtdll/wchar/wcsrev.c +++ b/reactos/lib/crtdll/wchar/wcsrev.c @@ -13,4 +13,4 @@ wchar_t * wcsrev(wchar_t *s) e--; } return s; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/wchar/wcsspn.c b/reactos/lib/crtdll/wchar/wcsspn.c index 61e11d801fd..a125b034ea9 100644 --- a/reactos/lib/crtdll/wchar/wcsspn.c +++ b/reactos/lib/crtdll/wchar/wcsspn.c @@ -15,4 +15,4 @@ size_t wcsspn(const wchar_t *str,const wchar_t *accept) s++; } while (*s); return s-str; /* nr of wchars */ -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/wchar/wcsstr.c b/reactos/lib/crtdll/wchar/wcsstr.c index faf47cf2520..6bab79315ab 100644 --- a/reactos/lib/crtdll/wchar/wcsstr.c +++ b/reactos/lib/crtdll/wchar/wcsstr.c @@ -18,4 +18,4 @@ wchar_t *wcsstr(const wchar_t *s,const wchar_t *b) x++; } return NULL; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/wchar/wcstok.c b/reactos/lib/crtdll/wchar/wcstok.c index 490f1834161..ed49ad48ab3 100644 --- a/reactos/lib/crtdll/wchar/wcstok.c +++ b/reactos/lib/crtdll/wchar/wcstok.c @@ -49,4 +49,4 @@ wchar_t *wcstok(wchar_t *s, const wchar_t *ct) } /* NOTREACHED */ -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/wchar/wcstombs.c b/reactos/lib/crtdll/wchar/wcstombs.c index eba0bbd1450..a04f53e487f 100644 --- a/reactos/lib/crtdll/wchar/wcstombs.c +++ b/reactos/lib/crtdll/wchar/wcstombs.c @@ -3,4 +3,4 @@ size_t __cdecl wcstombs( char *dst, const wchar_t *src, size_t len ) { lstrcpynWtoA( dst, src, len ); return strlen(dst); /* FIXME: is this right? */ -} \ No newline at end of file +} diff --git a/reactos/lib/kernel32/file/copy.c b/reactos/lib/kernel32/file/copy.c new file mode 100644 index 00000000000..ebe5d465ad9 --- /dev/null +++ b/reactos/lib/kernel32/file/copy.c @@ -0,0 +1,237 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * FILE: lib/kernel32/file/copy.c + * PURPOSE: Copying files + * PROGRAMMER: Ariadne ( ariadne@xs4all.nl) + * UPDATE HISTORY: + * 01/11/98 Created + * 07/02/99 Moved to seperate file + */ + +/* INCLUDES ****************************************************************/ + +#include +#include +#include +#include + +#define NDEBUG +#include + +#define LPPROGRESS_ROUTINE void* + +/* FUNCTIONS ****************************************************************/ + +WINBOOL STDCALL CopyFileExW(LPCWSTR lpExistingFileName, + LPCWSTR lpNewFileName, + LPPROGRESS_ROUTINE lpProgressRoutine, + LPVOID lpData, + WINBOOL * pbCancel, + DWORD dwCopyFlags) +{ + NTSTATUS errCode = 0; + HANDLE FileHandleSource, FileHandleDest; + IO_STATUS_BLOCK IoStatusBlock; + FILE_STANDARD_INFORMATION FileStandard; + FILE_BASIC_INFORMATION FileBasic; + FILE_POSITION_INFORMATION FilePosition; + UCHAR *lpBuffer = NULL; + ULONG RegionSize = 0x1000000; + BOOL bCancel = FALSE; + + FileHandleSource = CreateFileW(lpExistingFileName, + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL|FILE_FLAG_NO_BUFFERING, + NULL); + if (FileHandleSource == NULL) + { + return(FALSE); + } + + errCode = NtQueryInformationFile(FileHandleSource, + &IoStatusBlock, + &FileStandard, + sizeof(FILE_STANDARD_INFORMATION), + FileStandardInformation); + if (!NT_SUCCESS(errCode)) + { + NtClose(FileHandleSource); + SetLastError(RtlNtStatusToDosError(errCode)); + return FALSE; + } + + errCode = NtQueryInformationFile(FileHandleSource, + &IoStatusBlock,&FileBasic, + sizeof(FILE_BASIC_INFORMATION), + FileBasicInformation); + if (!NT_SUCCESS(errCode)) + { + NtClose(FileHandleSource); + SetLastError(RtlNtStatusToDosError(errCode)); + return FALSE; + } + + FileHandleDest = CreateFileW(lpNewFileName, + GENERIC_WRITE, + FILE_SHARE_WRITE, + NULL, + dwCopyFlags ? CREATE_NEW : CREATE_ALWAYS , + FileBasic.FileAttributes|FILE_FLAG_NO_BUFFERING, + NULL); + if (FileHandleDest == NULL) + { + return(FALSE); + } + + SET_LARGE_INTEGER_LOW_PART(FilePosition.CurrentByteOffset, 0); + SET_LARGE_INTEGER_HIGH_PART(FilePosition.CurrentByteOffset, 0); + + errCode = NtSetInformationFile(FileHandleSource, + &IoStatusBlock, + &FilePosition, + sizeof(FILE_POSITION_INFORMATION), + FilePositionInformation); + if (!NT_SUCCESS(errCode)) + { + NtClose(FileHandleSource); + NtClose(FileHandleDest); + SetLastError(RtlNtStatusToDosError(errCode)); + return FALSE; + } + + errCode = NtSetInformationFile(FileHandleDest, + &IoStatusBlock, + &FilePosition, + sizeof(FILE_POSITION_INFORMATION), + FilePositionInformation); + if (!NT_SUCCESS(errCode)) + { + NtClose(FileHandleSource); + NtClose(FileHandleDest); + SetLastError(RtlNtStatusToDosError(errCode)); + return FALSE; + } + + errCode = NtAllocateVirtualMemory(NtCurrentProcess(), + (PVOID *)&lpBuffer, + 2, + &RegionSize, + MEM_COMMIT, + PAGE_READWRITE); + + if (!NT_SUCCESS(errCode)) + { + NtClose(FileHandleSource); + NtClose(FileHandleDest); + SetLastError(RtlNtStatusToDosError(errCode)); + return FALSE; + } + + do { + errCode = NtReadFile(FileHandleSource, + NULL, + NULL, + NULL, + (PIO_STATUS_BLOCK)&IoStatusBlock, + lpBuffer, + RegionSize, + NULL, + NULL); + if (pbCancel != NULL) + bCancel = *pbCancel; + + if (!NT_SUCCESS(errCode) || bCancel) + { + NtFreeVirtualMemory(NtCurrentProcess(), + (PVOID *)&lpBuffer, &RegionSize,MEM_RELEASE); + NtClose(FileHandleSource); + NtClose(FileHandleDest); + if ( errCode == STATUS_END_OF_FILE ) + break; + else + return FALSE; + } + + errCode = NtWriteFile(FileHandleDest, + NULL, + lpProgressRoutine, + lpData, + (PIO_STATUS_BLOCK)&IoStatusBlock, + lpBuffer, + RegionSize, + NULL, + NULL); + + if (!NT_SUCCESS(errCode)) + { + NtFreeVirtualMemory(NtCurrentProcess(), + (PVOID *)&lpBuffer, + &RegionSize, + MEM_RELEASE); + NtClose(FileHandleSource); + NtClose(FileHandleDest); + return FALSE; + } + + } while ( TRUE ); + return TRUE; +} + +WINBOOL STDCALL CopyFileExA(LPCSTR lpExistingFileName, + LPCSTR lpNewFileName, + LPPROGRESS_ROUTINE lpProgressRoutine, + LPVOID lpData, + WINBOOL* pbCancel, + DWORD dwCopyFlags) +{ + ULONG i; + WCHAR ExistingFileNameW[MAX_PATH]; + WCHAR NewFileNameW[MAX_PATH]; + + if (!KERNEL32_AnsiToUnicode(ExistingFileNameW, + lpExistingFileName, + MAX_PATH)) + { + return(FALSE); + } + if (!KERNEL32_AnsiToUnicode(NewFileNameW, + lpNewFileName, + MAX_PATH)) + { + return(FALSE); + } + return(CopyFileExW(ExistingFileNameW, + NewFileNameW, + lpProgressRoutine, + lpData, + pbCancel, + dwCopyFlags)); +} + + +WINBOOL STDCALL CopyFileA(LPCSTR lpExistingFileName, + LPCSTR lpNewFileName, + WINBOOL bFailIfExists) +{ + return CopyFileExA(lpExistingFileName, + lpNewFileName, + NULL, + NULL, + FALSE, + bFailIfExists); +} +WINBOOL STDCALL CopyFileW(LPCWSTR lpExistingFileName, + LPCWSTR lpNewFileName, + WINBOOL bFailIfExists) +{ + return CopyFileExW(lpExistingFileName, + lpNewFileName, + NULL, + NULL, + NULL, + bFailIfExists); +} diff --git a/reactos/lib/kernel32/file/create.c b/reactos/lib/kernel32/file/create.c index 892a6bd3951..8daddd9731b 100644 --- a/reactos/lib/kernel32/file/create.c +++ b/reactos/lib/kernel32/file/create.c @@ -14,14 +14,16 @@ #include #include -#include +#include #include -#include -#include //#define NDEBUG #include +/* EXTERNS ******************************************************************/ + +DWORD STDCALL GetCurrentDriveW(DWORD nBufferLength, PWSTR lpBuffer); + /* FUNCTIONS ****************************************************************/ HANDLE STDCALL CreateFileA(LPCSTR lpFileName, @@ -103,11 +105,24 @@ HANDLE STDCALL CreateFileW(LPCWSTR lpFileName, Flags |= FILE_SYNCHRONOUS_IO_ALERT; } - if ( lpFileName[0] == L'\\' || lpFileName[1] == L':') + if (lpFileName[1] == (WCHAR)':') { - wcscpy(PathNameW,lpFileName); + wcscpy(PathNameW, lpFileName); } - else + else if (wcslen(lpFileName) > 4 && + lpFileName[0] == (WCHAR)'\\' && + lpFileName[1] == (WCHAR)'\\' && + lpFileName[2] == (WCHAR)'.' && + lpFileName[3] == (WCHAR)'\\') + { + wcscpy(PathNameW, lpFileName); + } + else if (lpFileName[0] == (WCHAR)'\\') + { + GetCurrentDriveW(MAX_PATH,PathNameW); + wcscat(PathNameW, lpFileName); + } + else { Len = GetCurrentDirectoryW(MAX_PATH,PathNameW); if ( Len == 0 ) diff --git a/reactos/lib/kernel32/file/curdir.c b/reactos/lib/kernel32/file/curdir.c index 478fd401cbe..296445d1eae 100644 --- a/reactos/lib/kernel32/file/curdir.c +++ b/reactos/lib/kernel32/file/curdir.c @@ -30,7 +30,16 @@ static WCHAR WindowsDirectoryW[MAX_PATH]; WINBOOL STDCALL SetCurrentDirectoryW(LPCWSTR lpPathName); /* FUNCTIONS *****************************************************************/ - + +DWORD STDCALL GetCurrentDriveW(DWORD nBufferLength, PWSTR lpBuffer) +{ + lpBuffer[0] = 'A' + CurrentDrive; + lpBuffer[1] = ':'; + lpBuffer[2] = '\\'; + lpBuffer[3] = 0; + return(4); +} + DWORD STDCALL GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer) { UINT uSize,i; @@ -67,9 +76,10 @@ DWORD STDCALL GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer) { lpBuffer[0] = 'A' + CurrentDrive; lpBuffer[1] = ':'; + lpBuffer[2] = 0; lstrcpyW(&lpBuffer[2], DriveDirectoryW[CurrentDrive]); } - DPRINT("GetCurrentDirectoryW() = %w\n",lpBuffer); + DPRINT("GetCurrentDirectoryW() = '%w'\n",lpBuffer); return uSize; } @@ -100,7 +110,7 @@ WINBOOL STDCALL SetCurrentDirectoryW(LPCWSTR lpPathName) HANDLE hDir; PWSTR prev, current; - DPRINT("SetCurrentDirectoryW(lpPathName %w\n",lpPathName); + DPRINT("SetCurrentDirectoryW(lpPathName %w)\n",lpPathName); if (lpPathName == NULL) return FALSE; @@ -127,7 +137,10 @@ WINBOOL STDCALL SetCurrentDirectoryW(LPCWSTR lpPathName) } hCurrentDirectory = hDir; - if (isalpha(lpPathName[0]) && lpPathName[1] == ':' ) + DPRINT("lpPathName %w %x\n",lpPathName,lpPathName); + if (wcslen(lpPathName) > 2 && + isalpha(lpPathName[0]) && + lpPathName[1] == ':' ) { DPRINT("lpPathName %w\n",lpPathName); diff --git a/reactos/lib/kernel32/file/dir.c b/reactos/lib/kernel32/file/dir.c index 49f3f2053a0..5cce4f78286 100644 --- a/reactos/lib/kernel32/file/dir.c +++ b/reactos/lib/kernel32/file/dir.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include #define NDEBUG #include @@ -35,12 +35,9 @@ WINBOOL STDCALL CreateDirectoryExA(LPCSTR lpTemplateDirectory, LPSECURITY_ATTRIBUTES lpSecurityAttributes) { WCHAR TemplateDirectoryW[MAX_PATH]; - PWCHAR pTemplateDirectoryW; WCHAR NewDirectoryW[MAX_PATH]; ULONG i; i = 0; - if(lpTemplateDirectory) - { while ((*lpTemplateDirectory)!=0 && i < MAX_PATH) { TemplateDirectoryW[i] = *lpTemplateDirectory; @@ -48,12 +45,9 @@ WINBOOL STDCALL CreateDirectoryExA(LPCSTR lpTemplateDirectory, i++; } TemplateDirectoryW[i] = 0; - pTemplateDirectoryW=TemplateDirectoryW; - } - else pTemplateDirectoryW=NULL; i = 0; - while ((*lpNewDirectory)!=0 && i < MAX_PATH-1) + while ((*lpNewDirectory)!=0 && i < MAX_PATH) { NewDirectoryW[i] = *lpNewDirectory; lpNewDirectory++; @@ -82,7 +76,6 @@ WINBOOL STDCALL CreateDirectoryExW(LPCWSTR lpTemplateDirectory, OBJECT_ATTRIBUTES ObjectAttributes; UNICODE_STRING DirectoryNameString; IO_STATUS_BLOCK IoStatusBlock; - WCHAR FileNameW[MAX_PATH]; if ( lpTemplateDirectory != NULL ) { @@ -91,14 +84,8 @@ WINBOOL STDCALL CreateDirectoryExW(LPCWSTR lpTemplateDirectory, return(FALSE); } - FileNameW[0] = '\\'; - FileNameW[1] = '?'; - FileNameW[2] = '?'; - FileNameW[3] = '\\'; - FileNameW[4] = 0; - wcscat(FileNameW,lpNewDirectory); - DirectoryNameString.Length = lstrlenW(FileNameW)*sizeof(WCHAR); - DirectoryNameString.Buffer = (WCHAR *)FileNameW; + DirectoryNameString.Length = lstrlenW(lpNewDirectory)*sizeof(WCHAR); + DirectoryNameString.Buffer = (WCHAR *)lpNewDirectory; DirectoryNameString.MaximumLength = DirectoryNameString.Length+sizeof(WCHAR); ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); @@ -113,10 +100,10 @@ WINBOOL STDCALL CreateDirectoryExW(LPCWSTR lpTemplateDirectory, &ObjectAttributes, &IoStatusBlock, NULL, - FILE_ATTRIBUTE_NORMAL, + FILE_ATTRIBUTE_DIRECTORY, 0, FILE_CREATE, - FILE_DIRECTORY_FILE, + 0, NULL, 0); diff --git a/reactos/lib/kernel32/file/file.c b/reactos/lib/kernel32/file/file.c index 358a00cdf03..b26d7ecba12 100644 --- a/reactos/lib/kernel32/file/file.c +++ b/reactos/lib/kernel32/file/file.c @@ -11,78 +11,39 @@ /* FIXME: the large integer manipulations in this file dont handle overflow */ -#undef WIN32_LEAN_AND_MEAN +/* INCLUDES ****************************************************************/ + #include #include -#include +#include #include -#include -#include #define NDEBUG #include #define LPPROGRESS_ROUTINE void* +/* GLOBALS ******************************************************************/ +static BOOLEAN bIsFileApiAnsi; // set the file api to ansi or oem +/* FUNCTIONS ****************************************************************/ -WINBOOL -CopyFileExW( - LPCWSTR lpExistingFileName, - LPCWSTR lpNewFileName, - LPPROGRESS_ROUTINE lpProgressRoutine, - LPVOID lpData, - WINBOOL * pbCancel, - DWORD dwCopyFlags - ); - -WINBOOL -CopyFileExA( - LPCSTR lpExistingFileName, - LPCSTR lpNewFileName, - LPPROGRESS_ROUTINE lpProgressRoutine, - LPVOID lpData, - WINBOOL * pbCancel, - DWORD dwCopyFlags - ); - - - -BOOLEAN bIsFileApiAnsi; // set the file api to ansi or oem - - - -VOID -STDCALL -SetFileApisToOEM(VOID) +VOID STDCALL SetFileApisToOEM(VOID) { - bIsFileApiAnsi = FALSE; - return; + bIsFileApiAnsi = FALSE; } -WINBASEAPI -VOID -WINAPI -SetFileApisToANSI(VOID) +WINBASEAPI VOID WINAPI SetFileApisToANSI(VOID) { - bIsFileApiAnsi = TRUE; - return; + bIsFileApiAnsi = TRUE; } - - -WINBOOL -STDCALL -AreFileApisANSI(VOID) +WINBOOL STDCALL AreFileApisANSI(VOID) { - return bIsFileApiAnsi; - + return(bIsFileApiAnsi); } - - - WINBOOL STDCALL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, @@ -90,7 +51,7 @@ WINBOOL STDCALL WriteFile(HANDLE hFile, LPOVERLAPPED lpOverLapped) { - LARGE_INTEGER Offset,*pOffset; + LARGE_INTEGER Offset; HANDLE hEvent = NULL; NTSTATUS errCode; PIO_STATUS_BLOCK IoStatusBlock; @@ -105,12 +66,11 @@ WINBOOL STDCALL WriteFile(HANDLE hFile, lpOverLapped->Internal = STATUS_PENDING; hEvent= lpOverLapped->hEvent; IoStatusBlock = (PIO_STATUS_BLOCK)lpOverLapped; - pOffset=&Offset; } else { IoStatusBlock = &IIosb; - pOffset = NULL; + Offset = NULL; } errCode = NtWriteFile(hFile, hEvent, @@ -119,7 +79,7 @@ WINBOOL STDCALL WriteFile(HANDLE hFile, IoStatusBlock, (PVOID)lpBuffer, nNumberOfBytesToWrite, - pOffset, + &Offset, NULL); if (!NT_SUCCESS(errCode)) { @@ -133,108 +93,85 @@ WINBOOL STDCALL WriteFile(HANDLE hFile, return(TRUE); } +WINBOOL STDCALL KERNEL32_ReadFile(HANDLE hFile, + LPVOID lpBuffer, + DWORD nNumberOfBytesToRead, + LPDWORD lpNumberOfBytesRead, + LPOVERLAPPED lpOverLapped, + LPOVERLAPPED_COMPLETION_ROUTINE + lpCompletionRoutine) +{ + HANDLE hEvent = NULL; + LARGE_INTEGER Offset; + NTSTATUS errCode; + IO_STATUS_BLOCK IIosb; + PIO_STATUS_BLOCK IoStatusBlock; + PLARGE_INTEGER ptrOffset; + + if (lpOverLapped != NULL) + { + SET_LARGE_INTEGER_LOW_PART(Offset, lpOverLapped->Offset); + SET_LARGE_INTEGER_HIGH_PART(Offset, lpOverLapped->OffsetHigh); + lpOverLapped->Internal = STATUS_PENDING; + hEvent = lpOverLapped->hEvent; + IoStatusBlock = (PIO_STATUS_BLOCK)lpOverLapped; + ptrOffset = &Offset; + } + else + { + ptrOffset = NULL; + IoStatusBlock = &IIosb; + } + + errCode = NtReadFile(hFile, + hEvent, + (PIO_APC_ROUTINE)lpCompletionRoutine, + NULL, + IoStatusBlock, + lpBuffer, + nNumberOfBytesToRead, + ptrOffset, + NULL); + + if (errCode != STATUS_PENDING && lpNumberOfBytesRead != NULL) + { + *lpNumberOfBytesRead = IoStatusBlock->Information; + } + + if (!NT_SUCCESS(errCode)) + { + SetLastError(RtlNtStatusToDosError(errCode)); + return(FALSE); + } + return(TRUE); +} + WINBOOL STDCALL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverLapped) { - - HANDLE hEvent = NULL; - PLARGE_INTEGER Offset; - LARGE_INTEGER ByteOffset; - NTSTATUS errCode; - PIO_STATUS_BLOCK IoStatusBlock; - IO_STATUS_BLOCK IIosb; - - if (lpOverLapped != NULL) - { - SET_LARGE_INTEGER_LOW_PART(ByteOffset, lpOverLapped->Offset); - SET_LARGE_INTEGER_HIGH_PART(ByteOffset, lpOverLapped->OffsetHigh); - Offset = &ByteOffset; - lpOverLapped->Internal = STATUS_PENDING; - hEvent = lpOverLapped->hEvent; - IoStatusBlock = (PIO_STATUS_BLOCK)lpOverLapped; - } - else - { - IoStatusBlock = &IIosb; - Offset = NULL; - } - - errCode = NtReadFile(hFile, - hEvent, - NULL, - NULL, - IoStatusBlock, - lpBuffer, - nNumberOfBytesToRead, - Offset, - NULL); - - if ( !NT_SUCCESS(errCode) ) - { - SetLastError(RtlNtStatusToDosError(errCode)); - return FALSE; - } - - if (lpNumberOfBytesRead != NULL ) - { - *lpNumberOfBytesRead = IoStatusBlock->Information; - } - - return TRUE; + return(KERNEL32_ReadFile(hFile, + lpBuffer, + nNumberOfBytesToRead, + lpNumberOfBytesRead, + lpOverLapped, + NULL)); } -WINBOOL -STDCALL -ReadFileEx( - HANDLE hFile, - LPVOID lpBuffer, - DWORD nNumberOfBytesToRead, - LPOVERLAPPED lpOverLapped, - LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine - ) +WINBOOL STDCALL ReadFileEx(HANDLE hFile, + LPVOID lpBuffer, + DWORD nNumberOfBytesToRead, + LPOVERLAPPED lpOverLapped, + LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) { - HANDLE hEvent = NULL; - LARGE_INTEGER Offset; - NTSTATUS errCode; - IO_STATUS_BLOCK IIosb; - PIO_STATUS_BLOCK IoStatusBlock; - - - if ( lpOverLapped != NULL ) { - SET_LARGE_INTEGER_LOW_PART(Offset, lpOverLapped->Offset); - SET_LARGE_INTEGER_HIGH_PART(Offset, lpOverLapped->OffsetHigh); - lpOverLapped->Internal = STATUS_PENDING; - hEvent = lpOverLapped->hEvent; - IoStatusBlock = (PIO_STATUS_BLOCK)lpOverLapped; - } - else { - SET_LARGE_INTEGER_LOW_PART(Offset, 0); - SET_LARGE_INTEGER_HIGH_PART(Offset, 0); - IoStatusBlock = &IIosb; - } - - - - - errCode = NtReadFile(hFile, - hEvent, - (PIO_APC_ROUTINE)lpCompletionRoutine, - NULL, - IoStatusBlock, - lpBuffer, - nNumberOfBytesToRead, - &Offset, - NULL); - if ( !NT_SUCCESS(errCode) ) { - SetLastError(RtlNtStatusToDosError(errCode)); - return FALSE; - } - - - return TRUE; + return(KERNEL32_ReadFile(hFile, + lpBuffer, + nNumberOfBytesToRead, + NULL, + lpOverLapped, + lpCompletionRoutine)); } @@ -390,263 +327,6 @@ UnlockFileEx( - -WINBOOL -STDCALL -CopyFileA( - LPCSTR lpExistingFileName, - LPCSTR lpNewFileName, - WINBOOL bFailIfExists - ) -{ - return CopyFileExA(lpExistingFileName,lpNewFileName,NULL,NULL,FALSE,bFailIfExists); -} - -WINBOOL -STDCALL -CopyFileExA( - LPCSTR lpExistingFileName, - LPCSTR lpNewFileName, - LPPROGRESS_ROUTINE lpProgressRoutine, - LPVOID lpData, - WINBOOL * pbCancel, - DWORD dwCopyFlags - ) -{ - ULONG i; - WCHAR ExistingFileNameW[MAX_PATH]; - WCHAR NewFileNameW[MAX_PATH]; - - - - i = 0; - while ((*lpExistingFileName)!=0 && i < MAX_PATH) - { - ExistingFileNameW[i] = *lpExistingFileName; - lpExistingFileName++; - i++; - } - ExistingFileNameW[i] = 0; - - i = 0; - while ((*lpNewFileName)!=0 && i < MAX_PATH) - { - NewFileNameW[i] = *lpNewFileName; - lpNewFileName++; - i++; - } - NewFileNameW[i] = 0; - - return CopyFileExW(ExistingFileNameW,NewFileNameW,lpProgressRoutine,lpData,pbCancel,dwCopyFlags); -} - - -WINBOOL -STDCALL -CopyFileW( - LPCWSTR lpExistingFileName, - LPCWSTR lpNewFileName, - WINBOOL bFailIfExists - ) -{ - return CopyFileExW(lpExistingFileName,lpNewFileName,NULL,NULL,NULL,bFailIfExists); -} - - - - - -WINBOOL -STDCALL -CopyFileExW( - LPCWSTR lpExistingFileName, - LPCWSTR lpNewFileName, - LPPROGRESS_ROUTINE lpProgressRoutine, - LPVOID lpData, - WINBOOL * pbCancel, - DWORD dwCopyFlags - ) -{ - - NTSTATUS errCode = 0; - HANDLE FileHandleSource, FileHandleDest; - IO_STATUS_BLOCK IoStatusBlock; - - FILE_STANDARD_INFORMATION FileStandard; - FILE_BASIC_INFORMATION FileBasic; - FILE_POSITION_INFORMATION FilePosition; - - UCHAR *lpBuffer = NULL; - - - - ULONG RegionSize = 0x1000000; - - BOOL bCancel = FALSE; - - - - FileHandleSource = CreateFileW( - lpExistingFileName, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL|FILE_FLAG_NO_BUFFERING, - NULL - ); - - - - if ( !NT_SUCCESS(errCode) ) { - SetLastError(RtlNtStatusToDosError(errCode)); - return FALSE; - } - - - errCode = NtQueryInformationFile(FileHandleSource, - &IoStatusBlock,&FileStandard, sizeof(FILE_STANDARD_INFORMATION), - FileStandardInformation); - if ( !NT_SUCCESS(errCode) ) { - NtClose(FileHandleSource); - SetLastError(RtlNtStatusToDosError(errCode)); - return FALSE; - } - - errCode = NtQueryInformationFile(FileHandleSource, - &IoStatusBlock,&FileBasic, sizeof(FILE_BASIC_INFORMATION), - FileBasicInformation); - if ( !NT_SUCCESS(errCode) ) { - NtClose(FileHandleSource); - SetLastError(RtlNtStatusToDosError(errCode)); - return FALSE; - } - - - - - - - FileHandleDest = CreateFileW( - lpNewFileName, - GENERIC_WRITE, - FILE_SHARE_WRITE, - NULL, - dwCopyFlags ? CREATE_NEW : CREATE_ALWAYS , - FileBasic.FileAttributes|FILE_FLAG_NO_BUFFERING, - NULL - ); - - if ( !NT_SUCCESS(errCode) ) { - NtClose(FileHandleSource); - SetLastError(RtlNtStatusToDosError(errCode)); - return FALSE; - } - - - - - SET_LARGE_INTEGER_LOW_PART(FilePosition.CurrentByteOffset, 0); - SET_LARGE_INTEGER_HIGH_PART(FilePosition.CurrentByteOffset, 0); - - errCode = NtSetInformationFile(FileHandleSource, - &IoStatusBlock,&FilePosition, sizeof(FILE_POSITION_INFORMATION), - FilePositionInformation); - if ( !NT_SUCCESS(errCode) ) { - NtClose(FileHandleSource); - NtClose(FileHandleDest); - SetLastError(RtlNtStatusToDosError(errCode)); - return FALSE; - } - - errCode = NtSetInformationFile(FileHandleDest, - &IoStatusBlock,&FilePosition, sizeof(FILE_POSITION_INFORMATION), - FilePositionInformation); - - if ( !NT_SUCCESS(errCode) ) { - NtClose(FileHandleSource); - NtClose(FileHandleDest); - SetLastError(RtlNtStatusToDosError(errCode)); - return FALSE; - } - - - - errCode = NtAllocateVirtualMemory( - NtCurrentProcess(), - (PVOID *)&lpBuffer, - 2, - &RegionSize, - MEM_COMMIT, - PAGE_READWRITE - ); - - if ( !NT_SUCCESS(errCode) ) { - NtClose(FileHandleSource); - NtClose(FileHandleDest); - SetLastError(RtlNtStatusToDosError(errCode)); - return FALSE; - } - - - - - - - do { - - errCode = NtReadFile( - FileHandleSource, - NULL, - NULL, - NULL, - (PIO_STATUS_BLOCK)&IoStatusBlock, - lpBuffer, - RegionSize, - NULL, - NULL); - if ( pbCancel != NULL ) - bCancel = *pbCancel; - - - if ( !NT_SUCCESS(errCode) || bCancel ) { - NtFreeVirtualMemory(NtCurrentProcess(),(PVOID *)&lpBuffer, &RegionSize,MEM_RELEASE); - NtClose(FileHandleSource); - NtClose(FileHandleDest); - if ( errCode == STATUS_END_OF_FILE ) - break; - else - return FALSE; - - } - - errCode = NtWriteFile(FileHandleDest, - NULL, - lpProgressRoutine, - lpData, - (PIO_STATUS_BLOCK)&IoStatusBlock, - lpBuffer, - RegionSize, - NULL, - NULL); - - - - if ( !NT_SUCCESS(errCode) ) { - NtFreeVirtualMemory(NtCurrentProcess(),(PVOID *)&lpBuffer, &RegionSize,MEM_RELEASE); - NtClose(FileHandleSource); - NtClose(FileHandleDest); - return FALSE; - } - - } while ( TRUE ); - - return TRUE; - - -} - - HFILE STDCALL OpenFile( @@ -1221,12 +901,8 @@ GetFileAttributesW( } -WINBOOL -STDCALL -SetFileAttributesA( - LPCSTR lpFileName, - DWORD dwFileAttributes - ) +WINBOOL STDCALL SetFileAttributesA(LPCSTR lpFileName, + DWORD dwFileAttributes) { ULONG i; WCHAR FileNameW[MAX_PATH]; @@ -1242,46 +918,47 @@ SetFileAttributesA( } -WINBOOL -STDCALL -SetFileAttributesW( - LPCWSTR lpFileName, - DWORD dwFileAttributes - ) +WINBOOL STDCALL SetFileAttributesW(LPCWSTR lpFileName, + DWORD dwFileAttributes) { - IO_STATUS_BLOCK IoStatusBlock; - FILE_BASIC_INFORMATION FileBasic; - HANDLE hFile; - NTSTATUS errCode; + IO_STATUS_BLOCK IoStatusBlock; + FILE_BASIC_INFORMATION FileBasic; + HANDLE hFile; + NTSTATUS errCode; + + hFile = CreateFileW(lpFileName, + FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); - - hFile = CreateFileW( - lpFileName, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL - ); - - - errCode = NtQueryInformationFile(hFile,&IoStatusBlock,&FileBasic, sizeof(FILE_BASIC_INFORMATION),FileBasicInformation); - if ( !NT_SUCCESS(errCode) ) { - CloseHandle(hFile); - SetLastError(RtlNtStatusToDosError(errCode)); - return FALSE; - } - FileBasic.FileAttributes = dwFileAttributes; - errCode = NtSetInformationFile(hFile,&IoStatusBlock,&FileBasic, sizeof(FILE_BASIC_INFORMATION),FileBasicInformation); - if ( !NT_SUCCESS(errCode) ) { - CloseHandle(hFile); - SetLastError(RtlNtStatusToDosError(errCode)); - return FALSE; - } + errCode = NtQueryInformationFile(hFile, + &IoStatusBlock, + &FileBasic, + sizeof(FILE_BASIC_INFORMATION), + FileBasicInformation); + if (!NT_SUCCESS(errCode)) + { CloseHandle(hFile); - return TRUE; - + SetLastError(RtlNtStatusToDosError(errCode)); + return FALSE; + } + FileBasic.FileAttributes = dwFileAttributes; + errCode = NtSetInformationFile(hFile, + &IoStatusBlock, + &FileBasic, + sizeof(FILE_BASIC_INFORMATION), + FileBasicInformation); + if (!NT_SUCCESS(errCode)) + { + CloseHandle(hFile); + SetLastError(RtlNtStatusToDosError(errCode)); + return FALSE; + } + CloseHandle(hFile); + return TRUE; } diff --git a/reactos/lib/kernel32/file/find.c b/reactos/lib/kernel32/file/find.c index d470379bec4..bb6b1f51be2 100644 --- a/reactos/lib/kernel32/file/find.c +++ b/reactos/lib/kernel32/file/find.c @@ -12,7 +12,7 @@ /* INCLUDES *****************************************************************/ #include -#include +#include #include #define NDEBUG @@ -93,9 +93,9 @@ static FileDataToWin32Data(LPWIN32_FIND_DATA lpFindFileData, PKERNEL32_FIND_FILE { int i; lpFindFileData->dwFileAttributes = IData->FileInfo.FileAttributes; - memcpy(&lpFindFileData->ftCreationTime,&IData->FileInfo.CreationTime,sizeof(FILETIME)); - memcpy(&lpFindFileData->ftLastAccessTime,&IData->FileInfo.LastAccessTime,sizeof(FILETIME)); - memcpy(&lpFindFileData->ftLastWriteTime,&IData->FileInfo.LastWriteTime,sizeof(FILETIME)); +// memcpy(&lpFindFileData->ftCreationTime,&IData->FileInfo.CreationTime,sizeof(FILETIME)); +// memcpy(&lpFindFileData->ftLastAccessTime,&IData->FileInfo.LastAccessTime,sizeof(FILETIME)); +// memcpy(&lpFindFileData->ftLastWriteTime,&IData->FileInfo.LastWriteTime,sizeof(FILETIME)); lpFindFileData->nFileSizeHigh = IData->FileInfo.EndOfFile>>32; lpFindFileData->nFileSizeLow = IData->FileInfo.EndOfFile; diff --git a/reactos/lib/kernel32/file/find1.c b/reactos/lib/kernel32/file/find1.c deleted file mode 100644 index 0279c9b9295..00000000000 --- a/reactos/lib/kernel32/file/find1.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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 -#include -#include - -/* 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) -{ -} diff --git a/reactos/lib/kernel32/file/iocompl.c b/reactos/lib/kernel32/file/iocompl.c index b272f14c86a..569c8bac5e7 100644 --- a/reactos/lib/kernel32/file/iocompl.c +++ b/reactos/lib/kernel32/file/iocompl.c @@ -10,8 +10,7 @@ #include #include -#include -#include +#include typedef struct _FILE_COMPLETION_INFORMATION { diff --git a/reactos/lib/kernel32/file/lfile.c b/reactos/lib/kernel32/file/lfile.c index fa02d642977..ce4ff8618d2 100644 --- a/reactos/lib/kernel32/file/lfile.c +++ b/reactos/lib/kernel32/file/lfile.c @@ -11,7 +11,7 @@ #undef WIN32_LEAN_AND_MEAN #include #include -#include +#include diff --git a/reactos/lib/kernel32/file/volume.c b/reactos/lib/kernel32/file/volume.c index 2e432fb516e..71702dc9039 100644 --- a/reactos/lib/kernel32/file/volume.c +++ b/reactos/lib/kernel32/file/volume.c @@ -18,12 +18,10 @@ * Copyright 1996 Alexandre Julliard */ -#undef WIN32_LEAN_AND_MEAN #include #include -#include +#include #include -#include #define MAX_DOS_DRIVES 26 diff --git a/reactos/lib/kernel32/internal/dprintf.c b/reactos/lib/kernel32/internal/dprintf.c index f98ded81de7..d248bf909ec 100644 --- a/reactos/lib/kernel32/internal/dprintf.c +++ b/reactos/lib/kernel32/internal/dprintf.c @@ -4,34 +4,26 @@ VOID STDCALL OutputDebugStringA(LPCSTR lpOutputString) { - NtDisplayString(lpOutputString); - #if 0 - WCHAR DebugStringW[161]; - int i,j; - i = 0; + WCHAR DebugStringW[161]; + int i,j; + i = 0; + j = 0; + while ( lpOutputString[i] != 0 ) + { + while ( j < 160 && lpOutputString[i] != 0 ) + { + DebugStringW[j] = (WCHAR)lpOutputString[i]; + i++; + j++; + } + DebugStringW[j] = 0; + OutputDebugStringW(DebugStringW); j = 0; - while ( lpOutputString[i] != 0 ) - { - while ( j < 160 && lpOutputString[i] != 0 ) - { - DebugStringW[j] = (WCHAR)lpOutputString[i]; - i++; - j++; - } - DebugStringW[j] = 0; - OutputDebugStringW(DebugStringW); - j = 0; - } - - return; - #endif + } + return; } -VOID -STDCALL -OutputDebugStringW( - LPCWSTR lpOutputString - ) +VOID STDCALL OutputDebugStringW(LPCWSTR lpOutputString) { UNICODE_STRING UnicodeOutput; @@ -60,6 +52,6 @@ void aprintf(char* fmt, ...) va_start(va_args,fmt); vsprintf(buffer,fmt,va_args); - OutputDebugString(buffer); + OutputDebugStringA(buffer); va_end(fmt); } diff --git a/reactos/lib/kernel32/internal/init.c b/reactos/lib/kernel32/internal/init.c index d6107852aaa..90a812509e4 100644 --- a/reactos/lib/kernel32/internal/init.c +++ b/reactos/lib/kernel32/internal/init.c @@ -2,8 +2,12 @@ #include #include -VOID KERNEL32_Init(PWSTR Args) +#include + +VOID WINAPI __HeapInit(LPVOID base, ULONG minsize, ULONG maxsize); + +VOID KERNEL32_Init() { - InitializePeb(Args); + DPRINT("KERNEL32_Init()\n"); __HeapInit(0, 4*1024*1024, 4*1024*1024); } diff --git a/reactos/lib/kernel32/internal/string.c b/reactos/lib/kernel32/internal/string.c new file mode 100644 index 00000000000..d29ba6b622c --- /dev/null +++ b/reactos/lib/kernel32/internal/string.c @@ -0,0 +1,21 @@ +#include +#include +#include + +BOOL KERNEL32_AnsiToUnicode(PWSTR DestStr, + LPCSTR SrcStr, + ULONG MaxLen) +{ + ULONG i=0; + + while (SrcStr[i] != 0 && i < MaxLen) + { + DestStr[i] = (WCHAR)SrcStr[i]; + i++; + } + if (i == MaxLen && SrcStr[i] != 0) + { + return(FALSE); + } + return(TRUE); +} diff --git a/reactos/lib/kernel32/makefile b/reactos/lib/kernel32/makefile index f602ffb31ba..3169c166264 100644 --- a/reactos/lib/kernel32/makefile +++ b/reactos/lib/kernel32/makefile @@ -7,23 +7,25 @@ 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/find.o + file/create.o file/find.o file/copy.o MEM_OBJECTS = mem/virtual.o mem/heap.o mem/utils.o +NLS_OBJECTS = # nls/mbtowc.o nls/wctomb.o + THREAD_OBJECTS = thread/thread.o PROCESS_OBJECTS = process/proc.o process/cmdline.o STRING_OBJECTS = string/lstring.o -INTERNAL_OBJECTS = internal/dprintf.o internal/init.o +INTERNAL_OBJECTS = internal/dprintf.o internal/init.o internal/string.o EXCEPT_OBJECTS = except/except.o OBJECTS = $(MISC_OBJECTS) $(FILE_OBJECTS) $(THREAD_OBJECTS) \ - $(PROCESS_OBJECTS) $(STRING_OBJECTS) $(MEM_OBJECTS) \ + $(PROCESS_OBJECTS) $(STRING_OBJECTS) $(MEM_OBJECTS) $(NLS_OBJECTS) \ $(INTERNAL_OBJECTS) $(SYNCH_OBJECTS) $(EXCEPT_OBJECTS) diff --git a/reactos/lib/kernel32/mem/heap.c b/reactos/lib/kernel32/mem/heap.c index 7ef099143a7..c7d3dcdd30f 100644 --- a/reactos/lib/kernel32/mem/heap.c +++ b/reactos/lib/kernel32/mem/heap.c @@ -31,7 +31,7 @@ #include #include -#include +#include #include diff --git a/reactos/lib/kernel32/misc/atom.c b/reactos/lib/kernel32/misc/atom.c index 905375a4950..b0d5a6d0033 100644 --- a/reactos/lib/kernel32/misc/atom.c +++ b/reactos/lib/kernel32/misc/atom.c @@ -9,10 +9,10 @@ * Created 01/11/98 */ -#include -#include -#include -#include +#include +#include +#include +#include #include //#include diff --git a/reactos/lib/kernel32/misc/console.c b/reactos/lib/kernel32/misc/console.c index aef76f075c1..2c62f539780 100644 --- a/reactos/lib/kernel32/misc/console.c +++ b/reactos/lib/kernel32/misc/console.c @@ -164,7 +164,7 @@ STDCALL AllocConsole( VOID ) { /* FIXME: add CreateFile error checking */ - StdInput = CreateFile("\\Keyboard", + StdInput = CreateFile("\\\\.\\Keyboard", FILE_GENERIC_READ, 0, NULL, @@ -172,7 +172,7 @@ AllocConsole( VOID ) 0, NULL); - StdOutput = CreateFile("\\BlueScreen", + StdOutput = CreateFile("\\\\.\\BlueScreen", FILE_GENERIC_WRITE|FILE_GENERIC_READ, 0, NULL, @@ -936,6 +936,7 @@ GetConsoleTitleA( if (!lpConsoleTitle || !nSize) return 0; nWideTitle = GetConsoleTitleW( (LPWSTR) WideTitle, nWideTitle ); if (!nWideTitle) return 0; +#if 0 if ( (nWritten = WideCharToMultiByte( CP_ACP, // ANSI code page 0, // performance and mapping flags @@ -950,6 +951,7 @@ GetConsoleTitleA( lpConsoleTitle[nWritten] = '\0'; return nWritten; } +#endif return 0; } @@ -997,6 +999,7 @@ SetConsoleTitleA( return FALSE; } AnsiTitle[nWideTitle] = '\0'; +#if 0 if ( MultiByteToWideChar( CP_ACP, // ANSI code page MB_PRECOMPOSED, // character-type options @@ -1008,6 +1011,7 @@ SetConsoleTitleA( { return SetConsoleTitleW( (LPWSTR) WideTitle ); } +#endif return FALSE; } diff --git a/reactos/lib/kernel32/misc/dllmain.c b/reactos/lib/kernel32/misc/dllmain.c index 4289dfc9738..b4dafb6ad1f 100644 --- a/reactos/lib/kernel32/misc/dllmain.c +++ b/reactos/lib/kernel32/misc/dllmain.c @@ -10,7 +10,7 @@ #include #include -#include +#include #include WINBOOL diff --git a/reactos/lib/kernel32/misc/env.c b/reactos/lib/kernel32/misc/env.c index c61d0ec8cea..2cccfcf389d 100644 --- a/reactos/lib/kernel32/misc/env.c +++ b/reactos/lib/kernel32/misc/env.c @@ -10,7 +10,7 @@ #include #include -#include +#include #include #define MAX_ENVIRONMENT_VARS 255 diff --git a/reactos/lib/kernel32/misc/error.c b/reactos/lib/kernel32/misc/error.c index 54ed7e79722..5c4b7fefaae 100644 --- a/reactos/lib/kernel32/misc/error.c +++ b/reactos/lib/kernel32/misc/error.c @@ -6,12 +6,7 @@ static DWORD LastError; DWORD RtlNtStatusToDosError(NTSTATUS Status) { - if (NT_SUCCESS(Status)) return(0); - else - { - // FIXME must return different values - return 1; - } + return(0); } diff --git a/reactos/lib/kernel32/misc/handle.c b/reactos/lib/kernel32/misc/handle.c index f16eabc245d..65decf8a42a 100644 --- a/reactos/lib/kernel32/misc/handle.c +++ b/reactos/lib/kernel32/misc/handle.c @@ -8,7 +8,7 @@ * Created 01/11/98 */ #include -#include +#include diff --git a/reactos/lib/kernel32/misc/time.c b/reactos/lib/kernel32/misc/time.c index 8ff2937920a..c9dd19d3a72 100644 --- a/reactos/lib/kernel32/misc/time.c +++ b/reactos/lib/kernel32/misc/time.c @@ -10,9 +10,6 @@ */ #include #include -#include - -TIME_ZONE_INFORMATION TimeZoneInformation; typedef struct __DOSTIME { @@ -30,44 +27,26 @@ typedef struct __DOSDATE #define NSPERSEC 10000000 - - #define SECOND 1 #define MINUTE 60*SECOND #define HOUR 60*MINUTE - #define DAY 24*HOUR #define YEAR (365*DAY) #define FOURYEAR (4*YEAR+DAY) #define CENTURY (25*FOURYEAR-DAY) -#define FOURCENTURY (4*CENTURY+DAY) +#define MILLENIUM (100*CENTURY) -#define MINUTE60 1 -#define HOUR60 60*MINUTE60 -#define DAY60 24*HOUR60 -#define YEAR60 (365*DAY60) -#define FOURYEAR60 (4*YEAR60+DAY60) -#define CENTURY60 (25*FOURYEAR60-DAY60) -#define FOURCENTURY60 (4*CENTURY60+DAY60) - -#ifdef COMPILER_LARGE_INTEGERS - #define RtlEnlargedUnsignedMultiply(m,n) (LARGE_INTEGER_QUAD_PART(((ULONGLONG)m)*((ULONGLONG)n))) - #define RtlEnlargedIntegerMultiply(m,n) (LARGE_INTEGER_QUAD_PART(((LONGLONG)m)*((LONGLONG)n))) - #define RtlLargeIntegerAdd(a1,a2) (LARGE_INTEGER_QUAD_PART(a1) + LARGE_INTEGER_QUAD_PART(a2)) - #define RtlExtendedIntegerMultiply(m1,m2) (LARGE_INTEGER_QUAD_PART(m1) * m2) - #define RtlLargeIntegerDivide(d1,d2,r1) LARGE_INTEGER_QUAD_PART(d1) / LARGE_INTEGER_QUAD_PART(d2);LARGE_INTEGER_QUAD_PART(*r1) = LARGE_INTEGER_QUAD_PART(d1) % LARGE_INTEGER_QUAD_PART(d2) - -#endif - #define LISECOND RtlEnlargedUnsignedMultiply(SECOND,NSPERSEC) -#define LIMINUTE RtlEnlargedUnsignedMultiply(MINUTE60,60*NSPERSEC) -#define LIHOUR RtlEnlargedUnsignedMultiply(HOUR60,60*NSPERSEC) -#define LIDAY RtlEnlargedUnsignedMultiply(DAY60,60*NSPERSEC) -#define LIYEAR RtlEnlargedUnsignedMultiply(YEAR60,60*NSPERSEC) -#define LIFOURYEAR RtlEnlargedUnsignedMultiply(FOURYEAR60,60*NSPERSEC) -#define LICENTURY RtlEnlargedUnsignedMultiply(CENTURY60,60*NSPERSEC) -#define LIFOURCENTURY RtlEnlargedUnsignedMultiply(FOURCENTURY60,60*NSPERSEC) +#define LIMINUTE RtlEnlargedUnsignedMultiply(MINUTE,NSPERSEC) +#define LIHOUR RtlEnlargedUnsignedMultiply(HOUR,NSPERSEC) +#define LIDAY RtlEnlargedUnsignedMultiply(DAY,NSPERSEC) +#define LIYEAR RtlEnlargedUnsignedMultiply(YEAR,NSPERSEC) +#define LIFOURYEAR RtlEnlargedUnsignedMultiply(FOURYEAR,NSPERSEC) +#define LICENTURY RtlEnlargedUnsignedMultiply(CENTURY,NSPERSEC) +#define LIMILLENIUM RtlEnlargedUnsignedMultiply(CENTURY,10*NSPERSEC) + + @@ -153,29 +132,24 @@ CompareFileTime( CONST FILETIME *lpFileTime2 ) { - LARGE_INTEGER FileTime1, FileTime2; - - - + if ( lpFileTime1 == NULL ) return 0; if ( lpFileTime2 == NULL ) return 0; - - memcpy(&FileTime1,lpFileTime1,sizeof(FILETIME)); - memcpy(&FileTime2,lpFileTime2,sizeof(FILETIME)); - if ((GET_LARGE_INTEGER_HIGH_PART((FileTime1))) > (GET_LARGE_INTEGER_HIGH_PART((FileTime2))) ) + /* + if ((GET_LARGE_INTEGER_HIGH_PART(lpFileTime1)) > (GET_LARGE_INTEGER_HIGH_PART(lpFileTime2)) ) return 1; - else if ((GET_LARGE_INTEGER_HIGH_PART(FileTime1)) < (GET_LARGE_INTEGER_HIGH_PART(FileTime2))) + else if ((GET_LARGE_INTEGER_HIGH_PART(lpFileTime1)) < (GET_LARGE_INTEGER_HIGH_PART(lpFileTime2))) return -1; - else if ((GET_LARGE_INTEGER_LOW_PART(FileTime1)) > (GET_LARGE_INTEGER_LOW_PART(FileTime2))) + else if ((GET_LARGE_INTEGER_LOW_PART(lpFileTime1)) > (GET_LARGE_INTEGER_LOW_PART(lpFileTime2))) return 1; - else if ((GET_LARGE_INTEGER_LOW_PART(FileTime1)) < (GET_LARGE_INTEGER_LOW_PART(FileTime2))) + else if ((GET_LARGE_INTEGER_LOW_PART(lpFileTime1)) < (GET_LARGE_INTEGER_LOW_PART(lpFileTime2))) return -1; else return 0; - + */ } VOID @@ -280,31 +254,31 @@ FileTimeToSystemTime( LARGE_INTEGER FileTime; - LARGE_INTEGER liFourCentury; - LARGE_INTEGER liRemFourCentury; + LARGE_INTEGER dwMillenium; + LARGE_INTEGER dwRemMillenium; - LARGE_INTEGER liCentury; - LARGE_INTEGER liRemCentury; + LARGE_INTEGER dwCentury; + LARGE_INTEGER dwRemCentury; - LARGE_INTEGER liFourYear; - LARGE_INTEGER liRemFourYear; + LARGE_INTEGER dwFourYear; + LARGE_INTEGER dwRemFourYear; - LARGE_INTEGER liYear; - LARGE_INTEGER liRemYear; + LARGE_INTEGER dwYear; + LARGE_INTEGER dwRemYear; - LARGE_INTEGER liDay; - LARGE_INTEGER liRemDay; + LARGE_INTEGER dwDay; + LARGE_INTEGER dwRemDay; - LARGE_INTEGER liHour; - LARGE_INTEGER liRemHour; + LARGE_INTEGER dwHour; + LARGE_INTEGER dwRemHour; - LARGE_INTEGER liMinute; - LARGE_INTEGER liRemMinute; + LARGE_INTEGER dwMinute; + LARGE_INTEGER dwRemMinute; - LARGE_INTEGER liSecond; - LARGE_INTEGER liRemSecond; + LARGE_INTEGER dwSecond; + LARGE_INTEGER dwRemSecond; - LARGE_INTEGER liDayOfWeek; + LARGE_INTEGER dwDayOfWeek; DWORD LeapDay = 0; @@ -313,19 +287,19 @@ FileTimeToSystemTime( memcpy(&FileTime,lpFileTime,sizeof(FILETIME)); - liFourCentury = RtlLargeIntegerDivide(FileTime,LIFOURCENTURY,&liRemFourCentury); - liCentury = RtlLargeIntegerDivide(liRemFourCentury,LICENTURY,&liRemCentury); - liFourYear = RtlLargeIntegerDivide(liRemCentury,LIFOURYEAR,&liRemFourYear); - liYear = RtlLargeIntegerDivide(liRemFourYear,LIYEAR,&liRemYear); - liDay = RtlLargeIntegerDivide(liRemYear,LIDAY,&liRemDay); - liHour = RtlLargeIntegerDivide(liRemDay,LIHOUR,&liRemHour); - liMinute = RtlLargeIntegerDivide(liRemHour,LIMINUTE,&liRemMinute); - liSecond = RtlLargeIntegerDivide(liRemMinute,LISECOND,&liRemSecond); + dwMillenium = RtlLargeIntegerDivide(FileTime,LIMILLENIUM,&dwRemMillenium); + dwCentury = RtlLargeIntegerDivide(dwRemMillenium,LICENTURY,&dwRemCentury); + dwFourYear = RtlLargeIntegerDivide(dwRemCentury,LIFOURYEAR,&dwRemFourYear); + dwYear = RtlLargeIntegerDivide(dwRemFourYear,LIYEAR,&dwRemYear); + dwDay = RtlLargeIntegerDivide(dwRemYear,LIDAY,&dwRemDay); + dwHour = RtlLargeIntegerDivide(dwRemDay,LIHOUR,&dwRemHour); + dwMinute = RtlLargeIntegerDivide(dwRemHour,LIMINUTE,&dwRemMinute); + dwSecond = RtlLargeIntegerDivide(dwRemMinute,LISECOND,&dwRemSecond); - lpSystemTime->wHour= (WORD) GET_LARGE_INTEGER_LOW_PART(liHour); - lpSystemTime->wMinute= (WORD)GET_LARGE_INTEGER_LOW_PART(liMinute); - lpSystemTime->wSecond= (WORD)GET_LARGE_INTEGER_LOW_PART(liSecond); - lpSystemTime->wMilliseconds = (WORD)(GET_LARGE_INTEGER_LOW_PART(liRemSecond)/10000); + lpSystemTime->wHour= (WORD) GET_LARGE_INTEGER_LOW_PART(dwHour); + lpSystemTime->wMinute= (WORD)GET_LARGE_INTEGER_LOW_PART(dwMinute); + lpSystemTime->wSecond= (WORD)GET_LARGE_INTEGER_LOW_PART(dwSecond); + lpSystemTime->wMilliseconds = (WORD)(GET_LARGE_INTEGER_LOW_PART(dwRemSecond)/10000); if ( lpSystemTime->wSecond > 60 ) { @@ -340,14 +314,13 @@ FileTimeToSystemTime( if (lpSystemTime->wHour > 24 ) { lpSystemTime->wHour-= 24; - SET_LARGE_INTEGER_LOW_PART(liDay,GET_LARGE_INTEGER_LOW_PART(liDay)+1); + SET_LARGE_INTEGER_LOW_PART(dwDay,GET_LARGE_INTEGER_LOW_PART(dwDay)+1); } //FIXME since 1972 some years have a leap second [ aprox 15 out of 20 ] - // printf("400 %d 100 %d 4 %d 1 %d\n",(LONG)GET_LARGE_INTEGER_LOW_PART(liFourCentury) , (LONG)GET_LARGE_INTEGER_LOW_PART(liCentury), (LONG)GET_LARGE_INTEGER_LOW_PART(liFourYear), (LONG)GET_LARGE_INTEGER_LOW_PART(liYear)); // if leap year - lpSystemTime->wYear= 1601 + 400* (WORD)GET_LARGE_INTEGER_LOW_PART(liFourCentury) + 100 * (WORD)GET_LARGE_INTEGER_LOW_PART(liCentury) + 4*(LONG)GET_LARGE_INTEGER_LOW_PART(liFourYear) + (WORD)GET_LARGE_INTEGER_LOW_PART(liYear); + lpSystemTime->wYear= 1601 + 1000* (LONG)GET_LARGE_INTEGER_LOW_PART(dwMillenium) + 100 * (LONG)GET_LARGE_INTEGER_LOW_PART(dwCentury) + 4*(LONG)GET_LARGE_INTEGER_LOW_PART(dwFourYear) + (LONG)GET_LARGE_INTEGER_LOW_PART(dwYear); if ( (lpSystemTime->wYear % 4 == 0 && lpSystemTime->wYear % 100 != 0) || lpSystemTime->wYear % 400 == 0) LeapDay = 1; @@ -356,58 +329,58 @@ FileTimeToSystemTime( - if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= 0 && GET_LARGE_INTEGER_LOW_PART(liDay) < 31 ) { + if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= 0 && GET_LARGE_INTEGER_LOW_PART(dwDay) < 31 ) { lpSystemTime->wMonth = 1; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1; + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1; } - else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= 31 && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 59 + LeapDay )) { + else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= 31 && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 59 + LeapDay )) { lpSystemTime->wMonth = 2; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - 31; + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - 31; } - else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 59 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 90 + LeapDay ) ) { + else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 59 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 90 + LeapDay ) ) { lpSystemTime->wMonth = 3; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 59 + LeapDay); + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 59 + LeapDay); } - else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= 90+ LeapDay && GET_LARGE_INTEGER_LOW_PART(liDay) < 120 + LeapDay) { + else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= 90+ LeapDay && GET_LARGE_INTEGER_LOW_PART(dwDay) < 120 + LeapDay) { lpSystemTime->wMonth = 4; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - (31 + LeapDay ); + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - (31 + LeapDay ); } - else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= 120 + LeapDay && GET_LARGE_INTEGER_LOW_PART(liDay) < 151 + LeapDay ) { + else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= 120 + LeapDay && GET_LARGE_INTEGER_LOW_PART(dwDay) < 151 + LeapDay ) { lpSystemTime->wMonth = 5; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - (120 + LeapDay); + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - (120 + LeapDay); } - else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 151 + LeapDay) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 181 + LeapDay ) ) { + else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 151 + LeapDay) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 181 + LeapDay ) ) { lpSystemTime->wMonth = 6; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 151 + LeapDay ); + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 151 + LeapDay ); } - else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 181 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 212 + LeapDay ) ) { + else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 181 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 212 + LeapDay ) ) { lpSystemTime->wMonth = 7; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 181 + LeapDay ); + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 181 + LeapDay ); } - else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 212 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 243 + LeapDay ) ) { + else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 212 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 243 + LeapDay ) ) { lpSystemTime->wMonth = 8; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - (212 + LeapDay ); + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - (212 + LeapDay ); } - else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 243+ LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 273 + LeapDay ) ) { + else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 243+ LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 273 + LeapDay ) ) { lpSystemTime->wMonth = 9; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 243 + LeapDay ); + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 243 + LeapDay ); } - else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 273 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 304 + LeapDay ) ) { + else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 273 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 304 + LeapDay ) ) { lpSystemTime->wMonth = 10; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 273 + LeapDay); + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 273 + LeapDay); } - else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 304 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 334 + LeapDay ) ) { + else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 304 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 334 + LeapDay ) ) { lpSystemTime->wMonth = 11; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 304 + LeapDay ); + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 304 + LeapDay ); } - else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 334 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 365 + LeapDay )) { + else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 334 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 365 + LeapDay )) { lpSystemTime->wMonth = 12; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 334 + LeapDay ); + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 334 + LeapDay ); } - liDayOfWeek = RtlLargeIntegerDivide(FileTime,LIDAY,&liRemDay); - lpSystemTime->wDayOfWeek = 1 + GET_LARGE_INTEGER_LOW_PART(liDayOfWeek) % 7; + dwDayOfWeek = RtlLargeIntegerDivide(FileTime,LIDAY,&dwRemDay); + lpSystemTime->wDayOfWeek = 1 + GET_LARGE_INTEGER_LOW_PART(dwDayOfWeek) % 7; @@ -423,18 +396,9 @@ FileTimeToLocalFileTime( LPFILETIME lpLocalFileTime ) { - TIME_ZONE_INFORMATION TimeZoneInformation; - LARGE_INTEGER *FileTime, *LocalFileTime; - - if ( lpFileTime == NULL || lpLocalFileTime == NULL ) - return FALSE; - FileTime = (LARGE_INTEGER *)lpFileTime; - LocalFileTime = (LARGE_INTEGER *)lpLocalFileTime; - - GetTimeZoneInformation(&TimeZoneInformation); - *LocalFileTime = RtlLargeIntegerAdd(*FileTime,RtlExtendedIntegerMultiply((LIMINUTE),(LONG)-1*TimeZoneInformation.Bias)); - - return TRUE; + // memcpy(lpLocalFileTime,lpFileTime,sizeof(FILETIME)); + + return TRUE; } WINBOOL @@ -444,18 +408,8 @@ LocalFileTimeToFileTime( LPFILETIME lpFileTime ) { - TIME_ZONE_INFORMATION TimeZoneInformation; - LARGE_INTEGER *FileTime, *LocalFileTime; - - if ( lpFileTime == NULL || lpLocalFileTime == NULL ) - return FALSE; - FileTime = (LARGE_INTEGER *)lpFileTime; - LocalFileTime = (LARGE_INTEGER *)lpLocalFileTime; - - GetTimeZoneInformation(&TimeZoneInformation); - *FileTime = RtlLargeIntegerAdd(*LocalFileTime,RtlExtendedIntegerMultiply((LIMINUTE),(LONG)TimeZoneInformation.Bias)); - - return TRUE; + + return TRUE; } VOID @@ -464,13 +418,7 @@ GetLocalTime( LPSYSTEMTIME lpSystemTime ) { - - FILETIME FileTime; - FILETIME LocalTime; - GetSystemTimeAsFileTime(&FileTime); - FileTimeToLocalFileTime(&FileTime,&LocalTime); - FileTimeToSystemTime(&LocalTime,lpSystemTime); - + GetSystemTime(lpSystemTime); return; } @@ -492,17 +440,8 @@ SetLocalTime( CONST SYSTEMTIME *lpSystemTime ) { - NTSTATUS errCode; - FILETIME FileTime, LocalTime; - SystemTimeToFileTime(lpSystemTime,&LocalTime); - LocalFileTimeToFileTime(&LocalTime,&FileTime); - errCode = NtSetSystemTime ((LARGE_INTEGER *)&FileTime,(LARGE_INTEGER *)&FileTime); - if ( !NT_SUCCESS(errCode) ) - return FALSE; - return TRUE; - + return SetSystemTime(lpSystemTime); } - WINBOOL STDCALL SetSystemTime( @@ -513,16 +452,39 @@ SetSystemTime( LARGE_INTEGER NewSystemTime; SystemTimeToFileTime(lpSystemTime, (FILETIME *)&NewSystemTime); - errCode = NtSetSystemTime ((LARGE_INTEGER *)&NewSystemTime,(LARGE_INTEGER *)&NewSystemTime); + errCode = NtSetSystemTime (&NewSystemTime,&NewSystemTime); if ( !NT_SUCCESS(errCode) ) return FALSE; return TRUE; } +/* +typedef struct _TIME_ZONE_INFORMATION { // tzi + LONG Bias; + WCHAR StandardName[ 32 ]; + SYSTEMTIME StandardDate; + LONG StandardBias; + WCHAR DaylightName[ 32 ]; + SYSTEMTIME DaylightDate; + LONG DaylightBias; +} TIME_ZONE_INFORMATION; +TIME_ZONE_INFORMATION TimeZoneInformation = {60,"CET",; +*/ DWORD STDCALL -GetCurrentTime(VOID) +GetTimeZoneInformation( + LPTIME_ZONE_INFORMATION lpTimeZoneInformation + ) +{ + // aprintf("GetTimeZoneInformation()\n"); + + // memset(lpTimeZoneInformation, 0, sizeof(TIME_ZONE_INFORMATION)); + + return TIME_ZONE_ID_UNKNOWN; +} + +DWORD STDCALL GetCurrentTime(VOID) { return GetTickCount(); } @@ -535,85 +497,3 @@ GetTickCount(VOID) NtGetTickCount(&UpTime); return UpTime; } - - - -VOID __InitTimeZoneInformation(VOID) -{ - TimeZoneInformation.Bias = 60; - TimeZoneInformation.StandardName[0] = 0; - TimeZoneInformation.StandardDate.wMonth = 9; - TimeZoneInformation.StandardDate.wDay = 21; - TimeZoneInformation.StandardBias = 0; - TimeZoneInformation.DaylightName[0] = 0; - TimeZoneInformation.DaylightDate.wMonth = 3; - TimeZoneInformation.DaylightDate.wDay = 21; - TimeZoneInformation.DaylightBias = -60; - -} - -WINBOOL -STDCALL -SetTimeZoneInformation( - CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation - ) -{ - if ( lpTimeZoneInformation == NULL ) - return FALSE; - TimeZoneInformation = *lpTimeZoneInformation; - return TRUE; -} - - - -DWORD -STDCALL -GetTimeZoneInformation( - LPTIME_ZONE_INFORMATION lpTimeZoneInformation - ) -{ - // aprintf("GetTimeZoneInformation()\n"); - SYSTEMTIME SystemTime; - if ( lpTimeZoneInformation == NULL ) - return -1; - - - *lpTimeZoneInformation = TimeZoneInformation; -/* - FIXME I should not recurse - GetLocalTime(&SystemTime); - if ( TimeZoneInformation.DaylightDate.wMonth == 0 || TimeZoneInformation.StandardDate.wMonth == 0 ) - return TIME_ZONE_ID_UNKNOWN; - else if ( ( SystemTime.wMonth > TimeZoneInformation.DaylightDate.wMonth && - SystemTime.wDay > TimeZoneInformation.DaylightDate.wDay ) && - ( SystemTime.wMonth < TimeZoneInformation.StandardDate.wMonth && - SystemTime.wDay < TimeZoneInformation.StandardDate.wDay ) ) - return TIME_ZONE_ID_DAYLIGHT; - else - return TIME_ZONE_ID_STANDARD; - */ - return TIME_ZONE_ID_UNKNOWN; -} - - -WINBOOL -STDCALL -SetSystemTimeAdjustment( - DWORD dwTimeAdjustment, - WINBOOL bTimeAdjustmentDisabled - ) -{ - return FALSE; -} - - -WINBOOL -STDCALL -GetSystemTimeAdjustment( - PDWORD lpTimeAdjustment, - PDWORD lpTimeIncrement, - PWINBOOL lpTimeAdjustmentDisabled - ) -{ - return FALSE; -} diff --git a/reactos/lib/kernel32/process/cmdline.c b/reactos/lib/kernel32/process/cmdline.c index 6198dffae50..f56dc946678 100644 --- a/reactos/lib/kernel32/process/cmdline.c +++ b/reactos/lib/kernel32/process/cmdline.c @@ -14,10 +14,8 @@ #include #include #include -#include +#include #include -#include -#include /* GLOBALS ******************************************************************/ diff --git a/reactos/lib/kernel32/process/proc.c b/reactos/lib/kernel32/process/proc.c index 68e11b35942..396b2165e26 100644 --- a/reactos/lib/kernel32/process/proc.c +++ b/reactos/lib/kernel32/process/proc.c @@ -14,10 +14,8 @@ #include #include #include -#include +#include #include -#include -#include #include #define NDEBUG @@ -406,7 +404,7 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName, BaseAddress = (PVOID)0x10000; LARGE_INTEGER_QUAD_PART(SectionOffset) = 0; - Size = 0x10000; + Size = 0x20000; NtMapViewOfSection(hSection, hProcess, &BaseAddress, diff --git a/reactos/lib/kernel32/string/lstring.c b/reactos/lib/kernel32/string/lstring.c index c69aade5605..ea8252d7477 100644 --- a/reactos/lib/kernel32/string/lstring.c +++ b/reactos/lib/kernel32/string/lstring.c @@ -7,10 +7,10 @@ * UPDATE HISTORY: * Created 01/11/98 */ -#undef WIN32_LEAN_AND_MEAN + #include #include -#include +#include int diff --git a/reactos/lib/kernel32/synch/event.c b/reactos/lib/kernel32/synch/event.c index 55cce0bb824..f63a43af250 100644 --- a/reactos/lib/kernel32/synch/event.c +++ b/reactos/lib/kernel32/synch/event.c @@ -7,11 +7,10 @@ * UPDATE HISTORY: * Created 01/11/98 */ -#undef WIN32_LEAN_AND_MEAN + #include #include -#include -#include +#include WINBOOL @@ -195,4 +194,4 @@ PulseEvent( return FALSE; } return TRUE; -} \ No newline at end of file +} diff --git a/reactos/lib/kernel32/synch/wait.c b/reactos/lib/kernel32/synch/wait.c index 354ae352529..50bc8bb0842 100644 --- a/reactos/lib/kernel32/synch/wait.c +++ b/reactos/lib/kernel32/synch/wait.c @@ -9,9 +9,8 @@ */ #include -#include +#include #include -#include HANDLE STDCALL diff --git a/reactos/lib/mingw32/main.c b/reactos/lib/mingw32/main.c deleted file mode 100644 index 04d204ef884..00000000000 --- a/reactos/lib/mingw32/main.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * main.c - * - * Extra startup code for applications which do not have a main function - * of their own (but do have a WinMain). Generally these are GUI - * applications, but they don't *have* to be. - * - * This code was written to interface with CRTDLL.DLL as supplied with - * Windows NT and Windows 95, although it could, conceivably, be useful - * under other circumstances. - * - * Contributors: - * Created by Colin Peters - * - * THIS SOFTWARE IS NOT COPYRIGHTED - * - * This source code is offered for use in the public domain. You may - * use, modify or distribute it freely. - * - * This code is distributed in the hope that it will be useful but - * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY - * DISCLAMED. This includes but is not limited to warrenties of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - -#include -#include -#include - -#define ISSPACE(a) (a == ' ' || a == '\t') - -extern int PASCAL WinMain (HANDLE hInst, HANDLE hPrevInst, LPSTR szCmdLine, - int nShow); - -int -main (int argc, char* argv[], char* environ[]) -{ - char* szCmd; - STARTUPINFO startinfo; - int nRet; - - /* Get the command line passed to the process. */ - szCmd = GetCommandLineA(); - GetStartupInfoA(&startinfo); - - /* Strip off the name of the application and any leading - * whitespace. */ - if (szCmd) - { - while(ISSPACE(*szCmd)) - { - szCmd++; - } - - /* On my system I always get the app name enclosed - * in quotes... */ - if (*szCmd == '\"') - { - do - { - szCmd++; - } - while (*szCmd != '\"' && *szCmd != '\0'); - - if (*szCmd == '\"') - { - szCmd++; - } - } - else - { - /* If no quotes then assume first token is program - * name. */ - while (!ISSPACE(*szCmd) && *szCmd != '\0') - { - szCmd++; - } - } - - while (ISSPACE(*szCmd)) - { - szCmd++; - } - } - - nRet = WinMain (GetModuleHandle(NULL), NULL, szCmd, - (startinfo.dwFlags & STARTF_USESHOWWINDOW) ? - startinfo.wShowWindow : SW_SHOWDEFAULT); - - return nRet; -} - diff --git a/reactos/lib/mingw32/makefile b/reactos/lib/mingw32/makefile deleted file mode 100644 index c0d97532f45..00000000000 --- a/reactos/lib/mingw32/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: mingw32.a - -OBJECTS = main.o - -mingw32.a: $(OBJECTS) - $(AR) vrcs mingw32.a $(OBJECTS) - -dummy: - -include ../../rules.mak diff --git a/reactos/lib/ntdll/.cvsignore b/reactos/lib/ntdll/.cvsignore new file mode 100644 index 00000000000..e0113baccbe --- /dev/null +++ b/reactos/lib/ntdll/.cvsignore @@ -0,0 +1,6 @@ +napi.asm +ntdll.lib +base.tmp +junk.tmp +ntdll.dll +temp.exp diff --git a/reactos/lib/ntdll/def/ntdll.def b/reactos/lib/ntdll/def/ntdll.def index 7e26983f8ec..e5b03838a05 100644 --- a/reactos/lib/ntdll/def/ntdll.def +++ b/reactos/lib/ntdll/def/ntdll.def @@ -1,421 +1,450 @@ EXPORTS -NtAcceptConnectPort -NtAccessCheck -NtAccessCheckAndAuditAlarm -NtAddAtom -NtAdjustGroupsToken -NtAdjustPrivilegesToken -NtAlertResumeThread -NtAlertThread -NtAllocateLocallyUniqueId -NtAllocateUuids -NtAllocateVirtualMemory -NtCallbackReturn -NtCancelIoFile -NtCancelTimer -NtClearEvent -NtClose -NtCloseObjectAuditAlarm -NtCompleteConnectPort -NtConnectPort -NtContinue -NtCreateDirectoryObject -NtCreateEvent -NtCreateEventPair -NtCreateFile -NtCreateIoCompletion -NtCreateKey -NtCreateMailslotFile -NtCreateMutant -NtCreateNamedPipeFile -NtCreatePagingFile -NtCreatePort -NtCreateProcess -NtCreateProfile -NtCreateSection -NtCreateSemaphore -NtCreateSymbolicLinkObject -NtCreateThread -NtCreateTimer -NtCreateToken -NtDelayExecution -NtDeleteAtom -NtDeleteFile -NtDeleteKey -NtDeleteObjectAuditAlarm -NtDeleteValueKey -NtDeviceIoControlFile -NtDisplayString -NtDuplicateObject -NtDuplicateToken -NtEnumerateKey -NtEnumerateValueKey -NtExtendSection -NtFindAtom -NtFlushBuffersFile -NtFlushInstructionCache -NtFlushKey -NtFlushVirtualMemory -NtFlushWriteBuffer -NtFreeVirtualMemory -NtFsControlFile -NtGetContextThread -NtGetPlugPlayEvent -NtGetTickCount -NtImpersonateClientOfPort -NtImpersonateThread -NtInitializeRegistry -NtListenPort -NtLoadDriver -NtLoadKey -NtLoadKey2 -NtLockFile -NtLockVirtualMemory -NtMakeTemporaryObject -NtMapViewOfSection -NtNotifyChangeDirectoryFile -NtNotifyChangeKey -NtOpenDirectoryObject -NtOpenEvent -NtOpenEventPair -NtOpenFile -NtOpenIoCompletion -NtOpenKey -NtOpenMutant -NtOpenObjectAuditAlarm -NtOpenProcess -NtOpenProcessToken -NtOpenSection -NtOpenSemaphore -NtOpenSymbolicLinkObject -NtOpenThread -NtOpenThreadToken -NtOpenTimer -NtPlugPlayControl -NtPrivilegeCheck -NtPrivilegedServiceAuditAlarm -NtPrivilegeObjectAuditAlarm -NtProtectVirtualMemory -NtPulseEvent -NtQueryInformationAtom -NtQueryAttributesFile -NtQueryDefaultLocale -NtQueryDirectoryFile -NtQueryDirectoryObject -NtQueryEaFile -NtQueryEvent -NtQueryFullAttributesFile -NtQueryInformationFile -NtQueryIoCompletion -NtQueryInformationPort -NtQueryInformationProcess -NtQueryInformationThread -NtQueryInformationToken -NtQueryIntervalProfile -NtQueryKey -NtQueryMultipleValueKey -NtQueryMutant -NtQueryObject -NtQueryOleDirectoryFile -NtQueryPerformanceCounter -NtQuerySection -NtQuerySecurityObject -NtQuerySemaphore -NtQuerySymbolicLinkObject -NtQuerySystemEnvironmentValue -NtQuerySystemInformation -NtQuerySystemTime -NtQueryTimer -NtQueryTimerResolution -NtQueryValueKey -NtQueryVirtualMemory -NtQueryVolumeInformationFile -NtQueueApcThread -NtRaiseException -NtRaiseHardError -NtReadFile -NtReadFileScatter -NtReadRequestData -NtReadVirtualMemory -NtRegisterThreadTerminatePort -NtReleaseMutant -NtReleaseSemaphore -NtRemoveIoCompletion -NtReplaceKey -NtReplyPort -NtReplyWaitReceivePort -NtReplyWaitReplyPort -NtRequestPort -NtRequestWaitReplyPort -NtResetEvent -NtRestoreKey -NtResumeThread -NtSaveKey -NtSetIoCompletion -NtSetContextThread -NtSetDefaultHardErrorPort -NtSetDefaultLocale -NtSetEaFile -NtSetEvent -NtSetHighEventPair -NtSetHighWaitLowEventPair -NtSetInformationFile -NtSetInformationKey -NtSetInformationObject -NtSetInformationProcess -NtSetInformationThread -NtSetInformationToken -NtSetIntervalProfile -NtSetLdtEntries -NtSetLowEventPair -NtSetLowWaitHighEventPair -NtSetSecurityObject -NtSetSystemEnvironmentValue -NtSetSystemInformation -NtSetSystemPowerState -NtSetSystemTime -NtSetTimer -NtSetTimerResolution -NtSetValueKey -NtSetVolumeInformationFile -NtShutdownSystem -NtSignalAndWaitForSingleObject -NtStartProfile -NtStopProfile -NtSuspendThread -NtSystemDebugControl -NtTerminateProcess -NtTerminateThread -NtTestAlert -NtUnloadDriver -NtUnloadKey -NtUnlockFile -NtUnlockVirtualMemory -NtUnmapViewOfSection -NtVdmControl -NtWaitForMultipleObjects -NtWaitForSingleObject -NtWaitHighEventPair -NtWaitLowEventPair -NtWriteFile -NtWriteFileGather -NtWriteRequestData -NtWriteVirtualMemory -NtW32Call -NtCreateChannel -NtListenChannel -NtOpenChannel -NtReplyWaitSendChannel -NtSendWaitReplyChannel -NtSetContextChannel -NtYieldExecution -ZwAcceptConnectPort -ZwAccessCheck -ZwAccessCheckAndAuditAlarm -ZwAddAtom -ZwAdjustGroupsToken -ZwAdjustPrivilegesToken -ZwAlertResumeThread -ZwAlertThread -ZwAllocateLocallyUniqueId -ZwAllocateUuids -ZwAllocateVirtualMemory -ZwCallbackReturn -ZwCancelIoFile -ZwCancelTimer -ZwClearEvent -ZwClose -ZwCloseObjectAuditAlarm -ZwCompleteConnectPort -ZwConnectPort -ZwContinue -ZwCreateDirectoryObject -ZwCreateEvent -ZwCreateEventPair -ZwCreateFile -ZwCreateIoCompletion -ZwCreateKey -ZwCreateMailslotFile -ZwCreateMutant -ZwCreateNamedPipeFile -ZwCreatePagingFile -ZwCreatePort -ZwCreateProcess -ZwCreateProfile -ZwCreateSection -ZwCreateSemaphore -ZwCreateSymbolicLinkObject -ZwCreateThread -ZwCreateTimer -ZwCreateToken -ZwDelayExecution -ZwDeleteAtom -ZwDeleteFile -ZwDeleteKey -ZwDeleteObjectAuditAlarm -ZwDeleteValueKey -ZwDeviceIoControlFile -ZwDisplayString -ZwDuplicateObject -ZwDuplicateToken -ZwEnumerateKey -ZwEnumerateValueKey -ZwExtendSection -ZwFindAtom -ZwFlushBuffersFile -ZwFlushInstructionCache -ZwFlushKey -ZwFlushVirtualMemory -ZwFlushWriteBuffer -ZwFreeVirtualMemory -ZwFsControlFile -ZwGetContextThread -ZwGetPlugPlayEvent -ZwGetTickCount -ZwImpersonateClientOfPort -ZwImpersonateThread -ZwInitializeRegistry -ZwListenPort -ZwLoadDriver -ZwLoadKey -ZwLoadKey2 -ZwLockFile -ZwLockVirtualMemory -ZwMakeTemporaryObject -ZwMapViewOfSection -ZwNotifyChangeDirectoryFile -ZwNotifyChangeKey -ZwOpenDirectoryObject -ZwOpenEvent -ZwOpenEventPair -ZwOpenFile -ZwOpenIoCompletion -ZwOpenKey -ZwOpenMutant -ZwOpenObjectAuditAlarm -ZwOpenProcess -ZwOpenProcessToken -ZwOpenSection -ZwOpenSemaphore -ZwOpenSymbolicLinkObject -ZwOpenThread -ZwOpenThreadToken -ZwOpenTimer -ZwPlugPlayControl -ZwPrivilegeCheck -ZwPrivilegedServiceAuditAlarm -ZwPrivilegeObjectAuditAlarm -ZwProtectVirtualMemory -ZwPulseEvent -ZwQueryInformationAtom -ZwQueryAttributesFile -ZwQueryDefaultLocale -ZwQueryDirectoryFile -ZwQueryDirectoryObject -ZwQueryEaFile -ZwQueryEvent -ZwQueryFullAttributesFile -ZwQueryInformationFile -ZwQueryIoCompletion -ZwQueryInformationPort -ZwQueryInformationProcess -ZwQueryInformationThread -ZwQueryInformationToken -ZwQueryIntervalProfile -ZwQueryKey -ZwQueryMultipleValueKey -ZwQueryMutant -ZwQueryObject -ZwQueryOleDirectoryFile -ZwQueryPerformanceCounter -ZwQuerySection -ZwQuerySecurityObject -ZwQuerySemaphore -ZwQuerySymbolicLinkObject -ZwQuerySystemEnvironmentValue -ZwQuerySystemInformation -ZwQuerySystemTime -ZwQueryTimer -ZwQueryTimerResolution -ZwQueryValueKey -ZwQueryVirtualMemory -ZwQueryVolumeInformationFile -ZwQueueApcThread -ZwRaiseException -ZwRaiseHardError -ZwReadFile -ZwReadFileScatter -ZwReadRequestData -ZwReadVirtualMemory -ZwRegisterThreadTerminatePort -ZwReleaseMutant -ZwReleaseSemaphore -ZwRemoveIoCompletion -ZwReplaceKey -ZwReplyPort -ZwReplyWaitReceivePort -ZwReplyWaitReplyPort -ZwRequestPort -ZwRequestWaitReplyPort -ZwResetEvent -ZwRestoreKey -ZwResumeThread -ZwSaveKey -ZwSetIoCompletion -ZwSetContextThread -ZwSetDefaultHardErrorPort -ZwSetDefaultLocale -ZwSetEaFile -ZwSetEvent -ZwSetHighEventPair -ZwSetHighWaitLowEventPair -ZwSetInformationFile -ZwSetInformationKey -ZwSetInformationObject -ZwSetInformationProcess -ZwSetInformationThread -ZwSetInformationToken -ZwSetIntervalProfile -ZwSetLdtEntries -ZwSetLowEventPair -ZwSetLowWaitHighEventPair -ZwSetSecurityObject -ZwSetSystemEnvironmentValue -ZwSetSystemInformation -ZwSetSystemPowerState -ZwSetSystemTime -ZwSetTimer -ZwSetTimerResolution -ZwSetValueKey -ZwSetVolumeInformationFile -ZwShutdownSystem -ZwSignalAndWaitForSingleObject -ZwStartProfile -ZwStopProfile -ZwSuspendThread -ZwSystemDebugControl -ZwTerminateProcess -ZwTerminateThread -ZwTestAlert -ZwUnloadDriver -ZwUnloadKey -ZwUnlockFile -ZwUnlockVirtualMemory -ZwUnmapViewOfSection -ZwVdmControl -ZwWaitForMultipleObjects -ZwWaitForSingleObject -ZwWaitHighEventPair -ZwWaitLowEventPair -ZwWriteFile -ZwWriteFileGather -ZwWriteRequestData -ZwWriteVirtualMemory -ZwW32Call -ZwCreateChannel -ZwListenChannel -ZwOpenChannel -ZwReplyWaitSendChannel -ZwSendWaitReplyChannel -ZwSetContextChannel -ZwYieldExecution +InitializeObjectAttributes +NtAcceptConnectPort@24 +NtAccessCheck@32 +NtAccessCheckAndAuditAlarm@44 +NtAddAtom@8 +NtAdjustGroupsToken@24 +NtAdjustPrivilegesToken@24 +NtAlertResumeThread@8 +NtAlertThread@4 +NtAllocateLocallyUniqueId@4 +NtAllocateUuids@12 +NtAllocateVirtualMemory@24 +NtCallbackReturn@12 +NtCancelIoFile@8 +NtCancelTimer@8 +NtClearEvent@4 +NtClose@4 +NtCloseObjectAuditAlarm@12 +NtCompleteConnectPort@4 +NtConnectPort@32 +NtContinue@8 +NtCreateDirectoryObject@12 +NtCreateEvent@20 +NtCreateEventPair@12 +NtCreateFile@44 +NtCreateIoCompletion@16 +NtCreateKey@28 +NtCreateMailslotFile@32 +NtCreateMutant@16 +NtCreateNamedPipeFile@56 +NtCreatePagingFile@16 +NtCreatePort@20 +NtCreateProcess@32 +NtCreateProfile@36 +NtCreateSection@28 +NtCreateSemaphore@20 +NtCreateSymbolicLinkObject@16 +NtCreateThread@32 +NtCreateTimer@16 +NtCreateToken@52 +NtDelayExecution@8 +NtDeleteAtom@4 +NtDeleteFile@4 +NtDeleteKey@4 +NtDeleteObjectAuditAlarm@12 +NtDeleteValueKey@8 +NtDeviceIoControlFile@40 +NtDisplayString@4 +NtDuplicateObject@28 +NtDuplicateToken@24 +NtEnumerateKey@24 +NtEnumerateValueKey@24 +NtExtendSection@8 +NtFindAtom@8 +NtFlushBuffersFile@8 +NtFlushInstructionCache@12 +NtFlushKey@4 +NtFlushVirtualMemory@16 +NtFlushWriteBuffer@0 +NtFreeVirtualMemory@16 +NtFsControlFile@40 +NtGetContextThread@8 +NtGetPlugPlayEvent@16 +NtGetTickCount@4 +NtImpersonateClientOfPort@8 +NtImpersonateThread@12 +NtInitializeRegistry@4 +NtListenPort@8 +NtLoadDriver@4 +NtLoadKey@8 +NtLoadKey2@12 +NtLockFile@40 +NtLockVirtualMemory@16 +NtMakeTemporaryObject@4 +NtMapViewOfSection@40 +NtNotifyChangeDirectoryFile@36 +NtNotifyChangeKey@40 +NtOpenDirectoryObject@12 +NtOpenEvent@12 +NtOpenEventPair@12 +NtOpenFile@24 +NtOpenIoCompletion@12 +NtOpenKey@12 +NtOpenMutant@12 +NtOpenObjectAuditAlarm@48 +NtOpenProcess@16 +NtOpenProcessToken@12 +NtOpenSection@12 +NtOpenSemaphore@12 +NtOpenSymbolicLinkObject@12 +NtOpenThread@16 +NtOpenThreadToken@16 +NtOpenTimer@12 +NtPlugPlayControl@16 +NtPrivilegeCheck@12 +NtPrivilegedServiceAuditAlarm@20 +NtPrivilegeObjectAuditAlarm@24 +NtProtectVirtualMemory@20 +NtPulseEvent@8 +NtQueryInformationAtom@20 +NtQueryAttributesFile@8 +NtQueryDefaultLocale@8 +NtQueryDirectoryFile@44 +NtQueryDirectoryObject@28 +NtQueryEaFile@36 +NtQueryEvent@20 +NtQueryFullAttributesFile@8 +NtQueryInformationFile@20 +NtQueryIoCompletion@20 +NtQueryInformationPort@20 +NtQueryInformationProcess@20 +NtQueryInformationThread@20 +NtQueryInformationToken@20 +NtQueryIntervalProfile@8 +NtQueryKey@20 +NtQueryMultipleValueKey@24 +NtQueryMutant@20 +NtQueryObject@20 +NtQueryOleDirectoryFile@44 +NtQueryPerformanceCounter@8 +NtQuerySection@20 +NtQuerySecurityObject@20 +NtQuerySemaphore@20 +NtQuerySymbolicLinkObject@12 +NtQuerySystemEnvironmentValue@16 +NtQuerySystemInformation@16 +NtQuerySystemTime@4 +NtQueryTimer@20 +NtQueryTimerResolution@12 +NtQueryValueKey@24 +NtQueryVirtualMemory@24 +NtQueryVolumeInformationFile@20 +NtQueueApcThread@20 +NtRaiseException@12 +NtRaiseHardError@24 +NtReadFile@36 +NtReadFileScatter@36 +NtReadRequestData@24 +NtReadVirtualMemory@20 +NtRegisterThreadTerminatePort@4 +NtReleaseMutant@8 +NtReleaseSemaphore@12 +NtRemoveIoCompletion@20 +NtReplaceKey@12 +NtReplyPort@8 +NtReplyWaitReceivePort@16 +NtReplyWaitReplyPort@8 +NtRequestPort@8 +NtRequestWaitReplyPort@12 +NtResetEvent@8 +NtRestoreKey@12 +NtResumeThread@8 +NtSaveKey@8 +NtSetIoCompletion@20 +NtSetContextThread@8 +NtSetDefaultHardErrorPort@4 +NtSetDefaultLocale@8 +NtSetEaFile@16 +NtSetEvent@8 +NtSetHighEventPair@4 +NtSetHighWaitLowEventPair@4 +NtSetInformationFile@20 +NtSetInformationKey@16 +NtSetInformationObject@16 +NtSetInformationProcess@16 +NtSetInformationThread@16 +NtSetInformationToken@16 +NtSetIntervalProfile@8 +NtSetLdtEntries@24 +NtSetLowEventPair@4 +NtSetLowWaitHighEventPair@4 +NtSetSecurityObject@12 +NtSetSystemEnvironmentValue@8 +NtSetSystemInformation@12 +NtSetSystemPowerState@12 +NtSetSystemTime@8 +NtSetTimer@28 +NtSetTimerResolution@12 +NtSetValueKey@24 +NtSetVolumeInformationFile@20 +NtShutdownSystem@4 +NtSignalAndWaitForSingleObject@16 +NtStartProfile@4 +NtStopProfile@4 +NtSuspendThread@8 +NtSystemDebugControl@24 +NtTerminateProcess@8 +NtTerminateThread@8 +NtTestAlert@0 +NtUnloadDriver@4 +NtUnloadKey@4 +NtUnlockFile@20 +NtUnlockVirtualMemory@16 +NtUnmapViewOfSection@8 +NtVdmControl@8 +NtWaitForMultipleObjects@20 +NtWaitForSingleObject@12 +NtWaitHighEventPair@4 +NtWaitLowEventPair@4 +NtWriteFile@36 +NtWriteFileGather@36 +NtWriteRequestData@24 +NtWriteVirtualMemory@20 +NtW32Call@20 +NtCreateChannel@8 +NtListenChannel@8 +NtOpenChannel@8 +NtReplyWaitSendChannel@12 +NtSendWaitReplyChannel@16 +NtSetContextChannel@4 +NtYieldExecution@0 +ZwAcceptConnectPort@24 +ZwAccessCheck@32 +ZwAccessCheckAndAuditAlarm@44 +ZwAddAtom@8 +ZwAdjustGroupsToken@24 +ZwAdjustPrivilegesToken@24 +ZwAlertResumeThread@8 +ZwAlertThread@4 +ZwAllocateLocallyUniqueId@4 +ZwAllocateUuids@12 +ZwAllocateVirtualMemory@24 +ZwCallbackReturn@12 +ZwCancelIoFile@8 +ZwCancelTimer@8 +ZwClearEvent@4 +ZwClose@4 +ZwCloseObjectAuditAlarm@12 +ZwCompleteConnectPort@4 +ZwConnectPort@32 +ZwContinue@8 +ZwCreateDirectoryObject@12 +ZwCreateEvent@20 +ZwCreateEventPair@12 +ZwCreateFile@44 +ZwCreateIoCompletion@16 +ZwCreateKey@28 +ZwCreateMailslotFile@32 +ZwCreateMutant@16 +ZwCreateNamedPipeFile@56 +ZwCreatePagingFile@16 +ZwCreatePort@20 +ZwCreateProcess@32 +ZwCreateProfile@36 +ZwCreateSection@28 +ZwCreateSemaphore@20 +ZwCreateSymbolicLinkObject@16 +ZwCreateThread@32 +ZwCreateTimer@16 +ZwCreateToken@52 +ZwDelayExecution@8 +ZwDeleteAtom@4 +ZwDeleteFile@4 +ZwDeleteKey@4 +ZwDeleteObjectAuditAlarm@12 +ZwDeleteValueKey@8 +ZwDeviceIoControlFile@40 +ZwDisplayString@4 +ZwDuplicateObject@28 +ZwDuplicateToken@24 +ZwEnumerateKey@24 +ZwEnumerateValueKey@24 +ZwExtendSection@8 +ZwFindAtom@8 +ZwFlushBuffersFile@8 +ZwFlushInstructionCache@12 +ZwFlushKey@4 +ZwFlushVirtualMemory@16 +ZwFlushWriteBuffer@0 +ZwFreeVirtualMemory@16 +ZwFsControlFile@40 +ZwGetContextThread@8 +ZwGetPlugPlayEvent@16 +ZwGetTickCount@4 +ZwImpersonateClientOfPort@8 +ZwImpersonateThread@12 +ZwInitializeRegistry@4 +ZwListenPort@8 +ZwLoadDriver@4 +ZwLoadKey@8 +ZwLoadKey2@12 +ZwLockFile@40 +ZwLockVirtualMemory@16 +ZwMakeTemporaryObject@4 +ZwMapViewOfSection@40 +ZwNotifyChangeDirectoryFile@36 +ZwNotifyChangeKey@40 +ZwOpenDirectoryObject@12 +ZwOpenEvent@12 +ZwOpenEventPair@12 +ZwOpenFile@24 +ZwOpenIoCompletion@12 +ZwOpenKey@12 +ZwOpenMutant@12 +ZwOpenObjectAuditAlarm@48 +ZwOpenProcess@16 +ZwOpenProcessToken@12 +ZwOpenSection@12 +ZwOpenSemaphore@12 +ZwOpenSymbolicLinkObject@12 +ZwOpenThread@16 +ZwOpenThreadToken@16 +ZwOpenTimer@12 +ZwPlugPlayControl@16 +ZwPrivilegeCheck@12 +ZwPrivilegedServiceAuditAlarm@20 +ZwPrivilegeObjectAuditAlarm@24 +ZwProtectVirtualMemory@20 +ZwPulseEvent@8 +ZwQueryInformationAtom@20 +ZwQueryAttributesFile@8 +ZwQueryDefaultLocale@8 +ZwQueryDirectoryFile@44 +ZwQueryDirectoryObject@28 +ZwQueryEaFile@36 +ZwQueryEvent@20 +ZwQueryFullAttributesFile@8 +ZwQueryInformationFile@20 +ZwQueryIoCompletion@20 +ZwQueryInformationPort@20 +ZwQueryInformationProcess@20 +ZwQueryInformationThread@20 +ZwQueryInformationToken@20 +ZwQueryIntervalProfile@8 +ZwQueryKey@20 +ZwQueryMultipleValueKey@24 +ZwQueryMutant@20 +ZwQueryObject@20 +ZwQueryOleDirectoryFile@44 +ZwQueryPerformanceCounter@8 +ZwQuerySection@20 +ZwQuerySecurityObject@20 +ZwQuerySemaphore@20 +ZwQuerySymbolicLinkObject@12 +ZwQuerySystemEnvironmentValue@16 +ZwQuerySystemInformation@16 +ZwQuerySystemTime@4 +ZwQueryTimer@20 +ZwQueryTimerResolution@12 +ZwQueryValueKey@24 +ZwQueryVirtualMemory@24 +ZwQueryVolumeInformationFile@20 +ZwQueueApcThread@20 +ZwRaiseException@12 +ZwRaiseHardError@24 +ZwReadFile@36 +ZwReadFileScatter@36 +ZwReadRequestData@24 +ZwReadVirtualMemory@20 +ZwRegisterThreadTerminatePort@4 +ZwReleaseMutant@8 +ZwReleaseSemaphore@12 +ZwRemoveIoCompletion@20 +ZwReplaceKey@12 +ZwReplyPort@8 +ZwReplyWaitReceivePort@16 +ZwReplyWaitReplyPort@8 +ZwRequestPort@8 +ZwRequestWaitReplyPort@12 +ZwResetEvent@8 +ZwRestoreKey@12 +ZwResumeThread@8 +ZwSaveKey@8 +ZwSetIoCompletion@20 +ZwSetContextThread@8 +ZwSetDefaultHardErrorPort@4 +ZwSetDefaultLocale@8 +ZwSetEaFile@16 +ZwSetEvent@8 +ZwSetHighEventPair@4 +ZwSetHighWaitLowEventPair@4 +ZwSetInformationFile@20 +ZwSetInformationKey@16 +ZwSetInformationObject@16 +ZwSetInformationProcess@16 +ZwSetInformationThread@16 +ZwSetInformationToken@16 +ZwSetIntervalProfile@8 +ZwSetLdtEntries@24 +ZwSetLowEventPair@4 +ZwSetLowWaitHighEventPair@4 +ZwSetSecurityObject@12 +ZwSetSystemEnvironmentValue@8 +ZwSetSystemInformation@12 +ZwSetSystemPowerState@12 +ZwSetSystemTime@8 +ZwSetTimer@28 +ZwSetTimerResolution@12 +ZwSetValueKey@24 +ZwSetVolumeInformationFile@20 +ZwShutdownSystem@4 +ZwSignalAndWaitForSingleObject@16 +ZwStartProfile@4 +ZwStopProfile@4 +ZwSuspendThread@8 +ZwSystemDebugControl@24 +ZwTerminateProcess@8 +ZwTerminateThread@8 +ZwTestAlert@0 +ZwUnloadDriver@4 +ZwUnloadKey@4 +ZwUnlockFile@20 +ZwUnlockVirtualMemory@16 +ZwUnmapViewOfSection@8 +ZwVdmControl@8 +ZwWaitForMultipleObjects@20 +ZwWaitForSingleObject@12 +ZwWaitHighEventPair@4 +ZwWaitLowEventPair@4 +ZwWriteFile@36 +ZwWriteFileGather@36 +ZwWriteRequestData@24 +ZwWriteVirtualMemory@20 +ZwW32Call@20 +ZwCreateChannel@8 +ZwListenChannel@8 +ZwOpenChannel@8 +ZwReplyWaitSendChannel@12 +ZwSendWaitReplyChannel@16 +ZwSetContextChannel@4 +ZwYieldExecution@0 +RtlInitAnsiString +RtlInitUnicodeString +RtlLargeIntegerDivide +RtlLargeIntegerAdd +RtlEnlargedIntegerMultiply +RtlEnlargedUnsignedMultiply +RtlExtendedIntegerMultiply +isalpha +memcpy +memset +strcat +strcmp +stricmp +strcpy +strncpy +strlen +strrchr +toupper +wcscpy +wcschr +wcscat +wcscmp +wcsicmp +wcsnicmp +wcsncpy +wcslen +wcsrchr +vsprintf diff --git a/reactos/lib/ntdll/ldr/startup.c b/reactos/lib/ntdll/ldr/startup.c new file mode 100644 index 00000000000..8bf94e8e062 --- /dev/null +++ b/reactos/lib/ntdll/ldr/startup.c @@ -0,0 +1,380 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: lib/ntdll/ldr/startup.c + * PURPOSE: Process startup for PE executables + * PROGRAMMERS: Jean Michault + * Rex Jolliff (rex@lvcablemodem.com) + */ + +/* INCLUDES *****************************************************************/ + +#define WIN32_NO_PEHDR +#include +#include +#include +#include +#include +#include + +#define NDEBUG +#include + +VOID WINAPI __RtlInitHeap(LPVOID base, ULONG minsize, ULONG maxsize); + +/* MACROS ********************************************************************/ + +#define RVA(m, b) ((ULONG)b + m->BaseAddress) + +/* TYPEDEFS ******************************************************************/ + +typedef NTSTATUS (*PEPFUNC)(VOID); + +typedef struct _DLL +{ + PIMAGE_NT_HEADERS Headers; + PVOID BaseAddress; + struct _DLL* Prev; + struct _DLL* Next; +} DLL, *PDLL; + +/* GLOBALS *******************************************************************/ + +static DLL DllListHead; + +/* FORWARD DECLARATIONS ******************************************************/ + +static PEPFUNC LdrPEStartup(DWORD ImageBase, HANDLE SectionHandle); + +/* FUNCTIONS *****************************************************************/ + +static NTSTATUS LdrMapSections(PVOID ImageBase, HANDLE SectionHandle, + PIMAGE_NT_HEADERS NTHeaders) +{ + ULONG i; + NTSTATUS Status; + + for (i=0; iFileHeader.NumberOfSections; i++) + { + PIMAGE_SECTION_HEADER Sections; + LARGE_INTEGER Offset; + ULONG Base; + + Sections = (PIMAGE_SECTION_HEADER)SECHDROFFSET(ImageBase); + Base = Sections[i].VirtualAddress + ImageBase; + SET_LARGE_INTEGER_HIGH_PART(Offset,0); + SET_LARGE_INTEGER_LOW_PART(Offset,Sections[i].PointerToRawData); + Status = ZwMapViewOfSection(SectionHandle, + NtCurrentProcess(), + (PVOID *)&Base, + 0, + Sections[i].Misc.VirtualSize, + &Offset, + &Sections[i].Misc.VirtualSize, + 0, + MEM_COMMIT, + PAGE_READWRITE); + if (!NT_SUCCESS(Status)) + { + return Status; + } + } + return(STATUS_SUCCESS); +} + +static NTSTATUS LdrLoadDll(PDLL* Base, PCHAR Name) +{ + PIMAGE_EXPORT_DIRECTORY ExportDir; + DLL* current; + PIMAGE_OPTIONAL_HEADER OptionalHeader; + + DPRINT("LdrLoadDll(Name %s)\n",Name); + + current = &DllListHead; + do + { + OptionalHeader = ¤t->Headers->OptionalHeader; + ExportDir = (PIMAGE_EXPORT_DIRECTORY)OptionalHeader->DataDirectory[ + IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; + ExportDir = ((ULONG)ExportDir + (ULONG)current->BaseAddress); + + DPRINT("ExportDir %x\n",ExportDir); + DPRINT("Scanning %x\n",ExportDir->Name); + DPRINT("Scanning %s\n",ExportDir->Name + current->BaseAddress); + if (strcmp(ExportDir->Name + current->BaseAddress, Name) == 0) + { + *Base = current; + return(STATUS_SUCCESS); + } + + current = current->Next; + } while (current != &DllListHead); + + return(STATUS_UNSUCCESSFUL); +} + +#define HEAP_BASE (0xa0000000) + +/* LdrStartup + * FUNCTION: + * Handles Process Startup Activities. + * ARGUMENTS: + * DWORD ImageBase The base address of the process image + */ +VOID LdrStartup(HANDLE SectionHandle, DWORD ImageBase) +{ + PEPFUNC EntryPoint; + PIMAGE_DOS_HEADER PEDosHeader; + char buffer[512]; + NTSTATUS Status; + PIMAGE_NT_HEADERS NTHeaders; + + DPRINT("LdrStartup(ImageBase %x, SectionHandle %x)\n",ImageBase, + SectionHandle); + + DllListHead.BaseAddress = 0x80000000; + DllListHead.Prev = &DllListHead; + DllListHead.Next = &DllListHead; + PEDosHeader = (PIMAGE_DOS_HEADER)DllListHead.BaseAddress; + DllListHead.Headers = (PIMAGE_NT_HEADERS)(DllListHead.BaseAddress + + PEDosHeader->e_lfanew); + + /* If MZ header exists */ + PEDosHeader = (PIMAGE_DOS_HEADER) ImageBase; + if (PEDosHeader->e_magic != IMAGE_DOS_MAGIC || + PEDosHeader->e_lfanew == 0L || + *(PULONG)((PUCHAR)ImageBase + PEDosHeader->e_lfanew) != IMAGE_PE_MAGIC) + { + DPRINT("Image has bad header\n"); + ZwTerminateProcess(NULL,STATUS_UNSUCCESSFUL); + } + + NTHeaders = (PIMAGE_NT_HEADERS)(ImageBase + PEDosHeader->e_lfanew); + __RtlInitHeap(HEAP_BASE, + NTHeaders->OptionalHeader.SizeOfHeapCommit, + NTHeaders->OptionalHeader.SizeOfHeapReserve); + EntryPoint = LdrPEStartup(ImageBase, SectionHandle); + + if (EntryPoint == NULL) + { + DPRINT("Failed to initialize image\n"); + ZwTerminateProcess(NULL,STATUS_UNSUCCESSFUL); + } + + DPRINT("Transferring control to image\n"); + Status = EntryPoint(); + ZwTerminateProcess(NtCurrentProcess(),Status); +} + +static PVOID LdrGetExport(PDLL Module, PUCHAR SymbolName) +{ + PIMAGE_EXPORT_DIRECTORY ExportDir; + PDWORD* ExFunctions; + PDWORD* ExNames; + USHORT* ExOrdinals; + ULONG i; + PVOID ExName; + ULONG Ordinal; + + 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, ExportDir->AddressOfNames); + ExOrdinals = (USHORT*)RVA(Module, ExportDir->AddressOfNameOrdinals); + ExFunctions = (PDWORD*)RVA(Module, ExportDir->AddressOfFunctions); + for (i=0; iNumberOfFunctions; i++) + { + ExName = RVA(Module, ExNames[i]); + if (strcmp(ExName,SymbolName) == 0) + { + Ordinal = ExOrdinals[i]; + return(RVA(Module, ExFunctions[Ordinal])); + } + } + return(NULL); +} + +static PEPFUNC LdrPEStartup(DWORD ImageBase, HANDLE SectionHandle) +{ + int i; + PVOID SectionBase; + NTSTATUS Status; + PEPFUNC EntryPoint; + PIMAGE_DOS_HEADER DosHeader; + PIMAGE_NT_HEADERS NTHeaders; + PIMAGE_SECTION_HEADER SectionList; + char buffer[512]; + PDLL Module; + + DosHeader = (PIMAGE_DOS_HEADER) ImageBase; + NTHeaders = (PIMAGE_NT_HEADERS)(ImageBase + DosHeader->e_lfanew); + SectionList = (PIMAGE_SECTION_HEADER) (ImageBase + DosHeader->e_lfanew + + sizeof(ULONG) + sizeof(IMAGE_FILE_HEADER) + sizeof(IMAGE_OPTIONAL_HEADER)); + + /* Initialize Image sections */ + LdrMapSections(ImageBase, SectionHandle, NTHeaders); + + /* FIXME: if actual load address is different from ImageBase, then reloc */ + if (ImageBase != (DWORD) NTHeaders->OptionalHeader.ImageBase) + { + USHORT NumberOfEntries; + PUSHORT pValue16; + ULONG RelocationRVA; + ULONG Delta32, Offset; + PULONG pValue32; + PRELOCATION_DIRECTORY RelocationDir; + PRELOCATION_ENTRY RelocationBlock; + + RelocationRVA = NTHeaders->OptionalHeader.DataDirectory[ + IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress; + if (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++) + { + Offset = (RelocationBlock[i].TypeOffset & 0xfff) + + RelocationDir->VirtualAddress; + switch (RelocationBlock[i].TypeOffset >> 12) + { + case TYPE_RELOC_ABSOLUTE: + break; + + case TYPE_RELOC_HIGH: + pValue16 = (PUSHORT) (ImageBase + Offset); + *pValue16 += Delta32 >> 16; + break; + + case TYPE_RELOC_LOW: + pValue16 = (PUSHORT)(ImageBase + Offset); + *pValue16 += Delta32 & 0xffff; + break; + + case TYPE_RELOC_HIGHLOW: + pValue32 = (PULONG) (ImageBase + Offset); + *pValue32 += Delta32; + break; + + case TYPE_RELOC_HIGHADJ: + /* FIXME: do the highadjust fixup */ + DPRINT( + "TYPE_RELOC_HIGHADJ fixup not implemented, sorry\n"); + return 0; + + default: + DPRINT("unexpected fixup type\n"); + return 0; + } + } + RelocationRVA += RelocationDir->SizeOfBlock; + RelocationDir = (PRELOCATION_DIRECTORY)(ImageBase + + RelocationRVA); + } + } + } + + /* FIXME: do import fixups/load required libraries */ + /* Resolve Import Library references */ + if (NTHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT]. + VirtualAddress != 0) + { + PIMAGE_IMPORT_MODULE_DIRECTORY ImportModuleDirectory; + + /* Process each import module */ + ImportModuleDirectory = (PIMAGE_IMPORT_MODULE_DIRECTORY) + (ImageBase + NTHeaders->OptionalHeader. + DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress); + while (ImportModuleDirectory->dwRVAModuleName) + { + DWORD LibraryBase; + PIMAGE_DOS_HEADER LibDosHeader; + PIMAGE_NT_HEADERS LibNTHeaders; + PVOID *ImportAddressList; // was pImpAddr + PULONG FunctionNameList; + DWORD pName; + PWORD pHint; + + Status = LdrLoadDll(&Module, + (PCHAR)(ImageBase + + ImportModuleDirectory->dwRVAModuleName)); + if (!NT_SUCCESS(Status)) + { + return 0; + } + + /* 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); + } + else + { + FunctionNameList = (PULONG) (ImageBase + + ImportModuleDirectory->dwRVAFunctionAddressList); + } + + /* Walk through function list and fixup addresses */ + while(*FunctionNameList != 0L) + { + if ((*FunctionNameList) & 0x80000000) // hint + { +// *ImportAddressList = LibraryExports[(*FunctionNameList) & 0x7fffffff]; + DPRINT("Import by ordinal unimplemented\n"); + for(;;); + } + else // hint-name + { + pName = (DWORD)(ImageBase + *FunctionNameList + 2); + pHint = (PWORD)(ImageBase + *FunctionNameList); + + /* FIXME: verify name */ + + if (strcmp(pName,"vsprintf")==0) + { + DPRINT("Fixing up reference to %s at %x\n", + pName,ImportAddressList); + DPRINT("pHint %x\n",pHint); + } + + + + *ImportAddressList = LdrGetExport(Module,pName); + } + /* FIXME: verify value of hint */ + + ImportAddressList++; + FunctionNameList++; + } + ImportModuleDirectory++; + } + } + + /* FIXME: locate the entry point for the image */ + EntryPoint = NTHeaders->OptionalHeader.ImageBase + + NTHeaders->OptionalHeader.AddressOfEntryPoint; + + return EntryPoint; +} + + + diff --git a/reactos/lib/ntdll/main/dllmain.c b/reactos/lib/ntdll/main/dllmain.c index 955c0343095..fe4eeb0cc6d 100644 --- a/reactos/lib/ntdll/main/dllmain.c +++ b/reactos/lib/ntdll/main/dllmain.c @@ -1,9 +1,34 @@ #include +#include +#include +#include -/* FIXME: Should this function be called DllEntryPoint? */ - -BOOL WINAPI STDCALL DllMainCRTStartup(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved) +void dprintf(char* fmt,...) { - return 0; + char buffer[512]; + va_list ap; + WCHAR bufferw[512]; + UNICODE_STRING UnicodeString; + ULONG i; + + va_start(ap, fmt); + vsprintf(buffer, fmt, ap); + for (i=0; buffer[i] != 0; i++) + { + bufferw[i] = buffer[i]; + } + bufferw[i] = 0; + RtlInitUnicodeString(&UnicodeString, bufferw); + NtDisplayString(&UnicodeString); + va_end(ap); } + +BOOL WINAPI DllMainCRTStartup(HINSTANCE hinstDll, + DWORD fdwReason, + LPVOID fImpLoad) +{ + return TRUE; +} + + diff --git a/reactos/lib/ntdll/makefile b/reactos/lib/ntdll/makefile index 91fbbb75c7d..1c41cfd512f 100644 --- a/reactos/lib/ntdll/makefile +++ b/reactos/lib/ntdll/makefile @@ -1,12 +1,46 @@ -all: ntdll.a -OBJECTS = napi.o stubs/stubs.o string/wstring.o stdio/vsprintf.o \ - rtl/unicode.o rtl/namespc.o string/ctype.o string/strlen.o \ - rtl/time.o string/memcpy.o +ifneq ($(HOST),mingw32-windows) + ifneq ($(HOST),mingw32-linux) + DLLTARGET=ntdll.a + DLLMAIN= + else + DLLTARGET=ntdll.dll + DLLMAIN=main/dllmain.o + endif +else + DLLTARGET=ntdll.dll + DLLMAIN=main/dllmain.o +endif + +all: $(DLLTARGET) + +OBJECTS = napi.o ldr/startup.o rtl/largeint.o rtl/namespc.o rtl/unicode.o \ + stdio/vsprintf.o string/ctype.o string/memcpy.o string/memset.o \ + string/strcat.o string/strcmp.o string/strcpy.o string/stricmp.o \ + string/strlen.o string/strncmp.o string/strncpy.o string/strnlen.o \ + string/strrchr.o string/wstring.o stubs/stubs.o rtl/heap.o \ + rtl/critical.o rtl/mem.o ntdll.a: $(OBJECTS) - $(AR) vcsr ntdll.a $(OBJECTS) - -dummy: + $(AR) csr ntdll.a $(OBJECTS) + +ntdll.dll: $(DLLMAIN) $(OBJECTS) + $(LD) -r $(DLLMAIN) $(OBJECTS) -o ntdll.o + $(DLLTOOL) --dllname ntdll.dll --def def/ntdll.def \ + --output-lib ntdll.a + $(CC) -specs=ntdll_specs -mdll -o junk.tmp \ + -Wl,--base-file,base.tmp ntdll.o + - $(RM) junk.tmp + $(DLLTOOL) --dllname ntdll.dll --base-file base.tmp \ + --output-exp temp.exp --def def/ntdll.def + - $(RM) base.tmp + $(CC) -specs=ntdll_specs -mdll -o ntdll.dll ntdll.o \ + -Wl,--entry=_LdrStartup \ + -Wl,--image-base,0x80000000 \ + -Wl,--file-alignment,0x1000 \ + -Wl,--section-alignment,0x1000 \ + -Wl,temp.exp + - $(RM) temp.exp + $(NM) --numeric-sort ntdll.dll > ntdll.sym include ../../rules.mak diff --git a/reactos/lib/ntdll/ntdll_specs b/reactos/lib/ntdll/ntdll_specs new file mode 100644 index 00000000000..096efd6c4c1 --- /dev/null +++ b/reactos/lib/ntdll/ntdll_specs @@ -0,0 +1,78 @@ +*asm: + + +*asm_final: + + +*cpp: +-remap %(cpp_cpu) %{posix:-D_POSIX_SOURCE} + +*cc1: +%(cc1_spec) + +*cc1plus: + + +*endfile: + + +*link: +%{mwindows:--subsystem windows} %{mdll:--dll -e _DllMainCRTStartup@12} + +*lib: + + +*libgcc: +-lgcc + +*startfile: + + +*switches_need_spaces: + + +*signed_char: +%{funsigned-char:-D__CHAR_UNSIGNED__} + +*predefines: +-Di386 -D_WIN32 -DWIN32 -D__WIN32__ -D__MINGW32__ -DWINNT -D_X86_=1 -D__STDC__=1 -D__stdcall=__attribute__((__stdcall__)) _D_stdcall=__attribute__((__stdcall__)) -D__cdecl=__attribute__((__cdecl__)) -D__declspec(x)=__attribute__((x)) -Asystem(winnt) -Acpu(i386) -Amachine(i386) + +*cross_compile: +1 + +*version: +egcs-2.91.57 + +*multilib: +. ; + +*multilib_defaults: + + +*multilib_extra: + + +*multilib_matches: + + +*linker: +collect2 + +*cpp_486: +%{!ansi:-Di486} -D__i486 -D__i486__ + +*cpp_586: +%{!ansi:-Di586 -Dpentium} -D__i586 -D__i586__ -D__pentium -D__pentium__ + +*cpp_686: +%{!ansi:-Di686 -Dpentiumpro} -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ + +*cpp_cpu_default: +%(cpp_586) + +*cpp_cpu: +-Acpu(i386) -Amachine(i386) %{!ansi:-Di386} -D__i386 -D__i386__ %{mcpu=i486:%(cpp_486)} %{m486:%(cpp_486)} %{mpentium:%(cpp_586)} %{mcpu=pentium:%(cpp_586)} %{mpentiumpro:%(cpp_686)} %{mcpu=pentiumpro:%(cpp_686)} %{!mcpu*:%{!m486:%{!mpentium*:%(cpp_cpu_default)}}} + +*cc1_cpu: +%{!mcpu*: %{m386:-mcpu=i386 -march=i386} %{mno-486:-mcpu=i386 -march=i386} %{m486:-mcpu=i486 -march=i486} %{mno-386:-mcpu=i486 -march=i486} %{mno-pentium:-mcpu=i486 -march=i486} %{mpentium:-mcpu=pentium} %{mno-pentiumpro:-mcpu=pentium} %{mpentiumpro:-mcpu=pentiumpro}} + diff --git a/reactos/lib/ntdll/rtl/critical.c b/reactos/lib/ntdll/rtl/critical.c new file mode 100644 index 00000000000..2e29aa3aa42 --- /dev/null +++ b/reactos/lib/ntdll/rtl/critical.c @@ -0,0 +1,41 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * FILE: lib/kernel32/sync/critical.c + * PURPOSE: Critical regions + * UPDATE HISTORY: + * Created 30/09/98 + */ + +/* INCLUDES ******************************************************************/ + +#include + +/* FUNCTIONS *****************************************************************/ + +VOID RtlDeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection) +{ + lpCriticalSection->Reserved = -1; +} + +VOID RtlEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection) +{ +} + +VOID RtlInitializeCriticalSection(LPCRITICAL_SECTION pcritical) +{ + pcritical->LockCount = -1; + pcritical->RecursionCount = 0; + pcritical->LockSemaphore = NULL; + pcritical->OwningThread = (HANDLE)-1; + pcritical->Reserved = 0; +} + +VOID RtlLeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection) +{ +} + +WINBOOL RtlTryEntryCriticalSection(LPCRITICAL_SECTION lpCriticalSection) +{ +} + diff --git a/reactos/lib/ntdll/rtl/heap.c b/reactos/lib/ntdll/rtl/heap.c new file mode 100644 index 00000000000..715140aed41 --- /dev/null +++ b/reactos/lib/ntdll/rtl/heap.c @@ -0,0 +1,1116 @@ +/* + * kernel/heap.c + * Copyright (C) 1996, Onno Hovers, All rights reserved + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this software; see the file COPYING.LIB. If + * not, write to the Free Software Foundation, Inc., 675 Mass Ave, + * Cambridge, MA 02139, USA. + * + * Win32 heap functions (HeapXXX). + * + */ + +/* + * Adapted for the ReactOS system libraries by David Welch (welch@mcmail.com) + * Put the type definitions of the heap in a seperate header. Boudewijn Dekker + */ + +#include +#include + +//#define NDEBUG +#include + +#define HEAP_VALIDATE + +static HEAP_BUCKET __HeapDefaultBuckets[]= +{ + { NULL, 16, 18, 504 }, + { NULL, 24, 30, 1016 }, + { NULL, 32, 24, 1016 }, + { NULL, 48, 17, 1016 }, + { NULL, 64, 27, 2040 }, + { NULL, 96, 19, 2040 }, + { NULL, 128, 29, 4088 }, + { NULL, 256, 15, 4088 }, +}; + +PHEAP __ProcessHeap = NULL; + +static BOOL __HeapCommit(PHEAP pheap, LPVOID start, LPVOID end); +static BOOL __HeapDecommit(PHEAP pheap, LPVOID start, LPVOID end); +static LPVOID __HeapAlloc(PHEAP pheap, ULONG flags, ULONG size, ULONG tag); +static VOID __HeapFreeRest(PHEAP pheap, PHEAP_BLOCK pfree, ULONG allocsize, + ULONG newsize); +static LPVOID __HeapReAlloc(PHEAP pheap, ULONG flags, LPVOID pold, DWORD size); +static BOOL __HeapFree(PHEAP pheap, ULONG flags, LPVOID pmem); +static PHEAP_SUBALLOC __HeapAllocSub(PHEAP pheap, PHEAP_BUCKET pbucket); +static LPVOID __HeapAllocFragment(PHEAP pheap, ULONG flags, ULONG size); +static LPVOID __HeapReAllocFragment(PHEAP pheap, ULONG flags, + LPVOID pold, ULONG size); +static BOOL __HeapFreeFragment(PHEAP pheap, ULONG flags, LPVOID ptr); +static PHEAP __HeapPrepare(LPVOID base, ULONG minsize, ULONG maxsize, + ULONG flags); + + + +/********************************************************************* +* __HeapCommit * +* * +* commits a range of memory in the heap * +*********************************************************************/ +static BOOL __HeapCommit(PHEAP pheap, LPVOID start, LPVOID end) +{ + NTSTATUS Result; + ULONG length; + + DPRINT("__HeapCommit( 0x%lX, 0x%lX, 0x%lX)\n", + (ULONG) pheap, (ULONG) start, (ULONG) end); + + if(end >= pheap->LastBlock) + pheap->LastBlock=end; + + length = end - start; + Result = ZwAllocateVirtualMemory(NtCurrentProcess(), + &start, + 0, + &length, + MEM_COMMIT, + PAGE_READWRITE); + + return(NT_SUCCESS(Result)); +} + +/********************************************************************* +* __HeapDecommit * +* * +* decommits a range of memory in the heap * +*********************************************************************/ +static BOOL __HeapDecommit(PHEAP pheap, LPVOID start, LPVOID end) +{ + NTSTATUS Status; + ULONG size; + + DPRINT("__HeapDecommit( 0x%lX, 0x%lX, 0x%lX)\n", + (ULONG) pheap, (ULONG) start, (ULONG) end); +#ifdef NOT + __VirtualDump(); +#endif + if((end >= pheap->LastBlock)&&(start<= pheap->LastBlock)) + pheap->LastBlock=start; + + size = end - start; + Status = ZwFreeVirtualMemory(NtCurrentProcess(), + &start, + &size, + MEM_DECOMMIT); + + return(NT_SUCCESS(Status)); +} + +/********************************************************************* +* __HeapAlloc * +* * +* allocates a range of memory from the heap * +*********************************************************************/ +static LPVOID __HeapAlloc(PHEAP pheap, ULONG flags, ULONG size, ULONG tag) +{ + PHEAP_BLOCK pfree; + PHEAP_BLOCK palloc; + PHEAP_BLOCK pnext; + LPVOID commitstart; + LPVOID commitend; + ULONG freesize; + ULONG allocsize; + + DPRINT("__HeapAlloc(pheap %x, flags %x, size %d, tag %x)\n", + pheap,flags,size,tag); + + if (size <= HEAP_ADMIN_SIZE) + { + size = size + HEAP_ADMIN_SIZE; + } + + pfree=&(pheap->Start); + allocsize=SIZE_ROUND(size); + freesize=HEAP_SIZE(pfree); + /* look for a free region of memory: simple First Fit */ + while( HEAP_ISALLOC(pfree) || ( freesize=pheap->End) + return NULL; + freesize=HEAP_SIZE(pfree); + } + palloc=pfree; + + if(freesize>allocsize) + { + /* commit necessary memory */ + commitstart=(LPVOID) ROUNDDOWN((ULONG) palloc+HEAP_ADMIN_SIZE,PAGESIZE); + commitend =(LPVOID) ROUNDUP ((ULONG) palloc+ + allocsize+2*HEAP_ADMIN_SIZE, PAGESIZE); + if(commitstartSize =(freesize-allocsize-HEAP_ADMIN_SIZE) | HEAP_FREE_TAG; + pfree->PrevSize=(LPVOID)pfree-(LPVOID)palloc; + + pnext=HEAP_NEXT(pfree); + if((LPVOID) pnext < pheap->End ) + pnext->PrevSize=freesize-allocsize; + } + else + { + /* commit necessary memory */ + commitstart=(LPVOID) ROUNDDOWN((ULONG) palloc+HEAP_ADMIN_SIZE, PAGESIZE); + commitend =(LPVOID) ROUNDUP((ULONG) palloc+HEAP_ADMIN_SIZE +allocsize, + PAGESIZE); + if(commitstartSize= size | tag; + if((flags | pheap->Flags)& HEAP_ZERO_MEMORY) + FillMemory((LPVOID)palloc+HEAP_ADMIN_SIZE, allocsize, 0); + return (LPVOID)palloc+HEAP_ADMIN_SIZE; +} + +/********************************************************************* +* __HeapFreeRest * +* * +* used by realloc to free a part of the heap * +*********************************************************************/ +static VOID __HeapFreeRest(PHEAP pheap, PHEAP_BLOCK pfree, + ULONG allocsize, ULONG newsize) +{ + PHEAP_BLOCK pnext; + + if(allocsize==newsize) + { + pfree->PrevSize=allocsize+HEAP_ADMIN_SIZE; + return; + } + + pfree->Size = (allocsize-newsize-HEAP_ADMIN_SIZE) | HEAP_FREE_TAG; + pfree->PrevSize = newsize+HEAP_ADMIN_SIZE; + + pnext=HEAP_NEXT(pfree); + /* if there is a free region of memory after us, join it */ + if(((LPVOID) pnext< pheap->End)&& HEAP_ISFREE(pnext)) + { + pfree->Size = (HEAP_SIZE(pfree)+HEAP_SIZE(pnext) + HEAP_ADMIN_SIZE) | + HEAP_FREE_TAG; + + pnext->Size=0; + pnext->PrevSize=0; + } + + pnext=HEAP_NEXT(pfree); + if((LPVOID) pnext< pheap->End) + pnext->PrevSize=(LPVOID)pnext-(LPVOID)pfree; +} + +/********************************************************************* +* __HeapReAlloc * +* * +* reallocates a range of memory from the heap * +*********************************************************************/ + +static LPVOID __HeapReAlloc(PHEAP pheap, ULONG flags, LPVOID pold, DWORD size) +{ + PHEAP_BLOCK prealloc=(PHEAP_BLOCK)((LPVOID)pold-HEAP_ADMIN_SIZE); + PHEAP_BLOCK pnext; + LPVOID pmem; + LPVOID commitstart; + LPVOID commitend; + ULONG allocsize; + ULONG newsize; + ULONG oldsize; + + /* check that this is a valid allocated block */ + if(!HEAP_ISALLOC(prealloc)) + return NULL; + + allocsize = HEAP_RSIZE(prealloc); + newsize = SIZE_ROUND(size); + /* + * cases: size=0 free memory + * [ sizeprevious size try to merge + * else realloc + */ + if(size==0) + { + DPRINT("__HeapReAlloc: freeing memory\n"); + __HeapFree(pheap, flags, pold); + return NULL; + } +#ifdef NOT + else if(size < HEAP_FRAGMENT_THRESHOLD) + { + /* alloc a new fragment */ + pmem=__HeapAllocFragment(pheap, flags, size); + if(pmem) + RtlCopyMemory(pmem, pold, size); + return pmem; + } +#endif + else if(newsize < allocsize ) + { + DPRINT("__HeapReAlloc: shrinking memory\n"); + /* free remaining region of memory */ + prealloc->Size=size | HEAP_NORMAL_TAG; + pnext=HEAP_NEXT(prealloc); + __HeapFreeRest(pheap, pnext, allocsize, newsize); + + /* decommit unnecessary memory */ + commitstart=(LPVOID) ROUNDUP((ULONG) pnext+HEAP_ADMIN_SIZE ,PAGESIZE); + commitend =(LPVOID) ROUNDDOWN((ULONG) pnext+HEAP_ADMIN_SIZE+ + HEAP_SIZE(pnext), PAGESIZE); + if(commitstartSize= size | HEAP_NORMAL_TAG; + return pold; + } + else if(newsize > allocsize) + { + /* try to merge */ + pnext=HEAP_NEXT(prealloc); + + if(((LPVOID) pnext< pheap->End)&& HEAP_ISFREE(pnext) && + (HEAP_SIZE(pnext) + HEAP_ADMIN_SIZE >=newsize-allocsize)) + { + DPRINT("__HeapReAlloc: joining memory\n"); + oldsize=HEAP_SIZE(prealloc); + prealloc->Size=size | HEAP_NORMAL_TAG; + + /* commit new memory if necessary */ + commitstart=(LPVOID) ROUNDDOWN((ULONG) pnext+HEAP_ADMIN_SIZE, + PAGESIZE); + commitend =(LPVOID) ROUNDUP((ULONG) pnext+newsize-allocsize+ + HEAP_ADMIN_SIZE, PAGESIZE); + if(commitstartFlags)&HEAP_ZERO_MEMORY) + memset(pold+oldsize, 0, size-oldsize); + return pold; + } + else + { + if((flags&HEAP_REALLOC_IN_PLACE_ONLY)==0) + { + DPRINT("__HeapReAlloc: allocating new memory\n"); + /* alloc a new piece of memory */ + oldsize=HEAP_SIZE(prealloc); + pmem=__HeapAlloc(pheap, flags, size, HEAP_NORMAL_TAG); + if(pmem) + RtlCopyMemory(pmem, pold, oldsize); + if((flags|pheap->Flags)&HEAP_ZERO_MEMORY) + memset(pmem + oldsize, 0, size-oldsize); + __HeapFree(pheap, flags, pold); + return pmem; + } + else + return NULL; + } + } + return NULL; +} + +/********************************************************************* +* __HeapFree * +* * +* frees a range of memory from the heap * +*********************************************************************/ + +static BOOL __HeapFree(PHEAP pheap, ULONG flags, LPVOID ptr) +{ + PHEAP_BLOCK pfree=(PHEAP_BLOCK)((LPVOID)ptr-HEAP_ADMIN_SIZE); + PHEAP_BLOCK pprev; + PHEAP_BLOCK pnext; + LPVOID decommitstart; + LPVOID decommitend; + + /* check that this is a valid allocated block */ + if(!HEAP_ISALLOC(pfree)) + return FALSE; + + pfree->Size = HEAP_RSIZE(pfree) | HEAP_FREE_TAG; + + /* if there is a free region of memory before us, join it */ + pprev=HEAP_PREV(pfree); + pnext=HEAP_NEXT(pfree); + if((pprev!=pfree) && HEAP_ISFREE(pprev)) + { + pprev->Size = (HEAP_SIZE(pprev)+HEAP_SIZE(pfree) + HEAP_ADMIN_SIZE) | + HEAP_FREE_TAG; + if((LPVOID) pnextEnd) + pnext->PrevSize=(LPVOID)pnext-(LPVOID)pprev; + + pfree->Size=0; + pfree->PrevSize=0; + pfree=pprev; + } + /* if there is a free region of memory after us, join it */ + if(((LPVOID) pnext< pheap->End)&& HEAP_ISFREE(pnext)) + { + pfree->Size = (HEAP_SIZE(pfree)+HEAP_SIZE(pnext) + HEAP_ADMIN_SIZE) | + HEAP_FREE_TAG; + + pnext->Size=0; + pnext->PrevSize=0; + + pnext=HEAP_NEXT(pfree); + if((LPVOID) pnext< pheap->End) + pnext->PrevSize=(LPVOID)pnext-(LPVOID)pfree; + } + + /* decommit unnecessary memory */ + decommitstart=(LPVOID) ROUNDUP((ULONG) pfree+HEAP_ADMIN_SIZE ,PAGESIZE); + decommitend =(LPVOID) ROUNDDOWN((ULONG) pfree+HEAP_ADMIN_SIZE+ + HEAP_SIZE(pfree), PAGESIZE); + if(decommitstartTotalSize, + HEAP_SUB_TAG); + if(!psub) + return NULL; + + /* initialize suballoc */ + palloc=(PHEAP_FRAGMENT) ((LPVOID)psub + sizeof(HEAP_SUBALLOC)); + psub->FirstFree=palloc; + psub->NumberFree=pbucket->Number; + psub->Bitmap=0; + psub->Next=pbucket->FirstFree; + psub->Prev=NULL; + psub->Bucket=pbucket; + pbucket->FirstFree=psub; + + /* initialize free fragments */ + add=pbucket->Size+HEAP_FRAG_ADMIN_SIZE; + pprev=NULL; + for(i=0;iNumber;i++) + { + pnext=(PHEAP_FRAGMENT)((LPVOID)palloc+add); + palloc->Magic=HEAP_FRAG_MAGIC; + palloc->Number=i; + palloc->Size=pbucket->Size; + palloc->Sub=psub; + palloc->FreeNext=pnext; + palloc->FreePrev=pprev; + pprev=palloc; + palloc=pnext; + } + pprev->FreeNext=NULL; + return psub; +} + +/********************************************************************* +* __HeapAllocFragment * +* * +* allocates a small fragment of memory from the heap * +*********************************************************************/ +static LPVOID __HeapAllocFragment(PHEAP pheap, ULONG flags, ULONG size ) +{ + PHEAP_BUCKET pbucket; + PHEAP_SUBALLOC psub; + PHEAP_FRAGMENT palloc; + INT nalloc; + + DPRINT("__HeapAllocFragment(pheap %x, flags %d, size %d)\n", + pheap,flags,size); + + size = size + HEAP_FRAG_ADMIN_SIZE; + + /* get bucket size */ + pbucket=pheap->Bucket; + while(size>pbucket->Size) + { + DPRINT("pbucket->Size %d\n",pbucket->Size); + pbucket++; + } + /* get suballoc */ + psub = pbucket->FirstFree; + if(!psub) + psub = __HeapAllocSub(pheap, pbucket); + if(!psub) + return NULL; + + /* do our bookkeeping */ + palloc = psub->FirstFree; + psub->FirstFree = palloc->FreeNext; + nalloc = palloc->Number; + psub->NumberFree--; + psub->Bitmap|=(1<NumberFree) + pbucket->FirstFree=psub->Next; + + /* initialize allocated block */ + palloc->Magic=HEAP_FRAG_MAGIC; + palloc->Size=size; + + if((flags|pheap->Flags)&HEAP_ZERO_MEMORY) + memset((LPVOID)palloc+HEAP_FRAG_ADMIN_SIZE, 0, pbucket->Size); + return (LPVOID) palloc+HEAP_FRAG_ADMIN_SIZE; +} + +/********************************************************************* +* __HeapReAllocFragment * +* * +* reallocates a small fragment of memory * +*********************************************************************/ +static LPVOID __HeapReAllocFragment(PHEAP pheap, ULONG flags, + LPVOID pold, ULONG size ) +{ + PHEAP_BUCKET pbucket; + PHEAP_SUBALLOC psub; + PHEAP_FRAGMENT pfrag=(PHEAP_FRAGMENT) + ((LPVOID)pold-HEAP_FRAG_ADMIN_SIZE); + LPVOID pmem; + + /* sanity checks */ + if(pfrag->Magic!=HEAP_FRAG_MAGIC) + return NULL; + + /* get bucket size */ + psub=pfrag->Sub; + pbucket=psub->Bucket; + if(size<=pbucket->Size) + { + pfrag->Size=size; + return pold; + } + else + { + if((flags&HEAP_REALLOC_IN_PLACE_ONLY)==0) + { + /* alloc a new piece of memory */ + if(size>HEAP_FRAGMENT_THRESHOLD) + pmem=__HeapAlloc(pheap, flags, size, HEAP_NORMAL_TAG); + else + pmem=__HeapAllocFragment(pheap, flags, size); + + if(pmem) + RtlCopyMemory(pmem, pold, size); + if((flags|pheap->Flags)&HEAP_ZERO_MEMORY) + memset(pmem+pfrag->Size, 0, size-pfrag->Size); + + __HeapFreeFragment(pheap, flags, pold); + return pmem; + } + } + return NULL; +} + +/********************************************************************* +* __HeapFreeFragment * +* * +* frees a small fragment of memory * +*********************************************************************/ +static BOOL __HeapFreeFragment(PHEAP pheap, ULONG flags, LPVOID pfree ) +{ + PHEAP_BUCKET pbucket; + PHEAP_SUBALLOC psub; + PHEAP_FRAGMENT pfrag=(PHEAP_FRAGMENT) + ((DWORD)pfree - HEAP_FRAG_ADMIN_SIZE); + INT nalloc; + + /* sanity checks */ + if(pfrag->Magic!=HEAP_FRAG_MAGIC) + return FALSE; + + /* get bucket size */ + psub=pfrag->Sub; + pbucket=psub->Bucket; + + nalloc=pfrag->Number; + if((psub->Bitmap&(1<NumberFree++; + if(psub->NumberFree==pbucket->Number) + { + /* free suballoc */ + if(psub==pbucket->FirstFree) + pbucket->FirstFree=psub->Next; + if(psub->Prev) + psub->Prev->Next=psub->Next; + if(psub->Next) + psub->Next->Prev=psub->Prev; + if(!__HeapFree(pheap, flags, psub)) + return FALSE; + } + else + { + /* free fragment */ + psub->Bitmap&= ~(1<FirstFree) + { + pfrag->FreeNext = psub->FirstFree; + pfrag->FreePrev = NULL; + psub->FirstFree->FreePrev = pfrag; + psub->FirstFree = pfrag; + } + else + { + psub->FirstFree=pfrag; + pfrag->FreePrev=NULL; + pfrag->FreeNext=NULL; + } + } + + return TRUE; +} + +/********************************************************************* +* __HeapPrepare * +* * +* Fills in all the data structures of a heap * +*********************************************************************/ +PHEAP __HeapPrepare(LPVOID base, ULONG minsize, ULONG maxsize, ULONG flags) +{ + PHEAP pheap=(PHEAP) base; + + DPRINT("__HeapPrepare(base %x, minsize %d, maxsize %d, flags %x)\n", + base,minsize,maxsize,flags); + + pheap->Magic=MAGIC_HEAP; + pheap->End= ((LPVOID)pheap)+minsize; + pheap->Flags=flags; + pheap->LastBlock=(LPVOID)pheap + PAGESIZE; + RtlCopyMemory(pheap->Bucket, + __HeapDefaultBuckets, + sizeof(__HeapDefaultBuckets)); + if (__ProcessHeap) + { + pheap->NextHeap=__ProcessHeap->NextHeap; + __ProcessHeap->NextHeap=pheap; + } + else + { + pheap->NextHeap=0; + __ProcessHeap=pheap; + } + RtlInitializeCriticalSection(&(pheap->Synchronize)); + pheap->Start.Size= (minsize-sizeof(HEAP))|HEAP_FREE_TAG; + pheap->Start.PrevSize =0; + + return pheap; +} + +/********************************************************************* +* __HeapInit * +* * +* Called by __VirtualInit to initialize the default process heap * +*********************************************************************/ + +VOID WINAPI __RtlInitHeap(LPVOID base, ULONG minsize, ULONG maxsize) +{ + NTSTATUS Result; + PHEAP NewHeap; + ULONG Length; + + Result = ZwAllocateVirtualMemory(NtCurrentProcess(), + &base, + 0, + &maxsize, + MEM_RESERVE, + PAGE_READWRITE); + NewHeap = base; + + Length = PAGESIZE; + ZwAllocateVirtualMemory(NtCurrentProcess(), + (PVOID*)&NewHeap, + 0, + &Length, + MEM_COMMIT, + PAGE_READWRITE); + __HeapPrepare(NewHeap, minsize, maxsize, 0); + __ProcessHeap = NewHeap; +} + + +/********************************************************************* +* HeapCreate -- KERNEL32 * +*********************************************************************/ +HANDLE STDCALL RtlCreateHeap(ULONG Flags, + PVOID BaseAddress, + ULONG SizeToReserve, + ULONG SizeToCommit, + PVOID Unknown, + PRTL_HEAP_DEFINITION Definition) +{ + NTSTATUS Status; + + DPRINT("RtlHeapCreate( 0x%lX, 0x%lX, 0x%lX )\n", Flags, + SizeToReserve, SizeToCommit); + + Status = ZwAllocateVirtualMemory(NtCurrentProcess(), + &BaseAddress, + 0, + &SizeToReserve, + MEM_TOP_DOWN | MEM_RESERVE, + PAGE_READWRITE); + Status = ZwAllocateVirtualMemory(NtCurrentProcess(), + &BaseAddress, + 0, + &SizeToCommit, + MEM_COMMIT, + PAGE_READWRITE); + + return (HANDLE) __HeapPrepare(BaseAddress, + SizeToCommit, + SizeToReserve, + Flags); +} + +/********************************************************************* +* HeapDestroy -- KERNEL32 * +*********************************************************************/ +BOOL WINAPI RtlDestroyHeap(HANDLE hheap) +{ + PHEAP pheap=(PHEAP) hheap; + ULONG Length; + + DPRINT("RtlDestroyHeap( 0x%lX )\n", (ULONG) hheap ); + + if (pheap->Magic != MAGIC_HEAP) + return FALSE; + + RtlDeleteCriticalSection(&(pheap->Synchronize)); + + Length = 0; + ZwFreeVirtualMemory(NtCurrentProcess(), + (PVOID*)&pheap, + &Length, + MEM_RELEASE); + + return TRUE; +} + +/********************************************************************* +* HeapAlloc -- KERNEL32 * +*********************************************************************/ +PVOID STDCALL RtlAllocateHeap(HANDLE Heap, + ULONG Flags, + ULONG Size) +{ + PHEAP pheap=Heap; + LPVOID retval; + + DPRINT("HeapAlloc(hheap 0x%lX, flags 0x%lX, size 0x%lX )\n", + (ULONG) Heap, Flags, (ULONG) Size ); +#ifdef HEAP_VALIDATE + HeapValidate(Heap, 0, 0); +#endif + if(( Flags | pheap->Flags) & HEAP_NO_SERIALIZE ) + RtlEnterCriticalSection(&(pheap->Synchronize)); + + if(Size>HEAP_FRAGMENT_THRESHOLD) + retval=__HeapAlloc(pheap, Flags, Size, HEAP_NORMAL_TAG); + else + retval=__HeapAllocFragment(pheap, Flags, Size); + + if( (Flags | pheap->Flags) & HEAP_NO_SERIALIZE ) + RtlLeaveCriticalSection(&(pheap->Synchronize)); + + DPRINT("HeapAlloc returns 0x%lX\n", (ULONG) retval); + + HeapValidate(Heap, 0, 0); + return retval; + + +} + +/********************************************************************* +* HeapReAlloc -- KERNEL32 * +*********************************************************************/ +LPVOID STDCALL RtlReAllocHeap(HANDLE hheap, DWORD flags, LPVOID ptr, + DWORD size) +{ + + PHEAP pheap=hheap; + PHEAP_BLOCK pfree=((PHEAP_BLOCK)ptr-1); + LPVOID retval; + + DPRINT("HeapReAlloc( 0x%lX, 0x%lX, 0x%lX, 0x%lX )\n", + (ULONG) hheap, flags, (ULONG) ptr, size ); +#ifdef HEAP_VALIDATE + HeapValidate(hheap, 0, 0); +#endif + if(( flags | pheap->Flags) & HEAP_NO_SERIALIZE ) + RtlEnterCriticalSection(&(pheap->Synchronize)); + + if(HEAP_ISNORMAL(pfree)) + retval=__HeapReAlloc(pheap, flags, ptr, size); + else if(HEAP_ISFRAG(pfree)) + retval=__HeapReAllocFragment(pheap, flags, ptr, size); + else + retval = NULL; + + if( (flags| pheap->Flags) & HEAP_NO_SERIALIZE ) + RtlLeaveCriticalSection(&(pheap->Synchronize)); + + return retval; + + +} + +/********************************************************************* +* HeapFree -- KERNEL32 * +********************************************************************/ +BOOLEAN STDCALL RtlFreeHeap(HANDLE Heap, ULONG Flags, PVOID Address) +{ + + PHEAP pheap=Heap; + PHEAP_BLOCK pfree=(PHEAP_BLOCK)((DWORD)Address-HEAP_ADMIN_SIZE); + BOOL retval; + + DPRINT("HeapFree( 0x%lX, 0x%lX, 0x%lX )\n", + (ULONG) Heap, Flags, (ULONG) Address ); +#ifdef HEAP_VALIDATE + HeapValidate(Heap, 0, 0); +#endif + if(( Flags | pheap->Flags) & HEAP_NO_SERIALIZE ) + RtlEnterCriticalSection(&(pheap->Synchronize)); + + if(HEAP_ISNORMAL(pfree)) + { + retval = __HeapFree(pheap, Flags, Address); + } + else if(HEAP_ISFRAG(pfree)) + { + retval = __HeapFreeFragment(pheap, Flags, Address); + } + else + { + retval = FALSE; + } + + if( (Flags| pheap->Flags) & HEAP_NO_SERIALIZE ) + RtlLeaveCriticalSection(&(pheap->Synchronize)); + + return retval; + +} + +/********************************************************************* +* GetProcessHeap -- KERNEL32 * +*********************************************************************/ +HANDLE WINAPI GetProcessHeap(VOID) +{ + DPRINT("GetProcessHeap()\n"); + return (HANDLE) __ProcessHeap; +} + +/******************************************************************** +* GetProcessHeaps -- KERNEL32 * +* * +* NOTE in Win95 this function is not implemented and just returns * +* ERROR_CALL_NOT_IMPLEMENTED * +********************************************************************/ +DWORD WINAPI RtlEnumProcessHeaps(DWORD maxheaps, PHANDLE phandles ) +{ + DWORD retval; + PHEAP pheap; + + DPRINT("GetProcessHeaps( %u, 0x%lX )\n", maxheaps, (ULONG) phandles ); + + pheap= __ProcessHeap; + retval=0; + while((pheap)&&(maxheaps)) + { + *phandles=pheap; + phandles++; + maxheaps--; + retval++; + pheap=pheap->NextHeap; + } + while(pheap) + { + retval++; + pheap=pheap->NextHeap; + } + + + return retval; +} + +/********************************************************************* +* HeapLock -- KERNEL32 * +*********************************************************************/ + +BOOL WINAPI RtlLockHeap(HANDLE hheap) +{ + PHEAP pheap=hheap; + + DPRINT("HeapLock( 0x%lX )\n", (ULONG) hheap ); + + RtlEnterCriticalSection(&(pheap->Synchronize)); + return TRUE; +} + +/********************************************************************* +* HeapUnlock -- KERNEL32 * +*********************************************************************/ + +BOOL WINAPI RtlUnlockHeap(HANDLE hheap) +{ + PHEAP pheap=hheap; + + DPRINT("HeapUnlock( 0x%lX )\n", (ULONG) hheap ); + + RtlLeaveCriticalSection(&(pheap->Synchronize)); + return TRUE; +} + +/********************************************************************* +* HeapCompact -- KERNEL32 * +* * +* NT uses this function to compact moveable blocks and other things * +* Here it does not compact, but it finds the largest free region * +*********************************************************************/ + +UINT RtlCompactHeap(HANDLE hheap, DWORD flags) +{ + PHEAP pheap=hheap; + PHEAP_BLOCK pfree; + ULONG freesize; + ULONG largestfree; + + if(( flags | pheap->Flags) & HEAP_NO_SERIALIZE ) + RtlEnterCriticalSection(&(pheap->Synchronize)); + + pfree=&(pheap->Start); + /* look for the largest free region of memory */ + largestfree=0; + do + { + freesize=HEAP_SIZE(pfree); + if(HEAP_ISFREE(pfree) && freesize>largestfree) + largestfree=freesize; + + pfree=HEAP_NEXT(pfree); + } + while( (LPVOID)pfree < pheap->End ); + + if( (flags| pheap->Flags) & HEAP_NO_SERIALIZE ) + RtlLeaveCriticalSection(&(pheap->Synchronize)); + + return largestfree; +} + +/********************************************************************* +* HeapSize -- KERNEL32 * +*********************************************************************/ +DWORD WINAPI HeapSize(HANDLE hheap, DWORD flags, LPCVOID pmem) +{ + PHEAP pheap=(PHEAP) hheap; + PHEAP_BLOCK palloc=((PHEAP_BLOCK)pmem-1); + DWORD retval=0; + + DPRINT("HeapSize( 0x%lX, 0x%lX, 0x%lX )\n", + (ULONG) hheap, flags, (ULONG) pmem ); + + if (pheap->Magic != MAGIC_HEAP) + { + return 0; + } + + if(( flags | pheap->Flags) & HEAP_NO_SERIALIZE ) + RtlEnterCriticalSection(&(pheap->Synchronize)); + + if((pmem> (LPVOID)pheap)&&(pmem < pheap->End)) + { + if(HEAP_ISALLOC(palloc)) + retval=HEAP_SIZE(palloc); /* normal allocation */ + else if(HEAP_ISFRAG(palloc)) + retval=HEAP_FRAG_SIZE(palloc); /* fragment */ + else + { + retval = -1; + } + } + + if( (flags| pheap->Flags) & HEAP_NO_SERIALIZE ) + RtlLeaveCriticalSection(&(pheap->Synchronize)); + + return retval; +} + +/********************************************************************* +* HeapValidate -- KERNEL32 * +* * +* NOTE: only implemented in NT * +*********************************************************************/ +BOOL WINAPI HeapValidate(HANDLE hheap, DWORD flags, LPCVOID pmem) +{ + PHEAP pheap=(PHEAP)hheap; + PHEAP_BLOCK pcheck; + PHEAP_BLOCK pprev; + PHEAP_BLOCK pnext; + PHEAP_SUBALLOC psub; + PHEAP_FRAGMENT pfrag; + PHEAP_FRAGMENT pnextfrag; + PHEAP_FRAGMENT pprevfrag; + PHEAP_BUCKET pbucket; + INT i; + INT number; + INT add; + + if(( flags | pheap->Flags) & HEAP_NO_SERIALIZE ) + RtlEnterCriticalSection(&(pheap->Synchronize)); + + if(pmem==NULL) + { + pcheck=&(pheap->Start); + pprev=NULL; + /* verify all blocks */ + do + { + pnext=HEAP_NEXT(pcheck); + if((pprev)&&(HEAP_PREV(pcheck)!=pprev)) + { + DPRINT("HeapValidate: linked list invalid, region 0x%lX," + " previous region 0x%lX, list says 0x%lX\n", + (ULONG)pcheck, (ULONG)pprev, (ULONG) HEAP_PREV(pcheck)); + return FALSE; + } + if(HEAP_ISSUB(pcheck)) + { + + /* check fragments */ + psub=(PHEAP_SUBALLOC) ((PHEAP_BLOCK)pcheck+1); + pbucket=psub->Bucket; + pfrag=(PHEAP_FRAGMENT) ((LPVOID)psub + sizeof(HEAP_SUBALLOC)); + + if(psub->NumberFree>pbucket->Number) + return FALSE; + + add=pbucket->Size+HEAP_FRAG_ADMIN_SIZE; + pprevfrag=NULL; + number=0; + for(i=0;iNumber;i++) + { + pnextfrag=(PHEAP_FRAGMENT)((LPVOID)pfrag+add); + if(pfrag->Magic!=HEAP_FRAG_MAGIC) + { + DPRINT("HeapValidate: fragment %d magic invalid, region 0x%lX," + " previous region 0x%lX\n", i, (ULONG)pcheck, (ULONG)pprev); + return FALSE; + } + if(pfrag->Number!=i) + { + DPRINT("HeapValidate: fragment %d number invalid, region 0x%lX," + " previous region 0x%lX\n", i, (ULONG)pcheck, (ULONG)pprev); + return FALSE; + } + if((psub->Bitmap&(1<Sub!=psub) + { + DPRINT("HeapValidate: fragment %d suballoc invalid, region 0x%lX," + " previous region 0x%lX\n", i, (ULONG)pcheck, (ULONG)pprev); + return FALSE; + } + pprevfrag=pfrag; + pfrag=pnextfrag; + } + if(number!=psub->NumberFree) + { + DPRINT("HeapValidate: invalid number of free fragments, region 0x%lX," + " previous region 0x%lX\n", (ULONG)pcheck, (ULONG)pprev); + return FALSE; + } + DPRINT("HeapValidate: [0x%08lX-0x%08lX] suballocated," + " bucket size=%d, bitmap=0x%08lX\n", + (ULONG) pcheck, (ULONG) pnext, pbucket->Size, psub->Bitmap); + } + else if(HEAP_ISFREE(pcheck)) + { + if(HEAP_RSIZE(pcheck)!=HEAP_SIZE(pcheck)) + { + DPRINT("HeapValidate: invalid size of free region 0x%lX," + " previous region 0x%lX\n", + (ULONG) pcheck, (ULONG) pprev); + return FALSE; + } + DPRINT("HeapValidate: [0x%08lX-0x%08lX] free\n", + (ULONG) pcheck, (ULONG) pnext ); + } + else if(HEAP_ISNORMAL(pcheck)) + { + DPRINT("HeapValidate: [0x%08lX-0x%08lX] allocated\n", + (ULONG) pcheck, (ULONG) pnext ); + } + else + { + DPRINT("HeapValidate: invalid tag %x, region 0x%lX," + " previous region 0x%lX\n", pcheck->Size>>28, + (ULONG)pcheck, (ULONG)pprev); + return FALSE; + } + pprev=pcheck; + pcheck=HEAP_NEXT(pcheck); + } + while( (LPVOID)pcheck < pheap->End ); + } + + if( (flags| pheap->Flags) & HEAP_NO_SERIALIZE ) + RtlLeaveCriticalSection(&(pheap->Synchronize)); + + return TRUE; +} + diff --git a/reactos/lib/ntdll/rtl/largeint.c b/reactos/lib/ntdll/rtl/largeint.c new file mode 100644 index 00000000000..bae9a82ce18 --- /dev/null +++ b/reactos/lib/ntdll/rtl/largeint.c @@ -0,0 +1,277 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: lib/ntdll/rtl/largeint.c + * PURPOSE: Large integer operations + * UPDATE HISTORY: + * Created 22/05/98 + * 08/30/98 RJJ Implemented several functions + */ + +/* INCLUDES *****************************************************************/ + +#include +#include +#include + +#define NDEBUG +#include + +typedef long long int LLI, *PLLI; +typedef unsigned long long int ULLI, *PULLI; + +#define LIFromLLI(X) (*(PLARGE_INTEGER)&(X)) +#define LLIFromLI(X) (*(PLLI)&(X)) +#define ULIFromULLI(X) (*(PULARGE_INTEGER)&(X)) + +/* FUNCTIONS *****************************************************************/ + +LARGE_INTEGER RtlLargeIntegerDivide(LARGE_INTEGER Dividend, + LARGE_INTEGER Divisor, + PLARGE_INTEGER Remainder) +{ +} + +LARGE_INTEGER +RtlConvertLongToLargeInteger(LONG SignedInteger) +{ + LARGE_INTEGER RC; + + LARGE_INTEGER_QUAD_PART(RC) = SignedInteger; + + return RC; +} + +LARGE_INTEGER +RtlConvertUlongToLargeInteger(ULONG UnsignedInteger) +{ + LARGE_INTEGER RC; + + LARGE_INTEGER_QUAD_PART(RC) = UnsignedInteger; + + return RC; +} + +LARGE_INTEGER +RtlEnlargedIntegerMultiply(LONG Multiplicand, + LONG Multiplier) +{ + LARGE_INTEGER RC; + + LARGE_INTEGER_QUAD_PART(RC) = (LONGLONG) Multiplicand * Multiplier; + + return RC; +} + +LARGE_INTEGER RtlEnlargedUnsignedMultiply(ULONG Multiplicand, + ULONG Multiplier) +{ + LARGE_INTEGER RC; + + LARGE_INTEGER_QUAD_PART(RC) = (ULONGLONG) Multiplicand * Multiplier; + + return RC; +} + +LARGE_INTEGER +RtlExtendedIntegerMultiply(LARGE_INTEGER Multiplicand, + LONG Multiplier) +{ + LARGE_INTEGER RC; + + LARGE_INTEGER_QUAD_PART(RC) = LARGE_INTEGER_QUAD_PART(Multiplicand) * + Multiplier; + + return RC; +} + +LARGE_INTEGER +RtlLargeIntegerAdd(LARGE_INTEGER Addend1, + LARGE_INTEGER Addend2) +{ + LARGE_INTEGER RC; + + RC = LARGE_INTEGER_QUAD_PART(Addend1) + + LARGE_INTEGER_QUAD_PART(Addend2); + + return RC; +} + +VOID RtlLargeIntegerAnd(PLARGE_INTEGER Result, + LARGE_INTEGER Source, + LARGE_INTEGER Mask) +{ + LARGE_INTEGER_QUAD_PART(*Result) = LARGE_INTEGER_QUAD_PART(Source) & + LARGE_INTEGER_QUAD_PART(Mask); +} + +BOOLEAN +RtlLargeIntegerEqualTo(LARGE_INTEGER Operand1, + LARGE_INTEGER Operand2) +{ + return LARGE_INTEGER_QUAD_PART(Operand1) == + LARGE_INTEGER_QUAD_PART(Operand2); +#if 0 + return Operand1.HighPart == Operand2.HighPart && + Operand1.LowPart == Operand2.LowPart; +#endif +} + +BOOLEAN +RtlLargeIntegerEqualToZero(LARGE_INTEGER Operand) +{ + return LARGE_INTEGER_QUAD_PART(Operand) == 0 ; +} + +BOOLEAN +RtlLargeIntegerGreaterThan(LARGE_INTEGER Operand1, + LARGE_INTEGER Operand2) +{ + return LARGE_INTEGER_QUAD_PART(Operand1) > + LARGE_INTEGER_QUAD_PART(Operand2); +#if 0 + return Operand1.HighPart > Operand2.HighPart || + (Operand1.HighPart == Operand2.HighPart && + Operand1.LowPart > Operand2.LowPart); +#endif +} + +BOOLEAN +RtlLargeIntegerGreaterThanOrEqualTo(LARGE_INTEGER Operand1, + LARGE_INTEGER Operand2) +{ + return LARGE_INTEGER_QUAD_PART(Operand1) >= + LARGE_INTEGER_QUAD_PART(Operand2); +#if 0 + return Operand1.HighPart > Operand2.HighPart || + (Operand1.HighPart == Operand2.HighPart && + Operand1.LowPart >= Operand2.LowPart); +#endif +} + +BOOLEAN +RtlLargeIntegerGreaterThanOrEqualToZero(LARGE_INTEGER Operand1) +{ + return LARGE_INTEGER_QUAD_PART(Operand1) > 0; +#if 0 + return Operand1.HighPart >= 0; +#endif +} + +BOOLEAN +RtlLargeIntegerGreaterThanZero(LARGE_INTEGER Operand1) +{ + return LARGE_INTEGER_QUAD_PART(Operand1) >= 0; +#if 0 + return Operand1.HighPart > 0 || + (Operand1.HighPart == 0 && Operand1.LowPart > 0); +#endif +} + +BOOLEAN +RtlLargeIntegerLessThan(LARGE_INTEGER Operand1, + LARGE_INTEGER Operand2) +{ + return LARGE_INTEGER_QUAD_PART(Operand1) < + LARGE_INTEGER_QUAD_PART(Operand2); +#if 0 + return Operand1.HighPart < Operand2.HighPart || + (Operand1.HighPart == Operand2.HighPart && + Operand1.LowPart < Operand2.LowPart); +#endif +} + +BOOLEAN +RtlLargeIntegerLessThanOrEqualTo(LARGE_INTEGER Operand1, + LARGE_INTEGER Operand2) +{ + return LARGE_INTEGER_QUAD_PART(Operand1) <= + LARGE_INTEGER_QUAD_PART(Operand2); +#if 0 + return Operand1.HighPart < Operand2.HighPart || + (Operand1.HighPart == Operand2.HighPart && + Operand1.LowPart <= Operand2.LowPart); +#endif +} + +BOOLEAN +RtlLargeIntegerLessThanOrEqualToZero(LARGE_INTEGER Operand) +{ + return LARGE_INTEGER_QUAD_PART(Operand) <= 0; +#if 0 + return Operand.HighPart < 0 || + (Operand.HighPart == 0 && Operand.LowPart == 0); +#endif +} + +BOOLEAN +RtlLargeIntegerLessThanZero(LARGE_INTEGER Operand) +{ + return LARGE_INTEGER_QUAD_PART(Operand) < 0; +#if 0 + return Operand.HighPart < 0; +#endif +} + +LARGE_INTEGER RtlLargeIntegerNegate(LARGE_INTEGER Subtrahend) +{ + LARGE_INTEGER RC; + + LARGE_INTEGER_QUAD_PART(RC) = - LARGE_INTEGER_QUAD_PART(Subtrahend); + + return RC; +} + +BOOLEAN +RtlLargeIntegerNotEqualTo(LARGE_INTEGER Operand1, + LARGE_INTEGER Operand2) +{ + return LARGE_INTEGER_QUAD_PART(Operand1) != + LARGE_INTEGER_QUAD_PART(Operand2); +#if 0 + return Operand1.LowPart != Operand2.LowPart || + Operand1.HighPart != Operand2.HighPart; +#endif +} + +BOOLEAN +RtlLargeIntegerNotEqualToZero(LARGE_INTEGER Operand) +{ + return LARGE_INTEGER_QUAD_PART(Operand) != 0; +#if 0 + return Operand.LowPart != 0 || Operand.HighPart != 0; +#endif +} + +LARGE_INTEGER RtlLargeIntegerShiftLeft(LARGE_INTEGER LargeInteger, + CCHAR ShiftCount) +{ + LARGE_INTEGER RC; + + LARGE_INTEGER_QUAD_PART(RC) = LARGE_INTEGER_QUAD_PART(LargeInteger) << + ShiftCount; + + return RC; +} + +LARGE_INTEGER RtlLargeIntegerShiftRight(LARGE_INTEGER LargeInteger, + CCHAR ShiftCount) +{ + LARGE_INTEGER RC; + + LARGE_INTEGER_QUAD_PART(RC) = LARGE_INTEGER_QUAD_PART(LargeInteger) >> + ShiftCount; + + return RC; +} + +LARGE_INTEGER RtlLargeIntegerSubtract(LARGE_INTEGER Minuend, + LARGE_INTEGER Subtrahend) +{ + LARGE_INTEGER RC; + + RC = LARGE_INTEGER_QUAD_PART(Minuend) - LARGE_INTEGER_QUAD_PART(Subtrahend); + + return RC; +} + diff --git a/reactos/lib/ntdll/rtl/mem.c b/reactos/lib/ntdll/rtl/mem.c new file mode 100644 index 00000000000..7d6aab2633f --- /dev/null +++ b/reactos/lib/ntdll/rtl/mem.c @@ -0,0 +1,74 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: kernel/rtl/mem.c + * PURPOSE: Memory functions + * PROGRAMMER: David Welch (welch@mcmail.com) + * UPDATE HISTORY: + * Created 22/05/98 + */ + +/* INCLUDES *****************************************************************/ + +#include +#include +#include + +#define NDEBUG +#include + +/* FUNCTIONS *****************************************************************/ + +ULONG RtlCompareMemory(PVOID Source1, PVOID Source2, ULONG Length) +/* + * FUNCTION: Compares blocks of memory and returns the number of equal bytes + * ARGUMENTS: + * Source1 = Block to compare + * Source2 = Block to compare + * Length = Number of bytes to compare + * RETURNS: Number of equal bytes + */ +{ + int i,total; + + for (i=0,total=0;i -#include - #include -#include -#include -#include - #define NDEBUG #include @@ -31,11 +24,6 @@ PUNICODE_STRING RtlDuplicateUnicodeString(PUNICODE_STRING Dest, } } -VOID RtlUpperString(PSTRING DestinationString, PSTRING SourceString) -{ - UNIMPLEMENTED; -} - WCHAR wtoupper(WCHAR c) { if((c>='a') && (c<='z')) return c+Aa_Difference; @@ -107,7 +95,7 @@ NTSTATUS RtlAppendUnicodeStringToString(IN OUT PUNICODE_STRING Destination, NTSTATUS RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination, IN PWSTR Source) { - unsigned long i, slen=wstrlen(Source); + unsigned long i, slen=wcslen(Source); if(Destination->MaximumLength-Destination->Length-slen<0) return STATUS_BUFFER_TOO_SMALL; @@ -357,7 +345,7 @@ VOID RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString, DestinationString->MaximumLength=0; DestinationString->Buffer=NULL; } else { - DestSize=wstrlen((PWSTR)SourceString); + DestSize=wcslen((PWSTR)SourceString); DestinationString->Length=DestSize; DestinationString->MaximumLength=DestSize+1; diff --git a/reactos/lib/ntdll/stdio/vsprintf.c b/reactos/lib/ntdll/stdio/vsprintf.c index 507e35c3d8c..ba40bebe6f9 100644 --- a/reactos/lib/ntdll/stdio/vsprintf.c +++ b/reactos/lib/ntdll/stdio/vsprintf.c @@ -14,10 +14,10 @@ */ #include +#include +#include #include -#include -#include unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base) { @@ -371,7 +371,7 @@ unsigned short towupper(unsigned short w) return w; } -char iswlower(unsigned short w) +int iswlower(wint_t w) { if ( w < L'A' ) return 1; diff --git a/reactos/lib/ntdll/string/memset.c b/reactos/lib/ntdll/string/memset.c new file mode 100644 index 00000000000..a17ed3f04f3 --- /dev/null +++ b/reactos/lib/ntdll/string/memset.c @@ -0,0 +1,13 @@ +typedef int size_t; + +void * memset(void *src,int val,size_t count) +{ + char *char_src = src; + + while(count>0) { + *char_src = val; + char_src++; + count--; + } + return src; +} \ No newline at end of file diff --git a/reactos/lib/ntdll/string/strcat.c b/reactos/lib/ntdll/string/strcat.c new file mode 100644 index 00000000000..33050472650 --- /dev/null +++ b/reactos/lib/ntdll/string/strcat.c @@ -0,0 +1,12 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +char * +strcat(char *s, const char *append) +{ + char *save = s; + + for (; *s; ++s); + while ((*s++ = *append++)); + return save; +} diff --git a/reactos/lib/ntdll/string/strcmp.c b/reactos/lib/ntdll/string/strcmp.c new file mode 100644 index 00000000000..7b82a6e6d70 --- /dev/null +++ b/reactos/lib/ntdll/string/strcmp.c @@ -0,0 +1,15 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +int +strcmp(const char *s1, const char *s2) +{ + while (*s1 == *s2) + { + if (*s1 == 0) + return 0; + s1++; + s2++; + } + return *(unsigned const char *)s1 - *(unsigned const char *)(s2); +} diff --git a/reactos/lib/ntdll/string/strcpy.c b/reactos/lib/ntdll/string/strcpy.c new file mode 100644 index 00000000000..cf77c546e6a --- /dev/null +++ b/reactos/lib/ntdll/string/strcpy.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +char* strcpy(char *to, const char *from); + +char* strcpy(char *to, const char *from) +{ + char *save = to; + + for (; (*to = *from); ++from, ++to); + return save; +} diff --git a/reactos/lib/ntdll/string/stricmp.c b/reactos/lib/ntdll/string/stricmp.c new file mode 100644 index 00000000000..377414e972f --- /dev/null +++ b/reactos/lib/ntdll/string/stricmp.c @@ -0,0 +1,16 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +stricmp(const char *s1, const char *s2) +{ + while (toupper(*s1) == toupper(*s2)) + { + if (*s1 == 0) + return 0; + s1++; + s2++; + } + return toupper(*(unsigned const char *)s1) - toupper(*(unsigned const char *)(s2)); +} diff --git a/reactos/lib/ntdll/string/strncmp.c b/reactos/lib/ntdll/string/strncmp.c new file mode 100644 index 00000000000..f90eb5b2e44 --- /dev/null +++ b/reactos/lib/ntdll/string/strncmp.c @@ -0,0 +1,18 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + + +int +strncmp(const char *s1, const char *s2, size_t n) +{ + + if (n == 0) + return 0; + do { + if (*s1 != *s2++) + return *(unsigned const char *)s1 - *(unsigned const char *)--s2; + if (*s1++ == 0) + break; + } while (--n != 0); + return 0; +} diff --git a/reactos/lib/ntdll/string/strncpy.c b/reactos/lib/ntdll/string/strncpy.c new file mode 100644 index 00000000000..fdf7bd6c333 --- /dev/null +++ b/reactos/lib/ntdll/string/strncpy.c @@ -0,0 +1,21 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +char * +strncpy(char *dst, const char *src, size_t n) +{ + if (n != 0) { + char *d = dst; + const char *s = src; + + do { + if ((*d++ = *s++) == 0) + { + while (--n != 0) + *d++ = 0; + break; + } + } while (--n != 0); + } + return dst; +} diff --git a/reactos/lib/ntdll/string/strnlen.c b/reactos/lib/ntdll/string/strnlen.c new file mode 100644 index 00000000000..e71c15887e1 --- /dev/null +++ b/reactos/lib/ntdll/string/strnlen.c @@ -0,0 +1,14 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +size_t +strnlen(const char *str, size_t count) +{ + const char *s; + + if (str == 0) + return 0; + for (s = str; *s && count; ++s, count--); + return s-str; +} + diff --git a/reactos/lib/ntdll/string/strrchr.c b/reactos/lib/ntdll/string/strrchr.c new file mode 100644 index 00000000000..e6f3399494f --- /dev/null +++ b/reactos/lib/ntdll/string/strrchr.c @@ -0,0 +1,21 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +//#include + +char * +strrchr(const char *s, int c) +{ + char cc = c; + const char *sp=(char *)0; + while (*s) + { + if (*s == cc) + sp = s; + s++; + } + if (cc == 0) + sp = s; + return (char *)sp; +} + diff --git a/reactos/lib/ntdll/string/wstring.c b/reactos/lib/ntdll/string/wstring.c index a730920ef6b..bfb25066243 100644 --- a/reactos/lib/ntdll/string/wstring.c +++ b/reactos/lib/ntdll/string/wstring.c @@ -12,16 +12,21 @@ /* INCLUDES *****************************************************************/ #include -#include +#include -#include - -wchar_t * ___wcstok = NULL; +static wchar_t * ___wcstok = NULL; /* FUNCTIONS *****************************************************************/ -wchar_t * -wcscat(wchar_t *dest, const wchar_t *src) +int wcsicmp(const wchar_t* ws1, const wchar_t* ws2) +{ +} + +int wcsnicmp(const wchar_t* ws1, const wchar_t* ws2, size_t size) +{ +} + +wchar_t* wcscat(wchar_t *dest, const wchar_t *src) { int i, j; @@ -75,99 +80,8 @@ wchar_t* wcscpy(wchar_t* str1, const wchar_t* str2) return(str1); } -#if 0 -size_t -wcscspn(const wchar_t *cs, const wchar_t *ct) -{ - register wchar_t * __res; - __asm__ __volatile__( - "cld\n\t" - "movl %4,%%edi\n\t" - "repne\n\t" - "scasw\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "movl %%ecx,%%edx\n" - "1:\tlodsw\n\t" - "testw %%eax,%%eax\n\t" - "je 2f\n\t" - "movl %4,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne\n\t" - "scasw\n\t" - "jne 1b\n" - "2:\tdecl %0" - : "=S" (__res) - : "a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) - : "eax","ecx","edx","edi"); - - return __res-cs; -} - -#else - -size_t -wcscspn(const wchar_t *cs, const wchar_t *ct) -{ -UNIMPLEMENTED; -} - -#endif - -#ifdef i386 - -int -wcsicmp(const wchar_t *cs,const wchar_t *ct) -{ - register int __res; - - __asm__ __volatile__( - "cld\n" - "1:\tmovw (%%esi), %%eax\n\t" - "movw (%%edi), %%edx \n\t" - "cmpw $0x5A, %%eax\n\t" - "ja 2f\t\n" - "cmpw $0x40, %%eax\t\n" - "jbe 2f\t\n" - "addw $0x20, %%eax\t\n" - "2:\t cmpw $0x5A, %%edx\t\n" - "ja 3f\t\n" - "cmpw $0x40, %%edx\t\n" - "jbe 3f\t\n" - "addw $0x20, %%edx\t\n" - "3:\t inc %%esi\t\n" - "inc %%esi\t\n" - "inc %%edi\t\n" - "inc %%edi\t\n" - "cmpw %%eax, %%edx\t\n" - "jne 4f\n\t" - "cmpw $00, %%eax\n\t" - "jne 1b\n\t" - "xorl %%eax,%%eax\n\t" - "jmp 5f\n" - "4:\tsbbl %%eax,%%eax\n\t" - "orw $1,%%eax\n" - "5:" - : "=a" (__res) - : "S" (cs),"D" (ct) - : "esi","edi"); - - return __res; -} - -#else - -int -wcsicmp(const wchar_t *cs,const wchar_t *ct) -{ -UNIMPLEMENTED; -} - -#endif - -size_t -wcslen(const wchar_t *s) +size_t wcslen(const wchar_t *s) { unsigned int len = 0; @@ -199,43 +113,7 @@ wcsncat(wchar_t *dest, const wchar_t *src, size_t count) return dest; } -#ifdef i386 -int -wcsncmp(const wchar_t *cs, const wchar_t *ct, size_t count) -{ - register int __res; - - __asm__ __volatile__( - "cld\n" - "1:\tdecl %3\n\t" - "js 2f\n\t" - "lodsw\n\t" - "scasw\n\t" - "jne 3f\n\t" - "testw %%eax,%%eax\n\t" - "jne 1b\n" - "2:\txorl %%eax,%%eax\n\t" - "jmp 4f\n" - "3:\tsbbl %%eax,%%eax\n\t" - "orw $1,%%eax\n" - "4:" - : "=a" (__res) - : "S" (cs), "D" (ct), "c" (count) - : "esi","edi","ecx"); - - return __res; -} - -#else - -int -wcsncmp(const wchar_t *cs, const wchar_t *ct, size_t count) -{ -UNIMPLEMENTED; -} - -#endif wchar_t* wcsncpy(wchar_t *dest, const wchar_t *src, size_t count) { @@ -254,134 +132,6 @@ wchar_t* wcsncpy(wchar_t *dest, const wchar_t *src, size_t count) return dest; } -#ifdef i386 - -int -wcsnicmp(const wchar_t *cs,const wchar_t *ct, size_t count) -{ - register int __res; - - __asm__ __volatile__( - "cld\n" - "1:\t decl %3\n\t" - "js 6f\n\t" - "movw (%%esi), %%eax\n\t" - "movw (%%edi), %%edx \n\t" - "cmpw $0x5A, %%eax\n\t" - "ja 2f\t\n" - "cmpw $0x40, %%eax\t\n" - "jbe 2f\t\n" - "addw $0x20, %%eax\t\n" - "2:\t cmpw $0x5A, %%edx\t\n" - "ja 3f\t\n" - "cmpw $0x40, %%edx\t\n" - "jbe 3f\t\n" - "addw $0x20, %%edx\t\n" - "3:\t inc %%esi\t\n" - "inc %%esi\t\n" - "inc %%edi\t\n" - "inc %%edi\t\n" - "cmpw %%eax, %%edx\t\n" - "jne 4f\n\t" - "cmpw $00, %%eax\n\t" - "jne 1b\n\t" - "6:xorl %%eax,%%eax\n\t" - "jmp 5f\n" - "4:\tsbbl %%eax,%%eax\n\t" - "orw $1,%%eax\n" - "5:" - : "=a" (__res) - : "S" (cs), "D" (ct), "c" (count) - : "esi", "edi", "ecx"); - - return __res; -} - -#else - -int -wcsnicmp(const wchar_t *cs,const wchar_t *ct, size_t count) -{ -UNIMPLEMENTED; -} - -#endif - -#ifdef i386 - -size_t -wcsnlen(const wchar_t *s, size_t count) -{ - register int __res; - __asm__ __volatile__( - "movl %1,%0\n\t" - "jmp 2f\n" - "1:\tcmpw $0,(%0)\n\t" - "je 3f\n\t" - "incl %0\n" - "2:\tdecl %2\n\t" - "cmpl $-1,%2\n\t" - "jne 1b\n" - "3:\tsubl %1,%0" - : "=a" (__res) - : "c" (s), "d" (count) - : "edx"); - - return __res; -} - -#else - -size_t -wcsnlen(const wchar_t *s, size_t count) -{ -UNIMPLEMENTED; -} - -#endif - -#ifdef i386 - -wchar_t * -wcspbrk(const wchar_t *cs, const wchar_t *ct) -{ - register wchar_t * __res; - __asm__ __volatile__( - "cld\n\t" - "movl %4,%%edi\n\t" - "repne\n\t" - "scasw\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "movl %%ecx,%%edx\n" - "1:\tlodsw\n\t" - "testw %%eax,%%eax\n\t" - "je 2f\n\t" - "movl %4,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne\n\t" - "scasw\n\t" - "jne 1b\n\t" - "decl %0\n\t" - "jmp 3f\n" - "2:\txorl %0,%0\n" - "3:" - : "=S" (__res) - : "a" (0), "c" (0xffffffff), "0" (cs), "g" (ct) - : "eax", "ecx", "edx", "edi"); - - return __res; -} - -#else - -wchar_t * -wcspbrk(const wchar_t *cs, const wchar_t *ct) -{ -UNIMPLEMENTED; -} - -#endif wchar_t * wcsrchr(const wchar_t *str, wchar_t ch) @@ -403,175 +153,5 @@ wcsrchr(const wchar_t *str, wchar_t ch) return NULL; } -#ifdef i386 - -size_t -wcsspn(const wchar_t *cs, const wchar_t *ct) -{ - register wchar_t * __res; - - __asm__ __volatile__( - "cld\n\t" - "movl %4,%%edi\n\t" - "repne\n\t" - "scasw\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "movl %%ecx,%%edx\n" - "1:\tlodsw\n\t" - "testw %%eax,%%eax\n\t" - "je 2f\n\t" - "movl %4,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne\n\t" - "scasb\n\t" - "je 1b\n" - "2:\tdecl %0" - : "=S" (__res) - : "a" (0), "c" (0xffffffff), "0" (cs), "g" (ct) - : "eax", "ecx", "edx", "edi"); - - return __res-cs; -} - -#else - -size_t -wcsspn(const wchar_t *cs, const wchar_t *ct) -{ -UNIMPLEMENTED; -} - -#endif - -#ifdef i386 - -wchar_t * -wcsstr(const wchar_t *cs, const wchar_t *ct) -{ - register wchar_t * __res; - - __asm__ __volatile__( - "cld\n\t" \ - "movl %4,%%edi\n\t" - "repne\n\t" - "scasw\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */ - "movl %%ecx,%%edx\n" - "1:\tmovl %4,%%edi\n\t" - "movl %%esi,%%eax\n\t" - "movl %%edx,%%ecx\n\t" - "repe\n\t" - "cmpsw\n\t" - "je 2f\n\t" /* also works for empty string, see above */ - "xchgl %%eax,%%esi\n\t" - "incl %%esi\n\t" - "cmpw $0,-1(%%eax)\n\t" - "jne 1b\n\t" - "xorl %%eax,%%eax\n\t" - "2:" - : "=a" (__res) - : "0" (0), "c" (0xffffffff), "S" (cs), "g" (ct) - : "ecx", "edx", "edi", "esi"); - - return __res; -} - -#else - -wchar_t * -wcsstr(const wchar_t *cs, const wchar_t *ct) -{ -UNIMPLEMENTED; -} - -#endif - -size_t wstrlen(const wchar_t *s) -{ - return wcslen(s); -} - -#ifdef i386 - -wchar_t * -wcstok(wchar_t * s,const wchar_t * ct) -{ - register wchar_t * __res; - - __asm__ __volatile__( - "testl %1,%1\n\t" - "jne 1f\n\t" - "testl %0,%0\n\t" - "je 8f\n\t" - "movl %0,%1\n" - "1:\txorl %0,%0\n\t" - "movl $-1,%%ecx\n\t" - "xorl %%eax,%%eax\n\t" - "cld\n\t" - "movl %4,%%edi\n\t" - "repnz\n\t" - "scasw\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "decl %%ecx\n\t" - "je 7f\n\t" /* empty delimiter-string */ - "movl %%ecx,%%edx\n" - "2:\tlodsw\n\t" - "testw %%eax,%%eax\n\t" - "je 7f\n\t" - "movl %4,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne\n\t" - "scasw\n\t" - "je 2b\n\t" - "decl %1\n\t" - "decl %1\n\t" - "cmpw $0,(%1)\n\t" - "je 7f\n\t" - "movl %1,%0\n" - "3:\tlodsw\n\t" - "testw %%eax,%%eax\n\t" - "je 5f\n\t" - "movl %4,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne\n\t" - "scasw\n\t" - "jne 3b\n\t" - "decl %1\n\t" - "decl %1\n\t" - "decl %1\n\t" - "decl %1\n\t" - "cmpw $0,(%1)\n\t" - "je 5f\n\t" - "movw $0,(%1)\n\t" - "incl %1\n\t" - "incl %1\n\t" - "jmp 6f\n" - "5:\txorl %1,%1\n" - "6:\tcmpw $0,(%0)\n\t" - "jne 7f\n\t" - "xorl %0,%0\n" - "7:\ttestl %0,%0\n\t" - "jne 8f\n\t" - "movl %0,%1\n" - "8:" - : "=b" (__res), "=S" (___wcstok) - : "0" (___wcstok), "1" (s), "g" (ct) - : "eax", "ecx", "edx", "edi", "memory"); - - return __res; -} - -#else - -wchar_t * -wcstok(wchar_t * s,const wchar_t * ct) -{ -UNIMPLEMENTED; -} - -#endif diff --git a/reactos/lib/ntdll/stubs/stubs.c b/reactos/lib/ntdll/stubs/stubs.c index 9da649397cd..88ecfba3204 100644 --- a/reactos/lib/ntdll/stubs/stubs.c +++ b/reactos/lib/ntdll/stubs/stubs.c @@ -1,6 +1,10 @@ #include +#include -#define STUB(x) void x(void) { NtDisplayString("NTDLL: Stub for "#x"\n"); } +#define STUB(x) void x(void) { UNICODE_STRING UnicodeString; \ + RtlInitUnicodeString(&UnicodeString,\ + L"NTDLL: Stub for "#x"\n"); \ + NtDisplayString(&UnicodeString); } // ?Allocate@CBufferAllocator@@UAEPAXK@Z STUB(PropertyLengthAsVariant) @@ -22,7 +26,6 @@ STUB(CsrProbeForRead) STUB(CsrProbeForWrite) STUB(CsrSetPriorityClass) STUB(DbgBreakPoint) -STUB(DbgPrint) STUB(DbgPrompt) STUB(DbgSsHandleKmApiMsg) STUB(DbgSsInitialize) @@ -43,7 +46,6 @@ STUB(LdrFindResource_U) STUB(LdrGetDllHandle) STUB(LdrGetProcedureAddress) STUB(LdrInitializeThunk) -STUB(LdrLoadDll) STUB(LdrProcessRelocationBlock) STUB(LdrQueryImageFileExecutionOptions) STUB(LdrQueryProcessModuleInformation) @@ -60,308 +62,10 @@ STUB(PfxInitialize) STUB(PfxInsertPrefix) STUB(PfxRemovePrefix) STUB(RestoreEm87Context) -STUB(RtlAbortRXact) -STUB(RtlAbsoluteToSelfRelativeSD) -STUB(RtlAcquirePebLock) -STUB(RtlAcquireResourceExclusive) -STUB(RtlAcquireResourceShared) -STUB(RtlAddAccessAllowedAce) -STUB(RtlAddAccessDeniedAce) -STUB(RtlAddAce) -STUB(RtlAddActionToRXact) -STUB(RtlAddAtomToAtomTable) -STUB(RtlAddAttributeActionToRXact) -STUB(RtlAddAuditAccessAce) -STUB(RtlAddCompoundAce) -STUB(RtlAdjustPrivilege) -STUB(RtlAllocateAndInitializeSid) -STUB(RtlAllocateHandle) -STUB(RtlAllocateHeap) -STUB(RtlAnsiCharToUnicodeChar) -STUB(RtlAppendAsciizToString) -STUB(RtlAppendStringToString) -STUB(RtlApplyRXact) -STUB(RtlApplyRXactNoFlush) -STUB(RtlAreAllAccessesGranted) -STUB(RtlAreAnyAccessesGranted) -STUB(RtlAreBitsClear) -STUB(RtlAreBitsSet) -STUB(RtlAssert) -STUB(RtlCaptureStackBackTrace) -STUB(RtlCheckRegistryKey) -STUB(RtlClearAllBits) -STUB(RtlClearBits) -STUB(RtlClosePropertySet) -STUB(RtlCompactHeap) -STUB(RtlCompareMemory) -STUB(RtlCompareMemoryUlong) -STUB(RtlCompressBuffer) -STUB(RtlConsoleMultiByteToUnicodeN) -STUB(RtlConvertExclusiveToShared) -STUB(RtlConvertLongToLargeInteger) -STUB(RtlConvertSharedToExclusive) -STUB(RtlConvertSidToUnicodeString) -STUB(RtlConvertUiListToApiList) -STUB(RtlConvertUlongToLargeInteger) -STUB(RtlCopyLuid) -STUB(RtlCopyLuidAndAttributesArray) -STUB(RtlCopySecurityDescriptor) -STUB(RtlCopySid) -STUB(RtlCopySidAndAttributesArray) -STUB(RtlCreateAcl) -STUB(RtlCreateAndSetSD) -STUB(RtlCreateAtomTable) -STUB(RtlCreateEnvironment) -STUB(RtlCreateHeap) -STUB(RtlCreateProcessParameters) -STUB(RtlCreatePropertySet) -STUB(RtlCreateQueryDebugBuffer) -STUB(RtlCreateRegistryKey) -STUB(RtlCreateSecurityDescriptor) -STUB(RtlCreateTagHeap) -STUB(RtlCreateUnicodeString) -STUB(RtlCreateUnicodeStringFromAsciiz) -STUB(RtlCreateUserProcess) -STUB(RtlCreateUserSecurityObject) -STUB(RtlCreateUserThread) -STUB(RtlCustomCPToUnicodeN) -STUB(RtlCutoverTimeToSystemTime) -STUB(RtlDeNormalizeProcessParams) -STUB(RtlDecompressBuffer) -STUB(RtlDecompressFragment) -STUB(RtlDelete) -STUB(RtlDeleteAce) -STUB(RtlDeleteAtomFromAtomTable) -STUB(RtlDeleteCriticalSection) -STUB(RtlDeleteElementGenericTable) -STUB(RtlDeleteNoSplay) -STUB(RtlDeleteRegistryValue) -STUB(RtlDeleteResource) -STUB(RtlDeleteSecurityObject) -STUB(RtlDestroyAtomTable) -STUB(RtlDestroyEnvironment) -STUB(RtlDestroyHandleTable) -STUB(RtlDestroyHeap) -STUB(RtlDestroyProcessParameters) -STUB(RtlDestroyQueryDebugBuffer) -STUB(RtlDetermineDosPathNameType_U) -STUB(RtlDoesFileExists_U) -STUB(RtlDosPathNameToNtPathName_U) -STUB(RtlDosSearchPath_U) -STUB(RtlDowncaseUnicodeString) -STUB(RtlDumpResource) -STUB(RtlEmptyAtomTable) -STUB(RtlEnlargedIntegerMultiply) -STUB(RtlEnlargedUnsignedDivide) -STUB(RtlEnlargedUnsignedMultiply) -STUB(RtlEnterCriticalSection) -STUB(RtlEnumProcessHeaps) -STUB(RtlEnumerateGenericTable) -STUB(RtlEnumerateGenericTableWithoutSplaying) -STUB(RtlEnumerateProperties) -STUB(RtlEqualComputerName) -STUB(RtlEqualDomainName) -STUB(RtlEqualLuid) -STUB(RtlEqualPrefixSid) -STUB(RtlEqualSid) -STUB(RtlEraseUnicodeString) -STUB(RtlExpandEnvironmentStrings_U) -STUB(RtlExtendHeap) -STUB(RtlExtendedIntegerMultiply) -STUB(RtlExtendedLargeIntegerDivide) -STUB(RtlExtendedMagicDivide) -STUB(RtlFillMemory) -STUB(RtlFillMemoryUlong) -STUB(RtlFindClearBits) -STUB(RtlFindClearBitsAndSet) -STUB(RtlFindLongestRunClear) -STUB(RtlFindLongestRunSet) -STUB(RtlFindMessage) -STUB(RtlFindSetBits) -STUB(RtlFindSetBitsAndClear) -STUB(RtlFirstFreeAce) -STUB(RtlFlushPropertySet) -STUB(RtlFormatCurrentUserKeyPath) -STUB(RtlFormatMessage) -STUB(RtlFreeHandle) -STUB(RtlFreeHeap) -STUB(RtlFreeOemString) -STUB(RtlFreeSid) -STUB(RtlFreeUserThreadStack) -STUB(RtlGenerate8dot3Name) -STUB(RtlGetAce) -STUB(RtlGetCallersAddress) -STUB(RtlGetCompressionWorkSpaceSize) -STUB(RtlGetControlSecurityDescriptor) -STUB(RtlGetCurrentDirectory_U) -STUB(RtlGetDaclSecurityDescriptor) -STUB(RtlGetElementGenericTable) -STUB(RtlGetFullPathName_U) -STUB(RtlGetGroupSecurityDescriptor) -STUB(RtlGetLongestNtPathLength) -STUB(RtlGetNtGlobalFlags) -STUB(RtlGetNtProductType) -STUB(RtlGetOwnerSecurityDescriptor) -STUB(RtlGetProcessHeaps) -STUB(RtlGetSaclSecurityDescriptor) -STUB(RtlGetUserInfoHeap) -STUB(RtlGuidToPropertySetName) -STUB(RtlIdentifierAuthoritySid) -STUB(RtlImageDirectoryEntryToData) -STUB(RtlImageNtHeader) -STUB(RtlImageRvaToSection) -STUB(RtlImageRvaToVa) -STUB(RtlImpersonateSelf) -STUB(RtlInitCodePageTable) -STUB(RtlInitNlsTables) -STUB(RtlInitializeAtomPackage) -STUB(RtlInitializeBitMap) -STUB(RtlInitializeContext) -STUB(RtlInitializeCriticalSection) -STUB(RtlInitializeCriticalSectionAndSpinCount) -STUB(RtlInitializeGenericTable) -STUB(RtlInitializeHandleTable) -STUB(RtlInitializeRXact) -STUB(RtlInitializeResource) -STUB(RtlInitializeSid) -STUB(RtlInsertElementGenericTable) -STUB(RtlIntegerToChar) -STUB(RtlIsDosDeviceName_U) -STUB(RtlIsGenericTableEmpty) -STUB(RtlIsNameLegalDOS8Dot3) -STUB(RtlIsTextUnicode) -STUB(RtlIsValidHandle) -STUB(RtlIsValidIndexHandle) -STUB(RtlLargeIntegerAdd) -STUB(RtlLargeIntegerArithmeticShift) -STUB(RtlLargeIntegerDivide) -STUB(RtlLargeIntegerNegate) -STUB(RtlLargeIntegerShiftLeft) -STUB(RtlLargeIntegerShiftRight) -STUB(RtlLargeIntegerSubtract) -STUB(RtlLargeIntegerToChar) -STUB(RtlLeaveCriticalSection) -STUB(RtlLengthRequiredSid) -STUB(RtlLengthSecurityDescriptor) -STUB(RtlLengthSid) -STUB(RtlLocalTimeToSystemTime) -STUB(RtlLockHeap) -STUB(RtlLookupAtomInAtomTable) -STUB(RtlLookupElementGenericTable) -STUB(RtlMakeSelfRelativeSD) -STUB(RtlMapGenericMask) -STUB(RtlMoveMemory) -STUB(RtlMultiByteToUnicodeN) -STUB(RtlMultiByteToUnicodeSize) -STUB(RtlNewInstanceSecurityObject) -STUB(RtlNewSecurityGrantedAccess) -STUB(RtlNewSecurityObject) -STUB(RtlNormalizeProcessParams) -/*STUB(RtlNtStatusToDosError)*/ -STUB(RtlNumberGenericTableElements) -STUB(RtlNumberOfClearBits) -STUB(RtlNumberOfSetBits) -STUB(RtlOemStringToUnicodeSize) -STUB(RtlOemStringToUnicodeString) -STUB(RtlOemToUnicodeN) -STUB(RtlOnMappedStreamEvent) -STUB(RtlOpenCurrentUser) -STUB(RtlPcToFileHeader) -STUB(RtlPinAtomInAtomTable) -STUB(RtlPrefixString) -STUB(RtlPrefixUnicodeString) -STUB(RtlPropertySetNameToGuid) -STUB(RtlProtectHeap) -STUB(RtlQueryAtomInAtomTable) -STUB(RtlQueryEnvironmentVariable_U) -STUB(RtlQueryInformationAcl) -STUB(RtlQueryProcessBackTraceInformation) -STUB(RtlQueryProcessDebugInformation) -STUB(RtlQueryProcessHeapInformation) -STUB(RtlQueryProcessLockInformation) -STUB(RtlQueryProperties) -STUB(RtlQueryPropertyNames) -STUB(RtlQueryPropertySet) -STUB(RtlQueryRegistryValues) -STUB(RtlQuerySecurityObject) -STUB(RtlQueryTagHeap) -STUB(RtlQueryTimeZoneInformation) -STUB(RtlRaiseException) -STUB(RtlRaiseStatus) -STUB(RtlRandom) -STUB(RtlReAllocateHeap) -STUB(RtlRealPredecessor) -STUB(RtlRealSuccessor) -STUB(RtlReleasePebLock) -STUB(RtlReleaseResource) -STUB(RtlRemoteCall) -STUB(RtlResetRtlTranslations) -STUB(RtlRunDecodeUnicodeString) -STUB(RtlRunEncodeUnicodeString) -STUB(RtlSecondsSince1970ToTime) -STUB(RtlSecondsSince1980ToTime) -STUB(RtlSelfRelativeToAbsoluteSD) -STUB(RtlSetAllBits) -STUB(RtlSetAttributesSecurityDescriptor) -STUB(RtlSetBits) -STUB(RtlSetCriticalSectionSpinCount) -STUB(RtlSetCurrentDirectory_U) -STUB(RtlSetCurrentEnvironment) -STUB(RtlSetDaclSecurityDescriptor) -STUB(RtlSetEnvironmentVariable) -STUB(RtlSetGroupSecurityDescriptor) -STUB(RtlSetInformationAcl) -STUB(RtlSetOwnerSecurityDescriptor) -STUB(RtlSetProperties) -STUB(RtlSetPropertyNames) -STUB(RtlSetPropertySetClassId) -STUB(RtlSetSaclSecurityDescriptor) -STUB(RtlSetSecurityObject) -STUB(RtlSetTimeZoneInformation) -STUB(RtlSetUnicodeCallouts) -STUB(RtlSetUserFlagsHeap) -STUB(RtlSetUserValueHeap) -STUB(RtlSizeHeap) -STUB(RtlSplay) -STUB(RtlStartRXact) -STUB(RtlSubAuthorityCountSid) -STUB(RtlSubAuthoritySid) -STUB(RtlSubtreePredecessor) -STUB(RtlSubtreeSuccessor) -STUB(RtlSystemTimeToLocalTime) -STUB(RtlTimeToElapsedTimeFields) -STUB(RtlTimeToSecondsSince1970) -STUB(RtlTimeToSecondsSince1980) -STUB(RtlTryEnterCriticalSection) -STUB(RtlUnicodeStringToAnsiSize) -STUB(RtlUnicodeStringToCountedOemString) -STUB(RtlUnicodeStringToOemSize) -STUB(RtlUnicodeStringToOemString) -STUB(RtlUnicodeToCustomCPN) -STUB(RtlUnicodeToMultiByteN) -STUB(RtlUnicodeToMultiByteSize) -STUB(RtlUnicodeToOemN) -STUB(RtlUniform) -STUB(RtlUnlockHeap) -STUB(RtlUnwind) -STUB(RtlUpcaseUnicodeChar) -STUB(RtlUpcaseUnicodeStringToAnsiString) -STUB(RtlUpcaseUnicodeStringToCountedOemString) -STUB(RtlUpcaseUnicodeStringToOemString) -STUB(RtlUpcaseUnicodeToCustomCPN) -STUB(RtlUpcaseUnicodeToMultiByteN) -STUB(RtlUpcaseUnicodeToOemN) -STUB(RtlUpperChar) -STUB(RtlUsageHeap) -STUB(RtlValidAcl) -STUB(RtlValidSecurityDescriptor) -STUB(RtlValidSid) STUB(RtlValidateHeap) STUB(RtlValidateProcessHeaps) STUB(RtlWalkHeap) -STUB(RtlWriteRegistryValue) STUB(RtlZeroHeap) -STUB(RtlZeroMemory) STUB(RtlpNtCreateKey) STUB(RtlpNtEnumerateSubKey) STUB(RtlpNtMakeTemporaryKey) @@ -553,25 +257,19 @@ STUB(mbstowcs) STUB(memchr) STUB(memcmp) STUB(memmove) -STUB(memset) STUB(pow) STUB(qsort) STUB(sin) STUB(sqrt) STUB(sscanf) -STUB(strcat) STUB(strchr) -STUB(strcmp) -STUB(strcpy) STUB(strcspn) STUB(strncat) -STUB(strncmp) -STUB(strncpy) STUB(strpbrk) -STUB(strrchr) STUB(strspn) STUB(strstr) STUB(strtol) STUB(strtoul) STUB(swprintf) STUB(tan) + diff --git a/reactos/loaders/dos/loadros.asm b/reactos/loaders/dos/loadros.asm index bbf7b60778f..14376f84e51 100644 --- a/reactos/loaders/dos/loadros.asm +++ b/reactos/loaders/dos/loadros.asm @@ -684,7 +684,7 @@ next: ; push edx push dword 0 - jmp dword KERNEL_CS:KERNEL_BASE + jmp dword KERNEL_CS:(KERNEL_BASE+0x1000) ; diff --git a/reactos/makedisk.bat b/reactos/makedisk.bat index 53336a2998f..14a44f26666 100644 --- a/reactos/makedisk.bat +++ b/reactos/makedisk.bat @@ -2,10 +2,11 @@ echo copying latest files to a:... copy /Y bootflop.bat a:\autoexec.bat copy /Y loaders\dos\loadros.com a: -copy /Y apps\shell\shell.bin a: -copy /Y ntoskrnl\kimage.bin a: -copy /Y services\dd\blue\blues.o a: -copy /Y services\dd\keyboard\keyboard.o a: -copy /Y services\dd\ide\ide.o a: -copy /Y services\fs\vfat\vfatfsd.o a: - +copy /Y apps\shell\shell.exe a: +copy /Y ntoskrnl\ntoskrnl.exe a: +copy /Y services\dd\blue\blue.sys a: +copy /Y services\dd\keyboard\keyboard.sys a: +copy /Y services\dd\ide\ide.sys a: +copy /Y services\fs\vfat\vfatfsd.sys a: +copy /Y lib\ntdll\ntdll.dll a: +: copy /Y lib\crtdll\crtdll.dll a: diff --git a/reactos/makefile.dos b/reactos/makefile.dos index a9730eb4f23..aef28b3da84 100644 --- a/reactos/makefile.dos +++ b/reactos/makefile.dos @@ -7,15 +7,20 @@ # #HOST = djgpp-linux #HOST = mingw32-linux -HOST = djgpp-msdos -#HOST = mingw32-windows +#HOST = djgpp-msdos +HOST = mingw32-windows + +ifeq ($(HOST),mingw32-windows) +TOPDIR := /TEMP/M32/REACTOS +endif include rules.mak # # Required to run the system # -COMPONENTS = iface_native ntoskrnl kernel32 ntdll crtdll mingw32 +COMPONENTS = iface_native ntoskrnl kernel32 ntdll +# crtdll mingw32 # # Select the server(s) you want to build @@ -29,35 +34,41 @@ LOADERS = dos # # Select the device drivers and filesystems you want -# -KERNEL_SERVICES = parallel keyboard blues null mouse serial sound ide test sdisk \ +# +KERNEL_SERVICES = blue parallel keyboard null mouse serial sound ide test sdisk \ minix vfat APPS = hello shell all: $(COMPONENTS) $(LOADERS) $(KERNEL_SERVICES) $(APPS) +.PHONY: all -clean: dummy - make -C iface/native clean +clean: $(COMPONENTS:%=%_clean) $(LOADERS:%=%_clean) \ + $(KERNEL_SERVICES:%=%_clean) $(APPS:%=%_clean) +.PHONY: clean # # Applications # -hello: dummy - make -C apps/hello +$(APPS): %: + make -C apps/$* -cmd: dummy - make -C apps/cmd +$(APPS:%=%_clean): %_clean: + make -C apps/$* clean -shell: dummy - make -C apps/shell +.PHONY: $(APPS:%=%) $(APPS:%=%_clean) # # Interfaces # -iface_native: dummy +iface_native: make -C iface/native +iface_native_clean: + make -C iface/native clean + +.PHONY: iface_native iface_native_clean + # # Device driver rules # @@ -94,7 +105,7 @@ parallel: dummy keyboard: dummy make -C services/dd/keyboard -blues: dummy +blue: dummy make -C services/dd/blue mouse: dummy diff --git a/reactos/makefile_rex b/reactos/makefile_rex index 7d9fe022d9e..179c567ea4f 100644 --- a/reactos/makefile_rex +++ b/reactos/makefile_rex @@ -5,9 +5,8 @@ # # Select your host # -#HOST = djgpp-linux -#HOST = mingw32-linux -HOST = djgpp-msdos +HOST = mingw32-linux +#HOST = djgpp-msdos #HOST = mingw32-windows include rules.mak @@ -15,103 +14,128 @@ include rules.mak # # Required to run the system # -LIBRARIES = kernel32 ntdll crtdll mingw32 -COMPONENTS = iface_native ntoskrnl $(LIBRARIES) -.PHONY: $(COMPONENTS) $(COMPONENTS:%=%_clean) +COMPONENTS = iface_native ntoskrnl kernel32 ntdll # # Select the server(s) you want to build # SERVERS = win32 posix linux os2 -.PHONY: $(SERVERS) $(SERVERS:%=%_clean) # # Select the loader(s) you want to build # LOADERS = dos -.PHONY: $(LOADERS) $(LOADERS:%=%_clean) # # Select the device drivers and filesystems you want # -DD_SERVICES = blue ide keyboard mouse null parallel sdisk serial sound test -FS_SERVICES = minix vfat ext2 -KERNEL_SERVICES = $(DD_SERVICES) $(FS_SERVICES) -.PHONY: $(KERNEL_SERVICES) $(KERNEL_SERVICES:%=%_clean) +KERNEL_SERVICES = parallel keyboard blues null mouse serial sound ide test sdisk \ + minix vfat ext2 -APPS = hello shell # args -.PHONY: $(APPS:%=%) $(APPS:%=%_clean) +APPS = hello shell args all: $(COMPONENTS) $(LOADERS) $(KERNEL_SERVICES) $(APPS) -.PHONY: all -clean: $(COMPONENTS:%=%_clean) $(LOADERS:%=%_clean) \ - $(KERNEL_SERVICES:%=%_clean) $(APPS:%=%_clean) -.PHONY: clean +clean: dummy + make -C iface/native clean # # Applications # -$(APPS): %: - make -C apps/$* +hello: dummy + make -C apps/hello -$(APPS:%=%_clean): %_clean: - make -C apps/$* clean +args: dummy + make -C apps/args + +cmd: dummy + make -C apps/cmd + +shell: dummy + make -C apps/shell # # Interfaces # - -iface_native: +iface_native: dummy make -C iface/native -iface_native_clean: - make -C iface/native clean - # # Device driver rules # +vfat: dummy + make -C services/fs/vfat + +sdisk: dummy + make -C services/dd/sdisk + +minix: dummy + make -C services/fs/minix + +template: dummy + make -C services/fs/template -$(DD_SERVICES): %: - make -C services/dd/$* -$(DD_SERVICES:%=%_clean): %_clean: - make -C services/dd/$* clean +ide-test: dummy + make -C services/dd/ide-test -$(FS_SERVICES): %: - make -C services/fs/$* +ide: dummy + make -C services/dd/ide -$(FS_SERVICES:%=%_clean): %_clean: - make -C services/fs/$* clean +test: dummy + make -C services/dd/test + +test1: dummy + make -C services/dd/test1 + +null: dummy + make -C services/dd/null + +parallel: dummy + make -C services/dd/parallel + +keyboard: dummy + make -C services/dd/keyboard + +blues: dummy + make -C services/dd/blue + +mouse: dummy + make -C services/dd/mouse + +serial: dummy + make -C services/dd/serial + +sound: dummy + make -C services/dd/sound + +ext2: dummy + make -C services/fs/ext2 # # Kernel loaders # -$(LOADERS): %: - make -C loaders/$* - -$(LOADERS:%=%_clean): %_clean: - make -C loaders/$* clean - -# -# Libraries -# - -$(LIBRARIES): %: - make -C lib/$* - -$(LIBRARIES:%=%_clean): %_clean: - make -C lib/$* clean +dos: dummy + make -C loaders/dos # # Required system components # -ntoskrnl: +ntoskrnl: dummy make -C ntoskrnl -ntoskrnl_clean: - make -C ntoskrnl clean +kernel32: dummy + make -C lib/kernel32 +ntdll: dummy + make -C lib/ntdll +crtdll: dummy + make -C lib/crtdll + +mingw32: dummy + make -C lib/mingw32 + +dummy: diff --git a/reactos/ntoskrnl/.cvsignore b/reactos/ntoskrnl/.cvsignore new file mode 100644 index 00000000000..2e5d5e24473 --- /dev/null +++ b/reactos/ntoskrnl/.cvsignore @@ -0,0 +1,3 @@ +base.tmp +junk.tmp +temp.exp diff --git a/reactos/ntoskrnl/dbg/errinfo.c b/reactos/ntoskrnl/dbg/errinfo.c index 0c104c1e6eb..687fcde65d3 100644 --- a/reactos/ntoskrnl/dbg/errinfo.c +++ b/reactos/ntoskrnl/dbg/errinfo.c @@ -13,6 +13,7 @@ #include #include +#include #include #include /* for sprintf */ diff --git a/reactos/ntoskrnl/ex/napi.c b/reactos/ntoskrnl/ex/napi.c index e67471b7105..8488c834e58 100644 --- a/reactos/ntoskrnl/ex/napi.c +++ b/reactos/ntoskrnl/ex/napi.c @@ -3,13 +3,12 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/napi.c * PURPOSE: Native API support routines - * PROGRAMMER: David Welch (welch@mcmail.com) + * PROGRAMMER: David Welch (welch@cwcom.net) */ /* INCLUDES *****************************************************************/ #include -#include #include /* GLOBALS ******************************************************************/ diff --git a/reactos/ntoskrnl/exports.lst b/reactos/ntoskrnl/exports.lst index bac9ae633f1..cb083a7f994 100644 --- a/reactos/ntoskrnl/exports.lst +++ b/reactos/ntoskrnl/exports.lst @@ -103,7 +103,6 @@ HalReadDmaCounter HalSetBusData HalSetBusDataByOffset HalTranslateBusAddress -HalQueryRealTimeClock IoAcquireCancelSpinLock IoAllocateAdapterChannel IoAllocateController @@ -387,8 +386,9 @@ wcslen wcschr wcsncat wcsncpy -wtolower -wtoupper CbInitDccb CbAcquireForRead CbReleaseFromRead +wtolower +tolower +toupper diff --git a/reactos/ntoskrnl/hal/x86/bios32.c b/reactos/ntoskrnl/hal/x86/bios32.c index 49d67034129..2884744916e 100644 --- a/reactos/ntoskrnl/hal/x86/bios32.c +++ b/reactos/ntoskrnl/hal/x86/bios32.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include diff --git a/reactos/ntoskrnl/hal/x86/dma.c b/reactos/ntoskrnl/hal/x86/dma.c index e819b561b5d..0ed2afee163 100644 --- a/reactos/ntoskrnl/hal/x86/dma.c +++ b/reactos/ntoskrnl/hal/x86/dma.c @@ -37,7 +37,7 @@ static PMAP_REGISTER map_registers[]; /* FUNCTIONS *****************************************************************/ -VOID HalInitializeAdapterSupport() +VOID HalInitializeAdapterSupport(VOID) { /* ?? */ } diff --git a/reactos/ntoskrnl/hal/x86/exp.c b/reactos/ntoskrnl/hal/x86/exp.c index facbb2e6bd8..cb85c657d8e 100644 --- a/reactos/ntoskrnl/hal/x86/exp.c +++ b/reactos/ntoskrnl/hal/x86/exp.c @@ -37,6 +37,7 @@ extern void interrupt_handler2e(void); #define EXCEPTION_HANDLER_WITH_ERROR(x,y) \ void exception_handler##y (void); \ + void tmp_exception_handler##y (void) { \ __asm__("\n\t_exception_handler"##x":\n\t" \ "pushl %gs\n\t" \ "pushl %fs\n\t" \ @@ -57,10 +58,11 @@ extern void interrupt_handler2e(void); "popl %fs\n\t" \ "popl %gs\n\t" \ "addl $4,%esp\n\t" \ - "iret\n\t") + "iret\n\t"); } #define EXCEPTION_HANDLER_WITHOUT_ERROR(x,y) \ asmlinkage void exception_handler##y (void); \ + void tmp_exception_handler##y (void) { \ __asm__("\n\t_exception_handler"##x":\n\t" \ "pushl $0\n\t" \ "pushl %gs\n\t" \ @@ -82,9 +84,11 @@ extern void interrupt_handler2e(void); "popl %fs\n\t" \ "popl %gs\n\t" \ "addl $4,%esp\n\t" \ - "iret\n\t") + "iret\n\t"); } -asmlinkage void exception_handler_unknown(void); +asmlinkage void exception_handler_unknown(void); +asmlinkage void tmp_exception_handler_unknown(void) +{ __asm__("\n\t_exception_handler_unknown:\n\t" "pushl $0\n\t" "pushl %gs\n\t" @@ -103,7 +107,7 @@ asmlinkage void exception_handler_unknown(void); "popa\n\t" "addl $8,%esp\n\t" "iret\n\t"); - +} EXCEPTION_HANDLER_WITHOUT_ERROR("0",0); EXCEPTION_HANDLER_WITHOUT_ERROR("1",1); @@ -266,10 +270,16 @@ asmlinkage void exception_handler(unsigned int edi, stack=(unsigned int *)(esp0); printk("Stack:\n"); - for (i=0;i<16;i=i+4) + for (i=0; i<16; i++) { - printk("%.8x %.8x %.8x %.8x\n",stack[i],stack[i+1],stack[i+2], - stack[i+3]); + if (MmIsPagePresent(NULL,&stack[i])) + { + DbgPrint("%.8x ",stack[i]); + if (((i+1)%4) == 0) + { + DbgPrint("\n"); + } + } } } @@ -309,6 +319,7 @@ static void set_system_call_gate(unsigned int sel, unsigned int func) static void set_interrupt_gate(unsigned int sel, unsigned int func) { + DPRINT("set_interrupt_gate(sel %d, func %x)\n",sel,func); idt[sel].a = (((int)func)&0xffff) + (KERNEL_CS << 16); idt[sel].b = 0x8f00 + (((int)func)&0xffff0000); diff --git a/reactos/ntoskrnl/hal/x86/head.s b/reactos/ntoskrnl/hal/x86/head.s index b56d771532f..ef6ea17d421 100644 --- a/reactos/ntoskrnl/hal/x86/head.s +++ b/reactos/ntoskrnl/hal/x86/head.s @@ -6,7 +6,9 @@ .globl _start .globl _mainCRTStartup .globl start +/*.globl _DllMainCRTStartup@12*/ +/*_DllMainCRTStartup@12:*/ _stext: _mainCRTStartup: _start: diff --git a/reactos/ntoskrnl/hal/x86/irq.c b/reactos/ntoskrnl/hal/x86/irq.c index 7fa8ffa4cdb..9693322a544 100644 --- a/reactos/ntoskrnl/hal/x86/irq.c +++ b/reactos/ntoskrnl/hal/x86/irq.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include diff --git a/reactos/ntoskrnl/hal/x86/irql.c b/reactos/ntoskrnl/hal/x86/irql.c index 3e316f97c09..85e6a5ce0f1 100644 --- a/reactos/ntoskrnl/hal/x86/irql.c +++ b/reactos/ntoskrnl/hal/x86/irql.c @@ -3,15 +3,15 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/hal/x86/irql.c * PURPOSE: Implements IRQLs - * PROGRAMMER: David Welch (welch@mcmail.com) + * PROGRAMMER: David Welch (welch@cwcom.net) */ /* INCLUDES *****************************************************************/ -#include #include #include #include +#include #define NDEBUG #include @@ -109,7 +109,7 @@ VOID KeLowerIrql(KIRQL NewIrql) if (NewIrql > CurrentIrql) { DbgPrint("NewIrql %x CurrentIrql %x\n",NewIrql,CurrentIrql); - KeDumpStackFrames(0); + KeDumpStackFrames(0,32); for(;;); } CurrentIrql = NewIrql; diff --git a/reactos/ntoskrnl/hal/x86/page.c b/reactos/ntoskrnl/hal/x86/page.c index d9209521453..806bd14bbe3 100644 --- a/reactos/ntoskrnl/hal/x86/page.c +++ b/reactos/ntoskrnl/hal/x86/page.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -49,11 +50,12 @@ static ULONG ProtectToPTE(ULONG flProtect) return(Attributes); } -PULONG MmGetPageEntry(PEPROCESS Process, ULONG Address) +PULONG MmGetPageEntry(PEPROCESS Process, PVOID PAddress) { ULONG page_table; PULONG page_tlb; PULONG page_dir; + ULONG Address = (ULONG)PAddress; DPRINT("MmGetPageEntry(Process %x, Address %x)\n",Process,Address); @@ -63,11 +65,11 @@ PULONG MmGetPageEntry(PEPROCESS Process, ULONG Address) } else { - page_dir = get_page_directory(); + page_dir = (PULONG)get_page_directory(); } DPRINT("page_dir %x\n",page_dir); - page_tlb = (unsigned int *)physical_to_linear( + page_tlb = (PULONG)physical_to_linear( PAGE_MASK(page_dir[VADDR_TO_PD_OFFSET(Address)])); DPRINT("page_tlb %x\n",page_tlb); @@ -75,7 +77,7 @@ PULONG MmGetPageEntry(PEPROCESS Process, ULONG Address) { DPRINT("Creating new page directory\n",0); page_table = get_free_page(); // Returns a physical address - page_tlb=(unsigned int *)physical_to_linear(page_table); + page_tlb=(PULONG)physical_to_linear(page_table); memset(page_tlb,0,PAGESIZE); page_dir[VADDR_TO_PD_OFFSET(Address)]=page_table+0x7; diff --git a/reactos/ntoskrnl/hal/x86/printk.c b/reactos/ntoskrnl/hal/x86/printk.c index 380cbcd3979..6e67cafe43c 100644 --- a/reactos/ntoskrnl/hal/x86/printk.c +++ b/reactos/ntoskrnl/hal/x86/printk.c @@ -12,6 +12,7 @@ /* INCLUDES *****************************************************************/ #include +#include #include #include #include @@ -90,19 +91,6 @@ static char* vidmem = (char *)(VIDMEM_BASE + IDMAP_BASE); */ static unsigned int in_hal_console = 1; -/* - * PURPOSE: Defines the hal console video mode - */ -static unsigned char mode03[] = {0x67,0x00,0x03,0x00,0x03,0x00,0x02, - 0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf, - 0x1f,0x00,0x4f,0x0e,0x0f,0x00,0x00, - 0x00,0x00,0x9c,0x0e,0x8f,0x28,0x01, - 0x96,0xb9,0xa3,0xff,0x00,0x00,0x00, - 0x00,0x00,0x10,0x0e,0x00,0xff,0x00, - 0x00,0x01,0x02,0x03,0x04,0x05,0x06, - 0x07,0x10,0x11,0x12,0x13,0x14,0x15, - 0x16,0x17,0x0c,0x00,0x0f,0x08,0x00}; - /* FUNCTIONS ***************************************************************/ @@ -137,9 +125,8 @@ void HalSwitchToBlueScreen(void) NTSTATUS STDCALL NtDisplayString(IN PUNICODE_STRING DisplayString) { -// DbgPrint("DisplayString %x\n",DisplayString); - DbgPrint("%s",DisplayString); -// DbgPrint("Returning from NtDisplayString()\n"); +// DbgPrint("NtDisplayString(%w)\n",DisplayString->Buffer); + DbgPrint("%w",DisplayString->Buffer); return(STATUS_SUCCESS); } @@ -168,7 +155,6 @@ void __putchar(char c) * NOTE: This function handles newlines as well */ { - char* address; int offset; int i; @@ -293,10 +279,6 @@ asmlinkage void printk(const char* fmt, ...) : "m" (eflags)); } -int bad_user_access_length(void) -{ - printk("Bad user access length\n"); -} ULONG DbgPrint(PCH Format, ...) { @@ -334,6 +316,7 @@ ULONG DbgPrint(PCH Format, ...) __asm__("push %0\n\tpopf\n\t" : : "m" (eflags)); + return(strlen(buffer)); } void HalInitConsole(boot_param* bp) diff --git a/reactos/ntoskrnl/hal/x86/sources b/reactos/ntoskrnl/hal/x86/sources index 5c604eff741..2dfae103238 100644 --- a/reactos/ntoskrnl/hal/x86/sources +++ b/reactos/ntoskrnl/hal/x86/sources @@ -3,3 +3,4 @@ HAL_OBJECTS = hal/x86/head.o hal/x86/irq.o hal/x86/exp.o hal/x86/isa.o \ hal/x86/irql.o hal/x86/bios32.o hal/x86/thread.o hal/x86/spinlock.o \ hal/x86/printk.o hal/x86/mp.o hal/x86/dma.o hal/x86/bus.o hal/x86/mbr.o \ hal/x86/sysinfo.o hal/x86/time.o hal/x86/usercall.o hal/x86/beep.o + diff --git a/reactos/ntoskrnl/hal/x86/thread.c b/reactos/ntoskrnl/hal/x86/thread.c index 920f3e80928..dda07d2bdb4 100644 --- a/reactos/ntoskrnl/hal/x86/thread.c +++ b/reactos/ntoskrnl/hal/x86/thread.c @@ -3,17 +3,17 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/hal/x86/thread.c * PURPOSE: HAL multitasking functions - * PROGRAMMER: David Welch (welch@mcmail.com) + * PROGRAMMER: David Welch (welch@cwcom.net) * REVISION HISTORY: * 27/06/98: Created */ /* INCLUDES ****************************************************************/ -#include #include #include #include +#include #include #include #include @@ -164,6 +164,7 @@ NTSTATUS HalReleaseTask(PETHREAD Thread) { ExFreePool(Thread->Tcb.Context.KernelStackBase); } + return(STATUS_SUCCESS); } NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context) @@ -221,13 +222,13 @@ NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context) Thread->Tcb.Context.iomap_base = FIELD_OFFSET(hal_thread_state,io_bitmap); Thread->Tcb.Context.esp0 = (ULONG)stack_start; Thread->Tcb.Context.ss0 = KERNEL_DS; - Thread->Tcb.Context.esp = stack_start; + Thread->Tcb.Context.esp = (ULONG)stack_start; Thread->Tcb.Context.ss = KERNEL_DS; Thread->Tcb.Context.cs = KERNEL_CS; - Thread->Tcb.Context.eip = PsBeginThreadWithContextInternal; + Thread->Tcb.Context.eip = (ULONG)PsBeginThreadWithContextInternal; Thread->Tcb.Context.io_bitmap[0] = 0xff; - Thread->Tcb.Context.cr3 = - linear_to_physical(Thread->ThreadsProcess->Pcb.PageTableDirectory); + Thread->Tcb.Context.cr3 = (ULONG)MmGetPhysicalAddress( + Thread->ThreadsProcess->Pcb.PageTableDirectory); Thread->Tcb.Context.ds = KERNEL_DS; Thread->Tcb.Context.es = KERNEL_DS; Thread->Tcb.Context.fs = KERNEL_DS; @@ -285,7 +286,7 @@ BOOLEAN HalInitTask(PETHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext) */ kernel_stack[1023] = (unsigned int)StartContext; kernel_stack[1022] = (unsigned int)fn; - kernel_stack[1021] = NULL; + kernel_stack[1021] = 0; /* * Initialize the thread context @@ -294,15 +295,15 @@ BOOLEAN HalInitTask(PETHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext) thread->Tcb.Context.ldt = null_ldt_sel; thread->Tcb.Context.eflags = (1<<1)+(1<<9); thread->Tcb.Context.iomap_base = FIELD_OFFSET(hal_thread_state,io_bitmap); - thread->Tcb.Context.esp0 = &kernel_stack[1021]; + thread->Tcb.Context.esp0 = (ULONG)&kernel_stack[1021]; thread->Tcb.Context.ss0 = KERNEL_DS; - thread->Tcb.Context.esp = &kernel_stack[1021]; + thread->Tcb.Context.esp = (ULONG)&kernel_stack[1021]; thread->Tcb.Context.ss = KERNEL_DS; thread->Tcb.Context.cs = KERNEL_CS; thread->Tcb.Context.eip = (unsigned long)PsBeginThread; thread->Tcb.Context.io_bitmap[0] = 0xff; thread->Tcb.Context.cr3 = - linear_to_physical(thread->ThreadsProcess->Pcb.PageTableDirectory); + MmGetPhysicalAddress(thread->ThreadsProcess->Pcb.PageTableDirectory); thread->Tcb.Context.ds = KERNEL_DS; thread->Tcb.Context.es = KERNEL_DS; thread->Tcb.Context.fs = KERNEL_DS; diff --git a/reactos/ntoskrnl/io/cleanup.c b/reactos/ntoskrnl/io/cleanup.c index 1dfab951679..6121532aa4a 100644 --- a/reactos/ntoskrnl/io/cleanup.c +++ b/reactos/ntoskrnl/io/cleanup.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include diff --git a/reactos/ntoskrnl/io/create.c b/reactos/ntoskrnl/io/create.c index 56e736fd948..10cb2b028c9 100644 --- a/reactos/ntoskrnl/io/create.c +++ b/reactos/ntoskrnl/io/create.c @@ -10,12 +10,12 @@ /* INCLUDES ***************************************************************/ -#include +#include #include #include #include +#include #include -#include #define NDEBUG #include @@ -32,17 +32,17 @@ NTSTATUS STDCALL ZwDeleteFile(IN POBJECT_ATTRIBUTES ObjectAttributes) UNIMPLEMENTED; } -NTSTATUS NtCreateFile(PHANDLE FileHandle, - ACCESS_MASK DesiredAccess, - POBJECT_ATTRIBUTES ObjectAttributes, - PIO_STATUS_BLOCK IoStatusBlock, - PLARGE_INTEGER AllocateSize, - ULONG FileAttributes, - ULONG ShareAccess, - ULONG CreateDisposition, - ULONG CreateOptions, - PVOID EaBuffer, - ULONG EaLength) +NTSTATUS STDCALL NtCreateFile(PHANDLE FileHandle, + ACCESS_MASK DesiredAccess, + POBJECT_ATTRIBUTES ObjectAttributes, + PIO_STATUS_BLOCK IoStatusBlock, + PLARGE_INTEGER AllocateSize, + ULONG FileAttributes, + ULONG ShareAccess, + ULONG CreateDisposition, + ULONG CreateOptions, + PVOID EaBuffer, + ULONG EaLength) { return(ZwCreateFile(FileHandle, DesiredAccess, @@ -110,26 +110,27 @@ NTSTATUS IopCreateFile(PVOID ObjectBody, } DeviceObject = IoGetAttachedDevice(DeviceObject); } - RtlInitUnicodeString(&(FileObject->FileName),wstrdup(RemainingPath)); + RtlInitUnicodeString(&(FileObject->FileName),wcsdup(RemainingPath)); } DPRINT("FileObject->FileName.Buffer %w\n",FileObject->FileName.Buffer); - FileObject->DeviceObject=DeviceObject; - FileObject->Vpb=DeviceObject->Vpb; - + FileObject->DeviceObject = DeviceObject; + FileObject->Vpb = DeviceObject->Vpb; + FileObject->Type = ID_FILE_OBJECT; + return(STATUS_SUCCESS); } -NTSTATUS ZwCreateFile(PHANDLE FileHandle, - ACCESS_MASK DesiredAccess, - POBJECT_ATTRIBUTES ObjectAttributes, - PIO_STATUS_BLOCK IoStatusBlock, - PLARGE_INTEGER AllocateSize, - ULONG FileAttributes, - ULONG ShareAccess, - ULONG CreateDisposition, - ULONG CreateOptions, - PVOID EaBuffer, - ULONG EaLength) +NTSTATUS STDCALL ZwCreateFile(PHANDLE FileHandle, + ACCESS_MASK DesiredAccess, + POBJECT_ATTRIBUTES ObjectAttributes, + PIO_STATUS_BLOCK IoStatusBlock, + PLARGE_INTEGER AllocateSize, + ULONG FileAttributes, + ULONG ShareAccess, + ULONG CreateDisposition, + ULONG CreateOptions, + PVOID EaBuffer, + ULONG EaLength) /* * FUNCTION: Either causes a new file or directory to be created, or it opens * an existing file, device, directory or volume, giving the caller a handle @@ -223,12 +224,12 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle, return(Status); } -NTSTATUS NtOpenFile(PHANDLE FileHandle, - ACCESS_MASK DesiredAccess, - POBJECT_ATTRIBUTES ObjectAttributes, - PIO_STATUS_BLOCK IoStatusBlock, - ULONG ShareAccess, - ULONG OpenOptions) +NTSTATUS STDCALL NtOpenFile(PHANDLE FileHandle, + ACCESS_MASK DesiredAccess, + POBJECT_ATTRIBUTES ObjectAttributes, + PIO_STATUS_BLOCK IoStatusBlock, + ULONG ShareAccess, + ULONG OpenOptions) { return(ZwOpenFile(FileHandle, DesiredAccess, @@ -238,12 +239,12 @@ NTSTATUS NtOpenFile(PHANDLE FileHandle, OpenOptions)); } -NTSTATUS ZwOpenFile(PHANDLE FileHandle, - ACCESS_MASK DesiredAccess, - POBJECT_ATTRIBUTES ObjectAttributes, - PIO_STATUS_BLOCK IoStatusBlock, - ULONG ShareAccess, - ULONG OpenOptions) +NTSTATUS STDCALL ZwOpenFile(PHANDLE FileHandle, + ACCESS_MASK DesiredAccess, + POBJECT_ATTRIBUTES ObjectAttributes, + PIO_STATUS_BLOCK IoStatusBlock, + ULONG ShareAccess, + ULONG OpenOptions) /* * FUNCTION: Opens a file (simpler than ZwCreateFile) * ARGUMENTS: diff --git a/reactos/ntoskrnl/io/device.c b/reactos/ntoskrnl/io/device.c index 5676478566f..6e891636594 100644 --- a/reactos/ntoskrnl/io/device.c +++ b/reactos/ntoskrnl/io/device.c @@ -14,6 +14,7 @@ #include #include +#include #include #define NDEBUG @@ -122,48 +123,39 @@ NTSTATUS IopDefaultDispatchFunction(PDEVICE_OBJECT DeviceObject, return(STATUS_NOT_IMPLEMENTED); } -NTSTATUS InitializeLoadedDriver(PDRIVER_INITIALIZE entry) +NTSTATUS IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry) /* * FUNCTION: Called to initalize a loaded driver * ARGUMENTS: */ { - NTSTATUS ret; + NTSTATUS Status; PDRIVER_OBJECT DriverObject; ULONG i; - /* - * Allocate memory for a driver object - * NOTE: The object only becomes system visible once the associated - * device objects are initialized - */ - DriverObject=ExAllocatePool(NonPagedPool,sizeof(DRIVER_OBJECT)); - if (DriverObject==NULL) + DriverObject = ExAllocatePool(NonPagedPool,sizeof(DRIVER_OBJECT)); + if (DriverObject == NULL) { - DbgPrint("%s:%d\n",__FILE__,__LINE__); return STATUS_INSUFFICIENT_RESOURCES; } memset(DriverObject, 0, sizeof(DRIVER_OBJECT)); + DriverObject->Type = ID_DRIVER_OBJECT; + for (i=0; i<=IRP_MJ_MAXIMUM_FUNCTION; i++) { DriverObject->MajorFunction[i] = IopDefaultDispatchFunction; } - - /* - * Initalize the driver - * FIXME: Registry in general please - */ - DPRINT("Calling driver entrypoint at %08lx\n", entry); - if ((ret=entry(DriverObject,NULL)) != STATUS_SUCCESS) - { - DPRINT("Failed to load driver (status %x)\n",ret); - ExFreePool(DriverObject); - return ret; - } - CHECKPOINT; - return STATUS_SUCCESS; + DPRINT("Calling driver entrypoint at %08lx\n", DriverEntry); + Status = DriverEntry(DriverObject, NULL); + if (!NT_SUCCESS(Status)) + { + ExFreePool(DriverObject); + return(Status); + } + + return(Status); } NTSTATUS IoAttachDevice(PDEVICE_OBJECT SourceDevice, @@ -229,11 +221,11 @@ NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject, * NOTES: See the DDK documentation for more information */ { - PDEVICE_OBJECT dev; - OBJECT_ATTRIBUTES dev_attr; - HANDLE devh; + PDEVICE_OBJECT CreatedDeviceObject; + OBJECT_ATTRIBUTES ObjectAttributes; + HANDLE DeviceHandle; - if (DeviceName!=NULL) + if (DeviceName != NULL) { DPRINT("IoCreateDevice(DriverObject %x, DeviceName %w)\n",DriverObject, DeviceName->Buffer); @@ -243,61 +235,65 @@ NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject, DPRINT("IoCreateDevice(DriverObject %x)\n",DriverObject); } - if (DeviceName!=NULL) + if (DeviceName != NULL) { - InitializeObjectAttributes(&dev_attr,DeviceName,0,NULL,NULL); - dev = ObCreateObject(&devh,0,&dev_attr,IoDeviceType); + InitializeObjectAttributes(&ObjectAttributes,DeviceName,0,NULL,NULL); + CreatedDeviceObject = ObCreateObject(&DeviceHandle, + 0, + &ObjectAttributes, + IoDeviceType); } else { - dev = ObCreateObject(&devh,0,NULL,IoDeviceType); + CreatedDeviceObject = ObCreateObject(&DeviceHandle, + 0, + NULL, + IoDeviceType); } *DeviceObject=NULL; - if (dev==NULL) + if (CreatedDeviceObject == NULL) { return(STATUS_INSUFFICIENT_RESOURCES); } - - if (DriverObject->DeviceObject==NULL) + + if (DriverObject->DeviceObject == NULL) { - DriverObject->DeviceObject = dev; - dev->NextDevice=NULL; + DriverObject->DeviceObject = CreatedDeviceObject; + CreatedDeviceObject->NextDevice = NULL; } else { - dev->NextDevice=DriverObject->DeviceObject; - DriverObject->DeviceObject=dev; + CreatedDeviceObject->NextDevice = DriverObject->DeviceObject; + DriverObject->DeviceObject = CreatedDeviceObject; } - dev->DriverObject = DriverObject; - DPRINT("dev %x\n",dev); - DPRINT("dev->DriverObject %x\n",dev->DriverObject); - - dev->CurrentIrp=NULL; - dev->Flags=0; + CreatedDeviceObject->Type = ID_DEVICE_OBJECT; + CreatedDeviceObject->DriverObject = DriverObject; + CreatedDeviceObject->CurrentIrp = NULL; + CreatedDeviceObject->Flags = 0; - dev->DeviceExtension=ExAllocatePool(NonPagedPool,DeviceExtensionSize); - if (DeviceExtensionSize > 0 && dev->DeviceExtension==NULL) + CreatedDeviceObject->DeviceExtension = ExAllocatePool(NonPagedPool, + DeviceExtensionSize); + if (DeviceExtensionSize > 0 && CreatedDeviceObject->DeviceExtension == NULL) { - ExFreePool(dev); + ExFreePool(CreatedDeviceObject); return(STATUS_INSUFFICIENT_RESOURCES); } - dev->AttachedDevice=NULL; - dev->DeviceType=DeviceType; - dev->StackSize=1; - dev->AlignmentRequirement=1; - KeInitializeDeviceQueue(&dev->DeviceQueue); + CreatedDeviceObject->AttachedDevice = NULL; + CreatedDeviceObject->DeviceType = DeviceType; + CreatedDeviceObject->StackSize = 1; + CreatedDeviceObject->AlignmentRequirement = 1; + KeInitializeDeviceQueue(&CreatedDeviceObject->DeviceQueue); - if (dev->DeviceType==FILE_DEVICE_DISK) + if (CreatedDeviceObject->DeviceType == FILE_DEVICE_DISK) { - IoAttachVpb(dev); + IoAttachVpb(CreatedDeviceObject); } - *DeviceObject=dev; - DPRINT("dev->DriverObject %x\n",dev->DriverObject); + *DeviceObject = CreatedDeviceObject; return(STATUS_SUCCESS); } diff --git a/reactos/ntoskrnl/io/ioctrl.c b/reactos/ntoskrnl/io/ioctrl.c index 2d0ae82f040..c97fe267380 100644 --- a/reactos/ntoskrnl/io/ioctrl.c +++ b/reactos/ntoskrnl/io/ioctrl.c @@ -175,3 +175,4 @@ ZwDeviceIoControlFile( return(Status); } + diff --git a/reactos/ntoskrnl/io/irp.c b/reactos/ntoskrnl/io/irp.c index b7a5267af37..b28ac887706 100644 --- a/reactos/ntoskrnl/io/irp.c +++ b/reactos/ntoskrnl/io/irp.c @@ -29,9 +29,10 @@ /* INCLUDES ****************************************************************/ +#include +#include #include #include -#include #define NDEBUG #include diff --git a/reactos/ntoskrnl/io/mailslot.c b/reactos/ntoskrnl/io/mailslot.c index b70c12618d8..801c977caae 100644 --- a/reactos/ntoskrnl/io/mailslot.c +++ b/reactos/ntoskrnl/io/mailslot.c @@ -45,4 +45,4 @@ ZwCreateMailslotFile( IN PLARGE_INTEGER TimeOut ) { -} \ No newline at end of file +} diff --git a/reactos/ntoskrnl/io/rw.c b/reactos/ntoskrnl/io/rw.c index fc42a2ef44b..6a8f9a8a947 100644 --- a/reactos/ntoskrnl/io/rw.c +++ b/reactos/ntoskrnl/io/rw.c @@ -10,9 +10,9 @@ /* INCLUDES ****************************************************************/ -#include #include #include +#include #include #include @@ -56,6 +56,7 @@ NTSTATUS ZwReadFile(HANDLE FileHandle, PFILE_OBJECT FileObject; PIRP Irp; PIO_STACK_LOCATION StackPtr; + PKEVENT ptrEvent = NULL; KEVENT Event; assert(KeGetCurrentIrql()==PASSIVE_LEVEL); @@ -66,7 +67,7 @@ NTSTATUS ZwReadFile(HANDLE FileHandle, Status = ObReferenceObjectByHandle(FileHandle, FILE_READ_DATA, - NULL, + IoFileType, UserMode, (PVOID *) &FileObject, NULL); @@ -81,14 +82,32 @@ NTSTATUS ZwReadFile(HANDLE FileHandle, ByteOffset = &(FileObject->CurrentByteOffset); } - KeInitializeEvent(&Event,NotificationEvent,FALSE); + if (EventHandle != NULL) + { + Status = ObReferenceObjectByHandle(EventHandle, + SYNCHRONIZE, + ExEventType, + UserMode, + (PVOID *)ptrEvent, + NULL); + if (!NT_SUCCESS(Status)) + { + return(Status); + } + } + else + { + KeInitializeEvent(&Event,NotificationEvent,FALSE); + ptrEvent = &Event; + } + DPRINT("FileObject %x\n",FileObject); Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ, FileObject->DeviceObject, Buffer, Length, ByteOffset, - &Event, + ptrEvent, IoStatusBlock); StackPtr = IoGetNextIrpStackLocation(Irp); @@ -148,9 +167,12 @@ NTSTATUS ZwWriteFile(HANDLE FileHandle, PIO_STACK_LOCATION StackPtr; KEVENT Event; + DPRINT("ZwWriteFile(FileHandle %x, Buffer %x, Length %d)\n", + FileHandle,Buffer,Length); + Status = ObReferenceObjectByHandle(FileHandle, FILE_WRITE_DATA, - NULL, + IoFileType, UserMode, (PVOID *) &FileObject, NULL); diff --git a/reactos/ntoskrnl/io/vpb.c b/reactos/ntoskrnl/io/vpb.c index 5d56101b7bb..fb6dba12938 100644 --- a/reactos/ntoskrnl/io/vpb.c +++ b/reactos/ntoskrnl/io/vpb.c @@ -11,6 +11,7 @@ /* INCLUDES *****************************************************************/ #include +#include #include #include diff --git a/reactos/ntoskrnl/ke/.cvsignore b/reactos/ntoskrnl/ke/.cvsignore new file mode 100644 index 00000000000..c7fbdadb9db --- /dev/null +++ b/reactos/ntoskrnl/ke/.cvsignore @@ -0,0 +1 @@ +exports.c diff --git a/reactos/ntoskrnl/ke/apc.c b/reactos/ntoskrnl/ke/apc.c index e2b5bdc9dcc..7624e2007a9 100644 --- a/reactos/ntoskrnl/ke/apc.c +++ b/reactos/ntoskrnl/ke/apc.c @@ -11,6 +11,7 @@ /* INCLUDES *****************************************************************/ #include +#include #include #include #include diff --git a/reactos/ntoskrnl/ke/bug.c b/reactos/ntoskrnl/ke/bug.c index 8dd54becf29..8dee985c6eb 100644 --- a/reactos/ntoskrnl/ke/bug.c +++ b/reactos/ntoskrnl/ke/bug.c @@ -65,7 +65,7 @@ VOID KeBugCheckEx(ULONG BugCheckCode, DbgPrint("Bug detected (code %x param %x %x %x %x)\n",BugCheckCode, BugCheckParameter1,BugCheckParameter2,BugCheckParameter3, BugCheckParameter4); - KeDumpStackFrames(0,32); + KeDumpStackFrames(0,64); for(;;); } diff --git a/reactos/ntoskrnl/ke/event.c b/reactos/ntoskrnl/ke/event.c index 1033d94b30f..aa27814d417 100644 --- a/reactos/ntoskrnl/ke/event.c +++ b/reactos/ntoskrnl/ke/event.c @@ -49,4 +49,5 @@ LONG KeSetEvent(PKEVENT Event, KPRIORITY Increment, BOOLEAN Wait) ret = InterlockedExchange(&(Event->Header.SignalState),1); KeDispatcherObjectWake((DISPATCHER_HEADER *)Event); KeReleaseDispatcherDatabaseLock(Wait); + return(ret); } diff --git a/reactos/ntoskrnl/ke/kernel.c b/reactos/ntoskrnl/ke/kernel.c index 360b2a17507..5ba1f875830 100644 --- a/reactos/ntoskrnl/ke/kernel.c +++ b/reactos/ntoskrnl/ke/kernel.c @@ -22,7 +22,7 @@ VOID KeInit(VOID) KeInitDpc(); KeInitializeBugCheck(); KeInitializeDispatcher(); - InitializeTimer(); + KeInitializeTimerImpl(); /* * Allow interrupts diff --git a/reactos/ntoskrnl/ke/main.c b/reactos/ntoskrnl/ke/main.c index 1cd29ba5d34..cc470f36ea4 100644 --- a/reactos/ntoskrnl/ke/main.c +++ b/reactos/ntoskrnl/ke/main.c @@ -15,9 +15,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -162,6 +164,7 @@ asmlinkage void _main(boot_param* _bp) start1 = start+PAGE_ROUND_UP(bp.module_length[1]); for (i=1;i -#include - -#include - -#include -#include -#include -#include -#include - -#define NDEBUG -#include - -/* FUNCTIONS **************************************************************/ - -static unsigned int get_kernel_symbol_addr(char* name) -/* - * FUNCTION: Get the address of a kernel symbol - * ARGUMENTS: - * name = symbol name - * RETURNS: The address of the symbol on success - * NULL on failure - */ -{ - int i=0; - while (symbol_table[i].name!=NULL) - { - if (strcmp(symbol_table[i].name,name)==0) - { - return(symbol_table[i].value); - } - i++; - } - return(0); -} - -static void get_symbol_name(module* mod, unsigned int i, char* name) -/* - * FUNCTION: Get the name of a symbol from a loaded module by ordinal - * ARGUMENTS: - * mod = module - * i = index of symbol - * name (OUT) = pointer to a string where the symbol name will be - * stored - */ -{ - if (mod->sym_list[i].e.e_name[0]!=0) - { - strncpy(name,mod->sym_list[i].e.e_name,8); - } - else - { - strcpy(name,&mod->str_tab[mod->sym_list[i].e.e.e_offset]); - } -} - -static unsigned int get_symbol_value_by_name(module* mod, char* sname, - unsigned int idx) -{ - unsigned int i; - char name[255]; - - DPRINT("get_symbol_value_by_name(sname %s, idx %x)\n",sname,idx); - - for (i=0; insyms; i++) - { - get_symbol_name(mod,i,name); - DPRINT("Scanning %s Value %x\n",name,mod->sym_list[i].e_value); - if (strcmp(name,sname)==0) - { - DPRINT("Returning %x\n",mod->sym_list[i].e_value); - return(mod->sym_list[i].e_value); - } - } - return(0); -} - -static unsigned int get_symbol_value(module* mod, unsigned int i) -/* - * FUNCTION: Get the value of a module defined symbol - * ARGUMENTS: - * mod = module - * i = index of symbol - * RETURNS: The value of the symbol - * NOTE: This fixes up references to known sections - */ -{ - char name[255]; - get_symbol_name(mod,i,name); - // DPRINT("name %s ",name); - - /* - * Check if the symbol is a section we have relocated - */ - if (strcmp(name,".text")==0) - { - return(mod->text_base); - } - if (strcmp(name,".data")==0) - { - return(mod->data_base); - } - if (strcmp(name,".bss")==0) - { - return(mod->bss_base); - } - return(mod->sym_list[i].e_value); -} - -static int do_reloc32_reloc(module* mod, SCNHDR* scn, RELOC* reloc) -/* - * FUNCTION: Performs a reloc32 relocation on a loaded module - * ARGUMENTS: - * mod = module to perform the relocation on - * scn = Section to perform the relocation in - * reloc = Pointer to a data structure describing the relocation - * RETURNS: Success or failure - * NOTE: This fixes up an undefined reference to a kernel function in a module - */ -{ - char name[255]; - unsigned int val; - unsigned int * loc; - - memset(name,0,255); - get_symbol_name(mod,reloc->r_symndx,name); - val = get_kernel_symbol_addr(name); - if (val==0) - { - val = get_symbol_value_by_name(mod,name,reloc->r_symndx); - if (val==0) - { - DbgPrint("Undefined symbol %s in module\n",name); - return(0); - } - loc=(unsigned int *)(mod->base+reloc->r_vaddr); - DPRINT("old %x ",*loc); -// (*loc) = (*loc) + val + mod->base - scn->s_vaddr; - (*loc) = (*loc); - DPRINT("mod->base %x scn->s_vaddr %x\n",mod->base,scn->s_vaddr); - - DPRINT("new %x\n",*loc); - - } - else - { - DPRINT("REL32 value %x name %s\n",val,name); - DPRINT("value %x\n",val); - loc=(unsigned int *)(mod->base+reloc->r_vaddr); - DPRINT("old %x ",*loc); - DPRINT("mod->base %x scn->s_vaddr %x\n",mod->base,scn->s_vaddr); - (*loc) = (*loc) + val - mod->base + scn->s_vaddr; - - DPRINT("new %x\n",*loc); - } - return(1); -} - -static int do_addr32_reloc(module* mod, SCNHDR* scn, RELOC* reloc) -/* - * FUNCTION: Performs a addr32 relocation on a loaded module - * ARGUMENTS: - * mod = module to perform the relocation on - * scn = Section to perform the relocation in - * reloc = Pointer to a data structure describing the relocation - * RETURNS: Success or failure - * NOTE: This fixes up a relocation needed when changing the base address of a - * module - */ -{ - unsigned int value; - unsigned int * loc; - // printk("ADDR32 "); - - - value=get_symbol_value(mod,reloc->r_symndx); - - // printk("value %x\n",value); - - loc=(unsigned int *)(mod->base+reloc->r_vaddr); -// DPRINT("ADDR32 loc %x value %x *loc %x ",loc,value,*loc); - *loc=(*loc)+mod->base; - // *loc = value; - // *loc=(*loc)+value - -// DPRINT("*loc %x\n",*loc); - - return(1); -} - -static BOOLEAN do_reloc(module* mod, unsigned int scn_idx) -/* - * FUNCTION: Do the relocations for a module section - * ARGUMENTS: - * mod = Pointer to the module - * scn_idx = Index of the section to be relocated - * RETURNS: Success or failure - */ -{ - SCNHDR* scn = &mod->scn_list[scn_idx]; - RELOC* reloc = (RELOC *)(mod->raw_data_off + scn->s_relptr); - int j; - - DPRINT("scn_idx %d name %.8s relocs %d\n",scn_idx, - mod->scn_list[scn_idx].s_name,scn->s_nreloc); - - for (j=0;js_nreloc;j++) - { - // printk("vaddr %x ",reloc->r_vaddr); - // printk("symndex %x ",reloc->r_symndx); - - switch(reloc->r_type) - { - case RELOC_ADDR32: - if (!do_addr32_reloc(mod,scn,reloc)) - { - return(0); - } - break; - - case RELOC_REL32: - if (!do_reloc32_reloc(mod,scn,reloc)) - { - return(0); - } - break; - - default: - DbgPrint("Unknown relocation type %x at %d in module\n", - reloc->r_type,j); - return(0); - } - - reloc = (RELOC *)(((unsigned int)reloc) + sizeof(RELOC)); - } - - DPRINT("Done relocations for %.8s\n",mod->scn_list[scn_idx].s_name); - - return(1); -} - -BOOLEAN process_boot_module(unsigned int start) -/* - * FUNCTION: Processes and initializes a module whose disk image has been - * loaded - * ARGUMENTS: - * start = start of the module in memory - * RETURNS: Success or failure - */ -{ - FILHDR hdr; - AOUTHDR ohdr; - module* mod; - unsigned int entry=0; - unsigned int found_entry=0; - PDRIVER_INITIALIZE func; - int i; - - DPRINT("process_boot_module(start %x)\n",start); - DPRINT("n = %x\n",*((unsigned int *)start)); - mod=(module *)ExAllocatePool(NonPagedPool,sizeof(module)); - - DPRINT("magic %x\n",((FILHDR *)start)->f_magic); -// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000)); - - memcpy(&hdr,(void *)start,FILHSZ); - - if (I386BADMAG(hdr)) - { - DbgPrint("(%s:%d) Module has bad magic value (%x)\n",__FILE__, - __LINE__,hdr.f_magic); - return(0); - } - - memcpy(&ohdr,(void *)(start+FILHSZ),AOUTSZ); - - mod->sym_list = (SYMENT *)(start + hdr.f_symptr); - - mod->str_tab = (char *)(start + hdr.f_symptr + - hdr.f_nsyms * SYMESZ); - - mod->scn_list = (SCNHDR *)(start+FILHSZ+hdr.f_opthdr); - mod->size=0; - mod->raw_data_off = start; - mod->nsyms = hdr.f_nsyms; - - /* - * Determine the length of the module - */ - for (i=0;iscn_list[i].s_name); - DPRINT("size %x vaddr %x size %x\n",mod->size, - mod->scn_list[i].s_vaddr,mod->scn_list[i].s_size); - if (mod->scn_list[i].s_flags & STYP_TEXT) - { - mod->text_base=mod->scn_list[i].s_vaddr; - } - if (mod->scn_list[i].s_flags & STYP_DATA) - { - mod->data_base=mod->scn_list[i].s_vaddr; - } - if (mod->scn_list[i].s_flags & STYP_BSS) - { - mod->bss_base=mod->scn_list[i].s_vaddr; - } - if (mod->size < - (mod->scn_list[i].s_vaddr + mod->scn_list[i].s_size)) - { - mod->size = mod->size + mod->scn_list[i].s_vaddr + - mod->scn_list[i].s_size; - } - } - - CHECKPOINT; -// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000)); - mod->base = (unsigned int)MmAllocateSection(mod->size); -// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000)); - if (mod->base == 0) - { - DbgPrint("Failed to alloc section for module\n"); - return(0); - } - CHECKPOINT; - - /* - * Adjust section vaddrs for allocated area - */ - mod->data_base=mod->data_base+mod->base; - mod->text_base=mod->text_base+mod->base; - mod->bss_base=mod->bss_base+mod->base; - - /* - * Relocate module and fixup imports - */ - for (i=0;iscn_list[i].s_flags & STYP_TEXT || - mod->scn_list[i].s_flags & STYP_DATA) - { - memcpy((void *)(mod->base + mod->scn_list[i].s_vaddr), - (void *)(start + mod->scn_list[i].s_scnptr), - mod->scn_list[i].s_size); - if (!do_reloc(mod,i)) - { - DPRINT("Relocation failed for section %s\n", - mod->scn_list[i].s_name); - return(0); - } - } - if (mod->scn_list[i].s_flags & STYP_BSS) - { - memset((void *)(mod->base + mod->scn_list[i].s_vaddr),0, - mod->scn_list[i].s_size); - } - } - - DbgPrint("Module base: %x\n",mod->base); - - /* - * Find the entry point - */ - - for (i=0;isym_list[i].e_value; - found_entry=1; - DPRINT("Found entry at %x\n",entry); - } - } - - if (!found_entry) - { - DbgPrint("No module entry point defined\n"); - return(0); - } - - /* - * Call the module initalization routine - */ - func = (PDRIVER_INITIALIZE)(mod->base + entry); - return(InitializeLoadedDriver(func)); -} diff --git a/reactos/ntoskrnl/ke/timer.c b/reactos/ntoskrnl/ke/timer.c index bae22e9bf35..aa25cc804c8 100644 --- a/reactos/ntoskrnl/ke/timer.c +++ b/reactos/ntoskrnl/ke/timer.c @@ -18,6 +18,7 @@ #include #include #include +#include #define NDEBUG #include @@ -172,7 +173,8 @@ NTSTATUS STDCALL NtDelayExecution(IN BOOLEAN Alertable, NTSTATUS STDCALL ZwDelayExecution(IN BOOLEAN Alertable, IN TIME *Interval) { - UNIMPLEMENTED; + KeBugCheck(0); + return(STATUS_UNSUCCESSFUL); } NTSTATUS KeDelayExecutionThread(KPROCESSOR_MODE WaitMode, @@ -547,7 +549,7 @@ BOOLEAN KiTimerInterrupt(VOID) } -void InitializeTimer(void) +VOID KeInitializeTimerImpl(VOID) /* * FUNCTION: Initializes timer irq handling * NOTE: This is only called once from main() diff --git a/reactos/ntoskrnl/ldr/loader.c b/reactos/ntoskrnl/ldr/loader.c index 3927de8f9d1..52abd36686b 100644 --- a/reactos/ntoskrnl/ldr/loader.c +++ b/reactos/ntoskrnl/ldr/loader.c @@ -10,16 +10,21 @@ * RJJ 10/12/98 Completed image loader function and added hooks for MZ/PE * RJJ 10/12/98 Built driver loader function and added hooks for PE/COFF * RJJ 10/12/98 Rolled in David's code to load COFF drivers - * JM 14/12/98 Built initail PE user module loader + * JM 14/12/98 Built initial PE user module loader + * RJJ 06/03/99 Moved user PE loader into NTDLL */ /* INCLUDES *****************************************************************/ +#include + #include -#include #include #include +#include #include +#include +#include #include #include @@ -28,6 +33,9 @@ #define NDEBUG #include +/* FIXME: this should appear in a kernel header file */ +NTSTATUS IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry); + /* MACROS ********************************************************************/ /* GLOBALS *******************************************************************/ @@ -52,11 +60,6 @@ static void LdrCOFFGetSymbolName(module *Module, unsigned int Idx, char *Name); static unsigned int LdrCOFFGetSymbolValue(module *Module, unsigned int Idx); static unsigned int LdrCOFFGetSymbolValueByName(module *Module, char *SymbolName, unsigned int Idx); -/* Image loader forward delcarations */ -static NTSTATUS LdrProcessMZImage(HANDLE ProcessHandle, HANDLE ModuleHandle, HANDLE FileHandle); -static NTSTATUS LdrProcessPEImage(HANDLE ProcessHandle, HANDLE ModuleHandle, HANDLE FileHandle); -static NTSTATUS LdrProcessBinImage(HANDLE ProcessHandle, HANDLE ModuleHandle, HANDLE FileHandle); - /* FUNCTIONS *****************************************************************/ VOID LdrInitModuleManagement(VOID) @@ -92,7 +95,7 @@ VOID LdrLoadAutoConfigDrivers(VOID) ANSI_STRING AnsiDriverName; UNICODE_STRING DriverName; - RtlInitAnsiString(&AnsiDriverName,"\\??\\C:\\reactos\\system\\drivers\\keyboard.o"); + RtlInitAnsiString(&AnsiDriverName,"\\??\\C:\\reactos\\system\\drivers\\keyboard.sys"); RtlAnsiStringToUnicodeString(&DriverName, &AnsiDriverName, TRUE); Status = LdrLoadDriver(&DriverName); RtlFreeUnicodeString(&DriverName); @@ -101,7 +104,7 @@ VOID LdrLoadAutoConfigDrivers(VOID) DbgPrint("driver load failed, status;%d(%x)\n", Status, Status); DbgPrintErrorMessage(Status); } - RtlInitAnsiString(&AnsiDriverName,"\\??\\C:\\reactos\\system\\drivers\\blues.o"); + RtlInitAnsiString(&AnsiDriverName,"\\??\\C:\\reactos\\system\\drivers\\blue.sys"); RtlAnsiStringToUnicodeString(&DriverName, &AnsiDriverName, TRUE); Status = LdrLoadDriver(&DriverName); RtlFreeUnicodeString(&DriverName); @@ -218,8 +221,8 @@ NTSTATUS LdrPEProcessDriver(PVOID ModuleLoadBase) { unsigned int DriverSize, Idx; - long int RelocDelta, NumRelocs; - DWORD CurrentSize; + ULONG RelocDelta, NumRelocs; + DWORD CurrentSize, TotalRelocs; PVOID DriverBase, CurrentBase, EntryPoint; PULONG PEMagic; PIMAGE_DOS_HEADER PEDosHeader; @@ -287,25 +290,10 @@ LdrPEProcessDriver(PVOID ModuleLoadBase) CHECKPOINT; /* Determine the size of the module */ - DPRINT("Sections: (section align:%08lx)\n", - PEOptionalHeader->SectionAlignment); - DriverSize = PESectionHeaders[0].PointerToRawData; - for (Idx = 0; Idx < PEFileHeader->NumberOfSections; Idx++) - { - DPRINT("Name:%-8.8s VA:%08lx RawSz:%6d Offs:%08lx CHAR:%08lx OfsA: %08lx\n", - PESectionHeaders[Idx].Name, - PESectionHeaders[Idx].VirtualAddress, - PESectionHeaders[Idx].SizeOfRawData, - PESectionHeaders[Idx].PointerToRawData, - PESectionHeaders[Idx].Characteristics, - DriverSize); - DriverSize += ROUND_UP(PESectionHeaders[Idx].SizeOfRawData, - PEOptionalHeader->SectionAlignment); - } - DPRINT("DriverSize computed by using section headers: %d(%08lx)\n", - DriverSize, - DriverSize); - + + DriverSize = PEOptionalHeader->SizeOfImage; + DPRINT("DriverSize %x\n",DriverSize); + /* Allocate a virtual section for the module */ DriverBase = MmAllocateSection(DriverSize); if (DriverBase == 0) @@ -324,13 +312,18 @@ LdrPEProcessDriver(PVOID ModuleLoadBase) if (PESectionHeaders[Idx].Characteristics & (IMAGE_SECTION_CHAR_CODE | IMAGE_SECTION_CHAR_DATA)) { - memcpy(CurrentBase, + DPRINT("PESectionHeaders[Idx].VirtualAddress + DriverBase %x\n", + PESectionHeaders[Idx].VirtualAddress + DriverBase); + memcpy(PESectionHeaders[Idx].VirtualAddress + DriverBase, (PVOID)(ModuleLoadBase + PESectionHeaders[Idx].PointerToRawData), PESectionHeaders[Idx].SizeOfRawData); } else { - memset(CurrentBase, '\0', PESectionHeaders[Idx].SizeOfRawData); + DPRINT("PESectionHeaders[Idx].VirtualAddress + DriverBase %x\n", + PESectionHeaders[Idx].VirtualAddress + DriverBase); + memset(PESectionHeaders[Idx].VirtualAddress + DriverBase, + '\0', PESectionHeaders[Idx].SizeOfRawData); } CurrentSize += ROUND_UP(PESectionHeaders[Idx].SizeOfRawData, PEOptionalHeader->SectionAlignment); @@ -341,50 +334,73 @@ LdrPEProcessDriver(PVOID ModuleLoadBase) /* Perform relocation fixups */ RelocDelta = (DWORD) DriverBase - PEOptionalHeader->ImageBase; - RelocDir = (PRELOCATION_DIRECTORY) ((DWORD)ModuleLoadBase + - PEOptionalHeader->DataDirectory[ + RelocDir = (PRELOCATION_DIRECTORY)(PEOptionalHeader->DataDirectory[ IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress); DPRINT("DrvrBase:%08lx ImgBase:%08lx RelocDelta:%08lx\n", DriverBase, PEOptionalHeader->ImageBase, RelocDelta); - while (RelocDir->SizeOfBlock != 0) + DPRINT("RelocDir %x\n",RelocDir); + for (Idx = 0; Idx < PEFileHeader->NumberOfSections; Idx++) + { + if (PESectionHeaders[Idx].VirtualAddress == (DWORD)RelocDir) + { + DPRINT("Name %.8s PESectionHeader[Idx].PointerToRawData %x\n", + PESectionHeaders[Idx].Name, + PESectionHeaders[Idx].PointerToRawData); + RelocDir = PESectionHeaders[Idx].PointerToRawData + + ModuleLoadBase; + CurrentSize = PESectionHeaders[Idx].Misc.VirtualSize; + break; + } + } + DPRINT("RelocDir %08lx CurrentSize %08lx\n", RelocDir, CurrentSize); + TotalRelocs = 0; + while (TotalRelocs < CurrentSize && RelocDir->SizeOfBlock != 0) { NumRelocs = (RelocDir->SizeOfBlock - sizeof(RELOCATION_DIRECTORY)) / sizeof(WORD); - DPRINT("RelocDir at %08lx for VA %08lx with %08lx relocs\n", +/* DPRINT("RelocDir at %08lx for VA %08lx with %08lx relocs\n", RelocDir, RelocDir->VirtualAddress, - NumRelocs); + NumRelocs);*/ RelocEntry = (PRELOCATION_ENTRY) ((DWORD)RelocDir + sizeof(RELOCATION_DIRECTORY)); for (Idx = 0; Idx < NumRelocs; Idx++) { - DPRINT(" reloc at %08lx %x %s old:%08lx new:%08lx\n", - DriverBase + RelocDir->VirtualAddress + - (RelocEntry[Idx].TypeOffset & 0x0fff), - (RelocEntry[Idx].TypeOffset >> 12) & 0xf, - (RelocEntry[Idx].TypeOffset >> 12) & 0xf ? "HIGHLOW" : "ABS", - *(PDWORD)((DWORD) DriverBase + RelocDir->VirtualAddress + - (RelocEntry[Idx].TypeOffset & 0x0fff)), - (*(PDWORD)((DWORD) DriverBase + RelocDir->VirtualAddress + - (RelocEntry[Idx].TypeOffset & 0x0fff))) + RelocDelta); - if (((RelocEntry[Idx].TypeOffset >> 12) & 0xf) == 3) + ULONG Offset; + ULONG Type; + PDWORD RelocItem; + + Offset = RelocEntry[Idx].TypeOffset & 0xfff; + Type = (RelocEntry[Idx].TypeOffset >> 12) & 0xf; + RelocItem = (PDWORD)(DriverBase + RelocDir->VirtualAddress + + Offset); +/* DPRINT(" reloc at %08lx %x %s old:%08lx new:%08lx\n", + RelocItem, + Type, + Type ? "HIGHLOW" : "ABS", + *RelocItem, + (*RelocItem) + RelocDelta); */ + if (Type == 3) { - (*(PDWORD)((DWORD) DriverBase + RelocDir->VirtualAddress + - (RelocEntry[Idx].TypeOffset & 0x0fff))) += RelocDelta; + (*RelocItem) += RelocDelta; } - else if (((RelocEntry[Idx].TypeOffset >> 12) & 0xf) != 0) + else if (Type != 0) { - DPRINT("Unknown relocation type %x\n", - (RelocEntry[Idx].TypeOffset >> 12) & 0xf); + DPRINT("Unknown relocation type %x\n",Type); return STATUS_UNSUCCESSFUL; } } + TotalRelocs += RelocDir->SizeOfBlock; RelocDir = (PRELOCATION_DIRECTORY)((DWORD)RelocDir + RelocDir->SizeOfBlock); +// DPRINT("TotalRelocs: %08lx CurrentSize: %08lx\n", TotalRelocs, CurrentSize); } - + + DPRINT("PEOptionalHeader->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT] %x\n", + PEOptionalHeader->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT] + .VirtualAddress); /* Perform import fixups */ if (PEOptionalHeader->DataDirectory[ IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress) @@ -395,7 +411,7 @@ LdrPEProcessDriver(PVOID ModuleLoadBase) /* Process each import module */ ImportModuleDirectory = (PIMAGE_IMPORT_MODULE_DIRECTORY) - ((DWORD)ModuleLoadBase + PEOptionalHeader-> + ((DWORD)DriverBase + PEOptionalHeader-> DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress); while (ImportModuleDirectory->dwRVAModuleName) { @@ -403,29 +419,28 @@ LdrPEProcessDriver(PVOID ModuleLoadBase) /* Check to make sure that import lib is kernel */ Library = NULL; - pName = (PCHAR) ModuleLoadBase + + pName = (PCHAR) DriverBase + ImportModuleDirectory->dwRVAModuleName; - DPRINT("Import module: %s\n", pName); - if (strcmp(pName, "ntoskrnl.exe") && - strcmp(pName, "roskrnl.exe") && - strcmp(pName, "HAL.dll")) +// DPRINT("Import module: %s\n", pName); + if (strcmp(pName, "ntoskrnl.exe")!=0 && + strcmp(pName, "HAL.dll")!=0) { DPRINT("Kernel mode DLLs are currently unsupported\n"); } /* Get the import address list */ - ImportAddressList = (PVOID *) ((DWORD)ModuleLoadBase + + ImportAddressList = (PVOID *) ((DWORD)DriverBase + ImportModuleDirectory->dwRVAFunctionAddressList); /* Get the list of functions to import */ if (ImportModuleDirectory->dwRVAFunctionNameList != 0) { - FunctionNameList = (PULONG) ((DWORD)ModuleLoadBase + + FunctionNameList = (PULONG) ((DWORD)DriverBase + ImportModuleDirectory->dwRVAFunctionNameList); } else { - FunctionNameList = (PULONG) ((DWORD)ModuleLoadBase + + FunctionNameList = (PULONG) ((DWORD)DriverBase + ImportModuleDirectory->dwRVAFunctionAddressList); } @@ -434,7 +449,7 @@ LdrPEProcessDriver(PVOID ModuleLoadBase) { if ((*FunctionNameList) & 0x80000000) // hint { - DPRINT(" Hint: %08lx\n", *FunctionNameList); +// DPRINT(" Hint: %08lx\n", *FunctionNameList); if (Library == NULL) { DPRINT("Hints for kernel symbols are not handled.\n"); @@ -443,10 +458,10 @@ LdrPEProcessDriver(PVOID ModuleLoadBase) } else // hint-name { - pName = (PCHAR)((DWORD)ModuleLoadBase + + pName = (PCHAR)((DWORD)DriverBase+ *FunctionNameList + 2); - pHint = (PWORD)((DWORD)ModuleLoadBase + *FunctionNameList); - DPRINT(" Hint:%04x Name:%s\n", pHint, pName); + pHint = (PWORD)((DWORD)DriverBase + *FunctionNameList); + // DPRINT(" Hint:%04x Name:%s\n", pHint, pName); /* Get address for symbol */ if (Library == NULL) @@ -471,7 +486,7 @@ LdrPEProcessDriver(PVOID ModuleLoadBase) /* Compute address of entry point */ EntryPoint = (PVOID) ((DWORD)DriverBase + PEOptionalHeader->AddressOfEntryPoint); - return InitializeLoadedDriver(EntryPoint); + return IoInitializeDriver(EntryPoint); } NTSTATUS @@ -620,7 +635,7 @@ LdrCOFFProcessDriver(PVOID ModuleLoadBase) /* Cleanup */ ExFreePool(Module); - return InitializeLoadedDriver(EntryRoutine); + return IoInitializeDriver(EntryRoutine); } /* LdrCOFFDoRelocations @@ -823,17 +838,31 @@ static unsigned int LdrGetKernelSymbolAddr(char *Name) { int i = 0; - + char* s; + + if ((s=strchr(Name,'@'))!=NULL) + { + *s=0; + DbgPrint("Name %s ",Name); + } while (symbol_table[i].name != NULL) { if (strcmp(symbol_table[i].name, Name) == 0) { + if (s!=NULL) + { + *s=0; + DbgPrint("Matched with %s\n",symbol_table[i].name); + } return symbol_table[i].value; } i++; } - - return 0L; + if (s!=NULL) + { + *s=0; + } + return 0L; } static unsigned int @@ -860,592 +889,293 @@ LdrCOFFGetSymbolValueByName(module *Module, return 0L; } -NTSTATUS LdrLoadLibrary(HANDLE ProcessHandle, - PHANDLE ModuleHandle, - PCHAR Name) -{ -#if 0 - NTSTATUS Status; - ANSI_STRING afilename; - UNICODE_STRING ufilename,umodName; - PMODULE *Library, *Module; - OBJECT_ATTRIBUTES attr; - PWSTR Ignored; - char name2[512]; - - /* FIXME: this is broke */ - /* FIXME: check for module already loaded */ - /* FIXME: otherwise load module */ - /* FIXME: we need to fix how modules are loaded so that they can - be shared... :( */ - - /* If module is already loaded, get a reference and return it */ - strcpy(name2, "\\modules\\"); - strcat(name2, Name); - RtlInitAnsiString(&afilename, name2); - RtlAnsiStringToUnicodeString(&umodName, &afilename, TRUE); - InitializeObjectAttributes(&attr, &umodName, 0, NULL, NULL); - Status = ObOpenObjectByName(&attr, (PVOID *) &Library, &Ignored); - DPRINT("LoadLibrary : Status=%x,pLibrary=%x\n",Status, Library); - if (!NT_SUCCESS(Status) || Library == NULL) - { - strcpy(name2, "\\??\\C:\\reactos\\system\\"); - strcat(name2, name); - RtlInitAnsiString(&afilename, name2); - RtlAnsiStringToUnicodeString(&ufilename, &afilename, TRUE); - DPRINT("LoadLibrary,load %s\n", name2); - Library = LdrLoadImage(&ufilename); - /* FIXME: execute start code ? */ - Module = ObGenericCreateObject(NULL, PROCESS_ALL_ACCESS, &attr, ObModuleType); - if (Module) - { - memcpy(Module, Library, PMODULE); - } - else - { - DbgPrint("library object not created\n"); - } - RtlFreeUnicodeString(&ufilename); - Status = ObOpenObjectByName(&attr, (PVOID *)&Library, &Ignored); - } - else - { - DPRINT("Library already loaded\n"); - *Module = Library - } - RtlFreeUnicodeString(&umodName); - - return STATUS_SUCCESS; -#endif - UNIMPLEMENTED; -} - /* LdrLoadImage * FUNCTION: - * Loads a module into the specified process + * Builds the initial environment for a process. Should be used + * to load the initial user process. * ARGUMENTS: * HANDLE ProcessHandle handle of the process to load the module into - * PHANDLE ModuleHandle handle of the loaded module * PUNICODE_STRING Filename name of the module to load * RETURNS: * NTSTATUS */ -NTSTATUS -LdrLoadImage(HANDLE ProcessHandle, - PHANDLE ModuleHandle, - PUNICODE_STRING Filename) +#define STACK_TOP (0xb0000000) + +NTSTATUS LdrLoadImage(HANDLE ProcessHandle, PUNICODE_STRING Filename) { char BlockBuffer[1024]; + DWORD ImageBase, LdrStartupAddr, StackBase; + ULONG ImageSize, StackSize; NTSTATUS Status; OBJECT_ATTRIBUTES FileObjectAttributes; - HANDLE FileHandle; - PMODULE Module; - PIMAGE_DOS_HEADER PEDosHeader; + HANDLE FileHandle, SectionHandle, ThreadHandle; + CONTEXT Context; + ANSI_STRING AnsiString; + UNICODE_STRING DllPathname; + PIMAGE_DOS_HEADER DosHeader; + PIMAGE_NT_HEADERS NTHeaders; + ULONG BytesWritten; + ULONG InitialViewSize; + ULONG i; + HANDLE DupSectionHandle; + + /* Locate and open NTDLL to determine ImageBase and LdrStartup */ + RtlInitUnicodeString(&DllPathname,L"\\??\\C:\\reactos\\system\\ntdll.dll"); + InitializeObjectAttributes(&FileObjectAttributes, + &DllPathname, + 0, + NULL, + NULL); + DPRINT("Opening NTDLL\n"); + Status = ZwOpenFile(&FileHandle, FILE_ALL_ACCESS, &FileObjectAttributes, NULL, 0, 0); + if (!NT_SUCCESS(Status)) + { + DPRINT("NTDLL open failed "); + DbgPrintErrorMessage(Status); - /* FIXME: should DLLs be named sections? */ + return Status; + } + Status = ZwReadFile(FileHandle, 0, 0, 0, 0, BlockBuffer, 1024, 0, 0); + if (!NT_SUCCESS(Status)) + { + DPRINT("NTDLL header read failed "); + DbgPrintErrorMessage(Status); + ZwClose(FileHandle); - /* Open the image file */ + return Status; + } + /* FIXME: this will fail if the NT headers are more than 1024 bytes from start */ + 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) + { + DPRINT("NTDLL format invalid\n"); + ZwClose(FileHandle); + + return STATUS_UNSUCCESSFUL; + } + NTHeaders = (PIMAGE_NT_HEADERS)(BlockBuffer + DosHeader->e_lfanew); + ImageBase = NTHeaders->OptionalHeader.ImageBase; + ImageSize = NTHeaders->OptionalHeader.SizeOfImage; + /* FIXME: retrieve the offset of LdrStartup from NTDLL */ + DPRINT("ImageBase %x\n",ImageBase); + LdrStartupAddr = ImageBase + NTHeaders->OptionalHeader.AddressOfEntryPoint; + + /* Create a section for NTDLL */ + Status = ZwCreateSection(&SectionHandle, + SECTION_ALL_ACCESS, + NULL, + NULL, + PAGE_READWRITE, + MEM_COMMIT, + FileHandle); + if (!NT_SUCCESS(Status)) + { + DPRINT("NTDLL create section failed "); + DbgPrintErrorMessage(Status); + ZwClose(FileHandle); + + return Status; + } + + /* Map the NTDLL into the process */ + InitialViewSize = DosHeader->e_lfanew + sizeof(IMAGE_NT_HEADERS) + + sizeof(IMAGE_SECTION_HEADER) * NTHeaders->FileHeader.NumberOfSections; + Status = ZwMapViewOfSection(SectionHandle, + ProcessHandle, + (PVOID *)&ImageBase, + 0, + InitialViewSize, + NULL, + &InitialViewSize, + 0, + MEM_COMMIT, + PAGE_READWRITE); + if (!NT_SUCCESS(Status)) + { + DPRINT("NTDLL map view of secion failed "); + DbgPrintErrorMessage(Status); + + /* FIXME: destroy the section here */ + + ZwClose(FileHandle); + + return Status; + } + for (i=0; iFileHeader.NumberOfSections; i++) + { + PIMAGE_SECTION_HEADER Sections; + LARGE_INTEGER Offset; + ULONG Base; + + Sections = (PIMAGE_SECTION_HEADER)SECHDROFFSET(BlockBuffer); + Base = Sections[i].VirtualAddress + ImageBase; + SET_LARGE_INTEGER_HIGH_PART(Offset,0); + SET_LARGE_INTEGER_LOW_PART(Offset,Sections[i].PointerToRawData); + Status = ZwMapViewOfSection(SectionHandle, + ProcessHandle, + (PVOID *)&Base, + 0, + Sections[i].Misc.VirtualSize, + &Offset, + &Sections[i].Misc.VirtualSize, + 0, + MEM_COMMIT, + PAGE_READWRITE); + if (!NT_SUCCESS(Status)) + { + DPRINT("NTDLL map view of secion failed "); + DbgPrintErrorMessage(Status); + + /* FIXME: destroy the section here */ + + ZwClose(FileHandle); + return Status; + } + } + ZwClose(FileHandle); + + /* Open process image to determine ImageBase and StackBase/Size */ InitializeObjectAttributes(&FileObjectAttributes, Filename, 0, NULL, NULL); - Status = ZwOpenFile(&FileHandle, 0, &FileObjectAttributes, NULL, 0, 0); + DPRINT("Opening image file %w\n",FileObjectAttributes.ObjectName->Buffer); + Status = ZwOpenFile(&FileHandle, FILE_ALL_ACCESS, &FileObjectAttributes, + NULL, 0, 0); if (!NT_SUCCESS(Status)) { + DPRINT("Image open failed "); + DbgPrintErrorMessage(Status); + return Status; } - - /* Build a module structure for the image */ - Module = ObCreateObject(ModuleHandle, - PROCESS_ALL_ACCESS, - NULL, - ObModuleType); - if (Module == NULL) - { - ZwClose(FileHandle); - return Status; - } - - /* Read first block of image to determine type */ Status = ZwReadFile(FileHandle, 0, 0, 0, 0, BlockBuffer, 1024, 0, 0); if (!NT_SUCCESS(Status)) { - ObDereferenceObject(*ModuleHandle); - *ModuleHandle = NULL; + DPRINT("Image header read failed "); + DbgPrintErrorMessage(Status); ZwClose(FileHandle); return Status; } - /* If MZ header exists */ - PEDosHeader = (PIMAGE_DOS_HEADER) BlockBuffer; - if (PEDosHeader->e_magic == IMAGE_DOS_MAGIC && - PEDosHeader->e_lfanew != 0L && - *(PULONG)((PUCHAR)BlockBuffer + PEDosHeader->e_lfanew) == IMAGE_PE_MAGIC) - { - Status = LdrProcessPEImage(ProcessHandle, - ModuleHandle, - FileHandle); - } - else if (PEDosHeader->e_magic == 0x54AD) - { - Status = LdrProcessMZImage(ProcessHandle, - ModuleHandle, - FileHandle); - } - else /* Assume bin format and load */ - { - Status = LdrProcessBinImage(ProcessHandle, - ModuleHandle, - FileHandle); - } - /* FIXME: {else} could check for a.out, ELF, COFF, etc. images here... */ + /* FIXME: this will fail if the NT headers are more than 1024 bytes from start */ - /* FIXME: should we unconditionally dereference the module handle here? */ + 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) + { + DPRINT("Image invalid format rc=%08lx\n", Status); + ZwClose(FileHandle); + + return STATUS_UNSUCCESSFUL; + } + NTHeaders = (PIMAGE_NT_HEADERS)(BlockBuffer + DosHeader->e_lfanew); + ImageBase = NTHeaders->OptionalHeader.ImageBase; + ImageSize = NTHeaders->OptionalHeader.SizeOfImage; + + /* Create a section for the image */ + Status = ZwCreateSection(&SectionHandle, + SECTION_ALL_ACCESS, + NULL, + NULL, + PAGE_READWRITE, + MEM_COMMIT, + FileHandle); if (!NT_SUCCESS(Status)) { - ObDereferenceObject(*ModuleHandle); - *ModuleHandle = NULL; + DPRINT("Image create section failed "); + DbgPrintErrorMessage(Status); + ZwClose(FileHandle); + + return Status; + } + + /* Map the image into the process */ + InitialViewSize = DosHeader->e_lfanew + sizeof(IMAGE_NT_HEADERS) + + sizeof(IMAGE_SECTION_HEADER) * NTHeaders->FileHeader.NumberOfSections; + DPRINT("InitialViewSize %x\n",InitialViewSize); + Status = ZwMapViewOfSection(SectionHandle, + ProcessHandle, + (PVOID *)&ImageBase, + 0, + InitialViewSize, + NULL, + &InitialViewSize, + 0, + MEM_COMMIT, + PAGE_READWRITE); + if (!NT_SUCCESS(Status)) + { + DPRINT("Image map view of section failed "); + DbgPrintErrorMessage(Status); + + /* FIXME: destroy the section here */ + + ZwClose(FileHandle); + + return Status; } ZwClose(FileHandle); - return Status; -} - -static NTSTATUS -LdrProcessMZImage(HANDLE ProcessHandle, - HANDLE ModuleHandle, - HANDLE FileHandle) -{ - - /* FIXME: map VDM into low memory */ - /* FIXME: Build/Load image sections */ - - return STATUS_NOT_IMPLEMENTED; -} - -static NTSTATUS -LdrProcessPEImage(HANDLE ProcessHandle, - HANDLE ModuleHandle, - HANDLE FileHandle) -{ - int i; - NTSTATUS Status; - PVOID BaseSection; - PIMAGE_DOS_HEADER DosHeader; - PIMAGE_NT_HEADERS NTHeaders; - PMODULE Module; - LARGE_INTEGER SectionOffset; - HANDLE SectionHandle; - - /* Allocate memory for headers */ - Module = HEADER_TO_BODY(ModuleHandle); - if (Module == NULL) - { - return STATUS_UNSUCCESSFUL; - } - DosHeader = (PIMAGE_DOS_HEADER)ExAllocatePool(NonPagedPool, - sizeof(IMAGE_DOS_HEADER) + - sizeof(IMAGE_NT_HEADERS)); - if (DosHeader == NULL) - { - return STATUS_UNSUCCESSFUL; - } - NTHeaders = (PIMAGE_NT_HEADERS)((PUCHAR) DosHeader + sizeof(IMAGE_DOS_HEADER)); - - /* Read the headers into memory */ - memset(Module, '\0', sizeof(PMODULE)); - Status = ZwReadFile(FileHandle, - NULL, NULL, NULL, NULL, - DosHeader, - sizeof(IMAGE_DOS_HEADER), - 0, 0); - if (!NT_SUCCESS(Status)) - { - ExFreePool(DosHeader); - return Status; - } - SET_LARGE_INTEGER_HIGH_PART(SectionOffset, 0); - SET_LARGE_INTEGER_LOW_PART(SectionOffset, DosHeader->e_lfanew); - Status = ZwReadFile(FileHandle, - NULL, NULL, NULL, NULL, - NTHeaders, - sizeof(IMAGE_NT_HEADERS), - &SectionOffset, - 0); - if (!NT_SUCCESS(Status)) - { - ExFreePool(DosHeader); - return Status; - } - - /* Create the section for the code */ - Status = ZwCreateSection(&SectionHandle, - SECTION_ALL_ACCESS, - NULL, - NULL, - PAGE_READWRITE, - MEM_COMMIT, - FileHandle); - if (!NT_SUCCESS(Status)) - { - return Status; - } - - /* Map the Image into the process */ - Module->Flags = MODULE_FLAG_PE; - Module->Base = (PVOID) NTHeaders->OptionalHeader.ImageBase; - Module->Size = NTHeaders->OptionalHeader.SizeOfImage; - Status = ZwMapViewOfSection(SectionHandle, - ProcessHandle, - &Module->Base, - 0, - Module->Size, - NULL, - &Module->Size, - 0, - MEM_COMMIT, - PAGE_READWRITE); - if (!NT_SUCCESS(Status)) - { - /* FIXME: destroy the section here */ - ExFreePool(DosHeader); - return Status; - } - - /* FIXME: create stack and other BSS sections */ - /* FIXME: if actual load address is different from ImageBase, then reloc */ - /* FIXME: do import fixups/load required libraries */ - -#if 0 - /* Load headers into virtual memory */ - Status = ZwReadFile(FileHandle, - NULL, NULL, NULL, NULL, - Module->Base, - NTHeaders->OptionalHeader.SizeOfHeaders, - 0, 0); - if (!NT_SUCCESS(Status)) - { - ZwFreeVirtualMemory(ProcessHandle, - Module->Base, - 0, - MEM_RELEASE); - ExFreePool(DosHeader); - return Status; - } - - /* Adjust module pointers into virtual memory */ - DosHeader = (PIMAGE_DOS_HEADER) Module->Base; - NTHeaders = (PIMAGE_NT_HEADERS) ((PUCHAR)Module->Base + - DosHeader->e_lfanew); - Module->Image.PE.FileHeader = (PIMAGE_FILE_HEADER) ((PUCHAR)NTHeaders + - sizeof(DWORD)); - Module->Image.PE.OptionalHeader = (PIMAGE_OPTIONAL_HEADER) - ((PUCHAR)Module->Image.PE.FileHeader + sizeof(IMAGE_FILE_HEADER)); - Module->Image.PE.SectionList = (PCOFF_SECTION_HEADER) ((PUCHAR)NTHeaders + - sizeof(IMAGE_NT_HEADERS)); - - /* Build Image Sections */ - /* FIXME: should probably use image directory to load sections. */ - for (i = 0; i < Module->Image.PE.FileHeader->NumberOfSections; i++) - { - DPRINT("section %d\n", i); - BaseSection = (PVOID)((PCHAR) Module->Base + - Module->Image.PE.SectionList[i].s_vaddr); - - /* Load code and initialized data sections from disk */ - if ((Module->Image.PE.SectionList[i].s_flags & STYP_TEXT) || - (Module->Image.PE.SectionList[i].s_flags & STYP_DATA)) - { - SET_LARGE_INTEGER_HIGH_PART(SectionOffset, 0); - SET_LARGE_INTEGER_LOW_PART(SectionOffset, - Module->Image.PE.SectionList[i].s_scnptr); - - /* FIXME: should probably map sections into sections */ - Status = ZwReadFile(FileHandle, - NULL, NULL, NULL, NULL, - Module->Base + Module->Image.PE.SectionList[i].s_vaddr, - min(Module->Image.PE.SectionList[i].s_size, - Module->Image.PE.SectionList[i].s_paddr), - &SectionOffset, 0); - if (!NT_SUCCESS(Status)) - { - ZwFreeVirtualMemory(ProcessHandle, - Module->Base, - 0, - MEM_RELEASE); - ExFreePool(DosHeader); - return Status; - } - } - else if (Module->Image.PE.SectionList[i].s_flags & STYP_BSS) - { - memset((PVOID)(Module->Base + - Module->Image.PE.SectionList[i].s_vaddr), - 0, - Module->Image.PE.SectionList[i].s_size); - } - } - - /* Resolve Import Library references */ - if (Module->Image.PE.OptionalHeader->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress) - { - PIMAGE_IMPORT_MODULE_DIRECTORY ImportModuleDirectory; - - /* Process each import module */ - ImportModuleDirectory = (PIMAGE_IMPORT_MODULE_DIRECTORY) - ((PUCHAR)Module->Base + Module->Image.PE.OptionalHeader-> - DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress); - while (ImportModuleDirectory->dwRVAModuleName) - { - PMODULE Library; - PVOID *LibraryExports; - PVOID *ImportAddressList; // was pImpAddr - PULONG FunctionNameList; - DWORD pName; - PWORD pHint; - - /* Load the library module into the process */ - /* FIXME: this should take a UNICODE string */ - Status = LdrLoadLibrary(ProcessHandle, - &Library, - (PCHAR)(Module->Base + - ImportModuleDirectory->dwRVAModuleName)); - if (!NT_SUCCESS(Status)) - { - /* FIXME: Dereference all loaded modules */ - ZwFreeVirtualMemory(ProcessHandle, - Module->Base, - 0, - MEM_RELEASE); - ExFreePool(DosHeader); - - return Status; - } - - /* Get the address of the export list for the library */ - LibraryExports = (PVOID *)(Library->Base + - Library->Image.PE.OptionalHeader-> - DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress + - sizeof(IMAGE_EXPORT_DIRECTORY)); - - /* Get the import address list */ - ImportAddressList = (PVOID *) - ((PCHAR)Module->Image.PE.OptionalHeader->ImageBase + - ImportModuleDirectory->dwRVAFunctionAddressList); - - /* Get the list of functions to import */ - if (ImportModuleDirectory->dwRVAFunctionNameList != 0) - { - FunctionNameList = (PULONG) ((PCHAR)Module->Base + - ImportModuleDirectory->dwRVAFunctionNameList); - } - else - { - FunctionNameList = (PULONG) ((PCHAR)Module->Base + - ImportModuleDirectory->dwRVAFunctionAddressList); - } - - /* Walk through function list and fixup addresses */ - while(*FunctionNameList != 0L) - { - if ((*FunctionNameList) & 0x80000000) // hint - { - *ImportAddressList = LibraryExports[(*FunctionNameList) & 0x7fffffff]; - } - else // hint-name - { - pName = (DWORD)((PCHAR)Module->Base + *FunctionNameList + 2); - pHint = (PWORD)((PCHAR)Module->Base + *FunctionNameList); - - /* FIXME: verify name */ - - *ImportAddressList = LibraryExports[*pHint]; - } - - /* FIXME: verify value of hint */ - - ImportAddressList++; - FunctionNameList++; - } - ImportModuleDirectory++; - } - } - - /* Do fixups */ - if (Module->Base != (PVOID)Module->Image.PE.OptionalHeader->ImageBase) - { - USHORT NumberOfEntries; - PUSHORT pValue16; - ULONG RelocationRVA; - ULONG Delta32, Offset; - PULONG pValue32; - PRELOCATION_DIRECTORY RelocationDir; - PRELOCATION_ENTRY RelocationBlock; - - RelocationRVA = NTHeaders->OptionalHeader.DataDirectory[ - IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress; - if (RelocationRVA) - { - RelocationDir = (PRELOCATION_DIRECTORY) - ((PCHAR)Module->Base + RelocationRVA); - while (RelocationDir->SizeOfBlock) - { - Delta32 = (unsigned long)(Module->Base - NTHeaders->OptionalHeader.ImageBase); - RelocationBlock = (PRELOCATION_ENTRY) - (RelocationRVA + Module->Base + 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; - switch (RelocationBlock[i].TypeOffset >> 12) - { - case TYPE_RELOC_ABSOLUTE: - break; - - case TYPE_RELOC_HIGH: - pValue16 = (PUSHORT) (Module->Base + Offset); - *pValue16 += Delta32 >> 16; - break; - - case TYPE_RELOC_LOW: - pValue16 = (PUSHORT)(Module->Base + Offset); - *pValue16 += Delta32 & 0xffff; - break; - - case TYPE_RELOC_HIGHLOW: - pValue32 = (PULONG) (Module->Base + Offset); - *pValue32 += Delta32; - break; - - case TYPE_RELOC_HIGHADJ: - /* FIXME: do the highadjust fixup */ - DbgPrint("TYPE_RELOC_HIGHADJ fixup not implemented, sorry\n"); -// break; - - default: - DbgPrint("unexpected fixup type\n"); - - /* FIXME: Dereference all loaded modules */ - - ZwFreeVirtualMemory(ProcessHandle, - Module->Base, - 0, - MEM_RELEASE); - ExFreePool(DosHeader); - return STATUS_UNSUCCESSFUL; - } - } - RelocationRVA += RelocationDir->SizeOfBlock; - RelocationDir = (PRELOCATION_DIRECTORY)((PCHAR)Module->Base + - RelocationRVA); - } - } - } -#endif - - /* FIXME: Create the stack for the process */ - /* FIXME: Setup the context for the initial thread */ - /* FIXME: Create the initial thread */ - -// fail: ZwFreeVirtualMemory(ProcessHandle, Module->ImageBase, 0, MEM_RELEASE); - ExFreePool(DosHeader); - - return STATUS_NOT_IMPLEMENTED; -} - -NTSTATUS -LdrProcessBinImage(HANDLE ProcessHandle, - HANDLE ModuleHandle, - HANDLE FileHandle) -{ - NTSTATUS Status; - FILE_STANDARD_INFORMATION FileStdInfo; - ULONG SectionSize; - HANDLE ThreadHandle; - CONTEXT Context; - HANDLE SectionHandle; - PVOID BaseAddress; - - /* FIXME: should set module pointers */ - - /* Get the size of the file for the section */ - Status = ZwQueryInformationFile(FileHandle, - NULL, - &FileStdInfo, - sizeof(FileStdInfo), - FileStandardInformation); - if (!NT_SUCCESS(Status)) - { - return Status; - } - - /* Create the section for the code */ - Status = ZwCreateSection(&SectionHandle, - SECTION_ALL_ACCESS, - NULL, - NULL, - PAGE_READWRITE, - MEM_COMMIT, - FileHandle); - if (!NT_SUCCESS(Status)) - { - return Status; - } - - /* Map a view of the section into the desired process */ - BaseAddress = (PVOID)0x10000; - SectionSize = GET_LARGE_INTEGER_LOW_PART(FileStdInfo.AllocationSize); - Status = ZwMapViewOfSection(SectionHandle, - ProcessHandle, - &BaseAddress, - 0, - SectionSize, - NULL, - &SectionSize, - 0, - MEM_COMMIT, - PAGE_READWRITE); - if (!NT_SUCCESS(Status)) - { - /* FIXME: destroy the section here */ - return Status; - } - - /* Setup the context for the initial thread */ - memset(&Context,0,sizeof(CONTEXT)); - Context.SegSs = USER_DS; - Context.Esp = 0x2000; - Context.EFlags = 0x202; - Context.SegCs = USER_CS; - Context.Eip = 0x10000; - Context.SegDs = USER_DS; - Context.SegEs = USER_DS; - Context.SegFs = USER_DS; - Context.SegGs = USER_DS; - - /* Create the stack for the process */ - BaseAddress = (PVOID) 0x1000; - SectionSize = 0x1000; + /* Create page backed section for stack */ + StackBase = (STACK_TOP - NTHeaders->OptionalHeader.SizeOfStackReserve); + StackSize = NTHeaders->OptionalHeader.SizeOfStackReserve; Status = ZwAllocateVirtualMemory(ProcessHandle, - &BaseAddress, + (PVOID *)&StackBase, 0, - &SectionSize, + &StackSize, MEM_COMMIT, PAGE_READWRITE); if (!NT_SUCCESS(Status)) { + DPRINT("Stack allocation failed "); + DbgPrintErrorMessage(Status); + /* FIXME: unmap the section here */ /* FIXME: destroy the section here */ return Status; } - /* Create the initial thread */ + ZwDuplicateObject(NtCurrentProcess(), + &SectionHandle, + ProcessHandle, + &DupSectionHandle, + 0, + FALSE, + DUPLICATE_SAME_ACCESS); + + ZwWriteVirtualMemory(ProcessHandle, + STACK_TOP - 4, + &ImageBase, + sizeof(ImageBase), + &BytesWritten); + ZwWriteVirtualMemory(ProcessHandle, + STACK_TOP - 8, + &DupSectionHandle, + sizeof(DupSectionHandle), + &BytesWritten); + + /* Initialize context to point to LdrStartup */ + memset(&Context,0,sizeof(CONTEXT)); + Context.SegSs = USER_DS; + Context.Esp = STACK_TOP - 12; + Context.EFlags = 0x202; + Context.SegCs = USER_CS; + Context.Eip = LdrStartupAddr; + Context.SegDs = USER_DS; + Context.SegEs = USER_DS; + Context.SegFs = USER_DS; + Context.SegGs = USER_DS; + + DPRINT("LdrStartupAddr %x\n",LdrStartupAddr); + /* FIXME: Create process and let 'er rip */ Status = ZwCreateThread(&ThreadHandle, THREAD_ALL_ACCESS, NULL, @@ -1456,13 +1186,46 @@ LdrProcessBinImage(HANDLE ProcessHandle, FALSE); if (!NT_SUCCESS(Status)) { + DPRINT("Thread creation failed "); + DbgPrintErrorMessage(Status); + /* FIXME: destroy the stack memory block here */ /* FIXME: unmap the section here */ /* FIXME: destroy the section here */ - return Status; + + return Status; } return STATUS_SUCCESS; } +NTSTATUS LdrLoadInitialProcess(VOID) +{ + NTSTATUS Status; + HANDLE ProcessHandle; + ANSI_STRING AnsiString; + UNICODE_STRING ProcessName; + Status = ZwCreateProcess(&ProcessHandle, + PROCESS_ALL_ACCESS, + NULL, + SystemProcessHandle, + FALSE, + NULL, + NULL, + NULL); + if (!NT_SUCCESS(Status)) + { + DbgPrint("Could not create process\n"); + return Status; + } + + RtlInitAnsiString(&AnsiString, "\\??\\C:\\reactos\\system\\shell.exe"); + RtlAnsiStringToUnicodeString(&ProcessName, &AnsiString, TRUE); + + Status = LdrLoadImage(ProcessHandle, &ProcessName); + + RtlFreeUnicodeString(&ProcessName); + + return Status; +} diff --git a/reactos/ntoskrnl/makefile_rex b/reactos/ntoskrnl/makefile_rex index 39d75cfb241..7b673417aa4 100644 --- a/reactos/ntoskrnl/makefile_rex +++ b/reactos/ntoskrnl/makefile_rex @@ -1,4 +1,4 @@ -all: kimage +all: ntoskrnl.exe utils/pe2bin/pe2bin$(EXE_POSTFIX) # # Defines $(HAL_OBJECTS) @@ -12,10 +12,10 @@ NT_OBJECTS = nt/port.o nt/channel.o nt/ntevent.o nt/nttimer.o nt/atom.o \ RTL_OBJECTS = rtl/vsprintf.o rtl/lookas.o rtl/unicode.o rtl/strtok.o \ rtl/time.o rtl/unalign.o rtl/mem.o rtl/largeint.o rtl/ctype.o \ rtl/list.o rtl/slist.o rtl/interlck.o rtl/return.o \ - rtl/wstring.o + rtl/wstring.o rtl/memcpy.o KE_OBJECTS = ke/main.o ke/timer.o ke/error.o ke/catch.o ke/exports.o \ - ke/module.o ke/dpc.o ke/wait.o ke/kqueue.o ke/dispatch.o \ + ke/dpc.o ke/wait.o ke/kqueue.o ke/dispatch.o \ ke/sem.o ke/critical.o ke/event.o ke/apc.o ke/bug.o \ ke/mutex.o ke/kernel.o ke/ldt.o ke/apchelp.o @@ -103,27 +103,49 @@ OBJECTS = objects/hal.o objects/ke.o objects/rtl.o objects/mm.o \ objects/se.o objects/cm.o objects/tst.o objects/dbg.o\ objects/nt.o objects/cc.o objects/ldr.o +utils/pe2bin/pe2bin$(EXE_POSTFIX): utils/pe2bin/pe2bin.c + $(NATIVE_CC) -I../include -g utils/pe2bin/pe2bin.c -o utils/pe2bin/pe2bin$(EXE_POSTFIX) + utils/export/export$(EXE_POSTFIX): utils/export/export.c $(NATIVE_CC) -g utils/export/export.c -o utils/export/export$(EXE_POSTFIX) ke/exports.o: exports.lst utils/export/export$(EXE_POSTFIX) +ifeq ($(HOST),mingw32-windows) + .\\utils\\export\\export$(EXE_POSTFIX) < exports.lst > ke\\exports.c +else utils/export/export$(EXE_POSTFIX) < exports.lst > ke/exports.c +endif $(CC) $(CFLAGS) -c ke/exports.c -o ke/exports.o -kimage: $(OBJECTS) - $(LD) --defsym _end=end --defsym _etext=etext $(KERNEL_BFD_TARGET) -Ttext c0000000 $(LDFLAGS) $(OBJECTS) $(LIBGCC) -o kimage - $(NM) --numeric-sort kimage > kernel.sym - $(OBJCOPY) -S --gap-fill=0 -O binary kimage kimage.bin - -old_kimage: $(OBJECTS) - $(LD) --defsym _end=end --defsym _etext=etext --oformat=$(KERNEL_BFD_TARGET) -Ttext c0000000 $(LDFLAGS) $(OBJECTS) $(LIBGCC) -o kimage - $(NM) --numeric-sort kimage > kernel.sym - $(OBJCOPY) -S --gap-fill=0 -O binary kimage kimage.bin - +ntoskrnl.exe: $(OBJECTS) ntoskrnl.def + $(LD) -r $(OBJECTS) -o ntoskrnl.o + $(DLLTOOL) --dllname ntoskrnl.exe --def ntoskrnl.def \ + --output-lib ntoskrnl.a + $(CC) -specs=../specs -mdll -o junk.tmp \ + -Wl,--image-base,0xc0000000 \ + -Wl,--file-alignment,0x1000 \ + -Wl,--section-alignment,0x1000 \ + -Wl,--defsym,_end=end \ + -Wl,--defsym,_edata=__data_end__ \ + -Wl,--defsym,_etext=etext -Wl,--base-file,base.tmp ntoskrnl.o + - $(RM) junk.tmp + $(DLLTOOL) --dllname ntoskrnl.exe --base-file base.tmp \ + --output-exp temp.exp --def ntoskrnl.def + - $(RM) base.tmp + $(CC) -specs=../specs -mdll -o ntoskrnl.exe ntoskrnl.o \ + -Wl,--image-base,0xc0000000 \ + -Wl,--file-alignment,0x1000 \ + -Wl,--section-alignment,0x1000 \ + -Wl,--defsym,_end=end \ + -Wl,--defsym,_edata=__data_end__ \ + -Wl,--defsym,_etext=etext -Wl,temp.exp + - $(RM) temp.exp + $(NM) --numeric-sort ntoskrnl.exe > ntoskrnl.sym + dummy: ex/napi.o: ex/napi.c ../include/ntdll/napi.h -WITH_DEBUGGING = yes +#WITH_DEBUGGING = yes WIN32_LEAN_AND_MEAN = yes include ../rules.mak diff --git a/reactos/ntoskrnl/mm/freelist.new.c b/reactos/ntoskrnl/mm/freelist.new.c new file mode 100644 index 00000000000..da419965d5f --- /dev/null +++ b/reactos/ntoskrnl/mm/freelist.new.c @@ -0,0 +1,149 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: ntoskrnl/mm/freelist.c + * PURPOSE: Handle the list of free physical pages + * PROGRAMMER: David Welch (welch@cwcom.net) + * UPDATE HISTORY: + * 27/05/98: Created + * 18/08/98: Added a fix from Robert Bergkvist + */ + +/* INCLUDES ****************************************************************/ + +#include +#include +#include +#include +#include +#include + +#define NDEBUG +#include + +/* TYPES *******************************************************************/ + +#define PHYSICAL_PAGE_FREE (0x1) +#define PHYSICAL_PAGE_INUSE (0x2) +#define PHYSICAL_PAGE_BIOS (0x4) + +#define PHYSICAL_PAGE_PAGEIN (0x8) + +typedef struct _PHYSICAL_PAGE +{ + ULONG Flags; + LIST_ENTRY ListEntry; +} PHYSICAL_PAGE, *PPHYSICAL_PAGE; + +/* GLOBALS ****************************************************************/ + +static PAGE_ARRAY[] PageArray; + +static LIST_ENTRY UsedPageListHead; +static LIST_ENTRY FreePageListHead; +static LIST_ENTRY BiosPageListHead; + +/* FUNCTIONS *************************************************************/ + +PVOID MmMapKernelPage(PVOID PhysicalAddress) +{ + +} + +VOID MmInitializePageList(PVOID FirstKernelAddress, + PVOID LastKernelAddress, + ULONG MemorySizeInPages) +/* + * FUNCTION: Initializes the page list with all pages free + * except those known to be reserved and those used by the kernel + * ARGUMENTS: + * PageBuffer = Page sized buffer + * FirstKernelAddress = First physical address used by the kernel + * LastKernelAddress = Last physical address used by the kernel + */ +{ + PHYSICAL_PAGE PageArray[]; + ULONG i; + ULONG Reserved; + + InitializeListHead(&UsedPageListHead); + InitializeListHead(&FreePageListHead); + InitializeListHead(&BiosPageListHead); + + Reserved = (MemorySizeInPages * sizeof(PHYSICAL_PAGE)) / PAGESIZE; + + PageArray = MmMapKernelPages(LastKernelAddress + PAGESIZE, + Reserved); + + for (i=1; i= (0xa0000 / PAGESIZE) && + i < (0x100000 / PAGESIZE)) + { + PageArray[i].Flags = PHYSICAL_PAGE_BIOS; + InsertTailList(&BiosPageListHead, + &PageArray[CurrentOffset].ListEntry); + } + else if (i >= (FirstKernelAddress / PAGE_SIZE) && + i < (LastKernelAddress / PAGESIZE)) + { + PageArray[i].Flags = PHYSICAL_PAGE_INUSE; + InsertTailList(&UsedPageListHead, + &PageArray[CurrentOffset].ListEntry); + } + else + { + PageArray[i].Flags = PHYSICAL_PAGE_FREE; + InsertTailList(&UsedPageListHead, + &PageArray[CurrentOffset].ListEntry); + } + } + +} + +VOID MmFreePage(PVOID PhysicalAddress, + PVOID Nr) +{ + ULONG i; + ULONG Start = PhysicalAddress / PAGESIZE; + + for (i=0; i++; iFlags = PHYSICAL_PAGE_INUSE; + RemoveEntryList(&PageDescriptor->ListEntry); + InsertTailList(&UsedPageListHead, + &PageDescriptor->ListEntry); + return(i * PAGESIZE); + } + } + return(NULL); +} + +PVOID MmAllocPage(VOID) +{ + PLIST_ENTRY ListEntry; + PPHYSICAL_PAGE PageDescriptor; + + ListEntry = RemoveHeadList(&FreePageListHead); + PageDescriptor = CONTAING_RECORD(ListEntry, PHYSICAL_PAGE, ListEntry); + + PageDescriptor->Flags = PHYSICAL_PAGE_INUSE; + InsertTailList(&UsedPageListHead, + ListEntry); + + return((PageDescriptor - PageArray) / sizeof(PHYSICAL_PAGE) * PAGESIZE); +} diff --git a/reactos/ntoskrnl/mm/mdl.c b/reactos/ntoskrnl/mm/mdl.c index d8446cb66f3..2ede1589405 100644 --- a/reactos/ntoskrnl/mm/mdl.c +++ b/reactos/ntoskrnl/mm/mdl.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #define NDEBUG diff --git a/reactos/ntoskrnl/mm/mm.c b/reactos/ntoskrnl/mm/mm.c index 53a5c6cf7a2..ec1775dfa85 100644 --- a/reactos/ntoskrnl/mm/mm.c +++ b/reactos/ntoskrnl/mm/mm.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include diff --git a/reactos/ntoskrnl/mm/npool.c b/reactos/ntoskrnl/mm/npool.c index 627d6a55968..1f7f3e5d900 100644 --- a/reactos/ntoskrnl/mm/npool.c +++ b/reactos/ntoskrnl/mm/npool.c @@ -15,6 +15,7 @@ /* INCLUDES ****************************************************************/ +#include #include #include #include diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index d27a28445e6..835b413083b 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -227,16 +227,16 @@ NTSTATUS ZwOpenSection(PHANDLE SectionHandle, return(Status); } -NTSTATUS NtMapViewOfSection(HANDLE SectionHandle, - HANDLE ProcessHandle, - PVOID* BaseAddress, - ULONG ZeroBits, - ULONG CommitSize, - PLARGE_INTEGER SectionOffset, - PULONG ViewSize, - SECTION_INHERIT InheritDisposition, - ULONG AllocationType, - ULONG Protect) +NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle, + HANDLE ProcessHandle, + PVOID* BaseAddress, + ULONG ZeroBits, + ULONG CommitSize, + PLARGE_INTEGER SectionOffset, + PULONG ViewSize, + SECTION_INHERIT InheritDisposition, + ULONG AllocationType, + ULONG Protect) { return(ZwMapViewOfSection(SectionHandle, ProcessHandle, @@ -250,16 +250,16 @@ NTSTATUS NtMapViewOfSection(HANDLE SectionHandle, Protect)); } -NTSTATUS ZwMapViewOfSection(HANDLE SectionHandle, - HANDLE ProcessHandle, - PVOID* BaseAddress, - ULONG ZeroBits, - ULONG CommitSize, - PLARGE_INTEGER SectionOffset, - PULONG ViewSize, - SECTION_INHERIT InheritDisposition, - ULONG AllocationType, - ULONG Protect) +NTSTATUS STDCALL ZwMapViewOfSection(HANDLE SectionHandle, + HANDLE ProcessHandle, + PVOID* BaseAddress, + ULONG ZeroBits, + ULONG CommitSize, + PLARGE_INTEGER SectionOffset, + PULONG ViewSize, + SECTION_INHERIT InheritDisposition, + ULONG AllocationType, + ULONG Protect) /* * FUNCTION: Maps a view of a section into the virtual address space of a * process @@ -287,8 +287,21 @@ NTSTATUS ZwMapViewOfSection(HANDLE SectionHandle, MEMORY_AREA* Result; NTSTATUS Status; - DPRINT("ZwMapViewOfSection(SectionHandle %x, ProcessHandle %x)\n", - SectionHandle,ProcessHandle); + DPRINT("ZwMapViewOfSection(Section:%08lx, Process:%08lx,\n" + " Base:%08lx, ZeroBits:%08lx, CommitSize:%08lx,\n" + " SectionOffs:%08lx, *ViewSize:%08lx, InheritDisp:%08lx,\n" + " AllocType:%08lx, Protect:%08lx)\n", + SectionHandle, + ProcessHandle, + BaseAddress, + ZeroBits, + CommitSize, + SectionOffset, + *ViewSize, + InheritDisposition, + AllocationType, + Protect); + DPRINT(" *Base:%08lx\n", *BaseAddress); Status = ObReferenceObjectByHandle(SectionHandle, SECTION_MAP_READ, @@ -298,10 +311,12 @@ NTSTATUS ZwMapViewOfSection(HANDLE SectionHandle, NULL); if (Status != STATUS_SUCCESS) { - DPRINT("%s() = %x\n",Status); + DPRINT("ObReference failed rc=%x\n",Status); return(Status); } + DPRINT("Section %x\n",Section); + Status = ObReferenceObjectByHandle(ProcessHandle, PROCESS_VM_OPERATION, PsProcessType, @@ -313,24 +328,39 @@ NTSTATUS ZwMapViewOfSection(HANDLE SectionHandle, return(Status); } + DPRINT("ViewSize %x\n",ViewSize); if ((*ViewSize) > GET_LARGE_INTEGER_LOW_PART(Section->MaximumSize)) { (*ViewSize) = GET_LARGE_INTEGER_LOW_PART(Section->MaximumSize); } - MmCreateMemoryArea(UserMode, - Process, - MEMORY_AREA_SECTION_VIEW_COMMIT, - BaseAddress, - *ViewSize, - Protect, - &Result); + Status = MmCreateMemoryArea(UserMode, + Process, + MEMORY_AREA_SECTION_VIEW_COMMIT, + BaseAddress, + *ViewSize, + Protect, + &Result); + if (!NT_SUCCESS(Status)) + { + DPRINT("ZwMapViewOfSection() = %x\n",Status); + return(Status); + } Result->Data.SectionData.Section = Section; - Result->Data.SectionData.ViewOffset = GET_LARGE_INTEGER_LOW_PART(*SectionOffset); + + DPRINT("SectionOffset %x\n",SectionOffset); + + if (SectionOffset == NULL) + { + Result->Data.SectionData.ViewOffset = 0; + } + else + { + Result->Data.SectionData.ViewOffset = + GET_LARGE_INTEGER_LOW_PART(*SectionOffset); + } DPRINT("*BaseAddress %x\n",*BaseAddress); - DPRINT("Result->Data.SectionData.Section->FileObject %x\n", - Result->Data.SectionData.Section->FileObject); return(STATUS_SUCCESS); } diff --git a/reactos/ntoskrnl/mm/virtual.c b/reactos/ntoskrnl/mm/virtual.c index 8eb74148501..ccc3f871013 100644 --- a/reactos/ntoskrnl/mm/virtual.c +++ b/reactos/ntoskrnl/mm/virtual.c @@ -12,8 +12,6 @@ /* INCLUDE *****************************************************************/ -#include - #include #include #include @@ -317,7 +315,7 @@ ZwAllocateVirtualMemory( NTSTATUS Status; DPRINT("ZwAllocateVirtualMemory(ProcessHandle %x, *BaseAddress %x, " - "ZeroBits %d, RegionSize %d, AllocationType %x, Protect %x)\n", + "ZeroBits %d, *RegionSize %x, AllocationType %x, Protect %x)\n", ProcessHandle,*BaseAddress,ZeroBits,*RegionSize,AllocationType, Protect); diff --git a/reactos/ntoskrnl/ntoskrnl.def b/reactos/ntoskrnl/ntoskrnl.def new file mode 100644 index 00000000000..8d7930855d0 --- /dev/null +++ b/reactos/ntoskrnl/ntoskrnl.def @@ -0,0 +1,66 @@ +EXPORTS +__putchar +__getscreensize +__goxy +__wherey +__wherex +memcpy +strtok +toupper +wcschr +wcslen +wtolower +DbgPrint +ExAllocatePool +ExFreePool +HalGetInterruptVector +KeBugCheck +KeBugCheckEx +KeFlushIoBuffers +KeInitializeDpc +KeInitializeEvent +KeInitializeSpinLock +KeInsertQueueDpc +KeLowerIrql +KeStallExecutionProcessor +KeSynchronizeExecution +KeRaiseIrql +KeWaitForSingleObject +InitializeObjectAttributes +IoAllocateController +IoAttachDeviceToDeviceStack +IoBuildSynchronousFsdRequest +IoCallDriver +IoCompleteRequest +IoConnectInterrupt +IoCreateController +IoCreateDevice +IoCreateSymbolicLink +IoDeleteController +IoDisconnectInterrupt +IoFreeController +IoGetCurrentIrpStackLocation +IoInitializeDpcRequest +IoInitializeTimer +IoMarkIrpPending +IoRegisterFileSystem +IoRequestDpc +IoStartPacket +IoStartNextPacket +IoStartNextPacketByKey +IoStartTimer +MmGetSystemAddressForMdl +RtlAnsiStringToUnicodeString +RtlConvertLongToLargeInteger +RtlConvertUlongToLargeInteger +RtlCopyMemory +RtlEnlargedIntegerMultiply +RtlExtendedIntegerMultiply +RtlFreeUnicodeString +RtlInitAnsiString +RtlInitUnicodeString +RtlLargeIntegerAdd +RtlLargeIntegerGreaterThan +RtlLargeIntegerShiftRight +RtlZeroMemory +ZwCreateDirectoryObject@12 diff --git a/reactos/ntoskrnl/ntoskrnl.full.def b/reactos/ntoskrnl/ntoskrnl.full.def new file mode 100644 index 00000000000..a1fddc0c618 --- /dev/null +++ b/reactos/ntoskrnl/ntoskrnl.full.def @@ -0,0 +1,1070 @@ +EXPORTS +ExAcquireFastMutexUnsafe +ExInterlockedAddLargeStatistic +ExInterlockedCompareExchange64 +ExInterlockedPopEntrySList +ExInterlockedPushEntrySList +ExReleaseFastMutexUnsafe +ExReleaseResourceLite +ExfInterlockedAddUlong +ExfInterlockedInsertHeadList +ExfInterlockedInsertTailList +ExfInterlockedPopEntryList +ExfInterlockedPushEntryList +ExfInterlockedRemoveHeadList +Exfi386InterlockedDecrementLong +Exfi386InterlockedExchangeUlong +Exfi386InterlockedIncrementLong +InterlockedCompareExchange +InterlockedDecrement +InterlockedExchange +InterlockedExchangeAdd +InterlockedIncrement +IofCallDriver +IofCompleteRequest +KeSetSwapContextNotifyRoutine +KeSetThreadSelectNotifyRoutine +KeSetTimeUpdateNotifyRoutine +KefAcquireSpinLockAtDpcLevel +KefReleaseSpinLockFromDpcLevel +KiAcquireSpinLock +KiReleaseSpinLock +ObfDereferenceObject +ObfReferenceObject +Kei386EoiHelper +Kii386SpinOnSpinLock +CcCanIWrite +CcCopyRead +CcCopyWrite +CcDeferWrite +CcFastCopyRead +CcFastCopyWrite +CcFastMdlReadWait +CcFastReadNotPossible +CcFastReadWait +CcFlushCache +CcGetDirtyPages +CcGetFileObjectFromBcb +CcGetFileObjectFromSectionPtrs +CcGetLsnForFileObject +CcInitializeCacheMap +CcIsThereDirtyData +CcMapData +CcMdlRead +CcMdlReadComplete +CcMdlWriteComplete +CcPinMappedData +CcPinRead +CcPrepareMdlWrite +CcPreparePinWrite +CcPurgeCacheSection +CcRepinBcb +CcScheduleReadAhead +CcSetAdditionalCacheAttributes +CcSetBcbOwnerPointer +CcSetDirtyPageThreshold +CcSetDirtyPinnedData +CcSetFileSizes +CcSetLogHandleForFile +CcSetReadAheadGranularity +CcUninitializeCacheMap +CcUnpinData +CcUnpinDataForThread +CcUnpinRepinnedBcb +CcZeroData +DbgBreakPoint +DbgBreakPointWithStatus +DbgLoadImageSymbols +DbgPrint +DbgPrompt +ExAcquireResourceExclusive +ExAcquireResourceExclusiveLite +ExAcquireResourceSharedLite +ExAcquireSharedStarveExclusive +ExAcquireSharedWaitForExclusive +ExAllocateFromPagedLookasideList +ExAllocatePool +ExAllocatePoolWithQuota +ExAllocatePoolWithQuotaTag +ExAllocatePoolWithTag +ExConvertExclusiveToSharedLite +ExCreateCallback +ExDeleteNPagedLookasideList +ExDeletePagedLookasideList +ExDeleteResource +ExDeleteResourceLite +ExDesktopObjectType +ExDisableResourceBoostLite +ExEnumHandleTable +ExEventObjectType +ExExtendZone +ExFreePool +ExFreeToPagedLookasideList +ExGetExclusiveWaiterCount +ExGetPreviousMode +ExGetSharedWaiterCount +ExInitializeNPagedLookasideList +ExInitializePagedLookasideList +ExInitializeResource +ExInitializeResourceLite +ExInitializeZone +ExInterlockedAddLargeInteger +ExInterlockedAddUlong +ExInterlockedDecrementLong +ExInterlockedExchangeUlong +ExInterlockedExtendZone +ExInterlockedIncrementLong +ExInterlockedInsertHeadList +ExInterlockedInsertTailList +ExInterlockedPopEntryList +ExInterlockedPushEntryList +ExInterlockedRemoveHeadList +ExIsProcessorFeaturePresent +ExIsResourceAcquiredExclusiveLite +ExIsResourceAcquiredSharedLite +ExLocalTimeToSystemTime +ExNotifyCallback +ExPostSystemEvent +ExQueryPoolBlockSize +ExQueueWorkItem +ExRaiseAccessViolation +ExRaiseDatatypeMisalignment +ExRaiseException +ExRaiseHardError +ExRaiseStatus +ExRegisterCallback +ExReinitializeResourceLite +ExReleaseResourceForThread +ExReleaseResourceForThreadLite +ExSetResourceOwnerPointer +ExSystemExceptionFilter +ExSystemTimeToLocalTime +ExUnregisterCallback +ExWindowStationObjectType +Exi386InterlockedDecrementLong +Exi386InterlockedExchangeUlong +Exi386InterlockedIncrementLong +FsRtlAddLargeMcbEntry +FsRtlAddMcbEntry +FsRtlAddToTunnelCache +FsRtlAllocatePool +FsRtlAllocatePoolWithQuota +FsRtlAllocatePoolWithQuotaTag +FsRtlAllocatePoolWithTag +FsRtlAllocateResource +FsRtlAreNamesEqual +FsRtlBalanceReads +FsRtlCheckLockForReadAccess +FsRtlCheckLockForWriteAccess +FsRtlCheckOplock +FsRtlCopyRead +FsRtlCopyWrite +FsRtlCurrentBatchOplock +FsRtlDeleteKeyFromTunnelCache +FsRtlDeleteTunnelCache +FsRtlDeregisterUncProvider +FsRtlDissectDbcs +FsRtlDissectName +FsRtlDoesDbcsContainWildCards +FsRtlDoesNameContainWildCards +FsRtlFastCheckLockForRead +FsRtlFastCheckLockForWrite +FsRtlFastUnlockAll +FsRtlFastUnlockAllByKey +FsRtlFastUnlockSingle +FsRtlFindInTunnelCache +FsRtlGetFileSize +FsRtlGetNextFileLock +FsRtlGetNextLargeMcbEntry +FsRtlGetNextMcbEntry +FsRtlInitializeFileLock +FsRtlInitializeLargeMcb +FsRtlInitializeMcb +FsRtlInitializeOplock +FsRtlInitializeTunnelCache +FsRtlIsDbcsInExpression +FsRtlIsFatDbcsLegal +FsRtlIsHpfsDbcsLegal +FsRtlIsNameInExpression +FsRtlIsNtstatusExpected +FsRtlIsTotalDeviceFailure +FsRtlLegalAnsiCharacterArray +FsRtlLookupLargeMcbEntry +FsRtlLookupLastLargeMcbEntry +FsRtlLookupLastMcbEntry +FsRtlLookupMcbEntry +FsRtlMdlRead +FsRtlMdlReadComplete +FsRtlMdlReadCompleteDev +FsRtlMdlReadDev +FsRtlMdlWriteComplete +FsRtlMdlWriteCompleteDev +FsRtlNormalizeNtstatus +FsRtlNotifyChangeDirectory +FsRtlNotifyCleanup +FsRtlNotifyFullChangeDirectory +FsRtlNotifyFullReportChange +FsRtlNotifyInitializeSync +FsRtlNotifyReportChange +FsRtlNotifyUninitializeSync +FsRtlNumberOfRunsInLargeMcb +FsRtlNumberOfRunsInMcb +FsRtlOplockFsctrl +FsRtlOplockIsFastIoPossible +FsRtlPostPagingFileStackOverflow +FsRtlPostStackOverflow +FsRtlPrepareMdlWrite +FsRtlPrepareMdlWriteDev +FsRtlPrivateLock +FsRtlProcessFileLock +FsRtlRegisterUncProvider +FsRtlRemoveLargeMcbEntry +FsRtlRemoveMcbEntry +FsRtlSplitLargeMcb +FsRtlSyncVolumes +FsRtlTruncateLargeMcb +FsRtlTruncateMcb +FsRtlUninitializeFileLock +FsRtlUninitializeLargeMcb +FsRtlUninitializeMcb +FsRtlUninitializeOplock +HalDispatchTable +HalPrivateDispatchTable +IoAcquireCancelSpinLock +IoAcquireVpbSpinLock +IoAdapterObjectType +IoAllocateAdapterChannel +IoAllocateController +IoAllocateErrorLogEntry +IoAllocateIrp +IoAllocateMdl +IoAssignResources +IoAttachDevice +IoAttachDeviceByPointer +IoAttachDeviceToDeviceStack +IoBuildAsynchronousFsdRequest +IoBuildDeviceIoControlRequest +IoBuildPartialMdl +IoBuildSynchronousFsdRequest +IoCallDriver +IoCancelIrp +IoCheckDesiredAccess +IoCheckEaBufferValidity +IoCheckFunctionAccess +IoCheckShareAccess +IoCompleteRequest +IoConnectInterrupt +IoCreateController +IoCreateDevice +IoCreateFile +IoCreateNotificationEvent +IoCreateStreamFileObject +IoCreateSymbolicLink +IoCreateSynchronizationEvent +IoCreateUnprotectedSymbolicLink +IoDeleteController +IoDeleteDevice +IoDeleteSymbolicLink +IoDetachDevice +IoDeviceHandlerObjectSize +IoDeviceHandlerObjectType +IoDeviceObjectType +IoDisconnectInterrupt +IoDriverObjectType +IoEnqueueIrp +IoFastQueryNetworkAttributes +IoFileObjectType +IoFreeController +IoFreeIrp +IoFreeMdl +IoGetAttachedDevice +IoGetBaseFileSystemDeviceObject +IoGetConfigurationInformation +IoGetCurrentProcess +IoGetDeviceObjectPointer +IoGetDeviceToVerify +IoGetFileObjectGenericMapping +IoGetInitialStack +IoGetRelatedDeviceObject +IoGetRequestorProcess +IoGetStackLimits +IoGetTopLevelIrp +IoInitializeIrp +IoInitializeTimer +IoIsOperationSynchronous +IoIsSystemThread +IoMakeAssociatedIrp +IoOpenDeviceInstanceKey +IoPageRead +IoQueryDeviceDescription +IoQueryDeviceEnumInfo +IoQueryFileInformation +IoQueryVolumeInformation +IoQueueThreadIrp +IoRaiseHardError +IoRaiseInformationalHardError +IoReadOperationCount +IoReadTransferCount +IoRegisterDriverReinitialization +IoRegisterFileSystem +IoRegisterFsRegistrationChange +IoRegisterShutdownNotification +IoReleaseCancelSpinLock +IoReleaseVpbSpinLock +IoRemoveShareAccess +IoReportHalResourceUsage +IoReportResourceUsage +IoSetDeviceToVerify +IoSetHardErrorOrVerifyDevice +IoSetInformation +IoSetShareAccess +IoSetThreadHardErrorMode +IoSetTopLevelIrp +IoStartNextPacket +IoStartNextPacketByKey +IoStartPacket +IoStartTimer +IoStatisticsLock +IoStopTimer +IoSynchronousPageWrite +IoThreadToProcess +IoUnregisterFileSystem +IoUnregisterFsRegistrationChange +IoUnregisterShutdownNotification +IoUpdateShareAccess +IoVerifyVolume +IoWriteErrorLogEntry +IoWriteOperationCount +IoWriteTransferCount +KdDebuggerEnabled +KdDebuggerNotPresent +KdPollBreakIn +Ke386CallBios +Ke386IoSetAccessProcess +Ke386QueryIoAccessMap +Ke386SetIoAccessMap +KeAcquireSpinLockAtDpcLevel +KeAddSystemServiceTable +KeAttachProcess +KeBoostCurrentThread +KeBugCheck +KeBugCheckEx +KeCancelTimer +KeClearEvent +KeConnectInterrupt +KeDcacheFlushCount +KeDelayExecutionThread +KeDeregisterBugCheckCallback +KeDetachProcess +KeDisconnectInterrupt +KeEnterCriticalRegion +KeEnterKernelDebugger +KeFindConfigurationEntry +KeFindConfigurationNextEntry +KeFlushEntireTb +KeGetCurrentThread +KeGetPreviousMode +KeI386AbiosCall +KeI386AllocateGdtSelectors +KeI386Call16BitCStyleFunction +KeI386Call16BitFunction +KeI386FlatToGdtSelector +KeI386GetLid +KeI386MachineType +KeI386ReleaseGdtSelectors +KeI386ReleaseLid +KeI386SetGdtSelector +KeIcacheFlushCount +KeInitializeApc +KeInitializeDeviceQueue +KeInitializeDpc +KeInitializeEvent +KeInitializeInterrupt +KeInitializeMutant +KeInitializeMutex +KeInitializeQueue +KeInitializeSemaphore +KeInitializeSpinLock +KeInitializeTimer +KeInitializeTimerEx +KeInsertByKeyDeviceQueue +KeInsertDeviceQueue +KeInsertHeadQueue +KeInsertQueue +KeInsertQueueApc +KeInsertQueueDpc +KeIsExecutingDpc +KeLeaveCriticalRegion +KeLoaderBlock +KeNumberProcessors +KeProfileInterrupt +KeProfileInterruptWithSource +KePulseEvent +KeQuerySystemTime +KeQueryTickCount +KeQueryTimeIncrement +KeRaiseUserException +KeReadStateEvent +KeReadStateMutant +KeReadStateMutex +KeReadStateQueue +KeReadStateSemaphore +KeReadStateTimer +KeRegisterBugCheckCallback +KeReleaseMutant +KeReleaseMutex +KeReleaseSemaphore +KeReleaseSpinLockFromDpcLevel +KeRemoveByKeyDeviceQueue +KeRemoveDeviceQueue +KeRemoveEntryDeviceQueue +KeRemoveQueue +KeRemoveQueueDpc +KeResetEvent +KeRestoreFloatingPointState +KeRundownQueue +KeSaveFloatingPointState +KeServiceDescriptorTable +KeSetAffinityThread +KeSetBasePriorityThread +KeSetDmaIoCoherency +KeSetEvent +KeSetEventBoostPriority +KeSetIdealProcessorThread +KeSetImportanceDpc +KeSetKernelStackSwapEnable +KeSetPriorityThread +KeSetProfileIrql +KeSetTargetProcessorDpc +KeSetTimeIncrement +KeSetTimer +KeSetTimerEx +KeSynchronizeExecution +KeTerminateThread +KeTickCount +KeUpdateRunTime +KeUpdateSystemTime +KeUserModeCallback +KeWaitForMultipleObjects +KeWaitForMutexObject +KeWaitForSingleObject +KiBugCheckData +KiCoprocessorError +KiDeliverApc +KiDispatchInterrupt +KiIpiServiceRoutine +KiUnexpectedInterrupt +LdrAccessResource +LdrEnumResources +LdrFindResourceDirectory_U +LdrFindResource_U +LpcRequestPort +LsaCallAuthenticationPackage +LsaDeregisterLogonProcess +LsaFreeReturnBuffer +LsaLogonUser +LsaLookupAuthenticationPackage +LsaRegisterLogonProcess +MmAdjustWorkingSetSize +MmAllocateContiguousMemory +MmAllocateNonCachedMemory +MmBuildMdlForNonPagedPool +MmCanFileBeTruncated +MmCreateMdl +MmCreateSection +MmDbgTranslatePhysicalAddress +MmDisableModifiedWriteOfSection +MmFlushImageSection +MmForceSectionClosed +MmFreeContiguousMemory +MmFreeNonCachedMemory +MmGetPhysicalAddress +MmGrowKernelStack +MmIsAddressValid +MmIsNonPagedSystemAddressValid +MmIsRecursiveIoFault +MmIsThisAnNtAsSystem +MmLockPagableDataSection +MmLockPagableImageSection +MmLockPagableSectionByHandle +MmMapIoSpace +MmMapLockedPages +MmMapMemoryDumpMdl +MmMapVideoDisplay +MmMapViewInSystemSpace +MmMapViewOfSection +MmPageEntireDriver +MmProbeAndLockPages +MmQuerySystemSize +MmResetDriverPaging +MmSectionObjectType +MmSecureVirtualMemory +MmSetAddressRangeModified +MmSetBankedSection +MmSizeOfMdl +MmUnlockPagableImageSection +MmUnlockPages +MmUnmapIoSpace +MmUnmapLockedPages +MmUnmapVideoDisplay +MmUnmapViewInSystemSpace +MmUnmapViewOfSection +MmUnsecureVirtualMemory +NlsAnsiCodePage +NlsLeadByteInfo +NlsMbCodePageTag +NlsMbOemCodePageTag +NlsOemLeadByteInfo +NtAddAtom +NtAdjustPrivilegesToken +NtAllocateLocallyUniqueId +NtAllocateUuids +NtAllocateVirtualMemory +NtBuildNumber +NtClose +NtConnectPort +NtCreateEvent +NtCreateFile +NtCreateSection +NtDeleteAtom +NtDeleteFile +NtDeviceIoControlFile +NtDuplicateObject +NtDuplicateToken +NtFindAtom +NtFreeVirtualMemory +NtFsControlFile +NtGlobalFlag +NtLockFile +NtMapViewOfSection +NtNotifyChangeDirectoryFile +NtOpenFile +NtOpenProcess +NtOpenProcessToken +NtQueryDirectoryFile +NtQueryEaFile +NtQueryInformationAtom +NtQueryInformationFile +NtQueryInformationProcess +NtQueryInformationToken +NtQueryOleDirectoryFile +NtQuerySecurityObject +NtQueryVolumeInformationFile +NtReadFile +NtRequestPort +NtRequestWaitReplyPort +NtSetEvent +NtSetInformationFile +NtSetInformationProcess +NtSetInformationThread +NtSetSecurityObject +NtUnlockFile +NtVdmControl +NtWaitForSingleObject +NtWriteFile +ObAssignSecurity +ObCheckCreateObjectAccess +ObCheckObjectAccess +ObCreateObject +ObDereferenceObject +ObFindHandleForObject +ObGetObjectPointerCount +ObGetObjectSecurity +ObInsertObject +ObMakeTemporaryObject +ObOpenObjectByName +ObOpenObjectByPointer +ObQueryNameString +ObQueryObjectAuditingByHandle +ObReferenceObjectByHandle +ObReferenceObjectByName +ObReferenceObjectByPointer +ObReleaseObjectSecurity +ObSetSecurityDescriptorInfo +PfxFindPrefix +PfxInitialize +PfxInsertPrefix +PfxRemovePrefix +PoQueryPowerSequence +PoRequestPowerChange +PoSetDeviceIdleDetection +ProbeForWrite +PsAssignImpersonationToken +PsChargePoolQuota +PsCreateSystemProcess +PsCreateSystemThread +PsCreateWin32Process +PsEstablishWin32Callouts +PsGetCurrentProcessId +PsGetCurrentThreadId +PsGetProcessExitTime +PsGetVersion +PsImpersonateClient +PsInitialSystemProcess +PsIsThreadTerminating +PsLookupProcessByProcessId +PsLookupProcessThreadByCid +PsLookupThreadByThreadId +PsProcessType +PsReferenceImpersonationToken +PsReferencePrimaryToken +PsReturnPoolQuota +PsRevertToSelf +PsSetCreateProcessNotifyRoutine +PsSetCreateThreadNotifyRoutine +PsSetLegoNotifyRoutine +PsSetProcessPriorityByClass +PsTerminateSystemThread +PsThreadType +READ_REGISTER_BUFFER_UCHAR +READ_REGISTER_BUFFER_ULONG +READ_REGISTER_BUFFER_USHORT +READ_REGISTER_UCHAR +READ_REGISTER_ULONG +READ_REGISTER_USHORT +RtlAbsoluteToSelfRelativeSD +RtlAddAccessAllowedAce +RtlAddAce +RtlAddAtomToAtomTable +RtlAllocateAndInitializeSid +RtlAllocateHeap +RtlAnsiCharToUnicodeChar +RtlAnsiStringToUnicodeSize +RtlAnsiStringToUnicodeString +RtlAppendAsciizToString +RtlAppendStringToString +RtlAppendUnicodeStringToString +RtlAppendUnicodeToString +RtlAreAllAccessesGranted +RtlAreAnyAccessesGranted +RtlAreBitsClear +RtlAreBitsSet +RtlAssert +RtlCaptureStackBackTrace +RtlCharToInteger +RtlCheckRegistryKey +RtlClearAllBits +RtlClearBits +RtlCompareMemory +RtlCompareMemoryUlong +RtlCompareString +RtlCompareUnicodeString +RtlCompressBuffer +RtlCompressChunks +RtlConvertLongToLargeInteger +RtlConvertSidToUnicodeString +RtlConvertUlongToLargeInteger +RtlCopyLuid +RtlCopySid +RtlCopyString +RtlCopyUnicodeString +RtlCreateAcl +RtlCreateAtomTable +RtlCreateHeap +RtlCreateRegistryKey +RtlCreateSecurityDescriptor +RtlCreateUnicodeString +RtlCustomCPToUnicodeN +RtlDecompressBuffer +RtlDecompressChunks +RtlDecompressFragment +RtlDelete +RtlDeleteAtomFromAtomTable +RtlDeleteElementGenericTable +RtlDeleteNoSplay +RtlDeleteRegistryValue +RtlDescribeChunk +RtlDestroyAtomTable +RtlDestroyHeap +RtlDowncaseUnicodeString +RtlEmptyAtomTable +RtlEnlargedIntegerMultiply +RtlEnlargedUnsignedDivide +RtlEnlargedUnsignedMultiply +RtlEnumerateGenericTable +RtlEnumerateGenericTableWithoutSplaying +RtlEqualLuid +RtlEqualSid +RtlEqualString +RtlEqualUnicodeString +RtlExtendedIntegerMultiply +RtlExtendedLargeIntegerDivide +RtlExtendedMagicDivide +RtlFillMemory +RtlFillMemoryUlong +RtlFindClearBits +RtlFindClearBitsAndSet +RtlFindFirstRunClear +RtlFindFirstRunSet +RtlFindLongestRunClear +RtlFindLongestRunSet +RtlFindMessage +RtlFindSetBits +RtlFindSetBitsAndClear +RtlFindUnicodePrefix +RtlFormatCurrentUserKeyPath +RtlFreeAnsiString +RtlFreeHeap +RtlFreeOemString +RtlFreeUnicodeString +RtlGenerate8dot3Name +RtlGetCallersAddress +RtlGetCompressionWorkSpaceSize +RtlGetDaclSecurityDescriptor +RtlGetDefaultCodePage +RtlGetElementGenericTable +RtlGetGroupSecurityDescriptor +RtlGetOwnerSecurityDescriptor +RtlImageNtHeader +RtlInitAnsiString +RtlInitCodePageTable +RtlInitString +RtlInitUnicodeString +RtlInitializeBitMap +RtlInitializeGenericTable +RtlInitializeSid +RtlInitializeUnicodePrefix +RtlInsertElementGenericTable +RtlInsertUnicodePrefix +RtlIntegerToChar +RtlIntegerToUnicodeString +RtlIsNameLegalDOS8Dot3 +RtlLargeIntegerAdd +RtlLargeIntegerArithmeticShift +RtlLargeIntegerDivide +RtlLargeIntegerNegate +RtlLargeIntegerShiftLeft +RtlLargeIntegerShiftRight +RtlLargeIntegerSubtract +RtlLengthRequiredSid +RtlLengthSecurityDescriptor +RtlLengthSid +RtlLookupAtomInAtomTable +RtlLookupElementGenericTable +RtlMapGenericMask +RtlMoveMemory +RtlMultiByteToUnicodeN +RtlMultiByteToUnicodeSize +RtlNextUnicodePrefix +RtlNtStatusToDosError +RtlNtStatusToDosErrorNoTeb +RtlNumberGenericTableElements +RtlNumberOfClearBits +RtlNumberOfSetBits +RtlOemStringToCountedUnicodeString +RtlOemStringToUnicodeSize +RtlOemStringToUnicodeString +RtlOemToUnicodeN +RtlPinAtomInAtomTable +RtlPrefixString +RtlPrefixUnicodeString +RtlQueryAtomInAtomTable +RtlQueryRegistryValues +RtlQueryTimeZoneInformation +RtlRaiseException +RtlRandom +RtlRemoveUnicodePrefix +RtlReserveChunk +RtlSecondsSince1970ToTime +RtlSecondsSince1980ToTime +RtlSetAllBits +RtlSetBits +RtlSetDaclSecurityDescriptor +RtlSetGroupSecurityDescriptor +RtlSetOwnerSecurityDescriptor +RtlSetSaclSecurityDescriptor +RtlSetTimeZoneInformation +RtlSplay +RtlSubAuthorityCountSid +RtlSubAuthoritySid +RtlTimeFieldsToTime +RtlTimeToSecondsSince1970 +RtlTimeToSecondsSince1980 +RtlTimeToTimeFields +RtlUnicodeStringToAnsiSize +RtlUnicodeStringToAnsiString +RtlUnicodeStringToCountedOemString +RtlUnicodeStringToInteger +RtlUnicodeStringToOemSize +RtlUnicodeStringToOemString +RtlUnicodeToCustomCPN +RtlUnicodeToMultiByteN +RtlUnicodeToMultiByteSize +RtlUnicodeToOemN +RtlUnwind +RtlUpcaseUnicodeChar +RtlUpcaseUnicodeString +RtlUpcaseUnicodeStringToAnsiString +RtlUpcaseUnicodeStringToCountedOemString +RtlUpcaseUnicodeStringToOemString +RtlUpcaseUnicodeToCustomCPN +RtlUpcaseUnicodeToMultiByteN +RtlUpcaseUnicodeToOemN +RtlUpperChar +RtlUpperString +RtlValidSecurityDescriptor +RtlValidSid +RtlWriteRegistryValue +RtlZeroHeap +RtlZeroMemory +RtlxAnsiStringToUnicodeSize +RtlxOemStringToUnicodeSize +RtlxUnicodeStringToAnsiSize +RtlxUnicodeStringToOemSize +SeAccessCheck +SeAppendPrivileges +SeAssignSecurity +SeAuditingFileEvents +SeAuditingFileOrGlobalEvents +SeCaptureSecurityDescriptor +SeCaptureSubjectContext +SeCloseObjectAuditAlarm +SeCreateAccessState +SeCreateClientSecurity +SeDeassignSecurity +SeDeleteAccessState +SeDeleteObjectAuditAlarm +SeExports +SeFreePrivileges +SeImpersonateClient +SeLockSubjectContext +sionForTerminationNotification +SeOpenObjectAuditAlarm +SeOpenObjectForDeleteAuditAlarm +SePrivilegeCheck +SePrivilegeObjectAuditAlarm +SePublicDefaultDacl +SeQueryAuthenticationIdToken +SeQuerySecurityDescriptorInfo +SeRegisterLogonSessionTerminatedRoutine +SeReleaseSecurityDescriptor +SeReleaseSubjectContext +SeSetAccessStateGenericMapping +SeSetSecurityDescriptorInfo +SeSinglePrivilegeCheck +SeSystemDefaultDacl +SeTokenImpersonationLevel +SeTokenType +SeUnlockSubjectContext +SeUnregisterLogonSessionTerminatedRoutine +SeValidSecurityDescriptor +WRITE_REGISTER_BUFFER_UCHAR +WRITE_REGISTER_BUFFER_ULONG +WRITE_REGISTER_BUFFER_USHORT +WRITE_REGISTER_UCHAR +WRITE_REGISTER_ULONG +WRITE_REGISTER_USHORT +ZwAccessCheckAndAuditAlarm +ZwAlertThread +ZwAllocateVirtualMemory +ZwClearEvent +ZwClose +ZwCloseObjectAuditAlarm +ZwConnectPort +ZwCreateDirectoryObject +ZwCreateEvent +ZwCreateFile +ZwCreateKey +ZwCreateSection +ZwCreateSymbolicLinkObject +ZwDeleteFile +ZwDeleteKey +ZwDeleteValueKey +ZwDeviceIoControlFile +ZwDisplayString +ZwDuplicateObject +ZwDuplicateToken +ZwEnumerateKey +ZwEnumerateValueKey +ZwFlushInstructionCache +ZwFlushKey +ZwFreeVirtualMemory +ZwFsControlFile +ZwLoadDriver +ZwLoadKey +ZwMakeTemporaryObject +ZwMapViewOfSection +ZwNotifyChangeKey +ZwOpenDirectoryObject +ZwOpenEvent +ZwOpenFile +ZwOpenKey +ZwOpenProcess +ZwOpenProcessToken +ZwOpenSection +ZwOpenSymbolicLinkObject +ZwOpenThread +ZwOpenThreadToken +ZwPulseEvent +ZwQueryDefaultLocale +ZwQueryDirectoryFile +ZwQueryInformationFile +ZwQueryInformationProcess +ZwQueryInformationToken +ZwQueryKey +ZwQueryObject +ZwQuerySection +ZwQuerySecurityObject +ZwQuerySymbolicLinkObject +ZwQuerySystemInformation +ZwQueryValueKey +ZwQueryVolumeInformationFile +ZwReadFile +ZwReplaceKey +ZwRequestWaitReplyPort +ZwResetEvent +ZwSaveKey +ZwSetDefaultLocale +ZwSetEvent +ZwSetInformationFile +ZwSetInformationObject +ZwSetInformationProcess +ZwSetInformationThread +ZwSetSystemInformation +ZwSetSystemTime +ZwSetValueKey +ZwTerminateProcess +ZwUnloadDriver +ZwUnloadKey +ZwUnmapViewOfSection +ZwWaitForMultipleObjects +ZwWaitForSingleObject +ZwWriteFile +ZwYieldExecution +_abnormal_termination +_alldiv +_allmul +_allrem +_allshl +_allshr +_aulldiv +_aullrem +_aullshr +_except_handler2 +_global_unwind2 +_itoa +_local_unwind2 +_purecall +_snprintf +_snwprintf +_stricmp +_strlwr +_strnicmp +_strnset +_strrev +_strset +_strupr +_vsnprintf +_wcsicmp +_wcslwr +_wcsnicmp +_wcsnset +_wcsrev +_wcsupr +atoi +atol +isdigit +islower +isprint +isspace +isupper +isxdigit +mbstowcs +mbtowc +memchr +memcpy +memmove +memset +qsort +rand +sprintf +srand +strcat +strchr +strcmp +strcpy +strlen +strncat +strncmp +strncpy +strrchr +strspn +strstr +swprintf +tolower +toupper +towlower +towupper +vsprintf +wcscat +wcschr +wcscmp +wcscpy +wcscspn +wcslen +wcsncat +wcsncmp +wcsncpy +wcsrchr +wcsspn +wcsstr +wcstombs +wctomb +KdPortSave +KeRaiseIrqlToDpcLevel +ExReleaseFastMutex +ExAcquireFastMutex +ExTryToAcquireFastMutex +HalRequestSoftwareInterrupt +HalReturnToFirmware +HalDisplayString +HalQueryRealTimeClock +HalSetRealTimeClock +HalSetTimeIncrement +KeGetCurrentIrql +KeQueryPerformanceCounter +HalGetEnvironmentVariable +HalSetEnvironmentVariable +KfRaiseIrql +HalInitSystem +HalReportResourceUsage +HalAllProcessorsStarted +HalAllocateAdapterChannel +HalGetInterruptVector +HalTranslateBusAddress +HalAdjustResourceList +IoAssignDriveLetters +IoReadPartitionTable +HalAllocateCommonBuffer +KdPortInitialize +KdPortGetByte +KdPortPutByte +KdPortPollByte +KfLowerIrql +KdPortRestore +READ_PORT_ULONG +READ_PORT_USHORT +READ_PORT_UCHAR +WRITE_PORT_ULONG +WRITE_PORT_USHORT +WRITE_PORT_UCHAR +HalInitializeProcessor +HalProcessorIdle +HalClearSoftwareInterrupt +KeRaiseIrqlToSynchLevel +HalHandleNMI +HalBeginSystemInterrupt +HalEndSystemInterrupt +HalEnableSystemInterrupt +HalDisableSystemInterrupt +HalSystemVectorDispatchEntry +KeRaiseIrql +KeLowerIrql +HalSetProfileInterval +HalStartProfileInterrupt +HalStopProfileInterrupt +HalQueryDisplayParameters +KfReleaseSpinLock +KfAcquireSpinLock +KeFlushWriteBuffer +KeStallExecutionProcessor diff --git a/reactos/ntoskrnl/ob/dirobj.c b/reactos/ntoskrnl/ob/dirobj.c index cc6bd8e1ede..bff9f584bfc 100644 --- a/reactos/ntoskrnl/ob/dirobj.c +++ b/reactos/ntoskrnl/ob/dirobj.c @@ -10,8 +10,7 @@ /* INCLUDES ***************************************************************/ -#include -#include +#include #include #include #include @@ -203,18 +202,18 @@ NTSTATUS ZwQueryDirectoryObject(IN HANDLE DirObjHandle, } -NTSTATUS NtCreateDirectoryObject(PHANDLE DirectoryHandle, - ACCESS_MASK DesiredAccess, - POBJECT_ATTRIBUTES ObjectAttributes) +NTSTATUS STDCALL NtCreateDirectoryObject(PHANDLE DirectoryHandle, + ACCESS_MASK DesiredAccess, + POBJECT_ATTRIBUTES ObjectAttributes) { return(ZwCreateDirectoryObject(DirectoryHandle, DesiredAccess, ObjectAttributes)); } -NTSTATUS ZwCreateDirectoryObject(PHANDLE DirectoryHandle, - ACCESS_MASK DesiredAccess, - POBJECT_ATTRIBUTES ObjectAttributes) +NTSTATUS STDCALL ZwCreateDirectoryObject(PHANDLE DirectoryHandle, + ACCESS_MASK DesiredAccess, + POBJECT_ATTRIBUTES ObjectAttributes) /* * FUNCTION: Creates or opens a directory object (a container for other * objects) diff --git a/reactos/ntoskrnl/ob/handle.c b/reactos/ntoskrnl/ob/handle.c index 15d6ad9ed10..2c9820767bb 100644 --- a/reactos/ntoskrnl/ob/handle.c +++ b/reactos/ntoskrnl/ob/handle.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #define NDEBUG diff --git a/reactos/ntoskrnl/ob/namespc.c b/reactos/ntoskrnl/ob/namespc.c index 15b29f4068f..8fea636ebe4 100644 --- a/reactos/ntoskrnl/ob/namespc.c +++ b/reactos/ntoskrnl/ob/namespc.c @@ -10,8 +10,7 @@ /* INCLUDES ***************************************************************/ -#include -#include +#include #include #include #include @@ -74,7 +73,7 @@ VOID ObAddEntryDirectory(PDIRECTORY_OBJECT Parent, KIRQL oldlvl; POBJECT_HEADER Header = BODY_TO_HEADER(Object); - RtlInitUnicodeString(&Header->Name, wstrdup(Name)); + RtlInitUnicodeString(&Header->Name, wcsdup(Name)); Header->Parent = Parent; KeAcquireSpinLock(&Parent->Lock, &oldlvl); diff --git a/reactos/ntoskrnl/ob/ntobj.c b/reactos/ntoskrnl/ob/ntobj.c index 31651f5681f..1ef60c81de2 100644 --- a/reactos/ntoskrnl/ob/ntobj.c +++ b/reactos/ntoskrnl/ob/ntobj.c @@ -10,9 +10,9 @@ /* INCLUDES *****************************************************************/ +#include #include #include -#include #include #define NDEBUG diff --git a/reactos/ntoskrnl/ob/object.c b/reactos/ntoskrnl/ob/object.c index d0a32783764..26754409e0c 100644 --- a/reactos/ntoskrnl/ob/object.c +++ b/reactos/ntoskrnl/ob/object.c @@ -10,10 +10,10 @@ /* INCLUDES *****************************************************************/ +#include #include #include -#include -#include +#include #define NDEBUG #include diff --git a/reactos/ntoskrnl/ps/process.c b/reactos/ntoskrnl/ps/process.c index a8e6b7d508c..8c73a7f86d0 100644 --- a/reactos/ntoskrnl/ps/process.c +++ b/reactos/ntoskrnl/ps/process.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #define NDEBUG diff --git a/reactos/ntoskrnl/ps/thread.c b/reactos/ntoskrnl/ps/thread.c index eb6838a348e..8ddc880cbd3 100644 --- a/reactos/ntoskrnl/ps/thread.c +++ b/reactos/ntoskrnl/ps/thread.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include diff --git a/reactos/ntoskrnl/rtl/ctype.c b/reactos/ntoskrnl/rtl/ctype.c index cbdb1133369..60eded49792 100644 --- a/reactos/ntoskrnl/rtl/ctype.c +++ b/reactos/ntoskrnl/rtl/ctype.c @@ -4,7 +4,7 @@ * Copyright (C) 1991, 1992 Linus Torvalds */ -#include +#include #if 0 char _ctmp; @@ -35,3 +35,36 @@ _L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L, /* 224-239 */ _L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L}; /* 240-255 */ #endif +int toupper(int c) +{ + if ('a' <= c && 'z' >= c) + { + return(c + 'A' - 'a'); + } + return(c); +} + +int tolower(int c) +{ + if ('A' <= c && 'Z' >= c) + { + return(c + 'a' - 'A'); + } + return(c); +} + +int islower(int c) +{ + return(('a' <= c && 'z' >= c)); +} + +int isdigit(int c) +{ + return(('0' <= c && '9' >= c)); +} + +int isxdigit(int c) +{ + return(('0' <= c && '9' >= c) || ('a' <= 'c' && 'f' >= 'c') || + ('A' <= c && 'Z' >= c)); +} diff --git a/reactos/ntoskrnl/rtl/mem.c b/reactos/ntoskrnl/rtl/mem.c index 26d9aa715e7..7d6aab2633f 100644 --- a/reactos/ntoskrnl/rtl/mem.c +++ b/reactos/ntoskrnl/rtl/mem.c @@ -10,8 +10,9 @@ /* INCLUDES *****************************************************************/ -#include #include +#include +#include #define NDEBUG #include diff --git a/reactos/ntoskrnl/rtl/memcpy.c b/reactos/ntoskrnl/rtl/memcpy.c new file mode 100644 index 00000000000..0c7dab7ac8a --- /dev/null +++ b/reactos/ntoskrnl/rtl/memcpy.c @@ -0,0 +1,31 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: ntoskrnl/rtl/memcpy.c + * PROGRAMMER: David Welch (welch@cwcom.net) + * UPDATE HISTORY: + */ + +/* INCLUDES *****************************************************************/ + +#include +#include + +#define NDEBUG +#include + +/* FUNCTIONS *****************************************************************/ + +#undef memcpy +void *memcpy (void *to, const void *from, size_t count) +{ + register char *f = from; + register char *t = to; + register int i = count; + + while (i-- > 0) + *t++ = *f++; + + return to; +} + diff --git a/reactos/ntoskrnl/rtl/strtok.c b/reactos/ntoskrnl/rtl/strtok.c index 69c8abf520d..4f18a67d3bb 100644 --- a/reactos/ntoskrnl/rtl/strtok.c +++ b/reactos/ntoskrnl/rtl/strtok.c @@ -17,6 +17,54 @@ /* FUNCTIONS *****************************************************************/ +char* strtok(char *s, const char *delim) +{ + const char *spanp; + int c, sc; + char *tok; + static char *last; + + + if (s == NULL && (s = last) == NULL) + return (NULL); + + /* + * Skip (span) leading delimiters (s += strspn(s, delim), sort of). + */ + cont: + c = *s++; + for (spanp = delim; (sc = *spanp++) != 0;) { + if (c == sc) + goto cont; + } + + if (c == 0) { /* no non-delimiter characters */ + last = NULL; + return (NULL); + } + tok = s - 1; + + /* + * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). + * Note that delim must have one NUL; we stop if we see that, too. + */ + for (;;) { + c = *s++; + spanp = delim; + do { + if ((sc = *spanp++) == c) { + if (c == 0) + s = NULL; + else + s[-1] = 0; + last = s; + return (tok); + } + } while (sc != 0); + } + /* NOTREACHED */ +} + PWSTR RtlStrtok(PUNICODE_STRING _string, PWSTR _sep, PWSTR* temp) /* diff --git a/reactos/ntoskrnl/rtl/time.c b/reactos/ntoskrnl/rtl/time.c index be78a125efd..7fdab2cf7d2 100644 --- a/reactos/ntoskrnl/rtl/time.c +++ b/reactos/ntoskrnl/rtl/time.c @@ -61,7 +61,7 @@ VOID RtlTimeToTimeFields(PLARGE_INTEGER liTime, int LeapSecondCorrections, SecondsInDay, CurYear; int LeapYear, CurMonth, GMTOffset; long int Days; - long long int Time = *(long long int *)liTime; + long long int Time = *(long long int *)&liTime; /* Extract millisecond from time and convert time into seconds */ TimeFields->Milliseconds = (CSHORT) ((Time % TICKSPERSEC) / TICKSPERMSEC); diff --git a/reactos/ntoskrnl/rtl/unicode.c b/reactos/ntoskrnl/rtl/unicode.c index cb0fbfeab45..dac951859c1 100644 --- a/reactos/ntoskrnl/rtl/unicode.c +++ b/reactos/ntoskrnl/rtl/unicode.c @@ -8,14 +8,13 @@ * Created 10/08/98 */ -#include -#include +#include #include #include #include -#include +#include #define NDEBUG #include @@ -107,7 +106,7 @@ NTSTATUS RtlAppendUnicodeStringToString(IN OUT PUNICODE_STRING Destination, NTSTATUS RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination, IN PWSTR Source) { - unsigned long i, slen=wstrlen(Source); + unsigned long i, slen=wcslen(Source); if(Destination->MaximumLength-Destination->Length-slen<0) return STATUS_BUFFER_TOO_SMALL; @@ -362,7 +361,7 @@ VOID RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString, } else { - DestSize=wstrlen((PWSTR)SourceString); + DestSize=wcslen((PWSTR)SourceString); DestinationString->Length=DestSize; DestinationString->MaximumLength=DestSize+1; DestinationString->Buffer=(PWSTR)SourceString; diff --git a/reactos/ntoskrnl/rtl/vsprintf.c b/reactos/ntoskrnl/rtl/vsprintf.c index 07239410835..8f54ff5eb0f 100644 --- a/reactos/ntoskrnl/rtl/vsprintf.c +++ b/reactos/ntoskrnl/rtl/vsprintf.c @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include diff --git a/reactos/ntoskrnl/rtl/wstring.c b/reactos/ntoskrnl/rtl/wstring.c index 4925ada4144..be99d628c7b 100644 --- a/reactos/ntoskrnl/rtl/wstring.c +++ b/reactos/ntoskrnl/rtl/wstring.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/rtl/wstring.c * PURPOSE: Wide string functions - * PROGRAMMER: David Welch (welch@mcmail.com) + * PROGRAMMER: David Welch (welch@cwcom.net) * UPDATE HISTORY: * Created 22/05/98 * 1998/12/04 RJJ Cleaned up and added i386 def checks @@ -12,26 +12,27 @@ /* INCLUDES *****************************************************************/ #include -#include +#include #define NDEBUG #include +/* GLOBALS *****************************************************************/ + wchar_t * ___wcstok = NULL; /* FUNCTIONS *****************************************************************/ -wchar_t* wstrdup(const wchar_t* src) +wchar_t* wcsdup(wchar_t* src) { wchar_t* dest; - dest = ExAllocatePool(NonPagedPool, (wstrlen(src)+1)*2); + dest = ExAllocatePool(NonPagedPool, (wcslen(src)+1)*2); wcscpy(dest,src); return(dest); } -wchar_t * -wcscat(wchar_t *dest, const wchar_t *src) +wchar_t * wcscat(wchar_t *dest, const wchar_t *src) { int i, j; @@ -53,7 +54,7 @@ wcschr(const wchar_t *str, wchar_t ch) { if ((*str) == ch) { - return str; + return (wchar_t *) str; } str++; } @@ -77,7 +78,7 @@ wchar_t towupper(wchar_t w) int wcsicmp(const wchar_t* cs, const wchar_t* ct) { - while (*cs != '\0' && *ct != '\0' && towupper(*cs) == towupper(*ct)) + while (*cs != '\0' && *ct != '\0' && wtoupper(*cs) == wtoupper(*ct)) { cs++; ct++; @@ -109,99 +110,12 @@ wchar_t* wcscpy(wchar_t* str1, const wchar_t* str2) return(str1); } -#ifdef i386 - -size_t -wcscspn(const wchar_t *cs, const wchar_t *ct) +size_t wcscspn(const wchar_t *cs, const wchar_t *ct) { - register wchar_t * __res; - __asm__ __volatile__( - "cld\n\t" - "movl %4,%%edi\n\t" - "repne\n\t" - "scasw\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "movl %%ecx,%%edx\n" - "1:\tlodsw\n\t" - "testw %%eax,%%eax\n\t" - "je 2f\n\t" - "movl %4,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne\n\t" - "scasw\n\t" - "jne 1b\n" - "2:\tdecl %0" - : "=S" (__res) - : "a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) - : "eax","ecx","edx","edi"); - - return __res-cs; + UNIMPLEMENTED; } -#else - -size_t -wcscspn(const wchar_t *cs, const wchar_t *ct) -{ -UNIMPLEMENTED; -} - -#endif - -#if 0 - -int -wcsicmp(const wchar_t *cs,const wchar_t *ct) -{ - register int __res; - - __asm__ __volatile__( - "cld\n" - "1:\tmovw (%%esi), %%eax\n\t" - "movw (%%edi), %%edx \n\t" - "cmpw $0x5A, %%eax\n\t" - "ja 2f\t\n" - "cmpw $0x40, %%eax\t\n" - "jbe 2f\t\n" - "addw $0x20, %%eax\t\n" - "2:\t cmpw $0x5A, %%edx\t\n" - "ja 3f\t\n" - "cmpw $0x40, %%edx\t\n" - "jbe 3f\t\n" - "addw $0x20, %%edx\t\n" - "3:\t inc %%esi\t\n" - "inc %%esi\t\n" - "inc %%edi\t\n" - "inc %%edi\t\n" - "cmpw %%eax, %%edx\t\n" - "jne 4f\n\t" - "cmpw $00, %%eax\n\t" - "jne 1b\n\t" - "xorl %%eax,%%eax\n\t" - "jmp 5f\n" - "4:\tsbbl %%eax,%%eax\n\t" - "orw $1,%%eax\n" - "5:" - : "=a" (__res) - : "S" (cs),"D" (ct) - : "esi","edi"); - - return __res; -} - - - -int -wcsicmp(const wchar_t *cs,const wchar_t *ct) -{ -UNIMPLEMENTED; -} - -#endif - -size_t -wcslen(const wchar_t *s) +size_t wcslen(const wchar_t *s) { unsigned int len = 0; @@ -233,43 +147,12 @@ wcsncat(wchar_t *dest, const wchar_t *src, size_t count) return dest; } -#ifdef i386 - -int -wcsncmp(const wchar_t *cs, const wchar_t *ct, size_t count) -{ - register int __res; - - __asm__ __volatile__( - "cld\n" - "1:\tdecl %3\n\t" - "js 2f\n\t" - "lodsw\n\t" - "scasw\n\t" - "jne 3f\n\t" - "testw %%eax,%%eax\n\t" - "jne 1b\n" - "2:\txorl %%eax,%%eax\n\t" - "jmp 4f\n" - "3:\tsbbl %%eax,%%eax\n\t" - "orw $1,%%eax\n" - "4:" - : "=a" (__res) - : "S" (cs), "D" (ct), "c" (count) - : "esi","edi","ecx"); - - return __res; -} - -#else - int wcsncmp(const wchar_t *cs, const wchar_t *ct, size_t count) { UNIMPLEMENTED; } -#endif wchar_t * wcsncpy(wchar_t *dest, const wchar_t *src, size_t count) @@ -289,134 +172,12 @@ wcsncpy(wchar_t *dest, const wchar_t *src, size_t count) return dest; } -#ifdef i386 -int -wcsnicmp(const wchar_t *cs,const wchar_t *ct, size_t count) +int wcsnicmp(const wchar_t *cs, const wchar_t *ct, size_t count) { - register int __res; - - __asm__ __volatile__( - "cld\n" - "1:\t decl %3\n\t" - "js 6f\n\t" - "movw (%%esi), %%eax\n\t" - "movw (%%edi), %%edx \n\t" - "cmpw $0x5A, %%eax\n\t" - "ja 2f\t\n" - "cmpw $0x40, %%eax\t\n" - "jbe 2f\t\n" - "addw $0x20, %%eax\t\n" - "2:\t cmpw $0x5A, %%edx\t\n" - "ja 3f\t\n" - "cmpw $0x40, %%edx\t\n" - "jbe 3f\t\n" - "addw $0x20, %%edx\t\n" - "3:\t inc %%esi\t\n" - "inc %%esi\t\n" - "inc %%edi\t\n" - "inc %%edi\t\n" - "cmpw %%eax, %%edx\t\n" - "jne 4f\n\t" - "cmpw $00, %%eax\n\t" - "jne 1b\n\t" - "6:xorl %%eax,%%eax\n\t" - "jmp 5f\n" - "4:\tsbbl %%eax,%%eax\n\t" - "orw $1,%%eax\n" - "5:" - : "=a" (__res) - : "S" (cs), "D" (ct), "c" (count) - : "esi", "edi", "ecx"); - - return __res; + UNIMPLEMENTED; } -#else - -int -wcsnicmp(const wchar_t *cs,const wchar_t *ct, size_t count) -{ -UNIMPLEMENTED; -} - -#endif - -#ifdef i386 - -size_t -wcsnlen(const wchar_t *s, size_t count) -{ - register int __res; - __asm__ __volatile__( - "movl %1,%0\n\t" - "jmp 2f\n" - "1:\tcmpw $0,(%0)\n\t" - "je 3f\n\t" - "incl %0\n" - "2:\tdecl %2\n\t" - "cmpl $-1,%2\n\t" - "jne 1b\n" - "3:\tsubl %1,%0" - : "=a" (__res) - : "c" (s), "d" (count) - : "edx"); - - return __res; -} - -#else - -size_t -wcsnlen(const wchar_t *s, size_t count) -{ -UNIMPLEMENTED; -} - -#endif - -#ifdef i386 - -wchar_t * -wcspbrk(const wchar_t *cs, const wchar_t *ct) -{ - register wchar_t * __res; - __asm__ __volatile__( - "cld\n\t" - "movl %4,%%edi\n\t" - "repne\n\t" - "scasw\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "movl %%ecx,%%edx\n" - "1:\tlodsw\n\t" - "testw %%eax,%%eax\n\t" - "je 2f\n\t" - "movl %4,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne\n\t" - "scasw\n\t" - "jne 1b\n\t" - "decl %0\n\t" - "jmp 3f\n" - "2:\txorl %0,%0\n" - "3:" - : "=S" (__res) - : "a" (0), "c" (0xffffffff), "0" (cs), "g" (ct) - : "eax", "ecx", "edx", "edi"); - - return __res; -} - -#else - -wchar_t * -wcspbrk(const wchar_t *cs, const wchar_t *ct) -{ -UNIMPLEMENTED; -} - -#endif wchar_t * wcsrchr(const wchar_t *str, wchar_t ch) @@ -438,175 +199,20 @@ wcsrchr(const wchar_t *str, wchar_t ch) return NULL; } -#ifdef i386 - -size_t -wcsspn(const wchar_t *cs, const wchar_t *ct) -{ - register wchar_t * __res; - - __asm__ __volatile__( - "cld\n\t" - "movl %4,%%edi\n\t" - "repne\n\t" - "scasw\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "movl %%ecx,%%edx\n" - "1:\tlodsw\n\t" - "testw %%eax,%%eax\n\t" - "je 2f\n\t" - "movl %4,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne\n\t" - "scasb\n\t" - "je 1b\n" - "2:\tdecl %0" - : "=S" (__res) - : "a" (0), "c" (0xffffffff), "0" (cs), "g" (ct) - : "eax", "ecx", "edx", "edi"); - - return __res-cs; -} - -#else - size_t wcsspn(const wchar_t *cs, const wchar_t *ct) { UNIMPLEMENTED; } -#endif - -#ifdef i386 - -wchar_t * -wcsstr(const wchar_t *cs, const wchar_t *ct) -{ - register wchar_t * __res; - - __asm__ __volatile__( - "cld\n\t" \ - "movl %4,%%edi\n\t" - "repne\n\t" - "scasw\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */ - "movl %%ecx,%%edx\n" - "1:\tmovl %4,%%edi\n\t" - "movl %%esi,%%eax\n\t" - "movl %%edx,%%ecx\n\t" - "repe\n\t" - "cmpsw\n\t" - "je 2f\n\t" /* also works for empty string, see above */ - "xchgl %%eax,%%esi\n\t" - "incl %%esi\n\t" - "cmpw $0,-1(%%eax)\n\t" - "jne 1b\n\t" - "xorl %%eax,%%eax\n\t" - "2:" - : "=a" (__res) - : "0" (0), "c" (0xffffffff), "S" (cs), "g" (ct) - : "ecx", "edx", "edi", "esi"); - - return __res; -} - -#else - -wchar_t * -wcsstr(const wchar_t *cs, const wchar_t *ct) +wchar_t * wcsstr(const wchar_t *cs, const wchar_t *ct) { UNIMPLEMENTED; } -#endif - -size_t wstrlen(const wchar_t *s) -{ - return wcslen(s); -} - -#ifdef i386 - -wchar_t * -wcstok(wchar_t * s,const wchar_t * ct) -{ - register wchar_t * __res; - - __asm__ __volatile__( - "testl %1,%1\n\t" - "jne 1f\n\t" - "testl %0,%0\n\t" - "je 8f\n\t" - "movl %0,%1\n" - "1:\txorl %0,%0\n\t" - "movl $-1,%%ecx\n\t" - "xorl %%eax,%%eax\n\t" - "cld\n\t" - "movl %4,%%edi\n\t" - "repnz\n\t" - "scasw\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "decl %%ecx\n\t" - "je 7f\n\t" /* empty delimiter-string */ - "movl %%ecx,%%edx\n" - "2:\tlodsw\n\t" - "testw %%eax,%%eax\n\t" - "je 7f\n\t" - "movl %4,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne\n\t" - "scasw\n\t" - "je 2b\n\t" - "decl %1\n\t" - "decl %1\n\t" - "cmpw $0,(%1)\n\t" - "je 7f\n\t" - "movl %1,%0\n" - "3:\tlodsw\n\t" - "testw %%eax,%%eax\n\t" - "je 5f\n\t" - "movl %4,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne\n\t" - "scasw\n\t" - "jne 3b\n\t" - "decl %1\n\t" - "decl %1\n\t" - "decl %1\n\t" - "decl %1\n\t" - "cmpw $0,(%1)\n\t" - "je 5f\n\t" - "movw $0,(%1)\n\t" - "incl %1\n\t" - "incl %1\n\t" - "jmp 6f\n" - "5:\txorl %1,%1\n" - "6:\tcmpw $0,(%0)\n\t" - "jne 7f\n\t" - "xorl %0,%0\n" - "7:\ttestl %0,%0\n\t" - "jne 8f\n\t" - "movl %0,%1\n" - "8:" - : "=b" (__res), "=S" (___wcstok) - : "0" (___wcstok), "1" (s), "g" (ct) - : "eax", "ecx", "edx", "edi", "memory"); - - return __res; -} - -#else - -wchar_t * -wcstok(wchar_t * s,const wchar_t * ct) +wchar_t * wcstok(wchar_t * s,const wchar_t * ct) { UNIMPLEMENTED; } -#endif - diff --git a/reactos/ntoskrnl/se/semgr.c b/reactos/ntoskrnl/se/semgr.c index 888297a79ad..7dce4db5210 100644 --- a/reactos/ntoskrnl/se/semgr.c +++ b/reactos/ntoskrnl/se/semgr.c @@ -182,23 +182,7 @@ NtImpersonateThread( { } -NTSTATUS -STDCALL -NtCreateToken( - OUT PHANDLE TokenHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN TOKEN_TYPE TokenType, - IN PLUID AuthenticationId, - IN PLARGE_INTEGER ExpirationTime, - IN PTOKEN_USER TokenUser, - IN PTOKEN_GROUPS TokenGroups, - IN PTOKEN_PRIVILEGES TokenPrivileges, - IN PTOKEN_OWNER TokenOwner, - IN PTOKEN_PRIMARY_GROUP TokenPrimaryGroup, - IN PTOKEN_DEFAULT_DACL TokenDefaultDacl, - IN PTOKEN_SOURCE TokenSource - ) +NTSTATUS STDCALL NtCreateToken(VOID) { } diff --git a/reactos/ntoskrnl/tst/test.c b/reactos/ntoskrnl/tst/test.c index 1c1d2347d15..267a5ea7ab5 100644 --- a/reactos/ntoskrnl/tst/test.c +++ b/reactos/ntoskrnl/tst/test.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include diff --git a/reactos/ntoskrnl/utils/export/export b/reactos/ntoskrnl/utils/export/export deleted file mode 100644 index ec862755a227086545ac6cc338f48a58898582ce..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3292 zcmaJ@Yitx%6uxb@x~!lJ0&4IvRttzoZL9_bi9m~BD%8*h3F5Hr&UQwY*}5|eCA7G> zHg+j%YGM`Qi$s1He~2bVNf2!Sh4=~@4H$_MA7PuV&zPcuj^8(XXIv|IH)qcIzH{%n z=f3vdhZ-6em6eqVuat`lK@{!@1nZy=PAPiogd!@%ba9!OEY1T(UtJn?AUk1GDj@+# z1>{o-e3Xk}Q|M!Czc=^0)Me!TeEVT{HSJOg;mBSrrNWOE~M zf7ZhxaSQ#=1cJ@b(42!+kYGvscHm?1?}Vm5 z4(SALmH0vEJtg(Kh~d|v+26wuuRjI-Z3X@f{y}KQdmM5Yc(%mbp?iTBNxTa>4?Iue z-Oyv74Ft=fIlg_+y>k4VuYI+BKI$AqeC=6WNU zFok6&qp1$BQX*xmLhD4^n3h1bVpGFJ%XZCf6D6(Unkgc-TUS+?nCw%vG&|OjYTJNL zpw+g7X(tnLp=zj%oU~}fj=Y_eg2$yP0R1u(~CNL zS?|MiU;VYg7iJ^IMQ>Dc@|yBH5GHdlkgtW-dH(Y4k~#I4`_&-b+PUT*kN{o({?_G?rncMjl_J!Gzz6$3^=0G4bN2Gr3TYV-wy!t?PM7BqL z;(o6HXNCj)I@dLS6#XKj>|pQy-WDhQN61!+j?JE7o#$R>=DD|J{#%BJO(72TT>f}*S`YPHDy>X+u*|+f-;TM_ zxdHQ&-8_O1hjseC9LBRBrWJ9rzFPs$|Cab)J{Z zIG@Q$=6avmB$azEN9|9y|Lp!;V89*m07u*x2safIJ&QxXpwHVYPo3uEdt-Q#$3UOzdpEk? zpkC)Q?M0?`un_dd`>(@?L+GC0x$gPp*ZJrCp2^H{&V7EFJWKvG`oRBXixp|tZd0_* zjzrQ{=1Kz>fMqN56l>$U)!2th^DkM)7{Mwc5Enrk$|XCe8S{{Oi_@@@&A3YMAYkjYYMXqN;5j@svdg;dbQ+ zl&XbQ$|mHFyU&P)L^mDoloki3x>LAn_3fy$sYLRV#1L2b=6k)Ot_Y| zG&auUhp2lFE<6D{+ zd2jF?mdCr8@5zaoKoHljcw$Q+$X<^__#WiN$agFY-`ji-^8K?I!uKKHk$iuK5tsH) zh{Ly)0^wWJPZV~sY!j#PkmY+e3OR!J|FtFdZLsG;Se8K2G*H$;(lk)IA!!;YyC7*A tD148lX`p-oNz*{N3WHC(mJn?v_LdU+g%W$P#6DhP|4?F=VG_KUe*+&Q%Mkzo diff --git a/reactos/ntoskrnl/utils/export/export.c b/reactos/ntoskrnl/utils/export/export.c index 4458945b62c..409e5cdedd1 100644 --- a/reactos/ntoskrnl/utils/export/export.c +++ b/reactos/ntoskrnl/utils/export/export.c @@ -48,7 +48,7 @@ int main(int argc, char* argv[]) fprintf(stdout,"#include \n"); fprintf(stdout,"#include \n"); fprintf(stdout,"#include \n"); - fprintf(stdout,"#include \n"); + fprintf(stdout,"#include \n"); while (!feof(stdin)) { diff --git a/reactos/ntoskrnl/utils/pe2bin/.cvsignore b/reactos/ntoskrnl/utils/pe2bin/.cvsignore new file mode 100644 index 00000000000..5d0d55d420b --- /dev/null +++ b/reactos/ntoskrnl/utils/pe2bin/.cvsignore @@ -0,0 +1 @@ +pe2bin diff --git a/reactos/ntoskrnl/utils/pe2bin/pe2bin.c b/reactos/ntoskrnl/utils/pe2bin/pe2bin.c new file mode 100644 index 00000000000..dd66e171b0c --- /dev/null +++ b/reactos/ntoskrnl/utils/pe2bin/pe2bin.c @@ -0,0 +1,88 @@ +#include +#include +#include + +int main(int argc, char* argv[]) +{ + FILE* in; + FILE* out; + IMAGE_DOS_HEADER dos_header; + DWORD pe_signature; + IMAGE_FILE_HEADER file_header; + IMAGE_OPTIONAL_HEADER opt_header; + IMAGE_SECTION_HEADER scn_header; + int i; + int prev_pos; + void* buffer; + ULONG base_address; + + if (argc != 4) + { + printf("usage: pe2bin base infile outfile\n"); + return(1); + } + + base_address = strtoul(argv[1],NULL,0); + printf("Generating for base %x\n",base_address); + + in = fopen(argv[2], "rb"); + if (in == NULL) + { + printf("Unable to open %s\n",argv[1]); + return(1); + } + + out = fopen(argv[3], "wb"); + if (out == NULL) + { + printf("Unable to open %s\n",argv[2]); + return(1); + } + + fread(&dos_header,sizeof(IMAGE_DOS_HEADER),1,in); +// printf("dos_header.e_magic %x\n",dos_header.e_magic); + if (dos_header.e_magic != IMAGE_DOS_MAGIC) + { + printf("Bad magic in dos header\n"); + return(1); + } + + fseek(in,dos_header.e_lfanew,SEEK_SET); + fread(&pe_signature,sizeof(DWORD),1,in); + if (pe_signature != IMAGE_PE_MAGIC) + { + printf("Bad magic in pe header\n"); + return(1); + } + + fread(&file_header,sizeof(IMAGE_FILE_HEADER),1,in); + fread(&opt_header,sizeof(IMAGE_OPTIONAL_HEADER),1,in); + +// printf("Linker version: %d.%d\n",opt_header.MajorLinkerVersion, +// opt_header.MinorLinkerVersion); + + for (i=0; i