can not load the inpoutx64.dll

My x64 port of InpOut32
Post Reply
Nusspapst
New User
Posts: 4
Joined: Wed Sep 21, 2016 4:57 pm

can not load the inpoutx64.dll

Post by Nusspapst »

Hi @ All.
My Name is Thomas, I'm 47 years old, live in Germany next to Hamburg and have a problem with the inpoutx64.

I used the inpout32.dll until today.
I've modified the code of inpouttest a little bit. Used it for my CNC milling machine to control the spindle.
It worked very well under windows XP 32bit.

Now I have a new PC with Windows 7 professional 64-Bit.
I have modified the code to load now the "inpoutx64.dll".
At first I placed the inpoutx64.dll (I think an older one with around 54kB) in the system32 folder.
Windows told me that this dll is not made for windows, or has an bug.
In further trying for a few hours (with the newer one of the file, around 96 kB) I have the following state:

inpoutx64.dll is placed in
\windows\system32
\windows\sysWOW64
direkt in the root folder, where I've also placed my WxDEV Projekt.

Fore test purposes I've also placed the 32-Bit one at these folders.

If I load the inpout32.dll in the code, the ,exe will load it and I get an Windows Error - so far so good.
If I do it with the inpoutx64.dll, the programm always tells me, that it is not able to load the dll.
It seems the handle always contains NULL.

It doesn't matter if I try to load from the system folders

Code: Select all

INPOUTx64_DLL_Handle=LoadLibrary("inpoutx64.dll");
  if(INPOUTx64_DLL_Handle == NULL)
  {
   printf("LoadLibrary failed for inpoutx64.dll...\n\n");
   system("PAUSE");
   return -1;
  }
or from the root, where my code project is placed for the moment

Code: Select all

INPOUTx64_DLL_Handle=LoadLibrary("c:/inpoutx64.dll");
  if(INPOUTx64_DLL_Handle == NULL)
  {
   printf("LoadLibrary failed for inpoutx64.dll...\n\n");
   system("PAUSE");
   return -1;
  }
Any Idea's?

Best regards
Thomas
Nusspapst
New User
Posts: 4
Joined: Wed Sep 21, 2016 4:57 pm

Re: can not load the inpoutx64.dll

Post by Nusspapst »

Although I do not believe that there is a code trouble, I post here once the code . (Handle name set back to original 32)

Code: Select all

#include <stdio.h>
#include <windows.h>

typedef short _stdcall (*_Out32)(short, short);
typedef short _stdcall (*_Inp32)(short portaddr);

int main(int argc, char *argv[])
{
 HINSTANCE INPOUT32_DLL_Handle;
 _Inp32 Inp32;
 _Out32 Out32;

int d_drehzahl;
char c_drehzahl[6];
 //Load the inpout32.dll library. It's also associated
 //with hwinterface.sys, but it should open it by itself:
 ///
  INPOUT32_DLL_Handle=LoadLibrary("inpoutx64.dll");
  if(INPOUT32_DLL_Handle == NULL)
  {
   printf("LoadLibrary failed for inpoutx64.dll...\n\n");
   system("PAUSE");
   return -1;
  }


 //Get access to the Out32 function from inpout32.dll:
 ///
  Out32 = (_Out32)GetProcAddress(INPOUT32_DLL_Handle, "Out32");
  Inp32 = (_Inp32)GetProcAddress(INPOUT32_DLL_Handle, "Inp32");


 //Configure the CONTROL Port:
 ///
  Out32(strtol(argv[1],NULL,16)+2, 0);  //Bit 0: Strobe
                                        //Bit 1: Auto Line Feed
                                        //Bit 2: Initialize Printer
                                        //Bit 3: Select Printer
                                        //Bit 4: Enable IRQ Via Ack Line
                                        //Bit 5: Enable Bi-Directional Port
                                        //Bit 6: Unused
                                        //Bit 7: Unused
 


 //Write the port with the desired 8-bit value:
 ///
  
  d_drehzahl = atoi(argv[2]);
  d_drehzahl = d_drehzahl / 500;
  //Out32(strtol(argv[1],NULL,16), strtol(argv[2],NULL,2));
Out32(strtol(argv[1],NULL,16), d_drehzahl);

 //Unload our inpout32.dll library:
 ///
  FreeLibrary(INPOUT32_DLL_Handle);

 return 0;
}
Again: If I modifiy the dll name to inpout32.dll, the exe tries to load the inpout32.dll and windows interrupts the programm with an error, which is indeed completely in order under windows 64Bit
User avatar
phil
Site Admin
Posts: 7611
Joined: Sun Apr 06, 2003 11:12 pm

Re: can not load the inpoutx64.dll

Post by phil »

I think you perhaps need to understand how x86 and x64 DLLs (and drivers) work!

inpoutx64.dll is an x64 DLL. It can NOT be loaded by or into a 32bit (x86) process.
inputout32.dll is a x86 DLL. It can not be loaded by or into a 64bit (x64) process.

If you try and load the x64 DLL from a 32bit process, you WILL get an error saying it is unable to load the DLL (not for this platform or something along those lines). Thats because 32 bit processes cant load 64bit DLL's/

How have you modified your code - have you changed the compiler to the 64bit compiler or is its still compiling a 32bit process? (I suspect its still a 32bit process - therefore you need InpOut32.dll (but it must be my version that works on x64 windows).

Don't forget, on Windows Vista and later you MUST run as administrator to install the driver or the driver will not be installed. If you havent done this, there is an "InstallDriver.exe" in my binary distribution that does this for you.

Thanks,
Phil
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
Nusspapst
New User
Posts: 4
Joined: Wed Sep 21, 2016 4:57 pm

Re: can not load the inpoutx64.dll

Post by Nusspapst »

I think You're right.
I don't have the compiler said to compile in 64 Bit.

But......
I have installed the driver succesfuly (as admin)
If i try to load Your inpout32.dll in my code, the run-process crashes.
If I try to load Your inpoutx64.dll in my code, the run process answers with the error line from my code that the dll was fail to load and without any system error.

What I wonder about:
The first times I attempt to load the x64, windows answered with a "This file is not made for windows or has an bug.....".
Later it was as I described above.

I must say that I had 3 versions of the x64.dll here.
one is 54kb, one is 96kb and one with 123kb (???)

On my last attempts I only used the files from the "binary files only"-download link
Nusspapst
New User
Posts: 4
Joined: Wed Sep 21, 2016 4:57 pm

Re: can not load the inpoutx64.dll

Post by Nusspapst »

I tried again now (can't wait until tomorrow)

Now it works with the 32 Bit one.

I think there was a confusion during all my attempts and the different dll's I tried.
I have cleaned it all out. Put the 32 -Bit one on he root again and loaded from root.

Thank you so much for this dll!
My old spindle controller runs on 6-Bit binary input. This is the best way (LPT Port) to keep it running.

Good night!
Thomas
User avatar
phil
Site Admin
Posts: 7611
Joined: Sun Apr 06, 2003 11:12 pm

Re: can not load the inpoutx64.dll

Post by phil »

I'm glad you got it working. :)
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
Post Reply