Commit 448eb275 authored by John Spikowski's avatar John Spikowski

OXSC190203

parent 30252ed0
del c.exe
del t.exe
del co2???.exe
del oxygen32.dll
del oxygen64.dll
......@@ -3,6 +3,7 @@
*.txt
*.o2bas
..\rtl*.inc
..\OXFBSRC\*.bas
-r ..\*.inc
......
......@@ -22,9 +22,13 @@ rollbacks:
'11:16 24/12/2018 Support pre and post '++' '--' macro operators (++/--)
'11:10 18/12/2018 Prepare ert (o2_errno) for renumbering
21:47 03/02/2019 checksum translated to asm (hdrs.inc)
19:08 02/02/2019 Implement checksum in PE files (hdrs.inc)
17:46 23/01/2019 Remove 'void' adjustments fix void* (types decl.inc)
11:10 22/01/2019 Windows Defender false positive oxygen.dll Win32/Fuery.B!ml Unwaders.C!ml
10:51 22/01/2019 Internal unaryh subroutine for 'not' and 'neg" etc
13:34 20/01/2019 Interal array expression flag irx (expr.inc irx)
13:34 20/01/2019 Internal array expression flag irx (expr.inc irx)
13:31 20/01/2019 Perform "conv" before main calc (converterh hiex+=)
13:08 20/01/2019 Support "save" operation switch accum-based (expr.inc tran.inc)
13:38 16/01/2019 Fix 64bit extern variadics (expl.inc block if n)
......
......@@ -1577,9 +1577,9 @@ sub types(int unip,vtp,*ttc,*tuc)
if m
'w2=string(m,"*")+w2 'INDIRECTION
indi+=m : m=0
if typ=-1
typ=cpuw : indi=0 'void *
endif
'if typ=-1
' typ=cpuw : indi=0 'void *
'endif
n or=1
endif
if ascn=91
......@@ -1692,7 +1692,10 @@ sub types(int unip,vtp,*ttc,*tuc)
'------------------------------
'
ctype(wm,k,wr)
if wr="void" then typ=cpuw : lent=0 'IN THIS CONTEXT
'if wr="void"
' 'ASSUME VOID*
' typ=cpuw : lent=cpuw
'endif
v=lent : n=typ ': midspace(wm,b,k)
'
elseif n<typh
......
......@@ -21,13 +21,13 @@ FF FF 00 00 ' 000c
B8 00 00 00 ' 0010
00 00 00 00 ' 0014
40 00 00 00 ' 0018 e_lfanew
$20 ' 32 nulls
$20 ' 001c '32 nulls
hle8 ' 003c 'e8 (cofo) was hl80
'
0E 1F BA 0E ' 0040
00 B4 09 CD ' 0044
21 B8 01 4C ' 0048
CD 21
CD 21 ' 004c
`This program cannot be run in DOS mode.` 0d 0a 00
......@@ -660,6 +660,43 @@ function MakePE(string*fi) as int
endif
'
'
'CALCULATE AND SET CHECKSUM
'==========================
'
int *ck 'checksum
sys ps=strptr(dll)
dword b at ps+60 'PE header offset
@ck=ps+b+0x58 'checksum location
ck=0 'clear checksum
'
uint ls 'byte length of data
ls=len(dll)
'word *pd 'input
xor eax,eax 'uint ca 'checksum accumulator
xor edx,edx 'uint uw 'upper word '
mov rsi,ps '@pd=ps
mov ecx,ls 'int j 'iterator
( 'for j=1 to ls step 2 'each word
mov dx,[rsi] '
add eax,edx ' ca+=pd
mov edx,eax ' uw=ca>>16
shr edx,16 '
and eax,0xffff ' ca and=0xffff
add eax,edx ' ca+=uw
add rsi,2 ' @pd+=2
sub ecx,2 '
jg repeat '
) 'next
'final '
mov edx,eax 'uw=ca>>16
shr edx,16 '
add eax,edx 'ca=uw+ca
and eax,0xffff 'ca and= 0xffff
add eax,ls 'ca+=ls 'add in byte length of data
addr rsi,ck 'ck=ca 'set checksum
mov [rsi],eax '
'
'
'CREATE AND STORE THE FILE
'=========================
'
......
......@@ -18,7 +18,7 @@
uses TimeUtil
'
$ datetimestamp "2019-01-22T10:56:30"
$ datetimestamp "2019-02-03T20:36:03"
$ o2version chr(34)+"0.1.0 "+datetimestamp+chr(34)
'
'DEFINITIONS GROUP
......
/*
int a=0x1ffff
int b
mov eax,0x20000
mov ax,a
print hex(eax)
*/
'/*
'MapFileAndCheckSumA
'https://docs.microsoft.com/en-us/windows/desktop/api/imagehlp/nf-imagehlp-mapfileandchecksuma
'http://www.sunshine2k.de/reversing/tuts/tut_pe.htm
'https://www.codeproject.com/Articles/19326/An-Analysis-of-the-Windows-PE-Checksum-Algorithm
'https://bytepointer.com/resources/microsoft_pe_checksum_algo_distilled.htm
'
! MapFileAndCheckSumA lib "Imagehlp.dll"
'
string fi
string s
fi="oxygen.dll"
getfile fi,s
'
int *ck 'checksum
dword b at strptr(s)+60 'PE header offset
@ck=strptr(s)+b+0x58 'checksum location
'
'CLEAR CHECKSUM
ck=0
'
'CALCULATE CHECKSUM
uint uw 'upper word
uint ls 'byte length of data
uint ca 'checksum accumulator
word *pd 'input
int j 'iterator
ls=len(s)
@pd=strptr(s)
for j=1 to ls step 2 'each word
ca+=pd
uw=ca>>16
ca and=0xffff
ca+=uw
@pd+=2
next
'final
uw=ca>>16
ca=uw+ca
ca and= 0xffff
ca+=ls 'add in byte length of data
'print hex(ca)
'
'SET CHECKSUM
'ck=ca
'putfile fi,s 'testing
'VERIFY
=======
dword e ' error
dword i ' previous checksum
dword o ' new checksum
'
e=MapFileAndCheckSumA("oxygen.dll",@i,@o)
select e
case 2 : print "Could not map the file"
case 3 : print "Could not map a view of the file"
case 1 : print "Could not open the file"
case 4 : print "Could not convert the file name to Unicode"
case else : print hex(i) " " hex(o) " " e '" " hex(crc32(strptr s, len s))
end select
'*/
/*
'01:47 31/01/2019
uses chaos
dword d
int i
string s=getfile("o2tests.o2bas")
d=crc32(strptr s, len s)
dword d
d=-1
print d
*/
/*
'01:47 31/01/2019
$ filename "Checksums.exe"
'uses rtl32
'uses rtl64
uses chaos
uses console
'RtlComputeCrc32 (DWORD dwInitial, const BYTE *pData, INT iLen) result dword
'RtlCrc32 ( void const* Buffer, size_t Size, DWORD InitialCrc ) result dword
'RtlCrc64 ( void const* Buffer, size_t Size, ULONGLONG InitialCrc ) result ulonglong
'string fname="Checksums.o2bas"
string fname="o2tests.o2bas"
string s
'getfile fname, s
s="a"
'print s
https://github.com/Mattiwatti/BSOD10/blob/master/src/ntdll.h'RtlComputeCrc32(
' _In_ ULONG32 PartialCrc,
' _In_ PVOID Buffer,
' _In_ ULONG Length
' );
'NTAPI
'RtlCrc32(
' _In_reads_bytes_(Size) const void *Buffer,
' _In_ size_t Size,
' _In_ DWORD InitialCrc
' );
extern lib "ntdll.dll"
! RtlComputeCrc32
! RtlCrc32
! RtlCrc64
end extern
'printl hex (RtlComputeCrc32 0, s, len s)
'printl right(hex (RtlComputeCrc32 0, s, len(s), 8))
int p=0x04c11db7 'polynomial
int i = Crc32(strptr "", 0)
int a = Crc32(strptr s, len s)
int b = RtlComputeCrc32(0, s, len s)
int c = RtlCrc32(s, len(s),i)
printl right(hex(a),8) " Chaos crc32"
printl right(hex(b),8) " ntdll RtlComputeCrc32"
printl right(hex(c),8) " ntdll RtlCrc32"
'printl hex(RtlCrc32(s, len(s),0)) ": Incorrect."
printl "Enter..."
waitkey
*/
/*
'03:16 28/01/2019
'itr char* deref
uses corewin
FUNCTION MSGBOX(wstring wText, dword mOptions=0) AS LONG
wString wCaption = "PluriBASIC w"
FUNCTION = MessageBoxw(0, wText, wCaption, mOptions)
END FUNCTION
char c="ok char*"
wchar w[100]
w=c
'print w
#show msgbox w,1
*/
/*
function f(sys p, int le) as string
string s=space(le)
copy strptr(s),p,le
#show return s
end function
print f(strptr("12345"),4)
'1234
*/
/*
'14:04 23/01/2019
$filename "t.exe"
uses ..\rtl64
type tt
'a as void*
'b as void*
'void *a,*b
'void*a
'void *b
'void *c
end type
#recordof tt
*/
/*
'12:48 15/01/2019
'oleaut
'https://docs.microsoft.com/en-us/windows/desktop/api/oleauto/nf-oleauto-variantinit
......@@ -63,7 +252,7 @@ y=x+x
'variantcopy y,x
print y.vt " " y.dblval
'print "ok"
'*/
*/
/*
void VariantInit(
......
No preview for this file type
......@@ -471,7 +471,7 @@ function HiMac(int mm, string*s, int*i) as string
b=1
c=0
do
w4=tword(w3,b) 'NEXT PARAM FROM PROTOTYPE
w4=tword(w3,b) 'NEXT PARAM FROM PROTOTYPE
if lenw=0
exit do 'NO FURTHER PARAMS
endif
......@@ -488,7 +488,7 @@ function HiMac(int mm, string*s, int*i) as string
a=0
'
if isxn
w2=w4
w2=w4 'DEFAULT
else
a=1
if ascn=47
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment