Skip to content

Commit

Permalink
use argument symbols in SimpleString.c asm code
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Christopher Gurnee committed Dec 7, 2014
1 parent 355020d commit 5d426c4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 54 deletions.
83 changes: 33 additions & 50 deletions libs/SimpleString.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* SimpleString Library
* Last modified: 2009/01/06
* Copyright (C) Kai Liu. All rights reserved.
* Last modified: 2012/12/07
* Original work copyright (C) Kai Liu. All rights reserved.
* Modified work copyright (C) 2014 Christopher Gurnee. All rights reserved.
**/

#include "SimpleString.h"
Expand All @@ -19,15 +20,12 @@ PSTR SSCALL SSChainNCpy2FA( PSTR pszDest, PCSTR pszSrc1, SIZE_T cch1,
{
__asm
{
// The auto-generated pushing of edi and esi onto the stack means that
// our esp is offset by 8 bytes

mov edi,[esp+0x0C] // pszDest
mov esi,[esp+0x10] // pszSrc1
mov ecx,[esp+0x14] // cch1
mov edi,[pszDest]
mov esi,[pszSrc1]
mov ecx,[cch1]
rep movsb
mov esi,[esp+0x18] // pszSrc2
mov ecx,[esp+0x1C] // cch2
mov esi,[pszSrc2]
mov ecx,[cch2]
rep movsb
xchg eax,edi
}
Expand All @@ -39,18 +37,15 @@ PSTR SSCALL SSChainNCpy3FA( PSTR pszDest, PCSTR pszSrc1, SIZE_T cch1,
{
__asm
{
// The auto-generated pushing of edi and esi onto the stack means that
// our esp is offset by 8 bytes

mov edi,[esp+0x0C] // pszDest
mov esi,[esp+0x10] // pszSrc1
mov ecx,[esp+0x14] // cch1
mov edi,[pszDest]
mov esi,[pszSrc1]
mov ecx,[cch1]
rep movsb
mov esi,[esp+0x18] // pszSrc2
mov ecx,[esp+0x1C] // cch2
mov esi,[pszSrc2]
mov ecx,[cch2]
rep movsb
mov esi,[esp+0x20] // pszSrc3
mov ecx,[esp+0x24] // cch3
mov esi,[pszSrc3]
mov ecx,[cch3]
rep movsb
xchg eax,edi
}
Expand All @@ -61,15 +56,12 @@ PWSTR SSCALL SSChainNCpy2FW( PWSTR pszDest, PCWSTR pszSrc1, SIZE_T cch1,
{
__asm
{
// The auto-generated pushing of edi and esi onto the stack means that
// our esp is offset by 8 bytes

mov edi,[esp+0x0C] // pszDest
mov esi,[esp+0x10] // pszSrc1
mov ecx,[esp+0x14] // cch1
mov edi,[pszDest]
mov esi,[pszSrc1]
mov ecx,[cch1]
rep movsw
mov esi,[esp+0x18] // pszSrc2
mov ecx,[esp+0x1C] // cch2
mov esi,[pszSrc2]
mov ecx,[cch2]
rep movsw
xchg eax,edi
}
Expand All @@ -81,18 +73,15 @@ PWSTR SSCALL SSChainNCpy3FW( PWSTR pszDest, PCWSTR pszSrc1, SIZE_T cch1,
{
__asm
{
// The auto-generated pushing of edi and esi onto the stack means that
// our esp is offset by 8 bytes

mov edi,[esp+0x0C] // pszDest
mov esi,[esp+0x10] // pszSrc1
mov ecx,[esp+0x14] // cch1
mov edi,[pszDest]
mov esi,[pszSrc1]
mov ecx,[cch1]
rep movsw
mov esi,[esp+0x18] // pszSrc2
mov ecx,[esp+0x1C] // cch2
mov esi,[pszSrc2]
mov ecx,[cch2]
rep movsw
mov esi,[esp+0x20] // pszSrc3
mov ecx,[esp+0x24] // cch3
mov esi,[pszSrc3]
mov ecx,[cch3]
rep movsw
xchg eax,edi
}
Expand All @@ -102,21 +91,18 @@ PSTR SSCALL SSChainCpyCatA( PSTR pszDest, PCSTR pszSrc1, PCSTR pszSrc2 )
{
__asm
{
// The auto-generated pushing of edi and esi onto the stack means that
// our esp is offset by 8 bytes

xor eax,eax

mov esi,[esp+0x10] // pszSrc1
mov esi,[pszSrc1]
mov edi,esi
or ecx,-1
repnz scasb
not ecx
dec ecx
mov edi,[esp+0x0C] // pszDest
mov edi,[pszDest]
rep movsb

mov esi,[esp+0x14] // pszSrc2
mov esi,[pszSrc2]
push edi
mov edi,esi
or ecx,-1
Expand All @@ -133,21 +119,18 @@ PWSTR SSCALL SSChainCpyCatW( PWSTR pszDest, PCWSTR pszSrc1, PCWSTR pszSrc2 )
{
__asm
{
// The auto-generated pushing of edi and esi onto the stack means that
// our esp is offset by 8 bytes

xor eax,eax

mov esi,[esp+0x10] // pszSrc1
mov esi,[pszSrc1]
mov edi,esi
or ecx,-1
repnz scasw
not ecx
dec ecx
mov edi,[esp+0x0C] // pszDest
mov edi, [pszDest]
rep movsw

mov esi,[esp+0x14] // pszSrc2
mov esi, [pszSrc2]
push edi
mov edi,esi
or ecx,-1
Expand Down
5 changes: 3 additions & 2 deletions libs/SimpleString.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* SimpleString Library
* Last modified: 2009/01/06
* Copyright (C) Kai Liu. All rights reserved.
* Original work copyright (C) Kai Liu. All rights reserved.
* Modified work copyright (C) 2014 Christopher Gurnee. All rights reserved.
*
* This is a custom C string library that provides wide-character inline
* intrinsics for older compilers as well as some helpful chained functions.
Expand Down Expand Up @@ -187,7 +188,7 @@ __forceinline wchar_t * intrin_strcat_w( wchar_t *dest, const wchar_t *src )


#define SSINLINE __forceinline
#define SSCALL __stdcall
#define SSCALL


// BEGIN: SSCpyNCh -------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
#define HASHCHECK_NAME_STR "HashCheck Shell Extension"

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

// String version: May be any suitable string
#define HASHCHECK_VERSION_STR "2.2.1.4"
#define HASHCHECK_VERSION_STR "2.2.2.5"

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

0 comments on commit 5d426c4

Please sign in to comment.