jeudi 19 janvier 2017

Smart pointer for virtual memory

I'm writing a program that interact a lot with virtual memory, which means that I can't hold some pointer to this memory, because all the reads/writes needs to be thru dedicated functions: bool ReadMemory(handle, address, size, buffer) bool WriteMemory(handle, address, size, buffer)

I'm trying to implement class that allows me do the following:

typedef struct _user_details
{
    char[256] name;
    uint32_t id;
    bool is_reg;
} user_details;

VirtualMemory<user_details> bob(memory_handle, address);
printf("user id:%d", bob->id);

I tried to implement it with: T* operator->() But the problem in this way is that I need in the end of the day copy the whole strut locally, and I want to prevent this (I work with huge struts)

Any ideas?

Aucun commentaire:

Enregistrer un commentaire