go my file uploader

This commit is contained in:
AirDog46
2025-05-13 19:45:22 +03:00
commit c5fab8aa94
708 changed files with 343216 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) .NET Foundation and Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,139 @@
/*
* Process Hacker .NET Tools -
* .NET Process IPC definitions
*
* Copyright (C) 2015-2016 dmex
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Process Hacker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the current folder for more information.
//-----------------------------------------------------------------------------
//
// dmex: This header has been highly modified.
// Original: https://github.com/dotnet/coreclr/blob/master/src/debug/inc/dbgappdomain.h
#ifndef _DBG_APPDOMAIN_H_
#define _DBG_APPDOMAIN_H_
#ifndef _WIN64
#include <pshpack4.h>
#endif
typedef struct _AppDomainInfo
{
ULONG Id; // unique identifier
INT NameLengthInBytes;
PWSTR AppDomainName;
PVOID AppDomains;
} AppDomainInfo;
#ifndef _WIN64
#include <poppack.h>
#endif
#include <pshpack4.h>
typedef struct _AppDomainInfo_Wow64
{
ULONG Id; // unique identifier
INT NameLengthInBytes;
ULONG AppDomainName;
ULONG AppDomains;
} AppDomainInfo_Wow64;
#include <poppack.h>
// AppDomain publishing server support:
// Information about all appdomains in the process will be maintained
// in the shared memory block for use by the debugger, etc.
#ifndef _WIN64
#include <pshpack4.h>
#endif
typedef struct _AppDomainEnumerationIPCBlock
{
HANDLE Mutex; // lock for serialization while manipulating AppDomain list.
INT TotalSlots; // Number of slots in AppDomainListElement array
INT NumOfUsedSlots;
INT LastFreedSlot;
INT SizeInBytes; // Size of AppDomainInfo in bytes
INT ProcessNameLengthInBytes; // We can use psapi!GetModuleFileNameEx to get the module name.
PVOID ProcessName; // This provides an alternative.
PVOID ListOfAppDomains;
BOOL LockInvalid;
} AppDomainEnumerationIPCBlock;
#ifndef _WIN64
#include <poppack.h>
#endif
#include <pshpack4.h>
typedef struct _AppDomainEnumerationIPCBlock_Wow64
{
ULONG Mutex; // lock for serialization while manipulating AppDomain list.
INT TotalSlots; // Number of slots in AppDomainListElement array
INT NumOfUsedSlots;
INT LastFreedSlot;
INT SizeInBytes; // Size of AppDomainInfo in bytes
INT ProcessNameLengthInBytes; // We can use psapi!GetModuleFileNameEx to get the module name.
ULONG ProcessName; // This provides an alternative.
ULONG ListOfAppDomains;
BOOL LockInvalid;
} AppDomainEnumerationIPCBlock_Wow64;
#include <poppack.h>
// Enforce the AppDomain IPC block binary layout.
C_ASSERT(FIELD_OFFSET(AppDomainInfo_Wow64, Id) == 0x0);
C_ASSERT(FIELD_OFFSET(AppDomainInfo_Wow64, NameLengthInBytes) == 0x4);
C_ASSERT(FIELD_OFFSET(AppDomainInfo_Wow64, AppDomainName) == 0x8);
C_ASSERT(FIELD_OFFSET(AppDomainInfo_Wow64, AppDomains) == 0xC);
#if defined(_WIN64)
C_ASSERT(FIELD_OFFSET(AppDomainInfo, Id) == 0x0);
C_ASSERT(FIELD_OFFSET(AppDomainInfo, NameLengthInBytes) == 0x4);
C_ASSERT(FIELD_OFFSET(AppDomainInfo, AppDomainName) == 0x8);
C_ASSERT(FIELD_OFFSET(AppDomainInfo, AppDomains) == 0x10);
#endif
// Enforce the AppDomain IPC block binary layout.
C_ASSERT(FIELD_OFFSET(AppDomainEnumerationIPCBlock_Wow64, Mutex) == 0x0);
C_ASSERT(FIELD_OFFSET(AppDomainEnumerationIPCBlock_Wow64, TotalSlots) == 0x4);
C_ASSERT(FIELD_OFFSET(AppDomainEnumerationIPCBlock_Wow64, NumOfUsedSlots) == 0x8);
C_ASSERT(FIELD_OFFSET(AppDomainEnumerationIPCBlock_Wow64, LastFreedSlot) == 0xC);
C_ASSERT(FIELD_OFFSET(AppDomainEnumerationIPCBlock_Wow64, SizeInBytes) == 0x10);
C_ASSERT(FIELD_OFFSET(AppDomainEnumerationIPCBlock_Wow64, ProcessNameLengthInBytes) == 0x14);
C_ASSERT(FIELD_OFFSET(AppDomainEnumerationIPCBlock_Wow64, ProcessName) == 0x18);
C_ASSERT(FIELD_OFFSET(AppDomainEnumerationIPCBlock_Wow64, ListOfAppDomains) == 0x1C);
C_ASSERT(FIELD_OFFSET(AppDomainEnumerationIPCBlock_Wow64, LockInvalid) == 0x20);
#if defined(_WIN64)
C_ASSERT(FIELD_OFFSET(AppDomainEnumerationIPCBlock, Mutex) == 0x0);
C_ASSERT(FIELD_OFFSET(AppDomainEnumerationIPCBlock, TotalSlots) == 0x8);
C_ASSERT(FIELD_OFFSET(AppDomainEnumerationIPCBlock, NumOfUsedSlots) == 0xC);
C_ASSERT(FIELD_OFFSET(AppDomainEnumerationIPCBlock, LastFreedSlot) == 0x10);
C_ASSERT(FIELD_OFFSET(AppDomainEnumerationIPCBlock, SizeInBytes) == 0x14);
C_ASSERT(FIELD_OFFSET(AppDomainEnumerationIPCBlock, ProcessNameLengthInBytes) == 0x18);
// TODO: Why does Visual Studio have issues with these entries...
//C_ASSERT(FIELD_OFFSET(AppDomainEnumerationIPCBlock, ProcessName) == 0x20);
//C_ASSERT(FIELD_OFFSET(AppDomainEnumerationIPCBlock, ListOfAppDomains) == 0x28);
//C_ASSERT(FIELD_OFFSET(AppDomainEnumerationIPCBlock, LockInvalid) == 0x30);
#endif
#endif _DBG_APPDOMAIN_H_

View File

@@ -0,0 +1,77 @@
/*
* Process Hacker .NET Tools -
* .NET Process IPC definitions
*
* Copyright (C) 2015-2016 dmex
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Process Hacker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the current folder for more information.
//-----------------------------------------------------------------------------
// IPCEnums.h
//
// Define various enums used by IPCMan.
//-----------------------------------------------------------------------------
//
// dmex: This header has been highly modified.
// Original: https://github.com/dotnet/coreclr/blob/master/src/ipcman/ipcenums.h
#ifndef _IPC_ENUMS_H_
#define _IPC_ENUMS_H_
//-----------------------------------------------------------------------------
// Each IPC client for an IPC block has one entry.
//-----------------------------------------------------------------------------
typedef enum _EIPCClient
{
eIPC_PerfCounters = 0,
// MAX used for arrays, insert above this.
eIPC_MAX
} EIPCClient;
//-----------------------------------------------------------------------------
// Each IPC client for a LegacyPrivate block (debugging, perf counters, etc) has one entry.
//-----------------------------------------------------------------------------
typedef enum _ELegacyPrivateIPCClient
{
eLegacyPrivateIPC_PerfCounters = 0,
eLegacyPrivateIPC_Obsolete_Debugger = 1,
eLegacyPrivateIPC_AppDomain = 2,
eLegacyPrivateIPC_Obsolete_Service = 3,
eLegacyPrivateIPC_Obsolete_ClassDump = 4,
eLegacyPrivateIPC_Obsolete_MiniDump = 5,
eLegacyPrivateIPC_InstancePath = 6,
// MAX used for arrays, insert above this.
eLegacyPrivateIPC_MAX
} ELegacyPrivateIPCClient;
//-----------------------------------------------------------------------------
// Each IPC client for a LegacyPublic block has one entry.
//-----------------------------------------------------------------------------
typedef enum _ELegacyPublicIPCClient
{
eLegacyPublicIPC_PerfCounters = 0,
// MAX used for arrays, insert above this.
eLegacyPublicIPC_MAX
} ELegacyPublicIPCClient;
#endif _IPC_ENUMS_H_

View File

@@ -0,0 +1,545 @@
/*
* Process Hacker .NET Tools -
* .NET Process IPC definitions
*
* Copyright (C) 2015-2016 dmex
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Process Hacker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the current folder for more information.
//-----------------------------------------------------------------------------
// IPCHeader.h
//
// Define the LegacyPrivate header format for IPC memory mapped files.
//-----------------------------------------------------------------------------
//
// dmex: This header has been highly modified.
// Original: https://github.com/dotnet/coreclr/blob/master/src/ipcman/ipcheader.h
#ifndef _IPC_HEADER_H_
#define _IPC_HEADER_H_
#include "perfcounterdefs.h"
#include "ipcenums.h"
// Current version of the IPC Block
const USHORT VER_IPC_BLOCK = 4;
// Legacy version of the IPC Block
const USHORT VER_LEGACYPRIVATE_IPC_BLOCK = 2;
const USHORT VER_LEGACYPUBLIC_IPC_BLOCK = 3;
//-----------------------------------------------------------------------------
// Entry in the IPC Directory. Ensure binary compatibility across versions
// if we add (or remove) entries. If we remove an block, the entry should
// be EMPTY_ENTRY_OFFSET
//-----------------------------------------------------------------------------
const ULONG EMPTY_ENTRY_OFFSET = 0xFFFFFFFF;
const ULONG EMPTY_ENTRY_SIZE = 0;
typedef struct IPCEntry
{
ULONG Offset; // offset of the IPC Block from the end of the Full IPC Header
ULONG Size; // size (in bytes) of the block
} IPCEntry;
// Newer versions of the CLR use Flags field
const USHORT IPC_FLAG_USES_FLAGS = 0x1;
const USHORT IPC_FLAG_INITIALIZED = 0x2;
const USHORT IPC_FLAG_X86 = 0x4;
// In hindsight, we should have made the offsets be absolute, but we made them
// relative to the end of the FullIPCHeader.
// The problem is that as future versions added new Entries to the directory,
// the header size grew.
// Thus we make IPCEntry::Offset is relative to IPC_ENTRY_OFFSET_BASE, which
// corresponds to sizeof(PrivateIPCHeader) for an v1.0 /v1.1 build.
const ULONG IPC_ENTRY_OFFSET_BASE_X86 = 0x14;
const ULONG IPC_ENTRY_OFFSET_BASE_X64 = 0x0;
/******************************************************************************
* The CLR opens memory mapped files to expose perfcounter values and other
* information to other processes. Historically there have been three memory
* mapped files: the BlockTable, the LegacyPrivateBlock, and the
* LegacyPublicBlock.
*
* BlockTable - The block table was designed to work with multiple runtimes
* running side by side in the same process (SxS in-proc). We have defined
* semantics using interlocked operations that allow a runtime to allocate
* a block from the block table in a thread-safe manner.
*
* LegacyPrivateBlock - The legacy private block was used by older versions
* of the runtime to expose various information to the debugger. The
* legacy private block is not compatible with in-proc SxS, and thus it
* must be removed in the near future. Currently it is being used to expose
* information about AppDomains to the debugger. We will need to keep the
* code that knows how to read the legacy private block as long as we
* continue to support .NET 3.5 SP1.
*
* LegacyPublicBlock - The legacy public block was used by older versions
* of the runtime to expose perfcounter values. The legacy public block is
* not compatible with in-proc SxS, and thus it has been removed. We will
* need to keep the code that knows how to read the legacy public block as
* long as we continue to support .NET 3.5 SP1.
******************************************************************************/
/**************************************** BLOCK TABLE ****************************************/
#define IPC_BLOCK_TABLE_SIZE 65536
#define IPC_BLOCK_SIZE 2048
#define IPC_NUM_BLOCKS_IN_TABLE 32
C_ASSERT(IPC_BLOCK_TABLE_SIZE == IPC_NUM_BLOCKS_IN_TABLE * IPC_BLOCK_SIZE);
typedef struct _IPCHeader
{
// Chunk header
volatile LONG Counter; // *** Volatile<LONG> *** value of 0 is special; means that this block has never been touched before by a writer
ULONG RuntimeId; // value of 0 is special; means that chunk is currently free (runtime ids are always greater than 0)
ULONG Reserved1;
ULONG Reserved2;
// Standard header
USHORT Version; // version of the IPC Block
USHORT Flags; // flags field
ULONG blockSize; // Size of the entire shared memory block
USHORT BuildYear; // stamp for year built
USHORT BuildNumber; // stamp for Month/Day built
ULONG NumEntries; // Number of entries in the table
// Directory
IPCEntry EntryTable[eIPC_MAX]; // entry describing each client's block
} IPCHeader;
#define SXSPUBLIC_IPC_SIZE_NO_PADDING (sizeof(IPCHeader) + sizeof(PerfCounterIPCControlBlock))
#define SXSPUBLIC_WOW64_IPC_SIZE_NO_PADDING (sizeof(IPCHeader) + sizeof(PerfCounterIPCControlBlock_Wow64))
#define SXSPUBLIC_IPC_PAD_SIZE (IPC_BLOCK_SIZE - SXSPUBLIC_IPC_SIZE_NO_PADDING)
#define SXSPUBLIC_WOW64_IPC_PAD_SIZE (IPC_BLOCK_SIZE - SXSPUBLIC_WOW64_IPC_SIZE_NO_PADDING)
#ifndef _WIN64
#include <pshpack4.h>
#endif
typedef struct _IPCControlBlock
{
// Header
IPCHeader Header;
// Client blocks
PerfCounterIPCControlBlock PerfIpcBlock;
// Padding
BYTE Padding[SXSPUBLIC_IPC_PAD_SIZE];
} IPCControlBlock;
#ifndef _WIN64
#include <poppack.h>
#endif
#include <pshpack4.h>
typedef struct _IPCControlBlock_Wow64
{
// Header
IPCHeader Header;
// Client blocks
PerfCounterIPCControlBlock_Wow64 PerfIpcBlock;
// Padding
BYTE Padding[SXSPUBLIC_WOW64_IPC_PAD_SIZE];
} IPCControlBlock_Wow64;
#include <poppack.h>
C_ASSERT(sizeof(IPCControlBlock) == IPC_BLOCK_SIZE);
C_ASSERT(sizeof(IPCControlBlock_Wow64) == IPC_BLOCK_SIZE);
#ifndef _WIN64
#include <pshpack4.h>
#endif
typedef struct IPCControlBlockTable
{
IPCControlBlock Blocks[IPC_NUM_BLOCKS_IN_TABLE];
} IPCControlBlockTable;
#ifndef _WIN64
#include <poppack.h>
#endif
#include <pshpack4.h>
typedef struct IPCControlBlockTable_Wow64
{
IPCControlBlock_Wow64 Blocks[IPC_NUM_BLOCKS_IN_TABLE];
} IPCControlBlockTable_Wow64;
#include <poppack.h>
C_ASSERT(sizeof(IPCControlBlockTable) == IPC_BLOCK_TABLE_SIZE);
C_ASSERT(sizeof(IPCControlBlockTable_Wow64) == IPC_BLOCK_TABLE_SIZE);
#ifndef _WIN64
#include <pshpack4.h>
#endif
typedef struct LegacyPrivateIPCHeader
{
USHORT Version; // version of the IPC Block
USHORT Flags; // flags field
ULONG BlockSize; // Size of the entire shared memory block
HINSTANCE hInstance; // Instance of module that created this header
USHORT BuildYear; // stamp for year built
USHORT BuildNumber; // stamp for Month/Day built
ULONG NumEntries; // Number of entries in the table
} LegacyPrivateIPCHeader;
#ifndef _WIN64
#include <poppack.h>
#endif
#include <pshpack4.h>
typedef struct LegacyPrivateIPCHeader_Wow64
{
USHORT Version; // version of the IPC Block
USHORT Flags; // flags field
ULONG BlockSize; // Size of the entire shared memory block
ULONG hInstance; // Instance of module that created this header
USHORT BuildYear; // stamp for year built
USHORT BuildNumber; // stamp for Month/Day built
ULONG NumEntries; // Number of entries in the table
} LegacyPrivateIPCHeader_Wow64;
#include <poppack.h>
#ifndef _WIN64
#include <pshpack4.h>
#endif
typedef struct FullIPCHeaderLegacyPrivate
{
// Header
LegacyPrivateIPCHeader Header;
// Directory
IPCEntry EntryTable[eLegacyPrivateIPC_MAX]; // entry describing each client's block
} FullIPCHeaderLegacyPrivate;
#ifndef _WIN64
#include <poppack.h>
#endif
#include <pshpack4.h>
typedef struct FullIPCHeaderLegacyPrivate_Wow64
{
// Header
LegacyPrivateIPCHeader_Wow64 Header;
// Directory
IPCEntry EntryTable[eLegacyPrivateIPC_MAX]; // entry describing each client's block
} FullIPCHeaderLegacyPrivate_Wow64;
#include <poppack.h>
#ifndef _WIN64
#include <pshpack4.h>
#endif
typedef struct FullIPCHeaderLegacyPublic
{
// Header
LegacyPrivateIPCHeader Header;
// Directory
IPCEntry EntryTable[eLegacyPublicIPC_MAX]; // entry describing each client's block
} FullIPCHeaderLegacyPublic;
#ifndef _WIN64
#include <poppack.h>
#endif
#include <pshpack4.h>
typedef struct FullIPCHeaderLegacyPublic_Wow64
{
// Header
LegacyPrivateIPCHeader_Wow64 Header;
// Directory
IPCEntry EntryTable[eLegacyPublicIPC_MAX]; // entry describing each client's block
} FullIPCHeaderLegacyPublic_Wow64;
#include <poppack.h>
//-----------------------------------------------------------------------------
// LegacyPrivate (per process) IPC Block for COM+ apps
//-----------------------------------------------------------------------------
#ifndef _WIN64
#include <pshpack4.h>
#endif
typedef struct _LegacyPrivateIPCControlBlock
{
FullIPCHeaderLegacyPrivate FullIPCHeader;
// Client blocks
PerfCounterIPCControlBlock PerfIpcBlock; // no longer used but kept for compat
AppDomainEnumerationIPCBlock AppDomainBlock;
WCHAR InstancePath[MAX_PATH];
} LegacyPrivateIPCControlBlock;
#ifndef _WIN64
#include <poppack.h>
#endif
#include <pshpack4.h>
typedef struct _LegacyPrivateIPCControlBlock_Wow64
{
FullIPCHeaderLegacyPrivate_Wow64 FullIPCHeader;
// Client blocks
PerfCounterIPCControlBlock_Wow64 PerfIpcBlock; // no longer used but kept for compat
AppDomainEnumerationIPCBlock_Wow64 AppDomainBlock;
WCHAR InstancePath[MAX_PATH];
} LegacyPrivateIPCControlBlock_Wow64;
#include <poppack.h>
//-----------------------------------------------------------------------------
// LegacyPublic (per process) IPC Block for CLR apps
//-----------------------------------------------------------------------------
#ifndef _WIN64
#include <pshpack4.h>
#endif
typedef struct LegacyPublicIPCControlBlock
{
FullIPCHeaderLegacyPublic FullIPCHeaderLegacyPublic;
// Client blocks
PerfCounterIPCControlBlock PerfIpcBlock;
} LegacyPublicIPCControlBlock;
#ifndef _WIN64
#include <poppack.h>
#endif
#include <pshpack4.h>
typedef struct _LegacyPublicIPCControlBlock_Wow64
{
FullIPCHeaderLegacyPublic_Wow64 FullIPCHeaderLegacyPublic;
// Client blocks
PerfCounterIPCControlBlock_Wow64 PerfIpcBlock;
} LegacyPublicIPCControlBlock_Wow64;
#include <poppack.h>
//class IPCHeaderLockHolder
//{
// LONG Counter;
// BOOL HaveLock;
// IPCHeader & Header;
//
// public:
//
// IPCHeaderLockHolder(IPCHeader & header) : HaveLock(FALSE), Header(header) {}
//
// BOOL TryGetLock()
// {
// _ASSERTE(!HaveLock);
// LONG oldCounter = Header.Counter;
// if ((oldCounter & 1) != 0)
// return FALSE;
// Counter = oldCounter + 1;
// if (InterlockedCompareExchange((LONG *)(&(Header.Counter)), Counter, oldCounter) != oldCounter)
// return FALSE;
// HaveLock = TRUE;
//
// return TRUE;
// }
//
// BOOL TryGetLock(ULONG numRetries)
// {
// ULONG dwSwitchCount = 0;
//
// for (;;)
// {
// if (TryGetLock())
// return TRUE;
//
// if (numRetries == 0)
// return FALSE;
//
// --numRetries;
// __SwitchToThread(0, ++dwSwitchCount);
// }
// }
//
// void FreeLock()
// {
// _ASSERTE(HaveLock);
// _ASSERTE(Header.Counter == Counter);
// ++Counter;
// Counter = (Counter == 0) ? 2 : Counter;
// Header.Counter = Counter;
// HaveLock = FALSE;
// }
//
// ~IPCHeaderLockHolder()
// {
// if (HaveLock)
// FreeLock();
// }
//};
//
//class IPCHeaderReadHelper
//{
// IPCHeader CachedHeader;
// IPCHeader * pUnreliableHeader;
// BOOL IsOpen;
//
// public:
//
// IPCHeaderReadHelper() : pUnreliableHeader(NULL), IsOpen(FALSE) {}
//
// BOOL TryOpenHeader(IPCHeader * header)
// {
// _ASSERTE(!IsOpen);
//
// pUnreliableHeader = header;
//
// // Read the counter and the runtime ID from the header
// CachedHeader.Counter = pUnreliableHeader->Counter;
// if ((CachedHeader.Counter & 1) != 0)
// return FALSE;
// CachedHeader.RuntimeId = pUnreliableHeader->RuntimeId;
//
// // If runtime ID is 0, then this block is not allocated by
// // a runtime, and thus there is no further work to do
// if (CachedHeader.RuntimeId == 0)
// {
// IsOpen = TRUE;
// return TRUE;
// }
//
// // Read the rest of the values from the header
// CachedHeader.Reserved1 = pUnreliableHeader->Reserved1;
// CachedHeader.Reserved2 = pUnreliableHeader->Reserved2;
// CachedHeader.Version = pUnreliableHeader->Version;
// CachedHeader.Flags = pUnreliableHeader->Flags;
// CachedHeader.blockSize = pUnreliableHeader->blockSize;
// CachedHeader.BuildYear = pUnreliableHeader->BuildYear;
// CachedHeader.BuildNumber = pUnreliableHeader->BuildNumber;
// CachedHeader.numEntries = pUnreliableHeader->numEntries;
//
// // Verify that the header did not change during the read
// LONG counter = pUnreliableHeader->Counter;
// if (CachedHeader.Counter != counter)
// return FALSE;
//
// // Since we know we got a clean read of numEntries, we
// // should be able to assert this with confidence
// if (CachedHeader.numEntries == 0)
// {
// _ASSERTE(!"numEntries from IPCBlock is zero");
// return FALSE;
// }
// else if (CachedHeader.numEntries > eIPC_MAX)
// {
// _ASSERTE(!"numEntries from IPCBlock is too big");
// return FALSE;
// }
//
// if (CachedHeader.blockSize == 0)
// {
// _ASSERTE(!"blockSize from IPCBlock is zero");
// return FALSE;
// }
// else if (CachedHeader.blockSize > IPC_BLOCK_SIZE)
// {
// _ASSERTE(!"blockSize from IPCBlock is too big");
// return FALSE;
// }
//
// // Copy the table
// for (ULONG i = 0; i < CachedHeader.numEntries; ++i)
// {
// CachedHeader.EntryTable[i].Offset = pUnreliableHeader->EntryTable[i].Offset;
// CachedHeader.EntryTable[i].Size = pUnreliableHeader->EntryTable[i].Size;
// if (i == eIPC_PerfCounters)
// {
// if(!((SIZE_T)CachedHeader.EntryTable[i].Offset < IPC_BLOCK_SIZE) && ((SIZE_T)CachedHeader.EntryTable[i].Offset + CachedHeader.EntryTable[i].Size <= IPC_BLOCK_SIZE))
// {
// _ASSERTE(!"PerfCounter section offset + size is too large");
// return FALSE;
// }
// }
// }
//
// // If eIPC_MAX > numEntries, then mark the left over
// // slots in EntryTable as "empty".
// for (ULONG i = CachedHeader.numEntries; i < eIPC_MAX; ++i)
// {
// CachedHeader.EntryTable[i].Offset = EMPTY_ENTRY_OFFSET;
// CachedHeader.EntryTable[i].Size = EMPTY_ENTRY_SIZE;
// }
//
// // Verify again that the header did not change during the read
// counter = pUnreliableHeader->Counter;
// if (CachedHeader.Counter != counter)
// return FALSE;
//
// IsOpen = TRUE;
// return TRUE;
// }
//
//
// BOOL HeaderHasChanged()
// {
// _ASSERTE(IsOpen);
// LONG counter = pUnreliableHeader->Counter;
// return (CachedHeader.Counter != counter) ? TRUE : FALSE;
// }
//
// BOOL IsSentinal()
// {
// _ASSERTE(IsOpen);
// return (CachedHeader.Counter == 0);
// }
//
//
// BOOL UseWow64Structs()
// {
// _ASSERTE(IsOpen);
//#if !defined(_TARGET_X86_)
// return ((CachedHeader.Flags & IPC_FLAG_X86) != 0) ? TRUE : FALSE;
//#else
// return FALSE;
//#endif
// }
//
// void * GetUnreliableSection(EIPCClient eClient)
// {
// if (!IsOpen)
// {
// _ASSERTE(!"IPCHeaderReadHelper is not open");
// return NULL;
// }
//
// if (eClient < 0 || eClient >= eIPC_MAX)
// {
// _ASSERTE(!"eClient is out of bounds");
// return NULL;
// }
//
// if (CachedHeader.EntryTable[eClient].Offset == EMPTY_ENTRY_OFFSET)
// {
// _ASSERTE(!"Section is empty");
// return NULL;
// }
//
// return (BYTE*)pUnreliableHeader + (SIZE_T)CachedHeader.EntryTable[eClient].Offset;
// }
//};
#endif // _IPC_HEADER_H_

View File

@@ -0,0 +1,57 @@
/*
* Process Hacker .NET Tools -
* .NET Process IPC definitions
*
* Copyright (C) 2015-2016 dmex
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Process Hacker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the current folder for more information.
//-----------------------------------------------------------------------------
// IPCShared.h
//
// Shared LegacyPrivate utility functions for IPC operations.
//-----------------------------------------------------------------------------
//
// dmex: This header has been highly modified.
// Original: https://github.com/dotnet/coreclr/blob/master/src/ipcman/ipcshared.h
#ifndef _IPC_SHARED_H_
#define _IPC_SHARED_H_
// This is the name of the file backed session's name on the LS (debuggee)
// Name of the LegacyPrivate (per-process) block. %lu resolved to a PID
#define CorLegacyPrivateIPCBlock L"Cor_Private_IPCBlock_%lu"
#define CorLegacyPrivateIPCBlockTempV4 L"Cor_Private_IPCBlock_v4_%lu"
#define CorLegacyPublicIPCBlock L"Cor_Public_IPCBlock_%lu"
#define CorSxSPublicIPCBlock L"Cor_SxSPublic_IPCBlock_%lu"
#define CorSxSBoundaryDescriptor L"Cor_CLR_IPCBlock_%lu"
#define CorSxSWriterPrivateNamespacePrefix L"Cor_CLR_WRITER"
#define CorSxSReaderPrivateNamespacePrefix L"Cor_CLR_READER"
#define CorSxSVistaPublicIPCBlock L"Cor_SxSPublic_IPCBlock"
#define CorLegacyPrivateIPCBlock_RS L"CLR_PRIVATE_RS_IPCBlock_%lu"
#define CorLegacyPrivateIPCBlock_RSTempV4 L"CLR_PRIVATE_RS_IPCBlock_v4_%lu"
#define CorLegacyPublicIPCBlock_RS L"CLR_PUBLIC_IPCBlock_%lu"
#define CorSxSPublicIPCBlock_RS L"CLR_SXSPUBLIC_IPCBlock_%lu"
#define CorSxSPublicInstanceName L"%s_p%lu_r%lu"
#define CorSxSPublicInstanceNameWhidbey L"%s_p%lu"
#endif _IPC_SHARED_H_

View File

@@ -0,0 +1,333 @@
/*
* Process Hacker .NET Tools -
* .NET Process IPC definitions
*
* Copyright (C) 2015-2016 dmex
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Process Hacker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the current folder for more information.
//-----------------------------------------------------------------------------
// PerfCounterDefs.h
//
// Internal Interface for CLR to use Performance counters.
//-----------------------------------------------------------------------------
//
// dmex: This header has been highly modified.
// Original: https://github.com/dotnet/coreclr/blob/master/src/inc/perfcounterdefs.h
#ifndef _PERF_COUNTERS_H_
#define _PERF_COUNTERS_H_
//-----------------------------------------------------------------------------
// Name of global IPC block
#define SHARED_PERF_IPC_NAME "SharedPerfIPCBlock"
//-----------------------------------------------------------------------------
// Attributes for the IPC block
#define PERF_ATTR_ON 0x0001 // Are we even updating any counters?
#define PERF_ATTR_GLOBAL 0x0002 // Is this a global or private block?
//.............................................................................
// Tri Counter. Support for the common trio of counters (Total, Current, and Instantaneous).
typedef struct _TRICOUNT
{
ULONG Current; // Current, has +, -
ULONG Total; // Total, has only +
} TRICOUNT;
//.............................................................................
// Interlocked Tri Counter. Support for the common trio of counters (Total, Current, and Instantaneous).
typedef struct _TRICOUNT_IL
{
ULONG Current; // Current, has +, -
ULONG Total; // Total, has only +
} TRICOUNT_IL;
//.............................................................................
// Dual Counter. Support for the (Total and Instantaneous (rate)). Helpful in cases
// where the current value is always same as the total value. ie. the counter is never
// decremented.
//.............................................................................
typedef struct _DUALCOUNT
{
ULONG Total;
} DUALCOUNT;
//-----------------------------------------------------------------------------
// Format for the Perf Counter IPC Block
// IPC block is broken up into sections. This marks it easier to marshall
// into different perfmon objects
//
//.............................................................................
// Naming convention (by prefix):
// c - Raw count of something.
// cb- count of bytes
// time - time value.
// depth - stack depth
//-----------------------------------------------------------------------------
#define MAX_TRACKED_GENS 3 // number of generations we track
#ifndef _WIN64
#include <pshpack4.h>
#endif
typedef struct _Perf_GC
{
size_t cGenCollections[MAX_TRACKED_GENS]; // count of collects per gen
size_t cbPromotedMem[MAX_TRACKED_GENS - 1]; // count of promoted memory
size_t cbPromotedFinalizationMem; // count of memory promoted due to finalization
size_t cProcessID; // process ID
size_t cGenHeapSize[MAX_TRACKED_GENS]; // size of heaps per gen
size_t cTotalCommittedBytes; // total number of committed bytes.
size_t cTotalReservedBytes; // bytes reserved via VirtualAlloc
size_t cLrgObjSize; // size of Large Object Heap
size_t cSurviveFinalize; // count of instances surviving from finalizing
size_t cHandles; // count of GC handles
size_t cbAlloc; // bytes allocated
size_t cbLargeAlloc; // bytes allocated for Large Objects
size_t cInducedGCs; // number of explicit GCs
ULONG timeInGC; // Time in GC
ULONG timeInGCBase; // must follow time in GC counter
size_t cPinnedObj; // # of Pinned Objects
size_t cSinkBlocks; // # of sink blocks
} Perf_GC;
#ifndef _WIN64
#include <poppack.h>
#endif
// Perf_GC_Wow64 mimics in a 64 bit process, the layout of Perf_GC in a 32 bit process
// It does this by replacing all size_t by ULONG
#include <pshpack4.h>
typedef struct _Perf_GC_Wow64
{
ULONG cGenCollections[MAX_TRACKED_GENS]; // count of collects per gen
ULONG cbPromotedMem[MAX_TRACKED_GENS - 1]; // count of promoted memory
ULONG cbPromotedFinalizationMem; // count of memory promoted due to finalization
ULONG cProcessID; // process ID
ULONG cGenHeapSize[MAX_TRACKED_GENS]; // size of heaps per gen
ULONG cTotalCommittedBytes; // total number of committed bytes.
ULONG cTotalReservedBytes; // bytes reserved via VirtualAlloc
ULONG cLrgObjSize; // size of Large Object Heap
ULONG cSurviveFinalize; // count of instances surviving from finalizing
ULONG cHandles; // count of GC handles
ULONG cbAlloc; // bytes allocated
ULONG cbLargeAlloc; // bytes allocated for Large Objects
ULONG cInducedGCs; // number of explicit GCs
ULONG timeInGC; // Time in GC
ULONG timeInGCBase; // must follow time in GC counter
ULONG cPinnedObj; // # of Pinned Objects
ULONG cSinkBlocks; // # of sink blocks
} Perf_GC_Wow64;
#include <poppack.h>
#ifndef _WIN64
#include <pshpack4.h>
#endif
typedef struct Perf_Loading
{
TRICOUNT cClassesLoaded;
TRICOUNT_IL cAppDomains; // Current # of AppDomains
TRICOUNT cAssemblies; // Current # of Assemblies
UNALIGNED LONGLONG timeLoading; // % time loading
ULONG cAsmSearchLen; // Avg search length for assemblies
DUALCOUNT cLoadFailures; // Classes Failed to load
size_t cbLoaderHeapSize; // Total size of heap used by the loader
DUALCOUNT cAppDomainsUnloaded; // Rate at which app domains are unloaded
} Perf_Loading;
#ifndef _WIN64
#include <poppack.h>
#endif
#include <pshpack4.h>
typedef struct Perf_Loading_Wow64
{
TRICOUNT cClassesLoaded;
TRICOUNT_IL cAppDomains; // Current # of AppDomains
TRICOUNT cAssemblies; // Current # of Assemblies
UNALIGNED LONGLONG timeLoading; // % time loading
ULONG cAsmSearchLen; // Avg search length for assemblies
DUALCOUNT cLoadFailures; // Classes Failed to load
ULONG cbLoaderHeapSize; // Total size of heap used by the loader
DUALCOUNT cAppDomainsUnloaded; // Rate at which app domains are unloaded
} Perf_Loading_Wow64;
#include <poppack.h>
#ifndef _WIN64
#include <pshpack4.h>
#endif
typedef struct Perf_Jit
{
ULONG cMethodsJitted; // number of methods jitted
TRICOUNT cbILJitted; // IL jitted stats
//DUALCOUNT cbPitched; // Total bytes pitched
ULONG cJitFailures; // # of standard Jit failures
ULONG timeInJit; // Time in JIT since last sample
ULONG timeInJitBase; // Time in JIT base counter
} Perf_Jit;
#ifndef _WIN64
#include <poppack.h>
#endif
#ifndef _WIN64
#include <pshpack4.h>
#endif
typedef struct Perf_Excep
{
DUALCOUNT cThrown; // Number of Exceptions thrown
ULONG cFiltersExecuted; // Number of Filters executed
ULONG cFinallysExecuted; // Number of Finallys executed
ULONG cThrowToCatchStackDepth; // Delta from throw to catch site on stack
} Perf_Excep;
#ifndef _WIN64
#include <poppack.h>
#endif
#ifndef _WIN64
#include <pshpack4.h>
#endif
typedef struct Perf_Interop
{
ULONG cCCW; // Number of CCWs
ULONG cStubs; // Number of stubs
ULONG cMarshalling; // # of time marshalling args and return values.
ULONG cTLBImports; // Number of tlbs we import
ULONG cTLBExports; // Number of tlbs we export
} Perf_Interop;
#ifndef _WIN64
#include <poppack.h>
#endif
#ifndef _WIN64
#include <pshpack4.h>
#endif
typedef struct Perf_LocksAndThreads
{
// Locks
DUALCOUNT cContention; // # of times in AwareLock::EnterEpilogue()
TRICOUNT cQueueLength; // Lenght of queue
// Threads
ULONG cCurrentThreadsLogical; // Number (created - destroyed) of logical threads
ULONG cCurrentThreadsPhysical; // Number (created - destroyed) of OS threads
TRICOUNT cRecognizedThreads; // # of Threads execute in runtime's control
} Perf_LocksAndThreads;
#ifndef _WIN64
#include <poppack.h>
#endif
// IMPORTANT!!!!!!!: The first two fields in the struct have to be together
// and be the first two fields in the struct. The managed code in ChannelServices.cs
// depends on this.
#ifndef _WIN64
#include <pshpack4.h>
#endif
typedef struct Perf_Contexts
{
// Contexts & Remoting
DUALCOUNT cRemoteCalls; // # of remote calls
ULONG cChannels; // Number of current channels
ULONG cProxies; // Number of context proxies.
ULONG cClasses; // # of Context-bound classes
ULONG cObjAlloc; // # of context bound objects allocated
ULONG cContexts; // The current number of contexts.
} Perf_Contexts;
#ifndef _WIN64
#include <poppack.h>
#endif
#ifndef _WIN64
#include <pshpack4.h>
#endif
typedef struct Perf_Security
{
ULONG cTotalRTChecks; // Total runtime checks
UNALIGNED LONGLONG timeAuthorize; // % time authenticating
ULONG cLinkChecks; // link time checks
ULONG timeRTchecks; // % time in Runtime checks
ULONG timeRTchecksBase; // % time in Runtime checks base counter
ULONG stackWalkDepth; // depth of stack for security checks
} Perf_Security;
#ifndef _WIN64
#include <poppack.h>
#endif
#include <pshpack4.h>
typedef struct Perf_Security_Wow64
{
ULONG cTotalRTChecks; // Total runtime checks
UNALIGNED LONGLONG timeAuthorize; // % time authenticating
ULONG cLinkChecks; // link time checks
ULONG timeRTchecks; // % time in Runtime checks
ULONG timeRTchecksBase; // % time in Runtime checks base counter
ULONG stackWalkDepth; // depth of stack for security checks
} Perf_Security_Wow64;
#include <poppack.h>
#ifndef _WIN64
#include <pshpack4.h>
#endif
typedef struct _PerfCounterIPCControlBlock
{
// Versioning info
USHORT Bytes; // size of this entire block
USHORT Attributes; // attributes for this block
// Counter Sections
Perf_GC GC;
Perf_Contexts Context;
Perf_Interop Interop;
Perf_Loading Loading;
Perf_Excep Excep;
Perf_LocksAndThreads LocksAndThreads;
Perf_Jit Jit;
Perf_Security Security;
} PerfCounterIPCControlBlock;
#ifndef _WIN64
#include <poppack.h>
#endif
#include <pshpack4.h>
typedef struct _PerfCounterIPCControlBlock_Wow64
{
// Versioning info
USHORT Bytes; // size of this entire block
USHORT Attributes; // attributes for this block
// Counter Sections
Perf_GC_Wow64 GC;
Perf_Contexts Context;
Perf_Interop Interop;
Perf_Loading_Wow64 Loading;
Perf_Excep Excep;
Perf_LocksAndThreads LocksAndThreads;
Perf_Jit Jit;
Perf_Security_Wow64 Security;
} PerfCounterIPCControlBlock_Wow64;
#include <poppack.h>
#endif _PERF_COUNTERS_H_