Windows Crypto API is not working on 64 bit
-
Hello All, My application is using CryptGenRandom() API to get random numbers. This API is working in all 32-bit computers. I recently installed my application in windows-7 64-bit computer. On this machine CryptGenRandom() API is throwing below error. Problem Event Name: APPCRASH Application Timestamp: 4b84b933 Fault Module Name: StackHash_6299 Fault Module Version: 0.0.0.0 Fault Module Timestamp: 00000000 Exception Code: c0000005 Exception Offset: 000007ff005880cb OS Version: 6.1.7600.2.0.0.256.48 Locale ID: 1033 Additional Information 1: 6299 Additional Information 2: 6299b6a70d20c6215a02ce0a4291f9cc Additional Information 3: 7130 Additional Information 4: 71302fa4a91436747a963f67bb2f095e Sample Code: ReDim bChallengeArray(127) lres = CryptGenRandom(lhcsp, 128, bChallengeArray(0)) lres = CryptEncrypt(lhkey, 0, 1, 0, bCryptBufferArray(0), ldatalength, lBufferLength) Please don't ask me to use managed code, because this is maintanance project client will not agree to change the code. If anybody have any idea, please let me know the solution. Thnaks in advance. Sri
modified on Friday, February 26, 2010 5:16 AM
-
Hello All, My application is using CryptGenRandom() API to get random numbers. This API is working in all 32-bit computers. I recently installed my application in windows-7 64-bit computer. On this machine CryptGenRandom() API is throwing below error. Problem Event Name: APPCRASH Application Timestamp: 4b84b933 Fault Module Name: StackHash_6299 Fault Module Version: 0.0.0.0 Fault Module Timestamp: 00000000 Exception Code: c0000005 Exception Offset: 000007ff005880cb OS Version: 6.1.7600.2.0.0.256.48 Locale ID: 1033 Additional Information 1: 6299 Additional Information 2: 6299b6a70d20c6215a02ce0a4291f9cc Additional Information 3: 7130 Additional Information 4: 71302fa4a91436747a963f67bb2f095e Sample Code: ReDim bChallengeArray(127) lres = CryptGenRandom(lhcsp, 128, bChallengeArray(0)) lres = CryptEncrypt(lhkey, 0, 1, 0, bCryptBufferArray(0), ldatalength, lBufferLength) Please don't ask me to use managed code, because this is maintanance project client will not agree to change the code. If anybody have any idea, please let me know the solution. Thnaks in advance. Sri
modified on Friday, February 26, 2010 5:16 AM
The error you posted is useless. It doesn't provide any details that can be used to diagnose the problem. You need the error from GetLastError to have any meaningful error code. We'd also need to see your PInvoke headers for these two functions. It's possible the wrong datatypes have been used to declare the parameters passed into the functions.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009... -
Hello All, My application is using CryptGenRandom() API to get random numbers. This API is working in all 32-bit computers. I recently installed my application in windows-7 64-bit computer. On this machine CryptGenRandom() API is throwing below error. Problem Event Name: APPCRASH Application Timestamp: 4b84b933 Fault Module Name: StackHash_6299 Fault Module Version: 0.0.0.0 Fault Module Timestamp: 00000000 Exception Code: c0000005 Exception Offset: 000007ff005880cb OS Version: 6.1.7600.2.0.0.256.48 Locale ID: 1033 Additional Information 1: 6299 Additional Information 2: 6299b6a70d20c6215a02ce0a4291f9cc Additional Information 3: 7130 Additional Information 4: 71302fa4a91436747a963f67bb2f095e Sample Code: ReDim bChallengeArray(127) lres = CryptGenRandom(lhcsp, 128, bChallengeArray(0)) lres = CryptEncrypt(lhkey, 0, 1, 0, bCryptBufferArray(0), ldatalength, lBufferLength) Please don't ask me to use managed code, because this is maintanance project client will not agree to change the code. If anybody have any idea, please let me know the solution. Thnaks in advance. Sri
modified on Friday, February 26, 2010 5:16 AM
Just a thought as I had something similar. Did you compile for 32 bit? I had to specifically compile for 32 bit before an app would run on Windows 7 64 bit.
-
Just a thought as I had something similar. Did you compile for 32 bit? I had to specifically compile for 32 bit before an app would run on Windows 7 64 bit.