RegEnumValue WOW Bug

Discussion in 'Windows 64bit' started by =?Utf-8?B?TWFnbnVtTWFu?=, Aug 30, 2005.

  1. I'm finding that the "value length" in/out parameter to RegEnumValue does not
    work properly when called from a 32-bit application that is spawned from
    another 32-bit application. I have a very simple test case that succeeds in
    2 ways and fails in one; same executable, different shell:

    CMD.EXE (64-bit): PASS
    cygwin bash (32-bit): PASS (I suspect it uses system() or something though
    and may spawn a 64-bit CMD then run the program?)
    4NT 5.00U: FAIL

    Here is the source code for my test program. When I run it under the 4NT
    shell, the argument "lpcValueName" defned in the Platform SDK Docs, I pass in
    256 and receive back 256 even though the returned length of lpValueName is
    actually 10 (or 11, I can't remember which). I'm using Visual Studio 2003
    C++ and the April 2005 Platform SDK for Win2k3 SP1, set to /SVR /32.

    #include <Windows.h>
    #include <stdio.h>
    #include <assert.h>

    int main(void)
    {
    HKEY key;
    assert(RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\DirectMusic",
    0, KEY_ALL_ACCESS, &key) == ERROR_SUCCESS);
    printf("Opened HKLM/Software/Microsoft/DirectMusic, enumerating values\n");

    for (DWORD i = 0; ; ++i) {
    char valname[256];
    DWORD valnamelen = 256;
    DWORD type;
    BYTE value[256];
    DWORD valuelen = 256;
    memset(valname, 0, 256);
    memset(value, 0, 256);

    DWORD status = RegEnumValue(key, i, valname, &valnamelen, 0, &type, value,
    &valuelen);
    if (status == ERROR_NO_MORE_ITEMS)
    break;

    printf(" status = %d\n", status );
    assert(status == ERROR_SUCCESS);

    printf(" valname = %s\n", valname );
    printf(" strlen = %d\n", strlen(valname ));
    printf(" valnamelen = %d\n", valnamelen);
    printf(" value = %s\n", value);
    printf(" strlen = %d\n", strlen((char *)value));
    printf(" valuelen = %d\n", valuelen);
    assert(strlen(valname) == valnamelen); // on Win64 in 32 bit mode, this is
    always what you pass in... on Win32 it's fine
    printf("\n");
    }

    assert(RegCloseKey(key) == ERROR_SUCCESS);
    return 0;
    }
     
    =?Utf-8?B?TWFnbnVtTWFu?=, Aug 30, 2005
    #1
    1. Advertising

  2. I tried test code below but couldn't see the results you have seen.
    Can you run 32bit cmd.exe (\windows\syswow64\cmd.exe) then run the test
    program to see if it is really about having a 32bit parent process?
    Also does this happen on 4nt6 as well?
    my guess the problem might be with the 4nt5 itself.

    "MagnumMan" wrote:

    > I'm finding that the "value length" in/out parameter to RegEnumValue does not
    > work properly when called from a 32-bit application that is spawned from
    > another 32-bit application. I have a very simple test case that succeeds in
    > 2 ways and fails in one; same executable, different shell:
    >
    > CMD.EXE (64-bit): PASS
    > cygwin bash (32-bit): PASS (I suspect it uses system() or something though
    > and may spawn a 64-bit CMD then run the program?)
    > 4NT 5.00U: FAIL
    >
    > Here is the source code for my test program. When I run it under the 4NT
    > shell, the argument "lpcValueName" defned in the Platform SDK Docs, I pass in
    > 256 and receive back 256 even though the returned length of lpValueName is
    > actually 10 (or 11, I can't remember which). I'm using Visual Studio 2003
    > C++ and the April 2005 Platform SDK for Win2k3 SP1, set to /SVR /32.
    >
    > #include <Windows.h>
    > #include <stdio.h>
    > #include <assert.h>
    >
    > int main(void)
    > {
    > HKEY key;
    > assert(RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\DirectMusic",
    > 0, KEY_ALL_ACCESS, &key) == ERROR_SUCCESS);
    > printf("Opened HKLM/Software/Microsoft/DirectMusic, enumerating values\n");
    >
    > for (DWORD i = 0; ; ++i) {
    > char valname[256];
    > DWORD valnamelen = 256;
    > DWORD type;
    > BYTE value[256];
    > DWORD valuelen = 256;
    > memset(valname, 0, 256);
    > memset(value, 0, 256);
    >
    > DWORD status = RegEnumValue(key, i, valname, &valnamelen, 0, &type, value,
    > &valuelen);
    > if (status == ERROR_NO_MORE_ITEMS)
    > break;
    >
    > printf(" status = %d\n", status );
    > assert(status == ERROR_SUCCESS);
    >
    > printf(" valname = %s\n", valname );
    > printf(" strlen = %d\n", strlen(valname ));
    > printf(" valnamelen = %d\n", valnamelen);
    > printf(" value = %s\n", value);
    > printf(" strlen = %d\n", strlen((char *)value));
    > printf(" valuelen = %d\n", valuelen);
    > assert(strlen(valname) == valnamelen); // on Win64 in 32 bit mode, this is
    > always what you pass in... on Win32 it's fine
    > printf("\n");
    > }
    >
    > assert(RegCloseKey(key) == ERROR_SUCCESS);
    > return 0;
    > }
    >
    >
     
    =?Utf-8?B?dGFoc2lu?=, Aug 30, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Frisbee®

    OT: Wow... just wow.

    Frisbee®, Jun 30, 2005, in forum: MCSE
    Replies:
    35
    Views:
    1,141
  2. Neil

    OT: wow, just wow

    Neil, Aug 19, 2005, in forum: MCSE
    Replies:
    13
    Views:
    812
    Mike T.
    Aug 20, 2005
  3. smiley

    wow, just.. wow

    smiley, Jan 21, 2004, in forum: Computer Support
    Replies:
    7
    Views:
    584
    Duncan Ham
    Jan 23, 2004
  4. janet_princess_2k
    Replies:
    0
    Views:
    531
    janet_princess_2k
    Aug 9, 2006
  5. A bug catalogue for bug lovers!

    , Sep 16, 2005, in forum: Digital Photography
    Replies:
    4
    Views:
    573
Loading...

Share This Page