//creates a list of accessible memory regions in VRAM (readable&&writable) private void CreateEntryPoints() { long helpMinimumAddress = (long)minimumAddress; RegionStructure region; MEMORY_BASIC_INFORMATION memoryInfo = new MEMORY_BASIC_INFORMATION(); List <RegionStructure> originalRegionList = new List <RegionStructure>(); while (helpMinimumAddress < maximum32BitAddress) { minimumAddress = new IntPtr(helpMinimumAddress); //receives basic memory information for a handle specified by OpenProcess (more info : MEMORY_BASIC_INFORMATION struct) VirtualQueryEx(targetHandle, minimumAddress, out memoryInfo, (uint)Marshal.SizeOf(memoryInfo)); if (memoryInfo.RegionSize < 0) //TODO: prüfen regionsize int oder uint | prüfen cast auf long oder int { break; } //checks regions for necessary ProtectionStatus to ReadAndWrite and for the needed MemoryType if (memoryInfo.Protect == AllocationProtectEnum.PAGE_READWRITE || memoryInfo.Protect == AllocationProtectEnum.PAGE_WRITECOMBINEPLUSREADWRITE && (memoryInfo.Type == TypeEnum.MEM_IMAGE || memoryInfo.Type == TypeEnum.MEM_PRIVATE)) { //adds regions to a List region = new RegionStructure(memoryInfo.BaseAddress, (int)memoryInfo.RegionSize); originalRegionList.Add(region); } helpMinimumAddress = (uint)memoryInfo.BaseAddress + memoryInfo.RegionSize; } SplitList(originalRegionList); }
public PointerStructure(uint address, RegionStructure regionStructure) { this.regionStructure = regionStructure; offsets = new List <uint>(); addresses = new List <uint> { address }; moduleName = "stack"; }
private void WriteToList(byte[] memoryBuffer, RegionStructure regionStructure) { bool done = false; while (!done) { Monitor.TryEnter(MemoryDump, ref done); //waits until no other thread is accessing the list if (done) { MemoryDump.Add(new MemoryStructure(regionStructure.RegionBeginning, regionStructure.RegionSize, memoryBuffer)); Monitor.Exit(MemoryDump); } } }