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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:21:58+00:00 2026-06-16T06:21:58+00:00

In java i am using JNA to load VC++ dll file and calling functions

  • 0

In java i am using JNA to load VC++ dll file and calling functions within it,in one function i need to send 6 parameters,In VC++ function definition i am getting correct values for first 3 parameters but last 3 are having value ‘0’,
2nd parameter is byte array,when i send 1024 bytes, i am getting 5th bool parameter as false but when i pass 10 bytes it is taken as true
my function prototype :

int deviceupload(Pointer p, _byte[] data_, long startaddress, long datalength,_Boolean rt_,Pointer xyz);

So will mapping changes depending upon the size of parameters?

or JNA stack is so small that it cant hold 6 paramters?but according to JNA documentation MAX_NARGS of Function class value is 256 so i think 6 number of parameters is not an issue,
even though 3rd and 4th parameters have same data type,in VC++ function definition startaddress is correctly received but datalength received value is 0

so any idea why it is behaving so weird ?

  • 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-06-16T06:22:00+00:00Added an answer on June 16, 2026 at 6:22 am

    Arguments are placed in memory “slots” on the stack. A small argument might take one slot, or share a slot with another argument, while a large argument might take two slots. You can see how if you mistake a small argument for a large one, it will shift all the subsequent arguments into incorrect positions.

    void my_func(int32 p1, int64 p2)

    |               |
    +---------------+
    | P2 (64-bit)   |
    +---------------+
    | P2            | (P2 takes up two slots)
    +---------------+
    + P1 (32-bit)   |
    +---------------+ <-- Top of stack
    

    Now if you mistakenly use a 64-bit value for P1, you get this instead:

    |               |
    +---------------+
    | P2 (64-bit)   |
    +---------------+
    | P2            | 
    +---------------+
    + P1 (64-bit)   |
    +---------------+ 
    + P1            |
    +---------------+ <-- Top of stack
    

    The callee (the function you called) has no idea that this shift has taken place, and therefore attempts to read the arguments from their expected positions. For small arguments it might get a piece of a larger one, and for larger arguments it might get pieces of two or more other arguments.

    What the callee actually sees is this:

    |               |
    +---------------+
    | (P2)          | 
    +---------------+
    + (P1)          |
    +---------------+ 
    + (P1)          |
    +---------------+ <-- Top of stack
    

    You can see that the value read for P1 is actually only half of the larger value, while the value read for P2 comprises the other half of P1 and half of the value passed in as P2.

    (This explanation is somewhat simplified, but generally indicates how the stack works)

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

Sidebar

Related Questions

Using JNA, I am loading a dll written in C++ and calling function present
Edited Question: Trying to use a .dll file from Java using JNA. I've managed
I am trying to run the following C function from Java using JNA, but
I'm working on wrapping a C DLL library to Java using JNA. The library
What is the Java type for *short using JNA I have in my dll
I've been using JNA with relative success to make native function calls from Java
I'm trying to call a function in a delphi dll using JNA . the
I'm using a native c++ dll out of an Java application with the JNA
I'm trying to bind the dhcpctl library to Java using JNA. This is mi
Using JNA, the documentation says: Make your target library available to your Java program.

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.