type
DWORDOfArray = Array of Cardinal;
ByteOfArray = array of byte;
function FindVale_Byte(dwProcessID, dwStartAddress, dwEndAddress : Cardinal; Value : Byte; ProgressSearching : TGauge): DWORDOfArray;
var
I, Len, iCount : Integer;
NumReadBytes : NativeUInt;
TempAddress, hProcess : Cardinal;
aResult : ByteOfArray;
ImageBase, ImageSize : Cardinal;
begin
iCount := 0;
SetLength(Result,iCount + 1);
Result[iCount] := 0;
if dwProcessID = 0 then Exit;
hProcess := OpenProcess(PROCESS_VM_READ,False,dwProcessID);
ImageBase := GetBaseAddress(dwProcessID,PWideChar(GetNameFromPID(dwProcessID)));
ImageSize := GetBaseSize(dwProcessID,PWideChar(GetNameFromPID(dwProcessID))) + ImageBase;
if dwStartAddress > dwEndAddress then
begin
TempAddress := dwEndAddress;
dwEndAddress := dwStartAddress;
dwStartAddress := TempAddress;
end;
if dwStartAddress < ImageBase then
dwStartAddress := ImageBase;
if dwEndAddress > ImageSize then
dwEndAddress := ImageSize;
Len := (dwEndAddress - dwStartAddress) + 1;
SetLength(aResult,Len);
ReadProcessMemory(hProcess,Pointer(dwStartAddress),aResult,Len,NumReadBytes);
ProgressSearching.MaxValue := NumReadBytes;
ProgressSearching.Progress := 0;
ProgressSearching.MinValue := ProgressSearching.Progress;
for I := 0 to NumReadBytes do
begin
if aResult[i] = Value then
begin
Inc(iCount);
SetLength(Result,iCount);
Result[iCount-1] := dwStartAddress + i;
end;
ProgressSearching.Progress := i;
end;
end;