List of usage examples for java.lang Long toHexString
public static String toHexString(long i)
From source file:org.tvbrowser.tvbrowser.TvBrowser.java
private void openDonation(final SkuDetails skuDetails) { if (skuDetails != null && mHelper != null) { AlertDialog.Builder alert = new AlertDialog.Builder(TvBrowser.this); alert.setTitle(R.string.donation); View view = getLayoutInflater().inflate(R.layout.open_donation, getParentViewGroup(), false); alert.setView(view);//from ww w . j a v a 2s .com ((TextView) view.findViewById(R.id.donation_open_info)) .setText(getString(R.string.make_donation_info).replace("{0}", skuDetails.getPrice())); alert.setNegativeButton(R.string.stop_donation, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); alert.setPositiveButton(R.string.make_donation, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handler.post(new Runnable() { @Override public void run() { mHelper.launchPurchaseFlow(TvBrowser.this, skuDetails.getSku(), 500012, new IabHelper.OnIabPurchaseFinishedListener() { @Override public void onIabPurchaseFinished(IabResult result, Purchase info) { if (result.isSuccess()) { AlertDialog.Builder alert2 = new AlertDialog.Builder( TvBrowser.this); alert2.setTitle(R.string.donation); alert2.setMessage(R.string.thanks_for_donation); alert2.setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); alert2.show(); } } }, Long.toHexString(Double.doubleToLongBits(Math.random()))); } }); } }); alert.show(); } }
From source file:com.peterbochs.PeterBochsDebugger.java
private void jRefreshAddressTranslateTableButtonActionPerformed(ActionEvent evt) { AddressTranslateTableModel model = (AddressTranslateTableModel) this.jAddressTranslateTable2.getModel(); for (int x = 0; x < model.getRowCount(); x++) { if (model.searchType.get(x).equals(1)) { model.segNo.set(x, model.searchSegSelector.get(x).shiftRight(3)); model.virtualAddress.set(x, model.searchAddress.get(x)); BigInteger gdtBase = PeterBochsCommonLib.getPhysicalAddress( CommonLib.string2BigInteger(this.registerPanel.jCR3TextField.getText()), CommonLib.string2BigInteger(this.registerPanel.jGDTRTextField.getText())); commandReceiver.clearBuffer(); gdtBase = gdtBase.add(model.segNo.get(x).multiply(BigInteger.valueOf(8))); sendCommand("xp /8bx " + gdtBase); String result = commandReceiver.getCommandResult(String.format("%08x", gdtBase)); int bytes[] = new int[8]; String[] b = result.replaceFirst("^.*:", "").split("\t"); for (int y = 1; y <= 8; y++) { bytes[y - 1] = (int) CommonLib.string2long(b[y]); }/*w w w.j a v a2 s . c o m*/ Long gdtDescriptor = CommonLib.getLong(bytes, 0); System.out.println(Long.toHexString(gdtDescriptor)); BigInteger base = CommonLib.getBigInteger(bytes[2], bytes[3], bytes[4], bytes[7], 0, 0, 0, 0); System.out.println(base.toString(16)); model.linearAddress.set(x, base.add(model.searchAddress.get(x))); } } model.fireTableDataChanged(); }
From source file:com.peterbochs.PeterBochsDebugger.java
private void parseELF(File elfFile) { jELFDumpPanel.remove(jTabbedPane4);//from w w w. j a va 2 s . c o m jTabbedPane4 = null; jELFDumpPanel.add(getJTabbedPane4(), BorderLayout.CENTER); HashMap map = ElfUtil.getELFDetail(elfFile); if (map != null) { // header DefaultTableModel model = (DefaultTableModel) jELFHeaderTable.getModel(); while (model.getRowCount() > 0) { model.removeRow(0); } Set entries = ((HashMap) map.get("header")).entrySet(); Iterator it = entries.iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); Vector<String> v = new Vector<String>(); v.add(entry.getKey().toString()); String bytesStr = ""; if (entry.getValue().getClass() == Short.class) { jStatusLabel.setText("header " + Long.toHexString((Short) entry.getValue())); bytesStr += "0x" + Long.toHexString((Short) entry.getValue()); } else if (entry.getValue().getClass() == Integer.class) { bytesStr += "0x" + Long.toHexString((Integer) entry.getValue()); } else if (entry.getValue().getClass() == Long.class) { bytesStr += "0x" + Long.toHexString((Long) entry.getValue()); } else { int b[] = (int[]) entry.getValue(); for (int x = 0; x < b.length; x++) { bytesStr += "0x" + Long.toHexString(b[x]) + " "; } } v.add(bytesStr); model.addRow(v); } // end header // section model = (DefaultTableModel) jELFSectionTable.getModel(); while (model.getRowCount() > 0) { model.removeRow(0); } int sectionNo = 0; while (map.get("section" + sectionNo) != null) { entries = ((HashMap) map.get("section" + sectionNo)).entrySet(); it = entries.iterator(); Vector<String> v = new Vector<String>(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); String bytesStr = ""; if (entry.getValue().getClass() == Short.class) { jStatusLabel.setText("section " + Long.toHexString((Short) entry.getValue())); bytesStr += "0x" + Long.toHexString((Short) entry.getValue()); } else if (entry.getValue().getClass() == Integer.class) { bytesStr += "0x" + Long.toHexString((Integer) entry.getValue()); } else if (entry.getValue().getClass() == String.class) { bytesStr = (String) entry.getValue(); } else if (entry.getValue().getClass() == Long.class) { bytesStr += "0x" + Long.toHexString((Long) entry.getValue()); } else { int b[] = (int[]) entry.getValue(); for (int x = 0; x < b.length; x++) { bytesStr += "0x" + Long.toHexString(b[x]) + " "; } } v.add(bytesStr); } model.addRow(v); sectionNo++; } // end section // program header model = (DefaultTableModel) jProgramHeaderTable.getModel(); while (model.getRowCount() > 0) { model.removeRow(0); } int programHeaderNo = 0; while (map.get("programHeader" + programHeaderNo) != null) { entries = ((HashMap) map.get("programHeader" + programHeaderNo)).entrySet(); it = entries.iterator(); Vector<String> v = new Vector<String>(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); String bytesStr = ""; if (entry.getValue().getClass() == Short.class) { jStatusLabel.setText("Program header " + Long.toHexString((Short) entry.getValue())); bytesStr += "0x" + Long.toHexString((Short) entry.getValue()); } else if (entry.getValue().getClass() == Integer.class) { bytesStr += "0x" + Long.toHexString((Integer) entry.getValue()); } else if (entry.getValue().getClass() == Long.class) { bytesStr += "0x" + Long.toHexString((Long) entry.getValue()); } else if (entry.getValue().getClass() == String.class) { bytesStr += "0x" + entry.getValue(); } else { int b[] = (int[]) entry.getValue(); for (int x = 0; x < b.length; x++) { bytesStr += "0x" + Long.toHexString(b[x]) + " "; } } v.add(bytesStr); } model.addRow(v); programHeaderNo++; } // program header // symbol table int symbolTableNo = 0; while (map.get("symbolTable" + symbolTableNo) != null) { DefaultTableModel tempTableModel = new DefaultTableModel(null, new String[] { "No.", "st_name", "st_value", "st_size", "st_info", "st_other", "p_st_shndx" }); JTable tempTable = new JTable(); HashMap tempMap = (HashMap) map.get("symbolTable" + symbolTableNo); Vector<LinkedHashMap> v = (Vector<LinkedHashMap>) tempMap.get("vector"); for (int x = 0; x < v.size(); x++) { Vector tempV = new Vector(); jStatusLabel.setText("Symbol table " + x); tempV.add("0x" + Long.toHexString((Integer) v.get(x).get("No."))); tempV.add(v.get(x).get("st_name")); tempV.add("0x" + Long.toHexString((Long) v.get(x).get("st_value"))); tempV.add("0x" + Long.toHexString((Long) v.get(x).get("st_size"))); tempV.add("0x" + Long.toHexString((Integer) v.get(x).get("st_info"))); tempV.add("0x" + Long.toHexString((Integer) v.get(x).get("st_other"))); tempV.add("0x" + Long.toHexString((Integer) v.get(x).get("p_st_shndx"))); tempTableModel.addRow(tempV); } tempTable.setModel(tempTableModel); JScrollPane tempScrollPane = new JScrollPane(); tempScrollPane.setViewportView(tempTable); jTabbedPane4.addTab(tempMap.get("name").toString(), null, tempScrollPane, null); symbolTableNo++; } // end symbol table // note int noteSectionNo = 0; while (map.get("note" + noteSectionNo) != null) { DefaultTableModel tempTableModel = new DefaultTableModel(null, new String[] { "No.", "namesz", "descsz", "type", "name", "desc" }); JTable tempTable = new JTable(); HashMap tempMap = (HashMap) map.get("note" + noteSectionNo); Vector<LinkedHashMap> v = (Vector<LinkedHashMap>) tempMap.get("vector"); for (int x = 0; x < v.size(); x++) { Vector tempV = new Vector(); jStatusLabel.setText("Note " + x); tempV.add("0x" + Long.toHexString((Integer) v.get(x).get("No."))); tempV.add("0x" + Long.toHexString((Long) v.get(x).get("namesz"))); tempV.add("0x" + Long.toHexString((Long) v.get(x).get("descsz"))); tempV.add("0x" + Long.toHexString((Long) v.get(x).get("type"))); tempV.add(v.get(x).get("name")); tempV.add(v.get(x).get("desc")); tempTableModel.addRow(tempV); } tempTable.setModel(tempTableModel); JScrollPane tempScrollPane = new JScrollPane(); tempScrollPane.setViewportView(tempTable); jTabbedPane4.addTab(tempMap.get("name").toString(), null, tempScrollPane, null); noteSectionNo++; } // end note } try { jStatusLabel.setText("running objdump -DS"); Process process = Runtime.getRuntime().exec("objdump -DS " + elfFile.getAbsolutePath()); InputStream input = process.getInputStream(); String str = ""; byte b[] = new byte[102400]; int len; while ((len = input.read(b)) > 0) { str += new String(b, 0, len); } jEditorPane1.setText(str); jStatusLabel.setText("readelf -r"); process = Runtime.getRuntime().exec("readelf -r " + elfFile.getAbsolutePath()); input = process.getInputStream(); str = ""; b = new byte[102400]; while ((len = input.read(b)) > 0) { str += new String(b, 0, len); } jSearchRelPltEditorPane.setText(str); jStatusLabel.setText("readelf -d"); process = Runtime.getRuntime().exec("readelf -d " + elfFile.getAbsolutePath()); input = process.getInputStream(); str = ""; b = new byte[102400]; while ((len = input.read(b)) > 0) { str += new String(b, 0, len); } input.close(); jSearchDynamicEditorPane.setText(str); jStatusLabel.setText(""); } catch (IOException e) { e.printStackTrace(); } // end symbol table }
From source file:com.peterbochs.PeterBochsDebugger.java
private void jPreviousMemoryButtonActionPerformed(ActionEvent evt) { try {//from w w w . j a va2 s .co m long address = CommonLib.string2long(jMemoryAddressComboBox.getSelectedItem().toString()); if (address >= 0xc8) { jMemoryAddressComboBox.setSelectedItem("0x" + Long.toHexString(address - 0xc8)); } else { jMemoryAddressComboBox.setSelectedItem("0x0"); } jGOMemoryButtonActionPerformed(null); } catch (Exception ex) { if (Global.debug) { ex.printStackTrace(); } } }
From source file:com.peterbochs.PeterBochsDebugger.java
private void jNextMemoryPageButtonActionPerformed(ActionEvent evt) { try {/* ww w . ja va 2 s .co m*/ long address = CommonLib.string2long(jMemoryAddressComboBox.getSelectedItem().toString()); jMemoryAddressComboBox.setSelectedItem("0x" + Long.toHexString(address + 0xc8)); jGOMemoryButtonActionPerformed(null); } catch (Exception ex) { if (Global.debug) { ex.printStackTrace(); } } }