Initial
This commit is contained in:
230
uudecode/TASM/DECODE64.ASM
Normal file
230
uudecode/TASM/DECODE64.ASM
Normal file
@@ -0,0 +1,230 @@
|
||||
;*************************************************************************************
|
||||
; MODULE: DECODE64.ASM DATE: JANUARY 27,1997
|
||||
; AUTHOR: SEAN M. KESSLER
|
||||
; TARGET: 32 BIT FLAT MODEL
|
||||
; FUNCTION : BASE64 DECODER
|
||||
;*************************************************************************************
|
||||
.386
|
||||
.MODEL FLAT
|
||||
INCLUDE devioctl.inc
|
||||
INCLUDE string.inc
|
||||
INCLUDE openfile.inc
|
||||
.DATA
|
||||
inputFile FileInfo <>
|
||||
outputFile FileInfo <>
|
||||
lineData DB 400h DUP(0)
|
||||
szDefaultOutputPathFileName DB 'IMAGE.JPG',00h
|
||||
szOutputPathFileName DB 0FFh DUP(0)
|
||||
szFileNameLiteral DB 'filename=',00h
|
||||
szOutBytes DB 04h DUP(0)
|
||||
szInputPathFileName DD ?
|
||||
szBase64ID DB '/9j/',00h
|
||||
szExtension DB '.JPG',00H
|
||||
szBase64Vector DB 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',00h
|
||||
szBase64End DB '---',00h
|
||||
num DD ?
|
||||
lineLength DD ?
|
||||
itemIndex DD ?
|
||||
itemCount DD ?
|
||||
numIndex DD ?
|
||||
valueItem DD ?
|
||||
.CODE
|
||||
_decodeBase64 proc near ; WORD decodeBase64(const char *szPathFileName)
|
||||
push ebp ; save stack frame
|
||||
mov ebp,esp ; create new frame
|
||||
push esi ; save source index register
|
||||
push edi ; save destination index register
|
||||
mov itemCount,0000h ; initialize decoded counter to zero
|
||||
push dword ptr[ebp+8] ; save pathFileName
|
||||
pop szInputPathFileName ; restore into inputPathFileName
|
||||
cmp szInputPathFileName,0000h ; is the file na null
|
||||
je @@error ; if so then we've got an error
|
||||
FOPEN szInputPathFileName,inputFile,GENERIC_READ,FILE_SHARE_READ,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL
|
||||
cmp inputFile.FileInfo@@mhFileHandle,INVALID_HANDLE ; do we have a valid handle ?
|
||||
je @@error ; if the handle is invalid then we've got an error
|
||||
call _outputName ; get output file name
|
||||
@@search: ; search sync address
|
||||
FGETS inputFile,lineData ; get input line
|
||||
cmp eax,0000h ; did we read anything
|
||||
je @@end ; if not we're done
|
||||
STRSTR lineData,szFileNameLiteral ; look for "filename=" literal
|
||||
cmp eax,0000h ; did we find it
|
||||
jne @@nameFile ; if so then extract the filename
|
||||
STRNCMP szBase64ID,lineData ; compare line to base64 identifier
|
||||
cmp eax,0001h ; if we've got it then we start decoding
|
||||
je @@beginDecode ; jump to decode handler
|
||||
jmp @@search ; keep going
|
||||
@@nameFile: ; nameFile sync address
|
||||
push eax ; save address of filename literal
|
||||
push offset szOutputPathFileName ; save address of filename buffer
|
||||
call _nameFile ; extract the file name
|
||||
add esp,08h ; reset stack frame
|
||||
jmp @@search ; keep going
|
||||
@@beginDecode: ; begin decode sync address
|
||||
mov esi,offset szOutputPathFileName
|
||||
FOPEN esi,outputFile,GENERIC_WRITE,FILE_SHARE_READ,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL
|
||||
; FOPEN szOutputPathFileName,outputFile,GENERIC_WRITE,FILE_SHARE_READ,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL
|
||||
@@continueDecode: ; continue decode sync address
|
||||
STRLEN lineData ; get length of lineData
|
||||
dec eax ; decrement line length
|
||||
mov lineLength,eax ; move line length into lineLength
|
||||
mov itemIndex,0000h ; set itemIndex to zero
|
||||
@@itemLoop: ; itemLoop sync address
|
||||
mov valueItem,0000h ; set valueItem to zero
|
||||
mov esi,offset lineData ; move ptr lineData to esi register
|
||||
add esi,itemIndex ; add itemIndex to address
|
||||
cmp byte ptr[esi+02h],'=' ; is pChar[2] equal to '='?
|
||||
je @@assignOne ; if so then num=1
|
||||
cmp byte ptr[esi+03h],'=' ; else if pChar[3]='='
|
||||
je @@assignTwo ; then num=2
|
||||
mov num,0003h ; otherwise num=3
|
||||
jmp @@assignContinue ; continue
|
||||
@@assignOne: ; assignment sync address
|
||||
mov num,0001h ; assign 1 to num
|
||||
jmp @@assignContinue ; continue
|
||||
@@assignTwo: ; assignment sync address
|
||||
mov num,0002h ; assign two to num
|
||||
jmp @@assignContinue ; continue
|
||||
@@assignContinue: ; end assignment sync address
|
||||
mov numIndex,0000h ; set numIndex to zero
|
||||
@@numLoop: ; numIndex loop sync address
|
||||
xor eax,eax ; clear out eax
|
||||
mov edi,numIndex ; move numIndex into destination index
|
||||
mov al,byte ptr[esi+edi] ; get the byte at pChar[numIndex]
|
||||
STRCHR szBase64Vector,eax ; ::strchar(szBase64Vector,pChar[numIndex])
|
||||
cmp eax,0000h ; did we find the token
|
||||
je @@end ; if not then we've got an error
|
||||
mov edi,eax ; move address of found token to edi (pTok)
|
||||
sub edi,offset szBase64Vector ; perform (pTok-szBase64Vector) result to edi
|
||||
mov eax,0003h ; move 3 into eax
|
||||
sub eax,numIndex ; perform (3-numIndex) result to eax
|
||||
mov edx,0006h ; move 6 into edx
|
||||
imul eax,edx ; perform (3-numIndex)*6 result to eax
|
||||
mov cl,al ; move shift value into cl register
|
||||
shl edi,cl ; perform (pTok-smszVec)<<((3-numIndex)*6) result to edi
|
||||
add valueItem,edi ; valueItem+=(pTok-smszVec)<<((3-numIndex)*6)
|
||||
inc numIndex ; increment numIndex
|
||||
mov eax,numIndex ; move numIndex into eax register
|
||||
cmp eax,num ; compare numIndex to num
|
||||
jle @@numLoop ; loop through <= operation
|
||||
mov numIndex,0002h ; set numIndex to 2
|
||||
@@nextNumLoop: ; next numLoop sync address
|
||||
mov esi,offset szOutBytes ; move szOutBytes address into esi
|
||||
mov edi,numIndex ; move numIndex into edi
|
||||
mov eax,valueItem ; move valueItem into eax register
|
||||
and eax,000000FFh ; apply bit mask
|
||||
mov byte ptr[esi+edi],al ; set byte in szOutBytes
|
||||
shr valueItem,08h ; shift valueItem right 8 bytes
|
||||
dec numIndex ; decrement numIndex
|
||||
cmp numIndex,0000h ; compare numIndex to zero
|
||||
jge @@nextNumLoop ; if >=0 keep going
|
||||
mov esi,offset szOutBytes ; move szOutBytes to esi
|
||||
xor edi,edi ; clear edi
|
||||
@@writeLoop: ; writeLoop sync address
|
||||
FWRITE outputFile,byte ptr[esi+edi] ; write out the byte
|
||||
inc edi ; increment edi
|
||||
cmp edi,num ; compare edi to num
|
||||
jl @@writeLoop ; if it's less then keep going
|
||||
add itemIndex,0004h ; increment itemIndex by four
|
||||
mov eax,itemIndex ; move itemIndex to eax
|
||||
cmp eax,lineLength ; compare itemIndex to lineLength
|
||||
jl @@itemLoop ; if it's less that keep going
|
||||
FGETS inputFile,lineData ; get another line
|
||||
cmp eax,0000h ; did we get a line?
|
||||
je @@end ; if not then we're done
|
||||
STRNCMP lineData,szBase64End ; look for trailer signature
|
||||
cmp eax,0001h ; if we found it then another image may follow
|
||||
je @@prepNewImage ; flush and close current output file
|
||||
jmp @@continueDecode ; otherwise keep going
|
||||
@@prepNewImage: ; prepNewImage sync address
|
||||
inc itemCount ; increment decoded counter
|
||||
FFLUSH outputFile ; flush output file
|
||||
CLOSEHANDLE outputFile.FileInfo@@mhFileHandle ; close output file
|
||||
mov outputFile.FileInfo@@mhFileHandle,INVALID_HANDLE ; invalidate the handle
|
||||
jmp @@search ; try to decode another image
|
||||
@@end: ; end sync address
|
||||
cmp outputFile.FileInfo@@mhFileHandle,INVALID_HANDLE ; is this a valid handle
|
||||
je @@closePrimary ; is handle is invalid, just close the input file
|
||||
FFLUSH outputFile ; flush the output file
|
||||
CLOSEHANDLE outputFile.FileInfo@@mhFileHandle ; close output file
|
||||
@@closePrimary: ; close primary sync address
|
||||
CLOSEHANDLE inputFile.FileInfo@@mhFileHandle ; close input file
|
||||
@@error: ; error sync address
|
||||
mov eax,itemCount ; move decoded count to eax register
|
||||
pop edi ; restore destination index register
|
||||
pop esi ; restore source index register
|
||||
pop ebp ; restore prior stack frame
|
||||
retn ; return near to caller
|
||||
_decodeBase64 endp
|
||||
_nameFile proc near
|
||||
push ebp ; save stack frame
|
||||
mov ebp,esp ; create new frame
|
||||
push esi ; save source index register
|
||||
push edi ; save destination index register
|
||||
mov edi,[ebp+8] ; move dest string to destination index register
|
||||
mov esi,[ebp+0Ch] ; move source string to source index register
|
||||
@@NAMEFILEquoteLoop: ; first quote loop control
|
||||
mov al,byte ptr[esi] ; move byte into al
|
||||
cmp al,00h ; is it null?
|
||||
je @@NAMEFILEerror ; if it's null then we've got an error
|
||||
cmp al,'"' ; is it the first quote ?
|
||||
je @@NAMEFILEreadFile ; if so then get the filename
|
||||
inc esi ; increment along esi
|
||||
jmp @@NAMEFILEquoteLoop ; keep going
|
||||
@@NAMEFILEreadFile: ; read file name sync address
|
||||
inc esi ; skip past the first quote
|
||||
mov al,byte ptr[esi] ; read from file name
|
||||
cmp al,'"' ; is the byte the closing quote?
|
||||
je @@NAMEFILEreadEnd ; if so then we're done
|
||||
cmp al,00h ; is the byte a null byte?
|
||||
je @@NAMEFILEreadEnd ; if so then we're done
|
||||
mov byte ptr[edi],al ; store the byte in destination
|
||||
inc edi ; increment along destination
|
||||
jmp @@NAMEFILEreadFile ; keep going
|
||||
@@NAMEFILEreadEnd: ; read end sync address
|
||||
mov byte ptr[edi],00h ; null terminate the string
|
||||
mov eax,0001h ; set return code
|
||||
jmp @@NAMEFILEend ; we're done
|
||||
@@NAMEFILEerror: ; error sync address
|
||||
xor eax,eax ; set error return
|
||||
@@NAMEFILEend: ; end proc sync address
|
||||
pop edi ; restore destination index register
|
||||
pop esi ; restore source index register
|
||||
pop ebp ; restore prior stack frame
|
||||
retn ; return near to caller
|
||||
_nameFile endp
|
||||
_outputName proc near
|
||||
push ebp ; save stack frame
|
||||
mov ebp,esp ; create new frame
|
||||
push esi ; save source index register
|
||||
push edi ; save destination index register
|
||||
mov esi,szInputPathFileName ; set esi to input name address
|
||||
mov edi,offset szOutputPathFileName ; set edi to output name address
|
||||
xor ecx,ecx ; clear ecx for indexing
|
||||
@@copyLoop: ; copy loop sync address
|
||||
mov al,[esi+ecx] ; get byte from source to al
|
||||
cmp al,00h ; is this a null byte
|
||||
je @@copyDone ; if so then we're done copying
|
||||
mov byte ptr[edi],al ; store the byte into destination
|
||||
inc edi ; increment destination
|
||||
inc ecx ; increment source index
|
||||
jmp @@copyLoop ; loop through the string
|
||||
@@copyDone: ; copy done sync address
|
||||
mov byte ptr[edi],00h ; set null terminator
|
||||
STRCHR szOutputPathFileName,'.' ; look for extension marker
|
||||
cmp eax,0000h ; did we find it?
|
||||
je @@nameError ; if not then we set output name to default
|
||||
mov byte ptr[eax],0000h ; otherwise terminate the string
|
||||
STRCAT szOutputPathFileName,szExtension ; cat the string with ".jpg"
|
||||
jmp @@outputDone ; we're done
|
||||
@@nameError: ; nameError sync address
|
||||
STRLEN szDefaultOutputPathFileName ; get the length of the default file name
|
||||
MEMCPY szOutputPathFileName,szDefaultOutputPathFileName,eax ; set output file name to default
|
||||
@@outputDone: ; outputDone sync address
|
||||
pop edi ; restore destination index
|
||||
pop esi ; restore source index
|
||||
pop ebp ; restore previous stack frame
|
||||
retn ; return near to caller
|
||||
_outputName endp
|
||||
public _decodeBase64
|
||||
END
|
||||
230
uudecode/TASM/DECODE64.BAK
Normal file
230
uudecode/TASM/DECODE64.BAK
Normal file
@@ -0,0 +1,230 @@
|
||||
;*************************************************************************************
|
||||
; MODULE: DECODE64.ASM DATE: JANUARY 27,1997
|
||||
; AUTHOR: SEAN M. KESSLER
|
||||
; TARGET: 32 BIT FLAT MODEL
|
||||
; FUNCTION : BASE64 DECODER
|
||||
;*************************************************************************************
|
||||
.386
|
||||
.MODEL FLAT
|
||||
INCLUDE devioctl.inc
|
||||
INCLUDE string.inc
|
||||
INCLUDE openfile.inc
|
||||
.DATA
|
||||
inputFile FileInfo <>
|
||||
outputFile FileInfo <>
|
||||
lineData DB 400h DUP(0)
|
||||
szDefaultOutputPathFileName DB 'IMAGE.JPG',00h
|
||||
szOutputPathFileName DB 0FFh DUP(0)
|
||||
szFileNameLiteral DB 'filename=',00h
|
||||
szOutBytes DB 04h DUP(0)
|
||||
szInputPathFileName DD ?
|
||||
szBase64ID DB '/9j/',00h
|
||||
szExtension DB '.JPG',00H
|
||||
szBase64Vector DB 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',00h
|
||||
szBase64End DB '---',00h
|
||||
num DD ?
|
||||
lineLength DD ?
|
||||
itemIndex DD ?
|
||||
itemCount DD ?
|
||||
numIndex DD ?
|
||||
valueItem DD ?
|
||||
.CODE
|
||||
_decodeBase64 proc near ; WORD decodeBase64(const char *szPathFileName)
|
||||
push ebp ; save stack frame
|
||||
mov ebp,esp ; create new frame
|
||||
push esi ; save source index register
|
||||
push edi ; save destination index register
|
||||
mov itemCount,0000h ; initialize decoded counter to zero
|
||||
push dword ptr[ebp+8] ; save pathFileName
|
||||
pop szInputPathFileName ; restore into inputPathFileName
|
||||
cmp szInputPathFileName,0000h ; is the file na null
|
||||
je @@error ; if so then we've got an error
|
||||
FOPEN szInputPathFileName,inputFile,GENERIC_READ,FILE_SHARE_READ,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL
|
||||
cmp inputFile.FileInfo@@mhFileHandle,INVALID_HANDLE ; do we have a valid handle ?
|
||||
je @@error ; if the handle is invalid then we've got an error
|
||||
call _outputName ; get output file name
|
||||
@@search: ; search sync address
|
||||
FGETS inputFile,lineData ; get input line
|
||||
cmp eax,0000h ; did we read anything
|
||||
je @@end ; if not we're done
|
||||
STRSTR lineData,szFileNameLiteral ; look for "filename=" literal
|
||||
cmp eax,0000h ; did we find it
|
||||
jne @@nameFile ; if so then extract the filename
|
||||
STRNCMP szBase64ID,lineData ; compare line to base64 identifier
|
||||
cmp eax,0001h ; if we've got it then we start decoding
|
||||
je @@beginDecode ; jump to decode handler
|
||||
jmp @@search ; keep going
|
||||
@@nameFile: ; nameFile sync address
|
||||
push eax ; save address of filename literal
|
||||
push offset szOutputPathFileName ; save address of filename buffer
|
||||
call _nameFile ; extract the file name
|
||||
add esp,08h ; reset stack frame
|
||||
jmp @@search ; keep going
|
||||
@@beginDecode: ; begin decode sync address
|
||||
mov esi,offset szOutputPathFileName
|
||||
FOPEN esi,outputFile,GENERIC_WRITE,FILE_SHARE_READ,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL
|
||||
; FOPEN szOutputPathFileName,outputFile,GENERIC_WRITE,FILE_SHARE_READ,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL
|
||||
@@continueDecode: ; continue decode sync address
|
||||
STRLEN lineData ; get length of lineData
|
||||
dec eax ; decrement line length
|
||||
mov lineLength,eax ; move line length into lineLength
|
||||
mov itemIndex,0000h ; set itemIndex to zero
|
||||
@@itemLoop: ; itemLoop sync address
|
||||
mov valueItem,0000h ; set valueItem to zero
|
||||
mov esi,offset lineData ; move ptr lineData to esi register
|
||||
add esi,itemIndex ; add itemIndex to address
|
||||
cmp byte ptr[esi+02h],'=' ; is pChar[2] equal to '='?
|
||||
je @@assignOne ; if so then num=1
|
||||
cmp byte ptr[esi+03h],'=' ; else if pChar[3]='='
|
||||
je @@assignTwo ; then num=2
|
||||
mov num,0003h ; otherwise num=3
|
||||
jmp @@assignContinue ; continue
|
||||
@@assignOne: ; assignment sync address
|
||||
mov num,0001h ; assign 1 to num
|
||||
jmp @@assignContinue ; continue
|
||||
@@assignTwo: ; assignment sync address
|
||||
mov num,0002h ; assign two to num
|
||||
jmp @@assignContinue ; continue
|
||||
@@assignContinue: ; end assignment sync address
|
||||
mov numIndex,0000h ; set numIndex to zero
|
||||
@@numLoop: ; numIndex loop sync address
|
||||
xor eax,eax ; clear out eax
|
||||
mov edi,numIndex ; move numIndex into destination index
|
||||
mov al,byte ptr[esi+edi] ; get the byte at pChar[numIndex]
|
||||
STRCHR szBase64Vector,eax ; ::strchar(szBase64Vector,pChar[numIndex])
|
||||
cmp eax,0000h ; did we find the token
|
||||
je @@end ; if not then we've got an error
|
||||
mov edi,eax ; move address of found token to edi (pTok)
|
||||
sub edi,offset szBase64Vector ; perform (pTok-szBase64Vector) result to edi
|
||||
mov eax,0003h ; move 3 into eax
|
||||
sub eax,numIndex ; perform (3-numIndex) result to eax
|
||||
mov edx,0006h ; move 6 into edx
|
||||
imul eax,edx ; perform (3-numIndex)*6 result to eax
|
||||
mov cl,al ; move shift value into cl register
|
||||
shl edi,cl ; perform (pTok-smszVec)<<((3-numIndex)*6) result to edi
|
||||
add valueItem,edi ; valueItem+=(pTok-smszVec)<<((3-numIndex)*6)
|
||||
inc numIndex ; increment numIndex
|
||||
mov eax,numIndex ; move numIndex into eax register
|
||||
cmp eax,num ; compare numIndex to num
|
||||
jle @@numLoop ; loop through <= operation
|
||||
mov numIndex,0002h ; set numIndex to 2
|
||||
@@nextNumLoop: ; next numLoop sync address
|
||||
mov esi,offset szOutBytes ; move szOutBytes address into esi
|
||||
mov edi,numIndex ; move numIndex into edi
|
||||
mov eax,valueItem ; move valueItem into eax register
|
||||
and eax,000000FFh ; apply bit mask
|
||||
mov byte ptr[esi+edi],al ; set byte in szOutBytes
|
||||
shr valueItem,08h ; shift valueItem right 8 bytes
|
||||
dec numIndex ; decrement numIndex
|
||||
cmp numIndex,0000h ; compare numIndex to zero
|
||||
jge @@nextNumLoop ; if >=0 keep going
|
||||
mov esi,offset szOutBytes ; move szOutBytes to esi
|
||||
xor edi,edi ; clear edi
|
||||
@@writeLoop: ; writeLoop sync address
|
||||
FWRITE outputFile,byte ptr[esi+edi] ; write out the byte
|
||||
inc edi ; increment edi
|
||||
cmp edi,num ; compare edi to num
|
||||
jl @@writeLoop ; if it's less then keep going
|
||||
add itemIndex,0004h ; increment itemIndex by four
|
||||
mov eax,itemIndex ; move itemIndex to eax
|
||||
cmp eax,lineLength ; compare itemIndex to lineLength
|
||||
jl @@itemLoop ; if it's less that keep going
|
||||
FGETS inputFile,lineData ; get another line
|
||||
cmp eax,0000h ; did we get a line?
|
||||
je @@end ; if not then we're done
|
||||
STRNCMP lineData,szBase64End ; look for trailer signature
|
||||
cmp eax,0001h ; if we found it then another image may follow
|
||||
je @@prepNewImage ; flush and close current output file
|
||||
jmp @@continueDecode ; otherwise keep going
|
||||
@@prepNewImage: ; prepNewImage sync address
|
||||
inc itemCount ; increment decoded counter
|
||||
FFLUSH outputFile ; flush output file
|
||||
CLOSEHANDLE outputFile.FileInfo@@mhFileHandle ; close output file
|
||||
mov outputFile.FileInfo@@mhFileHandle,INVALID_HANDLE ; invalidate the handle
|
||||
jmp @@search ; try to decode another image
|
||||
@@end: ; end sync address
|
||||
cmp outputFile.FileInfo@@mhFileHandle,INVALID_HANDLE ; is this a valid handle
|
||||
je @@closePrimary ; is handle is invalid, just close the input file
|
||||
FFLUSH outputFile ; flush the output file
|
||||
CLOSEHANDLE outputFile.FileInfo@@mhFileHandle ; close output file
|
||||
@@closePrimary: ; close primary sync address
|
||||
CLOSEHANDLE inputFile.FileInfo@@mhFileHandle ; close input file
|
||||
@@error: ; error sync address
|
||||
mov eax,itemCount ; move decoded count to eax register
|
||||
pop edi ; restore destination index register
|
||||
pop esi ; restore source index register
|
||||
pop ebp ; restore prior stack frame
|
||||
retn ; return near to caller
|
||||
_decodeBase64 endp
|
||||
_nameFile proc near
|
||||
push ebp ; save stack frame
|
||||
mov ebp,esp ; create new frame
|
||||
push esi ; save source index register
|
||||
push edi ; save destination index register
|
||||
mov edi,[ebp+8] ; move dest string to destination index register
|
||||
mov esi,[ebp+0Ch] ; move source string to source index register
|
||||
@@NAMEFILEquoteLoop: ; first quote loop control
|
||||
mov al,byte ptr[esi] ; move byte into al
|
||||
cmp al,00h ; is it null?
|
||||
je @@NAMEFILEerror ; if it's null then we've got an error
|
||||
cmp al,'"' ; is it the first quote ?
|
||||
je @@NAMEFILEreadFile ; if so then get the filename
|
||||
inc esi ; increment along esi
|
||||
jmp @@NAMEFILEquoteLoop ; keep going
|
||||
@@NAMEFILEreadFile: ; read file name sync address
|
||||
inc esi ; skip past the first quote
|
||||
mov al,byte ptr[esi] ; read from file name
|
||||
cmp al,'"' ; is the byte the closing quote?
|
||||
je @@NAMEFILEreadEnd ; if so then we're done
|
||||
cmp al,00h ; is the byte a null byte?
|
||||
je @@NAMEFILEreadEnd ; if so then we're done
|
||||
mov byte ptr[edi],al ; store the byte in destination
|
||||
inc edi ; increment along destination
|
||||
jmp @@NAMEFILEreadFile ; keep going
|
||||
@@NAMEFILEreadEnd: ; read end sync address
|
||||
mov byte ptr[edi],00h ; null terminate the string
|
||||
mov eax,0001h ; set return code
|
||||
jmp @@NAMEFILEend ; we're done
|
||||
@@NAMEFILEerror: ; error sync address
|
||||
xor eax,eax ; set error return
|
||||
@@NAMEFILEend: ; end proc sync address
|
||||
pop edi ; restore destination index register
|
||||
pop esi ; restore source index register
|
||||
pop ebp ; restore prior stack frame
|
||||
retn ; return near to caller
|
||||
_nameFile endp
|
||||
_outputName proc near
|
||||
push ebp ; save stack frame
|
||||
mov ebp,esp ; create new frame
|
||||
push esi ; save source index register
|
||||
push edi ; save destination index register
|
||||
mov esi,szInputPathFileName ; set esi to input name address
|
||||
mov edi,offset szOutputPathFileName ; set edi to output name address
|
||||
xor ecx,ecx ; clear ecx for indexing
|
||||
@@copyLoop: ; copy loop sync address
|
||||
mov al,[esi+ecx] ; get byte from source to al
|
||||
cmp al,00h ; is this a null byte
|
||||
je @@copyDone ; if so then we're done copying
|
||||
mov byte ptr[edi],al ; store the byte into destination
|
||||
inc edi ; increment destination
|
||||
inc ecx ; increment source index
|
||||
jmp @@copyLoop ; loop through the string
|
||||
@@copyDone: ; copy done sync address
|
||||
mov byte ptr[edi],00h ; set null terminator
|
||||
STRCHR szOutputPathFileName,'.' ; look for extension marker
|
||||
cmp eax,0000h ; did we find it?
|
||||
je @@nameError ; if not then we set output name to default
|
||||
mov byte ptr[eax],0000h ; otherwise terminate the string
|
||||
STRCAT szOutputPathFileName,szExtension ; cat the string with ".jpg"
|
||||
jmp @@outputDone ; we're done
|
||||
@@nameError: ; nameError sync address
|
||||
STRLEN szDefaultOutputPathFileName ; get the length of the default file name
|
||||
MEMCPY szOutputPathFileName,szDefaultOutputPathFileName,eax ; set output file name to default
|
||||
@@outputDone: ; outputDone sync address
|
||||
pop edi ; restore destination index
|
||||
pop esi ; restore source index
|
||||
pop ebp ; restore previous stack frame
|
||||
retn ; return near to caller
|
||||
_outputName endp
|
||||
public _decodeBase64
|
||||
END
|
||||
59
uudecode/TASM/DEVIOCTL.INC
Normal file
59
uudecode/TASM/DEVIOCTL.INC
Normal file
@@ -0,0 +1,59 @@
|
||||
;*************************************************************************************
|
||||
; MODULE: DEVIOCTL.INC DATE: FEBRUARY 2, 1997
|
||||
; AUTHOR: SEAN M. KESSLER
|
||||
; TARGET: 32 BIT FLAT MODEL
|
||||
; FUNCTION : FILE RELATED CONSTANTS
|
||||
;*************************************************************************************
|
||||
FILE_SHARE_READ equ 00000001h
|
||||
FILE_SHARE_WRITE equ 00000002h
|
||||
FILE_SHARE_DELETE equ 00000004h
|
||||
FILE_ATTRIBUTE_READONLY equ 00000001h
|
||||
FILE_ATTRIBUTE_HIDDEN equ 00000002h
|
||||
FILE_ATTRIBUTE_SYSTEM equ 00000004h
|
||||
FILE_ATTRIBUTE_DIRECTORY equ 00000010h
|
||||
FILE_ATTRIBUTE_ARCHIVE equ 00000020h
|
||||
FILE_ATTRIBUTE_NORMAL equ 00000080h
|
||||
FILE_ATTRIBUTE_TEMPORARY equ 00000100h
|
||||
FILE_ATTRIBUTE_COMPRESSED equ 00000800h
|
||||
FILE_ATTRIBUTE_OFFLINE equ 00001000h
|
||||
CREATE_NEW equ 00000001h
|
||||
CREATE_ALWAYS equ 00000002h
|
||||
OPEN_EXISTING equ 00000003h
|
||||
OPEN_ALWAYS equ 00000004h
|
||||
TRUNCATE_EXISTING equ 00000005h
|
||||
DELETE equ 00010000h
|
||||
READ_CONTROL equ 00020000h
|
||||
WRITE_DAC equ 00040000h
|
||||
WRITE_OWNER equ 00080000h
|
||||
SYNCHRONIZE equ 00100000h
|
||||
STANDARD_RIGHTS_REQUIRED equ 000F0000h
|
||||
STANDARD_RIGHTS_READ equ READ_CONTROL
|
||||
STANDARD_RIGHTS_WRITE equ READ_CONTROL
|
||||
STANDARD_RIGHTS_EXECUTE equ READ_CONTROL
|
||||
STANDARD_RIGHTS_ALL equ 001F0000h
|
||||
SPECIFIC_RIGHTS_ALL equ 0000FFFFh
|
||||
FILE_READ_DATA equ 0001h
|
||||
FILE_LIST_DIRECTORY equ 0001h
|
||||
FILE_WRITE_DATA equ 0002h
|
||||
FILE_ADD_FILE equ 0002h
|
||||
FILE_APPEND_DATA equ 0004h
|
||||
FILE_ADD_SUBDIRECTORY equ 0004h
|
||||
FILE_CREATE_PIPE_INSTANCE equ 0004h
|
||||
FILE_READ_EA equ 0008h
|
||||
FILE_WRITE_EA equ 0010h
|
||||
FILE_EXECUTE equ 0020h
|
||||
FILE_TRAVERSE equ 0020h
|
||||
FILE_DELETE_CHILD equ 0040h
|
||||
FILE_READ_ATTRIBUTES equ 0080h
|
||||
FILE_WRITE_ATTRIBUTES equ 0100h
|
||||
FILE_ALL_ACCESS equ STANDARD_RIGHTS_REQUIRED or SYNCHRONIZE or 1FFh
|
||||
FILE_GENERIC_READ equ STANDARD_RIGHTS_READ or FILE_READ_DATA or FILE_READ_ATTRIBUTES or FILE_READ_EA or SYNCHRONIZE
|
||||
FILE_GENERIC_WRITE equ STANDARD_RIGHTS_WRITE or FILE_WRITE_DATA or FILE_WRITE_ATTRIBUTES or FILE_WRITE_EA or FILE_APPEND_DATA or SYNCHRONIZE
|
||||
FILE_GENERIC_EXECUTE equ STANDARD_RIGHTS_EXECUTE or FILE_READ_ATTRIBUTES or FILE_EXECUTE or SYNCHRONIZE
|
||||
GENERIC_READ equ 80000000h
|
||||
GENERIC_WRITE equ 40000000h
|
||||
GENERIC_EXECUTE equ 20000000h
|
||||
GENERIC_ALL equ 10000000h
|
||||
|
||||
|
||||
|
||||
162
uudecode/TASM/OPENFILE.BAK
Normal file
162
uudecode/TASM/OPENFILE.BAK
Normal file
@@ -0,0 +1,162 @@
|
||||
;*************************************************************************************
|
||||
; MODULE: OPENFILE.INC DATE: FEBRUARY 2, 1997
|
||||
; AUTHOR: SEAN M. KESSLER
|
||||
; TARGET: 32 BIT FLAT MODEL
|
||||
; FUNCTION : FILE HANDLING MACROS
|
||||
;*************************************************************************************
|
||||
HANDLE STRUC
|
||||
PHANDLE TYPEDEF FAR PTR HANDLE
|
||||
HANDLE@@mHandle DD ?
|
||||
HANDLE ENDS
|
||||
|
||||
INVALID_HANDLE equ 0FFFFFFFFh
|
||||
|
||||
CREATEFILE MACRO pathFileName,access,share,open,attribute
|
||||
push 0000h ; save handle to template (null)
|
||||
push attribute ; save attributes
|
||||
push open ; save creation flags
|
||||
push 0000h ; save security attributes
|
||||
push share ; save share mode
|
||||
push access ; save acess mode
|
||||
push pathFileName ; save pathFileName
|
||||
call CreateFileA ; call create
|
||||
ENDM
|
||||
|
||||
READFILE MACRO hFileHandle,szBuffer,sizeBuffer
|
||||
sub esp,04h ; create bytesRead on stack
|
||||
mov eax,esp ; move bytesRead address to eax
|
||||
push 0000h ; save overlapped structure address
|
||||
push eax ; save pointer to bytesRead
|
||||
push sizeBuffer ; save length of buffer
|
||||
push offset szBuffer ; save address of read buffer
|
||||
push hFileHandle ; save file handle
|
||||
call ReadFile ; call read
|
||||
mov eax,[esp] ; move bytesRead value to eax
|
||||
add esp,04h ; remove bytesRead variable from stack
|
||||
ENDM
|
||||
|
||||
WRITEFILE MACRO hFileHandle,szBuffer,sizeBuffer
|
||||
sub esp,04h ; create bytesWritten variable on stack
|
||||
mov eax,esp ; move bytesWritten address to eax
|
||||
push 0000h ; save overlapped structure address
|
||||
push eax ; save bytesWritten address
|
||||
push sizeBuffer ; save write length
|
||||
push offset szBuffer ; save address of write buffer
|
||||
push hFileHandle ; save file handle
|
||||
call WriteFile ; call write
|
||||
mov eax,[esp] ; move number of bytes written to eax
|
||||
add esp,04h ; remove bytesWritten variable from stack
|
||||
ENDM
|
||||
|
||||
CLOSEHANDLE MACRO handle
|
||||
push handle ; save file handle
|
||||
call CloseHandle ; call close
|
||||
ENDM
|
||||
|
||||
FOPEN MACRO pathFileName,sFileInfo,access,share,open,attribute
|
||||
CREATEFILE pathFileName,access,share,open,attribute
|
||||
mov sFileInfo.FileInfo@@mhFileHandle,eax
|
||||
ENDM
|
||||
|
||||
FCLOSE MACRO sFileInfo
|
||||
LOCAL @@FCLOSEend
|
||||
cmp sFileInfo.FileInfo@@mhFileHandle,INVALID_HANDLE
|
||||
je @@FCLOSEend
|
||||
CLOSEHANDLE sFileInfo.FileInfo@@mhFileHandle
|
||||
mov sFileInfo.FileInfo@@mhFileHandle,INVALID_HANDLE
|
||||
@@FCLOSEend:
|
||||
ENDM
|
||||
|
||||
FREAD MACRO sFileInfo,ptrByte
|
||||
LOCAL @@FREADreadError,@@FREADsimpleRead,@@FREADdone
|
||||
cmp sFileInfo.FileInfo@@mBufferIndex,00h ; is buffer index zero
|
||||
jne @@FREADsimpleRead ; if not then just grab next byte
|
||||
READFILE sFileInfo.FileInfo@@mhFileHandle,sFileInfo.FileInfo@@mszBuffer,MaxLength ; otherwise we fill the read buffer
|
||||
cmp eax,0000h ; did we read any data ?
|
||||
je @@FREADreadError ; if not then we're done
|
||||
mov sFileInfo.FileInfo@@mBufferIndex,eax ; move number of bytes read to buffer index
|
||||
mov eax,offset sFileInfo.FileInfo@@mszBuffer ; move address of buffer to eax
|
||||
mov sFileInfo.FileInfo@@mlpBufferPointer,eax ; move address of buffer to lpBufferPointer
|
||||
jmp @@FREADsimpleRead ; grab next byte
|
||||
@@FREADreadError: ; read error sync address
|
||||
xor eax,eax ; set return code
|
||||
jmp @@FREADdone ; we're done
|
||||
@@FREADsimpleRead: ; simple read sync address
|
||||
mov eax,sFileInfo.FileInfo@@mlpBufferPointer ; move address of buffer to eax
|
||||
mov al,byte ptr[eax] ; move byte value to al
|
||||
mov byte ptr[ptrByte],al ; move byte value to user buffer
|
||||
inc sFileInfo.FileInfo@@mlpBufferPointer ; increment along lpBufferPointer
|
||||
dec sFileInfo.FileInfo@@mBufferIndex ; decrement the buffer index
|
||||
mov eax,01h ; set the return code
|
||||
@@FREADdone: ; done reading sync
|
||||
ENDM
|
||||
|
||||
FWRITE MACRO sFileInfo,ptrByte
|
||||
LOCAL @@FWRITEsimpleWrite,@@FWRITEuseBuffer
|
||||
cmp sFileInfo.FileInfo@@mBufferIndex,MaxLength ; compare buffer index to MaxLength
|
||||
jl @@FWRITEsimpleWrite ; if it's less then insert char into buffer
|
||||
WRITEFILE sFileInfo.FileInfo@@mhFileHandle,sFileInfo.FileInfo@@mszBuffer,MaxLength ; other wise
|
||||
mov sFileInfo.FileInfo@@mBufferIndex,0000h ; set buffer index to zero
|
||||
mov eax,offset sFileInfo.FileInfo@@mszBuffer ; move address of buffer to eax
|
||||
mov sFileInfo.FileInfo@@mlpBufferPointer,eax ; move address of buffer to lpBufferPointer
|
||||
@@FWRITEsimpleWrite: ; simple write sync address
|
||||
cmp sFileInfo.FileInfo@@mlpBufferPointer,0000h ; is buffer pointer null?
|
||||
jne @@FWRITEuseBuffer ; if not then just use it
|
||||
mov eax,offset sFileInfo.FileInfo@@mszBuffer ; move address of buffer to eax
|
||||
mov sFileInfo.FileInfo@@mlpBufferPointer,eax ; move address of buffer to lpBufferPointer
|
||||
@@FWRITEuseBuffer: ; use buffer sync address
|
||||
mov cl,byte ptr[ptrByte] ; move byte to write to cl
|
||||
mov eax,sFileInfo.FileInfo@@mlpBufferPointer ; move address of buffer to eax
|
||||
mov byte ptr[eax],cl ; move byte into buffer
|
||||
inc sFileInfo.FileInfo@@mlpBufferPointer ; increment buffer pointer
|
||||
inc sFileInfo.FileInfo@@mBufferIndex ; increment buffer index
|
||||
mov eax,01h ; set return code
|
||||
ENDM
|
||||
|
||||
FFLUSH MACRO sFileInfo
|
||||
LOCAL @@FFLUSHexit
|
||||
cmp sFileInfo.FileInfo@@mhFileHandle,INVALID_HANDLE
|
||||
je @@FFLUSHexit
|
||||
WRITEFILE sFileInfo.FileInfo@@mhFileHandle,sFileInfo.FileInfo@@mszBuffer,sFileInfo.FileInfo@@mBufferIndex ; write buffer to disk
|
||||
mov sFileInfo.FileInfo@@mBufferIndex,0000h ; set buffer index to zero
|
||||
mov eax,offset sFileInfo.FileInfo@@mszBuffer ; move address of buffer to eax
|
||||
mov sFileInfo.FileInfo@@mlpBufferPointer,eax ; move address of buffer to lpBufferPointer
|
||||
@@FFLUSHexit:
|
||||
ENDM
|
||||
|
||||
FGETS MACRO sFileInfo,szBuffer
|
||||
LOCAL @@FGETScont,@@FGETexit,@@FGETsetError,@@FGETScrlf
|
||||
push esi ; save source index register
|
||||
mov esi,offset szBuffer ; move address of buffer into esi
|
||||
@@FGETScont: ; loop control
|
||||
FREAD sFileInfo,esi ; read a byte
|
||||
cmp eax,0000h ; was our read successful?
|
||||
je @@FGETexit ; if not we're done
|
||||
cmp byte ptr[esi],0Dh ; is the byte a carriage return?
|
||||
je @@FGETScrlf ; if yes then jump to handler
|
||||
inc esi ; increment along esi
|
||||
jmp @@FGETScont ; keep reading
|
||||
@@FGETScrlf: ; carriage return control
|
||||
mov byte ptr[esi],00h ; move null into line data
|
||||
sub esp,04h ; create temp var on stack
|
||||
mov esi,esp ; esi points to temp var
|
||||
FREAD sFileInfo,esi ; read line-feed into temp var
|
||||
add esp,04h ; restore stack
|
||||
@@FGETexit: ; exit sync address
|
||||
pop esi ; restore source index register
|
||||
ENDM
|
||||
|
||||
FileInfo STRUC
|
||||
MaxLength equ 800h
|
||||
FileInfo@@mhFileHandle HANDLE <INVALID_HANDLE>
|
||||
FileInfo@@mszBuffer DB MaxLength DUP(0)
|
||||
FileInfo@@mBufferIndex DD (0)
|
||||
FileInfo@@mlpBufferPointer DD (0)
|
||||
FileInfo ENDS
|
||||
|
||||
extrn WriteFile:near
|
||||
extrn CloseHandle:near
|
||||
extrn CreateFileA:near
|
||||
extrn GetLastError:near
|
||||
extrn ReadFile:near
|
||||
|
||||
162
uudecode/TASM/OPENFILE.INC
Normal file
162
uudecode/TASM/OPENFILE.INC
Normal file
@@ -0,0 +1,162 @@
|
||||
;*************************************************************************************
|
||||
; MODULE: OPENFILE.INC DATE: FEBRUARY 2, 1997
|
||||
; AUTHOR: SEAN M. KESSLER
|
||||
; TARGET: 32 BIT FLAT MODEL
|
||||
; FUNCTION : FILE HANDLING MACROS
|
||||
;*************************************************************************************
|
||||
HANDLE STRUC
|
||||
PHANDLE TYPEDEF FAR PTR HANDLE
|
||||
HANDLE@@mHandle DD ?
|
||||
HANDLE ENDS
|
||||
|
||||
INVALID_HANDLE equ 0FFFFFFFFh
|
||||
|
||||
CREATEFILE MACRO pathFileName,access,share,open,attribute
|
||||
push 0000h ; save handle to template (null)
|
||||
push attribute ; save attributes
|
||||
push open ; save creation flags
|
||||
push 0000h ; save security attributes
|
||||
push share ; save share mode
|
||||
push access ; save acess mode
|
||||
push pathFileName ; save pathFileName
|
||||
call CreateFileA ; call create
|
||||
ENDM
|
||||
|
||||
READFILE MACRO hFileHandle,szBuffer,sizeBuffer
|
||||
sub esp,04h ; create bytesRead on stack
|
||||
mov eax,esp ; move bytesRead address to eax
|
||||
push 0000h ; save overlapped structure address
|
||||
push eax ; save pointer to bytesRead
|
||||
push sizeBuffer ; save length of buffer
|
||||
push offset szBuffer ; save address of read buffer
|
||||
push hFileHandle ; save file handle
|
||||
call ReadFile ; call read
|
||||
mov eax,[esp] ; move bytesRead value to eax
|
||||
add esp,04h ; remove bytesRead variable from stack
|
||||
ENDM
|
||||
|
||||
WRITEFILE MACRO hFileHandle,szBuffer,sizeBuffer
|
||||
sub esp,04h ; create bytesWritten variable on stack
|
||||
mov eax,esp ; move bytesWritten address to eax
|
||||
push 0000h ; save overlapped structure address
|
||||
push eax ; save bytesWritten address
|
||||
push sizeBuffer ; save write length
|
||||
push offset szBuffer ; save address of write buffer
|
||||
push hFileHandle ; save file handle
|
||||
call WriteFile ; call write
|
||||
mov eax,[esp] ; move number of bytes written to eax
|
||||
add esp,04h ; remove bytesWritten variable from stack
|
||||
ENDM
|
||||
|
||||
CLOSEHANDLE MACRO handle
|
||||
push handle ; save file handle
|
||||
call CloseHandle ; call close
|
||||
ENDM
|
||||
|
||||
FOPEN MACRO pathFileName,sFileInfo,access,share,open,attribute
|
||||
CREATEFILE pathFileName,access,share,open,attribute
|
||||
mov sFileInfo.FileInfo@@mhFileHandle,eax
|
||||
ENDM
|
||||
|
||||
FCLOSE MACRO sFileInfo
|
||||
LOCAL @@FCLOSEend
|
||||
cmp sFileInfo.FileInfo@@mhFileHandle,INVALID_HANDLE
|
||||
je @@FCLOSEend
|
||||
CLOSEHANDLE sFileInfo.FileInfo@@mhFileHandle
|
||||
mov sFileInfo.FileInfo@@mhFileHandle,INVALID_HANDLE
|
||||
@@FCLOSEend:
|
||||
ENDM
|
||||
|
||||
FREAD MACRO sFileInfo,ptrByte
|
||||
LOCAL @@FREADreadError,@@FREADsimpleRead,@@FREADdone
|
||||
cmp sFileInfo.FileInfo@@mBufferIndex,00h ; is buffer index zero
|
||||
jne @@FREADsimpleRead ; if not then just grab next byte
|
||||
READFILE sFileInfo.FileInfo@@mhFileHandle,sFileInfo.FileInfo@@mszBuffer,MaxLength ; otherwise we fill the read buffer
|
||||
cmp eax,0000h ; did we read any data ?
|
||||
je @@FREADreadError ; if not then we're done
|
||||
mov sFileInfo.FileInfo@@mBufferIndex,eax ; move number of bytes read to buffer index
|
||||
mov eax,offset sFileInfo.FileInfo@@mszBuffer ; move address of buffer to eax
|
||||
mov sFileInfo.FileInfo@@mlpBufferPointer,eax ; move address of buffer to lpBufferPointer
|
||||
jmp @@FREADsimpleRead ; grab next byte
|
||||
@@FREADreadError: ; read error sync address
|
||||
xor eax,eax ; set return code
|
||||
jmp @@FREADdone ; we're done
|
||||
@@FREADsimpleRead: ; simple read sync address
|
||||
mov eax,sFileInfo.FileInfo@@mlpBufferPointer ; move address of buffer to eax
|
||||
mov al,byte ptr[eax] ; move byte value to al
|
||||
mov byte ptr[ptrByte],al ; move byte value to user buffer
|
||||
inc sFileInfo.FileInfo@@mlpBufferPointer ; increment along lpBufferPointer
|
||||
dec sFileInfo.FileInfo@@mBufferIndex ; decrement the buffer index
|
||||
mov eax,01h ; set the return code
|
||||
@@FREADdone: ; done reading sync
|
||||
ENDM
|
||||
|
||||
FWRITE MACRO sFileInfo,ptrByte
|
||||
LOCAL @@FWRITEsimpleWrite,@@FWRITEuseBuffer
|
||||
cmp sFileInfo.FileInfo@@mBufferIndex,MaxLength ; compare buffer index to MaxLength
|
||||
jl @@FWRITEsimpleWrite ; if it's less then insert char into buffer
|
||||
WRITEFILE sFileInfo.FileInfo@@mhFileHandle,sFileInfo.FileInfo@@mszBuffer,MaxLength ; other wise
|
||||
mov sFileInfo.FileInfo@@mBufferIndex,0000h ; set buffer index to zero
|
||||
mov eax,offset sFileInfo.FileInfo@@mszBuffer ; move address of buffer to eax
|
||||
mov sFileInfo.FileInfo@@mlpBufferPointer,eax ; move address of buffer to lpBufferPointer
|
||||
@@FWRITEsimpleWrite: ; simple write sync address
|
||||
cmp sFileInfo.FileInfo@@mlpBufferPointer,0000h ; is buffer pointer null?
|
||||
jne @@FWRITEuseBuffer ; if not then just use it
|
||||
mov eax,offset sFileInfo.FileInfo@@mszBuffer ; move address of buffer to eax
|
||||
mov sFileInfo.FileInfo@@mlpBufferPointer,eax ; move address of buffer to lpBufferPointer
|
||||
@@FWRITEuseBuffer: ; use buffer sync address
|
||||
mov cl,byte ptr[ptrByte] ; move byte to write to cl
|
||||
mov eax,sFileInfo.FileInfo@@mlpBufferPointer ; move address of buffer to eax
|
||||
mov byte ptr[eax],cl ; move byte into buffer
|
||||
inc sFileInfo.FileInfo@@mlpBufferPointer ; increment buffer pointer
|
||||
inc sFileInfo.FileInfo@@mBufferIndex ; increment buffer index
|
||||
mov eax,01h ; set return code
|
||||
ENDM
|
||||
|
||||
FFLUSH MACRO sFileInfo
|
||||
LOCAL @@FFLUSHexit
|
||||
cmp sFileInfo.FileInfo@@mhFileHandle,INVALID_HANDLE
|
||||
je @@FFLUSHexit
|
||||
WRITEFILE sFileInfo.FileInfo@@mhFileHandle,sFileInfo.FileInfo@@mszBuffer,sFileInfo.FileInfo@@mBufferIndex ; write buffer to disk
|
||||
mov sFileInfo.FileInfo@@mBufferIndex,0000h ; set buffer index to zero
|
||||
mov eax,offset sFileInfo.FileInfo@@mszBuffer ; move address of buffer to eax
|
||||
mov sFileInfo.FileInfo@@mlpBufferPointer,eax ; move address of buffer to lpBufferPointer
|
||||
@@FFLUSHexit:
|
||||
ENDM
|
||||
|
||||
FGETS MACRO sFileInfo,szBuffer
|
||||
LOCAL @@FGETScont,@@FGETexit,@@FGETsetError,@@FGETScrlf
|
||||
push esi ; save source index register
|
||||
mov esi,offset szBuffer ; move address of buffer into esi
|
||||
@@FGETScont: ; loop control
|
||||
FREAD sFileInfo,esi ; read a byte
|
||||
cmp eax,0000h ; was our read successful?
|
||||
je @@FGETexit ; if not we're done
|
||||
cmp byte ptr[esi],0Dh ; is the byte a carriage return?
|
||||
je @@FGETScrlf ; if yes then jump to handler
|
||||
inc esi ; increment along esi
|
||||
jmp @@FGETScont ; keep reading
|
||||
@@FGETScrlf: ; carriage return control
|
||||
mov byte ptr[esi],00h ; move null into line data
|
||||
sub esp,04h ; create temp var on stack
|
||||
mov esi,esp ; esi points to temp var
|
||||
FREAD sFileInfo,esi ; read line-feed into temp var
|
||||
add esp,04h ; restore stack
|
||||
@@FGETexit: ; exit sync address
|
||||
pop esi ; restore source index register
|
||||
ENDM
|
||||
|
||||
FileInfo STRUC
|
||||
MaxLength equ 800h
|
||||
FileInfo@@mhFileHandle HANDLE <INVALID_HANDLE>
|
||||
FileInfo@@mszBuffer DB MaxLength DUP(0)
|
||||
FileInfo@@mBufferIndex DD (0)
|
||||
FileInfo@@mlpBufferPointer DD (0)
|
||||
FileInfo ENDS
|
||||
|
||||
extrn WriteFile:near
|
||||
extrn CloseHandle:near
|
||||
extrn CreateFileA:near
|
||||
extrn GetLastError:near
|
||||
extrn ReadFile:near
|
||||
|
||||
113
uudecode/TASM/STRING.INC
Normal file
113
uudecode/TASM/STRING.INC
Normal file
@@ -0,0 +1,113 @@
|
||||
;*************************************************************************************
|
||||
; MODULE: STRING.INC DATE: FEBRUARY 2, 1997
|
||||
; AUTHOR: SEAN M. KESSLER
|
||||
; TARGET: 32 BIT FLAT MODEL
|
||||
; FUNCTION : STRING RELATED MACROS
|
||||
;*************************************************************************************
|
||||
STRSTR MACRO szStringOne,szStringTwo
|
||||
push offset szStringTwo ; save string one
|
||||
push offset szStringOne ; save string two
|
||||
call _strstr ; call standard library strstr
|
||||
add esp,08h ; reset stack frame
|
||||
ENDM
|
||||
|
||||
STRCHR MACRO szString,charByte
|
||||
push charByte ; save charByte
|
||||
push offset szString ; save string
|
||||
call _strchr ; call standard library strchr
|
||||
add esp,08h ; reset stack frame
|
||||
ENDM
|
||||
|
||||
STRCAT MACRO szDstString,szSrcString
|
||||
push offset szSrcString ; save source string
|
||||
push offset szDstString ; save destination string
|
||||
call _strcat ; call standard library strcat
|
||||
add esp,08h ; reset stack frame
|
||||
ENDM
|
||||
|
||||
STRLEN MACRO szData
|
||||
push edi ; save destination index register
|
||||
push ecx ; save ecx register
|
||||
mov edi,offset szData ; get string to destination index register
|
||||
mov ecx,0FFFFh ; move 65535 to ecx register
|
||||
xor eax,eax ; clear eax register
|
||||
repnz scasb ; scan string
|
||||
mov eax,0FFFFh ; move 65535 to eax
|
||||
sub eax,ecx ; subtract number of bytes scanned
|
||||
dec eax ; decrement result
|
||||
pop ecx ; restore ecx register
|
||||
pop edi ; restore destination index register
|
||||
ENDM
|
||||
|
||||
MEMCPY MACRO szDstData,szSrcData,lengthCopy
|
||||
push esi ; save source index register
|
||||
push edi ; save destination index register
|
||||
mov esi,offset szSrcData ; move source data to source index register
|
||||
mov edi,offset szDstData ; move destination data to destination index register
|
||||
mov ecx,lengthCopy ; move number of bytes to copy to ecx register
|
||||
rep movsb ; copy data
|
||||
pop edi ; restore destination index register
|
||||
pop esi ; restore source index register
|
||||
ENDM
|
||||
|
||||
STRCMP MACRO szStringOne,szStringTwo
|
||||
LOCAL @@STRCMPnotEqual,@@STRCMPequal,@@STRCMPexit
|
||||
push ecx ; save ecx register
|
||||
push edi ; save destination index register
|
||||
push esi ; save source index register
|
||||
mov edi,offset szStringOne ; move string one to destination index register
|
||||
mov esi,offset szStringTwo ; move string two to source index register
|
||||
STRLEN szStringOne ; get length of string one
|
||||
mov ecx,eax ; save length to ecx register
|
||||
STRLEN szStringTwo ; get length of string two
|
||||
cmp ecx,eax ; compare lengths
|
||||
jne @@STRCMPnotEqual ; if lengths differ, strings are not equal
|
||||
@@STRCMPloop: ; loop control
|
||||
mov al,byte ptr[esi] ; get byte from string two
|
||||
cmp al,byte ptr[edi] ; compare with byte from string one
|
||||
jne @@STRCMPnotEqual ; if bytes differ then we're done
|
||||
loop @@STRCMPloop ; iterate through string length
|
||||
@@STRCMPequal: ; equality control
|
||||
mov eax,0001h ; set return code
|
||||
jmp @@STRCMPexit ; we're done
|
||||
@@STRCMPnotEqual: ; inequality control
|
||||
xor eax,eax ; set return code
|
||||
@@STRCMPexit: ; exit sync address
|
||||
pop esi ; restore source index register
|
||||
pop edi ; restore destination index register
|
||||
pop ecx ; restore ecx register
|
||||
ENDM
|
||||
|
||||
STRNCMP MACRO szStringOne,szStringTwo
|
||||
LOCAL @@STRNCMPloop,@@STRNCMPequal,@@STRNCMPnotEqual,@@STRNCMPexit
|
||||
push ecx ; save ecx register
|
||||
push edi ; save edi register
|
||||
push esi ; save source index register
|
||||
mov edi,offset szStringOne ; move string one to destination index register
|
||||
mov esi,offset szStringTwo ; move string two to source index register
|
||||
STRLEN szStringOne ; get length of string one
|
||||
mov ecx,eax ; save length to ecx register
|
||||
STRLEN szStringTwo ; get length of string two
|
||||
cmp ecx,eax ; compare the lengths
|
||||
jle @@STRNCMPloop ; string one is less equal to string two
|
||||
mov ecx,eax ; string two is less, so use it's length
|
||||
@@STRNCMPloop: ; loop control
|
||||
mov al,byte ptr[esi] ; get byte from string one
|
||||
cmp al,byte ptr[edi] ; compare with byte from string two
|
||||
jne @@STRNCMPnotEqual ; if byte are unequal, strings are unequal
|
||||
inc edi ; increment along string two
|
||||
inc esi ; increment along string one
|
||||
loop @@STRNCMPloop ; keep going
|
||||
@@STRNCMPequal: ; string equal sync address
|
||||
mov eax,0001h ; set return code
|
||||
jmp @@STRNCMPexit ; we're done
|
||||
@@STRNCMPnotEqual: ; string unequal sync address
|
||||
xor eax,eax ; set return code
|
||||
@@STRNCMPexit: ; exit sync address
|
||||
pop esi ; restore source index register
|
||||
pop edi ; restore destination index register
|
||||
pop ecx ; restore ecx register
|
||||
ENDM
|
||||
extrn _strstr:near
|
||||
extrn _strchr:near
|
||||
extrn _strcat:near
|
||||
191
uudecode/TASM/UUDECODE.ASM
Normal file
191
uudecode/TASM/UUDECODE.ASM
Normal file
@@ -0,0 +1,191 @@
|
||||
;*************************************************************************************
|
||||
; MODULE: DECODE64.ASM DATE: JANUARY 27,1997
|
||||
; AUTHOR: SEAN M. KESSLER
|
||||
; TARGET: 32 BIT LAT MODEL
|
||||
; FUNCTION : BASE64 DECODER
|
||||
;*************************************************************************************
|
||||
.386
|
||||
.MODEL FLAT
|
||||
INCLUDE devioctl.inc
|
||||
INCLUDE string.inc
|
||||
INCLUDE openfile.inc
|
||||
LOCALS
|
||||
|
||||
DECODEBYTE MACRO index,offset
|
||||
mov al,byte ptr [index+offset] ; get byte at index register + offset
|
||||
sub al,' ' ; subtract space
|
||||
and al,3Fh ; and with 3Fh
|
||||
ENDM
|
||||
|
||||
.DATA
|
||||
inputFile FileInfo <>
|
||||
outputFile FileInfo <>
|
||||
szBeginLine DB 'begin ',0000h
|
||||
szEndLine DB 'end',0000h
|
||||
szLineData DB 400h DUP(0)
|
||||
numItem DB (0)
|
||||
charByte DB (0)
|
||||
status DD (0)
|
||||
szOutputPathFileName DB 0FFh DUP(0)
|
||||
szInputPathFileName DD ?
|
||||
.CODE
|
||||
_uudecode proc near ; void uudecode(char *szInputPathFileName)
|
||||
push ebp ; save stack frame
|
||||
mov ebp,esp ; create new frame
|
||||
push esi ; save source index register
|
||||
push edi ; save destination index register
|
||||
push dword ptr[ebp+08h] ; save inputPathFileName
|
||||
pop szInputPathFileName ; restore into szInputPathFileName
|
||||
cmp szInputPathFileName,0000h ; is the file name null
|
||||
je @@errorExit ; if so then we're done
|
||||
FOPEN szInputPathFileName,inputFile,GENERIC_READ,FILE_SHARE_READ,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL
|
||||
cmp eax,INVALID_HANDLE
|
||||
je @@errorExit
|
||||
@@munchLoop:
|
||||
FGETS inputFile,szLineData ; read a line
|
||||
cmp eax,0000h ; did the read succeed ?
|
||||
je @@endRead ; if not then we're done
|
||||
STRNCMP szBeginLine,szLineData ; compare line to signature
|
||||
cmp eax,0001h ; did we find the signature
|
||||
jne @@munchLoop ; if not then keep reading
|
||||
call _getOutputFileName ; get output file name
|
||||
mov esi,offset szOutputPathFileName
|
||||
FOPEN esi,outputFile,GENERIC_WRITE,FILE_SHARE_READ,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL
|
||||
cmp eax,INVALID_HANDLE ; was there a problem creating the output file
|
||||
je @@endRead ; if so then we're done
|
||||
@@readLoop: ; read loop sync address
|
||||
mov esi,offset szLineData ; assign input line address to esi
|
||||
FGETS inputFile,szLineData ; read an input line
|
||||
cmp eax,0000h ; check for read error
|
||||
je @@endDecode ; if there was an error, then we're done
|
||||
xor eax,eax ; clear eax register
|
||||
DECODEBYTE esi,00h ; decode the byte
|
||||
mov numItem,al ; move the decoded item into numItem
|
||||
cmp numItem,0000h ; compare numItem to zero
|
||||
jle @@endDecode ; if it's less than or equal, we're done
|
||||
inc esi ; increment line pointer
|
||||
@@decodeLoop: ; decode loop sync address
|
||||
cmp numItem,0000h ; compare numItem to zero
|
||||
jle @@readLoop ; if it's less than or equal, get another line
|
||||
cmp numItem,0003h ; compare numItem to 3
|
||||
jge @@handleItemFGE3 ; handle (numItem>=3)
|
||||
cmp numItem,0001h ; compare numItem to 1
|
||||
jge @@handleItemGE1 ; handle (numItem>=1)
|
||||
@@GE1Ret: ; return sync address
|
||||
cmp numItem,0002h ; compare numItem to 2
|
||||
jge @@handleItemGE2 ; handle (numItem>=2)
|
||||
@@GE2Ret: ; return sync address
|
||||
cmp numItem,0003h ; compare numItem to 3
|
||||
jge @@handleItemGE3 ; handle (numItem>=3)
|
||||
@@GE3Ret: ; return sync address
|
||||
add esi,0004h ; increment line pointer
|
||||
sub numItem,0003h ; subtract 3 from numItem
|
||||
jmp @@decodeLoop ; keep going
|
||||
@@handleItemFGE3: ; return sunc address
|
||||
DECODEBYTE esi,00h ; decode the byte
|
||||
mov cl,02h ; move shift value into cl register
|
||||
shl ax,cl ; perform left shift
|
||||
mov charByte,al ; save value into charByte
|
||||
DECODEBYTE esi,01h ; decode the byte
|
||||
mov cl,04h ; move shift value into cl register
|
||||
shr al,cl ; perform right shift
|
||||
or charByte,al ; or result with saved value
|
||||
FWRITE outputFile,charByte ; write out the char
|
||||
DECODEBYTE esi,01h ; decode byte
|
||||
mov cl,04h ; move shift value into cl register
|
||||
shl ax,cl ; perform left shift
|
||||
mov charByte,al ; save value into charByte
|
||||
DECODEBYTE esi,02h ; decode byte
|
||||
mov cl,02h ; move shift value into cl register
|
||||
shr al,cl ; perform right shift
|
||||
or charByte,al ; or result with saved value
|
||||
FWRITE outputFile,charByte ; write out the char
|
||||
DECODEBYTE esi,02h ; decode byte
|
||||
mov cl,06h ; move shift value into cl register
|
||||
shl ax,cl ; perform left shift
|
||||
mov charByte,al ; save value into charByte
|
||||
DECODEBYTE esi,03h ; decode byte
|
||||
or charByte,al ; or result with saved value
|
||||
FWRITE outputFile,charByte ; write out the char
|
||||
jmp @@GE3Ret ; jump back
|
||||
@@handleItemGE1: ; (numItem>=1) sync address
|
||||
DECODEBYTE esi,00h ; decode byte
|
||||
mov cl,02h ; move shift value into cl register
|
||||
shl ax,cl ; perform left shift
|
||||
mov charByte,al ; save result into charByte
|
||||
DECODEBYTE esi,01h ; decode byte
|
||||
mov cl,04h ; mov shift value into cl register
|
||||
shr ax,cl ; perform right shift
|
||||
or charByte,al ; or the result into charByte
|
||||
FWRITE outputFile,charByte ; write out the byte
|
||||
jmp @@GE1Ret ; return
|
||||
@@handleItemGE2: ; (numItem>=2) sync address
|
||||
DECODEBYTE esi,01h ; decode byte
|
||||
mov cl,04h ; move shift value into cl register
|
||||
shl ax,cl ; perform left shift
|
||||
mov charByte,al ; save result into charByte
|
||||
DECODEBYTE esi,02h ; decode byte
|
||||
mov cl,02h ; move shift value into cl register
|
||||
shr ax,cl ; perform right shift
|
||||
or charByte,al ; or result into charByte
|
||||
FWRITE outputFile,charByte ; write out the byte
|
||||
jmp @@GE2Ret ; return
|
||||
@@handleItemGE3: ; (numItem>=3) sync address
|
||||
DECODEBYTE esi,02h ; decode byte
|
||||
mov cl,06h ; move shift value into cl register
|
||||
shl ax,cl ; perform left shift
|
||||
mov charByte,al ; save result into charByte
|
||||
DECODEBYTE esi,03h ; decode byte
|
||||
or charByte,al ; or result with charByte
|
||||
FWRITE outputFile,charByte ; write out the byte
|
||||
jmp @@GE3Ret ; return
|
||||
@@endDecode: ; end decode sync address
|
||||
FGETS inputFile,szLineData ; get final line from input file s/b 'end'
|
||||
STRNCMP szLineData,szEndLine ; compare last line to endLine
|
||||
cmp eax,0000h ; check return
|
||||
je @@setError ; if it's not equal to 'end' we've got an error
|
||||
mov status,0001h ; set success
|
||||
jmp @@endRead ; skip over next instruction(s)
|
||||
@@setError: ; setError sync address
|
||||
mov status,0000h ; set failure
|
||||
@@endRead: ; end read sync address
|
||||
FCLOSE inputFile ; close input file
|
||||
FFLUSH outputFile ; flush output file
|
||||
FCLOSE outputFile ; close output file
|
||||
@@errorExit: ; error exit sync address
|
||||
mov eax,status ; set return code
|
||||
pop edi ; restore destination index register
|
||||
pop esi ; restore source index register
|
||||
pop ebp ; restore previous stack frame
|
||||
retn ; return near to caller
|
||||
_uudecode endp
|
||||
_getOutputFileName proc near
|
||||
push ebp ; save stack frame
|
||||
mov ebp,esp ; create new frame
|
||||
push esi ; save source index register
|
||||
push edi ; save destination index register
|
||||
mov esi,offset szLineData ; move input line address into source index
|
||||
mov edi,offset szOutputPathFileName ; move output file name buffer into destination index
|
||||
xor ecx,ecx ; clear ecx register for counting
|
||||
@@munchLoop: ; munch loop sync address
|
||||
mov al,byte ptr[esi] ; get byte from input line
|
||||
inc esi ; increment esi along input line
|
||||
cmp al,' ' ; did we read a space
|
||||
jne @@munchLoop ; if not then keep reading
|
||||
inc ecx ; increment space counter
|
||||
cmp ecx,0002h ; is this the second space
|
||||
jne @@munchLoop ; if not then keep reading
|
||||
@@copyLoop: ; copy loop sync address
|
||||
mov al,byte ptr[esi] ; get source byte into al register
|
||||
mov byte ptr[edi],al ; copy byte into destination
|
||||
inc esi ; increment along source line
|
||||
inc edi ; increment along destination
|
||||
cmp al,0000h ; compare input byte to zero
|
||||
jne @@copyLoop ; if it's not null then keep going
|
||||
pop edi ; restore destination index register
|
||||
pop esi ; restore source index register
|
||||
pop ebp ; restore stack frame
|
||||
retn ; return near to caller
|
||||
_getOutputFileName endp
|
||||
public _uudecode
|
||||
END
|
||||
191
uudecode/TASM/UUDECODE.BAK
Normal file
191
uudecode/TASM/UUDECODE.BAK
Normal file
@@ -0,0 +1,191 @@
|
||||
;*************************************************************************************
|
||||
; MODULE: DECODE64.ASM DATE: JANUARY 27,1997
|
||||
; AUTHOR: SEAN M. KESSLER
|
||||
; TARGET: 32 BIT LAT MODEL
|
||||
; FUNCTION : BASE64 DECODER
|
||||
;*************************************************************************************
|
||||
.386
|
||||
.MODEL FLAT
|
||||
INCLUDE devioctl.inc
|
||||
INCLUDE string.inc
|
||||
INCLUDE openfile.inc
|
||||
LOCALS
|
||||
|
||||
DECODEBYTE MACRO index,offset
|
||||
mov al,byte ptr [index+offset] ; get byte at index register + offset
|
||||
sub al,' ' ; subtract space
|
||||
and al,3Fh ; and with 3Fh
|
||||
ENDM
|
||||
|
||||
.DATA
|
||||
inputFile FileInfo <>
|
||||
outputFile FileInfo <>
|
||||
szBeginLine DB 'begin ',0000h
|
||||
szEndLine DB 'end',0000h
|
||||
szLineData DB 400h DUP(0)
|
||||
numItem DB (0)
|
||||
charByte DB (0)
|
||||
status DD (0)
|
||||
szOutputPathFileName DB 0FFh DUP(0)
|
||||
szInputPathFileName DD ?
|
||||
.CODE
|
||||
_uudecode proc near ; void uudecode(char *szInputPathFileName)
|
||||
push ebp ; save stack frame
|
||||
mov ebp,esp ; create new frame
|
||||
push esi ; save source index register
|
||||
push edi ; save destination index register
|
||||
push dword ptr[ebp+08h] ; save inputPathFileName
|
||||
pop szInputPathFileName ; restore into szInputPathFileName
|
||||
cmp szInputPathFileName,0000h ; is the file name null
|
||||
je @@errorExit ; if so then we're done
|
||||
FOPEN szInputPathFileName,inputFile,GENERIC_READ,FILE_SHARE_READ,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL
|
||||
cmp eax,INVALID_HANDLE
|
||||
je @@errorExit
|
||||
@@munchLoop:
|
||||
FGETS inputFile,szLineData ; read a line
|
||||
cmp eax,0000h ; did the read succeed ?
|
||||
je @@endRead ; if not then we're done
|
||||
STRNCMP szBeginLine,szLineData ; compare line to signature
|
||||
cmp eax,0001h ; did we find the signature
|
||||
jne @@munchLoop ; if not then keep reading
|
||||
call _getOutputFileName ; get output file name
|
||||
mov esi,offset szOutputPathFileName
|
||||
FOPEN esi,outputFile,GENERIC_WRITE,FILE_SHARE_READ,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL
|
||||
cmp eax,INVALID_HANDLE ; was there a problem creating the output file
|
||||
je @@endRead ; if so then we're done
|
||||
@@readLoop: ; read loop sync address
|
||||
mov esi,offset szLineData ; assign input line address to esi
|
||||
FGETS inputFile,szLineData ; read an input line
|
||||
cmp eax,0000h ; check for read error
|
||||
je @@endDecode ; if there was an error, then we're done
|
||||
xor eax,eax ; clear eax register
|
||||
DECODEBYTE esi,00h ; decode the byte
|
||||
mov numItem,al ; move the decoded item into numItem
|
||||
cmp numItem,0000h ; compare numItem to zero
|
||||
jle @@endDecode ; if it's less than or equal, we're done
|
||||
inc esi ; increment line pointer
|
||||
@@decodeLoop: ; decode loop sync address
|
||||
cmp numItem,0000h ; compare numItem to zero
|
||||
jle @@readLoop ; if it's less than or equal, get another line
|
||||
cmp numItem,0003h ; compare numItem to 3
|
||||
jge @@handleItemFGE3 ; handle (numItem>=3)
|
||||
cmp numItem,0001h ; compare numItem to 1
|
||||
jge @@handleItemGE1 ; handle (numItem>=1)
|
||||
@@GE1Ret: ; return sync address
|
||||
cmp numItem,0002h ; compare numItem to 2
|
||||
jge @@handleItemGE2 ; handle (numItem>=2)
|
||||
@@GE2Ret: ; return sync address
|
||||
cmp numItem,0003h ; compare numItem to 3
|
||||
jge @@handleItemGE3 ; handle (numItem>=3)
|
||||
@@GE3Ret: ; return sync address
|
||||
add esi,0004h ; increment line pointer
|
||||
sub numItem,0003h ; subtract 3 from numItem
|
||||
jmp @@decodeLoop ; keep going
|
||||
@@handleItemFGE3: ; return sunc address
|
||||
DECODEBYTE esi,00h ; decode the byte
|
||||
mov cl,02h ; move shift value into cl register
|
||||
shl ax,cl ; perform left shift
|
||||
mov charByte,al ; save value into charByte
|
||||
DECODEBYTE esi,01h ; decode the byte
|
||||
mov cl,04h ; move shift value into cl register
|
||||
shr al,cl ; perform right shift
|
||||
or charByte,al ; or result with saved value
|
||||
FWRITE outputFile,charByte ; write out the char
|
||||
DECODEBYTE esi,01h ; decode byte
|
||||
mov cl,04h ; move shift value into cl register
|
||||
shl ax,cl ; perform left shift
|
||||
mov charByte,al ; save value into charByte
|
||||
DECODEBYTE esi,02h ; decode byte
|
||||
mov cl,02h ; move shift value into cl register
|
||||
shr al,cl ; perform right shift
|
||||
or charByte,al ; or result with saved value
|
||||
FWRITE outputFile,charByte ; write out the char
|
||||
DECODEBYTE esi,02h ; decode byte
|
||||
mov cl,06h ; move shift value into cl register
|
||||
shl ax,cl ; perform left shift
|
||||
mov charByte,al ; save value into charByte
|
||||
DECODEBYTE esi,03h ; decode byte
|
||||
or charByte,al ; or result with saved value
|
||||
FWRITE outputFile,charByte ; write out the char
|
||||
jmp @@GE3Ret ; jump back
|
||||
@@handleItemGE1: ; (numItem>=1) sync address
|
||||
DECODEBYTE esi,00h ; decode byte
|
||||
mov cl,02h ; move shift value into cl register
|
||||
shl ax,cl ; perform left shift
|
||||
mov charByte,al ; save result into charByte
|
||||
DECODEBYTE esi,01h ; decode byte
|
||||
mov cl,04h ; mov shift value into cl register
|
||||
shr ax,cl ; perform right shift
|
||||
or charByte,al ; or the result into charByte
|
||||
FWRITE outputFile,charByte ; write out the byte
|
||||
jmp @@GE1Ret ; return
|
||||
@@handleItemGE2: ; (numItem>=2) sync address
|
||||
DECODEBYTE esi,01h ; decode byte
|
||||
mov cl,04h ; move shift value into cl register
|
||||
shl ax,cl ; perform left shift
|
||||
mov charByte,al ; save result into charByte
|
||||
DECODEBYTE esi,02h ; decode byte
|
||||
mov cl,02h ; move shift value into cl register
|
||||
shr ax,cl ; perform right shift
|
||||
or charByte,al ; or result into charByte
|
||||
FWRITE outputFile,charByte ; write out the byte
|
||||
jmp @@GE2Ret ; return
|
||||
@@handleItemGE3: ; (numItem>=3) sync address
|
||||
DECODEBYTE esi,02h ; decode byte
|
||||
mov cl,06h ; move shift value into cl register
|
||||
shl ax,cl ; perform left shift
|
||||
mov charByte,al ; save result into charByte
|
||||
DECODEBYTE esi,03h ; decode byte
|
||||
or charByte,al ; or result with charByte
|
||||
FWRITE outputFile,charByte ; write out the byte
|
||||
jmp @@GE3Ret ; return
|
||||
@@endDecode: ; end decode sync address
|
||||
FGETS inputFile,szLineData ; get final line from input file s/b 'end'
|
||||
STRNCMP szLineData,szEndLine ; compare last line to endLine
|
||||
cmp eax,0000h ; check return
|
||||
je @@setError ; if it's not equal to 'end' we've got an error
|
||||
mov status,0001h ; set success
|
||||
jmp @@endRead ; skip over next instruction(s)
|
||||
@@setError: ; setError sync address
|
||||
mov status,0000h ; set failure
|
||||
@@endRead: ; end read sync address
|
||||
FCLOSE inputFile ; close input file
|
||||
FFLUSH outputFile ; flush output file
|
||||
FCLOSE outputFile ; close output file
|
||||
@@errorExit: ; error exit sync address
|
||||
mov eax,status ; set return code
|
||||
pop edi ; restore destination index register
|
||||
pop esi ; restore source index register
|
||||
pop ebp ; restore previous stack frame
|
||||
retn ; return near to caller
|
||||
_uudecode endp
|
||||
_getOutputFileName proc near
|
||||
push ebp ; save stack frame
|
||||
mov ebp,esp ; create new frame
|
||||
push esi ; save source index register
|
||||
push edi ; save destination index register
|
||||
mov esi,offset szLineData ; move input line address into source index
|
||||
mov edi,offset szOutputPathFileName ; move output file name buffer into destination index
|
||||
xor ecx,ecx ; clear ecx register for counting
|
||||
@@munchLoop: ; munch loop sync address
|
||||
mov al,byte ptr[esi] ; get byte from input line
|
||||
inc esi ; increment esi along input line
|
||||
cmp al,' ' ; did we read a space
|
||||
jne @@munchLoop ; if not then keep reading
|
||||
inc ecx ; increment space counter
|
||||
cmp ecx,0002h ; is this the second space
|
||||
jne @@munchLoop ; if not then keep reading
|
||||
@@copyLoop: ; copy loop sync address
|
||||
mov al,byte ptr[esi] ; get source byte into al register
|
||||
mov byte ptr[edi],al ; copy byte into destination
|
||||
inc esi ; increment along source line
|
||||
inc edi ; increment along destination
|
||||
cmp al,0000h ; compare input byte to zero
|
||||
jne @@copyLoop ; if it's not null then keep going
|
||||
pop edi ; restore destination index register
|
||||
pop esi ; restore source index register
|
||||
pop ebp ; restore stack frame
|
||||
retn ; return near to caller
|
||||
_getOutputFileName endp
|
||||
public _uudecode
|
||||
END
|
||||
BIN
uudecode/TASM/UUDECODE.DSW
Normal file
BIN
uudecode/TASM/UUDECODE.DSW
Normal file
Binary file not shown.
BIN
uudecode/TASM/UUDECODE.IDE
Normal file
BIN
uudecode/TASM/UUDECODE.IDE
Normal file
Binary file not shown.
Reference in New Issue
Block a user