From 5d426c459ad81c6ed3b6fcf7e71a63ce577b967f Mon Sep 17 00:00:00 2001 From: Christopher Gurnee Date: Sun, 7 Dec 2014 09:54:25 -0500 Subject: [PATCH] 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. --- libs/SimpleString.c | 83 ++++++++++++++++++--------------------------- libs/SimpleString.h | 5 +-- version.h | 4 +-- 3 files changed, 38 insertions(+), 54 deletions(-) diff --git a/libs/SimpleString.c b/libs/SimpleString.c index 70d9eda..8f66f5f 100644 --- a/libs/SimpleString.c +++ b/libs/SimpleString.c @@ -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" @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 @@ -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 diff --git a/libs/SimpleString.h b/libs/SimpleString.h index 059172d..ef6ed42 100644 --- a/libs/SimpleString.h +++ b/libs/SimpleString.h @@ -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. @@ -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 ------------------------------------------------------------- diff --git a/version.h b/version.h index 8ba7d30..0d7f9f7 100644 --- a/version.h +++ b/version.h @@ -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