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