magicxor / delphi-detours-library

Automatically exported from code.google.com/p/delphi-detours-library
1 stars 0 forks source link

Integer overflow when range checking is on #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What is the function that you are trying to hook ?

Using Vcl.Styles.Hooks: user32.dll > GetSysColor

What is the expected output? What do you see instead?

When hook is being created: EIntOverflow.

What version of the product are you using? On what operating system? Which
architecture x86 or x64 ?

Delphi XE3, Win8, x86.

Please provide any additional information below.

The version of DDetours included in VCL Style Utils was used.

Original issue reported on code.google.com by ritsa...@continuit.nl on 10 Jun 2014 at 3:56

GoogleCodeExporter commented 9 years ago
NB: Adding a {$Q-} solves the problem:

  { Calculate the offset between the InterceptProc variable and the jmp instruction (target proc) . }
  {$Q-} // <<<<< this one.
{$IFDEF CPUX64}
  Offset := Int64(UINT64(PSave) - UINT64(P) - SizeOfJmp); // Sign Extended ! .
{$ELSE}
  Offset := Integer(UINT(InterceptProc) - UINT(P) - SizeOfJmp); // Sign Extended ! .
{$ENDIF}

Original comment by ritsa...@continuit.nl on 10 Jun 2014 at 3:58

GoogleCodeExporter commented 9 years ago
Hi,
Can you please include a sample demo to repdoduce the issue ?

Original comment by ismspi...@gmail.com on 13 Jun 2014 at 7:31

GoogleCodeExporter commented 9 years ago
Here is a project. Also a print screen with the watch values where you can see 
that the subtraction of two UINT-casted values yield a negative number (and 
hence an EIntOverflow when that is enabled in the project options).

Original comment by ritsa...@continuit.nl on 13 Jun 2014 at 9:50

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you .
The issue is fixed now .

Original comment by ismspi...@gmail.com on 15 Jun 2014 at 12:13

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r29.

Original comment by ismspi...@gmail.com on 15 Jun 2014 at 12:13