diff --git a/reactos/apps/tests/bench/bench-thread.c b/reactos/apps/tests/bench/bench-thread.c new file mode 100644 index 00000000000..87d8d18586d --- /dev/null +++ b/reactos/apps/tests/bench/bench-thread.c @@ -0,0 +1,25 @@ +#include +#include + +#define NR_THREADS (0x1000) + +ULONG thread_main(PVOID param) +{ +} + +int main() +{ + unsigned int i=0; + DWORD id; + + printf("Creating %d threads\n",NR_THREADS); + for (i=0;i bench-thread.sym + +include ../../rules.mak diff --git a/reactos/apps/tests/test_old/makefile b/reactos/apps/tests/test_old/makefile index f97a61346a0..bf9f7779a30 100644 --- a/reactos/apps/tests/test_old/makefile +++ b/reactos/apps/tests/test_old/makefile @@ -1,9 +1,9 @@ # # # -OBJECTS= test-stdio.o -all: test-stdio.exe +all: test-stdio.exe tst-printf.exe tstdiomisc.exe bug2.exe bug3.exe \ + temptest.exe test-fseek.exe test_rdwr.exe .phony: all @@ -14,8 +14,40 @@ clean: .phony: clean -test-stdio.exe: $(OBJECTS) - $(CC) $(OBJECTS) -lkernel32 -o test-stdio.exe +bug2.exe: bug2.c + $(CC) bug2.c -lkernel32 -o bug2.exe + $(NM) --numeric-sort bug2.exe > bug2.sym + +bug3.exe: bug3.c + $(CC) bug3.c -lkernel32 -o bug3.exe + $(NM) --numeric-sort bug3.exe > bug3.sym + +temptest.exe: temptest.c + $(CC) temptest.c -lkernel32 -o temptest.exe + $(NM) --numeric-sort temptest.exe > temptest.sym + +test-fseek.exe: test-fseek.c + $(CC) test-fseek.c -lkernel32 -o test-fseek.exe + $(NM) --numeric-sort test-fseek.exe > test-fseek.sym + +test-fwrite.exe: test-fwrite.c + $(CC) test-fwrite.c -lkernel32 -o test-fwrite.exe + $(NM) --numeric-sort test-fwrite.exe > test-fwrite.sym + +test_rdwr.exe: test_rdwr.c + $(CC) test_rdwr.c -lkernel32 -o test_rdwr.exe + $(NM) --numeric-sort test_rdwr.exe > test_rdwr.sym + +test-stdio.exe: test-stdio.c + $(CC) test-stdio.c -lkernel32 -o test-stdio.exe $(NM) --numeric-sort test-stdio.exe > test-stdio.sym +tst-printf.exe: tst-printf.c + $(CC) tst-printf.c -lkernel32 -o tst-printf.exe + $(NM) --numeric-sort tst-printf.exe > tst-printf.sym + +tstdiomisc.exe: tstdiomisc.c + $(CC) tstdiomisc.c -lkernel32 -o tstdiomisc.exe + $(NM) --numeric-sort tstdiomisc.exe > tstdiomisc.sym + include ../../rules.mak diff --git a/reactos/apps/tests/test_old/temptest.c b/reactos/apps/tests/test_old/temptest.c new file mode 100644 index 00000000000..35ea4dc8086 --- /dev/null +++ b/reactos/apps/tests/test_old/temptest.c @@ -0,0 +1,27 @@ +#include +#include + +char *files[500]; + +int +main (int argc, char *argv[]) +{ + FILE *fp; + int i; + + for (i = 0; i < 500; i++) { + files[i] = tempnam (NULL, "file"); + if (files[i] == NULL) { + printf ("tempnam failed\n"); + exit (1); + } + printf ("file: %s\n", files[i]); + fp = fopen (files[i], "w"); + fclose (fp); + } + + for (i = 0; i < 500; i++) + remove (files[i]); + + exit (0); +} diff --git a/reactos/apps/tests/test_old/test-fseek.c b/reactos/apps/tests/test_old/test-fseek.c new file mode 100644 index 00000000000..e736ed7cdc3 --- /dev/null +++ b/reactos/apps/tests/test_old/test-fseek.c @@ -0,0 +1,85 @@ +/* Copyright (C) 1991, 1992, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library 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. + + The GNU C Library 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 the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include + +#define TESTFILE "/tmp/test.dat" + +int +main (void) +{ + FILE *fp; + int i, j; + + puts ("\nFile seek test"); + fp = fopen (TESTFILE, "w"); + if (fp == NULL) + { + perror (TESTFILE); + return 1; + } + + for (i = 0; i < 256; i++) + putc (i, fp); + if (freopen (TESTFILE, "r", fp) != fp) + { + perror ("Cannot open file for reading"); + return 1; + } + + for (i = 1; i <= 255; i++) + { + printf ("%3d\n", i); + fseek (fp, (long) -i, SEEK_END); + if ((j = getc (fp)) != 256 - i) + { + printf ("SEEK_END failed %d\n", j); + break; + } + if (fseek (fp, (long) i, SEEK_SET)) + { + puts ("Cannot SEEK_SET"); + break; + } + if ((j = getc (fp)) != i) + { + printf ("SEEK_SET failed %d\n", j); + break; + } + if (fseek (fp, (long) i, SEEK_SET)) + { + puts ("Cannot SEEK_SET"); + break; + } + if (fseek (fp, (long) (i >= 128 ? -128 : 128), SEEK_CUR)) + { + puts ("Cannot SEEK_CUR"); + break; + } + if ((j = getc (fp)) != (i >= 128 ? i - 128 : i + 128)) + { + printf ("SEEK_CUR failed %d\n", j); + break; + } + } + fclose (fp); + remove (TESTFILE); + + puts ((i > 255) ? "Test succeeded." : "Test FAILED!"); + return (i > 255) ? 0 : 1; +} diff --git a/reactos/apps/tests/test_old/test-fwrite.c b/reactos/apps/tests/test_old/test-fwrite.c new file mode 100644 index 00000000000..ce541699310 --- /dev/null +++ b/reactos/apps/tests/test_old/test-fwrite.c @@ -0,0 +1,68 @@ +#include +#include + +int +main (int argc, char *argv[]) +{ + FILE *f = tmpfile (); + char obuf[99999], ibuf[sizeof obuf]; + char *line; + size_t linesz; + + if (! f) + { + perror ("tmpfile"); + return 1; + } + + if (fputs ("line\n", f) == EOF) + { + perror ("fputs"); + return 1; + } + + memset (obuf, 'z', sizeof obuf); + memset (ibuf, 'y', sizeof ibuf); + + if (fwrite (obuf, sizeof obuf, 1, f) != 1) + { + perror ("fwrite"); + return 1; + } + + rewind (f); + + line = NULL; + linesz = 0; + if (getline (&line, &linesz, f) != 5) + { + perror ("getline"); + return 1; + } + if (strcmp (line, "line\n")) + { + puts ("Lines differ. Test FAILED!"); + return 1; + } + + if (fread (ibuf, sizeof ibuf, 1, f) != 1) + { + perror ("fread"); + return 1; + } + + if (memcmp (ibuf, obuf, sizeof ibuf)) + { + puts ("Buffers differ. Test FAILED!"); + return 1; + } + + asprintf (&line, "\ +GDB is free software and you are welcome to distribute copies of it\n\ + under certain conditions; type \"show copying\" to see the conditions.\n\ +There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\ +"); + + puts ("Test succeeded."); + return 0; +} diff --git a/reactos/apps/tests/test_old/test_rdwr.c b/reactos/apps/tests/test_old/test_rdwr.c new file mode 100644 index 00000000000..a3b01b7c7ce --- /dev/null +++ b/reactos/apps/tests/test_old/test_rdwr.c @@ -0,0 +1,129 @@ +/* Copyright (C) 1991, 1992, 1996, 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library 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. + + The GNU C Library 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 the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include + + +int +main (int argc, char **argv) +{ + static const char hello[] = "Hello, world.\n"; + static const char replace[] = "Hewwo, world.\n"; + static const size_t replace_from = 2, replace_to = 4; + char filename[FILENAME_MAX]; + char *name = strrchr (*argv, '/'); + char buf[BUFSIZ]; + FILE *f; + int lose = 0; + + if (name != NULL) + ++name; + else + name = *argv; + + (void) sprintf (filename, "/tmp/%s.test", name); + + f = fopen (filename, "w+"); + if (f == NULL) + { + perror (filename); + exit (1); + } + + (void) fputs (hello, f); + rewind (f); + (void) fgets (buf, sizeof (buf), f); + rewind (f); + (void) fputs (buf, f); + rewind (f); + { + size_t i; + for (i = 0; i < replace_from; ++i) + { + int c = getc (f); + if (c == EOF) + { + printf ("EOF at %Zu.\n", i); + lose = 1; + break; + } + else if (c != hello[i]) + { + printf ("Got '%c' instead of '%c' at %Zu.\n", + (unsigned char) c, hello[i], i); + lose = 1; + break; + } + } + } + + { + long int where = ftell (f); + if (where == (long int) replace_from) + { + register size_t i; + for (i = replace_from; i < replace_to; ++i) + if (putc(replace[i], f) == EOF) + { + printf ("putc('%c') got %s at %Zu.\n", + replace[i], strerror (errno), i); + lose = 1; + break; + } + } + else if (where == -1L) + { + printf ("ftell got %s (should be at %Zu).\n", + strerror (errno), replace_from); + lose = 1; + } + else + { + printf ("ftell returns %lu; should be %Zu.\n", where, replace_from); + lose = 1; + } + } + + if (!lose) + { + rewind (f); + if (fgets (buf, sizeof (buf), f) == NULL) + { + printf ("fgets got %s.\n", strerror(errno)); + lose = 1; + } + else if (strcmp (buf, replace)) + { + printf ("Read \"%s\" instead of \"%s\".\n", buf, replace); + lose = 1; + } + } + + if (lose) + printf ("Test FAILED! Losing file is \"%s\".\n", filename); + else + { + (void) remove (filename); + puts ("Test succeeded."); + } + + exit (lose ? EXIT_FAILURE : EXIT_SUCCESS); +} diff --git a/reactos/apps/tests/test_old/tst-printf.c b/reactos/apps/tests/test_old/tst-printf.c new file mode 100644 index 00000000000..8c4feedead8 --- /dev/null +++ b/reactos/apps/tests/test_old/tst-printf.c @@ -0,0 +1,311 @@ +/* Copyright (C) 1991, 92, 93, 95, 96, 97, 98 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library 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. + + The GNU C Library 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 the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifdef BSD +#include +#define EXIT_SUCCESS 0 +#else +#include +#include +#include +#endif + +#include + +void rfg1 (void); +void rfg2 (void); + + +void +fmtchk (const char *fmt) +{ + (void) fputs(fmt, stdout); + (void) printf(":\t`"); + (void) printf(fmt, 0x12); + (void) printf("'\n"); +} + +void +fmtst1chk (const char *fmt) +{ + (void) fputs(fmt, stdout); + (void) printf(":\t`"); + (void) printf(fmt, 4, 0x12); + (void) printf("'\n"); +} + +void +fmtst2chk (const char *fmt) +{ + (void) fputs(fmt, stdout); + (void) printf(":\t`"); + (void) printf(fmt, 4, 4, 0x12); + (void) printf("'\n"); +} + +/* This page is covered by the following copyright: */ + +/* (C) Copyright C E Chew + * + * Feel free to copy, use and distribute this software provided: + * + * 1. you do not pretend that you wrote it + * 2. you leave this copyright notice intact. + */ + +/* + * Extracted from exercise.c for glibc-1.05 bug report by Bruce Evans. + */ + +#define DEC -123 +#define INT 255 +#define UNS (~0) + +/* Formatted Output Test + * + * This exercises the output formatting code. + */ + +void +fp_test (void) +{ + int i, j, k, l; + char buf[7]; + char *prefix = buf; + char tp[20]; + + puts("\nFormatted output test"); + printf("prefix 6d 6o 6x 6X 6u\n"); + strcpy(prefix, "%"); + for (i = 0; i < 2; i++) { + for (j = 0; j < 2; j++) { + for (k = 0; k < 2; k++) { + for (l = 0; l < 2; l++) { + strcpy(prefix, "%"); + if (i == 0) strcat(prefix, "-"); + if (j == 0) strcat(prefix, "+"); + if (k == 0) strcat(prefix, "#"); + if (l == 0) strcat(prefix, "0"); + printf("%5s |", prefix); + strcpy(tp, prefix); + strcat(tp, "6d |"); + printf(tp, DEC); + strcpy(tp, prefix); + strcat(tp, "6o |"); + printf(tp, INT); + strcpy(tp, prefix); + strcat(tp, "6x |"); + printf(tp, INT); + strcpy(tp, prefix); + strcat(tp, "6X |"); + printf(tp, INT); + strcpy(tp, prefix); + strcat(tp, "6u |"); + printf(tp, UNS); + printf("\n"); + } + } + } + } + printf("%10s\n", (char *) NULL); + printf("%-10s\n", (char *) NULL); +} + +int +main (int argc, char *argv[]) +{ + static char shortstr[] = "Hi, Z."; + static char longstr[] = "Good morning, Doctor Chandra. This is Hal. \ +I am ready for my first lesson today."; + + fmtchk("%.4x"); + fmtchk("%04x"); + fmtchk("%4.4x"); + fmtchk("%04.4x"); + fmtchk("%4.3x"); + fmtchk("%04.3x"); + + fmtst1chk("%.*x"); + fmtst1chk("%0*x"); + fmtst2chk("%*.*x"); + fmtst2chk("%0*.*x"); + +#ifndef BSD + printf("bad format:\t\"%b\"\n"); + printf("nil pointer (padded):\t\"%10p\"\n", (void *) NULL); +#endif + + printf("decimal negative:\t\"%d\"\n", -2345); + printf("octal negative:\t\"%o\"\n", -2345); + printf("hex negative:\t\"%x\"\n", -2345); + printf("long decimal number:\t\"%ld\"\n", -123456L); + printf("long octal negative:\t\"%lo\"\n", -2345L); + printf("long unsigned decimal number:\t\"%lu\"\n", -123456L); + printf("zero-padded LDN:\t\"%010ld\"\n", -123456L); + printf("left-adjusted ZLDN:\t\"%-010ld\"\n", -123456); + printf("space-padded LDN:\t\"%10ld\"\n", -123456L); + printf("left-adjusted SLDN:\t\"%-10ld\"\n", -123456L); + + printf("zero-padded string:\t\"%010s\"\n", shortstr); + printf("left-adjusted Z string:\t\"%-010s\"\n", shortstr); + printf("space-padded string:\t\"%10s\"\n", shortstr); + printf("left-adjusted S string:\t\"%-10s\"\n", shortstr); + printf("null string:\t\"%s\"\n", (char *)NULL); + printf("limited string:\t\"%.22s\"\n", longstr); + + printf("e-style >= 1:\t\"%e\"\n", 12.34); + printf("e-style >= .1:\t\"%e\"\n", 0.1234); + printf("e-style < .1:\t\"%e\"\n", 0.001234); + printf("e-style big:\t\"%.60e\"\n", 1e20); + printf ("e-style == .1:\t\"%e\"\n", 0.1); + printf("f-style >= 1:\t\"%f\"\n", 12.34); + printf("f-style >= .1:\t\"%f\"\n", 0.1234); + printf("f-style < .1:\t\"%f\"\n", 0.001234); + printf("g-style >= 1:\t\"%g\"\n", 12.34); + printf("g-style >= .1:\t\"%g\"\n", 0.1234); + printf("g-style < .1:\t\"%g\"\n", 0.001234); + printf("g-style big:\t\"%.60g\"\n", 1e20); + + printf (" %6.5f\n", .099999999860301614); + printf (" %6.5f\n", .1); + printf ("x%5.4fx\n", .5); + + printf ("%#03x\n", 1); + + { + double d = FLT_MIN; + int niter = 17; + + while (niter-- != 0) + printf ("%.17e\n", d / 2); + fflush (stdout); + } + + printf ("%15.5e\n", 4.9406564584124654e-324); + +#define FORMAT "|%12.4f|%12.4e|%12.4g|\n" + printf (FORMAT, 0.0, 0.0, 0.0); + printf (FORMAT, 1.0, 1.0, 1.0); + printf (FORMAT, -1.0, -1.0, -1.0); + printf (FORMAT, 100.0, 100.0, 100.0); + printf (FORMAT, 1000.0, 1000.0, 1000.0); + printf (FORMAT, 10000.0, 10000.0, 10000.0); + printf (FORMAT, 12345.0, 12345.0, 12345.0); + printf (FORMAT, 100000.0, 100000.0, 100000.0); + printf (FORMAT, 123456.0, 123456.0, 123456.0); +#undef FORMAT + + { + char buf[20]; + printf ("sprintf (\"%%30s\", \"foo\") == %d, \"%.*s\"\n", + sprintf (buf, "%30s", "foo"), sizeof (buf), buf); + } + + fp_test (); + + printf ("%e should be 1.234568e+06\n", 1234567.8); + printf ("%f should be 1234567.800000\n", 1234567.8); + printf ("%g should be 1.23457e+06\n", 1234567.8); + printf ("%g should be 123.456\n", 123.456); + printf ("%g should be 1e+06\n", 1000000.0); + printf ("%g should be 10\n", 10.0); + printf ("%g should be 0.02\n", 0.02); + + { + double x=1.0; + printf("%.17f\n",(1.0/x/10.0+1.0)*x-x); + } + + puts ("--- Should be no further output. ---"); + rfg1 (); + rfg2 (); + + { + char buf[200]; + int result; + + sprintf(buf,"%*s%*s%*s",-1,"one",-20,"two",-30,"three"); + + result = strcmp (buf, + "onetwo three "); + + puts (result != 0 ? "Test failed!" : "Test ok."); + return result != 0; + } +} + +void +rfg1 (void) +{ + char buf[100]; + + sprintf (buf, "%5.s", "xyz"); + if (strcmp (buf, " ") != 0) + printf ("got: '%s', expected: '%s'\n", buf, " "); + sprintf (buf, "%5.f", 33.3); + if (strcmp (buf, " 33") != 0) + printf ("got: '%s', expected: '%s'\n", buf, " 33"); + sprintf (buf, "%8.e", 33.3e7); + if (strcmp (buf, " 3e+08") != 0) + printf ("got: '%s', expected: '%s'\n", buf, " 3e+08"); + sprintf (buf, "%8.E", 33.3e7); + if (strcmp (buf, " 3E+08") != 0) + printf ("got: '%s', expected: '%s'\n", buf, " 3E+08"); + sprintf (buf, "%.g", 33.3); + if (strcmp (buf, "3e+01") != 0) + printf ("got: '%s', expected: '%s'\n", buf, "3e+01"); + sprintf (buf, "%.G", 33.3); + if (strcmp (buf, "3E+01") != 0) + printf ("got: '%s', expected: '%s'\n", buf, "3E+01"); +} + +void +rfg2 (void) +{ + int prec; + char buf[100]; + + prec = 0; + sprintf (buf, "%.*g", prec, 3.3); + if (strcmp (buf, "3") != 0) + printf ("got: '%s', expected: '%s'\n", buf, "3"); + prec = 0; + sprintf (buf, "%.*G", prec, 3.3); + if (strcmp (buf, "3") != 0) + printf ("got: '%s', expected: '%s'\n", buf, "3"); + prec = 0; + sprintf (buf, "%7.*G", prec, 3.33); + if (strcmp (buf, " 3") != 0) + printf ("got: '%s', expected: '%s'\n", buf, " 3"); + prec = 3; + sprintf (buf, "%04.*o", prec, 33); + if (strcmp (buf, " 041") != 0) + printf ("got: '%s', expected: '%s'\n", buf, " 041"); + prec = 7; + sprintf (buf, "%09.*u", prec, 33); + if (strcmp (buf, " 0000033") != 0) + printf ("got: '%s', expected: '%s'\n", buf, " 0000033"); + prec = 3; + sprintf (buf, "%04.*x", prec, 33); + if (strcmp (buf, " 021") != 0) + printf ("got: '%s', expected: '%s'\n", buf, " 021"); + prec = 3; + sprintf (buf, "%04.*X", prec, 33); + if (strcmp (buf, " 021") != 0) + printf ("got: '%s', expected: '%s'\n", buf, " 021"); +} diff --git a/reactos/apps/tests/test_old/tstdiomisc.c b/reactos/apps/tests/test_old/tstdiomisc.c new file mode 100644 index 00000000000..1affac5b511 --- /dev/null +++ b/reactos/apps/tests/test_old/tstdiomisc.c @@ -0,0 +1,56 @@ +#include + +int +t1 (void) +{ + int n = -1; + sscanf ("abc ", "abc %n", &n); + printf ("t1: count=%d\n", n); + + return n != 5; +} + +int +t2 (void) +{ + int result = 0; + int n; + long N; + int retval; +#define SCAN(INPUT, FORMAT, VAR, EXP_RES, EXP_VAL) \ + VAR = -1; \ + retval = sscanf (INPUT, FORMAT, &VAR); \ + printf ("sscanf (\"%s\", \"%s\", &x) => %d, x = %ld\n", \ + INPUT, FORMAT, retval, (long int) VAR); \ + result |= retval != EXP_RES || VAR != EXP_VAL + + SCAN ("12345", "%ld", N, 1, 12345); + SCAN ("12345", "%llllld", N, 0, -1); + SCAN ("12345", "%LLLLLd", N, 0, -1); + SCAN ("test ", "%*s%n", n, 0, 4); + SCAN ("test ", "%2*s%n", n, 0, -1); + SCAN ("12 ", "%l2d", n, 0, -1); + SCAN ("12 ", "%2ld", N, 1, 12); + + n = -1; + N = -1; + retval = sscanf ("1 1", "%d %Z", &n, &N); + printf ("sscanf (\"1 1\", \"%%d %%Z\", &n, &N) => %d, n = %d, N = %ld\n", \ + retval, n, N); \ + result |= retval != 1 || n != 1 || N != -1; + + return result; +} + +int +main (int argc, char *argv[]) +{ + int result = 0; + + result |= t1 (); + result |= t2 (); + + result |= fflush (stdout) == EOF; + + return result; +} diff --git a/reactos/drivers/fs/vfat/iface.c b/reactos/drivers/fs/vfat/iface.c index 20a8ca005e0..96d4b68c020 100644 --- a/reactos/drivers/fs/vfat/iface.c +++ b/reactos/drivers/fs/vfat/iface.c @@ -1585,10 +1585,10 @@ NTSTATUS FsdSetPositionInformation(PFILE_OBJECT FileObject, PDEVICE_OBJECT DeviceObject, PFILE_POSITION_INFORMATION PositionInfo) { - DbgPrint("FsdSetPositionInformation()\n"); + DPRINT("FsdSetPositionInformation()\n"); - DbgPrint("PositionInfo %x\n", PositionInfo); - DbgPrint("Setting position %d\n",GET_LARGE_INTEGER_LOW_PART( + DPRINT("PositionInfo %x\n", PositionInfo); + DPRINT("Setting position %d\n",GET_LARGE_INTEGER_LOW_PART( PositionInfo->CurrentByteOffset)); memcpy(&FileObject->CurrentByteOffset,&PositionInfo->CurrentByteOffset, sizeof(LARGE_INTEGER)); @@ -1601,11 +1601,11 @@ NTSTATUS FsdGetPositionInformation(PFILE_OBJECT FileObject, PDEVICE_OBJECT DeviceObject, PFILE_POSITION_INFORMATION PositionInfo) { - DbgPrint("FsdGetPositionInformation()\n"); + DPRINT("FsdGetPositionInformation()\n"); memcpy(&PositionInfo->CurrentByteOffset, &FileObject->CurrentByteOffset, sizeof(LARGE_INTEGER)); - DbgPrint("Getting position %x\n",GET_LARGE_INTEGER_LOW_PART( + DPRINT("Getting position %x\n",GET_LARGE_INTEGER_LOW_PART( PositionInfo->CurrentByteOffset)); return(STATUS_SUCCESS); } @@ -1679,7 +1679,7 @@ NTSTATUS FsdSetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp) assert(DeviceObject != NULL); assert(Irp != NULL); - DbgPrint("FsdSetInformation(DeviceObject %x, Irp %x)\n", + DPRINT("FsdSetInformation(DeviceObject %x, Irp %x)\n", DeviceObject,Irp); /* INITIALIZATION */ @@ -1695,8 +1695,8 @@ NTSTATUS FsdSetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp) SystemBuffer = Irp->UserBuffer; // SystemBuffer = Irp->AssociatedIrp.SystemBuffer; - DbgPrint("FileInformationClass %d\n",FileInformationClass); - DbgPrint("SystemBuffer %x\n",SystemBuffer); + DPRINT("FileInformationClass %d\n",FileInformationClass); + DPRINT("SystemBuffer %x\n",SystemBuffer); switch(FileInformationClass) { diff --git a/reactos/include/ddk/kedef.h b/reactos/include/ddk/kedef.h index 19d00f87502..9afe3e58816 100644 --- a/reactos/include/ddk/kedef.h +++ b/reactos/include/ddk/kedef.h @@ -9,7 +9,6 @@ typedef enum _EVENT_TYPE NotificationEvent, SynchronizationEvent, SemaphoreType, - ProcessType, } EVENT_TYPE; typedef enum _KWAIT_REASON diff --git a/reactos/include/internal/id.h b/reactos/include/internal/id.h index 1d09562c8c7..2addb17eb5d 100644 --- a/reactos/include/internal/id.h +++ b/reactos/include/internal/id.h @@ -3,10 +3,11 @@ */ -#define ID_BASE_OBJECT (0x1234) +#define ID_BASE_OBJECT (0x34) #define ID_FILE_OBJECT (ID_BASE_OBJECT + 1) #define ID_DEVICE_OBJECT (ID_BASE_OBJECT + 2) #define ID_DRIVER_OBJECT (ID_BASE_OBJECT + 3) #define ID_DIRECTORY_OBJECT (ID_BASE_OBJECT + 4) #define ID_EVENT_OBJECT (ID_BASE_OBJECT + 5) #define ID_TIMER_OBJECT (ID_BASE_OBJECT + 6) +#define ID_PROCESS_OBJECT (ID_BASE_OBJECT + 7) diff --git a/reactos/lib/crtdll/crtdll.def b/reactos/lib/crtdll/crtdll.def index 5cab39c4767..34578171563 100644 --- a/reactos/lib/crtdll/crtdll.def +++ b/reactos/lib/crtdll/crtdll.def @@ -17,9 +17,9 @@ ; DISCLAMED. This includes but is not limited to warrenties of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; -; $Revision: 1.7 $ -; $Author: ariadne $ -; $Date: 1999/04/14 21:26:48 $ +; $Revision: 1.8 $ +; $Author: dwelch $ +; $Date: 1999/04/18 08:56:06 $ ; ; These three functions appear to be name mangled in some way, so GCC is ; probably not going to be able to use them in any case. @@ -72,7 +72,7 @@ __GetMainArgs ;__threadid ;__toascii ;_abnormal_termination -;_access +_access ;_acmdln_dll ;_aexit_rtn_dll ;_amsg_exit @@ -86,13 +86,13 @@ __GetMainArgs ;_cabs _cexit ;_cgets -;_chdir +_chdir ;_chdrive ;_chgsign _chmod ;_chsize ;_clearfp -;_close +_close ;_commit ;_commode_dll ;_control87 @@ -106,8 +106,8 @@ _chmod ;_ctype ;_cwait ;_daylight_dll -;_dup -;_dup2 +_dup +_dup2 ;_ecvt ;_endthread ;_environ_dll @@ -129,15 +129,15 @@ _fcloseall _fdopen ;_fgetchar ;_fgetwchar -;_filbuf +_filbuf ;_fileinfo_dll -;_filelength +_filelength _fileno -;_findclose -;_findfirst -;_findnext +_findclose +_findfirst +_findnext ;_finite -;_flsbuf +_flsbuf ;_flushall _fmode_dll ;_fpclass @@ -152,12 +152,12 @@ _fstat ;_fullpath ;_futime ;_gcvt -;_get_osfhandle -;_getch -;_getche -;_getcwd +_get_osfhandle +_getch +_getche +_getcwd ;_getdcwd -;_getdiskfree +_getdiskfree ;_getdllprocaddr ;_getdrive ;_getdrives @@ -172,8 +172,8 @@ _fstat ;_hypot ;_initterm _iob -;_isatty -;_isctype +_isatty +_isctype ;_ismbbalnum ;_ismbbalpha ;_ismbbgraph @@ -213,7 +213,7 @@ _iob ;_lrotl ;_lrotr ;_lsearch -;_lseek +_lseek ;_ltoa ;_makepath ;_matherr @@ -272,8 +272,8 @@ _mktemp ;_msize ;_nextafter ;_onexit -;_open -;_open_osfhandle +_open +_open_osfhandle ;_osmajor_dll ;_osminor_dll ;_osmode_dll @@ -286,10 +286,10 @@ _pipe ;_popen ;_purecall ;_putch -;_putenv +_putenv ;_putw ;_pwctype_dll -;_read +_read ;_rmdir ;_rmtmp ;_rotl @@ -300,7 +300,7 @@ _pipe ;_setjmp _setmode ;_setsystime -;_sleep +_sleep ;_snprintf ;_snwprintf ;_sopen @@ -349,7 +349,7 @@ _umask ;_ungetch _unlink ;_unloaddll -;_utime +_utime ;_vsnprintf ;_vsnwprintf ;_wcsdup @@ -371,29 +371,29 @@ _write ;_y1 ;_yn abort -;abs -;acos -;asctime -;asin -;atan -;atan2 +abs +acos +asctime +asin +atan +atan2 atexit -;atof +atof atoi atol -;bsearch -;calloc -;ceil +bsearch +calloc +ceil ;clearerr -;clock -;cos -;cosh +clock +cos +cosh ctime -;difftime -;div +difftime +div exit -;exp -;fabs +exp +fabs fclose feof ferror @@ -402,8 +402,8 @@ fgetc fgetpos fgets ;fgetwc -;floor -;fmod +floor +fmod fopen fprintf fputc @@ -424,7 +424,7 @@ getc getchar getenv gets -;gmtime +gmtime is_wctype isalnum isalpha @@ -451,13 +451,13 @@ iswspace iswupper iswxdigit isxdigit -;labs -;ldexp -;ldiv +labs +ldexp +ldiv ;localeconv ;localtime -;log -;log10 +log +log10 ;longjmp malloc ;mblen @@ -468,70 +468,70 @@ memcmp memcpy memmove memset -;mktime -;modf +mktime +modf perror -;pow +pow printf putc putchar puts -;qsort -;raise +qsort +raise ;rand realloc remove rename rewind scanf -;setbuf +setbuf ;setlocale -;setvbuf -;signal -;sin -;sinh +setvbuf +signal +sin +sinh sprintf -;sqrt +sqrt ;srand sscanf strcat strchr strcmp -;strcoll +strcoll strcpy -;strcspn +strcspn strerror -;strftime +strftime strlen -;strncat +strncat strncmp strncpy -;strpbrk +strpbrk strrchr -;strspn -;strstr -;strtod -;strtok +strspn +strstr +strtod +strtok strtol strtoul -;strxfrm +strxfrm ;swprintf ;swscanf ;system -;tan -;tanh +tan +tanh time -;tmpfile -;tmpnam +tmpfile +tmpnam tolower -;toupper +toupper ;towlower ;towupper -;ungetc +ungetc ;ungetwc vfprintf ;vfwprintf -;vprintf +vprintf vsprintf ;vswprintf ;vwprintf diff --git a/reactos/lib/crtdll/io/read.c b/reactos/lib/crtdll/io/read.c index 0db3018c115..520e2ec9a4b 100644 --- a/reactos/lib/crtdll/io/read.c +++ b/reactos/lib/crtdll/io/read.c @@ -14,13 +14,9 @@ size_t _read(int _fd, void *_buf, size_t _nbyte) { size_t _rbyte; - printf("_read(fd %d, buf %x, _nbyte %d)\n",_fd,_buf,_nbyte); - if (!ReadFile(_get_osfhandle(_fd),_buf,_nbyte,&_rbyte,NULL)) { - printf("_read() = %d\n",-1); return -1; } - printf("_read() = %d\n",_rbyte); return _rbyte; } diff --git a/reactos/lib/crtdll/io/utime.c b/reactos/lib/crtdll/io/utime.c new file mode 100644 index 00000000000..c77beb4e44a --- /dev/null +++ b/reactos/lib/crtdll/io/utime.c @@ -0,0 +1,7 @@ +#include + +int _utime(const char* filename, struct utimbuf* buf) +{ + printf("utime(filename %s, buf %x)\n",filename,buf); + return(-1); +} diff --git a/reactos/lib/crtdll/makefile b/reactos/lib/crtdll/makefile index 19209657fac..61282746af6 100644 --- a/reactos/lib/crtdll/makefile +++ b/reactos/lib/crtdll/makefile @@ -66,7 +66,7 @@ QUAD_OBJECTS = quad/qdivrem.o quad/divdi3.o quad/moddi3.o quad/udivdi3.o quad/u IO_OBJECTS = io/access.o io/close.o io/create.o io/dup.o io/dup2.o io/find.o io/isatty.o io/lseek.o \ io/open.o io/read.o io/setmode.o io/unlink.o io/write.o io/fmode.o io/mktemp.o\ io/chmod.o io/chsize.o io/commit.o io/locking.o io/pipe.o io/sopen.o io/filelen.o\ - io/umask.o io/tell.o io/eof.o + io/umask.o io/tell.o io/eof.o io/utime.o SEARCH_OBJECTS = search/lsearch.o search/lfind.o @@ -124,7 +124,8 @@ OBJECTS = $(MISC_OBJECTS) $(STDLIB_OBJECTS) $(IO_OBJECTS) \ $(STDIO_OBJECTS) $(CTYPE_OBJECTS) $(MATH_OBJECTS) \ $(STRING_OBJECTS) $(TIME_OBJECTS) $(WCHAR_OBJECTS) \ $(SYS_STAT_OBJECTS) misc/dllmain.o $(MALLOC_OBJECTS) \ - $(SEARCH_OBJECTS) $(CONIO_OBJECTS) $(DIRECT_OBJECTS) + $(SEARCH_OBJECTS) $(CONIO_OBJECTS) $(DIRECT_OBJECTS) \ + $(SIGNAL_OBJECTS) crtdll.a: $(OBJECTS) diff --git a/reactos/lib/crtdll/misc/GetArgs.c b/reactos/lib/crtdll/misc/GetArgs.c index 84e79987d64..46ae863e0b4 100644 --- a/reactos/lib/crtdll/misc/GetArgs.c +++ b/reactos/lib/crtdll/misc/GetArgs.c @@ -53,30 +53,32 @@ int __GetMainArgs(int *argc,char ***argv,char ***env,int flag) i=0; afterlastspace=0; - - while (_acmdln_dll[i]) { - if (_acmdln_dll[i]==' ') { + while (_acmdln_dll[i]) + { + if (_acmdln_dll[i]==' ') + { __argc++; _acmdln_dll[i]='\0'; - __argv[__argc-1] = strdup(_acmdln_dll+afterlastspace); + __argv[__argc-1] = strdup(_acmdln_dll + afterlastspace); i++; while (_acmdln_dll[i]==' ') i++; - if (_acmdln_dll[i]) - afterlastspace=i; + afterlastspace=i; } else { i++; } } - - __argc++; - _acmdln_dll[i]='\0'; - __argv[__argc-1] = strdup(_acmdln_dll+afterlastspace); + if (_acmdln_dll[afterlastspace] != 0) + { + __argc++; + _acmdln_dll[i]='\0'; + __argv[__argc-1] = strdup(_acmdln_dll+afterlastspace); + } HeapValidate(GetProcessHeap(),0,NULL); - + _environ = (char **)GetEnvironmentStringsA();; _environ_dll = &_environ; diff --git a/reactos/lib/crtdll/stdio/fflush.c b/reactos/lib/crtdll/stdio/fflush.c index 066bff9e0e0..c57c08a9fc9 100644 --- a/reactos/lib/crtdll/stdio/fflush.c +++ b/reactos/lib/crtdll/stdio/fflush.c @@ -13,43 +13,45 @@ int fflush(FILE *f) { - char *base; - int n, rn; - - if (f == NULL) - { - int e = errno; - - __set_errno(0); - _fwalk((void (*)(FILE *))fflush); - if (_errno) - return EOF; - __set_errno(e); - return 0; - } - - f->_flag &= ~_IOUNGETC; - if ((f->_flag&(_IONBF|_IOWRT))==_IOWRT - && (base = f->_base) != NULL - && (rn = n = f->_ptr - base) > 0) - { - f->_ptr = base; - f->_cnt = (f->_flag&(_IOLBF|_IONBF)) ? 0 : f->_bufsiz; - do { - n = _write(fileno(f), base, rn); - if (n <= 0) { - f->_flag |= _IOERR; - return EOF; - } - rn -= n; - base += n; - } while (rn > 0); - } - if (f->_flag & _IORW) - { - f->_cnt = 0; - f->_flag &= ~(_IOWRT|_IOREAD); - f->_ptr = f->_base; - } - return 0; + char *base; + int n, rn; + + if (f == NULL) + { + int e = errno; + + __set_errno(0); + _fwalk((void (*)(FILE *))fflush); + if (_errno) + return EOF; + __set_errno(e); + return 0; + } + + f->_flag &= ~_IOUNGETC; + if ((f->_flag&(_IONBF|_IOWRT))==_IOWRT + && (base = f->_base) != NULL + && (rn = n = f->_ptr - base) > 0) + { + f->_ptr = base; + f->_cnt = (f->_flag&(_IOLBF|_IONBF)) ? 0 : f->_bufsiz; + do + { + n = _write(fileno(f), base, rn); + if (n <= 0) + { + f->_flag |= _IOERR; + return EOF; + } + rn -= n; + base += n; + } while (rn > 0); + } + if (f->_flag & _IORW) + { + f->_cnt = 0; + f->_flag &= ~(_IOWRT|_IOREAD); + f->_ptr = f->_base; + } + return 0; } diff --git a/reactos/lib/crtdll/stdio/filbuf.c b/reactos/lib/crtdll/stdio/filbuf.c index 19e5c5e305a..ffbe39aa630 100644 --- a/reactos/lib/crtdll/stdio/filbuf.c +++ b/reactos/lib/crtdll/stdio/filbuf.c @@ -10,24 +10,78 @@ #include #include -/* Note: We set _fillsize to 512, and use that for reading instead of - _bufsize, for performance reasons. We double _fillsize each time - we read here, and reset it to 512 each time we call fseek. That - way, we don't waste time reading data we won't use, or doing lots - of small reads we could optimize. If we do lots of seeking, we'll - end up maintaining small read sizes, but if we don't seek, we'll - eventually read blocks as large as the transfer buffer. */ +/* + * Note: We set _fillsize to 512, and use that for reading instead of + * _bufsize, for performance reasons. We double _fillsize each time + * we read here, and reset it to 512 each time we call fseek. That + * way, we don't waste time reading data we won't use, or doing lots + * of small reads we could optimize. If we do lots of seeking, we'll + * end up maintaining small read sizes, but if we don't seek, we'll + * eventually read blocks as large as the transfer buffer. + */ -int -_filbuf(FILE *f) +int _filbuf(FILE *f) { int size, fillsize; char c; if (f->_flag & _IORW) - f->_flag |= _IOREAD; + f->_flag |= _IOREAD; + + if ((f->_flag&_IOREAD) == 0) + return EOF; + if (f->_flag&(_IOSTRG|_IOEOF)) + return EOF; + f->_flag &= ~_IOUNGETC; + + if (f->_base==NULL && (f->_flag&_IONBF)==0) + { + size = 512; + if ((f->_base = malloc(size)) == NULL) + { + f->_flag |= _IONBF; + f->_flag &= ~(_IOFBF|_IOLBF); + } + else + { + f->_flag |= _IOMYBUF; + f->_bufsiz = size; + //f->_fillsize = 512; + } + } + + if (f->_flag&_IONBF) + f->_base = &c; + + if (f == stdin) + { + if (stdout->_flag&_IOLBF) + fflush(stdout); + if (stderr->_flag&_IOLBF) + fflush(stderr); + } + + /* don't read too much! */ + //if (f->_fillsize > f->_bufsiz) + // f->_fillsize = f->_bufsiz; + + /* This next bit makes it so that the cumulative amount read always + aligns with file cluster boundaries; i.e. 512, then 2048 + (512+1536), then 4096 (2048+2048) etc. */ + //fillsize = f->_fillsize; + //if (fillsize == 1024 && f->_bufsiz >= 1536) + // fillsize = 1536; + + if (f->_flag & _IONBF) + { + f->_cnt = read(fileno(f), f->_base, 1); + } + else + { + f->_cnt = read(fileno(f), f->_base, size); + } - if ((f->_flag&_IOREAD) == 0) + if ((f->_flag&_IOREAD) == 0) return EOF; if (f->_flag&(_IOSTRG|_IOEOF)) return EOF; diff --git a/reactos/lib/crtdll/stdio/fread.c b/reactos/lib/crtdll/stdio/fread.c index 0f10098a586..c4c8459f628 100644 --- a/reactos/lib/crtdll/stdio/fread.c +++ b/reactos/lib/crtdll/stdio/fread.c @@ -7,52 +7,57 @@ #include -size_t -fread(void *vptr, size_t size, size_t count, FILE *iop) +size_t fread(void *vptr, size_t size, size_t count, FILE *iop) { - char *ptr = (char *)vptr; - int s; - int c; + char *ptr = (char *)vptr; + int s; + int c; + + /* + * grow if we know we're asking for a lot, even if it's in the + * buffer, since we'll probably read chunks this size for a while + */ + while (size*count > iop->_fillsize + && iop->_fillsize < iop->_bufsiz) + { + if (iop->_fillsize < 512) + iop->_fillsize = 512; + iop->_fillsize *= 2; + } - /* grow if we know we're asking for a lot, even if it's in the - buffer, since we'll probably read chunks this size for a while */ - while (size*count > iop->_fillsize - && iop->_fillsize < iop->_bufsiz) - { - if (iop->_fillsize < 512) - iop->_fillsize = 512; - iop->_fillsize *= 2; - } - - s = size * count; - if(!__is_text_file(iop)) - { - while (s > 0) { - if (iop->_cnt < s) { - if (iop->_cnt > 0) { - memcpy(ptr, iop->_ptr, iop->_cnt); - ptr += iop->_cnt; - s -= iop->_cnt; - } - /* - * filbuf clobbers _cnt & _ptr, - * so don't waste time setting them. - */ - if ((c = _filbuf(iop)) == EOF) - break; - *ptr++ = c; - s--; - } - if (iop->_cnt >= s) { - memcpy(ptr, iop->_ptr, s); - iop->_ptr += s; - iop->_cnt -= s; - return count; - } - } - } - else - { + s = size * count; + if(!__is_text_file(iop)) + { + while (s > 0) + { + if (iop->_cnt < s) + { + if (iop->_cnt > 0) + { + memcpy(ptr, iop->_ptr, iop->_cnt); + ptr += iop->_cnt; + s -= iop->_cnt; + } + /* + * filbuf clobbers _cnt & _ptr, + * so don't waste time setting them. + */ + if ((c = _filbuf(iop)) == EOF) + break; + *ptr++ = c; + s--; + } + if (iop->_cnt >= s) + { + memcpy(ptr, iop->_ptr, s); + iop->_ptr += s; + iop->_cnt -= s; + return count; + } + } + } + else + { while (s > 0) { if (iop->_cnt < s) { while (iop->_cnt > 0) { diff --git a/reactos/lib/crtdll/stdio/fseek.c b/reactos/lib/crtdll/stdio/fseek.c index d851e0fa542..f8d5cbb958f 100644 --- a/reactos/lib/crtdll/stdio/fseek.c +++ b/reactos/lib/crtdll/stdio/fseek.c @@ -8,49 +8,50 @@ #include -int -fseek(FILE *f, long offset, int ptrname) +int fseek(FILE *f, long offset, int ptrname) { - long p = -1; /* can't happen? */ - + long p = -1; /* can't happen? */ + /* See comment in filbuf.c */ - f->_fillsize = 512; + f->_fillsize = 512; - f->_flag &= ~_IOEOF; - if (f->_flag & _IOREAD) - { - if (f->_base && !(f->_flag & _IONBF)) - { - p = ftell(f); - if (ptrname == SEEK_CUR) - { - offset += p; - ptrname = SEEK_SET; - } - /* check if the target position is in the buffer and - optimize seek by moving inside the buffer */ - if (ptrname == SEEK_SET && (f->_flag & (_IOUNGETC|_IORW)) == 0 - && p-offset <= f->_ptr-f->_base && offset-p <= f->_cnt) - { - f->_ptr+=offset-p; - f->_cnt+=p-offset; - return 0; - } - } - - if (f->_flag & _IORW) - f->_flag &= ~_IOREAD; - - p = lseek(fileno(f), offset, ptrname); - f->_cnt = 0; - f->_ptr = f->_base; - f->_flag &= ~_IOUNGETC; - } - else if (f->_flag & (_IOWRT|_IORW)) - { - p = fflush(f); - return lseek(fileno(f), offset, ptrname) == -1 || p == EOF ? - -1 : 0; - } - return p==-1 ? -1 : 0; + f->_flag &= ~_IOEOF; + if (f->_flag & _IOREAD) + { + if (f->_base && !(f->_flag & _IONBF)) + { + p = ftell(f); + if (ptrname == SEEK_CUR) + { + offset += p; + ptrname = SEEK_SET; + } + /* check if the target position is in the buffer and + optimize seek by moving inside the buffer */ + if (ptrname == SEEK_SET && (f->_flag & (_IOUNGETC|_IORW)) == 0 + && p-offset <= f->_ptr-f->_base && offset-p <= f->_cnt) + { + f->_ptr+=offset-p; + f->_cnt+=p-offset; + return 0; + } + } + + if (f->_flag & _IORW) + f->_flag &= ~_IOREAD; + + p = lseek(fileno(f), offset, ptrname); + f->_cnt = 0; + f->_ptr = f->_base; + f->_flag &= ~_IOUNGETC; + } + else if (f->_flag & (_IOWRT|_IORW)) + { + p = fflush(f); + f->_cnt = 0; + f->_ptr = f->_base = NULL; + f->_flag &= ~_IOUNGETC; + return lseek(fileno(f), offset, ptrname) == -1 || p == EOF ? -1 : 0; + } + return p==-1 ? -1 : 0; } diff --git a/reactos/lib/kernel32/file/create.c b/reactos/lib/kernel32/file/create.c index 3c9e636e1f9..3bbb0a5e0c6 100644 --- a/reactos/lib/kernel32/file/create.c +++ b/reactos/lib/kernel32/file/create.c @@ -17,7 +17,7 @@ #include #include -//#define NDEBUG +#define NDEBUG #include /* EXTERNS ******************************************************************/ diff --git a/reactos/lib/kernel32/mem/section.c b/reactos/lib/kernel32/mem/section.c new file mode 100644 index 00000000000..f02a598cd1e --- /dev/null +++ b/reactos/lib/kernel32/mem/section.c @@ -0,0 +1,103 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: lib/kernel32/mem/section.c + * PURPOSE: Implementing file mapping + * PROGRAMMER: David Welch (welch@mcmail.com) + */ + +/* INCLUDES ******************************************************************/ + +#include +#include + +/* FUNCTIONS *****************************************************************/ + +HANDLE CreationFileMappingA(HANDLE hFile, + LPSECURITY_ATTRIBUTES lpFileMappingAttributes, + DWORD flProtect, + DWORD dwMaximumSizeHigh, + DWORD dwMaximumSizeLow, + LPCSTR lpName) +{ + NTSTATUS Status; + HANDLE SectionHandle; + LARGE_INTEGER MaximumSize; + OBJECT_ATTRIBUTES ObjectAttributes; + ANSI_STRING AnsiName; + UNICODE_STRING UnicodeName; + + SET_LARGE_INTEGER_LOW_PART(MaximumSize, dwMaximumSizeLow); + SET_LARGE_INTEGER_HIGH_PART(MaximumSize, dwMaximumSizeHigh); + RtlInitAnsiString(&AnsiString, lpName); + RtlAnsiStringToUnicodeString(&UnicodeName, &AnsiName, TRUE); + InitializeObjectAttributes(&ObjectAttributes, + &UnicodeName, + 0, + NULL, + lpFileMappingAttributes); + Status = ZwCreateSection(&SectionHandle, + SECTION_ALL_ACCESS, + &ObjectAttributes, + &MaximumSize, + flProtect, + 0, + hFile); + if (!NT_SUCCESS(Status)) + { + return(SectionHandle); + } + return(NULL); +} + +HANDLE CreationFileMappingW(HANDLE hFile, + LPSECURITY_ATTRIBUTES lpFileMappingAttributes, + DWORD flProtect, + DWORD dwMaximumSizeHigh, + DWORD dwMaximumSizeLow, + LPCWSTR lpName) +{ + NTSTATUS Status; + HANDLE SectionHandle; + LARGE_INTEGER MaximumSize; + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING UnicodeName; + + SET_LARGE_INTEGER_LOW_PART(MaximumSize, dwMaximumSizeLow); + SET_LARGE_INTEGER_HIGH_PART(MaximumSize, dwMaximumSizeHigh); + RtlInitUnicodeString(&UnicodeString, lpName); + InitializeObjectAttributes(&ObjectAttributes, + &UnicodeName, + 0, + NULL, + lpFileMappingAttributes); + Status = ZwCreateSection(&SectionHandle, + SECTION_ALL_ACCESS, + &ObjectAttributes, + &MaximumSize, + flProtect, + 0, + hFile); + if (!NT_SUCCESS(Status)) + { + return(SectionHandle); + } + return(NULL); +} + +LPVOID MapViewOfFileEx(HANDLE hFileMappingObject, + DWORD dwDesiredAccess, + DWORD dwFileOffsetHigh, + DWORD dwFileOffsetLow, + DWORD dwNumberOfBytesToMap, + LPVOID lpBaseAddress) +{ + NTSTATUS Status; + + Status = ZwMapViewOfSection(hFileMappingObject, + NtCurrentProcess(), + &lpBaseAddress, + 0, + dwNumberOfBytesToMap, + +} diff --git a/reactos/lib/kernel32/process/create.c b/reactos/lib/kernel32/process/create.c index 482272c5820..a281e9bab91 100644 --- a/reactos/lib/kernel32/process/create.c +++ b/reactos/lib/kernel32/process/create.c @@ -21,7 +21,7 @@ #include #include -//#define NDEBUG +#define NDEBUG #include /* FUNCTIONS ****************************************************************/ diff --git a/reactos/lib/ntdll/ldr/startup.c b/reactos/lib/ntdll/ldr/startup.c index 6597973033b..000cf7ca5a7 100644 --- a/reactos/lib/ntdll/ldr/startup.c +++ b/reactos/lib/ntdll/ldr/startup.c @@ -18,7 +18,7 @@ #include #include -//#define NDEBUG +#define NDEBUG #include /* GLOBALS *******************************************************************/ @@ -84,7 +84,7 @@ VOID LdrStartup(HANDLE SectionHandle, NTSTATUS Status; PIMAGE_NT_HEADERS NTHeaders; - dprintf("LdrStartup(ImageBase %x, SectionHandle %x, " + DPRINT("LdrStartup(ImageBase %x, SectionHandle %x, " "NTDllSectionHandle %x)\n",ImageBase, SectionHandle, NTDllSectionHandle); diff --git a/reactos/lib/ntdll/ldr/utils.c b/reactos/lib/ntdll/ldr/utils.c index 8428805a79a..62613b81cff 100644 --- a/reactos/lib/ntdll/ldr/utils.c +++ b/reactos/lib/ntdll/ldr/utils.c @@ -44,7 +44,7 @@ static NTSTATUS LdrLoadDll(PDLL* Dll, PCHAR Name) HANDLE FileHandle, SectionHandle; PDLLMAIN_FUNC Entrypoint; - dprintf("LdrLoadDll(Base %x, Name %s)\n",Dll,Name); + DPRINT("LdrLoadDll(Base %x, Name %s)\n",Dll,Name); strcat(fqname, Name); @@ -140,9 +140,9 @@ static NTSTATUS LdrLoadDll(PDLL* Dll, PCHAR Name) Entrypoint = (PDLLMAIN_FUNC)LdrPEStartup(ImageBase, SectionHandle); if (Entrypoint != NULL) { - dprintf("Calling entry point at %x\n",Entrypoint); + DPRINT("Calling entry point at %x\n",Entrypoint); Entrypoint(ImageBase, DLL_PROCESS_ATTACH, NULL); - dprintf("Successful called entrypoint\n"); + DPRINT("Successful called entrypoint\n"); } return(STATUS_SUCCESS); diff --git a/reactos/makefile_rex b/reactos/makefile_rex index 98ee9f383b5..36d2e6cdb77 100644 --- a/reactos/makefile_rex +++ b/reactos/makefile_rex @@ -38,7 +38,7 @@ FS_DRIVERS = minix vfat ext2 # FS_DRIVERS = template KERNEL_SERVICES = $(DEVICE_DRIVERS) $(FS_DRIVERS) -APPS = args hello shell test cat +APPS = args hello shell test cat bench # APPS = cmd all: $(COMPONENTS) $(DLLS) $(LOADERS) $(KERNEL_SERVICES) $(APPS) diff --git a/reactos/ntoskrnl/hal/x86/exp.c b/reactos/ntoskrnl/hal/x86/exp.c index d5a7c92cd9a..dc06b4cfb53 100644 --- a/reactos/ntoskrnl/hal/x86/exp.c +++ b/reactos/ntoskrnl/hal/x86/exp.c @@ -233,8 +233,6 @@ asmlinkage void exception_handler(unsigned int edi, DbgPrint("ESP %.8x\n",esp); } - for(;;); - if ((cs & 0xffff) == KERNEL_CS) { DbgPrint("ESP %x\n",esp); @@ -290,6 +288,12 @@ asmlinkage void exception_handler(unsigned int edi, } } + if ((cs&0xffff) == USER_CS) + { + ZwTerminateProcess(NtCurrentProcess(), + STATUS_NONCONTINUABLE_EXCEPTION); + } + for(;;); } diff --git a/reactos/ntoskrnl/hal/x86/page.c b/reactos/ntoskrnl/hal/x86/page.c index f84d1c371f5..aa962f033f0 100644 --- a/reactos/ntoskrnl/hal/x86/page.c +++ b/reactos/ntoskrnl/hal/x86/page.c @@ -158,7 +158,7 @@ VOID MmDeletePageEntry(PEPROCESS Process, PVOID Address, BOOL FreePage) return; } page_tlb = ADDR_TO_PTE(Address); - if (FreePage) + if (FreePage && PAGE_MASK(*page_tlb) != 0) { MmFreePage(PAGE_MASK(*page_tlb),1); } diff --git a/reactos/ntoskrnl/io/buildirp.c b/reactos/ntoskrnl/io/buildirp.c index 4003f7af8b5..c82063942c7 100644 --- a/reactos/ntoskrnl/io/buildirp.c +++ b/reactos/ntoskrnl/io/buildirp.c @@ -262,40 +262,41 @@ PIRP IoBuildDeviceIoControlRequest(ULONG IoControlCode, switch (IO_METHOD_FROM_CTL_CODE(IoControlCode)) { - case METHOD_BUFFERED: - DPRINT("Using METHOD_BUFFERED!\n"); - - BufferLength = (InputBufferLength>OutputBufferLength)?InputBufferLength:OutputBufferLength; - if (BufferLength) + case METHOD_BUFFERED: + DPRINT("Using METHOD_BUFFERED!\n"); + + BufferLength = (InputBufferLength>OutputBufferLength)?InputBufferLength:OutputBufferLength; + if (BufferLength) { Irp->AssociatedIrp.SystemBuffer = (PVOID) - ExAllocatePool(NonPagedPool,BufferLength); - + ExAllocatePool(NonPagedPool,BufferLength); + if (Irp->AssociatedIrp.SystemBuffer==NULL) - { - IoFreeIrp(Irp); - return(NULL); - } + { + IoFreeIrp(Irp); + return(NULL); + } } + + if (InputBuffer && InputBufferLength) + { + RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer, + InputBuffer, + InputBufferLength); + } + Irp->UserBuffer = OutputBuffer; + break; - if (InputBuffer && InputBufferLength) - { - RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer, - InputBuffer, - InputBufferLength); - } - break; - - case METHOD_IN_DIRECT: - DPRINT("Using METHOD_IN_DIRECT!\n"); - - /* build input buffer (control buffer) */ - if (InputBuffer && InputBufferLength) - { - Irp->AssociatedIrp.SystemBuffer = (PVOID) + case METHOD_IN_DIRECT: + DPRINT("Using METHOD_IN_DIRECT!\n"); + + /* build input buffer (control buffer) */ + if (InputBuffer && InputBufferLength) + { + Irp->AssociatedIrp.SystemBuffer = (PVOID) ExAllocatePool(NonPagedPool,InputBufferLength); - - if (Irp->AssociatedIrp.SystemBuffer==NULL) + + if (Irp->AssociatedIrp.SystemBuffer==NULL) { IoFreeIrp(Irp); return(NULL); @@ -337,8 +338,12 @@ PIRP IoBuildDeviceIoControlRequest(ULONG IoControlCode, /* build output buffer (data transfer buffer) */ if (OutputBuffer && OutputBufferLength) { - Irp->MdlAddress = IoAllocateMdl (OutputBuffer,OutputBufferLength,FALSE,FALSE,Irp); - MmProbeAndLockPages (Irp->MdlAddress,UserMode,IoWriteAccess); + Irp->MdlAddress = IoAllocateMdl(OutputBuffer, + OutputBufferLength, + FALSE, + FALSE, + Irp); + MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess); } break; diff --git a/reactos/ntoskrnl/io/cleanup.c b/reactos/ntoskrnl/io/cleanup.c index 6121532aa4a..8cc459b2320 100644 --- a/reactos/ntoskrnl/io/cleanup.c +++ b/reactos/ntoskrnl/io/cleanup.c @@ -22,6 +22,65 @@ /* FUNCTIONS ***************************************************************/ + +VOID IoDeviceControlCompletion(PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PIO_STACK_LOCATION IoStack) +{ + ULONG IoControlCode; + + IoControlCode = IoStack->Parameters.DeviceIoControl.IoControlCode; + + switch (IO_METHOD_FROM_CTL_CODE(IoControlCode)) + { + case METHOD_BUFFERED: + DPRINT ("Using METHOD_BUFFERED!\n"); + + /* copy output buffer back and free it */ + if (Irp->AssociatedIrp.SystemBuffer) + { + if (IoStack->Parameters.DeviceIoControl.OutputBufferLength) + { + RtlCopyMemory(Irp->UserBuffer, + Irp->AssociatedIrp.SystemBuffer, + IoStack->Parameters.DeviceIoControl. + OutputBufferLength); + } + ExFreePool (Irp->AssociatedIrp.SystemBuffer); + } + break; + + case METHOD_IN_DIRECT: + DPRINT ("Using METHOD_IN_DIRECT!\n"); + + /* free input buffer (control buffer) */ + if (Irp->AssociatedIrp.SystemBuffer) + ExFreePool (Irp->AssociatedIrp.SystemBuffer); + + /* free output buffer (data transfer buffer) */ + if (Irp->MdlAddress) + IoFreeMdl (Irp->MdlAddress); + break; + + case METHOD_OUT_DIRECT: + DPRINT ("Using METHOD_OUT_DIRECT!\n"); + + /* free input buffer (control buffer) */ + if (Irp->AssociatedIrp.SystemBuffer) + ExFreePool (Irp->AssociatedIrp.SystemBuffer); + + /* free output buffer (data transfer buffer) */ + if (Irp->MdlAddress) + IoFreeMdl (Irp->MdlAddress); + break; + + case METHOD_NEITHER: + DPRINT ("Using METHOD_NEITHER!\n"); + /* nothing to do */ + break; + } +} + VOID IoReadWriteCompletion(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IoStack) @@ -59,6 +118,12 @@ VOID IoReadWriteCompletion(PDEVICE_OBJECT DeviceObject, } } +VOID IoVolumeInformationCompletion(PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PIO_STACK_LOCATION IoStack) +{ +} + VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost) /* * FUNCTION: Performs the second stage of irp completion for read/write irps @@ -78,7 +143,8 @@ VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost) switch (IoStack->MajorFunction) { case IRP_MJ_CREATE: - /* NOP */ + case IRP_MJ_FLUSH_BUFFERS: + /* NOP */ break; case IRP_MJ_READ: @@ -86,6 +152,16 @@ VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost) IoReadWriteCompletion(DeviceObject,Irp,IoStack); break; + case IRP_MJ_DEVICE_CONTROL: + case IRP_MJ_INTERNAL_DEVICE_CONTROL: + IoDeviceControlCompletion(DeviceObject, Irp, IoStack); + break; + + case IRP_MJ_QUERY_VOLUME_INFORMATION: + case IRP_MJ_SET_VOLUME_INFORMATION: + IoVolumeInformationCompletion(DeviceObject, Irp, IoStack); + break; + default: } diff --git a/reactos/ntoskrnl/io/file.c b/reactos/ntoskrnl/io/file.c index 15b279a5ed5..5a4053bef46 100644 --- a/reactos/ntoskrnl/io/file.c +++ b/reactos/ntoskrnl/io/file.c @@ -13,7 +13,7 @@ #include #include -//#define NDEBUG +#define NDEBUG #include /* FUNCTIONS *****************************************************************/ diff --git a/reactos/ntoskrnl/io/flush.c b/reactos/ntoskrnl/io/flush.c index 2793457364f..27ca0fcfb35 100644 --- a/reactos/ntoskrnl/io/flush.c +++ b/reactos/ntoskrnl/io/flush.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/flush.c * PURPOSE: Flushing file buffer - * PROGRAMMER: David Welch (welch@mcmail.com) + * PROGRAMMER: David Welch (welch@cwcom.net) * UPDATE HISTORY: * Created 22/05/98 */ diff --git a/reactos/ntoskrnl/io/fs.c b/reactos/ntoskrnl/io/fs.c index 370764d1139..cb4aafd11dc 100644 --- a/reactos/ntoskrnl/io/fs.c +++ b/reactos/ntoskrnl/io/fs.c @@ -58,90 +58,101 @@ NtFsControlFile( OutputBufferSize)); } -NTSTATUS -STDCALL -ZwFsControlFile( - IN HANDLE DeviceHandle, - IN HANDLE EventHandle OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG IoControlCode, - IN PVOID InputBuffer, - IN ULONG InputBufferSize, - OUT PVOID OutputBuffer, - IN ULONG OutputBufferSize - ) +NTSTATUS STDCALL ZwFsControlFile(IN HANDLE DeviceHandle, + IN HANDLE EventHandle OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG IoControlCode, + IN PVOID InputBuffer, + IN ULONG InputBufferSize, + OUT PVOID OutputBuffer, + IN ULONG OutputBufferSize) { NTSTATUS Status = -1; PFILE_OBJECT FileObject; PIRP Irp; PIO_STACK_LOCATION StackPtr; KEVENT Event; - - - if ( InputBufferSize > 0 ) { + if (InputBufferSize > 0) + { Status = ObReferenceObjectByHandle(DeviceHandle, - FILE_WRITE_DATA|FILE_READ_DATA, - NULL, - UserMode, - (PVOID *) &FileObject, - NULL); + FILE_WRITE_DATA|FILE_READ_DATA, + NULL, + UserMode, + (PVOID *) &FileObject, + NULL); if (Status != STATUS_SUCCESS) - { + { return(Status); - } - + } + KeInitializeEvent(&Event,NotificationEvent,FALSE); Irp = IoBuildSynchronousFsdRequest(IRP_MJ_DEVICE_CONTROL, - FileObject->DeviceObject, - InputBuffer, - InputBufferSize, - 0, - &Event, - IoStatusBlock); + FileObject->DeviceObject, + InputBuffer, + InputBufferSize, + 0, + &Event, + IoStatusBlock); + if (Irp == NULL) + { + ObDereferenceObject(FileObject); + return(STATUS_UNSUCCESSFUL); + } StackPtr = IoGetNextIrpStackLocation(Irp); - if ( StackPtr == NULL ) - return -1; + if (StackPtr == NULL) + { + ObDereferenceObject(FileObject); + return(STATUS_UNSUCCESSFUL); + } StackPtr->Parameters.DeviceIoControl.IoControlCode = IoControlCode; StackPtr->FileObject = FileObject; StackPtr->Parameters.Write.Length = InputBufferSize; DPRINT("FileObject->DeviceObject %x\n",FileObject->DeviceObject); Status = IoCallDriver(FileObject->DeviceObject,Irp); if (Status==STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO)) - { - KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL); - return Irp->IoStatus.Status; - } + { + KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL); + } + ObDereferenceObject(FileObject); + return(Irp->IoStatus.Status); } - if ( OutputBufferSize > 0 ) { + if (OutputBufferSize > 0) + { CHECKPOINT; Status = ObReferenceObjectByHandle(DeviceHandle, - FILE_WRITE_DATA|FILE_READ_DATA, - NULL, - UserMode, - (PVOID *) &FileObject, - NULL); + FILE_WRITE_DATA|FILE_READ_DATA, + NULL, + UserMode, + (PVOID *) &FileObject, + NULL); if (Status != STATUS_SUCCESS) - { - return(Status); - } + { + return(Status); + } CHECKPOINT; KeInitializeEvent(&Event,NotificationEvent,FALSE); CHECKPOINT; Irp = IoBuildSynchronousFsdRequest(IRP_MJ_DEVICE_CONTROL, - FileObject->DeviceObject, - OutputBuffer, - OutputBufferSize, - 0, - &Event, - IoStatusBlock); - CHECKPOINT; + FileObject->DeviceObject, + OutputBuffer, + OutputBufferSize, + 0, + &Event, + IoStatusBlock); + if (Irp == NULL) + { + ObDereferenceObject(FileObject); + return(STATUS_UNSUCCESSFUL); + } StackPtr = IoGetNextIrpStackLocation(Irp); - if ( StackPtr == NULL ) - return -1; + if (StackPtr == NULL) + { + return(STATUS_UNSUCCESSFUL); + } StackPtr->Parameters.DeviceIoControl.IoControlCode = IoControlCode; StackPtr->FileObject = FileObject; StackPtr->Parameters.Read.Length = OutputBufferSize; @@ -149,11 +160,10 @@ ZwFsControlFile( Status = IoCallDriver(FileObject->DeviceObject,Irp); if (Status==STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO)) { - KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL); - return Irp->IoStatus.Status; + KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL); } + return(Irp->IoStatus.Status); } - CHECKPOINT; return(Status); } diff --git a/reactos/ntoskrnl/io/ioctrl.c b/reactos/ntoskrnl/io/ioctrl.c index 6a60992cea1..21507605e58 100644 --- a/reactos/ntoskrnl/io/ioctrl.c +++ b/reactos/ntoskrnl/io/ioctrl.c @@ -25,51 +25,43 @@ ULONG IoGetFunctionCodeFromCtlCode(ULONG ControlCode) UNIMPLEMENTED; } -NTSTATUS -STDCALL -NtDeviceIoControlFile( - IN HANDLE DeviceHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL, - IN PVOID UserApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG IoControlCode, - IN PVOID InputBuffer, - IN ULONG InputBufferSize, - OUT PVOID OutputBuffer, - IN ULONG OutputBufferSize - ) +NTSTATUS STDCALL NtDeviceIoControlFile(IN HANDLE DeviceHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE UserApcRoutine, + IN PVOID UserApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG IoControlCode, + IN PVOID InputBuffer, + IN ULONG InputBufferSize, + OUT PVOID OutputBuffer, + IN ULONG OutputBufferSize) { return(ZwDeviceIoControlFile(DeviceHandle, - Event, - UserApcRoutine, - UserApcContext, - IoStatusBlock, - IoControlCode, - InputBuffer, - InputBufferSize, - OutputBuffer, - OutputBufferSize)); + Event, + UserApcRoutine, + UserApcContext, + IoStatusBlock, + IoControlCode, + InputBuffer, + InputBufferSize, + OutputBuffer, + OutputBufferSize)); } /* * NOTES: No apc support yet! */ -NTSTATUS -STDCALL -ZwDeviceIoControlFile( - IN HANDLE DeviceHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL, - IN PVOID UserApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG IoControlCode, - IN PVOID InputBuffer, - IN ULONG InputBufferSize, - OUT PVOID OutputBuffer, - IN ULONG OutputBufferSize - ) +NTSTATUS STDCALL ZwDeviceIoControlFile(IN HANDLE DeviceHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE UserApcRoutine, + IN PVOID UserApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG IoControlCode, + IN PVOID InputBuffer, + IN ULONG InputBufferSize, + OUT PVOID OutputBuffer, + IN ULONG OutputBufferSize) { NTSTATUS Status; PFILE_OBJECT FileObject; @@ -79,19 +71,19 @@ ZwDeviceIoControlFile( KEVENT KEvent; assert(KeGetCurrentIrql()==PASSIVE_LEVEL); - + DPRINT("ZwDeviceIoControlFile(DeviceHandle %x Event %x UserApcRoutine %x " "UserApcContext %x IoStatusBlock %x InputBuffer %x " "InputBufferSize %x OutputBuffer %x OutputBufferSize %x)\n", DeviceHandle,Event,UserApcRoutine,UserApcContext,IoStatusBlock, InputBuffer,InputBufferSize,OutputBuffer,OutputBufferSize); - + Status = ObReferenceObjectByHandle(DeviceHandle, - FILE_READ_DATA | FILE_WRITE_DATA, - NULL, - KernelMode, - (PVOID *) &FileObject, - NULL); + FILE_READ_DATA | FILE_WRITE_DATA, + NULL, + KernelMode, + (PVOID *) &FileObject, + NULL); if (Status != STATUS_SUCCESS) { @@ -104,75 +96,26 @@ ZwDeviceIoControlFile( KeInitializeEvent(&KEvent,NotificationEvent,TRUE); Irp = IoBuildDeviceIoControlRequest(IoControlCode, - DeviceObject, - InputBuffer, - InputBufferSize, - OutputBuffer, - OutputBufferSize, - FALSE, - &KEvent, - IoStatusBlock); - + DeviceObject, + InputBuffer, + InputBufferSize, + OutputBuffer, + OutputBufferSize, + FALSE, + &KEvent, + IoStatusBlock); + StackPtr = IoGetNextIrpStackLocation(Irp); StackPtr->DeviceObject = DeviceObject; StackPtr->Parameters.DeviceIoControl.InputBufferLength = InputBufferSize; StackPtr->Parameters.DeviceIoControl.OutputBufferLength = OutputBufferSize; Status = IoCallDriver(DeviceObject,Irp); - if (Status == STATUS_PENDING) + if (Status == STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO)) { KeWaitForSingleObject(&KEvent,Executive,KernelMode,FALSE,NULL); return(IoStatusBlock->Status); } - - switch (IO_METHOD_FROM_CTL_CODE(IoControlCode)) - { - case METHOD_BUFFERED: - DPRINT ("Using METHOD_BUFFERED!\n"); - - /* copy output buffer back and free it */ - if (Irp->AssociatedIrp.SystemBuffer) - { - if (OutputBuffer && OutputBufferSize) - { - RtlCopyMemory(OutputBuffer, - Irp->AssociatedIrp.SystemBuffer, - OutputBufferSize); - } - ExFreePool (Irp->AssociatedIrp.SystemBuffer); - } - break; - - case METHOD_IN_DIRECT: - DPRINT ("Using METHOD_IN_DIRECT!\n"); - - /* free input buffer (control buffer) */ - if (Irp->AssociatedIrp.SystemBuffer) - ExFreePool (Irp->AssociatedIrp.SystemBuffer); - - /* free output buffer (data transfer buffer) */ - if (Irp->MdlAddress) - IoFreeMdl (Irp->MdlAddress); - break; - - case METHOD_OUT_DIRECT: - DPRINT ("Using METHOD_OUT_DIRECT!\n"); - - /* free input buffer (control buffer) */ - if (Irp->AssociatedIrp.SystemBuffer) - ExFreePool (Irp->AssociatedIrp.SystemBuffer); - - /* free output buffer (data transfer buffer) */ - if (Irp->MdlAddress) - IoFreeMdl (Irp->MdlAddress); - break; - - case METHOD_NEITHER: - DPRINT ("Using METHOD_NEITHER!\n"); - /* nothing to do */ - break; - } - return(Status); } diff --git a/reactos/ntoskrnl/io/rw.c b/reactos/ntoskrnl/io/rw.c index fb9b6ae7698..968c81deaf4 100644 --- a/reactos/ntoskrnl/io/rw.c +++ b/reactos/ntoskrnl/io/rw.c @@ -63,7 +63,7 @@ NTSTATUS ZwReadFile(HANDLE FileHandle, DPRINT("ZwReadFile(FileHandle %x Buffer %x Length %x ByteOffset %x, " "IoStatusBlock %x)\n", - FileHandle,Buffer,Length,ByteOffset,IoStatusBlock); + FileHandle,Buffer,Length,ByteOffset,IoStatusBlock); Status = ObReferenceObjectByHandle(FileHandle, FILE_READ_DATA, @@ -77,6 +77,9 @@ NTSTATUS ZwReadFile(HANDLE FileHandle, return(Status); } + DPRINT("ByteOffset %x FileObject->CurrentByteOffset %d\n", + ByteOffset, + GET_LARGE_INTEGER_LOW_PART(FileObject->CurrentByteOffset)); if (ByteOffset==NULL) { ByteOffset = &(FileObject->CurrentByteOffset); @@ -125,8 +128,9 @@ NTSTATUS ZwReadFile(HANDLE FileHandle, if (Status == STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO)) { KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL); - return(IoStatusBlock->Status); + Status = IoStatusBlock->Status; } + DPRINT("ZwReadFile() = %x\n",Status); return(Status); } @@ -205,7 +209,7 @@ NTSTATUS ZwWriteFile(HANDLE FileHandle, StackPtr->Parameters.Write.Key = 0; } Status = IoCallDriver(FileObject->DeviceObject,Irp); - if (Status==STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO)) + if (Status == STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO)) { KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL); Status = Irp->IoStatus.Status; diff --git a/reactos/ntoskrnl/io/symlink.c b/reactos/ntoskrnl/io/symlink.c index 9209abb7ce2..c7049ce3c2d 100644 --- a/reactos/ntoskrnl/io/symlink.c +++ b/reactos/ntoskrnl/io/symlink.c @@ -165,6 +165,7 @@ NTSTATUS ZwQuerySymbolicLinkObject(IN HANDLE LinkHandle, { *ReturnedLength=SymlinkObject->Target.Length; } + ObDereferenceObject(SymlinkObject); return(STATUS_SUCCESS); } diff --git a/reactos/ntoskrnl/ke/wait.c b/reactos/ntoskrnl/ke/wait.c index 31dee72af00..399b90ecfe5 100644 --- a/reactos/ntoskrnl/ke/wait.c +++ b/reactos/ntoskrnl/ke/wait.c @@ -124,6 +124,7 @@ BOOLEAN KeDispatcherObjectWake(DISPATCHER_HEADER* hdr) DPRINT("Entering KeDispatcherObjectWake(hdr %x)\n",hdr); // DPRINT("hdr->WaitListHead %x hdr->WaitListHead.Flink %x\n", // &hdr->WaitListHead,hdr->WaitListHead.Flink); + DPRINT("hdr->Type %x\n",hdr->Type); switch (hdr->Type) { case NotificationEvent: @@ -148,10 +149,10 @@ BOOLEAN KeDispatcherObjectWake(DISPATCHER_HEADER* hdr) } else return FALSE; - case ProcessType: + case ID_PROCESS_OBJECT: return(KeDispatcherObjectWakeAll(hdr)); } - DbgPrint("Dispatcher object has unknown type\n"); + DbgPrint("Dispatcher object %x has unknown type\n",hdr); KeBugCheck(0); return(FALSE); } @@ -196,6 +197,18 @@ NTSTATUS KeWaitForSingleObject(PVOID Object, case SemaphoreType: break; + + case ID_PROCESS_OBJECT: + break; + + case NotificationEvent: + break; + + default: + DbgPrint("(%s:%d) Dispatcher object %x has unknown type\n", + __FILE__,__LINE__,hdr); + KeBugCheck(0); + } KeReleaseDispatcherDatabaseLock(FALSE); return(STATUS_SUCCESS); diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index c5c38b80c4d..8dbea1364d5 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -60,7 +60,8 @@ NTSTATUS MmpCreateSection(PVOID ObjectBody, } ObAddEntryDirectory(Parent, ObjectBody, RemainingPath+1); - + ObDereferenceObject(Parent); + return(STATUS_SUCCESS); } @@ -326,6 +327,7 @@ NTSTATUS STDCALL ZwMapViewOfSection(HANDLE SectionHandle, NULL); if (Status != STATUS_SUCCESS) { + ObDereferenceObject(Section); return(Status); } @@ -346,6 +348,7 @@ NTSTATUS STDCALL ZwMapViewOfSection(HANDLE SectionHandle, { DPRINT("ZwMapViewOfSection() = %x\n",Status); ObDereferenceObject(Process); + ObDereferenceObject(Section); return(Status); } Result->Data.SectionData.Section = Section; @@ -364,6 +367,7 @@ NTSTATUS STDCALL ZwMapViewOfSection(HANDLE SectionHandle, DPRINT("*BaseAddress %x\n",*BaseAddress); ObDereferenceObject(Process); + ObDereferenceObject(Section); return(STATUS_SUCCESS); } @@ -387,7 +391,9 @@ NTSTATUS ZwUnmapViewOfSection(HANDLE ProcessHandle, PVOID BaseAddress) { return(Status); } - return(MmFreeMemoryArea(Process,BaseAddress,0,TRUE)); + Status = MmFreeMemoryArea(Process,BaseAddress,0,TRUE); + ObDereferenceObject(Process); + return(Status); } NTSTATUS STDCALL NtQuerySection(IN HANDLE SectionHandle, diff --git a/reactos/ntoskrnl/mm/virtual.c b/reactos/ntoskrnl/mm/virtual.c index b51ed97a2ca..c73767391cc 100644 --- a/reactos/ntoskrnl/mm/virtual.c +++ b/reactos/ntoskrnl/mm/virtual.c @@ -50,7 +50,7 @@ NTSTATUS MmReleaseMmInfo(PEPROCESS Process) PLIST_ENTRY CurrentEntry; PMEMORY_AREA Current; - DPRINT("MmReleaseMmInfo(Process %x)\n",Process); + DbgPrint("MmReleaseMmInfo(Process %x)\n",Process); while (!IsListEmpty(&Process->Pcb.MemoryAreaList)) { @@ -95,16 +95,12 @@ BOOLEAN MmIsAddressValid(PVOID VirtualAddress) return(TRUE); } -NTSTATUS -STDCALL -NtAllocateVirtualMemory( - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN ULONG ZeroBits, - IN OUT PULONG RegionSize, - IN ULONG AllocationType, - IN ULONG Protect - ) +NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN ULONG ZeroBits, + IN OUT PULONG RegionSize, + IN ULONG AllocationType, + IN ULONG Protect) { return(ZwAllocateVirtualMemory(ProcessHandle, BaseAddress, @@ -114,16 +110,12 @@ NtAllocateVirtualMemory( 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: Allocates a block of virtual memory in the process address space * ARGUMENTS: @@ -317,6 +309,7 @@ NTSTATUS STDCALL ZwFreeVirtualMemory(IN HANDLE ProcessHandle, MemoryArea = MmOpenMemoryAreaByAddress(Process,*BaseAddress); if (MemoryArea == NULL) { + ObDereferenceObject(Process); return(STATUS_UNSUCCESSFUL); } @@ -423,6 +416,7 @@ NTSTATUS STDCALL ZwProtectVirtualMemory(IN HANDLE ProcessHandle, if (MemoryArea == NULL) { DPRINT("ZwProtectVirtualMemory() = %x\n",STATUS_UNSUCCESSFUL); + ObDereferenceObject(Process); return(STATUS_UNSUCCESSFUL); } @@ -493,24 +487,17 @@ NTSTATUS STDCALL ZwReadVirtualMemory(IN HANDLE ProcessHandle, IN ULONG NumberOfBytesToRead, OUT PULONG NumberOfBytesRead) { - UNIMPLEMENTED; -} - -#if 0 -NTSTATUS STDCALL ZwReadVirtualMemory(IN HANDLE ProcessHandle, - IN PVOID BaseAddress, - OUT PVOID Buffer, - IN ULONG NumberOfBytesToRead, - OUT PULONG NumberOfBytesRead) -{ - PEPROCESS Process; - MEMORY_AREA* MemoryArea; - ULONG i; NTSTATUS Status; - PULONG CurrentEntry; + PMDL Mdl; + PVOID SystemAddress; + PEPROCESS Process; + + DPRINT("ZwReadVirtualMemory(ProcessHandle %x, BaseAddress %x, " + "Buffer %x, NumberOfBytesToRead %d)\n",ProcessHandle,BaseAddress, + Buffer,NumberOfBytesToRead); Status = ObReferenceObjectByHandle(ProcessHandle, - PROCESS_VM_READ, + PROCESS_VM_WRITE, NULL, UserMode, (PVOID*)(&Process), @@ -519,32 +506,26 @@ NTSTATUS STDCALL ZwReadVirtualMemory(IN HANDLE ProcessHandle, { return(Status); } - - MemoryArea = MmOpenMemoryAreaByAddress(Process,BaseAddress); - if (MemoryArea == NULL) - { - return(STATUS_UNSUCCESSFUL); - } - if (MemoryArea->Length > NumberOfBytesToRead) - { - NumberOfBytesToRead = MemoryArea->Length; - } + Mdl = MmCreateMdl(NULL, + Buffer, + NumberOfBytesToRead); + MmProbeAndLockPages(Mdl, + UserMode, + IoWriteAccess); + + KeAttachProcess(Process); + + SystemAddress = MmGetSystemAddressForMdl(Mdl); + memcpy(SystemAddress, BaseAddress, NumberOfBytesToRead); + + KeDetachProcess(); + + ObDereferenceObject(Process); *NumberOfBytesRead = NumberOfBytesToRead; - - for (i=0; i<(NumberOfBytesToRead/PAGESIZE); i++) - { - CurrentEntry = MmGetPageEntry(Process, - (PVOID)((DWORD)BaseAddress + (i*PAGESIZE))); - RtlCopyMemory(Buffer + (i*PAGESIZE), - (PVOID)physical_to_linear(PAGE_MASK(*CurrentEntry)), - PAGESIZE); - - } return(STATUS_SUCCESS); } -#endif NTSTATUS STDCALL NtUnlockVirtualMemory(HANDLE ProcessHandle, PVOID BaseAddress, diff --git a/reactos/ntoskrnl/ob/handle.c b/reactos/ntoskrnl/ob/handle.c index 6175f49c370..a20a4736f89 100644 --- a/reactos/ntoskrnl/ob/handle.c +++ b/reactos/ntoskrnl/ob/handle.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ob/handle.c * PURPOSE: Managing handles - * PROGRAMMER: David Welch (welch@mcmail.com) + * PROGRAMMER: David Welch (welch@cwcom.net) * REVISION HISTORY: * 17/06/98: Created */ @@ -155,6 +155,9 @@ NTSTATUS STDCALL ZwDuplicateObject(IN HANDLE SourceProcessHandle, ZwClose(*SourceHandle); } + ObDereferenceObject(TargetProcess); + ObDereferenceObject(SourceProcess); + return(STATUS_SUCCESS); } @@ -326,12 +329,15 @@ NTSTATUS ObReferenceObjectByHandle(HANDLE Handle, DPRINT("ObReferenceObjectByHandle(Handle %x, DesiredAccess %x, " "ObjectType %x, AccessMode %d, Object %x)\n",Handle,DesiredAccess, ObjectType,AccessMode,Object); + + if (Handle == NtCurrentProcess() && (ObjectType == PsProcessType || ObjectType == NULL)) { BODY_TO_HEADER(PsGetCurrentProcess())->RefCount++; *Object = PsGetCurrentProcess(); + DPRINT("Referencing current process %x\n", PsGetCurrentProcess()); return(STATUS_SUCCESS); } if (Handle == NtCurrentThread() && @@ -350,7 +356,7 @@ NTSTATUS ObReferenceObjectByHandle(HANDLE Handle, } ObjectHeader = BODY_TO_HEADER(HandleRep->ObjectBody); - + if (ObjectType != NULL && ObjectType != ObjectHeader->ObjectType) { return(STATUS_OBJECT_TYPE_MISMATCH); @@ -362,7 +368,7 @@ NTSTATUS ObReferenceObjectByHandle(HANDLE Handle, } ObjectHeader->RefCount++; - + *Object = HandleRep->ObjectBody; return(STATUS_SUCCESS); diff --git a/reactos/ntoskrnl/ob/object.c b/reactos/ntoskrnl/ob/object.c index 56c895f0e0d..2b05283050d 100644 --- a/reactos/ntoskrnl/ob/object.c +++ b/reactos/ntoskrnl/ob/object.c @@ -14,6 +14,7 @@ #include #include #include +#include #define NDEBUG #include @@ -195,6 +196,7 @@ NTSTATUS ObReferenceObjectByPointer(PVOID ObjectBody, } ObjectHeader->RefCount++; + return(STATUS_SUCCESS); } @@ -247,7 +249,8 @@ VOID ObDereferenceObject(PVOID ObjectBody) DPRINT("ObDeferenceObject(ObjectBody %x) RefCount %d\n",ObjectBody, Header->RefCount); - + Header->RefCount--; + ObPerformRetentionChecks(Header); } diff --git a/reactos/ntoskrnl/ps/kill.c b/reactos/ntoskrnl/ps/kill.c index eceea362978..e85a1a903b9 100644 --- a/reactos/ntoskrnl/ps/kill.c +++ b/reactos/ntoskrnl/ps/kill.c @@ -28,7 +28,6 @@ extern ULONG PiNrThreads; VOID PiDeleteProcess(PVOID ObjectBody) { DPRINT("PiDeleteProcess(ObjectBody %x)\n",ObjectBody); - /* FIXME: This doesn't work, why? */ (VOID)MmReleaseMmInfo((PEPROCESS)ObjectBody); } @@ -91,9 +90,6 @@ NTSTATUS STDCALL ZwTerminateProcess(IN HANDLE ProcessHandle, return(Status); } - DPRINT("Process %x ReferenceCount %d\n",Process, - ObGetReferenceCount(Process)); - PiTerminateProcessThreads(Process, ExitStatus); KeRaiseIrql(DISPATCH_LEVEL, &oldlvl); Process->Pcb.ProcessState = PROCESS_STATE_TERMINATED; diff --git a/reactos/ntoskrnl/ps/process.c b/reactos/ntoskrnl/ps/process.c index e1f36e8966c..0a303336ef4 100644 --- a/reactos/ntoskrnl/ps/process.c +++ b/reactos/ntoskrnl/ps/process.c @@ -17,6 +17,7 @@ #include #include #include +#include #define NDEBUG #include @@ -66,6 +67,12 @@ VOID PsInitProcessManagment(VOID) PROCESS_ALL_ACCESS, NULL, PsProcessType); + KeInitializeDispatcherHeader(&SystemProcess->Pcb.DispatcherHeader, + ID_PROCESS_OBJECT, + sizeof(EPROCESS), + FALSE); + DPRINT("SystemProcess->Pcb.Type %x\n", + SystemProcess->Pcb.Type); KProcess = &SystemProcess->Pcb; InitializeListHead(&(KProcess->MemoryAreaList)); @@ -179,7 +186,7 @@ NTSTATUS STDCALL ZwCreateProcess( ObjectAttributes, PsProcessType); KeInitializeDispatcherHeader(&Process->Pcb.DispatcherHeader, - ProcessType, + ID_PROCESS_OBJECT, sizeof(EPROCESS), FALSE); KProcess = &(Process->Pcb); @@ -244,23 +251,31 @@ NTSTATUS STDCALL ZwQueryInformationProcess(IN HANDLE ProcessHandle, IN ULONG ProcessInformationLength, OUT PULONG ReturnLength) { -// PEPROCESS Process; + PEPROCESS Process; NTSTATUS Status; + PPROCESS_BASIC_INFORMATION ProcessBasicInformationP; -/* Status = ObReferenceObjectByHandle(ProcessHandle, - PROCESS_QUERY_INFORMATION, + Status = ObReferenceObjectByHandle(ProcessHandle, + PROCESS_SET_INFORMATION, PsProcessType, UserMode, - &ProcessHandle, + (PVOID*)&Process, NULL); if (Status != STATUS_SUCCESS) { return(Status); - }*/ + } switch (ProcessInformationClass) { case ProcessBasicInformation: + ProcessBasicInformationP = (PPROCESS_BASIC_INFORMATION) + ProcessInformation; + memset(ProcessBasicInformationP, 0, sizeof(PROCESS_BASIC_INFORMATION)); + ProcessBasicInformationP->AffinityMask = Process->Pcb.Affinity; + Status = STATUS_SUCCESS; + break; + case ProcessQuotaLimits: case ProcessIoCounters: case ProcessVmCounters: @@ -284,6 +299,7 @@ NTSTATUS STDCALL ZwQueryInformationProcess(IN HANDLE ProcessHandle, default: Status = STATUS_NOT_IMPLEMENTED; } + ObDereferenceObject(Process); return(Status); } @@ -303,23 +319,31 @@ NTSTATUS STDCALL ZwSetInformationProcess(IN HANDLE ProcessHandle, IN PVOID ProcessInformation, IN ULONG ProcessInformationLength) { -// PEPROCESS Process; + PEPROCESS Process; NTSTATUS Status; + PPROCESS_BASIC_INFORMATION ProcessBasicInformationP; -/* Status = ObReferenceObjectByHandle(ProcessHandle, + Status = ObReferenceObjectByHandle(ProcessHandle, PROCESS_SET_INFORMATION, PsProcessType, UserMode, - &ProcessHandle, + (PVOID*)&Process, NULL); if (Status != STATUS_SUCCESS) { return(Status); - }*/ + } switch (ProcessInformationClass) { case ProcessBasicInformation: + ProcessBasicInformationP = (PPROCESS_BASIC_INFORMATION) + ProcessInformation; + memset(ProcessBasicInformationP, 0, sizeof(PROCESS_BASIC_INFORMATION)); + Process->Pcb.Affinity = ProcessBasicInformationP->AffinityMask; + Status = STATUS_SUCCESS; + break; + case ProcessQuotaLimits: case ProcessIoCounters: case ProcessVmCounters: @@ -343,5 +367,6 @@ NTSTATUS STDCALL ZwSetInformationProcess(IN HANDLE ProcessHandle, default: Status = STATUS_NOT_IMPLEMENTED; } + ObDereferenceObject(Process); return(Status); } diff --git a/reactos/ntoskrnl/ps/thread.c b/reactos/ntoskrnl/ps/thread.c index badfcae9d43..a89cffed5aa 100644 --- a/reactos/ntoskrnl/ps/thread.c +++ b/reactos/ntoskrnl/ps/thread.c @@ -26,6 +26,7 @@ #include #include #include +#include #define NDEBUG #include @@ -63,7 +64,7 @@ PKTHREAD KeGetCurrentThread(VOID) PETHREAD PsGetCurrentThread(VOID) { - return((PETHREAD)KeGetCurrentThread()); + return(CurrentThread); } VOID PiTerminateProcessThreads(PEPROCESS Process, NTSTATUS ExitStatus) @@ -113,7 +114,7 @@ VOID PsBeginThread(PKSTART_ROUTINE StartRoutine, PVOID StartContext) KeReleaseSpinLock(&ThreadListLock,PASSIVE_LEVEL); Ret = StartRoutine(StartContext); PsTerminateSystemThread(Ret); - for(;;); + KeBugCheck(0); } static PETHREAD PsScanThreadList(KPRIORITY Priority) @@ -227,7 +228,7 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle, Thread->Tcb.CurrentPriority=THREAD_PRIORITY_NORMAL; Thread->Tcb.ApcList=ExAllocatePool(NonPagedPool,sizeof(LIST_ENTRY)); Thread->Tcb.SuspendCount = 1; - if (ProcessHandle!=NULL) + if (ProcessHandle != NULL) { Status = ObReferenceObjectByHandle(ProcessHandle, PROCESS_CREATE_THREAD, @@ -266,7 +267,7 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle, *ThreadPtr = Thread; - ObDereferenceObject(Thread->ThreadsProcess); + ObDereferenceObject(Thread->ThreadsProcess); return(STATUS_SUCCESS); }