Commit graph

62368 commits

Author SHA1 Message Date
Colin Finck
a758d604df [SPOOLSV, WINSPOOL]
- Add RPC calls, proper marshalling and exports for all implemented functions.
- Move the spoolsv stubs into categories, so that future implementations in winspool, spoolsv, spoolss and localspl can follow a consistent naming scheme.

svn path=/branches/colins-printing-for-freedom/; revision=68408
2015-07-17 10:57:10 +00:00
Colin Finck
c3a6132e37 [FORMATTING]
Tabs -> Spaces

svn path=/branches/colins-printing-for-freedom/; revision=68407
2015-07-16 15:24:40 +00:00
Colin Finck
30af627761 Merge r67713 and r67936 (Eric's parport driver) from trunk
svn path=/branches/colins-printing-for-freedom/; revision=68406
2015-07-16 15:12:50 +00:00
Colin Finck
ba2134dd1e [LOCALSPL, WINSPOOL]
Partially implement the whole StartDocPrinter, StartPagePrinter, ReadPrinter, WritePrinter, EndPagePrinter, EndDocPrinter, ClosePrinter group of functions.
They behave very differently based on whether spooled printing is enabled, whether it's a local or remote call, etc. Most information was gained by observing callchains under Windows.

So far, only the spooled path is implemented, the others need more investigation first.
Many other TODOs remain as well, see the comments.

Also make some more comments Doxygen-aware :)

svn path=/branches/colins-printing-for-freedom/; revision=68405
2015-07-16 15:03:47 +00:00
Colin Finck
f848e96f26 [SPOOLSV]
Implement the RPC calls for EnumMonitors, EnumPorts, ClosePrinter, EndDocPrinter, EndPagePrinter, ReadPrinter, StartDocPrinter, StartPagePrinter and WritePrinter.

svn path=/branches/colins-printing-for-freedom/; revision=68404
2015-07-16 13:59:20 +00:00
Colin Finck
843622e20a [LOCALMON]
- Bugfix: Unset bStartedDoc in LocalmonEndDocPort so that new documents can be started again.
- Bugfix: Use CREATE_ALWAYS instead of OPEN_ALWAYS for CreateFileW to truncate any existing output file before writing a new document into it.

svn path=/branches/colins-printing-for-freedom/; revision=68403
2015-07-15 18:45:37 +00:00
Colin Finck
afb3ba35d8 [LOCALMON]
My idea to just care about COM, FILE: and LPT ports was too short-sighted.
Apart from selecting a FILE: port that prompts for the output filename at printing, you can also add a port "C:\bla.txt" to always output into that particular file.
Even shared network printers can be added as a local port "\\COMPUTERNAME\PrinterName" (and Windows even does that when auto-adding printers found on the network). Note that this is the exception though, shared network printers are normally handled by a different component.

Our localmon now handles all valid ports found in the registry.
Port name checks were modified to be extra-picky and not let any false positives happen (e.g. trying to print into a file starting with "LPT" shouldn't be treated as printing to an LPT port)

svn path=/branches/colins-printing-for-freedom/; revision=68402
2015-07-15 18:15:33 +00:00
Colin Finck
1f52401541 [WINPRINT]
Bugfix: The Printer Name with Port is given through the parameter pPrinterName, not the pPrinterName field of the pPrintProcessorOpenData structure.

svn path=/branches/colins-printing-for-freedom/; revision=68401
2015-07-15 15:53:04 +00:00
Colin Finck
2e94fb273d [LOCALSPL]
- Rewrite LocalOpenPrinter to also properly support opening Port and Xcv handles.
- Manage a list of Ports and their associated Print Monitors.
- const-ify some parameters.

svn path=/branches/colins-printing-for-freedom/; revision=68397
2015-07-13 10:18:07 +00:00
Colin Finck
7ed643eb9c [LOCALSPL]
Bugfix: Copy the full DevMode including the extra data by the driver.

svn path=/branches/colins-printing-for-freedom/; revision=68379
2015-07-08 12:35:35 +00:00
Colin Finck
b83f56253b [LOCALSPL]
- Initialize all Print Monitors on startup and keep a list of them.
- Implement LocalEnumMonitors and LocalEnumPorts.
- Check the result of the initialization functions.

[SPOOLSS]
- Implement support for multiple Print Providers.
  Initialize them on startup and keep a list here as well.
- Implement all functions that had simple stubs in the C code. This still needs to be done for the remaining functions stubbed in the .spec file.
  But generally spoken, this always boils down to 3 cases:
    * Forward the call to the Local Spooler (for general functions like GetPrintProcessorDirectory).
    * Forward the call to the Print Provider we used for OpenPrinter (for functions like SetJob).
    * Forward the call to all Print Providers and collect the results (for functions like EnumPrinters).

svn path=/branches/colins-printing-for-freedom/; revision=68375
2015-07-07 17:06:48 +00:00
Colin Finck
91eab8a77a [LOCALMON]
- Bugfix: LocalmonClosePort must only free the memory for virtual file ports. Other port entries are reused.
- Bugfix: Set the port type to PortType_OtherLPT in all conditions that ít's not a physical LPT port.
- Synchronize access to the port lists.
- Keep a list of open Xcv handles as well to properly close them on shutdown.
- Add traces to all monitor functions for easier debugging. (requires DEBUGCHANNEL=+localmon environment variable)

svn path=/branches/colins-printing-for-freedom/; revision=68364
2015-07-07 10:30:30 +00:00
Colin Finck
75f2cf5f6f [LOCALMON]
Implement a Local Port Monitor for COM, FILE: and LPT ports, usable as a drop-in replacement for the Windows original.
Fully implements opening, enumerating and closing ports, starting and ending documents as well as reading and writing to ports along with Xcv data transfer between Port Monitor and Port Monitor UI.
Does not support IrDA printers unlike the Windows original, sorry guys :-P

The Windows Local Port Monitor is partly documented in an ancient DDK sample.
Additional information was gathered through API monitoring.

TODO:
- AddPort, DeletePort and PortIsValid Xcv functions need to be implemented.
- A real privilege check needs to be added to LocalmonXcvOpenPort.
- TESTING TESTING TESTING (under Windows) and fixing bugs.

To test it under Windows:
- Copy the compiled "localmon.dll" to the system32 directory.
- Open regedit.exe and move to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Local Port.
- Replace "localspl.dll" by "localmon.dll" for the "Driver" value.

[SPOOLSS]
- Properly stub EnumPortsW to let localmon compile.

svn path=/branches/colins-printing-for-freedom/; revision=68356
2015-07-06 12:41:06 +00:00
Colin Finck
d2c73472d0 [PSDK]
Source our winspool.h from MinGW-w64.
Our current version was still based on MinGW w32api from 2005 and missing lots of definitions added ages ago.

svn path=/branches/colins-printing-for-freedom/; revision=68355
2015-07-06 09:57:09 +00:00
Colin Finck
259a6572ae [LOCALSPL, WINPRINT]
Bugfix: All functions returning multiple elements must only set *pcReturned to the element count on success!
Currently, this was also done when querying the needed buffer size. But for this case, *pcReturned just has to be zeroed.

svn path=/branches/colins-printing-for-freedom/; revision=68335
2015-07-03 09:06:35 +00:00
Colin Finck
86dbf40cd1 [LOCALSPL]
Bugfix: The RegEnum* functions take the buffer size _including_ the terminating null character as input and only return the actual data length _without_ the terminating null character as output.

svn path=/branches/colins-printing-for-freedom/; revision=68324
2015-06-30 16:08:16 +00:00
Colin Finck
aef3b57f55 [LOCALSPL, WINPRINT]
Bugfix: I want to dereference the pointer and then increment its value, not increment the pointer address.

svn path=/branches/colins-printing-for-freedom/; revision=68323
2015-06-30 16:02:26 +00:00
Colin Finck
6574de04e3 [LOCALSPL]
Bugfix: The last entry in a doubly linked list (LIST_ENTRY structure) is actually the head element again, not NULL!

svn path=/branches/colins-printing-for-freedom/; revision=68322
2015-06-30 15:54:42 +00:00
Colin Finck
14711237a1 [LOCALSPL]
- Partly implement LocalScheduleJob.
- Set the default status to JOB_STATUS_SPOOLING in LocalAddJob.
- Fix file sharing flags in ReadJobShadowFile and WriteJobShadowFile.

[SPOOLSS, SPOOLSV, WINSPOOL]
- Forward the newly implemented ScheduleJob call all the way down to localspl.dll.
- Stub ReadPrinter.

[WINPRINT]
Implement a very simple RAW Print Processor that just takes the input and forwards it to the Print Monitor. This one doesn't even do pausing or multiple copies yet.
The implementation includes:
- Implemented ClosePrintProcessor, OpenPrintProcessor and PrintDocumentOnPrintProcessor (apart from the previously implemented EnumPrintProcessorDatatypesW).
- Stubbed ControlPrintProcessor and GetPrintProcessorCapabilities.

svn path=/branches/colins-printing-for-freedom/; revision=68304
2015-06-28 15:51:32 +00:00
Colin Finck
b0bc4bb807 [LOCALSPL]
- Write the shadow file after changing job details.
- dwUnknown2 in the shadow file header is actually the offset of the Print Processor Parameters.
- Process all known fields of the shadow file in ReadJobShadowFile and WriteJobShadowFile.

svn path=/branches/colins-printing-for-freedom/; revision=68292
2015-06-27 15:37:14 +00:00
Colin Finck
03bc6a133e [SPOOLSS, SPOOLSV, WINSPOOL]
Connect AddJobW, EnumJobsW, GetJobW and SetJobW from winspool.drv over spoolsv.exe and spoolss.dll to the implemented functions in localspl.dll (including marshalling the involved structures down and up).
I decided to not use my recently implemented MarshallDownStructure API here and rather do the pointer math in place as this is simpler and faster.

svn path=/branches/colins-printing-for-freedom/; revision=68288
2015-06-27 12:36:45 +00:00
Colin Finck
3218c2067a [LOCALSPL]
Implement LocalEnumJobs the easy way by using the new Skiplist function LookupNodeByIndexSkiplist and calling _LocalGetJobLevelX for each job.
This required changes in _LocalGetJobLevelX, so that the strings are now copied in reverse to the end of the buffer while the structure is copied to the start. By preserving the pointers after each call, the function can be called multiple times.

svn path=/branches/colins-printing-for-freedom/; revision=68264
2015-06-25 15:27:38 +00:00
Colin Finck
84416a465a [SKIPLIST]
- Add a LookupNodeByIndexSkiplist function and a small test for it in skiplist_test.
- Remove a redundant double-set in LookupElementSkiplist.

Yes, we now have one lookup function that accepts search criteria and returns an element and another one that accepts an index and returns a SKIPLIST_NODE.
It's simply because I have exactly these two cases :)
You're free to implement the two missing functions or refactor this code another way.

svn path=/branches/colins-printing-for-freedom/; revision=68262
2015-06-25 13:12:01 +00:00
Colin Finck
7aef841dea [LOCALSPL]
- Implement LocalSetJob for Level 1 and 2.
- Add pPrintProcessor, pwszPrintProcessorParameters and pwszStatus members to the LOCAL_JOB structure and use them in LocalAddJob, LocalGetJob and LocalSetJob.
- Fix naming of some LOCAL_JOB members.

svn path=/branches/colins-printing-for-freedom/; revision=68259
2015-06-25 12:29:18 +00:00
Colin Finck
fe48c72925 [SPOOLSS]
Halfplement and document the undocumented but exported MarshallDownStructure API.
Information about this API was exclusively gained by writing a custom XML file for rohitab.com's API Monitor and monitoring calls under Windows.

I could figure out the parameters passed to the function, but don't really know what most of them are for.
For me, the function does what it should and what I will soon need it for, but without making use of cbSize, cbPerElementSize, cbStructureSize and bSomeBoolean.
A Code Review and additional hints are highly appreciated! My XML file for the API Monitor is available on request.

svn path=/branches/colins-printing-for-freedom/; revision=68253
2015-06-24 16:26:33 +00:00
Colin Finck
587d83f1e3 Addendum to r68248
svn path=/branches/colins-printing-for-freedom/; revision=68252
2015-06-24 16:20:13 +00:00
Colin Finck
794f62a466 [SPOOLSV, WINSPOOL]
Local Communication between winspool.drv and spoolsv.exe happens using the ncalrpc protocol. The ncacn_np endpoint is only available when sharing a printer. It's then used for receiving a remote call from win32spl.dll.
Reference: http://www.hsc.fr/ressources/articles/win_net_srv/msrpc_spoolss.html

This fixes e.g. testing a _RpcOpenPrinter call from our winspool.drv to a local printer under Windows.

svn path=/branches/colins-printing-for-freedom/; revision=68248
2015-06-24 09:51:29 +00:00
Colin Finck
7e4bcf78c4 [WINSPOOL]
Don't rely on pure magic to transmit the error code of the RPC call to the calling application. Instead use SetLastError on the return value of the call (this is what all these DWORD return values are for!)

[SPOOLSV]
For every RPC function, return the error code of the called Spooler Router function instead of the error code of RpcRevertToSelf.

[LOCALSPL, WINPRINT]
- Change the code structure in every function called from the Spooler Router to always set an error code, especially ERROR_SUCCESS on success.
- Store Attributes and Status values for a local printer.
- Fail in LocalAddJob if an invalid handle has been supplied or the printer is set to do direct printing.

svn path=/branches/colins-printing-for-freedom/; revision=68247
2015-06-23 13:46:14 +00:00
Colin Finck
5df5a009e2 [SPOOLSS] [SPOOLSV] [WINSPOOL]
- Add RPC calls in winspool, Router calls in spoolsv and Local Spooler calls in spoolss for most of the APIs I've implemented in localspl.
  This is still Work-In-Progress and missing some sanity checks, but a first step into something usable from the documented Spooler API side.
- Separate APIs into individual source files just like I did for localspl.

svn path=/branches/colins-printing-for-freedom/; revision=68237
2015-06-22 14:31:47 +00:00
Colin Finck
9be537abb7 [LOCALSPL]
- Get rid of the Generic Tables entirely and make use of the new Skiplist for the Global Job List, the Printer's Job List and the Printer List.
  Use a doubly linked-list for the Print Processors (there won't be many) and just save the information returned from the Print Processor's EnumPrintProcessorDatatypesW instead of putting it in another structure.
- Implement LocalAddJob and LocalGetJob (with full JOB_INFO_1W and JOB_INFO_2W support)
  This makes use of the element index in the new Skiplist implementation to retrieve the position of the job in the list.
- Do some changes to LocalStartDocPrinter, though this will make use of LocalAddJob in the future.
- Make some global variables static again.

svn path=/branches/colins-printing-for-freedom/; revision=68195
2015-06-19 15:21:30 +00:00
Colin Finck
a4d50f82ff [LOCALSPL_APITEST]
Put the calls that eventually give us the function pointers to localspl into a separate procedure GetLocalsplFuncs to enable further tests easily.

svn path=/branches/colins-printing-for-freedom/; revision=68194
2015-06-19 15:05:58 +00:00
Colin Finck
1793014ec3 [RPCRT4]
Add a lazy stub for RpcBindingServerFromClient to get my upcoming localspl changes to compile.
This needs further attention later.

svn path=/branches/colins-printing-for-freedom/; revision=68193
2015-06-19 15:00:41 +00:00
Colin Finck
f1377fcb7c [SKIPLIST]
Verify that SKIPLIST_LEVELS is in the required range using C_ASSERTs (thanks to Thomas for the hint!)

svn path=/branches/colins-printing-for-freedom/; revision=68192
2015-06-19 12:33:45 +00:00
Colin Finck
86ad9580b1 [SKIPLIST]
Add my implementation of an efficient Skiplist. A Skiplist can do insertion, deletion and lookups in O(log N) on average just like balanced trees.
It features simpler algorithms though due to purely relying on probabilistic balancing at insertion and not on rebalancing with every modification.

This simple structure allowed me to implement some additions on top of the standard algorithms:
* Storing distances between elements on each level to efficiently return the index of the element in the Skiplist when doing a lookup.
* InsertTailElementSkiplist to explicitly insert an element at the end of the Skiplist.
  This needs no comparisons and is useful when you can be sure that the new element would be inserted at the end (e.g. for a new print job in the queue with default priority).

More features are easily possible, but for now I limited features on those needed for my Local Spooler work.

Some references on Skiplists:
* ftp://ftp.cs.umd.edu/pub/skipLists/skiplists.pdf
* http://drum.lib.umd.edu/bitstream/1903/544/2/CS-TR-2286.1.pdf

svn path=/branches/colins-printing-for-freedom/; revision=68191
2015-06-19 10:27:46 +00:00
Colin Finck
888171ae18 [LOCALSPL_APITEST]
It's only the second disabled test, which is causing trouble for us, so reactivate the first one.
This also confirms that the problem is not related to SEH.

svn path=/branches/colins-printing-for-freedom/; revision=68104
2015-06-10 21:49:49 +00:00
Colin Finck
1e363204d6 [LOCALSPL_APITEST]
- Add more tests for fpEnumPrinters.
  For some reason, using SEH here works only once. We experience a hang in the testing process when you run the test again for a second time without restarting spoolsv. Needs more investigation.
- Ensure that the spooler service is running before starting any testing.
- Do proper cleanup in every case.

[LOCALSPL]
- Implement LocalEnumPrinters level 1 based on the API-Tests.
- Use DllAllocSplMem/DllFreeSplMem instead of HeapAlloc/HeapFree.
- Use AllocSplStr with DllFreeSplStr now that DuplicateStringW is gone.
- Use _countof where applicable.

[SPOOLSS]
- Found out that I was not the only one needing a wcsdup equivalent. My DuplicateStringW from localspl is actually exported as AllocSplStr in spoolss.
  This is actually part of a range of undocumented memory functions in spoolss, so implement and document AllocSplStr, DllAllocSplMem, DllFreeSplMem, DllFreeSplStr, ReallocSplMem and ReallocSplStr.
  Information about some of them was gathered through black box testing and DDK samples (down to Win95 DDK), which at least contained prototypes of them.
- Implement SplInitializeWinSpoolDrv based on the API-Test and simply return FALSE for SplIsUpgrade.

[SPOOLSS_APITEST]
- Add a test for ReallocSplStr, which was actually the most undocumented function of spoolss' memory functions.

[WINSPOOL]
SplInitializeWinSpoolDrv shows that we can't just auto-assign an ordinal to all winspool.drv functions. We even need to export some nameless functions by ordinal only.
Redo the whole .spec file based on the ordinals found in Windows Server 2003's winspool.drv. Trust WINE for the nameless stubs.

svn path=/branches/colins-printing-for-freedom/; revision=68089
2015-06-09 13:22:25 +00:00
Colin Finck
f2a66788f8 [LOCALSPL_APITEST]
Write an API-Test for localspl.dll. As the original localspl.dll from Windows Server 2003 relies on proper initialization inside spoolsv.exe, we cannot test it standalone as usual.
To make testing possible anyway, this program basically does four things:

  - Injecting our testing code into spoolsv.exe.
  - Registering and running us as a service in the SYSTEM security context like spoolsv.exe, so that injection is possible at all.
  - Sending the test name and receiving the console output over named pipes.
  - Redirecting the received console output to stdout again, so it looks and feels like a standard API-Test.

Nevertheless, the testing code in fpEnumPrinters.c is still written like a usual test. The known ok(), skip(), etc. macros can be used as usual, their output is just redirected through the named pipes.
Thanks to Thomas for giving me the tip about injecting code into spoolsv! :)

svn path=/branches/colins-printing-for-freedom/; revision=68080
2015-06-08 17:15:44 +00:00
Colin Finck
19839c646c [SPOOLSS_APITEST]
Add a test for SplInitializeWinSpoolDrv verifying that Wine's XP-compatible implementation of this function also works for 2003 (and that we're going to need some nameless exports by ordinals in winspool.drv...)

svn path=/branches/colins-printing-for-freedom/; revision=68035
2015-06-06 12:32:30 +00:00
Colin Finck
1e4d261c62 [PRINTING]
Add an include directory for all printing components containing definitions not found in the public headers.
For now, that's just PackStrings in spoolss.h.

[SPOOLSS_APITEST]
Use the new spoolss.h header.

[WINPRINT_APITEST]
Add an API-Test for the winprint Print Processor, so far for its EnumPrintProcessorDatatypesW function. Tests succeed in Windows Server 2003.
winspool.drv also provides functions that go into winprint.dll, but as these tests show, they behave slightly different in terms of error codes due to the involved RPC and routing.
Windows Server 2003 has winprint functions in localspl.dll, so you have to copy its localspl.dll to winprint.dll for testing.

[WINPRINT]
- Use PackStrings to simplify the code.
- Fix test failures.

svn path=/branches/colins-printing-for-freedom/; revision=68025
2015-06-05 18:16:51 +00:00
Colin Finck
ecd7f83ffb [SPOOLSS]
In an attempt to simplify the code for further functions that return information structures, implement and document the undocumented PackStrings function.
Hints were taken from an XP DDK sample and own testing.

[SPOOLSS_APITEST]
Add some tests for PackStrings that succeed under Windows Server 2003.

svn path=/branches/colins-printing-for-freedom/; revision=68023
2015-06-05 15:52:39 +00:00
Colin Finck
af0a3b64a9 [WINSPOOL_APITEST]
- Add tests for EnumPrinters
- Fix a test for EnumPrintProcessorDatatypes

svn path=/branches/colins-printing-for-freedom/; revision=68007
2015-06-04 12:19:06 +00:00
Eric Kohl
f4494b1b46 [PARPORT]
- Add FdoQueryBusRelations to enumerate the 'attached' raw port.
- Create the PDO for the raw port (\Device\ParallelX) and let the symbolic link (\DosDevices\LPTX) point to it.
- Move the open, close and write code from the FDO to the PDO.

svn path=/trunk/; revision=67936
2015-05-27 20:18:10 +00:00
Amine Khaldi
556d08c8f1 [PSDK] Apply Wine commit ea41f29 by Vincent Povirk: Fix off-by-one error in EmfPlusRecordType enumeration.
svn path=/trunk/; revision=67935
2015-05-27 19:58:39 +00:00
Aleksandar Andrejevic
71d4766281 [NTVDM]
Now that the Fast486 FPU is feature-complete, tell programs that we have a builtin FPU.
(This commit may cause regressions if there are bugs in the FPU)


svn path=/trunk/; revision=67934
2015-05-27 01:07:05 +00:00
Aleksandar Andrejevic
391168594d [FAST486]
Implement FPATAN.
Fix the sign of the FPTAN result. Spotted by fox_anthony.


svn path=/trunk/; revision=67933
2015-05-27 01:00:20 +00:00
Aleksandar Andrejevic
d0860613d9 [FAST486]
Implement FPTAN by calculating the sine and then dividing it by
the approximated cosine: sqrt(1 - sin(x) ^ 2).
This method turned out to be faster and more precise than the
Maclaurin series for tan(x), which converges very slowly.


svn path=/trunk/; revision=67932
2015-05-26 19:11:33 +00:00
Daniel Reimer
644884cece [rapps]
[rapps_new]
Add zh-CN translation in RAPPS/RAPPS_NEW by Henry Tang Ih
CORE-9554 #resolve #comment Committed, thx ^^

svn path=/trunk/; revision=67931
2015-05-26 18:18:27 +00:00
Daniel Reimer
c770f94d2d [TRANSLATION]
Adding Turkish Translations (inf) by Erdem Ersoy
CORE-9138 #resolve #comment Committed, thx ^^

svn path=/trunk/; revision=67930
2015-05-26 18:12:08 +00:00
Daniel Reimer
dc318d55ce [TRANSLATION]
work on Romanian related strings in drivers inf by Stefan Fulea
CORE-9572 #resolve #comment Committed, thx ^^

svn path=/trunk/; revision=67929
2015-05-26 18:05:52 +00:00
Daniel Reimer
f4905944e7 [TRANSLATIONS]
Updating Turkish Translations by Erdem Ersoy
CORE-9587 #resolve #comment Committed, thx ^^

svn path=/trunk/; revision=67928
2015-05-26 18:01:39 +00:00