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
September 2005
----- 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
22 participants
582 discussions
Start a n
N
ew thread
[gedmurphy] 18021: First commit, mainly testing.
by gedmurphy@svn.reactos.com
First commit, mainly testing. Cleanup code to follow ROS' coding style better Remove tabs and trailing whitespace. Modified: trunk/reactos/apps/utils/net/tracert/tracert.c Modified: trunk/reactos/apps/utils/net/tracert/tracert.h _____ Modified: trunk/reactos/apps/utils/net/tracert/tracert.c --- trunk/reactos/apps/utils/net/tracert/tracert.c 2005-09-23 21:08:57 UTC (rev 18020) +++ trunk/reactos/apps/utils/net/tracert/tracert.c 2005-09-23 21:46:54 UTC (rev 18021) @@ -1,4 +1,22 @@ -/* +/* + * ReactOS Win32 Applications + * Copyright (C) 2005 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS traceroute utility * FILE: apps/utils/net/tracert/tracert.c @@ -29,7 +47,7 @@ /* * globals */ -SOCKET icmpSock; // socket descriptor +SOCKET icmpSock; // socket descriptor SOCKADDR_IN source, dest; // source and destination address info ECHO_REPLY_HEADER sendpacket; // ICMP echo packet IPv4_HEADER recvpacket; // return reveive packet @@ -38,7 +56,7 @@ LARGE_INTEGER TicksPerMs; // number of millisecs in relation to proc freq LARGE_INTEGER TicksPerUs; // number of microsecs in relation to proc freq LONGLONG lTimeStart; // send packet, timer start -LONGLONG lTimeEnd; // receive packet, timer end +LONGLONG lTimeEnd; // receive packet, timer end CHAR cHostname[256]; // target hostname CHAR cDestIP[18]; // target IP @@ -55,7 +73,7 @@ -/* +/* * * Parse command line parameters and set any options * @@ -63,35 +81,37 @@ BOOL ParseCmdline(int argc, char* argv[]) { int i; - - if (argc < 2) + + if (argc < 2) { Usage(); return FALSE; } - for (i = 1; i < argc; i++) { - if (argv[i][0] == '-') { - switch (argv[i][1]) { - case 'd': bResolveAddresses = FALSE; + for (i = 1; i < argc; i++) + { + if (argv[i][0] == '-') + { + switch (argv[i][1]) + { + case 'd': bResolveAddresses = FALSE; break; - case 'h': sscanf(argv[i+1], "%d", &iMaxHops); + case 'h': sscanf(argv[i+1], "%d", &iMaxHops); break; - case 'l': break; /* @unimplemented@ */ - case 'w': sscanf(argv[i+1], "%d", &iTimeOut); + case 'j': break; /* @unimplemented@ */ + case 'w': sscanf(argv[i+1], "%d", &iTimeOut); break; default: _tprintf(_T("%s is not a valid option.\n"), argv[i]); Usage(); return FALSE; } - } else { + } + else /* copy target address */ strncpy(cHostname, argv[i], 255); + } - } - } - return TRUE; } @@ -100,11 +120,11 @@ /* * * Driver function, controls the traceroute program - * + * */ -INT Driver(VOID) { - - INT i; +INT Driver(VOID) +{ + INT iHopCount = 1; // hop counter. default max is 30 INT iSeqNum = 0; // initialise packet sequence number INT iTTL = 1; // set initial packet TTL to 1 @@ -115,27 +135,29 @@ INT iNameInfoRet; // getnameinfo return value INT iPacketSize = PACKET_SIZE; // packet size WORD wHeaderLen; // header length - PECHO_REPLY_HEADER icmphdr; - - + PECHO_REPLY_HEADER icmphdr; + + //temps for getting host name CHAR cHost[256]; CHAR cServ[256]; CHAR *ip; - + /* setup winsock */ WSADATA wsaData; /* check for winsock 2 */ - if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) { + if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) + { #ifdef DBG _tprintf(_T("WSAStartup failed.\n")); #endif /* DBG */ exit(1); } - + + /* establish what timing method we can use */ SetupTimingMethod(); - + /* setup target info */ ResolveHostname(); @@ -145,11 +167,16 @@ iMaxHops > 1 ? _tprintf(_T("s:\n\n")) : _tprintf(_T(":\n\n")); /* run until we hit either max hops, or we recieve 3 echo replys */ - while ((iHopCount <= iMaxHops) && (bFoundTarget != TRUE)) { + while ((iHopCount <= iMaxHops) && (bFoundTarget != TRUE)) + { + INT i; + _tprintf(_T("%3d "), iHopCount); /* run 3 pings for each hop */ - for (i=0; i<3; i++) { - if (Setup(iTTL) != TRUE) { + for (i=0; i<3; i++) + { + if (Setup(iTTL) != TRUE) + { #ifdef DBG _tprintf(_T("error in Setup()\n")); #endif /* DBG */ @@ -157,71 +184,77 @@ exit(1); } PreparePacket(iPacketSize, iSeqNum); - if (SendPacket(iPacketSize) != SOCKET_ERROR) { + if (SendPacket(iPacketSize) != SOCKET_ERROR) + { /* loop until we get a good packet */ bAwaitPacket = TRUE; - while (bAwaitPacket) { + while (bAwaitPacket) + { /* Receive replies until we either get a successful * read, or a fatal error occurs. */ - if ((iRecieveReturn = ReceivePacket(iPacketSize)) < 0) { + if ((iRecieveReturn = ReceivePacket(iPacketSize)) < 0) + { /* check the sequence number in the packet * if it's bad, complain and wait for another packet * , otherwise break */ wHeaderLen = recvpacket.h_len * 4; icmphdr = (ECHO_REPLY_HEADER *)((char*)&recvpacket + wHeaderLen); - if (icmphdr->icmpheader.seq != iSeqNum) { + if (icmphdr->icmpheader.seq != iSeqNum) + { _tprintf(_T("bad sequence number!\n")); continue; - } else { + } + else break; - } } - + /* if RecievePacket timed out we don't bother decoding */ - if (iRecieveReturn != 1) { + if (iRecieveReturn != 1) + { iDecRes = DecodeResponse(iPacketSize, iSeqNum); - - switch (iDecRes) { + + switch (iDecRes) + { case 0 : bAwaitPacket = FALSE; /* time exceeded */ break; case 1 : bAwaitPacket = FALSE; /* echo reply */ - break; + break; case 2 : bAwaitPacket = FALSE; /* destination unreachable */ - break; -#ifdef DBG + break; +#ifdef DBG case -1 : - _tprintf(_T("recieved foreign packet\n")); + _tprintf(_T("recieved foreign packet\n")); break; - case -2 : - _tprintf(_T("error in DecodeResponse\n")); + case -2 : + _tprintf(_T("error in DecodeResponse\n")); break; - case -3 : - _tprintf(_T("unknown ICMP packet\n")); + case -3 : + _tprintf(_T("unknown ICMP packet\n")); break; #endif /* DBG */ default : break; } - } else { + } + else /* packet timed out. Don't wait for it again */ bAwaitPacket = FALSE; - } - } + } } iSeqNum++; _tprintf(_T(" ")); } - if(bResolveAddresses) { - /* gethostbyaddr() and getnameinfo() are + if(bResolveAddresses) + { + /* gethostbyaddr() and getnameinfo() are * unimplemented in ROS at present. - * Alex has advised he will be implementing gethostbyaddr - * but as it's depricieted and getnameinfo is much nicer, + * Alex has advised he will be implementing getnameinfo. * I've used that for the time being for testing in Windows*/ - + //ip = inet_addr(inet_ntoa(source.sin_addr)); //host = gethostbyaddr((char *)&ip, 4, 0); - + ip = inet_ntoa(source.sin_addr); iNameInfoRet = getnameinfo((SOCKADDR *)&source, @@ -231,30 +264,34 @@ cServ, 256, NI_NUMERICSERV); - if (iNameInfoRet == 0) { + if (iNameInfoRet == 0) + { /* if IP address resolved to a hostname, - * print the IP address after it */ - if (lstrcmpA(cHost, ip) != 0) { + * print the IP address after it */ + if (lstrcmpA(cHost, ip) != 0) _tprintf(_T("%s [%s]"), cHost, ip); - } else { + else _tprintf(_T("%s"), cHost); - } - } else { - _tprintf(_T("error: %d"), WSAGetLastError()); + } + else + { + _tprintf(_T("error: %d"), WSAGetLastError()); #ifdef DBG _tprintf(_T(" getnameinfo failed: %d"), iNameInfoRet); -#endif /* DBG */ +#endif /* DBG */ } - } else { + } + else _tprintf(_T("%s"), inet_ntoa(source.sin_addr)); - } + _tprintf(_T("\n")); /* check if we've arrived at the target */ - if (strcmp(cDestIP, inet_ntoa(source.sin_addr)) == 0) { + if (strcmp(cDestIP, inet_ntoa(source.sin_addr)) == 0) bFoundTarget = TRUE; - } else { + else + { iTTL++; iHopCount++; Sleep(500); @@ -262,37 +299,39 @@ } _tprintf(_T("\nTrace complete.\n")); WSACleanup(); - + return 0; } + /* * Establish if performance counters are available and * set up timing figures in relation to processor frequency. - * If performance counters are not available, we'll be using + * If performance counters are not available, we'll be using * gettickcount, so set the figures to 1 * */ VOID SetupTimingMethod(VOID) { LARGE_INTEGER PerformanceCounterFrequency; - + /* check if performance counters are available */ bUsePerformanceCounter = QueryPerformanceFrequency(&PerformanceCounterFrequency); - if (bUsePerformanceCounter) { + if (bUsePerformanceCounter) + { /* restrict execution to first processor on SMP systems */ - if (SetThreadAffinityMask(GetCurrentThread(), 1) == 0) { + if (SetThreadAffinityMask(GetCurrentThread(), 1) == 0) bUsePerformanceCounter = FALSE; - } - + TicksPerMs.QuadPart = PerformanceCounterFrequency.QuadPart / 1000; TicksPerUs.QuadPart = PerformanceCounterFrequency.QuadPart / 1000000; } - - if (!bUsePerformanceCounter) { + + if (!bUsePerformanceCounter) + { TicksPerMs.QuadPart = 1; TicksPerUs.QuadPart = 1; - } + } } @@ -300,7 +339,7 @@ * * Check for a hostname or dotted deciamal for our target. * If we have a hostname, resolve to an IP and store it, else - * just store the target IP address. Also set up other key + * just store the target IP address. Also set up other key * SOCKADDR_IN members needed for the connection. * */ @@ -308,28 +347,34 @@ { HOSTENT *hp; ULONG addr; - + memset(&dest, 0, sizeof(dest)); addr = inet_addr(cHostname); /* if address is not a dotted decimal */ - if (addr == INADDR_NONE) { + if (addr == INADDR_NONE) + { hp = gethostbyname(cHostname); - if (hp != 0) { + if (hp != 0) + { memcpy(&dest.sin_addr, hp->h_addr, hp->h_length); //dest.sin_addr = *((struct in_addr *)hp->h_addr); dest.sin_family = hp->h_addrtype; - } else { + } + else + { _tprintf(_T("Unable to resolve target system name %s.\n"), cHostname); WSACleanup(); exit(1); } - } else { + } + else + { dest.sin_addr.s_addr = addr; dest.sin_family = AF_INET; } /* copy destination IP address into a string */ - strcpy(cDestIP, inet_ntoa(dest.sin_addr)); + strcpy(cDestIP, inet_ntoa(dest.sin_addr)); } @@ -347,23 +392,26 @@ /* create raw socket */ icmpSock = WSASocket(AF_INET, SOCK_RAW, IPPROTO_ICMP, 0, 0, 0); - if (icmpSock == INVALID_SOCKET) { + if (icmpSock == INVALID_SOCKET) + { _tprintf(_T("Could not create socket : %d.\n"), WSAGetLastError()); - if (WSAGetLastError() == WSAEACCES) { + if (WSAGetLastError() == WSAEACCES) + { _tprintf(_T("\n\nYou must be an administrator to run this program!\n\n")); WSACleanup(); exit(1); - } + } return FALSE; } - + /* setup for TTL */ iSockRet = setsockopt(icmpSock, IPPROTO_IP, IP_TTL, (const char *)&iTTL, sizeof(iTTL)); - if (iSockRet == SOCKET_ERROR) { + if (iSockRet == SOCKET_ERROR) + { _tprintf(_T("TTL setsockopt failed : %d. \n"), WSAGetLastError()); return FALSE; } - + return TRUE; } @@ -374,7 +422,7 @@ * Calculate the packet checksum * */ -VOID PreparePacket(INT iPacketSize, INT iSeqNum) +VOID PreparePacket(INT iPacketSize, INT iSeqNum) { /* assemble ICMP echo request packet */ sendpacket.icmpheader.type = ECHO_REQUEST; @@ -399,7 +447,7 @@ { INT iSockRet; INT iPacketSize; - + iPacketSize = sizeof(ECHO_REPLY_HEADER) + datasize; #ifdef DBG @@ -415,16 +463,20 @@ 0, //flags (SOCKADDR *)&dest, //destination sizeof(dest)); //address length - - if (iSockRet == SOCKET_ERROR) { - if (WSAGetLastError() == WSAEACCES) { + + if (iSockRet == SOCKET_ERROR) + { + if (WSAGetLastError() == WSAEACCES) + { _tprintf(_T("\n\nYou must be an administrator to run this program!\n\n")); exit(1); WSACleanup(); - } else { + } + else + { #ifdef DBG _tprintf(_T("sendto failed %d\n"), WSAGetLastError()); -#endif /* DBG */ +#endif /* DBG */ return FALSE; } } @@ -441,7 +493,7 @@ /* * * Set up a timeout value and put the socket in a select poll. - * Wait until we recieve an IPv4 reply packet in reply to the ICMP + * Wait until we recieve an IPv4 reply packet in reply to the ICMP * echo request packet and get the time the packet was recieved. * If we don't recieve a packet, do some checking to establish why. * @@ -456,7 +508,7 @@ /* allow for a larger recv buffer to store ICMP TTL * exceed, IP header and orginal ICMP request */ - iPacketSize = MAX_REC_SIZE + datasize; + iPacketSize = MAX_REC_SIZE + datasize; iFromLen = sizeof(source); @@ -467,14 +519,15 @@ /* monitor icmpSock for incomming connections */ FD_ZERO(&readFDS); FD_SET(icmpSock, &readFDS); - + /* set timeout values */ timeVal.tv_sec = iTimeOut / 1000; timeVal.tv_usec = iTimeOut % 1000; - + iSelRet = select(0, &readFDS, NULL, NULL, &timeVal); - - if ((iSelRet != SOCKET_ERROR) && (iSelRet != 0)) { + + if ((iSelRet != SOCKET_ERROR) && (iSelRet != 0)) + { iSockRet = recvfrom(icmpSock, //socket (char *)&recvpacket, //buffer iPacketSize, //size of buffer @@ -482,25 +535,29 @@ (SOCKADDR *)&source, //source address &iFromLen); //pointer to address length /* get time packet was recieved */ - lTimeEnd = GetTime(); - /* if socket timed out */ - } else if (iSelRet == 0) { + lTimeEnd = GetTime(); + /* if socket timed out */ + } + else if (iSelRet == 0) + { _tprintf(_T(" * ")); return 1; - } else if (iSelRet == SOCKET_ERROR) { + } + else if (iSelRet == SOCKET_ERROR) + { _tprintf(_T("select() failed in sendPacket() %d\n"), WSAGetLastError()); - return -1; + return -1; } - - if (iSockRet == SOCKET_ERROR) { + + if (iSockRet == SOCKET_ERROR) + { _tprintf(_T("recvfrom failed: %d\n"), WSAGetLastError()); return -2; } #ifdef DBG - else { - _tprintf(_T("reveived %d bytes\n"), iSockRet); - } + else + _tprintf(_T("reveived %d bytes\n"), iSockRet); #endif /* DBG */ return 0; @@ -511,7 +568,7 @@ /* * * Cast the IPv4 packet to an echo reply and to a TTL exceed. - * Check the 'type' field to establish what was recieved, and + * Check the 'type' field to establish what was recieved, and * ensure the packet is related to the originating process. * It all is well, print the time taken for the round trip. * @@ -524,14 +581,17 @@ TTL_EXCEED_HEADER *TTLExceedHdr = (TTL_EXCEED_HEADER *)((char *)&recvpacket + header_len); /* Make sure the reply is ok */ - if (iPacketSize < header_len + ICMP_MIN_SIZE) { + if (iPacketSize < header_len + ICMP_MIN_SIZE) + { _tprintf(_T("too few bytes from %s\n"), inet_ntoa(dest.sin_addr)); return -2; - } - - switch (IcmpHdr->icmpheader.type) { + } + + switch (IcmpHdr->icmpheader.type) + { case TTL_EXCEEDED : - if (TTLExceedHdr->OrigIcmpHeader.id != (USHORT)GetCurrentProcessId()) { + if (TTLExceedHdr->OrigIcmpHeader.id != (USHORT)GetCurrentProcessId()) + { /* FIXME */ /* we've picked up a packet not related to this process * probably from another local program. We ignore it */ @@ -544,7 +604,8 @@ _tprintf(_T("%3Ld ms"), (lTimeEnd - lTimeStart) / TicksPerMs.QuadPart); return 0; case ECHO_REPLY : - if (IcmpHdr->icmpheader.id != (USHORT)GetCurrentProcessId()) { + if (IcmpHdr->icmpheader.id != (USHORT)GetCurrentProcessId()) + { /* FIXME */ /* we've picked up a packet not related to this process * probably from another local program. We ignore it */ @@ -562,7 +623,7 @@ default : /* unknown ICMP packet */ return -3; - } + } } @@ -573,17 +634,21 @@ * */ -LONG GetTime(VOID) +LONG GetTime(VOID) { LARGE_INTEGER Time; - - if (bUsePerformanceCounter) { - if (QueryPerformanceCounter(&Time) == 0) { + + if (bUsePerformanceCounter) + { + if (QueryPerformanceCounter(&Time) == 0) + { Time.u.LowPart = (DWORD)GetTickCount(); Time.u.HighPart = 0; return (LONGLONG)Time.u.LowPart; - } - } else { + } + } + else + { Time.u.LowPart = (DWORD)GetTickCount(); Time.u.HighPart = 0; return (LONGLONG)Time.u.LowPart; @@ -601,7 +666,8 @@ { DWORD dwSum = 0; - while (size > 1) { + while (size > 1) + { dwSum += *data++; size -= sizeof(USHORT); } @@ -623,13 +689,13 @@ */ VOID Usage(VOID) { - _tprintf(_T("\nUsage: tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout] target_name\n\n")); - _tprintf(_T("Options:\n")); - _tprintf(_T(" -d Do not resolve addresses to hostnames.\n")); - _tprintf(_T(" -h maximum_hops Maximum number of hops to search for target.\n")); - _tprintf(_T(" -j host-list Loose source route along host-list.\n")); - _tprintf(_T(" -w timeout Wait timeout milliseconds for each reply.\n\n")); - + _tprintf(_T("\nUsage: tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout] target_name\n\n" + "Options:\n" + " -d Do not resolve addresses to hostnames.\n" + " -h maximum_hops Maximum number of hops to search for target.\n" + " -j host-list Loose source route along host-list.\n" + " -w timeout Wait timeout milliseconds for each reply.\n\n")); + /* temp notes to stop user questions until getnameinfo/gethostbyaddr and getsockopt are implemented */ _tprintf(_T("NOTES\n-----\n" "- Setting TTL values is not currently supported in ReactOS, so the trace will\n" _____ Modified: trunk/reactos/apps/utils/net/tracert/tracert.h --- trunk/reactos/apps/utils/net/tracert/tracert.h 2005-09-23 21:08:57 UTC (rev 18020) +++ trunk/reactos/apps/utils/net/tracert/tracert.h 2005-09-23 21:46:54 UTC (rev 18021) @@ -16,16 +16,17 @@ #define ICMP_MIN_SIZE 8 #define ICMP_MAX_SIZE 65535 #define PACKET_SIZE 32 -/* we need this for packets which have the 'dont fragment' - * bit set, as they can get quite large otherwise +/* we need this for packets which have the 'dont fragment' + * bit set, as they can get quite large otherwise * (I've seen some reach 182 bytes */ -#define MAX_REC_SIZE 200 +#define MAX_REC_SIZE 200 /* pack the structures */ -#pragma pack(1) +#include <pshpack1.h> /* IPv4 Header, 20 bytes */ -typedef struct IPv4Header { +typedef struct IPv4Header +{ BYTE h_len:4; BYTE version:4; BYTE tos; @@ -40,7 +41,8 @@ } IPv4_HEADER, *PIPv4_HEADER; /* ICMP Header, 8 bytes */ -typedef struct ICMPHeader { +typedef struct ICMPHeader +{ BYTE type; BYTE code; USHORT checksum; @@ -49,20 +51,22 @@ } ICMP_HEADER, *PICMP_HEADER; /* ICMP Echo Reply Header, 12 bytes */ -typedef struct EchoReplyHeader { +typedef struct EchoReplyHeader +{ struct ICMPHeader icmpheader; - struct timeval timestamp; + struct timeval timestamp; } ECHO_REPLY_HEADER, *PECHO_REPLY_HEADER; /* ICMP Echo Reply Header, 12 bytes */ -typedef struct TTLExceedHeader { +typedef struct TTLExceedHeader +{ struct ICMPHeader icmpheader; struct IPv4Header ipheader; struct ICMPHeader OrigIcmpHeader; } TTL_EXCEED_HEADER, *PTTL_EXCEED_HEADER; /* return to normal */ -#pragma pack() +#include <poppack.h> /* function definitions */
19 years, 3 months
1
0
0
0
[gvg] 18020: Fix RtlQueryAtomInAtomTable and add regression tests
by gvg@svn.reactos.com
Fix RtlQueryAtomInAtomTable and add regression tests Modified: trunk/reactos/lib/rtl/atom.c Modified: trunk/reactos/regtests/winetests/ntdll/atom.c Modified: trunk/reactos/subsys/win32k/ntuser/class.c _____ Modified: trunk/reactos/lib/rtl/atom.c --- trunk/reactos/lib/rtl/atom.c 2005-09-23 19:24:20 UTC (rev 18019) +++ trunk/reactos/lib/rtl/atom.c 2005-09-23 21:08:57 UTC (rev 18020) @@ -565,6 +565,23 @@ /* * @implemented + * + * This API is really messed up with regards to NameLength. If you pass in a + * valid buffer for AtomName, NameLength should be the size of the buffer + * (in bytes, not characters). So if you expect the string to be 6 char long, + * you need to allocate a buffer of 7 WCHARs and pass 14 for NameLength. + * The AtomName returned is always null terminated. If the NameLength you pass + * is smaller than 4 (4 would leave room for 1 character) the function will + * return with status STATUS_BUFFER_TOO_SMALL. If you pass more than 4, the + * return status will be STATUS_SUCCESS, even if the buffer is not large enough + * to hold the complete string. In that case, the string is silently truncated + * and made to fit in the provided buffer. On return NameLength is set to the + * number of bytes (but EXCLUDING the bytes for the null terminator) copied. + * So, if the string is 6 char long, you pass a buffer of 10 bytes, on return + * NameLength will be set to 8. + * If you pass in a NULL value for AtomName, the length of the string in bytes + * (again EXCLUDING the null terminator) is returned in NameLength, at least + * on Win2k, XP and ReactOS. NT4 will return 0 in that case. */ NTSTATUS STDCALL RtlQueryAtomInAtomTable(PRTL_ATOM_TABLE AtomTable, @@ -575,54 +592,35 @@ PULONG NameLength) { ULONG Length; + union + { + /* A RTL_ATOM_TABLE_ENTRY has a "WCHAR Name[1]" entry at the end. + * Make sure we reserve enough room to facilitate a 12 character name */ + RTL_ATOM_TABLE_ENTRY AtomTableEntry; + WCHAR StringBuffer[sizeof(RTL_ATOM_TABLE_ENTRY) / sizeof(WCHAR) + 12]; + } NumberEntry; PRTL_ATOM_TABLE_ENTRY Entry; NTSTATUS Status = STATUS_SUCCESS; if (Atom < 0xC000) { - if (RefCount != NULL) - { - *RefCount = 1; - } + /* Synthesize an entry */ + NumberEntry.AtomTableEntry.Atom = Atom; + NumberEntry.AtomTableEntry.NameLength = swprintf(NumberEntry.AtomTableEntry.Name, + L"#%lu", + (ULONG)Atom); + NumberEntry.AtomTableEntry.ReferenceCount = 1; + NumberEntry.AtomTableEntry.Flags = RTL_ATOM_IS_PINNED; + Entry = &NumberEntry.AtomTableEntry; + } + else + { + RtlpLockAtomTable(AtomTable); - if (PinCount != NULL) - { - *PinCount = 1; - } - - if ((AtomName != NULL) && (NameLength != NULL) && (NameLength > 0)) - { - WCHAR NameString[12]; - - Length = swprintf(NameString, L"#%lu", (ULONG)Atom) * sizeof(WCHAR); - - if (*NameLength < Length + sizeof(WCHAR)) - { - *NameLength = Length; - Status = STATUS_BUFFER_TOO_SMALL; - } - else - { - RtlCopyMemory(AtomName, - NameString, - Length); - AtomName[Length / sizeof(WCHAR)] = L'\0'; - *NameLength = Length; - } - } - else if (NameLength != NULL) - { - *NameLength = (Entry->NameLength + 1) * sizeof(WCHAR); - } - - return Status; + Entry = RtlpGetAtomEntry(AtomTable, + (ULONG)((USHORT)Atom - 0xC000)); } - RtlpLockAtomTable(AtomTable); - - Entry = RtlpGetAtomEntry(AtomTable, - (ULONG)((USHORT)Atom - 0xC000)); - if (Entry != NULL && Entry->Atom == (USHORT)Atom) { DPRINT("Atom name: %wZ\n", &Entry->Name); @@ -637,27 +635,40 @@ *PinCount = ((Entry->Flags & RTL_ATOM_IS_PINNED) != 0); } - if ((AtomName != NULL) && (NameLength != NULL)) + if (NULL != NameLength) { Length = Entry->NameLength * sizeof(WCHAR); - - if (*NameLength < Length + sizeof(WCHAR)) + if (NULL != AtomName) { - *NameLength = Length; - Status = STATUS_BUFFER_TOO_SMALL; + if (*NameLength < Length + sizeof(WCHAR)) + { + if (*NameLength < 4) + { + *NameLength = Length; + Status = STATUS_BUFFER_TOO_SMALL; + } + else + { + Length = *NameLength - sizeof(WCHAR); + } + } + if (NT_SUCCESS(Status)) + { + RtlCopyMemory(AtomName, + Entry->Name, + Length); + AtomName[Length / sizeof(WCHAR)] = L'\0'; + *NameLength = Length; + } } else { - RtlCopyMemory(AtomName, - Entry->Name, - Length); - AtomName[Length / sizeof(WCHAR)] = L'\0'; *NameLength = Length; } } - else if (NameLength != NULL) + else if (NULL != AtomName) { - *NameLength = (Entry->NameLength + 1) * sizeof(WCHAR); + Status = STATUS_INVALID_PARAMETER; } } else @@ -665,7 +676,10 @@ Status = STATUS_INVALID_HANDLE; } - RtlpUnlockAtomTable(AtomTable); + if (NULL != Entry && Entry != &NumberEntry.AtomTableEntry) + { + RtlpUnlockAtomTable(AtomTable); + } return Status; } _____ Modified: trunk/reactos/regtests/winetests/ntdll/atom.c --- trunk/reactos/regtests/winetests/ntdll/atom.c 2005-09-23 19:24:20 UTC (rev 18019) +++ trunk/reactos/regtests/winetests/ntdll/atom.c 2005-09-23 21:08:57 UTC (rev 18020) @@ -233,6 +233,19 @@ ok(res == STATUS_BUFFER_TOO_SMALL, "Got wrong retval, retval: %lx\n", res); ok((strlenW(testAtom1) * sizeof(WCHAR)) == Len, "Got wrong length %lx\n", Len); + res = pRtlQueryAtomInAtomTable(AtomTable, Atom1, NULL, NULL, NULL, &Len); + ok(!res, "Failed to retrieve atom length, retval: %lx\n", res); + ok(Len == strlenW(testAtom1) * sizeof(WCHAR), "Invalid atom length got %lu expected %u\n", + Len, strlenW(testAtom1) * sizeof(WCHAR)); + + Len = strlenW(testAtom1) * sizeof(WCHAR); + Name[strlenW(testAtom1)] = '*'; + res = pRtlQueryAtomInAtomTable(AtomTable, Atom1, NULL, NULL, Name, &Len); + ok(!res, "Failed with exactly long enough buffer, retval: %lx\n", res); + ok(Name[strlenW(testAtom1)] == '*', "Writing outside buffer\n"); + ok(0 == memcmp(Name, testAtom1, (strlenW(testAtom1) - 1) * sizeof(WCHAR)), + "We found wrong atom!!\n"); + res = pRtlPinAtomInAtomTable(AtomTable, Atom1); ok(!res, "Unable to pin atom in atom table, retval: %lx\n", res); _____ Modified: trunk/reactos/subsys/win32k/ntuser/class.c --- trunk/reactos/subsys/win32k/ntuser/class.c 2005-09-23 19:24:20 UTC (rev 18019) +++ trunk/reactos/subsys/win32k/ntuser/class.c 2005-09-23 21:08:57 UTC (rev 18020) @@ -207,10 +207,13 @@ Length = 0; Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable, - WindowObject->Class->Atom, NULL, NULL, NULL, &Length); + WindowObject->Class->Atom, NULL, NULL, + NULL, &Length); + Length += sizeof(WCHAR); Name = ExAllocatePoolWithTag(PagedPool, Length, TAG_STRING); Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable, - WindowObject->Class->Atom, NULL, NULL, Name, &Length); + WindowObject->Class->Atom, NULL, NULL, + Name, &Length); if (!NT_SUCCESS(Status)) { DPRINT("IntGetClassName: RtlQueryAtomInAtomTable failed\n");
19 years, 3 months
1
0
0
0
[weiden] 18019: imported shfolder.dll from WINE-20050830
by weiden@svn.reactos.com
imported shfolder.dll from WINE-20050830 Modified: trunk/reactos/baseaddress.xml Modified: trunk/reactos/bootdata/packages/reactos.dff Modified: trunk/reactos/lib/directory.xml Added: trunk/reactos/lib/shfolder/ Added: trunk/reactos/lib/shfolder/Makefile.in Added: trunk/reactos/lib/shfolder/shfolder.spec Added: trunk/reactos/lib/shfolder/shfolder.xml Added: trunk/reactos/lib/shfolder/shfolder_main.c Modified: trunk/reactos/media/doc/README.WINE _____ Modified: trunk/reactos/baseaddress.xml --- trunk/reactos/baseaddress.xml 2005-09-23 18:15:39 UTC (rev 18018) +++ trunk/reactos/baseaddress.xml 2005-09-23 19:24:20 UTC (rev 18019) @@ -57,6 +57,7 @@ <property name="BASEADDRESS_WAVEMAP" value="0x76610000" /> <property name="BASEADDRESS_MPR" value="0x76620000" /> <property name="BASEADDRESS_SETUPAPI" value="0x76660000" /> +<property name="BASEADDRESS_SHFOLDER" value="0x76780000" /> <property name="BASEADDRESS_NTMARTA" value="0x768A0000" /> <property name="BASEADDRESS_GDIPLUS" value="0x76a00000" /> <property name="BASEADDRESS_IMAGEHLP" value="0x76c90000" /> _____ Modified: trunk/reactos/bootdata/packages/reactos.dff --- trunk/reactos/bootdata/packages/reactos.dff 2005-09-23 18:15:39 UTC (rev 18018) +++ trunk/reactos/bootdata/packages/reactos.dff 2005-09-23 19:24:20 UTC (rev 18019) @@ -136,6 +136,7 @@ lib\setupapi\setupapi.dll 1 lib\shdocvw\shdocvw.dll 1 lib\shell32\shell32.dll 1 +lib\shfolder\shfolder.dll 1 lib\shlwapi\shlwapi.dll 1 lib\smdll\smdll.dll 1 lib\syssetup\syssetup.dll 1 _____ Modified: trunk/reactos/lib/directory.xml --- trunk/reactos/lib/directory.xml 2005-09-23 18:15:39 UTC (rev 18018) +++ trunk/reactos/lib/directory.xml 2005-09-23 19:24:20 UTC (rev 18019) @@ -224,6 +224,9 @@ <directory name="shell32"> <xi:include href="shell32/shell32.xml" /> </directory> +<directory name="shfolder"> + <xi:include href="shfolder/shfolder.xml" /> +</directory> <directory name="shlwapi"> <xi:include href="shlwapi/shlwapi.xml" /> </directory> _____ Added: trunk/reactos/lib/shfolder/Makefile.in --- trunk/reactos/lib/shfolder/Makefile.in 2005-09-23 18:15:39 UTC (rev 18018) +++ trunk/reactos/lib/shfolder/Makefile.in 2005-09-23 19:24:20 UTC (rev 18019) @@ -0,0 +1,13 @@ +TOPSRCDIR = @top_srcdir@ +TOPOBJDIR = ../.. +SRCDIR = @srcdir@ +VPATH = @srcdir@ +MODULE = shfolder.dll +IMPORTLIB = libshfolder.$(IMPLIBEXT) +IMPORTS = shell32 kernel32 + +C_SRCS = shfolder_main.c + +@MAKE_DLL_RULES@ + +### Dependencies: Property changes on: trunk/reactos/lib/shfolder/Makefile.in ___________________________________________________________________ Name: svn:eol-style + native _____ Added: trunk/reactos/lib/shfolder/shfolder.spec --- trunk/reactos/lib/shfolder/shfolder.spec 2005-09-23 18:15:39 UTC (rev 18018) +++ trunk/reactos/lib/shfolder/shfolder.spec 2005-09-23 19:24:20 UTC (rev 18019) @@ -0,0 +1,2 @@ +@ stdcall SHGetFolderPathA(long long long long ptr) shell32.SHGetFolderPathA +@ stdcall SHGetFolderPathW(long long long long ptr) shell32.SHGetFolderPathW Property changes on: trunk/reactos/lib/shfolder/shfolder.spec ___________________________________________________________________ Name: svn:eol-style + native _____ Added: trunk/reactos/lib/shfolder/shfolder.xml --- trunk/reactos/lib/shfolder/shfolder.xml 2005-09-23 18:15:39 UTC (rev 18018) +++ trunk/reactos/lib/shfolder/shfolder.xml 2005-09-23 19:24:20 UTC (rev 18019) @@ -0,0 +1,10 @@ +<module name="shfolder" type="win32dll" baseaddress="${BASEADDRESS_SHFOLDER}" installbase="system32" installname="shfolder.dll"> + <importlibrary definition="shfolder.spec.def" /> + <include base="shfolder">.</include> + <include base="shfolder">include</include> + <define name="__REACTOS__" /> + <define name="__USE_W32API" /> + <library>shell32</library> + <file>shfolder_main.c</file> + <file>shfolder.spec</file> +</module> Property changes on: trunk/reactos/lib/shfolder/shfolder.xml ___________________________________________________________________ Name: svn:eol-style + native _____ Added: trunk/reactos/lib/shfolder/shfolder_main.c --- trunk/reactos/lib/shfolder/shfolder_main.c 2005-09-23 18:15:39 UTC (rev 18018) +++ trunk/reactos/lib/shfolder/shfolder_main.c 2005-09-23 19:24:20 UTC (rev 18019) @@ -0,0 +1 @@ +/* nothing here yet */ Property changes on: trunk/reactos/lib/shfolder/shfolder_main.c ___________________________________________________________________ Name: svn:keywords + author date id revision Name: svn:eol-style + native _____ Modified: trunk/reactos/media/doc/README.WINE --- trunk/reactos/media/doc/README.WINE 2005-09-23 18:15:39 UTC (rev 18018) +++ trunk/reactos/media/doc/README.WINE 2005-09-23 19:24:20 UTC (rev 18019) @@ -64,6 +64,7 @@ reactos/lib/setupapi # Forked at Wine-20050524 reactos/lib/shell32 # Synced to Wine-20050830 reactos/lib/shdocvw # Synced to Wine-20050830 +reactos/lib/shfolder # Synced to Wine-20050830 reactos/lib/shlwapi # Synced to Wine-20050830 reactos/lib/twain # Out of sync reactos/lib/urlmon # Synced to Wine-20050830
19 years, 3 months
1
0
0
0
[ion] 18018: fix identation bug in 18016
by ion@svn.reactos.com
fix identation bug in 18016 Modified: trunk/reactos/subsys/system/notepad/main.c _____ Modified: trunk/reactos/subsys/system/notepad/main.c --- trunk/reactos/subsys/system/notepad/main.c 2005-09-23 16:31:06 UTC (rev 18017) +++ trunk/reactos/subsys/system/notepad/main.c 2005-09-23 18:15:39 UTC (rev 18018) @@ -376,12 +376,12 @@ while (GetMessage(&msg, 0, 0, 0)) { - if (!IsDialogMessage(Globals.hFindReplaceDlg, &msg) && - !TranslateAccelerator(Globals.hMainWnd, hAccel, &msg)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); + if (!IsDialogMessage(Globals.hFindReplaceDlg, &msg) && + !TranslateAccelerator(Globals.hMainWnd, hAccel, &msg)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } } - } return msg.wParam; }
19 years, 3 months
1
0
0
0
[ion] 18017: Fix signalstate check in KGATE code; spotted by magey.
by ion@svn.reactos.com
Fix signalstate check in KGATE code; spotted by magey. Modified: trunk/reactos/ntoskrnl/ke/gate.c _____ Modified: trunk/reactos/ntoskrnl/ke/gate.c --- trunk/reactos/ntoskrnl/ke/gate.c 2005-09-23 15:46:10 UTC (rev 18016) +++ trunk/reactos/ntoskrnl/ke/gate.c 2005-09-23 16:31:06 UTC (rev 18017) @@ -47,7 +47,7 @@ OldIrql = KeAcquireDispatcherDatabaseLock(); /* Check if it's already signaled */ - if (!Gate->Header.SignalState) + if (Gate->Header.SignalState) { /* Unsignal it */ Gate->Header.SignalState = 0;
19 years, 3 months
1
0
0
0
[ion] 18016: - Call IsDialogMessage before TranslateAccelerators, so that the accelerator's output, if any, appears in the proper window. Patch by Bletch <npwoods@mess.org>. Fixes bug 803.
by ion@svn.reactos.com
- Call IsDialogMessage before TranslateAccelerators, so that the accelerator's output, if any, appears in the proper window. Patch by Bletch <npwoods(a)mess.org>. Fixes bug 803. Modified: trunk/reactos/subsys/system/notepad/main.c _____ Modified: trunk/reactos/subsys/system/notepad/main.c --- trunk/reactos/subsys/system/notepad/main.c 2005-09-23 15:42:40 UTC (rev 18015) +++ trunk/reactos/subsys/system/notepad/main.c 2005-09-23 15:46:10 UTC (rev 18016) @@ -376,11 +376,12 @@ while (GetMessage(&msg, 0, 0, 0)) { - if (!TranslateAccelerator(Globals.hMainWnd, hAccel, &msg) && !IsDialogMessage(Globals.hFindReplaceDlg, &msg)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } + if (!IsDialogMessage(Globals.hFindReplaceDlg, &msg) && + !TranslateAccelerator(Globals.hMainWnd, hAccel, &msg)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); } + } return msg.wParam; }
19 years, 3 months
1
0
0
0
[ion] 18015: - Return focus to run dialog after showing the file not found messagebox. Patch by brbak <mpd000@yahoo.de>
by ion@svn.reactos.com
- Return focus to run dialog after showing the file not found messagebox. Patch by brbak <mpd000(a)yahoo.de> Modified: trunk/reactos/lib/shell32/dialogs.c _____ Modified: trunk/reactos/lib/shell32/dialogs.c --- trunk/reactos/lib/shell32/dialogs.c 2005-09-23 15:31:42 UTC (rev 18014) +++ trunk/reactos/lib/shell32/dialogs.c 2005-09-23 15:42:40 UTC (rev 18015) @@ -162,6 +162,7 @@ HeapFree(GetProcessHeap(), 0, psz); SendMessageA (htxt, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ; + SetFocus(htxt); return TRUE ; } FillList (htxt, psz) ; @@ -217,15 +218,19 @@ return TRUE ; } - ofnProc (&ofn) ; + if(ofnProc (&ofn)) + { + SetFocus (GetDlgItem (hwnd, IDOK)) ; + SetWindowTextA (GetDlgItem (hwnd, 12298), szFName) ; + SendMessageA (GetDlgItem (hwnd, 12298), CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ; + SetFocus (GetDlgItem (hwnd, IDOK)) ; + } + else + { + SetFocus(GetDlgItem(hwnd, 12288)); + } - SetFocus (GetDlgItem (hwnd, IDOK)) ; - SetWindowTextA (GetDlgItem (hwnd, 12298), szFName) ; - SendMessageA (GetDlgItem (hwnd, 12298), CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ; - SetFocus (GetDlgItem (hwnd, IDOK)) ; - FreeLibrary (hComdlg) ; - return TRUE ; } }
19 years, 3 months
1
0
0
0
[weiden] 18014: use RegGetKeySecurity() directly to read the security information
by weiden@svn.reactos.com
use RegGetKeySecurity() directly to read the security information Modified: trunk/reactos/subsys/system/regedit/security.c Modified: trunk/reactos/subsys/system/regedit/security.h _____ Modified: trunk/reactos/subsys/system/regedit/security.c --- trunk/reactos/subsys/system/regedit/security.c 2005-09-23 15:31:04 UTC (rev 18013) +++ trunk/reactos/subsys/system/regedit/security.c 2005-09-23 15:31:42 UTC (rev 18014) @@ -86,7 +86,7 @@ }; -LPREGKEYSECURITY CRegKeySecurity_fnConstructor(HANDLE Handle, SE_OBJECT_TYPE ObjectType, SI_OBJECT_INFO *ObjectInfo, BOOL *Btn) +static LPREGKEYSECURITY CRegKeySecurity_fnConstructor(HANDLE Handle, SI_OBJECT_INFO *ObjectInfo, BOOL *Btn) { LPREGKEYSECURITY obj; @@ -96,7 +96,6 @@ obj->ref = 1; obj->lpVtbl = &efvt; obj->Handle = Handle; - obj->ObjectType = ObjectType; obj->ObjectInfo = *ObjectInfo; obj->Btn = Btn; } @@ -153,11 +152,32 @@ PSECURITY_DESCRIPTOR* ppSecurityDescriptor, BOOL fDefault) { - /* FIXME */ - if(GetSecurityInfo(this->Handle, this->ObjectType, RequestedInformation, 0, 0, - 0, 0, ppSecurityDescriptor) == ERROR_SUCCESS) + DWORD DescriptorSize = 0; + PSECURITY_DESCRIPTOR SecurityDescriptor; + LONG ErrorCode; + + /* find out how much memory we need to allocate */ + ErrorCode = RegGetKeySecurity(this->Handle, RequestedInformation, NULL, &DescriptorSize); + if(ErrorCode == ERROR_INSUFFICIENT_BUFFER) { - return S_OK; + SecurityDescriptor = (PSECURITY_DESCRIPTOR)LocalAlloc(LMEM_FIXED, DescriptorSize); + if (SecurityDescriptor != NULL) + { + if (RegGetKeySecurity(this->Handle, RequestedInformation, SecurityDescriptor, &DescriptorSize) == ERROR_SUCCESS) + { + *ppSecurityDescriptor = SecurityDescriptor; + return S_OK; + } + else + { + LocalFree((HLOCAL)SecurityDescriptor); + return E_ACCESSDENIED; + } + } + else + { + return E_OUTOFMEMORY; + } } else { @@ -345,7 +365,7 @@ ObjectInfo.pszObjectName = KeyName; ObjectInfo.pszPageTitle = KeyName; - if(!(RegKeySecurity = CRegKeySecurity_fnConstructor(hInfoKey, SE_REGISTRY_KEY, &ObjectInfo, &Result))) + if(!(RegKeySecurity = CRegKeySecurity_fnConstructor(hInfoKey, &ObjectInfo, &Result))) { /* FIXME - print error with FormatMessage */ return FALSE; _____ Modified: trunk/reactos/subsys/system/regedit/security.h --- trunk/reactos/subsys/system/regedit/security.h 2005-09-23 15:31:04 UTC (rev 18013) +++ trunk/reactos/subsys/system/regedit/security.h 2005-09-23 15:31:42 UTC (rev 18014) @@ -7,17 +7,6 @@ VOID UnloadAclUiDll(VOID); -/* FIXME - remove the definition */ -DWORD STDCALL -GetSecurityInfo(HANDLE handle, - SE_OBJECT_TYPE ObjectType, - SECURITY_INFORMATION SecurityInfo, - PSID* ppsidOwner, - PSID* ppsidGroup, - PACL* ppDacl, - PACL* ppSacl, - PSECURITY_DESCRIPTOR* ppSecurityDescriptor); - DEFINE_GUID(IID_CRegKeySecurity, 0x965fc360, 0x16ff, 0x11d0, 0x0091, 0xcb,0x00,0xaa,0x00,0xbb,0xb7,0x23); /*********************************************************************** ******* @@ -72,7 +61,6 @@ DWORD ref; /* CRegKeySecurity fields */ HANDLE Handle; - SE_OBJECT_TYPE ObjectType; SI_OBJECT_INFO ObjectInfo; BOOL *Btn; } REGKEYSECURITY;
19 years, 3 months
1
0
0
0
[weiden] 18013: don't read the DACL if it's not present or if it's a NULL-DACL
by weiden@svn.reactos.com
don't read the DACL if it's not present or if it's a NULL-DACL Modified: trunk/reactos/lib/aclui/aclui.c _____ Modified: trunk/reactos/lib/aclui/aclui.c --- trunk/reactos/lib/aclui/aclui.c 2005-09-23 14:15:30 UTC (rev 18012) +++ trunk/reactos/lib/aclui/aclui.c 2005-09-23 15:31:04 UTC (rev 18013) @@ -330,7 +330,8 @@ if (GetSecurityDescriptorDacl(SecurityDescriptor, &DaclPresent, &Dacl, - &DaclDefaulted)) + &DaclDefaulted) && + DaclPresent && Dacl != NULL) { PSID Sid; PVOID Ace; @@ -978,10 +979,10 @@ (DWORD_PTR)sp); sp->hiPrincipals = ImageList_LoadBitmap(hDllInstance, - MAKEINTRESOURCE(IDB_USRGRPIMAGES), - 16, - 3, - 0); + MAKEINTRESOURCE(IDB_USRGRPIMAGES), + 16, + 3, + 0); /* setup the listview control */ ListView_SetExtendedListViewStyleEx(sp->hWndPrincipalsList,
19 years, 3 months
1
0
0
0
[weiden] 18012: - fixed buffer size calculation in RtlLengthRequiredSid and RtlLengthSid
by weiden@svn.reactos.com
- fixed buffer size calculation in RtlLengthRequiredSid and RtlLengthSid - use RtlCreateUnicodeString to allocate the string in RtlConvertSidToUnicodeString Modified: trunk/reactos/lib/rtl/sid.c _____ Modified: trunk/reactos/lib/rtl/sid.c --- trunk/reactos/lib/rtl/sid.c 2005-09-23 14:13:44 UTC (rev 18011) +++ trunk/reactos/lib/rtl/sid.c 2005-09-23 14:15:30 UTC (rev 18012) @@ -42,7 +42,8 @@ { PAGED_CODE_RTL(); - return (sizeof(SID) + (SubAuthorityCount - 1) * sizeof(ULONG)); + return (sizeof(SID) - (ANYSIZE_ARRAY * sizeof(ULONG)) + + (SubAuthorityCount * sizeof(ULONG))); } @@ -106,22 +107,18 @@ { PISID Sid1 = Sid1_; PISID Sid2 = Sid2_; + SIZE_T SidLen; PAGED_CODE_RTL(); - if (Sid1->Revision != Sid2->Revision) + if (Sid1->Revision != Sid2->Revision || + (*RtlSubAuthorityCountSid(Sid1)) != (*RtlSubAuthorityCountSid(Sid2))) { return(FALSE); } - if ((*RtlSubAuthorityCountSid(Sid1)) != (*RtlSubAuthorityCountSid(Sid2))) - { - return(FALSE); - } - if (RtlCompareMemory(Sid1, Sid2, RtlLengthSid(Sid1)) != RtlLengthSid(Sid1)) - { - return(FALSE); - } - return(TRUE); + + SidLen = RtlLengthSid(Sid1); + return RtlCompareMemory(Sid1, Sid2, SidLen) == SidLen; } @@ -135,7 +132,8 @@ PAGED_CODE_RTL(); - return (sizeof(SID) + (Sid->SubAuthorityCount-1) * sizeof(ULONG)); + return (sizeof(SID) - sizeof(Sid->SubAuthority) + + (Sid->SubAuthorityCount * sizeof(ULONG))); } @@ -243,7 +241,7 @@ if (Sid == NULL) return STATUS_INVALID_PARAMETER; - pSid = RtlpAllocateMemory(sizeof(SID) + (SubAuthorityCount - 1) * sizeof(ULONG), + pSid = RtlpAllocateMemory(RtlLengthRequiredSid(SubAuthorityCount), TAG_SID); if (pSid == NULL) return STATUS_NO_MEMORY; @@ -338,7 +336,7 @@ wcs = Buffer; wcs += swprintf (wcs, L"S-%u-", Sid->Revision); if (Sid->IdentifierAuthority.Value[0] == 0 && - Sid->IdentifierAuthority.Value[1] == 0) + Sid->IdentifierAuthority.Value[1] == 0) { wcs += swprintf (wcs, L"%lu", @@ -366,28 +364,29 @@ Sid->SubAuthority[i]); } - Length = (wcs - Buffer) * sizeof(WCHAR); if (AllocateBuffer) { - String->Buffer = RtlpAllocateMemory(Length + sizeof(WCHAR), - TAG_SID); - if (String->Buffer == NULL) + if (!RtlCreateUnicodeString(String, + Buffer)) + { return STATUS_NO_MEMORY; - String->MaximumLength = Length + sizeof(WCHAR); + } } else { + Length = (wcs - Buffer) * sizeof(WCHAR); + if (Length > String->MaximumLength) return STATUS_BUFFER_TOO_SMALL; - } - String->Length = Length; - RtlCopyMemory (String->Buffer, - Buffer, - Length); - if (Length < String->MaximumLength) - String->Buffer[Length / sizeof(WCHAR)] = 0; - + String->Length = Length; + RtlCopyMemory (String->Buffer, + Buffer, + Length); + if (Length < String->MaximumLength) + String->Buffer[Length / sizeof(WCHAR)] = 0; + } + return STATUS_SUCCESS; }
19 years, 3 months
1
0
0
0
← Newer
1
...
14
15
16
17
18
19
20
...
59
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
Results per page:
10
25
50
100
200