[206] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
[4] | 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;
|
---|
[75] | 52 | Type resultType;
|
---|
| 53 | if( !StaticCalculation(true, temporary,0,&i64data,resultType) ){
|
---|
| 54 | return;
|
---|
| 55 | }
|
---|
| 56 | if(resultType.IsReal()){
|
---|
[465] | 57 | compiler.errorMessenger.Output(9,temporary,0);
|
---|
[4] | 58 | return;
|
---|
| 59 | }
|
---|
| 60 | dwId=(DWORD)i64data;
|
---|
| 61 |
|
---|
| 62 | //Type
|
---|
| 63 | while(buffer[i2]==' '||buffer[i2]=='\t') i2++;
|
---|
| 64 | for(i3=0;;i2++,i3++){
|
---|
| 65 | if(!IsVariableChar(buffer[i2])){
|
---|
| 66 | temporary[i3]=0;
|
---|
| 67 | break;
|
---|
| 68 | }
|
---|
| 69 | temporary[i3]=buffer[i2];
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | //FileName
|
---|
| 73 | while(buffer[i2]==' '||buffer[i2]=='\t') i2++;
|
---|
| 74 | if(buffer[i2]!='\"'){
|
---|
| 75 | //エラー
|
---|
| 76 | return;
|
---|
| 77 | }
|
---|
| 78 | for(i2++,i3=0;;i2++,i3++){
|
---|
| 79 | if(buffer[i2]=='\"'){
|
---|
| 80 | temp2[i3]=0;
|
---|
| 81 | break;
|
---|
| 82 | }
|
---|
| 83 | temp2[i3]=buffer[i2];
|
---|
| 84 | }
|
---|
| 85 | GetFullPath(temp2,BasicCurDir);
|
---|
| 86 |
|
---|
| 87 | if(lstrcmpi(temporary,"CURSOR")==0){
|
---|
| 88 | pCursorResourceInfo=(RESOURCEDATAINFO *)HeapReAlloc(hHeap,0,pCursorResourceInfo,(CursorResourceNum+1)*sizeof(RESOURCEDATAINFO));
|
---|
| 89 | pCursorResourceInfo[CursorResourceNum].dwId=dwId;
|
---|
| 90 | lstrcpy(pCursorResourceInfo[CursorResourceNum].FileName,temp2);
|
---|
| 91 | CursorResourceNum++;
|
---|
| 92 | }
|
---|
| 93 | else if(lstrcmpi(temporary,"BITMAP")==0){
|
---|
| 94 | pBitmapResourceInfo=(RESOURCEDATAINFO *)HeapReAlloc(hHeap,0,pBitmapResourceInfo,(BitmapResourceNum+1)*sizeof(RESOURCEDATAINFO));
|
---|
| 95 | pBitmapResourceInfo[BitmapResourceNum].dwId=dwId;
|
---|
| 96 | lstrcpy(pBitmapResourceInfo[BitmapResourceNum].FileName,temp2);
|
---|
| 97 | BitmapResourceNum++;
|
---|
| 98 | }
|
---|
| 99 | else if(lstrcmpi(temporary,"ICON")==0){
|
---|
| 100 | pIconResourceInfo=(RESOURCEDATAINFO *)HeapReAlloc(hHeap,0,pIconResourceInfo,(IconResourceNum+1)*sizeof(RESOURCEDATAINFO));
|
---|
| 101 | pIconResourceInfo[IconResourceNum].dwId=dwId;
|
---|
| 102 | lstrcpy(pIconResourceInfo[IconResourceNum].FileName,temp2);
|
---|
| 103 | IconResourceNum++;
|
---|
| 104 | }
|
---|
| 105 | else if(lstrcmpi(temporary,"RT_MANIFEST")==0){
|
---|
| 106 | if(XPManiResourceNum) goto error;
|
---|
| 107 |
|
---|
| 108 | lstrcpy(szManifestPath,temp2);
|
---|
| 109 |
|
---|
| 110 | XPManiResourceNum++;
|
---|
| 111 | }
|
---|
| 112 | else{
|
---|
| 113 | error:
|
---|
[465] | 114 | compiler.errorMessenger.Output(17,NULL,0);
|
---|
[4] | 115 | return;
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | i2++;
|
---|
| 119 | while(buffer[i2]==' '||buffer[i2]=='\t') i2++;
|
---|
| 120 | if(buffer[i2]=='\0') break;
|
---|
| 121 | else if(buffer[i2]!='\n'){
|
---|
[465] | 122 | compiler.errorMessenger.Output(17,NULL,0);
|
---|
[4] | 123 | return;
|
---|
| 124 | }
|
---|
| 125 | i2++;
|
---|
| 126 | }
|
---|
| 127 |
|
---|
| 128 | HeapDefaultFree(buffer);
|
---|
| 129 | }
|
---|