static PCImgDelayDescr PiddFromDllName(LPCSTR szDll) { PCImgDelayDescr piddRet = NULL; PIMAGE_NT_HEADERS pinh = PinhFromImageBase(HMODULE(&__ImageBase)); // Scan the Delay load IAT/INT for the dll in question // if (pinh->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT].Size != 0) { PCImgDelayDescr pidd = PFromRva<PCImgDelayDescr>( pinh->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT].VirtualAddress ); // Check all of the dlls listed up to the NULL one. // while (pidd->rvaDLLName != 0) { // Check to see if it is the DLL we want // Intentionally case sensitive to avoid complication of using the CRT // for those that don't use the CRT...the user can replace this with // a variant of a case insenstive comparison routine. // LPCSTR szDllCur = PFromRva<LPCSTR>(pidd->rvaDLLName); size_t cchDllCur = __strlen(szDllCur); if (cchDllCur == __strlen(szDll) && __memcmp(szDll, szDllCur, cchDllCur) == 0) { piddRet = pidd; break; } pidd++; } } return piddRet; }
//多字节转化为宽字节 void C2W(WCHAR** dest, const char* src) { if (src == NULL) { return ; } size_t alen = __strlen(src) + 1; size_t ulen = (size_t)MultiByteToWideChar(CP_ACP, 0, src,alen,NULL, 0 )+1; *dest = new WCHAR[ulen]; ::MultiByteToWideChar(CP_ACP, 0, src, alen, *dest, ulen); }
static void strlen_func() { char* str; for(int i = 1; i < 4000; i++) { str = malloc(i + 1); memset(str, 1, i); str[i] = '\0'; int len = __strlen(str); assert_int_equal(i, len); free(str); str = NULL; } }
// // 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); }
CString::CString(T_DOUBLE dValue) { __T_CHAR pBuffer[__BASE__CString__BUFFER_SIZE]; __BASE__CString__SPRINTF(pBuffer, "%f", dValue); __construct(pBuffer, __strlen(pBuffer)); } // CString
CString::CString(T_LONG iValue) { __T_CHAR pBuffer[__BASE__CString__BUFFER_SIZE]; __BASE__CString__SPRINTF(pBuffer, "%d", iValue); __construct(pBuffer, __strlen(pBuffer)); } // CString
CString::CString(const T_CHAR * pString, T_ULONG uLength) { __construct(pString, (uLength == 0) ? __strlen(pString) : uLength); } // CString
bool check_if_used_string(puint_t test, char* string) { return check_used_range(test, (puint_t)string, __strlen(string)+1); }