Addons Compatibility with Firefox 48 - firefox-addon

I have an addon correctly working just up to FF 47.I know that with e10s FF 48, it has some compatibility troubles. Here a brief list of the lines of code I think they are affected by the new multiprocess model of the browser:
1.let { Cc, Ci } = require('chrome');
2.const { Cu } = require("chrome");
3.require("sdk/tabs").on("ready",logURL);
4.Cu.import("resource://gre/modules/FileUtils.jsm");
5.const {TextDecoder, TextEncoder, OS} = Cu.import("resource://gre/modules/osfile.jsm", {});
6. file = FileUtils.getFile("Home", [".cp.txt"]); //reopen the file just saved
7. var txt = "";
var fstream = Cc["#mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream);
var cstream = Cc["#mozilla.org/intl/converter-input-stream;1"].createInstance(Ci.nsIConverterInputStream);
fstream.init(file, -1, 0, 0); cstream.init(fstream, "UTF-8", 0, 0); let str = {};
let read = 0;
do {
read = cstream.readString(0xffffffff, str); // read as much as we can and put it in str.value
txt += str.value;
} while (read != 0);
cstream.close(); // this closes fstream // use 0x02 | 0x10 to open file for appending. // save the domain option in file
foStream.init(file, 0x02 | 0x08 | 0x20, 0666, 0);
converter.init(foStream, "UTF-8", 0, 0);
var sEP = txt + '\n' + 'h' + '\n'; // encrypt new path converter.writeString(sEP); converter.close(); // this closes foStream
console.log('saved h'); }
I need to know, first of all, if all these elements are effectively problematic with new FF (I am pretty sure 6 and 7 are not compatible — the XUL and XPCOM are obsolete and work on the same thread —, but not so sure for the other lines), and finally if there are surrogate constructs for the 48 version in order to solve the same problems (input/output and so on). In particular, it is essential for the add-on the use of the tabs mechanism (for reading the URL of a tab). Thanks for the help.

None of these issues are e10s related, they are all es6 and xpcom questions.
If you use this in a framescript, then its a e10s question, however I avoid using xpcom in framescripts, try to use messaging from framescript to bootstrap such as this - https://github.com/Noitidart/CommPlayground
Re 1 and 2: if you are not using the Cu Ci in require'ed scripts, let and const is fine.
Re 7: Don't do this way, it will be deprecated soon, and is not main ui friendly. It can lock it up. Use OS.File.
Re 4 and 6: I recommend doing Services.dirsvc.get('Home', Ci.nsIFile).path;. This is XPCOM but it is using the common Services.jsm module, which is less likely to be depercated. Also, Services.dirsvc.get caches the files, so its much faster then FileUtils. However, ideally, you should use OS.Path.join and OS.Constants.Path which comes when you import osfile.jsm. So you would do OS.Path.join(OS.Constants.Path.homeDir, '.cp.txt') - try to avoid as much XPCOM as possible.
Re 3: This is fine.

Related

Proper PE base relocation

I'm trying to run a WIN32 PE executable from memory (not for malware just for software protection purposes). When I allocate at the desired image base address (0x00400000) it works perfectly. But this is not ideal since this address is not always available, sometimes even already in use by the current process depending on ASLR.
Instead I have to relocate the image with the new address obtained from VirtualAlloc() using this generic code.
while (pIBR->VirtualAddress)
{
if (pIBR->SizeOfBlock >= sizeof(IMAGE_BASE_RELOCATION))
{
count = (pIBR->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION)) / sizeof(WORD);
list = (PWORD)(pIBR + 1);
for (i = 0; i < count; i++)
{
if (list[i])
{
ptr = (PDWORD)((LPBYTE)image + (pIBR->VirtualAddress + (list[i] & 0xFFF)));
*ptr += delta;
}
}
}
pIBR = (PIMAGE_BASE_RELOCATION)((LPBYTE)pIBR + pIBR->SizeOfBlock);
}
which works fine for simple executable's, but more complex executable's with resources, TLS, and various other things, don't load correctly or at all.
My question, is there a better way of doing image relocation, or how can I always reserve the address 0x00400000 for my new PE image.
Thanks.

how to fix CAN connection errors?

i'm newbie to the field of automotive, i'm trying to make a connection with can bus between CAN box and aurix board and monitor this connection using CANoe software.
i'm only trying to send a simple message one time from the kit over the can bus as a start just to test the connection and make sure it works before i proceed with the rest of the application.
but all i receive from the kit on CANoe is errors like Form errors, stuff error, CRC error, CAN overload frame.
i checked the pins of the can on the board multiple times to make sure they are correct, also tried to change the CAN channel used on the CAN box, even checked the wires and every thing seems like connected correctly.
and the software i'm using is only a demo that i found inside TASKING compiler demos in the files related the the kit i'm using so i can assume it's not wrong.
the steps i followed to get it this demo to compile are simple
use the software platform builder inside TASKING IDE to attach the files related to the kit to the project.
include the CAN driver file in it "IfxMultican_Can.h"
then i copied and pasted the code inside the documentation within that header file into my project.
i did every thing i could think of to get this to work but still same errors, so it's either the connections are wrong some how or the driver code provided with TASKING IDE contains errors, there is nothing else in the system.
the code i'm using for the project is
#include <stdio.h>
#include "SoftwarePlatform/illd_tc29xb/src/ifx/TC29xB/Multican/Can/IfxMultican_Can.h"
// CAN handle
IfxMultican_Can can;
// Nodes handles
IfxMultican_Can_Node canSrcNode;
IfxMultican_Can_Node canDstNode;
// Message Object handles
IfxMultican_Can_MsgObj canSrcMsgObj;
IfxMultican_Can_MsgObj canDstMsgObj;
const unsigned id = 0x100;
int main(){
// create configuration
IfxMultican_Can_Config canConfig;
IfxMultican_Can_initModuleConfig(&canConfig, &MODULE_CAN);
//initialize module
//IfxMultican_Can can; // defined globally
IfxMultican_Can_initModule(&can, &canConfig);
// create CAN node config
IfxMultican_Can_NodeConfig canNodeConfig;
IfxMultican_Can_Node_initConfig(&canNodeConfig, &can);
canNodeConfig.baudrate = 1000000; // 1 MBaud
// Source Node
// IfxMultican_Can_Node canSrcNode; // defined globally
{
canNodeConfig.nodeId = IfxMultican_NodeId_0;
canNodeConfig.rxPin = &IfxMultican_RXD0B_P20_7_IN;
canNodeConfig.rxPinMode = IfxPort_InputMode_pullUp;
canNodeConfig.txPin = &IfxMultican_TXD0_P20_8_OUT;
canNodeConfig.txPinMode = IfxPort_OutputMode_pushPull;
// initialize the node
IfxMultican_Can_Node_init(&canSrcNode, &canNodeConfig);
}
// Destination Node
// IfxMultican_Can_Node canDstNode; // defined globally
{
canNodeConfig.nodeId = IfxMultican_NodeId_1;
canNodeConfig.rxPin = &IfxMultican_RXD1B_P14_1_IN;
canNodeConfig.rxPinMode = IfxPort_InputMode_pullUp;
canNodeConfig.txPin = &IfxMultican_TXD1_P14_0_OUT;
canNodeConfig.txPinMode = IfxPort_OutputMode_pushPull;
// initialize the node
IfxMultican_Can_Node_init(&canDstNode, &canNodeConfig);
}
// IfxMultican_Can_MsgObj canSrcMsgObj; // defined globally
{
// create message object config
IfxMultican_Can_MsgObjConfig canMsgObjConfig;
IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canSrcNode);
// assigned message object:
canMsgObjConfig.msgObjId = 0;
canMsgObjConfig.messageId = id; // 'id' is defined globally
canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
canMsgObjConfig.frame = IfxMultican_Frame_transmit;
canMsgObjConfig.control.messageLen = IfxMultican_DataLengthCode_8;
canMsgObjConfig.control.extendedFrame = FALSE;
canMsgObjConfig.control.matchingId = TRUE;
// initialize message object
IfxMultican_Can_MsgObj_init(&canSrcMsgObj, &canMsgObjConfig);
}
// IfxMultican_Can_MsgObj canDstMsgObj; // defined globally
{
// create message object config
IfxMultican_Can_MsgObjConfig canMsgObjConfig;
IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canDstNode);
// assigned message object:
canMsgObjConfig.msgObjId = 2;
canMsgObjConfig.messageId = id;
canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
canMsgObjConfig.frame = IfxMultican_Frame_receive;
canMsgObjConfig.control.messageLen = IfxMultican_DataLengthCode_8;
canMsgObjConfig.control.extendedFrame = FALSE;
canMsgObjConfig.control.matchingId = TRUE;
// initialize message object
IfxMultican_Can_MsgObj_init(&canDstMsgObj, &canMsgObjConfig);
}
const unsigned dataLow = 0xC0CAC01A;
const unsigned dataHigh = 0xBA5EBA11;
// Initialize the message structure
IfxMultican_Message txMsg;
IfxMultican_Message_init(&txMsg, id, dataLow, dataHigh, IfxMultican_DataLengthCode_8);
// Transmit Data
while( IfxMultican_Can_MsgObj_sendMessage(&canSrcMsgObj, &txMsg) == IfxMultican_Status_notSentBusy );
return 0;
}
some examples of the errors i get in CANoe
Time Chn ID Name Event Type Dir DLC Data
[-] 18.909137 CAN 1 CAN Error RxErr ECC: 100000011xxxxx, Form Error, Bit Position = 12
| ECC 100000011xxxxx
| Code Form Error
| Position 12
| ID 0010010011001b (499)
| DLC 9
| Data 00-07 00 00 00 00 00 00 00 00
another example
Time Chn ID Name Event Type Dir DLC Data
[-] 18.907080 CAN 1 CAN Error RxErr ECC: 100001001xxxxx, CRC Error, Bit Position = 36
| ECC 100001001xxxxx
| Code CRC Error
| Position 36
| ID 0010010011001b (499)
| DLC 9
| Data 00-07 00 00 00 00 00 00 00 00
i also must point that despite i only send the message once, i keep receiving a non-ending sequence of those errors until i stop the simulation.
is there any way i can use to better understand how to fix those errors?
any information about the kit pins numbering or the correct connection for can would be very helpful.
i also must point that i'm only using the driver for the can abstractly from how it works, i only understand the CAN as bus on which i'll throw a message and receive it from the other end using some functions i don't know how it actually works and the time i have is quite limit and doesn't allow me to learn that much.
board used : KIT_AURIX_TC297_TFT
, CAN box : VN6510A
You need to change your baudrate in CANOe from 500.0 to 1000.0 Kbps (as configured in infineon iLLD canNodeConfig.baudrate = 1000000; // 1 MBaud)
Also, make sure you have 120 Ohm resistor between CANH and CANL.
Try to see your output from microcontroler (CAN TX/CAN RX) in oscilloscope or logic analyser, also the output from your CAN transceiver, since you are using TFT board you already have the transceiver resistor.

Zebra Printer - Not Printing PNG Stream *Provided my own answer*

I think I'm very close to getting this to print. However it still isn't. There is no exception thrown and it does seem to be hitting the zebra printer, but nothing. Its a long shot as I think most people are in the same position I am and know little about it. Any help anyone can give no matter how small will be welcomed, I'm losing the will to live
using (var response = request.GetResponse())
{
using (var responseStream = response.GetResponseStream())
{
using (var stream = new MemoryStream())
{
if (responseStream == null)
{
return;
}
responseStream.CopyTo(stream);
stream.Position = 0;
using (var zipout = ZipFile.Read(stream))
{
using (var ms = new MemoryStream())
{
foreach (var e in zipout.Where(e => e.FileName.Contains(".png")))
{
e.Extract(ms);
}
if (ms.Length <= 0)
{
return;
}
var binaryData = ms.ToArray();
byte[] compressedFileData;
// Compress the data using the LZ77 algorithm.
using (var outStream = new MemoryStream())
{
using (var compress = new DeflateStream(outStream, CompressionMode.Compress, true))
{
compress.Write(binaryData, 0, binaryData.Length);
compress.Flush();
compress.Close();
}
compressedFileData = outStream.ToArray();
}
// Encode the compressed data using the MIME Base64 algorithm.
var base64 = Convert.ToBase64String(compressedFileData);
// Calculate a CRC across the encoded data.
var crc = Calc(Convert.FromBase64String(base64));
// Add a unique header to differentiate the new format from the existing ASCII hexadecimal encoding.
var finalData = string.Format(":Z64:{0}:{1}", base64, crc);
var zplToSend = "~DYR:LOGO,P,P," + finalData.Length + ",," + finalData;
const string PrintImage = "^XA^FO0,0^IMR:LOGO.PNG^FS^XZ";
try
{
var client = new System.Net.Sockets.TcpClient();
client.Connect(IpAddress, Port);
var writer = new StreamWriter(client.GetStream(), Encoding.UTF8);
writer.Write(zplToSend);
writer.Flush();
writer.Write(PrintImage);
writer.Close();
client.Close();
}
catch (Exception ex)
{
// Catch Exception
}
}
}
}
}
}
private static ushort Calc(byte[] data)
{
ushort wCrc = 0;
for (var i = 0; i < data.Length; i++)
{
wCrc ^= (ushort)(data[i] << 8);
for (var j = 0; j < 8; j++)
{
if ((wCrc & 0x8000) != 0)
{
wCrc = (ushort)((wCrc << 1) ^ 0x1021);
}
else
{
wCrc <<= 1;
}
}
}
return wCrc;
}
The following code is working for me. The issue was the commands, these are very very important! Overview of the command I have used below, more can be found here
PrintImage
^XA
Start Format Description The ^XA command is used at the beginning of ZPL II code. It is the opening bracket and indicates the start of a new label format. This command is substituted with a single ASCII control character STX (control-B, hexadecimal 02). Format ^XA Comments Valid ZPL II format requires that label formats should start with the ^XA command and end with the ^XZ command.
^FO
Field Origin Description The ^FO command sets a field origin, relative to the label home (^LH) position. ^FO sets the upper-left corner of the field area by defining points along the x-axis and y-axis independent of the rotation. Format ^FOx,y,z
x = x-axis location (in dots) Accepted Values: 0 to 32000 Default
Value: 0
y = y-axis location (in dots) Accepted Values: 0 to 32000
Default Value: 0
z = justification The z parameter is only
supported in firmware versions V60.14.x, V50.14.x, or later. Accepted
Values: 0 = left justification 1 = right justification 2 = auto
justification (script dependent) Default Value: last accepted ^FW
value or ^FW default
^IM
Image Move Description The ^IM command performs a direct move of an image from storage area into the bitmap. The command is identical to the ^XG command (Recall Graphic), except there are no sizing parameters. Format ^IMd:o.x
d = location of stored object Accepted Values: R:, E:, B:, and A: Default Value: search priority
o = object name Accepted Values: 1 to 8 alphanumeric characters Default Value: if a name is not specified, UNKNOWN is used
x = extension Fixed Value: .GRF, .PNG
^FS
Field Separator Description The ^FS command denotes the end of the field definition. Alternatively, ^FS command can also be issued as a single ASCII control code SI (Control-O, hexadecimal 0F). Format ^FS
^XZ
End Format Description The ^XZ command is the ending (closing) bracket. It indicates the end of a label format. When this command is received, a label prints. This command can also be issued as a single ASCII control character ETX (Control-C, hexadecimal 03). Format ^XZ Comments Label formats must start with the ^XA command and end with the ^XZ command to be in valid ZPL II format.
zplToSend
^MN
Media Tracking Description This command specifies the media type being used and the black mark offset in dots. This bulleted list shows the types of media associated with this command:
Continuous Media – this media has no physical characteristic (such as a web, notch, perforation, black mark) to separate labels. Label length is determined by the ^LL command.
Continuous Media, variable length – same as Continuous Media, but if portions of the printed label fall outside of the defined label length, the label size will automatically be extended to contain them. This label length extension applies only to the current label. Note that ^MNV still requires the use of the ^LL command to define the initial desired label length.
Non-continuous Media – this media has some type of physical characteristic (such as web, notch, perforation, black mark) to separate the labels.
Format ^MNa,b
a = media being used Accepted Values: N = continuous media Y = non-continuous media web sensing d, e W = non-continuous media web sensing d, e M = non-continuous media mark sensing A = auto-detects the type of media during calibration d, f V = continuous media, variable length g Default Value: a value must be entered or the command is ignored
b = black mark offset in dots This sets the expected location of the media mark relative to the point of separation between documents. If set to 0, the media mark is expected to be found at the point of separation. (i.e., the perforation, cut point, etc.) All values are listed in dots. This parameter is ignored unless the a parameter is set to M. If this parameter is missing, the default value is used. Accepted Values: -80 to 283 for direct-thermal only printers -240 to 566 for 600 dpi printers -75 to 283 for KR403 printers -120 to 283 for all other printers Default Value: 0
~DY
Download Objects Description The ~DY command downloads to the printer graphic objects or fonts in any supported format. This command can be used in place of ~DG for more saving and loading options. ~DY is the preferred command to download TrueType fonts on printers with firmware later than X.13. It is faster than ~DU. The ~DY command also supports downloading wireless certificate files. Format ~DYd:f,b,x,t,w,data
Note
When using certificate files, your printer supports:
- Using Privacy Enhanced Mail (PEM) formatted certificate files.
- Using the client certificate and private key as two files, each downloaded separately.
- Using exportable PAC files for EAP-FAST.
- Zebra recommends using Linear sty
d = file location .NRD and .PAC files reside on E: in firmware versions V60.15.x, V50.15.x, or later. Accepted Values: R:, E:, B:, and A: Default Value: R:
f = file name Accepted Values: 1 to 8 alphanumeric characters Default Value: if a name is not specified, UNKNOWN is used
b = format downloaded in data field .TTE and .TTF are only supported in firmware versions V60.14.x, V50.14.x, or later. Accepted Values: A = uncompressed (ZB64, ASCII) B = uncompressed (.TTE, .TTF, binary) C = AR-compressed (used only by Zebra’s BAR-ONE® v5) P = portable network graphic (.PNG) - ZB64 encoded Default Value: a value must be specified
clearDownLabel
^ID
Description The ^ID command deletes objects, graphics, fonts, and stored formats from storage areas. Objects can be deleted selectively or in groups. This command can be used within a printing format to delete objects before saving new ones, or in a stand-alone format to delete objects.
The image name and extension support the use of the asterisk (*) as a wild card. This allows you to easily delete a selected groups of objects. Format ^IDd:o.x
d = location of stored object Accepted Values: R:, E:, B:, and A: Default Value: R:
o = object name Accepted Values: any 1 to 8 character name Default Value: if a name is not specified, UNKNOWN is used
x = extension Accepted Values: any extension conforming to Zebra conventions
Default Value: .GRF
const string PrintImage = "^XA^FO0,0,0^IME:LOGO.PNG^FS^XZ";
var zplImageData = string.Empty;
using (var response = request.GetResponse())
{
using (var responseStream = response.GetResponseStream())
{
using (var stream = new MemoryStream())
{
if (responseStream == null)
{
return;
}
responseStream.CopyTo(stream);
stream.Position = 0;
using (var zipout = ZipFile.Read(stream))
{
using (var ms = new MemoryStream())
{
foreach (var e in zipout.Where(e => e.FileName.Contains(".png")))
{
e.Extract(ms);
}
if (ms.Length <= 0)
{
return;
}
var binaryData = ms.ToArray();
foreach (var b in binaryData)
{
var hexRep = string.Format("{0:X}", b);
if (hexRep.Length == 1)
{
hexRep = "0" + hexRep;
}
zplImageData += hexRep;
}
var zplToSend = "^XA" + "^FO0,0,0" + "^MNN" + "~DYE:LOGO,P,P," + binaryData.Length + ",," + zplImageData + "^XZ";
var label = GenerateStreamFromString(zplToSend);
var client = new System.Net.Sockets.TcpClient();
client.Connect(IpAddress, Port);
label.CopyTo(client.GetStream());
label.Flush();
client.Close();
var cmd = GenerateStreamFromString(PrintImage);
var client2 = new System.Net.Sockets.TcpClient();
client2.Connect(IpAddress, Port);
cmd.CopyTo(client2.GetStream());
cmd.Flush();
client2.Close();var clearDownLabel = GenerateStreamFromString("^XA^IDR:LOGO.PNG^FS^XZ");
var client3 = new System.Net.Sockets.TcpClient();
client3.Connect(IpAddress, Port);
clearDownLabel.CopyTo(client3.GetStream());
clearDownLabel.Flush();
client3.Close();
}
}
}
}
}
}
Easy once you know how.
Zebra ZPL logo example in base64
Python3
import crcmod
import base64
crc16 = crcmod.predefined.mkCrcFun('xmodem')
s = hex(crc16(ZPL_LOGO.encode()))[2:]
print (f"crc16: {s}")
Poorly documented may I say the least

Newline in text file created in jscript via activeXObject

Okay from the top:
Using the following code I can create a text file using jscript in an htm file from Internet Explorer via an ActiveX object. Yay!
However, opening the text file in Notepad I noticed new lines appear as mojibake characters (rectangular character) instead of newlines . It's fine in Sublime 2.
<html>
<head>
</head>
<script type="text/javascript">
var myStr = "The self same moment I could pray;\nAnd from my neck so free\nThe Albatross fell off, and sank\nLike lead into the sea.";
var myPath = "C:\\temp\\";
var myTextfile = "Rime.txt"
writeFile(myPath, myTextfile, myStr)
function writeFile(apath, afilename, str)
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var outFile = fso.CreateTextFile(apath + afilename, true);
outFile.WriteLine(str);
outFile.Close();
}
</script>
</body>
</html>
I also noticed that it doesn't occur when using the following from Photoshop environment (where I normally script from)
var txtFile = new File(apath + "/" + afilename);
outFile.open('w');
outFile.writeln(str);
outFile.close();
Is this just a quirk (or bonus) of ActiveX? Can I change it so it writes new lines that can be viewed properly in Notepad?
And, yes my Mother did warn me about the dangers of getting involved with ActiveX objects.
Looks like there's something wrong with character encoding. Try this instead of CreateTextFile():
var outFile = fso.OpenTextFile(apath + afilename, 2, true, 0);
2nd arg: 1 = reading, 2 = writing, 8 = appending.
3rd arg: true if non-existing file is created, false if non-existing file is not created. [optional, default = false]
4th arg: 0 = ASCII, -1 = Unicode, -2 = system default. [optional, default = 0]

Extract document name from print job

Is there a reliable way to extract a document name or job name from a postscript print job if you have the raw postscript data?
I've seen print release station software that labels each job with a document name or url it was printed from, so it seems possible.
There is no reliable way to do this, as there is no such (metadata) information in the PostScript language. If your files are DSC (Document Structuring Convention) compliant then you can look for comments. These are documented in the DSC reference manual. Valid PostScript files need not be DSC compliant.
Other than that, there is no information there to extract, at least as far as PostScript is concerned.
To extract document name from print job using C++.
#include <WinSpool.h>
wstring GetDocumentName(wstring m_strFriendlyName)
{
wstring strDocName = L"";
HANDLE hPrinter ;
if ( OpenPrinter(const_cast<LPWSTR>(m_strFriendlyName.c_str()), &hPrinter, NULL) == 0 )
{
/*OpenPrinter call failed*/
return false;
}
DWORD dwBufsize = 0;
PRINTER_INFO_2* pinfo = 0;
GetPrinter(hPrinter, 2,(LPBYTE)pinfo, dwBufsize, &dwBufsize); //Get dwBufsize
PRINTER_INFO_2* pinfo2 = (PRINTER_INFO_2*)malloc(dwBufsize); //Allocate with dwBufsize
GetPrinter(hPrinter, 2,(LPBYTE)pinfo2, dwBufsize, &dwBufsize);
DWORD numJobs = pinfo2->cJobs;
free(pinfo2);
JOB_INFO_1 *pJobInfo = 0;
DWORD bytesNeeded = 0, jobsReturned = 0;
//Get info about jobs in queue.
EnumJobs(hPrinter, 0, numJobs, 1, (LPBYTE)pJobInfo, 0,&bytesNeeded,&jobsReturned);
pJobInfo = (JOB_INFO_1*) malloc(bytesNeeded);
EnumJobs(hPrinter, 0, numJobs, 1, (LPBYTE)pJobInfo, bytesNeeded, &bytesNeeded, &jobsReturned);
JOB_INFO_1 *pJobInfoInitial = pJobInfo;
for(unsigned short count = 0; count < jobsReturned; count++)
{
if (pJobInfo != NULL)
{
strDocName = pJobInfo->pDocument; // Document name
DWORD dw = pJobInfo->Status;
}
pJobInfo++;
}
free(pJobInfoInitial);
ClosePrinter( hPrinter );
return strDocName;
}
What you might be seeing is the document name that the application submitted to the print spooler. Also, it may not be reliable but most print drivers put the document name in PJL or XML at the top of the print job. With some flexible rules you might be able to pull this data with some confidence.
This, of course, assumes that the PS data was generated by a printer drivers.

Resources