Untitled
#include <iostream.h> #include <dos.h> // Функция за проверка дали портът е наличен bool isPortAvailable(unsigned int portAddress) { // Опит за запис в порта и проверка за грешка outportb(portAddress, 0x00); return (inportb(portAddress) == 0x00); } void main() { // Възможни адреси на паралелните портове unsigned int possiblePorts[] = {0x03BC, 0x0378, 0x0278}; int numPorts = sizeof(possiblePorts) / sizeof(possiblePorts[0]); // Адреси на клетките в BIOS Data Area (за LPT1, LPT2, LPT3, LPT4) unsigned int biosAddresses[] = {0x0408, 0x040A, 0x040C, 0x040E}; int biosSize = sizeof(biosAddresses) / sizeof(biosAddresses[0]); // Зануляване на BIOS клетките за LPT портовете for (int i = 0; i < biosSize; i++) { unsigned int far *biosCell = (unsigned int far *)MK_FP(0x40, biosAddresses[i]); *biosCell = 0; // Зануляваме клетката } cout << "Scanning for parallel ports..." << endl; int foundPorts = 0; for (int i = 0; i < numPorts && foundPorts < biosSize; i++) { if (isPortAvailable(possiblePorts[i])) { cout << "Parallel port found at address: 0x" << hex << possiblePorts[i] << endl; unsigned int far *biosCell = (unsigned int far *)MK_FP(0x40, biosAddresses[foundPorts]); *biosCell = possiblePorts[i]; // Записваме адреса в BIOS Data Area foundPorts++; } } if (foundPorts == 0) { cout << "No parallel ports found!" << endl; } else { cout << "Parallel port addresses have been saved in BIOS Data Area." << endl; } // Извеждане на тайм-аут константата (примерен адрес: 0x0412) unsigned int far *timeoutConstant = (unsigned int far *)MK_FP(0x40, 0x0412); cout << "Timeout Constant: 0x" << hex << *timeoutConstant << endl; }
Leave a Comment