コード例 #1
0
ファイル: obsolete.c プロジェクト: mingpen/OpenNT
LOCAL uchar *AllocNewStr (TENTRY *OldEntry, ushort length)
{
	uchar	   *pNew;

	if ((length + LNGTHSZ) > POOL2SIZE) {
		pNew = Alloc (length + LNGTHSZ);
	}
	else if ((length + LNGTHSZ) > POOLSIZE) {
		pNew = Pool2Alloc ();
	}
	else {
		pNew = PoolAlloc ();
	}
	FreeAllocStrings (OldEntry);
	if ((length + LNGTHSZ) > POOL2SIZE) {
		OldEntry->flags.IsMalloced = TRUE;
	}
	else if ((length + LNGTHSZ) > POOLSIZE) {
		OldEntry->flags.IsPool2 = TRUE;
	}
	else {
		OldEntry->flags.IsPool = TRUE;
	}
	OldEntry->TypeString = pNew;
	return (pNew);
}
コード例 #2
0
ファイル: display.c プロジェクト: mstorsjo/vlc
static picture_pool_t *Pool(vout_display_t *vd, unsigned requested_count)
{
    vout_display_sys_t *sys = vd->sys;

    if (sys->pool == NULL)
        sys->pool = PoolAlloc(vd, requested_count);
    return sys->pool;
}
コード例 #3
0
ファイル: data.c プロジェクト: RayPlante/usvirtualobservatory
const char *
PoolStrdup(TPool *      const poolP,
           const char * const origString) {

    char * newString;

    if (origString == NULL)
        newString = NULL;
    else {
        newString = PoolAlloc(poolP, strlen(origString) + 1);
        if (newString != NULL)
            strcpy(newString, origString);
    }
    return newString;
}
コード例 #4
0
static void
generateListing(TList *       const listP,
                char *        const z,
                const char *  const uri,
                TPool *       const poolP,
                const char ** const errorP,
                uint16_t *    const responseStatusP) {
    
    TFileInfo fileinfo;
    TFileFind findhandle;

    *errorP = NULL;

    if (!FileFindFirst(&findhandle, z, &fileinfo)) {
        *responseStatusP = ResponseStatusFromErrno(errno);
        xmlrpc_asprintf(errorP, "Can't read first entry in directory");
    } else {
        ListInit(listP);

        do {
            TFileInfo * fi;
            /* Files whose names start with a dot are ignored */
            /* This includes implicitly the ./ and ../ */
            if (*fileinfo.name == '.') {
                if (xmlrpc_streq(fileinfo.name, "..")) {
                    if (xmlrpc_streq(uri, "/"))
                        continue;
                } else
                    continue;
            }
            fi = (TFileInfo *)PoolAlloc(poolP, sizeof(fileinfo));
            if (fi) {
                abyss_bool success;
                memcpy(fi, &fileinfo, sizeof(fileinfo));
                success =  ListAdd(listP, fi);
                if (!success)
                    xmlrpc_asprintf(errorP, "ListAdd() failed");
            } else
                xmlrpc_asprintf(errorP, "PoolAlloc() failed.");
        } while (!*errorP && FileFindNext(&findhandle, &fileinfo));

        if (*errorP) {
            *responseStatusP = 500;
            ListFree(listP);
        }            
        FileFindClose(&findhandle);
    }
}
コード例 #5
0
ファイル: sac.c プロジェクト: BarAgent/mps-temporary
Res SACFill(Addr *p_o, SAC sac, Size size, Bool hasReservoirPermit)
{
  Index i;
  Count blockCount, j;
  Size blockSize;
  Addr p, fl;
  Res res = ResOK; /* stop compiler complaining */
  mps_sac_t esac;

  AVER(p_o != NULL);
  AVERT(SAC, sac);
  AVER(size != 0);
  AVERT(Bool, hasReservoirPermit);
  esac = ExternalSACOfSAC(sac);

  sacFind(&i, &blockSize, sac, size);
  /* Check it's empty (in the future, there will be other cases). */
  AVER(esac->_freelists[i]._count == 0);

  /* Fill 1/3 of the cache for this class. */
  blockCount = esac->_freelists[i]._count_max / 3;
  /* Adjust size for the overlarge class. */
  if (blockSize == SizeMAX)
    /* .align: align 'cause some classes don't accept unaligned. */
    blockSize = SizeAlignUp(size, PoolAlignment(sac->pool));
  for (j = 0, fl = esac->_freelists[i]._blocks;
       j <= blockCount; ++j) {
    res = PoolAlloc(&p, sac->pool, blockSize, hasReservoirPermit);
    if (res != ResOK)
      break;
    /* @@@@ ignoring shields for now */
    *ADDR_PTR(Addr, p) = fl; fl = p;
  }
  /* If didn't get any, just return. */
  if (j == 0) {
    AVER(res != ResOK);
    return res;
  }

  /* Take the last one off, and return it. */
  esac->_freelists[i]._count = j - 1;
  *p_o = fl;
  /* @@@@ ignoring shields for now */
  esac->_freelists[i]._blocks = *ADDR_PTR(Addr, fl);
  return ResOK;
}
コード例 #6
0
ファイル: data.c プロジェクト: cmjonze/anacapa
char *PoolStrdup(TPool *p,char *s)
{
	char *ns = 0;

	/* sanity */
	if (!p) {
		return 0;
	}

	if (s) {
		if( (ns = PoolAlloc(p,strlen(s)+1)) )
			strcpy(ns,s);
	} else
		ns=NULL;

	return ns;
}
コード例 #7
0
ファイル: utask.c プロジェクト: noteforsteve/utask
void *
uTaskAlloc(
    IN int              uSize
    )
{
    void *p;

    /* Disable interrupts, allowing pool allocs during isr execution */
    int PrevState = uTaskInterruptDisable();

    /* Allocate the pool block, note this is not your normal alloc */
    p = PoolAlloc(uSize);

    /* Restore the interrupt state */
    uTaskInterruptRestore(PrevState);

    return p;
}
コード例 #8
0
ファイル: zmwin.c プロジェクト: mingpen/OpenNT
/*  ResizeWindow - change the size of a window, update pContent.
 *
 *  arguments:
 *      hWnd        handle to window to resize
 *      pBox        pointer to box to check
 *
 *  return value:
 *      returns TRUE if window needs repainting
 *
 *  IMPORTANT :
 *      ResizeWindow does not update the screen.
 */
FLAG PASCAL INTERNAL ResizeWindow ( HW hWnd, PBOX pBox )
{
    INT windSize = 0;

    FitWinToScrn ( pBox );
    if (hWnd->win.left == pBox->left && hWnd->win.right == pBox->right &&
        hWnd->win.top == pBox->top && hWnd->win.bottom == pBox->bottom)
        return FALSE;

    hWnd->win = *pBox;
    if (hWnd->pContent != NULL) {
        windSize = TWINWIDTH (hWnd) * TWINHEIGHT (hWnd) * sizeof(CHAR);
        if ( (UINT)windSize > hWnd->contSize ) {
            PoolFree ( hWnd->pContent );
            hWnd->pContent = PoolAlloc ( windSize );
            hWnd->contSize = windSize;
        }
        SendMessage ( hWnd, REGENCONT, NULL );
    }
    return TRUE;
}
コード例 #9
0
ファイル: poolncv.c プロジェクト: sionescu/mps-temporary
#include "mpsavm.h"
#include "testlib.h"
#include "mpslib.h"


static void testit(ArenaClass class, ArgList args)
{
  Arena arena;
  Pool pool;
  Res res;
  Addr p;

  die(ArenaCreate(&arena, class, args), "ArenaCreate");

  die(PoolCreate(&pool, arena, PoolClassN(), argsNone), "PoolNCreate");
  res = PoolAlloc(&p, pool, 1, /* withReservoirPermit */ FALSE);
  if (res == ResOK) {
    error("Error: Unexpectedly succeeded in"
          "allocating block from PoolN\n");
  }
  PoolDestroy(pool);
  ArenaDestroy(arena);
}


int main(int argc, char *argv[])
{
  testlib_unused(argc);
  MPS_ARGS_BEGIN(args) {
    MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, 600000);
    MPS_ARGS_DONE(args);
コード例 #10
0
ファイル: readfile.c プロジェクト: mingpen/OpenNT
/*  readProc - handle messages for the read-file window.  This function is used
 *             to handle both help windows and read-message windows.
 *
 *  arguments:
 *      hWnd        handle of window receiving message
 *      command     command in message
 *      data        data peculiar to the command
 *
 *  return value:
 *      none
 *
 */
VOID PASCAL INTERNAL readProc ( HW hWnd, INT command, WDATA data )
{
    INT width = TWINWIDTH (hWnd);
    INT height = TWINHEIGHT (hWnd);
    INT winSize = width *height *sizeof ( CHAR );
    INT oldTop;     /* Do NOT initialize this here, hWnd->data may be invalid */
    INT i;

    switch ( command ) {
    case KEY :
        oldTop = FT->top;
        switch ( data ) {
        case HELP :
            if ( !fHelp ) {
                fHelp = TRUE;
                SpecificHlp ( "reading messages" );
                }
            break;
        case ESC :
            fAllowCM = FALSE;
            CloseWindow ( hWnd );
            return;
        case CTRL_P:
        case UP :
            FT->top = max ( 0, FT->top - 1 );
            break;
        case CTRL_N:
        case DOWN :
            if ( ( FT->llof == -1 ) || ( FT->top < FT->llof - 1 ) )
                FT->top++;
            break;
        case CTRL_K:
        case PGUP :
            FT->top = max ( 0, FT->top - ( height - 1 ) );
            break;
        case CTRL_L:
        case PGDN :
            if ( ( FT->llof == -1 ) || ( FT->top + height - 1 < FT->llof ) )
                FT->top += height - 1;
            break;
        case CTRL_T:
        case HOME :
            FT->top = 0;
            break;
        case CTRL_B:
        case END :
            if ( FT->llof == -1 ) {
                FT->top = PAGETOLINE (FT->cPages - 1);
                while ( GrabNextPage ( hWnd ) )
                    FT->top += PAGELEN;
                while ( fSkipToLine ( hWnd, FT->top ) )
                    FT->top++;
                FT->top = max ( 0, FT->top - ( height - 2 ) );
                }
            else
                FT->top = FT->llof - 1;
            break;
        default :
            if ( ( *hWnd->keyProc ) ( hWnd, data ) )
                return;
            break;
        }
        /* topLine has moved, so decide how to redraw the read window,  */
        /* if the window was only moved 1 line, scroll it and draw the  */
        /* new line, otherwise redraw the whole window.                 */
        if ( ( FT->top == oldTop - 1 ) || ( FT->top == oldTop + 1 ) ) {
            ScrollWindow ( hWnd, 1, FT->top - oldTop );
            if ( FT->top - oldTop < 0 ) {
                SendMessage ( hWnd, REGENCONT, FT->top + 1 );
                SendMessage ( hWnd, PAINT, 0 );
                }
            else {
                SendMessage ( hWnd, REGENCONT, FT->top + height );
                SendMessage ( hWnd, PAINT, height - 1 );
                }
            CheckMore ( hWnd );
            }
        else
        if ( FT->top != oldTop ) {
            SendMessage ( hWnd, REGENCONT, NULL );
            DrawWindow ( hWnd, FALSE );
            }
#if DEBUG
        debout ( "Character %x struck", data );
#endif
        break;
    case REGENCONT :
        /* grab line from file and put it in window's content region */
        /* data is a pointer to struct pos. if data == NULL, redo    */
        /* all lines from FT->top to the end of the window           */
        if ( data != 0 )
            LineToCont ( hWnd, data - 1 );
        else {
            Fill ( ( LPSTR ) hWnd->pContent, ' ', winSize );
            for ( i = 0; i <= height - 1; i++)
                SendMessage ( hWnd, REGENCONT, FT->top + i + 1 );
            CheckMore ( hWnd );
            }
        break;
    case CREATE :
        hWnd->data = data;
        FT->pages = ( PLONG ) ZMalloc ( PAGEMAX * sizeof ( *FT->pages ) );
        FT->pages [ 0 ] = 0L;
        FT->cPageMax = PAGEMAX;
        hWnd->pContent = PoolAlloc ( winSize );
        hWnd->contSize = winSize;
        WindLevel++;
        SendMessage ( hWnd, REOPNFILE, 0 );
        break;
    case REOPNFILE :
        FT->fhRead = fopen ( FT->fileRead, "r" );
        fseek ( FT->fhRead, 0L, 0 );
        FT->cur = FT->top = 0;
        FT->llof = -1;
        FT->cPages = 1;
        SendMessage ( hWnd, REGENCONT, NULL );
        /* if data != 0 redraw the window too */
        if ( data ) {
            DrawWindow ( hWnd, FALSE );
            CheckMore ( hWnd );
            }
        break;
    case CLOSEFILE :
        fclose ( FT->fhRead );
        break;
    case CLOSE :
        fclose ( FT->fhRead );
        if ( FT->fDeleteRead )
            _unlink ( FT->fileRead );
        ZMfree ( FT->fileRead );
        ZMfree ( FT->pages );
        ZMfree ( FT );
        PoolFree ( hWnd->pContent );
        fHelp = FALSE;
        WindLevel--;
        if ( hWnd == hReadMessage )
            hReadMessage = NULL;
        break;
    default :
        defWndProc (hWnd, command, data);
        break;
        }
}
コード例 #11
0
ファイル: hook_file.c プロジェクト: 0day29/zer0m0n
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);
	}