導航:首頁 > 源碼編譯 > 374的源碼

374的源碼

發布時間:2025-07-14 21:34:02

『壹』 如何在centos6.5的kvm虛擬機中永久激活windows2008

一、激活原理
目前激活Windows7/Windows2008的各種方法充斥互聯網,但公認比較完美的激活方式是將品牌機(例如DELL、LENOVO等)的SLIC信息表刷寫進需要安裝Windows系統的計算機BIOS中,將該計算機「模擬」為品牌機,然後安裝微軟的OEM版Windows7/Windows2008並自動激活。
相信喜歡搞破解的童鞋都應該知道其中的奧秘,微軟和PC廠商為了減輕對於操作系統的激活負荷,對大多數品牌機實行了有別於聯網激活的「SLIC激活機制」:當Windows操作系統啟動時,就會自行讀取本機BIOS中的SLIC信息表,以及操作系統的「OEM密鑰」和「OEM證書」,如果三者完全吻合、驗證一致,Windows7/Windows2008系統就會被識別為自動激活的OEM版本。
筆者研究發現,Windows2012(注意不是Windows2012_R2,下同)與以往激活Windows7/Windows2008的方式類似,依然可以採用刷寫BIOS中SLIC信息表安裝OEM版系統的方式實現永久激活,只不過激活Windows2012需要SLIC2.2版,經測試SLIC2.2能夠向下兼容SLIC2.1/2.0。
眾所周知,虛擬機軟體也是有BIOS的,目前市場上常見的虛擬機軟體,如VMware、Xen、Kvm等均通過軟體模擬的方式「模擬」硬體BIOS。既然可以採用刷寫計算機硬體BIOS的方式實現永久激活,那麼如果能夠將SLIC2.2信息表通過軟體再編譯方式「灌入」虛擬機的BIOS中,然後再安裝Windows2012的OEM版本,不就可以與刷寫BIOS硬體實現自動激活「異曲同工」了嗎?
二、核心問題
激活原理已經非常明確了,現在的關鍵問題是如何重新編譯Linux虛擬機的問題了,這涉及Linux內核的重新編譯,一些菜鳥可能望而生畏,盡管編譯 Linux全部內核確實需要較高的技術水平,但重新編譯Linux的BIOS難度並不高,初學者也可以輕松實現。本文以Linux的常見版本CentOs6.5為例,詳細講解重新編譯KVM虛擬機BIOS的步驟。本文的方法同樣適用Ubuntu等 Linux版本。
CentOs6.5虛擬機KVM的BIOS實際是一個二進制的可執行文件,默認安裝路徑為/usr/share/seabios/bios.bin。筆者研究發現,KVM虛擬機BIOS使用的是開源軟體 seabios,該軟體的源代碼可以在互聯網上找到,開源組織也製作了為seabios軟體增加相應SLIC信息表的補丁包,下載seabios的源代碼並打上該補丁包,然後重新編譯並替換Linux默認的bios.bin文件,就可以將虛擬機「模擬」為品牌機,然後自動激活OEM版的Windows2012系統了,這種激活方式是永久激活,激活後的Windows2012可以打上微軟的後續補丁且絕對不會被封殺。
三、詳細步驟
1.獲取SLIC2.2信息表。當前SLIC2.1的信息表網上很容易找到,SLIC2.2的信息表不多,比較容易找到的是DELL 版的SLIC2.2信息表。當然也可以找一台預裝了Windows2012的品牌機(市面上比較常見的是DELL的機器),然後使用SLIC_Toolkit3.2工具導出該機器的SLIC表。SLIC2.1/2.2表為二進制文件,長度均為374位元組(這一點一定要注意)。
2.安裝CentOs6.5_x64版操作系統。記得把gcc安裝上,然後將上一步已經獲取的SLIC2.2表拷貝在/ opt目錄中(假定文件名稱為DELL_SLIC2.2.BIN)。
3.在root用戶下安裝git,、iasl及所有依賴包。
#yum install git
#yum install iasl //這是必須安裝的包
4.使用git獲取sealic項目的源碼
# mkdir bios //目錄可以自己隨便建
#cd bios
#git clone git://github.com/ghuntley/seaslic //獲取源代碼
#ls -ls
Seaslic //用git軟體獲取源代碼後會有多出一個目錄
# cd seaslic
#ls
patch.sh README.markdown seabios.patch seabios.submole
//該目錄共包含三個文件和一個子目錄,其中子目錄seabios.submole需要刪除掉,用我們後面下載的內容重建。
#rm -rf seabios.submole
5.從地址code.coreboot.org/p/seabios下載的SeaBios的源碼並解壓。注意源代碼一定要下載1.7.3.2版本的,這一點也很關鍵,千萬不能搞錯了。
#tar xzvf seabios-1.7.3.2.tar.gz 解壓在/bios目錄下。
6.重建seabios.submole
#cd /bios
# cp –r seabios-1.7.3.2 seaslic/seabios.submole
# cd seaslic
# ls
patch.sh README.markdown seabios.patch seabios.submole
進入我們重建的seabios.submole目錄,可以發現有bios的源代碼存在:
# cd seabios.submole
# ls
COPYING COPYING.LESSER Makefile README README.CSM src TODO tools vgasrc
# cd src
可以發現seabios的源代碼,我們需要重新編譯這些源代碼,生成新的bios.bin 文件,用於替代CentOs6.5系統自帶的bios.bin。
7.查看/bios/seaslic /patch.sh文件。這是一個批處理文件,只有2行有用。用Linux的命令方式執行,為防止輸入錯誤,最好從patch.sh中復制粘貼後在root用戶下執行:
①將SLIC2.2文件轉換為C語言包含文件格式(acpi-slic.hex)的命令:
#xxd -i /opt/DELL_SLIC2.2.BIN | grep -v -E "len "| sed 's/unsigned char.*/static char SLIC[] = {/' > seabios.submole/src/acpi-slic.hex
說明:這條命令執行後將會把SLIC2.2表(即/opt/DELL_SLIC2.2.BIN文件)轉換為C語言包含文件格式(文件名../src/acpi-slic.hex),並以數組形式存在。這一步非常非常關鍵,轉換完成的acpi-slic.hex文件應為2333位元組。如果本條命令執行不成功的話,編譯出來的bios.bin文件不會包含SLIC2.2信息,也就無法實現激活了。
②為acpi.c 文件打補丁的命令:
# cd /bios/seaslic /seabios.submole
#patch -p1 < ../seabios.patch

說明:這條語句執行後將給../ src/acpi.c 文件打上補丁,執行後系統將會提示:
Hunk #1 succeeded at 20 with fuzz 2 (offset -194 lines).
Hunk #2 succeeded at 37 with fuzz 2 (offset -194 lines).
Hunk #3 succeeded at 631 with fuzz 2 (offset -205 lines).
注意:至此我們的准備工作已經全部完成了,下面將重新編譯生成新的bios了。
8.重新編譯生成bios.bin文件
# cd /bios/seaslic /seabios.submole
#make //編譯需要花幾十秒鍾吧,應提示無錯誤、無警告,否則可能需要仔細檢查以上步驟。
查看..seabios.submole/out/bios.bin
看到最後生成的結果了吧,會在..seabios.submole/out/中多出一個bios.bin文件,這個文件就是我們重新編譯生成的虛擬機的bios,將用來替換KVM的系統原有的bios.bin文件。
說明:這里編譯生成bios.bin文件包含有DELL品牌機的SLIC2.2,可以激活DELL的Windows2012_OEM版。同理,我們只要找到其他品牌機的SLIC2.2信息表,重新編譯後就可以安裝激活其他品牌機的OEM版Windows7/2008/2012(SLIC2.1隻能支持Vista/Win7/2008,不支持 Win2012;SLIC2.2則支持XP/Vista以及Win2008/2012並兼容SLIC2.1),與刷寫計算機硬體BIOS實現自動激活的方式相比,採用這種方式激活Windows的風險為零,非常適合批量激活虛擬機的Windows2008/Windows2012。
9.替換CentOs6.5系統默認的bios.bin文件
# cp out/bios.bin /usr/share/seabios/bios.bin
#reboot //重新啟動一下宿主機,然後再重新啟動Windows虛擬機,在啟動KVM虛擬機的時候,可以發現虛擬機的bios 已經更新為最新版本了。
10.激活windows2012
至此KVM虛擬機的bios已經重新配置完成,在KVM中啟動WINDOWS客戶機,然後利用SLIC_Toolkit3.2工具檢查SLIC,會發現你的SLIC信息已經獲取成功,如果你安裝的是OEM版本的 Win2008/2012的話,無需輸入key和證書就能自動激活。你可以從網上網路如下OEM鏡像(我已試驗過可自動激活):
(1)Lenovo的OEM版Windows2008_R2鏡像:
Windows_Server-2008_R2_ENT_OEM.iso或者
Win_Server_08_R2_SP1_33in1.iso
(2)Dell的OEM版Windows2012鏡像:
Ser2012_ST_DA_OEM.iso
(3)如果你手上暫時沒有OEM版的話,也不要緊,可以用slmgr命令手工增加證書及OEM序列號也可以激活Windows2008/20012。直接用管理員身份進入命令行模式:
①slmgr -ilc DELL2.2.XRM-MS //這里找到的是DELL計算機的Windows2012版OEM證書。
②接下來就是寫入注冊號了:
slmgr -ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
說明:下面是我從網上找到的 OEM版序列號(經測試可以激活):
Windows Server 2012 Standard DELL OEM KEY
2G9DG-XKFR6-VG8D3-DN9T9-CDG98
Windows Server 2012 Datacenter DELL OEM KEY
2BVGY-TNRWK-6927W-866R9-66J3H
Windows Server 2008 R2 Standard DELL OEM KEY
D7TCH-6P8JP-KRG4P-VJKYY-P9GFF
Windows Server 2008 R2 Enterprise DELL OEM KEY
BKCJJ-J6G9Y-4P7YF-8D4J7-7TCWD
③執行slmgr –dlv //顯示全部激活信息
④執行slmgr -xpr //顯示Windows2008/2012已經永久激活。

『貳』 如何實現android藍牙自動配對連接

望你踩吶我的回答

下面是自動配對的代碼
Mainfest,xml注冊
<receiver android:name="." >
<intent-filter>
<action android:name="android.bluetooth.device.action.PAIRING_REQUEST" />
</intent-filter>
</receiver>

自己在收到廣播時處理並將預先輸入的密碼設置進去

public class extends BroadcastReceiver
{

String strPsw = "0";

@Override
public void onReceive(Context context, Intent intent)
{
// TODO Auto-generated method stub
if (intent.getAction().equals(
"android.bluetooth.device.action.PAIRING_REQUEST"))
{
BluetoothDevice btDevice = intent
.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);

// byte[] pinBytes = BluetoothDevice.convertPinToBytes("1234");
// device.setPin(pinBytes);
Log.i("tag11111", "ddd");
try
{
ClsUtils.setPin(btDevice.getClass(), btDevice, strPsw); // 手機和藍牙採集器配對
ClsUtils.createBond(btDevice.getClass(), btDevice);
ClsUtils.cancelPairingUserInput(btDevice.getClass(), btDevice);
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}
}

<b>/************************************ 藍牙配對函數 * **************/
import java.lang.reflect.Field;
import java.lang.reflect.Method;

import android.bluetooth.BluetoothDevice;
import android.util.Log;
public class ClsUtils
{

/**
* 與設備配對 參考源碼:platform/packages/apps/Settings.git
* /Settings/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
*/
static public boolean createBond(Class btClass, BluetoothDevice btDevice)
throws Exception
{
Method createBondMethod = btClass.getMethod("createBond");
Boolean returnValue = (Boolean) createBondMethod.invoke(btDevice);
return returnValue.booleanValue();
}

/**
* 與設備解除配對 參考源碼:platform/packages/apps/Settings.git
* /Settings/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
*/
static public boolean removeBond(Class btClass, BluetoothDevice btDevice)
throws Exception
{
Method removeBondMethod = btClass.getMethod("removeBond");
Boolean returnValue = (Boolean) removeBondMethod.invoke(btDevice);
return returnValue.booleanValue();
}

static public boolean setPin(Class btClass, BluetoothDevice btDevice,
String str) throws Exception
{
try
{
Method removeBondMethod = btClass.getDeclaredMethod("setPin",
new Class[]
{byte[].class});
Boolean returnValue = (Boolean) removeBondMethod.invoke(btDevice,
new Object[]
{str.getBytes()});
Log.e("returnValue", "" + returnValue);
}
catch (SecurityException e)
{
// throw new RuntimeException(e.getMessage());
e.printStackTrace();
}
catch (IllegalArgumentException e)
{
// throw new RuntimeException(e.getMessage());
e.printStackTrace();
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;

}

// 取消用戶輸入
static public boolean cancelPairingUserInput(Class btClass,
BluetoothDevice device)

throws Exception
{
Method createBondMethod = btClass.getMethod("cancelPairingUserInput");
// cancelBondProcess()
Boolean returnValue = (Boolean) createBondMethod.invoke(device);
return returnValue.booleanValue();
}

// 取消配對
static public boolean cancelBondProcess(Class btClass,
BluetoothDevice device)

throws Exception
{
Method createBondMethod = btClass.getMethod("cancelBondProcess");
Boolean returnValue = (Boolean) createBondMethod.invoke(device);
return returnValue.booleanValue();
}

/**
*
* @param clsShow
*/
static public void printAllInform(Class clsShow)
{
try
{
// 取得所有方法
Method[] hideMethod = clsShow.getMethods();
int i = 0;
for (; i < hideMethod.length; i++)
{
Log.e("method name", hideMethod[i].getName() + ";and the i is:"
+ i);
}
// 取得所有常量
Field[] allFields = clsShow.getFields();
for (i = 0; i < allFields.length; i++)
{
Log.e("Field name", allFields[i].getName());
}
}
catch (SecurityException e)
{
// throw new RuntimeException(e.getMessage());
e.printStackTrace();
}
catch (IllegalArgumentException e)
{
// throw new RuntimeException(e.getMessage());
e.printStackTrace();
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}</b>

執行時直接使用:

<b>public static boolean pair(String strAddr, String strPsw)
{
boolean result = false;
BluetoothAdapter bluetoothAdapter = BluetoothAdapter
.getDefaultAdapter();

bluetoothAdapter.cancelDiscovery();

if (!bluetoothAdapter.isEnabled())
{
bluetoothAdapter.enable();
}

if (!BluetoothAdapter.checkBluetoothAddress(strAddr))
{ // 檢查藍牙地址是否有效

Log.d("mylog", "devAdd un effient!");
}

BluetoothDevice device = bluetoothAdapter.getRemoteDevice(strAddr);

if (device.getBondState() != BluetoothDevice.BOND_BONDED)
{
try
{
Log.d("mylog", "NOT BOND_BONDED");
ClsUtils.setPin(device.getClass(), device, strPsw); // 手機和藍牙採集器配對
ClsUtils.createBond(device.getClass(), device);
remoteDevice = device; // 配對完畢就把這個設備對象傳給全局的remoteDevice
result = true;
}
catch (Exception e)
{
// TODO Auto-generated catch block

Log.d("mylog", "setPiN failed!");
e.printStackTrace();
} //

}
else
{
Log.d("mylog", "HAS BOND_BONDED");
try
{
ClsUtils.createBond(device.getClass(), device);
ClsUtils.setPin(device.getClass(), device, strPsw); // 手機和藍牙採集器配對
ClsUtils.createBond(device.getClass(), device);
remoteDevice = device; // 如果綁定成功,就直接把這個設備對象傳給全局的remoteDevice
result = true;
}
catch (Exception e)
{
// TODO Auto-generated catch block
Log.d("mylog", "setPiN failed!");
e.printStackTrace();
}
}
return result;
}</b>

『叄』 嚴重: Servlet.service() for servlet jsp threw exception

出現此錯誤一般都是在jsp中使用了輸出流(如輸出圖片驗證碼,文件下載等),
沒有妥善處理好的原因。

具體的原因就是
在tomcat中jsp編譯成servlet之後在函數_jspService(HttpServletRequest request, HttpServletResponse response)的最後
有一段這樣的代碼
finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
}
這里是在釋放在jsp中使用的對象,會調用response.getWriter(),因為這個方法是和
response.getOutputStream()相沖突的!所以會出現以上這個異常。

然後當然是要提出解決的辦法,其實挺簡單的(並不是和某些朋友說的那樣--
將jsp內的所有空格和回車符號所有都刪除掉),

在使用完輸出流以後調用以下兩行代碼即可:
out.clear();
out = pageContext.pushBody();

最後這里是一個輸出彩色驗證碼例子(這樣的例子幾乎隨處可見)
imag.jsp

<%@ page import="java.awt.*,java.awt.image.*,java.util.*,javax.imageio.*" %>
<%@ page import="java.io.OutputStream" %>
<%!
Color getRandColor(int fc,int bc){
Random random = new Random();
if(fc>255) fc=255;
if(bc>255) bc=255;
int r=fc+random.nextInt(bc-fc);
int g=fc+random.nextInt(bc-fc);
int b=fc+random.nextInt(bc-fc);
return new Color(r,g,b);
}
%>
<%
try{
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
int width=60, height=20;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
OutputStream os=response.getOutputStream();
Graphics g = image.getGraphics();
Random random = new Random();
g.setColor(getRandColor(200,250));
g.fillRect(0, 0, width, height);

g.setFont(new Font("Times New Roman",Font.PLAIN,18));
g.setColor(getRandColor(160,200));
for (int i=0;i<155;i++)
{
int x = random.nextInt(width);
int y = random.nextInt(height);
int xl = random.nextInt(12);
int yl = random.nextInt(12);
g.drawLine(x,y,x+xl,y+yl);
}
String sRand="";
for (int j=0;j<4;j++){
String rand=String.valueOf(random.nextInt(10));
sRand+=rand;
g.setColor(new Color(20+random.nextInt(110),20+random.nextInt(110),20+random.nextInt(110)));
g.drawString(rand,13*j+6,16);
}
session.setAttribute("rand",sRand);
g.dispose();

ImageIO.write(image, "JPEG",os);
os.flush();
os.close();
os=null;
response.flushBuffer();
out.clear();
out = pageContext.pushBody();
}
catch(IllegalStateException e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}%>

如有不足之處,歡迎斧正!

2

getOutputStream() has already been called for this response問題的解決
在jsp向頁面輸出圖片的時候,使用response.getOutputStream()會有這樣的提示:java.lang.IllegalStateException:getOutputStream() has already been called for this response,會拋出Exception

原因一:
JSP默認的輸出流為PrintWriter ,即<% %>以外的東西所默認的輸出方式,如果你嘗試在JSP中使用ServletOutputStream就會引起錯誤.要嘛直接改用Servlet輸出(復寫service方法),要嘛刪除除%><%中的任何東西
(包括HTML標簽,空格,回車等東西)應該就可以。
對於這樣的情況應該這樣來解決,刪除%><%之間的所有內容包括空格和換行符,最後也要消除空格和換行符,
最好再加上一句response.reset()。
原因二:

在J2EE的API參考里有這么個:

ServletResponse的getWriter()方法里會拋出這個異常,

IllegalStateException - if the getOutputStream method has already been called
for this response object

而它的getOutputStream()方法里會拋出這個異常.

IllegalStateException - if the getOutputStream method has already been called for this response object

並且兩者的函數申明裡都有這么樣的一句
Either this method or getOutputStream() may be called to write the body, not both.
Either this method or getWriter() may be called to write the body, not both.

以上說明也解釋了為什麼在往頁面中寫入圖片的時候要使用如下循環格式
OutputStream output=response.getOutputStream();
while((len=in.read(b)) >0)
{
output.write(b,0,len);

}
output.flush();
而不是把response.getOutputStream().write()放到循環體內

在頁面中直接寫:
<body bgcolor="#ffffff">
<h1>
<%
response.getOutputStream();
%>
</h1>
</body>
將會出現錯誤消息如下:
java.lang.IllegalStateException: getOutputStream() has already been called for this response
org.apache.catalina.connector.Response.getWriter(Response.java:604)
org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)
org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:125)
org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:118)

閱讀全文

與374的源碼相關的資料

熱點內容
學好單片機可以做什麼東西 瀏覽:220
雲伺服器開放公網帶寬安全么 瀏覽:17
java位元組亂碼 瀏覽:305
榮耀50什麼時候升級安卓12 瀏覽:75
pdf文件怎麼轉成jpg 瀏覽:259
比澤爾壓縮機代理商 瀏覽:629
什麼app能下載多鄰國 瀏覽:234
伺服器藍色什麼意思 瀏覽:226
vb組態軟體源碼 瀏覽:698
加密蚊帳防蚊門簾 瀏覽:828
vs2010多線程編程 瀏覽:214
新股上市指標源碼 瀏覽:699
c語言51單片機教程 瀏覽:554
app中的hd是什麼意思 瀏覽:279
手機什麼解壓器最好 瀏覽:49
什麼是適合自己的app 瀏覽:451
雲伺服器怎麼補漏洞 瀏覽:176
如何看自己的安卓是什麼等級 瀏覽:633
被丁磊挖走的程序員 瀏覽:19
gsk980ta編程 瀏覽:507