Subversion Repositories filter_foundry

Rev

Rev 408 | Rev 536 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 408 Rev 440
Line 22... Line 22...
22
 
22
 
23
#include <Resources.h>
23
#include <Resources.h>
24
 
24
 
25
#include "file_compat.h"
25
#include "file_compat.h"
26
 
26
 
27
Boolean readPARMresource(HMODULE hm,char **reason,int readobfusc){
27
Boolean readPARMresource(HMODULE hm,char **reason){
28
        Boolean res = false;
28
        Boolean res = false;
29
        Handle h;
29
        Handle h;
30
 
30
 
31
        if(  !(h = Get1Resource(PARM_TYPE,PARM_ID_NEW))
31
        if( (h = Get1Resource(PARM_TYPE,PARM_ID_NEW)) ||
32
          && !(h = Get1Resource(PARM_TYPE,PARM_ID_OLD))
32
            (h = Get1Resource(PARM_TYPE,PARM_ID_OLD)) )
33
          && readobfusc
33
        {
34
          && ((h = Get1Resource(OBFUSCDATA_TYPE_NEW,OBFUSCDATA_ID_NEW)) ||
-
 
35
              (h = Get1Resource(OBFUSCDATA_TYPE_OLD,OBFUSCDATA_ID_OLD))) ){
-
 
36
                HLock(h);
34
                HLock(h);
37
                if(GetHandleSize(h) == sizeof(PARM_T)) {
35
                if(GetHandleSize(h) == sizeof(PARM_T)) {
38
                        deobfusc((PARM_T*)*h);
36
                        res = readPARM(*h, &gdata->parm, reason, 0 /*Mac format resource*/);
39
                        gdata->obfusc = true;
37
                        gdata->obfusc = false;
-
 
38
                        ReleaseResource(h);
40
                } else {
39
                } else {
41
                        // Obfuscated PARM has wrong size. Should not happen
40
                        // PARM has wrong size. Should not happen
42
                        gdata->obfusc = false;
41
                        gdata->obfusc = false;
43
                        ReleaseResource(h);
42
                        ReleaseResource(h);
44
                        return false;
43
                        return false;
45
                }
44
                }
46
        }
45
        }
-
 
46
        else if( ((h = Get1Resource(OBFUSCDATA_TYPE_NEW,OBFUSCDATA_ID_NEW)) ||
-
 
47
                  (h = Get1Resource(OBFUSCDATA_TYPE_OLD,OBFUSCDATA_ID_OLD))) )
47
        if(h){
48
        {
48
                HLock(h);
49
                HLock(h);
-
 
50
                if(GetHandleSize(h) == sizeof(PARM_T)) {
-
 
51
                        deobfusc((PARM_T*)*h);
49
                res = readPARM(*h, &gdata->parm, reason, 0 /*Mac format resource*/);
52
                        res = readPARM(*h, &gdata->parm, reason, 0 /*Mac format resource*/);
-
 
53
                        gdata->obfusc = true;
50
                ReleaseResource(h);
54
                        ReleaseResource(h);
-
 
55
                } else {
-
 
56
                        // Obfuscated PARM has wrong size. Should not happen
51
                gdata->obfusc = false;
57
                        gdata->obfusc = false;
-
 
58
                        ReleaseResource(h);
-
 
59
                        return false;
-
 
60
                }
52
        }
61
        }
53
        if (!res) {
62
        if (!res) {
54
                gdata->obfusc = false;
63
                gdata->obfusc = false;
55
        }
64
        }
56
        return res;
65
        return res;
Line 59... Line 68...
59
static Boolean readmacplugin(StandardFileReply *sfr,char **reason){
68
static Boolean readmacplugin(StandardFileReply *sfr,char **reason){
60
        Boolean res = false;
69
        Boolean res = false;
61
        short rrn = FSpOpenResFile(&sfr->sfFile,fsRdPerm);
70
        short rrn = FSpOpenResFile(&sfr->sfFile,fsRdPerm);
62
 
71
 
63
        if(rrn != -1){
72
        if(rrn != -1){
64
                if(readPARMresource(NULL,reason,0))
73
                if(readPARMresource(NULL,reason))
65
                        res = true;
74
                        res = true;
66
                CloseResFile(rrn);
75
                CloseResFile(rrn);
67
        }else
76
        }else
68
                *reason = "Could not open file.";
77
                *reason = "Could not open file.";
69
        return res;
78
        return res;