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
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 |
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
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); |
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
private void Cleanup(bool fromGC) | |
{ | |
if (_disposed) | |
return; | |
try | |
{ | |
// always clean up the NATIVE resources | |
if (fromGC) | |
return; |
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
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>"; |
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
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); |
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
ClassID classId; | |
ModuleID moduleId; | |
mdToken mdtokenFunction; | |
pInfo->GetFunctionInfo(functionId, &classId, &moduleId, &mdtokenFunction); |
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
PROFILER_STUB EnterStub(FunctionIDOrClientID functionId, COR_PRF_ELT_INFO eltInfo) | |
{ | |
... | |
} | |
PROFILER_STUB LeaveStub(FunctionID functionId, COR_PRF_ELT_INFO eltInfo) | |
{ | |
... | |
} |
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
<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> |
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
public ClassType ClassParamReturnClass(ClassType obj) | |
{ | |
return new ClassType(obj.IntProperty + 1); | |
} |
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
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(); | |
} |
NewerOlder