You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There does not appear to be any way to easily translate an imported function to its IAT address (for mapping an image into memory.) The following code works. 64 bit only, was in a hurry!
publicstructBetterImportedFunction{/// <summary>/// The module of the import./// </summary>publicstringModule;/// <summary>/// The function being imported./// </summary>publicstringFunction;/// <summary>/// The ordinal being imported./// </summary>publicintOrdinal;/// <summary>/// The IAT address to fill./// </summary>publiculongFillAddress;}publicstaticclassPeFileExtensions{privateconstulongOrdinalBit=0x8000000000000000ul;privateconstulongOrdinalMask=0x7FFFFFFFFFFFFFFFul;publicstaticvoidIterateImports(thisPeFilefile,Action<BetterImportedFunction>handler){varheaders= file.ImageSectionHeaders;foreach(var import in file.ImageImportDescriptors){varmodule= file.Buff.GetCString(import.Name.RVAtoFileMapping(headers));varround=0u;varthunkAddr= import.FirstThunk.RVAtoFileMapping(headers);varthunk=new IMAGE_THUNK_DATA(file.Buff, thunkAddr,true);while(thunk.AddressOfData !=0){if((thunk.Ordinal &OrdinalBit)==OrdinalBit){
handler.Invoke(new BetterImportedFunction
{Module=module,Function=null,Ordinal=(ushort)(thunk.Ordinal &OrdinalMask),FillAddress= import.FirstThunk +(round*8)});}else{varaddrOfNameData=((uint)thunk.AddressOfData).RVAtoFileMapping(headers);varnameData=new IMAGE_IMPORT_BY_NAME(file.Buff, addrOfNameData);
handler.Invoke(new BetterImportedFunction
{Module=module,Function= nameData.Name,Ordinal=-1,FillAddress= import.FirstThunk +(round*8)});}round+=1;thunk=new IMAGE_THUNK_DATA(file.Buff,thunkAddr+(round*8u),true);}}}}
`
The text was updated successfully, but these errors were encountered:
There does not appear to be any way to easily translate an imported function to its IAT address (for mapping an image into memory.) The following code works. 64 bit only, was in a hurry!
The text was updated successfully, but these errors were encountered: