In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to solve the abnormal initialization of WinIO". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to solve the WinIO initialization exception".
The InitializeWinIo () function is called during initialization:
Bool _ stdcall InitializeWinIo () {bool bResult;DWORD dwBytesReturned; `IsNT = IsWinNT (); if (IsNT) {hDriver = CreateFile ("\\.\ WINIO", GENERIC_READ | GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); / / If the driver is not running, install itif (hDriver = = INVALID_HANDLE_VALUE) {GetDriverPath (); bResult = InstallWinIoDriver (szWinIoDriverPath, true); if (! bResult) return false;bResult = StartWinIoDriver (); if (! bResult) return false HDriver = CreateFile ("\\.\ WINIO", GENERIC_READ | GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); if (hDriver = = INVALID_HANDLE_VALUE) return false;} / / Enable I Band O port access for this processif (! DeviceIoControl (hDriver, IOCTL_WINIO_ENABLEDIRECTIO, NULL,0, NULL,0, & dwBytesReturned, NULL)) return false;} else {VxDCall = (DWORD (WINAPI *) (DWORD,DWORD,DWORD)) GetK32ProcAddress (1) HDriver = CreateFile ("\\.\ WINIO.VXD", 0,0,0, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, 0); if (hDriver = = INVALID_HANDLE_VALUE) return false;} IsWinIoInitialized = true;return true;}
The function first checks to see if it is a NT system, if so, creates a device-driven handle, and if not, installs one. Use it directly if you have it.
If you take a closer look at the value of this function, you can see that there are many reasons for initialization failure. The problem I encounter is that sometimes I exit abnormally, and the second time I can't start WinIO properly. It can only be done in this way:
InitWinIO- > success-> Program abnormal exit-> InitWinIO- > failure-> ShutdownWinIO- > InitWinIO- > success
In other words, restart the program twice. Due to abnormal exit of the driver that remains in memory, the second InitWinIO will fail, and then ShutdownWinIO will uninstall the driver, and then InitWinIO will be correct.
So how about running ShutdownWinIO directly before the application starts and shutting it down for a while? It seems possible to take a look at the code:
Void _ stdcall ShutdownWinIo () {DWORD dwBytesReturned; `if (IsNT) {if (hDriver! = INVALID_HANDLE_VALUE) {/ / Disable I port accessDeviceIoControl (hDriver, IOCTL_WINIO_DISABLEDIRECTIO, NULL,0, NULL,0, & dwBytesReturned, NULL); CloseHandle (hDriver);} RemoveWinIoDriver ();} elseCloseHandle (hDriver); IsWinIoInitialized = false;}
I have tested that executing ShutdownWinIo () directly at the beginning of the program and then initializing WinIO may also indicate an error. What's the reason?
In fact, WinIO's ShutdownWinIo has a bug here:
If (IsNT)
If you haven't called InitializeWinIo (), the global variable IsNT is false, and it doesn't execute the nt platform code correctly. This explains why the shutdown was not successful.
So, having found the problem, there are two solutions:
Function call to replace IsNT with IsWinNT ()
After if (IsNT) in InitWinIO, execute ShutdownWinIO once.
At this point, I believe that everyone on the "WinIO initialization exception how to solve" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.