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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:47:18+00:00 2026-05-22T23:47:18+00:00

Is this list correct? unsigned int(c) -> uint(c#) const char*(c) -> String(c#) unsigned int*(c)

  • 0

Is this list correct?

unsigned int(c) -> uint(c#)
const char*(c) -> String(c#)
unsigned int*(c) -> uint[](c#)
unsigned char*(c) -> byte[](c#)

I think there’s a mistake here because with these 4 parameters for native function I have PInvokeStackImbalance.

C function is:

bool something
  (unsigned char *a,
   unsigned int a_length,
   unsigned char *b,
   unsigned int *b_length);

PInvoke is:

[DllImport(@"lib.dll", EntryPoint = "something")]<br>
public static extern bool something(
    byte[] a,
    uint a_length,
    byte[] b,
    uint[] b_length);
  • 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-22T23:47:19+00:00Added an answer on May 22, 2026 at 11:47 pm

    First, PInvoke.net is your friend.

    Second, You conversions are correct except that you should use a StringBuilder for functions that take a char* as a buffer to fill ([in out]).

    Your stack imbalance may be due to the use of different calling conventions. The default calling convention for C# is __stdcall, but your C function is probably __cdecl. If that is the case you will need to add the CallingConvention to your DLLImport attribute.

    EDIT: Also, as Groo pointed out, if the pointer arguments in your C function are actually just pointers to unsigned int (for example, as opposed to expecting an array of int) then you should use ref uint instead of an int[].

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

Sidebar

Related Questions

I have a collection like this List<int> {1,15,17,8,3}; how to get a flat string
Is this list-initialization of an array of unknown size valid in C++0x? int main()
I frequently find myself writing code like this: List<int> list = new List<int> {
I know I can loop through a list of strings like this: list<string>::iterator Iterator;
I have a question about LinkedList<> . There are properties of this list First
In the past I have done this: List<Item> _Items = GetItems(); int _CountDown =
Hello I have this list that i am working on. When i move the
Part of a programme builds this list, [u'1 x Affinity for war', u'1 x
I am trying to do this: List<Parent> test = new List<Child>(); The complete code
I have a list of strings similar to this list: tags = ('apples', 'apricots',

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.