duncanthrax / scream

Virtual network sound card for Microsoft Windows
Microsoft Public License
1.74k stars 145 forks source link

Issues building in 32bit mode #133

Open andyclegg opened 3 years ago

andyclegg commented 3 years ago

I can successfully build the driver in Visual Studio 2019 targeting x64, but when I set the target platform to Win32 in order to support a 32-bit machine, I get a whole load of linker errors. Any input into getting this building would be greatly appreciated. Thanks

Build started...
------ Build started: Project: Scream, Configuration: Win8.1 Release Win32 ------
Building 'Scream' with toolset 'WindowsKernelModeDriver10.0' and the 'Desktop' target platform.
Stamping Win8.1Release\Scream.inf
Stamping [Version] section with DriverVer=03/30/2021,15.46.17.151
C:\Users\andy\Documents\scream-master-01\Scream\Scream.inf(1-1): warning 1324: [Version] section should specify PnpLockdown=1.
adapter.obj : error LNK2019: unresolved external symbol __imp__PcInitializeAdapterDriver@12 referenced in function _DriverEntry@8
adapter.obj : error LNK2019: unresolved external symbol __imp__PcAddAdapterDevice@20 referenced in function "long __stdcall AddDevice(struct _DRIVER_OBJECT *,struct _DEVICE_OBJECT *)" (?AddDevice@@YGJPAU_DRIVER_OBJECT@@PAU_DEVICE_OBJECT@@@Z)
adapter.obj : error LNK2019: unresolved external symbol __imp__PcRegisterSubdevice@12 referenced in function "long __stdcall InstallSubdevice(struct _DEVICE_OBJECT *,struct _IRP *,unsigned short *,struct _GUID const &,struct _GUID const &,long (__stdcall*)(struct IUnknown * *,struct _GUID const &,struct IUnknown *,enum _POOL_TYPE),struct IUnknown *,struct IResourceList *,struct _GUID const &,struct IUnknown * *,struct IUnknown * *)" (?InstallSubdevice@@YGJPAU_DEVICE_OBJECT@@PAU_IRP@@PAGABU_GUID@@3P6GJPAPAUIUnknown@@3PAU4@W4_POOL_TYPE@@@Z5PAUIResourceList@@344@Z)
adapter.obj : error LNK2019: unresolved external symbol __imp__PcRegisterPhysicalConnection@20 referenced in function "long __stdcall StartDevice(struct _DEVICE_OBJECT *,struct _IRP *,struct IResourceList *)" (?StartDevice@@YGJPAU_DEVICE_OBJECT@@PAU_IRP@@PAUIResourceList@@@Z)
adapter.obj : error LNK2019: unresolved external symbol __imp__PcNewPort@8 referenced in function "long __stdcall InstallSubdevice(struct _DEVICE_OBJECT *,struct _IRP *,unsigned short *,struct _GUID const &,struct _GUID const &,long (__stdcall*)(struct IUnknown * *,struct _GUID const &,struct IUnknown *,enum _POOL_TYPE),struct IUnknown *,struct IResourceList *,struct _GUID const &,struct IUnknown * *,struct IUnknown * *)" (?InstallSubdevice@@YGJPAU_DEVICE_OBJECT@@PAU_IRP@@PAGABU_GUID@@3P6GJPAPAUIUnknown@@3PAU4@W4_POOL_TYPE@@@Z5PAUIResourceList@@344@Z)
adapter.obj : error LNK2019: unresolved external symbol __imp__PcNewMiniport@8 referenced in function "long __stdcall InstallSubdevice(struct _DEVICE_OBJECT *,struct _IRP *,unsigned short *,struct _GUID const &,struct _GUID const &,long (__stdcall*)(struct IUnknown * *,struct _GUID const &,struct IUnknown *,enum _POOL_TYPE),struct IUnknown *,struct IResourceList *,struct _GUID const &,struct IUnknown * *,struct IUnknown * *)" (?InstallSubdevice@@YGJPAU_DEVICE_OBJECT@@PAU_IRP@@PAGABU_GUID@@3P6GJPAPAUIUnknown@@3PAU4@W4_POOL_TYPE@@@Z5PAUIResourceList@@344@Z)
adapter.obj : error LNK2019: unresolved external symbol __imp__PcRegisterAdapterPowerManagement@8 referenced in function "long __stdcall StartDevice(struct _DEVICE_OBJECT *,struct _IRP *,struct IResourceList *)" (?StartDevice@@YGJPAU_DEVICE_OBJECT@@PAU_IRP@@PAUIResourceList@@@Z)
common.obj : error LNK2019: unresolved external symbol "public: __thiscall CUnknown::CUnknown(struct IUnknown *)" (??0CUnknown@@QAE@PAUIUnknown@@@Z) referenced in function "public: __thiscall CAdapterCommon::CAdapterCommon(struct IUnknown *)" (??0CAdapterCommon@@QAE@PAUIUnknown@@@Z)
minstream.obj : error LNK2001: unresolved external symbol "public: __thiscall CUnknown::CUnknown(struct IUnknown *)" (??0CUnknown@@QAE@PAUIUnknown@@@Z)
mintopo.obj : error LNK2001: unresolved external symbol "public: __thiscall CUnknown::CUnknown(struct IUnknown *)" (??0CUnknown@@QAE@PAUIUnknown@@@Z)
minwave.obj : error LNK2001: unresolved external symbol "public: __thiscall CUnknown::CUnknown(struct IUnknown *)" (??0CUnknown@@QAE@PAUIUnknown@@@Z)
common.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall CUnknown::~CUnknown(void)" (??1CUnknown@@UAE@XZ) referenced in function "public: virtual __thiscall CAdapterCommon::~CAdapterCommon(void)" (??1CAdapterCommon@@UAE@XZ)
minstream.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall CUnknown::~CUnknown(void)" (??1CUnknown@@UAE@XZ)
mintopo.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall CUnknown::~CUnknown(void)" (??1CUnknown@@UAE@XZ)
minwave.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall CUnknown::~CUnknown(void)" (??1CUnknown@@UAE@XZ)
common.obj : error LNK2001: unresolved external symbol "public: virtual unsigned long __stdcall CUnknown::NonDelegatingAddRef(void)" (?NonDelegatingAddRef@CUnknown@@UAGKXZ)
minstream.obj : error LNK2001: unresolved external symbol "public: virtual unsigned long __stdcall CUnknown::NonDelegatingAddRef(void)" (?NonDelegatingAddRef@CUnknown@@UAGKXZ)
mintopo.obj : error LNK2001: unresolved external symbol "public: virtual unsigned long __stdcall CUnknown::NonDelegatingAddRef(void)" (?NonDelegatingAddRef@CUnknown@@UAGKXZ)
minwave.obj : error LNK2001: unresolved external symbol "public: virtual unsigned long __stdcall CUnknown::NonDelegatingAddRef(void)" (?NonDelegatingAddRef@CUnknown@@UAGKXZ)
common.obj : error LNK2001: unresolved external symbol "public: virtual unsigned long __stdcall CUnknown::NonDelegatingRelease(void)" (?NonDelegatingRelease@CUnknown@@UAGKXZ)
minstream.obj : error LNK2001: unresolved external symbol "public: virtual unsigned long __stdcall CUnknown::NonDelegatingRelease(void)" (?NonDelegatingRelease@CUnknown@@UAGKXZ)
mintopo.obj : error LNK2001: unresolved external symbol "public: virtual unsigned long __stdcall CUnknown::NonDelegatingRelease(void)" (?NonDelegatingRelease@CUnknown@@UAGKXZ)
minwave.obj : error LNK2001: unresolved external symbol "public: virtual unsigned long __stdcall CUnknown::NonDelegatingRelease(void)" (?NonDelegatingRelease@CUnknown@@UAGKXZ)
minwave.obj : error LNK2019: unresolved external symbol __imp__PcNewServiceGroup@8 referenced in function "public: virtual long __stdcall CMiniportWaveCyclic::Init(struct IUnknown *,struct IResourceList *,struct IPortWaveCyclic *)" (?Init@CMiniportWaveCyclic@@UAGJPAUIUnknown@@PAUIResourceList@@PAUIPortWaveCyclic@@@Z)
savedata.obj : error LNK2019: unresolved external symbol _WskRegister@8 referenced in function "public: __thiscall CSaveData::CSaveData(void)" (??0CSaveData@@QAE@XZ)
savedata.obj : error LNK2019: unresolved external symbol _WskCaptureProviderNPI@12 referenced in function "private: void __thiscall CSaveData::CreateSocket(void)" (?CreateSocket@CSaveData@@AAEXXZ)
savedata.obj : error LNK2019: unresolved external symbol _WskReleaseProviderNPI@4 referenced in function "private: void __thiscall CSaveData::CreateSocket(void)" (?CreateSocket@CSaveData@@AAEXXZ)
savedata.obj : error LNK2019: unresolved external symbol _WskDeregister@4 referenced in function "public: __thiscall CSaveData::~CSaveData(void)" (??1CSaveData@@QAE@XZ)
C:\Users\zynstra\Documents\scream-master-01\Win8.1Release\Scream.sys : fatal error LNK1120: 16 unresolved externals
Done building project "Scream.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
duncanthrax commented 3 years ago

I never built a win32 variant. I just tried it and get the same symptoms, so this isn't just your machine. When you installed WDK, was there an option to install both x86 and x64 variants?

andyclegg commented 3 years ago

Thanks for trying - was good to know it wasn't just me! After trying a bit more I got it to compile and install by making two changes -

  1. Added C:\Program Files\Windows Kits\10\Lib\10.0.19041.0\km\x86*.lib to Linker>Input>Additional dependencies
  2. After building, manually edited Scream.inf to replace NTAMD64 with NTx86 in two places.

This installs successfully, however I've now come across another issue - the sound quality is really bad. It sounds really clipped and distorted. I wonder if there might be any places in the code where it uses architecture-dependent variable sizes, such that a 32-bit sample might now be stored in a 16-bit variable?

andyclegg commented 3 years ago

After more testing, I changed Scream to use Unicast and the sound quality improved a lot. I now suspect that it's VirtualBox dropping packets.

Related to previous, one more change I needed for a successful install was to substitute in the x86 version of devcon.exe.

gabrielstedman commented 3 years ago

The following enabled me to build a x86 release from a x64 machine and the inf sections missing to be able to install.
Thank you @andyclegg for your useful notes.
Let me know if you want a PR

diff --git a/Scream/Scream.inf b/Scream/Scream.inf
index 4ed033e..789d846 100644
--- a/Scream/Scream.inf
+++ b/Scream/Scream.inf
@@ -13,11 +13,14 @@ CatalogFile=scream.cat
 scream.sys=222

 [Manufacturer]
-%MfgName%=MicrosoftDS,NTAMD64
+%MfgName%=MicrosoftDS,NTAMD64,NTx86

 [MicrosoftDS.NTAMD64]
 %Scream.DeviceDesc%=Scream,*Scream

+[MicrosoftDS.NTx86]
+%Scream.DeviceDesc%=Scream,*Scream
+
 [DestinationDirs]
 Scream.CopyList=10,system32\drivers

diff --git a/Scream/Scream.vcxproj b/Scream/Scream.vcxproj
index a176775..4a98444 100644
--- a/Scream/Scream.vcxproj
+++ b/Scream/Scream.vcxproj
@@ -221,6 +221,16 @@
       <DisableSpecificWarnings>4228;4603;4627;4986;4987;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
     </ClCompile>
   </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Win7 Release|Win32'">
+    <ClCompile>
+      <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)\C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0</AdditionalIncludeDirectories>
+    </ClCompile>
+    <Link>
+      <AdditionalDependencies>%(AdditionalDependencies);$(KernelBufferOverflowLib);$(DDK_LIB_PATH)ntoskrnl.lib;$(DDK_LIB_PATH)hal.lib;$(DDK_LIB_PATH)wmilib.lib;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\km\x86\*.lib</AdditionalDependencies>
+      <AdditionalLibraryDirectories>
+      </AdditionalLibraryDirectories>
+    </Link>
+  </ItemDefinitionGroup>
   <ItemGroup>
     <Inf Include="Scream.inf" />
   </ItemGroup>
duncanthrax commented 3 years ago

32 bit signed build now up with 3.8 release.