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

  • Home
  • SEARCH
  • 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 6556985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:00:58+00:00 2026-05-25T13:00:58+00:00

We are using a third-party COM API from NET. Currently Visual Studio & presumably

  • 0

We are using a third-party COM API from NET. Currently Visual Studio & presumably TLBIMP is used to generate the Interop wrapper DLL.

The generated interface of one specific method provided to NET is not the one we’d prefer to use. Is it possible to change the COM interop code so that the method signature presented to NET is different? We can’t change the COM interfaces or TLB used because it’s third-party code.

The actual example is as follows:

The method in question is where one passes a cleartext password. The current code goes as follows:

  1. Our password handling returns a System.Security.SecureString (password is encrypted in memory).
  2. We marshal the SecureString to a BSTR (annoyingly cleartext but can be zeroed afterwards to reduce exposure).
  3. BSTR is converted to a System.String (Oops! This will be immutable, potentially never garbage collected, and keep the cleartext password around in memory).
  4. COM Interop function wrapping third-party library takes System.String & marshals it again to a BSTR.
  5. Third party COM API takes the BSTR and hopefully handles it in a vaguely secure way.

It is steps 2 & 3 I’d like to avoid. I can’t change the fact that the third party API is handling a cleartext password, but I’d like at least the code we have control over to minimise the presence of the cleartext in memory.

I’d like to change the signature of the NET method to take a SecureString instead of a String – NET can already marshal a SecureString to a BSTR, so the COM interop code could still present the same data to the actual COM API, but without the horrible step of creating a String. Can this be done?

  • 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-25T13:00:59+00:00Added an answer on May 25, 2026 at 1:00 pm

    Yes, but you need to write the code for the interop interface manually, and then you can of course change the type of the parameters as you like.

    I would probably start by creating the interop assembly using tlbimp. Then I would decompile it using Reflector and placing these sources in a separate class library project, modifying the interface as needed and use this assembly as the interop assembly.

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

Sidebar

Related Questions

I'm using a third-party COM library from C#. There are get/set methods that take
I'm using a COM object from a third party library that generates periodic events.
session.identify is a third party COM API that I call and have no access
I am using a third-party API (Spreadshirt's API) and in order to perform a
I want to send an encrypted and signed mail without using any third-party API.
I'm trying to connect to a third party application API using apache commons HTTP
When using third-party libraries such as jquery, yui-reset, swfobject and so on, do you
What is the simplest way (preferably without using third party frameworks) in objective c,
Is it possible in IE8 without using third party plugin like Java?
How can I detect keyboard event in C language without using third party libraries?

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.