I do not have ubuntu/mmap protection here, could you/somebody try with a address like 0x80000.


I've run the attached test program on Windows XP SP3, Hardy Heron 8.04, and
a Debian 'Lenny' system for the memory range of 0x0 through 0x110000.

The results were that on Windows XP, you get partial reads from 0x0 to 0x10000,
and then full reads thereafter.  On Lenny, you get full reads from 0x0 on up.

On Hardy, you get full reads from 0x10000, but no partial reads at 0x0.

Therefore I now believe my patch is correct.  Note that I do not
disable the probe for sub 0x10000 in my patch; I simply avoid checking
readcount if the status from the read is not what we expect.

I've submitted it now to wine-patches; this fixes that particular
make test result for me.

Cheers,

Jeremy
#include <windows.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
    int i;
    int trymem;
    int lowmem;
    int highmem;
    char buffer[12];
    HANDLE process;
    SIZE_T readcount;
    int working = 0;
    int partial = 0;

    if (argc != 3)
    {
        fprintf(stderr, "%s low-mem high-mem\n", argv[0]);
        exit(-1);
    }


    process = OpenProcess(PROCESS_VM_READ, FALSE, GetCurrentProcessId());
    if (process == 0)
    {
        fprintf(stderr, "Error:  could not open my own process for reading\n");
        exit(-2);
    }

    sscanf(argv[1], "0x%x", &lowmem);
    sscanf(argv[2], "0x%x", &highmem);
    for (trymem = lowmem; trymem <= highmem; )
    {
        if (ReadProcessMemory(process, (void *) trymem, buffer, sizeof(buffer), &readcount))
        {
            if (! working)
                printf("0x%x: ok\n", trymem);
            working = 1;
            trymem += sizeof(buffer);
        }
        else if (GetLastError() == ERROR_PARTIAL_COPY)
        {
            if (! partial)
                printf("0x%x: partial\n", trymem);
            partial = 1;
            trymem += readcount + 1;
        }
        else
        {
            if (working)
                printf("0x%x: stop\n", trymem);
            if (partial)
                printf("0x%x: pstop\n", trymem);
            partial = 0;
            working = 0;
            trymem++;
        }
    }

    return 0;
}
0x10000: ok
0x0: ok
0x0: partial
0x10000: ok


Reply via email to