Sporadic Issues Exporting from Macros with Corel 2023

At my company we have a macro that exports a bitmap into .psd format and opens it in Photoshop. This has worked perfectly in previous versions of CorelDraw but we are now getting sporadic issues where the export fails. Sometimes there is an unhelpful HRESULT error and sometimes the app hangs. In either case, the file is locked to the CorelDraw process and we need to kill the process in order to delete the file. Sometimes CorelDraw crashes.

I did see this question: https://community.coreldraw.com/sdk/f/coreldraw-and-corel-designer-api/65792/corel-2022-exportbitmap-to-psd-is-broken-in-net/312227#312227

However, we are now on the latest version and there has been no improvement to the situation.

As I said, this was never an issue in past versions so I do not believe our macro code is causing the issues, but here is the macro code:

Dim strPSDfile As String
strPSDfile = "C:\Temp\" & docCorelDraw.FileName & "_edit.psd"

Dim ExportImage As ExportFilter
Set ExportImage = docCorelDraw.ExportBitmap(strPSDfile, cdrPSD, cdrSelection, cdrRGBColorImage, objImage.Bitmap.SizeWidth, objImage.Bitmap.SizeHeight, objImage.Bitmap.ResolutionX, objImage.Bitmap.ResolutionY, , , True)

ExportImage.Finish ' This call fails sometimes
  • Reproduced and looked at a Crash Dump in Windbg. I'm adding the analysis here:

    PROCESS_NAME:  CorelDRW.exe
    
    ERROR_CODE: (NTSTATUS) 0xc0000409 - The system detected an overrun of a stack-based buffer in this application. This overrun could potentially allow a malicious user to gain control of this application.
    
    EXCEPTION_CODE_STR:  c0000409
    
    EXCEPTION_PARAMETER1:  0000000000000007
    
    FAULTING_THREAD:  0000105c
    
    STACK_TEXT:  
    00000011`948fb250 00007ffc`6432ed39     : 00007ffc`00000003 00000011`00000003 00000000`00000000 00000000`00000000 : ucrtbase!abort+0x4e
    00000011`948fb280 00007ffc`30166e8a     : 00000011`948fb4e8 00000011`948fb4f8 00000011`948fb370 00000000`00000000 : ucrtbase!terminate+0x29
    00000011`948fb2b0 00007ffc`301680fa     : 00000011`948fb290 00007ffc`301b4408 ffffffff`ffffffff 00007ffc`30164350 : CrlConfig!StabilityFramework::CrashHandler::InitializeSignalHandlers+0xfa
    00000011`948fb2e0 00007ffc`6432e5f5     : 00000000`00000016 00000011`00000000 00000000`00000000 00000000`00000000 : CrlConfig!StabilityFramework::CrashHandler::InitializeSignalHandlers+0x136a
    00000011`948fb4e0 00007ffc`6432f601     : 00007ffc`301b4401 0000013f`00000000 00000000`00000000 00000011`948fb590 : ucrtbase!raise+0x1e5
    00000011`948fb560 00007ffc`6432ed39     : 00007ffc`00000003 00000011`00000003 00000000`00000000 00000000`00000000 : ucrtbase!abort+0x31
    00000011`948fb590 00007ffc`30166e8a     : 00000000`00000000 00000000`00000000 00000011`00000000 00000000`00000000 : ucrtbase!terminate+0x29
    00000011`948fb5c0 00007ffc`3016779a     : 00000011`948fb5a0 00007ffc`301b4408 0000013f`97f868e0 00000000`00000000 : CrlConfig!StabilityFramework::CrashHandler::InitializeSignalHandlers+0xfa
    00000011`948fb5f0 00007ffc`64314090     : 00000000`00000000 0000013f`00000001 00000000`00000000 00000000`00000000 : CrlConfig!StabilityFramework::CrashHandler::InitializeSignalHandlers+0xa0a
    00000011`948fb7f0 00007ff6`23ff8d14     : 00007ff6`23ffd344 00000011`948ff7d0 00000000`00000000 00000000`00000000 : ucrtbase!_seh_filter_exe+0x38d40
    00000011`948fb820 00007ffc`40cbf0e0     : 00000011`948fb950 00000000`00000000 00000011`948fb908 00000011`948fbef0 : CorelDRW+0x8d14
    00000011`948fb850 00007ffc`66773dff     : 00000000`00000000 00000011`948fbe50 00000011`948fc530 00000011`948fc530 : VCRUNTIME140!__C_specific_handler+0xa0
    00000011`948fb8c0 00007ffc`666ee456     : 00000011`948fc530 00007ff6`23ff0000 00007ff6`23ff75c2 00007ff6`24003534 : ntdll!RtlpExecuteHandlerForException+0xf
    00000011`948fb8f0 00007ffc`66772dee     : 00000000`00000087 00000011`948fc0e0 40180000`00000000 00007ffb`d1c56291 : ntdll!RtlDispatchException+0x286
    00000011`948fc040 00007ffb`c02fc3a8     : 0000013f`8a40a100 0000013f`00000000 00000000`00000000 00000000`00000000 : ntdll!KiUserExceptionDispatch+0x2e
    00000011`948fcdb0 00007ffb`c0316509     : 00000000`00000000 0000013f`8a5d7710 0000013f`00000033 0000013f`8a3a1d40 : IEPSD+0xc3a8
    00000011`948fcde0 00007ffb`c030c7ac     : 00000011`948fd0a0 00000000`00000001 0000013f`aef25838 00000000`00000001 : IEPSD!FilterEntry+0x9dc9
    00000011`948fce10 00007ffb`e9e07622     : 0000013f`aef25838 00000000`00000001 00000000`00000001 0000013f`89ff7090 : IEPSD!FilterEntry+0x6c
    00000011`948fce40 00007ffb`e9dffd31     : 0000013f`aef25838 00000000`00000007 0000013f`aef25838 0000013f`aef25838 : CDRFLT!FILTERDATALIST::FreeData+0x1682
    00000011`948fce80 00007ffb`d58a57ea     : 0000013f`89ff7090 0000013f`aef25838 c130adaf`00000033 0000013f`00000001 : CDRFLT!FLTCLIPDATA::SetFM+0x15c1
    00000011`948fcf80 00007ffb`d58a553e     : 00000000`00000001 0000013f`8a5d7710 00000011`948fd090 00007ffb`d5bcfd00 : VGCore!CDrawlibDoc::Clone+0x36b64a
    00000011`948fd000 00007ffb`e9e2186a     : 0000013f`8a0eee20 00000000`00000040 00000000`00000001 00000011`00000000 : VGCore!CDrawlibDoc::Clone+0x36b39e
    00000011`948fd030 0000013f`98038c1b     : 0000013f`8a0eee20 00000000`00000003 00000000`00000007 00007ffb`c2f31239 : CDRFLT!CPreviewBuilder::GenerateFilterManagerPreviewInternal+0x2a9a
    00000011`948fd070 00000000`00000000     : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : 0x0000013f`98038c1b
    
    
    SYMBOL_NAME:  ucrtbase!abort+4e
    
    MODULE_NAME: ucrtbase
    
    IMAGE_NAME:  ucrtbase.dll
    
    STACK_COMMAND:  dt ntdll!LdrpLastDllInitializer BaseDllName ; dt ntdll!LdrpFailureData ; ~0s ; .cxr ; kb
    
    FAILURE_BUCKET_ID:  FAIL_FAST_FATAL_APP_EXIT_c0000409_ucrtbase.dll!abort
    
    OS_VERSION:  10.0.22621.1
    
    BUILDLAB_STR:  ni_release
    
    OSPLATFORM_TYPE:  x64
    
    OSNAME:  Windows 10
    
    IMAGE_VERSION:  10.0.22621.608
    
    FAILURE_ID_HASH:  {e31753ac-c98a-8055-3663-47e707543d20}

  • what version of vc++ on this machine?

  • Have you tried other export procedures? ExportEx  or  Export ?