static void strchr_func() { char text[1024] = "`11223344567890-=qwertyuiop[]asdfghjkl;'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:ZXCVBNM<>?\0"; int len = strlen(text); for(int i = 0; i < len; i++) { if(i < 10 && i != 0 && i % 2 == 0) { char* str = __strchr(text, text[i]); assert_memory_equal(str, text + i - 1, strlen(text + i - 1)); } else { char* str = __strchr(text, text[i]); assert_memory_equal(str, text + i, strlen(text + i)); } } }
// // 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); }