コード例 #1
0
ファイル: pesup.c プロジェクト: 0x00dec0de/Rovnix
//
// Retrieves a module base for the specified module from the specified list of loaded modules.
//
PVOID	PeSupGetModuleBase(
	PCHAR	ModuleName
	)
{
	BOOL	Found = FALSE;
	CHAR	ShortName[MAX_DLL_NAME];
	PVOID	ModuleBase = NULL;
	PLIST_ENTRY	pEntry;
	PLDR_DATA_TABLE_ENTRY	LdrEntry;
	ULONG	NameLen = (ULONG)__strlen(ModuleName);
	
	pEntry = PeSupLoadedModuleList->Flink;
	
	while(pEntry != PeSupLoadedModuleList)
	{
		LdrEntry = CONTAINING_RECORD(pEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderModuleList);
		if (LdrEntry->BaseDllName.Length < MAX_DLL_NAME)
		{
			ULONG i;
			PCHAR Dot;

			for (i=0; i<LdrEntry->BaseDllName.Length; i++)
				ShortName[i] = (CHAR)LdrEntry->BaseDllName.Buffer[i];
			ShortName[NameLen] = 0;

			if (__stricmp(ShortName, ModuleName) == 0)
			{
				Found = TRUE;
				break;
			}
			if (Dot = __strchr(ShortName, '.'))
			{
				Dot[0] = 0;
				if (__stricmp(ShortName, ModuleName) == 0)
				{
					Found = TRUE;
					break;
				}
			}	// if (Dot = strchr(ShortName, '.'))
		}	// if (LdrEntry->BaseDllName.Length < MAX_DLL_NAME)
		pEntry = pEntry->Flink;
	 }	//  while(pEntry != PeSupLoadedModuleList)

	 if (Found)
		 ModuleBase = LdrEntry->DllBase;

	 return(ModuleBase);
 }
コード例 #2
0
ファイル: SharedUtils.cpp プロジェクト: UCSD-AUVSI/Heimdall
bool contains_substr_i(std::string theStr, std::string containsThis, int* position/*=nullptr*/)
{
	int imax = (theStr.size() - containsThis.size() + 1);
	for(int i=0; i<imax; i++) {
		if(!__stricmp(theStr.substr(i,containsThis.size()).c_str(), containsThis.c_str())) {
			if(position != nullptr) {
				(*position) = i;
			}
			return true;
		}
	}
	if(position != nullptr) {
		(*position) = -1;
	}
	return false;
}
コード例 #3
0
ファイル: SharedUtils.cpp プロジェクト: UCSD-AUVSI/Heimdall
void DeleteFilesOfTypeInFolder(std::string folder, std::string filename_extension)
{
	std::string thisfname;
	std::string thisextens;
	tinydir_dir dir;
	tinydir_open(&dir, folder.c_str());
	while(dir.has_next) {
		tinydir_file file;
		tinydir_readfile(&dir, &file);
		if(file.is_dir == false && file.name[0] != '.') {
			thisfname = std::string(file.name);
			//std::cout<<"found file (might delete?) "<<thisfname<<std::endl;
			thisextens = trim_chars_after_delim(thisfname,'.',true);
			//std::cout<<"      extension: \""<<thisextens<<"\""<<std::endl;
			if(!__stricmp(thisextens.c_str(),filename_extension.c_str())) {
				thisfname = std::string(file.path);
				//std::cout<<"DELETING \""<<thisfname<<"\""<<std::endl;
				std::remove(thisfname.c_str());
			}
		}
		tinydir_next(&dir);
	}
	tinydir_close(&dir);
}
コード例 #4
0
ファイル: SharedUtils.cpp プロジェクト: UCSD-AUVSI/Heimdall
bool filename_extension_is_image_type(const std::string & filename_extension)
{
    /*
     * Possible re-write of this function
     *
    std::string possible_extensions[14] = {".bmp", ".dib", ".jpeg",
        ".jpg", ".jpe", ".jp2", ".png", ".pbm", ".pgm", ".ppm", ".sr"
            ".ras", "tiff", ".tif"};

    std::string check_extension = filename_extension;
    std::transform(check_extension.begin(), check_extension.end(),
                    check_extension.begin(), ::tolower);
    for(std::string extension : possible_extensions){
        if(filename_extension == possible_extensions){
            return true;
        }
    }
    return false;
    */

    return (

        !__stricmp(filename_extension.c_str(), ".bmp")
    ||  !__stricmp(filename_extension.c_str(), ".dib")

    ||  !__stricmp(filename_extension.c_str(), ".jpeg")
    ||  !__stricmp(filename_extension.c_str(), ".jpg")
    ||  !__stricmp(filename_extension.c_str(), ".jpe")

    ||  !__stricmp(filename_extension.c_str(), ".jp2")

    ||  !__stricmp(filename_extension.c_str(), ".png")

    ||  !__stricmp(filename_extension.c_str(), ".pbm")
    ||  !__stricmp(filename_extension.c_str(), ".pgm")
    ||  !__stricmp(filename_extension.c_str(), ".ppm")

    ||  !__stricmp(filename_extension.c_str(), ".sr")
    ||  !__stricmp(filename_extension.c_str(), ".ras")

    ||  !__stricmp(filename_extension.c_str(), ".tiff")
    ||  !__stricmp(filename_extension.c_str(), ".tif")

    );
}