1 #ifndef _MSWHELPER_H 2 #define _MSWHELPER_H 3 4 #include <ws2spi.h> 5 6 typedef struct { 7 DWORD bytesUsed; 8 DWORD bytesMax; 9 BYTE* buffer; 10 BYTE* bufendptr; // Pointer to the first "unused" byte 11 BOOL bufok; // FALSE if on mswBuffer-Function fails 12 } MSW_BUFFER, *PMSW_BUFFER; 13 14 void 15 mswBufferInit( 16 _Out_ PMSW_BUFFER mswBuf, 17 _In_ BYTE* buffer, 18 _In_ DWORD bufferSize); 19 20 BOOL 21 mswBufferCheck( 22 _Inout_ PMSW_BUFFER mswBuf, 23 _In_ DWORD count); 24 25 BOOL 26 mswBufferIncUsed( 27 _Inout_ PMSW_BUFFER mswBuf, 28 _In_ DWORD count); 29 30 BYTE* 31 mswBufferEndPtr( 32 _Inout_ PMSW_BUFFER mswBuf); 33 34 BOOL 35 mswBufferAppend( 36 _Inout_ PMSW_BUFFER mswBuf, 37 _In_ void *dataToAppend, 38 _In_ DWORD dataSize); 39 40 BOOL 41 mswBufferAppendStrA( 42 _Inout_ PMSW_BUFFER mswBuf, 43 _In_ char* str); 44 45 BOOL 46 mswBufferAppendStrW( 47 _Inout_ PMSW_BUFFER mswBuf, 48 _In_ WCHAR* str); 49 50 BOOL 51 mswBufferAppendPtr( 52 _Inout_ PMSW_BUFFER mswBuf, 53 _In_ void* ptr); 54 55 BOOL 56 mswBufferAppendLst( 57 _Inout_ PMSW_BUFFER mswBuf, 58 _In_ void **lst, 59 _In_ DWORD itemByteLength, 60 _In_opt_ int deltaofs); 61 62 BOOL 63 mswBufferAppendStrLstA( 64 _Inout_ PMSW_BUFFER mswBuf, 65 _In_ void **lst, 66 _In_opt_ int ptrofs); 67 68 BOOL 69 mswBufferAppendBlob_Hostent( 70 _Inout_ PMSW_BUFFER mswBuf, 71 _Inout_ LPWSAQUERYSETW lpRes, 72 _In_ char** hostAliasesA, 73 _In_ char* hostnameA, 74 _In_ DWORD ip4addr); 75 76 BOOL 77 mswBufferAppendBlob_Servent( 78 _Inout_ PMSW_BUFFER mswBuf, 79 _Inout_ LPWSAQUERYSETW lpRes, 80 _In_ char* serviceNameA, 81 _In_ char** serviceAliasesA, 82 _In_ char* protocolNameA, 83 _In_ WORD port); 84 85 BOOL 86 mswBufferAppendAddr_AddrInfoW( 87 _Inout_ PMSW_BUFFER mswBuf, 88 _Inout_ LPWSAQUERYSETW lpRes, 89 _In_ DWORD ip4addr); 90 91 WCHAR* 92 StrA2WHeapAlloc( 93 _In_opt_ HANDLE hHeap, 94 _In_ char* aStr); 95 96 char* 97 StrW2AHeapAlloc( 98 _In_opt_ HANDLE hHeap, 99 _In_ WCHAR* wStr); 100 101 WCHAR* 102 StrCpyHeapAllocW( 103 _In_opt_ HANDLE hHeap, 104 _In_ WCHAR* wStr); 105 106 char* 107 StrCpyHeapAllocA( 108 _In_opt_ HANDLE hHeap, 109 _In_ char* aStr); 110 111 /* strary: 112 ptr1 ... ptrn \0 113 data1 ... datan 114 */ 115 char** 116 StrAryCpyHeapAllocA( 117 _In_opt_ HANDLE hHeap, 118 _In_ char** aStrAry); 119 120 /* strary: 121 ptr1 ... ptrn \0 122 data1 ... datan 123 */ 124 char** 125 StrAryCpyHeapAllocWToA( 126 _In_opt_ HANDLE hHeap, 127 _In_ WCHAR** aStrAry); 128 129 #endif // _MSWHELPER_H 130