+-----------------------------------------------+
| Introduction |
| |
| 1.Symptoms |
| |
| Solution |
| |
| 2.modify pclReader.exe |
| 2.1.skip the messageBox |
| 2.2.delay loading the ptc32.dll |
| 2.3.import the api from ptc32.dll |
| 2.4.call pcl2Emf after GetOpenFileNameA |
| |
| 3.modify ptc32.dll |
| 3.1.raw,driver,waterMark in ptc32.dll |
| 3.2.pcl2raw |
| 3.3.textOutWA |
| 3.4.pclFileConvert |
| 3.5.DllMain |
| 3.6.drive_emf->creatFon_44 |
| 3.7.drive_pdf->creatFon_44 |
| |
| 4.modify pdfWrite.dll |
| 4.1.pdfwInit |
| 4.2.pdfwOpenNewDoc |
| 4.3.pdfwCloseDoc |
| 4.4.pdfwAddCharset |
| 4.5.pdfwDecAllocFont |
| 4.5.1.TrueType font attributes |
| 4.5.2.Simple Encoding |
| 4.5.3.FontDescriptor |
| |
| 5.needn't to manually modify |
| 6.after word |
+-----------------------------------------------+
Introduction:
in 2026, we can download pclreader_913.zip at
https://www.instaluj.cz/pclreader
So we can install version 9.13 of pclReader in our pc.
-------------- 1.symptoms ---------------------------------------------
From https://h30434.www3.hp.com/t5/Printers-Archive-Read-Only/Not-printing-proper-Chinese-fonts/td-p/5759390
we can see the pcl "symbol set" command has taken its effect,
because the OP(C_A_Grande) post his printed paper "this is how it's being displayed"
with cjk fonts, in 09-11-2016.
But in pclReader(2010,version 9.13), she(this exe) can NOT display cjk fonts.
That is a bug.
Actually, when this exe is running, she only show messageBox
"License Date Exceeded - Go to: http://www.pclreader.com/updates"
and exit. Of course, this software was born in 2010, and her license is just 30 days.
But after we goto the site which showed by her,
we can see "This domain is for sale".
-------------- 2.1.skip the messageBox --------------------------------
That above messageBox is shown after assert_runcode() in init_instance().
+-----------------------------------------------------------------------+
|:00460A0B 663BC8 cmp cx, ax |
|:00460A0E 7621 jbe 00460A31 |
|:00460A10 8B842488020000 mov eax, dword ptr [esp+288] |
|:00460A17 C70005000000 mov dword ptr [eax], 05 |
| ... |
|:00460A22 C7808003000005000000 mov dword ptr [ebx+380], 05 |
|:00460A2C E9E7FDFFFF jmp 00460818;//fail |
+-----------------------------------------------------------------------+
This subProc call KERNEL32.GetLocalTime() into cx,
and call KERNEL32.GetPrivateProfileString() from runCode.ini to ax.
So "cmp cx,ax" means "compare localTime to deadLine"
and "jbe 0a31" means "if(localTime <= deadLine)/*below*/{goto line_0a31}"
else{set g_err=5/*ENUM_License_Date_Exceeded*/, goto fail;}
At line_0a31, the subProc judge int bool_1c= (whether localTime is close to deadLine)?1:0.
And at line_0d35, she maybe call dlgProc("The license for %s will expire in %d day%s")
+---------------------------------------------------------------+
|:00460D35 837C241C00 cmp dword ptr [esp+1C], 0 |
|:00460D3A 7446 je 00460D82 |
| ... |
|:00460D46 8D8C2484020000 lea ecx, dword ptr [esp+284] |
|:00460D4D 51 push ecx |
|:00460D4E 55 push ebp |
|:00460D4F 50 push eax |
|:00460D50 E8DB0E0000 call 00461C30;//dlgProc |
|:00460D55 83C40C add esp, 0C |
| ... |
|:00460D62 8B1504714900 mov edx, dword ptr [00497104] |
|:00460D68 A100714900 mov eax, dword ptr [00497100] |
|:00460D6D 52 push edx |
|:00460D6E 688C4B4700 push "1";//00474B8C |
|:00460D73 83C020 add eax, 20 |
|:00460D76 50 push eax |
|:00460D77 6858284800 push "Runcode";//00482858 |
|:00460D7C FF154C444700 Call KERNEL32.WritePrivateProfileStringA
+---------------------------------------------------------------+
So, if we change the byte(memory offset==0x460A0E, file offset==0x5FE0E)
"76"(jbe)to byte "EB"(jmp),
and change the byte(memory offset==0x460D3A, file offset==0x6013A)
"74"(je) to byte "EB"(jmp),
then we can skip the messageBox.
After the codes' modifying, the pclReader.exe can run,
but exit() immediately.
-------------- 2.2.delay loading the ptc32.dll ------------------------
According from gui_user_guide.chm,
pclReader is just "sample of a standalone executable that provides an example of a user interface...
... and exercises all of the SDK functions",
and ptc32.dll is the conversion DLL "that performs conversions from PCL to other formats
(PCX, WMF, .EMF, TIFF, etc.)". Because the former delay loads the latter.
so if InitLibrary() error in the latter, then the former will fail and exit.
That similar code is called by assert_runcode() from pclInitLibrary().
+-------------------------------------------------------+
|:10075A9B 663BF0 cmp si, ax |
|:10075A9E 7614 jbe 10075AB4 |
|:10075AA0 8B4C2410 mov ecx, dword [esp+10] |
|:10075AA4 C70105000000 mov dword ptr [ecx], 05 |
|:10075AAA B905000000 mov ecx, 05 |
|:10075AAF E9FC020000 jmp 10075DB0;//fail |
+-------------------------------------------------------+
This subProc call KERNEL32.GetLocalTime() into si,
and call KERNEL32.GetPrivateProfileString() from runCode.ini to ax.
So "cmp si,ax" means "compare localTime to deadLine"
and "jbe 5a74" means "if(localTime <= deadLine)/*below*/{goto line_5a74}"
else{set g_err=5/*ENUM_License_Date_Exceeded*/, goto fail;}
At line_5d44, the subProc maybe call dlgProc("The license for %s will expire in %d day%s"),
similar to the line_0a31 of pclReader.
+-----------------------------------------------------------------------+
|:10075D44 83BC248402000000 cmp dword ptr [esp+00000284], 0 |
|:10075D4C 7542 jne 10075D90 |
|:10075D4E 8B0DECC01510 mov ecx, dword ptr [1015C0EC] |
|:10075D54 8D842484020000 lea eax, dword ptr [esp+284] |
|:10075D5B 50 push eax |
|:10075D5C 53 push ebx |
|:10075D5D 51 push ecx |
|:10075D5E E80D1B0000 call 10077870;//dlgProc |
|:10075D63 83C40C add esp, 0C |
| |
|:10075D66 83BC248402000000 cmp dword ptr [esp+00000284], 0 |
|:10075D6E 7420 je 10075D90 |
|:10075D70 8B15F0C01510 mov edx, dword ptr [1015C0F0] |
|:10075D76 A1ECC01510 mov eax, dword ptr [1015C0EC] |
|:10075D7B 52 push edx |
|:10075D7C 68F0481010 push "1";//101048F0 |
|:10075D81 83C020 add eax, 20 |
|:10075D84 50 push eax |
|:10075D85 68F8340F10 push "Runcode";//100F34F8 |
|:10075D8A FF159C320F10 Call KERNEL32.WritePrivateProfileStringA|
+-----------------------------------------------------------------------+
So, if we change the byte(memory offset==0x10075A9E, file offset==0x74E9E)
"76"(jbe)to byte "EB"(jmp),
and change the byte(memory offset==0x10075D4C, file offset==0x7514C)
"75"(jne)to byte "EB"(jmp),
then we can prevent failure from pct32.dll.
After the codes' modifying, the pclReader.exe can run now.
And we see her CAN'T display cjk fonts,
because she only use _dl_pcl2MemoryDib,
not use _dl_pcl2MemoryWmf
nor _dl_pcl2Wmf nor _dl_pcl2Emf.
The former don't call createFont(),
and the latters maybe call that api.
-------------- 2.3.import the api from ptc32.dll ----------------------
Almost all api(export from ptc32.dll) delay_loaded by pclReader.exe
follow a same pattern:
+-----------------------------------------------------------------------+
|;// int __stdcall _dl_pclxxxx(int argv0, int argv1, int argv2...) |
|:000 83EC44 sub esp, 44 |
|:003 A1605D4900 mov eax, [00495D60];//___security_cookie |
|:008 33C4 xor eax, esp |
|:00A 89442440 mov dword ptr [esp+40], eax;//cookie |
| |
|;// {if(lp_procAddr_xxx != NULL |
|:00E 833D6477490000 cmp dword ptr [lp_procAddr_xxx], 0 |
|:015 753C jne 053 |
| |
|;// || loadLib(getFullPathName("ptc32.dll")) ) |
|:017 6A00 push 00 |
|:019 8D442404 lea eax, dword ptr [esp+04];//&lp_dll_name |
|:01D 50 push eax |
|:01E 6828644700 push 00476428;//&"ptc32.dll" |
|:023 6A00 push 00 |
|:025 E8D6DEFFFF call 00406E10;//getFullPathName_406E10 |
| |
|:02A 8D4C2410 lea ecx, dword ptr [esp+10];//&lp_dll_name |
|:02E 51 push ecx |
|:02F E82CF6FFFF call 00408510;//loadLib_408510 |
|:034 83C414 add esp, 14 |
|:037 85C0 test eax, eax |
|:039 7518 jnz 053;//it means "jz 03B" |
| |
|;//=================== |
| {lp_procAddr_xxx(argv[0]);} |
|:053 8B542448 mov edx, dword ptr [esp+48];//argv[0] |
|:057 52 push edx |
|:058 FF15A8774900 call dword ptr [lp_procAddr_xxx] |
|:05E jmp 03B |
| |
|or {lp_procAddr_xxx(argv[0], argv[1]);} |
| |
|:053 8B54244C mov edx, dword ptr [esp+4C];//argv[1] |
|:057 8B442448 mov eax, dword ptr [esp+48];//argv[0] |
|:05B 52 push edx |
|:05C 50 push eax |
|:05D FF1564774900 call dword ptr [lp_procAddr_xxx] |
|:063 jmp 03B |
| |
|or {lp_procAddr_xxx(argv[0], argv[1], arg[2]);} |
| |
|:053 8B4C2450 mov ecx, dword ptr [esp+50];//argv[2] |
|:057 8B54244C mov edx, dword ptr [esp+4C];//argv[1] |
|:05B 8B442448 mov eax, dword ptr [esp+48];//argv[0] |
|:05F 51 push ecx |
|:060 52 push edx |
|:061 50 push eax |
|:062 FF159C764900 call dword ptr [lp_procAddr_xxx] |
|:068 jmp 03B |
| |
| ... |
|;//=================== |
| return; |
|:03B 8B4C2440 mov ecx, dword ptr [esp+40];//cookie |
|:03F 33CC xor ecx, esp |
|:041 E844E00300 call 00447236;//__security_check_cookie |
|:046 83C444 add esp, 44 |
|:049 C20400 ret 4*argc |
|;// } |
+-----------------------------------------------------------------------+
In loadLib(sub_408510), she loadLibrary "ptc32.dll",
and GetProcAddress lots of api from latter,
and save them to lp_procAddr_xxx
(memory from lp_pclSetCalibration_49765C to lp_pclBeginSegExtract_4977AC).
So in _dl_pclxxxx(), she judge:
if(lp_procAddr_xxx==NULL)//oh? before init?
{ret=loadLib(); //get all apis.
if(ret==0) //oh? get proc address fail?
{return;}
else{;} //get proc address ok
}
//now, lp_procAddr_xxx!=NULL
//bypass all parameters to lp_procAddr_xxx
lp_procAddr_xxx(argv0, argv1, argv2 ....)
These delay_loading funcions in pclReader.exe, their address are
from _dl_pclDeinitLibrary(sub_408E50, file offset==0x8250),
_dl_pclSetPreference(sub_408EB0, file offset==0x82b0),
_dl_pclGetPreference(sub_408F10, file offset==0x8310),
...
to _dl_pclStringFindAll(sub_409530, file offset==0x8930).
Almost all of them can be reWrite as:
int __stdcall _dl_pclxxxx(int argv0, int argv1, int argv2...)
{pattern_408ec2(argc,lp_procAddr_xxx);}
and function pattern_408ec2(file offset==0x8253~0x82af, 0x82c2~0x82df) is:
+-----------------------------------------------------------------------+
|int __fastcall pattern_408ec2(int argc@ecx, LPVOID lp_procAddr_xxx@edx)|
|:072 83EC54 sub esp, 54 |
|:075 895424 44 mov dword ptr [esp+44], edx;//lp_procAddr_xxx |
|:079 894C24 48 mov dword ptr [esp+48], ecx;//argc |
|:07D EB84 jmp 003 |
|:003 A1605D4900 mov eax, [00495D60];//___security_cookie |
|:008 33C4 xor eax, esp |
|:00A 89442440 mov dword ptr [esp+40], eax;//cookie |
| |
|;// {if(lp_procAddr_xxx != NULL |
|:00E 833a00 90909090 cmp dword ptr [edx], 00 |
|:015 753C jne 053 |
| |
|;// || loadLib(getFullPathName("ptc32.dll")) ) |
|:017 6A00 push 00 |
|:019 8D442404 lea eax, dword ptr [esp+04];//&lp_dll_name |
|:01D 50 push eax |
|:01E 6828644700 push 00476428;//&"ptc32.dll" |
|:023 6A00 push 00 |
|:025 E8D6DEFFFF call 00406E10;//getFullPathName_406E10 |
| |
|:02A 8D4C2410 lea ecx, dword ptr [esp+10];//&lp_dll_name |
|:02E 51 push ecx |
|:02F E82CF6FFFF call 00408510;//loadLib_408510 |
|:034 83C414 add esp, 14 |
|:037 85C0 test eax, eax |
|:039 7518 jnz 053;//it means "jz 03B" |
| |
| {//memmove(dst=&esp[-argc], src=argv, cnt=argc*4) |
|:053 8B4C24 48 mov ecx,dword ptr [esp+48];//argc |
|:057 8D548C 54 lea edx,[esp+54+ecx*4];//edx:=&argv[argc-1] |
|:05B EB22 jmp 07F |
|:05D 90 90 90 |
|:07F E3 08 jecxz 089 |
|:081 8B02 mov eax,[edx] |
|:083 50 push eax |
|:084 83EA 04 sub edx,4 |
|:087 E2 F8 loop 081 |
| //all args have been move to their position, now |
| |
| lp_procAddr_xxx(arg0, arg1...); |
|:089 8B42 F0 mov eax,[edx-10];//lp_procAddr_xxx |
|:08C FF10 call [eax] |
|:08E EBAB jmp 03B |
|;// } |
|;// return; |
|:03B 8B4C2440 mov ecx, dword ptr [esp+40];//cookie |
|:03F 33CC xor ecx, esp |
|:041 E8 30E30300 call __security_check_cookie;//00447236 |
|:046 8B4C24 48 mov ecx,[esp+48];//argc |
|:04A 83C4 54 add esp, 54 |
|:04D 5A pop edx;//old eip |
|:04E 8D248C lea esp,dword ptr [esp+ecx*4];//esp+=(argc*4) |
|:051 FFE2 jmp edx;//return to old eip |
|;// } |
+-----------------------------------------------------------------------+
So, the first 4 delay_loading functions in pclReader.exe, can be reWrite as:
2.3.1: _dl_pclDeinitLibrary(file offset==0x8250~0x8252, 0x82ba~0x82c1)
:00408E50 eb68 90 jmp 00408EBA
:00408EBA BA 90764900 mov edx,00497690;//lp_pclDeinitLibrary_497690
:00408EBF 6A 00 push 0
:00408EC1 59 pop ecx;//argc=0
//goto pattern_408ec2
2.3.2: _dl_pclSetPreference(file offset==0x82b0~0x82b9)
:00408EB0 BA 64774900 mov edx,00497764;//lp_pclSetPreference_497764
:00408EB5 6A 02 push 2
:00408EB7 59 pop ecx;//argc=2
:00408EB8 EB 08 jmp pattern_408ec2
2.3.3: _dl_pcl2Emf(file offset==0x82e0~0x82e9)
:00408EE0 BA F0764900 mov edx,004976F0;//lp_pcl2Emf_4976F0
:00408EE5 6A 06 push 6
:00408EE7 59 pop ecx;//argc=6
:00408EE8 EB D8 jmp pattern_408ec2
2.3.4: _dl_pclGetPreference(file offset==0x8310~0x831d)
:408F10 BA 68764900 mov edx,497668;//lp_pclGetPreference_497668
:408F15 6A 01 push 01
:408F17 59 pop ecx;//argc==1
:408F18 E9 A5FFFFFF jmp pattern_408ec2
:408F1D 90
-------------- 2.4.call pcl2Emf after GetOpenFileNameA ----------------
In pclReader.exe, if we select in her menu, that means WM_COMMAND(111h).
In her resource of menu, we can see "View Image"[ID=8007h] and "View PCL"[ID=8008h].
+---------------------------------------------------------------+
|:004789E0 dd 111h,0, 8007h, 8007h, 39h, offset sub_40D860 |
|:004789F8 dd 111h,0, 8008h 8008h, 39h, offset sub_40D8B0 |
+---------------------------------------------------------------+
sub_40D860(void){GetOpenFile_40D740("Open Image File", "All Image Files", this->0A8->10EC, 1, this->0A8->0EE4);}
sub_40D8B0(void){GetOpenFile_40D740("Open/View PCL File", "All PCL Files", this->0A8->10F4, 1, this->0A8->0FE8);}
And GetOpenFile_40D740(in its subProc) call CDocTemplate::CreateNewDocument->74,
in the above "View Image" case, that means read_file_40F740,
(btw, in the "View PCL" case, that means copy_file_name_40F500).
Both of them NOT call _dl_pcl2MemoryDib nor _dl_pcl2MemoryWmf
nor _dl_pcl2Wmf nor _dl_pcl2Emf.
Actually, if pclReader.exe know the input file extern_name is ".pcl",
she will call _dl_pcl2MemoryDib in handle WM_NCPAINT, not here WM_COMMAND.
So we can insert our code into read_file_40F740(),
to decode pcl as emf and declare the file extern_name isNOT ".pcl":
+---------------------------------------------------------------+
|int read_file_40F740(void *this, char *fileNameSrc) |
|{ |
| char tmp_str[0x108]; |
|:0040F740 81EC08010000 sub esp, 108 |
| ... |
|:0040F754 56 push esi |
|:0040F755 8BB42410010000 mov esi, [esp+110];//fileNameSrc
|:0040F75D 8BF9 mov edi, ecx;//this |
|:0040F75F 8D4F54 lea ecx, dword ptr [edi+54] |
|:0040F762 85F6 test esi, esi |
|:0040F764 7504 jne 0040F76A |
| ... |
|} |
+---------------------------------------------------------------+
We can change code in 0040F75F~0040F763(file offset=0xeb5f~0xeb63) to
:0040F75F E9 8697FFFF jmp 00408EEA
and change code in 00408EEA~00408F0F(file offset=0x82ea~0x830f),
00408F1E~00408F51(file offset=0x831e~0x8351) to
+-----------------------------------------------------------------------+
|{ |
|:00408EEA 8D4424 08 lea eax,dword ptr [esp+8];//tmp_str |
|:00408EEE 68 04010000 push 104 |
|:00408EF3 56 push esi;//fileNameSrc |
|:00408EF4 50 push eax |
|:00408EF5 E8 96080000 call strcpy_409790 |
|:00408EFA 83C4 0C add esp,0c |
| |
|;// if(strlen>5 |
|:00408EFD 83F8 05 cmp eax,5 |
|:00408F00 76 46 jbe short 00408f48 |
| |
|;// && stricmp(".PCL", p8=&(fileNameSrc[strlen-4]))==0) |
|:00408F02 03C6 add eax,esi |
|:00408F04 83E8 04 sub eax,4 |
|:00408F07 50 push eax |
|:00408F08 68 D1584700 push 004758d1;//".PCL" |
|:00408F0D EB 0F jmp short 00408f1e |
|:00408F0F 90 |
|:00408F1E E8 A01A0500 call stricmp_45a9c3 |
|:00408F23 5A pop edx |
|:00408F24 59 pop ecx |
|:00408F25 09C0 or eax,eax |
|:00408F27 75 1F jnz short 00408f48 |
| |
|;// {memcpy(p8,".raw",4); |
|:00408F29 C701 2E726177 mov dword ptr [ecx],".raw";//7761722e |
| |
|;// dl_pcl2Emf(tmp_str,fileNameSrc,300dpi,300dpi,1,NULL);
|:00408F2F 8D4424 08 lea eax,dword ptr ss:[esp+8];//tmp_str |
|:00408F33 6A 00 push 0 |
|:00408F35 6A 01 push 1 |
|:00408F37 68 2C010000 push 12c |
|:00408F3C 68 2C010000 push 12c |
|:00408F41 56 push esi;//fileNameSrc |
|:00408F42 50 push eax;//tmp_str |
|:00408F43 E8 98FFFFFF call _dl_pcl2Emf;//00408EE0 |
|;// } |
| |
|;//------------- restore code from 0040F75F ------------ |
|:00408F48 8D4F 54 lea ecx,dword ptr [edi+54] |
|:00408F4B 85F6 test esi,esi |
|:00408F4D E9 12680000 jmp 0040F764 |
|} |
+-----------------------------------------------------------------------+
Since (according from gui_user_guide.chm) pclReader.exe is just
"sample of a standalone executable that provides an example of a user interface...
... and exercises all of the SDK functions",
and ptc32.dll is the conversion DLL "that performs conversions from PCL to other formats
(PCX, WMF, .EMF, TIFF, etc.)".
So the responsibility now falls on ptc32.dll.
-------------- 3.1.raw,driver,waterMark in ptc32.dll ------------------
Why use pcl2emf?
Because in ptc32.pclFileConvert(), she can call pcl2Pcx,pcl2Tiff,pcl2Bmp,
pcl2Wmf,pcl2raw,pcl2Emf,pcl2PdfRaster,pcl2Pdf. In these functions,
only pcl2raw and pcl2Pdf support vector and multiPages, and we can check them
in pclReader's menu "file" (subMenu) "convert".
3.1.1.pcl2raw:
ptc32 can generate many emf files, or combine them into a package...
.. and named that package as ".raw" file.
And pcl2raw(char *srcfileName1, char *dstFileName2, int dpi3, int dpi4, 0, int a6)
== pcl2Emf(char *srcfileName1, char *dstFileName2, int16 dpi3, int16 dpi4, int a6)
In other words, if we call pcl2raw(sub_100092E0) with parameter5==0,
we will get same output as pcl2Emf(sub_100093E0).
Then we just export the former api: the export table in file offset==0x1512D8,
the origin data is 1512D8: dd 93e0, we change it to dd 92e0,
to export sub_100092E0 as "pcl2Emf" now.
(More precisely, the name should be "pcl2emfEx".)
3.1.2.driver:
In version 4.5 of ptc32.dll, also in ptc32.pclFileConvert(), her codes are
+-----------------------------------------------+
|if(is_bmp()==TRUE) |
| {if ( enumDrvBmp_45E7A8 == -1 ) |
| {if(enumDrvBmp_45E7A8 = search_drv("BMP") |
| {fprint("BMP driver not found."); |
| _ThrowException(stru_40EB0C, ...); |
| } |
| } |
| ... |
| } |
| else if(is_wmf()==TRUE) |
| {if(enumDrvWmf_45E7DE == -1) |
| {enumDrvWmf_45E7DE = search_drv("WMF"); |
| if ( enumDrvWmf_45E7DE == -1 ) |
| {fprint("WMF driver not found."); |
| _ThrowException(stru_40EB0C, ...); |
| } |
| } |
| ... |
| }" |
+-----------------------------------------------+
In version 9.13, her codes evolve to "drv->creatFon_44()","drv->textOutW_50()" mode.
+-------------------------------+
|LPVOID off_101532EC[11] = |
|{ |
| &off_100F50D0,//tif |
| &off_100FD890,//png |
| &off_100FD760,//xps |
| &off_100FD6B0,//pcx |
| &off_100FD5E8,//bmp |
| &off_100FD1A0,//pdf |
| &off_100FD118,//mem |
| &off_1011EF18,//wmf |
| &off_1011EF98,//pmf |
| &off_1011EBD0,//emf |
| &off_100FCF58 //eps |
|}; |
+-------------------------------+
Every drive has her own private functions(a strong smell of object oriented programming!),
example for flag_0c,dpi_10,dpi_14,
openPage_20, destructor_24,structural_28,openPage_2c,
writeTail_30, closeDoc_34,
shadedRect_40, creatFon_44, textOutA_48, dib_4c,
textOutW_50, dib_54, penBrsh_58, font_5c,
setPassBytes_60,closeTxt_64, lineGon_68,
clipRgn_70, setPassByte_74,closeTxt_78,...
3.1.3.waterMark:
ptc32.dll add waterMark by setPassBytes_60() in pdf:
+---------------------------------------------------------------+
|;//int setPassBytes_10034AC0(...) |
| |
|;// if ( dword_1016A730 |
|:10034AC0 A130A71610 mov eax, dword ptr [1016A730] |
|:10034AC5 85C0 test eax, eax |
|:10034AC7 7409 je 10034AD2 |
| |
|;// && (proc=drv->setPassBytes_60)) |
|:10034AC9 8B4060 mov eax, dword ptr [eax+60] |
|:10034ACC 85C0 test eax, eax |
|:10034ACE 7402 je 10034AD2 |
| |
|;// proc(...) |
|:10034AD0 FFE0 jmp eax |
|:10034AD2 C3 ret |
+---------------------------------------------------------------+
So, if we change the byte(memory offset==0x10034AC7, file offset==0x33ec7)
"74"(je)to byte "EB"(jmp), that will be no waterMark in pdf.
ptc32.dll add waterMark by dib_4c() in emf,wmf,tif,bmp:
int dib_10034870(int a1, int left2, int top3, int width4, int height5, int a6, int a7, int a8, int a9, int right10, int bottom11, int a12)
+-----------------------------------------------------------------------+
|;// if ( dword_1016A730 |
|:10034870 A130A71610 mov eax, dword ptr [1016A730] |
|:10034875 85C0 test eax, eax |
|:10034877 744A je 100348C3 |
| |
|;// && (proc=drv->dib_4c)) |
|:10034879 8B404C mov eax, dword ptr [eax+4C] |
|:1003487C 85C0 test eax, eax |
|:1003487E 7443 je 100348C3 |
| |
|;// return proc(a1,left2,top3,...bottom11,a12); |
|:10034880 8B4C2430 mov ecx, dword [esp+30];//a12 |
|:10034884 8B54242C mov edx, dword [esp+2C];//bottom11 |
|:10034888 51 push ecx |
| ... |
|:100348BA 51 push ecx;//left2 |
|:100348BB 52 push edx;//a1 |
|:100348BC FFD0 call eax;//proc |
|:100348BE 83C430 add esp, 30 |
|:100348C1 98 cwde |
|:100348C2 C3 ret |
| |
|;// else return(1) |
|:100348C3 B801000000 mov eax, 00000001 |
|:100348C8 C3 ret |
+-----------------------------------------------------------------------+
So, if we change the byte(memory offset==0x10034877, file offset==0x33c77)
"74"(je)to byte "EB"(jmp), that will be no waterMark in pdf.
ptc32.dll add waterMark by raster_1003C190():
+---------------------------------------------------------------+
|;// if(WarnPassRaster |
|:10021E8F 66833D346C161000 cmp word ptr [10166C34], 0000 |
|:10021E97 7429 je 10021EC2 |
| |
|;// && messageBox(0,"Raster data detected,\ |
|;// but Pass Raster Data preference is off.\|
|;// Turn preference on ?", |
|;// MB_ICONQUESTION | MB_YESNO)== IDYES ) |
|:10021E99 6A24 push 00000024;//(MB_ICONQUESTION | MB_YESNO)
|:10021E9B 68C0FE1510 push 1015FEC0 |
|:10021EA0 6810480F10 push 100F4810;//"Raster data detected, but Pass Raster Data preference is off. Turn preference on ?"
|:10021EA5 6A00 push 00000000 |
|:10021EA7 E8C4BD0000 call messageBox;//1002DC70 |
|:10021EAC 83C410 add esp, 10 |
|:10021EAF 83F806 cmp eax, 00000006;//IDYES |
|:10021EB2 750E jne 10021EC2 |
| |
|;// {raster_preference = TRUE;} |
|:10021EB4 B901000000 mov ecx, 00000001 |
|:10021EB9 66890D205D1610 mov word ptr [10165D20], cx |
|:10021EC0 EB33 jmp 10021EF5 |
| |
| |
|;// if(raster_preference == FALSE) |
|:10021EC2 66833D205D161000 cmp word ptr [10165D20], 0000 |
|:10021ECA 7529 jne 10021EF5 |
| |
|;// {fprintf("Raster data detected, but Pass Raster Data preference is off.")
|:10021ECC 68D0470F10 push 100F47D0;//"Raster data detected, but Pass Raster Data preference is off."
|:10021ED1 E8BABC0000 call fprintf;1002DB90 |
|:10021ED6 83C404 add esp, 00000004 |
|:10021ED9 C644241B01 mov [esp+1B], 01 |
| |
|;// if(raster_preference == FALSE |
|:10021EDE 66833D205D161000 cmp word ptr [10165D20], 0000 |
|:10021EE6 750D jne 10021EF5 |
| |
|;// && isnt_object_10034570()==TRUE) |
|:10021EE8 E883260100 call 10034570 |
|:10021EED 85C0 test eax, eax |
| |
|;// {goto next_object;} |
|:10021EEF 0F85BE000000 jne 10021FB3 |
|;// } |
| |
|;// raster_1003C190(...) |
|:10021EF5 55 push ebp |
|:10021EF6 6A00 push 00000000 |
|:10021EF8 56 push esi |
|:10021EF9 E892A20100 call 1003C190 |
|:10021EFE 8BF8 mov edi, eax |
|:10021F00 83C40C add esp, 0000000C |
|:10021F03 897C2424 mov dword ptr [esp+24], edi |
|:10021F07 E9A3000000 jmp 10021FAF |
|:10021FAF FF442414 inc [esp+14] |
| |
|;//next_object |
|:10021FB3 |
+---------------------------------------------------------------+
So, if we change the byte(memory offset==0x10021EF9, file offset==0x212F9)
E8"92A2"0100 to byte E8"7226"0100(call 10034570), that will be no waterMark in image.
and the function raster_1003C190() will be overlay at 3.6.
3.1.4.kanji
At sub_10027CF0(parm), she switch(dword_101684BC){...}
(this switch offset is at 10027DB8)
in case 38(loc_10027D49), judge whether parm>=0x80.
+---------------------------------------+
|:10027D44 5E pop esi |
|:10027D45 33C0 xor eax, eax |
|:10027D47 5B pop ebx |
|:10027D48 C3 ret |
| |
|:10027D49 33C0 xor eax, eax |
|:10027D4B 81FB80000000 cmp ebx, 080 |
|:10027D51 5E pop esi |
|:10027D52 0F9DC0 setnl al |
|:10027D55 5B pop ebx |
|:10027D56 C3 ret |
| |
|:10027DB8 DWORD 10027D49 |
+---------------------------------------+
We can change this switch to loc_10027D44 to treat equally with ascii and kanji.
In other word, we change the byte(memory offset==0x10027DB8,
file offset==0x271B8)"49" to byte "44".
-------------- 3.2.pcl2raw --------------------------------------------
The pcl2raw() in ptc32.dll is:
int pcl2raw(char *srcfileName1, char *dstFileName2, int dpi3, int dpi4, int a5, int a6)
{
if ( dword_101603FC ){return result = 0;}
...
}
Then who set dword_101603FC !=0 ?
If we search in all dll, we can seek
+---------------------------------------------------------------------------------------+
|:10003304 F6051404161040 test byte ptr [10160414], 40 |
|:1000330B 7441 je 1000334E |
|:1000330D 68DA5F1610 {push 10165FDA |
|:10003312 E8C9B30200 call 1002E6E0 |
|:10003317 83C404 add esp, 00000004 |
|:1000331A E871B40200 call 1002E790 |
|:1000331F 85C0 test eax, eax |
|:10003321 7517 jne 1000333A |
|:10003323 33C0 {xor eax, eax |
|:10003325 8B8C2404010000 mov ecx, dword [esp+0104];//cookie |
|:1000332C 33CC xor ecx, esp |
|:1000332E E80DE70A00 call __security_check_cookie;//100B1A40 |
|:10003333 81C408010000 add esp, 00000108 |
|:10003339 C3 ret |
| } |
|:1000333A 6A01 else {push 00000001 |
|:1000333C E87FEB0000 call 10011EC0 |
|:10003341 83C404 add esp, 00000004 |
|:10003344 C705FC03161001000000 mov dword ptr [101603FC], 00000001 |
| } |
| } |
|:1000334E F7051404161000010000 test dword ptr [10160414], 00000100 |
+---------------------------------------------------------------------------------------+
|:10007485 E806730200 call 1002E790 |
|:1000748A 85C0 test eax, eax |
|:1000748C 0F849F000000 je 10007531 |
|:10007492 6A01 push 01 |
|:10007494 E827AA0000 call 10011EC0 |
|:10007499 83C404 add esp, 04 |
|:1000749C C705FC03161001000000 mov dword ptr [101603FC], 00000001 |
|:100074A6 8B4C240C mov ecx, dword ptr [esp+0C] |
|:100074AA 64890D00000000 mov dword ptr fs:[00000000], ecx |
|:100074B1 59 pop ecx |
|:100074B2 5F pop edi |
|:100074B3 5E pop esi |
|:100074B4 83C40C add esp, 0C |
|:100074B7 C3 ret |
+---------------------------------------------------------------------------------------+
So, if we change the byte(memory offset==0x10003321, file offset==0x2721)
75"17"(jne 333A)to byte 75"2B"(jne 334E),
and change the byte(memory offset==0x10007492, file offset==0x6892)
6A01 to byte EB12(jmp 100074A6),
that will be nobody set dword_101603FC =1;
-------------- 3.3.textOutWA ------------------------------------------
In function textOutWA_1001F780(),
she has NOT use IsDBCSLeadByte() to which text can be separated,
and NOT use MultiByteToWideChar() to make unicode string,
she only use local variable "is_unicode" to...
... judge whether textOutA or textOutW. bug!
OK, without MultiByteToWideChar, it only can be textOutA,
so "is_unicode" must be zero.
+-------------------------------------------------------+
|:1001F7DD 33FF xor edi, edi |
|... |
| if(drv->textOutW_50==NULL |
|:1001F915 E806500100 call 10034920 |
|:1001F91A 85C0 test eax, eax |
|:1001F91C 7448 je 1001F966 |
|... |
| || ! stricmp("symbol", font_name) |
|:1001F92A 8D54247E lea edx, dword ptr [esp+7E] |
|:1001F92E 52 push edx |
|:1001F92F 6890470F10 push 100F4790;//"symbol"|
|:1001F934 E861330900 call stricmp;//100B2C9A |
|:1001F939 83C408 add esp, 08 |
|:1001F93C 85C0 test eax, eax |
|:1001F93E 7426 je 1001F966 |
| |
| || ! stricmp("wingdings", font_name)) |
|:1001F940 8D44247E lea eax, dword ptr [esp+7E] |
|:1001F944 50 push eax |
|:1001F945 6884470F10 push 100F4784;//"wingdings"
|:1001F94A E84B330900 call stricmp;//100B2C9A |
|:1001F94F 83C408 add esp, 08 |
|:1001F952 85C0 test eax, eax |
|:1001F954 7410 je 1001F966 |
| {is_unicode = FALSE;} |
|:1001F966 897C2430 mov [esp+30], edi |
| else {is_unicode = TRUE;} |
|:1001F956 C744243001000000 mov [esp+30], 01 |
|:1001F95E EB0A jmp 1001F96A |
+-------------------------------------------------------+
So, if we change the byte(memory offset==0x1001F91C, file offset==0x1ed1c)
"74"(je) to byte "EB"(jmp), then is_unicode is sure zero.
-------------- 3.4.pclFileConvert -------------------------------------
The function pclFileConvert(sub_100A4BB0) will check version conflict
and call listBox_add_string,
+-------------------------------------------------------------------------------+
|:100A4BCD 33DB xor ebx, ebx |
|:100A4BEB E82002F6FF call check_ver_conflict_10004E10 |
|:100A4BF0 85C0 test eax, eax |
|:100A4BF2 7508 jne 100A4BFC |
|:100A4BF4 8D4302 lea eax, dword ptr [ebx+02] |
|:100A4BF7 E962020000 jmp 100A4E5E;//return |
| |
|:100A4C50 0FBFC2 movsx eax, dx |
|:100A4C53 C1E004 shl eax, 04 |
|:100A4C56 6685B83CDF1110 test word ptr [eax+1011DF30+0c], di |
|:100A4C5D 7527 jnz 100A4C86 |
|;// {memcpy(ecx,&(str_1011DF30[eax]),0x10); |
|:100A4C5F 8BA830DF1110 mov ebp, dword ptr [eax+1011DF30] |
|:100A4C65 8929 mov dword ptr [ecx], ebp |
|:100A4C67 8BA834DF1110 mov ebp, dword ptr [eax+1011DF30+4] |
|:100A4C6D 896904 mov dword ptr [ecx+04], ebp |
|:100A4C70 8BA838DF1110 mov ebp, dword ptr [eax+1011DF30+8] |
|:100A4C76 8B803CDF1110 mov eax, dword ptr [eax+1011DF30+C] |
|:100A4C7C 896908 mov dword ptr [ecx+08], ebp |
|:100A4C7F 89410C mov dword ptr [ecx+0C], eax |
|:100A4C82 46 inc esi |
|:100A4C83 83C110 add ecx, 10 |
|:100A4C86 42 inc edx |
| } |
|:100A4C87 6683FA0A cmp dx, 0A |
|:100A4C8B 72C3 jb 100A4C50 |
+-------------------------------------------------------------------------------+
|;//int check_ver_conflict_10004E10(void) |
|;// {if(runcode_valid_1016046C |
|:10004E24 833D6C04161000 cmp dword ptr [1016046C], 00000000 |
|:10004E2B 7516 jne 10004E43 |
| |
|;// && (runcode_err_1016048C==0 |
|:10004E43 833D8C04161000 cmp dword ptr [1016048C], 00000000 |
|:10004E4A 7509 jne 10004E55 |
| |
|;// && (runcode_attr_10160414 & CONFLICT/*0x1c*/)==0 ) |
|:10004E4C F605140416101C test byte ptr [10160414], 1C |
|:10004E53 7418 je 10004E6D |
| |
|;// ... ){return 1;}//success |
|:10004E6D B801000000 {mov eax, 01;//success |
|:10004E72 8B8C2490010000 mov ecx, dword [esp+190];//cookie |
|:10004E79 33CC xor ecx, esp |
|:10004E7B E8C0CB0A00 call __security_check_cookie;//100B1A40 |
|:10004E80 81C494010000 add esp, 00000194 |
|:10004E86 C3 ret |
| } |
| |
|;// else if(!runcode_valid_1016046C) |
|;// {MessageBeep(MB_ICONWARNING); |
|:10004E2D 6A30 push 30 |
|:10004E2F FF1584330F10 Call USER32.MessageBeep |
| |
|;// MessageBox(0,"Expired or invalid runcode in .INI file",MB_ICONWARNING);
|:10004E35 6A30 push 30 |
|:10004E37 68C0FE1510 push 1015FEC0 |
|:10004E3C 6868360F10 push 100F3668;//"Expired or invalid runcode in .INI file"
|:10004E41 EB79 jmp 10004EBC |
|:10004EBC 6A00 push 00 |
|:10004EBE E8AD8D0200 call MessageBox;//1002DC70 |
|;// } |
|;// else {sprintf(tmp_str,"This program is using %s.\ |
|;// A version conflict error has been detected.", |
|;// getNameFromIni()); |
|:10004E87 E8B4E0FFFF call getNameFromIni_10002F40 |
|:10004E8C 68C0FE1510 push 1015FEC0 |
|:10004E91 68C0FE1510 push 1015FEC0 |
|:10004E96 8D4C2408 lea ecx, dword ptr [esp+08];//tmp_str |
|:10004E9A 68C0350F10 push 100F35C0;//"This program is using %s. A version conflict error has been detected."
|:10004E9F 51 push ecx |
|:10004EA0 E820D90A00 call sprintf;//100B27C5 |
|:10004EA5 83C410 add esp, 00000010 |
| |
|;// MessageBeep(MB_ICONWARNING); |
|:10004EA8 6A30 push 00000030 |
|:10004EAA FF1584330F10 Call USER32.MessageBeep |
| |
|;// MessageBox(0,tmp_str,MB_ICONWARNING); |
|:10004EB0 6A30 push 00000030 |
|:10004EB2 68C0FE1510 push 1015FEC0 |
|:10004EB7 8D542408 lea edx, dword ptr [esp+08];//tmp_str |
|:10004EBB 52 push edx |
|:10004EBC 6A00 push 00 |
|:10004EBE E8AD8D0200 call MessageBox;//1002DC70 |
| } |
|;// return 0;//fail |
|:10004EC3 8B8C24A0010000 mov ecx, dword [esp+1A0];//cookie |
|:10004ECA 83C410 add esp, 10 |
|:10004ECD 33CC xor ecx, esp |
|:10004ECF 33C0 xor eax, eax;//fail |
|:10004ED1 E86ACB0A00 call __security_check_cookie;//100B1A40 |
|:10004ED6 81C494010000 add esp, 00000194 |
|:10004EDC C3 ret |
+-------------------------------------------------------------------------------+
If detect version conflict error, sub_10004E10() will show
"A version conflict error has been detected."
So, if we change the byte(memory offset==0x10004E53, file offset==0x4253)74 to byte EB(jmp),
then we can skip the messageBox.
If the mask don't match str_1011DF30 in 100A4C5D, pclFileConvert() don't copy strings,
then listBox will less them.
So, if we change the byte(memory offset==0x100A4C5D, file offset==0xa405d)
7527 to byte "9090"(nop), then all string can been showed.
-------------- 3.5.DllMain --------------------------------------------
The DllMain(sub_10008ED0) will judge whether she is called by PT32.EXE,FV32.EXE,
TV32.EXE,PV32.EXE,PCLT32.EXE,PCLTOOL.EXE,PCLVIEW.EXE,
if not, she maybe activate pclInitLibrary().
+---------------------------------------------------------------+
|:10008EE4 8B442404 mov eax, [esp+04];//hinstDLL |
|:10008EE8 56 push esi |
|:10008EE9 8B35AC320F10 mov esi, [100F32AC];//GetModuleHandleA
|:10008EEF A37CF81510 mov [1015F87C], eax |
|:10008EF4 7428 jz 10008F1E |
|:10008EF6 68E8390F10 push 100F39E8;//"PT32.EXE" |
|:10008EFB FFD6 call esi |
|:10008EFD 85C0 test eax, eax |
|:10008EFF 7545 jne 10008F46 |
|:10008F01 68DC390F10 push 100F39DC;//"FV32.EXE" |
|:10008F06 FFD6 call esi |
|:10008F08 85C0 test eax, eax |
|:10008F0A 753A jne 10008F46 |
|:10008F0C 68D0390F10 push 100F39D0;//"TV32.EXE" |
|:10008F11 FFD6 call esi |
|:10008F13 85C0 test eax, eax |
|:10008F15 752F jne 10008F46 |
|:10008F17 68C4390F10 push 100F39C4;//"PV32.EXE" |
| ... |
+---------------------------------------------------------------+
So, if we change the byte(memory offset==0x10008EF4, file offset==0x82f4)
7428 to byte EB50(jmp 10008F46), she can goto that position without judge.
-------------- 3.6.drive_emf->creatFon_44 -----------------------------
drive_emf is off_1011EBD0, her creatFon_44() is fontCharset_100AA310.
+-----------------------------------------------------------------------+
|;//int __cdecl fontCharset_100AA310(..) |
|:100AA3FF 53 push ebx;//defOrSym_6 |
|:100AA400 51 push ecx;//oriente_5 |
|:100AA401 52 push edx |
|:100AA402 50 push eax |
|:100AA403 8D8C24F000.. lea ecx, dword ptr [esp+0F0] |
|:100AA40A 55 push ebp;//height |
|:100AA40B 51 push ecx;//fontname |
|:100AA40C 8D74247C lea esi, dword ptr [esp+7C];//&lf |
|:100AA410 E8BBF2FFFF call makeFon_100A96D0 |
|:100AA415 83C418 add esp, 18 |
| |
|:100AA418 8BD6 mov edx, esi;//&lf |
|:100AA41A 52 push edx |
|:100AA41B FF1590300F10 Call GDI32.CreateFontIndirectA |
| |
|:100AA424 85C0 test eax, eax |
|:100AA426 751F jne 100AA447 |
|:100AA428 B838ED1110 mov eax, 1011ED38;//"Error creating EMF File - CreateFontIndirect"
|:100AA42D E84E8DFAFF call throw_10053180 |
|:100AA432 8B8C2408010000 mov ecx, dword ptr [esp+108] |
|:100AA439 33CC xor ecx, esp |
|:100AA43B E800760000 call __security_check_cookie;//100B1A40 |
|:100AA440 81C40C010000 add esp, 0000010C |
|:100AA446 C3 ret |
|:100AA447 |
+-----------------------------------------------------------------------+
she call makeFon_100A96D0() to fill member into struct LOGFONTA{};
and makeFon_100A96D0 is:
+-------------------------------------------------------+
|;//int makeFon_100A96D0(LOGFONTA* lf@<esi>, int fontname2, int16 height3, char a4, int16 a5, int16 oriente6, char defOrSym_7)
|;// lf->lfCharSet = (defOrSym_7 == 0) + 1; |
|;// //1(DEFAULT_CHARSET) or 2(SYMBOL_CHARSET) |
|:100A9788 8A5C2424 mov bl, byte [esp+24];//defOrSym_7
|:100A978C 84DB test bl, bl |
|:100A978E 0F94C1 sete cl |
|:100A9791 FEC1 inc cl |
|:100A97AA 884E17 mov byte ptr [esi+17], cl |
| |
|;// lf->lfPitchAndFamily = (a5 != 0); |
|:100A9793 66397C241C cmp word ptr [esp+1C], di |
|:100A9798 8D7E1C lea edi, dword ptr [esi+1C] |
|:100A979B 0F95C2 setne dl |
|:100A979E 88561B mov byte ptr [esi+1B], dl |
| |
|;// lf->lfUnderline = (a4 & 0x24)!= 0; |
|:100A97A3 884615 mov byte ptr [esi+15], al |
| |
|;// lf->lfStrikeOut = 0; |
|:100A97A6 C6461600 mov [esi+16], 00 |
| |
|;// lf->lfOutPrecision = 7; //OUT_TT_ONLY_PRECIS |
|:100A97AD C6461807 mov [esi+18], 07 |
| |
|;// lf->lfClipPrecision = 0; |
|:100A97B1 C6461900 mov [esi+19], 00 |
| |
|;// lf->lfQuality = 2;//PROOF_QUALITY |
|:100A97B5 C6461A02 mov [esi+1A], 02 |
| |
|;// strcpy(lf->lfFaceName, fontname2); |
|:100A97A1 8BD7 mov edx, edi;//&lf->lfFaceName |
|:100A97B9 8BC5 mov eax, ebp;//fontname2 |
|:100A97BB 2BD5 sub edx, ebp |
|;100A97BD 8D4900 lea ecx, [ecx] |
|:100A97C0 8A08 mov cl, byte ptr [eax] |
|:100A97C2 880C02 mov byte [edx+eax], cl |
|:100A97C5 40 inc eax |
|:100A97C6 84C9 test cl, cl |
|:100A97C8 75F6 jne 100A97C0 |
|:100A97CA 84DB test bl, bl |
|:100A97CC 7472 je 100A9840 |
+-------------------------------------------------------+
As you see: she set lf->lfCharSet only will be DEFAULT_CHARSET(1)
or SYMBOL_CHARSET(2), and copy fontName at 100A97B9, ignore "symbol set"
then any cjk font will NOT be display.
So, if we change the byte(memory offset==0x100A97B9, file offset==0xa8bb9)
to byte E9CA29F9FF 9090(jmp 1003C188), to set the correct lfCharSet.
+---------------------------------------------------------------+
|;// charSet=get_CharSet_from_symbolSet() |
|1003C188(8B4424 28) mov eax,[esp+28];//old esi |
|1003C18C(8B 40 06) mov eax,dword ptr [eax+6];//symbol set|
|1003C18F(E8 14000000) call 1003C1A8 |
| |
|;// if(is cjk charSet) |
|1003C194(75 07) jne 1003C19D |
| |
|;// {lf->lfCharSet = charSet; |
|1003C196(8846 17) mov byte ptr [esi+17],al |
|1003C199(33DB) xor ebx,ebx |
|1003C19B(EB 06) jmp 1003C1A3 |
|;// } |
|;// else {//restore code from 100A97A1,100A97B9 |
|1003C19D(8BD7) mov edx,edi |
|1003C19F(8BC5 mov eax, ebp |
|1003C1A1(2BD5) sub edx, ebp |
|;// } |
|1003C1A3(E9 20D60600) jmp 100A97C8 |
+---------------------------------------------------------------+
and the function get_CharSet_from_symbolSet() is:
+-------------------------------------------------------------------------------+
|1003C1A8(80FC 02) cmp ah,2 |
|1003C1AB(75 1A) jnz 1003C1C7 |
|1003C1AD(3C 6B) cmp al,6b;//19"k"(Symbol Set=Japanese Windows 3.1J) |
|1003C1AF(74 12) je 1003C1C3 |
|1003C1B1(3C 54) cmp al,54;//18"T"(Symbol Set=Big 5) |
|1003C1B3(74 0C) je 1003C1C1 |
|1003C1B5(3C 48) cmp al,48;//18"H"(Symbol Set=KS C 5601) |
|1003C1B7(74 06) je 1003C1BF |
|1003C1B9(3C 43) cmp al,43;//18"C"(Symbol Set=GB 2312) |
|1003C1BB(75 0A) jnz 1003C1C7 |
|1003C1BD(04 0A) add al,0a;//43+0a+5+1f+15=86;//GB2312_CHARSET |
|1003C1BF(04 05) add al,5 ;//48+ 5+1f+15=81;//HANGUL_CHARSET |
|1003C1C1(04 1F) add al,1f;//54+ 1f+15=88;//CHINESEBIG5_CHARSET |
|1003C1C3(04 15) add al,15;//6b +15=80;//SHIFTJIS_CHARSET |
|1003C1C5(32E4) xor ah,ah |
|1003C1C7(C3) retn |
+-------------------------------------------------------------------------------+
So, after we change the byte(memory offset==0x1003C188~0x1003C1C7,
file offset==0x3b588~0x3b5c7) as above,
(of course, that will overlay function raster_1003C190(), but nobody call it now.)
in menu "file" -> subMenu "Open Image File",(we input "*.pcl" first,
and select C_A_Grande.pcl), she can display cjk fonts now.
If we just want to see pcl, we needn't 3.7 nor 4.modify pdfWrite.dll any more.
note:
More precisely, 0x243 is named "Kind1 Value" by HP's document <<PCL 5 Comparison Guide>>,
we can download the document at https://www.hp.com/ctg/Manual/bpl13206.pdf .
HP give formula for "Kind1 Value" in that document as
Kind1_Value = (Escape Sequence Value)*32 +(Termination Character-64).
for example, because symbol_set_GB2312=18C, so Kind1_Value_GB2312
= 18*32 + ('C'-64) = 0x240 + (0x43-0x40) = 0x243.
At here, we still call 0x243 as symbolSet, just for convenience.
-------------- 3.7.drive_pdf->creatFon_44 -----------------------------
drive_pdf is off_100FD1A0, her creatFon_44() is fontCharset_10054240.
+---------------------------------------------------------------+
|;//int fontCharset_10054240(int16 a1, int16 a2, int16 wiu3, int16 width4, int16 oriente5, char defOrSym_6)
| |
|;// charSet=get_charSet_10068020(); |
|:10054295 E8863D0100 call get_charSet_10068020 |
|:1005429A 89442418 mov dword ptr [esp+18], eax |
| |
|;//makeFont_100665C0(a1+1, wiu3, &font, &v42, &baseFont) |
|;// (write font.name[]) |
|:1005429E 0FBF84245C060000 movsx eax, word ptr [esp+65C] |
|:100542A6 0FBFBC2460060000 movsx edi, word ptr [esp+660];//combine(width,itali,underLine)
|:100542AE 0FBFB42458060000 movsx esi, word ptr [esp+658] |
|:100542BB 8D4C241C lea ecx, dword ptr [esp+1C];//&{BaseFont,FirstChar,LastChar};//see also pdfWrite.1000A545
|:100542BF 51 push ecx |
|:100542C0 8D542440 lea edx, dword ptr [esp+40] |
|:100542C4 52 push edx |
|:100542C5 89442430 mov dword ptr [esp+30], eax |
|:100542C9 8D8424B4000000 lea eax, dword ptr [esp+0B4];//&font
|:100542D0 50 push eax |
|:100542D1 8D4E01 lea ecx, dword ptr [esi+01] |
|:100542D4 57 push edi;//combine(width,itali,underLine)
|:100542D5 51 push ecx |
|:100542D6 E8E5220100 call makeFont_100665C0 |
|:100542DB 0FBF9424EC000000 movsx edx, word ptr [esp+0EC] |
|:100542E3 0FBF8424EA000000 movsx eax, word ptr [esp+0EA] |
|:100542EB 83C414 add esp, 14 |
+---------------------------------------------------------------+
First, which she call, the function get_charSet_10068020() return incorrect value.
Second, she has NOT call IsDBCSLeadByte to separate her text(like 3.3),
she only use GetPrivateProfileIntA("Misc", "PlacePdfPerChar", ..., ptc32.ini)
get a bit(0x100) into dword_1018338C, we can macro this bit as PLACEPDFPERCHAR.
A shadow of it, is dword_1016A0EC.
So, if we change the byte(memory offset==0x100542DB, file offset==0x536db)
to byte E9 E87EFEFF 909090(jmp 1003C1C8), to set the correct lfCharSet.
+-----------------------------------------------------------------------+
|;// zf = get_CharSet_from_symbolSet() |
|1003C1C8(8B5424 1c) mov edx,[esp+1c] |
|1003C1CC(0FB742 06) movzx eax,word ptr ds:[edx+6];//symbol set
|1003C1D0(50) push eax |
|1003C1D1(E8 D2FFFFFF) call 1003C1A8 |
|1003C1D6(58) pop eax |
|;// if(is cjk charSet) |
|1003C1D7(75 0C) jne 1003C1E5 |
| |
|;// {charSet = symbol_set |
|1003C1D9(894424 2c) mov [esp+14+18],eax |
| |
|;// font.name[0]='\0' |
|;// } |
|1003C1DD(C68424 C2000000 00) mov byte ptr [esp+14+AE],0 |
|1003C1E5(E9 0CCDFCFF) jmp 10008EF6 |
| |
|10008EF6(B8 8D331810) mov eax,1018338d |
|10008EFB(75 05) jnz 10008F02 |
|;// if(is cjk charSet) |
|;// dword_1018338C.PlacePdfPerChar = 0 |
|10008EFD(8020 FE) and byte [eax],0fe |
|10008F00(EB 08) jmp 10008F0A |
| |
|;// else dword_1018338C.PlacePdfPerChar = dword_1016A0EC.PlacePdfPerChar
|10008F02(8A15 EDA01610) mov dl,[1016A0ED] |
|10008F08(8810) mov [eax],dl |
| |
|;// restore code from 100542DB |
|10008F0A(0FBF9424 EC000000) movsx edx, word ptr [esp+0EC] |
|10008F12(E9 CCB30400) jmp 100542E3 |
+-----------------------------------------------------------------------+
After we change the
byte(memory offset==0x1003C1C8~0x1003C1E9,file offset==0x3b5c8~0x3b5e9
and memory offset==0x10008EF6~0x10008F16, file offset==0x82F6~0x8316)
as above,
(and change some reloction in file offset==0x163a1a~0x163a1d)
the responsibility now falls on pdfWrite.dll.
-------------- 4.1.pdfwInit -------------------------------------------
Like 3.1, that similar code is called by assert_runcode() from pdfwInit().
+-------------------------------------------------------+
|:1001184E 663BF8 cmp di, ax |
|:10011851 7611 jbe 10011864 |
|:10011853 8B442410 mov eax, dword ptr [esp+10] |
|:10011857 C70005000000 mov dword ptr [eax], 05 |
|:1001185D 6A05 push 05 |
|:1001185F E909030000 jmp 10011B6D;//fail |
+-------------------------------------------------------+
This subProc GetLocalTime_1000F4F0() into di,
and call KERNEL32.GetPrivateProfileString() from runCode.ini to ax.
So "cmp di,ax" means "compare localTime to deadLine"
and "jbe 1864" means "if(localTime <= deadLine)/*below*/{goto line_1864}"
else{set g_err=5/*ENUM_License_Date_Exceeded*/, goto fail;}
At line_1aeb, the subProc maybe call dlgProc("The license for %s will expire in %d day%s"),
similar to the line_0a31 of pclReader.
+---------------------------------------------------------------+
|:10011AEB 85C0 test eax, eax |
|:10011AED 740C je 10011AFB |
|:10011AEF F7C300020000 test ebx, 200 |
|:10011AF5 0F85B1FEFFFF jne 100119AC |
|:10011AFB 85FF test edi, edi |
|:10011AFD 7451 je 10011B50 |
|:10011AFF 83BC248802000000 cmp dword ptr [esp+288], 0 |
|:10011B07 7547 jne 10011B50 |
| |
|:10011B09 8B442418 mov eax, dword ptr [esp+18] |
|:10011B0D 8B8EFC060000 mov ecx, dword ptr [esi+6FC] |
|:10011B13 8D942488020000 lea edx, dword ptr [esp+288] |
|:10011B1A 52 push edx |
|:10011B1B 50 push eax |
|:10011B1C 51 push ecx |
|:10011B1D E83E1A0000 call 10013560;//dlgProc |
|:10011B22 83C40C add esp, 0C |
| ... |
|:10011B2F 8B960C080000 mov edx, dword ptr [esi+80C] |
|:10011B35 8B86FC060000 mov eax, dword ptr [esi+6FC] |
|:10011B3B 52 push edx |
|:10011B3C 68E0CE0210 push "1";//1002CEE0 |
|:10011B41 83C020 add eax, 20 |
|:10011B44 50 push eax |
|:10011B45 68F43B0310 push "Runcode";//10033BF4 |
|:10011B4A FF158C800210 Call KERNEL32.WritePrivateProfileStringA
+---------------------------------------------------------------+
So, if we change the byte(memory offset==0x10011851, file offset==0x10c51)
"76"(jbe)to byte "EB"(jmp),
and change the byte(memory offset==0x10011AEB, file offset==0x10eeb)
"85C0" to byte "EB 63"(jmp 10011B50),
then we can prevent failure from pdfwInit().
-------------- 4.2.pdfwOpenNewDoc -------------------------------------
In pdfwOpenNewDoc_10008490(),
+-------------------------------------------------------+
|:100089D8 8BCE mov ecx, esi |
|:100089DA E861E1FFFF call 10006B40 |
|:100089DF 85C0 test eax, eax |
|:100089E1 0F84FBFAFFFF je 100084E2;//fail |
|:100089E7 |
+-------------------------------------------------------+
she call sub_10006B40 to write /FlateDecode in pdf.
We can disable that to save some space,
by change the byte(memory offset==0x100089D8, file offset==0x7dd8)
"8B CE" to byte "EB 0D"(jmp 100089E7).
She call fwriteAuthor_10007840 to write "/Creator (Created by PCLReader" in pdf,
+-----------------------------------------------+
|:10008AE1 399E64600500 cmp dword [esi+56064], ebx
|:10008AE7 740F je 10008AF8 |
|:10008AE9 8BCE mov ecx, esi |
|:10008AEB E850EDFFFF call 10007840 |
|:10008AF0 85C0 test eax, eax |
|:10008AF2 0F84EAF9FFFF je 100084E2 |
|:10008AF8 |
+-----------------------------------------------+
We can disable that to save some space,
by change the byte(memory offset==0x10008AE7, file offset==0x7ee7)
"74" to byte "EB"(jmp).
-------------- 4.3.pdfwCloseDoc ---------------------------------------
In pdfwCloseDoc_1000B4E0(),
+-------------------------------------------------------+
|:1000BFF4 837C241000 cmp dword [esp+10], 0 |
|:1000BFF9 0F84F6040000 je 1000C4F5 |
|... |
|:1000C043 68E8CE0210 push 1002CEE8; "<rdf:Description rdf:about='' xmlns:pdf"...
|:1000C048 8BCE mov ecx, esi |
|:1000C04A E811100000 call fwrite;//1000D060 |
|:1000C04F 85C0 test eax, eax |
|:1000C051 0F845CFCFFFF je 1000BCB3 |
| |
|:1000C057 68E0CE0210 push "1";//1002CEE0 |
|:1000C05C 68D4CE0210 push "pdfaid:part";//1002CED4
|:1000C061 8BCE mov ecx, esi |
|:1000C063 E808150000 call fwrite;//1000D570 |
|:1000C068 85C0 test eax, eax |
|:1000C06A 0F8443FCFFFF je 1000BCB3 |
|... |
|:1000C07E 6880BF0210 push 1002BF80 |
|:1000C083 68C8CE0210 push "pdfaid:amd";//1002CEC8
|:1000C088 8BCE mov ecx, esi |
|:1000C08A E8E1140000 call fwrite;//1000D570 |
|:1000C08F 85C0 test eax, eax |
|:1000C091 0F841CFCFFFF je 1000BCB3 |
+-------------------------------------------------------+
We change the byte(memory offset==0x1000BFF9, file offset==0xb3f9)
"0F 84" to byte "90 E9"(jmp), to disable the xml obj in pdf,
and make code space(memery offset=0x1000BFFF~0x1000C4F4),
data space(memery offset=0x1002CB88~0x1002CEE0, which ...
... reloction in file offset=0x39cec~0x39d5c),
for the following 4.5.
So we can insert the function get_CharSetEnum_from_symbolSet()
in memory offset==0x1000BFFF~0x1000C01E(file offset==0xb3ff~0xb41e).
+-------------------------------------------------------------------------------+
|1000BFFF(80FC 02) cmp ah,2 |
|1000C002(75 1A) jnz 1000C01E |
|1000C004(3C 6B) cmp al,6b;//19"k"(Symbol Set=Japanese Windows 3.1J) |
|1000C006(74 12) je 1000C01A |
|1000C008(3C 54) cmp al,54;//18"T"(Symbol Set=Big 5) |
|1000C00A(74 0C) je 1000C018 |
|1000C00C(3C 48) cmp al,48;//18"H"(Symbol Set=KS C 5601) |
|1000C00E(74 06) je 1000C016 |
|1000C010(3C 43) cmp al,43;//18"C"(Symbol Set=GB 2312) |
|1000C012(75 0A) jnz 1000C01E |
|1000C014(04 06) add al,06;//43+6+0d+18+96=04;//GB2312_ENUM |
|1000C016(04 0d) add al,0d;//48+ 0d+18+96=03;//HANGUL_ENUM |
|1000C018(04 18) add al,18;//54+ 18+96=02;//CHINESEBIG5_ENUM |
|1000C01A(04 96) add al,96;//6b +96=01;//SHIFTJIS_ENUM |
|1000C01C(32E4) xor ah,ah |
|1000C01E(C3) retn |
+-------------------------------------------------------------------------------+
-------------- 4.4.pdfwAddCharset -------------------------------------
In pdfwAddCharset_1000AFD0
+-----------------------------------------------------------------------+
|;// if(this->55FBC) |
|:1000B04B 83BBBC5F050000 cmp dword ptr [ebx+55FBC], 0 |
|:1000B052 7437 je 1000B08B |
|;// { |
|:1000B054 B980000000 mov ecx, 80 |
| ... |
|;// if(fail) |
|:1000B070 85C0 test eax, eax |
|:1000B072 753B jne 1000B0AF |
|;// {;//now eax==0 |
|:1000B074 5F pop edi |
|:1000B075 5E pop esi |
|:1000B076 5B pop ebx |
|:1000B077 8B8C2408020000 mov ecx, [esp+208];//cookie |
|:1000B07E 33CC xor ecx, esp |
|:1000B080 E827B30000 call __security_check_cookie;//100163AC |
|:1000B085 8BE5 mov esp, ebp |
|:1000B087 5D pop ebp |
|:1000B088 C20800 ret 0008 |
|;// } |
|:1000B0AF 8B8C2414020000 else {mov ecx, [esp+214];//cookie |
|:1000B0B6 5F pop edi |
|:1000B0B7 5E pop esi |
|:1000B0B8 5B pop ebx |
|:1000B0B9 33CC xor ecx, esp |
|:1000B0BB B801000000 mov eax, 1;//success |
|:1000B0C0 E8E7B20000 call __security_check_cookie;//100163AC |
|:1000B0C5 8BE5 mov esp, ebp |
|:1000B0C7 5D pop ebp |
|:1000B0C8 C20800 ret 0008 |
|;// } |
|;// } |
|;// else { |
|:1000B08B 50 push eax |
|:1000B08C 56 push esi |
|:1000B08D 8BCB mov ecx, ebx |
|:1000B08F E86CFDFFFF call Simple_Encoding_1000AE00;//ret 0:fail, 1:success
|:1000B094 85C0 test eax, eax |
|:1000B096 7517 jne 1000B0AF;//that means return(1), see above. |
|:1000B098 5F pop edi |
|:1000B099 5E pop esi |
|:1000B09A 5B pop ebx |
|:1000B09B 8B8C2408020000 mov ecx, [esp+208];//cookie |
|:1000B0A2 33CC xor ecx, esp |
|:1000B0A4 E803B30000 call __security_check_cookie;//100163AC |
|:1000B0A9 8BE5 mov esp, ebp |
|:1000B0AB 5D pop ebp |
|:1000B0AC C20800 ret 0008 |
|;// } |
+-----------------------------------------------------------------------+
She call Simple_Encoding_1000AE00 to write /Encoding
/Differences [...] in pdf.
But for cjk fonts, there should be composite_encoding,
so at first: we must get_CharSetEnum_from_symbolSet(),
second: according zf to judge whether need to call Simple_Encoding_1000AE00().
But,to insert code of "first", we have to make some code space.
We can see 0x1000B074~0x1000B08A is same to 0x1000B098~0x1000B0AE.
So if we change the byte(memory offset==0x1000B074, file offset==0xa474)
to byte "EB22"(jmp 1000B098), then we can make some code space(0x1000B076~0x1000B08A).
Ok, with the help of code space, we can change the byte(memory offset==0x1000B052,
file offset==0xa452)from 74"37"(je 1000B08B) to byte 74"2E"(je 1000B082),
so she will not directly goto 1000B08B(there she call Simple_Encoding_1000AE00).
Ok, we insert our code of "first" now:
+-------------------------------------------------------+
|;1000B082 97 xchg eax,edi |
|;1000B083 E8 770F0000 call get_CharSetEnum_from_symbolSet;//1000BFFF
|;1000B088 97 xchg eax,edi |
|;1000B089 74 24 je 1000B0AF |
+-------------------------------------------------------+
and second:
if(is cjk charSet)//that means zf==1
{goto 1000B0AF};//that means return(1), see above
else {goto 1000B08B};//this is the original logic.
After we change the byte(memory offset==0x1000B082~0x1000B08A,
file offset==0xa482~0xa48a) as above,
then she will NOT call Simple_Encoding_1000AE00() in cjk font case.
-------------- 4.5.pdfwDecAllocFont -----------------------------------
In the end of pdfwDeclareAllocFont_1000A8E0(),
1000AA6F: call sub_1000A470.
In the latter subProc, her codes are:
4.5.1.TrueType font attributes
+-----------------------------------------------------------------------+
|:1000A4F0 6844C20210 push "<<";//1002C244 |
|:1000A4F5 8BCF mov ecx, edi |
|:1000A4F7 E8642B0000 call fwrite;//1000D060 |
|:1000A4FC 85C0 test eax, eax |
|:1000A4FE 0F84E1000000 je 1000A5E5 |
| |
|:1000A504 6838C20210 push "/Type /Font";//1002C238 |
|:1000A509 8BCF mov ecx, edi;//this |
|:1000A50B E8502B0000 call fwrite;//1000D060 |
|:1000A510 85C0 test eax, eax |
|:1000A512 0F84CD000000 je 1000A5E5 |
| |
|:1000A518 6864C80210 push "/Subtype /TrueType";//1002C864 |
|:1000A51D 8BCF mov ecx, edi;//this |
|:1000A51F E83C2B0000 call fwrite;//1000D060 |
|:1000A524 85C0 test eax, eax |
|:1000A526 0F84B9000000 je 1000A5E5 |
| |
|:1000A52C 8D4C2424 lea ecx, dword ptr [esp+24] |
|:1000A530 51 push ecx |
|:1000A531 6834C60210 push "Name";//1002C634 |
|:1000A536 8BCF mov ecx, edi |
|:1000A538 E8132D0000 call fwrite;//1000D250 |
|:1000A53D 85C0 test eax, eax |
|:1000A53F 0F84A0000000 je 1000A5E5 |
| |
|;==== see also ptc32.100542BB ===== |
|:1000A545 8D452C lea eax, dword ptr [ebp+2C] |
|:1000A548 50 push eax |
|:1000A549 684CC80210 push "BaseFont ";//1002C84C |
|:1000A54E 8BCF mov ecx, edi;//this |
|:1000A550 E8FB2C0000 call fwrite;//1000D250 |
|:1000A555 85C0 test eax, eax |
|:1000A557 0F8488000000 je 1000A5E5 |
| |
|:1000A55D 8B550C mov edx, dword ptr [ebp+0C] |
|:1000A560 52 push edx |
|:1000A561 6840C80210 push "FirstChar ";//1002C840 |
|:1000A566 8BCF mov ecx, edi;//this |
|:1000A568 E8E32D0000 call fprint;//1000D350 |
|:1000A56D 85C0 test eax, eax |
|:1000A56F 7474 je 1000A5E5 |
| |
|:1000A571 8B4510 mov eax, dword ptr [ebp+10] |
|:1000A574 50 push eax |
|:1000A575 6834C80210 push "LastChar";//1002C834 |
|:1000A57A 8BCF mov ecx, edi;//this |
|:1000A57C E8CF2D0000 call fprint;//1000D350 |
|:1000A581 85C0 test eax, eax |
|:1000A583 7460 je 1000A5E5 |
| ... ... |
|:1000A627 68E8C10210 push ">>";//1002C1E8 |
|:1000A62C 8BCF mov ecx, edi;//this |
|:1000A62E E82D2A0000 call fwrite;//1000D060 |
|:1000A633 85C0 test eax, eax |
|:1000A635 74AE je 1000A5E5 |
+-----------------------------------------------------------------------+
If we want to replace subtype from truetype to type0,
we can upsideDown the sequence of /Name and /Subtype to ...
+---------------------------------------------------------------+
|:1000A518 8D4C2424 lea ecx, dword ptr [esp+24] |
|:1000A51C 51 push ecx |
|:1000A51D 6834C60210 push "Name";//1002C634 |
|:1000A522 8BCF mov ecx, edi |
|:1000A524 E8372D0000 call fwrite;//1000D250 |
|:1000A529 85C0 test eax, eax |
|:1000A52B 90 E9 0A1B00000 jmp 1000C03B |
| |
|:1000A531 6864C80210 push "/Subtype /TrueType";//1002C864
|:1000A536 8BCF mov ecx, edi;//this |
|:1000A538 E83C2B0000 call fwrite;//1000D060 |
|:1000A53D 85C0 test eax, eax |
|:1000A53F 0F84B9000000 je 1000A5E5 |
+---------------------------------------------------------------+
These upsideDown codes' memery offset=0x1000A518~0x1000A53F,
(file offset=0x9918~0x993F), and use reloction which file offset=0x39bb8.
And because we must judge whether truetype or type0,
so we dont use "je 1000A5E5", replace to "jmp 1000C03B".
There are the new codes(for type0) at 1000C03B:
(memery offset=0x1000C03B~0x1000C098, file offset=0xb43b~0xb498),
and she use the data memery=0x1002CB88~0x1002CBD5(file offset=0x2b988~0x2b9d5)
+-----------------------------------------------------------------------+
|;// restore code from 1000A52B |
|:1000C03B(0F84 A4E5FFFF) JE 1000A5E5 |
| |
|;// if(is NOT cjk charSet) |
|:1000C041(8B8424 64010000) mov eax,[esp+148h+1c];//symbol set |
|:1000C048(E8 B2FFFFFF) call get_CharSetEnum_from_symbolSet;//1000BFFF
| ret to original position |
|:1000C04D(0F85 DEE4FFFF) jnz 1000A531 |
| |
| else {fwrite("/Subtype /Type0") |
|:1000C053(68 88CB0210) push "/Subtype /Type0";//1002CB88 |
|:1000C058(8BCF) mov ecx, edi;//this |
|:1000C05A(E8 01100000) call fwrite;//1000D060 |
|:1000C05F(74 DA) JE 1000C03B |
| |
|;// fwrite_DescendantFonts(next_obj) |
|:1000C061(8B4C24 1C) mov ecx, dword ptr [esp+1C] |
|:1000C065(51) push ecx |
|:1000C066(8BCF) mov ecx, edi;//this |
|:1000C068(E8 23150000) call fwrite_DescendantFonts;//1000D590 |
|:1000C06D(74 CC) JE 1000C03B |
| |
|;// const char array[4][12]={ |
|;// "90ms-RKSJ-H\0", |
|;// "ETen-B5-H \0", |
|;// "KSCms-UHC-H\0", |
|;// "GBK-EUC-H\0"}, |
|:1000C06F(8B8424 64010000) mov eax,[esp+148h+1c];//symbol set |
|:1000C076(E8 84FFFFFF) call get_CharSetEnum_from_symbolSet;//1000BFFF
| |
|;// p8 =&array[CharSetEnum-1] |
|:1000C07B(6A 0C) push 0c |
|:1000C07D(59) pop ecx |
|:1000C07E(F7E1) mul ecx |
|:1000C080(05 8CCB0210) add eax,(-0C + offset array) |
| |
|;// fwrite%s%s("Encoding",p8) |
|:1000C085(50) push eax |
|:1000C086(68 3BCA0210) push "Encoding";//1002CA3A |
|:1000C08B(8BCF) mov ecx, edi;//this |
|:1000C08D(E8 BE110000) call fwrite%s%s;//1000D250 |
|:1000C092(74 A7) JE 1000C03B |
|:1000C094(E9 8EE5FFFF) jmp 1000A627 |
|;// };//goto position of ">>" |
+-----------------------------------------------------------------------+
|:1002CB88 db "/Subtype /Type0",0 |
|:1002CB98 db "90ms-RKSJ-H",0 |
|:1002CBA4 db "ETen-B5-H",0,0,0 |
|:1002CBB0 db "KSCms-UHC-H",0 |
|:1002CBBC db "GBK-EUC-H",0 |
+-----------------------------------------------------------------------+
The original code sub_1000D590() is only called at 1000C38E,1000C3B4,1000C3DA
(all within 1000BFFF~1000C4F4, which disable at 4.3).
So we can reWrite it(memory offset=0x1000D590~0x1000D5B7,
file offset=0xc990~0xc9b7) as:
+---------------------------------------------------------------+
|;//void fwrite_DescendantFonts(int obj_enum) |
|:1000D590 8B542404 mov edx, [esp+04];//obj_enum |
|:1000D594 56 push esi |
|:1000D595 8BF1 mov esi, ecx;//this |
|:1000D597 57 push edi |
| |
|; //sprintf(this->buf, "/DescendantFonts[ %d 0 R ]", obj_enum)
|:1000D598 52 push edx;//obj_enum |
|:1000D599 8DBE F4FD0500 lea edi, dword ptr [esi+0005FDF4]
|:1000D59F 68 1CD40210 push "/DescendantFonts[ %d 0 R ]";//1002D41C;
|:1000D5A4 57 push edi |
|:1000D5A5 E8 A2980000 call sprintf;//10016E4C |
|:1000D5AA 83C40C add esp, 0C |
| |
|; //fwrite(this->buf) |
|:1000D5AD 57 push edi |
|:1000D5AE 8BCE mov ecx, esi |
|:1000D5B0 E8 ABFAFFFF call fwrite;//1000D060 |
|:1000D5B5 5F pop edi |
|:1000D5B6 5E pop esi |
|:1000D5B7 C20400 ret 0004 |
+---------------------------------------------------------------+
|:1002D41C db "/DescendantFonts[ %d 0 R]",0 |
+---------------------------------------------------------------+
and she use data memory=0x1002D41C~0x1002D435(file offset=0x2c21c~0x2c235)
and reloction which file offset=0x39e1c.
4.5.2.every char's width for Simple_Encoding
In the sub_1000A470(she is pdfwDeclareAllocFont's subProc),
her codes are:
+-------------------------------------------------------+
|;// fwrite%ld(obj_enum) |
|:1000A642 8B442420 mov eax, [esp+20];//obj_enum |
|:1000A646 50 push eax |
|:1000A647 8BCF mov ecx, edi;//this |
|:1000A649 E8C22A0000 call fwrite%ld;//1000D110 |
|:1000A64E 85C0 test eax, eax |
|:1000A650 7493 je 1000A5E5 |
| |
|;// buf[0]='['; buf[1]=' ' |
|:1000A688 C64424445B mov [esp+44], '[' |
|:1000A68D C644244520 mov [esp+45], ' ' |
| |
|;// p8=&(buf[2]); |
|:1000A692 8D742446 lea esi, [esp+46] |
|:1000A696 C644244600 mov [esp+46], 00 |
| ... |
|;// do{tmp16= *(pWidth++) |
|:1000A6AD 0FB711 movzx edx, word ptr [ecx] |
|:1000A6B0 83C102 add ecx, 2 |
|:1000A6B3 89542418 mov dword ptr [esp+18], edx |
| |
|;// sprintf(p8, "%d", tmp16) |
|:1000A6C3 0FB7442418 movzx eax, word ptr [esp+18];//tmp16
|:1000A6C8 50 push eax |
|:1000A6C9 68E8C70210 push "%d";//1002C7E8 |
|:1000A6CE 56 push esi |
|:1000A6CF E878C70000 call sprintf;//10016E4C |
|:1000A6D4 83C40C add esp, 0C |
| |
|;// while(p8[0]){p8++;};//this means "p8=&(p8[strlen-1])"
|:1000A6E0 46 inc esi |
|:1000A6E1 803E00 cmp byte ptr [esi], 00 |
|:1000A6E4 75FA jne 1000A6E0 |
| |
|;// }while(++i < 16); |
|:1000A6EE 43 inc ebx |
|:1000A6EF 83FB10 cmp ebx, 10 |
|:1000A6F2 7CAC jl 1000A6A0 |
| |
|;// p8[0]=']', p8[1]='\0' |
|:1000A6FD C6065D mov byte ptr [esi], ']' |
|:1000A700 C6460100 mov [esi+01], 00 |
| |
|;// fwrite(buf) |
|:1000A704 8D4C2444 lea ecx, [esp+44];//buf |
|:1000A708 51 push ecx |
|:1000A709 8BCF mov ecx, edi;//this |
|:1000A70B E850290000 call fwrite;//1000D060 |
|:1000A710 85C0 test eax, eax |
|:1000A712 0F84CDFEFFFF je 1000A5E5 |
| ... |
|:1000A72C 8BCF mov ecx, edi;//this |
|:1000A72E E83D2A0000 call fwriteEndObj;//1000D170 |
|:1000A733 8BCF mov ecx, edi |
|:1000A735 85C0 test eax, eax |
|:1000A737 0F84AAFEFFFF je 1000A5E7 |
+-------------------------------------------------------+
She write every char's width for Simple_Encoding.
But for cjk fonts, there should be composite_encoding,
so we should judge whether to that or not.
We change the byte(memery offset=0x1000A642~0x1000A646,
file offset=0x9A42~0x9A46) to byte"E9 D8190000"(jmp 1000C01F)
to goto our judge:
+---------------------------------------------------------------+
|:1000C01F 8B8424 64010000 mov eax,[esp+148h+1c];//symbol set
|:1000C026 E8 D4FFFFFF call get_CharSetEnum_from_symbolSet;//1000BFFF
| |
|;// if(is cjk charSet) |
|;// skip this obj, because all of it are widths.
|:1000C02B 0F84 02E7FFFF jz 1000A733 |
| |
|;// else {restore code from 1000A642 |
|:1000C031 8B4424 20 mov eax, dword ptr [esp+20] |
|:1000C035 50 push eax |
| |
|;// goto original position |
|:1000C036 E9 0CE6FFFF jmp 1000A647 |
+---------------------------------------------------------------+
This judge is insert at memery offset=0x1000C01F~0x1000C03A,
(file offset=0xb41f~0xb43a)
4.5.3.FontDescriptor
In the sub_1000A470(she is pdfwDeclareAllocFont's subProc),
her codes are:
+-------------------------------------------------------+
|:1000A74F 6844C20210 push "<<";//1002C244 |
|:1000A754 8BCF mov ecx, edi;//this |
|:1000A756 E805290000 call fwrite;//1000D060 |
|:1000A75B 85C0 test eax, eax |
|:1000A75D 0F8482FEFFFF je 1000A5E5 |
| |
|:1000A763 68D0C70210 push "/Type /FontDescriptor";//1002C7D0
|:1000A768 8BCF mov ecx, edi;//this |
|:1000A76A E8F1280000 call fwrite;//1000D060 |
|:1000A76F 85C0 test eax, eax |
|:1000A771 0F846EFEFFFF je 1000A5E5 |
| |
|:1000A777 8B4D20 mov ecx, dword ptr [ebp+20] |
|:1000A77A 51 push ecx |
|:1000A77B 68C8C70210 push "Ascent";//1002C7C8 |
|:1000A780 8BCF mov ecx, edi;//this |
|:1000A782 E8C92B0000 call fprint;//1000D350 |
|:1000A787 85C0 test eax, eax |
|:1000A789 0F8456FEFFFF je 1000A5E5 |
| |
|:1000A78F 8B5520 mov edx, dword ptr [ebp+20] |
|:1000A792 52 push edx |
|:1000A793 68BCC70210 push "CapHeight";//1002C7BC |
|:1000A798 8BCF mov ecx, edi;//this |
|:1000A79A E8B12B0000 call fprint;//1000D350 |
|:1000A79F 85C0 test eax, eax |
|:1000A7A1 0F843EFEFFFF je 1000A5E5 |
|... |
|:1000A8A1 68E8C10210 push ">>";//1002C1E8 |
|:1000A8A6 8BCF mov ecx, edi;//this |
|:1000A8A8 E8B3270000 call fwrite;//1000D060 |
|:1000A8AD 85C0 test eax, eax |
|:1000A8AF 0F8430FDFFFF je 1000A5E5 |
+-------------------------------------------------------+
She write FontDescriptor for truetype,
but we want DescendantFonts for cjk fonts indeed.
so we should judge whether to that or not.
We change the byte(memery offset=0x1000A75D~0x1000A762,
file offset=0x9b5d~0x9b62) to byte"90 E9 36190000"(jmp 1000C099)
to goto our judge:
+---------------------------------------------------------------+
|;// if(original with fail) |
|;// retore code from 1000A75D; |
|:1000C099(0F84 46E5FFFF) je 1000A5E5 |
| |
|:1000C09F(8B8424 64010000) mov eax,[esp+148h+1c];//symbol set
|:1000C0A6(E8 54FFFFFF) call get_CharSetEnum_from_symbolSet;//1000BFFF
| |
|;// if(is NOT cjk charSet) |
| goto original position; |
|:1000C0AB(0F85 B2E6FFFF) jnz 1000A763 |
| |
|;// else {fwrite("/Type /Font") |
|:1000C0B1(68 38C20210) push "/Type /Font";//1002C238 |
|:1000C0B6(8BCF) mov ecx, edi;//this |
|:1000C0B8(E8 A30F0000) call fwrite;//1000D060 |
|:1000C0BD(74 DA) JE 1000C099 |
| |
|;// fwrite("/Subtype /CIDFontType0") |
|:1000C0BF 68 C6CB0210 push "/Subtype /CIDFontType0";//1002CBC6
|:1000C0C4 8BCF mov ecx, edi;//this |
|:1000C0C6 E8 950F0000 call fwrite;//1000D060 |
|:1000C0CB(74 CC) JE 1000C099 |
| |
|:1000C0CD(E9 CFE7FFFF) jmp 1000A8A1 |
|;// };//goto position of ">>" |
+---------------------------------------------------------------+
|:1002CBC6 db "/Subtype /CIDFontType0",0 |
+---------------------------------------------------------------+
This judge code is insert at
memery offset=0x1000C099~0x1000C0D1,(file offset=0xb499~0xb4d1)
and she use data memery offset=0x1002CBC6~0x1002CBDC
(file offset=0x2b9c6~0x2b9dc)
-------------- 5.needn't to manually modify ---------------------------
We have change 201 bytes in pclReader.exe, change 164 bytes in ptc32.dll,
change 428 bytes in pdfWrite.dll.
Before change, we must backup them(1 exe + 2 dll) as ".bak" file.
After change, we can see <<C_A_Grande.pcl>> by pclReader.exe with ...
menu "file" -> subMenu "Open Image File" now.
5.1.pclReader.exe
To prove we just modify about 201 bytes in pclReader.exe,
we can "fc /b PCLReader.exe PCLReader.exe.bak > fc_exe.txt" to do
file-compare in binary mode. And we will get a text file,
which name is "fc_exe.txt", and its' content are:
'Comparing files PCLReader.exe and PCLReader.exe.bak
00008250: EB 83
00008251: 68 EC
00008252: 90 44
...'
The bytes in column of PCLReader.exe are we just inputed.
and those are 201 lines.
About the file_offset:
8250~8252: see also 2.3.1
8253~82af: see also 2.3
82b0~82b9: see also 2.3.2
82ba~82c1: see also 2.3.1
82c2~82df: see also 2.3
82e0~82e9: see also 2.3.3
82ea~830f: see also 2.4
8310~831d: see also 2.3.4
831e~8351: see also 2.4
eb5f~eb63: as above
5fe0e: see also 2.1
6013a: as above
5.2.ptc32.dll
To prove we just modify about 164 bytes in ptc32.dll,
we can "fc /b ptc32.dll ptc32.dll.bak > fc_ptc32.txt" to do
file-compare in binary mode. And we will get a text file,
which name is "fc_ptc32.txt", and its' content are:
'Comparing files Ptc32.dll and Ptc32.dll.bak
00002722: 2B 17
00004253: EB 74
...'
The bytes in column of ptc32.dll are we just inputed.
and those are 164 lines.
About the file_offset:
2722: see alse 3.2
4253: see alse 3.4
6892~6893: see alse 3.2
82f4~82f5: see also 3.5
82f6~8316: see alse 3.7
1ed1c: see alse 3.3
212fa~212fb: see alse 3.1.3
271b8: see alse 3.1.4
33c77: as above
33ec7: as above
3b588~3b5c7: see alse 3.6
3b5c8~3b5e9: see alse 3.7
536db~536e2: as above
74e9e: see also 2.2
7514c: as above
a405d~a405e: see also 3.4
a8bb9~a8bbf: see alse 3.6
1512d9: see also 3.1.1
163a1a~163a1c: see also 3.7
5.3.pdfWrite.dll
To prove we just modify about 428 bytes in pdfWrite.dll,
we can "fc /b pdfWrite.dll pdfWrite.dll.bak > fc_pdf.txt" to do
file-compare in binary mode. And we will get a text file,
which name is "fc_pdf.txt", and its' content are:
'Comparing files PdfWrite.dll and PdfWrite.dll.bak
00007DD8: EB 8B
00007DD9: 0D CE
00007EE7: EB 74
...'
The bytes in column of pdfWrite.dll are we just inputed.
and those are 428 lines.
About the file_offset:
7dd8~7dd9: see also 4.2
7ee7: as above
9918~993a: see also 4.5.1
9a42~9a46: see also 4.5.2
9b5d~9b62: see also 4.5.3
a453: see also 4.4
a474~a475: as above
a482~a48a: as above
b3f9~b3fa: see also 4.3
b3ff~b41e: as above
b41f~b43a: see also 4.5.2
b43b~b498: see also 4.5.1
b499~b4d1: see also 4.5.3
c990~c9b9: see also 4.5.1
10c51: see also 4.1
10eeb~10eec: as above
2b988~2b9c5: see also 4.5.1
2b9c6~2b9dc: see also 4.5.3
2c21c~2c235: see also 4.5.1
39bb8: as above
39cec~39cfe: see also 4.3
39e1c: see also 4.5.1
5.4.modify by difc
Too many lines to be modify, and needn't modify them manually.
We have already give out these fc_exe.txt, fc_ptc32.txt, fc_pdf.txt here.
All you should do, just are:
reName pclReader.exe to pclReader.exe.bak
reName ptc32.dll ro ptc32.dll.bak
reName pdfWrite.dll to pdfWrite.dll.bak
In console,
input "difc.exe fc_exe.txt"
"difc.exe fc_ptc32.txt"
"difc.exe fc_pdf.txt"
Of course, the name of these text files is not important.
-------------- 6.after word -------------------------------------------
If you had download a same pclReader 9.13,
after you notice bugs above, you can
1)goto www.pclReader.com or www.pageTech.com ...
but "This domain is for sale"
2)send message to the author D.C.Burdette...
but without his' emailBox.
3)do it as 5.4