common_api.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. #pragma once
  2. #include <map>
  3. #include <string>
  4. #include <Rpc.h>
  5. #include <vector>
  6. #include "ResDataObject.h"
  7. using namespace std;
  8. bool AddEnvPath(const char *pPath);
  9. bool DelEnvPath(const char* pPath);
  10. UINT64 GetDay(UINT64 TheTime);
  11. __time64_t GetCurrentRealTimeOfStk();
  12. int CompareTimeByDay(UINT64 Prev, UINT64 Cur);
  13. bool string_2_guid(const char *pstr, GUID &stGuid);
  14. bool guid_2_string(GUID &stGuid, string &str);
  15. bool SplitString(const char *pString, string args, vector<string> &nodes);
  16. bool SplitTo84422222222String(const char *pString, vector<string> &nodes);
  17. bool CreateFileDirectory(string &FullFilePath);
  18. string FormatstdString(const char *pcFormat, ...);
  19. bool getBusIdFromFilePath(const char *pFilePath,string &BusId);
  20. bool SplitDevicePath(const char *pDevicePath, vector<string> &nodes);
  21. bool SplitDeviceList(const char* pDevicePath, vector<string>& nodes);
  22. bool MergeDevicePath(vector<string> &nodes, string &Devpath);
  23. string GetProcessDirectory();
  24. string GetFileTitle(string &fullpath);
  25. string GetFileName(string &fullpath);
  26. string & makeLowerStr(string & src);
  27. string GetFileDirectory(string &fullpath);
  28. bool FindSubVersionDirs(string rootDir, map<string, vector<string>>& dirlist);
  29. bool FindSortedSubFiles(string rootFile, vector<string> &filelist);
  30. void RawToHex(const char *pRaw, DWORD RawLen, string &Hex);
  31. string ReplaceSubString(string org, string &keystr, string &replacestr);
  32. string ReplaceFileTitle(string FilePath, string NewTitle);
  33. bool FindSubFiles(string rootDir, vector<string> &filelist, bool Recursive = true, string strWildcard = "*");
  34. void TransferModuleJosnConfig2DriverConfig(ResDataObject& config);
  35. template <class Type> bool StrToIntT(const char * str, Type *result)
  36. {
  37. Type value = 0;
  38. Type sign = 1;
  39. Type radix;
  40. if (str == NULL)
  41. {
  42. return false;
  43. }
  44. if (strlen(str) == 0)
  45. {
  46. return false;
  47. }
  48. if (*str == '-')
  49. {
  50. sign = -1;
  51. str++;
  52. }
  53. if (*str == '0' && (*(str + 1) == 'x' || *(str + 1) == 'X'))
  54. {
  55. radix = 16;
  56. str += 2;
  57. }
  58. //else if(*str == '0')
  59. //{
  60. // radix = 8;
  61. // str++;
  62. //}
  63. else
  64. {
  65. bool HitF = false;
  66. size_t Len = strlen(str);
  67. for (size_t i = 0; i < Len; i++)
  68. {
  69. if (str[i] >= '0' && str[i] <= '9')
  70. {
  71. continue;
  72. }
  73. HitF = true;
  74. break;
  75. }
  76. if (HitF)
  77. {
  78. radix = 16;
  79. }
  80. else
  81. {
  82. radix = 10;
  83. }
  84. }
  85. while (*str)
  86. {
  87. if (radix == 16)
  88. {
  89. if (*str >= '0' && *str <= '9')
  90. {
  91. value = value * radix + *str - '0';
  92. }
  93. else
  94. {
  95. if ((*str | 0x20) >= 'a' && (*str | 0x20) <= 'f')
  96. {
  97. value = value * radix + (*str | 0x20) - 'a' + 10;
  98. }
  99. else
  100. {
  101. return false;
  102. }
  103. }
  104. }
  105. else
  106. {
  107. value = value * radix + *str - '0';
  108. }
  109. str++;
  110. }
  111. *result = sign*value;
  112. return true;
  113. };
  114. class common_api
  115. {
  116. public:
  117. common_api(void);
  118. virtual ~common_api(void);
  119. HANDLE m_NotifyEvent;
  120. };
  121. using export_functions = std::tuple<string, DWORD, DWORD>;
  122. std::vector<export_functions> GetDllFunctionInfo(const char* moduleName);