From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id DF769385E008 for ; Wed, 25 Mar 2020 14:23:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DF769385E008 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [10.0.0.11] (unknown [192.222.164.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 81EEE1E60C; Wed, 25 Mar 2020 10:23:42 -0400 (EDT) Subject: Re: [PATCH v2] Fix WOW64 process system DLL paths To: Hannes Domani , Gdb-patches References: <20200324192351.3904-1-ssbssa.ref@yahoo.de> <20200324192351.3904-1-ssbssa@yahoo.de> <6fcfc7b1-5b1d-1bca-5bd8-06b075d626e6@simark.ca> <840438313.3764470.1585146130281@mail.yahoo.com> From: Simon Marchi Message-ID: <1d7bb2df-1f3e-9ff7-ea38-05db350192d2@simark.ca> Date: Wed, 25 Mar 2020 10:23:41 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <840438313.3764470.1585146130281@mail.yahoo.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US-large Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-15.1 required=5.0 tests=BAYES_00, BODY_8BITS, GARBLED_BODY, GIT_PATCH_2, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Mar 2020 14:23:45 -0000 On 2020-03-25 10:22 a.m., Hannes Domani via Gdb-patches wrote: > Am Mittwoch, 25. März 2020, 15:04:44 MEZ hat Simon Marchi Folgendes geschrieben: > >> On 2020-03-24 3:23 p.m., Hannes Domani via Gdb-patches wrote: >> >>> GetModuleFileNameEx returns for some DLLs of WOW64 processes >>> the path inside the 64bit system directory instead of the 32bit >>> syswow64 directory. >>> >>> Problem happens e.g. with dbghelp.dll: >>> >>> (gdb) start >>> Temporary breakpoint 1 at 0x415a00: file fiber.cpp, line 430. >>> Starting program: C:\src\tests\fiber.exe >>> warning: `C:\Windows\system32\dbghelp.dll': Shared library architecture i386:x86-64 is not compatible with target architecture i386. >>> >>> Temporary breakpoint 1, main () at fiber.cpp:430 >>> 430    { >>> (gdb) info sharedlibrary >>> From        To          Syms Read  Shared Object Library >>> 0x77070000  0x771d4d20  Yes (*)    C:\Windows\SysWOW64\ntdll.dll >>> 0x74dc0000  0x74ebad9c  Yes (*)    C:\Windows\syswow64\kernel32.dll >>> 0x75341000  0x75386a18  Yes (*)    C:\Windows\syswow64\KernelBase.dll >>> 0x6f6a1000  0x6f7c48fc  Yes (*)    C:\Windows\system32\dbghelp.dll >>> 0x74d01000  0x74dab2c4  Yes (*)    C:\Windows\syswow64\msvcrt.dll >>> (*): Shared library is missing debugging information. >>> >>> This detects this situation and converts the DLL path to the >>> syswow64 equivalent. >>> >>> gdb/ChangeLog: >>> >>> 2020-03-24  Hannes Domani  >>> >>>      * windows-nat.c (windows_add_all_dlls): Fix system dll paths. >>> --- >>> v2: >>> - added error check with gdb_assert's >>> - use std::string for newly assembled dll path >> >> >> Btw, I found this Stack Overflow question that seems to be about this exact >> problem (which you may have already found too if you researched the topic), >> but honestly I don't understand a thing from the answer. >> >>    https://stackoverflow.com/questions/46403532/getmodulefilenameex-on-32bit-process-from-64bit-process-on-windows-10 > > Yes, I did see this when I googled this problem. > Basically, if you use GetMappedFileName instead of GetModuleFileNameEx, you > get the correct path (I tested this also), but it's returned in the nt-path > format: > \Device\HarddiskVolume9\Windows\SysWOW64\dbghelp.dll > > Which you then have to convert to the "normal" path every one else expects. > But I figured my way with GetSystemWow64Directory is simpler. > > > Is the v2 OK to commit? Yes, thanks. Simon