Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: byteinterpreter.pas
- ===================================================================
- --- byteinterpreter.pas (wersja 1131)
- +++ byteinterpreter.pas (kopia robocza)
- @@ -253,10 +253,13 @@
- if ReadProcessMemory(processhandle,pointer(address),buf2,customtype.bytesize,x) then
- begin
- try
- + x:=customtype.ConvertDataToInteger(buf2);
- if showashexadecimal then
- - result:=inttohex(customtype.ConvertDataToInteger(buf2),8)
- + result:=inttohex(x,8)
- else
- - result:=IntToStr(customtype.ConvertDataToInteger(buf2));
- + if not customtype.treatAsFloat then
- + result:=IntToStr(x)
- + else result:=FloatToStr(psingle(@x)^);
- except //no need to flood the user with meaningless error messages
- end;
- end;
- Index: CustomTypeHandler.pas
- ===================================================================
- --- CustomTypeHandler.pas (wersja 1131)
- +++ CustomTypeHandler.pas (kopia robocza)
- @@ -40,6 +40,8 @@
- public
- bytesize: integer;
- + fastscanalignsize: integer;
- + treatAsFloat: boolean;
- function ConvertDataToInteger(data: pointer): integer;
- function ConvertDataToIntegerLua(data: pbytearray): integer;
- @@ -273,6 +275,8 @@
- newroutine, oldroutine: TConversionRoutine;
- newreverseroutine, oldreverseroutine: TReverseConversionRoutine;
- newbytesize, oldbytesize: integer;
- + newtreatAsFloat, oldtreatAsFloat: boolean;
- + newfastscanalignsize, oldfastscanalignsize: integer;
- oldallocarray: TCEAllocArray;
- begin
- oldname:=fname;
- @@ -280,6 +284,12 @@
- oldroutine:=routine;
- oldreverseroutine:=reverseroutine;
- oldbytesize:=bytesize;
- +
- + oldtreatAsFloat:=treatAsFloat;
- + oldfastscanalignsize:=fastscanalignsize;
- + newtreatAsFloat:=false;
- + newfastscanalignsize:=0;
- +
- setlength(oldallocarray, length(c));
- for i:=0 to length(c)-1 do
- oldallocarray[i]:=c[i];
- @@ -308,6 +318,12 @@
- if uppercase(c[i].varname)='BYTESIZE' then
- newbytesize:=pinteger(c[i].address)^;
- + if uppercase(c[i].varname)='TREATASFLOAT' then
- + newtreatAsFloat:=true;
- +
- + if uppercase(c[i].varname)='FASTSCANALIGNSIZE' then
- + newfastscanalignsize:=pinteger(c[i].address)^;
- +
- if uppercase(c[i].varname)='CONVERTBACKROUTINE' then
- newreverseroutine:=pointer(c[i].address);
- end;
- @@ -317,6 +333,9 @@
- //and now set the new values
- bytesize:=newbytesize;
- + if bytesize=0 then raise exception.create(rsBytesizeIs0);
- + treatAsFloat:=newtreatAsFloat;
- + if (newfastscanalignsize>0) then fastscanalignsize:=newfastscanalignsize else fastscanalignsize:=bytesize;
- routine:=newroutine;
- reverseroutine:=newreverseroutine;
- @@ -418,6 +437,8 @@
- routine:=oldroutine;
- reverseroutine:=oldreverseroutine;
- bytesize:=oldbytesize;
- + treatAsFloat:=oldtreatAsFloat;
- + fastscanalignsize:=oldfastscanalignsize;
- setlength(c,length(oldallocarray));
- for i:=0 to length(oldallocarray)-1 do
- @@ -546,6 +567,8 @@
- ct.lua_valuetobytesfunctionid:=f_valuetobytes;
- ct.name:=typename;
- ct.bytesize:=bytecount;
- + ct.treatAsFloat:=false;
- + ct.fastscanalignsize:=bytecount;
- customtypes.Add(ct);
- mainform.RefreshCustomTypes;
- @@ -580,6 +603,8 @@
- ct.fCustomTypeType:=cttAutoAssembler;
- ct.name:=typename;
- ct.bytesize:=bytecount;
- + ct.treatAsFloat:=false;
- + ct.fastscanalignsize:=bytecount;
- Index: foundlisthelper.pas
- ===================================================================
- --- foundlisthelper.pas (wersja 1131)
- +++ foundlisthelper.pas (kopia robocza)
- @@ -618,12 +618,16 @@
- if customType<>nil then
- begin
- read3:=customType.ConvertDataToInteger(tempbuf);
- - if hexadecimal then
- - valuelist[j]:=IntToHex(read3,8)
- - else if signed then
- - valuelist[j]:=IntToStr(Longint(read3))
- + if not customtype.treatAsFloat then
- + begin
- + if hexadecimal then valuelist[j]:=IntToHex(read3,8)
- + else if signed then valuelist[j]:=IntToStr(Longint(read3))
- + else valuelist[j]:=IntToStr(read3);
- + end
- else
- - valuelist[j]:=IntToStr(read3);
- + valuelist[j]:=FloatToStr(psingle(@read3)^);
- +
- +
- end else valuelist[j]:=rsUndefinedError;
- end
- Index: MainUnit.pas
- ===================================================================
- --- MainUnit.pas (wersja 1131)
- +++ MainUnit.pas (kopia robocza)
- @@ -1855,6 +1855,16 @@
- //byte-word-dword--8bytes-float-double-all - custom
- begin
- + if (vartype.ItemIndex >= 10) then // CUSTOM.
- + begin
- + if vartype.Items.Objects[vartype.ItemIndex] <> nil then
- + if TCustomType(vartype.Items.Objects[vartype.ItemIndex]).treatAsFloat then
- + if oldindex = 0 then
- + begin
- + floatvis := True; //Because, I need visible pnlfloat (for float custom type)
- + hexvis := False;
- + end;
- + end else
- if vartype.ItemIndex in [5, 6, 9] then //float/all
- begin
- if oldindex = 0 then
- @@ -4959,7 +4969,7 @@
- //custom type is ALWAYS the decider
- if rbFsmAligned.Checked then
- edtAlignment.Text := inttohex(
- - TCustomType(vartype.Items.Objects[vartype.ItemIndex]).bytesize, 1);
- + TCustomType(vartype.Items.Objects[vartype.ItemIndex]).fastscanalignsize, 1);
- end
- else
- begin
- @@ -4988,7 +4998,7 @@
- exact_value, Advanced_Scan]) then
- scantype.ItemIndex := 0;
- - if (newvartype in [1, 2, 3, 4, 9]) or (newvartype >= 10) then //if normal or custom type
- + if (newvartype in [1, 2, 3, 4, 9]) then //if normal
- begin
- casevis := False;
- hexvis := True;
- @@ -4996,6 +5006,21 @@
- cbHexadecimal.Enabled := newscan.Enabled;
- //cbHexadecimal.Checked:=hexstateForIntTypes;
- end
- + else if (newvartype >= 10) then //if custom type
- + begin
- + casevis := False;
- + hexvis := True;
- + scanvalue.MaxLength := 0;
- + cbHexadecimal.Enabled := newscan.Enabled;
- + //cbHexadecimal.Checked:=hexstateForIntTypes;
- + if vartype.Items.Objects[vartype.ItemIndex] <> nil then
- + if TCustomType(vartype.Items.Objects[vartype.ItemIndex]).treatAsFloat then // float custom type ??
- + begin
- + casevis := False;
- + cbHexadecimal.Checked := False;
- + cbHexadecimal.Enabled := False;
- + end;
- + end
- else
- case newvartype of
- 0:
- Index: MemoryRecordUnit.pas
- ===================================================================
- --- MemoryRecordUnit.pas (wersja 1131)
- +++ MemoryRecordUnit.pas (kopia robocza)
- @@ -1352,7 +1352,13 @@
- begin
- if customtype<>nil then
- begin
- - if showashex then result:=inttohex(customtype.ConvertDataToInteger(buf),8) else if showassigned then result:=inttostr(integer(customtype.ConvertDataToInteger(buf))) else result:=inttostr(customtype.ConvertDataToInteger(buf));
- + br:=customtype.ConvertDataToInteger(buf);
- + if not customtype.treatAsFloat then
- + begin
- + if showashex then result:=inttohex(br,8) else if showassigned then result:=inttostr(integer(br)) else result:=inttostr(br);
- + end
- + else
- + if showashex then result:=inttohex(br,8) else result:=FloatToStr(psingle(@br)^);
- end
- else
- result:='error';
- @@ -1429,6 +1435,7 @@
- bufsize: integer;
- x: dword;
- i: integer;
- + tmpSingle: single;
- pb: pbyte absolute buf;
- pba: pbytearray absolute buf;
- pw: pword absolute buf;
- @@ -1533,7 +1540,26 @@
- if not check then exit;
- case VarType of
- - vtCustom: if customtype<>nil then customtype.ConvertIntegerToData(strtoint(currentValue), pdw);
- + vtCustom: if customtype<>nil then
- + if not customtype.treatAsFloat then
- + customtype.ConvertIntegerToData(strtoint(currentValue), pdw)
- + else
- + begin
- + try
- + fs:=DefaultFormatSettings;
- + tmpSingle:=StrToFloat(currentValue, fs);
- + customtype.ConvertIntegerToData(pdword(@tmpSingle)^, pdw);
- + except
- + if fs.DecimalSeparator='.' then
- + fs.DecimalSeparator:=','
- + else
- + fs.DecimalSeparator:='.';
- +
- + tmpSingle:=StrToFloat(currentValue, fs);
- + customtype.ConvertIntegerToData(pdword(@tmpSingle)^, pdw);
- + end;
- + end;
- +
- vtByte: pb^:=strtoint(currentValue);
- vtWord: pw^:=strtoint(currentValue);
- vtDword: pdw^:=strtoint(currentValue);
- Index: memscan.pas
- ===================================================================
- --- memscan.pas (wersja 1131)
- +++ memscan.pas (kopia robocza)
- @@ -1291,58 +1291,132 @@
- //--------------\/custom\/
- function TScanner.CustomExact(newvalue,oldvalue: pointer): boolean;
- +var dw_new: dword;
- begin
- - result:=customType.ConvertDataToInteger(newvalue)=integer(value);
- + dw_new:=customType.ConvertDataToInteger(newvalue);
- + if not customType.treatAsFloat then
- + result:=dw_new=integer(value)
- + else
- + begin
- + result:=false;
- + case roundingtype of
- + rtRounded:
- + result:=(RoundTo(psingle(@dw_new)^,-floataccuracy)=svalue);
- +
- + rtExtremerounded:
- + result:=(psingle(@dw_new)^>minsvalue) and (psingle(@dw_new)^<maxsvalue);
- +
- + rtTruncated:
- + result:=(psingle(@dw_new)^>=svalue) and (psingle(@dw_new)^<maxsvalue);
- + end;
- + end;
- end;
- function TScanner.CustomBetween(newvalue,oldvalue: pointer): boolean;
- +var dw_new: dword;
- begin
- - result:=(customType.ConvertDataToInteger(newvalue)>=integer(value)) and (customType.ConvertDataToInteger(newvalue)<=integer(value2));
- + dw_new:=customType.ConvertDataToInteger(newvalue);
- + if not customType.treatAsFloat then
- + result:=(dw_new>=integer(value)) and (dw_new<=integer(value2))
- + else
- + result:=(psingle(@dw_new)^>=svalue) and (psingle(@dw_new)^<=svalue2)
- end;
- function TScanner.CustomBetweenPercentage(newvalue,oldvalue: pointer):boolean;
- +var dw_new, dw_old: dword;
- begin
- - result:=(customType.ConvertDataToInteger(newvalue)>trunc(customType.ConvertDataToInteger(oldvalue)*svalue)) and (customType.ConvertDataToInteger(newvalue)<=trunc(customType.ConvertDataToInteger(oldvalue)*svalue2));
- + dw_new:=customType.ConvertDataToInteger(newvalue);
- + dw_old:=customType.ConvertDataToInteger(oldvalue);
- + if not customType.treatAsFloat then
- + result:=(dw_new>trunc(dw_old*svalue)) and (dw_new<=trunc(dw_old*svalue2))
- + else
- + result:=(psingle(@dw_new)^>psingle(@dw_old)^*svalue) and (psingle(@dw_new)^<=psingle(@dw_old)^*svalue2);
- end;
- function TScanner.CustomBiggerThan(newvalue,oldvalue: pointer): boolean;
- +var dw_new: dword;
- begin
- - result:=customType.ConvertDataToInteger(newvalue)>integer(value);
- + dw_new:=customType.ConvertDataToInteger(newvalue);
- + if not customType.treatAsFloat then
- + result:=dw_new>integer(value)
- + else
- + result:=psingle(@dw_new)^>svalue;
- end;
- function TScanner.CustomSmallerThan(newvalue,oldvalue: pointer): boolean;
- +var dw_new: dword;
- begin
- - result:=customType.ConvertDataToInteger(newvalue)<integer(value);
- + dw_new:=customType.ConvertDataToInteger(newvalue);
- + if not customType.treatAsFloat then
- + result:=dw_new<integer(value)
- + else
- + result:=psingle(@dw_new)^<=svalue;
- end;
- function TScanner.CustomIncreasedValue(newvalue,oldvalue: pointer): boolean;
- +var dw_new, dw_old: dword;
- begin
- - result:=customType.ConvertDataToInteger(newvalue)>customType.ConvertDataToInteger(oldvalue);
- + dw_new:=customType.ConvertDataToInteger(newvalue);
- + dw_old:=customType.ConvertDataToInteger(oldvalue);
- + if not customType.treatAsFloat then
- + result:=dw_new>dw_old
- + else
- + result:=psingle(@dw_new)^>psingle(@dw_old)^;
- end;
- function TScanner.CustomIncreasedValueBy(newvalue,oldvalue: pointer): boolean;
- +var dw_new, dw_old: dword;
- begin
- - result:=customType.ConvertDataToInteger(newvalue)=customType.ConvertDataToInteger(oldvalue)+dword(value);
- + dw_new:=customType.ConvertDataToInteger(newvalue);
- + dw_old:=customType.ConvertDataToInteger(oldvalue);
- + if not customType.treatAsFloat then
- + result:=dw_new=dw_old+dword(value)
- + else
- + result:=RoundTo(psingle(@dw_new)^,-floataccuracy)=RoundTo(psingle(@dw_old)^+svalue,-floataccuracy);
- end;
- function TScanner.CustomIncreasedValueByPercentage(newvalue,oldvalue: pointer): boolean;
- +var dw_new, dw_old: dword;
- begin
- - result:=(customType.ConvertDataToInteger(newvalue)>trunc(customType.ConvertDataToInteger(oldvalue)+pdword(oldvalue)^*svalue)) and (customType.ConvertDataToInteger(newvalue)<trunc(customType.ConvertDataToInteger(oldvalue)+customType.ConvertDataToInteger(oldvalue)*svalue2));
- + dw_new:=customType.ConvertDataToInteger(newvalue);
- + dw_old:=customType.ConvertDataToInteger(oldvalue);
- + if not customType.treatAsFloat then
- + result:=(dw_new>trunc(dw_old+dw_old*svalue)) and (dw_new<trunc(dw_old+dw_old*svalue2))
- + else
- + result:=(psingle(@dw_new)^>psingle(@dw_old)^+psingle(@dw_old)^*svalue) and (psingle(@dw_new)^<psingle(@dw_old)^+psingle(@dw_old)^*svalue2);
- end;
- function TScanner.CustomDecreasedValue(newvalue,oldvalue: pointer): boolean;
- +var dw_new, dw_old: dword;
- begin
- - result:=customType.ConvertDataToInteger(newvalue)<customType.ConvertDataToInteger(oldvalue);
- + dw_new:=customType.ConvertDataToInteger(newvalue);
- + dw_old:=customType.ConvertDataToInteger(oldvalue);
- + if not customType.treatAsFloat then
- + result:=dw_new<dw_old
- + else
- + result:=psingle(@dw_new)^<psingle(@dw_old)^;
- end;
- function TScanner.CustomDecreasedValueBy(newvalue,oldvalue: pointer): boolean;
- +var dw_new, dw_old: dword;
- begin
- - result:=customType.ConvertDataToInteger(newvalue)=customType.ConvertDataToInteger(oldvalue)-dword(value);
- + dw_new:=customType.ConvertDataToInteger(newvalue);
- + dw_old:=customType.ConvertDataToInteger(oldvalue);
- + if not customType.treatAsFloat then
- + result:=dw_new=dw_old-dword(value)
- + else
- + result:=RoundTo(psingle(@dw_new)^,-floataccuracy)=RoundTo(psingle(@dw_old)^-svalue,-floataccuracy);
- end;
- function TScanner.CustomDecreasedValueByPercentage(newvalue,oldvalue: pointer): boolean;
- +var dw_new, dw_old: dword;
- begin
- - result:=(customType.ConvertDataToInteger(newvalue)>trunc(customType.ConvertDataToInteger(oldvalue)-customType.ConvertDataToInteger(oldvalue)*svalue2)) and (customType.ConvertDataToInteger(newvalue)<trunc(customType.ConvertDataToInteger(oldvalue)-customType.ConvertDataToInteger(oldvalue)*svalue));
- + dw_new:=customType.ConvertDataToInteger(newvalue);
- + dw_old:=customType.ConvertDataToInteger(oldvalue);
- + if not customType.treatAsFloat then
- + result:=(dw_new>trunc(dw_old-dw_old*svalue2)) and (dw_new<trunc(dw_old-dw_old*svalue))
- + else
- + result:=(psingle(@dw_new)^>psingle(@dw_old)^-psingle(@dw_old)^*svalue2) and (psingle(@dw_new)^<psingle(@dw_old)^-psingle(@dw_old)^*svalue);
- end;
- function TScanner.CustomChanged(newvalue,oldvalue: pointer): boolean;
- @@ -1652,7 +1726,13 @@
- {
- Generic routine for storing results. Use as last resort. E.g custom scans
- }
- +var dw: dword;
- begin
- + if ((variableType = vtCustom) and customType.treatAsFloat) then
- + begin
- + dw:=customType.ConvertDataToInteger(oldvalue);
- + if (isnan(psingle(@dw)^) or IsInfinite(psingle(@dw)^)) then exit;
- + end;
- //save varsize
- PPtrUintArray(CurrentAddressBuffer)[found]:=address;
- copyMemory(pointer(ptruint(CurrentFoundBuffer)+ptruint(variablesize*found)),oldvalue,variablesize);
- @@ -2630,7 +2710,7 @@
- end;
- end;
- - if percentage or (variableType in [vtsingle,vtDouble,vtAll]) then
- + if percentage or (variableType in [vtsingle,vtDouble,vtAll]) or ((variableType = vtCustom) and customType.treatAsFloat) then
- begin
- try
- dvalue:=strtofloat(scanvalue1,FloatSettings);
- @@ -3592,7 +3672,7 @@
- vtCustom:
- begin
- variablesize:=customtype.bytesize;
- - fastscanalignsize:=min(4, variablesize);
- + fastscanalignsize:=customtype.fastscanalignsize;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement