bool
LocateTeXnicCenter (/*[out]*/ PathName & tc)
{
  PathName path;
  if (ReadPath(HKEY_LOCAL_MACHINE, L"SOFTWARE\\ToolsCenter\\TeXnicCenter", L"AppPath", path))
  {
    path += "TEXCNTR.EXE";;
    if (! File::Exists(path))
    {
      return (false);
    }
  }
  else if (ReadPath(HKEY_LOCAL_MACHINE, L"SOFTWARE\\ToolsCenter\\TeXnicCenterNT", L"AppPath", path))
  {
    path += "TeXnicCenter.exe";;
    if (! File::Exists(path))
    {
      return (false);
    }
  }
  else
  {
    return (false);
  }
  tc = path;
  return (true);
}
int _tmain(int argc, _TCHAR* argv[])
{
	//pdf原版(是0 92 40,但用0 40也可以??
	PDFPath="Z:/My Folder/Files/PDF相关/PDFs/Yes/老友记-六人行-Friends-老友妙语录.pdf";
	ReadPath(PDFPath);
	showInfo();
	List attrs=InitList();
	Attr attr=(Attr)malloc(sizeof(_Attr));
	attr->Name=ProduceNameString(L"学校®");
	attr->Value=L"北航®";
	AddNode(attrs,attr);
	attr=(Attr)malloc(sizeof(_Attr));
	attr->Name=ProduceNameString(L"学院®");
	attr->Value=L"计算机®";
	AddNode(attrs,attr);
	SaveInfo(L"标题®",L"作者®",L"主题®",L"关键词®",attrs);
	List tails=InitList();
	Attr tail=(Attr)malloc(sizeof(_Attr));
	tail->Name=ProduceNameString(L"啊啊啊啊®");
	tail->Value=L"1112®";
	AddNode(tails,tail);
	tail=(Attr)malloc(sizeof(_Attr));
	tail->Name=ProduceNameString(L"ooo®");
	tail->Value=L"计算机®";
	AddNode(tails,tail);
	ReadPath(PDFPath);
	AppendTail(tails);
	ReadPath(PDFPath);
	showInfo();
	system("pause");
	return 0;
}
bool
LocateWinEdt (/*[out]*/ PathName & winEdt)
{
  if (ReadPath(HKEY_CURRENT_USER, L"Software\\WinEdt", L"Install Root", winEdt))
  {
    winEdt += "winedt.exe";
    if (File::Exists(winEdt))
    {
      return (true);
    }
  }
  return (ReadPath(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\WinEdt.exe", 0, winEdt));
}
bool
MakeXEmacsCommandLine (/*[out]*/ string &	program,
		       /*[out]*/ string &	arguments)
{
  PathName emacsDir;
  if (! ReadPath(
    HKEY_LOCAL_MACHINE,
    L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\xemacs.exe",
    L"Path",
    emacsDir))
  {
    return (false);
  }
  PathName pathEmacs;
  pathEmacs = emacsDir;
  pathEmacs += "runemacs.exe";
  if (! File::Exists(pathEmacs))
  {
    pathEmacs = emacsDir;
    pathEmacs += "xemacs.exe";
    if (! File::Exists(pathEmacs))
    {
      return (false);
    }
  }
  program = pathEmacs.Get();
  arguments = "+%l \"%f\"";
  return (true);
}
예제 #5
0
void CFile::CheckIncbin()
{
    // Optimization: assume most lines are not incbins
    if (!(m_buffer[m_pos+0] == 'I'
       && m_buffer[m_pos+1] == 'N'
       && m_buffer[m_pos+2] == 'C'
       && m_buffer[m_pos+3] == 'B'
       && m_buffer[m_pos+4] == 'I'
       && m_buffer[m_pos+5] == 'N'
       && m_buffer[m_pos+6] == '_'))
    {
            return;
    }

    std::string idents[6] = { "INCBIN_S8", "INCBIN_U8", "INCBIN_S16", "INCBIN_U16", "INCBIN_S32", "INCBIN_U32" };
    int incbinType = -1;

    for (int i = 0; i < 6; i++)
    {
        if (CheckIdentifier(idents[i]))
        {
            incbinType = i;
            break;
        }
    }

    if (incbinType == -1)
        return;

    long oldPos = m_pos;
    long oldLineNum = m_lineNum;

    m_pos += idents[incbinType].length();

    SkipWhitespace();

    if (m_buffer[m_pos] != '(')
    {
        m_pos = oldPos;
        m_lineNum = oldLineNum;
        return;
    }

    m_pos++;

    SkipWhitespace();

    std::string path = ReadPath();

    SkipWhitespace();

    if (m_buffer[m_pos] != ')')
        FATAL_INPUT_ERROR("expected ')'");

    m_pos++;

    m_incbins.emplace(path);
}
bool
LocateNTEmacs (/*[out]*/ PathName &	ntEmacs,
	       /*[in]*/ const char *	lpszName)
{
  PathName path;
  if (! ReadPath(HKEY_LOCAL_MACHINE, L"SOFTWARE\\GNU\\Emacs", L"emacs_dir", path))
  {
    return (false);
  }
  path += "bin";
  path += lpszName;
  path.SetExtension (".exe");
  if (! File::Exists(path))
  {
    return (false);
  }
  ntEmacs = path;
  return (true);
}
예제 #7
0
void CFile::CheckInclude()
{
    if (m_buffer[m_pos] != '#')
        return;

    std::string ident = "#include";

    if (!CheckIdentifier(ident))
    {
        return;
    }

    m_pos += ident.length();

    ConsumeHorizontalWhitespace();

    std::string path = ReadPath();

    if (!path.empty()) {
        m_includes.emplace(path);
    }
}
//------------------------------------------------------------------------------
DWORD Traiter_RegBin_nk_deleted(char *fic, DWORD position, DWORD taille_fic, char *buffer, unsigned int session_id, sqlite3 *db, BOOL deleted)
{
  if (position + HBIN_CELL_NK_SIZE > taille_fic)return 1;
    HBIN_CELL_NK_HEADER *nk_h = (HBIN_CELL_NK_HEADER *)(buffer+position);
  //valide ?
  if (nk_h->key_name_size >0 && nk_h->key_name_size<taille_fic && nk_h->size>0 && (position-HBIN_CELL_NK_SIZE)&& nk_h->type == 0x6B6E)
  {
    if (nk_h->nb_values > 0 && nk_h->nb_values < 0xFFFFFFFF && nk_h->val_ls_offset < 0xFFFFFFFF && nk_h->val_ls_offset > 0)
    {
      if (!deleted) return HBIN_CELL_NK_SIZE;

      char path[MAX_LINE_SIZE]="";
      char value[MAX_LINE_SIZE];
      char data[MAX_LINE_SIZE];
      char type[MAX_LINE_SIZE];
      char parent_key_update[DATE_SIZE_MAX];
      char Owner_SID[MAX_PATH]="";

      //lecture du path complet + SID ^^
      ReadPath(buffer, taille_fic, position, path,MAX_LINE_SIZE,NULL,Owner_SID,MAX_PATH);

      //lecture des valeures ^^
      DWORD i, k;
      S_ITEM_LS *item_ls;
      HBIN_CELL_VK_HEADER *vk_h;
      char tmp[MAX_LINE_SIZE];
      char *c;

      //last update
      parent_key_update[0]=0;
      if (nk_h->last_write.dwHighDateTime != 0 || nk_h->last_write.dwLowDateTime != 0)
      {
        filetimeToString_GMT(nk_h->last_write, parent_key_update, DATE_SIZE_MAX);
        if (parent_key_update[0] != '2' && deleted) //bad date
          parent_key_update[0]=0;
      }

      BOOL val_ok;
      for (i=0;i< (nk_h->nb_values);i++)
      {
        value[0] = 0;
        type[0] = 0;
        if (nk_h->val_ls_offset+0x1000+i*HBIN_CELL_ITEM_LS+4 >= taille_fic)break;
        item_ls = (S_ITEM_LS *)&buffer[nk_h->val_ls_offset+0x1000+i*HBIN_CELL_ITEM_LS+4];
        //lecture de l'offset de la valeure :
        if (item_ls->val_of>0 && (item_ls->val_of+0x1000+HBIN_CELL_VK_SIZE)<taille_fic)
        {
          //traitement des valeures !!!
          val_ok = TRUE;
          vk_h = (HBIN_CELL_VK_HEADER *)&buffer[item_ls->val_of+0x1000];

          //récupération du nom de la valeur :
          strncpy(value,vk_h->value,MAX_LINE_SIZE);
          if (vk_h->name_size>=MAX_LINE_SIZE)value[MAX_LINE_SIZE-1]=0;
          else
          {
            value[vk_h->name_size]=0;
            if (strlen(value) != vk_h->name_size)val_ok = FALSE;
          }

          data[0] = 0;
          switch(vk_h->data_type)
          {
            //Chaines
            case 0x00000001 : //REG_SZ, chaine ASCII et Unicodes
              if (vk_h->data_size < 0xFFFFFFFF && vk_h->data_offset > 0 && vk_h->data_offset < taille_fic)
              {
                if (vk_h->data_size < 5)
                {
                  snprintf(data,MAX_LINE_SIZE,"%S",vk_h->cdata_offset);
                  data[vk_h->data_size/2]=0;
                }else snprintf(data,MAX_LINE_SIZE,"%S",(wchar_t *)&buffer[0x1000+vk_h->data_offset+HBIN_CELL_VK_DATA_PADDING_SIZE]);
              }
              strcpy(type,"REG_SZ\0");
            break;
            case 0x00000002 : //REG_EXPAND_SZ, chaine ASCII et Unicodes, contient des path type %path%
              data[0] = 0;
              if (vk_h->data_size < 0xFFFFFFFF && vk_h->data_offset > 0 && vk_h->data_offset < taille_fic)
              {
                if (vk_h->data_size < 5)
                {
                  strcpy(data,vk_h->cdata_offset);
                  data[4]=0;
                }else snprintf(data,MAX_LINE_SIZE,"%S",(wchar_t *)&buffer[0x1000+vk_h->data_offset+HBIN_CELL_VK_DATA_PADDING_SIZE]);
              }
              strcpy(type,"REG_EXPAND_SZ\0");
            break;
            case 0x00000006 : //REG_LINK, chaine ASCII et Unicodes, lien lien
              if (vk_h->data_size < 0xFFFFFFFF && vk_h->data_offset > 0 && vk_h->data_offset < taille_fic)
              {
                if (vk_h->data_size < 5)
                {
                  strcpy(data,vk_h->cdata_offset);
                  data[4]=0;
                }else snprintf(data,MAX_LINE_SIZE,"%S",(wchar_t *)&buffer[0x1000+vk_h->data_offset+HBIN_CELL_VK_DATA_PADDING_SIZE]);
              }
              strcpy(type,"REG_LINK\0");
            break;
            case 0x00000007 : //REG_MULTI_SZ, multiples chaine ASCII et Unicodes, lien
                if (vk_h->data_size < 0xFFFFFFFF && vk_h->data_offset > 0 && vk_h->data_offset < taille_fic)
                {
                  if (vk_h->data_size < 5)
                  {
                    strcpy(data,vk_h->cdata_offset);
                    data[4]=0;
                  }else
                  {
                    //traitement des chaines multiples :
                    do
                    {
                      snprintf(tmp,MAX_LINE_SIZE,"%S",(wchar_t *)&buffer[0x1000+vk_h->data_offset+HBIN_CELL_VK_DATA_PADDING_SIZE+2*strlen(data)]);
                      strncat (data,tmp,MAX_LINE_SIZE);
                      strncat (data," \0",MAX_LINE_SIZE);
                    }while (strlen(data)*2 < (vk_h->data_size));
                  }
                }
                strcpy(type,"REG_MULTI_SZ\0");
              break;
              case 0x00000003 : //REG_BINARY, données binaires
                if (vk_h->data_size < 0xFFFFFFFF && vk_h->data_offset > 0 && vk_h->data_offset < taille_fic)
                {
                  if (vk_h->data_size < 5)
                  {
                    for (k=0;k<vk_h->data_size && k/2<MAX_LINE_SIZE;k++)
                    {
                      snprintf(tmp,10,"%02X",vk_h->cdata_offset[k]&0xff);
                      strncat(data,tmp,MAX_LINE_SIZE);
                    }
                    strncat(data,"\0",MAX_LINE_SIZE);
                  }else
                  {
                    for (k=0;k<vk_h->data_size && k/2<MAX_LINE_SIZE;k++)
                    {
                      snprintf(tmp,10,"%02X",buffer[0x1000+vk_h->data_offset+HBIN_CELL_VK_DATA_PADDING_SIZE+k]&0xff);
                      strncat(data,tmp,MAX_LINE_SIZE);
                    }
                    strncat(data,"\0",MAX_LINE_SIZE);
                  }
                }
                strcpy(type,"REG_BINARY\0");
              break;
              case 0x0000000A : //REG_RESSOURCE_REQUIREMENT_LIST, données binaires
                if (vk_h->data_size < 0xFFFFFFFF && vk_h->data_offset > 0 && vk_h->data_offset < taille_fic)
                {
                  if (vk_h->data_size < 5)
                  {
                    for (k=0;k<vk_h->data_size && k/2<MAX_LINE_SIZE;k++)
                    {
                      snprintf(tmp,10,"%02X",vk_h->cdata_offset[k]&0xff);
                      strncat(data,tmp,MAX_LINE_SIZE);
                    }
                    strncat(data,"\0",MAX_LINE_SIZE);
                  }else
                  {
                    for (k=0;k<vk_h->data_size && k/2<MAX_LINE_SIZE;k++)
                    {
                      snprintf(tmp,10,"%02X",buffer[0x1000+vk_h->data_offset+HBIN_CELL_VK_DATA_PADDING_SIZE+k]&0xff);
                      strncat(data,tmp,MAX_LINE_SIZE);
                    }
                    strncat(data,"\0",MAX_LINE_SIZE);
                  }
                }
                strcpy(type,"REG_RESSOURCE_REQUIREMENT_LIST\0");
              break;
              case 0x00000004 : //REG_DWORD, données numériques 32bitschar
              case 0x00000005 : //REG_DWORD, données numériques 32bits signées
                if (vk_h->data_size > 0)
                {
                  snprintf(data,MAX_LINE_SIZE,"%08X",(unsigned int)(vk_h->data_offset&0xFFFFFFFF)); // en dword offset = valeur
                }
                strcpy(type,"REG_DWORD\0");
              break;
              case 0x0000000b : //REG_QWORD, données numériques 64bits signées
                if (vk_h->data_offset > 0 && vk_h->data_offset < taille_fic)
                {
                  c = &buffer[0x1000+vk_h->data_offset+HBIN_CELL_VK_DATA_PADDING_SIZE];
                  snprintf(data,MAX_LINE_SIZE,"0x%02X%02X%02X%02X%02X%02X%02X%02X",c[7]&0xff,c[6]&0xff,c[5]&0xff,c[4]&0xff,c[3]&0xff,c[2]&0xff,c[1]&0xff,c[0]&0xff);
                }
                strcpy(type,"REG_QWORD\0");
              break;
              default :
                if (deleted)val_ok = FALSE;
                //on ajoute pas au liste view les éléments inconnus non valides
                if (vk_h->data_size < 0xFFFFFFFF && vk_h->data_offset > 0 && vk_h->data_offset < taille_fic)
                {
                  /*for (k=0;k<vk_h->data_size && k/2<MAX_LINE_SIZE;k++)
                  {
                    snprintf(tmp,10,"%02X",buffer[0x1000+vk_h->data_offset+HBIN_CELL_VK_DATA_PADDING_SIZE+k]&0xff);
                    strncat(data,tmp,MAX_LINE_SIZE);
                  }
                  strncat(data,"\0",MAX_LINE_SIZE);*/

                  if (vk_h->data_type == 0x00000000)strcpy(type,"REG_NONE\0");
                  else val_ok = FALSE;
                }else
                {
                  if (vk_h->data_type == 0x00000000)strcpy(type,"REG_NONE\0");
                  else val_ok = FALSE;
                }
              break;
          }

          if (val_ok && strlen(value) || strlen(data))
          {
            //ajout de l'item
            addDeletedKey(fic, path, value, data, type,Owner_SID, parent_key_update,session_id, db);
          }
        }else break;
      }

      //no value : only directory
      if ((nk_h->nb_values < 1 || nk_h->nb_values == 0xFFFFFFFF) && (nk_h->nb_subkeys < 1 || nk_h->nb_subkeys == 0xFFFFFFFF))
      {
        addDeletedKey(fic, path, "", "", "", Owner_SID, parent_key_update,session_id, db);
      }
    }
    return HBIN_CELL_NK_SIZE;
  }
  return 1;
}