MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / peExtractStrings

Function peExtractStrings

emmy_hook/src/libpe/libpe.cpp:209–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209template<typename T> void peExtractStrings( PE *pe, uint32_t dwMinSize, PE_STRING_ENCODING encoding, PE_STRING_DUP dup, ht_t *LookupTable )
210{
211#define STRING_BUFF_SIZE 0xFFFF
212
213 T zBuffer[STRING_BUFF_SIZE] = {0};
214 int byte = 0;
215 uint32_t dwOffset, dwEnd = ( pe->dwFileSize - sizeof(T) ), dwCurrent = 0;
216 PE_STRING *pString = NULL;
217
218 for( dwOffset = 0; dwOffset < dwEnd; dwOffset += sizeof(T) )
219 {
220 byte = *(T *)&pe->pData[dwOffset];
221 if( peIsPrintable( byte, encoding ) == false )
222 {
223 if( dwCurrent > dwMinSize )
224 {
225 zBuffer[dwCurrent] = 0x00;
226
227 if( ht_get( LookupTable, zBuffer ) == NULL )
228 {
229 pString = (PE_STRING *)malloc( sizeof(PE_STRING) );
230
231 pString->Encoding = encoding;
232 pString->CharLength = dwCurrent - 1;
233 pString->ByteLength = pString->CharLength * sizeof(T);
234 pString->Data = (uint8_t *)dup(zBuffer);
235 pString->Offset = dwOffset;
236
237 ht_add( LookupTable, pString->Data, pString );
238 ll_append( &pe->Strings.List, pString );
239 }
240 }
241
242 dwCurrent = 0;
243 }
244 else if( dwCurrent < STRING_BUFF_SIZE - 2 )
245 {
246 zBuffer[dwCurrent++] = byte;
247 }
248 }
249}
250
251#pragma endregion
252

Callers

nothing calls this directly

Calls 5

peIsPrintableFunction · 0.85
ht_getFunction · 0.85
ht_addFunction · 0.85
ll_appendFunction · 0.85
ll_initFunction · 0.85

Tested by

no test coverage detected