inversojvo
asked on
Error "The instruction at address "0x00000000" referenced memory at number "0x00000000" for DLL function call from VBA.
Beginning and the prehistory of the problem is here:
https://www.experts-exchange.com/questions/21161325/Calling-dll-from-VBA-and-getting-a-big-complex-UDT-as-a-return-value-bad-calling-convention-error.html
In a few words: I'm trying to work from VBA with GIS system through C dll functions, which receive/return the pointer to a big UDT structure "TGisAbfrage" (in English it would be "GisQuery"). Function, declared in C as :
TGisAbfrage* API_EXPORT erzeugeAbfrageStruktur(voi d);
creates this UDT structure and returns the pointer to it. I have to fill some parts of this structure with parameters and to give the UDT as a parameter to the next function, (which runs the query, in fact):
TBool API_EXPORT ausfuehrenAbfrage(TGisAbfr age*);
So, when I'm trying to run in VBA the abovementioned function, the Access application crashes with error:
The instruction at address "0x00000000" referenced memory at number "0x00000000". The memory could not be "read".
The relevant info for the problem:
1. Declaration in VBA modul.
Public Type Bool '
Bool As Integer
End Type
Declare Function erzeugeAbfrageStruktur Lib "D:\Gis\GisAbfrage32.dll" () As Long
Declare Function ausfuehrenAbfrage Lib "D:\Gis\GisAbfrage32.dll" (ByVal lng As Long) As Bool
Remark:= type Bool was declared to fit the C declaration (I don't know, if conditional compillation is relevant here,
but it was declared so in a C header) -
// Boolean-Typ
typedef short TBool; // 19.01.98, S.J.
#ifndef SWIG
#define false 0 // 19.01.98, S.J.
#define true 1 // 19.01.98, S.J.
#endif
The VBA function, where I test the thing, and where the error happens, looks so:
Sub main()
... - irrelevant declarations
Dim b As Bool
Dim lngPointer As Long
... - irrelevant code
lngPointer = erzeugeAbfrageStruktur()
... - irrelevant code, lngPointer was not modified here
b = ausfuehrenAbfrage(ByVal lngPointer) '!!!! - here the application crashes
... - irrelevant code
End Sub
I told today with the guy, who created this dll and asked him expressly, what will happen if to give the pointer to ausfuehrenAbfrage() just after getting it from erzeugeAbfrageStruktur(), and without any modification of the structure in-between. He told, that it has just to run, but the structure will not be filled with results and the info, that nothing was found, will be saved in some UDT elements. But ANYWAY IT HAS TO RUN. But under Access 2000 it doesn't run.
What causes of that do you think are possible? In what direction have I to dig?
https://www.experts-exchange.com/questions/21161325/Calling-dll-from-VBA-and-getting-a-big-complex-UDT-as-a-return-value-bad-calling-convention-error.html
In a few words: I'm trying to work from VBA with GIS system through C dll functions, which receive/return the pointer to a big UDT structure "TGisAbfrage" (in English it would be "GisQuery"). Function, declared in C as :
TGisAbfrage* API_EXPORT erzeugeAbfrageStruktur(voi
creates this UDT structure and returns the pointer to it. I have to fill some parts of this structure with parameters and to give the UDT as a parameter to the next function, (which runs the query, in fact):
TBool API_EXPORT ausfuehrenAbfrage(TGisAbfr
So, when I'm trying to run in VBA the abovementioned function, the Access application crashes with error:
The instruction at address "0x00000000" referenced memory at number "0x00000000". The memory could not be "read".
The relevant info for the problem:
1. Declaration in VBA modul.
Public Type Bool '
Bool As Integer
End Type
Declare Function erzeugeAbfrageStruktur Lib "D:\Gis\GisAbfrage32.dll" () As Long
Declare Function ausfuehrenAbfrage Lib "D:\Gis\GisAbfrage32.dll" (ByVal lng As Long) As Bool
Remark:= type Bool was declared to fit the C declaration (I don't know, if conditional compillation is relevant here,
but it was declared so in a C header) -
// Boolean-Typ
typedef short TBool; // 19.01.98, S.J.
#ifndef SWIG
#define false 0 // 19.01.98, S.J.
#define true 1 // 19.01.98, S.J.
#endif
The VBA function, where I test the thing, and where the error happens, looks so:
Sub main()
... - irrelevant declarations
Dim b As Bool
Dim lngPointer As Long
... - irrelevant code
lngPointer = erzeugeAbfrageStruktur()
... - irrelevant code, lngPointer was not modified here
b = ausfuehrenAbfrage(ByVal lngPointer) '!!!! - here the application crashes
... - irrelevant code
End Sub
I told today with the guy, who created this dll and asked him expressly, what will happen if to give the pointer to ausfuehrenAbfrage() just after getting it from erzeugeAbfrageStruktur(), and without any modification of the structure in-between. He told, that it has just to run, but the structure will not be filled with results and the info, that nothing was found, will be saved in some UDT elements. But ANYWAY IT HAS TO RUN. But under Access 2000 it doesn't run.
What causes of that do you think are possible? In what direction have I to dig?
Have you tried to take out byval on both declaration and call
ASKER
Yes, just tried - the same error only memory address is different.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, but I don't think it's relevant in this case. I need to use CopyMemory, when I want to map VB UDT from C UDT. Now I don't want - I want only to test, if ausfuerenAbfrage() runs with the declared type of parameter.
So, as the author of dll stated, that the function ausfuerenAbfrage() has to work also with the empty, not modified structure, I give the pointer to the structure just after dll creates it in memory.
Miss I smth in this logical order?
So, as the author of dll stated, that the function ausfuerenAbfrage() has to work also with the empty, not modified structure, I give the pointer to the structure just after dll creates it in memory.
Miss I smth in this logical order?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
> Test to see if lngPointer returns a valid pointer to your data structure.
The matter is, that all I know is that pointer returns address, where the structure, created by dll, resides. In the "prehisory" you can see the part of C header file, which describes the structure. The pointer lngPointer gives the address of the structure, made of 4 pointers to the substructures of the lower level. I've made the Hex dumps of this 1-st level and it seems OK.
========================== ========== ========== ========== ========== ========== =====
lpBuffer = &hBBE1490 nBytes = 16
0BBE1490 0000 F0 0D BE 0B 20 11 BE 0B-60 12 BE 0B 50 13 BE 0B .... ...`...P...
========================== ========== ========== ========== ========== ========== =====
At least, going to the addresses, marked there, I can surely get some members of lower levels.
But, again - it is not my structure, it's a structure, created by that damn dll, and I'm NOT sure, that if I call the same function from C, the structure of data in memory is the same.
What I assumed and expected is that the structures, created by dll, called from VB and from C, are the same, and I only need some efforts to map it to UDT, declared in VB , as some elements (strings, etc.) have different memory allocation rules. But now I'm starting to think, that the structures, created by this dll differ depending on from where we call - from VB or from C.
The guy, who implemented this dll, told me, that no alignment is used while creating the structure in memory, but I've noticed some interesting points in HEX dumps (sorry for flood :) ) :
UDT Meldung starts: 197004784 in Dec-System, in Hex: BBE0DF0
========================== ========== ========== ========== ========== ========== =====
lpBuffer = &hBBE0DF0 nBytes = 900
0BBE0DF0 0000 00 00 00 00 CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0E00 0010 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0E10 0020 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0E20 0030 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0E30 0040 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0E40 0050 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0E50 0060 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0E60 0070 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0E70 0080 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0E80 0090 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0E90 00A0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0EA0 00B0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0EB0 00C0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0EC0 00D0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0ED0 00E0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0EE0 00F0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0EF0 0100 CD CD CD 00 CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0F00 0110 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0F10 0120 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0F20 0130 CD CD CD CD CD CD FD FD-FD FD 00 00 00 00 00 00 ................
0BBE0F30 0140 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0F40 0150 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0F50 0160 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0F60 0170 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0F70 0180 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0F80 0190 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0F90 01A0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0FA0 01B0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0FB0 01C0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0FC0 01D0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0FD0 01E0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0FE0 01F0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0FF0 0200 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1000 0210 43 10 BE 0B B5 00 00 00-14 00 00 00 00 00 00 00 C...............
0BBE1010 0220 00 00 00 00 00 00 00 00-00 00 00 00 0F 00 00 00 ................
0BBE1020 0230 00 00 00 00 00 00 00 00-00 00 00 14 00 00 00 00 ................
0BBE1030 0240 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 04 ................
0BBE1040 0250 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1050 0260 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1060 0270 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1070 0280 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1080 0290 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1090 02A0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE10A0 02B0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE10B0 02C0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE10C0 02D0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE10D0 02E0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE10E0 02F0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE10F0 0300 00 00 00 00 00 00 00 00-FF 00 00 00 00 00 00 00 ................
0BBE1100 0310 D0 0D BE 0B 40 12 BE 0B-00 00 00 00 00 00 00 00 ....@...........
0BBE1110 0320 12 01 00 00 01 00 00 00-2A 00 00 00 FD FD FD FD ........*.......
========================== ========== ========== ========== ========== ========== =====
UDT VersionsInfo starts: 197005600 in Dec-System, in Hex: BBE1120
========================== ========== ========== ========== ========== ========== =====
lpBuffer = &hBBE1120 nBytes = 400
0BBE1120 0000 30 2E 33 00 CD CD 30 00-CD CD CD CD D3 07 07 00 0.3...0.........
0BBE1130 0010 0A 00 54 65 73 74 76 65-72 73 69 6F 6E 20 5A 75 ..Testversion Zu
0BBE1140 0020 66 61 6C 6C 73 2D 47 4B-00 CD CD CD CD CD CD CD falls-GK........
0BBE1150 0030 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1160 0040 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1170 0050 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1180 0060 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1190 0070 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE11A0 0080 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE11B0 0090 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE11C0 00A0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE11D0 00B0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE11E0 00C0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE11F0 00D0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1200 00E0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1210 00F0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1220 0100 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1230 0110 CD CD FD FD FD FD 00 00-00 00 00 00 00 00 00 00 ................
0BBE1240 0120 00 11 BE 0B 30 13 BE 0B-00 00 00 00 00 00 00 00 ....0...........
0BBE1250 0130 C6 00 00 00 01 00 00 00-2B 00 00 00 FD FD FD FD ........+.......
========================== ========== ========== ========== ========== ========== =====
UDT AbfrageParameter starts: 197005920 in Dec-System, in Hex: BBE1260
========================== ========== ========== ========== ========== ========== =====
lpBuffer = &hBBE1260 nBytes = 400
0BBE1260 0000 01 00 00 00 00 00 00 CD-CD CD CD CD CD 00 CD CD ................
0BBE1270 0010 CD CD CD CD CD 00 CD CD-CD CD CD CD CD CD CD CD ................
0BBE1280 0020 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1290 0030 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE12A0 0040 CD CD CD CD CD CD CD CD-00 CD CD CD CD CD CD CD ................
0BBE12B0 0050 00 CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE12C0 0060 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE12D0 0070 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE12E0 0080 CD CD CD 00 CD CD CD CD-CD CD CD 00 CD CD CD CD ................
0BBE12F0 0090 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1300 00A0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1310 00B0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD 00 CD ................
0BBE1320 00C0 CD CD CD CD CD CD FD FD-FD FD 00 00 00 00 00 00 ................
0BBE1330 00D0 40 12 BE 0B 70 14 BE 0B-00 00 00 00 00 00 00 00 @...p...........
0BBE1340 00E0 16 01 00 00 01 00 00 00-2C 00 00 00 FD FD FD FD ........,.......
========================== ========== ========== ========== ========== ========== =====
UDT DatenSet starts: 197006160 in Dec-System, in Hex: BBE1350
========================== ========== ========== ========== ========== ========== =====
lpBuffer = &hBBE1350 nBytes = 900
0BBE1350 0000 00 00 00 00 00 00 00 CD-CD CD CD CD CD CD 00 00 ................
0BBE1360 0010 00 CD CD CD CD CD CD CD-00 00 00 CD CD CD CD CD ................
0BBE1370 0020 CD CD 00 00 00 CD CD CD-CD CD CD CD 00 00 00 00 ................
0BBE1380 0030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1390 0040 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE13A0 0050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE13B0 0060 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE13C0 0070 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE13D0 0080 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE13E0 0090 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE13F0 00A0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1400 00B0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1410 00C0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1420 00D0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1430 00E0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1440 00F0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1450 0100 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1460 0110 00 CD 00 CD 00 CD FD FD-FD FD 00 00 00 00 00 00 ................
0BBE1470 0120 30 13 BE 0B 00 00 00 00-00 00 00 00 00 00 00 00 0...............
0BBE1480 0130 10 00 00 00 01 00 00 00-2D 00 00 00 FD FD FD FD ........-.......
0BBE1490 0140 F0 0D BE 0B 20 11 BE 0B-60 12 BE 0B 50 13 BE 0B .... ...`...P...
0BBE14A0 0150 FD FD FD FD 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE14B0 0160 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE14C0 0170 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE14D0 0180 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE14E0 0190 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE14F0 01A0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1500 01B0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1510 01C0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1520 01D0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1530 01E0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1540 01F0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1550 0200 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1560 0210 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1570 0220 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1580 0230 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1590 0240 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE15A0 0250 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE15B0 0260 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE15C0 0270 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE15D0 0280 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE15E0 0290 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE15F0 02A0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1600 02B0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
========================== ========== ========== ========== ========== ========== =====
At the end of some dump fragments, that could be identified, as structure elements from declaration, we can see the sequence:
FD FD-FD FD
that seems to mark the end of some structure elements.
If C function ausfuehrenAbfrage(ByVal lngPointer) expects the structure in memory to be WITHOUT those DWORD alignment (or formatted a bit differently), or how it's called, then it COULD explain, why in C the sequence of 2 calls:
lngPointer = erzeugeAbfrageStruktur()
b = ausfuehrenAbfrage(ByVal lngPointer)
runs OK, and in VB it fails. But if it's really the reason, then I don't understand, HOW the structure, created in memory by C dll, can be different, when we call dll from 2 programms, written in different languages. My understanding is, that dll doesn't care, who call it, it makes what it has to make and if the OS is the same (32-bit), than the structure has to be alse the same.
But I'm not experienced enough to be sure :(.
> As a test, I would suggest the following to see what line, if any, crashes.
What did you mean "what line"? Line in VBA function? - if so, it was marked:
b = ausfuehrenAbfrage(ByVal lngPointer) '!!!! - here the application crashes,
Or did you mean "line" as a memory fragment ?
The matter is, that all I know is that pointer returns address, where the structure, created by dll, resides. In the "prehisory" you can see the part of C header file, which describes the structure. The pointer lngPointer gives the address of the structure, made of 4 pointers to the substructures of the lower level. I've made the Hex dumps of this 1-st level and it seems OK.
==========================
lpBuffer = &hBBE1490 nBytes = 16
0BBE1490 0000 F0 0D BE 0B 20 11 BE 0B-60 12 BE 0B 50 13 BE 0B .... ...`...P...
==========================
At least, going to the addresses, marked there, I can surely get some members of lower levels.
But, again - it is not my structure, it's a structure, created by that damn dll, and I'm NOT sure, that if I call the same function from C, the structure of data in memory is the same.
What I assumed and expected is that the structures, created by dll, called from VB and from C, are the same, and I only need some efforts to map it to UDT, declared in VB , as some elements (strings, etc.) have different memory allocation rules. But now I'm starting to think, that the structures, created by this dll differ depending on from where we call - from VB or from C.
The guy, who implemented this dll, told me, that no alignment is used while creating the structure in memory, but I've noticed some interesting points in HEX dumps (sorry for flood :) ) :
UDT Meldung starts: 197004784 in Dec-System, in Hex: BBE0DF0
==========================
lpBuffer = &hBBE0DF0 nBytes = 900
0BBE0DF0 0000 00 00 00 00 CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0E00 0010 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0E10 0020 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0E20 0030 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0E30 0040 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0E40 0050 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0E50 0060 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0E60 0070 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0E70 0080 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0E80 0090 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0E90 00A0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0EA0 00B0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0EB0 00C0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0EC0 00D0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0ED0 00E0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0EE0 00F0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0EF0 0100 CD CD CD 00 CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0F00 0110 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0F10 0120 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE0F20 0130 CD CD CD CD CD CD FD FD-FD FD 00 00 00 00 00 00 ................
0BBE0F30 0140 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0F40 0150 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0F50 0160 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0F60 0170 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0F70 0180 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0F80 0190 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0F90 01A0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0FA0 01B0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0FB0 01C0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0FC0 01D0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0FD0 01E0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0FE0 01F0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE0FF0 0200 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1000 0210 43 10 BE 0B B5 00 00 00-14 00 00 00 00 00 00 00 C...............
0BBE1010 0220 00 00 00 00 00 00 00 00-00 00 00 00 0F 00 00 00 ................
0BBE1020 0230 00 00 00 00 00 00 00 00-00 00 00 14 00 00 00 00 ................
0BBE1030 0240 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 04 ................
0BBE1040 0250 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1050 0260 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1060 0270 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1070 0280 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1080 0290 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1090 02A0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE10A0 02B0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE10B0 02C0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE10C0 02D0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE10D0 02E0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE10E0 02F0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE10F0 0300 00 00 00 00 00 00 00 00-FF 00 00 00 00 00 00 00 ................
0BBE1100 0310 D0 0D BE 0B 40 12 BE 0B-00 00 00 00 00 00 00 00 ....@...........
0BBE1110 0320 12 01 00 00 01 00 00 00-2A 00 00 00 FD FD FD FD ........*.......
==========================
UDT VersionsInfo starts: 197005600 in Dec-System, in Hex: BBE1120
==========================
lpBuffer = &hBBE1120 nBytes = 400
0BBE1120 0000 30 2E 33 00 CD CD 30 00-CD CD CD CD D3 07 07 00 0.3...0.........
0BBE1130 0010 0A 00 54 65 73 74 76 65-72 73 69 6F 6E 20 5A 75 ..Testversion Zu
0BBE1140 0020 66 61 6C 6C 73 2D 47 4B-00 CD CD CD CD CD CD CD falls-GK........
0BBE1150 0030 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1160 0040 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1170 0050 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1180 0060 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1190 0070 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE11A0 0080 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE11B0 0090 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE11C0 00A0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE11D0 00B0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE11E0 00C0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE11F0 00D0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1200 00E0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1210 00F0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1220 0100 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1230 0110 CD CD FD FD FD FD 00 00-00 00 00 00 00 00 00 00 ................
0BBE1240 0120 00 11 BE 0B 30 13 BE 0B-00 00 00 00 00 00 00 00 ....0...........
0BBE1250 0130 C6 00 00 00 01 00 00 00-2B 00 00 00 FD FD FD FD ........+.......
==========================
UDT AbfrageParameter starts: 197005920 in Dec-System, in Hex: BBE1260
==========================
lpBuffer = &hBBE1260 nBytes = 400
0BBE1260 0000 01 00 00 00 00 00 00 CD-CD CD CD CD CD 00 CD CD ................
0BBE1270 0010 CD CD CD CD CD 00 CD CD-CD CD CD CD CD CD CD CD ................
0BBE1280 0020 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1290 0030 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE12A0 0040 CD CD CD CD CD CD CD CD-00 CD CD CD CD CD CD CD ................
0BBE12B0 0050 00 CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE12C0 0060 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE12D0 0070 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE12E0 0080 CD CD CD 00 CD CD CD CD-CD CD CD 00 CD CD CD CD ................
0BBE12F0 0090 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1300 00A0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD CD CD ................
0BBE1310 00B0 CD CD CD CD CD CD CD CD-CD CD CD CD CD CD 00 CD ................
0BBE1320 00C0 CD CD CD CD CD CD FD FD-FD FD 00 00 00 00 00 00 ................
0BBE1330 00D0 40 12 BE 0B 70 14 BE 0B-00 00 00 00 00 00 00 00 @...p...........
0BBE1340 00E0 16 01 00 00 01 00 00 00-2C 00 00 00 FD FD FD FD ........,.......
==========================
UDT DatenSet starts: 197006160 in Dec-System, in Hex: BBE1350
==========================
lpBuffer = &hBBE1350 nBytes = 900
0BBE1350 0000 00 00 00 00 00 00 00 CD-CD CD CD CD CD CD 00 00 ................
0BBE1360 0010 00 CD CD CD CD CD CD CD-00 00 00 CD CD CD CD CD ................
0BBE1370 0020 CD CD 00 00 00 CD CD CD-CD CD CD CD 00 00 00 00 ................
0BBE1380 0030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1390 0040 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE13A0 0050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE13B0 0060 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE13C0 0070 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE13D0 0080 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE13E0 0090 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE13F0 00A0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1400 00B0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1410 00C0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1420 00D0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1430 00E0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1440 00F0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1450 0100 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1460 0110 00 CD 00 CD 00 CD FD FD-FD FD 00 00 00 00 00 00 ................
0BBE1470 0120 30 13 BE 0B 00 00 00 00-00 00 00 00 00 00 00 00 0...............
0BBE1480 0130 10 00 00 00 01 00 00 00-2D 00 00 00 FD FD FD FD ........-.......
0BBE1490 0140 F0 0D BE 0B 20 11 BE 0B-60 12 BE 0B 50 13 BE 0B .... ...`...P...
0BBE14A0 0150 FD FD FD FD 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE14B0 0160 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE14C0 0170 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE14D0 0180 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE14E0 0190 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE14F0 01A0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1500 01B0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1510 01C0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1520 01D0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1530 01E0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1540 01F0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1550 0200 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1560 0210 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1570 0220 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1580 0230 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1590 0240 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE15A0 0250 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE15B0 0260 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE15C0 0270 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE15D0 0280 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE15E0 0290 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE15F0 02A0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0BBE1600 02B0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
==========================
At the end of some dump fragments, that could be identified, as structure elements from declaration, we can see the sequence:
FD FD-FD FD
that seems to mark the end of some structure elements.
If C function ausfuehrenAbfrage(ByVal lngPointer) expects the structure in memory to be WITHOUT those DWORD alignment (or formatted a bit differently), or how it's called, then it COULD explain, why in C the sequence of 2 calls:
lngPointer = erzeugeAbfrageStruktur()
b = ausfuehrenAbfrage(ByVal lngPointer)
runs OK, and in VB it fails. But if it's really the reason, then I don't understand, HOW the structure, created in memory by C dll, can be different, when we call dll from 2 programms, written in different languages. My understanding is, that dll doesn't care, who call it, it makes what it has to make and if the OS is the same (32-bit), than the structure has to be alse the same.
But I'm not experienced enough to be sure :(.
> As a test, I would suggest the following to see what line, if any, crashes.
What did you mean "what line"? Line in VBA function? - if so, it was marked:
b = ausfuehrenAbfrage(ByVal lngPointer) '!!!! - here the application crashes,
Or did you mean "line" as a memory fragment ?
ASKER
the reason was found, and it was out of the question's area - the initialization procedure for dll returned code, that was error code, but wasn't documented. So, at last my chief has built a COM-shell around of original dll and the calls run OK now.
Thank everybody who tried to help, I'll split the points evenly with grade B, if you don't mind:
EDDYKT - 250
Erick37 - 250
Thank everybody who tried to help, I'll split the points evenly with grade B, if you don't mind:
EDDYKT - 250
Erick37 - 250