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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:22:15+00:00 2026-05-30T09:22:15+00:00

I am verifying some code for x64 compatability. Previously I’ve used PInvoke.net, but I’ve

  • 0

I am verifying some code for x64 compatability. Previously I’ve used PInvoke.net, but I’ve found a few suspect declarations in terms of x64. So now, I:

  1. Look up the API reference such as MapViewOfFile
  2. Look up the windows data type definition
  3. Find the corresponding .NET type.

It’s step 3 where I’d like a definitive reference

As an example:

LPVOID WINAPI MapViewOfFile(
  __in  HANDLE hFileMappingObject,
  __in  DWORD dwDesiredAccess,
  __in  DWORD dwFileOffsetHigh,
  __in  DWORD dwFileOffsetLow,
  __in  SIZE_T dwNumberOfBytesToMap
);

Return value is LPVOID, which is defined as:

LPVOID

A pointer to any type.

This type is declared in WinDef.h as follows:

typedef void *LPVOID;

OK… so I guess that’s IntPtr or UIntPtr. This article has a table and suggests LPVOID should map to IntPtr or UIntPtr. OK.

Next, HANDLE.

HANDLE

A handle to an object.

This type is declared in WinNT.h as follows:

typedef PVOID HANDLE;

OK, HANDLE is a PVOID.

PVOID

A pointer to any type.

This type is declared in WinNT.h as follows:

typedef void *PVOID;

Hmmmm, sounds like IntPtr

Next, DWORD

DWORD

A 32-bit unsigned integer. The range is 0 through 4294967295 decimal.

This type is declared in WinDef.h as follows:

typedef unsigned long DWORD;

OK, unsigned long 0 to 4294967295, so that’s a uint and yet here it suggests Int32 or UInt32. Int32 won’t be able to store any value over 2,147,483,648. So that table is very suspect.

Finally, we have SIZE_T, which is defined as a ULONG_PTR which can be 32 or 64 bit signed long depending on the platform (definitions below). This article (and follow up) conclude you should use IntPtr, since it will handle the variable sizes.

SIZE_T

The maximum number of bytes to which a pointer can point. Use for a
count that must span the full range of a pointer.

This type is declared in BaseTsd.h as follows:

typedef ULONG_PTR SIZE_T;

ULONG_PTR

An unsigned LONG_PTR.

This type is declared in BaseTsd.h as follows:

#if defined(_WIN64)
 typedef unsigned __int64 ULONG_PTR;
#else
 typedef unsigned long ULONG_PTR;
#endif

LONG

A 32-bit signed integer. The range is –2147483648 through 2147483647
decimal.

This type is declared in WinNT.h as follows:

typedef long LONG;

INT64

A 64-bit signed integer. The range is –9223372036854775808 through
9223372036854775807 decimal.

This type is declared in BaseTsd.h as follows:

typedef signed __int64 INT64;

So, while I can look up the definition of every windows data type and then find a corresponding .NET datatype in terms of size, sign, and whether it works on both x86 and x64, it’s not ideal.

Is there a definitive reference out there (not pinvoke.net) with a good mapping table that’s up to date for x64?

  • 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-30T09:22:16+00:00Added an answer on May 30, 2026 at 9:22 am

    When mapping native datatypes to managed types, all that matters is size and consistency.

    The choice of signed vs. unsigned types only matters when interpreting the managed value.
    They’re both marshaled as raw bits.

    In most cases, you will just be passing values from one API method to another; in these cases, it doesn’t matter whether the type is signed or unsigned, as long as it’s the right size.

    Therefore, the general rule is that any pointer-sized value becomes IntPtr, and DWORD and QWORD become U?Int32 and U?Int64, respectively.

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

Sidebar

Related Questions

I am verifying my login authentication using ASP.net webservices. But the client requested to
I am assigned with the task of verifying some verilog based RTL code. Now,
Update Thanks to @mrtsherman verifying my code was fine, I dove into the CSS
Alright, I'm injecting some code into another process using the CreateRemoteThread/LoadLibrary trick. I end
I have an assembly that provides an API and is used by some other
I'm currently managing some C++ code that runs on multiple platforms from a single
Let's say I'm defining some cases to match, where I care only about verifying
I'm using the following code in an ASP.NET page to create a record, then
I am trying to install MySQL5 on Snow Leopard, but I am having some
I'm trying to make a wrapper for some C-based sparse-matrix-handling code (see previous question

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.