AndreasFagschlunger / O2Xfs

Java API for accessing CEN/XFS API, EMV Level 2 Kernel
47 stars 28 forks source link

I get this error "at.o2xfs.xfs.XfsServiceException: CFG_VALUE_TOO_LONG (-12)" when I look up for a description of the services from the registry. #63

Closed VitalyEG closed 6 years ago

VitalyEG commented 6 years ago

I get this error "at.o2xfs.xfs.XfsServiceException: CFG_VALUE_TOO_LONG (-12)" when I look up for a description of the services from the registry:

520 [main] ERROR at.o2xfs.xfs.service.lookup.RegistryServiceLookup - lookup(): Error opening registry Key: hKey=01000000 at.o2xfs.xfs.XfsServiceException: CFG_INVALID_HKEY(-5) at at.o2xfs.xfs.XfsServiceExceptionFactory.throwException(XfsServiceExceptionFactory.java:51) at at.o2xfs.xfs.XfsException.throwFor(XfsException.java:90) at at.o2xfs.xfs.conf.O2XfsConf.wfmOpenKey(O2XfsConf.java:144) at at.o2xfs.xfs.service.lookup.RegistryServiceLookup.lookup(RegistryServiceLookup.java:103) at at.o2xfs.TestCommon.main(TestCommon.java:27) 520 [main] ERROR at.o2xfs.xfs.service.lookup.RegistryServiceLookup - queryServiceClass(HKEY): Error querying key value: hKey=1C050000 at.o2xfs.xfs.XfsServiceException: CFG_VALUE_TOO_LONG(-12) at at.o2xfs.xfs.XfsServiceExceptionFactory.throwException(XfsServiceExceptionFactory.java:51) at at.o2xfs.xfs.XfsException.throwFor(XfsException.java:90) at at.o2xfs.xfs.conf.O2XfsConf.wfmQueryValue(O2XfsConf.java:161) at at.o2xfs.xfs.service.lookup.RegistryServiceLookup.queryServiceClass(RegistryServiceLookup.java:63) at at.o2xfs.xfs.service.lookup.RegistryServiceLookup.retrievesServiceClass(RegistryServiceLookup.java:80) at at.o2xfs.xfs.service.lookup.RegistryServiceLookup.lookup(RegistryServiceLookup.java:111) at at.o2xfs.TestCommon.main(TestCommon.java:27)

AndreasFagschlunger commented 6 years ago

Currently the size limit is hard coded in at.o2xfs.xfs.conf.O2XfsConf.SIZE_LIMIT, try increasing the value. The question is, when is a value really too long. I may check the usual Windows Registry limits.

VitalyEG commented 6 years ago

public String wfmQueryValue(final HKEY hKey, final String valueName) throws XfsException { final ZSTR data = new ZSTR(SIZE_LIMIT, true); ... Description from the documentation: WFS_ERR_CFG_VALUE_TOO_LONG The length of the value to be returned exceeds the length of the buffer.

I increased the value of the SIZE_LIMIT constant, but this error remained (up to 512, 1024, 2048, 16383).

Here is a description of the registry elements size limits: Registry Element - Size Limit Key name - 255 characters. The key name includes the absolute path of the key in the registry, always starting at a base key, for example, HKEY_LOCAL_MACHINE. Value name - 16,383 charactersWindows 2000:  260 ANSI characters or 16,383 Unicode characters. Value - Available memory (latest format)1 MB (standard format)

VitalyEG commented 6 years ago

The problem was at this line:

public String wfmQueryValue(final HKEY hKey, final String valueName) throws XfsException { final ZSTR data = new ZSTR(SIZE_LIMIT, true); final DWORD cchData = new DWORD(0L);

_need: final DWORD cchData = new DWORD(SIZELIMIT);

LPDWORD lpcchData Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpszData parameter, including the terminating null character. When the function returns, this variable contains the number of characters actually stored in the buffer, not including the terminating null character.

AndreasFagschlunger commented 6 years ago

Can you find out which registry entry causes the problem (path, valueName)? Maybe you find something odd. The XFS functions are basically wrappers for the Win32-API, which would have the option to query the value size first.

VitalyEG commented 6 years ago

At this registry key (as example, in fact, when you get any value): [HKEY_USERS.DEFAULT\XFS\LOGICAL_SERVICES\CDM_BILLS_EMULATION] "class"="CDM" "provider"="CDM_BILLS_EMULATION"

VitalyEG commented 6 years ago

This error was on Windows 7 32bit and 64bit. I used JVM 32bit.