[REOPENING THE TOPIC]
ouch, well i try to compile a version of portio with new values to match one of my basic delphi app
(just reading the LPT1 port)
So that’s what i modify in gpioctl.h
#define GPD_TYPE 61696
// The IOCTL function codes from 0x800 to 0xFFF are for customer use.
#define IOCTL_GPD_READ_PORT_UCHAR \
CTL_CODE( GPD_TYPE, 0x901, METHOD_BUFFERED, FILE_READ_ACCESS )
#define IOCTL_GPD_WRITE_PORT_UCHAR \
CTL_CODE(GPD_TYPE, 0x902, METHOD_BUFFERED, FILE_WRITE_ACCESS)
#define IOCTL_GPD_READ_PORT_USHORT \
CTL_CODE( GPD_TYPE, 0x903, METHOD_BUFFERED, FILE_READ_ACCESS )
#define IOCTL_GPD_WRITE_PORT_USHORT \
CTL_CODE(GPD_TYPE, 0x904, METHOD_BUFFERED, FILE_WRITE_ACCESS)
#define IOCTL_GPD_READ_PORT_ULONG \
CTL_CODE( GPD_TYPE, 0x905, METHOD_BUFFERED, FILE_READ_ACCESS )
#define IOCTL_GPD_WRITE_PORT_ULONG \
CTL_CODE(GPD_TYPE, 0x916, METHOD_BUFFERED, FILE_WRITE_ACCESS)
TARGETNAME=smport in SOURCES
of course it compiles fine.
So i put the .sys in my app directory instead of the old one.
fire up my app.
The app Install the driver. And then try to start the service and… Failed to start it.
So i use a little programm to uninistall the driver.
OK
Fire up DebugView, and i my installer/starter.
InstDriver -Install smport smport.sys
smport succesfully installed.
InstDriver -Start smport
Failed to start.
InstDriver -Uninstall smport
smport succesfully Uninstalled.
here’s the bebug output from DebugView
PortIo:
Entered Driver Entry
PortIo:
unload
So for the next test i compile the original gpio driver without any modification.
No problem
Fireup debugview
InstDriver -Install genport genport.sys
smport succesfully installed.
InstDriver -genport smport
Failed to start.
the bebug output from DebugView is exactly the same
PortIo:
Entered Driver Entry
PortIo:
unload
By the way i tried to install the driver manually once again…
Successfull
and fireup
GpdRead -b 1
Unable to open the Device.
Ouch…
So i decided to use the “add hardware” wizzard
everything runs fine
GpdRead -b 1
Ioctl failed with code 87
That’s etter even if it’s not really a big succes.
So i’ll try ro use the add hadware wizzard to install the “new” replacement smport driver to test with my app.
I assume i also have to modify
%PortIO.DRVDESC%=PortIO_Inst,root\portio
by
%PortIO.DRVDESC%=PortIO_Inst,root\smport
(I’m not very familiar yet with .inf)
The fact is smport does not use .inf
What i don’t understand is why when i manually install the driver i can’t start it.
here’s the (yes i know it’s pascal syntax but api call is api call) the code for my installer
procedure TSmallPort.InstallSmallPortDriver;
var
hService: SC_HANDLE;
DriverPath: string;
buf: array[0…MAX_PATH - 1]of char;
begin
dwLastError := 0;
DriverPath := GetCurrentDir + '' + DriverName + ‘.sys’;
if not FileExists(DriverPath)then
begin
GetSystemDirectory(buf, MAX_PATH);
DriverPath := StrPas(buf) + '' + DriverName + ‘.sys’;
end;
hService := CreateService(hManager, PChar(DriverName),PChar(DriverName),
SERVICE_ALL_ACCESS,
SERVICE_KERNEL_DRIVER,
SERVICE_DEMAND_START,
SERVICE_ERROR_NORMAL,
PChar(DriverPath),
nil, nil, nil, nil, nil);
if hService = 0 then dwLastError := GetLastError
else
begin
CloseServiceHandle(hService);
dwLastError := 0;
end;
end;
The big part is CreateService api call. And it seems correct to me.
But as you know all errors seem to be correct to the eyes of the coder.
Well i can verify the fact the driver is installed after the call but…