dll.h文件#pragma onceextern "C" int _declspec(dllexport)call_cpu_id(unsigned long& s1,unsigned long& s2,unsigned long& s3,unsigned long& s4);dll.cpp文件#include "Lcall.h"int call_cpu_id(unsigned long& s1,unsigned long& s2,unsigned long& s3,unsigned long& s4)
{
__asm{ 
mov   eax,01h 
xor   edx,edx 
cpuid 
mov   s1,edx 
mov   s2,eax 
}
__asm{
mov   eax,03h 
xor   ecx,ecx 
xor   edx,edx 
cpuid
mov   s3,edx 
mov   s4,ecx 
}
return 1;
}调用文件#include <iostream>
#include <windows.h>using namespace std;typedef int(*lpcall)(unsigned long&,unsigned long&,unsigned long&,unsigned long&);int main()
{
HINSTANCE hDll;
lpcall lpc;
unsigned long s1=0,s2=0,s3=0,s4=0;
int c=0;
hDll = LoadLibrary("../Debug/Call_id.dll");
if (hDll != NULL)
{
lpc = (lpcall)GetProcAddress(hDll,"call_cpu_id");
c=lpc(s1,s2,s3,s4);
cout<<hex<<s1<<"--"<<hex<<s2<<"--"<<hex<<s3<<"--"<<hex<<s4<<endl;
}
return 0;
}
问题调用成功 c为1,当参数全部为0,即无法将参数传出来
问题2 dll代码中 汇编得到的s1,s2s3,s4的值全不对。
大侠们帮忙看看,小弟结贴很迅速的