-1

I have a really old (Photoshop SDK for Delphi from Centaurix Interactive) component set. We could recompile it and successfully use it in our application without any problem. But it has started to create an access violation when we upgrade to Delphi 11.

If I change the line for memory allocation from new(Stub) to Stub:= VirtualAlloc(nil, SizeOf(TStub), MEM_COMMIT, PAGE_EXECUTE_READWRITE)

it works at first, but it creates several 'memory problems' during further operations...
what's the reason for this issue, and is there any compiler directive or workaround to fix this?

Update : It is a Windows 32bit application and it could work with delphi 10.3 so it supports unicode.

Levent Üncü
  • 325
  • 2
  • 10
  • 5
    Nothing relevant changed. If `New` worked before, it should also work now. It is possible that your code has issue in other places and they never appeared just by luck. There is one change around records that could have some impact [Custom Managed Records](https://docwiki.embarcadero.com/RADStudio/Sydney/en/Custom_Managed_Records) In theory it shouldn't, but anything is possible, so I don't want to rule it out. Anyway, without [mcve] it is all just wild guessing. – Dalija Prasnikar Jun 03 '22 at 11:17
  • If you change new() by VirtualAlloc, then you must change corresponding Dispose() by VirtualFree(). – fpiette Jun 03 '22 at 13:13
  • @fpiette Yes, I did it, thank you for your answer anyway. – Levent Üncü Jun 03 '22 at 13:31
  • @DalijaPrasnikar, thank you for the answer again, I'm trying to isolate the issue and create a minimal example, if I can, I will share it here. – Levent Üncü Jun 03 '22 at 13:35
  • Since this component set is really old (how old exactly?) maybe there are some problems regarding the change of the string type to Unicode since Delphi 2009? – Delphi Coder Jun 03 '22 at 15:54
  • I would check if `TStub` still refer to the expected type. Maybe Delphi introduced a type named `TStub` that "hides" the type your component set expect. – Ken Bourassa Jun 03 '22 at 17:34
  • You should also provide information on which platform this is happening. Are we talking here about Windows or mobile environment? – SilverWarior Jun 04 '22 at 15:00

1 Answers1

0

I found the reason for this issue. it is not directly creating memory allocation but about creating a stub function for dll. Several PE security flags have been introduced in Delphi 11. you can find the details in Marco Cantu's blog. One of them, DEP flag, apparently prevents some memory operations. If I uncheck it, the application works pretty well.

Levent Üncü
  • 325
  • 2
  • 10