summaryrefslogtreecommitdiffstats
path: root/private/unimodem/new/mic/chksum.cpp
diff options
context:
space:
mode:
authorAdam <you@example.com>2020-05-17 05:51:50 +0200
committerAdam <you@example.com>2020-05-17 05:51:50 +0200
commite611b132f9b8abe35b362e5870b74bce94a1e58e (patch)
treea5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/unimodem/new/mic/chksum.cpp
downloadNT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip
Diffstat (limited to 'private/unimodem/new/mic/chksum.cpp')
-rw-r--r--private/unimodem/new/mic/chksum.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/private/unimodem/new/mic/chksum.cpp b/private/unimodem/new/mic/chksum.cpp
new file mode 100644
index 000000000..55e936eaa
--- /dev/null
+++ b/private/unimodem/new/mic/chksum.cpp
@@ -0,0 +1,57 @@
+//
+// Copyright (c) 1996 Microsoft Corporation
+//
+//
+// CHKSUM.CPP -- Implementation Checksum()
+//
+// History:
+// 05/24/96 JosephJ Created
+//
+//
+#include "common.h"
+
+//---------------- ::Checksum -----------------------------------
+// Compute a 32-bit checksum of the specified bytes
+// 0 is retured if pb==NULL or cb==0
+DWORD Checksum(const BYTE *pb, UINT cb)
+{
+ const UINT MAXSIZE = 1024;
+ DWORD dwRet = 0;
+ //DWORD rgdwBuf[MAXSIZE/sizeof(DWORD)];
+
+
+ if (!pb) goto end;
+
+
+ // TODO: replace by crc32
+ while(cb--) {dwRet ^= dwRet<<1 ^ *pb++;}
+
+#if (TODO)
+ // If buffer not dword aligned, we copy it over to a buffer which is,
+ // and pad it
+ if (cb & 0x3)
+ {
+ if (cb>=MAXSIZE)
+ {
+ ASSERT(FALSE);
+ goto end;
+ }
+ CopyMemory(rgdwBuf, pb, cb);
+ }
+#endif (TODO)
+
+end:
+ return dwRet;
+}
+
+
+//---------------- ::AddToChecksumDW ----------------------------
+// Set *pdwChkSum to a new checksum, computed using it's previous value and dw.
+void AddToChecksumDW(DWORD *pdwChkSum, DWORD dw)
+{
+ DWORD rgdw[2];
+ rgdw[0] = *pdwChkSum;
+ rgdw[1] = dw;
+
+ *pdwChkSum = Checksum((const BYTE *) rgdw, sizeof(rgdw));
+}