Skip to content

Commit 856a939

Browse files
committed
test
1 parent 56fa227 commit 856a939

20 files changed

Lines changed: 249 additions & 130 deletions

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/build/
22
.idea/
3-
/vcpkg_installed/
43
/.vs/
54
*.vcxproj.user
65
/src/DOpusScriptingExtensions/DOpusScriptingExtensions_i.c

DOpusScriptingExtensions.sln

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Files", "Files", "{02EA681E
2222
EndProject
2323
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DOpusScriptingExtensions.ProcessHandlesService", "src\ProcessHandlesService\DOpusScriptingExtensions.ProcessHandlesService.vcxproj", "{A3FF3F77-FAFA-46A0-BB08-C020A23A5CB3}"
2424
EndProject
25-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{A3486339-82F3-4028-9953-81634C43DB95}"
26-
EndProject
27-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utils", "Utils", "{6747C6D4-F5DD-4AC9-9546-21D391C5ADE7}"
28-
ProjectSection(SolutionItems) = preProject
29-
src\Shared\Utils\Exceptions.h = src\Shared\Utils\Exceptions.h
30-
src\Shared\Utils\Logger.h = src\Shared\Utils\Logger.h
31-
src\Shared\Utils\StringUtils.h = src\Shared\Utils\StringUtils.h
32-
src\Shared\Utils\WinApiUtils.h = src\Shared\Utils\WinApiUtils.h
33-
EndProjectSection
34-
EndProject
3525
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTest", "src\UnitTest\UnitTest.vcxproj", "{A8E7502F-54A3-41E8-B1C8-B32466D256C4}"
3626
EndProject
27+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Shared", "src\Shared\Shared.vcxproj", "{476AC9A0-8D26-4C05-8232-5D61787C9BEF}"
28+
EndProject
3729
Global
3830
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3931
Debug|x64 = Debug|x64
@@ -56,14 +48,14 @@ Global
5648
{A8E7502F-54A3-41E8-B1C8-B32466D256C4}.Debug|x64.Build.0 = Debug|x64
5749
{A8E7502F-54A3-41E8-B1C8-B32466D256C4}.Release|x64.ActiveCfg = Release|x64
5850
{A8E7502F-54A3-41E8-B1C8-B32466D256C4}.Release|x64.Build.0 = Release|x64
51+
{476AC9A0-8D26-4C05-8232-5D61787C9BEF}.Debug|x64.ActiveCfg = Debug|x64
52+
{476AC9A0-8D26-4C05-8232-5D61787C9BEF}.Debug|x64.Build.0 = Debug|x64
53+
{476AC9A0-8D26-4C05-8232-5D61787C9BEF}.Release|x64.ActiveCfg = Release|x64
54+
{476AC9A0-8D26-4C05-8232-5D61787C9BEF}.Release|x64.Build.0 = Release|x64
5955
EndGlobalSection
6056
GlobalSection(SolutionProperties) = preSolution
6157
HideSolutionNode = FALSE
6258
EndGlobalSection
63-
GlobalSection(NestedProjects) = preSolution
64-
{A3486339-82F3-4028-9953-81634C43DB95} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
65-
{6747C6D4-F5DD-4AC9-9546-21D391C5ADE7} = {A3486339-82F3-4028-9953-81634C43DB95}
66-
EndGlobalSection
6759
GlobalSection(ExtensibilityGlobals) = postSolution
6860
SolutionGuid = {499071BF-D9EA-44E1-9436-41474094429D}
6961
EndGlobalSection

src/DOpusScriptingExtensions/DOpusScriptingExtensions.vcxproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
</PropertyGroup>
5050
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
5151
<ClCompile>
52-
<Optimization>Disabled</Optimization>
5352
<PreprocessorDefinitions>_WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
5453
</ClCompile>
5554
<Midl>
@@ -77,7 +76,6 @@
7776
</ItemDefinitionGroup>
7877
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
7978
<ClCompile>
80-
<Optimization>MaxSpeed</Optimization>
8179
<PreprocessorDefinitions>_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
8280
</ClCompile>
8381
<Midl>
@@ -156,8 +154,8 @@
156154
<Midl Include="DOpusScriptingExtensions.idl" />
157155
</ItemGroup>
158156
<ItemGroup>
159-
<ProjectReference Include="..\ProcessHandlesService\DOpusScriptingExtensions.ProcessHandlesService.vcxproj">
160-
<Project>{a3ff3f77-fafa-46a0-bb08-c020a23a5cb3}</Project>
157+
<ProjectReference Include="..\Shared\Shared.vcxproj">
158+
<Project>{476ac9a0-8d26-4c05-8232-5d61787c9bef}</Project>
161159
</ProjectReference>
162160
</ItemGroup>
163161
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

src/DOpusScriptingExtensions/Utils/ComUtils.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,24 @@ inline ATL::CComVariant GetPropertyValue(IDispatch& obj, const std::wstring_view
44
DISPID dispId = 0;
55
LPOLESTR lpNames[] = { const_cast<LPOLESTR>(propName.data()) };
66
THROW_IF_FAILED_MSG(
7-
obj.GetIDsOfNames(IID_NULL, lpNames, 1, LOCALE_USER_DEFAULT, &dispId),
7+
obj.GetIDsOfNames(/* riid */ IID_NULL,
8+
/* rgszNames */ lpNames,
9+
/* cNames */ 1,
10+
/* lcid */ LOCALE_USER_DEFAULT,
11+
/* rgDispId */ &dispId),
812
L"iDispatchObj doesn't have a property '{}'", propName);
913

1014
ATL::CComVariant result;
1115
DISPPARAMS dispParams = { 0 };
1216
THROW_IF_FAILED_MSG(
13-
obj.Invoke(dispId, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &dispParams, &result, NULL, NULL),
17+
obj.Invoke(/* dispIdMember */ dispId,
18+
/* riid */ IID_NULL,
19+
/* lcid */ LOCALE_USER_DEFAULT,
20+
/* wFlags */ DISPATCH_PROPERTYGET,
21+
/* pDispParams */ &dispParams,
22+
/* pVarResult */ &result,
23+
/* pExcepInfo */ NULL,
24+
/* puArgErr */ NULL),
1425
L"Failed to get the value of the property '{}'", propName);
1526

1627
return result;

src/Directory.Build.props

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<ProjectRoot>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\'))</ProjectRoot>
44
<BuildFolder>$(ProjectRoot)build\</BuildFolder>
5-
<OutputPath>$(BuildFolder)$(Platform)\$(Configuration)\$(MSBuildProjectName)\</OutputPath>
5+
<OutputPath>$(BuildFolder)$(Platform)\$(Configuration)\</OutputPath>
66
<BaseIntermediateOutputPath>$(BuildFolder)obj\$(MSBuildProjectName)\$(Platform)\$(Configuration)\</BaseIntermediateOutputPath>
77
<InstallerVersion>0.0</InstallerVersion>
88
<OutDir>$(OutputPath)</OutDir>
@@ -15,10 +15,6 @@
1515
<IncludePath>$(MSBuildThisFileDirectory);$(BuildFolder)grpc_generated;$(IncludePath)</IncludePath>
1616
</PropertyGroup>
1717

18-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
19-
<EnableASAN>true</EnableASAN>
20-
</PropertyGroup>
21-
2218
<ItemDefinitionGroup>
2319
<ClCompile>
2420
<TreatWarningAsError>true</TreatWarningAsError>
@@ -30,25 +26,26 @@
3026
<SDLCheck>true</SDLCheck>
3127
<LanguageStandard>stdcpp23</LanguageStandard>
3228
<DisableAnalyzeExternal>true</DisableAnalyzeExternal>
29+
<ExternalTemplatesDiagnostics>false</ExternalTemplatesDiagnostics>
3330

3431
<!-- Disable warnings that comes from grpc generated code:
35-
* C4702 unreachable code
36-
* C4267 conversion from 'size_t' to 'int', possible loss of data -->
37-
<DisableSpecificWarnings>4702;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
32+
* C4702 unreachable code
33+
Reason: workaround for a bug https://developercommunity.visualstudio.com/t/error:-C4702-with-external:w0/1696694
34+
-->
35+
<DisableSpecificWarnings>4702;%(DisableSpecificWarnings)</DisableSpecificWarnings>
3836
</ClCompile>
3937
</ItemDefinitionGroup>
4038

4139
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
4240
<ClCompile>
41+
<Optimization>Disabled</Optimization>
4342
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
44-
<PreprocessorDefinitions>
45-
_DISABLE_VECTOR_ANNOTATION;_DISABLE_STRING_ANNOTATION;%(PreprocessorDefinitions)
46-
</PreprocessorDefinitions>
4743
</ClCompile>
4844
</ItemDefinitionGroup>
4945

5046
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
5147
<ClCompile>
48+
<Optimization>MaxSpeed</Optimization>
5249
<WholeProgramOptimization>true</WholeProgramOptimization>
5350
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
5451
</ClCompile>

src/ProcessHandlesService/DOpusScriptingExtensions.ProcessHandlesService.vcxproj

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<Link>
4949
<SubSystem>Console</SubSystem>
5050
<GenerateDebugInformation>true</GenerateDebugInformation>
51+
<AdditionalDependencies>$(OutputPath)Shared.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
5152
</Link>
5253
</ItemDefinitionGroup>
5354
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -61,6 +62,7 @@
6162
<Link>
6263
<SubSystem>Console</SubSystem>
6364
<GenerateDebugInformation>true</GenerateDebugInformation>
65+
<AdditionalDependencies>$(OutputPath)Shared.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
6466
</Link>
6567
</ItemDefinitionGroup>
6668
<ItemGroup>
@@ -69,7 +71,7 @@
6971
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
7072
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
7173
</ClCompile>
72-
<ClInclude Include="ProcessHandlesServiceGrpcServer.h" />
74+
<ClInclude Include="ProcessHandlesServiceGrpcImpl.h" />
7375
</ItemGroup>
7476
<ItemGroup>
7577
<ClInclude Include="DevicePathToDrivePathConverter.h" />
@@ -80,31 +82,11 @@
8082
<ClInclude Include="Utils\ScopedHandle.h" />
8183
</ItemGroup>
8284
<ItemGroup>
83-
<None Include="ProcessHandlesService.proto" />
85+
<ProjectReference Include="..\Shared\Shared.vcxproj">
86+
<Project>{476ac9a0-8d26-4c05-8232-5d61787c9bef}</Project>
87+
</ProjectReference>
8488
</ItemGroup>
8589
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
8690
<ImportGroup Label="ExtensionTargets">
8791
</ImportGroup>
88-
<Target Name="ProtoCompile" BeforeTargets="PrepareForBuild" DependsOnTargets="VcpkgInstallManifestDependencies">
89-
<MakeDir Directories="$(BuildFolder)grpc_generated/gen" />
90-
<Exec Command="&quot;$(VcpkgManifestRoot)/vcpkg_installed/$(VcpkgTriplet)/$(VcpkgTriplet)/tools/protobuf/protoc&quot; --plugin=protoc-gen-grpc=&quot;$(VcpkgManifestRoot)/vcpkg_installed/$(VcpkgTriplet)/vcpkg/pkgs/grpc_x64-windows/tools/grpc/grpc_cpp_plugin.exe&quot; --proto_path=&quot;$(ProjectDir)/&quot; --cpp_out=&quot;$(BuildFolder)grpc_generated/gen&quot; --grpc_out=&quot;$(BuildFolder)grpc_generated/gen&quot; &quot;$(ProjectDir)ProcessHandlesService.proto&quot;" LogStandardErrorAsError="true" />
91-
<ItemGroup>
92-
<ClCompile Include="$(BuildFolder)grpc_generated/gen/ProcessHandlesService.pb.cc">
93-
<IncludeInUnityFile>false</IncludeInUnityFile>
94-
<PrecompiledHeader>NotUsing</PrecompiledHeader>
95-
</ClCompile>
96-
<ClCompile Include="$(BuildFolder)grpc_generated/gen/ProcessHandlesService.grpc.pb.cc">
97-
<IncludeInUnityFile>false</IncludeInUnityFile>
98-
<PrecompiledHeader>NotUsing</PrecompiledHeader>
99-
</ClCompile>
100-
<ClInclude Include="$(BuildFolder)grpc_generated/gen/ProcessHandlesService.pb.h">
101-
<IncludeInUnityFile>false</IncludeInUnityFile>
102-
<PrecompiledHeader>NotUsing</PrecompiledHeader>
103-
</ClInclude>
104-
<ClInclude Include="$(BuildFolder)grpc_generated/gen/ProcessHandlesService.grpc.pb.h">
105-
<IncludeInUnityFile>false</IncludeInUnityFile>
106-
<PrecompiledHeader>NotUsing</PrecompiledHeader>
107-
</ClInclude>
108-
</ItemGroup>
109-
</Target>
110-
</Project>
92+
</Project>

src/ProcessHandlesService/DOpusScriptingExtensions.ProcessHandlesService.vcxproj.filters

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,11 @@
1313
<ClInclude Include="LockedFilesProvider.h" />
1414
<ClInclude Include="NtDll.h" />
1515
<ClInclude Include="DevicePathToDrivePathConverter.h" />
16-
<ClInclude Include="ProcessHandlesServiceGrpcServer.h" />
16+
<ClInclude Include="ProcessHandlesServiceGrpcImpl.h" />
1717
</ItemGroup>
1818
<ItemGroup>
1919
<Filter Include="Utils">
2020
<UniqueIdentifier>{e1ad11f9-4601-48eb-9559-2c152d484b20}</UniqueIdentifier>
2121
</Filter>
2222
</ItemGroup>
23-
<ItemGroup>
24-
<None Include="ProcessHandlesService.proto" />
25-
</ItemGroup>
2623
</Project>

src/ProcessHandlesService/LockedFilesProvider.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <gen/ProcessHandlesService.pb.h>
3+
#include <grpc_generated/ProcessHandlesService.pb.h>
44
#include "Shared/Utils/StringUtils.h"
55
#include "ProcessHandlesService/ProcExp152Driver.h"
66
#include "ProcessHandlesService/NtDll.h"

src/ProcessHandlesService/NtDll.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ class NtDll final : boost::noncopyable {
5959
}
6060

6161
auto QuerySystemHandleInformation() const {
62-
const NTSTATUS STATUS_INFO_LENGTH_MISMATCH = 0xC0000004L; // Copied from ntstatus.h because "um/winnt.h" conflicts with general inclusion of "ntstatus.h"
63-
const auto SystemExtendedHandleInformation = static_cast<SYSTEM_INFORMATION_CLASS>(64);
64-
const size_t mb = 1024 * 1024;
65-
const size_t gb = mb * 1024;
62+
constexpr NTSTATUS STATUS_INFO_LENGTH_MISMATCH = 0xC0000004L; // Copied from ntstatus.h because "um/winnt.h" conflicts with general inclusion of "ntstatus.h"
63+
constexpr auto SystemExtendedHandleInformation = static_cast<SYSTEM_INFORMATION_CLASS>(64);
64+
constexpr size_t mb = 1024 * 1024;
65+
constexpr size_t gb = mb * 1024;
6666

6767
for (size_t bufSize = 32 * mb; bufSize <= gb; bufSize *= 2) {
6868
auto buf = std::make_unique_for_overwrite<std::byte[]>(bufSize);

src/ProcessHandlesService/ProcessHandlesServiceGrpcServer.h renamed to src/ProcessHandlesService/ProcessHandlesServiceGrpcImpl.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#pragma once
2-
3-
#include <gen/ProcessHandlesService.pb.h>
4-
#include <gen/ProcessHandlesService.grpc.pb.h>
2+
#include <grpc_generated/ProcessHandlesService.pb.h>
3+
#include <grpc_generated/ProcessHandlesService.grpc.pb.h>
54
#include "ProcessHandlesService/LockedFilesProvider.h"
65

7-
class ProcessHandlesServiceGrpc final : public ProcessHandlesService::ProcessHandlesServiceGrpc::Service {
6+
class ProcessHandlesServiceGrpcImpl final : public ProcessHandlesService::ProcessHandlesServiceGrpc::Service {
87
LockedFilesProvider _lockedFilesProvider;
98

109
public:

0 commit comments

Comments
 (0)