-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathSMem.cpp
More file actions
66 lines (48 loc) · 1.31 KB
/
SMem.cpp
File metadata and controls
66 lines (48 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// SMem.cpp - Memory functions
//
// Converted from assembly to C++ by ShadowFlare.
// E-mail : blakflare@hotmail.com
// Webpage : http://sfsrealm.hopto.org/
// License information for this code is in license.txt
#include "SMem.h"
#include <stdlib.h>
LPVOID WINAPI SMemAlloc(DWORD dwSize)
{
LPVOID lpMemory = malloc(dwSize);
if (lpMemory) SMemZero(lpMemory,dwSize);
return lpMemory;
}
void WINAPI SMemFree(LPVOID lpvMemory)
{
if (lpvMemory) free(lpvMemory);
}
DWORD WINAPI SMemCopy(LPVOID lpDestination, LPCVOID lpSource, DWORD dwLength)
{
DWORD dwPrevLen = dwLength;
LPDWORD lpdwDestination = (LPDWORD)lpDestination,lpdwSource = (LPDWORD)lpSource;
LPBYTE lpbyDestination,lpbySource;
dwLength >>= 2;
while (dwLength--)
*lpdwDestination++ = *lpdwSource++;
lpbyDestination = (LPBYTE)lpdwDestination;
lpbySource = (LPBYTE)lpdwSource;
dwLength = dwPrevLen;
dwLength &= 3;
while (dwLength--)
*lpbyDestination++ = *lpbySource++;
return dwPrevLen;
}
void WINAPI SMemZero(LPVOID lpDestination, DWORD dwLength)
{
DWORD dwPrevLen = dwLength;
LPDWORD lpdwDestination = (LPDWORD)lpDestination;
LPBYTE lpbyDestination;
dwLength >>= 2;
while (dwLength--)
*lpdwDestination++ = 0;
lpbyDestination = (LPBYTE)lpdwDestination;
dwLength = dwPrevLen;
dwLength &= 3;
while (dwLength--)
*lpbyDestination++ = 0;
}