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
October 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
26 participants
641 discussions
Start a n
N
ew thread
[lsuggs] 43700: First push of nslookup implementation.
by lsuggs@svn.reactos.org
Author: lsuggs Date: Fri Oct 23 19:25:05 2009 New Revision: 43700 URL:
http://svn.reactos.org/svn/reactos?rev=43700&view=rev
Log: First push of nslookup implementation. Added: trunk/reactos/base/applications/network/nslookup/ (with props) trunk/reactos/base/applications/network/nslookup/nslookup.c (with props) trunk/reactos/base/applications/network/nslookup/nslookup.h (with props) trunk/reactos/base/applications/network/nslookup/nslookup.rbuild (with props) trunk/reactos/base/applications/network/nslookup/nslookup.rc (with props) trunk/reactos/base/applications/network/nslookup/utility.c (with props) Modified: trunk/reactos/base/applications/network/network.rbuild trunk/reactos/boot/bootdata/packages/reactos.dff Modified: trunk/reactos/base/applications/network/network.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/network.rbuild [iso-8859-1] (original) +++ trunk/reactos/base/applications/network/network.rbuild [iso-8859-1] Fri Oct 23 19:25:05 2009 @@ -22,6 +22,9 @@ <directory name="netstat"> <xi:include href="netstat/netstat.rbuild" /> </directory> + <directory name="nslookup"> + <xi:include href="nslookup/nslookup.rbuild" /> + </directory> <directory name="ping"> <xi:include href="ping/ping.rbuild" /> </directory> Propchange: trunk/reactos/base/applications/network/nslookup/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Fri Oct 23 19:25:05 2009 @@ -1,0 +1,2 @@ +([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))? +(\d+) Propchange: trunk/reactos/base/applications/network/nslookup/ ------------------------------------------------------------------------------ bugtraq:message = See issue #%BUGID% for more details. Propchange: trunk/reactos/base/applications/network/nslookup/ ------------------------------------------------------------------------------ bugtraq:url =
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: trunk/reactos/base/applications/network/nslookup/ ------------------------------------------------------------------------------ tsvn:logminsize = 10 Added: trunk/reactos/base/applications/network/nslookup/nslookup.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/nslookup/nslookup.c (added) +++ trunk/reactos/base/applications/network/nslookup/nslookup.c [iso-8859-1] Fri Oct 23 19:25:05 2009 @@ -1,0 +1,858 @@ +/* + * PROJECT: ReactOS nslookup utility + * LICENSE: GPL - See COPYING in the top level directory + * FILE: applications/network/nslookup/nslookup.c + * PURPOSE: Perform DNS lookups + * COPYRIGHT: Copyright 2009 Lucas Suggs <lucas.suggs(a)gmail.com> + */ + +#include <windows.h> +#include <windns.h> +#include <winsock2.h> +#include <tchar.h> +#include <stdio.h> +#include <stdlib.h> +#include <iphlpapi.h> +#include "nslookup.h" + +STATE State; +HANDLE ProcessHeap; +ULONG RequestID; + +void PrintState() +{ + _tprintf( _T("Default Server: (null)\n\n") ); + _tprintf( _T("Set options:\n") ); + + _tprintf( _T(" ") ); + if( !State.debug ) _tprintf( _T("no") ); + _tprintf( _T("debug\n") ); + + _tprintf( _T(" ") ); + if( !State.defname ) _tprintf( _T("no") ); + _tprintf( _T("defname\n") ); + + _tprintf( _T(" ") ); + if( !State.search ) _tprintf( _T("no") ); + _tprintf( _T("search\n") ); + + _tprintf( _T(" ") ); + if( !State.recurse ) _tprintf( _T("no") ); + _tprintf( _T("recurse\n") ); + + _tprintf( _T(" ") ); + if( !State.d2 ) _tprintf( _T("no") ); + _tprintf( _T("d2\n") ); + + _tprintf( _T(" ") ); + if( !State.vc ) _tprintf( _T("no") ); + _tprintf( _T("vc\n") ); + + _tprintf( _T(" ") ); + if( !State.ignoretc ) _tprintf( _T("no") ); + _tprintf( _T("ignoretc\n") ); + + _tprintf( _T(" port=%d\n"), State.port ); + _tprintf( _T(" type=%s\n"), State.type ); + _tprintf( _T(" class=%s\n"), State.Class ); + _tprintf( _T(" timeout=%d\n"), (int)State.timeout ); + _tprintf( _T(" retry=%d\n"), (int)State.retry ); + _tprintf( _T(" root=%s\n"), State.root ); + _tprintf( _T(" domain=%s\n"), State.domain ); + + _tprintf( _T(" ") ); + if( !State.MSxfr ) _tprintf( _T("no") ); + _tprintf( _T("MSxfr\n") ); + + _tprintf( _T(" IXFRversion=%d\n"), (int)State.ixfrver ); + + _tprintf( _T(" srchlist=%s\n\n"), State.srchlist[0] ); +} + +void PrintUsage() +{ + _tprintf( _T("Usage:\n" + " nslookup [-opt ...] # interactive mode using" + " default server\n nslookup [-opt ...] - server #" + " interactive mode using 'server'\n nslookup [-opt ...]" + " host # just look up 'host' using default server\n" + " nslookup [-opt ...] host server # just look up 'host'" + " using 'server'\n") ); +} + +BOOL PerformInternalLookup( PCHAR pAddr, PCHAR pResult ) +{ + /* Needed to issue DNS packets and parse them. */ + PCHAR Buffer = NULL, RecBuffer = NULL; + CHAR pResolve[256]; + ULONG BufferLength = 0, RecBufferLength = 512; + int i = 0, j = 0, k = 0, d = 0; + BOOL bOk = FALSE; + + /* Makes things easier when parsing the response packet. */ + UCHAR Header1, Header2; + USHORT NumQuestions; + USHORT NumAnswers; + USHORT NumAuthority; + USHORT NumAdditional; + USHORT Type; + + if( (strlen( pAddr ) + 1) > 255 ) return FALSE; + + Type = TYPE_A; + if( IsValidIP( pAddr ) ) Type = TYPE_PTR; + + /* If it's a PTR lookup then append the ARPA sig to the end. */ + if( Type == TYPE_PTR ) + { + ReverseIP( pAddr, pResolve ); + strcat( pResolve, ARPA_SIG ); + } + else + { + strcpy( pResolve, pAddr ); + } + + /* Base header length + length of QNAME + length of QTYPE and QCLASS */ + BufferLength = 12 + (strlen( pResolve ) + 2) + 4; + + /* Allocate memory for the buffer. */ + Buffer = HeapAlloc( ProcessHeap, 0, BufferLength ); + if( !Buffer ) + { + _tprintf( _T("ERROR: Out of memory\n") ); + goto cleanup; + } + + /* Allocate the receiving buffer. */ + RecBuffer = HeapAlloc( ProcessHeap, 0, RecBufferLength ); + if( !RecBuffer ) + { + _tprintf( _T("ERROR: Out of memory\n") ); + goto cleanup; + } + + /* Insert the ID field. */ + ((PSHORT)&Buffer[i])[0] = htons( RequestID ); + i += 2; + + /* Bits 0-7 of the second 16 are all 0, except for when recursion is + desired. */ + Buffer[i] = 0x00; + if( State.recurse) Buffer[i] |= 0x01; + i += 1; + + /* Bits 8-15 of the second 16 are 0 for a query. */ + Buffer[i] = 0x00; + i += 1; + + /* Only 1 question. */ + ((PSHORT)&Buffer[i])[0] = htons( 1 ); + i += 2; + + /* We aren't sending a response, so 0 out the rest of the header. */ + Buffer[i] = 0x00; + Buffer[i + 1] = 0x00; + Buffer[i + 2] = 0x00; + Buffer[i + 3] = 0x00; + Buffer[i + 4] = 0x00; + Buffer[i + 5] = 0x00; + i += 6; + + /* Walk through the query address. Split each section delimited by '.'. + Format of the QNAME section is length|data, etc. Last one is null */ + j = i; + i += 1; + + for( k = 0; k < strlen( pResolve ); k += 1 ) + { + if( pResolve[k] != '.' ) + { + Buffer[i] = pResolve[k]; + i += 1; + } + else + { + Buffer[j] = (i - j) - 1; + j = i; + i += 1; + } + } + + Buffer[j] = (i - j) - 1; + Buffer[i] = 0x00; + i += 1; + + /* QTYPE */ + ((PSHORT)&Buffer[i])[0] = htons( Type ); + i += 2; + + /* QCLASS */ + ((PSHORT)&Buffer[i])[0] = htons( CLASS_IN ); + + /* Ship the request off to the DNS server. */ + bOk = SendRequest( Buffer, + BufferLength, + RecBuffer, + &RecBufferLength ); + if( !bOk ) goto cleanup; + + /* Start parsing the received packet. */ + Header1 = RecBuffer[2]; + Header2 = RecBuffer[3]; + NumQuestions = ntohs( ((PSHORT)&RecBuffer[4])[0] ); + NumAnswers = ntohs( ((PSHORT)&RecBuffer[6])[0] ); + NumAuthority = ntohs( ((PUSHORT)&RecBuffer[8])[0] ); + NumAdditional = ntohs( ((PUSHORT)&RecBuffer[10])[0] ); + + k = 12; + + /* We don't care about the questions section, blow through it. */ + if( NumQuestions ) + { + for( i = 0; i < NumQuestions; i += 1 ) + { + /* Quick way to skip the domain name section. */ + k += ExtractName( RecBuffer, pResult, k, 0 ); + k += 4; + } + } + + /* Skip the answer name. */ + k += ExtractName( RecBuffer, pResult, k, 0 ); + + Type = ntohs( ((PUSHORT)&RecBuffer[k])[0] ); + k += 8; + + d = ntohs( ((PUSHORT)&RecBuffer[k])[0] ); + k += 2; + + if( TYPE_PTR == Type ) + { + k += ExtractName( RecBuffer, pResult, k, d ); + } + else if( TYPE_A == Type ) + { + k += ExtractIP( RecBuffer, pResult, k ); + } + +cleanup: + /* Free memory. */ + if( Buffer ) HeapFree( ProcessHeap, 0, Buffer ); + if( RecBuffer ) HeapFree( ProcessHeap, 0, RecBuffer ); + + RequestID += 1; + + return bOk; +} + +void PerformLookup( PCHAR pAddr ) +{ + /* Needed to issue DNS packets and parse them. */ + PCHAR Buffer = NULL, RecBuffer = NULL; + CHAR pResolve[256]; + CHAR pResult[256]; + ULONG BufferLength = 0, RecBufferLength = 512; + int i = 0, j = 0, k = 0, d = 0; + BOOL bOk = FALSE; + + /* Makes things easier when parsing the response packet. */ + UCHAR Header1, Header2; + USHORT NumQuestions; + USHORT NumAnswers; + USHORT NumAuthority; + USHORT NumAdditional; + USHORT Type; + + if( (strlen( pAddr ) + 1) > 255 ) return; + + _tprintf( _T("Server: %s\n"), State.DefaultServer ); + _tprintf( _T("Address: %s\n\n"), State.DefaultServerAddress ); + + if( !strcmp( TypeA, State.type ) + || !strcmp( TypeAAAA, State.type ) + || !strcmp( TypeBoth, State.type ) ) + { + Type = TYPE_A; + if( IsValidIP( pAddr ) ) Type = TYPE_PTR; + } + else + Type = TypeNametoTypeID( State.type ); + + /* If it's a PTR lookup then append the ARPA sig to the end. */ + if( (Type == TYPE_PTR) && IsValidIP( pAddr ) ) + { + ReverseIP( pAddr, pResolve ); + strcat( pResolve, ARPA_SIG ); + } + else + { + strcpy( pResolve, pAddr ); + } + + /* Base header length + length of QNAME + length of QTYPE and QCLASS */ + BufferLength = 12 + (strlen( pResolve ) + 2) + 4; + + /* Allocate memory for the buffer. */ + Buffer = HeapAlloc( ProcessHeap, 0, BufferLength ); + if( !Buffer ) + { + _tprintf( _T("ERROR: Out of memory\n") ); + goto cleanup; + } + + /* Allocate memory for the return buffer. */ + RecBuffer = HeapAlloc( ProcessHeap, 0, RecBufferLength ); + if( !RecBuffer ) + { + _tprintf( _T("ERROR: Out of memory\n") ); + goto cleanup; + } + + /* Insert the ID field. */ + ((PSHORT)&Buffer[i])[0] = htons( RequestID ); + i += 2; + + /* Bits 0-7 of the second 16 are all 0, except for when recursion is + desired. */ + Buffer[i] = 0x00; + if( State.recurse) Buffer[i] |= 0x01; + i += 1; + + /* Bits 8-15 of the second 16 are 0 for a query. */ + Buffer[i] = 0x00; + i += 1; + + /* Only 1 question. */ + ((PSHORT)&Buffer[i])[0] = htons( 1 ); + i += 2; + + /* We aren't sending a response, so 0 out the rest of the header. */ + Buffer[i] = 0x00; + Buffer[i + 1] = 0x00; + Buffer[i + 2] = 0x00; + Buffer[i + 3] = 0x00; + Buffer[i + 4] = 0x00; + Buffer[i + 5] = 0x00; + i += 6; + + /* Walk through the query address. Split each section delimited by '.'. + Format of the QNAME section is length|data, etc. Last one is null */ + j = i; + i += 1; + + for( k = 0; k < strlen( pResolve ); k += 1 ) + { + if( pResolve[k] != '.' ) + { + Buffer[i] = pResolve[k]; + i += 1; + } + else + { + Buffer[j] = (i - j) - 1; + j = i; + i += 1; + } + } + + Buffer[j] = (i - j) - 1; + Buffer[i] = 0x00; + i += 1; + + /* QTYPE */ + ((PSHORT)&Buffer[i])[0] = htons( Type ); + i += 2; + + /* QCLASS */ + ((PSHORT)&Buffer[i])[0] = htons( ClassNametoClassID( State.Class ) ); + + /* Ship off the request to the DNS server. */ + bOk = SendRequest( Buffer, + BufferLength, + RecBuffer, + &RecBufferLength ); + if( !bOk ) goto cleanup; + + /* Start parsing the received packet. */ + Header1 = RecBuffer[2]; + Header2 = RecBuffer[3]; + NumQuestions = ntohs( ((PSHORT)&RecBuffer[4])[0] ); + NumAnswers = ntohs( ((PSHORT)&RecBuffer[6])[0] ); + NumAuthority = ntohs( ((PUSHORT)&RecBuffer[8])[0] ); + NumAdditional = ntohs( ((PUSHORT)&RecBuffer[10])[0] ); + Type = 0; + + /* Check the RCODE for failure. */ + d = Header2 & 0x0F; + if( d != RCODE_NOERROR ) + { + switch( d ) + { + case RCODE_NXDOMAIN: + _tprintf( _T("*** %s can't find %s: Non-existant domain\n"), State.DefaultServer, pAddr ); + break; + + case RCODE_REFUSED: + _tprintf( _T("*** %s can't find %s: Query refused\n"), State.DefaultServer, pAddr ); + break; + + default: + _tprintf( _T("*** %s can't find %s: Unknown RCODE\n"), State.DefaultServer, pAddr ); + } + + goto cleanup; + } + + k = 12; + + if( NumQuestions ) + { + /* Blow through the questions section since we don't care about it. */ + for( i = 0; i < NumQuestions; i += 1 ) + { + k += ExtractName( RecBuffer, pResult, k, 0 ); + k += 4; + } + } + + if( NumAnswers ) + { + /* Skip the name. */ + k += ExtractName( RecBuffer, pResult, k, 0 ); + + Type = ntohs( ((PUSHORT)&RecBuffer[k])[0] ); + k += 8; + + d = ntohs( ((PUSHORT)&RecBuffer[k])[0] ); + k += 2; + + if( TYPE_PTR == Type ) + { + k += ExtractName( RecBuffer, pResult, k, d ); + } + else if( TYPE_A == Type ) + { + k += ExtractIP( RecBuffer, pResult, k ); + } + } + + /* FIXME: This'll need to support more than PTR and A at some point. */ + if( !strcmp( State.type, TypePTR ) ) + { + if( TYPE_PTR == Type ) + { + _tprintf( _T("%s name = %s\n"), pResolve, pResult ); + } + else + { + } + } + else if( !strcmp( State.type, TypeA ) + || !strcmp( State.type, TypeAAAA ) + || !strcmp( State.type, TypeBoth ) ) + { + if( (TYPE_A == Type) /*|| (TYPE_AAAA == Type)*/ ) + { + if( 0 == NumAuthority ) + _tprintf( _T("Non-authoritative answer:\n") ); + + _tprintf( _T("Name: %s\n"), pAddr ); + _tprintf( _T("Address: %s\n\n"), pResult ); + } + else + { + _tprintf( _T("Name: %s\n"), pResult ); + _tprintf( _T("Address: %s\n\n"), pAddr ); + } + } + +cleanup: + /* Free memory. */ + if( Buffer ) HeapFree( ProcessHeap, 0, Buffer ); + if( RecBuffer ) HeapFree( ProcessHeap, 0, RecBuffer ); + + RequestID += 1; +} + +BOOL ParseCommandLine( int argc, char* argv[] ) +{ + int i; + BOOL NoMoreOptions = FALSE; + BOOL Interactive = FALSE; + CHAR AddrToResolve[256]; + CHAR Server[256]; + + RtlZeroMemory( AddrToResolve, 256 ); + RtlZeroMemory( Server, 256 ); + + if( 2 == argc ) + { + /* In the Windows nslookup, usage is only displayed if /? is the only + option specified on the command line. */ + if( !strncmp( "/?", argv[1], 2 ) ) + { + PrintUsage(); + return 0; + } + } + + if( argc > 1 ) + { + for( i = 1; i < argc; i += 1 ) + { + if( NoMoreOptions ) + { + strncpy( Server, argv[i], 255 ); + + /* Determine which one to resolve. This is based on whether the + DNS server provided was an IP or an FQDN. */ + if( IsValidIP( Server ) ) + { + strncpy( State.DefaultServerAddress, Server, 16 ); + + PerformInternalLookup( State.DefaultServerAddress, + State.DefaultServer ); + } + else + { + strncpy( State.DefaultServer, Server, 255 ); + + PerformInternalLookup( State.DefaultServer, + State.DefaultServerAddress ); + } + + if( Interactive ) return 1; + + PerformLookup( AddrToResolve ); + + return 0; + } + else + { + if( !strncmp( "-all", argv[i], 4 ) ) + { + PrintState(); + } + else if( !strncmp( "-type=", argv[i], 6 ) ) + { + if( !strncmp( TypeA, &argv[i][6], strlen( TypeA ) ) ) + { + State.type = TypeA; + } + else if( !strncmp( TypeAAAA, &argv[i][6], strlen( TypeAAAA ) ) ) + { + State.type = TypeAAAA; + } + else if( !strncmp( TypeBoth, &argv[i][6], strlen( TypeBoth ) ) ) + { + State.type = TypeBoth; + } + else if( !strncmp( TypeAny, &argv[i][6], strlen( TypeAny ) ) ) + { + State.type = TypeAny; + } + else if( !strncmp( TypeCNAME, &argv[i][6], strlen( TypeCNAME ) ) ) + { + State.type = TypeCNAME; + } + else if( !strncmp( TypeMX, &argv[i][6], strlen( TypeMX ) ) ) + { + State.type = TypeMX; + } + else if( !strncmp( TypeNS, &argv[i][6], strlen( TypeNS ) ) ) + { + State.type = TypeNS; + } + else if( !strncmp( TypePTR, &argv[i][6], strlen( TypePTR ) ) ) + { + State.type = TypePTR; + } + else if( !strncmp( TypeSOA, &argv[i][6], strlen( TypeSOA ) ) ) + { + State.type = TypeSOA; + } + else if( !strncmp( TypeSRV, &argv[i][6], strlen( TypeSRV ) ) ) + { + State.type = TypeSRV; + } + else + { + _tprintf( _T("unknown query type: %s"), &argv[i][6] ); + } + } + else if( !strncmp( "-domain=", argv[i], 8 ) ) + { + strcpy( State.domain, &argv[i][8] ); + } + else if( !strncmp( "-srchlist=", argv[i], 10 ) ) + { + } + else if( !strncmp( "-root=", argv[i], 6 ) ) + { + strcpy( State.root, &argv[i][6] ); + } + else if( !strncmp( "-retry=", argv[i], 7 ) ) + { + } + else if( !strncmp( "-timeout=", argv[i], 9 ) ) + { + } + else if( !strncmp( "-querytype=", argv[i], 11 ) ) + { + if( !strncmp( TypeA, &argv[i][11], strlen( TypeA ) ) ) + { + State.type = TypeA; + } + else if( !strncmp( TypeAAAA, &argv[i][11], strlen( TypeAAAA ) ) ) + { + State.type = TypeAAAA; + } + else if( !strncmp( TypeBoth, &argv[i][11], strlen( TypeBoth ) ) ) + { + State.type = TypeBoth; + } + else if( !strncmp( TypeAny, &argv[i][11], strlen( TypeAny ) ) ) + { + State.type = TypeAny; + } + else if( !strncmp( TypeCNAME, &argv[i][11], strlen( TypeCNAME ) ) ) + { + State.type = TypeCNAME; + } + else if( !strncmp( TypeMX, &argv[i][11], strlen( TypeMX ) ) ) + { + State.type = TypeMX; + } + else if( !strncmp( TypeNS, &argv[i][11], strlen( TypeNS ) ) ) + { + State.type = TypeNS; + } + else if( !strncmp( TypePTR, &argv[i][11], strlen( TypePTR ) ) ) + { + State.type = TypePTR; + } + else if( !strncmp( TypeSOA, &argv[i][11], strlen( TypeSOA ) ) ) + { + State.type = TypeSOA; + } + else if( !strncmp( TypeSRV, &argv[i][11], strlen( TypeSRV ) ) ) + { + State.type = TypeSRV; + } + else + { + _tprintf( _T("unknown query type: %s"), &argv[i][6] ); + } + } + else if( !strncmp( "-class=", argv[i], 7 ) ) + { + if( !strncmp( ClassIN, &argv[i][7], strlen( ClassIN ) ) ) + { + State.Class = ClassIN; + } + else if( !strncmp( ClassAny, &argv[i][7], strlen( ClassAny ) ) ) + { + State.Class = ClassAny; + } + else + { + _tprintf( _T("unknown query class: %s"), &argv[i][7] ); + } + } + else if( !strncmp( "-ixfrver=", argv[i], 9 ) ) + { + } + else if( !strncmp( "-debug", argv[i], 6 ) ) + { + State.debug = TRUE; + } + else if( !strncmp( "-nodebug", argv[i], 8 ) ) + { + State.debug = FALSE; + State.d2 = FALSE; + } + else if( !strncmp( "-d2", argv[i], 3 ) ) + { + State.d2 = TRUE; + State.debug = TRUE; + } + else if( !strncmp( "-nod2", argv[i], 5 ) ) + { + if( State.debug ) _tprintf( _T("d2 mode disabled; still in debug mode\n") ); + + State.d2 = FALSE; + } + else if( !strncmp( "-defname", argv[i], 8 ) ) + { + State.defname = TRUE; + } + else if( !strncmp( "-noddefname", argv[i], 10 ) ) + { + State.defname = FALSE; + } + else if( !strncmp( "-recurse", argv[i], 8 ) ) + { + State.recurse = TRUE; + } + else if( !strncmp( "-norecurse", argv[i], 10 ) ) + { + State.recurse = FALSE; + } + else if( !strncmp( "-search", argv[i], 7 ) ) + { + State.search = TRUE; + } + else if( !strncmp( "-nosearch", argv[i], 9 ) ) + { + State.search = FALSE; + } + else if( !strncmp( "-vc", argv[i], 3 ) ) + { + State.vc = TRUE; + } + else if( !strncmp( "-novc", argv[i], 5 ) ) + { + State.vc = FALSE; + } + else if( !strncmp( "-msxfr", argv[i], 6 ) ) + { + State.MSxfr = TRUE; + } + else if( !strncmp( "-nomsxfr", argv[i], 8 ) ) + { + State.MSxfr = FALSE; + } + else if( !strncmp( "-", argv[i], 1 ) && (strlen( argv[i] ) == 1) ) + { + /* Since we received just the plain - switch, we are going + to be entering interactive mode. We also will not be + parsing any more options. */ + NoMoreOptions = TRUE; + Interactive = TRUE; + } + else + { + /* Grab the address to resolve. No more options accepted + past this point. */ + strncpy( AddrToResolve, argv[i], 255 ); + NoMoreOptions = TRUE; + } + } + } + + if( NoMoreOptions && !Interactive ) + { + /* Get the FQDN of the DNS server. */ + PerformInternalLookup( State.DefaultServerAddress, + State.DefaultServer ); + + PerformLookup( AddrToResolve ); + + return 0; + } + } + + /* Get the FQDN of the DNS server. */ + PerformInternalLookup( State.DefaultServerAddress, + State.DefaultServer ); + + return 1; +} + +void InteractiveMode() +{ + _tprintf( _T("Default Server: %s\n"), State.DefaultServer ); + _tprintf( _T("Address: %s\n\n"), State.DefaultServerAddress ); + + /* TODO: Implement interactive mode. */ + + _tprintf( _T("ERROR: Feature not implemented.\n") ); +} + +int main( int argc, char* argv[] ) +{ + int i; + ULONG Status; + PFIXED_INFO pNetInfo = NULL; + ULONG NetBufLen = 0; + WSADATA wsaData; + + ProcessHeap = GetProcessHeap(); + RequestID = 1; + + /* Set up the initial state. */ + State.debug = FALSE; + State.defname = TRUE; + State.search = TRUE; + State.recurse = TRUE; + State.d2 = FALSE; + State.vc = FALSE; + State.ignoretc = FALSE; + State.port = 53; + State.type = TypeBoth; + State.Class = ClassIN; + State.timeout = 2; + State.retry = 1; + State.MSxfr = TRUE; + State.ixfrver = 1; + + RtlZeroMemory( State.root, 256 ); + RtlZeroMemory( State.domain, 256 ); + for( i = 0; i < 6; i += 1 ) RtlZeroMemory( State.srchlist[i], 256 ); + RtlZeroMemory( State.DefaultServer, 256 ); + RtlZeroMemory( State.DefaultServerAddress, 16 ); + + strncpy( State.root, DEFAULT_ROOT, strlen( DEFAULT_ROOT ) ); + + /* We don't know how long of a buffer it will want to return. So we'll + pass an empty one now and let it fail only once, instead of guessing. */ + Status = GetNetworkParams( pNetInfo, &NetBufLen ); + if( Status == ERROR_BUFFER_OVERFLOW ) + { + pNetInfo = (PFIXED_INFO)HeapAlloc( ProcessHeap, 0, NetBufLen ); + if( pNetInfo == NULL ) + { + _tprintf( _T("ERROR: Out of memory\n") ); + + return -1; + } + + /* For real this time. */ + Status = GetNetworkParams( pNetInfo, &NetBufLen ); + if( Status != NO_ERROR ) + { + _tprintf( _T("Error in GetNetworkParams call\n") ); + + HeapFree( ProcessHeap, 0, pNetInfo ); + + return -2; + } + } + + strncpy( State.domain, pNetInfo->DomainName, 255 ); + strncpy( State.srchlist[0], pNetInfo->DomainName, 255 ); + strncpy( State.DefaultServerAddress, + pNetInfo->DnsServerList.IpAddress.String, + 15 ); + + HeapFree( ProcessHeap, 0, pNetInfo ); + + WSAStartup( MAKEWORD(2,2), &wsaData ); + + switch( ParseCommandLine( argc, argv ) ) + { + case 0: + /* This means that it was a /? parameter. */ + break; + + default: + /* Anything else means we enter interactive mode. The only exception + to this is when the host to resolve was provided on the command + line. */ + InteractiveMode(); + } + + WSACleanup(); + return 0; +} Propchange: trunk/reactos/base/applications/network/nslookup/nslookup.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/base/applications/network/nslookup/nslookup.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/nslookup/nslookup.h (added) +++ trunk/reactos/base/applications/network/nslookup/nslookup.h [iso-8859-1] Fri Oct 23 19:25:05 2009 @@ -1,0 +1,104 @@ +#define TypeA "A" +#define TypeAAAA "AAAA" +#define TypeBoth "A+AAAA" +#define TypeAny "ANY" +#define TypeCNAME "CNAME" +#define TypeMX "MX" +#define TypeNS "NS" +#define TypePTR "PTR" +#define TypeSOA "SOA" +#define TypeSRV "SRV" + +#define TYPE_A 0x01 +#define TYPE_NS 0x02 +#define TYPE_CNAME 0x05 +#define TYPE_SOA 0x06 +#define TYPE_WKS 0x0B +#define TYPE_PTR 0x0C +#define TYPE_MX 0x0F +#define TYPE_ANY 0xFF + +#define ClassIN "IN" +#define ClassAny "ANY" + +#define CLASS_IN 0x01 +#define CLASS_ANY 0xFF + +#define OPCODE_QUERY 0x00 +#define OPCODE_IQUERY 0x01 +#define OPCODE_STATUS 0x02 + +#define OpcodeQuery "QUERY" +#define OpcodeIQuery "IQUERY" +#define OpcodeStatus "STATUS" +#define OpcodeReserved "RESERVED" + +#define RCODE_NOERROR 0x00 +#define RCODE_FORMERR 0x01 +#define RCODE_FAILURE 0x02 +#define RCODE_NXDOMAIN 0x03 +#define RCODE_NOTIMP 0x04 +#define RCODE_REFUSED 0x05 + +#define RCodeNOERROR "NOERROR" +#define RCodeFORMERR "FORMERR" +#define RCodeFAILURE "FAILURE" +#define RCodeNXDOMAIN "NXDOMAIN" +#define RCodeNOTIMP "NOTIMP" +#define RCodeREFUSED "REFUSED" +#define RCodeReserved "RESERVED" + +#define DEFAULT_ROOT "
A.ROOT-SERVERS.NET
." +#define ARPA_SIG ".in-addr.arpa" + +typedef struct _STATE +{ + BOOL debug; + BOOL defname; + BOOL d2; + BOOL recurse; + BOOL search; + BOOL vc; + BOOL ignoretc; + BOOL MSxfr; + CHAR domain[256]; + CHAR srchlist[6][256]; + CHAR root[256]; + DWORD retry; + DWORD timeout; + DWORD ixfrver; + PCHAR type; + PCHAR Class; + USHORT port; + CHAR DefaultServer[256]; + CHAR DefaultServerAddress[16]; +} STATE, *PSTATE; + +/* nslookup.c */ + +extern STATE State; +extern HANDLE ProcessHeap; + +/* utility.c */ + +BOOL SendRequest( PCHAR pInBuffer, + ULONG InBufferLength, + PCHAR pOutBuffer, + PULONG pOutBufferLength ); + +int ExtractName( PCHAR pBuffer, + PCHAR pOutput, + USHORT Offset, + UCHAR Limit ); + +void ReverseIP( PCHAR pIP, PCHAR pReturn ); +BOOL IsValidIP( PCHAR pInput ); +int ExtractIP( PCHAR pBuffer, PCHAR pOutput, USHORT Offset ); +void PrintD2( PCHAR pBuffer, DWORD BufferLength ); +void PrintDebug( PCHAR pBuffer, DWORD BufferLength ); +PCHAR OpcodeIDtoOpcodeName( UCHAR Opcode ); +PCHAR RCodeIDtoRCodeName( UCHAR RCode ); +PCHAR TypeIDtoTypeName( USHORT TypeID ); +USHORT TypeNametoTypeID( PCHAR TypeName ); +PCHAR ClassIDtoClassName( USHORT ClassID ); +USHORT ClassNametoClassID( PCHAR ClassName ); Propchange: trunk/reactos/base/applications/network/nslookup/nslookup.h ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/base/applications/network/nslookup/nslookup.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/nslookup/nslookup.rbuild (added) +++ trunk/reactos/base/applications/network/nslookup/nslookup.rbuild [iso-8859-1] Fri Oct 23 19:25:05 2009 @@ -1,0 +1,13 @@ +<?xml version="1.0"?> +<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd"> +<module name="nslookup" type="win32cui" installbase="system32" installname="nslookup.exe"> + <include base="nslookup">.</include> + <library>kernel32</library> + <library>user32</library> + <library>ws2_32</library> + <library>snmpapi</library> + <library>iphlpapi</library> + <file>nslookup.c</file> + <file>utility.c</file> + <file>nslookup.rc</file> +</module> Propchange: trunk/reactos/base/applications/network/nslookup/nslookup.rbuild ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/base/applications/network/nslookup/nslookup.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/nslookup/nslookup.rc (added) +++ trunk/reactos/base/applications/network/nslookup/nslookup.rc [iso-8859-1] Fri Oct 23 19:25:05 2009 @@ -1,0 +1,5 @@ +#define REACTOS_STR_FILE_DESCRIPTION "ReactOS TCP/IPv4 Win32 nslookup\0" +#define REACTOS_STR_INTERNAL_NAME "nslookup\0" +#define REACTOS_STR_ORIGINAL_FILENAME "nslookup.exe\0" +#define REACTOS_STR_ORIGINAL_COPYRIGHT "Lucas Suggs (lucas.suggs(a)gmail.com)\0" +#include <reactos/version.rc> Propchange: trunk/reactos/base/applications/network/nslookup/nslookup.rc ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/base/applications/network/nslookup/utility.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/nslookup/utility.c (added) +++ trunk/reactos/base/applications/network/nslookup/utility.c [iso-8859-1] Fri Oct 23 19:25:05 2009 @@ -1,0 +1,852 @@ +/* + * PROJECT: ReactOS nslookup utility + * LICENSE: GPL - See COPYING in the top level directory + * FILE: applications/network/nslookup/utility.c + * PURPOSE: Support functions for nslookup.c + * COPYRIGHT: Copyright 2009 Lucas Suggs <lucas.suggs(a)gmail.com> + */ + +#include <windows.h> +#include <tchar.h> +#include <stdio.h> +#include "nslookup.h" + +BOOL SendRequest( PCHAR pInBuffer, + ULONG InBufferLength, + PCHAR pOutBuffer, + PULONG pOutBufferLength ) +{ + int j; + USHORT RequestID, ResponseID; + BOOL bWait; + SOCKET s; + SOCKADDR_IN RecAddr, RecAddr2, SendAddr; + int SendAddrLen = sizeof(SendAddr); + + RtlZeroMemory( &RecAddr, sizeof(SOCKADDR_IN) ); + RtlZeroMemory( &RecAddr2, sizeof(SOCKADDR_IN) ); + RtlZeroMemory( &SendAddr, sizeof(SOCKADDR_IN) ); + + /* Pull the request ID from the buffer. */ + RequestID = ntohs( ((PSHORT)&pInBuffer[0])[0] ); + + /* If D2 flags is enabled, then display D2 information. */ + if( State.d2 ) PrintD2( pInBuffer, InBufferLength ); + + /* Create the sockets for both send and receive. */ + s = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP ); + + /* Set up the structure to tell it where we are going. */ + RecAddr.sin_family = AF_INET; + RecAddr.sin_port = htons( State.port ); + RecAddr.sin_addr.s_addr = inet_addr( State.DefaultServerAddress ); + + /* Set up the structure to tell it what port to listen on. */ + RecAddr2.sin_family = AF_INET; + RecAddr2.sin_port = htons( State.port ); + RecAddr2.sin_addr.s_addr = htonl( INADDR_ANY ); + + /* Bind the receive socket. */ + bind( s, (SOCKADDR*)&RecAddr2, sizeof(RecAddr2) ); + + /* Send the datagram to the DNS server. */ + j = sendto( s, + pInBuffer, + InBufferLength, + 0, + (SOCKADDR*)&RecAddr, + sizeof(RecAddr) ); + if( j == SOCKET_ERROR ) + { + switch( WSAGetLastError() ) + { + case WSANOTINITIALISED: + _tprintf( _T("sendto() failed with WSANOTINITIALIZED\n") ); + break; + case WSAENETDOWN: + _tprintf( _T("sendto() failed with WSAENETDOWN\n") ); + break; + case WSAEACCES: + _tprintf( _T("sendto() failed with WSAEACCES\n") ); + break; + case WSAEINVAL: + _tprintf( _T("sendto() failed with WSAEINVAL\n") ); + break; + case WSAEINTR: + _tprintf( _T("sendto() failed with WSAEINTR\n") ); + break; + case WSAEINPROGRESS: + _tprintf( _T("sendto() failed with WSAEINPROGRESS\n") ); + break; + case WSAEFAULT: + _tprintf( _T("sendto() failed with WSAEFAULT\n") ); + break; + case WSAENETRESET: + _tprintf( _T("sendto() failed with WSAENETRESET\n") ); + break; + case WSAENOBUFS: + _tprintf( _T("sendto() failed with WSAENOBUFS\n") ); + break; + case WSAENOTCONN: + _tprintf( _T("sendto() failed with WSAENOTCONN\n") ); + break; + case WSAENOTSOCK: + _tprintf( _T("sendto() failed with WSAENOTSOCK\n") ); + break; + case WSAEOPNOTSUPP: + _tprintf( _T("sendto() failed with WSAEOPNOTSUPP\n") ); + break; + case WSAESHUTDOWN: + _tprintf( _T("sendto() failed with WSAESHUTDOWN\n") ); + break; + case WSAEWOULDBLOCK: + _tprintf( _T("sendto() failed with WSAEWOULDBLOCK\n") ); + break; + case WSAEMSGSIZE: + _tprintf( _T("sendto() failed with WSAEMSGSIZE\n") ); + break; + case WSAEHOSTUNREACH: + _tprintf( _T("sendto() failed with WSAEHOSTUNREACH\n") ); + break; + case WSAECONNABORTED: + _tprintf( _T("sendto() failed with WSAECONNABORTED\n") ); + break; + case WSAECONNRESET: + _tprintf( _T("sendto() failed with WSAECONNRESET\n") ); + break; + case WSAEADDRNOTAVAIL: + _tprintf( _T("sendto() failed with WSAEADDRNOTAVAIL\n") ); + break; + case WSAEAFNOSUPPORT: + _tprintf( _T("sendto() failed with WSAEAFNOSUPPORT\n") ); + break; + case WSAEDESTADDRREQ: + _tprintf( _T("sendto() failed with WSAEDESTADDRREQ\n") ); + break; + case WSAENETUNREACH: + _tprintf( _T("sendto() failed with WSAENETUNREACH\n") ); + break; + case WSAETIMEDOUT: + _tprintf( _T("sendto() failed with WSAETIMEDOUT\n") ); + break; + default: + _tprintf( _T("sendto() failed with unknown error\n") ); + } + + return FALSE; + } + + bWait = TRUE; + + while( bWait ) + { + /* Wait for the DNS reply. */ + j = recvfrom( s, + pOutBuffer, + *pOutBufferLength, + 0, + (SOCKADDR*)&SendAddr, + &SendAddrLen ); + if( j == SOCKET_ERROR ) + { + switch( WSAGetLastError() ) + { + case WSANOTINITIALISED: + _tprintf( _T("recvfrom() failed with WSANOTINITIALIZED\n") ); + break; + case WSAENETDOWN: + _tprintf( _T("recvfrom() failed with WSAENETDOWN\n") ); + break; + case WSAEACCES: + _tprintf( _T("recvfrom() failed with WSAEACCES\n") ); + break; + case WSAEINVAL: + _tprintf( _T("recvfrom() failed with WSAEINVAL\n") ); + break; + case WSAEINTR: + _tprintf( _T("recvfrom() failed with WSAEINTR\n") ); + break; + case WSAEINPROGRESS: + _tprintf( _T("recvfrom() failed with WSAEINPROGRESS\n") ); + break; + case WSAEFAULT: + _tprintf( _T("recvfrom() failed with WSAEFAULT\n") ); + break; + case WSAENETRESET: + _tprintf( _T("recvfrom() failed with WSAENETRESET\n") ); + break; + case WSAENOBUFS: + _tprintf( _T("recvfrom() failed with WSAENOBUFS\n") ); + break; + case WSAENOTCONN: + _tprintf( _T("recvfrom() failed with WSAENOTCONN\n") ); + break; + case WSAENOTSOCK: + _tprintf( _T("recvfrom() failed with WSAENOTSOCK\n") ); + break; + case WSAEOPNOTSUPP: + _tprintf( _T("recvfrom() failed with WSAEOPNOTSUPP\n") ); + break; + case WSAESHUTDOWN: + _tprintf( _T("recvfrom() failed with WSAESHUTDOWN\n") ); + break; + case WSAEWOULDBLOCK: + _tprintf( _T("recvfrom() failed with WSAEWOULDBLOCK\n") ); + break; + case WSAEMSGSIZE: + _tprintf( _T("recvfrom() failed with WSAEMSGSIZE\n") ); + break; + case WSAEHOSTUNREACH: + _tprintf( _T("recvfrom() failed with WSAEHOSTUNREACH\n") ); + break; + case WSAECONNABORTED: + _tprintf( _T("recvfrom() failed with WSAECONNABORTED\n") ); + break; + case WSAECONNRESET: + _tprintf( _T("recvfrom() failed with WSAECONNRESET\n") ); + break; + case WSAEADDRNOTAVAIL: + _tprintf( _T("recvfrom() failed with WSAEADDRNOTAVAIL\n") ); + break; + case WSAEAFNOSUPPORT: + _tprintf( _T("recvfrom() failed with WSAEAFNOSUPPORT\n") ); + break; + case WSAEDESTADDRREQ: + _tprintf( _T("recvfrom() failed with WSAEDESTADDRREQ\n") ); + break; + case WSAENETUNREACH: + _tprintf( _T("recvfrom() failed with WSAENETUNREACH\n") ); + break; + case WSAETIMEDOUT: + _tprintf( _T("recvfrom() failed with WSAETIMEDOUT\n") ); + break; + default: + _tprintf( _T("recvfrom() failed with unknown error\n") ); + } + + return FALSE; + } + + ResponseID = ntohs( ((PSHORT)&pOutBuffer[0])[0] ); + + if( ResponseID == RequestID ) bWait = FALSE; + } + + /* We don't need the sockets anymore. */ + closesocket( s ); + + /* If debug information then display debug information. */ + if( State.debug ) PrintDebug( pOutBuffer, j ); + + /* Return the real output buffer length. */ + *pOutBufferLength = j; + + return TRUE; +} + +void ReverseIP( PCHAR pIP, PCHAR pReturn ) +{ + int i; + int j; + int k = 0; + + j = strlen( pIP ) - 1; + i = j; + + /* We have A.B.C.D + We will turn this into D.C.B.A and stick it in pReturn */ + + /* A */ + for( ; i > 0; i -= 1 ) if( '.' == pIP[i] ) break; + + strncpy( &pReturn[k], &pIP[i + 1], (j - i) ); + k += (j - i); + + pReturn[k] = '.'; + k += 1; + + i -= 1; + j = i; + + /* B */ + for( ; i > 0; i -= 1 ) if( '.' == pIP[i] ) break; + + strncpy( &pReturn[k], &pIP[i + 1], (j - i) ); + k += (j - i); + + pReturn[k] = '.'; + k += 1; + + i -= 1; + j = i; + + /* C */ + for( ; i > 0; i -= 1 ) if( '.' == pIP[i] ) break; + + strncpy( &pReturn[k], &pIP[i + 1], (j - i) ); + k += (j - i); + + pReturn[k] = '.'; + k += 1; + + i -= 1; + j = i; + + /* D */ + for( ; i > 0; i -= 1 ); + + strncpy( &pReturn[k], &pIP[i], (j - i) + 1 ); + k += (j - i) + 1; + + pReturn[k] = '\0'; +} + +BOOL IsValidIP( PCHAR pInput ) +{ + int i = 0, l = 0, b = 0, c = 1; + + /* Max length of an IP, e.g. 255.255.255.255, is 15 characters. */ + l = strlen( pInput ); + if( l > 15 ) return FALSE; + + /* 'b' is the count of the current segment. It gets reset after seeing a + '.'. */ + for( ; i < l; i += 1 ) + { + if( '.' == pInput[i] ) + { + if( !b ) return FALSE; + if( b > 3 ) return FALSE; + + b = 0; + c += 1; + } + else + { + b += 1; + + if( (pInput[i] < '0') || (pInput[i] > '9') ) return FALSE; + } + } + + if( b > 3 ) return FALSE; + + /* 'c' is the number of segments seen. If it's less than 4, then it's not + a valid IP. */ + if( c < 4 ) return FALSE; + + return TRUE; +} + +int ExtractName( PCHAR pBuffer, PCHAR pOutput, USHORT Offset, UCHAR Limit ) +{ + int c = 0, d = 0, i = 0, j = 0, k = 0, l = 0, m = 0; + + i = Offset; + + /* If Limit == 0, then we assume "no" limit. */ + d = Limit; + if( 0 == Limit ) d = 255; + + while( d > 0 ) + { + l = pBuffer[i] & 0xFF; + i += 1; + if( !m ) c += 1; + + if( 0xC0 == l ) + { + if( !m ) c += 1; + m = 1; + d += (255 - Limit); + i = pBuffer[i]; + } + else + { + for( j = 0; j < l; j += 1 ) + { + pOutput[k] = pBuffer[i]; + + i += 1; + if( !m ) c += 1; + k += 1; + d -= 1; + } + + d -= 1; + + if( !pBuffer[i] || (d < 1) ) break; + + pOutput[k] = '.'; + k += 1; + } + }; + + if( !m ) + { + if( !Limit ) c += 1; + } + + pOutput[k] = '\0'; + + return c; +} + +int ExtractIP( PCHAR pBuffer, PCHAR pOutput, USHORT Offset ) +{ + int c = 0, l = 0, i = 0, v = 0; + + i = Offset; + + v = (UCHAR)pBuffer[i]; + l += 1; + i += 1; + + sprintf( &pOutput[c], "%d.", v ); + c += strlen( &pOutput[c] ); + + v = (UCHAR)pBuffer[i]; + l += 1; + i += 1; + + sprintf( &pOutput[c], "%d.", v ); + c += strlen( &pOutput[c] ); + + v = (UCHAR)pBuffer[i]; + l += 1; + i += 1; + + sprintf( &pOutput[c], "%d.", v ); + c += strlen( &pOutput[c] ); + + v = (UCHAR)pBuffer[i]; + l += 1; + i += 1; + + sprintf( &pOutput[c], "%d", v ); + c += strlen( &pOutput[c] ); + + pOutput[c] = '\0'; + + return l; +} + +void PrintD2( PCHAR pBuffer, DWORD BufferLength ) +{ + USHORT RequestID; + UCHAR Header1, Header2; + USHORT NumQuestions, NumAnswers, NumAuthority, NumAdditional; + USHORT Type, Class; + CHAR pName[255]; + int i = 0, k = 0; + + RequestID = ntohs( ((PUSHORT)&pBuffer[i])[0] ); + i += 2; + + Header1 = pBuffer[i]; + i += 1; + + Header2 = pBuffer[i]; + i += 1; + + NumQuestions = ntohs( ((PSHORT)&pBuffer[i])[0] ); + i += 2; + + NumAnswers = ntohs( ((PSHORT)&pBuffer[i])[0] ); + i += 2; + + NumAuthority = ntohs( ((PUSHORT)&pBuffer[i])[0] ); + i += 2; + + NumAdditional = ntohs( ((PUSHORT)&pBuffer[i])[0] ); + i += 2; + + _tprintf( _T("------------\n") ); + _tprintf( _T("SendRequest(), len %d\n"), (int)BufferLength ); + _tprintf( _T(" HEADER:\n") ); + _tprintf( _T(" opcode = %s, id = %d, rcode = %s\n"), + OpcodeIDtoOpcodeName( (Header1 & 0x78) >> 3 ), + (int)RequestID, + RCodeIDtoRCodeName( Header2 & 0x0F ) ); + + _tprintf( _T(" header flags: query") ); + if( Header1 & 0x01 ) _tprintf( _T(", want recursion") ); + _tprintf( _T("\n") ); + + _tprintf( _T(" questions = %d, answers = %d," + " authority records = %d, additional = %d\n\n"), + (int)NumQuestions, + (int)NumAnswers, + (int)NumAuthority, + (int)NumAdditional ); + + if( NumQuestions ) + { + _tprintf( _T(" QUESTIONS:\n") ); + + for( k = 0; k < NumQuestions; k += 1 ) + { + i += ExtractName( pBuffer, pName, i, 0 ); + + _tprintf( _T(" %s"), pName ); + + Type = ntohs( ((PUSHORT)&pBuffer[i])[0] ); + i += 2; + + Class = ntohs( ((PUSHORT)&pBuffer[i])[0] ); + i += 2; + + _tprintf( _T(", type = %s, class = %s\n"), + TypeIDtoTypeName( Type ), + ClassIDtoClassName( Class ) ); + } + } + + _tprintf( _T("\n------------\n") ); +} + +void PrintDebug( PCHAR pBuffer, DWORD BufferLength ) +{ + USHORT ResponseID; + UCHAR Header1, Header2; + USHORT NumQuestions, NumAnswers, NumAuthority, NumAdditional; + USHORT Type, Class; + ULONG TTL; + CHAR pName[255]; + int d = 0, i = 0, k = 0; + + ResponseID = ntohs( ((PUSHORT)&pBuffer[i])[0] ); + i += 2; + + Header1 = pBuffer[i]; + i += 1; + + Header2 = pBuffer[i]; + i += 1; + + NumQuestions = ntohs( ((PSHORT)&pBuffer[i])[0] ); + i += 2; + + NumAnswers = ntohs( ((PSHORT)&pBuffer[i])[0] ); + i += 2; + + NumAuthority = ntohs( ((PUSHORT)&pBuffer[i])[0] ); + i += 2; + + NumAdditional = ntohs( ((PUSHORT)&pBuffer[i])[0] ); + i += 2; + + _tprintf( _T("------------\n") ); + _tprintf( _T("Got answer (%d bytes):\n"), (int)BufferLength ); + _tprintf( _T(" HEADER:\n") ); + _tprintf( _T(" opcode = %s, id = %d, rcode = %s\n"), + OpcodeIDtoOpcodeName( (Header1 & 0x78) >> 3 ), + (int)ResponseID, + RCodeIDtoRCodeName( Header2 & 0x0F ) ); + + _tprintf( _T(" header flags: response") ); + if( Header1 & 0x01 ) _tprintf( _T(", want recursion") ); + if( Header2 & 0x80 ) _tprintf( _T(", recursion avail.") ); + _tprintf( _T("\n") ); + + _tprintf( _T(" questions = %d, answers = %d, " + "authority records = %d, additional = %d\n\n"), + (int)NumQuestions, + (int)NumAnswers, + (int)NumAuthority, + (int)NumAdditional ); + + if( NumQuestions ) + { + _tprintf( _T(" QUESTIONS:\n") ); + + for( k = 0; k < NumQuestions; k += 1 ) + { + i += ExtractName( pBuffer, pName, i, 0 ); + + _tprintf( _T(" %s"), pName ); + + Type = ntohs( ((PUSHORT)&pBuffer[i])[0] ); + i += 2; + + Class = ntohs( ((PUSHORT)&pBuffer[i])[0] ); + i += 2; + + _tprintf( _T(", type = %s, class = %s\n"), + TypeIDtoTypeName( Type ), + ClassIDtoClassName( Class ) ); + } + } + + if( NumAnswers ) + { + _tprintf( _T(" ANSWERS:\n") ); + + for( k = 0; k < NumAnswers; k += 1 ) + { + _tprintf( _T(" -> ") ); + + /* Print out the name. */ + i += ExtractName( pBuffer, pName, i, 0 ); + + _tprintf( _T("%s\n"), pName ); + + /* Print out the type, class and data length. */ + Type = ntohs( ((PUSHORT)&pBuffer[i])[0] ); + i += 2; + + Class = ntohs( ((PUSHORT)&pBuffer[i])[0] ); + i += 2; + + TTL = ntohl( ((PULONG)&pBuffer[i])[0] ); + i += 4; + + d = ntohs( ((PUSHORT)&pBuffer[i])[0] ); + i += 2; + + _tprintf( _T(" type = %s, class = %s, dlen = %d\n"), + TypeIDtoTypeName( Type ), + ClassIDtoClassName( Class ), + d ); + + /* Print out the answer. */ + if( TYPE_A == Type ) + { + i += ExtractIP( pBuffer, pName, i ); + + _tprintf( _T(" internet address = %s\n"), pName ); + } + else + { + i += ExtractName( pBuffer, pName, i, d ); + + _tprintf( _T(" name = %s\n"), pName ); + } + + _tprintf( _T(" ttl = %d ()\n"), (int)TTL ); + } + } + + if( NumAuthority ) + { + _tprintf( _T(" AUTHORITY RECORDS:\n") ); + + for( k = 0; k < NumAuthority; k += 1 ) + { + /* Print out the zone name. */ + i += ExtractName( pBuffer, pName, i, 0 ); + + _tprintf( _T(" -> %s\n"), pName ); + + /* Print out the type, class, data length and TTL. */ + Type = ntohs( ((PUSHORT)&pBuffer[i])[0] ); + i += 2; + + Class = ntohs( ((PUSHORT)&pBuffer[i])[0] ); + i += 2; + + TTL = ntohl( ((PULONG)&pBuffer[i])[0] ); + i += 4; + + d = ntohs( ((PUSHORT)&pBuffer[i])[0] ); + i += 2; + + _tprintf( _T(" type = %s, class = %s, dlen = %d\n"), + TypeIDtoTypeName( Type ), + ClassIDtoClassName( Class ), + d ); + + /* TODO: There might be more types? */ + if( TYPE_NS == Type ) + { + /* Print out the NS. */ + i += ExtractName( pBuffer, pName, i, d ); + + _tprintf( _T(" nameserver = %s\n"), pName ); + + _tprintf( _T(" ttl = %d ()\n"), (int)TTL ); + } + else if( TYPE_SOA == Type ) + { + _tprintf( _T(" ttl = %d ()\n"), (int)TTL ); + + /* Print out the primary NS. */ + i += ExtractName( pBuffer, pName, i, 0 ); + + _tprintf( _T(" primary name server = %s\n"), pName ); + + /* Print out the responsible mailbox. */ + i += ExtractName( pBuffer, pName, i, 0 ); + + _tprintf( _T(" responsible mail addr = %s\n"), pName ); + + /* Print out the serial, refresh, retry, expire and default TTL. */ + _tprintf( _T(" serial = ()\n") ); + _tprintf( _T(" refresh = ()\n") ); + _tprintf( _T(" retry = ()\n") ); + _tprintf( _T(" expire = ()\n") ); + _tprintf( _T(" default TTL = ()\n") ); + i += 20; + } + } + } + + if( NumAdditional ) + { + _tprintf( _T(" ADDITIONAL:\n") ); + + for( k = 0; k < NumAdditional; k += 1 ) + { + /* Print the name. */ + i += ExtractName( pBuffer, pName, i, 0 ); + + _tprintf( _T(" -> %s\n"), pName ); + + /* Print out the type, class, data length and TTL. */ + Type = ntohs( ((PUSHORT)&pBuffer[i])[0] ); + i += 2; + + Class = ntohs( ((PUSHORT)&pBuffer[i])[0] ); + i += 2; + + TTL = ntohl( ((PULONG)&pBuffer[i])[0] ); + i += 4; + + d = ntohs( ((PUSHORT)&pBuffer[i])[0] ); + i += 2; + + _tprintf( _T(" type = %s, class = %s, dlen = %d\n"), + TypeIDtoTypeName( Type ), + ClassIDtoClassName( Class ), + d ); + + /* TODO: There might be more types? */ + if( TYPE_A == Type ) + { + /* Print out the NS. */ + i += ExtractIP( pBuffer, pName, i ); + + _tprintf( _T(" internet address = %s\n"), pName ); + + _tprintf( _T(" ttl = %d ()\n"), (int)TTL ); + } + } + } + + _tprintf( _T("\n------------\n") ); +} + +PCHAR OpcodeIDtoOpcodeName( UCHAR Opcode ) +{ + switch( Opcode & 0x0F ) + { + case OPCODE_QUERY: + return OpcodeQuery; + + case OPCODE_IQUERY: + return OpcodeIQuery; + + case OPCODE_STATUS: + return OpcodeStatus; + + default: + return OpcodeReserved; + } +} + +PCHAR RCodeIDtoRCodeName( UCHAR RCode ) +{ + switch( RCode & 0x0F ) + { + case RCODE_NOERROR: + return RCodeNOERROR; + + case RCODE_FORMERR: + return RCodeFORMERR; + + case RCODE_FAILURE: + return RCodeFAILURE; + + case RCODE_NXDOMAIN: + return RCodeNXDOMAIN; + + case RCODE_NOTIMP: + return RCodeNOTIMP; + + case RCODE_REFUSED: + return RCodeREFUSED; + + default: + return RCodeReserved; + } +} + +PCHAR TypeIDtoTypeName( USHORT TypeID ) +{ + switch( TypeID ) + { + case TYPE_A: + return TypeA; + + case TYPE_NS: + return TypeNS; + + case TYPE_CNAME: + return TypeCNAME; + + case TYPE_SOA: + return TypeSOA; + + case TYPE_WKS: + return TypeSRV; + + case TYPE_PTR: + return TypePTR; + + case TYPE_MX: + return TypeMX; + + case TYPE_ANY: + return TypeAny; + + default: + return "Unknown"; + } +} + +USHORT TypeNametoTypeID( PCHAR TypeName ) +{ + if( !strncmp( TypeName, TypeA, strlen( TypeA ) ) ) return TYPE_A; + if( !strncmp( TypeName, TypeNS, strlen( TypeNS ) ) ) return TYPE_NS; + if( !strncmp( TypeName, TypeCNAME, strlen( TypeCNAME ) ) ) return TYPE_CNAME; + if( !strncmp( TypeName, TypeSOA, strlen( TypeSOA ) ) ) return TYPE_SOA; + if( !strncmp( TypeName, TypeSRV, strlen( TypeSRV ) ) ) return TYPE_WKS; + if( !strncmp( TypeName, TypePTR, strlen( TypePTR ) ) ) return TYPE_PTR; + if( !strncmp( TypeName, TypeMX, strlen( TypeMX ) ) ) return TYPE_MX; + if( !strncmp( TypeName, TypeAny, strlen( TypeAny ) ) ) return TYPE_ANY; + + return 0; +} + +PCHAR ClassIDtoClassName( USHORT ClassID ) +{ + switch( ClassID ) + { + case CLASS_IN: + return ClassIN; + + case CLASS_ANY: + return ClassAny; + + default: + return "Unknown"; + } +} + +USHORT ClassNametoClassID( PCHAR ClassName ) +{ + if( !strncmp( ClassName, ClassIN, strlen( ClassIN ) ) ) return CLASS_IN; + if( !strncmp( ClassName, ClassAny, strlen( ClassAny ) ) ) return CLASS_ANY; + + return 0; +} Propchange: trunk/reactos/base/applications/network/nslookup/utility.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/reactos/boot/bootdata/packages/reactos.dff URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/packages/rea…
============================================================================== --- trunk/reactos/boot/bootdata/packages/reactos.dff [iso-8859-1] (original) +++ trunk/reactos/boot/bootdata/packages/reactos.dff [iso-8859-1] Fri Oct 23 19:25:05 2009 @@ -64,6 +64,7 @@ base\applications\network\ftp\ftp.exe 1 base\applications\network\ipconfig\ipconfig.exe 1 base\applications\network\netstat\netstat.exe 1 +base\applications\network\nslookup\nslookup.exe 1 base\applications\network\ping\ping.exe 1 base\applications\network\telnet\telnet.exe 1 base\applications\network\tracert\tracert.exe 1
15 years, 2 months
1
0
0
0
[fireball] 43699: - Make all object dumping use DbgPrint instead of DPRINT macro, since it does table formatted output. - Properly print strings.
by fireball@svn.reactos.org
Author: fireball Date: Fri Oct 23 15:26:18 2009 New Revision: 43699 URL:
http://svn.reactos.org/svn/reactos?rev=43699&view=rev
Log: - Make all object dumping use DbgPrint instead of DPRINT macro, since it does table formatted output. - Properly print strings. Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/atom.c branches/arwinss/reactos/subsystems/win32/win32k/wine/directory.c branches/arwinss/reactos/subsystems/win32/win32k/wine/handle.c branches/arwinss/reactos/subsystems/win32/win32k/wine/object.c branches/arwinss/reactos/subsystems/win32/win32k/wine/queue.c branches/arwinss/reactos/subsystems/win32/win32k/wine/winstation.c Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/atom.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/wine/atom.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/wine/atom.c [iso-8859-1] Fri Oct 23 15:26:18 2009 @@ -170,21 +170,22 @@ static void atom_table_dump( struct object *obj, int verbose ) { int i; + UNICODE_STRING str; struct atom_table *table = (struct atom_table *)obj; assert( obj->ops == &atom_table_ops ); - DPRINT1( "Atom table size=%d entries=%d\n", + DbgPrint( "Atom table size=%d entries=%d\n", table->last + 1, table->entries_count ); if (!verbose) return; for (i = 0; i <= table->last; i++) { struct atom_entry *entry = table->handles[i]; if (!entry) continue; - DPRINT1( " %04x: ref=%d pinned=%c hash=%d \"", + DbgPrint( " %04x: ref=%d pinned=%c hash=%d \"", entry->atom, entry->count, entry->pinned ? 'Y' : 'N', entry->hash ); - //dump_strW( entry->str, entry->len / sizeof(WCHAR), stderr, "\"\""); - DbgPrint("skipping dump_strW..."); - DPRINT1( "\"\n" ); + str.Buffer = entry->str; str.Length = str.MaximumLength = entry->len; + DbgPrint("%wZ", &str); + DbgPrint( "\"\n" ); } } Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/directory.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/wine/directory.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/wine/directory.c [iso-8859-1] Fri Oct 23 15:26:18 2009 @@ -118,7 +118,7 @@ { assert( obj->ops == &directory_ops ); - DPRINT1( "Directory "); + DbgPrint( "Directory "); dump_object_name( obj ); DbgPrint( "\n" ); } Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/handle.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/wine/handle.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/wine/handle.c [iso-8859-1] Fri Oct 23 15:26:18 2009 @@ -121,14 +121,14 @@ assert( obj->ops == &handle_table_ops ); - DPRINT1( "Handle table last=%d count=%d process=%p\n", + DbgPrint( "Handle table last=%d count=%d process=%p\n", table->last, table->count, table->process ); if (!verbose) return; entry = table->entries; for (i = 0; i <= table->last; i++, entry++) { if (!entry->ptr) continue; - DPRINT1( " %04x: %p %08x ", + DbgPrint( " %04x: %p %08x ", index_to_handle(i), entry->ptr, entry->access ); entry->ptr->ops->dump( entry->ptr, 0 ); } Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/object.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/wine/object.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/wine/object.c [iso-8859-1] Fri Oct 23 15:26:18 2009 @@ -53,13 +53,13 @@ LIST_FOR_EACH( p, &static_object_list ) { struct object *ptr = LIST_ENTRY( p, struct object, obj_list ); - DPRINT1( "%p:%d: ", ptr, ptr->refcount ); + DbgPrint( "%p:%d: ", ptr, ptr->refcount ); ptr->ops->dump( ptr, 1 ); } LIST_FOR_EACH( p, &object_list ) { struct object *ptr = LIST_ENTRY( p, struct object, obj_list ); - DPRINT1( "%p:%d: ", ptr, ptr->refcount ); + DbgPrint( "%p:%d: ", ptr, ptr->refcount ); ptr->ops->dump( ptr, 1 ); } } @@ -222,12 +222,13 @@ /* dump the name of an object to stderr */ void dump_object_name( struct object *obj ) { + UNICODE_STRING str; if (!obj->name) DbgPrint( "name=\"\"" ); else { DbgPrint( "name=L\"" ); - //dump_strW( obj->name->name, obj->name->len/sizeof(WCHAR), stderr, "\"\"" ); - DbgPrint("[dump_strW is missing]"); + str.Buffer = obj->name->name; str.Length = str.MaximumLength = obj->name->len; + DbgPrint("%wZ", &str); DbgPrint( "\"" ); } } Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/queue.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/wine/queue.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/wine/queue.c [iso-8859-1] Fri Oct 23 15:26:18 2009 @@ -848,7 +848,7 @@ static void msg_queue_dump( struct object *obj, int verbose ) { struct msg_queue *queue = (struct msg_queue *)obj; - DPRINT1( "Msg queue bits=%x mask=%x\n", + DbgPrint( "Msg queue bits=%x mask=%x\n", queue->wake_bits, queue->wake_mask ); } @@ -920,7 +920,7 @@ static void thread_input_dump( struct object *obj, int verbose ) { struct thread_input *input = (struct thread_input *)obj; - DPRINT1( "Thread input focus=%08x capture=%08x active=%08x\n", + DbgPrint( "Thread input focus=%08x capture=%08x active=%08x\n", input->focus, input->capture, input->active ); } Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/winstation.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/wine/winstation.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/wine/winstation.c [iso-8859-1] Fri Oct 23 15:26:18 2009 @@ -122,7 +122,7 @@ { struct winstation *winstation = (struct winstation *)obj; - DPRINT1( "Winstation flags=%x clipboard=%p atoms=%p ", + DbgPrint( "Winstation flags=%x clipboard=%p atoms=%p ", winstation->flags, winstation->clipboard, winstation->atom_table ); dump_object_name( &winstation->obj ); DbgPrint( "\n" ); @@ -232,7 +232,7 @@ { struct desktop *desktop = (struct desktop *)obj; - DPRINT1( "Desktop flags=%x winstation=%p top_win=%p hooks=%p ", + DbgPrint( "Desktop flags=%x winstation=%p top_win=%p hooks=%p ", desktop->flags, desktop->winstation, desktop->top_window, desktop->global_hooks ); dump_object_name( &desktop->obj ); DbgPrint( "\n" );
15 years, 2 months
1
0
0
0
[fireball] 43698: [rtl] - Fix incorrect leap year days checking condition, spotted by Gabriel Iliardi. See issue #4917 for more details.
by fireball@svn.reactos.org
Author: fireball Date: Fri Oct 23 15:19:36 2009 New Revision: 43698 URL:
http://svn.reactos.org/svn/reactos?rev=43698&view=rev
Log: [rtl] - Fix incorrect leap year days checking condition, spotted by Gabriel Iliardi. See issue #4917 for more details. Modified: trunk/reactos/lib/rtl/time.c Modified: trunk/reactos/lib/rtl/time.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/time.c?rev=43698&r…
============================================================================== --- trunk/reactos/lib/rtl/time.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/time.c [iso-8859-1] Fri Oct 23 15:19:36 2009 @@ -192,8 +192,8 @@ TimeFields->Hour < 0 || TimeFields->Hour > 23 || TimeFields->Month < 1 || TimeFields->Month > 12 || TimeFields->Day < 1 || - TimeFields->Day > MonthLengths[TimeFields->Month == 2 || - IsLeapYear(TimeFields->Year)][TimeFields->Month - 1] || + TimeFields->Day > + MonthLengths[IsLeapYear(TimeFields->Year)][TimeFields->Month - 1] || TimeFields->Year < 1601) { return FALSE;
15 years, 2 months
1
0
0
0
[fireball] 43697: - Enable debug dump routines.
by fireball@svn.reactos.org
Author: fireball Date: Fri Oct 23 14:49:38 2009 New Revision: 43697 URL:
http://svn.reactos.org/svn/reactos?rev=43697&view=rev
Log: - Enable debug dump routines. Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/atom.c branches/arwinss/reactos/subsystems/win32/win32k/wine/object.c Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/atom.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/wine/atom.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/wine/atom.c [iso-8859-1] Fri Oct 23 14:49:38 2009 @@ -169,24 +169,23 @@ /* dump an atom table */ static void atom_table_dump( struct object *obj, int verbose ) { -#if 0 int i; struct atom_table *table = (struct atom_table *)obj; assert( obj->ops == &atom_table_ops ); - fprintf( stderr, "Atom table size=%d entries=%d\n", + DPRINT1( "Atom table size=%d entries=%d\n", table->last + 1, table->entries_count ); if (!verbose) return; for (i = 0; i <= table->last; i++) { struct atom_entry *entry = table->handles[i]; if (!entry) continue; - fprintf( stderr, " %04x: ref=%d pinned=%c hash=%d \"", + DPRINT1( " %04x: ref=%d pinned=%c hash=%d \"", entry->atom, entry->count, entry->pinned ? 'Y' : 'N', entry->hash ); - dump_strW( entry->str, entry->len / sizeof(WCHAR), stderr, "\"\""); - fprintf( stderr, "\"\n" ); - } -#endif + //dump_strW( entry->str, entry->len / sizeof(WCHAR), stderr, "\"\""); + DbgPrint("skipping dump_strW..."); + DPRINT1( "\"\n" ); + } } /* destroy the atom table */ Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/object.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/wine/object.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/wine/object.c [iso-8859-1] Fri Oct 23 14:49:38 2009 @@ -48,22 +48,20 @@ void dump_objects(void) { -#ifndef __REACTOS__ struct list *p; LIST_FOR_EACH( p, &static_object_list ) { struct object *ptr = LIST_ENTRY( p, struct object, obj_list ); - fprintf( stderr, "%p:%d: ", ptr, ptr->refcount ); + DPRINT1( "%p:%d: ", ptr, ptr->refcount ); ptr->ops->dump( ptr, 1 ); } LIST_FOR_EACH( p, &object_list ) { struct object *ptr = LIST_ENTRY( p, struct object, obj_list ); - fprintf( stderr, "%p:%d: ", ptr, ptr->refcount ); + DPRINT1( "%p:%d: ", ptr, ptr->refcount ); ptr->ops->dump( ptr, 1 ); } -#endif } void close_objects(void) @@ -224,15 +222,14 @@ /* dump the name of an object to stderr */ void dump_object_name( struct object *obj ) { -#ifndef __REACTOS__ - if (!obj->name) fprintf( stderr, "name=\"\"" ); - else - { - fprintf( stderr, "name=L\"" ); - dump_strW( obj->name->name, obj->name->len/sizeof(WCHAR), stderr, "\"\"" ); - fputc( '\"', stderr ); - } -#endif + if (!obj->name) DbgPrint( "name=\"\"" ); + else + { + DbgPrint( "name=L\"" ); + //dump_strW( obj->name->name, obj->name->len/sizeof(WCHAR), stderr, "\"\"" ); + DbgPrint("[dump_strW is missing]"); + DbgPrint( "\"" ); + } } /* unlink a named object from its namespace, without freeing the object itself */
15 years, 2 months
1
0
0
0
[fireball] 43696: - Move all CSR-interacting functions to a standalone file (csr.c) and implement them (ROS-specific, for Win2003 compatiblity they have to be at least commented out). Mainly those are needed for proper shutdown/reboot in ReactOS.
by fireball@svn.reactos.org
Author: fireball Date: Fri Oct 23 12:30:21 2009 New Revision: 43696 URL:
http://svn.reactos.org/svn/reactos?rev=43696&view=rev
Log: - Move all CSR-interacting functions to a standalone file (csr.c) and implement them (ROS-specific, for Win2003 compatiblity they have to be at least commented out). Mainly those are needed for proper shutdown/reboot in ReactOS. Added: branches/arwinss/reactos/dll/win32/user32/csr.c (with props) Modified: branches/arwinss/reactos/dll/win32/user32/misc.c branches/arwinss/reactos/dll/win32/user32/user32.rbuild branches/arwinss/reactos/dll/win32/user32/user_main.c Added: branches/arwinss/reactos/dll/win32/user32/csr.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/user3…
============================================================================== --- branches/arwinss/reactos/dll/win32/user32/csr.c (added) +++ branches/arwinss/reactos/dll/win32/user32/csr.c [iso-8859-1] Fri Oct 23 12:30:21 2009 @@ -1,0 +1,142 @@ +/* + * COPYRIGHT: GNU LGPL v2.1 or any later version as + published by the Free Software Foundation + * PROJECT: ReactOS + * FILE: dll/win32/user32/csr.c + * PURPOSE: ReactOS-specific interaction with CSR + * PROGRAMMER: Aleksey Bragin <aleksey(a)reactos.org> + */ + +/* INCLUDES ******************************************************************/ + +/* C Headers */ +#include <assert.h> +#include <stdio.h> +#include <math.h> + +/* SDK/NDK Headers */ +#define _USER32_ +#define OEMRESOURCE +#define NTOS_MODE_USER +#define WIN32_NO_STATUS +#include <windows.h> +#include <winuser.h> +#include <windowsx.h> +#include <winnls32.h> +#include <ndk/ntndk.h> +#include <ddk/ntstatus.h> + +/* CSRSS Headers */ +#include <csrss/csrss.h> + +/* FUNCTIONS ******************************************************************/ + +/*********************************************************************** + * ExitWindowsEx (USER32.@) + */ +BOOL WINAPI ExitWindowsEx( UINT uFlags, DWORD dwReason ) +{ + CSR_API_MESSAGE Request; + ULONG CsrRequest; + NTSTATUS Status; + + CsrRequest = MAKE_CSR_API(EXIT_REACTOS, CSR_GUI); + Request.Data.ExitReactosRequest.Flags = uFlags; + Request.Data.ExitReactosRequest.Reserved = dwReason; + + Status = CsrClientCallServer(&Request, + NULL, + CsrRequest, + sizeof(CSR_API_MESSAGE)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } + + return TRUE; +} + +/*********************************************************************** + * RegisterServicesProcess (USER32.@) + */ +BOOL WINAPI RegisterServicesProcess(DWORD ServicesProcessId) +{ + CSR_API_MESSAGE Request; + ULONG CsrRequest; + NTSTATUS Status; + + CsrRequest = MAKE_CSR_API(REGISTER_SERVICES_PROCESS, CSR_GUI); + Request.Data.RegisterServicesProcessRequest.ProcessId = (HANDLE)ServicesProcessId; + + Status = CsrClientCallServer(&Request, + NULL, + CsrRequest, + sizeof(CSR_API_MESSAGE)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } + + return TRUE; +} + +/*********************************************************************** + * RegisterLogonProcess (USER32.@) + */ +BOOL WINAPI RegisterLogonProcess(DWORD dwProcessId, BOOL bRegister) +{ + CSR_API_MESSAGE Request; + ULONG CsrRequest; + NTSTATUS Status; + + CsrRequest = MAKE_CSR_API(REGISTER_LOGON_PROCESS, CSR_GUI); + Request.Data.RegisterLogonProcessRequest.ProcessId = dwProcessId; + Request.Data.RegisterLogonProcessRequest.Register = bRegister; + + Status = CsrClientCallServer(&Request, + NULL, + CsrRequest, + sizeof(CSR_API_MESSAGE)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } + + return TRUE; +} + + +/*********************************************************************** + * SetLogonNotifyWindow (USER32.@) + */ +BOOL +WINAPI +SetLogonNotifyWindow (HWND Wnd, HWINSTA WinSta) +{ + /* Maybe we should call NtUserSetLogonNotifyWindow and let that one inform CSRSS??? */ + CSR_API_MESSAGE Request; + ULONG CsrRequest; + NTSTATUS Status; + + CsrRequest = MAKE_CSR_API(SET_LOGON_NOTIFY_WINDOW, CSR_GUI); + Request.Data.SetLogonNotifyWindowRequest.LogonNotifyWindow = Wnd; + + Status = CsrClientCallServer(&Request, + NULL, + CsrRequest, + sizeof(CSR_API_MESSAGE)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } + + return TRUE; +} + + + +/* EOF */ Propchange: branches/arwinss/reactos/dll/win32/user32/csr.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: branches/arwinss/reactos/dll/win32/user32/misc.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/user3…
============================================================================== --- branches/arwinss/reactos/dll/win32/user32/misc.c [iso-8859-1] (original) +++ branches/arwinss/reactos/dll/win32/user32/misc.c [iso-8859-1] Fri Oct 23 12:30:21 2009 @@ -253,24 +253,6 @@ DWORD WINAPI SetWindowStationUser(DWORD x1,DWORD x2) { FIXME("(0x%08x,0x%08x),stub!\n",x1,x2); - return 1; -} - -/*********************************************************************** - * RegisterLogonProcess (USER32.@) - */ -BOOL WINAPI RegisterLogonProcess(DWORD dwProcessId, BOOL bRegister) -{ - FIXME("(%d,%d),stub!\n",dwProcessId,bRegister); - return 1; -} - -/*********************************************************************** - * SetLogonNotifyWindow (USER32.@) - */ -DWORD WINAPI SetLogonNotifyWindow(HWINSTA hwinsta,HWND hwnd) -{ - FIXME("(%p,%p),stub!\n",hwinsta,hwnd); return 1; } Modified: branches/arwinss/reactos/dll/win32/user32/user32.rbuild URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/user3…
============================================================================== --- branches/arwinss/reactos/dll/win32/user32/user32.rbuild [iso-8859-1] (original) +++ branches/arwinss/reactos/dll/win32/user32/user32.rbuild [iso-8859-1] Fri Oct 23 12:30:21 2009 @@ -23,6 +23,7 @@ <file>class.c</file> <file>clipboard.c</file> <file>combo.c</file> + <file>csr.c</file> <file>cursoricon.c</file> <file>dde_client.c</file> <file>dde_misc.c</file> Modified: branches/arwinss/reactos/dll/win32/user32/user_main.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/user3…
============================================================================== --- branches/arwinss/reactos/dll/win32/user32/user_main.c [iso-8859-1] (original) +++ branches/arwinss/reactos/dll/win32/user32/user_main.c [iso-8859-1] Fri Oct 23 12:30:21 2009 @@ -356,45 +356,6 @@ return ret; } - -/*********************************************************************** - * ExitWindowsEx (USER32.@) - */ -BOOL WINAPI ExitWindowsEx( UINT flags, DWORD reason ) -{ - static const WCHAR winebootW[] = { '\\','w','i','n','e','b','o','o','t','.','e','x','e',0 }; - static const WCHAR killW[] = { ' ','-','-','k','i','l','l',0 }; - static const WCHAR end_sessionW[] = { ' ','-','-','e','n','d','-','s','e','s','s','i','o','n',0 }; - static const WCHAR forceW[] = { ' ','-','-','f','o','r','c','e',0 }; - static const WCHAR shutdownW[] = { ' ','-','-','s','h','u','t','d','o','w','n',0 }; - - WCHAR cmdline[MAX_PATH + 64]; - PROCESS_INFORMATION pi; - STARTUPINFOW si; - - GetSystemDirectoryW( cmdline, MAX_PATH ); - lstrcatW( cmdline, winebootW ); - - if (flags & EWX_FORCE) lstrcatW( cmdline, killW ); - else - { - lstrcatW( cmdline, end_sessionW ); - if (flags & EWX_FORCEIFHUNG) lstrcatW( cmdline, forceW ); - } - if (!(flags & EWX_REBOOT)) lstrcatW( cmdline, shutdownW ); - - memset( &si, 0, sizeof si ); - si.cb = sizeof si; - if (!CreateProcessW( NULL, cmdline, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &si, &pi )) - { - ERR( "Failed to run %s\n", debugstr_w(cmdline) ); - return FALSE; - } - CloseHandle( pi.hProcess ); - CloseHandle( pi.hThread ); - return TRUE; -} - /*********************************************************************** * LockWorkStation (USER32.@) */ @@ -405,15 +366,6 @@ return FALSE; } -/*********************************************************************** - * RegisterServicesProcess (USER32.@) - */ -int WINAPI RegisterServicesProcess(DWORD ServicesProcessId) -{ - FIXME("(0x%x): stub\n", ServicesProcessId); - return TRUE; -} - BOOL WINAPI ClientThreadSetup() {
15 years, 2 months
1
0
0
0
[spetreolle] 43694: fix build
by spetreolle@svn.reactos.org
Author: spetreolle Date: Fri Oct 23 10:25:26 2009 New Revision: 43694 URL:
http://svn.reactos.org/svn/reactos?rev=43694&view=rev
Log: fix build Modified: branches/ros-amd64-bringup/reactos/drivers/base/directory.rbuild Modified: branches/ros-amd64-bringup/reactos/drivers/base/directory.rbuild URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/drive…
============================================================================== --- branches/ros-amd64-bringup/reactos/drivers/base/directory.rbuild [iso-8859-1] (original) +++ branches/ros-amd64-bringup/reactos/drivers/base/directory.rbuild [iso-8859-1] Fri Oct 23 10:25:26 2009 @@ -11,7 +11,7 @@ <directory name="kdcom"> <xi:include href="kdcom/kdcom.rbuild" /> </directory> -</if> +</ifnot> <if property="_WINKD_" value="1"> <directory name="kddll"> <xi:include href="kddll/kddll.rbuild" />
15 years, 2 months
1
0
0
0
[cgutman] 43693: - Limit the number of interrupts that are handled per call to MiniportHandleInterrupt to prevent us from staying at DISPATCH_LEVEL for too long
by cgutman@svn.reactos.org
Author: cgutman Date: Fri Oct 23 02:27:00 2009 New Revision: 43693 URL:
http://svn.reactos.org/svn/reactos?rev=43693&view=rev
Log: - Limit the number of interrupts that are handled per call to MiniportHandleInterrupt to prevent us from staying at DISPATCH_LEVEL for too long Modified: trunk/reactos/drivers/network/dd/ne2000/include/ne2000.h trunk/reactos/drivers/network/dd/ne2000/ne2000/8390.c trunk/reactos/drivers/network/dd/pcnet/pcnet.c trunk/reactos/drivers/network/dd/pcnet/pcnet.h Modified: trunk/reactos/drivers/network/dd/ne2000/include/ne2000.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/ne2000/…
============================================================================== --- trunk/reactos/drivers/network/dd/ne2000/include/ne2000.h [iso-8859-1] (original) +++ trunk/reactos/drivers/network/dd/ne2000/include/ne2000.h [iso-8859-1] Fri Oct 23 02:27:00 2009 @@ -55,7 +55,8 @@ /* Interrupt Mask Register value */ #define DRIVER_INTERRUPT_MASK IMR_ALLE - IMR_RDCE - +/* Maximum number of interrupts handled per call to MiniportHandleInterrupt */ +#define INTERRUPT_LIMIT 10 /* Global structures */ Modified: trunk/reactos/drivers/network/dd/ne2000/ne2000/8390.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/ne2000/…
============================================================================== --- trunk/reactos/drivers/network/dd/ne2000/ne2000/8390.c [iso-8859-1] (original) +++ trunk/reactos/drivers/network/dd/ne2000/ne2000/8390.c [iso-8859-1] Fri Oct 23 02:27:00 2009 @@ -1315,6 +1315,7 @@ UCHAR ISRMask; UCHAR Mask; PNIC_ADAPTER Adapter = (PNIC_ADAPTER)MiniportAdapterContext; + UINT i = 0; ISRMask = Adapter->InterruptMask; NdisRawReadPortUchar(Adapter->IOBase + PG0_ISR, &ISRValue); @@ -1323,12 +1324,14 @@ Adapter->InterruptStatus |= (ISRValue & ISRMask); - if (ISRValue != 0x00) - /* Acknowledge interrupts */ - NdisRawWritePortUchar(Adapter->IOBase + PG0_ISR, ISRValue); - Mask = 0x01; - while (Adapter->InterruptStatus != 0x00) { + while (Adapter->InterruptStatus != 0x00 && i++ < INTERRUPT_LIMIT) { + + if (ISRValue != 0x00) { + /* Acknowledge interrupts */ + NdisRawWritePortUchar(Adapter->IOBase + PG0_ISR, ISRValue); + Mask = 0x01; + } NDIS_DbgPrint(MID_TRACE, ("Adapter->InterruptStatus (0x%X) Mask (0x%X).\n", Adapter->InterruptStatus, Mask)); @@ -1409,12 +1412,6 @@ NDIS_DbgPrint(MID_TRACE, ("ISRValue (0x%X).\n", ISRValue)); Adapter->InterruptStatus |= (ISRValue & ISRMask); - - if (ISRValue != 0x00) { - /* Acknowledge interrupts */ - NdisRawWritePortUchar(Adapter->IOBase + PG0_ISR, ISRValue); - Mask = 0x01; - } } NICEnableInterrupts((PNIC_ADAPTER)MiniportAdapterContext); Modified: trunk/reactos/drivers/network/dd/pcnet/pcnet.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/pcnet/p…
============================================================================== --- trunk/reactos/drivers/network/dd/pcnet/pcnet.c [iso-8859-1] (original) +++ trunk/reactos/drivers/network/dd/pcnet/pcnet.c [iso-8859-1] Fri Oct 23 02:27:00 2009 @@ -66,6 +66,7 @@ { PADAPTER Adapter = (PADAPTER)MiniportAdapterContext; USHORT Data; + UINT i = 0; DPRINT("Called\n"); @@ -78,7 +79,7 @@ DPRINT("CSR0 is 0x%x\n", Data); - while(Data & CSR0_INTR) + while((Data & CSR0_INTR) && i++ < INTERRUPT_LIMIT) { /* Clear interrupt flags early to avoid race conditions. */ NdisRawWritePortUshort(Adapter->PortOffset + RDP, Data); Modified: trunk/reactos/drivers/network/dd/pcnet/pcnet.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/pcnet/p…
============================================================================== --- trunk/reactos/drivers/network/dd/pcnet/pcnet.h [iso-8859-1] (original) +++ trunk/reactos/drivers/network/dd/pcnet/pcnet.h [iso-8859-1] Fri Oct 23 02:27:00 2009 @@ -149,6 +149,9 @@ /* flags */ #define RESET_IN_PROGRESS 0x1 +/* Maximum number of interrupts handled per call to MiniportHandleInterrupt */ +#define INTERRUPT_LIMIT 10 + #if DBG #define BREAKPOINT DbgBreakPoint(); #else
15 years, 2 months
1
0
0
0
[cgutman] 43692: - Move the DstAddress check above the NCE modification code so we don't use ARP requests that aren't addressed to us - Fixes bug 4879
by cgutman@svn.reactos.org
Author: cgutman Date: Thu Oct 22 21:08:02 2009 New Revision: 43692 URL:
http://svn.reactos.org/svn/reactos?rev=43692&view=rev
Log: - Move the DstAddress check above the NCE modification code so we don't use ARP requests that aren't addressed to us - Fixes bug 4879 Modified: trunk/reactos/lib/drivers/ip/network/arp.c Modified: trunk/reactos/lib/drivers/ip/network/arp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/arp…
============================================================================== --- trunk/reactos/lib/drivers/ip/network/arp.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/ip/network/arp.c [iso-8859-1] Thu Oct 22 21:08:02 2009 @@ -212,11 +212,13 @@ SenderProtoAddress = (PVOID)((ULONG_PTR)SenderHWAddress + Header->HWAddrLen); TargetProtoAddress = (PVOID)((ULONG_PTR)SenderProtoAddress + Header->ProtoAddrLen + Header->HWAddrLen); + AddrInitIPv4(&DstAddress, *((PULONG)TargetProtoAddress)); + if (!AddrIsEqual(&DstAddress, &Interface->Unicast)) + return; + + AddrInitIPv4(&SrcAddress, *((PULONG)SenderProtoAddress)); + /* Check if we know the sender */ - - AddrInitIPv4(&SrcAddress, *((PULONG)SenderProtoAddress)); - AddrInitIPv4(&DstAddress, *((PULONG)TargetProtoAddress)); - NCE = NBLocateNeighbor(&SrcAddress); if (NCE) { /* We know the sender. Update the hardware address @@ -230,8 +232,7 @@ Header->HWAddrLen, 0, ARP_TIMEOUT); } - if (Header->Opcode != ARP_OPCODE_REQUEST || - !AddrIsEqual(&DstAddress, &Interface->Unicast)) + if (Header->Opcode != ARP_OPCODE_REQUEST) return; /* This is a request for our address. Swap the addresses and
15 years, 2 months
1
0
0
0
[sginsberg] 43691: - Fix 43192 -- MAXUINT and MAXULONGLONG are only defined for Vista and later. - Add some leftover MAXULONG.
by sginsberg@svn.reactos.org
Author: sginsberg Date: Thu Oct 22 20:27:17 2009 New Revision: 43691 URL:
http://svn.reactos.org/svn/reactos?rev=43691&view=rev
Log: - Fix 43192 -- MAXUINT and MAXULONGLONG are only defined for Vista and later. - Add some leftover MAXULONG. Modified: trunk/reactos/boot/freeldr/freeldr/fs/ntfs.c trunk/reactos/dll/cpl/main/mouse.c trunk/reactos/include/psdk/basetsd.h trunk/reactos/lib/rtl/rangelist.c trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c trunk/reactos/ntoskrnl/mm/i386/pagepae.c Modified: trunk/reactos/boot/freeldr/freeldr/fs/ntfs.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/fs/nt…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/fs/ntfs.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/fs/ntfs.c [iso-8859-1] Thu Oct 22 20:27:17 2009 @@ -292,7 +292,7 @@ { CurrentOffset += DataRunLength * Volume->ClusterSize; DataRun = NtfsDecodeRun(DataRun, &DataRunOffset, &DataRunLength); - if (DataRunLength != MAXULONGLONG) + if (DataRunLength != (ULONGLONG)-1) { DataRunStartLCN = LastLCN + DataRunOffset; LastLCN = DataRunStartLCN; Modified: trunk/reactos/dll/cpl/main/mouse.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/main/mouse.c?rev=4…
============================================================================== --- trunk/reactos/dll/cpl/main/mouse.c [iso-8859-1] (original) +++ trunk/reactos/dll/cpl/main/mouse.c [iso-8859-1] Thu Oct 22 20:27:17 2009 @@ -971,7 +971,7 @@ GetSysColor(COLOR_WINDOWTEXT)); } - if (lpdis->itemID != MAXUINT) + if (lpdis->itemID != (UINT)-1) { CopyRect(&rc, &lpdis->rcItem); rc.left += 5; Modified: trunk/reactos/include/psdk/basetsd.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/basetsd.h?rev…
============================================================================== --- trunk/reactos/include/psdk/basetsd.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/basetsd.h [iso-8859-1] Thu Oct 22 20:27:17 2009 @@ -48,9 +48,12 @@ #define MAXHALF_PTR ((HALF_PTR)(MAXUHALF_PTR >> 1)) #define MINHALF_PTR (~MAXHALF_PTR) +#if _WIN32_WINNT >= 0x0600 + #define MAXUINT ((UINT)~((UINT)0)) +#define MAXULONGLONG ((ULONGLONG)~((ULONGLONG)0)) -#define MAXULONGLONG ((ULONGLONG)~((ULONGLONG)0)) +#endif #ifndef RC_INVOKED #ifdef __cplusplus Modified: trunk/reactos/lib/rtl/rangelist.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/rangelist.c?rev=43…
============================================================================== --- trunk/reactos/lib/rtl/rangelist.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/rangelist.c [iso-8859-1] Thu Oct 22 20:27:17 2009 @@ -608,11 +608,11 @@ } /* Add trailing range */ - if (Previous->Range.End + 1 != MAXULONGLONG) + if (Previous->Range.End + 1 != (ULONGLONG)-1) { Status = RtlAddRange (InvertedRangeList, Previous->Range.End + 1, - MAXULONGLONG, + (ULONGLONG)-1, 0, 0, NULL, Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.…
============================================================================== --- trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c [iso-8859-1] Thu Oct 22 20:27:17 2009 @@ -1420,7 +1420,7 @@ sizeof(ULONG)); /* Set 'UINumber' value */ - if (DeviceCapabilities.UINumber != (ULONG)-1) + if (DeviceCapabilities.UINumber != MAXULONG) { RtlInitUnicodeString(&ValueName, L"UINumber"); Status = ZwSetValueKey(InstanceKey, @@ -3078,7 +3078,7 @@ case DevicePropertyAddress: /* Query the device caps */ Status = IopQueryDeviceCapabilities(DeviceNode, &DeviceCaps); - if (NT_SUCCESS(Status) && (DeviceCaps.Address != (ULONG)-1)) + if (NT_SUCCESS(Status) && (DeviceCaps.Address != MAXULONG)) { /* Return length */ *ResultLength = sizeof(ULONG); Modified: trunk/reactos/ntoskrnl/mm/i386/pagepae.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/i386/pagepae.c…
============================================================================== --- trunk/reactos/ntoskrnl/mm/i386/pagepae.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/i386/pagepae.c [iso-8859-1] Thu Oct 22 20:27:17 2009 @@ -78,11 +78,11 @@ NTAPI MiFlushTlbIpiRoutine(ULONG_PTR Address) { - if (Address == MAXULONGLONG) + if (Address == (ULONGLONG)-1) { KeFlushCurrentTb(); } - else if (Address == MAXULONGLONG-1) + else if (Address == (ULONGLONG)-2) { KeFlushCurrentTb(); }
15 years, 2 months
1
0
0
0
[tkreuzer] 43690: revert the KD_CONTEXT change
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Thu Oct 22 17:25:37 2009 New Revision: 43690 URL:
http://svn.reactos.org/svn/reactos?rev=43690&view=rev
Log: revert the KD_CONTEXT change Modified: trunk/reactos/drivers/base/kddll/kddll.c trunk/reactos/include/reactos/windbgkd.h trunk/reactos/ntoskrnl/kd64/kdinit.c trunk/reactos/ntoskrnl/kd64/kdlock.c Modified: trunk/reactos/drivers/base/kddll/kddll.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/kddll/kddll.c…
============================================================================== --- trunk/reactos/drivers/base/kddll/kddll.c [iso-8859-1] (original) +++ trunk/reactos/drivers/base/kddll/kddll.c [iso-8859-1] Thu Oct 22 17:25:37 2009 @@ -139,7 +139,7 @@ /* Check if we got a breakin */ if (KdStatus == KDP_PACKET_RESEND) { - KdContext->BreakInRequested = TRUE; + KdContext->KdpControlCPending = TRUE; } return KdStatus; } Modified: trunk/reactos/include/reactos/windbgkd.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/windbgkd.h…
============================================================================== --- trunk/reactos/include/reactos/windbgkd.h [iso-8859-1] (original) +++ trunk/reactos/include/reactos/windbgkd.h [iso-8859-1] Thu Oct 22 17:25:37 2009 @@ -211,8 +211,8 @@ // typedef struct _KD_CONTEXT { - ULONG RetryCount; - BOOLEAN BreakInRequested; + ULONG KdpDefaultRetries; + BOOLEAN KdpControlCPending; } KD_CONTEXT, *PKD_CONTEXT; // Modified: trunk/reactos/ntoskrnl/kd64/kdinit.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd64/kdinit.c?rev…
============================================================================== --- trunk/reactos/ntoskrnl/kd64/kdinit.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/kd64/kdinit.c [iso-8859-1] Thu Oct 22 17:25:37 2009 @@ -284,7 +284,7 @@ if (!KdpDebuggerStructuresInitialized) { /* Set the Debug Switch Routine and Retries*/ - KdpContext.RetryCount = 20; + KdpContext.KdpDefaultRetries = 20; KiDebugSwitchRoutine = KdpSwitchProcessor; /* Initialize the Time Slip DPC */ Modified: trunk/reactos/ntoskrnl/kd64/kdlock.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd64/kdlock.c?rev…
============================================================================== --- trunk/reactos/ntoskrnl/kd64/kdlock.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/kd64/kdlock.c [iso-8859-1] Thu Oct 22 17:25:37 2009 @@ -40,11 +40,11 @@ if (KdDebuggerEnabled) { /* Check if a CTRL-C is in the queue */ - if (KdpContext.BreakInRequested) + if (KdpContext.KdpControlCPending) { /* Set it and prepare for break */ DoBreak = TRUE; - KdpContext.BreakInRequested = FALSE; + KdpContext.KdpControlCPending = FALSE; } else { @@ -83,12 +83,12 @@ Enable = KeDisableInterrupts(); /* Check if a CTRL-C is in the queue */ - if (KdpContext.BreakInRequested) + if (KdpContext.KdpControlCPending) { /* Set it and prepare for break */ KdpControlCPressed = TRUE; DoBreak = TRUE; - KdpContext.BreakInRequested = FALSE; + KdpContext.KdpControlCPending = FALSE; } else {
15 years, 2 months
1
0
0
0
← Newer
1
...
17
18
19
20
21
22
23
...
65
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Results per page:
10
25
50
100
200