Skip to content

Instantly share code, notes, and snippets.

View vivmishra's full-sized avatar

Vivek Mishra vivmishra

View GitHub Profile
@vivmishra
vivmishra / dotnet-461-ICorProfilerInfo.cpp
Created October 23, 2015 21:04
Better support for accessing PDBs in IcorProfilerInfo
//Step 1) Set the COR_PRF_HIGH_IN_MEMORY_SYMBOLS_UPDATED flag so that your profiler will receive callbacks when symbols are loaded for modules.
// in production handle possible failing HRESULTs
ICorProfilerInfo5* pCorProfilerInfo5 = …
DWORD lowFlags = 0; // Most profilers will have other flags to set
DWORD highFlags = COR_PRF_HIGH_IN_MEMORY_SYMBOLS_UPDATED;
pCorProfilerInfo5->SetEventMask2(lowFlags, highFlags);
// Step 2) Implement ICorProfilerCallback7 so that your profiler can handle the symbol load notification
@vivmishra
vivmishra / dotnet-461-System.Transactions.cs
Created October 23, 2015 18:09
Sample for System.Transactions updates in .NET 4.6.1
using System;
using System.Transactions;
namespace YourNamespaceGoesHere
{
public class NonMSDTCPromoterEnlistment : IPromotableSinglePhaseNotification
{
Guid promoterType;
Guid distributedTxId;
Transaction enlistedTransaction;
@vivmishra
vivmishra / dotnet-461-crypto.cs
Last active October 29, 2015 23:55
X509certificates containing ECDSA Example
// Current approach
public class Net46Approach
{
public static byte[] SignECDsaSha512(byte[] data, X509Certificate2 cert)
{
// This would require using cert.Handle and a series of p/invokes to get at the
// underlying key, then passing that to a CngKey object, and passing that to
// new ECDsa(CngKey). It's a lot of work.
throw new Exception("That's a lot of work...");
}