-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable analysis for managed binary (#335)
* Enable analysis for managed binary * updating sarif expected results * updating logic to pdblocation * removing old comment * updating pdb loader for checksum and tests * updating logic to check if we can process and tests * adding more tests * addressing pr comments * Moving from NotApplicable to FailureLevel = Error
- Loading branch information
Showing
108 changed files
with
1,701 additions
and
1,399 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.CodeAnalysis.BinaryParsers | ||
{ | ||
/// <summary> | ||
/// Checksum Algorithm for managed binary. | ||
/// </summary> | ||
public enum ChecksumAlgorithmType | ||
{ | ||
/// <summary> | ||
/// Unknown format. | ||
/// </summary> | ||
Unknown, | ||
|
||
/// <summary> | ||
/// SHA1 algorithm. | ||
/// </summary> | ||
Sha1, | ||
|
||
/// <summary> | ||
/// SHA256 algorithm. | ||
/// </summary> | ||
Sha256, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
src/BinaryParsers/PEBinary/PortableExecutable/SymMetadataProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
using System.Reflection; | ||
using System.Reflection.Metadata; | ||
using System.Reflection.Metadata.Ecma335; | ||
|
||
namespace Microsoft.DiaSymReader.Tools | ||
{ | ||
internal sealed class SymMetadataProvider : ISymWriterMetadataProvider, ISymReaderMetadataProvider | ||
{ | ||
private readonly MetadataReader _reader; | ||
|
||
internal SymMetadataProvider(MetadataReader reader) | ||
{ | ||
_reader = reader; | ||
} | ||
|
||
public unsafe bool TryGetStandaloneSignature(int standaloneSignatureToken, out byte* signature, out int length) | ||
{ | ||
var sigHandle = (StandaloneSignatureHandle)MetadataTokens.Handle(standaloneSignatureToken); | ||
if (sigHandle.IsNil) | ||
{ | ||
signature = null; | ||
length = 0; | ||
return false; | ||
} | ||
|
||
StandaloneSignature sig = _reader.GetStandaloneSignature(sigHandle); | ||
BlobReader blobReader = _reader.GetBlobReader(sig.Signature); | ||
|
||
signature = blobReader.StartPointer; | ||
length = blobReader.Length; | ||
return true; | ||
} | ||
|
||
public bool TryGetTypeDefinitionInfo(int typeDefinitionToken, [NotNullWhen(true)] out string namespaceName, [NotNullWhen(true)] out string typeName, out TypeAttributes attributes) | ||
{ | ||
var handle = (TypeDefinitionHandle)MetadataTokens.Handle(typeDefinitionToken); | ||
if (handle.IsNil) | ||
{ | ||
namespaceName = null; | ||
typeName = null; | ||
attributes = 0; | ||
return false; | ||
} | ||
|
||
TypeDefinition typeDefinition = _reader.GetTypeDefinition(handle); | ||
namespaceName = _reader.GetString(typeDefinition.Namespace); | ||
typeName = _reader.GetString(typeDefinition.Name); | ||
attributes = typeDefinition.Attributes; | ||
return true; | ||
} | ||
|
||
public bool TryGetTypeReferenceInfo(int typeReferenceToken, [NotNullWhen(true)] out string namespaceName, [NotNullWhen(true)] out string typeName) | ||
{ | ||
var handle = (TypeReferenceHandle)MetadataTokens.Handle(typeReferenceToken); | ||
if (handle.IsNil) | ||
{ | ||
namespaceName = null; | ||
typeName = null; | ||
return false; | ||
} | ||
|
||
TypeReference typeReference = _reader.GetTypeReference(handle); | ||
namespaceName = _reader.GetString(typeReference.Namespace); | ||
typeName = _reader.GetString(typeReference.Name); | ||
return true; | ||
} | ||
|
||
public bool TryGetEnclosingType(int nestedTypeToken, out int enclosingTypeToken) | ||
{ | ||
TypeDefinition nestedTypeDef = _reader.GetTypeDefinition(MetadataTokens.TypeDefinitionHandle(nestedTypeToken)); | ||
TypeDefinitionHandle declaringTypeHandle = nestedTypeDef.GetDeclaringType(); | ||
|
||
if (declaringTypeHandle.IsNil) | ||
{ | ||
enclosingTypeToken = 0; | ||
return false; | ||
} | ||
else | ||
{ | ||
enclosingTypeToken = MetadataTokens.GetToken(declaringTypeHandle); | ||
return true; | ||
} | ||
} | ||
|
||
public bool TryGetMethodInfo(int methodDefinitionToken, [NotNullWhen(true)] out string methodName, out int declaringTypeToken) | ||
{ | ||
var handle = (MethodDefinitionHandle)MetadataTokens.Handle(methodDefinitionToken); | ||
if (handle.IsNil) | ||
{ | ||
methodName = null; | ||
declaringTypeToken = 0; | ||
return false; | ||
} | ||
|
||
MethodDefinition methodDefinition = _reader.GetMethodDefinition(handle); | ||
methodName = _reader.GetString(methodDefinition.Name); | ||
declaringTypeToken = MetadataTokens.GetToken(methodDefinition.GetDeclaringType()); | ||
return true; | ||
} | ||
} | ||
} |
Oops, something went wrong.