Exemple #1
0
 void Add(std::size_t offset, std::size_t size) const
 {
   Dbg(" Affected range %1%..%2%", offset, offset + size);
   Require(TotalRanges->AddRange(offset, size));
 }
Exemple #2
0
int au_dcsub_pages(struct au_dcsub_pages *dpages, struct dentry *root,
		   au_dpages_test test, void *arg)
{
	int err;
	struct dentry *this_parent = root;
	struct list_head *next;
	struct super_block *sb = root->d_sb;

	TraceEnter();

	err = 0;
	spin_lock(&dcache_lock);
 repeat:
	next = this_parent->d_subdirs.next;
 resume:
	if (this_parent->d_sb == sb
	    && !IS_ROOT(this_parent)
	    && atomic_read(&this_parent->d_count)
	    && this_parent->d_inode
	    && (!test || test(this_parent, arg))) {
		err = au_dpages_append(dpages, this_parent, GFP_ATOMIC);
		if (unlikely(err))
			goto out;
	}

	while (next != &this_parent->d_subdirs) {
		struct list_head *tmp = next;
		struct dentry *dentry = list_entry(tmp, struct dentry, D_CHILD);
		next = tmp->next;
		if (unlikely(/*d_unhashed(dentry) || */!dentry->d_inode))
			continue;
		if (!list_empty(&dentry->d_subdirs)) {
			this_parent = dentry;
			goto repeat;
		}
		if (dentry->d_sb == sb
		    && atomic_read(&dentry->d_count)
		    && (!test || test(dentry, arg))) {
			err = au_dpages_append(dpages, dentry, GFP_ATOMIC);
			if (unlikely(err))
				goto out;
		}
	}

	if (this_parent != root) {
		next = this_parent->D_CHILD.next;
		this_parent = this_parent->d_parent;
		goto resume;
	}
 out:
	spin_unlock(&dcache_lock);
#if 0
	if (!err) {
		int i, j;
		j = 0;
		for (i = 0; i < dpages->ndpage; i++) {
			if ((dpages->dpages + i)->ndentry)
				Dbg("%d: %d\n",
				    i, (dpages->dpages + i)->ndentry);
			j += (dpages->dpages + i)->ndentry;
		}
		if (j)
			Dbg("ndpage %d, %d\n", dpages->ndpage, j);
	}
#endif
	TraceErr(err);
	return err;
}
Exemple #3
0
NTSTATUS Hooked_NtQueryAttributesFile(__in POBJECT_ATTRIBUTES ObjectAttributes,
									  __out PFILE_BASIC_INFORMATION FileInformation)
{
	NTSTATUS statusCall, exceptionCode;
	ULONG currentProcessId;
	UNICODE_STRING kObjectName;
	PWCHAR parameter = NULL; 
	
	PAGED_CODE();
	
	currentProcessId = (ULONG)PsGetCurrentProcessId();
	statusCall = Orig_NtQueryAttributesFile(ObjectAttributes, FileInformation);
	
	if(IsProcessInList(currentProcessId, pMonitoredProcessListHead) && (ExGetPreviousMode() != KernelMode))
	{
		Dbg("Call NtQueryAttributesFile\n");

		parameter = PoolAlloc(MAX_SIZE * sizeof(WCHAR));
		kObjectName.Buffer = NULL;
		
		if(NT_SUCCESS(statusCall))
		{
			__try
			{
				if(ObjectAttributes != NULL)
				{
					ProbeForRead(ObjectAttributes, sizeof(OBJECT_ATTRIBUTES), 1);
					ProbeForRead(ObjectAttributes->ObjectName, sizeof(UNICODE_STRING), 1);
					ProbeForRead(ObjectAttributes->ObjectName->Buffer, ObjectAttributes->ObjectName->Length, 1);
					kObjectName.Length = ObjectAttributes->ObjectName->Length;
					kObjectName.MaximumLength = ObjectAttributes->ObjectName->MaximumLength;
					kObjectName.Buffer = PoolAlloc(kObjectName.MaximumLength);
					RtlCopyUnicodeString(&kObjectName, ObjectAttributes->ObjectName);
				}
				else
					RtlInitUnicodeString(&kObjectName, L"");
			}
			__except(EXCEPTION_EXECUTE_HANDLER)
			{
				exceptionCode = GetExceptionCode();
				if(parameter && NT_SUCCESS(RtlStringCchPrintfW(parameter, MAX_SIZE, L"0,%d,sss,FileHandle->0,buffer->ERROR,offset->0", exceptionCode)))
					SendLogs(currentProcessId, SIG_ntdll_NtQueryAttributesFile, parameter);
				else
					SendLogs(currentProcessId, SIG_ntdll_NtQueryAttributesFile, L"0,-1,sss,FileHandle->0,buffer->ERROR,offset->0");
				if(parameter != NULL)
					PoolFree(parameter);
				return statusCall;
			}			
		
			if(wcsistr(kObjectName.Buffer, L"\\??\\C:\\Windows\\system32\\drivers\\VBoxMouse.sys") || 
				wcsistr(kObjectName.Buffer, L"\\??\\C:\\Windows\\system32\\drivers\\VBoxGuest.sys") ||
				wcsistr(kObjectName.Buffer, L"\\??\\C:\\Windows\\system32\\drivers\\VBoxSF.sys") ||
				wcsistr(kObjectName.Buffer, L"\\??\\C:\\Windows\\system32\\drivers\\VBoxVideo.sys") ||
				wcsistr(kObjectName.Buffer, L"\\??\\C:\\Windows\\system32\\VBoxControl.exe") ||
				wcsistr(kObjectName.Buffer, L"\\??\\C:\\Windows\\system32\\VBoxDisp.dll") ||
				wcsistr(kObjectName.Buffer, L"\\??\\C:\\Windows\\system32\\VBoxHook.dll") ||
				wcsistr(kObjectName.Buffer, L"\\??\\C:\\Windows\\system32\\VBoxMRXNP.dll") ||
				wcsistr(kObjectName.Buffer, L"\\??\\C:\\Windows\\system32\\VBoxOGL.dll") ||
				wcsistr(kObjectName.Buffer, L"\\??\\C:\\Windows\\system32\\VBoxOGLarrayspu.dll") ||
				wcsistr(kObjectName.Buffer, L"\\??\\C:\\Windows\\system32\\VBoxOGLcrutil.dll") ||
				wcsistr(kObjectName.Buffer, L"\\??\\C:\\Windows\\system32\\VBoxOGLerrorspu.dll") ||
				wcsistr(kObjectName.Buffer, L"\\??\\C:\\Windows\\system32\\VBoxOGLfeedbackspu.dll") ||
				wcsistr(kObjectName.Buffer, L"\\??\\C:\\Windows\\system32\\VBoxOGLpackspu.dll") ||
				wcsistr(kObjectName.Buffer, L"\\??\\C:\\Windows\\system32\\VBoxOGLpassthroughspu.dll") ||
				wcsistr(kObjectName.Buffer, L"\\??\\C:\\Windows\\system32\\VBoxService.exe") ||
				wcsistr(kObjectName.Buffer, L"\\??\\C:\\Windows\\system32\\VBoxTray.exe") ||
				wcsistr(kObjectName.Buffer, L"\\??\\C:\\Windows\\system32\\drivers\\vmmouse.sys") ||
				wcsistr(kObjectName.Buffer, L"\\??\\C:\\Windows\\system32\\drivers\\vmhgfs.sys") ||
				wcsistr(kObjectName.Buffer, L"\\??\\C:\\Program Files\\oracle\\virtualbox guest additions\\"))
			{
				if(parameter && NT_SUCCESS(RtlStringCchPrintfW(parameter, MAX_SIZE, L"0,-1,s,filepath->%wZ", &kObjectName)))
					SendLogs(currentProcessId, SIG_ntdll_NtQueryAttributesFile, parameter);
				else
					SendLogs(currentProcessId, SIG_ntdll_NtQueryAttributesFile, L"0,-1,s,filepath->ERROR");
				if(parameter != NULL)
					PoolFree(parameter);
				return INVALID_FILE_ATTRIBUTES;
			}
		}
		if(parameter != NULL)
			PoolFree(parameter);
	}
Exemple #4
0
INT_PTR
CALLBACK
DlgReplace(
           HWND hDlg,
           UINT message,
           WPARAM wParam,
           LPARAM lParam
           )
{
    Unused( lParam );

    switch (message) {

    case WM_INITDIALOG: {

            BOOL lookAround = TRUE;
            int i;
            LPSTR s;

            frMem.replaceAll = FALSE;
            frMem.oneLineDone = FALSE;
            frMem.replacing = TRUE;
            SetStopLimit();

            //Retrieve text from document, blank string if nothing found
            //and send string to dialog box
            if (GetCurrentText(curView, &lookAround,
                               (LPSTR)findReplace.findWhat,
                               MAX_USER_LINE, &frMem.leftCol, NULL)) {

                //Temporarly put the string in the picklist
                extraPick = InsertInPickList(FIND_PICK);

            } else
                extraPick = FALSE;

            frMem.rightCol = frMem.leftCol;
            SendDlgItemMessage(hDlg, ID_REPLACE_WHAT,
                               CB_LIMITTEXT, MAX_USER_LINE, (LPARAM) NULL);
            SendDlgItemMessage(hDlg, ID_REPLACE_WHAT, WM_SETTEXT, 0,
                               (LPARAM)((LPSTR)findReplace.findWhat));

            //Put back last replaced value
            SendDlgItemMessage(hDlg, ID_REPLACE_REPLACEWITH,
                               CB_LIMITTEXT, MAX_USER_LINE, (LPARAM) NULL);
            SendDlgItemMessage(hDlg, ID_REPLACE_REPLACEWITH, WM_SETTEXT, 0,
                               (LPARAM)((LPSTR)findReplace.replaceWith));

            //Transfer boolean values to Dialog Box
            SendDlgItemMessage(hDlg, ID_REPLACE_MATCHUPLO, BM_SETCHECK,
                               findReplace.matchCase, 0L);
            SendDlgItemMessage(hDlg, ID_REPLACE_WHOLEWORD, BM_SETCHECK,
                               !findReplace.regExpr & findReplace.wholeWord, 0L);
            SendDlgItemMessage(hDlg, ID_REPLACE_REGEXP, BM_SETCHECK,
                               findReplace.regExpr, 0L);
            EnableWindow(GetDlgItem(hDlg, ID_REPLACE_WHOLEWORD),
                         !findReplace.regExpr);

            frMem.goUpCopy = findReplace.goUp;
            findReplace.goUp = FALSE;

            //Set the line to start find
            frMem.line = Views[curView].Y;

            //Set number of replaced occurences to 0
            frMem.nbReplaced = 0;

            //Fill find pick list
            for (i = 0 ; i < findReplace.nbInPick[FIND_PICK]; i++) {
                Dbg(s = (LPSTR)GlobalLock(findReplace.hPickList[FIND_PICK][i]));
                SendDlgItemMessage(hDlg, ID_REPLACE_WHAT, CB_INSERTSTRING, (WPARAM) -1,
                                   (LPARAM)(LPSTR)s);
                Dbg(GlobalUnlock (findReplace.hPickList[FIND_PICK][i]) == FALSE);
            }

            //Fill replace pick list
            for (i = 0 ; i < findReplace.nbInPick[REPLACE_PICK]; i++) {
                Dbg(s = (LPSTR)GlobalLock(findReplace.hPickList[REPLACE_PICK][i]));
                SendDlgItemMessage(hDlg, ID_REPLACE_REPLACEWITH, CB_INSERTSTRING, (WPARAM) -1,
                                   (LPARAM)(LPSTR)s);
                Dbg(GlobalUnlock (findReplace.hPickList[REPLACE_PICK][i]) == FALSE);
            }

            return TRUE;
        }

    case WM_COMMAND: {

            switch (wParam) {

            case ID_REPLACE_FINDNEXT:
            case ID_REPLACE_REPLACEALL:

                if (SendDlgItemMessage(hDlg, ID_REPLACE_WHAT, WM_GETTEXT,
                                       MAX_USER_LINE,
                                       (LPARAM)((LPSTR)findReplace.findWhat))) {


                    SendDlgItemMessage(hDlg, ID_REPLACE_REPLACEWITH,
                                       WM_GETTEXT, MAX_USER_LINE,
                                       (LPARAM)((LPSTR)findReplace.replaceWith));

                    if (extraPick)
                        RemoveFromPick(FIND_PICK);

                    frMem.replaceAll = (wParam == ID_REPLACE_REPLACEALL);
                    InsertInPickList(FIND_PICK);
                    InsertInPickList(REPLACE_PICK);
                    if (FindNext(hDlg, Views[curView].Y, Views[curView].X,
                                 TRUE, TRUE, TRUE)) {
                        if (frMem.hadError)
                            findReplace.goUp = frMem.goUpCopy;
                        frMem.replacing = !frMem.hadError;
                        frMem.firstConfirmInvoc = TRUE;
                        EndDialog(hDlg, !frMem.hadError);
                    } else {
                        SetStopLimit();
                        SetFocus(GetDlgItem(hDlg, ID_REPLACE_WHAT));
                    }

                }
                return TRUE;

            case ID_REPLACE_WHOLEWORD:
                findReplace.wholeWord = !findReplace.wholeWord;
                return TRUE;

            case ID_REPLACE_MATCHUPLO:
                findReplace.matchCase = !findReplace.matchCase;
                return TRUE;

            case ID_REPLACE_REGEXP:
                findReplace.regExpr = !findReplace.regExpr;
                SendDlgItemMessage(hDlg, ID_REPLACE_WHOLEWORD, BM_SETCHECK,
                                   !findReplace.regExpr & findReplace.wholeWord, 0L);
                EnableWindow(GetDlgItem(hDlg, ID_REPLACE_WHOLEWORD),
                             !findReplace.regExpr);
                return TRUE;

            case IDCANCEL :

                //Remove the extra pick we inserted
                if (extraPick)
                    RemoveFromPick(FIND_PICK);

                findReplace.goUp = frMem.goUpCopy;
                frMem.replacing = FALSE;
                EndDialog(hDlg, FALSE);
                return TRUE;

            case IDWINDBGHELP :
                Dbg(WinHelp(hDlg,szHelpFileName,HELP_CONTEXT,ID_REPLACE_HELP));
                return TRUE;
            }
            break;
        }
    }

    return FALSE;
}
Exemple #5
0
BOOL
DlgKernelDbg(
    HWND    hDlg,
    UINT    message,
    WPARAM  wParam,
    LONG    lParam
    )
{
    char        rgch[256];
    BOOL        b;
    BOOL        fChange = FALSE;
    int         i;
    HWND        hCtl;
    DWORD       tmp;

    switch (message) {
        case WM_INITDIALOG:
            KdParams = (LPKDPARAMS) lParam;

            if (KdParams->fEnable) {
                CheckDlgButton( hDlg, ID_KD_ENABLE, 1);
            }

            if (KdParams->fGoExit) {
                CheckDlgButton( hDlg, ID_KD_GOEXIT, 1);
            }

            if (KdParams->fVerbose) {
                CheckDlgButton( hDlg, ID_KD_VERBOSE, 1);
            }

            if (KdParams->fInitialBp) {
                CheckDlgButton( hDlg, ID_KD_INITIALBP, 1);
            }

            if (KdParams->fDefer) {
                CheckDlgButton( hDlg, ID_KD_DEFER, 1);
            }

            if (KdParams->fUseModem) {
                CheckDlgButton( hDlg, ID_KD_MODEM, 1);
            }

            hCtl = GetDlgItem(hDlg,ID_KD_PORT);
            sprintf( rgch, "COM%d", KdParams->dwPort );
            for (i=0; i<KdMaxComPorts; i++) {
                SendMessage(hCtl, CB_ADDSTRING, 0, (LPARAM)KdComPorts[i]);
                if (strcmp( rgch, KdComPorts[i] ) == 0) {
                    SendMessage(hCtl, CB_SETCURSEL, i, 0);
                }
            }

            hCtl = GetDlgItem(hDlg,ID_KD_BAUDRATE);
            for (i=0; i<KdMaxBaudRates; i++) {
                sprintf( rgch, "%d", KdBaudRates[i] );
                SendMessage(hCtl, CB_ADDSTRING, 0, (LPARAM)rgch);
                if (KdParams->dwBaudRate ==  KdBaudRates[i] ) {
                    SendMessage(hCtl, CB_SETCURSEL, i, 0);
                }
            }

            hCtl = GetDlgItem(hDlg,ID_KD_CACHE);
            for (i=0; i<KdMaxCacheSizes; i++) {
                sprintf( rgch, "%d", KdCacheSizes[i] );
                SendMessage(hCtl, CB_ADDSTRING, 0, (LPARAM)rgch);
                if (KdParams->dwCache ==  KdCacheSizes[i] ) {
                    SendMessage(hCtl, CB_SETCURSEL, i, 0);
                }
            }

            hCtl = GetDlgItem(hDlg,ID_KD_PLATFORM);
            for (i=0; i<KdMaxPlatforms; i++) {
                SendMessage(hCtl, CB_ADDSTRING, 0, (LPARAM)KdPlatforms[i]);
                if (KdParams->dwPlatform == (DWORD)i) {
                    SendMessage(hCtl, CB_SETCURSEL, i, 0);
                }
            }

            return TRUE;

        case WM_COMMAND:
            switch (wParam) {
                case IDOK :

                    /*
                     * Transfer the options to global
                     *
                     * Now start looking at the rest and determine what needs to
                     * be updated
                     */

                    b = (IsDlgButtonChecked(hDlg,ID_KD_ENABLE) != 0);
                    if (b != KdParams->fEnable) {
                        KdParams->fEnable = b;
                        fChange = TRUE;
                    }

                    b = (IsDlgButtonChecked(hDlg,ID_KD_GOEXIT) != 0);
                    if (b != KdParams->fGoExit) {
                        KdParams->fGoExit = b;
                        fChange = TRUE;
                    }

                    b = (IsDlgButtonChecked(hDlg,ID_KD_VERBOSE) != 0);
                    if (b != KdParams->fVerbose) {
                        KdParams->fVerbose = b;
                        fChange = TRUE;
                    }

                    b = (IsDlgButtonChecked(hDlg,ID_KD_INITIALBP) != 0);
                    if (b != KdParams->fInitialBp) {
                        KdParams->fInitialBp = b;
                        fChange = TRUE;
                    }

                    b = (IsDlgButtonChecked(hDlg,ID_KD_DEFER) != 0);
                    if (b != KdParams->fDefer) {
                        KdParams->fDefer = b;
                        fChange = TRUE;
                    }

                    b = (IsDlgButtonChecked(hDlg,ID_KD_MODEM) != 0);
                    if (b != KdParams->fUseModem) {
                        KdParams->fUseModem = b;
                        fChange = TRUE;
                    }

                    if (GetDlgItemText( hDlg, ID_KD_PORT, rgch, sizeof(rgch) )) {
                        for (i=0; i<KdMaxComPorts; i++) {
                            if (strcmp(KdComPorts[i],rgch)==0) {
                                KdParams->dwPort = i+1;
                                fChange = TRUE;
                                break;
                            }
                        }
                    }

                    if (GetDlgItemText( hDlg, ID_KD_BAUDRATE, rgch, sizeof(rgch) )) {
                        tmp = atol( rgch );
                        for (i=0; i<KdMaxBaudRates; i++) {
                            if (KdBaudRates[i] == tmp) {
                                KdParams->dwBaudRate = tmp;
                                fChange = TRUE;
                                break;
                            }
                        }
                    }

                    if (GetDlgItemText( hDlg, ID_KD_CACHE, rgch, sizeof(rgch) )) {
                        tmp = atol( rgch );
                        for (i=0; i<KdMaxCacheSizes; i++) {
                            if (KdCacheSizes[i] == tmp) {
                                KdParams->dwCache = tmp;
                                fChange = TRUE;
                                break;
                            }
                        }
                    }

                    if (GetDlgItemText( hDlg, ID_KD_PLATFORM, rgch, sizeof(rgch) )) {
                        for (i=0; i<KdMaxPlatforms; i++) {
                            if (strcmp(KdPlatforms[i],rgch)==0) {
                                KdParams->dwPlatform = i;
                                fChange = TRUE;
                                break;
                            }
                        }
                    }

                    EndDialog(hDlg, TRUE);
                    return (TRUE);

                case IDCANCEL:
                    EndDialog(hDlg, TRUE);
                    return (TRUE);

#if 0
                case IDHELP:                /* User Help */
                    Dbg(WinHelp(hDlg, szHelpFileName, (DWORD) HELP_CONTEXT,(DWORD)ID_DBUGOPT_HELP));
                    return (TRUE);
#endif

                default:
                    break;
            }
            break;
    }
    return FALSE;
}
Exemple #6
0
    void SetupContext(lame_global_flags& ctx) const
    {
      const StreamParameters stream(Params);
      const RenderParameters::Ptr sound = RenderParameters::Create(Params);

      const uint_t samplerate = sound->SoundFreq();
      Dbg("Setting samplerate to %1%Hz", samplerate);
      CheckLameCall(LameApi->lame_set_in_samplerate(&ctx, samplerate), THIS_LINE);
      CheckLameCall(LameApi->lame_set_out_samplerate(&ctx, samplerate), THIS_LINE);
      CheckLameCall(LameApi->lame_set_num_channels(&ctx, Sample::CHANNELS), THIS_LINE);
      CheckLameCall(LameApi->lame_set_bWriteVbrTag(&ctx, true), THIS_LINE);
      switch (stream.GetBitrateMode())
      {
      case MODE_CBR:
        {
          const uint_t bitrate = stream.GetBitrate();
          Dbg("Setting bitrate to %1%kbps", bitrate);
          CheckLameCall(LameApi->lame_set_VBR(&ctx, vbr_off), THIS_LINE);
          CheckLameCall(LameApi->lame_set_brate(&ctx, bitrate), THIS_LINE);
        }
        break;
      case MODE_ABR:
        {
          const uint_t bitrate = stream.GetBitrate();
          Dbg("Setting average bitrate to %1%kbps", bitrate);
          CheckLameCall(LameApi->lame_set_VBR(&ctx, vbr_abr), THIS_LINE);
          CheckLameCall(LameApi->lame_set_VBR_mean_bitrate_kbps(&ctx, bitrate), THIS_LINE);
        }
        break;
      case MODE_VBR:
        {
          const uint_t quality = stream.GetQuality();
          Dbg("Setting VBR quality to %1%", quality);
          CheckLameCall(LameApi->lame_set_VBR(&ctx, vbr_default), THIS_LINE);
          CheckLameCall(LameApi->lame_set_VBR_q(&ctx, quality), THIS_LINE);
        }
        break;
      default:
        assert(!"Invalid mode");
      }
      switch (stream.GetChannelsMode())
      {
      case MODE_DEFAULT:
        Dbg("Using default channels mode");
        break;
      case MODE_STEREO:
        Dbg("Using stereo mode");
        CheckLameCall(LameApi->lame_set_mode(&ctx, STEREO), THIS_LINE);
        break;
      case MODE_JOINTSTEREO:
        Dbg("Using joint stereo mode");
        CheckLameCall(LameApi->lame_set_mode(&ctx, JOINT_STEREO), THIS_LINE);
        break;
      case MODE_MONO:
        Dbg("Using mono mode");
        CheckLameCall(LameApi->lame_set_mode(&ctx, MONO), THIS_LINE);
        break;
      default:
        assert(!"Invalid mode");
      }
      CheckLameCall(LameApi->lame_init_params(&ctx), THIS_LINE);
      LameApi->id3tag_init(&ctx);
    }
Exemple #7
0
 void ResizeBuffer()
 {
   Encoded.resize(Encoded.size() * 2);
   Dbg("Increase buffer to %1% bytes", Encoded.size());
 }