mike_marquet
asked on
Equivalence !
What's the equivalent of the function 'outportb' (Borland C++ 3.1 [DOS]) in Microsoft Visual C++ 5.0 [WINDOWS] ?
you could use assembler to send stuff to the ports....
asm {
mov al, 5
mov dl, 2h
out dl, al
}
which would write the value 5 to port 2...
-Viktor
--Ivanov
asm {
mov al, 5
mov dl, 2h
out dl, al
}
which would write the value 5 to port 2...
-Viktor
--Ivanov
ASKER
I want to access an I/O card with 8255 chips.
Can I use assembler in a window program ?
Can I use assembler in a window program ?
ofcourse you can use assembler,
but you must take in consideration that window handles the ports. and some other applications may also try to do the same,
in a multithreaded environment you're taking a big risk
but you must take in consideration that window handles the ports. and some other applications may also try to do the same,
in a multithreaded environment you're taking a big risk
ASKER
Thanks. I will try it.
You may of course reject the answer, but this does _NOT_ affect the fact that it is true...
asm {
mov al, 5
mov dl, 2h
out dl, al
}
-> EXCEPTION_PRIV_INSTRUCTION ;-)
asm {
mov al, 5
mov dl, 2h
out dl, al
}
-> EXCEPTION_PRIV_INSTRUCTION
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
jkr, I just tried to give something like a pseudo code and say that the individual could use Assembler.. that's all.. I've never said that the code I wrote will work just the way it is... :))
-Viktor
--Ivanov
-Viktor
--Ivanov
Viktor, i agree - you can always use assembler, but certain instructions are restricted to ring 0 (i.e. kernel mode)...
ASKER
To JKR,
How can I set the privilege on NT to use inp(...) ?
I have try this but it doesn't work !
BOOL rcCode;
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
rcCode = OpenProcessToken(GetCurren tProcess() ,TOKEN_ADJ UST_PRIVIL EGES | TOKEN_QUERY,&hToken);
if (rcCode == FALSE) return FALSE;
LookupPrivilegeValue(NULL, SE_SECURITY_NAME, &tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1; // One privileges to set
tkp.Privileges[0].Attribut es = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hTok en, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
if (GetLastError() != ERROR_SUCCESS) return FALSE;
How can I set the privilege on NT to use inp(...) ?
I have try this but it doesn't work !
BOOL rcCode;
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
rcCode = OpenProcessToken(GetCurren
if (rcCode == FALSE) return FALSE;
LookupPrivilegeValue(NULL,
tkp.PrivilegeCount = 1; // One privileges to set
tkp.Privileges[0].Attribut
AdjustTokenPrivileges(hTok
if (GetLastError() != ERROR_SUCCESS) return FALSE;
You cannot - privileged instructions only work in ring0 (i.e. kernel mode), as i stated in my answer which you have chosen to reject ;-)
Why do you need to use 'outportb()'? Maybe we can find a way to get around this...