[Openvpn-devel] Strip _stdcall suffixes (@nn) for 32-bit builds

Message ID 20190101233547.10100-1-simon@rozman.si
State Accepted
Headers show
Series
  • [Openvpn-devel] Strip _stdcall suffixes (@nn) for 32-bit builds
Related show

Commit Message

Simon Rozman Jan. 1, 2019, 11:35 p.m.
This makes DLL exported function names consistent between 32 and 64-bit
builds.

Signed-off-by: Simon Rozman <simon@rozman.si>
---
 src/openvpnmsica/Makefile.am | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Gert Doering Jan. 18, 2019, 7:57 p.m. | #1
Acked-by: Gert Doering <gert@greenie.muc.de>

You really do not like this calling convention, do you?  ;-) - learned
something new today, what "-Wl,--kill-at" does...  (while the original
round of stdcall discussion was MSVC, here's the mingw variant)

Your patch has been applied to the master branch.

commit f9f1605194281a6103d889298d4f303f94bc9d96
Author: Simon Rozman
Date:   Wed Jan 2 00:35:47 2019 +0100

     Strip _stdcall suffixes (@nn) for 32-bit builds

     Signed-off-by: Simon Rozman <simon@rozman.si>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20190101233547.10100-1-simon@rozman.si>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg18077.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering
Simon Rozman Jan. 20, 2019, 2:54 p.m. | #2
Hi,

> You really do not like this calling convention, do you?  ;-) - learned
> something new today, what "-Wl,--kill-at" does...  (while the original
> round of stdcall discussion was MSVC, here's the mingw variant)

If I was importing this library into a C/C++ project, I wouldn't mind
function name decorations at all.

However, DLL exported functions are authored in MSI package by name. Having
a different name for i386 and x64 platforms would require "#ifdefs" in WiX
XML files.



I'll explain this in the developer documentation but briefly I can explain
it here already: Consider the openvpnmsica.dll as a collection of functions
(aka "Custom Actions") the MSI installer calls to perform tasks that are not
implemented by stock MSI actions.

Some functions are completely stand-alone. FindSystemInfo() and
FindTAPInterfaces() are sequenced in the MSI package to execute early. They
perform some tests MSI is too limited to do itself, and set various MSI
properties accordingly. Later, those MSI properties are used to form
conditions in MSI. Like which version of driver to install, should
OpenVPNServ be selected to install or not, etc. The CloseOpenVPNGUI() and
StartOpenVPNGUI() do just what they say immediately when called.

Then there are other functions that form an <evaluation, execute, commit,
rollback> tuple. The <EvaluateTAPInterfaces(), ProcessDeferredAction(),
ProcessDeferredAction(), ProcessDeferredAction()> is an example of those.
They are sequenced in the MSI package like this:

1. EvaluateTAPInterfaces() executes in the first pass. It runs in the
current user context and it doesn't touch computer in any way. Well, it just
prepares a list of TAP-interface-related operations to be executed and saves
it in a temporary file. The list contains operations like: "install TAP
interface X", "delete TAP interface X", "rename TAP interface X>Y", "delete
file X", etc. Operations are implemented in msica_op.h/.c.

2. ProcessDeferredAction() runs in the so called deferred MSI execution pass
run by Windows Installer service as the SYSTEM user. It loads the list of
operations from the temporary file and executes them one by one.

Let's look at a sample operation "delete file X". Normally, this operation
does not really delete the file X. It renames it to Y instead, while adding
"delete file Y" to a separate commit list tail, and inserting "move file
Y>X" to a rollback list head. Unless MSI rollback is explicitly disabled -
in this case it just deletes the file immediately and doesn't touch
commit/rollback lists.

After all operations on the list are executed, the newly created commit and
rollback operation lists are saved to separate temporary files.

3. Should the installation succeed, the MSI calls all deferred commit
actions: This time, the ProcessDeferredAction() is called with the commit
list filename as the action parameter.

Should the installation fail, the MSI calls all deferred rollback actions in
reverse order: This time, the ProcessDeferredAction() would be called with
the rollback list filename as the action parameter.

Since execution, commit and rollback list files are of the same syntax, the
same ProcessDeferredAction() function is reused. The only detail worth
noting is that when ProcessDeferredAction() detects it is run in the
commit/rollback pass it disables the MSI rollback: this makes all sequenced
operations execute immediately and no longer bother with commit/rollback
lists.




Wow, this made a nice text to start the developer documentation of MSI
setup. If it was understandable enough. :)

Regards,
Simon
Gert Doering Feb. 28, 2019, 3:31 p.m. | #3
Hi,

never replied to this one...

On Sun, Jan 20, 2019 at 02:54:01PM +0000, Simon Rozman wrote:
[..]
> Wow, this made a nice text to start the developer documentation of MSI
> setup. If it was understandable enough. :)

It was understandable and matched what I had to guess out of reading
quite a bit of code ;-) - so, yes, good start!

gert

Patch

diff --git a/src/openvpnmsica/Makefile.am b/src/openvpnmsica/Makefile.am
index f00a01d8..db8502b8 100644
--- a/src/openvpnmsica/Makefile.am
+++ b/src/openvpnmsica/Makefile.am
@@ -2,7 +2,7 @@ 
 #  openvpnmsica -- Custom Action DLL to provide OpenVPN-specific support to MSI packages
 #
 #  Copyright (C) 2002-2018 OpenVPN Inc <sales@openvpn.net>
-#  Copyright (C) 2018 Simon Rozman <simon@rozman.si>
+#  Copyright (C) 2018-2019 Simon Rozman <simon@rozman.si>
 #
 #  This program is free software; you can redistribute it and/or modify
 #  it under the terms of the GNU General Public License version 2
@@ -40,7 +40,8 @@  lib_LTLIBRARIES = libopenvpnmsica.la
 libopenvpnmsica_la_CFLAGS = \
 	-municode -D_UNICODE \
 	-UNTDDI_VERSION -U_WIN32_WINNT \
-	-D_WIN32_WINNT=_WIN32_WINNT_VISTA
+	-D_WIN32_WINNT=_WIN32_WINNT_VISTA \
+	-Wl,--kill-at
 libopenvpnmsica_la_LDFLAGS = -ladvapi32 -lole32 -lmsi -lsetupapi -liphlpapi -lshell32 -lshlwapi -lversion -no-undefined -avoid-version
 endif