kernel32: Create registry keys for available COM ports

Austin English austinenglish at gmail.com
Tue Sep 22 15:27:17 CDT 2015


On Tue, Sep 22, 2015 at 3:14 PM, André Hentschel <nerv at dawncrow.de> wrote:
> ---
>  dlls/kernel32/kernel_private.h |  3 +++
>  dlls/kernel32/oldconfig.c      | 42 +++++++++++++++++++++++++++++++++++++++---
>  dlls/kernel32/volume.c         |  2 +-
>  3 files changed, 43 insertions(+), 4 deletions(-)
>
> diff --git a/dlls/kernel32/kernel_private.h b/dlls/kernel32/kernel_private.h
> index 76611d7..9f2db22 100644
> --- a/dlls/kernel32/kernel_private.h
> +++ b/dlls/kernel32/kernel_private.h
> @@ -107,6 +107,9 @@ extern void LOCALE_InitRegistry(void) DECLSPEC_HIDDEN;
>  /* oldconfig.c */
>  extern void convert_old_config(void) DECLSPEC_HIDDEN;
>
> +/* volume.c */
> +extern char *get_dos_device_path(LPCWSTR) DECLSPEC_HIDDEN;
> +
>  /* returns directory handle for named objects */
>  extern HANDLE get_BaseNamedObjects_handle(void) DECLSPEC_HIDDEN;
>
> diff --git a/dlls/kernel32/oldconfig.c b/dlls/kernel32/oldconfig.c
> index 2c8bc18..b7f6b97 100644
> --- a/dlls/kernel32/oldconfig.c
> +++ b/dlls/kernel32/oldconfig.c
> @@ -264,8 +264,8 @@ static int SCSI_getprocentry( FILE * procfile, struct LinuxProcScsiDevice * dev
>  }
>
>
> -/* create the hardware registry branch */
> -static void create_hardware_branch(void)
> +/* create the scsi registry branch */
> +static void create_scsi_branch(void)
>  {
>      /* The following mostly will work on Linux, but should not cause
>       * problems on other systems. */
> @@ -389,6 +389,41 @@ static void create_hardware_branch(void)
>  }
>
>
> +/* create SERIALCOMM branch */
> +void create_serialcomm_branch(void)
> +{
> +    static WCHAR comW[] = {'C','O','M','1',0};
> +    UNICODE_STRING nameU;
> +    DWORD disp;
> +    HANDLE key;
> +    int i;
> +
> +    /* Ensure there is a SERIALCOMM key */
> +    if (create_key( 0, "Machine\\HARDWARE\\DEVICEMAP\\SERIALCOMM", &key, &disp )) return;
> +
> +    for (i = 1; i <= 9; i++)
> +    {
> +        char *link;
> +        int ret;
> +
> +        comW[3] = 0x30 + i;
> +        link = get_dos_device_path( comW );
> +        ret = access( link, R_OK | W_OK );
> +
> +        RtlCreateUnicodeString( &nameU, comW );
> +        if (ret)
> +            NtDeleteValueKey( key, &nameU );
> +        else
> +            NtSetValueKey( key, &nameU, 0, REG_SZ, (BYTE*)comW, sizeof(comW) );
> +        RtlFreeUnicodeString( &nameU );
> +
> +        HeapFree(GetProcessHeap(), 0, link);
> +    }
> +
> +    NtClose(key);
> +}
> +
> +
>  /***********************************************************************
>   *              convert_old_config
>   */
> @@ -400,5 +435,6 @@ void convert_old_config(void)
>      /* create some hardware keys (FIXME: should not be done here) */
>      if (create_key( 0, "Machine\\HARDWARE", &key, &disp )) return;
>      NtClose( key );
> -    if (disp != REG_OPENED_EXISTING_KEY) create_hardware_branch();
> +    if (disp != REG_OPENED_EXISTING_KEY) create_scsi_branch();
> +    create_serialcomm_branch();
>  }
> diff --git a/dlls/kernel32/volume.c b/dlls/kernel32/volume.c
> index 7a1dc11..43fbb7e 100644
> --- a/dlls/kernel32/volume.c
> +++ b/dlls/kernel32/volume.c
> @@ -99,7 +99,7 @@ static char *read_symlink( const char *path )
>  }
>
>  /* get the path of a dos device symlink in the $WINEPREFIX/dosdevices directory */
> -static char *get_dos_device_path( LPCWSTR name )
> +char *get_dos_device_path( LPCWSTR name )
>  {
>      const char *config_dir = wine_get_config_dir();
>      char *buffer, *dev;
> --
> 1.9.1

Hi Andre,

You forgot to sign off on this patch ;)

-- 
-Austin



More information about the wine-devel mailing list