├── .gitignore
├── CAPE
├── CAPE.c
├── CAPE.h
├── Debugger.c
├── Debugger.h
├── GetThreadId.c
├── Output.c
├── Scylla
│ ├── ApiReader.cpp
│ ├── ApiReader.h
│ ├── Architecture.h
│ ├── DeviceNameResolver.cpp
│ ├── DeviceNameResolver.h
│ ├── IATReferenceScan.cpp
│ ├── IATReferenceScan.h
│ ├── IATSearch.cpp
│ ├── IATSearch.h
│ ├── ImportRebuilder.cpp
│ ├── ImportRebuilder.h
│ ├── ImportsHandling.cpp
│ ├── ImportsHandling.h
│ ├── NativeWinApi.cpp
│ ├── NativeWinApi.h
│ ├── PeParser.cpp
│ ├── PeParser.h
│ ├── ProcessAccessHelp.cpp
│ ├── ProcessAccessHelp.h
│ ├── StringConversion.cpp
│ ├── StringConversion.h
│ ├── SystemInformation.cpp
│ ├── SystemInformation.h
│ └── Thunks.h
├── ScyllaHarness.cpp
├── w64wow64
│ ├── internal.h
│ ├── w64wow64.c
│ ├── w64wow64.h
│ ├── w64wow64defs.h
│ └── windef.h
└── wow64_fix.c
├── LICENSE.txt
├── Makefile
├── README.md
├── alloc.c
├── alloc.h
├── bson
├── LICENSE
├── bson.c
├── bson.h
├── bson.sln
├── bson.vcxproj
├── bson.vcxproj.filters
├── encoding.c
├── encoding.h
└── numbers.c
├── capstone-config.mk
├── config.c
├── config.h
├── cuckoomon.c
├── cuckoomon.sln
├── cuckoomon.vcxproj
├── cuckoomon.vcxproj.filters
├── distorm
├── COPYING
├── include
│ ├── distorm.h
│ └── mnemonics.h
└── src
│ ├── config.h
│ ├── decoder.c
│ ├── decoder.h
│ ├── distorm.c
│ ├── instructions.c
│ ├── instructions.h
│ ├── insts.c
│ ├── insts.h
│ ├── mnemonics.c
│ ├── operands.c
│ ├── operands.h
│ ├── prefix.c
│ ├── prefix.h
│ ├── textdefs.c
│ ├── textdefs.h
│ ├── wstring.c
│ ├── wstring.h
│ └── x86defs.h
├── hook_crypto.c
├── hook_file.c
├── hook_file.h
├── hook_misc.c
├── hook_network.c
├── hook_process.c
├── hook_reg.c
├── hook_reg_native.c
├── hook_services.c
├── hook_sleep.c
├── hook_sleep.h
├── hook_socket.c
├── hook_special.c
├── hook_sync.c
├── hook_thread.c
├── hook_window.c
├── hooking.c
├── hooking.h
├── hooking_32.c
├── hooking_64.c
├── hooks.h
├── ignore.c
├── ignore.h
├── install.sh
├── loader
└── loader
│ ├── Loader.c
│ ├── Loader.h
│ ├── loader.vcxproj
│ └── loader.vcxproj.filters
├── log.c
├── log.h
├── lookup.c
├── lookup.h
├── misc.c
├── misc.h
├── ntapi.h
├── pipe.c
├── pipe.h
├── tests
├── Makefile
├── apc-inject.c
├── apihooks.c
├── bind-port.c
├── blacklist.c
├── child-sleep.c
├── crash.c
├── create-file.c
├── delete-file.c
├── getcursorpos.c
├── logging.c
├── lookup.c
├── migrate-process.c
├── mitigate-process.c
├── mousebutton-count.c
├── open-protected-pid.c
├── peb-check.c
├── sleep.c
├── sleep2.c
├── startup-time.c
├── suspended-process.c
├── test-dns.c
├── test-lasterr.c
├── test-lde.c
├── unhook.c
├── wininet.c
└── write-file.c
├── unhook.c
├── unhook.h
├── utf8.c
└── utf8.h
/.gitignore:
--------------------------------------------------------------------------------
1 | logtbl.c
2 | Debug/
3 | cuckoomon.opensdf
4 | cuckoomon.sdf
5 | cuckoomon.v11.suo
6 | cuckoomon.v12.suo
7 | bson/bson.sdf
8 | bson/bson.v11.suo
9 | bson/bson.v12.suo
10 | bson/bson.vcxproj.user
11 | logtbl.pyc
12 | cuckoomon.vcxproj.user
13 | bson/Release
14 | objects
15 | Release
16 | tests/logging-test.*
17 | *.suo
18 | *.opendb
19 | *.VC.db
20 | .vs/*
21 |
--------------------------------------------------------------------------------
/CAPE/CAPE.h:
--------------------------------------------------------------------------------
1 | /*
2 | CAPE - Config And Payload Extraction
3 | Copyright(C) 2015-2017 Context Information Security. (kevin.oreilly@contextis.com)
4 |
5 | This program is free software : you can redistribute it and / or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program.If not, see .
17 | */
18 | extern HMODULE s_hInst;
19 | extern WCHAR s_wzDllPath[MAX_PATH];
20 | extern CHAR s_szDllPath[MAX_PATH];
21 |
22 | //Global debugger switch
23 | #define DEBUGGER_ENABLED 0
24 |
25 | PVOID GetHookCallerBase();
26 | PVOID GetPageAddress(PVOID Address);
27 | PVOID GetAllocationBase(PVOID Address);
28 | BOOL TranslatePathFromDeviceToLetter(__in TCHAR *DeviceFilePath, __out TCHAR* DriveLetterFilePath, __inout LPDWORD lpdwBufferSize);
29 | BOOL DumpPEsInRange(LPVOID Buffer, SIZE_T Size);
30 | BOOL DumpRegion(PVOID Address);
31 | int DumpMemory(LPVOID Buffer, SIZE_T Size);
32 | int DumpCurrentProcessNewEP(LPVOID NewEP);
33 | int DumpCurrentProcess();
34 | int DumpProcess(HANDLE hProcess, LPVOID ImageBase);
35 | int DumpPE(LPVOID Buffer);
36 | int ScanForNonZero(LPVOID Buffer, SIZE_T Size);
37 | int ScanPageForNonZero(LPVOID Address);
38 | int ScanForPE(LPVOID Buffer, SIZE_T Size, LPVOID* Offset);
39 | int ScanForDisguisedPE(LPVOID Buffer, SIZE_T Size, LPVOID* Offset);
40 | int IsDisguisedPEHeader(LPVOID Buffer);
41 | int DumpImageInCurrentProcess(LPVOID ImageBase);
42 | void DumpSectionViewsForPid(DWORD Pid);
43 |
44 | SYSTEM_INFO SystemInfo;
45 | PVOID CallingModule;
46 |
47 | typedef struct InjectionSectionView
48 | {
49 | HANDLE SectionHandle;
50 | PVOID LocalView;
51 | SIZE_T ViewSize;
52 | int TargetProcessId;
53 | struct InjectionSectionView *NextSectionView;
54 | } INJECTIONSECTIONVIEW, *PINJECTIONSECTIONVIEW;
55 |
56 | PINJECTIONSECTIONVIEW AddSectionView(HANDLE SectionHandle, PVOID LocalView, SIZE_T ViewSize);
57 | PINJECTIONSECTIONVIEW GetSectionView(HANDLE SectionHandle);
58 | BOOL DropSectionView(PINJECTIONSECTIONVIEW SectionView);
59 | void DumpSectionViewsForPid(DWORD Pid);
60 | void DumpSectionView(PINJECTIONSECTIONVIEW SectionView);
61 |
62 | typedef struct InjectionInfo
63 | {
64 | int ProcessId;
65 | HANDLE ProcessHandle;
66 | DWORD_PTR ImageBase;
67 | DWORD_PTR EntryPoint;
68 | BOOL WriteDetected;
69 | BOOL ImageDumped;
70 | LPVOID BufferBase;
71 | LPVOID StackPointer;
72 | unsigned int BufferSizeOfImage;
73 | HANDLE SectionHandle;
74 | // struct InjectionSectionView *SectionViewList;
75 | struct InjectionInfo *NextInjectionInfo;
76 | } INJECTIONINFO, *PINJECTIONINFO;
77 |
78 | struct InjectionInfo *InjectionInfoList;
79 |
80 | PINJECTIONINFO GetInjectionInfo(DWORD ProcessId);
81 | PINJECTIONINFO CreateInjectionInfo(DWORD ProcessId);
82 |
83 | struct InjectionSectionView *SectionViewList;
84 |
85 | //
86 | // MessageId: STATUS_SUCCESS
87 | //
88 | // MessageText:
89 | //
90 | // STATUS_SUCCESS
91 | //
92 | #define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
93 |
94 | //
95 | // MessageId: STATUS_BAD_COMPRESSION_BUFFER
96 | //
97 | // MessageText:
98 | //
99 | // The specified buffer contains ill-formed data.
100 | //
101 | #define STATUS_BAD_COMPRESSION_BUFFER ((NTSTATUS)0xC0000242L)
102 |
103 | #define PE_HEADER_LIMIT 0x200 // Range to look for PE header within candidate buffer
104 |
105 | #define SIZE_OF_LARGEST_IMAGE ((ULONG)0x77000000)
106 |
107 | #pragma comment(lib, "Wininet.lib")
108 |
109 | #define DATA 0
110 | #define EXECUTABLE 1
111 | #define DLL 2
112 |
113 | #define PLUGX_SIGNATURE 0x5658 // 'XV'
114 |
115 | typedef struct CapeMetadata
116 | {
117 | char* ProcessPath;
118 | char* ModulePath;
119 | DWORD Pid;
120 | DWORD DumpType;
121 | char* TargetProcess; // For injection
122 | DWORD TargetPid; // "
123 | PVOID Address; // For shellcode/modules
124 | SIZE_T Size; // "
125 | } CAPEMETADATA, *PCAPEMETADATA;
126 |
127 | struct CapeMetadata *CapeMetaData;
128 |
129 | BOOL SetCapeMetaData(DWORD DumpType, DWORD TargetPid, HANDLE hTargetProcess, PVOID Address);
130 |
131 | enum {
132 | PROCDUMP = 0,
133 |
134 | COMPRESSION = 1,
135 |
136 | INJECTION_PE = 3,
137 | INJECTION_SHELLCODE = 4,
138 | //INJECTION_RUNPE = 5,
139 |
140 | EXTRACTION_PE = 8,
141 | EXTRACTION_SHELLCODE = 9,
142 |
143 | PLUGX_PAYLOAD = 0x10,
144 | PLUGX_CONFIG = 0x11,
145 |
146 | EVILGRAB_PAYLOAD = 0x14,
147 | EVILGRAB_DATA = 0x15,
148 |
149 | SEDRECO_DATA = 0x20,
150 |
151 | URSNIF_CONFIG = 0x24,
152 | URSNIF_PAYLOAD = 0x25,
153 |
154 | CERBER_CONFIG = 0x30,
155 | CERBER_PAYLOAD = 0x31,
156 |
157 | DATADUMP = 0x66
158 | };
159 |
160 | HANDLE EvilGrabRegHandle;
161 |
--------------------------------------------------------------------------------
/CAPE/Debugger.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #pragma once
3 |
4 | #define DEBUGGER_LAUNCHER 0
5 | #define DisableThreadSuspend 0
6 |
7 | #define BP_EXEC 0x00
8 | #define BP_WRITE 0x01
9 | #define BP_RESERVED 0x02
10 | #define BP_READWRITE 0x03
11 |
12 | #define NUMBER_OF_DEBUG_REGISTERS 4
13 | #define MAX_DEBUG_REGISTER_DATA_SIZE 4
14 | #define DEBUG_REGISTER_DATA_SIZES {1, 2, 4}
15 | #define DEBUG_REGISTER_LENGTH_MASKS {0xFFFFFFFF, 0, 1, 0xFFFFFFFF, 3}
16 |
17 | #define EXECUTABLE_FLAGS (PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY)
18 | #define WRITABLE_FLAGS (PAGE_READWRITE | PAGE_WRITECOPY | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY | PAGE_WRITECOMBINE)
19 |
20 | #define EXTRACTION_MIN_SIZE 0x1001
21 |
22 | #if (NTDDI_VERSION <= NTDDI_WINBLUE)
23 | typedef struct _EXCEPTION_REGISTRATION_RECORD {
24 | struct _EXCEPTION_REGISTRATION_RECORD *Next;
25 | PEXCEPTION_ROUTINE Handler;
26 | } EXCEPTION_REGISTRATION_RECORD;
27 |
28 | typedef EXCEPTION_REGISTRATION_RECORD *PEXCEPTION_REGISTRATION_RECORD;
29 | #endif
30 |
31 | typedef struct BreakpointInfo
32 | {
33 | HANDLE ThreadHandle;
34 | int Register;
35 | int Size;
36 | LPVOID Address;
37 | DWORD Type;
38 | LPVOID Callback;
39 | } BREAKPOINTINFO, *PBREAKPOINTINFO;
40 |
41 | typedef BOOL (cdecl *BREAKPOINT_HANDLER)(PBREAKPOINTINFO, struct _EXCEPTION_POINTERS*);
42 |
43 | typedef struct ThreadBreakpoints
44 | {
45 | DWORD ThreadId;
46 | HANDLE ThreadHandle;
47 | BREAKPOINTINFO BreakpointInfo[4];
48 | struct ThreadBreakpoints *NextThreadBreakpoints;
49 | } THREADBREAKPOINTS, *PTHREADBREAKPOINTS;
50 |
51 | typedef struct TrackedRegion
52 | {
53 | PVOID BaseAddress;
54 | PVOID ProtectAddress;
55 | SIZE_T RegionSize;
56 | ULONG Protect;
57 | MEMORY_BASIC_INFORMATION MemInfo;
58 | BOOL Committed;
59 | PVOID LastAccessAddress;
60 | PVOID LastWriteAddress;
61 | PVOID LastReadAddress;
62 | BOOL WriteDetected;
63 | BOOL ReadDetected;
64 | PVOID LastAccessBy;
65 | PVOID LastWrittenBy;
66 | PVOID LastReadBy;
67 | BOOL PagesDumped;
68 | BOOL CanDump;
69 | BOOL Guarded;
70 | unsigned int WriteCounter;
71 | // under review
72 | BOOL WriteBreakpointSet;
73 | BOOL PeImageDetected;
74 | BOOL AllocationBaseExecBpSet;
75 | BOOL AllocationWriteDetected;
76 | //
77 | PVOID ExecBp;
78 | unsigned int ExecBpRegister;
79 | PVOID MagicBp;
80 | unsigned int MagicBpRegister;
81 | BOOL BreakpointsSet;
82 | BOOL BreakpointsSaved;
83 | struct ThreadBreakpoints *TrackedRegionBreakpoints;
84 | struct TrackedRegion *NextTrackedRegion;
85 | } TRACKEDREGION, *PTRACKEDREGION;
86 |
87 | struct TrackedRegion *TrackedRegionList;
88 |
89 | typedef BOOL (cdecl *SINGLE_STEP_HANDLER)(struct _EXCEPTION_POINTERS*);
90 | typedef BOOL (cdecl *GUARD_PAGE_HANDLER)(struct _EXCEPTION_POINTERS*);
91 | typedef BOOL (cdecl *SAMPLE_HANDLER)(struct _EXCEPTION_POINTERS*);
92 |
93 | typedef void (WINAPI *PWIN32ENTRY)();
94 |
95 | #ifdef __cplusplus
96 | extern "C" {
97 | #endif
98 |
99 | BOOL DebuggerInitialised;
100 |
101 | // Global variables for submission options
102 | void *CAPE_var1, *CAPE_var2, *CAPE_var3, *CAPE_var4;
103 | PVOID bp0, bp1, bp2, bp3;
104 |
105 | LONG WINAPI CAPEExceptionFilter(struct _EXCEPTION_POINTERS* ExceptionInfo);
106 | PVOID CAPEExceptionFilterHandle;
107 | SAMPLE_HANDLER SampleVectoredHandler;
108 | PEXCEPTION_ROUTINE SEH_TopLevelHandler;
109 | LPTOP_LEVEL_EXCEPTION_FILTER OriginalExceptionHandler;
110 | BOOL VECTORED_HANDLER;
111 | BOOL GuardPagesDisabled;
112 |
113 | DWORD ChildProcessId;
114 | DWORD ChildThreadId;
115 | DWORD_PTR DebuggerEP;
116 | PWIN32ENTRY OEP;
117 |
118 | int launch_debugger(void);
119 |
120 | // Set
121 | BOOL SetBreakpoint(int Register, int Size, LPVOID Address, DWORD Type, PVOID Callback);
122 | BOOL SetThreadBreakpoint(DWORD ThreadId, int Register, int Size, LPVOID Address, DWORD Type, PVOID Callback);
123 | BOOL ContextSetThreadBreakpoint(PCONTEXT Context, int Register, int Size, LPVOID Address, DWORD Type, PVOID Callback);
124 | BOOL ContextSetDebugRegister(PCONTEXT Context, int Register, int Size, LPVOID Address, DWORD Type);
125 | BOOL SetThreadBreakpoints(PTHREADBREAKPOINTS ThreadBreakpoints);
126 | BOOL ContextSetBreakpoint(PTHREADBREAKPOINTS ThreadBreakpoints);
127 | BOOL ContextUpdateCurrentBreakpoint(PCONTEXT Context, int Size, LPVOID Address, DWORD Type, PVOID Callback);
128 | BOOL SetNextAvailableBreakpoint(DWORD ThreadId, unsigned int* Register, int Size, LPVOID Address, DWORD Type, PVOID Callback);
129 | BOOL SetSingleStepMode(PCONTEXT Context, PVOID Handler);
130 | BOOL SetResumeFlag(PCONTEXT Context);
131 | BOOL SetZeroFlag(PCONTEXT Context);
132 | BOOL ClearZeroFlag(PCONTEXT Context);
133 | PTHREADBREAKPOINTS CreateThreadBreakpoints(DWORD ThreadId);
134 |
135 | // Get
136 | BOOL GetNextAvailableBreakpoint(DWORD ThreadId, unsigned int* Register);
137 | PTHREADBREAKPOINTS GetThreadBreakpoints(DWORD ThreadId);
138 | BOOL ContextGetNextAvailableBreakpoint(PCONTEXT Context, unsigned int* Register);
139 | BOOL ContextSetNextAvailableBreakpoint(PCONTEXT Context, unsigned int* Register, int Size, LPVOID Address, DWORD Type, PVOID Callback);
140 | int CheckDebugRegister(HANDLE hThread, int Register);
141 | BOOL CheckDebugRegisters(HANDLE hThread, PCONTEXT pContext);
142 | int ContextCheckDebugRegister(CONTEXT Context, int Register);
143 | BOOL ContextCheckDebugRegisters(PCONTEXT pContext);
144 | HANDLE GetThreadHandle(DWORD ThreadId);
145 |
146 | // Clear
147 | BOOL ClearBreakpoint(DWORD ThreadId, int Register);
148 | BOOL ClearBreakpointsInRange(DWORD ThreadId, PVOID BaseAddress, SIZE_T Size);
149 | BOOL ContextClearBreakpoint(PCONTEXT Context, PBREAKPOINTINFO pBreakpointInfo);
150 | BOOL ContextClearCurrentBreakpoint(PCONTEXT Context);
151 | BOOL ContextClearAllBreakpoints(PCONTEXT Context);
152 | BOOL ClearAllBreakpoints();
153 | BOOL ClearSingleStepMode(PCONTEXT Context);
154 |
155 | // Misc
156 | BOOL InitNewThreadBreakpoints(DWORD ThreadId);
157 | BOOL InitialiseDebugger(void);
158 | BOOL DebugNewProcess(unsigned int ProcessId, unsigned int ThreadId, DWORD CreationFlags);
159 | BOOL SendDebuggerMessage(PVOID Input);
160 | BOOL StepOverExecutionBreakpoint(PCONTEXT Context, PBREAKPOINTINFO pBreakpointInfo);
161 | BOOL ResumeAfterExecutionBreakpoint(PCONTEXT Context, PBREAKPOINTINFO pBreakpointInfo);
162 |
163 | void ShowStack(DWORD_PTR StackPointer, unsigned int NumberOfRecords);
164 |
165 | BOOL IsInTrackedRegions(PVOID Address);
166 | PTRACKEDREGION CreateTrackedRegions();
167 | PTRACKEDREGION GetTrackedRegion(PVOID Address);
168 | PTRACKEDREGION AddTrackedRegion(PVOID Address, SIZE_T RegionSize, ULONG Protect);
169 | BOOL DropTrackedRegion(PTRACKEDREGION TrackedRegion);
170 | BOOL ActivateGuardPages(PTRACKEDREGION TrackedRegion);
171 | BOOL ActivateGuardPagesOnProtectedRange(PTRACKEDREGION TrackedRegion);
172 | BOOL DeactivateGuardPages(PTRACKEDREGION TrackedRegion);
173 | BOOL ActivateSurroundingGuardPages(PTRACKEDREGION TrackedRegion);
174 |
175 | #ifdef __cplusplus
176 | }
177 | #endif
--------------------------------------------------------------------------------
/CAPE/GetThreadId.c:
--------------------------------------------------------------------------------
1 | /*
2 | CAPE - Config And Payload Extraction
3 | Copyright(C) 2015, 2016 Context Information Security. (kevin.oreilly@contextis.com)
4 |
5 | This program is free software : you can redistribute it and / or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program.If not, see .
17 | */
18 | #include
19 |
20 | #define STATUS_SUCCESS ((NTSTATUS) 0x00000000)
21 | typedef LONG NTSTATUS;
22 | typedef LONG KPRIORITY;
23 | typedef PVOID PTEB;
24 |
25 | //
26 | // Thread Information Classes
27 | //
28 |
29 | typedef enum _THREADINFOCLASS
30 | {
31 | ThreadBasicInformation,
32 | ThreadTimes,
33 | ThreadPriority,
34 | ThreadBasePriority,
35 | ThreadAffinityMask,
36 | ThreadImpersonationToken,
37 | ThreadDescriptorTableEntry,
38 | ThreadEnableAlignmentFaultFixup,
39 | ThreadEventPair_Reusable,
40 | ThreadQuerySetWin32StartAddress,
41 | ThreadZeroTlsCell,
42 | ThreadPerformanceCount,
43 | ThreadAmILastThread,
44 | ThreadIdealProcessor,
45 | ThreadPriorityBoost,
46 | ThreadSetTlsArrayAddress,
47 | ThreadIsIoPending,
48 | ThreadHideFromDebugger,
49 | ThreadBreakOnTermination,
50 | ThreadSwitchLegacyState,
51 | ThreadIsTerminated,
52 | MaxThreadInfoClass
53 | } THREADINFOCLASS;
54 |
55 | typedef struct _CLIENT_ID
56 | {
57 | HANDLE UniqueProcess;
58 | HANDLE UniqueThread;
59 | } CLIENT_ID, *PCLIENT_ID;
60 |
61 | //
62 | // Thread Information Structures
63 | //
64 |
65 | //
66 | // Basic Thread Information
67 | // NtQueryInformationThread using ThreadBasicInfo
68 | //
69 |
70 | typedef struct _THREAD_BASIC_INFORMATION
71 | {
72 | NTSTATUS ExitStatus;
73 | PTEB TebBaseAddress;
74 | CLIENT_ID ClientId;
75 | ULONG_PTR AffinityMask;
76 | KPRIORITY Priority;
77 | LONG BasePriority;
78 | } THREAD_BASIC_INFORMATION;
79 | typedef THREAD_BASIC_INFORMATION *PTHREAD_BASIC_INFORMATION;
80 |
81 | typedef NTSTATUS (__stdcall *pfnNtQueryInformationThread)
82 | (
83 | __in HANDLE ThreadHandle,
84 | __in THREADINFOCLASS ThreadInformationClass,
85 | __out_bcount(ThreadInformationLength) PVOID ThreadInformation,
86 | __in ULONG ThreadInformationLength,
87 | __out_opt PULONG ReturnLength
88 | );
89 |
90 | pfnNtQueryInformationThread NtQueryInformationThread;
91 |
92 | //**************************************************************************************
93 | DWORD MyGetThreadId
94 | //**************************************************************************************
95 | (
96 | _In_ HANDLE Thread
97 | )
98 | {
99 | THREAD_BASIC_INFORMATION ThreadBasicInfo;
100 | THREADINFOCLASS ThreadInfoClass;
101 | HMODULE hModule;
102 |
103 | if (Thread == NULL)
104 | return 0;
105 |
106 | hModule = LoadLibrary("ntdll.dll");
107 | NtQueryInformationThread = (pfnNtQueryInformationThread) GetProcAddress(hModule, "NtQueryInformationThread");
108 | if (NtQueryInformationThread == NULL)
109 | return 0;
110 |
111 | ThreadInfoClass = ThreadBasicInformation;
112 | if (NtQueryInformationThread(Thread, ThreadInfoClass, &ThreadBasicInfo, sizeof(ThreadBasicInfo), NULL) != STATUS_SUCCESS)
113 | {
114 | FreeLibrary(hModule);
115 | return 0;
116 | }
117 |
118 | FreeLibrary(hModule);
119 |
120 | return (DWORD)(UINT_PTR)ThreadBasicInfo.ClientId.UniqueThread;
121 | }
122 |
--------------------------------------------------------------------------------
/CAPE/Scylla/ApiReader.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include