toizy-mr / delphi-detours-library

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

library fails on MS application verifier basic-test (Win32) #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Usings VCL.Styles.Hooks in a delphi application uses delphi-detours-library. 
The application fails then basic MS application verifier tests.
Problematic seems to be the uninstall of hooks. This is the error:

=======================================
VERIFIER STOP 0000060C: pid 0x1550: Incorrect Size parameter for VirtualFree 
(MEM_RELEASE) operation. 

    0000002A : Incorrect size used by the application.
    00000000 : Expected correct size (0).
    00000000 : Not used.
    00000000 : Not used.

=======================================

Debugger stops in DDetours in InterceptRemove:

    OrgProcAccess := SetMemPermission(P, Sb, PAGE_EXECUTE_READWRITE);
    CopyInstruction(Q^, P^, Sb);
    SetMemPermission(P, Sb, OrgProcAccess);
    Result := VirtualFree(PSave, TrampolineSize, MEM_RELEASE); // +++ problematic call here +++

Steps to reproduce:

Create empty Win32 Delphi application. Add VCL.Styles.Hooks tio uses clause, 
this integrates DDetours.
Add program in Application verifier and choose basic tests. start application 
in Delphi debugger and watch debug breakpoint while closing the application 
(break in InterceptRemove)

Best regards
Dirk

Original issue reported on code.google.com by dirk.car...@gmail.com on 8 Dec 2014 at 9:17

Attachments:

GoogleCodeExporter commented 9 years ago
Workaround:

    Result := VirtualFree(PSave, 0, MEM_RELEASE);

See documentation of VirtualFree (dwSize must be zero):

MEM_RELEASE
0x8000

Releases the specified region of pages. After this operation, the pages are in 
the free state.

If you specify this value, dwSize must be 0 (zero), and lpAddress must point to 
the base address returned by the VirtualAlloc function when the region is 
reserved. The function fails if either of these conditions is not met.

Original comment by dirk.car...@gmail.com on 8 Dec 2014 at 9:20

GoogleCodeExporter commented 9 years ago
Hi Dirk

This issue is related to the v1 of the library.
I no longer provide support for the old version (v1) .
You need to update to the new version (v2).

BTW , your issue is similar to this one:
https://code.google.com/p/delphi-detours-library/issues/detail?id=8

Regards
Mahdi.

Original comment by ismspi...@gmail.com on 8 Dec 2014 at 3:09

GoogleCodeExporter commented 9 years ago
Hi Mahdi,

thanks for your explaination! I use VCL.Styles which uses a deprecated version 
V1?
I'll report it to the VCL.Styles project..

Best regards
Dirk

Original comment by dirk.car...@gmail.com on 9 Dec 2014 at 8:51