[PATCH 1/2] wpcap: Implement pcap_dump_open and pcap_dump

Jianqiu Zhang zhangjianqiu_133 at yeah.net
Wed Feb 10 07:59:34 CST 2016


Hi, sorry for the late reply

I have met some problem when implementing wine_pcap_dump_open 
My wine_pcap_dump_open code goes like this

--snip--

pcap_dumper_t* CDECL wine_pcap_dump_open(pcap_t *p, const char *fname)
{
    UNICODE_STRING nt_name, dospathW;
    ANSI_STRING fname_dos;
    ANSI_STRING fname_unix;
    int res;
    fname_unix.Buffer = NULL;
    RtlInitAnsiString(&fname_dos, fname);
    RtlInitAnsiString(&fname_unix, NULL);
    res = RtlAnsiStringToUnicodeString(&dospathW, &fname_dos, TRUE);
    res = RtlDosPathNameToNtPathName_U(dospathW.Buffer, &nt_name, NULL, NULL);
    if(!res)
    {
        printf("RtlDosPathNameToNtPathName_U failed\n");
        return NULL;
    }
    res  = wine_nt_to_unix_file_name(&nt_name, &fname_unix, FILE_OPEN_IF, FALSE);
    printf("#1 ERRCODE is %X\n", GetLastError());
    printf("VOID_DEBUG: Nt FileName is %s\n", wine_dbgstr_w(nt_name.Buffer));
    if(res != 0 && res != 0xC000000F)
    {
        SetLastError(0xB7);
        printf("wine_nt_to_unix_file_name failed\n");
        printf("#2 ERRCODE is %X\n", GetLastError());
        return NULL;
    }
    RtlFreeUnicodeString(&nt_name);
    printf("#3 ERRCODE is %X\n", GetLastError());
    RtlFreeAnsiString(&fname_dos);
    //HeapFree(GetProcessHeap(), 0, fname_dos.Buffer);
    printf("#4 ERRCODE is %X\n", GetLastError());
    //SetLastError(0xB7);
    return pcap_dump_open(p, fname_unix.Buffer);
}

--snip--

And I modify the test program source code , the source is attached in the attachment(test.c)

And I run the same test both on win32(XP) and wine , Below are my tests:

1. test.exe "AFileNameDoesNotExist" on wine it gets errorcode 0x57 on Windows it gets errorcode 0x00, Both get the correct dumpfile
2. test.exe "NameThatExists" on wine it gets errorcode 0x57, on windows it gets errorcode 0xB7, both overwrite the previous file and get the correct dumpfile

And I dig into the code found RtlFreeAnsiString calls two functions RtlFreeHeap and RtlZeroMemory both give the errorcode 0x57(ERROR_INVALID_PARAMETER) , I wonder why this happens
If it's a undefined behavior, can I use SetLastError(0) to Manually reset the error code? Thanks in advance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20160210/59ae36c1/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.c
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20160210/59ae36c1/attachment.c>


More information about the wine-devel mailing list