#NEWLINE# @ windows . hooks . RegOpenKeyExACallback #NEWLINE# def open_reg_hook( hKey , lpSubKey , ulOptions , samDesired , phkResult , real_function ) : #NEWLINE# #INDENT# print ( '<in hook> Hook called | hKey = {0} | lpSubKey = <{1}>' . format ( hex ( hKey ) , lpSubKey . value ) ) #NEWLINE# if ( 'SECRET' in lpSubKey . value ) : #NEWLINE# #INDENT# print ( '<in hook> Secret key asked, returning magic handle 0x12345678' ) #NEWLINE# phkResult [ 0 ] = 305419896 #NEWLINE# return 0 #NEWLINE# #UNINDENT# if ( 'FAIL' in lpSubKey . value ) : #NEWLINE# #INDENT# print ( '<in hook> Asked for a failing key: returning 0x2a' ) #NEWLINE# return 42 #NEWLINE# #UNINDENT# print ( '<in hook> Non-secret key : calling normal function' ) #NEWLINE# return real_function ( )