int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrCmdLine, int nCmdShow ) { AttachConsole(ATTACH_PARENT_PROCESS); int argc; wchar_t *const *argv=CommandLineToArgvW(lpstrCmdLine,&argc); if (!argv) return 1; if (argc==3) { if (_wcsicmp(argv[0],L"extract")==0) { // extract DLL, CSV // extracts the string table, the dialog text, and the L10N text from a DLL and stores it in a CSV return ExtractStrings(argv[1],argv[2]); } if (_wcsicmp(argv[0],L"import")==0) { // import DLL, CSV // replaces the string table in the DLL with the text from the CSV return ImportStrings(argv[1],argv[2]); } } return 0; }
static Status InitStructures() { #if OS_WIN wfirmware::Table table; RETURN_STATUS_IF_ERR(GetTable(table)); #else std::vector<u8> table; return ERR::NOT_SUPPORTED; #endif // (instead of counting the total string size, just use the // SMBIOS size - typically 1-2 KB - as an upper bound.) stringStoragePos = stringStorage = (char*)calloc(table.size(), sizeof(char)); // freed in Cleanup if(!stringStorage) WARN_RETURN(ERR::NO_MEM); atexit(Cleanup); const Header* header = (const Header*)&table[0]; const Header* const end = (const Header*)(&table[0] + table.size()); for(;;) { if(header+1 > end) { debug_printf("SMBIOS: table not terminated\n"); break; } if(header->id == 127) // end break; if(header->length < sizeof(Header)) return ERR::_3; // NOWARN (happens on some unknown BIOS, see http://trac.wildfiregames.com/ticket/2985) const Header* next; const Strings strings = ExtractStrings(header, (const char*)end, next); switch(header->id) { #define STRUCTURE(name, id) case id: AddStructure(header, strings, structures.name##_); break; STRUCTURES #undef STRUCTURE default: if(32 < header->id && header->id < 126) // only mention non-proprietary structures of which we are not aware debug_printf("SMBIOS: unknown structure type %d\n", header->id); break; } header = next; } return INFO::OK; }
void ReadStringsT( hid_t iParent, const std::string &iAttrName, size_t iNumStrings, StringT *oStrings ) { ABCA_ASSERT( iParent >= 0, "Invalid parent in ReadStringsT" ); // Open the attribute. hid_t attrId = H5Aopen( iParent, iAttrName.c_str(), H5P_DEFAULT ); ABCA_ASSERT( attrId >= 0, "Couldn't open attribute named: " << iAttrName ); AttrCloser attrCloser( attrId ); // Checking code. { hid_t attrFtype = H5Aget_type( attrId ); DtypeCloser dtypeCloser( attrFtype ); hid_t nativeDtype = GetNativeDtype<CharT>(); ABCA_ASSERT( H5Tget_class( attrFtype ) == H5Tget_class( nativeDtype ) && H5Tget_sign( attrFtype ) == H5Tget_sign( nativeDtype ), "Invalid datatype for stringT" ); } hid_t attrSpace = H5Aget_space( attrId ); ABCA_ASSERT( attrSpace >= 0, "Couldn't get dataspace for attribute: " << iAttrName ); DspaceCloser dspaceCloser( attrSpace ); hssize_t numPoints = H5Sget_simple_extent_npoints( attrSpace ); ABCA_ASSERT( numPoints > 0, "Degenerate string dimensions in ReadStringsT" ); // Create temporary char storage buffer. std::vector<CharT> charStorage( ( size_t )( 1 + numPoints ), ( CharT )0 ); // Read into it. herr_t status = H5Aread( attrId, GetNativeDtype<CharT>(), ( void * )&charStorage.front() ); ABCA_ASSERT( status >= 0, "Couldn't read from attribute: " << iAttrName ); // Extract 'em. ExtractStrings( oStrings, ( const CharT * )&charStorage.front(), 1 + numPoints, iNumStrings ); }