对话框的隐藏

修改对话框资源属性

1 用pe工具修改对话框的属性从WS_EX_APPWINDOW 到WS_EX_TOOLWINDOW

2 hook showwindow api

系统打开文件对话框的隐藏

1 hook showwindow api

  
ShowWindow_T oldShowWindow=ShowWindow;
CreateDialogIndirectParamA_T oldCreateDialogIndirectParamA=(CreateDialogIndirectParamA_T)CreateDialogIndirectParamA;
CreateWindowExA_T oldCreateWindowExA=CreateWindowExA;
CreateWindowExW_T oldCreateWindowExW=CreateWindowExW;
  
int ModifyStyleEx(HWND hwnd,DWORD clrbit,DWORD insbit)
{
 
    DWORD exstyle = (DWORD)GetWindowLong(hwnd,GWL_EXSTYLE);
    exstyle  &= ~clrbit;
    exstyle  |= insbit;

    SetWindowLong(hwnd,GWL_EXSTYLE,(DWORD)exstyle);
    return 0;
}
#define MAKE_STYLE_REPLACE(exstyle,clrbit,setbit) do{    exstyle  &= ~clrbit; exstyle |= setbit;}while(0);
 

showwindow hook

int hidewindow(HWND hwnd,int flag)
{
#define FACTOR_DIV_WINDOW 1
    RECT rc;
    GetWindowRect(hwnd,&rc);
    if(flag){
        COLORREF crKey = RGB(0, 0, 0);  
        //颜色值为crKey的地方将变为全透明,而其它地方根据bAlpha参数确定透明度  
        //SetLayeredWindowAttributes(hwnd, crKey, 2, LWA_COLORKEY | LWA_ALPHA);
        MoveWindow(hwnd,-1000,-1000,(rc.right-rc.left)/FACTOR_DIV_WINDOW,(rc.bottom-rc.top)/FACTOR_DIV_WINDOW,TRUE);
    }else{
        MoveWindow(hwnd,0,0,rc.right-rc.left,rc.bottom-rc.top,TRUE);
    }
    return 0;
}
BOOL WINAPI newShowWindow(
           HWND hWnd,
           int nCmdShow)
{
    hidewindow(hWnd,1);
    return oldShowWindow(hWnd,nCmdShow);
}
 

hook入口

void SetHook(BOOL flag)

{
    
    if (flag)
        
    {
        
        DetourRestoreAfterWith();
        
        DetourTransactionBegin();
        
        DetourUpdateThread(GetCurrentThread());
        
        
        
        // HOOK 函数列表
        
        DetourAttach(&(PVOID&)oldCreateWindowExA, newCreateWindowExA);
        DetourAttach(&(PVOID&)oldCreateWindowExW, newCreateWindowExW);
        DetourAttach(&(PVOID&)oldCreateDialogIndirectParamA, newCreateDialogIndirectParamA);
        DetourAttach(&(PVOID&)oldShowWindow, newShowWindow);
        
        
        
        DetourTransactionCommit();
        
    }
    
    else
        
    {
        
        DetourTransactionBegin();
        
        DetourUpdateThread(GetCurrentThread());
        
        
        
        // 取消 HOOK 函数列表
        
        DetourDetach(&(PVOID&)oldCreateWindowExA, newCreateWindowExA);
        DetourDetach(&(PVOID&)oldCreateWindowExW, newCreateWindowExW);
        DetourDetach(&(PVOID&)oldCreateDialogIndirectParamA, newCreateDialogIndirectParamA);
        DetourDetach(&(PVOID&)oldShowWindow, newShowWindow);

        
        
        DetourTransactionCommit();
        
    }
    
}

ida以及dbgapispy分析

// HOOK.H

cimage_8

int __stdcall cimage_8(int a1, char *a2)
{
  int v2; // esi@1
  int v4; // [sp+4h] [bp-214h]@1
  int v5; // [sp+214h] [bp-4h]@1

  sub_1007E860(0);
  v2 = sub_10079880(a2);
  v5 = -1;
  v4 = (int)off_101501E0;
  sub_1007E930(&v4);
  sub_1007E880(&v4);
  return v2;
}

cimage_6



int __userpurge cimage_6@<eax>(int a1@<eax>, int a2, char *a3)
{
  void *v3; // esp@1
  int v4; // eax@1
  int v5; // esi@1
  FILE *v6; // esi@4
  void *v7; // edi@4
  int v8; // ebp@4
  int (__stdcall **v10)(char); // [sp+0h] [bp-1078h]@4
  FILE *v11; // [sp+4h] [bp-1074h]@4
  bool v12; // [sp+8h] [bp-1070h]@4
  int v13; // [sp+Ch] [bp-106Ch]@8
  int (__stdcall **v14)(char); // [sp+214h] [bp-E64h]@4
  int v15; // [sp+41Ch] [bp-C5Ch]@4
  char v16; // [sp+420h] [bp-C58h]@4
  int v17; // [sp+424h] [bp-C54h]@4
  int v18; // [sp+106Ch] [bp-Ch]@1
  int (*v19)(); // [sp+1070h] [bp-8h]@1
  int v20; // [sp+1074h] [bp-4h]@1

  v19 = sub_1014F371;
  v18 = a1;
  v3 = alloca(4204);
  sub_1007E860(0);
  v20 = 0;
  v4 = sub_10079880(a3);
  v5 = v4;
  if ( v4 <= 0 || v4 >= 22 )
  {
    v8 = 0;
  }
  else if ( v4 == 6 )
  {
    sub_1007E860(6);
    v14 = &off_10150254;
    v15 = 0;
    v16 = 0;
    v17 = 0;
    v6 = fopen(a3, aRb);
    v10 = &off_1015021C;
    v11 = v6;
    v12 = v6 == 0;
    LOBYTE(v20) = 2;
    v7 = (void *)sub_1007C040(&v10);
    v8 = sub_1007C930(v7);
    sub_1007C060(v7);
    fclose(v6);
    v10 = &off_1015021C;
    if ( v11 && v12 )
    {
      fclose(v11);
      v11 = 0;
    }
    v10 = &off_101501E4;
    LOBYTE(v20) = 0;
    sub_1007A110(&v14);
  }
  else
  {
    sub_10079F70(-1);
    sub_1007D5B0(a3, v5);
    v8 = sub_10079F90(&v13);
    sub_10079F70(0);
  }
  v20 = -1;
  v13 = (int)off_101501E0;
  sub_1007E930(&v13);
  sub_1007E880(&v13);
  return v8;
}



cimage_32

int __stdcall cimage_32(char *a1, int a2)
{
  int result; // eax@2

  if ( (unsigned __int8)sub_10001010(a2) )
  {
    result = sub_10003790(a1);
    dword_101BCB80 = result;
  }
  else
  {
    result = 0;
  }
  return result;
}

cimage_15


int __stdcall cimage_15(int a1, int a2, int a3, char *a4, char *a5, char *a6, int a7)
{
  int result; // eax@2

  if ( (unsigned __int8)sub_10001010(a7) )
    result = sub_10005FC0(a1, a2, a3, a4, a5, a6);
  else
    result = 0;
  return result;
}

cimage_22


signed int __stdcall cimage_22(int a1, const char *a2, int a3)
{
  int v3; // ebx@4
  int v4; // ebp@6
  int v5; // ecx@8
  signed int result; // eax@9
  signed int v7; // ebp@10
  char *v8; // ST14_4@17
  char *v9; // eax@17
  char *v10; // ST14_4@17
  char *v11; // eax@17
  char *v12; // ST14_4@17
  char *v13; // eax@17
  __int32 v14; // [sp+10h] [bp-570h]@17
  __int32 v15; // [sp+14h] [bp-56Ch]@17
  int v16; // [sp+18h] [bp-568h]@1
  int v17; // [sp+1Ch] [bp-564h]@6
  int v18; // [sp+20h] [bp-560h]@6
  int v19; // [sp+24h] [bp-55Ch]@12
  int v20; // [sp+28h] [bp-558h]@4
  char v21; // [sp+2Ch] [bp-554h]@17
  char v22; // [sp+4Ch] [bp-534h]@17
  CHAR Buffer; // [sp+6Ch] [bp-514h]@1
  int v24; // [sp+16Ch] [bp-414h]@4
  char v25; // [sp+374h] [bp-20Ch]@1
  CHAR PrefixString; // [sp+474h] [bp-10Ch]@1
  int v27; // [sp+57Ch] [bp-4h]@4

  memset(&PrefixString, 0, 0x100u);
  memset(&Buffer, 0, 0x100u);
  memset(&v25, 0, 0x100u);
  v16 = 0;
  strcpy(&v25, a2);
  sprintf(&PrefixString, aD_ap, a1);
  GetTempPathA(0x100u, &Buffer);
  if ( (unsigned __int8)sub_10001010(a3) && a1 > 0 && v25 )
  {
    sub_1007E860(0);
    v27 = 0;
    v3 = sub_10079880(&v25);
    v20 = v3;
    sub_10079830(&v24);
    if ( v3 > 0 && v3 < 22 )
    {
      v18 = 1;
      v17 = 0;
      sub_10079F70(-1);
      sub_1007D5B0(&v25, v3);
      v4 = sub_10079F90(&v24);
      sub_10079F70(0);
      sub_100072F0(a1, 215, (int)&v18, (int)&v17, 0, 0);
      if ( v18 <= 0 || v17 <= 0 )
      {
        v5 = v4;
        v7 = 1;
      }
      else
      {
        v5 = v17 + v18 - 1;
        if ( v4 < v5 )
        {
          v27 = -1;
          v24 = (int)off_101501E0;
          sub_1007E930(&v24);
          sub_1007E880(&v24);
          return -1;
        }
        v7 = v18;
      }
      v19 = v5;
      if ( v7 <= v5 )
      {
        while ( 1 )
        {
          sub_10079FA0(v7 - 1);
          sub_1007D5B0(&v25, v3);
          if ( (unsigned __int8)sub_10079F80(&v24) )
          {
            GetTempFileNameA(&Buffer, &PrefixString, 0, &Buffer);
            sub_10080510(24);
            sub_10079F40(100);
            LOBYTE(v16) = sub_1007CBC0(&Buffer, 3);
            v16 = (unsigned __int8)v16;
            if ( (_BYTE)v16 )
            {
              cimage_3(a1, 202, (int)&v15, (int)&v14, &Buffer, 0, a3);
              cimage_15(a1, 109, v15, (char *)v14, 0, 0, a3);
              v8 = _ltoa(v14, &v21, 10);
              v9 = _ltoa(v15, &v22, 10);
              cimage_15(a1, 104, 0, 0, v9, v8, a3);
              cimage_15(a1, 101, v7, (char *)1, 0, 0, a3);
              sub_100087F0(a1, &Buffer);
              v10 = _ltoa(v14, &v21, 10);
              v11 = _ltoa(v15, &v22, 10);
              cimage_15(a1, 104, 0, 0, v11, v10, a3);
              cimage_15(a1, 101, v7, (char *)1, 0, 0, a3);
              sub_100087F0(a1, &Buffer);
              v12 = _ltoa(v14, &v21, 10);
              v13 = _ltoa(v15, &v22, 10);
              cimage_15(a1, 104, 0, 0, v13, v12, a3);
              cimage_15(a1, 101, v7, (char *)1, 0, 0, a3);
              v16 = sub_100087F0(a1, &Buffer);
              cimage_15(a1, 109, 0, 0, 0, 0, a3);
            }
            DeleteFileA(&Buffer);
          }
          ++v7;
          if ( v7 > v19 )
            break;
          v3 = v20;
        }
      }
    }
    v27 = -1;
    v24 = (int)off_101501E0;
    sub_1007E930(&v24);
    sub_1007E880(&v24);
    result = v16;
  }
  else
  {
    result = 0;
  }
  return result;
}

cimage_9

int __stdcall cimage_9(int a1, int a2)

{
  int result; // eax@1

  result = sub_10001010(a2);
  if ( (_BYTE)result )
    result = sub_100052B0(a1);
  return result;
}

设置断点在cimage.22上

继续执行崩溃了


typedef signed int (__stdcall* cimage_22_t)(int a1, const char *a2, int a3);
cimage_22_t cimage_22_old=0;
__declspec (naked) void* __builtin_return_address (int iLevel)  
{  
    __asm  
    {  
    
        mov eax, ebp;  
        ret
    
    }  
}   
signed int __stdcall cimage_22_new(int a1, const char *a2, int a3)
{
    DWORD dwCaller;
    __asm push dword ptr [ebp+4]
     __asm pop  dword ptr [dwCaller]
    char buffer[100];
    sprintf(buffer,"cimage_22 %x ",dwCaller);
    OutputDebugStringA(buffer);

    return cimage_22_old(a1,a2,a3);
}
int setup_cimage_hook()
{
    HMODULE hcmiage = LoadLibraryA("cimage.dll");
    cimage_22_old = (cimage_22_t)((DWORD)hcmiage + 0x3180);
    DetourAttach(&(PVOID&)cimage_22_old, cimage_22_new);
    return 0;
}

IDA自定义调用规则

BOOL __thiscall sub_41AA40(CWnd *this)
{
 
     if ( v13 == 1 )
    {
      sprintf(&pdfpath, aSS_pdf, *((_DWORD *)v2 + 4092), &v25);
      sub_417A40(&pdfpath, &pdfpath);
      retc32 = (*((int (__stdcall **)(char *, char *))v2 + 90))(&pdfpath, modulehandle);// cimage32
      (*((void (__stdcall **)(int, signed int, signed int, _DWORD, _DWORD, _DWORD, char *))v2
       + 93))(                                  // cimage15
        retc32,
        128,
        100,
        0,
        0,
        0,
        modulehandle);
      if ( retc32 > 0 )
      {
        (*((void (__stdcall **)(int, int, char *))v2 + 96))(retc32, *((_DWORD *)v2 + 300) + j + 4, modulehandle);// call cimage22
        (*((void (__stdcall **)(int, char *))v2 + 92))(retc32, modulehandle);// cimage9
      }
      ++v18;
      sub_4197F0(v2, (signed __int64)((double)v18 / (double)v21 * 100.0));
    }
}
 IDA支持用户定义的调用规则。在调用规则中用户可以显式指定参数位置和返回值。例如:

        int __usercall func<ebx>(int x, int y<esi>);

表示函数有两个参数:第一个参数传递给堆栈,第二个参数传递给ESI寄存器并且返回值保存在EBX寄存器中。对于用户定义原型通常的规则是:

  - 返回值必须在寄存器中。

  - 如果返回类型是"void",返回位置不能指定。

  - 如果参数位置没有指定,那么就默认在堆栈上。堆栈位置随之分配。

  - 当前IDA不能检查寄存器大小,但是推荐指定正确的寄存器大小(例如,对于字符类型使用AL寄存器)

  - 允许使用嵌套定义例如:
    int **__usercall func16<eax>(int *(__usercall *x)<ebx>
                                (int, long<ecx>, int)<esi>);

    在这里指针 "x" 被传递给ESI寄存器;
    指向的函数是一个用户定义调用类型的函数,第二个参数为ECX寄存器,返回值在EBX寄存器中。

    这样复杂的规则,应用在打开参数列表时指定寄存器这种情况下。

  
   - 寄存器作为位置名时必须对当前处理器有效。一些寄存器不被支持(如果一些寄存器名
     不被支持请通知我们。如果可行我们会改进寄存器模型。

  - 通过 <edx:eax>这样的克隆可以指定寄存器对。

IDA 同样可以理解 "__userpurge" 调用方式。这种方式同 __usercall一致, 唯一不同的是这种调用会清空堆栈。

用户定义的名称将被IDA忽略。

函数定义可以使用__spoils关键词。该选项用于指定被函数破坏的寄存器列表。语法如下:

   int __spoils<eax, bh> func(int x);

如果使用__spoils关键词,指定的列表将覆盖标准的破坏列表。对于X86,标准的破坏列表是<eax, edx, ecx>。破坏列表可以为空。

[3488] cimage_8 4198b6 
[3488] c:\abcdef.tif
[3488] cimage_6 41996a 
[3488] c:\abcdef.tif
[3488] cimage_32 41ac73 
[3488] c:\abcdef_00.pdf
[3488] chief@~`_!·#¥%…—*
[3488] cimage_15 41ac90 
[3488] chief@~`_!·#¥%…—*
[3488] cimage_22 41acac 
[3488] c:\abcdef.tif
[3488] chief@~`_!·#¥%…—*
[3488] cimage_15 bb3423 
[3488] chief@~`_!·#¥%…—*
[3488] cimage_15 bb345a 
[3488] chief@~`_!·#¥%…—*
[3488] cimage_15 bb346a 
[3488] cimage_15 bb34ac 
[3488] chief@~`_!·#¥%…—*
[3488] cimage_15 bb34bc 
[3488] chief@~`_!·#¥%…—*
[3488] cimage_15 bb34fe 
[3488] chief@~`_!·#¥%…—*
[3488] cimage_15 bb350e 
[3488] chief@~`_!·#¥%…—*
[3488] cimage_15 bb352e 
[3488] chief@~`_!·#¥%…—*
[3488] cimage_9 41acb9 
[3488] chief@~`_!·#¥%…—*

最终逆向后的流程

#include "stdafx.h"
// sprintf(&pdfpath, aSS_pdf, *((_DWORD *)v2 + 4092), &v25);
// sub_417A40(&pdfpath, &pdfpath);
// retc32 = (*((int (__stdcall **)(char *, char *))v2 + 90))(&pdfpath, modulehandle);// cimage32
// (*((void (__stdcall **)(int, signed int, signed int, _DWORD, _DWORD, _DWORD, char *))v2
//  + 93))(                                  // cimage15
//  retc32,
//  128,
//  100,
//  0,
//  0,
//  0,
//  modulehandle);
// if ( retc32 > 0 )
// {
// 	(*((void (__stdcall **)(int, int, char *))v2 + 96))(retc32, *((_DWORD *)v2 + 300) + j + 4, modulehandle);// call cimage22
// 	(*((void (__stdcall **)(int, char *))v2 + 92))(retc32, modulehandle);// cimage9
// }
// ++v18;
//       sub_4197F0(v2, (signed __int64)((double)v18 / (double)v21 * 100.0));

typedef int (__stdcall *cimage_8_t)(int a1, char *a2);
cimage_8_t cimage_8_old=0; 

typedef int (__stdcall * cimage_6_t)(int a1, char *a2);
cimage_6_t cimage_6_old=0; 

typedef int (__stdcall * cimage_32_t)(char *a1, int a2);
cimage_32_t cimage_32_old=0; 

typedef int (__stdcall * cimage_15_t)(int a1, int a2, int a3, char *a4, char *a5, char *a6, int a7);
cimage_15_t cimage_15_old=0; 

typedef signed int (__stdcall* cimage_22_t)(int a1, const char *a2, int a3);
cimage_22_t cimage_22_old=0; 

typedef int (__stdcall * cimage_9_t)(int a1, int a2);
cimage_9_t cimage_9_old=0; 

int init_cimage_module()
{
	HMODULE hcimage = LoadLibrary("cimage.dll");
 	cimage_8_old = (cimage_8_t)((DWORD)hcimage + 0x2EE0);
 	
	cimage_6_old = (cimage_6_t)((DWORD)hcimage + 0x2F70);
 	
	cimage_32_old = (cimage_32_t)((DWORD)hcimage + 0x10F0);
 	
	cimage_15_old = (cimage_15_t)((DWORD)hcimage + 0x1210);
 	
	cimage_22_old = (cimage_22_t)((DWORD)hcimage + 0x3180);
 	
	cimage_9_old = (cimage_9_t)((DWORD)hcimage + 0x11E0);
	return 0;
}
int __stdcall cimage_8_new(int a1, char *a2)
{ 	
	return cimage_8_old(a1,a2);
}

int __stdcall cimage_6_new(int a1, char *a2)
{	
	return cimage_6_old(a1,a2);
}
int __stdcall cimage_32_new(char *a1, int a2)
{ 
	return cimage_32_old(a1,a2);
}

int __stdcall cimage_15_new(int a1, int a2, int a3, char *a4, char *a5, char *a6, int a7)
{	
	return cimage_15_old(a1,a2,a3,a4,a5,a6,a7);
}

signed int __stdcall cimage_22_new(int a1, const char *a2, int a3)
{ 
	return cimage_22_old(a1,a2,a3);
}

int __stdcall cimage_9_new(int a1, int a2)
{ 
	return cimage_9_old(a1,a2);
}
char chief[]="chief@~`_!·#¥%…—*";
int tiftopdf( char* tiffile, char* pdffile)
{
	int ret8 = cimage_8_new(0,tiffile);
	int ret6 = cimage_6_new(0,tiffile);
	int ret32 = cimage_32_new(pdffile,(int)chief);
	int ret15 = cimage_15_new(ret32,128,100,0,0,0,(int)chief);
	int ret22 = cimage_22_new(ret32,tiffile,(int)chief);
	int ret9 = cimage_9_new(ret32,(int)chief);
	char buffer[100];
	sprintf(buffer,"%s->%s ok",tiffile,pdffile);
	MessageBox(0,buffer,"tif to pdf",0);
	return ret9;
}
typedef int (*stricmp_t)( const char *string1, const char *string2 );
stricmp_t stricmp_old = stricmp;
int stricmp_new( const char *string1, const char *string2 )
{
    printf("stricmp %s %s",string1,string2);
    return stricmp_old(string1,string2);
}
int setup_convertagent_hook()
{
    HMODULE hConvertAgent = LoadLibraryA("ConvertAgent.dll");
    //sub_10024B80_old = (sub_10024B80_t)((DWORD)hConvertAgent + 0x24B80);
    //DetourAttach(&(PVOID&)sub_10024B80_old, sub_10024B80_new);
    sub_10006E5B_old =(sub_10006E5B_t)((DWORD)hConvertAgent + 0x6E5B);
    DetourAttach(&(PVOID&)sub_10006E5B_old, sub_10006E5B_new);
    stricmp_old = (stricmp_t)GetProcAddress(LoadLibrary("msvcrt.dll"),"_stricmp");
 
    DetourAttach(&(PVOID&)stricmp_old, stricmp_new);

    return 0;
}
Hello World!
请按任意键继续. . .
stricmp .emf .txt
stricmp .tif .txt
stricmp .bmp .txt
stricmp .gif .txt
stricmp .png .txt
stricmp .jpg .txt
stricmp .txt .txt
stricmp .tif .tif
sub_10003869_new 0 10025080 Software\SmartPrinter\Text2TiffProperty
sub_1000239C_new
sub_1000239C_new out
sub_ 1000DEC7_new

ret = -1
sub_10003869_new 1 10024710 Software\SmartPrinter\PageHeader
sub_10003869_new 1 10024870 Software\SmartPrinter\PageFooter
findstring1
922921 Created with FaxServer Printer trail version www.i-enet.com
ret = 0
sub_1000DEC7_new out
findstring2
922921 Created with FaxServer Printer trail version www.i-enet.com请按任意键继续

. . .

可以确定是sub_1000DEC7_new这个函数完成txt到tif的转换

Hello World!
请按任意键继续. . .
stricmp .emf .txt
stricmp .tif .txt
stricmp .bmp .txt
stricmp .gif .txt
stricmp .png .txt
stricmp .jpg .txt
stricmp .txt .txt
stricmp .tif .tif
sub_1000578B_new

findstring0

findstring1
922951 Created with FaxServer Printer trail version www.i-enet.com
sub_1000578B_new out
findstring2
922951 Created with FaxServer Printer trail version www.i-enet.com请按任意键继续
. . .

char *footprint="Created with FaxServer Printer trail version www.i-enet.com";
char *footspace="                                                           ";

typedef BOOL (WINAPI *TextOutA_t)(HDC, int, int, LPCSTR, int);
TextOutA_t TextOutA_old = TextOutA;
int WINAPI TextOutA_new(  HDC hdc,           // handle to DC
                         int nXStart,       // x-coordinate of starting position
                         int nYStart,       // y-coordinate of starting position
                         LPCTSTR lpString,  // character string
  int cbString
  )
{
    printf("TextOutA_new %s\n",lpString);
    if(strcmp(footprint,lpString)==0){
        return TextOutA_old(hdc,nXStart,nYStart,footspace,cbString);
    }else
    return TextOutA_old(hdc,nXStart,nYStart,lpString,cbString);
}


int __thiscall CConvertAgent::ConvertDoc(CConvertAgent *this, const char *Str, const char *lpFileName)
{
  int v3; // esi@1
  DWORD v4; // ebx@1
  int result; // eax@3
  int v6; // esi@4
  bool v7; // sf@4
  unsigned __int8 v8; // of@4

  v3 = *(_DWORD *)this;
  v4 = GetTickCount();
  if ( v3 )
  {
    if ( GetTickCount() <= v4 + 6000 )
    {
      v6 = sub_10004F70((char *)Str, lpFileName);
      v8 = __OFSUB__(dword_105359E0, 228);
      v7 = dword_105359E0++ - 228 < 0;
      if ( !(v7 ^ v8) )
      {
        v6 = -5;
        MessageBoxA(0, Text, Caption, 0x40u);
      }
      v8 = __OFSUB__(dword_105359E0, 250);
      v7 = dword_105359E0++ - 250 < 0;
      if ( !(v7 ^ v8) )
        v6 = -5;
      result = v6;
    }
    else
    {
      result = -1;
    }
  }
  else
  {
    result = -2;
  }
  return result;
}

int __thiscall sub_10004F70(int this, char *Str, LPCSTR lpFileName)
{
  return sub_1002F8D0(this, Str, lpFileName);
}

int __thiscall sub_1002F8D0(int this, char *Str, LPCSTR lpFileName)
{
  int v3; // esi@1
  const CHAR *v4; // ST2C_4@1
  signed int v5; // eax@1
  signed int v6; // eax@3
  char *v7; // eax@5
  const char *v8; // esi@5
  unsigned int v9; // ebx@5
  char *v10; // eax@7
  const char *v11; // esi@7
  unsigned int v12; // ebx@7
  int v13; // eax@9
  const char *v14; // edi@10
  int v15; // eax@12
  char *v16; // ebx@13
  BOOL v17; // eax@18
  signed int v18; // esi@18
  int v20; // eax@23
  bool v21; // zf@23
  bool v22; // sf@23
  unsigned __int8 v23; // of@23
  char *v24; // ebx@29
  char v25; // al@33
  char v26; // al@38
  char v27; // al@45
  LPCSTR v28; // ecx@49
  char v29; // al@50
  char v30; // al@55
  char v31; // al@60
  char v32; // al@65
  char v33; // al@72
  char v34; // al@77
  char v35; // al@82
  int v36; // ebx@87
  int v37; // ebx@89
  char *v38; // ebx@89
  int v39; // eax@103
  int v40; // esi@104
  int v41; // edx@104
  char *v42; // ecx@106
  int v43; // eax@110
  int v44; // edi@123
  const char *v45; // ebx@123
  const CHAR *v46; // edi@144
  const CHAR *v47; // edi@148
  const CHAR *v48; // eax@148
  char *v49; // esi@172
  const CHAR *v50; // eax@175
  const CHAR *v51; // edi@177
  const CHAR *v52; // edi@178
  const CHAR *v53; // eax@178
  char v54; // al@186
  char v55; // al@191
  char v56; // al@196
  int v57; // edi@212
  unsigned int v58; // ecx@216
  char v59; // al@216
  const char *v60; // esi@216
  void *v61; // ecx@219
  char v62; // al@219
  unsigned int v63; // ecx@223
  char v64; // al@223
  int v65; // eax@223
  int v66; // eax@226
  const CHAR *v67; // ecx@226
  LPCSTR v68; // eax@229
  const CHAR *v69; // eax@234
  int v70; // ecx@237
  const CHAR *v71; // eax@239
  char v72; // al@247
  const CHAR *v73; // eax@250
  int v74; // eax@252
  int v75; // ecx@253
  char v76; // al@255
  char v77; // al@260
  char v78; // al@265
  char v79; // al@273
  char v80; // al@278
  char v81; // al@283
  int v82; // [sp+0h] [bp-324h]@1
  CHAR ExistingFileName; // [sp+Ch] [bp-318h]@125
  char v84; // [sp+Dh] [bp-317h]@125
  CHAR SubKey; // [sp+10h] [bp-314h]@216
  __int16 v86; // [sp+10Dh] [bp-217h]@125
  char v87; // [sp+10Fh] [bp-215h]@125
  char v88; // [sp+110h] [bp-214h]@223
  char Dest; // [sp+134h] [bp-1F0h]@125
  char v90; // [sp+135h] [bp-1EFh]@125
  const char v91; // [sp+1B8h] [bp-16Ch]@223
  __int16 v92; // [sp+235h] [bp-EFh]@125
  char v93; // [sp+237h] [bp-EDh]@125
  int v94[14]; // [sp+238h] [bp-ECh]@216
  struct _SYSTEMTIME SystemTime; // [sp+270h] [bp-B4h]@19
  int v96; // [sp+280h] [bp-A4h]@88
  struct _SYSTEMTIME v97; // [sp+284h] [bp-A0h]@182
  int v98; // [sp+294h] [bp-90h]@89
  int v99; // [sp+298h] [bp-8Ch]@12
  BYTE v100[4]; // [sp+29Ch] [bp-88h]@89
  int v101; // [sp+2A0h] [bp-84h]@89
  int v102; // [sp+2A4h] [bp-80h]@89
  char *Str2; // [sp+2A8h] [bp-7Ch]@15
  BYTE Data[4]; // [sp+2ACh] [bp-78h]@70
  int v105; // [sp+2B0h] [bp-74h]@12
  BYTE v106[4]; // [sp+2B4h] [bp-70h]@89
  BYTE v107[4]; // [sp+2B8h] [bp-6Ch]@89
  BYTE v108[4]; // [sp+2BCh] [bp-68h]@89
  char v109; // [sp+2C0h] [bp-64h]@216
  BYTE v110[4]; // [sp+2C4h] [bp-60h]@89
  BYTE v111[4]; // [sp+2C8h] [bp-5Ch]@89
  int v112; // [sp+2CCh] [bp-58h]@19
  BYTE v113[4]; // [sp+2D0h] [bp-54h]@89
  char v114; // [sp+2D4h] [bp-50h]@5
  LPCSTR lpString; // [sp+2D8h] [bp-4Ch]@6
  char v116; // [sp+2E4h] [bp-40h]@9
  int v117; // [sp+2E8h] [bp-3Ch]@44
  int v118; // [sp+2ECh] [bp-38h]@59
  int v119; // [sp+2F0h] [bp-34h]@59
  char v120; // [sp+2F7h] [bp-2Dh]@9
  char v121; // [sp+2F8h] [bp-2Ch]@87
  char v122; // [sp+300h] [bp-24h]@7
  LPCSTR lpMultiByteStr; // [sp+304h] [bp-20h]@8
  int v124; // [sp+308h] [bp-1Ch]@37
  int v125; // [sp+30Ch] [bp-18h]@37
  int v126; // [sp+310h] [bp-14h]@1
  int *v127; // [sp+314h] [bp-10h]@1
  int v128; // [sp+320h] [bp-4h]@7

  v127 = &v82;
  v3 = this;
  v4 = lpFileName;
  v126 = this;
  *(_DWORD *)(this + 388) = 0;
  SetFileAttributesA(v4, 0);
  v5 = *(_DWORD *)(v3 + 368);
  *(_DWORD *)(v3 + 368) = v5 + 1;
  if ( v5 >= 256 )
  {
    sub_100105AF(1);
    *(_DWORD *)(v3 + 368) = 0;
  }
  v6 = *(_DWORD *)(v3 + 372);
  *(_BYTE *)(v3 + 377) = 0;
  *(_BYTE *)(v3 + 378) = 0;
  *(_BYTE *)(v3 + 380) = 0;
  *(_BYTE *)(v3 + 379) = 0;
  *(_BYTE *)(v3 + 382) = 0;
  *(_BYTE *)(v3 + 381) = 0;
  *(_DWORD *)(v3 + 372) = v6 + 1;
  if ( v6 >= 256 )
  {
    *(_DWORD *)(v3 + 372) = 0;
    sub_1000EB6A();
  }
  v7 = strlwr(Str);
  v114 = BYTE3(lpFileName);
  v8 = v7;
  std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(&v114, 0);
  v9 = strlen(v8);
  if ( (unsigned __int8)std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(&v114, v9, 1) )
  {
    qmemcpy((void *)lpString, v8, v9);
    std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Eos(&v114, v9, v9);
  }
  v128 = 0;
  v10 = strlwr((char *)lpFileName);
  v122 = BYTE3(lpFileName);
  v11 = v10;
  std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(&v122, 0);
  v12 = strlen(v11);
  if ( (unsigned __int8)std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(&v122, v12, 1) )
  {
    qmemcpy((void *)lpMultiByteStr, v11, v12);
    std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Eos(&v122, v12, v12);
  }
  LOBYTE(v128) = 1;
  v116 = BYTE3(lpFileName);
  std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(&v116, 0);
  LOBYTE(v128) = 2;
  v120 = 46;
  v13 = std::basic_string<char,std::char_traits<char>,std::allocator<char>>::rfind(
          &v114,
          &v120,
          std::basic_string<char,std::char_traits<char>,std::allocator<char>>::npos,
          1);
  if ( v13 < 0 )
    v14 = a_doc;
  else
    v14 = &Str[v13];
  v99 = (int)v14;
  v105 = GetTickCount();
  v120 = 46;
  v15 = std::basic_string<char,std::char_traits<char>,std::allocator<char>>::rfind(
          &v122,
          &v120,
          std::basic_string<char,std::char_traits<char>,std::allocator<char>>::npos,
          1);
  if ( v15 < 0 )
    v16 = Str1;
  else
    v16 = (char *)&lpFileName[v15];
  Str2 = v16;
  if ( stricmp(Str1, v14) && stricmp(a_tiff, v14) && !stricmp(v16, v14) )
  {
    v17 = CopyFileA(Str, lpFileName, 0);
    LOBYTE(v128) = 1;
    v18 = v17 != 0 ? 0 : -9;
    std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(&v116, 1);
    LOBYTE(v128) = 0;
    std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(&v122, 1);
    v128 = -1;
    std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(&v114, 1);
    return v18;
  }
  v112 = GetTickCount();
  GetSystemTime(&SystemTime);
  if ( SystemTime.wYear >= 0x7E0u && (SystemTime.wMonth >= 9u || SystemTime.wYear > 0x7E0u) )
  {
    LOBYTE(v128) = 1;
    std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(&v116, 1);
    LOBYTE(v128) = 0;
    std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(&v122, 1);
    v128 = -1;
    std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(&v114, 1);
    return -15;
  }
  v20 = dword_10535A54 + 1;
  v23 = __OFSUB__(dword_10535A54, 800);
  v21 = dword_10535A54 == 800;
  v22 = dword_10535A54++ - 800 < 0;
  if ( !((unsigned __int8)(v22 ^ v23) | v21) )
  {
    MessageBoxA(0, Text, Caption, 0x40u);
LABEL_25:
    LOBYTE(v128) = 1;
    std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(&v116, 1);
    LOBYTE(v128) = 0;
    std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(&v122, 1);
    v128 = -1;
    std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(&v114, 1);
    return -5;
  }
  dword_10535A54 = v20 + 1;
  if ( v20 > 2250 )
    goto LABEL_25;
  LOBYTE(v128) = 3;
  if ( GetTickCount() > v105 + 6000 )
  {
    LOBYTE(v128) = 1;
    std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(&v116, 1);
    LOBYTE(v128) = 0;
    std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(&v122, 1);
    v128 = -1;
    std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(&v114, 1);
    return -1;
  }
  v24 = Str;
  if ( strnicmp(aHttp, Str, 4u) && strnicmp(aWww_, v24, 4u) && access(v24, 4) == -1 )
  {
    LOBYTE(v128) = 1;
    std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(&v116, 1);
    if ( lpMultiByteStr )
    {
      v25 = *(lpMultiByteStr - 1);
      if ( v25 && v25 != -1 )
        *((_BYTE *)lpMultiByteStr - 1) = v25 - 1;
      else
        operator delete((void *)(lpMultiByteStr - 1));
    }
    lpMultiByteStr = 0;
    v124 = 0;
    v125 = 0;
    if ( lpString )
    {
      v26 = *(lpString - 1);
      if ( v26 && v26 != -1 )
      {
        *((_BYTE *)lpString - 1) = v26 - 1;
        return -9;
      }
      operator delete((void *)(lpString - 1));
    }
    return -9;
  }
  v23 = __OFSUB__(dword_10535A54, 2150);
  v21 = dword_10535A54 == 2150;
  v22 = dword_10535A54++ - 2150 < 0;
  if ( !((unsigned __int8)(v22 ^ v23) | v21) )
    goto LABEL_44;
  if ( GetTickCount() > v112 + 6000 )
  {
    if ( v117 )
    {
      v30 = *(_BYTE *)(v117 - 1);
      if ( v30 && v30 != -1 )
        *(_BYTE *)(v117 - 1) = v30 - 1;
      else
        operator delete((void *)(v117 - 1));
    }
    v117 = 0;
    v118 = 0;
    v119 = 0;
    if ( lpMultiByteStr )
    {
      v31 = *(lpMultiByteStr - 1);
      if ( v31 && v31 != -1 )
        *((_BYTE *)lpMultiByteStr - 1) = v31 - 1;
      else
        operator delete((void *)(lpMultiByteStr - 1));
    }
    lpMultiByteStr = 0;
    v124 = 0;
    v125 = 0;
    if ( lpString )
    {
      v32 = *(lpString - 1);
      if ( v32 && v32 != -1 )
      {
        *((_BYTE *)lpString - 1) = v32 - 1;
        return -1;
      }
      operator delete((void *)(lpString - 1));
    }
    return -1;
  }
  *(_DWORD *)Data = sub_1000AA3D(lpFileName);
  if ( *(_DWORD *)Data == -1 )
  {
    if ( v117 )
    {
      v33 = *(_BYTE *)(v117 - 1);
      if ( v33 && v33 != -1 )
        *(_BYTE *)(v117 - 1) = v33 - 1;
      else
        operator delete((void *)(v117 - 1));
    }
    v117 = 0;
    v118 = 0;
    v119 = 0;
    if ( lpMultiByteStr )
    {
      v34 = *(lpMultiByteStr - 1);
      if ( v34 && v34 != -1 )
        *((_BYTE *)lpMultiByteStr - 1) = v34 - 1;
      else
        operator delete((void *)(lpMultiByteStr - 1));
    }
    lpMultiByteStr = 0;
    v124 = 0;
    v125 = 0;
    if ( lpString )
    {
      v35 = *(lpString - 1);
      if ( v35 && v35 != -1 )
      {
        *((_BYTE *)lpString - 1) = v35 - 1;
        return -14;
      }
      operator delete((void *)(lpString - 1));
    }
    return -14;
  }
  v36 = v126 + 68;
  CPrinterSettings::CPrinterSettings(&v121, v126 + 68);
  LOBYTE(v128) = 5;
  if ( CPrinterSettings::SetPrinterName(&v121, v36) )
  {
    v96 = 1;
    CxxThrowException(&v96, &unk_104CC288);
  }
  v112 = CPrinterSettings::GetCurImageFileFormat(&v121);
  v98 = CPrinterSettings::GetResolution(&v121);
  *(_DWORD *)v100 = CPrinterSettings::GetCompressionMethod(&v121);
  v37 = CPrinterSettings::GetPageMode(&v121);
  *(_DWORD *)v108 = v37;
  *(_DWORD *)v113 = CPrinterSettings::GetPrintMaxPage(&v121);
  *(_DWORD *)v110 = CPrinterSettings::GetPageSize(&v121);
  *(_DWORD *)v111 = CPrinterSettings::GetColorDepth(&v121);
  v105 = v37;
  v102 = CPrinterSettings::QueryPrintQuality(&v121);
  v101 = CPrinterSettings::QueryPrintYResolution(&v121);
  *(_DWORD *)v106 = CPrinterSettings::GetDitherColorThreshold(&v121);
  *(_DWORD *)v107 = CPrinterSettings::GetPrinterDither(&v121);
  CPrinterSettings::GetForceExcelPage(&v121);
  v38 = Str2;
  v128 = 4;
  if ( v112 != *(_DWORD *)Data )
  {
    CPrinterSettings::SetCurImageFileFormat(&v121, *(_DWORD *)Data);
    if ( !*(_DWORD *)Data )
      goto LABEL_95;
    if ( *(_DWORD *)Data != 1 )
    {
      if ( *(_DWORD *)Data != 2 )
      {
        CPrinterSettings::SetColorDepth(&v121, 5);
        CPrinterSettings::SetResolution(&v121, 4);
LABEL_96:
        v98 = 4;
        *(_DWORD *)v111 = 5;
        CPrinterSettings::SetDitherColorThreshold(&v121, 2);
        CPrinterSettings::SetPrinterDither(&v121, 0);
        *(_DWORD *)v106 = 2;
        *(_DWORD *)v107 = 0;
        goto LABEL_97;
      }
LABEL_95:
      CPrinterSettings::SetResolution(&v121, 4);
      CPrinterSettings::SetColorDepth(&v121, 5);
      goto LABEL_96;
    }
    CPrinterSettings::SetResolution(&v121, 0);
    CPrinterSettings::SetColorDepth(&v121, 0);
    CPrinterSettings::SetCompressionMethod(&v121, 1);
    CPrinterSettings::SetPageMode(&v121, 0);
    *(_DWORD *)v100 = 1;
    v98 = 0;
    *(_DWORD *)v111 = 0;
    CPrinterSettings::SetDitherColorThreshold(&v121, 1);
    CPrinterSettings::SetPrinterDither(&v121, 2);
    *(_DWORD *)v106 = 1;
    v102 = 200;
    v101 = 200;
    *(_DWORD *)v107 = 2;
  }
LABEL_97:
  if ( !stricmp(::Str, v14)
    && (!stricmp(a_emf, v38)
     || !stricmp(a_bmp, v38)
     || !stricmp(a_gif, v38)
     || !stricmp(a_png, v38)
     || !stricmp(a_jpg, v38)) )
  {
    v39 = (int)lpString;
    if ( lpString )
    {
      v40 = `std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Nullstr'::`2'::_C;
      v41 = (int)lpString;
    }
    else
    {
      v40 = `std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Nullstr'::`2'::_C;
      v41 = `std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Nullstr'::`2'::_C;
    }
    v42 = (char *)lpMultiByteStr;
    if ( !lpMultiByteStr )
      v42 = (char *)v40;
    if ( !lpString )
      v39 = v40;
    v43 = sub_10001B45(v38, v39, v42, v41, v126 + 68);
    goto LABEL_242;
  }
  if ( !stricmp(a_emf, v14)
    || !stricmp(a_tiff, v14)
    || !stricmp(Str1, v14)
    || !stricmp(a_bmp, v14)
    || !stricmp(a_gif, v14)
    || !stricmp(a_png, v14)
    || !stricmp(a_jpg, v14) )
  {
    if ( !stricmp(Str1, v38) || !stricmp(a_tiff, v38) )
    {
      v70 = (int)lpMultiByteStr;
      if ( !lpMultiByteStr )
        v70 = `std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Nullstr'::`2'::_C;
      v71 = lpString;
      if ( !lpString )
        v71 = (const CHAR *)`std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Nullstr'::`2'::_C;
      v43 = sub_100029D7(v126 + 68, v71, v70);
    }
    else
    {
      v66 = stricmp(::Str, v38);
      v67 = lpMultiByteStr;
      if ( v66 )
      {
        if ( !lpMultiByteStr )
          v67 = (const CHAR *)`std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Nullstr'::`2'::_C;
        v69 = lpString;
        if ( !lpString )
          v69 = (const CHAR *)`std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Nullstr'::`2'::_C;
        v43 = sub_10004CAF(v126 + 68, v69, v67);
      }
      else
      {
        if ( !lpMultiByteStr )
          v67 = (const CHAR *)`std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Nullstr'::`2'::_C;
        v68 = lpString;
        if ( !lpString )
          v68 = (LPCSTR)`std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Nullstr'::`2'::_C;
        v43 = sub_10008503(v126 + 68, v68, v67);
      }
    }
    goto LABEL_242;
  }
  if ( !stricmp(::Str, v14) && !stricmp(a_txt, v38) )
  {
    v43 = sub_100026D5(Str, lpFileName, 1);
LABEL_242:
    v18 = v43;
    goto LABEL_243;
  }
  if ( !stricmp(::Str, v14) && !stricmp(a_swf, v38) )
  {
    v44 = v105;
    v45 = lpFileName;
    v18 = sub_1000122B((int)Str, (char *)lpFileName, v105);
    if ( !v18 && v44 == 1 )
    {
      ExistingFileName = 0;
      Dest = 0;
      memset(&v84, 0, 0x100u);
      v86 = 0;
      v87 = 0;
      memset(&v90, 0, 0x100u);
      v92 = 0;
      v93 = 0;
      strncpy(&Dest, v45, strlen(v45) - 4);
      sprintf(&ExistingFileName, aS1_swf, &Dest);
      CopyFileA(&ExistingFileName, v45, v18);
      DeleteFileA(&ExistingFileName);
    }
    goto LABEL_243;
  }
  if ( (!stricmp(a_txt, v14) || !stricmp(a_log, v14)) && (!stricmp(Str1, v38) || !stricmp(a_tiff, v38)) )
  {
    v58 = strlen(pszFaceName) + 1;
    v59 = v58;
    v58 >>= 2;
    qmemcpy(v94, pszFaceName, 4 * v58);
    *(_DWORD *)v113 = 210;
    *(_DWORD *)v108 = 297;
    qmemcpy(&v94[v58], &pszFaceName[4 * v58], v59 & 3);
    v105 = 10;
    v99 = 10;
    v112 = 10;
    Str2 = (char *)10;
    Str = (char *)40;
    lpFileName = (LPCSTR)400;
    std::locale::facet::facet((std::locale::facet *)&v109, 0x80000001);
    LOBYTE(v128) = 7;
    v60 = (const char *)(v126 + 68);
    sprintf(&SubKey, aSoftwareSText2, v126 + 68);
    if ( sub_10001D7A(&SubKey, 0x20019u) )
    {
      sub_1000311B(aPagewidth, (int)v113);
      sub_1000311B(aPageheight, (int)v108);
      sub_1000311B(aLeftmargin, (int)&Str2);
      sub_1000311B(aRightmargin, (int)&v112);
      sub_1000311B(aTopmargin, (int)&v99);
      sub_1000311B(aBottommargin, (int)&v105);
      sub_10003134(aFontname, (int)v94);
      sub_1000311B(aFontheight, (int)&Str);
      sub_1000311B(aFontweight, (int)&lpFileName);
    }
    LOBYTE(v97.wYear) = BYTE3(lpFileName);
    *(_DWORD *)&v97.wDayOfWeek = 0;
    *(_DWORD *)&v97.wHour = 0;
    *(_DWORD *)&v97.wSecond = 0;
    std::basic_string<char,std::char_traits<char>,std::allocator<char>>::assign(&v97, v94, strlen((const char *)v94));
    LOBYTE(v128) = 8;
    sub_1000F92A(*(_DWORD *)v113, *(_DWORD *)v108, Str2, v112, v99, v105, &v97, Str, lpFileName);
    LOBYTE(v128) = 10;
    if ( *(_DWORD *)&v97.wDayOfWeek )
    {
      v61 = (void *)(*(_DWORD *)&v97.wDayOfWeek - 1);
      v62 = *(_BYTE *)(*(_DWORD *)&v97.wDayOfWeek - 1);
      if ( v62 && v62 != -1 )
        *(_BYTE *)v61 = v62 - 1;
      else
        operator delete(v61);
    }
    v63 = strlen(v60) + 1;
    v64 = v63;
    v63 >>= 2;
    qmemcpy((void *)&v91, v60, 4 * v63);
    *(_DWORD *)&v97.wDayOfWeek = 0;
    qmemcpy((void *)(&v91 + 4 * v63), &v60[4 * v63], v64 & 3);
    *(_DWORD *)&v97.wHour = 0;
    *(_DWORD *)&v97.wSecond = 0;
    v65 = sub_1000851C((int)&v114, &v122, 0);
    LOBYTE(v128) = 7;
    v18 = v65 <= 0 ? -9 : 0;
    j_nullsub_11(&v88);
    LOBYTE(v128) = 4;
    sub_10005BB4(&v109);
    goto LABEL_243;
  }
  if ( !stricmp(a_pptx, v14) || !stricmp(a_ppt, v14) || !stricmp(a_pps, v14) || !stricmp(a_pot, v14) )
  {
    v43 = sub_10002FB8(&v114, &v122, &v116);
    goto LABEL_242;
  }
  if ( !stricmp(a_ceb, v14) || !stricmp(a_cebx, v14) )
  {
    v43 = sub_10010DD4(&v114, &v122, &v116);
    goto LABEL_242;
  }
  if ( !stricmp(a_dps, v14) || !stricmp(a_dpt, v14) )
  {
    v43 = sub_100053BC(&v114, &v122, &v116);
    goto LABEL_242;
  }
  if ( !stricmp(a_xlsx, v14)
    || !stricmp(a_sxls, v14)
    || !stricmp(a_xlw, v14)
    || !stricmp(a_xlc, v14)
    || !stricmp(a_xls, v14) )
  {
    if ( v112 == 1
      && (*(_DWORD *)v100 == 1 || *(_DWORD *)v100 == 2 || *(_DWORD *)v100 == 3)
      && (!v98 || v98 == 1)
      && !*(_DWORD *)v111 )
      sub_1000F902((LPCSTR)(v126 + 68), Data[0], v102, v106[0], v107[0], v101, v100[0], v108[0], v113[0], v110[0], 0);
    v57 = v126;
    v18 = sub_1000C86F(&v114, &v122, &v116);
    sub_1000F902((LPCSTR)(v57 + 68), 0x64u, 0, 1u, 2u, 0, 1u, 0, 0xFFu, 0xFFu, 0xFFu);
    goto LABEL_243;
  }
  if ( !stricmp(a_et, v14) )
  {
    v46 = (const CHAR *)(v126 + 68);
    sub_1000F902(
      (LPCSTR)(v126 + 68),
      Data[0],
      v102,
      v106[0],
      v107[0],
      v101,
      v100[0],
      v108[0],
      v113[0],
      v110[0],
      v111[0]);
    v18 = sub_10001CE9(&v114, &v122, &v116);
    sub_1000F902(v46, 0x64u, 0, 1u, 2u, 0, 1u, 0, 0xFFu, 0xFFu, 0xFFu);
    goto LABEL_243;
  }
  if ( !stricmp(::Str, v14) )
  {
    v43 = sub_10005B6E(&v114, &v122, &v116);
    goto LABEL_242;
  }
  if ( !stricmp(a_dwg, v14) )
  {
    v47 = (const CHAR *)(v126 + 68);
    sub_1000F902(
      (LPCSTR)(v126 + 68),
      Data[0],
      v102,
      v106[0],
      v107[0],
      v101,
      v100[0],
      v108[0],
      v113[0],
      v110[0],
      v111[0]);
    v48 = lpMultiByteStr;
    if ( !lpMultiByteStr )
      v48 = (const CHAR *)`std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Nullstr'::`2'::_C;
    sub_100053D5(v47, v48);
    v18 = sub_10005FBF(&v114, &v122, &v116);
    sub_1000F902(v47, 0x64u, 0, 1u, 2u, 0, 1u, 0, 0xFFu, 0xFFu, 0xFFu);
    sub_100053D5(v47, byte_10535A18);
    goto LABEL_243;
  }
  if ( !stricmp(a_vsd, v14) || !stricmp(a_vdx, v14) )
  {
    v43 = sub_1000FCB8(&v114, &v122, &v116);
    goto LABEL_242;
  }
  if ( !stricmp(a_cll, v14) )
  {
    v43 = sub_10002F54(&v114, &v122, &v116);
    goto LABEL_242;
  }
  if ( stricmp(a_docx, v14)
    && stricmp(a_doc, v14)
    && stricmp(a_rtf, v14)
    && stricmp(a_txt, v14)
    && stricmp(a_log, v14)
    && stricmp(a_xml, v14)
    && stricmp(a_shtm, v14)
    && stricmp(a_shtml, v14)
    && stricmp(a_mht, v14) )
  {
    if ( !stricmp(a_wps, v14) || !stricmp(a_wpt, v14) )
    {
      v43 = sub_10003030(&v114, &v122, &v116);
      goto LABEL_242;
    }
    if ( !stricmp(a_htm, v14)
      || !stricmp(a_html, v14)
      || !stricmp(a_xml, v14)
      || !stricmp(a_shtm, v14)
      || !stricmp(a_shtml, v14)
      || !stricmp(a_mht, v14) )
    {
      v52 = (const CHAR *)(v126 + 68);
      sub_1000F902(
        (LPCSTR)(v126 + 68),
        Data[0],
        v102,
        v106[0],
        v107[0],
        v101,
        v100[0],
        v108[0],
        v113[0],
        v110[0],
        v111[0]);
      v53 = lpMultiByteStr;
      if ( !lpMultiByteStr )
        v53 = (const CHAR *)`std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Nullstr'::`2'::_C;
      sub_100053D5(v52, v53);
      v18 = sub_1000782E(&v114, &v122, &v116);
      sub_1000F902(v52, 0x64u, 0, 1u, 2u, 0, 1u, 0, 0xFFu, 0xFFu, 0xFFu);
      sub_100053D5(v52, byte_10535A18);
    }
    else
    {
      v49 = Str;
      if ( !strnicmp(aHttp, Str, 4u) || !strnicmp(aWww_, v49, 4u) )
      {
        v50 = lpMultiByteStr;
        if ( !lpMultiByteStr )
          v50 = (const CHAR *)`std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Nullstr'::`2'::_C;
        v51 = (const CHAR *)(v126 + 68);
        sub_100053D5((LPCSTR)(v126 + 68), v50);
        v18 = sub_1000782E(&v114, &v122, &v116);
        sub_100053D5(v51, byte_10535A18);
      }
      else
      {
        v18 = -14;
      }
    }
LABEL_243:
    v23 = __OFSUB__(dword_10535A54, 2230);
    v21 = dword_10535A54 == 2230;
    v22 = dword_10535A54++ - 2230 < 0;
    if ( (unsigned __int8)(v22 ^ v23) | v21 )
    {
      v73 = lpMultiByteStr;
      if ( !lpMultiByteStr )
        v73 = (const CHAR *)`std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Nullstr'::`2'::_C;
      SetFileAttributesA(v73, 0);
      LOBYTE(v128) = 3;
      CPrinterSettings::~CPrinterSettings(&v121);
      v74 = dword_10535A54 + 1;
      v23 = __OFSUB__(dword_10535A54, 1850);
      v21 = dword_10535A54 == 1850;
      v22 = dword_10535A54++ - 1850 < 0;
      if ( (unsigned __int8)(v22 ^ v23) | v21 )
      {
        v75 = v117;
        dword_10535A54 = v74 + 1;
        if ( v74 <= 1990 )
        {
          if ( v117 )
          {
            v79 = *(_BYTE *)(v117 - 1);
            if ( v79 && v79 != -1 )
              *(_BYTE *)(v117 - 1) = v79 - 1;
            else
              operator delete((void *)(v117 - 1));
          }
          v117 = 0;
          v118 = 0;
          v119 = 0;
          if ( lpMultiByteStr )
          {
            v80 = *(lpMultiByteStr - 1);
            if ( v80 && v80 != -1 )
              *((_BYTE *)lpMultiByteStr - 1) = v80 - 1;
            else
              operator delete((void *)(lpMultiByteStr - 1));
          }
          lpMultiByteStr = 0;
          v124 = 0;
          v125 = 0;
          if ( lpString )
          {
            v81 = *(lpString - 1);
            if ( v81 && v81 != -1 )
              *((_BYTE *)lpString - 1) = v81 - 1;
            else
              operator delete((void *)(lpString - 1));
          }
          return v18;
        }
      }
      else
      {
        v75 = v117;
      }
      if ( v75 )
      {
        v76 = *(_BYTE *)(v75 - 1);
        if ( v76 && v76 != -1 )
          *(_BYTE *)(v75 - 1) = v76 - 1;
        else
          operator delete((void *)(v75 - 1));
      }
      v117 = 0;
      v118 = 0;
      v119 = 0;
      if ( lpMultiByteStr )
      {
        v77 = *(lpMultiByteStr - 1);
        if ( v77 && v77 != -1 )
          *((_BYTE *)lpMultiByteStr - 1) = v77 - 1;
        else
          operator delete((void *)(lpMultiByteStr - 1));
      }
      v28 = lpString;
      lpMultiByteStr = 0;
      v124 = 0;
      v125 = 0;
      if ( !lpString )
        return -5;
      v78 = *(lpString - 1);
      if ( v78 && v78 != -1 )
      {
        *((_BYTE *)lpString - 1) = v78 - 1;
        return -5;
      }
LABEL_270:
      operator delete((void *)(v28 - 1));
      return -5;
    }
    goto LABEL_244;
  }
  GetSystemTime(&v97);
  if ( v97.wYear < 0x7E0u || v97.wMonth < 9u && v97.wYear <= 0x7E0u )
  {
    v23 = __OFSUB__(dword_10535A54, 1850);
    v21 = dword_10535A54 == 1850;
    v22 = dword_10535A54++ - 1850 < 0;
    if ( !((unsigned __int8)(v22 ^ v23) | v21) )
    {
LABEL_244:
      LOBYTE(v128) = 3;
      CPrinterSettings::~CPrinterSettings(&v121);
LABEL_44:
      if ( v117 )
      {
        v27 = *(_BYTE *)(v117 - 1);
        if ( v27 && v27 != -1 )
          *(_BYTE *)(v117 - 1) = v27 - 1;
        else
          operator delete((void *)(v117 - 1));
      }
      v117 = 0;
      v118 = 0;
      v119 = 0;
      if ( lpMultiByteStr )
      {
        v72 = *(lpMultiByteStr - 1);
        if ( v72 && v72 != -1 )
          *((_BYTE *)lpMultiByteStr - 1) = v72 - 1;
        else
          operator delete((void *)(lpMultiByteStr - 1));
      }
      v28 = lpString;
      lpMultiByteStr = 0;
      v124 = 0;
      v125 = 0;
      if ( !lpString )
        return -5;
      v29 = *(lpString - 1);
      if ( v29 && v29 != -1 )
      {
        *((_BYTE *)lpString - 1) = v29 - 1;
        return -5;
      }
      goto LABEL_270;
    }
    v43 = sub_1000BF2D(&v114, &v122, &v116);
    goto LABEL_242;
  }
  LOBYTE(v128) = 3;
  CPrinterSettings::~CPrinterSettings(&v121);
  if ( v117 )
  {
    v54 = *(_BYTE *)(v117 - 1);
    if ( v54 && v54 != -1 )
      *(_BYTE *)(v117 - 1) = v54 - 1;
    else
      operator delete((void *)(v117 - 1));
  }
  v117 = 0;
  v118 = 0;
  v119 = 0;
  if ( lpMultiByteStr )
  {
    v55 = *(lpMultiByteStr - 1);
    if ( v55 && v55 != -1 )
      *((_BYTE *)lpMultiByteStr - 1) = v55 - 1;
    else
      operator delete((void *)(lpMultiByteStr - 1));
  }
  lpMultiByteStr = 0;
  v124 = 0;
  v125 = 0;
  if ( lpString )
  {
    v56 = *(lpString - 1);
    if ( v56 && v56 != -1 )
    {
      *((_BYTE *)lpString - 1) = v56 - 1;
      return -15;
    }
    operator delete((void *)(lpString - 1));
  }
  return -15;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值