// File Example1Server.cpp #include #include "DNSSERVER_TEST_h.h" using namespace std; int main() { RPC_STATUS status; // Uses the protocol combined with the endpoint for receiving // remote procedure calls. status = RpcServerUseProtseqEp( reinterpret_cast("ncacn_np"), // Use TCP/IP // protocol. RPC_C_PROTSEQ_MAX_REQS_DEFAULT, // Backlog queue length for TCP/IP. reinterpret_cast("\\pipe\\dnsserver_test"), // TCP/IP port to use. NULL); // No security. if (status) exit(status); // Registers the Example1 interface. status = RpcServerRegisterIf( dnsserver_test_v1_0_s_ifspec, // Interface to register. NULL, // Use the MIDL generated entry-point vector. NULL); // Use the MIDL generated entry-point vector. if (status) exit(status); // Start to listen for remote procedure calls for all registered interfaces. // This call will not return until RpcMgmtStopServerListening is called. status = RpcServerListen( 1, // Recommended minimum number of threads. RPC_C_LISTEN_MAX_CALLS_DEFAULT, // Recommended maximum number of threads. FALSE); // Start listening now. if (status) exit(status); } // Memory allocation function for RPC. // The runtime uses these two functions for allocating/deallocating // enough memory to pass the string to the server. void* __RPC_USER midl_user_allocate(size_t size) { return malloc(size); } // Memory deallocation function for RPC. void __RPC_USER midl_user_free(void* p) { free(p); } LONG R_DnssrvOperation( /* [string][unique][in] */ LPCWSTR pwszServerName, /* [string][unique][in] */ LPCSTR pszZone, /* [in] */ DWORD dwContext, /* [string][unique][in] */ LPCSTR pszOperation, /* [in] */ DWORD dwTypeId, /* [switch_is][in] */ DNSSRV_RPC_UNION pData) { cout << "R_DnssrvOperation" << endl; return -1; } void dump_utf16le(char* utf16le, char* ascii){ int i8 = 0; int i16 = 0; while(true){ ascii[i8] = utf16le[i16]; if(ascii[i8] == 0) break; i8++; i16 += 2; } } LONG R_DnssrvQuery( /* [string][unique][in] */ LPCWSTR pwszServerName, /* [string][unique][in] */ LPCSTR pszZone, /* [string][unique][in] */ LPCSTR pszOperation, /* [out] */ PDWORD pdwTypeId, /* [switch_is][out] */ DNSSRV_RPC_UNION *ppData) { char ascii[16]; cout << "R_DnssrvQuery" << endl; dump_utf16le((char*)pwszServerName, ascii); cout << "pwszServerName: " << ascii << endl; cout << "pszZone: " << pszZone << endl; cout << "pszOperation: " << pszOperation << endl; DWORD intA = 0xfafafafa; pdwTypeId = (PDWORD)&intA; DNSSRV_RPC_UNION b; ppData = (DNSSRV_RPC_UNION *)&b; return 0x12345678; } LONG R_DnssrvComplexOperation( /* [string][unique][in] */ LPCWSTR pwszServerName, /* [string][unique][in] */ LPCSTR pszZone, /* [string][unique][in] */ LPCSTR pszOperation, /* [in] */ DWORD dwTypeIn, /* [switch_is][in] */ DNSSRV_RPC_UNION pDataIn, /* [out] */ PDWORD pdwTypeOut, /* [switch_is][out] */ DNSSRV_RPC_UNION *ppDataOut) { cout << "R_DnssrvComplexOperation" << endl; return -1; } LONG R_DnssrvEnumRecords( /* [string][unique][in] */ LPCWSTR pwszServerName, /* [string][unique][in] */ LPCSTR pszZone, /* [string][unique][in] */ LPCSTR pszNodeName, /* [string][unique][in] */ LPCSTR pszStartChild, /* [in] */ WORD wRecordType, /* [in] */ DWORD fSelectFlag, /* [string][unique][in] */ LPCSTR pszFilterStart, /* [string][unique][in] */ LPCSTR pszFilterStop, /* [out] */ PDWORD pdwBufferLength, /* [size_is][size_is][out] */ PBYTE *ppBuffer) { cout << "R_EnumRecords" << endl; return -1; } LONG R_DnssrvUpdateRecord( /* [string][unique][in] */ LPCWSTR pwszServerName, /* [string][unique][in] */ LPCSTR pszZone, /* [string][in] */ LPCSTR pszNodeName, /* [unique][in] */ PDNS_RPC_RECORD pAddRecord, /* [unique][in] */ PDNS_RPC_RECORD pDeleteRecord) { cout << "R_DnssrvUpdateRecord" << endl; return -1; } LONG R_DnssrvOperation2( /* [in] */ handle_t hBindingHandle, /* [in] */ DWORD dwClientVersion, /* [in] */ DWORD dwSettingFlags, /* [string][unique][in] */ LPCWSTR pwszServerName, /* [string][unique][in] */ LPCSTR pszZone, /* [in] */ DWORD dwContext, /* [string][unique][in] */ LPCSTR pszOperation, /* [in] */ DWORD dwTypeId, /* [switch_is][in] */ DNSSRV_RPC_UNION pData) { cout << "R_DnssrvOperation2" << endl; return -1; } LONG R_DnssrvQuery2( /* [in] */ DWORD dwClientVersion, /* [in] */ DWORD dwSettingFlags, /* [string][unique][in] */ LPCWSTR pwszServerName, /* [string][unique][in] */ LPCSTR pszZone, /* [string][unique][in] */ LPCSTR pszOperation, /* [out] */ PDWORD pdwTypeId, /* [switch_is][out] */ DNSSRV_RPC_UNION *ppData) { cout << "R_DnssrvQuery2" << endl; return -1; } LONG R_DnssrvComplexOperation2( /* [in] */ DWORD dwClientVersion, /* [in] */ DWORD dwSettingFlags, /* [string][unique][in] */ LPCWSTR pwszServerName, /* [string][unique][in] */ LPCSTR pszZone, /* [string][unique][in] */ LPCSTR pszOperation, /* [in] */ DWORD dwTypeIn, /* [switch_is][in] */ DNSSRV_RPC_UNION pDataIn, /* [out] */ PDWORD pdwTypeOut, /* [switch_is][out] */ DNSSRV_RPC_UNION *ppDataOut) { cout << "R_DnssrvComplexOperation2" << endl; return -1; } LONG R_DnssrvEnumRecords2( /* [in] */ DWORD dwClientVersion, /* [in] */ DWORD dwSettingFlags, /* [string][unique][in] */ LPCWSTR pwszServerName, /* [string][unique][in] */ LPCSTR pszZone, /* [string][unique][in] */ LPCSTR pszNodeName, /* [string][unique][in] */ LPCSTR pszStartChild, /* [in] */ WORD wRecordType, /* [in] */ DWORD fSelectFlag, /* [string][unique][in] */ LPCSTR pszFilterStart, /* [string][unique][in] */ LPCSTR pszFilterStop, /* [out] */ PDWORD pdwBufferLength, /* [size_is][size_is][out] */ PBYTE *ppBuffer) { cout << "R_DnssrvEnumRecords2" << endl; return -1; } LONG R_DnssrvUpdateRecord2( /* [in] */ DWORD dwClientVersion, /* [in] */ DWORD dwSettingFlags, /* [string][unique][in] */ LPCWSTR pwszServerName, /* [string][unique][in] */ LPCSTR pszZone, /* [string][in] */ LPCSTR pszNodeName, /* [unique][in] */ PDNS_RPC_RECORD pAddRecord, /* [unique][in] */ PDNS_RPC_RECORD pDeleteRecord) { cout << "R_DnssrvUpdateRecord2" << endl; return -1; }