0%

【Linux技术分享】捕捉打印时的中间文件

捕捉打印时的中间文件

wine7.18以下

  • psdrv模块下查看PSDRV_ExtTextOut函数,会打印对应字体的样式选择
  • psdrv模块下PSDRV_SelectFont会选择字体
  • ScheduleJob函数中删除DeleteFileW(job->filename);函数,在C:\Windows\System32\spool\PRINTERS路径下存在待打印文件

高版本wine

  • 截取wine下打印数据目前在高版本wine下需要从/dlls/localspl/cups.c中打印逻辑中提取
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    --- a/dlls/localspl/cups.c
    +++ b/dlls/localspl/cups.c
    @@ -493,7 +493,24 @@ static NTSTATUS start_doc(void *args)
    static NTSTATUS write_doc(void *args)
    {
    const struct write_doc_params *params = args;
    - doc_t *doc = (doc_t *)(size_t)params->doc;
    + doc_t *doc = (doc_t *)(size_t)params->doc;
    + TRACE("\n");
    + static FILE *ps_file = NULL;
    + if (!ps_file)
    :
    + doc_t *doc = (doc_t *)(size_t)params->doc;
    + /* =========== 新增:保存 PostScript 数据 =========== */
    + static FILE *ps_file = NULL;
    + if (!ps_file)
    + {
    + ps_file = fopen("/tmp/wine_print.ps", "wb");
    :
    + doc_t *doc = (doc_t *)(size_t)params->doc;
    + TRACE("\n");
    + static FILE *ps_file = NULL;
    + if (!ps_file)
    + {
    + ps_file = fopen("/tmp/wine_print.ps", "wb");
    + if (!ps_file)
    + ERR("Failed to open PS debug file\n");
    + }
    +
    + if (ps_file)
    + {
    + fwrite(params->buf, 1, params->size, ps_file);
    + fflush(ps_file);
    + TRACE("Saved %u bytes to /tmp/wine_print.ps\n", params->size);
    :
    + doc_t *doc = (doc_t *)(size_t)params->doc;
    + TRACE("\n");
    + static FILE *ps_file = NULL;
    + if (!ps_file)
    + {
    + ps_file = fopen("/tmp/wine_print.ps", "wb");
    + if (!ps_file)
    + ERR("Failed to open PS debug file\n");
    + }
    +
    + if (ps_file)
    + {
    + fwrite(params->buf, 1, params->size, ps_file);
    + fflush(ps_file);
    + TRACE("Saved %u bytes to /tmp/wine_print.ps\n", params->size);
    + }
    return doc->write_doc(doc, params->buf, params->size);
    }