Skip to content

Instantly share code, notes, and snippets.

int BasicConnection(DWORD pid)
{
wchar_t pszPipeName[256];
// build the pipe name as described in the protocol
int nCharactersWritten = -1;
nCharactersWritten = wsprintf(
pszPipeName,
L"\\\\.\\pipe\\dotnet-diagnostic-%d",
pid
class DisposableMe : IDisposable
{
private bool _disposed = false;
// 1. field that implements IDisposable
// 2. field that stores "native resource" (ex: IntPtr)
~DisposableMe()
{
Cleanup("called from GC" != null);
private void Cleanup(bool fromGC)
{
if (_disposed)
return;
try
{
// always clean up the NATIVE resources
if (fromGC)
return;
hr = pInfo->GetAssemblyInfo(assemblyId, 0, &nameLen, NULL, NULL, NULL);
if (SUCCEEDED(hr))
{
WCHAR* pszName = new WCHAR[nameLen]; // count the trailing \0
hr = pInfo->GetAssemblyInfo(assemblyId, nameLen, &nameLen, pszName, NULL, NULL);
oss << pszName;
delete [] pszName;
}
else
oss << L"<UNKNOWN>";
LPCBYTE loadAddress;
ULONG nameLen = 0;
AssemblyID assemblyId;
hr = pInfo->GetModuleInfo(moduleId, &loadAddress, nameLen, &nameLen, NULL, &assemblyId);
if (SUCCEEDED(hr))
{
WCHAR* pszName = new WCHAR[nameLen]; // count the trailing \0
pInfo->GetModuleInfo(moduleId, &loadAddress, nameLen, &nameLen, pszName,
&assemblyId);
ClassID classId;
ModuleID moduleId;
mdToken mdtokenFunction;
pInfo->GetFunctionInfo(functionId, &classId, &moduleId, &mdtokenFunction);
PROFILER_STUB EnterStub(FunctionIDOrClientID functionId, COR_PRF_ELT_INFO eltInfo)
{
...
}
PROFILER_STUB LeaveStub(FunctionID functionId, COR_PRF_ELT_INFO eltInfo)
{
...
}
<ImportGroup Label = "ExtensionSettings">
<Import Project = "$(VCTargetsPath)\BuildCustomizations\masm.props" / >
</ ImportGroup>
<ItemGroup>
<MASM Include = "../DotNext.Profiler.Shared/asm/windows/nakedcallbacks.asm"
Condition = "'$(Platform)' == 'x64'" / >
</ ItemGroup>
<ImportGroup Label = "ExtensionTargets">
<Import Project = "$(VCTargetsPath)\BuildCustomizations\masm.targets" / >
</ ImportGroup>
public ClassType ClassParamReturnClass(ClassType obj)
{
return new ClassType(obj.IntProperty + 1);
}
static async Task Main(string[] args)
{
Console.WriteLine($"pid = {Process.GetCurrentProcess().Id}");
Console.WriteLine("press ENTER to start...");
Console.ReadLine();
await ComputeAsync();
Console.WriteLine("press ENTER to exit...");
Console.ReadLine();
}