Skip to content

Instantly share code, notes, and snippets.

@spotco
Created December 3, 2019 21:16
Show Gist options
  • Select an option

  • Save spotco/bbac2c2527bf897616bdf48d5d40524a to your computer and use it in GitHub Desktop.

Select an option

Save spotco/bbac2c2527bf897616bdf48d5d40524a to your computer and use it in GitHub Desktop.
resource_id_unique.py
import sys
import os
file_lines = open(sys.argv[1],'r').read().split("\n")
prefix_to_keys = {}
for line in file_lines:
tokens = line.split(" ")
key = tokens[1]
prefix = key[0:3]
if not prefix in prefix_to_keys:
prefix_to_keys[prefix] = {}
keys = prefix_to_keys[prefix]
keys[key] = len(keys)
for prefix in sorted(prefix_to_keys.keys()):
keys = prefix_to_keys[prefix]
for key, value in keys.items():
offset = 0
if prefix == "IDD": #APS_NEXT_RESOURCE_VALUE
offset = 1000
elif prefix == "IDM": #APS_NEXT_COMMAND_VALUE
offset = 0x8000
elif prefix == "IDC": #APS_NEXT_CONTROL_VALUE
offset = 1
elif prefix == "IDS": #APS_NEXT_SYMED_VALUE
offset = 2000
print("#define %s %d" % (key, value + offset))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment