1 /** 2 * @namespace biew_plugins_auto 3 * @file plugins/bin/nlm386.h 4 * @brief This file contains NLM file format definitions. 5 * @version - 6 * @remark this source file is part of Binary vIEW project (BIEW). 7 * The Binary vIEW (BIEW) is copyright (C) 1995 Nickols_K. 8 * All rights reserved. This software is redistributable under the 9 * licence given in the file "Licence.en" ("Licence.ru" in russian 10 * translation) distributed in the BIEW archive. 11 * @note Requires POSIX compatible development system 12 * 13 * @author Nickols_K 14 * @since 1995 15 * @note Development, fixes and improvements 16 **/ 17 #ifndef __NLM_INC 18 #define __NLM_INC 19 20 #ifndef __SYS_DEP_H 21 #include "_sys_dep.h" 22 #endif 23 24 #ifdef __HAVE_PRAGMA_PACK__ 25 #pragma pack(1) 26 #endif 27 28 typedef tUInt32 file_ptr; 29 typedef tUInt32 bfd_size_type; 30 typedef tUInt32 bfd_vma; 31 typedef tUInt32 PTR; 32 #define NLM_SIGNATURE "NetWare Loadable Module\x1a" 33 #define NLM_SIGNATURE_SIZE 24 34 #define NLM_MODULE_NAME_SIZE 14 35 #define NLM_MAX_DESCRIPTION_LENGTH 41 36 #define NLM_OLD_THREAD_NAME_LENGTH 5 37 #define NLM_MAX_SCREEN_NAME_LENGTH 4 38 #define NLM_MAX_THREAD_NAME_LENGTH 7 39 #define NLM_MAX_COPYRIGHT_MESSAGE_LENGTH 1 40 41 42 typedef struct nlm_internal_fixed_header 43 { 44 tInt8 nlm_signature[NLM_SIGNATURE_SIZE]; 45 tInt32 nlm_version; 46 tInt8 nlm_moduleName[NLM_MODULE_NAME_SIZE]; 47 file_ptr nlm_codeImageOffset; 48 bfd_size_type nlm_codeImageSize; 49 file_ptr nlm_dataImageOffset; 50 bfd_size_type nlm_dataImageSize; 51 bfd_size_type nlm_uninitializedDataSize; 52 file_ptr nlm_customDataOffset; 53 bfd_size_type nlm_customDataSize; 54 file_ptr nlm_moduleDependencyOffset; 55 tInt32 nlm_numberOfModuleDependencies; 56 file_ptr nlm_relocationFixupOffset; 57 tInt32 nlm_numberOfRelocationFixups; 58 file_ptr nlm_externalReferencesOffset; 59 tInt32 nlm_numberOfExternalReferences; 60 file_ptr nlm_publicsOffset; 61 tInt32 nlm_numberOfPublics; 62 file_ptr nlm_debugInfoOffset; 63 tInt32 nlm_numberOfDebugRecords; 64 file_ptr nlm_codeStartOffset; 65 file_ptr nlm_exitProcedureOffset; 66 file_ptr nlm_checkUnloadProcedureOffset; 67 tInt32 nlm_moduleType; 68 tInt32 nlm_flags; 69 } Nlm_Internal_Fixed_Header; 70 71 typedef struct nlm_internal_variable_header 72 { 73 tUInt8 descriptionLength; 74 tInt8 descriptionText[NLM_MAX_DESCRIPTION_LENGTH + 1]; 75 tInt32 stackSize; 76 tInt32 reserved; /**< should contain zero */ 77 tInt8 oldThreadName[NLM_OLD_THREAD_NAME_LENGTH]; /**< " LONG" */ 78 tUInt8 screenNameLength; 79 tInt8 screenName[NLM_MAX_SCREEN_NAME_LENGTH + 1]; 80 tUInt8 threadNameLength; 81 tInt8 threadName[NLM_MAX_THREAD_NAME_LENGTH + 1]; 82 } Nlm_Internal_Variable_Header; 83 84 /** The header is recognized by "VeRsIoN#" in the stamp field. */ 85 typedef struct nlm_internal_version_header 86 { 87 tInt8 stamp[8]; 88 tInt32 majorVersion; 89 tInt32 minorVersion; 90 tInt32 revision; 91 tInt32 year; 92 tInt32 month; 93 tInt32 day; 94 } Nlm_Internal_Version_Header; 95 96 /** The header is recognized by "CoPyRiGhT=" in the stamp field. */ 97 typedef struct nlm_internal_copyright_header 98 { 99 tInt8 stamp[10]; 100 tUInt8 copyrightMessageLength; 101 tInt8 copyrightMessage[NLM_MAX_COPYRIGHT_MESSAGE_LENGTH]; 102 } Nlm_Internal_Copyright_Header; 103 104 /** The header is recognized by "MeSsAgEs" in the stamp field. */ 105 typedef struct nlm_internal_extended_header 106 { 107 tInt8 stamp[8]; 108 tInt32 languageID; 109 file_ptr messageFileOffset; 110 bfd_size_type messageFileLength; 111 tInt32 messageCount; 112 file_ptr helpFileOffset; 113 bfd_size_type helpFileLength; 114 file_ptr RPCDataOffset; 115 bfd_size_type RPCDataLength; 116 file_ptr sharedCodeOffset; 117 bfd_size_type sharedCodeLength; 118 file_ptr sharedDataOffset; 119 bfd_size_type sharedDataLength; 120 file_ptr sharedRelocationFixupOffset; 121 tInt32 sharedRelocationFixupCount; 122 file_ptr sharedExternalReferenceOffset; 123 tInt32 sharedExternalReferenceCount; 124 file_ptr sharedPublicsOffset; 125 tInt32 sharedPublicsCount; 126 file_ptr sharedDebugRecordOffset; 127 tInt32 sharedDebugRecordCount; 128 bfd_vma SharedInitializationOffset; 129 bfd_vma SharedExitProcedureOffset; 130 tInt32 productID; 131 tInt32 reserved[6]; 132 } Nlm_Internal_Extended_Header; 133 134 /** The format of a custom header as stored internally is different 135 from the external format. This is how we store a custom header 136 which we do not recognize. */ 137 /** The header is recognized by "CuStHeAd" in the stamp field. */ 138 typedef struct nlm_internal_custom_header 139 { 140 tInt8 stamp[8]; 141 bfd_size_type hdrLength; 142 file_ptr dataOffset; 143 bfd_size_type dataLength; 144 tInt8 dataStamp[8]; 145 PTR hdr; 146 } Nlm_Internal_Custom_Header; 147 148 /** The internal Cygnus header is written out externally as a custom 149 header. We don't try to replicate that structure here. */ 150 151 /** The header is recognized by "CyGnUsEx" in the stamp field. */ 152 typedef struct nlm_internal_cygnus_ext_header 153 { 154 tInt8 stamp[8]; 155 file_ptr offset; /**< File location of debugging information. */ 156 bfd_size_type length; /**< Length of debugging information. */ 157 } Nlm_Internal_Cygnus_Ext_Header; 158 159 /** 160 Public names table: 161 =================== 162 +0 ( 1 byte ) - name length 163 +1 ( length bytes ) - name 164 +length+1 ( 4 bytes ) - physical offset from begin of code section 165 */ 166 167 /** 168 External name table: 169 ==================== 170 +0 ( 1 byte ) - name length 171 +1 ( length bytes ) - name 172 +length+1 ( 4 bytes ) - number of fixups 173 +length+5 ( 4 bytes array) - physical offsets from begin of code section 174 */ 175 176 177 typedef tUInt32 Nlm32_Addr; /**< Unsigned program address */ 178 typedef tUInt32 Nlm32_Off; /**< Unsigned file offset */ 179 typedef tInt32 Nlm32_Sword; /**< Signed large integer */ 180 typedef tUInt32 Nlm32_Word; /**< Unsigned large integer */ 181 typedef tUInt16 Nlm32_Half; /**< Unsigned medium integer */ 182 typedef tUInt8 Nlm32_Char; /**< Unsigned tiny integer */ 183 184 typedef tInt32 Nlm64_Sword; 185 typedef tUInt32 Nlm64_Word; 186 typedef tUInt16 Nlm64_Half; 187 188 #ifdef __HAVE_PRAGMA_PACK__ 189 #pragma pack() 190 #endif 191 192 193 #endif 194