From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from fencepost.gnu.org (fencepost.gnu.org [IPv6:2001:470:142:3::e]) by sourceware.org (Postfix) with ESMTPS id 9151C3858C29; Sun, 7 Jan 2024 17:03:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9151C3858C29 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9151C3858C29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:142:3::e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704647039; cv=none; b=CG0Q1NPtrh3KDYvF+hYUusGrrkKfpnQRNWyMQ36j124tyN4kPXYK9TlO8TqgYWfmGXV5HTjD8yB2VIFXHM7I1Zx6h1z0RZiWTSNNKVlvXZp/j5GANJpITOmGfZc6tdk/1/LH8LaJq5AL7X2sOG662B6BSZT8DH3hUMmlss3cyAs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704647039; c=relaxed/simple; bh=Uk4IyNVb9kNskBYTfm/RMD8ggrnSnazX67/jayUNWqQ=; h=DKIM-Signature:Date:Message-Id:From:To:Subject:MIME-version; b=Fl4fxn114hsWJGPvRpQ9x5BD6FseE48dvC8i3XxQwkBbs974VsVkNJHsBME2MG3yD16FiVz1C4XEfFLJR25kkgfSOYSDBBc+f+7/PaKtFvOKTHxN7TvNl3UhNXZczWv2JeuNj3Pen1DAd19ees/3cW8SbFai6pXwJ2/h+zIHDTg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=DlhoSOy1AnUDa6wVwVZDCcCrHQmgWib2xgicG50oinQ=; b=EydgDinPvpoL3Luesunz +ZnxXyPxfXK0q4ZYVaiBcKi1cUOYe+QeQWeqs6llQsrJdDRjzUXneshMxcQAhg0TPbLMb4yh0lSvX 1hddveruNsEzZH3kFsdQb3kNwEByeKS9yC0MbBRQXaGOyJ2jkP7HO+zPcYh/FbgCiw9Go9QdLhAbB dR48A4qHuyVyI1EWpcQGTAIoHI0SmDWgtglCdW0PaKTwoqzh9cjVoVZeRdB8VLEZ0ZhoijmFtJGX6 Y0SSWigKd9dD2e0R4FVteFbysvLqwVlTVePy3y0svUha2ouIHumTTpThKBdPATdZRm/amLV9etti6 tZYadtyJ1LXZcg==; Date: Sun, 07 Jan 2024 19:03:50 +0200 Message-Id: <83msthqdmx.fsf@gnu.org> From: Eli Zaretskii To: =?utf-8?Q?Bj=C3=B6rn_Sch=C3=A4pers?= Cc: iant@google.com, gcc-patches@gcc.gnu.org, gcc@gcc.gnu.org In-Reply-To: <4630f8bb-5859-483e-9db3-e09e4cb46ecf@hazardy.de> (message from =?utf-8?Q?Bj=C3=B6rn_Sch=C3=A4pers?= on Sun, 7 Jan 2024 17:07:06 +0100) Subject: Re: [PATCH 6/4] libbacktrace: Add loaded dlls after initialize References: <20230120105409.54949-1-gcc@hazardy.de> <20230120105409.54949-4-gcc@hazardy.de> <0c08e584-499f-473f-8699-a41c6a967536@hazardy.de> <863fd658-11e9-455e-9def-8a95217bc98f@hazardy.de> <83bk9xsklk.fsf@gnu.org> <4cb3a2a5-c0b3-40c8-b460-f21d65a9aea2@hazardy.de> <83ttnpqk0g.fsf@gnu.org> <4630f8bb-5859-483e-9db3-e09e4cb46ecf@hazardy.de> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > Date: Sun, 7 Jan 2024 17:07:06 +0100 > Cc: iant@google.com, gcc-patches@gcc.gnu.org, gcc@gcc.gnu.org > From: Björn Schäpers > > > That was about GetModuleHandle, not about GetModuleHandleEx. For the > > latter, all Windows versions that support it also support "wide" APIs. > > So my suggestion is to use GetModuleHandleExW here. However, you will > > need to make sure that notification_data->dll_base is declared as > > 'wchar_t *', not 'char *'. If dll_base is declared as 'char *', then > > only GetModuleHandleExA will work, and you will lose the ability to > > support file names with non-ASCII characters outside of the current > > system codepage. > > The dll_base is a PVOID. With the GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS flag > GetModuleHandleEx does not look for a name, but uses an adress in the module to > get the HMODULE, so you cast it to char* or wchar_t* depending on which function > you call. Actually one could just cast the dll_base to HMODULE, at least in > win32 on x86 the HMODULE of a dll is always its base adress. But to make it > safer and future proof I went the way through GetModuleHandeEx. In that case, you an call either GetModuleHandeExA or GetModuleHandeExW, the difference is minor.