- Timestamp:
- Mar 31, 2003, 4:53:32 AM (22 years ago)
- Location:
- trunk/src/win32k
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win32k/include/options.h
r9954 r9957 1 /* $Id: options.h,v 1.2 5 2003-03-31 01:22:45bird Exp $1 /* $Id: options.h,v 1.26 2003-03-31 02:53:31 bird Exp $ 2 2 * 3 3 * Options. … … 92 92 FLAGS_PE_PE, /* fPE */ \ 93 93 FLAGS_PEOO_FORCED, /* fPEOneObject */ \ 94 FALSE, /* fAllRWObjects */ \ 95 FALSE, /* fSkipFixups */ \ 94 96 INFOLEVEL_QUIET, /* ulInfoLevel */ \ 95 97 FALSE, /* fElf */ \ … … 98 100 TRUE, /* fJava */ \ 99 101 FALSE, /* fNoLoader */ \ 100 FALSE, /* fSkipFixups */ \101 102 NULL, /* pszCustomDll */ \ 102 103 NULL, /* pszCustomExports */ \ … … 121 122 #define isPEOneObjectForced() (options.fPEOneObject == FLAGS_PEOO_FORCED) 122 123 124 #define isAllRWObjectsEnabled() (options.fAllRWObjects) 125 #define isAllRWObjectsDisabled() (!options.fAllRWObjects) 126 123 127 #define isELFDisabled() (!options.fElf) 124 128 #define isELFEnabled() (options.fElf) … … 178 182 ULONG fPE; /* Flags set the type of conversion. */ 179 183 ULONG fPEOneObject; /* All in one object. */ 184 ULONG fAllRWObjects; /* All objects are writable. */ 185 ULONG fSkipFixups; /* Base the image stripping of fixups. (Exe only please.) */ 180 186 ULONG ulInfoLevel; /* Pe2Lx InfoLevel. */ 181 187 … … 195 201 ULONG fNoLoader; /* No loader stuff. !FIXME! We should import / functions even if this flag is set!!! */ 196 202 197 ULONG fSkipFixups;198 203 char * pszCustomDll; /* Pointer to custom odin dll name */ 199 204 char * pszCustomExports; /* Pointer to custom export table */ -
trunk/src/win32k/include/pe2lx.h
r9955 r9957 1 /* $Id: pe2lx.h,v 1.1 5 2003-03-31 01:23:14bird Exp $1 /* $Id: pe2lx.h,v 1.16 2003-03-31 02:53:32 bird Exp $ 2 2 * 3 3 * Pe2Lx class declarations. Ring 0 and Ring 3 … … 110 110 ULONG addPageFixupEntry(BOOL fLast = FALSE); 111 111 ULONG add32OffsetFixup(WORD offSource, ULONG ulTarget); 112 #ifndef RING0 113 ULONG add32OrdImportFixup(WORD offSource, ULONG ulModuleOrdinal, ULONG ulFunctionOrdinal, PSZ pszModuleName); 114 ULONG add32NameImportFixup(WORD offSource, ULONG ulModuleOrdinal, PCSZ pszFnName, PSZ pszModuleName); 115 #else 116 ULONG add32OrdImportFixup(WORD offSource, ULONG ulModuleOrdinal, ULONG ulFunctionOrdinal); 117 ULONG add32NameImportFixup(WORD offSource, ULONG ulModuleOrdinal, PCSZ pszFnName); 118 #endif 112 ULONG add32OrdImportFixup(WORD offSource, ULONG ulModuleOrdinal, ULONG ulFunctionOrdinal, PCSZ pszModuleName); 113 ULONG add32NameImportFixup(WORD offSource, ULONG ulModuleOrdinal, PCSZ pszFnName, PCSZ pszModuleName); 119 114 ULONG addModule(PCSZ pszModuleName, PULONG pulModuleOrdinal); 120 115 ULONG addImportFunctionName(PCSZ pszFnName, PULONG poffFnName); … … 140 135 static BOOL setOdin32Path(const char *psz); 141 136 #ifndef RING0 142 static BOOL isCustomDllExcluded( const char *pszModuleName);137 static BOOL isCustomDllExcluded(PCSZ pszModuleName); 143 138 #endif 144 139 -
trunk/src/win32k/pe2lx/pe2lx.cpp
r7068 r9957 1 /* $Id: pe2lx.cpp,v 1.3 4 2001-10-15 20:46:20 sandervlExp $1 /* $Id: pe2lx.cpp,v 1.35 2003-03-31 02:52:49 bird Exp $ 2 2 * 3 3 * Pe2Lx class implementation. Ring 0 and Ring 3 … … 1905 1905 */ 1906 1906 rfree(pVars); 1907 NOREF(lLibPath); 1907 1908 return ERROR_FILE_NOT_FOUND;//ldrOpenPath(pachFilename, (USHORT)cchFilename, pLdrLv, pful, lLibPath); 1908 1909 … … 2567 2568 paObjTab[i].o32_base = ulImageBase + paObjects[i].ulRVA; 2568 2569 paObjTab[i].o32_flags = paObjects[i].flFlags; 2570 if (isAllRWObjectsEnabled()) 2571 paObjTab[i].o32_flags = OBJREAD | OBJWRITE | OBJBIGDEF; 2569 2572 paObjTab[i].o32_pagemap = ulPageMap; 2570 2573 paObjTab[i].o32_mapsize = ALIGN(paObjTab[i].o32_size, PAGESIZE) >> PAGESHIFT; … … 2789 2792 char szModuleName[128]; 2790 2793 #endif 2794 char * pszModuleName; /* Pointer to the current modulename or NULL. Only used with Custombuild. */ 2791 2795 ULONG ulRVAFirstThunk; /* Current first thunk array RVA. Points at current entry. */ 2792 2796 ULONG ulRVAOrgFirstThunk; /* Current original first thunk array RVA. Points at current entry. */ … … 2895 2899 } 2896 2900 2897 /* Make sure kernel32 is the first imported module */ 2898 if (rc == NO_ERROR) 2899 { 2900 #ifndef RING0 2901 if(hasCustomDll()) { 2902 rc = addModule(options.pszCustomDll, (PULONG)SSToDS(&ul)); 2903 ulCustomModOrdinal = ul; 2904 strcpy(szModuleName, "KERNEL32"); 2905 } 2906 else 2907 #endif 2908 rc = addModule("KERNEL32.DLL", (PULONG)SSToDS(&ul)); 2909 } 2901 /* Make sure kernel32/customdll is the first imported module */ 2902 #ifndef RING0 2903 if (hasCustomDll()) 2904 { 2905 rc = addModule(options.pszCustomDll, (PULONG)SSToDS(&ul)); 2906 ulCustomModOrdinal = ul; 2907 } 2908 else 2909 #endif 2910 rc = addModule("KERNEL32.DLL", (PULONG)SSToDS(&ul)); 2910 2911 2911 2912 /* initiate the import variables */ … … 2937 2938 if (rc == NO_ERROR) 2938 2939 { 2939 #ifndef RING0 2940 if(hasCustomDll()) { 2940 pszModuleName = NULL; 2941 #ifdef RING0 2942 rc = addModule(psz, (PULONG)SSToDS(&ulModuleOrdinal)); 2943 2944 #else 2945 /* Uppercase the module names, and skip the extension. */ 2946 if (hasCustomDll()) 2947 { 2948 strcpy((pszModuleName = (char*)SSToDS(szModuleName)), psz); 2941 2949 ulModuleOrdinal = ulCustomModOrdinal; 2942 strcpy(szModuleName, psz); 2943 char *tmp = szModuleName; 2944 while(*tmp != 0 && *tmp != '.') 2945 { 2946 if(*tmp >= 'a' && *tmp <= 'z') { 2947 *tmp += ('A' - 'a'); 2948 } 2949 tmp++; 2950 } 2951 *tmp = 0; 2950 for (char *pszTmp = pszModuleName; *pszTmp !='\0' && *pszTmp != '.'; pszTmp++) 2951 if (*pszTmp >= 'a' && *pszTmp <= 'z') 2952 *pszTmp += ('A' - 'a'); 2953 *pszTmp = '\0'; 2952 2954 } 2953 else 2955 if (!hasCustomDll() || isCustomDllExcluded(pszModuleName)) 2956 { 2957 rc = addModule(psz, (PULONG)SSToDS(&ulModuleOrdinal)); 2958 szModuleName[0] = '\0'; 2959 pszModuleName = NULL; 2960 } 2954 2961 #endif 2955 rc = addModule(psz, (PULONG)SSToDS(&ulModuleOrdinal));2956 2957 2962 free(psz); 2958 2963 } … … 2990 2995 && ((paObjects[iObj].Misc.offTIBFix + paObjects[iObj].ulRVA) & ~(PAGESIZE-1UL)) == ulRVAPage) 2991 2996 { 2997 PCSZ pszTmp = NULL; 2992 2998 #ifndef RING0 2993 if(hasCustomDll()) { 2999 if (hasCustomDll()) 3000 { 3001 pszTmp = "KERNEL32"; 2994 3002 rc = addModule(options.pszCustomDll, (PULONG)SSToDS(&ul)); 2995 ulCustomModOrdinal = ul;2996 3003 } 2997 3004 else … … 3004 3011 ul, 3005 3012 pNtHdrs->FileHeader.Characteristics & IMAGE_FILE_DLL ? 3006 ORD_REGISTERPE2LXDLL : ORD_REGISTERPE2LXEXE 3007 #ifndef RING0 3008 , "KERNEL32" 3009 #endif 3010 ); 3013 ORD_REGISTERPE2LXDLL : ORD_REGISTERPE2LXEXE, pszTmp); 3011 3014 } 3012 3015 if (rc != NO_ERROR) … … 3028 3031 if (Thunk.u1.Ordinal & (ULONG)IMAGE_ORDINAL_FLAG) 3029 3032 rc = add32OrdImportFixup((WORD)(ulRVAFirstThunk & (PAGESIZE-1)), 3030 ulModuleOrdinal, Thunk.u1.Ordinal & 0xffff 3031 #ifndef RING0 3032 , szModuleName 3033 #endif 3034 ); 3033 ulModuleOrdinal, Thunk.u1.Ordinal & 0xffff, pszModuleName); 3035 3034 else if (Thunk.u1.Ordinal > 0UL && Thunk.u1.Ordinal < pNtHdrs->OptionalHeader.SizeOfImage) 3036 3035 { … … 3040 3039 break; 3041 3040 rc = add32NameImportFixup((WORD)(ulRVAFirstThunk & (PAGESIZE-1)), 3042 ulModuleOrdinal, psz 3043 #ifndef RING0 3044 , szModuleName 3045 #endif 3046 ); 3041 ulModuleOrdinal, psz, pszModuleName); 3047 3042 free(psz); 3048 3043 } … … 3087 3082 if (rc == NO_ERROR) 3088 3083 { 3089 #ifndef RING0 3090 if(hasCustomDll()) { 3084 pszModuleName = NULL; 3085 #ifdef RING0 3086 rc = addModule(psz, (PULONG)SSToDS(&ulModuleOrdinal)); 3087 3088 #else 3089 if (hasCustomDll()) 3090 { 3091 strcpy((pszModuleName = (char*)SSToDS(szModuleName)), psz); 3091 3092 ulModuleOrdinal = ulCustomModOrdinal; 3092 strcpy(szModuleName, psz); 3093 char *tmp = szModuleName; 3094 while(*tmp != 0 && *tmp != '.') { 3095 if(*tmp >= 'a' && *tmp <= 'z') { 3096 *tmp += ('A' - 'a'); 3097 } 3098 tmp++; 3099 } 3100 *tmp = 0; 3093 for (char *pszTmp = pszModuleName; *pszTmp !='\0' && *pszTmp != '.'; pszTmp++) 3094 if (*pszTmp >= 'a' && *pszTmp <= 'z') 3095 *pszTmp += ('A' - 'a'); 3096 *pszTmp = '\0'; 3101 3097 } 3102 else 3098 if (!hasCustomDll() || isCustomDllExcluded(pszModuleName)) 3099 { 3100 rc = addModule(psz, (PULONG)SSToDS(&ulModuleOrdinal)); 3101 szModuleName[0] = '\0'; 3102 pszModuleName = NULL; 3103 } 3103 3104 #endif 3104 rc = addModule(psz, (PULONG)SSToDS(&ulModuleOrdinal));3105 3105 free(psz); 3106 3106 } … … 3851 3851 * @param ulFunctionOrdinal Function ordinal. Number of the export which is to be imported from 3852 3852 * the module given by ulModuleOrdinal. 3853 * @param pszModuleName The name of the module or NULL. For custombuild only. 3853 3854 * @sketch IF not enough memory for the fixup THEN (try) allocate more memory 3854 3855 * Fill in fixup record. … … 3902 3903 * 3903 3904 */ 3904 #ifndef RING0 3905 ULONG Pe2Lx::add32OrdImportFixup(WORD offSource, ULONG ulModuleOrdinal, ULONG ulFunctionOrdinal, PSZ pszModuleName) 3906 #else 3907 ULONG Pe2Lx::add32OrdImportFixup(WORD offSource, ULONG ulModuleOrdinal, ULONG ulFunctionOrdinal) 3908 #endif 3905 ULONG Pe2Lx::add32OrdImportFixup(WORD offSource, ULONG ulModuleOrdinal, ULONG ulFunctionOrdinal, PCSZ pszModuleName) 3909 3906 { 3910 3907 struct r32_rlc *prlc; … … 3912 3909 3913 3910 #ifndef RING0 3914 if(hasCustomDll() && pszModuleName) 3915 { 3916 char searchstring[256]; 3917 char *found; 3918 3919 sprintf(searchstring, "%s.%d ", pszModuleName, ulFunctionOrdinal); 3920 found = strstr(options.pszCustomExports, searchstring); 3921 if(found) { 3922 while(*found != '@') { 3923 found++; 3924 } 3925 ulFunctionOrdinal = atoi(++found); 3926 } 3927 else { 3928 printf("Error: Export %s not found in table.\n\n", searchstring); 3911 if (pszModuleName != NULL && *pszModuleName && hasCustomDll() && !isCustomDllExcluded(pszModuleName)) 3912 { 3913 /* Search for "DLL.EXPORT" in the translation file. */ 3914 char szSearchString[256]; 3915 sprintf(szSearchString, "%s.%d ", pszModuleName, ulFunctionOrdinal); 3916 const char * pszFound = strstr(options.pszCustomExports, szSearchString); 3917 if (pszFound) 3918 { 3919 /* Following the DLL.EXPORT is a @ordinal. */ 3920 while (*pszFound != '@') 3921 pszFound++; 3922 return add32OrdImportFixup(offSource, ulModuleOrdinal, atoi(++pszFound), NULL); 3923 } 3924 else 3925 { 3926 printf("Error: Export %s not found in table.\n\n", szSearchString); 3929 3927 return ERROR_MOD_NOT_FOUND; 3930 3928 } 3931 3929 } 3930 #else 3931 NOREF(pszModuleName); 3932 3932 #endif 3933 3933 … … 4000 4000 * @param ulModuleOrdinal Module ordinal in the import module name table (1 based!) 4001 4001 * @param pszFnName Pointer to a readonly function name for the imported function. 4002 * @param pszModuleName The name of the module or NULL. For custombuild only. 4002 4003 * @sketch IF not enough memory for the fixup THEN (try) allocate more memory 4003 4004 * Add function name to the import procedure name table. … … 4052 4053 * 4053 4054 */ 4054 #ifndef RING0 4055 ULONG Pe2Lx::add32NameImportFixup(WORD offSource, ULONG ulModuleOrdinal, PCSZ pszFnName, PSZ pszModuleName) 4056 #else 4057 ULONG Pe2Lx::add32NameImportFixup(WORD offSource, ULONG ulModuleOrdinal, PCSZ pszFnName) 4058 #endif 4055 ULONG Pe2Lx::add32NameImportFixup(WORD offSource, ULONG ulModuleOrdinal, PCSZ pszFnName, PCSZ pszModuleName) 4059 4056 { 4060 4057 APIRET rc; … … 4064 4061 4065 4062 #ifndef RING0 4066 if(hasCustomDll()) 4067 { 4068 char searchstring[256]; 4069 char *found; 4070 int ordinal; 4071 4072 sprintf(searchstring, "%s.%s ", pszModuleName, pszFnName); 4073 found = strstr(options.pszCustomExports, searchstring); 4074 if(found) { 4075 while(*found != '@') { 4076 found++; 4077 } 4078 ordinal = atoi(++found); 4079 return add32OrdImportFixup(offSource, ulModuleOrdinal, ordinal, NULL); 4080 } 4081 else { 4082 printf("Error: Export %s not found in table.\n\n", searchstring); 4063 if (pszModuleName != NULL && *pszModuleName && hasCustomDll() && !isCustomDllExcluded(pszModuleName)) 4064 { 4065 /* Search for "DLL.EXPORT" in the translation file. */ 4066 char szSearchString[256]; 4067 sprintf(szSearchString, "%s.%s ", pszModuleName, pszFnName); 4068 const char * pszFound = strstr(options.pszCustomExports, szSearchString); 4069 if (pszFound) 4070 { 4071 /* Following the DLL.EXPORT is a @ordinal. */ 4072 while (*pszFound != '@') 4073 pszFound++; 4074 return add32OrdImportFixup(offSource, ulModuleOrdinal, atoi(++pszFound), NULL); 4075 } 4076 else 4077 { 4078 printf("Error: Export %s not found in table.\n\n", szSearchString); 4083 4079 return ERROR_MOD_NOT_FOUND; 4084 4080 } 4085 4081 } 4082 #else 4083 NOREF(pszModuleName); 4086 4084 #endif 4087 4085 … … 5133 5131 PCSZ Pe2Lx::queryOdin32ModuleName(PCSZ pszWin32ModuleName) 5134 5132 { 5133 #ifndef RING0 5134 if (hasCustomDll() && !isCustomDllExcluded(pszWin32ModuleName)) 5135 return pszWin32ModuleName; 5136 #endif 5137 5135 5138 int i = 0; 5136 5137 #ifndef RING05138 if(hasCustomDll()) {5139 return pszWin32ModuleName;5140 }5141 #endif5142 5139 while (paLieList[i].pszWin32Name != NULL) 5143 5140 { … … 5149 5146 return pszWin32ModuleName; 5150 5147 } 5148 5149 5150 #ifndef RING0 5151 /** 5152 * Checks if this DLL is excluded from the custombuild dll or not. 5153 * @returns TRUE if excluded. 5154 * @returns FALSE not excluded. 5155 * @param pszModuleName DLL in question. 5156 */ 5157 BOOL Pe2Lx::isCustomDllExcluded(PCSZ pszModuleName) 5158 { 5159 if (options.pszCustomDllExclude == NULL) 5160 return FALSE; 5161 if (!pszModuleName) 5162 return TRUE; 5163 const char *psz = strstr(options.pszCustomDllExclude, pszModuleName); 5164 return (psz && psz[-1] == ';' && psz[strlen(pszModuleName)] == ';'); 5165 } 5166 #endif 5151 5167 5152 5168 -
trunk/src/win32k/pe2lx/pe2lxmain.cpp
r6852 r9957 1 /* $Id: pe2lxmain.cpp,v 1. 8 2001-09-28 07:43:03 sandervlExp $1 /* $Id: pe2lxmain.cpp,v 1.9 2003-03-31 02:52:50 bird Exp $ 2 2 * 3 3 * Pe2Lx main program. (Ring 3 only!) … … 129 129 break; 130 130 131 case 'f': / /ignore internal fixups131 case 'f': /* ignore internal fixups */ 132 132 case 'F': 133 133 options.fSkipFixups = TRUE; 134 134 break; 135 135 136 case 'c': 137 case 'C': //custom odin dll name 138 if(!hasCustomExports()) { 139 printf("Syntax error: export table file not specified (/O).\n\n"); 136 case 'r': /* all read-write objects */ 137 case 'R': 138 if (argv[argi][2] != 'w' && argv[argi][2] != 'W') 139 { 140 printf("Syntax error: Invalid argument, '%s'\n", argv[argi]); 140 141 return 5; 141 142 } 143 options.fAllRWObjects = TRUE; 144 break; 145 146 case 'c': /* custom odin dll name */ 147 case 'C': 148 if (!hasCustomExports()) 149 { 150 printf("Syntax error: export table file not specified (-o:).\n\n"); 151 return 5; 152 } 142 153 options.pszCustomDll = &argv[argi][3]; 143 154 break; 144 case 'o': 155 156 case 'o': /* custom odin dll ordinal mapping */ 145 157 case 'O': 146 158 { … … 152 164 read(fileIn, options.pszCustomExports, sizein); 153 165 close(fileIn); 166 break; 167 } 168 169 case 'x': /* custombuild exclude dll */ 170 case 'X': 171 { 172 int cch = strlen(&argv[argi][3]); 173 if (!cch) 174 { 175 printf("Syntax error: optino -x: requires a dll name!"); 176 return 5; 177 } 178 int cchNew = cch + 4; 179 if (options.pszCustomDllExclude) 180 cchNew += strlen(options.pszCustomDllExclude); 181 options.pszCustomDllExclude = (char*)realloc(options.pszCustomDllExclude, cchNew); 182 183 char *psz = options.pszCustomDllExclude; 184 if (cchNew != cch + 4) 185 psz = psz + strlen(psz); 186 187 /* copy the name in uppercase with ';' at both ends. */ 188 *psz++ = ';'; 189 for (strcpy(psz, &argv[argi][3]); *psz; psz++) 190 if (*psz >= 'a' && *psz <= 'z') 191 *psz += ('A' - 'a'); 192 *psz++ =';'; 193 *psz = '\0'; 154 194 break; 155 195 } … … 293 333 " *: Forced. Applied every time.\n" 294 334 " Default: -1*\n" 335 " -rw Make all segments writable. For use with -1+. A trick to make\n" 336 " it possible for OS/2 to load the objects following on another.\n" 337 " This of course doesn't solve the alignment difference. So if\n" 338 " you build the program pass /ALIGN:0x10000 to the linker.\n" 339 " -f Strip fixups forcing. Don't use with DLLs, may cause traps.\n" 340 "\n" 341 " Custombuild options:\n" 342 " -o:<ordfile> Ordinal file. form: <W32DLL>.<name/ord> @<CustDLLOrd>\n" 343 " -c:<custdll> Custombuild dll. After -o:!\n" 344 " -x:<dll> Exclude from custombuild. -x:MSVCRT for example.\n" 345 "\n" 295 346 " Win32File Input Win32 Exe, Dll or other Win32 PE file.\n" 296 347 " Odin32File Output Odin32-file. If not specified the Win32-file is\n"
Note:
See TracChangeset
for help on using the changeset viewer.