Esempio n. 1
0
/*----------------------------------------------------------------------
  DAVDisplayMessage: display a message to user.
  ---------------------------------------------------------------------- */
void DAVDisplayMessage (const char *msg, const char *arg) 
{
  if (msg && *msg) 
    {
      if (arg && *arg) 
        {
          char label[2*MAX_LENGTH];
          sprintf (label, msg, arg);
          InitInfo (" ", label);
        }
      else 
        InitInfo (" ", msg);
    }
}
Esempio n. 2
0
nsresult
nsPlatformCharset::MapToCharset(nsAString& inANSICodePage, nsACString& outCharset)
{
  //delay loading os2charset.properties bundle if possible
  if (inANSICodePage.EqualsLiteral("os2.850")) {
    outCharset.AssignLiteral("IBM850");
    return NS_OK;
  } 

  if (inANSICodePage.EqualsLiteral("os2.932")) {
    outCharset.AssignLiteral("Shift_JIS");
    return NS_OK;
  } 

  // ensure the .property file is loaded
  nsresult rv = InitInfo();
  if (NS_FAILED(rv)) {
    outCharset.AssignLiteral("IBM850");
    return rv;
  }

  nsAutoString charset;
  rv = gInfo->Get(inANSICodePage, charset);
  if (NS_FAILED(rv)) {
    outCharset.AssignLiteral("IBM850");
    return rv;
  }

  LossyCopyUTF16toASCII(charset, outCharset);
  return NS_OK;
}
void dgDeformableContact::GetInfo (dgConstraintInfo* const info) const
{
	memset (info, 0, sizeof (dgConstraintInfo));
	InitInfo (info);
	info->m_collideCollisionOn = GetCount();
	strcpy (info->m_discriptionType, "contact");
}
Esempio n. 4
0
void NewtonUserJoint::GetInfo (dgConstraintInfo* const info) const
{
	memset (info, 0, sizeof (dgConstraintInfo));
	if (m_getInfoCallback) {
		InitInfo (info);
		m_getInfoCallback ((NewtonJoint*) this, (NewtonJointRecord*)info);
	}
}
Esempio n. 5
0
BOOL CModifyMemoryDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	SetIcon(m_hIcon, TRUE);			
	SetIcon(m_hIcon, FALSE);
    // InitInfo
    InitInfo();
	return TRUE;
}
Esempio n. 6
0
BOOL CRegNewUserDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	//! 서버의 메시지를 받을수 있게 준비.
	CChatSession::Instance().SetOwnerWnd(this->GetSafeHwnd());	
	
	if(m_strId.IsEmpty() == FALSE)
	{
		m_bModify = TRUE;
		InitInfo();
	}
	else
	{
		m_bModify = FALSE ;

		TRACEX("RAWSQL_GETCOMPANY_INFO 요청!\n");
		CString		strSql;	
		strSql = GetQueryCompany(); // name, code 구한다.	
		if(CChatSession::Instance().RequestRawSQL(RAWSQL_GETCOMPANY_INFO, (LPCSTR)strSql, strlen((LPCSTR)strSql) ) != TRUE)
		{
			return FALSE ;
		}

	    Sleep(1);

		// 직급 combobox setting m_cbGrade
		TRACEX("RAWSQL_GETCLASS_INFO 요청!\n");

		strSql = GetQueryClass(); // name, code 구한다.
		if(CChatSession::Instance().RequestRawSQL(RAWSQL_GETCLASS_INFO, (LPCSTR)strSql, strlen((LPCSTR)strSql) ) != TRUE)
		{
			return FALSE ;
		}

	}
	// 사용자상태에 따른 처리
	if( m_strStatus == _T("00") )
	{
		SetDlgItemText(ID_EB_PWD, _T(""));
		SetDlgItemText(ID_EB_CONFIRM_PWD, _T(""));
	}
	else
	{
		GetDlgItem(ID_EB_REG_SID		)->EnableWindow(FALSE);
		GetDlgItem(ID_EB_REG_NAME		)->EnableWindow(FALSE);
		GetDlgItem(ID_EB_USER_ID		)->EnableWindow(FALSE);
		GetDlgItem(ID_BTN_DUPID_CHECK	)->EnableWindow(FALSE);
	}

	/////////////////////////////////////////////////////////////////

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Esempio n. 7
0
/*----------------------------------------------------------------------
  DAVPropertiesVerticalDialog: display a "Confirm" vertical 
  dialog for XML DAV properties.
  Parameters : 
  Document docid : document
  char * title : window title
  char * rheader : a header message for the rigth column
  char * lheader : a header message for the left column
  AwList * list : a list with name and value strings

  THE LIST AND ITS COMPONENTES ARE DESTROYED INSIDE THIS FUNCTION!!!!
  ---------------------------------------------------------------------- */
static void DAVPropertiesVerticalDialog (Document docid, const char *title,
    const char *rheader, const char *lheader, AwList *list) 
{
  int     lines = 0;

  if (docid > 0 && list) 
    {
      lines = AwList_size(list)/2;
      /* function not implemented yet */
      InitInfo ("", TtaGetMessage(LIB, TMSG_NOT_AVAILABLE));
    }
}
Esempio n. 8
0
/*-----------------------------------------------------------------------
  LINK_ReloadAnnotationIndex
  -----------------------------------------------------------------------
  Redisplays an already loaded annotation index.
  -----------------------------------------------------------------------*/
void LINK_ReloadAnnotationIndex (Document doc, View view)
{
  Element body;
  List *annot_list, *list_ptr;
  AnnotMeta *annot;
  DisplayMode dispMode;
  /* counts the number of orphan annotations in the document */
  int orphan_count = 0;

  annot_list = AnnotMetaData[doc].annotations;

  if (!annot_list)
    /* there are no annotations */
    return;

  /* avoid refreshing the document while adding the annotation links */
  dispMode = TtaGetDisplayMode (doc);
  if (dispMode == DisplayImmediately)
    TtaSetDisplayMode (doc, DeferredDisplay);

  /* Insert the annotations in the body */
  view = TtaGetViewFromName (doc, "Formatted_view");
  body = SearchElementInDoc (doc, HTML_EL_BODY);
  
  list_ptr = annot_list;
  
  while (list_ptr)
    {
      annot = (AnnotMeta *) list_ptr->object;
      
      if (annot->is_visible)
        {
          if (! LINK_AddLinkToSource (doc, annot))
            annot->show = TRUE;
        }
      list_ptr = list_ptr->next;
    }

  /* show the document */
  if (dispMode == DisplayImmediately)
    TtaSetDisplayMode (doc, dispMode);

  if (orphan_count)
    {
      /* warn the user there were some orphan annotations */
      InitInfo ("Annotation load", 
                "There were some orphan annotations. You may See them with the Links view.");
    }
}
Esempio n. 9
0
void CustomMsgBubble::InitControl(const nim::IMMessage &msg)
{
	GlobalManager::FillBoxWithCache(this, L"main/custom_msg.xml");

	text_ = (RichEdit*)FindSubControl(L"text");
	time_ = (Label*)FindSubControl(L"msg_time");
	name_ = (Label*)FindSubControl(L"sender_name");
	head_ = (Button*)FindSubControl(L"msg_header_button");

	ITextServices* text_services = text_->GetTextServices();
	IRichEditOleCallbackEx* richedit_cb = new IRichEditOleCallbackEx(text_services, std::function<void()>());
	text_services->Release();
	text_->SetOleCallback(richedit_cb);

	InitInfo(msg);
}
Esempio n. 10
0
void Context::InitSegment()
{
    m_segment_pos = m_file.GetPosition();

    m_file.WriteID4(0x18538067);  //Segment ID

#if 0
    m_file.Write8UInt(0);         //will need to be filled in later
#else
    m_file.Serialize8UInt(0x01FFFFFFFFFFFFFFLL);
#endif

    InitFirstSeekHead();  //Meta Seek
    InitInfo();      //Segment Info
    WriteTrack();
}
Esempio n. 11
0
//extern "C" __declspec(dllexport) int run(char * szFunName, char * szSMTo, char *szContent)   
extern "C" __declspec(dllexport) int run(char * source, char * destination, char * content)
{
	SmsSend s;
	cout<<"test sms"<<endl;
	WriteLog(">>>>>>>>run start<<<<<<<<");
	try
	{
		bool bRet = InitInfo(s,destination, content);//"卓望短信");
		if(bRet)
		{
			bRet = SendMsg(s);
			if(bRet)
			{
				return 1;
			}
			else
			{
				return 0;
			}
		}
		else
		{
			WriteLog("Init failed!");
			return 0;
		}
	}
	catch(...)
	{
		DWORD dwErr = GetLastError();
		LPSTR lpBuffer = NULL;
		::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
			NULL,
			dwErr,
			0,
			(LPTSTR)&lpBuffer,
			0,
			NULL
			);
		char strMsg[128] = {0};
		sprintf(strMsg , "Exception occured in run! error number:%d\terror msg:%s" , dwErr , lpBuffer);
		LocalFree(lpBuffer);
		WriteLog(strMsg);
		return 0;
	}
}
Esempio n. 12
0
BOOL CDlgNewEMBTask::OnInitDialog()
{
	CDialog::OnInitDialog();
	DateTime_SetFormat(m_dtCtrlPlaytime.GetSafeHwnd(), TEXT("yyyy-MM-dd HH:mm:ss"));
	m_lstSrcFtp.SetExtendedStyle( (m_lstSrcFtp.GetExtendedStyle()|LVS_EX_FULLROWSELECT|LVS_EX_CHECKBOXES|LVS_EX_GRIDLINES|LVS_SHOWSELALWAYS) &(~LVS_EX_TRACKSELECT));

	// TODO:  在此添加额外的初始化
	InitFtpListHeader();

 	InitCtrl();

	m_ptcCtrlLength = (CMxtTimecodeCtrl*)GetDlgItem(IDC_TCODE_LENGTH);
	m_ptcCtrlSom = (CMxtTimecodeCtrl*)GetDlgItem(IDC_TCODE_SOM);
	m_ptcCtrlEom = (CMxtTimecodeCtrl*)GetDlgItem(IDC_TCODE_EOM);

	InitInfo();
	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常: OCX 属性页应返回 FALSE
}
Esempio n. 13
0
nsresult nsPlatformCharset::MapToCharset(short script, short region, nsACString& outCharset)
{
  switch (region) {
    case verUS:
    case verFrance:
    case verGermany:
      outCharset.AssignLiteral("x-mac-roman");
      return NS_OK;
    case verJapan:
      outCharset.AssignLiteral("Shift_JIS");
      return NS_OK;
  }

  // ensure the .property file is loaded
  nsresult rv = InitInfo();
  NS_ENSURE_SUCCESS(rv, rv);

  // try mapping from region then from script
  nsAutoString key(NS_LITERAL_STRING("region."));
  key.AppendInt(region, 10);

  nsAutoString uCharset;
  rv = gInfo->Get(key, uCharset);
  if (NS_SUCCEEDED(rv))
    LossyCopyUTF16toASCII(uCharset, outCharset);
  else {
    key.AssignLiteral("script.");
    key.AppendInt(script, 10);
    rv = gInfo->Get(key, uCharset);
    // not found in the .property file, assign x-mac-roman
    if (NS_SUCCEEDED(rv))
      LossyCopyUTF16toASCII(uCharset, outCharset);
    else {
      outCharset.AssignLiteral("x-mac-roman");
    }
  }
  
  return NS_OK;
}
Esempio n. 14
0
TInt Initialise(TZipInfo& a)
	{
	TInt r=InitInfo(a);
	if (r!=KErrNone)
		return r;
	a.iFileBufSize=4*a.iInBufSize;
	TAny* pFileBuf=MALLOC(a.iFileBufSize);
	if (!pFileBuf)
		return KErrNoMemory;
	a.iFileBuf=(TUint8*)pFileBuf;
	RThread t;
	r=t.Create(KLitThreadName,UnzipThread,0x2000,NULL,&a);
	if (r!=KErrNone)
		{
		delete pFileBuf;
		a.iFileBuf=NULL;
		return r;
		}
	t.SetPriority(EPriorityLess);
	t.Logon(a.iThreadStatus);
	t.Resume();
	a.iThreadHandle=t.Handle();
	return KErrNone;
	}
Esempio n. 15
0
extern void GUImain( void )
/*************************/
{
    int                 argc = 0;
    char                **argv = NULL;
    char                *dir;
    char                *drive;
    char                *inf_name;
    char                *tmp_path;
    char                *arc_name;
    char                *new_inf;
    char                current_dir[_MAX_PATH];
    bool                ret = FALSE;
    dlg_state           state;

    GUIMemOpen();
    GUIGetArgs( &argv, &argc );
#if defined( __NT__ )
    if( CheckWin95Uninstall( argc, argv ) ) return;
#endif
#ifdef __WINDOWS__
    if( CheckForSetup32( argc, argv ) ) return;
#endif

    // initialize paths and env. vbls.

    if( !SetupPreInit() ) return;
    if( !GetDirParams( argc, argv, &inf_name, &tmp_path, &arc_name ) ) return;
    if( !SetupInit() ) return;
    GUIDrainEvents();   // push things along
    FileInit( arc_name );
    InitGlobalVarList();
    strcpy( current_dir, tmp_path );
    while( InitInfo( inf_name, tmp_path ) ) {

        ret = DoMainLoop( &state );

        if( state == DLG_DONE ) break;
//        if( CancelSetup == TRUE || !ret ) break;
        if( CancelSetup == TRUE ) break;
//        if( !ret ) break;

        // look for another SETUP.INF
        if( GetVariableByName( "SetupPath" ) == NO_VAR ) {
            if( DirParamStack( &inf_name, &tmp_path, Stack_IsEmpty ) == FALSE ) {  // "IsEmpty"?
                DirParamStack( &inf_name, &tmp_path, Stack_Pop ); // "Pop"
                CloseDownMessage( ret );
                CancelSetup = FALSE;
                ret = TRUE;
            } else {
                CloseDownMessage( ret );
                break;
            }
        } else {
            if( GetVariableIntVal( "IsMultiInstall" ) ) {
                // push current script on stack
                DirParamStack( &inf_name, &tmp_path, Stack_Push ); // "Push"
            }
            new_inf = GUIMemAlloc( _MAX_PATH );
            drive = GUIMemAlloc( _MAX_DRIVE );
            dir = GUIMemAlloc( _MAX_PATH );
            if( new_inf == NULL || drive == NULL || dir == NULL ) {
                GUIMemFree( new_inf );
                GUIMemFree( drive );
                GUIMemFree( dir );
                break;
            }
            // construct new path relative to previous
            ReplaceVars( new_inf, GetVariableStrVal( "SetupPath" ) );
            _splitpath( current_dir, drive, dir, NULL, NULL );
            _makepath( inf_name, drive, dir, new_inf, NULL );

            _splitpath( inf_name, drive, dir, NULL, NULL );
            _makepath( tmp_path, drive, dir, NULL, NULL );
//          strcpy( current_dir, tmp_path );

            GUIMemFree( new_inf );
            GUIMemFree( drive );
            GUIMemFree( dir );
        } /* if */

        FreeGlobalVarList( FALSE );
        FreeDefaultDialogs();
        FreeAllStructs();
        ConfigModified = FALSE;
    } /* while */


    FileFini();
    FreeGlobalVarList( TRUE );
    FreeDefaultDialogs();
    FreeAllStructs();
    FreeDirParams( &inf_name, &tmp_path, &arc_name );
    CloseDownProgram();
}
Esempio n. 16
0
void dgUserConstraint::GetInfo (dgConstraintInfo* const info) const
{
	InitInfo (info);
}
Esempio n. 17
0
/*-----------------------------------------------------------------------
  LINK_LoadAnnotationIndex
  -----------------------------------------------------------------------
  Searches for an annotation index related to the document. If it exists,
  it parses it and then, if the variable mark_visible is set true, adds
  links to them from the source document.
  -----------------------------------------------------------------------*/
void LINK_LoadAnnotationIndex (Document doc, char *annotIndex, ThotBool mark_visible)
{
  View    view;
  Element body;
  List *annot_list, *list_ptr;
  AnnotMeta *annot;
  AnnotMeta *old_annot;
  DisplayMode dispMode;
  /* counts the number of orphan annotations in the document */
  int orphan_count = 0;
#ifdef ANNOT_ON_ANNOT
  Document doc_thread;
  AnnotThreadList *thread;
#endif /* ANNOT_ON_ANNOT */

  if (!annotIndex || !(TtaFileExist (annotIndex)))
    /* there are no annotations */
    return;
  
  annot_list = RDF_parseFile (annotIndex, &AnnotMetaData[doc].rdf_model);
  TtaFreeMemory (annotIndex);
  annotIndex = NULL;
  if (!annot_list)
    /* we didn't read any annotation */
    return;

  /* avoid refreshing the document while adding the annotation links */
  dispMode = TtaGetDisplayMode (doc);
  if (dispMode == DisplayImmediately)
    TtaSetDisplayMode (doc, DeferredDisplay);

  /* Insert the annotations in the body */
  view = TtaGetViewFromName (doc, "Formatted_view");
  body = SearchElementInDoc (doc, HTML_EL_BODY);
  
  list_ptr = annot_list;

  while (list_ptr)
    {
      char *url;
      AnnotMetaDataSearch searchType;

      annot = (AnnotMeta *) list_ptr->object;
      
      /* don't add an annotation if it's already on the list */
      /* @@ JK: later, Ralph will add code to delete the old one.
         We should remove the old annotations and preserve the newer
         ones. Take into account that an anotation window may be open
         and that we'll have to close it without saving... or just update
         the metadata... */
      
      if (IsW3Path (annot->annot_url))
        {
          url = annot->annot_url;
          searchType = AM_ANNOT_URL;
        }
      else
        {
          url = annot->body_url;
          searchType = AM_BODY_URL;
        }
      old_annot = AnnotList_searchAnnot (AnnotMetaData[doc].annotations,
                                         url, searchType);
#ifdef ANNOT_ON_ANNOT
      /* do the same thing to avoid duplicating the thread items */
      if (!old_annot && AnnotThread[doc].annotations)
        old_annot = AnnotList_searchAnnot (AnnotThread[doc].annotations,
                                           url, searchType);
#endif /* ANNOT_ON_ANNOT */

      if (!old_annot)
        {
          if (mark_visible)
            {
              /* create the reverse link name */
              LINK_CreateAName (annot);
              if (! LINK_AddLinkToSource (doc, annot))
                orphan_count++;
              annot->is_visible = TRUE;
              annot->show = TRUE;
            }
          else
            annot->is_visible = FALSE;
#ifdef ANNOT_ON_ANNOT
          if (annot->inReplyTo)
            {
              doc_thread = AnnotThread_searchRoot (annot->rootOfThread);
              /* if there's no other thread, then use the source doc as the
                 start of the thread */
              if (doc_thread ==  0)
                {
                  thread = NULL;
                  doc_thread = doc;
                }
              else
                thread = &AnnotThread[doc_thread];

              /* there was no thread. Create a new one if it's the same rootOfThread document */
              if (!thread && Annot_isSameURL (AnnotMetaData[doc].annot_url, annot->rootOfThread))
                {
                  /* add the root of thread (used by load index later on) */
                  AnnotThread[doc].rootOfThread = 
                    TtaStrdup (annot->rootOfThread);
                  AnnotThread[doc].references = 1;
                  thread = &AnnotThread[doc_thread];
                }

              /* add and show the thread item */
              if (thread)
                {
                  List_add (&(thread->annotations), (void *) annot);
                  if (!AnnotMetaData[doc].thread)
                    AnnotMetaData[doc].thread = thread;
                  annot->thread = thread;
                  /* ANNOT_AddThreadItem (doc_thread, annot); */
                }
              else
                Annot_free (annot);
            }
          else /* not a reply */
#endif /* ANNOT_ON_ANNOT */
            /* Verify that the annotates property really does point
               to this document and discard if not or if there is
               no annotates property. */
            if (Annot_isSameURL (annot->source_url, DocumentURLs[doc]))
              List_add (&AnnotMetaData[doc].annotations, (void *) annot);
            else
              Annot_free (annot);
        }
      else
        Annot_free (annot);
      List_delFirst (&list_ptr);
    }

#ifdef ANNOT_ON_ANNOT
  /* erase and redisplay the thread items */
  ANNOT_DeleteThread (doc);
  if (AnnotThread[doc].annotations)
    ANNOT_BuildThread (doc);
#endif /* ANNOT_ON_ANNOT */

  /* show the document */
  if (dispMode == DisplayImmediately)
    TtaSetDisplayMode (doc, dispMode);

  if (orphan_count)
    {
      /* warn the user there were some orphan annotations */
      InitInfo ("Annotation load", 
                "There were some orphan annotations. You may See them with the Links view.");
    }
}
Esempio n. 18
0
int main(void)
{
	uint32_t regValue = 0;
	uint32_t uiReady = 0;
	uint32_t j = 0, i = 0;
	uint32_t uiRet = 0;
	uint32_t uiTaShift = 0;
	uint32_t ii = 0;
	uint32_t uiReadyNo = 0;
	int32_t iRet = 0;

	const char *m_csrDev = "/dev/axi_csr0";

	char *BramAddr0 = NULL;
	char *pBramDev0 = "/dev/xfifo_dma0";
	char *pRamDev0 = "/dev/bram0";
	char *pIrqDev0 = "/dev/counter_irq0";
	char *pDataIrq = "/dev/data_irq0";
	uint32_t uiMapLen = 4096;

	s_csrFd = open(m_csrDev, O_RDWR);
	if (s_csrFd < 0)
	{	
		ErrorInfo("can't open device %s[%d].\n", m_csrDev, s_csrFd);
		return -1;
	}
	InitInfo("csrfd is %d.\n", s_csrFd);

	/*
	   s_iBramFd = open(pBramDev0, O_RDWR);
	   if (s_iBramFd < 0)
	   {	
	   ErrorInfo("can't open device %s[%d].\n", pBramDev0, s_iBramFd);
	   return -1;
	   }
	   InitInfo("BramFd is %d.\n", s_iBramFd);
	 */

	s_iRamFd = open(pRamDev0, O_RDWR);
	if (s_iRamFd < 0)
	{
		ErrorInfo("Can't open device %s[%d].\n", pRamDev0, s_iRamFd);
		return -1;
	}

	s_iIrqFd = open(pIrqDev0, O_RDWR);
	if (s_iIrqFd < 0)
	{
		ErrorInfo("Can't open device %s[%d].\n", pIrqDev0, s_iIrqFd);
		return -1;
	}

	s_iDataIrqFd = open(pDataIrq, O_RDWR);
	if (s_iDataIrqFd < 0)
	{
		ErrorInfo("Can't open device %s[%d].\n", pDataIrq, s_iDataIrqFd);
		printf("error:%s\n",strerror(errno));
		return -1;
	}

	InitInfo("AcquisitionBoard Version 1.0 No 21 build date 2014-8-15.\n");

	//TestSd();
	InitMem();
	InitGps();
	InitNetLink();
	AcceptLink();
	//UdpInitNetLink();
	iRet = pthread_create(&s_MesgThreadId, NULL, MesgThread, NULL);
	if (iRet != 0)
	{
		ErrorInfo("Create Mesg Thread Failed![%d]\n", iRet);
		return -1;
	}

	iRet = pthread_create(&s_GpsThreadId, NULL, GpsThread, NULL);
	if (iRet != 0)
	{
		ErrorInfo("Create GPS Thread Failed![%d]\n", iRet);
		return -1;
	}

	while(1)
	{
		App();

		if (TRUE == GetReadyFlag())
		{			
			//DeliverData();
			DeliverData_s();
			//UdpDeliverData();
		}   

	}

	close(s_iBramFd);
	close(s_csrFd);
	close(s_iRamFd);
	close(s_iIrqFd);

	return 0;
}
Esempio n. 19
0
void ServiceStart(BOOL aService)
{
  DWORD ThreadID,i;
  wchar_t filename[MAX_PATH],access_filename[MAX_PATH];
  InitInfo();
  InitNotify();
  {
    HANDLE token; PTOKEN_USER token_user=NULL;
    SID_IDENTIFIER_AUTHORITY SIDAuthSystem={SECURITY_NT_AUTHORITY}; PSID pSystemSid=NULL;
    if(AllocateAndInitializeSid(&SIDAuthSystem,1,SECURITY_LOCAL_SYSTEM_RID,0,0,0,0,0,0,0,&pSystemSid))
    {
      if(OpenProcessToken(GetCurrentProcess(),TOKEN_QUERY,&token))
      {
        token_user=(PTOKEN_USER)DefaultTokenInformation(token,TokenUser);
        if(token_user)
        {
          if((token_user->User.Sid)&&(pSystemSid)&&(IsValidSid(token_user->User.Sid))&&(IsValidSid(pSystemSid))&&(EqualSid(token_user->User.Sid,pSystemSid)))
            IsSystem=TRUE;
          free(token_user);
        }
        CloseHandle(token);
      }
      FreeSid(pSystemSid);
    }
  }
  //get security from file.
  EnablePrivilege(L"SeSecurityPrivilege");
  if(!pipe_sd&&GetModuleFileNameW(NULL,filename,sizeofa(filename)))
  {
    wchar_t *filename_ptr;
    DWORD res=GetFullPathNameW(filename,sizeofa(access_filename),access_filename,&filename_ptr);
    if(res&&(res<sizeofa(access_filename))&&filename_ptr)
    {
      DWORD needed;
      wcscpy(filename_ptr,ACCESS_NAMEW);
      if(!GetFileSecurityW(access_filename,DACL_SECURITY_INFORMATION|SACL_SECURITY_INFORMATION,NULL,0,&needed))
        if(GetLastError()==ERROR_INSUFFICIENT_BUFFER)
        {
          pipe_sd=(PSECURITY_DESCRIPTOR)malloc(needed);
          if(pipe_sd)
          {
            if(!GetFileSecurityW(access_filename,DACL_SECURITY_INFORMATION|SACL_SECURITY_INFORMATION,pipe_sd,needed,&needed))
            {
              free(pipe_sd);
              pipe_sd=NULL;
            }
          }
        }
    }
  }
  //create default security
  if(!pipe_sd)
  {
    PSID pAccessSid=NULL;
    PSID pSystemSid=NULL;
    SID_IDENTIFIER_AUTHORITY SIDAuthLocal={SECURITY_LOCAL_SID_AUTHORITY};
    SID_IDENTIFIER_AUTHORITY SIDAuthEveryone={SECURITY_WORLD_SID_AUTHORITY};
    SID_IDENTIFIER_AUTHORITY SIDAuthSystem={SECURITY_NT_AUTHORITY};
    DWORD sd_size=SECURITY_DESCRIPTOR_MIN_LENGTH+sizeof(ACL);
    PACL pAcl=NULL;

    if(GetAllowNetwork()?AllocateAndInitializeSid(&SIDAuthEveryone,1,SECURITY_WORLD_RID,0,0,0,0,0,0,0,&pAccessSid):AllocateAndInitializeSid(&SIDAuthLocal,1,SECURITY_LOCAL_RID,0,0,0,0,0,0,0,&pAccessSid))
    {
      if(AllocateAndInitializeSid(&SIDAuthSystem,1,SECURITY_LOCAL_SYSTEM_RID,0,0,0,0,0,0,0,&pSystemSid))
      {
        sd_size+=2*(sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD))+GetLengthSid(pAccessSid)+GetLengthSid(pSystemSid);
        pipe_sd=(PSECURITY_DESCRIPTOR)malloc(sd_size);
        if(pipe_sd)
        {
          pAcl=(PACL)(((char *)pipe_sd)+SECURITY_DESCRIPTOR_MIN_LENGTH);
          if(!(InitializeAcl(pAcl,sd_size-SECURITY_DESCRIPTOR_MIN_LENGTH,ACL_REVISION)&&AddAccessAllowedAce(pAcl,ACL_REVISION,FILE_ALL_ACCESS,pAccessSid)&&AddAccessAllowedAce(pAcl,ACL_REVISION,FILE_ALL_ACCESS,pSystemSid)&&InitializeSecurityDescriptor(pipe_sd,SECURITY_DESCRIPTOR_REVISION)&&SetSecurityDescriptorDacl(pipe_sd,TRUE,pAcl,FALSE)))
          {
            free(pipe_sd);
            pipe_sd=NULL;
          }
        }
        FreeSid(pSystemSid);
      }
      FreeSid(pAccessSid);
    }
  }
  for(i=0;i<GetThreadCount();i++)
  {
    threads[i]=CreateThread(NULL,0,ServiceStartThread,(void *)(DWORD_PTR)i,CREATE_SUSPENDED,&ThreadID);
    if(threads[i])
    {
      SetThreadPriority(threads[i],GetHearPriority());
      ResumeThread(threads[i]);
    }
  }
  WaitStartEvent(aService);
  if(aService) ReportStatusToSCMgr(SERVICE_RUNNING,NO_ERROR,0);
}