- Timestamp:
- Sep 28, 2001, 9:43:03 AM (24 years ago)
- Location:
- trunk/src/win32k/pe2lx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win32k/pe2lx/pe2lx.cpp
r6493 r6852 1 /* $Id: pe2lx.cpp,v 1.3 2 2001-08-08 17:24:45 birdExp $1 /* $Id: pe2lx.cpp,v 1.33 2001-09-28 07:43:02 sandervl Exp $ 2 2 * 3 3 * Pe2Lx class implementation. Ring 0 and Ring 3 … … 94 94 #include <stddef.h> /* C library stddef.h. */ 95 95 #include <stdarg.h> /* C library stdarg.h. */ 96 #ifndef RING0 97 #include <stdio.h> 98 #endif 96 99 97 100 #include "vprintf.h" /* win32k printf and vprintf. Not C library! */ … … 2780 2783 BufferedRVARead *pImpThunkReader; /* Buffered reader for thunk reads; ie. reading from the OrgiginalFirstThunk array. */ 2781 2784 ULONG ulModuleOrdinal; /* Module ordinal. Valid as long as fImport is set. */ 2785 #ifndef RING0 2786 ULONG ulCustomModOrdinal; /* Module ordinal of custom Odin dll. Valid as long as fImport is set. */ 2787 char szModuleName[128]; 2788 #endif 2782 2789 ULONG ulRVAFirstThunk; /* Current first thunk array RVA. Points at current entry. */ 2783 2790 ULONG ulRVAOrgFirstThunk; /* Current original first thunk array RVA. Points at current entry. */ … … 2831 2838 (ulRVABaseReloc = pNtHdrs->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress) > 0UL 2832 2839 && 2833 ulRVABaseReloc < pNtHdrs->OptionalHeader.SizeOfImage; 2840 ulRVABaseReloc < pNtHdrs->OptionalHeader.SizeOfImage 2841 && 2842 areFixupsEnabled(); 2834 2843 #endif 2835 2844 printInf(("\n")); … … 2885 2894 2886 2895 /* Make sure kernel32 is the first imported module */ 2887 if (rc == NO_ERROR) 2888 rc = addModule("KERNEL32.DLL", (PULONG)SSToDS(&ul)); 2896 if (rc == NO_ERROR) 2897 { 2898 #ifndef RING0 2899 if(hasCustomDll()) { 2900 rc = addModule(options.pszCustomDll, (PULONG)SSToDS(&ul)); 2901 ulCustomModOrdinal = ul; 2902 strcpy(szModuleName, "KERNEL32"); 2903 } 2904 else 2905 #endif 2906 rc = addModule("KERNEL32.DLL", (PULONG)SSToDS(&ul)); 2907 } 2889 2908 2890 2909 /* initiate the import variables */ … … 2915 2934 rc = pImpNameReader->dupString(ulModuleOrdinal, (PSZ*)SSToDS(&psz)); 2916 2935 if (rc == NO_ERROR) 2917 rc = addModule(psz, (PULONG)SSToDS(&ulModuleOrdinal)); 2918 free(psz); 2936 { 2937 #ifndef RING0 2938 if(hasCustomDll()) { 2939 ulModuleOrdinal = ulCustomModOrdinal; 2940 strcpy(szModuleName, psz); 2941 char *tmp = szModuleName; 2942 while(*tmp != 0 && *tmp != '.') 2943 { 2944 if(*tmp >= 'a' && *tmp <= 'z') { 2945 *tmp += ('A' - 'a'); 2946 } 2947 tmp++; 2948 } 2949 *tmp = 0; 2950 } 2951 else 2952 #endif 2953 rc = addModule(psz, (PULONG)SSToDS(&ulModuleOrdinal)); 2954 2955 free(psz); 2956 } 2919 2957 } 2920 2958 else … … 2950 2988 && ((paObjects[iObj].Misc.offTIBFix + paObjects[iObj].ulRVA) & ~(PAGESIZE-1UL)) == ulRVAPage) 2951 2989 { 2952 rc = addModule("KERNEL32.DLL", (PULONG)SSToDS(&ul)); 2990 #ifndef RING0 2991 if(hasCustomDll()) { 2992 rc = addModule(options.pszCustomDll, (PULONG)SSToDS(&ul)); 2993 ulCustomModOrdinal = ul; 2994 } 2995 else 2996 #endif 2997 rc = addModule("KERNEL32.DLL", (PULONG)SSToDS(&ul)); 2953 2998 if (rc == NO_ERROR) 2954 2999 { … … 2957 3002 ul, 2958 3003 pNtHdrs->FileHeader.Characteristics & IMAGE_FILE_DLL ? 2959 ORD_REGISTERPE2LXDLL : ORD_REGISTERPE2LXEXE); 3004 ORD_REGISTERPE2LXDLL : ORD_REGISTERPE2LXEXE 3005 #ifndef RING0 3006 , "KERNEL32" 3007 #endif 3008 ); 2960 3009 } 2961 3010 if (rc != NO_ERROR) … … 2977 3026 if (Thunk.u1.Ordinal & (ULONG)IMAGE_ORDINAL_FLAG) 2978 3027 rc = add32OrdImportFixup((WORD)(ulRVAFirstThunk & (PAGESIZE-1)), 2979 ulModuleOrdinal, Thunk.u1.Ordinal & 0xffff); 3028 ulModuleOrdinal, Thunk.u1.Ordinal & 0xffff 3029 #ifndef RING0 3030 , szModuleName 3031 #endif 3032 ); 2980 3033 else if (Thunk.u1.Ordinal > 0UL && Thunk.u1.Ordinal < pNtHdrs->OptionalHeader.SizeOfImage) 2981 3034 { … … 2985 3038 break; 2986 3039 rc = add32NameImportFixup((WORD)(ulRVAFirstThunk & (PAGESIZE-1)), 2987 ulModuleOrdinal, psz); 3040 ulModuleOrdinal, psz 3041 #ifndef RING0 3042 , szModuleName 3043 #endif 3044 ); 2988 3045 free(psz); 2989 3046 } … … 3028 3085 if (rc == NO_ERROR) 3029 3086 { 3030 rc = addModule(psz, (PULONG)SSToDS(&ulModuleOrdinal)); 3087 #ifndef RING0 3088 if(hasCustomDll()) { 3089 ulModuleOrdinal = ulCustomModOrdinal; 3090 strcpy(szModuleName, psz); 3091 char *tmp = szModuleName; 3092 while(*tmp != 0 && *tmp != '.') { 3093 if(*tmp >= 'a' && *tmp <= 'z') { 3094 *tmp += ('A' - 'a'); 3095 } 3096 tmp++; 3097 } 3098 *tmp = 0; 3099 } 3100 else 3101 #endif 3102 rc = addModule(psz, (PULONG)SSToDS(&ulModuleOrdinal)); 3031 3103 free(psz); 3032 3104 } … … 3828 3900 * 3829 3901 */ 3902 #ifndef RING0 3903 ULONG Pe2Lx::add32OrdImportFixup(WORD offSource, ULONG ulModuleOrdinal, ULONG ulFunctionOrdinal, PSZ pszModuleName) 3904 #else 3830 3905 ULONG Pe2Lx::add32OrdImportFixup(WORD offSource, ULONG ulModuleOrdinal, ULONG ulFunctionOrdinal) 3906 #endif 3831 3907 { 3832 3908 struct r32_rlc *prlc; 3833 3909 ULONG cbFixup; /* size of the fixup record. */ 3910 3911 #ifndef RING0 3912 if(hasCustomDll() && pszModuleName) 3913 { 3914 char searchstring[256]; 3915 char *found; 3916 3917 sprintf(searchstring, "%s.%d", pszModuleName, ulFunctionOrdinal); 3918 found = strstr(options.pszCustomExports, searchstring); 3919 if(found) { 3920 while(*found != '@') { 3921 found++; 3922 } 3923 ulFunctionOrdinal = atoi(++found); 3924 } 3925 else { 3926 printf("Error: Export %s not found in table.\n\n", searchstring); 3927 return ERROR_MOD_NOT_FOUND; 3928 } 3929 } 3930 #endif 3834 3931 3835 3932 /* enough memory? */ … … 3953 4050 * 3954 4051 */ 4052 #ifndef RING0 4053 ULONG Pe2Lx::add32NameImportFixup(WORD offSource, ULONG ulModuleOrdinal, PCSZ pszFnName, PSZ pszModuleName) 4054 #else 3955 4055 ULONG Pe2Lx::add32NameImportFixup(WORD offSource, ULONG ulModuleOrdinal, PCSZ pszFnName) 4056 #endif 3956 4057 { 3957 4058 APIRET rc; … … 3959 4060 ULONG cbFixup; /* size of the fixup record. */ 3960 4061 ULONG offFnName; 4062 4063 #ifndef RING0 4064 if(hasCustomDll()) 4065 { 4066 char searchstring[256]; 4067 char *found; 4068 int ordinal; 4069 4070 sprintf(searchstring, "%s.%s", pszModuleName, pszFnName); 4071 found = strstr(options.pszCustomExports, searchstring); 4072 if(found) { 4073 while(*found != '@') { 4074 found++; 4075 } 4076 ordinal = atoi(++found); 4077 return add32OrdImportFixup(offSource, ulModuleOrdinal, ordinal, NULL); 4078 } 4079 else { 4080 printf("Error: Export %s not found in table.\n\n", searchstring); 4081 return ERROR_MOD_NOT_FOUND; 4082 } 4083 } 4084 #endif 3961 4085 3962 4086 /* enough memory? */ … … 5009 5133 int i = 0; 5010 5134 5135 #ifndef RING0 5136 if(hasCustomDll()) { 5137 return pszWin32ModuleName; 5138 } 5139 #endif 5011 5140 while (paLieList[i].pszWin32Name != NULL) 5012 5141 { -
trunk/src/win32k/pe2lx/pe2lxmain.cpp
r5086 r6852 1 /* $Id: pe2lxmain.cpp,v 1. 7 2001-02-10 11:11:48 birdExp $1 /* $Id: pe2lxmain.cpp,v 1.8 2001-09-28 07:43:03 sandervl Exp $ 2 2 * 3 3 * Pe2Lx main program. (Ring 3 only!) … … 32 32 #include <string.h> 33 33 #include <stdlib.h> 34 #include <io.h> 35 #include <fcntl.h> 36 #include <sys/stat.h> 34 37 #include "OS2Krnl.h" 35 38 #include "modulebase.h" … … 125 128 } 126 129 break; 130 131 case 'f': //ignore internal fixups 132 case 'F': 133 options.fSkipFixups = TRUE; 134 break; 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"); 140 return 5; 141 } 142 options.pszCustomDll = &argv[argi][3]; 143 break; 144 case 'o': 145 case 'O': 146 { 147 int fileIn = open(&argv[argi][3], O_RDONLY, S_IREAD); 148 int sizein = (int)_filelength(fileIn); 149 150 options.pszCustomExports = (PSZ)malloc(sizein+1); 151 memset(options.pszCustomExports, 0, sizein+1); 152 read(fileIn, options.pszCustomExports, sizein); 153 close(fileIn); 154 break; 155 } 127 156 128 157 default:
Note:
See TracChangeset
for help on using the changeset viewer.