Topic: DevPath.exe fails to set registry key when using a lot of driverpacks

I'm using method 2 for Windows XP install with the latest version of base.

I'm using the following driverpacks:
Chipset
CPU
Graphics A
Graphics B
Graphics C
LAN
Mass Storage
Sound A
Sound B
WLAN

I'm also using the following 3rd party driverpacks:
Bluetooth
Monitors

During the execution of presetup.cmd, all of the driverpacks are properly extracted/unzipped to %SystemDrive%. The DevPath.exe %SystemDrive%\D command runs, but it does not set the registry key.

In order to test, I manually extracted the driverpacks to C:\D and manually ran DevPath.exe... this also confirmed that the registry key does not get set.

In order to test further, I manually removed one of the "big" subfolders C:\D\L and manually ran DevPath.exe. After doing this, the registry key was correctly set. In order to test further, I put the C:\D\L back and removed one of the other driverpack subfolders C:\D\S. After doing this, the registry key was set properly.

Looks like the problem is being caused by a string size limit within DevPath.exe. It can not generate the string for a huge subfolder structure.

The problem is NOT with the registry key lenght. The registry key can handle a much longer string. I confirmed this by manually cutting and pasting a duplicate of the long string to the end of the string... several times.

Does anyone have an updated version of DevPath.exe that would get around this limit?

Can anyone share the source code for DevPath.exe in order to debug further?

Last edited by zookeeper (2011-02-10 02:33:51)

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

Do not use the monitors Third Party DriverPack.  It's folder structure does not play nice with the folder path length limit.  You can use it in a SAD disk though with no problems.
Bluetooth also has it's own problems.

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

Thanks for the response.

I won't use the monitors and bluetooth driverpacks.

However, I would like to help solve the limitation with DrivePath.exe so that we don't encounter a problem as the core driverpacks continue to grow.

Would you like the help?

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

You are welcome to help... However, this has been reported and investigated several times. There are several posts on the forum about it.

Our research leads us to find out there is a limit to the size of a single registry entry. We have come to the conclusion that this is not an issue with DevPath. We believe the issue is exceeding the max size of a single registry entry. If true then this is a limitation of windows XP and not DevPath. It was difficult to find the documentation but as best as i could discover through MS documentation a single registry entry can be no more than 1MB in size. However in practice i believe it is less than that.

while working on a Auto-it script i discovered that it has a limit for the max size of an array and was able to create a workaround by using multiple arrays. This was discovered while i was working on the script to parse the HWIDs contained in a packs INF files (the output is used to populate the supported devices list on our download pages). It may be that DevPath has a similar issue but we don't have the original code for DevPath it was donated to us. I believe it was written in VB. IDK if VB has a similar issue.


If you have time and can figure something out let us know... I would love to fix it.

DP BartPE Tutorial   DP_BASE Tutorial   HWID's Tool     Read BEFORE you post    UserBars!
http://driverpacks.net/userbar/admin-1.png
The DriverPacks, the DP_Base program, and Support Forum are FREE!.

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

I have written the following C program as a replacement for the older DevPath.exe, which was written using AutoIT and VB.. but the source code doesn't exist.

This new DevPath.exe functions the same way as the old AutoIt/VisualBasic version of DevPath. It scans the supplied path for *.inf files and automatically sets the registry key value HKLM\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\DevicePath to the discovered list of driverpack folders that contain *.inf files.

The new version has a much larger string buffer size for handling the navigation of a large number of driverpack folders with corresponding *.inf files.

The same command is used to run it:

DevPath.exe C:\D

I compiled the following source code using "Microsoft Visual C++ 2010 Express" (The Express edition is free).  I could post the project file used for building it.

I initially encountered a problem with DevPath.exe that required the existence of MSVCR100.DLL on the windows computer. On a clean install of Windows, this MSVCR100.DLL does not exist. This problem was fixed by changing the project properties to statically linking the MFC runtime and also statically link AdvAPI32.lib, which is part of the Windows SDK v7.1 (Downloaded and installed the x86 libraries).  I added the one line to the code for #pragma comment(lib,"AdvAPI32.Lib")

Code was enhanced on 03/11/11 to handle upper and lower case filename extension (e.g.  .inf  or  .INF  or  .Inf)

#include <Windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <tchar.h>
#include <strsafe.h>

#pragma comment(lib, "AdvAPI32.Lib")


//------------------------------------------------------------------------------------------------------------------
// Globals...
//------------------------------------------------------------------------------------------------------------------
WIN32_FIND_DATA *fd;

#define DEVPATH_REGISTRY_VALUE_BUFFER 100000
#define DEVPATH_REGISTRY_KEY   "SOFTWARE\\Microsoft\\Windows\\CurrentVersion"
#define DEVPATH_REGISTRY_VALUE "DevicePath"

//------------------------------------------------------------------------------------------------------------------
// Protos...
//------------------------------------------------------------------------------------------------------------------
int     navigatepath(const char *path, char *registryvalue, BOOL recursive);
int     fixpath(const char *inpath, char *outpath);

//------------------------------------------------------------------------------------------------------------------
// navigatepath()
//------------------------------------------------------------------------------------------------------------------
int navigatepath(const char *_path, char *registryvalue, BOOL recursive)
{
  HANDLE fh;
  int    filecnt=0;
  int    filenamelen;
  char	 path[MAX_PATH];
  char	 tmppath[MAX_PATH];

  fd = malloc(sizeof(WIN32_FIND_DATA));

  fixpath(_path,path);
  strcat_s(path,MAX_PATH,"*");

  fh = FindFirstFile((LPCSTR) path,fd);

  if (fh != INVALID_HANDLE_VALUE)
  {
    do
    {
      if (!(fd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
      {
        filenamelen = strlen( fd->cFileName );

        if (filenamelen >= 4)
        {
          if (fd->cFileName[filenamelen - 4] == '.' && (fd->cFileName[filenamelen - 3] == 'I' || fd->cFileName[filenamelen - 3] == 'i') && (fd->cFileName[filenamelen - 2] == 'N' || fd->cFileName[filenamelen - 2] == 'n') && (fd->cFileName[filenamelen - 1] == 'F' || fd->cFileName[filenamelen - 1] == 'f'))
          {
            filecnt++;
            break;
          }
        }
        
      }
    }
    while(FindNextFile(fh,fd));
  }

  if (filecnt)
  {
    strcat_s(registryvalue,DEVPATH_REGISTRY_VALUE_BUFFER,";");
    strcat_s(registryvalue,DEVPATH_REGISTRY_VALUE_BUFFER,_path);
  }

  fh = FindFirstFile((LPCSTR) path,fd);

  if (fh != INVALID_HANDLE_VALUE)
  {
    do
    {
      if (fd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
      {
        if((0 != strcmp(fd->cFileName,".")) && (0 != strcmp(fd->cFileName,"..")))
        {
          fixpath(_path,tmppath);
          strcat_s(tmppath,MAX_PATH,fd->cFileName);

          if(recursive)
            navigatepath(tmppath, registryvalue, recursive);
        }
      }
    }
    while(FindNextFile(fh,fd));
  }

  
  FindClose(fh);

  return 0;
}

//------------------------------------------------------------------------------------------------------------------
// fixpath() - Adds \ to the end of a path if not present.
//------------------------------------------------------------------------------------------------------------------
int fixpath(const char *inpath, char *outpath)
{
  int   n=0;

  strcpy_s(outpath,MAX_PATH,inpath);

  while(inpath[n]) n++;

  if(inpath[n-1] != '\\')
  {
    strcat_s(outpath,MAX_PATH,"\\");
    return 1;
  }

  return 0;
}

//------------------------------------------------------------------------------------------------------------------
// Entry point...
//------------------------------------------------------------------------------------------------------------------

int main(int argc, char *argv[])
{
  int   recursive=1;
  char  registryvalue[DEVPATH_REGISTRY_VALUE_BUFFER];
  DWORD dwCategoryNum = 1;
  HKEY  hk;
  DWORD dwDisp;

  registryvalue[0] = 0;
  strcpy_s(registryvalue, DEVPATH_REGISTRY_VALUE_BUFFER, "%SystemRoot%\\Inf");

  if (argc == 1)
  {
    printf("Devpath.exe [drive:][path]\n\n");
    printf("DevPath.exe will scan [drive:][path] and all subfolders for the existence\n");
    printf("of *.inf file(s). It will set the registry key to the list of subfolders\n");
    printf("that contain *.inf file(s).\n");
    printf("HKLM %s REG_EXPAND_SZ %s\n",DEVPATH_REGISTRY_KEY,DEVPATH_REGISTRY_VALUE);
  }
  
  if (argc == 2)
  {
    navigatepath(argv[1], registryvalue, recursive);
  
    //printf("%s\n",registryvalue);
    //printf("string lenght of registryvalue = %d\n",strlen(registryvalue) );

    if ( RegCreateKeyEx( HKEY_LOCAL_MACHINE, TEXT(DEVPATH_REGISTRY_KEY), 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hk, &dwDisp))
    {
      printf("Could not create the registry key\n");
      return 0;
    }

    if ( RegSetValueEx( hk, TEXT(DEVPATH_REGISTRY_VALUE), 0, REG_EXPAND_SZ, (LPBYTE) registryvalue, (DWORD) (lstrlen(registryvalue)+1)*sizeof(TCHAR)))
    {
      printf("Could not set the registry value for \"DevicePath\"\n");
    }
  }
  
  return 0;
}

Last edited by zookeeper (2011-03-12 06:23:39)

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

I'm sure that using a different build environment will fix that .dll dependency.  I'm not a C programmer.

Thank you very much for your contribution! smile

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

The new C program is using two Registry functions to create and set the registry key value.

These registry functions require the linking of Advapi32.lib.  I need to download the Windows SDK, which contains Advapi32.lib and it should be solved. Will let you know.

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

So you were able to prove that Devcon was having an 'overflow' issue? Cool... Perhaps we can write it in VB and not have to worry about missing DLL's? Or was VB the issue?

DP BartPE Tutorial   DP_BASE Tutorial   HWID's Tool     Read BEFORE you post    UserBars!
http://driverpacks.net/userbar/admin-1.png
The DriverPacks, the DP_Base program, and Support Forum are FREE!.

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

The problem with the requirement for the DLL has been fixed by changing the project properties to statically link the MFC runtime and also statically link AdvAPI32.lib. As a result, the new DevPath.exe does not require any additional DLLs to run.

AdvAPI32.lib is part of the Windows SDK v7.1 (Downloaded the Windows SDK and only installed the x86 libraries).  I added the one line to the code for #pragma comment(lib,"AdvAPI32.Lib").

The latest C source code for DevPath.c is posted above.

I tested the new DevPath.exe with all of the core DriverPacks and also all of the 3rd party driverpacks. It works and the registry key value is properly set without encountering a size limit.

Does anybody want the compiled DevPath.exe?  Total size is 46KB.

Unfortunately, I'm not a VB programmer.

Last edited by zookeeper (2011-02-16 09:34:05)

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

I'll compile it myself so i can vouch for the contents... big_smile!

Thanks a million this has been a nagging issue for months!

DP BartPE Tutorial   DP_BASE Tutorial   HWID's Tool     Read BEFORE you post    UserBars!
http://driverpacks.net/userbar/admin-1.png
The DriverPacks, the DP_Base program, and Support Forum are FREE!.

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

Your welcome.

If you want, I can provide you with a zip file of the Visual Studio 2010 project.

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

That would be awesome! Please do.

DP BartPE Tutorial   DP_BASE Tutorial   HWID's Tool     Read BEFORE you post    UserBars!
http://driverpacks.net/userbar/admin-1.png
The DriverPacks, the DP_Base program, and Support Forum are FREE!.

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

Download the DevPath.zip from the following SkyDrive:

link removed

NOTE: Select the "Download" link as the top left to the save DevPath.zip to your local computer.

Last edited by zookeeper (2011-03-12 06:25:17)

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

Thanks getting it now!

DP BartPE Tutorial   DP_BASE Tutorial   HWID's Tool     Read BEFORE you post    UserBars!
http://driverpacks.net/userbar/admin-1.png
The DriverPacks, the DP_Base program, and Support Forum are FREE!.

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

The code sample shown above was enhanced on 03/11/11 to handle upper and lower case filename extension (e.g.  .inf  or  .INF  or  .Inf).

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

got it, built it, seems to work

Ill get it in the next test release

DP BartPE Tutorial   DP_BASE Tutorial   HWID's Tool     Read BEFORE you post    UserBars!
http://driverpacks.net/userbar/admin-1.png
The DriverPacks, the DP_Base program, and Support Forum are FREE!.

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

That's cool... remember, though, that not all INF files are true driver files.

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

a good point... bot not really relevant... if a few non relevant paths slip through they will just be ignored when searched... shouldn't slow things down much big_smile

Nice to see ya Kickarse!

DP BartPE Tutorial   DP_BASE Tutorial   HWID's Tool     Read BEFORE you post    UserBars!
http://driverpacks.net/userbar/admin-1.png
The DriverPacks, the DP_Base program, and Support Forum are FREE!.

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

yeah... I've been hecka busy with life ... ugh...

Good to see you're still plugging along!

Is devpath any different than http://www.vernalex.com/tools/spdrvscn/ ?

Last edited by stamandster (2011-03-17 03:14:41)

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

It looks to be the same thing... except this one is ours ... big_smile

DP BartPE Tutorial   DP_BASE Tutorial   HWID's Tool     Read BEFORE you post    UserBars!
http://driverpacks.net/userbar/admin-1.png
The DriverPacks, the DP_Base program, and Support Forum are FREE!.

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

Gotcha ... perhaps as a slight improvement it might be good to add all iterations of the inf extension, as it seems it is case sensitive in its searching and in those just in case scenerios (for scanning not so perfect INFs, stuff the DP team hasn't done) --> .INF, .INf, .Inf, .iNF, .inF, .inf, .InF, .iNf -- OR somehow make it case insensitive.

Last edited by stamandster (2011-03-18 00:44:17)

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

Also, I had an idea in the resolution of the string length in the registry value ... what about adding the ability to truncate to only the required to get up and running INF types (LAN, MassStorage, CPU, etc) and then have the program wait around (or call it again) for the installation of those items and then add the rest (provided it's not over the limit and then rinse and repeat as necessary until all drivers are installed) then reboot or whatever the case is.

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

he recently updated the code to deal with case issues

if (fd->cFileName[filenamelen - 4] == '.' && (fd->cFileName[filenamelen - 3] == 'I' || fd->cFileName[filenamelen - 3] == 'i') && (fd->cFileName[filenamelen - 2] == 'N' || fd->cFileName[filenamelen - 2] == 'n') && (fd->cFileName[filenamelen - 1] == 'F' || fd->cFileName[filenamelen - 1] == 'f'))
         
that will find  .INF, .INf, .Inf, .iNF, .inF, .inf, .InF, .iNf  ect...

the path limit for xp is the max reg size value, i believe it is 64k... no worries ATM

the old devpath code had a similar issue to the one you and i had .. exceeding the buffer size of an array in the app. I think he set the buffer size in this app to 100k again no worries.

I am curious what our path length is ATM?

DP BartPE Tutorial   DP_BASE Tutorial   HWID's Tool     Read BEFORE you post    UserBars!
http://driverpacks.net/userbar/admin-1.png
The DriverPacks, the DP_Base program, and Support Forum are FREE!.

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

I think I am struggling with this issue. I already ran DriverPacks Finisher on 36 separate builds and powerpacked them. I tried removing the offending packs from the OEM folder and repacking, but no effect. I tried running DriverPacks Finisher on a fresh build and then copying the files to the powerpack OEM folder, still no effect. Do I have to start over? Posting DPs_Base.ini below. Also, I originally had all the latest drivers plus the latest 3rd party: Graphic lang, Phisx, HID, MISC, Modem, Runtimes, TV, Monitors, Bluetooth and LAN RIS. I removed Monitors, Bluetooth and LAN RIS and the problem persists. Are there any other offending packs? Thanks.

[General]
; preferred language
prefLang    = "English"
; yes/no, enable or disable the wizard-style buttons, if not specified: yes
wizardButtons    = "yes"
; yes/no, enable or disable the GUI, if not specified: yes
GUI        = "yes"


[Settings]
; disc/bartpe/multibootDisc
instPlatform    = "disc"
; trailing backslash is allowed, but not necessary
location    = "E:\Project X\XPAdvanced Pro_11_2010\dpbuild"
; none/all/select, if select, specify them below, if not specified: all
DriverPacks    = "all"
; 1/2, method to install the DriverPacks, if not specified: 2
DPsMethod    = "2"
; GUIRunOnce/RunOnceEx/custom, if not specified: GUIRunOnce
finisherMethod    = "GUIRunOnce"


; this section is optional!
[OptionalSettings]
; none/all/select/paths/patterns, enable or disable Keep The Drivers (KTD) , if not specified: none
KTD        = "false"
; <path>, to specify a custom KTD cache location, if not specified: default (%SystemRoot%\DriverPacks)
KTDlocation    = "%SystemRoot%\DriverPacks"
; yes/no, enable or disable QuickStream Cache (QSC), if not specified: yes
QSC        = "yes"

Re: DevPath.exe fails to set registry key when using a lot of driverpacks

I am sure you won't need LAN RIS.... unless you are doing RIS deployments...

Use SAD for the third party packs...

DP BartPE Tutorial   DP_BASE Tutorial   HWID's Tool     Read BEFORE you post    UserBars!
http://driverpacks.net/userbar/admin-1.png
The DriverPacks, the DP_Base program, and Support Forum are FREE!.