Если процедуру void PortDOWN(unsigned short port)вызвать из программы, то все работает.При попытке вызвать из DLL пишет (win98, помогите, plz, очень надо)
file: i386\chkesp.c
line: 42
The value of ESP was not properly saved across a function call. This is usually a result of calling a function
declared with one calling convertion with a function pointer declared with a different calling convention.
-= Программа =-
typedef void (CALLBACK* PORTUP)(unsigned short);
PORTUP PortUP;
skip
void COpenDtestDlg::OnOpenButton(unsigned short port)
{
PortDOWN=(PORTDOWN)GetProcAddress(hDLL,"PortDOWN");
PortDOWN(port);
}
-= DLL =-
#include <Windows.h>
#include <conio.h>
void PortDOWN(unsigned short);
BOOL WINAPI DllMain( HANDLE hModule,
DWORD dwReason,
LPVOID lpReserved
)
{
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
void PortDOWN(unsigned short port)
{
int databyte=0x00; // 0xFF
int reflex=_outp(port, databyte); //port 0x0378 или 0x378
}
Здравствуйте D_Danil, Вы писали:
DD>The value of ESP was not properly saved across a function call. This is usually a result of calling a function
DD>declared with one calling convertion with a function pointer declared with a different calling convention.
Ну, правильно. Ты вызываешь функцию как CALLBACK (он же __stdcall), а в dll объявил её просто так. Когда всё в одном exe такой проблемы нет.
Нужно сделать dll такой:
#include <Windows.h>
#include <conio.h>
void CALLBACK PortDOWN(unsigned short);
BOOL WINAPI DllMain( HANDLE hModule, DWORD dwReason, LPVOID lpReserved )
{
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
void CALLBACK PortDOWN(unsigned short port)
{
int databyte=0x00; // 0xFF
int reflex=_outp(port, databyte); //port 0x0378 или 0x378
}