大海Online的博客

Looking for Interest

手机游戏 resco bubbles 个人记录 score

手机游戏resco bubbles

游戏共50关 个人记录如下

-------------------------------

(2009-01-27)

1 1.5
2 2.6
3 3.3
4 5.9
5 10.2
6 3.2
7 6.0
8 0.6
9 14.3
10 15.5
11 1.6
12 14.4
13 1.3
14 3.8
15 4.4
16 3.5
17 1.2
18 24.3
19 28.1
20 24.7
21 5.9
22 15.2
23 16.9
24 11.5
25 28.9
26 21.6
27 15.2
28 12.2
29 5.4
30 7.3
31 1:38.2
32 12.8
33 50.0
34 12.1
35 8.2
36 2.3(bug??) --------此处是因软件bug而导致成绩出错
37 1:01.2
38 5.4
39 37.4
40 8.6
41 5.1
42 8.3
43 13.4
44 11.8
45 10.6
46 1.9
47 1:32.0
48 (未通关)
49 (未通关)
50 (未通关)

-----------------------------------------

第二次更新成绩 (20090719)

11.5
22.6
33.3
44.8
58.9
62.8
74.8
80.5
914.1
1014.3
111.6
1211.1
131.3
141.9
154.2
163.5
171.1
1824.3
1927.6
2016.2
215.2
2210.0
2316.9
2411.2
2513.9
2621.6
2715.2
2812.2
295.4
307.3
311:38.2
3212.8
3350.0
3410.1
357.0
3616.9
3749.2
385.2
3937.4
408.6
415.1
428.3
4313.4
4411.8
4510.6
461.9
471:32.0
48--
49--
50--

利用bat反编译jar包生成源码jar包

(这篇文章是从blog.csdn.net/seavers导入的, 最新版本见: http://seavers.iteye.com/blog/1416013,  )

反编译所使用的工具是jad.exe,笔者的测试版本是1.5.8e,压缩与解压缩使用的是WinRAR

jad.exe 可反编译一个class文件为java文件,笔者的BAT可通过此工具将一个jar包反编译成一个完整的源码jar包,同时生成的目录也可以在eclipse中使用

jad.exe 官方网站 : http://www.kpdus.com/jad.html (英文的)

BAT脚本见后

安装方法如下:

复制粘贴后面的文本为一个BAT,然后与jad.exe放在同一个目录即可(WinRAR需正确安装)

使用方法如下: (有3种使用方法, 使用其中任意一种均可,结果是相同的)

1. 双击BAT,提示输入需反编译的jar包,请输入完整的jar路径

2. 直接将 jar 包拖放在bat上

3.右键点击jar包,选择打开方式,然后选择使用该BAT来执行

运行后的结果如下:

在jar包的同一目录下, 将会生成一个目录,一个jar,目录下有两个子目录,一个目录存放解压缩后的所有class,一个目录存放反编译后的java文件,jar包是用源码压缩生成的

几点说明:

1. 工具中使用的WinRAR是自动识别安装路径的,请正确安装WinRAR

2. 工具使用的jad.exe,须与BAT放在同一目录,或者放在PATH可搜索到的位置

3. jar包中非class文件,也会完整拷贝在源码目录下,方便生成源码工程

4. 生成的目录名与原 jar 包同名, 生成的源码 jar 包的文件名是在原名称中加入-src而生成, 如原 jar 包为 jdbc.jar, 则生成的目录名为 jdbc, 而生成的源码jar 包名则为 jdbc-src.jar

5. eclipse使用方法1, 将BAT生成的目录放在workspace中,然后创建同名工程

6. eclipse使用方法2,在 eclipse 中创建同名工程,使用src为源文件目录,bin为class文件目录,然后将BAT生成的目录拷贝在eclipse的workspace中

 

该BAT为 blog.csdn.net/seavers 原创, BAT源码仅供个人学习,使用,研究,未经本人同意,不可用于商业用途

 

 

BAT源码如下: (请直接拷贝在BAT文件中)

 

::作者:seavers
::
blog:blog.csdn.net/seavers(在此blog上首次发布该bat)
::
功能:反编译jar包,生成对应的源码jar包,详细说明方档请登陆我的blog


::打开/关闭命令行显示
@echoOFF

::::::::::::::::::::::::::::解析并设置变量::::::::::::::::::


::查找jad文件的路径,这里取的jad.exe,表示从PATH中查找,如果想手工指定,需在这里修改
setJAD_PATH=jad.exe

::设置解压出的class文件存放的位置(相对路径)
setCLASS_PATH=bin

::设置反编译后的java文件存放的位置(相对路径)
setJAVA_PATH=src

::检查JAD文件是否存在bat所在目录下,
ifexist"%~dp0jad.exe"setJAD_PATH=%~dp0jad.exe

::判断参数个数,如果没有文件参数,则报错,这里也可以使用%~f1,也可以用%1,没有关系,之后要去掉引号
if""%1""==""""(set/PJAR_PATH=请输入要反编译的JAR包的路径...)else(setJAR_PATH=%~f1)
if'%JAR_PATH:~0,1%%JAR_PATH:~0,1%'=='""'setJAR_PATH=%JAR_PATH:~1,-1%

::获取源代码存放的路径,这里取JAR包所在路径,然后去掉".jar"作为文件夹路径,这里的LOCATION不能带引号,因为下面还要追加字符)
if""%2""==""""(setLOCATION=%JAR_PATH:~0,-4%)else(setLOCATION=%~f2)

::::::::::::::::::::开始执行程序:::::::::::::::::::::::::::::::

::获取WinRAR.exe的路径,设置在临时变量rarpath中
for/f"usebackqdelims="%%iin(`ftypeWinRAR`)dosetRARPATH=%%i

::对rarpath进行解析,去掉前面7个节符,去掉后面5个字符,得到WinRAR执行路径
::
路径大致是这样的形式Winrar="C:/ProgramFiles/WinRAR/WinRAR.exe""%1"
setRAREXE=%RARPATH:~7,-5%

::调用WinRAR命令,解压文件到指定目录的bin目录下
%RAREXE%x"%JAR_PATH%""%LOCATION%/%CLASS_PATH%/"

::遍历整个bin目录,取所有class文件,调用jad.exe反编译出源码,非class的拷贝到src目录下
::
打开变量延迟功能
setlocalEnableDelayedExpansion
for/r"%LOCATION%/bin"%%iin(*.*)doif'%%~xi'=='.class'("%JAD_PATH%"-o-r-sjava-ff-b-nonlb-space-t-8-d"%LOCATION%/%JAVA_PATH%""%%~si")else(setTEMP_PATH=%%i&echof|xcopy"%%i""!TEMP_PATH:%LOCATION%/bin=%LOCATION%/src!")
endlocalEnableDelayedExpansion

::将产生的java文件压缩成源码文件
%RAREXE%a-ep1-r"%LOCATION%-src.zip""%LOCATION%/%JAVA_PATH%/*.*"


::::::::::::::::::程序结束,显示运行结果::::::::::::::::::::::
echo*********************************************
echo程序运行结束
echo解析的JAR包的路径为%JAR_PATH%
echo解压缩工具WinRAR.exe的路径为%RAREXE%
echo反编译工具JAD.exe的路径为%JAD_PATH%
echo解析后的文件的根路径为%LOCATION%
echo解析后的class文件存放在%LOCATION%/%CLASS_PATH%
echo解析后的java文件存放在%LOCATION%/%JAVA_PATH%
echo压缩后的java文件存放在%LOCATION%-src.zip
echo*********************************************
pause


 

 

 

 

 

 

 

 

c3p0.properties .vs. c3p0-config.xml

 

摘自c3p0.jar,方便查看

//c3p0.properties

#
#Thisfileisdetritusfromvarioustestingattempts
#thevaluesbelowmaychange
,andoftendonotrepresent
#reasonablevaluesfortheparameters.
#

#c3p0.testConnectionOnCheckout
=true
#c3p0.testConnectionOnCheckin
=true
#c3p0.minPoolSize
=3
#c3p0.maxPoolSize
=20
#c3p0.checkoutTimeout
=2000
#c3p0.idleConnectionTestPeriod
=5
#c3p0.maxConnectionAge
=10
#c3p0.maxIdleTime
=2
#c3p0.maxIdleTimeExcessConnections
=1
#c3p0.propertyCycle
=1
#c3p0.numHelperThreads
=10
#c3p0.unreturnedConnectionTimeout
=15
#c3p0.debugUnreturnedConnectionStackTraces
=true
#c3p0.maxStatements
=30
#c3p0.maxStatementsPerConnection
=5
#c3p0.maxAdministrativeTaskTime
=3
#c3p0.preferredTestQuery
=SELECT1
#c3p0.preferredTestQuery
=SELECTaFROMemptyyukyukWHEREa=5
#c3p0.preferredTestQuery
=SELECTaFROMtestpbdsWHEREa=5
#c3p0.usesTraditionalReflectiveProxies
=true
#c3p0.automaticTestTable
=PoopyTestTable
#c3p0.acquireIncrement
=4
#c3p0.acquireRetryDelay
=1000
#c3p0.acquireRetryAttempts
=60
#c3p0.connectionTesterClassName
=com.mchange.v2.c3p0.test.AlwaysFailConnectionTester
#c3p0.initialPoolSize
=10

c3p0.jdbcUrl
=jdbc:postgresql://localhost/c3p0-test
c3p0.driverClass
=org.postgresql.Driver
c3p0.user
=swaldman
c3p0.password
=test
#c3p0.user
=poop
#c3p0.password
=scoop

#com.mchange.v2.log.MLog
=com.mchange.v2.log.log4j.Log4jMLog
#com.mchange.v2.log.MLog
=com.mchange.v2.log.jdk14logging.Jdk14MLog
#com.mchange.v2.log.MLog
=com.mchange.v2.log.FallbackMLog
#com.mchange.v2.log.NameTransformer
=com.mchange.v2.log.PackageNames
#com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL
=ALL


#com.mchange.v2.c3p0.VMID
=poop

 

 

//c3p0-config.xml

<c3p0-config>
<default-config>
<!--<propertyname="automaticTestTable">con_test</property>-->
<!--<propertyname="checkoutTimeout">30000</property>-->
<!--<propertyname="idleConnectionTestPeriod">30</property>-->
<!--<propertyname="initialPoolSize">10</property>-->
<!--<propertyname="maxIdleTime">30</property>-->
<!--<propertyname="maxIdleTimeExcessConnections">10</property>-->
<!--<propertyname="maxConnectionAge">60</property>-->
<!--<propertyname="propertyCycle">1</property>-->
<!--<propertyname="maxPoolSize">25</property>-->
<!--<propertyname="minPoolSize">5</property>-->
<!--<propertyname="maxStatements">0</property>-->
<!--<propertyname="maxStatementsPerConnection">5</property>-->
<!--<propertyname="maxAdministrativeTaskTime">4</property>-->
<!--<propertyname="connectionCustomizerClassName">com.mchange.v2.c3p0.test.TestConnectionCustomizer</property>-->
<!--<propertyname="unreturnedConnectionTimeout">15</property>-->
<!--<propertyname="debugUnreturnedConnectionStackTraces">true</property>-->

<!--
<user-overridesuser="swaldman">
<propertyname="debugUnreturnedConnectionStackTraces">true</property>
</user-overrides>
-->

</default-config>

<!--
<named-configname="dumbTestConfig">
<propertyname="maxStatements">200</property>
<propertyname="jdbcUrl">jdbc:test</property>
<user-overridesuser="poop">
<propertyname="maxStatements">300</property>
</user-overrides>
</named-config>
-->

</c3p0-config>


 

 

//解析properties

 

/*
*Distributedaspartofc3p0v.0.9.1.2
*
*Copyright(C)2005MachineryForChange,Inc.
*
*Author:SteveWaldman<swaldman@mchange.com>
*
*Thislibraryisfreesoftware;youcanredistributeitand/ormodify
*itunderthetermsoftheGNULesserGeneralPublicLicenseversion2.1,as
*publishedbytheFreeSoftwareFoundation.
*
*Thissoftwareisdistributedinthehopethatitwillbeuseful,
*butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof
*MERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.Seethe
*GNULesserGeneralPublicLicenseformoredetails.
*
*YoushouldhavereceivedacopyoftheGNULesserGeneralPublicLicense
*alongwiththissoftware;seethefileLICENSE.Ifnot,writetothe
*FreeSoftwareFoundation,Inc.,59TemplePlace,Suite330,
*Boston,MA02111-1307,USA.
*/



packagecom.mchange.v2.c3p0.cfg;

importjava.io.*;
importjava.lang.reflect.*;
importjava.util.*;
importcom.mchange.v2.cfg.*;
importcom.mchange.v2.log.*;
importcom.mchange.v2.c3p0.impl.*;

publicfinalclassC3P0ConfigUtils
{
publicfinalstaticStringPROPS_FILE_RSRC_PATH="/c3p0.properties";
publicfinalstaticStringPROPS_FILE_PROP_PFX="c3p0.";
publicfinalstaticintPROPS_FILE_PROP_PFX_LEN=5;

privatefinalstaticString[]MISSPELL_PFXS={"/c3pO","/c3po","/C3P0","/C3PO"};

finalstaticMLoggerlogger=MLog.getLogger(C3P0ConfigUtils.class);

static
{
if(logger.isLoggable(MLevel.WARNING)&&C3P0ConfigUtils.class.getResource(PROPS_FILE_RSRC_PATH)==null)
{
//warnonamisspelling...itsanuglywaytodothis,butsinceresourcesarenotlistable...
for(inti=0;i<MISSPELL_PFXS.length;++i)
{
Stringtest
=MISSPELL_PFXS[i]+".properties";
if(C3P0ConfigUtils.class.getResource(MISSPELL_PFXS[i]+".properties")!=null)
{
logger.warning(
"POSSIBLYMISSPELLEDc3p0.propertiesCONFIGRESOURCEFOUND."+
"Pleaseensurethefilenameisc3p0.properties,alllowercase,"+
"withthedigit0(NOTtheletterO)inc3p0.Itshouldbeplaced"+
"inthetoplevelofc3p0'seffectiveclasspath.");
break;
}

}

}

}


publicstaticHashMapextractHardcodedC3P0Defaults(booleanstringify)
{
HashMapout
=newHashMap();

try
{
Method[]methods
=C3P0Defaults.class.getMethods();
for(inti=0,len=methods.length;i<len;++i)
{
Methodm
=methods[i];
intmods=m.getModifiers();
if((mods&Modifier.PUBLIC)!=0&&(mods&Modifier.STATIC)!=0&&m.getParameterTypes().length==0)
{
if(stringify)
{
Objectval
=m.invoke(null,null);
if(val!=null)
out.put(m.getName(),String.valueOf(val));
}

else
out.put(m.getName(),m.invoke(
null,null));
}

}

}

catch(Exceptione)
{
logger.log(MLevel.WARNING,
"Failedtoextracthardcodeddefaultconfig!?",e);
}


returnout;
}


publicstaticHashMapextractHardcodedC3P0Defaults()
{returnextractHardcodedC3P0Defaults(true);}

publicstaticHashMapextractC3P0PropertiesResources()
{
HashMapout
=newHashMap();

//Propertiesprops=findResourceProperties();
//props.putAll(findAllC3P0Properties());

Propertiesprops
=findAllC3P0Properties();
for(Iteratorii=props.keySet().iterator();ii.hasNext();)
{
Stringkey
=(String)ii.next();
Stringval
=(String)props.get(key);
if(key.startsWith(PROPS_FILE_PROP_PFX))
out.put(key.substring(PROPS_FILE_PROP_PFX_LEN).trim(),val.trim());
}


returnout;
}


publicstaticC3P0ConfigconfigFromFlatDefaults(HashMapflatDefaults)
{
NamedScopedefaults
=newNamedScope();
defaults.props.putAll(flatDefaults);

HashMapconfigNamesToNamedScopes
=newHashMap();

returnnewC3P0Config(defaults,configNamesToNamedScopes);
}


publicstaticStringgetPropFileConfigProperty(Stringprop)
{returnMultiPropertiesConfig.readVmConfig().getProperty(prop);}

privatestaticPropertiesfindResourceProperties()
{returnMultiPropertiesConfig.readVmConfig().getPropertiesByResourcePath(PROPS_FILE_RSRC_PATH);}

privatestaticPropertiesfindAllC3P0Properties()
{returnMultiPropertiesConfig.readVmConfig().getPropertiesByPrefix("c3p0");}

staticPropertiesfindAllC3P0SystemProperties()
{
Propertiesout
=newProperties();

SecurityExceptionsampleExc
=null;
try
{
for(Iteratorii=C3P0Defaults.getKnownProperties().iterator();ii.hasNext();)
{
Stringkey
=(String)ii.next();
StringprefixedKey
="c3p0."+key;
Stringvalue
=System.getProperty(prefixedKey);
if(value!=null&&value.trim().length()>0)
out.put(key,value);
}

}

catch(SecurityExceptione)
{sampleExc=e;}

returnout;
}


privateC3P0ConfigUtils()
{}
}


 

 

//解析xml

 

/*
*Distributedaspartofc3p0v.0.9.1.2
*
*Copyright(C)2005MachineryForChange,Inc.
*
*Author:SteveWaldman<swaldman@mchange.com>
*
*Thislibraryisfreesoftware;youcanredistributeitand/ormodify
*itunderthetermsoftheGNULesserGeneralPublicLicenseversion2.1,as
*publishedbytheFreeSoftwareFoundation.
*
*Thissoftwareisdistributedinthehopethatitwillbeuseful,
*butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof
*MERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.Seethe
*GNULesserGeneralPublicLicenseformoredetails.
*
*YoushouldhavereceivedacopyoftheGNULesserGeneralPublicLicense
*alongwiththissoftware;seethefileLICENSE.Ifnot,writetothe
*FreeSoftwareFoundation,Inc.,59TemplePlace,Suite330,
*Boston,MA02111-1307,USA.
*/



packagecom.mchange.v2.c3p0.cfg;

importjava.io.*;
importjava.util.*;
importjavax.xml.parsers.*;
importorg.w3c.dom.*;
importcom.mchange.v2.log.*;

importcom.mchange.v1.xml.DomParseUtils;

publicfinalclassC3P0ConfigXmlUtils
{
publicfinalstaticStringXML_CONFIG_RSRC_PATH="/c3p0-config.xml";

finalstaticMLoggerlogger=MLog.getLogger(C3P0ConfigXmlUtils.class);

publicfinalstaticStringLINESEP;

privatefinalstaticString[]MISSPELL_PFXS={"/c3p0","/c3pO","/c3po","/C3P0","/C3PO"};
privatefinalstaticchar[]MISSPELL_LINES={'-','_'};
privatefinalstaticString[]MISSPELL_CONFIG={"config","CONFIG"};
privatefinalstaticString[]MISSPELL_XML={"xml","XML"};

//itsanuglywaytodothis,butsinceresourcesarenotlistable...
//
//thisisonlyexecutedonce,anddoesabout40tests(fornow)
//shouldIcareaboutthecostininitializationtime?
//
//shouldonlyberunifwe'vecheckedforthecorrectfile,but
//notfoundit
privatefinalstaticvoidwarnCommonXmlConfigResourceMisspellings()
{
if(logger.isLoggable(MLevel.WARNING))
{
for(inta=0,lena=MISSPELL_PFXS.length;a<lena;++a)
{
StringBuffersb
=newStringBuffer(16);
sb.append(MISSPELL_PFXS[a]);
for(intb=0,lenb=MISSPELL_LINES.length;b<lenb;++b)
{
sb.append(MISSPELL_LINES*);
for(intc=0,lenc=MISSPELL_CONFIG.length;c<lenc;++c)
{
sb.append(MISSPELL_CONFIG[c]);
sb.append(
'.');
for(intd=0,lend=MISSPELL_XML.length;d<lend;++d)
{
sb.append(MISSPELL_XML[d]);
Stringtest
=sb.toString();
if(!test.equals(XML_CONFIG_RSRC_PATH))
{
ObjecthopefullyNull
=C3P0ConfigXmlUtils.class.getResource(test);
if(hopefullyNull!=null)
{
logger.warning(
"POSSIBLYMISSPELLEDc3p0-conf.xmlRESOURCEFOUND."+
"Pleaseensurethefilenameisc3p0-config.xml,alllowercase,"+
"withthedigit0(NOTtheletterO)inc3p0.Itshouldbeplaced"+
"inthetoplevelofc3p0'seffectiveclasspath.");
return;
}

}

}

}


}

}

}

}


static
{
Stringls;

try
{ls=System.getProperty("line.separator","");}
catch(Exceptione)
{ls="";}

LINESEP
=ls;

}


publicstaticC3P0ConfigextractXmlConfigFromDefaultResource()throwsException
{
InputStreamis
=null;

try
{
is
=C3P0ConfigUtils.class.getResourceAsStream(XML_CONFIG_RSRC_PATH);
if(is==null)
{
warnCommonXmlConfigResourceMisspellings();
returnnull;
}

else
returnextractXmlConfigFromInputStream(is);
}

finally
{
try{if(is!=null)is.close();}
catch(Exceptione)
{
if(logger.isLoggable(MLevel.FINE))
logger.log(MLevel.FINE,
"ExceptiononresourceInputStreamclose.",e);
}

}

}


publicstaticC3P0ConfigextractXmlConfigFromInputStream(InputStreamis)throwsException
{
DocumentBuilderFactoryfact
=DocumentBuilderFactory.newInstance();
DocumentBuilderdb
=fact.newDocumentBuilder();
Documentdoc
=db.parse(is);

returnextractConfigFromXmlDoc(doc);
}


publicstaticC3P0ConfigextractConfigFromXmlDoc(Documentdoc)throwsException
{
ElementdocElem
=doc.getDocumentElement();
if(docElem.getTagName().equals("c3p0-config"))
{
NamedScopedefaults;
HashMapconfigNamesToNamedScopes
=newHashMap();

ElementdefaultConfigElem
=DomParseUtils.uniqueChild(docElem,"default-config");
if(defaultConfigElem!=null)
defaults
=extractNamedScopeFromLevel(defaultConfigElem);
else
defaults
=newNamedScope();
NodeListnl
=DomParseUtils.immediateChildElementsByTagName(docElem,"named-config");
for(inti=0,len=nl.getLength();i<len;++i)
{
ElementnamedConfigElem
=(Element)nl.item(i);
StringconfigName
=namedConfigElem.getAttribute("name");
if(configName!=null&&configName.length()>0)
{
NamedScopenamedConfig
=extractNamedScopeFromLevel(namedConfigElem);
configNamesToNamedScopes.put(configName,namedConfig);
}

else
logger.warning(
"ConfigurationXMLcontainednamed-configelementwithoutnameattribute:"+namedConfigElem);
}

returnnewC3P0Config(defaults,configNamesToNamedScopes);
}

else
thrownewException("Rootelementofc3p0configxmlshouldbe'c3p0-config',not'"+docElem.getTagName()+"'.");
}


privatestaticNamedScopeextractNamedScopeFromLevel(Elementelem)
{
HashMapprops
=extractPropertiesFromLevel(elem);
HashMapuserNamesToOverrides
=newHashMap();

NodeListnl
=DomParseUtils.immediateChildElementsByTagName(elem,"user-overrides");
for(inti=0,len=nl.getLength();i<len;++i)
{
ElementperUserConfigElem
=(Element)nl.item(i);
StringuserName
=perUserConfigElem.getAttribute("user");
if(userName!=null&&userName.length()>0)
{
HashMapuserProps
=extractPropertiesFromLevel(perUserConfigElem);
userNamesToOverrides.put(userName,userProps);
}

else
logger.warning(
"ConfigurationXMLcontaineduser-overrideselementwithoutuserattribute:"+LINESEP+perUserConfigElem);
}


returnnewNamedScope(props,userNamesToOverrides);
}


privatestaticHashMapextractPropertiesFromLevel(Elementelem)
{
//System.err.println("extractPropertiesFromLevel()");

HashMapout
=newHashMap();

try
{
NodeListnl
=DomParseUtils.immediateChildElementsByTagName(elem,"property");
intlen=nl.getLength();
for(inti=0;i<len;++i)
{
ElementpropertyElem
=(Element)nl.item(i);
StringpropName
=propertyElem.getAttribute("name");
if(propName!=null&&propName.length()>0)
{
StringpropVal
=DomParseUtils.allTextFromElement(propertyElem,true);
out.put(propName,propVal);
//System.err.println(propName+"->"+propVal);
}

else
logger.warning(
"ConfigurationXMLcontainedpropertyelementwithoutnameattribute:"+LINESEP+propertyElem);
}

}

catch(Exceptione)
{
logger.log(MLevel.WARNING,
"AnexceptionoccurredwhilereadingconfigXML."+
"Someconfigurationinformationhasprobablybeenignored.",
e);
}


returnout;
}


privateC3P0ConfigXmlUtils()
{}
}


 

 

/*
*Distributedaspartofc3p0v.0.9.1.2
*
*Copyright(C)2005MachineryForChange,Inc.
*
*Author:SteveWaldman<swaldman@mchange.com>
*
*Thislibraryisfreesoftware;youcanredistributeitand/ormodify
*itunderthetermsoftheGNULesserGeneralPublicLicenseversion2.1,as
*publishedbytheFreeSoftwareFoundation.
*
*Thissoftwareisdistributedinthehopethatitwillbeuseful,
*butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof
*MERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.Seethe
*GNULesserGeneralPublicLicenseformoredetails.
*
*YoushouldhavereceivedacopyoftheGNULesserGeneralPublicLicense
*alongwiththissoftware;seethefileLICENSE.Ifnot,writetothe
*FreeSoftwareFoundation,Inc.,59TemplePlace,Suite330,
*Boston,MA02111-1307,USA.
*/



packagecom.mchange.v1.xml;

importjava.util.*;
importorg.xml.sax.*;
importorg.w3c.dom.*;
importcom.mchange.v1.util.DebugUtils;

publicfinalclassDomParseUtils
{
finalstaticbooleanDEBUG=true;

/**
*
@returnnullifchilddoesn'texist.
*/

publicstaticStringallTextFromUniqueChild(Elementelem,StringchildTagName)
throwsDOMException
{returnallTextFromUniqueChild(elem,childTagName,false);}

/**
*
@returnnullifchilddoesn'texist.
*/

publicstaticStringallTextFromUniqueChild(Elementelem,StringchildTagName,booleantrim)
throwsDOMException
{
ElementuniqueChild
=uniqueChildByTagName(elem,childTagName);
if(uniqueChild==null)
returnnull;
else
returnDomParseUtils.allTextFromElement(uniqueChild,trim);
}


publicstaticElementuniqueChild(Elementelem,StringchildTagName)throwsDOMException
{returnuniqueChildByTagName(elem,childTagName);}

/**
*
@deprecateduseuniqueChild(Elementelem,StringchildTagName)
*/

publicstaticElementuniqueChildByTagName(Elementelem,StringchildTagName)throwsDOMException
{
NodeListnl
=elem.getElementsByTagName(childTagName);
intlen=nl.getLength();
if(DEBUG)
DebugUtils.myAssert(len
<=1,
"Thereismorethanone("+len+")childwithtagname:"+
childTagName
+"!!!");
return(len==1?(Element)nl.item(0):null);
}


publicstaticStringallText(Elementelem)throwsDOMException
{returnallTextFromElement(elem);}

publicstaticStringallText(Elementelem,booleantrim)throwsDOMException
{returnallTextFromElement(elem,trim);}

/**@deprecateduseallText(Elementelem)*/
publicstaticStringallTextFromElement(Elementelem)throwsDOMException
{returnallTextFromElement(elem,false);}

/**@deprecateduseallText(Elementelem,booleantrim)*/
publicstaticStringallTextFromElement(Elementelem,booleantrim)throwsDOMException
{
StringBuffertextBuf
=newStringBuffer();
NodeListnl
=elem.getChildNodes();
for(intj=0,len=nl.getLength();j<len;++j)
{
Nodenode
=nl.item(j);
if(nodeinstanceofText)//includesTextandCDATA!
textBuf.append(node.getNodeValue());
}

Stringout
=textBuf.toString();
return(trim?out.trim():out);
}


publicstaticString[]allTextFromImmediateChildElements(Elementparent,StringtagName)
throwsDOMException
{returnallTextFromImmediateChildElements(parent,tagName,false);}

publicstaticString[]allTextFromImmediateChildElements(Elementparent,StringtagName,booleantrim)
throwsDOMException
{
NodeListnl
=immediateChildElementsByTagName(parent,tagName);
intlen=nl.getLength();
String[]out
=newString[len];
for(inti=0;i<len;++i)
out[i]
=allText((Element)nl.item(i),trim);
returnout;
}



publicstaticNodeListimmediateChildElementsByTagName(Elementparent,StringtagName)
throwsDOMException
{returngetImmediateChildElementsByTagName(parent,tagName);}

/**
*
@deprecateduseimmediateChildrenByTagName(Elementparent,StringtagName)
*/

publicstaticNodeListgetImmediateChildElementsByTagName(Elementparent,StringtagName)
throwsDOMException
{
finalListnodes=newArrayList();
for(Nodechild=parent.getFirstChild();child!=null;child=child.getNextSibling())
if(childinstanceofElement&&((Element)child).getTagName().equals(tagName))
nodes.add(child);
returnnewNodeList()
{
publicintgetLength()
{returnnodes.size();}

publicNodeitem(inti)
{return(Node)nodes.get(i);}
}
;
}


publicstaticStringallTextFromUniqueImmediateChild(Elementelem,StringchildTagName)
throwsDOMException
{
ElementuniqueChild
=uniqueImmediateChildByTagName(elem,childTagName);
if(uniqueChild==null)
returnnull;
returnDomParseUtils.allTextFromElement(uniqueChild);
}


publicstaticElementuniqueImmediateChild(Elementelem,StringchildTagName)
throwsDOMException
{returnuniqueImmediateChildByTagName(elem,childTagName);}

/**
*
@deprecateduseuniqueImmediateChild(Elementelem,StringchildTagName)
*/

publicstaticElementuniqueImmediateChildByTagName(Elementelem,StringchildTagName)
throwsDOMException
{
NodeListnl
=getImmediateChildElementsByTagName(elem,childTagName);
intlen=nl.getLength();
if(DEBUG)
DebugUtils.myAssert(len
<=1,
"Thereismorethanone("+len+")childwithtagname:"+
childTagName
+"!!!");
return(len==1?(Element)nl.item(0):null);
}


/**
*
@deprecateduseElement.getAttribute(Stringval)
*/

publicstaticStringattrValFromElement(Elementelement,StringattrName)
throwsDOMException
{
Attrattr
=element.getAttributeNode(attrName);
return(attr==null?null:attr.getValue());
}


privateDomParseUtils()
{}
}


 

 

 

 

 

 

缓冲区溢出漏洞

贴一小段自己写的小程序

//MS VC++ 6.0 Console lhj
#include <windows.h>

void main()
{
//保留原来的返回地址
DWORD *pBackAddress = (DWORD *)&pBackAddress + 2;
DWORD BackAddress = *pBackAddress;

//获取自己的执行代码地址
HMODULE hModule = LoadLibrary("User32.dll");
DWORD Address = (DWORD)GetProcAddress(hModule, "MessageBoxA");

//缓冲区溢出
DWORD Buffer[100];
Buffer[0] = 0x5050C033;// xoreax, eaxpush eaxpush eax
Buffer[1] = 0xE8905050;// pusheax pusheax
Buffer[2] = Address - (DWORD)&Buffer[3];// call MessageBoxA
Buffer[3] = 0xE9909090;// jmpBackAddress
Buffer[4] = BackAddress - (DWORD)&Buffer[5];

//更改返回地址
*pBackAddress = (DWORD)Buffer;

}

举例:

void MyRecv(char buffer)
{
char TempBuf[1024];
memset(TempBuf, 0, 1024);
int len = recv(TempBuf);
memcpy(buffer, TempBuf, len);
}

如果在我们的程序中调用过这样一段程序, 那么我们的程序将面临着溢出的危险!