- 积分
- 36555
- 明经币
- 个
- 注册时间
- 2013-8-16
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 baitang36 于 2020-11-25 12:47 编辑
经mokson大侠研究, 明经论坛打不开的图片或附件之中,在文件头开始都加入了“0D 0A”这两个字节,因此jpg,gif,png 等图片不能正确显示,下载的全部压缩附件也打不开,解压提示错误信息。
本程序的作用就是修复下载的附件和图片,让它变成正常的。
使用方法很简单,执行fixmj.exe,选需要修复的文件,点打开。程序会自动备份原来的文件,不用担心修坏了。
链接: https://pan.baidu.com/s/1w16z5RGFXOZstccQcs7LPQ 提取码: 264h
解压缩密码是mjtd
以下为汇编源码,可以用masm32编译
.386
.model flat,stdcall
option casemap:none
include \MASM32\INCLUDE\shell32.inc
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\advapi32.inc
includelib \masm32\lib\advapi32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \MASM32\LIB\oleaut32.lib
include \MASM32\include\oleaut32.inc
includelib \MASM32\LIB\shell32.lib
include \masm32\include\comdlg32.inc
includelib \masm32\lib\comdlg32.lib
stralloc MACRO file_ln
invoke SysAllocStringByteLen,0,file_ln
ENDM
.data
buffer db 512 dup(0)
newfilename1 db 512 dup(0)
buff1 db 16 dup(0)
buff2 db 16 dup(0)
AppName db "明经论坛附件文件修正工具 ver 1.0 (C)SYZ 2020.10.23",0
mesberr_1 db " 欢迎使用明经论坛附件文件修正工具 ver 1.0",0dh,0ah
db ' 山东济南 盛玉增 (baitang36)研制 ',0dh,0ah
db ' 联系QQ:5520971 ',0dh,0ah,0dh,0ah
db '修正成功!',0
mesberr_2 db '程序错误!',0
br1 dd 20h
db 0
ofn OPENFILENAME <>
FilterString db "Files (*.*)",0,"*.*",0
.data?
hInstance HINSTANCE ?
fhand1 dd ? ;文件句柄
fhand3 dd ?
file_ln dd ? ;源文件长度
source$ dd ? ;分配内存开始地址
.code
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
mov ofn.lStructSize,SIZEOF ofn
mov ofn.lpstrFilter, OFFSET FilterString
mov ofn.lpstrFile, OFFSET buffer
mov ofn.nMaxFile,512
mov ofn.Flags, OFN_FILEMUSTEXIST or OFN_PATHMUSTEXIST or OFN_LONGNAMES or OFN_EXPLORER or OFN_HIDEREADONLY
invoke GetOpenFileName, ADDR ofn
mov esi,OFFSET buffer
mov edi,OFFSET newfilename1
@@: lodsb
cmp al,0
jz @f
stosb
jmp @b
@@: sub esi,5
lodsd
mov edx,eax
sub edi,4
mov eax,'kab_'
stosd
mov eax,edx
stosd
mov al,0
stosb
invoke CopyFile, ADDR buffer,ADDR newfilename1,0 ;复制bak文件
invoke CreateFile,ADDR buffer, ;打开
GENERIC_READ,
FILE_SHARE_WRITE,
NULL,OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL
.if eax==INVALID_HANDLE_VALUE
jmp nx_3
.else
mov fhand1,eax
.endif
invoke GetFileSize,fhand1,NULL
mov file_ln , eax
stralloc file_ln ;分配内存
mov source$, eax
invoke ReadFile,fhand1,source$,file_ln,ADDR br1,NULL
mov eax,fhand1
invoke CloseHandle,eax
mov esi,source$
lodsw
cmp ax,0a0dh
jz wfas_1
jmp end_1
wfas_1:
lodsb
cmp al,20h
jnz wfas_2
jmp end_1
wfas_2:
invoke CreateFile,ADDR buffer, ;建立文件
GENERIC_WRITE, ; access (read-write) mode
FILE_SHARE_READ, ;NULL, ; share mode
NULL, ; pointer to security attributes
CREATE_ALWAYS, ; how to create
FILE_ATTRIBUTE_NORMAL, ; file attributes
NULL
.if eax==INVALID_HANDLE_VALUE
jmp nx_3
.else
mov fhand3,eax
.endif
mov edx,file_ln
sub edx,2
mov ecx,source$
add ecx,2
invoke WriteFile,fhand3,ecx,edx,ADDR br1,NULL
mov eax,fhand3
invoke CloseHandle,eax
jmp nx_2
nx_2: invoke MessageBox,NULL,ADDR mesberr_1,ADDR AppName,MB_OK;MB_YESNO
invoke ExitProcess,eax
nx_3: invoke MessageBox,NULL,ADDR mesberr_2,ADDR AppName,MB_OK
invoke ExitProcess,eax
end_1: jmp @f ;
no_1 db "文件正常,不需要修正!",0
@@: invoke MessageBox,NULL,ADDR no_1,ADDR AppName,MB_OK
invoke ExitProcess,eax
end start
编译工具下载链接: https://pan.baidu.com/s/1-wugzQ_-IH5gfztPDUC3Xg 提取码: dsyy
|
|