Page Menu
Home
desp's stash
Search
Configure Global Search
Log In
Files
F607899
IATReferenceScan.h
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
IATReferenceScan.h
View Options
#pragma once
#include
<vector>
#include
"ProcessAccessHelp.h"
#include
"PeParser.h"
enum
IATReferenceType
{
IAT_REFERENCE_PTR_JMP
,
IAT_REFERENCE_PTR_CALL
,
IAT_REFERENCE_DIRECT_JMP
,
IAT_REFERENCE_DIRECT_CALL
};
class
IATReference
{
public
:
DWORD_PTR
addressVA
;
//Address of reference
DWORD_PTR
targetPointer
;
//Place inside IAT
DWORD_PTR
targetAddressInIat
;
//WIN API?
IATReferenceType
type
;
};
class
IATReferenceScan
{
public
:
IATReferenceScan
()
{
IatAddressVA
=
0
;
IatSize
=
0
;
ImageBase
=
0
;
ImageSize
=
0
;
iatBackup
=
0
;
ScanForDirectImports
=
false
;
ScanForNormalImports
=
true
;
}
~
IATReferenceScan
()
{
iatReferenceList
.
clear
();
iatDirectImportList
.
clear
();
if
(
iatBackup
)
{
free
(
iatBackup
);
}
}
bool
ScanForDirectImports
;
bool
ScanForNormalImports
;
void
startScan
(
DWORD_PTR
imageBase
,
DWORD
imageSize
,
DWORD_PTR
iatAddress
,
DWORD
iatSize
);
//void patchNewIatBaseMemory(DWORD_PTR newIatBaseAddress);
//void patchNewIatBaseFile(DWORD_PTR newIatBaseAddress);
void
patchNewIat
(
DWORD_PTR
stdImagebase
,
DWORD_PTR
newIatBaseAddress
,
PeParser
*
peParser
);
void
patchDirectImportsMemory
();
int
numberOfFoundDirectImports
();
private
:
DWORD_PTR
NewIatAddressRVA
;
DWORD_PTR
IatAddressVA
;
DWORD
IatSize
;
DWORD_PTR
ImageBase
;
DWORD
ImageSize
;
DWORD_PTR
standardImageBase
;
DWORD_PTR
*
iatBackup
;
std
::
vector
<
IATReference
>
iatReferenceList
;
std
::
vector
<
IATReference
>
iatDirectImportList
;
bool
isPageExecutable
(
DWORD
Protect
);
void
scanMemoryPage
(
PVOID
BaseAddress
,
SIZE_T
RegionSize
);
void
analyzeInstruction
(
_DInst
*
instruction
);
void
findNormalIatReference
(
_DInst
*
instruction
);
void
getIatEntryAddress
(
IATReference
*
ref
);
void
findDirectIatReference
(
_DInst
*
instruction
);
bool
isAddressValidMemory
(
DWORD_PTR
address
);
void
patchReferenceInMemory
(
IATReference
*
ref
);
void
patchReferenceInFile
(
IATReference
*
ref
);
void
patchDirectImportInMemory
(
IATReference
*
iter
);
DWORD_PTR
lookUpIatForPointer
(
DWORD_PTR
addr
);
};
/*
PE64
----------
000000013FF82D87 FF15 137C0A00 CALL QWORD [RIP+0xA7C13]
Result: 000000014002A9A0
000000013F65C952 FF25 F8EA0B00 JMP QWORD [RIP+0xBEAF8]
Result: 000000013F71B450
PE32
----------
0120FFA5 FF15 8C6D2601 CALL DWORD [0x01266D8C]
0120FF52 FF25 D4722601 JMP DWORD [0x012672D4]
*/
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Fri, Apr 3, 12:29 AM (1 d, 20 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
9a/a7/a617ec5f13c9d0ef6340a6b0256d
Attached To
rSCY Scylla
Event Timeline
Log In to Comment