Highlighted
Super Contributor.
Super Contributor.
3480 views

Call "GetDeviceCaps" gives in extend 9.0.0 Memory acces violation

[Migrated content. Thread originally posted on 06 February 2011]

When subprogram running with runtime 9.0.0 and compiled with -x -Cr -Di -Ga -Za -Zl -Z80 there is no problem.
When compiled with -x -Cr -Di -Ga -Za -Zl there is coming a Memory acces violation on the statement Call "GetDeviceCaps", see the source lines below.
How can tell me what I have to change.

ACCEPT    SYSTEM-INFORMATION        FROM  SYSTEM-INFO.
IF        OS-IS-WIN-NT
          MOVE "C:\WINDOWS\SYSTEM32\" TO MAP-SYSTEEM
    ELSE
          MOVE "C:\WINDOWS\SYSTEM\" TO MAP-SYSTEEM
END-IF.                   
MOVE      SPACES TO             MAP-SYSTEEM-NAAM-DLL.
STRING    MAP-SYSTEEM DELIMITED BY SPACE
          "GDI32.DLL" DELIMITED BY SIZE
                                    INTO      MAP-SYSTEEM-NAAM-DLL.
SET       ENVIRONMENT      "DLL-CONVENTION" TO 1.
CALL      MAP-SYSTEEM-NAAM-DLL
          ON EXCEPTION            GO TO   R4117
END-CALL.
SET       HORZSIZE                    TO  TRUE.
CALL      "GetDeviceCaps"          USING
                                    BY VALUE         H-ACU-SPOOLER-DC
                                    BY VALUE         FUNCTIONNUMBER
                                             GIVING  WS-HORZSIZE.
SET       VERTSIZE                    TO  TRUE.
CALL      "GetDeviceCaps"          USING
                                    BY VALUE         H-ACU-SPOOLER-DC
                                    BY VALUE         FUNCTIONNUMBER
                                             GIVING  WS-VERTSIZE.


       77  H-ACU-SPOOLER-DC         PIC 9(9) COMP-5 EXTERNAL.

       77  MAP-SYSTEEM              PIC X(20).
       77  MAP-SYSTEEM-NAAM-DLL     PIC X(35).

       77  FUNCTIONNUMBER           PIC 9(9) COMP-5.
      *              Horizontal size in millimeters
           88 HORZSIZE              VALUE 04.
      *              Vertical size in millimeters
           88 VERTSIZE              VALUE 06.
      *              Horizontal size in pixels
           88 LOGPIXELSX            VALUE 88.
      *              Logical pixels/inch Y wise
           88 LOGPIXELSY            VALUE 90.
      *              Physical width in device units
           88 PHYSICALWIDTH         VALUE 110.
      *              Physical height in device units
           88 PHYSICALHEIGHT        VALUE 111.
      *              Physical printable area x wise
           88 PHYSICALOFFSETX       VALUE 112.
      *              Physical printable area y wise
           88 PHYSICALOFFSETY       VALUE 113.

       77  WS-HORZSIZE              PIC 9(9) COMP-5.
       77  WS-VERTSIZE              PIC 9(9) COMP-5.
0 Likes
15 Replies
Highlighted
Absent Member.
Absent Member.

RE: Call "GetDeviceCaps" gives in extend 9.0.0 Memory acces violation

I tried to reproduce this, but I did not get a memory access violation. Do you use a 64bit runtime?

Here is what I tried:

       IDENTIFICATION  DIVISION.

       PROGRAM-ID.     Jaap.
       ENVIRONMENT DIVISION.
       SPECIAL-NAMES.

       INPUT-OUTPUT SECTION.
       FILE-CONTROL.

           SELECT PRINT-FILE
           ASSIGN TO PRINT "-P SPOOLER".

       DATA DIVISION.
       FILE SECTION.

       FD  PRINT-FILE.
       01  PRINT-REC.
           03 FILLER       PIC X(80).

       WORKING-STORAGE SECTION.
       77  H-ACU-SPOOLER-DC         PIC 9(9) COMP-5 EXTERNAL.       
       77  FUNCTIONNUMBER           PIC 9(9) COMP-5.
           88 HORZSIZE              VALUE 04.     
           88 VERTSIZE              VALUE 06.
       77  WS-HORZSIZE              PIC 9(9) COMP-5.
       77  WS-VERTSIZE              PIC 9(9) COMP-5.


       PROCEDURE DIVISION.
       MAIN-LOGIC.

           call    "gdi32.dll@WINAPI".
           OPEN    OUTPUT           PRINT-FILE.
           SET     HORZSIZE         TO  TRUE.
           CALL    "GetDeviceCaps"  USING
                   BY VALUE         H-ACU-SPOOLER-DC
                   BY VALUE         FUNCTIONNUMBER
                   GIVING           WS-HORZSIZE.
           SET     VERTSIZE         TO  TRUE.
           CALL    "GetDeviceCaps"  USING
                   BY VALUE         H-ACU-SPOOLER-DC
                   BY VALUE         FUNCTIONNUMBER
                   GIVING  WS-VERTSIZE.
           CANCEL  "GDI32.DLL".
           CLOSE   PRINT-FILE.

       MAIN-LOGIC-END.

           STOP    RUN.
0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: Call "GetDeviceCaps" gives in extend 9.0.0 Memory acces violation

Cheesle, on my Windows7 the about of AcuBench gives me: Configuration: WIN32, IA-32.

Further I used @WINAPI and still I get the memory acces violation.
I shall now take your sources lines and going to look what happens then.
0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: Call "GetDeviceCaps" gives in extend 9.0.0 Memory acces violation

I toke the source lines you posted and still I get the memory acces violation. Wich options you use when compiling?
0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

RE: Call "GetDeviceCaps" gives in extend 9.0.0 Memory acces violation

Check your runtime directory to make sure that the CLRControlModule.dll file is there. I was getting memory access violations with the 9.0 runtime when calling some DLL's and Word and Excel with COM. We had the beta of 9.0 and it worked fine with the beta. Then I noticed that the beta had the CLRControlModule.dll file in the runtime directory but when I installed the released 9.0 runtime, the file was not in the directory. It appears that the installer is not installing the CLRControlModule.dll with the runtime when you choose to just install the runtime during the installation. I manually copied the file from the distribution CD and my memory access violation errors went away.
0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: Call "GetDeviceCaps" gives in extend 9.0.0 Memory acces violation

I copied the CLRControlModule.dll to the bin directory and still get the memory acces violation.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Call "GetDeviceCaps" gives in extend 9.0.0 Memory acces violation

Jaap, I tried with both you compiler options and none at all. Still executed without issues.

Are you trying this from Acubench? That might have impact. Could you try to use the compiler (ccbl32.exe) and runtime (wrun32.exe) direct from the command line rather than using Acubench. Just to see if it makes a difference.

Also, if you could check the version numbers of the compiler and runtime using the command prompt and -vv rather than Acubench.

This, just to try to narrow down what we are looking at, it should of course work from Acubench as well.
0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: Call "GetDeviceCaps" gives in extend 9.0.0 Memory acces violation

Cheesle, I use AcuBench only to compile. For running/debugging I have a shortcut on my desktop.
When wrun32 -vv the result is Serial number 348673. Licensed for 1 user(s). AcuServer client. Vision version 5 file system (interface v8.1.2). XML version expat_2.0.0 file system (interface v8.1.2). Copyright(C) 1985-2009 Micro Focus (IP) Ltd. Configuration: WIN32, IA-32.
I shall try they ccbl32 from the prompt but I think you can try quicker the AcuBench than I the prompt because I never use it in that way.
By the way, I tested your example in the AcuBench.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Call "GetDeviceCaps" gives in extend 9.0.0 Memory acces violation

Jaap,
I don't have a 8.1.2 version at hand, I suggest you provide the sample to technical support and ask them if they can reproduce the problem with version 8.l.2.
0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: Call "GetDeviceCaps" gives in extend 9.0.0 Memory acces violation

Cheesle, sorry that I mislead you.

I deinstalled the completed versie 8.1.2 now.
and the result of wrun32 -vv from the prompt is now:
Micro Focus extend runtime version 9.0.0. Serial number 348673. Licensed for 1 user(s). AcuServer client. Vision version 5 file system (interface v9.0.0). XML version expat_2.0.0 file system (interface v9.0.0). Copyright(C) 1985-2010 Micro Focus (IP) Ltd. Configuration: WIN32, IA-32.
I did again the test with your source in the AcuBench but still memory acces violation.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Call "GetDeviceCaps" gives in extend 9.0.0 Memory acces violation

Jaap,

as I said, I am unable to reproduce this, you will have to talk with technical support.
0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: Call "GetDeviceCaps" gives in extend 9.0.0 Memory acces violation

Cheesle, you give me a piece of the solution because I found out that when compiled with the prompt ccbl32 -ga file1.cbl and then running with wrun32 -d file1 there is not coming a memory acces violation.
So I dropped it by support.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.