Skip to content

Commit a325992

Browse files
Copilotxusheng6
andcommitted
Add TTDHeapEvent structure and core API implementation
Co-authored-by: xusheng6 <94503187+xusheng6@users.noreply.github.com>
1 parent 30cf89d commit a325992

File tree

8 files changed

+542
-0
lines changed

8 files changed

+542
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,4 @@ api/python/__pycache__
6969
# TTD files
7070
*.run
7171
*.idx
72+
__pycache__/

api/debuggerapi.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,31 @@ namespace BinaryNinjaDebuggerAPI {
517517
TTDCallEvent() : threadId(0), uniqueThreadId(0), functionAddress(0), returnAddress(0), returnValue(0), hasReturnValue(false) {}
518518
};
519519

520+
struct TTDHeapEvent
521+
{
522+
std::string eventType; // Event type (always "Heap" for TTD.Heap objects)
523+
std::string action; // Heap action: Alloc, ReAlloc, Free, Create, Protect, Lock, Unlock, Destroy
524+
uint32_t threadId; // OS thread ID of thread that made the heap call
525+
uint32_t uniqueThreadId; // Unique ID for the thread across the trace
526+
uint64_t heap; // Handle for the Win32 heap
527+
uint64_t address; // Address of the allocated object (if applicable)
528+
uint64_t previousAddress; // Address before reallocation (for ReAlloc)
529+
uint64_t size; // Size of allocated object (if applicable)
530+
uint64_t baseAddress; // Base address of allocated object (if applicable)
531+
uint64_t flags; // Heap API flags (meaning depends on API)
532+
uint64_t result; // Result of heap API call (non-zero = success)
533+
uint64_t reserveSize; // Amount of memory to reserve (for Create)
534+
uint64_t commitSize; // Initial committed size (for Create)
535+
uint64_t makeReadOnly; // Non-zero = make heap read-only (for Protect)
536+
std::vector<std::string> parameters; // Raw parameters from the heap call
537+
TTDPosition timeStart; // Position when heap operation started
538+
TTDPosition timeEnd; // Position when heap operation ended
539+
540+
TTDHeapEvent() : threadId(0), uniqueThreadId(0), heap(0), address(0), previousAddress(0),
541+
size(0), baseAddress(0), flags(0), result(0), reserveSize(0),
542+
commitSize(0), makeReadOnly(0) {}
543+
};
544+
520545

521546
typedef BNDebugAdapterConnectionStatus DebugAdapterConnectionStatus;
522547
typedef BNDebugAdapterTargetStatus DebugAdapterTargetStatus;
@@ -687,6 +712,7 @@ namespace BinaryNinjaDebuggerAPI {
687712
// TTD Memory Analysis Methods
688713
std::vector<TTDMemoryEvent> GetTTDMemoryAccessForAddress(uint64_t address, uint64_t size, TTDMemoryAccessType accessType = TTDMemoryRead);
689714
std::vector<TTDCallEvent> GetTTDCallsForSymbols(const std::string& symbols, uint64_t startReturnAddress = 0, uint64_t endReturnAddress = 0);
715+
std::vector<TTDHeapEvent> GetTTDHeapObjects();
690716
TTDPosition GetCurrentTTDPosition();
691717
bool SetTTDPosition(const TTDPosition& position);
692718

0 commit comments

Comments
 (0)