// File: bluesky466[P]ResourcesParser/ResourcesParser.cpp
// Function: ResourcesParser::ResourcesParser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
ResourcesParser::ResourcesParser(const string& filePath) {
	ifstream resources(filePath, ios::in|ios::binary);

	// resources文件开头是个ResTable_header,记录整个文件的信息
	resources.read((char*)&mResourcesInfo, sizeof(ResTable_header));

	// 紧接着就是全局字符串池
	mGlobalStringPool = parserResStringPool(resources);
	if(mGlobalStringPool == nullptr) {
		return;
	}

	for(int i = 0 ; i < mResourcesInfo.packageCount ; i++) {
		PackageResourcePtr pResource = parserPackageResource(resources);
		if(pResource == nullptr) {
			return;
		}
		mResourceForId[pResource->header.id] = pResource;
		mResourceForPackageName[toUtf8((char16_t*)pResource->header.name)] = pResource;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x300, %rsp            # imm = 0x300
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
addq $0x10, %rdi
movq %rdi, -0x2c8(%rbp)
callq 0xb830
movq -0x2b0(%rbp), %rdi
addq $0x20, %rdi
movq %rdi, -0x2c0(%rbp)
callq 0xb850
movq -0x2b0(%rbp), %rdi
addq $0x50, %rdi
movq %rdi, -0x2b8(%rbp)
callq 0xb870
movq -0x2b0(%rbp), %rdi
subq $-0x80, %rdi
movq %rdi, -0x2a8(%rbp)
callq 0xb890
movq -0x10(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movl $0x8, %edi
movl $0x4, %esi
callq 0xb8b0
movl %eax, -0x298(%rbp)
jmp 0x9c85
movl -0x298(%rbp), %edx
movq -0x2a0(%rbp), %rsi
leaq -0x218(%rbp), %rdi
callq 0x33e0
jmp 0x9ca0
movq -0x2b0(%rbp), %rsi
leaq -0x218(%rbp), %rdi
movl $0xc, %edx
callq 0x32f0
jmp 0x9cba
movq -0x2b0(%rbp), %rsi
leaq -0x238(%rbp), %rdi
leaq -0x218(%rbp), %rdx
callq 0x9ff0
jmp 0x9cd6
movq -0x2b0(%rbp), %rdi
addq $0x10, %rdi
leaq -0x238(%rbp), %rsi
callq 0xb8d0
leaq -0x238(%rbp), %rdi
callq 0x43a0
movq -0x2b0(%rbp), %rdi
addq $0x10, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xb900
testb $0x1, %al
jne 0x9d13
jmp 0x9d50
movl $0x1, -0x23c(%rbp)
jmp 0x9f8b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x9fac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x9fa0
movl $0x0, -0x240(%rbp)
movq -0x2b0(%rbp), %rcx
movl -0x240(%rbp), %eax
cmpl 0x8(%rcx), %eax
jae 0x9f81
movq -0x2b0(%rbp), %rsi
leaq -0x250(%rbp), %rdi
leaq -0x218(%rbp), %rdx
callq 0xa370
jmp 0x9d8c
leaq -0x250(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xb930
testb $0x1, %al
jne 0x9da2
jmp 0x9db1
movl $0x1, -0x23c(%rbp)
jmp 0x9ecf
movq -0x2b0(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x2d8(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x6550
movq -0x2d8(%rbp), %rdi
movq %rax, %rsi
addq $0x8, %rsi
callq 0xb960
movq %rax, -0x2d0(%rbp)
jmp 0x9deb
movq -0x2d0(%rbp), %rdi
leaq -0x250(%rbp), %rsi
movq %rsi, -0x2f8(%rbp)
callq 0xba40
movq -0x2f8(%rbp), %rdi
movq -0x2b0(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x2f0(%rbp)
callq 0x6550
addq $0xc, %rax
movq %rax, -0x2e8(%rbp)
leaq -0x291(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0xbb50
movq -0x2e8(%rbp), %rsi
movq -0x2e0(%rbp), %rdx
leaq -0x290(%rbp), %rdi
callq 0xbb70
jmp 0x9e5d
leaq -0x270(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0xa920
jmp 0x9e72
movq -0x2f0(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0xba70
movq %rax, -0x300(%rbp)
jmp 0x9e8e
movq -0x300(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0xba40
leaq -0x270(%rbp), %rdi
callq 0x34a8
leaq -0x290(%rbp), %rdi
callq 0xbc20
leaq -0x291(%rbp), %rdi
callq 0xbc60
movl $0x0, -0x23c(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x4820
movl -0x23c(%rbp), %eax
testl %eax, %eax
jne 0x9f8b
jmp 0x9eeb
jmp 0x9eed
movl -0x240(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x240(%rbp)
jmp 0x9d5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x9f73
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x9f67
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x9f5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x34a8
leaq -0x290(%rbp), %rdi
callq 0xbc20
leaq -0x291(%rbp), %rdi
callq 0xbc60
leaq -0x250(%rbp), %rdi
callq 0x4820
jmp 0x9fa0
movl $0x0, -0x23c(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x3070
addq $0x300, %rsp            # imm = 0x300
popq %rbp
retq
leaq -0x218(%rbp), %rdi
callq 0x3070
movq -0x2a8(%rbp), %rdi
callq 0x4300
movq -0x2b8(%rbp), %rdi
callq 0x4360
movq -0x2c0(%rbp), %rdi
callq 0x4380
movq -0x2c8(%rbp), %rdi
callq 0x43a0
movq -0x220(%rbp), %rdi
callq 0x3450
nopl (%rax,%rax)