Advertisement
Guest User

Untitled

a guest
Dec 4th, 2011
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 16.64 KB | None | 0 0
  1. Index: byteinterpreter.pas
  2. ===================================================================
  3. --- byteinterpreter.pas (wersja 1131)
  4. +++ byteinterpreter.pas (kopia robocza)
  5. @@ -253,10 +253,13 @@
  6.            if ReadProcessMemory(processhandle,pointer(address),buf2,customtype.bytesize,x) then
  7.            begin
  8.              try
  9. +              x:=customtype.ConvertDataToInteger(buf2);
  10.                if showashexadecimal then
  11. -                result:=inttohex(customtype.ConvertDataToInteger(buf2),8)
  12. +                result:=inttohex(x,8)
  13.                else
  14. -                result:=IntToStr(customtype.ConvertDataToInteger(buf2));
  15. +                if not customtype.treatAsFloat then
  16. +                result:=IntToStr(x)
  17. +                else result:=FloatToStr(psingle(@x)^);
  18.              except //no need to flood the user with meaningless error messages
  19.              end;
  20.            end;
  21. Index: CustomTypeHandler.pas
  22. ===================================================================
  23. --- CustomTypeHandler.pas   (wersja 1131)
  24. +++ CustomTypeHandler.pas   (kopia robocza)
  25. @@ -40,6 +40,8 @@
  26.    public
  27.  
  28.      bytesize: integer;
  29. +    fastscanalignsize: integer;
  30. +    treatAsFloat: boolean;
  31.  
  32.      function ConvertDataToInteger(data: pointer): integer;
  33.      function ConvertDataToIntegerLua(data: pbytearray): integer;
  34. @@ -273,6 +275,8 @@
  35.    newroutine, oldroutine: TConversionRoutine;
  36.    newreverseroutine, oldreverseroutine: TReverseConversionRoutine;
  37.    newbytesize, oldbytesize: integer;
  38. +  newtreatAsFloat, oldtreatAsFloat: boolean;
  39. +  newfastscanalignsize, oldfastscanalignsize: integer;
  40.    oldallocarray: TCEAllocArray;
  41.  begin
  42.    oldname:=fname;
  43. @@ -280,6 +284,12 @@
  44.    oldroutine:=routine;
  45.    oldreverseroutine:=reverseroutine;
  46.    oldbytesize:=bytesize;
  47. +
  48. +  oldtreatAsFloat:=treatAsFloat;
  49. +  oldfastscanalignsize:=fastscanalignsize;
  50. +  newtreatAsFloat:=false;
  51. +  newfastscanalignsize:=0;
  52. +
  53.    setlength(oldallocarray, length(c));
  54.    for i:=0 to length(c)-1 do
  55.      oldallocarray[i]:=c[i];
  56. @@ -308,6 +318,12 @@
  57.              if uppercase(c[i].varname)='BYTESIZE' then
  58.                newbytesize:=pinteger(c[i].address)^;
  59.  
  60. +            if uppercase(c[i].varname)='TREATASFLOAT' then
  61. +              newtreatAsFloat:=true;
  62. +
  63. +            if uppercase(c[i].varname)='FASTSCANALIGNSIZE' then
  64. +              newfastscanalignsize:=pinteger(c[i].address)^;
  65. +
  66.              if uppercase(c[i].varname)='CONVERTBACKROUTINE' then
  67.                newreverseroutine:=pointer(c[i].address);
  68.            end;
  69. @@ -317,6 +333,9 @@
  70.  
  71.            //and now set the new values
  72.            bytesize:=newbytesize;
  73. +          if bytesize=0 then raise exception.create(rsBytesizeIs0);
  74. +          treatAsFloat:=newtreatAsFloat;
  75. +          if (newfastscanalignsize>0) then fastscanalignsize:=newfastscanalignsize else fastscanalignsize:=bytesize;
  76.            routine:=newroutine;
  77.            reverseroutine:=newreverseroutine;
  78.  
  79. @@ -418,6 +437,8 @@
  80.        routine:=oldroutine;
  81.        reverseroutine:=oldreverseroutine;
  82.        bytesize:=oldbytesize;
  83. +      treatAsFloat:=oldtreatAsFloat;
  84. +      fastscanalignsize:=oldfastscanalignsize;
  85.  
  86.        setlength(c,length(oldallocarray));
  87.        for i:=0 to length(oldallocarray)-1 do
  88. @@ -546,6 +567,8 @@
  89.      ct.lua_valuetobytesfunctionid:=f_valuetobytes;
  90.      ct.name:=typename;
  91.      ct.bytesize:=bytecount;
  92. +    ct.treatAsFloat:=false;
  93. +    ct.fastscanalignsize:=bytecount;
  94.  
  95.      customtypes.Add(ct);
  96.      mainform.RefreshCustomTypes;
  97. @@ -580,6 +603,8 @@
  98.      ct.fCustomTypeType:=cttAutoAssembler;
  99.      ct.name:=typename;
  100.      ct.bytesize:=bytecount;
  101. +    ct.treatAsFloat:=false;
  102. +    ct.fastscanalignsize:=bytecount;
  103.  
  104.  
  105.  
  106. Index: foundlisthelper.pas
  107. ===================================================================
  108. --- foundlisthelper.pas (wersja 1131)
  109. +++ foundlisthelper.pas (kopia robocza)
  110. @@ -618,12 +618,16 @@
  111.                if customType<>nil then
  112.                begin
  113.                  read3:=customType.ConvertDataToInteger(tempbuf);
  114. -                if hexadecimal then
  115. -                  valuelist[j]:=IntToHex(read3,8)
  116. -                else if signed then
  117. -                  valuelist[j]:=IntToStr(Longint(read3))
  118. +                if not customtype.treatAsFloat then
  119. +                  begin
  120. +                    if hexadecimal then valuelist[j]:=IntToHex(read3,8)
  121. +                    else if signed then valuelist[j]:=IntToStr(Longint(read3))
  122. +                    else                valuelist[j]:=IntToStr(read3);
  123. +                  end
  124.                  else
  125. -                  valuelist[j]:=IntToStr(read3);
  126. +                  valuelist[j]:=FloatToStr(psingle(@read3)^);
  127. +
  128. +
  129.                end else valuelist[j]:=rsUndefinedError;
  130.  
  131.              end
  132. Index: MainUnit.pas
  133. ===================================================================
  134. --- MainUnit.pas    (wersja 1131)
  135. +++ MainUnit.pas    (kopia robocza)
  136. @@ -1855,6 +1855,16 @@
  137.        //byte-word-dword--8bytes-float-double-all   - custom
  138.      begin
  139.  
  140. +      if (vartype.ItemIndex >= 10) then // CUSTOM.
  141. +      begin
  142. +        if vartype.Items.Objects[vartype.ItemIndex] <> nil then
  143. +          if TCustomType(vartype.Items.Objects[vartype.ItemIndex]).treatAsFloat then
  144. +            if oldindex = 0 then
  145. +              begin
  146. +              floatvis := True; //Because, I need visible pnlfloat (for float custom type)
  147. +              hexvis := False;  
  148. +              end;
  149. +      end else
  150.        if vartype.ItemIndex in [5, 6, 9] then //float/all
  151.        begin
  152.          if oldindex = 0 then
  153. @@ -4959,7 +4969,7 @@
  154.        //custom type is ALWAYS the decider
  155.        if rbFsmAligned.Checked then
  156.          edtAlignment.Text := inttohex(
  157. -          TCustomType(vartype.Items.Objects[vartype.ItemIndex]).bytesize, 1);
  158. +          TCustomType(vartype.Items.Objects[vartype.ItemIndex]).fastscanalignsize, 1);
  159.      end
  160.      else
  161.      begin
  162. @@ -4988,7 +4998,7 @@
  163.      exact_value, Advanced_Scan]) then
  164.      scantype.ItemIndex := 0;
  165.  
  166. -  if (newvartype in [1, 2, 3, 4, 9]) or (newvartype >= 10) then //if normal or custom type
  167. +  if (newvartype in [1, 2, 3, 4, 9]) then //if normal
  168.    begin
  169.      casevis := False;
  170.      hexvis := True;
  171. @@ -4996,6 +5006,21 @@
  172.      cbHexadecimal.Enabled := newscan.Enabled;
  173.      //cbHexadecimal.Checked:=hexstateForIntTypes;
  174.    end
  175. +  else if (newvartype >= 10) then //if custom type
  176. +  begin
  177. +    casevis := False;
  178. +    hexvis := True;
  179. +    scanvalue.MaxLength := 0;
  180. +    cbHexadecimal.Enabled := newscan.Enabled;
  181. +    //cbHexadecimal.Checked:=hexstateForIntTypes;
  182. +    if vartype.Items.Objects[vartype.ItemIndex] <> nil then
  183. +      if TCustomType(vartype.Items.Objects[vartype.ItemIndex]).treatAsFloat then // float custom type ??
  184. +      begin
  185. +        casevis := False;
  186. +        cbHexadecimal.Checked := False;
  187. +        cbHexadecimal.Enabled := False;
  188. +      end;
  189. +  end
  190.    else
  191.      case newvartype of
  192.        0:
  193. Index: MemoryRecordUnit.pas
  194. ===================================================================
  195. --- MemoryRecordUnit.pas    (wersja 1131)
  196. +++ MemoryRecordUnit.pas    (kopia robocza)
  197. @@ -1352,7 +1352,13 @@
  198.        begin
  199.          if customtype<>nil then
  200.          begin
  201. -          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));
  202. +          br:=customtype.ConvertDataToInteger(buf);
  203. +          if not customtype.treatAsFloat then
  204. +            begin
  205. +            if showashex then result:=inttohex(br,8) else if showassigned then result:=inttostr(integer(br)) else result:=inttostr(br);
  206. +            end
  207. +          else
  208. +            if showashex then result:=inttohex(br,8) else result:=FloatToStr(psingle(@br)^);
  209.          end
  210.          else
  211.            result:='error';
  212. @@ -1429,6 +1435,7 @@
  213.    bufsize: integer;
  214.    x: dword;
  215.    i: integer;
  216. +  tmpSingle: single;
  217.    pb: pbyte absolute buf;
  218.    pba: pbytearray absolute buf;
  219.    pw: pword absolute buf;
  220. @@ -1533,7 +1540,26 @@
  221.        if not check then exit;
  222.  
  223.      case VarType of
  224. -      vtCustom: if customtype<>nil then customtype.ConvertIntegerToData(strtoint(currentValue), pdw);
  225. +      vtCustom: if customtype<>nil then
  226. +                  if not customtype.treatAsFloat then
  227. +                    customtype.ConvertIntegerToData(strtoint(currentValue), pdw)
  228. +                  else
  229. +                  begin
  230. +                    try
  231. +                      fs:=DefaultFormatSettings;
  232. +                      tmpSingle:=StrToFloat(currentValue, fs);
  233. +                      customtype.ConvertIntegerToData(pdword(@tmpSingle)^, pdw);
  234. +                    except
  235. +                      if fs.DecimalSeparator='.' then
  236. +                        fs.DecimalSeparator:=','
  237. +                      else
  238. +                      fs.DecimalSeparator:='.';
  239. +
  240. +                      tmpSingle:=StrToFloat(currentValue, fs);
  241. +                      customtype.ConvertIntegerToData(pdword(@tmpSingle)^, pdw);
  242. +                    end;
  243. +                  end;
  244. +
  245.        vtByte: pb^:=strtoint(currentValue);
  246.        vtWord: pw^:=strtoint(currentValue);
  247.        vtDword: pdw^:=strtoint(currentValue);
  248. Index: memscan.pas
  249. ===================================================================
  250. --- memscan.pas (wersja 1131)
  251. +++ memscan.pas (kopia robocza)
  252. @@ -1291,58 +1291,132 @@
  253.  
  254.  //--------------\/custom\/
  255.  function TScanner.CustomExact(newvalue,oldvalue: pointer): boolean;
  256. +var dw_new: dword;
  257.  begin
  258. -  result:=customType.ConvertDataToInteger(newvalue)=integer(value);
  259. +  dw_new:=customType.ConvertDataToInteger(newvalue);
  260. +  if not customType.treatAsFloat then
  261. +    result:=dw_new=integer(value)
  262. +  else
  263. +    begin
  264. +    result:=false;
  265. +      case roundingtype of
  266. +        rtRounded:
  267. +          result:=(RoundTo(psingle(@dw_new)^,-floataccuracy)=svalue);
  268. +      
  269. +        rtExtremerounded:
  270. +          result:=(psingle(@dw_new)^>minsvalue) and (psingle(@dw_new)^<maxsvalue);
  271. +      
  272. +        rtTruncated:
  273. +          result:=(psingle(@dw_new)^>=svalue) and (psingle(@dw_new)^<maxsvalue);
  274. +      end;
  275. +   end;  
  276.  end;
  277.  
  278.  function TScanner.CustomBetween(newvalue,oldvalue: pointer): boolean;
  279. +var dw_new: dword;
  280.  begin
  281. -  result:=(customType.ConvertDataToInteger(newvalue)>=integer(value)) and (customType.ConvertDataToInteger(newvalue)<=integer(value2));
  282. +  dw_new:=customType.ConvertDataToInteger(newvalue);
  283. +  if not customType.treatAsFloat then
  284. +    result:=(dw_new>=integer(value)) and (dw_new<=integer(value2))
  285. +  else
  286. +    result:=(psingle(@dw_new)^>=svalue) and (psingle(@dw_new)^<=svalue2)
  287.  end;
  288.  
  289.  function TScanner.CustomBetweenPercentage(newvalue,oldvalue: pointer):boolean;
  290. +var dw_new, dw_old: dword;
  291.  begin
  292. -  result:=(customType.ConvertDataToInteger(newvalue)>trunc(customType.ConvertDataToInteger(oldvalue)*svalue)) and (customType.ConvertDataToInteger(newvalue)<=trunc(customType.ConvertDataToInteger(oldvalue)*svalue2));
  293. +  dw_new:=customType.ConvertDataToInteger(newvalue);
  294. +  dw_old:=customType.ConvertDataToInteger(oldvalue);
  295. +  if not customType.treatAsFloat then
  296. +    result:=(dw_new>trunc(dw_old*svalue)) and (dw_new<=trunc(dw_old*svalue2))
  297. +  else
  298. +    result:=(psingle(@dw_new)^>psingle(@dw_old)^*svalue) and (psingle(@dw_new)^<=psingle(@dw_old)^*svalue2);
  299.  end;
  300.  
  301.  function TScanner.CustomBiggerThan(newvalue,oldvalue: pointer): boolean;
  302. +var dw_new: dword;
  303.  begin
  304. -  result:=customType.ConvertDataToInteger(newvalue)>integer(value);
  305. +  dw_new:=customType.ConvertDataToInteger(newvalue);
  306. +  if not customType.treatAsFloat then
  307. +    result:=dw_new>integer(value)
  308. +  else
  309. +    result:=psingle(@dw_new)^>svalue;
  310.  end;
  311.  
  312.  function TScanner.CustomSmallerThan(newvalue,oldvalue: pointer): boolean;
  313. +var dw_new: dword;
  314.  begin
  315. -  result:=customType.ConvertDataToInteger(newvalue)<integer(value);
  316. +  dw_new:=customType.ConvertDataToInteger(newvalue);
  317. +  if not customType.treatAsFloat then
  318. +    result:=dw_new<integer(value)
  319. +  else
  320. +    result:=psingle(@dw_new)^<=svalue;
  321.  end;
  322.  
  323.  function TScanner.CustomIncreasedValue(newvalue,oldvalue: pointer): boolean;
  324. +var dw_new, dw_old: dword;
  325.  begin
  326. -  result:=customType.ConvertDataToInteger(newvalue)>customType.ConvertDataToInteger(oldvalue);
  327. +  dw_new:=customType.ConvertDataToInteger(newvalue);
  328. +  dw_old:=customType.ConvertDataToInteger(oldvalue);
  329. +  if not customType.treatAsFloat then
  330. +    result:=dw_new>dw_old
  331. +  else
  332. +    result:=psingle(@dw_new)^>psingle(@dw_old)^;
  333.  end;
  334.  
  335.  function TScanner.CustomIncreasedValueBy(newvalue,oldvalue: pointer): boolean;
  336. +var dw_new, dw_old: dword;
  337.  begin
  338. -  result:=customType.ConvertDataToInteger(newvalue)=customType.ConvertDataToInteger(oldvalue)+dword(value);
  339. +  dw_new:=customType.ConvertDataToInteger(newvalue);
  340. +  dw_old:=customType.ConvertDataToInteger(oldvalue);
  341. +  if not customType.treatAsFloat then
  342. +    result:=dw_new=dw_old+dword(value)
  343. +  else
  344. +    result:=RoundTo(psingle(@dw_new)^,-floataccuracy)=RoundTo(psingle(@dw_old)^+svalue,-floataccuracy);
  345.  end;
  346.  
  347.  function TScanner.CustomIncreasedValueByPercentage(newvalue,oldvalue: pointer): boolean;
  348. +var dw_new, dw_old: dword;
  349.  begin
  350. -  result:=(customType.ConvertDataToInteger(newvalue)>trunc(customType.ConvertDataToInteger(oldvalue)+pdword(oldvalue)^*svalue)) and (customType.ConvertDataToInteger(newvalue)<trunc(customType.ConvertDataToInteger(oldvalue)+customType.ConvertDataToInteger(oldvalue)*svalue2));
  351. +  dw_new:=customType.ConvertDataToInteger(newvalue);
  352. +  dw_old:=customType.ConvertDataToInteger(oldvalue);
  353. +  if not customType.treatAsFloat then
  354. +    result:=(dw_new>trunc(dw_old+dw_old*svalue)) and (dw_new<trunc(dw_old+dw_old*svalue2))
  355. +  else
  356. +    result:=(psingle(@dw_new)^>psingle(@dw_old)^+psingle(@dw_old)^*svalue) and (psingle(@dw_new)^<psingle(@dw_old)^+psingle(@dw_old)^*svalue2);    
  357.  end;
  358.  
  359.  function TScanner.CustomDecreasedValue(newvalue,oldvalue: pointer): boolean;
  360. +var dw_new, dw_old: dword;
  361.  begin
  362. -  result:=customType.ConvertDataToInteger(newvalue)<customType.ConvertDataToInteger(oldvalue);
  363. +  dw_new:=customType.ConvertDataToInteger(newvalue);
  364. +  dw_old:=customType.ConvertDataToInteger(oldvalue);
  365. +  if not customType.treatAsFloat then
  366. +    result:=dw_new<dw_old
  367. +  else
  368. +    result:=psingle(@dw_new)^<psingle(@dw_old)^;
  369.  end;
  370.  
  371.  function TScanner.CustomDecreasedValueBy(newvalue,oldvalue: pointer): boolean;
  372. +var dw_new, dw_old: dword;
  373.  begin
  374. -  result:=customType.ConvertDataToInteger(newvalue)=customType.ConvertDataToInteger(oldvalue)-dword(value);
  375. +  dw_new:=customType.ConvertDataToInteger(newvalue);
  376. +  dw_old:=customType.ConvertDataToInteger(oldvalue);
  377. +  if not customType.treatAsFloat then
  378. +    result:=dw_new=dw_old-dword(value)
  379. +  else
  380. +    result:=RoundTo(psingle(@dw_new)^,-floataccuracy)=RoundTo(psingle(@dw_old)^-svalue,-floataccuracy);
  381.  end;
  382.  
  383.  function TScanner.CustomDecreasedValueByPercentage(newvalue,oldvalue: pointer): boolean;
  384. +var dw_new, dw_old: dword;
  385.  begin
  386. -  result:=(customType.ConvertDataToInteger(newvalue)>trunc(customType.ConvertDataToInteger(oldvalue)-customType.ConvertDataToInteger(oldvalue)*svalue2)) and (customType.ConvertDataToInteger(newvalue)<trunc(customType.ConvertDataToInteger(oldvalue)-customType.ConvertDataToInteger(oldvalue)*svalue));
  387. +  dw_new:=customType.ConvertDataToInteger(newvalue);
  388. +  dw_old:=customType.ConvertDataToInteger(oldvalue);
  389. +  if not customType.treatAsFloat then
  390. +    result:=(dw_new>trunc(dw_old-dw_old*svalue2)) and (dw_new<trunc(dw_old-dw_old*svalue))
  391. +  else
  392. +    result:=(psingle(@dw_new)^>psingle(@dw_old)^-psingle(@dw_old)^*svalue2) and (psingle(@dw_new)^<psingle(@dw_old)^-psingle(@dw_old)^*svalue);    
  393.  end;
  394.  
  395.  function TScanner.CustomChanged(newvalue,oldvalue: pointer): boolean;
  396. @@ -1652,7 +1726,13 @@
  397.  {
  398.  Generic routine for storing results. Use as last resort. E.g custom scans
  399.  }
  400. +var dw: dword;
  401.  begin
  402. +  if ((variableType = vtCustom) and customType.treatAsFloat) then
  403. +    begin
  404. +    dw:=customType.ConvertDataToInteger(oldvalue);
  405. +    if (isnan(psingle(@dw)^) or IsInfinite(psingle(@dw)^)) then exit;
  406. +    end;
  407.    //save varsize
  408.    PPtrUintArray(CurrentAddressBuffer)[found]:=address;
  409.    copyMemory(pointer(ptruint(CurrentFoundBuffer)+ptruint(variablesize*found)),oldvalue,variablesize);
  410. @@ -2630,7 +2710,7 @@
  411.        end;
  412.      end;
  413.  
  414. -    if percentage or (variableType in [vtsingle,vtDouble,vtAll]) then
  415. +    if percentage or (variableType in [vtsingle,vtDouble,vtAll]) or ((variableType = vtCustom) and customType.treatAsFloat) then
  416.      begin
  417.        try
  418.          dvalue:=strtofloat(scanvalue1,FloatSettings);
  419. @@ -3592,7 +3672,7 @@
  420.      vtCustom:
  421.      begin
  422.        variablesize:=customtype.bytesize;
  423. -      fastscanalignsize:=min(4, variablesize);
  424. +      fastscanalignsize:=customtype.fastscanalignsize;
  425.      end;
  426.  
  427.    end;
  428.  
  429.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement