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 6923733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:34:26+00:00 2026-05-27T10:34:26+00:00

We have an out of process COM application that was written in C++ that

  • 0

We have an out of process COM application that was written in C++ that implements are networking protocol. When a packet of data is received a callback is invoked into the application that registered for the packet.

The callback interface is defined as such:

[helpstring("method MessageHandler")] HRESULT MessageHandler([in,size_is(nSize)] char * szBuf, int nSize, DWORD dwTransCode, DWORD dwSenderID, BSTR bstrFromIP);

Using this in C++ has not been an issue. We now have a case where we have a C++/CLI application that needs to receive callbacks. After hacking away until the compiler was happy, I arrived at the following implementation:

ref class MessageHandlerClass : public MessageRouterCallback
    {
    public:
        virtual void MessageHandler(signed char %buffer, int size, unsigned int msgId, unsigned int fromId, System::String^ fromIp)
        {
            switch (msgId)
            {
            case MaintenanceMsgs::maintenance_event_message::ID:
                {
                    SomeStructure msg;
                    myHandler->HandleMaintenanceEvent(&msg);
                }
            }
        }

This is my first foray into C++/CLI.

First Question: What they heck does ‘%’ mean in ‘signed char %buffer’?

Second Question: I can place a breakpoint and see that the callback is getting called. I can look at the ‘buffer’ argument in the memory debugger and it contains the data I expect. I have been VERY unsuccessful at pulling that data out and placing it into the variable ‘msg’. I know I can’t do a cast like in C++, but every example I’ve been tried (Mostly InteropServices::Marshal and some pin_ptr stuff) doesn’t seem to get me anywhere.

SomeStructure is declared in a header file and is included by both the C++ and the C++/CLI application. SomeStructure contains 2 unsigned shorts followed by three character arrays.

Any direction on where to go from here would be greatly appreciated.

  • 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-27T10:34:27+00:00Added an answer on May 27, 2026 at 10:34 am

    Ok. It just ‘clicked’… So I’ll answer my own question here.

    First Question: What they heck does ‘%’ mean in ‘signed char %buffer’?

    The ‘%’ just means its ‘tracked’ and will be garbage collected, or at least that’s what I think it means 🙂

    Second Question: How to marshal.

    First I had to get to the ‘internal pointer’ and C++/CLI provides the & operator for that. Then I was able to simply memcpy the data over.

    pin_ptr<signed char> p = &buffer;
    
    MaintenanceMsgs::maintenance_event_message msg;
    memcpy((void*)&msg, (void*)p, sizeof(msg));
    
    myHandler->HandleMaintenanceEvent(&msg);
    

    Is this safe?

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

Sidebar

Related Questions

We have an application that uses several out of process COM objects for various
Say we have an existing process (or application) that calls a COM object from
I have a console app that performs a lengthy process. I am printing out
In my web application there is a process that queries data from all over
I have read about storing session state out-of-process but still in memory by configuring
I'm trying to figure out how XSLT process namespace prefixes and have following example:
I have found out that I am doing WPF wrong and frustratingly must overhaul
I have checked out now a local working copy of a codebase that lives
I currently have a .NET class library written in C# that exposes its functionaility
We're developing an application that will have a plug-in architecture to allow consumers of

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.