Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1028 lines
31 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // FILE : minidriv.c //
  3. // //
  4. // DESCRIPTION : Implementation for the driver Device Driver Interface. //
  5. // For further details about driver interface functions - //
  6. // refer to the Windows 95 DDK chapter under the DDK - //
  7. // Documentation. //
  8. // //
  9. // AUTHOR : DanL. //
  10. // //
  11. // HISTORY : //
  12. // Oct 19 1999 DannyL Creation. //
  13. // //
  14. // Copyright (C) 1999 Microsoft Corporation All Rights Reserved //
  15. /////////////////////////////////////////////////////////////////////////////
  16. #include "stdhdr.h"
  17. #include "resource.h"
  18. #include "..\faxdrv32\faxdrv32.h" // faxdrv32 api
  19. #include "faxreg.h"
  20. #define TEXT(quote) quote
  21. //
  22. // To enable the user info tab in the printer properties, define:
  23. //
  24. // #define ENABLE_USER_INFO_TAB
  25. DBG_DECLARE_MODULE("fxsdrv");
  26. HANDLE g_hModule;
  27. //
  28. // Decleration for the winproc of the user info tab on the device mode property
  29. // sheet page.
  30. //
  31. BOOL FAR PASCAL
  32. UserInfoDlgProc(
  33. HWND hDlg,
  34. WORD message,
  35. WPARAM wParam,
  36. LPARAM lParam
  37. );
  38. //
  39. // Debugging mechanizm for device pointer debug prints (lpdev, lpdv->lpMd and the device context).
  40. //
  41. #if 0
  42. //#ifdef DBG_DEBUG
  43. #define DEBUG_OUTPUT_DEVICE_POINTERS(sz, lpDev) OutputDevicePointers(sz, lpDev)
  44. void OutputDevicePointers(char* szMessage, LPDV lpdv)
  45. {
  46. DBG_PROC_ENTRY("OutputDevicePointers");
  47. DBG_TRACE3(
  48. "Device Event:%s lpdv:%#lx lpdv->lpMd:%#lx",
  49. szMessage,
  50. lpdv,
  51. lpdv->lpMd);
  52. if (lpdv->lpMd)
  53. {
  54. DBG_TRACE2("Device Event:%s dc:%#lx", szMessage, ((LPEXTPDEV)lpdv->lpMd)->hAppDC);
  55. }
  56. RETURN;
  57. }
  58. #else
  59. #define DEBUG_OUTPUT_DEVICE_POINTERS(sz, lpDev)
  60. #endif
  61. ////////////////////////////////////////////////////////////////////////////////////////
  62. // Printer-Escape Functions
  63. //
  64. // The printer-escape functions support device-specific operations. The
  65. // following briefly describes these escape functions.
  66. //
  67. // ABORTDOC The ABORTDOC escape function signals the abnormal
  68. // cancellation of a print job.
  69. //
  70. // BANDINFO The BANDINFO escape function RETURNs information about a
  71. // band of bitmap data.
  72. //
  73. // ENDDOC The ENDDOC escape function signals the end of a print job.
  74. //
  75. // NEXTBAND The NEXTBAND escape function prints a band of bitmap data.
  76. //
  77. // QUERYESCSUPPORT The QUERYESCSUPPORT escape function specifies whether the
  78. // driver supports a specified escape.
  79. //
  80. // SETABORTDOC The SETABORTDOC escape function calls an application's
  81. // cancellation procedure.
  82. //
  83. // STARTDOC The STARTDOC escape function signals the beginning of a
  84. // print job.
  85. //
  86. // The previous list of printer escapes is a list of escapes supported by the
  87. // Microsoft Windows Universal Printer Driver (UNIDRV.DLL). It is not a
  88. // comprehensive list of all Windows escape functions. Most of the escape
  89. // functions now have equivalent Windows API functions with Windows 3.1. The
  90. // escapes are supported for backward compatibility, but application
  91. // developers are encouraged to start using the new API calls.
  92. //
  93. #ifndef NOCONTROL
  94. short WINAPI Control(lpdv, function, lpInData, lpOutData)
  95. LPDV lpdv;
  96. WORD function;
  97. LPSTR lpInData;
  98. LPSTR lpOutData;
  99. {
  100. LPEXTPDEV lpXPDV;
  101. LPEXTPDEV lpOldXPDV;
  102. short sRet, sRc;
  103. DBG_PROC_ENTRY("Control");
  104. if (lpdv)
  105. {
  106. DBG_TRACE1("lpdv: 0x%lx", lpdv);
  107. }
  108. DBG_TRACE1("function: %d", function);
  109. if (lpInData)
  110. {
  111. DBG_TRACE2("lpInData: 0x%lx, *lpInData: %d", lpInData, *((LPWORD)lpInData));
  112. }
  113. if (lpOutData)
  114. {
  115. DBG_TRACE1("lpOutData: 0x%lx", lpOutData);
  116. }
  117. //
  118. // get pointer to our private data stored in UNIDRV's PDEVICE
  119. //
  120. lpXPDV = ((LPEXTPDEV)lpdv->lpMd);
  121. switch(function)
  122. {
  123. case SETPRINTERDC:
  124. //
  125. // save app's DC for QueryAbort() calls.
  126. //
  127. DBG_TRACE("SETPRINTERDC");
  128. if(lpXPDV)
  129. lpXPDV->hAppDC = *(HANDLE FAR *)lpInData;
  130. DEBUG_OUTPUT_DEVICE_POINTERS("SETPRINTERDC", lpdv);
  131. break;
  132. case NEXTBAND:
  133. DBG_TRACE("NEXTBAND");
  134. //
  135. // call UNIDRV.DLL's NEXTBAND to see if we're at end of page
  136. //
  137. sRet = UniControl(lpdv, function, lpInData, lpOutData);
  138. //
  139. // check for end of page (ie, empty rectangle) or failure
  140. //
  141. if((!IsRectEmpty((LPRECT)lpOutData)) || (sRet <= 0))
  142. {
  143. RETURN sRet;
  144. }
  145. //
  146. // Rewind buffer pointer.
  147. //
  148. lpXPDV->lpScanBuf -= lpXPDV->dwTotalScanBytes;
  149. ASSERT(lpXPDV->dwTotalScanBytes != 0);
  150. //
  151. // Add this page to our tiff.
  152. //
  153. DEBUG_OUTPUT_DEVICE_POINTERS("Before FaxEddPage", lpdv);
  154. sRc = FaxAddPage(
  155. lpXPDV->dwPointer,
  156. (LPBYTE)lpXPDV->lpScanBuf,
  157. lpXPDV->dwTotalScanBytes * 8 / lpXPDV->dwTotalScans,
  158. lpXPDV->dwTotalScans);
  159. if(sRc != TRUE)
  160. {
  161. if(sRc < 0)
  162. {
  163. ERROR_PROMPT(NULL,THUNK_CALL_FAIL);
  164. }
  165. DBG_CALL_FAIL("FaxAddPage",0);
  166. RETURN SP_ERROR;
  167. }
  168. //
  169. // clean up page stuff
  170. // initialize job variables
  171. //
  172. lpXPDV->dwTotalScans =
  173. lpXPDV->dwTotalScanBytes = 0;
  174. RETURN sRet;
  175. case STARTDOC:
  176. {
  177. DOCINFO di;
  178. char szTiffName[MAX_PATH] = "*.tif";
  179. DBG_TRACE("STARTDOC");
  180. if(IsBadReadPtr(lpOutData,1))
  181. {
  182. RETURN SP_ERROR;
  183. }
  184. //
  185. // If the output file is named "file:" we must pop up a dialog
  186. // and request the output filename from the user.
  187. //
  188. if(((LPDOCINFO)lpOutData)->lpszOutput &&
  189. (_fstrncmp(((LPDOCINFO)lpOutData)->lpszOutput,"file:",5) == 0))
  190. {
  191. OPENFILENAME ofn;
  192. char szTitle[MAX_LENGTH_CAPTION]="";
  193. char szFilters[MAX_LENGTH_PRINT_TO_FILE_FILTERS]="";
  194. _fmemset(&ofn,0,sizeof(ofn));
  195. ofn.lStructSize = sizeof(ofn);
  196. ofn.hwndOwner = GetActiveWindow();
  197. LoadString(g_hModule,
  198. IDS_PRINT_TO_FILE_FILTER,
  199. szFilters,
  200. sizeof(szFilters) - 1);
  201. ofn.lpstrDefExt = FAX_TIF_FILE_EXT;
  202. ofn.lpstrFilter = StringReplace(szFilters,'\n','\0');
  203. ofn.nMaxFile = sizeof(szTiffName) -1;
  204. ofn.lpstrFile = szTiffName;
  205. LoadString(g_hModule,
  206. IDS_CAPTION_PRINT_TO_FILE,
  207. szTitle,
  208. sizeof(szTitle) - 1);
  209. ofn.lpstrTitle = szTitle;
  210. if(!GetOpenFileName(&ofn))
  211. {
  212. //
  213. // User aborted.
  214. //
  215. RETURN SP_APPABORT;
  216. }
  217. ((LPDOCINFO)lpOutData)->lpszOutput = szTiffName;
  218. }
  219. //
  220. // Create the tiff/output file for pages.
  221. //
  222. DEBUG_OUTPUT_DEVICE_POINTERS("Before FaxStartDoc", lpdv);
  223. sRc = FaxStartDoc(lpXPDV->dwPointer, (LPDOCINFO)lpOutData);
  224. if(sRc != TRUE)
  225. {
  226. if(sRc < 0)
  227. {
  228. ERROR_PROMPT(NULL,THUNK_CALL_FAIL);
  229. }
  230. DBG_CALL_FAIL("FaxStartDoc",0);
  231. RETURN SP_ERROR;
  232. }
  233. //
  234. // pass NUL file to OpenJob in order to redirect the print
  235. // job to dev nul sinc we take care of the print job ourselves.
  236. //
  237. di.cbSize = sizeof(DOCINFO);
  238. di.lpszDocName = NULL;
  239. di.lpszOutput = (LPSTR)"nul";
  240. //
  241. // call UNIDRV.DLL's Control()
  242. //
  243. sRet = UniControl(lpdv, function, lpInData, (LPSTR)&di);
  244. //
  245. // if failure clean up scan buffer
  246. //
  247. if(sRet <= 0)
  248. {
  249. FaxEndDoc(lpXPDV->dwPointer, TRUE);
  250. }
  251. RETURN sRet;
  252. }
  253. case ABORTDOC:
  254. DBG_TRACE("ABORTDOC");
  255. //
  256. // The input parameter for FaxEndDoc reflects the difference.
  257. //
  258. case ENDDOC:
  259. DBG_TRACE("ENDDOC");
  260. //
  261. // Finalize tiff generation.
  262. //
  263. DEBUG_OUTPUT_DEVICE_POINTERS("Before FaxEndDoc", lpdv);
  264. sRc = FaxEndDoc(lpXPDV->dwPointer, function == ABORTDOC);
  265. if(sRc != TRUE)
  266. {
  267. if(sRc < 0)
  268. {
  269. ERROR_PROMPT(NULL,THUNK_CALL_FAIL);
  270. }
  271. DBG_CALL_FAIL("FaxEndDoc",0);
  272. RETURN SP_ERROR;
  273. }
  274. break;
  275. case RESETDEVICE:
  276. DBG_TRACE("RESETDEVICE");
  277. //
  278. // ResetDC was called - Copy the context to the new DC
  279. //
  280. lpOldXPDV = ((LPEXTPDEV)((LPDV)lpInData)->lpMd);
  281. sRc = FaxResetDC(&(lpOldXPDV->dwPointer), &(lpXPDV->dwPointer));
  282. if(sRc != TRUE)
  283. {
  284. if(sRc < 0)
  285. {
  286. ERROR_PROMPT(NULL,THUNK_CALL_FAIL);
  287. }
  288. DBG_CALL_FAIL("FaxResetDC",0);
  289. RETURN SP_ERROR;
  290. }
  291. break;
  292. default:
  293. DBG_TRACE1("UNSUPPORTED: %d",function);
  294. break;
  295. } // end case
  296. // call UNIDRV's Control
  297. RETURN (UniControl(lpdv, function, lpInData, lpOutData));
  298. }
  299. #endif
  300. #ifndef NODEVBITBLT
  301. BOOL WINAPI DevBitBlt(lpdv, DstxOrg, DstyOrg, lpSrcDev, SrcxOrg, SrcyOrg,
  302. xExt, yExt, lRop, lpPBrush, lpDrawmode)
  303. LPDV lpdv; // --> to destination bitmap descriptor
  304. short DstxOrg; // Destination origin - x coordinate
  305. short DstyOrg; // Destination origin - y coordinate
  306. LPBITMAP lpSrcDev; // --> to source bitmap descriptor
  307. short SrcxOrg; // Source origin - x coordinate
  308. short SrcyOrg; // Source origin - y coordinate
  309. WORD xExt; // x extent of the BLT
  310. WORD yExt; // y extent of the BLT
  311. long lRop; // Raster operation descriptor
  312. LPPBRUSH lpPBrush; // --> to a physical brush (pattern)
  313. LPDRAWMODE lpDrawmode;
  314. {
  315. DBG_PROC_ENTRY("DevBitBlt");
  316. RETURN UniBitBlt(lpdv, DstxOrg, DstyOrg, lpSrcDev, SrcxOrg, SrcyOrg,
  317. xExt, yExt, lRop, lpPBrush, lpDrawmode);
  318. }
  319. #endif
  320. #ifndef NOPIXEL
  321. DWORD WINAPI Pixel(lpdv, x, y, Color, lpDrawMode)
  322. LPDV lpdv;
  323. short x;
  324. short y;
  325. DWORD Color;
  326. LPDRAWMODE lpDrawMode;
  327. {
  328. DBG_PROC_ENTRY("Pixel");
  329. RETURN UniPixel(lpdv, x, y, Color, lpDrawMode);
  330. }
  331. #endif
  332. #ifndef NOOUTPUT
  333. short WINAPI Output(lpdv, style, count, lpPoints, lpPPen, lpPBrush, lpDrawMode, lpCR)
  334. LPDV lpdv; // --> to the destination
  335. WORD style; // Output operation
  336. WORD count; // # of points
  337. LPPOINT lpPoints; // --> to a set of points
  338. LPVOID lpPPen; // --> to physical pen
  339. LPPBRUSH lpPBrush; // --> to physical brush
  340. LPDRAWMODE lpDrawMode; // --> to a Drawing mode
  341. LPRECT lpCR; // --> to a clipping rectange if <> 0
  342. {
  343. DBG_PROC_ENTRY("Output");
  344. RETURN UniOutput(lpdv, style, count, lpPoints, lpPPen, lpPBrush, lpDrawMode, lpCR);
  345. }
  346. #endif
  347. #ifndef NOSTRBLT
  348. DWORD WINAPI StrBlt(lpdv, x, y, lpCR, lpStr, count, lpFont, lpDrawMode, lpXform)
  349. LPDV lpdv;
  350. short x;
  351. short y;
  352. LPRECT lpCR;
  353. LPSTR lpStr;
  354. int count;
  355. LPFONTINFO lpFont;
  356. LPDRAWMODE lpDrawMode; // includes background mode and bkColor
  357. LPTEXTXFORM lpXform;
  358. {
  359. DBG_PROC_ENTRY("StrBlt");
  360. // StrBlt is never called by GDI.
  361. // Keep a stub function here so nobody complains.
  362. //
  363. RETURN 0;
  364. }
  365. #endif
  366. #ifndef NOSCANLR
  367. short WINAPI ScanLR(lpdv, x, y, Color, DirStyle)
  368. LPDV lpdv;
  369. short x;
  370. short y;
  371. DWORD Color;
  372. WORD DirStyle;
  373. {
  374. DBG_PROC_ENTRY("ScanLR");
  375. // ScanLR is only called for RASDISPLAY devices.
  376. // Keep a stub function here so nobody complains.
  377. //
  378. RETURN 0;
  379. }
  380. #endif
  381. #ifndef NOENUMOBJ
  382. short WINAPI EnumObj(lpdv, style, lpCallbackFunc, lpClientData)
  383. LPDV lpdv;
  384. WORD style;
  385. FARPROC lpCallbackFunc;
  386. LPVOID lpClientData;
  387. {
  388. DBG_PROC_ENTRY("EnumObj");
  389. RETURN UniEnumObj(lpdv, style, lpCallbackFunc, lpClientData);
  390. }
  391. #endif
  392. #ifndef NOCOLORINFO
  393. DWORD WINAPI ColorInfo(lpdv, ColorIn, lpPhysBits)
  394. LPDV lpdv;
  395. DWORD ColorIn;
  396. LPDWORD lpPhysBits;
  397. {
  398. DBG_PROC_ENTRY("ColorInfo");
  399. RETURN UniColorInfo(lpdv, ColorIn, lpPhysBits);
  400. }
  401. #endif
  402. #ifndef NOREALIZEOBJECT
  403. DWORD WINAPI RealizeObject(lpdv, sStyle, lpInObj, lpOutObj, lpTextXForm)
  404. LPDV lpdv;
  405. short sStyle;
  406. LPSTR lpInObj;
  407. LPSTR lpOutObj;
  408. LPTEXTXFORM lpTextXForm;
  409. {
  410. DBG_PROC_ENTRY("RealizeObject");
  411. RETURN UniRealizeObject(lpdv, sStyle, lpInObj, lpOutObj, lpTextXForm);
  412. }
  413. #endif
  414. #ifndef NOENUMDFONTS
  415. short WINAPI EnumDFonts(lpdv, lpFaceName, lpCallbackFunc, lpClientData)
  416. LPDV lpdv;
  417. LPSTR lpFaceName;
  418. FARPROC lpCallbackFunc;
  419. LPVOID lpClientData;
  420. {
  421. DBG_PROC_ENTRY("EnumDFonts");
  422. RETURN UniEnumDFonts(lpdv, lpFaceName, lpCallbackFunc, lpClientData);
  423. }
  424. #endif
  425. // Enable will be called twice by the GDI
  426. // First: the unidriver fills the GDIINFO structure (so the GDI will know the
  427. // size of PDEVICE, and alloc memory for it.
  428. // Second: To initialize the already allocated PDEIVCE.
  429. #ifndef NOENABLE
  430. WORD WINAPI Enable(
  431. LPVOID lpDevInfo,
  432. WORD wAction,
  433. LPSTR lpDestDevType,
  434. LPSTR lpOutputFile,
  435. LPVOID lpData
  436. )
  437. {
  438. CUSTOMDATA cd;
  439. short sRet;
  440. LPEXTPDEV lpXPDV = NULL;
  441. DBG_PROC_ENTRY("Enable");
  442. DBG_TRACE1("lpDevInfo: 0x%lx", lpDevInfo);
  443. DBG_TRACE1("wAction: %d", wAction);
  444. DBG_TRACE1("lpDestDevType: %s", lpDestDevType);
  445. DBG_TRACE1("lpOutputFile: %s", lpOutputFile);
  446. DBG_TRACE1("lpData: 0x%lx", lpData);
  447. cd.cbSize = sizeof(CUSTOMDATA);
  448. cd.hMd = g_hModule;
  449. // output raster graphics in portrait and landscape orientation.
  450. cd.fnOEMDump = fnDump;
  451. if (!(sRet = UniEnable((LPDV)lpDevInfo,
  452. wAction,
  453. lpDestDevType, // Printer model
  454. lpOutputFile, // Port name
  455. (LPDM)lpData,
  456. &cd)))
  457. {
  458. RETURN (sRet);
  459. }
  460. switch(wAction)
  461. {
  462. case 0x0000:
  463. // Initializes the driver and associated hardware and then copies
  464. // device-specific information needed by the driver to the PDEVICE
  465. // structure pointed to by lpDevInfo.
  466. case 0x8000:
  467. // Initializes the PDEVICE structure pointed to by lpDevInfo,
  468. // but does not initialize the driver and peripheral hardware.
  469. {
  470. LPDV lpdv = (LPDV)lpDevInfo;
  471. DBG_TRACE("Init PDEVICE");
  472. //
  473. // allocate space for our private data
  474. //
  475. if (!(lpdv->hMd = GlobalAlloc(GHND, sizeof(EXTPDEV))))
  476. {
  477. RETURN 0;
  478. }
  479. if (!(lpdv->lpMd = GlobalLock(lpdv->hMd)))
  480. {
  481. GlobalFree (lpdv->hMd);
  482. RETURN 0;
  483. }
  484. lpXPDV = (LPEXTPDEV) lpdv->lpMd;
  485. //
  486. // alloc page scan buffer
  487. //
  488. if(!(lpXPDV->hScanBuf = GlobalAlloc(GHND, BUF_CHUNK)))
  489. {
  490. GlobalUnlock (lpdv->hMd);
  491. GlobalFree (lpdv->hMd);
  492. RETURN 0;
  493. }
  494. if (!(lpXPDV->lpScanBuf = (char _huge *)GlobalLock(lpXPDV->hScanBuf)))
  495. {
  496. GlobalUnlock (lpdv->hMd);
  497. GlobalFree (lpdv->hMd);
  498. GlobalFree (lpXPDV->hScanBuf);
  499. RETURN 0;
  500. }
  501. lpXPDV->dwScanBufSize = BUF_CHUNK;
  502. //
  503. // initialize job variables
  504. //
  505. lpXPDV->dwTotalScans = 0;
  506. lpXPDV->dwTotalScanBytes = 0;
  507. //
  508. // Set the device context parameters in a newly allocated 32 bit driver context
  509. // and save the returned pointer
  510. //
  511. DBG_TRACE3("lpData:0x%lx, lpDestDevType:%s ,lpOutputFile:%s",lpData, lpDestDevType, lpOutputFile);
  512. sRet = FaxCreateDriverContext(
  513. lpDestDevType,
  514. lpOutputFile,
  515. (LPDEVMODE)lpData,
  516. &(lpXPDV->dwPointer));
  517. if(sRet != TRUE)
  518. {
  519. if(sRet < 0)
  520. {
  521. ERROR_PROMPT(NULL,THUNK_CALL_FAIL);
  522. }
  523. DBG_CALL_FAIL("FaxCreateDriverContext",0);
  524. GlobalUnlock (lpdv->hMd);
  525. GlobalFree (lpdv->hMd);
  526. GlobalUnlock (lpXPDV->hScanBuf);
  527. GlobalFree (lpXPDV->hScanBuf);
  528. RETURN 0;
  529. }
  530. }
  531. break;
  532. case 0x0001:
  533. case 0x8001:
  534. //
  535. // Copies the device driver information to the GDIINFO structure pointed
  536. // to by lpDevInfo. GDIINFO also contains information about the sizes of
  537. // DEVMODE and PDEVICE needed by the GDI to allocate them.
  538. //
  539. {
  540. // GDIINFO far* lpgdiinfo = (GDIINFO far*)lpDevInfo;
  541. DBG_TRACE("Init GDIINFO");
  542. }
  543. break;
  544. default:
  545. DBG_TRACE("UNSUPPORTED style");
  546. }
  547. RETURN sRet;
  548. }
  549. #endif
  550. #ifndef NODISABLE
  551. void WINAPI Disable(lpdv)
  552. LPDV lpdv;
  553. {
  554. DBG_PROC_ENTRY("Disable");
  555. //
  556. // if allocated private PDEVICE data
  557. //
  558. if (lpdv->hMd)
  559. {
  560. LPEXTPDEV lpXPDV;
  561. // get pointer to our private data stored in UNIDRV's PDEVICE
  562. lpXPDV = ((LPEXTPDEV)lpdv->lpMd);
  563. ASSERT(lpXPDV);
  564. DEBUG_OUTPUT_DEVICE_POINTERS("Before calling fax disable", lpdv);
  565. // check to see if scan buffer is still around
  566. if (lpXPDV->hScanBuf)
  567. {
  568. GlobalUnlock(lpXPDV->hScanBuf);
  569. GlobalFree(lpXPDV->hScanBuf);
  570. }
  571. //
  572. // Free 32 bit driver context
  573. //
  574. FaxDisable(lpXPDV->dwPointer);
  575. //
  576. // Release our pdev
  577. //
  578. GlobalUnlock(lpdv->hMd);
  579. GlobalFree(lpdv->hMd);
  580. }
  581. UniDisable(lpdv);
  582. RETURN;
  583. }
  584. #endif
  585. #ifndef NODEVEXTTEXTOUT
  586. DWORD WINAPI DevExtTextOut(lpdv, x, y, lpCR, lpStr, count, lpFont,
  587. lpDrawMode, lpXform, lpWidths, lpOpaqRect, options)
  588. LPDV lpdv;
  589. short x;
  590. short y;
  591. LPRECT lpCR;
  592. LPSTR lpStr;
  593. int count;
  594. LPFONTINFO lpFont;
  595. LPDRAWMODE lpDrawMode;
  596. LPTEXTXFORM lpXform;
  597. LPSHORT lpWidths;
  598. LPRECT lpOpaqRect;
  599. WORD options;
  600. {
  601. DBG_PROC_ENTRY("DevExtTextOut");
  602. RETURN(UniExtTextOut(lpdv, x, y, lpCR, lpStr, count, lpFont,
  603. lpDrawMode, lpXform, lpWidths, lpOpaqRect, options));
  604. }
  605. #endif
  606. #ifndef NODEVGETCHARWIDTH
  607. short WINAPI DevGetCharWidth(lpdv, lpBuf, chFirst, chLast, lpFont, lpDrawMode,
  608. lpXForm)
  609. LPDV lpdv;
  610. LPSHORT lpBuf;
  611. WORD chFirst;
  612. WORD chLast;
  613. LPFONTINFO lpFont;
  614. LPDRAWMODE lpDrawMode;
  615. LPTEXTXFORM lpXForm;
  616. {
  617. DBG_PROC_ENTRY("DevGetCharWidth");
  618. RETURN(UniGetCharWidth(lpdv, lpBuf, chFirst, chLast, lpFont,lpDrawMode,
  619. lpXForm));
  620. }
  621. #endif
  622. #ifndef NODEVICEBITMAP
  623. short WINAPI DeviceBitmap(lpdv, command, lpBitMap, lpBits)
  624. LPDV lpdv;
  625. WORD command;
  626. LPBITMAP lpBitMap;
  627. LPSTR lpBits;
  628. {
  629. DBG_PROC_ENTRY("DeviceBitmap");
  630. RETURN 0;
  631. }
  632. #endif
  633. #ifndef NOFASTBORDER
  634. short WINAPI FastBorder(lpRect, width, depth, lRop, lpdv, lpPBrush,
  635. lpDrawmode, lpCR)
  636. LPRECT lpRect;
  637. short width;
  638. short depth;
  639. long lRop;
  640. LPDV lpdv;
  641. long lpPBrush;
  642. long lpDrawmode;
  643. LPRECT lpCR;
  644. {
  645. DBG_PROC_ENTRY("FastBorder");
  646. RETURN 0;
  647. }
  648. #endif
  649. #ifndef NOSETATTRIBUTE
  650. short WINAPI SetAttribute(lpdv, statenum, index, attribute)
  651. LPDV lpdv;
  652. WORD statenum;
  653. WORD index;
  654. WORD attribute;
  655. {
  656. DBG_PROC_ENTRY("SetAttribute");
  657. RETURN 0;
  658. }
  659. #endif
  660. //
  661. // The ExtDeviceMode function also displays a dialog box that
  662. // allows a user to select printer options such as paper size,
  663. // paper orientation, output quality, and so on. Printer
  664. // drivers written for Windows 3.x and later versions support
  665. // this function. This DDI replaces obsolete DeviceMode.
  666. //
  667. int WINAPI ExtDeviceMode(hWnd, hDriver, lpDevModeOutput, lpDeviceName, lpPort,
  668. lpDevModeInput, lpProfile, wMode)
  669. HWND hWnd; // parent for DM_PROMPT dialog box
  670. HANDLE hDriver; // handle from LoadLibrary()
  671. LPDM lpDevModeOutput;// output DEVMODE for DM_COPY
  672. LPSTR lpDeviceName; // device name
  673. LPSTR lpPort; // port name
  674. LPDM lpDevModeInput; // input DEVMODE for DM_MODIFY
  675. LPSTR lpProfile; // alternate .INI file
  676. WORD wMode; // operation(s) to carry out
  677. #define FAILURE -1
  678. {
  679. int iRc;
  680. DBG_PROC_ENTRY("ExtDeviceMode");
  681. ASSERT(!(wMode & DM_COPY) || lpDevModeOutput);
  682. DBG_TRACE2("params: lpDevModeInput:0x%lx wMode:%d",lpDevModeInput,wMode);
  683. //
  684. // We don't do anything particular here. Let unidrive manage the default devmode...
  685. //
  686. iRc = UniExtDeviceMode(hWnd,
  687. hDriver,
  688. lpDevModeOutput,
  689. lpDeviceName,
  690. lpPort,
  691. lpDevModeInput,
  692. lpProfile,
  693. wMode);
  694. if(iRc < 0)
  695. {
  696. DBG_CALL_FAIL("UniExtDeviceMode",iRc);
  697. }
  698. RETURN iRc;
  699. }
  700. #ifndef WANT_WIN30
  701. #ifndef NODMPS
  702. int WINAPI ExtDeviceModePropSheet(hWnd, hInst, lpDevName, lpPort,
  703. dwReserved, lpfnAdd, lParam)
  704. HWND hWnd; // Parent window for dialog
  705. HANDLE hInst; // handle from LoadLibrary()
  706. LPSTR lpDevName; // friendly name
  707. LPSTR lpPort; // port name
  708. DWORD dwReserved; // for future use
  709. LPFNADDPROPSHEETPAGE lpfnAdd; // Callback to add dialog page
  710. LPARAM lParam; // Pass to callback
  711. {
  712. int iRc;
  713. DBG_PROC_ENTRY("ExtDeviceModePropSheet");
  714. DBG_TRACE1("lpDevName PTR [0x%08X]",lpDevName);
  715. DBG_TRACE3("hInst:[%ld] lpDevName:[%s] lpPort:[%s]",hInst,
  716. (LPSTR)lpDevName,
  717. (LPSTR)lpPort);
  718. DBG_TRACE1("lpfnAdd:[%ld]",lpfnAdd);
  719. iRc = UniExtDeviceModePropSheet(hWnd, hInst, lpDevName, lpPort,
  720. dwReserved, lpfnAdd, lParam);
  721. if (iRc < 0)
  722. {
  723. DBG_CALL_FAIL("UniExtDeviceModePropSheet",0);
  724. }
  725. RETURN iRc;
  726. }
  727. #endif
  728. #endif
  729. #ifndef NODEVICECAPABILITIES
  730. DWORD WINAPI DeviceCapabilities(lpDevName, lpPort, wIndex, lpOutput, lpdm)
  731. LPSTR lpDevName;
  732. LPSTR lpPort;
  733. WORD wIndex;
  734. LPSTR lpOutput;
  735. LPDM lpdm;
  736. {
  737. DWORD dwCap;
  738. DBG_PROC_ENTRY("DeviceCapabilities");
  739. DBG_TRACE1("Capability index: %d",wIndex);
  740. dwCap = UniDeviceCapabilities(lpDevName,
  741. lpPort,
  742. wIndex,
  743. lpOutput,
  744. lpdm,
  745. g_hModule);
  746. DBG_TRACE1("Reporeted Capability %d", dwCap);
  747. if (DC_VERSION == wIndex )
  748. {
  749. DBG_TRACE1("Reporting DC_VERSION [0x%08X]",dwCap);
  750. }
  751. RETURN dwCap;
  752. }
  753. #endif
  754. #ifndef NOADVANCEDSETUPDIALOG
  755. LONG WINAPI AdvancedSetUpDialog(hWnd, hInstMiniDrv, lpdmIn, lpdmOut)
  756. HWND hWnd;
  757. HANDLE hInstMiniDrv; // handle of the driver module
  758. LPDM lpdmIn; // initial device settings
  759. LPDM lpdmOut; // final device settings
  760. {
  761. DBG_PROC_ENTRY("AdvancedSetUpDialog");
  762. RETURN(UniAdvancedSetUpDialog(hWnd, hInstMiniDrv, lpdmIn, lpdmOut));
  763. }
  764. #endif
  765. #ifndef NODIBBLT
  766. short WINAPI DIBBLT(lpBmp, style, iStart, sScans, lpDIBits,
  767. lpBMI, lpDrawMode, lpConvInfo)
  768. LPBITMAP lpBmp;
  769. WORD style;
  770. WORD iStart;
  771. WORD sScans;
  772. LPSTR lpDIBits;
  773. LPBITMAPINFO lpBMI;
  774. LPDRAWMODE lpDrawMode;
  775. LPSTR lpConvInfo;
  776. {
  777. DBG_PROC_ENTRY("DIBBLT");
  778. RETURN(UniDIBBlt(lpBmp, style, iStart, sScans, lpDIBits,
  779. lpBMI, lpDrawMode, lpConvInfo));
  780. }
  781. #endif
  782. #ifndef NOCREATEDIBITMAP
  783. short WINAPI CreateDIBitmap()
  784. {
  785. DBG_PROC_ENTRY("CreateDIBitmap");
  786. // CreateDIBitmap is never called by GDI.
  787. // Keep a stub function here so nobody complains.
  788. //
  789. RETURN(0);
  790. }
  791. #endif
  792. #ifndef NOSETDIBITSTODEVICE
  793. short WINAPI SetDIBitsToDevice(lpdv, DstXOrg, DstYOrg, StartScan, NumScans,
  794. lpCR, lpDrawMode, lpDIBits, lpDIBHdr, lpConvInfo)
  795. LPDV lpdv;
  796. WORD DstXOrg;
  797. WORD DstYOrg;
  798. WORD StartScan;
  799. WORD NumScans;
  800. LPRECT lpCR;
  801. LPDRAWMODE lpDrawMode;
  802. LPSTR lpDIBits;
  803. LPBITMAPINFOHEADER lpDIBHdr;
  804. LPSTR lpConvInfo;
  805. {
  806. DBG_PROC_ENTRY("SetDIBitsToDevice");
  807. RETURN(UniSetDIBitsToDevice(lpdv, DstXOrg, DstYOrg, StartScan, NumScans,
  808. lpCR, lpDrawMode, lpDIBits, lpDIBHdr, lpConvInfo));
  809. }
  810. #endif
  811. #ifndef NOSTRETCHDIB
  812. int WINAPI StretchDIB(lpdv, wMode, DstX, DstY, DstXE, DstYE,
  813. SrcX, SrcY, SrcXE, SrcYE, lpBits, lpDIBHdr,
  814. lpConvInfo, dwRop, lpbr, lpdm, lpClip)
  815. LPDV lpdv;
  816. WORD wMode;
  817. short DstX, DstY, DstXE, DstYE;
  818. short SrcX, SrcY, SrcXE, SrcYE;
  819. LPSTR lpBits; /* pointer to DIBitmap Bits */
  820. LPBITMAPINFOHEADER lpDIBHdr; /* pointer to DIBitmap info Block */
  821. LPSTR lpConvInfo; /* not used */
  822. DWORD dwRop;
  823. LPPBRUSH lpbr;
  824. LPDRAWMODE lpdm;
  825. LPRECT lpClip;
  826. {
  827. DBG_PROC_ENTRY("StretchDIB");
  828. RETURN(UniStretchDIB(lpdv, wMode, DstX, DstY, DstXE, DstYE,
  829. SrcX, SrcY, SrcXE, SrcYE, lpBits, lpDIBHdr,
  830. lpConvInfo, dwRop, lpbr, lpdm, lpClip));
  831. }
  832. #endif
  833. #if 0 // nobody is calling this DDI. Deleted.
  834. #ifndef NOQUERYDEVICENAMES
  835. long WINAPI QueryDeviceNames(lprgDeviceNames)
  836. LPSTR lprgDeviceNames;
  837. {
  838. DBG_PROC_ENTRY("QueryDeviceNames");
  839. RETURN UniQueryDeviceNames(g_hModule,lprgDeviceNames);
  840. }
  841. #endif
  842. #endif
  843. #ifndef NODEVINSTALL
  844. int WINAPI DevInstall(hWnd, lpDevName, lpOldPort, lpNewPort)
  845. HWND hWnd;
  846. LPSTR lpDevName;
  847. LPSTR lpOldPort, lpNewPort;
  848. {
  849. short sRc;
  850. int nRet;
  851. DBG_PROC_ENTRY("DevInstall");
  852. //
  853. // This call is made right after installation of the driver into the system
  854. // directory.
  855. //
  856. DBG_TRACE3("hWnd: %ld DevName: %s OldPort: %s", hWnd,lpDevName,lpOldPort);
  857. DBG_TRACE1("NewPort: %s",lpNewPort);
  858. sRc = FaxDevInstall(lpDevName,lpOldPort,lpNewPort);
  859. if(sRc < 0)
  860. {
  861. ERROR_PROMPT(NULL,THUNK_CALL_FAIL);
  862. RETURN 0;
  863. }
  864. if (!sRc)
  865. {
  866. DBG_CALL_FAIL("FaxDevInstall",0);
  867. RETURN 0;
  868. }
  869. nRet = UniDevInstall(hWnd, lpDevName, lpOldPort, lpNewPort);
  870. DBG_TRACE1("UniDevInstall() returned: %d",nRet);
  871. return nRet;
  872. }
  873. #endif
  874. #ifndef NOBITMAPBITS
  875. BOOL WINAPI BitmapBits(lpdv, fFlags, dwCount, lpBits)
  876. LPDV lpdv;
  877. DWORD fFlags;
  878. DWORD dwCount;
  879. LPSTR lpBits;
  880. {
  881. DBG_PROC_ENTRY("BitmapBits");
  882. RETURN UniBitmapBits(lpdv, fFlags, dwCount, lpBits);
  883. }
  884. #endif
  885. #ifndef NOSELECTBITMAP
  886. BOOL WINAPI DeviceSelectBitmap(lpdv, lpPrevBmp, lpBmp, fFlags)
  887. LPDV lpdv;
  888. LPBITMAP lpPrevBmp;
  889. LPBITMAP lpBmp;
  890. DWORD fFlags;
  891. {
  892. DBG_PROC_ENTRY("DeviceSelectBitmap");
  893. RETURN UniDeviceSelectBitmap(lpdv, lpPrevBmp, lpBmp, fFlags);
  894. }
  895. #endif
  896. BOOL WINAPI
  897. thunk1632_ThunkConnect16(LPSTR, LPSTR, WORD, DWORD);
  898. #ifndef NOLIBMAIN
  899. int WINAPI LibMain(HANDLE hInstance, WORD wDataSeg, WORD cbHeapSize,
  900. LPSTR lpszCmdLine)
  901. {
  902. DBG_PROC_ENTRY("LibMain");
  903. //
  904. // Save instance handle.
  905. //
  906. g_hModule = hInstance;
  907. if( !(thunk1632_ThunkConnect16( "fxsdrv.dll", // name of 16-bit DLL
  908. "fxsdrv32.dll",// name of 32-bit DLL
  909. g_hModule,
  910. 1)) )
  911. {
  912. DBG_CALL_FAIL("thunk1632_ThunkConnect16",0);
  913. RETURN FALSE;
  914. }
  915. RETURN TRUE;
  916. }
  917. #endif
  918. VOID WINAPI WEP(short fExitWindows);
  919. #pragma alloc_text(WEP_TEXT, WEP)
  920. VOID WINAPI WEP(fExitWindows)
  921. short fExitWindows;
  922. {
  923. SDBG_PROC_ENTRY("WEP");
  924. if( !(thunk1632_ThunkConnect16( "fxsdrv.dll", // name of 16-bit DLL
  925. "fxsdrv32.dll",// name of 32-bit DLL
  926. g_hModule,
  927. 0)) )
  928. {
  929. DBG_MESSAGE_BOX("thunk1632_ThunkConnect16 failed");
  930. RETURN;
  931. }
  932. RETURN;
  933. }