简体   繁体   English

内联汇编,SEHException

[英]Inline assembly, SEHException

I have created a .dll file in cpp to access the I/O ports and write to them.For this purpose I am calling this .dll from my c# console application but when try to run it, I get "SEHException was unhandled" exception. 我在cpp中创建了一个.dll文件来访问I / O端口并写入它们。为此,我从我的c#控制台应用程序调用此.dll但是当我尝试运行它时,我得到“SEHException未处理”异常。 Do you have any idea? 你有什么主意吗?

this is c#: 这是c#:

[DllImport("testlib.dll")]
public static extern void enableWatchDog();

static void Main(string[] args)
{
    enableWatchDog();
}

this is cpp (which creates .dll): 这是cpp(创建.dll):

extern "C" __declspec(dllexport) void enableWatchDog() { 
   _asm {
      mov al, 41
      out 66, al
      mov al, 4
      out 62, al
   }
}   

You cannot access arbitrary I/O ports directly from user mode applications in Windows. 您无法直接从Windows中的用户模式应用程序访问任意I / O端口。 You need to use a special kernel mode driver for that. 您需要使用特殊的内核模式驱动程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM