I want to make a list of pointers to locations that contain a specific value in the process memory of another process. The value can be short, int, long, string, bool, or something else.
My idea is to use Generics for this. I have one problem with creating it, how can I tell the compiler what type it needs to convert byte array to?
This is what I did:
public List<IntPtr> ScanProccessFor<T>(T ItemToScanFor)
{
List<IntPtr> Output = new List<IntPtr>();
IntPtr StartOffset = SelectedProcess.MainModule.BaseAddress;
int ScanSize = SelectedProcess.MainModule.ModuleMemorySize;
for (int i = 0; i < ScanSize; i++)
if (ReadMemory(SelectedProcess, StartOffset + i, (UInt16)Marshal.SizeOf(ItemToScanFor)) == ItemToScanFor)
Output.Insert(Output.Count,StartOffset + i);
return Output;
}
How can I tell the compiler that it needs to convert byte [] to enter T?
source
share