Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6817131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:00:41+00:00 2026-05-26T21:00:41+00:00

I downloaded the ATI AGS (ATI GPU Services) Libary, and am attempting to retrieve

  • 0

I downloaded the ATI AGS (ATI GPU Services) Libary, and am attempting to retrieve some basic driver information using this API, from C#. The ATI AGS library is available for download from here:

http://developer.amd.com/gpu/ags/Pages/default.aspx

I wrote a little bit of C# code to pull driver information from the GPU using the AGS API, but I’m having some trouble calling the unmanaged method. I’ve tried all sorts of different permutations of DllImportAttribute parameters, to no avail. I’m getting either a MarshalDirectiveException or a pInvokeStackImbalance.

I’m pretty sure that this is all due to an incorrect P/Invoke signature, but I have exhausted my knowledge of this API.

By the way, as an aside, you’ll see that I’m using the 32-bit DLL, and I seem to be getting farther with it, but when I use the 64-bit DLL, I get a BadImageFormatException.

Here is the code that I’m using:

    [DllImport(
            "atiags.dll"
            , PreserveSig=false
            , ExactSpelling=true
            , ThrowOnUnmappableChar=true
            , CharSet=CharSet.Unicode
            , EntryPoint="agsDriverGetVersionInfo"
    )]
    public static extern void agsDriverGetVersionInfo(
        [MarshalAs(UnmanagedType.Struct)]
        out agsDriverVersionInfoStruct DriverInfo
    );

    public static agsDriverVersionInfoStruct GetAgsDriverVersion()
    {
       agsDriverVersionInfoStruct DriverInfo = new agsDriverVersionInfoStruct();
       agsDriverGetVersionInfo(out DriverInfo);
    }

    public struct agsDriverVersionInfoStruct
    {
        [MarshalAs(UnmanagedType.LPTStr)]
        public string strDriverVersion;
        [MarshalAs(UnmanagedType.LPStr)]
        public string strCatalystVersion;
        [MarshalAs(UnmanagedType.LPStr)]
        public string strCatalystWebLink;
    }

Any ideas?

Edit: Here is the definition of the ATIAGSDriverGetVersionInfo() function in ati_ags.h. According to the ATI AGS documentation (a PDF included in the download), it says to define _ATI_AGS_USE_DLL, so I added this line at the top of my C# class code file:

Documentation Quote

Determine if AGS functionality will be accessed through a dll or static lib. If the dll option is chosen, make sure to define _ATI_AGS_USE_DLL in your project properties. If the static lib option is chosen, no special token needs to be defined.

__inline AGSReturnCode ATIAGSDriverGetVersionInfo( AGSDriverVersionInfoStruct *lpDriverVersionInfo )
{
AGSReturnCode iReturnValue = AGS_SUCCESS;

// Validate params
if ( NULL == lpDriverVersionInfo )
{
    return AGS_FAILURE;
}

#ifdef _ATI_AGS_USE_DLL
// Load the lib
HINSTANCE lib = NULL;
lib = LoadLibrary(TEXT("atiags.dll"));
if (NULL == lib)
{
    lib = LoadLibrary(TEXT("atiags64.dll"));
    if (NULL == lib)
    {
        return AGS_FAILURE;     
    }
}

// Get the function pointer
AGSDRIVERGETVERSIONINFO agsDriverGetVersionInfo = NULL;
agsDriverGetVersionInfo = (AGSDRIVERGETVERSIONINFO)GetProcAddress(lib, "agsDriverGetVersionInfo");
if (NULL == agsDriverGetVersionInfo)
{
    FreeLibrary(lib);
    return AGS_FAILURE;
}
#endif // _ATI_AGS_USE_DLL

// Get the number of GPUs
iReturnValue = agsDriverGetVersionInfo( lpDriverVersionInfo );

#ifdef _ATI_AGS_USE_DLL
// Free the lib
FreeLibrary(lib);
#endif // _ATI_AGS_USE_DLL

return iReturnValue;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:00:41+00:00Added an answer on May 26, 2026 at 9:00 pm

    This does the trick for me…

    public enum AGSReturnCode
    {
        AGS_ERROR_MISSING_DLL = -2,
        AGS_ERROR_LEGACY_DRIVER = -1,
        AGS_FAILURE = 0,
        AGS_SUCCESS = 1
    }
    
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
    public struct AGSDriverVersionInfoStruct
    {
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
        public string strDriverVersion;
    
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
        public string strCatalystVersion;
    
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
        public string strCatalystWebLink;
    }
    
    public static class AGSharp
    {
        [DllImport("atiags.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "agsDriverGetVersionInfo")]
        public static extern AGSReturnCode agsDriverGetVersionInfo(out AGSDriverVersionInfoStruct driver_info);
    }
    

    … seems like the wrong calling convention was causing troubles (like Richard pointed out already)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just downloaded AMD-APP-SDK-v2.5-RC2-lnx32 , why i got this: GPU not found. , when i
I downloaded this vimrc file. It contains entries for mapping comma seperated keys to
I downloaded a program implemented in Java (in this case, http://julian.togelius.com/mariocompetition2009/index.php ). I first
I downloaded HTTP::Daemon::SSL for Strawberry Perl 5.10 from CPAN and ran this example: use
I downloaded FileHelpers from nuget but I am not sure if this feature does
Downloaded the WCF REST Template from this location. The default response format is XML,
I downloaded a binary file that was compiled (a C program) using GCC 4.4.4
Recently downloaded some code for a minor open-source project related to a small webgame
i downloaded a DBDateTimePicker which i am using to edit dates in a table,
I downloaded this endsWith function - String.prototype.endsWith = function(suffix) { return this.match(suffix+$) == suffix;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.