我发现了一篇关于自修改代码的文章,并试图做一些例子,但我总是得到分段错误.就像我能理解的那样,内存权限存在违规行为.代码段是(r)ead/e(x)ecute,因此写入的尝试导致此错误.有没有办法通过在运行时或之前更改内存权限来测试程序?我正在使用linux,这个例子是用GAS汇编编写的.
.extern memcpy
.section .data
string:
.asciz "whatever"
string_end:
.section .bss
.lcomm buf, string_end-string
.section .text
.globl main
main:
call changer
mov $string, %edx
label:
push string_end-string
push $buf
push $string
call memcpy
changer:
mov $offset_to_write, %esi
mov $label, %edi
mov $0xb, %ecx
loop1:
lodsb
stosb
loop loop1
ret
offset_to_write:
push 0
call exit
end:
Run Code Online (Sandbox Code Playgroud)
所以在osgx建议的修改后,这是一个工作代码.(实际上,如果你组装并链接并运行它崩溃,但如果你看着使用gdb,它确实修改了它的代码!)
.extern memcpy
.section .data
string:
.asciz "Giorgos"
string_end:
.section .bss
.lcomm buf, string_end-string
.section .text
.globl main
main:
lea (main), %esi # get the …Run Code Online (Sandbox Code Playgroud) 假设我们有一个使用UiBinder声明的自定义小部件,它需要在其构造函数中包含一些参数.当我在ui.xml中声明它时,我怎样才能提供这些参数?
那是我有一个
CustomWidget(int param1, int param2)
Run Code Online (Sandbox Code Playgroud)
当我将它添加到ui.xml时,我需要能够:
...
xmlns:my="urn:import:...">
<g:Container>
<my:CustomWidget param1="1" param2="arg2"/>
</g:Container>
Run Code Online (Sandbox Code Playgroud) 我必须编写一个简单的多态引擎.我使用linux(32位),我可以在汇编和c中编码.我不知道如何开始.
你能给我一个架构来构建这样一个引擎吗?我的想法是制作一个程序:
是对的吗?它是否反映了这种发动机的运转?
我手动编写一个可执行的ELF头+程序头,如下所示:
elf_head:
e_ident db 7Fh, 'ELF', 1, 1, 1
times 9 db 0
e_type dw 2 ; ET_EXEC
e_mach dw 3 ; EM_386
e_ver dd 1 ; EV_CURRENT
e_entry dd 0x08048000+elf_head_len ; entry point
e_phoff dd 34h ; program header table offset
e_shoff dd 00h ; section header table offset
e_flags dd 0 ; flags
e_elfhs dw 34h ; ELF header size
e_phes dw 20h ; program header entry size
e_phec dw 01h ; program header entries count
e_shes dw …Run Code Online (Sandbox Code Playgroud) 我使用以下代码作为GWT-RPC的GWT服务器端类(servlet)的一部分.
private void getImage() {
HttpServletResponse res = this.getThreadLocalResponse();
try {
// Set content type
res.setContentType("image/png");
// Set content size
File file = new File("C:\\Documents and Settings\\User\\image.png");
res.setContentLength((int) file.length());
// Open the file and output streams
FileInputStream in = new FileInputStream(file);
OutputStream out = res.getOutputStream();
// Copy the contents of the file to the output stream
byte[] buf = new byte[1024];
int count = 0;
while ((count = in.read(buf)) >= 0) {
out.write(buf, 0, count);
}
in.close();
out.close();
} catch …Run Code Online (Sandbox Code Playgroud) 我为VerticalLayout面板的边框声明了一些颜色,如:
<ui:style>
.onMouseOverBorderColor {border-color: red; border-style: outset}
.onMouseOutBorderColor {border-color: black; border-style: outset}
</ui:style>
Run Code Online (Sandbox Code Playgroud)
然后我想根据鼠标的位置更改面板边框的颜色,并添加到我的窗口小部件的构造函数中:
clickable.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
GWT.log("mouse over");
border.setStyleName("onMouseOverBorderColor");
}
});
clickable.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
GWT.log("mouse out");
border.setStyleName("onMouseOutBorderColor");
}
});
Run Code Online (Sandbox Code Playgroud)
但是......没有任何反应!我做错了什么?
建议后的代码(不起作用):
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:style>
.fontStyleTitle {font-weight: bold }
.border {border-color: black; border-style: outset}
.border:hover {border-color: red; border-style: outset}
</ui:style>
<g:FocusPanel ui:field="clickable">
<g:VerticalPanel ui:field="border" borderWidth="1" styleName="style.border">
<g:Image ui:field="myImage"/>
<g:Label ui:field="myTitle" horizontalAlignment="ALIGN_CENTER" styleName="{style.fontStyleTitle}"/>
</g:VerticalPanel>
</g:FocusPanel>
</ui:UiBinder>
Run Code Online (Sandbox Code Playgroud)
和java类:
public …Run Code Online (Sandbox Code Playgroud) 我正在尝试为XML文档进行转换,但由于我不了解XSLT,因此无法找到解决方案.我有XML文档:
<?xml version="1.0" encoding="UTF-8"?>
<addresses xmlns="http://www.test.org/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation='http://whatever/test.xsd'>
<address>
<name>Joe Tester</name>
<street>Baker street 5</street>
</address>
</addresses>
Run Code Online (Sandbox Code Playgroud)
我想生产:
<?xml version="1.0" encoding="UTF-8"?>
<addresses xmlns="http://www.test.org/xml">
<address>
<name>Joe Tester</name>
<street>Baker street 5</street>
</address>
</addresses>
Run Code Online (Sandbox Code Playgroud)
(考虑到xsi:noNamespaceSchemaLocation ="..."已经在此之前使用另一个XSLT排除了).
有人可以帮我找到解决方案吗?
用于消除xsi:noNamespaceSchemaLocation的XSLT是:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="@xsi:noNamespaceSchemaLocation"/>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud) 我想在bash脚本中添加这个命令grep -co'\ b5\b'$ INFILE.问题是,而不是5我想在其位置使用变量,所以我写:
V=`grep -co '\b$L\b' $INFILE`
Run Code Online (Sandbox Code Playgroud)
但它不起作用,因为$用于在内部描述grep中的行尾.我怎样才能使它工作?是否存在$的转义序列,以使其使用变量值的bash含义?
使用Embed标签,我们不仅可以在swf文件中嵌入swf或jpg等,还可以嵌入不支持的文件格式,例如:
Embed[(source="mzip.zip", mimeType="application/octet-stream")]
public static MyZip:Class;
package {
import flash.utils.ByteArray;
public final class Resource {
[Embed(source="p2.zip", mimeType="application/octet-stream")]
public static const MyZip:Class;
public static function getByteArrayFromZip():ByteArray {
var zip:ByteArray = new MyZip as ByteArray;
return zip;
}
}
Run Code Online (Sandbox Code Playgroud)
}
public class Main extends Sprite {
private var ship:Bitmap;
private var lib:FZipLibrary;
public function Main() {
lib = new FZipLibrary();
lib.formatAsBitmapData(".jpg");
lib.addEventListener(Event.COMPLETE,onCompleteHandler);
var fzip:FZip = new FZip();
fzip.loadBytes(Resource.getByteArrayFromZip());
lib.addZip(fzip);
}
private function onCompleteHandler(evt:Event) {
var image:BitmapData = lib.getBitmapData("assets/graphics/scratchers/myimg.jpg");
trace("Size: " + image.width …Run Code Online (Sandbox Code Playgroud) 是否有算法从给定的无上下文语法生成所有字符串?