Skip to content

Commit 5d426c4

Browse files
author
Christopher Gurnee
committed
use argument symbols in SimpleString.c asm code
Previously the argument addresses were being calculated by hand, which required the Frame Pointer Omission optimization and disallowed Whole Program Optimization in Win32 builds (so that the calling conventions were predictable). This loosens that requirement and fixes Win32 builds.
1 parent 355020d commit 5d426c4

File tree

3 files changed

+38
-54
lines changed

3 files changed

+38
-54
lines changed

libs/SimpleString.c

Lines changed: 33 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/**
22
* SimpleString Library
3-
* Last modified: 2009/01/06
4-
* Copyright (C) Kai Liu. All rights reserved.
3+
* Last modified: 2012/12/07
4+
* Original work copyright (C) Kai Liu. All rights reserved.
5+
* Modified work copyright (C) 2014 Christopher Gurnee. All rights reserved.
56
**/
67

78
#include "SimpleString.h"
@@ -19,15 +20,12 @@ PSTR SSCALL SSChainNCpy2FA( PSTR pszDest, PCSTR pszSrc1, SIZE_T cch1,
1920
{
2021
__asm
2122
{
22-
// The auto-generated pushing of edi and esi onto the stack means that
23-
// our esp is offset by 8 bytes
24-
25-
mov edi,[esp+0x0C] // pszDest
26-
mov esi,[esp+0x10] // pszSrc1
27-
mov ecx,[esp+0x14] // cch1
23+
mov edi,[pszDest]
24+
mov esi,[pszSrc1]
25+
mov ecx,[cch1]
2826
rep movsb
29-
mov esi,[esp+0x18] // pszSrc2
30-
mov ecx,[esp+0x1C] // cch2
27+
mov esi,[pszSrc2]
28+
mov ecx,[cch2]
3129
rep movsb
3230
xchg eax,edi
3331
}
@@ -39,18 +37,15 @@ PSTR SSCALL SSChainNCpy3FA( PSTR pszDest, PCSTR pszSrc1, SIZE_T cch1,
3937
{
4038
__asm
4139
{
42-
// The auto-generated pushing of edi and esi onto the stack means that
43-
// our esp is offset by 8 bytes
44-
45-
mov edi,[esp+0x0C] // pszDest
46-
mov esi,[esp+0x10] // pszSrc1
47-
mov ecx,[esp+0x14] // cch1
40+
mov edi,[pszDest]
41+
mov esi,[pszSrc1]
42+
mov ecx,[cch1]
4843
rep movsb
49-
mov esi,[esp+0x18] // pszSrc2
50-
mov ecx,[esp+0x1C] // cch2
44+
mov esi,[pszSrc2]
45+
mov ecx,[cch2]
5146
rep movsb
52-
mov esi,[esp+0x20] // pszSrc3
53-
mov ecx,[esp+0x24] // cch3
47+
mov esi,[pszSrc3]
48+
mov ecx,[cch3]
5449
rep movsb
5550
xchg eax,edi
5651
}
@@ -61,15 +56,12 @@ PWSTR SSCALL SSChainNCpy2FW( PWSTR pszDest, PCWSTR pszSrc1, SIZE_T cch1,
6156
{
6257
__asm
6358
{
64-
// The auto-generated pushing of edi and esi onto the stack means that
65-
// our esp is offset by 8 bytes
66-
67-
mov edi,[esp+0x0C] // pszDest
68-
mov esi,[esp+0x10] // pszSrc1
69-
mov ecx,[esp+0x14] // cch1
59+
mov edi,[pszDest]
60+
mov esi,[pszSrc1]
61+
mov ecx,[cch1]
7062
rep movsw
71-
mov esi,[esp+0x18] // pszSrc2
72-
mov ecx,[esp+0x1C] // cch2
63+
mov esi,[pszSrc2]
64+
mov ecx,[cch2]
7365
rep movsw
7466
xchg eax,edi
7567
}
@@ -81,18 +73,15 @@ PWSTR SSCALL SSChainNCpy3FW( PWSTR pszDest, PCWSTR pszSrc1, SIZE_T cch1,
8173
{
8274
__asm
8375
{
84-
// The auto-generated pushing of edi and esi onto the stack means that
85-
// our esp is offset by 8 bytes
86-
87-
mov edi,[esp+0x0C] // pszDest
88-
mov esi,[esp+0x10] // pszSrc1
89-
mov ecx,[esp+0x14] // cch1
76+
mov edi,[pszDest]
77+
mov esi,[pszSrc1]
78+
mov ecx,[cch1]
9079
rep movsw
91-
mov esi,[esp+0x18] // pszSrc2
92-
mov ecx,[esp+0x1C] // cch2
80+
mov esi,[pszSrc2]
81+
mov ecx,[cch2]
9382
rep movsw
94-
mov esi,[esp+0x20] // pszSrc3
95-
mov ecx,[esp+0x24] // cch3
83+
mov esi,[pszSrc3]
84+
mov ecx,[cch3]
9685
rep movsw
9786
xchg eax,edi
9887
}
@@ -102,21 +91,18 @@ PSTR SSCALL SSChainCpyCatA( PSTR pszDest, PCSTR pszSrc1, PCSTR pszSrc2 )
10291
{
10392
__asm
10493
{
105-
// The auto-generated pushing of edi and esi onto the stack means that
106-
// our esp is offset by 8 bytes
107-
10894
xor eax,eax
10995

110-
mov esi,[esp+0x10] // pszSrc1
96+
mov esi,[pszSrc1]
11197
mov edi,esi
11298
or ecx,-1
11399
repnz scasb
114100
not ecx
115101
dec ecx
116-
mov edi,[esp+0x0C] // pszDest
102+
mov edi,[pszDest]
117103
rep movsb
118104

119-
mov esi,[esp+0x14] // pszSrc2
105+
mov esi,[pszSrc2]
120106
push edi
121107
mov edi,esi
122108
or ecx,-1
@@ -133,21 +119,18 @@ PWSTR SSCALL SSChainCpyCatW( PWSTR pszDest, PCWSTR pszSrc1, PCWSTR pszSrc2 )
133119
{
134120
__asm
135121
{
136-
// The auto-generated pushing of edi and esi onto the stack means that
137-
// our esp is offset by 8 bytes
138-
139122
xor eax,eax
140123

141-
mov esi,[esp+0x10] // pszSrc1
124+
mov esi,[pszSrc1]
142125
mov edi,esi
143126
or ecx,-1
144127
repnz scasw
145128
not ecx
146129
dec ecx
147-
mov edi,[esp+0x0C] // pszDest
130+
mov edi, [pszDest]
148131
rep movsw
149132

150-
mov esi,[esp+0x14] // pszSrc2
133+
mov esi, [pszSrc2]
151134
push edi
152135
mov edi,esi
153136
or ecx,-1

libs/SimpleString.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/**
22
* SimpleString Library
33
* Last modified: 2009/01/06
4-
* Copyright (C) Kai Liu. All rights reserved.
4+
* Original work copyright (C) Kai Liu. All rights reserved.
5+
* Modified work copyright (C) 2014 Christopher Gurnee. All rights reserved.
56
*
67
* This is a custom C string library that provides wide-character inline
78
* intrinsics for older compilers as well as some helpful chained functions.
@@ -187,7 +188,7 @@ __forceinline wchar_t * intrin_strcat_w( wchar_t *dest, const wchar_t *src )
187188

188189

189190
#define SSINLINE __forceinline
190-
#define SSCALL __stdcall
191+
#define SSCALL
191192

192193

193194
// BEGIN: SSCpyNCh -------------------------------------------------------------

version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
#define HASHCHECK_NAME_STR "HashCheck Shell Extension"
1212

1313
// Full version: MUST be in the form of major,minor,revision,build
14-
#define HASHCHECK_VERSION_FULL 2,2,1,4
14+
#define HASHCHECK_VERSION_FULL 2,2,2,5
1515

1616
// String version: May be any suitable string
17-
#define HASHCHECK_VERSION_STR "2.2.1.4"
17+
#define HASHCHECK_VERSION_STR "2.2.2.5"
1818

1919
#ifdef _USRDLL
2020
// PE version: MUST be in the form of major.minor

0 commit comments

Comments
 (0)