[PR] この広告は3ヶ月以上更新がないため表示されています。
ホームページを更新後24時間以内に表示されなくなります。
'dump.abpで保存すること以下のように使います。
#console
#include<vcrt71.sbp>
'コマンドライン分析
Dim cmd As *Byte
Dim cmdlen As Long
Dim fnam[MAX_PATH] As Byte
Dim n As Long,m As Long
cmd = GetCommandLine()
cmdlen = strlen(cmd)
cmd[cmdlen+1] = &h20'番人
For n=0 To cmdlen
'スペースを探す
If cmd[n-1] = &h20 Then
'次のスペースまでをfnamにコピー
While cmd[n] = &h20
n=n+1
Wend
While(cmd[n] <> &h20)
fnam[m] = cmd[n]
n=n+1
m=m+1
Wend
Exit For
End If
Next
'ファイルを開きます。
Dim fp As *FILE
Dim fsiz As Long
Dim buf As *Byte
fp = fopen(fnam , "rb")
If fp = NULL Then
printf("%sを開けません" , fnam)
exit(0)
EndIf
fseek(fp , 0 , SEEK_END)
fsiz = ftell(fp)
fseek(fp , 0 , SEEK_SET)
buf = malloc(fsiz + 16)
fread(buf , 1 , fsiz , fp)
fclose(fp)
'ダンプ
For n=0 To fsiz Step 16
'16進数表示
For m=n To n+15
If m >=fsiz Then buf[m] = 0
printf("%02x " , buf[m])
Next
'文字なら表示
For m=n To n+15
If buf[m] >= &h20 And buf[m] <= &h7F Then
printf("%c" , buf[m])
Else
printf(".")
End If
Next
'改行
printf(Ex"\r\n")
Next
free(buf)
exit(0)
dump ファイル自分自身をダンプすると以下のようになります。
#console使い方は下記の通りです。
#include<vcrt71.sbp>
'コマンドライン分析
Sub USAGE()
printf(Ex"DUMPER for AB Version 1.1\ndump ファイル [開始 終了]\n")
exit(0)
End Sub
Function GetCmd(cnt As Long,buf As *Byte) As Long
Dim cmd As *Byte
Dim cmdlen As Long
Dim cidx As Long
Dim ctmp[MAX_PATH] As Byte
cmd = GetCommandLine()
cmdlen = strlen(cmd)
cmd[cmdlen] = &h20
buf[0] = 0'初期化
'スペースを圧縮
For n=0 To cmdlen
If cmd[n] = &h20 And cmd[n+1] = &h20 Then
memcpy(VarPtr(cmd[n]) , VarPtr(cmd[n+1]) , cmdlen - n)
n=n-1
cmdlen=cmdlen-1
End If
Next
For n=0 To cmdlen
While cmd[n]<>&h20
ctmp[m]=cmd[n]
m=m+1
n=n+1
Wend
ctmp[m]=0
m=0
If cidx = cnt Then
strcpy(buf , ctmp)
Exit For
End If
cidx = cidx+1
Next
End Function
Dim fnam[MAX_PATH] As Byte
Dim tmp[MAX_PATH] As Byte
Dim dstart As Long , dend As Long
Dim n As Long,m As Long
GetCmd(1 , fnam)
GetCmd(2 , tmp)
dstart = atoi(tmp)
GetCmd(3 , tmp)
dend = atoi(tmp)
'printf(Ex"[%s] : %d -> %d\n" , fnam , start , end)
'ファイルを開きます。
Dim fp As *FILE
Dim fsiz As Long
Dim buf As *Byte
fp = fopen(fnam , "rb")
If fp = NULL Then USAGE()
fseek(fp , 0 , SEEK_END)
fsiz = ftell(fp)
fseek(fp , 0 , SEEK_SET)
buf = malloc(fsiz + 16)
fread(buf , 1 , fsiz , fp)
fclose(fp)
'位置を設定
If dstart < 0 or dstart > dend or dstart > fsiz Then dstart = 0
If dend <= 0 or dend > fsiz Then dend = fsiz
printf(Ex"dump : %s : %d -> %d\n------------------------------------\n", _
fnam , dstart , dend)
'ダンプ
For n=dstart To dend Step 16
'アドレス
printf("%6d : " , n)
'16進数表示
For m=n To n+15
If m > dend Then
printf(" ")
Else
printf("%02x " , buf[m])
End If
Next
'文字なら表示
For m=n To n+15
If m =>dend Then Exit For
If buf[m] >= &h20 And buf[m] <= &h7F Then
printf("%c" , buf[m])
Else
printf(".")
End If
Next
'改行
printf(Ex"\r\n")
Next
free(buf)
exit(0)
dump ファイル [開始 終了]私の書き方が悪いため、読みにくいと思いますが、勘弁してください。