Subversion Repositories filter_foundry

Rev

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

Rev 194 Rev 198
Line 44... Line 44...
44
        parm_id = PARM_ID;
44
        parm_id = PARM_ID;
45
        EnumResourceNames(hm,"PARM",enumnames,0);
45
        EnumResourceNames(hm,"PARM",enumnames,0);
46
 
46
 
47
        // load first PARM resource
47
        // load first PARM resource
48
        if( (resinfo = FindResource(hm,MAKEINTRESOURCE(parm_id),"PARM")) ){
48
        if( (resinfo = FindResource(hm,MAKEINTRESOURCE(parm_id),"PARM")) ){
49
                if( (h = LoadResource(hm,resinfo)) && (pparm = LockResource(h)) )
49
                if( (h = LoadResource(hm,resinfo)) && (pparm = (Ptr)LockResource(h)) )
50
                        res = readPARM(pparm,&gdata->parm,reason,1 /*Windows format resource*/);
50
                        res = readPARM(pparm,&gdata->parm,reason,1 /*Windows format resource*/);
51
        }else if( readobfusc && (resinfo = FindResource(hm,MAKEINTRESOURCE(OBFUSCDATA_ID),RT_RCDATA)) ){
51
        }else if( readobfusc && (resinfo = FindResource(hm,MAKEINTRESOURCE(OBFUSCDATA_ID),RT_RCDATA)) ){
52
                if( (h = LoadResource(hm,resinfo)) && (pparm = LockResource(h)) ){
52
                if( (h = LoadResource(hm,resinfo)) && (pparm = (Ptr)LockResource(h)) ){
53
                        // Fix by DM, 18 Dec 2018:
53
                        // Fix by DM, 18 Dec 2018:
54
                        // We need to copy the information, because the resource data is read-only
54
                        // We need to copy the information, because the resource data is read-only
55
                        DWORD resSize = SizeofResource(hm,resinfo);
55
                        DWORD resSize = SizeofResource(hm,resinfo);
56
                        char* copy = (char*)malloc(resSize);
56
                        char* copy = (char*)malloc(resSize);
57
                        memcpy(copy, pparm, resSize);
57
                        memcpy(copy, pparm, resSize);
Line 77... Line 77...
77
                // see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/loadlibraryex.asp
77
                // see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/loadlibraryex.asp
78
                char name[MAX_PATH+1];
78
                char name[MAX_PATH+1];
79
                if (hm = LoadLibraryEx(myp2cstrcpy(name,sfr->sfFile.name),NULL,LOAD_LIBRARY_AS_DATAFILE)) {
79
                if (hm = LoadLibraryEx(myp2cstrcpy(name,sfr->sfFile.name),NULL,LOAD_LIBRARY_AS_DATAFILE)) {
80
                        if (readPARMresource(hm,reason,0)) {
80
                        if (readPARMresource(hm,reason,0)) {
81
                                if (gdata->parm.iProtected) {
81
                                if (gdata->parm.iProtected) {
82
                                        *reason = "The filter is protected.";
82
                                        *reason = _strdup("The filter is protected.");
83
                                } else {
83
                                } else {
84
                                        readok = gdata->parmloaded = true;
84
                                        readok = gdata->parmloaded = true;
85
                                }
85
                                }
86
                        } else {
86
                        } else {
87
                                *reason = "It is not a standalone filter made by Filter Factory/Filter Foundry.";
87
                                *reason = _strdup("It is not a standalone filter made by Filter Factory/Filter Foundry.");
88
                        }
88
                        }
89
                        FreeLibrary(hm);
89
                        FreeLibrary(hm);
90
                }
90
                }
91
        }
91
        }
92
 
92
 
93
        // If nothing worked, we will try to find a PARM resource (MacOS plugin, or NE executable on Win64)
93
        // If nothing worked, we will try to find a PARM resource (MacOS plugin, or NE executable on Win64)
94
        if (!readok) {
94
        if (!readok) {
95
                if( (readok = read8bfplugin(sfr, reason)) ){
95
                if( (readok = read8bfplugin(sfr, reason)) ){
96
                        gdata->parmloaded = true;
96
                        gdata->parmloaded = true;
97
                } else {
97
                } else {
98
                        *reason = "PARM resource was not found in this plugin file, or this is not a standalone plugin.";
98
                        *reason = _strdup("PARM resource was not found in this plugin file, or this is not a standalone plugin.");
99
                }
99
                }
100
        }
100
        }
101
 
101
 
102
        // Check if we had success
102
        // Check if we had success
103
        if (!readok) {
103
        if (!readok) {
104
                *reason = "PARM resource was not found in this plugin file, or this is not a standalone plugin.";
104
                *reason = _strdup("PARM resource was not found in this plugin file, or this is not a standalone plugin.");
105
        }
105
        }
106
 
106
 
107
        return readok;
107
        return readok;
108
}
108
}