enum mapper is now a FlagMapper + improve winfunc parsing

This commit is contained in:
hakril
2018-11-26 22:39:31 +01:00
parent 460274d532
commit 5df8cc96dc
3 changed files with 14 additions and 2 deletions
+8 -1
View File
@@ -45,6 +45,7 @@ class WinFunc(object):
class WinFuncParser(Parser):
known_io_info_type = ["__in", "__in_opt", "_In_", "_In_opt_", "_Inout_", "_Out_opt_", "_Out_", "_Reserved_", "_Inout_opt_", "__inout_opt", "__out", "__inout", "__deref_out", "_Outptr_"]
known_io_info_with_param = ["_Out_writes_bytes_", "_In_reads_bytes_opt_", "_In_reads_bytes_"]
known_declarations = {
"WINAPI" : "WINFUNCTYPE",
"LDAPAPI" : "CFUNCTYPE"
@@ -54,7 +55,13 @@ class WinFuncParser(Parser):
def assert_argument_io_info(self):
io_info = self.assert_token_type(NameToken)
if io_info.value not in self.known_io_info_type:
raise ParsingError("Was expection IO_INFO got {0} instead".format(io_info))
if io_info.value not in self.known_io_info_with_param:
raise ParsingError("Was expection IO_INFO got {0} instead".format(io_info))
# Ignore IO infor params.
# Only 1 param accepted for now
self.assert_token_type(OpenParenthesisToken)
self.assert_token_type(NameToken)
self.assert_token_type(CloseParenthesisToken)
return io_info
def parse_func_arg(self, has_winapi):
+5
View File
@@ -103,6 +103,11 @@ class DefinitionParsedFile(ParsedFile):
def compute_imports_exports(self, data):
for windef in data:
self.add_exports(windef.name) # No dependancy check on rvalue for now
if "|" in windef.code: # Multi flags ? Allow cross-file dependancies
# Quick parsing: add all names in the imports
all_imports_words = re.findall(r"\b[A-Z_]\w+", windef.code)
real_deps = [word for word in all_imports_words if word not in self.exports]
self.add_imports(*real_deps)
class NtStatusParsedFile(ParsedFile):
PARSER = def_parser.NtStatusParser
+1 -1
View File
@@ -173,7 +173,7 @@ class WinEnum(object):
lines += ["class {0}(EnumType):".format(self.name)]
lines += [" values = [{0}]".format(", ".join([name for i, name in self.fields]))]
lines += [" mapper = {{x:x for x in values}}".format(self.name)]
lines += [" mapper = FlagMapper(*values)".format(self.name)]
for typedef_name, value in self.typedef.items():
str_value = self.name