Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
DWrightson Absent Member.
Absent Member.
1065 views

LoadLibrary/GetProcAddress

Hello,

I'm trying to resolve some issues with DLL conflicts by using the Windows API calls to LoadLibrary, and GetProcAddress. I'm able to get a handle to the instance of the DLL by using LoadLibrary, but cannot get a handle to the internal processes of the DLL using GetProcAddress. I'm also wondering how I'm going to call these methods once I get the pointer? Does anyone have any experience using these functions?

      01  DLL-INSTANCE             PIC X(4) COMP-N.

      01  PROCESS-POINTER          PIC X(4) COMP-N.

             CALL "LoadLibraryA@WINAPI"

                  USING BY REFERENCE "C:\CSL\CloudSyncLib.dll",

                  RETURNING DLL-INSTANCE

             CALL "GetProcAddress@WINAPI"

                  USING BY REFERENCE DLL-INSTANCE

                        BY REFERENCE "CSL_InitInterface"

                  RETURNING PROCESS-POINTER

Thanks

Dave

0 Likes
1 Reply
Micro Focus Expert
Micro Focus Expert

RE: LoadLibrary/GetProcAddress

A terminological note: "the internal processes of the DLL" is the wrong nomenclature (and confused me when I initially read your question). The "proc" in GetProcAddress is short for "procedure", not process.

GetProcAddress wants the module handle (DLL-INSTANCE) passed by value, not by reference. And the strings passed to LoadLibrary and GetProcAddress should be nul-terminated (C-style strings with a low-value character at the end). Also, you should be calling GetProcAddressA, since you're passing an ASCII string.

I'm not an extend user (must install it and play around with it one of these days), so I don't know if it uses the z"xxx" syntax for nul-terminated strings. Maybe it knows to nul-terminate the literal string it passes to the function?

In any case, I'd suggest trying:

  CALL "GetProcAddressA@WINAPI" USING BY VALUE DLL-INSTANCE BY REFERENCE "CSL_InitInterface" RETURNING PROCESS-POINTER

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.