void OverwriteDlg::_DisplayFileInfo(void) {

  TSTRING tsTitle;
  TSTRING tsShortFile = GetFileFromPath(m_tsSrc);

 /*
  * Truncate file if necessary
  */
  tsShortFile = FileGetCompactName(tsShortFile, OD_MAXCURFILE);

  sprintf(tsTitle, _T("The file '%s' already exists in the")
          _T(" destination directory. Would you like to ")
          _T("replace this file:"), tsShortFile.c_str());

  m_sTitle.SetWindowText(tsTitle);

  SHFILEINFO sfi = {0};

  SHGetFileInfo(m_tsSrc.c_str(),
                0,
                &sfi,
                sizeof(sfi),
                SHGFI_ATTRIBUTES | SHGFI_LARGEICON | SHGFI_ICON);

  m_icoSrc.SendMsg(STM_SETICON, reinterpret_cast<WPARAM>(sfi.hIcon), 0);

  _SetStaticText(m_sSrc, m_tsSrc);

  RtlFillMemory(&sfi, sizeof(sfi), 0x00);

  SHGetFileInfo(m_tsDest.c_str(),
                0,
                &sfi,
                sizeof(sfi),
                SHGFI_ATTRIBUTES | SHGFI_LARGEICON | SHGFI_ICON);

  m_icoDest.SendMsg(STM_SETICON, reinterpret_cast<WPARAM>(sfi.hIcon), 0);

  _SetStaticText(m_sDest, m_tsDest);

}
Example #2
0
void KernelSymbolsLoad() {
	// Load kernel.map
	File* file = GetFileFromPath("/sys/kernel.map");
	
	FileSeek(SEEK_EOF, file);
	int length = FileTell(file);

	FileSeek(0, file);
	
	#ifdef DRIVERS_DEBUG
	kprintf("length=%d,%x\n", length, length);
	#endif

	void* buf = kalloc(length);

	ReadFile(buf, length, file);
	
	Header* hdr = (Header*) buf;
	kernelSyms = buf + hdr->symentries_offset;
	kernelMapStrtab = buf+hdr->strtab_offset;
	
	numKernelSyms = hdr->entries;
	CloseFile(file);
}
Example #3
0
//--------------------------------------------------------------------------------------
void FBXScene::ProcessMaterials(FbxScene* pScene)
{
	for( int i = 0; i < pScene->GetMaterialCount(); ++i )
	{
		Material* pMaterial = new Material(i);

		FbxSurfaceMaterial* pFBXMaterial = pScene->GetMaterial(i);

		FbxProperty diffuseTextureProperty = pFBXMaterial->FindProperty(FbxSurfaceMaterial::sDiffuse);
		if( diffuseTextureProperty.IsValid() )
		{
			FbxFileTexture* pDiffuseTexture = diffuseTextureProperty.GetSrcObject<FbxFileTexture>(0);

			if( pDiffuseTexture )
			{
				std::string strFileName = pDiffuseTexture->GetFileName();

				if( strFileName.length() == 0 )
					strFileName = pDiffuseTexture->GetRelativeFileName();

				strFileName = GetFileFromPath(strFileName);

				pMaterial->SetDiffuseTextureName(strFileName);
			}
		}
		
		FbxProperty normalTextureProperty = pFBXMaterial->FindProperty(FbxSurfaceMaterial::sNormalMap);
		if( normalTextureProperty.IsValid() )
		{
				FbxFileTexture* pNormalTexture = normalTextureProperty.GetSrcObject<FbxFileTexture>(0);

				if( pNormalTexture )
				{
					std::string strFileName = pNormalTexture->GetFileName();

					if( strFileName.length() == 0 )
						strFileName = pNormalTexture->GetRelativeFileName();
					
					strFileName = GetFileFromPath(strFileName);

					pMaterial->SetNormalTextureName(strFileName);
				}
		}

		FbxSurfaceLambert* pLambert = FbxCast<FbxSurfaceLambert>(pFBXMaterial);
		FbxSurfacePhong* pPhong = FbxCast<FbxSurfacePhong>(pFBXMaterial); 

		BTHFBX_VEC3 AmbientColor2;
		BTHFBX_VEC3 EmissiveColor2;
		BTHFBX_VEC3 DiffuseColor2;
		BTHFBX_VEC3 SpecularColor2;

		float fSpecularPower = 1.0f;
		float fTransparency = 1.0f;

		if( pLambert )
		{
			AmbientColor2 = GetMaterialColor2(pLambert->Ambient, pLambert->AmbientFactor);
			EmissiveColor2 = GetMaterialColor2(pLambert->Emissive, pLambert->EmissiveFactor);
			DiffuseColor2 = GetMaterialColor2(pLambert->Diffuse, pLambert->DiffuseFactor);

			FbxPropertyT<FbxDouble> FBXTransparencyProperty = pLambert->TransparencyFactor;

			if( FBXTransparencyProperty.IsValid() )
				fTransparency = (float)FBXTransparencyProperty.Get();
		}

		if( pPhong )
		{
			SpecularColor2 = GetMaterialColor2(pPhong->Specular, pPhong->SpecularFactor);

			FbxPropertyT<FbxDouble> FBXSpecularPowerProperty = pPhong->Shininess;

			if( FBXSpecularPowerProperty.IsValid() )
				fSpecularPower = (float)FBXSpecularPowerProperty.Get();
		}

		pMaterial->SetAmbientColor2(AmbientColor2);
		pMaterial->SetEmissiveColor2(EmissiveColor2);
		pMaterial->SetDiffuseColor2(DiffuseColor2);
		pMaterial->SetSpecularColor2(SpecularColor2);

		pMaterial->SetSpecularPower(fSpecularPower);
		pMaterial->SetTransparency(fTransparency);

		pMaterial->AddTexturePath( GetFilePath(this->mFilename) + "/" );

		m_Materials.push_back(pMaterial);
		m_FBXMaterials.push_back(pFBXMaterial);
	}
}
Example #4
0
unsigned __stdcall _OpFileMoveThread(void *pVoid) {

  OPERATIONSTRUCT os  = *reinterpret_cast<POPERATIONSTRUCT>(pVoid);
  OPCALLBACKDATA ocd;
  TSTRINGLISTIT it    = os.Files.begin();
  UINT uiCurFile      = 1U;
  bool bAskOverwrite  = true;
  BOOL bCancelOp      = FALSE;
  TSTRING tsTemp;

 /*
  * If the destination directory is invalid,
  * it's probably been moved, or renamed
  * since its association with the application.
  * Prompt the user to see if they'd like to 
  * create it, or abort.
  */
  if (FALSE == PathIsDirectory(os.tsDest.c_str())) {

    INT_PTR iChoice = PrintMsgBox(os.hWnd, _T("extFileCopy")
                                  _T(" : Directory not found"),
                                  MB_YESNO | MB_ICONWARNING,
                                  _T("The destination directory:\n\n")
                                  _T("%s\n\nhas either been moved")
                                  _T(" or renamed since its association")
                                  _T(" with extFileCopy. Would you like")
                                  _T(" to create it?"),
                                  os.tsDest.c_str());
            
    switch (iChoice) {

      case IDYES:
      {
       /*
        * Attempt to create the directory.
        */
        if (FALSE == CreateDirectory(os.tsDest.c_str(), NULL)) {

         /*
          * We've failed miserably.
          * Can't copy any files to a non-existant
          * directory; done.
          */
          PrintMsgBox(os.hWnd, _T("extFileCopy : ERROR"),
                      MB_OK | MB_ICONSTOP,
                      _T("An error occurred while attempting")
                      _T(" to create the directory:\n\n%s.\n\n")
                      _T("The directory will be disassociated with")
                      _T("extFileCopy.\n\n")
                      _T("Win32 error: %d"),
                      os.tsDest.c_str(),
                      GetLastError());

          RegUtil_RemAssociatedDirectory(ExtensionFromList(os.Files), os.tsDest);

          goto mtFinish;
        }

      }
      break;

      case IDNO:
      {
       /*
        * User doesn't want to bother creating
        * the directory; We have to remove
        * the association in the registry.
        */
        PrintMsgBox(os.hWnd, _T("extFileCopy : Removing association"),
                    MB_OK | MB_ICONWARNING,
                    _T("The inaccessible directory:\n\n%s\n\nwill now")
                    _T(" be disassociated with extFileCopy."),
                    os.tsDest.c_str());

        RegUtil_RemAssociatedDirectory(ExtensionFromList(os.Files), os.tsDest);

        goto mtFinish;
      }
      break;

    }

  }

  os.pDlg->SetCancelPtr(&bCancelOp);

 /*
  * Set up the dialog UI
  */
  if (os.bCopy) {

    os.pDlg->SetWindowText(_T("Copying ..."));

  } else {

    os.pDlg->SetWindowText(_T("Moving ..."));

  }

  os.pDlg->SetElapsedTime(0);

  for(; it != os.Files.end(); it++) {

   /*
    * Check if the operation was cancelled
    * by the user
    */
    os.pMutex->Lock();

    if (TRUE == bCancelOp) {

      os.pMutex->Unlock();
      goto mtFinish;
    }

    os.pMutex->Unlock();

   /*
    * Update overall progress
    */
    INT64 iOverallPct = ((uiCurFile * 100) / os.Files.size());

    sprintf(tsTemp, _T("Overall Progress (file %d of %d) : %I64d%%"),
            uiCurFile++, os.Files.size(), iOverallPct);

    os.pDlg->SetOverallProgress(iOverallPct, tsTemp);

   /*
    * Update current file name
    */
    TSTRING tsShortFile = GetFileFromPath((*it));
    TSTRING tsDisplay   = tsShortFile;

   /*
    * Truncate file name if necessary
    */
    tsDisplay = FileGetCompactName(tsDisplay, PD_MAXCURFILE);
    
    sprintf(tsTemp, _T("Current file '%s' : %I64d%%"),
            tsDisplay.c_str(), 0LL);

    os.pDlg->SetCurrentProgress(0, tsTemp);

   /*
    * Reset transfer rate
    */
    os.pDlg->SetTransferRate(_T("Transfer Rate: calculating..."));
            
   /* 
    * If the resulting destination path is > MAX_PATH,
    * we've got to skip this file and tell the user.
    */
    TSTRING tsDest = PathConcatFile(os.tsDest, tsShortFile);

    if (MAX_PATH < tsDest.size()) {

      PrintMsgBox(os.hWnd, _T("extFileCopy : Can't copy file"),
                  MB_OK | MB_ICONWARNING,
                  _T("The following destination path:\n\n")
                  _T("%s\n\nis longer than MAX_PATH characters, and")
                  _T(" cannot be created."), tsDest.c_str());

      continue;

    }

   /*
    * Make sure the file doesn't exist; if it does,
    * we've got to prompt the user to overwrite.
    */
    if (-1 != GetFileAttributes(tsDest.c_str())) {

     /*
      * Yeah, the file exists.
      */
      if (bAskOverwrite) {

        OverwriteDlg dlg((*it), tsDest, 1 < os.Files.size());

        if (!dlg.DoModal(static_cast<HINSTANCE>(g_hModule),
                         MAKEINTRESOURCE(IDD_OVERWRITE),
                         os.pDlg->m_hWnd))
        {
          
          MessageBox(os.pDlg->m_hWnd, _T("A fatal internal error has occurred. Cannot continue.\n"),
                     _T("extFileCopy : ERROR"), MB_OK | MB_ICONSTOP);

          os.pDlg->CleanUp();
          _endthreadex(1);

        }

       /*
        * Find out what the user chose
        */
        switch (dlg.Result()) {

          case YES:
           /*
            * Ok to overwrite, but don't touch
            * bAskOverwrite.
            */            
          break;

          case YESTOALL:
           /*
            * Ok to overwrite ALL files.
            */
            bAskOverwrite = false;
          break;

          case NO:
           /*
            * Don't overwrite this file;
            * instead skip to the next.
            */
            continue;
          break;

          case CANCEL:
           /*
            * Forget it. We're outta here.
            */
            os.pMutex->Lock();
            bCancelOp = TRUE;
            os.pMutex->Unlock();
            goto mtFinish;
          break;

        }

      }

    }

   /*
    * File doesn't exist, or we don't
    * really care.  Continue normally
    */
    TSTRING tsCurFile = FileGetCompactName(tsShortFile.c_str(), PD_MAXCURFILE);

    ocd.pbCancel    = &bCancelOp;
    ocd.dwStartTime = (2 == uiCurFile) ? GetTickCount() : ocd.dwStartTime;
    ocd.dwLastTime  = (2 == uiCurFile) ? ocd.dwStartTime : ocd.dwLastTime;
    ocd.dwLastRate  = GetTickCount();
    ocd.iLastPct    = 0LL;
    ocd.iThroughput = 0LL;
    ocd.pDlg        = os.pDlg;
    ocd.pMutex      = os.pMutex;
    ocd.szCurFile   = tsCurFile.c_str();

    if (os.bCopy) {

     /*
      * This is a copy operation
      */
      if (0 == CopyFileEx((*it).c_str(), tsDest.c_str(), _Callback,
                           &ocd, &bCancelOp, 0UL))
      {

       /*
        * The copy operation has failed!
        * Let's tell the user, and then
        * if there's more than one file
        * being copied, ask the user if
        * they'd like to continue with
        * the next file. (If the error
        * didn't result from user abortion)
        */
        if (ERROR_REQUEST_ABORTED != GetLastError()) {

          INT_PTR iUser = ErrorPrompt(os.pDlg->m_hWnd, (*it), tsDest, 
                                    (1 < os.Files.size()) ? true : false, os.bCopy);

          if (1 < os.Files.size()) {

            if (IDYES == iUser) {

            /*
              * User wishes to try the next file.
              */
              continue;

            } else if (IDNO == iUser) {

              break;

            }

          } else {

            continue;

          }

        }

      }

    } else {

     /*
      * This is a move operation
      */
      if (0 == MoveFileWithProgress((*it).c_str(), tsDest.c_str(), _Callback,
                                    &ocd, MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING
                                    | MOVEFILE_WRITE_THROUGH))
      {

       /*
        * The move operation has failed!
        * Let's tell the user, and then
        * if there's more than one file
        * being copied, ask the user if
        * they'd like to continue with
        * the next file. (If the error
        * didn't result from user abortion)
        */
        if (ERROR_REQUEST_ABORTED != GetLastError()) {

          INT_PTR iUser = ErrorPrompt(os.pDlg->m_hWnd, (*it), tsDest,
                                      (1 < os.Files.size()) ? true : false, os.bCopy);

          if (1 < os.Files.size()) {

            if (IDYES == iUser) {

            /*
              * User wishes to try the next file.
              */
              continue;

            } else if (IDNO == iUser) {

              break;

            }

          } else {

            continue;

          }

        }

      }

    }

  }

mtFinish:

  os.pDlg->CleanUp();
  _endthreadex(0U);
  return 0U;
}
Example #5
0
int StackTrace::GetSymbolInfo(Address address, char* symbol, int maxSymbolLen)
{
    if (!InitSymbols())
        return 0;

    // Start with address.
    int charsAdded = 
        _snprintf_s(symbol, maxSymbolLen, _TRUNCATE, "%p ", address);
    symbol += charsAdded;
    maxSymbolLen -= charsAdded;
    if (maxSymbolLen < 0)
        return charsAdded;

    const DWORD64 address64 = (DWORD64)address;
    // Module name
    IMAGEHLP_MODULE64 moduleInfo;
    ZeroMemory(&moduleInfo, sizeof(moduleInfo));
    moduleInfo.SizeOfStruct = sizeof(moduleInfo);
    const HANDLE hCurrentProcess = GetCurrentProcess();
    if (SymGetModuleInfo64(hCurrentProcess, address64, &moduleInfo))
    {
        char moduleName[_MAX_PATH + 1];
        GetFileFromPath(moduleInfo.ImageName, moduleName, _MAX_PATH);
        const int moduleLen = (int)strlen(moduleName);
        strncpy_s(symbol, maxSymbolLen, moduleName, _TRUNCATE);
        symbol += moduleLen;
        charsAdded += moduleLen;
        maxSymbolLen -= moduleLen;
    }
    if (maxSymbolLen <= 0)
        return charsAdded;

    // Symbol name
    ULONG64 symbolBuffer[(sizeof(SYMBOL_INFO) + MAX_SYM_NAME*sizeof(TCHAR) +
            sizeof(ULONG64) - 1) / sizeof(ULONG64)] = { 0 };
    IMAGEHLP_SYMBOL64* symbolInfo = reinterpret_cast<IMAGEHLP_SYMBOL64*>(symbolBuffer);
    symbolInfo->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64);
    symbolInfo->MaxNameLength = MAX_SYM_NAME;
    DWORD64 disp(0);
    if (SymGetSymFromAddr64(hCurrentProcess, address64, &disp, symbolInfo))
    {
        const int symbolChars =
            _snprintf_s(symbol, maxSymbolLen, _TRUNCATE, " %s + 0x%X", symbolInfo->Name, disp);
        symbol += symbolChars;
        maxSymbolLen -= symbolChars;
        charsAdded += symbolChars;
    }
    if (maxSymbolLen <= 0)
        return charsAdded;

    // File + line
    DWORD displacementLine;
    IMAGEHLP_LINE64 lineInfo;
    ZeroMemory(&lineInfo, sizeof(lineInfo));
    lineInfo.SizeOfStruct = sizeof(lineInfo);
    if (SymGetLineFromAddr64(hCurrentProcess, address64, &displacementLine, &lineInfo))
    {
        char fileName[_MAX_PATH + 1];
        GetFileFromPath(lineInfo.FileName, fileName, _MAX_PATH);
        int fileLineChars(0);
        if (displacementLine > 0)
        {
            fileLineChars = _snprintf_s(symbol, maxSymbolLen, _TRUNCATE, 
                " %s(%d+%04d byte(s))", fileName, lineInfo.LineNumber, displacementLine);
        }
        else
        {
            fileLineChars = _snprintf_s(symbol, maxSymbolLen, _TRUNCATE,
                " %s(%d)", fileName, lineInfo.LineNumber);
        }
        symbol += fileLineChars;
        maxSymbolLen -= fileLineChars;
        charsAdded += fileLineChars;
    }
    return charsAdded;
}
int WINAPI FindDupes2(const char* szList, HWND hParent)
{
	AFX_MANAGE_STATE(AfxGetAppModuleState());
	sListOfImages.RemoveAll();
	sListOfImagesToDelete.RemoveAll();
	sListOfImageDibs.RemoveAll();
	CString sFiles=szList;
	sFiles.Replace("\r","");
	sFiles+="\n";
	while(sFiles.GetLength()>0){
		CString sWPTitle=sFiles.SpanExcluding("\n");
		if(strlen(sWPTitle)!=strlen(sFiles)){
			sFiles=sFiles.Mid(strlen(sWPTitle)+1);
		}else{
			sFiles="";
		}
		if(sWPTitle!="" && FindMini(sFiles,sWPTitle+"\n")==-1){
			sListOfImages.Add(sWPTitle);
		}
	}
	CheckImages(0);
	{
		CSplashParams sp;
		sp.szText="Reading...";
		sp.bgColor=0;
		sp.txColor=RGB(255,255,255);
		sp.dwTextParams|=TXSHADOW_VCENT|TXSHADOW_FILLBG|TXSHADOW_WIDE|TXSHADOW_GLOW|TXSHADOW_MIXBG;////TXSHADOW_SHCOL
		sp.dwSplashAlign=SPLASH_OPACITY;
		sp.dwSplashAlign|=SPLASH_HLEFT;
		sp.dwSplashAlign|=SPLASH_VTOP;
		CSplashWindow sw(&sp);
		{//!!!
			for(int i=0;i<sListOfImageDibs.GetSize()-1;i++){
				int iClosest=i+1;
				if(sListOfImageDibs[i] && sListOfImageDibs[iClosest]){
					double daffmin=sListOfImageDibs[i]->CalcDistance(sListOfImageDibs[iClosest]);
					for(int j=i+2;j<sListOfImageDibs.GetSize();j++){
						if(sListOfImageDibs[j]){
							double lAffinity=sListOfImageDibs[i]->CalcDistance(sListOfImageDibs[j]);
							if(daffmin>lAffinity){
								daffmin=lAffinity;
								iClosest=j;
							}
						}
					}
				}
				// iClosest<>i+1
				CString sTmp=sListOfImages[iClosest];
				sListOfImages[iClosest]=sListOfImages[i+1];
				sListOfImages[i+1]=sTmp;
				CDib* sTmp2=sListOfImageDibs[iClosest];
				sListOfImageDibs[iClosest]=sListOfImageDibs[i+1];
				sListOfImageDibs[i+1]=sTmp2;
				sw.SetText(Format("Checking %i",i));
			}
		}
		sw.SetText("Renaming...");
		for(int i=0;i<sListOfImageDibs.GetSize();i++){
			MoveFile(sListOfImages[i],GetDirectoryFromPath(sListOfImages[i])+Format("%04i_%s",i,GetFileFromPath(sListOfImages[i])));
			if(sListOfImageDibs[i]){
				delete sListOfImageDibs[i];
			}
		}
	}
	return 0;
}
Example #7
0
File: main.c Project: kfreezen/kos
int kmain(UInt32 initial_stack, MultibootHeader* mboot, UInt32 mboot_magic) {
	initial_esp = initial_stack;
	
	CLI_Init();
	Cls();
	
	UInt32 initrd_end = *(UInt32*)(mboot->mods_addr+4);
	
	placement_address = (Pointer) initrd_end;
	
	// Set up our new stack here.
	//UInt32 stack = (UInt32) kmalloc_a(8192, TRUE);
	MultibootHeader* mboot_hdr = mboot; //kmalloc(sizeof(MultibootHeader));
	//memcpy(mboot_hdr, mboot, sizeof(MultibootHeader));
	
	kprintf("Starting init...\n");

	//new_start(stack, mboot_hdr);
	GDT_Init();
	IDT_Init();
	ISR_Init();
	asm volatile("sti");
	
	kprintf("Basics\t\t\t[OK]\n");

	PIT_Init(PIT_MSTIME);

	kprintf("PIT\t\t\t[OK]\n");

	init_kheap();
	InitPaging((mboot_hdr->mem_lower+mboot_hdr->mem_upper)&~3);
	InitKernelHeap();

	kprintf("Heap\t\t\t[OK]\n");

	VFS_Init();
	DevFS_Init();
	
	kprintf("VFS\t\t\t[OK]\n");

	DriversInit();

	kprintf("Drivers\t\t\t[OK]\n");

	Screen_Init();

	FloppyInit();

	checkAllBuses();
	DumpPCIDeviceData();
	kprintf("PCI\t\t\t[OK]\n");

	/*kprintf("Keyboard Init... ");
	KB_Init(0);
	kprintf("[ok]\n");*/

	FAT12_Init(FAT12_GetContext(FloppyGetDevice()), "/", "sys");
	
	InitTasking();

	KernelSymbolsLoad();

	//Cls();

	kprintf("kOS v0.6.13\n");

	VFS_Node* rd = GetNodeFromFile(GetFileFromPath("/sys"));
	kprintf("rd = %x\n", rd);
	
	ArrayList* list = ListFiles(rd);
	ALIterator* itr = ALGetItr(list);

	while(ALItrHasNext(itr)) {
		VFS_Node* node = ALItrNext(itr);
		kprintf("file: %s\n", node->name);
	}

	ALFreeItr(itr);
	
	ALFreeList(list);

	//kprintf("kprintf symbol = %x\n", getKernelSymbol("kprintf"));
	File* initScript = GetFileFromPath("/sys/init.script");
	FileSeek(0, initScript); // Due to these being global objects, we have to do such ugly things as this.

	#ifdef INIT_DEBUG
	kprintf("initScript=%x\n", initScript);
	#endif

	char* lineBuf = kalloc(256);
	int doBreak = 0;
	while(!doBreak) {
		if(fgetline(initScript, lineBuf, 256, '\n')==-1) {
			if(strlen(lineBuf) > 0) {
				doBreak = 1;
			} else {
				break; // We've processed everything that needs to be processed.
			}
		}

		// Now parse it.
		char* tok = strtok(lineBuf, " ");
		kprintf("%s, %x\n", tok,tok);
		if(!strcmp(tok, "load_driver")) {
			#ifdef INIT_DEBUG
			kprintf("load_driver ");
			#endif

			tok = strtok(NULL, " ");

			// Load the driver specified.
			File* drv = GetFileFromPath(tok);
			if(drv != NULL) {
				int drvLength = FileSeek(SEEK_EOF, drv);
				FileSeek(0, drv);
				void* drvBuf = kalloc(drvLength);

				#ifdef INIT_DEBUG
				kprintf("%s\n", GetNodeFromFile(drv)->name);
				#endif

				ReadFile(drvBuf, drvLength, drv);
				ELF* elf = LoadKernelDriver(drvBuf);

				#ifdef INIT_DEBUG
				kprintf("elf->start=%x\n", elf->start);
				#endif

				if(elf->error == 0) {
					void (*driverInit)() = (void (*)()) elf->start;
					driverInit();
				}

				kfree(drvBuf);
				drvBuf = NULL;

				CloseFile(drv);
			}
		}
	}

	CloseFile(initScript);
	kfree(lineBuf);

	kprintf("Kernel init done...\n");

	File* elf = GetFileFromPath("/sys/helloworld");
	
	FileSeek(SEEK_EOF, elf);
	int length = FileTell(elf);
	FileSeek(0, elf);
	UInt8* elfBuf = kalloc(length);
	ReadFile(elfBuf, length, elf);
	ELF* elfExe = Parse_ELF(elfBuf);
	CreateTaskFromELF(elfExe);

	// Kernel main logic loop
	while(1) {
		asm volatile("hlt");
	}

	return 0;
}