Exemplo n.º 1
0
int main(){
    char s1,*s2;
    mas = (Trec*)calloc(maxn*maxw,sizeof(Trec));
    m2 = root = mas;
    char f=0;
    printf("Input 'h' for help\n");
    while(f==0){
        printf("%s","Input operation: ");
        scanf("\n%s",s2);
        s1 = *s2;
        switch (s1){
            case 'a':
                scanf("%s",s2);
                Insert(s2);
                printf("String %s inserted\n",s2);
                break;
            case 'g':
                ;
                int wrd,l1,l2;
				scanf("%d %d %d",&wrd,&l1,&l2);
				Gen(wrd,l1,l2);
				printf("%d words were generated\n",wrd);
                break;
            case 'd':
                scanf("%s",s2);
                int r = Delete(s2);
                if(!r)printf("String %s deleted\n",s2);
                else printf("String %s wasn't found\n",s2); 
                break;
            case 's':
                ;
                char * ssh = "\0"; 
                Show(ssh);
                break;
            case 'p':
                scanf("%s",s2);
                Show(s2);
                break;
            case 'f':
				;
 				time_t t1 = time(NULL); 
                PrintToFile();
				time_t t2 = time(NULL);
			    printf("Time: %f\n",difftime(t2,t1));
                break;
            case 'q':
                printf("%s\n","Quit");
                f=1;
                break;
            case 'h':
                printf("\nBor structure\nby Nickolay Andronov(c)\n\n Operations:\n1)a string - Appends string\n2)d string - Deletes string\n3)s - Shows all strings\n4)q - Quit\n5)h - Help\n6)p string - Prints all strings started with prefix\n7)g(number of words, lowerlimit, upper limit) - Generates random strings \n\n");
                break;
            default: 
                printf("%s\n","Invalid operation");
                break;
        }
    }
	free(mas);		
	return 0;
}
Exemplo n.º 2
0
void
Debug::TimeStart(const uni_char* key, const uni_char* s)
{
	if (!g_dbg_timing || !DoDebugging(key))
		return;

	struct DebugTime time;
	GetTime(time);

	TimeStringLink* link = (TimeStringLink*)Find(&g_dbg_timers, key);
	if (link == NULL)
	{
		// Not found, so put one in.
		OP_NEW(TimeStringLink, (time, key, &g_dbg_timers));
	}
	else
	{
		link->time = time;
	}

	Indent();

    uni_snprintf(g_dbg_mybuff, DEBUG_DEBUGBUFFERSIZE, UNI_L("%s: %s %ld.%03d\n"), key, s, time.sec, time.msec);

	if (g_dbg_use_file)
		PrintToFile(g_dbg_mybuff);

	if (g_dbg_system_debug)
		dbg_systemoutput(g_dbg_mybuff);

#ifdef OPERA_CONSOLE
	if (g_dbg_console)
		ConsoleOutput(g_dbg_mybuff);
#endif
}
Exemplo n.º 3
0
/* static */
void Debug::FlushDbgBuffer()
{
	if (g_dbg_use_file)
		PrintToFile(g_dbg_mybuff);

	if (g_dbg_system_debug)
		dbg_systemoutput(g_dbg_mybuff);

#ifdef OPERA_CONSOLE
	if (g_dbg_console)
		ConsoleOutput(g_dbg_mybuff);
#endif
}
Exemplo n.º 4
0
void CLogFile::Print(const char * szString)
{
	// Lock the mutex
	m_mutex.TryLock(1);

	// Print the message
	printf("%s\n", szString);

	// Flush the output buffer
	fflush(stdout);

	// Print the message to the log file
	PrintToFile(szString);

	// Unlock the mutex
	m_mutex.Unlock();
}
Exemplo n.º 5
0
void CLogFile::PrintfToFile(const char * szFormat, ...)
{
	// Lock the mutex
	m_mutex.TryLock(1);

	// Collect the arguments
	va_list vaArgs;
	char szBuffer[2048];
	va_start(vaArgs, szFormat);
	vsnprintf_s(szBuffer, sizeof(szBuffer), szFormat, vaArgs);
	va_end(vaArgs);

	// Print the message to the log file
	PrintToFile(szBuffer);

	// Unlock the mutex
	m_mutex.Unlock();
}
Exemplo n.º 6
0
void
Debug::TimeEnd(const uni_char* key, const uni_char* s)
{
	if (!g_dbg_timing || !DoDebugging(key))
		return;

	struct DebugTime time;
	GetTime(time);

	TimeStringLink* link = (TimeStringLink*)Find(&g_dbg_timers, key);
	if (link == NULL)
	{
		// Not found!
		// This puts an entry in the g_dbg_timers vector
		// it won't be very informative, but it keeps
		// things going OK.
		link = OP_NEW(TimeStringLink, (time, key, &g_dbg_timers));
	}

    int secs, millis;
    millis = time.msec - link->time.msec;
    secs = time.sec - link->time.sec;
    if(millis < 0)
	{
		millis += 1000;
		--secs;
	}

	Indent();

    uni_snprintf(g_dbg_mybuff, DEBUG_DEBUGBUFFERSIZE, UNI_L("%s: %s %d.%03d\n"), key, s, secs, millis);

	if (g_dbg_use_file)
		PrintToFile(g_dbg_mybuff);

	if (g_dbg_system_debug)
		dbg_systemoutput(g_dbg_mybuff);

#ifdef OPERA_CONSOLE
	if (g_dbg_console)
		ConsoleOutput(g_dbg_mybuff);
#endif
}
Exemplo n.º 7
0
void CLogFile::Print( const char * szString )
{
	// Lock the mutex
	m_mutex.TryLock( 1 );

	// Print the message
	if( m_bLogTime )
		printf( "[%s] %s\n", SharedUtility::GetTimeString(), szString );
	else
		printf( "%s\n", szString );

	// Flush the output buffer
	fflush( stdout );

	// Print the message to the log file
	PrintToFile( szString );

	// Unlock the mutex
	m_mutex.Unlock( );
}
Exemplo n.º 8
0
/*
    Method to merge 2 sorted arrays into 1 array
*/
void Merge(int *A, int *B, int a, int b)
{
    // variables for counters
    int i = 0, j = 0, k = 0;

    // create new array to hold the merged data set
    int *C = new int[a+b];

    // while i is less than a's size and j less than b's size
    while (i < a && j < b)
    {
        // if A's element is less than or equal to B's element
        if (A[i] <= B[j])
            C[k++] = A[i++];  // add to C
        else
            C[k++] = B[j++]; // else, B[j] is greater
    }
    
    // fill out rest of array, in order
    if (i < a)
    {
        for (int p = i; p < a; ++p)
            C[k++] = A[p];
    }
    else
    {
        for (int p = j; p < b; ++p)
            C[k++] = B[p];
    }

    // call print method
    PrintToFile(C, a+b);
    
    // delete dynamically allocated array
    delete [] C;
}
Exemplo n.º 9
0
BOOL
MemoryProc(
    )

/*++

Routine Description:

    MemoryDlgProc supports the display of the memory dialog which displays
    information about total memory, available memory and paging file location.

Arguments:

    Standard PROC entry.

Return Value:

    BOOL - Depending on input message and processing options.

--*/

{
    BOOL    Success;

    static
    int     PercentUtilization;

    MEMORYSTATUS    MemoryStatus;
    HREGKEY         hRegKey;
    LPTSTR          PagingFile;
    TCHAR           Buffer[ MAX_PATH ];

            //
            // Query the memory status from the system.
            //

            MemoryStatus.dwLength = sizeof( MemoryStatus );
            GlobalMemoryStatus( &MemoryStatus );

            //
            // Remember the memory utilization.
            //

            PercentUtilization = MemoryStatus.dwMemoryLoad;

            //
            // Display the total and available physical memory and paging file
            // space in KB and in bytes.
            //


		PrintToFile((LPCTSTR)FormatBigInteger(MemoryStatus.dwTotalPhys,FALSE),IDC_EDIT_TOTAL_PHYSICAL_MEMORY,TRUE);


		PrintToFile((LPCTSTR)FormatBigInteger(MemoryStatus.dwAvailPhys,FALSE),IDC_EDIT_AVAILABLE_PHYSICAL_MEMORY,TRUE);


		PrintToFile((LPCTSTR)FormatBigInteger(MemoryStatus.dwTotalPageFile,FALSE),IDC_EDIT_TOTAL_PAGING_FILE_SPACE,TRUE);


		PrintToFile((LPCTSTR)FormatBigInteger(MemoryStatus.dwAvailPageFile,FALSE),IDC_EDIT_AVAILABLE_PAGING_FILE_SPACE,TRUE);

		/*WFormatMessage(
                            Buffer,
                            sizeof( Buffer ),
                            IDS_FORMAT_MEMORY_IN_USE,
                            PercentUtilization
                            );*/

                PrintDwordToFile(PercentUtilization,IDC_FORMAT_MEMORY_IN_USE);


            //
            // Open the registry key that contains the location of the paging
            // files.
            //

            hRegKey = OpenRegistryKey( &MemKey );
            DbgHandleAssert( hRegKey );
            if( hRegKey == NULL ) {
                return TRUE;
            }

            //
            // Retrieve the location of the paging files.
            //

            Success = QueryNextValue( hRegKey );
            DbgAssert( Success );
            if( Success == FALSE ) {
                Success = CloseRegistryKey( hRegKey );
                DbgAssert( Success );
                return TRUE;
            }

            //
            // PagingFile points to a series of NUL terminated string terminated
            // by an additional NUL (i.e. a MULTI_SZ string). THerefore walk
            // this list of strings adding each to the list box.
            //

            PagingFile = ( LPTSTR ) hRegKey->Data;
            while(( PagingFile != NULL ) && ( PagingFile[ 0 ] != TEXT( '\0' ))) {

                PrintToFile((LPCTSTR)PagingFile,IDC_LIST_PAGING_FILES,TRUE);

                PagingFile += _tcslen( PagingFile ) + 1;
            }

            //
            // Close the registry key.
            //

            Success = CloseRegistryKey( hRegKey );
            DbgAssert( Success );

            return TRUE;
}
Exemplo n.º 10
0
BOOL
DisplayServiceProc(LPDISPLAY_SERVICE ServiceObject)

/*++

Routine Description:

    DisplayServiceProc displays the details about the supplied
    service/device.

Arguments:

    Standard PROC entry.

Return Value:

    BOOL - Depending on input message and processing options.

--*/

{
    BOOL    Success;
    LPDISPLAY_SERVICE       DisplayService;
    LPQUERY_SERVICE_CONFIG  SvcConfig;
    LPTSTR                  Dependent;
    DWORD                   Count;
    TCHAR                   Buffer[ MAX_PATH ];

            //
            // Retrieve and validate the DISPLAY_SERVICE object.
            //

            DisplayService= ( LPDISPLAY_SERVICE ) ServiceObject;
            DbgPointerAssert( DisplayService );
            DbgAssert( CheckSignature( DisplayService ));
            if(    ( DisplayService == NULL )
                || ( ! CheckSignature( DisplayService ))) {
                return FALSE;
            }

            //
            // Display the name and state of the service/device, separated by a
            // colon, as the window title.
            //

                PrintToFile((LPCTSTR)DisplayService->Ess->lpDisplayName,IDC_SERVICE_TITLE,TRUE);
                PrintDwordToFile(DisplayService->Ess->ServiceStatus.dwCurrentState,IDC_CURRENT_STATE);


            //
            // Create a configuration status for this device/service.
            //

            SvcConfig = ConstructSvcConfig(
                            DisplayService->hSvc,
                            DisplayService->Ess
                            );
            DbgPointerAssert( SvcConfig );
            if( SvcConfig == NULL ) {
                return FALSE;
            }

            //
            // Display the service/device's type, start type, error control,
            // and start name.
            //
            //defined in D:\NT\PUBLIC\SDK\INC\winsvc.h
		//typedef struct _QUERY_SERVICE_CONFIGA {
    		//DWORD   dwServiceType;
    		//DWORD   dwStartType;
    		//DWORD   dwErrorControl;
    		//LPSTR   lpBinaryPathName;
    		//LPSTR   lpLoadOrderGroup;
    		//DWORD   dwTagId;
    		//LPSTR   lpDependencies;
    		//LPSTR   lpServiceStartName;
    		//LPSTR   lpDisplayName;
		//} QUERY_SERVICE_CONFIGA, *LPQUERY_SERVICE_CONFIGA;


            PrintDwordToFile((DWORD)
                                SvcConfig->dwServiceType
                             ,IDC_EDIT_SERVICE_TYPE);


            PrintDwordToFile((DWORD)
                                SvcConfig->dwStartType
                            ,IDC_EDIT_START_TYPE);


            PrintDwordToFile((DWORD)
                                SvcConfig->dwErrorControl
                            ,IDC_EDIT_ERROR_CONTROL);


            PrintToFile((LPCTSTR)SvcConfig->lpServiceStartName,
                        IDC_EDIT_START_NAME,TRUE);


            //
            // If the service/device has a binary path name display it.
            //

            if( SvcConfig->lpBinaryPathName != NULL ) {

                TCHAR       Buffer2[ MAX_PATH ];
                LPTSTR      PathName;

                //
                // If the binary path name's prefix is '\\SystemRoot' replace
                // this with '%SystemRoot%' and expand the environment
                // variable to the real system root. This is needed because
                // services/devices that are started by the I/O system do not
                // use the environment variable form in their name.
                //

                if( _tcsnicmp(
                        SvcConfig->lpBinaryPathName,
                        TEXT( "\\SystemRoot" ),
                        11 )
                    == 0 ) {


                    PrintToFile((LPCTSTR)&SvcConfig->lpBinaryPathName[11],IDC_SYSTEM_ROOT,TRUE);//test to see if we need to remove the following

                    Count = ExpandEnvironmentStrings(
                                Buffer,
                                Buffer2,
                                sizeof( Buffer2 )
                                );
                    DbgAssert(( Count != 0 ) && ( Count <= sizeof( Buffer2 )));

                    PathName = Buffer2;

                    PrintToFile((LPCTSTR)
                            Buffer2,IDC_EDIT_PATHNAME,TRUE);

                } else {

                    PathName = SvcConfig->lpBinaryPathName;

                    PrintToFile((LPCTSTR)
                            SvcConfig->lpBinaryPathName,IDC_EDIT_PATHNAME,TRUE);

                }




            }//endif

            //
            // Display the name of the order group.
            //

            PrintToFile((LPCTSTR)
                        SvcConfig->lpLoadOrderGroup,IDC_EDIT_GROUP,TRUE);

            //
            // Traverse the list of dependencies and display them in their
            // appropriate group.
            //

            Dependent = SvcConfig->lpDependencies;
            while(( Dependent != NULL ) && ( Dependent[ 0 ] != TEXT( '\0' ))) {

                UINT    ListId;
                LONG    Index;
                LPTSTR  Name;

                //
                // If the dependent has the prefix SC_GROUP_IDENTIFIER then
                // display it in the group dependency list otherwise display it
                // in the service dependency list.
                //

                if( Dependent[ 0 ] == SC_GROUP_IDENTIFIER ) {

                    ListId = IDC_LIST_GROUP_DEPEND;
                    Name = &Dependent[ 1 ];

                } else {

                    ListId = IDC_LIST_SERVICE_DEPEND;
                    Name = Dependent;
                }

		PrintToFile((LPCTSTR)
                        Name,IDC_NAME,TRUE);


                //
                // Get the next dependent from the list of NUL terminated
                // strings (the list itself is further NUL terminated).
                //

                Dependent += _tcslen( Dependent ) + 1;
            }//end while

            //
            // Destroy the QUERY_SERVICE_CONFIG structure.
            //

            Success = DestroySvcConfig( SvcConfig );
            DbgAssert( Success );

        return TRUE;

}
Exemplo n.º 11
0
BOOL
ServiceListProc(DWORD Param)

/*++

Routine Description:

    ServiceListProc displays the lists of services or devices that are
    available on the system. Double clicking on one of these displayed services
    or devices causes a second dialog box to be displayed with detailed
    information.

Arguments:

    Standard PROC entry.

Return Value:

    BOOL - Depending on input message and processing options.

--*/

{
    BOOL                    Success;
    LPENUM_SERVICE_STATUS   Ess;

    static
    HSVC        hSvc;
    DWORD       ServiceType;
    DWORD       Count;
    DWORD       Widths[ ] = {
                            35,
                            ( DWORD ) -1
                            };

            //
            // By default the dialogs box is set-up to display services.
            // Change its labels if drivers are being displayed.
            //

            ServiceType = ( DWORD ) Param;
            DbgAssert(      ( ServiceType == SERVICE_WIN32 )
                        ||  ( ServiceType == SERVICE_DRIVER ));

            //
            // Open the service controller for the supplied type of service.
            //

            hSvc = OpenSvc( ServiceType );
            DbgHandleAssert( hSvc );
            if( hSvc == NULL ) {
                return FALSE;
            }

            //
            // For each service/device of the supplied type, add it to the list.
            //

            while( Ess = QueryNextSvcEss( hSvc )) {

                LONG            Index;
                DISPLAY_SERVICE DisplayService;
                // LPCLB_ROW       ClbRow;

                //Ess = ( LPENUM_SERVICE_STATUS ) ClbRow->Data;

                //
                // Set up a DISPLAY_SERVICE object.
                //

                DisplayService.hSvc = hSvc;
                DisplayService.Ess  = Ess;
                SetSignature( &DisplayService );

                //
                // Display details about the selected service/device.
                //

                DisplayServiceProc(
                   //( LPARAM ) &DisplayService
                   (LPDISPLAY_SERVICE) &DisplayService
                   );

                PrintToFile((LPCTSTR)TEXT("\n"),IDC_SPACE,TRUE);

            }//end while


    return TRUE;
}
Exemplo n.º 12
0
BOOL
FillEnvironmentListBox(
    IN INT  ListBoxId,
    IN LPKEY Key
    )

/*++

Routine Description:

    FillEnvironmentListBox fills the list box referred to by the supplied
    window handle and control id with enviornment variables and values. The
    environment comes from either the location specified by the supplied key or
    from the process if the key is NULL.

Arguments:

    ListBoxId   - Supplies the control id for the list box to fill.
    Key         - Supplies a pointer to a registry KEY object that describes
                  the location of the environment.

Return Value:

    BOOL        - Returns TRUE if the list box was succesfully filled with the
                  environment, FALSE otherwise.

--*/

{
    BOOL        Success;
    LPENV_VAR   EnvVar;
    LPENV_VAR   ( *NextEnvVarFunc )( );


    //
    // If the supplied Key is NULL get the environment variables from the
    // current process, otherwise get them from the supplied Registry key.
    //

    if( Key == NULL ) {

        EnvVar = FindFirstEnvironmentVariableW( );
        NextEnvVarFunc = FindNextEnvironmentVariableW;

    } else {

        EnvVar = FindFirstRegistryEnvironmentVariableW( Key );
        NextEnvVarFunc = FindNextRegistryEnvironmentVariableW;
    }

    //
    // For each environment variable, initialize the CLB_ROW and CLB_STRING
    // object and add each row's column data.
    //

    while( EnvVar ) {

 	PrintToFile((LPCTSTR)EnvVar->Variable,ListBoxId,TRUE);

	PrintToFile((LPCTSTR)EnvVar->Value,ListBoxId,TRUE);

        //
        // Get the next environment variable.
        //

        EnvVar = NextEnvVarFunc( );
    }

    return TRUE;
}
Exemplo n.º 13
0
BOOL
PortResourceProc( LPSYSTEM_RESOURCES PortObject, int Translation)

/*++

Routine Description:

    PortResourceProc supports the display of port resources for
    each device/driver in the system.

Arguments:

    Standard PROC entry.

Return Value:

    BOOL - Depending on input message and processing options.

--*/

{
    BOOL                Success;

    static
    LPSYSTEM_RESOURCES  SystemResourceLists;
    DWORD       Widths[ ] = {
                            22,
                            10,
                            ( DWORD ) -1
                };
    LPRESOURCE_DESCRIPTOR   ResourceDescriptor;
    TCHAR                   StartBuffer[ MAX_PATH ];
    TCHAR                   LengthBuffer[ MAX_PATH ];

            //
            // Retrieve and validate the system resource lists.
            //

            SystemResourceLists = ( LPSYSTEM_RESOURCES ) PortObject;
            DbgPointerAssert( SystemResourceLists );
            DbgAssert( CheckSignature( SystemResourceLists ));
            if(     ( ! SystemResourceLists )
                ||  ( ! CheckSignature( SystemResourceLists ))) {

                return FALSE;
            }


                ResourceDescriptor = SystemResourceLists[ Translation ].PortHead;
                DbgPointerAssert( ResourceDescriptor );
                DbgAssert( CheckSignature( ResourceDescriptor ));
                if(     ( ! ResourceDescriptor )
                    ||  ( ! CheckSignature( ResourceDescriptor ))) {

                    return FALSE;
                }


                //
                // Walk the resource descriptor list, formatting the appropriate
                // values and adding the CLB_ROW to the Clb.
                //

                while( ResourceDescriptor ) {

                    DbgAssert( ResourceDescriptor->CmResourceDescriptor.Type
                               == CmResourceTypePort );

			PrintDwordToFile(ResourceDescriptor->CmResourceDescriptor.u.Port.Start.LowPart,IDC_PORT_START_LOWPART);

//take out for now scottsu
//PrintDwordToFile(ResourceDescriptor->CmResourceDescriptor.u.Port.Start,IDC_PORT_START);

			PrintDwordToFile(ResourceDescriptor->CmResourceDescriptor.u.Port.Length,IDC_PORT_LENGTH);

			PrintToFile((LPCTSTR) ResourceDescriptor->Owner->Name,IDC_PORT_NAME,TRUE);

			PrintToFile((LPCTSTR)TEXT("\n"),IDC_SPACE,TRUE);
                    //
                    // Get the next resource descriptor.
                    //

                    ResourceDescriptor = ResourceDescriptor->NextSame;

           }

    return TRUE;
}
Exemplo n.º 14
0
BOOL
MemoryResourceProc( LPSYSTEM_RESOURCES MemoryObject,int Translation)

/*++

Routine Description:

    MemoryResourceProc supports the display of memory resources for
    each device/driver in the system.

Arguments:

    Standard PROC entry.

Return Value:

    BOOL - Depending on input message and processing options.

--*/

{
    BOOL                    Success;
    static
    LPSYSTEM_RESOURCES      SystemResourceLists;
    LPCOMPAREITEMSTRUCT     lpcis;
    LPRESOURCE_DESCRIPTOR   ResourceDescriptor;
    TCHAR                   StartBuffer[ MAX_PATH ];
    TCHAR                   LengthBuffer[ MAX_PATH ];

            //
            // Retrieve and validate the system resource lists.
            //

            SystemResourceLists = ( LPSYSTEM_RESOURCES ) MemoryObject;
            DbgPointerAssert( SystemResourceLists );
            DbgAssert( CheckSignature( SystemResourceLists ));
            if(     ( ! SystemResourceLists )
                ||  ( ! CheckSignature( SystemResourceLists ))) {
                return FALSE;
            }


            lpcis = ( LPCOMPAREITEMSTRUCT ) MemoryObject;

                ResourceDescriptor = SystemResourceLists[ Translation ].MemoryHead;
                DbgPointerAssert( ResourceDescriptor );
                DbgAssert( CheckSignature( ResourceDescriptor ));
                if(     ( ! ResourceDescriptor )
                    ||  ( ! CheckSignature( ResourceDescriptor ))) {
                     return FALSE;
                }

                //
                // Initialize the constants in the CLB_ROW object.
                //

                //
                // Walk the resource descriptor list, formatting the appropriate
                // values and adding the CLB_ROW to the Clb.
                //

                while( ResourceDescriptor ) {

                    DbgAssert( ResourceDescriptor->CmResourceDescriptor.Type
                               == CmResourceTypeMemory );

			PrintHexToFile((DWORD) &ResourceDescriptor->CmResourceDescriptor.u.Memory.Start,IDC_MEMORY_START);
                                       //( LPVOID )
			PrintDwordToFile(ResourceDescriptor->CmResourceDescriptor.u.Memory.Length,IDC_MEMORY_LENGTH);

			PrintToFile((LPCTSTR) ResourceDescriptor->Owner->Name,IDC_MEMORY_NAME,TRUE);

                        PrintToFile((LPCTSTR)TEXT("\n"),IDC_SPACE,TRUE);

                    //
                    // Get the next resource descriptor.
                    //

                    ResourceDescriptor = ResourceDescriptor->NextSame;
                }

    return TRUE;
}
Exemplo n.º 15
0
BOOL
InterruptResourceProc(LPSYSTEM_RESOURCES InterruptObject, int Translation)

/*++

Routine Description:

    InterruptResourceProc supports the display of interrupt resources for
    each device/driver in the system.

Arguments:

    Standard DLGPROC entry.

Return Value:

    BOOL - Depending on input message and processing options.

--*/

{
    BOOL                Success;

    static
    LPSYSTEM_RESOURCES  SystemResourceLists;

    DWORD       Widths[ ] = {
                            5,
                            5,
                            16,
                            ( DWORD ) -1
                };
    LPRESOURCE_DESCRIPTOR   ResourceDescriptor;
    TCHAR                   VectorBuffer[ MAX_PATH ];
    TCHAR                   LevelBuffer[ MAX_PATH ];
    TCHAR                   AffinityBuffer[ MAX_PATH ];

            //
            // Retrieve and validate the system resource lists.
            //

            SystemResourceLists = ( LPSYSTEM_RESOURCES ) InterruptObject;
            DbgPointerAssert( SystemResourceLists );
            DbgAssert( CheckSignature( SystemResourceLists ));
            if(     ( ! SystemResourceLists )
                ||  ( ! CheckSignature( SystemResourceLists ))) {

                return FALSE;
            }


                ResourceDescriptor = SystemResourceLists[ Translation ].InterruptHead;
                DbgPointerAssert( ResourceDescriptor );
                DbgAssert( CheckSignature( ResourceDescriptor ));
                if(     ( ! ResourceDescriptor )
                    ||  ( ! CheckSignature( ResourceDescriptor ))) {

                    return FALSE;
                }

                //
                // Walk the resource descriptor list, formatting the appropriate
                // values and adding the CLB_ROW to the Clb.
                //

                while( ResourceDescriptor ) {

                    DbgAssert( ResourceDescriptor->CmResourceDescriptor.Type
                               == CmResourceTypeInterrupt );

			PrintDwordToFile(ResourceDescriptor->CmResourceDescriptor.u.Interrupt.Vector,IDC_INTERRUPT_VECTOR);

			PrintDwordToFile(ResourceDescriptor->CmResourceDescriptor.u.Interrupt.Level,IDC_INTERRUPT_LEVEL);

			PrintDwordToFile(ResourceDescriptor->CmResourceDescriptor.u.Interrupt.Affinity,IDC_INTERRUPT_AFFINITY);

			PrintToFile((LPCTSTR) ResourceDescriptor->Owner->Name,IDC_INTERRUPT_NAME,TRUE);

                        PrintToFile((LPCTSTR)TEXT("\n"),IDC_SPACE,TRUE);

                    //
                    // Get the next resource descriptor.
                    //

                    ResourceDescriptor = ResourceDescriptor->NextSame;
                }

    return TRUE;
}
Exemplo n.º 16
0
BOOL
DmaResourceProc(LPSYSTEM_RESOURCES DMAObject,int Translation)

/*++

Routine Description:

    DmaResourceProc supports the display of DMA resources for each
    device/driver in the system.

Arguments:

    Standard PROC entry.

Return Value:

    BOOL - Depending on input message and processing options.

--*/

{
    BOOL                Success;
    static
    LPSYSTEM_RESOURCES  SystemResourceLists;
    DWORD       Widths[ ] = {
                            12,
                            12,
                            ( DWORD ) -1
                };
    LPRESOURCE_DESCRIPTOR   ResourceDescriptor;
    TCHAR                   ChannelBuffer[ MAX_PATH ];
    TCHAR                   PortBuffer[ MAX_PATH ];

            //
            // Retrieve and validate the system resource lists.
            //

            SystemResourceLists = ( LPSYSTEM_RESOURCES ) DMAObject;
            DbgPointerAssert( SystemResourceLists );
            DbgAssert( CheckSignature( SystemResourceLists ));
            if(     ( ! SystemResourceLists )
                ||  ( ! CheckSignature( SystemResourceLists ))) {

                return FALSE;
            }


                //
                // Determine which list to display.
                //

                ResourceDescriptor = SystemResourceLists[ Translation ].DmaHead;
                DbgPointerAssert( ResourceDescriptor );
                DbgAssert( CheckSignature( ResourceDescriptor ));
                if(     ( ! ResourceDescriptor )
                    ||  ( ! CheckSignature( ResourceDescriptor ))) {

                    return FALSE;
                }

                //
                // Walk the resource descriptor list, formatting the appropriate
                // values and adding the CLB_ROW to the Clb.
                //

                while( ResourceDescriptor ) {

                    DbgAssert( ResourceDescriptor->CmResourceDescriptor.Type
                               == CmResourceTypeDma );

			PrintDwordToFile(ResourceDescriptor->CmResourceDescriptor.u.Dma.Channel,IDC_DMA_CHANNEL);

			PrintDwordToFile(ResourceDescriptor->CmResourceDescriptor.u.Dma.Port,IDC_DMA_PORT);

			PrintToFile((LPCTSTR) ResourceDescriptor->Owner->Name,IDC_DMA_NAME,TRUE);

                        PrintToFile((LPCTSTR)TEXT("\n"),IDC_SPACE,TRUE);

                    //
                    // Get the next resource descriptor.
                    //

                    ResourceDescriptor = ResourceDescriptor->NextSame;

	}//end while

    return TRUE;
}
Exemplo n.º 17
0
int main(int argc, char *argv[])
{
	FILE			*in, *out;
	unsigned char	key[MAX_KEY_SIZE] = {0};
	unsigned char	string[MAX_STRING_SIZE] = {0};
	unsigned char	data[MAX_STRING_SIZE] = {0};
	int				c;
	int				i = 0, k = 0;
	BOOL			active = FALSE;

	printf("\n\nXOR encoder by iserdo v0.3 for DCI bot\n");
	printf("Copyright (c) 2007\n");
	printf("[email protected]\n\n");

	if (argc < 4)
	{
		printf("Usage: %s <key> <inputfile> <outputfile>\n\n", argv[0]);
		printf("Example: %s hiu342 strings.cfg strings.h\n\n", argv[0]);
		return 0;
	}

	strncpy(key, argv[1], sizeof(key));

	in = fopen(argv[2], "rt");
	out = fopen(argv[3], "wt");
	if (in == NULL || out == NULL)
	{
		printf("Failed to open file(s)!\n");
		return 0;
	}

	while ((c = fgetc(in)) != EOF)
	{
		if (c == '\"')
		{
			if (!active)
			{
				active = TRUE;
				memset(data, 0, sizeof(data));
			}
			else
			{
				active = FALSE;
				printf("String: %s, encoded: ", data);
				PrintToFile(Encode(data, key), strlen(data), out);
				printf("%s\n", data);
			}
			fputc(c, out);
			continue;
		}

		if (active)
		{
			_snprintf(data, sizeof(data) - 1, "%s%c", data, c);
		}
		else
			fputc(c, out);
	}

/*		if (c == ' ' && k == 0)
		{
			k = 1;
			i = 0;
			memset(data, 0, sizeof(data));
		}
		else if (c == '\n' || c == '\r')
		{
			k = 0;
			i = 0;

			if (strlen(data) == 0 || strlen(string) == 0)
			{
				fputs("\n", out);
				continue;
			}

			printf("String: %s, value: %s, encoded: ", string, data);

			fputs("\t{", out);
			fputs(string, out);
			fputs(", \"", out);
			PrintToFile(Encode(data, key), strlen(data), out);
			fputs("\", 0},\n", out);

			printf("%s\n", data);

			memset(data, 0, sizeof(data));
			memset(string, 0, sizeof(string));
		}
		else
		{
			if (!k)
				string[i] = c;
			else
				data[i] = c;

			i++;
		}

	}

	if (strlen(data) != 0 && strlen(string) != 0)
	{
		printf("String: %s, value: %s, encoded: ", string, data);

		fputs("\t{", out);
		fputs(string, out);
		fputs(", \"", out);
		PrintToFile(Encode(data, key), strlen(data), out);
		fputs("\", 0},\n", out);
		//fputs("\\x00\", \"\"},\n", out);

		printf("%s\n", data);
	}*/

	fputs("\nchar decode_key[] = \"", out);
	fputs(key, out);
	fputs("\";\n", out);

	printf("Key is: %s\n", key);

	fclose(in);
	fclose(out);

	system("pause");

	return 0;
}
Exemplo n.º 18
0
BOOL
EnvironmentProc()

/*++

Routine Description:

    Display the three (system, user and process) environment variable lists.

Arguments:

    Standard PROC entry.

Return Value:

    BOOL - Depending on input message and processing options.

--*/

{
    BOOL    Success;

            TCHAR       UserName[ MAX_PATH ];
            DWORD       UserNameLength;
            KEY         SystemEnvironKey;
            KEY         UserEnvironKey;

            //
            // Restore the initial state of the KEYs.
            //

            CopyMemory(
                &SystemEnvironKey,
                &_SystemEnvironKey,
                sizeof( SystemEnvironKey )
                );

            CopyMemory(
                &UserEnvironKey,
                &_UserEnvironKey,
                sizeof( UserEnvironKey )
                );

            //
            // Fill the system environment variable list box.
            //

            Success = FillEnvironmentListBox(
                            IDC_LIST_SYSTEM_ENVIRONMENT,
                            &SystemEnvironKey
                            );
            DbgAssert( Success );
            if( Success == FALSE ) {
                return TRUE;
            }

            //
            // Fill the per user environment variable list box.
            //

            Success = FillEnvironmentListBox(
                            IDC_LIST_USER_ENVIRONMENT,
                            &UserEnvironKey
                            );
            DbgAssert( Success );
            if( Success == FALSE ) {
                return TRUE;
            }

            //
            // Fill the process' environment variable list box.
            //

            Success = FillEnvironmentListBox(
                            IDC_LIST_PROCESS_ENVIRONMENT,
                            NULL
                            );
            DbgAssert( Success );
            if( Success == FALSE ) {
                return TRUE;
            }

            //
            // Display the name of the user that user environment variable list
            // belongs to.
            //

            UserNameLength = sizeof( UserName );
            Success = GetUserName(
                        UserName,
                        &UserNameLength
                        );
            DbgAssert( Success );
            if( Success == FALSE ) {
                return TRUE;
            }

	PrintToFile((LPCTSTR)UserName,IDC_EDIT_USER_NAME,TRUE);
	PrintToFile((LPCTSTR)TEXT("\n"),IDC_SPACE,TRUE);


    return TRUE;
}