-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodexsrv.cpp
executable file
·817 lines (651 loc) · 19.5 KB
/
codexsrv.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
# include "common_header.h"
# include "codex_srv_impl.h"
# include "codex_archive_impl.h"
# include "codex_cpl_impl.h"
volatile LONG g_nRefCounter = 0;
class CCodexSrvClassFactory :
IMPLEMENTS( IUnknown ),
IMPLEMENTS( IClassFactory ),
public CRefCounted
{
public:
virtual HRESULT
IUnknown_QueryInterface(
__in const IID & i_poReqIfaceId,
__out void** o_ppoIface )
{
if( ! VERIFY( o_ppoIface ) )
{
return E_INVALIDARG;
}
* o_ppoIface = 0;
if( __uuidof( IClassFactory ) == i_poReqIfaceId )
{
* o_ppoIface
= static_cast< IClassFactory* >(
static_cast< IClassFactory_wrap* >( this ) );
}
else if( __uuidof( IUnknown ) == i_poReqIfaceId )
{
* o_ppoIface
= static_cast< IUnknown* >(
static_cast< IUnknown_wrap* >( this ) );
}
else
{
return E_NOINTERFACE;
}
IUnknown_AddRef();
return S_OK;
}
virtual ULONG
IUnknown_AddRef( void )
{
return CRefCounted_AddRef();
}
virtual ULONG
IUnknown_Release( void )
{
//::MessageBoxW( 0, L"Class factory release", L"CodexSrv", 0 );
return CRefCounted_Release();
}
virtual HRESULT
IClassFactory_CreateInstance(
__in IUnknown* i_poIfaceOuter,
__in const IID & i_poReqIfaceId,
__out void** o_ppoIface )
{
//::MessageBoxW( 0, L"Create Instance called", L"CodexSrv", 0 );
if( ! VERIFY( o_ppoIface ) )
{
return E_INVALIDARG;
}
if( i_poIfaceOuter )
{
return CLASS_E_NOAGGREGATION;
}
* o_ppoIface = 0;
CodexSrv* poCodexSrv = new CodexSrv();
if( ! VERIFY( poCodexSrv ) )
{
return E_OUTOFMEMORY;
}
IUnknown* poIUnknown
= static_cast< IUnknown* >(
static_cast< IUnknown_wrap* >( poCodexSrv ) );
HRESULT hRes = poIUnknown->QueryInterface(
i_poReqIfaceId, o_ppoIface );
//VERIFY( S_OK == hRes );
poIUnknown->Release();
return hRes;
}
virtual HRESULT
IClassFactory_LockServer( BOOL i_fnLock )
{
if( i_fnLock )
{
::InterlockedIncrement( & g_nRefCounter );
}
else
{
//::MessageBoxW( 0, L"Unlock called", L"CodexSrv", 0 );
if( ! ::InterlockedDecrement( & g_nRefCounter ) )
{
::PostQuitMessage( 0 );
}
}
return S_OK;
}
};
CCodexSrvClassFactory* g_poCodexSrvClassFactory = 0;
extern BOOL RegUnregOrRun( CHAR* i_pczCmdLine, BOOL* o_pfnRun );
template< class T, size_t N >
struct ArrayAnyToChar_StubBB
{
static T* NN() { return (T*)N; }
};
// template< class T, T* N >
// char ( & ArrayAnyToChar_StubB( ( & )N ) )[ 5 ];
template< class T, size_t N >
ArrayAnyToChar_StubBB< T, N > ( & ArrayAnyToChar_StubB( T(&)[ N ] ))[ N ];
/*
int ( & someFn( void ) )[ 5 ]
{
int arr[ 5 ];
return arr;
}*/
template< size_t N >
void foo( int ( & arr )[ N ] )
{
}
struct SIntegralCTag
{
static const int value = 0;
};
template< int N >
struct SInt
{
static const int value = N;
typedef SInt type;
typedef int value_type;
typedef SIntegralCTag tag;
typedef SInt< static_cast< int >( value + 1 ) > next;
typedef SInt< static_cast< int >( value - 1 ) > prior;
operator int() const
{
return static_cast< int >( this->value );
}
};
template< int N >
int const SInt< N >::value;
template< bool C >
struct SBool
{
static const bool value = C;
typedef SIntegralCTag tag;
typedef SBool type;
typedef bool value_type;
operator bool( void ) const
{
return this->value;
}
};
typedef SBool< true > STrue;
typedef SBool< false > SFalse;
template< typename T, T N >
struct SIntegralC;
template < class T, T val >
struct SIntegralConstant :
public SIntegralC< T, val >
{
typedef SIntegralConstant< T, val > type;
};
template<>
struct SIntegralConstant< bool, true > :
public STrue
{
typedef SIntegralConstant< bool, true > type;
};
template<>
struct SIntegralConstant< bool, false > :
public SFalse
{
typedef SIntegralConstant< bool, false > type;
};
typedef SIntegralConstant< bool, true > STruetype;
typedef SIntegralConstant< bool, false > SFalsetype;
// Function Ptr Testers
typedef char YesType;
struct NoType
{
char padding[ 8 ];
};
// Note it is acceptible to use ellipsis here,
// since the argument will always be a pointer type of some sort:
NoType __cdecl IsFuncPtrTester( ... );
template < class R >
YesType IsFuncPtrTester( R (*)( void ) );
#ifndef IS_FUNC_TEST_NO_CHECK_ELLIPSIS
template <class R >
YesType IsFuncPtrTester(R (*)( ...));
#endif
#ifdef IS_FUNC_TEST_MS_SIGS
template <class R >
YesType IsFuncPtrTester(R (__stdcall*)());
template <class R >
YesType IsFuncPtrTester(R (__stdcall*)( ...));
template <class R >
YesType IsFuncPtrTester(R (__fastcall*)());
template <class R >
YesType IsFuncPtrTester(R (__fastcall*)( ...));
template <class R >
YesType IsFuncPtrTester(R (__cdecl*)());
template <class R >
YesType IsFuncPtrTester(R (__cdecl*)( ...));
#endif
template <class R , class T0 >
YesType IsFuncPtrTester(R (*)( T0));
#ifndef IS_FUNC_TEST_NO_CHECK_ELLIPSIS
template <class R , class T0 >
YesType IsFuncPtrTester(R (*)( T0 ...));
#endif
#ifdef IS_FUNC_TEST_MS_SIGS
template <class R , class T0 >
YesType IsFuncPtrTester(R (__stdcall*)( T0));
template <class R , class T0 >
YesType IsFuncPtrTester(R (__stdcall*)( T0 ...));
template <class R , class T0 >
YesType IsFuncPtrTester(R (__fastcall*)( T0));
template <class R , class T0 >
YesType IsFuncPtrTester(R (__fastcall*)( T0 ...));
template <class R , class T0 >
YesType IsFuncPtrTester(R (__cdecl*)( T0));
template <class R , class T0 >
YesType IsFuncPtrTester(R (__cdecl*)( T0 ...));
#endif
template <class R , class T0 , class T1 >
YesType IsFuncPtrTester(R (*)( T0 , T1));
#ifndef IS_FUNC_TEST_NO_CHECK_ELLIPSIS
template <class R , class T0 , class T1 >
YesType IsFuncPtrTester(R (*)( T0 , T1 ...));
#endif
#ifdef IS_FUNC_TEST_MS_SIGS
template <class R , class T0 , class T1 >
YesType IsFuncPtrTester(R (__stdcall*)( T0 , T1));
template <class R , class T0 , class T1 >
YesType IsFuncPtrTester(R (__stdcall*)( T0 , T1 ...));
template <class R , class T0 , class T1 >
YesType IsFuncPtrTester(R (__fastcall*)( T0 , T1));
template <class R , class T0 , class T1 >
YesType IsFuncPtrTester(R (__fastcall*)( T0 , T1 ...));
template <class R , class T0 , class T1 >
YesType IsFuncPtrTester(R (__cdecl*)( T0 , T1));
template <class R , class T0 , class T1 >
YesType IsFuncPtrTester(R (__cdecl*)( T0 , T1 ...));
#endif
template <class R , class T0 , class T1 , class T2 >
YesType IsFuncPtrTester(R (*)( T0 , T1 , T2));
#ifndef IS_FUNC_TEST_NO_CHECK_ELLIPSIS
template <class R , class T0 , class T1 , class T2 >
YesType IsFuncPtrTester(R (*)( T0 , T1 , T2 ...));
#endif
#ifdef IS_FUNC_TEST_MS_SIGS
template <class R , class T0 , class T1 , class T2 >
YesType IsFuncPtrTester(R (__stdcall*)( T0 , T1 , T2));
template <class R , class T0 , class T1 , class T2 >
YesType IsFuncPtrTester(R (__stdcall*)( T0 , T1 , T2 ...));
template <class R , class T0 , class T1 , class T2 >
YesType IsFuncPtrTester(R (__fastcall*)( T0 , T1 , T2));
template <class R , class T0 , class T1 , class T2 >
YesType IsFuncPtrTester(R (__fastcall*)( T0 , T1 , T2 ...));
template <class R , class T0 , class T1 , class T2 >
YesType IsFuncPtrTester(R (__cdecl*)( T0 , T1 , T2));
template <class R , class T0 , class T1 , class T2 >
YesType IsFuncPtrTester(R (__cdecl*)( T0 , T1 , T2 ...));
#endif
template <class R , class T0 , class T1 , class T2 , class T3 >
YesType IsFuncPtrTester(R (*)( T0 , T1 , T2 , T3));
#ifndef IS_FUNC_TEST_NO_CHECK_ELLIPSIS
template <class R , class T0 , class T1 , class T2 , class T3 >
YesType IsFuncPtrTester(R (*)( T0 , T1 , T2 , T3 ...));
#endif
#ifdef IS_FUNC_TEST_MS_SIGS
template <class R , class T0 , class T1 , class T2 , class T3 >
YesType IsFuncPtrTester(R (__stdcall*)( T0 , T1 , T2 , T3));
template <class R , class T0 , class T1 , class T2 , class T3 >
YesType IsFuncPtrTester(R (__stdcall*)( T0 , T1 , T2 , T3 ...));
template <class R , class T0 , class T1 , class T2 , class T3 >
YesType IsFuncPtrTester(R (__fastcall*)( T0 , T1 , T2 , T3));
template <class R , class T0 , class T1 , class T2 , class T3 >
YesType IsFuncPtrTester(R (__fastcall*)( T0 , T1 , T2 , T3 ...));
template <class R , class T0 , class T1 , class T2 , class T3 >
YesType IsFuncPtrTester(R (__cdecl*)( T0 , T1 , T2 , T3));
template <class R , class T0 , class T1 , class T2 , class T3 >
YesType IsFuncPtrTester(R (__cdecl*)( T0 , T1 , T2 , T3 ...));
#endif
template <class R , class T0 , class T1 , class T2 , class T3 , class T4 >
YesType IsFuncPtrTester(R (*)( T0 , T1 , T2 , T3 , T4));
#ifndef IS_FUNC_TEST_NO_CHECK_ELLIPSIS
template <class R , class T0 , class T1 , class T2 , class T3 , class T4 >
YesType IsFuncPtrTester(R (*)( T0 , T1 , T2 , T3 , T4 ...));
#endif
#ifdef IS_FUNC_TEST_MS_SIGS
template <class R , class T0 , class T1 , class T2 , class T3 , class T4 >
YesType IsFuncPtrTester(R (__stdcall*)( T0 , T1 , T2 , T3 , T4));
template <class R , class T0 , class T1 , class T2 , class T3 , class T4 >
YesType IsFuncPtrTester(R (__stdcall*)( T0 , T1 , T2 , T3 , T4 ...));
template <class R , class T0 , class T1 , class T2 , class T3 , class T4 >
YesType IsFuncPtrTester(R (__fastcall*)( T0 , T1 , T2 , T3 , T4));
template <class R , class T0 , class T1 , class T2 , class T3 , class T4 >
YesType IsFuncPtrTester(R (__fastcall*)( T0 , T1 , T2 , T3 , T4 ...));
template <class R , class T0 , class T1 , class T2 , class T3 , class T4 >
YesType IsFuncPtrTester(R (__cdecl*)( T0 , T1 , T2 , T3 , T4));
template <class R , class T0 , class T1 , class T2 , class T3 , class T4 >
YesType IsFuncPtrTester(R (__cdecl*)( T0 , T1 , T2 , T3 , T4 ...));
#endif
template< class R, class T0, class T1, class T2, class T3, class T4, class T5 >
YesType IsFuncPtrTester( R (*)( T0 , T1 , T2 , T3 , T4 , T5 ) );
#ifndef IS_FUNC_TEST_NO_CHECK_ELLIPSIS
template <class R , class T0 , class T1 , class T2 , class T3 , class T4 , class T5 >
YesType IsFuncPtrTester(R (*)( T0 , T1 , T2 , T3 , T4 , T5 ...));
#endif
#ifdef IS_FUNC_TEST_MS_SIGS
template <class R , class T0 , class T1 , class T2 , class T3 , class T4 , class T5 >
YesType IsFuncPtrTester(R (__stdcall*)( T0 , T1 , T2 , T3 , T4 , T5));
template <class R , class T0 , class T1 , class T2 , class T3 , class T4 , class T5 >
YesType IsFuncPtrTester(R (__stdcall*)( T0 , T1 , T2 , T3 , T4 , T5 ...));
template <class R , class T0 , class T1 , class T2 , class T3 , class T4 , class T5 >
YesType IsFuncPtrTester(R (__fastcall*)( T0 , T1 , T2 , T3 , T4 , T5));
template <class R , class T0 , class T1 , class T2 , class T3 , class T4 , class T5 >
YesType IsFuncPtrTester(R (__fastcall*)( T0 , T1 , T2 , T3 , T4 , T5 ...));
template <class R , class T0 , class T1 , class T2 , class T3 , class T4 , class T5 >
YesType IsFuncPtrTester(R (__cdecl*)( T0 , T1 , T2 , T3 , T4 , T5));
template <class R , class T0 , class T1 , class T2 , class T3 , class T4 , class T5 >
YesType IsFuncPtrTester(R (__cdecl*)( T0 , T1 , T2 , T3 , T4 , T5 ...));
#endif
// SIsFunc
template < typename T >
struct SIsFuncImpl
{
#pragma warning( push )
#pragma warning( disable: 6334 )
static T* t;
static const bool
value = sizeof( IsFuncPtrTester( t ) ) == sizeof( YesType );
#pragma warning( pop )
};
template < typename T >
struct SIsFuncImpl< T& > :
public SFalsetype
{
};
template< typename T >
struct SIsFunc :
SIntegralConstant< bool, SIsFuncImpl< T >::value >
{
};
// Counter
template< int N >
struct STheCounter;
template< typename T, int N = 5 >
struct SEncodeCounter
{
__if_exists( STheCounter< N + 256 > )
{
static const unsigned count = SEncodeCounter< T, N + 257 >::count;
}
__if_not_exists( STheCounter< N + 256 > )
{
__if_exists( STheCounter< N + 64 > )
{
static const unsigned count = SEncodeCounter< T, N + 65 >::count;
}
__if_not_exists( STheCounter< N + 64 > )
{
__if_exists( STheCounter< N + 16 > )
{
static const unsigned count = SEncodeCounter< T, N + 17 >::count;
}
__if_not_exists( STheCounter< N + 16 > )
{
__if_exists( STheCounter< N + 4 > )
{
static const unsigned count = SEncodeCounter< T, N + 5 >::count;
}
__if_not_exists( STheCounter< N + 4 > )
{
__if_exists( STheCounter< N > )
{
static const unsigned
count = SEncodeCounter< T, N + 1 >::count;
}
__if_not_exists( STheCounter< N > )
{
static const unsigned count = N;
typedef STheCounter< N > type;
}
}
}
}
}
};
// Extract type
struct SExtractTypeDefParam
{
};
template< typename ID, typename T = SExtractTypeDefParam >
struct SExtractType;
template< typename ID >
struct SExtractType< ID, SExtractTypeDefParam >
{
template< bool >
struct SId2TypeImpl;
typedef SId2TypeImpl< true > SId2Type;
};
template< typename ID, typename T >
struct SExtractType :
SExtractType< ID, SExtractTypeDefParam >
{
template<>
struct SId2TypeImpl< true > //VC8.0 specific bugfeature
{
typedef T type;
};
template< bool >
struct SId2TypeImpl;
typedef SId2TypeImpl< true > SId2Type;
};
// Register type
template< typename T, typename ID >
struct SRegisterType : SExtractType< ID, T >
{
};
//Tie it all together
template< typename T >
struct SEncodeType
{
//Get the next available compile time constants index
static const unsigned value = SEncodeCounter< T >::count;
//Instantiate the template
typedef typename SRegisterType< T, SInt< value > >::SId2Type type;
//Set the next compile time constants index
static const unsigned next = value + 1;
};
// SSizer
template< class T >
struct SSizer
{
typedef char( * type )[ SEncodeType< T >::value ];
};
// EncodeStart( T const & )
template < bool B, class T = void >
struct SDisableIfC
{
typedef T type;
};
template < class T >
struct SDisableIfC< true, T >
{
};
template < class Cond, class T = void >
struct SDisableIf :
public SDisableIfC< Cond::value, T >
{
};
template< typename T >
typename SDisableIf< typename SIsFunc< T >::type,
typename SSizer< T >::type
>::type
EncodeStart( T const & );
// EncodeStart( T & )
template < bool B, class T = void >
struct SEnableIfC
{
typedef T type;
};
template < class T >
struct SEnableIfC< false, T >
{
};
template < class Cond, class T = void >
struct SEnableIf :
public SEnableIfC< Cond::value, T >
{
};
template< typename T >
typename SEnableIf< typename SIsFunc< T >::type,
typename SSizer< T >::type
>::type
EncodeStart( T & );
// TypeID Wrapper
template< int ID >
struct STypeIdWrapper
{
typedef typename SExtractType< SInt< ID > >::SId2Type SId2Type;
typedef typename SId2Type::type Type;
};
// (Workaround for ETI-bug for VC6 and VC7)
template<>
struct STypeIdWrapper< 1 >
{
typedef STypeIdWrapper< 1 > Type;
};
// (Workaround for ETI-bug for VC7.1)
template<>
struct STypeIdWrapper< 4 >
{
typedef STypeIdWrapper< 4 > Type;
};
// Main Macro
#define VAR2TYPE( expr ) \
STypeIdWrapper< sizeof( * EncodeStart( expr ) ) >::Type
struct NIL { };
template< typename TFun >
struct FuncParser;
template<>
struct FuncParser< void WINAPI(void) >
{
static const int ParamsCount = 0;
static const int StackSize = 0;
};
template< typename TRet >
struct FuncParser< typename TRet WINAPI(void) >
{
static const int ParamsCount = 0;
struct SSizeTest
{
TRet ret;
};
static const int StackSize = sizeof( SSizeTest );
};
template< typename TRet, typename TArg0 >
struct FuncParser< typename TRet WINAPI( typename TArg0 ) >
{
static const int ParamsCount = 1;
struct SSizeTest
{
TRet ret;
TArg0 arg0;
};
static const int StackSize = sizeof( SSizeTest );
};
template< typename TRet, typename TArg0, typename TArg1 >
struct FuncParser< typename TRet WINAPI( typename TArg0, typename TArg1 ) >
{
static const int ParamsCount = 2;
struct SSizeTest
{
TRet ret;
TArg0 arg0;
TArg1 arg1;
};
static const int StackSize = sizeof( SSizeTest );
};
template< typename TRet, typename TArg0, typename TArg1, typename TArg2, typename TArg3, typename TArg4, typename TArg5 >
struct FuncParser< typename TRet WINAPI( typename TArg0, typename TArg1, typename TArg2, typename TArg3, typename TArg4, typename TArg5 ) >
{
static const int ParamsCount = 6;
struct SSizeTest
{
TRet ret;
TArg0 arg0;
TArg1 arg1;
TArg2 arg2;
TArg3 arg3;
TArg4 arg4;
TArg5 arg5;
};
static const int StackSize = sizeof( SSizeTest );
};
template< typename TRet, typename TArg0, typename TArg1, typename TArg2, typename TArg3, typename TArg4, typename TArg5, typename TArg6 >
struct FuncParser< typename TRet WINAPI( typename TArg0, typename TArg1, typename TArg2, typename TArg3, typename TArg4, typename TArg5, typename TArg6 ) >
{
static const int ParamsCount = 7;
struct SSizeTest
{
TRet ret;
TArg0 arg0;
TArg1 arg1;
TArg2 arg2;
TArg3 arg3;
TArg4 arg4;
TArg5 arg5;
TArg6 arg6;
};
static const int StackSize = sizeof( SSizeTest );
};
int WINAPI foo( int a )
{
return 5;
}
VAR2TYPE( foo ) bar;
int WINAPI bar( int a )
{
return 7;
}
INT WINAPI WinMain(
__in HINSTANCE i_hInst,
__in_opt HINSTANCE,
__in_opt CHAR* i_pczCmdLine,
__in int )
{
//void* abc[ 5 ] = { 0 };
//void** n = ArrayAnyToChar_StubB( abc )[ 0 ].NN();
int abc[ 5 ] = { 0 };
// foo( abc );
// someFn()[ 0 ] = 0;
VAR2TYPE( abc ) def = { 0 };
size_t argscnt = FuncParser< VAR2TYPE( foo ) >::ParamsCount;
size_t stacksize = FuncParser< VAR2TYPE( foo ) >::StackSize;
VAR2TYPE( foo )* fooPtr = foo;
fooPtr( 5 );
// STypeIdWrapper< sizeof( * EncodeStart( expr ) ) >::Type;
UNREFERENCED_PARAMETER( i_hInst );
BOOL fnStartServer = FALSE;
if( ! VERIFY( RegUnregOrRun( i_pczCmdLine, & fnStartServer ) ) )
{
return E_UNEXPECTED;
}
if( ! fnStartServer )
{
return S_OK;
}
//::MessageBoxW( 0, L"Attach to me!", L"CodexSrv", 0 );
HRESULT hRes = CoInitializeEx( 0, COINIT_APARTMENTTHREADED );
if( VERIFY( S_OK == hRes ) )
{
g_poCodexSrvClassFactory = new CCodexSrvClassFactory();
if( VERIFY( g_poCodexSrvClassFactory ) )
{
DWORD nClassObjId = 0;
hRes = ::CoRegisterClassObject(
__uuidof( CodexSrv ),
static_cast< IUnknown_wrap* >( g_poCodexSrvClassFactory ),
CLSCTX_LOCAL_SERVER,
REGCLS_SINGLEUSE,
& nClassObjId );
if( VERIFY( S_OK == hRes ) )
{
MSG oMsg = { 0 };
while( ::GetMessageW( & oMsg, 0, 0, 0 ) )
{
::DispatchMessageW( & oMsg );
}
hRes = ::CoRevokeClassObject( nClassObjId );
VERIFY( S_OK == hRes );
}
else
{
::MessageBoxW( 0, L"CoRegisterClassObject failed", L"CodexSrv", 0 );
}
g_poCodexSrvClassFactory->IUnknown_Release();
g_poCodexSrvClassFactory = 0;
}
else
{
hRes = E_OUTOFMEMORY;
}
::CoUninitialize();
}
return hRes;
}