This repository was archived by the owner on Dec 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 296
Expand file tree
/
Copy pathmsdnapihelp.py
More file actions
84 lines (68 loc) · 2.48 KB
/
msdnapihelp.py
File metadata and controls
84 lines (68 loc) · 2.48 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
"""
User contributed script: MSDN API HELP plugin
This script fetches the API reference (from MSDN) of a given highlighted identifier
and returns the results in a new web browser page.
This script depends on the feedparser package: http://code.google.com/p/feedparser/
"""
from __future__ import print_function
# -----------------------------------------------------------------------
import ida_kernwin
import ida_name
import ida_idaapi
try:
import feedparser
except:
ida_kernwin.warning('Feedparser package not installed')
def get_url(ident):
"""
Note: This code is left in a separate, toplevel function so that
tests can easily override it and provide a replacement file://
URL and work on machines without an internet connection
"""
try:
# This is a 'hook' to enable testing on machines disconnected
# from the internet (we're not testing feedparser's HTTPS URL
# download capabilities anyway)
import sys
return sys.modules["__main__"].get_url(ident)
except:
return "https://social.msdn.microsoft.com/search/en-US/feed?query=%s&format=RSS&theme=feed%%2fen-us" % ident
# -----------------------------------------------------------------------
class msdnapihelp_plugin_t(ida_idaapi.plugin_t):
flags = ida_idaapi.PLUGIN_UNL
comment = "Online MSDN API Help"
help = "Help me"
wanted_name = "MSDN API Help"
wanted_hotkey = "F3"
def init(self):
return ida_idaapi.PLUGIN_OK
@staticmethod
def sanitize_name(name):
t = ida_name.FUNC_IMPORT_PREFIX
if name.startswith(t):
return name[len(t):]
return name
def run(self, arg):
# Get the highlighted identifier
v = ida_kernwin.get_current_viewer()
ident, ok = ida_kernwin.get_highlight(v)
if not ok:
print("No identifier was highlighted")
return
ident = self.sanitize_name(ident)
print("Looking up '%s' in MSDN online" % ident)
d = feedparser.parse(get_url(ident))
if len(d['entries']) > 0:
url = d['entries'][0].link
if arg > 0:
print("URL: %s" % url)
else:
import webbrowser
webbrowser.open_new_tab(url)
else:
print("API documentation not found for: %s" % ident)
def term(self):
pass
# -----------------------------------------------------------------------
def PLUGIN_ENTRY():
return msdnapihelp_plugin_t()