VB6 compiled code calls assembly code .DLL = Invalid Page Fault in KERNEL32.DLL
Posted on 2003-11-13
I've got a VB6 application under Win98 that is comprised of a simple form with a single button, the declarations for an external .dll, and a function call to the dll.
The DLL was written in assembly and performs communication with the parallel port to custom hardware. Everything works fine within the VB6 IDE (development environment) however once the VB6 compiled executable is created (the DLL remains the same) and executed it crashes.
I've narrowed it down to the specific assembly instruction that causes it to crash:
I've tried various combinations and work arounds but it seems any MOV instruction that places something in the BX register (e.g. MOV BX,CX etc) causes it to crash.
The actual error message received is:
ApplicationName caused an invalid page fault in module KERNEL32.DLL at blablabla
This seems rather odd as the MOV command is rather innocuous. Why would it crash in Kernel32?? I would think if there was some sort of stack error caused by the assembly code that it wouldn't work in the IDE but it works GREAT until you create an executable.