from ctypes import*defsub_40119B():# 根据Name决定0xCC和0xDD位置和个数global dword_401B00
global dword_401700
# Name每个字符相加得到v2
v2 = c_uint8(0)for i in Name:
v2.value =(v2.value +ord(i))&0xff# Name每个字符进行计算,改变dword_401B00的值
n =0
v5 = c_uint8(0)for i inrange(len(Name)):
v5.value =(v2.value ^ord(Name[i]))
v2.value -= v5.value
dword_401B00[v5.value]|=0xCC# 对dword_401B00[v5]赋值0xDD
i = c_uint8(0)
i.value = v5.value ^ v2.value
while1:
v5.value = v5.value - i.value
if(dword_401B00[v5.value]!=0xCC):break
i.value = i.value -1
dword_401B00[v5.value]=0xDD
v5.value = i.value
while( dword_401B00[v5.value]==0xCCor dword_401B00[v5.value]==0xDD):
v5.value = v5.value -1
dword_401B00[v5.value]=0x99# 对dword_401700赋值
dword_401700 = v5.value
defsub_40120C():global maps
global Serial
# 对地图进行分块for i inrange(0,16):
maps.append(dword_401B00[16*i:16*(i+1)])# 获取0xCC坐标点
addr_CC =[]for y inrange(0,16):for x inrange(0,16):if maps[y][x]==0xCC:
addr_CC.append([x,y])# 获取0xDD坐标
addr_DD =[]for x inrange(0,16):for y inrange(0,16):if maps[y][x]==0xDD:
addr_DD.append([x,y])# 获取初始蛇头位置
addr_99 =[]for x inrange(0,16):for y inrange(0,16):if maps[y][x]==0x99:
addr_99.append([x,y])# 蛇头吃0xCC行动轨迹for i inrange(len(addr_CC)-1,-1,-1):
y = addr_99[0][1]- addr_CC[i][1]
x = addr_99[0][0]- addr_CC[i][0]if y >=0:
Serial +='1'* y
else:
Serial +='0'*(-y)if x >=0:
Serial +='2'* x
else:
Serial +='3'*(-x)
addr_99[0]= addr_CC[i]# 蛇头吃0xDD行动轨迹
y = addr_99[0][1]- addr_DD[i][1]
x = addr_99[0][0]- addr_DD[i][0]if y >=0:
Serial +='1'* y
else:
Serial +='0'*(-y)if x >=0:
Serial +='2'* x
else:
Serial +='3'*(-x)if __name__ =='__main__':
Name ='c'# 假设Name长度为1
Serial =''
dword_401B00 =[0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]
maps =[]
sub_40119B()
sub_40120C()print(Name +'的Serial为:\n'+ Serial)