title: JNA C DLL Debug Howto?
body: <p>I have a DLL that takes an encoded string input and decodes it. The DLL was made on a Win7 64-bit using Codeblocks and mingw64. The C code alone runs fine but when I run it via JNA in a while loop with the same string it is decoded properly for about 70% calls and for the rest its incorrect. I want to debug the situation but I am not sure how to do it after the Java code hands the control over to JNA. Alternatively any ideas on where to look will also be helpful.</p>
  
  <p>The method signature in C and JNA are as follows,</p>
  
  <pre><code>Java: int Decrypt_Blk(byte[] expkey, byte[] in, int size, byte[] out);  
  C: __declspec (dllexport) int Decrypt_Blk (unsigned char *expkey, unsigned char *in, unsigned int insize, unsigned char *out);
  </code></pre>
  
  <p>the correctness is determined by the output, for example, if i take the string "helloworld" encrypt it (I am not going into the encryption details as they are irrelevant) then pass the encrypted output to this DLL method, 7 out of 10 times I get "HelloWorld" other 3 times I would get incorrect and varying characters. And for all 10 times I am in the same thread using the same variable, in the same loop. The 3 incorrect occurrences are also random, the only thing I can notice is that the first run is ALWAYS correct as many times as I have tested but the incorrect run happens at any of the 1-10 runs. </p>