1 | #include "common.h"
|
---|
2 |
|
---|
3 | void GetResourceData(char *FileName){
|
---|
4 | extern HANDLE hHeap;
|
---|
5 | extern char BasicCurDir[MAX_PATH];
|
---|
6 | int i2,i3;
|
---|
7 | char *buffer,temporary[MAX_PATH],temp2[MAX_PATH];
|
---|
8 | HANDLE hFile;
|
---|
9 | DWORD dwId;
|
---|
10 |
|
---|
11 | extern RESOURCEDATAINFO *pCursorResourceInfo;
|
---|
12 | extern int CursorResourceNum;
|
---|
13 | extern RESOURCEDATAINFO *pBitmapResourceInfo;
|
---|
14 | extern int BitmapResourceNum;
|
---|
15 | extern RESOURCEDATAINFO *pIconResourceInfo;
|
---|
16 | extern int IconResourceNum;
|
---|
17 | pCursorResourceInfo=(RESOURCEDATAINFO *)HeapAlloc(hHeap,0,1);
|
---|
18 | CursorResourceNum=0;
|
---|
19 | pBitmapResourceInfo=(RESOURCEDATAINFO *)HeapAlloc(hHeap,0,1);
|
---|
20 | BitmapResourceNum=0;
|
---|
21 | pIconResourceInfo=(RESOURCEDATAINFO *)HeapAlloc(hHeap,0,1);
|
---|
22 | IconResourceNum=0;
|
---|
23 |
|
---|
24 | extern char szManifestPath[MAX_PATH];
|
---|
25 | extern int XPManiResourceNum;
|
---|
26 | szManifestPath[0]=0;
|
---|
27 | XPManiResourceNum=0;
|
---|
28 |
|
---|
29 | hFile=CreateFile(FileName,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
|
---|
30 | if(hFile==INVALID_HANDLE_VALUE) return;
|
---|
31 | i2=GetFileSize(hFile,NULL);
|
---|
32 | buffer=(char *)HeapAlloc(hHeap,0,i2+i2);
|
---|
33 | ReadFile(hFile,buffer,i2,(DWORD *)&i3,NULL);
|
---|
34 | CloseHandle(hFile);
|
---|
35 | buffer[i3]=0;
|
---|
36 | ChangeReturnCode(buffer);
|
---|
37 |
|
---|
38 | i2=0;
|
---|
39 | while(1){
|
---|
40 | //ID
|
---|
41 | while(buffer[i2]==' '||buffer[i2]=='\t') i2++;
|
---|
42 | for(i3=0;;i2++,i3++){
|
---|
43 | if(!IsVariableChar(buffer[i2])){
|
---|
44 | temporary[i3]=0;
|
---|
45 | break;
|
---|
46 | }
|
---|
47 | temporary[i3]=buffer[i2];
|
---|
48 | }
|
---|
49 | if(temporary[0]=='\0') break;
|
---|
50 |
|
---|
51 | _int64 i64data;
|
---|
52 | int type;
|
---|
53 | type=StaticCalculation(true, temporary,0,&i64data,0);
|
---|
54 | if(IsRealNumberType(type)){
|
---|
55 | SetError(9,temporary,0);
|
---|
56 | return;
|
---|
57 | }
|
---|
58 | dwId=(DWORD)i64data;
|
---|
59 |
|
---|
60 | //Type
|
---|
61 | while(buffer[i2]==' '||buffer[i2]=='\t') i2++;
|
---|
62 | for(i3=0;;i2++,i3++){
|
---|
63 | if(!IsVariableChar(buffer[i2])){
|
---|
64 | temporary[i3]=0;
|
---|
65 | break;
|
---|
66 | }
|
---|
67 | temporary[i3]=buffer[i2];
|
---|
68 | }
|
---|
69 |
|
---|
70 | //FileName
|
---|
71 | while(buffer[i2]==' '||buffer[i2]=='\t') i2++;
|
---|
72 | if(buffer[i2]!='\"'){
|
---|
73 | //エラー
|
---|
74 | return;
|
---|
75 | }
|
---|
76 | for(i2++,i3=0;;i2++,i3++){
|
---|
77 | if(buffer[i2]=='\"'){
|
---|
78 | temp2[i3]=0;
|
---|
79 | break;
|
---|
80 | }
|
---|
81 | temp2[i3]=buffer[i2];
|
---|
82 | }
|
---|
83 | GetFullPath(temp2,BasicCurDir);
|
---|
84 |
|
---|
85 | if(lstrcmpi(temporary,"CURSOR")==0){
|
---|
86 | pCursorResourceInfo=(RESOURCEDATAINFO *)HeapReAlloc(hHeap,0,pCursorResourceInfo,(CursorResourceNum+1)*sizeof(RESOURCEDATAINFO));
|
---|
87 | pCursorResourceInfo[CursorResourceNum].dwId=dwId;
|
---|
88 | lstrcpy(pCursorResourceInfo[CursorResourceNum].FileName,temp2);
|
---|
89 | CursorResourceNum++;
|
---|
90 | }
|
---|
91 | else if(lstrcmpi(temporary,"BITMAP")==0){
|
---|
92 | pBitmapResourceInfo=(RESOURCEDATAINFO *)HeapReAlloc(hHeap,0,pBitmapResourceInfo,(BitmapResourceNum+1)*sizeof(RESOURCEDATAINFO));
|
---|
93 | pBitmapResourceInfo[BitmapResourceNum].dwId=dwId;
|
---|
94 | lstrcpy(pBitmapResourceInfo[BitmapResourceNum].FileName,temp2);
|
---|
95 | BitmapResourceNum++;
|
---|
96 | }
|
---|
97 | else if(lstrcmpi(temporary,"ICON")==0){
|
---|
98 | pIconResourceInfo=(RESOURCEDATAINFO *)HeapReAlloc(hHeap,0,pIconResourceInfo,(IconResourceNum+1)*sizeof(RESOURCEDATAINFO));
|
---|
99 | pIconResourceInfo[IconResourceNum].dwId=dwId;
|
---|
100 | lstrcpy(pIconResourceInfo[IconResourceNum].FileName,temp2);
|
---|
101 | IconResourceNum++;
|
---|
102 | }
|
---|
103 | else if(lstrcmpi(temporary,"RT_MANIFEST")==0){
|
---|
104 | if(XPManiResourceNum) goto error;
|
---|
105 |
|
---|
106 | lstrcpy(szManifestPath,temp2);
|
---|
107 |
|
---|
108 | XPManiResourceNum++;
|
---|
109 | }
|
---|
110 | else{
|
---|
111 | error:
|
---|
112 | SetError(17,NULL,0);
|
---|
113 | return;
|
---|
114 | }
|
---|
115 |
|
---|
116 | i2++;
|
---|
117 | while(buffer[i2]==' '||buffer[i2]=='\t') i2++;
|
---|
118 | if(buffer[i2]=='\0') break;
|
---|
119 | else if(buffer[i2]!='\n'){
|
---|
120 | SetError(17,NULL,0);
|
---|
121 | return;
|
---|
122 | }
|
---|
123 | i2++;
|
---|
124 | }
|
---|
125 |
|
---|
126 | HeapDefaultFree(buffer);
|
---|
127 | }
|
---|