Log in

View Full Version : System Driver Linking


kolina
May 24th, 2003, 19:39
Hi everybody,

I tried to compile the UCL HASP Emulator for a valid HaspNT.sys. But my problem is how to link the .obj files correctly. With the DDK I can compile the .cpp files and with TASM the .asm files, but I can't figure out the correct switches for link to get them together. Always some entry point error or something else. Any help would be greatly appreciated! I'd also like to try out CrackZ HASP Driver Pack, but his download is suspended at the moment. Maybe somebody else can give me a link or send the file?

Thank you very much for your help!
--kolina

Mostek
May 25th, 2003, 17:14
1st if you are using borland then there is a utility that will convert exe(if I remember right) to sys->I forgot the name of the utility but I know there is one as I had the same problem.

2nd I know that everybody is used to his tools, but I would recomend you to start using M$ Visual C/C++ and MASM.
Why?
Most of the examples and documentation solutions references VC directly->so you don't have to read/search on how borland solve this problem.

Sum: Borland is nice and I still use it sometimes, but for programming drivers (for win machines) the best solution is to go with M$ stuff.
I didn't want to use M$ stuff at the begining also, but found that it works quite nice.

Just a notice: If you'll install 'VisualStudio Net' be carefull not to uncheck to much stuff from installation options, as you will land into problems->the best is to leave everything what is already checked and maybe check even something extra that you need.

I hope this helped.

Peace
Mostek

kolina
May 26th, 2003, 03:31
Thanks Mostek! Normally I hate Borland, but in this case the source is for Turbo Assembler and can't be compiled with Masm. In the meantime I even managed to link all the OBJ files together (cpp compiled with VC XP DDK, asm files with TASM) with the following linker switches if I remember right:
link *.obj (some lib) /driver /subsystem:native /entryriverEntry /out:HaspNT.sys
And the driver is linked, but then I get a blue screen when running it. As I didn't change the source files at all I think it's a matter of the link switches.
Any hints???
Thanks!

Mostek
May 26th, 2003, 06:39
Sorry non what so ever.

Use SIce and debug->so you'll see what is wrong->maybe that will give you a hint.

Peace
Mostek

g_g
May 28th, 2003, 07:47
There are several checks performed by the operating system (my memory is rusty at best, so i'll skip attempting to specify wich - you can debug the loading process, if you wan't this info) before a driver can be loaded.

Once loaded, there are certain rules wich must be followed, mainly regarding the memory attributes of the various sections of the driver image. Certain functions must be located in non-pageable sections, as paging won't be possible when the functions are called.

Obviously, none of the above is really going to help you with your problem, sorry, but that's as specific i can get without reading up on the subject.

Here's the link argument's i've used when building masm based drivers:

link /STACK:0x40000,0x1000 /MERGE:_PAGE=PAGE /MERGE:_TEXT=.text /MERGE:.rdata=INIT /SECTION:INIT,d /DRIVER /ALIGN:0x20 /SUBSYSTEM:NATIVE /BASE:0x10000 /LIBPATH:[ddk libpath] [object files] /OUT:[driver binary]

the /merge arguments will most likely have to be changed to reflect the section names of your object files.

Hope you'll be able to dig out a solution to your problem.