dawner1
驱动牛犊
驱动牛犊
  • 注册日期2002-02-27
  • 最后登录2002-03-29
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:981回复:1

有高手吗?

楼主#
更多 发布于:2002-03-01 19:05
在学习WDM编程时,我使用书中给的一个例子进行调试,但总是出现一个错误,报告信息为:
Testor.obj : error LNK2001: unresolved external symbol __chkesp
debug\\testor.exe : fatal error LNK1120: 1 unresolved externals
另附调试程序的文件源代码:
/**************************
#include <windows.h>
#include <stdio.h>

int main() {
HANDLE hDevice;
BOOL status;
printf(\"Beginning test of Minimal PnP Parallel Port Driver (CH9)...\\n\");
hDevice =
CreateFile(\"\\\\\\\\.\\\\MPNP1\",
GENERIC_READ | GENERIC_WRITE,
0, // share mode none
NULL, // no security
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL ); // no template
if (hDevice == INVALID_HANDLE_VALUE) {
printf(\"Failed to obtain file handle to device: \"
\"%s with Win32 error code: %d\\n\",
\"MPNP1\", GetLastError() );
return 1;
}
printf(\"Succeeded in obtaining handle to MPNP1 device.\\n\");
printf(\"Attempting write to device...\\n\");
char outBuffer[20];
for (DWORD i=0; i<sizeof(outBuffer); i++)
outBuffer = (char)i;
DWORD outCount = sizeof(outBuffer);
DWORD bW;
status =
WriteFile(hDevice, outBuffer, outCount, &bW, NULL);
if (!status) {
printf(\"Failed on call to WriteFile - error: %d\\n\",
GetLastError() );
return 2;
}
if (outCount == bW) {
printf(\"Succeeded in writing %d bytes\\n\", outCount);
printf(\"OutBuffer was: \\n\");
for (i=0; i<bW; i++)
printf(\"%02X \", (UCHAR)outBuffer);
printf(\"\\n\");
} else {
printf(\"Failed to write the correct number of bytes.\\n\"
\"Attempted to write %d bytes, but WriteFile reported %d bytes.\\n\",
outCount, bW);
return 3;
}
printf(\"Attempting to read from device...\\n\");
char inBuffer[80];
DWORD inCount = sizeof(inBuffer);
DWORD bR;
status =
ReadFile(hDevice, inBuffer, inCount, &bR, NULL);
if (!status) {
printf(\"Failed on call to ReadFile - error: %d\\n\",
GetLastError() );
return 4;
}
if (bR == bW) {
printf(\"Succeeded in reading %d bytes\\n\", bR);
printf(\"Buffer was: \\n\");
for (i=0; i<bR; i++)
printf(\"%02X \", (UCHAR)inBuffer);
printf(\"\\n\");
} else {
printf(\"Failed to read the correct number of bytes.\\n\"
\"Should have read %d bytes, but ReadFile reported %d bytes.\\n\",
bW, inCount);
return 5;
}
printf(\"Attempting to close device MPNP1...\\n\");
status =
CloseHandle(hDevice);
if (!status) {
printf(\"Failed on call to CloseHandle - error: %d\\n\",
GetLastError() );
return 6;
}
printf(\"Succeeded in closing device...exiting normally\\n\");
return 0;
}
****************/
我自己认为是VC6.0的Setting没有设好,有哪位高手知道,快告诉我,谢谢你了!!
 :P
WindThruEars
驱动老牛
驱动老牛
  • 注册日期2002-11-17
  • 最后登录2004-07-10
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2002-03-02 00:52
Add the following code into your driver code:

#if DBG && defined(_X86_)
#pragma LOCKEDCODE
extern \"C\" void __declspec(naked) __cdecl _chkesp()
{
_asm je okay
okay:
_asm ret
}
#endif // DBG
我是假耳朵
游客

返回顶部