Repository navigation
Expand file tree
/
Copy pathThreadMapper.h
More file actions
54 lines (40 loc) · 1.57 KB
/
Copy pathThreadMapper.h
File metadata and controls
54 lines (40 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef THREAD_MAPPER_H
#define THREAD_MAPPER_H
#include <windows.h>
#include <vector>
#include <string>
#include <mutex>
// Structure to hold information about a thread
struct ThreadInfo {
DWORD threadID; // Thread ID
LPVOID threadStartAddress;
std::vector<unsigned char> cpuFunctionData;
};
// ThreadMapper class for mapping and transferring threads to GPU
class ThreadMapper {
public:
// Constructor
ThreadMapper();
// Destructor
~ThreadMapper();
// Attach to a process by name and return its handle
HANDLE AttachToProcess(const std::string& processName);
// Map all threads in the specified process
bool MapThreads(const std::string& processName);
// Retrieve thread-specific data (e.g., function data) and populate ThreadInfo
bool RetrieveThreadData(HANDLE hProcess, ThreadInfo& threadInfo);
// Transfer mapped thread data to the GPU
bool TransferCPUFunctionsToGPU();
// Accessor for GPU buffer
unsigned char* GetGPUBuffer() const;
// Accessor for GPU buffer size
size_t GetGPUBufferSize() const;
// Accessor for the number of mapped threads
int GetMappedThreadCount() const;
private:
std::vector<ThreadInfo> mappedThreads; // List of mapped threads
unsigned char* d_gpuBuffer; // GPU buffer for storing thread data
size_t bufferSize; // Size of the GPU buffer
std::mutex threadMutex; // Mutex for thread-safe access to mappedThreads
};
#endif // THREAD_MAPPER_H