// File DRAZEN_SVC_SERVER.cpp #include #include "DRAZEN_SVC_h.h" using namespace std; int main() { RPC_STATUS status; // Uses the protocol combined with the endpoint for receiving // remote procedure calls. /*Set the tcp endpoint*/ status = RpcServerUseProtseqEp( reinterpret_cast("ncacn_ip_tcp"), // Use TCP/IP // protocol. RPC_C_PROTSEQ_MAX_REQS_DEFAULT, // Backlog queue length for TCP/IP. reinterpret_cast("1337"), // TCP/IP port to use. NULL); // No security. if (status) exit(status); /*Set the named pipe endpoint*/ status = RpcServerUseProtseqEp( reinterpret_cast("ncacn_np"), // Use Named pipes over SMB NULL, reinterpret_cast("\\pipe\\drazen_svc"), // Named pipe to use NULL); // No security. if (status) exit(status); // Registers the DRAZEN_SVC interface status = RpcServerRegisterIf( drazen_svc_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); } void Hello_World(){ cout << "Hello Wolrd" << endl; } tptp1_struct_t TestPrimTypesPacking1( /* [in] */ small sm, /* [in] */ unsigned small usm, /* [in] */ short sh, /* [in] */ unsigned short ush, /* [in] */ long lo, /* [in] */ unsigned long ulo, /* [in] */ hyper hy, /* [in] */ MIDL_uhyper uhy, /* [in] */ boolean bo, /* [in] */ unsigned char ch, /* [in] */ byte by) { printf("[TestPrimTypesPacking1]\n"); printf("sm: %d\n", sm); printf("usm: %d\n", usm); printf("sh: %d\n", sh); printf("ush: %d\n", ush); printf("lo: %d\n", lo); printf("ulo: %d\n", ulo); printf("hy: %d\n", hy); printf("uhy: %d\n", uhy); printf("bo: %d\n", bo); printf("ch: %d\n", ch); printf("by: %d\n", by); tptp1_struct_t s_tptp1; s_tptp1.sm = sm; s_tptp1.usm = usm; s_tptp1.sh = sh; s_tptp1.ush = ush; s_tptp1.lo = lo; s_tptp1.ulo = ulo; s_tptp1.hy = uhy; s_tptp1.bo = bo; s_tptp1.ch = ch; s_tptp1.by = by; return s_tptp1; } tptp2_struct_t TestPrimTypesPacking2( /* [in] */ small sm, /* [in] */ short sh, /* [in] */ long lo, /* [in] */ small sm_, /* [in] */ hyper hy) { printf("[TestPrimTypesPacking2]\n"); printf("sm: %d\n", sm); printf("sh: %d\n", sh); printf("lo: %d\n", lo); printf("sm_: %d\n", sm_); printf("hy: %d\n", hy); tptp2_struct_t s_tptp2; s_tptp2.sm = sm; s_tptp2.sh = sh; s_tptp2.lo = lo; s_tptp2.sm_ = sm_; s_tptp2.hy = hy; return s_tptp2; } enum tptp3_enum_t TestPrimTypesPacking3( /* [in] */ enum tptp3_enum_t e1) { cout << "[TestPrimTypesPacking3]" << endl; printf("e1: %d\n", e1); return e1; } tufa_struct_t TestUniFixedArray( /* [in] */ small sm, /* [out][in] */ long longs[ 16 ], /* [in] */ small sm_, /* [out][in] */ short shorts[ 16 ], /* [in] */ small sm__, /* [out][in] */ threes_t threes[ 16 ]) { cout << "[TestUniFixedArray]" << endl; printf("sm: %d\n", sm); printf("longs: "); for(int i=0; i < 16; i++){ printf("%d ", longs[i]++); } printf("\n"); printf("sm_: %d\n", sm_); printf("shorts: "); for(int i=0; i < 16; i++){ printf("%d ", shorts[i]++); } printf("\n"); printf("sm__: %d\n", sm__); printf("threes: "); for(int i=0; i < 16; i++){ printf("%d %d %d ", threes[i].s1++, threes[i].s2++, threes[i].s3++); } printf("\n"); tufa_struct_t s_tufa; for(int i=0; i < 16; i++){ s_tufa.longs[i] = longs[i]; s_tufa.shorts[i] = shorts[i]; s_tufa.threes[i] = threes[i]; } return s_tufa; } /* [unique] */ tuca_struct_t *TestUniConfArray( /* [unique][out][in] */ small *ptr_s1, /* [size_is][out][in] */ long longs[ ], /* [unique][out][in] */ small *ptr_s2, /* [size_is][out][in] */ short shorts[ ], /* [unique][out][in] */ small *ptr_s3, /* [size_is][out][in] */ threes_t threes[ ]) { cout << "[TestUniConfArray]" << endl; printf("s1: %d\n", *ptr_s1); printf("longs: "); for(int i=0; i < *ptr_s1; i++){ printf("%d ", longs[i]); longs[i]++; } printf("\n"); printf("s2: %d\n", *ptr_s2); printf("shorts: "); for(int i=0; i < *ptr_s2; i++){ printf("%d ", shorts[i]); shorts[i]++; } printf("\n"); printf("s3: %d\n", *ptr_s3); printf("threes: "); for(int i=0; i < *ptr_s3; i++){ printf("%d %d %d ", threes[i].s1++, threes[i].s2++, threes[i].s3++); } printf("\n"); tuca_struct_t* s_tuca = (tuca_struct_t*)(malloc(100)); s_tuca->s3 = 5; for(int i=0; is3; i++){ s_tuca->threes[i].s1 = threes[i].s1; s_tuca->threes[i].s2 = threes[i].s2; s_tuca->threes[i].s3 = threes[i].s3; } return s_tuca; } tuva_struct_t TestUniVarArray( /* [in] */ small s1, /* [length_is][out][in] */ long longs[ 16 ], /* [in] */ small s2, /* [length_is][out][in] */ short shorts[ 16 ], /* [in] */ small s3, /* [length_is][out][in] */ threes_t threes[ 16 ]) { cout << "[TestUniVarArray]" << endl; printf("s1: %d\n", s1); printf("longs: "); for(int i=0; i < s1; i++){ printf("%d ", longs[i]++); } printf("\n"); printf("s2: %d\n", s2); printf("shorts: "); for(int i=0; i < s2; i++){ printf("%d ", shorts[i]++); } printf("\n"); printf("s3: %d\n", s3); printf("threes: "); for(int i=0; i < s3; i++){ printf("%d %d %d ", threes[i].s1++, threes[i].s2++, threes[i].s3++); } printf("\n"); tuva_struct_t s_tuva; s_tuva.s1 = 5; for(int i=0; is1); printf("s_ts1.shorts: \n\t"); for(int i=0; i < 3; i++){ for(int j=0; j < 3; j++){ printf("%d ", s_ts1->shorts[i][j]++); } printf("\n\t"); } printf("\n"); printf("s_ts1.s2: %d\n", s_ts1->s2); } ts2_struct_t* TestStructure2( /* [in] */ small sm, /* [ref][out][in] */ ts2_struct_t *s_ts2) { printf("[TestStructure2]\n"); printf("sm: %d\n", sm); printf("s_ts2.s1: %d\n", s_ts2->s1); printf("s_ts2.shorts: \n\t"); for(int i=0; i < s_ts2->s1; i++){ for(int j=0; j < s_ts2->s1; j++){ printf("%d ", ((s_ts2->shorts + i*s_ts2->s1 + j)[0][0])); } printf("\n\t"); } printf("\n"); return s_ts2; } void TestStructAlign1( /* [in] */ small s1, /* [in] */ tsa1_struct_t s_tsa1) { printf("[TestStructAlign1]\n"); printf("s1: %d\n", s1); printf("s_tsa1.sm: %d\n", s_tsa1.sm); printf("s_tsa1.sh: %d\n", s_tsa1.sh); } void TestStructAlign2( /* [in] */ small sm, /* [in] */ tsa2b_struct_t s_tsa2b) { printf("[TestStructAlign1]\n"); printf("sm: %d\n", sm); printf("s_tsa2b.lo: %d\n", s_tsa2b.lo); printf("s_tsa2b.tsa2a: %d, %d\n", s_tsa2b.s_tsa2a.lo,s_tsa2b.s_tsa2a.hy); } void TestStructure3( short _sh1, test_struct6_t _ts6) { printf("[TestStructure3]\n"); printf("_sh1: %d\n", _sh1); printf("_ts6.l: %d\n", _ts6.l); printf("_ts6.h: %d\n", _ts6.h); printf("_ts6.hypers:\n\t"); for(int i=0; i < _ts6.l; i++){ printf("%d ",_ts6.hypers[i]); } printf("\n"); printf("_ts6.s: %d\n", _ts6.s); printf("\n"); } void TestStructure4( /* [in] */ short _sh1, /* [ref][in] */ test_struct7_t *_ts7) { printf("[TestStructure4]\n"); printf("_sh1: %d\n", _sh1); printf("_ts7.l: %d\n", _ts7->l); printf("_ts7.h: %d\n", _ts7->h); printf("_ts7.hypers:\n\t"); for(int i=0; i < _ts7->l; i++){ printf("%d ",(_ts7->hypers+i)[0]); } printf("\n"); } void TestRefPtr1( /* [ref][in] */ small *_ps, /* [ref][in] */ short *_psh, /* [ref][in] */ long *_pl, /* [ref][in] */ hyper _phypers_fix[ 2 ], /* [size_is][ref][in] */ hyper _phypers_conf[ ], /* [length_is][ref][in] */ hyper _phypers_var[ 2 ], /* [length_is][size_is][ref][in] */ hyper _phypers_conf_var[ ]) { printf("[TestRefPtr1]\n"); printf("*_ps:%d \n", *_ps); printf("*_psh:%d \n", *_psh); printf("*_pl:%d \n", *_pl); printf("_phypers_fix: \n\t"); for(int i=0; i < 2; i++){ printf("%d ",_phypers_fix[i]); } printf("\n"); printf("_phypers_conf: \n\t"); for(int i=0; i < *_psh; i++){ printf("%d ",(_phypers_conf+i)[0]); } printf("\n"); printf("_phypers_var: \n\t"); for(int i=0; i < *_psh; i++){ printf("%d ",_phypers_var[i]); } printf("\n"); printf("_phypers_conf_Var: \n\t"); for(int i=0; i < *_psh; i++){ printf("%d ",(_phypers_conf_var+i)[0]); } printf("\n"); } void TestRefPtr2( /* [in] */ test_refptr1_t trp1) { printf("[TestRefPtr2]\n"); printf("*trp1.ps:%d \n", *(trp1.ps)); printf("*trp1.psh:%d \n", *(trp1.psh)); printf("*trp1.pl:%d \n", *(trp1.pl)); } void TestAll1( /* [in] */ small sm, /* [ref][in] */ small *smptrs[ 3 ], /* [full][in] */ test_all1_t *tal1, /* [full][in] */ test_all1_t *tal2) { printf("[TestAll1]\n"); printf("sm: %d\n", sm); printf("smptrs:\n\t"); for(int i=0; i < 3; i++) printf("%d ", *smptrs[i]); printf("\n"); printf("tal1:\n\t"); for(int i=0; i < 3; i++) printf("%d ", *(tal1->smptrs[i])); printf("\n"); printf("tal2:\n\t"); for(int i=0; i < 3; i++) printf("%d ", *(tal2->smptrs[i])); printf("\n"); }