From ad935d0d04f25d963d846d7f8847fffa47ef2f9a Mon Sep 17 00:00:00 2001
From: Rob Swindell <rob@synchro.net>
Date: Thu, 2 Dec 2021 21:03:15 -0800
Subject: [PATCH] Add sbbsexec.dll project (again)

Regenerated for MSVC2019, the Synchronet virtual UART/FOSSIL driver (VDD) can be built from Visual Studio again (the makevdd.bat can probably go away now). I haven't had an MSVC project to build this DLL since the old MSVC 6.0 sbbsexec.dsp file.

A few oddities about this project:
1. xpdev files had to directly included/compiled in this project rather than linking with the xpdev_mt.lib because __stdcall calling convention is required for compatibility with ntvdm.lib and xpdev_mt.lib is built using __cdecl calling convention (the default). Rather than re-introducing the calling convention game-playing that I just recently removed (e.g. #define DLLCALL), just build the required xpdev files directly as part of this project. Perhaps there is a more elegant solution that I'll revisit later.

2. The absolute path of my install Windows 10 SDK directories had to be specified (for include and library paths) to find vdd_svc.h and ntvdm.lib. Weird thing is that I didn't have to do anything hacky like this with the command-line/batch file build method. Again, there's probably a better solution I'm not seeing. But as is, this project might not build on other systems.

So why use this rather than the brute-force batch file (makevdd.bat)? Well, this should be a little easier to get into CI/nightly builds and the resulting release build was 30KB (instead of 150KB), so that's good.

Before:
           1AA00 size of code
            AA00 size of initialized data
               0 size of uninitialized data
After:
            4C00 size of code
            2A00 size of initialized data
               0 size of uninitialized data

Those default DLL project build options include some good optimization flags apparently.
---
 src/sbbs3/sbbs3.sln        |   6 ++
 src/sbbs3/sbbsexec.vcxproj | 118 +++++++++++++++++++++++++++++++++++++
 2 files changed, 124 insertions(+)
 create mode 100644 src/sbbs3/sbbsexec.vcxproj

diff --git a/src/sbbs3/sbbs3.sln b/src/sbbs3/sbbs3.sln
index 43e18aa81e..8815ae03c1 100644
--- a/src/sbbs3/sbbs3.sln
+++ b/src/sbbs3/sbbs3.sln
@@ -86,6 +86,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fmsgdump", "fmsgdump.vcxpro
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "upgrade_to_v319", "upgrade_to_v319.vcxproj", "{B84CB739-8425-4612-BDEF-B292BEAE858F}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sbbsexec", "sbbsexec.vcxproj", "{AF4DBBF1-F99A-4DFF-8991-0B98B581151B}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Win32 = Debug|Win32
@@ -252,6 +254,10 @@ Global
 		{B84CB739-8425-4612-BDEF-B292BEAE858F}.Debug|Win32.Build.0 = Debug|Win32
 		{B84CB739-8425-4612-BDEF-B292BEAE858F}.Release|Win32.ActiveCfg = Release|Win32
 		{B84CB739-8425-4612-BDEF-B292BEAE858F}.Release|Win32.Build.0 = Release|Win32
+		{AF4DBBF1-F99A-4DFF-8991-0B98B581151B}.Debug|Win32.ActiveCfg = Debug|Win32
+		{AF4DBBF1-F99A-4DFF-8991-0B98B581151B}.Debug|Win32.Build.0 = Debug|Win32
+		{AF4DBBF1-F99A-4DFF-8991-0B98B581151B}.Release|Win32.ActiveCfg = Release|Win32
+		{AF4DBBF1-F99A-4DFF-8991-0B98B581151B}.Release|Win32.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
diff --git a/src/sbbs3/sbbsexec.vcxproj b/src/sbbs3/sbbsexec.vcxproj
new file mode 100644
index 0000000000..061b006008
--- /dev/null
+++ b/src/sbbs3/sbbsexec.vcxproj
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="..\xpdev\datewrap.c" />
+    <ClCompile Include="..\xpdev\dirwrap.c" />
+    <ClCompile Include="..\xpdev\genwrap.c" />
+    <ClCompile Include="..\xpdev\ini_file.c" />
+    <ClCompile Include="..\xpdev\semwrap.c" />
+    <ClCompile Include="..\xpdev\str_list.c" />
+    <ClCompile Include="..\xpdev\threadwrap.c" />
+    <ClCompile Include="..\xpdev\xpdatetime.c" />
+    <ClCompile Include="..\xpdev\xpprintf.c" />
+    <ClCompile Include="ringbuf.c" />
+    <ClCompile Include="sbbsexec.c" />
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <VCProjectVersion>16.0</VCProjectVersion>
+    <Keyword>Win32Proj</Keyword>
+    <ProjectGuid>{af4dbbf1-f99a-4dff-8991-0b98b581151b}</ProjectGuid>
+    <RootNamespace>sbbsexec</RootNamespace>
+    <WindowsTargetPlatformVersion>7.0</WindowsTargetPlatformVersion>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v141_xp</PlatformToolset>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v141_xp</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="Shared">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="..\xpdev\xpdev_mt.props" />
+    <Import Project="..\build\undeprecate.props" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="..\xpdev\xpdev_mt.props" />
+    <Import Project="..\build\undeprecate.props" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <LinkIncremental>true</LinkIncremental>
+    <TargetName>sbbsexec</TargetName>
+    <IncludePath>c:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared;c:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um;$(IncludePath)</IncludePath>
+    <LibraryPath>c:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x86;$(LibraryPath)</LibraryPath>
+    <OutDir>.\msvc.win32.dll.debug\</OutDir>
+    <IntDir>.\msvc.win32.debug\sbbsexec\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LinkIncremental>false</LinkIncremental>
+    <TargetName>sbbsexec</TargetName>
+    <IncludePath>c:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared;c:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um;$(IncludePath)</IncludePath>
+    <LibraryPath>c:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x86;$(LibraryPath)</LibraryPath>
+    <OutDir>.\msvc.win32.dll.release\</OutDir>
+    <IntDir>.\msvc.win32.release\sbbsexec\</IntDir>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>WIN32;i386;RINGBUF_SEM;RINGBUF_MUTEX;NO_SOCKET_SUPPORT;_DEBUG;SBBSEXEC_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <ConformanceMode>true</ConformanceMode>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+      <CallingConvention>StdCall</CallingConvention>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableUAC>false</EnableUAC>
+      <AdditionalDependencies>wsock32.lib;ntvdm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>WIN32;i386;RINGBUF_SEM;RINGBUF_MUTEX;NO_SOCKET_SUPPORT;NDEBUG;SBBSEXEC_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <ConformanceMode>true</ConformanceMode>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+      <CallingConvention>StdCall</CallingConvention>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableUAC>false</EnableUAC>
+      <AdditionalDependencies>wsock32.lib;ntvdm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file
-- 
GitLab