diff --git a/build/ClrInstrumentationEngine.cpp.props b/build/ClrInstrumentationEngine.cpp.props
index 7bd35934..903c0e65 100644
--- a/build/ClrInstrumentationEngine.cpp.props
+++ b/build/ClrInstrumentationEngine.cpp.props
@@ -17,4 +17,28 @@
/SafeSEH %(AdditionalOptions)
+
+
+
+ /wd25007 /wd25021 /wd25031 /wd25046 /wd25090 /wd25129 /wd25164 /wd25165 /wd25166
+
+
+
+
+ %(AdditionalOptions) $(CodeAnalysisWarningsToDisable)
+
+
\ No newline at end of file
diff --git a/build/yaml/jobs/codeanalysis/PolicheckExclusion.xml b/build/yaml/jobs/codeanalysis/PolicheckExclusion.xml
new file mode 100644
index 00000000..5fd04548
--- /dev/null
+++ b/build/yaml/jobs/codeanalysis/PolicheckExclusion.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ CODESIGNVERIFY.YAML
+
+
\ No newline at end of file
diff --git a/build/yaml/jobs/codeanalysis/apiscan.yaml b/build/yaml/jobs/codeanalysis/apiscan.yaml
index 70d9acdc..63342f98 100644
--- a/build/yaml/jobs/codeanalysis/apiscan.yaml
+++ b/build/yaml/jobs/codeanalysis/apiscan.yaml
@@ -17,9 +17,9 @@ jobs:
workspace:
clean: all
-
steps:
- - checkout: none
+ - checkout: self
+ clean: true
- task: DownloadBuildArtifacts@0
displayName: Download Windows Files (Release)
@@ -45,7 +45,6 @@ jobs:
TargetFolder: '$(Build.ArtifactStagingDirectory)\ApiScan'
# Run API Scan
-
- task: securedevelopmentteam.vss-secure-development-tools.build-task-apiscan.APIScan@2
displayName: 'Run APIScan'
inputs:
diff --git a/build/yaml/jobs/codeanalysis/binskim.yaml b/build/yaml/jobs/codeanalysis/binskim.yaml
index 173882aa..6a1323a2 100644
--- a/build/yaml/jobs/codeanalysis/binskim.yaml
+++ b/build/yaml/jobs/codeanalysis/binskim.yaml
@@ -17,7 +17,8 @@ jobs:
clean: all
steps:
- - checkout: none
+ - checkout: self
+ clean: true
- task: DownloadBuildArtifacts@0
displayName: Download Windows Files (Release)
diff --git a/build/yaml/jobs/codeanalysis/policheck.yaml b/build/yaml/jobs/codeanalysis/policheck.yaml
index cbabd265..d0655302 100644
--- a/build/yaml/jobs/codeanalysis/policheck.yaml
+++ b/build/yaml/jobs/codeanalysis/policheck.yaml
@@ -24,6 +24,7 @@ jobs:
inputs:
targetType: F
optionsFC: 1
+ optionsUEPATH: $(Build.SourcesDirectory)\build\yaml\jobs\codeanalysis\PolicheckExclusion.xml
continueOnError: true
# Publish SecurityAnalysis Logs
diff --git a/build/yaml/steps/codeanalysis/baseline.gdnbaselines b/build/yaml/steps/codeanalysis/baseline.gdnbaselines
new file mode 100644
index 00000000..3ae23684
--- /dev/null
+++ b/build/yaml/steps/codeanalysis/baseline.gdnbaselines
@@ -0,0 +1,168 @@
+{
+ "version": "1.0.0",
+ "baselines": {
+ "ApiScanBaseline": {
+ "name": "ApiScanBaseline",
+ "createdDate": "2020-11-06 18:31:35Z",
+ "lastUpdatedDate": "2020-11-06 18:31:35Z"
+ }
+ },
+ "results": {
+ "f9161db938b600dbc540052744fb9f56b4ddb189fa8af2dd3d1440ed877aba27": {
+ "signature": "f9161db938b600dbc540052744fb9f56b4ddb189fa8af2dd3d1440ed877aba27",
+ "target": "x64/instrumentationengine.profilerproxy_x64.dll",
+ "memberOf": [
+ "ApiScanBaseline"
+ ],
+ "tool": "APIScanCmd",
+ "ruleId": "unpublisheddependency",
+ "justification": null,
+ "createdDate": "2020-11-06 18:31:35Z",
+ "expirationDate": null,
+ "type": null
+ },
+ "a4f38aba45c6d1cb052b3325324f13734f9556a7ea3a7291b5a56659dedc6ac7": {
+ "signature": "a4f38aba45c6d1cb052b3325324f13734f9556a7ea3a7291b5a56659dedc6ac7",
+ "target": "x64/instrumentationengine.profilerproxy_x64.dll",
+ "memberOf": [
+ "ApiScanBaseline"
+ ],
+ "tool": "APIScanCmd",
+ "ruleId": "duplicatefunctionnamesdefined",
+ "justification": null,
+ "createdDate": "2020-11-06 18:31:35Z",
+ "expirationDate": null,
+ "type": null
+ },
+ "5a286c1bd1664a64a5695b91413562ecaaa8b4966f25a63d8928f8612164dc76": {
+ "signature": "5a286c1bd1664a64a5695b91413562ecaaa8b4966f25a63d8928f8612164dc76",
+ "target": "x64/microsoft.instrumentationengine.extensions.base_x64.dll",
+ "memberOf": [
+ "ApiScanBaseline"
+ ],
+ "tool": "APIScanCmd",
+ "ruleId": "unpublisheddependency",
+ "justification": null,
+ "createdDate": "2020-11-06 18:31:35Z",
+ "expirationDate": null,
+ "type": null
+ },
+ "0590d0a061affc2c5c0dee04003a41c9fe4cd2eff1ee6263d5b3790c41318193": {
+ "signature": "0590d0a061affc2c5c0dee04003a41c9fe4cd2eff1ee6263d5b3790c41318193",
+ "target": "x64/microsoft.instrumentationengine.extensions.base_x64.dll",
+ "memberOf": [
+ "ApiScanBaseline"
+ ],
+ "tool": "APIScanCmd",
+ "ruleId": "duplicatefunctionnamesdefined",
+ "justification": null,
+ "createdDate": "2020-11-06 18:31:35Z",
+ "expirationDate": null,
+ "type": null
+ },
+ "d1704e2466dde92d518f6d55319d49b0b9815838cffec0dc2eff69ae455fa5de": {
+ "signature": "d1704e2466dde92d518f6d55319d49b0b9815838cffec0dc2eff69ae455fa5de",
+ "target": "x64/microsoftinstrumentationengine_x64.dll",
+ "memberOf": [
+ "ApiScanBaseline"
+ ],
+ "tool": "APIScanCmd",
+ "ruleId": "unpublisheddependency",
+ "justification": null,
+ "createdDate": "2020-11-06 18:31:35Z",
+ "expirationDate": null,
+ "type": null
+ },
+ "1a3e28074d0e8c9fed99fb1736aad132b85bc23e35f2a4a7a774e4643a7d9e52": {
+ "signature": "1a3e28074d0e8c9fed99fb1736aad132b85bc23e35f2a4a7a774e4643a7d9e52",
+ "target": "x64/microsoftinstrumentationengine_x64.dll",
+ "memberOf": [
+ "ApiScanBaseline"
+ ],
+ "tool": "APIScanCmd",
+ "ruleId": "duplicatefunctionnamesdefined",
+ "justification": null,
+ "createdDate": "2020-11-06 18:31:35Z",
+ "expirationDate": null,
+ "type": null
+ },
+ "68fd14ab9bf2f5cf6da3f9b87af45de16cf735a85681bc5b646e5e7947e1393c": {
+ "signature": "68fd14ab9bf2f5cf6da3f9b87af45de16cf735a85681bc5b646e5e7947e1393c",
+ "target": "x86/instrumentationengine.profilerproxy_x86.dll",
+ "memberOf": [
+ "ApiScanBaseline"
+ ],
+ "tool": "APIScanCmd",
+ "ruleId": "unpublisheddependency",
+ "justification": null,
+ "createdDate": "2020-11-06 18:31:35Z",
+ "expirationDate": null,
+ "type": null
+ },
+ "606ff1a32562ced566594456285a2c00e47a3483f056da990406e87003e01c4f": {
+ "signature": "606ff1a32562ced566594456285a2c00e47a3483f056da990406e87003e01c4f",
+ "target": "x86/instrumentationengine.profilerproxy_x86.dll",
+ "memberOf": [
+ "ApiScanBaseline"
+ ],
+ "tool": "APIScanCmd",
+ "ruleId": "duplicatefunctionnamesdefined",
+ "justification": null,
+ "createdDate": "2020-11-06 18:31:35Z",
+ "expirationDate": null,
+ "type": null
+ },
+ "1e30042cdad939a4605939692e76e2ea51c567ad7749a3078465fcb5c0378918": {
+ "signature": "1e30042cdad939a4605939692e76e2ea51c567ad7749a3078465fcb5c0378918",
+ "target": "x86/microsoft.instrumentationengine.extensions.base_x86.dll",
+ "memberOf": [
+ "ApiScanBaseline"
+ ],
+ "tool": "APIScanCmd",
+ "ruleId": "unpublisheddependency",
+ "justification": null,
+ "createdDate": "2020-11-06 18:31:35Z",
+ "expirationDate": null,
+ "type": null
+ },
+ "4b287efe3b35e04f74c818284f5954e06c863a1f67c6ebf1b285cabd3b5d64af": {
+ "signature": "4b287efe3b35e04f74c818284f5954e06c863a1f67c6ebf1b285cabd3b5d64af",
+ "target": "x86/microsoft.instrumentationengine.extensions.base_x86.dll",
+ "memberOf": [
+ "ApiScanBaseline"
+ ],
+ "tool": "APIScanCmd",
+ "ruleId": "duplicatefunctionnamesdefined",
+ "justification": null,
+ "createdDate": "2020-11-06 18:31:35Z",
+ "expirationDate": null,
+ "type": null
+ },
+ "d0859c9d9ecc46ee33a83348587ccceddd040a1746c160b872d9a03f229dfafa": {
+ "signature": "d0859c9d9ecc46ee33a83348587ccceddd040a1746c160b872d9a03f229dfafa",
+ "target": "x86/microsoftinstrumentationengine_x86.dll",
+ "memberOf": [
+ "ApiScanBaseline"
+ ],
+ "tool": "APIScanCmd",
+ "ruleId": "unpublisheddependency",
+ "justification": null,
+ "createdDate": "2020-11-06 18:31:35Z",
+ "expirationDate": null,
+ "type": null
+ },
+ "7810672618fab2fe1b77804887f6938d909346bc0e2f49738a8036f1404831b4": {
+ "signature": "7810672618fab2fe1b77804887f6938d909346bc0e2f49738a8036f1404831b4",
+ "target": "x86/microsoftinstrumentationengine_x86.dll",
+ "memberOf": [
+ "ApiScanBaseline"
+ ],
+ "tool": "APIScanCmd",
+ "ruleId": "duplicatefunctionnamesdefined",
+ "justification": null,
+ "createdDate": "2020-11-06 18:31:35Z",
+ "expirationDate": null,
+ "type": null
+ }
+ }
+}
\ No newline at end of file
diff --git a/build/yaml/steps/codeanalysis/csharpsuppressions.txt b/build/yaml/steps/codeanalysis/csharpsuppressions.txt
index 62dcb1e9..a0585de8 100644
--- a/build/yaml/steps/codeanalysis/csharpsuppressions.txt
+++ b/build/yaml/steps/codeanalysis/csharpsuppressions.txt
@@ -2,3 +2,5 @@ CA1707
CA1303
CA1031
CA1822
+CA1016
+CS2008
diff --git a/build/yaml/steps/codeanalysis/postanalysis.yaml b/build/yaml/steps/codeanalysis/postanalysis.yaml
index 83dcc8f8..06843f92 100644
--- a/build/yaml/steps/codeanalysis/postanalysis.yaml
+++ b/build/yaml/steps/codeanalysis/postanalysis.yaml
@@ -29,4 +29,6 @@ steps:
GdnBreakOutputBaseline: MyBL1
GdnBreakOutputSuppressionFile: MySupp1
GdnBreakOutputSuppressionSet: MySupp1
+ GdnBreakBaselineFiles: $(Build.SourcesDirectory)\build\yaml\steps\codeanalysis\baseline
+ GdnBreakBaselines: ApiScanBaseline
condition: succeededOrFailed()
\ No newline at end of file
diff --git a/build/yaml/steps/codeanalysis/prefast.yaml b/build/yaml/steps/codeanalysis/prefast.yaml
index f569c460..9ab26070 100644
--- a/build/yaml/steps/codeanalysis/prefast.yaml
+++ b/build/yaml/steps/codeanalysis/prefast.yaml
@@ -8,6 +8,14 @@ steps:
- task: ms-vseng.MicroBuildShipTasks.9ef02907-718e-41b7-a57e-b10f86130bb8.MicroBuildPrefastPlugin@2
displayName: 'Install Prefast Plugin'
+# Increase the maximum cyclomatic complexity threshold.
+# The cyclomatic complexity is the number of closed loops in a function + 1.
+# A quick way to count this metric is to sum 1 plus the count of {IF FOR WHILE SWITCH BREAK RETURN OPERATOR.QUESTION OPERATOR.AND OPERATOR.OR CATCH} in the function body.
+# Ideally we'd like to simplify the faulting methods and use the default (25), but for now we'll ignore them.
+- powershell: |
+ Write-Host "##vso[task.setvariable variable=_PREFAST_CYCLOMATIC;] 83"
+ displayName: Set _PREFAST_CYCLOMATIC=83
+
- template: ../windows/binaries.yaml
parameters:
NuGetRestore: false
\ No newline at end of file
diff --git a/inc/clr/extra/LegacyActivationShim.h b/inc/clr/extra/LegacyActivationShim.h
index 93b214bc..7a678762 100644
--- a/inc/clr/extra/LegacyActivationShim.h
+++ b/inc/clr/extra/LegacyActivationShim.h
@@ -1348,7 +1348,10 @@ WRAP_HRESULT_IMPL_BOOLEAN(StrongNameGetPublicKeyEx_HRESULT,
}
else
{
+#pragma warning( push )
+#pragma warning( disable: 25130 ) // 'CoCreateInstance' needs to be reviewed if a non-global or non-const CLSID is passed.
IfHrFailRet(::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv));
+#pragma warning( pop )
}
return hr;
diff --git a/inc/clr/extra/LegacyActivationShimUtil.h b/inc/clr/extra/LegacyActivationShimUtil.h
index 071853fa..8cb353f8 100644
--- a/inc/clr/extra/LegacyActivationShimUtil.h
+++ b/inc/clr/extra/LegacyActivationShimUtil.h
@@ -534,14 +534,14 @@ namespace LegacyActivationShim
inline
bool HasNewActivationAPIs()
{
- if (ReadAcquire((LONG volatile *)&g_fHasNewActivationAPIs) == LONG(-1))
+ if (ReadAcquire(&g_fHasNewActivationAPIs) == -1l)
{
ICLRMetaHost *pMetaHost = NULL;
HRESULT hr = GetCLRMetaHost(&pMetaHost);
InterlockedCompareExchange((LONG volatile *)&g_fHasNewActivationAPIs, (LONG)(SUCCEEDED(hr)), ULONG(-1));
}
- return ReadAcquire((LONG volatile *)&g_fHasNewActivationAPIs) != 0;
+ return ReadAcquire(&g_fHasNewActivationAPIs) != 0l;
}
// ---CLRMETAHOSTPOLICY INTERFACE DATA-----------------------------------------------------
@@ -1020,7 +1020,7 @@ namespace LegacyActivationShim
inline
HRESULT AddStartupFlags(
ICLRRuntimeInfo *pInfo,
- LPCWSTR wszBuildFlavor,
+ _In_opt_z_ LPCWSTR wszBuildFlavor,
DWORD dwStartupFlags,
LPCWSTR wszHostConfigFile)
{
diff --git a/inc/clr/prof/clrprofiler.h b/inc/clr/prof/clrprofiler.h
new file mode 100644
index 00000000..a3da9559
--- /dev/null
+++ b/inc/clr/prof/clrprofiler.h
@@ -0,0 +1,5 @@
+#pragma once
+#pragma warning(push) // corprof.h from the coreclr does not include SAL anotations
+#pragma warning(disable : 6313 25057 25155 28718 28204 28722 28723 28729 28740)
+#include "corprof.h"
+#pragma warning(pop)
\ No newline at end of file
diff --git a/src/Common.Lib/CriticalSectionHolder.h b/src/Common.Lib/CriticalSectionHolder.h
index d64e2f44..5fed857b 100644
--- a/src/Common.Lib/CriticalSectionHolder.h
+++ b/src/Common.Lib/CriticalSectionHolder.h
@@ -50,18 +50,15 @@ namespace CommonLib
This function checks if a critical section is owned or not.
--*/
- inline BOOL IsCriticalSectionOwned(
- _In_ CRITICAL_SECTION* lpCriticalSection
+ inline bool IsCriticalSectionOwned(
+ _In_ const CRITICAL_SECTION* lpCriticalSection
)
{
- BOOL fOwned = FALSE;
DWORD threadId = GetCurrentThreadId();
//
// this is actually thread safe
//
- fOwned = (DWORD_PTR)lpCriticalSection->OwningThread == threadId;
-
- return fOwned;
+ return (DWORD_PTR)lpCriticalSection->OwningThread == threadId;
}
}
\ No newline at end of file
diff --git a/src/Common.Lib/EventLoggingBase.h b/src/Common.Lib/EventLoggingBase.h
index f096807a..d96aec78 100644
--- a/src/Common.Lib/EventLoggingBase.h
+++ b/src/Common.Lib/EventLoggingBase.h
@@ -18,7 +18,7 @@ namespace CommonLib
{
struct EventLogItem
{
- EventLogItem(WORD wType, tstring tsLog)
+ EventLogItem(WORD wType, const tstring& tsLog)
: wEventType(wType), tsEventLog(tsLog)
{
}
diff --git a/src/Common.Lib/InitOnce.h b/src/Common.Lib/InitOnce.h
index 32ba4171..2475c00c 100644
--- a/src/Common.Lib/InitOnce.h
+++ b/src/Common.Lib/InitOnce.h
@@ -25,7 +25,7 @@ namespace CommonLib
HRESULT m_result;
public:
- CInitOnce(std::function func) : m_isCreated(false), m_func(func), m_result(0) { }
+ CInitOnce(const std::function& func) : m_isCreated(false), m_func(func), m_result(0) { }
public:
HRESULT Get()
@@ -42,7 +42,7 @@ namespace CommonLib
return m_result;
}
- bool IsSuccessful()
+ bool IsSuccessful() const
{
return m_isCreated.load(std::memory_order_relaxed) && SUCCEEDED(m_result);
}
diff --git a/src/Extensions.Base.Api.Tests/Extensions.Base.Api.Tests.csproj b/src/Extensions.Base.Api.Tests/Extensions.Base.Api.Tests.csproj
index 45a3c26a..406ffa5e 100644
--- a/src/Extensions.Base.Api.Tests/Extensions.Base.Api.Tests.csproj
+++ b/src/Extensions.Base.Api.Tests/Extensions.Base.Api.Tests.csproj
@@ -13,6 +13,7 @@
Extensions.Base.Api.Tests
Extensions.Base.Api.Tests
v4.0
+ false
512
{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
10.0
diff --git a/src/Extensions.Base.Api.Tests/ExtensionsBaseCallbacks.cs b/src/Extensions.Base.Api.Tests/ExtensionsBaseCallbacks.cs
index 41cfeac5..b5a12ce6 100644
--- a/src/Extensions.Base.Api.Tests/ExtensionsBaseCallbacks.cs
+++ b/src/Extensions.Base.Api.Tests/ExtensionsBaseCallbacks.cs
@@ -5,6 +5,7 @@ namespace ProfilerCallbacksTests
{
using System;
using System.Globalization;
+ using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -155,10 +156,12 @@ public void TestMultipleThreadsAddingAndRemovingCallbacks()
allTasks[nonCapturedI] =
Task.Factory.StartNew(
- () => AID.ApplicationInsights_RemoveCallbacks(nonCapturedI, 0));
+ () => AID.ApplicationInsights_RemoveCallbacks(nonCapturedI, 0),
+ default(CancellationToken), TaskCreationOptions.None, TaskScheduler.Default);
allTasks[nonCapturedI + numberOfTasks] =
Task.Factory.StartNew(
- () => AID.ApplicationInsights_AddCallbacks(nonCapturedI + numberOfTasks, () => nonCapturedI + numberOfTasks, null, null));
+ () => AID.ApplicationInsights_AddCallbacks(nonCapturedI + numberOfTasks, () => nonCapturedI + numberOfTasks, null, null),
+ default(CancellationToken), TaskCreationOptions.None, TaskScheduler.Default);
}
Task.WaitAll(allTasks);
diff --git a/src/Extensions.Base.Api/ExceptionCallbacks.cs b/src/Extensions.Base.Api/ExceptionCallbacks.cs
index 62ab0d64..aca80b7b 100644
--- a/src/Extensions.Base.Api/ExceptionCallbacks.cs
+++ b/src/Extensions.Base.Api/ExceptionCallbacks.cs
@@ -47,6 +47,7 @@ namespace _System.Diagnostics
///
/// This class defines public contract to register new callbacks
///
+ [AttributeUsage(AttributeTargets.All)]
public partial class DebuggerHiddenAttribute : Attribute
{
diff --git a/src/Extensions.Base.Api/Extensions.Base.Api.csproj b/src/Extensions.Base.Api/Extensions.Base.Api.csproj
index 47137025..e3ba5ed6 100644
--- a/src/Extensions.Base.Api/Extensions.Base.Api.csproj
+++ b/src/Extensions.Base.Api/Extensions.Base.Api.csproj
@@ -13,6 +13,7 @@
Microsoft.Diagnostics.Instrumentation.Extensions.Base
Microsoft.Diagnostics.Instrumentation.Extensions.Base
v4.0
+ false
512
Client
true
diff --git a/src/ExtensionsCommon/DecorationCallbackInfo.cpp b/src/ExtensionsCommon/DecorationCallbackInfo.cpp
index df8f8544..c8dcb29f 100644
--- a/src/ExtensionsCommon/DecorationCallbackInfo.cpp
+++ b/src/ExtensionsCommon/DecorationCallbackInfo.cpp
@@ -9,7 +9,7 @@
CDecorationCallbackInfo::CDecorationCallbackInfo(
const std::wstring& strMethodName,
DWORD dwAttributes,
- PCCOR_SIGNATURE pCorSig,
+ _In_reads_(ulCorSigSize) PCCOR_SIGNATURE pCorSig,
ULONG ulCorSigSize,
DWORD dwImplFlags)
: m_strMethodName(strMethodName)
@@ -41,7 +41,7 @@ DWORD CDecorationCallbackInfo::GetMethodImplFlags() const
return m_dwMethodImplFlags;
}
-DWORD CDecorationCallbackInfo::GetParamCount()
+DWORD CDecorationCallbackInfo::GetParamCount() const
{
const auto InvalidArgumentCount = -1;
diff --git a/src/ExtensionsCommon/DecorationCallbackInfo.h b/src/ExtensionsCommon/DecorationCallbackInfo.h
index 9bb07f9f..9fea79d5 100644
--- a/src/ExtensionsCommon/DecorationCallbackInfo.h
+++ b/src/ExtensionsCommon/DecorationCallbackInfo.h
@@ -15,7 +15,7 @@ class CDecorationCallbackInfo final
CDecorationCallbackInfo(
const std::wstring& strMethodName,
DWORD dwAttributes,
- PCCOR_SIGNATURE pCorSig,
+ _In_reads_(ulCorSigSize) PCCOR_SIGNATURE pCorSig,
ULONG ulCorSigSize,
DWORD dwImplFlags);
@@ -25,7 +25,7 @@ class CDecorationCallbackInfo final
const CorSigDefinition& GetMethodSig() const;
DWORD GetMethodAttributes() const;
DWORD GetMethodImplFlags() const;
- DWORD GetParamCount();
+ DWORD GetParamCount() const;
};
typedef std::shared_ptr CDecorationCallbackInfoSptr;
\ No newline at end of file
diff --git a/src/ExtensionsCommon/DecorationCallbacksInfoStaticReader.cpp b/src/ExtensionsCommon/DecorationCallbacksInfoStaticReader.cpp
index 9eaa1474..0ab06ba2 100644
--- a/src/ExtensionsCommon/DecorationCallbacksInfoStaticReader.cpp
+++ b/src/ExtensionsCommon/DecorationCallbacksInfoStaticReader.cpp
@@ -44,9 +44,9 @@ static const COR_SIGNATURE ExceptionCallbackTheShortestSignature[] =
};
HRESULT CDecorationCallbacksInfoStaticReader::InternalGenerateCallbackInfosForNCustomArgs(
- const std::wstring strMehodName,
+ const std::wstring& strMehodName,
const unsigned int uMaxCustomArgsCount,
- PCCOR_SIGNATURE pCorSigTemplate,
+ _In_reads_(ucCorSigTemplateSize) PCCOR_SIGNATURE pCorSigTemplate,
unsigned int ucCorSigTemplateSize,
_Out_ DecorationCallbackInfoCollection& vecCallbacksResult)
{
diff --git a/src/ExtensionsCommon/DecorationCallbacksInfoStaticReader.h b/src/ExtensionsCommon/DecorationCallbacksInfoStaticReader.h
index 891d5e63..9572897e 100644
--- a/src/ExtensionsCommon/DecorationCallbacksInfoStaticReader.h
+++ b/src/ExtensionsCommon/DecorationCallbacksInfoStaticReader.h
@@ -17,9 +17,9 @@ class CDecorationCallbacksInfoStaticReader final : public CProfilerHostServices
virtual ~CDecorationCallbacksInfoStaticReader() {}
private:
HRESULT InternalGenerateCallbackInfosForNCustomArgs(
- const std::wstring strMehodName,
+ const std::wstring& strMehodName,
const unsigned int uMaxCustomArgsCount,
- PCCOR_SIGNATURE pCorSigTemplate,
+ _In_reads_(ucCorSigTemplateSize) PCCOR_SIGNATURE pCorSigTemplate,
unsigned int ucCorSigTemplateSize,
_Out_ DecorationCallbackInfoCollection& vecCallbacksResult);
}; // CDecorationCallbacksInfoStaticReader
diff --git a/src/ExtensionsCommon/InstrumentationEngineDefs.h b/src/ExtensionsCommon/InstrumentationEngineDefs.h
index a2b1a734..36464fa8 100644
--- a/src/ExtensionsCommon/InstrumentationEngineDefs.h
+++ b/src/ExtensionsCommon/InstrumentationEngineDefs.h
@@ -4,5 +4,5 @@
#pragma once
#include
-#include
+#include
#include "InstrumentationEngine.h"
\ No newline at end of file
diff --git a/src/ExtensionsCommon/ReflectionHelper.cpp b/src/ExtensionsCommon/ReflectionHelper.cpp
index 05800bc0..13e61a0e 100644
--- a/src/ExtensionsCommon/ReflectionHelper.cpp
+++ b/src/ExtensionsCommon/ReflectionHelper.cpp
@@ -72,7 +72,7 @@ HRESULT CReflectionHelper::GetAssemblyRefByName(
HRESULT CReflectionHelper::IsTypeBelongsToModule(
_In_ const IModuleInfoSptr& spModuleInfo,
- _In_ const std::shared_ptr spWellKnownTypeInfo,
+ _In_ const std::shared_ptr& spWellKnownTypeInfo,
_Out_ bool& bBelong)
{
HRESULT hr = S_OK;
@@ -101,7 +101,7 @@ HRESULT CReflectionHelper::IsTypeBelongsToModule(
HRESULT CReflectionHelper::DefineMethodToken(
_In_ const IModuleInfoSptr& spModuleInfo,
- _In_ const std::shared_ptr spWellKnownMethodInfo,
+ _In_ const std::shared_ptr& spWellKnownMethodInfo,
_Out_ mdToken& tkMethodToken)
{
HRESULT hr = S_OK;
@@ -114,7 +114,7 @@ HRESULT CReflectionHelper::DefineMethodToken(
HRESULT CReflectionHelper::GetMethodToken(
_In_ const IModuleInfoSptr& spModuleInfo,
- _In_ const std::shared_ptr spWellKnownMethodInfo,
+ _In_ const std::shared_ptr& spWellKnownMethodInfo,
_Out_ mdToken& tkMethodToken)
{
HRESULT hr = S_OK;
@@ -127,7 +127,7 @@ HRESULT CReflectionHelper::GetMethodToken(
HRESULT CReflectionHelper::GetOrDefineMethodToken(
_In_ const IModuleInfoSptr& spModuleInfo,
- _In_ const std::shared_ptr spWellKnownMethodInfo,
+ _In_ const std::shared_ptr& spWellKnownMethodInfo,
_Out_ mdToken& tkMethodToken,
_In_ bool bDefine)
{
@@ -186,7 +186,7 @@ HRESULT CReflectionHelper::GetOrDefineMethodToken(
HRESULT CReflectionHelper::GetTypeToken(
_In_ const IModuleInfoSptr& spModuleInfo,
- _In_ const std::shared_ptr spWellKnownTypeInfo,
+ _In_ const std::shared_ptr& spWellKnownTypeInfo,
_Out_ mdToken& tkTypeToken)
{
HRESULT hr = S_OK;
@@ -198,7 +198,7 @@ HRESULT CReflectionHelper::GetTypeToken(
HRESULT CReflectionHelper::DefineTypeToken(
_In_ const IModuleInfoSptr& spModuleInfo,
- _In_ const std::shared_ptr spWellKnownTypeInfo,
+ _In_ const std::shared_ptr& spWellKnownTypeInfo,
_Out_ mdToken& tkTypeToken)
{
HRESULT hr = S_OK;
@@ -210,7 +210,7 @@ HRESULT CReflectionHelper::DefineTypeToken(
HRESULT CReflectionHelper::GetOrDefineTypeToken(
_In_ const IModuleInfoSptr& spModuleInfo,
- _In_ const std::shared_ptr spWellKnownTypeInfo,
+ _In_ const std::shared_ptr& spWellKnownTypeInfo,
_Out_ mdToken& tkTypeToken,
_In_ bool bDefine)
{
diff --git a/src/ExtensionsCommon/ReflectionHelper.h b/src/ExtensionsCommon/ReflectionHelper.h
index e4e096ec..e4995c17 100644
--- a/src/ExtensionsCommon/ReflectionHelper.h
+++ b/src/ExtensionsCommon/ReflectionHelper.h
@@ -21,39 +21,39 @@ class CReflectionHelper final
HRESULT IsTypeBelongsToModule(
_In_ const IModuleInfoSptr& spModuleInfo,
- _In_ const std::shared_ptr spWellKnownTypeInfo,
+ _In_ const std::shared_ptr& spWellKnownTypeInfo,
_Out_ bool& bBelong);
HRESULT GetMethodToken(
_In_ const IModuleInfoSptr& spModuleInfo,
- _In_ const std::shared_ptr spWellKnownMethodInfo,
+ _In_ const std::shared_ptr& spWellKnownMethodInfo,
_Out_ mdToken& tkMethodToken);
HRESULT DefineMethodToken(
_In_ const IModuleInfoSptr& spModuleInfo,
- _In_ const std::shared_ptr spWellKnownMethodInfo,
+ _In_ const std::shared_ptr& spWellKnownMethodInfo,
_Out_ mdToken& tkMethodToken);
HRESULT GetTypeToken(
_In_ const IModuleInfoSptr& spModuleInfo,
- _In_ const std::shared_ptr spWellKnownTypeInfo,
+ _In_ const std::shared_ptr& spWellKnownTypeInfo,
_Out_ mdToken& tkTypeToken);
HRESULT DefineTypeToken(
_In_ const IModuleInfoSptr& spModuleInfo,
- _In_ const std::shared_ptr spWellKnownTypeInfo,
+ _In_ const std::shared_ptr& spWellKnownTypeInfo,
_Out_ mdToken& tkTypeToken);
private:
HRESULT GetOrDefineMethodToken(
_In_ const IModuleInfoSptr& spModuleInfo,
- _In_ const std::shared_ptr spWellKnownMethodInfo,
+ _In_ const std::shared_ptr& spWellKnownMethodInfo,
_Out_ mdToken& tkMethodToken,
_In_ bool bDefine);
HRESULT GetOrDefineTypeToken(
_In_ const IModuleInfoSptr& spModuleInfo,
- _In_ const std::shared_ptr spWellKnownTypeInfo,
+ _In_ const std::shared_ptr& spWellKnownTypeInfo,
_Out_ mdToken& tkTypeToken,
_In_ bool bDefine);
diff --git a/src/ExtensionsCommon/WellKnownMethodInfo.cpp b/src/ExtensionsCommon/WellKnownMethodInfo.cpp
index 4bdee653..2b4d73b2 100644
--- a/src/ExtensionsCommon/WellKnownMethodInfo.cpp
+++ b/src/ExtensionsCommon/WellKnownMethodInfo.cpp
@@ -10,11 +10,11 @@ namespace Agent
namespace Reflection
{
CWellKnownMethodInfo::CWellKnownMethodInfo(
- _In_ std::wstring assemblyName,
- _In_ std::wstring moduleName,
- _In_ std::wstring typeName,
- _In_ std::wstring methodName,
- _In_ PCCOR_SIGNATURE pCorSig,
+ _In_ const std::wstring& assemblyName,
+ _In_ const std::wstring& moduleName,
+ _In_ const std::wstring& typeName,
+ _In_ const std::wstring& methodName,
+ _In_reads_(ulCorSigSize) PCCOR_SIGNATURE pCorSig,
_In_ ULONG ulCorSigSize)
: m_spTypeInfo(new CWellKnownTypeInfo(assemblyName, moduleName, typeName))
, m_methodName(methodName)
diff --git a/src/ExtensionsCommon/WellKnownMethodInfo.h b/src/ExtensionsCommon/WellKnownMethodInfo.h
index e3841bf7..4abf0866 100644
--- a/src/ExtensionsCommon/WellKnownMethodInfo.h
+++ b/src/ExtensionsCommon/WellKnownMethodInfo.h
@@ -20,11 +20,11 @@ namespace Agent
public:
CWellKnownMethodInfo(
- _In_ std::wstring assemblyName,
- _In_ std::wstring moduleName,
- _In_ std::wstring typeName,
- _In_ std::wstring methodName,
- _In_ PCCOR_SIGNATURE pCorSig,
+ _In_ const std::wstring& assemblyName,
+ _In_ const std::wstring& moduleName,
+ _In_ const std::wstring& typeName,
+ _In_ const std::wstring& methodName,
+ _In_reads_(ulCorSigSize) PCCOR_SIGNATURE pCorSig,
_In_ ULONG ulCorSigSize);
const std::wstring& GetMethodName() const;
diff --git a/src/ExtensionsCommon/WellKnownTypeInfo.cpp b/src/ExtensionsCommon/WellKnownTypeInfo.cpp
index 0aa2e8cb..78c8266c 100644
--- a/src/ExtensionsCommon/WellKnownTypeInfo.cpp
+++ b/src/ExtensionsCommon/WellKnownTypeInfo.cpp
@@ -8,7 +8,7 @@ namespace Agent
{
namespace Reflection
{
- CWellKnownTypeInfo::CWellKnownTypeInfo(_In_ std::wstring assemblyName, _In_ std::wstring moduleName, _In_ std::wstring typeName)
+ CWellKnownTypeInfo::CWellKnownTypeInfo(_In_ const std::wstring& assemblyName, _In_ const std::wstring& moduleName, _In_ const std::wstring& typeName)
: m_assemblyName(assemblyName)
, m_moduleName(moduleName)
, m_typeName(typeName)
diff --git a/src/ExtensionsCommon/WellKnownTypeInfo.h b/src/ExtensionsCommon/WellKnownTypeInfo.h
index 7aa881d7..fd44d59c 100644
--- a/src/ExtensionsCommon/WellKnownTypeInfo.h
+++ b/src/ExtensionsCommon/WellKnownTypeInfo.h
@@ -15,7 +15,7 @@ namespace Agent
const std::wstring m_typeName;
public:
- CWellKnownTypeInfo(_In_ std::wstring assemblyName, _In_ std::wstring moduleName, _In_ std::wstring typeName);
+ CWellKnownTypeInfo(_In_ const std::wstring& assemblyName, _In_ const std::wstring& moduleName, _In_ const std::wstring& typeName);
const std::wstring& GetAssemblyName() const;
const std::wstring& GetModuleName() const;
diff --git a/src/InstrumentationEngine.Api/InstrumentationEngine.h b/src/InstrumentationEngine.Api/InstrumentationEngine.h
index 8cea5a6d..565f6ae8 100644
--- a/src/InstrumentationEngine.Api/InstrumentationEngine.h
+++ b/src/InstrumentationEngine.Api/InstrumentationEngine.h
@@ -7,8 +7,8 @@
/* at Mon Jan 18 19:14:07 2038
*/
/* Compiler settings for InstrumentationEngine.idl:
- Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.01.0622
- protocol : dce , ms_ext, c_ext, robust
+ Oicf, W1, Zp8, env=Win64 (32b run), target_arch=AMD64 8.01.0622
+ protocol : all , ms_ext, c_ext, robust
error checks: allocation ref bounds_check enum stub_data
VC __declspec() decoration level:
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
@@ -7433,7 +7433,7 @@ EXTERN_C const IID IID_IInstructionFactory;
virtual HRESULT STDMETHODCALLTYPE DecodeInstructionByteStream(
/* [in] */ DWORD cbMethod,
- /* [in] */ __RPC__in LPCBYTE instructionBytes,
+ /* [size_is][in] */ __RPC__in_ecount_full(cbMethod) LPCBYTE instructionBytes,
/* [out] */ __RPC__deref_out_opt IInstructionGraph **ppInstructionGraph) = 0;
};
@@ -7550,7 +7550,7 @@ EXTERN_C const IID IID_IInstructionFactory;
HRESULT ( STDMETHODCALLTYPE *DecodeInstructionByteStream )(
__RPC__in IInstructionFactory * This,
/* [in] */ DWORD cbMethod,
- /* [in] */ __RPC__in LPCBYTE instructionBytes,
+ /* [size_is][in] */ __RPC__in_ecount_full(cbMethod) LPCBYTE instructionBytes,
/* [out] */ __RPC__deref_out_opt IInstructionGraph **ppInstructionGraph);
END_INTERFACE
diff --git a/src/InstrumentationEngine.Api/InstrumentationEngine.idl b/src/InstrumentationEngine.Api/InstrumentationEngine.idl
index 60db1672..8ba1f350 100644
--- a/src/InstrumentationEngine.Api/InstrumentationEngine.idl
+++ b/src/InstrumentationEngine.Api/InstrumentationEngine.idl
@@ -764,7 +764,7 @@ library MicrosoftInstrumentationEngine
// next and original previous fields set.
//
// 2) This graph will not have a method info set and cannot create exception sections or handlers.
- HRESULT DecodeInstructionByteStream([in] DWORD cbMethod, [in] LPCBYTE instructionBytes, [out] IInstructionGraph** ppInstructionGraph);
+ HRESULT DecodeInstructionByteStream([in] DWORD cbMethod, [in, size_is(cbMethod)] LPCBYTE instructionBytes, [out] IInstructionGraph** ppInstructionGraph);
}
[
diff --git a/src/InstrumentationEngine.Attach/CommandHandler/AttachCommandHandler.cs b/src/InstrumentationEngine.Attach/CommandHandler/AttachCommandHandler.cs
index 099d18f0..dc34fdeb 100644
--- a/src/InstrumentationEngine.Attach/CommandHandler/AttachCommandHandler.cs
+++ b/src/InstrumentationEngine.Attach/CommandHandler/AttachCommandHandler.cs
@@ -233,9 +233,12 @@ private static int Attach(int processId,
}
XmlSerializer engineConfigSerializer = new XmlSerializer(typeof(InstrumentationEngineConfiguration));
- MemoryStream memStream = new MemoryStream();
- engineConfigSerializer.Serialize(memStream, configuration);
- byte[] bytes = memStream.ToArray();
+ byte[] bytes;
+ using (var memStream = new MemoryStream())
+ {
+ engineConfigSerializer.Serialize(memStream, configuration);
+ bytes = memStream.ToArray();
+ }
#endregion
#region InstrumentationEngine Path
diff --git a/src/InstrumentationEngine.Lib/LoggerService.cpp b/src/InstrumentationEngine.Lib/LoggerService.cpp
index 468b6ee4..0df7759c 100644
--- a/src/InstrumentationEngine.Lib/LoggerService.cpp
+++ b/src/InstrumentationEngine.Lib/LoggerService.cpp
@@ -46,7 +46,7 @@ HRESULT CLoggerService::GetLoggingHost(_Out_ IProfilerManagerLoggingHost** ppLog
return m_pLoggingHost.CopyTo(ppLoggingHost);
}
-HRESULT CLoggerService::SetLoggingHost(_In_ IProfilerManagerLoggingHost* pLoggingHost)
+HRESULT CLoggerService::SetLoggingHost(_In_opt_ IProfilerManagerLoggingHost* pLoggingHost)
{
IfNotInitRetUnexpected(m_initialize);
diff --git a/src/InstrumentationEngine.Lib/LoggerService.h b/src/InstrumentationEngine.Lib/LoggerService.h
index 14f335fa..06474e91 100644
--- a/src/InstrumentationEngine.Lib/LoggerService.h
+++ b/src/InstrumentationEngine.Lib/LoggerService.h
@@ -118,7 +118,7 @@ namespace MicrosoftInstrumentationEngine
void LogDumpMessage(_In_ LPCWSTR wszMessage, ...);
HRESULT GetLoggingHost(_Out_ IProfilerManagerLoggingHost** ppLoggingHost);
- HRESULT SetLoggingHost(_In_ IProfilerManagerLoggingHost* pLoggingHost);
+ HRESULT SetLoggingHost(_In_opt_ IProfilerManagerLoggingHost* pLoggingHost);
bool GetLogToDebugPort();
void SetLogToDebugPort(_In_ bool enable);
diff --git a/src/InstrumentationEngine.Lib/Logging.cpp b/src/InstrumentationEngine.Lib/Logging.cpp
index a38e3b3e..8b8b85bd 100644
--- a/src/InstrumentationEngine.Lib/Logging.cpp
+++ b/src/InstrumentationEngine.Lib/Logging.cpp
@@ -141,7 +141,7 @@ HRESULT CLogging::SetLoggingFlags(_In_ LoggingFlags loggingFlags)
}
// static
-HRESULT CLogging::SetLoggingHost(_In_ IProfilerManagerLoggingHost* pLoggingHost)
+HRESULT CLogging::SetLoggingHost(_In_opt_ IProfilerManagerLoggingHost* pLoggingHost)
{
IfNotInitRetUnexpected(s_initialize);
diff --git a/src/InstrumentationEngine.Lib/Logging.h b/src/InstrumentationEngine.Lib/Logging.h
index fca58c01..bbea17f8 100644
--- a/src/InstrumentationEngine.Lib/Logging.h
+++ b/src/InstrumentationEngine.Lib/Logging.h
@@ -16,8 +16,8 @@
// CLogging uses *wprintf* methods for formatting strings.
#ifdef PLATFORM_UNIX
// Use %S for WCHAR* on Linux (which is char16_t*) since *wprintf* expects strings to be wchar_t*.
-// The capital S specifier means "format the string using the width that is opposite of the formatting method".
-// The capital S specifier is appropriate since WCHAR* on Linux is smaller than the *wprintf* width expectation.
+// The uppercase S specifier means "format the string using the width that is opposite of the formatting method".
+// The uppercase S specifier is appropriate since WCHAR* on Linux is smaller than the *wprintf* width expectation.
#define WCHAR_SPEC _T("%S")
#else
// Use %s for WCHAR* on Windows (which is wchar_t*)
@@ -79,7 +79,7 @@ namespace MicrosoftInstrumentationEngine
static HRESULT UpdateInstrumentationMethodLoggingFlags(_In_ GUID classId, _In_ LoggingFlags loggingFlags);
- static HRESULT SetLoggingHost(_In_ IProfilerManagerLoggingHost* pLoggingHost);
+ static HRESULT SetLoggingHost(_In_opt_ IProfilerManagerLoggingHost* pLoggingHost);
static HRESULT Shutdown();
diff --git a/src/InstrumentationEngine.Lib/SharedArray.h b/src/InstrumentationEngine.Lib/SharedArray.h
index 95238b4a..2eb95e23 100644
--- a/src/InstrumentationEngine.Lib/SharedArray.h
+++ b/src/InstrumentationEngine.Lib/SharedArray.h
@@ -68,7 +68,7 @@ namespace MicrosoftInstrumentationEngine
return *this;
}
- CSharedArray& operator=(CSharedArray&& other)
+ CSharedArray& operator=(CSharedArray&& other) noexcept
{
if (this != &other)
{
diff --git a/src/InstrumentationEngine.Lib/refcount.h b/src/InstrumentationEngine.Lib/refcount.h
index e1d12ded..c2ca6b25 100644
--- a/src/InstrumentationEngine.Lib/refcount.h
+++ b/src/InstrumentationEngine.Lib/refcount.h
@@ -52,7 +52,7 @@ namespace MicrosoftInstrumentationEngine
// defines a delegated method call from InprocServerClassFactory::LockServer() to ClassFactory::LockServer().
#define DEFINE_DELEGATED_METHOD(base_cls, result_type, method, derived_paren_args, base_paren_args) \
- result_type STDMETHODCALLTYPE method derived_paren_args override \
+ STDMETHOD_(result_type, method) derived_paren_args override\
{ \
return base_cls::method base_paren_args; \
}
diff --git a/src/InstrumentationEngine.Lib/stdafx.h b/src/InstrumentationEngine.Lib/stdafx.h
index 20673a7f..f40e9ca0 100644
--- a/src/InstrumentationEngine.Lib/stdafx.h
+++ b/src/InstrumentationEngine.Lib/stdafx.h
@@ -43,7 +43,7 @@ using namespace ATL;
#include
#include
-#include
+#include
#include
#ifndef PLATFORM_UNIX
diff --git a/src/InstrumentationEngine.ProfilerProxy.Lib/InstrumentationEngineVersion.cpp b/src/InstrumentationEngine.ProfilerProxy.Lib/InstrumentationEngineVersion.cpp
index d1ccb6b0..929de5f8 100644
--- a/src/InstrumentationEngine.ProfilerProxy.Lib/InstrumentationEngineVersion.cpp
+++ b/src/InstrumentationEngine.ProfilerProxy.Lib/InstrumentationEngineVersion.cpp
@@ -52,12 +52,12 @@ const std::wstring& InstrumentationEngineVersion::GetSemanticVersionString() con
return m_semanticVersionStr;
}
-BOOL InstrumentationEngineVersion::IsPreview() const
+bool InstrumentationEngineVersion::IsPreview() const
{
return m_isPreview;
}
-BOOL InstrumentationEngineVersion::IsDebug() const
+bool InstrumentationEngineVersion::IsDebug() const
{
return m_isDebug;
}
diff --git a/src/InstrumentationEngine.ProfilerProxy.Lib/InstrumentationEngineVersion.h b/src/InstrumentationEngine.ProfilerProxy.Lib/InstrumentationEngineVersion.h
index 875aa813..3f8f28fa 100644
--- a/src/InstrumentationEngine.ProfilerProxy.Lib/InstrumentationEngineVersion.h
+++ b/src/InstrumentationEngine.ProfilerProxy.Lib/InstrumentationEngineVersion.h
@@ -21,9 +21,9 @@ namespace ProfilerProxy
const std::wstring& GetSemanticVersionString() const;
- BOOL IsPreview() const;
+ bool IsPreview() const;
- BOOL IsDebug() const;
+ bool IsDebug() const;
int Compare(_In_ const InstrumentationEngineVersion& right) const noexcept;
diff --git a/src/InstrumentationEngine.ProfilerProxy/dllmain.cpp b/src/InstrumentationEngine.ProfilerProxy/dllmain.cpp
index 6dd3c0ee..c1bc0719 100644
--- a/src/InstrumentationEngine.ProfilerProxy/dllmain.cpp
+++ b/src/InstrumentationEngine.ProfilerProxy/dllmain.cpp
@@ -18,8 +18,6 @@ namespace ProfilerProxy
// Critical section object which provides synchronization when accessing hProfiler.
static CCriticalSection g_criticalSection;
- static LPFN_ISWOW64PROCESS fnIsWow64Process;
-
static constexpr const WCHAR* instrumentationEngineFolder = _T("Microsoft CLR Instrumentation Engine");
static constexpr const WCHAR* useDebugVar = _T("InstrumentationEngineProxy_UseDebug");
static constexpr const WCHAR* usePreviewVar = _T("InstrumentationEngineProxy_UsePreview");
@@ -67,6 +65,8 @@ namespace ProfilerProxy
{
*pIsWow64 = FALSE;
+ LPFN_ISWOW64PROCESS fnIsWow64Process = nullptr;
+
// IsWow64Process is not available on all supported versions of Windows.
// Use GetModuleHandle to get a handle to the DLL that contains the function.
// and GetProcAddress to get a pointer to the function if available.
@@ -135,10 +135,10 @@ namespace ProfilerProxy
WCHAR wszBuffer[2];
ZeroMemory(wszBuffer, 2);
- BOOL useDebug = GetEnvironmentVariable(useDebugVar, wszBuffer, 2) > 0 && wcscmp(wszBuffer, _T("1")) == 0;
+ bool useDebug = GetEnvironmentVariable(useDebugVar, wszBuffer, 2) > 0 && wcscmp(wszBuffer, _T("1")) == 0;
ZeroMemory(wszBuffer, 2);
- BOOL usePreview = GetEnvironmentVariable(usePreviewVar, wszBuffer, 2) > 0 && wcscmp(wszBuffer, _T("1")) == 0;
+ bool usePreview = GetEnvironmentVariable(usePreviewVar, wszBuffer, 2) > 0 && wcscmp(wszBuffer, _T("1")) == 0;
//
// Iterate folders & compare versions
@@ -160,7 +160,7 @@ namespace ProfilerProxy
return HRESULT_FROM_WIN32(GetLastError());
}
- InstrumentationEngineVersion* pLatestVersionFolder = nullptr;
+ const InstrumentationEngineVersion* pLatestVersionFolder = nullptr;
do {
// Skip any files; we only want directories
if ((findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
@@ -313,9 +313,15 @@ namespace ProfilerProxy
* MicrosoftInstrumentationEngine_x64|86.dll
*/
_Check_return_
- STDAPI DLLEXPORT(DllGetClassObject, 12)(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ PVOID* ppObj)
+ STDAPI DLLEXPORT(DllGetClassObject, 12)(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_result_maybenull_ PVOID* ppObj)
{
HRESULT hr = S_OK;
+ if (ppObj == nullptr)
+ {
+ return E_POINTER;
+ }
+ *ppObj = nullptr;
+
#ifdef DEBUG
WCHAR wszEnvVar[MAX_PATH];
diff --git a/src/InstrumentationEngine/AppDomainCollection.cpp b/src/InstrumentationEngine/AppDomainCollection.cpp
index acd73e20..5951b238 100644
--- a/src/InstrumentationEngine/AppDomainCollection.cpp
+++ b/src/InstrumentationEngine/AppDomainCollection.cpp
@@ -207,13 +207,14 @@ HRESULT MicrosoftInstrumentationEngine::CAppDomainCollection::GetModuleInfoById(
}
-HRESULT MicrosoftInstrumentationEngine::CAppDomainCollection::GetModuleInfosByMvid(_In_ GUID mvid, _Out_ IEnumModuleInfo** ppEnum)
+HRESULT MicrosoftInstrumentationEngine::CAppDomainCollection::GetModuleInfosByMvid(GUID mvid, _Out_opt_ IEnumModuleInfo** ppEnum)
{
HRESULT hr = S_OK;
+ IfNullRetPointer(ppEnum);
CLogging::LogMessage(_T("Starting CAppDomainCollection::GetModuleInfosByMvid"));
CCriticalSectionHolder lock(&m_cs);
- *ppEnum = NULL;
+ *ppEnum = nullptr;
vector> vecModules;
diff --git a/src/InstrumentationEngine/AppDomainCollection.h b/src/InstrumentationEngine/AppDomainCollection.h
index e1f2547f..1393b4b4 100644
--- a/src/InstrumentationEngine/AppDomainCollection.h
+++ b/src/InstrumentationEngine/AppDomainCollection.h
@@ -55,7 +55,7 @@ namespace MicrosoftInstrumentationEngine
// NOTE: These helpers will search all appdomains
STDMETHOD(GetAssemblyInfoById)(_In_ AssemblyID assemblyID, _Out_ IAssemblyInfo** ppAssemblyInfo) override;
STDMETHOD(GetModuleInfoById)(_In_ ModuleID moduleID, _Out_ IModuleInfo** ppModuleInfo) override;
- STDMETHOD(GetModuleInfosByMvid)(_In_ GUID mvid, _Out_ IEnumModuleInfo** ppEnum) override;
+ STDMETHOD(GetModuleInfosByMvid)(GUID mvid, _Out_opt_ IEnumModuleInfo** ppEnum) override;
// Obtain a method info instance from a function id. This method info is for querying information only,
// and cannot be used for instrumentation.
diff --git a/src/InstrumentationEngine/AppDomainInfo.cpp b/src/InstrumentationEngine/AppDomainInfo.cpp
index cfead194..cafbfb9f 100644
--- a/src/InstrumentationEngine/AppDomainInfo.cpp
+++ b/src/InstrumentationEngine/AppDomainInfo.cpp
@@ -447,7 +447,7 @@ HRESULT MicrosoftInstrumentationEngine::CAppDomainInfo::GetModuleInfoById(_In_ M
return hr;
}
-HRESULT MicrosoftInstrumentationEngine::CAppDomainInfo::GetModuleInfosByMvid(_In_ GUID mvid, _Out_ IEnumModuleInfo** ppModuleInfo)
+HRESULT MicrosoftInstrumentationEngine::CAppDomainInfo::GetModuleInfosByMvid(GUID mvid, _Out_opt_ IEnumModuleInfo** ppModuleInfo)
{
HRESULT hr = S_OK;
IfNullRetPointer(ppModuleInfo);
diff --git a/src/InstrumentationEngine/AppDomainInfo.h b/src/InstrumentationEngine/AppDomainInfo.h
index 7c422912..f442de68 100644
--- a/src/InstrumentationEngine/AppDomainInfo.h
+++ b/src/InstrumentationEngine/AppDomainInfo.h
@@ -79,7 +79,7 @@ namespace MicrosoftInstrumentationEngine
virtual HRESULT __stdcall GetModuleCount(_Out_ ULONG* pcModuleInfos) override;
virtual HRESULT __stdcall GetModuleInfoById(_In_ ModuleID moduleId, _Out_ IModuleInfo** ppModuleInfo) override;
- virtual HRESULT __stdcall GetModuleInfosByMvid(_In_ GUID mvid, _Out_ IEnumModuleInfo** ppModuleInfo) override;
+ virtual HRESULT __stdcall GetModuleInfosByMvid(GUID mvid, _Out_opt_ IEnumModuleInfo** ppModuleInfo) override;
virtual HRESULT __stdcall GetModuleInfosByName(_In_ BSTR pszModuleName, _Out_ IEnumModuleInfo** ppModuleInfo) override;
};
}
\ No newline at end of file
diff --git a/src/InstrumentationEngine/AssemblyInfo.cpp b/src/InstrumentationEngine/AssemblyInfo.cpp
index d757fadf..2dfd9513 100644
--- a/src/InstrumentationEngine/AssemblyInfo.cpp
+++ b/src/InstrumentationEngine/AssemblyInfo.cpp
@@ -10,7 +10,7 @@
#include "StrongName.h"
#endif
-MicrosoftInstrumentationEngine::CAssemblyInfo::CAssemblyInfo(CProfilerManager* pProfilerManager) :
+MicrosoftInstrumentationEngine::CAssemblyInfo::CAssemblyInfo(_In_ CProfilerManager* pProfilerManager) :
m_pProfilerManager(pProfilerManager),
m_assemblyId(0),
m_tkAssembly(mdTokenNil),
@@ -31,7 +31,7 @@ MicrosoftInstrumentationEngine::CAssemblyInfo::~CAssemblyInfo()
HRESULT MicrosoftInstrumentationEngine::CAssemblyInfo::Initialize(
_In_ AssemblyID assemblyId,
- _In_ WCHAR* wszAssemblyName,
+ _In_ const WCHAR* wszAssemblyName,
_In_ IAppDomainInfo* pAppDomainInfo,
_In_ ModuleID manifestModuleID
)
@@ -462,7 +462,7 @@ HRESULT MicrosoftInstrumentationEngine::CAssemblyInfo::InitializePublicKeyToken(
const DWORD dwPublicKeyTokenBufferLen = 16 + 1;
WCHAR wszPublicKeyToken[dwPublicKeyTokenBufferLen] = { 0 };
WCHAR *currTokenPos = wszPublicKeyToken;
- WCHAR *endTokenBuffer = wszPublicKeyToken + 16; // Ignore last element since it is for null not content.
+ const WCHAR *endTokenBuffer = wszPublicKeyToken + 16; // Ignore last element since it is for null not content.
for (ULONG i = 0; i < publicKeyTokenSize && (currTokenPos != endTokenBuffer); ++i)
{
// 2 for each printed character in a byte and 1 for the implicit null
diff --git a/src/InstrumentationEngine/AssemblyInfo.h b/src/InstrumentationEngine/AssemblyInfo.h
index 93b9f990..20b27e08 100644
--- a/src/InstrumentationEngine/AssemblyInfo.h
+++ b/src/InstrumentationEngine/AssemblyInfo.h
@@ -64,7 +64,7 @@ namespace MicrosoftInstrumentationEngine
HRESULT Initialize(
_In_ AssemblyID assemblyID,
- _In_ WCHAR* wszAssemblyName,
+ _In_ const WCHAR* wszAssemblyName,
_In_ IAppDomainInfo* pAppDomainInfo,
_In_ ModuleID manifestModuleID
);
diff --git a/src/InstrumentationEngine/AssemblyInjector.cpp b/src/InstrumentationEngine/AssemblyInjector.cpp
index 4d04bb6b..cbe35de0 100644
--- a/src/InstrumentationEngine/AssemblyInjector.cpp
+++ b/src/InstrumentationEngine/AssemblyInjector.cpp
@@ -633,8 +633,8 @@ HRESULT MicrosoftInstrumentationEngine::AssemblyInjector::ImportMethodDef(_In_ m
if (ulCodeRVA != 0)
{
VOID* pSourceCode = (BYTE*)m_pSourceImageBaseAddress + ulCodeRVA;
- IMAGE_COR_ILMETHOD_TINY* pSourceCodeTinyHeader = (IMAGE_COR_ILMETHOD_TINY*)pSourceCode;
- IMAGE_COR_ILMETHOD_FAT* pSourceCodeFatHeader = (IMAGE_COR_ILMETHOD_FAT*)pSourceCode;
+ const IMAGE_COR_ILMETHOD_TINY* pSourceCodeTinyHeader = (IMAGE_COR_ILMETHOD_TINY*)pSourceCode;
+ const IMAGE_COR_ILMETHOD_FAT* pSourceCodeFatHeader = (IMAGE_COR_ILMETHOD_FAT*)pSourceCode;
bool isTinyHeader = ((pSourceCodeTinyHeader->Flags_CodeSize & (CorILMethod_FormatMask >> 1)) == CorILMethod_TinyFormat);
ULONG ilCodeSize = 0;
ULONG headerSize = 0;
@@ -1420,7 +1420,7 @@ static OPCLSA g_opcodeInlineValues[] = {
#define MAX_MSIL_OPCODE (0x22+0x100)
-HRESULT MicrosoftInstrumentationEngine::AssemblyInjector::ConvertILCode(_In_ const BYTE* pSourceILCode, _In_ BYTE* pTargetILCode, ULONG32 bufferSize)
+HRESULT MicrosoftInstrumentationEngine::AssemblyInjector::ConvertILCode(_In_reads_bytes_(bufferSize) const BYTE* pSourceILCode, _Inout_updates_bytes_(bufferSize) BYTE* pTargetILCode, ULONG32 bufferSize)
{
HRESULT hr = S_OK;
diff --git a/src/InstrumentationEngine/AssemblyInjector.h b/src/InstrumentationEngine/AssemblyInjector.h
index 625cce4c..a1bf4cb0 100644
--- a/src/InstrumentationEngine/AssemblyInjector.h
+++ b/src/InstrumentationEngine/AssemblyInjector.h
@@ -45,7 +45,7 @@ namespace MicrosoftInstrumentationEngine
HRESULT ImportMethodSpec(_In_ const mdMethodSpec sourceMethodSpec, _Out_ mdMethodSpec* pTargetMethodSpec);
HRESULT ConvertToken(_In_ mdToken token, _Out_ mdToken* pTargetToken);
- HRESULT ConvertILCode(_In_ const BYTE* pSourceILCode, _In_ BYTE* pTargetILCode, ULONG32 ilCodeSize);
+ HRESULT ConvertILCode(_In_reads_bytes_(ilCodeSize) const BYTE* pSourceILCode, _Inout_updates_bytes_(ilCodeSize) BYTE* pTargetILCode, ULONG32 ilCodeSize);
HRESULT ConvertNonTypeSignatureCached(_Inout_ PCCOR_SIGNATURE* pSignature, _Inout_ DWORD* pcbSignature);
HRESULT ConvertTypeSignatureCached(_Inout_ PCCOR_SIGNATURE* pSignature, _Inout_ DWORD* pcbSignature);
HRESULT ConvertNonTypeSignature(_In_ SigParser & sig, _In_ const CComPtr& newSig);
diff --git a/src/InstrumentationEngine/AtlModule.h b/src/InstrumentationEngine/AtlModule.h
index 9c12ddd7..c5fcd241 100644
--- a/src/InstrumentationEngine/AtlModule.h
+++ b/src/InstrumentationEngine/AtlModule.h
@@ -16,9 +16,9 @@ namespace MicrosoftInstrumentationEngine
private:
/// Find and load the correct satellite resource dll for the profiler
- HRESULT LoadResourceModule();
+ static HRESULT LoadResourceModule();
- void FreeResourceModule();
+ static void FreeResourceModule();
public:
DECLARE_NO_REGISTRY() // don't try to register the module.
diff --git a/src/InstrumentationEngine/CorHeaders.cpp b/src/InstrumentationEngine/CorHeaders.cpp
index fae6c882..a6da282f 100644
--- a/src/InstrumentationEngine/CorHeaders.cpp
+++ b/src/InstrumentationEngine/CorHeaders.cpp
@@ -41,7 +41,7 @@ void __stdcall DecoderInit(COR_ILMETHOD_DECODER * pThis, const COR_ILMETHOD_FAT*
/*********************************************************************/
/* APIs for emitting sections etc */
-unsigned __stdcall IlmethodSize(COR_ILMETHOD_FAT* header, BOOL moreSections)
+unsigned __stdcall IlmethodSize(const COR_ILMETHOD_FAT* header, bool moreSections)
{
if (header->MaxStack <= 8 && (header->Flags & ~CorILMethod_FormatMask) == 0
&& header->LocalVarSigTok == 0 && header->CodeSize < 64 && !moreSections)
@@ -52,8 +52,8 @@ unsigned __stdcall IlmethodSize(COR_ILMETHOD_FAT* header, BOOL moreSections)
/*********************************************************************/
// emit the header (bestFormat) return amount emitted
-unsigned __stdcall IlmethodEmit(unsigned size, COR_ILMETHOD_FAT* header,
- BOOL moreSections, _Out_cap_(size) BYTE* outBuff)
+unsigned __stdcall IlmethodEmit(unsigned size, const COR_ILMETHOD_FAT* header,
+ bool moreSections, _Out_cap_(size) BYTE* outBuff)
{
#ifdef _DEBUG
BYTE* origBuff = outBuff;
@@ -110,7 +110,7 @@ unsigned __stdcall SectEH_SizeWorst(unsigned ehCount)
}
// will return exact size which will match the size returned by Emit
-unsigned __stdcall SectEH_SizeExact(unsigned ehCount, IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT* clauses)
+unsigned __stdcall SectEH_SizeExact(unsigned ehCount, const IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT* clauses)
{
if (ehCount == 0)
return(0);
@@ -133,8 +133,8 @@ unsigned __stdcall SectEH_SizeExact(unsigned ehCount, IMAGE_COR_ILMETHOD_SECT_EH
// emit the section (best format);
unsigned __stdcall SectEH_Emit(unsigned size, unsigned ehCount,
- __in_ecount(ehCount) IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT* clauses,
- BOOL moreSections, __inout_ecount_opt(size) BYTE* outBuff,
+ __in_ecount(ehCount) const IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT* clauses,
+ bool moreSections, __inout_ecount_opt(size) BYTE* outBuff,
__out_ecount(ehCount) ULONG* ehTypeOffsets)
{
HRESULT hr = S_OK;
diff --git a/src/InstrumentationEngine/CorHeaders.h b/src/InstrumentationEngine/CorHeaders.h
index cc6a2a44..18020c66 100644
--- a/src/InstrumentationEngine/CorHeaders.h
+++ b/src/InstrumentationEngine/CorHeaders.h
@@ -127,10 +127,10 @@ unsigned __stdcall SectEH_SizeWithCode (unsigned ehCount, unsigned codeSize);
unsigned __stdcall SectEH_SizeWorst (unsigned ehCount);
// will return exact size which will match the size returned by Emit
-unsigned __stdcall SectEH_SizeExact (unsigned ehCount, IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT* clauses);
+unsigned __stdcall SectEH_SizeExact (unsigned ehCount, const IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT* clauses);
// emit the section (best format);
-unsigned __stdcall SectEH_Emit (unsigned size, unsigned ehCount, __in_ecount(ehCount) IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT* clauses, BOOL moreSections, __inout_ecount_opt(size) BYTE* outBuff, __out_ecount(ehCount) ULONG* ehTypeOffsets = 0);
+unsigned __stdcall SectEH_Emit (unsigned size, unsigned ehCount, __in_ecount(ehCount) const IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT* clauses, bool moreSections, __inout_ecount_opt(size) BYTE* outBuff, __out_ecount(ehCount) ULONG* ehTypeOffsets = 0);
struct COR_ILMETHOD_SECT_EH : public COR_ILMETHOD_SECT
@@ -161,13 +161,13 @@ struct COR_ILMETHOD_SECT_EH : public COR_ILMETHOD_SECT
// will return exact size which will match the size returned by Emit
unsigned static Size (unsigned ehCount, const IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT* clauses)
{
- return SectEH_SizeExact (ehCount, (IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT*)clauses);
+ return SectEH_SizeExact (ehCount, clauses);
};
// emit the section (best format);
- unsigned static Emit (unsigned size, unsigned ehCount, IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT* clauses, bool moreSections, _Out_cap_(size) BYTE* outBuff, __out_ecount(ehCount) ULONG* ehTypeOffsets = 0)
+ unsigned static Emit (unsigned size, unsigned ehCount, const IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT* clauses, bool moreSections, _Out_cap_(size) BYTE* outBuff, __out_ecount(ehCount) ULONG* ehTypeOffsets = 0)
{
- return SectEH_Emit (size, ehCount, (IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT*)clauses, moreSections, outBuff, ehTypeOffsets);
+ return SectEH_Emit (size, ehCount, clauses, moreSections, outBuff, ehTypeOffsets);
};
}; // COR_ILMETHOD_SECT_EH
@@ -178,10 +178,10 @@ typedef struct tagCOR_ILMETHOD_TINY : IMAGE_COR_ILMETHOD_TINY
{
bool IsTiny () const { return (Flags_CodeSize & (CorILMethod_FormatMask >> 1)) == CorILMethod_TinyFormat; }
unsigned GetCodeSize () const { return ((unsigned) Flags_CodeSize) >> (CorILMethod_FormatShift-1); }
- unsigned GetMaxStack () const { return 8; }
+ unsigned GetMaxStack () { return 8; }
BYTE* GetCode () const { return ((BYTE*) this) + sizeof (struct tagCOR_ILMETHOD_TINY); }
- DWORD GetLocalVarSigTok () const { return 0; }
- COR_ILMETHOD_SECT* GetSect () const { return 0; }
+ DWORD GetLocalVarSigTok () { return 0; }
+ COR_ILMETHOD_SECT* GetSect () { return 0; }
} COR_ILMETHOD_TINY;
// This strucuture is the 'fat' layout, where no compression is attempted.
@@ -217,10 +217,10 @@ typedef COR_ILMETHOD_FAT *PCOR_ILMETHOD_FAT;
/************************************/
// exported functions (impl. Format\Format.cpp)
-unsigned __stdcall IlmethodSize (COR_ILMETHOD_FAT* header, BOOL MoreSections);
+unsigned __stdcall IlmethodSize (const COR_ILMETHOD_FAT* header, bool MoreSections);
// emit the header (bestFormat) return amount emitted
-unsigned __stdcall IlmethodEmit (unsigned size, COR_ILMETHOD_FAT* header, BOOL moreSections, _Out_cap_(size) BYTE* outBuff);
+unsigned __stdcall IlmethodEmit (unsigned size, const COR_ILMETHOD_FAT* header, bool moreSections, _Out_cap_(size) BYTE* outBuff);
struct COR_ILMETHOD
{
@@ -231,13 +231,13 @@ struct COR_ILMETHOD
// compute the size of the header (best format)
unsigned static Size (const COR_ILMETHOD_FAT* header, bool MoreSections)
{
- return IlmethodSize ((COR_ILMETHOD_FAT*)header,MoreSections);
+ return IlmethodSize (header,MoreSections);
};
// emit the header (bestFormat) return amount emitted
unsigned static Emit (unsigned size, const COR_ILMETHOD_FAT* header, bool moreSections, _Out_cap_(size) BYTE* outBuff)
{
- return IlmethodEmit (size, (COR_ILMETHOD_FAT*)header, moreSections, outBuff);
+ return IlmethodEmit (size, header, moreSections, outBuff);
};
//private:
@@ -284,4 +284,4 @@ class COR_ILMETHOD_DECODER : public COR_ILMETHOD_FAT
PCCOR_SIGNATURE LocalVarSig; // pointer to signature blob, or 0 if none
const COR_ILMETHOD_SECT_EH* EH; // eh table if any 0 if none
const COR_ILMETHOD_SECT* Sect; // additional sections 0 if none
-};
+};
\ No newline at end of file
diff --git a/src/InstrumentationEngine/CorProfilerInfoWrapper.cpp b/src/InstrumentationEngine/CorProfilerInfoWrapper.cpp
index 8cfdf867..df629294 100644
--- a/src/InstrumentationEngine/CorProfilerInfoWrapper.cpp
+++ b/src/InstrumentationEngine/CorProfilerInfoWrapper.cpp
@@ -160,13 +160,14 @@ ULONG MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::AddRef()
ULONG MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::Release()
{
- if (InterlockedDecrement(&m_refcount) == 0)
+ auto newRefCount = InterlockedDecrement(&m_refcount);
+ if (newRefCount == 0)
{
delete this;
return 0;
}
- return m_refcount;
+ return newRefCount;
}
HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::GetClassFromObject(
@@ -223,7 +224,7 @@ HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::GetFunctionFrom
HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::GetHandleFromThread(
_In_ ThreadID threadId,
- _In_ HANDLE* phThread
+ _Out_ HANDLE* phThread
)
{
return m_pRealCorProfilerInfo->GetHandleFromThread(threadId, phThread);
@@ -318,11 +319,11 @@ HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::GetTokenAndMeta
HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::GetModuleInfo(
_In_ ModuleID moduleId,
- _Out_ LPCBYTE* ppBaseLoadAddress,
+ _Out_opt_ LPCBYTE* ppBaseLoadAddress,
_In_ ULONG cchName,
_Out_ ULONG* pcchName,
- _Out_writes_(cchName) WCHAR szName[],
- _Out_ AssemblyID* pAssemblyId
+ _Out_writes_to_(cchName, *pcchName) WCHAR szName[],
+ _Out_opt_ AssemblyID* pAssemblyId
)
{
return m_pRealCorProfilerInfo->GetModuleInfo(moduleId, ppBaseLoadAddress, cchName, pcchName, szName, pAssemblyId);
@@ -477,7 +478,7 @@ HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::GetAppDomainInf
_In_ AppDomainID appDomainId,
_In_ ULONG cchName,
_Out_ ULONG* pcchName,
- _Out_writes_(cchName) WCHAR szName[],
+ _Out_writes_to_(cchName, *pcchName) WCHAR szName[],
_Out_ ProcessID* pProcessId
)
{
@@ -487,10 +488,10 @@ HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::GetAppDomainInf
HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::GetAssemblyInfo(
_In_ AssemblyID assemblyId,
_In_ ULONG cchName,
- _Out_ ULONG* pcchName,
- _Out_writes_to_(cchName,* pcchName) WCHAR szName[],
- _Out_ AppDomainID* pAppDomainId,
- _Out_ ModuleID* pModuleId
+ _Out_opt_ ULONG* pcchName,
+ _Out_writes_bytes_to_(cchName,* pcchName) WCHAR szName[],
+ _Out_opt_ AppDomainID* pAppDomainId,
+ _Out_opt_ ModuleID* pModuleId
)
{
return m_pRealCorProfilerInfo->GetAssemblyInfo(assemblyId, cchName, pcchName, szName, pAppDomainId, pModuleId);
@@ -577,7 +578,7 @@ HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::DoStackSnapshot
_In_ StackSnapshotCallback *callback,
_In_ ULONG32 infoFlags,
_In_ void *clientData,
- _In_ BYTE context[],
+ _In_reads_bytes_(contextSize) BYTE context[],
_In_ ULONG32 contextSize
)
{
@@ -598,12 +599,12 @@ HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::SetEnterLeaveFu
HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::GetFunctionInfo2(
_In_ FunctionID funcId,
_In_ COR_PRF_FRAME_INFO frameInfo,
- _Out_ ClassID* pClassId,
- _Out_ ModuleID* pModuleId,
- _Out_ mdToken* pToken,
+ _Out_opt_ ClassID* pClassId,
+ _Out_opt_ ModuleID* pModuleId,
+ _Out_opt_ mdToken* pToken,
_In_ ULONG32 cTypeArgs,
- _Out_ ULONG32* pcTypeArgs,
- _Out_writes_(cTypeArgs) ClassID typeArgs[]
+ _Out_opt_ ULONG32* pcTypeArgs,
+ _Out_writes_bytes_to_opt_(cTypeArgs, *pcTypeArgs) ClassID typeArgs[]
)
{
return m_pRealCorProfilerInfo2->GetFunctionInfo2(funcId, frameInfo, pClassId, pModuleId, pToken, cTypeArgs, pcTypeArgs, typeArgs);
@@ -633,7 +634,7 @@ HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::GetClassIDInfo2
_In_ ClassID classId,
_Out_ ModuleID* pModuleId,
_Out_ mdTypeDef* pTypeDefToken,
- ClassID* pParentClassId,
+ _Out_ ClassID* pParentClassId,
_In_ ULONG32 cNumTypeArgs,
_Out_ ULONG32* pcNumTypeArgs,
_Out_writes_(cNumTypeArgs) ClassID typeArgs[]
@@ -798,7 +799,7 @@ HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::RequestProfiler
HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::SetFunctionIDMapper2(
_In_ FunctionIDMapper2* pFunc,
- _Out_ void *clientData
+ _In_ void *clientData
)
{
return m_pRealCorProfilerInfo3->SetFunctionIDMapper2(pFunc, clientData);
@@ -870,15 +871,15 @@ HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::EnumModules(
}
HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::GetRuntimeInformation(
- _Out_ USHORT* pClrInstanceId,
- _Out_ COR_PRF_RUNTIME_TYPE* pRuntimeType,
- _Out_ USHORT* pMajorVersion,
- _Out_ USHORT* pMinorVersion,
- _Out_ USHORT* pBuildNumber,
- _Out_ USHORT* pQFEVersion,
+ _Out_opt_ USHORT* pClrInstanceId,
+ _Out_opt_ COR_PRF_RUNTIME_TYPE* pRuntimeType,
+ _Out_opt_ USHORT* pMajorVersion,
+ _Out_opt_ USHORT* pMinorVersion,
+ _Out_opt_ USHORT* pBuildNumber,
+ _Out_opt_ USHORT* pQFEVersion,
_In_ ULONG cchVersionString,
- _Out_ ULONG* pcchVersionString,
- _Out_writes_(cchVersionString) WCHAR szVersionString[]
+ _Out_opt_ ULONG* pcchVersionString,
+ _Out_writes_opt_(cchVersionString) WCHAR szVersionString[]
)
{
return m_pRealCorProfilerInfo3->GetRuntimeInformation(pClrInstanceId, pRuntimeType, pMajorVersion, pMinorVersion, pBuildNumber, pQFEVersion, cchVersionString, pcchVersionString, szVersionString);
@@ -907,12 +908,12 @@ HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::GetAppDomainsCo
HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::GetModuleInfo2(
_In_ ModuleID moduleId,
- _Out_ LPCBYTE* ppBaseLoadAddress,
+ _Out_opt_ LPCBYTE* ppBaseLoadAddress,
_In_ ULONG cchName,
- _Out_ ULONG* pcchName,
- _Out_writes_(cchName) WCHAR szName[],
- _Out_ AssemblyID* pAssemblyId,
- _Out_ DWORD* pdwModuleFlags
+ _Out_opt_ ULONG* pcchName,
+ _Out_writes_bytes_to_(cchName, *pcchName) WCHAR szName[],
+ _Out_opt_ AssemblyID* pAssemblyId,
+ _Out_opt_ DWORD* pdwModuleFlags
)
{
return m_pRealCorProfilerInfo3->GetModuleInfo2(moduleId, ppBaseLoadAddress, cchName, pcchName, szName, pAssemblyId, pdwModuleFlags);
@@ -943,7 +944,7 @@ HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::RequestRevert(
_In_ ULONG cFunctions,
_In_reads_(cFunctions) ModuleID moduleIds[],
_In_reads_(cFunctions) mdMethodDef methodIds[],
- _In_reads_(cFunctions) HRESULT status[]
+ _Out_writes_(cFunctions) HRESULT status[]
)
{
return m_pRealCorProfilerInfo4->RequestRevert(cFunctions, moduleIds, methodIds, status);
@@ -993,7 +994,7 @@ HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::GetILToNativeMa
}
HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::EnumJITedFunctions2(
- _In_ ICorProfilerFunctionEnum **ppEnum
+ _Out_ ICorProfilerFunctionEnum **ppEnum
)
{
return m_pRealCorProfilerInfo4->EnumJITedFunctions2(ppEnum);
@@ -1061,7 +1062,7 @@ HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::GetInMemorySymb
HRESULT MicrosoftInstrumentationEngine::CCorProfilerInfoWrapper::ReadInMemorySymbols(
_In_ ModuleID moduleId,
_In_ DWORD symbolsReadOffset,
- _Out_ BYTE *pSymbolBytes,
+ _Out_writes_(countSymbolBytes) BYTE *pSymbolBytes,
_In_ DWORD countSymbolBytes,
_Out_ DWORD *pCountSymbolBytesRead
)
diff --git a/src/InstrumentationEngine/CorProfilerInfoWrapper.h b/src/InstrumentationEngine/CorProfilerInfoWrapper.h
index 2a940482..ba9014ba 100644
--- a/src/InstrumentationEngine/CorProfilerInfoWrapper.h
+++ b/src/InstrumentationEngine/CorProfilerInfoWrapper.h
@@ -82,7 +82,7 @@ namespace MicrosoftInstrumentationEngine
STDMETHOD(GetHandleFromThread)(
_In_ ThreadID threadId,
- _In_ HANDLE* phThread
+ _Out_ HANDLE* phThread
);
STDMETHOD(GetObjectSize)(
@@ -142,11 +142,11 @@ namespace MicrosoftInstrumentationEngine
STDMETHOD(GetModuleInfo)(
_In_ ModuleID moduleId,
- _Out_ LPCBYTE* ppBaseLoadAddress,
+ _Out_opt_ LPCBYTE* ppBaseLoadAddress,
_In_ ULONG cchName,
_Out_ ULONG* pcchName,
- _Out_writes_(cchName) WCHAR szName[],
- _Out_ AssemblyID* pAssemblyId
+ _Out_writes_to_(cchName, *pcchName) WCHAR szName[],
+ _Out_opt_ AssemblyID* pAssemblyId
);
STDMETHOD(GetModuleMetaData)(
@@ -178,17 +178,17 @@ namespace MicrosoftInstrumentationEngine
_In_ AppDomainID appDomainId,
_In_ ULONG cchName,
_Out_ ULONG* pcchName,
- _Out_writes_(cchName) WCHAR szName[],
+ _Out_writes_to_(cchName, *pcchName) WCHAR szName[],
_Out_ ProcessID* pProcessId
);
STDMETHOD(GetAssemblyInfo)(
_In_ AssemblyID assemblyId,
_In_ ULONG cchName,
- _Out_ ULONG* pcchName,
- _Out_writes_to_(cchName, *pcchName) WCHAR szName[],
- _Out_ AppDomainID* pAppDomainId,
- _Out_ ModuleID* pModuleId
+ _Out_opt_ ULONG* pcchName,
+ _Out_writes_bytes_to_(cchName, *pcchName) WCHAR szName[],
+ _Out_opt_ AppDomainID* pAppDomainId,
+ _Out_opt_ ModuleID* pModuleId
);
STDMETHOD(SetFunctionReJIT)(
@@ -240,7 +240,7 @@ namespace MicrosoftInstrumentationEngine
_In_ StackSnapshotCallback *callback,
_In_ ULONG32 infoFlags,
_In_ void *clientData,
- _In_ BYTE context[],
+ _In_reads_bytes_(contextSize) BYTE context[],
_In_ ULONG32 contextSize
);
@@ -253,12 +253,12 @@ namespace MicrosoftInstrumentationEngine
STDMETHOD(GetFunctionInfo2)(
_In_ FunctionID funcId,
_In_ COR_PRF_FRAME_INFO frameInfo,
- _Out_ ClassID* pClassId,
- _Out_ ModuleID* pModuleId,
- _Out_ mdToken* pToken,
+ _Out_opt_ ClassID* pClassId,
+ _Out_opt_ ModuleID* pModuleId,
+ _Out_opt_ mdToken* pToken,
_In_ ULONG32 cTypeArgs,
- _Out_ ULONG32* pcTypeArgs,
- _Out_writes_(cTypeArgs) ClassID typeArgs[]
+ _Out_opt_ ULONG32* pcTypeArgs,
+ _Out_writes_bytes_to_opt_(cTypeArgs, *pcTypeArgs) ClassID typeArgs[]
);
STDMETHOD(GetStringLayout)(
@@ -279,7 +279,7 @@ namespace MicrosoftInstrumentationEngine
_In_ ClassID classId,
_Out_ ModuleID* pModuleId,
_Out_ mdTypeDef* pTypeDefToken,
- ClassID* pParentClassId,
+ _Out_ ClassID* pParentClassId,
_In_ ULONG32 cNumTypeArgs,
_Out_ ULONG32* pcNumTypeArgs,
_Out_writes_(cNumTypeArgs) ClassID typeArgs[]
@@ -391,7 +391,7 @@ namespace MicrosoftInstrumentationEngine
STDMETHOD(SetFunctionIDMapper2)(
_In_ FunctionIDMapper2* pFunc,
- _Out_ void *clientData
+ _In_ void *clientData
);
STDMETHOD(GetStringLayout2)(
@@ -437,15 +437,15 @@ namespace MicrosoftInstrumentationEngine
);
STDMETHOD(GetRuntimeInformation)(
- _Out_ USHORT* pClrInstanceId,
- _Out_ COR_PRF_RUNTIME_TYPE* pRuntimeType,
- _Out_ USHORT* pMajorVersion,
- _Out_ USHORT* pMinorVersion,
- _Out_ USHORT* pBuildNumber,
- _Out_ USHORT* pQFEVersion,
+ _Out_opt_ USHORT* pClrInstanceId,
+ _Out_opt_ COR_PRF_RUNTIME_TYPE* pRuntimeType,
+ _Out_opt_ USHORT* pMajorVersion,
+ _Out_opt_ USHORT* pMinorVersion,
+ _Out_opt_ USHORT* pBuildNumber,
+ _Out_opt_ USHORT* pQFEVersion,
_In_ ULONG cchVersionString,
- _Out_ ULONG* pcchVersionString,
- _Out_writes_(cchVersionString) WCHAR szVersionString[]
+ _Out_opt_ ULONG* pcchVersionString,
+ _Out_writes_opt_(cchVersionString) WCHAR szVersionString[]
);
STDMETHOD(GetThreadStaticAddress2)(
@@ -465,12 +465,12 @@ namespace MicrosoftInstrumentationEngine
STDMETHOD(GetModuleInfo2)(
_In_ ModuleID moduleId,
- _Out_ LPCBYTE* ppBaseLoadAddress,
+ _Out_opt_ LPCBYTE* ppBaseLoadAddress,
_In_ ULONG cchName,
- _Out_ ULONG* pcchName,
- _Out_writes_(cchName) WCHAR szName[],
- _Out_ AssemblyID* pAssemblyId,
- _Out_ DWORD* pdwModuleFlags
+ _Out_opt_ ULONG* pcchName,
+ _Out_writes_bytes_to_(cchName, *pcchName) WCHAR szName[],
+ _Out_opt_ AssemblyID* pAssemblyId,
+ _Out_opt_ DWORD* pdwModuleFlags
);
// ICorProfilerInfo4
@@ -492,7 +492,7 @@ namespace MicrosoftInstrumentationEngine
_In_ ULONG cFunctions,
_In_reads_(cFunctions) ModuleID moduleIds[],
_In_reads_(cFunctions) mdMethodDef methodIds[],
- _In_reads_(cFunctions) HRESULT status[]
+ _Out_writes_(cFunctions) HRESULT status[]
);
STDMETHOD(GetCodeInfo3)(
@@ -525,7 +525,7 @@ namespace MicrosoftInstrumentationEngine
);
STDMETHOD(EnumJITedFunctions2)(
- _In_ ICorProfilerFunctionEnum **ppEnum
+ _Out_ ICorProfilerFunctionEnum **ppEnum
);
STDMETHOD(GetObjectSize2)(
@@ -569,7 +569,7 @@ namespace MicrosoftInstrumentationEngine
STDMETHOD(ReadInMemorySymbols)(
_In_ ModuleID moduleId,
_In_ DWORD symbolsReadOffset,
- _Out_ BYTE *pSymbolBytes,
+ _Out_writes_(countSymbolBytes) BYTE *pSymbolBytes,
_In_ DWORD countSymbolBytes,
_Out_ DWORD *pCountSymbolBytesRead
);
diff --git a/src/InstrumentationEngine/ExceptionClause.cpp b/src/InstrumentationEngine/ExceptionClause.cpp
index 12e091e5..cf2f3737 100644
--- a/src/InstrumentationEngine/ExceptionClause.cpp
+++ b/src/InstrumentationEngine/ExceptionClause.cpp
@@ -98,14 +98,14 @@ HRESULT MicrosoftInstrumentationEngine::CExceptionClause::RenderExceptionClause(
DWORD lastTrySize = 0;
IfFailRet(m_pTryFirstInstruction->GetOffset(&firstTryOffset));
IfFailRet(m_pTryLastInstruction->GetOffset(&lastTryOffset));
- IfFailRet(m_pTryLastInstruction->GetInstructionSize(&lastTrySize));
+ IfFailRet(CInstruction::GetInstructionSize(m_pTryLastInstruction, &lastTrySize));
DWORD firstHandlerOffset = 0;
DWORD lastHandlerOffset = 0;
DWORD lastHandlerSize = 0;
IfFailRet(m_pHandlerFirstInstruction->GetOffset(&firstHandlerOffset));
IfFailRet(m_pHandlerLastInstruction->GetOffset(&lastHandlerOffset));
- IfFailRet(m_pHandlerLastInstruction->GetInstructionSize(&lastHandlerSize));
+ IfFailRet(CInstruction::GetInstructionSize(m_pHandlerLastInstruction, &lastHandlerSize));
pEHClause->TryOffset = firstTryOffset;
@@ -201,7 +201,7 @@ HRESULT MicrosoftInstrumentationEngine::CExceptionClause::GetTryFirstInstruction
if (m_pTryFirstInstruction != NULL)
{
- *ppInstruction = (IInstruction*)(m_pTryFirstInstruction.p);
+ *ppInstruction = m_pTryFirstInstruction.p;
(*ppInstruction)->AddRef();
}
@@ -218,7 +218,7 @@ HRESULT MicrosoftInstrumentationEngine::CExceptionClause::GetTryLastInstruction(
if (m_pTryLastInstruction != NULL)
{
- *ppInstruction = (IInstruction*)(m_pTryLastInstruction.p);
+ *ppInstruction = m_pTryLastInstruction.p;
(*ppInstruction)->AddRef();
}
@@ -235,7 +235,7 @@ HRESULT MicrosoftInstrumentationEngine::CExceptionClause::GetHandlerFirstInstruc
if (m_pHandlerFirstInstruction != NULL)
{
- *ppInstruction = (IInstruction*)(m_pHandlerFirstInstruction.p);
+ *ppInstruction = m_pHandlerFirstInstruction.p;
(*ppInstruction)->AddRef();
}
@@ -252,7 +252,7 @@ HRESULT MicrosoftInstrumentationEngine::CExceptionClause::GetHandlerLastInstruct
if (m_pHandlerLastInstruction != NULL)
{
- *ppInstruction = (IInstruction*)(m_pHandlerLastInstruction.p);
+ *ppInstruction = m_pHandlerLastInstruction.p;
(*ppInstruction)->AddRef();
}
@@ -269,7 +269,7 @@ HRESULT MicrosoftInstrumentationEngine::CExceptionClause::GetFilterFirstInstruct
if (m_pFilterFirstInstruction != NULL)
{
- *ppInstruction = (IInstruction*)(m_pFilterFirstInstruction.p);
+ *ppInstruction = m_pFilterFirstInstruction.p;
(*ppInstruction)->AddRef();
}
@@ -308,7 +308,7 @@ HRESULT MicrosoftInstrumentationEngine::CExceptionClause::SetTryFirstInstruction
HRESULT hr = S_OK;
CLogging::LogMessage(_T("Starting CExceptionClause::SetTryFirstInstruction"));
- m_pTryFirstInstruction = (CInstruction*)pInstruction;
+ m_pTryFirstInstruction = pInstruction;
CLogging::LogMessage(_T("End CExceptionClause::SetTryFirstInstruction"));
return hr;
@@ -319,7 +319,7 @@ HRESULT MicrosoftInstrumentationEngine::CExceptionClause::SetTryLastInstruction(
HRESULT hr = S_OK;
CLogging::LogMessage(_T("Starting CExceptionClause::SetTryLastInstruction"));
- m_pTryLastInstruction = (CInstruction*)pInstruction;
+ m_pTryLastInstruction = pInstruction;
CLogging::LogMessage(_T("End CExceptionClause::SetTryLastInstruction"));
return hr;
@@ -330,7 +330,7 @@ HRESULT MicrosoftInstrumentationEngine::CExceptionClause::SetHandlerFirstInstruc
HRESULT hr = S_OK;
CLogging::LogMessage(_T("Starting CExceptionClause::SetHandlerFirstInstruction"));
- m_pHandlerFirstInstruction = (CInstruction*)pInstruction;
+ m_pHandlerFirstInstruction = pInstruction;
CLogging::LogMessage(_T("End CExceptionClause::SetHandlerFirstInstruction"));
return hr;
@@ -341,7 +341,7 @@ HRESULT MicrosoftInstrumentationEngine::CExceptionClause::SetHandlerLastInstruct
HRESULT hr = S_OK;
CLogging::LogMessage(_T("Starting CExceptionClause::SetHandlerLastInstruction"));
- m_pHandlerLastInstruction = (CInstruction*)pInstruction;
+ m_pHandlerLastInstruction = pInstruction;
CLogging::LogMessage(_T("End CExceptionClause::SetHandlerLastInstruction"));
return hr;
@@ -352,7 +352,7 @@ HRESULT MicrosoftInstrumentationEngine::CExceptionClause::SetFilterFirstInstruct
HRESULT hr = S_OK;
CLogging::LogMessage(_T("Starting CExceptionClause::SetFilterFirstInstruction"));
- m_pFilterFirstInstruction = (CInstruction*)pInstruction;
+ m_pFilterFirstInstruction = pInstruction;
CLogging::LogMessage(_T("End CExceptionClause::SetFilterFirstInstruction"));
return hr;
diff --git a/src/InstrumentationEngine/ExceptionClause.h b/src/InstrumentationEngine/ExceptionClause.h
index dbe4c4b2..3cb263ed 100644
--- a/src/InstrumentationEngine/ExceptionClause.h
+++ b/src/InstrumentationEngine/ExceptionClause.h
@@ -18,11 +18,11 @@ namespace MicrosoftInstrumentationEngine
{
private:
CorExceptionFlag m_flags;
- CComPtr m_pTryFirstInstruction;
- CComPtr m_pTryLastInstruction;
- CComPtr m_pHandlerFirstInstruction;
- CComPtr m_pHandlerLastInstruction;
- CComPtr m_pFilterFirstInstruction;
+ CComPtr m_pTryFirstInstruction;
+ CComPtr m_pTryLastInstruction;
+ CComPtr m_pHandlerFirstInstruction;
+ CComPtr m_pHandlerLastInstruction;
+ CComPtr m_pFilterFirstInstruction;
mdToken m_ExceptionHandlerType;
diff --git a/src/InstrumentationEngine/ExceptionSection.cpp b/src/InstrumentationEngine/ExceptionSection.cpp
index 9fa7dbb1..9ea1a92a 100644
--- a/src/InstrumentationEngine/ExceptionSection.cpp
+++ b/src/InstrumentationEngine/ExceptionSection.cpp
@@ -115,7 +115,7 @@ HRESULT MicrosoftInstrumentationEngine::CExceptionSection::CreateExceptionHeader
pEHSect->DataSize = dataSize;
int i=0;
- for(vector>::iterator iter = m_exceptionClauses.begin(); iter != m_exceptionClauses.end(); iter++)
+ for(vector>::iterator iter = m_exceptionClauses.begin(); iter != m_exceptionClauses.end(); ++iter)
{
CComPtr pClause = *iter;
((CExceptionClause*)pClause.p)->RenderExceptionClause(&pEHSect->Clauses[i]);
@@ -195,7 +195,7 @@ HRESULT MicrosoftInstrumentationEngine::CExceptionSection::RemoveExceptionClause
CCriticalSectionHolder lock(&m_cs);
- for (vector>::iterator iter = m_exceptionClauses.begin(); iter != m_exceptionClauses.end(); iter++)
+ for (vector>::iterator iter = m_exceptionClauses.begin(); iter != m_exceptionClauses.end(); ++iter)
{
if (*iter == pExceptionClause)
{
@@ -231,7 +231,7 @@ HRESULT MicrosoftInstrumentationEngine::CExceptionSection::UpdateInstruction(_In
CCriticalSectionHolder lock(&m_cs);
- for (vector>::iterator iter = m_exceptionClauses.begin(); iter != m_exceptionClauses.end(); iter++)
+ for (vector>::iterator iter = m_exceptionClauses.begin(); iter != m_exceptionClauses.end(); ++iter)
{
CExceptionClause* pClause = (CExceptionClause*)((*iter).p);
pClause->UpdateInstruction(pInstructionOld, pInstructionNew);
@@ -301,7 +301,7 @@ HRESULT MicrosoftInstrumentationEngine::CExceptionSection::FindExceptionClauseIn
// is the correct range to insert after.
if (m_exceptionClauses.begin() != m_exceptionClauses.end())
{
- for (vector>::reverse_iterator iter = m_exceptionClauses.rbegin(); iter != m_exceptionClauses.rend(); iter++)
+ for (vector>::reverse_iterator iter = m_exceptionClauses.rbegin(); iter != m_exceptionClauses.rend(); ++iter)
{
CComPtr pExistingExceptionClause = *iter;
diff --git a/src/InstrumentationEngine/GenericInstanceType.cpp b/src/InstrumentationEngine/GenericInstanceType.cpp
index fa9bcb01..dd1103a2 100644
--- a/src/InstrumentationEngine/GenericInstanceType.cpp
+++ b/src/InstrumentationEngine/GenericInstanceType.cpp
@@ -4,9 +4,10 @@
#include "stdafx.h"
#include "GenericInstanceType.h"
-MicrosoftInstrumentationEngine::CGenericInstance::CGenericInstance(_In_ IType* typeDefinition, _In_ std::vector genericParameters) : CCompositeType(ELEMENT_TYPE_GENERICINST, typeDefinition)
+MicrosoftInstrumentationEngine::CGenericInstance::CGenericInstance(_In_ IType* typeDefinition, _In_ const std::vector& genericParameters) : CCompositeType(ELEMENT_TYPE_GENERICINST, typeDefinition)
{
DEFINE_REFCOUNT_NAME(CGenericInstance);
+ m_genericParameters.reserve(genericParameters.size());
for (IType* type : genericParameters)
{
m_genericParameters.push_back(CComPtr(type));
diff --git a/src/InstrumentationEngine/GenericInstanceType.h b/src/InstrumentationEngine/GenericInstanceType.h
index d73d044e..af1a9e5c 100644
--- a/src/InstrumentationEngine/GenericInstanceType.h
+++ b/src/InstrumentationEngine/GenericInstanceType.h
@@ -15,7 +15,7 @@ namespace MicrosoftInstrumentationEngine
private:
std::vector> m_genericParameters;
protected:
- CGenericInstance(_In_ IType* typeDefinition, _In_ std::vector genericParameters);
+ CGenericInstance(_In_ IType* typeDefinition, _In_ const std::vector& genericParameters);
// IType
public:
STDMETHOD(AddToSignature)(_In_ ISignatureBuilder* pSignatureBuilder);
diff --git a/src/InstrumentationEngine/InlineSite.cpp b/src/InstrumentationEngine/InlineSite.cpp
index ce4be5a7..0c075858 100644
--- a/src/InstrumentationEngine/InlineSite.cpp
+++ b/src/InstrumentationEngine/InlineSite.cpp
@@ -14,17 +14,17 @@ MicrosoftInstrumentationEngine::CInlineSite::CInlineSite(
{
}
-mdToken MicrosoftInstrumentationEngine::CInlineSite::GetInlineeToken()
+mdToken MicrosoftInstrumentationEngine::CInlineSite::GetInlineeToken() const
{
return m_inlineeToken;
}
-mdToken MicrosoftInstrumentationEngine::CInlineSite::GetInlineSiteToken()
+mdToken MicrosoftInstrumentationEngine::CInlineSite::GetInlineSiteToken() const
{
return m_inlineSiteToken;
}
-ModuleID MicrosoftInstrumentationEngine::CInlineSite::GetModuleID()
+ModuleID MicrosoftInstrumentationEngine::CInlineSite::GetModuleID() const
{
return m_moduleID;
}
\ No newline at end of file
diff --git a/src/InstrumentationEngine/InlineSite.h b/src/InstrumentationEngine/InlineSite.h
index 0daf319d..a0fa1bbd 100644
--- a/src/InstrumentationEngine/InlineSite.h
+++ b/src/InstrumentationEngine/InlineSite.h
@@ -21,8 +21,8 @@ namespace MicrosoftInstrumentationEngine
_In_ ModuleID m_moduleID
);
- mdToken GetInlineeToken();
- mdToken GetInlineSiteToken();
- ModuleID GetModuleID();
+ mdToken GetInlineeToken() const;
+ mdToken GetInlineSiteToken() const;
+ ModuleID GetModuleID() const;
};
}
\ No newline at end of file
diff --git a/src/InstrumentationEngine/Instruction.cpp b/src/InstrumentationEngine/Instruction.cpp
index 9cbdf8a3..5258275f 100644
--- a/src/InstrumentationEngine/Instruction.cpp
+++ b/src/InstrumentationEngine/Instruction.cpp
@@ -4,7 +4,7 @@
#include "stdafx.h"
#include "Instruction.h"
-HRESULT MicrosoftInstrumentationEngine::CInstruction::LogInstruction(_In_ BOOL ignoreTest)
+HRESULT MicrosoftInstrumentationEngine::CInstruction::LogInstruction(bool ignoreTest)
{
HRESULT hr = S_OK;
@@ -207,7 +207,7 @@ HRESULT MicrosoftInstrumentationEngine::CInstruction::InstructionFromBytes(
// static
-HRESULT MicrosoftInstrumentationEngine::CInstruction::OrdinalOpcodeFromBytes(_In_ LPCBYTE pCode, _In_ LPCBYTE pEndOfCode, _Out_ ILOrdinalOpcode* pOpcode)
+HRESULT MicrosoftInstrumentationEngine::CInstruction::OrdinalOpcodeFromBytes(_In_reads_to_ptr_(pEndOfCode) LPCBYTE pCode, _In_ LPCBYTE pEndOfCode, _Out_ ILOrdinalOpcode* pOpcode)
{
HRESULT hr = S_OK;
IfNullRetPointer(pOpcode);
@@ -232,12 +232,12 @@ HRESULT MicrosoftInstrumentationEngine::CInstruction::OrdinalOpcodeFromBytes(_In
}
//virtual
-HRESULT MicrosoftInstrumentationEngine::CInstruction::EmitIL(_In_ BYTE* pILBuffer, _In_ DWORD dwcbILBuffer)
+HRESULT MicrosoftInstrumentationEngine::CInstruction::EmitIL(_In_reads_bytes_(dwcbILBuffer) BYTE* pILBuffer, _In_ DWORD dwcbILBuffer)
{
HRESULT hr = S_OK;
ULONG curpos = m_offset;
- CInstruction::ILOpcodeInfo &opcodeInfo = CInstruction::s_ilOpcodeInfo [m_opcode];
+ const CInstruction::ILOpcodeInfo &opcodeInfo = CInstruction::s_ilOpcodeInfo [m_opcode];
unsigned opcodeLength = opcodeInfo.m_opcodeLength;
if (curpos + opcodeLength + opcodeInfo.m_operandLength > dwcbILBuffer)
@@ -331,7 +331,7 @@ HRESULT MicrosoftInstrumentationEngine::CInstruction::EmitIL(_In_ BYTE* pILBuffe
return S_OK;
}
-MicrosoftInstrumentationEngine::CInstruction::CInstruction(_In_ ILOrdinalOpcode opcode, _In_ BOOL isNew) :
+MicrosoftInstrumentationEngine::CInstruction::CInstruction(_In_ ILOrdinalOpcode opcode, _In_ bool isNew) :
m_opcode(opcode),
m_offset(0),
m_origOffset(0),
@@ -343,7 +343,7 @@ MicrosoftInstrumentationEngine::CInstruction::CInstruction(_In_ ILOrdinalOpcode
}
HRESULT MicrosoftInstrumentationEngine::CInstruction::InitializeFromBytes(
- _In_ LPCBYTE pCode,
+ _In_reads_to_ptr_(pEndOfCode) LPCBYTE pCode,
_In_ LPCBYTE pEndOfCode
)
{
@@ -354,7 +354,7 @@ HRESULT MicrosoftInstrumentationEngine::CInstruction::InitializeFromBytes(
HRESULT MicrosoftInstrumentationEngine::CInstruction::SetIsRemoved()
{
- this->m_bIsRemoved = true;
+ this->m_bIsRemoved = TRUE;
this->m_pGraph = nullptr;
return S_OK;
}
@@ -522,17 +522,18 @@ HRESULT MicrosoftInstrumentationEngine::CInstruction::GetIsRemoved(_Out_ BOOL* p
return S_OK;
}
-HRESULT MicrosoftInstrumentationEngine::CInstruction::GetInstructionSize(_Out_ DWORD* pdwSize)
+HRESULT MicrosoftInstrumentationEngine::CInstruction::GetInstructionSize(_In_ IInstruction* pInstruction, _Out_ DWORD* pdwSize)
{
HRESULT hr = S_OK;
CLogging::LogMessage(_T("Starting CInstruction::GetInstructionSize"));
+ IfNullRetPointer(pInstruction);
IfNullRetPointer(pdwSize);
DWORD dwOpCodeLength = 0;
- IfFailRet(this->GetOpcodeLength(&dwOpCodeLength));
+ IfFailRet(pInstruction->GetOpcodeLength(&dwOpCodeLength));
DWORD dwOperandLength = 0;
- IfFailRet(this->GetOperandLength(&dwOperandLength));
+ IfFailRet(pInstruction->GetOperandLength(&dwOperandLength));
*pdwSize = dwOpCodeLength + dwOperandLength;
@@ -541,6 +542,11 @@ HRESULT MicrosoftInstrumentationEngine::CInstruction::GetInstructionSize(_Out_ D
return S_OK;
}
+HRESULT MicrosoftInstrumentationEngine::CInstruction::GetInstructionSize(_Out_ DWORD* pdwSize)
+{
+ return GetInstructionSize(this, pdwSize);
+}
+
HRESULT MicrosoftInstrumentationEngine::CInstruction::GetIsBranch(_Out_ BOOL* pbValue)
{
HRESULT hr = S_OK;
@@ -829,7 +835,7 @@ HRESULT MicrosoftInstrumentationEngine::CInstruction::GetInstructionGeneration(_
MicrosoftInstrumentationEngine::COperandInstruction::COperandInstruction(
_In_ ILOrdinalOpcode opcode,
- _In_ BOOL isNew,
+ _In_ bool isNew,
_In_ DWORD cbBytes,
_In_ BYTE* pBytes
) : CInstruction(opcode, isNew)
@@ -845,7 +851,7 @@ MicrosoftInstrumentationEngine::COperandInstruction::COperandInstruction(
MicrosoftInstrumentationEngine::COperandInstruction::COperandInstruction(
_In_ ILOrdinalOpcode opcode,
- _In_ BOOL isNew
+ _In_ bool isNew
)
: CInstruction(opcode, isNew)
{
@@ -853,7 +859,7 @@ MicrosoftInstrumentationEngine::COperandInstruction::COperandInstruction(
}
HRESULT MicrosoftInstrumentationEngine::COperandInstruction::InitializeFromBytes(
- _In_ LPCBYTE pCode,
+ _In_reads_to_ptr_(pEndOfCode) LPCBYTE pCode,
_In_ LPCBYTE pEndOfCode
)
{
@@ -1028,7 +1034,7 @@ HRESULT MicrosoftInstrumentationEngine::COperandInstruction::SetOperandValue(
MicrosoftInstrumentationEngine::CBranchInstruction::CBranchInstruction(
_In_ ILOrdinalOpcode opcode,
- _In_ BOOL isNew
+ _In_ bool isNew
)
: CInstruction(opcode, isNew),
m_decodedTargetOffset(0)
@@ -1037,7 +1043,7 @@ MicrosoftInstrumentationEngine::CBranchInstruction::CBranchInstruction(
}
HRESULT MicrosoftInstrumentationEngine::CBranchInstruction::InitializeFromBytes(
- _In_ LPCBYTE pCode,
+ _In_reads_to_ptr_(pEndOfCode) LPCBYTE pCode,
_In_ LPCBYTE pEndOfCode
)
{
@@ -1167,7 +1173,7 @@ HRESULT MicrosoftInstrumentationEngine::CBranchInstruction::SetBranchTarget(_In_
CLogging::LogMessage(_T("Starting CBranchInstruction::SetBranchTarget"));
IfNullRetPointer(pInstruction);
- m_pBranchTarget = (CInstruction*)pInstruction;
+ m_pBranchTarget = pInstruction;
if (m_pBranchTarget == nullptr)
{
@@ -1188,7 +1194,7 @@ HRESULT MicrosoftInstrumentationEngine::CBranchInstruction::SetBranchTarget(_In_
MicrosoftInstrumentationEngine::CSwitchInstruction::CSwitchInstruction(
_In_ ILOrdinalOpcode opcode,
- _In_ BOOL isNew
+ _In_ bool isNew
) : CInstruction(opcode, isNew)
{
@@ -1196,7 +1202,7 @@ MicrosoftInstrumentationEngine::CSwitchInstruction::CSwitchInstruction(
MicrosoftInstrumentationEngine::CSwitchInstruction::CSwitchInstruction(
_In_ ILOrdinalOpcode opcode,
- _In_ BOOL isNew,
+ _In_ bool isNew,
_In_ DWORD cBranchTargets,
_In_reads_(cBranchTargets) IInstruction** ppBranchTargets
) : CInstruction(opcode, isNew)
@@ -1206,13 +1212,13 @@ MicrosoftInstrumentationEngine::CSwitchInstruction::CSwitchInstruction(
for (DWORD i = 0; i < cBranchTargets; i++)
{
- CComPtr pTarget = (CInstruction*)(ppBranchTargets[i]);
+ CComPtr pTarget = ppBranchTargets[i];
m_branchTargets[i] = pTarget;
}
}
HRESULT MicrosoftInstrumentationEngine::CSwitchInstruction::InitializeFromBytes(
- _In_ LPCBYTE pCode,
+ _In_reads_to_ptr_(pEndOfCode) LPCBYTE pCode,
_In_ LPCBYTE pEndOfCode
)
{
@@ -1267,7 +1273,7 @@ HRESULT MicrosoftInstrumentationEngine::CSwitchInstruction::GetBranchTarget(_In_
return hr;
}
-CInstruction* MicrosoftInstrumentationEngine::CSwitchInstruction::GetBranchTargetInternal(_In_ DWORD index)
+IInstruction* MicrosoftInstrumentationEngine::CSwitchInstruction::GetBranchTargetInternal(_In_ DWORD index)
{
if (index >= m_branchTargets.size())
{
@@ -1275,7 +1281,7 @@ CInstruction* MicrosoftInstrumentationEngine::CSwitchInstruction::GetBranchTarge
return NULL;
}
- const CComPtr& pInstruction = m_branchTargets[index];
+ const CComPtr& pInstruction = m_branchTargets[index];
if (pInstruction == NULL)
{
CLogging::LogError(_T("CSwitchInstruction::GetBranchTarget - branch target at index is null"));
@@ -1291,7 +1297,7 @@ HRESULT MicrosoftInstrumentationEngine::CSwitchInstruction::SetBranchTarget(_In_
HRESULT hr = S_OK;
CLogging::LogMessage(_T("Starting CSwitchInstruction::SetBranchTarget"));
- m_branchTargets[index] = (CInstruction*)(pTarget);
+ m_branchTargets[index] = pTarget;
CLogging::LogMessage(_T("End CSwitchInstruction::SetBranchTarget"));
@@ -1315,11 +1321,11 @@ HRESULT MicrosoftInstrumentationEngine::CSwitchInstruction::RemoveBranchTarget(_
HRESULT hr = S_OK;
CLogging::LogMessage(_T("Starting CSwitchInstruction::RemoveBranchTarget"));
- for(std::vector>::iterator iter = m_branchTargets.begin(); iter != m_branchTargets.end(); iter++)
+ for(std::vector>::iterator iter = m_branchTargets.begin(); iter != m_branchTargets.end(); ++iter)
{
if(*iter == pTarget)
{
- m_branchTargets.erase(iter);
+ iter = m_branchTargets.erase(iter);
}
}
@@ -1371,7 +1377,7 @@ HRESULT MicrosoftInstrumentationEngine::CSwitchInstruction::GetBranchOffset(_In_
IfNullRetPointer(pdwOffset);
- CComPtr pInstruction = m_branchTargets[index];
+ CComPtr pInstruction = m_branchTargets[index];
if (pInstruction != NULL)
{
IfFailRet(pInstruction->GetOffset(pdwOffset));
diff --git a/src/InstrumentationEngine/Instruction.h b/src/InstrumentationEngine/Instruction.h
index ce5b9ba3..a4dfabce 100644
--- a/src/InstrumentationEngine/Instruction.h
+++ b/src/InstrumentationEngine/Instruction.h
@@ -55,11 +55,11 @@ namespace MicrosoftInstrumentationEngine
public:
CInstruction(
_In_ ILOrdinalOpcode opcode,
- _In_ BOOL isNew
+ _In_ bool isNew
);
virtual HRESULT InitializeFromBytes(
- _In_ LPCBYTE pCode,
+ _In_reads_to_ptr_(pEndOfCode) LPCBYTE pCode,
_In_ LPCBYTE pEndOfCode
);
@@ -68,12 +68,11 @@ namespace MicrosoftInstrumentationEngine
DEFINE_DELEGATED_REFCOUNT_RELEASE(CInstruction);
STDMETHOD(QueryInterface)(_In_ REFIID riid, _Out_ void **ppvObject) override
{
- return ImplQueryInterface(
- static_cast(this),
- static_cast(this),
+ return QueryInterfaceInternal(
riid,
- ppvObject
- );
+ ppvObject,
+ static_cast(this),
+ static_cast(this));
}
public:
@@ -86,6 +85,8 @@ namespace MicrosoftInstrumentationEngine
HRESULT SetGraph(_In_ CInstructionGraph* pGraph);
constexpr CInstructionGraph* GetGraph() { return m_pGraph; }
+ static HRESULT GetInstructionSize(_In_ IInstruction* pInstruction, _Out_ DWORD* pdwSize);
+
public:
virtual HRESULT __stdcall GetOffset(_Out_ DWORD* pdwOffset) override;
virtual HRESULT __stdcall GetOriginalOffset(_Out_ DWORD* pdwOffset) override;
@@ -143,19 +144,41 @@ namespace MicrosoftInstrumentationEngine
HRESULT SetInstructionGeneration(_In_ InstructionGeneration instructionGeneration);
static HRESULT InstructionFromBytes(_In_ LPCBYTE pCode, _In_ LPCBYTE pEndOfCode, _Out_ CInstruction** ppInstruction);
- static HRESULT OrdinalOpcodeFromBytes(_In_ LPCBYTE pCode, _In_ LPCBYTE pEndOfCode, _Out_ ILOrdinalOpcode* pOpcode);
+ static HRESULT OrdinalOpcodeFromBytes(_In_reads_to_ptr_(pEndOfCode) LPCBYTE pCode, _In_ LPCBYTE pEndOfCode, _Out_ ILOrdinalOpcode* pOpcode);
- HRESULT EmitIL(_In_ BYTE* pILBuffer, _In_ DWORD dwcbILBuffer);
+ HRESULT EmitIL(_In_reads_bytes_(dwcbILBuffer) BYTE* pILBuffer, _In_ DWORD dwcbILBuffer);
- HRESULT LogInstruction(_In_ BOOL ignoreTest);
+ HRESULT LogInstruction(bool ignoreTest);
constexpr CInstruction* NextInstructionInternal() { return m_pNextInstruction.p; }
constexpr CInstruction* PreviousInstructionInternal() { return m_pPreviousInstruction.p; }
constexpr CInstruction* OriginalNextInstructionInternal() { return m_pOriginalNextInstruction.p; }
constexpr CInstruction* OriginalPreviousInstructionInternal() { return m_pOriginalPreviousInstruction.p; }
- constexpr bool GetIsSwitchInternal() { return m_opcode == Cee_Switch; }
- bool GetIsBranchInternal() { return IsFlagSet(s_ilOpcodeInfo[m_opcode].m_flags, ILOpcodeFlag_Branch); }
+ constexpr bool GetIsSwitchInternal() const { return m_opcode == Cee_Switch; }
+ bool GetIsBranchInternal() const { return IsFlagSet(s_ilOpcodeInfo[m_opcode].m_flags, ILOpcodeFlag_Branch); }
+
+ protected:
+ template
+ HRESULT QueryInterfaceInternal(_In_ REFIID riid, _Out_ void** ppvObject, Args... pThisArgs)
+ {
+ // Workaround for the diamond inheritence problem.
+ // Both CDataContainer and IInstruction inherit from IUnknown and
+ // ImplQueryInterface() doesn't know which one to pick when casting CInstruction* to IUnknown*.
+ // A more comprehensive fix will be covered by https://github.com/microsoft/CLRInstrumentationEngine/issues/311
+ if (__uuidof(CInstruction) == riid && ppvObject != nullptr)
+ {
+ *ppvObject = static_cast(this);
+ AddRef();
+ return S_OK;
+ }
+
+ return ImplQueryInterface(
+ std::forward(pThisArgs)...,
+ riid,
+ ppvObject
+ );
+ }
private:
// If the callee token is a MethodSpec (generic method), the parameter count and signature returned
@@ -198,18 +221,18 @@ namespace MicrosoftInstrumentationEngine
public:
COperandInstruction(
_In_ ILOrdinalOpcode opcode,
- _In_ BOOL isNew,
+ _In_ bool isNew,
_In_ DWORD cbBytes,
_In_ BYTE* pBytes
);
COperandInstruction(
_In_ ILOrdinalOpcode opcode,
- _In_ BOOL isNew
+ _In_ bool isNew
);
virtual HRESULT InitializeFromBytes(
- _In_ LPCBYTE pCode,
+ _In_reads_to_ptr_(pEndOfCode) LPCBYTE pCode,
_In_ LPCBYTE pEndOfCode
) override;
@@ -218,13 +241,12 @@ namespace MicrosoftInstrumentationEngine
DEFINE_DELEGATED_REFCOUNT_RELEASE(COperandInstruction);
STDMETHOD(QueryInterface)(_In_ REFIID riid, _Out_ void **ppvObject) override
{
- return ImplQueryInterface(
+ return QueryInterfaceInternal(
+ riid,
+ ppvObject,
static_cast(this),
static_cast(this),
- static_cast(this),
- riid,
- ppvObject
- );
+ static_cast(this));
}
// IOperandInstruction methods
@@ -256,13 +278,12 @@ namespace MicrosoftInstrumentationEngine
DEFINE_DELEGATED_REFCOUNT_RELEASE(CLoadConstInstruction);
STDMETHOD(QueryInterface)(_In_ REFIID riid, _Out_ void **ppvObject) override
{
- return ImplQueryInterface(
+ return QueryInterfaceInternal(
+ riid,
+ ppvObject,
static_cast((COperandInstruction*)this),
static_cast((CInstruction*)this),
- static_cast(this),
- riid,
- ppvObject
- );
+ static_cast(this));
}
};
@@ -279,13 +300,12 @@ namespace MicrosoftInstrumentationEngine
DEFINE_DELEGATED_REFCOUNT_RELEASE(CLoadConstInstruction);
STDMETHOD(QueryInterface)(_In_ REFIID riid, _Out_ void **ppvObject) override
{
- return ImplQueryInterface(
+ return QueryInterfaceInternal(
+ riid,
+ ppvObject,
static_cast((COperandInstruction*)this),
static_cast((CInstruction*)this),
- static_cast(this),
- riid,
- ppvObject
- );
+ static_cast(this));
}
};
@@ -302,13 +322,12 @@ namespace MicrosoftInstrumentationEngine
DEFINE_DELEGATED_REFCOUNT_RELEASE(CLoadLocalAddrInstruction);
STDMETHOD(QueryInterface)(_In_ REFIID riid, _Out_ void **ppvObject) override
{
- return ImplQueryInterface(
+ return QueryInterfaceInternal(
+ riid,
+ ppvObject,
static_cast((COperandInstruction*)this),
static_cast((CInstruction*)this),
- static_cast(this),
- riid,
- ppvObject
- );
+ static_cast(this));
}
};
@@ -326,13 +345,12 @@ namespace MicrosoftInstrumentationEngine
DEFINE_DELEGATED_REFCOUNT_RELEASE(CStoreLocalInstruction);
STDMETHOD(QueryInterface)(_In_ REFIID riid, _Out_ void **ppvObject) override
{
- return ImplQueryInterface(
+ return QueryInterfaceInternal(
+ riid,
+ ppvObject,
static_cast((COperandInstruction*)this),
static_cast((CInstruction*)this),
- static_cast(this),
- riid,
- ppvObject
- );
+ static_cast(this));
}
};
@@ -349,13 +367,12 @@ namespace MicrosoftInstrumentationEngine
DEFINE_DELEGATED_REFCOUNT_RELEASE(CLoadArg);
STDMETHOD(QueryInterface)(_In_ REFIID riid, _Out_ void **ppvObject) override
{
- return ImplQueryInterface(
+ return QueryInterfaceInternal(
+ riid,
+ ppvObject,
static_cast((COperandInstruction*)this),
static_cast((CInstruction*)this),
- static_cast(this),
- riid,
- ppvObject
- );
+ static_cast(this));
}
};
@@ -372,13 +389,12 @@ namespace MicrosoftInstrumentationEngine
DEFINE_DELEGATED_REFCOUNT_RELEASE(CLoadArgAddrInstruction);
STDMETHOD(QueryInterface)(_In_ REFIID riid, _Out_ void **ppvObject) override
{
- return ImplQueryInterface(
+ return QueryInterfaceInternal(
+ riid,
+ ppvObject,
static_cast((COperandInstruction*)this),
static_cast((CInstruction*)this),
- static_cast(this),
- riid,
- ppvObject
- );
+ static_cast(this));
}
};
@@ -389,17 +405,17 @@ namespace MicrosoftInstrumentationEngine
// NOTE: This is the target offset for the original decoded instruction.
// It should not be used if m_pBranchTarget has been set.
DWORD m_decodedTargetOffset;
- CComPtr m_pBranchTarget;
- CComPtr m_pOrigBranchTarget;
+ CComPtr m_pBranchTarget;
+ CComPtr m_pOrigBranchTarget;
public:
CBranchInstruction(
_In_ ILOrdinalOpcode opcode,
- _In_ BOOL isNew
+ _In_ bool isNew
);
virtual HRESULT InitializeFromBytes(
- _In_ LPCBYTE pCode,
+ _In_reads_to_ptr_(pEndOfCode) LPCBYTE pCode,
_In_ LPCBYTE pEndOfCode
) override;
@@ -408,13 +424,12 @@ namespace MicrosoftInstrumentationEngine
DEFINE_DELEGATED_REFCOUNT_RELEASE(CILBranch);
STDMETHOD(QueryInterface)(_In_ REFIID riid, _Out_ void **ppvObject) override
{
- return ImplQueryInterface(
+ return QueryInterfaceInternal(
+ riid,
+ ppvObject,
static_cast(this),
static_cast((CInstruction*)this),
- static_cast(this),
- riid,
- ppvObject
- );
+ static_cast(this));
}
// IBranchInstruction methods
@@ -432,7 +447,7 @@ namespace MicrosoftInstrumentationEngine
// Internal optimized helpers.
public:
- constexpr CInstruction* GetBranchTargetInternal() { return m_pBranchTarget.p; }
+ constexpr IInstruction* GetBranchTargetInternal() { return m_pBranchTarget.p; }
protected:
virtual HRESULT Disconnect() override;
@@ -449,23 +464,23 @@ namespace MicrosoftInstrumentationEngine
// Vector of actual branch targets. Offsets etc... should be read from here
// after the initialization phase is over.
- std::vector> m_branchTargets;
+ std::vector> m_branchTargets;
public:
CSwitchInstruction(
_In_ ILOrdinalOpcode opcode,
- _In_ BOOL isNew
+ _In_ bool isNew
);
CSwitchInstruction(
_In_ ILOrdinalOpcode opcode,
- _In_ BOOL isNew,
+ _In_ bool isNew,
_In_ DWORD cBranchTargets,
_In_reads_(cBranchTargets) IInstruction** ppBranchTargets
);
virtual HRESULT InitializeFromBytes(
- _In_ LPCBYTE pCode,
+ _In_reads_to_ptr_(pEndOfCode) LPCBYTE pCode,
_In_ LPCBYTE pEndOfCode
) override;
@@ -474,13 +489,12 @@ namespace MicrosoftInstrumentationEngine
DEFINE_DELEGATED_REFCOUNT_RELEASE(CSwitchInstruction);
STDMETHOD(QueryInterface)(_In_ REFIID riid, _Out_ void **ppvObject) override
{
- return ImplQueryInterface(
+ return QueryInterfaceInternal(
+ riid,
+ ppvObject,
static_cast(this),
static_cast((CInstruction*)this),
- static_cast(this),
- riid,
- ppvObject
- );
+ static_cast(this));
}
public:
@@ -501,7 +515,7 @@ namespace MicrosoftInstrumentationEngine
// Optimized helpers
public:
- CInstruction* GetBranchTargetInternal(_In_ DWORD index);
+ IInstruction* GetBranchTargetInternal(_In_ DWORD index);
protected:
virtual HRESULT Disconnect() override;
diff --git a/src/InstrumentationEngine/InstructionFactory.cpp b/src/InstrumentationEngine/InstructionFactory.cpp
index da1539c7..dadd4156 100644
--- a/src/InstrumentationEngine/InstructionFactory.cpp
+++ b/src/InstrumentationEngine/InstructionFactory.cpp
@@ -369,7 +369,7 @@ HRESULT MicrosoftInstrumentationEngine::CInstructionFactory::CreateLoadArgAddres
return S_OK;
}
-HRESULT MicrosoftInstrumentationEngine::CInstructionFactory::DecodeInstructionByteStream(_In_ DWORD cbMethod, _In_ LPCBYTE instructionBytes, _Out_ IInstructionGraph** ppInstructionGraph)
+HRESULT MicrosoftInstrumentationEngine::CInstructionFactory::DecodeInstructionByteStream(_In_ DWORD cbMethod, _In_reads_bytes_(cbMethod) LPCBYTE instructionBytes, _Out_ IInstructionGraph** ppInstructionGraph)
{
HRESULT hr = S_OK;
CLogging::LogMessage(_T("Starting CInstructionFactory::DecodeInstructionByteStream"));
diff --git a/src/InstrumentationEngine/InstructionFactory.h b/src/InstrumentationEngine/InstructionFactory.h
index 0d910456..c6bb77c6 100644
--- a/src/InstrumentationEngine/InstructionFactory.h
+++ b/src/InstrumentationEngine/InstructionFactory.h
@@ -90,6 +90,6 @@ namespace MicrosoftInstrumentationEngine
// next and original previous fields set.
//
// 2) This graph will not have a method info set and cannot create exception sections or handlers.
- virtual HRESULT __stdcall DecodeInstructionByteStream(_In_ DWORD cbMethod, _In_ LPCBYTE instructionBytes, _Out_ IInstructionGraph** ppInstructionGraph) override;
+ virtual HRESULT __stdcall DecodeInstructionByteStream(_In_ DWORD cbMethod, _In_reads_bytes_(cbMethod) LPCBYTE instructionBytes, _Out_ IInstructionGraph** ppInstructionGraph) override;
};
}
\ No newline at end of file
diff --git a/src/InstrumentationEngine/InstructionGraph.cpp b/src/InstrumentationEngine/InstructionGraph.cpp
index fab64f7c..b588a7c8 100644
--- a/src/InstrumentationEngine/InstructionGraph.cpp
+++ b/src/InstrumentationEngine/InstructionGraph.cpp
@@ -109,9 +109,9 @@ HRESULT MicrosoftInstrumentationEngine::CInstructionGraph::CreateBaseline(
_In_ LPCBYTE pCodeBase,
_In_ LPCBYTE pEndOfCode,
_In_ DWORD originalToBaselineCorIlMapSize,
- _In_ COR_IL_MAP originalToBaselineCorIlMap[],
+ _In_reads_(originalToBaselineCorIlMapSize) COR_IL_MAP originalToBaselineCorIlMap[],
_In_ DWORD baselineSequencePointSize,
- _In_ DWORD baselineSequencePointList[]
+ _In_reads_(baselineSequencePointSize) DWORD baselineSequencePointList[]
)
{
HRESULT hr = S_OK;
@@ -227,7 +227,7 @@ HRESULT MicrosoftInstrumentationEngine::CInstructionGraph::DecodeInstructions(_I
CCriticalSectionHolder lock(&m_cs);
- const BYTE * pCode = (BYTE*)pCodeBase;
+ const BYTE * pCode = pCodeBase;
if (pEndOfCode > pCode)
@@ -403,14 +403,14 @@ HRESULT MicrosoftInstrumentationEngine::CInstructionGraph::EncodeIL(
CAutoVectorPtr pILArray;
if (cbBuffer > 0)
{
- pILArray.Attach(new BYTE[cbBuffer]);
+ pILArray.Attach(new BYTE[cbBuffer]{});
}
// Allocate the il map.
CAutoVectorPtr pCorILMap;
if(cCorILMap > 0)
{
- pCorILMap.Attach(new COR_IL_MAP[cCorILMap]);
+ pCorILMap.Attach(new COR_IL_MAP[cCorILMap]{});
}
DWORD iCorILMap = 0;
@@ -490,31 +490,7 @@ HRESULT MicrosoftInstrumentationEngine::CInstructionGraph::EncodeIL(
return S_OK;
}
-HRESULT MicrosoftInstrumentationEngine::CInstructionGraph::GetInstructionAtOffset(_In_ DWORD offset, _Out_ CInstruction** ppInstruction)
-{
- HRESULT hr = S_OK;
- CCriticalSectionHolder lock(&m_cs);
-
- CInstruction* pCurrent = m_pFirstInstruction;
- while (pCurrent != NULL)
- {
- DWORD currOffset = 0;
- IfFailRet(pCurrent->GetOffset(&currOffset));
-
- if (currOffset == offset)
- {
- *ppInstruction = pCurrent;
- pCurrent->AddRef();
- return S_OK;
- }
-
- pCurrent = pCurrent->NextInstructionInternal();
- }
-
- return E_FAIL;
-}
-
-HRESULT MicrosoftInstrumentationEngine::CInstructionGraph::GetInstructionAtEndOffset(_In_ DWORD offset, _Out_ CInstruction** ppInstruction)
+HRESULT MicrosoftInstrumentationEngine::CInstructionGraph::GetInstructionAtEndOffset(_In_ DWORD offset, _Out_ IInstruction** ppInstruction)
{
HRESULT hr = S_OK;
CCriticalSectionHolder lock(&m_cs);
@@ -578,7 +554,6 @@ HRESULT MicrosoftInstrumentationEngine::CInstructionGraph::ExpandBranches()
ULONG pos = 0;
CInstruction* pCurrent = m_pFirstInstruction;
- CInstruction* pPrev = NULL;
while (pCurrent != NULL)
{
bool bIsBranch = pCurrent->GetIsBranchInternal();
@@ -588,7 +563,6 @@ HRESULT MicrosoftInstrumentationEngine::CInstructionGraph::ExpandBranches()
((CBranchInstruction*)pCurrent)->ExpandBranch();
}
- pPrev = pCurrent;
pCurrent = pCurrent->NextInstructionInternal();
}
@@ -809,8 +783,10 @@ HRESULT MicrosoftInstrumentationEngine::CInstructionGraph::InsertBefore(_In_ IIn
IfNullRetPointer(pInstructionOrig);
IfNullRetPointer(pInstructionNew);
- CInstruction* pInstrOrig = (CInstruction*)pInstructionOrig;
- CInstruction* pInstrNew = (CInstruction*)pInstructionNew;
+ CComPtr pInstrOrig;
+ IfFailRet(pInstructionOrig->QueryInterface(&pInstrOrig));
+ CComPtr pInstrNew;
+ IfFailRet(pInstructionNew->QueryInterface(&pInstrNew));
IfFalseRet(pInstrOrig->GetGraph() == this, E_UNEXPECTED);
IfFailRet(pInstrNew->SetGraph(this));
@@ -847,7 +823,7 @@ HRESULT MicrosoftInstrumentationEngine::CInstructionGraph::InsertBefore(_In_ IIn
// Insert an instruction after another instruction. jmp offsets that point to the next instruction after
// the other instruction are not updated to reflect this change
-HRESULT MicrosoftInstrumentationEngine::CInstructionGraph::InsertAfter(_In_ IInstruction* pInstructionOrig, _In_ IInstruction* pInstructionNew)
+HRESULT MicrosoftInstrumentationEngine::CInstructionGraph::InsertAfter(_In_opt_ IInstruction* pInstructionOrig, _In_ IInstruction* pInstructionNew)
{
HRESULT hr = S_OK;
CLogging::LogMessage(_T("Starting CInstructionGraph::InsertAfter"));
@@ -855,8 +831,15 @@ HRESULT MicrosoftInstrumentationEngine::CInstructionGraph::InsertAfter(_In_ IIns
IfNullRetPointer(pInstructionNew);
- CInstruction* pInstrOrig = (CInstruction*)pInstructionOrig;
- CInstruction* pInstrNew = (CInstruction*)pInstructionNew;
+ CComPtr pInstrOrig;
+ if (pInstructionOrig != nullptr)
+ {
+ IfFailRet(pInstructionOrig->QueryInterface(&pInstrOrig));
+ }
+
+ CComPtr pInstrNew;
+ IfFailRet(pInstructionNew->QueryInterface(&pInstrNew));
+
IfFailRet(pInstrNew->SetGraph(this));
IfFailRet(pInstrNew->SetPreviousInstruction(pInstrOrig, false));
@@ -908,8 +891,10 @@ HRESULT MicrosoftInstrumentationEngine::CInstructionGraph::InsertBeforeAndRetarg
IfNullRetPointer(pInstructionOrig);
IfNullRetPointer(pInstructionNew);
- CInstruction* pInstrOrig = (CInstruction*)pInstructionOrig;
- CInstruction* pInstrNew = (CInstruction*)pInstructionNew;
+ CComPtr pInstrOrig;
+ IfFailRet(pInstructionOrig->QueryInterface(&pInstrOrig));
+ CComPtr pInstrNew;
+ IfFailRet(pInstructionNew->QueryInterface(&pInstrNew));
IfFalseRet(pInstrOrig->GetGraph() == this, E_UNEXPECTED);
IfFailRet(pInstrNew->SetGraph(this));
@@ -948,7 +933,7 @@ HRESULT MicrosoftInstrumentationEngine::CInstructionGraph::InsertBeforeAndRetarg
{
CComPtr pBranch = (CBranchInstruction*)pCurr;
- CInstruction* pBranchTarget = pBranch->GetBranchTargetInternal();
+ const IInstruction* pBranchTarget = pBranch->GetBranchTargetInternal();
// If the branch target is the original instruction AND the branch is not the new instruction,
// update it. Note the second condition is important because for things like leave instructions,
@@ -1002,8 +987,10 @@ HRESULT MicrosoftInstrumentationEngine::CInstructionGraph::Replace(_In_ IInstruc
IfNullRetPointer(pInstructionOrig);
IfNullRetPointer(pInstructionNew);
- CInstruction* pInstrOrig = (CInstruction*)pInstructionOrig;
- CInstruction* pInstrNew = (CInstruction*)pInstructionNew;
+ CComPtr pInstrOrig;
+ IfFailRet(pInstructionOrig->QueryInterface(&pInstrOrig));
+ CComPtr pInstrNew;
+ IfFailRet(pInstructionNew->QueryInterface(&pInstrNew));
IfFalseRet(pInstrOrig->GetGraph() == this, E_UNEXPECTED);
IfFailRet(pInstrNew->SetGraph(this));
@@ -1063,7 +1050,8 @@ HRESULT MicrosoftInstrumentationEngine::CInstructionGraph::Remove(_In_ IInstruct
IfNullRetPointer(pInstruction);
- CComPtr pInstr = (CInstruction*)pInstruction;
+ CComPtr pInstr;
+ IfFailRet(pInstruction->QueryInterface(&pInstr));
IfFalseRet(pInstr->GetGraph() == this, E_UNEXPECTED);
CComPtr pPreviousInstruction;
diff --git a/src/InstrumentationEngine/InstructionGraph.h b/src/InstrumentationEngine/InstructionGraph.h
index 7415b98a..cc843649 100644
--- a/src/InstrumentationEngine/InstructionGraph.h
+++ b/src/InstrumentationEngine/InstructionGraph.h
@@ -71,8 +71,7 @@ namespace MicrosoftInstrumentationEngine
HRESULT CalculateInstructionOffsets();
- HRESULT GetInstructionAtOffset(_In_ DWORD offset, _Out_ CInstruction** ppInstruction);
- HRESULT GetInstructionAtEndOffset(_In_ DWORD offset, _Out_ CInstruction** ppInstruction);
+ HRESULT GetInstructionAtEndOffset(_In_ DWORD offset, _Out_ IInstruction** ppInstruction);
HRESULT CalculateMaxStack(_Out_ DWORD* pMaxStack);
@@ -104,7 +103,7 @@ namespace MicrosoftInstrumentationEngine
// Insert an instruction after another instruction. jmp offsets that point to the next instruction after
// the other instruction are not updated to reflect this change
- virtual HRESULT __stdcall InsertAfter(_In_ IInstruction* pInstructionOrig, _In_ IInstruction* pInstructionNew) override;
+ virtual HRESULT __stdcall InsertAfter(_In_opt_ IInstruction* pInstructionOrig, _In_ IInstruction* pInstructionNew) override;
// Insert an instruction before another instruction AND update branch offsets and exception ranges that used
// to point to the old instruction to point to the new instruction.
@@ -124,9 +123,9 @@ namespace MicrosoftInstrumentationEngine
_In_ LPCBYTE pCodeBase,
_In_ LPCBYTE pEndOfCode,
_In_ DWORD originalToBaselineCorIlMapSize,
- _In_ COR_IL_MAP originalToBaselineCorIlMap[],
+ _In_reads_(originalToBaselineCorIlMapSize) COR_IL_MAP originalToBaselineCorIlMap[],
_In_ DWORD baselineSequencePointSize,
- _In_ DWORD baselineSequencePointList[]
+ _In_reads_(baselineSequencePointSize) DWORD baselineSequencePointList[]
) override;
// true if CreateBaseline has previously been called.
diff --git a/src/InstrumentationEngine/LocalVariableCollection.cpp b/src/InstrumentationEngine/LocalVariableCollection.cpp
index 15fcf662..822dcd00 100644
--- a/src/InstrumentationEngine/LocalVariableCollection.cpp
+++ b/src/InstrumentationEngine/LocalVariableCollection.cpp
@@ -35,7 +35,7 @@ HRESULT MicrosoftInstrumentationEngine::CLocalVariableCollection::Initialize()
return hr;
}
-HRESULT MicrosoftInstrumentationEngine::CLocalVariableCollection::ReplaceSignature(_In_ const BYTE* pSignature, _In_ DWORD dwSigSize)
+HRESULT MicrosoftInstrumentationEngine::CLocalVariableCollection::ReplaceSignature(_In_reads_bytes_(dwSigSize) const BYTE* pSignature, _In_ DWORD dwSigSize)
{
//TODO Should we allow complete signature removal?
diff --git a/src/InstrumentationEngine/LocalVariableCollection.h b/src/InstrumentationEngine/LocalVariableCollection.h
index 9bd5aa03..c6b0fe88 100644
--- a/src/InstrumentationEngine/LocalVariableCollection.h
+++ b/src/InstrumentationEngine/LocalVariableCollection.h
@@ -51,7 +51,7 @@ namespace MicrosoftInstrumentationEngine
virtual HRESULT __stdcall CommitSignature() override;
virtual HRESULT __stdcall GetCount(_Out_ DWORD* pdwCount) override;
virtual HRESULT __stdcall AddLocal(_In_ IType* pType, _Out_opt_ DWORD* pIndex) override;
- virtual HRESULT __stdcall ReplaceSignature(_In_ const BYTE* pSignature, _In_ DWORD dwSigSize) override;
+ virtual HRESULT __stdcall ReplaceSignature(_In_reads_bytes_(dwSigSize) const BYTE* pSignature, _In_ DWORD dwSigSize) override;
// ILocalVariableCollection2
public:
diff --git a/src/InstrumentationEngine/LoggingWrapper.h b/src/InstrumentationEngine/LoggingWrapper.h
index 799ceccd..4403d36d 100644
--- a/src/InstrumentationEngine/LoggingWrapper.h
+++ b/src/InstrumentationEngine/LoggingWrapper.h
@@ -96,7 +96,7 @@ namespace MicrosoftInstrumentationEngine
}
private:
- HRESULT InitializeCore()
+ static HRESULT InitializeCore()
{
return CLogging::Initialize();
}
diff --git a/src/InstrumentationEngine/MethodInfo.cpp b/src/InstrumentationEngine/MethodInfo.cpp
index 788c90c9..e7ed1789 100644
--- a/src/InstrumentationEngine/MethodInfo.cpp
+++ b/src/InstrumentationEngine/MethodInfo.cpp
@@ -399,7 +399,7 @@ HRESULT MicrosoftInstrumentationEngine::CMethodInfo::CreateILFunctionBody()
CAutoVectorPtr pSectEhBuffer;
DWORD cbSectEhBuffer = 0;
IfFailRet(m_pExceptionSection->CreateExceptionHeader((BYTE**)&pSectEhBuffer, &cbSectEhBuffer));
- COR_ILMETHOD_SECT_EH_FAT* pSectEh = (COR_ILMETHOD_SECT_EH_FAT*)(pSectEhBuffer.m_p);
+ const COR_ILMETHOD_SECT_EH_FAT* pSectEh = (COR_ILMETHOD_SECT_EH_FAT*)(pSectEhBuffer.m_p);
cbSehExtra = sizeof(IMAGE_COR_ILMETHOD_SECT_EH_FAT);
if(pSectEh != NULL)
{
@@ -1194,7 +1194,7 @@ HRESULT MicrosoftInstrumentationEngine::CMethodInfo::InitializeGenericParameters
IfFailRet(m_pModuleInfo->CreateTypeFactory(&typeFactory));
CComPtr parameter;
- DWORD used;
+ DWORD used = 0;
IfFailRet(typeFactory->FromSignature(cbSigBlob - currentOffset, &pSigBlob[currentOffset], ¶meter, &used));
currentOffset += used;
m_genericParameters.push_back(parameter);
@@ -1391,7 +1391,7 @@ HRESULT MicrosoftInstrumentationEngine::CMethodInfo::ApplyFinalInstrumentation()
GetRejitCount(&rejitCount);
if (rejitCount != 0)
{
- DWORD corILMapmLen = (DWORD)m_pCorILMap.Count();
+ size_t corILMapmLen = m_pCorILMap.Count();
corILMapmLen++;
CSharedArray pTempCorILMap(corILMapmLen);
size_t capacity = m_pCorILMap.Count() * sizeof(COR_IL_MAP);
@@ -1403,7 +1403,7 @@ HRESULT MicrosoftInstrumentationEngine::CMethodInfo::ApplyFinalInstrumentation()
// NOTE: CLR's earlier than 4.5.2 won't have this implemented and will return E_NOTIMPL.
// 4.5.2 is a prereq for rejit.
- m_pFunctionControl->SetILInstrumentedCodeMap(corILMapmLen, pTempCorILMap.Get());
+ m_pFunctionControl->SetILInstrumentedCodeMap((ULONG)corILMapmLen, pTempCorILMap.Get());
}
else
{
@@ -1537,7 +1537,7 @@ void MicrosoftInstrumentationEngine::CMethodInfo::LogExceptionSection(_In_ CExce
}
// static
-void MicrosoftInstrumentationEngine::CMethodInfo::LogCorIlMap(_In_ COR_IL_MAP* pCorIlMap, _In_ DWORD dwCorILMapmLen)
+void MicrosoftInstrumentationEngine::CMethodInfo::LogCorIlMap(_In_reads_(dwCorILMapmLen) const COR_IL_MAP* pCorIlMap, _In_ DWORD dwCorILMapmLen)
{
if (!CLogging::AllowLogEntry(LoggingFlags_InstrumentationResults))
{
@@ -1921,7 +1921,7 @@ HRESULT MicrosoftInstrumentationEngine::CMethodInfo::MergeILInstrumentedCodeMap(
if (iter != oldMapNewOffsetToEntryMap.end())
{
- COR_IL_MAP* pOldEntry = iter->second;
+ const COR_IL_MAP* pOldEntry = iter->second;
// Entry was found in the original map.
pCurr->oldOffset = pOldEntry->oldOffset;
@@ -2064,7 +2064,7 @@ MicrosoftInstrumentationEngine::CModuleInfo* MicrosoftInstrumentationEngine::CMe
return m_pModuleInfo;
}
-bool MicrosoftInstrumentationEngine::CMethodInfo::IsCreateBaselineEnabled()
+bool MicrosoftInstrumentationEngine::CMethodInfo::IsCreateBaselineEnabled() const
{
return m_bIsCreateBaselineEnabled;
}
diff --git a/src/InstrumentationEngine/MethodInfo.h b/src/InstrumentationEngine/MethodInfo.h
index a4acdfd7..64702abc 100644
--- a/src/InstrumentationEngine/MethodInfo.h
+++ b/src/InstrumentationEngine/MethodInfo.h
@@ -176,7 +176,7 @@ namespace MicrosoftInstrumentationEngine
_In_ ULONG cbMethodSize
);
- bool IsInstrumented()
+ bool IsInstrumented() const
{
return m_bIsInstrumented;
}
@@ -198,15 +198,15 @@ namespace MicrosoftInstrumentationEngine
void LogMethodInfo();
void LogInstructionGraph(_In_ CInstructionGraph* pInstructionGraph);
void LogExceptionSection(_In_ CExceptionSection* pExceptionSection);
- void LogCorIlMap(_In_ COR_IL_MAP* pCorIlMap, _In_ DWORD dwCorILMapmLen);
+ void LogCorIlMap(_In_reads_(dwCorILMapmLen) const COR_IL_MAP* pCorIlMap, _In_ DWORD dwCorILMapmLen);
tstring GetCorElementTypeString(_In_ IType* pType);
CModuleInfo* GetModuleInfo();
- bool IsCreateBaselineEnabled();
+ bool IsCreateBaselineEnabled() const;
void DisableCreateBaseline();
- bool IsRejit()
+ bool IsRejit() const
{
return m_bIsRejit;
}
diff --git a/src/InstrumentationEngine/ModuleInfo.cpp b/src/InstrumentationEngine/ModuleInfo.cpp
index 8ba1a52e..fe14c737 100644
--- a/src/InstrumentationEngine/ModuleInfo.cpp
+++ b/src/InstrumentationEngine/ModuleInfo.cpp
@@ -40,7 +40,7 @@ MicrosoftInstrumentationEngine::CModuleInfo::~CModuleInfo()
HRESULT MicrosoftInstrumentationEngine::CModuleInfo::Initialize(
_In_ ModuleID moduleID,
- _In_ WCHAR* wszModuleName,
+ _In_ const WCHAR* wszModuleName,
_In_ IAssemblyInfo* pAssemblyInfo,
_In_ IAppDomainInfo* pAppDomainInfo,
_In_ LPCBYTE pModuleBaseLoadAddress,
@@ -598,7 +598,7 @@ HRESULT MicrosoftInstrumentationEngine::CModuleInfo::GetModuleTypeFlags()
{
//HACK: Figure out whether this is Ngen module by looking for .ni.dll in the raw module name.
tstring moduleName = m_bstrModuleName;
- WCHAR* pExtension = PathFindExtension(moduleName.c_str());
+ const WCHAR* pExtension = PathFindExtension(moduleName.c_str());
tstring modifiedModuleName = moduleName.substr(pExtension - moduleName.c_str());
modifiedModuleName.append(L".ni.dll");
diff --git a/src/InstrumentationEngine/ModuleInfo.h b/src/InstrumentationEngine/ModuleInfo.h
index 28c8eb37..d4d73e04 100644
--- a/src/InstrumentationEngine/ModuleInfo.h
+++ b/src/InstrumentationEngine/ModuleInfo.h
@@ -119,7 +119,7 @@ namespace MicrosoftInstrumentationEngine
HRESULT Initialize(
_In_ ModuleID moduleID,
- _In_ WCHAR* wszModulePath,
+ _In_ const WCHAR* wszModulePath,
_In_ IAssemblyInfo* pAssemblyInfo,
_In_ IAppDomainInfo* pAppDomainInfo,
_In_ LPCBYTE pModuleBaseLoadAddress,
diff --git a/src/InstrumentationEngine/ProfilerManager.cpp b/src/InstrumentationEngine/ProfilerManager.cpp
index 8b70471c..c1ab9504 100644
--- a/src/InstrumentationEngine/ProfilerManager.cpp
+++ b/src/InstrumentationEngine/ProfilerManager.cpp
@@ -52,7 +52,7 @@ CProfilerManager::CProfilerManager() :
tstringstream mboxStream;
DWORD pid = GetCurrentProcessId();
mboxStream << _T("MicrosoftInstrumentationEngine ProfilerAttach. PID: ") << pid;
- MessageBox(NULL, mboxStream.str().c_str(), L"", MB_OK);
+ MessageBoxW(NULL, mboxStream.str().c_str(), L"", MB_OK);
}
if (GetEnvironmentVariable(_T("MicrosoftInstrumentationEngine_DebugWait"), wszEnvVar, MAX_PATH) > 0)
{
@@ -150,7 +150,10 @@ HRESULT CProfilerManager::InvokeThreadRoutine(_In_ LPTHREAD_START_ROUTINE thread
// The CLR doesn't initialize com before calling the profiler, and the profiler manager cannot do so itself
// as that would screw up the com state for the application thread. This thread allows the profiler manager
// to co create a free threaded version of msxml on a thread that it owns to avoid this.
- CHandle hConfigThread(CreateThread(NULL, 0, threadRoutine, this, 0, NULL));
+ HANDLE hThread = CreateThread(NULL, 0, threadRoutine, this, 0, NULL);
+ IfFalseRet(hThread != NULL, CORPROF_E_PROFILER_CANCEL_ACTIVATION);
+
+ CHandle hConfigThread(hThread);
DWORD waitTime = 60 * 1000; // Wait 1 minute for loading instrumentation methods
@@ -719,7 +722,7 @@ HRESULT CProfilerManager::RemoveInstrumentationMethod(
{
DWORD dwFlags = 0;
CCriticalSectionHolder lock(&m_cs);
- for (TInstrumentationMethodsCollection::iterator iter = m_instrumentationMethods.begin(); iter != m_instrumentationMethods.end(); iter++)
+ for (TInstrumentationMethodsCollection::iterator iter = m_instrumentationMethods.begin(); iter != m_instrumentationMethods.end(); ++iter)
{
CComPtr spInstrMethodTmp;
IfFailRet(iter->first->GetRawInstrumentationMethod(&spInstrMethodTmp));
@@ -801,7 +804,7 @@ HRESULT CProfilerManager::AddInstrumentationMethod(
bool bInserted = false;
// Number of instrumentation methods is expected to be very small.
- for (TInstrumentationMethodsCollection::iterator iter = m_instrumentationMethods.begin(); iter != m_instrumentationMethods.end(); iter++)
+ for (TInstrumentationMethodsCollection::iterator iter = m_instrumentationMethods.begin(); iter != m_instrumentationMethods.end(); ++iter)
{
shared_ptr pCurrInstrumentationMethod = iter->first;
@@ -1235,7 +1238,7 @@ HRESULT CProfilerManager::SetEventMask2(_In_ DWORD dwEventMaskLow, _In_ DWORD dw
return S_OK;
}
-ClrVersion CProfilerManager::GetAttachedClrVersion()
+ClrVersion CProfilerManager::GetAttachedClrVersion() const
{
return m_attachedClrVersion;
}
@@ -3028,14 +3031,14 @@ HRESULT CProfilerManager::InitializeForAttach(
// Copy data to new buffer to ensure that it is null terminated.
// Add one more to make room for null terminator.
- size_t bufferSize = cbClientData + 1;
+ size_t bufferSize = (size_t)cbClientData + 1;
unique_ptr pszConfigXml = make_unique(bufferSize);
IfFailRetErrno(
memcpy_s(
pszConfigXml.get(), // Destination buffer
bufferSize, // Destination buffer size in Bytes
pvClientData, // Source buffer
- cbClientData // Source buffer size in Bytes
+ (size_t)cbClientData // Source buffer size in Bytes
));
// Ensure that the data is null terminated.
pszConfigXml[bufferSize - 1] = 0;
diff --git a/src/InstrumentationEngine/ProfilerManager.h b/src/InstrumentationEngine/ProfilerManager.h
index 023d39ff..df00696b 100644
--- a/src/InstrumentationEngine/ProfilerManager.h
+++ b/src/InstrumentationEngine/ProfilerManager.h
@@ -193,7 +193,7 @@ namespace MicrosoftInstrumentationEngine
#endif
HRESULT FinalConstruct();
- void FinalRelease();
+ static void FinalRelease();
void SetIsInInitialize(_In_ bool val);
bool GetIsInInitialize() const;
@@ -208,7 +208,7 @@ namespace MicrosoftInstrumentationEngine
HRESULT GetEventMask2(_Out_ DWORD* dwEventMaskLow, _Out_ DWORD* dwEventMaskHigh);
HRESULT SetEventMask2(_In_ DWORD dwEventMaskLow, _In_ DWORD dwEventMaskHigh);
- ClrVersion GetAttachedClrVersion();
+ ClrVersion GetAttachedClrVersion() const;
// Returns the raw unwrapped profiler info instance.
HRESULT GetRealCorProfilerInfo(ICorProfilerInfo** ppRealProfilerInfo);
@@ -291,13 +291,13 @@ namespace MicrosoftInstrumentationEngine
//Template method to either QI or simple copy the InstrumentionMethod ComPtr. These methods support CopyInstrumentationMethods.
template
- HRESULT GetInterfaceType(CComPtr pRawInstrumentationMethod, TInterfaceType** pInterface)
+ HRESULT GetInterfaceType(CComPtr& pRawInstrumentationMethod, TInterfaceType** pInterface)
{
return pRawInstrumentationMethod->QueryInterface(__uuidof(TInterfaceType), (void**)pInterface);
}
template<>
- HRESULT GetInterfaceType(CComPtr pRawInstrumentationMethod, IInstrumentationMethod** pInterface)
+ HRESULT GetInterfaceType(CComPtr& pRawInstrumentationMethod, IInstrumentationMethod** pInterface)
{
return pRawInstrumentationMethod.CopyTo(pInterface);
}
diff --git a/src/InstrumentationEngine/ProfilerManagerForInstrumentationMethod.cpp b/src/InstrumentationEngine/ProfilerManagerForInstrumentationMethod.cpp
index 04c51d7f..99d58142 100644
--- a/src/InstrumentationEngine/ProfilerManagerForInstrumentationMethod.cpp
+++ b/src/InstrumentationEngine/ProfilerManagerForInstrumentationMethod.cpp
@@ -10,7 +10,7 @@
#define FORMATTABLE_PREFIX _T("[IM:%s]")
#endif
-CProfilerManagerForInstrumentationMethod::CProfilerManagerForInstrumentationMethod(GUID instrumentationMethodGuid, CProfilerManager* pProfilerManager)
+CProfilerManagerForInstrumentationMethod::CProfilerManagerForInstrumentationMethod(const GUID& instrumentationMethodGuid, CProfilerManager* pProfilerManager)
{
WCHAR wszCurrentMethodGuid[40] = { 0 };
m_flags = LoggingFlags_None;
@@ -253,9 +253,9 @@ HRESULT CProfilerManagerForInstrumentationMethod::LogMessageInternal(_In_ const
}
}
-void MicrosoftInstrumentationEngine::EscapeFormatSpecifiers(_In_ const tstring tsOriginal, _Inout_ tstring& tsEscaped)
+void MicrosoftInstrumentationEngine::EscapeFormatSpecifiers(_In_ const tstring& tsOriginal, _Inout_ tstring& tsEscaped)
{
- for (tstring::const_iterator it = tsOriginal.begin(); it < tsOriginal.end(); it++)
+ for (tstring::const_iterator it = tsOriginal.begin(); it < tsOriginal.end(); ++it)
{
// This duplicates any single '%' character (ie. "%%") in the
// format string from being treated as a format specifier.
diff --git a/src/InstrumentationEngine/ProfilerManagerForInstrumentationMethod.h b/src/InstrumentationEngine/ProfilerManagerForInstrumentationMethod.h
index 254d7c1b..7c1d50b4 100644
--- a/src/InstrumentationEngine/ProfilerManagerForInstrumentationMethod.h
+++ b/src/InstrumentationEngine/ProfilerManagerForInstrumentationMethod.h
@@ -12,7 +12,7 @@ namespace MicrosoftInstrumentationEngine
public CModuleRefCount
{
public:
- CProfilerManagerForInstrumentationMethod(GUID instrumentationMethodGuid, CProfilerManager* pProfilerManager);
+ CProfilerManagerForInstrumentationMethod(const GUID& instrumentationMethodGuid, CProfilerManager* pProfilerManager);
private:
static const int LogEntryMaxSize = 4096;
@@ -113,5 +113,5 @@ namespace MicrosoftInstrumentationEngine
STDMETHOD(LogMessageInternal)(_In_ const WCHAR* wszMessage, _In_ LoggingFlags flagToCheck);
};
- void EscapeFormatSpecifiers(_In_ const tstring tsOriginal, _Inout_ tstring& tsEscaped);
+ void EscapeFormatSpecifiers(_In_ const tstring& tsOriginal, _Inout_ tstring& tsEscaped);
}
\ No newline at end of file
diff --git a/src/InstrumentationEngine/SigParser.h b/src/InstrumentationEngine/SigParser.h
index eaf63a82..fa6e4444 100644
--- a/src/InstrumentationEngine/SigParser.h
+++ b/src/InstrumentationEngine/SigParser.h
@@ -84,7 +84,7 @@ namespace MicrosoftInstrumentationEngine
// Peek at value of one byte and return it.
//-------------------------------------------------------------------------
__checkReturn
- FORCEINLINE HRESULT PeekByte(_Out_ BYTE *data)
+ FORCEINLINE HRESULT PeekByte(_Out_ BYTE *data) const
{
if (m_dwLen > 0)
{
diff --git a/src/InstrumentationEngine/SignatureBuilder.cpp b/src/InstrumentationEngine/SignatureBuilder.cpp
index bc9906e3..70ee043a 100644
--- a/src/InstrumentationEngine/SignatureBuilder.cpp
+++ b/src/InstrumentationEngine/SignatureBuilder.cpp
@@ -97,7 +97,7 @@ namespace MicrosoftInstrumentationEngine
return S_OK;
}
- HRESULT CSignatureBuilder::GetCorSignature(_In_ DWORD cbBuffer, _Inout_opt_ BYTE* pCorSignature, _Out_opt_ DWORD* pcbSignature)
+ HRESULT CSignatureBuilder::GetCorSignature(_In_ DWORD cbBuffer, _Inout_updates_bytes_opt_(cbBuffer) BYTE* pCorSignature, _Out_opt_ DWORD* pcbSignature)
{
HRESULT hr = S_OK;
if (pCorSignature == nullptr)
diff --git a/src/InstrumentationEngine/SignatureBuilder.h b/src/InstrumentationEngine/SignatureBuilder.h
index 87f8dcc4..61e18b09 100644
--- a/src/InstrumentationEngine/SignatureBuilder.h
+++ b/src/InstrumentationEngine/SignatureBuilder.h
@@ -38,7 +38,7 @@ namespace MicrosoftInstrumentationEngine
STDMETHOD(AddData)(_In_ const BYTE* memory, _In_ DWORD cbSize) override;
STDMETHOD(AddSignature)(_In_ ISignatureBuilder* pSignature) override;
STDMETHOD(Clear)() override;
- STDMETHOD(GetCorSignature)(_In_ DWORD cbBuffer, _Inout_opt_ BYTE* pCorSignature, _Out_opt_ DWORD* pcbSignature) override;
+ STDMETHOD(GetCorSignature)(_In_ DWORD cbBuffer, _Inout_updates_bytes_opt_(cbBuffer) BYTE* pCorSignature, _Out_opt_ DWORD* pcbSignature) override;
STDMETHOD(GetCorSignaturePtr)(_Out_ const BYTE** ppCorSignature) override;
STDMETHOD(GetSize)(_Out_ DWORD* cbSize) override;
private:
diff --git a/src/InstrumentationEngine/StrongName.cpp b/src/InstrumentationEngine/StrongName.cpp
index d91931c5..11eafdd7 100644
--- a/src/InstrumentationEngine/StrongName.cpp
+++ b/src/InstrumentationEngine/StrongName.cpp
@@ -8,7 +8,10 @@
#undef USE_DEPRECATED_CLR_API_WITHOUT_WARNING
#include
+#pragma warning( push )
+#pragma warning( disable: 28740 ) // Unannotated unsigned buffer
#include
+#pragma warning( pop )
__encoded_pointer void* g_StrongNameTokenFromAssemblyPtr = EncodePointer(0);
__encoded_pointer void* g_StrongNameTokenFromPublicKeyPtr = EncodePointer(0);
diff --git a/src/InstrumentationEngine/TypeCreator.cpp b/src/InstrumentationEngine/TypeCreator.cpp
index 5643b5eb..d77185c0 100644
--- a/src/InstrumentationEngine/TypeCreator.cpp
+++ b/src/InstrumentationEngine/TypeCreator.cpp
@@ -389,7 +389,7 @@ HRESULT MicrosoftInstrumentationEngine::CTypeCreator::IsValueType(_In_ mdTypeDef
}
HRESULT MicrosoftInstrumentationEngine::CTypeCreator::ParseMethodSignature(
- _In_ const BYTE* pSignature,
+ _In_reads_bytes_(cbSignature) const BYTE* pSignature,
_In_ DWORD cbSignature,
_Out_opt_ ULONG* pCallingConvention,
_Out_opt_ IType** ppReturnType,
@@ -491,7 +491,7 @@ HRESULT MicrosoftInstrumentationEngine::CTypeCreator::ParseMethodSignature(
}
HRESULT MicrosoftInstrumentationEngine::CTypeCreator::ParseLocalVarSignature(
- _In_ const BYTE* pSignature,
+ _In_reads_bytes_(cbSignature) const BYTE* pSignature,
_In_ ULONG cbSignature,
_Out_opt_ ULONG* pCallingConvention,
_Out_opt_ IEnumTypes** ppEnumTypes,
@@ -556,7 +556,7 @@ HRESULT MicrosoftInstrumentationEngine::CTypeCreator::ParseLocalVarSignature(
}
HRESULT MicrosoftInstrumentationEngine::CTypeCreator::ParseTypeSequence(
- _In_ const BYTE* pBuffer,
+ _In_reads_bytes_(cbBuffer) const BYTE* pBuffer,
_In_ ULONG cbBuffer,
_In_ ULONG cTypes,
_Out_opt_ IEnumTypes** ppEnumTypes,
diff --git a/src/InstrumentationEngine/TypeCreator.h b/src/InstrumentationEngine/TypeCreator.h
index 7bed2291..a183a856 100644
--- a/src/InstrumentationEngine/TypeCreator.h
+++ b/src/InstrumentationEngine/TypeCreator.h
@@ -27,7 +27,7 @@ namespace MicrosoftInstrumentationEngine
// ISignatureParser
STDMETHOD(ParseMethodSignature)(
- _In_ const BYTE* pSignature,
+ _In_reads_bytes_(cbSignature) const BYTE* pSignature,
_In_ DWORD cbSignature,
_Out_opt_ ULONG* pCallingConvention,
_Out_opt_ IType** ppReturnType,
@@ -36,14 +36,14 @@ namespace MicrosoftInstrumentationEngine
_Out_opt_ ULONG* pcbRead
) override;
STDMETHOD(ParseLocalVarSignature)(
- _In_ const BYTE* pSignature,
+ _In_reads_bytes_(cbSignature) const BYTE* pSignature,
_In_ ULONG cbSignature,
_Out_opt_ ULONG* pCallingConvention,
_Out_opt_ IEnumTypes** ppEnumTypes,
_Out_opt_ ULONG* pcbRead
) override;
STDMETHOD(ParseTypeSequence)(
- _In_ const BYTE* pBuffer,
+ _In_reads_bytes_(cbBuffer) const BYTE* pBuffer,
_In_ ULONG cbBuffer,
_In_ ULONG cTypes,
_Out_opt_ IEnumTypes** ppEnumTypes,
diff --git a/src/InstrumentationEngine/dllmain.cpp b/src/InstrumentationEngine/dllmain.cpp
index 14302378..3b886f19 100644
--- a/src/InstrumentationEngine/dllmain.cpp
+++ b/src/InstrumentationEngine/dllmain.cpp
@@ -119,6 +119,9 @@ STDAPI DLLEXPORT(DllGetClassObject, 12)(_In_ REFCLSID rclsid, _In_ REFIID riid,
}
#ifndef PLATFORM_UNIX
+#pragma warning( push )
+#pragma warning( disable: 28301 ) // No annotations for first declaration of 'DllRegisterServer'.
+
__control_entrypoint(DllExport)
STDAPI DLLEXPORT(DllRegisterServer, 0)(void)
{
@@ -130,6 +133,8 @@ STDAPI DLLEXPORT(DllUnregisterServer, 0)(void)
{
return _AtlModule.DllRegisterServer(false);
}
+
+#pragma warning ( pop )
#endif
STDAPI DLLEXPORT(GetInstrumentationEngineLogger, 4)(_Outptr_ IProfilerManagerLogging** ppLogging)
diff --git a/src/InstrumentationEngine/stdafx.h b/src/InstrumentationEngine/stdafx.h
index 0f06ec0a..41fb4871 100644
--- a/src/InstrumentationEngine/stdafx.h
+++ b/src/InstrumentationEngine/stdafx.h
@@ -39,7 +39,7 @@ using namespace ATL;
#include
#include
-#include
+#include
#include "CorHeaders.h"
#include
diff --git a/src/TestHostExtension/InteropInstrumentationHandlerTests.cpp b/src/TestHostExtension/InteropInstrumentationHandlerTests.cpp
index 269213af..5ec27371 100644
--- a/src/TestHostExtension/InteropInstrumentationHandlerTests.cpp
+++ b/src/TestHostExtension/InteropInstrumentationHandlerTests.cpp
@@ -11,6 +11,10 @@ using namespace Microsoft::VisualStudio::CppUnitTestFramework;
#include "ExtensionsCommon\NativeInstanceMethodInstrumentationInfo.h"
#include "MethodInfoMock.h"
+#pragma warning( push )
+#pragma warning( disable: 25143 ) // Writable function pointer 'pVoidStaticMethod' with fixed global memory address.
+#pragma warning( disable: 25007 ) // member function '' can be static
+
namespace TestsHostExtension
{
TEST_CLASS(InteropInstrumentationHandlerTests)
@@ -49,4 +53,5 @@ namespace TestsHostExtension
//Assert::IsTrue(handler.ShouldInstrument(spMethodInfo) == S_OK);
}
};
-}
\ No newline at end of file
+}
+#pragma warning ( pop )
\ No newline at end of file
diff --git a/src/TestHostExtension/MethodInfoMock.cpp b/src/TestHostExtension/MethodInfoMock.cpp
index 1f383bac..098c768c 100644
--- a/src/TestHostExtension/MethodInfoMock.cpp
+++ b/src/TestHostExtension/MethodInfoMock.cpp
@@ -149,7 +149,7 @@ namespace TestsHostExtension
return E_NOTIMPL;
}
- HRESULT STDMETHODCALLTYPE CMethodInfoMock::GetCorSignature(DWORD cbBuffer, BYTE * pCorSignature, DWORD * pcbSignature)
+ HRESULT STDMETHODCALLTYPE CMethodInfoMock::GetCorSignature(_In_ DWORD cbBuffer, _Out_opt_ BYTE * pCorSignature, _Out_opt_ DWORD * pcbSignature)
{
return E_NOTIMPL;
}
diff --git a/src/TestHostExtension/MethodInfoMock.h b/src/TestHostExtension/MethodInfoMock.h
index 7dc224dc..d843e1c6 100644
--- a/src/TestHostExtension/MethodInfoMock.h
+++ b/src/TestHostExtension/MethodInfoMock.h
@@ -45,7 +45,7 @@ namespace TestsHostExtension
virtual HRESULT STDMETHODCALLTYPE GetParameters(IEnumMethodParameters ** pMethodArgs) override;
virtual HRESULT STDMETHODCALLTYPE GetDeclaringType(IType ** ppType) override;
virtual HRESULT STDMETHODCALLTYPE GetReturnType(IType ** ppType) override;
- virtual HRESULT STDMETHODCALLTYPE GetCorSignature(DWORD cbBuffer, BYTE * pCorSignature, DWORD * pcbSignature) override;
+ virtual HRESULT STDMETHODCALLTYPE GetCorSignature(_In_ DWORD cbBuffer, _Out_opt_ BYTE * pCorSignature, _Out_opt_ DWORD * pcbSignature) override;
virtual HRESULT STDMETHODCALLTYPE GetLocalVarSigToken(mdToken * pToken) override;
virtual HRESULT STDMETHODCALLTYPE SetLocalVarSigToken(mdToken token) override;
virtual HRESULT STDMETHODCALLTYPE GetAttributes(DWORD * pCorMethodAttr) override;
diff --git a/src/TestHostExtension/ModuleMetaDataLoaderTests.cpp b/src/TestHostExtension/ModuleMetaDataLoaderTests.cpp
index f15c8e79..20c6d4e5 100644
--- a/src/TestHostExtension/ModuleMetaDataLoaderTests.cpp
+++ b/src/TestHostExtension/ModuleMetaDataLoaderTests.cpp
@@ -8,6 +8,10 @@ using namespace Microsoft::VisualStudio::CppUnitTestFramework;
#include "Extensions.BaseLib\ModuleMetaDataLoader.h"
+#pragma warning( push )
+#pragma warning( disable: 25143 ) // Writable function pointer 'pVoidStaticMethod' with fixed global memory address.
+#pragma warning( disable: 25007 ) // member function '' can be static
+
namespace TestsHostExtension
{
TEST_CLASS(ModuleMetaDataLoaderTests)
@@ -46,4 +50,5 @@ namespace TestsHostExtension
Assert::IsTrue(nullptr == loader.GetMetaDataImport());
}
};
-}
\ No newline at end of file
+}
+#pragma warning ( pop )
\ No newline at end of file
diff --git a/tests/ApplicationInsightsCompatibility/Intercept.2.0.1.Tests/Constants.cs b/tests/ApplicationInsightsCompatibility/Intercept.2.0.1.Tests/Constants.cs
index bf40ff60..413f293c 100644
--- a/tests/ApplicationInsightsCompatibility/Intercept.2.0.1.Tests/Constants.cs
+++ b/tests/ApplicationInsightsCompatibility/Intercept.2.0.1.Tests/Constants.cs
@@ -9,7 +9,7 @@
namespace Intercept.Tests
{
- public class Constants
+ public static class Constants
{
public const string InterceptVersion = "2.0.1.0";
}
diff --git a/tests/ApplicationInsightsCompatibility/Intercept.2.0.1.Tests/Intercept.2.0.1.Tests.csproj b/tests/ApplicationInsightsCompatibility/Intercept.2.0.1.Tests/Intercept.2.0.1.Tests.csproj
index 7c85572f..2682b671 100644
--- a/tests/ApplicationInsightsCompatibility/Intercept.2.0.1.Tests/Intercept.2.0.1.Tests.csproj
+++ b/tests/ApplicationInsightsCompatibility/Intercept.2.0.1.Tests/Intercept.2.0.1.Tests.csproj
@@ -24,6 +24,7 @@
Intercept_2_0_1.Tests
Intercept.2.0.1.Tests_$(Platform)
v4.5
+ false
512
{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
10.0
diff --git a/tests/ApplicationInsightsCompatibility/Intercept.Latest.Tests/Constants.cs b/tests/ApplicationInsightsCompatibility/Intercept.Latest.Tests/Constants.cs
index e9c2bebb..34aa1792 100644
--- a/tests/ApplicationInsightsCompatibility/Intercept.Latest.Tests/Constants.cs
+++ b/tests/ApplicationInsightsCompatibility/Intercept.Latest.Tests/Constants.cs
@@ -9,7 +9,7 @@
namespace Intercept.Tests
{
- public class Constants
+ public static class Constants
{
public const string InterceptVersion = "2.4.0.0";
}
diff --git a/tests/ApplicationInsightsCompatibility/Intercept.Latest.Tests/Intercept.Latest.Tests.csproj b/tests/ApplicationInsightsCompatibility/Intercept.Latest.Tests/Intercept.Latest.Tests.csproj
index b325f507..391c0579 100644
--- a/tests/ApplicationInsightsCompatibility/Intercept.Latest.Tests/Intercept.Latest.Tests.csproj
+++ b/tests/ApplicationInsightsCompatibility/Intercept.Latest.Tests/Intercept.Latest.Tests.csproj
@@ -26,6 +26,7 @@
Intercept.Latest.Tests
Intercept.Latest.Tests_$(Platform)
v4.5
+ false
512
{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
10.0
diff --git a/tests/ApplicationInsightsCompatibility/Intercept.Latest.Tests/InterceptDecorateTests.cs b/tests/ApplicationInsightsCompatibility/Intercept.Latest.Tests/InterceptDecorateTests.cs
index 8c525902..8e7741ca 100644
--- a/tests/ApplicationInsightsCompatibility/Intercept.Latest.Tests/InterceptDecorateTests.cs
+++ b/tests/ApplicationInsightsCompatibility/Intercept.Latest.Tests/InterceptDecorateTests.cs
@@ -4,6 +4,7 @@
namespace InstrEngineTests
{
using System.Collections.Generic;
+ using System.Globalization;
using System.Linq;
using System.Reflection;
using ApplicationInsightsCompatibility;
@@ -14,13 +15,13 @@ namespace InstrEngineTests
[TestClass]
public class CustomAttributesTest
{
- public class CustomAttributesTestBase : TestBase
+ private class CustomAttributesTestBase : TestBase
{
public override void Execute()
{
var declaredMscorlib = Assembly.ReflectionOnlyLoadFrom((typeof(object)).Assembly.Location);
- var declaredAttributes = CustomAttributeData.GetCustomAttributes(declaredMscorlib).Select(attr => attr.AttributeType.FullName.ToString()).ToArray();
- var runtimeAttributes = CustomAttributeData.GetCustomAttributes((typeof(object)).Assembly).Select(attr => attr.AttributeType.FullName.ToString()).ToArray();
+ var declaredAttributes = CustomAttributeData.GetCustomAttributes(declaredMscorlib).Select(attr => attr.AttributeType.FullName.ToString(CultureInfo.InvariantCulture)).ToArray();
+ var runtimeAttributes = CustomAttributeData.GetCustomAttributes((typeof(object)).Assembly).Select(attr => attr.AttributeType.FullName.ToString(CultureInfo.InvariantCulture)).ToArray();
Assert.AreEqual(declaredAttributes.Length, runtimeAttributes.Length);
diff --git a/tests/ApplicationInsightsCompatibility/Intercept.Shared.Tests/InterceptDecorateTests.cs b/tests/ApplicationInsightsCompatibility/Intercept.Shared.Tests/InterceptDecorateTests.cs
index 75191a0a..ab61ed8c 100644
--- a/tests/ApplicationInsightsCompatibility/Intercept.Shared.Tests/InterceptDecorateTests.cs
+++ b/tests/ApplicationInsightsCompatibility/Intercept.Shared.Tests/InterceptDecorateTests.cs
@@ -16,7 +16,7 @@ namespace InstrEngineTests
[TestClass]
public class InterceptDecorateTests
{
- public class SimpleDecorate : TestBase
+ private class SimpleDecorate : TestBase
{
public override void TestPreInitialize()
{
@@ -27,6 +27,7 @@ public override void TestPreInitialize()
public override void TestInitialize()
{
Decorator.InitializeExtension(Environment.CurrentDirectory);
+#pragma warning disable CS0612 // Type or member is obsolete
Decorator.Decorate(
"System",
"System.dll",
@@ -35,12 +36,13 @@ public override void TestInitialize()
this.OnBegin,
this.OnEnd,
this.OnException);
+#pragma warning restore CS0612
}
public override void Execute()
{
// Calls the method WebRequest.GetResponse which was decorated
- WebRequest.Create("http://bing.com").GetResponse();
+ WebRequest.Create(new Uri("http://bing.com")).GetResponse();
// Make sure begin and end methods are invoked
AssertExtensions.InvokedMethodsAreEqual(this.TestResult.InvokedMethods, new[] { "OnBegin", "OnEnd" });
@@ -50,7 +52,7 @@ public override void Execute()
try
{
// Calling method to fail
- WebRequest.Create("http://SomeRandomBadUri.com").GetResponse();
+ WebRequest.Create(new Uri("http://SomeRandomBadUri.com")).GetResponse();
}
catch
{
diff --git a/tests/ApplicationInsightsCompatibility/Intercept.Shared.Tests/TestEngine.cs b/tests/ApplicationInsightsCompatibility/Intercept.Shared.Tests/TestEngine.cs
index bce6a3e8..eaaf714d 100644
--- a/tests/ApplicationInsightsCompatibility/Intercept.Shared.Tests/TestEngine.cs
+++ b/tests/ApplicationInsightsCompatibility/Intercept.Shared.Tests/TestEngine.cs
@@ -23,15 +23,12 @@ class TestEngine : TestEngineBase
public const string MscorlibExtensionMethodsBaseModuleName = "Microsoft.Diagnostics.Instrumentation.Extensions.Base.dll";
public const string InstrumentationEngineHostConfigName = "Microsoft.InstrumentationEngine.Extensions.config";
- private const string InstrumentationEngineProfilerId = "{324F817A-7420-4E6D-B3C1-143FBED6D855}";
- private const string InstrumentationEngineApmcExtensionApmcId = "{CA487940-57D2-10BF-11B2-A3AD5A13CBC0}";
- private const string RawProfilerHookComponentId = "{4BCBE156-37EC-4179-B051-0183C57BACF9}";
private TestEngine()
{
}
- public static ITestResult ExecuteTest()
+ public static ITestResult ExecuteTest() where T : new()
{
var executor = new TestEngine();
diff --git a/tests/InstrEngineTests/InstrEngineTests/InstrEngineTests.csproj b/tests/InstrEngineTests/InstrEngineTests/InstrEngineTests.csproj
index ddb48748..789c858f 100644
--- a/tests/InstrEngineTests/InstrEngineTests/InstrEngineTests.csproj
+++ b/tests/InstrEngineTests/InstrEngineTests/InstrEngineTests.csproj
@@ -12,6 +12,7 @@
InstrEngineTests
InstrEngineTests_$(Platform)
v4.5
+ false
512
{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
10.0
diff --git a/tests/InstrEngineTests/InstrEngineTests/NativeMethods.cs b/tests/InstrEngineTests/InstrEngineTests/NativeMethods.cs
index d1555eb7..b5f592e3 100644
--- a/tests/InstrEngineTests/InstrEngineTests/NativeMethods.cs
+++ b/tests/InstrEngineTests/InstrEngineTests/NativeMethods.cs
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
+using System;
+using System.Globalization;
using System.Runtime.InteropServices;
namespace InstrEngineTests
@@ -11,6 +13,6 @@ internal class NativeMethods
public static extern int GetComPlusPackageInstallStatus();
[DllImport("kernel32.dll")]
- public static extern int SetComPlusPackageInstallStatus(int flag);
+ public static extern bool SetComPlusPackageInstallStatus(int flag);
}
}
diff --git a/tests/InstrEngineTests/InstrEngineTests/PathUtils.cs b/tests/InstrEngineTests/InstrEngineTests/PathUtils.cs
index 67a7d424..4eaa1031 100644
--- a/tests/InstrEngineTests/InstrEngineTests/PathUtils.cs
+++ b/tests/InstrEngineTests/InstrEngineTests/PathUtils.cs
@@ -11,7 +11,7 @@
namespace InstrEngineTests
{
- public class PathUtils
+ public static class PathUtils
{
private const string BaselinesFolder = "Baselines";
private const string TestResultsFolder = "TestResults";
diff --git a/tests/InstrEngineTests/InstrEngineTests/ProfilerHelpers.cs b/tests/InstrEngineTests/InstrEngineTests/ProfilerHelpers.cs
index b0e5b47a..b58dea61 100644
--- a/tests/InstrEngineTests/InstrEngineTests/ProfilerHelpers.cs
+++ b/tests/InstrEngineTests/InstrEngineTests/ProfilerHelpers.cs
@@ -82,7 +82,7 @@ public static void LaunchAppUnderProfiler(string testApp, string testScript, str
psi.UseShellExecute = false;
psi.EnvironmentVariables.Add("COR_ENABLE_PROFILING", "1");
psi.EnvironmentVariables.Add("COR_PROFILER", ProfilerGuid.ToString("B", CultureInfo.InvariantCulture));
- psi.EnvironmentVariables.Add("COR_PROFILER_PATH", Path.Combine(PathUtils.GetAssetsPath(), string.Format("MicrosoftInstrumentationEngine_{0}.dll", bitnessSuffix)));
+ psi.EnvironmentVariables.Add("COR_PROFILER_PATH", Path.Combine(PathUtils.GetAssetsPath(), string.Format(CultureInfo.InvariantCulture, "MicrosoftInstrumentationEngine_{0}.dll", bitnessSuffix)));
if (EnableRefRecording)
{
@@ -155,7 +155,7 @@ public static void LaunchAppUnderProfiler(string testApp, string testScript, str
psi.EnvironmentVariables.Add(TestOutputEnvName, PathUtils.GetAssetsPath());
psi.EnvironmentVariables.Add(
is32bitTest ? HostConfig32PathEnvName : HostConfig64PathEnvName,
- Path.Combine(PathUtils.GetAssetsPath(), string.Format("NaglerInstrumentationMethod_{0}.xml", bitnessSuffix)));
+ Path.Combine(PathUtils.GetAssetsPath(), string.Format(CultureInfo.InvariantCulture, "NaglerInstrumentationMethod_{0}.xml", bitnessSuffix)));
string scriptPath = Path.Combine(PathUtils.GetTestScriptsPath(), testScript);
@@ -242,7 +242,7 @@ public static void DiffResultToBaseline(string output, string baseline, bool reg
while ((tmpStr = outputStream.ReadLine()) != null)
{
if (!string.IsNullOrEmpty(tmpStr) &&
- !tmpStr.StartsWith("[TestIgnore]"))
+ !tmpStr.StartsWith("[TestIgnore]", StringComparison.Ordinal))
{
strBuilder.Append(tmpStr);
outputStrList.Add(tmpStr);
@@ -273,15 +273,8 @@ public static void DiffResultToBaseline(string output, string baseline, bool reg
Assert.AreEqual(baselineDocs.Length, outputDocs.Length);
for (int docIdx = 0; docIdx < baselineDocs.Length; docIdx++)
{
-
- string baselineXmlDocStr = baselineDocs[docIdx];
- string outputXmlDocStr = outputDocs[docIdx];
-
- XmlDocument baselineDocument = new XmlDocument();
- baselineDocument.LoadXml(baselineXmlDocStr);
-
- XmlDocument outputDocument = new XmlDocument();
- outputDocument.LoadXml(outputXmlDocStr);
+ var baselineDocument = LoadXmlFromString(baselineDocs[docIdx]);
+ var outputDocument = LoadXmlFromString(outputDocs[docIdx]);
Assert.AreEqual(baselineDocument.ChildNodes.Count, outputDocument.ChildNodes.Count);
@@ -304,6 +297,20 @@ public static void DiffResultToBaseline(string output, string baseline, bool reg
}
}
+ private static XmlDocument LoadXmlFromString(string inputXml)
+ {
+ // https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca3075#solution-3
+ XmlDocument xmlDoc = new XmlDocument() { XmlResolver = null };
+ using (var baselineStringReader = new StringReader(inputXml))
+ {
+ using (var xmlReader = XmlReader.Create(baselineStringReader, new XmlReaderSettings() { XmlResolver = null }))
+ {
+ xmlDoc.Load(xmlReader);
+ }
+ }
+ return xmlDoc;
+ }
+
private static void DiffResultToBaselineNode(XmlNode baselineNode, XmlNode outputNode)
{
const string VolatileAttribute = "Volatile";
@@ -351,10 +358,12 @@ private static XmlDocument LoadTestScript(string testScript)
{
string scriptPath = Path.Combine(PathUtils.GetTestScriptsPath(), testScript);
- XmlDocument scriptDocument = new XmlDocument();
- scriptDocument.Load(scriptPath);
-
- return scriptDocument;
+ using (var xmlReader = XmlReader.Create(scriptPath, new XmlReaderSettings() { XmlResolver = null }))
+ {
+ XmlDocument scriptDocument = new XmlDocument() { XmlResolver = null };
+ scriptDocument.Load(xmlReader);
+ return scriptDocument;
+ }
}
private static bool Is32bitTest(string testScript)
@@ -408,7 +417,10 @@ private static void SetBitness(bool isWow64)
flag |= COMPLUS_ENABLE_64BIT;
}
- NativeMethods.SetComPlusPackageInstallStatus(flag);
+ if(!NativeMethods.SetComPlusPackageInstallStatus(flag))
+ {
+ throw new InvalidOperationException();
+ }
}
}
}
diff --git a/tests/InstrEngineTests/InstrEngineTests/TargetAppCompiler.cs b/tests/InstrEngineTests/InstrEngineTests/TargetAppCompiler.cs
index f1ea33e6..f063c37d 100644
--- a/tests/InstrEngineTests/InstrEngineTests/TargetAppCompiler.cs
+++ b/tests/InstrEngineTests/InstrEngineTests/TargetAppCompiler.cs
@@ -40,25 +40,27 @@ internal static void ComplileCSharpTestCode(string path)
{
foreach (string prefix in TestAppFilePrefixes)
{
- CodeDomProvider codeProvider = CodeDomProvider.CreateProvider("CSharp");
+ using (CodeDomProvider codeProvider = CodeDomProvider.CreateProvider("CSharp"))
+ {
- string sourceCode = GetEmbeddedSourceFile(Assembly.GetExecutingAssembly(), "InstrEngineTests.EmbeddedResources", prefix + ".cs");
+ string sourceCode = GetEmbeddedSourceFile(Assembly.GetExecutingAssembly(), "InstrEngineTests.EmbeddedResources", prefix + ".cs");
- CompilerParameters debugX86Parameters = CreateCompilerParameters(path, prefix, isDebug: true, is64bit: false);
- CompilerResults results = codeProvider.CompileAssemblyFromSource(debugX86Parameters, sourceCode);
- Assert.IsFalse(results.Errors.HasErrors, results.Errors.Count > 0 ? "Compile error:" + results.Errors[0].ErrorText : null);
+ CompilerParameters debugX86Parameters = CreateCompilerParameters(path, prefix, isDebug: true, is64bit: false);
+ CompilerResults results = codeProvider.CompileAssemblyFromSource(debugX86Parameters, sourceCode);
+ Assert.IsFalse(results.Errors.HasErrors, results.Errors.Count > 0 ? "Compile error:" + results.Errors[0].ErrorText : null);
- CompilerParameters debugX64Parameters = CreateCompilerParameters(path, prefix, isDebug: true, is64bit: true);
- results = codeProvider.CompileAssemblyFromSource(debugX64Parameters, sourceCode);
- Assert.IsFalse(results.Errors.HasErrors, results.Errors.Count > 0 ? "Compile error:" + results.Errors[0].ErrorText : null);
+ CompilerParameters debugX64Parameters = CreateCompilerParameters(path, prefix, isDebug: true, is64bit: true);
+ results = codeProvider.CompileAssemblyFromSource(debugX64Parameters, sourceCode);
+ Assert.IsFalse(results.Errors.HasErrors, results.Errors.Count > 0 ? "Compile error:" + results.Errors[0].ErrorText : null);
- CompilerParameters releaseX86Parameters = CreateCompilerParameters(path, prefix, isDebug: false, is64bit: false);
- results = codeProvider.CompileAssemblyFromSource(releaseX86Parameters, sourceCode);
- Assert.IsFalse(results.Errors.HasErrors, results.Errors.Count > 0 ? "Compile error:" + results.Errors[0].ErrorText : null);
+ CompilerParameters releaseX86Parameters = CreateCompilerParameters(path, prefix, isDebug: false, is64bit: false);
+ results = codeProvider.CompileAssemblyFromSource(releaseX86Parameters, sourceCode);
+ Assert.IsFalse(results.Errors.HasErrors, results.Errors.Count > 0 ? "Compile error:" + results.Errors[0].ErrorText : null);
- CompilerParameters releaseX64Parameters = CreateCompilerParameters(path, prefix, isDebug: false, is64bit: true);
- results = codeProvider.CompileAssemblyFromSource(releaseX64Parameters, sourceCode);
- Assert.IsFalse(results.Errors.HasErrors, results.Errors.Count > 0 ? "Compile error:" + results.Errors[0].ErrorText : null);
+ CompilerParameters releaseX64Parameters = CreateCompilerParameters(path, prefix, isDebug: false, is64bit: true);
+ results = codeProvider.CompileAssemblyFromSource(releaseX64Parameters, sourceCode);
+ Assert.IsFalse(results.Errors.HasErrors, results.Errors.Count > 0 ? "Compile error:" + results.Errors[0].ErrorText : null);
+ }
}
}
@@ -108,7 +110,7 @@ internal static string GetBinaryFullPath(string path, string prefix, bool isDebu
{
Assert.IsFalse(string.IsNullOrEmpty(prefix));
- string fullName = string.Format("{0}_{1}_{2}.exe", prefix, isDebug ? DebugBinarySuffix : ReleaseBinarySuffic, is64bit ? X64BinarySuffix : X86BinarySuffix);
+ string fullName = string.Format(CultureInfo.InvariantCulture, "{0}_{1}_{2}.exe", prefix, isDebug ? DebugBinarySuffix : ReleaseBinarySuffic, is64bit ? X64BinarySuffix : X86BinarySuffix);
return Path.Combine(path, fullName);
}
diff --git a/tests/InstrEngineTests/InstrEngineTests/TestParameters.cs b/tests/InstrEngineTests/InstrEngineTests/TestParameters.cs
index 3333f8f0..83325a07 100644
--- a/tests/InstrEngineTests/InstrEngineTests/TestParameters.cs
+++ b/tests/InstrEngineTests/InstrEngineTests/TestParameters.cs
@@ -25,6 +25,8 @@ public static void Initialize(TestContext context)
// By default, enable LogLevel
DisableLogLevel = false;
+
+ TestContext = context;
}
#endregion
@@ -37,6 +39,8 @@ public static void Initialize(TestContext context)
public static bool DisableLogLevel { get; internal set; }
+ public static TestContext TestContext { get; internal set; }
+
internal static LogLevel MethodLogLevel { get; set; }
#endregion
diff --git a/tests/InstrEngineTests/NaglerInstrumentationMethod/stdafx.h b/tests/InstrEngineTests/NaglerInstrumentationMethod/stdafx.h
index 34df734d..494c6098 100644
--- a/tests/InstrEngineTests/NaglerInstrumentationMethod/stdafx.h
+++ b/tests/InstrEngineTests/NaglerInstrumentationMethod/stdafx.h
@@ -22,7 +22,7 @@
#include
#include
-#include
+#include
#include "InstrumentationEngine.h"
diff --git a/tests/InstrumentationEngine.Lib.Tests/ConfigurationLoaderTests.cpp b/tests/InstrumentationEngine.Lib.Tests/ConfigurationLoaderTests.cpp
index 69958709..9e5144a3 100644
--- a/tests/InstrumentationEngine.Lib.Tests/ConfigurationLoaderTests.cpp
+++ b/tests/InstrumentationEngine.Lib.Tests/ConfigurationLoaderTests.cpp
@@ -28,7 +28,8 @@ namespace InstrumentationEngineLibTests
wfstream output;
output.open(fileName, ios_base::app | ios_base::out);
- auto error = _wcserror(GetLastError());
+ wchar_t error[256] = { 0 };
+ _wcserror_s(error,GetLastError());
Assert::IsTrue(!output.fail() && !output.bad(), error);
output << L"" << std::endl;
@@ -64,7 +65,8 @@ namespace InstrumentationEngineLibTests
}
wfstream output;
output.open(fileName, ios_base::app | ios_base::out);
- auto error = _wcserror(GetLastError());
+ wchar_t error[256] = { 0 };
+ _wcserror_s(error, GetLastError());
Assert::IsTrue(!output.fail() && !output.bad(), error);
output << L"" << std::endl;
@@ -96,7 +98,8 @@ namespace InstrumentationEngineLibTests
}
wfstream output;
output.open(fileName, ios_base::app | ios_base::out);
- auto error = _wcserror(GetLastError());
+ wchar_t error[256] = { 0 };
+ _wcserror_s(error, GetLastError());
Assert::IsTrue(!output.fail() && !output.bad(), error);
output << L"" << std::endl;
diff --git a/tests/InstrumentationEngine.Lib.Tests/InstrumentationEngine.Lib.Tests.vcxproj b/tests/InstrumentationEngine.Lib.Tests/InstrumentationEngine.Lib.Tests.vcxproj
index b3dbea64..f341fda3 100644
--- a/tests/InstrumentationEngine.Lib.Tests/InstrumentationEngine.Lib.Tests.vcxproj
+++ b/tests/InstrumentationEngine.Lib.Tests/InstrumentationEngine.Lib.Tests.vcxproj
@@ -41,12 +41,13 @@
true
+
- $(OutDir);..\..\src\InstrumentationEngine.Lib;$(InstrumentationEngineApiInc);$(VCInstallDir)UnitTest\include;$(VCInstallDir)Auxiliary\VS\UnitTest\include;%(AdditionalIncludeDirectories)
+ $(OutDir);..\..\src\InstrumentationEngine.Lib;$(OutDir);..\..\inc\clr\prof;$(InstrumentationEngineApiInc);$(VCInstallDir)UnitTest\include;$(VCInstallDir)Auxiliary\VS\UnitTest\include;%(AdditionalIncludeDirectories)
Use
Level3
stdafx.h
diff --git a/tests/InstrumentationEngine.Lib.Tests/stdafx.h b/tests/InstrumentationEngine.Lib.Tests/stdafx.h
index d25bc17b..a99d30e5 100644
--- a/tests/InstrumentationEngine.Lib.Tests/stdafx.h
+++ b/tests/InstrumentationEngine.Lib.Tests/stdafx.h
@@ -34,7 +34,7 @@
#include
#include
-#include
+#include
#include
#include
diff --git a/tests/InstrumentationEngine.ProfilerProxy.Tests/InstrumentationEngine.ProfilerProxy.Tests.vcxproj b/tests/InstrumentationEngine.ProfilerProxy.Tests/InstrumentationEngine.ProfilerProxy.Tests.vcxproj
index 752a0316..d2be496b 100644
--- a/tests/InstrumentationEngine.ProfilerProxy.Tests/InstrumentationEngine.ProfilerProxy.Tests.vcxproj
+++ b/tests/InstrumentationEngine.ProfilerProxy.Tests/InstrumentationEngine.ProfilerProxy.Tests.vcxproj
@@ -41,6 +41,7 @@
true
+
diff --git a/tests/RawProfilerHook/RawProfilerHook.Tests/RawProfilerHook.Tests.csproj b/tests/RawProfilerHook/RawProfilerHook.Tests/RawProfilerHook.Tests.csproj
index 2e49b20d..3a6c07c1 100644
--- a/tests/RawProfilerHook/RawProfilerHook.Tests/RawProfilerHook.Tests.csproj
+++ b/tests/RawProfilerHook/RawProfilerHook.Tests/RawProfilerHook.Tests.csproj
@@ -26,6 +26,7 @@
RawProfilerHook.Tests
RawProfilerHook.Tests_$(Platform)
v4.5
+ false
512
{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
10.0
diff --git a/tests/RawProfilerHook/RawProfilerHook.Tests/TestEngine/TestEngine.cs b/tests/RawProfilerHook/RawProfilerHook.Tests/TestEngine/TestEngine.cs
index 978c2a3c..f3af0b48 100644
--- a/tests/RawProfilerHook/RawProfilerHook.Tests/TestEngine/TestEngine.cs
+++ b/tests/RawProfilerHook/RawProfilerHook.Tests/TestEngine/TestEngine.cs
@@ -48,7 +48,7 @@ public class TestEngine : RemoteUnitTestExecutor.TestEngineBase
private readonly string traceFilePath;
- public static ITestResult ExecuteTest()
+ public static ITestResult ExecuteTest() where T : new()
{
var executor = new TestEngine();
@@ -72,7 +72,7 @@ public ITestResult ExecuteTest(Type t, string[] expectedErrors = null)
{
if (null == t)
{
- throw new ArgumentNullException("t");
+ throw new ArgumentNullException(nameof(t));
}
return ExecuteTest(t.AssemblyQualifiedName, IsX86, expectedErrors);
@@ -80,6 +80,11 @@ public ITestResult ExecuteTest(Type t, string[] expectedErrors = null)
protected override void OnBeforeStarted(DebugeeProcess debugee)
{
+ if (debugee == null)
+ {
+ throw new ArgumentNullException(nameof(debugee));
+ }
+
string profilerDest = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(typeof(TestEngine).Assembly.Location), ProfilerSrcFolder));
Trace.TraceInformation("profilerDest: {0}", profilerDest);
@@ -157,12 +162,12 @@ protected override void OnComplete(DebugeeProcess debugee, string[] expectedErro
while (!traceFile.EndOfStream)
{
string traceLine = traceFile.ReadLine();
- if (traceLine.StartsWith("LogError"))
+ if (traceLine.StartsWith("LogError", StringComparison.Ordinal))
{
errors += traceLine + "\r\n";
}
if (traceLine.Length != 0 &&
- !traceLine.StartsWith("[TestIgnore]"))
+ !traceLine.StartsWith("[TestIgnore]", StringComparison.Ordinal))
{
Trace.WriteLine(traceLine);
}
diff --git a/tests/RawProfilerHook/RawProfilerHook.Tests/TestsRawProfilerHookAttach.cs b/tests/RawProfilerHook/RawProfilerHook.Tests/TestsRawProfilerHookAttach.cs
index 4c1a11d8..46290d04 100644
--- a/tests/RawProfilerHook/RawProfilerHook.Tests/TestsRawProfilerHookAttach.cs
+++ b/tests/RawProfilerHook/RawProfilerHook.Tests/TestsRawProfilerHookAttach.cs
@@ -13,7 +13,7 @@ namespace RawProfilerHook.Tests
[TestClass]
public class TestsRawProfilerHookAttach
{
- public class TestsRawProfilerHookIsLoadedIfEnvVariableIsSet : TestBase
+ private class TestsRawProfilerHookIsLoadedIfEnvVariableIsSet : TestBase
{
public override void Execute()
{
@@ -47,12 +47,12 @@ public void TestRawProfilerHookIsLoadedIfEnvVariableIsSet()
TestEngine.ExecuteTest();
}
- public class TestRawProfilerHookCallsGetAssemblyReferencesBase : TestBase
+ private class TestRawProfilerHookCallsGetAssemblyReferencesBase : TestBase
{
public override void Execute()
{
// load APTCA module from GAC - System.Xml
- XmlDocument doc = new XmlDocument();
+ XmlDocument doc = new XmlDocument() { XmlResolver = null };
Assert.AreEqual(
"S_OK",
@@ -74,10 +74,10 @@ public void TestRawProfilerHookCallsGetAssemblyReferences()
"Exception extensions module is loaded");
TestEngine.IgnoreBitness = true;
- TestEngine.ExecuteTest();
+ TestEngine.ExecuteTest();
TestEngine.IgnoreBitness = false;
- TestEngine.ExecuteTest();
+ TestEngine.ExecuteTest();
}
}
}
diff --git a/tests/RawProfilerHook/RawProfilerHook/CoRawProfilerHook.h b/tests/RawProfilerHook/RawProfilerHook/CoRawProfilerHook.h
index dfd53cad..8befcee2 100644
--- a/tests/RawProfilerHook/RawProfilerHook/CoRawProfilerHook.h
+++ b/tests/RawProfilerHook/RawProfilerHook/CoRawProfilerHook.h
@@ -6,7 +6,7 @@
#include "RawProfilerHook_i.h"
#include
-#include
+#include
class ATL_NO_VTABLE CCoRawProfilerHook
: public ATL::CComObjectRootEx
@@ -371,12 +371,12 @@ class ATL_NO_VTABLE CCoRawProfilerHook
- HRESULT FinalConstruct()
+ static HRESULT FinalConstruct()
{
return S_OK;
}
- void FinalRelease()
+ static void FinalRelease()
{
}
diff --git a/tests/RawProfilerHook/RawProfilerHook/RawProfilerHook.cpp b/tests/RawProfilerHook/RawProfilerHook/RawProfilerHook.cpp
index 33cd97b0..88a8a9b4 100644
--- a/tests/RawProfilerHook/RawProfilerHook/RawProfilerHook.cpp
+++ b/tests/RawProfilerHook/RawProfilerHook/RawProfilerHook.cpp
@@ -25,6 +25,9 @@ STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID
return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
}
+#pragma warning( push )
+#pragma warning( disable: 28301 ) // No annotations for first declaration of 'DllRegisterServer'.
+
// DllRegisterServer - Adds entries to the system registry.
__control_entrypoint(DllExport)
STDAPI DllRegisterServer(void)
@@ -42,11 +45,16 @@ STDAPI DllUnregisterServer(void)
return hr;
}
+#pragma warning ( pop )
+
// DllInstall - Adds/Removes entries to the system registry per user per machine.
STDAPI DllInstall(BOOL bInstall, _In_opt_ LPCWSTR pszCmdLine)
{
HRESULT hr = E_FAIL;
+#pragma warning( push )
+#pragma warning( disable: 25138 ) // static array 'const wchar_t szUserSwitch[5]' should be a local pointer.
static const wchar_t szUserSwitch[] = L"user";
+#pragma warning ( pop )
if (pszCmdLine != NULL)
{