-
Notifications
You must be signed in to change notification settings - Fork 55
/
FunctionIdExtractor.ps1
39 lines (39 loc) · 1.23 KB
/
FunctionIdExtractor.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
$filename = "R410-developer\amd64\nvapi64.lib"
$dumpbinAddress = "$Env:VS140COMNTOOLS..\..\VC\bin\dumpbin.exe"
$dumpbinParameter = "/DISASM $filename"
Start-Process $dumpbinAddress $dumpbinParameter -Wait -WindowStyle Hidden -RedirectStandardOutput "$filename.asm"
$content = Get-Content "$filename.asm"
$functionName = ""
foreach ($line in $content)
{
if (!$line)
{
if ($functionName -ne "") {
#Write-Host "$functionName = FAILED,"
}
$functionName = ""
continue;
}
if ($functionName -eq "" -and $line.EndsWith(":") -and ($line.StartsWith("NvAPI_")))
{
$functionName = $line.TrimEnd(':')
continue;
}
$leadingPattern = "ecx,"
if ($functionName -ne "" -and $line.Contains($leadingPattern) -and $line.EndsWith("h"))
{
$functionAddress = $line.Substring($line.IndexOf($leadingPattern) + $leadingPattern.Length).TrimEnd('h')
$functionAddressNumberic = 0
if ([int32]::TryParse($functionAddress,
[System.Globalization.NumberStyles]::HexNumber,
[System.Globalization.CultureInfo]::CurrentCulture,
[ref] $functionAddressNumberic))
{
$functionAddress = $functionAddressNumberic.ToString("X")
Write-Host "$functionName = 0x$functionAddress,"
$functionName = ""
continue;
}
}
}
Remove-Item "$filename.asm"