diff --git a/reactos/lib/iphlpapi/ifenum_reactos.c b/reactos/lib/iphlpapi/ifenum_reactos.c index d58c0ebc905..1aba52674d3 100644 --- a/reactos/lib/iphlpapi/ifenum_reactos.c +++ b/reactos/lib/iphlpapi/ifenum_reactos.c @@ -71,22 +71,22 @@ NTSTATUS openTcpFile(PHANDLE tcpFile) { RtlInitUnicodeString( &fileName, TcpFileName ); InitializeObjectAttributes( &objectAttributes, - &fileName, - OBJ_CASE_INSENSITIVE, - NULL, - NULL ); + &fileName, + OBJ_CASE_INSENSITIVE, + NULL, + NULL ); status = NtCreateFile( tcpFile, - SYNCHRONIZE | GENERIC_EXECUTE, - &objectAttributes, - &ioStatusBlock, - NULL, - FILE_ATTRIBUTE_NORMAL, - FILE_SHARE_READ | FILE_SHARE_WRITE, - FILE_OPEN_IF, - FILE_SYNCHRONOUS_IO_NONALERT, - 0, - 0 ); + SYNCHRONIZE | GENERIC_EXECUTE, + &objectAttributes, + &ioStatusBlock, + NULL, + FILE_ATTRIBUTE_NORMAL, + FILE_SHARE_READ | FILE_SHARE_WRITE, + FILE_OPEN_IF, + FILE_SYNCHRONOUS_IO_NONALERT, + 0, + 0 ); /* String does not need to be freed: it points to the constant * string we provided */ @@ -114,29 +114,29 @@ void closeTcpFile( HANDLE h ) { * IPInterfaceInfo */ NTSTATUS tdiGetSetOfThings( HANDLE tcpFile, - DWORD toiClass, - DWORD toiType, - DWORD toiId, - DWORD teiEntity, - DWORD fixedPart, - DWORD entrySize, - PVOID *tdiEntitySet, - PDWORD numEntries ) { + DWORD toiClass, + DWORD toiType, + DWORD toiId, + DWORD teiEntity, + DWORD fixedPart, + DWORD entrySize, + PVOID *tdiEntitySet, + PDWORD numEntries ) { TCP_REQUEST_QUERY_INFORMATION_EX req = TCP_REQUEST_QUERY_INFORMATION_INIT; PVOID entitySet = 0; NTSTATUS status = STATUS_SUCCESS; DWORD allocationSizeForEntityArray = entrySize * MAX_TDI_ENTITIES, - arraySize = entrySize * MAX_TDI_ENTITIES; + arraySize = entrySize * MAX_TDI_ENTITIES; DPRINT("TdiGetSetOfThings(tcpFile %x,toiClass %x,toiType %x,toiId %x," - "teiEntity %x,fixedPart %d,entrySize %d)\n", - (int)tcpFile, - (int)toiClass, - (int)toiType, - (int)toiId, - (int)teiEntity, - (int)fixedPart, - (int)entrySize ); + "teiEntity %x,fixedPart %d,entrySize %d)\n", + (int)tcpFile, + (int)toiClass, + (int)toiType, + (int)toiId, + (int)teiEntity, + (int)fixedPart, + (int)entrySize ); req.ID.toi_class = toiClass; req.ID.toi_type = toiType; @@ -152,61 +152,61 @@ NTSTATUS tdiGetSetOfThings( HANDLE tcpFile, * stabilizes. */ do { - assert( !entitySet ); /* We must not have an entity set allocated */ - status = DeviceIoControl( tcpFile, - IOCTL_TCP_QUERY_INFORMATION_EX, - &req, - sizeof(req), - 0, - 0, - &allocationSizeForEntityArray, - NULL ); - - if( !NT_SUCCESS(status) ) { - DPRINT("TdiGetSetOfThings() => %08x\n", (int)status); - return status; - } - - arraySize = allocationSizeForEntityArray; - entitySet = HeapAlloc( GetProcessHeap(), 0, arraySize ); - - if( !entitySet ) { - status = STATUS_INSUFFICIENT_RESOURCES; - DPRINT("TdiGetSetOfThings() => %08x\n", (int)status); - return status; - } + assert( !entitySet ); /* We must not have an entity set allocated */ + status = DeviceIoControl( tcpFile, + IOCTL_TCP_QUERY_INFORMATION_EX, + &req, + sizeof(req), + 0, + 0, + &allocationSizeForEntityArray, + NULL ); + + if( !NT_SUCCESS(status) ) { + DPRINT("TdiGetSetOfThings() => %08x\n", (int)status); + return status; + } + + arraySize = allocationSizeForEntityArray; + entitySet = HeapAlloc( GetProcessHeap(), 0, arraySize ); + + if( !entitySet ) { + status = STATUS_INSUFFICIENT_RESOURCES; + DPRINT("TdiGetSetOfThings() => %08x\n", (int)status); + return status; + } - status = DeviceIoControl( tcpFile, - IOCTL_TCP_QUERY_INFORMATION_EX, - &req, - sizeof(req), - entitySet, - arraySize, - &allocationSizeForEntityArray, - NULL ); - - /* This is why we have the loop -- we might have added an adapter */ - if( arraySize == allocationSizeForEntityArray ) - break; + status = DeviceIoControl( tcpFile, + IOCTL_TCP_QUERY_INFORMATION_EX, + &req, + sizeof(req), + entitySet, + arraySize, + &allocationSizeForEntityArray, + NULL ); + + /* This is why we have the loop -- we might have added an adapter */ + if( arraySize == allocationSizeForEntityArray ) + break; - HeapFree( GetProcessHeap(), 0, entitySet ); - entitySet = 0; + HeapFree( GetProcessHeap(), 0, entitySet ); + entitySet = 0; - if( !NT_SUCCESS(status) ) { - DPRINT("TdiGetSetOfThings() => %08x\n", (int)status); - return status; - } + if( !NT_SUCCESS(status) ) { + DPRINT("TdiGetSetOfThings() => %08x\n", (int)status); + return status; + } - DPRINT("TdiGetSetOfThings(): Array changed size: %d -> %d.\n", - arraySize, allocationSizeForEntityArray ); + DPRINT("TdiGetSetOfThings(): Array changed size: %d -> %d.\n", + arraySize, allocationSizeForEntityArray ); } while( TRUE ); /* We break if the array we received was the size we - * expected. Therefore, we got here because it wasn't */ + * expected. Therefore, we got here because it wasn't */ *numEntries = (arraySize - fixedPart) / entrySize; *tdiEntitySet = entitySet; DPRINT("TdiGetSetOfThings() => Success: %d things @ %08x\n", - (int)*numEntries, (int)entitySet); + (int)*numEntries, (int)entitySet); return STATUS_SUCCESS; } @@ -222,7 +222,7 @@ NTSTATUS tdiGetMibForIfEntity DWORD returnSize; DPRINT("TdiGetMibForIfEntity(tcpFile %x,entityId %x)\n", - (int)tcpFile, (int)ent->tei_instance); + (int)tcpFile, (int)ent->tei_instance); req.ID.toi_class = INFO_CLASS_PROTOCOL; req.ID.toi_type = INFO_TYPE_PROVIDER; @@ -230,65 +230,65 @@ NTSTATUS tdiGetMibForIfEntity req.ID.toi_entity = *ent; status = DeviceIoControl( tcpFile, - IOCTL_TCP_QUERY_INFORMATION_EX, - &req, - sizeof(req), - entry, - sizeof(*entry), - &returnSize, - NULL ); + IOCTL_TCP_QUERY_INFORMATION_EX, + &req, + sizeof(req), + entry, + sizeof(*entry), + &returnSize, + NULL ); if( !NT_SUCCESS(status) ) { - TRACE("failure: %08x\n", status); - return status; + TRACE("failure: %08x\n", status); + return status; } else TRACE("Success.\n"); DPRINT("TdiGetMibForIfEntity() => {\n" - " if_index ....................... %x\n" - " if_type ........................ %x\n" - " if_mtu ......................... %d\n" - " if_speed ....................... %x\n" - " if_physaddrlen ................. %d\n", - entry->ent.if_index, - entry->ent.if_type, - entry->ent.if_mtu, - entry->ent.if_speed, - entry->ent.if_physaddrlen); + " if_index ....................... %x\n" + " if_type ........................ %x\n" + " if_mtu ......................... %d\n" + " if_speed ....................... %x\n" + " if_physaddrlen ................. %d\n", + entry->ent.if_index, + entry->ent.if_type, + entry->ent.if_mtu, + entry->ent.if_speed, + entry->ent.if_physaddrlen); DPRINT(" if_physaddr .................... %02x:%02x:%02x:%02x:%02x:%02x\n", - " if_descr ....................... %s\n", - entry->ent.if_physaddr[0] & 0xff, - entry->ent.if_physaddr[1] & 0xff, - entry->ent.if_physaddr[2] & 0xff, - entry->ent.if_physaddr[3] & 0xff, - entry->ent.if_physaddr[4] & 0xff, - entry->ent.if_physaddr[5] & 0xff, - entry->ent.if_descr); + " if_descr ....................... %s\n", + entry->ent.if_physaddr[0] & 0xff, + entry->ent.if_physaddr[1] & 0xff, + entry->ent.if_physaddr[2] & 0xff, + entry->ent.if_physaddr[3] & 0xff, + entry->ent.if_physaddr[4] & 0xff, + entry->ent.if_physaddr[5] & 0xff, + entry->ent.if_descr); DPRINT("} status %08x\n",status); - + return status; } NTSTATUS tdiGetEntityIDSet( HANDLE tcpFile, - TDIEntityID **entitySet, - PDWORD numEntities ) { + TDIEntityID **entitySet, + PDWORD numEntities ) { NTSTATUS status = tdiGetSetOfThings( tcpFile, - INFO_CLASS_GENERIC, - INFO_TYPE_PROVIDER, - ENTITY_LIST_ID, - GENERIC_ENTITY, - 0, - sizeof(TDIEntityID), - (PVOID *)entitySet, - numEntities ); + INFO_CLASS_GENERIC, + INFO_TYPE_PROVIDER, + ENTITY_LIST_ID, + GENERIC_ENTITY, + 0, + sizeof(TDIEntityID), + (PVOID *)entitySet, + numEntities ); if( NT_SUCCESS(status) ) { - int i; + int i; - for( i = 0; i < *numEntities; i++ ) { - DPRINT("%-4d: %04x:%08x\n", - i, - (*entitySet)[i].tei_entity, - (*entitySet)[i].tei_instance ); - } + for( i = 0; i < *numEntities; i++ ) { + DPRINT("%-4d: %04x:%08x\n", + i, + (*entitySet)[i].tei_entity, + (*entitySet)[i].tei_instance ); + } } return status; @@ -296,18 +296,18 @@ NTSTATUS tdiGetEntityIDSet( HANDLE tcpFile, static BOOL isInterface( TDIEntityID *if_maybe ) { return - if_maybe->tei_entity == IF_ENTITY; + if_maybe->tei_entity == IF_ENTITY; } static BOOL isLoopback( HANDLE tcpFile, TDIEntityID *loop_maybe ) { IFEntrySafelySized entryInfo; tdiGetMibForIfEntity( tcpFile, - loop_maybe, - &entryInfo ); + loop_maybe, + &entryInfo ); return !entryInfo.ent.if_type || - entryInfo.ent.if_type == IFENT_SOFTWARE_LOOPBACK; + entryInfo.ent.if_type == IFENT_SOFTWARE_LOOPBACK; } NTSTATUS tdiGetEntityType( HANDLE tcpFile, TDIEntityID *ent, PULONG type ) { @@ -316,7 +316,7 @@ NTSTATUS tdiGetEntityType( HANDLE tcpFile, TDIEntityID *ent, PULONG type ) { DWORD returnSize; DPRINT("TdiGetEntityType(tcpFile %x,entityId %x)\n", - (DWORD)tcpFile, ent->tei_instance); + (DWORD)tcpFile, ent->tei_instance); req.ID.toi_class = INFO_CLASS_GENERIC; req.ID.toi_type = INFO_TYPE_PROVIDER; @@ -325,13 +325,13 @@ NTSTATUS tdiGetEntityType( HANDLE tcpFile, TDIEntityID *ent, PULONG type ) { req.ID.toi_entity.tei_instance = ent->tei_instance; status = DeviceIoControl( tcpFile, - IOCTL_TCP_QUERY_INFORMATION_EX, - &req, - sizeof(req), - type, - sizeof(*type), - &returnSize, - NULL ); + IOCTL_TCP_QUERY_INFORMATION_EX, + &req, + sizeof(req), + type, + sizeof(*type), + &returnSize, + NULL ); DPRINT("TdiGetEntityType() => %08x %08x\n", *type, status); @@ -339,8 +339,8 @@ NTSTATUS tdiGetEntityType( HANDLE tcpFile, TDIEntityID *ent, PULONG type ) { } static NTSTATUS getInterfaceInfoSet( HANDLE tcpFile, - IFInfo **infoSet, - PDWORD numInterfaces ) { + IFInfo **infoSet, + PDWORD numInterfaces ) { DWORD numEntities; TDIEntityID *entIDSet = 0; NTSTATUS status = tdiGetEntityIDSet( tcpFile, &entIDSet, &numEntities ); @@ -349,44 +349,44 @@ static NTSTATUS getInterfaceInfoSet( HANDLE tcpFile, int curInterf = 0, i; if( NT_SUCCESS(status) ) - infoSetInt = HeapAlloc( GetProcessHeap(), 0, - sizeof(IFInfo) * numEntities ); + infoSetInt = HeapAlloc( GetProcessHeap(), 0, + sizeof(IFInfo) * numEntities ); if( infoSetInt ) { - for( i = 0; i < numEntities; i++ ) { - if( isInterface( &entIDSet[i] ) ) { - status = tdiGetMibForIfEntity - ( tcpFile, - &entIDSet[i], - &infoSetInt[curInterf].if_info ); - if( NT_SUCCESS(status) ) { - DWORD numAddrs; - IPAddrEntry *addrs; - TDIEntityID ip_ent; - int j,k; + for( i = 0; i < numEntities; i++ ) { + if( isInterface( &entIDSet[i] ) ) { + status = tdiGetMibForIfEntity + ( tcpFile, + &entIDSet[i], + &infoSetInt[curInterf].if_info ); + if( NT_SUCCESS(status) ) { + DWORD numAddrs; + IPAddrEntry *addrs; + TDIEntityID ip_ent; + int j,k; - interfaceInfoComplete = FALSE; - for( j = 0; NT_SUCCESS(status); j++ ) { - status = getNthIpEntity( tcpFile, j, &ip_ent ); - if( NT_SUCCESS(status) ) - status = tdiGetIpAddrsForIpEntity - ( tcpFile, &ip_ent, &addrs, &numAddrs ); - for( k = 0; k < numAddrs && NT_SUCCESS(status); k++ ) { - if( addrs[k].iae_index == - infoSetInt[curInterf].if_info.ent.if_index ) { - memcpy( &infoSetInt[curInterf].ip_addr, - &addrs[k], - sizeof( addrs[k] ) ); - interfaceInfoComplete = TRUE; - break; - } - } - if( interfaceInfoComplete ) break; - } - } - if( NT_SUCCESS(status) ) curInterf++; - } - } + interfaceInfoComplete = FALSE; + for( j = 0; NT_SUCCESS(status); j++ ) { + status = getNthIpEntity( tcpFile, j, &ip_ent ); + if( NT_SUCCESS(status) ) + status = tdiGetIpAddrsForIpEntity + ( tcpFile, &ip_ent, &addrs, &numAddrs ); + for( k = 0; k < numAddrs && NT_SUCCESS(status); k++ ) { + if( addrs[k].iae_index == + infoSetInt[curInterf].if_info.ent.if_index ) { + memcpy( &infoSetInt[curInterf].ip_addr, + &addrs[k], + sizeof( addrs[k] ) ); + interfaceInfoComplete = TRUE; + break; + } + } + if( interfaceInfoComplete ) break; + } + } + if( NT_SUCCESS(status) ) curInterf++; + } + } } *infoSet = infoSetInt; @@ -406,27 +406,27 @@ static DWORD getNumInterfacesInt(BOOL onlyLoopback) status = openTcpFile( &tcpFile ); if( !NT_SUCCESS(status) ) { - DPRINT("getNumInterfaces: failed %08x\n", status ); - return 0; + DPRINT("getNumInterfaces: failed %08x\n", status ); + return 0; } status = tdiGetEntityIDSet( tcpFile, &entitySet, &numEntities ); if( !NT_SUCCESS(status) ) { - DPRINT("getNumInterfaces: failed %08x\n", status ); - return 0; + DPRINT("getNumInterfaces: failed %08x\n", status ); + return 0; } closeTcpFile( tcpFile ); for( i = 0; i < numEntities; i++ ) { - if( isInterface( &entitySet[i] ) && - (!onlyLoopback || isLoopback( tcpFile, &entitySet[i] )) ) - numInterfaces++; + if( isInterface( &entitySet[i] ) && + (!onlyLoopback || isLoopback( tcpFile, &entitySet[i] )) ) + numInterfaces++; } DPRINT("getNumInterfaces: success: %d %d %08x\n", - onlyLoopback, numInterfaces, status ); + onlyLoopback, numInterfaces, status ); tdiFreeThingSet( entitySet ); @@ -451,25 +451,25 @@ DWORD getNthInterfaceEntity( HANDLE tcpFile, DWORD index, TDIEntityID *ent ) { int i; if( !NT_SUCCESS(status) ) - return status; + return status; for( i = 0; i < numEntities; i++ ) { - if( isInterface( &entitySet[i] ) ) { - if( numInterfaces == index ) break; - else numInterfaces++; - } + if( isInterface( &entitySet[i] ) ) { + if( numInterfaces == index ) break; + else numInterfaces++; + } } DPRINT("Index %d is entity #%d - %04x:%08x\n", index, i, - entitySet[i].tei_entity, entitySet[i].tei_instance ); + entitySet[i].tei_entity, entitySet[i].tei_instance ); if( numInterfaces == index && i < numEntities ) { - memcpy( ent, &entitySet[i], sizeof(*ent) ); - tdiFreeThingSet( entitySet ); - return STATUS_SUCCESS; + memcpy( ent, &entitySet[i], sizeof(*ent) ); + tdiFreeThingSet( entitySet ); + return STATUS_SUCCESS; } else { - tdiFreeThingSet( entitySet ); - return STATUS_UNSUCCESSFUL; + tdiFreeThingSet( entitySet ); + return STATUS_UNSUCCESSFUL; } } @@ -480,17 +480,17 @@ NTSTATUS getInterfaceInfoByIndex( HANDLE tcpFile, DWORD index, IFInfo *info ) { int i; if( NT_SUCCESS(status) ) - for( i = 0; i < numInterfaces; i++ ) { - if( ifInfo[i].if_info.ent.if_index == index ) { - memcpy( info, &ifInfo[i], sizeof(*info) ); - break; - } - } + for( i = 0; i < numInterfaces; i++ ) { + if( ifInfo[i].if_info.ent.if_index == index ) { + memcpy( info, &ifInfo[i], sizeof(*info) ); + break; + } + } if( NT_SUCCESS(status) ) - return i < numInterfaces ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL; + return i < numInterfaces ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL; else - return status; + return status; } NTSTATUS getInterfaceInfoByName( HANDLE tcpFile, char *name, IFInfo *info ) { @@ -500,17 +500,17 @@ NTSTATUS getInterfaceInfoByName( HANDLE tcpFile, char *name, IFInfo *info ) { NTSTATUS status = getInterfaceInfoSet( tcpFile, &ifInfo, &numInterfaces ); if( NT_SUCCESS(status) ) - for( i = 0; i < numInterfaces; i++ ) { - if( !strcmp(ifInfo[i].if_info.ent.if_descr, name) ) { - memcpy( info, &ifInfo[i], sizeof(*info) ); - break; - } - } + for( i = 0; i < numInterfaces; i++ ) { + if( !strcmp(ifInfo[i].if_info.ent.if_descr, name) ) { + memcpy( info, &ifInfo[i], sizeof(*info) ); + break; + } + } if( NT_SUCCESS(status) ) - return i < numInterfaces ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL; + return i < numInterfaces ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL; else - return status; + return status; } /* Note that the result of this operation must be freed later */ @@ -523,17 +523,17 @@ const char *getInterfaceNameByIndex(DWORD index) NTSTATUS status = openTcpFile( &tcpFile ); if( NT_SUCCESS(status) ) { - status = getInterfaceInfoByIndex( tcpFile, index, &ifInfo ); - - if( NT_SUCCESS(status) ) { - adapter_name = ifInfo.if_info.ent.if_descr; - - interfaceName = HeapAlloc( GetProcessHeap(), 0, - strlen(adapter_name) + 1 ); - strcpy( interfaceName, adapter_name ); - - closeTcpFile( tcpFile ); - } + status = getInterfaceInfoByIndex( tcpFile, index, &ifInfo ); + + if( NT_SUCCESS(status) ) { + adapter_name = ifInfo.if_info.ent.if_descr; + + interfaceName = HeapAlloc( GetProcessHeap(), 0, + strlen(adapter_name) + 1 ); + strcpy( interfaceName, adapter_name ); + + closeTcpFile( tcpFile ); + } } return interfaceName; @@ -550,12 +550,12 @@ DWORD getInterfaceIndexByName(const char *name, PDWORD index) NTSTATUS status = openTcpFile( &tcpFile ); if( NT_SUCCESS(status) ) { - status = getInterfaceInfoByName( tcpFile, (char *)name, &ifInfo ); - - if( NT_SUCCESS(status) ) { - *index = ifInfo.if_info.ent.if_index; - closeTcpFile( tcpFile ); - } + status = getInterfaceInfoByName( tcpFile, (char *)name, &ifInfo ); + + if( NT_SUCCESS(status) ) { + *index = ifInfo.if_info.ent.if_index; + closeTcpFile( tcpFile ); + } } return status; @@ -573,30 +573,30 @@ InterfaceIndexTable *getInterfaceIndexTableInt( BOOL nonLoopbackOnly ) { status = getInterfaceInfoSet( tcpFile, &ifInfo, &numInterfaces ); if( NT_SUCCESS(status) ) { - ret = (InterfaceIndexTable *) - calloc(1, - sizeof(InterfaceIndexTable) + - (numInterfaces - 1) * sizeof(DWORD)); - - if (ret) { - ret->numAllocated = numInterfaces; - - for( i = 0; i < numInterfaces; i++ ) { - if( !nonLoopbackOnly || - !isLoopback( tcpFile, &ifInfo[i].entity_id ) ) { - ret->indexes[curInterface++] = - ifInfo[i].if_info.ent.if_index; - } - } + ret = (InterfaceIndexTable *) + calloc(1, + sizeof(InterfaceIndexTable) + + (numInterfaces - 1) * sizeof(DWORD)); + + if (ret) { + ret->numAllocated = numInterfaces; + + for( i = 0; i < numInterfaces; i++ ) { + if( !nonLoopbackOnly || + !isLoopback( tcpFile, &ifInfo[i].entity_id ) ) { + ret->indexes[curInterface++] = + ifInfo[i].if_info.ent.if_index; + } + } - ret->numIndexes = curInterface; - } - - tdiFreeThingSet( ifInfo ); + ret->numIndexes = curInterface; + } + + tdiFreeThingSet( ifInfo ); } closeTcpFile( tcpFile ); } - + return ret; } @@ -614,13 +614,13 @@ DWORD getInterfaceIPAddrByName(const char *name) } NTSTATUS getIPAddrEntryForIf(HANDLE tcpFile, - char *name, - DWORD index, - IFInfo *ifInfo) { + char *name, + DWORD index, + IFInfo *ifInfo) { NTSTATUS status = - name ? - getInterfaceInfoByName( tcpFile, name, ifInfo ) : - getInterfaceInfoByIndex( tcpFile, index, ifInfo ); + name ? + getInterfaceInfoByName( tcpFile, name, ifInfo ) : + getInterfaceInfoByIndex( tcpFile, index, ifInfo ); return status; } @@ -633,21 +633,21 @@ DWORD getAddrByIndexOrName( char *name, DWORD index, IPHLPAddrType addrType ) { status = openTcpFile( &tcpFile ); if( NT_SUCCESS(status) ) { - status = getIPAddrEntryForIf( tcpFile, name, index, &ifInfo ); - if( NT_SUCCESS(status) ) { - switch( addrType ) { - case IPAAddr: addrOut = ifInfo.ip_addr.iae_addr; break; - case IPABcast: addrOut = ifInfo.ip_addr.iae_bcastaddr; break; - case IPAMask: addrOut = ifInfo.ip_addr.iae_mask; break; - case IFMtu: addrOut = ifInfo.if_info.ent.if_mtu; break; - case IFStatus: addrOut = ifInfo.if_info.ent.if_operstatus; break; - } - } - closeTcpFile( &tcpFile ); + status = getIPAddrEntryForIf( tcpFile, name, index, &ifInfo ); + if( NT_SUCCESS(status) ) { + switch( addrType ) { + case IPAAddr: addrOut = ifInfo.ip_addr.iae_addr; break; + case IPABcast: addrOut = ifInfo.ip_addr.iae_bcastaddr; break; + case IPAMask: addrOut = ifInfo.ip_addr.iae_mask; break; + case IFMtu: addrOut = ifInfo.if_info.ent.if_mtu; break; + case IFStatus: addrOut = ifInfo.if_info.ent.if_operstatus; break; + } + } + closeTcpFile( &tcpFile ); } return addrOut; -} +} DWORD getInterfaceIPAddrByIndex(DWORD index) { return getAddrByIndexOrName( 0, index, IPAAddr ); @@ -670,24 +670,24 @@ DWORD getInterfaceMaskByIndex(DWORD index) { } void getInterfacePhysicalFromInfo( IFInfo *info, - PDWORD len, PBYTE addr, PDWORD type ) { + PDWORD len, PBYTE addr, PDWORD type ) { *len = info->if_info.ent.if_physaddrlen; memcpy( addr, info->if_info.ent.if_physaddr, *len ); *type = info->if_info.ent.if_type; } DWORD getInterfacePhysicalByName(const char *name, PDWORD len, PBYTE addr, - PDWORD type) + PDWORD type) { HANDLE tcpFile; IFInfo info; NTSTATUS status = openTcpFile( &tcpFile ); if( NT_SUCCESS(status) ) { - status = getInterfaceInfoByName( tcpFile, (char *)name, &info ); - if( NT_SUCCESS(status) ) - getInterfacePhysicalFromInfo( &info, len, addr, type ); - closeTcpFile( tcpFile ); + status = getInterfaceInfoByName( tcpFile, (char *)name, &info ); + if( NT_SUCCESS(status) ) + getInterfacePhysicalFromInfo( &info, len, addr, type ); + closeTcpFile( tcpFile ); } return status; @@ -701,10 +701,10 @@ DWORD getInterfacePhysicalByIndex(DWORD index, PDWORD len, PBYTE addr, NTSTATUS status = openTcpFile( &tcpFile ); if( NT_SUCCESS(status) ) { - status = getInterfaceInfoByIndex( tcpFile, index, &info ); - if( NT_SUCCESS(status) ) - getInterfacePhysicalFromInfo( &info, len, addr, type ); - closeTcpFile( tcpFile ); + status = getInterfaceInfoByIndex( tcpFile, index, &info ); + if( NT_SUCCESS(status) ) + getInterfacePhysicalFromInfo( &info, len, addr, type ); + closeTcpFile( tcpFile ); } return status; @@ -740,15 +740,15 @@ DWORD getInterfaceEntryByName(const char *name, PMIB_IFROW entry) DPRINT("Called.\n"); if( NT_SUCCESS(status) ) { - status = getInterfaceInfoByName( tcpFile, (char *)name, &info ); - - if( NT_SUCCESS(status) ) { - memcpy( &entry->wszName[MAX_INTERFACE_NAME_LEN], - &info.if_info, - sizeof(info.if_info) ); - } - - closeTcpFile( tcpFile ); + status = getInterfaceInfoByName( tcpFile, (char *)name, &info ); + + if( NT_SUCCESS(status) ) { + memcpy( &entry->wszName[MAX_INTERFACE_NAME_LEN], + &info.if_info, + sizeof(info.if_info) ); + } + + closeTcpFile( tcpFile ); } return status; @@ -763,15 +763,15 @@ DWORD getInterfaceEntryByIndex(DWORD index, PMIB_IFROW entry) DPRINT("Called.\n"); if( NT_SUCCESS(status) ) { - status = getInterfaceInfoByIndex( tcpFile, index, &info ); - - if( NT_SUCCESS(status) ) { - memcpy( &entry->wszName[MAX_INTERFACE_NAME_LEN], - &info.if_info, - sizeof(info.if_info) ); - } - - closeTcpFile( tcpFile ); + status = getInterfaceInfoByIndex( tcpFile, index, &info ); + + if( NT_SUCCESS(status) ) { + memcpy( &entry->wszName[MAX_INTERFACE_NAME_LEN], + &info.if_info, + sizeof(info.if_info) ); + } + + closeTcpFile( tcpFile ); } return status; @@ -794,7 +794,7 @@ DWORD createIpForwardEntryOS( PMIB_IPFORWARDROW pRoute ) { HANDLE tcpFile = INVALID_HANDLE_VALUE; NTSTATUS status = openTcpFile( &tcpFile ); TCP_REQUEST_SET_INFORMATION_EX_SAFELY_SIZED req = - TCP_REQUEST_SET_INFORMATION_INIT; + TCP_REQUEST_SET_INFORMATION_INIT; IPRouteEntry *rte; TDIEntityID id; DWORD returnSize = 0; @@ -802,35 +802,35 @@ DWORD createIpForwardEntryOS( PMIB_IPFORWARDROW pRoute ) { DPRINT("Called.\n"); if( NT_SUCCESS(status) ) - status = getNthIpEntity( tcpFile, 0, &id ); + status = getNthIpEntity( tcpFile, 0, &id ); if( NT_SUCCESS(status) ) { - req.Req.ID.toi_class = INFO_CLASS_PROTOCOL; - req.Req.ID.toi_type = INFO_TYPE_PROVIDER; - req.Req.ID.toi_id = IP_MIB_ROUTETABLE_ENTRY_ID; - req.Req.ID.toi_entity = id; - req.Req.BufferSize = sizeof(*rte); - rte = - (IPRouteEntry *)&req.Req.Buffer[0]; + req.Req.ID.toi_class = INFO_CLASS_PROTOCOL; + req.Req.ID.toi_type = INFO_TYPE_PROVIDER; + req.Req.ID.toi_id = IP_MIB_ROUTETABLE_ENTRY_ID; + req.Req.ID.toi_entity = id; + req.Req.BufferSize = sizeof(*rte); + rte = + (IPRouteEntry *)&req.Req.Buffer[0]; - rte->ire_dest = pRoute->dwForwardDest; - rte->ire_index = pRoute->dwForwardIfIndex; - rte->ire_metric = pRoute->dwForwardMetric1; - rte->ire_gw = pRoute->dwForwardNextHopAS; - rte->ire_mask = pRoute->dwForwardMask; + rte->ire_dest = pRoute->dwForwardDest; + rte->ire_index = pRoute->dwForwardIfIndex; + rte->ire_metric = pRoute->dwForwardMetric1; + rte->ire_gw = pRoute->dwForwardNextHopAS; + rte->ire_mask = pRoute->dwForwardMask; - status = DeviceIoControl( tcpFile, - IOCTL_TCP_SET_INFORMATION_EX, - &req, - sizeof(req), - NULL, - 0, - &returnSize, - NULL ); + status = DeviceIoControl( tcpFile, + IOCTL_TCP_SET_INFORMATION_EX, + &req, + sizeof(req), + NULL, + 0, + &returnSize, + NULL ); } if( tcpFile != INVALID_HANDLE_VALUE ) - closeTcpFile( tcpFile ); + closeTcpFile( tcpFile ); return status; } diff --git a/reactos/lib/iphlpapi/iphlpapi_main.c b/reactos/lib/iphlpapi/iphlpapi_main.c index 9888e845151..b25db6e20ee 100644 --- a/reactos/lib/iphlpapi/iphlpapi_main.c +++ b/reactos/lib/iphlpapi/iphlpapi_main.c @@ -620,13 +620,13 @@ DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen) for (ndx = 0; ndx < table->numIndexes; ndx++) { PIP_ADAPTER_INFO ptr = &pAdapterInfo[ndx]; DWORD addrLen = sizeof(ptr->Address), type; - const char *ifname = - getInterfaceNameByIndex(table->indexes[ndx]); + const char *ifname = + getInterfaceNameByIndex(table->indexes[ndx]); /* on Win98 this is left empty, but whatever */ - + strncpy(ptr->AdapterName,ifname,sizeof(ptr->AdapterName)); - consumeInterfaceName(ifname); + consumeInterfaceName(ifname); ptr->AdapterName[MAX_ADAPTER_NAME_LENGTH] = '\0'; getInterfacePhysicalByIndex(table->indexes[ndx], &addrLen, ptr->Address, &type); @@ -973,7 +973,7 @@ DWORD WINAPI GetInterfaceInfo(PIP_INTERFACE_INFO pIfTable, PULONG dwOutBufLen) walker++, assigner++) *assigner = *walker; *assigner = 0; - consumeInterfaceName(name); + consumeInterfaceName(name); pIfTable->NumAdapters++; } ret = NO_ERROR; @@ -1125,7 +1125,7 @@ DWORD WINAPI GetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable, PULONG pdwSi DWORD ret; TRACE("pIpForwardTable %p, pdwSize %p, bOrder %ld\n", pIpForwardTable, - pdwSize, (DWORD)bOrder); + pdwSize, (DWORD)bOrder); if (!pdwSize) ret = ERROR_INVALID_PARAMETER; else { @@ -1358,11 +1358,11 @@ DWORD WINAPI GetNetworkParams(PFIXED_INFO pFixedInfo, PULONG pOutBufLen) for (i = 0, ptr = &pFixedInfo->DnsServerList; i < resInfo->riCount && ptr; i++, ptr = ptr->Next) { - struct sockaddr_in *addr_v4 = - (struct sockaddr_in *)&resInfo->riAddressList[i]; - toIPAddressString - (addr_v4->sin_addr.s_addr, - ptr->IpAddress.String); + struct sockaddr_in *addr_v4 = + (struct sockaddr_in *)&resInfo->riAddressList[i]; + toIPAddressString + (addr_v4->sin_addr.s_addr, + ptr->IpAddress.String); if (i == resInfo->riCount - 1) ptr->Next = NULL; else if (i == 0) diff --git a/reactos/lib/iphlpapi/ipstats_reactos.c b/reactos/lib/iphlpapi/ipstats_reactos.c index 4f5e6da9a0e..1651d0aeef5 100644 --- a/reactos/lib/iphlpapi/ipstats_reactos.c +++ b/reactos/lib/iphlpapi/ipstats_reactos.c @@ -68,18 +68,18 @@ BOOL isIpEntity( HANDLE tcpFile, TDIEntityID *ent ) { req.ID.toi_entity = *ent; status = - DeviceIoControl - ( tcpFile, - IOCTL_TCP_QUERY_INFORMATION_EX, - &req, - sizeof(req), - &entityType, - sizeof(entityType), - &returnedLen, - NULL ); + DeviceIoControl + ( tcpFile, + IOCTL_TCP_QUERY_INFORMATION_EX, + &req, + sizeof(req), + &entityType, + sizeof(entityType), + &returnedLen, + NULL ); DPRINT("Ent: %04x:d -> %04x\n", - ent->tei_entity, ent->tei_instance, entityType ); + ent->tei_entity, ent->tei_instance, entityType ); return NT_SUCCESS(status) && entityType == CL_NL_IP; } @@ -92,25 +92,25 @@ NTSTATUS getNthIpEntity( HANDLE tcpFile, DWORD index, TDIEntityID *ent ) { int i; if( !NT_SUCCESS(status) ) - return status; + return status; for( i = 0; i < numEntities; i++ ) { - if( isIpEntity( tcpFile, &entitySet[i] ) ) { - DPRINT("Entity %d is an IP Entity\n", i); - if( numRoutes == index ) break; - else numRoutes++; - } + if( isIpEntity( tcpFile, &entitySet[i] ) ) { + DPRINT("Entity %d is an IP Entity\n", i); + if( numRoutes == index ) break; + else numRoutes++; + } } if( numRoutes == index && i < numEntities ) { - DPRINT("Index %d is entity #%d - %04x:%08x\n", index, i, - entitySet[i].tei_entity, entitySet[i].tei_instance ); - memcpy( ent, &entitySet[i], sizeof(*ent) ); - tdiFreeThingSet( entitySet ); - return STATUS_SUCCESS; + DPRINT("Index %d is entity #%d - %04x:%08x\n", index, i, + entitySet[i].tei_entity, entitySet[i].tei_instance ); + memcpy( ent, &entitySet[i], sizeof(*ent) ); + tdiFreeThingSet( entitySet ); + return STATUS_SUCCESS; } else { - tdiFreeThingSet( entitySet ); - return STATUS_UNSUCCESSFUL; + tdiFreeThingSet( entitySet ); + return STATUS_UNSUCCESSFUL; } } @@ -123,7 +123,7 @@ NTSTATUS tdiGetMibForIpEntity memset( entry, 0, sizeof( *entry ) ); DPRINT("TdiGetMibForIpEntity(tcpFile %x,entityId %x)\n", - (DWORD)tcpFile, ent->tei_instance); + (DWORD)tcpFile, ent->tei_instance); req.ID.toi_class = INFO_CLASS_PROTOCOL; req.ID.toi_type = INFO_TYPE_PROVIDER; @@ -131,40 +131,40 @@ NTSTATUS tdiGetMibForIpEntity req.ID.toi_entity = *ent; status = DeviceIoControl( tcpFile, - IOCTL_TCP_QUERY_INFORMATION_EX, - &req, - sizeof(req), - entry, - sizeof(*entry), - &returnSize, - NULL ); + IOCTL_TCP_QUERY_INFORMATION_EX, + &req, + sizeof(req), + entry, + sizeof(*entry), + &returnSize, + NULL ); DPRINT("TdiGetMibForIpEntity() => {\n" - " ipsi_forwarding ............ %d\n" - " ipsi_defaultttl ............ %d\n" - " ipsi_inreceives ............ %d\n" - " ipsi_indelivers ............ %d\n" - " ipsi_outrequests ........... %d\n" - " ipsi_routingdiscards ....... %d\n" - " ipsi_outdiscards ........... %d\n" - " ipsi_outnoroutes ........... %d\n" - " ipsi_numif ................. %d\n" - " ipsi_numaddr ............... %d\n" - " ipsi_numroutes ............. %d\n" - "} status %08x\n", - entry->ipsi_forwarding, - entry->ipsi_defaultttl, - entry->ipsi_inreceives, - entry->ipsi_indelivers, - entry->ipsi_outrequests, - entry->ipsi_routingdiscards, - entry->ipsi_outdiscards, - entry->ipsi_outnoroutes, - entry->ipsi_numif, - entry->ipsi_numaddr, - entry->ipsi_numroutes, - status); - + " ipsi_forwarding ............ %d\n" + " ipsi_defaultttl ............ %d\n" + " ipsi_inreceives ............ %d\n" + " ipsi_indelivers ............ %d\n" + " ipsi_outrequests ........... %d\n" + " ipsi_routingdiscards ....... %d\n" + " ipsi_outdiscards ........... %d\n" + " ipsi_outnoroutes ........... %d\n" + " ipsi_numif ................. %d\n" + " ipsi_numaddr ............... %d\n" + " ipsi_numroutes ............. %d\n" + "} status %08x\n", + entry->ipsi_forwarding, + entry->ipsi_defaultttl, + entry->ipsi_inreceives, + entry->ipsi_indelivers, + entry->ipsi_outrequests, + entry->ipsi_routingdiscards, + entry->ipsi_outdiscards, + entry->ipsi_outnoroutes, + entry->ipsi_numif, + entry->ipsi_numaddr, + entry->ipsi_numroutes, + status); + return status; } @@ -173,17 +173,17 @@ NTSTATUS tdiGetRoutesForIpEntity NTSTATUS status = STATUS_SUCCESS; DPRINT("TdiGetRoutesForIpEntity(tcpFile %x,entityId %x)\n", - (DWORD)tcpFile, ent->tei_instance); + (DWORD)tcpFile, ent->tei_instance); status = tdiGetSetOfThings( tcpFile, - INFO_CLASS_PROTOCOL, - INFO_TYPE_PROVIDER, - IP_MIB_ROUTETABLE_ENTRY_ID, - ent->tei_entity, - 0, - sizeof(IPRouteEntry), - (PVOID *)routes, - numRoutes); + INFO_CLASS_PROTOCOL, + INFO_TYPE_PROVIDER, + IP_MIB_ROUTETABLE_ENTRY_ID, + ent->tei_entity, + 0, + sizeof(IPRouteEntry), + (PVOID *)routes, + numRoutes); return status; } @@ -193,17 +193,17 @@ NTSTATUS tdiGetIpAddrsForIpEntity NTSTATUS status; DPRINT("TdiGetIpAddrsForIpEntity(tcpFile %x,entityId %x)\n", - (DWORD)tcpFile, ent->tei_instance); + (DWORD)tcpFile, ent->tei_instance); status = tdiGetSetOfThings( tcpFile, - INFO_CLASS_PROTOCOL, - INFO_TYPE_PROVIDER, - IP_MIB_ADDRTABLE_ENTRY_ID, - ent->tei_entity, - 0, - sizeof(IPAddrEntry), - (PVOID *)addrs, - numAddrs ); + INFO_CLASS_PROTOCOL, + INFO_TYPE_PROVIDER, + IP_MIB_ADDRTABLE_ENTRY_ID, + ent->tei_entity, + 0, + sizeof(IPAddrEntry), + (PVOID *)addrs, + numAddrs ); return status; } @@ -389,28 +389,28 @@ DWORD getNumRoutes(void) status = openTcpFile( &tcpFile ); if( !NT_SUCCESS(status) ) { - TRACE("failure: %08x\n", (int)status ); - return 0; + TRACE("failure: %08x\n", (int)status ); + return 0; } status = tdiGetEntityIDSet( tcpFile, &entitySet, &numEntities ); if( !NT_SUCCESS(status) ) { - TRACE("failure: %08x\n", (int)status ); - return 0; + TRACE("failure: %08x\n", (int)status ); + return 0; } for( i = 0; i < numEntities; i++ ) { - if( isIpEntity( tcpFile, &entitySet[i] ) ) { - IPSNMPInfo isnmp; - memset( &isnmp, 0, sizeof( isnmp ) ); - status = tdiGetMibForIpEntity( tcpFile, &entitySet[i], &isnmp ); - if( !NT_SUCCESS(status) ) { - tdiFreeThingSet( entitySet ); - return status; - } - numRoutes += isnmp.ipsi_numroutes; - } + if( isIpEntity( tcpFile, &entitySet[i] ) ) { + IPSNMPInfo isnmp; + memset( &isnmp, 0, sizeof( isnmp ) ); + status = tdiGetMibForIpEntity( tcpFile, &entitySet[i], &isnmp ); + if( !NT_SUCCESS(status) ) { + tdiFreeThingSet( entitySet ); + return status; + } + numRoutes += isnmp.ipsi_numroutes; + } } TRACE("numRoutes: %d\n", (int)numRoutes); @@ -424,11 +424,11 @@ VOID HexDump( PCHAR Data, DWORD Len ) { int i; for( i = 0; i < Len; i++ ) { - if( !(i & 0xf) ) { - if( i ) fprintf(stderr,"\n"); - fprintf(stderr,"%08x:", i); - } - fprintf( stderr, " %02x", Data[i] & 0xff ); + if( !(i & 0xf) ) { + if( i ) fprintf(stderr,"\n"); + fprintf(stderr,"%08x:", i); + } + fprintf( stderr, " %02x", Data[i] & 0xff ); } fprintf(stderr,"\n"); } @@ -444,55 +444,55 @@ RouteTable *getRouteTable(void) int i; if( !NT_SUCCESS(status) ) - return 0; + return 0; out_route_table = HeapAlloc( GetProcessHeap(), 0, - sizeof(RouteTable) + - (sizeof(RouteEntry) * (numRoutes - 1)) ); + sizeof(RouteTable) + + (sizeof(RouteEntry) * (numRoutes - 1)) ); out_route_table->numRoutes = numRoutes; for( i = 0; routesAdded < numRoutes; i++ ) { - int j; - IPRouteEntry *route_set; + int j; + IPRouteEntry *route_set; - getNthIpEntity( tcpFile, i, &ent ); - tdiGetMibForIpEntity( tcpFile, &ent, &snmpInfo ); + getNthIpEntity( tcpFile, i, &ent ); + tdiGetMibForIpEntity( tcpFile, &ent, &snmpInfo ); - DPRINT( "%d routes in instance %d\n", snmpInfo.ipsi_numroutes, i ); + DPRINT( "%d routes in instance %d\n", snmpInfo.ipsi_numroutes, i ); - if( !route_set ) { - closeTcpFile( tcpFile ); - HeapFree( GetProcessHeap(), 0, out_route_table ); - return 0; - } + if( !route_set ) { + closeTcpFile( tcpFile ); + HeapFree( GetProcessHeap(), 0, out_route_table ); + return 0; + } - tdiGetRoutesForIpEntity( tcpFile, &ent, &route_set, &numRoutes ); + tdiGetRoutesForIpEntity( tcpFile, &ent, &route_set, &numRoutes ); - DPRINT("Route set returned\n"); + DPRINT("Route set returned\n"); #if 0 - HexDump( route_set, - sizeof( IPRouteEntry ) * - snmpInfo.ipsi_numroutes ); + HexDump( route_set, + sizeof( IPRouteEntry ) * + snmpInfo.ipsi_numroutes ); #endif - for( j = 0; j < snmpInfo.ipsi_numroutes; j++ ) { - int routeNum = j + routesAdded; - out_route_table->routes[routeNum].dest = - route_set[j].ire_dest; - out_route_table->routes[routeNum].mask = - route_set[j].ire_mask; - out_route_table->routes[routeNum].gateway = - route_set[j].ire_gw; - out_route_table->routes[routeNum].ifIndex = - route_set[j].ire_index; - out_route_table->routes[routeNum].metric = - route_set[j].ire_metric; - } + for( j = 0; j < snmpInfo.ipsi_numroutes; j++ ) { + int routeNum = j + routesAdded; + out_route_table->routes[routeNum].dest = + route_set[j].ire_dest; + out_route_table->routes[routeNum].mask = + route_set[j].ire_mask; + out_route_table->routes[routeNum].gateway = + route_set[j].ire_gw; + out_route_table->routes[routeNum].ifIndex = + route_set[j].ire_index; + out_route_table->routes[routeNum].metric = + route_set[j].ire_metric; + } - if( route_set ) tdiFreeThingSet( route_set ); + if( route_set ) tdiFreeThingSet( route_set ); - routesAdded += snmpInfo.ipsi_numroutes; + routesAdded += snmpInfo.ipsi_numroutes; } return out_route_table; diff --git a/reactos/lib/iphlpapi/registry.c b/reactos/lib/iphlpapi/registry.c index 614bbdec492..20ed619680d 100644 --- a/reactos/lib/iphlpapi/registry.c +++ b/reactos/lib/iphlpapi/registry.c @@ -7,17 +7,17 @@ int GetLongestChildKeyName( HANDLE RegHandle ) { DWORD MaxAdapterName; Status = RegQueryInfoKeyA(RegHandle, - NULL, - NULL, - NULL, - NULL, - &MaxAdapterName, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL); + NULL, + NULL, + NULL, + NULL, + &MaxAdapterName, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); if (Status == ERROR_SUCCESS) return MaxAdapterName + 1; else @@ -25,13 +25,13 @@ int GetLongestChildKeyName( HANDLE RegHandle ) { } LONG OpenChildKeyRead( HANDLE RegHandle, - PCHAR ChildKeyName, - PHKEY ReturnHandle ) { + PCHAR ChildKeyName, + PHKEY ReturnHandle ) { return RegOpenKeyExA( RegHandle, - ChildKeyName, - 0, - KEY_READ, - ReturnHandle ); + ChildKeyName, + 0, + KEY_READ, + ReturnHandle ); } /* @@ -52,7 +52,7 @@ PCHAR GetNthChildKeyName( HANDLE RegHandle, DWORD n ) { ValueLen = MaxAdapterName; Value = (PCHAR)HeapAlloc( GetProcessHeap(), 0, MaxAdapterName ); Status = RegEnumKeyExA( RegHandle, n, Value, &ValueLen, - NULL, NULL, NULL, NULL ); + NULL, NULL, NULL, NULL ); if (Status != ERROR_SUCCESS) return 0; else { @@ -70,12 +70,12 @@ PCHAR QueryRegistryValueString( HANDLE RegHandle, PCHAR ValueName ) { DWORD ReturnedSize = 0; if (RegQueryValueExA( RegHandle, ValueName, NULL, NULL, NULL, - &ReturnedSize ) != 0) + &ReturnedSize ) != 0) return 0; else { Name = malloc( (ReturnedSize + 1) * sizeof(WCHAR) ); RegQueryValueExA( RegHandle, ValueName, NULL, NULL, (PVOID)Name, - &ReturnedSize ); + &ReturnedSize ); Name[ReturnedSize] = 0; return Name; } diff --git a/reactos/lib/iphlpapi/resinfo_reactos.c b/reactos/lib/iphlpapi/resinfo_reactos.c index 39f6aaf14ae..a880a7172d9 100644 --- a/reactos/lib/iphlpapi/resinfo_reactos.c +++ b/reactos/lib/iphlpapi/resinfo_reactos.c @@ -50,11 +50,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi); PIPHLP_RES_INFO getResInfo() { PIPHLP_RES_INFO InfoPtr = - (PIPHLP_RES_INFO)HeapAlloc( GetProcessHeap(), 0, - sizeof(PIPHLP_RES_INFO) ); + (PIPHLP_RES_INFO)HeapAlloc( GetProcessHeap(), 0, + sizeof(PIPHLP_RES_INFO) ); if( InfoPtr ) { - InfoPtr->riCount = 0; - InfoPtr->riAddressList = (LPSOCKADDR)0; + InfoPtr->riCount = 0; + InfoPtr->riAddressList = (LPSOCKADDR)0; } return InfoPtr;