ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
March 2009
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
28 participants
483 discussions
Start a n
N
ew thread
[cgutman] 39994: - Add a check for an empty NetworkAddress registry entry
by cgutman@svn.reactos.org
Author: cgutman Date: Fri Mar 13 02:23:57 2009 New Revision: 39994 URL:
http://svn.reactos.org/svn/reactos?rev=39994&view=rev
Log: - Add a check for an empty NetworkAddress registry entry Modified: branches/aicom-network-fixes/drivers/network/ndis/ndis/config.c Modified: branches/aicom-network-fixes/drivers/network/ndis/ndis/config.c URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/drivers/net…
============================================================================== --- branches/aicom-network-fixes/drivers/network/ndis/ndis/config.c [iso-8859-1] (original) +++ branches/aicom-network-fixes/drivers/network/ndis/ndis/config.c [iso-8859-1] Fri Mar 13 02:23:57 2009 @@ -713,6 +713,13 @@ *NetworkAddressLength = (UINT)((j/2)+0.5); + if (j == 0) + { + NDIS_DbgPrint(MIN_TRACE,("Empty NetworkAddress registry entry.\n")); + *Status = NDIS_STATUS_FAILURE; + return; + } + IntArray = ExAllocatePool(PagedPool, (*NetworkAddressLength)*sizeof(UINT)); if(!IntArray) {
15 years, 9 months
1
0
0
0
[tkreuzer] 39993: Cleanup freetypee lib
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Fri Mar 13 02:08:01 2009 New Revision: 39993 URL:
http://svn.reactos.org/svn/reactos?rev=39993&view=rev
Log: Cleanup freetypee lib Removed: trunk/reactos/lib/3rdparty/freetype/ftfd/ trunk/reactos/lib/3rdparty/freetype/rosglue.c trunk/reactos/lib/3rdparty/freetype/sprintf.c Removed: trunk/reactos/lib/3rdparty/freetype/rosglue.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/freetype/rosg…
============================================================================== --- trunk/reactos/lib/3rdparty/freetype/rosglue.c [iso-8859-1] (original) +++ trunk/reactos/lib/3rdparty/freetype/rosglue.c (removed) @@ -1,137 +1,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: FreeType implementation for ReactOS - * PURPOSE: Glue functions between FreeType - * FILE: thirdparty/freetype/rosglue.c - * PROGRAMMER: Ge van Geldorp (ge(a)gse.nl) - * NOTES: - */ - -#include <windef.h> -#include <wingdi.h> -#include <winddi.h> -#include <stdarg.h> -#include <stdio.h> - -#define NDEBUG -#include <debug.h> - -#define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24)) -#define TAG_FREETYPE TAG('F', 'T', 'Y', 'P') - -/* - * First some generic routines - */ - -ULONG -DbgPrint(IN PCCH Format, IN ...) -{ - va_list args; - - va_start(args, Format); - EngDebugPrint("ft2: ", (PCHAR)Format, args); - va_end(args); - return 0; -} - -/* - * Memory allocation - * - * Because of realloc, we need to keep track of the size of the allocated - * buffer (need to copy the old contents to the new buffer). So, allocate - * extra space for a size_t, store the allocated size in there and return - * the address just past it as the allocated buffer. - */ - -void * -malloc(size_t Size) -{ - void *Object; - - Object = EngAllocMem(0, sizeof(size_t) + Size, TAG_FREETYPE); - if (NULL != Object) - { - *((size_t *) Object) = Size; - Object = (void *)((size_t *) Object + 1); - } - - return Object; -} - -void * -realloc(void *Object, size_t Size) -{ - void *NewObject; - size_t CopySize; - - NewObject = EngAllocMem(0, sizeof(size_t) + Size, TAG_FREETYPE); - if (NULL != NewObject) - { - *((size_t *) NewObject) = Size; - NewObject = (void *)((size_t *) NewObject + 1); - CopySize = *((size_t *) Object - 1); - if (Size < CopySize) - { - CopySize = Size; - } - memcpy(NewObject, Object, CopySize); - EngFreeMem((size_t *) Object - 1); - } - - return NewObject; -} - -void -free(void *Object) -{ - EngFreeMem((size_t *) Object - 1); -} - -/* - * File I/O - * - * This is easy, we don't want FreeType to do any I/O. So return an - * error on each I/O attempt. Note that errno is not being set, it is - * not used by FreeType. - */ - -FILE * -fopen(const char *FileName, const char *Mode) -{ - DPRINT1("Freetype tries to open file %s\n", FileName); - - return NULL; -} - -int -fseek(FILE *Stream, long Offset, int Origin) -{ - DPRINT1("Doubleplus ungood: freetype shouldn't fseek!\n"); - - return -1; -} - -long -ftell(FILE *Stream) -{ - DPRINT1("Doubleplus ungood: freetype shouldn't ftell!\n"); - - return -1; -} - -size_t -fread(void *Buffer, size_t Size, size_t Count, FILE *Stream) -{ - DPRINT1("Doubleplus ungood: freetype shouldn't fread!\n"); - - return 0; -} - -int -fclose(FILE *Stream) -{ - DPRINT1("Doubleplus ungood: freetype shouldn't fclose!\n"); - - return EOF; -} Removed: trunk/reactos/lib/3rdparty/freetype/sprintf.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/freetype/spri…
============================================================================== --- trunk/reactos/lib/3rdparty/freetype/sprintf.c [iso-8859-1] (original) +++ trunk/reactos/lib/3rdparty/freetype/sprintf.c (removed) @@ -1,742 +1,0 @@ -/* - * PROGRAMMERS: David Welch - * Eric Kohl - * - * TODO: - * - Verify the implementation of '%Z'. - */ - -/* - * linux/lib/vsprintf.c - * - * Copyright (C) 1991, 1992 Linus Torvalds - */ - -/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */ -/* - * Wirzenius wrote this portably, Torvalds fucked it up :-) - */ - -#define WIN32_NO_STATUS -#include <windows.h> -#include <ndk/ntndk.h> -#include <stdlib.h> -#include <stdio.h> - -#define ZEROPAD 1 /* pad with zero */ -#define SIGN 2 /* unsigned/signed long */ -#define PLUS 4 /* show plus */ -#define SPACE 8 /* space if plus */ -#define LEFT 16 /* left justified */ -#define SPECIAL 32 /* 0x */ -#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */ -#define REMOVEHEX 256 /* use 256 as remve 0x frim BASE 16 */ -typedef struct { - unsigned int mantissal:32; - unsigned int mantissah:20; - unsigned int exponent:11; - unsigned int sign:1; -} double_t; - -static -__inline -int -_isinf(double __x) -{ - union - { - double* __x; - double_t* x; - } x; - - x.__x = &__x; - return ( x.x->exponent == 0x7ff && ( x.x->mantissah == 0 && x.x->mantissal == 0 )); -} - -static -__inline -int -_isnan(double __x) -{ - union - { - double* __x; - double_t* x; - } x; - x.__x = &__x; - return ( x.x->exponent == 0x7ff && ( x.x->mantissah != 0 || x.x->mantissal != 0 )); -} - - -static -__inline -int -do_div(long long *n, int base) -{ - int a; - a = ((unsigned long long) *n) % (unsigned) base; - *n = ((unsigned long long) *n) / (unsigned) base; - return a; -} - - -static int skip_atoi(const char **s) -{ - int i=0; - - while (isdigit(**s)) - i = i*10 + *((*s)++) - '0'; - return i; -} - - -static char * -number(char * buf, char * end, long long num, int base, int size, int precision, int type) -{ - char c,sign,tmp[66]; - const char *digits; - const char *small_digits = "0123456789abcdefghijklmnopqrstuvwxyz"; - const char *large_digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - int i; - - digits = (type & LARGE) ? large_digits : small_digits; - if (type & LEFT) - type &= ~ZEROPAD; - if (base < 2 || base > 36) - return 0; - c = (type & ZEROPAD) ? '0' : ' '; - sign = 0; - if (type & SIGN) { - if (num < 0) { - sign = '-'; - num = -num; - size--; - } else if (type & PLUS) { - sign = '+'; - size--; - } else if (type & SPACE) { - sign = ' '; - size--; - } - } - - if ((type & SPECIAL) && ((type & REMOVEHEX) == 0)) { - if (base == 16) - size -= 2; - - } - i = 0; - if ((num == 0) && (precision !=0)) - tmp[i++] = '0'; - else while (num != 0) - tmp[i++] = digits[do_div(&num,base)]; - if (i > precision) - precision = i; - size -= precision; - if (!(type&(ZEROPAD+LEFT))) { - while(size-->0) { - if (buf <= end) - *buf = ' '; - ++buf; - } - } - if (sign) { - if (buf <= end) - *buf = sign; - ++buf; - } - - if ((type & SPECIAL) && ((type & REMOVEHEX) == 0)) { - if (base==16) { - if (buf <= end) - *buf = '0'; - ++buf; - if (buf <= end) - *buf = digits[33]; - ++buf; - } - } - - if (!(type & LEFT)) { - while (size-- > 0) { - if (buf <= end) - *buf = c; - ++buf; - } - } - while (i < precision--) { - if (buf <= end) - *buf = '0'; - ++buf; - } - while (i-- > 0) { - if (buf <= end) - *buf = tmp[i]; - ++buf; - } - while (size-- > 0) { - if (buf <= end) - *buf = ' '; - ++buf; - } - - return buf; -} - -static char * -numberf(char * buf, char * end, double num, int base, int size, int precision, int type) -{ - char c,sign,tmp[66]; - const char *digits; - const char *small_digits = "0123456789abcdefghijklmnopqrstuvwxyz"; - const char *large_digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - int i; - long long x; - - /* FIXME - the float version of number is direcly copy of number - */ - - digits = (type & LARGE) ? large_digits : small_digits; - if (type & LEFT) - type &= ~ZEROPAD; - if (base < 2 || base > 36) - return 0; - c = (type & ZEROPAD) ? '0' : ' '; - sign = 0; - if (type & SIGN) { - if (num < 0) { - sign = '-'; - num = -num; - size--; - } else if (type & PLUS) { - sign = '+'; - size--; - } else if (type & SPACE) { - sign = ' '; - size--; - } - } - if (type & SPECIAL) { - if (base == 16) - size -= 2; - else if (base == 8) - size--; - } - i = 0; - if (num == 0) - tmp[i++] = '0'; - else while (num != 0) - { - x = num; - tmp[i++] = digits[do_div(&x,base)]; - num=x; - } - if (i > precision) - precision = i; - size -= precision; - if (!(type&(ZEROPAD+LEFT))) { - while(size-->0) { - if (buf <= end) - *buf = ' '; - ++buf; - } - } - if (sign) { - if (buf <= end) - *buf = sign; - ++buf; - } - if (type & SPECIAL) { - if (base==8) { - if (buf <= end) - *buf = '0'; - ++buf; - } else if (base==16) { - if (buf <= end) - *buf = '0'; - ++buf; - if (buf <= end) - *buf = digits[33]; - ++buf; - } - } - if (!(type & LEFT)) { - while (size-- > 0) { - if (buf <= end) - *buf = c; - ++buf; - } - } - while (i < precision--) { - if (buf <= end) - *buf = '0'; - ++buf; - } - while (i-- > 0) { - if (buf <= end) - *buf = tmp[i]; - ++buf; - } - while (size-- > 0) { - if (buf <= end) - *buf = ' '; - ++buf; - } - return buf; -} - -static char* -string(char* buf, char* end, const char* s, int len, int field_width, int precision, int flags) -{ - int i; - char c; - - c = (flags & ZEROPAD) ? '0' : ' '; - - if (s == NULL) - { - s = "<NULL>"; - len = 6; - } - else - { - if (len == -1) - { - len = 0; - while ((unsigned int)len < (unsigned int)precision && s[len]) - len++; - } - else - { - if ((unsigned int)len > (unsigned int)precision) - len = precision; - } - } - if (!(flags & LEFT)) - while (len < field_width--) - { - if (buf <= end) - *buf = c; - ++buf; - } - for (i = 0; i < len; ++i) - { - if (buf <= end) - *buf = *s++; - ++buf; - } - while (len < field_width--) - { - if (buf <= end) - *buf = ' '; - ++buf; - } - return buf; -} - -static char* -stringw(char* buf, char* end, const wchar_t* sw, int len, int field_width, int precision, int flags) -{ - int i; - char c; - - c = (flags & ZEROPAD) ? '0' : ' '; - - if (sw == NULL) - { - sw = L"<NULL>"; - len = 6; - } - else - { - if (len == -1) - { - len = 0; - while ((unsigned int)len < (unsigned int)precision && sw[len]) - len++; - } - else - { - if ((unsigned int)len > (unsigned int)precision) - len = precision; - } - } - if (!(flags & LEFT)) - while (len < field_width--) - { - if (buf <= end) - *buf = c; - buf++; - } - for (i = 0; i < len; ++i) - { - if (buf <= end) - *buf = (unsigned char)(*sw++); - buf++; - } - while (len < field_width--) - { - if (buf <= end) - *buf = ' '; - buf++; - } - return buf; -} - -/* - * @implemented - */ -int __cdecl _vsnprintf(char *buf, size_t cnt, const char *fmt, va_list args) -{ - int len; - unsigned long long num; - double _double; - - int base; - char *str, *end; - const char *s; - const wchar_t *sw; - - int flags; /* flags to number() */ - - int field_width; /* width of output field */ - int precision; /* min. # of digits for integers; max - number of chars for from string */ - int qualifier; /* 'h', 'l', 'L', 'I' or 'w' for integer fields */ - - /* clear the string buffer with zero so we do not need NULL terment it at end */ - - str = buf; - end = buf + cnt - 1; - if (end < buf - 1) { - end = ((char *) -1); - cnt = end - buf + 1; - } - - for ( ; *fmt ; ++fmt) { - if (*fmt != '%') { - if (str <= end) - *str = *fmt; - ++str; - continue; - } - - /* process flags */ - flags = 0; - repeat: - ++fmt; /* this also skips first '%' */ - switch (*fmt) { - case '-': flags |= LEFT; goto repeat; - case '+': flags |= PLUS; goto repeat; - case ' ': flags |= SPACE; goto repeat; - case '#': flags |= SPECIAL; goto repeat; - case '0': flags |= ZEROPAD; goto repeat; - } - - /* get field width */ - field_width = -1; - if (isdigit(*fmt)) - field_width = skip_atoi(&fmt); - else if (*fmt == '*') { - ++fmt; - /* it's the next argument */ - field_width = va_arg(args, int); - if (field_width < 0) { - field_width = -field_width; - flags |= LEFT; - } - } - - /* get the precision */ - precision = -1; - if (*fmt == '.') { - ++fmt; - if (isdigit(*fmt)) - precision = skip_atoi(&fmt); - else if (*fmt == '*') { - ++fmt; - /* it's the next argument */ - precision = va_arg(args, int); - } - if (precision < 0) - precision = 0; - } - - /* get the conversion qualifier */ - qualifier = -1; - if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'w') { - qualifier = *fmt; - ++fmt; - } else if (*fmt == 'I' && *(fmt+1) == '6' && *(fmt+2) == '4') { - qualifier = *fmt; - fmt += 3; - } else if (*fmt == 'I' && *(fmt+1) == '3' && *(fmt+2) == '2') { - qualifier = 'l'; - fmt += 3; - } else if (*fmt == 'F' && *(fmt+1) == 'p') { - fmt += 1; - flags |= REMOVEHEX; - } - - /* default base */ - base = 10; - - switch (*fmt) { - case 'c': /* finished */ - if (qualifier == 'l' || qualifier == 'w') { - wchar_t sw1[2]; - /* print unicode string */ - sw1[0] = (wchar_t) va_arg(args, int); - sw1[1] = 0; - str = stringw(str, end, (wchar_t *)&sw1, -1, field_width, precision, flags); - } else { - char s1[2]; - /* print ascii string */ - s1[0] = ( unsigned char) va_arg(args, int); - s1[1] = 0; - str = string(str, end, (char *)&s1, -1, field_width, precision, flags); - } - continue; - - case 'C': /* finished */ - if (!(flags & LEFT)) - while (--field_width > 0) { - if (str <= end) - *str = ' '; - ++str; - } - if (qualifier == 'h') { - if (str <= end) - *str = (unsigned char) va_arg(args, int); - ++str; - } else { - if (str <= end) - *str = (unsigned char)(wchar_t) va_arg(args, int); - ++str; - } - while (--field_width > 0) { - if (str <= end) - *str = ' '; - ++str; - } - continue; - - case 's': /* finished */ - if (qualifier == 'l' || qualifier == 'w') { - /* print unicode string */ - sw = va_arg(args, wchar_t *); - str = stringw(str, end, sw, -1, field_width, precision, flags); - } else { - /* print ascii string */ - s = va_arg(args, char *); - str = string(str, end, s, -1, field_width, precision, flags); - } - continue; - - case 'S': - if (qualifier == 'h') { - /* print ascii string */ - s = va_arg(args, char *); - str = string(str, end, s, -1, field_width, precision, flags); - } else { - /* print unicode string */ - sw = va_arg(args, wchar_t *); - str = stringw(str, end, sw, -1, field_width, precision, flags); - } - continue; - - case 'Z': - if (qualifier == 'w') { - /* print counted unicode string */ - PUNICODE_STRING pus = va_arg(args, PUNICODE_STRING); - if ((pus == NULL) || (pus->Buffer == NULL)) { - sw = NULL; - len = -1; - } else { - sw = pus->Buffer; - len = pus->Length / sizeof(WCHAR); - } - str = stringw(str, end, sw, len, field_width, precision, flags); - } else { - /* print counted ascii string */ - PANSI_STRING pus = va_arg(args, PANSI_STRING); - if ((pus == NULL) || (pus->Buffer == NULL)) { - s = NULL; - len = -1; - } else { - s = pus->Buffer; - len = pus->Length; - } - str = string(str, end, s, len, field_width, precision, flags); - } - continue; - - case 'p': - if ((flags & LARGE) == 0) - flags |= LARGE; - - if (field_width == -1) { - field_width = 2 * sizeof(void *); - flags |= ZEROPAD; - } - str = number(str, end, - (ULONG_PTR) va_arg(args, void *), 16, - field_width, precision, flags); - continue; - - case 'n': - /* FIXME: What does C99 say about the overflow case here? */ - if (qualifier == 'l') { - long * ip = va_arg(args, long *); - *ip = (str - buf); - } else { - int * ip = va_arg(args, int *); - *ip = (str - buf); - } - continue; - - /* float number formats - set up the flags and "break" */ - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - _double = (double)va_arg(args, double); - if ( _isnan(_double) ) { - s = "Nan"; - len = 3; - while ( len > 0 ) { - if (str <= end) - *str = *s++; - ++str; - len --; - } - } else if ( _isinf(_double) < 0 ) { - s = "-Inf"; - len = 4; - while ( len > 0 ) { - if (str <= end) - *str = *s++; - ++str; - len --; - } - } else if ( _isinf(_double) > 0 ) { - s = "+Inf"; - len = 4; - while ( len > 0 ) { - if (str <= end) - *str = *s++; - ++str; - len --; - } - } else { - if ( precision == -1 ) - precision = 6; - str = numberf(str, end, (int)_double, base, field_width, precision, flags); - } - - continue; - - - /* integer number formats - set up the flags and "break" */ - case 'o': - base = 8; - break; - - case 'b': - base = 2; - break; - - case 'X': - flags |= LARGE; - case 'x': - base = 16; - break; - - case 'd': - case 'i': - flags |= SIGN; - case 'u': - break; - - default: - if (*fmt) { - if (str <= end) - *str = *fmt; - ++str; - } else - --fmt; - continue; - } - - if (qualifier == 'I') - num = va_arg(args, unsigned long long); - else if (qualifier == 'l') { - if (flags & SIGN) - num = va_arg(args, long); - else - num = va_arg(args, unsigned long); - } - else if (qualifier == 'h') { - if (flags & SIGN) - num = va_arg(args, int); - else - num = va_arg(args, unsigned int); - } - else { - if (flags & SIGN) - num = va_arg(args, int); - else - num = va_arg(args, unsigned int); - } - str = number(str, end, num, base, field_width, precision, flags); - } - if (str <= end) - *str = '\0'; - else if (cnt > 0) - /* don't write out a null byte if the buf size is zero */ - *end = '\0'; - return str-buf; -} - - -/* - * @implemented - */ -int sprintf(char * buf, const char *fmt, ...) -{ - va_list args; - int i; - - va_start(args, fmt); - i=_vsnprintf(buf,MAXLONG,fmt,args); - va_end(args); - return i; -} - - -/* - * @implemented - */ -int _snprintf(char * buf, size_t cnt, const char *fmt, ...) -{ - va_list args; - int i; - - va_start(args, fmt); - i=_vsnprintf(buf,cnt,fmt,args); - va_end(args); - return i; -} - - -/* - * @implemented - */ -int __cdecl vsprintf(char *buf, const char *fmt, va_list args) -{ - return _vsnprintf(buf,MAXLONG,fmt,args); -} - -/* EOF */
15 years, 9 months
1
0
0
0
[janderwald] 39992: - Disable some debug prints - Close the real pin on exit / when a new wave stream is played. This should fix stuttering when changing the sample rate - Always create the mixer pin
by janderwald@svn.reactos.org
Author: janderwald Date: Fri Mar 13 01:11:53 2009 New Revision: 39992 URL:
http://svn.reactos.org/svn/reactos?rev=39992&view=rev
Log: - Disable some debug prints - Close the real pin on exit / when a new wave stream is played. This should fix stuttering when changing the sample rate - Always create the mixer pin Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/dispatcher.c trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c trunk/reactos/drivers/wdm/audio/filters/kmixer/pin.c trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c trunk/reactos/drivers/wdm/audio/sysaudio/control.c trunk/reactos/drivers/wdm/audio/sysaudio/dispatcher.c trunk/reactos/drivers/wdm/audio/sysaudio/sysaudio.h Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/dispatcher.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
============================================================================== --- trunk/reactos/drivers/wdm/audio/backpln/portcls/dispatcher.c [iso-8859-1] (original) +++ trunk/reactos/drivers/wdm/audio/backpln/portcls/dispatcher.c [iso-8859-1] Fri Mar 13 01:11:53 2009 @@ -10,7 +10,7 @@ IIrpTarget * IrpTarget; PKSOBJECT_CREATE_ITEM CreateItem; - DPRINT1("Dispatch_fnDeviceIoControl called DeviceObject %p Irp %p\n", DeviceObject); + //DPRINT1("Dispatch_fnDeviceIoControl called DeviceObject %p Irp %p\n", DeviceObject); /* access the create item */ CreateItem = KSCREATE_ITEM_IRP_STORAGE(Irp); @@ -114,7 +114,7 @@ IrpTarget = (IIrpTarget*)CreateItem->Context; - DPRINT1("IrpTarget %p\n", IrpTarget); + //DPRINT1("IrpTarget %p\n", IrpTarget); return IrpTarget->lpVtbl->Close(IrpTarget, DeviceObject, Irp); } Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
============================================================================== --- trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c [iso-8859-1] (original) +++ trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c [iso-8859-1] Fri Mar 13 01:11:53 2009 @@ -15,6 +15,7 @@ PMINIPORTWAVECYCLICSTREAM Stream; KSSTATE State; PKSDATAFORMAT Format; + KSPIN_CONNECT * ConnectDetails; PVOID CommonBuffer; ULONG CommonBufferSize; @@ -184,8 +185,8 @@ } DPRINT1("Stopping %u\n", This->IrpQueue->lpVtbl->NumMappings(This->IrpQueue)); - This->Stream->lpVtbl->SetState(This->Stream, KSSTATE_PAUSE); - This->State = KSSTATE_PAUSE; + This->Stream->lpVtbl->SetState(This->Stream, KSSTATE_STOP); + This->State = KSSTATE_STOP; return; } @@ -306,7 +307,7 @@ IoStack = IoGetCurrentIrpStackLocation(Irp); - DPRINT1("IPortPinWave_HandleKsProperty entered\n"); + //DPRINT1("IPortPinWave_HandleKsProperty entered\n"); if (IoStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(KSPROPERTY)) { @@ -365,7 +366,16 @@ PKSDATAFORMAT DataFormat = (PKSDATAFORMAT)Irp->UserBuffer; if (Property->Flags & KSPROPERTY_TYPE_SET) { - PKSDATAFORMAT NewDataFormat = AllocateItem(NonPagedPool, DataFormat->FormatSize, TAG_PORTCLASS); + PKSDATAFORMAT NewDataFormat; + if (!RtlCompareMemory(DataFormat, This->Format, DataFormat->FormatSize)) + { + Irp->IoStatus.Information = DataFormat->FormatSize; + Irp->IoStatus.Status = STATUS_SUCCESS; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_SUCCESS; + } + + NewDataFormat = AllocateItem(NonPagedPool, DataFormat->FormatSize, TAG_PORTCLASS); if (!NewDataFormat) { Irp->IoStatus.Information = 0; @@ -377,11 +387,18 @@ if (This->Stream) { + ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL); + ASSERT(NewDataFormat->FormatSize == sizeof(KSDATAFORMAT_WAVEFORMATEX)); + ASSERT(IsEqualGUIDAligned(&((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->DataFormat.MajorFormat, &KSDATAFORMAT_TYPE_AUDIO)); + ASSERT(IsEqualGUIDAligned(&((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->DataFormat.SubFormat, &KSDATAFORMAT_SUBTYPE_PCM)); + ASSERT(IsEqualGUIDAligned(&((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->DataFormat.Specifier, &KSDATAFORMAT_SPECIFIER_WAVEFORMATEX)); + Status = This->Stream->lpVtbl->SetState(This->Stream, KSSTATE_STOP); + ASSERT(Status == STATUS_SUCCESS); This->State = KSSTATE_STOP; - DPRINT1("NewDataFormat: Channels %u Bits %u Samples %u\n", ((PKSDATAFORMAT_WAVEFORMATEX)DataFormat)->WaveFormatEx.nChannels, - ((PKSDATAFORMAT_WAVEFORMATEX)DataFormat)->WaveFormatEx.wBitsPerSample, - ((PKSDATAFORMAT_WAVEFORMATEX)DataFormat)->WaveFormatEx.nSamplesPerSec); + DPRINT1("NewDataFormat: Channels %u Bits %u Samples %u\n", ((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->WaveFormatEx.nChannels, + ((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->WaveFormatEx.wBitsPerSample, + ((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->WaveFormatEx.nSamplesPerSec); Status = This->Stream->lpVtbl->SetFormat(This->Stream, NewDataFormat); if (NT_SUCCESS(Status)) @@ -399,7 +416,6 @@ } DPRINT1("Failed to set format\n"); -DbgBreakPoint(); Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; IoCompleteRequest(Irp, IO_NO_INCREMENT); @@ -549,8 +565,20 @@ return KsDispatchInvalidDeviceRequest(DeviceObject, Irp); } -/* - * @unimplemented +VOID +NTAPI +CloseStreamRoutine( + IN PDEVICE_OBJECT DeviceObject, + IN PVOID Context) +{ + PMINIPORTWAVECYCLICSTREAM Stream = (PMINIPORTWAVECYCLICSTREAM)Context; + + DPRINT("CloseStreamRoutine %p\n", Stream); + Stream->lpVtbl->Release(Stream); +} + +/* + * @implemented */ NTSTATUS NTAPI @@ -559,9 +587,50 @@ IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { + ISubdevice *ISubDevice; + NTSTATUS Status; + SUBDEVICE_DESCRIPTOR * Descriptor; + PIO_WORKITEM WorkItem; + + IPortPinWaveCyclicImpl * This = (IPortPinWaveCyclicImpl*)iface; DPRINT1("IPortPinWaveCyclic_fnClose\n"); - //FIXME + Status = This->Port->lpVtbl->QueryInterface(This->Port, &IID_ISubdevice, (PVOID*)&ISubDevice); + if (NT_SUCCESS(Status)) + { + Status = ISubDevice->lpVtbl->GetDescriptor(ISubDevice, &Descriptor); + if (NT_SUCCESS(Status)) + { + ISubDevice->lpVtbl->Release(ISubDevice); + Descriptor->Factory.Instances[This->ConnectDetails->PinId].CurrentPinInstanceCount--; + DPRINT1("InstanceCount %u\n", Descriptor->Factory.Instances[This->ConnectDetails->PinId].CurrentPinInstanceCount); + } + } + + + if (This->Stream) + { + This->Stream->lpVtbl->SetState(This->Stream, KSSTATE_STOP); + } + + This->ServiceGroup->lpVtbl->RemoveMember(This->ServiceGroup, (PSERVICESINK)&This->lpVtblServiceSink); + This->ServiceGroup->lpVtbl->Release(This->ServiceGroup); + This->DmaChannel->lpVtbl->Release(This->DmaChannel); + + if (This->Format) + ExFreePool(This->Format); + + This->IrpQueue->lpVtbl->Release(This->IrpQueue); + + + if (This->Stream) + { + WorkItem = IoAllocateWorkItem(DeviceObject); + if (WorkItem) + { + IoQueueWorkItem(WorkItem, CloseStreamRoutine, DelayedWorkQueue, (PVOID)This->Stream); + } + } Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_SUCCESS; @@ -716,6 +785,7 @@ This->Port = Port; This->Filter = Filter; This->KsPinDescriptor = KsPinDescriptor; + This->ConnectDetails = ConnectDetails; This->Miniport = GetWaveCyclicMiniport(Port); DeviceObject = GetDeviceObject(Port); Modified: trunk/reactos/drivers/wdm/audio/filters/kmixer/pin.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/filters/…
============================================================================== --- trunk/reactos/drivers/wdm/audio/filters/kmixer/pin.c [iso-8859-1] (original) +++ trunk/reactos/drivers/wdm/audio/filters/kmixer/pin.c [iso-8859-1] Fri Mar 13 01:11:53 2009 @@ -163,42 +163,32 @@ PIRP Irp) { PIO_STACK_LOCATION IoStack; - PKSPROPERTY Property; - DPRINT1("Pin_fnDeviceIoControl called DeviceObject %p Irp %p\n", DeviceObject); + PKSP_PIN Property; + //DPRINT1("Pin_fnDeviceIoControl called DeviceObject %p Irp %p\n", DeviceObject); IoStack = IoGetCurrentIrpStackLocation(Irp); - if (IoStack->Parameters.DeviceIoControl.InputBufferLength == sizeof(KSPROPERTY) && IoStack->Parameters.DeviceIoControl.OutputBufferLength == sizeof(KSDATAFORMAT_WAVEFORMATEX)) - { - Property = (PKSPROPERTY)IoStack->Parameters.DeviceIoControl.Type3InputBuffer; - - if (IsEqualGUIDAligned(&Property->Set, &KSPROPSETID_Connection)) + if (IoStack->Parameters.DeviceIoControl.InputBufferLength == sizeof(KSP_PIN) && IoStack->Parameters.DeviceIoControl.OutputBufferLength == sizeof(KSDATAFORMAT_WAVEFORMATEX)) + { + Property = (PKSP_PIN)IoStack->Parameters.DeviceIoControl.Type3InputBuffer; + + if (IsEqualGUIDAligned(&Property->Property.Set, &KSPROPSETID_Connection)) { - if (Property->Id == KSPROPERTY_CONNECTION_DATAFORMAT && Property->Flags == KSPROPERTY_TYPE_SET) + if (Property->Property.Id == KSPROPERTY_CONNECTION_DATAFORMAT && Property->Property.Flags == KSPROPERTY_TYPE_SET) { - PKSDATAFORMAT_WAVEFORMATEX WaveFormat2; - PKSDATAFORMAT_WAVEFORMATEX WaveFormat = ExAllocatePool(NonPagedPool, sizeof(KSDATAFORMAT_WAVEFORMATEX)); - - if (!WaveFormat) - { - Irp->IoStatus.Information = 0; - Irp->IoStatus.Status = STATUS_NO_MEMORY; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - return STATUS_NO_MEMORY; - } - - if (IoStack->FileObject->FsContext2) - { - ExFreePool(IoStack->FileObject->FsContext2); - } - - WaveFormat2 = (PKSDATAFORMAT_WAVEFORMATEX)Irp->UserBuffer; - WaveFormat->WaveFormatEx.nChannels = WaveFormat2->WaveFormatEx.nChannels; - WaveFormat->WaveFormatEx.nSamplesPerSec = WaveFormat2->WaveFormatEx.nSamplesPerSec; - WaveFormat->WaveFormatEx.wBitsPerSample = WaveFormat2->WaveFormatEx.wBitsPerSample; - - IoStack->FileObject->FsContext2 = (PVOID)WaveFormat; - + PKSDATAFORMAT_WAVEFORMATEX Formats; + PKSDATAFORMAT_WAVEFORMATEX WaveFormat; + + Formats = (PKSDATAFORMAT_WAVEFORMATEX)IoStack->FileObject->FsContext2; + WaveFormat = (PKSDATAFORMAT_WAVEFORMATEX)Irp->UserBuffer; + + ASSERT(Property->PinId == 0 || Property->PinId == 1); + ASSERT(Formats); + ASSERT(WaveFormat); + + Formats[Property->PinId].WaveFormatEx.nChannels = WaveFormat->WaveFormatEx.nChannels; + Formats[Property->PinId].WaveFormatEx.wBitsPerSample = WaveFormat->WaveFormatEx.wBitsPerSample; + Formats[Property->PinId].WaveFormatEx.nSamplesPerSec = WaveFormat->WaveFormatEx.nSamplesPerSec; Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_SUCCESS; @@ -207,7 +197,7 @@ } } } - + DPRINT1("Size %u Expected %u\n",IoStack->Parameters.DeviceIoControl.OutputBufferLength, sizeof(KSDATAFORMAT_WAVEFORMATEX)); Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; IoCompleteRequest(Irp, IO_NO_INCREMENT); @@ -365,54 +355,34 @@ PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject) { - PKSPIN_CONNECT ConnectDetails; PKSSTREAM_HEADER StreamHeader; PVOID BufferOut; ULONG BufferLength; NTSTATUS Status = STATUS_SUCCESS; - LPWSTR PinName = L"{146F1A80-4791-11D0-A5D6-28DB04C10000}\\"; - - PKSDATAFORMAT_WAVEFORMATEX BaseFormat, TransformedFormat; + PKSDATAFORMAT_WAVEFORMATEX Formats; + PKSDATAFORMAT_WAVEFORMATEX InputFormat, OutputFormat; //DPRINT1("Pin_fnFastWrite called DeviceObject %p Irp %p\n", DeviceObject); - - BaseFormat = (PKSDATAFORMAT_WAVEFORMATEX)FileObject->FsContext2; - if (!BaseFormat) - { - DPRINT1("Expected DataFormat\n"); - DbgBreakPoint(); - IoStatus->Status = STATUS_UNSUCCESSFUL; - IoStatus->Information = 0; - return FALSE; - } - - if (FileObject->FileName.Length < wcslen(PinName) + sizeof(KSPIN_CONNECT) + sizeof(KSDATAFORMAT)) - { - DPRINT1("Expected DataFormat\n"); - DbgBreakPoint(); - IoStatus->Status = STATUS_INVALID_PARAMETER; - IoStatus->Information = 0; - return FALSE; - } - - ConnectDetails = (PKSPIN_CONNECT)(FileObject->FileName.Buffer + wcslen(PinName)); - TransformedFormat = (PKSDATAFORMAT_WAVEFORMATEX)(ConnectDetails + 1); + Formats = (PKSDATAFORMAT_WAVEFORMATEX)FileObject->FsContext2; + + InputFormat = Formats; + OutputFormat = (Formats + 1); StreamHeader = (PKSSTREAM_HEADER)Buffer; #if 0 DPRINT1("Num Channels %u Old Channels %u\n SampleRate %u Old SampleRate %u\n BitsPerSample %u Old BitsPerSample %u\n", - BaseFormat->WaveFormatEx.nChannels, TransformedFormat->WaveFormatEx.nChannels, - BaseFormat->WaveFormatEx.nSamplesPerSec, TransformedFormat->WaveFormatEx.nSamplesPerSec, - BaseFormat->WaveFormatEx.wBitsPerSample, TransformedFormat->WaveFormatEx.wBitsPerSample); -#endif - - if (BaseFormat->WaveFormatEx.wBitsPerSample != TransformedFormat->WaveFormatEx.wBitsPerSample) + InputFormat->WaveFormatEx.nChannels, OutputFormat->WaveFormatEx.nChannels, + InputFormat->WaveFormatEx.nSamplesPerSec, OutputFormat->WaveFormatEx.nSamplesPerSec, + InputFormat->WaveFormatEx.wBitsPerSample, OutputFormat->WaveFormatEx.wBitsPerSample); +#endif + + if (InputFormat->WaveFormatEx.wBitsPerSample != OutputFormat->WaveFormatEx.wBitsPerSample) { Status = PerformQualityConversion(StreamHeader->Data, StreamHeader->DataUsed, - BaseFormat->WaveFormatEx.wBitsPerSample, - TransformedFormat->WaveFormatEx.wBitsPerSample, + InputFormat->WaveFormatEx.wBitsPerSample, + OutputFormat->WaveFormatEx.wBitsPerSample, &BufferOut, &BufferLength); if (NT_SUCCESS(Status)) @@ -424,10 +394,10 @@ } } - if (BaseFormat->WaveFormatEx.nSamplesPerSec != TransformedFormat->WaveFormatEx.nSamplesPerSec) + if (InputFormat->WaveFormatEx.nSamplesPerSec != OutputFormat->WaveFormatEx.nSamplesPerSec) { /* sample format conversion must be done in a deferred routine */ - DPRINT1("SampleRate conversion not available yet\n"); + DPRINT1("SampleRate conversion not available yet %u %u\n", InputFormat->WaveFormatEx.nSamplesPerSec, OutputFormat->WaveFormatEx.nSamplesPerSec); return FALSE; } @@ -457,6 +427,18 @@ { NTSTATUS Status; KSOBJECT_HEADER ObjectHeader; + PKSDATAFORMAT DataFormat; + PIO_STACK_LOCATION IoStack; + + + DataFormat = ExAllocatePool(NonPagedPool, sizeof(KSDATAFORMAT_WAVEFORMATEX) * 2); + if (!DataFormat) + return STATUS_INSUFFICIENT_RESOURCES; + + RtlZeroMemory(DataFormat, sizeof(KSDATAFORMAT_WAVEFORMATEX) * 2); + + IoStack = IoGetCurrentIrpStackLocation(Irp); + IoStack->FileObject->FsContext2 = (PVOID)DataFormat; /* allocate object header */ Status = KsAllocateObjectHeader(&ObjectHeader, 0, NULL, Irp, &PinTable); Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/w…
============================================================================== --- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c [iso-8859-1] (original) +++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c [iso-8859-1] Fri Mar 13 01:11:53 2009 @@ -144,7 +144,7 @@ if (DeviceInfo->DeviceType != WAVE_OUT_DEVICE_TYPE && DeviceInfo->DeviceType != WAVE_IN_DEVICE_TYPE) { - DPRINT1("FIXME: only waveout devices are supported\n"); + DPRINT1("FIXME: only waveout / wavein devices are supported\n"); return SetIrpIoStatus(Irp, STATUS_UNSUCCESSFUL, 0); } @@ -154,7 +154,6 @@ DPRINT1("Invalid device index %u\n", DeviceInfo->DeviceIndex); return SetIrpIoStatus(Irp, STATUS_UNSUCCESSFUL, 0); } - Length = sizeof(KSDATAFORMAT_WAVEFORMATEX) + sizeof(KSPIN_CONNECT) + sizeof(SYSAUDIO_INSTANCE_INFO); InstanceInfo = ExAllocatePool(NonPagedPool, Length); @@ -343,8 +342,6 @@ } } } - else - DPRINT1("KSPROPERTY_PIN_CTYPES index %u failed with %x\n", Index, Status); } @@ -370,7 +367,7 @@ ULONG BytesReturned; PFILE_OBJECT FileObject; - DPRINT1("WdmAudControlDeviceState\n"); + //DPRINT1("WdmAudControlDeviceState\n"); Status = ObReferenceObjectByHandle(DeviceInfo->hDevice, GENERIC_READ | GENERIC_WRITE, IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); if (!NT_SUCCESS(Status)) @@ -389,7 +386,7 @@ ObDereferenceObject(FileObject); - DPRINT1("WdmAudControlDeviceState Status %x\n", Status); + //DPRINT1("WdmAudControlDeviceState Status %x\n", Status); return SetIrpIoStatus(Irp, Status, sizeof(WDMAUD_DEVICE_INFO)); } @@ -468,7 +465,6 @@ DPRINT("WdmAudCapabilities entered\n"); - Status = GetFilterIdAndPinId(DeviceObject, DeviceInfo, ClientInfo, &FilterId, &PinId); if (!NT_SUCCESS(Status)) { @@ -595,7 +591,7 @@ IoStack = IoGetCurrentIrpStackLocation(Irp); - DPRINT1("WdmAudDeviceControl entered\n"); + DPRINT("WdmAudDeviceControl entered\n"); if (IoStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(WDMAUD_DEVICE_INFO)) { @@ -621,7 +617,7 @@ } ClientInfo = (PWDMAUD_CLIENT)IoStack->FileObject->FsContext; - DPRINT1("WdmAudDeviceControl entered\n"); + DPRINT("WdmAudDeviceControl entered\n"); switch(IoStack->Parameters.DeviceIoControl.IoControlCode) { Modified: trunk/reactos/drivers/wdm/audio/sysaudio/control.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/sysaudio…
============================================================================== --- trunk/reactos/drivers/wdm/audio/sysaudio/control.c [iso-8859-1] (original) +++ trunk/reactos/drivers/wdm/audio/sysaudio/control.c [iso-8859-1] Fri Mar 13 01:11:53 2009 @@ -33,7 +33,14 @@ { Irp->IoStatus.Information = Length; Irp->IoStatus.Status = Status; - IoCompleteRequest(Irp, IO_NO_INCREMENT); + if (Status != STATUS_PENDING) + { + IoCompleteRequest(Irp, IO_NO_INCREMENT); + } + else + { + IoMarkIrpPending(Irp); + } return Status; } @@ -139,6 +146,90 @@ return SetIrpIoStatus(Irp, STATUS_SUCCESS, 0); } +NTSTATUS +SetMixerInputOutputFormat( + IN PFILE_OBJECT FileObject, + IN PKSDATAFORMAT InputFormat, + IN PKSDATAFORMAT OutputFormat) +{ + KSP_PIN PinRequest; + ULONG BytesReturned; + NTSTATUS Status; + + /* re-using pin */ + PinRequest.Property.Set = KSPROPSETID_Connection; + PinRequest.Property.Flags = KSPROPERTY_TYPE_SET; + PinRequest.Property.Id = KSPROPERTY_CONNECTION_DATAFORMAT; + + /* set the input format */ + PinRequest.PinId = 0; + //DPRINT1("InputFormat %p Size %u WaveFormatSize %u DataFormat %u WaveEx %u\n", InputFormat, InputFormat->FormatSize, sizeof(KSDATAFORMAT_WAVEFORMATEX), sizeof(KSDATAFORMAT), sizeof(WAVEFORMATEX)); + Status = KsSynchronousIoControlDevice(FileObject, KernelMode, IOCTL_KS_PROPERTY, + (PVOID)&PinRequest, + sizeof(KSP_PIN), + (PVOID)InputFormat, + InputFormat->FormatSize, + &BytesReturned); + if (!NT_SUCCESS(Status)) + return Status; + + /* set the the output format */ + PinRequest.PinId = 1; + //DPRINT1("OutputFormat %p Size %u WaveFormatSize %u DataFormat %u WaveEx %u\n", OutputFormat, OutputFormat->FormatSize, sizeof(KSDATAFORMAT_WAVEFORMATEX), sizeof(KSDATAFORMAT), sizeof(WAVEFORMATEX)); + Status = KsSynchronousIoControlDevice(FileObject, KernelMode, IOCTL_KS_PROPERTY, + (PVOID)&PinRequest, + sizeof(KSP_PIN), + (PVOID)OutputFormat, + OutputFormat->FormatSize, + &BytesReturned); + return Status; +} + + +NTSTATUS +CreateMixerPinAndSetFormat( + IN HANDLE KMixerHandle, + IN KSPIN_CONNECT *PinConnect, + IN PKSDATAFORMAT InputFormat, + IN PKSDATAFORMAT OutputFormat, + OUT PHANDLE MixerPinHandle, + OUT PFILE_OBJECT *MixerFileObject) +{ + NTSTATUS Status; + HANDLE PinHandle; + PFILE_OBJECT FileObject; + + Status = KsCreatePin(KMixerHandle, PinConnect, GENERIC_READ | GENERIC_WRITE, &PinHandle); + + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to create Mixer Pin with %x\n", Status); + return STATUS_UNSUCCESSFUL; + } + + Status = ObReferenceObjectByHandle(PinHandle, + GENERIC_READ | GENERIC_WRITE, + IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); + + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to get file object with %x\n", Status); + return STATUS_UNSUCCESSFUL; + } + + Status = SetMixerInputOutputFormat(FileObject, InputFormat, OutputFormat); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject(FileObject); + ZwClose(PinHandle); + } + + *MixerPinHandle = PinHandle; + *MixerFileObject = FileObject; + return Status; +} + + VOID NTAPI CreatePinWorkerRoutine( @@ -147,22 +238,22 @@ { NTSTATUS Status; PSYSAUDIO_CLIENT AudioClient; - HANDLE RealPinHandle, VirtualPinHandle, MixerPinHandle = NULL; + HANDLE RealPinHandle, VirtualPinHandle; HANDLE Filter; - ULONG NumHandels, BytesReturned; - PFILE_OBJECT FileObject, MixerFileObject = NULL; + ULONG NumHandels; + PFILE_OBJECT FileObject; PSYSAUDIO_PIN_HANDLE ClientPinHandle; PPIN_WORKER_CONTEXT WorkerContext = (PPIN_WORKER_CONTEXT)Context; PKSPIN_CONNECT PinConnect = NULL; - KSPROPERTY PinRequest; - PKSDATAFORMAT_WAVEFORMATEX ClientFormat; + PKSDATAFORMAT ClientFormat; + KSP_PIN PinRequest; + ULONG BytesReturned; Filter = WorkerContext->PinConnect->PinToHandle; - WorkerContext->PinConnect->PinToHandle = NULL; - DPRINT1("CreatePinWorkerRoutine entered\n"); + DPRINT("CreatePinWorkerRoutine entered\n"); ASSERT(WorkerContext->Entry); ASSERT(WorkerContext->PinConnect); @@ -170,7 +261,7 @@ ASSERT(WorkerContext->Entry->NumberOfPins > WorkerContext->PinConnect->PinId); PinConnect = WorkerContext->PinConnect; - ClientFormat = (PKSDATAFORMAT_WAVEFORMATEX)(PinConnect + 1); + ClientFormat = (PKSDATAFORMAT)(PinConnect + 1); if (WorkerContext->CreateMixerPin) { @@ -188,8 +279,14 @@ RtlMoveMemory(PinConnect, WorkerContext->PinConnect, sizeof(KSPIN_CONNECT)); RtlMoveMemory((PinConnect + 1), WorkerContext->MixerFormat, WorkerContext->MixerFormat->DataFormat.FormatSize); - - Status = KsCreatePin(WorkerContext->DeviceExtension->KMixerHandle, PinConnect, GENERIC_READ | GENERIC_WRITE, &MixerPinHandle); + Status = CreateMixerPinAndSetFormat(WorkerContext->DeviceExtension->KMixerHandle, + PinConnect, + (PKSDATAFORMAT)(WorkerContext->PinConnect + 1), + (PKSDATAFORMAT)WorkerContext->MixerFormat, + &WorkerContext->DispatchContext->hMixerPin, + &WorkerContext->DispatchContext->MixerFileObject); + + ExFreePool(WorkerContext->MixerFormat); if (!NT_SUCCESS(Status)) { @@ -199,10 +296,60 @@ ExFreePool(WorkerContext); return; } - - Status = ObReferenceObjectByHandle(MixerPinHandle, + } + else + { + Status = CreateMixerPinAndSetFormat(WorkerContext->DeviceExtension->KMixerHandle, + WorkerContext->PinConnect, + (PKSDATAFORMAT)(WorkerContext->PinConnect + 1), + (PKSDATAFORMAT)(WorkerContext->PinConnect + 1), + &WorkerContext->DispatchContext->hMixerPin, + &WorkerContext->DispatchContext->MixerFileObject); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to create Mixer Pin with %x\n", Status); + SetIrpIoStatus(WorkerContext->Irp, STATUS_UNSUCCESSFUL, 0); + ExFreePool(WorkerContext->DispatchContext); + ExFreePool(WorkerContext); + return; + } + } + + if (WorkerContext->CreateRealPin) + { + /* create the real pin */ + DPRINT("Creating real pin\n"); + + if (WorkerContext->CreateMixerPin) + Status = KsCreatePin(WorkerContext->Entry->Handle, PinConnect, GENERIC_READ | GENERIC_WRITE, &RealPinHandle); + else + Status = KsCreatePin(WorkerContext->Entry->Handle, WorkerContext->PinConnect, GENERIC_READ | GENERIC_WRITE, &RealPinHandle); + + DPRINT1("Status %x\n", Status); + if (!NT_SUCCESS(Status)) + { + PKSDATAFORMAT_WAVEFORMATEX RequestedFormat = (PKSDATAFORMAT_WAVEFORMATEX)(WorkerContext->PinConnect + 1); + DPRINT1("Failed to create Pin with %x\nNumChannels: %u BitsPerSample %u SampleRate %u\n", Status, + RequestedFormat->WaveFormatEx.nChannels, RequestedFormat->WaveFormatEx.wBitsPerSample, RequestedFormat->WaveFormatEx.nSamplesPerSec); + + if (WorkerContext->CreateMixerPin) + { + /* The mixer pin format should have been accepted */ + ObDereferenceObject(WorkerContext->DispatchContext->MixerFileObject); + ZwClose(WorkerContext->DispatchContext->hMixerPin); + ASSERT(0); + } + + SetIrpIoStatus(WorkerContext->Irp, STATUS_UNSUCCESSFUL, 0); + ExFreePool(WorkerContext->DispatchContext); + ExFreePool(WorkerContext); + return; + } + + /* get pin file object */ + Status = ObReferenceObjectByHandle(RealPinHandle, GENERIC_READ | GENERIC_WRITE, - IoFileObjectType, KernelMode, (PVOID*)&MixerFileObject, NULL); + IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); if (!NT_SUCCESS(Status)) { @@ -213,94 +360,58 @@ return; } - WorkerContext->DispatchContext->hMixerPin = MixerPinHandle; - WorkerContext->DispatchContext->MixerFileObject = MixerFileObject; - - PinRequest.Set = KSPROPSETID_Connection; - PinRequest.Flags = KSPROPERTY_TYPE_SET; - PinRequest.Id = KSPROPERTY_CONNECTION_DATAFORMAT; - - DPRINT1("ClientFormat %p Channels %u Samples %u Bits %u\n", ClientFormat, ClientFormat->WaveFormatEx.nChannels, ClientFormat->WaveFormatEx.nSamplesPerSec, ClientFormat->WaveFormatEx.wBitsPerSample); - - Status = KsSynchronousIoControlDevice(MixerFileObject, KernelMode, IOCTL_KS_PROPERTY, - (PVOID)&PinRequest, - sizeof(KSPROPERTY), - (PVOID)ClientFormat, - sizeof(KSDATAFORMAT_WAVEFORMATEX), - &BytesReturned); - - } - - if (WorkerContext->CreateRealPin) - { - /* create the real pin */ - DPRINT("Creating real pin\n"); - - if (WorkerContext->CreateMixerPin) - Status = KsCreatePin(WorkerContext->Entry->Handle, PinConnect, GENERIC_READ | GENERIC_WRITE, &RealPinHandle); - else - Status = KsCreatePin(WorkerContext->Entry->Handle, WorkerContext->PinConnect, GENERIC_READ | GENERIC_WRITE, &RealPinHandle); - - DPRINT1("Status %x\n", Status); + if (WorkerContext->Entry->Pins[WorkerContext->PinConnect->PinId].MaxPinInstanceCount == 1) + { + /* store the pin handle there is the pin can only be instantiated once*/ + WorkerContext->Entry->Pins[WorkerContext->PinConnect->PinId].PinHandle = RealPinHandle; + } + + WorkerContext->Entry->Pins[WorkerContext->PinConnect->PinId].References = 0; + WorkerContext->DispatchContext->Handle = RealPinHandle; + WorkerContext->DispatchContext->PinId = WorkerContext->PinConnect->PinId; + WorkerContext->DispatchContext->AudioEntry = WorkerContext->Entry; + WorkerContext->DispatchContext->FileObject = FileObject; + } + else + { + WorkerContext->DispatchContext->AudioEntry = WorkerContext->Entry; + WorkerContext->DispatchContext->Handle = WorkerContext->Entry->Pins[WorkerContext->PinConnect->PinId].PinHandle; + WorkerContext->DispatchContext->PinId = WorkerContext->PinConnect->PinId; + + /* get pin file object */ + Status = ObReferenceObjectByHandle(WorkerContext->Entry->Pins[WorkerContext->PinConnect->PinId].PinHandle, + GENERIC_READ | GENERIC_WRITE, + IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); + if (!NT_SUCCESS(Status)) { - DPRINT1("Failed to create Pin with %x\n", Status); + DPRINT1("Failed to get file object with %x %p\n", Status, WorkerContext->Entry->Pins[WorkerContext->PinConnect->PinId].PinHandle); SetIrpIoStatus(WorkerContext->Irp, STATUS_UNSUCCESSFUL, 0); ExFreePool(WorkerContext->DispatchContext); ExFreePool(WorkerContext); return; } - - /* get pin file object */ - Status = ObReferenceObjectByHandle(RealPinHandle, - GENERIC_READ | GENERIC_WRITE, - IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); - - DPRINT1("Status %x\n", Status); - if (!NT_SUCCESS(Status)) - { - DPRINT1("Failed to get file object with %x\n", Status); - SetIrpIoStatus(WorkerContext->Irp, STATUS_UNSUCCESSFUL, 0); - ExFreePool(WorkerContext->DispatchContext); - ExFreePool(WorkerContext); - return; - } - - if (WorkerContext->Entry->Pins[WorkerContext->PinConnect->PinId].MaxPinInstanceCount == 1) - { - /* store the pin handle there is the pin can only be instantiated once*/ - WorkerContext->Entry->Pins[WorkerContext->PinConnect->PinId].PinHandle = RealPinHandle; - } - - WorkerContext->Entry->Pins[WorkerContext->PinConnect->PinId].References = 1; - WorkerContext->DispatchContext->Handle = RealPinHandle; - WorkerContext->DispatchContext->PinId = WorkerContext->PinConnect->PinId; - WorkerContext->DispatchContext->AudioEntry = WorkerContext->Entry; WorkerContext->DispatchContext->FileObject = FileObject; - } - else - { - WorkerContext->DispatchContext->AudioEntry = WorkerContext->Entry; - WorkerContext->DispatchContext->Handle = WorkerContext->Entry->Pins[WorkerContext->PinConnect->PinId].PinHandle; - WorkerContext->DispatchContext->PinId = WorkerContext->PinConnect->PinId; - - /* get pin file object */ - Status = ObReferenceObjectByHandle(WorkerContext->Entry->Pins[WorkerContext->PinConnect->PinId].PinHandle, - GENERIC_READ | GENERIC_WRITE, - IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); - - if (!NT_SUCCESS(Status)) - { - DPRINT1("Failed to get file object with %x\n", Status); - SetIrpIoStatus(WorkerContext->Irp, STATUS_UNSUCCESSFUL, 0); - ExFreePool(WorkerContext->DispatchContext); - ExFreePool(WorkerContext); - return; - } - WorkerContext->DispatchContext->FileObject = FileObject; - } - - DPRINT1("creating virtual pin\n"); + + + /* re-using pin */ + PinRequest.Property.Set = KSPROPSETID_Connection; + PinRequest.Property.Flags = KSPROPERTY_TYPE_SET; + PinRequest.Property.Id = KSPROPERTY_CONNECTION_DATAFORMAT; + PinRequest.PinId = PinConnect->PinId; + + if (WorkerContext->MixerFormat) + ClientFormat = (PKSDATAFORMAT)WorkerContext->MixerFormat; + else + ClientFormat = (PKSDATAFORMAT)(WorkerContext->PinConnect + 1); + + /* set the format on the real pin */ + Status = KsSynchronousIoControlDevice(FileObject, KernelMode, IOCTL_KS_PROPERTY, (PVOID)&PinRequest, sizeof(KSPROPERTY), + (PVOID)ClientFormat, ClientFormat->FormatSize, &BytesReturned); + + } + + DPRINT("creating virtual pin\n"); /* now create the virtual audio pin which is exposed to wdmaud */ Status = KsCreatePin(Filter, WorkerContext->PinConnect, GENERIC_READ | GENERIC_WRITE, &VirtualPinHandle); @@ -369,27 +480,28 @@ AudioClient->Devs[AudioClient->NumDevices -1].ClientHandles[NumHandels].bHandle = TRUE; AudioClient->Devs[AudioClient->NumDevices -1].ClientHandles[NumHandels].hPin = RealPinHandle; AudioClient->Devs[AudioClient->NumDevices -1].ClientHandles[NumHandels].PinId = WorkerContext->PinConnect->PinId; - AudioClient->Devs[AudioClient->NumDevices -1].ClientHandles[NumHandels].hMixer = MixerPinHandle; - + AudioClient->Devs[AudioClient->NumDevices -1].ClientHandles[NumHandels].hMixer = WorkerContext->DispatchContext->hMixerPin; + AudioClient->Devs[AudioClient->NumDevices -1].ClientHandles[NumHandels].DispatchContext = WorkerContext->DispatchContext; } else { AudioClient->Devs[AudioClient->NumDevices -1].ClientHandles[NumHandels].bHandle = FALSE; AudioClient->Devs[AudioClient->NumDevices -1].ClientHandles[NumHandels].hPin = VirtualPinHandle; AudioClient->Devs[AudioClient->NumDevices -1].ClientHandles[NumHandels].PinId = WorkerContext->PinConnect->PinId; - AudioClient->Devs[AudioClient->NumDevices -1].ClientHandles[NumHandels].hMixer = MixerPinHandle; + AudioClient->Devs[AudioClient->NumDevices -1].ClientHandles[NumHandels].hMixer = WorkerContext->DispatchContext->hMixerPin; + AudioClient->Devs[AudioClient->NumDevices -1].ClientHandles[NumHandels].DispatchContext = WorkerContext->DispatchContext; } /// increase reference count + AudioClient->Devs[AudioClient->NumDevices -1].ClientHandlesCount++; WorkerContext->Entry->Pins[WorkerContext->PinConnect->PinId].References++; - AudioClient->Devs[AudioClient->NumDevices -1].ClientHandlesCount++; } /* store pin context */ FileObject->FsContext2 = (PVOID)WorkerContext->DispatchContext; - DPRINT1("Successfully created virtual pin %p\n", VirtualPinHandle); + DPRINT("Successfully created virtual pin %p\n", VirtualPinHandle); *((PHANDLE)WorkerContext->Irp->UserBuffer) = VirtualPinHandle; SetIrpIoStatus(WorkerContext->Irp, STATUS_SUCCESS, sizeof(HANDLE)); @@ -488,48 +600,97 @@ } } -NTSTATUS -SetPinFormat( - PKSAUDIO_DEVICE_ENTRY Entry, - KSPIN_CONNECT * PinConnect, - ULONG Length) +BOOL +ComputeCompatibleFormat( + IN PKSAUDIO_DEVICE_ENTRY Entry, + IN ULONG PinId, + IN PSYSAUDIODEVEXT DeviceExtension, + IN PKSDATAFORMAT_WAVEFORMATEX ClientFormat, + OUT PKSDATAFORMAT_WAVEFORMATEX MixerFormat) { + BOOL bFound; + ULONG BytesReturned; KSP_PIN PinRequest; - PFILE_OBJECT FileObject; - ULONG BytesReturned; + PKSDATARANGE_AUDIO AudioRange; NTSTATUS Status; - - /* re-using pin */ - PinRequest.Property.Set = KSPROPSETID_Connection; - PinRequest.Property.Flags = KSPROPERTY_TYPE_SET; - PinRequest.Property.Id = KSPROPERTY_CONNECTION_DATAFORMAT; - PinRequest.PinId = PinConnect->PinId; - - - /* get pin file object */ - Status = ObReferenceObjectByHandle(Entry->Pins[PinConnect->PinId].PinHandle, - GENERIC_READ | GENERIC_WRITE, - IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); - - if (!NT_SUCCESS(Status)) - { - DPRINT1("Failed to get pin file object with %x\n", Status); - return Status; - } - - Length -= sizeof(KSPIN_CONNECT) + sizeof(SYSAUDIO_INSTANCE_INFO); - Status = KsSynchronousIoControlDevice(FileObject, KernelMode, IOCTL_KS_PROPERTY, (PVOID)&PinRequest, sizeof(KSPROPERTY), - (PVOID)(PinConnect + 1), Length, &BytesReturned); - ObDereferenceObject(FileObject); - - if (!NT_SUCCESS(Status)) - { - /* set the format on the mixer pin */ - UNIMPLEMENTED - return STATUS_SUCCESS; - } - - return Status; + ULONG Index; + PKSMULTIPLE_ITEM MultipleItem; + + if (!DeviceExtension->KMixerHandle || !DeviceExtension->KMixerFileObject) + { + DPRINT1("KMixer is not available\n"); + return STATUS_UNSUCCESSFUL; + } + + PinRequest.PinId = PinId; + PinRequest.Property.Set = KSPROPSETID_Pin; + PinRequest.Property.Flags = KSPROPERTY_TYPE_GET; + PinRequest.Property.Id = KSPROPERTY_PIN_DATARANGES; + + Status = KsSynchronousIoControlDevice(Entry->FileObject, KernelMode, IOCTL_KS_PROPERTY, (PVOID)&PinRequest, sizeof(KSP_PIN), NULL, 0, &BytesReturned); + if (Status != STATUS_BUFFER_TOO_SMALL) + { + DPRINT1("Property Request KSPROPERTY_PIN_DATARANGES failed with %x\n", Status); + return STATUS_UNSUCCESSFUL; + } + + MultipleItem = ExAllocatePool(NonPagedPool, BytesReturned); + if (!MultipleItem) + { + return STATUS_NO_MEMORY; + } + + Status = KsSynchronousIoControlDevice(Entry->FileObject, KernelMode, IOCTL_KS_PROPERTY, (PVOID)&PinRequest, sizeof(KSP_PIN), (PVOID)MultipleItem, BytesReturned, &BytesReturned); + if (!NT_SUCCESS(Status)) + { + DPRINT("Property Request KSPROPERTY_PIN_DATARANGES failed with %x\n", Status); + ExFreePool(MultipleItem); + return STATUS_UNSUCCESSFUL; + } + + AudioRange = (PKSDATARANGE_AUDIO)(MultipleItem + 1); + bFound = FALSE; + for(Index = 0; Index < MultipleItem->Count; Index++) + { + if (AudioRange->DataRange.FormatSize != sizeof(KSDATARANGE_AUDIO)) + { + UNIMPLEMENTED + AudioRange = (PKSDATARANGE_AUDIO)((PUCHAR)AudioRange + AudioRange->DataRange.FormatSize); + } + MixerFormat->DataFormat.FormatSize = sizeof(KSDATAFORMAT) + sizeof(WAVEFORMATEX); + MixerFormat->DataFormat.Flags = 0; + MixerFormat->DataFormat.Reserved = 0; + MixerFormat->DataFormat.MajorFormat = KSDATAFORMAT_TYPE_AUDIO; + MixerFormat->DataFormat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; + MixerFormat->DataFormat.Specifier = KSDATAFORMAT_SPECIFIER_WAVEFORMATEX; + MixerFormat->DataFormat.SampleSize = 4; + MixerFormat->WaveFormatEx.wFormatTag = ClientFormat->WaveFormatEx.wFormatTag; + MixerFormat->WaveFormatEx.nChannels = min(AudioRange->MaximumChannels, ClientFormat->WaveFormatEx.nChannels); + MixerFormat->WaveFormatEx.nSamplesPerSec = max(AudioRange->MinimumSampleFrequency, min(AudioRange->MaximumSampleFrequency, ClientFormat->WaveFormatEx.nSamplesPerSec)); + MixerFormat->WaveFormatEx.wBitsPerSample = max(AudioRange->MinimumBitsPerSample, min(AudioRange->MaximumBitsPerSample, ClientFormat->WaveFormatEx.wBitsPerSample)); + MixerFormat->WaveFormatEx.cbSize = 0; + MixerFormat->WaveFormatEx.nBlockAlign = (MixerFormat->WaveFormatEx.nChannels * MixerFormat->WaveFormatEx.wBitsPerSample) / 8; + MixerFormat->WaveFormatEx.nAvgBytesPerSec = MixerFormat->WaveFormatEx.nChannels * MixerFormat->WaveFormatEx.nSamplesPerSec * (MixerFormat->WaveFormatEx.wBitsPerSample / 8); + + bFound = TRUE; + break; + + AudioRange = (PKSDATARANGE_AUDIO)((PUCHAR)AudioRange + AudioRange->DataRange.FormatSize); + } + ExFreePool(MultipleItem); + + +#if 0 + DPRINT1("\nNum Channels %u Old Channels %u\n SampleRate %u Old SampleRate %u\n BitsPerSample %u Old BitsPerSample %u\n ClientFormat %p", + MixerFormat->WaveFormatEx.nChannels, ClientFormat->WaveFormatEx.nChannels, + MixerFormat->WaveFormatEx.nSamplesPerSec, ClientFormat->WaveFormatEx.nSamplesPerSec, + MixerFormat->WaveFormatEx.wBitsPerSample, ClientFormat->WaveFormatEx.wBitsPerSample, ClientFormat); +#endif + + if (bFound) + return STATUS_SUCCESS; + else + return STATUS_NOT_IMPLEMENTED; } @@ -555,10 +716,9 @@ PDISPATCH_CONTEXT DispatchContext; ULONG Index, SubIndex; BOOL CreateMixerPin; - PKSDATARANGE_AUDIO AudioRange; + ULONG DeviceId; PKSDATAFORMAT_WAVEFORMATEX MixerFormat = NULL, ClientFormat; - PKSMULTIPLE_ITEM MultipleItem; IoStack = IoGetCurrentIrpStackLocation(Irp); @@ -611,6 +771,27 @@ DPRINT("Invalid PinId %x\n", PinConnect->PinId); return SetIrpIoStatus(Irp, STATUS_INVALID_PARAMETER, 0); } + +Retry: + /* get the instances count */ + PinRequest.PinId = PinConnect->PinId; + PinRequest.Property.Set = KSPROPSETID_Pin; + PinRequest.Property.Flags = KSPROPERTY_TYPE_GET; + PinRequest.Property.Id = KSPROPERTY_PIN_CINSTANCES; + + Status = KsSynchronousIoControlDevice(Entry->FileObject, KernelMode, IOCTL_KS_PROPERTY, (PVOID)&PinRequest, sizeof(KSP_PIN), (PVOID)&PinInstances, sizeof(KSPIN_CINSTANCES), &BytesReturned); + if (!NT_SUCCESS(Status)) + { + DPRINT("Property Request KSPROPERTY_PIN_GLOBALCINSTANCES failed with %x\n", Status); + return SetIrpIoStatus(Irp, Status, 0); + } + + if (PinInstances.PossibleCount == 0) + { + /* caller wanted to open an instance-less pin */ + return SetIrpIoStatus(Irp, STATUS_UNSUCCESSFUL, 0); + } + /* check the format */ PinRequest.PinId = PinConnect->PinId; @@ -620,12 +801,6 @@ CreateMixerPin = FALSE; BytesReturned = IoStack->Parameters.DeviceIoControl.InputBufferLength - sizeof(KSPIN_CONNECT) - sizeof(SYSAUDIO_INSTANCE_INFO); - if (BytesReturned != sizeof(KSDATAFORMAT_WAVEFORMATEX)) - { - UNIMPLEMENTED - return SetIrpIoStatus(Irp, STATUS_UNSUCCESSFUL, 0); - } - ClientFormat = (PKSDATAFORMAT_WAVEFORMATEX)(PinConnect + 1); Status = KsSynchronousIoControlDevice(Entry->FileObject, KernelMode, IOCTL_KS_PROPERTY, (PVOID)&PinRequest, sizeof(KSP_PIN), (PVOID)ClientFormat, BytesReturned, &BytesReturned); @@ -640,136 +815,58 @@ return SetIrpIoStatus(Irp, STATUS_UNSUCCESSFUL, 0); } - PinRequest.PinId = PinConnect->PinId; - PinRequest.Property.Set = KSPROPSETID_Pin; - PinRequest.Property.Flags = KSPROPERTY_TYPE_GET; - PinRequest.Property.Id = KSPROPERTY_PIN_DATARANGES; - - Status = KsSynchronousIoControlDevice(Entry->FileObject, KernelMode, IOCTL_KS_PROPERTY, (PVOID)&PinRequest, sizeof(KSP_PIN), NULL, 0, &BytesReturned); - if (Status != STATUS_BUFFER_TOO_SMALL) - { - DPRINT1("Property Request KSPROPERTY_PIN_DATARANGES failed with %x\n", Status); - return SetIrpIoStatus(Irp, STATUS_UNSUCCESSFUL, 0); - } - - MultipleItem = ExAllocatePool(NonPagedPool, BytesReturned); - if (!MultipleItem) - { - return SetIrpIoStatus(Irp, STATUS_UNSUCCESSFUL, 0); - } - MixerFormat = ExAllocatePool(NonPagedPool, sizeof(KSDATAFORMAT_WAVEFORMATEX)); if (!MixerFormat) { - ExFreePool(MultipleItem); - return SetIrpIoStatus(Irp, STATUS_UNSUCCESSFUL, 0); - } - - Status = KsSynchronousIoControlDevice(Entry->FileObject, KernelMode, IOCTL_KS_PROPERTY, (PVOID)&PinRequest, sizeof(KSP_PIN), (PVOID)MultipleItem, BytesReturned, &BytesReturned); + return SetIrpIoStatus(Irp, STATUS_NO_MEMORY, 0); + } + + Status = ComputeCompatibleFormat(Entry, PinConnect->PinId, DeviceExtension, ClientFormat, MixerFormat); if (!NT_SUCCESS(Status)) { - DPRINT("Property Request KSPROPERTY_PIN_DATARANGES failed with %x\n", Status); ExFreePool(MixerFormat); - ExFreePool(MultipleItem); - return SetIrpIoStatus(Irp, STATUS_UNSUCCESSFUL, 0); - } - - CreateMixerPin = FALSE; - AudioRange = (PKSDATARANGE_AUDIO)(MultipleItem + 1); - for(Index = 0; Index < MultipleItem->Count; Index++) - { - if (AudioRange->DataRange.FormatSize != sizeof(KSDATARANGE_AUDIO)) - { - UNIMPLEMENTED - AudioRange = (PKSDATARANGE_AUDIO)((PUCHAR)AudioRange + AudioRange->DataRange.FormatSize); - } - MixerFormat->DataFormat.FormatSize = sizeof(KSDATAFORMAT) + sizeof(WAVEFORMATEX); - MixerFormat->DataFormat.Flags = 0; - MixerFormat->DataFormat.Reserved = 0; - MixerFormat->DataFormat.MajorFormat = KSDATAFORMAT_TYPE_AUDIO; - MixerFormat->DataFormat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; - MixerFormat->DataFormat.Specifier = KSDATAFORMAT_SPECIFIER_WAVEFORMATEX; - MixerFormat->DataFormat.SampleSize = 4; - MixerFormat->WaveFormatEx.wFormatTag = ClientFormat->WaveFormatEx.wFormatTag; - MixerFormat->WaveFormatEx.nChannels = min(AudioRange->MaximumChannels, ClientFormat->WaveFormatEx.nChannels); - MixerFormat->WaveFormatEx.nSamplesPerSec = max(AudioRange->MinimumSampleFrequency, min(AudioRange->MaximumSampleFrequency, ClientFormat->WaveFormatEx.nSamplesPerSec)); - MixerFormat->WaveFormatEx.wBitsPerSample = max(AudioRange->MinimumBitsPerSample, min(AudioRange->MaximumBitsPerSample, ClientFormat->WaveFormatEx.wBitsPerSample)); - MixerFormat->WaveFormatEx.cbSize = 0; - MixerFormat->WaveFormatEx.nBlockAlign = (MixerFormat->WaveFormatEx.nChannels * MixerFormat->WaveFormatEx.wBitsPerSample) / 8; - MixerFormat->WaveFormatEx.nAvgBytesPerSec = MixerFormat->WaveFormatEx.nChannels * MixerFormat->WaveFormatEx.nSamplesPerSec * (MixerFormat->WaveFormatEx.wBitsPerSample / 8); - - CreateMixerPin = TRUE; - break; - - AudioRange = (PKSDATARANGE_AUDIO)((PUCHAR)AudioRange + AudioRange->DataRange.FormatSize); - } - ExFreePool(MultipleItem); - if (!CreateMixerPin) - { - ExFreePool(MixerFormat); - DPRINT1("No Format found :(\n"); - return SetIrpIoStatus(Irp, STATUS_UNSUCCESSFUL, 0); - } -#if 0 - DPRINT1("\nNum Channels %u Old Channels %u\n SampleRate %u Old SampleRate %u\n BitsPerSample %u Old BitsPerSample %u\n ClientFormat %p", - MixerFormat->WaveFormatEx.nChannels, ClientFormat->WaveFormatEx.nChannels, - MixerFormat->WaveFormatEx.nSamplesPerSec, ClientFormat->WaveFormatEx.nSamplesPerSec, - MixerFormat->WaveFormatEx.wBitsPerSample, ClientFormat->WaveFormatEx.wBitsPerSample, ClientFormat); -#endif - } - - /* get the instances count */ - PinRequest.PinId = PinConnect->PinId; - PinRequest.Property.Set = KSPROPSETID_Pin; - PinRequest.Property.Flags = KSPROPERTY_TYPE_GET; - PinRequest.Property.Id = KSPROPERTY_PIN_CINSTANCES; - - Status = KsSynchronousIoControlDevice(Entry->FileObject, KernelMode, IOCTL_KS_PROPERTY, (PVOID)&PinRequest, sizeof(KSP_PIN), (PVOID)&PinInstances, sizeof(KSPIN_CINSTANCES), &BytesReturned); - if (!NT_SUCCESS(Status)) - { - DPRINT("Property Request KSPROPERTY_PIN_GLOBALCINSTANCES failed with %x\n", Status); - if (MixerFormat) - ExFreePool(MixerFormat); - return SetIrpIoStatus(Irp, Status, 0); - } - - if (PinInstances.PossibleCount == 0) - { - /* caller wanted to open an instance-less pin */ - if (MixerFormat) - ExFreePool(MixerFormat); - return SetIrpIoStatus(Irp, STATUS_UNSUCCESSFUL, 0); - } - - if (PinInstances.CurrentCount == PinInstances.PossibleCount) - { - for (Index = 0; Index < ClientInfo->NumDevices; Index++) - { - if (ClientInfo->Devs[Index].DeviceId == InstanceInfo->DeviceNumber) - { - if (ClientInfo->Devs[Index].ClientHandlesCount) + return SetIrpIoStatus(Irp, Status, 0); + } + CreateMixerPin = TRUE; + } + + DeviceId = (ULONG)-1; + + /* scan the clientinfo if the client has already opened device with the specified pin */ + for (Index = 0; Index < ClientInfo->NumDevices; Index++) + { + if (ClientInfo->Devs[Index].DeviceId == InstanceInfo->DeviceNumber) + { + DeviceId = Index; + if (ClientInfo->Devs[Index].ClientHandlesCount) + { + for(SubIndex = 0; SubIndex < ClientInfo->Devs[Index].ClientHandlesCount; SubIndex++) { - for(SubIndex = 0; SubIndex < ClientInfo->Devs[Index].ClientHandlesCount; SubIndex++) + if (ClientInfo->Devs[Index].ClientHandles[SubIndex].PinId == PinConnect->PinId) { - if (ClientInfo->Devs[Index].ClientHandles[SubIndex].PinId == PinConnect->PinId) - { - /* reuse opened pin */ - Length = IoStack->Parameters.DeviceIoControl.InputBufferLength - sizeof(KSPIN_CONNECT) + sizeof(SYSAUDIO_INSTANCE_INFO); - Status = SetPinFormat(Entry, PinConnect, Length); - DPRINT1("Reusing instance handle Status %x\n", Status); - ASSERT(ClientInfo->Devs[Index].ClientHandles[SubIndex].bHandle == FALSE); - *((PHANDLE)Irp->UserBuffer) = ClientInfo->Devs[Index].ClientHandles[SubIndex].hPin; - return SetIrpIoStatus(Irp, Status, sizeof(HANDLE)); - } + /* the pin has been already opened by the client, re-use it */ + ASSERT(ClientInfo->Devs[Index].ClientHandles[SubIndex].bHandle == FALSE); + + DispatchContext = ClientInfo->Devs[Index].ClientHandles[SubIndex].DispatchContext; + ObDereferenceObject(DispatchContext->MixerFileObject); + ObDereferenceObject(DispatchContext->FileObject); + ZwClose(DispatchContext->hMixerPin); + ZwClose(DispatchContext->Handle); + ClientInfo->Devs[Index].ClientHandles[SubIndex].PinId = (ULONG)-1; + goto Retry; } } - - } - } - + } + } + } + + ASSERT(DeviceId != (ULONG)-1); + + if (PinInstances.CurrentCount == PinInstances.PossibleCount) + { /* pin already exists */ ASSERT(Entry->Pins[PinConnect->PinId].PinHandle != NULL); - if (Entry->Pins[PinConnect->PinId].References > 1) + if (Entry->Pins[PinConnect->PinId].References) { /* FIXME need ksmixer */ DPRINT1("Device %u Pin %u References %u is already occupied, try later\n", InstanceInfo->DeviceNumber, PinConnect->PinId, Entry->Pins[PinConnect->PinId].References); @@ -816,28 +913,14 @@ RtlZeroMemory(WorkerContext, sizeof(PIN_WORKER_CONTEXT)); RtlZeroMemory(DispatchContext, sizeof(DISPATCH_CONTEXT)); - if (PinInstances.CurrentCount == PinInstances.PossibleCount) - { - /* re-using pin */ - Status = SetPinFormat(Entry, PinConnect, Length); - if (!NT_SUCCESS(Status)) - { - if (MixerFormat) - ExFreePool(MixerFormat); - IoFreeWorkItem(WorkItem); - ExFreePool(WorkerContext); - ExFreePool(DispatchContext); - return SetIrpIoStatus(Irp, Status, 0); - } - } - else - { - /* create the real pin */ + DPRINT1("PinInstances.CurrentCount %u\n", PinInstances.CurrentCount); + + if (PinInstances.CurrentCount < PinInstances.PossibleCount) + { WorkerContext->CreateRealPin = TRUE; } /* set up context */ - WorkerContext->DispatchContext = DispatchContext; WorkerContext->Entry = Entry; WorkerContext->Irp = Irp; Modified: trunk/reactos/drivers/wdm/audio/sysaudio/dispatcher.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/sysaudio…
============================================================================== --- trunk/reactos/drivers/wdm/audio/sysaudio/dispatcher.c [iso-8859-1] (original) +++ trunk/reactos/drivers/wdm/audio/sysaudio/dispatcher.c [iso-8859-1] Fri Mar 13 01:11:53 2009 @@ -24,7 +24,7 @@ { PIO_STACK_LOCATION IoStack; - DPRINT("Dispatch_fnDeviceIoControl called DeviceObject %p Irp %p\n", DeviceObject); + //DPRINT("Dispatch_fnDeviceIoControl called DeviceObject %p Irp %p\n", DeviceObject); IoStack = IoGetCurrentIrpStackLocation(Irp); if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KS_PROPERTY) @@ -95,6 +95,8 @@ PIO_STACK_LOCATION IoStatus; ULONG Index, SubIndex; PSYSAUDIODEVEXT DeviceExtension; + PDISPATCH_CONTEXT DispatchContext; + IoStatus = IoGetCurrentIrpStackLocation(Irp); @@ -105,6 +107,7 @@ DPRINT1("Client %p NumDevices %u\n", Client, Client->NumDevices); for(Index = 0; Index < Client->NumDevices; Index++) { + DPRINT1("Index %u Device %u Handels Count %u\n", Index, Client->Devs[Index].DeviceId, Client->Devs[Index].ClientHandlesCount); if (Client->Devs[Index].ClientHandlesCount) { Entry = GetListEntry(&DeviceExtension->KsAudioDeviceList, Client->Devs[Index].DeviceId); @@ -112,7 +115,9 @@ for(SubIndex = 0; SubIndex < Client->Devs[Index].ClientHandlesCount; SubIndex++) { - ASSERT(Entry->NumberOfPins > Client->Devs[Index].ClientHandles[SubIndex].PinId); + if (Client->Devs[Index].ClientHandles[SubIndex].PinId == (ULONG)-1) + continue; + if (Client->Devs[Index].ClientHandles[SubIndex].bHandle) { DPRINT1("Closing handle %p\n", Client->Devs[Index].ClientHandles[SubIndex].hPin); @@ -125,6 +130,21 @@ /* this is pin which can only be instantiated once * so we just need to release the reference count on that pin */ Entry->Pins[Client->Devs[Index].ClientHandles[SubIndex].PinId].References--; + + DispatchContext = (PDISPATCH_CONTEXT)Client->Devs[Index].ClientHandles[SubIndex].DispatchContext; + ObDereferenceObject(DispatchContext->MixerFileObject); + ObDereferenceObject(DispatchContext->FileObject); + ZwClose(DispatchContext->hMixerPin); + ExFreePool(DispatchContext); + + //DPRINT1("Index %u DeviceIndex %u Pin %u References %u\n", Index, Client->Devs[Index].DeviceId, SubIndex, Entry->Pins[Client->Devs[Index].ClientHandles[SubIndex].PinId].References); + if (!Entry->Pins[Client->Devs[Index].ClientHandles[SubIndex].PinId].References) + { + DPRINT1("Closing pin %p\n", Entry->Pins[Client->Devs[Index].ClientHandles[SubIndex].PinId].PinHandle); + + ZwClose(Entry->Pins[Client->Devs[Index].ClientHandles[SubIndex].PinId].PinHandle); + Entry->Pins[Client->Devs[Index].ClientHandles[SubIndex].PinId].PinHandle = NULL; + } } } ExFreePool(Client->Devs[Index].ClientHandles); Modified: trunk/reactos/drivers/wdm/audio/sysaudio/sysaudio.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/sysaudio…
============================================================================== --- trunk/reactos/drivers/wdm/audio/sysaudio/sysaudio.h [iso-8859-1] (original) +++ trunk/reactos/drivers/wdm/audio/sysaudio/sysaudio.h [iso-8859-1] Fri Mar 13 01:11:53 2009 @@ -7,6 +7,7 @@ ULONG PinId; HANDLE hPin; HANDLE hMixer; + PVOID DispatchContext; }SYSAUDIO_PIN_HANDLE, *PSYSAUDIO_PIN_HANDLE;
15 years, 9 months
1
0
0
0
[jmorlan] 39991: In a pipeline ("prog1 | prog2") run all programs simultaneously, using a real pipe instead of a temporary file. Output from RosBE "make" is now visible immediately instead of having to wait for it to complete.
by jmorlan@svn.reactos.org
Author: jmorlan Date: Fri Mar 13 01:04:59 2009 New Revision: 39991 URL:
http://svn.reactos.org/svn/reactos?rev=39991&view=rev
Log: In a pipeline ("prog1 | prog2") run all programs simultaneously, using a real pipe instead of a temporary file. Output from RosBE "make" is now visible immediately instead of having to wait for it to complete. Modified: trunk/reactos/base/shell/cmd/cmd.c trunk/reactos/base/shell/cmd/cmd.h trunk/reactos/base/shell/cmd/parser.c Modified: trunk/reactos/base/shell/cmd/cmd.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmd.c?rev=3…
============================================================================== --- trunk/reactos/base/shell/cmd/cmd.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/cmd.c [iso-8859-1] Fri Mar 13 01:04:59 2009 @@ -695,172 +695,130 @@ } } +/* Execute a command without waiting for it to finish. If it's an internal + * command or batch file, we must create a new cmd.exe process to handle it. + * TODO: For now, this just always creates a cmd.exe process. + * This works, but is inefficient for running external programs, + * which could just be run directly. */ +static HANDLE +ExecuteAsync(PARSED_COMMAND *Cmd) +{ + TCHAR CmdPath[MAX_PATH]; + TCHAR CmdParams[CMDLINE_LENGTH], *ParamsEnd; + STARTUPINFO stui; + PROCESS_INFORMATION prci; + + /* Get the path to cmd.exe */ + GetModuleFileName(NULL, CmdPath, MAX_PATH); + + /* Build the parameter string to pass to cmd.exe */ + ParamsEnd = _stpcpy(CmdParams, _T("/S/D/C\"")); + ParamsEnd = Unparse(Cmd, ParamsEnd, &CmdParams[CMDLINE_LENGTH - 2]); + if (!ParamsEnd) + { + error_out_of_memory(); + return NULL; + } + _tcscpy(ParamsEnd, _T("\"")); + + memset(&stui, 0, sizeof stui); + stui.cb = sizeof(STARTUPINFO); + if (!CreateProcess(CmdPath, CmdParams, NULL, NULL, TRUE, 0, + NULL, NULL, &stui, &prci)) + { + ErrorMessage(GetLastError(), NULL); + return NULL; + } + + CloseHandle(prci.hThread); + return prci.hProcess; +} + static VOID ExecutePipeline(PARSED_COMMAND *Cmd) { #ifdef FEATURE_REDIRECTION - TCHAR szTempPath[MAX_PATH] = _T(".\\"); - TCHAR szFileName[2][MAX_PATH] = {_T(""), _T("")}; - HANDLE hFile[2] = {INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE}; - INT Length; - UINT Attributes; - HANDLE hOldConIn; - HANDLE hOldConOut; -#endif /* FEATURE_REDIRECTION */ - - //TRACE ("ParseCommandLine: (\'%s\')\n", debugstr_aw(s)); - -#ifdef FEATURE_REDIRECTION - /* find the temp path to store temporary files */ - Length = GetTempPath (MAX_PATH, szTempPath); - if (Length > 0 && Length < MAX_PATH) - { - Attributes = GetFileAttributes(szTempPath); - if (Attributes == 0xffffffff || - !(Attributes & FILE_ATTRIBUTE_DIRECTORY)) - { - Length = 0; - } - } - if (Length == 0 || Length >= MAX_PATH) - { - _tcscpy(szTempPath, _T(".\\")); - } - if (szTempPath[_tcslen (szTempPath) - 1] != _T('\\')) - _tcscat (szTempPath, _T("\\")); - - /* Set up the initial conditions ... */ - /* preserve STDIN and STDOUT handles */ - hOldConIn = GetStdHandle (STD_INPUT_HANDLE); - hOldConOut = GetStdHandle (STD_OUTPUT_HANDLE); - - /* Now do all but the last pipe command */ - *szFileName[0] = _T('\0'); - hFile[0] = INVALID_HANDLE_VALUE; - - while (Cmd->Type == C_PIPE) - { - SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE}; - - /* Create unique temporary file name */ - GetTempFileName (szTempPath, _T("CMD"), 0, szFileName[1]); - - /* we need make sure the LastError msg is zero before calling CreateFile */ - SetLastError(0); - - /* Set current stdout to temporary file */ - hFile[1] = CreateFile (szFileName[1], GENERIC_WRITE, 0, &sa, - TRUNCATE_EXISTING, FILE_ATTRIBUTE_TEMPORARY, NULL); - - if (hFile[1] == INVALID_HANDLE_VALUE) - { - ConErrResPrintf(STRING_CMD_ERROR2); - return; - } - - SetStdHandle (STD_OUTPUT_HANDLE, hFile[1]); - - ExecuteCommand(Cmd->Subcommands); - - /* close stdout file */ - SetStdHandle (STD_OUTPUT_HANDLE, hOldConOut); - if ((hFile[1] != INVALID_HANDLE_VALUE) && (hFile[1] != hOldConOut)) - { - CloseHandle (hFile[1]); - hFile[1] = INVALID_HANDLE_VALUE; - } - - /* close old stdin file */ - SetStdHandle (STD_INPUT_HANDLE, hOldConIn); - if ((hFile[0] != INVALID_HANDLE_VALUE) && (hFile[0] != hOldConIn)) - { - /* delete old stdin file, if it is a real file */ - CloseHandle (hFile[0]); - hFile[0] = INVALID_HANDLE_VALUE; - DeleteFile (szFileName[0]); - *szFileName[0] = _T('\0'); - } - - /* copy stdout file name to stdin file name */ - _tcscpy (szFileName[0], szFileName[1]); - *szFileName[1] = _T('\0'); - - /* we need make sure the LastError msg is zero before calling CreateFile */ - SetLastError(0); - - /* open new stdin file */ - hFile[0] = CreateFile (szFileName[0], GENERIC_READ, 0, &sa, - OPEN_EXISTING, FILE_ATTRIBUTE_TEMPORARY, NULL); - SetStdHandle (STD_INPUT_HANDLE, hFile[0]); + HANDLE hInput = NULL; + HANDLE hOldConIn = GetStdHandle(STD_INPUT_HANDLE); + HANDLE hOldConOut = GetStdHandle(STD_OUTPUT_HANDLE); + HANDLE hProcess[MAXIMUM_WAIT_OBJECTS]; + INT nProcesses = 0; + DWORD dwExitCode; + + /* Do all but the last pipe command */ + do + { + HANDLE hPipeRead, hPipeWrite; + if (nProcesses > (MAXIMUM_WAIT_OBJECTS - 2)) + { + error_too_many_parameters(_T("|")); + goto failed; + } + + /* Create the pipe that this process will write into. + * Make the handles non-inheritable initially, because this + * process shouldn't inherit the reading handle. */ + if (!CreatePipe(&hPipeRead, &hPipeWrite, NULL, 0)) + { + error_no_pipe(); + goto failed; + } + + /* The writing side of the pipe is STDOUT for this process */ + SetHandleInformation(hPipeWrite, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT); + SetStdHandle(STD_OUTPUT_HANDLE, hPipeWrite); + + /* Execute it (error check is done later for easier cleanup) */ + hProcess[nProcesses] = ExecuteAsync(Cmd->Subcommands); + CloseHandle(hPipeWrite); + if (hInput) + CloseHandle(hInput); + + /* The reading side of the pipe will be STDIN for the next process */ + SetHandleInformation(hPipeRead, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT); + SetStdHandle(STD_INPUT_HANDLE, hPipeRead); + hInput = hPipeRead; + + if (!hProcess[nProcesses]) + goto failed; + nProcesses++; Cmd = Cmd->Subcommands->Next; - } - - /* Now set up the end conditions... */ + } while (Cmd->Type == C_PIPE); + + /* The last process uses the original STDOUT */ SetStdHandle(STD_OUTPUT_HANDLE, hOldConOut); - -#endif - - /* process final command */ - ExecuteCommand(Cmd); - -#ifdef FEATURE_REDIRECTION - /* close old stdin file */ -#if 0 /* buggy implementation */ - SetStdHandle (STD_INPUT_HANDLE, hOldConIn); - if ((hFile[0] != INVALID_HANDLE_VALUE) && - (hFile[0] != hOldConIn)) - { - /* delete old stdin file, if it is a real file */ - CloseHandle (hFile[0]); - hFile[0] = INVALID_HANDLE_VALUE; - DeleteFile (szFileName[0]); - *szFileName[0] = _T('\0'); - } - - /* Restore original STDIN */ - if (hOldConIn != INVALID_HANDLE_VALUE) - { - HANDLE hIn = GetStdHandle (STD_INPUT_HANDLE); - SetStdHandle (STD_INPUT_HANDLE, hOldConIn); - if (hOldConIn != hIn) - CloseHandle (hIn); - hOldConIn = INVALID_HANDLE_VALUE; - } - else - { - WARN ("Can't restore STDIN! Is invalid!!\n", out); - } -#endif /* buggy implementation */ - - - if (hOldConIn != INVALID_HANDLE_VALUE) - { - HANDLE hIn = GetStdHandle (STD_INPUT_HANDLE); - SetStdHandle (STD_INPUT_HANDLE, hOldConIn); - if (hIn == INVALID_HANDLE_VALUE) - { - WARN ("Previous STDIN is invalid!!\n"); - } - else - { - if (GetFileType (hIn) == FILE_TYPE_DISK) - { - if (hFile[0] == hIn) - { - CloseHandle (hFile[0]); - hFile[0] = INVALID_HANDLE_VALUE; - DeleteFile (szFileName[0]); - *szFileName[0] = _T('\0'); - } - else - { - WARN ("hFile[0] and hIn dont match!!!\n"); - } - } - } - } -#endif /* FEATURE_REDIRECTION */ + hProcess[nProcesses] = ExecuteAsync(Cmd); + if (!hProcess[nProcesses]) + goto failed; + nProcesses++; + CloseHandle(hInput); + SetStdHandle(STD_INPUT_HANDLE, hOldConIn); + + /* Wait for all processes to complete */ + bChildProcessRunning = TRUE; + WaitForMultipleObjects(nProcesses, hProcess, TRUE, INFINITE); + bChildProcessRunning = FALSE; + + /* Use the exit code of the last process in the pipeline */ + GetExitCodeProcess(hProcess[nProcesses - 1], &dwExitCode); + nErrorLevel = (INT)dwExitCode; + + while (--nProcesses >= 0) + CloseHandle(hProcess[nProcesses]); + return; + +failed: + if (hInput) + CloseHandle(hInput); + while (--nProcesses >= 0) + { + TerminateProcess(hProcess[nProcesses], 0); + CloseHandle(hProcess[nProcesses]); + } + SetStdHandle(STD_INPUT_HANDLE, hOldConIn); + SetStdHandle(STD_OUTPUT_HANDLE, hOldConOut); +#endif } BOOL Modified: trunk/reactos/base/shell/cmd/cmd.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmd.h?rev=3…
============================================================================== --- trunk/reactos/base/shell/cmd/cmd.h [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/cmd.h [iso-8859-1] Fri Mar 13 01:04:59 2009 @@ -384,6 +384,7 @@ } PARSED_COMMAND; PARSED_COMMAND *ParseCommand(LPTSTR Line); VOID EchoCommand(PARSED_COMMAND *Cmd); +TCHAR *Unparse(PARSED_COMMAND *Cmd, TCHAR *Out, TCHAR *OutEnd); VOID FreeCommand(PARSED_COMMAND *Cmd); Modified: trunk/reactos/base/shell/cmd/parser.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/parser.c?re…
============================================================================== --- trunk/reactos/base/shell/cmd/parser.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/parser.c [iso-8859-1] Fri Mar 13 01:04:59 2009 @@ -807,6 +807,106 @@ } } +/* "Unparse" a command into a text form suitable for passing to CMD /C. + * Used for pipes. This is basically the same thing as EchoCommand, but + * writing into a string instead of to standard output. */ +TCHAR * +Unparse(PARSED_COMMAND *Cmd, TCHAR *Out, TCHAR *OutEnd) +{ + TCHAR Buf[CMDLINE_LENGTH]; + PARSED_COMMAND *Sub; + REDIRECTION *Redir; + +/* Since this function has the annoying requirement that it must avoid + * overflowing the supplied buffer, define some helper macros to make + * this less painful */ +#define CHAR(Char) { \ + if (Out == OutEnd) return NULL; \ + *Out++ = Char; } +#define STRING(String) { \ + if (Out + _tcslen(String) > OutEnd) return NULL; \ + Out = _stpcpy(Out, String); } +#define PRINTF(Format, ...) { \ + UINT Len = _sntprintf(Out, OutEnd - Out, Format, __VA_ARGS__); \ + if (Len > (UINT)(OutEnd - Out)) return NULL; \ + Out += Len; } +#define RECURSE(Subcommand) { \ + Out = Unparse(Subcommand, Out, OutEnd); \ + if (!Out) return NULL; } + + switch (Cmd->Type) + { + case C_COMMAND: + if (!SubstituteForVars(Cmd->Command.CommandLine, Buf)) return NULL; + /* This is fragile since there could be special characters, but + * Windows doesn't bother escaping them, so for compatibility + * we probably shouldn't do it either */ + STRING(Buf) + break; + case C_QUIET: + CHAR(_T('@')) + RECURSE(Cmd->Subcommands) + break; + case C_BLOCK: + CHAR(_T('(')) + for (Sub = Cmd->Subcommands; Sub; Sub = Sub->Next) + { + RECURSE(Sub) + if (Sub->Next) + CHAR(_T('&')) + } + CHAR(_T(')')) + break; + case C_MULTI: + case C_IFFAILURE: + case C_IFSUCCESS: + case C_PIPE: + Sub = Cmd->Subcommands; + RECURSE(Sub) + PRINTF(_T(" %s "), OpString[Cmd->Type - C_OP_LOWEST]) + RECURSE(Sub->Next) + break; + case C_IF: + STRING(_T("if")) + if (Cmd->If.Flags & IFFLAG_IGNORECASE) + STRING(_T(" /I")) + if (Cmd->If.Flags & IFFLAG_NEGATE) + STRING(_T(" not")) + if (Cmd->If.LeftArg && SubstituteForVars(Cmd->If.LeftArg, Buf)) + PRINTF(_T(" %s"), Buf) + PRINTF(_T(" %s"), IfOperatorString[Cmd->If.Operator]); + if (!SubstituteForVars(Cmd->If.RightArg, Buf)) return NULL; + PRINTF(_T(" %s "), Buf) + Sub = Cmd->Subcommands; + RECURSE(Sub) + if (Sub->Next) + { + STRING(_T(" else ")) + RECURSE(Sub->Next) + } + break; + case C_FOR: + STRING(_T("for")) + if (Cmd->For.Switches & FOR_DIRS) STRING(_T(" /D")) + if (Cmd->For.Switches & FOR_F) STRING(_T(" /F")) + if (Cmd->For.Switches & FOR_LOOP) STRING(_T(" /L")) + if (Cmd->For.Switches & FOR_RECURSIVE) STRING(_T(" /R")) + if (Cmd->For.Params) + PRINTF(_T(" %s"), Cmd->For.Params) + PRINTF(_T(" %%%c in (%s) do "), Cmd->For.Variable, Cmd->For.List) + RECURSE(Cmd->Subcommands) + break; + } + + for (Redir = Cmd->Redirections; Redir; Redir = Redir->Next) + { + if (!SubstituteForVars(Redir->Filename, Buf)) return NULL; + PRINTF(_T(" %c%s%s"), _T('0') + Redir->Number, + RedirString[Redir->Type], Buf) + } + return Out; +} + VOID FreeCommand(PARSED_COMMAND *Cmd) {
15 years, 9 months
1
0
0
0
[cgutman] 39990: - Add an extra parameter check
by cgutman@svn.reactos.org
Author: cgutman Date: Fri Mar 13 00:33:21 2009 New Revision: 39990 URL:
http://svn.reactos.org/svn/reactos?rev=39990&view=rev
Log: - Add an extra parameter check Modified: branches/aicom-network-fixes/drivers/network/afd/afd/info.c Modified: branches/aicom-network-fixes/drivers/network/afd/afd/info.c URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/drivers/net…
============================================================================== --- branches/aicom-network-fixes/drivers/network/afd/afd/info.c [iso-8859-1] (original) +++ branches/aicom-network-fixes/drivers/network/afd/afd/info.c [iso-8859-1] Fri Mar 13 00:33:21 2009 @@ -123,7 +123,7 @@ if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp ); - if (FCB->RemoteAddress == NULL) { + if (FCB->RemoteAddress == NULL || FCB->Connection.Object == NULL) { return UnlockAndMaybeComplete( FCB, STATUS_INVALID_PARAMETER, Irp, 0, NULL ); }
15 years, 9 months
1
0
0
0
[mkupfer] 39989: Evgeniy Boltik <bstsoft AT narod DOT ru> - Fix draw icon with alpha in 32 bit. - See issue #4243 for details.
by mkupfer@svn.reactos.org
Author: mkupfer Date: Fri Mar 13 00:25:49 2009 New Revision: 39989 URL:
http://svn.reactos.org/svn/reactos?rev=39989&view=rev
Log: Evgeniy Boltik <bstsoft AT narod DOT ru> - Fix draw icon with alpha in 32 bit. - See issue #4243 for details. Modified: trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c Modified: trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c [iso-8859-1] Fri Mar 13 00:25:49 2009 @@ -1389,82 +1389,6 @@ } -#define STRETCH_CAN_SRCCOPY_ONLY - -#ifdef STRETCH_CAN_SRCCOPY_ONLY -void -FASTCALL -DoStretchBlt(HDC DcDest, int XDest, int YDest, int WidthDest, int HeightDest, - HDC DcSrc, int XSrc, int YSrc, int WidthSrc, int HeightSrc, - DWORD Rop3, BOOL Color) -{ - HDC DcStretched; - HBITMAP BitmapStretched; - HBITMAP OldBitmap; - - if (WidthDest == WidthSrc && HeightDest == HeightSrc) - { - NtGdiBitBlt(DcDest, XDest, YDest, WidthDest, HeightDest, - DcSrc, XSrc, YSrc, Rop3, 0, 0); - } - else if (SRCCOPY == Rop3) - { - NtGdiStretchBlt(DcDest, XDest, YDest, WidthDest, HeightDest, - DcSrc, XSrc, YSrc, WidthSrc, HeightSrc, - Rop3, 0); - } - else - { - DcStretched = NtGdiCreateCompatibleDC(DcSrc); - if (NULL == DcStretched) - { - DPRINT1("Failed to create compatible DC\n"); - return; - } - if (Color) - { - BitmapStretched = NtGdiCreateCompatibleBitmap(DcDest, WidthDest, - HeightDest); - } - else - { - BitmapStretched = IntGdiCreateBitmap(WidthDest, HeightDest, 1, 1, NULL); - } - if (NULL == BitmapStretched) - { - NtGdiDeleteObjectApp(DcStretched); - DPRINT1("Failed to create temporary bitmap\n"); - return; - } - OldBitmap = NtGdiSelectBitmap(DcStretched, BitmapStretched); - if (NULL == OldBitmap) - { - NtGdiDeleteObject(BitmapStretched); - NtGdiDeleteObjectApp(DcStretched); - DPRINT1("Failed to create temporary bitmap\n"); - return; - } - if (! NtGdiStretchBlt(DcStretched, 0, 0, WidthDest, HeightDest, - DcSrc, XSrc, YSrc, WidthSrc, HeightSrc, - SRCCOPY, 0) || - ! NtGdiBitBlt(DcDest, XDest, YDest, WidthDest, HeightDest, - DcStretched, 0, 0, Rop3, 0, 0)) - { - DPRINT1("Failed to blt\n"); - } - NtGdiSelectBitmap(DcStretched, OldBitmap); - NtGdiDeleteObject(BitmapStretched); - NtGdiDeleteObjectApp(DcStretched); - } -} -#else -#define DoStretchBlt(DcDest, XDest, YDest, WidthDest, HeightDest, \ - DcSrc, XSrc, YSrc, WidthSrc, HeightSrc, Rop3, Color) \ - NtGdiStretchBlt((DcDest), (XDest), (YDest), (WidthDest), (HeightDest), \ - (DcSrc), (XSrc), (YSrc), (WidthSrc), (HeightSrc), \ - (Rop3), 0) -#endif /* STRETCH_CAN_SRCCOPY_ONLY */ - BOOL UserDrawIconEx( HDC hDc, @@ -1482,7 +1406,6 @@ BITMAP bmpMask, bmpColor; COLORREF oldFg, oldBg; BOOL DoFlickerFree; - INT nStretchMode; SIZE IconSize; HDC hdcOff; @@ -1524,7 +1447,31 @@ when cxWidth or cyHeight is 0 */ if ((bmpColor.bmBitsPixel == 32) && (cxWidth != 0) && (cyHeight != 0)) { - bAlpha = TRUE; + SURFACE *psurfOff = NULL; + PFN_DIB_GetPixel fnSource_GetPixel = NULL; + INT x, y; + + //Find alpha into icon + psurfOff = SURFACE_LockSurface(hbmColor ? hbmColor : hbmMask); + if (psurfOff) + { + fnSource_GetPixel = DibFunctionsForBitmapFormat[psurfOff->SurfObj.iBitmapFormat].DIB_GetPixel; + if (fnSource_GetPixel) + { + for (x = 0; x < psurfOff->SurfObj.sizlBitmap.cx; x++) + { + for (y = 0; y < psurfOff->SurfObj.sizlBitmap.cy; y++) + { + bAlpha = ((BYTE)(fnSource_GetPixel(&psurfOff->SurfObj, x, y) >> 24) & 0xff); + if (bAlpha) + break; + } + if (bAlpha) + break; + } + } + SURFACE_UnlockSurface(psurfOff); + } } if (!diFlags) @@ -1608,8 +1555,6 @@ goto cleanup; } - nStretchMode = IntGdiSetStretchBltMode(hdcOff, STRETCH_DELETESCANS); - oldFg = IntGdiSetTextColor(hdcOff, RGB(0, 0, 0)); oldBg = IntGdiSetBkColor(hdcOff, RGB(255, 255, 255)); @@ -1622,7 +1567,7 @@ goto cleanup; } - DoStretchBlt(hdcOff, + NtGdiStretchBlt(hdcOff, (DoFlickerFree || bAlpha ? 0 : xLeft), (DoFlickerFree || bAlpha ? 0 : yTop), cxWidth, @@ -1633,7 +1578,7 @@ IconSize.cx, IconSize.cy, ((diFlags & DI_IMAGE) ? SRCAND : SRCCOPY), - FALSE); + 0); NtGdiSelectBitmap(hdcMem, hOldMem); } @@ -1642,7 +1587,7 @@ { hOldMem = NtGdiSelectBitmap(hdcMem, (hbmColor ? hbmColor : hbmMask)); - DoStretchBlt(hdcOff, + NtGdiStretchBlt(hdcOff, (DoFlickerFree || bAlpha ? 0 : xLeft), (DoFlickerFree || bAlpha ? 0 : yTop), cxWidth, @@ -1653,7 +1598,7 @@ IconSize.cx, IconSize.cy, ((diFlags & DI_MASK) ? SRCINVERT : SRCCOPY), - NULL != hbmColor); + 0); NtGdiSelectBitmap(hdcMem, hOldMem); } @@ -1729,7 +1674,6 @@ IntGdiSetTextColor(hdcOff, oldFg); IntGdiSetBkColor(hdcOff, oldBg); - IntGdiSetStretchBltMode(hdcOff, nStretchMode); Ret = TRUE;
15 years, 9 months
1
0
0
0
[cgutman] 39988: - Separate AfdGetSockOrPeerName into AfdGetSockName and AfdGetPeerName - Rewrite AfdGetPeerName - I will change SEH to SEH2 before merging
by cgutman@svn.reactos.org
Author: cgutman Date: Fri Mar 13 00:14:03 2009 New Revision: 39988 URL:
http://svn.reactos.org/svn/reactos?rev=39988&view=rev
Log: - Separate AfdGetSockOrPeerName into AfdGetSockName and AfdGetPeerName - Rewrite AfdGetPeerName - I will change SEH to SEH2 before merging Modified: branches/aicom-network-fixes/drivers/network/afd/afd/info.c branches/aicom-network-fixes/drivers/network/afd/afd/main.c branches/aicom-network-fixes/drivers/network/afd/include/afd.h Modified: branches/aicom-network-fixes/drivers/network/afd/afd/info.c URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/drivers/net…
============================================================================== --- branches/aicom-network-fixes/drivers/network/afd/afd/info.c [iso-8859-1] (original) +++ branches/aicom-network-fixes/drivers/network/afd/afd/info.c [iso-8859-1] Fri Mar 13 00:14:03 2009 @@ -13,7 +13,7 @@ #include "debug.h" #include "pseh/pseh.h" -NTSTATUS STDCALL +NTSTATUS NTAPI AfdGetInfo( PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp ) { NTSTATUS Status = STATUS_SUCCESS; @@ -69,19 +69,20 @@ return UnlockAndMaybeComplete( FCB, Status, Irp, 0, NULL ); } -NTSTATUS STDCALL -AfdGetSockOrPeerName( PDEVICE_OBJECT DeviceObject, PIRP Irp, - PIO_STACK_LOCATION IrpSp, BOOLEAN Local ) { +NTSTATUS NTAPI +AfdGetSockName( PDEVICE_OBJECT DeviceObject, PIRP Irp, + PIO_STACK_LOCATION IrpSp ) { NTSTATUS Status = STATUS_SUCCESS; PFILE_OBJECT FileObject = IrpSp->FileObject; PAFD_FCB FCB = FileObject->FsContext; - PMDL Mdl = NULL, SysMdl = NULL; - PTDI_CONNECTION_INFORMATION ConnInfo = NULL; - PTRANSPORT_ADDRESS TransAddr = NULL; - - AFD_DbgPrint(MID_TRACE,("Called on %x\n", FCB)); + PMDL Mdl = NULL; if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp ); + + if( FCB->AddressFile.Object == NULL && FCB->Connection.Object == NULL ) { + return UnlockAndMaybeComplete( FCB, STATUS_INVALID_PARAMETER, Irp, 0, + NULL ); + } Mdl = IoAllocateMdl ( Irp->UserBuffer, @@ -99,75 +100,69 @@ } _SEH_END; if( NT_SUCCESS(Status) ) { - if( Local ) { - if( FCB->AddressFile.Object == NULL ) { - return UnlockAndMaybeComplete( FCB, STATUS_INVALID_PARAMETER, Irp, 0, - NULL ); - } - Status = TdiQueryInformation - ( FCB->AddressFile.Object, + ( FCB->Connection.Object ? FCB->Connection.Object : FCB->AddressFile.Object, TDI_QUERY_ADDRESS_INFO, Mdl ); - } else { - if( FCB->Connection.Object == NULL || (FCB->State != SOCKET_STATE_BOUND && FCB->State != SOCKET_STATE_CONNECTED) ) { - return UnlockAndMaybeComplete( FCB, STATUS_INVALID_PARAMETER, Irp, 0, - NULL ); - } - - if( NT_SUCCESS - ( Status = TdiBuildNullConnectionInfo - ( &ConnInfo, - FCB->LocalAddress->Address[0].AddressType ) ) ) { - SysMdl = IoAllocateMdl - ( ConnInfo, - sizeof( TDI_CONNECTION_INFORMATION ) + - TaLengthOfTransportAddress - ( ConnInfo->RemoteAddress ), - FALSE, - FALSE, - NULL ); - } - - if( SysMdl ) { - _SEH_TRY { - MmProbeAndLockPages( SysMdl, Irp->RequestorMode, IoModifyAccess ); - } _SEH_HANDLE { - AFD_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n")); - Status = _SEH_GetExceptionCode(); - } _SEH_END; - } else Status = STATUS_NO_MEMORY; - - if( NT_SUCCESS(Status) ) { - Status = TdiQueryInformation - ( FCB->Connection.Object, - TDI_QUERY_CONNECTION_INFO, - SysMdl ); - } - - if( NT_SUCCESS(Status) ) { - TransAddr = - (PTRANSPORT_ADDRESS)MmGetSystemAddressForMdlSafe( Mdl, NormalPagePriority ); - - if( TransAddr ) - RtlCopyMemory( TransAddr, ConnInfo->RemoteAddress, - TaLengthOfTransportAddress - ( ConnInfo->RemoteAddress ) ); - else Status = STATUS_INSUFFICIENT_RESOURCES; - } - - if( ConnInfo ) ExFreePool( ConnInfo ); - if( SysMdl ) IoFreeMdl( SysMdl ); - if( TransAddr ) MmUnmapLockedPages( TransAddr, Mdl ); - MmUnlockPages( Mdl ); - IoFreeMdl( Mdl ); - } - } - } else { - Status = STATUS_INSUFFICIENT_RESOURCES; - } - - AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status)); + } + } else + Status = STATUS_INSUFFICIENT_RESOURCES; return UnlockAndMaybeComplete( FCB, Status, Irp, 0, NULL ); } + +NTSTATUS NTAPI +AfdGetPeerName( PDEVICE_OBJECT DeviceObject, PIRP Irp, + PIO_STACK_LOCATION IrpSp ) { + NTSTATUS Status = STATUS_SUCCESS; + PFILE_OBJECT FileObject = IrpSp->FileObject; + PAFD_FCB FCB = FileObject->FsContext; + PMDL Mdl = NULL; + PTDI_CONNECTION_INFORMATION ConnInfo = NULL; + + + if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp ); + + if (FCB->RemoteAddress == NULL) { + return UnlockAndMaybeComplete( FCB, STATUS_INVALID_PARAMETER, Irp, 0, NULL ); + } + + if(NT_SUCCESS(Status = TdiBuildNullConnectionInfo + (&ConnInfo, + FCB->RemoteAddress->Address[0].AddressType))) + { + Mdl = IoAllocateMdl(ConnInfo, + sizeof(TDI_CONNECTION_INFORMATION) + + TaLengthOfTransportAddress(ConnInfo->RemoteAddress), + FALSE, + FALSE, + NULL); + + if (Mdl) + { + _SEH_TRY { + MmProbeAndLockPages(Mdl, Irp->RequestorMode, IoModifyAccess); + } _SEH_HANDLE { + AFD_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n")); + Status = _SEH_GetExceptionCode(); + } _SEH_END; + + if (NT_SUCCESS(Status)) + { + Status = TdiQueryInformation(FCB->Connection.Object, + TDI_QUERY_CONNECTION_INFO, + Mdl); + + if (NT_SUCCESS(Status)) + { + RtlCopyMemory(Irp->UserBuffer, ConnInfo->RemoteAddress, TaLengthOfTransportAddress + (ConnInfo->RemoteAddress)); + } + } + } + + ExFreePool(ConnInfo); + } + + return UnlockAndMaybeComplete( FCB, Status, Irp, 0, NULL ); +} Modified: branches/aicom-network-fixes/drivers/network/afd/afd/main.c URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/drivers/net…
============================================================================== --- branches/aicom-network-fixes/drivers/network/afd/afd/main.c [iso-8859-1] (original) +++ branches/aicom-network-fixes/drivers/network/afd/afd/main.c [iso-8859-1] Fri Mar 13 00:14:03 2009 @@ -402,10 +402,10 @@ return AfdDisconnect( DeviceObject, Irp, IrpSp ); case IOCTL_AFD_GET_SOCK_NAME: - return AfdGetSockOrPeerName( DeviceObject, Irp, IrpSp, TRUE ); + return AfdGetSockName( DeviceObject, Irp, IrpSp ); case IOCTL_AFD_GET_PEER_NAME: - return AfdGetSockOrPeerName( DeviceObject, Irp, IrpSp, FALSE ); + return AfdGetPeerName( DeviceObject, Irp, IrpSp ); case IOCTL_AFD_GET_TDI_HANDLES: AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_GET_TDI_HANDLES\n")); Modified: branches/aicom-network-fixes/drivers/network/afd/include/afd.h URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/drivers/net…
============================================================================== --- branches/aicom-network-fixes/drivers/network/afd/include/afd.h [iso-8859-1] (original) +++ branches/aicom-network-fixes/drivers/network/afd/include/afd.h [iso-8859-1] Fri Mar 13 00:14:03 2009 @@ -232,8 +232,12 @@ PIO_STACK_LOCATION IrpSp ); NTSTATUS STDCALL -AfdGetSockOrPeerName( PDEVICE_OBJECT DeviceObject, PIRP Irp, - PIO_STACK_LOCATION IrpSp, BOOLEAN Local ); +AfdGetSockName( PDEVICE_OBJECT DeviceObject, PIRP Irp, + PIO_STACK_LOCATION IrpSp ); + +NTSTATUS STDCALL +AfdGetPeerName( PDEVICE_OBJECT DeviceObject, PIRP Irp, + PIO_STACK_LOCATION IrpSp ); /* listen.c */ NTSTATUS AfdWaitForListen( PDEVICE_OBJECT DeviceObject, PIRP Irp,
15 years, 9 months
1
0
0
0
[tkreuzer] 39987: LoadBitmapImage: - add space for 3 RGBQUADs to BITMAPINFO when biCompression is BI_BITFIELDS. Based on patch by Evgeniy Boltik <bstsoft at narod dot ru>, modified by me. - Take into account BITMAPV4/V5HEADER sizes. See issue #3708 for more details.
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Thu Mar 12 23:55:34 2009 New Revision: 39987 URL:
http://svn.reactos.org/svn/reactos?rev=39987&view=rev
Log: LoadBitmapImage: - add space for 3 RGBQUADs to BITMAPINFO when biCompression is BI_BITFIELDS. Based on patch by Evgeniy Boltik <bstsoft at narod dot ru>, modified by me. - Take into account BITMAPV4/V5HEADER sizes. See issue #3708 for more details. Modified: trunk/reactos/dll/win32/user32/windows/bitmap.c Modified: trunk/reactos/dll/win32/user32/windows/bitmap.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/b…
============================================================================== --- trunk/reactos/dll/win32/user32/windows/bitmap.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/bitmap.c [iso-8859-1] Thu Mar 12 23:55:34 2009 @@ -449,18 +449,26 @@ BitmapInfo = (LPBITMAPINFO)((ULONG_PTR)BitmapInfo + sizeof(BITMAPFILEHEADER)); } - if (BitmapInfo->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) + HeaderSize = BitmapInfo->bmiHeader.biSize; + if (HeaderSize == sizeof(BITMAPCOREHEADER)) { BITMAPCOREHEADER* Core = (BITMAPCOREHEADER*)BitmapInfo; ColorCount = (Core->bcBitCount <= 8) ? (1 << Core->bcBitCount) : 0; - HeaderSize = sizeof(BITMAPCOREHEADER) + ColorCount * sizeof(RGBTRIPLE); + HeaderSize += ColorCount * sizeof(RGBTRIPLE); } else { - ColorCount = BitmapInfo->bmiHeader.biClrUsed; - if (ColorCount == 0 && BitmapInfo->bmiHeader.biBitCount <= 8) - ColorCount = 1 << BitmapInfo->bmiHeader.biBitCount; - HeaderSize = sizeof(BITMAPINFOHEADER) + ColorCount * sizeof(RGBQUAD); + if (BitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) + { + HeaderSize += 3 * sizeof(RGBQUAD); + } + else + { + ColorCount = BitmapInfo->bmiHeader.biClrUsed; + if (ColorCount == 0 && BitmapInfo->bmiHeader.biBitCount <= 8) + ColorCount = 1 << BitmapInfo->bmiHeader.biBitCount; + HeaderSize += ColorCount * sizeof(RGBQUAD); + } } Data = (PVOID)((ULONG_PTR)BitmapInfo + HeaderSize);
15 years, 9 months
1
0
0
0
[jmorlan] 39986: NtSetInformationObject: OBJECT_HANDLE_ATTRIBUTE_INFORMATION is just made of BOOLEANs, so it doesn't need ULONG alignment.
by jmorlan@svn.reactos.org
Author: jmorlan Date: Thu Mar 12 23:29:32 2009 New Revision: 39986 URL:
http://svn.reactos.org/svn/reactos?rev=39986&view=rev
Log: NtSetInformationObject: OBJECT_HANDLE_ATTRIBUTE_INFORMATION is just made of BOOLEANs, so it doesn't need ULONG alignment. Modified: trunk/reactos/ntoskrnl/ob/oblife.c Modified: trunk/reactos/ntoskrnl/ob/oblife.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/oblife.c?rev=3…
============================================================================== --- trunk/reactos/ntoskrnl/ob/oblife.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ob/oblife.c [iso-8859-1] Thu Mar 12 23:29:32 2009 @@ -1665,7 +1665,7 @@ { ProbeForRead(ObjectInformation, sizeof(OBJECT_HANDLE_ATTRIBUTE_INFORMATION), - sizeof(ULONG)); + sizeof(BOOLEAN)); Context.Information = *(POBJECT_HANDLE_ATTRIBUTE_INFORMATION) ObjectInformation; }
15 years, 9 months
1
0
0
0
[tkreuzer] 39985: NtSetSystemInformation: - Don't leak the copied string when being called from user mode. - Don't recursively call ZwSetSystemInformation, instead continue the normal path.
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Thu Mar 12 21:29:11 2009 New Revision: 39985 URL:
http://svn.reactos.org/svn/reactos?rev=39985&view=rev
Log: NtSetSystemInformation: - Don't leak the copied string when being called from user mode. - Don't recursively call ZwSetSystemInformation, instead continue the normal path. Modified: trunk/reactos/ntoskrnl/ex/sysinfo.c Modified: trunk/reactos/ntoskrnl/ex/sysinfo.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/sysinfo.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/ex/sysinfo.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ex/sysinfo.c [iso-8859-1] Thu Mar 12 21:29:11 2009 @@ -1587,18 +1587,10 @@ /* FIXME: We can't, fail */ //return STATUS_PRIVILEGE_NOT_HELD; } - - /* Probe and capture the driver name */ - ProbeAndCaptureUnicodeString(&ImageName, UserMode, Buffer); - - /* Force kernel as previous mode */ - return ZwSetSystemInformation(SystemExtendServiceTableInformation, - &ImageName, - sizeof(ImageName)); - } - - /* Just copy the string */ - ImageName = *(PUNICODE_STRING)Buffer; + } + + /* Probe and capture the driver name */ + ProbeAndCaptureUnicodeString(&ImageName, PreviousMode, Buffer); /* Load the image */ Status = MmLoadSystemImage(&ImageName, @@ -1607,6 +1599,10 @@ 0, (PVOID)&ModuleObject, &ImageBase); + + /* Release String */ + ReleaseCapturedUnicodeString(&ImageName, PreviousMode); + if (!NT_SUCCESS(Status)) return Status; /* Get the headers */
15 years, 9 months
1
0
0
0
← Newer
1
...
29
30
31
32
33
34
35
...
49
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Results per page:
10
25
50
100
200