Pushok

Dll Test

Apr 1st, 2011
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include "windows.h"
  2.  
  3. extern "C" __declspec(dllexport) int  StrLength(const char* str);
  4. extern "C" __declspec(dllexport) void StrConcat(char* str, const char* str1);
  5. extern "C" __declspec(dllexport) void StrCopy(char* str, const char* str1);
  6. extern "C" __declspec(dllexport) void StrReverse(char* str);
  7.  
  8. BOOL APIENTRY DllMain(_In_ void * _HDllHandle, _In_ unsigned _Reason, _In_opt_ void * _Reserved)
  9. {
  10.     return TRUE;
  11. }
  12.  
  13. int StrLength(const char* str)
  14. {
  15.     DWORD i = 0;
  16.     while(*str++) i++;
  17.     return i;
  18. }
  19.  
  20. void StrConcat(char* str, const char* str1)
  21. {
  22.     for(int i=StrLength(str)-1, j=0; i < StrLength(str) + StrLength(str1) - 1; i++, j++)
  23.     {
  24.         *(str+i) = *(str1+j);
  25.     }
  26. }
  27.  
  28. void StrCopy(char* str, const char* str1)
  29. {
  30.     while(*str++ = *str1++);
  31. }
  32.  
  33. void StrReverse(char* str)
  34. {
  35.     int i = StrLength(str);
  36.     for(int j = 0; j < i / 2; j++, i--)
  37.     {
  38.         char ch = str[i];
  39.         str[i] = str[j];
  40.         str[j] = ch;
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment